@rainmanhhh/pi-web 0.14.2 → 0.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server.mjs +1 -1
- package/dist/static/assets/{CodeMirrorEditor-8bwgbhKt.js → CodeMirrorEditor-DSMafr9-.js} +1 -1
- package/dist/static/assets/architecture-YZFGNWBL-CVvRajjQ.js +1 -0
- package/dist/static/assets/{architectureDiagram-Q4EWVU46-CKc2igpM.js → architectureDiagram-Q4EWVU46-BKXGUEon.js} +1 -1
- package/dist/static/assets/{blockDiagram-DXYQGD6D-DlptypHr.js → blockDiagram-DXYQGD6D-DtHKKnNV.js} +1 -1
- package/dist/static/assets/{c4Diagram-AHTNJAMY-tcmYnJoV.js → c4Diagram-AHTNJAMY-DfNjdjag.js} +1 -1
- package/dist/static/assets/channel-32A1CqdZ.js +1 -0
- package/dist/static/assets/{chunk-4TB4RGXK-B4MWr7LS.js → chunk-4TB4RGXK-CQQfRY6d.js} +1 -1
- package/dist/static/assets/{chunk-5FUZZQ4R-BG7AmZxO.js → chunk-5FUZZQ4R-BT9--VMU.js} +1 -1
- package/dist/static/assets/{chunk-5PVQY5BW-CFfysGpU.js → chunk-5PVQY5BW-E7SGdWgk.js} +1 -1
- package/dist/static/assets/{chunk-EDXVE4YY-CfSImrW2.js → chunk-EDXVE4YY-DU7Uv6vE.js} +1 -1
- package/dist/static/assets/{chunk-ENJZ2VHE-DOpxVTJu.js → chunk-ENJZ2VHE-DQtmTAKW.js} +1 -1
- package/dist/static/assets/{chunk-ICPOFSXX-C6tkNhxV.js → chunk-ICPOFSXX-mnPIMDGh.js} +1 -1
- package/dist/static/assets/{chunk-K5T4RW27-mlfukfRz.js → chunk-K5T4RW27-FZnXJnjE.js} +1 -1
- package/dist/static/assets/{chunk-OYMX7WX6-Bksi0Mih.js → chunk-OYMX7WX6-BYnOHrZV.js} +1 -1
- package/dist/static/assets/{chunk-U2HBQHQK-DXHG5R00.js → chunk-U2HBQHQK-g05X_MA6.js} +1 -1
- package/dist/static/assets/{chunk-X2U36JSP-BdkhkF1p.js → chunk-X2U36JSP-BZPGf1aL.js} +1 -1
- package/dist/static/assets/{chunk-YZCP3GAM-DNYSkKU3.js → chunk-YZCP3GAM-B8imZryx.js} +1 -1
- package/dist/static/assets/{chunk-ZZ45TVLE-CFME0Xlo.js → chunk-ZZ45TVLE-BJ_TZvey.js} +1 -1
- package/dist/static/assets/classDiagram-6PBFFD2Q-C5GB6FiX.js +1 -0
- package/dist/static/assets/classDiagram-v2-HSJHXN6E-C5GB6FiX.js +1 -0
- package/dist/static/assets/clone-B3ii8qUC.js +1 -0
- package/dist/static/assets/{dagre-BU_8Q1BK.js → dagre-BKbOt7ji.js} +1 -1
- package/dist/static/assets/{dagre-KV5264BT-D7rX3jnO.js → dagre-KV5264BT-DgSY2Ba5.js} +1 -1
- package/dist/static/assets/{diagram-5BDNPKRD-Cm1isCIv.js → diagram-5BDNPKRD-BXNflAsd.js} +1 -1
- package/dist/static/assets/{diagram-G4DWMVQ6-vHV3JW33.js → diagram-G4DWMVQ6-DzS9xfX_.js} +1 -1
- package/dist/static/assets/{diagram-MMDJMWI5-BQc5V9vg.js → diagram-MMDJMWI5-BoG2YV2C.js} +1 -1
- package/dist/static/assets/{diagram-TYMM5635-CZwsW2Pr.js → diagram-TYMM5635-U2rjNzQx.js} +1 -1
- package/dist/static/assets/{erDiagram-SMLLAGMA-CeEcpQUf.js → erDiagram-SMLLAGMA-CHTodmHm.js} +1 -1
- package/dist/static/assets/{flatten-DQzG0m2h.js → flatten-C_yBBeSl.js} +1 -1
- package/dist/static/assets/{flowDiagram-DWJPFMVM-yOcQnWhz.js → flowDiagram-DWJPFMVM-DFu_v3fI.js} +1 -1
- package/dist/static/assets/{ganttDiagram-T4ZO3ILL-DD39n1rG.js → ganttDiagram-T4ZO3ILL-CUCMHyF5.js} +1 -1
- package/dist/static/assets/gitGraph-7Q5UKJZL-BuXuhPqP.js +1 -0
- package/dist/static/assets/{gitGraphDiagram-UUTBAWPF-D-GatTTx.js → gitGraphDiagram-UUTBAWPF-rfqjvQ6E.js} +1 -1
- package/dist/static/assets/{graphlib-DKC1qYM0.js → graphlib-xGFxrNAo.js} +1 -1
- package/dist/static/assets/{highlighted-body-OFNGDK62-On_DQ4Qj.js → highlighted-body-OFNGDK62-D4klPf9N.js} +1 -1
- package/dist/static/assets/{index-BTGDN9pw.js → index-CIK1v_mV.js} +69 -69
- package/dist/static/assets/{index-gILWY8jP.css → index-ChUDiDlj.css} +1 -1
- package/dist/static/assets/info-OMHHGYJF-DonquLJ0.js +1 -0
- package/dist/static/assets/{infoDiagram-42DDH7IO-BAItLAUw.js → infoDiagram-42DDH7IO-Bi1fBDfH.js} +1 -1
- package/dist/static/assets/{ishikawaDiagram-UXIWVN3A-B3pEDdQ6.js → ishikawaDiagram-UXIWVN3A-D8NN32RZ.js} +1 -1
- package/dist/static/assets/{journeyDiagram-VCZTEJTY-BjL6nVrF.js → journeyDiagram-VCZTEJTY-C-_XrW_o.js} +1 -1
- package/dist/static/assets/{kanban-definition-6JOO6SKY-CgWISWEF.js → kanban-definition-6JOO6SKY-SCLxIrx0.js} +1 -1
- package/dist/static/assets/{line-CT5lbgtU.js → line-CVjASbT7.js} +1 -1
- package/dist/static/assets/mermaid-GHXKKRXX-BNiS2a30.js +1 -0
- package/dist/static/assets/{mermaid-parser.core-DUK85858.js → mermaid-parser.core-CtITMJFU.js} +2 -2
- package/dist/static/assets/{mermaid.core-CqS5xRTZ.js → mermaid.core-B5Pfvt4i.js} +4 -4
- package/dist/static/assets/{mindmap-definition-QFDTVHPH-IBrutOhs.js → mindmap-definition-QFDTVHPH-CUnhD8xy.js} +1 -1
- package/dist/static/assets/packet-4T2RLAQJ-TWy53oeO.js +1 -0
- package/dist/static/assets/pie-ZZUOXDRM-BYJc_hio.js +1 -0
- package/dist/static/assets/{pieDiagram-DEJITSTG-DyG6TsT0.js → pieDiagram-DEJITSTG-0bhPCKQn.js} +1 -1
- package/dist/static/assets/{quadrantDiagram-34T5L4WZ-CSsu0EuU.js → quadrantDiagram-34T5L4WZ-DbYQ_K2d.js} +1 -1
- package/dist/static/assets/radar-PYXPWWZC-BsGfyi_n.js +1 -0
- package/dist/static/assets/{reduce-BHCewYyP.js → reduce-NfeZfRJU.js} +1 -1
- package/dist/static/assets/{requirementDiagram-MS252O5E-D0VuG1BI.js → requirementDiagram-MS252O5E-iApTZcp4.js} +1 -1
- package/dist/static/assets/{sankeyDiagram-XADWPNL6-C0xN882Q.js → sankeyDiagram-XADWPNL6-BxUa_NbO.js} +1 -1
- package/dist/static/assets/{sequenceDiagram-FGHM5R23-C5ymOn11.js → sequenceDiagram-FGHM5R23-UOp8Uvyb.js} +1 -1
- package/dist/static/assets/{stateDiagram-FHFEXIEX-Dn-QersK.js → stateDiagram-FHFEXIEX-CNBP6z0s.js} +1 -1
- package/dist/static/assets/stateDiagram-v2-QKLJ7IA2-BUu6wXtb.js +1 -0
- package/dist/static/assets/{timeline-definition-GMOUNBTQ-DeIq44bw.js → timeline-definition-GMOUNBTQ-BMUBUtVF.js} +1 -1
- package/dist/static/assets/treeView-SZITEDCU-LMyV2xPx.js +1 -0
- package/dist/static/assets/treemap-W4RFUUIX-Clk0YF-c.js +1 -0
- package/dist/static/assets/{vennDiagram-DHZGUBPP-BrJEi36o.js → vennDiagram-DHZGUBPP-_tA3-C6y.js} +1 -1
- package/dist/static/assets/wardley-RL74JXVD-CjrClIuS.js +1 -0
- package/dist/static/assets/{wardleyDiagram-NUSXRM2D-C6MThXKC.js → wardleyDiagram-NUSXRM2D-DSU7lqhe.js} +1 -1
- package/dist/static/assets/{xychartDiagram-5P7HB3ND-Bbnfx82-.js → xychartDiagram-5P7HB3ND-C6ldupwG.js} +1 -1
- package/dist/static/index.html +2 -2
- package/package.json +1 -1
- package/dist/static/assets/architecture-YZFGNWBL-odEWyhpp.js +0 -1
- package/dist/static/assets/channel-hZgkjJkW.js +0 -1
- package/dist/static/assets/classDiagram-6PBFFD2Q-Dj9SC5Hf.js +0 -1
- package/dist/static/assets/classDiagram-v2-HSJHXN6E-Dj9SC5Hf.js +0 -1
- package/dist/static/assets/clone-ChX467wi.js +0 -1
- package/dist/static/assets/gitGraph-7Q5UKJZL-DkJ07MaR.js +0 -1
- package/dist/static/assets/info-OMHHGYJF-7apwdS_N.js +0 -1
- package/dist/static/assets/mermaid-GHXKKRXX-CmTuLrk-.js +0 -1
- package/dist/static/assets/packet-4T2RLAQJ-DH1U2n71.js +0 -1
- package/dist/static/assets/pie-ZZUOXDRM-s3GaMhNd.js +0 -1
- package/dist/static/assets/radar-PYXPWWZC-D0eR_IOT.js +0 -1
- package/dist/static/assets/stateDiagram-v2-QKLJ7IA2-CAi9dK0Q.js +0 -1
- package/dist/static/assets/treeView-SZITEDCU-Ct-rIIyE.js +0 -1
- package/dist/static/assets/treemap-W4RFUUIX-CxzGzM6J.js +0 -1
- package/dist/static/assets/wardley-RL74JXVD-B2ugemaV.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/highlighted-body-OFNGDK62-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/highlighted-body-OFNGDK62-D4klPf9N.js","assets/rolldown-runtime-C_s2cVnS.js","assets/mermaid.core-B5Pfvt4i.js","assets/_baseFor-D6HAxaEF.js","assets/src-D3QavEJ4.js","assets/chunk-ICPOFSXX-mnPIMDGh.js","assets/chunk-5PVQY5BW-E7SGdWgk.js","assets/dist-C_yfW-4f.js","assets/chunk-U2HBQHQK-g05X_MA6.js","assets/chunk-BSJP7CBP-BclwT518.js","assets/chunk-ZZ45TVLE-BJ_TZvey.js","assets/chunk-X2U36JSP-BZPGf1aL.js","assets/chunk-5FUZZQ4R-BT9--VMU.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-ENJZ2VHE-DQtmTAKW.js","assets/line-CVjASbT7.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js","assets/CodeMirrorEditor-DSMafr9-.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{o as e,r as t,t as n}from"./rolldown-runtime-C_s2cVnS.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var r=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(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 N(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,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+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+j(a,u),c+=N(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+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(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 P(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ee(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 F=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)},te={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=te,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=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ee}},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,F)}catch(e){F(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.4`})),i=n(((e,t)=>{t.exports=r()})),a=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(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,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),o=n(((e,t)=>{t.exports=a()})),s=n((e=>{var t=i();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var a={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return s(e,t,null,r)},e.flushSync=function(e){var t=c.T,n=a.p;try{if(c.T=null,a.p=2,e)return e()}finally{c.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??a.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=l(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else a.d.m(e)}},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.4`})),c=n(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=s()})),l=n((e=>{var t=o(),n=i(),r=c();function a(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function l(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function u(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function f(e){if(l(e)!==e)throw Error(a(188))}function p(e){var t=e.alternate;if(!t){if(t=l(e),t===null)throw Error(a(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return f(i),e;if(o===r)return f(i),t;o=o.sibling}throw Error(a(188))}if(n.return!==r.return)n=i,r=o;else{for(var s=!1,c=i.child;c;){if(c===n){s=!0,n=i,r=o;break}if(c===r){s=!0,r=i,n=o;break}c=c.sibling}if(!s){for(c=o.child;c;){if(c===n){s=!0,n=o,r=i;break}if(c===r){s=!0,r=o,n=i;break}c=c.sibling}if(!s)throw Error(a(189))}}if(n.alternate!==r)throw Error(a(190))}if(n.tag!==3)throw Error(a(188));return n.stateNode.current===n?e:t}function m(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=m(e),t!==null)return t;e=e.sibling}return null}var h=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),A=Symbol.for(`react.memo_cache_sentinel`),j=Symbol.iterator;function M(e){return typeof e!=`object`||!e?null:(e=j&&e[j]||e[`@@iterator`],typeof e==`function`?e:null)}var N=Symbol.for(`react.client.reference`);function P(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===N?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 k: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 D:return t=e.displayName||null,t===null?P(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return P(e(t))}catch{}}return null}var ee=Array.isArray,F=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne={pending:!1,data:null,method:null,action:null},re=[],ie=-1;function ae(e){return{current:e}}function oe(e){0>ie||(e.current=re[ie],re[ie]=null,ie--)}function I(e,t){ie++,re[ie]=e.current,e.current=t}var L=ae(null),se=ae(null),R=ae(null),ce=ae(null);function le(e,t){switch(I(R,t),I(se,e),I(L,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?nf(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=nf(t),e=rf(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}oe(L),I(L,e)}function ue(){oe(L),oe(se),oe(R)}function de(e){e.memoizedState!==null&&I(ce,e);var t=L.current,n=rf(t,e.type);t!==n&&(I(se,e),I(L,n))}function fe(e){se.current===e&&(oe(L),oe(se)),ce.current===e&&(oe(ce),pp._currentValue=ne)}var pe,me;function he(e){if(pe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);pe=t&&t[1]||``,me=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+pe+e+me}var ge=!1;function _e(e,t){if(!e||ge)return``;ge=!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(`
|
|
@@ -345,45 +345,45 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
345
345
|
`:`
|
|
346
346
|
`,n=e.split(/\r?\n/),r=[],i=null,a=0,o=null;for(let e=0;e<n.length;e++){let t=n[e];if(o){r.push(t),RegExp(`</${o}\\s*>`,`i`).test(t)&&(o=null);continue}let s=t.match(/^ {0,3}(`{3,}|~{3,})/);if(s){let e=s[1][0],n=s[1].length;i?e===i.marker&&n>=i.size&&(i=null):i={marker:e,size:n},a=0,r.push(t);continue}if(i){r.push(t);continue}let c=t.match(/<(code|pre|script|style)\b/i);if(c){let e=c[1].toLowerCase(),n=t.slice((c.index??0)+c[0].length);RegExp(`</${e}\\s*>`,`i`).test(n)||(o=e),a=0,r.push(t);continue}if(/^(?: {4}|\t)/.test(t)||t.trim()===``){a=0,r.push(t);continue}if(a||t.includes("`")){a=uG(t,a),r.push(t);continue}let l=t.match(/^([ ]{0,3})\\\[[ \t]*(.+?)[ \t]*\\\][ \t]*$/);if(l){let e=l[2].trim();if(e){r.push(`${l[1]}$$`,e,`${l[1]}$$`);continue}}let u=t.match(/^([ ]{0,3})\\\[[ \t]*$/);if(u){let t=lG(n,e+1);if(t!==-1){r.push(`${u[1]}$$`,...n.slice(e+1,t),`${u[1]}$$`),e=t;continue}}let d=t.match(/^([ \t]{0,3})\$\$(.+)\$\$[ \t]*$/);if(d){let e=d[2].trim();if(e){r.push(`${d[1]}$$`,e,`${d[1]}$$`);continue}}r.push(dG(t))}return r.join(t)}function lG(e,t){for(let n=t;n<e.length;n++){let t=e[n];if(/^ {0,3}\\\][ \t]*$/.test(t))return n;if(/^ {0,3}(`{3,}|~{3,})/.test(t)||/^ {0,3}\\\[[ \t]*$/.test(t)||/<(code|pre|script|style)\b/i.test(t))return-1}return-1}function uG(e,t){let n=t;for(let t=0;t<e.length;){if(e[t]!=="`"){t++;continue}let r=t+1;for(;e[r]==="`";)r++;let i=r-t;n===0?n=i:i===n&&(n=0),t=r}return n}function dG(e){return/^\s{0,3}\[[^\]]+\]:/.test(e)||/]\s*\(/.test(e)||/<(?:!--|\/?[A-Za-z][^>]*>)/.test(e)||/\b(?:https?|file|mailto):/i.test(e)||/\b[A-Za-z]:\\/.test(e)?e:e.replace(/(?<!\\)\\\(([^`\r\n$]+?)(?<!\\)\\\)/g,(e,t)=>t.trim()?`$${t}$`:e)}var fG=[JW,oG],pG=[JW,oG],mG=[kV,[JV,sG],[OI,{throwOnError:!1,strict:!1}]],hG=[kV,[JV,sG],[OI,{throwOnError:!1,strict:!1}]];function gG(e){return/^[!+-].+/.test(e.trim())}function _G(e){return/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith(`\\\\`)?e.replace(/\\/g,`/`):e}function vG(e){return _G(e).split(`/`).filter(Boolean).map(encodeURIComponent).join(`/`)}function yG(e){let t=_G(e).replace(/\/+$/,``);return t.split(`/`).pop()??t}function bG(e){let t=_G(e).replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n<0?``:n===0?`/`:n===2&&/^[a-zA-Z]:\//.test(t)?t.slice(0,3):t.slice(0,n)}function xG(e,t){if(!t)return e;let n=_G(e),r=_G(t).replace(/\/$/,``);return n.startsWith(`${r}/`)?n.slice(r.length+1):e}function SG(e,t){return`${_G(e).replace(/\/$/,``)}/${t}`}function CG({className:e,type:t,...n}){return(0,E.jsx)(`input`,{type:t,"data-slot":`input`,className:Cm(`h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...n})}async function wG(e){let t=e?`?path=${encodeURIComponent(e)}`:``,n=await fetch(`/api/cwd/browse${t}`),r=await n.json();if(!n.ok||r.error)throw Error(r.error??`HTTP ${n.status}`);return r}var TG={backgroundColor:`#ffffff`,color:`#0f1115`};function EG(){return(0,E.jsx)(`svg`,{width:p.xl,height:p.xl,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.3`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M1.5 3h4l1.5 2h7.5v7.5h-13z`})})}function DG(){return(0,E.jsxs)(`svg`,{width:p.xl,height:p.xl,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.3`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`rect`,{x:`2`,y:`3`,width:`12`,height:`10`,rx:`1.5`}),(0,E.jsx)(`path`,{d:`M2 9h12`}),(0,E.jsx)(`circle`,{cx:`11.5`,cy:`11`,r:`0.6`,fill:`currentColor`,stroke:`none`})]})}function OG(e){return/^[a-zA-Z]:[\\/]?$/.test(e)}function kG(){return(0,E.jsxs)(`svg`,{width:p.xl,height:p.xl,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.3`,"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`M4 1.5h5l3 3v10h-8z`}),(0,E.jsx)(`path`,{d:`M9 1.5v3h3`})]})}function AG(e){return e.replace(/\\/g,`/`)}function jG({open:e,onCancel:t,onConfirm:n,title:r,confirmText:i,cancelText:a,noteLabel:o,notePlaceholder:s,busy:c=!1,error:l,showFiles:u=!0,showExtensionFilter:f=!1,extensionOptions:m=[],initialPath:h}){let{t:g}=N(),[_,v]=(0,d.useState)(``),[y,b]=(0,d.useState)(null),[x,S]=(0,d.useState)(``),[C,w]=(0,d.useState)([]),[T,D]=(0,d.useState)([]),[O,k]=(0,d.useState)(null),[A,j]=(0,d.useState)(null),[M,P]=(0,d.useState)(``),[ee,F]=(0,d.useState)(``),[te,ne]=(0,d.useState)(``),[re,ie]=(0,d.useState)(null),[ae,oe]=(0,d.useState)(!0),I=(0,d.useRef)(null),L=(0,d.useCallback)(async e=>{oe(!0),ie(null);try{let t=await wG(e),n=AG(t.path??e??`/`);v(n),b(t.parentPath?AG(t.parentPath):null),S(n),w((t.directories??[]).map(e=>({...e,path:AG(e.path)}))),D((t.files??[]).map(e=>({...e,path:AG(e.path)}))),k(t.drives??null),j(null),F(``),ne(``)}catch(e){ie(e instanceof Error?e.message:String(e))}finally{oe(!1)}},[]);(0,d.useEffect)(()=>{e&&(P(``),L(h))},[e,L,h]);let se=e=>{e.preventDefault();let t=AG(x.trim());t&&L(t)},R=!!y||OG(_),ce=ee.trim().toLowerCase(),le=e=>!ce||e.toLowerCase().includes(ce),ue=O===null?[]:O.filter(e=>le(e.name)||le(e.path)),de=C.filter(e=>le(e.name)),fe=u?T.filter(e=>le(e.name)).filter(e=>!te||e.name.toLowerCase().endsWith(te.toLowerCase())):[],pe=!!A&&!c;return(0,E.jsx)(Ax,{open:e,onOpenChange:e=>{!e&&!c&&t()},children:(0,E.jsxs)(Px,{className:`directory-picker-light flex w-[520px] max-w-[calc(100vw-16px)] flex-col gap-0 overflow-hidden p-0`,style:{height:`min(620px, calc(100dvh - 16px))`},showCloseButton:!1,onPointerDownOutside:e=>{c&&e.preventDefault()},onEscapeKeyDown:e=>{c&&e.preventDefault()},onOpenAutoFocus:e=>{e.preventDefault(),I.current?.focus()},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,flexShrink:0,padding:`12px 18px`,borderBottom:`1px solid var(--border)`},children:[(0,E.jsx)(Fx,{style:{fontWeight:700,fontSize:`var(--text-2xl)`,color:`var(--text)`},children:r}),(0,E.jsx)(Mx,{asChild:!0,children:(0,E.jsx)(`button`,{type:`button`,disabled:c,title:g(`i18n.close`),"aria-label":g(`i18n.close`),style:{padding:`2px 6px`,border:0,background:`none`,color:`var(--text-muted)`,fontSize:`var(--text-5xl)`,lineHeight:1,cursor:c?`default`:`pointer`,opacity:c?.5:1},children:`×`})})]}),o&&(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,flexShrink:0,padding:`10px 14px`,borderBottom:`1px solid var(--border)`},children:[(0,E.jsx)(`label`,{htmlFor:`file-picker-note`,style:{fontSize:`var(--text-sm)`,color:`var(--text-muted)`,whiteSpace:`nowrap`},children:o}),(0,E.jsx)(CG,{id:`file-picker-note`,className:`h-9 flex-1 bg-bg-panel`,type:`text`,value:M,placeholder:s,autoComplete:`off`,style:TG,onChange:e=>P(e.target.value)})]}),(0,E.jsxs)(`form`,{onSubmit:se,style:{display:`flex`,alignItems:`center`,gap:8,flexShrink:0,padding:`10px 14px`,borderBottom:`1px solid var(--border)`},children:[(0,E.jsx)(`button`,{type:`button`,onClick:()=>void L(y??void 0),disabled:ae||!R,title:g(`directoryPicker.goToParent`),"aria-label":g(`directoryPicker.goToParent`),style:{width:36,height:36,padding:0,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,border:`1px solid var(--border)`,borderRadius:6,background:TG.backgroundColor,color:`var(--text-muted)`,cursor:R?`pointer`:`default`,opacity:R?1:.45},children:(0,E.jsx)(`svg`,{width:p[`3xl`],height:p[`3xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`m18 15-6-6-6 6`})})}),(0,E.jsx)(`label`,{htmlFor:`file-picker-path`,style:{position:`absolute`,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,border:0},children:g(`directoryPicker.directoryPath`)}),(0,E.jsx)(CG,{className:`h-9 flex-1 font-mono text-xs bg-bg-panel`,id:`file-picker-path`,type:`text`,ref:I,value:x,placeholder:`/path/to/folder or ~/folder`,autoComplete:`off`,spellCheck:!1,style:TG,onChange:e=>{S(AG(e.target.value)),ie(null)}}),(0,E.jsx)(`button`,{type:`submit`,disabled:ae||!x.trim(),title:g(`directoryPicker.goToDirectory`),style:{minWidth:58,height:36,padding:`0 12px`,border:`1px solid var(--border)`,borderRadius:6,background:TG.backgroundColor,color:`var(--text-muted)`,cursor:ae||!x.trim()?`default`:`pointer`,opacity:ae||!x.trim()?.6:1},children:g(`directoryPicker.go`)})]}),(0,E.jsxs)(`div`,{className:`directory-picker-list`,style:{flex:1,minHeight:0,overflow:`auto`,padding:`8px 10px`},children:[ae?(0,E.jsx)(`div`,{style:{padding:8,color:`var(--text-dim)`,fontSize:`var(--text-sm)`},children:g(`directoryPicker.loadingDirectories`)}):O===null?de.length>0||fe.length>0?(0,E.jsxs)(E.Fragment,{children:[de.map(e=>(0,E.jsxs)(`button`,{type:`button`,onClick:()=>void L(e.path),title:e.path,style:{width:`100%`,minHeight:30,display:`flex`,alignItems:`center`,gap:7,padding:`5px 8px`,border:0,borderRadius:5,background:`none`,color:`var(--text-muted)`,cursor:`pointer`,textAlign:`left`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`},children:[(0,E.jsx)(EG,{}),(0,E.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.name})]},e.path)),fe.map(e=>{let t=A===e.path;return(0,E.jsxs)(`button`,{type:`button`,onClick:()=>j(e.path),title:e.path,style:{width:`100%`,minHeight:30,display:`flex`,alignItems:`center`,gap:7,padding:`5px 8px`,border:0,borderRadius:5,background:t?`color-mix(in srgb, var(--accent) 14%, transparent)`:`none`,color:t?`var(--accent)`:`var(--text-muted)`,cursor:`pointer`,textAlign:`left`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`},children:[(0,E.jsx)(kG,{}),(0,E.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.name})]},e.path)})]}):(0,E.jsx)(`div`,{style:{padding:8,color:`var(--text-dim)`,fontSize:`var(--text-sm)`},children:g(ce?`directoryPicker.noMatches`:u?`i18n.noFiles`:`directoryPicker.noSubdirectories`)}):ue.length>0?ue.map(e=>(0,E.jsxs)(`button`,{type:`button`,onClick:()=>void L(e.path),title:e.path,style:{width:`100%`,minHeight:34,display:`flex`,alignItems:`center`,gap:7,padding:`6px 8px`,border:0,borderRadius:5,background:`none`,color:`var(--text-muted)`,cursor:`pointer`,textAlign:`left`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`},children:[(0,E.jsx)(DG,{}),(0,E.jsx)(`span`,{children:e.name})]},e.path)):(0,E.jsx)(`div`,{style:{padding:8,color:`var(--text-dim)`,fontSize:`var(--text-sm)`},children:g(ce?`directoryPicker.noMatches`:`directoryPicker.noDrives`)}),(re||l)&&(0,E.jsx)(`div`,{style:{padding:`8px`,color:`var(--status-error)`,fontSize:`var(--text-sm)`},children:re??l})]}),(0,E.jsxs)(`div`,{className:`directory-picker-footer`,style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,gap:10,flexShrink:0,padding:`10px 18px`,borderTop:`1px solid var(--border)`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,flex:1,minWidth:0},children:[f&&m.length>0&&(0,E.jsxs)(`select`,{value:te,onChange:e=>ne(e.target.value),"aria-label":g(`i18n.filterByType`),style:{flexShrink:0,height:32,padding:`0 6px`,border:`1px solid var(--border)`,borderRadius:6,background:`var(--bg-panel)`,color:`var(--text)`,fontSize:`var(--text-sm)`},children:[(0,E.jsx)(`option`,{value:``,children:g(`i18n.allFiles`)}),m.map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))]}),(0,E.jsxs)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,style:{color:`var(--text-dim)`,flexShrink:0},children:[(0,E.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,E.jsx)(`path`,{d:`m21 21-4.3-4.3`})]}),(0,E.jsx)(CG,{className:`directory-picker-search h-8 flex-1 bg-bg-panel`,type:`text`,value:ee,placeholder:g(`directoryPicker.search`),"aria-label":g(`directoryPicker.search`),autoComplete:`off`,spellCheck:!1,style:TG,onChange:e=>F(e.target.value)})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,flexShrink:0},children:[(0,E.jsx)(`button`,{type:`button`,onClick:t,disabled:c,style:{padding:`6px 14px`,border:`1px solid var(--border)`,borderRadius:6,background:`none`,color:`var(--text-muted)`,cursor:c?`default`:`pointer`,fontSize:`var(--text-lg)`},children:a??g(`i18n.cancel`)}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>A&&n(A,M.trim()),disabled:!pe,title:A?void 0:g(`i18n.selectFile`),style:{padding:`6px 16px`,border:0,borderRadius:6,background:`var(--accent)`,color:`var(--on-accent)`,fontSize:`var(--text-lg)`,fontWeight:600,opacity:pe?1:.6,cursor:pe?`pointer`:`default`},children:c?g(`i18n.checking`):A?`${i}: ${yG(A)}`:i})]})]})]})})}var MG={display:`inline-flex`,alignItems:`center`,gap:4,maxWidth:220,padding:`4px 10px`,borderRadius:12,border:`1px solid var(--accent)`,background:`color-mix(in srgb, var(--accent) 12%, transparent)`,color:`var(--accent)`,fontSize:`var(--text-sm)`,overflow:`hidden`,whiteSpace:`nowrap`,textOverflow:`ellipsis`},NG={minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`};function PG({label:e,onClick:t,onRemove:n,title:r,removeLabel:i,testId:a}){return n?(0,E.jsxs)(`span`,{"data-testid":a,title:r,style:MG,children:[(0,E.jsx)(`button`,{type:`button`,title:r,onClick:t,style:{...NG,flex:1,background:`none`,border:`none`,color:`inherit`,font:`inherit`,padding:0,textAlign:`left`,cursor:t?`pointer`:`default`},children:e}),(0,E.jsx)(`button`,{type:`button`,"aria-label":i??r??`remove`,onClick:n,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,marginLeft:`auto`,padding:2,borderRadius:4,color:`inherit`,background:`none`,border:`none`,cursor:`pointer`,flexShrink:0},children:(0,E.jsx)(ni,{size:p.sm})})]}):(0,E.jsx)(`button`,{type:`button`,"data-testid":a,title:r,onClick:t,style:{...MG,font:`inherit`,textAlign:`left`,cursor:t?`pointer`:`default`},children:(0,E.jsx)(`span`,{style:NG,children:e})})}function FG(e){try{return decodeURIComponent(e)}catch{return e}}function IG(e){return/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith(`\\\\`)?e.replace(/\\/g,`/`):e}function LG(e){return e.replace(/:\d+(?::\d+)?$/,``)}function RG(e){let t=IG(e),n=/^[a-zA-Z]:\//.test(t),r=t.startsWith(`//`),i=t.startsWith(`/`)&&!n&&!r,a=[];for(let e of t.split(`/`))if(!(!e||e===`.`)){if(e===`..`){a.length>0&&a[a.length-1]!==`..`?a.pop():!i&&!n&&!r&&a.push(e);continue}a.push(e)}let o=a.join(`/`);return n?o:r?`//${o}`:i?`/${o}`:o}function zG(e,t){let n=RG(e).replace(/\/+$/,``),r=RG(t).replace(/\/+$/,``),i=/^[a-zA-Z]:\//.test(n)||/^[a-zA-Z]:\//.test(r),a=i?n.toLowerCase():n,o=i?r.toLowerCase():r;return a===o||a.startsWith(`${o}/`)}function BG(e){return e.startsWith(`#`)||e.startsWith(`?`)?!1:e.startsWith(`./`)||e.startsWith(`../`)||e.includes(`/`)?!0:/(^|\/)\.?[^/]+\.[^/.]+$/.test(e)}function VG(e){try{let t=new URL(e);if(t.protocol!==`file:`)return null;let n=FG(t.pathname);return t.hostname?`//${t.hostname}${n.startsWith(`/`)?n:`/${n}`}`:/^\/[a-zA-Z]:\//.test(n)?n.slice(1):n}catch{return null}}function HG(e,t,n=t){if(!e)return null;let r=e.split(`#`,1)[0].split(`?`,1)[0].trim();if(!r)return null;let i=null,a=null,o=FG(r),s=o.startsWith(`\\\\`),c=IG(o),l=c.toLowerCase();if(l.startsWith(`/api/`)||l.startsWith(`/_next/`)||!s&&c.startsWith(`//`)||/^[a-zA-Z][a-zA-Z0-9+.-]*:/i.test(c)&&!l.startsWith(`file:`)&&!/^[a-zA-Z]:\//.test(c)||(l.startsWith(`file:`)?(i=VG(c),a=i?`absolute`:null):/^[a-zA-Z]:\//.test(c)||c.startsWith(`/`)?(i=c,a=`absolute`):t&&BG(c)&&(i=`${IG(t).replace(/\/+$/,``)}/${c}`,a=`relative`),!i))return null;let u=LG(RG(i));return a===`relative`&&n&&!zG(u,n)?null:u}function UG(e,t){if(!e)return{kind:`external`};let n=e.split(`#`,1)[0].split(`?`,1)[0].trim();if(!n||n.startsWith(`#`)||n.startsWith(`?`))return{kind:`external`};let r=FG(n);if(r.startsWith(`\\\\`))return{kind:`unsafe`};let i=IG(r);if(/^[a-zA-Z]:[\\/]/.test(i))return{kind:`unsafe`};if(/^[a-zA-Z][a-zA-Z0-9+.-]*:/i.test(i)||i.startsWith(`//`))return{kind:`external`};if(i.startsWith(`/`))return{kind:`unsafe`};let a=RG(`${IG(t).replace(/\/+$/,``)}/${i}`);return zG(a,t)?{kind:`safe`,path:LG(a)}:{kind:`unsafe`}}function WG({href:e,markdownDir:t,onOpenFile:n,children:r,...i}){let{t:a}=N();if(!e||!n)return(0,E.jsx)(`a`,{href:e,...i,children:r});let o=UG(e,t),s=t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(o.kind===`safe`?(t.preventDefault(),n(o.path)):o.kind===`unsafe`&&(t.preventDefault(),window.alert(a(`i18n.unsafeLinkBlocked`,{href:e}))))};return o.kind===`external`?(0,E.jsx)(`a`,{href:e,...i,target:`_blank`,rel:`noopener noreferrer`,children:r}):(0,E.jsx)(`a`,{href:e,...i,onClick:s,children:r})}function GG(e){return e.replace(/^\/(?:Users|home)\/[^/]+/,`~`)}var KG=`package`,qG=null,JG=null;function YG(e){return e.trim().match(/^\$?\s*pi\s+install\s+(\S+)\s*$/)?.[1]??e}function XG(e){return`${e.scope}\0${e.source}`}function ZG(e){return`${e.scope}\0${e.pattern}`}function QG(e,t){if(e.disabled)return t(`i18n.disabled`);let n=e.version||e.configuredVersion;return[n?`${t(`i18n.versionShort`)}:${n}`:``,`${t(`i18n.extensionShort`)}:${e.counts.extensions}`,`${t(`i18n.skillShort`)}:${e.counts.skills}`].filter(Boolean).join(` `)}function $G(e,t){let n=[];return e.version&&n.push(t(`i18n.installedVersion`,{version:e.version})),e.configuredVersion&&n.push(t(`i18n.configuredVersion`,{version:e.configuredVersion})),n.length?n.join(` · `):t(`i18n.unknown`)}function eK(e,t){return e===`project`?`${GG(t)}/.pi/agent/{npm,git}`:`~/.pi/agent/{npm,git}`}function tK(e,t,n){let r=t.trim(),i=r.startsWith(`npm:`)?r.slice(4):r;return e.find(e=>e.scope===n&&e.source===r)??e.find(e=>e.scope===n&&e.source===`npm:${i}`)??e.find(e=>e.scope===n&&e.source.endsWith(r))}function nK(e){let t=e[0];return t===`!`?`var(--status-error)`:t===`+`?`var(--status-success)`:`var(--text-dim)`}function rK(e,t){let n=e[0];return t(n===`!`?`plugins.filterPrefixExclude`:n===`+`?`plugins.filterPrefixForceInclude`:`plugins.filterPrefixForceExclude`)}function iK(e){return e===`loaded`?`var(--accent)`:e===`installed`?`var(--status-warning)`:e===`disabled`?`var(--text-dim)`:`var(--status-error)`}function aK(e,t){switch(e){case`loaded`:return t(`plugins.statusLoaded`);case`installed`:return t(`plugins.statusInstalled`);case`disabled`:return t(`plugins.statusDisabled`);default:return t(`plugins.statusMissing`)}}function oK({pkg:e}){let{t}=N(),n=[[`extension`,t(`i18n.extensions`)],[`skill`,t(`i18n.skills`)],[`prompt`,t(`i18n.prompts`)],[`theme`,t(`i18n.themes`)]].map(([t,n])=>({kind:t,label:n,resources:e.resources.filter(e=>e.kind===t)})).filter(e=>e.resources.length>0);return n.length===0?(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--text-dim)`},children:e.disabled?t(`i18n.packageDisabled`):t(`i18n.noResolvedResources`)}):(0,E.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:n.map((e,t)=>(0,E.jsxs)(`div`,{style:{borderTop:t===0?`none`:`1px solid var(--border)`,paddingTop:t===0?0:12},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-xs)`,fontWeight:700,color:`var(--text-dim)`,textTransform:`uppercase`,marginBottom:6},children:e.label}),(0,E.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:e.resources.map(e=>(0,E.jsxs)(`div`,{style:{minWidth:0},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--text)`,fontFamily:`var(--font-mono)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},title:e.path,children:e.name}),(0,E.jsx)(`div`,{style:{fontSize:`var(--text-xs)`,color:`var(--text-dim)`,fontFamily:`var(--font-mono)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,marginTop:1},title:e.path,children:e.relativePath})]},`${e.kind}:${e.path}`))})]},e.kind))})}function sK({scope:e}){return(0,E.jsx)(`span`,{style:{fontSize:`var(--text-xs)`,padding:`1px 5px`,borderRadius:3,flexShrink:0,background:e===`project`?`color-mix(in srgb, var(--status-info) 12%, transparent)`:`color-mix(in srgb, var(--text-dim) 12%, transparent)`,color:e===`project`?`color-mix(in srgb, var(--status-info) 85%, transparent)`:`var(--text-dim)`},children:e})}function cK(e,t){return{padding:`6px 12px`,background:t?`color-mix(in srgb, var(--status-error) 8%, transparent)`:`none`,border:`1px solid var(--border)`,borderRadius:6,color:t?`var(--status-error)`:`var(--text-muted)`,cursor:e?`not-allowed`:`pointer`,fontSize:`var(--text-base)`,opacity:e?.5:1}}function lK({enabled:e,loading:t,onToggle:n,label:r,testId:i}){return(0,E.jsx)(`button`,{type:`button`,"data-testid":i,onClick:n,disabled:t,title:r,"aria-label":r,"aria-pressed":e,style:{flexShrink:0,width:40,height:22,borderRadius:11,border:`none`,padding:0,cursor:t?`wait`:`pointer`,background:e?`var(--accent)`:`var(--border)`,position:`relative`,transition:`background 0.18s`,outline:`none`,opacity:t?.65:1},children:(0,E.jsx)(`span`,{style:{position:`absolute`,top:3,left:e?21:3,width:16,height:16,borderRadius:`50%`,background:`var(--bg)`,boxShadow:`0 1px 4px var(--shadow-color)`,transition:`left 0.18s cubic-bezier(.4,0,.2,1)`}})})}function uK({value:e,projectResourcesLoaded:t,onChange:n}){let{t:r}=N();return(0,E.jsx)(zx,{value:e,onChange:n,options:[`global`,`project`].map(e=>({value:e,label:e,disabled:e===`project`&&!t,title:e===`project`&&!t?r(`trust.projectScopeUnavailable`):void 0}))})}function dK(e){return{width:`100%`,height:36,padding:`0 11px`,border:`1px solid ${e}`,borderRadius:6,background:`var(--bg-input)`,color:`var(--text)`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-lg)`,outline:`none`}}function fK({examples:e,onPick:t}){return(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:7},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,fontWeight:600,color:`var(--text-muted)`},children:`Examples`}),(0,E.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:e.map(e=>(0,E.jsx)(`button`,{type:`button`,onClick:()=>t(e),style:{width:`100%`,minHeight:30,textAlign:`left`,padding:`6px 9px`,border:`1px solid var(--border)`,borderRadius:6,background:`var(--bg-panel)`,color:`var(--text-dim)`,cursor:`pointer`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,"--hover-color":`var(--text-muted)`,"--hover-bg":`var(--bg-hover)`},className:`hover-shift`,children:e},e))})]})}function pK({scope:e,projectResourcesLoaded:t,onScopeChange:n,actionBusy:r,actionDisabled:i,actionLabel:a,onAction:o,actionTestId:s}){let{t:c}=N();return(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,flexWrap:`wrap`},children:[(0,E.jsx)(uK,{value:e,projectResourcesLoaded:t,onChange:n}),(0,E.jsx)(`button`,{type:`button`,"data-testid":s,onClick:o,disabled:i,style:{...cK(i),background:`var(--accent)`,color:`var(--on-accent)`,borderColor:`var(--accent)`},children:r?c(`i18n.installing`):a})]})}var mK=`/recommended-plugins.json`;function hK({packages:e,onPick:t}){let{t:n,locale:r}=N(),[i,a]=(0,d.useState)([]);if((0,d.useEffect)(()=>{fetch(mK).then(e=>e.json()).then(e=>{Array.isArray(e)&&a(e)}).catch(()=>{})},[]),i.length===0)return null;let o=r===`zh-CN`?`zh`:`en`;return(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:7},children:[(0,E.jsxs)(`div`,{style:{fontSize:`var(--text-base)`,fontWeight:600,color:`var(--text-muted)`,display:`flex`,alignItems:`center`,gap:6},children:[(0,E.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:`var(--accent)`},children:[(0,E.jsx)(`path`,{d:`M12 2L2 7l10 5 10-5-10-5z`}),(0,E.jsx)(`path`,{d:`M2 17l10 5 10-5`}),(0,E.jsx)(`path`,{d:`M2 12l10 5 10-5`})]}),n(`i18n.recommendedPlugins`)]}),(0,E.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:i.map(r=>{let i=e.some(e=>e.source===r.source||e.source===`npm:${r.source.replace(/^npm:/,``)}`||e.source.endsWith(r.source.replace(/^npm:/,``))),a=typeof r.name==`object`?r.name[o]??r.name.en:r.name,s=typeof r.description==`object`?r.description[o]??r.description.en:r.description;return(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8,padding:`8px 10px`,border:`1px solid var(--border)`,borderRadius:6,background:`var(--bg-panel)`},children:[(0,E.jsxs)(`div`,{style:{minWidth:0,flex:1},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,fontWeight:600,color:`var(--text)`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:a}),(0,E.jsx)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-dim)`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:s})]}),i?(0,E.jsx)(`span`,{style:{fontSize:`var(--text-sm)`,color:`var(--status-success)`,whiteSpace:`nowrap`,flexShrink:0,display:`inline-flex`,alignItems:`center`,gap:4},children:n(`i18n.installed`)}):(0,E.jsx)(`button`,{type:`button`,onClick:()=>t(r.source),className:`hover-shift`,style:{flexShrink:0,padding:`5px 12px`,border:`1px solid var(--accent)`,borderRadius:6,background:`transparent`,color:`var(--accent)`,cursor:`pointer`,fontSize:`var(--text-sm)`,fontWeight:600,whiteSpace:`nowrap`},children:n(`i18n.install`)})]},r.source)})})]})}function gK({cwd:e,source:t,scope:n,projectResourcesLoaded:r,busy:i,actionError:a,packages:o,onSourceChange:s,onScopeChange:c,onInstall:l}){let{t:u}=N(),f=(0,d.useRef)(null);return(0,d.useEffect)(()=>{f.current?.focus()},[]),(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:18,maxWidth:660,minHeight:`100%`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:12,flexWrap:`wrap`},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-xl)`,fontWeight:700,color:`var(--text)`},children:u(`i18n.addPlugin`)}),(0,E.jsxs)(`a`,{href:`https://pi.dev/packages`,target:`_blank`,rel:`noopener noreferrer`,style:{display:`inline-flex`,alignItems:`center`,gap:5,color:`var(--accent)`,fontSize:`var(--text-base)`,textDecoration:`none`,whiteSpace:`nowrap`},children:[(0,E.jsxs)(`svg`,{width:`28`,height:`28`,viewBox:`0 0 800 800`,"aria-hidden":`true`,focusable:`false`,style:{flexShrink:0},children:[(0,E.jsx)(`path`,{fill:`#000`,fillRule:`evenodd`,d:`M165.29 165.29H517.36V400H400V517.36H282.65V634.72H165.29ZM282.65 282.65V400H400V282.65Z`}),(0,E.jsx)(`path`,{fill:`#000`,d:`M517.36 400H634.72V634.72H517.36Z`})]}),`pi.dev/packages`]})]}),(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--text-dim)`,fontFamily:`var(--font-mono)`},children:eK(n,e)})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:7},children:[(0,E.jsx)(`label`,{htmlFor:`plugin-source`,style:{fontSize:`var(--text-base)`,fontWeight:600,color:`var(--text-muted)`},children:`Source`}),(0,E.jsx)(oi,{label:(0,E.jsxs)(`span`,{style:{display:`flex`,flexDirection:`column`,gap:2,fontSize:`var(--text-sm)`,fontFamily:`var(--font-mono)`,lineHeight:1.5},children:[(0,E.jsx)(`span`,{children:`npm:@scope/package`}),(0,E.jsx)(`span`,{children:`git:https://github.com/user/repo`}),(0,E.jsx)(`span`,{children:`/absolute/path/to/plugin`})]}),children:(0,E.jsx)(`input`,{id:`plugin-source`,ref:f,value:t,onChange:e=>s(e.target.value),onPaste:e=>{let t=e.clipboardData.getData(`text`),n=YG(t);n!==t&&(e.preventDefault(),s(n))},onBlur:e=>s(YG(e.currentTarget.value)),placeholder:u(`plugins.npmSourcePlaceholder`),style:dK(`var(--border)`),onKeyDown:e=>{e.key===`Enter`&&t.trim()&&!i&&l()}})})]}),(0,E.jsx)(pK,{scope:n,projectResourcesLoaded:r,onScopeChange:c,actionBusy:i,actionDisabled:i||!t.trim(),actionLabel:u(`i18n.install`),onAction:l}),(0,E.jsx)(hK,{packages:o,onPick:s}),a&&(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--status-error)`,whiteSpace:`pre-wrap`},children:a})]})}function _K({pattern:e,scope:t,projectResourcesLoaded:n,busy:r,actionError:i,onPatternChange:a,onScopeChange:o,onAdd:s}){let{t:c}=N(),l=(0,d.useRef)(null),u=e.trim(),f=u.length>0&&!gG(u);return(0,d.useEffect)(()=>{l.current?.focus()},[]),(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:18,maxWidth:660,minHeight:`100%`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-xl)`,fontWeight:700,color:`var(--text)`},children:c(`plugins.addFilter`)}),(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--text-dim)`,lineHeight:1.5},children:c(`plugins.extensionFiltersHint`)})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:7},children:[(0,E.jsx)(`label`,{htmlFor:`extension-filter-pattern`,style:{fontSize:`var(--text-base)`,fontWeight:600,color:`var(--text-muted)`},children:c(`plugins.filterPatternLabel`)}),(0,E.jsx)(`input`,{id:`extension-filter-pattern`,"data-testid":`extension-filter-pattern`,ref:l,value:e,onChange:e=>a(e.target.value),placeholder:c(`plugins.filterPlaceholder`),style:dK(f?`var(--status-error)`:`var(--border)`),onKeyDown:e=>{e.key===`Enter`&&u&&!f&&!r&&s()}}),f&&(0,E.jsx)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--status-error)`},children:c(`plugins.filterInvalid`)})]}),(0,E.jsx)(pK,{scope:t,projectResourcesLoaded:n,onScopeChange:o,actionBusy:r,actionDisabled:r||!u||f,actionLabel:c(`plugins.addFilter`),onAction:s,actionTestId:`extension-filter-add`}),(0,E.jsx)(fK,{examples:[`!**/*.test.ts`,`+./my-ext.ts`,`-./legacy-ext.ts`],onPick:a}),(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,E.jsxs)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-dim)`,lineHeight:1.6},children:[(0,E.jsx)(`span`,{style:{color:`var(--status-error)`,fontWeight:700},children:`!`}),` `,c(`plugins.filterPrefixExclude`)]}),(0,E.jsxs)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-dim)`,lineHeight:1.6},children:[(0,E.jsx)(`span`,{style:{color:`var(--status-success)`,fontWeight:700},children:`+`}),` `,c(`plugins.filterPrefixForceInclude`)]}),(0,E.jsxs)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-dim)`,lineHeight:1.6},children:[(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`,fontWeight:700},children:`-`}),` `,c(`plugins.filterPrefixForceExclude`)]})]}),i&&(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--status-error)`,whiteSpace:`pre-wrap`},children:i})]})}function vK({filter:e,busyKey:t,actionError:n,actionMessage:r,onRemove:i}){let{t:a}=N(),o=ZG(e),s=t?.endsWith(o)??!1;return(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:20},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,justifyContent:`space-between`,gap:12,minWidth:0,flexWrap:`wrap`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,minWidth:180,flex:1},children:[(0,E.jsx)(sK,{scope:e.scope}),(0,E.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`,fontSize:`var(--text-lg)`,color:`var(--text)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.pattern})]}),(0,E.jsx)(`button`,{"data-testid":`extension-filter-remove`,onClick:()=>i(e),disabled:s,style:cK(s,!0),children:a(s?`i18n.removing`:`plugins.removeFilter`)})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,fontWeight:700,color:`var(--text)`},children:a(`plugins.filterEffect`)}),(0,E.jsxs)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--text-muted)`,lineHeight:1.55},children:[(0,E.jsx)(`span`,{style:{color:nK(e.pattern),fontWeight:700,fontFamily:`var(--font-mono)`},children:e.pattern[0]}),` `,rK(e.pattern,a)]}),(0,E.jsx)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-dim)`,lineHeight:1.5},children:a(`plugins.extensionFiltersHint`)})]}),r&&(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--status-success)`},children:r}),n&&(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--status-error)`,whiteSpace:`pre-wrap`},children:n})]})}function yK({pkg:e,busyKey:t,actionError:n,actionMessage:r,sessionId:i,onAction:a,onReloadSession:o,onOpenFile:s}){let{t:c}=N(),{pluginConfigBindings:l,addPluginConfigBinding:u,removePluginConfigBinding:d}=ge(),f=XG(e),p=t?.endsWith(f)??!1,m=t===`reload`,h=!e.disabled;return(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:20},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,justifyContent:`space-between`,gap:12,minWidth:0,flexWrap:`wrap`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,minWidth:180,flex:1},children:[(0,E.jsx)(lK,{enabled:h,loading:p||m,onToggle:()=>a(e.disabled?`enable`:`disable`,e),label:e.disabled?c(`i18n.enablePackage`):c(`i18n.disablePackage`),testId:`package-toggle`}),(0,E.jsx)(sK,{scope:e.scope}),e.disabled?(0,E.jsx)(`span`,{style:{fontSize:`var(--text-xs)`,padding:`1px 5px`,borderRadius:3,background:`color-mix(in srgb, var(--text-dim) 12%, transparent)`,color:`var(--text-dim)`},children:c(`i18n.disabled`)}):e.filtered&&(0,E.jsx)(`span`,{style:{fontSize:`var(--text-xs)`,padding:`1px 5px`,borderRadius:3,background:`color-mix(in srgb, var(--status-warning) 12%, transparent)`,color:`var(--status-warning)`},children:c(`i18n.filtered`)}),(0,E.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`,fontSize:`var(--text-base)`,color:`var(--text)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.source})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`},children:[(0,E.jsx)(`button`,{onClick:()=>a(`update`,e),disabled:p||m,style:cK(p||m),children:t===`update:${f}`?c(`i18n.updating`):c(`i18n.update`)}),(0,E.jsx)(`button`,{onClick:o,disabled:!i||m||p,style:cK(!i||m||p),title:c(i?`i18n.reloadSession`:`i18n.openSessionToReload`),children:c(m?`i18n.reloading`:`i18n.reloadSession`)}),(0,E.jsx)(`button`,{onClick:()=>a(`remove`,e),disabled:p||m,style:cK(p||m,!0),children:t===`remove:${f}`?c(`i18n.removing`):c(`i18n.remove`)})]})]}),(0,E.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`minmax(96px, 130px) minmax(0, 1fr)`,gap:`9px 14px`,fontSize:`var(--text-base)`,lineHeight:1.45},children:[(0,E.jsx)(`div`,{style:{color:`var(--text-dim)`},children:c(`i18n.status`)}),(0,E.jsx)(`div`,{style:{color:iK(e.status),textTransform:`capitalize`},children:e.status}),(0,E.jsx)(`div`,{style:{color:`var(--text-dim)`},children:c(`i18n.version`)}),(0,E.jsx)(`div`,{style:{color:`var(--text-muted)`,fontFamily:`var(--font-mono)`},children:$G(e,c)}),(0,E.jsx)(`div`,{style:{color:`var(--text-dim)`},children:c(`i18n.package`)}),(0,E.jsx)(`div`,{style:{color:`var(--text-muted)`,fontFamily:`var(--font-mono)`,overflowWrap:`anywhere`},children:e.packageName??c(`i18n.unknown`)}),(0,E.jsx)(`div`,{style:{color:`var(--text-dim)`},children:c(`i18n.resources`)}),(0,E.jsx)(`div`,{style:{color:`var(--text-muted)`},children:QG(e,c)}),(0,E.jsx)(`div`,{style:{color:`var(--text-dim)`},children:c(`i18n.installedPath`)}),(0,E.jsx)(`div`,{style:{color:e.installedPath?`var(--text-muted)`:`#ef4444`,fontFamily:`var(--font-mono)`,overflowWrap:`anywhere`},children:e.installedPath?GG(e.installedPath):c(`i18n.notFound`)})]}),e.readmePath&&e.readmeSummary&&(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,padding:`8px 10px`,border:`1px solid var(--border)`,borderRadius:6,background:`var(--bg-panel)`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,E.jsx)(`span`,{style:{fontSize:`var(--text-base)`,fontWeight:600,color:`var(--text)`},children:c(`i18n.readme`)}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>s(e.readmePath,yG(e.readmePath)),style:{cursor:`pointer`,fontSize:`var(--text-sm)`,color:`var(--accent)`,background:`none`,border:`none`,padding:0},children:c(`i18n.readmeDetails`)})]}),(0,E.jsx)(`div`,{className:`markdown-body markdown-file-preview`,style:{fontSize:`var(--text-sm)`,lineHeight:1.5,overflowWrap:`anywhere`},children:(0,E.jsx)(Ok,{remarkPlugins:pG,rehypePlugins:hG,components:{a({href:t,children:n,...r}){return delete r.node,(0,E.jsx)(WG,{href:t,markdownDir:bG(e.readmePath),onOpenFile:e=>s(e,yG(e)),...r,children:n})}},children:e.readmeSummary})})]}),(0,E.jsx)(bK,{bindings:l[f]??[],onAdd:e=>u(f,e),onRemove:e=>d(f,e),onOpenFile:s}),(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,fontWeight:700,color:`var(--text)`},children:c(`i18n.resolvedResources`)}),(0,E.jsx)(oK,{pkg:e})]}),r&&(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--status-success)`},children:r}),n&&(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--status-error)`,whiteSpace:`pre-wrap`},children:n})]})}function bK({bindings:e,onAdd:t,onRemove:n,onOpenFile:r}){let{t:i}=N(),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1);return(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`flex-start`,gap:8},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,fontWeight:700,color:`var(--text)`},children:i(`i18n.configBindings`)}),(0,E.jsxs)(`button`,{type:`button`,onClick:()=>c(!0),style:{...cK(!1),display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,E.jsx)(Ir,{size:p.sm}),i(`i18n.addBinding`)]})]}),e.length===0?(0,E.jsx)(`p`,{style:{margin:0,fontSize:`var(--text-sm)`,color:`var(--text-muted)`},children:i(`i18n.noConfigBindings`)}):(0,E.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6},children:[e.map(e=>{let t=e.note?`${yG(e.path)} · ${e.note}`:yG(e.path),n=e.note?`${e.path}\n${e.note}`:e.path;return(0,E.jsx)(oi,{label:n,wrapperStyle:{display:`inline-flex`,minWidth:0},children:(0,E.jsx)(PG,{label:t,title:n,onClick:()=>r(e.path,yG(e.path)),onRemove:()=>o(e.path)})},e.path)}),a!==null&&(0,E.jsx)(Bx,{open:!0,title:i(`i18n.removeBinding`),description:(0,E.jsx)(`span`,{style:{display:`block`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,color:`var(--text-muted)`,overflowWrap:`anywhere`},children:a}),confirmText:i(`i18n.confirm`),cancelText:i(`i18n.cancel`),destructive:!0,onConfirm:()=>{n(a),o(null)},onCancel:()=>o(null)})]}),(0,E.jsx)(jG,{open:s,title:i(`i18n.bindConfigFile`),confirmText:i(`i18n.confirm`),initialPath:`~/.pi`,noteLabel:i(`i18n.configFileNote`),showFiles:!0,showExtensionFilter:!0,extensionOptions:[`.json`,`.json5`,`.yaml`,`.yml`,`.toml`,`.ini`,`.conf`],onCancel:()=>c(!1),onConfirm:(e,n)=>{t({path:e,note:n||void 0}),c(!1)}})]})}function xK({cwd:e,sessionId:t,onClose:n,onOpenFile:r,onReloaded:i,pane:a,globalPackages:o=[],globalExtensionFilters:s=[]}){let c=ne(),{t:l}=N(),[u,f]=(0,d.useState)(null),[m,h]=(0,d.useState)(!0),[g,_]=(0,d.useState)(null),[v,y]=(0,d.useState)(qG),[b,x]=(0,d.useState)(JG),[S,C]=(0,d.useState)(KG),[w,T]=(0,d.useState)(`plugins`),[D,O]=(0,d.useState)(``),[k,A]=(0,d.useState)(``),[j,M]=(0,d.useState)(`global`),[P,ee]=(0,d.useState)(`global`),[F,te]=(0,d.useState)(280),[re,ie]=(0,d.useState)(``),[ae,oe]=(0,d.useState)(null),[I,L]=(0,d.useState)(null),[se,R]=(0,d.useState)(null),ce=(0,d.useMemo)(()=>{let e=u?.packages??[];return!o||o.length===0?e:[...e,...o]},[u?.packages,o]),le=ce.find(e=>XG(e)===v)??null,ue=(0,d.useMemo)(()=>{let e=[...u?.extensionFilters??[],...s??[]],t=new Set;return e.filter(e=>{let n=ZG(e);return!t.has(n)&&(t.add(n),!0)})},[u?.extensionFilters,s]),de=ue.find(e=>ZG(e)===b)??null,fe=u?.projectResourcesLoaded??!0,pe=(0,d.useMemo)(()=>[`project`,`global`].map(e=>({scope:e,packages:ce.filter(t=>t.scope===e)})).filter(e=>e.packages.length>0),[ce]),me=re.trim().toLowerCase(),he=me?pe.map(e=>({...e,packages:e.packages.filter(e=>e.source.toLowerCase().includes(me))})).filter(e=>e.packages.length>0):pe,ge=(0,d.useMemo)(()=>[`project`,`global`].map(e=>({scope:e,filters:ue.filter(t=>t.scope===e)})).filter(e=>e.filters.length>0),[ue]),_e=(0,d.useMemo)(()=>me?ge.map(e=>({...e,filters:e.filters.filter(e=>e.pattern.toLowerCase().includes(me))})).filter(e=>e.filters.length>0):ge,[ge,me]),ve=e=>{T(e),C(e===`plugins`?e=>e===`addFilter`||e===`filter`?le?`package`:`addPlugin`:e:e=>e===`addPlugin`||e===`package`?de?`filter`:`addFilter`:e)},ye=(0,d.useCallback)(async()=>{h(!0),_(null);try{let t=await fetch(`/api/plugins?cwd=${encodeURIComponent(e)}`),n=await t.json();if(!t.ok||n.error)throw Error(n.error??`HTTP ${t.status}`);f(n);let r=[...n.packages,...o??[]],i=[...n.extensionFilters,...s??[]];C(e=>r.length===0&&e!==`addFilter`?`addPlugin`:e),y(e=>e&&r.some(t=>XG(t)===e)?e:r[0]?XG(r[0]):null),x(e=>e&&i.some(t=>ZG(t)===e)?e:null)}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}},[e,o,s]);(0,d.useEffect)(()=>{ye()},[ye]),(0,d.useEffect)(()=>{KG=S,qG=v,JG=b});let be=(0,d.useCallback)(async(t,n)=>{let r=XG(n);oe(`${t}:${r}`),L(null),R(null);try{let r=await fetch(`/api/plugins`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t,source:n.source,scope:n.scope,cwd:e})}),i=await r.json();if(!r.ok||i.error)throw Error(i.error??`HTTP ${r.status}`);let a={...i,packages:i.packages.filter(e=>e.scope===`project`),extensionFilters:i.extensionFilters.filter(e=>e.scope===`project`)};if(f(a),t===`remove`)y(a.packages[0]?XG(a.packages[0]):null),a.packages.length===0&&C(`addPlugin`),R(l(`plugins.packageRemoved`));else{let e={install:l(`plugins.packageInstalled`),update:l(`plugins.packageUpdated`),disable:l(`plugins.packageDisabled`),enable:l(`plugins.packageEnabled`),addExtensionFilter:l(`plugins.extensionFilterAdded`),removeExtensionFilter:l(`plugins.extensionFilterRemoved`)};R(e[t])}n.scope===`global`&&we.refresh().catch(()=>{})}catch(e){L(e instanceof Error?e.message:String(e))}finally{oe(null)}},[e,l]),xe=(0,d.useCallback)(async(t,n)=>{let r=ZG(n);oe(`${t}:${r}`),L(null),R(null);try{let i=await fetch(`/api/plugins`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t,source:n.pattern,scope:n.scope,cwd:e})}),a=await i.json();if(!i.ok||a.error)throw Error(a.error??`HTTP ${i.status}`);let o={...a,packages:a.packages.filter(e=>e.scope===`project`),extensionFilters:a.extensionFilters};f(o),t===`removeExtensionFilter`?(x(null),R(l(`plugins.extensionFilterRemoved`))):(x(r),R(l(`plugins.extensionFilterAdded`))),n.scope===`global`&&we.refresh().catch(()=>{})}catch(e){L(e instanceof Error?e.message:String(e))}finally{oe(null)}},[e,l]),Se=(0,d.useCallback)(async()=>{let t=YG(D).trim();if(!t)return;O(t);let n=`${j}\0${t}`;oe(`install:${n}`),L(null),R(null);try{let r=await fetch(`/api/plugins`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`install`,source:t,scope:j,cwd:e})}),i=await r.json();if(!r.ok||i.error)throw Error(i.error??`HTTP ${r.status}`);let a={...i,packages:i.packages.filter(e=>e.scope===`project`),extensionFilters:i.extensionFilters.filter(e=>e.scope===`project`)};f(a);let o=tK(a.packages,t,j);y(o?XG(o):n),C(`package`),O(``),R(l(`plugins.packageInstalled`)),j===`global`&&we.refresh().catch(()=>{})}catch(e){L(e instanceof Error?e.message:String(e))}finally{oe(null)}},[e,j,D,l]),Ce=(0,d.useCallback)(async()=>{let e=k.trim();if(e){if(!gG(e)){L(l(`plugins.filterInvalid`));return}L(null),R(null),await xe(`addExtensionFilter`,{pattern:e,scope:P}),C(`filter`),A(``)}},[k,P,xe,l]),Te=(0,d.useCallback)(async()=>{if(t){oe(`reload`),L(null),R(null);try{await US(t,{type:`reload`}),i?.(),await ye(),R(l(`plugins.sessionReloaded`))}catch(e){L(e instanceof Error?e.message:String(e))}finally{oe(null)}}},[ye,i,t,l]),Ee=ae?.startsWith(`install:`)??!1,De=ae?.startsWith(`addExtensionFilter:`)??!1;return(0,E.jsx)(`div`,{style:a?{display:`contents`}:{position:`fixed`,inset:0,zIndex:1e3,background:`var(--overlay)`,display:`flex`,alignItems:`center`,justifyContent:`center`},onClick:e=>{e.target===e.currentTarget&&n()},children:(0,E.jsxs)(`div`,{style:a?{width:`100%`,height:`100%`,background:`var(--bg)`,display:`flex`,flexDirection:`column`,overflow:`hidden`}:{width:c?`calc(100vw - 16px)`:860,maxWidth:`calc(100vw - 16px)`,height:c?`calc(100dvh - 16px)`:`76vh`,maxHeight:`calc(100dvh - 16px)`,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:8,display:`flex`,flexDirection:`column`,boxShadow:`0 8px 32px var(--shadow-color)`,overflow:`hidden`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`12px 18px`,borderBottom:`1px solid var(--border)`,flexShrink:0},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,minWidth:0,flexWrap:`wrap`,rowGap:6},children:[(0,E.jsx)(`div`,{style:{display:`inline-flex`,border:`1px solid var(--border)`,borderRadius:7,overflow:`hidden`,flexShrink:0},children:[`plugins`,`filters`].map(e=>{let t=w===e;return(0,E.jsx)(`button`,{type:`button`,"data-testid":e===`plugins`?`plugins-tab-plugins`:`plugins-tab-filters`,onClick:()=>ve(e),style:{padding:`4px 12px`,border:`none`,borderRight:e===`plugins`?`1px solid var(--border)`:`none`,background:t?`var(--accent)`:`transparent`,color:t?`var(--on-accent)`:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-base)`,fontWeight:t?700:400},children:l(e===`plugins`?`plugins.managePlugins`:`plugins.filterRules`)},e)})}),(0,E.jsx)(`code`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-muted)`,fontFamily:`var(--font-mono)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:GG(e)}),(0,E.jsx)(Xx,{testId:`plugins-search`,query:re,onChange:ie,t:l})]}),!a&&(0,E.jsx)(`button`,{onClick:n,style:{background:`none`,border:`none`,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-5xl)`,lineHeight:1,padding:`2px 6px`},children:`×`})]}),!fe&&(0,E.jsx)(`div`,{role:`status`,style:{padding:`8px 18px`,borderBottom:`1px solid var(--border)`,background:`var(--bg-panel)`,color:`var(--text-muted)`,fontSize:`var(--text-base)`},children:l(`trust.pluginsNotLoaded`)}),(0,E.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:c?`column`:`row`,overflow:`hidden`},children:[(0,E.jsxs)(`div`,{style:{width:c?`100%`:F,maxHeight:c?`40vh`:void 0,display:`flex`,flexDirection:`column`,flexShrink:0,background:`var(--bg)`},children:[(0,E.jsx)(`div`,{style:{flex:1,overflowY:`auto`,padding:`8px 6px`},children:m?(0,E.jsx)(`div`,{style:{padding:`10px 8px`,fontSize:`var(--text-base)`,color:`var(--text-muted)`},children:l(`i18n.loading`)}):g?(0,E.jsx)(`div`,{style:{padding:`10px 8px`,fontSize:`var(--text-sm)`,color:`var(--status-error)`},children:g}):w===`plugins`?ce.length===0||me&&he.length===0?(0,E.jsx)(`div`,{style:{padding:`10px 8px`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`},children:l(me?`i18n.noMatch`:`i18n.noPlugins`)}):(0,E.jsx)(E.Fragment,{children:he.map(e=>(0,E.jsxs)(`div`,{style:{marginBottom:6},children:[(0,E.jsx)(`div`,{style:{padding:`4px 8px 3px`,fontSize:`var(--text-xs)`,fontWeight:600,color:`var(--text-dim)`,textTransform:`uppercase`},children:e.scope}),e.packages.map(e=>{let t=XG(e),n=S===`package`&&v===t;return(0,E.jsxs)(`div`,{"data-testid":`package-item-${e.scope}-${e.source}`,onClick:()=>{y(t),C(`package`),L(null),R(null)},style:{display:`flex`,alignItems:`center`,gap:7,padding:`8px 8px`,borderRadius:5,cursor:`pointer`},className:n?`selectable-row row-selected-gradient`:`selectable-row`,children:[(0,E.jsx)(oi,{label:aK(e.status,l),children:(0,E.jsx)(`span`,{style:{flexShrink:0,width:7,height:7,borderRadius:`50%`,background:iK(e.status)}})}),(0,E.jsxs)(`div`,{style:{minWidth:0,flex:1},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,fontWeight:n?600:400,color:`var(--text)`,fontFamily:`var(--font-mono)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:(0,E.jsx)(oi,{label:e.source,children:(0,E.jsx)(`span`,{children:e.source})})}),(0,E.jsx)(`div`,{style:{fontSize:`var(--text-xs)`,color:`var(--text-dim)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,marginTop:2},children:(0,E.jsx)(oi,{label:QG(e,l),children:(0,E.jsxs)(`span`,{style:{display:`inline-flex`,gap:8},children:[(e.version||e.configuredVersion)&&(0,E.jsxs)(`span`,{children:[(0,E.jsxs)(`span`,{children:[l(`i18n.versionShort`),`:`]}),(0,E.jsx)(`span`,{style:{color:`var(--text)`},children:e.version||e.configuredVersion})]}),(0,E.jsxs)(`span`,{children:[(0,E.jsxs)(`span`,{children:[l(`i18n.extensionShort`),`:`]}),(0,E.jsx)(`span`,{style:{color:`var(--text)`},children:e.counts.extensions})]}),(0,E.jsxs)(`span`,{children:[(0,E.jsxs)(`span`,{children:[l(`i18n.skillShort`),`:`]}),(0,E.jsx)(`span`,{style:{color:`var(--text)`},children:e.counts.skills})]})]})})})]})]},t)})]},e.scope))}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{style:{padding:`4px 8px 3px`,fontSize:`var(--text-xs)`,fontWeight:600,color:`var(--text-dim)`,textTransform:`uppercase`},children:l(`plugins.extensionFilters`)}),(0,E.jsx)(`div`,{style:{padding:`0 8px 4px`,fontSize:`var(--text-xs)`,color:`var(--text-dim)`,lineHeight:1.45},children:l(`plugins.extensionFiltersHint`)}),ge.length===0||me&&_e.length===0?(0,E.jsx)(`div`,{style:{padding:`10px 8px`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`},children:l(me?`i18n.noMatch`:`plugins.noExtensionFilters`)}):_e.map(e=>(0,E.jsxs)(`div`,{style:{marginBottom:6},children:[(0,E.jsx)(`div`,{style:{padding:`4px 8px 3px`,fontSize:`var(--text-xs)`,fontWeight:600,color:`var(--text-dim)`,textTransform:`uppercase`},children:e.scope}),e.filters.map(e=>{let t=ZG(e),n=S===`filter`&&b===t;return(0,E.jsxs)(`div`,{"data-testid":`extension-filter-item-${e.scope}-${e.pattern}`,onClick:()=>{x(t),y(null),C(`filter`),L(null),R(null)},style:{display:`flex`,alignItems:`center`,gap:7,padding:`6px 8px`,borderRadius:5,cursor:`pointer`},className:n?`selectable-row row-selected-gradient`:`selectable-row`,children:[(0,E.jsx)(`span`,{style:{flexShrink:0,width:18,height:18,borderRadius:4,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:`var(--text-sm)`,fontWeight:700,fontFamily:`var(--font-mono)`,color:nK(e.pattern),background:`color-mix(in srgb, var(--border) 55%, transparent)`},children:e.pattern[0]}),(0,E.jsx)(`span`,{style:{minWidth:0,flex:1,fontSize:`var(--text-sm)`,color:`var(--text)`,fontFamily:`var(--font-mono)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:(0,E.jsx)(oi,{label:e.pattern,children:(0,E.jsx)(`span`,{children:e.pattern})})})]},t)})]},`filters-${e.scope}`))]})}),(0,E.jsx)(`div`,{style:{padding:`8px 6px`,borderTop:`1px solid var(--border)`,flexShrink:0},children:w===`plugins`?(0,E.jsxs)(`button`,{type:`button`,onClick:()=>{C(`addPlugin`),L(null),R(null)},style:{display:`flex`,alignItems:`center`,gap:6,padding:`7px 8px`,borderRadius:5,border:`none`,width:`100%`,cursor:`pointer`,color:S===`addPlugin`?`var(--accent)`:`var(--text-dim)`,fontSize:`var(--text-base)`},className:S===`addPlugin`?`row-selected-gradient`:`hover-shift`,children:[(0,E.jsxs)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,E.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]}),l(`i18n.addPlugin`)]}):(0,E.jsxs)(`button`,{type:`button`,"data-testid":`add-extension-filter-btn`,onClick:()=>{C(`addFilter`),x(null),y(null),L(null),R(null)},style:{display:`flex`,alignItems:`center`,gap:6,padding:`7px 8px`,borderRadius:5,border:`none`,width:`100%`,cursor:`pointer`,color:S===`addFilter`?`var(--accent)`:`var(--text-dim)`,fontSize:`var(--text-base)`},className:S===`addFilter`?`row-selected-gradient`:`hover-shift`,children:[(0,E.jsxs)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`path`,{d:`M3 6h18`}),(0,E.jsx)(`path`,{d:`M7 12h10`}),(0,E.jsx)(`path`,{d:`M11 18h2`})]}),l(`plugins.addFilter`)]})})]}),!c&&(0,E.jsx)(wx,{width:F,onResize:te,ariaLabel:l(`i18n.resizeList`,{name:l(`i18n.plugins`)})}),(0,E.jsx)(`div`,{style:{flex:1,overflowY:`auto`,padding:20},children:S===`addFilter`?(0,E.jsx)(_K,{pattern:k,scope:P,projectResourcesLoaded:fe,busy:De,actionError:I,onPatternChange:A,onScopeChange:ee,onAdd:Ce}):m?null:S===`filter`&&de?(0,E.jsx)(vK,{filter:de,busyKey:ae,actionError:I,actionMessage:se,onRemove:e=>void xe(`removeExtensionFilter`,e)},ZG(de)):S===`addPlugin`?(0,E.jsx)(gK,{cwd:e,source:D,scope:j,projectResourcesLoaded:fe,busy:Ee,actionError:I,packages:ce,onSourceChange:O,onScopeChange:M,onInstall:Se}):le?(0,E.jsx)(yK,{pkg:le,busyKey:ae,actionError:I,actionMessage:se,sessionId:t,onAction:be,onReloadSession:Te,onOpenFile:r},XG(le)):(0,E.jsx)(`div`,{style:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--text-dim)`,fontSize:`var(--text-lg)`},children:de?null:l(`i18n.selectPackage`)})})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:12,padding:`10px 18px`,borderTop:`1px solid var(--border)`,flexShrink:0},children:[(0,E.jsx)(`div`,{style:{minWidth:0,flex:1,fontSize:`var(--text-sm)`,color:`var(--text-dim)`,overflow:`hidden`},children:u?.diagnostics.length?(0,E.jsxs)(`span`,{title:u.diagnostics.map(e=>`${e.type}: ${e.source?`${e.source}: `:``}${e.message}`).join(`
|
|
347
347
|
`),style:{color:u.diagnostics.some(e=>e.type===`error`)?`var(--status-error)`:`var(--status-warning)`},children:[u.diagnostics.length,` diagnostic`,u.diagnostics.length===1?``:`s`]}):(0,E.jsx)(`span`,{children:u?`${u.totals.extensions} ext · ${u.totals.skills} skills · ${u.totals.prompts} prompts · ${u.totals.themes} themes`:``})}),(0,E.jsx)(`button`,{onClick:()=>void ye(),disabled:m||ae!==null,style:cK(m||ae!==null),children:l(`i18n.refresh`)}),(0,E.jsx)(`button`,{onClick:n,style:cK(!1),children:l(`i18n.close`)})]})]})})}function SK(e){return e.replace(/^\/(?:Users|home)\/[^/]+/,`~`)}function CK(e){let t=e.sourceInfo?.source,n=e.sourceInfo?.scope;return n===`user`||t===`user`?`global`:n===`project`||t===`project`?`project`:`path`}function wK(e){let t=CK(e);return t===`path`?t:e.install?.skillsShUrl?`${t} / skills.sh`:t}function TK(e){return e.install?`${e.install.scope}\0${e.install.package}`:null}function EK(e){return e?e.slice(0,8):`unknown`}function DK({enabled:e,loading:t,onToggle:n}){let{t:r}=N();return(0,E.jsx)(`button`,{onClick:n,disabled:t,title:r(e?`i18n.visibleInPrompt`:`i18n.hiddenFromPrompt`),style:{flexShrink:0,width:40,height:22,borderRadius:11,border:`none`,padding:0,cursor:t?`wait`:`pointer`,background:e?`var(--accent)`:`var(--border)`,position:`relative`,transition:`background 0.18s`,outline:`none`},children:(0,E.jsx)(`span`,{style:{position:`absolute`,top:3,left:e?21:3,width:16,height:16,borderRadius:`50%`,background:`var(--bg)`,boxShadow:`0 1px 4px var(--shadow-color)`,transition:`left 0.18s cubic-bezier(.4,0,.2,1)`}})})}function OK({skill:e,cwd:t,onToggle:n,toggling:r,saveError:i,updateStatus:a,checkingUpdate:o,updating:s,updateError:c,onCheckUpdate:l,onUpdate:u}){let{t:d}=N(),f=CK(e),p=!e.disableModelInvocation;function m(e){return f===`project`&&e.startsWith(t)?`./${e.slice(t.length).replace(/^[/\\]/,``)}`:SK(e)}return(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:20},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:7},children:[(0,E.jsx)(`span`,{style:{fontSize:`var(--text-xs)`,padding:`1px 5px`,borderRadius:3,flexShrink:0,background:f===`project`?`color-mix(in srgb, var(--status-info) 12%, transparent)`:`color-mix(in srgb, var(--text-dim) 12%, transparent)`,color:f===`project`?`color-mix(in srgb, var(--status-info) 80%, transparent)`:`var(--text-dim)`},children:f}),(0,E.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`,flex:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:m(e.filePath)}),(0,E.jsx)(DK,{enabled:p,loading:r,onToggle:()=>n(e)})]}),(0,E.jsxs)(`div`,{style:{minHeight:16,display:`flex`,alignItems:`center`,justifyContent:`flex-end`,gap:8,flexWrap:`wrap`,textAlign:`right`},children:[!p&&(0,E.jsx)(`span`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-dim)`},children:d(`i18n.hiddenButInvocable`)}),i&&(0,E.jsx)(`span`,{style:{fontSize:`var(--text-base)`,color:`var(--status-error)`,overflowWrap:`anywhere`},children:i})]})]}),e.install?.skillsShUrl&&(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:[(0,E.jsx)(`span`,{style:{fontSize:`var(--text-base)`,color:`var(--text-muted)`,fontWeight:500},children:`Source`}),(0,E.jsx)(`a`,{href:e.install.skillsShUrl,target:`_blank`,rel:`noreferrer`,title:e.install.skillsShUrl,style:{display:`flex`,alignItems:`center`,gap:8,width:`fit-content`,maxWidth:`100%`,color:`var(--accent)`,textDecoration:`none`},children:(0,E.jsxs)(`span`,{style:{fontFamily:`var(--font-mono)`,fontSize:`var(--text-base)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:[e.install.skillsShUrl.replace(/^https?:\/\//,``),` ↗`]})})]}),e.install&&(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:7},children:[(0,E.jsx)(`span`,{style:{fontSize:`var(--text-base)`,color:`var(--text-muted)`,fontWeight:500},children:`Version`}),(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,flexWrap:`wrap`},children:[(0,E.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`,fontSize:`var(--text-base)`,color:`var(--text-muted)`},children:EK(a?.currentVersion??e.install.versionHash)}),e.install.canCheckForUpdates&&(0,E.jsx)(`button`,{onClick:l,disabled:o||s,style:{padding:`4px 9px`,border:`1px solid var(--border)`,borderRadius:5,background:`none`,color:`var(--text-muted)`,cursor:o||s?`not-allowed`:`pointer`,opacity:o||s?.5:1,fontSize:`var(--text-sm)`},children:d(`i18n.check`)}),a?.state===`update-available`&&(0,E.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`,fontSize:`var(--text-base)`,color:`var(--status-warning)`},children:EK(a.latestVersion)}),(o||a&&a.state!==`update-available`)&&(0,E.jsx)(`span`,{style:{fontSize:`var(--text-base)`,color:o?`var(--accent)`:a?.state===`up-to-date`?`var(--status-success)`:a?.state===`error`?`var(--status-error)`:`var(--text-dim)`},children:o?d(`i18n.checking`):a?.state===`up-to-date`?d(`i18n.upToDate`):a?.state===`unsupported`?d(`i18n.automaticChecksUnavailable`):a?.message||d(`i18n.checkFailed`)}),a?.state===`update-available`&&(0,E.jsx)(`button`,{onClick:u,disabled:s||o,style:{padding:`4px 10px`,border:`none`,borderRadius:5,background:`var(--accent)`,color:`var(--on-accent)`,cursor:s||o?`not-allowed`:`pointer`,opacity:s||o?.5:1,fontSize:`var(--text-sm)`,fontWeight:600},children:d(s?`i18n.updating`:`i18n.update`)})]}),c&&(0,E.jsx)(`span`,{style:{fontSize:`var(--text-base)`,color:`var(--status-error)`},children:c})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:[(0,E.jsx)(`span`,{style:{fontSize:`var(--text-base)`,color:`var(--text-muted)`,fontWeight:500},children:`Name`}),(0,E.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`,fontSize:`var(--text-xl)`,color:`var(--text)`},children:e.name})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:[(0,E.jsx)(`span`,{style:{fontSize:`var(--text-base)`,color:`var(--text-muted)`,fontWeight:500},children:`Description`}),(0,E.jsx)(`span`,{style:{fontSize:`var(--text-xl)`,color:`var(--text-muted)`,lineHeight:1.6},children:e.description})]})]})}function kK({cwd:e,installedPackages:t,projectResourcesLoaded:n,onInstalled:r}){let{t:i}=N(),[a,o]=(0,d.useState)(``),[s,c]=(0,d.useState)([]),[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(null),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(null),[v,y]=(0,d.useState)(new Set),[b,x]=(0,d.useState)(`global`),S=(0,d.useRef)(null);(0,d.useEffect)(()=>{S.current?.focus()},[]);let C=(0,d.useCallback)(async e=>{if(e.trim()){u(!0),p(null),c([]);try{let t=await(await fetch(`/api/skills/search`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({query:e.trim()})})).json();if(t.error){p(t.error);return}c(t.results??[]),(t.results??[]).length===0&&p(i(`i18n.noSkills`))}catch(e){p(String(e))}finally{u(!1)}}},[i]),w=(0,d.useCallback)(async t=>{h(t),_(null);try{let n=await fetch(`/api/skills/install`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({package:t,scope:b,cwd:e})}),i=await n.json();if(!n.ok||i.error){_(i.error??`HTTP ${n.status}`);return}y(e=>new Set(e).add(`${b}:${t}`)),r()}catch(e){_(String(e))}finally{h(null)}},[r,b,e]),T=b===`global`?`~/.pi/agent/skills/`:`${SK(e)}/.pi/skills/`;return(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12,marginBottom:20},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-xl)`,fontWeight:600,color:`var(--text)`},children:i(`i18n.addSkill`)}),(0,E.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,E.jsx)(`input`,{ref:S,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&C(a)},placeholder:i(`i18n.skillSearchPlaceholder`),style:{flex:1,padding:`7px 10px`,fontSize:`var(--text-lg)`,background:`var(--bg-input)`,border:`1px solid var(--border)`,borderRadius:6,color:`var(--text)`,outline:`none`}}),(0,E.jsx)(`button`,{onClick:()=>C(a),disabled:l||!a.trim(),style:{padding:`7px 16px`,fontSize:`var(--text-lg)`,borderRadius:6,border:`none`,background:`var(--accent)`,color:`var(--on-accent)`,cursor:l||!a.trim()?`not-allowed`:`pointer`,opacity:l||!a.trim()?.5:1,flexShrink:0},children:i(l?`i18n.searching`:`i18n.search`)})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[(0,E.jsx)(`div`,{style:{display:`flex`,borderRadius:5,border:`1px solid var(--border)`,overflow:`hidden`,fontSize:`var(--text-base)`,flexShrink:0},children:[`global`,`project`].map(e=>(0,E.jsx)(`button`,{onClick:()=>{(e===`global`||n)&&x(e)},disabled:e===`project`&&!n,title:e===`project`&&!n?i(`trust.projectScopeUnavailable`):void 0,style:{padding:`3px 10px`,border:`none`,cursor:e===`project`&&!n?`not-allowed`:`pointer`,background:b===e?`var(--accent)`:`transparent`,color:b===e?`var(--on-accent)`:`var(--text-dim)`,fontWeight:b===e?600:400,opacity:e===`project`&&!n?.45:1,borderRight:e===`global`?`1px solid var(--border)`:`none`},children:e},e))}),(0,E.jsxs)(`span`,{style:{fontSize:`var(--text-base)`,color:`var(--text-dim)`,fontFamily:`var(--font-mono)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:[`→ `,T]})]}),f&&(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--status-error)`},children:f}),g&&(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--status-error)`,wordBreak:`break-word`},children:g})]}),s.length>0?(0,E.jsx)(`div`,{style:{flex:1,overflowY:`auto`},children:s.map(e=>{let n=t[b].has(e.package)||v.has(`${b}:${e.package}`),r=m===e.package,a=e.package.indexOf(`@`),o=a>-1?e.package.slice(0,a):e.package,s=a>-1?e.package.slice(a+1):null;return(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:14,padding:`12px 0`,borderBottom:`1px solid var(--border)`},children:[(0,E.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-lg)`,fontWeight:600,color:`var(--text)`,marginBottom:3},children:s??o}),(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,flexWrap:`wrap`},children:[(0,E.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`},children:o}),(0,E.jsx)(`span`,{style:{fontSize:`var(--text-base)`,color:`var(--text-muted)`,fontWeight:500},children:e.installs}),e.url&&(0,E.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,style:{fontSize:`var(--text-base)`,color:`var(--accent)`,textDecoration:`none`},children:`skills.sh ↗`})]})]}),(0,E.jsx)(`button`,{onClick:()=>!n&&!r&&w(e.package),disabled:n||r||m!==null,style:{flexShrink:0,padding:`5px 14px`,fontSize:`var(--text-base)`,fontWeight:500,borderRadius:5,border:`1px solid var(--border)`,cursor:n||r||m!==null?`not-allowed`:`pointer`,background:n?`color-mix(in srgb, var(--status-success) 10%, transparent)`:`none`,color:n?`var(--status-success)`:r?`var(--accent)`:`var(--text-muted)`,transition:`color 0.12s`},children:n?`✓ ${i(`i18n.installed`)}`:i(r?`i18n.installing`:`i18n.install`)})]},e.package)})}):!f&&!l&&(0,E.jsxs)(`div`,{style:{fontSize:`var(--text-lg)`,color:`var(--text-dim)`,lineHeight:1.8},children:[`Search`,` `,(0,E.jsx)(`a`,{href:`https://skills.sh`,target:`_blank`,rel:`noreferrer`,style:{color:`var(--accent)`,textDecoration:`none`},children:`skills.sh`}),` `,`to discover and install skills for your agent.`]})]})}var AK=null;function jK({cwd:e,onClose:t,pane:n,homeSkills:r=[]}){let i=ne(),{t:a}=N(),[o,s]=(0,d.useState)([]),c=(0,d.useMemo)(()=>r.length===0?o:[...o,...r],[o,r]),[l,u]=(0,d.useState)(!0),[f,m]=(0,d.useState)(null),[h,g]=(0,d.useState)(AK),[_,v]=(0,d.useState)(new Set),[y,b]=(0,d.useState)(null),[x,S]=(0,d.useState)(!1),[C,w]=(0,d.useState)({}),[T,D]=(0,d.useState)(new Set),[O,k]=(0,d.useState)(!1),[A,j]=(0,d.useState)(null),[M,P]=(0,d.useState)(null),[ee,F]=(0,d.useState)(!0),[te,re]=(0,d.useState)({}),[ie,ae]=(0,d.useState)(280),[oe,I]=(0,d.useState)(``),L=oe.trim().toLowerCase(),se=(0,d.useCallback)(async()=>{u(!0),m(null);try{let t=await fetch(`/api/skills?cwd=${encodeURIComponent(e)}`),n=await t.json();if(!t.ok||n.error)throw Error(n.error??`HTTP ${t.status}`);let r=n.skills??[];if(s(r),F(n.projectResourcesLoaded??!0),r.length>0&&!h){let e=r.find(e=>!e.disableModelInvocation)??r[0];g(e.filePath),e.disableModelInvocation&&re(t=>({...t,[wK(e)]:!0}))}return r}catch(e){return m(String(e)),[]}finally{u(!1)}},[e,h]);(0,d.useEffect)(()=>{w({}),P(null),se()},[e]),(0,d.useEffect)(()=>{AK=h});let R=(0,d.useCallback)(async t=>{let n=(t?[t]:o.filter(e=>!!e.install)).map(TK).filter(e=>!!e);if(n.length!==0){P(null),D(e=>new Set([...e,...n])),t||k(!0);try{let n=await fetch(`/api/skills/check`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:e,package:t?.install?.package,scope:t?.install?.scope})}),r=await n.json();if(!n.ok||r.error)throw Error(r.error??`HTTP ${n.status}`);w(e=>{let t={...e};for(let e of r.updates??[])t[`${e.scope}\0${e.package}`]=e;return t})}catch(e){P(e instanceof Error?e.message:String(e))}finally{D(e=>{let t=new Set(e);for(let e of n)t.delete(e);return t}),t||k(!1)}}},[e,o]),ce=(0,d.useCallback)(async t=>{if(!t.install)return;let n=TK(t);j(n),P(null);try{let r=await fetch(`/api/skills/update`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:e,package:t.install.package,scope:t.install.scope})}),i=await r.json();if(!r.ok||i.error||!i.success)throw Error(i.error??`HTTP ${r.status}`);await se();let a=i.skill?.install?.versionHash;w(e=>({...e,[n]:{package:t.install.package,scope:t.install.scope,state:`up-to-date`,currentVersion:a,latestVersion:a}}))}catch(e){P(e instanceof Error?e.message:String(e))}finally{j(null)}},[e,se]),le=(0,d.useCallback)(async t=>{let n=!t.disableModelInvocation;v(e=>new Set(e).add(t.filePath)),b(null);try{let i=await fetch(`/api/skills`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({filePath:t.filePath,disableModelInvocation:n,cwd:e})}),a=await i.json();if(!i.ok||a.error){b(a.error??`HTTP ${i.status}`);return}s(e=>e.map(e=>e.filePath===t.filePath?{...e,disableModelInvocation:n}:e)),r.some(e=>e.filePath===t.filePath)&&Te.refresh().catch(()=>{}),n&&re(e=>({...e,[wK(t)]:!0}))}catch(e){b(String(e))}finally{v(e=>{let n=new Set(e);return n.delete(t.filePath),n})}},[r,e]),ue=o.find(e=>e.filePath===h)??null;return(0,E.jsx)(`div`,{style:n?{display:`contents`}:{position:`fixed`,inset:0,zIndex:1e3,background:`var(--overlay)`,display:`flex`,alignItems:`center`,justifyContent:`center`},onClick:e=>{e.target===e.currentTarget&&t()},children:(0,E.jsxs)(`div`,{style:n?{width:`100%`,height:`100%`,background:`var(--bg)`,display:`flex`,flexDirection:`column`,overflow:`hidden`}:{width:i?`calc(100vw - 16px)`:860,maxWidth:`calc(100vw - 16px)`,height:i?`calc(100dvh - 16px)`:`78vh`,maxHeight:`calc(100dvh - 16px)`,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:10,display:`flex`,flexDirection:`column`,boxShadow:`0 8px 32px var(--shadow-color)`,overflow:`hidden`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`12px 18px`,borderBottom:`1px solid var(--border)`,flexShrink:0},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,gap:10},children:[(0,E.jsx)(`span`,{style:{fontSize:`var(--text-2xl)`,fontWeight:700,color:`var(--text)`},children:a(`common.skills`)}),(0,E.jsx)(`code`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-muted)`,fontFamily:`var(--font-mono)`,maxWidth:320,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:SK(e)}),(0,E.jsx)(Xx,{testId:`skills-search`,query:oe,onChange:I,t:a})]}),!n&&(0,E.jsx)(`button`,{onClick:t,style:{background:`none`,border:`none`,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-5xl)`,lineHeight:1,padding:`2px 6px`},children:`×`})]}),!ee&&(0,E.jsx)(`div`,{role:`status`,style:{padding:`8px 18px`,borderBottom:`1px solid var(--border)`,background:`var(--bg-panel)`,color:`var(--text-muted)`,fontSize:`var(--text-base)`},children:a(`trust.skillsNotLoaded`)}),(0,E.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:i?`column`:`row`,overflow:`hidden`},children:[(0,E.jsxs)(`div`,{style:{width:i?`100%`:ie,maxHeight:i?`40vh`:void 0,display:`flex`,flexDirection:`column`,flexShrink:0,background:`var(--bg)`},children:[(0,E.jsx)(`div`,{style:{flex:1,overflowY:`auto`,padding:`8px 6px`},children:l?(0,E.jsx)(`div`,{style:{padding:`10px 8px`,fontSize:`var(--text-base)`,color:`var(--text-muted)`},children:a(`i18n.loading`)}):f?(0,E.jsx)(`div`,{style:{padding:`10px 8px`,fontSize:`var(--text-sm)`,color:`var(--status-error)`},children:f}):c.length===0?(0,E.jsx)(`div`,{style:{padding:`10px 8px`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`},children:a(`i18n.noSkills`)}):(()=>{let e=L?c.filter(e=>e.name.toLowerCase().includes(L)):c,t=[],n=[{label:`project / skills.sh`,matches:e=>CK(e)===`project`&&!!e.install?.skillsShUrl},{label:`project`,matches:e=>CK(e)===`project`&&!e.install?.skillsShUrl},{label:`global / skills.sh`,matches:e=>CK(e)===`global`&&!!e.install?.skillsShUrl},{label:`global`,matches:e=>CK(e)===`global`&&!e.install?.skillsShUrl},{label:`path`,matches:e=>CK(e)===`path`}];for(let{label:r,matches:i}of n){let n=e.filter(i);n.length>0&&t.push({label:r,skills:n})}if(t.length===0)return(0,E.jsx)(`div`,{style:{padding:`10px 8px`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`},children:a(`i18n.noMatch`)});let r=e=>{let t=!x&&h===e.filePath,n=e.disableModelInvocation;return(0,E.jsxs)(`div`,{onClick:()=>{g(e.filePath),S(!1)},style:{display:`flex`,alignItems:`center`,gap:7,padding:`8px 8px`,borderRadius:5,cursor:`pointer`},className:t?`selectable-row row-selected-gradient`:`selectable-row`,children:[(0,E.jsx)(`span`,{style:{flexShrink:0,width:7,height:7,borderRadius:`50%`,background:n?`var(--border)`:`var(--accent)`,boxShadow:n?`none`:`0 0 4px var(--accent)`,transition:`background 0.15s, box-shadow 0.15s`}}),(0,E.jsx)(oi,{label:e.name,children:(0,E.jsx)(`span`,{style:{fontSize:`var(--text-base)`,fontWeight:t?600:400,color:n?`var(--text-dim)`:`var(--text)`,fontFamily:`var(--font-mono)`,flex:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.name})}),(()=>{let t=TK(e);return(t?C[t]:void 0)?.state===`update-available`?(0,E.jsx)(`span`,{title:a(`i18n.updateAvailable`),style:{color:`var(--status-warning)`,fontSize:`var(--text-lg)`,lineHeight:1,flexShrink:0},children:`↑`}):null})()]},e.filePath)};return t.map(({label:e,skills:t})=>{let n=t.filter(e=>!e.disableModelInvocation),i=t.filter(e=>e.disableModelInvocation),o=te[e]??!1;return(0,E.jsxs)(`div`,{style:{marginBottom:6},children:[(0,E.jsx)(`div`,{style:{padding:`4px 8px 3px`,fontSize:`var(--text-xs)`,fontWeight:600,color:`var(--text-dim)`,textTransform:`uppercase`,letterSpacing:`0.06em`},children:e}),n.map(r),i.length>0&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{onClick:()=>re(t=>({...t,[e]:!o})),style:{display:`flex`,alignItems:`center`,gap:5,padding:`4px 8px 3px`,fontSize:`var(--text-xs)`,fontWeight:600,color:`var(--text-dim)`,textTransform:`uppercase`,letterSpacing:`0.06em`,cursor:`pointer`,userSelect:`none`},children:[(0,E.jsx)(`span`,{style:{fontSize:`var(--text-3xs)`},children:o?`▾`:`▸`}),a(`i18n.dormant`),` (`,i.length,`)`]}),o||L?i.map(r):null]})]},e)})})()}),(0,E.jsx)(`div`,{style:{padding:`8px 6px`,borderTop:`1px solid var(--border)`,flexShrink:0},children:!L&&(0,E.jsxs)(`div`,{onClick:()=>S(!0),style:{display:`flex`,alignItems:`center`,gap:6,padding:`7px 8px`,borderRadius:5,cursor:`pointer`,color:x?`var(--accent)`:`var(--text-dim)`,fontSize:`var(--text-base)`},className:x?`row-selected-gradient`:`hover-shift`,children:[(0,E.jsxs)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,E.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]}),a(`i18n.addSkill`)]})})]}),!i&&(0,E.jsx)(wx,{width:ie,onResize:ae,ariaLabel:a(`i18n.resizeList`,{name:a(`i18n.skills`)})}),(0,E.jsx)(`div`,{style:{flex:1,overflowY:`auto`,padding:20},children:x?(0,E.jsx)(kK,{cwd:e,projectResourcesLoaded:ee,installedPackages:{global:new Set(o.filter(e=>e.install?.scope===`global`).map(e=>e.install.package)),project:new Set(o.filter(e=>e.install?.scope===`project`).map(e=>e.install.package))},onInstalled:()=>{se()}}):l?null:ue?(0,E.jsx)(OK,{skill:ue,cwd:e,onToggle:le,toggling:_.has(ue.filePath),saveError:y,updateStatus:TK(ue)?C[TK(ue)]:void 0,checkingUpdate:TK(ue)?T.has(TK(ue)):!1,updating:A===TK(ue),updateError:M,onCheckUpdate:()=>void R(ue),onUpdate:()=>void ce(ue)},ue.filePath):(0,E.jsx)(`div`,{style:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--text-dim)`,fontSize:`var(--text-lg)`},children:a(`i18n.selectSkill`)})})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`10px 18px`,borderTop:`1px solid var(--border)`,flexShrink:0},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[c.some(e=>!!e.install)&&(0,E.jsx)(`button`,{onClick:()=>void R(),disabled:O||A!==null,style:{padding:`6px 12px`,background:`none`,border:`1px solid var(--border)`,borderRadius:6,color:`var(--text-muted)`,cursor:O||A!==null?`not-allowed`:`pointer`,opacity:O||A!==null?.5:1,fontSize:`var(--text-base)`},children:a(O?`i18n.checking`:`i18n.checkUpdates`)}),Object.values(C).filter(e=>e.state===`update-available`).length>0&&(0,E.jsxs)(`span`,{style:{fontSize:`var(--text-base)`,color:`var(--status-warning)`},children:[Object.values(C).filter(e=>e.state===`update-available`).length,` `,Object.values(C).filter(e=>e.state===`update-available`).length===1?a(`i18n.update`):a(`i18n.updates`)]})]}),(0,E.jsx)(`button`,{onClick:t,style:{padding:`6px 14px`,background:`none`,border:`1px solid var(--border)`,borderRadius:6,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-lg)`},children:a(`i18n.close`)})]})]})})}var MK=[{name:`compact`,description:`chat.commandCompact`,source:`builtin`},{name:`reload`,description:`chat.commandReload`,source:`builtin`},{name:`name`,description:`chat.commandName`,source:`builtin`},{name:`session`,description:`chat.commandSession`,source:`builtin`},{name:`copy`,description:`chat.commandCopy`,source:`builtin`}],NK=[`builtin`,`extension`,`prompt`,`skill`],PK={builtin:`chat.builtIn`,extension:`chat.extensions`,prompt:`chat.prompts`,skill:`chat.skills`},FK={builtin:0,extension:1,prompt:2,skill:3},IK=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`});function LK(e,t,n){let r=e.name.toLowerCase(),i=RK(e,n).toLowerCase();return r===t?0:r.startsWith(t)?1:r.includes(t)?2:i.includes(t)?3:4}function RK(e,t){return e.source===`builtin`?t(e.description):e.description??``}function zK(e,t){return e.source!==`skill`||!e.name.startsWith(`skill:`)?!1:t[e.name.slice(6)]===!0}function BK(e,t){let n=0,r=NK.map(r=>{let i=e.filter(e=>e.source===r);return{source:r,items:(r===`skill`?[...i.filter(e=>!zK(e,t)),...i.filter(e=>zK(e,t))]:i).map(e=>({command:e,index:n++}))}}).filter(e=>e.items.length>0);return{commands:r.flatMap(e=>e.items.map(({command:e})=>e)),groups:r}}function VK(e){return e.startsWith(`/`)&&!/\s/.test(e.slice(1))?e.slice(1).toLowerCase():null}function HK(e){let{value:t,commands:n,skillDormancy:r={},builtinDisabled:i=!1,onLoadCommands:a,onApply:o}=e,{t:s}=N(),c=VK(t),[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(0),m=(0,d.useRef)([]),h=(0,d.useRef)(!1),g=(0,d.useRef)(a);(0,d.useEffect)(()=>{g.current=a});let _=(0,d.useMemo)(()=>c===null?[]:[...i?[]:MK,...n??[]].filter(e=>{let t=e.name.toLowerCase(),n=RK(e,s).toLowerCase();return t.includes(c)||n.includes(c)}).sort((e,t)=>{let n=LK(e,c,s)-LK(t,c,s);return n===0?FK[e.source]-FK[t.source]||IK.compare(e.name,t.name):n}),[c,i,n,s]),{commands:v,groups:y}=(0,d.useMemo)(()=>BK(_,r),[_,r]),b=(0,d.useMemo)(()=>_.length===1?s(c?`chat.match`:`chat.command`):s(c?`chat.matches`:`chat.commands`,{count:_.length}),[_.length,c,s]);(0,d.useEffect)(()=>{if(c===null){u(!1),p(0),h.current=!1;return}u(!0),p(0);let e=g.current;!h.current&&e&&(h.current=!0,Promise.resolve(e()).catch(()=>{h.current=!1}))},[c]),(0,d.useEffect)(()=>{f>=v.length&&p(Math.max(0,v.length-1))},[v.length,f]),(0,d.useEffect)(()=>{m.current.length=v.length},[v.length]),(0,d.useEffect)(()=>{l&&m.current[f]?.scrollIntoView({block:`nearest`,behavior:`smooth`})},[f,l]);let x=(0,d.useCallback)(e=>{let t=v.length-1;if(t<0)return 0;if(e===`left`)return Math.max(0,f-1);if(e===`right`)return Math.min(t,f+1);let n=m.current[f];if(!n)return e===`down`?Math.min(t,f+1):Math.max(0,f-1);let r=n.getBoundingClientRect(),i=r.left+r.width/2,a=r.top+r.height/2,o=-1,s=1/0;for(let n=0;n<=t;n+=1){if(n===f)continue;let t=m.current[n];if(!t)continue;let r=t.getBoundingClientRect(),c=r.top+r.height/2-a;if(e===`down`?c<=4:c>=-4)continue;let l=r.left+r.width/2,u=Math.abs(c)*1e3+Math.abs(l-i);u<s&&(o=n,s=u)}return o>=0?o:e===`down`?Math.min(t,f+1):Math.max(0,f-1)},[v.length,f]),S=(0,d.useCallback)(e=>{o(e),u(!1),p(0)},[o]),C=(0,d.useCallback)(e=>!l||c===null?!1:e.key===`ArrowDown`?(e.preventDefault(),p(x(`down`)),!0):e.key===`ArrowUp`?(e.preventDefault(),p(x(`up`)),!0):e.key===`ArrowRight`?(e.preventDefault(),p(x(`right`)),!0):e.key===`ArrowLeft`?(e.preventDefault(),p(x(`left`)),!0):e.key===`Escape`?(e.preventDefault(),u(!1),!0):(e.key===`Tab`||e.key===`Enter`&&!e.shiftKey)&&v[f]?(e.preventDefault(),S(v[f]),!0):!1,[l,c,x,v,f,S]);return{open:l,query:c,filteredCount:_.length,countLabel:b,displayed:v,groups:y,activeIndex:f,setActiveIndex:p,itemRefs:m,apply:S,handleKeyDown:C}}function UK({palette:e,loading:t,skillDormancy:n}){let{t:r}=N();return e.open&&e.query!==null?(0,E.jsxs)(`div`,{style:{position:`absolute`,left:0,right:0,bottom:`calc(100% + 8px)`,zIndex:120,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:8,boxShadow:`0 -6px 20px var(--shadow-color)`,overflow:`hidden`,maxHeight:`min(56vh, 460px)`},children:[(0,E.jsxs)(`div`,{style:{padding:`8px 10px`,borderBottom:`1px solid var(--border)`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8,fontSize:`var(--text-sm)`,color:`var(--text-dim)`},children:[(0,E.jsx)(`span`,{children:t?r(`chat.loadingCommands`):r(`chat.slashCommands`,{label:e.countLabel})}),(0,E.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`},children:r(`chat.tabEnter`)})]}),(0,E.jsx)(`div`,{style:{maxHeight:`calc(min(56vh, 460px) - 34px)`,overflowY:`auto`,padding:10},children:!t&&e.filteredCount===0?(0,E.jsx)(`div`,{style:{padding:`2px 2px 4px`,fontSize:`var(--text-base)`,color:`var(--text-dim)`},children:r(`chat.noCommands`)}):e.groups.map(t=>(0,E.jsxs)(`section`,{style:{marginBottom:12},children:[(0,E.jsxs)(`div`,{style:{position:`sticky`,top:-10,zIndex:1,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8,padding:`4px 0 6px`,background:`var(--bg)`,color:`var(--text-dim)`,fontSize:`var(--text-xs)`,fontWeight:600,textTransform:`uppercase`},children:[(0,E.jsx)(`span`,{children:r(PK[t.source])}),(0,E.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`,fontWeight:500},children:t.items.length})]}),(0,E.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(220px, 1fr))`,gap:8},children:t.items.map(({command:t,index:i})=>{let a=i===e.activeIndex,o=zK(t,n);return(0,E.jsxs)(`button`,{ref:t=>{e.itemRefs.current[i]=t},type:`button`,onMouseDown:n=>{n.preventDefault(),e.apply(t)},onMouseEnter:()=>e.setActiveIndex(i),style:{width:`100%`,minWidth:0,minHeight:58,display:`flex`,flexDirection:`column`,gap:4,justifyContent:`center`,padding:`9px 10px`,border:`1px solid ${a?`var(--accent)`:`var(--border)`}`,borderRadius:7,background:a?`var(--bg-selected)`:`var(--bg-panel)`,color:`var(--text)`,cursor:`pointer`,textAlign:`left`,boxShadow:a?`0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent)`:`none`},children:[(0,E.jsxs)(`span`,{style:{fontSize:`var(--text-lg)`,fontFamily:`var(--font-mono)`,overflowWrap:`anywhere`,wordBreak:`break-word`,color:o?`var(--text-dim)`:void 0},children:[`/`,t.name,o&&(0,E.jsx)(`span`,{style:{marginLeft:6,padding:`0 4px`,border:`1px solid var(--border)`,borderRadius:3,fontSize:`var(--text-2xs)`,color:`var(--text-dim)`,whiteSpace:`nowrap`},children:r(`chat.dormant`)})]}),t.description&&(0,E.jsx)(`span`,{style:{display:`-webkit-box`,WebkitBoxOrient:`vertical`,WebkitLineClamp:2,overflow:`hidden`,fontSize:`var(--text-sm)`,lineHeight:1.35,color:`var(--text-dim)`},children:RK(t,r)})]},`${t.source}:${t.name}`)})})]},t.source))})]}):null}function WK({open:e,onOpenChange:t,onConfirm:n,title:r,hint:i,labelPlaceholder:a,messagePlaceholder:o,initialValue:s,testIdPrefix:c=`bind`}){let{t:l}=N(),[u,f]=(0,d.useState)(s?.label??``),[p,m]=(0,d.useState)(s?.message??``),[h,g]=(0,d.useState)(s?.allowAppend??!1),_=u.trim()!==``&&p.trim()!==``,v=Qn(Te).value,y=(0,d.useMemo)(()=>(v?.skills??[]).map(e=>({name:`skill:${e.name}`,description:e.description,source:`skill`})),[v]),b=(0,d.useMemo)(()=>{let e={};for(let t of v?.skills??[])e[t.name]=t.disableModelInvocation;return e},[v]),x=HK({value:p,commands:y,skillDormancy:b,onLoadCommands:()=>void Te.load().catch(()=>{}),onApply:(0,d.useCallback)(e=>{m(`/${e.name} `)},[])});return(0,E.jsx)(Ax,{open:e,onOpenChange:t,children:(0,E.jsxs)(Px,{className:`sm:max-w-md`,showCloseButton:!0,onEscapeKeyDown:e=>{x.open&&x.query!==null&&e.preventDefault()},children:[(0,E.jsx)(Fx,{style:{fontWeight:700,fontSize:`var(--text-2xl)`,color:`var(--text)`},children:r}),(0,E.jsx)(Ix,{style:{fontSize:`var(--text-base)`,color:`var(--text-dim)`},children:i}),(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10,marginTop:4},children:[(0,E.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,E.jsx)(`span`,{style:{fontSize:`var(--text-base)`,color:`var(--text-muted)`},children:l(`config.widgets.label`)}),(0,E.jsx)(CG,{"data-testid":`${c}-label`,value:u,onChange:e=>f(e.target.value),placeholder:a,autoFocus:!0})]}),(0,E.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,E.jsx)(`span`,{style:{fontSize:`var(--text-base)`,color:`var(--text-muted)`},children:l(`config.widgets.message`)}),(0,E.jsxs)(`div`,{style:{position:`relative`},children:[(0,E.jsx)(CG,{"data-testid":`${c}-message`,value:p,onChange:e=>m(e.target.value),placeholder:o,onKeyDown:e=>{x.handleKeyDown(e)||e.key===`Enter`&&_&&(n(u.trim(),p.trim(),h),f(``),m(``),g(!1))}}),(0,E.jsx)(UK,{palette:x,skillDormancy:b})]})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[(0,E.jsx)(`span`,{style:{fontSize:`var(--text-base)`,color:`var(--text-muted)`},children:l(`config.widgets.sendMode`)}),(0,E.jsx)(zx,{testId:`${c}-append`,value:h?`fill`:`send`,onChange:e=>g(e===`fill`),options:[{value:`send`,label:l(`config.widgets.sendImmediately`)},{value:`fill`,label:l(`config.widgets.fillToChatInput`)}]})]})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8,marginTop:12},children:[(0,E.jsx)(kx,{type:`button`,variant:`outline`,className:`h-8 px-3 text-xs`,onClick:()=>t(!1),children:l(`i18n.cancel`)}),(0,E.jsx)(kx,{type:`button`,"data-testid":`${c}-confirm`,className:`h-8 px-3 text-xs`,disabled:!_,style:{cursor:_?`pointer`:`default`,opacity:_?1:.5},onClick:()=>{n(u.trim(),p.trim(),h),f(``),m(``),g(!1)},children:l(`config.widgets.confirm`)})]})]})})}function GK({messages:e,onRemove:t,onEdit:n,chipTestIdPrefix:r}){return e.length===0?null:(0,E.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6,marginTop:8,paddingTop:8,borderTop:`1px solid var(--border)`},children:e.map((e,i)=>(0,E.jsx)(oi,{label:e.message,wrapperStyle:{display:`inline-flex`,minWidth:0},children:(0,E.jsx)(PG,{testId:`${r}-${i}`,label:e.label,title:e.message,onRemove:t?()=>t(i):void 0,onClick:n?()=>n(i):void 0})},i))})}function KK({messages:e,onAdd:t,onRemove:n,onUpdate:r,bindOpen:i,onBindOpenChange:a,ns:o,bindTestIdPrefix:s,editTestIdPrefix:c,chipTestIdPrefix:l,bindHintArgs:u,emptyLabel:f}){let{t:p}=N(),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(null),v=m===null?null:e[m],y=g===null?null:e[g];return(0,E.jsxs)(E.Fragment,{children:[e.length===0?f?(0,E.jsx)(`div`,{style:{padding:`24px 16px`,textAlign:`center`,color:`var(--text-dim)`,fontSize:`var(--text-lg)`,lineHeight:1.6},children:f}):null:(0,E.jsx)(GK,{messages:e,onRemove:e=>h(e),onEdit:e=>_(e),chipTestIdPrefix:l}),i&&(0,E.jsx)(WK,{open:!0,onOpenChange:a,onConfirm:(e,n,r)=>{t({label:e,message:n,allowAppend:r}),a(!1)},testIdPrefix:s,title:p(`config.${o}.bindTitle`),hint:p(`config.${o}.bindHint`,u),labelPlaceholder:p(`config.widgets.labelPlaceholder`),messagePlaceholder:p(`config.widgets.messagePlaceholder`)}),m!==null&&v&&(0,E.jsx)(Bx,{open:!0,title:p(`config.${o}.unbindTitle`),description:(0,E.jsxs)(`span`,{style:{display:`block`},children:[(0,E.jsx)(`span`,{style:{display:`block`},children:p(`config.${o}.unbindConfirm`,{label:v.label})}),(0,E.jsx)(`span`,{style:{display:`block`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,color:`var(--text-muted)`,padding:`6px 8px`,borderRadius:5,background:`var(--bg)`,border:`1px solid var(--border)`,overflowWrap:`anywhere`,marginTop:6},children:v.message})]}),confirmText:p(`config.${o}.unbind`),cancelText:p(`i18n.cancel`),destructive:!0,onCancel:()=>h(null),onConfirm:()=>{n(m),h(null)}}),g!==null&&y&&(0,E.jsx)(WK,{open:!0,onOpenChange:e=>!e&&_(null),onConfirm:(e,t,n)=>{r(g,{label:e,message:t,allowAppend:n}),_(null)},initialValue:y,testIdPrefix:c,title:p(`config.${o}.editTitle`),hint:p(`config.${o}.editHint`),labelPlaceholder:p(`config.widgets.labelPlaceholder`),messagePlaceholder:p(`config.widgets.messagePlaceholder`)},c)]})}function qK(){let{t:e}=N(),{startScreenMessages:t,addStartScreenMessage:n,removeStartScreenMessage:r,updateStartScreenMessage:i,resetStartScreenMessages:a}=ge(),[o,s]=(0,d.useState)(!1);return(0,E.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`},children:(0,E.jsxs)(`div`,{style:{flex:1,minHeight:0,overflowY:`auto`,padding:10,display:`flex`,flexDirection:`column`,gap:8},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--text-muted)`},children:e(`config.startScreen.hint`)}),(0,E.jsxs)(`div`,{style:{display:`flex`,gap:6},children:[(0,E.jsx)(oi,{label:e(`config.startScreen.resetHint`),children:(0,E.jsxs)(`button`,{type:`button`,"data-testid":`start-screen-reset`,onClick:a,style:{flexShrink:0,display:`flex`,alignItems:`center`,gap:4,padding:`4px 8px`,borderRadius:5,border:`1px solid var(--border)`,background:`var(--bg)`,color:`var(--text-muted)`,fontSize:`var(--text-sm)`,cursor:`pointer`},children:[(0,E.jsx)(Br,{size:13,"aria-hidden":!0}),e(`config.startScreen.reset`)]})}),(0,E.jsxs)(`button`,{type:`button`,"data-testid":`start-screen-bind`,onClick:()=>s(!0),style:{flexShrink:0,display:`flex`,alignItems:`center`,gap:4,padding:`4px 8px`,borderRadius:5,border:`1px solid var(--border)`,background:`var(--bg)`,color:`var(--text-muted)`,fontSize:`var(--text-sm)`,cursor:`pointer`},children:[(0,E.jsx)(Or,{size:13,"aria-hidden":!0}),e(`config.startScreen.bind`)]})]})]}),(0,E.jsx)(KK,{messages:t,onAdd:n,onRemove:r,onUpdate:i,bindOpen:o,onBindOpenChange:s,ns:`startScreen`,bindTestIdPrefix:`start-screen-bind`,editTestIdPrefix:`start-screen-edit`,chipTestIdPrefix:`start-screen-bound`,emptyLabel:e(`config.startScreen.empty`)})]})})}var JK=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`});function YK(e,t){return JK.compare(`${e.provider}/${e.name||e.modelId}`,`${t.provider}/${t.name||t.modelId}`)}function XK(e,t){let n=t.trim().toLocaleLowerCase();return n?e.filter(e=>`${e.provider}/${e.name}`.toLocaleLowerCase().includes(n)):e}function ZK({value:e,options:t,onChange:n,disabled:r,placeholder:i,variant:a=`form`,isAutoSelection:o}){let{t:s}=N(),[c,l]=(0,d.useState)(!1),[u,f]=(0,d.useState)(``),[m,h]=(0,d.useState)(0),[g,_]=(0,d.useState)(null),v=(0,d.useRef)(null),y=(0,d.useRef)(null),b=(0,d.useRef)(null),x=(0,d.useRef)(null),S=XK([...t].sort(YK),u),C=e?t.find(t=>t.provider===e.provider&&t.modelId===e.modelId)?.name??e.modelId:null;e&&C&&`${e.provider}${C}`,(0,d.useEffect)(()=>{b.current?.scrollIntoView({block:`nearest`})},[m,u]),(0,d.useEffect)(()=>{if(!c)return;let e=e=>{v.current?.contains(e.target)||y.current?.contains(e.target)||(l(!1),f(``))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[c]);let w=t=>{l(!1),f(``),(e?.provider!==t.provider||e?.modelId!==t.modelId||o)&&n(t.provider,t.modelId)};return(0,E.jsxs)(`div`,{style:{position:`relative`,display:a===`chat`?`flex`:`block`,minWidth:0,flex:a===`chat`?1:void 0},children:[(0,E.jsxs)(`button`,{ref:v,type:`button`,disabled:r,onClick:e=>{if(r)return;if(c){l(!1),f(``);return}let t=e.currentTarget.getBoundingClientRect();_({top:t.top,left:t.left,width:t.width}),l(!0),h(0),requestAnimationFrame(()=>x.current?.focus())},style:a===`chat`?{display:`flex`,alignItems:`center`,gap:6,padding:`8px 12px`,height:32,minWidth:0,maxWidth:`100%`,overflow:`hidden`,background:`none`,border:`none`,borderRadius:9,color:`var(--text-muted)`,cursor:r?`not-allowed`:`pointer`,fontSize:`var(--text-base)`,opacity:r?.5:1}:{display:`flex`,alignItems:`center`,gap:6,padding:`6px 10px`,height:32,width:320,maxWidth:`100%`,background:`var(--bg-input)`,border:`1px solid var(--border)`,borderRadius:6,color:e?`var(--text)`:`var(--text-dim)`,cursor:r?`not-allowed`:`pointer`,fontSize:`var(--text-base)`,textAlign:`left`},className:r?void 0:`hover-shift`,"aria-expanded":c,children:[a===`chat`&&(0,E.jsx)(_r,{size:p[`2xl`],style:{color:`var(--status-info)`,flexShrink:0}}),(0,E.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,minWidth:0,flex:a===`form`?1:void 0},children:e&&C?a===`chat`?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`span`,{style:{color:`var(--text-dim)`},children:[e.provider,`/`]}),(0,E.jsx)(`span`,{style:{fontWeight:700,color:`var(--text)`},children:C})]}):`${e.provider}/${C}`:i??(t.length>0?s(`chat.filterModels`):s(`git.commitModel.noModels`))})]}),c&&g&&(0,E.jsxs)(`div`,{ref:y,"data-testid":`model-dropdown`,style:{position:`fixed`,zIndex:500,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:8,boxShadow:`0 -4px 16px var(--shadow-color)`,overflow:`hidden`,display:`flex`,flexDirection:`column`,...a===`chat`?(()=>{let e=window.visualViewport?.height??window.innerHeight,t=e-g.top+6,n=Math.max(120,Math.min(g.top-8,e*.6));return{bottom:t,left:g.left,width:`max-content`,minWidth:g.width,maxHeight:n}})():{top:g.top+32+4,left:g.left,width:g.width,maxHeight:280}},children:[(0,E.jsx)(`div`,{style:{padding:6,borderBottom:`1px solid var(--border)`},children:(0,E.jsx)(`input`,{ref:x,value:u,onChange:e=>{f(e.target.value),h(0)},onKeyDown:e=>{if(e.key===`Escape`)f(``),l(!1);else if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),S.length===0)return;h(t=>e.key===`ArrowDown`?(t+1)%S.length:(t-1+S.length)%S.length)}else if(e.key===`Enter`){let e=S[m]??S[0];e&&w(e)}},placeholder:s(`chat.filterModels`),autoComplete:`off`,spellCheck:!1,style:{width:`100%`,padding:`6px 8px`,background:`var(--bg-hover)`,border:`none`,borderRadius:6,color:`var(--text)`,fontSize:`var(--text-base)`,outline:`none`}})}),(0,E.jsx)(`div`,{style:{minHeight:0,overflowY:`auto`},children:S.length===0?(0,E.jsx)(`div`,{style:{padding:`8px 12px`,color:`var(--text-dim)`,fontSize:`var(--text-base)`,whiteSpace:`nowrap`},children:u.trim()?s(`chat.noMatchingModels`):s(`git.commitModel.noModels`)}):S.map((t,n)=>{let r=e?.provider===t.provider&&e?.modelId===t.modelId,i=n===m;return(0,E.jsxs)(`button`,{ref:i?b:void 0,"data-highlighted":i?`true`:void 0,onClick:()=>w(t),onMouseEnter:()=>h(n),style:{display:`flex`,alignItems:`center`,gap:8,width:`100%`,padding:`7px 12px`,background:i?`var(--bg-hover)`:r?`var(--bg-selected)`:`none`,border:`none`,color:r?`var(--text)`:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-base)`,textAlign:`left`,fontWeight:r?600:400,whiteSpace:`nowrap`},children:[r?(0,E.jsx)(ur,{size:p.xs,strokeWidth:4.8,style:{flexShrink:0}}):(0,E.jsx)(`span`,{style:{width:10,flexShrink:0}}),(0,E.jsxs)(`span`,{style:{display:`inline`},children:[(0,E.jsxs)(`span`,{style:{color:`var(--text-dim)`},children:[t.provider,`/`]}),(0,E.jsx)(`span`,{style:{fontWeight:700},children:t.name})]})]},`${t.provider}:${t.modelId}`)})})]})]})}function QK(e){fetch(`/api/preferences`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({preferences:e})}).catch(()=>{}).finally(()=>void Se.refresh().catch(()=>{}))}var $K={};function eq(){let{t:e}=N(),t=(0,d.useSyncExternalStore)(Se.subscribe,()=>Se.get()?.preferences??$K,()=>$K),n=(0,d.useSyncExternalStore)(be.subscribe,()=>be.get()??null),r=t,i=r.commitMessageUseCurrentModel===!0,a=typeof r.commitMessageModel==`string`?r.commitMessageModel:``,o=typeof r.commitMessageMaxTokens==`number`&&Number.isFinite(r.commitMessageMaxTokens)?r.commitMessageMaxTokens:512,s=r.commitMessageAutoGenerateOnEmpty!==!1,c=r.commitStageAllConfirm!==!1,l=(n?.modelList??[]).map(e=>({provider:e.provider,modelId:e.id,name:e.name})),u=e=>{QK({commitMessageUseCurrentModel:e})},f=(e,t)=>{QK({commitMessageModel:`${e}/${t}`})},p=e=>{let t=Number(e);Number.isFinite(t)&&QK({commitMessageMaxTokens:Math.min(4096,Math.max(64,Math.round(t)))})},m=e=>{QK({commitMessageAutoGenerateOnEmpty:e})},h=e=>{QK({commitStageAllConfirm:e})},g=(()=>{if(!a)return null;let e=a.indexOf(`/`);return e===-1?null:{provider:a.slice(0,e),modelId:a.slice(e+1)}})();return(0,E.jsxs)(`div`,{style:{height:`100%`,overflowY:`auto`,padding:`18px 20px 40px`,display:`flex`,flexDirection:`column`,gap:16,maxWidth:640},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12,padding:`14px 16px`,border:`1px solid var(--border)`,borderRadius:10,background:`var(--bg-panel)`},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,fontWeight:600,color:`var(--text)`,lineHeight:1.4},children:e(`git.commitSectionTitle`)}),(0,E.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:(0,E.jsx)(pi,{label:e(`git.commitConfirmStageAll`),hint:e(`git.commitConfirmStageAllHint`),children:(0,E.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`,fontSize:`var(--text-base)`},children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>h(e.target.checked)}),(0,E.jsx)(`span`,{children:e(c?`git.commitConfirmStageAllOn`:`git.commitConfirmStageAllOff`)})]})})})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12,padding:`14px 16px`,border:`1px solid var(--border)`,borderRadius:10,background:`var(--bg-panel)`},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,fontWeight:600,color:`var(--text)`,lineHeight:1.4},children:e(`git.groupTitle`)}),(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,E.jsx)(pi,{label:e(`git.commitModel.followCurrent`),hint:e(`git.commitModel.followCurrentHint`),children:(0,E.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`,fontSize:`var(--text-base)`},children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>u(e.target.checked)}),(0,E.jsx)(`span`,{children:e(i?`git.commitModel.followCurrentOn`:`git.commitModel.followCurrentOff`)})]})}),!i&&(0,E.jsx)(pi,{label:e(`git.commitModel.fixedModel`),hint:e(`git.commitModel.fixedModelHint`),children:(0,E.jsx)(ZK,{value:g,options:l,onChange:f,variant:`form`,placeholder:e(`git.commitModel.selectPlaceholder`)})}),!i&&!a&&(0,E.jsx)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--status-warning)`,padding:`0 2px`},children:e(`git.commitModel.notConfiguredHint`)}),(0,E.jsx)(pi,{label:e(`git.commitModel.autoGenerateOnEmpty`),hint:e(`git.commitModel.autoGenerateOnEmptyHint`),children:(0,E.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`,fontSize:`var(--text-base)`},children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>m(e.target.checked)}),(0,E.jsx)(`span`,{children:e(s?`git.ai.autoGenerateOn`:`git.ai.autoGenerateOff`)})]})}),(0,E.jsx)(pi,{label:e(`git.commitModel.maxTokens`),hint:e(`git.commitModel.maxTokensHint`),children:(0,E.jsx)(`input`,{type:`number`,min:64,max:4096,step:64,value:o,onChange:e=>p(e.target.value),onBlur:e=>{let t=Number(e.target.value);(!Number.isFinite(t)||t<64||t>4096)&&(e.target.value=String(o))},style:{width:120,height:28,padding:`0 8px`,fontSize:`var(--text-base)`,color:`var(--text)`,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:6,outline:`none`}})})]})]})]})}function tq(e){fetch(`/api/model-thinking`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}).catch(()=>{}).finally(()=>void Ee.refresh().catch(()=>{}))}function nq({value:e,providers:t,placeholder:n,onChange:r}){let{t:i}=N(),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(``),l=(0,d.useRef)(null),u=(0,d.useRef)(null);(0,d.useEffect)(()=>{if(!a)return;let e=e=>{l.current?.contains(e.target)||(o(!1),c(``))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]),(0,d.useEffect)(()=>{a&&requestAnimationFrame(()=>u.current?.focus())},[a]);let f=s.trim().toLocaleLowerCase(),m=f?t.filter(e=>e.toLocaleLowerCase().includes(f)):t,h=e=>{let t=e.trim();t&&(r(t),o(!1),c(``))};return(0,E.jsxs)(`div`,{ref:l,style:{position:`relative`,minWidth:220},children:[(0,E.jsxs)(`button`,{type:`button`,onClick:()=>{if(a){o(!1),c(``);return}c(``),o(!0)},style:{display:`flex`,alignItems:`center`,gap:6,padding:`6px 10px`,height:32,width:220,maxWidth:`100%`,background:`var(--bg-input)`,border:`1px solid var(--border)`,borderRadius:6,color:e?`var(--text)`:`var(--text-dim)`,cursor:`pointer`,fontSize:`var(--text-base)`,textAlign:`left`},className:`hover-shift`,"aria-expanded":a,children:[(0,E.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,flex:1},children:e||n}),(0,E.jsx)(dr,{size:p.sm,style:{color:`var(--text-dim)`,flexShrink:0}})]}),a&&(0,E.jsxs)(`div`,{style:{position:`absolute`,top:36,left:0,width:`max-content`,minWidth:`100%`,zIndex:500,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:8,boxShadow:`0 -4px 16px var(--shadow-color)`,overflow:`hidden`,display:`flex`,flexDirection:`column`,maxHeight:280},children:[(0,E.jsx)(`div`,{style:{padding:6,borderBottom:`1px solid var(--border)`,position:`sticky`,top:0,background:`var(--bg)`,zIndex:1},children:(0,E.jsx)(`input`,{ref:u,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Escape`?(o(!1),c(``)):e.key===`ArrowDown`||e.key===`ArrowUp`?e.preventDefault():e.key===`Enter`&&h(m[0]??s)},placeholder:i(`i18n.searchProviders`),autoComplete:`off`,spellCheck:!1,style:{width:`100%`,padding:`6px 8px`,background:`var(--bg-hover)`,border:`none`,borderRadius:6,color:`var(--text)`,fontSize:`var(--text-base)`,outline:`none`}})}),(0,E.jsxs)(`div`,{style:{overflowY:`auto`},children:[t.filter(e=>!f||e.toLocaleLowerCase().includes(f)).map(t=>{let n=t===e;return(0,E.jsxs)(`button`,{type:`button`,onClick:()=>h(t),style:{display:`flex`,alignItems:`center`,gap:8,width:`100%`,padding:`7px 12px`,background:n?`var(--bg-selected)`:`none`,border:`none`,color:n?`var(--text)`:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-base)`,textAlign:`left`,fontWeight:n?600:400,whiteSpace:`nowrap`},children:[n?(0,E.jsx)(ur,{size:p.xs,strokeWidth:4.8,style:{flexShrink:0}}):(0,E.jsx)(`span`,{style:{width:10,flexShrink:0}}),(0,E.jsx)(`span`,{children:t})]},t)}),f&&!t.some(e=>e.toLocaleLowerCase()===f)&&(0,E.jsxs)(`button`,{type:`button`,onClick:()=>h(s),style:{display:`flex`,alignItems:`center`,gap:8,width:`100%`,padding:`7px 12px`,background:`none`,border:`none`,color:`var(--accent)`,cursor:`pointer`,fontSize:`var(--text-base)`,textAlign:`left`,whiteSpace:`nowrap`},children:[(0,E.jsx)(Ir,{size:p.xs,style:{flexShrink:0}}),(0,E.jsx)(`span`,{children:s.trim()})]}),!f&&t.length===0&&(0,E.jsx)(`div`,{style:{padding:`8px 12px`,color:`var(--text-dim)`,fontSize:`var(--text-base)`},children:i(`chat.noMatchingModels`)})]})]})]})}function rq({value:e,onChange:t,ariaLabel:n,width:r=225}){let{t:i}=N();return(0,E.jsxs)(wm,{value:e,onValueChange:e=>t(e),children:[(0,E.jsx)(Em,{size:`sm`,style:{width:r,background:`var(--bg-input)`,flexShrink:0},"aria-label":n,children:(0,E.jsx)(Tm,{})}),(0,E.jsx)(Dm,{children:bi.map(e=>(0,E.jsxs)(Om,{value:e,className:`text-xs`,children:[(0,E.jsx)(`span`,{className:`font-mono`,children:e}),(0,E.jsx)(`span`,{style:{color:`var(--text-muted)`},children:i(Si[e])})]},e))})]})}var iq={};function aq(){let{t:e}=N(),t=(0,d.useSyncExternalStore)(Ee.subscribe,()=>Ee.get()??iq,()=>iq),n=(0,d.useSyncExternalStore)(be.subscribe,()=>be.get()??null);(0,d.useEffect)(()=>{Ee.load().catch(()=>{})},[]);let r=n?.modelList??[],i=(0,d.useMemo)(()=>r.map(e=>({provider:e.provider,modelId:e.id,name:e.name})),[r]),a=(0,d.useMemo)(()=>{let e=new Set;for(let t of r)e.add(t.provider);for(let n of Object.keys(t.providers??{}))e.add(n);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[r,t.providers]),o=(0,d.useMemo)(()=>Object.entries(t.models??{}).sort(([e],[t])=>e.localeCompare(t)),[t.models]),s=(0,d.useMemo)(()=>Object.entries(t.providers??{}).sort(([e],[t])=>e.localeCompare(t)),[t.providers]),c=(e,n)=>{tq({...t,models:{...t.models??{},[e]:n}})},l=e=>{let n={...t.models??{}};delete n[e];let r={...t};Object.keys(n).length===0?delete r.models:r.models=n,tq(r)},u=(e,n)=>{tq({...t,providers:{...t.providers??{},[e]:n}})},f=e=>{let n={...t.providers??{}};delete n[e];let r={...t};Object.keys(n).length===0?delete r.providers:r.providers=n,tq(r)},[p,m]=(0,d.useState)(null),[h,g]=(0,d.useState)(`medium`),[_,v]=(0,d.useState)(``),[y,b]=(0,d.useState)(`medium`);return(0,E.jsxs)(`div`,{style:{height:`100%`,overflowY:`auto`,padding:`18px 20px 40px`,display:`flex`,flexDirection:`column`,gap:16,maxWidth:720},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-muted)`,lineHeight:1.6},children:e(`modelThinking.desc`)}),(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12,padding:`14px 16px`,border:`1px solid var(--border)`,borderRadius:10,background:`var(--bg-panel)`},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,fontWeight:600,color:`var(--text)`},children:e(`modelThinking.byModel`)}),o.length===0?(0,E.jsx)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-dim)`,padding:`4px 0`},children:e(`modelThinking.emptyModel`)}):(0,E.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:o.map(([t,n])=>(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`8px 10px`,border:`1px solid var(--border)`,borderRadius:8,background:`var(--bg)`},children:[(0,E.jsx)(`span`,{style:{flex:1,fontSize:`var(--text-sm)`,color:`var(--text)`,fontFamily:`var(--font-mono)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:t}),(0,E.jsx)(rq,{value:n,onChange:e=>c(t,e),ariaLabel:`${t} ${e(`i18n.thinking`)}`}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>l(t),title:e(`common.delete`),style:{width:28,height:28,display:`flex`,alignItems:`center`,justifyContent:`center`,border:`1px solid var(--border)`,borderRadius:6,background:`var(--bg-panel)`,color:`var(--text-muted)`,cursor:`pointer`},children:(0,E.jsx)(Yr,{size:14})})]},t))}),(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,flexWrap:`wrap`,marginTop:4},children:[(0,E.jsx)(ZK,{value:p?{provider:p.provider,modelId:p.modelId}:null,options:i,onChange:(e,t)=>{let n=i.find(n=>n.provider===e&&n.modelId===t);m(n??{provider:e,modelId:t,name:`${e}/${t}`})},variant:`form`,placeholder:e(`modelThinking.selectModelPlaceholder`)}),(0,E.jsx)(rq,{value:h,onChange:g,ariaLabel:e(`modelThinking.byModel`)}),(0,E.jsxs)(`button`,{type:`button`,onClick:()=>{if(!p)return;let e=`${p.provider}/${p.modelId}`;tq({...t,models:{...t.models??{},[e]:h}}),m(null)},disabled:!p,style:{height:32,padding:`0 12px`,display:`flex`,alignItems:`center`,gap:6,border:`1px solid var(--accent)`,borderRadius:6,background:p?`var(--accent)`:`var(--bg)`,color:p?`white`:`var(--text-dim)`,cursor:p?`pointer`:`not-allowed`,fontSize:`var(--text-sm)`,fontWeight:600},children:[(0,E.jsx)(Ir,{size:14}),` `,e(`common.add`)]})]})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12,padding:`14px 16px`,border:`1px solid var(--border)`,borderRadius:10,background:`var(--bg-panel)`},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,fontWeight:600,color:`var(--text)`},children:e(`modelThinking.byProvider`)}),(0,E.jsx)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-muted)`,lineHeight:1.5},children:e(`modelThinking.byProviderHint`)}),s.length===0?(0,E.jsx)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-dim)`,padding:`4px 0`},children:e(`modelThinking.emptyProvider`)}):(0,E.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:s.map(([t,n])=>(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`8px 10px`,border:`1px solid var(--border)`,borderRadius:8,background:`var(--bg)`},children:[(0,E.jsx)(`span`,{style:{flex:1,fontSize:`var(--text-sm)`,color:`var(--text)`,fontFamily:`var(--font-mono)`},children:t}),(0,E.jsx)(rq,{value:n,onChange:e=>u(t,e),ariaLabel:`${t} ${e(`i18n.thinking`)}`}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>f(t),title:e(`common.delete`),style:{width:28,height:28,display:`flex`,alignItems:`center`,justifyContent:`center`,border:`1px solid var(--border)`,borderRadius:6,background:`var(--bg-panel)`,color:`var(--text-muted)`,cursor:`pointer`},children:(0,E.jsx)(Yr,{size:14})})]},t))}),(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,flexWrap:`wrap`,marginTop:4},children:[(0,E.jsx)(nq,{value:_,providers:a,placeholder:e(`modelThinking.selectProviderPlaceholder`),onChange:v}),(0,E.jsx)(rq,{value:y,onChange:b,ariaLabel:e(`modelThinking.byProvider`)}),(0,E.jsxs)(`button`,{type:`button`,onClick:()=>{let e=_.trim();e&&(tq({...t,providers:{...t.providers??{},[e]:y}}),v(``))},disabled:!_.trim(),style:{height:32,padding:`0 12px`,display:`flex`,alignItems:`center`,gap:6,border:`1px solid var(--accent)`,borderRadius:6,background:_.trim()?`var(--accent)`:`var(--bg)`,color:_.trim()?`white`:`var(--text-dim)`,cursor:_.trim()?`pointer`:`not-allowed`,fontSize:`var(--text-sm)`,fontWeight:600},children:[(0,E.jsx)(Ir,{size:14}),` `,e(`common.add`)]})]})]}),(0,E.jsx)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-dim)`,lineHeight:1.6,padding:`0 2px`},children:e(`modelThinking.footerHint`)})]})}var oq=[`models`,`plugins`,`skills`,`session`,`appearance`,`startScreen`,`git`,`modelThinking`,`advanced`];function sq({section:e,onSectionChange:t,cwd:n,sessionId:r,onClose:i,onOpenFile:a,defaultThinkingLevel:o,onDefaultThinkingLevelChange:s,compaction:c,onCompactionChange:l,retry:u,onRetryChange:f,defaultProjectTrust:p,onDefaultProjectTrustChange:m,subagents:h,onSubagentsChange:g,sidebarWidth:_,onSidebarWidthChange:v,widgetPanelWidth:y,onWidgetPanelWidthChange:b,modelConfigFocus:x}){let{t:S}=N(),{value:C}=Qn(we),{value:w}=Qn(Te);(0,d.useEffect)(()=>{we.load().catch(()=>{}),Te.load().catch(()=>{})},[]);let T=e=>{switch(e){case`models`:return S(`common.models`);case`plugins`:return S(`common.plugins`);case`skills`:return S(`common.skills`);case`startScreen`:return S(`config.section.startScreen`);case`session`:return S(`config.section.session`);case`appearance`:return S(`config.section.appearance`);case`advanced`:return S(`config.section.advanced`);case`git`:return S(`config.section.git`);case`modelThinking`:return S(`config.section.modelThinking`)}},D=e=>{switch(e){case`models`:return(0,E.jsx)(_r,{size:15});case`plugins`:return(0,E.jsx)(Lr,{size:15});case`skills`:return(0,E.jsx)(ti,{size:15});case`startScreen`:return(0,E.jsx)(ri,{size:15});case`session`:return(0,E.jsx)(Gr,{size:15});case`appearance`:return(0,E.jsx)(Mr,{size:15});case`advanced`:return(0,E.jsx)(Ur,{size:15});case`git`:return(0,E.jsx)(Sr,{size:15});case`modelThinking`:return(0,E.jsx)(Dr,{size:15})}},O=oq.map(e=>({id:e,label:T(e),icon:D(e),closable:!1}));return(0,E.jsx)(`div`,{style:{height:`100%`,display:`flex`,flexDirection:`column`,overflow:`hidden`,background:`var(--bg)`},children:(0,E.jsxs)(Gn,{tabs:O,activeTabId:e,onSelectTab:e=>t(e),onCloseTab:()=>{},children:[(0,E.jsx)(Un,{id:`models`,children:(0,E.jsx)(HS,{onClose:i,pane:!0,initialSelection:x?{provider:x.provider,modelId:x.modelId}:null})}),(0,E.jsx)(Un,{id:`plugins`,children:n?(0,E.jsx)(xK,{cwd:n,sessionId:r,onClose:i,onOpenFile:a,pane:!0,globalPackages:C?.packages??[],globalExtensionFilters:C?.extensionFilters??[]}):(0,E.jsx)(cq,{text:S(`config.section.requiresCwd`)})}),(0,E.jsx)(Un,{id:`skills`,children:n?(0,E.jsx)(jK,{cwd:n,onClose:i,pane:!0,homeSkills:w?.skills??[]}):(0,E.jsx)(cq,{text:S(`config.section.requiresCwd`)})}),(0,E.jsx)(Un,{id:`startScreen`,children:(0,E.jsx)(qK,{})}),(0,E.jsx)(Un,{id:`session`,children:(0,E.jsx)(Pm,{defaultThinkingLevel:o,onDefaultThinkingLevelChange:s,compaction:c,onCompactionChange:l,retry:u,onRetryChange:f,defaultProjectTrust:p,onDefaultProjectTrustChange:m,subagents:h,onSubagentsChange:g})}),(0,E.jsx)(Un,{id:`appearance`,children:(0,E.jsx)(hi,{sidebarWidth:_,onSidebarWidthChange:v,widgetPanelWidth:y,onWidgetPanelWidthChange:b})}),(0,E.jsx)(Un,{id:`advanced`,children:(0,E.jsx)(Lm,{})}),(0,E.jsx)(Un,{id:`git`,children:(0,E.jsx)(eq,{})}),(0,E.jsx)(Un,{id:`modelThinking`,children:(0,E.jsx)(aq,{})})]})})}function cq({text:e}){return(0,E.jsx)(`div`,{style:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--text-muted)`,fontSize:`var(--text-lg)`,padding:24,textAlign:`center`},children:e})}var lq=`chat`,uq=`config`,dq=`widgets`,fq=e=>`file:${e}`;function pq(e){if(!e||typeof e!=`object`)return null;let t=e;return t.kind===`config`?typeof t.section==`string`&&oq.includes(t.section)?{kind:`config`,section:t.section}:null:t.kind===`file`&&typeof t.filePath==`string`&&t.filePath&&typeof t.label==`string`?{kind:`file`,filePath:t.filePath,label:t.label,sourceSessionId:typeof t.sourceSessionId==`string`?t.sourceSessionId:null,initialDisplayMode:t.initialDisplayMode===`source`||t.initialDisplayMode===`preview`||t.initialDisplayMode===`diff`?t.initialDisplayMode:void 0}:null}var mq=e=>Array.isArray(e)?e.map(pq).filter(e=>e!==null):[];function hq(e){return{id:fq(e.filePath),label:e.label,filePath:e.filePath,sourceSessionId:e.sourceSessionId,initialDisplayMode:e.initialDisplayMode}}function gq(){try{if(localStorage.getItem(`pi:openTabs`)!==null)return[];let e=[],t=JSON.parse(localStorage.getItem(`pi:fileTabs`)??`[]`);if(e.push(...mq(Array.isArray(t)?t.map(e=>({kind:`file`,...typeof e==`object`&&e?e:{}})):[])),localStorage.getItem(`pi:configTabOpen`)===`1`){let t=pq({kind:`config`,section:localStorage.getItem(`pi:configSection`)??`models`});t&&e.unshift(t)}for(let e of[`pi:fileTabs`,`pi:activeFileTab`,`pi:configTabOpen`,`pi:configTabActive`,`pi:configSection`])localStorage.removeItem(e);return e}catch{return[]}}function _q(){try{return localStorage.getItem(`pi:openTabsActive`)===null?localStorage.getItem(`pi:configTabActive`)===`1`?uq:localStorage.getItem(`pi:activeFileTab`):null}catch{return null}}function vq({onSessionSelected:e,onRefreshModels:t}){let[n,r]=Zn(`pi:openTabs`,gq,mq),[i,a]=Zn(`pi:openTabsActive`,_q),[o,s]=(0,d.useState)(null),c=n.find(e=>e.kind===`config`),l=c!==void 0,u=c?.kind===`config`?c.section:`models`,f=(0,d.useCallback)(e=>{r(t=>t.map(t=>t.kind===`config`?{kind:`config`,section:e}:t))},[r]),p=(0,d.useMemo)(()=>n.filter(e=>e.kind===`file`).map(hq),[n]),m=i===null?null:n.find(e=>e.kind===`file`&&fq(e.filePath)===i)??null,h=l&&i===`config`,g=(0,d.useCallback)((t,n,i)=>{let o=i?.sourceSessionId,s=i?.modeHint,c=fq(t);r(e=>{let r=e.find(e=>e.kind===`file`&&e.filePath===t);if(!r)return[...e,{kind:`file`,filePath:t,label:n,sourceSessionId:o,initialDisplayMode:s}];let i=!o||r.sourceSessionId===o,a=!s||r.initialDisplayMode===s;return i&&a?e:e.map(e=>e.kind!==`file`||e.filePath!==t?e:{...e,sourceSessionId:o??e.sourceSessionId,initialDisplayMode:s??e.initialDisplayMode})}),e?.(),a(c)},[e,r,a]),_=(0,d.useCallback)(e=>{r(t=>t.filter(t=>t.kind!==`file`||fq(t.filePath)!==e)),a(t=>{if(t!==e)return t;let r=n.filter(t=>t.kind===`file`&&fq(t.filePath)!==e);return r.length>0?fq(r[r.length-1].filePath):null})},[n,r,a]),v=(0,d.useCallback)(t=>{r(e=>{let n=e.findIndex(e=>e.kind===`config`),r=t??(n>=0&&e[n].kind===`config`?e[n].section:`models`);if(n>=0){let t=[...e];return t[n]={kind:`config`,section:r},t}return[...e,{kind:`config`,section:r}]}),e?.(),a(uq)},[e,r,a]),y=(0,d.useCallback)(e=>{s(e),v(`models`)},[v]),b=(0,d.useCallback)(()=>{r(e=>e.filter(e=>e.kind!==`config`)),a(e=>e===`config`?null:e),s(null),t?.()},[r,a,t]);return{savedTabs:n,setSavedTabs:r,activeSavedId:i,setActiveSavedId:a,configTabOpen:l,configSection:u,setConfigSection:f,configTabActive:h,activeFileTab:m,fileTabs:p,modelConfigFocus:o,handleOpenFile:g,handleCloseFileTab:_,openConfigTab:v,handleOpenModelConfig:y,closeConfigTab:b,handleCloseMainTab:(0,d.useCallback)(e=>{if(e===`config`){b();return}_(e)},[b,_])}}function yq({widgetGeometries:e,setWidgetGeometry:t}){let[n,r]=(0,d.useState)(!0),[i,a]=(0,d.useState)(!1),[o,s]=(0,d.useState)([]),[c,l]=(0,d.useState)(new Map),[u,f]=(0,d.useState)(!0);return{widgetPanelOpen:n,setWidgetPanelOpen:r,widgetsTabActive:i,setWidgetsTabActive:a,extensionWidgets:o,closedWidgets:c,handleCloseWidget:(0,d.useCallback)((n,r)=>{l(e=>new Map(e).set(n,r));let i=e[n];t(n,{x:i?.x??0,y:i?.y??0,width:i?.width??560,height:i?.height??Math.round(window.innerHeight*.6),collapsed:!0})},[e,t]),handleReopenWidget:(0,d.useCallback)(n=>{l(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t});let r=e[n];r&&t(n,{...r,collapsed:!1}),a(!1)},[e,t,a]),handleExtensionWidgetsChange:(0,d.useCallback)(n=>{s(n),l(r=>{let i=!1,a=new Map(r);for(let[o,s]of r){let r=n.find(e=>e.key===o);if(r&&r.lines.join(`
|
|
348
|
-
`)!==s){a.delete(o),i=!0;let n=e[o];n&&t(o,{...n,collapsed:!1})}}return i?a:r})},[e,t]),rightSidebarOpen:u,setRightSidebarOpen:f,closedWidgetCount:c.size}}function bq({hasFocusedEditable:e,innerHeight:t,viewportHeight:n,viewportScale:r}){let i=Math.abs(r-1)<.01;return e&&i&&t-n>1}function xq(){let e=document.activeElement;return e instanceof HTMLElement?e.isContentEditable||e.tagName===`INPUT`||e.tagName===`SELECT`||e.tagName===`TEXTAREA`:!1}function Sq(){(0,d.useEffect)(()=>{let e=window.visualViewport;if(!e)return;let t=document.documentElement,n=()=>{bq({hasFocusedEditable:xq(),innerHeight:window.innerHeight,viewportHeight:e.height,viewportScale:e.scale})?(t.style.setProperty(`--app-viewport-height`,`${e.height}px`),(window.scrollX!==0||window.scrollY!==0)&&window.scrollTo(0,0)):t.style.removeProperty(`--app-viewport-height`)};return n(),e.addEventListener(`resize`,n),e.addEventListener(`scroll`,n),()=>{e.removeEventListener(`resize`,n),e.removeEventListener(`scroll`,n),t.style.removeProperty(`--app-viewport-height`)}},[])}function Cq(e){let t=/(?:^|\s)@"([^"\n]*)$/.exec(e);if(t)return{start:e.length-(t[1].length+2),query:t[1],quoted:!0};let n=/(?:^|\s)@([^\s"]*)$/.exec(e);return n?{start:e.length-(n[1].length+1),query:n[1],quoted:!1}:null}function wq(e){let t=0;for(let n=0;n<e.length;n++)e[n]===`/`&&t++;return t}function Tq(e){let t=new Set;for(let n of e){let e=n.indexOf(`/`);for(;e!==-1;)t.add(n.slice(0,e)),e=n.indexOf(`/`,e+1)}let n=[];for(let e of t)n.push({path:e,isDir:!0});for(let t of e)t&&n.push({path:t,isDir:!1});return n.sort((e,t)=>wq(e.path)-wq(t.path)||e.path.localeCompare(t.path)),n}function Eq(e,t){let n=e.path.toLowerCase(),r=0;if(t.includes(`/`))n===t?r=100:n.startsWith(t)?r=80:n.includes(t)&&(r=50);else{let e=n.lastIndexOf(`/`),i=e===-1?n:n.slice(e+1);i===t?r=100:i.startsWith(t)?r=80:i.includes(t)?r=50:n.includes(t)&&(r=30)}return e.isDir&&r>0&&(r+=10),r}function Dq(e,t,n=20){let r=t.toLowerCase();if(!r)return e.slice(0,n);let i=[];for(let t of e){let e=Eq(t,r);e>0&&i.push({entry:t,score:e})}return i.sort((e,t)=>t.score-e.score||wq(e.entry.path)-wq(t.entry.path)||e.entry.path.localeCompare(t.entry.path)),i.slice(0,n).map(e=>e.entry)}function Oq(e,t,n=!1){let r=t?`${e}/`:e,i=n||r.includes(` `);if(t){let e=i?`@"${r}"`:`@${r}`;return{text:e,cursorOffset:i?e.length-1:e.length}}let a=i?`@"${r}" `:`@${r} `;return{text:a,cursorOffset:a.length}}function kq(e,t){let n=t?`${e}/`:e;return n.includes(` `)?`@"${n}" `:`@${n} `}function Aq(e,t,n){let r=Math.max(1,Math.min(t,n)),i=Math.max(1,Math.max(t,n));return`${e.includes(` `)?`@"${e}"`:`@${e}`}${r===i?`:${r}`:`:${r}-${i}`} `}function jq(e){return e.map(e=>kq(e,!1)).join(``)}function Mq(e){let t=e.get(`cwd`)?.trim()||null;return{requestedCwd:t,sessionId:t?null:e.get(`session`)}}function Nq(){return(0,E.jsxs)(`div`,{role:`status`,"aria-label":`Loading`,"data-testid":`boot-splash`,style:{position:`fixed`,inset:0,zIndex:9999,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:18,background:`var(--bg)`,color:`var(--text-muted)`},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-6xl)`,fontWeight:700,color:`var(--accent)`,letterSpacing:`0.02em`},children:`pi`}),(0,E.jsx)(`div`,{style:{width:22,height:22,border:`2px solid var(--border)`,borderTopColor:`var(--accent)`,borderRadius:`50%`,animation:`boot-spin 0.8s linear infinite`}}),(0,E.jsx)(`style`,{children:`@keyframes boot-spin { to { transform: rotate(360deg); } }`})]})}var Pq=!1,Fq=performance.now();function Iq(e){Pq=e,Fq=performance.now(),Pq&&Rq(`boot`,`debug log enabled`)}function Lq(e){return(t,n)=>Rq(e,t,n)}function Rq(e,t,n){if(!Pq)return;performance.now()-Fq;let r=new Date,i=(e,t=2)=>String(e).padStart(t,`0`);`${i(r.getHours())}${i(r.getMinutes())}${i(r.getSeconds())}${i(r.getMilliseconds(),3)}`}function zq(){if(!Pq)return;let e=window.fetch;window.fetch=async(t,n)=>{let r=typeof t==`string`?t:t instanceof URL?t.href:t.url,i=n?.method??`GET`,a=performance.now();try{let o=await e(t,n);return Rq(`fetch`,`${i} ${r}`,`${o.status} ${Math.round(performance.now()-a)}ms`),o}catch(e){throw Rq(`fetch`,`${i} ${r}`,`failed ${Math.round(performance.now()-a)}ms`),e}}}var Bq=new Set([`select`,`confirm`,`input`,`editor`]),Vq=new Set,Hq=new Set;function Uq(){for(let e of Hq)e()}function Wq(e){if(Vq.has(e))return;let t=new Set(Vq);t.add(e),Vq=t,Uq()}function Gq(e){if(!Vq.has(e))return;let t=new Set(Vq);t.delete(e),Vq=t,Uq()}function Kq(e){return Hq.add(e),()=>Hq.delete(e)}function qq(){return Vq}function Jq(){return(0,d.useSyncExternalStore)(Kq,qq,qq)}function Yq(e,t,n){let r=`${t}/${n}`;if(e.models?.[r])return e.models[r];if(e.providers?.[t])return e.providers[t]}function Xq(e,t){return e.providers?.[t]}function Zq(e,t,n,r){let i=`${t}/${n}`;if(r===`auto`){if(!e.models?.[i])return e;let t={...e.models};delete t[i];let n={...e};return Object.keys(t).length===0?delete n.models:n.models=t,n}let a=Xq(e,t);if(a!==void 0&&r===a){if(e.models?.[i]){let t={...e.models};delete t[i];let n={...e};return Object.keys(t).length===0?delete n.models:n.models=t,n}return e}return e.models?.[i]===r?e:{...e,models:{...e.models??{},[i]:r}}}function Qq(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $q(e){return!Qq(e)||e.type!==`toolCall`?null:{type:`toolCall`,toolCallId:typeof e.toolCallId==`string`?e.toolCallId:typeof e.id==`string`?e.id:``,toolName:typeof e.toolName==`string`?e.toolName:typeof e.name==`string`?e.name:``,input:typeof e.input==`object`&&e.input!==null&&!Array.isArray(e.input)?e.input:typeof e.arguments==`object`&&e.arguments!==null&&!Array.isArray(e.arguments)?e.arguments:{}}}function eJ(e){if(e.role!==`assistant`)return e;let t=e.content;if(!Array.isArray(t))return e;let n=t.map(e=>$q(e)??e);return{...e,content:n}}function tJ(e){if(e.role!==`assistant`)return e;let t=e.content;if(!Array.isArray(t))return e;for(let e=0;e<t.length;e++){let n=t[e],r=$q(n);r!==null&&(t[e]=r)}return e}var nJ=[],rJ=[`read`,`bash`,`edit`,`write`],iJ=[`bash`,`read`,`edit`,`write`,`grep`,`find`,`ls`],aJ=new Set(iJ);function oJ(e){let t=e.filter(e=>e.active);if(t.length===0)return`none`;let n=t.map(e=>e.name).filter(e=>aJ.has(e)).sort().join(`,`);return n===[...rJ].sort().join(`,`)?`default`:n===[...iJ].sort().join(`,`)?`full`:`default`}function sJ(e){return e===`none`?[...nJ]:e===`full`?[...iJ]:[...rJ]}function cJ(e,t){switch(t.type){case`start`:return{isStreaming:!0,streamingMessage:null};case`update`:return{isStreaming:!0,streamingMessage:t.message};case`end`:case`reset`:return{isStreaming:!1,streamingMessage:null};default:return e}}function lJ(e){if(!e||typeof e!=`object`)return;let t=e.content;if(!Array.isArray(t))return;let n=t.filter(e=>typeof e==`object`&&!!e&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text);return n.length>0?n.join(``):void 0}function uJ(e){return{steering:e?.steering??[],followUp:e?.followUp??[]}}var dJ=700,fJ=1200,pJ=80,mJ=800,hJ=600,gJ=2e4,_J=3e4,vJ=200,yJ=32,bJ=15e3,xJ=1e3,SJ=5e3,CJ=5,wJ=5e3,TJ=180,EJ=new Set([`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `,`Space`,`Spacebar`]),DJ=class extends Error{constructor(e){super(e===`timeout`?`Timed out connecting to the agent event stream. Please try again.`:`Failed to connect to the agent event stream. Please try again.`),this.status=e,this.name=`EventStreamConnectionError`}};function OJ(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`}function kJ(e){return new Promise(t=>setTimeout(t,e))}function AJ(e){let t=e.findIndex(e=>!e.exiting);return t===-1?e:e.map((e,n)=>n===t?{...e,exiting:!0}:e)}function jJ(e,t){let n=e,r=t;for(;r.length>0&&n.length<CJ;){let[e,...t]=r;n=[...n,e],r=t}return r.length>0&&!n.some(e=>e.exiting)&&(n=AJ(n)),{visible:n,pending:r}}function MJ(e,t){switch(t.type){case`add`:return e.visible.some(e=>e.exiting)||e.visible.length>=CJ?{visible:e.visible.some(e=>e.exiting)?e.visible:AJ(e.visible),pending:[...e.pending,t.notice],modals:e.modals}:{...e,visible:[...e.visible,t.notice]};case`mark_oldest_exiting`:return{...e,visible:AJ(e.visible)};case`add_modal`:return{...e,modals:[...e.modals,t.notice]};case`dismiss_modal`:return{...e,modals:e.modals.filter(e=>e.id!==t.id)};case`remove`:return{...jJ(e.visible.filter(e=>e.id!==t.id),e.pending),modals:e.modals};default:return e}}function NJ(){let[e,t]=(0,d.useReducer)(MJ,{visible:[],pending:[],modals:[]}),n=(0,d.useCallback)(e=>{let n=e.message.trim();if(!n)return;let r={id:e.id??OJ(),message:n,type:e.type??`info`};t(e.modal?{type:`add_modal`,notice:r}:{type:`add`,notice:r})},[]),r=(0,d.useCallback)(e=>{t({type:`dismiss_modal`,id:e})},[]);return(0,d.useEffect)(()=>{if(e.visible.length===0)return;let n=e.visible.find(e=>e.exiting);if(n){let e=setTimeout(()=>{t({type:`remove`,id:n.id})},TJ);return()=>clearTimeout(e)}if(!e.visible[0])return;let r=setTimeout(()=>{t({type:`mark_oldest_exiting`})},wJ);return()=>clearTimeout(r)},[e.visible]),{noticeState:e,addNotice:n,dismissModal:r}}function PJ({messages:e,contextUsage:t,data:n,session:r,sessionIdRef:i}){let[a,o]=(0,d.useState)(null);return{sessionStats:(0,d.useMemo)(()=>{if(a)return a;let o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},s=0,c=0,l=0,u=0,d=0;for(let t of e){if(t.role===`user`&&(c+=1),t.role===`toolResult`&&(u+=1),t.role!==`assistant`)continue;l+=1;let e=t.usage;d+=t.content.filter(e=>e.type===`toolCall`).length,e&&(o.input+=e.input??0,o.output+=e.output??0,o.cacheRead+=e.cacheRead??0,o.cacheWrite+=e.cacheWrite??0,s+=e.cost?.total??0)}return o.total=o.input+o.output+o.cacheRead+o.cacheWrite,o.total===0&&e.length===0?null:{sessionFile:n?.filePath||void 0,sessionId:i.current??r?.id??``,sessionName:r?.name,userMessages:c,assistantMessages:l,toolCalls:d,toolResults:u,totalMessages:e.length,tokens:o,cost:s,...t?{contextUsage:t}:{}}},[e,a,t,n?.filePath,r?.id,r?.name,i]),setSessionStatsOverride:o}}function FJ({isNew:e,sessionIdRef:t,ensuringNewSessionRef:n,setToolPresetOverride:r}){let[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)([]),[c,l]=(0,d.useState)(null),[u,f]=(0,d.useState)([]),[p,m]=(0,d.useState)({}),[h,g]=(0,d.useState)({}),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(null),[x,S]=(0,d.useState)(`default`),[C,w]=(0,d.useState)(`auto`),[T,E]=(0,d.useState)(null),[D,O]=(0,d.useState)(null),k=(0,d.useRef)(null),A=(0,d.useRef)(null),j=r??S,M=(0,d.useCallback)((t,n)=>{if(e){let e={provider:t,modelId:n};k.current=e,v(e),O(e);return}E({provider:t,modelId:n})},[e,v]);return{modelNames:i,modelList:o,modelError:c,modelScopeWarnings:u,modelThinkingLevels:p,modelThinkingLevelMaps:h,newSessionModel:_,newSessionDefaultModel:y,toolPreset:x,thinkingLevel:C,currentModelOverride:T,pendingModel:D,setThinkingLevel:w,setPendingModel:O,setNewSessionDefaultModel:b,setCurrentModelOverride:E,setModelError:l,setToolPresetState:j,newSessionModelOverrideRef:k,thinkingLevelOverrideRef:A,loadModels:(0,d.useCallback)(async t=>{let n=await be.load(t);a(n.models),l(n.modelError??null),f(n.modelScopeWarnings??[]),m(n.thinkingLevels??{}),g(n.thinkingLevelMaps??{});let r=n.modelList??[];if(s(r),e){let e=(n.defaultModel?r.find(e=>e.id===n.defaultModel?.modelId&&e.provider===n.defaultModel?.provider):void 0)??r[0];b(t=>t??(e?{provider:e.provider,modelId:e.id}:null));let t=e&&n.thinkingLevelPins?.[`${e.provider}/${e.id}`];A.current===null&&w(e=>e===`auto`?t??`auto`:e)}},[e]),handleModelChange:M,handleThinkingLevelChange:(0,d.useCallback)(async r=>{if(w(r),e&&!t.current&&(A.current=r===`auto`?null:r),r===`auto`)return;let i=t.current??await n.current;if(i)try{await US(i,{type:`set_thinking_level`,level:r})}catch(e){console.error(`Failed to set thinking level:`,e)}},[e,t,n]),handleToolPresetChange:(0,d.useCallback)(async e=>{let r=sJ(e);j(e);let i=t.current??await n.current;if(i)try{await US(i,{type:`set_tools`,toolNames:r})}catch(e){console.error(`Failed to set tools:`,e)}},[j,t,n])}}function IJ({addNotice:e,chatInputRef:t,sessionIdRef:n}){let[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)([]),[l,u]=(0,d.useState)([]);return(0,d.useEffect)(()=>{if(!r?.timeout)return;let e=r.id,t=setTimeout(()=>{Rq(`ui-chain`,`4c dialog auto-close by timeout`,`id=${e.slice(0,8)}`),i(t=>t?.id===e?null:t)},r.timeout);return()=>clearTimeout(t)},[r]),{extensionDialog:r,extensionCustomUi:a,extensionStatuses:s,extensionWidgets:l,setExtensionStatuses:c,setExtensionWidgets:u,respondToExtensionUi:(0,d.useCallback)(async(e,t)=>{let r=n.current;if(i(t=>t?.id===e.id?null:t),r)try{await US(r,{type:`extension_ui_response`,id:e.id,...t})}catch(e){console.error(`Failed to send extension UI response:`,e)}},[n]),sendExtensionCustomInput:(0,d.useCallback)(async(e,t)=>{let r=n.current;if(r)try{await US(r,{type:`extension_ui_input`,id:e.id,data:t})}catch(e){console.error(`Failed to send extension custom UI input:`,e)}},[n]),handleExtensionUiRequest:(0,d.useCallback)(n=>{switch(n.method){case`select`:case`confirm`:case`input`:case`editor`:i(n);break;case`notify`:{let t=n.notifyType??`info`,r=n.message;t===`warning`?console.warn(`[pi] notify (warning): ${r}`):t===`error`?console.error(`[pi] notify (error): ${r}`):console.info(`[pi] notify: ${r}`);let i=typeof r==`string`&&r.length>100;e({id:n.id,message:r,type:t,modal:t===`warning`||t===`error`||i});break}case`setStatus`:c(e=>{let t=e.filter(e=>e.key!==n.statusKey);return n.statusText===void 0?t:[...t,{key:n.statusKey,text:n.statusText}]});break;case`setWidget`:u(e=>{let t=e.filter(e=>e.key!==n.widgetKey);return n.widgetLines?[...t,{key:n.widgetKey,lines:n.widgetLines,placement:n.widgetPlacement??`aboveEditor`}]:t});break;case`setTitle`:n.title&&(document.title=n.title);break;case`set_editor_text`:t?.current?.insertText(n.text);break;case`custom`:o(e=>n.closed?e?.id===n.id?null:e:n)}},[e,t])}}function LJ(e){let t=e.content;return typeof t==`string`?t:Array.isArray(t)?t.map(e=>e&&typeof e==`object`&&e.type===`text`&&typeof e.text==`string`?e.text:``).filter(Boolean).join(`
|
|
349
|
-
`):``}function
|
|
348
|
+
`)!==s){a.delete(o),i=!0;let n=e[o];n&&t(o,{...n,collapsed:!1})}}return i?a:r})},[e,t]),rightSidebarOpen:u,setRightSidebarOpen:f,closedWidgetCount:c.size}}function bq({hasFocusedEditable:e,innerHeight:t,viewportHeight:n,viewportScale:r}){let i=Math.abs(r-1)<.01;return e&&i&&t-n>1}function xq(){let e=document.activeElement;return e instanceof HTMLElement?e.isContentEditable||e.tagName===`INPUT`||e.tagName===`SELECT`||e.tagName===`TEXTAREA`:!1}function Sq(){(0,d.useEffect)(()=>{let e=window.visualViewport;if(!e)return;let t=document.documentElement,n=()=>{bq({hasFocusedEditable:xq(),innerHeight:window.innerHeight,viewportHeight:e.height,viewportScale:e.scale})?(t.style.setProperty(`--app-viewport-height`,`${e.height}px`),(window.scrollX!==0||window.scrollY!==0)&&window.scrollTo(0,0)):t.style.removeProperty(`--app-viewport-height`)};return n(),e.addEventListener(`resize`,n),e.addEventListener(`scroll`,n),()=>{e.removeEventListener(`resize`,n),e.removeEventListener(`scroll`,n),t.style.removeProperty(`--app-viewport-height`)}},[])}function Cq(e){let t=/(?:^|\s)@"([^"\n]*)$/.exec(e);if(t)return{start:e.length-(t[1].length+2),query:t[1],quoted:!0};let n=/(?:^|\s)@([^\s"]*)$/.exec(e);return n?{start:e.length-(n[1].length+1),query:n[1],quoted:!1}:null}function wq(e){let t=0;for(let n=0;n<e.length;n++)e[n]===`/`&&t++;return t}function Tq(e){let t=new Set;for(let n of e){let e=n.indexOf(`/`);for(;e!==-1;)t.add(n.slice(0,e)),e=n.indexOf(`/`,e+1)}let n=[];for(let e of t)n.push({path:e,isDir:!0});for(let t of e)t&&n.push({path:t,isDir:!1});return n.sort((e,t)=>wq(e.path)-wq(t.path)||e.path.localeCompare(t.path)),n}function Eq(e,t){let n=e.path.toLowerCase(),r=0;if(t.includes(`/`))n===t?r=100:n.startsWith(t)?r=80:n.includes(t)&&(r=50);else{let e=n.lastIndexOf(`/`),i=e===-1?n:n.slice(e+1);i===t?r=100:i.startsWith(t)?r=80:i.includes(t)?r=50:n.includes(t)&&(r=30)}return e.isDir&&r>0&&(r+=10),r}function Dq(e,t,n=20){let r=t.toLowerCase();if(!r)return e.slice(0,n);let i=[];for(let t of e){let e=Eq(t,r);e>0&&i.push({entry:t,score:e})}return i.sort((e,t)=>t.score-e.score||wq(e.entry.path)-wq(t.entry.path)||e.entry.path.localeCompare(t.entry.path)),i.slice(0,n).map(e=>e.entry)}function Oq(e,t,n=!1){let r=t?`${e}/`:e,i=n||r.includes(` `);if(t){let e=i?`@"${r}"`:`@${r}`;return{text:e,cursorOffset:i?e.length-1:e.length}}let a=i?`@"${r}" `:`@${r} `;return{text:a,cursorOffset:a.length}}function kq(e,t){let n=t?`${e}/`:e;return n.includes(` `)?`@"${n}" `:`@${n} `}function Aq(e,t,n){let r=Math.max(1,Math.min(t,n)),i=Math.max(1,Math.max(t,n));return`${e.includes(` `)?`@"${e}"`:`@${e}`}${r===i?`:${r}`:`:${r}-${i}`} `}function jq(e){return e.map(e=>kq(e,!1)).join(``)}function Mq(e){let t=e.get(`cwd`)?.trim()||null;return{requestedCwd:t,sessionId:t?null:e.get(`session`)}}function Nq(){return(0,E.jsxs)(`div`,{role:`status`,"aria-label":`Loading`,"data-testid":`boot-splash`,style:{position:`fixed`,inset:0,zIndex:9999,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:18,background:`var(--bg)`,color:`var(--text-muted)`},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-6xl)`,fontWeight:700,color:`var(--accent)`,letterSpacing:`0.02em`},children:`pi`}),(0,E.jsx)(`div`,{style:{width:22,height:22,border:`2px solid var(--border)`,borderTopColor:`var(--accent)`,borderRadius:`50%`,animation:`boot-spin 0.8s linear infinite`}}),(0,E.jsx)(`style`,{children:`@keyframes boot-spin { to { transform: rotate(360deg); } }`})]})}var Pq=!1,Fq=performance.now();function Iq(e){Pq=e,Fq=performance.now(),Pq&&Rq(`boot`,`debug log enabled`)}function Lq(e){return(t,n)=>Rq(e,t,n)}function Rq(e,t,n){if(!Pq)return;performance.now()-Fq;let r=new Date,i=(e,t=2)=>String(e).padStart(t,`0`);`${i(r.getHours())}${i(r.getMinutes())}${i(r.getSeconds())}${i(r.getMilliseconds(),3)}`}function zq(){if(!Pq)return;let e=window.fetch;window.fetch=async(t,n)=>{let r=typeof t==`string`?t:t instanceof URL?t.href:t.url,i=n?.method??`GET`,a=performance.now();try{let o=await e(t,n);return Rq(`fetch`,`${i} ${r}`,`${o.status} ${Math.round(performance.now()-a)}ms`),o}catch(e){throw Rq(`fetch`,`${i} ${r}`,`failed ${Math.round(performance.now()-a)}ms`),e}}}var Bq=new Set([`select`,`confirm`,`input`,`editor`]),Vq=new Set,Hq=new Set;function Uq(){for(let e of Hq)e()}function Wq(e){if(Vq.has(e))return;let t=new Set(Vq);t.add(e),Vq=t,Uq()}function Gq(e){if(!Vq.has(e))return;let t=new Set(Vq);t.delete(e),Vq=t,Uq()}function Kq(e){return Hq.add(e),()=>Hq.delete(e)}function qq(){return Vq}function Jq(){return(0,d.useSyncExternalStore)(Kq,qq,qq)}function Yq(e,t,n){let r=`${t}/${n}`;if(e.models?.[r])return e.models[r];if(e.providers?.[t])return e.providers[t]}function Xq(e,t){return e.providers?.[t]}function Zq(e,t,n,r){let i=`${t}/${n}`;if(r===`auto`){if(!e.models?.[i])return e;let t={...e.models};delete t[i];let n={...e};return Object.keys(t).length===0?delete n.models:n.models=t,n}let a=Xq(e,t);if(a!==void 0&&r===a){if(e.models?.[i]){let t={...e.models};delete t[i];let n={...e};return Object.keys(t).length===0?delete n.models:n.models=t,n}return e}return e.models?.[i]===r?e:{...e,models:{...e.models??{},[i]:r}}}function Qq(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $q(e){return!Qq(e)||e.type!==`toolCall`?null:{type:`toolCall`,toolCallId:typeof e.toolCallId==`string`?e.toolCallId:typeof e.id==`string`?e.id:``,toolName:typeof e.toolName==`string`?e.toolName:typeof e.name==`string`?e.name:``,input:typeof e.input==`object`&&e.input!==null&&!Array.isArray(e.input)?e.input:typeof e.arguments==`object`&&e.arguments!==null&&!Array.isArray(e.arguments)?e.arguments:{}}}function eJ(e){if(e.role!==`assistant`)return e;let t=e.content;if(!Array.isArray(t))return e;let n=t.map(e=>$q(e)??e);return{...e,content:n}}function tJ(e){if(e.role!==`assistant`)return e;let t=e.content;if(!Array.isArray(t))return e;for(let e=0;e<t.length;e++){let n=t[e],r=$q(n);r!==null&&(t[e]=r)}return e}var nJ=e=>{let t=e;return t?typeof t.thinking==`string`?t.thinking.length:typeof t.text==`string`?t.text.length:typeof t.streamingOutput==`string`?t.streamingOutput.length:0:0};function rJ(){let e=new Map,t=new Map;return{snapshot(n){e.clear(),t.clear(),Array.isArray(n)&&n.forEach((n,r)=>{e.set(r,nJ(n)),t.set(r,0)})},take(n,r){let i=e.get(n)??0,a=t.get(n)??0;t.set(n,a+r.length);let o=Math.min(Math.max(i-a,0),r.length);return o>0?r.slice(o):r},reset(){e.clear(),t.clear()}}}var iJ=[],aJ=[`read`,`bash`,`edit`,`write`],oJ=[`bash`,`read`,`edit`,`write`,`grep`,`find`,`ls`],sJ=new Set(oJ);function cJ(e){let t=e.filter(e=>e.active);if(t.length===0)return`none`;let n=t.map(e=>e.name).filter(e=>sJ.has(e)).sort().join(`,`);return n===[...aJ].sort().join(`,`)?`default`:n===[...oJ].sort().join(`,`)?`full`:`default`}function lJ(e){return e===`none`?[...iJ]:e===`full`?[...oJ]:[...aJ]}function uJ(e,t){switch(t.type){case`start`:return{isStreaming:!0,streamingMessage:null};case`update`:return{isStreaming:!0,streamingMessage:t.message};case`end`:case`reset`:return{isStreaming:!1,streamingMessage:null};default:return e}}function dJ(e){if(!e||typeof e!=`object`)return;let t=e.content;if(!Array.isArray(t))return;let n=t.filter(e=>typeof e==`object`&&!!e&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text);return n.length>0?n.join(``):void 0}function fJ(e){return{steering:e?.steering??[],followUp:e?.followUp??[]}}var pJ=700,mJ=1200,hJ=80,gJ=800,_J=600,vJ=2e4,yJ=3e4,bJ=200,xJ=32,SJ=15e3,CJ=1e3,wJ=5e3,TJ=5,EJ=5e3,DJ=180,OJ=new Set([`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `,`Space`,`Spacebar`]),kJ=class extends Error{constructor(e){super(e===`timeout`?`Timed out connecting to the agent event stream. Please try again.`:`Failed to connect to the agent event stream. Please try again.`),this.status=e,this.name=`EventStreamConnectionError`}};function AJ(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`}function jJ(e){return new Promise(t=>setTimeout(t,e))}function MJ(e){let t=e.findIndex(e=>!e.exiting);return t===-1?e:e.map((e,n)=>n===t?{...e,exiting:!0}:e)}function NJ(e,t){let n=e,r=t;for(;r.length>0&&n.length<TJ;){let[e,...t]=r;n=[...n,e],r=t}return r.length>0&&!n.some(e=>e.exiting)&&(n=MJ(n)),{visible:n,pending:r}}function PJ(e,t){switch(t.type){case`add`:return e.visible.some(e=>e.exiting)||e.visible.length>=TJ?{visible:e.visible.some(e=>e.exiting)?e.visible:MJ(e.visible),pending:[...e.pending,t.notice],modals:e.modals}:{...e,visible:[...e.visible,t.notice]};case`mark_oldest_exiting`:return{...e,visible:MJ(e.visible)};case`add_modal`:return{...e,modals:[...e.modals,t.notice]};case`dismiss_modal`:return{...e,modals:e.modals.filter(e=>e.id!==t.id)};case`remove`:return{...NJ(e.visible.filter(e=>e.id!==t.id),e.pending),modals:e.modals};default:return e}}function FJ(){let[e,t]=(0,d.useReducer)(PJ,{visible:[],pending:[],modals:[]}),n=(0,d.useCallback)(e=>{let n=e.message.trim();if(!n)return;let r={id:e.id??AJ(),message:n,type:e.type??`info`};t(e.modal?{type:`add_modal`,notice:r}:{type:`add`,notice:r})},[]),r=(0,d.useCallback)(e=>{t({type:`dismiss_modal`,id:e})},[]);return(0,d.useEffect)(()=>{if(e.visible.length===0)return;let n=e.visible.find(e=>e.exiting);if(n){let e=setTimeout(()=>{t({type:`remove`,id:n.id})},DJ);return()=>clearTimeout(e)}if(!e.visible[0])return;let r=setTimeout(()=>{t({type:`mark_oldest_exiting`})},EJ);return()=>clearTimeout(r)},[e.visible]),{noticeState:e,addNotice:n,dismissModal:r}}function IJ({messages:e,contextUsage:t,data:n,session:r,sessionIdRef:i}){let[a,o]=(0,d.useState)(null);return{sessionStats:(0,d.useMemo)(()=>{if(a)return a;let o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},s=0,c=0,l=0,u=0,d=0;for(let t of e){if(t.role===`user`&&(c+=1),t.role===`toolResult`&&(u+=1),t.role!==`assistant`)continue;l+=1;let e=t.usage;d+=t.content.filter(e=>e.type===`toolCall`).length,e&&(o.input+=e.input??0,o.output+=e.output??0,o.cacheRead+=e.cacheRead??0,o.cacheWrite+=e.cacheWrite??0,s+=e.cost?.total??0)}return o.total=o.input+o.output+o.cacheRead+o.cacheWrite,o.total===0&&e.length===0?null:{sessionFile:n?.filePath||void 0,sessionId:i.current??r?.id??``,sessionName:r?.name,userMessages:c,assistantMessages:l,toolCalls:d,toolResults:u,totalMessages:e.length,tokens:o,cost:s,...t?{contextUsage:t}:{}}},[e,a,t,n?.filePath,r?.id,r?.name,i]),setSessionStatsOverride:o}}function LJ({isNew:e,sessionIdRef:t,ensuringNewSessionRef:n,setToolPresetOverride:r}){let[i,a]=(0,d.useState)({}),[o,s]=(0,d.useState)([]),[c,l]=(0,d.useState)(null),[u,f]=(0,d.useState)([]),[p,m]=(0,d.useState)({}),[h,g]=(0,d.useState)({}),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(null),[x,S]=(0,d.useState)(`default`),[C,w]=(0,d.useState)(`auto`),[T,E]=(0,d.useState)(null),[D,O]=(0,d.useState)(null),k=(0,d.useRef)(null),A=(0,d.useRef)(null),j=r??S,M=(0,d.useCallback)((t,n)=>{if(e){let e={provider:t,modelId:n};k.current=e,v(e),O(e);return}E({provider:t,modelId:n})},[e,v]);return{modelNames:i,modelList:o,modelError:c,modelScopeWarnings:u,modelThinkingLevels:p,modelThinkingLevelMaps:h,newSessionModel:_,newSessionDefaultModel:y,toolPreset:x,thinkingLevel:C,currentModelOverride:T,pendingModel:D,setThinkingLevel:w,setPendingModel:O,setNewSessionDefaultModel:b,setCurrentModelOverride:E,setModelError:l,setToolPresetState:j,newSessionModelOverrideRef:k,thinkingLevelOverrideRef:A,loadModels:(0,d.useCallback)(async t=>{let n=await be.load(t);a(n.models),l(n.modelError??null),f(n.modelScopeWarnings??[]),m(n.thinkingLevels??{}),g(n.thinkingLevelMaps??{});let r=n.modelList??[];if(s(r),e){let e=(n.defaultModel?r.find(e=>e.id===n.defaultModel?.modelId&&e.provider===n.defaultModel?.provider):void 0)??r[0];b(t=>t??(e?{provider:e.provider,modelId:e.id}:null));let t=e&&n.thinkingLevelPins?.[`${e.provider}/${e.id}`];A.current===null&&w(e=>e===`auto`?t??`auto`:e)}},[e]),handleModelChange:M,handleThinkingLevelChange:(0,d.useCallback)(async r=>{if(w(r),e&&!t.current&&(A.current=r===`auto`?null:r),r===`auto`)return;let i=t.current??await n.current;if(i)try{await US(i,{type:`set_thinking_level`,level:r})}catch(e){console.error(`Failed to set thinking level:`,e)}},[e,t,n]),handleToolPresetChange:(0,d.useCallback)(async e=>{let r=lJ(e);j(e);let i=t.current??await n.current;if(i)try{await US(i,{type:`set_tools`,toolNames:r})}catch(e){console.error(`Failed to set tools:`,e)}},[j,t,n])}}function RJ({addNotice:e,chatInputRef:t,sessionIdRef:n}){let[r,i]=(0,d.useState)(null),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)([]),[l,u]=(0,d.useState)([]);return(0,d.useEffect)(()=>{if(!r?.timeout)return;let e=r.id,t=setTimeout(()=>{Rq(`ui-chain`,`4c dialog auto-close by timeout`,`id=${e.slice(0,8)}`),i(t=>t?.id===e?null:t)},r.timeout);return()=>clearTimeout(t)},[r]),{extensionDialog:r,extensionCustomUi:a,extensionStatuses:s,extensionWidgets:l,setExtensionStatuses:c,setExtensionWidgets:u,respondToExtensionUi:(0,d.useCallback)(async(e,t)=>{let r=n.current;if(i(t=>t?.id===e.id?null:t),r)try{await US(r,{type:`extension_ui_response`,id:e.id,...t})}catch(e){console.error(`Failed to send extension UI response:`,e)}},[n]),sendExtensionCustomInput:(0,d.useCallback)(async(e,t)=>{let r=n.current;if(r)try{await US(r,{type:`extension_ui_input`,id:e.id,data:t})}catch(e){console.error(`Failed to send extension custom UI input:`,e)}},[n]),handleExtensionUiRequest:(0,d.useCallback)(n=>{switch(n.method){case`select`:case`confirm`:case`input`:case`editor`:i(n);break;case`notify`:{let t=n.notifyType??`info`,r=n.message;t===`warning`?console.warn(`[pi] notify (warning): ${r}`):t===`error`?console.error(`[pi] notify (error): ${r}`):console.info(`[pi] notify: ${r}`);let i=typeof r==`string`&&r.length>100;e({id:n.id,message:r,type:t,modal:t===`warning`||t===`error`||i});break}case`setStatus`:c(e=>{let t=e.filter(e=>e.key!==n.statusKey);return n.statusText===void 0?t:[...t,{key:n.statusKey,text:n.statusText}]});break;case`setWidget`:u(e=>{let t=e.filter(e=>e.key!==n.widgetKey);return n.widgetLines?[...t,{key:n.widgetKey,lines:n.widgetLines,placement:n.widgetPlacement??`aboveEditor`}]:t});break;case`setTitle`:n.title&&(document.title=n.title);break;case`set_editor_text`:t?.current?.insertText(n.text);break;case`custom`:o(e=>n.closed?e?.id===n.id?null:e:n)}},[e,t])}}function zJ(e){let t=e.content;return typeof t==`string`?t:Array.isArray(t)?t.map(e=>e&&typeof e==`object`&&e.type===`text`&&typeof e.text==`string`?e.text:``).filter(Boolean).join(`
|
|
349
|
+
`):``}function BJ(e){if(!e||typeof e!=`object`||e.type!==`image`)return``;let t=e.source;if(t&&typeof t==`object`){let e=t;return[e.type===`url`?`url`:`base64`,typeof e.media_type==`string`?e.media_type:``,typeof e.data==`string`?e.data:``,typeof e.url==`string`?e.url:``].join(`:`)}let n=e;return[`base64`,typeof n.mimeType==`string`?n.mimeType:``,typeof n.data==`string`?n.data:``,``].join(`:`)}function VJ(e){function t(t,n){try{if(localStorage.getItem(`piWebDebug`)===`1`){let e=Error().stack;Rq(`messages`,t,e?.split(`
|
|
350
350
|
`).slice(1).join(`
|
|
351
|
-
`))}}catch{}e(n)}return{apply:(e,n)=>t(e,n),append:(e,n)=>t(`${e}:append`,e=>[...e,n]),replaceAll(e,n){t(`${e}:replaceAll`,n)},truncateFrom:(e,n)=>t(`${e}:truncateFrom`,e=>e.slice(0,Math.max(0,n))),dropLastIf:(e,n)=>t(`${e}:dropLastIf`,e=>n(e[e.length-1])?e.slice(0,-1):e)}}function BJ(e){let t=e.content;return JSON.stringify(typeof t==`string`?{text:t,images:[]}:Array.isArray(t)?{text:LJ(e),images:t.map(RJ).filter(Boolean)}:{text:``,images:[]})}function VJ(e,t){if(!e||typeof e!=`object`)return null;let n=e;return typeof n.tokensBefore!=`number`||typeof n.estimatedTokensAfter!=`number`?null:{reason:t,tokensBefore:n.tokensBefore,estimatedTokensAfter:n.estimatedTokensAfter}}function HJ(e,t,n,r){let i=new Set(t),a=new Set(e.filter(e=>e.role===`user`).map(BJ)),o=[...e];for(let e=0;e<n.length;e++){let t=r[e];if(t!==void 0)i.has(t)||o.push(n[e]);else{let t=n[e];(t.role!==`user`||!a.has(BJ(t)))&&o.push(t)}}return o}function UJ(e){let{session:t,newSessionCwd:n,onAgentEnd:r,onAgentSettled:i,onAgentError:a,onSessionCreated:o,onSessionForked:s,modelsRefreshKey:c}=e,l=t===null&&n!==null,[u,f]=(0,d.useState)(null),[p,m]=(0,d.useState)(!l),[h,g]=(0,d.useState)(null),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)([]),x=(0,d.useRef)(null);x.current||=zJ(b);let S=x.current,[C,w]=(0,d.useState)([]),[T,E]=(0,d.useReducer)(cJ,{isStreaming:!1,streamingMessage:null}),D=(0,d.useRef)(null),O=(0,d.useRef)(null),k=(0,d.useRef)(null),A=(0,d.useRef)(new Map),j=(0,d.useRef)(!0),M=(0,d.useRef)([]),P=(0,d.useRef)(new Map),ee=(0,d.useRef)(null),F=(0,d.useRef)(null),te=(0,d.useCallback)(()=>{let e=A.current;if(e.size===0)return;let t=k.current;if(!t){e.clear();return}let n=t.content;if(!Array.isArray(n)){e.clear();return}for(let[t,r]of e){let e=r.join(``),i=n[t];i&&(i.type===`thinking`?i.thinking=(i.thinking??``)+e:i.type===`text`?i.text=(i.text??``)+e:i.type===`toolCall`&&(i.streamingOutput=(i.streamingOutput??``)+e))}e.clear()},[]),ne=(0,d.useCallback)(()=>{O.current&&=(clearTimeout(O.current),null),te();let e=D.current;if(D.current=null,e&&Je.current){let t=e,n={...e,content:[...t.content??[]]};(0,d.startTransition)(()=>E({type:`update`,message:n}))}else if(k.current&&Je.current){let e=k.current,t={...e,content:[...e.content??[]]};(0,d.startTransition)(()=>E({type:`update`,message:t}))}},[te]);(0,d.useEffect)(()=>()=>{O.current&&=(clearTimeout(O.current),null),ee.current&&=(clearTimeout(ee.current),null),F.current&&=(clearTimeout(F.current),null)},[]);let[re,ie]=(0,d.useState)(!1),[ae,oe]=(0,d.useState)(!1),I=(0,d.useCallback)(e=>{Je.current=e,ie(e)},[]),L=(0,d.useCallback)(e=>{Qe.current=e,oe(e)},[]),[se,R]=(0,d.useState)(``),[ce,le]=(0,d.useState)(null),[ue,de]=(0,d.useState)(null),[fe,pe]=(0,d.useState)(null),[me,he]=(0,d.useState)(null),[ge,_e]=(0,d.useState)(null),[ve,ye]=(0,d.useState)(!1),[xe,Se]=(0,d.useState)(null),[Ce,we]=(0,d.useState)(null),[Te,De]=(0,d.useState)(null),[Oe,ke]=(0,d.useState)([]),[Ae,je]=(0,d.useState)(!1),{noticeState:Me,addNotice:Ne,dismissModal:Pe}=NJ(),{t:Fe}=N(),[Ie,Le]=(0,d.useState)({steering:[],followUp:[]}),[Re,ze]=(0,d.useState)(!1),Be=(0,d.useRef)(null),Ve=(0,d.useRef)(null),He=(0,d.useRef)(null),Ue=(0,d.useRef)(null),We=(0,d.useRef)(null),Ge=(0,d.useRef)(0),Ke=(0,d.useRef)(!1),qe=(0,d.useRef)(t?.id??null),Je=(0,d.useRef)(!1),Ye=(0,d.useRef)(!1),Xe=(0,d.useRef)(!1),Ze=(0,d.useRef)(-1),Qe=(0,d.useRef)(!1),$e=(0,d.useRef)(0),et=(0,d.useRef)(null),tt=(0,d.useRef)(!1),nt=(0,d.useRef)(null),rt=(0,d.useRef)(!1),it=(0,d.useRef)(!0),at=(0,d.useRef)(void 0),ot=(0,d.useRef)(0),st=(0,d.useRef)(0),ct=(0,d.useRef)(null),lt=(0,d.useRef)(null),ut=(0,d.useRef)(null),dt=(0,d.useRef)(!1),ft=(0,d.useRef)(0),pt=(0,d.useRef)(!1),{modelNames:mt,modelList:ht,modelError:gt,modelScopeWarnings:_t,modelThinkingLevels:vt,modelThinkingLevelMaps:yt,newSessionModel:bt,newSessionDefaultModel:xt,toolPreset:St,thinkingLevel:Ct,currentModelOverride:wt,pendingModel:Tt,setThinkingLevel:Et,setPendingModel:Dt,setNewSessionDefaultModel:Ot,setCurrentModelOverride:kt,setModelError:At,setToolPresetState:jt,newSessionModelOverrideRef:Mt,thinkingLevelOverrideRef:Nt,loadModels:Pt,handleModelChange:It,handleThinkingLevelChange:Lt,handleToolPresetChange:Rt}=FJ({isNew:l,sessionIdRef:qe,ensuringNewSessionRef:ut,setToolPresetOverride:e.setToolPreset}),{extensionDialog:zt,extensionCustomUi:Bt,extensionStatuses:Vt,extensionWidgets:Ht,setExtensionStatuses:Ut,setExtensionWidgets:Wt,respondToExtensionUi:Gt,sendExtensionCustomInput:Kt,handleExtensionUiRequest:qt}=IJ({addNotice:Ne,chatInputRef:e.chatInputRef,sessionIdRef:qe}),Jt=(0,d.useCallback)(e=>{e?.contextUsage!==void 0&&pe(e.contextUsage??null),e?.systemPrompt!==void 0&&he(e.systemPrompt??null),e?.thinkingLevel!==void 0&&Et(e.thinkingLevel??`auto`),e?.extensionStatuses!==void 0&&Ut(e.extensionStatuses??[]),e?.extensionWidgets!==void 0&&Wt(e.extensionWidgets??[]),e?.queuedMessages!==void 0&&Le(uJ(e.queuedMessages))},[Et,Ut,Wt]),Yt=wt??u?.context.model??Tt??null,Xt=l?bt??xt:Yt,Zt=(0,d.useSyncExternalStore)(Ee.subscribe,()=>Ee.get()??null,()=>null);(0,d.useEffect)(()=>{Ee.load().catch(()=>{})},[]);let Qt=(0,d.useRef)(null);(0,d.useEffect)(()=>{if(!Xt||!Zt||Object.keys(vt).length===0)return;let e=Yq(Zt,Xt.provider,Xt.modelId),t=`${Xt.provider}/${Xt.modelId}`;if(Qt.current&&Qt.current.key!==t&&(Qt.current=null),!e||Qt.current)return;let n=vt[t],r=!n||n.includes(e),i;if(r)i=e;else if(e===`auto`||!n||n.length===0)i=`auto`;else{i=xi(e,n);let t=Ee.get()??{},r=Zq(t,Xt.provider,Xt.modelId,i);JSON.stringify(r)!==JSON.stringify(t)&&Ee.load().catch(()=>{}).then(async()=>{try{await fetch(`/api/model-thinking`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(r)}),await Ee.refresh()}catch{}})}if(i!==Ct&&(Et(i),l&&!qe.current&&(Nt.current=i===`auto`?null:i),i!==`auto`&&qe.current)){let e=qe.current;US(e,{type:`set_thinking_level`,level:i}).catch(()=>{})}},[Xt?.provider,Xt?.modelId,Zt,vt,Ct,l]);let $t=(0,d.useCallback)(async e=>{if(Xt&&(Qt.current={key:`${Xt.provider}/${Xt.modelId}`,level:e}),await Lt(e),!Xt)return;try{await Ee.load()}catch{}let t=Ee.get()??{},n=Zq(t,Xt.provider,Xt.modelId,e);if(JSON.stringify(n)!==JSON.stringify(t))try{await fetch(`/api/model-thinking`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}),await Ee.refresh()}catch{}},[Lt,Xt]),{sessionStats:en,setSessionStatsOverride:tn}=PJ({messages:y,contextUsage:fe,data:u,session:t,sessionIdRef:qe}),nn=(0,d.useCallback)(async(e,t=!1,n=!1)=>{let r=!1;try{t&&m(!0);let i=new URLSearchParams({deferMedia:`1`}),a=await fetch(`/api/sessions/${encodeURIComponent(e)}?${i}`);if(a.status===404)return t&&(f(null),v(null),S.apply(`loadSession:notFound`,[]),g(null)),null;if(!a.ok)throw Error(`HTTP ${a.status}`);let o=await a.json();if(qe.current!==e)return null;if(f(o),v(o.leafId),pt.current){let e=o.context.entryIds??[];S.apply(`loadSession:keepOptimistic`,t=>HJ(o.context.messages,e,t,C)),w(e)}else S.replaceAll(`loadSession`,o.context.messages),w(o.context.entryIds??[]);if(kt(null),g(null),o.context.thinkingLevel&&o.context.thinkingLevel!==`off`&&Et(o.context.thinkingLevel),r=!0,t&&m(!1),!n)return null;try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/state`);if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();if(qe.current!==e)return null;let r=n.state;return r?Jt(r):n.running||Le({steering:[],followUp:[]}),n}catch(e){return console.error(`Failed to load agent state:`,e),null}}catch(e){return g(String(e)),null}finally{t&&!r&&m(!1)}},[Jt,Et,kt,S,C]),rn=(0,d.useCallback)(async(e,t,n=!1)=>{try{let r=new URLSearchParams({deferMedia:`1`});t&&r.set(`leafId`,t);let i=`/api/sessions/${encodeURIComponent(e)}/context?${r}`,a=await fetch(i);if(!a.ok)throw Error(`HTTP ${a.status}`);let o=await a.json(),s=o.context.entryIds??[];S.apply(`loadContext merge=${n}`,e=>n?HJ(o.context.messages,s,e,C):o.context.messages),w(s)}catch(e){console.error(`Failed to load context:`,e)}},[C,S]),an=(0,d.useCallback)(async e=>{try{let t=await US(e,{type:`get_tools`});t&&jt(oJ(t))}catch(e){console.error(`Failed to load tools:`,e)}},[jt]),on=(0,d.useCallback)((e=0,t=`(no messages)`)=>{let r=qe.current;!l||!n||!r||dt.current||(dt.current=!0,o?.({id:r,path:``,cwd:n,name:void 0,created:new Date().toISOString(),modified:new Date().toISOString(),messageCount:e,firstMessage:t}))},[l,n,o]),sn=(0,d.useCallback)(async()=>{if(qe.current||!l||!n)return qe.current;if(ut.current)return ut.current;let e=(async()=>{let e=Mt.current,t=Nt.current;e&&Dt(e);let r=sJ(St),i=await fetch(`/api/agent/new`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:n,type:`ensure_session`,toolNames:r,...e?{provider:e.provider,modelId:e.modelId}:{},...t?{thinkingLevel:t}:{}})});if(!i.ok)throw Error(`HTTP ${i.status}`);let a=await i.json(),o=a.sessionId;return qe.current=o,a.model&&Mt.current===e&&(Dt(a.model),e||Ot(a.model)),a.thinkingLevel&&Nt.current===t&&Et(a.thinkingLevel),o})();ut.current=e;try{return await e}finally{ut.current=null}},[l,n,St,Nt,Mt,Dt,Et,Ot]),cn=(0,d.useCallback)(async()=>{let e=qe.current??await sn();if(!e)return ke([]),[];je(!0);try{let t=(await US(e,{type:`get_commands`}))?.commands??[];return ke(t),t}catch(e){return console.error(`Failed to load slash commands:`,e),ke([]),[]}finally{je(!1)}},[sn]),ln=(0,d.useCallback)(()=>{Ge.current+=1,Ke.current=!1,We.current&&=(clearTimeout(We.current),null)},[]),un=(0,d.useCallback)(()=>{Be.current?.(),Be.current=null,He.current=null,Ue.current=null},[]),dn=(0,d.useCallback)(e=>{un();let t=`agent:${e}`,n=!1,r=null,i,a={key:t,promise:null,pending:!0},o=e=>{n||(n=!0,r&&clearTimeout(r),Ue.current===a&&(a.pending=!1),i({status:e}))};r=setTimeout(()=>o(`timeout`),SJ);let s=new Promise(e=>{i=e});return a.promise=s,Be.current=Ft({ch:`agent`,sessionId:e},e=>{e.type===`connected`?o(`connected`):(e.type===`not_found`||e.type===`start_failed`)&&o(`closed`)}),He.current=e,Ue.current=a,s},[un]),fn=(0,d.useCallback)(async e=>{if(He.current===e&&Be.current){let e=Ue.current;if(e?.pending){let t=await e.promise;if(t.status===`connected`)return;throw un(),new DJ(t.status)}return}let t=await dn(e);if(t.status!==`connected`)throw un(),new DJ(t.status)},[un,dn]),pn=(0,d.useCallback)(()=>{let e=Je.current;return Je.current=!1,ie(!1),De(null),de(null),E({type:`end`}),e},[]),mn=(0,d.useCallback)(e=>Ze.current!==e&&(Ze.current=e,r?.(),!0),[r]),hn=(0,d.useCallback)(e=>{ln(),Ke.current=!0;let t=Ge.current,n=async()=>{if(!(t!==Ge.current||qe.current!==e||!Ke.current))try{let r=await fetch(`/api/agent/${encodeURIComponent(e)}`);if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.json();if(t!==Ge.current||qe.current!==e||!Ke.current)return;let a=i.state;if(i.running&&a&&(a.isStreaming||a.isPromptRunning)){Ke.current=!1,We.current=null,Ye.current=!!a?.isStreaming,Xe.current=!!a?.isPromptRunning,I(!0),De(a?.isStreaming?{kind:`waiting_model`}:{kind:`running_command`});return}if(i.running&&a?.isCompacting){ye(!0),We.current=setTimeout(()=>void n(),hJ);return}Ke.current=!1,We.current=null,un()}catch{if(t!==Ge.current||qe.current!==e||!Ke.current)return;We.current=setTimeout(()=>void n(),hJ)}};We.current=setTimeout(()=>void n(),_J)},[ln,un]),gn=(0,d.useCallback)(async(e=qe.current,t=ft.current)=>{if(ft.current===t)try{e&&await nn(e)}catch(e){if(ft.current!==t)return;throw e}finally{if(ft.current===t){let n=Xe.current,a=Ye.current;Xe.current=!1,Ye.current=!1,pt.current=!1;let o=pn();n?(mn(t),o&&i?.()):a&&o&&(r?.(),i?.()),e&&hn(e)}}},[nn,mn,r,i,hn,pn]),_n=(0,d.useCallback)(async(e,t)=>{await kJ(mJ);let n=Date.now();for(;Je.current&&Date.now()-n<gJ;){if(t!==void 0&&ft.current!==t)return;try{let n=await fetch(`/api/agent/${encodeURIComponent(e)}`);if(n.ok){let r=await n.json(),i=r.state;if(!r.running||!i||!i.isStreaming&&!i.isPromptRunning){await gn(e,t);return}}}catch{}await kJ(hJ)}},[gn]),vn=(0,d.useCallback)(async e=>{let t=$e.current+1;for($e.current=t;Qe.current&&$e.current===t&&qe.current===e;){await kJ(xJ);try{let n=await fetch(`/api/agent/${encodeURIComponent(e)}`);if(!n.ok||(await n.json()).state?.isBashRunning)continue;if(await nn(e),$e.current!==t||qe.current!==e)return;L(!1),le(null);return}catch{}}},[nn]),yn=(0,d.useCallback)(async e=>{if(!Je.current)return;let t=ft.current;try{let n=await fetch(`/api/agent/${encodeURIComponent(e)}`);if(!n.ok)return;let r=await n.json();if(ft.current!==t)return;let i=r.state;if(ye(i?.isCompacting??!1),Le(uJ(i?.queuedMessages)),r.running&&i&&(i.isStreaming||i.isPromptRunning||i.isCompacting)||!Je.current)return;i&&Jt(i),await gn(e,t)}catch{}},[Jt,gn]);(0,d.useEffect)(()=>{if(!re)return;let e=()=>{let e=qe.current;e&&yn(e)},t=()=>{document.visibilityState===`visible`&&e()},n=setInterval(e,bJ);return document.addEventListener(`visibilitychange`,t),window.addEventListener(`online`,e),()=>{clearInterval(n),document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`online`,e)}},[re,yn]),(0,d.useEffect)(()=>{Je.current=re},[re]),et.current=(0,d.useCallback)(e=>{let t=e=>{let t=e.assistantMessageEvent;if(!t||typeof t.type!=`string`)return;let n=k.current;if(!n)return;let r=t.contentIndex;if(typeof r!=`number`)return;let i=n.content;if(Array.isArray(i))switch(t.type){case`thinking_start`:{if(i[r]?.type===`thinking`)break;let e={type:`thinking`,thinking:``};r>=i.length?i.push(e):i.splice(r,0,e),j.current=!0;break}case`thinking_delta`:if(i[r]?.type===`thinking`&&typeof t.delta==`string`){let e=A.current,n=e.get(r)??[];n.push(t.delta),e.set(r,n)}break;case`thinking_end`:{let e=A.current;if(e.has(r)){let t=e.get(r);e.delete(r);let n=t.join(``),a=i[r];a?.type===`thinking`&&(a.thinking=(a.thinking??``)+n)}let n=i[r];if(n?.type===`thinking`&&typeof t.content==`string`&&(n.thinking=t.content),n?.type===`thinking`){let e=t.thinkingSignature??t.signature;typeof e==`string`&&e.length>0?n.thinkingSignature=e:e&&typeof e==`object`&&(n.thinkingSignature=JSON.stringify(e)),t.redacted===!0&&(n.redacted=!0);let i=t.partial?.content?.[r];i&&typeof i.thinkingSignature==`string`&&!n.thinkingSignature&&(n.thinkingSignature=i.thinkingSignature),i&&i.redacted===!0&&(n.redacted=!0)}break}case`text_start`:{if(i[r]?.type===`text`)break;let e={type:`text`,text:``};r>=i.length?i.push(e):i.splice(r,0,e),j.current=!0;break}case`text_delta`:if(i[r]?.type===`text`&&typeof t.delta==`string`){let e=A.current,n=e.get(r)??[];n.push(t.delta),e.set(r,n)}break;case`text_end`:{let e=A.current;if(e.has(r)){let t=e.get(r);e.delete(r);let n=t.join(``),a=i[r];a?.type===`text`&&(a.text=(a.text??``)+n)}let n=i[r];n?.type===`text`&&typeof t.content==`string`&&(n.text=t.content);break}case`toolcall_start`:break;case`toolcall_delta`:if(i[r]?.type===`toolCall`&&typeof t.delta==`string`){let e=A.current,n=e.get(r)??[];n.push(t.delta),e.set(r,n)}break;case`toolcall_end`:{let e=A.current;e.has(r)&&e.delete(r),t.toolCall&&typeof t.toolCall==`object`&&(i[r]={type:`toolCall`,...t.toolCall});break}}},n=()=>{if(O.current)return;let e=j.current?yJ:vJ;O.current=setTimeout(()=>{O.current=null,te();let e=k.current??D.current;if(D.current=null,!e||!Je.current)return;let t=e.content;if(!(Array.isArray(t)&&t.some(e=>{let t=e.type;return t===`thinking`?!!((e.thinking?.trim()??``)!==``||typeof e.thinkingSignature==`string`&&e.thinkingSignature.length>0||e.redacted):t!==`text`||(e.text?.trim()??``)!==``})))return;j.current=!1;let n={...e,content:[...t??[]]};(0,d.startTransition)(()=>E({type:`update`,message:n}))},e)},o=()=>{if(!Je.current)return;let r=e.message;if(r&&r.role!==`user`){A.current.clear();let e=tJ(r);k.current=e,D.current=e,j.current=!0,n()}else k.current&&(t(e),n())};switch(e.type){case`agent_start`:A.current.clear(),k.current=null,D.current=null,j.current=!0,ln(),Ye.current=!0,I(!0),De({kind:`waiting_model`}),E({type:`start`});break;case`agent_end`:if(!Je.current)break;if(De(null),de(null),E({type:`end`}),k.current=null,D.current=null,A.current.clear(),O.current&&=(clearTimeout(O.current),null),ee.current&&=(clearTimeout(ee.current),null),M.current.length){let e=M.current.join(``);M.current=[],e&&R(t=>t+e)}if(F.current&&=(clearTimeout(F.current),null),P.current.size){let e=new Map(P.current);P.current.clear(),S.apply(`tool_execution_update:batched:drain`,t=>t.map(t=>{if(!(`content`in t)||!Array.isArray(t.content))return t;let n=!1,r=t.content.map(t=>{if(t.type===`toolCall`){let r=e.get(t.toolCallId??``);if(r!==void 0)return n=!0,{...t,streamingOutput:r}}return t});return n?{...t,content:r}:t}))}qe.current&&(nn(qe.current),fetch(`/api/agent/${encodeURIComponent(qe.current)}`).then(e=>e.json()).then(e=>{e.state&&Jt(e.state),Le(uJ(e.state?.queuedMessages))}).catch(()=>{}));break;case`agent_settled`:{let e=Ye.current;if(Ye.current=!1,!e||Xe.current)break;let t=qe.current,n=pn();ye(!1),t&&(nn(t),hn(t)),k.current=null,D.current=null,A.current.clear(),O.current&&=(clearTimeout(O.current),null),n&&(r?.(),i?.());break}case`prompt_done`:{let e=ft.current,t=Xe.current;Xe.current=!1,pt.current=!1;let n=mn(e);if(!t&&!n)break;let a=qe.current;if(a&&nn(a),!Ye.current){let e=pn();a&&hn(a),e&&(r?.(),i?.())}}break;case`prompt_error`:Ne({type:`error`,message:e.errorMessage??Fe(`i18n.commandFailed`)}),a?.(e.errorMessage??Fe(`i18n.commandFailed`));break;case`extension_error`:Ne({type:`error`,message:e.error??Fe(`i18n.extensionCommandFailed`)}),a?.(e.error??Fe(`i18n.extensionCommandFailed`));break;case`message_start`:o();break;case`message_update`:o(),e.assistantMessageEvent?.type?.startsWith(`thinking`)?De({kind:`thinking`}):De(null);break;case`message_end`:{if(!Je.current)break;ne();let t=e.message;if(t&&t.role===`user`){let e=eJ(t),n=BJ(e),r=pt.current;pt.current=!1,S.apply(`message_end:userEcho`,t=>{let i=t[t.length-1];return i?.role===`user`&&BJ(i)===n?t:r&&i?.role===`user`?[...t.slice(0,-1),e]:[...t,e]})}else t&&S.append(`message_end:assistant`,eJ(t));E({type:`reset`}),k.current=null,D.current=null,A.current.clear(),O.current&&=(clearTimeout(O.current),null),De({kind:`waiting_model`});break}case`tool_execution_start`:{let t=e.toolCallId,n=e.toolName;De(e=>{let r=e?.kind===`running_tools`?[...e.tools]:[];return r.some(e=>e.id===t)||r.push({id:t,name:n}),{kind:`running_tools`,tools:r}});break}case`tool_execution_update`:{let t=e.toolCallId,n=lJ(e.partialResult);if(n===void 0)break;P.current.set(t,n),F.current||=setTimeout(()=>{F.current=null;let e=new Map(P.current);P.current.clear(),e.size!==0&&(0,d.startTransition)(()=>{S.apply(`tool_execution_update:batched`,t=>t.map(t=>{if(!(`content`in t)||!Array.isArray(t.content))return t;let n=!1,r=t.content.map(t=>{if(t.type===`toolCall`){let r=e.get(t.toolCallId??``);if(r!==void 0)return n=!0,{...t,streamingOutput:r}}return t});return n?{...t,content:r}:t}))})},vJ);break}case`tool_execution_end`:{let t=e.toolCallId;De(e=>{if(e?.kind!==`running_tools`)return e;let n=e.tools.filter(e=>e.id!==t);return n.length===0?{kind:`waiting_model`}:{kind:`running_tools`,tools:n}});break}case`bash_execution_update`:{let t=e.delta;if(!t)break;M.current.push(t),ee.current||=setTimeout(()=>{ee.current=null;let e=M.current;if(M.current=[],e.length===0)return;let t=e.join(``);t&&(0,d.startTransition)(()=>R(e=>e+t))},vJ);break}case`queue_update`:Le({steering:[...e.steering??[]],followUp:[...e.followUp??[]]});break;case`auto_retry_start`:de({attempt:e.attempt,maxAttempts:e.maxAttempts,errorMessage:e.errorMessage});break;case`auto_retry_end`:de(null);break;case`auto_compaction_start`:case`compaction_start`:ye(!0),Se(null),we(null);break;case`auto_compaction_end`:case`compaction_end`:ye(!1),e.errorMessage?(Se(e.errorMessage),we(null)):e.aborted||(we(VJ(e.result,e.reason??`auto`)),qe.current&&nn(qe.current));break;case`extension_ui_request`:qt(e)}},[Ne,ln,qt,nn,mn,r,i,a,hn,pn,Fe,ne,Jt,S]);let bn=(0,d.useRef)(qt);bn.current=qt,(0,d.useEffect)(()=>(Ve.current?.(),Ve.current=Ft({ch:`global`},e=>{if(e.type===`extension_ui_request`&&(Rq(`ui-chain`,`4a ws recv ${e.method}`,`id=${String(e.id).slice(0,8)} evtSid=${String(e.sessionId).slice(0,8)} activeSid=${qe.current?.slice(0,8)??`null`}`),e.sessionId&&e.sessionId!==qe.current&&Bq.has(e.method??``)&&Wq(e.sessionId)),e.sessionId===qe.current){if(e.type===`extension_ui_request`){bn.current?.(e);return}et.current?.(e)}}),()=>{Ve.current?.(),Ve.current=null}),[]);let xn=(0,d.useCallback)(async(r,i)=>{let a=r.trim();if(!a&&!i?.length||Je.current||Qe.current)return;let o=!i?.length&&a.startsWith(`/`);if(!i?.length&&a.startsWith(`!`)){let e=a.startsWith(`!!`),t=(e?a.slice(2):a.slice(1)).trim();if(!t)return;await at.current?.(t,e);return}Rq(`ui-chain`,`1 client send`,JSON.stringify(a.slice(0,80)));let s=ft.current+1;ln(),Xe.current=!0;let c=i?.map(e=>({type:`image`,source:{type:`base64`,media_type:e.mimeType,data:e.data}})),u={role:`user`,content:c?.length?[...r.trim()?[{type:`text`,text:r}]:[],...c]:r,timestamp:Date.now()};S.append(`handleSend:optimistic`,u),pt.current=!0,ft.current=s,I(!0),De(o?{kind:`running_command`}:{kind:`waiting_model`}),E({type:`start`}),rt.current=!0,it.current=!0;let d=i?.map(e=>({type:`image`,data:e.data,mimeType:e.mimeType})),f=null,p=!1;try{if(l&&n){let e=bt,t=qe.current??await ut.current,n=t??await sn();n&&(f=n,e&&(Dt(e),t&&await US(n,{type:`set_model`,provider:e.provider,modelId:e.modelId})),await fn(n),p=!0,on(1,r),await US(n,{type:`prompt`,message:r,...d?.length?{images:d}:{}}))}else if(t){f=t.id,await fn(t.id),p=!0;let e=wt;await US(t.id,{type:`prompt`,message:r,...d?.length?{images:d}:{},...e?{provider:e.provider,modelId:e.modelId}:{}})}o&&f&&_n(f,s)}catch(t){if(console.error(`Failed to send message:`,t),p&&f){t instanceof DJ||Ne({type:`error`,message:t instanceof Error?t.message:String(t)}),_n(f,s);return}Xe.current=!1,Je.current=!1,un(),t instanceof DJ&&(pt.current&&(pt.current=!1,S.dropLastIf(`sendError:rollbackOptimistic`,e=>e?.role===`user`)),Ne({type:`error`,message:t.message}),r&&e.chatInputRef?.current?.insertIfEmpty(r)),pt.current=!1,I(!1),De(null),E({type:`end`})}},[l,n,bt,t,sn,fn,on,wt,_n,Ne,ln,un,e.chatInputRef,Dt,S]);at.current=(0,d.useCallback)(async(n,r)=>{if(Je.current||Qe.current)return;let i=`${r?`!!`:`!`}${n}`;L(!0),le({command:n,excludeFromContext:r}),R(``);try{let e=qe.current??t?.id??await sn();if(!e)throw Error(`Unable to create a session for the shell command`);await fn(e),on(1,i),await US(e,{type:`bash`,command:n,excludeFromContext:r}),await nn(e)}catch(t){console.error(`Failed to execute shell command:`,t),Ne({type:`error`,message:t instanceof Error?t.message:String(t)}),e.chatInputRef?.current?.insertIfEmpty(i)}finally{L(!1),le(null)}},[Ne,fn,sn,nn,e.chatInputRef,on,t]);let Sn=(0,d.useCallback)(async()=>{let e=qe.current;if(e){if(Qe.current){try{await US(e,{type:`abort_bash`})}catch(e){console.error(`Failed to abort bash:`,e)}return}try{await US(e,{type:`abort`})}catch(e){console.error(`Failed to abort:`,e)}}},[]),Cn=(0,d.useCallback)(async e=>{if(Qe.current)return;let t=qe.current;if(t){_e(e);try{let{cancelled:n,newSessionId:r}=await US(t,{type:`fork`,entryId:e})??{};!n&&r&&s?.(r)}catch(e){console.error(`Fork failed:`,e)}finally{_e(null)}}},[s]),wn=(0,d.useCallback)(async e=>{if(Qe.current)return;let t=qe.current;t&&(US(t,{type:`navigate_tree`,targetId:e}).catch(()=>{}),v(e),await rn(t,e))},[rn]),Tn=(0,d.useCallback)(async e=>{if(Qe.current)return;v(e);let t=qe.current;t&&(await rn(t,e),e&&US(t,{type:`navigate_tree`,targetId:e}).catch(()=>{}))},[rn]),En=(0,d.useCallback)(async()=>{let e=qe.current;if(!(!e||ve)){ye(!0),Se(null),we(null);try{let t=await US(e,{type:`compact`});we(VJ(t,`manual`)),await nn(e,!0)}catch(e){Se(e instanceof Error?e.message:String(e)),we(null)}finally{ye(!1)}}},[ve,nn]),Dn=(0,d.useCallback)(async e=>{if(!e.startsWith(`/`))return{handled:!1};let t=e.match(/^\/([^\s]+)(?:\s+([\s\S]*))?$/);if(!t)return{handled:!1};let[,n,r=``]=t,i=r.trim(),a=qe.current??await sn(),o=e=>(e.handled&&(e.error?Ne({type:`error`,message:e.error}):e.action!==`openSessionStats`&&Ne({type:`success`,message:e.message??Fe(`i18n.commandCompleted`)})),e);try{switch(ze(!0),n){case`compact`:{if(!a||ve)return o({handled:!0,error:Fe(`i18n.noActiveSessionToCompact`)});ye(!0),Se(null),we(null);let e=await US(a,{type:`compact`,...i?{customInstructions:i}:{}});return we(VJ(e,`manual`)),await nn(a,!0)&&on(),o({handled:!0,message:Fe(`i18n.compactedContext`)})}case`reload`:return a?(await US(a,{type:`reload`}),await be.refresh(),await Promise.all([nn(a,!1,!0),an(a),cn(),Pt()]),o({handled:!0,message:Fe(`i18n.reloadedSessionResources`)})):o({handled:!0,error:Fe(`i18n.noActiveSessionToReload`)});case`name`:return a?i?(await US(a,{type:`set_session_name`,name:i}),await nn(a)&&on(),o({handled:!0,message:Fe(`i18n.sessionRenamedTo`,{name:i})})):o({handled:!0,error:Fe(`i18n.usageName`)}):o({handled:!0,error:Fe(`i18n.noActiveSessionToName`)});case`session`:{if(!a)return o({handled:!0,error:Fe(`i18n.noActiveSession`)});let e=await US(a,{type:`get_session_stats`});return e&&tn(e),o({handled:!0,action:`openSessionStats`})}case`copy`:{if(!a)return o({handled:!0,error:Fe(`i18n.noActiveSession`)});let e=(await US(a,{type:`get_last_assistant_text`}))?.text??``;return e?(await navigator.clipboard.writeText(e),o({handled:!0,message:Fe(`i18n.copiedLastAssistantMessage`)})):o({handled:!0,error:Fe(`i18n.noAssistantMessageToCopy`)})}default:return{handled:!1}}}catch(e){return o({handled:!0,error:e instanceof Error?e.message:String(e)})}finally{ze(!1),n===`compact`&&ye(!1)}},[Ne,sn,ve,Pt,nn,cn,an,on,tn,Fe]),On=(0,d.useCallback)(async(e,t,n)=>{let r=qe.current;if(!r)return;let i=t?.map(e=>({type:`image`,data:e.data,mimeType:e.mimeType}));try{await US(r,{...e,...i?.length?{images:i}:{}})}catch(e){console.error(`Failed to ${n}:`,e),Ne({type:`error`,message:e instanceof Error?e.message:String(e)})}},[Ne]),kn=(0,d.useCallback)((e,t)=>On({type:`steer`,message:e},t,`steer`),[On]),An=(0,d.useCallback)((e,t,n)=>On({type:`prompt`,message:e,streamingBehavior:t},n,`queue prompt`),[On]),jn=(0,d.useCallback)((e,t)=>On({type:`follow_up`,message:e},t,`follow up`),[On]),Mn=(0,d.useCallback)(async()=>{let e=qe.current;if(e)try{await US(e,{type:`abort_compaction`})}catch(e){console.error(`Failed to abort compaction:`,e)}},[]),Nn=(0,d.useCallback)(async()=>{let t=qe.current;if(t)try{let n=await US(t,{type:`clear_queue`});Le({steering:[],followUp:[]});let r=[...n?.steering??[],...n?.followUp??[]];r.length>0&&e.chatInputRef?.current?.prependText(r.join(`
|
|
351
|
+
`))}}catch{}e(n)}return{apply:(e,n)=>t(e,n),append:(e,n)=>t(`${e}:append`,e=>[...e,n]),replaceAll(e,n){t(`${e}:replaceAll`,n)},truncateFrom:(e,n)=>t(`${e}:truncateFrom`,e=>e.slice(0,Math.max(0,n))),dropLastIf:(e,n)=>t(`${e}:dropLastIf`,e=>n(e[e.length-1])?e.slice(0,-1):e)}}function HJ(e){let t=e.content;return JSON.stringify(typeof t==`string`?{text:t,images:[]}:Array.isArray(t)?{text:zJ(e),images:t.map(BJ).filter(Boolean)}:{text:``,images:[]})}function UJ(e,t){if(!e||typeof e!=`object`)return null;let n=e;return typeof n.tokensBefore!=`number`||typeof n.estimatedTokensAfter!=`number`?null:{reason:t,tokensBefore:n.tokensBefore,estimatedTokensAfter:n.estimatedTokensAfter}}function WJ(e,t,n,r){let i=new Set(t),a=new Set(e.filter(e=>e.role===`user`).map(HJ)),o=[...e];for(let e=0;e<n.length;e++){let t=r[e];if(t!==void 0)i.has(t)||o.push(n[e]);else{let t=n[e];(t.role!==`user`||!a.has(HJ(t)))&&o.push(t)}}return o}function GJ(e){let{session:t,newSessionCwd:n,onAgentEnd:r,onAgentSettled:i,onAgentError:a,onSessionCreated:o,onSessionForked:s,modelsRefreshKey:c}=e,l=t===null&&n!==null,[u,f]=(0,d.useState)(null),[p,m]=(0,d.useState)(!l),[h,g]=(0,d.useState)(null),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)([]),x=(0,d.useRef)(null);x.current||=VJ(b);let S=x.current,[C,w]=(0,d.useState)([]),[T,E]=(0,d.useReducer)(uJ,{isStreaming:!1,streamingMessage:null}),D=(0,d.useRef)(null),O=(0,d.useRef)(null),k=(0,d.useRef)(null),A=(0,d.useRef)(new Map),j=(0,d.useRef)(rJ()),M=(0,d.useRef)(!0),P=(0,d.useRef)([]),ee=(0,d.useRef)(new Map),F=(0,d.useRef)(null),te=(0,d.useRef)(null),ne=(0,d.useCallback)(()=>{let e=A.current;if(e.size===0)return;let t=k.current;if(!t){e.clear();return}let n=t.content;if(!Array.isArray(n)){e.clear();return}for(let[t,r]of e){let e=r.join(``),i=n[t];if(!i)continue;let a=j.current.take(t,e);a&&(i.type===`thinking`?i.thinking=(i.thinking??``)+a:i.type===`text`?i.text=(i.text??``)+a:i.type===`toolCall`&&(i.streamingOutput=(i.streamingOutput??``)+a))}e.clear()},[]),re=(0,d.useCallback)(()=>{O.current&&=(clearTimeout(O.current),null),ne();let e=D.current;if(D.current=null,e&&Ye.current){let t=e,n={...e,content:[...t.content??[]]};(0,d.startTransition)(()=>E({type:`update`,message:n}))}else if(k.current&&Ye.current){let e=k.current,t={...e,content:[...e.content??[]]};(0,d.startTransition)(()=>E({type:`update`,message:t}))}},[ne]);(0,d.useEffect)(()=>()=>{O.current&&=(clearTimeout(O.current),null),F.current&&=(clearTimeout(F.current),null),te.current&&=(clearTimeout(te.current),null)},[]);let[ie,ae]=(0,d.useState)(!1),[oe,I]=(0,d.useState)(!1),L=(0,d.useCallback)(e=>{Ye.current=e,ae(e)},[]),se=(0,d.useCallback)(e=>{$e.current=e,I(e)},[]),[R,ce]=(0,d.useState)(``),[le,ue]=(0,d.useState)(null),[de,fe]=(0,d.useState)(null),[pe,me]=(0,d.useState)(null),[he,ge]=(0,d.useState)(null),[_e,ve]=(0,d.useState)(null),[ye,xe]=(0,d.useState)(!1),[Se,Ce]=(0,d.useState)(null),[we,Te]=(0,d.useState)(null),[De,Oe]=(0,d.useState)(null),[ke,Ae]=(0,d.useState)([]),[je,Me]=(0,d.useState)(!1),{noticeState:Ne,addNotice:Pe,dismissModal:Fe}=FJ(),{t:Ie}=N(),[Le,Re]=(0,d.useState)({steering:[],followUp:[]}),[ze,Be]=(0,d.useState)(!1),Ve=(0,d.useRef)(null),He=(0,d.useRef)(null),Ue=(0,d.useRef)(null),We=(0,d.useRef)(null),Ge=(0,d.useRef)(null),Ke=(0,d.useRef)(0),qe=(0,d.useRef)(!1),Je=(0,d.useRef)(t?.id??null),Ye=(0,d.useRef)(!1),Xe=(0,d.useRef)(!1),Ze=(0,d.useRef)(!1),Qe=(0,d.useRef)(-1),$e=(0,d.useRef)(!1),et=(0,d.useRef)(0),tt=(0,d.useRef)(null),nt=(0,d.useRef)(!1),rt=(0,d.useRef)(null),it=(0,d.useRef)(!1),at=(0,d.useRef)(!0),ot=(0,d.useRef)(void 0),st=(0,d.useRef)(0),ct=(0,d.useRef)(0),lt=(0,d.useRef)(null),ut=(0,d.useRef)(null),dt=(0,d.useRef)(null),ft=(0,d.useRef)(!1),pt=(0,d.useRef)(0),mt=(0,d.useRef)(!1),{modelNames:ht,modelList:gt,modelError:_t,modelScopeWarnings:vt,modelThinkingLevels:yt,modelThinkingLevelMaps:bt,newSessionModel:xt,newSessionDefaultModel:St,toolPreset:Ct,thinkingLevel:wt,currentModelOverride:Tt,pendingModel:Et,setThinkingLevel:Dt,setPendingModel:Ot,setNewSessionDefaultModel:kt,setCurrentModelOverride:At,setModelError:jt,setToolPresetState:Mt,newSessionModelOverrideRef:Nt,thinkingLevelOverrideRef:Pt,loadModels:It,handleModelChange:Lt,handleThinkingLevelChange:Rt,handleToolPresetChange:zt}=LJ({isNew:l,sessionIdRef:Je,ensuringNewSessionRef:dt,setToolPresetOverride:e.setToolPreset}),{extensionDialog:Bt,extensionCustomUi:Vt,extensionStatuses:Ht,extensionWidgets:Ut,setExtensionStatuses:Wt,setExtensionWidgets:Gt,respondToExtensionUi:Kt,sendExtensionCustomInput:qt,handleExtensionUiRequest:Jt}=RJ({addNotice:Pe,chatInputRef:e.chatInputRef,sessionIdRef:Je}),Yt=(0,d.useCallback)(e=>{e?.contextUsage!==void 0&&me(e.contextUsage??null),e?.systemPrompt!==void 0&&ge(e.systemPrompt??null),e?.thinkingLevel!==void 0&&Dt(e.thinkingLevel??`auto`),e?.extensionStatuses!==void 0&&Wt(e.extensionStatuses??[]),e?.extensionWidgets!==void 0&&Gt(e.extensionWidgets??[]),e?.queuedMessages!==void 0&&Re(fJ(e.queuedMessages))},[Dt,Wt,Gt]),Xt=Tt??u?.context.model??Et??null,Zt=l?xt??St:Xt,Qt=(0,d.useSyncExternalStore)(Ee.subscribe,()=>Ee.get()??null,()=>null);(0,d.useEffect)(()=>{Ee.load().catch(()=>{})},[]);let $t=(0,d.useRef)(null);(0,d.useEffect)(()=>{if(!Zt||!Qt||Object.keys(yt).length===0)return;let e=Yq(Qt,Zt.provider,Zt.modelId),t=`${Zt.provider}/${Zt.modelId}`;if($t.current&&$t.current.key!==t&&($t.current=null),!e||$t.current)return;let n=yt[t],r=!n||n.includes(e),i;if(r)i=e;else if(e===`auto`||!n||n.length===0)i=`auto`;else{i=xi(e,n);let t=Ee.get()??{},r=Zq(t,Zt.provider,Zt.modelId,i);JSON.stringify(r)!==JSON.stringify(t)&&Ee.load().catch(()=>{}).then(async()=>{try{await fetch(`/api/model-thinking`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(r)}),await Ee.refresh()}catch{}})}if(i!==wt&&(Dt(i),l&&!Je.current&&(Pt.current=i===`auto`?null:i),i!==`auto`&&Je.current)){let e=Je.current;US(e,{type:`set_thinking_level`,level:i}).catch(()=>{})}},[Zt?.provider,Zt?.modelId,Qt,yt,wt,l]);let en=(0,d.useCallback)(async e=>{if(Zt&&($t.current={key:`${Zt.provider}/${Zt.modelId}`,level:e}),await Rt(e),!Zt)return;try{await Ee.load()}catch{}let t=Ee.get()??{},n=Zq(t,Zt.provider,Zt.modelId,e);if(JSON.stringify(n)!==JSON.stringify(t))try{await fetch(`/api/model-thinking`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}),await Ee.refresh()}catch{}},[Rt,Zt]),{sessionStats:tn,setSessionStatsOverride:nn}=IJ({messages:y,contextUsage:pe,data:u,session:t,sessionIdRef:Je}),rn=(0,d.useCallback)(async(e,t=!1,n=!1)=>{let r=!1;try{t&&m(!0);let i=new URLSearchParams({deferMedia:`1`}),a=await fetch(`/api/sessions/${encodeURIComponent(e)}?${i}`);if(a.status===404)return t&&(f(null),v(null),S.apply(`loadSession:notFound`,[]),g(null)),null;if(!a.ok)throw Error(`HTTP ${a.status}`);let o=await a.json();if(Je.current!==e)return null;if(f(o),v(o.leafId),mt.current){let e=o.context.entryIds??[];S.apply(`loadSession:keepOptimistic`,t=>WJ(o.context.messages,e,t,C)),w(e)}else S.replaceAll(`loadSession`,o.context.messages),w(o.context.entryIds??[]);if(At(null),g(null),o.context.thinkingLevel&&o.context.thinkingLevel!==`off`&&Dt(o.context.thinkingLevel),r=!0,t&&m(!1),!n)return null;try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/state`);if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();if(Je.current!==e)return null;let r=n.state;return r?Yt(r):n.running||Re({steering:[],followUp:[]}),n}catch(e){return console.error(`Failed to load agent state:`,e),null}}catch(e){return g(String(e)),null}finally{t&&!r&&m(!1)}},[Yt,Dt,At,S,C]),an=(0,d.useCallback)(async(e,t,n=!1)=>{try{let r=new URLSearchParams({deferMedia:`1`});t&&r.set(`leafId`,t);let i=`/api/sessions/${encodeURIComponent(e)}/context?${r}`,a=await fetch(i);if(!a.ok)throw Error(`HTTP ${a.status}`);let o=await a.json(),s=o.context.entryIds??[];S.apply(`loadContext merge=${n}`,e=>n?WJ(o.context.messages,s,e,C):o.context.messages),w(s)}catch(e){console.error(`Failed to load context:`,e)}},[C,S]),on=(0,d.useCallback)(async e=>{try{let t=await US(e,{type:`get_tools`});t&&Mt(cJ(t))}catch(e){console.error(`Failed to load tools:`,e)}},[Mt]),sn=(0,d.useCallback)((e=0,t=`(no messages)`)=>{let r=Je.current;!l||!n||!r||ft.current||(ft.current=!0,o?.({id:r,path:``,cwd:n,name:void 0,created:new Date().toISOString(),modified:new Date().toISOString(),messageCount:e,firstMessage:t}))},[l,n,o]),cn=(0,d.useCallback)(async()=>{if(Je.current||!l||!n)return Je.current;if(dt.current)return dt.current;let e=(async()=>{let e=Nt.current,t=Pt.current;e&&Ot(e);let r=lJ(Ct),i=await fetch(`/api/agent/new`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:n,type:`ensure_session`,toolNames:r,...e?{provider:e.provider,modelId:e.modelId}:{},...t?{thinkingLevel:t}:{}})});if(!i.ok)throw Error(`HTTP ${i.status}`);let a=await i.json(),o=a.sessionId;return Je.current=o,a.model&&Nt.current===e&&(Ot(a.model),e||kt(a.model)),a.thinkingLevel&&Pt.current===t&&Dt(a.thinkingLevel),o})();dt.current=e;try{return await e}finally{dt.current=null}},[l,n,Ct,Pt,Nt,Ot,Dt,kt]),ln=(0,d.useCallback)(async()=>{let e=Je.current??await cn();if(!e)return Ae([]),[];Me(!0);try{let t=(await US(e,{type:`get_commands`}))?.commands??[];return Ae(t),t}catch(e){return console.error(`Failed to load slash commands:`,e),Ae([]),[]}finally{Me(!1)}},[cn]),un=(0,d.useCallback)(()=>{Ke.current+=1,qe.current=!1,Ge.current&&=(clearTimeout(Ge.current),null)},[]),dn=(0,d.useCallback)(()=>{Ve.current?.(),Ve.current=null,Ue.current=null,We.current=null},[]),fn=(0,d.useCallback)(e=>{dn();let t=`agent:${e}`,n=!1,r=null,i,a={key:t,promise:null,pending:!0},o=e=>{n||(n=!0,r&&clearTimeout(r),We.current===a&&(a.pending=!1),i({status:e}))};r=setTimeout(()=>o(`timeout`),wJ);let s=new Promise(e=>{i=e});return a.promise=s,Ve.current=Ft({ch:`agent`,sessionId:e},e=>{e.type===`connected`?o(`connected`):(e.type===`not_found`||e.type===`start_failed`)&&o(`closed`)}),Ue.current=e,We.current=a,s},[dn]),pn=(0,d.useCallback)(async e=>{if(Ue.current===e&&Ve.current){let e=We.current;if(e?.pending){let t=await e.promise;if(t.status===`connected`)return;throw dn(),new kJ(t.status)}return}let t=await fn(e);if(t.status!==`connected`)throw dn(),new kJ(t.status)},[dn,fn]),mn=(0,d.useCallback)(()=>{let e=Ye.current;return Ye.current=!1,ae(!1),Oe(null),fe(null),E({type:`end`}),e},[]),hn=(0,d.useCallback)(e=>Qe.current!==e&&(Qe.current=e,r?.(),!0),[r]),gn=(0,d.useCallback)(e=>{un(),qe.current=!0;let t=Ke.current,n=async()=>{if(!(t!==Ke.current||Je.current!==e||!qe.current))try{let r=await fetch(`/api/agent/${encodeURIComponent(e)}`);if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.json();if(t!==Ke.current||Je.current!==e||!qe.current)return;let a=i.state;if(i.running&&a&&(a.isStreaming||a.isPromptRunning)){qe.current=!1,Ge.current=null,Xe.current=!!a?.isStreaming,Ze.current=!!a?.isPromptRunning,L(!0),Oe(a?.isStreaming?{kind:`waiting_model`}:{kind:`running_command`});return}if(i.running&&a?.isCompacting){xe(!0),Ge.current=setTimeout(()=>void n(),_J);return}qe.current=!1,Ge.current=null,dn()}catch{if(t!==Ke.current||Je.current!==e||!qe.current)return;Ge.current=setTimeout(()=>void n(),_J)}};Ge.current=setTimeout(()=>void n(),yJ)},[un,dn]),_n=(0,d.useCallback)(async(e=Je.current,t=pt.current)=>{if(pt.current===t)try{e&&await rn(e)}catch(e){if(pt.current!==t)return;throw e}finally{if(pt.current===t){let n=Ze.current,a=Xe.current;Ze.current=!1,Xe.current=!1,mt.current=!1;let o=mn();n?(hn(t),o&&i?.()):a&&o&&(r?.(),i?.()),e&&gn(e)}}},[rn,hn,r,i,gn,mn]),vn=(0,d.useCallback)(async(e,t)=>{await jJ(gJ);let n=Date.now();for(;Ye.current&&Date.now()-n<vJ;){if(t!==void 0&&pt.current!==t)return;try{let n=await fetch(`/api/agent/${encodeURIComponent(e)}`);if(n.ok){let r=await n.json(),i=r.state;if(!r.running||!i||!i.isStreaming&&!i.isPromptRunning){await _n(e,t);return}}}catch{}await jJ(_J)}},[_n]),yn=(0,d.useCallback)(async e=>{let t=et.current+1;for(et.current=t;$e.current&&et.current===t&&Je.current===e;){await jJ(CJ);try{let n=await fetch(`/api/agent/${encodeURIComponent(e)}`);if(!n.ok||(await n.json()).state?.isBashRunning)continue;if(await rn(e),et.current!==t||Je.current!==e)return;se(!1),ue(null);return}catch{}}},[rn]),bn=(0,d.useCallback)(async e=>{if(!Ye.current)return;let t=pt.current;try{let n=await fetch(`/api/agent/${encodeURIComponent(e)}`);if(!n.ok)return;let r=await n.json();if(pt.current!==t)return;let i=r.state;if(xe(i?.isCompacting??!1),Re(fJ(i?.queuedMessages)),r.running&&i&&(i.isStreaming||i.isPromptRunning||i.isCompacting)||!Ye.current)return;i&&Yt(i),await _n(e,t)}catch{}},[Yt,_n]);(0,d.useEffect)(()=>{if(!ie)return;let e=()=>{let e=Je.current;e&&bn(e)},t=()=>{document.visibilityState===`visible`&&e()},n=setInterval(e,SJ);return document.addEventListener(`visibilitychange`,t),window.addEventListener(`online`,e),()=>{clearInterval(n),document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`online`,e)}},[ie,bn]),(0,d.useEffect)(()=>{Ye.current=ie},[ie]),tt.current=(0,d.useCallback)(e=>{let t=e=>{let t=e.assistantMessageEvent;if(!t||typeof t.type!=`string`)return;let n=k.current;if(!n)return;let r=t.contentIndex;if(typeof r!=`number`)return;let i=n.content;if(Array.isArray(i))switch(t.type){case`thinking_start`:{if(i[r]?.type===`thinking`)break;let e={type:`thinking`,thinking:``};r>=i.length?i.push(e):i.splice(r,0,e),M.current=!0;break}case`thinking_delta`:if(i[r]?.type===`thinking`&&typeof t.delta==`string`){let e=A.current,n=e.get(r)??[];n.push(t.delta),e.set(r,n)}break;case`thinking_end`:{let e=A.current;if(e.has(r)){let t=e.get(r);e.delete(r);let n=t.join(``),a=j.current.take(r,n),o=i[r];o?.type===`thinking`&&a&&(o.thinking=(o.thinking??``)+a)}let n=i[r];if(n?.type===`thinking`&&typeof t.content==`string`&&(n.thinking=t.content),n?.type===`thinking`){let e=t.thinkingSignature??t.signature;typeof e==`string`&&e.length>0?n.thinkingSignature=e:e&&typeof e==`object`&&(n.thinkingSignature=JSON.stringify(e)),t.redacted===!0&&(n.redacted=!0);let i=t.partial?.content?.[r];i&&typeof i.thinkingSignature==`string`&&!n.thinkingSignature&&(n.thinkingSignature=i.thinkingSignature),i&&i.redacted===!0&&(n.redacted=!0)}break}case`text_start`:{if(i[r]?.type===`text`)break;let e={type:`text`,text:``};r>=i.length?i.push(e):i.splice(r,0,e),M.current=!0;break}case`text_delta`:if(i[r]?.type===`text`&&typeof t.delta==`string`){let e=A.current,n=e.get(r)??[];n.push(t.delta),e.set(r,n)}break;case`text_end`:{let e=A.current;if(e.has(r)){let t=e.get(r);e.delete(r);let n=t.join(``),a=j.current.take(r,n),o=i[r];o?.type===`text`&&a&&(o.text=(o.text??``)+a)}let n=i[r];n?.type===`text`&&typeof t.content==`string`&&(n.text=t.content);break}case`toolcall_start`:break;case`toolcall_delta`:if(i[r]?.type===`toolCall`&&typeof t.delta==`string`){let e=A.current,n=e.get(r)??[];n.push(t.delta),e.set(r,n)}break;case`toolcall_end`:{let e=A.current;e.has(r)&&e.delete(r),t.toolCall&&typeof t.toolCall==`object`&&(i[r]={type:`toolCall`,...t.toolCall});break}}},n=()=>{if(O.current)return;let e=M.current?xJ:bJ;O.current=setTimeout(()=>{O.current=null,ne();let e=k.current??D.current;if(D.current=null,!e||!Ye.current)return;let t=e.content;if(!(Array.isArray(t)&&t.some(e=>{let t=e.type;return t===`thinking`?!!((e.thinking?.trim()??``)!==``||typeof e.thinkingSignature==`string`&&e.thinkingSignature.length>0||e.redacted):t!==`text`||(e.text?.trim()??``)!==``})))return;M.current=!1;let n={...e,content:[...t??[]]};(0,d.startTransition)(()=>E({type:`update`,message:n}))},e)},o=()=>{if(!Ye.current)return;let r=e.message;if(r&&r.role!==`user`){A.current.clear();let e=tJ(r);j.current.snapshot(e.content),k.current=e,D.current=e,M.current=!0,n()}else k.current&&(t(e),n())};switch(e.type){case`agent_start`:A.current.clear(),k.current=null,D.current=null,M.current=!0,j.current.reset(),un(),Xe.current=!0,L(!0),Oe({kind:`waiting_model`}),fe(null),E({type:`start`});break;case`agent_end`:if(!Ye.current)break;if(Oe(null),fe(null),E({type:`end`}),k.current=null,D.current=null,A.current.clear(),j.current.reset(),O.current&&=(clearTimeout(O.current),null),F.current&&=(clearTimeout(F.current),null),P.current.length){let e=P.current.join(``);P.current=[],e&&ce(t=>t+e)}if(te.current&&=(clearTimeout(te.current),null),ee.current.size){let e=new Map(ee.current);ee.current.clear(),S.apply(`tool_execution_update:batched:drain`,t=>t.map(t=>{if(!(`content`in t)||!Array.isArray(t.content))return t;let n=!1,r=t.content.map(t=>{if(t.type===`toolCall`){let r=e.get(t.toolCallId??``);if(r!==void 0)return n=!0,{...t,streamingOutput:r}}return t});return n?{...t,content:r}:t}))}Je.current&&(rn(Je.current),fetch(`/api/agent/${encodeURIComponent(Je.current)}`).then(e=>e.json()).then(e=>{e.state&&Yt(e.state),Re(fJ(e.state?.queuedMessages))}).catch(()=>{}));break;case`agent_settled`:{let e=Xe.current;if(Xe.current=!1,!e||Ze.current)break;let t=Je.current,n=mn();xe(!1),t&&(rn(t),gn(t)),k.current=null,D.current=null,A.current.clear(),O.current&&=(clearTimeout(O.current),null),n&&(r?.(),i?.());break}case`prompt_done`:{let e=pt.current,t=Ze.current;Ze.current=!1,mt.current=!1;let n=hn(e);if(!t&&!n)break;let a=Je.current;if(a&&rn(a),!Xe.current){let e=mn();a&&gn(a),e&&(r?.(),i?.())}}break;case`prompt_error`:Pe({type:`error`,message:e.errorMessage??Ie(`i18n.commandFailed`)}),a?.(e.errorMessage??Ie(`i18n.commandFailed`));break;case`extension_error`:Pe({type:`error`,message:e.error??Ie(`i18n.extensionCommandFailed`)}),a?.(e.error??Ie(`i18n.extensionCommandFailed`));break;case`message_start`:o();break;case`message_update`:o(),e.assistantMessageEvent?.type?.startsWith(`thinking`)?Oe({kind:`thinking`}):Oe(null);break;case`message_end`:{if(!Ye.current)break;re();let t=e.message;if(t&&t.role===`user`){let e=eJ(t),n=HJ(e),r=mt.current;mt.current=!1,S.apply(`message_end:userEcho`,t=>{let i=t[t.length-1];return i?.role===`user`&&HJ(i)===n?t:r&&i?.role===`user`?[...t.slice(0,-1),e]:[...t,e]})}else t&&S.append(`message_end:assistant`,eJ(t));E({type:`reset`}),k.current=null,D.current=null,A.current.clear(),O.current&&=(clearTimeout(O.current),null),Oe({kind:`waiting_model`});break}case`tool_execution_start`:{let t=e.toolCallId,n=e.toolName;Oe(e=>{let r=e?.kind===`running_tools`?[...e.tools]:[];return r.some(e=>e.id===t)||r.push({id:t,name:n}),{kind:`running_tools`,tools:r}});break}case`tool_execution_update`:{let t=e.toolCallId,n=dJ(e.partialResult);if(n===void 0)break;ee.current.set(t,n),te.current||=setTimeout(()=>{te.current=null;let e=new Map(ee.current);ee.current.clear(),e.size!==0&&(0,d.startTransition)(()=>{S.apply(`tool_execution_update:batched`,t=>t.map(t=>{if(!(`content`in t)||!Array.isArray(t.content))return t;let n=!1,r=t.content.map(t=>{if(t.type===`toolCall`){let r=e.get(t.toolCallId??``);if(r!==void 0)return n=!0,{...t,streamingOutput:r}}return t});return n?{...t,content:r}:t}))})},bJ);break}case`tool_execution_end`:{let t=e.toolCallId;Oe(e=>{if(e?.kind!==`running_tools`)return e;let n=e.tools.filter(e=>e.id!==t);return n.length===0?{kind:`waiting_model`}:{kind:`running_tools`,tools:n}});break}case`bash_execution_update`:{let t=e.delta;if(!t)break;P.current.push(t),F.current||=setTimeout(()=>{F.current=null;let e=P.current;if(P.current=[],e.length===0)return;let t=e.join(``);t&&(0,d.startTransition)(()=>ce(e=>e+t))},bJ);break}case`queue_update`:Re({steering:[...e.steering??[]],followUp:[...e.followUp??[]]});break;case`auto_retry_start`:fe({attempt:e.attempt,maxAttempts:e.maxAttempts,errorMessage:e.errorMessage});break;case`auto_retry_end`:fe(null);break;case`auto_compaction_start`:case`compaction_start`:xe(!0),Ce(null),Te(null);break;case`auto_compaction_end`:case`compaction_end`:xe(!1),e.errorMessage?(Ce(e.errorMessage),Te(null)):e.aborted||(Te(UJ(e.result,e.reason??`auto`)),Je.current&&rn(Je.current));break;case`extension_ui_request`:Jt(e)}},[Pe,un,Jt,rn,hn,r,i,a,gn,mn,Ie,re,Yt,S]);let xn=(0,d.useRef)(Jt);xn.current=Jt,(0,d.useEffect)(()=>(He.current?.(),He.current=Ft({ch:`global`},e=>{if(e.type===`extension_ui_request`&&(Rq(`ui-chain`,`4a ws recv ${e.method}`,`id=${String(e.id).slice(0,8)} evtSid=${String(e.sessionId).slice(0,8)} activeSid=${Je.current?.slice(0,8)??`null`}`),e.sessionId&&e.sessionId!==Je.current&&Bq.has(e.method??``)&&Wq(e.sessionId)),e.sessionId===Je.current){if(e.type===`extension_ui_request`){xn.current?.(e);return}tt.current?.(e)}}),()=>{He.current?.(),He.current=null}),[]);let Sn=(0,d.useCallback)(async(r,i)=>{let a=r.trim();if(!a&&!i?.length||Ye.current||$e.current)return;let o=!i?.length&&a.startsWith(`/`);if(!i?.length&&a.startsWith(`!`)){let e=a.startsWith(`!!`),t=(e?a.slice(2):a.slice(1)).trim();if(!t)return;await ot.current?.(t,e);return}Rq(`ui-chain`,`1 client send`,JSON.stringify(a.slice(0,80)));let s=pt.current+1;un(),Ze.current=!0;let c=i?.map(e=>({type:`image`,source:{type:`base64`,media_type:e.mimeType,data:e.data}})),u={role:`user`,content:c?.length?[...r.trim()?[{type:`text`,text:r}]:[],...c]:r,timestamp:Date.now()};S.append(`handleSend:optimistic`,u),mt.current=!0,pt.current=s,L(!0),Oe(o?{kind:`running_command`}:{kind:`waiting_model`}),E({type:`start`}),it.current=!0,at.current=!0;let d=i?.map(e=>({type:`image`,data:e.data,mimeType:e.mimeType})),f=null,p=!1;try{if(l&&n){let e=xt,t=Je.current??await dt.current,n=t??await cn();n&&(f=n,e&&(Ot(e),t&&await US(n,{type:`set_model`,provider:e.provider,modelId:e.modelId})),await pn(n),p=!0,sn(1,r),await US(n,{type:`prompt`,message:r,...d?.length?{images:d}:{}}))}else if(t){f=t.id,await pn(t.id),p=!0;let e=Tt;await US(t.id,{type:`prompt`,message:r,...d?.length?{images:d}:{},...e?{provider:e.provider,modelId:e.modelId}:{}})}o&&f&&vn(f,s)}catch(t){if(console.error(`Failed to send message:`,t),p&&f){t instanceof kJ||Pe({type:`error`,message:t instanceof Error?t.message:String(t)}),vn(f,s);return}Ze.current=!1,Ye.current=!1,dn(),t instanceof kJ&&(mt.current&&(mt.current=!1,S.dropLastIf(`sendError:rollbackOptimistic`,e=>e?.role===`user`)),Pe({type:`error`,message:t.message}),r&&e.chatInputRef?.current?.insertIfEmpty(r)),mt.current=!1,L(!1),Oe(null),E({type:`end`})}},[l,n,xt,t,cn,pn,sn,Tt,vn,Pe,un,dn,e.chatInputRef,Ot,S]);ot.current=(0,d.useCallback)(async(n,r)=>{if(Ye.current||$e.current)return;let i=`${r?`!!`:`!`}${n}`;se(!0),ue({command:n,excludeFromContext:r}),ce(``);try{let e=Je.current??t?.id??await cn();if(!e)throw Error(`Unable to create a session for the shell command`);await pn(e),sn(1,i),await US(e,{type:`bash`,command:n,excludeFromContext:r}),await rn(e)}catch(t){console.error(`Failed to execute shell command:`,t),Pe({type:`error`,message:t instanceof Error?t.message:String(t)}),e.chatInputRef?.current?.insertIfEmpty(i)}finally{se(!1),ue(null)}},[Pe,pn,cn,rn,e.chatInputRef,sn,t]);let Cn=(0,d.useCallback)(async()=>{let e=Je.current;if(e){if($e.current){try{await US(e,{type:`abort_bash`})}catch(e){console.error(`Failed to abort bash:`,e)}return}try{await US(e,{type:`abort`})}catch(e){console.error(`Failed to abort:`,e)}}},[]),wn=(0,d.useCallback)(async e=>{if($e.current)return;let t=Je.current;if(t){ve(e);try{let{cancelled:n,newSessionId:r}=await US(t,{type:`fork`,entryId:e})??{};!n&&r&&s?.(r)}catch(e){console.error(`Fork failed:`,e)}finally{ve(null)}}},[s]),Tn=(0,d.useCallback)(async e=>{if($e.current)return;let t=Je.current;t&&(US(t,{type:`navigate_tree`,targetId:e}).catch(()=>{}),v(e),await an(t,e))},[an]),En=(0,d.useCallback)(async e=>{if($e.current)return;v(e);let t=Je.current;t&&(await an(t,e),e&&US(t,{type:`navigate_tree`,targetId:e}).catch(()=>{}))},[an]),Dn=(0,d.useCallback)(async()=>{let e=Je.current;if(!(!e||ye)){xe(!0),Ce(null),Te(null);try{let t=await US(e,{type:`compact`});Te(UJ(t,`manual`)),await rn(e,!0)}catch(e){Ce(e instanceof Error?e.message:String(e)),Te(null)}finally{xe(!1)}}},[ye,rn]),On=(0,d.useCallback)(async e=>{if(!e.startsWith(`/`))return{handled:!1};let t=e.match(/^\/([^\s]+)(?:\s+([\s\S]*))?$/);if(!t)return{handled:!1};let[,n,r=``]=t,i=r.trim(),a=Je.current??await cn(),o=e=>(e.handled&&(e.error?Pe({type:`error`,message:e.error}):e.action!==`openSessionStats`&&Pe({type:`success`,message:e.message??Ie(`i18n.commandCompleted`)})),e);try{switch(Be(!0),n){case`compact`:{if(!a||ye)return o({handled:!0,error:Ie(`i18n.noActiveSessionToCompact`)});xe(!0),Ce(null),Te(null);let e=await US(a,{type:`compact`,...i?{customInstructions:i}:{}});return Te(UJ(e,`manual`)),await rn(a,!0)&&sn(),o({handled:!0,message:Ie(`i18n.compactedContext`)})}case`reload`:return a?(await US(a,{type:`reload`}),await be.refresh(),await Promise.all([rn(a,!1,!0),on(a),ln(),It()]),o({handled:!0,message:Ie(`i18n.reloadedSessionResources`)})):o({handled:!0,error:Ie(`i18n.noActiveSessionToReload`)});case`name`:return a?i?(await US(a,{type:`set_session_name`,name:i}),await rn(a)&&sn(),o({handled:!0,message:Ie(`i18n.sessionRenamedTo`,{name:i})})):o({handled:!0,error:Ie(`i18n.usageName`)}):o({handled:!0,error:Ie(`i18n.noActiveSessionToName`)});case`session`:{if(!a)return o({handled:!0,error:Ie(`i18n.noActiveSession`)});let e=await US(a,{type:`get_session_stats`});return e&&nn(e),o({handled:!0,action:`openSessionStats`})}case`copy`:{if(!a)return o({handled:!0,error:Ie(`i18n.noActiveSession`)});let e=(await US(a,{type:`get_last_assistant_text`}))?.text??``;return e?(await navigator.clipboard.writeText(e),o({handled:!0,message:Ie(`i18n.copiedLastAssistantMessage`)})):o({handled:!0,error:Ie(`i18n.noAssistantMessageToCopy`)})}default:return{handled:!1}}}catch(e){return o({handled:!0,error:e instanceof Error?e.message:String(e)})}finally{Be(!1),n===`compact`&&xe(!1)}},[Pe,cn,ye,It,rn,ln,on,sn,nn,Ie]),kn=(0,d.useCallback)(async(e,t,n)=>{let r=Je.current;if(!r)return;let i=t?.map(e=>({type:`image`,data:e.data,mimeType:e.mimeType}));try{await US(r,{...e,...i?.length?{images:i}:{}})}catch(e){console.error(`Failed to ${n}:`,e),Pe({type:`error`,message:e instanceof Error?e.message:String(e)})}},[Pe]),An=(0,d.useCallback)((e,t)=>kn({type:`steer`,message:e},t,`steer`),[kn]),jn=(0,d.useCallback)((e,t,n)=>kn({type:`prompt`,message:e,streamingBehavior:t},n,`queue prompt`),[kn]),Mn=(0,d.useCallback)((e,t)=>kn({type:`follow_up`,message:e},t,`follow up`),[kn]),Nn=(0,d.useCallback)(async()=>{let e=Je.current;if(e)try{await US(e,{type:`abort_compaction`})}catch(e){console.error(`Failed to abort compaction:`,e)}},[]),Pn=(0,d.useCallback)(async()=>{let t=Je.current;if(t)try{let n=await US(t,{type:`clear_queue`});Re({steering:[],followUp:[]});let r=[...n?.steering??[],...n?.followUp??[]];r.length>0&&e.chatInputRef?.current?.prependText(r.join(`
|
|
352
352
|
|
|
353
|
-
`))}catch(e){console.error(`Failed to recall queued messages:`,e),Ne({type:`error`,message:Fe(`i18n.failedToRecallQueuedMessages`)})}},[e.chatInputRef,Ne,Fe]),Pn=(0,d.useCallback)((e=`smooth`)=>{st.current=Date.now()+dJ,ct.current?.scrollIntoView({behavior:e})},[]),Fn=(0,d.useCallback)(()=>{let e=lt.current,t=nt.current;if(!e||!t)return;let n=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;st.current=Date.now()+dJ,e.scrollTo({top:n-16,behavior:`smooth`})},[]),In=(0,d.useCallback)(e=>{e instanceof KeyboardEvent&&(!EJ.has(e.key)||e.target instanceof Element&&e.target.closest(`input, textarea, [contenteditable='true']`))||(ot.current=Date.now()+fJ)},[]),Ln=(0,d.useCallback)(()=>{if(Date.now()<st.current)return;let e=lt.current;if(e){if(e.scrollHeight-e.scrollTop-e.clientHeight<pJ){it.current=!0;return}Je.current&&(Date.now()>ot.current||(it.current=!1))}},[]);return(0,d.useEffect)(()=>(t?(qe.current=t.id,nn(t.id,!0,!1).then(()=>dn(t.id)).then(()=>nn(t.id,!1,!0)).then(e=>{e?.running&&(an(t.id),(e.state?.isStreaming||e.state?.isPromptRunning)&&(Ye.current=!!e.state.isStreaming,Xe.current=!!e.state.isPromptRunning,I(!0),De(e.state.isStreaming?{kind:`waiting_model`}:{kind:`running_command`}),E({type:`start`}),!e.state.isStreaming&&e.state.isPromptRunning&&_n(t.id)),e.state?.isBashRunning&&(L(!0),vn(t.id))),e?.state&&(e.state.isCompacting!==void 0&&ye(e.state.isCompacting),Jt(e.state))})):l&&n&&sn().then(async e=>{if(e){qe.current=e,await dn(e);try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/state`);if(!t.ok)return;let n=await t.json();qe.current===e&&Jt(n.state)}catch{}}}),()=>{$e.current+=1,ln(),un()}),[]),(0,d.useEffect)(()=>(window.addEventListener(`keydown`,In),window.addEventListener(`pointerdown`,In,{passive:!0}),()=>{window.removeEventListener(`keydown`,In),window.removeEventListener(`pointerdown`,In)}),[In]),(0,d.useEffect)(()=>{let e=lt.current;if(e)return e.addEventListener(`wheel`,In,{passive:!0}),e.addEventListener(`touchstart`,In,{passive:!0}),e.addEventListener(`scroll`,Ln,{passive:!0}),()=>{e.removeEventListener(`wheel`,In),e.removeEventListener(`touchstart`,In),e.removeEventListener(`scroll`,Ln)}},[y.length,p,Ln,In]),(0,d.useEffect)(()=>{if(y.length>0){if(rt.current)rt.current=!1,tt.current=!0,Fn();else if(!tt.current)tt.current=!0,Pn(`instant`);else if(it.current){let e=lt.current;e&&(e.scrollTop=e.scrollHeight)}}},[y.length,re,Pn,Fn]),(0,d.useLayoutEffect)(()=>{if(!it.current||!T.isStreaming)return;let e=lt.current;e&&(e.scrollTop=e.scrollHeight)},[T.isStreaming,T.streamingMessage]),(0,d.useEffect)(()=>{let e=new AbortController,t=()=>Pt(e.signal).catch(e=>{e instanceof DOMException&&e.name===`AbortError`||At(e instanceof Error?e.message:String(e))});return c===0?t():be.refresh().catch(()=>{}).then(t),()=>e.abort()},[Pt,c,At]),(0,d.useEffect)(()=>{if(!Ce)return;let e=setTimeout(()=>we(null),6e3);return()=>clearTimeout(e)},[Ce]),(0,d.useEffect)(()=>{tn(null)},[y.length,fe?.tokens,fe?.percent,fe?.contextWindow,tn]),{data:u,loading:p,error:h,activeLeafId:_,tree:u?.tree??[],messages:y,entryIds:C,streamState:T,agentRunning:re,modelNames:mt,modelList:ht,modelError:gt,modelScopeWarnings:_t,modelThinkingLevels:vt,modelThinkingLevelMaps:yt,newSessionModel:bt,toolPreset:St,thinkingLevel:Ct,retryInfo:ue,contextUsage:fe,systemPrompt:me,forkingEntryId:ge,isCompacting:ve,compactError:xe,compactResult:Ce,currentModel:Yt,displayModel:Xt,sessionStats:en,slashCommands:Oe,slashCommandsLoading:Ae,queuedMessages:Ie,notices:Me.visible,noticeModals:Me.modals,dismissNoticeModal:Pe,extensionDialog:zt,extensionCustomUi:Bt,extensionStatuses:Vt,extensionWidgets:Ht,respondToExtensionUi:Gt,sendExtensionCustomInput:Kt,isAutoModelSelection:l&&bt===null,agentPhase:Te,isNew:l,sessionIdRef:qe,loadContext:rn,messagesEndRef:ct,scrollContainerRef:lt,lastUserMsgRef:nt,pendingScrollToUserRef:rt,initialScrollDoneRef:tt,handleSend:xn,handleAbort:Sn,handleFork:Cn,handleNavigate:wn,handleLeafChange:Tn,handleModelChange:It,handleCompact:En,handleSteer:kn,handleFollowUp:jn,handlePromptWithStreamingBehavior:An,handleAbortCompaction:Mn,handleRecallQueue:Nn,handleBuiltinSlashCommand:Dn,handleToolPresetChange:Rt,handleThinkingLevelChange:$t,loadTools:an,loadSlashCommands:cn,setActiveLeafId:v,setData:f,setMessages:S,setSessionStatsOverride:tn,dispatch:E,setAgentRunning:ie,setForkingEntryId:_e,bashRunning:ae,bashOutput:se,pendingBash:ce,commandBusy:Re,handleAgentEventRef:et}}var WJ={background:`linear-gradient(90deg, var(--accent) 0%, var(--accent) 47%, var(--shine-highlight) 53%, var(--shine-highlight) 100%)`,backgroundSize:`200% 100%`,WebkitBackgroundClip:`text`,backgroundClip:`text`,color:`transparent`,animation:`pi-status-shine 1.5s linear infinite`},GJ={animation:`pi-status-icon-pulse 1.5s ease-in-out infinite`};function KJ(e,t){if(e?.kind===`running_tools`){let n=e.tools.map(e=>e.name);return n.length===0?t(`chat.runningTool`):n.length===1?t(`chat.runningNamedTool`,{name:n[0]}):n.length<=3?t(`chat.runningTools`,{names:n.join(`, `)}):t(`chat.runningToolsMore`,{names:n.slice(0,2).join(`, `),count:n.length-2})}return e?.kind===`thinking`?t(`chat.thinking`):e?.kind===`waiting_model`?t(`chat.waitingModel`):e?.kind===`running_command`?t(`chat.runningCommand`):e?.kind===`retrying`?t(`chat.retrying`,{attempt:e.attempt,max:e.maxAttempts}):null}function qJ(e){return e?.kind===`running_tools`?(0,E.jsx)(ti,{size:p.lg}):e?.kind===`running_command`?(0,E.jsx)(Jr,{size:p.lg}):e?.kind===`thinking`?(0,E.jsx)(Dr,{size:p.lg,fill:`currentColor`,style:{color:`var(--bulb-warning)`}}):e?.kind===`retrying`?(0,E.jsx)(Zr,{size:p.lg,style:{color:`var(--status-warning)`}}):(0,E.jsx)(Tr,{size:p.lg})}function JJ({phase:e,elapsed:t,totalElapsed:n}){let{t:r}=N(),i=KJ(e,r)??r(`chat.runningCommand`);return(0,E.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,style:{...WJ,minWidth:0,maxWidth:`100%`},children:[(0,E.jsx)(`span`,{className:`inline-flex flex-shrink-0`,style:GJ,children:qJ(e)}),(0,E.jsxs)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,minWidth:0},children:[i,t!=null&&(0,E.jsxs)(E.Fragment,{children:[` · `,t]}),n!=null&&(0,E.jsxs)(E.Fragment,{children:[` · `,r(`chat.totalElapsed`,{total:n})]})]})]})}function YJ({msg:e,onSend:t,onFillInput:n,testId:r}){let{t:i}=N(),a=()=>{if(e.allowAppend&&n){n(`${e.message} `);return}t(e.message)},o=`${e.allowAppend?i(`config.widgets.fillToChatInputTooltip`):i(`config.widgets.sendImmediatelyTooltip`)}${e.message}`;return(0,E.jsx)(oi,{label:o,children:(0,E.jsx)(PG,{label:e.label,title:o,onClick:a,testId:r})})}function XJ({messages:e,onSend:t,onFillInput:n,testIdPrefix:r=`quick-msg`,wrapperTestId:i=`quick-message-buttons`,center:a=!1}){return e.length===0?null:(0,E.jsx)(`div`,{"data-testid":i,style:{display:`flex`,flexWrap:`wrap`,gap:6,justifyContent:a?`center`:`flex-start`,paddingTop:8,borderTop:a?`1px solid var(--border)`:void 0},children:e.map((e,i)=>(0,E.jsx)(YJ,{msg:e,onSend:t,onFillInput:n,testId:`${r}-${i}`},i))})}function ZJ(e){let t=e.currentTime;[523.25,659.25].forEach((n,r)=>{let i=e.createOscillator(),a=e.createGain();i.connect(a),a.connect(e.destination),i.type=`sine`,i.frequency.value=n;let o=t+r*.18;a.gain.setValueAtTime(0,o),a.gain.linearRampToValueAtTime(.18,o+.02),a.gain.exponentialRampToValueAtTime(.001,o+.45),i.start(o),i.stop(o+.45)})}function QJ(){let[e,t]=(0,d.useState)(()=>{if(typeof window>`u`)return!0;let e=localStorage.getItem(`pi-sound-enabled`);return e===null||e===`true`}),n=(0,d.useRef)(e);(0,d.useEffect)(()=>{n.current=e},[e]);let r=(0,d.useRef)(null),i=(0,d.useCallback)(()=>{if(r.current&&r.current.state!==`closed`)return r.current;try{r.current=new AudioContext}catch{return null}return r.current},[]),a=(0,d.useCallback)((e=!1)=>{if(!e&&!n.current)return;let t=i();t?.state===`suspended`&&t.resume().catch(()=>{})},[i]);return{soundEnabled:e,onSoundToggle:(0,d.useCallback)(()=>{let e=!n.current;e&&a(!0),n.current=e,localStorage.setItem(`pi-sound-enabled`,String(e)),t(e)},[a]),playDoneSound:(0,d.useCallback)(()=>{if(!n.current)return;let e=i();if(!e)return;let t=()=>{try{ZJ(e)}catch{}};if(e.state===`suspended`){e.resume().then(t).catch(()=>{});return}t()},[i]),unlockAudio:a,soundEnabledRef:n}}function $J(e){let[t,n]=(0,d.useState)(!1),r=(0,d.useRef)(0);return{isDragOver:t,handleDragEnter:(0,d.useCallback)(e=>{Array.from(e.dataTransfer.items).some(e=>e.type.startsWith(`image/`))&&(e.preventDefault(),r.current+=1,n(!0))},[]),handleDragOver:(0,d.useCallback)(e=>{Array.from(e.dataTransfer.items).some(e=>e.type.startsWith(`image/`))&&e.preventDefault()},[]),handleDragLeave:(0,d.useCallback)(()=>{--r.current,r.current<=0&&(r.current=0,n(!1))},[]),handleDrop:(0,d.useCallback)(t=>{t.preventDefault(),r.current=0,n(!1),e(Array.from(t.dataTransfer.files))},[e])}}var eY=/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]|\][^\x07]*(?:\x07|\x1B\\))/g,tY=/^\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]|\][^\x07]*(?:\x07|\x1B\\))/,nY=/\x1B\[([0-9;]*)m/g,rY=/\x1B_pi:c\x07/g,iY=[`#1f2937`,`#dc2626`,`#16a34a`,`#d97706`,`#2563eb`,`#9333ea`,`#0891b2`,`#6b7280`],aY=[`#9ca3af`,`#ef4444`,`#22c55e`,`#f59e0b`,`#3b82f6`,`#a855f7`,`#06b6d4`,`#e5e7eb`];function oY(e){return e.replace(rY,``).replace(eY,``)}function sY(e){let t=[],n=0;for(;n<e.length;){if(e.charCodeAt(n)===27){let t=e.slice(n).match(tY);if(t){n+=t[0].length;continue}}let r=e.codePointAt(n);if(r===void 0)break;let i=String.fromCodePoint(r);t.push({start:n,end:n+i.length,char:i}),n+=i.length}return t}function cY(e,t){let n=sY(e)[t];return n?e.slice(0,n.start)+e.slice(n.end):e}function lY(e){return sY(e)[0]?.char}function uY(e){let t=sY(e);for(let e=t.length-1;e>=0;e--)if(t[e].char.trim()!==``)return e;return-1}function dY(e){let t=e;for(;;){let e=sY(t),n=e[e.length-1];if(n?.char.trim()!==``)return t;t=t.slice(0,n.start)+t.slice(n.end)}}function fY(e){let t=/^[┌├└╭╰][─┬┴┼]+[┐┤┘╮╯]$/,n=[];for(let r of e){let e=r.replace(rY,``),i=oY(e).trimEnd();if(t.test(i))continue;let a=e,o=lY(a);(o===`│`||o===`┃`)&&(a=cY(a,0),lY(a)===` `&&(a=cY(a,0)));let s=uY(a),c=s>=0?sY(a)[s]?.char:void 0;(c===`│`||c===`┃`)&&(a=cY(a,s)),n.push(dY(a))}for(;n.length>0&&oY(n[0]).trim()===``;)n.shift();for(;n.length>0&&oY(n[n.length-1]).trim()===``;)n.pop();return n.length?n:e}function pY(e){if(e>=0&&e<8)return iY[e];if(e>=8&&e<16)return aY[e-8];if(e>=16&&e<=231){let t=e-16,n=Math.floor(t/36),r=Math.floor(t%36/6),i=t%6,a=e=>e===0?0:55+e*40;return`rgb(${a(n)}, ${a(r)}, ${a(i)})`}if(e>=232&&e<=255){let t=8+(e-232)*10;return`rgb(${t}, ${t}, ${t})`}}function mY(e,t){let n={...e};for(let e=0;e<t.length;e++){let r=t[e];if(r===0)for(let e of Object.keys(n))delete n[e];else if(r===1)n.fontWeight=700;else if(r===2)n.opacity=.65;else if(r===3)n.fontStyle=`italic`;else if(r===4)n.textDecoration=`underline`;else if(r===22)delete n.fontWeight,delete n.opacity;else if(r===23)delete n.fontStyle;else if(r===24)delete n.textDecoration;else if(r===39)delete n.color;else if(r===49)delete n.backgroundColor;else if(r>=30&&r<=37)n.color=iY[r-30];else if(r>=90&&r<=97)n.color=aY[r-90];else if(r>=40&&r<=47)n.backgroundColor=iY[r-40];else if(r>=100&&r<=107)n.backgroundColor=aY[r-100];else if((r===38||r===48)&&t[e+1]===2){let[i,a,o]=[t[e+2],t[e+3],t[e+4]];[i,a,o].every(e=>typeof e==`number`&&Number.isFinite(e))&&(r===38?n.color=`rgb(${i}, ${a}, ${o})`:n.backgroundColor=`rgb(${i}, ${a}, ${o})`),e+=4}else if((r===38||r===48)&&t[e+1]===5){let i=pY(t[e+2]);i&&(r===38?n.color=i:n.backgroundColor=i),e+=2}}return n}function hY(e){let t=[],n={},r=0,i;for(nY.lastIndex=0;(i=nY.exec(e))!==null;){i.index>r&&t.push({text:e.slice(r,i.index),style:n});let a=i[1]?i[1].split(`;`).map(e=>Number(e||`0`)):[0];n=mY(n,a),r=i.index+i[0].length}return r<e.length&&t.push({text:e.slice(r),style:n}),t}var gY=`max(0px, (100% - 868px) / 2)`,_Y=`max(0px, calc((100% - 884px) / 2))`;function vY(e){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(e);try{let t=document.createElement(`textarea`);return t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t),Promise.resolve()}catch{return Promise.reject()}}var yY={ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`,ArrowRight:`\x1B[C`,ArrowLeft:`\x1B[D`,Home:`\x1B[H`,End:`\x1B[F`,Insert:`\x1B[2~`,Delete:`\x1B[3~`,PageUp:`\x1B[5~`,PageDown:`\x1B[6~`,Escape:`\x1B`,Backspace:``},bY={ArrowLeft:`\x1Bb`,ArrowRight:`\x1Bf`,ArrowUp:`\x1Bp`,ArrowDown:`\x1Bn`};function xY(e){if(e.length!==1)return null;let t=e.toUpperCase().charCodeAt(0);return t>=64&&t<=95?String.fromCharCode(t&31):e===`?`?``:null}function SY(e){if(e.metaKey||e.ctrlKey&&!e.altKey&&e.key.toLowerCase()===`v`)return null;if(e.ctrlKey&&!e.altKey){let t=xY(e.key);if(t)return t}if(e.altKey&&!e.ctrlKey){if(e.key===`Backspace`)return`\x1B`;let t=bY[e.key];if(t)return t;if(e.key.length===1)return`\x1b${e.key}`}return e.key===`Enter`?e.shiftKey?`
|
|
354
|
-
`:`\r`:e.key===`Tab`?e.shiftKey?`\x1B[Z`:` `:
|
|
355
|
-
`)})}var
|
|
353
|
+
`))}catch(e){console.error(`Failed to recall queued messages:`,e),Pe({type:`error`,message:Ie(`i18n.failedToRecallQueuedMessages`)})}},[e.chatInputRef,Pe,Ie]),Fn=(0,d.useCallback)((e=`smooth`)=>{ct.current=Date.now()+pJ,lt.current?.scrollIntoView({behavior:e})},[]),In=(0,d.useCallback)(()=>{let e=ut.current,t=rt.current;if(!e||!t)return;let n=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;ct.current=Date.now()+pJ,e.scrollTo({top:n-16,behavior:`smooth`})},[]),Ln=(0,d.useCallback)(e=>{e instanceof KeyboardEvent&&(!OJ.has(e.key)||e.target instanceof Element&&e.target.closest(`input, textarea, [contenteditable='true']`))||(st.current=Date.now()+mJ)},[]),Rn=(0,d.useCallback)(()=>{if(Date.now()<ct.current)return;let e=ut.current;if(e){if(e.scrollHeight-e.scrollTop-e.clientHeight<hJ){at.current=!0;return}Ye.current&&(Date.now()>st.current||(at.current=!1))}},[]);return(0,d.useEffect)(()=>(t?(Je.current=t.id,rn(t.id,!0,!1).then(()=>fn(t.id)).then(()=>rn(t.id,!1,!0)).then(e=>{e?.running&&(on(t.id),(e.state?.isStreaming||e.state?.isPromptRunning)&&(Xe.current=!!e.state.isStreaming,Ze.current=!!e.state.isPromptRunning,L(!0),Oe(e.state.isStreaming?{kind:`waiting_model`}:{kind:`running_command`}),E({type:`start`}),!e.state.isStreaming&&e.state.isPromptRunning&&vn(t.id)),e.state?.isBashRunning&&(se(!0),yn(t.id))),e?.state&&(e.state.isCompacting!==void 0&&xe(e.state.isCompacting),Yt(e.state))})):l&&n&&cn().then(async e=>{if(e){Je.current=e,await fn(e);try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/state`);if(!t.ok)return;let n=await t.json();Je.current===e&&Yt(n.state)}catch{}}}),()=>{et.current+=1,un(),dn()}),[]),(0,d.useEffect)(()=>(window.addEventListener(`keydown`,Ln),window.addEventListener(`pointerdown`,Ln,{passive:!0}),()=>{window.removeEventListener(`keydown`,Ln),window.removeEventListener(`pointerdown`,Ln)}),[Ln]),(0,d.useEffect)(()=>{let e=ut.current;if(e)return e.addEventListener(`wheel`,Ln,{passive:!0}),e.addEventListener(`touchstart`,Ln,{passive:!0}),e.addEventListener(`scroll`,Rn,{passive:!0}),()=>{e.removeEventListener(`wheel`,Ln),e.removeEventListener(`touchstart`,Ln),e.removeEventListener(`scroll`,Rn)}},[y.length,p,Rn,Ln]),(0,d.useEffect)(()=>{if(y.length>0){if(it.current)it.current=!1,nt.current=!0,In();else if(!nt.current)nt.current=!0,Fn(`instant`);else if(at.current){let e=ut.current;e&&(e.scrollTop=e.scrollHeight)}}},[y.length,ie,Fn,In]),(0,d.useLayoutEffect)(()=>{if(!at.current||!T.isStreaming)return;let e=ut.current;e&&(e.scrollTop=e.scrollHeight)},[T.isStreaming,T.streamingMessage]),(0,d.useEffect)(()=>{let e=new AbortController,t=()=>It(e.signal).catch(e=>{e instanceof DOMException&&e.name===`AbortError`||jt(e instanceof Error?e.message:String(e))});return c===0?t():be.refresh().catch(()=>{}).then(t),()=>e.abort()},[It,c,jt]),(0,d.useEffect)(()=>{if(!we)return;let e=setTimeout(()=>Te(null),6e3);return()=>clearTimeout(e)},[we]),(0,d.useEffect)(()=>{nn(null)},[y.length,pe?.tokens,pe?.percent,pe?.contextWindow,nn]),{data:u,loading:p,error:h,activeLeafId:_,tree:u?.tree??[],messages:y,entryIds:C,streamState:T,agentRunning:ie,modelNames:ht,modelList:gt,modelError:_t,modelScopeWarnings:vt,modelThinkingLevels:yt,modelThinkingLevelMaps:bt,newSessionModel:xt,toolPreset:Ct,thinkingLevel:wt,retryInfo:de,contextUsage:pe,systemPrompt:he,forkingEntryId:_e,isCompacting:ye,compactError:Se,compactResult:we,currentModel:Xt,displayModel:Zt,sessionStats:tn,slashCommands:ke,slashCommandsLoading:je,queuedMessages:Le,notices:Ne.visible,noticeModals:Ne.modals,dismissNoticeModal:Fe,extensionDialog:Bt,extensionCustomUi:Vt,extensionStatuses:Ht,extensionWidgets:Ut,respondToExtensionUi:Kt,sendExtensionCustomInput:qt,isAutoModelSelection:l&&xt===null,agentPhase:De,isNew:l,sessionIdRef:Je,loadContext:an,messagesEndRef:lt,scrollContainerRef:ut,lastUserMsgRef:rt,pendingScrollToUserRef:it,initialScrollDoneRef:nt,handleSend:Sn,handleAbort:Cn,handleFork:wn,handleNavigate:Tn,handleLeafChange:En,handleModelChange:Lt,handleCompact:Dn,handleSteer:An,handleFollowUp:Mn,handlePromptWithStreamingBehavior:jn,handleAbortCompaction:Nn,handleRecallQueue:Pn,handleBuiltinSlashCommand:On,handleToolPresetChange:zt,handleThinkingLevelChange:en,loadTools:on,loadSlashCommands:ln,setActiveLeafId:v,setData:f,setMessages:S,setSessionStatsOverride:nn,dispatch:E,setAgentRunning:ae,setForkingEntryId:ve,bashRunning:oe,bashOutput:R,pendingBash:le,commandBusy:ze,handleAgentEventRef:tt}}var KJ={background:`linear-gradient(90deg, var(--accent) 0%, var(--accent) 47%, var(--shine-highlight) 53%, var(--shine-highlight) 100%)`,backgroundSize:`200% 100%`,WebkitBackgroundClip:`text`,backgroundClip:`text`,color:`transparent`,animation:`pi-status-shine 1.5s linear infinite`},qJ={animation:`pi-status-icon-pulse 1.5s ease-in-out infinite`};function JJ(e,t){if(e?.kind===`running_tools`){let n=e.tools.map(e=>e.name);return n.length===0?t(`chat.runningTool`):n.length===1?t(`chat.runningNamedTool`,{name:n[0]}):n.length<=3?t(`chat.runningTools`,{names:n.join(`, `)}):t(`chat.runningToolsMore`,{names:n.slice(0,2).join(`, `),count:n.length-2})}return e?.kind===`thinking`?t(`chat.thinking`):e?.kind===`waiting_model`?t(`chat.waitingModel`):e?.kind===`running_command`?t(`chat.runningCommand`):e?.kind===`retrying`?t(`chat.retrying`,{attempt:e.attempt,max:e.maxAttempts}):null}function YJ(e){return e?.kind===`running_tools`?(0,E.jsx)(ti,{size:p.lg}):e?.kind===`running_command`?(0,E.jsx)(Jr,{size:p.lg}):e?.kind===`thinking`?(0,E.jsx)(Dr,{size:p.lg,fill:`currentColor`,style:{color:`var(--bulb-warning)`}}):e?.kind===`retrying`?(0,E.jsx)(Zr,{size:p.lg,style:{color:`var(--status-warning)`}}):(0,E.jsx)(Tr,{size:p.lg})}function XJ({phase:e,elapsed:t,totalElapsed:n}){let{t:r}=N(),i=JJ(e,r)??r(`chat.runningCommand`);return(0,E.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,style:{...KJ,minWidth:0,maxWidth:`100%`},children:[(0,E.jsx)(`span`,{className:`inline-flex flex-shrink-0`,style:qJ,children:YJ(e)}),(0,E.jsxs)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,minWidth:0},children:[i,t!=null&&(0,E.jsxs)(E.Fragment,{children:[` · `,t]}),n!=null&&(0,E.jsxs)(E.Fragment,{children:[` · `,r(`chat.totalElapsed`,{total:n})]})]})]})}function ZJ({msg:e,onSend:t,onFillInput:n,testId:r}){let{t:i}=N(),a=()=>{if(e.allowAppend&&n){n(`${e.message} `);return}t(e.message)},o=`${e.allowAppend?i(`config.widgets.fillToChatInputTooltip`):i(`config.widgets.sendImmediatelyTooltip`)}${e.message}`;return(0,E.jsx)(oi,{label:o,children:(0,E.jsx)(PG,{label:e.label,title:o,onClick:a,testId:r})})}function QJ({messages:e,onSend:t,onFillInput:n,testIdPrefix:r=`quick-msg`,wrapperTestId:i=`quick-message-buttons`,center:a=!1}){return e.length===0?null:(0,E.jsx)(`div`,{"data-testid":i,style:{display:`flex`,flexWrap:`wrap`,gap:6,justifyContent:a?`center`:`flex-start`,paddingTop:8,borderTop:a?`1px solid var(--border)`:void 0},children:e.map((e,i)=>(0,E.jsx)(ZJ,{msg:e,onSend:t,onFillInput:n,testId:`${r}-${i}`},i))})}function $J(e){let t=e.currentTime;[523.25,659.25].forEach((n,r)=>{let i=e.createOscillator(),a=e.createGain();i.connect(a),a.connect(e.destination),i.type=`sine`,i.frequency.value=n;let o=t+r*.18;a.gain.setValueAtTime(0,o),a.gain.linearRampToValueAtTime(.18,o+.02),a.gain.exponentialRampToValueAtTime(.001,o+.45),i.start(o),i.stop(o+.45)})}function eY(){let[e,t]=(0,d.useState)(()=>{if(typeof window>`u`)return!0;let e=localStorage.getItem(`pi-sound-enabled`);return e===null||e===`true`}),n=(0,d.useRef)(e);(0,d.useEffect)(()=>{n.current=e},[e]);let r=(0,d.useRef)(null),i=(0,d.useCallback)(()=>{if(r.current&&r.current.state!==`closed`)return r.current;try{r.current=new AudioContext}catch{return null}return r.current},[]),a=(0,d.useCallback)((e=!1)=>{if(!e&&!n.current)return;let t=i();t?.state===`suspended`&&t.resume().catch(()=>{})},[i]);return{soundEnabled:e,onSoundToggle:(0,d.useCallback)(()=>{let e=!n.current;e&&a(!0),n.current=e,localStorage.setItem(`pi-sound-enabled`,String(e)),t(e)},[a]),playDoneSound:(0,d.useCallback)(()=>{if(!n.current)return;let e=i();if(!e)return;let t=()=>{try{$J(e)}catch{}};if(e.state===`suspended`){e.resume().then(t).catch(()=>{});return}t()},[i]),unlockAudio:a,soundEnabledRef:n}}function tY(e){let[t,n]=(0,d.useState)(!1),r=(0,d.useRef)(0);return{isDragOver:t,handleDragEnter:(0,d.useCallback)(e=>{Array.from(e.dataTransfer.items).some(e=>e.type.startsWith(`image/`))&&(e.preventDefault(),r.current+=1,n(!0))},[]),handleDragOver:(0,d.useCallback)(e=>{Array.from(e.dataTransfer.items).some(e=>e.type.startsWith(`image/`))&&e.preventDefault()},[]),handleDragLeave:(0,d.useCallback)(()=>{--r.current,r.current<=0&&(r.current=0,n(!1))},[]),handleDrop:(0,d.useCallback)(t=>{t.preventDefault(),r.current=0,n(!1),e(Array.from(t.dataTransfer.files))},[e])}}var nY=/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]|\][^\x07]*(?:\x07|\x1B\\))/g,rY=/^\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]|\][^\x07]*(?:\x07|\x1B\\))/,iY=/\x1B\[([0-9;]*)m/g,aY=/\x1B_pi:c\x07/g,oY=[`#1f2937`,`#dc2626`,`#16a34a`,`#d97706`,`#2563eb`,`#9333ea`,`#0891b2`,`#6b7280`],sY=[`#9ca3af`,`#ef4444`,`#22c55e`,`#f59e0b`,`#3b82f6`,`#a855f7`,`#06b6d4`,`#e5e7eb`];function cY(e){return e.replace(aY,``).replace(nY,``)}function lY(e){let t=[],n=0;for(;n<e.length;){if(e.charCodeAt(n)===27){let t=e.slice(n).match(rY);if(t){n+=t[0].length;continue}}let r=e.codePointAt(n);if(r===void 0)break;let i=String.fromCodePoint(r);t.push({start:n,end:n+i.length,char:i}),n+=i.length}return t}function uY(e,t){let n=lY(e)[t];return n?e.slice(0,n.start)+e.slice(n.end):e}function dY(e){return lY(e)[0]?.char}function fY(e){let t=lY(e);for(let e=t.length-1;e>=0;e--)if(t[e].char.trim()!==``)return e;return-1}function pY(e){let t=e;for(;;){let e=lY(t),n=e[e.length-1];if(n?.char.trim()!==``)return t;t=t.slice(0,n.start)+t.slice(n.end)}}function mY(e){let t=/^[┌├└╭╰][─┬┴┼]+[┐┤┘╮╯]$/,n=[];for(let r of e){let e=r.replace(aY,``),i=cY(e).trimEnd();if(t.test(i))continue;let a=e,o=dY(a);(o===`│`||o===`┃`)&&(a=uY(a,0),dY(a)===` `&&(a=uY(a,0)));let s=fY(a),c=s>=0?lY(a)[s]?.char:void 0;(c===`│`||c===`┃`)&&(a=uY(a,s)),n.push(pY(a))}for(;n.length>0&&cY(n[0]).trim()===``;)n.shift();for(;n.length>0&&cY(n[n.length-1]).trim()===``;)n.pop();return n.length?n:e}function hY(e){if(e>=0&&e<8)return oY[e];if(e>=8&&e<16)return sY[e-8];if(e>=16&&e<=231){let t=e-16,n=Math.floor(t/36),r=Math.floor(t%36/6),i=t%6,a=e=>e===0?0:55+e*40;return`rgb(${a(n)}, ${a(r)}, ${a(i)})`}if(e>=232&&e<=255){let t=8+(e-232)*10;return`rgb(${t}, ${t}, ${t})`}}function gY(e,t){let n={...e};for(let e=0;e<t.length;e++){let r=t[e];if(r===0)for(let e of Object.keys(n))delete n[e];else if(r===1)n.fontWeight=700;else if(r===2)n.opacity=.65;else if(r===3)n.fontStyle=`italic`;else if(r===4)n.textDecoration=`underline`;else if(r===22)delete n.fontWeight,delete n.opacity;else if(r===23)delete n.fontStyle;else if(r===24)delete n.textDecoration;else if(r===39)delete n.color;else if(r===49)delete n.backgroundColor;else if(r>=30&&r<=37)n.color=oY[r-30];else if(r>=90&&r<=97)n.color=sY[r-90];else if(r>=40&&r<=47)n.backgroundColor=oY[r-40];else if(r>=100&&r<=107)n.backgroundColor=sY[r-100];else if((r===38||r===48)&&t[e+1]===2){let[i,a,o]=[t[e+2],t[e+3],t[e+4]];[i,a,o].every(e=>typeof e==`number`&&Number.isFinite(e))&&(r===38?n.color=`rgb(${i}, ${a}, ${o})`:n.backgroundColor=`rgb(${i}, ${a}, ${o})`),e+=4}else if((r===38||r===48)&&t[e+1]===5){let i=hY(t[e+2]);i&&(r===38?n.color=i:n.backgroundColor=i),e+=2}}return n}function _Y(e){let t=[],n={},r=0,i;for(iY.lastIndex=0;(i=iY.exec(e))!==null;){i.index>r&&t.push({text:e.slice(r,i.index),style:n});let a=i[1]?i[1].split(`;`).map(e=>Number(e||`0`)):[0];n=gY(n,a),r=i.index+i[0].length}return r<e.length&&t.push({text:e.slice(r),style:n}),t}var vY=`max(0px, (100% - 868px) / 2)`,yY=`max(0px, calc((100% - 884px) / 2))`;function bY(e){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(e);try{let t=document.createElement(`textarea`);return t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t),Promise.resolve()}catch{return Promise.reject()}}var xY={ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`,ArrowRight:`\x1B[C`,ArrowLeft:`\x1B[D`,Home:`\x1B[H`,End:`\x1B[F`,Insert:`\x1B[2~`,Delete:`\x1B[3~`,PageUp:`\x1B[5~`,PageDown:`\x1B[6~`,Escape:`\x1B`,Backspace:``},SY={ArrowLeft:`\x1Bb`,ArrowRight:`\x1Bf`,ArrowUp:`\x1Bp`,ArrowDown:`\x1Bn`};function CY(e){if(e.length!==1)return null;let t=e.toUpperCase().charCodeAt(0);return t>=64&&t<=95?String.fromCharCode(t&31):e===`?`?``:null}function wY(e){if(e.metaKey||e.ctrlKey&&!e.altKey&&e.key.toLowerCase()===`v`)return null;if(e.ctrlKey&&!e.altKey){let t=CY(e.key);if(t)return t}if(e.altKey&&!e.ctrlKey){if(e.key===`Backspace`)return`\x1B`;let t=SY[e.key];if(t)return t;if(e.key.length===1)return`\x1b${e.key}`}return e.key===`Enter`?e.shiftKey?`
|
|
354
|
+
`:`\r`:e.key===`Tab`?e.shiftKey?`\x1B[Z`:` `:xY[e.key]??null}function TY(e){return`\x1b[200~${e}\x1b[201~`}function EY(e){if(e.type!==`thinking`)return!1;let t=e;return t.thinking.trim()===``&&!!(t.redacted||typeof t.thinkingSignature==`string`&&t.thinkingSignature.trim().length>0)}function DY(e,t={}){return e.type===`thinking`&&!e.deferred&&!t.isStreaming&&e.thinking.trim()===``&&!EY(e)}function OY(e,t={}){return(e.content??[]).filter(e=>!DY(e,t))}function kY(e,t={}){return t.isStreaming||e.stopReason!==`error`?null:e.errorMessage?.trim()||`Unknown provider error`}function AY(e){return e.type===`text`||e.type===`image`}function jY(e,t={}){let n=OY(e,t),r=n.findLastIndex(e=>!AY(e));return r===-1?{answerBlocks:n,processBlocks:[]}:{answerBlocks:n.slice(r+1),processBlocks:n.slice(0,r+1)}}function MY(e){return e.filter(e=>e.type===`toolCall`).length}function NY(e){return e.role===`user`?96:e.role===`assistant`?260:120}function PY(e){return e.role===`assistant`&&jY(e).answerBlocks.some(e=>e.type===`image`||e.type===`text`&&e.text.trim().length>0)}function FY(e,t,n){for(let r=n-1;r>t;r--)if(PY(e[r]))return r;for(let r=n-1;r>t;r--)if(e[r]?.role===`assistant`)return r;return-1}function IY(e,t){let n=0;for(let r of t){let t=e[r];t?.role===`assistant`&&(n+=MY(OY(t)))}return n}function LY(e){return e.role===`assistant`?OY(e).length>0:e.role===`custom`}function RY(e){return e.role===`user`||e.role===`custom`&&e.customType===`compaction`}function zY(e,t,n={}){let r={...e,content:t};return n.omitUsage&&(r.usage=void 0),r}function BY(e,t){let{isLiveTail:n,lastAnchorIdx:r,visibleRefIndexByMessage:i}=t,a=[],o=(t,n={})=>{a.push({key:`message-${t}`,kind:`message`,msgIdx:t,estimate:NY(e[t]),...n})};for(let t=0;t<e.length;){let s=e[t];if(!RY(s)){o(t),t+=1;continue}let c=t,l=c+1;for(;l<e.length&&!RY(e[l]);)l+=1;let u=FY(e,c,l);if(u===-1||n&&l===e.length&&c===r){for(let e=c;e<l;e++)o(e);t=l;continue}o(c);let d=[];for(let e=c+1;e<u;e++)d.push(e);let f=d.filter(t=>LY(e[t])),p=e[u],m=jY(p),h=m.processBlocks.length>0?zY(p,m.processBlocks,{omitUsage:!0}):null,g=m.answerBlocks.length>0||kY(p)?zY(p,m.answerBlocks):null,_=f.length+ +!!h;if(_>0){let t=f.map(e=>i.get(e)).find(e=>typeof e==`number`)??(g?void 0:i.get(u));a.push({key:`group-header-${c}-${u}`,kind:`groupHeader`,groupUserIdx:c,finalAssistantIdx:u,messageCount:_,toolCallCount:IY(e,f)+MY(m.processBlocks),processRefIdx:t,estimate:40}),f.forEach((e,t)=>{o(e,{isProcess:!0,attachRef:!1,groupLast:!h&&t===f.length-1})}),h&&o(u,{isProcessFinal:!0,attachRef:!1,messageOverride:h,showTimestamp:!1,groupLast:!0})}g&&a.push({key:`message-${u}-answer`,kind:`message`,msgIdx:u,estimate:NY(e[u]),messageOverride:g,isAnswer:!0});for(let e=u+1;e<l;e++)o(e);t=l}return a}function VY(e){let t=new Map;return e.forEach((e,n)=>{e.kind===`message`&&t.set(e.msgIdx,n)}),t}var HY=new Map;function UY(e){return{value:e.value,images:e.images.map(e=>({...e}))}}function WY(e){return!e.value&&e.images.length===0}function GY(e){let t=HY.get(e);return t?UY(t):null}function KY(e,t){if(WY(t)){HY.delete(e);return}HY.set(e,UY(t))}function qY(e){HY.delete(e)}var JY=`pi-web:pending-message:`;function YY(e,t){if(!t){ZY(e);return}try{localStorage.setItem(JY+e,t)}catch{}}function XY(e){try{return localStorage.getItem(JY+e)}catch{return null}}function ZY(e){try{localStorage.removeItem(JY+e)}catch{}}function QY(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===43||e===47}function $Y(e){if(!e||e.length%4!=0)return null;let t=e.endsWith(`==`)?2:+!!e.endsWith(`=`),n=e.length-t;for(let t=0;t<n;t+=1)if(!QY(e.charCodeAt(t)))return null;for(let t=n;t<e.length;t+=1)if(e[t]!==`=`)return null;return e.length/4*3-t}function eX(e){if(!e||typeof e!=`object`)return!1;let t=e;if(typeof t.data!=`string`||typeof t.mimeType!=`string`||!t.mimeType.startsWith(`image/`))return!1;let n=$Y(t.data);return n!==null&&n<=10485760}function tX({active:e,label:t,desc:n,onSelect:r}){return(0,E.jsxs)(`button`,{type:`button`,onClick:r,style:{display:`flex`,alignItems:`center`,gap:8,width:`100%`,padding:`7px 12px`,background:e?`var(--bg-selected)`:`none`,border:`none`,color:e?`var(--text)`:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-base)`,textAlign:`left`,fontWeight:e?600:400,whiteSpace:`nowrap`},className:e?`selectable-row is-selected`:`selectable-row`,children:[e?(0,E.jsx)(ur,{size:p.xs,strokeWidth:4.8,style:{flexShrink:0}}):(0,E.jsx)(`span`,{style:{width:10,flexShrink:0}}),(0,E.jsx)(`span`,{style:{flex:1},children:t}),(0,E.jsx)(`span`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-dim)`,marginLeft:8},children:n})]})}var nX=[`off`,`default`,`full`],rX={off:`none`,default:`default`,full:`full`},iX=100;function aX(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:e.toLocaleString()}function oX(e){return{data:e.data,mimeType:e.mimeType}}function sX(e){return{...e,previewUrl:`data:${e.mimeType};base64,${e.data}`}}function cX(e){return(e??[]).filter(eX).slice(0,10).map(sX)}function lX(e){e.previewUrl.startsWith(`blob:`)&&URL.revokeObjectURL(e.previewUrl)}function uX({kind:e,text:t}){return(0,E.jsx)(oi,{label:t,wrapperStyle:{display:`flex`,minWidth:0,flex:1},children:(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`3px 10px`,fontSize:`var(--text-base)`,color:`var(--text-muted)`,minWidth:0},children:[(0,E.jsx)(`span`,{style:{flexShrink:0,fontSize:`var(--text-xs)`,fontFamily:`var(--font-mono)`,padding:`1px 7px`,borderRadius:999,border:`1px solid ${e===`steer`?`color-mix(in srgb, var(--accent) 45%, transparent)`:`var(--border)`}`,color:e===`steer`?`var(--accent)`:`var(--text-dim)`},children:e}),(0,E.jsx)(`span`,{style:{minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:t})]})})}function dX({tone:e,title:t,body:n}){let r=e===`error`?`239,68,68`:`234,179,8`;return(0,E.jsxs)(`div`,{role:`alert`,style:{display:`flex`,alignItems:`flex-start`,gap:8,maxHeight:120,marginBottom:8,padding:`7px 10px`,overflowY:`auto`,border:`1px solid rgba(${r},0.3)`,borderRadius:6,background:`rgba(${r},0.07)`,color:`rgb(${r})`,fontSize:`var(--text-sm)`,lineHeight:1.45},children:[(0,E.jsx)(Zr,{size:p.lg,style:{flexShrink:0,marginTop:1},"aria-hidden":`true`}),(0,E.jsxs)(`div`,{style:{minWidth:0},children:[(0,E.jsx)(`div`,{style:{fontWeight:600},children:t}),(0,E.jsx)(`div`,{style:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:n})]})]})}function fX({error:e}){return e?(0,E.jsx)(dX,{tone:`error`,title:`Model error`,body:e}):null}function pX({warnings:e}){return!e||e.length===0?null:(0,E.jsx)(dX,{tone:`warning`,title:e.length>1?`Model scope warnings`:`Model scope warning`,body:e.join(`
|
|
355
|
+
`)})}var mX=(0,d.forwardRef)(function({onSend:e,onAbort:t,onSteer:n,onFollowUp:r,isStreaming:i,model:a,isAutoModelSelection:o,modelNames:s,modelList:c,modelError:l,modelScopeWarnings:u,onModelChange:f,onCompact:m,onReloadFromDisk:h,onAbortCompaction:g,isCompacting:_,compactError:v,compactResult:y,toolPreset:b,onToolPresetChange:x,thinkingLevel:S,onThinkingLevelChange:C,availableThinkingLevels:w,thinkingLevelMap:T,onOpenModelConfig:D,retryInfo:O,queuedMessages:k,inputHistory:A=[],onRecallQueue:j,slashCommands:M,slashCommandsLoading:P,onLoadSlashCommands:ee,onBuiltinCommand:F,commandBusy:te,soundEnabled:re,onSoundToggle:ie,onAudioUnlock:ae,onPromptWithStreamingBehavior:oe,draftKey:I,cwd:L},se){let{t:R}=N(),ce=ne(),{isDark:le}=Xn(),[ue,de]=(0,d.useState)(()=>I?GY(I)?.value??``:``),fe=(k?.steering.length??0)+(k?.followUp.length??0),[pe,me]=(0,d.useState)(!1),[he,ge]=(0,d.useState)(null),[_e,ve]=(0,d.useState)(``),[ye,be]=(0,d.useState)(0),xe=(0,d.useRef)(null),[Se,Ce]=(0,d.useState)(!1),[we,Te]=(0,d.useState)(!1),[Ee,De]=(0,d.useState)(!1),[Oe,ke]=(0,d.useState)(null),[Ae,je]=(0,d.useState)(()=>I?cX(GY(I)?.images):[]),Me=ue.trimStart(),Ne=Ae.length===0&&Me.startsWith(`!`),Pe=Ne&&Me.startsWith(`!!`),[Fe,Ie]=(0,d.useState)(null),[Le,Re]=(0,d.useState)(!1),[ze,Be]=(0,d.useState)(0),[Ve,He]=(0,d.useState)(!1),[Ue,We]=(0,d.useState)(0),[Ge,Ke]=(0,d.useState)(null),[qe,Je]=(0,d.useState)(!1),[Ye,Xe]=(0,d.useState)(null),[Ze,Qe]=(0,d.useState)(null),$e=L&&Ze?.cwd===L?Ze.values:{},et=(0,d.useRef)(null),tt=(0,d.useRef)(null),nt=(0,d.useRef)(null),rt=(0,d.useRef)(null),it=(0,d.useRef)(null),at=(0,d.useRef)(null),ot=(0,d.useRef)(null),st=(0,d.useRef)(null),ct=(0,d.useRef)(!1),lt=(0,d.useRef)(0),ut=(0,d.useRef)([]),dt=(0,d.useRef)([]),ft=(0,d.useRef)(null),pt=(0,d.useRef)(null),mt=(0,d.useRef)(I),ht=(0,d.useRef)(ue),gt=(0,d.useRef)(Ae),_t=(0,d.useRef)(0);ht.current=ue,gt.current=Ae,(0,d.useImperativeHandle)(se,()=>({insertIfEmpty(e){let t=et.current;(t?t.value:ue).trim()||(de(e),Ie(null),requestAnimationFrame(()=>{t&&(t.focus(),t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,200)}px`)}))},prependText(e){if(!e.trim())return;let t=et.current,n=[e,t?t.value:ue].filter(e=>e.trim()).join(`
|
|
356
356
|
|
|
357
|
-
`);de(n),Ie(null),requestAnimationFrame(()=>{t&&(t.focus(),t.setSelectionRange(n.length,n.length),t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,200)}px`)})},insertText(e){let t=et.current;if(!t){de(t=>t+(t?` `:``)+e);return}let n=t.selectionStart??t.value.length,r=t.selectionEnd??t.value.length,i=t.value.slice(0,n),a=t.value.slice(r),o=i.length>0&&!i.endsWith(` `)?` `:``,s=i+o+e+a;de(s),Ie(null),requestAnimationFrame(()=>{if(!t)return;let r=n+o.length+e.length;t.setSelectionRange(r,r),t.focus(),t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,200)}px`})},fillInput(e){let t=et.current;de(e),Ie(null),requestAnimationFrame(()=>{if(!t)return;t.focus();let n=e.length;t.setSelectionRange(n,n),t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,200)}px`})},addImages(e){vt(e)}}));let vt=(0,d.useCallback)(async e=>{if(i)return;let t=Math.max(0,10-gt.current.length-_t.current),n=e.filter(e=>e.type.startsWith(`image/`)&&e.size<=10485760).slice(0,t);if(n.length){_t.current+=n.length;try{let e=await Promise.all(n.map(e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let n=r.result.split(`,`)[1];t({data:n,mimeType:e.type,previewUrl:URL.createObjectURL(e)})},r.onerror=n,r.readAsDataURL(e)})));je(t=>{let n=e.slice(0,Math.max(0,10-t.length));return e.slice(n.length).forEach(sX),[...t,...n]})}finally{_t.current-=n.length}}},[i]),yt=(0,d.useCallback)(e=>{je(t=>{let n=[...t],[r]=n.splice(e,1);return r&&sX(r),n})},[]),bt=(0,d.useCallback)(()=>{je(e=>(e.forEach(sX),[]))},[]),xt=(0,d.useCallback)(()=>{de(``),Ie(null),He(!1),I&&GY(I),mt.current&&mt.current!==I&&GY(mt.current),bt(),et.current&&(et.current.style.height=`auto`)},[bt,I]);(0,d.useEffect)(()=>{!I||mt.current!==I||WY(I,{value:ue,images:Ae.map(iX)})},[Ae,I,ue]),(0,d.useEffect)(()=>{let e=mt.current;if(e===I)return;e&&WY(e,{value:ht.current,images:gt.current.map(iX)});let t=I?UY(I):null;if(mt.current=I,de(t?.value??``),Ie(null),He(!1),je(e=>(e.forEach(sX),oX(t?.images))),I){let e=JY(I);e!==null&&(de(e),YY(I))}},[I]),(0,d.useEffect)(()=>{let e=et.current;e&&(e.style.height=`auto`,ue&&(e.style.height=`${Math.min(e.scrollHeight,200)}px`))},[ue]),(0,d.useEffect)(()=>()=>{gt.current.forEach(sX)},[]);let St=(0,d.useCallback)(async()=>{let t=ue.trim();if(!t&&!Ae.length||i||te)return;ae?.();let n=I??``;if(!Ae.length&&t.startsWith(`/`)&&F){qY(n,t),xt();let e=await F(t);if(e.handled){e.error&&de(t),YY(n);return}}qY(n,t),xt();try{await e(t,Ae.length?Ae:void 0)}finally{YY(n)}},[ue,Ae,i,te,I,F,e,xt,ae]),Ct=HK({value:ue,commands:M,skillDormancy:$e,builtinDisabled:i,onLoadCommands:ee,onApply:(0,d.useCallback)(e=>{let t=`/${e.name} `;de(t),requestAnimationFrame(()=>{let e=et.current;e&&(e.focus(),e.setSelectionRange(t.length,t.length),e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`)})},[])}),wt=!!ue.trim()&&Ae.length===0,Tt=(0,d.useCallback)((e,t)=>{if(!L){Ie(null);return}let n=t??e.length;Ie(Cq(e.slice(0,n)))},[L]),Et=Fe?.query??null,Dt=d.useMemo(()=>Et!==null&&Ge&&Ge.cwd===L?Dq(Ge.entries,Et):[],[Et,Ge,L]),Ot=!!(Et&&Ge?.truncated&&Ge.cwd===L);(0,d.useEffect)(()=>{if(!Ot||!L||!Et)return;let e=L,t=Et,n=setTimeout(()=>{fetch(`/api/file-index?cwd=${encodeURIComponent(e)}&q=${encodeURIComponent(t)}`).then(e=>{if(!e.ok)throw Error(`file search failed: ${e.status}`);return e.json()}).then(n=>Xe({cwd:e,query:t,matches:n.matches??[]})).catch(()=>{})},150);return()=>clearTimeout(n)},[Ot,Et,L]);let kt=Ot&&Ye!==null&&Ye.cwd===L&&Ye.query===Et,At=kt?Ye.matches:Dt,jt=Fe===null?null:`${Fe.start}:${+!!Fe.quoted}:${Fe.query}`;(0,d.useEffect)(()=>{if(jt===null){Re(!1),Be(0);return}Re(!0),Be(0)},[jt]);let Mt=Fe!==null;(0,d.useEffect)(()=>{if(!Mt||!L)return;let e=ft.current;if(e&&e.cwd===L&&Date.now()-e.fetchedAt<1e4||pt.current===L)return;pt.current=L;let t=L;Je(!0),fetch(`/api/file-index?cwd=${encodeURIComponent(t)}`).then(e=>{if(!e.ok)throw Error(`file index failed: ${e.status}`);return e.json()}).then(e=>{Ke({cwd:t,entries:Tq(e.files??[]),truncated:!!e.truncated}),ft.current={cwd:t,fetchedAt:Date.now()}}).catch(()=>{ft.current=null}).finally(()=>{pt.current=null,Je(!1)})},[Mt,L]);let Nt=(0,d.useCallback)(e=>{if(!Fe)return;let t=et.current?.selectionStart??ue.length,n=ue.slice(0,Fe.start),r=ue.slice(t);Fe.quoted&&r.startsWith(`"`)&&(r=r.slice(1));let i=Oq(e.path,e.isDir,Fe.quoted),a=n+i.text+r,o=n.length+i.cursorOffset;de(a),Ie(Cq(a.slice(0,o))),requestAnimationFrame(()=>{let e=et.current;e&&(e.focus(),e.setSelectionRange(o,o),e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`)})},[Fe,ue]);(0,d.useEffect)(()=>{ze>=At.length&&Be(Math.max(0,At.length-1))},[At.length,ze]),(0,d.useEffect)(()=>{ut.current.length=At.length},[At.length]),(0,d.useEffect)(()=>{Le&&ut.current[ze]?.scrollIntoView({block:`nearest`,inline:`nearest`})},[ze,Le]),(0,d.useEffect)(()=>{Ue>=A.length&&We(Math.max(0,A.length-1))},[A.length,Ue]),(0,d.useEffect)(()=>{dt.current.length=A.length},[A.length]),(0,d.useEffect)(()=>{Ve&&dt.current[Ue]?.scrollIntoView({block:`nearest`,inline:`nearest`})},[Ue,Ve]);let Pt=(0,d.useCallback)(e=>{de(e),He(!1),We(0),Ie(null),requestAnimationFrame(()=>{let t=et.current;t&&(t.focus(),t.setSelectionRange(e.length,e.length),t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,200)}px`)})},[]),Ft=(0,d.useCallback)(e=>{let t=ue.trim();if(!t&&!Ae.length||Ae.length)return;ae?.();let i=e===`steer`?`steer`:`followUp`;if(t.startsWith(`/`)&&oe){oe(t,i,Ae.length?Ae:void 0),xt();return}e===`steer`&&n?n(t,Ae.length?Ae:void 0):e===`followup`&&r&&r(t,Ae.length?Ae:void 0),xt()},[ue,Ae,oe,n,r,xt,ae]),It=(0,d.useCallback)(e=>{let a=e.nativeEvent,o=Date.now()-lt.current<nX,s=ct.current||a.isComposing||a.keyCode===229;if(e.key===`Enter`&&!e.shiftKey&&(s||o)){o&&e.preventDefault();return}if(Ve&&!s){if(e.key===`ArrowDown`){e.preventDefault(),We(e=>Math.min(Math.max(0,A.length-1),e+1));return}if(e.key===`ArrowUp`){e.preventDefault(),We(e=>Math.max(0,e-1));return}if(e.key===`Escape`){e.preventDefault(),He(!1);return}if((e.key===`Tab`||e.key===`Enter`&&!e.shiftKey)&&A[Ue]){e.preventDefault(),Pt(A[Ue]);return}}if(!Ct.handleKeyDown(e)){if(Le&&Fe!==null&&!s){if(e.key===`ArrowDown`){e.preventDefault(),Be(e=>Math.min(Math.max(0,At.length-1),e+1));return}if(e.key===`ArrowUp`){e.preventDefault(),Be(e=>Math.max(0,e-1));return}if(e.key===`Escape`){e.preventDefault(),Re(!1);return}if((e.key===`Tab`||e.key===`Enter`&&!e.shiftKey)&&At[ze]){e.preventDefault(),Nt(At[ze]);return}}if(e.key===`ArrowUp`&&!s&&!i&&A.length>0&&ue.trim().length===0){e.preventDefault(),Re(!1),We(A.length-1),He(!0);return}if(e.key===`Escape`&&!s&&i&&t){e.preventDefault(),t();return}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ue.trim().length===0&&j&&fe>0?j():i&&(n||r)?Ft(n?`steer`:`followup`):St())}},[i,n,r,j,fe,t,Ct,Ft,St,Le,Fe,At,ze,Nt,Ve,A,Ue,Pt,ue]),Lt=(0,d.useCallback)(()=>{let e=et.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`)},[]),Rt=(0,d.useCallback)(e=>{let t=Array.from(e.clipboardData?.items??[]).filter(e=>e.type.startsWith(`image/`));if(!t.length)return;e.preventDefault();let n=t.map(e=>e.getAsFile()).filter(e=>e!==null);vt(n)},[vt]);(0,d.useEffect)(()=>{if(!Ct.open||!L)return;let e=L,t=!1;return Qe({cwd:e,values:{}}),fetch(`/api/skills?cwd=${encodeURIComponent(e)}`).then(e=>{if(!e.ok)throw Error(`skills fetch failed: ${e.status}`);return e.json()}).then(n=>{if(t)return;let r={};for(let e of n.skills??[])r[e.name]=e.disableModelInvocation;Qe({cwd:e,values:r})}).catch(()=>{t||Qe({cwd:e,values:{}})}),()=>{t=!0}},[Ct.open,L]);let zt=c&&c.length>0?c.map(e=>({provider:e.provider,modelId:e.id,name:e.name})).sort(YK):Object.entries(s??{}).map(([e,t])=>({provider:a?.provider??`unknown`,modelId:e,name:t})).sort(YK);XK(zt,_e),(0,d.useEffect)(()=>{xe.current?.scrollIntoView({block:`nearest`})},[ye,_e]);let Bt=a?zt.find(e=>e.modelId===a.modelId&&e.provider===a.provider)?.name??a.modelId:null;a&&Bt&&`${a.provider}${Bt}`;let Vt=y?Math.max(0,y.tokensBefore-y.estimatedTokensAfter):0,Ht=y?`${y.reason&&y.reason!==`manual`?`${y.reason[0].toUpperCase()}${y.reason.slice(1)} `:R(`chat.compacted`)} ${rX(y.tokensBefore)} -> ${rX(y.estimatedTokensAfter)} tokens (${R(`chat.tokensSaved`,{saved:rX(Vt)})})`:null,Ut=(()=>{let e=S??`auto`;return e===`auto`||!T?e:T[e]??e})(),Wt=Object.entries(tX).find(([,e])=>e===(b??`default`))?.[0]??`default`;return(0,d.useEffect)(()=>{let e=e=>{tt.current&&!tt.current.contains(e.target)&&nt.current&&!nt.current.contains(e.target)&&(me(!1),ve(``)),rt.current&&!rt.current.contains(e.target)&&Ce(!1),it.current&&!it.current.contains(e.target)&&Te(!1),at.current&&!at.current.contains(e.target)&&De(!1),ot.current&&!ot.current.contains(e.target)&&!et.current?.contains(e.target)&&He(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,d.useEffect)(()=>{ce||De(!1)},[ce]),(0,E.jsxs)(`div`,{style:{position:`relative`,zIndex:140,flexShrink:0,background:`transparent`,padding:`0 16px 8px`,paddingRight:ce?16:52},children:[(0,E.jsx)(`input`,{ref:st,type:`file`,accept:`image/*`,multiple:!0,disabled:i,style:{display:`none`},onChange:e=>{let t=Array.from(e.target.files??[]);vt(t),e.target.value=``}}),(0,E.jsxs)(`div`,{style:{maxWidth:820,margin:`0 auto`},children:[(0,E.jsx)(uX,{error:l}),(0,E.jsx)(dX,{warnings:u}),(k?.steering.length??0)+(k?.followUp.length??0)>0&&(0,E.jsxs)(`div`,{"data-testid":`queue-panel`,style:{marginBottom:8,border:`1px solid var(--border)`,borderRadius:6,background:`var(--bg-panel)`,padding:`5px 0`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8,padding:`2px 8px 4px 10px`},children:[(0,E.jsx)(`span`,{style:{fontSize:`var(--text-xs)`,fontFamily:`var(--font-mono)`,color:`var(--text-dim)`,textTransform:`uppercase`,letterSpacing:.4},children:R(`chat.queued`,{count:(k?.steering.length??0)+(k?.followUp.length??0)})}),j&&(0,E.jsx)(oi,{label:R(`chat.recallTitle`),children:(0,E.jsxs)(`button`,{"data-testid":`queue-recall`,onClick:j,style:{display:`flex`,alignItems:`center`,gap:6,padding:`4px 12px`,fontSize:`var(--text-base)`,color:`var(--text)`,background:`transparent`,border:`1px solid var(--border)`,borderRadius:7,cursor:`pointer`,transition:`background 0.12s, border-color 0.12s`,whiteSpace:`nowrap`,"--hover-bg":`var(--bg-hover)`,"--hover-border":`color-mix(in srgb, var(--accent) 45%, var(--border))`},className:`hover-shift`,children:[(0,E.jsx)(gr,{size:p.lg}),R(`chat.recall`)]})})]}),k?.steering.map((e,t)=>(0,E.jsx)(cX,{kind:`steer`,text:e},`steer-${t}`)),k?.followUp.map((e,t)=>(0,E.jsx)(cX,{kind:`follow-up`,text:e},`followup-${t}`))]}),O&&(0,E.jsxs)(`div`,{style:{marginBottom:8,padding:`5px 10px`,background:`color-mix(in srgb, var(--status-warning) 8%, transparent)`,border:`1px solid color-mix(in srgb, var(--status-warning) 25%, transparent)`,borderRadius:6,fontSize:`var(--text-base)`,color:`var(--status-warning)`,display:`flex`,alignItems:`center`,gap:6},children:[(0,E.jsx)(Br,{size:p.sm,style:{flexShrink:0}}),R(`chat.retrying`,{attempt:O.attempt,max:O.maxAttempts}),O.errorMessage&&(0,E.jsxs)(`span`,{style:{opacity:.7,marginLeft:4},children:[`— `,O.errorMessage]})]}),Ht&&(0,E.jsxs)(`div`,{style:{marginBottom:8,padding:`5px 10px`,background:`color-mix(in srgb, var(--status-success) 8%, transparent)`,border:`1px solid color-mix(in srgb, var(--status-success) 24%, transparent)`,borderRadius:6,fontSize:`var(--text-base)`,color:`color-mix(in srgb, var(--status-success) 95%, transparent)`,display:`flex`,alignItems:`center`,gap:6},children:[(0,E.jsx)(ur,{size:p.sm,style:{flexShrink:0}}),Ht]}),v&&(0,E.jsx)(`div`,{role:`alert`,style:{marginBottom:8,padding:`7px 10px`,background:`color-mix(in srgb, var(--status-error) 7%, transparent)`,border:`1px solid color-mix(in srgb, var(--status-error) 30%, transparent)`,borderRadius:6,color:`var(--status-error)`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-base)`,lineHeight:1.5,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:v}),Ae.length>0&&(0,E.jsx)(`div`,{style:{display:`flex`,gap:6,marginBottom:6,flexWrap:`wrap`},children:Ae.map((e,t)=>(0,E.jsxs)(`div`,{style:{position:`relative`,flexShrink:0},children:[(0,E.jsx)(`img`,{src:e.previewUrl,alt:``,style:{width:56,height:56,objectFit:`cover`,borderRadius:6,border:`1px solid var(--border)`,display:`block`}}),(0,E.jsx)(`button`,{onClick:()=>yt(t),style:{position:`absolute`,top:-4,right:-4,width:16,height:16,borderRadius:`50%`,background:`var(--bg-panel)`,border:`1px solid var(--border)`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,padding:0,color:`var(--text-muted)`},children:(0,E.jsx)(ni,{size:8,strokeWidth:4.5})})]},t))}),(0,E.jsxs)(`div`,{style:{position:`relative`,minWidth:0},children:[Ve&&A.length>0&&(0,E.jsxs)(`div`,{ref:ot,style:{position:`absolute`,left:0,right:0,bottom:`calc(100% + 8px)`,zIndex:120,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:8,boxShadow:`0 -6px 20px var(--shadow-color)`,overflow:`hidden`,maxHeight:`min(44vh, 360px)`},children:[(0,E.jsx)(oi,{label:`Input history`,wrapperStyle:{display:`flex`},children:(0,E.jsx)(`div`,{style:{height:30,padding:`0 10px`,borderBottom:`1px solid var(--border)`,display:`flex`,alignItems:`center`,color:`var(--text-dim)`},children:(0,E.jsx)(zr,{size:p.xl,strokeWidth:1.8,"aria-hidden":`true`})})}),(0,E.jsx)(`div`,{style:{maxHeight:`calc(min(44vh, 360px) - 31px)`,overflowY:`auto`,padding:4},children:A.map((e,t)=>(0,E.jsxs)(`button`,{ref:e=>{dt.current[t]=e},type:`button`,onMouseDown:t=>{t.preventDefault(),Pt(e)},onMouseEnter:()=>We(t),style:{width:`100%`,display:`flex`,alignItems:`flex-start`,gap:8,padding:`7px 8px`,border:`none`,borderRadius:6,background:t===Ue?`var(--bg-selected)`:`none`,color:`var(--text)`,cursor:`pointer`,textAlign:`left`,fontSize:`var(--text-md)`,lineHeight:1.45},children:[(0,E.jsx)(`span`,{style:{flexShrink:0,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`,paddingTop:1},children:t+1}),(0,E.jsx)(`span`,{style:{minWidth:0,display:`-webkit-box`,WebkitBoxOrient:`vertical`,WebkitLineClamp:2,overflow:`hidden`,overflowWrap:`anywhere`},children:e})]},`${t}:${e}`))})]}),(0,E.jsx)(UK,{palette:Ct,loading:P,skillDormancy:$e}),Le&&Fe!==null&&(()=>{let e=qe&&(!Ge||Ge.cwd!==L),t=At.length===1?R(`chat.match`):R(`chat.matches`,{count:At.length}),n=Ge?.truncated&&!kt?Fe.query?R(`chat.searchingAll`):R(`chat.indexTruncated`):``;return(0,E.jsxs)(`div`,{style:{position:`absolute`,left:0,right:0,bottom:`calc(100% + 8px)`,zIndex:120,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:8,boxShadow:`0 -6px 20px var(--shadow-color)`,overflow:`hidden`,maxHeight:`min(48vh, 400px)`},children:[(0,E.jsxs)(`div`,{style:{padding:`8px 10px`,borderBottom:`1px solid var(--border)`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8,fontSize:`var(--text-sm)`,color:`var(--text-dim)`},children:[(0,E.jsx)(`span`,{children:e?R(`chat.loadingFiles`):R(`chat.files`,{label:t,hint:n})}),(0,E.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`},children:R(`chat.tabEnter`)})]}),(0,E.jsx)(`div`,{style:{maxHeight:`calc(min(48vh, 400px) - 34px)`,overflowY:`auto`,padding:4},children:!e&&At.length===0?(0,E.jsx)(`div`,{style:{padding:`6px 8px`,fontSize:`var(--text-base)`,color:`var(--text-dim)`},children:R(Ot&&!kt?`chat.searching`:`chat.noMatchingFiles`)}):At.map((e,t)=>{let n=t===ze,r=e.path.split(`/`).pop()??e.path,i=e.path.slice(0,e.path.length-r.length);return(0,E.jsxs)(`button`,{ref:e=>{ut.current[t]=e},type:`button`,onMouseDown:t=>{t.preventDefault(),Nt(e)},onMouseEnter:()=>Be(t),style:{width:`100%`,display:`flex`,alignItems:`center`,gap:8,padding:`6px 8px`,border:`none`,borderRadius:6,background:n?`var(--bg-selected)`:`none`,color:`var(--text)`,cursor:`pointer`,textAlign:`left`,fontSize:`var(--text-md)`,fontFamily:`var(--font-mono)`},children:[(0,E.jsx)(`span`,{style:{flexShrink:0,display:`flex`,alignItems:`center`},children:e.isDir?(0,E.jsx)(sn,{size:p.xl}):Fn(r,14)}),(0,E.jsxs)(`span`,{style:{minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:[i&&(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`},children:i}),r,e.isDir&&(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`},children:`/`})]})]},`${e.isDir?`d`:`f`}:${e.path}`)})})]})})(),(0,E.jsxs)(`div`,{style:{minWidth:0,display:`flex`,gap:8,alignItems:`center`,background:`var(--bg)`,border:`1px solid ${Ne?`var(--tool-bg)`:`color-mix(in srgb, var(--border) 70%, transparent)`}`,borderRadius:14,padding:`10px 10px 10px 14px`,zIndex:96,boxShadow:`0 1px 2px var(--shadow-color), 0 8px 24px -12px var(--shadow-color), 0 0 40px -10px var(--input-glow), -64px 0 48px -14px var(--input-glow), 64px 0 48px -14px var(--input-glow)`,transition:`border-color 0.15s, background 0.15s, box-shadow 0.15s`},children:[i&&(0,E.jsx)(`span`,{"aria-hidden":!0,style:{width:8,height:8,borderRadius:`50%`,background:`var(--accent)`,flexShrink:0,alignSelf:`flex-start`,marginTop:16,animation:`blink 1s ease-in-out infinite`}}),(0,E.jsx)(`textarea`,{"data-testid":`chat-input`,ref:et,value:ue,onChange:e=>{de(e.target.value),He(!1),Tt(e.target.value,e.target.selectionStart)},onSelect:e=>{let t=e.currentTarget;Tt(t.value,t.selectionStart)},onKeyDown:It,onCompositionStart:()=>{ct.current=!0},onCompositionEnd:e=>{ct.current=!1,lt.current=Date.now();let t=e.currentTarget;Tt(t.value,t.selectionStart)},onInput:Lt,onPaste:Rt,placeholder:fe>0?R(`chat.recallPlaceholder`):i&&(n||r)?R(`chat.steerPlaceholder`):i?R(`chat.agentPlaceholder`):L?`${L}\n${R(`chat.messagePlaceholder`)}`:R(`chat.messagePlaceholder`),rows:L?2:1,style:{flex:1,minWidth:0,width:`100%`,background:`none`,border:`none`,outline:`none`,resize:`none`,color:`var(--text)`,caretColor:i?`var(--accent)`:void 0,fontSize:`var(--text-xl)`,lineHeight:1.6,fontFamily:`inherit`,minHeight:24,maxHeight:200,overflow:`auto`}}),i?(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,flexShrink:0,alignSelf:`flex-end`},children:[n&&(0,E.jsx)(oi,{label:Ae.length?R(`chat.queueImageBlocked`):R(`chat.steerTooltip`),children:(0,E.jsxs)(`button`,{"data-testid":`steer-button`,onClick:()=>Ft(`steer`),disabled:!wt,style:{display:`flex`,alignItems:`center`,gap:5,padding:`7px 12px`,background:wt?`color-mix(in srgb, var(--status-warning) 12%, transparent)`:`none`,border:`1px solid color-mix(in srgb, var(--status-warning) 35%, transparent)`,borderRadius:8,color:wt?`var(--status-warning)`:`var(--text-dim)`,cursor:wt?`pointer`:`not-allowed`,fontSize:`var(--text-lg)`,fontWeight:600,letterSpacing:`-0.01em`,transition:`background 0.12s`},children:[(0,E.jsx)(Fr,{size:p.base,strokeWidth:4.3,style:{flexShrink:0}}),R(`chat.steer`)]})}),r&&(0,E.jsx)(oi,{label:Ae.length?R(`chat.queueImageBlocked`):R(`chat.followUpTooltip`),children:(0,E.jsxs)(`button`,{"data-testid":`followup-button`,onClick:()=>Ft(`followup`),disabled:!wt,style:{display:`flex`,alignItems:`center`,gap:5,padding:`7px 12px`,background:wt?`color-mix(in srgb, var(--status-info) 12%, transparent)`:`none`,border:`1px solid color-mix(in srgb, var(--status-info) 35%, transparent)`,borderRadius:8,color:wt?`var(--status-info)`:`var(--text-dim)`,cursor:wt?`pointer`:`not-allowed`,fontSize:`var(--text-lg)`,fontWeight:600,letterSpacing:`-0.01em`,transition:`background 0.12s`},children:[(0,E.jsx)(kr,{size:p.base,strokeWidth:4.3,style:{flexShrink:0}}),R(`chat.followUp`)]})})]}):(0,E.jsxs)(`button`,{onClick:St,disabled:!ue.trim()&&!Ae.length||te,style:{flexShrink:0,alignSelf:`flex-end`,display:`flex`,alignItems:`center`,gap:6,padding:`7px 14px`,background:ue.trim()||Ae.length?`var(--accent)`:`var(--bg-panel)`,border:`none`,borderRadius:8,color:ue.trim()||Ae.length?`var(--on-accent)`:`var(--text-dim)`,cursor:(ue.trim()||Ae.length)&&!te?`pointer`:`not-allowed`,fontSize:`var(--text-lg)`,fontWeight:600,letterSpacing:`-0.01em`,boxShadow:ue.trim()||Ae.length?`0 1px 3px var(--accent-glow)`:`none`,transition:`background 0.15s, box-shadow 0.15s`},children:[(0,E.jsx)(lr,{size:p.xl,strokeWidth:3.4,style:{flexShrink:0}}),R(`chat.send`)]})]})]}),Ne&&(0,E.jsxs)(`div`,{className:`text-xs px-2 py-1`,style:{color:Pe?`var(--text-muted)`:`var(--accent)`,marginTop:4},children:[R(`chat.shell`),` · `,R(Pe?`chat.outputLocal`:`chat.outputModel`)]}),(0,E.jsxs)(`div`,{style:{marginTop:8,display:ce?`grid`:`flex`,gridTemplateColumns:ce?`minmax(0, 1fr) auto`:void 0,alignItems:`center`,gap:6,rowGap:4,flexWrap:`wrap`},children:[(0,E.jsxs)(`div`,{style:{flex:ce?`1 1 auto`:`0 0 auto`,minWidth:0,display:`flex`,alignItems:`center`,gap:2},children:[(0,E.jsx)(oi,{label:R(`chat.attachImage`),children:(0,E.jsx)(`button`,{onClick:()=>st.current?.click(),disabled:i,style:{flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,width:32,height:32,padding:0,background:`none`,border:`none`,borderRadius:9,color:`var(--accent)`,cursor:i?`not-allowed`:`pointer`,opacity:i?.5:1,transition:`background 0.12s, color 0.12s`,"--hover-bg":`var(--bg-hover)`,"--hover-color":`var(--accent)`},className:i?void 0:`hover-shift`,children:(0,E.jsx)(Er,{size:p[`2xl`],strokeWidth:1.8,style:{color:`var(--accent)`,flexShrink:0}})})}),f&&(0,E.jsx)(ZK,{value:a??null,options:zt,onChange:f,disabled:i,variant:`chat`,isAutoSelection:o})]}),!ce&&!f&&(0,E.jsx)(`div`,{style:{flex:1}}),(0,E.jsxs)(`div`,{ref:at,style:{flex:`0 0 auto`,display:`flex`,alignItems:`center`,justifyContent:`flex-end`,position:`relative`,marginLeft:ce?0:`auto`},children:[ce&&(0,E.jsx)(oi,{label:Ee?void 0:R(`chat.moreControls`),children:(0,E.jsx)(`button`,{type:`button`,"aria-label":R(`chat.moreControls`),"aria-expanded":Ee,"aria-hidden":Ee||void 0,tabIndex:Ee?-1:void 0,onClick:()=>{me(!1),ve(``),De(!0)},style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:`100%`,height:32,padding:`8px 10px`,background:`none`,border:`none`,borderRadius:9,color:`var(--text-muted)`,cursor:Ee?`default`:`pointer`,fontSize:`var(--text-base)`,fontWeight:500,visibility:Ee?`hidden`:`visible`,pointerEvents:Ee?`none`:`auto`,transition:`background 0.12s, color 0.12s`,"--hover-bg":`var(--bg-hover)`,"--hover-color":`var(--text)`},className:Ee?void 0:`hover-shift`,children:R(`chat.moreControls`)})}),(0,E.jsxs)(`div`,{style:{display:ce?Ee?`flex`:`none`:`flex`,alignItems:`center`,gap:ce?1:2,...ce?{position:`absolute`,right:0,bottom:0,zIndex:60,padding:1,width:`max-content`,maxWidth:`calc(100vw - 32px)`,flexWrap:`nowrap`,justifyContent:`flex-end`,border:`1px solid color-mix(in srgb, var(--border) 72%, transparent)`,borderRadius:10,background:`color-mix(in srgb, var(--bg-panel) 92%, var(--bg))`,boxShadow:`0 8px 24px var(--shadow-color)`,backdropFilter:`blur(10px)`}:null},children:[(0,E.jsx)(`div`,{style:{display:`flex`,alignItems:`center`},children:(0,E.jsx)(oi,{label:i?R(`chat.stopAgent`):void 0,children:(0,E.jsxs)(`button`,{onClick:t,style:{display:`flex`,alignItems:`center`,gap:6,padding:`8px 14px`,height:32,background:le?`var(--status-error)`:`color-mix(in srgb, var(--status-error) 8%, transparent)`,border:le?`1px solid var(--status-error)`:`1px solid color-mix(in srgb, var(--status-error) 30%, transparent)`,borderRadius:9,color:le?`#fff`:`var(--status-error)`,cursor:`pointer`,fontSize:`var(--text-base)`,fontWeight:600,whiteSpace:`nowrap`,letterSpacing:`-0.01em`,transition:`background 0.12s`,visibility:i?`visible`:`hidden`,pointerEvents:i?`auto`:`none`,"--hover-bg":le?`color-mix(in srgb, var(--status-error) 82%, #000)`:`color-mix(in srgb, var(--status-error) 16%, transparent)`,"--hover-color":le?`#fff`:`var(--status-error)`},className:`hover-shift`,children:[(0,E.jsx)(qr,{size:p.xs,fill:`currentColor`}),R(`chat.stop`)]})})}),C&&(0,E.jsxs)(`div`,{ref:it,style:{position:`relative`},children:[(0,E.jsx)(oi,{label:R(`chat.changeReasoning`,{level:Ut}),children:(0,E.jsxs)(`button`,{onClick:()=>!i&&Te(e=>!e),disabled:i,"aria-label":R(`chat.changeReasoningLabel`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:5,padding:ce?`0 6px`:`8px 12px`,width:ce?`auto`:void 0,height:32,background:we?`var(--bg-hover)`:`none`,border:`none`,borderRadius:9,color:`var(--text-muted)`,cursor:i?`not-allowed`:`pointer`,fontSize:`var(--text-base)`,opacity:i?.5:1,transition:`background 0.12s, color 0.12s`,"--hover-bg":`var(--bg-hover)`,"--hover-color":`var(--text)`},className:i?void 0:`hover-shift`,children:[(0,E.jsx)(Dr,{size:p.base,fill:`currentColor`,style:{color:`var(--bulb-warning)`,flexShrink:0}}),(!ce||Ee)&&(0,E.jsx)(`span`,{style:{whiteSpace:`nowrap`},children:Ut})]})}),we&&(0,E.jsx)(`div`,{style:{position:`absolute`,bottom:`calc(100% + 6px)`,right:0,zIndex:100,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:8,boxShadow:`0 -4px 16px var(--shadow-color)`,overflow:`hidden`,minWidth:180},children:yi.filter(e=>!w||e===`auto`||w.includes(e)).map(e=>{let t=(S??`auto`)===e,n=R(Si[e]),r=e!==`auto`&&T?T[e]:void 0;return(0,E.jsx)($Y,{active:t,onSelect:()=>{if(Te(!1),!t){if((e===`xhigh`||e===`max`)&&!T?.[e]){ke(e);return}C(e)}},label:(0,E.jsxs)(E.Fragment,{children:[r!=null&&r!==e?r:e,r!=null&&r!==e&&(0,E.jsxs)(`span`,{style:{fontSize:`var(--text-xs)`,color:`var(--text-dim)`,fontFamily:`var(--font-mono)`,marginLeft:5},children:[`(`,e,`)`]})]}),desc:n},e)})})]}),Oe&&a&&(0,E.jsx)(`div`,{style:{position:`fixed`,inset:0,zIndex:1e3,background:`rgba(0, 0, 0, 0.45)`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,E.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,style:{background:`var(--bg-panel)`,border:`1px solid var(--border)`,borderRadius:10,boxShadow:`0 12px 40px var(--shadow-color)`,width:`min(420px, calc(100vw - 32px))`,padding:18},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-xl)`,fontWeight:600,color:`var(--text)`,marginBottom:8},children:R(`chat.thinkingMapTitle`)}),(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--text-muted)`,lineHeight:1.7,marginBottom:16},children:R(`chat.thinkingMapBody`,{level:Oe})}),(0,E.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8},children:[(0,E.jsx)(`button`,{type:`button`,onClick:()=>ke(null),style:{padding:`5px 14px`,background:`var(--bg-panel)`,border:`1px solid var(--border)`,borderRadius:6,color:`var(--text-muted)`,fontSize:`var(--text-base)`,cursor:`pointer`},children:R(`chat.cancel`)}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>{D?.({provider:a.provider,modelId:a.modelId}),ke(null)},style:{padding:`5px 14px`,background:`var(--accent)`,border:`none`,borderRadius:6,color:`var(--on-accent, #fff)`,fontSize:`var(--text-base)`,fontWeight:600,cursor:`pointer`},children:R(`chat.thinkingMapGo`)})]})]})}),x&&(0,E.jsxs)(`div`,{ref:rt,style:{position:`relative`},children:[(0,E.jsx)(oi,{label:`${R(`chat.changeToolPreset`)}: ${Wt}`,children:(0,E.jsxs)(`button`,{onClick:()=>!i&&Ce(e=>!e),disabled:i,"aria-label":R(`chat.changeToolPreset`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:5,padding:ce?`0 6px`:`8px 12px`,width:ce?`auto`:void 0,height:32,background:Se?`var(--bg-hover)`:`none`,border:`none`,borderRadius:9,color:`var(--text-muted)`,cursor:i?`not-allowed`:`pointer`,fontSize:`var(--text-base)`,opacity:i?.5:1,transition:`background 0.12s, color 0.12s`,"--hover-bg":`var(--bg-hover)`,"--hover-color":`var(--text)`},className:i?void 0:`hover-shift`,children:[(0,E.jsx)(ti,{size:p.base,style:{color:`var(--status-info)`,flexShrink:0}}),(!ce||Ee)&&(0,E.jsx)(`span`,{style:{whiteSpace:`nowrap`},children:Wt})]})}),Se&&(0,E.jsx)(`div`,{style:{position:`absolute`,bottom:`calc(100% + 6px)`,right:0,zIndex:100,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:8,boxShadow:`0 -4px 16px var(--shadow-color)`,overflow:`hidden`,minWidth:120},children:eX.map(e=>{let t=tX[e],n=(b??`default`)===t,r=e===`off`?R(`chat.noTools`):e==="default"?R(`chat.builtInTools`,{count:4}):R(`chat.allBuiltInTools`);return(0,E.jsx)($Y,{active:n,onSelect:()=>{Ce(!1),n||x(t)},label:e,desc:r},e)})})]}),h&&(0,E.jsx)(`div`,{children:(0,E.jsx)(oi,{label:(0,E.jsxs)(`span`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,E.jsx)(`span`,{children:R(`chat.reloadFromDisk`)}),(0,E.jsx)(`span`,{style:{opacity:.85,fontSize:`0.85em`,whiteSpace:`normal`,maxWidth:260},children:R(`chat.reloadFromDiskHint`)})]}),children:(0,E.jsx)(`button`,{onClick:()=>!i&&h(),disabled:i,"aria-label":R(`chat.reloadFromDisk`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:ce?`auto`:36,height:32,padding:`0 6px`,background:`none`,border:`none`,borderRadius:9,color:`var(--text-muted)`,cursor:i?`not-allowed`:`pointer`,opacity:i?.5:1,transition:`background 0.12s, color 0.12s`,"--hover-bg":`var(--bg-hover)`,"--hover-color":`var(--text)`},className:i?void 0:`hover-shift`,children:(0,E.jsx)(wr,{size:p.lg,"aria-hidden":`true`})})})}),m&&(0,E.jsx)(`div`,{children:(0,E.jsx)(oi,{label:R(_?`chat.stopCompaction`:`chat.compactContext`),children:(0,E.jsx)(`button`,{onClick:_?g:m,disabled:i&&!_,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:5,padding:`0 6px`,width:ce?`auto`:36,height:32,background:_?`color-mix(in srgb, var(--status-error) 8%, transparent)`:`none`,border:`none`,borderRadius:9,color:_?`#ef4444`:`var(--text-muted)`,cursor:i&&!_?`not-allowed`:`pointer`,fontSize:`var(--text-base)`,opacity:i&&!_?.5:1,transition:`background 0.12s, color 0.12s`,"--hover-bg":_?`color-mix(in srgb, var(--status-error) 16%, transparent)`:`var(--bg-hover)`,"--hover-color":_?`#ef4444`:`var(--text)`},className:i&&!_?void 0:`hover-shift`,"aria-label":R(_?`chat.stopCompaction`:`chat.compactContext`),children:_?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(qr,{size:p.xs,fill:`currentColor`}),Ee&&(0,E.jsx)(`span`,{style:{whiteSpace:`nowrap`},children:R(`chat.compacting`)})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(br,{size:p.base,style:{color:`var(--status-info)`,flexShrink:0}}),Ee&&(0,E.jsx)(`span`,{style:{whiteSpace:`nowrap`},children:R(`chat.compact`)})]})})})}),ie!==void 0&&(0,E.jsx)(oi,{label:R(re?`chat.disableSound`:`chat.enableSound`),children:(0,E.jsx)(`button`,{onClick:ie,"aria-label":R(re?`chat.disableSound`:`chat.enableSound`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:5,width:32,height:32,padding:0,background:`none`,border:`none`,borderRadius:9,color:re?`var(--text-muted)`:`var(--text-dim)`,cursor:`pointer`,opacity:re?1:.55,transition:`background 0.12s, color 0.12s, opacity 0.12s`,"--hover-bg":`var(--bg-hover)`,"--hover-color":`var(--text)`,"--hover-opacity":`1`},className:`hover-shift`,children:re?(0,E.jsx)($r,{size:p.base,style:{color:re?`var(--accent)`:`var(--text-dim)`,flexShrink:0}}):(0,E.jsx)(ei,{size:p.base,style:{color:re?`var(--accent)`:`var(--text-dim)`,flexShrink:0}})})}),ce&&Ee&&(0,E.jsx)(oi,{label:R(`chat.collapseControls`),children:(0,E.jsx)(`button`,{type:`button`,"aria-label":R(`chat.collapseControls`),"aria-expanded":!0,onClick:()=>{Ce(!1),Te(!1),De(!1)},style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:36,height:32,padding:0,marginLeft:0,background:`var(--bg-hover)`,border:`none`,borderLeft:`1px solid color-mix(in srgb, var(--border) 72%, transparent)`,borderRadius:`0 9px 9px 0`,color:`var(--text)`,cursor:`pointer`,transition:`background 0.12s, color 0.12s`,"--hover-bg":`var(--bg-selected)`},className:`hover-shift`,children:(0,E.jsx)(ni,{size:p.lg})})})]})]})]})]})]})}),pX=null,mX=new Set,hX=null;function gX(){return!hX&&typeof PointerEvent<`u`&&(hX=new PointerEvent(`pointermove`)),hX}var _X=[],vX=0;function yX(){pX===null&&(pX=requestAnimationFrame(()=>{if(pX=null,mX.size===0)return;let e=0;for(let t of mX)_X[e++]=t;_X.length=e,mX.clear();for(let t=0;t<e;t++)_X[t].update();for(let t=0;t<e;t++)_X[t]=null;_X.length=0,mX.size>0&&yX()}))}var bX=class e{get enabled(){return this._enabled}set enabled(e){this._enabled=e,!e&&this.isActive&&this.cancel()}cancel(){if(!this.isActive&&this.pointers.size===0)return;let t=this.isActive,n=gX(),r=t?this.createEvent(n):null;this.pointers.clear(),this.pointersCache.length=0,this.isActive=!1,t&&vX>0&&vX--,mX.delete(this),e.activeInstance.get(this.element)===this&&e.activeInstance.set(this.element,null),this.clearHoldTimers(),this.removeDocumentListeners(),r&&(this.options.onCancel?.(r),this.options.onEnd?.(r))}clearHoldTimers(){this.holdTimer&&=(clearTimeout(this.holdTimer),null),this.holdEventTimer&&=(clearTimeout(this.holdEventTimer),null)}removeDocumentListeners(){document.removeEventListener(`pointermove`,this.onPointerMove),document.removeEventListener(`pointerup`,this.onPointerUp),document.removeEventListener(`pointercancel`,this.onPointerUp)}getRect(e=this.element){return this.options.rectChecker?this.options.rectChecker(e):e.getBoundingClientRect()}getOrigin(){let e={x:0,y:0};return this.resolveOriginInto(e),e}resolveOriginInto(e){let t=this.options.origin;if(!t){e.x=0,e.y=0;return}if(t===`parent`){let t=this.element.offsetParent;if(!t){e.x=0,e.y=0;return}let n=this.getRect(t);e.x=n.left,e.y=n.top;return}if(t instanceof HTMLElement){let n=this.getRect(t);e.x=n.left,e.y=n.top;return}e.x=t.x,e.y=t.y}rebuildPointersCache(){let e=this.pointersCache;e.length=0;for(let t of this.pointers.values())e.push(t)}updateOptions(e){Object.assign(this.options,e),`touchAction`in e&&(this.element.style.touchAction=this.options.touchAction??`none`)}get interacting(){return this.isActive}static{this.elementInstances=new WeakMap}static{this.activeInstance=new WeakMap}static{this.elementListeners=new WeakMap}constructor(t,n={}){this.pointers=new Map,this.pointersCache=[],this.isActive=!1,this.lastUpdate=0,this.priority=0,this._enabled=!0,this.holdTimer=null,this.holdEventTimer=null,this.lastTapTime=0,this.lastTapTarget=null,this._originScratch={x:0,y:0},this._cachedEvent={target:null,pointers:[],isPrimary:!0,originalEvent:null},this.element=t,this.options={threshold:3,preventScroll:!0,styleCursor:!0,...n},this.registerInstance();let r=e.elementInstances.get(t);if(r&&r.length===1&&(t.style.touchAction=this.options.touchAction??`none`,t.style.userSelect=`none`,t.style.webkitUserSelect=`none`),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),r&&r.length===1){let n=n=>e.handleElementPointerDown(t,n);e.elementListeners.set(t,n),t.addEventListener(`pointerdown`,n)}}registerInstance(){let t=e.elementInstances.get(this.element);t?t.push(this):e.elementInstances.set(this.element,[this])}unregisterInstance(){let t=e.elementInstances.get(this.element);if(!t)return;let n=t.indexOf(this);n>=0&&(t.splice(n,1),t.length===0?(e.elementInstances.delete(this.element),e.activeInstance.delete(this.element),e.elementListeners.delete(this.element)):e.elementInstances.set(this.element,t))}shouldHandleEvent(e){return!0}checkEventFilters(e){let t=e.target;return!t||!(this.options.ignoreFrom&&t.closest(this.options.ignoreFrom)||this.options.allowFrom&&!t.closest(this.options.allowFrom))}static handleElementPointerDown(t,n){let r=e.elementInstances.get(t);if(!r)return;let i=e.activeInstance.get(t);if(i){i.onPointerDown(n);return}let a=null,o=-1;for(let e of r)e.checkEventFilters(n)&&e.shouldHandleEvent(n)&&e.enabled&&e.priority>o&&(a=e,o=e.priority);a&&(e.activeInstance.set(t,a),a.handlePointerDown(n))}onPointerDown(e){this.handlePointerDown(e)}handlePointerDown(e){if(this.options.mouseButtons&&!(e.buttons&this.options.mouseButtons))return;this.options.preventScroll&&e.preventDefault(),this.resolveOriginInto(this._originScratch);let t=e.clientX-this._originScratch.x,n=e.clientY-this._originScratch.y,r={id:e.pointerId,start:{x:t,y:n},current:{x:t,y:n},previous:{x:t,y:n},delta:{x:0,y:0},total:{x:0,y:0},velocity:{x:0,y:0},timestamp:e.timeStamp};this.pointers.set(e.pointerId,r),this.rebuildPointersCache(),this.pointers.size===1&&(document.addEventListener(`pointermove`,this.onPointerMove,{passive:!this.options.preventScroll}),document.addEventListener(`pointerup`,this.onPointerUp),document.addEventListener(`pointercancel`,this.onPointerUp)),this.options.onHold&&(this.holdEventTimer&&clearTimeout(this.holdEventTimer),this.holdEventTimer=setTimeout(()=>{this.holdEventTimer=null,this.pointers.size>0&&!this.isActive&&this.options.onHold(this.createEvent(e))},this.options.holdDuration??600));let i=this.options.holdDelay??0;i>0?(this.holdTimer&&clearTimeout(this.holdTimer),this.holdTimer=setTimeout(()=>{this.holdTimer=null,!this.isActive&&this.pointers.size>0&&this.start(e)},i)):this.options.threshold===0&&this.start(e)}onPointerMove(e){let t=this.pointers.get(e.pointerId);if(!t)return;this.resolveOriginInto(this._originScratch);let n=e.clientX-this._originScratch.x,r=e.clientY-this._originScratch.y;if(t.current.x!==n||t.current.y!==r){if(t.current.x=n,t.current.y=r,!this.isActive){let n=t.current.x-t.start.x,r=t.current.y-t.start.y;Math.sqrt(n*n+r*r)>=(this.options.threshold||3)&&(this.holdTimer&&=(clearTimeout(this.holdTimer),null),this.holdEventTimer&&=(clearTimeout(this.holdEventTimer),null),this.start(e))}this.isActive&&(this.options.preventScroll&&e.preventDefault(),mX.add(this),yX())}}onPointerUp(e){if(this.pointers.get(e.pointerId)&&(this.pointers.delete(e.pointerId),this.rebuildPointersCache(),this.clearHoldTimers(),this.pointers.size===0)){if(this.removeDocumentListeners(),this.isActive)this.end(e);else{let t=this.createEvent(e);this.options.onTap&&this.options.onTap(t);let n=e.timeStamp,r=this.options.doubleTapDelay??300;this.options.onDoubleTap&&n-this.lastTapTime<r&&this.lastTapTarget===e.target&&this.options.onDoubleTap(t),this.lastTapTime=n,this.lastTapTarget=e.target}}}start(e){this.isActive=!0,vX++;let t=this.createEvent(e);this.options.onStart&&this.options.onStart(t)}startFromEvent(t){this.isActive||this.pointers.has(t.pointerId)||(e.activeInstance.set(this.element,this),this.handlePointerDown(t),this.isActive||this.start(t))}end(t){this.isActive=!1,mX.delete(this),vX>0&&vX--,e.activeInstance.get(this.element)===this&&e.activeInstance.set(this.element,null);let n=this.createEvent(t);this.options.onEnd&&this.options.onEnd(n)}update(){if(!this.isActive||this.pointers.size===0)return;let e=performance.now(),t=this.lastUpdate===0?16:e-this.lastUpdate;this.lastUpdate=e;let n=t>0?1-Math.exp(-t/50):.3,r=!1;for(let e of this.pointers.values()){let i=e.current.x-e.previous.x,a=e.current.y-e.previous.y;if(i!==0||a!==0){if(r=!0,e.delta.x=i,e.delta.y=a,e.total.x=e.current.x-e.start.x,e.total.y=e.current.y-e.start.y,t>0){let r=i/t*1e3,o=a/t*1e3;e.velocity.x=e.velocity.x*(1-n)+r*n,e.velocity.y=e.velocity.y*(1-n)+o*n}e.previous.x=e.current.x,e.previous.y=e.current.y}else t>0&&(e.velocity.x*=1-n,e.velocity.y*=1-n)}r&&this.options.onMove&&this.options.onMove(this.populateEvent(gX()))}populateEvent(e){let t=this._cachedEvent;return t.target=this.element,t.pointers=this.pointersCache,t.isPrimary=e.isPrimary,t.originalEvent=e,t}createEvent(e){return this.populateEvent(e)}destroy(){this.clearHoldTimers(),this.unregisterInstance();let t=e.elementInstances.get(this.element);if(!t||t.length===0){let t=e.elementListeners.get(this.element);t&&(this.element.removeEventListener(`pointerdown`,t),e.elementListeners.delete(this.element)),this.element.style.touchAction=``,this.element.style.userSelect=``,this.element.style.webkitUserSelect=``}this.pointers.size>0&&this.removeDocumentListeners(),mX.delete(this),this.pointers.clear(),this.pointersCache.length=0}},xX=null;function SX(){if(xX!==null)return xX;if(typeof window>`u`||!window.matchMedia)return xX=!1,!1;let e=window.matchMedia(`(prefers-reduced-motion: reduce)`);return xX=e.matches,typeof e.addEventListener==`function`&&e.addEventListener(`change`,e=>{xX=e.matches}),xX}function CX(e,t){for(let n=0;n<e.length;n++)e[n].modify(t);return t}var wX={instructions:`Press Space or Enter to pick up. Use arrow keys to move. Press Space or Enter to drop. Press Escape to cancel.`,pickedUp:(e,t,n)=>`Picked up ${e}, position ${t} of ${n}`,movedTo:(e,t)=>`Moved to position ${e} of ${t}`,dropped:(e,t,n)=>`Dropped ${e} in position ${t} of ${n}`,dragPickedUp:`Picked up`,dragDropped:`Dropped`};function TX(){return wX}var EX=null;function DX(){return EX&&EX.isConnected?EX:(EX=document.createElement(`div`),EX.setAttribute(`aria-live`,`assertive`),EX.setAttribute(`aria-atomic`,`true`),EX.setAttribute(`role`,`status`),EX.style.cssText=`position:fixed;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,document.body.appendChild(EX),EX)}var OX=``;function kX(e){let t=DX();t.textContent=e===OX?e+`\xA0`:e,OX=e}var AX=null,jX=`pointrix-instructions`;function MX(){return AX&&AX.isConnected?(AX.textContent=wX.instructions,jX):(AX=document.createElement(`div`),AX.id=jX,AX.style.cssText=`position:fixed;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,AX.textContent=wX.instructions,document.body.appendChild(AX),jX)}function NX(e){e.hasAttribute(`tabindex`)||e.setAttribute(`tabindex`,`0`),e.hasAttribute(`role`)||e.setAttribute(`role`,`button`),e.setAttribute(`aria-roledescription`,`draggable`),e.setAttribute(`aria-describedby`,MX())}function PX(e,t){e.setAttribute(`aria-grabbed`,String(t))}function FX(e){e.removeAttribute(`aria-roledescription`),e.removeAttribute(`aria-grabbed`),e.removeAttribute(`aria-describedby`)}var IX=new class{constructor(){this.zones=new Set,this._activeDragCount=0,this._refreshBound=()=>this.refreshRects()}register(e){this.zones.add(e)}unregister(e){this.zones.delete(e)}refreshRects(){for(let e of this.zones)e.isActive&&e.refreshRect()}onDragStart(e){for(let t of this.zones)t.accepts(e)&&(t.activate(e),t.refreshRect());this._activeDragCount===0&&typeof window<`u`&&(window.addEventListener(`scroll`,this._refreshBound,{passive:!0,capture:!0}),window.addEventListener(`resize`,this._refreshBound,{passive:!0})),this._activeDragCount++}onDragMove(e,t,n,r){let i,a=!1;for(let e of this.zones)if(e.isActive&&(e.options.overlap??`pointer`)!==`pointer`){a=!0;break}a&&(i=r?r():e.getBoundingClientRect());for(let r of this.zones){if(!r.isActive)continue;let a=r.checkOverlap(e,t,i);a>0?(r.isOver||r.enter(e,a,n),r.over(e,a,n)):r.isOver&&r.leave(e,n)}}onDragEnd(e,t,n,r){for(let i of this.zones)if(i.isActive){if(i.isOver){let a=r?.(),o=i.checkOverlap(e,t,a);i.drop(e,o>0?o:1,n)}i.deactivate(e),i.clearRect()}this._activeDragCount>0&&this._activeDragCount--,this._activeDragCount===0&&typeof window<`u`&&(window.removeEventListener(`scroll`,this._refreshBound,{capture:!0}),window.removeEventListener(`resize`,this._refreshBound))}getActiveZones(){let e=[];for(let t of this.zones)t.isActive&&e.push(t);return e}getHoveredZones(){let e=[];for(let t of this.zones)t.isOver&&e.push(t);return e}},LX=class extends bX{constructor(e,t={}){super(e,{...t,onStart:e=>{this.handleDragStart(e),t.onStart?.(e)},onMove:e=>{this.handleDragMove(e),t.onMove?.(e)},onEnd:e=>{this.handleDragEnd(e),t.onEnd?.(e)}}),this.transform={x:0,y:0},this.startTransform={x:0,y:0},this.bounds=null,this.momentum={vx:0,vy:0,active:!1},this.transformNormalized=!1,this.detectedAxis=null,this.cachedSize={width:0,height:0},this._boundGetRect=()=>this.getRect(),this.modifierContext={position:{x:0,y:0},velocity:{x:0,y:0},element:null,startPosition:{x:0,y:0},delta:{x:0,y:0},size:{width:0,height:0}},this.cachedDragEvent={target:null,originalEvent:null,pointers:[],isPrimary:!0,dx:0,dy:0,totalX:0,totalY:0,velocityX:0,velocityY:0},this.dragOptions=t,this.priority=5,t.styleCursor!==!1&&(e.style.cursor=t.cursorChecker?t.cursorChecker(`idle`):`grab`),t.aria!==!1&&NX(e)}shouldHandleEvent(e){if(!this.dragOptions.handle)return!0;let t=null;return t=typeof this.dragOptions.handle==`string`?this.element.querySelector(this.dragOptions.handle):this.dragOptions.handle,t?t.contains(e.target):!1}readCurrentTransform(e){let t=window.getComputedStyle(e).transform;if(t&&t!==`none`){let e=t.match(/matrix.*\((.+)\)/);if(e){let t=e[1].split(`, `);this.transform.x=parseFloat(t[4])||0,this.transform.y=parseFloat(t[5])||0}}else this.transformNormalized||(this.transform.x=0,this.transform.y=0);this.transformNormalized||=(e.style.transform=`translate3d(${this.transform.x}px, ${this.transform.y}px, 0)`,!0)}handleDragStart(e){let t=e.target;if(this.dragOptions.aria!==!1&&(PX(t,!0),kX(TX().dragPickedUp)),this.detectedAxis=null,this.readCurrentTransform(t),this.dragOptions.styleCursor!==!1&&(t.style.cursor=this.dragOptions.cursorChecker?this.dragOptions.cursorChecker(`grabbing`):`grabbing`),t.style.willChange=`transform`,this.startTransform.x=this.transform.x,this.startTransform.y=this.transform.y,this.dragOptions.bounds){let e=this.getRect(t),n=this.startTransform.x,r=this.startTransform.y,i;if(this.dragOptions.bounds===`parent`){let e=t.offsetParent||document.body,n=this.getRect(e);i={left:n.left,top:n.top,right:n.right,bottom:n.bottom}}else if(this.dragOptions.bounds instanceof HTMLElement){let e=this.getRect(this.dragOptions.bounds);i={left:e.left,top:e.top,right:e.right,bottom:e.bottom}}else{let e=this.dragOptions.bounds;i={left:e.left??-1/0,top:e.top??-1/0,right:e.right??1/0,bottom:e.bottom??1/0}}let a=i.left-e.left+n,o=i.top-e.top+r,s=i.right-e.right+n,c=i.bottom-e.bottom+r;this.bounds=new DOMRect(a,o,s-a,c-o)}this.momentum.active=!1;let n=this.getRect(e.target);if(this.cachedSize.width=n.width,this.cachedSize.height=n.height,this.dragOptions.modifiers?.length){let t=this.modifierContext;t.position.x=this.startTransform.x,t.position.y=this.startTransform.y,t.velocity.x=0,t.velocity.y=0,t.element=e.target,t.startPosition.x=this.startTransform.x,t.startPosition.y=this.startTransform.y,t.delta.x=0,t.delta.y=0,t.size.width=this.cachedSize.width,t.size.height=this.cachedSize.height;for(let e of this.dragOptions.modifiers)e.onStart?.(t)}this.dragOptions.onDragStart&&this.dragOptions.onDragStart(this.createDragEvent(e,0,0)),this.dragOptions.droppable&&IX.onDragStart(e.target)}handleDragMove(e){let t=e.pointers[0],n=t.total.x,r=t.total.y;if(this.dragOptions.axis===`auto`&&this.detectedAxis===null){let e=Math.abs(n),t=Math.abs(r);(e>0||t>0)&&(this.detectedAxis=e>t?`x`:`y`)}let i=this.dragOptions.axis===`auto`?this.detectedAxis:this.dragOptions.axis;i===`x`?r=0:i===`y`&&(n=0);let a=this.startTransform.x+n,o=this.startTransform.y+r;if(this.dragOptions.grid&&(a=Math.round(a/this.dragOptions.grid.x)*this.dragOptions.grid.x,o=Math.round(o/this.dragOptions.grid.y)*this.dragOptions.grid.y),this.bounds&&(a=Math.max(this.bounds.left,Math.min(a,this.bounds.right)),o=Math.max(this.bounds.top,Math.min(o,this.bounds.bottom))),this.dragOptions.modifiers?.length){let n=this.modifierContext;n.position.x=a,n.position.y=o,n.velocity.x=t.velocity.x,n.velocity.y=t.velocity.y,n.element=e.target,n.startPosition.x=this.startTransform.x,n.startPosition.y=this.startTransform.y,n.delta.x=t.delta.x,n.delta.y=t.delta.y,n.size.width=this.cachedSize.width,n.size.height=this.cachedSize.height,CX(this.dragOptions.modifiers,n),a=n.position.x,o=n.position.y}this.transform.x=a,this.transform.y=o,this.applyTransform(e.target),this.dragOptions.momentum&&(this.momentum.vx=t.velocity.x,this.momentum.vy=t.velocity.y);let s=this.createDragEvent(e,n,r);this.dragOptions.onDragMove&&this.dragOptions.onDragMove(s),this.dragOptions.droppable&&IX.onDragMove(e.target,t.current,s,this._boundGetRect)}handleDragEnd(e){let t=e.target;this.dragOptions.aria!==!1&&(PX(t,!1),kX(TX().dragDropped)),this.dragOptions.styleCursor!==!1&&(t.style.cursor=this.dragOptions.cursorChecker?this.dragOptions.cursorChecker(`grab`):`grab`);let n=this.transform.x-this.startTransform.x,r=this.transform.y-this.startTransform.y,i=this.dragOptions.momentum,a=typeof i==`object`?i.minVelocity??10:10;if(i&&(Math.abs(this.momentum.vx)>a||Math.abs(this.momentum.vy)>a)?this.startMomentum():t.style.willChange=``,this.dragOptions.modifiers?.length){let i=e.pointers[0],a=this.modifierContext;a.position.x=this.transform.x,a.position.y=this.transform.y,a.velocity.x=i?.velocity.x??0,a.velocity.y=i?.velocity.y??0,a.element=e.target,a.startPosition.x=this.startTransform.x,a.startPosition.y=this.startTransform.y,a.delta.x=n,a.delta.y=r,a.size.width=this.cachedSize.width,a.size.height=this.cachedSize.height;for(let e of this.dragOptions.modifiers)e.onEnd?.(a);let o=a.position.x,s=a.position.y;if(o!==this.transform.x||s!==this.transform.y){if(this.transform.x=o,this.transform.y=s,SX())this.applyTransform(t);else{t.style.transition=`transform 300ms cubic-bezier(0.25, 1, 0.5, 1)`,this.applyTransform(t);let e=()=>{t.style.transition=``,t.removeEventListener(`transitionend`,e)};t.addEventListener(`transitionend`,e)}}}if(this.dragOptions.droppable){let t=e.pointers[0]?.current??{x:0,y:0};IX.onDragEnd(e.target,t,this.createDragEvent(e,n,r),this._boundGetRect)}this.dragOptions.onDragEnd&&this.dragOptions.onDragEnd(this.createDragEvent(e,n,r))}startMomentum(){this.momentum.active=!0;let e=this.dragOptions.momentum,t=typeof e==`object`?e.friction??.95:.95,n=typeof e==`object`?e.minSpeed??.1:.1,r=performance.now(),i=e=>{if(!this.momentum.active)return;let a=Math.min(100,e-r)/1e3;r=e;let o=t**+a;if(this.momentum.vx*=o,this.momentum.vy*=o,Math.abs(this.momentum.vx)<n&&Math.abs(this.momentum.vy)<n){this.momentum.active=!1,this.element.style.willChange=``;return}this.transform.x+=this.momentum.vx*a,this.transform.y+=this.momentum.vy*a,this.bounds&&((this.transform.x<this.bounds.left||this.transform.x>this.bounds.right)&&(this.momentum.vx*=-.5,this.transform.x=Math.max(this.bounds.left,Math.min(this.transform.x,this.bounds.right))),(this.transform.y<this.bounds.top||this.transform.y>this.bounds.bottom)&&(this.momentum.vy*=-.5,this.transform.y=Math.max(this.bounds.top,Math.min(this.transform.y,this.bounds.bottom)))),this.applyTransform(this.element),requestAnimationFrame(i)};requestAnimationFrame(i)}applyTransform(e){e.style.transform=`translate3d(${this.transform.x}px, ${this.transform.y}px, 0)`}createDragEvent(e,t,n){let r=e.pointers[0],i=this.cachedDragEvent;return i.target=e.target,i.originalEvent=e.originalEvent,i.pointers=e.pointers,i.isPrimary=e.isPrimary,i.dx=r?.delta.x||0,i.dy=r?.delta.y||0,i.totalX=t,i.totalY=n,i.velocityX=r?.velocity.x||0,i.velocityY=r?.velocity.y||0,i}setPosition(e,t){this.transform.x=e,this.transform.y=t,this.applyTransform(this.element)}getPosition(){return{...this.transform}}updateOptions(e){super.updateOptions(e),Object.assign(this.dragOptions,e),(`cursorChecker`in e||`styleCursor`in e)&&!this.interacting&&(this.dragOptions.styleCursor===!1?this.element.style.cursor=``:this.element.style.cursor=this.dragOptions.cursorChecker?this.dragOptions.cursorChecker(`idle`):`grab`)}destroy(){super.destroy(),this.element.style.cursor=``,this.element.style.willChange=``,this.momentum.active=!1,this.dragOptions.aria!==!1&&FX(this.element)}},RX=class extends bX{constructor(e,t={}){let n={edges:{top:!0,right:!0,bottom:!0,left:!0},handleSize:10,minWidth:50,minHeight:50,...t};super(e,{...n,threshold:0,onStart:e=>{this.handleResizeStart(e),t.onStart?.(e)},onMove:e=>{this.handleResizeMove(e),t.onMove?.(e)},onEnd:e=>{this.handleResizeEnd(e),t.onEnd?.(e)}}),this.startSize={width:0,height:0},this.startPos={x:0,y:0},this.currentSize={width:0,height:0},this.currentPos={x:0,y:0},this.activeEdge=null,this.edgeFlags={top:!1,right:!1,bottom:!1,left:!1},this.aspectRatio=null,this.transformNormalized=!1,this.modifierContext={position:{x:0,y:0},velocity:{x:0,y:0},element:null,startPosition:{x:0,y:0},delta:{x:0,y:0},edges:{top:!1,right:!1,bottom:!1,left:!1},size:{width:0,height:0},startSize:{width:0,height:0}},this.cachedResizeEvent={target:null,originalEvent:null,pointers:[],isPrimary:!0,width:0,height:0,deltaWidth:0,deltaHeight:0,edges:{top:!1,right:!1,bottom:!1,left:!1}},this.resizeOptions=n,this.resizeOptions.square&&(this.resizeOptions.aspectRatio=1),this.priority=10,this.boundUpdateCursor=this.updateCursor.bind(this),e.addEventListener(`pointermove`,this.boundUpdateCursor),e.style.position=`relative`}normalizeInitialTransform(e){let t=window.getComputedStyle(e).transform;if(t&&t!==`none`){let n=t.match(/matrix.*\((.+)\)/);if(n){let t=n[1].split(`, `),r=parseFloat(t[4])||0,i=parseFloat(t[5])||0;e.style.transform=`translate3d(${r}px, ${i}px, 0)`}}}shouldHandleEvent(e){return this.detectEdge(e)!==null}updateCursor(e){if(this.activeEdge)return;let t=this.detectEdge(e);this.element.style.cursor=this.resizeOptions.cursorChecker?this.resizeOptions.cursorChecker(t):this.getCursor(t)}detectEdge(e){let t=this.getRect(),n=e.clientX-t.left,r=e.clientY-t.top,i=this.resizeOptions.handleSize||10,a=this.resizeOptions.edges||{},o=a.top&&r<i,s=a.bottom&&r>t.height-i,c=a.left&&n<i,l=a.right&&n>t.width-i;return o&&c?`top-left`:o&&l?`top-right`:s&&c?`bottom-left`:s&&l?`bottom-right`:o?`top`:s?`bottom`:c?`left`:l?`right`:null}getCursor(e){switch(e){case`top`:case`bottom`:return`ns-resize`;case`left`:case`right`:return`ew-resize`;case`top-left`:case`bottom-right`:return`nwse-resize`;case`top-right`:case`bottom-left`:return`nesw-resize`;default:return``}}handleResizeStart(e){this.transformNormalized||=(this.normalizeInitialTransform(this.element),!0);let t=this.getRect(),n=window.getComputedStyle(this.element);if(this.activeEdge=this.detectEdge(e.originalEvent),!this.activeEdge)return;this.edgeFlags.top=this.activeEdge.includes(`top`),this.edgeFlags.right=this.activeEdge.includes(`right`),this.edgeFlags.bottom=this.activeEdge.includes(`bottom`),this.edgeFlags.left=this.activeEdge.includes(`left`),this.startSize={width:parseFloat(n.width)||t.width,height:parseFloat(n.height)||t.height},this.currentSize={...this.startSize};let r=n.transform;if(r&&r!==`none`){let e=r.match(/matrix.*\((.+)\)/);if(e){let t=e[1].split(`, `);this.startPos.x=parseFloat(t[4])||0,this.startPos.y=parseFloat(t[5])||0}}else this.startPos.x=0,this.startPos.y=0;this.currentPos={...this.startPos},this.resizeOptions.aspectRatio===`preserve`?this.aspectRatio=this.startSize.width/this.startSize.height:typeof this.resizeOptions.aspectRatio==`number`&&(this.aspectRatio=this.resizeOptions.aspectRatio),this.element.style.willChange=`width, height, transform`,this.resizeOptions.onResizeStart&&this.resizeOptions.onResizeStart(this.createResizeEvent(e,0,0))}handleResizeMove(e){if(!this.activeEdge)return;let t=e.pointers[0],n=t.total.x,r=t.total.y,i=this.startSize.width,a=this.startSize.height,o=this.startPos.x,s=this.startPos.y;this.edgeFlags.right&&(i+=n),this.edgeFlags.left&&(i-=n,o+=n),this.edgeFlags.bottom&&(a+=r),this.edgeFlags.top&&(a-=r,s+=r);let c=this.resizeOptions.invert||`none`;c===`reposition`&&(i<0&&(o+=i,i=-i),a<0&&(s+=a,a=-a));let l=c===`negate`?-1/0:this.resizeOptions.minWidth||0,u=c===`negate`?-1/0:this.resizeOptions.minHeight||0,d=this.resizeOptions.maxWidth||1/0,f=this.resizeOptions.maxHeight||1/0,p=c===`reposition`?1:l||50,m=c===`reposition`?1:u||50;if(this.aspectRatio&&(this.activeEdge===`left`||this.activeEdge===`right`?a=i/this.aspectRatio:this.activeEdge===`top`||this.activeEdge===`bottom`?i=a*this.aspectRatio:Math.abs(i-this.startSize.width)>Math.abs(a-this.startSize.height)?a=i/this.aspectRatio:i=a*this.aspectRatio),i<p&&(this.edgeFlags.left&&(o+=i-p),i=p,this.aspectRatio&&(a=i/this.aspectRatio)),i>d&&(this.edgeFlags.left&&(o+=i-d),i=d,this.aspectRatio&&(a=i/this.aspectRatio)),a<m&&(this.edgeFlags.top&&(s+=a-m),a=m,this.aspectRatio&&(i=a*this.aspectRatio)),a>f&&(this.edgeFlags.top&&(s+=a-f),a=f,this.aspectRatio&&(i=a*this.aspectRatio)),this.resizeOptions.grid&&(i=Math.round(i/this.resizeOptions.grid.width)*this.resizeOptions.grid.width,a=Math.round(a/this.resizeOptions.grid.height)*this.resizeOptions.grid.height),this.resizeOptions.modifiers?.length){let e=this.modifierContext;e.position.x=o,e.position.y=s,e.velocity.x=t.velocity?.x??0,e.velocity.y=t.velocity?.y??0,e.element=this.element,e.startPosition.x=this.startPos.x,e.startPosition.y=this.startPos.y,e.delta.x=n,e.delta.y=r,e.edges.top=this.edgeFlags.top,e.edges.right=this.edgeFlags.right,e.edges.bottom=this.edgeFlags.bottom,e.edges.left=this.edgeFlags.left,e.size.width=i,e.size.height=a,e.startSize.width=this.startSize.width,e.startSize.height=this.startSize.height,CX(this.resizeOptions.modifiers,e),o=e.position.x,s=e.position.y,i=e.size.width,a=e.size.height}if(this.currentSize={width:i,height:a},this.currentPos={x:o,y:s},this.element.style.width=`${i}px`,this.element.style.height=`${a}px`,(o!==this.startPos.x||s!==this.startPos.y)&&(this.element.style.transform=`translate3d(${o}px, ${s}px, 0)`),this.resizeOptions.onResizeMove){let t=i-this.startSize.width,n=a-this.startSize.height;this.resizeOptions.onResizeMove(this.createResizeEvent(e,t,n))}}handleResizeEnd(e){if(this.element.style.willChange=``,this.activeEdge=null,this.resizeOptions.onResizeEnd){let t=this.currentSize.width-this.startSize.width,n=this.currentSize.height-this.startSize.height;this.resizeOptions.onResizeEnd(this.createResizeEvent(e,t,n))}}createResizeEvent(e,t,n){let r=this.cachedResizeEvent;return r.target=e.target,r.originalEvent=e.originalEvent,r.pointers=e.pointers,r.isPrimary=e.isPrimary,r.width=this.currentSize.width,r.height=this.currentSize.height,r.deltaWidth=t,r.deltaHeight=n,r.edges.top=this.edgeFlags.top,r.edges.right=this.edgeFlags.right,r.edges.bottom=this.edgeFlags.bottom,r.edges.left=this.edgeFlags.left,r}setSize(e,t){this.currentSize={width:e,height:t},this.element.style.width=`${e}px`,this.element.style.height=`${t}px`}getSize(){return{...this.currentSize}}updateOptions(e){super.updateOptions(e),Object.assign(this.resizeOptions,e),`square`in e&&this.resizeOptions.square&&(this.resizeOptions.aspectRatio=1)}destroy(){super.destroy(),this.element.removeEventListener(`pointermove`,this.boundUpdateCursor),this.element.style.cursor=``,this.element.style.willChange=``}},zX=180/Math.PI,BX=class extends bX{constructor(e,t={}){super(e,{...t,threshold:0}),this.gestureActive=!1,this.startDistance=0,this.startAngle=0,this.prevScale=1,this.prevAngle=0,this._p1=null,this._p2=null,this._cachedGestureEvent={target:null,pointers:[],isPrimary:!1,originalEvent:null,scale:1,rotation:0,distance:0,angle:0,center:{x:0,y:0},deltaScale:0,deltaAngle:0},this.gestureOptions=t,this.minPointers=t.minPointers??2,this.priority=15}shouldHandleEvent(e){return!0}selectTwoPointers(){if(this.pointers.size<2)return this._p1=this._p2=null,!1;let e=this.pointers.values();return this._p1=e.next().value,this._p2=e.next().value,!0}distanceBetween(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}angleBetween(e,t){return Math.atan2(t.y-e.y,t.x-e.x)*zX}normalizeAngleDelta(e){for(;e>180;)e-=360;for(;e<-180;)e+=360;return e}buildEvent(e,t,n,r,i,a,o,s){let c=this._cachedGestureEvent;return c.target=this.element,c.pointers=this.pointersCache,c.isPrimary=!1,c.originalEvent=c.originalEvent??{},c.scale=n,c.rotation=r,c.distance=e,c.angle=t,c.center.x=o,c.center.y=s,c.deltaScale=i,c.deltaAngle=a,c}update(){if(!this.isActive||this.pointers.size===0)return;let e=this.selectTwoPointers();if(!this.gestureActive&&e&&this.pointers.size>=this.minPointers){this.gestureActive=!0;let e=this._p1.current,t=this._p2.current;this.startDistance=this.distanceBetween(e,t),this.startAngle=this.angleBetween(e,t),this.prevScale=1,this.prevAngle=0;let n=this.buildEvent(this.startDistance,this.startAngle,1,0,0,0,(e.x+t.x)/2,(e.y+t.y)/2);this.gestureOptions.onGestureStart&&this.gestureOptions.onGestureStart(n);return}if(this.gestureActive&&this.pointers.size<this.minPointers){this.endGesture(),super.update();return}if(this.gestureActive&&e){let e=this._p1.current,t=this._p2.current,n=this.distanceBetween(e,t),r=this.angleBetween(e,t),i=this.startDistance>0?n/this.startDistance:1,a=this.normalizeAngleDelta(r-this.startAngle),o=i-this.prevScale,s=this.normalizeAngleDelta(a-this.prevAngle);this.prevScale=i,this.prevAngle=a,this.gestureOptions.onGestureMove&&this.gestureOptions.onGestureMove(this.buildEvent(n,r,i,a,o,s,(e.x+t.x)/2,(e.y+t.y)/2))}super.update()}endGesture(){if(!this.gestureActive)return;this.gestureActive=!1;let e=this.selectTwoPointers(),t=e?this._p1.current:null,n=e?this._p2.current:null,r=t&&n?this.distanceBetween(t,n):0,i=t&&n?this.angleBetween(t,n):0,a=t&&n?(t.x+n.x)/2:0,o=t&&n?(t.y+n.y)/2:0,s=this.startDistance>0&&r>0?r/this.startDistance:this.prevScale;this.gestureOptions.onGestureEnd&&this.gestureOptions.onGestureEnd(this.buildEvent(r,i,s,this.prevAngle,0,0,a,o))}updateOptions(e){super.updateOptions(e),Object.assign(this.gestureOptions,e),e.minPointers!==void 0&&(this.minPointers=e.minPointers)}destroy(){this.gestureActive&&this.endGesture(),super.destroy()}},VX=typeof window<`u`?d.useLayoutEffect:d.useEffect;function HX(e){let t={};for(let n in e){let r=e[n];typeof r!=`function`&&(t[n]=r)}return t}function UX(e={},t){let n=(0,d.useRef)(e);n.current=e;let r=(0,d.useRef)(null),i=(0,d.useRef)(null),a=(0,d.useRef)(void 0),o=(0,d.useCallback)(o=>{if(o===i.current||(r.current&&(r.current.drag?.destroy(),r.current.resize?.destroy(),r.current.gesture?.destroy(),r.current=null,t&&(t.current=null)),i.current=o,!o))return;let s=n.current,c={drag:s.drag?new LX(o,typeof s.drag==`object`?WX(n,`drag`):{}):null,resize:s.resize?new RX(o,typeof s.resize==`object`?WX(n,`resize`):{}):null,gesture:s.gesture?new BX(o,typeof s.gesture==`object`?WX(n,`gesture`):{}):null};r.current=c,t&&(t.current=c),a.current=e},[]);return VX(()=>{let t=r.current;if(!t||a.current===e)return;let i=n.current;t.drag&&typeof i.drag==`object`&&t.drag.updateOptions(HX(i.drag)),t.resize&&typeof i.resize==`object`&&t.resize.updateOptions(HX(i.resize)),t.gesture&&typeof i.gesture==`object`&&t.gesture.updateOptions(HX(i.gesture)),a.current=e}),o}function WX(e,t){let n=e.current[t];if(typeof n!=`object`)return{};let r={};for(let i in n){let a=n[i];r[i]=typeof a==`function`?(...n)=>{let r=e.current[t];if(typeof r!=`object`)return;let a=r[i];return a?.(...n)}:a}return r}function GX({title:e,subtitle:t,children:n,footer:r,width:i=560,align:a=`bottom`,height:o,variant:s=`normal`,initialOffset:c,position:l,size:u,maxWidth:f,onDragStop:p,onResizeStop:m,testId:h,style:g,portalTarget:_,headerExtra:v}){let[y,b]=(0,d.useState)(!1),x=Math.round(window.innerHeight*.8),[S]=(0,d.useState)(()=>({x:l?.x??c?.dx??0,y:l?.y??c?.dy??0,w:u?.width??i,h:u?.height??o??null})),C=(0,d.useRef)(null),w=(0,d.useRef)(null),T=(0,d.useRef)(null),D=(0,d.useRef)(p);D.current=p;let O=(0,d.useRef)(m);O.current=m;let k=UX((0,d.useMemo)(()=>({drag:{handle:`.dd-drag-handle`,onDragEnd:()=>{let e=T.current?.drag?.getPosition();e&&D.current?.(e.x,e.y)}},resize:{edges:{top:!0,right:!0,bottom:!0,left:!0},minWidth:160,minHeight:100,onResizeEnd:e=>{let t=C.current?.style.transform.match(/translate3?d?\((-?[\d.]+)px,\s*(-?[\d.]+)px/);O.current?.(e.width,e.height,t?Number(t[1]):0,t?Number(t[2]):0)}}}),[]),T);(0,d.useEffect)(()=>()=>{T.current?.drag?.cancel(),T.current?.resize?.cancel()},[]);let A=(0,d.useCallback)(e=>{C.current=e,k(e)},[k]);(0,d.useEffect)(()=>{if(T.current?.drag?.setPosition(S.x,S.y),S.h!=null){if(T.current?.resize?.setSize(S.w,S.h),f&&w.current){let e=w.current;e.style.width=`max-content`;let t=Math.ceil(e.scrollWidth);e.style.width=``;let n=Math.min(Math.max(t,S.w),f);n!==S.w&&T.current?.resize?.setSize(n,S.h)}return}let e=C.current;if(!e)return;let t=e.style.height,n=e.style.maxHeight;e.style.height=`auto`,e.style.maxHeight=`none`;let r=e.scrollHeight;e.style.height=t,e.style.maxHeight=n;let i=Math.min(r,x);if(f&&w.current){let e=w.current;e.style.width=`max-content`;let t=Math.ceil(e.scrollWidth);e.style.width=``;let n=Math.min(Math.max(t,S.w),f);T.current?.resize?.setSize(n,i)}else T.current?.resize?.setSize(S.w,i)},[]);let j=s===`error`?1200:1e3,M=y?j+100:j;return(0,ii.createPortal)((0,E.jsx)(`div`,{"data-testid":h,onPointerDownCapture:()=>b(!0),style:{position:`fixed`,inset:0,zIndex:M,display:`flex`,alignItems:a===`bottom`?`flex-end`:`center`,justifyContent:`center`,padding:a===`bottom`?`0 20px 16px`:0,pointerEvents:`none`,...g},children:(0,E.jsxs)(`div`,{ref:A,role:`dialog`,"aria-modal":`true`,style:{transform:`translate(${S.x}px, ${S.y}px)`,width:S.w,...S.h==null?{maxHeight:x}:{height:S.h},display:`flex`,flexDirection:`column`,position:`relative`,border:`1px solid color-mix(in srgb, var(--foreground) 14%, transparent)`,borderRadius:12,background:`var(--bg)`,boxShadow:`0 -4px 24px var(--shadow-strong), 0 8px 28px var(--shadow-color), 0 2px 8px var(--shadow-color)`,overflow:`hidden`,pointerEvents:`auto`},children:[(0,E.jsxs)(`div`,{className:`dd-drag-handle`,style:{padding:`12px 14px`,borderBottom:`1px solid var(--border)`,cursor:`move`,touchAction:`none`,userSelect:`none`,flexShrink:0},children:[(0,E.jsx)(`div`,{style:{color:`var(--text)`,fontSize:`var(--text-2xl)`,fontWeight:650,paddingRight:v?34:0},children:e}),t&&(0,E.jsx)(`div`,{style:{marginTop:3,color:`var(--text-dim)`,fontSize:`var(--text-sm)`,fontFamily:`var(--font-mono)`},children:t})]}),v&&(0,E.jsx)(`div`,{style:{position:`absolute`,top:8,right:10,zIndex:2,display:`flex`,alignItems:`center`},children:v}),(0,E.jsx)(`div`,{ref:w,style:{padding:14,overflowY:`auto`,minHeight:0,flexGrow:1,userSelect:`text`},children:n}),r&&(0,E.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8,padding:`10px 14px`,borderTop:`1px solid var(--border)`,background:`var(--bg-panel)`,flexShrink:0},children:r})]})}),_??document.body)}function KX(e,t){if(!t)return new Set;let n=t;function r(e,t){for(let i of e){let e=[...t,i.entry.id];if(i.entry.id===n||i.compressedEntryIds?.includes(n))return e;let a=r(i.children,e);if(a)return a}return null}return new Set(r(e,[])??[])}function qX(e){let t=e,n=t.compressedEntryIds?.length??0;for(;t.children.length===1;)t=t.children[0],n+=1+(t.compressedEntryIds?.length??0);return{node:t,skipped:n}}function JX(e){if(e.type===`message`&&`message`in e){let t=e.message,n=t.content,r=``;if(typeof n==`string`?r=n:Array.isArray(n)&&(r=n.filter(e=>e.type===`text`).map(e=>e.text).join(` `)),r.length>40&&(r=`${r.slice(0,40)}…`),r)return r;if(t.role===`assistant`)return`[assistant]`}return e.type}function YX(e){for(let t of e)if(t.children.length>1||YX(t.children))return!0;return!1}function XX({node:e,activePathIds:t,depth:n,isLast:r,parentLines:i,onSelect:a}){let{node:o,skipped:s}=qX(e),c=t.has(o.entry.id),l=t.has(e.entry.id)||t.has(o.entry.id),u=JX(o.entry),d=o.entry.type===`message`&&`message`in o.entry?o.entry.message.role:null;return(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,height:24,cursor:`pointer`},onClick:()=>a(o.entry.id),children:[i.map((e,t)=>(0,E.jsx)(`div`,{style:{width:16,flexShrink:0,position:`relative`,height:`100%`,alignSelf:`stretch`},children:e&&(0,E.jsx)(`div`,{style:{position:`absolute`,left:7,top:0,bottom:0,width:1,background:`var(--border)`}})},t)),(0,E.jsxs)(`div`,{style:{width:16,flexShrink:0,position:`relative`,height:`100%`,alignSelf:`stretch`},children:[(0,E.jsx)(`div`,{style:{position:`absolute`,left:7,top:0,bottom:r?`50%`:0,width:1,background:`var(--border)`}}),(0,E.jsx)(`div`,{style:{position:`absolute`,left:7,top:`50%`,width:9,height:1,background:`var(--border)`}})]}),(0,E.jsx)(`div`,{style:{width:7,height:7,borderRadius:`50%`,flexShrink:0,background:c?`var(--accent)`:l?`var(--text-muted)`:`var(--border)`,border:c?`none`:`1px solid var(--text-dim)`,marginRight:6,transition:`background 0.12s`}}),d&&(0,E.jsx)(`span`,{style:{fontSize:`var(--text-2xs)`,fontFamily:`var(--font-mono)`,color:d===`user`?`var(--accent)`:`var(--text-dim)`,background:d===`user`?`color-mix(in srgb, var(--accent) 8%, transparent)`:`var(--bg-hover)`,border:`1px solid ${d===`user`?`color-mix(in srgb, var(--accent) 20%, transparent)`:`var(--border)`}`,borderRadius:3,padding:`0 4px`,marginRight:5,flexShrink:0,lineHeight:`16px`},children:d===`user`?`U`:`A`}),s>0&&(0,E.jsxs)(`span`,{style:{fontSize:`var(--text-xs)`,color:`var(--text-dim)`,marginRight:5,flexShrink:0},children:[`+`,s]}),(0,E.jsx)(`span`,{style:{fontSize:`var(--text-sm)`,color:c?`var(--text)`:l?`var(--text-muted)`:`var(--text-dim)`,fontWeight:c?500:400,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,flex:1,minWidth:0},children:u})]}),o.children.map((e,s)=>(0,E.jsx)(XX,{node:e,activePathIds:t,depth:n+1,isLast:s===o.children.length-1,parentLines:[...i,!r],onSelect:a},e.entry.id))]})}function ZX({tree:e,activeLeafId:t,onLeafChange:n,inline:r,containerRef:i,open:a,onToggle:o,hasSession:s,compact:c}){let{t:l}=N(),[u,f]=(0,d.useState)(!1),m=a===void 0?u:a,h=(0,d.useRef)(null),[g,_]=(0,d.useState)(null);(0,d.useEffect)(()=>{if(!m||!r)return;let e=i?.current??h.current;if(!e)return;let t=()=>{if(document.hidden)return;let t=e.getBoundingClientRect();_({top:t.bottom,left:t.left,width:t.width})};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[m,r,i]);let v=(0,d.useMemo)(()=>KX(e,t),[e,t]),y=(0,d.useCallback)(e=>{n(e)},[n]),b=s?YX(e)?null:l(`i18n.noBranches`):l(`i18n.noActiveSession`),x=(e.length>0?qX(e[0]):null)?.node??null,S=!b&&x&&x.children.length>1,C=(0,E.jsxs)(`svg`,{width:p.base,height:p.base,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,E.jsx)(`line`,{x1:`6`,y1:`3`,x2:`6`,y2:`15`}),(0,E.jsx)(`circle`,{cx:`18`,cy:`6`,r:`3`}),(0,E.jsx)(`circle`,{cx:`6`,cy:`18`,r:`3`}),(0,E.jsx)(`path`,{d:`M18 9a9 9 0 0 1-9 9`})]}),w=(0,E.jsx)(`svg`,{width:p.xs,height:p.xs,viewBox:`0 0 10 10`,fill:`none`,stroke:`var(--text-dim)`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{marginLeft:2,transform:m?`rotate(180deg)`:`none`,transition:`transform 0.15s`},children:(0,E.jsx)(`polyline`,{points:`2 3.5 5 6.5 8 3.5`})});return r?(0,E.jsxs)(`div`,{style:{height:`100%`,display:`flex`,alignItems:`stretch`},children:[(0,E.jsxs)(`button`,{ref:h,onClick:()=>o?o():f(e=>!e),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,alignSelf:`center`,width:32,height:32,padding:0,background:m?`var(--bg-selected)`:`transparent`,border:`1px solid`+(m?` var(--accent)`:` var(--border)`),borderRadius:7,cursor:`pointer`,color:m?`var(--text)`:`var(--text-muted)`,transition:`color 0.12s, background 0.12s, border-color 0.12s`,"--hover-color":`var(--text)`,"--hover-bg":`var(--bg-selected)`,"--hover-border":`color-mix(in srgb, var(--accent) 35%, transparent)`},className:`hover-shift`,"aria-label":l(`i18n.branches`),"aria-pressed":m,children:[C,!c&&(0,E.jsx)(`span`,{children:l(`i18n.branches`)})]}),m&&g&&(0,E.jsx)(`div`,{style:{position:`fixed`,top:g.top,left:g.left,width:g.width,background:`var(--bg)`,borderBottom:`1px solid var(--border)`,zIndex:1500},children:S&&x?(0,E.jsx)(`div`,{style:{padding:`4px 12px 8px 12px`,maxHeight:260,overflowY:`auto`},children:x.children.map((e,t)=>(0,E.jsx)(XX,{node:e,activePathIds:v,depth:0,isLast:t===x.children.length-1,parentLines:[],onSelect:y},e.entry.id))}):(0,E.jsx)(`div`,{style:{padding:`10px 16px`,fontSize:`var(--text-base)`,color:`var(--text-muted)`,fontStyle:`italic`},children:b})})]}):(0,E.jsxs)(`div`,{style:{borderBottom:`1px solid var(--border)`,background:`var(--bg)`,flexShrink:0,position:`relative`},children:[(0,E.jsxs)(`button`,{onClick:()=>f(e=>!e),style:{display:`flex`,alignItems:`center`,gap:6,width:`100%`,padding:`5px 12px`,background:`none`,border:`none`,cursor:`pointer`,color:`var(--text-muted)`,fontSize:`var(--text-sm)`,textAlign:`left`},children:[C,(0,E.jsx)(`span`,{style:{color:`var(--text-muted)`},children:l(`i18n.branches`)}),w]}),m&&(0,E.jsx)(`div`,{style:{position:`absolute`,top:`100%`,left:0,right:0,background:`var(--bg)`,borderBottom:`1px solid var(--border)`,boxShadow:`0 4px 12px var(--shadow-color)`,zIndex:100},children:S&&x?(0,E.jsx)(`div`,{style:{padding:`4px 12px 8px 12px`,maxHeight:260,overflowY:`auto`},children:x.children.map((e,t)=>(0,E.jsx)(XX,{node:e,activePathIds:v,depth:0,isLast:t===x.children.length-1,parentLines:[],onSelect:y},e.entry.id))}):(0,E.jsx)(`div`,{style:{padding:`10px 16px`,fontSize:`var(--text-base)`,color:`var(--text-muted)`,fontStyle:`italic`},children:b??l(`i18n.noBranches`)})})]})}var QX={preview:`_preview_1jmwf_1`,turn:`_turn_1jmwf_26`,number:`_number_1jmwf_47`,content:`_content_1jmwf_64`,user:`_user_1jmwf_69`,userText:`_userText_1jmwf_90`,assistant:`_assistant_1jmwf_104`,assistantJump:`_assistantJump_1jmwf_115`,outline:`_outline_1jmwf_143`,heading:`_heading_1jmwf_149`,paragraph:`_paragraph_1jmwf_150`},$X=Dx(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function eZ({className:e,variant:t=`default`,asChild:n=!1,...r}){let i=n?Ni:`span`;return(0,E.jsx)(i,{"data-slot":`badge`,"data-variant":t,className:Cm($X({variant:t}),e),...r})}function tZ({number:e,active:t=!1,highlighted:n=!1}){return(0,E.jsx)(eZ,{variant:`outline`,className:`h-[1.6em] w-[3em] rounded-[0.25em] border-[1.5px] p-0 font-mono text-[0.625rem] font-semibold leading-none`,style:{background:t?`color-mix(in srgb, var(--accent) 12%, transparent)`:n?`color-mix(in srgb, var(--accent) 10%, transparent)`:`transparent`,borderColor:t||n?`var(--accent)`:`color-mix(in srgb, var(--text) 65%, transparent)`,boxShadow:t?`0 0 0 2px var(--bg-panel)`:n?`0 0 0 1px var(--accent), 0 1px 2px -1px var(--shadow-color)`:`0 1px 2px -1px var(--shadow-color)`,transition:`transform 0.1s, background 0.1s, box-shadow 0.1s`,transform:n?`scale(1.15)`:`scale(1)`},children:(0,E.jsx)(`span`,{style:{fontSize:`var(--text-xs)`,lineHeight:1,fontFamily:`var(--font-mono)`,fontWeight:600,userSelect:`none`,color:t?`var(--accent)`:`var(--text)`},children:String(e)})})}var nZ=48,rZ=12,iZ=26,aZ=2,oZ=250,sZ=1600;function cZ(e){return typeof e.content==`string`?e.content.trim():e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
358
|
-
`).trim()}function
|
|
357
|
+
`);de(n),Ie(null),requestAnimationFrame(()=>{t&&(t.focus(),t.setSelectionRange(n.length,n.length),t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,200)}px`)})},insertText(e){let t=et.current;if(!t){de(t=>t+(t?` `:``)+e);return}let n=t.selectionStart??t.value.length,r=t.selectionEnd??t.value.length,i=t.value.slice(0,n),a=t.value.slice(r),o=i.length>0&&!i.endsWith(` `)?` `:``,s=i+o+e+a;de(s),Ie(null),requestAnimationFrame(()=>{if(!t)return;let r=n+o.length+e.length;t.setSelectionRange(r,r),t.focus(),t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,200)}px`})},fillInput(e){let t=et.current;de(e),Ie(null),requestAnimationFrame(()=>{if(!t)return;t.focus();let n=e.length;t.setSelectionRange(n,n),t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,200)}px`})},addImages(e){vt(e)}}));let vt=(0,d.useCallback)(async e=>{if(i)return;let t=Math.max(0,10-gt.current.length-_t.current),n=e.filter(e=>e.type.startsWith(`image/`)&&e.size<=10485760).slice(0,t);if(n.length){_t.current+=n.length;try{let e=await Promise.all(n.map(e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let n=r.result.split(`,`)[1];t({data:n,mimeType:e.type,previewUrl:URL.createObjectURL(e)})},r.onerror=n,r.readAsDataURL(e)})));je(t=>{let n=e.slice(0,Math.max(0,10-t.length));return e.slice(n.length).forEach(lX),[...t,...n]})}finally{_t.current-=n.length}}},[i]),yt=(0,d.useCallback)(e=>{je(t=>{let n=[...t],[r]=n.splice(e,1);return r&&lX(r),n})},[]),bt=(0,d.useCallback)(()=>{je(e=>(e.forEach(lX),[]))},[]),xt=(0,d.useCallback)(()=>{de(``),Ie(null),He(!1),I&&qY(I),mt.current&&mt.current!==I&&qY(mt.current),bt(),et.current&&(et.current.style.height=`auto`)},[bt,I]);(0,d.useEffect)(()=>{!I||mt.current!==I||KY(I,{value:ue,images:Ae.map(oX)})},[Ae,I,ue]),(0,d.useEffect)(()=>{let e=mt.current;if(e===I)return;e&&KY(e,{value:ht.current,images:gt.current.map(oX)});let t=I?GY(I):null;if(mt.current=I,de(t?.value??``),Ie(null),He(!1),je(e=>(e.forEach(lX),cX(t?.images))),I){let e=XY(I);e!==null&&(de(e),ZY(I))}},[I]),(0,d.useEffect)(()=>{let e=et.current;e&&(e.style.height=`auto`,ue&&(e.style.height=`${Math.min(e.scrollHeight,200)}px`))},[ue]),(0,d.useEffect)(()=>()=>{gt.current.forEach(lX)},[]);let St=(0,d.useCallback)(async()=>{let t=ue.trim();if(!t&&!Ae.length||i||te)return;ae?.();let n=I??``;if(!Ae.length&&t.startsWith(`/`)&&F){YY(n,t),xt();let e=await F(t);if(e.handled){e.error&&de(t),ZY(n);return}}YY(n,t),xt();try{await e(t,Ae.length?Ae:void 0)}finally{ZY(n)}},[ue,Ae,i,te,I,F,e,xt,ae]),Ct=HK({value:ue,commands:M,skillDormancy:$e,builtinDisabled:i,onLoadCommands:ee,onApply:(0,d.useCallback)(e=>{let t=`/${e.name} `;de(t),requestAnimationFrame(()=>{let e=et.current;e&&(e.focus(),e.setSelectionRange(t.length,t.length),e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`)})},[])}),wt=!!ue.trim()&&Ae.length===0,Tt=(0,d.useCallback)((e,t)=>{if(!L){Ie(null);return}let n=t??e.length;Ie(Cq(e.slice(0,n)))},[L]),Et=Fe?.query??null,Dt=d.useMemo(()=>Et!==null&&Ge&&Ge.cwd===L?Dq(Ge.entries,Et):[],[Et,Ge,L]),Ot=!!(Et&&Ge?.truncated&&Ge.cwd===L);(0,d.useEffect)(()=>{if(!Ot||!L||!Et)return;let e=L,t=Et,n=setTimeout(()=>{fetch(`/api/file-index?cwd=${encodeURIComponent(e)}&q=${encodeURIComponent(t)}`).then(e=>{if(!e.ok)throw Error(`file search failed: ${e.status}`);return e.json()}).then(n=>Xe({cwd:e,query:t,matches:n.matches??[]})).catch(()=>{})},150);return()=>clearTimeout(n)},[Ot,Et,L]);let kt=Ot&&Ye!==null&&Ye.cwd===L&&Ye.query===Et,At=kt?Ye.matches:Dt,jt=Fe===null?null:`${Fe.start}:${+!!Fe.quoted}:${Fe.query}`;(0,d.useEffect)(()=>{if(jt===null){Re(!1),Be(0);return}Re(!0),Be(0)},[jt]);let Mt=Fe!==null;(0,d.useEffect)(()=>{if(!Mt||!L)return;let e=ft.current;if(e&&e.cwd===L&&Date.now()-e.fetchedAt<1e4||pt.current===L)return;pt.current=L;let t=L;Je(!0),fetch(`/api/file-index?cwd=${encodeURIComponent(t)}`).then(e=>{if(!e.ok)throw Error(`file index failed: ${e.status}`);return e.json()}).then(e=>{Ke({cwd:t,entries:Tq(e.files??[]),truncated:!!e.truncated}),ft.current={cwd:t,fetchedAt:Date.now()}}).catch(()=>{ft.current=null}).finally(()=>{pt.current=null,Je(!1)})},[Mt,L]);let Nt=(0,d.useCallback)(e=>{if(!Fe)return;let t=et.current?.selectionStart??ue.length,n=ue.slice(0,Fe.start),r=ue.slice(t);Fe.quoted&&r.startsWith(`"`)&&(r=r.slice(1));let i=Oq(e.path,e.isDir,Fe.quoted),a=n+i.text+r,o=n.length+i.cursorOffset;de(a),Ie(Cq(a.slice(0,o))),requestAnimationFrame(()=>{let e=et.current;e&&(e.focus(),e.setSelectionRange(o,o),e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`)})},[Fe,ue]);(0,d.useEffect)(()=>{ze>=At.length&&Be(Math.max(0,At.length-1))},[At.length,ze]),(0,d.useEffect)(()=>{ut.current.length=At.length},[At.length]),(0,d.useEffect)(()=>{Le&&ut.current[ze]?.scrollIntoView({block:`nearest`,inline:`nearest`})},[ze,Le]),(0,d.useEffect)(()=>{Ue>=A.length&&We(Math.max(0,A.length-1))},[A.length,Ue]),(0,d.useEffect)(()=>{dt.current.length=A.length},[A.length]),(0,d.useEffect)(()=>{Ve&&dt.current[Ue]?.scrollIntoView({block:`nearest`,inline:`nearest`})},[Ue,Ve]);let Pt=(0,d.useCallback)(e=>{de(e),He(!1),We(0),Ie(null),requestAnimationFrame(()=>{let t=et.current;t&&(t.focus(),t.setSelectionRange(e.length,e.length),t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,200)}px`)})},[]),Ft=(0,d.useCallback)(e=>{let t=ue.trim();if(!t&&!Ae.length||Ae.length)return;ae?.();let i=e===`steer`?`steer`:`followUp`;if(t.startsWith(`/`)&&oe){oe(t,i,Ae.length?Ae:void 0),xt();return}e===`steer`&&n?n(t,Ae.length?Ae:void 0):e===`followup`&&r&&r(t,Ae.length?Ae:void 0),xt()},[ue,Ae,oe,n,r,xt,ae]),It=(0,d.useCallback)(e=>{let a=e.nativeEvent,o=Date.now()-lt.current<iX,s=ct.current||a.isComposing||a.keyCode===229;if(e.key===`Enter`&&!e.shiftKey&&(s||o)){o&&e.preventDefault();return}if(Ve&&!s){if(e.key===`ArrowDown`){e.preventDefault(),We(e=>Math.min(Math.max(0,A.length-1),e+1));return}if(e.key===`ArrowUp`){e.preventDefault(),We(e=>Math.max(0,e-1));return}if(e.key===`Escape`){e.preventDefault(),He(!1);return}if((e.key===`Tab`||e.key===`Enter`&&!e.shiftKey)&&A[Ue]){e.preventDefault(),Pt(A[Ue]);return}}if(!Ct.handleKeyDown(e)){if(Le&&Fe!==null&&!s){if(e.key===`ArrowDown`){e.preventDefault(),Be(e=>Math.min(Math.max(0,At.length-1),e+1));return}if(e.key===`ArrowUp`){e.preventDefault(),Be(e=>Math.max(0,e-1));return}if(e.key===`Escape`){e.preventDefault(),Re(!1);return}if((e.key===`Tab`||e.key===`Enter`&&!e.shiftKey)&&At[ze]){e.preventDefault(),Nt(At[ze]);return}}if(e.key===`ArrowUp`&&!s&&!i&&A.length>0&&ue.trim().length===0){e.preventDefault(),Re(!1),We(A.length-1),He(!0);return}if(e.key===`Escape`&&!s&&i&&t){e.preventDefault(),t();return}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ue.trim().length===0&&j&&fe>0?j():i&&(n||r)?Ft(n?`steer`:`followup`):St())}},[i,n,r,j,fe,t,Ct,Ft,St,Le,Fe,At,ze,Nt,Ve,A,Ue,Pt,ue]),Lt=(0,d.useCallback)(()=>{let e=et.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`)},[]),Rt=(0,d.useCallback)(e=>{let t=Array.from(e.clipboardData?.items??[]).filter(e=>e.type.startsWith(`image/`));if(!t.length)return;e.preventDefault();let n=t.map(e=>e.getAsFile()).filter(e=>e!==null);vt(n)},[vt]);(0,d.useEffect)(()=>{if(!Ct.open||!L)return;let e=L,t=!1;return Qe({cwd:e,values:{}}),fetch(`/api/skills?cwd=${encodeURIComponent(e)}`).then(e=>{if(!e.ok)throw Error(`skills fetch failed: ${e.status}`);return e.json()}).then(n=>{if(t)return;let r={};for(let e of n.skills??[])r[e.name]=e.disableModelInvocation;Qe({cwd:e,values:r})}).catch(()=>{t||Qe({cwd:e,values:{}})}),()=>{t=!0}},[Ct.open,L]);let zt=c&&c.length>0?c.map(e=>({provider:e.provider,modelId:e.id,name:e.name})).sort(YK):Object.entries(s??{}).map(([e,t])=>({provider:a?.provider??`unknown`,modelId:e,name:t})).sort(YK);XK(zt,_e),(0,d.useEffect)(()=>{xe.current?.scrollIntoView({block:`nearest`})},[ye,_e]);let Bt=a?zt.find(e=>e.modelId===a.modelId&&e.provider===a.provider)?.name??a.modelId:null;a&&Bt&&`${a.provider}${Bt}`;let Vt=y?Math.max(0,y.tokensBefore-y.estimatedTokensAfter):0,Ht=y?`${y.reason&&y.reason!==`manual`?`${y.reason[0].toUpperCase()}${y.reason.slice(1)} `:R(`chat.compacted`)} ${aX(y.tokensBefore)} -> ${aX(y.estimatedTokensAfter)} tokens (${R(`chat.tokensSaved`,{saved:aX(Vt)})})`:null,Ut=(()=>{let e=S??`auto`;return e===`auto`||!T?e:T[e]??e})(),Wt=Object.entries(rX).find(([,e])=>e===(b??`default`))?.[0]??`default`;return(0,d.useEffect)(()=>{let e=e=>{tt.current&&!tt.current.contains(e.target)&&nt.current&&!nt.current.contains(e.target)&&(me(!1),ve(``)),rt.current&&!rt.current.contains(e.target)&&Ce(!1),it.current&&!it.current.contains(e.target)&&Te(!1),at.current&&!at.current.contains(e.target)&&De(!1),ot.current&&!ot.current.contains(e.target)&&!et.current?.contains(e.target)&&He(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,d.useEffect)(()=>{ce||De(!1)},[ce]),(0,E.jsxs)(`div`,{style:{position:`relative`,zIndex:140,flexShrink:0,background:`transparent`,padding:`0 16px 8px`,paddingRight:ce?16:52},children:[(0,E.jsx)(`input`,{ref:st,type:`file`,accept:`image/*`,multiple:!0,disabled:i,style:{display:`none`},onChange:e=>{let t=Array.from(e.target.files??[]);vt(t),e.target.value=``}}),(0,E.jsxs)(`div`,{style:{maxWidth:820,margin:`0 auto`},children:[(0,E.jsx)(fX,{error:l}),(0,E.jsx)(pX,{warnings:u}),(k?.steering.length??0)+(k?.followUp.length??0)>0&&(0,E.jsxs)(`div`,{"data-testid":`queue-panel`,style:{marginBottom:8,border:`1px solid var(--border)`,borderRadius:6,background:`var(--bg-panel)`,padding:`5px 0`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8,padding:`2px 8px 4px 10px`},children:[(0,E.jsx)(`span`,{style:{fontSize:`var(--text-xs)`,fontFamily:`var(--font-mono)`,color:`var(--text-dim)`,textTransform:`uppercase`,letterSpacing:.4},children:R(`chat.queued`,{count:(k?.steering.length??0)+(k?.followUp.length??0)})}),j&&(0,E.jsx)(oi,{label:R(`chat.recallTitle`),children:(0,E.jsxs)(`button`,{"data-testid":`queue-recall`,onClick:j,style:{display:`flex`,alignItems:`center`,gap:6,padding:`4px 12px`,fontSize:`var(--text-base)`,color:`var(--text)`,background:`transparent`,border:`1px solid var(--border)`,borderRadius:7,cursor:`pointer`,transition:`background 0.12s, border-color 0.12s`,whiteSpace:`nowrap`,"--hover-bg":`var(--bg-hover)`,"--hover-border":`color-mix(in srgb, var(--accent) 45%, var(--border))`},className:`hover-shift`,children:[(0,E.jsx)(gr,{size:p.lg}),R(`chat.recall`)]})})]}),k?.steering.map((e,t)=>(0,E.jsx)(uX,{kind:`steer`,text:e},`steer-${t}`)),k?.followUp.map((e,t)=>(0,E.jsx)(uX,{kind:`follow-up`,text:e},`followup-${t}`))]}),O&&(0,E.jsxs)(`div`,{style:{marginBottom:8,padding:`5px 10px`,background:`color-mix(in srgb, var(--status-warning) 8%, transparent)`,border:`1px solid color-mix(in srgb, var(--status-warning) 25%, transparent)`,borderRadius:6,fontSize:`var(--text-base)`,color:`var(--status-warning)`,display:`flex`,alignItems:`center`,gap:6},children:[(0,E.jsx)(Br,{size:p.sm,style:{flexShrink:0}}),R(`chat.retrying`,{attempt:O.attempt,max:O.maxAttempts}),O.errorMessage&&(0,E.jsxs)(`span`,{style:{opacity:.7,marginLeft:4},children:[`— `,O.errorMessage]})]}),Ht&&(0,E.jsxs)(`div`,{style:{marginBottom:8,padding:`5px 10px`,background:`color-mix(in srgb, var(--status-success) 8%, transparent)`,border:`1px solid color-mix(in srgb, var(--status-success) 24%, transparent)`,borderRadius:6,fontSize:`var(--text-base)`,color:`color-mix(in srgb, var(--status-success) 95%, transparent)`,display:`flex`,alignItems:`center`,gap:6},children:[(0,E.jsx)(ur,{size:p.sm,style:{flexShrink:0}}),Ht]}),v&&(0,E.jsx)(`div`,{role:`alert`,style:{marginBottom:8,padding:`7px 10px`,background:`color-mix(in srgb, var(--status-error) 7%, transparent)`,border:`1px solid color-mix(in srgb, var(--status-error) 30%, transparent)`,borderRadius:6,color:`var(--status-error)`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-base)`,lineHeight:1.5,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:v}),Ae.length>0&&(0,E.jsx)(`div`,{style:{display:`flex`,gap:6,marginBottom:6,flexWrap:`wrap`},children:Ae.map((e,t)=>(0,E.jsxs)(`div`,{style:{position:`relative`,flexShrink:0},children:[(0,E.jsx)(`img`,{src:e.previewUrl,alt:``,style:{width:56,height:56,objectFit:`cover`,borderRadius:6,border:`1px solid var(--border)`,display:`block`}}),(0,E.jsx)(`button`,{onClick:()=>yt(t),style:{position:`absolute`,top:-4,right:-4,width:16,height:16,borderRadius:`50%`,background:`var(--bg-panel)`,border:`1px solid var(--border)`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,padding:0,color:`var(--text-muted)`},children:(0,E.jsx)(ni,{size:8,strokeWidth:4.5})})]},t))}),(0,E.jsxs)(`div`,{style:{position:`relative`,minWidth:0},children:[Ve&&A.length>0&&(0,E.jsxs)(`div`,{ref:ot,style:{position:`absolute`,left:0,right:0,bottom:`calc(100% + 8px)`,zIndex:120,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:8,boxShadow:`0 -6px 20px var(--shadow-color)`,overflow:`hidden`,maxHeight:`min(44vh, 360px)`},children:[(0,E.jsx)(oi,{label:`Input history`,wrapperStyle:{display:`flex`},children:(0,E.jsx)(`div`,{style:{height:30,padding:`0 10px`,borderBottom:`1px solid var(--border)`,display:`flex`,alignItems:`center`,color:`var(--text-dim)`},children:(0,E.jsx)(zr,{size:p.xl,strokeWidth:1.8,"aria-hidden":`true`})})}),(0,E.jsx)(`div`,{style:{maxHeight:`calc(min(44vh, 360px) - 31px)`,overflowY:`auto`,padding:4},children:A.map((e,t)=>(0,E.jsxs)(`button`,{ref:e=>{dt.current[t]=e},type:`button`,onMouseDown:t=>{t.preventDefault(),Pt(e)},onMouseEnter:()=>We(t),style:{width:`100%`,display:`flex`,alignItems:`flex-start`,gap:8,padding:`7px 8px`,border:`none`,borderRadius:6,background:t===Ue?`var(--bg-selected)`:`none`,color:`var(--text)`,cursor:`pointer`,textAlign:`left`,fontSize:`var(--text-md)`,lineHeight:1.45},children:[(0,E.jsx)(`span`,{style:{flexShrink:0,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`,paddingTop:1},children:t+1}),(0,E.jsx)(`span`,{style:{minWidth:0,display:`-webkit-box`,WebkitBoxOrient:`vertical`,WebkitLineClamp:2,overflow:`hidden`,overflowWrap:`anywhere`},children:e})]},`${t}:${e}`))})]}),(0,E.jsx)(UK,{palette:Ct,loading:P,skillDormancy:$e}),Le&&Fe!==null&&(()=>{let e=qe&&(!Ge||Ge.cwd!==L),t=At.length===1?R(`chat.match`):R(`chat.matches`,{count:At.length}),n=Ge?.truncated&&!kt?Fe.query?R(`chat.searchingAll`):R(`chat.indexTruncated`):``;return(0,E.jsxs)(`div`,{style:{position:`absolute`,left:0,right:0,bottom:`calc(100% + 8px)`,zIndex:120,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:8,boxShadow:`0 -6px 20px var(--shadow-color)`,overflow:`hidden`,maxHeight:`min(48vh, 400px)`},children:[(0,E.jsxs)(`div`,{style:{padding:`8px 10px`,borderBottom:`1px solid var(--border)`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8,fontSize:`var(--text-sm)`,color:`var(--text-dim)`},children:[(0,E.jsx)(`span`,{children:e?R(`chat.loadingFiles`):R(`chat.files`,{label:t,hint:n})}),(0,E.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`},children:R(`chat.tabEnter`)})]}),(0,E.jsx)(`div`,{style:{maxHeight:`calc(min(48vh, 400px) - 34px)`,overflowY:`auto`,padding:4},children:!e&&At.length===0?(0,E.jsx)(`div`,{style:{padding:`6px 8px`,fontSize:`var(--text-base)`,color:`var(--text-dim)`},children:R(Ot&&!kt?`chat.searching`:`chat.noMatchingFiles`)}):At.map((e,t)=>{let n=t===ze,r=e.path.split(`/`).pop()??e.path,i=e.path.slice(0,e.path.length-r.length);return(0,E.jsxs)(`button`,{ref:e=>{ut.current[t]=e},type:`button`,onMouseDown:t=>{t.preventDefault(),Nt(e)},onMouseEnter:()=>Be(t),style:{width:`100%`,display:`flex`,alignItems:`center`,gap:8,padding:`6px 8px`,border:`none`,borderRadius:6,background:n?`var(--bg-selected)`:`none`,color:`var(--text)`,cursor:`pointer`,textAlign:`left`,fontSize:`var(--text-md)`,fontFamily:`var(--font-mono)`},children:[(0,E.jsx)(`span`,{style:{flexShrink:0,display:`flex`,alignItems:`center`},children:e.isDir?(0,E.jsx)(sn,{size:p.xl}):Fn(r,14)}),(0,E.jsxs)(`span`,{style:{minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:[i&&(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`},children:i}),r,e.isDir&&(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`},children:`/`})]})]},`${e.isDir?`d`:`f`}:${e.path}`)})})]})})(),(0,E.jsxs)(`div`,{style:{minWidth:0,display:`flex`,gap:8,alignItems:`center`,background:`var(--bg)`,border:`1px solid ${Ne?`var(--tool-bg)`:`color-mix(in srgb, var(--border) 70%, transparent)`}`,borderRadius:14,padding:`10px 10px 10px 14px`,zIndex:96,boxShadow:`0 1px 2px var(--shadow-color), 0 8px 24px -12px var(--shadow-color), 0 0 40px -10px var(--input-glow), -64px 0 48px -14px var(--input-glow), 64px 0 48px -14px var(--input-glow)`,transition:`border-color 0.15s, background 0.15s, box-shadow 0.15s`},children:[i&&(0,E.jsx)(`span`,{"aria-hidden":!0,style:{width:8,height:8,borderRadius:`50%`,background:`var(--accent)`,flexShrink:0,alignSelf:`flex-start`,marginTop:16,animation:`blink 1s ease-in-out infinite`}}),(0,E.jsx)(`textarea`,{"data-testid":`chat-input`,ref:et,value:ue,onChange:e=>{de(e.target.value),He(!1),Tt(e.target.value,e.target.selectionStart)},onSelect:e=>{let t=e.currentTarget;Tt(t.value,t.selectionStart)},onKeyDown:It,onCompositionStart:()=>{ct.current=!0},onCompositionEnd:e=>{ct.current=!1,lt.current=Date.now();let t=e.currentTarget;Tt(t.value,t.selectionStart)},onInput:Lt,onPaste:Rt,placeholder:fe>0?R(`chat.recallPlaceholder`):i&&(n||r)?R(`chat.steerPlaceholder`):i?R(`chat.agentPlaceholder`):L?`${L}\n${R(`chat.messagePlaceholder`)}`:R(`chat.messagePlaceholder`),rows:L?2:1,style:{flex:1,minWidth:0,width:`100%`,background:`none`,border:`none`,outline:`none`,resize:`none`,color:`var(--text)`,caretColor:i?`var(--accent)`:void 0,fontSize:`var(--text-xl)`,lineHeight:1.6,fontFamily:`inherit`,minHeight:24,maxHeight:200,overflow:`auto`}}),i?(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,flexShrink:0,alignSelf:`flex-end`},children:[n&&(0,E.jsx)(oi,{label:Ae.length?R(`chat.queueImageBlocked`):R(`chat.steerTooltip`),children:(0,E.jsxs)(`button`,{"data-testid":`steer-button`,onClick:()=>Ft(`steer`),disabled:!wt,style:{display:`flex`,alignItems:`center`,gap:5,padding:`7px 12px`,background:wt?`color-mix(in srgb, var(--status-warning) 12%, transparent)`:`none`,border:`1px solid color-mix(in srgb, var(--status-warning) 35%, transparent)`,borderRadius:8,color:wt?`var(--status-warning)`:`var(--text-dim)`,cursor:wt?`pointer`:`not-allowed`,fontSize:`var(--text-lg)`,fontWeight:600,letterSpacing:`-0.01em`,transition:`background 0.12s`},children:[(0,E.jsx)(Fr,{size:p.base,strokeWidth:4.3,style:{flexShrink:0}}),R(`chat.steer`)]})}),r&&(0,E.jsx)(oi,{label:Ae.length?R(`chat.queueImageBlocked`):R(`chat.followUpTooltip`),children:(0,E.jsxs)(`button`,{"data-testid":`followup-button`,onClick:()=>Ft(`followup`),disabled:!wt,style:{display:`flex`,alignItems:`center`,gap:5,padding:`7px 12px`,background:wt?`color-mix(in srgb, var(--status-info) 12%, transparent)`:`none`,border:`1px solid color-mix(in srgb, var(--status-info) 35%, transparent)`,borderRadius:8,color:wt?`var(--status-info)`:`var(--text-dim)`,cursor:wt?`pointer`:`not-allowed`,fontSize:`var(--text-lg)`,fontWeight:600,letterSpacing:`-0.01em`,transition:`background 0.12s`},children:[(0,E.jsx)(kr,{size:p.base,strokeWidth:4.3,style:{flexShrink:0}}),R(`chat.followUp`)]})})]}):(0,E.jsxs)(`button`,{onClick:St,disabled:!ue.trim()&&!Ae.length||te,style:{flexShrink:0,alignSelf:`flex-end`,display:`flex`,alignItems:`center`,gap:6,padding:`7px 14px`,background:ue.trim()||Ae.length?`var(--accent)`:`var(--bg-panel)`,border:`none`,borderRadius:8,color:ue.trim()||Ae.length?`var(--on-accent)`:`var(--text-dim)`,cursor:(ue.trim()||Ae.length)&&!te?`pointer`:`not-allowed`,fontSize:`var(--text-lg)`,fontWeight:600,letterSpacing:`-0.01em`,boxShadow:ue.trim()||Ae.length?`0 1px 3px var(--accent-glow)`:`none`,transition:`background 0.15s, box-shadow 0.15s`},children:[(0,E.jsx)(lr,{size:p.xl,strokeWidth:3.4,style:{flexShrink:0}}),R(`chat.send`)]})]})]}),Ne&&(0,E.jsxs)(`div`,{className:`text-xs px-2 py-1`,style:{color:Pe?`var(--text-muted)`:`var(--accent)`,marginTop:4},children:[R(`chat.shell`),` · `,R(Pe?`chat.outputLocal`:`chat.outputModel`)]}),(0,E.jsxs)(`div`,{style:{marginTop:8,display:ce?`grid`:`flex`,gridTemplateColumns:ce?`minmax(0, 1fr) auto`:void 0,alignItems:`center`,gap:6,rowGap:4,flexWrap:`wrap`},children:[(0,E.jsxs)(`div`,{style:{flex:ce?`1 1 auto`:`0 0 auto`,minWidth:0,display:`flex`,alignItems:`center`,gap:2},children:[(0,E.jsx)(oi,{label:R(`chat.attachImage`),children:(0,E.jsx)(`button`,{onClick:()=>st.current?.click(),disabled:i,style:{flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,width:32,height:32,padding:0,background:`none`,border:`none`,borderRadius:9,color:`var(--accent)`,cursor:i?`not-allowed`:`pointer`,opacity:i?.5:1,transition:`background 0.12s, color 0.12s`,"--hover-bg":`var(--bg-hover)`,"--hover-color":`var(--accent)`},className:i?void 0:`hover-shift`,children:(0,E.jsx)(Er,{size:p[`2xl`],strokeWidth:1.8,style:{color:`var(--accent)`,flexShrink:0}})})}),f&&(0,E.jsx)(ZK,{value:a??null,options:zt,onChange:f,disabled:i,variant:`chat`,isAutoSelection:o})]}),!ce&&!f&&(0,E.jsx)(`div`,{style:{flex:1}}),(0,E.jsxs)(`div`,{ref:at,style:{flex:`0 0 auto`,display:`flex`,alignItems:`center`,justifyContent:`flex-end`,position:`relative`,marginLeft:ce?0:`auto`},children:[ce&&(0,E.jsx)(oi,{label:Ee?void 0:R(`chat.moreControls`),children:(0,E.jsx)(`button`,{type:`button`,"aria-label":R(`chat.moreControls`),"aria-expanded":Ee,"aria-hidden":Ee||void 0,tabIndex:Ee?-1:void 0,onClick:()=>{me(!1),ve(``),De(!0)},style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:`100%`,height:32,padding:`8px 10px`,background:`none`,border:`none`,borderRadius:9,color:`var(--text-muted)`,cursor:Ee?`default`:`pointer`,fontSize:`var(--text-base)`,fontWeight:500,visibility:Ee?`hidden`:`visible`,pointerEvents:Ee?`none`:`auto`,transition:`background 0.12s, color 0.12s`,"--hover-bg":`var(--bg-hover)`,"--hover-color":`var(--text)`},className:Ee?void 0:`hover-shift`,children:R(`chat.moreControls`)})}),(0,E.jsxs)(`div`,{style:{display:ce?Ee?`flex`:`none`:`flex`,alignItems:`center`,gap:ce?1:2,...ce?{position:`absolute`,right:0,bottom:0,zIndex:60,padding:1,width:`max-content`,maxWidth:`calc(100vw - 32px)`,flexWrap:`nowrap`,justifyContent:`flex-end`,border:`1px solid color-mix(in srgb, var(--border) 72%, transparent)`,borderRadius:10,background:`color-mix(in srgb, var(--bg-panel) 92%, var(--bg))`,boxShadow:`0 8px 24px var(--shadow-color)`,backdropFilter:`blur(10px)`}:null},children:[(0,E.jsx)(`div`,{style:{display:`flex`,alignItems:`center`},children:(0,E.jsx)(oi,{label:i?R(`chat.stopAgent`):void 0,children:(0,E.jsxs)(`button`,{onClick:t,style:{display:`flex`,alignItems:`center`,gap:6,padding:`8px 14px`,height:32,background:le?`var(--status-error)`:`color-mix(in srgb, var(--status-error) 8%, transparent)`,border:le?`1px solid var(--status-error)`:`1px solid color-mix(in srgb, var(--status-error) 30%, transparent)`,borderRadius:9,color:le?`#fff`:`var(--status-error)`,cursor:`pointer`,fontSize:`var(--text-base)`,fontWeight:600,whiteSpace:`nowrap`,letterSpacing:`-0.01em`,transition:`background 0.12s`,visibility:i?`visible`:`hidden`,pointerEvents:i?`auto`:`none`,"--hover-bg":le?`color-mix(in srgb, var(--status-error) 82%, #000)`:`color-mix(in srgb, var(--status-error) 16%, transparent)`,"--hover-color":le?`#fff`:`var(--status-error)`},className:`hover-shift`,children:[(0,E.jsx)(qr,{size:p.xs,fill:`currentColor`}),R(`chat.stop`)]})})}),C&&(0,E.jsxs)(`div`,{ref:it,style:{position:`relative`},children:[(0,E.jsx)(oi,{label:R(`chat.changeReasoning`,{level:Ut}),children:(0,E.jsxs)(`button`,{onClick:()=>!i&&Te(e=>!e),disabled:i,"aria-label":R(`chat.changeReasoningLabel`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:5,padding:ce?`0 6px`:`8px 12px`,width:ce?`auto`:void 0,height:32,background:we?`var(--bg-hover)`:`none`,border:`none`,borderRadius:9,color:`var(--text-muted)`,cursor:i?`not-allowed`:`pointer`,fontSize:`var(--text-base)`,opacity:i?.5:1,transition:`background 0.12s, color 0.12s`,"--hover-bg":`var(--bg-hover)`,"--hover-color":`var(--text)`},className:i?void 0:`hover-shift`,children:[(0,E.jsx)(Dr,{size:p.base,fill:`currentColor`,style:{color:`var(--bulb-warning)`,flexShrink:0}}),(!ce||Ee)&&(0,E.jsx)(`span`,{style:{whiteSpace:`nowrap`},children:Ut})]})}),we&&(0,E.jsx)(`div`,{style:{position:`absolute`,bottom:`calc(100% + 6px)`,right:0,zIndex:100,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:8,boxShadow:`0 -4px 16px var(--shadow-color)`,overflow:`hidden`,minWidth:180},children:yi.filter(e=>!w||e===`auto`||w.includes(e)).map(e=>{let t=(S??`auto`)===e,n=R(Si[e]),r=e!==`auto`&&T?T[e]:void 0;return(0,E.jsx)(tX,{active:t,onSelect:()=>{if(Te(!1),!t){if((e===`xhigh`||e===`max`)&&!T?.[e]){ke(e);return}C(e)}},label:(0,E.jsxs)(E.Fragment,{children:[r!=null&&r!==e?r:e,r!=null&&r!==e&&(0,E.jsxs)(`span`,{style:{fontSize:`var(--text-xs)`,color:`var(--text-dim)`,fontFamily:`var(--font-mono)`,marginLeft:5},children:[`(`,e,`)`]})]}),desc:n},e)})})]}),Oe&&a&&(0,E.jsx)(`div`,{style:{position:`fixed`,inset:0,zIndex:1e3,background:`rgba(0, 0, 0, 0.45)`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,E.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,style:{background:`var(--bg-panel)`,border:`1px solid var(--border)`,borderRadius:10,boxShadow:`0 12px 40px var(--shadow-color)`,width:`min(420px, calc(100vw - 32px))`,padding:18},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-xl)`,fontWeight:600,color:`var(--text)`,marginBottom:8},children:R(`chat.thinkingMapTitle`)}),(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--text-muted)`,lineHeight:1.7,marginBottom:16},children:R(`chat.thinkingMapBody`,{level:Oe})}),(0,E.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8},children:[(0,E.jsx)(`button`,{type:`button`,onClick:()=>ke(null),style:{padding:`5px 14px`,background:`var(--bg-panel)`,border:`1px solid var(--border)`,borderRadius:6,color:`var(--text-muted)`,fontSize:`var(--text-base)`,cursor:`pointer`},children:R(`chat.cancel`)}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>{D?.({provider:a.provider,modelId:a.modelId}),ke(null)},style:{padding:`5px 14px`,background:`var(--accent)`,border:`none`,borderRadius:6,color:`var(--on-accent, #fff)`,fontSize:`var(--text-base)`,fontWeight:600,cursor:`pointer`},children:R(`chat.thinkingMapGo`)})]})]})}),x&&(0,E.jsxs)(`div`,{ref:rt,style:{position:`relative`},children:[(0,E.jsx)(oi,{label:`${R(`chat.changeToolPreset`)}: ${Wt}`,children:(0,E.jsxs)(`button`,{onClick:()=>!i&&Ce(e=>!e),disabled:i,"aria-label":R(`chat.changeToolPreset`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:5,padding:ce?`0 6px`:`8px 12px`,width:ce?`auto`:void 0,height:32,background:Se?`var(--bg-hover)`:`none`,border:`none`,borderRadius:9,color:`var(--text-muted)`,cursor:i?`not-allowed`:`pointer`,fontSize:`var(--text-base)`,opacity:i?.5:1,transition:`background 0.12s, color 0.12s`,"--hover-bg":`var(--bg-hover)`,"--hover-color":`var(--text)`},className:i?void 0:`hover-shift`,children:[(0,E.jsx)(ti,{size:p.base,style:{color:`var(--status-info)`,flexShrink:0}}),(!ce||Ee)&&(0,E.jsx)(`span`,{style:{whiteSpace:`nowrap`},children:Wt})]})}),Se&&(0,E.jsx)(`div`,{style:{position:`absolute`,bottom:`calc(100% + 6px)`,right:0,zIndex:100,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:8,boxShadow:`0 -4px 16px var(--shadow-color)`,overflow:`hidden`,minWidth:120},children:nX.map(e=>{let t=rX[e],n=(b??`default`)===t,r=e===`off`?R(`chat.noTools`):e==="default"?R(`chat.builtInTools`,{count:4}):R(`chat.allBuiltInTools`);return(0,E.jsx)(tX,{active:n,onSelect:()=>{Ce(!1),n||x(t)},label:e,desc:r},e)})})]}),h&&(0,E.jsx)(`div`,{children:(0,E.jsx)(oi,{label:(0,E.jsxs)(`span`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,E.jsx)(`span`,{children:R(`chat.reloadFromDisk`)}),(0,E.jsx)(`span`,{style:{opacity:.85,fontSize:`0.85em`,whiteSpace:`normal`,maxWidth:260},children:R(`chat.reloadFromDiskHint`)})]}),children:(0,E.jsx)(`button`,{onClick:()=>!i&&h(),disabled:i,"aria-label":R(`chat.reloadFromDisk`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:ce?`auto`:36,height:32,padding:`0 6px`,background:`none`,border:`none`,borderRadius:9,color:`var(--text-muted)`,cursor:i?`not-allowed`:`pointer`,opacity:i?.5:1,transition:`background 0.12s, color 0.12s`,"--hover-bg":`var(--bg-hover)`,"--hover-color":`var(--text)`},className:i?void 0:`hover-shift`,children:(0,E.jsx)(wr,{size:p.lg,"aria-hidden":`true`})})})}),m&&(0,E.jsx)(`div`,{children:(0,E.jsx)(oi,{label:R(_?`chat.stopCompaction`:`chat.compactContext`),children:(0,E.jsx)(`button`,{onClick:_?g:m,disabled:i&&!_,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:5,padding:`0 6px`,width:ce?`auto`:36,height:32,background:_?`color-mix(in srgb, var(--status-error) 8%, transparent)`:`none`,border:`none`,borderRadius:9,color:_?`#ef4444`:`var(--text-muted)`,cursor:i&&!_?`not-allowed`:`pointer`,fontSize:`var(--text-base)`,opacity:i&&!_?.5:1,transition:`background 0.12s, color 0.12s`,"--hover-bg":_?`color-mix(in srgb, var(--status-error) 16%, transparent)`:`var(--bg-hover)`,"--hover-color":_?`#ef4444`:`var(--text)`},className:i&&!_?void 0:`hover-shift`,"aria-label":R(_?`chat.stopCompaction`:`chat.compactContext`),children:_?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(qr,{size:p.xs,fill:`currentColor`}),Ee&&(0,E.jsx)(`span`,{style:{whiteSpace:`nowrap`},children:R(`chat.compacting`)})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(br,{size:p.base,style:{color:`var(--status-info)`,flexShrink:0}}),Ee&&(0,E.jsx)(`span`,{style:{whiteSpace:`nowrap`},children:R(`chat.compact`)})]})})})}),ie!==void 0&&(0,E.jsx)(oi,{label:R(re?`chat.disableSound`:`chat.enableSound`),children:(0,E.jsx)(`button`,{onClick:ie,"aria-label":R(re?`chat.disableSound`:`chat.enableSound`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:5,width:32,height:32,padding:0,background:`none`,border:`none`,borderRadius:9,color:re?`var(--text-muted)`:`var(--text-dim)`,cursor:`pointer`,opacity:re?1:.55,transition:`background 0.12s, color 0.12s, opacity 0.12s`,"--hover-bg":`var(--bg-hover)`,"--hover-color":`var(--text)`,"--hover-opacity":`1`},className:`hover-shift`,children:re?(0,E.jsx)($r,{size:p.base,style:{color:re?`var(--accent)`:`var(--text-dim)`,flexShrink:0}}):(0,E.jsx)(ei,{size:p.base,style:{color:re?`var(--accent)`:`var(--text-dim)`,flexShrink:0}})})}),ce&&Ee&&(0,E.jsx)(oi,{label:R(`chat.collapseControls`),children:(0,E.jsx)(`button`,{type:`button`,"aria-label":R(`chat.collapseControls`),"aria-expanded":!0,onClick:()=>{Ce(!1),Te(!1),De(!1)},style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:36,height:32,padding:0,marginLeft:0,background:`var(--bg-hover)`,border:`none`,borderLeft:`1px solid color-mix(in srgb, var(--border) 72%, transparent)`,borderRadius:`0 9px 9px 0`,color:`var(--text)`,cursor:`pointer`,transition:`background 0.12s, color 0.12s`,"--hover-bg":`var(--bg-selected)`},className:`hover-shift`,children:(0,E.jsx)(ni,{size:p.lg})})})]})]})]})]})]})}),hX=null,gX=new Set,_X=null;function vX(){return!_X&&typeof PointerEvent<`u`&&(_X=new PointerEvent(`pointermove`)),_X}var yX=[],bX=0;function xX(){hX===null&&(hX=requestAnimationFrame(()=>{if(hX=null,gX.size===0)return;let e=0;for(let t of gX)yX[e++]=t;yX.length=e,gX.clear();for(let t=0;t<e;t++)yX[t].update();for(let t=0;t<e;t++)yX[t]=null;yX.length=0,gX.size>0&&xX()}))}var SX=class e{get enabled(){return this._enabled}set enabled(e){this._enabled=e,!e&&this.isActive&&this.cancel()}cancel(){if(!this.isActive&&this.pointers.size===0)return;let t=this.isActive,n=vX(),r=t?this.createEvent(n):null;this.pointers.clear(),this.pointersCache.length=0,this.isActive=!1,t&&bX>0&&bX--,gX.delete(this),e.activeInstance.get(this.element)===this&&e.activeInstance.set(this.element,null),this.clearHoldTimers(),this.removeDocumentListeners(),r&&(this.options.onCancel?.(r),this.options.onEnd?.(r))}clearHoldTimers(){this.holdTimer&&=(clearTimeout(this.holdTimer),null),this.holdEventTimer&&=(clearTimeout(this.holdEventTimer),null)}removeDocumentListeners(){document.removeEventListener(`pointermove`,this.onPointerMove),document.removeEventListener(`pointerup`,this.onPointerUp),document.removeEventListener(`pointercancel`,this.onPointerUp)}getRect(e=this.element){return this.options.rectChecker?this.options.rectChecker(e):e.getBoundingClientRect()}getOrigin(){let e={x:0,y:0};return this.resolveOriginInto(e),e}resolveOriginInto(e){let t=this.options.origin;if(!t){e.x=0,e.y=0;return}if(t===`parent`){let t=this.element.offsetParent;if(!t){e.x=0,e.y=0;return}let n=this.getRect(t);e.x=n.left,e.y=n.top;return}if(t instanceof HTMLElement){let n=this.getRect(t);e.x=n.left,e.y=n.top;return}e.x=t.x,e.y=t.y}rebuildPointersCache(){let e=this.pointersCache;e.length=0;for(let t of this.pointers.values())e.push(t)}updateOptions(e){Object.assign(this.options,e),`touchAction`in e&&(this.element.style.touchAction=this.options.touchAction??`none`)}get interacting(){return this.isActive}static{this.elementInstances=new WeakMap}static{this.activeInstance=new WeakMap}static{this.elementListeners=new WeakMap}constructor(t,n={}){this.pointers=new Map,this.pointersCache=[],this.isActive=!1,this.lastUpdate=0,this.priority=0,this._enabled=!0,this.holdTimer=null,this.holdEventTimer=null,this.lastTapTime=0,this.lastTapTarget=null,this._originScratch={x:0,y:0},this._cachedEvent={target:null,pointers:[],isPrimary:!0,originalEvent:null},this.element=t,this.options={threshold:3,preventScroll:!0,styleCursor:!0,...n},this.registerInstance();let r=e.elementInstances.get(t);if(r&&r.length===1&&(t.style.touchAction=this.options.touchAction??`none`,t.style.userSelect=`none`,t.style.webkitUserSelect=`none`),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),r&&r.length===1){let n=n=>e.handleElementPointerDown(t,n);e.elementListeners.set(t,n),t.addEventListener(`pointerdown`,n)}}registerInstance(){let t=e.elementInstances.get(this.element);t?t.push(this):e.elementInstances.set(this.element,[this])}unregisterInstance(){let t=e.elementInstances.get(this.element);if(!t)return;let n=t.indexOf(this);n>=0&&(t.splice(n,1),t.length===0?(e.elementInstances.delete(this.element),e.activeInstance.delete(this.element),e.elementListeners.delete(this.element)):e.elementInstances.set(this.element,t))}shouldHandleEvent(e){return!0}checkEventFilters(e){let t=e.target;return!t||!(this.options.ignoreFrom&&t.closest(this.options.ignoreFrom)||this.options.allowFrom&&!t.closest(this.options.allowFrom))}static handleElementPointerDown(t,n){let r=e.elementInstances.get(t);if(!r)return;let i=e.activeInstance.get(t);if(i){i.onPointerDown(n);return}let a=null,o=-1;for(let e of r)e.checkEventFilters(n)&&e.shouldHandleEvent(n)&&e.enabled&&e.priority>o&&(a=e,o=e.priority);a&&(e.activeInstance.set(t,a),a.handlePointerDown(n))}onPointerDown(e){this.handlePointerDown(e)}handlePointerDown(e){if(this.options.mouseButtons&&!(e.buttons&this.options.mouseButtons))return;this.options.preventScroll&&e.preventDefault(),this.resolveOriginInto(this._originScratch);let t=e.clientX-this._originScratch.x,n=e.clientY-this._originScratch.y,r={id:e.pointerId,start:{x:t,y:n},current:{x:t,y:n},previous:{x:t,y:n},delta:{x:0,y:0},total:{x:0,y:0},velocity:{x:0,y:0},timestamp:e.timeStamp};this.pointers.set(e.pointerId,r),this.rebuildPointersCache(),this.pointers.size===1&&(document.addEventListener(`pointermove`,this.onPointerMove,{passive:!this.options.preventScroll}),document.addEventListener(`pointerup`,this.onPointerUp),document.addEventListener(`pointercancel`,this.onPointerUp)),this.options.onHold&&(this.holdEventTimer&&clearTimeout(this.holdEventTimer),this.holdEventTimer=setTimeout(()=>{this.holdEventTimer=null,this.pointers.size>0&&!this.isActive&&this.options.onHold(this.createEvent(e))},this.options.holdDuration??600));let i=this.options.holdDelay??0;i>0?(this.holdTimer&&clearTimeout(this.holdTimer),this.holdTimer=setTimeout(()=>{this.holdTimer=null,!this.isActive&&this.pointers.size>0&&this.start(e)},i)):this.options.threshold===0&&this.start(e)}onPointerMove(e){let t=this.pointers.get(e.pointerId);if(!t)return;this.resolveOriginInto(this._originScratch);let n=e.clientX-this._originScratch.x,r=e.clientY-this._originScratch.y;if(t.current.x!==n||t.current.y!==r){if(t.current.x=n,t.current.y=r,!this.isActive){let n=t.current.x-t.start.x,r=t.current.y-t.start.y;Math.sqrt(n*n+r*r)>=(this.options.threshold||3)&&(this.holdTimer&&=(clearTimeout(this.holdTimer),null),this.holdEventTimer&&=(clearTimeout(this.holdEventTimer),null),this.start(e))}this.isActive&&(this.options.preventScroll&&e.preventDefault(),gX.add(this),xX())}}onPointerUp(e){if(this.pointers.get(e.pointerId)&&(this.pointers.delete(e.pointerId),this.rebuildPointersCache(),this.clearHoldTimers(),this.pointers.size===0)){if(this.removeDocumentListeners(),this.isActive)this.end(e);else{let t=this.createEvent(e);this.options.onTap&&this.options.onTap(t);let n=e.timeStamp,r=this.options.doubleTapDelay??300;this.options.onDoubleTap&&n-this.lastTapTime<r&&this.lastTapTarget===e.target&&this.options.onDoubleTap(t),this.lastTapTime=n,this.lastTapTarget=e.target}}}start(e){this.isActive=!0,bX++;let t=this.createEvent(e);this.options.onStart&&this.options.onStart(t)}startFromEvent(t){this.isActive||this.pointers.has(t.pointerId)||(e.activeInstance.set(this.element,this),this.handlePointerDown(t),this.isActive||this.start(t))}end(t){this.isActive=!1,gX.delete(this),bX>0&&bX--,e.activeInstance.get(this.element)===this&&e.activeInstance.set(this.element,null);let n=this.createEvent(t);this.options.onEnd&&this.options.onEnd(n)}update(){if(!this.isActive||this.pointers.size===0)return;let e=performance.now(),t=this.lastUpdate===0?16:e-this.lastUpdate;this.lastUpdate=e;let n=t>0?1-Math.exp(-t/50):.3,r=!1;for(let e of this.pointers.values()){let i=e.current.x-e.previous.x,a=e.current.y-e.previous.y;if(i!==0||a!==0){if(r=!0,e.delta.x=i,e.delta.y=a,e.total.x=e.current.x-e.start.x,e.total.y=e.current.y-e.start.y,t>0){let r=i/t*1e3,o=a/t*1e3;e.velocity.x=e.velocity.x*(1-n)+r*n,e.velocity.y=e.velocity.y*(1-n)+o*n}e.previous.x=e.current.x,e.previous.y=e.current.y}else t>0&&(e.velocity.x*=1-n,e.velocity.y*=1-n)}r&&this.options.onMove&&this.options.onMove(this.populateEvent(vX()))}populateEvent(e){let t=this._cachedEvent;return t.target=this.element,t.pointers=this.pointersCache,t.isPrimary=e.isPrimary,t.originalEvent=e,t}createEvent(e){return this.populateEvent(e)}destroy(){this.clearHoldTimers(),this.unregisterInstance();let t=e.elementInstances.get(this.element);if(!t||t.length===0){let t=e.elementListeners.get(this.element);t&&(this.element.removeEventListener(`pointerdown`,t),e.elementListeners.delete(this.element)),this.element.style.touchAction=``,this.element.style.userSelect=``,this.element.style.webkitUserSelect=``}this.pointers.size>0&&this.removeDocumentListeners(),gX.delete(this),this.pointers.clear(),this.pointersCache.length=0}},CX=null;function wX(){if(CX!==null)return CX;if(typeof window>`u`||!window.matchMedia)return CX=!1,!1;let e=window.matchMedia(`(prefers-reduced-motion: reduce)`);return CX=e.matches,typeof e.addEventListener==`function`&&e.addEventListener(`change`,e=>{CX=e.matches}),CX}function TX(e,t){for(let n=0;n<e.length;n++)e[n].modify(t);return t}var EX={instructions:`Press Space or Enter to pick up. Use arrow keys to move. Press Space or Enter to drop. Press Escape to cancel.`,pickedUp:(e,t,n)=>`Picked up ${e}, position ${t} of ${n}`,movedTo:(e,t)=>`Moved to position ${e} of ${t}`,dropped:(e,t,n)=>`Dropped ${e} in position ${t} of ${n}`,dragPickedUp:`Picked up`,dragDropped:`Dropped`};function DX(){return EX}var OX=null;function kX(){return OX&&OX.isConnected?OX:(OX=document.createElement(`div`),OX.setAttribute(`aria-live`,`assertive`),OX.setAttribute(`aria-atomic`,`true`),OX.setAttribute(`role`,`status`),OX.style.cssText=`position:fixed;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,document.body.appendChild(OX),OX)}var AX=``;function jX(e){let t=kX();t.textContent=e===AX?e+`\xA0`:e,AX=e}var MX=null,NX=`pointrix-instructions`;function PX(){return MX&&MX.isConnected?(MX.textContent=EX.instructions,NX):(MX=document.createElement(`div`),MX.id=NX,MX.style.cssText=`position:fixed;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,MX.textContent=EX.instructions,document.body.appendChild(MX),NX)}function FX(e){e.hasAttribute(`tabindex`)||e.setAttribute(`tabindex`,`0`),e.hasAttribute(`role`)||e.setAttribute(`role`,`button`),e.setAttribute(`aria-roledescription`,`draggable`),e.setAttribute(`aria-describedby`,PX())}function IX(e,t){e.setAttribute(`aria-grabbed`,String(t))}function LX(e){e.removeAttribute(`aria-roledescription`),e.removeAttribute(`aria-grabbed`),e.removeAttribute(`aria-describedby`)}var RX=new class{constructor(){this.zones=new Set,this._activeDragCount=0,this._refreshBound=()=>this.refreshRects()}register(e){this.zones.add(e)}unregister(e){this.zones.delete(e)}refreshRects(){for(let e of this.zones)e.isActive&&e.refreshRect()}onDragStart(e){for(let t of this.zones)t.accepts(e)&&(t.activate(e),t.refreshRect());this._activeDragCount===0&&typeof window<`u`&&(window.addEventListener(`scroll`,this._refreshBound,{passive:!0,capture:!0}),window.addEventListener(`resize`,this._refreshBound,{passive:!0})),this._activeDragCount++}onDragMove(e,t,n,r){let i,a=!1;for(let e of this.zones)if(e.isActive&&(e.options.overlap??`pointer`)!==`pointer`){a=!0;break}a&&(i=r?r():e.getBoundingClientRect());for(let r of this.zones){if(!r.isActive)continue;let a=r.checkOverlap(e,t,i);a>0?(r.isOver||r.enter(e,a,n),r.over(e,a,n)):r.isOver&&r.leave(e,n)}}onDragEnd(e,t,n,r){for(let i of this.zones)if(i.isActive){if(i.isOver){let a=r?.(),o=i.checkOverlap(e,t,a);i.drop(e,o>0?o:1,n)}i.deactivate(e),i.clearRect()}this._activeDragCount>0&&this._activeDragCount--,this._activeDragCount===0&&typeof window<`u`&&(window.removeEventListener(`scroll`,this._refreshBound,{capture:!0}),window.removeEventListener(`resize`,this._refreshBound))}getActiveZones(){let e=[];for(let t of this.zones)t.isActive&&e.push(t);return e}getHoveredZones(){let e=[];for(let t of this.zones)t.isOver&&e.push(t);return e}},zX=class extends SX{constructor(e,t={}){super(e,{...t,onStart:e=>{this.handleDragStart(e),t.onStart?.(e)},onMove:e=>{this.handleDragMove(e),t.onMove?.(e)},onEnd:e=>{this.handleDragEnd(e),t.onEnd?.(e)}}),this.transform={x:0,y:0},this.startTransform={x:0,y:0},this.bounds=null,this.momentum={vx:0,vy:0,active:!1},this.transformNormalized=!1,this.detectedAxis=null,this.cachedSize={width:0,height:0},this._boundGetRect=()=>this.getRect(),this.modifierContext={position:{x:0,y:0},velocity:{x:0,y:0},element:null,startPosition:{x:0,y:0},delta:{x:0,y:0},size:{width:0,height:0}},this.cachedDragEvent={target:null,originalEvent:null,pointers:[],isPrimary:!0,dx:0,dy:0,totalX:0,totalY:0,velocityX:0,velocityY:0},this.dragOptions=t,this.priority=5,t.styleCursor!==!1&&(e.style.cursor=t.cursorChecker?t.cursorChecker(`idle`):`grab`),t.aria!==!1&&FX(e)}shouldHandleEvent(e){if(!this.dragOptions.handle)return!0;let t=null;return t=typeof this.dragOptions.handle==`string`?this.element.querySelector(this.dragOptions.handle):this.dragOptions.handle,t?t.contains(e.target):!1}readCurrentTransform(e){let t=window.getComputedStyle(e).transform;if(t&&t!==`none`){let e=t.match(/matrix.*\((.+)\)/);if(e){let t=e[1].split(`, `);this.transform.x=parseFloat(t[4])||0,this.transform.y=parseFloat(t[5])||0}}else this.transformNormalized||(this.transform.x=0,this.transform.y=0);this.transformNormalized||=(e.style.transform=`translate3d(${this.transform.x}px, ${this.transform.y}px, 0)`,!0)}handleDragStart(e){let t=e.target;if(this.dragOptions.aria!==!1&&(IX(t,!0),jX(DX().dragPickedUp)),this.detectedAxis=null,this.readCurrentTransform(t),this.dragOptions.styleCursor!==!1&&(t.style.cursor=this.dragOptions.cursorChecker?this.dragOptions.cursorChecker(`grabbing`):`grabbing`),t.style.willChange=`transform`,this.startTransform.x=this.transform.x,this.startTransform.y=this.transform.y,this.dragOptions.bounds){let e=this.getRect(t),n=this.startTransform.x,r=this.startTransform.y,i;if(this.dragOptions.bounds===`parent`){let e=t.offsetParent||document.body,n=this.getRect(e);i={left:n.left,top:n.top,right:n.right,bottom:n.bottom}}else if(this.dragOptions.bounds instanceof HTMLElement){let e=this.getRect(this.dragOptions.bounds);i={left:e.left,top:e.top,right:e.right,bottom:e.bottom}}else{let e=this.dragOptions.bounds;i={left:e.left??-1/0,top:e.top??-1/0,right:e.right??1/0,bottom:e.bottom??1/0}}let a=i.left-e.left+n,o=i.top-e.top+r,s=i.right-e.right+n,c=i.bottom-e.bottom+r;this.bounds=new DOMRect(a,o,s-a,c-o)}this.momentum.active=!1;let n=this.getRect(e.target);if(this.cachedSize.width=n.width,this.cachedSize.height=n.height,this.dragOptions.modifiers?.length){let t=this.modifierContext;t.position.x=this.startTransform.x,t.position.y=this.startTransform.y,t.velocity.x=0,t.velocity.y=0,t.element=e.target,t.startPosition.x=this.startTransform.x,t.startPosition.y=this.startTransform.y,t.delta.x=0,t.delta.y=0,t.size.width=this.cachedSize.width,t.size.height=this.cachedSize.height;for(let e of this.dragOptions.modifiers)e.onStart?.(t)}this.dragOptions.onDragStart&&this.dragOptions.onDragStart(this.createDragEvent(e,0,0)),this.dragOptions.droppable&&RX.onDragStart(e.target)}handleDragMove(e){let t=e.pointers[0],n=t.total.x,r=t.total.y;if(this.dragOptions.axis===`auto`&&this.detectedAxis===null){let e=Math.abs(n),t=Math.abs(r);(e>0||t>0)&&(this.detectedAxis=e>t?`x`:`y`)}let i=this.dragOptions.axis===`auto`?this.detectedAxis:this.dragOptions.axis;i===`x`?r=0:i===`y`&&(n=0);let a=this.startTransform.x+n,o=this.startTransform.y+r;if(this.dragOptions.grid&&(a=Math.round(a/this.dragOptions.grid.x)*this.dragOptions.grid.x,o=Math.round(o/this.dragOptions.grid.y)*this.dragOptions.grid.y),this.bounds&&(a=Math.max(this.bounds.left,Math.min(a,this.bounds.right)),o=Math.max(this.bounds.top,Math.min(o,this.bounds.bottom))),this.dragOptions.modifiers?.length){let n=this.modifierContext;n.position.x=a,n.position.y=o,n.velocity.x=t.velocity.x,n.velocity.y=t.velocity.y,n.element=e.target,n.startPosition.x=this.startTransform.x,n.startPosition.y=this.startTransform.y,n.delta.x=t.delta.x,n.delta.y=t.delta.y,n.size.width=this.cachedSize.width,n.size.height=this.cachedSize.height,TX(this.dragOptions.modifiers,n),a=n.position.x,o=n.position.y}this.transform.x=a,this.transform.y=o,this.applyTransform(e.target),this.dragOptions.momentum&&(this.momentum.vx=t.velocity.x,this.momentum.vy=t.velocity.y);let s=this.createDragEvent(e,n,r);this.dragOptions.onDragMove&&this.dragOptions.onDragMove(s),this.dragOptions.droppable&&RX.onDragMove(e.target,t.current,s,this._boundGetRect)}handleDragEnd(e){let t=e.target;this.dragOptions.aria!==!1&&(IX(t,!1),jX(DX().dragDropped)),this.dragOptions.styleCursor!==!1&&(t.style.cursor=this.dragOptions.cursorChecker?this.dragOptions.cursorChecker(`grab`):`grab`);let n=this.transform.x-this.startTransform.x,r=this.transform.y-this.startTransform.y,i=this.dragOptions.momentum,a=typeof i==`object`?i.minVelocity??10:10;if(i&&(Math.abs(this.momentum.vx)>a||Math.abs(this.momentum.vy)>a)?this.startMomentum():t.style.willChange=``,this.dragOptions.modifiers?.length){let i=e.pointers[0],a=this.modifierContext;a.position.x=this.transform.x,a.position.y=this.transform.y,a.velocity.x=i?.velocity.x??0,a.velocity.y=i?.velocity.y??0,a.element=e.target,a.startPosition.x=this.startTransform.x,a.startPosition.y=this.startTransform.y,a.delta.x=n,a.delta.y=r,a.size.width=this.cachedSize.width,a.size.height=this.cachedSize.height;for(let e of this.dragOptions.modifiers)e.onEnd?.(a);let o=a.position.x,s=a.position.y;if(o!==this.transform.x||s!==this.transform.y){if(this.transform.x=o,this.transform.y=s,wX())this.applyTransform(t);else{t.style.transition=`transform 300ms cubic-bezier(0.25, 1, 0.5, 1)`,this.applyTransform(t);let e=()=>{t.style.transition=``,t.removeEventListener(`transitionend`,e)};t.addEventListener(`transitionend`,e)}}}if(this.dragOptions.droppable){let t=e.pointers[0]?.current??{x:0,y:0};RX.onDragEnd(e.target,t,this.createDragEvent(e,n,r),this._boundGetRect)}this.dragOptions.onDragEnd&&this.dragOptions.onDragEnd(this.createDragEvent(e,n,r))}startMomentum(){this.momentum.active=!0;let e=this.dragOptions.momentum,t=typeof e==`object`?e.friction??.95:.95,n=typeof e==`object`?e.minSpeed??.1:.1,r=performance.now(),i=e=>{if(!this.momentum.active)return;let a=Math.min(100,e-r)/1e3;r=e;let o=t**+a;if(this.momentum.vx*=o,this.momentum.vy*=o,Math.abs(this.momentum.vx)<n&&Math.abs(this.momentum.vy)<n){this.momentum.active=!1,this.element.style.willChange=``;return}this.transform.x+=this.momentum.vx*a,this.transform.y+=this.momentum.vy*a,this.bounds&&((this.transform.x<this.bounds.left||this.transform.x>this.bounds.right)&&(this.momentum.vx*=-.5,this.transform.x=Math.max(this.bounds.left,Math.min(this.transform.x,this.bounds.right))),(this.transform.y<this.bounds.top||this.transform.y>this.bounds.bottom)&&(this.momentum.vy*=-.5,this.transform.y=Math.max(this.bounds.top,Math.min(this.transform.y,this.bounds.bottom)))),this.applyTransform(this.element),requestAnimationFrame(i)};requestAnimationFrame(i)}applyTransform(e){e.style.transform=`translate3d(${this.transform.x}px, ${this.transform.y}px, 0)`}createDragEvent(e,t,n){let r=e.pointers[0],i=this.cachedDragEvent;return i.target=e.target,i.originalEvent=e.originalEvent,i.pointers=e.pointers,i.isPrimary=e.isPrimary,i.dx=r?.delta.x||0,i.dy=r?.delta.y||0,i.totalX=t,i.totalY=n,i.velocityX=r?.velocity.x||0,i.velocityY=r?.velocity.y||0,i}setPosition(e,t){this.transform.x=e,this.transform.y=t,this.applyTransform(this.element)}getPosition(){return{...this.transform}}updateOptions(e){super.updateOptions(e),Object.assign(this.dragOptions,e),(`cursorChecker`in e||`styleCursor`in e)&&!this.interacting&&(this.dragOptions.styleCursor===!1?this.element.style.cursor=``:this.element.style.cursor=this.dragOptions.cursorChecker?this.dragOptions.cursorChecker(`idle`):`grab`)}destroy(){super.destroy(),this.element.style.cursor=``,this.element.style.willChange=``,this.momentum.active=!1,this.dragOptions.aria!==!1&&LX(this.element)}},BX=class extends SX{constructor(e,t={}){let n={edges:{top:!0,right:!0,bottom:!0,left:!0},handleSize:10,minWidth:50,minHeight:50,...t};super(e,{...n,threshold:0,onStart:e=>{this.handleResizeStart(e),t.onStart?.(e)},onMove:e=>{this.handleResizeMove(e),t.onMove?.(e)},onEnd:e=>{this.handleResizeEnd(e),t.onEnd?.(e)}}),this.startSize={width:0,height:0},this.startPos={x:0,y:0},this.currentSize={width:0,height:0},this.currentPos={x:0,y:0},this.activeEdge=null,this.edgeFlags={top:!1,right:!1,bottom:!1,left:!1},this.aspectRatio=null,this.transformNormalized=!1,this.modifierContext={position:{x:0,y:0},velocity:{x:0,y:0},element:null,startPosition:{x:0,y:0},delta:{x:0,y:0},edges:{top:!1,right:!1,bottom:!1,left:!1},size:{width:0,height:0},startSize:{width:0,height:0}},this.cachedResizeEvent={target:null,originalEvent:null,pointers:[],isPrimary:!0,width:0,height:0,deltaWidth:0,deltaHeight:0,edges:{top:!1,right:!1,bottom:!1,left:!1}},this.resizeOptions=n,this.resizeOptions.square&&(this.resizeOptions.aspectRatio=1),this.priority=10,this.boundUpdateCursor=this.updateCursor.bind(this),e.addEventListener(`pointermove`,this.boundUpdateCursor),e.style.position=`relative`}normalizeInitialTransform(e){let t=window.getComputedStyle(e).transform;if(t&&t!==`none`){let n=t.match(/matrix.*\((.+)\)/);if(n){let t=n[1].split(`, `),r=parseFloat(t[4])||0,i=parseFloat(t[5])||0;e.style.transform=`translate3d(${r}px, ${i}px, 0)`}}}shouldHandleEvent(e){return this.detectEdge(e)!==null}updateCursor(e){if(this.activeEdge)return;let t=this.detectEdge(e);this.element.style.cursor=this.resizeOptions.cursorChecker?this.resizeOptions.cursorChecker(t):this.getCursor(t)}detectEdge(e){let t=this.getRect(),n=e.clientX-t.left,r=e.clientY-t.top,i=this.resizeOptions.handleSize||10,a=this.resizeOptions.edges||{},o=a.top&&r<i,s=a.bottom&&r>t.height-i,c=a.left&&n<i,l=a.right&&n>t.width-i;return o&&c?`top-left`:o&&l?`top-right`:s&&c?`bottom-left`:s&&l?`bottom-right`:o?`top`:s?`bottom`:c?`left`:l?`right`:null}getCursor(e){switch(e){case`top`:case`bottom`:return`ns-resize`;case`left`:case`right`:return`ew-resize`;case`top-left`:case`bottom-right`:return`nwse-resize`;case`top-right`:case`bottom-left`:return`nesw-resize`;default:return``}}handleResizeStart(e){this.transformNormalized||=(this.normalizeInitialTransform(this.element),!0);let t=this.getRect(),n=window.getComputedStyle(this.element);if(this.activeEdge=this.detectEdge(e.originalEvent),!this.activeEdge)return;this.edgeFlags.top=this.activeEdge.includes(`top`),this.edgeFlags.right=this.activeEdge.includes(`right`),this.edgeFlags.bottom=this.activeEdge.includes(`bottom`),this.edgeFlags.left=this.activeEdge.includes(`left`),this.startSize={width:parseFloat(n.width)||t.width,height:parseFloat(n.height)||t.height},this.currentSize={...this.startSize};let r=n.transform;if(r&&r!==`none`){let e=r.match(/matrix.*\((.+)\)/);if(e){let t=e[1].split(`, `);this.startPos.x=parseFloat(t[4])||0,this.startPos.y=parseFloat(t[5])||0}}else this.startPos.x=0,this.startPos.y=0;this.currentPos={...this.startPos},this.resizeOptions.aspectRatio===`preserve`?this.aspectRatio=this.startSize.width/this.startSize.height:typeof this.resizeOptions.aspectRatio==`number`&&(this.aspectRatio=this.resizeOptions.aspectRatio),this.element.style.willChange=`width, height, transform`,this.resizeOptions.onResizeStart&&this.resizeOptions.onResizeStart(this.createResizeEvent(e,0,0))}handleResizeMove(e){if(!this.activeEdge)return;let t=e.pointers[0],n=t.total.x,r=t.total.y,i=this.startSize.width,a=this.startSize.height,o=this.startPos.x,s=this.startPos.y;this.edgeFlags.right&&(i+=n),this.edgeFlags.left&&(i-=n,o+=n),this.edgeFlags.bottom&&(a+=r),this.edgeFlags.top&&(a-=r,s+=r);let c=this.resizeOptions.invert||`none`;c===`reposition`&&(i<0&&(o+=i,i=-i),a<0&&(s+=a,a=-a));let l=c===`negate`?-1/0:this.resizeOptions.minWidth||0,u=c===`negate`?-1/0:this.resizeOptions.minHeight||0,d=this.resizeOptions.maxWidth||1/0,f=this.resizeOptions.maxHeight||1/0,p=c===`reposition`?1:l||50,m=c===`reposition`?1:u||50;if(this.aspectRatio&&(this.activeEdge===`left`||this.activeEdge===`right`?a=i/this.aspectRatio:this.activeEdge===`top`||this.activeEdge===`bottom`?i=a*this.aspectRatio:Math.abs(i-this.startSize.width)>Math.abs(a-this.startSize.height)?a=i/this.aspectRatio:i=a*this.aspectRatio),i<p&&(this.edgeFlags.left&&(o+=i-p),i=p,this.aspectRatio&&(a=i/this.aspectRatio)),i>d&&(this.edgeFlags.left&&(o+=i-d),i=d,this.aspectRatio&&(a=i/this.aspectRatio)),a<m&&(this.edgeFlags.top&&(s+=a-m),a=m,this.aspectRatio&&(i=a*this.aspectRatio)),a>f&&(this.edgeFlags.top&&(s+=a-f),a=f,this.aspectRatio&&(i=a*this.aspectRatio)),this.resizeOptions.grid&&(i=Math.round(i/this.resizeOptions.grid.width)*this.resizeOptions.grid.width,a=Math.round(a/this.resizeOptions.grid.height)*this.resizeOptions.grid.height),this.resizeOptions.modifiers?.length){let e=this.modifierContext;e.position.x=o,e.position.y=s,e.velocity.x=t.velocity?.x??0,e.velocity.y=t.velocity?.y??0,e.element=this.element,e.startPosition.x=this.startPos.x,e.startPosition.y=this.startPos.y,e.delta.x=n,e.delta.y=r,e.edges.top=this.edgeFlags.top,e.edges.right=this.edgeFlags.right,e.edges.bottom=this.edgeFlags.bottom,e.edges.left=this.edgeFlags.left,e.size.width=i,e.size.height=a,e.startSize.width=this.startSize.width,e.startSize.height=this.startSize.height,TX(this.resizeOptions.modifiers,e),o=e.position.x,s=e.position.y,i=e.size.width,a=e.size.height}if(this.currentSize={width:i,height:a},this.currentPos={x:o,y:s},this.element.style.width=`${i}px`,this.element.style.height=`${a}px`,(o!==this.startPos.x||s!==this.startPos.y)&&(this.element.style.transform=`translate3d(${o}px, ${s}px, 0)`),this.resizeOptions.onResizeMove){let t=i-this.startSize.width,n=a-this.startSize.height;this.resizeOptions.onResizeMove(this.createResizeEvent(e,t,n))}}handleResizeEnd(e){if(this.element.style.willChange=``,this.activeEdge=null,this.resizeOptions.onResizeEnd){let t=this.currentSize.width-this.startSize.width,n=this.currentSize.height-this.startSize.height;this.resizeOptions.onResizeEnd(this.createResizeEvent(e,t,n))}}createResizeEvent(e,t,n){let r=this.cachedResizeEvent;return r.target=e.target,r.originalEvent=e.originalEvent,r.pointers=e.pointers,r.isPrimary=e.isPrimary,r.width=this.currentSize.width,r.height=this.currentSize.height,r.deltaWidth=t,r.deltaHeight=n,r.edges.top=this.edgeFlags.top,r.edges.right=this.edgeFlags.right,r.edges.bottom=this.edgeFlags.bottom,r.edges.left=this.edgeFlags.left,r}setSize(e,t){this.currentSize={width:e,height:t},this.element.style.width=`${e}px`,this.element.style.height=`${t}px`}getSize(){return{...this.currentSize}}updateOptions(e){super.updateOptions(e),Object.assign(this.resizeOptions,e),`square`in e&&this.resizeOptions.square&&(this.resizeOptions.aspectRatio=1)}destroy(){super.destroy(),this.element.removeEventListener(`pointermove`,this.boundUpdateCursor),this.element.style.cursor=``,this.element.style.willChange=``}},VX=180/Math.PI,HX=class extends SX{constructor(e,t={}){super(e,{...t,threshold:0}),this.gestureActive=!1,this.startDistance=0,this.startAngle=0,this.prevScale=1,this.prevAngle=0,this._p1=null,this._p2=null,this._cachedGestureEvent={target:null,pointers:[],isPrimary:!1,originalEvent:null,scale:1,rotation:0,distance:0,angle:0,center:{x:0,y:0},deltaScale:0,deltaAngle:0},this.gestureOptions=t,this.minPointers=t.minPointers??2,this.priority=15}shouldHandleEvent(e){return!0}selectTwoPointers(){if(this.pointers.size<2)return this._p1=this._p2=null,!1;let e=this.pointers.values();return this._p1=e.next().value,this._p2=e.next().value,!0}distanceBetween(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}angleBetween(e,t){return Math.atan2(t.y-e.y,t.x-e.x)*VX}normalizeAngleDelta(e){for(;e>180;)e-=360;for(;e<-180;)e+=360;return e}buildEvent(e,t,n,r,i,a,o,s){let c=this._cachedGestureEvent;return c.target=this.element,c.pointers=this.pointersCache,c.isPrimary=!1,c.originalEvent=c.originalEvent??{},c.scale=n,c.rotation=r,c.distance=e,c.angle=t,c.center.x=o,c.center.y=s,c.deltaScale=i,c.deltaAngle=a,c}update(){if(!this.isActive||this.pointers.size===0)return;let e=this.selectTwoPointers();if(!this.gestureActive&&e&&this.pointers.size>=this.minPointers){this.gestureActive=!0;let e=this._p1.current,t=this._p2.current;this.startDistance=this.distanceBetween(e,t),this.startAngle=this.angleBetween(e,t),this.prevScale=1,this.prevAngle=0;let n=this.buildEvent(this.startDistance,this.startAngle,1,0,0,0,(e.x+t.x)/2,(e.y+t.y)/2);this.gestureOptions.onGestureStart&&this.gestureOptions.onGestureStart(n);return}if(this.gestureActive&&this.pointers.size<this.minPointers){this.endGesture(),super.update();return}if(this.gestureActive&&e){let e=this._p1.current,t=this._p2.current,n=this.distanceBetween(e,t),r=this.angleBetween(e,t),i=this.startDistance>0?n/this.startDistance:1,a=this.normalizeAngleDelta(r-this.startAngle),o=i-this.prevScale,s=this.normalizeAngleDelta(a-this.prevAngle);this.prevScale=i,this.prevAngle=a,this.gestureOptions.onGestureMove&&this.gestureOptions.onGestureMove(this.buildEvent(n,r,i,a,o,s,(e.x+t.x)/2,(e.y+t.y)/2))}super.update()}endGesture(){if(!this.gestureActive)return;this.gestureActive=!1;let e=this.selectTwoPointers(),t=e?this._p1.current:null,n=e?this._p2.current:null,r=t&&n?this.distanceBetween(t,n):0,i=t&&n?this.angleBetween(t,n):0,a=t&&n?(t.x+n.x)/2:0,o=t&&n?(t.y+n.y)/2:0,s=this.startDistance>0&&r>0?r/this.startDistance:this.prevScale;this.gestureOptions.onGestureEnd&&this.gestureOptions.onGestureEnd(this.buildEvent(r,i,s,this.prevAngle,0,0,a,o))}updateOptions(e){super.updateOptions(e),Object.assign(this.gestureOptions,e),e.minPointers!==void 0&&(this.minPointers=e.minPointers)}destroy(){this.gestureActive&&this.endGesture(),super.destroy()}},UX=typeof window<`u`?d.useLayoutEffect:d.useEffect;function WX(e){let t={};for(let n in e){let r=e[n];typeof r!=`function`&&(t[n]=r)}return t}function GX(e={},t){let n=(0,d.useRef)(e);n.current=e;let r=(0,d.useRef)(null),i=(0,d.useRef)(null),a=(0,d.useRef)(void 0),o=(0,d.useCallback)(o=>{if(o===i.current||(r.current&&(r.current.drag?.destroy(),r.current.resize?.destroy(),r.current.gesture?.destroy(),r.current=null,t&&(t.current=null)),i.current=o,!o))return;let s=n.current,c={drag:s.drag?new zX(o,typeof s.drag==`object`?KX(n,`drag`):{}):null,resize:s.resize?new BX(o,typeof s.resize==`object`?KX(n,`resize`):{}):null,gesture:s.gesture?new HX(o,typeof s.gesture==`object`?KX(n,`gesture`):{}):null};r.current=c,t&&(t.current=c),a.current=e},[]);return UX(()=>{let t=r.current;if(!t||a.current===e)return;let i=n.current;t.drag&&typeof i.drag==`object`&&t.drag.updateOptions(WX(i.drag)),t.resize&&typeof i.resize==`object`&&t.resize.updateOptions(WX(i.resize)),t.gesture&&typeof i.gesture==`object`&&t.gesture.updateOptions(WX(i.gesture)),a.current=e}),o}function KX(e,t){let n=e.current[t];if(typeof n!=`object`)return{};let r={};for(let i in n){let a=n[i];r[i]=typeof a==`function`?(...n)=>{let r=e.current[t];if(typeof r!=`object`)return;let a=r[i];return a?.(...n)}:a}return r}function qX({title:e,subtitle:t,children:n,footer:r,width:i=560,align:a=`bottom`,height:o,variant:s=`normal`,initialOffset:c,position:l,size:u,maxWidth:f,onDragStop:p,onResizeStop:m,testId:h,style:g,portalTarget:_,headerExtra:v}){let[y,b]=(0,d.useState)(!1),x=Math.round(window.innerHeight*.8),[S]=(0,d.useState)(()=>({x:l?.x??c?.dx??0,y:l?.y??c?.dy??0,w:u?.width??i,h:u?.height??o??null})),C=(0,d.useRef)(null),w=(0,d.useRef)(null),T=(0,d.useRef)(null),D=(0,d.useRef)(p);D.current=p;let O=(0,d.useRef)(m);O.current=m;let k=GX((0,d.useMemo)(()=>({drag:{handle:`.dd-drag-handle`,onDragEnd:()=>{let e=T.current?.drag?.getPosition();e&&D.current?.(e.x,e.y)}},resize:{edges:{top:!0,right:!0,bottom:!0,left:!0},minWidth:160,minHeight:100,onResizeEnd:e=>{let t=C.current?.style.transform.match(/translate3?d?\((-?[\d.]+)px,\s*(-?[\d.]+)px/);O.current?.(e.width,e.height,t?Number(t[1]):0,t?Number(t[2]):0)}}}),[]),T);(0,d.useEffect)(()=>()=>{T.current?.drag?.cancel(),T.current?.resize?.cancel()},[]);let A=(0,d.useCallback)(e=>{C.current=e,k(e)},[k]);(0,d.useEffect)(()=>{if(T.current?.drag?.setPosition(S.x,S.y),S.h!=null){if(T.current?.resize?.setSize(S.w,S.h),f&&w.current){let e=w.current;e.style.width=`max-content`;let t=Math.ceil(e.scrollWidth);e.style.width=``;let n=Math.min(Math.max(t,S.w),f);n!==S.w&&T.current?.resize?.setSize(n,S.h)}return}let e=C.current;if(!e)return;let t=e.style.height,n=e.style.maxHeight;e.style.height=`auto`,e.style.maxHeight=`none`;let r=e.scrollHeight;e.style.height=t,e.style.maxHeight=n;let i=Math.min(r,x);if(f&&w.current){let e=w.current;e.style.width=`max-content`;let t=Math.ceil(e.scrollWidth);e.style.width=``;let n=Math.min(Math.max(t,S.w),f);T.current?.resize?.setSize(n,i)}else T.current?.resize?.setSize(S.w,i)},[]);let j=s===`error`?1200:1e3,M=y?j+100:j;return(0,ii.createPortal)((0,E.jsx)(`div`,{"data-testid":h,onPointerDownCapture:()=>b(!0),style:{position:`fixed`,inset:0,zIndex:M,display:`flex`,alignItems:a===`bottom`?`flex-end`:`center`,justifyContent:`center`,padding:a===`bottom`?`0 20px 16px`:0,pointerEvents:`none`,...g},children:(0,E.jsxs)(`div`,{ref:A,role:`dialog`,"aria-modal":`true`,style:{transform:`translate(${S.x}px, ${S.y}px)`,width:S.w,...S.h==null?{maxHeight:x}:{height:S.h},display:`flex`,flexDirection:`column`,position:`relative`,border:`1px solid color-mix(in srgb, var(--foreground) 14%, transparent)`,borderRadius:12,background:`var(--bg)`,boxShadow:`0 -4px 24px var(--shadow-strong), 0 8px 28px var(--shadow-color), 0 2px 8px var(--shadow-color)`,overflow:`hidden`,pointerEvents:`auto`},children:[(0,E.jsxs)(`div`,{className:`dd-drag-handle`,style:{padding:`12px 14px`,borderBottom:`1px solid var(--border)`,cursor:`move`,touchAction:`none`,userSelect:`none`,flexShrink:0},children:[(0,E.jsx)(`div`,{style:{color:`var(--text)`,fontSize:`var(--text-2xl)`,fontWeight:650,paddingRight:v?34:0},children:e}),t&&(0,E.jsx)(`div`,{style:{marginTop:3,color:`var(--text-dim)`,fontSize:`var(--text-sm)`,fontFamily:`var(--font-mono)`},children:t})]}),v&&(0,E.jsx)(`div`,{style:{position:`absolute`,top:8,right:10,zIndex:2,display:`flex`,alignItems:`center`},children:v}),(0,E.jsx)(`div`,{ref:w,style:{padding:14,overflowY:`auto`,minHeight:0,flexGrow:1,userSelect:`text`},children:n}),r&&(0,E.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8,padding:`10px 14px`,borderTop:`1px solid var(--border)`,background:`var(--bg-panel)`,flexShrink:0},children:r})]})}),_??document.body)}function JX(e,t){if(!t)return new Set;let n=t;function r(e,t){for(let i of e){let e=[...t,i.entry.id];if(i.entry.id===n||i.compressedEntryIds?.includes(n))return e;let a=r(i.children,e);if(a)return a}return null}return new Set(r(e,[])??[])}function YX(e){let t=e,n=t.compressedEntryIds?.length??0;for(;t.children.length===1;)t=t.children[0],n+=1+(t.compressedEntryIds?.length??0);return{node:t,skipped:n}}function XX(e){if(e.type===`message`&&`message`in e){let t=e.message,n=t.content,r=``;if(typeof n==`string`?r=n:Array.isArray(n)&&(r=n.filter(e=>e.type===`text`).map(e=>e.text).join(` `)),r.length>40&&(r=`${r.slice(0,40)}…`),r)return r;if(t.role===`assistant`)return`[assistant]`}return e.type}function ZX(e){for(let t of e)if(t.children.length>1||ZX(t.children))return!0;return!1}function QX({node:e,activePathIds:t,depth:n,isLast:r,parentLines:i,onSelect:a}){let{node:o,skipped:s}=YX(e),c=t.has(o.entry.id),l=t.has(e.entry.id)||t.has(o.entry.id),u=XX(o.entry),d=o.entry.type===`message`&&`message`in o.entry?o.entry.message.role:null;return(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,height:24,cursor:`pointer`},onClick:()=>a(o.entry.id),children:[i.map((e,t)=>(0,E.jsx)(`div`,{style:{width:16,flexShrink:0,position:`relative`,height:`100%`,alignSelf:`stretch`},children:e&&(0,E.jsx)(`div`,{style:{position:`absolute`,left:7,top:0,bottom:0,width:1,background:`var(--border)`}})},t)),(0,E.jsxs)(`div`,{style:{width:16,flexShrink:0,position:`relative`,height:`100%`,alignSelf:`stretch`},children:[(0,E.jsx)(`div`,{style:{position:`absolute`,left:7,top:0,bottom:r?`50%`:0,width:1,background:`var(--border)`}}),(0,E.jsx)(`div`,{style:{position:`absolute`,left:7,top:`50%`,width:9,height:1,background:`var(--border)`}})]}),(0,E.jsx)(`div`,{style:{width:7,height:7,borderRadius:`50%`,flexShrink:0,background:c?`var(--accent)`:l?`var(--text-muted)`:`var(--border)`,border:c?`none`:`1px solid var(--text-dim)`,marginRight:6,transition:`background 0.12s`}}),d&&(0,E.jsx)(`span`,{style:{fontSize:`var(--text-2xs)`,fontFamily:`var(--font-mono)`,color:d===`user`?`var(--accent)`:`var(--text-dim)`,background:d===`user`?`color-mix(in srgb, var(--accent) 8%, transparent)`:`var(--bg-hover)`,border:`1px solid ${d===`user`?`color-mix(in srgb, var(--accent) 20%, transparent)`:`var(--border)`}`,borderRadius:3,padding:`0 4px`,marginRight:5,flexShrink:0,lineHeight:`16px`},children:d===`user`?`U`:`A`}),s>0&&(0,E.jsxs)(`span`,{style:{fontSize:`var(--text-xs)`,color:`var(--text-dim)`,marginRight:5,flexShrink:0},children:[`+`,s]}),(0,E.jsx)(`span`,{style:{fontSize:`var(--text-sm)`,color:c?`var(--text)`:l?`var(--text-muted)`:`var(--text-dim)`,fontWeight:c?500:400,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,flex:1,minWidth:0},children:u})]}),o.children.map((e,s)=>(0,E.jsx)(QX,{node:e,activePathIds:t,depth:n+1,isLast:s===o.children.length-1,parentLines:[...i,!r],onSelect:a},e.entry.id))]})}function $X({tree:e,activeLeafId:t,onLeafChange:n,inline:r,containerRef:i,open:a,onToggle:o,hasSession:s,compact:c}){let{t:l}=N(),[u,f]=(0,d.useState)(!1),m=a===void 0?u:a,h=(0,d.useRef)(null),[g,_]=(0,d.useState)(null);(0,d.useEffect)(()=>{if(!m||!r)return;let e=i?.current??h.current;if(!e)return;let t=()=>{if(document.hidden)return;let t=e.getBoundingClientRect();_({top:t.bottom,left:t.left,width:t.width})};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[m,r,i]);let v=(0,d.useMemo)(()=>JX(e,t),[e,t]),y=(0,d.useCallback)(e=>{n(e)},[n]),b=s?ZX(e)?null:l(`i18n.noBranches`):l(`i18n.noActiveSession`),x=(e.length>0?YX(e[0]):null)?.node??null,S=!b&&x&&x.children.length>1,C=(0,E.jsxs)(`svg`,{width:p.base,height:p.base,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,E.jsx)(`line`,{x1:`6`,y1:`3`,x2:`6`,y2:`15`}),(0,E.jsx)(`circle`,{cx:`18`,cy:`6`,r:`3`}),(0,E.jsx)(`circle`,{cx:`6`,cy:`18`,r:`3`}),(0,E.jsx)(`path`,{d:`M18 9a9 9 0 0 1-9 9`})]}),w=(0,E.jsx)(`svg`,{width:p.xs,height:p.xs,viewBox:`0 0 10 10`,fill:`none`,stroke:`var(--text-dim)`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{marginLeft:2,transform:m?`rotate(180deg)`:`none`,transition:`transform 0.15s`},children:(0,E.jsx)(`polyline`,{points:`2 3.5 5 6.5 8 3.5`})});return r?(0,E.jsxs)(`div`,{style:{height:`100%`,display:`flex`,alignItems:`stretch`},children:[(0,E.jsxs)(`button`,{ref:h,onClick:()=>o?o():f(e=>!e),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,alignSelf:`center`,width:32,height:32,padding:0,background:m?`var(--bg-selected)`:`transparent`,border:`1px solid`+(m?` var(--accent)`:` var(--border)`),borderRadius:7,cursor:`pointer`,color:m?`var(--text)`:`var(--text-muted)`,transition:`color 0.12s, background 0.12s, border-color 0.12s`,"--hover-color":`var(--text)`,"--hover-bg":`var(--bg-selected)`,"--hover-border":`color-mix(in srgb, var(--accent) 35%, transparent)`},className:`hover-shift`,"aria-label":l(`i18n.branches`),"aria-pressed":m,children:[C,!c&&(0,E.jsx)(`span`,{children:l(`i18n.branches`)})]}),m&&g&&(0,E.jsx)(`div`,{style:{position:`fixed`,top:g.top,left:g.left,width:g.width,background:`var(--bg)`,borderBottom:`1px solid var(--border)`,zIndex:1500},children:S&&x?(0,E.jsx)(`div`,{style:{padding:`4px 12px 8px 12px`,maxHeight:260,overflowY:`auto`},children:x.children.map((e,t)=>(0,E.jsx)(QX,{node:e,activePathIds:v,depth:0,isLast:t===x.children.length-1,parentLines:[],onSelect:y},e.entry.id))}):(0,E.jsx)(`div`,{style:{padding:`10px 16px`,fontSize:`var(--text-base)`,color:`var(--text-muted)`,fontStyle:`italic`},children:b})})]}):(0,E.jsxs)(`div`,{style:{borderBottom:`1px solid var(--border)`,background:`var(--bg)`,flexShrink:0,position:`relative`},children:[(0,E.jsxs)(`button`,{onClick:()=>f(e=>!e),style:{display:`flex`,alignItems:`center`,gap:6,width:`100%`,padding:`5px 12px`,background:`none`,border:`none`,cursor:`pointer`,color:`var(--text-muted)`,fontSize:`var(--text-sm)`,textAlign:`left`},children:[C,(0,E.jsx)(`span`,{style:{color:`var(--text-muted)`},children:l(`i18n.branches`)}),w]}),m&&(0,E.jsx)(`div`,{style:{position:`absolute`,top:`100%`,left:0,right:0,background:`var(--bg)`,borderBottom:`1px solid var(--border)`,boxShadow:`0 4px 12px var(--shadow-color)`,zIndex:100},children:S&&x?(0,E.jsx)(`div`,{style:{padding:`4px 12px 8px 12px`,maxHeight:260,overflowY:`auto`},children:x.children.map((e,t)=>(0,E.jsx)(QX,{node:e,activePathIds:v,depth:0,isLast:t===x.children.length-1,parentLines:[],onSelect:y},e.entry.id))}):(0,E.jsx)(`div`,{style:{padding:`10px 16px`,fontSize:`var(--text-base)`,color:`var(--text-muted)`,fontStyle:`italic`},children:b??l(`i18n.noBranches`)})})]})}var eZ={preview:`_preview_1jmwf_1`,turn:`_turn_1jmwf_26`,number:`_number_1jmwf_47`,content:`_content_1jmwf_64`,user:`_user_1jmwf_69`,userText:`_userText_1jmwf_90`,assistant:`_assistant_1jmwf_104`,assistantJump:`_assistantJump_1jmwf_115`,outline:`_outline_1jmwf_143`,heading:`_heading_1jmwf_149`,paragraph:`_paragraph_1jmwf_150`},tZ=Dx(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function nZ({className:e,variant:t=`default`,asChild:n=!1,...r}){let i=n?Ni:`span`;return(0,E.jsx)(i,{"data-slot":`badge`,"data-variant":t,className:Cm(tZ({variant:t}),e),...r})}function rZ({number:e,active:t=!1,highlighted:n=!1}){return(0,E.jsx)(nZ,{variant:`outline`,className:`h-[1.6em] w-[3em] rounded-[0.25em] border-[1.5px] p-0 font-mono text-[0.625rem] font-semibold leading-none`,style:{background:t?`color-mix(in srgb, var(--accent) 12%, transparent)`:n?`color-mix(in srgb, var(--accent) 10%, transparent)`:`transparent`,borderColor:t||n?`var(--accent)`:`color-mix(in srgb, var(--text) 65%, transparent)`,boxShadow:t?`0 0 0 2px var(--bg-panel)`:n?`0 0 0 1px var(--accent), 0 1px 2px -1px var(--shadow-color)`:`0 1px 2px -1px var(--shadow-color)`,transition:`transform 0.1s, background 0.1s, box-shadow 0.1s`,transform:n?`scale(1.15)`:`scale(1)`},children:(0,E.jsx)(`span`,{style:{fontSize:`var(--text-xs)`,lineHeight:1,fontFamily:`var(--font-mono)`,fontWeight:600,userSelect:`none`,color:t?`var(--accent)`:`var(--text)`},children:String(e)})})}var iZ=48,aZ=12,oZ=26,sZ=2,cZ=250,lZ=1600;function uZ(e){return typeof e.content==`string`?e.content.trim():e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
358
|
+
`).trim()}function dZ(e){if(e.role!==`assistant`)return``;let{answerBlocks:t}=jY(e);return t.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
359
359
|
|
|
360
|
-
`).trim()}function uZ({level:e,children:t,headingIndex:n,onClick:r}){return(0,E.jsx)(`button`,{type:`button`,className:QX.heading,"data-level":e,"data-preview-heading-index":n??void 0,disabled:n===null||!r,onClick:e=>{e.stopPropagation(),n!==null&&r?.(n)},children:t})}function dZ(){return e=>{if(!Array.isArray(e.children))return;let t=e.children.filter(e=>e.type===`heading`&&typeof e.depth==`number`&&e.depth<=3);if(t.length>0){t.forEach((e,t)=>{e.data={...e.data,hProperties:{...e.data?.hProperties,"data-preview-heading-index":t}}}),e.children=t;return}let n=e.children.find(e=>e.type===`paragraph`);e.children=n?[n]:[]}}var fZ=[...pG??[],dZ];function pZ(e){let t=e?.properties,n=t?.dataPreviewHeadingIndex??t?.[`data-preview-heading-index`];return typeof n==`number`?n:typeof n==`string`&&/^\d+$/.test(n)?Number(n):null}var mZ=(0,d.memo)(function({markdown:e,onHeadingClick:t,onAnswerClick:n}){return e?(0,E.jsx)(`div`,{className:QX.outline,children:(0,E.jsx)(Ok,{remarkPlugins:fZ,components:{h1:({children:e,node:n})=>(0,E.jsx)(uZ,{level:1,headingIndex:pZ(n),onClick:t,children:e}),h2:({children:e,node:n})=>(0,E.jsx)(uZ,{level:2,headingIndex:pZ(n),onClick:t,children:e}),h3:({children:e,node:n})=>(0,E.jsx)(uZ,{level:3,headingIndex:pZ(n),onClick:t,children:e}),h4:()=>null,h5:()=>null,h6:()=>null,p:({children:e})=>(0,E.jsx)(`button`,{type:`button`,className:QX.paragraph,onClick:n,children:e}),blockquote:()=>null,ul:()=>null,ol:()=>null,pre:()=>null,table:()=>null,hr:()=>null,a:({children:e})=>(0,E.jsx)(E.Fragment,{children:e}),code:({children:e})=>(0,E.jsx)(E.Fragment,{children:e})},children:e})}):null});function hZ(e){return e.map((e,t)=>({topRatio:0,targetTurn:e,index:t}))}function gZ({messages:e,streamingMessage:t,scrollContainer:n,messageRefs:r,resolveMessageOffset:i,scrollStepPx:a=200,onWindowJumpTo:o}){let[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)([]),[f,p]=(0,d.useState)(null),[m,h]=(0,d.useState)(600),[g,_]=(0,d.useState)(0),[v,y]=(0,d.useState)(!1),[b,x]=(0,d.useState)(null),S=(0,d.useRef)(!1),C=(0,d.useRef)(null),w=(0,d.useRef)(null),T=(0,d.useRef)(null),D=(0,d.useRef)([]),O=(0,d.useRef)(null),k=(0,d.useRef)(null),A=(0,d.useRef)(null),j=(0,d.useRef)(null),M=(0,d.useRef)(null),N=(0,d.useRef)(null),P=(0,d.useRef)(null),ee=(0,d.useMemo)(()=>t?[...e,t]:e,[e,t]),F=(0,d.useRef)(ee);F.current=ee;let te=(0,d.useCallback)(e=>{A.current={index:e,until:Date.now()+sZ},p(e)},[]),ne=(0,d.useCallback)((e,t,n=!1)=>{let r=A.current;if(r&&Date.now()<r.until){if(n)A.current=null;else{p(r.index);return}}A.current=null;let i=e.scrollTop+e.clientHeight/2,a=e.getBoundingClientRect().top,o=null;for(let n of t){let t=n.targetTurn.userElement,r=n.targetTurn.scrollTop;if(t?.isConnected&&(r=t.getBoundingClientRect().top-a+e.scrollTop),r!==null){if(r<=i)o=n;else break}}p(o?o.index:null)},[]),re=(0,d.useCallback)(()=>{let e=n.current;if(!e||e.scrollHeight-e.clientHeight-e.scrollTop>16)return;let t=w.current;if(!t)return;let r=Math.max(0,t.scrollHeight-t.clientHeight);t.scrollTop!==r&&(t.scrollTop=r)},[n]),ie=(0,d.useCallback)(()=>{if(document.hidden)return;let e=n.current;if(!e)return;let t=e.scrollHeight-e.clientHeight;c(t>20),ne(e,D.current,!0),re()},[n,ne,re]),ae=(0,d.useRef)(null),oe=(0,d.useCallback)(()=>{if(document.hidden)return;let e=n.current,t=C.current;if(!e||!t)return;let a=e.getBoundingClientRect(),o=[],s=0,l=null,d=F.current;for(let t=0;t<d.length;t++){let n=d[t];if(n.role!==`user`&&n.role!==`assistant`)continue;let c=r.current?.[s];s++;let u=null;if(i?u=i(t):c&&(u=c.getBoundingClientRect().top-a.top+e.scrollTop),n.role===`user`){l=null,l={userMessage:n,userElement:c,assistantPreviews:[],scrollTop:u},o.push(l);continue}if(!l)continue;let f=lZ(n);f&&l.assistantPreviews.push({markdown:f,element:c,msgIdx:t})}let f=hZ(o);h(t.clientHeight),D.current=f,u(f),c(e.scrollHeight-e.clientHeight>20),ne(e,f),re();let p=P.current,m=p?f[p.nodeIndex]:null;if(p&&m){let t=p.assistantIndex===void 0?null:m.targetTurn.assistantPreviews[p.assistantIndex],n=m.targetTurn.scrollTop;if(p.target===`user`){let t=m.targetTurn.userElement?.getBoundingClientRect();n=t?t.top-a.top+e.scrollTop:null}else if(p.target===`assistant`){let r=t?.element?.getBoundingClientRect();n=r?r.top-a.top+e.scrollTop:null}else if(p.target===`heading`){let r=(p.headingIndex===void 0?null:t?.element?.querySelectorAll(`h1, h2, h3`).item(p.headingIndex))?.getBoundingClientRect();n=r?r.top-a.top+e.scrollTop:null}if(n===null)return;P.current=null,te(m.index);let r=e.clientHeight*.3;e.scrollTo({top:Math.max(0,n-r),behavior:`smooth`})}},[te,r,i,n,ne,re]),I=(0,d.useCallback)(()=>{document.hidden||(ae.current||=setTimeout(()=>{ae.current=null,!document.hidden&&oe()},150))},[oe]);(0,d.useEffect)(()=>{let e=n.current;if(e)return e.addEventListener(`scroll`,ie,{passive:!0}),()=>e.removeEventListener(`scroll`,ie)},[n,ie]),(0,d.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{document.hidden||(I(),ie())},r=new ResizeObserver(t);return r.observe(e),e.firstElementChild&&r.observe(e.firstElementChild),t(),()=>{r.disconnect(),ae.current&&=(clearTimeout(ae.current),null)}},[I,n,ie]),(0,d.useEffect)(()=>{let e=setTimeout(()=>{I(),ie()},50);return()=>clearTimeout(e)},[e.length,I,ie]);let L=(0,d.useRef)(null);(0,d.useLayoutEffect)(()=>{let e=L.current;if(e===null)return;L.current=null;let t=n.current;t&&(t.scrollTop=e)});let se=(0,d.useCallback)((e,t)=>{let r=n.current;if(!r)return;if(te(e.index),e.targetTurn.scrollTop===null){r.scrollTo({top:r.scrollHeight,behavior:t});return}let i=e.targetTurn.userElement;if(i){let e=r.getBoundingClientRect(),n=i.getBoundingClientRect().top-e.top+r.scrollTop-r.clientHeight*.3;r.scrollTo({top:Math.max(0,n),behavior:t});return}P.current={nodeIndex:e.index,target:`user`};let a=Math.max(0,e.targetTurn.scrollTop-r.clientHeight*.3);Math.abs(a-r.scrollTop)>r.clientHeight*3||t===`auto`?(o(a),L.current=a):r.scrollTo({top:a,behavior:t}),setTimeout(()=>I(),400)},[te,I,o,n]),R=(0,d.useCallback)((e,t)=>{let r=n.current;if(!r)return;let a=e.targetTurn.assistantPreviews[t]?.element;if(!a){P.current={nodeIndex:e.index,target:`assistant`,assistantIndex:t};let n=e.targetTurn.assistantPreviews[t],a=n&&i?i(n.msgIdx):null;if(a!==null){let e=Math.max(0,a-r.clientHeight*.3);Math.abs(e-r.scrollTop)>r.clientHeight*3?(o(e),L.current=e):r.scrollTo({top:e,behavior:`smooth`})}else e.targetTurn.scrollTop!==null&&r.scrollTo({top:Math.max(0,e.targetTurn.scrollTop-r.clientHeight*.3),behavior:`smooth`});setTimeout(()=>I(),400);return}let s=r.getBoundingClientRect(),c=a.getBoundingClientRect().top-s.top+r.scrollTop-r.clientHeight*.3;te(e.index),r.scrollTo({top:Math.max(0,c),behavior:`smooth`})},[te,I,o,i,n]),ce=(0,d.useCallback)(e=>{let t=D.current;if(t.length===0)return null;let n=Math.round((e-rZ)/iZ);return t[Math.max(0,Math.min(n,t.length-1))]??null},[]),le=(0,d.useCallback)((e,t,r)=>{let a=n.current;if(!a)return;let s=e.targetTurn.assistantPreviews[t]?.element;if(!s){P.current={nodeIndex:e.index,target:`heading`,assistantIndex:t,headingIndex:r};let n=e.targetTurn.assistantPreviews[t],s=n&&i?i(n.msgIdx):null;if(s!==null){let e=Math.max(0,s-a.clientHeight*.3);Math.abs(e-a.scrollTop)>a.clientHeight*3?(o(e),L.current=e):a.scrollTo({top:e,behavior:`smooth`})}else e.targetTurn.scrollTop!==null&&a.scrollTo({top:Math.max(0,e.targetTurn.scrollTop-a.clientHeight*.3),behavior:`smooth`});setTimeout(()=>I(),400);return}let c=s.querySelectorAll(`h1, h2, h3`).item(r);if(!c)return;let l=a.getBoundingClientRect(),u=c.getBoundingClientRect().top-l.top+a.scrollTop-a.clientHeight*.3;te(e.index),a.scrollTo({top:Math.max(0,u),behavior:`smooth`})},[te,I,o,i,n]),ue=pe(),de=(0,d.useCallback)(()=>{ue.cancel(),y(!0)},[ue]),fe=(0,d.useCallback)(()=>{ue.cancel(),y(!1),x(null)},[ue]),me=(0,d.useCallback)(()=>{ue.schedule(fe,oZ)},[ue,fe]);(0,d.useEffect)(()=>()=>{j.current!==null&&cancelAnimationFrame(j.current),M.current!==null&&cancelAnimationFrame(M.current)},[]);let he=(0,d.useCallback)(e=>{if(!s)return;S.current=!0,de();let t=e.currentTarget.getBoundingClientRect(),n=w.current?.scrollTop??0,r=n+(e.clientY-t.top);x(r);let i=e=>{S.current&&M.current===null&&(M.current=requestAnimationFrame(()=>{M.current=null,x(n+(e.clientY-t.top))}))},a=()=>{S.current=!1,M.current!==null&&(cancelAnimationFrame(M.current),M.current=null),window.removeEventListener(`mousemove`,i),window.removeEventListener(`mouseup`,a)};window.addEventListener(`mousemove`,i),window.addEventListener(`mouseup`,a)},[de,s]),ge=b===null?null:ce(b);(0,d.useLayoutEffect)(()=>{if(!v||ge===null)return;let e=O.current;if(!e)return;let t=w.current?.scrollTop??0,n=rZ+ge.index*iZ-t,r=Math.max(0,m-e.offsetHeight),i=Math.min(Math.max(n-e.offsetHeight/2,0),r);e.style.top=`${i}px`},[v,ge,m,g]);let _e=(0,d.useCallback)(()=>{T.current===null&&(T.current=requestAnimationFrame(()=>{T.current=null;let e=w.current;e&&_(e.scrollTop)}))},[]),ve=(0,d.useCallback)(e=>{let t=w.current;if(!t)return;let n=Math.max(0,t.scrollHeight-t.clientHeight);k.current=e===`top`?0:n,t.scrollTo({top:e===`top`?0:n,behavior:`smooth`})},[]),ye=(0,d.useCallback)(e=>{let t=w.current;if(!t)return;let n=Math.max(0,t.scrollHeight-t.clientHeight),r=k.current??t.scrollTop,i=Math.max(0,Math.min(n,r+e*a));k.current=i,t.scrollTo({top:i,behavior:`auto`})},[a]);if(!s)return null;let be=l.length*iZ+24,xe=Math.max(1,m),Se=Math.max(0,Math.floor(g/iZ)-aZ),Ce=Math.min(l.length,Math.ceil((g+xe)/iZ)+aZ),we=l.slice(Se,Ce),Te=g<=2,Ee=g>=be-xe-2;return(0,E.jsxs)(`div`,{ref:C,"data-testid":`chat-minimap`,"data-minimap":``,onMouseDown:he,onMouseLeave:()=>{me()},onMouseMove:e=>{let t=e.currentTarget.getBoundingClientRect(),n=(w.current?.scrollTop??0)+(e.clientY-t.top);N.current=n,j.current===null&&(j.current=requestAnimationFrame(()=>{j.current=null,x(N.current??0)}))},style:{width:nZ,position:`absolute`,top:0,bottom:0,right:_Y,zIndex:130,cursor:`pointer`,userSelect:`none`},children:[(0,E.jsx)(`div`,{ref:w,"data-minimap-rail":``,onScroll:_e,onMouseDown:he,onMouseMove:e=>{let t=w.current,n=e.currentTarget.getBoundingClientRect(),r=(t?.scrollTop??0)+(e.clientY-n.top);N.current=r,j.current===null&&(j.current=requestAnimationFrame(()=>{j.current=null,x(N.current??0)}))},style:{position:`absolute`,inset:0,overflowY:`auto`,scrollbarWidth:`none`,overflowAnchor:`none`,cursor:`pointer`,userSelect:`none`},children:(0,E.jsx)(`div`,{style:{position:`relative`,height:be},children:we.map(e=>{let t=v&&ge?.index===e.index,n=f===e.index;return(0,E.jsx)(`div`,{"data-minimap-node-index":e.index,"data-minimap-node-active":n?``:void 0,onMouseEnter:()=>{x(rZ+e.index*iZ),de()},onMouseLeave:me,style:{position:`absolute`,top:rZ+e.index*iZ,transform:`translateY(-50%)`,left:0,right:0,height:iZ,display:`flex`,alignItems:`center`,justifyContent:`center`,pointerEvents:`auto`,zIndex:2},children:(0,E.jsx)(tZ,{number:e.index+1,active:n,highlighted:t})},e.index)})})}),Te?null:(0,E.jsx)(Bn,{direction:`up`,visible:!0,onHover:()=>ye(-1),onClick:()=>ve(`top`),label:`Scroll minimap rail to top`,testId:`rail-scroll-up`}),Ee?null:(0,E.jsx)(Bn,{direction:`down`,visible:!0,onHover:()=>ye(1),onClick:()=>ve(`bottom`),label:`Scroll minimap rail to bottom`,testId:`rail-scroll-down`}),v&&l.length>0&&(0,E.jsx)(`div`,{ref:O,className:QX.preview,"data-minimap-preview-box":``,onMouseEnter:de,onMouseDown:e=>e.stopPropagation(),onMouseMove:e=>e.stopPropagation(),children:ge!==null&&(()=>{let e=l.length,t=Math.min(Math.max(0,ge.index-2),Math.max(0,e-5));return l.slice(t,t+5).map(e=>(0,E.jsxs)(`div`,{className:QX.turn,"data-minimap-preview-index":e.index,"data-located":e.index===ge.index?`true`:void 0,children:[(0,E.jsx)(`span`,{className:QX.number,"aria-hidden":`true`,children:String(e.index+1)}),(0,E.jsxs)(`div`,{className:QX.content,children:[(0,E.jsx)(`button`,{type:`button`,className:QX.user,"data-minimap-preview-user":e.index,onClick:()=>{se(e,`smooth`),fe()},children:(0,E.jsx)(`span`,{className:QX.userText,children:cZ(e.targetTurn.userMessage)})}),e.targetTurn.assistantPreviews.map((t,n)=>(0,E.jsxs)(`div`,{className:QX.assistant,children:[(0,E.jsx)(oi,{label:`Locate assistant message`,wrapperStyle:{display:`contents`},children:(0,E.jsx)(`button`,{type:`button`,className:QX.assistantJump,"data-minimap-preview-assistant":`${e.index}-${n}`,onClick:()=>{R(e,n),fe()},"aria-label":`Locate assistant message`,children:`A`})}),(0,E.jsx)(mZ,{markdown:t.markdown,onAnswerClick:()=>{R(e,n),fe()},onHeadingClick:t=>{le(e,n,t),fe()}})]},n))]})]},e.index))})()})]})}function _Z(e){let t=(0,d.useRef)([]);return t.current=Array(e).fill(null).map((e,n)=>t.current[n]??null),t}function vZ(e){return e.replace(/[\r\n\t]/g,` `).replace(/ +/g,` `).trim()}function yZ(e){return[...e].sort((e,t)=>e.key.localeCompare(t.key)).map(({text:e})=>vZ(e)).join(` `)}var bZ=/<(read-files|modified-files)>\s*([\s\S]*?)\s*<\/\1>/g,xZ=/(?:\r?\n){2,}((?:[ \t]*<(?:read-files|modified-files)>[ \t]*\r?\n[\s\S]*?\r?\n[ \t]*<\/(?:read-files|modified-files)>[ \t]*(?:\r?\n)?)+)\s*$/;function SZ(e){let t=[],n=[],r=e.match(xZ),i=r?.[1]??``,a=r?.index===void 0?e:e.slice(0,r.index);return i.replace(bZ,(e,r,i)=>{let a=i.split(/\r?\n/).map(e=>e.trim()).filter(Boolean);return r===`read-files`?t.push(...a):n.push(...a),``}),{body:a.trim(),readFiles:t,modifiedFiles:n}}var CZ=50;function wZ(e,t,n){let r=(0,d.useRef)(!1),i=()=>{let t=e.current;t&&(r.current=t.scrollHeight-t.scrollTop-t.clientHeight>CZ)};return(0,d.useLayoutEffect)(()=>{let n=e.current;!t||!n||r.current||(n.scrollTop=n.scrollHeight-n.clientHeight)},[t,...n]),i}function TZ(e){let t=[],n=null,r,i=0,a=0,o=[],s=[],c=()=>({lineNo:null,text:``,type:`empty`}),l=()=>{if(!n){o=[],s=[];return}let e=Math.max(o.length,s.length);for(let t=0;t<e;t++){let e=o[t]?{lineNo:o[t].lineNo,text:o[t].text,type:`removed`}:c(),r=s[t]?{lineNo:s[t].lineNo,text:s[t].text,type:`added`}:c();n.rows.push({type:`line`,left:e,right:r})}o=[],s=[]};for(let c of e.split(/\r?\n/)){if(c.startsWith(`--- `)){l(),r=EZ(c.slice(4));continue}if(c.startsWith(`+++ `)){l(),n={oldPath:r,newPath:EZ(c.slice(4)),rows:[]},t.push(n);continue}let e=c.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(e){n||(n={rows:[]},t.push(n)),l(),i=Number(e[1]),a=Number(e[2]),n.rows.push({type:`hunk`,text:c});continue}if(!n)continue;if(c.startsWith(`\\ `)){l(),n.rows.push({type:`hunk`,text:c});continue}let u=c[0],d=c.slice(1);u===` `?(l(),n.rows.push({type:`line`,left:{lineNo:i++,text:d,type:`context`},right:{lineNo:a++,text:d,type:`context`}})):u===`-`?o.push({lineNo:i++,text:d}):u===`+`?s.push({lineNo:a++,text:d}):c!==``&&(l(),n.rows.push({type:`hunk`,text:c}))}l();let u=t.filter(e=>e.rows.some(e=>e.type===`line`));return u.length>0?u:null}function EZ(e){return e.split(` `)[0].trim()}var DZ={indicator:`indicator`,textOnly:`text-only`,remove:`remove`};function OZ({defaultOrigin:e=``,allowedLinkPrefixes:t=[],allowedImagePrefixes:n=[],allowDataImages:r=!1,allowedProtocols:i=[],blockedImageClass:a=`inline-block bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-400 px-3 py-1 rounded text-sm`,blockedLinkClass:o=`text-gray-500`,linkBlockPolicy:s=DZ.indicator,imageBlockPolicy:c=DZ.indicator}){let l=t.length&&!t.every(e=>e===`*`),u=n.length&&!n.every(e=>e===`*`);if(!e&&(l||u))throw Error(`defaultOrigin is required when allowedLinkPrefixes or allowedImagePrefixes are provided`);return l=>{let u=RZ(e,t,n,r,i,a,o,s,c);PZ(l),AO(l,u)}}function kZ(e,t){if(typeof e!=`string`)return null;try{return new URL(e)}catch{if(t)try{return new URL(e,t)}catch{return null}if(e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`))try{return new URL(e,`http://example.com`)}catch{return null}return null}}function AZ(e){return typeof e==`string`?e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`):!1}var jZ=new Set([`https:`,`http:`,`irc:`,`ircs:`,`mailto:`,`xmpp:`,`blob:`]),MZ=new Set([`javascript:`,`data:`,`file:`,`vbscript:`]);function NZ(e,t,n,r=!1,i=!1,a=[]){if(!e)return null;if(typeof e==`string`&&e.startsWith(`#`)&&!i)try{if(new URL(e,`http://example.com`).hash===e)return e}catch{}if(typeof e==`string`&&e.startsWith(`data:`))return i&&r&&e.startsWith(`data:image/`)?e:null;if(typeof e==`string`&&e.startsWith(`blob:`)){try{if(new URL(e).protocol===`blob:`&&e.length>5){let t=e.substring(5);if(t&&t.length>0&&t!==`invalid`)return e}}catch{return null}return null}let o=kZ(e,n);if(!o||MZ.has(o.protocol)||!(jZ.has(o.protocol)||a.includes(o.protocol)||a.includes(`*`)))return null;if(o.protocol===`mailto:`||!o.protocol.match(/^https?:$/))return o.href;let s=AZ(e);return o&&t.some(e=>{let t=kZ(e,n);return!t||t.origin!==o.origin?!1:o.href.startsWith(t.href)})?s?o.pathname+o.search+o.hash:o.href:t.includes(`*`)?o.protocol!==`https:`&&o.protocol!==`http:`?null:s?o.pathname+o.search+o.hash:o.href:null}function PZ(e){if(`children`in e&&Array.isArray(e.children)){e.children=e.children.filter(e=>e!=null);for(let t of e.children)PZ(t)}}var FZ=Symbol(`node-seen`);function IZ(e,t,n){return t===DZ.remove?{type:`remove`}:t===DZ.textOnly?{type:`replace`,element:{type:`element`,tagName:`span`,properties:{},children:[...e.children]}}:{type:`replace`,element:{type:`element`,tagName:`span`,properties:{title:`Blocked URL: `+String(e.properties.href),class:n},children:[...e.children,{type:`text`,value:` [blocked]`}]}}}function LZ(e,t,n){if(t===DZ.remove)return{type:`remove`};if(t===DZ.textOnly){let t=String(e.properties.alt||``);return t?{type:`replace`,element:{type:`element`,tagName:`span`,properties:{},children:[{type:`text`,value:t}]}}:{type:`remove`}}return{type:`replace`,element:{type:`element`,tagName:`span`,properties:{class:n},children:[{type:`text`,value:`[Image blocked: `+String(e.properties.alt||`No description`)+`]`}]}}}var RZ=(e,t,n,r,i,a,o,s,c)=>{let l=(u,d,f)=>{if(u.type!==`element`||u[FZ])return!0;if(u.tagName===`a`){let n=NZ(u.properties.href,t,e,!1,!1,i);if(n===null){if(u[FZ]=!0,AO(u,l),f&&typeof d==`number`){let e=IZ(u,s,o);if(e.type===`remove`)return f.children.splice(d,1),[DO,d];f.children[d]=e.element}return DO}return u.properties.href=n,u.properties.target=`_blank`,u.properties.rel=`noopener noreferrer`,!0}if(u.tagName===`img`){let t=NZ(u.properties.src,n,e,r,!0,i);if(t===null){if(u[FZ]=!0,AO(u,l),f&&typeof d==`number`){let e=LZ(u,c,a);if(e.type===`remove`)return f.children.splice(d,1),[DO,d];f.children[d]=e.element}return DO}return u.properties.src=t,!0}return!0};return l},zZ=Object.defineProperty,BZ=Object.defineProperties,VZ=Object.getOwnPropertyDescriptors,HZ=Object.getOwnPropertySymbols,UZ=Object.prototype.hasOwnProperty,WZ=Object.prototype.propertyIsEnumerable,GZ=(e,t,n)=>t in e?zZ(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,KZ=(e,t)=>{for(var n in t||={})UZ.call(t,n)&&GZ(e,n,t[n]);if(HZ)for(var n of HZ(t))WZ.call(t,n)&&GZ(e,n,t[n]);return e},qZ=(e,t)=>BZ(e,VZ(t)),JZ=(e,t)=>{let n=!1,r=!1;for(let i=0;i<t;i+=1){if(e[i]===`\\`&&i+1<e.length&&e[i+1]==="`"){i+=1;continue}if(e.substring(i,i+3)==="```"){r=!r,i+=2;continue}!r&&e[i]==="`"&&(n=!n)}return n||r},YZ=(e,t)=>{let n=e.substring(t,t+3)==="```",r=t>0&&e.substring(t-1,t+2)==="```",i=t>1&&e.substring(t-2,t+1)==="```";return n||r||i},XZ=e=>{let t=0;for(let n=0;n<e.length;n+=1){if(e[n]===`\\`&&n+1<e.length&&e[n+1]==="`"){n+=1;continue}e[n]==="`"&&!YZ(e,n)&&(t+=1)}return t},ZZ=(e,t)=>{let n=!1,r=!1,i=-1;for(let a=0;a<e.length;a+=1){if(e[a]===`\\`&&a+1<e.length&&e[a+1]==="`"){a+=1;continue}if(e.substring(a,a+3)==="```"){r=!r,a+=2;continue}if(!r&&e[a]==="`"){if(n){if(i<t&&t<a)return!0;n=!1,i=-1}else n=!0,i=a}}return!1},QZ=/^(\s*(?:[-*+]|\d+[.)]) +)>(=?\s*[$]?\d)/gm,$Z=e=>!e||typeof e!=`string`||!e.includes(`>`)?e:e.replace(QZ,(t,n,r,i)=>JZ(e,i)?t:`${n}\\>${r}`),eQ=/(\*\*)([^*]*\*?)$/,tQ=/(__)([^_]*?)$/,nQ=/(\*\*\*)([^*]*?)$/,rQ=/(\*)([^*]*?)$/,iQ=/(_)([^_]*?)$/,aQ=/(`)([^`]*?)$/,oQ=/(~~)([^~]*?)$/,sQ=/^[\s_~*`]*$/,cQ=/^[\s]*[-*+][\s]+$/,lQ=/[\p{L}\p{N}_]/u,uQ=/^```[^`\n]*```?$/,dQ=/^\*{4,}$/,fQ=/(__)([^_]+)_$/,pQ=/(~~)([^~]+)~$/,mQ=/~~/g,hQ=e=>{if(!e)return!1;let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95||lQ.test(e)},gQ=(e,t)=>{let n=1;for(let r=t-1;r>=0;--r)if(e[r]===`]`)n+=1;else if(e[r]===`[`&&(--n,n===0))return r;return-1},_Q=(e,t)=>{let n=1;for(let r=t+1;r<e.length;r+=1)if(e[r]===`[`)n+=1;else if(e[r]===`]`&&(--n,n===0))return r;return-1},vQ=(e,t)=>{let n=!1,r=!1;for(let i=0;i<e.length&&i<t;i+=1){if(e[i]===`\\`&&e[i+1]===`$`){i+=1;continue}e[i]===`$`&&(e[i+1]===`$`?(r=!r,i+=1,n=!1):r||(n=!n))}return n||r},yQ=(e,t)=>{for(let n=t;n<e.length;n+=1){if(e[n]===`)`)return!0;if(e[n]===`
|
|
361
|
-
`)return!1}return!1},
|
|
362
|
-
`)return!1}return!1},
|
|
363
|
-
`)return!1}return!1},
|
|
360
|
+
`).trim()}function fZ({level:e,children:t,headingIndex:n,onClick:r}){return(0,E.jsx)(`button`,{type:`button`,className:eZ.heading,"data-level":e,"data-preview-heading-index":n??void 0,disabled:n===null||!r,onClick:e=>{e.stopPropagation(),n!==null&&r?.(n)},children:t})}function pZ(){return e=>{if(!Array.isArray(e.children))return;let t=e.children.filter(e=>e.type===`heading`&&typeof e.depth==`number`&&e.depth<=3);if(t.length>0){t.forEach((e,t)=>{e.data={...e.data,hProperties:{...e.data?.hProperties,"data-preview-heading-index":t}}}),e.children=t;return}let n=e.children.find(e=>e.type===`paragraph`);e.children=n?[n]:[]}}var mZ=[...pG??[],pZ];function hZ(e){let t=e?.properties,n=t?.dataPreviewHeadingIndex??t?.[`data-preview-heading-index`];return typeof n==`number`?n:typeof n==`string`&&/^\d+$/.test(n)?Number(n):null}var gZ=(0,d.memo)(function({markdown:e,onHeadingClick:t,onAnswerClick:n}){return e?(0,E.jsx)(`div`,{className:eZ.outline,children:(0,E.jsx)(Ok,{remarkPlugins:mZ,components:{h1:({children:e,node:n})=>(0,E.jsx)(fZ,{level:1,headingIndex:hZ(n),onClick:t,children:e}),h2:({children:e,node:n})=>(0,E.jsx)(fZ,{level:2,headingIndex:hZ(n),onClick:t,children:e}),h3:({children:e,node:n})=>(0,E.jsx)(fZ,{level:3,headingIndex:hZ(n),onClick:t,children:e}),h4:()=>null,h5:()=>null,h6:()=>null,p:({children:e})=>(0,E.jsx)(`button`,{type:`button`,className:eZ.paragraph,onClick:n,children:e}),blockquote:()=>null,ul:()=>null,ol:()=>null,pre:()=>null,table:()=>null,hr:()=>null,a:({children:e})=>(0,E.jsx)(E.Fragment,{children:e}),code:({children:e})=>(0,E.jsx)(E.Fragment,{children:e})},children:e})}):null});function _Z(e){return e.map((e,t)=>({topRatio:0,targetTurn:e,index:t}))}function vZ({messages:e,streamingMessage:t,scrollContainer:n,messageRefs:r,resolveMessageOffset:i,scrollStepPx:a=200,onWindowJumpTo:o}){let[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)([]),[f,p]=(0,d.useState)(null),[m,h]=(0,d.useState)(600),[g,_]=(0,d.useState)(0),[v,y]=(0,d.useState)(!1),[b,x]=(0,d.useState)(null),S=(0,d.useRef)(!1),C=(0,d.useRef)(null),w=(0,d.useRef)(null),T=(0,d.useRef)(null),D=(0,d.useRef)([]),O=(0,d.useRef)(null),k=(0,d.useRef)(null),A=(0,d.useRef)(null),j=(0,d.useRef)(null),M=(0,d.useRef)(null),N=(0,d.useRef)(null),P=(0,d.useRef)(null),ee=(0,d.useMemo)(()=>t?[...e,t]:e,[e,t]),F=(0,d.useRef)(ee);F.current=ee;let te=(0,d.useCallback)(e=>{A.current={index:e,until:Date.now()+lZ},p(e)},[]),ne=(0,d.useCallback)((e,t,n=!1)=>{let r=A.current;if(r&&Date.now()<r.until){if(n)A.current=null;else{p(r.index);return}}A.current=null;let i=e.scrollTop+e.clientHeight/2,a=e.getBoundingClientRect().top,o=null;for(let n of t){let t=n.targetTurn.userElement,r=n.targetTurn.scrollTop;if(t?.isConnected&&(r=t.getBoundingClientRect().top-a+e.scrollTop),r!==null){if(r<=i)o=n;else break}}p(o?o.index:null)},[]),re=(0,d.useCallback)(()=>{let e=n.current;if(!e||e.scrollHeight-e.clientHeight-e.scrollTop>16)return;let t=w.current;if(!t)return;let r=Math.max(0,t.scrollHeight-t.clientHeight);t.scrollTop!==r&&(t.scrollTop=r)},[n]),ie=(0,d.useCallback)(()=>{if(document.hidden)return;let e=n.current;if(!e)return;let t=e.scrollHeight-e.clientHeight;c(t>20),ne(e,D.current,!0),re()},[n,ne,re]),ae=(0,d.useRef)(null),oe=(0,d.useCallback)(()=>{if(document.hidden)return;let e=n.current,t=C.current;if(!e||!t)return;let a=e.getBoundingClientRect(),o=[],s=0,l=null,d=F.current;for(let t=0;t<d.length;t++){let n=d[t];if(n.role!==`user`&&n.role!==`assistant`)continue;let c=r.current?.[s];s++;let u=null;if(i?u=i(t):c&&(u=c.getBoundingClientRect().top-a.top+e.scrollTop),n.role===`user`){l=null,l={userMessage:n,userElement:c,assistantPreviews:[],scrollTop:u},o.push(l);continue}if(!l)continue;let f=dZ(n);f&&l.assistantPreviews.push({markdown:f,element:c,msgIdx:t})}let f=_Z(o);h(t.clientHeight),D.current=f,u(f),c(e.scrollHeight-e.clientHeight>20),ne(e,f),re();let p=P.current,m=p?f[p.nodeIndex]:null;if(p&&m){let t=p.assistantIndex===void 0?null:m.targetTurn.assistantPreviews[p.assistantIndex],n=m.targetTurn.scrollTop;if(p.target===`user`){let t=m.targetTurn.userElement?.getBoundingClientRect();n=t?t.top-a.top+e.scrollTop:null}else if(p.target===`assistant`){let r=t?.element?.getBoundingClientRect();n=r?r.top-a.top+e.scrollTop:null}else if(p.target===`heading`){let r=(p.headingIndex===void 0?null:t?.element?.querySelectorAll(`h1, h2, h3`).item(p.headingIndex))?.getBoundingClientRect();n=r?r.top-a.top+e.scrollTop:null}if(n===null)return;P.current=null,te(m.index);let r=e.clientHeight*.3;e.scrollTo({top:Math.max(0,n-r),behavior:`smooth`})}},[te,r,i,n,ne,re]),I=(0,d.useCallback)(()=>{document.hidden||(ae.current||=setTimeout(()=>{ae.current=null,!document.hidden&&oe()},150))},[oe]);(0,d.useEffect)(()=>{let e=n.current;if(e)return e.addEventListener(`scroll`,ie,{passive:!0}),()=>e.removeEventListener(`scroll`,ie)},[n,ie]),(0,d.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{document.hidden||(I(),ie())},r=new ResizeObserver(t);return r.observe(e),e.firstElementChild&&r.observe(e.firstElementChild),t(),()=>{r.disconnect(),ae.current&&=(clearTimeout(ae.current),null)}},[I,n,ie]),(0,d.useEffect)(()=>{let e=setTimeout(()=>{I(),ie()},50);return()=>clearTimeout(e)},[e.length,I,ie]);let L=(0,d.useRef)(null);(0,d.useLayoutEffect)(()=>{let e=L.current;if(e===null)return;L.current=null;let t=n.current;t&&(t.scrollTop=e)});let se=(0,d.useCallback)((e,t)=>{let r=n.current;if(!r)return;if(te(e.index),e.targetTurn.scrollTop===null){r.scrollTo({top:r.scrollHeight,behavior:t});return}let i=e.targetTurn.userElement;if(i){let e=r.getBoundingClientRect(),n=i.getBoundingClientRect().top-e.top+r.scrollTop-r.clientHeight*.3;r.scrollTo({top:Math.max(0,n),behavior:t});return}P.current={nodeIndex:e.index,target:`user`};let a=Math.max(0,e.targetTurn.scrollTop-r.clientHeight*.3);Math.abs(a-r.scrollTop)>r.clientHeight*3||t===`auto`?(o(a),L.current=a):r.scrollTo({top:a,behavior:t}),setTimeout(()=>I(),400)},[te,I,o,n]),R=(0,d.useCallback)((e,t)=>{let r=n.current;if(!r)return;let a=e.targetTurn.assistantPreviews[t]?.element;if(!a){P.current={nodeIndex:e.index,target:`assistant`,assistantIndex:t};let n=e.targetTurn.assistantPreviews[t],a=n&&i?i(n.msgIdx):null;if(a!==null){let e=Math.max(0,a-r.clientHeight*.3);Math.abs(e-r.scrollTop)>r.clientHeight*3?(o(e),L.current=e):r.scrollTo({top:e,behavior:`smooth`})}else e.targetTurn.scrollTop!==null&&r.scrollTo({top:Math.max(0,e.targetTurn.scrollTop-r.clientHeight*.3),behavior:`smooth`});setTimeout(()=>I(),400);return}let s=r.getBoundingClientRect(),c=a.getBoundingClientRect().top-s.top+r.scrollTop-r.clientHeight*.3;te(e.index),r.scrollTo({top:Math.max(0,c),behavior:`smooth`})},[te,I,o,i,n]),ce=(0,d.useCallback)(e=>{let t=D.current;if(t.length===0)return null;let n=Math.round((e-aZ)/oZ);return t[Math.max(0,Math.min(n,t.length-1))]??null},[]),le=(0,d.useCallback)((e,t,r)=>{let a=n.current;if(!a)return;let s=e.targetTurn.assistantPreviews[t]?.element;if(!s){P.current={nodeIndex:e.index,target:`heading`,assistantIndex:t,headingIndex:r};let n=e.targetTurn.assistantPreviews[t],s=n&&i?i(n.msgIdx):null;if(s!==null){let e=Math.max(0,s-a.clientHeight*.3);Math.abs(e-a.scrollTop)>a.clientHeight*3?(o(e),L.current=e):a.scrollTo({top:e,behavior:`smooth`})}else e.targetTurn.scrollTop!==null&&a.scrollTo({top:Math.max(0,e.targetTurn.scrollTop-a.clientHeight*.3),behavior:`smooth`});setTimeout(()=>I(),400);return}let c=s.querySelectorAll(`h1, h2, h3`).item(r);if(!c)return;let l=a.getBoundingClientRect(),u=c.getBoundingClientRect().top-l.top+a.scrollTop-a.clientHeight*.3;te(e.index),a.scrollTo({top:Math.max(0,u),behavior:`smooth`})},[te,I,o,i,n]),ue=pe(),de=(0,d.useCallback)(()=>{ue.cancel(),y(!0)},[ue]),fe=(0,d.useCallback)(()=>{ue.cancel(),y(!1),x(null)},[ue]),me=(0,d.useCallback)(()=>{ue.schedule(fe,cZ)},[ue,fe]);(0,d.useEffect)(()=>()=>{j.current!==null&&cancelAnimationFrame(j.current),M.current!==null&&cancelAnimationFrame(M.current)},[]);let he=(0,d.useCallback)(e=>{if(!s)return;S.current=!0,de();let t=e.currentTarget.getBoundingClientRect(),n=w.current?.scrollTop??0,r=n+(e.clientY-t.top);x(r);let i=e=>{S.current&&M.current===null&&(M.current=requestAnimationFrame(()=>{M.current=null,x(n+(e.clientY-t.top))}))},a=()=>{S.current=!1,M.current!==null&&(cancelAnimationFrame(M.current),M.current=null),window.removeEventListener(`mousemove`,i),window.removeEventListener(`mouseup`,a)};window.addEventListener(`mousemove`,i),window.addEventListener(`mouseup`,a)},[de,s]),ge=b===null?null:ce(b);(0,d.useLayoutEffect)(()=>{if(!v||ge===null)return;let e=O.current;if(!e)return;let t=w.current?.scrollTop??0,n=aZ+ge.index*oZ-t,r=Math.max(0,m-e.offsetHeight),i=Math.min(Math.max(n-e.offsetHeight/2,0),r);e.style.top=`${i}px`},[v,ge,m,g]);let _e=(0,d.useCallback)(()=>{T.current===null&&(T.current=requestAnimationFrame(()=>{T.current=null;let e=w.current;e&&_(e.scrollTop)}))},[]),ve=(0,d.useCallback)(e=>{let t=w.current;if(!t)return;let n=Math.max(0,t.scrollHeight-t.clientHeight);k.current=e===`top`?0:n,t.scrollTo({top:e===`top`?0:n,behavior:`smooth`})},[]),ye=(0,d.useCallback)(e=>{let t=w.current;if(!t)return;let n=Math.max(0,t.scrollHeight-t.clientHeight),r=k.current??t.scrollTop,i=Math.max(0,Math.min(n,r+e*a));k.current=i,t.scrollTo({top:i,behavior:`auto`})},[a]);if(!s)return null;let be=l.length*oZ+24,xe=Math.max(1,m),Se=Math.max(0,Math.floor(g/oZ)-sZ),Ce=Math.min(l.length,Math.ceil((g+xe)/oZ)+sZ),we=l.slice(Se,Ce),Te=g<=2,Ee=g>=be-xe-2;return(0,E.jsxs)(`div`,{ref:C,"data-testid":`chat-minimap`,"data-minimap":``,onMouseDown:he,onMouseLeave:()=>{me()},onMouseMove:e=>{let t=e.currentTarget.getBoundingClientRect(),n=(w.current?.scrollTop??0)+(e.clientY-t.top);N.current=n,j.current===null&&(j.current=requestAnimationFrame(()=>{j.current=null,x(N.current??0)}))},style:{width:iZ,position:`absolute`,top:0,bottom:0,right:yY,zIndex:130,cursor:`pointer`,userSelect:`none`},children:[(0,E.jsx)(`div`,{ref:w,"data-minimap-rail":``,onScroll:_e,onMouseDown:he,onMouseMove:e=>{let t=w.current,n=e.currentTarget.getBoundingClientRect(),r=(t?.scrollTop??0)+(e.clientY-n.top);N.current=r,j.current===null&&(j.current=requestAnimationFrame(()=>{j.current=null,x(N.current??0)}))},style:{position:`absolute`,inset:0,overflowY:`auto`,scrollbarWidth:`none`,overflowAnchor:`none`,cursor:`pointer`,userSelect:`none`},children:(0,E.jsx)(`div`,{style:{position:`relative`,height:be},children:we.map(e=>{let t=v&&ge?.index===e.index,n=f===e.index;return(0,E.jsx)(`div`,{"data-minimap-node-index":e.index,"data-minimap-node-active":n?``:void 0,onMouseEnter:()=>{x(aZ+e.index*oZ),de()},onMouseLeave:me,style:{position:`absolute`,top:aZ+e.index*oZ,transform:`translateY(-50%)`,left:0,right:0,height:oZ,display:`flex`,alignItems:`center`,justifyContent:`center`,pointerEvents:`auto`,zIndex:2},children:(0,E.jsx)(rZ,{number:e.index+1,active:n,highlighted:t})},e.index)})})}),Te?null:(0,E.jsx)(Bn,{direction:`up`,visible:!0,onHover:()=>ye(-1),onClick:()=>ve(`top`),label:`Scroll minimap rail to top`,testId:`rail-scroll-up`}),Ee?null:(0,E.jsx)(Bn,{direction:`down`,visible:!0,onHover:()=>ye(1),onClick:()=>ve(`bottom`),label:`Scroll minimap rail to bottom`,testId:`rail-scroll-down`}),v&&l.length>0&&(0,E.jsx)(`div`,{ref:O,className:eZ.preview,"data-minimap-preview-box":``,onMouseEnter:de,onMouseDown:e=>e.stopPropagation(),onMouseMove:e=>e.stopPropagation(),children:ge!==null&&(()=>{let e=l.length,t=Math.min(Math.max(0,ge.index-2),Math.max(0,e-5));return l.slice(t,t+5).map(e=>(0,E.jsxs)(`div`,{className:eZ.turn,"data-minimap-preview-index":e.index,"data-located":e.index===ge.index?`true`:void 0,children:[(0,E.jsx)(`span`,{className:eZ.number,"aria-hidden":`true`,children:String(e.index+1)}),(0,E.jsxs)(`div`,{className:eZ.content,children:[(0,E.jsx)(`button`,{type:`button`,className:eZ.user,"data-minimap-preview-user":e.index,onClick:()=>{se(e,`smooth`),fe()},children:(0,E.jsx)(`span`,{className:eZ.userText,children:uZ(e.targetTurn.userMessage)})}),e.targetTurn.assistantPreviews.map((t,n)=>(0,E.jsxs)(`div`,{className:eZ.assistant,children:[(0,E.jsx)(oi,{label:`Locate assistant message`,wrapperStyle:{display:`contents`},children:(0,E.jsx)(`button`,{type:`button`,className:eZ.assistantJump,"data-minimap-preview-assistant":`${e.index}-${n}`,onClick:()=>{R(e,n),fe()},"aria-label":`Locate assistant message`,children:`A`})}),(0,E.jsx)(gZ,{markdown:t.markdown,onAnswerClick:()=>{R(e,n),fe()},onHeadingClick:t=>{le(e,n,t),fe()}})]},n))]})]},e.index))})()})]})}function yZ(e){let t=(0,d.useRef)([]);return t.current=Array(e).fill(null).map((e,n)=>t.current[n]??null),t}function bZ(e){return e.replace(/[\r\n\t]/g,` `).replace(/ +/g,` `).trim()}function xZ(e){return[...e].sort((e,t)=>e.key.localeCompare(t.key)).map(({text:e})=>bZ(e)).join(` `)}var SZ=/<(read-files|modified-files)>\s*([\s\S]*?)\s*<\/\1>/g,CZ=/(?:\r?\n){2,}((?:[ \t]*<(?:read-files|modified-files)>[ \t]*\r?\n[\s\S]*?\r?\n[ \t]*<\/(?:read-files|modified-files)>[ \t]*(?:\r?\n)?)+)\s*$/;function wZ(e){let t=[],n=[],r=e.match(CZ),i=r?.[1]??``,a=r?.index===void 0?e:e.slice(0,r.index);return i.replace(SZ,(e,r,i)=>{let a=i.split(/\r?\n/).map(e=>e.trim()).filter(Boolean);return r===`read-files`?t.push(...a):n.push(...a),``}),{body:a.trim(),readFiles:t,modifiedFiles:n}}var TZ=50;function EZ(e,t,n){let r=(0,d.useRef)(!1),i=()=>{let t=e.current;t&&(r.current=t.scrollHeight-t.scrollTop-t.clientHeight>TZ)};return(0,d.useLayoutEffect)(()=>{let n=e.current;!t||!n||r.current||(n.scrollTop=n.scrollHeight-n.clientHeight)},[t,...n]),i}function DZ(e){let t=[],n=null,r,i=0,a=0,o=[],s=[],c=()=>({lineNo:null,text:``,type:`empty`}),l=()=>{if(!n){o=[],s=[];return}let e=Math.max(o.length,s.length);for(let t=0;t<e;t++){let e=o[t]?{lineNo:o[t].lineNo,text:o[t].text,type:`removed`}:c(),r=s[t]?{lineNo:s[t].lineNo,text:s[t].text,type:`added`}:c();n.rows.push({type:`line`,left:e,right:r})}o=[],s=[]};for(let c of e.split(/\r?\n/)){if(c.startsWith(`--- `)){l(),r=OZ(c.slice(4));continue}if(c.startsWith(`+++ `)){l(),n={oldPath:r,newPath:OZ(c.slice(4)),rows:[]},t.push(n);continue}let e=c.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(e){n||(n={rows:[]},t.push(n)),l(),i=Number(e[1]),a=Number(e[2]),n.rows.push({type:`hunk`,text:c});continue}if(!n)continue;if(c.startsWith(`\\ `)){l(),n.rows.push({type:`hunk`,text:c});continue}let u=c[0],d=c.slice(1);u===` `?(l(),n.rows.push({type:`line`,left:{lineNo:i++,text:d,type:`context`},right:{lineNo:a++,text:d,type:`context`}})):u===`-`?o.push({lineNo:i++,text:d}):u===`+`?s.push({lineNo:a++,text:d}):c!==``&&(l(),n.rows.push({type:`hunk`,text:c}))}l();let u=t.filter(e=>e.rows.some(e=>e.type===`line`));return u.length>0?u:null}function OZ(e){return e.split(` `)[0].trim()}var kZ={indicator:`indicator`,textOnly:`text-only`,remove:`remove`};function AZ({defaultOrigin:e=``,allowedLinkPrefixes:t=[],allowedImagePrefixes:n=[],allowDataImages:r=!1,allowedProtocols:i=[],blockedImageClass:a=`inline-block bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-400 px-3 py-1 rounded text-sm`,blockedLinkClass:o=`text-gray-500`,linkBlockPolicy:s=kZ.indicator,imageBlockPolicy:c=kZ.indicator}){let l=t.length&&!t.every(e=>e===`*`),u=n.length&&!n.every(e=>e===`*`);if(!e&&(l||u))throw Error(`defaultOrigin is required when allowedLinkPrefixes or allowedImagePrefixes are provided`);return l=>{let u=BZ(e,t,n,r,i,a,o,s,c);IZ(l),AO(l,u)}}function jZ(e,t){if(typeof e!=`string`)return null;try{return new URL(e)}catch{if(t)try{return new URL(e,t)}catch{return null}if(e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`))try{return new URL(e,`http://example.com`)}catch{return null}return null}}function MZ(e){return typeof e==`string`?e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`):!1}var NZ=new Set([`https:`,`http:`,`irc:`,`ircs:`,`mailto:`,`xmpp:`,`blob:`]),PZ=new Set([`javascript:`,`data:`,`file:`,`vbscript:`]);function FZ(e,t,n,r=!1,i=!1,a=[]){if(!e)return null;if(typeof e==`string`&&e.startsWith(`#`)&&!i)try{if(new URL(e,`http://example.com`).hash===e)return e}catch{}if(typeof e==`string`&&e.startsWith(`data:`))return i&&r&&e.startsWith(`data:image/`)?e:null;if(typeof e==`string`&&e.startsWith(`blob:`)){try{if(new URL(e).protocol===`blob:`&&e.length>5){let t=e.substring(5);if(t&&t.length>0&&t!==`invalid`)return e}}catch{return null}return null}let o=jZ(e,n);if(!o||PZ.has(o.protocol)||!(NZ.has(o.protocol)||a.includes(o.protocol)||a.includes(`*`)))return null;if(o.protocol===`mailto:`||!o.protocol.match(/^https?:$/))return o.href;let s=MZ(e);return o&&t.some(e=>{let t=jZ(e,n);return!t||t.origin!==o.origin?!1:o.href.startsWith(t.href)})?s?o.pathname+o.search+o.hash:o.href:t.includes(`*`)?o.protocol!==`https:`&&o.protocol!==`http:`?null:s?o.pathname+o.search+o.hash:o.href:null}function IZ(e){if(`children`in e&&Array.isArray(e.children)){e.children=e.children.filter(e=>e!=null);for(let t of e.children)IZ(t)}}var LZ=Symbol(`node-seen`);function RZ(e,t,n){return t===kZ.remove?{type:`remove`}:t===kZ.textOnly?{type:`replace`,element:{type:`element`,tagName:`span`,properties:{},children:[...e.children]}}:{type:`replace`,element:{type:`element`,tagName:`span`,properties:{title:`Blocked URL: `+String(e.properties.href),class:n},children:[...e.children,{type:`text`,value:` [blocked]`}]}}}function zZ(e,t,n){if(t===kZ.remove)return{type:`remove`};if(t===kZ.textOnly){let t=String(e.properties.alt||``);return t?{type:`replace`,element:{type:`element`,tagName:`span`,properties:{},children:[{type:`text`,value:t}]}}:{type:`remove`}}return{type:`replace`,element:{type:`element`,tagName:`span`,properties:{class:n},children:[{type:`text`,value:`[Image blocked: `+String(e.properties.alt||`No description`)+`]`}]}}}var BZ=(e,t,n,r,i,a,o,s,c)=>{let l=(u,d,f)=>{if(u.type!==`element`||u[LZ])return!0;if(u.tagName===`a`){let n=FZ(u.properties.href,t,e,!1,!1,i);if(n===null){if(u[LZ]=!0,AO(u,l),f&&typeof d==`number`){let e=RZ(u,s,o);if(e.type===`remove`)return f.children.splice(d,1),[DO,d];f.children[d]=e.element}return DO}return u.properties.href=n,u.properties.target=`_blank`,u.properties.rel=`noopener noreferrer`,!0}if(u.tagName===`img`){let t=FZ(u.properties.src,n,e,r,!0,i);if(t===null){if(u[LZ]=!0,AO(u,l),f&&typeof d==`number`){let e=zZ(u,c,a);if(e.type===`remove`)return f.children.splice(d,1),[DO,d];f.children[d]=e.element}return DO}return u.properties.src=t,!0}return!0};return l},VZ=Object.defineProperty,HZ=Object.defineProperties,UZ=Object.getOwnPropertyDescriptors,WZ=Object.getOwnPropertySymbols,GZ=Object.prototype.hasOwnProperty,KZ=Object.prototype.propertyIsEnumerable,qZ=(e,t,n)=>t in e?VZ(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,JZ=(e,t)=>{for(var n in t||={})GZ.call(t,n)&&qZ(e,n,t[n]);if(WZ)for(var n of WZ(t))KZ.call(t,n)&&qZ(e,n,t[n]);return e},YZ=(e,t)=>HZ(e,UZ(t)),XZ=(e,t)=>{let n=!1,r=!1;for(let i=0;i<t;i+=1){if(e[i]===`\\`&&i+1<e.length&&e[i+1]==="`"){i+=1;continue}if(e.substring(i,i+3)==="```"){r=!r,i+=2;continue}!r&&e[i]==="`"&&(n=!n)}return n||r},ZZ=(e,t)=>{let n=e.substring(t,t+3)==="```",r=t>0&&e.substring(t-1,t+2)==="```",i=t>1&&e.substring(t-2,t+1)==="```";return n||r||i},QZ=e=>{let t=0;for(let n=0;n<e.length;n+=1){if(e[n]===`\\`&&n+1<e.length&&e[n+1]==="`"){n+=1;continue}e[n]==="`"&&!ZZ(e,n)&&(t+=1)}return t},$Z=(e,t)=>{let n=!1,r=!1,i=-1;for(let a=0;a<e.length;a+=1){if(e[a]===`\\`&&a+1<e.length&&e[a+1]==="`"){a+=1;continue}if(e.substring(a,a+3)==="```"){r=!r,a+=2;continue}if(!r&&e[a]==="`"){if(n){if(i<t&&t<a)return!0;n=!1,i=-1}else n=!0,i=a}}return!1},eQ=/^(\s*(?:[-*+]|\d+[.)]) +)>(=?\s*[$]?\d)/gm,tQ=e=>!e||typeof e!=`string`||!e.includes(`>`)?e:e.replace(eQ,(t,n,r,i)=>XZ(e,i)?t:`${n}\\>${r}`),nQ=/(\*\*)([^*]*\*?)$/,rQ=/(__)([^_]*?)$/,iQ=/(\*\*\*)([^*]*?)$/,aQ=/(\*)([^*]*?)$/,oQ=/(_)([^_]*?)$/,sQ=/(`)([^`]*?)$/,cQ=/(~~)([^~]*?)$/,lQ=/^[\s_~*`]*$/,uQ=/^[\s]*[-*+][\s]+$/,dQ=/[\p{L}\p{N}_]/u,fQ=/^```[^`\n]*```?$/,pQ=/^\*{4,}$/,mQ=/(__)([^_]+)_$/,hQ=/(~~)([^~]+)~$/,gQ=/~~/g,_Q=e=>{if(!e)return!1;let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95||dQ.test(e)},vQ=(e,t)=>{let n=1;for(let r=t-1;r>=0;--r)if(e[r]===`]`)n+=1;else if(e[r]===`[`&&(--n,n===0))return r;return-1},yQ=(e,t)=>{let n=1;for(let r=t+1;r<e.length;r+=1)if(e[r]===`[`)n+=1;else if(e[r]===`]`&&(--n,n===0))return r;return-1},bQ=(e,t)=>{let n=!1,r=!1;for(let i=0;i<e.length&&i<t;i+=1){if(e[i]===`\\`&&e[i+1]===`$`){i+=1;continue}e[i]===`$`&&(e[i+1]===`$`?(r=!r,i+=1,n=!1):r||(n=!n))}return n||r},xQ=(e,t)=>{for(let n=t;n<e.length;n+=1){if(e[n]===`)`)return!0;if(e[n]===`
|
|
361
|
+
`)return!1}return!1},SQ=(e,t)=>{for(let n=t-1;n>=0;--n){if(e[n]===`)`)return!1;if(e[n]===`(`)return n>0&&e[n-1]===`]`&&xQ(e,t);if(e[n]===`
|
|
362
|
+
`)return!1}return!1},CQ=(e,t)=>{for(let n=t-1;n>=0;--n){if(e[n]===`>`)return!1;if(e[n]===`<`){let t=n+1<e.length?e[n+1]:``;return t>=`a`&&t<=`z`||t>=`A`&&t<=`Z`||t===`/`}if(e[n]===`
|
|
363
|
+
`)return!1}return!1},wQ=(e,t,n)=>{let r=0;for(let n=t-1;n>=0;--n)if(e[n]===`
|
|
364
364
|
`){r=n+1;break}let i=e.length;for(let n=t;n<e.length;n+=1)if(e[n]===`
|
|
365
|
-
`){i=n;break}let a=e.substring(r,i),o=0,s=!1;for(let e of a)if(e===n)o+=1;else if(e!==` `&&e!==` `){s=!0;break}return o>=3&&!s},
|
|
365
|
+
`){i=n;break}let a=e.substring(r,i),o=0,s=!1;for(let e of a)if(e===n)o+=1;else if(e!==` `&&e!==` `){s=!0;break}return o>=3&&!s},TQ=(e,t,n,r)=>n===`\\`||e.includes(`$`)&&bQ(e,t)?!0:n!==`*`&&r===`*`?(t<e.length-2?e[t+2]:``)!==`*`:!!(n===`*`||n&&r&&_Q(n)&&_Q(r)||(!n||n===` `||n===` `||n===`
|
|
366
366
|
`)&&(!r||r===` `||r===` `||r===`
|
|
367
|
-
`)),
|
|
368
|
-
`),i=r===-1?0:r+1,a=e.substring(i,n);return
|
|
369
|
-
`)?!0:
|
|
370
|
-
`),i=r===-1?0:r+1,a=e.substring(i,n);return
|
|
371
|
-
`)?!0:
|
|
367
|
+
`)),EQ=e=>{let t=0,n=!1,r=e.length;for(let i=0;i<r;i+=1){if(e[i]==="`"&&i+2<r&&e[i+1]==="`"&&e[i+2]==="`"){n=!n,i+=2;continue}if(n||e[i]!==`*`)continue;let a=i>0?e[i-1]:``,o=i<r-1?e[i+1]:``;TQ(e,i,a,o)||(t+=1)}return t},DQ=(e,t,n,r)=>!!(n===`\\`||e.includes(`$`)&&bQ(e,t)||SQ(e,t)||CQ(e,t)||n===`_`||r===`_`||n&&r&&_Q(n)&&_Q(r)),OQ=e=>{let t=0,n=!1,r=e.length;for(let i=0;i<r;i+=1){if(e[i]==="`"&&i+2<r&&e[i+1]==="`"&&e[i+2]==="`"){n=!n,i+=2;continue}if(n||e[i]!==`_`)continue;let a=i>0?e[i-1]:``,o=i<r-1?e[i+1]:``;DQ(e,i,a,o)||(t+=1)}return t},kQ=e=>{let t=0,n=0,r=!1;for(let i=0;i<e.length;i+=1){if(e[i]==="`"&&i+2<e.length&&e[i+1]==="`"&&e[i+2]==="`"){n>=3&&(t+=Math.floor(n/3)),n=0,r=!r,i+=2;continue}r||(e[i]===`*`?n+=1:(n>=3&&(t+=Math.floor(n/3)),n=0))}return n>=3&&(t+=Math.floor(n/3)),t},AQ=e=>{let t=0,n=!1;for(let r=0;r<e.length;r+=1){if(e[r]==="`"&&r+2<e.length&&e[r+1]==="`"&&e[r+2]==="`"){n=!n,r+=2;continue}n||e[r]===`*`&&r+1<e.length&&e[r+1]===`*`&&(t+=1,r+=1)}return t},jQ=e=>{let t=0,n=!1;for(let r=0;r<e.length;r+=1){if(e[r]==="`"&&r+2<e.length&&e[r+1]==="`"&&e[r+2]==="`"){n=!n,r+=2;continue}n||e[r]===`_`&&r+1<e.length&&e[r+1]===`_`&&(t+=1,r+=1)}return t},MQ=(e,t,n)=>{if(!t||lQ.test(t))return!0;let r=e.substring(0,n).lastIndexOf(`
|
|
368
|
+
`),i=r===-1?0:r+1,a=e.substring(i,n);return uQ.test(a)&&t.includes(`
|
|
369
|
+
`)?!0:wQ(e,n,`*`)},NQ=e=>{let t=e.match(nQ);if(!t)return e;let n=t[2],r=e.lastIndexOf(t[1]);return XZ(e,r)||$Z(e,r)||MQ(e,n,r)?e:AQ(e)%2==1?n.endsWith(`*`)?`${e}*`:`${e}**`:e},PQ=(e,t,n)=>{if(!t||lQ.test(t))return!0;let r=e.substring(0,n).lastIndexOf(`
|
|
370
|
+
`),i=r===-1?0:r+1,a=e.substring(i,n);return uQ.test(a)&&t.includes(`
|
|
371
|
+
`)?!0:wQ(e,n,`_`)},FQ=e=>{let t=e.match(rQ);if(!t){let t=e.match(mQ);if(t){let n=e.lastIndexOf(t[1]);if(!(XZ(e,n)||$Z(e,n))&&jQ(e)%2==1)return`${e}_`}return e}let n=t[2],r=e.lastIndexOf(t[1]);return XZ(e,r)||$Z(e,r)||PQ(e,n,r)?e:jQ(e)%2==1?`${e}__`:e},IQ=e=>{let t=!1;for(let n=0;n<e.length;n+=1){if(e[n]==="`"&&n+2<e.length&&e[n+1]==="`"&&e[n+2]==="`"){t=!t,n+=2;continue}if(!t&&e[n]===`*`&&e[n-1]!==`*`&&e[n+1]!==`*`&&e[n-1]!==`\\`&&!bQ(e,n)){let t=n>0?e[n-1]:``,r=n<e.length-1?e[n+1]:``;if((!t||t===` `||t===` `||t===`
|
|
372
372
|
`)&&(!r||r===` `||r===` `||r===`
|
|
373
|
-
`)||t&&r&&
|
|
374
|
-
`;)--t;return t<e.length?`${e.slice(0,t)}_${e.slice(t)}`:`${e}_`},
|
|
375
|
-
`)?null:e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e,
|
|
373
|
+
`)||t&&r&&_Q(t)&&_Q(r))continue;return n}}return-1},LQ=e=>{if(!e.match(aQ))return e;let t=IQ(e);if(t===-1||XZ(e,t)||$Z(e,t))return e;let n=e.substring(t+1);return!n||lQ.test(n)?e:EQ(e)%2==1?`${e}*`:e},RQ=e=>{let t=!1;for(let n=0;n<e.length;n+=1){if(e[n]==="`"&&n+2<e.length&&e[n+1]==="`"&&e[n+2]==="`"){t=!t,n+=2;continue}if(!t&&e[n]===`_`&&e[n-1]!==`_`&&e[n+1]!==`_`&&e[n-1]!==`\\`&&!bQ(e,n)&&!SQ(e,n)){let t=n>0?e[n-1]:``,r=n<e.length-1?e[n+1]:``;if(t&&r&&_Q(t)&&_Q(r))continue;return n}}return-1},zQ=e=>{let t=e.length;for(;t>0&&e[t-1]===`
|
|
374
|
+
`;)--t;return t<e.length?`${e.slice(0,t)}_${e.slice(t)}`:`${e}_`},BQ=e=>{if(!e.endsWith(`**`))return null;let t=e.slice(0,-2);if(AQ(t)%2!=1)return null;let n=t.indexOf(`**`),r=RQ(t);return n!==-1&&r!==-1&&n<r?`${t}_**`:null},VQ=e=>{if(!e.match(oQ))return e;let t=RQ(e);if(t===-1)return e;let n=e.substring(t+1);if(!n||lQ.test(n)||XZ(e,t)||$Z(e,t))return e;if(OQ(e)%2==1){let t=BQ(e);return t===null?zQ(e):t}return e},HQ=e=>{let t=AQ(e),n=EQ(e);return t%2==0&&n%2==0},UQ=(e,t,n)=>!t||lQ.test(t)||XZ(e,n)||$Z(e,n)?!0:wQ(e,n,`*`),WQ=e=>{if(pQ.test(e))return e;let t=e.match(iQ);if(!t)return e;let n=t[2];return UQ(e,n,e.lastIndexOf(t[1]))?e:kQ(e)%2==1?HQ(e)?e:`${e}***`:e},GQ=/<[a-zA-Z/][^>]*$/,KQ=e=>{let t=e.match(GQ);return!t||t.index===void 0||XZ(e,t.index)?e:e.substring(0,t.index).trimEnd()},qQ=e=>!e.match(fQ)||e.includes(`
|
|
375
|
+
`)?null:e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e,JQ=e=>(e.match(/```/g)||[]).length%2==1,YQ=e=>{let t=qQ(e);if(t!==null)return t;let n=e.match(sQ);if(n&&!JQ(e)){let t=n[2];if(!t||lQ.test(t))return e;if(QZ(e)%2==1)return`${e}\``}return e},XQ=(e,t)=>t>=2&&e.substring(t-2,t+1)==="```"||t>=1&&e.substring(t-1,t+2)==="```"||t<=e.length-3&&e.substring(t,t+3)==="```",ZQ=e=>{let t=0,n=!1;for(let r=0;r<e.length-1;r+=1)e[r]==="`"&&!XQ(e,r)&&(n=!n),!n&&e[r]===`$`&&e[r+1]===`$`&&(t+=1,r+=1);return t},QQ=e=>{let t=0,n=!1;for(let r=0;r<e.length;r+=1){if(e[r]===`\\`){r+=1;continue}if(e[r]==="`"&&!XQ(e,r)){n=!n;continue}!n&&e[r]===`$`&&(r+1<e.length&&e[r+1]===`$`?r+=1:t+=1)}return t},$Q=e=>{if(e.endsWith(`$`)&&!e.endsWith(`$$`))return`${e}$`;let t=e.indexOf(`$$`);return t!==-1&&e.indexOf(`
|
|
376
376
|
`,t)!==-1&&!e.endsWith(`
|
|
377
377
|
`)?`${e}
|
|
378
|
-
$$`:`${e}$$`},
|
|
379
|
-
`);if(t===-1)return e;let n=e.substring(t+1),r=e.substring(0,t),i=n.trim();if(
|
|
380
|
-
`).at(-1);if(t&&t.trim().length>0)return`${e}\u200B`}if(
|
|
381
|
-
`).at(-1);if(t&&t.trim().length>0)return`${e}\u200B`}return e},
|
|
382
|
-
]`).replace(`lheading`,
|
|
378
|
+
$$`:`${e}$$`},e$=e=>ZQ(e)%2==0?e:$Q(e),t$=e=>QQ(e)%2==1?`${e}$`:e,n$=(e,t,n)=>{if(e.substring(t+2).includes(`)`))return null;let r=vQ(e,t);if(r===-1||XZ(e,r))return null;let i=r>0&&e[r-1]===`!`,a=i?r-1:r,o=e.substring(0,a);if(i)return o;let s=e.substring(r+1,t);return n===`text-only`?`${o}${s}`:`${o}[${s}](streamdown:incomplete-link)`},r$=(e,t)=>{for(let n=0;n<t;n++)if(e[n]===`[`&&!XZ(e,n)){if(n>0&&e[n-1]===`!`)continue;let t=yQ(e,n);if(t===-1)return n;if(t+1<e.length&&e[t+1]===`(`){let r=e.indexOf(`)`,t+2);r!==-1&&(n=r)}}return t},i$=(e,t,n)=>{let r=t>0&&e[t-1]===`!`,i=r?t-1:t;if(!e.substring(t+1).includes(`]`)){let a=e.substring(0,i);if(r)return a;if(n===`text-only`){let n=r$(e,t);return e.substring(0,n)+e.substring(n+1)}return`${e}](streamdown:incomplete-link)`}if(yQ(e,t)===-1){let a=e.substring(0,i);if(r)return a;if(n===`text-only`){let n=r$(e,t);return e.substring(0,n)+e.substring(n+1)}return`${e}](streamdown:incomplete-link)`}return null},a$=(e,t=`protocol`)=>{let n=e.lastIndexOf(`](`);if(n!==-1&&!XZ(e,n)){let r=n$(e,n,t);if(r!==null)return r}for(let n=e.length-1;n>=0;--n)if(e[n]===`[`&&!XZ(e,n)){let r=i$(e,n,t);if(r!==null)return r}return e},o$=/^-{1,2}$/,s$=/^[\s]*-{1,2}[\s]+$/,c$=/^={1,2}$/,l$=/^[\s]*={1,2}[\s]+$/,u$=e=>{if(!e||typeof e!=`string`)return e;let t=e.lastIndexOf(`
|
|
379
|
+
`);if(t===-1)return e;let n=e.substring(t+1),r=e.substring(0,t),i=n.trim();if(o$.test(i)&&!n.match(s$)){let t=r.split(`
|
|
380
|
+
`).at(-1);if(t&&t.trim().length>0)return`${e}\u200B`}if(c$.test(i)&&!n.match(l$)){let t=r.split(`
|
|
381
|
+
`).at(-1);if(t&&t.trim().length>0)return`${e}\u200B`}return e},d$=RegExp(`(?<=[\\p{L}\\p{N}_])~(?!~)(?=[\\p{L}\\p{N}_])`,`gu`),f$=e=>!e||typeof e!=`string`||!e.includes(`~`)?e:e.replace(d$,(t,n)=>XZ(e,n)?t:`\\~`),p$=e=>{let t=e.match(cQ);if(t){let n=t[2];if(!n||lQ.test(n))return e;let r=e.lastIndexOf(t[1]);if(XZ(e,r)||$Z(e,r))return e;if(e.match(gQ)?.length%2==1)return`${e}~~`}else{let t=e.match(hQ);if(t){let n=e.lastIndexOf(t[0].slice(0,2));if(XZ(e,n)||$Z(e,n))return e;if(e.match(gQ)?.length%2==1)return`${e}~`}}return e},m$=e=>e!==!1,h$=e=>e===!0,g$={SINGLE_TILDE:0,COMPARISON_OPERATORS:5,HTML_TAGS:10,SETEXT_HEADINGS:15,LINKS:20,BOLD_ITALIC:30,BOLD:35,ITALIC_DOUBLE_UNDERSCORE:40,ITALIC_SINGLE_ASTERISK:41,ITALIC_SINGLE_UNDERSCORE:42,INLINE_CODE:50,STRIKETHROUGH:60,KATEX:70,INLINE_KATEX:75,DEFAULT:100},_$=[{handler:{name:`singleTilde`,handle:f$,priority:g$.SINGLE_TILDE},optionKey:`singleTilde`},{handler:{name:`comparisonOperators`,handle:tQ,priority:g$.COMPARISON_OPERATORS},optionKey:`comparisonOperators`},{handler:{name:`htmlTags`,handle:KQ,priority:g$.HTML_TAGS},optionKey:`htmlTags`},{handler:{name:`setextHeadings`,handle:u$,priority:g$.SETEXT_HEADINGS},optionKey:`setextHeadings`},{handler:{name:`links`,handle:a$,priority:g$.LINKS},optionKey:`links`,earlyReturn:e=>e.endsWith(`](streamdown:incomplete-link)`)},{handler:{name:`boldItalic`,handle:WQ,priority:g$.BOLD_ITALIC},optionKey:`boldItalic`},{handler:{name:`bold`,handle:NQ,priority:g$.BOLD},optionKey:`bold`},{handler:{name:`italicDoubleUnderscore`,handle:FQ,priority:g$.ITALIC_DOUBLE_UNDERSCORE},optionKey:`italic`},{handler:{name:`italicSingleAsterisk`,handle:LQ,priority:g$.ITALIC_SINGLE_ASTERISK},optionKey:`italic`},{handler:{name:`italicSingleUnderscore`,handle:VQ,priority:g$.ITALIC_SINGLE_UNDERSCORE},optionKey:`italic`},{handler:{name:`inlineCode`,handle:YQ,priority:g$.INLINE_CODE},optionKey:`inlineCode`},{handler:{name:`strikethrough`,handle:p$,priority:g$.STRIKETHROUGH},optionKey:`strikethrough`},{handler:{name:`katex`,handle:e$,priority:g$.KATEX},optionKey:`katex`},{handler:{name:`inlineKatex`,handle:t$,priority:g$.INLINE_KATEX},optionKey:`inlineKatex`}],v$=e=>{let t=e?.linkMode??`protocol`;return _$.filter(({handler:t,optionKey:n})=>t.name===`links`?m$(e?.links)||m$(e?.images):t.name===`inlineKatex`?h$(e?.inlineKatex):m$(e?.[n])).map(({handler:e,earlyReturn:n})=>e.name===`links`?{handler:YZ(JZ({},e),{handle:e=>a$(e,t)}),earlyReturn:t===`protocol`?n:void 0}:{handler:e,earlyReturn:n})},y$=(e,t)=>{if(!e||typeof e!=`string`)return e;let n=e.endsWith(` `)&&!e.endsWith(` `)?e.slice(0,-1):e,r=v$(t),i=(t?.handlers??[]).map(e=>({handler:YZ(JZ({},e),{priority:e.priority??g$.DEFAULT}),earlyReturn:void 0})),a=[...r,...i].sort((e,t)=>(e.handler.priority??0)-(t.handler.priority??0));for(let{handler:e,earlyReturn:t}of a)if(n=e.handle(n),t!=null&&t(n))return n;return n};function b$(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var x$=b$();function S$(e){x$=e}var C$={exec:()=>null};function w$(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(E$.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var T$=(()=>{try{return!0}catch{return!1}})(),E$={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},D$=/^(?:[ \t]*(?:\n|$))+/,O$=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,k$=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,A$=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,j$=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,M$=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,N$=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,P$=w$(N$).replace(/bull/g,M$).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),F$=w$(N$).replace(/bull/g,M$).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),I$=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,L$=/^[^\n]+/,R$=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,z$=w$(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,R$).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),B$=w$(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,M$).getRegex(),V$=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,H$=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,U$=w$(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,H$).replace(`tag`,V$).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),W$=w$(I$).replace(`hr`,A$).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,V$).getRegex(),G$={blockquote:w$(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,W$).getRegex(),code:O$,def:z$,fences:k$,heading:j$,hr:A$,html:U$,lheading:P$,list:B$,newline:D$,paragraph:W$,table:C$,text:L$},K$=w$(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,A$).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,V$).getRegex(),q$={...G$,lheading:F$,table:K$,paragraph:w$(I$).replace(`hr`,A$).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,K$).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,V$).getRegex()},J$={...G$,html:w$(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,H$).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:C$,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:w$(I$).replace(`hr`,A$).replace(`heading`,` *#{1,6} *[^
|
|
382
|
+
]`).replace(`lheading`,P$).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Y$=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,X$=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Z$=/^( {2,}|\\)\n(?!\s*$)/,Q$=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,$$=/[\p{P}\p{S}]/u,e1=/[\s\p{P}\p{S}]/u,t1=/[^\s\p{P}\p{S}]/u,n1=w$(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,e1).getRegex(),r1=/(?!~)[\p{P}\p{S}]/u,i1=/(?!~)[\s\p{P}\p{S}]/u,a1=/(?:[^\s\p{P}\p{S}]|~)/u,o1=w$(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,T$?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),s1=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,c1=w$(s1,`u`).replace(/punct/g,$$).getRegex(),l1=w$(s1,`u`).replace(/punct/g,r1).getRegex(),u1=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,d1=w$(u1,`gu`).replace(/notPunctSpace/g,t1).replace(/punctSpace/g,e1).replace(/punct/g,$$).getRegex(),f1=w$(u1,`gu`).replace(/notPunctSpace/g,a1).replace(/punctSpace/g,i1).replace(/punct/g,r1).getRegex(),p1=w$(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,t1).replace(/punctSpace/g,e1).replace(/punct/g,$$).getRegex(),m1=w$(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,$$).getRegex(),h1=w$(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,t1).replace(/punctSpace/g,e1).replace(/punct/g,$$).getRegex(),g1=w$(/\\(punct)/,`gu`).replace(/punct/g,$$).getRegex(),_1=w$(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),v1=w$(H$).replace(`(?:-->|$)`,`-->`).getRegex(),y1=w$(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,v1).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),b1=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,x1=w$(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,b1).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),S1=w$(/^!?\[(label)\]\[(ref)\]/).replace(`label`,b1).replace(`ref`,R$).getRegex(),C1=w$(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,R$).getRegex(),w1=w$(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,S1).replace(`nolink`,C1).getRegex(),T1=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,E1={_backpedal:C$,anyPunctuation:g1,autolink:_1,blockSkip:o1,br:Z$,code:X$,del:C$,delLDelim:C$,delRDelim:C$,emStrongLDelim:c1,emStrongRDelimAst:d1,emStrongRDelimUnd:p1,escape:Y$,link:x1,nolink:C1,punctuation:n1,reflink:S1,reflinkSearch:w1,tag:y1,text:Q$,url:C$},D1={...E1,link:w$(/^!?\[(label)\]\((.*?)\)/).replace(`label`,b1).getRegex(),reflink:w$(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,b1).getRegex()},O1={...E1,emStrongRDelimAst:f1,emStrongLDelim:l1,delLDelim:m1,delRDelim:h1,url:w$(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,T1).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:w$(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,T1).getRegex()},k1={...O1,br:w$(Z$).replace(`{2,}`,`*`).getRegex(),text:w$(O1.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},A1={normal:G$,gfm:q$,pedantic:J$},j1={normal:E1,gfm:O1,breaks:k1,pedantic:D1},M1={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},N1=e=>M1[e];function P1(e,t){if(t){if(E$.escapeTest.test(e))return e.replace(E$.escapeReplace,N1)}else if(E$.escapeTestNoEncode.test(e))return e.replace(E$.escapeReplaceNoEncode,N1);return e}function F1(e){try{e=encodeURI(e).replace(E$.percentDecode,`%`)}catch{return null}return e}function I1(e,t){let n=e.replace(E$.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(E$.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(E$.slashPipe,`|`);return n}function L1(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function R1(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function z1(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function B1(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function V1(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
383
383
|
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
|
|
384
|
-
`)}var
|
|
385
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=
|
|
386
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=
|
|
384
|
+
`)}var H1=class{options;rules;lexer;constructor(e){this.options=e||x$}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:L1(e,`
|
|
385
|
+
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=V1(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=L1(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:L1(t[0],`
|
|
386
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=L1(t[0],`
|
|
387
387
|
`).split(`
|
|
388
388
|
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
|
|
389
389
|
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
@@ -394,17 +394,17 @@ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
394
394
|
`),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}if(u?.type===`list`){let t=u,a=t.raw+`
|
|
395
395
|
`+e.join(`
|
|
396
396
|
`),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
|
|
397
|
-
`);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=
|
|
397
|
+
`);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=z1(t[2].split(`
|
|
398
398
|
`,1)[0],t[1].length),l=e.split(`
|
|
399
399
|
`,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=c.search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
|
|
400
400
|
`,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let p=e.split(`
|
|
401
401
|
`,1)[0],m;if(l=p,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),m=l):m=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
|
|
402
402
|
`+m.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
|
|
403
403
|
`+l}u=!l.trim(),r+=p+`
|
|
404
|
-
`,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,``),e.tokens[0]?.type===`text`||e.tokens[0]?.type===`paragraph`){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,``),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:`checkbox`,raw:t[0]+` `,checked:t[0]!==`[ ]`};e.checked=n.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:`paragraph`,raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=
|
|
405
|
-
`):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(
|
|
406
|
-
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=
|
|
407
|
-
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(
|
|
404
|
+
`,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,``),e.tokens[0]?.type===`text`||e.tokens[0]?.type===`paragraph`){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,``),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:`checkbox`,raw:t[0]+` `,checked:t[0]!==`[ ]`};e.checked=n.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:`paragraph`,raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=I1(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
405
|
+
`):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(I1(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
406
|
+
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=L1(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=R1(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),B1(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return B1(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},U1=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||x$,this.options.tokenizer=this.options.tokenizer||new H1,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:E$,block:A1.normal,inline:j1.normal};this.options.pedantic?(t.block=A1.pedantic,t.inline=j1.pedantic):this.options.gfm&&(t.block=A1.gfm,t.inline=this.options.breaks?j1.breaks:j1.gfm),this.tokenizer.rules=t}static get rules(){return{block:A1,inline:j1}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(E$.carriageReturn,`
|
|
407
|
+
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(E$.tabCharGlobal,` `).replace(E$.spaceLine,``));e;){let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
|
|
408
408
|
`:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
409
409
|
`)?``:`
|
|
410
410
|
`)+r.raw,n.text+=`
|
|
@@ -417,9 +417,9 @@ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
417
417
|
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
418
418
|
`)?``:`
|
|
419
419
|
`)+r.raw,n.text+=`
|
|
420
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!==null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!==null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!==null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``;for(;e;){a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}return t}},
|
|
421
|
-
`;return r?`<pre><code class="language-`+
|
|
422
|
-
`:`<pre><code>`+(n?i:
|
|
420
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!==null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!==null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!==null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``;for(;e;){a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}return t}},W1=class{options;parser;constructor(e){this.options=e||x$}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(E$.notSpaceStart)?.[0],i=e.replace(E$.endingNewline,``)+`
|
|
421
|
+
`;return r?`<pre><code class="language-`+P1(r)+`">`+(n?i:P1(i,!0))+`</code></pre>
|
|
422
|
+
`:`<pre><code>`+(n?i:P1(i,!0))+`</code></pre>
|
|
423
423
|
`}blockquote({tokens:e}){return`<blockquote>
|
|
424
424
|
${this.parser.parse(e)}</blockquote>
|
|
425
425
|
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
@@ -435,19 +435,19 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
435
435
|
`}tablerow({text:e}){return`<tr>
|
|
436
436
|
${e}</tr>
|
|
437
437
|
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
438
|
-
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${
|
|
439
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+
|
|
440
|
-
`:e.map((e,t)=>{let n={},r=!!e.bgColor;if(e.color&&(n[`--sdm-c`]=e.color),e.bgColor&&(n[`--sdm-tbg`]=e.bgColor),e.htmlStyle)for(let[t,i]of Object.entries(e.htmlStyle))t===`color`?n[`--sdm-c`]=i:t===`background-color`?(n[`--sdm-tbg`]=i,r=!0):n[t]=i;return(0,E.jsx)(`span`,{className:s(`text-[var(--sdm-c,inherit)]`,`dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]`,r&&`bg-[var(--sdm-tbg)]`,r&&`dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]`),style:n,...e.htmlAttrs,children:e.content},t)})},t))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers),
|
|
441
|
-
`;)t--;return e.slice(0,t)},
|
|
442
|
-
`).map(e=>[{content:e,color:`inherit`,bgColor:`transparent`,htmlStyle:{},offset:0}])}),[l]);return(0,E.jsx)(T0.Provider,{value:{code:e},children:(0,E.jsxs)(w0,{isIncomplete:i,language:t,children:[(0,E.jsx)(D0,{language:t}),r?(0,E.jsx)(`div`,{className:c(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,E.jsx)(`div`,{className:c(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`code-block-actions`,children:r})}):null,(0,E.jsx)(d.Suspense,{fallback:(0,E.jsx)(C0,{className:n,language:t,lineNumbers:o,result:u,startLine:a,...s}),children:(0,E.jsx)(k0,{className:n,code:l,language:t,lineNumbers:o,raw:u,startLine:a,...s})})]})})},j0={CheckIcon:e=>(0,E.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,E.jsx)(`path`,{clipRule:`evenodd`,d:`M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z`,fill:`currentColor`,fillRule:`evenodd`})}),CopyIcon:e=>(0,E.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,E.jsx)(`path`,{clipRule:`evenodd`,d:`M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z`,fill:`currentColor`,fillRule:`evenodd`})}),DownloadIcon:e=>(0,E.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,E.jsx)(`path`,{clipRule:`evenodd`,d:`M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z`,fill:`currentColor`,fillRule:`evenodd`})}),ExternalLinkIcon:e=>(0,E.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,E.jsx)(`path`,{clipRule:`evenodd`,d:`M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z`,fill:`currentColor`,fillRule:`evenodd`})}),Loader2Icon:e=>(0,E.jsxs)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:[(0,E.jsx)(`path`,{d:`M8 0V4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,E.jsx)(`path`,{d:`M8 16V12`,opacity:`0.5`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,E.jsx)(`path`,{d:`M3.29773 1.52783L5.64887 4.7639`,opacity:`0.9`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,E.jsx)(`path`,{d:`M12.7023 1.52783L10.3511 4.7639`,opacity:`0.1`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,E.jsx)(`path`,{d:`M12.7023 14.472L10.3511 11.236`,opacity:`0.4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,E.jsx)(`path`,{d:`M3.29773 14.472L5.64887 11.236`,opacity:`0.6`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,E.jsx)(`path`,{d:`M15.6085 5.52783L11.8043 6.7639`,opacity:`0.2`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,E.jsx)(`path`,{d:`M0.391602 10.472L4.19583 9.23598`,opacity:`0.7`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,E.jsx)(`path`,{d:`M15.6085 10.4722L11.8043 9.2361`,opacity:`0.3`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,E.jsx)(`path`,{d:`M0.391602 5.52783L4.19583 6.7639`,opacity:`0.8`,stroke:`currentColor`,strokeWidth:`1.5`})]}),Maximize2Icon:e=>(0,E.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,E.jsx)(`path`,{clipRule:`evenodd`,d:`M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z`,fill:`currentColor`,fillRule:`evenodd`})}),RotateCcwIcon:e=>(0,E.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,E.jsx)(`path`,{clipRule:`evenodd`,d:`M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z`,fill:`currentColor`,fillRule:`evenodd`})}),XIcon:e=>(0,E.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,E.jsx)(`path`,{clipRule:`evenodd`,d:`M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z`,fill:`currentColor`,fillRule:`evenodd`})}),ZoomInIcon:e=>(0,E.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,E.jsx)(`path`,{clipRule:`evenodd`,d:`M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z`,fill:`currentColor`,fillRule:`evenodd`})}),ZoomOutIcon:e=>(0,E.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,E.jsx)(`path`,{clipRule:`evenodd`,d:`M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z`,fill:`currentColor`,fillRule:`evenodd`})})},M0=(0,d.createContext)(j0),N0=(e,t)=>{if(e===t)return!0;if(!(e&&t))return e===t;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>e[n]===t[n])},P0=({icons:e,children:t})=>{let n=(0,d.useRef)(e),r=(0,d.useRef)(e?{...j0,...e}:j0);N0(n.current,e)||(n.current=e,r.current=e?{...j0,...e}:j0);let i=r.current;return(0,E.jsx)(M0.Provider,{value:i,children:t})},F0=()=>(0,d.useContext)(M0),I0={copyCode:`Copy Code`,downloadFile:`Download file`,downloadDiagram:`Download diagram`,downloadDiagramAsSvg:`Download diagram as SVG`,downloadDiagramAsPng:`Download diagram as PNG`,downloadDiagramAsMmd:`Download diagram as MMD`,viewFullscreen:`View fullscreen`,exitFullscreen:`Exit fullscreen`,mermaidFormatSvg:`SVG`,mermaidFormatPng:`PNG`,mermaidFormatMmd:`MMD`,copyTable:`Copy table`,copyTableAsMarkdown:`Copy table as Markdown`,copyTableAsCsv:`Copy table as CSV`,copyTableAsTsv:`Copy table as TSV`,downloadTable:`Download table`,downloadTableAsCsv:`Download table as CSV`,downloadTableAsMarkdown:`Download table as Markdown`,tableFormatMarkdown:`Markdown`,tableFormatCsv:`CSV`,tableFormatTsv:`TSV`,imageNotAvailable:`Image not available`,downloadImage:`Download image`,openExternalLink:`Open external link?`,externalLinkWarning:`You're about to visit an external website.`,close:`Close`,copyLink:`Copy link`,copied:`Copied`,openLink:`Open link`},L0=(0,d.createContext)(I0),R0=()=>(0,d.useContext)(L0),z0=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,code:a,...o})=>{let s=b0(),[c,l]=(0,d.useState)(!1),u=(0,d.useRef)(0),{code:f}=E0(),{isAnimating:p}=(0,d.useContext)(G4),m=R0(),h=a??f,g=async()=>{var r;if(typeof window>`u`||!((r=navigator==null?void 0:navigator.clipboard)!=null&&r.writeText)){t?.(Error(`Clipboard API not available`));return}try{c||(await navigator.clipboard.writeText(h),l(!0),e?.(),u.current=window.setTimeout(()=>l(!1),n))}catch(e){t?.(e)}};(0,d.useEffect)(()=>()=>{window.clearTimeout(u.current)},[]);let _=F0(),v=c?_.CheckIcon:_.CopyIcon;return(0,E.jsx)(`button`,{className:s(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),"data-streamdown":`code-block-copy-button`,disabled:p,onClick:g,title:m.copyCode,type:`button`,...o,children:r??(0,E.jsx)(v,{size:14})})},B0={"1c":`1c`,"1c-query":`1cq`,abap:`abap`,"actionscript-3":`as`,ada:`ada`,adoc:`adoc`,"angular-html":`html`,"angular-ts":`ts`,apache:`conf`,apex:`cls`,apl:`apl`,applescript:`applescript`,ara:`ara`,asciidoc:`adoc`,asm:`asm`,astro:`astro`,awk:`awk`,ballerina:`bal`,bash:`sh`,bat:`bat`,batch:`bat`,be:`be`,beancount:`beancount`,berry:`berry`,bibtex:`bib`,bicep:`bicep`,blade:`blade.php`,bsl:`bsl`,c:`c`,"c#":`cs`,"c++":`cpp`,cadence:`cdc`,cairo:`cairo`,cdc:`cdc`,clarity:`clar`,clj:`clj`,clojure:`clj`,"closure-templates":`soy`,cmake:`cmake`,cmd:`cmd`,cobol:`cob`,codeowners:`CODEOWNERS`,codeql:`ql`,coffee:`coffee`,coffeescript:`coffee`,"common-lisp":`lisp`,console:`sh`,coq:`v`,cpp:`cpp`,cql:`cql`,crystal:`cr`,cs:`cs`,csharp:`cs`,css:`css`,csv:`csv`,cue:`cue`,cypher:`cql`,d:`d`,dart:`dart`,dax:`dax`,desktop:`desktop`,diff:`diff`,docker:`dockerfile`,dockerfile:`dockerfile`,dotenv:`env`,"dream-maker":`dm`,edge:`edge`,elisp:`el`,elixir:`ex`,elm:`elm`,"emacs-lisp":`el`,erb:`erb`,erl:`erl`,erlang:`erl`,f:`f`,"f#":`fs`,f03:`f03`,f08:`f08`,f18:`f18`,f77:`f77`,f90:`f90`,f95:`f95`,fennel:`fnl`,fish:`fish`,fluent:`ftl`,for:`for`,"fortran-fixed-form":`f`,"fortran-free-form":`f90`,fs:`fs`,fsharp:`fs`,fsl:`fsl`,ftl:`ftl`,gdresource:`tres`,gdscript:`gd`,gdshader:`gdshader`,genie:`gs`,gherkin:`feature`,"git-commit":`gitcommit`,"git-rebase":`gitrebase`,gjs:`js`,gleam:`gleam`,"glimmer-js":`js`,"glimmer-ts":`ts`,glsl:`glsl`,gnuplot:`plt`,go:`go`,gql:`gql`,graphql:`graphql`,groovy:`groovy`,gts:`gts`,hack:`hack`,haml:`haml`,handlebars:`hbs`,haskell:`hs`,haxe:`hx`,hbs:`hbs`,hcl:`hcl`,hjson:`hjson`,hlsl:`hlsl`,hs:`hs`,html:`html`,"html-derivative":`html`,http:`http`,hxml:`hxml`,hy:`hy`,imba:`imba`,ini:`ini`,jade:`jade`,java:`java`,javascript:`js`,jinja:`jinja`,jison:`jison`,jl:`jl`,js:`js`,json:`json`,json5:`json5`,jsonc:`jsonc`,jsonl:`jsonl`,jsonnet:`jsonnet`,jssm:`jssm`,jsx:`jsx`,julia:`jl`,kotlin:`kt`,kql:`kql`,kt:`kt`,kts:`kts`,kusto:`kql`,latex:`tex`,lean:`lean`,lean4:`lean`,less:`less`,liquid:`liquid`,lisp:`lisp`,lit:`lit`,llvm:`ll`,log:`log`,logo:`logo`,lua:`lua`,luau:`luau`,make:`mak`,makefile:`mak`,markdown:`md`,marko:`marko`,matlab:`m`,md:`md`,mdc:`mdc`,mdx:`mdx`,mediawiki:`wiki`,mermaid:`mmd`,mips:`s`,mipsasm:`s`,mmd:`mmd`,mojo:`mojo`,move:`move`,nar:`nar`,narrat:`narrat`,nextflow:`nf`,nf:`nf`,nginx:`conf`,nim:`nim`,nix:`nix`,nu:`nu`,nushell:`nu`,objc:`m`,"objective-c":`m`,"objective-cpp":`mm`,ocaml:`ml`,pascal:`pas`,perl:`pl`,perl6:`p6`,php:`php`,plsql:`pls`,po:`po`,polar:`polar`,postcss:`pcss`,pot:`pot`,potx:`potx`,powerquery:`pq`,powershell:`ps1`,prisma:`prisma`,prolog:`pl`,properties:`properties`,proto:`proto`,protobuf:`proto`,ps:`ps`,ps1:`ps1`,pug:`pug`,puppet:`pp`,purescript:`purs`,py:`py`,python:`py`,ql:`ql`,qml:`qml`,qmldir:`qmldir`,qss:`qss`,r:`r`,racket:`rkt`,raku:`raku`,razor:`cshtml`,rb:`rb`,reg:`reg`,regex:`regex`,regexp:`regexp`,rel:`rel`,riscv:`s`,rs:`rs`,rst:`rst`,ruby:`rb`,rust:`rs`,sas:`sas`,sass:`sass`,scala:`scala`,scheme:`scm`,scss:`scss`,sdbl:`sdbl`,sh:`sh`,shader:`shader`,shaderlab:`shader`,shell:`sh`,shellscript:`sh`,shellsession:`sh`,smalltalk:`st`,solidity:`sol`,soy:`soy`,sparql:`rq`,spl:`spl`,splunk:`spl`,sql:`sql`,"ssh-config":`config`,stata:`do`,styl:`styl`,stylus:`styl`,svelte:`svelte`,swift:`swift`,"system-verilog":`sv`,systemd:`service`,talon:`talon`,talonscript:`talon`,tasl:`tasl`,tcl:`tcl`,templ:`templ`,terraform:`tf`,tex:`tex`,tf:`tf`,tfvars:`tfvars`,toml:`toml`,ts:`ts`,"ts-tags":`ts`,tsp:`tsp`,tsv:`tsv`,tsx:`tsx`,turtle:`ttl`,twig:`twig`,typ:`typ`,typescript:`ts`,typespec:`tsp`,typst:`typ`,v:`v`,vala:`vala`,vb:`vb`,verilog:`v`,vhdl:`vhdl`,vim:`vim`,viml:`vim`,vimscript:`vim`,vue:`vue`,"vue-html":`html`,"vue-vine":`vine`,vy:`vy`,vyper:`vy`,wasm:`wasm`,wenyan:`wy`,wgsl:`wgsl`,wiki:`wiki`,wikitext:`wiki`,wit:`wit`,wl:`wl`,wolfram:`wl`,xml:`xml`,xsl:`xsl`,yaml:`yaml`,yml:`yml`,zenscript:`zs`,zig:`zig`,zsh:`zsh`,文言:`wy`},V0=({onDownload:e,onError:t,language:n,children:r,className:i,code:a,...o})=>{let s=b0(),{code:c}=E0(),{isAnimating:l}=(0,d.useContext)(G4),u=R0(),f=F0(),p=a??c,m=`file.${n&&n in B0?B0[n]:`txt`}`;return(0,E.jsx)(`button`,{className:s(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),"data-streamdown":`code-block-download-button`,disabled:l,onClick:()=>{try{v0(m,p,`text/plain`),e?.()}catch(e){t?.(e)}},title:u.downloadFile,type:`button`,...o,children:r??(0,E.jsx)(f.DownloadIcon,{size:14})})},H0=()=>{let{Loader2Icon:e}=F0(),t=b0();return(0,E.jsxs)(`div`,{className:t(`w-full divide-y divide-border overflow-hidden rounded-xl border border-border`),children:[(0,E.jsx)(`div`,{className:t(`h-[46px] w-full bg-muted/80`)}),(0,E.jsx)(`div`,{className:t(`flex w-full items-center justify-center p-4`),children:(0,E.jsx)(e,{className:t(`size-4 animate-spin`)})})]})},U0=/\.[^/.]+$/,W0=({node:e,className:t,src:n,alt:r,onLoad:i,onError:a,...o})=>{let{DownloadIcon:s}=F0(),c=b0(),l=(0,d.useRef)(null),[u,f]=(0,d.useState)(!1),[p,m]=(0,d.useState)(!1),h=R0(),g=o.width!=null||o.height!=null,_=(u||g)&&!p,v=p&&!g;(0,d.useEffect)(()=>{let e=l.current;if(e!=null&&e.complete){let t=e.naturalWidth>0;f(t),m(!t)}},[]);let y=(0,d.useCallback)(e=>{f(!0),m(!1),i?.(e)},[i]),b=(0,d.useCallback)(e=>{f(!1),m(!0),a?.(e)},[a]),x=async()=>{if(n)try{let e=await(await fetch(n)).blob(),t=new URL(n,window.location.origin).pathname.split(`/`).pop()||``,i=t.split(`.`).pop(),a=t.includes(`.`)&&i!==void 0&&i.length<=4,o=``;if(a)o=t;else{let n=e.type,i=`png`;n.includes(`jpeg`)||n.includes(`jpg`)?i=`jpg`:n.includes(`png`)?i=`png`:n.includes(`svg`)?i=`svg`:n.includes(`gif`)?i=`gif`:n.includes(`webp`)&&(i=`webp`),o=`${(r||t||`image`).replace(U0,``)}.${i}`}v0(o,e,e.type)}catch{window.open(n,`_blank`)}};return n?(0,E.jsxs)(`div`,{className:c(`group relative my-4 inline-block`),"data-streamdown":`image-wrapper`,children:[(0,E.jsx)(`img`,{alt:r,className:c(`max-w-full rounded-lg`,v&&`hidden`,t),"data-streamdown":`image`,onError:b,onLoad:y,ref:l,src:n,...o}),v&&(0,E.jsx)(`span`,{className:c(`text-muted-foreground text-xs italic`),"data-streamdown":`image-fallback`,children:h.imageNotAvailable}),(0,E.jsx)(`div`,{className:c(`pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block`)}),_&&(0,E.jsx)(`button`,{className:c(`absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background`,`opacity-0 group-hover:opacity-100`),onClick:x,title:h.downloadImage,type:`button`,children:(0,E.jsx)(s,{size:14})})]}):null},G0=0,K0=()=>{G0+=1,G0===1&&(document.body.style.overflow=`hidden`)},q0=()=>{G0=Math.max(0,G0-1),G0===0&&(document.body.style.overflow=``)},J0=({url:e,isOpen:t,onClose:n,onConfirm:r})=>{let{CheckIcon:i,CopyIcon:a,ExternalLinkIcon:o,XIcon:s}=F0(),c=b0(),[l,u]=(0,d.useState)(!1),f=R0(),p=(0,d.useCallback)(async()=>{try{await navigator.clipboard.writeText(e),u(!0),setTimeout(()=>u(!1),2e3)}catch{}},[e]),m=(0,d.useCallback)(()=>{r(),n()},[r,n]);return(0,d.useEffect)(()=>{if(t){K0();let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),q0()}}},[t,n]),t?(0,E.jsx)(`div`,{className:c(`fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm`),"data-streamdown":`link-safety-modal`,onClick:n,onKeyDown:e=>{e.key===`Escape`&&n()},role:`button`,tabIndex:0,children:(0,E.jsxs)(`div`,{className:c(`relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,E.jsx)(`button`,{className:c(`absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:n,title:f.close,type:`button`,children:(0,E.jsx)(s,{size:16})}),(0,E.jsxs)(`div`,{className:c(`flex flex-col gap-2`),children:[(0,E.jsxs)(`div`,{className:c(`flex items-center gap-2 font-semibold text-lg`),children:[(0,E.jsx)(o,{size:20}),(0,E.jsx)(`span`,{children:f.openExternalLink})]}),(0,E.jsx)(`p`,{className:c(`text-muted-foreground text-sm`),children:f.externalLinkWarning})]}),(0,E.jsx)(`div`,{className:c(`break-all rounded-md bg-muted p-3 font-mono text-sm`,e.length>100&&`max-h-32 overflow-y-auto`),children:e}),(0,E.jsxs)(`div`,{className:c(`flex gap-2`),children:[(0,E.jsx)(`button`,{className:c(`flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted`),onClick:p,type:`button`,children:l?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(i,{size:14}),(0,E.jsx)(`span`,{children:f.copied})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(a,{size:14}),(0,E.jsx)(`span`,{children:f.copyLink})]})}),(0,E.jsxs)(`button`,{className:c(`flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90`),onClick:m,type:`button`,children:[(0,E.jsx)(o,{size:14}),(0,E.jsx)(`span`,{children:f.openLink})]})]})]})}):null},Y0=(0,d.createContext)(null),X0=()=>(0,d.useContext)(Y0),Z0=()=>X0()?.code??null,Q0=()=>X0()?.mermaid??null,$0=e=>{var t;let n=X0();return n!=null&&n.renderers&&e&&(t=n.renderers.find(t=>Array.isArray(t.language)?t.language.includes(e):t.language===e))!=null?t:null},e2=(e,t)=>new Promise((t,n)=>{let r=`data:image/svg+xml;base64,`+btoa(unescape(encodeURIComponent(e))),i=new Image;i.crossOrigin=`anonymous`,i.onload=()=>{let e=document.createElement(`canvas`),r=i.width*5,a=i.height*5;e.width=r,e.height=a;let o=e.getContext(`2d`);if(!o){n(Error(`Failed to create 2D canvas context for PNG export`));return}o.drawImage(i,0,0,r,a),e.toBlob(e=>{if(!e){n(Error(`Failed to create PNG blob`));return}t(e)},`image/png`)},i.onerror=()=>n(Error(`Failed to load SVG image`)),i.src=r}),t2=({chart:e,children:t,className:n,onDownload:r,config:i,onError:a})=>{let o=b0(),[s,c]=(0,d.useState)(!1),l=(0,d.useRef)(null),{isAnimating:u}=(0,d.useContext)(G4),f=F0(),p=Q0(),m=R0(),h=async t=>{try{if(t===`mmd`){v0(`diagram.mmd`,e,`text/plain`),c(!1),r?.(t);return}if(!p){a?.(Error(`Mermaid plugin not available`));return}let n=p.getMermaid(i),o=e.split(``).reduce((e,t)=>(e<<5)-e+t.charCodeAt(0)|0,0),s=`mermaid-${Math.abs(o)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:l}=await n.render(s,e);if(!l){a?.(Error(`SVG not found. Please wait for the diagram to render.`));return}if(t===`svg`){v0(`diagram.svg`,l,`image/svg+xml`),c(!1),r?.(t);return}if(t===`png`){v0(`diagram.png`,await e2(l),`image/png`),r?.(t),c(!1);return}}catch(e){a?.(e)}};return(0,d.useEffect)(()=>{let e=e=>{let t=e.composedPath();l.current&&!t.includes(l.current)&&c(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,E.jsxs)(`div`,{className:o(`relative`),ref:l,children:[(0,E.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,n),disabled:u,onClick:()=>c(!s),title:m.downloadDiagram,type:`button`,children:t??(0,E.jsx)(f.DownloadIcon,{size:14})}),s?(0,E.jsxs)(`div`,{className:o(`absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,E.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>h(`svg`),title:m.downloadDiagramAsSvg,type:`button`,children:m.mermaidFormatSvg}),(0,E.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>h(`png`),title:m.downloadDiagramAsPng,type:`button`,children:m.mermaidFormatPng}),(0,E.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>h(`mmd`),title:m.downloadDiagramAsMmd,type:`button`,children:m.mermaidFormatMmd})]}):null]})},n2=({chart:e,config:t,onFullscreen:n,onExit:r,className:i,...a})=>{let{Maximize2Icon:o,XIcon:s}=F0(),c=b0(),[l,u]=(0,d.useState)(!1),{isAnimating:f,controls:p}=(0,d.useContext)(G4),m=R0(),h=(()=>{if(typeof p==`boolean`)return p;let e=p.mermaid;return e===!1?!1:e===!0||e===void 0||e.panZoom!==!1})(),g=()=>{u(!l)};return(0,d.useEffect)(()=>{if(l){K0();let e=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),q0()}}},[l]),(0,d.useEffect)(()=>{l?n?.():r&&r()},[l,n,r]),(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`button`,{className:c(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),disabled:f,onClick:g,title:m.viewFullscreen,type:`button`,...a,children:(0,E.jsx)(o,{size:14})}),l?(0,ii.createPortal)((0,E.jsxs)(`div`,{className:c(`fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm`),onClick:g,onKeyDown:e=>{e.key===`Escape`&&g()},role:`button`,tabIndex:0,children:[(0,E.jsx)(`button`,{className:c(`absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:g,title:m.exitFullscreen,type:`button`,children:(0,E.jsx)(s,{size:20})}),(0,E.jsx)(`div`,{className:c(`flex size-full items-center justify-center p-4`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:(0,E.jsx)(Y4,{chart:e,className:c(`size-full [&_svg]:h-auto [&_svg]:w-auto`),config:t,fullscreen:!0,showControls:h})})]}),document.body):null]})},r2=e=>{let t=[],n=[],r=e.querySelectorAll(`thead th`);for(let e of r)t.push(e.textContent?.trim()||``);let i=e.querySelectorAll(`tbody tr`);for(let e of i){let t=[],r=e.querySelectorAll(`td`);for(let e of r)t.push(e.textContent?.trim()||``);n.push(t)}return{headers:t,rows:n}},i2=e=>{let{headers:t,rows:n}=e,r=e=>{let t=!1,n=!1;for(let r of e){if(r===`"`){t=!0,n=!0;break}(r===`,`||r===`
|
|
438
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${P1(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=F1(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+P1(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=F1(e);if(i===null)return P1(n);e=i;let a=`<img src="${e}" alt="${P1(n)}"`;return t&&(a+=` title="${P1(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:P1(e.text)}},G1=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},K1=class e{options;renderer;textRenderer;constructor(e){this.options=e||x$,this.options.renderer=this.options.renderer||new W1,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new G1}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},q1=class{options;block;constructor(e){this.options=e||x$}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?U1.lex:U1.lexInline}provideParser(e=this.block){return e?K1.parse:K1.parseInline}},J1=new class{defaults=b$();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=K1;Renderer=W1;TextRenderer=G1;Lexer=U1;Tokenizer=H1;Hooks=q1;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new W1(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new H1(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new q1;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=q1.passThroughHooks.has(n)?e=>{if(this.defaults.async&&q1.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return U1.lex(e,t??this.defaults)}parser(e,t){return K1.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?U1.lex:U1.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?K1.parse:K1.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?U1.lex:U1.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?K1.parse:K1.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
439
|
+
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+P1(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Y1(e,t){return J1.parse(e,t)}Y1.options=Y1.setOptions=function(e){return J1.setOptions(e),Y1.defaults=J1.defaults,S$(Y1.defaults),Y1},Y1.getDefaults=b$,Y1.defaults=x$,Y1.use=function(...e){return J1.use(...e),Y1.defaults=J1.defaults,S$(Y1.defaults),Y1},Y1.walkTokens=function(e,t){return J1.walkTokens(e,t)},Y1.parseInline=J1.parseInline,Y1.Parser=K1,Y1.parser=K1.parse,Y1.Renderer=W1,Y1.TextRenderer=G1,Y1.Lexer=U1,Y1.lexer=U1.lex,Y1.Tokenizer=H1,Y1.Hooks=q1,Y1.parse=Y1,Y1.options,Y1.setOptions,Y1.use,Y1.walkTokens,Y1.parseInline,K1.parse,U1.lex;var X1=`modulepreload`,Z1=function(e){return`/`+e},Q1={},$1=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Z1(t,n),t=s(t),t in Q1)return;Q1[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`:X1,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)})},e0=300,t0=`300px`,n0=500;function r0(e={}){let{immediate:t=!1,debounceDelay:n=e0,rootMargin:r=t0,idleTimeout:i=n0}=e,[a,o]=(0,d.useState)(!1),s=(0,d.useRef)(null),c=(0,d.useRef)(null),l=(0,d.useRef)(null),u=(0,d.useMemo)(()=>e=>{let t=Date.now();return window.setTimeout(()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})},1)},[]),f=(0,d.useMemo)(()=>typeof window<`u`&&window.requestIdleCallback?(e,t)=>window.requestIdleCallback(e,t):u,[u]),p=(0,d.useMemo)(()=>typeof window<`u`&&window.cancelIdleCallback?e=>window.cancelIdleCallback(e):e=>{clearTimeout(e)},[]);return(0,d.useEffect)(()=>{if(t){o(!0);return}let e=s.current;if(!e)return;c.current&&=(clearTimeout(c.current),null),l.current&&=(p(l.current),null);let a=()=>{c.current&&=(clearTimeout(c.current),null),l.current&&=(p(l.current),null)},u=e=>{l.current=f(t=>{t.timeRemaining()>0||t.didTimeout?(o(!0),e.disconnect()):l.current=f(()=>{o(!0),e.disconnect()},{timeout:i/2})},{timeout:i})},d=e=>{a(),c.current=window.setTimeout(()=>{var t;let n=e.takeRecords();(n.length===0||(t=n.at(-1)?.isIntersecting)!=null&&t)&&u(e)},n)},m=(e,t)=>{e.isIntersecting?d(t):a()},h=new IntersectionObserver(e=>{for(let t of e)m(t,h)},{rootMargin:r,threshold:0});return h.observe(e),()=>{c.current&&clearTimeout(c.current),l.current&&p(l.current),h.disconnect()}},[t,n,r,i,p,f]),{shouldRender:a,containerRef:s}}var i0=/\s/,a0=/^\s+$/,o0=new Set([`code`,`pre`,`svg`,`math`,`annotation`]),s0=e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`element`,c0=e=>e.some(e=>s0(e)&&o0.has(e.tagName)),l0=e=>{let t=[],n=``,r=!1;for(let i of e){let e=i0.test(i);e!==r&&n&&(t.push(n),n=``),n+=i,r=e}return n&&t.push(n),t},u0=e=>{let t=[],n=``;for(let r of e)i0.test(r)?n+=r:(n&&=(t.push(n),``),t.push(r));return n&&t.push(n),t},d0=(e,t,n,r,i,a)=>{let o=`--sd-animation:sd-${t};--sd-duration:${i?0:n}ms;--sd-easing:${r}`;return a&&(o+=`;--sd-delay:${a}ms`),{type:`element`,tagName:`span`,properties:{"data-sd-animate":!0,style:o},children:[{type:`text`,value:e}]}},f0=(e,t,n,r,i)=>{let a=t.at(-1);if(!(a&&`children`in a))return;if(c0(t))return DO;let o=a,s=o.children.indexOf(e);if(s===-1)return;let c=e.value;if(!c.trim()){i.count+=c.length;return}let l=n.sep===`char`?u0(c):l0(c),u=r.prevContentLength,d=l.map(e=>{let t=i.count;if(i.count+=e.length,a0.test(e))return{type:`text`,value:e};let r=u>0&&t<u,a=r?0:i.newIndex++*n.stagger;return d0(e,n.animation,n.duration,n.easing,r,a)});return o.children.splice(s,1,...d),s+d.length},p0=0;function m0(e){let t={animation:e?.animation??`fadeIn`,duration:e?.duration??150,easing:e?.easing??`ease`,sep:e?.sep??`word`,stagger:e?.stagger??40},n={prevContentLength:0,lastRenderCharCount:0},r=p0++,i=()=>e=>{let r={count:0,newIndex:0};OO(e,`text`,(e,i)=>f0(e,i,t,n,r)),n.lastRenderCharCount=r.count,n.prevContentLength=0};return Object.defineProperty(i,"name",{value:`rehypeAnimate$${r}`}),{name:`animate`,type:`animate`,rehypePlugin:i,setPrevContentLength(e){n.prevContentLength=e},getLastRenderCharCount(){let e=n.lastRenderCharCount;return n.lastRenderCharCount=0,e}}}m0();var h0=(0,d.createContext)(!1),g0=()=>(0,d.useContext)(h0),_0=(...e)=>Sm(Jf(e)),v0=(e,t)=>{if(!e||!t)return t;let n=`${e}:`;return t.split(/\s+/).filter(Boolean).map(t=>t.startsWith(n)?t:`${e}:${t}`).join(` `)},y0=e=>e?(...t)=>v0(e,Sm(Jf(t))):_0,b0=(e,t,n)=>{let r=typeof t==`string`&&n.startsWith(`text/csv`)?``:``,i=typeof t==`string`?new Blob([r+t],{type:n}):t,a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},x0=(0,d.createContext)(_0),S0=()=>(0,d.useContext)(x0),C0=_0(`block`,`before:content-[counter(line)]`,`before:inline-block`,`before:[counter-increment:line]`,`before:w-6`,`before:mr-4`,`before:text-[13px]`,`before:text-right`,`before:text-muted-foreground/50`,`before:font-mono`,`before:select-none`),w0=e=>{let t={};for(let n of e.split(`;`)){let e=n.indexOf(`:`);if(e>0){let r=n.slice(0,e).trim(),i=n.slice(e+1).trim();r&&i&&(t[r]=i)}}return t},T0=(0,d.memo)(({children:e,result:t,language:n,className:r,startLine:i,lineNumbers:a=!0,...o})=>{let s=S0(),c=(0,d.useMemo)(()=>s(C0),[s]),l=(0,d.useMemo)(()=>{let e={};return t.bg&&(e[`--sdm-bg`]=t.bg),t.fg&&(e[`--sdm-fg`]=t.fg),t.rootStyle&&Object.assign(e,w0(t.rootStyle)),e},[t.bg,t.fg,t.rootStyle]);return(0,E.jsx)(`div`,{className:s(r,`overflow-x-auto rounded-md border border-border bg-background p-4 text-sm`),"data-language":n,"data-streamdown":`code-block-body`,...o,children:(0,E.jsx)(`pre`,{className:s(r,`bg-[var(--sdm-bg,inherit]`,`dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]`),style:l,children:(0,E.jsx)(`code`,{className:a?s(`[counter-increment:line_0] [counter-reset:line]`):void 0,style:a&&i&&i>1?{counterReset:`line ${i-1}`}:void 0,children:t.tokens.map((e,t)=>(0,E.jsx)(`span`,{className:a?c:void 0,children:e.length===0||e.length===1&&e[0].content===``?`
|
|
440
|
+
`:e.map((e,t)=>{let n={},r=!!e.bgColor;if(e.color&&(n[`--sdm-c`]=e.color),e.bgColor&&(n[`--sdm-tbg`]=e.bgColor),e.htmlStyle)for(let[t,i]of Object.entries(e.htmlStyle))t===`color`?n[`--sdm-c`]=i:t===`background-color`?(n[`--sdm-tbg`]=i,r=!0):n[t]=i;return(0,E.jsx)(`span`,{className:s(`text-[var(--sdm-c,inherit)]`,`dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]`,r&&`bg-[var(--sdm-tbg)]`,r&&`dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]`),style:n,...e.htmlAttrs,children:e.content},t)})},t))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers),E0=({className:e,language:t,style:n,isIncomplete:r,...i})=>{let a=S0();return(0,E.jsx)(`div`,{className:a(`my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,e),"data-incomplete":r||void 0,"data-language":t,"data-streamdown":`code-block`,style:{contentVisibility:`auto`,containIntrinsicSize:`auto 200px`,...n},...i})},D0=(0,d.createContext)({code:``}),O0=()=>(0,d.useContext)(D0),k0=({language:e})=>{let t=S0();return(0,E.jsx)(`div`,{className:t(`flex h-8 items-center text-muted-foreground text-xs`),"data-language":e,"data-streamdown":`code-block-header`,children:(0,E.jsx)(`span`,{className:t(`ml-1 font-mono lowercase`),children:e})})},A0=e=>{let t=e.length;for(;t>0&&e[t-1]===`
|
|
441
|
+
`;)t--;return e.slice(0,t)},j0=(0,d.lazy)(()=>$1(()=>import(`./highlighted-body-OFNGDK62-D4klPf9N.js`).then(e=>({default:e.HighlightedCodeBlockBody})),__vite__mapDeps([0,1]))),M0=({code:e,language:t,className:n,children:r,isIncomplete:i=!1,startLine:a,lineNumbers:o,...s})=>{let c=S0(),l=(0,d.useMemo)(()=>A0(e),[e]),u=(0,d.useMemo)(()=>({bg:`transparent`,fg:`inherit`,tokens:l.split(`
|
|
442
|
+
`).map(e=>[{content:e,color:`inherit`,bgColor:`transparent`,htmlStyle:{},offset:0}])}),[l]);return(0,E.jsx)(D0.Provider,{value:{code:e},children:(0,E.jsxs)(E0,{isIncomplete:i,language:t,children:[(0,E.jsx)(k0,{language:t}),r?(0,E.jsx)(`div`,{className:c(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,E.jsx)(`div`,{className:c(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`code-block-actions`,children:r})}):null,(0,E.jsx)(d.Suspense,{fallback:(0,E.jsx)(T0,{className:n,language:t,lineNumbers:o,result:u,startLine:a,...s}),children:(0,E.jsx)(j0,{className:n,code:l,language:t,lineNumbers:o,raw:u,startLine:a,...s})})]})})},N0={CheckIcon:e=>(0,E.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,E.jsx)(`path`,{clipRule:`evenodd`,d:`M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z`,fill:`currentColor`,fillRule:`evenodd`})}),CopyIcon:e=>(0,E.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,E.jsx)(`path`,{clipRule:`evenodd`,d:`M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z`,fill:`currentColor`,fillRule:`evenodd`})}),DownloadIcon:e=>(0,E.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,E.jsx)(`path`,{clipRule:`evenodd`,d:`M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z`,fill:`currentColor`,fillRule:`evenodd`})}),ExternalLinkIcon:e=>(0,E.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,E.jsx)(`path`,{clipRule:`evenodd`,d:`M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z`,fill:`currentColor`,fillRule:`evenodd`})}),Loader2Icon:e=>(0,E.jsxs)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:[(0,E.jsx)(`path`,{d:`M8 0V4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,E.jsx)(`path`,{d:`M8 16V12`,opacity:`0.5`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,E.jsx)(`path`,{d:`M3.29773 1.52783L5.64887 4.7639`,opacity:`0.9`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,E.jsx)(`path`,{d:`M12.7023 1.52783L10.3511 4.7639`,opacity:`0.1`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,E.jsx)(`path`,{d:`M12.7023 14.472L10.3511 11.236`,opacity:`0.4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,E.jsx)(`path`,{d:`M3.29773 14.472L5.64887 11.236`,opacity:`0.6`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,E.jsx)(`path`,{d:`M15.6085 5.52783L11.8043 6.7639`,opacity:`0.2`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,E.jsx)(`path`,{d:`M0.391602 10.472L4.19583 9.23598`,opacity:`0.7`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,E.jsx)(`path`,{d:`M15.6085 10.4722L11.8043 9.2361`,opacity:`0.3`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,E.jsx)(`path`,{d:`M0.391602 5.52783L4.19583 6.7639`,opacity:`0.8`,stroke:`currentColor`,strokeWidth:`1.5`})]}),Maximize2Icon:e=>(0,E.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,E.jsx)(`path`,{clipRule:`evenodd`,d:`M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z`,fill:`currentColor`,fillRule:`evenodd`})}),RotateCcwIcon:e=>(0,E.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,E.jsx)(`path`,{clipRule:`evenodd`,d:`M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z`,fill:`currentColor`,fillRule:`evenodd`})}),XIcon:e=>(0,E.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,E.jsx)(`path`,{clipRule:`evenodd`,d:`M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z`,fill:`currentColor`,fillRule:`evenodd`})}),ZoomInIcon:e=>(0,E.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,E.jsx)(`path`,{clipRule:`evenodd`,d:`M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z`,fill:`currentColor`,fillRule:`evenodd`})}),ZoomOutIcon:e=>(0,E.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,E.jsx)(`path`,{clipRule:`evenodd`,d:`M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z`,fill:`currentColor`,fillRule:`evenodd`})})},P0=(0,d.createContext)(N0),F0=(e,t)=>{if(e===t)return!0;if(!(e&&t))return e===t;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>e[n]===t[n])},I0=({icons:e,children:t})=>{let n=(0,d.useRef)(e),r=(0,d.useRef)(e?{...N0,...e}:N0);F0(n.current,e)||(n.current=e,r.current=e?{...N0,...e}:N0);let i=r.current;return(0,E.jsx)(P0.Provider,{value:i,children:t})},L0=()=>(0,d.useContext)(P0),R0={copyCode:`Copy Code`,downloadFile:`Download file`,downloadDiagram:`Download diagram`,downloadDiagramAsSvg:`Download diagram as SVG`,downloadDiagramAsPng:`Download diagram as PNG`,downloadDiagramAsMmd:`Download diagram as MMD`,viewFullscreen:`View fullscreen`,exitFullscreen:`Exit fullscreen`,mermaidFormatSvg:`SVG`,mermaidFormatPng:`PNG`,mermaidFormatMmd:`MMD`,copyTable:`Copy table`,copyTableAsMarkdown:`Copy table as Markdown`,copyTableAsCsv:`Copy table as CSV`,copyTableAsTsv:`Copy table as TSV`,downloadTable:`Download table`,downloadTableAsCsv:`Download table as CSV`,downloadTableAsMarkdown:`Download table as Markdown`,tableFormatMarkdown:`Markdown`,tableFormatCsv:`CSV`,tableFormatTsv:`TSV`,imageNotAvailable:`Image not available`,downloadImage:`Download image`,openExternalLink:`Open external link?`,externalLinkWarning:`You're about to visit an external website.`,close:`Close`,copyLink:`Copy link`,copied:`Copied`,openLink:`Open link`},z0=(0,d.createContext)(R0),B0=()=>(0,d.useContext)(z0),V0=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,code:a,...o})=>{let s=S0(),[c,l]=(0,d.useState)(!1),u=(0,d.useRef)(0),{code:f}=O0(),{isAnimating:p}=(0,d.useContext)(q4),m=B0(),h=a??f,g=async()=>{var r;if(typeof window>`u`||!((r=navigator==null?void 0:navigator.clipboard)!=null&&r.writeText)){t?.(Error(`Clipboard API not available`));return}try{c||(await navigator.clipboard.writeText(h),l(!0),e?.(),u.current=window.setTimeout(()=>l(!1),n))}catch(e){t?.(e)}};(0,d.useEffect)(()=>()=>{window.clearTimeout(u.current)},[]);let _=L0(),v=c?_.CheckIcon:_.CopyIcon;return(0,E.jsx)(`button`,{className:s(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),"data-streamdown":`code-block-copy-button`,disabled:p,onClick:g,title:m.copyCode,type:`button`,...o,children:r??(0,E.jsx)(v,{size:14})})},H0={"1c":`1c`,"1c-query":`1cq`,abap:`abap`,"actionscript-3":`as`,ada:`ada`,adoc:`adoc`,"angular-html":`html`,"angular-ts":`ts`,apache:`conf`,apex:`cls`,apl:`apl`,applescript:`applescript`,ara:`ara`,asciidoc:`adoc`,asm:`asm`,astro:`astro`,awk:`awk`,ballerina:`bal`,bash:`sh`,bat:`bat`,batch:`bat`,be:`be`,beancount:`beancount`,berry:`berry`,bibtex:`bib`,bicep:`bicep`,blade:`blade.php`,bsl:`bsl`,c:`c`,"c#":`cs`,"c++":`cpp`,cadence:`cdc`,cairo:`cairo`,cdc:`cdc`,clarity:`clar`,clj:`clj`,clojure:`clj`,"closure-templates":`soy`,cmake:`cmake`,cmd:`cmd`,cobol:`cob`,codeowners:`CODEOWNERS`,codeql:`ql`,coffee:`coffee`,coffeescript:`coffee`,"common-lisp":`lisp`,console:`sh`,coq:`v`,cpp:`cpp`,cql:`cql`,crystal:`cr`,cs:`cs`,csharp:`cs`,css:`css`,csv:`csv`,cue:`cue`,cypher:`cql`,d:`d`,dart:`dart`,dax:`dax`,desktop:`desktop`,diff:`diff`,docker:`dockerfile`,dockerfile:`dockerfile`,dotenv:`env`,"dream-maker":`dm`,edge:`edge`,elisp:`el`,elixir:`ex`,elm:`elm`,"emacs-lisp":`el`,erb:`erb`,erl:`erl`,erlang:`erl`,f:`f`,"f#":`fs`,f03:`f03`,f08:`f08`,f18:`f18`,f77:`f77`,f90:`f90`,f95:`f95`,fennel:`fnl`,fish:`fish`,fluent:`ftl`,for:`for`,"fortran-fixed-form":`f`,"fortran-free-form":`f90`,fs:`fs`,fsharp:`fs`,fsl:`fsl`,ftl:`ftl`,gdresource:`tres`,gdscript:`gd`,gdshader:`gdshader`,genie:`gs`,gherkin:`feature`,"git-commit":`gitcommit`,"git-rebase":`gitrebase`,gjs:`js`,gleam:`gleam`,"glimmer-js":`js`,"glimmer-ts":`ts`,glsl:`glsl`,gnuplot:`plt`,go:`go`,gql:`gql`,graphql:`graphql`,groovy:`groovy`,gts:`gts`,hack:`hack`,haml:`haml`,handlebars:`hbs`,haskell:`hs`,haxe:`hx`,hbs:`hbs`,hcl:`hcl`,hjson:`hjson`,hlsl:`hlsl`,hs:`hs`,html:`html`,"html-derivative":`html`,http:`http`,hxml:`hxml`,hy:`hy`,imba:`imba`,ini:`ini`,jade:`jade`,java:`java`,javascript:`js`,jinja:`jinja`,jison:`jison`,jl:`jl`,js:`js`,json:`json`,json5:`json5`,jsonc:`jsonc`,jsonl:`jsonl`,jsonnet:`jsonnet`,jssm:`jssm`,jsx:`jsx`,julia:`jl`,kotlin:`kt`,kql:`kql`,kt:`kt`,kts:`kts`,kusto:`kql`,latex:`tex`,lean:`lean`,lean4:`lean`,less:`less`,liquid:`liquid`,lisp:`lisp`,lit:`lit`,llvm:`ll`,log:`log`,logo:`logo`,lua:`lua`,luau:`luau`,make:`mak`,makefile:`mak`,markdown:`md`,marko:`marko`,matlab:`m`,md:`md`,mdc:`mdc`,mdx:`mdx`,mediawiki:`wiki`,mermaid:`mmd`,mips:`s`,mipsasm:`s`,mmd:`mmd`,mojo:`mojo`,move:`move`,nar:`nar`,narrat:`narrat`,nextflow:`nf`,nf:`nf`,nginx:`conf`,nim:`nim`,nix:`nix`,nu:`nu`,nushell:`nu`,objc:`m`,"objective-c":`m`,"objective-cpp":`mm`,ocaml:`ml`,pascal:`pas`,perl:`pl`,perl6:`p6`,php:`php`,plsql:`pls`,po:`po`,polar:`polar`,postcss:`pcss`,pot:`pot`,potx:`potx`,powerquery:`pq`,powershell:`ps1`,prisma:`prisma`,prolog:`pl`,properties:`properties`,proto:`proto`,protobuf:`proto`,ps:`ps`,ps1:`ps1`,pug:`pug`,puppet:`pp`,purescript:`purs`,py:`py`,python:`py`,ql:`ql`,qml:`qml`,qmldir:`qmldir`,qss:`qss`,r:`r`,racket:`rkt`,raku:`raku`,razor:`cshtml`,rb:`rb`,reg:`reg`,regex:`regex`,regexp:`regexp`,rel:`rel`,riscv:`s`,rs:`rs`,rst:`rst`,ruby:`rb`,rust:`rs`,sas:`sas`,sass:`sass`,scala:`scala`,scheme:`scm`,scss:`scss`,sdbl:`sdbl`,sh:`sh`,shader:`shader`,shaderlab:`shader`,shell:`sh`,shellscript:`sh`,shellsession:`sh`,smalltalk:`st`,solidity:`sol`,soy:`soy`,sparql:`rq`,spl:`spl`,splunk:`spl`,sql:`sql`,"ssh-config":`config`,stata:`do`,styl:`styl`,stylus:`styl`,svelte:`svelte`,swift:`swift`,"system-verilog":`sv`,systemd:`service`,talon:`talon`,talonscript:`talon`,tasl:`tasl`,tcl:`tcl`,templ:`templ`,terraform:`tf`,tex:`tex`,tf:`tf`,tfvars:`tfvars`,toml:`toml`,ts:`ts`,"ts-tags":`ts`,tsp:`tsp`,tsv:`tsv`,tsx:`tsx`,turtle:`ttl`,twig:`twig`,typ:`typ`,typescript:`ts`,typespec:`tsp`,typst:`typ`,v:`v`,vala:`vala`,vb:`vb`,verilog:`v`,vhdl:`vhdl`,vim:`vim`,viml:`vim`,vimscript:`vim`,vue:`vue`,"vue-html":`html`,"vue-vine":`vine`,vy:`vy`,vyper:`vy`,wasm:`wasm`,wenyan:`wy`,wgsl:`wgsl`,wiki:`wiki`,wikitext:`wiki`,wit:`wit`,wl:`wl`,wolfram:`wl`,xml:`xml`,xsl:`xsl`,yaml:`yaml`,yml:`yml`,zenscript:`zs`,zig:`zig`,zsh:`zsh`,文言:`wy`},U0=({onDownload:e,onError:t,language:n,children:r,className:i,code:a,...o})=>{let s=S0(),{code:c}=O0(),{isAnimating:l}=(0,d.useContext)(q4),u=B0(),f=L0(),p=a??c,m=`file.${n&&n in H0?H0[n]:`txt`}`;return(0,E.jsx)(`button`,{className:s(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),"data-streamdown":`code-block-download-button`,disabled:l,onClick:()=>{try{b0(m,p,`text/plain`),e?.()}catch(e){t?.(e)}},title:u.downloadFile,type:`button`,...o,children:r??(0,E.jsx)(f.DownloadIcon,{size:14})})},W0=()=>{let{Loader2Icon:e}=L0(),t=S0();return(0,E.jsxs)(`div`,{className:t(`w-full divide-y divide-border overflow-hidden rounded-xl border border-border`),children:[(0,E.jsx)(`div`,{className:t(`h-[46px] w-full bg-muted/80`)}),(0,E.jsx)(`div`,{className:t(`flex w-full items-center justify-center p-4`),children:(0,E.jsx)(e,{className:t(`size-4 animate-spin`)})})]})},G0=/\.[^/.]+$/,K0=({node:e,className:t,src:n,alt:r,onLoad:i,onError:a,...o})=>{let{DownloadIcon:s}=L0(),c=S0(),l=(0,d.useRef)(null),[u,f]=(0,d.useState)(!1),[p,m]=(0,d.useState)(!1),h=B0(),g=o.width!=null||o.height!=null,_=(u||g)&&!p,v=p&&!g;(0,d.useEffect)(()=>{let e=l.current;if(e!=null&&e.complete){let t=e.naturalWidth>0;f(t),m(!t)}},[]);let y=(0,d.useCallback)(e=>{f(!0),m(!1),i?.(e)},[i]),b=(0,d.useCallback)(e=>{f(!1),m(!0),a?.(e)},[a]),x=async()=>{if(n)try{let e=await(await fetch(n)).blob(),t=new URL(n,window.location.origin).pathname.split(`/`).pop()||``,i=t.split(`.`).pop(),a=t.includes(`.`)&&i!==void 0&&i.length<=4,o=``;if(a)o=t;else{let n=e.type,i=`png`;n.includes(`jpeg`)||n.includes(`jpg`)?i=`jpg`:n.includes(`png`)?i=`png`:n.includes(`svg`)?i=`svg`:n.includes(`gif`)?i=`gif`:n.includes(`webp`)&&(i=`webp`),o=`${(r||t||`image`).replace(G0,``)}.${i}`}b0(o,e,e.type)}catch{window.open(n,`_blank`)}};return n?(0,E.jsxs)(`div`,{className:c(`group relative my-4 inline-block`),"data-streamdown":`image-wrapper`,children:[(0,E.jsx)(`img`,{alt:r,className:c(`max-w-full rounded-lg`,v&&`hidden`,t),"data-streamdown":`image`,onError:b,onLoad:y,ref:l,src:n,...o}),v&&(0,E.jsx)(`span`,{className:c(`text-muted-foreground text-xs italic`),"data-streamdown":`image-fallback`,children:h.imageNotAvailable}),(0,E.jsx)(`div`,{className:c(`pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block`)}),_&&(0,E.jsx)(`button`,{className:c(`absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background`,`opacity-0 group-hover:opacity-100`),onClick:x,title:h.downloadImage,type:`button`,children:(0,E.jsx)(s,{size:14})})]}):null},q0=0,J0=()=>{q0+=1,q0===1&&(document.body.style.overflow=`hidden`)},Y0=()=>{q0=Math.max(0,q0-1),q0===0&&(document.body.style.overflow=``)},X0=({url:e,isOpen:t,onClose:n,onConfirm:r})=>{let{CheckIcon:i,CopyIcon:a,ExternalLinkIcon:o,XIcon:s}=L0(),c=S0(),[l,u]=(0,d.useState)(!1),f=B0(),p=(0,d.useCallback)(async()=>{try{await navigator.clipboard.writeText(e),u(!0),setTimeout(()=>u(!1),2e3)}catch{}},[e]),m=(0,d.useCallback)(()=>{r(),n()},[r,n]);return(0,d.useEffect)(()=>{if(t){J0();let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),Y0()}}},[t,n]),t?(0,E.jsx)(`div`,{className:c(`fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm`),"data-streamdown":`link-safety-modal`,onClick:n,onKeyDown:e=>{e.key===`Escape`&&n()},role:`button`,tabIndex:0,children:(0,E.jsxs)(`div`,{className:c(`relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,E.jsx)(`button`,{className:c(`absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:n,title:f.close,type:`button`,children:(0,E.jsx)(s,{size:16})}),(0,E.jsxs)(`div`,{className:c(`flex flex-col gap-2`),children:[(0,E.jsxs)(`div`,{className:c(`flex items-center gap-2 font-semibold text-lg`),children:[(0,E.jsx)(o,{size:20}),(0,E.jsx)(`span`,{children:f.openExternalLink})]}),(0,E.jsx)(`p`,{className:c(`text-muted-foreground text-sm`),children:f.externalLinkWarning})]}),(0,E.jsx)(`div`,{className:c(`break-all rounded-md bg-muted p-3 font-mono text-sm`,e.length>100&&`max-h-32 overflow-y-auto`),children:e}),(0,E.jsxs)(`div`,{className:c(`flex gap-2`),children:[(0,E.jsx)(`button`,{className:c(`flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted`),onClick:p,type:`button`,children:l?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(i,{size:14}),(0,E.jsx)(`span`,{children:f.copied})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(a,{size:14}),(0,E.jsx)(`span`,{children:f.copyLink})]})}),(0,E.jsxs)(`button`,{className:c(`flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90`),onClick:m,type:`button`,children:[(0,E.jsx)(o,{size:14}),(0,E.jsx)(`span`,{children:f.openLink})]})]})]})}):null},Z0=(0,d.createContext)(null),Q0=()=>(0,d.useContext)(Z0),$0=()=>Q0()?.code??null,e2=()=>Q0()?.mermaid??null,t2=e=>{var t;let n=Q0();return n!=null&&n.renderers&&e&&(t=n.renderers.find(t=>Array.isArray(t.language)?t.language.includes(e):t.language===e))!=null?t:null},n2=(e,t)=>new Promise((t,n)=>{let r=`data:image/svg+xml;base64,`+btoa(unescape(encodeURIComponent(e))),i=new Image;i.crossOrigin=`anonymous`,i.onload=()=>{let e=document.createElement(`canvas`),r=i.width*5,a=i.height*5;e.width=r,e.height=a;let o=e.getContext(`2d`);if(!o){n(Error(`Failed to create 2D canvas context for PNG export`));return}o.drawImage(i,0,0,r,a),e.toBlob(e=>{if(!e){n(Error(`Failed to create PNG blob`));return}t(e)},`image/png`)},i.onerror=()=>n(Error(`Failed to load SVG image`)),i.src=r}),r2=({chart:e,children:t,className:n,onDownload:r,config:i,onError:a})=>{let o=S0(),[s,c]=(0,d.useState)(!1),l=(0,d.useRef)(null),{isAnimating:u}=(0,d.useContext)(q4),f=L0(),p=e2(),m=B0(),h=async t=>{try{if(t===`mmd`){b0(`diagram.mmd`,e,`text/plain`),c(!1),r?.(t);return}if(!p){a?.(Error(`Mermaid plugin not available`));return}let n=p.getMermaid(i),o=e.split(``).reduce((e,t)=>(e<<5)-e+t.charCodeAt(0)|0,0),s=`mermaid-${Math.abs(o)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:l}=await n.render(s,e);if(!l){a?.(Error(`SVG not found. Please wait for the diagram to render.`));return}if(t===`svg`){b0(`diagram.svg`,l,`image/svg+xml`),c(!1),r?.(t);return}if(t===`png`){b0(`diagram.png`,await n2(l),`image/png`),r?.(t),c(!1);return}}catch(e){a?.(e)}};return(0,d.useEffect)(()=>{let e=e=>{let t=e.composedPath();l.current&&!t.includes(l.current)&&c(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,E.jsxs)(`div`,{className:o(`relative`),ref:l,children:[(0,E.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,n),disabled:u,onClick:()=>c(!s),title:m.downloadDiagram,type:`button`,children:t??(0,E.jsx)(f.DownloadIcon,{size:14})}),s?(0,E.jsxs)(`div`,{className:o(`absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,E.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>h(`svg`),title:m.downloadDiagramAsSvg,type:`button`,children:m.mermaidFormatSvg}),(0,E.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>h(`png`),title:m.downloadDiagramAsPng,type:`button`,children:m.mermaidFormatPng}),(0,E.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>h(`mmd`),title:m.downloadDiagramAsMmd,type:`button`,children:m.mermaidFormatMmd})]}):null]})},i2=({chart:e,config:t,onFullscreen:n,onExit:r,className:i,...a})=>{let{Maximize2Icon:o,XIcon:s}=L0(),c=S0(),[l,u]=(0,d.useState)(!1),{isAnimating:f,controls:p}=(0,d.useContext)(q4),m=B0(),h=(()=>{if(typeof p==`boolean`)return p;let e=p.mermaid;return e===!1?!1:e===!0||e===void 0||e.panZoom!==!1})(),g=()=>{u(!l)};return(0,d.useEffect)(()=>{if(l){J0();let e=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),Y0()}}},[l]),(0,d.useEffect)(()=>{l?n?.():r&&r()},[l,n,r]),(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`button`,{className:c(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),disabled:f,onClick:g,title:m.viewFullscreen,type:`button`,...a,children:(0,E.jsx)(o,{size:14})}),l?(0,ii.createPortal)((0,E.jsxs)(`div`,{className:c(`fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm`),onClick:g,onKeyDown:e=>{e.key===`Escape`&&g()},role:`button`,tabIndex:0,children:[(0,E.jsx)(`button`,{className:c(`absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:g,title:m.exitFullscreen,type:`button`,children:(0,E.jsx)(s,{size:20})}),(0,E.jsx)(`div`,{className:c(`flex size-full items-center justify-center p-4`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:(0,E.jsx)(Z4,{chart:e,className:c(`size-full [&_svg]:h-auto [&_svg]:w-auto`),config:t,fullscreen:!0,showControls:h})})]}),document.body):null]})},a2=e=>{let t=[],n=[],r=e.querySelectorAll(`thead th`);for(let e of r)t.push(e.textContent?.trim()||``);let i=e.querySelectorAll(`tbody tr`);for(let e of i){let t=[],r=e.querySelectorAll(`td`);for(let e of r)t.push(e.textContent?.trim()||``);n.push(t)}return{headers:t,rows:n}},o2=e=>{let{headers:t,rows:n}=e,r=e=>{let t=!1,n=!1;for(let r of e){if(r===`"`){t=!0,n=!0;break}(r===`,`||r===`
|
|
443
443
|
`)&&(t=!0)}return t?n?`"${e.replace(/"/g,`""`)}"`:`"${e}"`:e},i=t.length>0?n.length+1:n.length,a=Array(i),o=0;t.length>0&&(a[o]=t.map(r).join(`,`),o+=1);for(let e of n)a[o]=e.map(r).join(`,`),o+=1;return a.join(`
|
|
444
|
-
`)},
|
|
444
|
+
`)},s2=e=>{let{headers:t,rows:n}=e,r=e=>{let t=!1;for(let n of e)if(n===` `||n===`
|
|
445
445
|
`||n===`\r`){t=!0;break}if(!t)return e;let n=[];for(let t of e)t===` `?n.push(`\\t`):t===`
|
|
446
446
|
`?n.push(`\\n`):t===`\r`?n.push(`\\r`):n.push(t);return n.join(``)},i=t.length>0?n.length+1:n.length,a=Array(i),o=0;t.length>0&&(a[o]=t.map(r).join(` `),o+=1);for(let e of n)a[o]=e.map(r).join(` `),o+=1;return a.join(`
|
|
447
|
-
`)},
|
|
448
|
-
`)},c2=({children:e,className:t,onCopy:n,onError:r,timeout:i=2e3})=>{let a=b0(),[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(!1),u=(0,d.useRef)(null),f=(0,d.useRef)(0),{isAnimating:p}=(0,d.useContext)(G4),m=R0(),h=async e=>{var t;if(typeof window>`u`||!((t=navigator==null?void 0:navigator.clipboard)!=null&&t.write)){r?.(Error(`Clipboard API not available`));return}try{let t=(u.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let a=r2(t),o=({csv:i2,tsv:a2,md:s2}[e]||s2)(a),c=new ClipboardItem({"text/plain":new Blob([o],{type:`text/plain`}),"text/html":new Blob([t.outerHTML],{type:`text/html`})});await navigator.clipboard.write([c]),l(!0),s(!1),n?.(e),f.current=window.setTimeout(()=>l(!1),i)}catch(e){r?.(e)}};(0,d.useEffect)(()=>{let e=e=>{let t=e.composedPath();u.current&&!t.includes(u.current)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e),window.clearTimeout(f.current)}},[]);let g=F0(),_=c?g.CheckIcon:g.CopyIcon;return(0,E.jsxs)(`div`,{className:a(`relative`),ref:u,children:[(0,E.jsx)(`button`,{className:a(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:p,onClick:()=>s(!o),title:m.copyTable,type:`button`,children:e??(0,E.jsx)(_,{height:14,width:14})}),o?(0,E.jsxs)(`div`,{className:a(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,E.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>h(`md`),title:m.copyTableAsMarkdown,type:`button`,children:m.tableFormatMarkdown}),(0,E.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>h(`csv`),title:m.copyTableAsCsv,type:`button`,children:m.tableFormatCsv}),(0,E.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>h(`tsv`),title:m.copyTableAsTsv,type:`button`,children:m.tableFormatTsv})]}):null]})},l2=({children:e,className:t,onDownload:n,onError:r})=>{let i=b0(),[a,o]=(0,d.useState)(!1),s=(0,d.useRef)(null),{isAnimating:c}=(0,d.useContext)(G4),l=R0(),u=F0(),f=e=>{try{let t=(s.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let i=r2(t),a=e===`csv`?i2(i):s2(i);v0(`table.${e===`csv`?`csv`:`md`}`,a,e===`csv`?`text/csv`:`text/markdown`),o(!1),n?.(e)}catch(e){r?.(e)}};return(0,d.useEffect)(()=>{let e=e=>{let t=e.composedPath();s.current&&!t.includes(s.current)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,E.jsxs)(`div`,{className:i(`relative`),ref:s,children:[(0,E.jsx)(`button`,{className:i(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:c,onClick:()=>o(!a),title:l.downloadTable,type:`button`,children:e??(0,E.jsx)(u.DownloadIcon,{size:14})}),a?(0,E.jsxs)(`div`,{className:i(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,E.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>f(`csv`),title:l.downloadTableAsCsv,type:`button`,children:l.tableFormatCsv}),(0,E.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>f(`markdown`),title:l.downloadTableAsMarkdown,type:`button`,children:l.tableFormatMarkdown})]}):null]})},u2=({children:e,className:t,showCopy:n=!0,showDownload:r=!0})=>{let{Maximize2Icon:i,XIcon:a}=F0(),o=b0(),[s,c]=(0,d.useState)(!1),{isAnimating:l}=(0,d.useContext)(G4),u=R0(),f=()=>{c(!0)},p=()=>{c(!1)};return(0,d.useEffect)(()=>{if(s){K0();let e=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),q0()}}},[s]),(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:l,onClick:f,title:u.viewFullscreen,type:`button`,children:(0,E.jsx)(i,{size:14})}),s?(0,ii.createPortal)((0,E.jsx)(`div`,{"aria-label":u.viewFullscreen,"aria-modal":`true`,className:o(`fixed inset-0 z-50 flex flex-col bg-background`),"data-streamdown":`table-fullscreen`,onClick:p,onKeyDown:e=>{e.key===`Escape`&&p()},role:`dialog`,children:(0,E.jsxs)(`div`,{className:o(`flex h-full flex-col`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,E.jsxs)(`div`,{className:o(`flex items-center justify-end gap-1 p-4`),children:[n?(0,E.jsx)(c2,{}):null,r?(0,E.jsx)(l2,{}):null,(0,E.jsx)(`button`,{className:o(`rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:p,title:u.exitFullscreen,type:`button`,children:(0,E.jsx)(a,{size:20})})]}),(0,E.jsx)(`div`,{className:o(`flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10`),children:(0,E.jsx)(`table`,{className:o(`w-full border-collapse border border-border`),"data-streamdown":`table`,children:e})})]})}),document.body):null]})},d2=({children:e,className:t,showControls:n,showCopy:r=!0,showDownload:i=!0,showFullscreen:a=!0,...o})=>{let s=b0(),c=n&&r,l=n&&i,u=n&&a,d=c||l||u;return(0,E.jsxs)(`div`,{className:s(`my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2`),"data-streamdown":`table-wrapper`,children:[d?(0,E.jsxs)(`div`,{className:s(`flex items-center justify-end gap-1`),children:[c?(0,E.jsx)(c2,{}):null,l?(0,E.jsx)(l2,{}):null,u?(0,E.jsx)(u2,{showCopy:c,showDownload:l,children:e}):null]}):null,(0,E.jsx)(`div`,{className:s(`border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background`),children:(0,E.jsx)(`table`,{className:s(`w-full divide-y divide-border`,t),"data-streamdown":`table`,...o,children:e})})]})},f2=/startLine=(\d+)/,p2=/\bnoLineNumbers\b/,m2=(0,d.lazy)(()=>Z1(()=>import(`./mermaid-GHXKKRXX-CmTuLrk-.js`).then(e=>({default:e.Mermaid})),[])),h2=/language-([^\s]+)/;function g2(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&t!=null&&t.position))return!1;let n=e.position.start,r=t.position.start,i=e.position.end,a=t.position.end;return n?.line===r?.line&&n?.column===r?.column&&i?.line===a?.line&&i?.column===a?.column}function _2(e,t){return e.className===t.className&&g2(e.node,t.node)}var v2=(e,t)=>typeof e==`boolean`?e:e[t]!==!1,y2=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.table;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},b2=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.code;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},x2=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.mermaid;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},S2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=b0();return(0,E.jsx)(`ol`,{className:i(`list-inside list-decimal whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`ordered-list`,...r,children:e})},(e,t)=>_2(e,t));S2.displayName=`MarkdownOl`;var C2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=b0();return(0,E.jsx)(`li`,{className:i(`py-1 [&>p]:inline`,t),"data-streamdown":`list-item`,...r,children:e})},(e,t)=>e.className===t.className&&g2(e.node,t.node));C2.displayName=`MarkdownLi`;var w2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=b0();return(0,E.jsx)(`ul`,{className:i(`list-inside list-disc whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`unordered-list`,...r,children:e})},(e,t)=>_2(e,t));w2.displayName=`MarkdownUl`;var T2=(0,d.memo)(({className:e,node:t,...n})=>{let r=b0();return(0,E.jsx)(`hr`,{className:r(`my-6 border-border`,e),"data-streamdown":`horizontal-rule`,...n})},(e,t)=>_2(e,t));T2.displayName=`MarkdownHr`;var E2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=b0();return(0,E.jsx)(`span`,{className:i(`font-semibold`,t),"data-streamdown":`strong`,...r,children:e})},(e,t)=>_2(e,t));E2.displayName=`MarkdownStrong`;var D2=(0,d.memo)(({children:e,className:t,href:n,node:r,...i})=>{let a=b0(),{linkSafety:o}=(0,d.useContext)(G4),[s,c]=(0,d.useState)(!1),l=n===`streamdown:incomplete-link`,u=(0,d.useCallback)(async e=>{if(!(!(o!=null&&o.enabled&&n)||l)){if(e.preventDefault(),o.onLinkCheck&&await o.onLinkCheck(n)){window.open(n,`_blank`,`noreferrer`);return}c(!0)}},[o,n,l]),f=(0,d.useCallback)(()=>{n&&window.open(n,`_blank`,`noreferrer`)},[n]),p=(0,d.useCallback)(()=>{c(!1)},[]),m={url:n??``,isOpen:s,onClose:p,onConfirm:f};return o!=null&&o.enabled&&n?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`button`,{className:a(`wrap-anywhere appearance-none text-left font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,onClick:u,type:`button`,children:e}),o.renderModal?o.renderModal(m):(0,E.jsx)(J0,{...m})]}):(0,E.jsx)(`a`,{className:a(`wrap-anywhere font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,href:n,rel:`noreferrer`,target:`_blank`,...i,children:e})},(e,t)=>_2(e,t)&&e.href===t.href);D2.displayName=`MarkdownA`;var O2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=b0();return(0,E.jsx)(`h1`,{className:i(`mt-6 mb-2 font-semibold text-3xl`,t),"data-streamdown":`heading-1`,...r,children:e})},(e,t)=>_2(e,t));O2.displayName=`MarkdownH1`;var k2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=b0();return(0,E.jsx)(`h2`,{className:i(`mt-6 mb-2 font-semibold text-2xl`,t),"data-streamdown":`heading-2`,...r,children:e})},(e,t)=>_2(e,t));k2.displayName=`MarkdownH2`;var A2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=b0();return(0,E.jsx)(`h3`,{className:i(`mt-6 mb-2 font-semibold text-xl`,t),"data-streamdown":`heading-3`,...r,children:e})},(e,t)=>_2(e,t));A2.displayName=`MarkdownH3`;var j2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=b0();return(0,E.jsx)(`h4`,{className:i(`mt-6 mb-2 font-semibold text-lg`,t),"data-streamdown":`heading-4`,...r,children:e})},(e,t)=>_2(e,t));j2.displayName=`MarkdownH4`;var M2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=b0();return(0,E.jsx)(`h5`,{className:i(`mt-6 mb-2 font-semibold text-base`,t),"data-streamdown":`heading-5`,...r,children:e})},(e,t)=>_2(e,t));M2.displayName=`MarkdownH5`;var N2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=b0();return(0,E.jsx)(`h6`,{className:i(`mt-6 mb-2 font-semibold text-sm`,t),"data-streamdown":`heading-6`,...r,children:e})},(e,t)=>_2(e,t));N2.displayName=`MarkdownH6`;var P2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let{controls:i}=(0,d.useContext)(G4),a=v2(i,`table`),o=y2(i,`copy`),s=y2(i,`download`),c=y2(i,`fullscreen`);return(0,E.jsx)(d2,{className:t,showControls:a,showCopy:o,showDownload:s,showFullscreen:c,...r,children:e})},(e,t)=>_2(e,t));P2.displayName=`MarkdownTable`;var F2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=b0();return(0,E.jsx)(`thead`,{className:i(`bg-muted/80`,t),"data-streamdown":`table-header`,...r,children:e})},(e,t)=>_2(e,t));F2.displayName=`MarkdownThead`;var I2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=b0();return(0,E.jsx)(`tbody`,{className:i(`divide-y divide-border`,t),"data-streamdown":`table-body`,...r,children:e})},(e,t)=>_2(e,t));I2.displayName=`MarkdownTbody`;var L2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=b0();return(0,E.jsx)(`tr`,{className:i(`border-border`,t),"data-streamdown":`table-row`,...r,children:e})},(e,t)=>_2(e,t));L2.displayName=`MarkdownTr`;var R2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=b0();return(0,E.jsx)(`th`,{className:i(`whitespace-nowrap px-4 py-2 text-left font-semibold text-sm`,t),"data-streamdown":`table-header-cell`,...r,children:e})},(e,t)=>_2(e,t));R2.displayName=`MarkdownTh`;var z2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=b0();return(0,E.jsx)(`td`,{className:i(`px-4 py-2 text-sm`,t),"data-streamdown":`table-cell`,...r,children:e})},(e,t)=>_2(e,t));z2.displayName=`MarkdownTd`;var B2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=b0();return(0,E.jsx)(`blockquote`,{className:i(`my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic`,t),"data-streamdown":`blockquote`,...r,children:e})},(e,t)=>_2(e,t));B2.displayName=`MarkdownBlockquote`;var V2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=b0();return(0,E.jsx)(`sup`,{className:i(`text-sm`,t),"data-streamdown":`superscript`,...r,children:e})},(e,t)=>_2(e,t));V2.displayName=`MarkdownSup`;var H2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=b0();return(0,E.jsx)(`sub`,{className:i(`text-sm`,t),"data-streamdown":`subscript`,...r,children:e})},(e,t)=>_2(e,t));H2.displayName=`MarkdownSub`;var U2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{if(`data-footnotes`in r){let n=e=>{if(!(0,d.isValidElement)(e))return!1;let t=Array.isArray(e.props.children)?e.props.children:[e.props.children],n=!1,r=!1;for(let e of t)if(e){if(typeof e==`string`)e.trim()!==``&&(n=!0);else if((0,d.isValidElement)(e)){if(e.props?.[`data-footnote-backref`]!==void 0)r=!0;else{let t=Array.isArray(e.props.children)?e.props.children:[e.props.children];for(let e of t){if(typeof e==`string`&&e.trim()!==``){n=!0;break}if((0,d.isValidElement)(e)&&e.props?.[`data-footnote-backref`]===void 0){n=!0;break}}}}}return r&&!n},i=Array.isArray(e)?e.map(e=>{if(!(0,d.isValidElement)(e))return e;if(e.type===S2){let t=(Array.isArray(e.props.children)?e.props.children:[e.props.children]).filter(e=>!n(e));return t.length===0?null:{...e,props:{...e.props,children:t}}}return e}):e;return(Array.isArray(i)?i.some(e=>e!==null):i!==null)?(0,E.jsx)(`section`,{className:t,...r,children:i}):null}return(0,E.jsx)(`section`,{className:t,...r,children:e})},(e,t)=>_2(e,t));U2.displayName=`MarkdownSection`;var W2=(0,d.memo)(({node:e,className:t,children:n,...r})=>{let i=b0(),a=!(`data-block`in r),{mermaid:o,controls:s,lineNumbers:c}=(0,d.useContext)(G4),l=Q0(),u=m0(),f=(t?.match(h2))?.at(1)??``,p=$0(f);if(a)return(0,E.jsx)(`code`,{className:i(`rounded bg-muted px-1.5 py-0.5 font-mono text-sm`,t),"data-streamdown":`inline-code`,...r,children:n});let m=e?.properties?.metastring,h=m?.match(f2),g=h?Number.parseInt(h[1],10):void 0,_=g!==void 0&&g>=1?g:void 0,v=!(m&&p2.test(m))&&c!==!1,y=``;if((0,d.isValidElement)(n)&&n.props&&typeof n.props==`object`&&`children`in n.props&&typeof n.props.children==`string`?y=n.props.children:typeof n==`string`&&(y=n),p){let e=p.component;return(0,E.jsx)(d.Suspense,{fallback:(0,E.jsx)(H0,{}),children:(0,E.jsx)(e,{code:y,isIncomplete:u,language:f,meta:m})})}if(f===`mermaid`&&l){let e=v2(s,`mermaid`),n=x2(s,`download`),r=x2(s,`copy`),a=x2(s,`fullscreen`),c=x2(s,`panZoom`),l=e&&(n||r||a);return(0,E.jsx)(d.Suspense,{fallback:(0,E.jsx)(H0,{}),children:(0,E.jsxs)(`div`,{className:i(`group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,t),"data-streamdown":`mermaid-block`,children:[(0,E.jsx)(`div`,{className:i(`flex h-8 items-center text-muted-foreground text-xs`),children:(0,E.jsx)(`span`,{className:i(`ml-1 font-mono lowercase`),children:`mermaid`})}),l?(0,E.jsx)(`div`,{className:i(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,E.jsxs)(`div`,{className:i(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`mermaid-block-actions`,children:[n?(0,E.jsx)(t2,{chart:y,config:o?.config}):null,r?(0,E.jsx)(z0,{code:y}):null,a?(0,E.jsx)(n2,{chart:y,config:o?.config}):null]})}):null,(0,E.jsx)(`div`,{className:i(`rounded-md border border-border bg-background`),children:(0,E.jsx)(m2,{chart:y,config:o?.config,showControls:c})})]})})}let b=v2(s,`code`),x=b2(s,`download`),S=b2(s,`copy`);return(0,E.jsx)(A0,{className:t,code:y,isIncomplete:u,language:f,lineNumbers:v,startLine:_,children:b?(0,E.jsxs)(E.Fragment,{children:[x?(0,E.jsx)(V0,{code:y,language:f}):null,S?(0,E.jsx)(z0,{}):null]}):null})},(e,t)=>e.className===t.className&&g2(e.node,t.node));W2.displayName=`MarkdownCode`;var G2=(0,d.memo)(W0,(e,t)=>e.className===t.className&&g2(e.node,t.node));G2.displayName=`MarkdownImg`;var K2=(0,d.memo)(({children:e,node:t,...n})=>{let r=(Array.isArray(e)?e:[e]).filter(e=>e!=null&&e!==``);if(r.length===1&&(0,d.isValidElement)(r[0])){let t=r[0].props.node?.tagName;if(t===`img`||t===`code`&&`data-block`in r[0].props)return(0,E.jsx)(E.Fragment,{children:e})}return(0,E.jsx)(`p`,{...n,children:e})},(e,t)=>_2(e,t));K2.displayName=`MarkdownParagraph`;var q2={ol:S2,li:C2,ul:w2,hr:T2,strong:E2,a:D2,h1:O2,h2:k2,h3:A2,h4:j2,h5:M2,h6:N2,table:P2,thead:F2,tbody:I2,tr:L2,th:R2,td:z2,blockquote:B2,code:W2,img:G2,pre:({children:e})=>(0,d.isValidElement)(e)?(0,d.cloneElement)(e,{"data-block":`true`}):e,sup:V2,sub:H2,p:K2,section:U2},J2=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,Y2=/\p{L}/u;function X2(e){let t=e.replace(/^#{1,6}\s+/gm,``).replace(/(\*{1,3}|_{1,3})/g,``).replace(/`[^`]*`/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/^[\s>*\-+\d.]+/gm,``);for(let e of t){if(J2.test(e))return`rtl`;if(Y2.test(e))return`ltr`}return`ltr`}var Z2=/^[ \t]{0,3}(`{3,}|~{3,})/,Q2=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,$2=e=>{let t=e.split(`
|
|
449
|
-
`),n=null,r=0;for(let e of t){let t
|
|
450
|
-
`);for(let e of t){let t=e.trim();if(t.length>0&&t.includes(`|`)&&
|
|
447
|
+
`)},c2=e=>{let t=!1;for(let n of e)if(n===`\\`||n===`|`){t=!0;break}if(!t)return e;let n=[];for(let t of e)t===`\\`?n.push(`\\\\`):t===`|`?n.push(`\\|`):n.push(t);return n.join(``)},l2=e=>{let{headers:t,rows:n}=e;if(t.length===0)return``;let r=Array(n.length+2),i=0,a=t.map(e=>c2(e));r[i]=`| ${a.join(` | `)} |`,i+=1;let o=Array(t.length);for(let e=0;e<t.length;e+=1)o[e]=`---`;r[i]=`| ${o.join(` | `)} |`,i+=1;for(let e of n)if(e.length<t.length){let n=Array(t.length);for(let r=0;r<t.length;r+=1)n[r]=r<e.length?c2(e[r]):``;r[i]=`| ${n.join(` | `)} |`,i+=1}else{let t=e.map(e=>c2(e));r[i]=`| ${t.join(` | `)} |`,i+=1}return r.join(`
|
|
448
|
+
`)},u2=({children:e,className:t,onCopy:n,onError:r,timeout:i=2e3})=>{let a=S0(),[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(!1),u=(0,d.useRef)(null),f=(0,d.useRef)(0),{isAnimating:p}=(0,d.useContext)(q4),m=B0(),h=async e=>{var t;if(typeof window>`u`||!((t=navigator==null?void 0:navigator.clipboard)!=null&&t.write)){r?.(Error(`Clipboard API not available`));return}try{let t=(u.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let a=a2(t),o=({csv:o2,tsv:s2,md:l2}[e]||l2)(a),c=new ClipboardItem({"text/plain":new Blob([o],{type:`text/plain`}),"text/html":new Blob([t.outerHTML],{type:`text/html`})});await navigator.clipboard.write([c]),l(!0),s(!1),n?.(e),f.current=window.setTimeout(()=>l(!1),i)}catch(e){r?.(e)}};(0,d.useEffect)(()=>{let e=e=>{let t=e.composedPath();u.current&&!t.includes(u.current)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e),window.clearTimeout(f.current)}},[]);let g=L0(),_=c?g.CheckIcon:g.CopyIcon;return(0,E.jsxs)(`div`,{className:a(`relative`),ref:u,children:[(0,E.jsx)(`button`,{className:a(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:p,onClick:()=>s(!o),title:m.copyTable,type:`button`,children:e??(0,E.jsx)(_,{height:14,width:14})}),o?(0,E.jsxs)(`div`,{className:a(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,E.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>h(`md`),title:m.copyTableAsMarkdown,type:`button`,children:m.tableFormatMarkdown}),(0,E.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>h(`csv`),title:m.copyTableAsCsv,type:`button`,children:m.tableFormatCsv}),(0,E.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>h(`tsv`),title:m.copyTableAsTsv,type:`button`,children:m.tableFormatTsv})]}):null]})},d2=({children:e,className:t,onDownload:n,onError:r})=>{let i=S0(),[a,o]=(0,d.useState)(!1),s=(0,d.useRef)(null),{isAnimating:c}=(0,d.useContext)(q4),l=B0(),u=L0(),f=e=>{try{let t=(s.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let i=a2(t),a=e===`csv`?o2(i):l2(i);b0(`table.${e===`csv`?`csv`:`md`}`,a,e===`csv`?`text/csv`:`text/markdown`),o(!1),n?.(e)}catch(e){r?.(e)}};return(0,d.useEffect)(()=>{let e=e=>{let t=e.composedPath();s.current&&!t.includes(s.current)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,E.jsxs)(`div`,{className:i(`relative`),ref:s,children:[(0,E.jsx)(`button`,{className:i(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:c,onClick:()=>o(!a),title:l.downloadTable,type:`button`,children:e??(0,E.jsx)(u.DownloadIcon,{size:14})}),a?(0,E.jsxs)(`div`,{className:i(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,E.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>f(`csv`),title:l.downloadTableAsCsv,type:`button`,children:l.tableFormatCsv}),(0,E.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>f(`markdown`),title:l.downloadTableAsMarkdown,type:`button`,children:l.tableFormatMarkdown})]}):null]})},f2=({children:e,className:t,showCopy:n=!0,showDownload:r=!0})=>{let{Maximize2Icon:i,XIcon:a}=L0(),o=S0(),[s,c]=(0,d.useState)(!1),{isAnimating:l}=(0,d.useContext)(q4),u=B0(),f=()=>{c(!0)},p=()=>{c(!1)};return(0,d.useEffect)(()=>{if(s){J0();let e=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),Y0()}}},[s]),(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:l,onClick:f,title:u.viewFullscreen,type:`button`,children:(0,E.jsx)(i,{size:14})}),s?(0,ii.createPortal)((0,E.jsx)(`div`,{"aria-label":u.viewFullscreen,"aria-modal":`true`,className:o(`fixed inset-0 z-50 flex flex-col bg-background`),"data-streamdown":`table-fullscreen`,onClick:p,onKeyDown:e=>{e.key===`Escape`&&p()},role:`dialog`,children:(0,E.jsxs)(`div`,{className:o(`flex h-full flex-col`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,E.jsxs)(`div`,{className:o(`flex items-center justify-end gap-1 p-4`),children:[n?(0,E.jsx)(u2,{}):null,r?(0,E.jsx)(d2,{}):null,(0,E.jsx)(`button`,{className:o(`rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:p,title:u.exitFullscreen,type:`button`,children:(0,E.jsx)(a,{size:20})})]}),(0,E.jsx)(`div`,{className:o(`flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10`),children:(0,E.jsx)(`table`,{className:o(`w-full border-collapse border border-border`),"data-streamdown":`table`,children:e})})]})}),document.body):null]})},p2=({children:e,className:t,showControls:n,showCopy:r=!0,showDownload:i=!0,showFullscreen:a=!0,...o})=>{let s=S0(),c=n&&r,l=n&&i,u=n&&a,d=c||l||u;return(0,E.jsxs)(`div`,{className:s(`my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2`),"data-streamdown":`table-wrapper`,children:[d?(0,E.jsxs)(`div`,{className:s(`flex items-center justify-end gap-1`),children:[c?(0,E.jsx)(u2,{}):null,l?(0,E.jsx)(d2,{}):null,u?(0,E.jsx)(f2,{showCopy:c,showDownload:l,children:e}):null]}):null,(0,E.jsx)(`div`,{className:s(`border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background`),children:(0,E.jsx)(`table`,{className:s(`w-full divide-y divide-border`,t),"data-streamdown":`table`,...o,children:e})})]})},m2=/startLine=(\d+)/,h2=/\bnoLineNumbers\b/,g2=(0,d.lazy)(()=>$1(()=>import(`./mermaid-GHXKKRXX-BNiS2a30.js`).then(e=>({default:e.Mermaid})),[])),_2=/language-([^\s]+)/;function v2(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&t!=null&&t.position))return!1;let n=e.position.start,r=t.position.start,i=e.position.end,a=t.position.end;return n?.line===r?.line&&n?.column===r?.column&&i?.line===a?.line&&i?.column===a?.column}function y2(e,t){return e.className===t.className&&v2(e.node,t.node)}var b2=(e,t)=>typeof e==`boolean`?e:e[t]!==!1,x2=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.table;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},S2=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.code;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},C2=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.mermaid;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},w2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=S0();return(0,E.jsx)(`ol`,{className:i(`list-inside list-decimal whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`ordered-list`,...r,children:e})},(e,t)=>y2(e,t));w2.displayName=`MarkdownOl`;var T2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=S0();return(0,E.jsx)(`li`,{className:i(`py-1 [&>p]:inline`,t),"data-streamdown":`list-item`,...r,children:e})},(e,t)=>e.className===t.className&&v2(e.node,t.node));T2.displayName=`MarkdownLi`;var E2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=S0();return(0,E.jsx)(`ul`,{className:i(`list-inside list-disc whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`unordered-list`,...r,children:e})},(e,t)=>y2(e,t));E2.displayName=`MarkdownUl`;var D2=(0,d.memo)(({className:e,node:t,...n})=>{let r=S0();return(0,E.jsx)(`hr`,{className:r(`my-6 border-border`,e),"data-streamdown":`horizontal-rule`,...n})},(e,t)=>y2(e,t));D2.displayName=`MarkdownHr`;var O2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=S0();return(0,E.jsx)(`span`,{className:i(`font-semibold`,t),"data-streamdown":`strong`,...r,children:e})},(e,t)=>y2(e,t));O2.displayName=`MarkdownStrong`;var k2=(0,d.memo)(({children:e,className:t,href:n,node:r,...i})=>{let a=S0(),{linkSafety:o}=(0,d.useContext)(q4),[s,c]=(0,d.useState)(!1),l=n===`streamdown:incomplete-link`,u=(0,d.useCallback)(async e=>{if(!(!(o!=null&&o.enabled&&n)||l)){if(e.preventDefault(),o.onLinkCheck&&await o.onLinkCheck(n)){window.open(n,`_blank`,`noreferrer`);return}c(!0)}},[o,n,l]),f=(0,d.useCallback)(()=>{n&&window.open(n,`_blank`,`noreferrer`)},[n]),p=(0,d.useCallback)(()=>{c(!1)},[]),m={url:n??``,isOpen:s,onClose:p,onConfirm:f};return o!=null&&o.enabled&&n?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`button`,{className:a(`wrap-anywhere appearance-none text-left font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,onClick:u,type:`button`,children:e}),o.renderModal?o.renderModal(m):(0,E.jsx)(X0,{...m})]}):(0,E.jsx)(`a`,{className:a(`wrap-anywhere font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,href:n,rel:`noreferrer`,target:`_blank`,...i,children:e})},(e,t)=>y2(e,t)&&e.href===t.href);k2.displayName=`MarkdownA`;var A2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=S0();return(0,E.jsx)(`h1`,{className:i(`mt-6 mb-2 font-semibold text-3xl`,t),"data-streamdown":`heading-1`,...r,children:e})},(e,t)=>y2(e,t));A2.displayName=`MarkdownH1`;var j2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=S0();return(0,E.jsx)(`h2`,{className:i(`mt-6 mb-2 font-semibold text-2xl`,t),"data-streamdown":`heading-2`,...r,children:e})},(e,t)=>y2(e,t));j2.displayName=`MarkdownH2`;var M2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=S0();return(0,E.jsx)(`h3`,{className:i(`mt-6 mb-2 font-semibold text-xl`,t),"data-streamdown":`heading-3`,...r,children:e})},(e,t)=>y2(e,t));M2.displayName=`MarkdownH3`;var N2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=S0();return(0,E.jsx)(`h4`,{className:i(`mt-6 mb-2 font-semibold text-lg`,t),"data-streamdown":`heading-4`,...r,children:e})},(e,t)=>y2(e,t));N2.displayName=`MarkdownH4`;var P2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=S0();return(0,E.jsx)(`h5`,{className:i(`mt-6 mb-2 font-semibold text-base`,t),"data-streamdown":`heading-5`,...r,children:e})},(e,t)=>y2(e,t));P2.displayName=`MarkdownH5`;var F2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=S0();return(0,E.jsx)(`h6`,{className:i(`mt-6 mb-2 font-semibold text-sm`,t),"data-streamdown":`heading-6`,...r,children:e})},(e,t)=>y2(e,t));F2.displayName=`MarkdownH6`;var I2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let{controls:i}=(0,d.useContext)(q4),a=b2(i,`table`),o=x2(i,`copy`),s=x2(i,`download`),c=x2(i,`fullscreen`);return(0,E.jsx)(p2,{className:t,showControls:a,showCopy:o,showDownload:s,showFullscreen:c,...r,children:e})},(e,t)=>y2(e,t));I2.displayName=`MarkdownTable`;var L2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=S0();return(0,E.jsx)(`thead`,{className:i(`bg-muted/80`,t),"data-streamdown":`table-header`,...r,children:e})},(e,t)=>y2(e,t));L2.displayName=`MarkdownThead`;var R2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=S0();return(0,E.jsx)(`tbody`,{className:i(`divide-y divide-border`,t),"data-streamdown":`table-body`,...r,children:e})},(e,t)=>y2(e,t));R2.displayName=`MarkdownTbody`;var z2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=S0();return(0,E.jsx)(`tr`,{className:i(`border-border`,t),"data-streamdown":`table-row`,...r,children:e})},(e,t)=>y2(e,t));z2.displayName=`MarkdownTr`;var B2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=S0();return(0,E.jsx)(`th`,{className:i(`whitespace-nowrap px-4 py-2 text-left font-semibold text-sm`,t),"data-streamdown":`table-header-cell`,...r,children:e})},(e,t)=>y2(e,t));B2.displayName=`MarkdownTh`;var V2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=S0();return(0,E.jsx)(`td`,{className:i(`px-4 py-2 text-sm`,t),"data-streamdown":`table-cell`,...r,children:e})},(e,t)=>y2(e,t));V2.displayName=`MarkdownTd`;var H2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=S0();return(0,E.jsx)(`blockquote`,{className:i(`my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic`,t),"data-streamdown":`blockquote`,...r,children:e})},(e,t)=>y2(e,t));H2.displayName=`MarkdownBlockquote`;var U2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=S0();return(0,E.jsx)(`sup`,{className:i(`text-sm`,t),"data-streamdown":`superscript`,...r,children:e})},(e,t)=>y2(e,t));U2.displayName=`MarkdownSup`;var W2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{let i=S0();return(0,E.jsx)(`sub`,{className:i(`text-sm`,t),"data-streamdown":`subscript`,...r,children:e})},(e,t)=>y2(e,t));W2.displayName=`MarkdownSub`;var G2=(0,d.memo)(({children:e,className:t,node:n,...r})=>{if(`data-footnotes`in r){let n=e=>{if(!(0,d.isValidElement)(e))return!1;let t=Array.isArray(e.props.children)?e.props.children:[e.props.children],n=!1,r=!1;for(let e of t)if(e){if(typeof e==`string`)e.trim()!==``&&(n=!0);else if((0,d.isValidElement)(e)){if(e.props?.[`data-footnote-backref`]!==void 0)r=!0;else{let t=Array.isArray(e.props.children)?e.props.children:[e.props.children];for(let e of t){if(typeof e==`string`&&e.trim()!==``){n=!0;break}if((0,d.isValidElement)(e)&&e.props?.[`data-footnote-backref`]===void 0){n=!0;break}}}}}return r&&!n},i=Array.isArray(e)?e.map(e=>{if(!(0,d.isValidElement)(e))return e;if(e.type===w2){let t=(Array.isArray(e.props.children)?e.props.children:[e.props.children]).filter(e=>!n(e));return t.length===0?null:{...e,props:{...e.props,children:t}}}return e}):e;return(Array.isArray(i)?i.some(e=>e!==null):i!==null)?(0,E.jsx)(`section`,{className:t,...r,children:i}):null}return(0,E.jsx)(`section`,{className:t,...r,children:e})},(e,t)=>y2(e,t));G2.displayName=`MarkdownSection`;var K2=(0,d.memo)(({node:e,className:t,children:n,...r})=>{let i=S0(),a=!(`data-block`in r),{mermaid:o,controls:s,lineNumbers:c}=(0,d.useContext)(q4),l=e2(),u=g0(),f=(t?.match(_2))?.at(1)??``,p=t2(f);if(a)return(0,E.jsx)(`code`,{className:i(`rounded bg-muted px-1.5 py-0.5 font-mono text-sm`,t),"data-streamdown":`inline-code`,...r,children:n});let m=e?.properties?.metastring,h=m?.match(m2),g=h?Number.parseInt(h[1],10):void 0,_=g!==void 0&&g>=1?g:void 0,v=!(m&&h2.test(m))&&c!==!1,y=``;if((0,d.isValidElement)(n)&&n.props&&typeof n.props==`object`&&`children`in n.props&&typeof n.props.children==`string`?y=n.props.children:typeof n==`string`&&(y=n),p){let e=p.component;return(0,E.jsx)(d.Suspense,{fallback:(0,E.jsx)(W0,{}),children:(0,E.jsx)(e,{code:y,isIncomplete:u,language:f,meta:m})})}if(f===`mermaid`&&l){let e=b2(s,`mermaid`),n=C2(s,`download`),r=C2(s,`copy`),a=C2(s,`fullscreen`),c=C2(s,`panZoom`),l=e&&(n||r||a);return(0,E.jsx)(d.Suspense,{fallback:(0,E.jsx)(W0,{}),children:(0,E.jsxs)(`div`,{className:i(`group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,t),"data-streamdown":`mermaid-block`,children:[(0,E.jsx)(`div`,{className:i(`flex h-8 items-center text-muted-foreground text-xs`),children:(0,E.jsx)(`span`,{className:i(`ml-1 font-mono lowercase`),children:`mermaid`})}),l?(0,E.jsx)(`div`,{className:i(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,E.jsxs)(`div`,{className:i(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`mermaid-block-actions`,children:[n?(0,E.jsx)(r2,{chart:y,config:o?.config}):null,r?(0,E.jsx)(V0,{code:y}):null,a?(0,E.jsx)(i2,{chart:y,config:o?.config}):null]})}):null,(0,E.jsx)(`div`,{className:i(`rounded-md border border-border bg-background`),children:(0,E.jsx)(g2,{chart:y,config:o?.config,showControls:c})})]})})}let b=b2(s,`code`),x=S2(s,`download`),S=S2(s,`copy`);return(0,E.jsx)(M0,{className:t,code:y,isIncomplete:u,language:f,lineNumbers:v,startLine:_,children:b?(0,E.jsxs)(E.Fragment,{children:[x?(0,E.jsx)(U0,{code:y,language:f}):null,S?(0,E.jsx)(V0,{}):null]}):null})},(e,t)=>e.className===t.className&&v2(e.node,t.node));K2.displayName=`MarkdownCode`;var q2=(0,d.memo)(K0,(e,t)=>e.className===t.className&&v2(e.node,t.node));q2.displayName=`MarkdownImg`;var J2=(0,d.memo)(({children:e,node:t,...n})=>{let r=(Array.isArray(e)?e:[e]).filter(e=>e!=null&&e!==``);if(r.length===1&&(0,d.isValidElement)(r[0])){let t=r[0].props.node?.tagName;if(t===`img`||t===`code`&&`data-block`in r[0].props)return(0,E.jsx)(E.Fragment,{children:e})}return(0,E.jsx)(`p`,{...n,children:e})},(e,t)=>y2(e,t));J2.displayName=`MarkdownParagraph`;var Y2={ol:w2,li:T2,ul:E2,hr:D2,strong:O2,a:k2,h1:A2,h2:j2,h3:M2,h4:N2,h5:P2,h6:F2,table:I2,thead:L2,tbody:R2,tr:z2,th:B2,td:V2,blockquote:H2,code:K2,img:q2,pre:({children:e})=>(0,d.isValidElement)(e)?(0,d.cloneElement)(e,{"data-block":`true`}):e,sup:U2,sub:W2,p:J2,section:G2},X2=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,Z2=/\p{L}/u;function Q2(e){let t=e.replace(/^#{1,6}\s+/gm,``).replace(/(\*{1,3}|_{1,3})/g,``).replace(/`[^`]*`/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/^[\s>*\-+\d.]+/gm,``);for(let e of t){if(X2.test(e))return`rtl`;if(Z2.test(e))return`ltr`}return`ltr`}var $2=/^[ \t]{0,3}(`{3,}|~{3,})/,e4=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,t4=e=>{let t=e.split(`
|
|
449
|
+
`),n=null,r=0;for(let e of t){let t=$2.exec(e);if(n===null){if(t){let e=t[1];n=e[0],r=e.length}}else if(t){let e=t[1],i=e[0],a=e.length;i===n&&a>=r&&(n=null,r=0)}}return n!==null},n4=e=>{let t=e.split(`
|
|
450
|
+
`);for(let e of t){let t=e.trim();if(t.length>0&&t.includes(`|`)&&e4.test(t))return!0}return!1},r4=()=>e=>{AO(e,`html`,(e,t,n)=>{!n||typeof t!=`number`||(n.children[t]={type:`text`,value:e.value})})},i4=[],a4={allowDangerousHtml:!0},o4=new WeakMap,s4=new class{constructor(){this.cache=new Map,this.keyCache=new WeakMap,this.maxSize=100}generateCacheKey(e){let t=this.keyCache.get(e);if(t)return t;let n=e.rehypePlugins,r=e.remarkPlugins,i=e.remarkRehypeOptions;if(!(n||r||i)){let t=`default`;return this.keyCache.set(e,t),t}let a=e=>{if(!e||e.length===0)return``;let t=``;for(let n=0;n<e.length;n+=1){let r=e[n];if(n>0&&(t+=`,`),Array.isArray(r)){let[e,n]=r;if(typeof e==`function`){let n=o4.get(e);n||(n=e.name,o4.set(e,n)),t+=n}else t+=String(e);t+=`:`,t+=JSON.stringify(n)}else if(typeof r==`function`){let e=o4.get(r);e||(e=r.name,o4.set(r,e)),t+=e}else t+=String(r)}return t},o=a(n),s=`${a(r)}::${o}::${i?JSON.stringify(i):``}`;return this.keyCache.set(e,s),s}get(e){let t=this.generateCacheKey(e),n=this.cache.get(t);return n&&(this.cache.delete(t),this.cache.set(t,n)),n}set(e,t){let n=this.generateCacheKey(e);if(this.cache.size>=this.maxSize){let e=this.cache.keys().next().value;e&&this.cache.delete(e)}this.cache.set(n,t)}clear(){this.cache.clear()}},c4=e=>{let t=l4(e),n=e.children||``;return g4(t.runSync(t.parse(n),n),e)},l4=e=>{let t=s4.get(e);if(t)return t;let n=d4(e);return s4.set(e,n),n},u4=e=>e.some(e=>Array.isArray(e)?e[0]===kV:e===kV),d4=e=>{let t=e.rehypePlugins||i4,n=e.remarkPlugins||i4,r=u4(t)?n:[...n,r4],i=e.remarkRehypeOptions?{...a4,...e.remarkRehypeOptions}:a4;return mk().use(TD).use(r).use(BO,i).use(t)},f4=e=>e,p4=(e,t,n,r)=>{n?e.children.splice(t,1):e.children[t]={type:`text`,value:r}},m4=(e,t)=>{for(let n in Cw)if(Object.hasOwn(Cw,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],i=Cw[n];(i===null||i.includes(e.tagName))&&(e.properties[n]=t(String(r||``),n,e)??void 0)}},h4=(e,t,n,r,i,a)=>{let o=!1;return r?o=!r.includes(e.tagName):i&&(o=i.includes(e.tagName)),!o&&a&&typeof t==`number`&&(o=!a(e,t,n)),o},g4=(e,t)=>{let{allowElement:n,allowedElements:r,disallowedElements:i,skipHtml:a,unwrapDisallowed:o,urlTransform:s}=t;if(n||r||i||a||s){let t=s||f4;AO(e,(e,s,c)=>{if(e.type===`raw`&&c&&typeof s==`number`)return p4(c,s,a,e.value),s;if(e.type===`element`&&(m4(e,t),h4(e,s,c,r,i,n)&&c&&typeof s==`number`))return o&&e.children?c.children.splice(s,1,...e.children):c.children.splice(s,1),s})}return tw(e,{Fragment:E.Fragment,components:t.components,ignoreInvalidStyle:!0,jsx:E.jsx,jsxs:E.jsxs,passKeys:!0,passNode:!0})},_4=/\[\^[\w-]{1,200}\](?!:)/,v4=/\[\^[\w-]{1,200}\]:/,y4=/<(\w+)[\s>]/,b4=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),x4=new Map,S4=new Map,C4=e=>{let t=e.toLowerCase(),n=x4.get(t);if(n)return n;let r=RegExp(`<${t}(?=[\\s>/])[^>]*>`,`gi`);return x4.set(t,r),r},w4=e=>{let t=e.toLowerCase(),n=S4.get(t);if(n)return n;let r=RegExp(`</${t}(?=[\\s>])[^>]*>`,`gi`);return S4.set(t,r),r},T4=(e,t)=>{if(b4.has(t.toLowerCase()))return 0;let n=e.match(C4(t));if(!n)return 0;let r=0;for(let e of n)e.trimEnd().endsWith(`/>`)||(r+=1);return r},E4=(e,t)=>{let n=e.match(w4(t));return n?n.length:0},D4=e=>{let t=0;for(let n=0;n<e.length-1;n+=1)e[n]===`$`&&e[n+1]===`$`&&(t+=1,n+=1);return t},O4=e=>{let t=_4.test(e),n=v4.test(e);if(t||n)return[e];let r=U1.lex(e,{gfm:!0}),i=[],a=[],o=!1;for(let e of r){let t=e.raw,n=i.length;if(a.length>0){i[n-1]+=t;let e=a.at(-1),r=T4(t,e),o=E4(t,e);for(let t=0;t<r;t+=1)a.push(e);for(let t=0;t<o;t+=1)a.length>0&&a.at(-1)===e&&a.pop();continue}if(e.type===`html`&&e.block){let e=t.match(y4);if(e){let n=e[1];T4(t,n)>E4(t,n)&&a.push(n)}}if(n>0&&!o){let e=i[n-1];if(D4(e)%2==1){i[n-1]=e+t;continue}}i.push(t),e.type!==`space`&&(o=e.type===`code`)}return i},k4=(e,t)=>{if(!t.length)return e;let n=e;for(let e of t){let t=RegExp(`(<${e}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${e}\\s*>)`,`gi`);n=n.replace(t,(e,t,n,r)=>{if(!n.includes(`
|
|
451
451
|
|
|
452
452
|
`))return t+n+r;let i=n.replace(/\n\n/g,`
|
|
453
453
|
<!---->
|
|
@@ -457,32 +457,32 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
457
457
|
`)?``:`
|
|
458
458
|
`)}${r}
|
|
459
459
|
|
|
460
|
-
`})}return n},O4=/([\\`*_~[\]|])/g,k4=e=>e.replace(O4,`\\$1`),A4=(e,t)=>{if(!t.length)return e;let n=e;for(let e of t){let t=RegExp(`(<${e}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${e}\\s*>)`,`gi`);n=n.replace(t,(e,t,n,r)=>t+k4(n).replace(/\n\n/g,` `)+r)}return n},j4=e=>e.type===`text`?e.value:`children`in e&&Array.isArray(e.children)?e.children.map(j4).join(``):``,M4=e=>t=>{if(!e||e.length===0)return;let n=new Set(e.map(e=>e.toLowerCase()));AO(t,`element`,e=>{if(n.has(e.tagName.toLowerCase())){let t=j4(e);e.children=t?[{type:`text`,value:t}]:[]}})},N4=()=>e=>{AO(e,`code`,e=>{e.meta&&(e.data=e.data??{},e.data.hProperties={...e.data.hProperties??{},metastring:e.meta})})},P4=/^[ \t]*<[\w!/?-]/,F4=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,I4=e=>typeof e!=`string`||e.length===0||!P4.test(e)?e:e.replace(F4,`$1`),L4={...jV,protocols:{...jV.protocols,href:[...jV.protocols?.href??[],`tel`]},attributes:{...jV.attributes,code:[...jV.attributes?.code??[],`metastring`]}},R4={raw:kV,sanitize:[JV,L4],harden:[OZ,{allowedImagePrefixes:[`*`],allowedLinkPrefixes:[`*`],allowedProtocols:[`*`],defaultOrigin:void 0,allowDataImages:!0}]},z4={gfm:[JW,{}],codeMeta:N4},B4=Object.values(R4),V4=Object.values(z4),H4={block:` ▋`,circle:` ●`},U4=[`github-light`,`github-dark`],W4={enabled:!0},G4=(0,d.createContext)({shikiTheme:U4,controls:!0,isAnimating:!1,lineNumbers:!0,mode:`streaming`,mermaid:void 0,linkSafety:W4}),K4=(0,d.memo)(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:n,index:r,isIncomplete:i,dir:a,animatePlugin:o,...s})=>{if(o){let e=o.getLastRenderCharCount();o.setPrevContentLength(e)}let c=typeof e==`string`&&n?I4(e):e,l=(0,E.jsx)(o4,{...s,children:c});return(0,E.jsx)(p0.Provider,{value:i,children:a?(0,E.jsx)(`div`,{dir:a,style:{display:`contents`},children:l}):l})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete||e.dir!==t.dir)return!1;if(e.components!==t.components){let n=Object.keys(e.components||{}),r=Object.keys(t.components||{});if(n.length!==r.length||n.some(n=>e.components?.[n]!==t.components?.[n]))return!1}return e.rehypePlugins===t.rehypePlugins&&e.remarkPlugins===t.remarkPlugins});K4.displayName=`Block`;var q4=(0,d.memo)(({children:e,mode:t=`streaming`,dir:n,parseIncompleteMarkdown:r=!0,normalizeHtmlIndentation:i=!1,components:a,rehypePlugins:o=B4,remarkPlugins:s=V4,className:c,shikiTheme:l=U4,mermaid:u,controls:f=!0,isAnimating:p=!1,animated:m,BlockComponent:h=K4,parseMarkdownIntoBlocksFn:g=E4,caret:_,plugins:v,remend:y,linkSafety:b=W4,lineNumbers:x=!0,allowedTags:S,literalTagContent:C,translations:w,icons:T,prefix:D,onAnimationStart:O,onAnimationEnd:k,...A})=>{let j=(0,d.useId)(),[M,N]=(0,d.useTransition)(),P=(0,d.useMemo)(()=>_0(D),[D]),ee=(0,d.useRef)(null),F=(0,d.useRef)(O),te=(0,d.useRef)(k);F.current=O,te.current=k,(0,d.useEffect)(()=>{var e,n,r;if(t===`static`)return;let i=ee.current;if(ee.current=p,i===null){p&&((e=F.current)==null||e.call(F));return}p&&!i?(n=F.current)==null||n.call(F):!p&&i&&((r=te.current)==null||r.call(te))},[p,t]);let ne=(0,d.useMemo)(()=>S?Object.keys(S):[],[S]),re=(0,d.useMemo)(()=>{if(typeof e!=`string`)return``;let n=t===`streaming`&&r?_$(e,y):e;return C&&C.length>0&&(n=A4(n,C)),ne.length>0&&(n=D4(n,ne)),n},[e,t,r,y,ne,C]),ie=(0,d.useMemo)(()=>g(re),[re,g]),[ae,oe]=(0,d.useState)(ie);(0,d.useEffect)(()=>{t===`streaming`&&!ce?N(()=>{oe(ie)}):oe(ie)},[ie,t]);let I=t===`streaming`?ae:ie,L=(0,d.useMemo)(()=>n===`auto`?I.map(X2):void 0,[I,n]),se=(0,d.useMemo)(()=>I.map((e,t)=>`${j}-${t}`),[I.length,j]),R=(0,d.useMemo)(()=>m===!0?`true`:m?JSON.stringify(m):``,[m]),ce=(0,d.useMemo)(()=>R?R===`true`?f0():f0(m):null,[R]),le=(0,d.useMemo)(()=>({shikiTheme:(v?.code)?.getThemes()??l,controls:f,isAnimating:p,lineNumbers:x,mode:t,mermaid:u,linkSafety:b}),[l,f,p,x,t,u,b,v?.code]),ue=(0,d.useMemo)(()=>w?JSON.stringify(w):``,[w]),de=(0,d.useMemo)(()=>({...I0,...w}),[ue]),fe=(0,d.useMemo)(()=>{let{inlineCode:e,...t}=a??{},n={...q2,...t};if(e){let t=n.code;n.code=n=>`data-block`in n?t?(0,d.createElement)(t,n):null:(0,d.createElement)(e,n)}return n},[a]),pe=(0,d.useMemo)(()=>{let e=[];return v!=null&&v.cjk&&(e=[...e,...v.cjk.remarkPluginsBefore]),e=[...e,...s],v!=null&&v.cjk&&(e=[...e,...v.cjk.remarkPluginsAfter]),v!=null&&v.math&&(e=[...e,v.math.remarkPlugin]),e},[s,v?.math,v?.cjk]),me=(0,d.useMemo)(()=>{let e=o;if(S&&Object.keys(S).length>0&&o===B4){let t={...L4,tagNames:[...L4.tagNames??[],...Object.keys(S)],attributes:{...L4.attributes,...S}};e=[R4.raw,[JV,t],R4.harden]}return C&&C.length>0&&(e=[...e,[M4,C]]),v!=null&&v.math&&(e=[...e,v.math.rehypePlugin]),ce&&p&&(e=[...e,ce.rehypePlugin]),e},[o,v?.math,ce,p,S,C]),he=(0,d.useMemo)(()=>{if(!p||I.length===0)return!1;let e=I.at(-1);return $2(e)||e4(e)},[p,I]),ge=(0,d.useMemo)(()=>_&&p&&!he?{"--streamdown-caret":`"${H4[_]}"`}:void 0,[_,p,he]);return t===`static`?(0,E.jsx)(L0.Provider,{value:de,children:(0,E.jsx)(Y0.Provider,{value:v??null,children:(0,E.jsx)(G4.Provider,{value:le,children:(0,E.jsx)(P0,{icons:T,children:(0,E.jsx)(y0.Provider,{value:P,children:(0,E.jsx)(`div`,{className:P(`space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,c),dir:n===`auto`?X2(re):n,children:(0,E.jsx)(o4,{components:fe,rehypePlugins:me,remarkPlugins:pe,...A,children:re})})})})})})}):(0,E.jsx)(L0.Provider,{value:de,children:(0,E.jsx)(Y0.Provider,{value:v??null,children:(0,E.jsx)(G4.Provider,{value:le,children:(0,E.jsx)(P0,{icons:T,children:(0,E.jsx)(y0.Provider,{value:P,children:(0,E.jsxs)(`div`,{className:P(`space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,_&&!he?`[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]`:null,c),style:ge,children:[I.length===0&&_&&p&&(0,E.jsx)(`span`,{}),I.map((e,t)=>{let a=t===I.length-1,o=p&&a&&$2(e);return(0,E.jsx)(h,{animatePlugin:ce,components:fe,content:e,dir:L?.[t]??(n===`auto`?void 0:n),index:t,isIncomplete:o,rehypePlugins:me,remarkPlugins:pe,shouldNormalizeHtmlIndentation:i,shouldParseIncompleteMarkdown:r,...A},se[t])})]})})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.animated===t.animated&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety&&e.lineNumbers===t.lineNumbers&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);q4.displayName=`Streamdown`;var J4=({children:e,className:t,minZoom:n=.5,maxZoom:r=3,zoomStep:i=.1,showControls:a=!0,initialZoom:o=1,fullscreen:s=!1})=>{let{RotateCcwIcon:c,ZoomInIcon:l,ZoomOutIcon:u}=F0(),f=b0(),p=(0,d.useRef)(null),m=(0,d.useRef)(null),[h,g]=(0,d.useState)(o),[_,v]=(0,d.useState)({x:0,y:0}),[y,b]=(0,d.useState)(!1),[x,S]=(0,d.useState)({x:0,y:0}),[C,w]=(0,d.useState)({x:0,y:0}),T=(0,d.useCallback)(e=>{g(t=>Math.max(n,Math.min(r,t+e)))},[n,r]),D=(0,d.useCallback)(()=>{T(i)},[T,i]),O=(0,d.useCallback)(()=>{T(-i)},[T,i]),k=(0,d.useCallback)(()=>{g(o),v({x:0,y:0})},[o]),A=(0,d.useCallback)(e=>{e.preventDefault();let t=e.deltaY>0?-i:i;T(t)},[T,i]),j=(0,d.useCallback)(e=>{if(e.button!==0||e.isPrimary===!1)return;b(!0),S({x:e.clientX,y:e.clientY}),w(_);let t=e.currentTarget;t instanceof HTMLElement&&t.setPointerCapture(e.pointerId)},[_]),M=(0,d.useCallback)(e=>{if(!y)return;e.preventDefault();let t=e.clientX-x.x,n=e.clientY-x.y;v({x:C.x+t,y:C.y+n})},[y,x,C]),N=(0,d.useCallback)(e=>{b(!1);let t=e.currentTarget;t instanceof HTMLElement&&t.releasePointerCapture(e.pointerId)},[]);return(0,d.useEffect)(()=>{let e=p.current;if(e)return e.addEventListener(`wheel`,A,{passive:!1}),()=>{e.removeEventListener(`wheel`,A)}},[A]),(0,d.useEffect)(()=>{let e=m.current;if(e&&y)return document.body.style.userSelect=`none`,e.addEventListener(`pointermove`,M,{passive:!1}),e.addEventListener(`pointerup`,N),e.addEventListener(`pointercancel`,N),()=>{document.body.style.userSelect=``,e.removeEventListener(`pointermove`,M),e.removeEventListener(`pointerup`,N),e.removeEventListener(`pointercancel`,N)}},[y,M,N]),(0,E.jsxs)(`div`,{className:f(`relative flex flex-col`,s?`h-full w-full`:`min-h-28 w-full`,t),ref:p,style:{cursor:y?`grabbing`:`grab`},children:[a?(0,E.jsxs)(`div`,{className:f(`absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm`,s?`bottom-4 left-4`:`bottom-2 left-2`),children:[(0,E.jsx)(`button`,{className:f(`flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`),disabled:h>=r,onClick:D,title:`Zoom in`,type:`button`,children:(0,E.jsx)(l,{size:16})}),(0,E.jsx)(`button`,{className:f(`flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`),disabled:h<=n,onClick:O,title:`Zoom out`,type:`button`,children:(0,E.jsx)(u,{size:16})}),(0,E.jsx)(`button`,{className:f(`flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`),onClick:k,title:`Reset zoom and pan`,type:`button`,children:(0,E.jsx)(c,{size:16})})]}):null,(0,E.jsx)(`div`,{className:f(`flex-1 origin-center transition-transform duration-150 ease-out`,s?`flex h-full w-full items-center justify-center`:`flex w-full items-center justify-center`),onPointerDown:j,ref:m,role:`application`,style:{transform:`translate(${_.x}px, ${_.y}px) scale(${h})`,transformOrigin:`center center`,touchAction:`none`,willChange:`transform`},children:e})]})},Y4=({chart:e,className:t,config:n,fullscreen:r=!1,showControls:i=!0})=>{let a=b0(),[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(!1),[u,f]=(0,d.useState)(``),[p,m]=(0,d.useState)(``),[h,g]=(0,d.useState)(0),{mermaid:_}=(0,d.useContext)(G4),v=Q0(),y=_?.errorComponent,{shouldRender:b,containerRef:x}=t0({immediate:r});if((0,d.useEffect)(()=>{if(b){if(!v){s(`Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.`);return}(async()=>{try{s(null),l(!0);let t=v.getMermaid(n),r=e.split(``).reduce((e,t)=>(e<<5)-e+t.charCodeAt(0)|0,0),i=`mermaid-${Math.abs(r)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:a}=await t.render(i,e);f(a),m(a)}catch(e){if(!(p||u)){let t=e instanceof Error?e.message:`Failed to render Mermaid chart`;s(t)}}finally{l(!1)}})()}},[e,n,h,b,v]),!(b||u||p))return(0,E.jsx)(`div`,{className:a(`my-4 min-h-[200px]`,t),ref:x});if(c&&!u&&!p)return(0,E.jsx)(`div`,{className:a(`my-4 flex justify-center p-4`,t),ref:x,children:(0,E.jsxs)(`div`,{className:a(`flex items-center space-x-2 text-muted-foreground`),children:[(0,E.jsx)(`div`,{className:a(`h-4 w-4 animate-spin rounded-full border-current border-b-2`)}),(0,E.jsx)(`span`,{className:a(`text-sm`),children:`Loading diagram...`})]})});if(o&&!u&&!p)return y?(0,E.jsx)(`div`,{ref:x,children:(0,E.jsx)(y,{chart:e,error:o,retry:()=>g(e=>e+1)})}):(0,E.jsxs)(`div`,{className:a(`rounded-md bg-red-50 p-4`,t),ref:x,children:[(0,E.jsxs)(`p`,{className:a(`font-mono text-red-700 text-sm`),children:[`Mermaid Error: `,o]}),(0,E.jsxs)(`details`,{className:a(`mt-2`),children:[(0,E.jsx)(`summary`,{className:a(`cursor-pointer text-red-600 text-xs`),children:`Show Code`}),(0,E.jsx)(`pre`,{className:a(`mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs`),children:e})]})]});let S=u||p;return(0,E.jsx)(`div`,{className:a(`size-full`,t),"data-streamdown":`mermaid`,ref:x,children:(0,E.jsx)(J4,{className:a(r?`size-full overflow-hidden`:`overflow-hidden`,t),fullscreen:r,maxZoom:3,minZoom:.5,showControls:i,zoomStep:.1,children:(0,E.jsx)(`div`,{"aria-label":`Mermaid chart`,className:a(`flex justify-center`,r?`size-full items-center`:null),dangerouslySetInnerHTML:{__html:S},role:`img`})})})},X4=1e5,Z4=5e3;function Q4(e,t=X4){if(e.length<=t)return e;let n=e.lastIndexOf(`
|
|
461
|
-
`,t-1);return n!==-1&&t-n
|
|
462
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function
|
|
463
|
-
`)})}function
|
|
464
|
-
`),style:o,startingLineNumber:s}))}function
|
|
460
|
+
`})}return n},A4=/([\\`*_~[\]|])/g,j4=e=>e.replace(A4,`\\$1`),M4=(e,t)=>{if(!t.length)return e;let n=e;for(let e of t){let t=RegExp(`(<${e}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${e}\\s*>)`,`gi`);n=n.replace(t,(e,t,n,r)=>t+j4(n).replace(/\n\n/g,` `)+r)}return n},N4=e=>e.type===`text`?e.value:`children`in e&&Array.isArray(e.children)?e.children.map(N4).join(``):``,P4=e=>t=>{if(!e||e.length===0)return;let n=new Set(e.map(e=>e.toLowerCase()));AO(t,`element`,e=>{if(n.has(e.tagName.toLowerCase())){let t=N4(e);e.children=t?[{type:`text`,value:t}]:[]}})},F4=()=>e=>{AO(e,`code`,e=>{e.meta&&(e.data=e.data??{},e.data.hProperties={...e.data.hProperties??{},metastring:e.meta})})},I4=/^[ \t]*<[\w!/?-]/,L4=/(^|\n)[ \t]{4,}(?=<[\w!/?-])/g,R4=e=>typeof e!=`string`||e.length===0||!I4.test(e)?e:e.replace(L4,`$1`),z4={...jV,protocols:{...jV.protocols,href:[...jV.protocols?.href??[],`tel`]},attributes:{...jV.attributes,code:[...jV.attributes?.code??[],`metastring`]}},B4={raw:kV,sanitize:[JV,z4],harden:[AZ,{allowedImagePrefixes:[`*`],allowedLinkPrefixes:[`*`],allowedProtocols:[`*`],defaultOrigin:void 0,allowDataImages:!0}]},V4={gfm:[JW,{}],codeMeta:F4},H4=Object.values(B4),U4=Object.values(V4),W4={block:` ▋`,circle:` ●`},G4=[`github-light`,`github-dark`],K4={enabled:!0},q4=(0,d.createContext)({shikiTheme:G4,controls:!0,isAnimating:!1,lineNumbers:!0,mode:`streaming`,mermaid:void 0,linkSafety:K4}),J4=(0,d.memo)(({content:e,shouldParseIncompleteMarkdown:t,shouldNormalizeHtmlIndentation:n,index:r,isIncomplete:i,dir:a,animatePlugin:o,...s})=>{if(o){let e=o.getLastRenderCharCount();o.setPrevContentLength(e)}let c=typeof e==`string`&&n?R4(e):e,l=(0,E.jsx)(c4,{...s,children:c});return(0,E.jsx)(h0.Provider,{value:i,children:a?(0,E.jsx)(`div`,{dir:a,style:{display:`contents`},children:l}):l})},(e,t)=>{if(e.content!==t.content||e.shouldNormalizeHtmlIndentation!==t.shouldNormalizeHtmlIndentation||e.index!==t.index||e.isIncomplete!==t.isIncomplete||e.dir!==t.dir)return!1;if(e.components!==t.components){let n=Object.keys(e.components||{}),r=Object.keys(t.components||{});if(n.length!==r.length||n.some(n=>e.components?.[n]!==t.components?.[n]))return!1}return e.rehypePlugins===t.rehypePlugins&&e.remarkPlugins===t.remarkPlugins});J4.displayName=`Block`;var Y4=(0,d.memo)(({children:e,mode:t=`streaming`,dir:n,parseIncompleteMarkdown:r=!0,normalizeHtmlIndentation:i=!1,components:a,rehypePlugins:o=H4,remarkPlugins:s=U4,className:c,shikiTheme:l=G4,mermaid:u,controls:f=!0,isAnimating:p=!1,animated:m,BlockComponent:h=J4,parseMarkdownIntoBlocksFn:g=O4,caret:_,plugins:v,remend:y,linkSafety:b=K4,lineNumbers:x=!0,allowedTags:S,literalTagContent:C,translations:w,icons:T,prefix:D,onAnimationStart:O,onAnimationEnd:k,...A})=>{let j=(0,d.useId)(),[M,N]=(0,d.useTransition)(),P=(0,d.useMemo)(()=>y0(D),[D]),ee=(0,d.useRef)(null),F=(0,d.useRef)(O),te=(0,d.useRef)(k);F.current=O,te.current=k,(0,d.useEffect)(()=>{var e,n,r;if(t===`static`)return;let i=ee.current;if(ee.current=p,i===null){p&&((e=F.current)==null||e.call(F));return}p&&!i?(n=F.current)==null||n.call(F):!p&&i&&((r=te.current)==null||r.call(te))},[p,t]);let ne=(0,d.useMemo)(()=>S?Object.keys(S):[],[S]),re=(0,d.useMemo)(()=>{if(typeof e!=`string`)return``;let n=t===`streaming`&&r?y$(e,y):e;return C&&C.length>0&&(n=M4(n,C)),ne.length>0&&(n=k4(n,ne)),n},[e,t,r,y,ne,C]),ie=(0,d.useMemo)(()=>g(re),[re,g]),[ae,oe]=(0,d.useState)(ie);(0,d.useEffect)(()=>{t===`streaming`&&!ce?N(()=>{oe(ie)}):oe(ie)},[ie,t]);let I=t===`streaming`?ae:ie,L=(0,d.useMemo)(()=>n===`auto`?I.map(Q2):void 0,[I,n]),se=(0,d.useMemo)(()=>I.map((e,t)=>`${j}-${t}`),[I.length,j]),R=(0,d.useMemo)(()=>m===!0?`true`:m?JSON.stringify(m):``,[m]),ce=(0,d.useMemo)(()=>R?R===`true`?m0():m0(m):null,[R]),le=(0,d.useMemo)(()=>({shikiTheme:(v?.code)?.getThemes()??l,controls:f,isAnimating:p,lineNumbers:x,mode:t,mermaid:u,linkSafety:b}),[l,f,p,x,t,u,b,v?.code]),ue=(0,d.useMemo)(()=>w?JSON.stringify(w):``,[w]),de=(0,d.useMemo)(()=>({...R0,...w}),[ue]),fe=(0,d.useMemo)(()=>{let{inlineCode:e,...t}=a??{},n={...Y2,...t};if(e){let t=n.code;n.code=n=>`data-block`in n?t?(0,d.createElement)(t,n):null:(0,d.createElement)(e,n)}return n},[a]),pe=(0,d.useMemo)(()=>{let e=[];return v!=null&&v.cjk&&(e=[...e,...v.cjk.remarkPluginsBefore]),e=[...e,...s],v!=null&&v.cjk&&(e=[...e,...v.cjk.remarkPluginsAfter]),v!=null&&v.math&&(e=[...e,v.math.remarkPlugin]),e},[s,v?.math,v?.cjk]),me=(0,d.useMemo)(()=>{let e=o;if(S&&Object.keys(S).length>0&&o===H4){let t={...z4,tagNames:[...z4.tagNames??[],...Object.keys(S)],attributes:{...z4.attributes,...S}};e=[B4.raw,[JV,t],B4.harden]}return C&&C.length>0&&(e=[...e,[P4,C]]),v!=null&&v.math&&(e=[...e,v.math.rehypePlugin]),ce&&p&&(e=[...e,ce.rehypePlugin]),e},[o,v?.math,ce,p,S,C]),he=(0,d.useMemo)(()=>{if(!p||I.length===0)return!1;let e=I.at(-1);return t4(e)||n4(e)},[p,I]),ge=(0,d.useMemo)(()=>_&&p&&!he?{"--streamdown-caret":`"${W4[_]}"`}:void 0,[_,p,he]);return t===`static`?(0,E.jsx)(z0.Provider,{value:de,children:(0,E.jsx)(Z0.Provider,{value:v??null,children:(0,E.jsx)(q4.Provider,{value:le,children:(0,E.jsx)(I0,{icons:T,children:(0,E.jsx)(x0.Provider,{value:P,children:(0,E.jsx)(`div`,{className:P(`space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,c),dir:n===`auto`?Q2(re):n,children:(0,E.jsx)(c4,{components:fe,rehypePlugins:me,remarkPlugins:pe,...A,children:re})})})})})})}):(0,E.jsx)(z0.Provider,{value:de,children:(0,E.jsx)(Z0.Provider,{value:v??null,children:(0,E.jsx)(q4.Provider,{value:le,children:(0,E.jsx)(I0,{icons:T,children:(0,E.jsx)(x0.Provider,{value:P,children:(0,E.jsxs)(`div`,{className:P(`space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,_&&!he?`[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]`:null,c),style:ge,children:[I.length===0&&_&&p&&(0,E.jsx)(`span`,{}),I.map((e,t)=>{let a=t===I.length-1,o=p&&a&&t4(e);return(0,E.jsx)(h,{animatePlugin:ce,components:fe,content:e,dir:L?.[t]??(n===`auto`?void 0:n),index:t,isIncomplete:o,rehypePlugins:me,remarkPlugins:pe,shouldNormalizeHtmlIndentation:i,shouldParseIncompleteMarkdown:r,...A},se[t])})]})})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating&&e.animated===t.animated&&e.mode===t.mode&&e.plugins===t.plugins&&e.className===t.className&&e.linkSafety===t.linkSafety&&e.lineNumbers===t.lineNumbers&&e.normalizeHtmlIndentation===t.normalizeHtmlIndentation&&e.literalTagContent===t.literalTagContent&&JSON.stringify(e.translations)===JSON.stringify(t.translations)&&e.prefix===t.prefix&&e.dir===t.dir);Y4.displayName=`Streamdown`;var X4=({children:e,className:t,minZoom:n=.5,maxZoom:r=3,zoomStep:i=.1,showControls:a=!0,initialZoom:o=1,fullscreen:s=!1})=>{let{RotateCcwIcon:c,ZoomInIcon:l,ZoomOutIcon:u}=L0(),f=S0(),p=(0,d.useRef)(null),m=(0,d.useRef)(null),[h,g]=(0,d.useState)(o),[_,v]=(0,d.useState)({x:0,y:0}),[y,b]=(0,d.useState)(!1),[x,S]=(0,d.useState)({x:0,y:0}),[C,w]=(0,d.useState)({x:0,y:0}),T=(0,d.useCallback)(e=>{g(t=>Math.max(n,Math.min(r,t+e)))},[n,r]),D=(0,d.useCallback)(()=>{T(i)},[T,i]),O=(0,d.useCallback)(()=>{T(-i)},[T,i]),k=(0,d.useCallback)(()=>{g(o),v({x:0,y:0})},[o]),A=(0,d.useCallback)(e=>{e.preventDefault();let t=e.deltaY>0?-i:i;T(t)},[T,i]),j=(0,d.useCallback)(e=>{if(e.button!==0||e.isPrimary===!1)return;b(!0),S({x:e.clientX,y:e.clientY}),w(_);let t=e.currentTarget;t instanceof HTMLElement&&t.setPointerCapture(e.pointerId)},[_]),M=(0,d.useCallback)(e=>{if(!y)return;e.preventDefault();let t=e.clientX-x.x,n=e.clientY-x.y;v({x:C.x+t,y:C.y+n})},[y,x,C]),N=(0,d.useCallback)(e=>{b(!1);let t=e.currentTarget;t instanceof HTMLElement&&t.releasePointerCapture(e.pointerId)},[]);return(0,d.useEffect)(()=>{let e=p.current;if(e)return e.addEventListener(`wheel`,A,{passive:!1}),()=>{e.removeEventListener(`wheel`,A)}},[A]),(0,d.useEffect)(()=>{let e=m.current;if(e&&y)return document.body.style.userSelect=`none`,e.addEventListener(`pointermove`,M,{passive:!1}),e.addEventListener(`pointerup`,N),e.addEventListener(`pointercancel`,N),()=>{document.body.style.userSelect=``,e.removeEventListener(`pointermove`,M),e.removeEventListener(`pointerup`,N),e.removeEventListener(`pointercancel`,N)}},[y,M,N]),(0,E.jsxs)(`div`,{className:f(`relative flex flex-col`,s?`h-full w-full`:`min-h-28 w-full`,t),ref:p,style:{cursor:y?`grabbing`:`grab`},children:[a?(0,E.jsxs)(`div`,{className:f(`absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm`,s?`bottom-4 left-4`:`bottom-2 left-2`),children:[(0,E.jsx)(`button`,{className:f(`flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`),disabled:h>=r,onClick:D,title:`Zoom in`,type:`button`,children:(0,E.jsx)(l,{size:16})}),(0,E.jsx)(`button`,{className:f(`flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`),disabled:h<=n,onClick:O,title:`Zoom out`,type:`button`,children:(0,E.jsx)(u,{size:16})}),(0,E.jsx)(`button`,{className:f(`flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`),onClick:k,title:`Reset zoom and pan`,type:`button`,children:(0,E.jsx)(c,{size:16})})]}):null,(0,E.jsx)(`div`,{className:f(`flex-1 origin-center transition-transform duration-150 ease-out`,s?`flex h-full w-full items-center justify-center`:`flex w-full items-center justify-center`),onPointerDown:j,ref:m,role:`application`,style:{transform:`translate(${_.x}px, ${_.y}px) scale(${h})`,transformOrigin:`center center`,touchAction:`none`,willChange:`transform`},children:e})]})},Z4=({chart:e,className:t,config:n,fullscreen:r=!1,showControls:i=!0})=>{let a=S0(),[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(!1),[u,f]=(0,d.useState)(``),[p,m]=(0,d.useState)(``),[h,g]=(0,d.useState)(0),{mermaid:_}=(0,d.useContext)(q4),v=e2(),y=_?.errorComponent,{shouldRender:b,containerRef:x}=r0({immediate:r});if((0,d.useEffect)(()=>{if(b){if(!v){s(`Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.`);return}(async()=>{try{s(null),l(!0);let t=v.getMermaid(n),r=e.split(``).reduce((e,t)=>(e<<5)-e+t.charCodeAt(0)|0,0),i=`mermaid-${Math.abs(r)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:a}=await t.render(i,e);f(a),m(a)}catch(e){if(!(p||u)){let t=e instanceof Error?e.message:`Failed to render Mermaid chart`;s(t)}}finally{l(!1)}})()}},[e,n,h,b,v]),!(b||u||p))return(0,E.jsx)(`div`,{className:a(`my-4 min-h-[200px]`,t),ref:x});if(c&&!u&&!p)return(0,E.jsx)(`div`,{className:a(`my-4 flex justify-center p-4`,t),ref:x,children:(0,E.jsxs)(`div`,{className:a(`flex items-center space-x-2 text-muted-foreground`),children:[(0,E.jsx)(`div`,{className:a(`h-4 w-4 animate-spin rounded-full border-current border-b-2`)}),(0,E.jsx)(`span`,{className:a(`text-sm`),children:`Loading diagram...`})]})});if(o&&!u&&!p)return y?(0,E.jsx)(`div`,{ref:x,children:(0,E.jsx)(y,{chart:e,error:o,retry:()=>g(e=>e+1)})}):(0,E.jsxs)(`div`,{className:a(`rounded-md bg-red-50 p-4`,t),ref:x,children:[(0,E.jsxs)(`p`,{className:a(`font-mono text-red-700 text-sm`),children:[`Mermaid Error: `,o]}),(0,E.jsxs)(`details`,{className:a(`mt-2`),children:[(0,E.jsx)(`summary`,{className:a(`cursor-pointer text-red-600 text-xs`),children:`Show Code`}),(0,E.jsx)(`pre`,{className:a(`mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs`),children:e})]})]});let S=u||p;return(0,E.jsx)(`div`,{className:a(`size-full`,t),"data-streamdown":`mermaid`,ref:x,children:(0,E.jsx)(X4,{className:a(r?`size-full overflow-hidden`:`overflow-hidden`,t),fullscreen:r,maxZoom:3,minZoom:.5,showControls:i,zoomStep:.1,children:(0,E.jsx)(`div`,{"aria-label":`Mermaid chart`,className:a(`flex justify-center`,r?`size-full items-center`:null),dangerouslySetInnerHTML:{__html:S},role:`img`})})})},Q4=1e5,$4=5e3;function e3(e,t=Q4){if(e.length<=t)return e;let n=e.lastIndexOf(`
|
|
461
|
+
`,t-1);return n!==-1&&t-n<=$4?e.slice(0,n+1):e.slice(0,t)}function t3(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function n3(e,t){if(e==null)return{};var n,r,i=t3(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function r3(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function i3(e){if(Array.isArray(e))return r3(e)}function a3(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function o3(e,t){if(e){if(typeof e==`string`)return r3(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r3(e,t):void 0}}function s3(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
462
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function c3(e){return i3(e)||a3(e)||o3(e)||s3()}function l3(e){"@babel/helpers - typeof";return l3=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},l3(e)}function u3(e,t){if(l3(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(l3(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function d3(e){var t=u3(e,`string`);return l3(t)==`symbol`?t:t+``}function f3(e,t,n){return(t=d3(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p3(){return p3=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},p3.apply(null,arguments)}function m3(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function h3(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?m3(Object(n),!0).forEach(function(t){f3(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):m3(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function g3(e){var t=e.length;if(t===0||t===1)return e;if(t===2)return[e[0],e[1],`${e[0]}.${e[1]}`,`${e[1]}.${e[0]}`];if(t===3)return[e[0],e[1],e[2],`${e[0]}.${e[1]}`,`${e[0]}.${e[2]}`,`${e[1]}.${e[0]}`,`${e[1]}.${e[2]}`,`${e[2]}.${e[0]}`,`${e[2]}.${e[1]}`,`${e[0]}.${e[1]}.${e[2]}`,`${e[0]}.${e[2]}.${e[1]}`,`${e[1]}.${e[0]}.${e[2]}`,`${e[1]}.${e[2]}.${e[0]}`,`${e[2]}.${e[0]}.${e[1]}`,`${e[2]}.${e[1]}.${e[0]}`];if(t>=4)return[e[0],e[1],e[2],e[3],`${e[0]}.${e[1]}`,`${e[0]}.${e[2]}`,`${e[0]}.${e[3]}`,`${e[1]}.${e[0]}`,`${e[1]}.${e[2]}`,`${e[1]}.${e[3]}`,`${e[2]}.${e[0]}`,`${e[2]}.${e[1]}`,`${e[2]}.${e[3]}`,`${e[3]}.${e[0]}`,`${e[3]}.${e[1]}`,`${e[3]}.${e[2]}`,`${e[0]}.${e[1]}.${e[2]}`,`${e[0]}.${e[1]}.${e[3]}`,`${e[0]}.${e[2]}.${e[1]}`,`${e[0]}.${e[2]}.${e[3]}`,`${e[0]}.${e[3]}.${e[1]}`,`${e[0]}.${e[3]}.${e[2]}`,`${e[1]}.${e[0]}.${e[2]}`,`${e[1]}.${e[0]}.${e[3]}`,`${e[1]}.${e[2]}.${e[0]}`,`${e[1]}.${e[2]}.${e[3]}`,`${e[1]}.${e[3]}.${e[0]}`,`${e[1]}.${e[3]}.${e[2]}`,`${e[2]}.${e[0]}.${e[1]}`,`${e[2]}.${e[0]}.${e[3]}`,`${e[2]}.${e[1]}.${e[0]}`,`${e[2]}.${e[1]}.${e[3]}`,`${e[2]}.${e[3]}.${e[0]}`,`${e[2]}.${e[3]}.${e[1]}`,`${e[3]}.${e[0]}.${e[1]}`,`${e[3]}.${e[0]}.${e[2]}`,`${e[3]}.${e[1]}.${e[0]}`,`${e[3]}.${e[1]}.${e[2]}`,`${e[3]}.${e[2]}.${e[0]}`,`${e[3]}.${e[2]}.${e[1]}`,`${e[0]}.${e[1]}.${e[2]}.${e[3]}`,`${e[0]}.${e[1]}.${e[3]}.${e[2]}`,`${e[0]}.${e[2]}.${e[1]}.${e[3]}`,`${e[0]}.${e[2]}.${e[3]}.${e[1]}`,`${e[0]}.${e[3]}.${e[1]}.${e[2]}`,`${e[0]}.${e[3]}.${e[2]}.${e[1]}`,`${e[1]}.${e[0]}.${e[2]}.${e[3]}`,`${e[1]}.${e[0]}.${e[3]}.${e[2]}`,`${e[1]}.${e[2]}.${e[0]}.${e[3]}`,`${e[1]}.${e[2]}.${e[3]}.${e[0]}`,`${e[1]}.${e[3]}.${e[0]}.${e[2]}`,`${e[1]}.${e[3]}.${e[2]}.${e[0]}`,`${e[2]}.${e[0]}.${e[1]}.${e[3]}`,`${e[2]}.${e[0]}.${e[3]}.${e[1]}`,`${e[2]}.${e[1]}.${e[0]}.${e[3]}`,`${e[2]}.${e[1]}.${e[3]}.${e[0]}`,`${e[2]}.${e[3]}.${e[0]}.${e[1]}`,`${e[2]}.${e[3]}.${e[1]}.${e[0]}`,`${e[3]}.${e[0]}.${e[1]}.${e[2]}`,`${e[3]}.${e[0]}.${e[2]}.${e[1]}`,`${e[3]}.${e[1]}.${e[0]}.${e[2]}`,`${e[3]}.${e[1]}.${e[2]}.${e[0]}`,`${e[3]}.${e[2]}.${e[0]}.${e[1]}`,`${e[3]}.${e[2]}.${e[1]}.${e[0]}`]}var _3={};function v3(e){if(e.length===0||e.length===1)return e;var t=e.join(`.`);return _3[t]||(_3[t]=g3(e)),_3[t]}function y3(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;return v3(e.filter(function(e){return e!==`token`})).reduce(function(e,t){return h3(h3({},e),n[t])},t)}function b3(e){return e.join(` `)}function x3(e,t){var n=0;return function(r){return n+=1,r.map(function(r,i){return S3({node:r,stylesheet:e,useInlineStyles:t,key:`code-segment-${n}-${i}`})})}}function S3(e){var t=e.node,n=e.stylesheet,r=e.style,i=r===void 0?{}:r,a=e.useInlineStyles,o=e.key,s=t.properties,c=t.type,l=t.tagName,u=t.value;if(c===`text`)return u;if(l){var f=x3(n,a),p;if(!a)p=h3(h3({},s),{},{className:b3(s.className)});else{var m=Object.keys(n).reduce(function(e,t){return t.split(`.`).forEach(function(t){e.includes(t)||e.push(t)}),e},[]),h=s.className&&s.className.includes(`token`)?[`token`]:[],g=s.className&&h.concat(s.className.filter(function(e){return!m.includes(e)}));p=h3(h3({},s),{},{className:b3(g)||void 0,style:y3(s.className,Object.assign({},s.style,i),n)})}var _=f(t.children);return d.createElement(l,p3({key:o},p),_)}}var C3=(function(e,t){return e.listLanguages().indexOf(t)!==-1}),w3=[`language`,`children`,`style`,`customStyle`,`codeTagProps`,`useInlineStyles`,`showLineNumbers`,`showInlineLineNumbers`,`startingLineNumber`,`lineNumberContainerStyle`,`lineNumberStyle`,`wrapLines`,`wrapLongLines`,`lineProps`,`renderer`,`PreTag`,`CodeTag`,`code`,`astGenerator`];function T3(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function E3(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?T3(Object(n),!0).forEach(function(t){f3(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T3(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var D3=/\n/g;function O3(e){return e.match(D3)}function k3(e){var t=e.lines,n=e.startingLineNumber,r=e.style;return t.map(function(e,t){var i=t+n;return d.createElement(`span`,{key:`line-${t}`,className:`react-syntax-highlighter-line-number`,style:typeof r==`function`?r(i):r},`${i}
|
|
463
|
+
`)})}function A3(e){var t=e.codeString,n=e.codeStyle,r=e.containerStyle,i=r===void 0?{float:`left`,paddingRight:`10px`}:r,a=e.numberStyle,o=a===void 0?{}:a,s=e.startingLineNumber;return d.createElement(`code`,{style:Object.assign({},n,i)},k3({lines:t.replace(/\n$/,``).split(`
|
|
464
|
+
`),style:o,startingLineNumber:s}))}function j3(e){return`${e.toString().length}.25em`}function M3(e,t){return{type:`element`,tagName:`span`,properties:{key:`line-number--${e}`,className:[`comment`,`linenumber`,`react-syntax-highlighter-line-number`],style:t},children:[{type:`text`,value:e}]}}function N3(e,t,n){var r={display:`inline-block`,minWidth:j3(n),paddingRight:`1em`,textAlign:`right`,userSelect:`none`},i=typeof e==`function`?e(t):e;return E3(E3({},r),i)}function P3(e){var t=e.children,n=e.lineNumber,r=e.lineNumberStyle,i=e.largestLineNumber,a=e.showInlineLineNumbers,o=e.lineProps,s=o===void 0?{}:o,c=e.className,l=c===void 0?[]:c,u=e.showLineNumbers,d=e.wrapLongLines,f=e.wrapLines,p=f!==void 0&&f?E3({},typeof s==`function`?s(n):s):{};if(p.className=p.className?[].concat(c3(p.className.trim().split(/\s+/)),c3(l)):l,n&&a){var m=N3(r,n,i);t.unshift(M3(n,m))}return d&u&&(p.style=E3({display:`flex`},p.style)),{type:`element`,tagName:`span`,properties:p,children:t}}function F3(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];e.length===void 0&&(e=[e]);for(var r=0;r<e.length;r++){var i=e[r];if(i.type===`text`)n.push(P3({children:[i],className:c3(new Set(t))}));else if(i.children){var a=t.concat(i.properties?.className||[]);F3(i.children,a).forEach(function(e){return n.push(e)})}}return n}function I3(e,t,n,r,i,a,o,s,c){var l,u=F3(e.value),d=[],f=-1,p=0;function m(e,a){return P3({children:e,lineNumber:a,lineNumberStyle:s,largestLineNumber:o,showInlineLineNumbers:i,lineProps:n,className:arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],showLineNumbers:r,wrapLongLines:c,wrapLines:t})}function h(e,t){if(r&&t&&i){var n=N3(s,t,o);e.unshift(M3(t,n))}return e}function g(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return t||r.length>0?m(e,n,r):h(e,n)}for(var _=function(){var e=u[p],t=e.children[0].value;if(O3(t)){var n=t.split(`
|
|
465
465
|
`);n.forEach(function(t,i){var o=r&&d.length+a,s={type:`text`,value:`${t}
|
|
466
|
-
`};if(i===0){var c=g(u.slice(f+1,p).concat(M3({children:[s],className:e.properties.className})),o);d.push(c)}else if(i===n.length-1){var l=u[p+1]&&u[p+1].children&&u[p+1].children[0],m={type:`text`,value:`${t}`};if(l){var h=M3({children:[m],className:e.properties.className});u.splice(p+1,0,h)}else{var _=g([m],o,e.properties.className);d.push(_)}}else{var v=g([s],o,e.properties.className);d.push(v)}}),f=p}p++};p<u.length;)_();if(f!==u.length-1){var v=u.slice(f+1,u.length);if(v&&v.length){var y=g(v,r&&d.length+a);d.push(y)}}return t?d:(l=[]).concat.apply(l,d)}function F3(e){var t=e.rows,n=e.stylesheet,r=e.useInlineStyles;return t.map(function(e,t){return b3({node:e,stylesheet:n,useInlineStyles:r,key:`code-segment-${t}`})})}function I3(e){return e&&e.highlightAuto!==void 0}function L3(e){var t=e.astGenerator,n=e.language,r=e.code,i=e.defaultCodeValue;if(I3(t)){var a=x3(t,n);return n===`text`?{value:i,language:`text`}:a?t.highlight(n,r):t.highlightAuto(r)}try{return n&&n!==`text`?{value:t.highlight(r,n)}:{value:i}}catch{return{value:i}}}function R3(e,t){return function(n){var r=n.language,i=n.children,a=n.style,o=a===void 0?t:a,s=n.customStyle,c=s===void 0?{}:s,l=n.codeTagProps,u=l===void 0?{className:r?`language-${r}`:void 0,style:w3(w3({},o[`code[class*="language-"]`]),o[`code[class*="language-${r}"]`])}:l,f=n.useInlineStyles,p=f===void 0||f,m=n.showLineNumbers,h=m!==void 0&&m,g=n.showInlineLineNumbers,_=g===void 0||g,v=n.startingLineNumber,y=v===void 0?1:v,b=n.lineNumberContainerStyle,x=n.lineNumberStyle,S=x===void 0?{}:x,C=n.wrapLines,w=n.wrapLongLines,T=w!==void 0&&w,E=n.lineProps,D=E===void 0?{}:E,O=n.renderer,k=n.PreTag,A=k===void 0?`pre`:k,j=n.CodeTag,M=j===void 0?`code`:j,N=n.code,P=N===void 0?(Array.isArray(i)?i[0]:i)||``:N,ee=n.astGenerator,F=e3(n,S3);ee||=e;var te=h?d.createElement(O3,{containerStyle:b,codeStyle:u.style||{},numberStyle:S,startingLineNumber:y,codeString:P}):null,ne=o.hljs||o[`pre[class*="language-"]`]||{backgroundColor:`#fff`},re=I3(ee)?`hljs`:`prismjs`,ie=p?Object.assign({},F,{style:Object.assign({},ne,c)}):Object.assign({},F,{className:F.className?`${re} ${F.className}`:re,style:Object.assign({},c)});if(u.style=w3(T?{whiteSpace:`pre-wrap`}:{whiteSpace:`pre`},u.style),!ee)return d.createElement(A,ie,te,d.createElement(M,u,P));(C===void 0&&O||T)&&(C=!0),O||=F3;var ae=[{type:`text`,value:P}],oe=L3({astGenerator:ee,language:r,code:P,defaultCodeValue:ae});oe.language===null&&(oe.value=ae);var I=y+(P.match(/\n/g)?.length??0),L=P3(oe,C,D,h,_,y,I,S,T);return d.createElement(A,ie,d.createElement(M,u,!_&&te,O({rows:L,stylesheet:o,useInlineStyles:p})))}}var z3=`AElig.AMP.Aacute.Acirc.Agrave.Aring.Atilde.Auml.COPY.Ccedil.ETH.Eacute.Ecirc.Egrave.Euml.GT.Iacute.Icirc.Igrave.Iuml.LT.Ntilde.Oacute.Ocirc.Ograve.Oslash.Otilde.Ouml.QUOT.REG.THORN.Uacute.Ucirc.Ugrave.Uuml.Yacute.aacute.acirc.acute.aelig.agrave.amp.aring.atilde.auml.brvbar.ccedil.cedil.cent.copy.curren.deg.divide.eacute.ecirc.egrave.eth.euml.frac12.frac14.frac34.gt.iacute.icirc.iexcl.igrave.iquest.iuml.laquo.lt.macr.micro.middot.nbsp.not.ntilde.oacute.ocirc.ograve.ordf.ordm.oslash.otilde.ouml.para.plusmn.pound.quot.raquo.reg.sect.shy.sup1.sup2.sup3.szlig.thorn.times.uacute.ucirc.ugrave.uml.uuml.yacute.yen.yuml`.split(`.`),B3={0:`�`,128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`};function V3(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=48&&t<=57}function H3(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}function U3(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}function W3(e){return U3(e)||V3(e)}var G3=[``,`Named character references must be terminated by a semicolon`,`Numeric character references must be terminated by a semicolon`,`Named character references cannot be empty`,`Numeric character references cannot be empty`,`Named character references must be known`,`Numeric character references cannot be disallowed`,`Numeric character references cannot be outside the permissible Unicode range`];function K3(e,t){let n=t||{},r=typeof n.additional==`string`?n.additional.charCodeAt(0):n.additional,i=[],a=0,o=-1,s=``,c,l;n.position&&(`start`in n.position||`indent`in n.position?(l=n.position.indent,c=n.position.start):c=n.position);let u=(c?c.line:0)||1,d=(c?c.column:0)||1,f=m(),p;for(a--;++a<=e.length;)if(p===10&&(d=(l?l[o]:0)||1),p=e.charCodeAt(a),p===38){let t=e.charCodeAt(a+1);if(t===9||t===10||t===12||t===32||t===38||t===60||Number.isNaN(t)||r&&t===r){s+=String.fromCharCode(p),d++;continue}let o=a+1,c=o,l=o,u;if(t===35){l=++c;let t=e.charCodeAt(l);t===88||t===120?(u=`hexadecimal`,l=++c):u=`decimal`}else u=`named`;let _=``,v=``,y=``,b=u===`named`?W3:u===`decimal`?V3:H3;for(l--;++l<=e.length;){let t=e.charCodeAt(l);if(!b(t))break;y+=String.fromCharCode(t),u===`named`&&z3.includes(y)&&(_=y,v=Aw(y))}let x=e.charCodeAt(l)===59;if(x){l++;let e=u===`named`&&Aw(y);e&&(_=y,v=e)}let S=1+l-o,C=``;if(!(!x&&n.nonTerminated===!1)){if(!y)u!==`named`&&h(4,S);else if(u===`named`){if(x&&!v)h(5,1);else if(_!==y&&(l=c+_.length,S=1+l-c,x=!1),!x){let t=_?1:3;if(n.attribute){let n=e.charCodeAt(l);n===61?(h(t,S),v=``):W3(n)?v=``:h(t,S)}else h(t,S)}C=v}else{x||h(2,S);let e=Number.parseInt(y,u===`hexadecimal`?16:10);if(q3(e))h(7,S),C=`�`;else if(e in B3)h(6,S),C=B3[e];else{let t=``;J3(e)&&h(6,S),e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10|55296),e=56320|e&1023),C=t+String.fromCharCode(e)}}}if(C){g(),f=m(),a=l-1,d+=l-o+1,i.push(C);let t=m();t.offset++,n.reference&&n.reference.call(n.referenceContext||void 0,C,{start:f,end:t},e.slice(o-1,l)),f=t}else y=e.slice(o-1,l),s+=y,d+=y.length,a=l-1}else p===10&&(u++,o++,d=0),Number.isNaN(p)?g():(s+=String.fromCharCode(p),d++);return i.join(``);function m(){return{line:u,column:d,offset:a+((c?c.offset:0)||0)}}function h(e,t){let r;n.warning&&(r=m(),r.column+=t,r.offset+=t,n.warning.call(n.warningContext||void 0,G3[e],r,e))}function g(){s&&=(i.push(s),n.text&&n.text.call(n.textContext||void 0,s,{start:f,end:m()}),``)}}function q3(e){return e>=55296&&e<=57343||e>1114111}function J3(e){return e>=1&&e<=8||e===11||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||(e&65535)==65535||(e&65535)==65534}var Y3=0,X3={},Z3={util:{type:function(e){return Object.prototype.toString.call(e).slice(8,-1)},objId:function(e){return e.__id||Object.defineProperty(e,"__id",{value:++Y3}),e.__id},clone:function e(t,n){n||={};var r,i;switch(Z3.util.type(t)){case`Object`:if(i=Z3.util.objId(t),n[i])return n[i];for(var a in r={},n[i]=r,t)t.hasOwnProperty(a)&&(r[a]=e(t[a],n));return r;case`Array`:return i=Z3.util.objId(t),n[i]?n[i]:(r=[],n[i]=r,t.forEach(function(t,i){r[i]=e(t,n)}),r);default:return t}}},languages:{plain:X3,plaintext:X3,text:X3,txt:X3,extend:function(e,t){var n=Z3.util.clone(Z3.languages[e]);for(var r in t)n[r]=t[r];return n},insertBefore:function(e,t,n,r){r||=Z3.languages;var i=r[e],a={};for(var o in i)if(i.hasOwnProperty(o)){if(o==t)for(var s in n)n.hasOwnProperty(s)&&(a[s]=n[s]);n.hasOwnProperty(o)||(a[o]=i[o])}var c=r[e];return r[e]=a,Z3.languages.DFS(Z3.languages,function(t,n){n===c&&t!=e&&(this[t]=a)}),a},DFS:function e(t,n,r,i){i||={};var a=Z3.util.objId;for(var o in t)if(t.hasOwnProperty(o)){n.call(t,o,t[o],r||o);var s=t[o],c=Z3.util.type(s);c===`Object`&&!i[a(s)]?(i[a(s)]=!0,e(s,n,null,i)):c===`Array`&&!i[a(s)]&&(i[a(s)]=!0,e(s,n,o,i))}}},plugins:{},highlight:function(e,t,n){var r={code:e,grammar:t,language:n};if(Z3.hooks.run(`before-tokenize`,r),!r.grammar)throw Error(`The language "`+r.language+`" has no grammar.`);return r.tokens=Z3.tokenize(r.code,r.grammar),Z3.hooks.run(`after-tokenize`,r),Q3.stringify(Z3.util.encode(r.tokens),r.language)},tokenize:function(e,t){var n=t.rest;if(n){for(var r in n)t[r]=n[r];delete t.rest}var i=new t6;return n6(i,i.head,e),e6(e,i,t,i.head,0),i6(i)},hooks:{all:{},add:function(e,t){var n=Z3.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=Z3.hooks.all[e];if(!(!n||!n.length))for(var r=0,i;i=n[r++];)i(t)}},Token:Q3};function Q3(e,t,n,r){this.type=e,this.content=t,this.alias=n,this.length=(r||``).length|0}function $3(e,t,n,r){e.lastIndex=t;var i=e.exec(n);if(i&&r&&i[1]){var a=i[1].length;i.index+=a,i[0]=i[0].slice(a)}return i}function e6(e,t,n,r,i,a){for(var o in n)if(!(!n.hasOwnProperty(o)||!n[o])){var s=n[o];s=Array.isArray(s)?s:[s];for(var c=0;c<s.length;++c){if(a&&a.cause==o+`,`+c)return;var l=s[c],u=l.inside,d=!!l.lookbehind,f=!!l.greedy,p=l.alias;if(f&&!l.pattern.global){var m=l.pattern.toString().match(/[imsuy]*$/)[0];l.pattern=RegExp(l.pattern.source,m+`g`)}for(var h=l.pattern||l,g=r.next,_=i;g!==t.tail&&!(a&&_>=a.reach);_+=g.value.length,g=g.next){var v=g.value;if(t.length>e.length)return;if(!(v instanceof Q3)){var y=1,b;if(f){if(b=$3(h,_,e,d),!b||b.index>=e.length)break;var x=b.index,S=b.index+b[0].length,C=_;for(C+=g.value.length;x>=C;)g=g.next,C+=g.value.length;if(C-=g.value.length,_=C,g.value instanceof Q3)continue;for(var w=g;w!==t.tail&&(C<S||typeof w.value==`string`);w=w.next)y++,C+=w.value.length;y--,v=e.slice(_,C),b.index-=_}else if(b=$3(h,0,v,d),!b)continue;var x=b.index,T=b[0],E=v.slice(0,x),D=v.slice(x+T.length),O=_+v.length;a&&O>a.reach&&(a.reach=O);var k=g.prev;E&&(k=n6(t,k,E),_+=E.length),r6(t,k,y);var A=new Q3(o,u?Z3.tokenize(T,u):T,p,T);if(g=n6(t,k,A),D&&n6(t,g,D),y>1){var j={cause:o+`,`+c,reach:O};e6(e,t,n,g.prev,_,j),a&&j.reach>a.reach&&(a.reach=j.reach)}}}}}}function t6(){var e={value:null,prev:null,next:null},t={value:null,prev:e,next:null};e.next=t,this.head=e,this.tail=t,this.length=0}function n6(e,t,n){var r=t.next,i={value:n,prev:t,next:r};return t.next=i,r.prev=i,e.length++,i}function r6(e,t,n){for(var r=t.next,i=0;i<n&&r!==e.tail;i++)r=r.next;t.next=r,r.prev=t,e.length-=i}function i6(e){for(var t=[],n=e.head.next;n!==e.tail;)t.push(n.value),n=n.next;return t}var a6=Z3;function o6(){}o6.prototype=a6;var s6=new o6;s6.highlight=c6,s6.register=l6,s6.alias=u6,s6.registered=d6,s6.listLanguages=f6,s6.util.encode=m6,s6.Token.stringify=p6;function c6(e,t){if(typeof e!=`string`)throw TypeError("Expected `string` for `value`, got `"+e+"`");let n,r;if(t&&typeof t==`object`)n=t;else{if(r=t,typeof r!=`string`)throw TypeError("Expected `string` for `name`, got `"+r+"`");if(Object.hasOwn(s6.languages,r))n=s6.languages[r];else throw Error("Unknown language: `"+r+"` is not registered")}return{type:`root`,children:a6.highlight.call(s6,e,n,r)}}function l6(e){if(typeof e!=`function`||!e.displayName)throw Error("Expected `function` for `syntax`, got `"+e+"`");Object.hasOwn(s6.languages,e.displayName)||e(s6)}function u6(e,t){let n=s6.languages,r={};typeof e==`string`?t&&(r[e]=t):r=e;let i;for(i in r)if(Object.hasOwn(r,i)){let e=r[i],t=typeof e==`string`?[e]:e,a=-1;for(;++a<t.length;)n[t[a]]=n[i]}}function d6(e){if(typeof e!=`string`)throw TypeError("Expected `string` for `aliasOrLanguage`, got `"+e+"`");return Object.hasOwn(s6.languages,e)}function f6(){let e=s6.languages,t=[],n;for(n in e)Object.hasOwn(e,n)&&typeof e[n]==`object`&&t.push(n);return t}function p6(e,t){if(typeof e==`string`)return{type:`text`,value:e};if(Array.isArray(e)){let n=[],r=-1;for(;++r<e.length;)e[r]!==null&&e[r]!==void 0&&e[r]!==``&&n.push(p6(e[r],t));return n}let n={attributes:{},classes:[`token`,e.type],content:p6(e.content,t),language:t,tag:`span`,type:e.type};return e.alias&&n.classes.push(...typeof e.alias==`string`?[e.alias]:e.alias),s6.hooks.run(`wrap`,n),Uk(n.tag+`.`+n.classes.join(`.`),h6(n.attributes),n.content)}function m6(e){return e}function h6(e){let t;for(t in e)Object.hasOwn(e,t)&&(e[t]=K3(e[t]));return e}var g6=R3(s6,{});g6.registerLanguage=function(e,t){return s6.register(t)},g6.alias=function(e,t){return s6.alias(e,t)},_6.displayName=`markup`,_6.aliases=[`atom`,`html`,`mathml`,`rss`,`ssml`,`svg`,`xml`];function _6(e){e.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:`attr-equals`},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:`named-entity`},/&#x?[\da-f]{1,8};/i]},e.languages.markup.tag.inside[`attr-value`].inside.entity=e.languages.markup.entity,e.languages.markup.doctype.inside[`internal-subset`].inside=e.languages.markup,e.hooks.add(`wrap`,function(e){e.type===`entity`&&(e.attributes.title=e.content.value.replace(/&/,`&`))}),Object.defineProperty(e.languages.markup.tag,"addInlined",{value:function(t,n){var r={};r[`language-`+n]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:e.languages[n]},r.cdata=/^<!\[CDATA\[|\]\]>$/i;var i={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:r}};i[`language-`+n]={pattern:/[\s\S]+/,inside:e.languages[n]};var a={};a[t]={pattern:RegExp(`(<__[^>]*>)(?:<!\\[CDATA\\[(?:[^\\]]|\\](?!\\]>))*\\]\\]>|(?!<!\\[CDATA\\[)[\\s\\S])*?(?=<\\/__>)`.replace(/__/g,function(){return t}),`i`),lookbehind:!0,greedy:!0,inside:i},e.languages.insertBefore(`markup`,`cdata`,a)}}),Object.defineProperty(e.languages.markup.tag,"addAttribute",{value:function(t,n){e.languages.markup.tag.inside[`special-attr`].push({pattern:RegExp(`(^|["'\\s])(?:`+t+`)\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s'">=]+(?=[\\s>]))`,`i`),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[n,`language-`+n],inside:e.languages[n]},punctuation:[{pattern:/^=/,alias:`attr-equals`},/"|'/]}}}})}}),e.languages.html=e.languages.markup,e.languages.mathml=e.languages.markup,e.languages.svg=e.languages.markup,e.languages.xml=e.languages.extend(`markup`,{}),e.languages.ssml=e.languages.xml,e.languages.atom=e.languages.xml,e.languages.rss=e.languages.xml}v6.displayName=`css`,v6.aliases=[];function v6(e){(function(e){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp(`@[\\w-](?:[^;{\\s"']|\\s+(?!\\s)|`+t.source+`)*?(?:;|(?=\\s*\\{))`),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:`selector`},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp(`\\burl\\((?:`+t.source+`|(?:[^\\\\\\r\\n()"']|\\\\[\\s\\S])*)\\)`,`i`),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp(`^`+t.source+`$`),alias:`url`}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+t.source+`)*(?=\\s*\\{)`),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var n=e.languages.markup;n&&(n.tag.addInlined(`style`,`css`),n.tag.addAttribute(`style`,`css`))})(e)}y6.displayName=`clike`,y6.aliases=[];function y6(e){e.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/}}b6.displayName=`javascript`,b6.aliases=[`js`];function b6(e){e.register(y6),e.languages.javascript=e.languages.extend(`clike`,{"class-name":[e.languages.clike[`class-name`],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(`(^|[^\\w$])(?:NaN|Infinity|0[bB][01]+(?:_[01]+)*n?|0[oO][0-7]+(?:_[0-7]+)*n?|0[xX][\\dA-Fa-f]+(?:_[\\dA-Fa-f]+)*n?|\\d+(?:_\\d+)*n|(?:\\d+(?:_\\d+)*(?:\\.(?:\\d+(?:_\\d+)*)?)?|\\.\\d+(?:_\\d+)*)(?:[Ee][+-]?\\d+(?:_\\d+)*)?)(?![\\w$])`),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),e.languages.javascript[`class-name`][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,e.languages.insertBefore(`javascript`,`keyword`,{regex:{pattern:RegExp(`((?:^|[^$\\w\\xA0-\\uFFFF."'\\])\\s]|\\b(?:return|yield))\\s*)\\/(?:(?:\\[(?:[^\\]\\\\\\r\\n]|\\\\.)*\\]|\\\\.|[^/\\\\\\[\\r\\n])+\\/[dgimyus]{0,7}|(?:\\[(?:[^[\\]\\\\\\r\\n]|\\\\.|\\[(?:[^[\\]\\\\\\r\\n]|\\\\.|\\[(?:[^[\\]\\\\\\r\\n]|\\\\.)*\\])*\\])*\\]|\\\\.|[^/\\\\\\[\\r\\n])+\\/[dgimyus]{0,7}v[dgimyus]{0,7})(?=(?:\\s|\\/\\*(?:[^*]|\\*(?!\\/))*\\*\\/)*(?:$|[\\r\\n,.;:})\\]]|\\/\\/))`),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:`language-regex`,inside:e.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:`function`},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:e.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:e.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:e.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:e.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),e.languages.insertBefore(`javascript`,`string`,{hashbang:{pattern:/^#!.*/,greedy:!0,alias:`comment`},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:`string`},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:`punctuation`},rest:e.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:`property`}}),e.languages.insertBefore(`javascript`,`operator`,{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:`property`}}),e.languages.markup&&(e.languages.markup.tag.addInlined(`script`,`javascript`),e.languages.markup.tag.addAttribute(`on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)`,`javascript`)),e.languages.js=e.languages.javascript}x6.displayName=`sql`,x6.aliases=[];function x6(e){e.languages.sql={comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,lookbehind:!0},variable:[{pattern:/@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,greedy:!0},/@[\w.$]+/],string:{pattern:/(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,greedy:!0,lookbehind:!0},identifier:{pattern:/(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,greedy:!0,lookbehind:!0,inside:{punctuation:/^`|`$/}},function:/\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,keyword:/\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,boolean:/\b(?:FALSE|NULL|TRUE)\b/i,number:/\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,operator:/[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,punctuation:/[;[\]()`,.]/}}S6.displayName=`c`,S6.aliases=[];function S6(e){e.register(y6),e.languages.c=e.languages.extend(`clike`,{comment:{pattern:/\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},string:{pattern:/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},"class-name":{pattern:/(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,lookbehind:!0},keyword:/\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,function:/\b[a-z_]\w*(?=\s*\()/i,number:/(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/}),e.languages.insertBefore(`c`,`string`,{char:{pattern:/'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,greedy:!0}}),e.languages.insertBefore(`c`,`string`,{macro:{pattern:/(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,lookbehind:!0,greedy:!0,alias:`property`,inside:{string:[{pattern:/^(#\s*include\s*)<[^>]+>/,lookbehind:!0},e.languages.c.string],char:e.languages.c.char,comment:e.languages.c.comment,"macro-name":[{pattern:/(^#\s*define\s+)\w+\b(?!\()/i,lookbehind:!0},{pattern:/(^#\s*define\s+)\w+\b(?=\()/i,lookbehind:!0,alias:`function`}],directive:{pattern:/^(#\s*)[a-z]+/,lookbehind:!0,alias:`keyword`},"directive-hash":/^#/,punctuation:/##|\\(?=[\r\n])/,expression:{pattern:/\S[\s\S]*/,inside:e.languages.c}}}}),e.languages.insertBefore(`c`,`function`,{constant:/\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/}),delete e.languages.c.boolean}C6.displayName=`cpp`,C6.aliases=[];function C6(e){e.register(S6),(function(e){var t=/\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,n=`\\b(?!<keyword>)\\w+(?:\\s*\\.\\s*\\w+)*\\b`.replace(/<keyword>/g,function(){return t.source});e.languages.cpp=e.languages.extend(`c`,{"class-name":[{pattern:RegExp(`(\\b(?:class|concept|enum|struct|typename)\\s+)(?!<keyword>)\\w+`.replace(/<keyword>/g,function(){return t.source})),lookbehind:!0},/\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,/\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,/\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/],keyword:t,number:{pattern:/(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,greedy:!0},operator:/>>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,boolean:/\b(?:false|true)\b/}),e.languages.insertBefore(`cpp`,`string`,{module:{pattern:RegExp(`(\\b(?:import|module)\\s+)(?:"(?:\\\\(?:\\r\\n|[\\s\\S])|[^"\\\\\\r\\n])*"|<[^<>\\r\\n]*>|`+`<mod-name>(?:\\s*:\\s*<mod-name>)?|:\\s*<mod-name>`.replace(/<mod-name>/g,function(){return n})+`)`),lookbehind:!0,greedy:!0,inside:{string:/^[<"][\s\S]+/,operator:/:/,punctuation:/\./}},"raw-string":{pattern:/R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,alias:`string`,greedy:!0}}),e.languages.insertBefore(`cpp`,`keyword`,{"generic-function":{pattern:/\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,inside:{function:/^\w+/,generic:{pattern:/<[\s\S]+/,alias:`class-name`,inside:e.languages.cpp}}}}),e.languages.insertBefore(`cpp`,`operator`,{"double-colon":{pattern:/::/,alias:`punctuation`}}),e.languages.insertBefore(`cpp`,`class-name`,{"base-clause":{pattern:/(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,lookbehind:!0,greedy:!0,inside:e.languages.extend(`cpp`,{})}}),e.languages.insertBefore(`inside`,`double-colon`,{"class-name":/\b[a-z_]\w*\b(?!\s*::)/i},e.languages.cpp[`base-clause`])})(e)}w6.displayName=`bash`,w6.aliases=[`sh`,`shell`];function w6(e){(function(e){var t=`\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b`,n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:`punctuation`,inside:null},r={bash:n,environment:{pattern:RegExp(`\\$`+t),alias:`constant`},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp(`(\\{)`+t),lookbehind:!0,alias:`constant`}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};e.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:`important`},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:`function`},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:`function`}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:`variable`,lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp(`(^|[\\s;|&]|[<>]\\()`+t),lookbehind:!0,alias:`constant`}},alias:`variable`,lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:`variable`,lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp(`\\$?`+t),alias:`constant`},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:`class-name`},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:`important`},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:`important`}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=e.languages.bash;for(var i=[`comment`,`function-name`,`for-or-select`,`assign-left`,`parameter`,`string`,`environment`,`function`,`keyword`,`builtin`,`boolean`,`file-descriptor`,`operator`,`punctuation`,`number`],a=r.variable[1].inside,o=0;o<i.length;o++)a[i[o]]=e.languages.bash[i[o]];e.languages.sh=e.languages.bash,e.languages.shell=e.languages.bash})(e)}T6.displayName=`yaml`,T6.aliases=[`yml`];function T6(e){(function(e){var t=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r=`(?:`+n.source+`(?:[ ]+`+t.source+`)?|`+t.source+`(?:[ ]+`+n.source+`)?)`,i=`(?:[^\\s\\x00-\\x08\\x0e-\\x1f!"#%&'*,\\-:>?@[\\]\`{|}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]|[?:-]<PLAIN>)(?:[ \\t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*`.replace(/<PLAIN>/g,function(){return`[^\\s\\x00-\\x08\\x0e-\\x1f,[\\]{}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]`}),a=`"(?:[^"\\\\\\r\\n]|\\\\.)*"|'(?:[^'\\\\\\r\\n]|\\\\.)*'`;function o(e,t){t=(t||``).replace(/m/g,``)+`m`;var n=`([:\\-,[{]\\s*(?:\\s<<prop>>[ \\t]+)?)(?:<<value>>)(?=[ \\t]*(?:$|,|\\]|\\}|(?:[\\r\\n]\\s*)?#))`.replace(/<<prop>>/g,function(){return r}).replace(/<<value>>/g,function(){return e});return RegExp(n,t)}e.languages.yaml={scalar:{pattern:RegExp(`([\\-:]\\s*(?:\\s<<prop>>[ \\t]+)?[|>])[ \\t]*(?:((?:\\r?\\n|\\r)[ \\t]+)\\S[^\\r\\n]*(?:\\2[^\\r\\n]+)*)`.replace(/<<prop>>/g,function(){return r})),lookbehind:!0,alias:`string`},comment:/#.*/,key:{pattern:RegExp(`((?:^|[:\\-,[{\\r\\n?])[ \\t]*(?:<<prop>>[ \\t]+)?)<<key>>(?=\\s*:\\s)`.replace(/<<prop>>/g,function(){return r}).replace(/<<key>>/g,function(){return`(?:`+i+`|`+a+`)`})),lookbehind:!0,greedy:!0,alias:`atrule`},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:`important`},datetime:{pattern:o(`\\d{4}-\\d\\d?-\\d\\d?(?:[tT]|[ \\t]+)\\d\\d?:\\d{2}:\\d{2}(?:\\.\\d*)?(?:[ \\t]*(?:Z|[-+]\\d\\d?(?::\\d{2})?))?|\\d{4}-\\d{2}-\\d{2}|\\d\\d?:\\d{2}(?::\\d{2}(?:\\.\\d*)?)?`),lookbehind:!0,alias:`number`},boolean:{pattern:o(`false|true`,`i`),lookbehind:!0,alias:`important`},null:{pattern:o(`null|~`,`i`),lookbehind:!0,alias:`important`},string:{pattern:o(a),lookbehind:!0,greedy:!0},number:{pattern:o(`[+-]?(?:0x[\\da-f]+|0o[0-7]+|(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+-]?\\d+)?|\\.inf|\\.nan)`,`i`),lookbehind:!0},tag:n,important:t,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},e.languages.yml=e.languages.yaml})(e)}E6.displayName=`markdown`,E6.aliases=[`md`];function E6(e){e.register(_6),(function(e){function t(e){return e=e.replace(/<inner>/g,function(){return`(?:\\\\.|[^\\\\\\n\\r]|(?:\\n|\\r\\n?)(?![\\r\\n]))`}),RegExp(`((?:^|[^\\\\])(?:\\\\{2})*)(?:`+e+`)`)}var n="(?:\\\\.|``(?:[^`\\r\\n]|`(?!`))+``|`[^`\\r\\n]+`|[^\\\\|\\r\\n`])+",r=`\\|?__(?:\\|__)+\\|?(?:(?:\\n|\\r\\n?)|(?![\\s\\S]))`.replace(/__/g,function(){return n}),i=`\\|?[ \\t]*:?-{3,}:?[ \\t]*(?:\\|[ \\t]*:?-{3,}:?[ \\t]*)+\\|?(?:\\n|\\r\\n?)`;e.languages.markdown=e.languages.extend(`markup`,{}),e.languages.insertBefore(`markdown`,`prolog`,{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:[`yaml`,`language-yaml`],inside:e.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:`punctuation`},table:{pattern:RegExp(`^`+r+i+`(?:`+r+`)*`,`m`),inside:{"table-data-rows":{pattern:RegExp(`^(`+r+i+`)(?:`+r+`)*$`),lookbehind:!0,inside:{"table-data":{pattern:RegExp(n),inside:e.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp(`^(`+r+`)`+i+`$`),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp(`^`+r+`$`),inside:{"table-header":{pattern:RegExp(n),alias:`important`,inside:e.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:`keyword`},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:`important`,inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:`important`,inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:`punctuation`},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:`punctuation`},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:`url`},bold:{pattern:t(`\\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\\b|\\*\\*(?:(?!\\*)<inner>|\\*(?:(?!\\*)<inner>)+\\*)+\\*\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:t(`\\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\\b|\\*(?:(?!\\*)<inner>|\\*\\*(?:(?!\\*)<inner>)+\\*\\*)+\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:t(`(~~?)(?:(?!~)<inner>)+\\2`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:[`code`,`keyword`]},url:{pattern:t(`!?\\[(?:(?!\\])<inner>)+\\](?:\\([^\\s)]+(?:[\\t ]+"(?:\\\\.|[^"\\\\])*")?\\)|[ \\t]?\\[(?:(?!\\])<inner>)+\\])`),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),[`url`,`bold`,`italic`,`strike`].forEach(function(t){[`url`,`bold`,`italic`,`strike`,`code-snippet`].forEach(function(n){t!==n&&(e.languages.markdown[t].inside.content.inside[n]=e.languages.markdown[n])})}),e.hooks.add(`after-tokenize`,function(e){if(e.language!==`markdown`&&e.language!==`md`)return;function t(e){if(!(!e||typeof e==`string`))for(var n=0,r=e.length;n<r;n++){var i=e[n];if(i.type!==`code`){t(i.content);continue}var a=i.content[1],o=i.content[3];if(a&&o&&a.type===`code-language`&&o.type===`code-block`&&typeof a.content==`string`){var s=a.content.replace(/\b#/g,`sharp`).replace(/\b\+\+/g,`pp`);s=(/[a-z][\w-]*/i.exec(s)||[``])[0].toLowerCase();var c=`language-`+s;o.alias?typeof o.alias==`string`?o.alias=[o.alias,c]:o.alias.push(c):o.alias=[c]}}}t(e.tokens)}),e.hooks.add(`wrap`,function(t){if(t.type===`code-block`){for(var n=``,r=0,i=t.classes.length;r<i;r++){var a=t.classes[r],o=/language-(.+)/.exec(a);if(o){n=o[1];break}}var s=e.languages[n];if(s)t.content=e.highlight(t.content.value,s,n);else if(n&&n!==`none`&&e.plugins.autoloader){var c=`md-`+new Date().valueOf()+`-`+Math.floor(Math.random()*0x2386f26fc10000);t.attributes.id=c,e.plugins.autoloader.loadLanguages(n,function(){var t=document.getElementById(c);t&&(t.innerHTML=e.highlight(t.textContent,e.languages[n],n))})}}}),RegExp(e.languages.markup.tag.pattern.source,`gi`),String.fromCodePoint||String.fromCharCode,e.languages.md=e.languages.markdown})(e)}D6.displayName=`csharp`,D6.aliases=[`cs`,`dotnet`];function D6(e){e.register(y6),(function(e){function t(e,t){return e.replace(/<<(\d+)>>/g,function(e,n){return`(?:`+t[+n]+`)`})}function n(e,n,r){return RegExp(t(e,n),r||``)}function r(e,t){for(var n=0;n<t;n++)e=e.replace(/<<self>>/g,function(){return`(?:`+e+`)`});return e.replace(/<<self>>/g,`[^\\s\\S]`)}var i={type:`bool byte char decimal double dynamic float int long object sbyte short string uint ulong ushort var void`,typeDeclaration:`class enum interface record struct`,contextual:`add alias and ascending async await by descending from(?=\\s*(?:\\w|$)) get global group into init(?=\\s*;) join let nameof not notnull on or orderby partial remove select set unmanaged value when where with(?=\\s*{)`,other:`abstract as base break case catch checked const continue default delegate do else event explicit extern finally fixed for foreach goto if implicit in internal is lock namespace new null operator out override params private protected public readonly ref return sealed sizeof stackalloc static switch this throw try typeof unchecked unsafe using virtual volatile while yield`};function a(e){return`\\b(?:`+e.trim().replace(/ /g,`|`)+`)\\b`}var o=a(i.typeDeclaration),s=RegExp(a(i.type+` `+i.typeDeclaration+` `+i.contextual+` `+i.other)),c=a(i.typeDeclaration+` `+i.contextual+` `+i.other),l=a(i.type+` `+i.typeDeclaration+` `+i.other),u=r(`<(?:[^<>;=+\\-*/%&|^]|<<self>>)*>`,2),d=r(`\\((?:[^()]|<<self>>)*\\)`,2),f=`@?\\b[A-Za-z_]\\w*\\b`,p=t(`<<0>>(?:\\s*<<1>>)?`,[f,u]),m=t(`(?!<<0>>)<<1>>(?:\\s*\\.\\s*<<1>>)*`,[c,p]),h=`\\[\\s*(?:,\\s*)*\\]`,g=t(`<<0>>(?:\\s*(?:\\?\\s*)?<<1>>)*(?:\\s*\\?)?`,[m,h]),_=t(`(?:<<0>>|<<1>>)(?:\\s*(?:\\?\\s*)?<<2>>)*(?:\\s*\\?)?`,[t(`\\(<<0>>+(?:,<<0>>+)+\\)`,[t(`[^,()<>[\\];=+\\-*/%&|^]|<<0>>|<<1>>|<<2>>`,[u,d,h])]),m,h]),v={keyword:s,punctuation:/[<>()?,.:[\]]/},y=`'(?:[^\\r\\n'\\\\]|\\\\.|\\\\[Uux][\\da-fA-F]{1,8})'`,b=`"(?:\\\\.|[^\\\\"\\r\\n])*"`,x=`@"(?:""|\\\\[\\s\\S]|[^\\\\"])*"(?!")`;e.languages.csharp=e.languages.extend(`clike`,{string:[{pattern:n(`(^|[^$\\\\])<<0>>`,[x]),lookbehind:!0,greedy:!0},{pattern:n(`(^|[^@$\\\\])<<0>>`,[b]),lookbehind:!0,greedy:!0}],"class-name":[{pattern:n(`(\\busing\\s+static\\s+)<<0>>(?=\\s*;)`,[m]),lookbehind:!0,inside:v},{pattern:n(`(\\busing\\s+<<0>>\\s*=\\s*)<<1>>(?=\\s*;)`,[f,_]),lookbehind:!0,inside:v},{pattern:n(`(\\busing\\s+)<<0>>(?=\\s*=)`,[f]),lookbehind:!0},{pattern:n(`(\\b<<0>>\\s+)<<1>>`,[o,p]),lookbehind:!0,inside:v},{pattern:n(`(\\bcatch\\s*\\(\\s*)<<0>>`,[m]),lookbehind:!0,inside:v},{pattern:n(`(\\bwhere\\s+)<<0>>`,[f]),lookbehind:!0},{pattern:n(`(\\b(?:is(?:\\s+not)?|as)\\s+)<<0>>`,[g]),lookbehind:!0,inside:v},{pattern:n(`\\b<<0>>(?=\\s+(?!<<1>>|with\\s*\\{)<<2>>(?:\\s*[=,;:{)\\]]|\\s+(?:in|when)\\b))`,[_,l,f]),inside:v}],keyword:s,number:/(?:\b0(?:x[\da-f_]*[\da-f]|b[01_]*[01])|(?:\B\.\d+(?:_+\d+)*|\b\d+(?:_+\d+)*(?:\.\d+(?:_+\d+)*)?)(?:e[-+]?\d+(?:_+\d+)*)?)(?:[dflmu]|lu|ul)?\b/i,operator:/>>=?|<<=?|[-=]>|([-+&|])\1|~|\?\?=?|[-+*/%&|^!=<>]=?/,punctuation:/\?\.?|::|[{}[\];(),.:]/}),e.languages.insertBefore(`csharp`,`number`,{range:{pattern:/\.\./,alias:`operator`}}),e.languages.insertBefore(`csharp`,`punctuation`,{"named-parameter":{pattern:n(`([(,]\\s*)<<0>>(?=\\s*:)`,[f]),lookbehind:!0,alias:`punctuation`}}),e.languages.insertBefore(`csharp`,`class-name`,{namespace:{pattern:n(`(\\b(?:namespace|using)\\s+)<<0>>(?:\\s*\\.\\s*<<0>>)*(?=\\s*[;{])`,[f]),lookbehind:!0,inside:{punctuation:/\./}},"type-expression":{pattern:n(`(\\b(?:default|sizeof|typeof)\\s*\\(\\s*(?!\\s))(?:[^()\\s]|\\s(?!\\s)|<<0>>)*(?=\\s*\\))`,[d]),lookbehind:!0,alias:`class-name`,inside:v},"return-type":{pattern:n(`<<0>>(?=\\s+(?:<<1>>\\s*(?:=>|[({]|\\.\\s*this\\s*\\[)|this\\s*\\[))`,[_,m]),inside:v,alias:`class-name`},"constructor-invocation":{pattern:n(`(\\bnew\\s+)<<0>>(?=\\s*[[({])`,[_]),lookbehind:!0,inside:v,alias:`class-name`},"generic-method":{pattern:n(`<<0>>\\s*<<1>>(?=\\s*\\()`,[f,u]),inside:{function:n(`^<<0>>`,[f]),generic:{pattern:RegExp(u),alias:`class-name`,inside:v}}},"type-list":{pattern:n(`\\b((?:<<0>>\\s+<<1>>|record\\s+<<1>>\\s*<<5>>|where\\s+<<2>>)\\s*:\\s*)(?:<<3>>|<<4>>|<<1>>\\s*<<5>>|<<6>>)(?:\\s*,\\s*(?:<<3>>|<<4>>|<<6>>))*(?=\\s*(?:where|[{;]|=>|$))`,[o,p,f,_,s.source,d,`\\bnew\\s*\\(\\s*\\)`]),lookbehind:!0,inside:{"record-arguments":{pattern:n(`(^(?!new\\s*\\()<<0>>\\s*)<<1>>`,[p,d]),lookbehind:!0,greedy:!0,inside:e.languages.csharp},keyword:s,"class-name":{pattern:RegExp(_),greedy:!0,inside:v},punctuation:/[,()]/}},preprocessor:{pattern:/(^[\t ]*)#.*/m,lookbehind:!0,alias:`property`,inside:{directive:{pattern:/(#)\b(?:define|elif|else|endif|endregion|error|if|line|nullable|pragma|region|undef|warning)\b/,lookbehind:!0,alias:`keyword`}}}});var S=b+`|`+y,C=t(`\\/(?![*/])|\\/\\/[^\\r\\n]*[\\r\\n]|\\/\\*(?:[^*]|\\*(?!\\/))*\\*\\/|<<0>>`,[S]),w=r(t(`[^"'/()]|<<0>>|\\(<<self>>*\\)`,[C]),2),T=`\\b(?:assembly|event|field|method|module|param|property|return|type)\\b`,E=t(`<<0>>(?:\\s*\\(<<1>>*\\))?`,[m,w]);e.languages.insertBefore(`csharp`,`class-name`,{attribute:{pattern:n(`((?:^|[^\\s\\w>)?])\\s*\\[\\s*)(?:<<0>>\\s*:\\s*)?<<1>>(?:\\s*,\\s*<<1>>)*(?=\\s*\\])`,[T,E]),lookbehind:!0,greedy:!0,inside:{target:{pattern:n(`^<<0>>(?=\\s*:)`,[T]),alias:`keyword`},"attribute-arguments":{pattern:n(`\\(<<0>>*\\)`,[w]),inside:e.languages.csharp},"class-name":{pattern:RegExp(m),inside:{punctuation:/\./}},punctuation:/[:,]/}}});var D=`:[^}\\r\\n]+`,O=r(t(`[^"'/()]|<<0>>|\\(<<self>>*\\)`,[C]),2),k=t(`\\{(?!\\{)(?:(?![}:])<<0>>)*<<1>>?\\}`,[O,D]),A=r(t(`[^"'/()]|\\/(?!\\*)|\\/\\*(?:[^*]|\\*(?!\\/))*\\*\\/|<<0>>|\\(<<self>>*\\)`,[S]),2),j=t(`\\{(?!\\{)(?:(?![}:])<<0>>)*<<1>>?\\}`,[A,D]);function M(t,r){return{interpolation:{pattern:n(`((?:^|[^{])(?:\\{\\{)*)<<0>>`,[t]),lookbehind:!0,inside:{"format-string":{pattern:n(`(^\\{(?:(?![}:])<<0>>)*)<<1>>(?=\\}$)`,[r,D]),lookbehind:!0,inside:{punctuation:/^:/}},punctuation:/^\{|\}$/,expression:{pattern:/[\s\S]+/,alias:`language-csharp`,inside:e.languages.csharp}}},string:/[\s\S]+/}}e.languages.insertBefore(`csharp`,`string`,{"interpolation-string":[{pattern:n(`(^|[^\\\\])(?:\\$@|@\\$)"(?:""|\\\\[\\s\\S]|\\{\\{|<<0>>|[^\\\\{"])*"`,[k]),lookbehind:!0,greedy:!0,inside:M(k,O)},{pattern:n(`(^|[^@\\\\])\\$"(?:\\\\.|\\{\\{|<<0>>|[^\\\\"{])*"`,[j]),lookbehind:!0,greedy:!0,inside:M(j,A)}],char:{pattern:RegExp(y),greedy:!0}}),e.languages.dotnet=e.languages.cs=e.languages.csharp})(e)}O6.displayName=`diff`,O6.aliases=[];function O6(e){(function(e){e.languages.diff={coord:[/^(?:\*{3}|-{3}|\+{3}).*$/m,/^@@.*@@$/m,/^\d.*$/m]};var t={"deleted-sign":`-`,"deleted-arrow":`<`,"inserted-sign":`+`,"inserted-arrow":`>`,unchanged:` `,diff:`!`};Object.keys(t).forEach(function(n){var r=t[n],i=[];/^\w+$/.test(n)||i.push(/\w+/.exec(n)[0]),n===`diff`&&i.push(`bold`),e.languages.diff[n]={pattern:RegExp(`^(?:[`+r+`].*(?:\r
|
|
466
|
+
`};if(i===0){var c=g(u.slice(f+1,p).concat(P3({children:[s],className:e.properties.className})),o);d.push(c)}else if(i===n.length-1){var l=u[p+1]&&u[p+1].children&&u[p+1].children[0],m={type:`text`,value:`${t}`};if(l){var h=P3({children:[m],className:e.properties.className});u.splice(p+1,0,h)}else{var _=g([m],o,e.properties.className);d.push(_)}}else{var v=g([s],o,e.properties.className);d.push(v)}}),f=p}p++};p<u.length;)_();if(f!==u.length-1){var v=u.slice(f+1,u.length);if(v&&v.length){var y=g(v,r&&d.length+a);d.push(y)}}return t?d:(l=[]).concat.apply(l,d)}function L3(e){var t=e.rows,n=e.stylesheet,r=e.useInlineStyles;return t.map(function(e,t){return S3({node:e,stylesheet:n,useInlineStyles:r,key:`code-segment-${t}`})})}function R3(e){return e&&e.highlightAuto!==void 0}function z3(e){var t=e.astGenerator,n=e.language,r=e.code,i=e.defaultCodeValue;if(R3(t)){var a=C3(t,n);return n===`text`?{value:i,language:`text`}:a?t.highlight(n,r):t.highlightAuto(r)}try{return n&&n!==`text`?{value:t.highlight(r,n)}:{value:i}}catch{return{value:i}}}function B3(e,t){return function(n){var r=n.language,i=n.children,a=n.style,o=a===void 0?t:a,s=n.customStyle,c=s===void 0?{}:s,l=n.codeTagProps,u=l===void 0?{className:r?`language-${r}`:void 0,style:E3(E3({},o[`code[class*="language-"]`]),o[`code[class*="language-${r}"]`])}:l,f=n.useInlineStyles,p=f===void 0||f,m=n.showLineNumbers,h=m!==void 0&&m,g=n.showInlineLineNumbers,_=g===void 0||g,v=n.startingLineNumber,y=v===void 0?1:v,b=n.lineNumberContainerStyle,x=n.lineNumberStyle,S=x===void 0?{}:x,C=n.wrapLines,w=n.wrapLongLines,T=w!==void 0&&w,E=n.lineProps,D=E===void 0?{}:E,O=n.renderer,k=n.PreTag,A=k===void 0?`pre`:k,j=n.CodeTag,M=j===void 0?`code`:j,N=n.code,P=N===void 0?(Array.isArray(i)?i[0]:i)||``:N,ee=n.astGenerator,F=n3(n,w3);ee||=e;var te=h?d.createElement(A3,{containerStyle:b,codeStyle:u.style||{},numberStyle:S,startingLineNumber:y,codeString:P}):null,ne=o.hljs||o[`pre[class*="language-"]`]||{backgroundColor:`#fff`},re=R3(ee)?`hljs`:`prismjs`,ie=p?Object.assign({},F,{style:Object.assign({},ne,c)}):Object.assign({},F,{className:F.className?`${re} ${F.className}`:re,style:Object.assign({},c)});if(u.style=E3(T?{whiteSpace:`pre-wrap`}:{whiteSpace:`pre`},u.style),!ee)return d.createElement(A,ie,te,d.createElement(M,u,P));(C===void 0&&O||T)&&(C=!0),O||=L3;var ae=[{type:`text`,value:P}],oe=z3({astGenerator:ee,language:r,code:P,defaultCodeValue:ae});oe.language===null&&(oe.value=ae);var I=y+(P.match(/\n/g)?.length??0),L=I3(oe,C,D,h,_,y,I,S,T);return d.createElement(A,ie,d.createElement(M,u,!_&&te,O({rows:L,stylesheet:o,useInlineStyles:p})))}}var V3=`AElig.AMP.Aacute.Acirc.Agrave.Aring.Atilde.Auml.COPY.Ccedil.ETH.Eacute.Ecirc.Egrave.Euml.GT.Iacute.Icirc.Igrave.Iuml.LT.Ntilde.Oacute.Ocirc.Ograve.Oslash.Otilde.Ouml.QUOT.REG.THORN.Uacute.Ucirc.Ugrave.Uuml.Yacute.aacute.acirc.acute.aelig.agrave.amp.aring.atilde.auml.brvbar.ccedil.cedil.cent.copy.curren.deg.divide.eacute.ecirc.egrave.eth.euml.frac12.frac14.frac34.gt.iacute.icirc.iexcl.igrave.iquest.iuml.laquo.lt.macr.micro.middot.nbsp.not.ntilde.oacute.ocirc.ograve.ordf.ordm.oslash.otilde.ouml.para.plusmn.pound.quot.raquo.reg.sect.shy.sup1.sup2.sup3.szlig.thorn.times.uacute.ucirc.ugrave.uml.uuml.yacute.yen.yuml`.split(`.`),H3={0:`�`,128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`};function U3(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=48&&t<=57}function W3(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}function G3(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}function K3(e){return G3(e)||U3(e)}var q3=[``,`Named character references must be terminated by a semicolon`,`Numeric character references must be terminated by a semicolon`,`Named character references cannot be empty`,`Numeric character references cannot be empty`,`Named character references must be known`,`Numeric character references cannot be disallowed`,`Numeric character references cannot be outside the permissible Unicode range`];function J3(e,t){let n=t||{},r=typeof n.additional==`string`?n.additional.charCodeAt(0):n.additional,i=[],a=0,o=-1,s=``,c,l;n.position&&(`start`in n.position||`indent`in n.position?(l=n.position.indent,c=n.position.start):c=n.position);let u=(c?c.line:0)||1,d=(c?c.column:0)||1,f=m(),p;for(a--;++a<=e.length;)if(p===10&&(d=(l?l[o]:0)||1),p=e.charCodeAt(a),p===38){let t=e.charCodeAt(a+1);if(t===9||t===10||t===12||t===32||t===38||t===60||Number.isNaN(t)||r&&t===r){s+=String.fromCharCode(p),d++;continue}let o=a+1,c=o,l=o,u;if(t===35){l=++c;let t=e.charCodeAt(l);t===88||t===120?(u=`hexadecimal`,l=++c):u=`decimal`}else u=`named`;let _=``,v=``,y=``,b=u===`named`?K3:u===`decimal`?U3:W3;for(l--;++l<=e.length;){let t=e.charCodeAt(l);if(!b(t))break;y+=String.fromCharCode(t),u===`named`&&V3.includes(y)&&(_=y,v=Aw(y))}let x=e.charCodeAt(l)===59;if(x){l++;let e=u===`named`&&Aw(y);e&&(_=y,v=e)}let S=1+l-o,C=``;if(!(!x&&n.nonTerminated===!1)){if(!y)u!==`named`&&h(4,S);else if(u===`named`){if(x&&!v)h(5,1);else if(_!==y&&(l=c+_.length,S=1+l-c,x=!1),!x){let t=_?1:3;if(n.attribute){let n=e.charCodeAt(l);n===61?(h(t,S),v=``):K3(n)?v=``:h(t,S)}else h(t,S)}C=v}else{x||h(2,S);let e=Number.parseInt(y,u===`hexadecimal`?16:10);if(Y3(e))h(7,S),C=`�`;else if(e in H3)h(6,S),C=H3[e];else{let t=``;X3(e)&&h(6,S),e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10|55296),e=56320|e&1023),C=t+String.fromCharCode(e)}}}if(C){g(),f=m(),a=l-1,d+=l-o+1,i.push(C);let t=m();t.offset++,n.reference&&n.reference.call(n.referenceContext||void 0,C,{start:f,end:t},e.slice(o-1,l)),f=t}else y=e.slice(o-1,l),s+=y,d+=y.length,a=l-1}else p===10&&(u++,o++,d=0),Number.isNaN(p)?g():(s+=String.fromCharCode(p),d++);return i.join(``);function m(){return{line:u,column:d,offset:a+((c?c.offset:0)||0)}}function h(e,t){let r;n.warning&&(r=m(),r.column+=t,r.offset+=t,n.warning.call(n.warningContext||void 0,q3[e],r,e))}function g(){s&&=(i.push(s),n.text&&n.text.call(n.textContext||void 0,s,{start:f,end:m()}),``)}}function Y3(e){return e>=55296&&e<=57343||e>1114111}function X3(e){return e>=1&&e<=8||e===11||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||(e&65535)==65535||(e&65535)==65534}var Z3=0,Q3={},$3={util:{type:function(e){return Object.prototype.toString.call(e).slice(8,-1)},objId:function(e){return e.__id||Object.defineProperty(e,"__id",{value:++Z3}),e.__id},clone:function e(t,n){n||={};var r,i;switch($3.util.type(t)){case`Object`:if(i=$3.util.objId(t),n[i])return n[i];for(var a in r={},n[i]=r,t)t.hasOwnProperty(a)&&(r[a]=e(t[a],n));return r;case`Array`:return i=$3.util.objId(t),n[i]?n[i]:(r=[],n[i]=r,t.forEach(function(t,i){r[i]=e(t,n)}),r);default:return t}}},languages:{plain:Q3,plaintext:Q3,text:Q3,txt:Q3,extend:function(e,t){var n=$3.util.clone($3.languages[e]);for(var r in t)n[r]=t[r];return n},insertBefore:function(e,t,n,r){r||=$3.languages;var i=r[e],a={};for(var o in i)if(i.hasOwnProperty(o)){if(o==t)for(var s in n)n.hasOwnProperty(s)&&(a[s]=n[s]);n.hasOwnProperty(o)||(a[o]=i[o])}var c=r[e];return r[e]=a,$3.languages.DFS($3.languages,function(t,n){n===c&&t!=e&&(this[t]=a)}),a},DFS:function e(t,n,r,i){i||={};var a=$3.util.objId;for(var o in t)if(t.hasOwnProperty(o)){n.call(t,o,t[o],r||o);var s=t[o],c=$3.util.type(s);c===`Object`&&!i[a(s)]?(i[a(s)]=!0,e(s,n,null,i)):c===`Array`&&!i[a(s)]&&(i[a(s)]=!0,e(s,n,o,i))}}},plugins:{},highlight:function(e,t,n){var r={code:e,grammar:t,language:n};if($3.hooks.run(`before-tokenize`,r),!r.grammar)throw Error(`The language "`+r.language+`" has no grammar.`);return r.tokens=$3.tokenize(r.code,r.grammar),$3.hooks.run(`after-tokenize`,r),e6.stringify($3.util.encode(r.tokens),r.language)},tokenize:function(e,t){var n=t.rest;if(n){for(var r in n)t[r]=n[r];delete t.rest}var i=new r6;return i6(i,i.head,e),n6(e,i,t,i.head,0),o6(i)},hooks:{all:{},add:function(e,t){var n=$3.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=$3.hooks.all[e];if(!(!n||!n.length))for(var r=0,i;i=n[r++];)i(t)}},Token:e6};function e6(e,t,n,r){this.type=e,this.content=t,this.alias=n,this.length=(r||``).length|0}function t6(e,t,n,r){e.lastIndex=t;var i=e.exec(n);if(i&&r&&i[1]){var a=i[1].length;i.index+=a,i[0]=i[0].slice(a)}return i}function n6(e,t,n,r,i,a){for(var o in n)if(!(!n.hasOwnProperty(o)||!n[o])){var s=n[o];s=Array.isArray(s)?s:[s];for(var c=0;c<s.length;++c){if(a&&a.cause==o+`,`+c)return;var l=s[c],u=l.inside,d=!!l.lookbehind,f=!!l.greedy,p=l.alias;if(f&&!l.pattern.global){var m=l.pattern.toString().match(/[imsuy]*$/)[0];l.pattern=RegExp(l.pattern.source,m+`g`)}for(var h=l.pattern||l,g=r.next,_=i;g!==t.tail&&!(a&&_>=a.reach);_+=g.value.length,g=g.next){var v=g.value;if(t.length>e.length)return;if(!(v instanceof e6)){var y=1,b;if(f){if(b=t6(h,_,e,d),!b||b.index>=e.length)break;var x=b.index,S=b.index+b[0].length,C=_;for(C+=g.value.length;x>=C;)g=g.next,C+=g.value.length;if(C-=g.value.length,_=C,g.value instanceof e6)continue;for(var w=g;w!==t.tail&&(C<S||typeof w.value==`string`);w=w.next)y++,C+=w.value.length;y--,v=e.slice(_,C),b.index-=_}else if(b=t6(h,0,v,d),!b)continue;var x=b.index,T=b[0],E=v.slice(0,x),D=v.slice(x+T.length),O=_+v.length;a&&O>a.reach&&(a.reach=O);var k=g.prev;E&&(k=i6(t,k,E),_+=E.length),a6(t,k,y);var A=new e6(o,u?$3.tokenize(T,u):T,p,T);if(g=i6(t,k,A),D&&i6(t,g,D),y>1){var j={cause:o+`,`+c,reach:O};n6(e,t,n,g.prev,_,j),a&&j.reach>a.reach&&(a.reach=j.reach)}}}}}}function r6(){var e={value:null,prev:null,next:null},t={value:null,prev:e,next:null};e.next=t,this.head=e,this.tail=t,this.length=0}function i6(e,t,n){var r=t.next,i={value:n,prev:t,next:r};return t.next=i,r.prev=i,e.length++,i}function a6(e,t,n){for(var r=t.next,i=0;i<n&&r!==e.tail;i++)r=r.next;t.next=r,r.prev=t,e.length-=i}function o6(e){for(var t=[],n=e.head.next;n!==e.tail;)t.push(n.value),n=n.next;return t}var s6=$3;function c6(){}c6.prototype=s6;var l6=new c6;l6.highlight=u6,l6.register=d6,l6.alias=f6,l6.registered=p6,l6.listLanguages=m6,l6.util.encode=g6,l6.Token.stringify=h6;function u6(e,t){if(typeof e!=`string`)throw TypeError("Expected `string` for `value`, got `"+e+"`");let n,r;if(t&&typeof t==`object`)n=t;else{if(r=t,typeof r!=`string`)throw TypeError("Expected `string` for `name`, got `"+r+"`");if(Object.hasOwn(l6.languages,r))n=l6.languages[r];else throw Error("Unknown language: `"+r+"` is not registered")}return{type:`root`,children:s6.highlight.call(l6,e,n,r)}}function d6(e){if(typeof e!=`function`||!e.displayName)throw Error("Expected `function` for `syntax`, got `"+e+"`");Object.hasOwn(l6.languages,e.displayName)||e(l6)}function f6(e,t){let n=l6.languages,r={};typeof e==`string`?t&&(r[e]=t):r=e;let i;for(i in r)if(Object.hasOwn(r,i)){let e=r[i],t=typeof e==`string`?[e]:e,a=-1;for(;++a<t.length;)n[t[a]]=n[i]}}function p6(e){if(typeof e!=`string`)throw TypeError("Expected `string` for `aliasOrLanguage`, got `"+e+"`");return Object.hasOwn(l6.languages,e)}function m6(){let e=l6.languages,t=[],n;for(n in e)Object.hasOwn(e,n)&&typeof e[n]==`object`&&t.push(n);return t}function h6(e,t){if(typeof e==`string`)return{type:`text`,value:e};if(Array.isArray(e)){let n=[],r=-1;for(;++r<e.length;)e[r]!==null&&e[r]!==void 0&&e[r]!==``&&n.push(h6(e[r],t));return n}let n={attributes:{},classes:[`token`,e.type],content:h6(e.content,t),language:t,tag:`span`,type:e.type};return e.alias&&n.classes.push(...typeof e.alias==`string`?[e.alias]:e.alias),l6.hooks.run(`wrap`,n),Uk(n.tag+`.`+n.classes.join(`.`),_6(n.attributes),n.content)}function g6(e){return e}function _6(e){let t;for(t in e)Object.hasOwn(e,t)&&(e[t]=J3(e[t]));return e}var v6=B3(l6,{});v6.registerLanguage=function(e,t){return l6.register(t)},v6.alias=function(e,t){return l6.alias(e,t)},y6.displayName=`markup`,y6.aliases=[`atom`,`html`,`mathml`,`rss`,`ssml`,`svg`,`xml`];function y6(e){e.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:`attr-equals`},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:`named-entity`},/&#x?[\da-f]{1,8};/i]},e.languages.markup.tag.inside[`attr-value`].inside.entity=e.languages.markup.entity,e.languages.markup.doctype.inside[`internal-subset`].inside=e.languages.markup,e.hooks.add(`wrap`,function(e){e.type===`entity`&&(e.attributes.title=e.content.value.replace(/&/,`&`))}),Object.defineProperty(e.languages.markup.tag,"addInlined",{value:function(t,n){var r={};r[`language-`+n]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:e.languages[n]},r.cdata=/^<!\[CDATA\[|\]\]>$/i;var i={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:r}};i[`language-`+n]={pattern:/[\s\S]+/,inside:e.languages[n]};var a={};a[t]={pattern:RegExp(`(<__[^>]*>)(?:<!\\[CDATA\\[(?:[^\\]]|\\](?!\\]>))*\\]\\]>|(?!<!\\[CDATA\\[)[\\s\\S])*?(?=<\\/__>)`.replace(/__/g,function(){return t}),`i`),lookbehind:!0,greedy:!0,inside:i},e.languages.insertBefore(`markup`,`cdata`,a)}}),Object.defineProperty(e.languages.markup.tag,"addAttribute",{value:function(t,n){e.languages.markup.tag.inside[`special-attr`].push({pattern:RegExp(`(^|["'\\s])(?:`+t+`)\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s'">=]+(?=[\\s>]))`,`i`),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[n,`language-`+n],inside:e.languages[n]},punctuation:[{pattern:/^=/,alias:`attr-equals`},/"|'/]}}}})}}),e.languages.html=e.languages.markup,e.languages.mathml=e.languages.markup,e.languages.svg=e.languages.markup,e.languages.xml=e.languages.extend(`markup`,{}),e.languages.ssml=e.languages.xml,e.languages.atom=e.languages.xml,e.languages.rss=e.languages.xml}b6.displayName=`css`,b6.aliases=[];function b6(e){(function(e){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp(`@[\\w-](?:[^;{\\s"']|\\s+(?!\\s)|`+t.source+`)*?(?:;|(?=\\s*\\{))`),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:`selector`},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp(`\\burl\\((?:`+t.source+`|(?:[^\\\\\\r\\n()"']|\\\\[\\s\\S])*)\\)`,`i`),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp(`^`+t.source+`$`),alias:`url`}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+t.source+`)*(?=\\s*\\{)`),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var n=e.languages.markup;n&&(n.tag.addInlined(`style`,`css`),n.tag.addAttribute(`style`,`css`))})(e)}x6.displayName=`clike`,x6.aliases=[];function x6(e){e.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/}}S6.displayName=`javascript`,S6.aliases=[`js`];function S6(e){e.register(x6),e.languages.javascript=e.languages.extend(`clike`,{"class-name":[e.languages.clike[`class-name`],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(`(^|[^\\w$])(?:NaN|Infinity|0[bB][01]+(?:_[01]+)*n?|0[oO][0-7]+(?:_[0-7]+)*n?|0[xX][\\dA-Fa-f]+(?:_[\\dA-Fa-f]+)*n?|\\d+(?:_\\d+)*n|(?:\\d+(?:_\\d+)*(?:\\.(?:\\d+(?:_\\d+)*)?)?|\\.\\d+(?:_\\d+)*)(?:[Ee][+-]?\\d+(?:_\\d+)*)?)(?![\\w$])`),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),e.languages.javascript[`class-name`][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,e.languages.insertBefore(`javascript`,`keyword`,{regex:{pattern:RegExp(`((?:^|[^$\\w\\xA0-\\uFFFF."'\\])\\s]|\\b(?:return|yield))\\s*)\\/(?:(?:\\[(?:[^\\]\\\\\\r\\n]|\\\\.)*\\]|\\\\.|[^/\\\\\\[\\r\\n])+\\/[dgimyus]{0,7}|(?:\\[(?:[^[\\]\\\\\\r\\n]|\\\\.|\\[(?:[^[\\]\\\\\\r\\n]|\\\\.|\\[(?:[^[\\]\\\\\\r\\n]|\\\\.)*\\])*\\])*\\]|\\\\.|[^/\\\\\\[\\r\\n])+\\/[dgimyus]{0,7}v[dgimyus]{0,7})(?=(?:\\s|\\/\\*(?:[^*]|\\*(?!\\/))*\\*\\/)*(?:$|[\\r\\n,.;:})\\]]|\\/\\/))`),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:`language-regex`,inside:e.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:`function`},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:e.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:e.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:e.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:e.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),e.languages.insertBefore(`javascript`,`string`,{hashbang:{pattern:/^#!.*/,greedy:!0,alias:`comment`},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:`string`},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:`punctuation`},rest:e.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:`property`}}),e.languages.insertBefore(`javascript`,`operator`,{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:`property`}}),e.languages.markup&&(e.languages.markup.tag.addInlined(`script`,`javascript`),e.languages.markup.tag.addAttribute(`on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)`,`javascript`)),e.languages.js=e.languages.javascript}C6.displayName=`sql`,C6.aliases=[];function C6(e){e.languages.sql={comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,lookbehind:!0},variable:[{pattern:/@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,greedy:!0},/@[\w.$]+/],string:{pattern:/(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,greedy:!0,lookbehind:!0},identifier:{pattern:/(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,greedy:!0,lookbehind:!0,inside:{punctuation:/^`|`$/}},function:/\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,keyword:/\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,boolean:/\b(?:FALSE|NULL|TRUE)\b/i,number:/\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,operator:/[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,punctuation:/[;[\]()`,.]/}}w6.displayName=`c`,w6.aliases=[];function w6(e){e.register(x6),e.languages.c=e.languages.extend(`clike`,{comment:{pattern:/\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},string:{pattern:/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},"class-name":{pattern:/(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,lookbehind:!0},keyword:/\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,function:/\b[a-z_]\w*(?=\s*\()/i,number:/(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/}),e.languages.insertBefore(`c`,`string`,{char:{pattern:/'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,greedy:!0}}),e.languages.insertBefore(`c`,`string`,{macro:{pattern:/(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,lookbehind:!0,greedy:!0,alias:`property`,inside:{string:[{pattern:/^(#\s*include\s*)<[^>]+>/,lookbehind:!0},e.languages.c.string],char:e.languages.c.char,comment:e.languages.c.comment,"macro-name":[{pattern:/(^#\s*define\s+)\w+\b(?!\()/i,lookbehind:!0},{pattern:/(^#\s*define\s+)\w+\b(?=\()/i,lookbehind:!0,alias:`function`}],directive:{pattern:/^(#\s*)[a-z]+/,lookbehind:!0,alias:`keyword`},"directive-hash":/^#/,punctuation:/##|\\(?=[\r\n])/,expression:{pattern:/\S[\s\S]*/,inside:e.languages.c}}}}),e.languages.insertBefore(`c`,`function`,{constant:/\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/}),delete e.languages.c.boolean}T6.displayName=`cpp`,T6.aliases=[];function T6(e){e.register(w6),(function(e){var t=/\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,n=`\\b(?!<keyword>)\\w+(?:\\s*\\.\\s*\\w+)*\\b`.replace(/<keyword>/g,function(){return t.source});e.languages.cpp=e.languages.extend(`c`,{"class-name":[{pattern:RegExp(`(\\b(?:class|concept|enum|struct|typename)\\s+)(?!<keyword>)\\w+`.replace(/<keyword>/g,function(){return t.source})),lookbehind:!0},/\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,/\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,/\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/],keyword:t,number:{pattern:/(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,greedy:!0},operator:/>>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,boolean:/\b(?:false|true)\b/}),e.languages.insertBefore(`cpp`,`string`,{module:{pattern:RegExp(`(\\b(?:import|module)\\s+)(?:"(?:\\\\(?:\\r\\n|[\\s\\S])|[^"\\\\\\r\\n])*"|<[^<>\\r\\n]*>|`+`<mod-name>(?:\\s*:\\s*<mod-name>)?|:\\s*<mod-name>`.replace(/<mod-name>/g,function(){return n})+`)`),lookbehind:!0,greedy:!0,inside:{string:/^[<"][\s\S]+/,operator:/:/,punctuation:/\./}},"raw-string":{pattern:/R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,alias:`string`,greedy:!0}}),e.languages.insertBefore(`cpp`,`keyword`,{"generic-function":{pattern:/\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,inside:{function:/^\w+/,generic:{pattern:/<[\s\S]+/,alias:`class-name`,inside:e.languages.cpp}}}}),e.languages.insertBefore(`cpp`,`operator`,{"double-colon":{pattern:/::/,alias:`punctuation`}}),e.languages.insertBefore(`cpp`,`class-name`,{"base-clause":{pattern:/(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,lookbehind:!0,greedy:!0,inside:e.languages.extend(`cpp`,{})}}),e.languages.insertBefore(`inside`,`double-colon`,{"class-name":/\b[a-z_]\w*\b(?!\s*::)/i},e.languages.cpp[`base-clause`])})(e)}E6.displayName=`bash`,E6.aliases=[`sh`,`shell`];function E6(e){(function(e){var t=`\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b`,n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:`punctuation`,inside:null},r={bash:n,environment:{pattern:RegExp(`\\$`+t),alias:`constant`},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp(`(\\{)`+t),lookbehind:!0,alias:`constant`}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};e.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:`important`},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:`function`},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:`function`}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:`variable`,lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp(`(^|[\\s;|&]|[<>]\\()`+t),lookbehind:!0,alias:`constant`}},alias:`variable`,lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:`variable`,lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp(`\\$?`+t),alias:`constant`},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:`class-name`},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:`important`},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:`important`}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=e.languages.bash;for(var i=[`comment`,`function-name`,`for-or-select`,`assign-left`,`parameter`,`string`,`environment`,`function`,`keyword`,`builtin`,`boolean`,`file-descriptor`,`operator`,`punctuation`,`number`],a=r.variable[1].inside,o=0;o<i.length;o++)a[i[o]]=e.languages.bash[i[o]];e.languages.sh=e.languages.bash,e.languages.shell=e.languages.bash})(e)}D6.displayName=`yaml`,D6.aliases=[`yml`];function D6(e){(function(e){var t=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r=`(?:`+n.source+`(?:[ ]+`+t.source+`)?|`+t.source+`(?:[ ]+`+n.source+`)?)`,i=`(?:[^\\s\\x00-\\x08\\x0e-\\x1f!"#%&'*,\\-:>?@[\\]\`{|}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]|[?:-]<PLAIN>)(?:[ \\t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*`.replace(/<PLAIN>/g,function(){return`[^\\s\\x00-\\x08\\x0e-\\x1f,[\\]{}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]`}),a=`"(?:[^"\\\\\\r\\n]|\\\\.)*"|'(?:[^'\\\\\\r\\n]|\\\\.)*'`;function o(e,t){t=(t||``).replace(/m/g,``)+`m`;var n=`([:\\-,[{]\\s*(?:\\s<<prop>>[ \\t]+)?)(?:<<value>>)(?=[ \\t]*(?:$|,|\\]|\\}|(?:[\\r\\n]\\s*)?#))`.replace(/<<prop>>/g,function(){return r}).replace(/<<value>>/g,function(){return e});return RegExp(n,t)}e.languages.yaml={scalar:{pattern:RegExp(`([\\-:]\\s*(?:\\s<<prop>>[ \\t]+)?[|>])[ \\t]*(?:((?:\\r?\\n|\\r)[ \\t]+)\\S[^\\r\\n]*(?:\\2[^\\r\\n]+)*)`.replace(/<<prop>>/g,function(){return r})),lookbehind:!0,alias:`string`},comment:/#.*/,key:{pattern:RegExp(`((?:^|[:\\-,[{\\r\\n?])[ \\t]*(?:<<prop>>[ \\t]+)?)<<key>>(?=\\s*:\\s)`.replace(/<<prop>>/g,function(){return r}).replace(/<<key>>/g,function(){return`(?:`+i+`|`+a+`)`})),lookbehind:!0,greedy:!0,alias:`atrule`},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:`important`},datetime:{pattern:o(`\\d{4}-\\d\\d?-\\d\\d?(?:[tT]|[ \\t]+)\\d\\d?:\\d{2}:\\d{2}(?:\\.\\d*)?(?:[ \\t]*(?:Z|[-+]\\d\\d?(?::\\d{2})?))?|\\d{4}-\\d{2}-\\d{2}|\\d\\d?:\\d{2}(?::\\d{2}(?:\\.\\d*)?)?`),lookbehind:!0,alias:`number`},boolean:{pattern:o(`false|true`,`i`),lookbehind:!0,alias:`important`},null:{pattern:o(`null|~`,`i`),lookbehind:!0,alias:`important`},string:{pattern:o(a),lookbehind:!0,greedy:!0},number:{pattern:o(`[+-]?(?:0x[\\da-f]+|0o[0-7]+|(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+-]?\\d+)?|\\.inf|\\.nan)`,`i`),lookbehind:!0},tag:n,important:t,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},e.languages.yml=e.languages.yaml})(e)}O6.displayName=`markdown`,O6.aliases=[`md`];function O6(e){e.register(y6),(function(e){function t(e){return e=e.replace(/<inner>/g,function(){return`(?:\\\\.|[^\\\\\\n\\r]|(?:\\n|\\r\\n?)(?![\\r\\n]))`}),RegExp(`((?:^|[^\\\\])(?:\\\\{2})*)(?:`+e+`)`)}var n="(?:\\\\.|``(?:[^`\\r\\n]|`(?!`))+``|`[^`\\r\\n]+`|[^\\\\|\\r\\n`])+",r=`\\|?__(?:\\|__)+\\|?(?:(?:\\n|\\r\\n?)|(?![\\s\\S]))`.replace(/__/g,function(){return n}),i=`\\|?[ \\t]*:?-{3,}:?[ \\t]*(?:\\|[ \\t]*:?-{3,}:?[ \\t]*)+\\|?(?:\\n|\\r\\n?)`;e.languages.markdown=e.languages.extend(`markup`,{}),e.languages.insertBefore(`markdown`,`prolog`,{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:[`yaml`,`language-yaml`],inside:e.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:`punctuation`},table:{pattern:RegExp(`^`+r+i+`(?:`+r+`)*`,`m`),inside:{"table-data-rows":{pattern:RegExp(`^(`+r+i+`)(?:`+r+`)*$`),lookbehind:!0,inside:{"table-data":{pattern:RegExp(n),inside:e.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp(`^(`+r+`)`+i+`$`),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp(`^`+r+`$`),inside:{"table-header":{pattern:RegExp(n),alias:`important`,inside:e.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:`keyword`},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:`important`,inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:`important`,inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:`punctuation`},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:`punctuation`},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:`url`},bold:{pattern:t(`\\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\\b|\\*\\*(?:(?!\\*)<inner>|\\*(?:(?!\\*)<inner>)+\\*)+\\*\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:t(`\\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\\b|\\*(?:(?!\\*)<inner>|\\*\\*(?:(?!\\*)<inner>)+\\*\\*)+\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:t(`(~~?)(?:(?!~)<inner>)+\\2`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:[`code`,`keyword`]},url:{pattern:t(`!?\\[(?:(?!\\])<inner>)+\\](?:\\([^\\s)]+(?:[\\t ]+"(?:\\\\.|[^"\\\\])*")?\\)|[ \\t]?\\[(?:(?!\\])<inner>)+\\])`),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),[`url`,`bold`,`italic`,`strike`].forEach(function(t){[`url`,`bold`,`italic`,`strike`,`code-snippet`].forEach(function(n){t!==n&&(e.languages.markdown[t].inside.content.inside[n]=e.languages.markdown[n])})}),e.hooks.add(`after-tokenize`,function(e){if(e.language!==`markdown`&&e.language!==`md`)return;function t(e){if(!(!e||typeof e==`string`))for(var n=0,r=e.length;n<r;n++){var i=e[n];if(i.type!==`code`){t(i.content);continue}var a=i.content[1],o=i.content[3];if(a&&o&&a.type===`code-language`&&o.type===`code-block`&&typeof a.content==`string`){var s=a.content.replace(/\b#/g,`sharp`).replace(/\b\+\+/g,`pp`);s=(/[a-z][\w-]*/i.exec(s)||[``])[0].toLowerCase();var c=`language-`+s;o.alias?typeof o.alias==`string`?o.alias=[o.alias,c]:o.alias.push(c):o.alias=[c]}}}t(e.tokens)}),e.hooks.add(`wrap`,function(t){if(t.type===`code-block`){for(var n=``,r=0,i=t.classes.length;r<i;r++){var a=t.classes[r],o=/language-(.+)/.exec(a);if(o){n=o[1];break}}var s=e.languages[n];if(s)t.content=e.highlight(t.content.value,s,n);else if(n&&n!==`none`&&e.plugins.autoloader){var c=`md-`+new Date().valueOf()+`-`+Math.floor(Math.random()*0x2386f26fc10000);t.attributes.id=c,e.plugins.autoloader.loadLanguages(n,function(){var t=document.getElementById(c);t&&(t.innerHTML=e.highlight(t.textContent,e.languages[n],n))})}}}),RegExp(e.languages.markup.tag.pattern.source,`gi`),String.fromCodePoint||String.fromCharCode,e.languages.md=e.languages.markdown})(e)}k6.displayName=`csharp`,k6.aliases=[`cs`,`dotnet`];function k6(e){e.register(x6),(function(e){function t(e,t){return e.replace(/<<(\d+)>>/g,function(e,n){return`(?:`+t[+n]+`)`})}function n(e,n,r){return RegExp(t(e,n),r||``)}function r(e,t){for(var n=0;n<t;n++)e=e.replace(/<<self>>/g,function(){return`(?:`+e+`)`});return e.replace(/<<self>>/g,`[^\\s\\S]`)}var i={type:`bool byte char decimal double dynamic float int long object sbyte short string uint ulong ushort var void`,typeDeclaration:`class enum interface record struct`,contextual:`add alias and ascending async await by descending from(?=\\s*(?:\\w|$)) get global group into init(?=\\s*;) join let nameof not notnull on or orderby partial remove select set unmanaged value when where with(?=\\s*{)`,other:`abstract as base break case catch checked const continue default delegate do else event explicit extern finally fixed for foreach goto if implicit in internal is lock namespace new null operator out override params private protected public readonly ref return sealed sizeof stackalloc static switch this throw try typeof unchecked unsafe using virtual volatile while yield`};function a(e){return`\\b(?:`+e.trim().replace(/ /g,`|`)+`)\\b`}var o=a(i.typeDeclaration),s=RegExp(a(i.type+` `+i.typeDeclaration+` `+i.contextual+` `+i.other)),c=a(i.typeDeclaration+` `+i.contextual+` `+i.other),l=a(i.type+` `+i.typeDeclaration+` `+i.other),u=r(`<(?:[^<>;=+\\-*/%&|^]|<<self>>)*>`,2),d=r(`\\((?:[^()]|<<self>>)*\\)`,2),f=`@?\\b[A-Za-z_]\\w*\\b`,p=t(`<<0>>(?:\\s*<<1>>)?`,[f,u]),m=t(`(?!<<0>>)<<1>>(?:\\s*\\.\\s*<<1>>)*`,[c,p]),h=`\\[\\s*(?:,\\s*)*\\]`,g=t(`<<0>>(?:\\s*(?:\\?\\s*)?<<1>>)*(?:\\s*\\?)?`,[m,h]),_=t(`(?:<<0>>|<<1>>)(?:\\s*(?:\\?\\s*)?<<2>>)*(?:\\s*\\?)?`,[t(`\\(<<0>>+(?:,<<0>>+)+\\)`,[t(`[^,()<>[\\];=+\\-*/%&|^]|<<0>>|<<1>>|<<2>>`,[u,d,h])]),m,h]),v={keyword:s,punctuation:/[<>()?,.:[\]]/},y=`'(?:[^\\r\\n'\\\\]|\\\\.|\\\\[Uux][\\da-fA-F]{1,8})'`,b=`"(?:\\\\.|[^\\\\"\\r\\n])*"`,x=`@"(?:""|\\\\[\\s\\S]|[^\\\\"])*"(?!")`;e.languages.csharp=e.languages.extend(`clike`,{string:[{pattern:n(`(^|[^$\\\\])<<0>>`,[x]),lookbehind:!0,greedy:!0},{pattern:n(`(^|[^@$\\\\])<<0>>`,[b]),lookbehind:!0,greedy:!0}],"class-name":[{pattern:n(`(\\busing\\s+static\\s+)<<0>>(?=\\s*;)`,[m]),lookbehind:!0,inside:v},{pattern:n(`(\\busing\\s+<<0>>\\s*=\\s*)<<1>>(?=\\s*;)`,[f,_]),lookbehind:!0,inside:v},{pattern:n(`(\\busing\\s+)<<0>>(?=\\s*=)`,[f]),lookbehind:!0},{pattern:n(`(\\b<<0>>\\s+)<<1>>`,[o,p]),lookbehind:!0,inside:v},{pattern:n(`(\\bcatch\\s*\\(\\s*)<<0>>`,[m]),lookbehind:!0,inside:v},{pattern:n(`(\\bwhere\\s+)<<0>>`,[f]),lookbehind:!0},{pattern:n(`(\\b(?:is(?:\\s+not)?|as)\\s+)<<0>>`,[g]),lookbehind:!0,inside:v},{pattern:n(`\\b<<0>>(?=\\s+(?!<<1>>|with\\s*\\{)<<2>>(?:\\s*[=,;:{)\\]]|\\s+(?:in|when)\\b))`,[_,l,f]),inside:v}],keyword:s,number:/(?:\b0(?:x[\da-f_]*[\da-f]|b[01_]*[01])|(?:\B\.\d+(?:_+\d+)*|\b\d+(?:_+\d+)*(?:\.\d+(?:_+\d+)*)?)(?:e[-+]?\d+(?:_+\d+)*)?)(?:[dflmu]|lu|ul)?\b/i,operator:/>>=?|<<=?|[-=]>|([-+&|])\1|~|\?\?=?|[-+*/%&|^!=<>]=?/,punctuation:/\?\.?|::|[{}[\];(),.:]/}),e.languages.insertBefore(`csharp`,`number`,{range:{pattern:/\.\./,alias:`operator`}}),e.languages.insertBefore(`csharp`,`punctuation`,{"named-parameter":{pattern:n(`([(,]\\s*)<<0>>(?=\\s*:)`,[f]),lookbehind:!0,alias:`punctuation`}}),e.languages.insertBefore(`csharp`,`class-name`,{namespace:{pattern:n(`(\\b(?:namespace|using)\\s+)<<0>>(?:\\s*\\.\\s*<<0>>)*(?=\\s*[;{])`,[f]),lookbehind:!0,inside:{punctuation:/\./}},"type-expression":{pattern:n(`(\\b(?:default|sizeof|typeof)\\s*\\(\\s*(?!\\s))(?:[^()\\s]|\\s(?!\\s)|<<0>>)*(?=\\s*\\))`,[d]),lookbehind:!0,alias:`class-name`,inside:v},"return-type":{pattern:n(`<<0>>(?=\\s+(?:<<1>>\\s*(?:=>|[({]|\\.\\s*this\\s*\\[)|this\\s*\\[))`,[_,m]),inside:v,alias:`class-name`},"constructor-invocation":{pattern:n(`(\\bnew\\s+)<<0>>(?=\\s*[[({])`,[_]),lookbehind:!0,inside:v,alias:`class-name`},"generic-method":{pattern:n(`<<0>>\\s*<<1>>(?=\\s*\\()`,[f,u]),inside:{function:n(`^<<0>>`,[f]),generic:{pattern:RegExp(u),alias:`class-name`,inside:v}}},"type-list":{pattern:n(`\\b((?:<<0>>\\s+<<1>>|record\\s+<<1>>\\s*<<5>>|where\\s+<<2>>)\\s*:\\s*)(?:<<3>>|<<4>>|<<1>>\\s*<<5>>|<<6>>)(?:\\s*,\\s*(?:<<3>>|<<4>>|<<6>>))*(?=\\s*(?:where|[{;]|=>|$))`,[o,p,f,_,s.source,d,`\\bnew\\s*\\(\\s*\\)`]),lookbehind:!0,inside:{"record-arguments":{pattern:n(`(^(?!new\\s*\\()<<0>>\\s*)<<1>>`,[p,d]),lookbehind:!0,greedy:!0,inside:e.languages.csharp},keyword:s,"class-name":{pattern:RegExp(_),greedy:!0,inside:v},punctuation:/[,()]/}},preprocessor:{pattern:/(^[\t ]*)#.*/m,lookbehind:!0,alias:`property`,inside:{directive:{pattern:/(#)\b(?:define|elif|else|endif|endregion|error|if|line|nullable|pragma|region|undef|warning)\b/,lookbehind:!0,alias:`keyword`}}}});var S=b+`|`+y,C=t(`\\/(?![*/])|\\/\\/[^\\r\\n]*[\\r\\n]|\\/\\*(?:[^*]|\\*(?!\\/))*\\*\\/|<<0>>`,[S]),w=r(t(`[^"'/()]|<<0>>|\\(<<self>>*\\)`,[C]),2),T=`\\b(?:assembly|event|field|method|module|param|property|return|type)\\b`,E=t(`<<0>>(?:\\s*\\(<<1>>*\\))?`,[m,w]);e.languages.insertBefore(`csharp`,`class-name`,{attribute:{pattern:n(`((?:^|[^\\s\\w>)?])\\s*\\[\\s*)(?:<<0>>\\s*:\\s*)?<<1>>(?:\\s*,\\s*<<1>>)*(?=\\s*\\])`,[T,E]),lookbehind:!0,greedy:!0,inside:{target:{pattern:n(`^<<0>>(?=\\s*:)`,[T]),alias:`keyword`},"attribute-arguments":{pattern:n(`\\(<<0>>*\\)`,[w]),inside:e.languages.csharp},"class-name":{pattern:RegExp(m),inside:{punctuation:/\./}},punctuation:/[:,]/}}});var D=`:[^}\\r\\n]+`,O=r(t(`[^"'/()]|<<0>>|\\(<<self>>*\\)`,[C]),2),k=t(`\\{(?!\\{)(?:(?![}:])<<0>>)*<<1>>?\\}`,[O,D]),A=r(t(`[^"'/()]|\\/(?!\\*)|\\/\\*(?:[^*]|\\*(?!\\/))*\\*\\/|<<0>>|\\(<<self>>*\\)`,[S]),2),j=t(`\\{(?!\\{)(?:(?![}:])<<0>>)*<<1>>?\\}`,[A,D]);function M(t,r){return{interpolation:{pattern:n(`((?:^|[^{])(?:\\{\\{)*)<<0>>`,[t]),lookbehind:!0,inside:{"format-string":{pattern:n(`(^\\{(?:(?![}:])<<0>>)*)<<1>>(?=\\}$)`,[r,D]),lookbehind:!0,inside:{punctuation:/^:/}},punctuation:/^\{|\}$/,expression:{pattern:/[\s\S]+/,alias:`language-csharp`,inside:e.languages.csharp}}},string:/[\s\S]+/}}e.languages.insertBefore(`csharp`,`string`,{"interpolation-string":[{pattern:n(`(^|[^\\\\])(?:\\$@|@\\$)"(?:""|\\\\[\\s\\S]|\\{\\{|<<0>>|[^\\\\{"])*"`,[k]),lookbehind:!0,greedy:!0,inside:M(k,O)},{pattern:n(`(^|[^@\\\\])\\$"(?:\\\\.|\\{\\{|<<0>>|[^\\\\"{])*"`,[j]),lookbehind:!0,greedy:!0,inside:M(j,A)}],char:{pattern:RegExp(y),greedy:!0}}),e.languages.dotnet=e.languages.cs=e.languages.csharp})(e)}A6.displayName=`diff`,A6.aliases=[];function A6(e){(function(e){e.languages.diff={coord:[/^(?:\*{3}|-{3}|\+{3}).*$/m,/^@@.*@@$/m,/^\d.*$/m]};var t={"deleted-sign":`-`,"deleted-arrow":`<`,"inserted-sign":`+`,"inserted-arrow":`>`,unchanged:` `,diff:`!`};Object.keys(t).forEach(function(n){var r=t[n],i=[];/^\w+$/.test(n)||i.push(/\w+/.exec(n)[0]),n===`diff`&&i.push(`bold`),e.languages.diff[n]={pattern:RegExp(`^(?:[`+r+`].*(?:\r
|
|
467
467
|
?|
|
|
468
|
-
|(?![\\s\\S])))+`,`m`),alias:i,inside:{line:{pattern:/(.)(?=[\s\S]).*(?:\r\n?|\n)?/,lookbehind:!0},prefix:{pattern:/[\s\S]/,alias:/\w+/.exec(n)[0]}}}}),Object.defineProperty(e.languages.diff,"PREFIXES",{value:t})})(e)}k6.displayName=`docker`,k6.aliases=[`dockerfile`];function k6(e){(function(e){var t=`(?:[ \\t]+(?![ \\t])(?:<SP_BS>)?|<SP_BS>)`.replace(/<SP_BS>/g,function(){return`\\\\[\\r\\n](?:\\s|\\\\[\\r\\n]|#.*(?!.))*(?![\\s#]|\\\\[\\r\\n])`}),n=`"(?:[^"\\\\\\r\\n]|\\\\(?:\\r\\n|[\\s\\S]))*"|'(?:[^'\\\\\\r\\n]|\\\\(?:\\r\\n|[\\s\\S]))*'`,r=`--[\\w-]+=(?:<STR>|(?!["'])(?:[^\\s\\\\]|\\\\.)+)`.replace(/<STR>/g,function(){return n}),i={pattern:RegExp(n),greedy:!0},a={pattern:/(^[ \t]*)#.*/m,lookbehind:!0,greedy:!0};function o(e,n){return e=e.replace(/<OPT>/g,function(){return r}).replace(/<SP>/g,function(){return t}),RegExp(e,n)}e.languages.docker={instruction:{pattern:/(^[ \t]*)(?:ADD|ARG|CMD|COPY|ENTRYPOINT|ENV|EXPOSE|FROM|HEALTHCHECK|LABEL|MAINTAINER|ONBUILD|RUN|SHELL|STOPSIGNAL|USER|VOLUME|WORKDIR)(?=\s)(?:\\.|[^\r\n\\])*(?:\\$(?:\s|#.*$)*(?![\s#])(?:\\.|[^\r\n\\])*)*/im,lookbehind:!0,greedy:!0,inside:{options:{pattern:o(`(^(?:ONBUILD<SP>)?\\w+<SP>)<OPT>(?:<SP><OPT>)*`,`i`),lookbehind:!0,greedy:!0,inside:{property:{pattern:/(^|\s)--[\w-]+/,lookbehind:!0},string:[i,{pattern:/(=)(?!["'])(?:[^\s\\]|\\.)+/,lookbehind:!0}],operator:/\\$/m,punctuation:/=/}},keyword:[{pattern:o(`(^(?:ONBUILD<SP>)?HEALTHCHECK<SP>(?:<OPT><SP>)*)(?:CMD|NONE)\\b`,`i`),lookbehind:!0,greedy:!0},{pattern:o(`(^(?:ONBUILD<SP>)?FROM<SP>(?:<OPT><SP>)*(?!--)[^ \\t\\\\]+<SP>)AS`,`i`),lookbehind:!0,greedy:!0},{pattern:o(`(^ONBUILD<SP>)\\w+`,`i`),lookbehind:!0,greedy:!0},{pattern:/^\w+/,greedy:!0}],comment:a,string:i,variable:/\$(?:\w+|\{[^{}"'\\]*\})/,operator:/\\$/m}},comment:a},e.languages.dockerfile=e.languages.docker})(e)}A6.displayName=`go`,A6.aliases=[];function A6(e){e.register(y6),e.languages.go=e.languages.extend(`clike`,{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),e.languages.insertBefore(`go`,`string`,{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete e.languages.go[`class-name`]}j6.displayName=`scss`,j6.aliases=[];function j6(e){e.register(v6),e.languages.scss=e.languages.extend(`css`,{comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,lookbehind:!0},atrule:{pattern:/@[\w-](?:\([^()]+\)|[^()\s]|\s+(?!\s))*?(?=\s+[{;])/,inside:{rule:/@[\w-]+/}},url:/(?:[-a-z]+-)?url(?=\()/i,selector:{pattern:/(?=\S)[^@;{}()]?(?:[^@;{}()\s]|\s+(?!\s)|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}][^:{}]*[:{][^}]))/,inside:{parent:{pattern:/&/,alias:`important`},placeholder:/%[-\w]+/,variable:/\$[-\w]+|#\{\$[-\w]+\}/}},property:{pattern:/(?:[-\w]|\$[-\w]|#\{\$[-\w]+\})+(?=\s*:)/,inside:{variable:/\$[-\w]+|#\{\$[-\w]+\}/}}}),e.languages.insertBefore(`scss`,`atrule`,{keyword:[/@(?:content|debug|each|else(?: if)?|extend|for|forward|function|if|import|include|mixin|return|use|warn|while)\b/i,{pattern:/( )(?:from|through)(?= )/,lookbehind:!0}]}),e.languages.insertBefore(`scss`,`important`,{variable:/\$[-\w]+|#\{\$[-\w]+\}/}),e.languages.insertBefore(`scss`,`function`,{"module-modifier":{pattern:/\b(?:as|hide|show|with)\b/i,alias:`keyword`},placeholder:{pattern:/%[-\w]+/,alias:`selector`},statement:{pattern:/\B!(?:default|optional)\b/i,alias:`keyword`},boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:`keyword`},operator:{pattern:/(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|not|or)(?=\s)/,lookbehind:!0}}),e.languages.scss.atrule.inside.rest=e.languages.scss}M6.displayName=`json`,M6.aliases=[`webmanifest`];function M6(e){e.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:`keyword`}},e.languages.webmanifest=e.languages.json}N6.displayName=`java`,N6.aliases=[];function N6(e){e.register(y6),(function(e){var t=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=`(?:[a-z]\\w*\\s*\\.\\s*)*(?:[A-Z]\\w*\\s*\\.\\s*)*`,r={pattern:RegExp(`(^|[^\\w.])`+n+`[A-Z](?:[\\d_A-Z]*[a-z]\\w*)?\\b`),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};e.languages.java=e.languages.extend(`clike`,{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(`(^|[^\\w.])`+n+`[A-Z]\\w*(?=\\s+\\w+\\s*[;,=()]|\\s*(?:\\[[\\s,]*\\]\\s*)?::\\s*new\\b)`),lookbehind:!0,inside:r.inside},{pattern:RegExp(`(\\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\\s+)`+n+`[A-Z]\\w*\\b`),lookbehind:!0,inside:r.inside}],keyword:t,function:[e.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),e.languages.insertBefore(`java`,`string`,{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:`string`},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),e.languages.insertBefore(`java`,`class-name`,{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:`punctuation`},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:t,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(`(\\bimport\\s+)`+n+`(?:[A-Z]\\w*|\\*)(?=\\s*;)`),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(`(\\bimport\\s+static\\s+)`+n+`(?:\\w+|\\*)(?=\\s*;)`),lookbehind:!0,alias:`static`,inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(`(\\b(?:exports|import(?:\\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\\s+)(?!<keyword>)[a-z]\\w*(?:\\.[a-z]\\w*)*\\.?`.replace(/<keyword>/g,function(){return t.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(e)}P6.displayName=`typescript`,P6.aliases=[`ts`];function P6(e){e.register(b6),(function(e){e.languages.typescript=e.languages.extend(`javascript`,{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),e.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete e.languages.typescript.parameter,delete e.languages.typescript[`literal-property`];var t=e.languages.extend(`typescript`,{});delete t[`class-name`],e.languages.typescript[`class-name`].inside=t,e.languages.insertBefore(`typescript`,`function`,{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:`operator`},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:`class-name`,inside:t}}}}),e.languages.ts=e.languages.typescript})(e)}F6.displayName=`python`,F6.aliases=[`py`];function F6(e){e.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0},"string-interpolation":{pattern:/(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=\}$)/,lookbehind:!0},"conversion-option":{pattern://,alias:`punctuation`},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:`string`},string:{pattern:/(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^[\t ]*)@\w+(?:\.\w+)*/m,lookbehind:!0,alias:[`annotation`,`punctuation`],inside:{punctuation:/\./}},keyword:/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:False|None|True)\b/,number:/\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,operator:/[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},e.languages.python[`string-interpolation`].inside.interpolation.inside.rest=e.languages.python,e.languages.py=e.languages.python}I6.displayName=`jsx`,I6.aliases=[];function I6(e){e.register(b6),e.register(_6),(function(e){var t=e.util.clone(e.languages.javascript),n=`(?:\\s|\\/\\/.*(?!.)|\\/\\*(?:[^*]|\\*(?!\\/))\\*\\/)`,r=`(?:\\{(?:\\{(?:\\{[^{}]*\\}|[^{}])*\\}|[^{}])*\\})`,i=`(?:\\{<S>*\\.{3}(?:[^{}]|<BRACES>)*\\})`;function a(e,t){return e=e.replace(/<S>/g,function(){return n}).replace(/<BRACES>/g,function(){return r}).replace(/<SPREAD>/g,function(){return i}),RegExp(e,t)}i=a(i).source,e.languages.jsx=e.languages.extend(`markup`,t),e.languages.jsx.tag.pattern=a(`<\\/?(?:[\\w.:-]+(?:<S>+(?:[\\w.:$-]+(?:=(?:"(?:\\\\[\\s\\S]|[^\\\\"])*"|'(?:\\\\[\\s\\S]|[^\\\\'])*'|[^\\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\\/?)?>`),e.languages.jsx.tag.inside.tag.pattern=/^<\/?[^\s>\/]*/,e.languages.jsx.tag.inside[`attr-value`].pattern=/=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/,e.languages.jsx.tag.inside.tag.inside[`class-name`]=/^[A-Z]\w*(?:\.[A-Z]\w*)*$/,e.languages.jsx.tag.inside.comment=t.comment,e.languages.insertBefore(`inside`,`attr-name`,{spread:{pattern:a(`<SPREAD>`),inside:e.languages.jsx}},e.languages.jsx.tag),e.languages.insertBefore(`inside`,`special-attr`,{script:{pattern:a(`=<BRACES>`),alias:`language-javascript`,inside:{"script-punctuation":{pattern:/^=(?=\{)/,alias:`punctuation`},rest:e.languages.jsx}}},e.languages.jsx.tag);var o=function(e){return e?typeof e==`string`?e:typeof e.content==`string`?e.content:e.content.map(o).join(``):``},s=function(t){for(var n=[],r=0;r<t.length;r++){var i=t[r],a=!1;if(typeof i!=`string`&&(i.type===`tag`&&i.content[0]&&i.content[0].type===`tag`?i.content[0].content[0].content===`</`?n.length>0&&n[n.length-1].tagName===o(i.content[0].content[1])&&n.pop():i.content[i.content.length-1].content===`/>`||n.push({tagName:o(i.content[0].content[1]),openedBraces:0}):n.length>0&&i.type===`punctuation`&&i.content===`{`?n[n.length-1].openedBraces++:n.length>0&&n[n.length-1].openedBraces>0&&i.type===`punctuation`&&i.content===`}`?n[n.length-1].openedBraces--:a=!0),(a||typeof i==`string`)&&n.length>0&&n[n.length-1].openedBraces===0){var c=o(i);r<t.length-1&&(typeof t[r+1]==`string`||t[r+1].type===`plain-text`)&&(c+=o(t[r+1]),t.splice(r+1,1)),r>0&&(typeof t[r-1]==`string`||t[r-1].type===`plain-text`)&&(c=o(t[r-1])+c,t.splice(r-1,1),r--),t[r]=new e.Token(`plain-text`,c,null,c)}i.content&&typeof i.content!=`string`&&s(i.content)}};e.hooks.add(`after-tokenize`,function(e){(e.language===`jsx`||e.language===`tsx`)&&s(e.tokens)})})(e)}L6.displayName=`tsx`,L6.aliases=[];function L6(e){e.register(I6),e.register(P6),(function(e){var t=e.util.clone(e.languages.typescript);e.languages.tsx=e.languages.extend(`jsx`,t),delete e.languages.tsx.parameter,delete e.languages.tsx[`literal-property`];var n=e.languages.tsx.tag;n.pattern=RegExp(`(^|[^\\w$]|(?=<\\/))(?:`+n.pattern.source+`)`,n.pattern.flags),n.lookbehind=!0})(e)}R6.displayName=`rust`,R6.aliases=[];function R6(e){(function(e){for(var t=`\\/\\*(?:[^*/]|\\*(?!\\/)|\\/(?!\\*)|<self>)*\\*\\/`,n=0;n<2;n++)t=t.replace(/<self>/g,function(){return t});t=t.replace(/<self>/g,function(){return`[^\\s\\S]`}),e.languages.rust={comment:[{pattern:RegExp(`(^|[^\\\\])`+t),lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,greedy:!0},char:{pattern:/b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,greedy:!0},attribute:{pattern:/#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,greedy:!0,alias:`attr-name`,inside:{string:null}},"closure-params":{pattern:/([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,lookbehind:!0,greedy:!0,inside:{"closure-punctuation":{pattern:/^\||\|$/,alias:`punctuation`},rest:null}},"lifetime-annotation":{pattern:/'\w+/,alias:`symbol`},"fragment-specifier":{pattern:/(\$\w+:)[a-z]+/,lookbehind:!0,alias:`punctuation`},variable:/\$\w+/,"function-definition":{pattern:/(\bfn\s+)\w+/,lookbehind:!0,alias:`function`},"type-definition":{pattern:/(\b(?:enum|struct|trait|type|union)\s+)\w+/,lookbehind:!0,alias:`class-name`},"module-declaration":[{pattern:/(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,lookbehind:!0,alias:`namespace`},{pattern:/(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,lookbehind:!0,alias:`namespace`,inside:{punctuation:/::/}}],keyword:[/\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,/\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/],function:/\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,macro:{pattern:/\b\w+!/,alias:`property`},constant:/\b[A-Z_][A-Z_\d]+\b/,"class-name":/\b[A-Z]\w*\b/,namespace:{pattern:/(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,inside:{punctuation:/::/}},number:/\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,boolean:/\b(?:false|true)\b/,punctuation:/->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,operator:/[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/},e.languages.rust[`closure-params`].inside.rest=e.languages.rust,e.languages.rust.attribute.inside.string=e.languages.rust.string})(e)}var z6={'code[class*="language-"]':{color:`#393A34`,fontFamily:`"Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace`,direction:`ltr`,textAlign:`left`,whiteSpace:`pre`,wordSpacing:`normal`,wordBreak:`normal`,fontSize:`.9em`,lineHeight:`1.2em`,MozTabSize:`4`,OTabSize:`4`,tabSize:`4`,WebkitHyphens:`none`,MozHyphens:`none`,msHyphens:`none`,hyphens:`none`},'pre[class*="language-"]':{color:`#393A34`,fontFamily:`"Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace`,direction:`ltr`,textAlign:`left`,whiteSpace:`pre`,wordSpacing:`normal`,wordBreak:`normal`,fontSize:`.9em`,lineHeight:`1.2em`,MozTabSize:`4`,OTabSize:`4`,tabSize:`4`,WebkitHyphens:`none`,MozHyphens:`none`,msHyphens:`none`,hyphens:`none`,padding:`1em`,margin:`.5em 0`,overflow:`auto`,border:`1px solid #dddddd`,backgroundColor:`white`},'pre > code[class*="language-"]':{fontSize:`1em`},'pre[class*="language-"]::-moz-selection':{background:`#C1DEF1`},'pre[class*="language-"] ::-moz-selection':{background:`#C1DEF1`},'code[class*="language-"]::-moz-selection':{background:`#C1DEF1`},'code[class*="language-"] ::-moz-selection':{background:`#C1DEF1`},'pre[class*="language-"]::selection':{background:`#C1DEF1`},'pre[class*="language-"] ::selection':{background:`#C1DEF1`},'code[class*="language-"]::selection':{background:`#C1DEF1`},'code[class*="language-"] ::selection':{background:`#C1DEF1`},':not(pre) > code[class*="language-"]':{padding:`.2em`,paddingTop:`1px`,paddingBottom:`1px`,background:`#f8f8f8`,border:`1px solid #dddddd`},comment:{color:`#008000`,fontStyle:`italic`},prolog:{color:`#008000`,fontStyle:`italic`},doctype:{color:`#008000`,fontStyle:`italic`},cdata:{color:`#008000`,fontStyle:`italic`},namespace:{Opacity:`.7`},string:{color:`#A31515`},punctuation:{color:`#393A34`},operator:{color:`#393A34`},url:{color:`#36acaa`},symbol:{color:`#36acaa`},number:{color:`#36acaa`},boolean:{color:`#36acaa`},variable:{color:`#36acaa`},constant:{color:`#36acaa`},inserted:{color:`#36acaa`},atrule:{color:`#0000ff`},keyword:{color:`#0000ff`},"attr-value":{color:`#0000ff`},".language-autohotkey .token.selector":{color:`#0000ff`},".language-json .token.boolean":{color:`#0000ff`},".language-json .token.number":{color:`#0000ff`},'code[class*="language-css"]':{color:`#0000ff`},function:{color:`#393A34`},deleted:{color:`#9a050f`},".language-autohotkey .token.tag":{color:`#9a050f`},selector:{color:`#800000`},".language-autohotkey .token.keyword":{color:`#00009f`},important:{color:`#e90`,fontWeight:`bold`},bold:{fontWeight:`bold`},italic:{fontStyle:`italic`},"class-name":{color:`#2B91AF`},".language-json .token.property":{color:`#2B91AF`},tag:{color:`#800000`},"attr-name":{color:`#ff0000`},property:{color:`#ff0000`},regex:{color:`#ff0000`},entity:{color:`#ff0000`},"directive.tag.tag":{background:`#ffff00`,color:`#393A34`},".line-numbers.line-numbers .line-numbers-rows":{borderRightColor:`#a5a5a5`},".line-numbers .line-numbers-rows > span:before":{color:`#2B91AF`},".line-highlight.line-highlight":{background:`linear-gradient(to right, rgba(193, 222, 241, 0.2) 70%, rgba(221, 222, 241, 0))`}},B6={'pre[class*="language-"]':{color:`#d4d4d4`,fontSize:`13px`,textShadow:`none`,fontFamily:`Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace`,direction:`ltr`,textAlign:`left`,whiteSpace:`pre`,wordSpacing:`normal`,wordBreak:`normal`,lineHeight:`1.5`,MozTabSize:`4`,OTabSize:`4`,tabSize:`4`,WebkitHyphens:`none`,MozHyphens:`none`,msHyphens:`none`,hyphens:`none`,padding:`1em`,margin:`.5em 0`,overflow:`auto`,background:`#1e1e1e`},'code[class*="language-"]':{color:`#d4d4d4`,fontSize:`13px`,textShadow:`none`,fontFamily:`Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace`,direction:`ltr`,textAlign:`left`,whiteSpace:`pre`,wordSpacing:`normal`,wordBreak:`normal`,lineHeight:`1.5`,MozTabSize:`4`,OTabSize:`4`,tabSize:`4`,WebkitHyphens:`none`,MozHyphens:`none`,msHyphens:`none`,hyphens:`none`},'pre[class*="language-"]::selection':{textShadow:`none`,background:`#264F78`},'code[class*="language-"]::selection':{textShadow:`none`,background:`#264F78`},'pre[class*="language-"] *::selection':{textShadow:`none`,background:`#264F78`},'code[class*="language-"] *::selection':{textShadow:`none`,background:`#264F78`},':not(pre) > code[class*="language-"]':{padding:`.1em .3em`,borderRadius:`.3em`,color:`#db4c69`,background:`#1e1e1e`},".namespace":{Opacity:`.7`},"doctype.doctype-tag":{color:`#569CD6`},"doctype.name":{color:`#9cdcfe`},comment:{color:`#6a9955`},prolog:{color:`#6a9955`},punctuation:{color:`#d4d4d4`},".language-html .language-css .token.punctuation":{color:`#d4d4d4`},".language-html .language-javascript .token.punctuation":{color:`#d4d4d4`},property:{color:`#9cdcfe`},tag:{color:`#569cd6`},boolean:{color:`#569cd6`},number:{color:`#b5cea8`},constant:{color:`#9cdcfe`},symbol:{color:`#b5cea8`},inserted:{color:`#b5cea8`},unit:{color:`#b5cea8`},selector:{color:`#d7ba7d`},"attr-name":{color:`#9cdcfe`},string:{color:`#ce9178`},char:{color:`#ce9178`},builtin:{color:`#ce9178`},deleted:{color:`#ce9178`},".language-css .token.string.url":{textDecoration:`underline`},operator:{color:`#d4d4d4`},entity:{color:`#569cd6`},"operator.arrow":{color:`#569CD6`},atrule:{color:`#ce9178`},"atrule.rule":{color:`#c586c0`},"atrule.url":{color:`#9cdcfe`},"atrule.url.function":{color:`#dcdcaa`},"atrule.url.punctuation":{color:`#d4d4d4`},keyword:{color:`#569CD6`},"keyword.module":{color:`#c586c0`},"keyword.control-flow":{color:`#c586c0`},function:{color:`#dcdcaa`},"function.maybe-class-name":{color:`#dcdcaa`},regex:{color:`#d16969`},important:{color:`#569cd6`},italic:{fontStyle:`italic`},"class-name":{color:`#4ec9b0`},"maybe-class-name":{color:`#4ec9b0`},console:{color:`#9cdcfe`},parameter:{color:`#9cdcfe`},interpolation:{color:`#9cdcfe`},"punctuation.interpolation-punctuation":{color:`#569cd6`},variable:{color:`#9cdcfe`},"imports.maybe-class-name":{color:`#9cdcfe`},"exports.maybe-class-name":{color:`#9cdcfe`},escape:{color:`#d7ba7d`},"tag.punctuation":{color:`#808080`},cdata:{color:`#808080`},"attr-value":{color:`#ce9178`},"attr-value.punctuation":{color:`#ce9178`},"attr-value.punctuation.attr-equals":{color:`#d4d4d4`},namespace:{color:`#4ec9b0`},'pre[class*="language-javascript"]':{color:`#9cdcfe`},'code[class*="language-javascript"]':{color:`#9cdcfe`},'pre[class*="language-jsx"]':{color:`#9cdcfe`},'code[class*="language-jsx"]':{color:`#9cdcfe`},'pre[class*="language-typescript"]':{color:`#9cdcfe`},'code[class*="language-typescript"]':{color:`#9cdcfe`},'pre[class*="language-tsx"]':{color:`#9cdcfe`},'code[class*="language-tsx"]':{color:`#9cdcfe`},'pre[class*="language-css"]':{color:`#ce9178`},'code[class*="language-css"]':{color:`#ce9178`},'pre[class*="language-html"]':{color:`#d4d4d4`},'code[class*="language-html"]':{color:`#d4d4d4`},".language-regex .token.anchor":{color:`#dcdcaa`},".language-html .token.punctuation":{color:`#808080`},'pre[class*="language-"] > code[class*="language-"]':{position:`relative`,zIndex:`1`},".line-highlight.line-highlight":{background:`#f7ebc6`,boxShadow:`inset 5px 0 0 #f7d87c`,zIndex:`0`}},V6={bash:w6,c:S6,cpp:C6,csharp:D6,css:v6,diff:O6,docker:k6,go:A6,java:N6,javascript:b6,json:M6,jsx:I6,markdown:E6,markup:_6,python:F6,rust:R6,scss:j6,sql:x6,tsx:L6,typescript:P6,yaml:T6};for(let[e,t]of Object.entries(V6))g6.registerLanguage(e,t);var H6=.25,U6=.5,W6=3;function G6({code:e,isStreaming:t,defaultPreview:n=!1}){let{isDark:r}=Xn(),{t:i}=N(),[a,o]=(0,d.useState)(n),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(!1),f=`${r?`dark`:`light`}\n${e}`,p=a&&!t;(0,d.useEffect)(()=>{if(!p)return;let t=!1;return c({key:f,status:`loading`}),(async()=>{let{default:n}=await Z1(async()=>{let{default:e}=await import(`./mermaid.core-CqS5xRTZ.js`);return{default:e}},__vite__mapDeps([2,3,4,1,5,6,7,8,9,10,11,12,13,14,15,16,17]));if(n.initialize({startOnLoad:!1,securityLevel:`strict`,suppressErrorRendering:!0,theme:r?`dark`:`default`}),!await n.parse(e,{suppressErrors:!0}))throw Error(`Invalid Mermaid diagram`);let i=typeof crypto<`u`&&`randomUUID`in crypto?`mermaid-${crypto.randomUUID()}`:`mermaid-${Date.now()}-${Math.random().toString(36).slice(2)}`,a=await n.render(i,e);t||c({key:f,status:`ready`,svg:a.svg})})().catch(()=>{t||c({key:f,status:`error`})}),()=>{t=!0}},[e,f,r,p]);let m=(0,E.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),disabled:t,title:i(t?`i18n.previewAfterStreaming`:p?`i18n.showMermaidSource`:`i18n.previewMermaid`),className:[`markdown-code-action`,p?`is-active`:``].filter(Boolean).join(` `),children:i(p?`i18n.source`:`i18n.preview`)});if(!p)return(0,E.jsx)(Y6,{code:e,lang:`mermaid`,headerAction:m});let h=s?.key===f&&s.status===`error`?(0,E.jsx)(`div`,{className:`mermaid-block mermaid-block-error`,children:i(`i18n.invalidMermaid`)}):s?.key!==f||s.status!==`ready`?(0,E.jsx)(`div`,{className:`mermaid-block mermaid-block-loading`,"aria-label":i(`i18n.renderingMermaid`)}):(0,E.jsxs)(E.Fragment,{children:[!l&&(0,E.jsx)(`button`,{type:`button`,className:`mermaid-block mermaid-preview-button`,title:i(`i18n.openMermaidViewer`),"aria-label":i(`i18n.openMermaidViewer`),onClick:()=>u(!0),dangerouslySetInnerHTML:{__html:s.svg}}),l&&(0,E.jsx)(K6,{svg:s.svg,onClose:()=>u(!1)})]});return(0,E.jsxs)(`div`,{className:`markdown-code-block`,children:[(0,E.jsxs)(`div`,{className:`markdown-code-header`,children:[(0,E.jsx)(`span`,{className:`markdown-code-lang`,children:`mermaid`}),m]}),h]})}function K6({svg:e,onClose:t}){let{t:n}=N(),r=(0,d.useRef)(null),[i,a]=(0,d.useState)(1);return(0,d.useEffect)(()=>{let e=r.current;if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,e.showModal(),()=>{document.body.style.overflow=t,e.open&&e.close()}},[]),(0,E.jsx)(`dialog`,{ref:r,className:`mermaid-zoom-dialog`,"aria-label":n(`i18n.mermaidViewer`),onCancel:e=>{e.preventDefault(),t()},onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),t())},children:(0,E.jsxs)(`div`,{className:`mermaid-zoom-layout`,children:[(0,E.jsxs)(`div`,{className:`mermaid-zoom-toolbar`,children:[(0,E.jsx)(`span`,{className:`mermaid-zoom-title`,children:n(`i18n.mermaidDiagram`)}),(0,E.jsxs)(`div`,{className:`mermaid-zoom-actions`,children:[(0,E.jsxs)(`div`,{className:`mermaid-zoom-stepper`,children:[(0,E.jsx)(`button`,{type:`button`,onClick:()=>a(e=>Math.max(U6,e-H6)),disabled:i<=U6,title:n(`i18n.zoomOut`),"aria-label":n(`i18n.zoomOut`),children:(0,E.jsx)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M5 12h14`})})}),(0,E.jsxs)(`span`,{className:`mermaid-zoom-value`,children:[Math.round(i*100),`%`]}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>a(e=>Math.min(W6,e+H6)),disabled:i>=W6,title:n(`i18n.zoomIn`),"aria-label":n(`i18n.zoomIn`),children:(0,E.jsx)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M12 5v14M5 12h14`})})})]}),(0,E.jsx)(`button`,{type:`button`,className:`mermaid-zoom-icon-button`,onClick:()=>a(1),title:n(`i18n.fitToWidth`),"aria-label":n(`i18n.fitToWidth`),children:(0,E.jsx)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M8 3H3v5M16 3h5v5M8 21H3v-5M16 21h5v-5`})})}),(0,E.jsx)(`button`,{type:`button`,className:`mermaid-zoom-icon-button`,onClick:t,title:n(`i18n.close`),"aria-label":n(`i18n.close`),children:(0,E.jsx)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M6 6l12 12M18 6 6 18`})})})]})]}),(0,E.jsx)(`div`,{className:`mermaid-zoom-viewport`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,E.jsx)(`div`,{className:`mermaid-zoom-canvas`,style:{width:`${i*100}%`},dangerouslySetInnerHTML:{__html:e}})})]})})}var q6=5e3,J6=800;function Y6({code:e,lang:t,headerAction:n,isStreaming:r}){let{isDark:i}=Xn(),{t:a}=N(),[o,s]=(0,d.useState)(!1),c=()=>{vY(e).then(()=>{s(!0),setTimeout(()=>s(!1),1500)})},l=e.length>q6||r===!0&&e.length>J6;return(0,E.jsxs)(`div`,{className:`markdown-code-block`,children:[(0,E.jsxs)(`div`,{className:`markdown-code-header`,children:[(0,E.jsx)(`span`,{className:`markdown-code-lang`,children:t||`text`}),(0,E.jsxs)(`div`,{className:`markdown-code-actions`,children:[n,(0,E.jsx)(`button`,{onClick:c,className:`markdown-code-action`,children:a(o?`i18n.copied`:`i18n.copy`)})]})]}),l?(0,E.jsx)(`pre`,{className:`markdown-code-plain`,style:{margin:0,padding:`11px 13px`,fontSize:`var(--text-md)`,lineHeight:1.62,borderRadius:0,background:`color-mix(in srgb, var(--bg) 92%, var(--bg-panel))`,overflow:`auto`},children:(0,E.jsx)(`code`,{style:{fontFamily:`var(--font-mono)`},children:e})}):(0,E.jsx)(g6,{language:t||`text`,style:i?B6:z6,showLineNumbers:!0,lineNumberStyle:{color:`var(--text-dim)`,fontStyle:`normal`},customStyle:{margin:0,padding:`11px 13px`,fontSize:`var(--text-md)`,lineHeight:1.62,borderRadius:0,background:`color-mix(in srgb, var(--bg) 92%, var(--bg-panel))`},codeTagProps:{style:{fontFamily:`var(--font-mono)`}},children:e})]})}function X6({children:e,className:t,isStreaming:n,cwd:r,onOpenFile:i}){let{t:a}=N(),[o,s]=(0,d.useState)(!1),c=!o&&e.length>1e5,l=(0,d.useMemo)(()=>c?Q4(e):e,[c,e]),u=(0,d.useMemo)(()=>cG(l),[l]),f=(0,d.useMemo)(()=>({code({className:e,children:t,...r}){let i=e?.replace(`language-`,``).toLowerCase()??``,a=String(t);return e?.includes(`language-`)||a.includes(`
|
|
469
|
-
`)?i===`mermaid`?(0,E.jsx)(G6,{code:a.replace(/\n$/,``),isStreaming:n}):(0,E.jsx)(Y6,{code:a.replace(/\n$/,``),lang:i,isStreaming:n}):(0,E.jsx)(`code`,{className:`markdown-inline-code`,...r,children:t})},pre({children:e}){return(0,E.jsx)(E.Fragment,{children:e})},a({href:e,children:t,...n}){delete n.node;let a=i?HG(e,r):null,o=i;if(!a||!o)return(0,E.jsx)(`a`,{href:e,...n,target:`_blank`,rel:`noopener noreferrer`,children:t});let s=e=>{if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.currentTarget.getAttribute(`target`);t&&t!==`_self`||(e.preventDefault(),o(a))};return(0,E.jsx)(`a`,{href:e,...n,onClick:s,children:t})},img({src:e,alt:t,...n}){delete n.node;let i=typeof e==`string`?HG(e,r):null,a=i?`/api/files/${vG(i)}?type=read`:e;return(0,E.jsx)(`img`,{src:a,alt:t??``,loading:`lazy`,...n})},table({children:e}){return(0,E.jsx)(`div`,{className:`markdown-table-wrap`,children:(0,E.jsx)(`table`,{children:e})})},blockquote({children:e}){return(0,E.jsx)(`blockquote`,{children:e})}}),[r,n,i]);return(0,E.jsxs)(`div`,{className:[`markdown-body`,t].filter(Boolean).join(` `),style:{whiteSpace:`pre-wrap`},children:[(0,E.jsx)(q4,{remarkPlugins:fG??void 0,rehypePlugins:mG??void 0,components:f,children:u}),c&&(0,E.jsxs)(`button`,{type:`button`,"aria-label":a(`chat.expandMessage`),title:a(`chat.expandMessage`),onClick:()=>s(!0),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:6,width:`100%`,marginTop:6,padding:`5px 0`,border:`none`,borderTop:`1px solid var(--border)`,background:`var(--bg-subtle)`,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-base)`},children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,children:`…`}),(0,E.jsx)(`svg`,{width:p.base,height:p.base,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`m6 9 6 6 6-6`})})]})]})}var{min:Z6,max:Q6,abs:$6,floor:e8}=Math,t8=(e,t,n)=>Z6(n,Q6(t,e)),n8=e=>[...e].sort((e,t)=>e-t),r8=setTimeout,i8=typeof queueMicrotask==`function`?queueMicrotask:e=>{Promise.resolve().then(e)},a8=()=>{let e;return[new Promise(t=>{e=t}),e]},o8=e=>{let t;return()=>(e&&=(t=e(),void 0),t)},s8=typeof window<`u`,c8=e=>e.documentElement,l8=e=>e.ownerDocument,u8=e=>e.defaultView,d8=o8(()=>!!/iP(hone|od|ad)/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>0),f8=o8(()=>`scrollBehavior`in c8(document).style),p8=e=>Q6(e.t(),e.o()),m8=({i:e,l:t,u:n,h:r,v:i,S:a,t:o,$:s,m:c,p:l},u=0)=>{let d=!!l,f=!!u,p=1,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=null,C=[0,f?Q6(u-1,0):-1],w=0,T=!1,E=new Set,D=()=>g-h,O=()=>D()+v+_,k=(e,t)=>{let i=n(e)-v;return t?o()-i-r(e):i},A=e=>{e&&(d8()&&b!==0||S&&x===1?v+=e:_+=e)};return{_:()=>{E.clear()},I:()=>p,i:(t=200)=>{if(!T||f)return C;let n,r;if(y)[n,r]=C;else{let i=Q6(0,O()),a=i+m;d||(t=Q6(0,t),b!==1&&(i-=t),b!==2&&(a+=t)),[n,r]=C=e(Q6(0,i),Q6(0,a)),S&&(n=Z6(n,S[0]),r=Q6(r,S[1]))}return[Q6(n,0),Z6(r,s()-1)]},k:e=>t(e-h),R:a,u:k,h:r,C:s,T:()=>g,M:()=>b!==0,o:()=>m,O:()=>h,t:o,L:()=>(y=_,_=0,[y,x===2]),H:(e,t)=>{let n=[e,t];return E.add(n),()=>{E.delete(n)}},W:(n,s)=>{let u,C,j=0;switch(n){case 1:{if(s===g&&x===0)break;let e=y;y=0;let t=s-g,n=$6(t);e&&n<$6(e)+1||x!==0||(b=t<0?2:1),f&&=!1,g=s,j=4;let r=D();r>=-m&&r<=o()&&(j+=1,C=n>m);break}case 2:j=8,b!==0&&(u=!0,j+=1),b=0,x=0,S=null;break;case 3:{let e=s.filter(([e,t])=>!a(e,t));if(!e.length)break;A(e.reduce((e,[t,n])=>{let i;if(x===2)i=!0;else if(S&&x===1)i=t<S[0];else{let e=D(),n=k(t),a=r(t);i=b!==1&&x===0?n+a<=e:n<e&&n+a<e+m}return i&&(e+=n-r(t)),e},0));for(let[t,n]of e){let e=r(t),a=i(t,n);d&&(w+=a?n:n-e)}d&&m&&w>m&&(A(l(t(O()))),d=!1),j=3,C=!0;break}case 4:m!==s&&(m||(T=C=!0),m=s,j=3);break;case 5:s[1]?(A(c(s[0],!0)),x=2,j=1):(c(s[0]),j=1);break;case 6:h=s;break;case 7:x=1;break;case 8:S=e(s,s+m),j=1}j&&(p=1+(2147483647&p),u&&v&&(_+=v,v=0),E.forEach(([e,t])=>{j&e&&t(C)}))}}},h8=(e,t,n,r=0,i=t-1)=>{let a=r;for(;r<=i;){let t=e8((r+i)/2);e(t)<=n?(a=t,r=t+1):i=t-1}return t8(a,0,t-1)},g8=(e,t,n)=>{let r=n?`unshift`:`push`;for(let n=0;n<t;n++)e[r](-1);return e},_8=(e,t,n)=>{let r=n&&n[1]||t||40,i=-1,a=0,o=n&&n[0],s=o?g8(o.slice(0,Z6(e,o.length)),Q6(0,e-o.length)):g8([],e),c=g8([],e+1),l=e=>{let t=s[e];return t===-1?r:t},u=t=>{if(!e)return 0;if(i>=t)return c[t];i<0&&(c[0]=0,i=0);let n=i,r=c[n];for(;n<t;)r+=l(n),c[++n]=r;return i=t,r};return{i:(t,n)=>{let r,i;return a=Z6(a,e-1),u(a)<=t?(i=h8(u,e,n,a),r=h8(u,e,t,a,i)):(r=h8(u,e,t,void 0,a),i=h8(u,e,n,r)),a=r,[r,i]},l:t=>h8(u,e,t),u,h:l,v:(e,t)=>{let n=s[e]===-1;return s[e]=t,i=Z6(e,i),n},S:(e,t=-1)=>s[e]===t,t:()=>u(e),$:()=>e,m:(t,n)=>{let a=t-e;return i=n?-1:Z6(t-1,i),e=t,a>0?(g8(c,a),g8(s,a,n),r*a):(c.splice(a),(n?s.splice(0,-a):s.splice(a)).reduce((e,t)=>e-(t===-1?r:t),0))},p:t?void 0:e=>{let t=0,n=[];s.forEach((r,i)=>{r!==-1&&(r&&n.push(r),i<e&&t++)}),i=-1;let a=n8(n),o=a.length,c=o/2|0,l=o%2==0?(a[c-1]+a[c])/2:a[c],u=r;return((r=l)-u)*Q6(e-t,0)},B:()=>[s.slice(),r]}},v8=e=>{let t;return{X(n){(t||=new(u8(l8(n))).ResizeObserver(e)).observe(n)},Y(e){t.unobserve(e)},q(){t&&t.disconnect()}}},y8=(e,t)=>t?-e:e,b8=(e,t,n,r,i,a)=>{let o=Date.now,s=0,c=!1,l=!1,u=!1,d=!1,f=(()=>{let t,n=()=>{t!=null&&clearTimeout(t)},r=()=>{n(),t=r8(()=>{t=null,(()=>{if(c||l)return c=!1,void f();u=!1,e.W(2)})()},150)};return r.A=n,r})(),p=()=>{s=o(),u&&(d=!0),a&&e.W(6,a()),e.W(1,r()),f()},m=t=>{if(c||!e.M()||t.ctrlKey)return;let r=o()-s;150>r&&50<r&&(n?t.deltaX:t.deltaY)&&(c=!0)},h=()=>{l=!0,u=d=!1},g=()=>{l=!1,d8()&&(u=!0)};return t.addEventListener(`scroll`,p),t.addEventListener(`wheel`,m,{passive:!0}),t.addEventListener(`touchstart`,h,{passive:!0}),t.addEventListener(`touchend`,g,{passive:!0}),{q:()=>{t.removeEventListener(`scroll`,p),t.removeEventListener(`wheel`,m),t.removeEventListener(`touchstart`,h),t.removeEventListener(`touchend`,g),f.A()},D:()=>{let[t,n]=e.L();t&&(i(t,n,d),d=!1,n&&e.o()>e.t()&&e.W(1,r()))}}},x8=(e,t,n)=>{let r;return[async(i,a)=>{if(!await t())return;r&&r();let o=()=>{let[t,n]=a8();return r=()=>{n(!1)},e.o()&&r8(r,150),[t,e.H(2,()=>{n(!0)})]};if(a&&f8())e.W(8,i()),i8(async()=>{for(;;){let t=!0;for(let[n,r]=e.i();n<=r;n++)if(e.R(n)){t=!1;break}if(t)break;let[n,r]=o();try{if(!await n)return}finally{r()}}e.W(7),n(i(),a)});else for(;;){let[t,r]=o();try{if(e.W(7),n(i()),!await t)return}finally{r()}}},()=>{r&&r()}]},S8=(e,t)=>{let n,r,i=a8(),a=!1,o=t?`scrollLeft`:`scrollTop`,s=t?`overflowX`:`overflowY`,[c,l]=x8(e,()=>i[0],(e,r)=>{e=y8(e,a),r?n.scrollTo({[t?`left`:`top`]:e,behavior:`smooth`}):n[o]=e}),u=t?`width`:`height`,d=new WeakMap,f=v8(t=>{let r=[];for(let{target:i,contentRect:a}of t)if(i.offsetParent){if(i===n)e.W(4,a[u]);else{let e=d.get(i);e!=null&&r.push([e,a[u]])}}r.length&&e.W(3,r)});return{N(c,u=c.parentElement){f.X(n=u),t&&(a=getComputedStyle(u).direction===`rtl`),r=b8(e,u,t,()=>y8(u[o],a),(t,n,r)=>{if(r){let e=u.style,t=e[s];e[s]=`hidden`,r8(()=>{e[s]=t})}u[o]=y8(e.T()+t,a),n&&l()}),i[1](!0)},_(){f.q(),r&&r.q(),i[1](!1),i=a8()},P:(e,t)=>(d.set(e,t),f.X(e),()=>{d.delete(e),f.Y(e)}),V:()=>a,J:c,j(){r&&r.D()},G:e.O,U:()=>0}},C8=(e,t)=>{e.J(()=>t)},w8=(e,t,n,{align:r,smooth:i,offset:a=0}={})=>{if(n=t8(n,0,t.C()-1),r===`nearest`){let e=t.u(n),i=t.T();if(e<i)r=`start`;else{if(!(e+t.h(n)>i+t.o()))return;r=`end`}}e.J(()=>a+e.G()+t.u(n)+(r===`end`?t.h(n)-(t.o()-e.U()):r===`center`?(t.h(n)-(t.o()-e.U()))/2:0),i)},T8=s8?d.useLayoutEffect:d.useEffect,E8=`current`,D8=(e,t)=>{if(Array.isArray(e))for(let n of e)D8(n,t);else e==null||typeof e==`boolean`||t.push(e)},O8=(e,t)=>e.key??`_`+t,k8=e=>{let t=(0,d.useRef)(null);return t.current||=e()},A8=e=>{let t=(0,d.useRef)(e);return T8(()=>{t[E8]=e},[e]),t},j8=(0,d.memo)(({te:e,oe:t,ne:n,re:r,ie:i,se:a,le:o,ce:s})=>{let c=(0,d.useRef)(null);T8(()=>t(c[E8],n),[n]);let l=(0,d.useMemo)(()=>{let e={contain:`layout style`,position:i&&s?void 0:`absolute`,[o?`height`:`width`]:`100%`,[o?`top`:`left`]:0,[o?`left`:`top`]:r,visibility:!i||s?void 0:`hidden`};return o&&(e.display=`inline-flex`),e},[r,i,s,o]);return(0,E.jsx)(a,typeof a==`string`?{ref:c,style:l,children:e}:{ref:c,style:l,index:n,children:e})}),M8=(e,t)=>(0,d.useMemo)(()=>{if(typeof e==`function`)return[n=>e(t[n],n),t.length];let n=(e=>{let t=[];return D8(e,t),t})(e);return[e=>n[e],n.length]},[e,t]),N8=(0,d.forwardRef)(({children:e,data:t,bufferSize:n,itemSize:r,shift:i,horizontal:a,keepMounted:o,cache:s,startMargin:c=0,ssrCount:l,as:u=`div`,item:f=`div`,scrollRef:p,onScroll:m,onScrollEnd:h},g)=>{let[_,v]=M8(e,t),y=(0,d.useRef)(null),b=(0,d.useRef)(!!l),x=A8(m),S=A8(h),[C,w,T,D]=k8(()=>{let e=!!a,t=_8(v,r,s),n=m8(t,l);return[n,t,S8(n,e),e]});v!==C.C()&&C.W(5,[v,i]),c!==C.O()&&C.W(6,c);let[O,k]=(0,d.useReducer)(C.I,void 0,C.I),A=C.M(),j=C.t(),M=T.V(),N=[],P=e=>{let t=_(e);return(0,E.jsx)(j8,{oe:T.P,ne:e,re:C.u(e,M),ie:C.R(e),se:f,te:t,le:D,ce:b[E8]},O8(t,e))};if(T8(()=>{b[E8]=!1,C.H(1,e=>{e?(0,ii.flushSync)(k):k()}),C.H(4,()=>{x.current&&x.current(C.T())}),C.H(8,()=>{S.current&&S.current()});let e=y[E8];return p?i8(()=>{p.current&&T.N(e,p[E8])}):T.N(e),()=>{C._(),T._()}},[]),T8(()=>{T.j()},[O]),(0,d.useImperativeHandle)(g,()=>({get cache(){return w.B()},get scrollOffset(){return C.T()},get scrollSize(){return p8(C)},get viewportSize(){return C.o()},findItemIndex:C.k,getItemOffset:C.u,getItemSize:C.h,scrollToIndex:(e,t)=>w8(T,C,e,t),scrollTo:e=>C8(T,e),scrollBy:e=>((e,t,n)=>{C8(e,n+t.T())})(T,C,e)}),[]),o){let e=new Set(o);for(let[t,r]=C.i(n);t<=r;t++)e.add(t);n8([...e]).forEach(e=>{N.push(P(e))})}else for(let[e,t]=C.i(n);e<=t;e++)N.push(P(e));return(0,E.jsx)(u,{ref:y,style:{contain:`size style`,overflowAnchor:`none`,flex:`none`,position:`relative`,width:D?j:`100%`,height:D?`100%`:j,pointerEvents:A?`none`:void 0},children:N})}),P8=100,F8=new Map;function I8(e,t,n){let r=`${e}:${t}:${n}`,i=F8.get(r);if(i)return F8.delete(r),F8.set(r,i),i;let a=fetch(`/api/sessions/${encodeURIComponent(e)}/entries/${encodeURIComponent(t)}/thinking?blockIndex=${n}`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();if(typeof t.thinking!=`string`)throw Error(`Invalid thinking response`);return t.thinking}).catch(e=>{throw F8.delete(r),e});if(F8.set(r,a),F8.size>P8){let e=F8.keys().next().value;e&&F8.delete(e)}return a}function L8(e){if(!e)return null;let t=new Date(e),n=new Date,r=t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate(),i=t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});return r?i:`${t.toLocaleDateString([],{month:`short`,day:`numeric`,year:t.getFullYear()===n.getFullYear()?void 0:`numeric`})} ${i}`}function R8(e,t,n){if(t===n||e.role!==`assistant`)return!0;for(let r of e.content??[])if(r.type===`toolCall`&&t?.get(r.toolCallId)!==n?.get(r.toolCallId))return!1;return!0}var z8=(0,d.memo)(function({message:e,isStreaming:t,toolResults:n,modelNames:r,cwd:i,onOpenFile:a,entryId:o,onFork:s,forking:c,onNavigate:l,prevAssistantEntryId:u,onEditContent:d,showTimestamp:f,turnStartTimestamp:p,sessionId:m,streamingBashOutput:h,longBlockCollapseChars:g,recentExpandedBlockKeys:_,modelLabelVisible:v,turnNumber:y}){return e.role===`user`?(0,E.jsx)(B8,{message:e,entryId:o,onFork:s,forking:c,onNavigate:l,prevAssistantEntryId:u,onEditContent:d,turnNumber:y}):e.role===`assistant`?(0,E.jsx)(V8,{message:e,isStreaming:t,toolResults:n,modelNames:r,cwd:i,onOpenFile:a,showTimestamp:f,turnStartTimestamp:p,sessionId:m,entryId:o,longBlockCollapseChars:g,recentExpandedBlockKeys:_,modelLabelVisible:v,turnNumber:y}):e.role===`toolResult`?null:e.role===`custom`?e.customType===`compaction`?(0,E.jsx)(a5,{message:e}):(0,E.jsx)(c5,{message:e,cwd:i,onOpenFile:a}):e.role===`bashExecution`?(0,E.jsx)(_5,{message:e,sessionId:m,streamingOutput:h,longBlockCollapseChars:g}):null},(e,t)=>e.message===t.message&&e.isStreaming===t.isStreaming&&R8(e.message,e.toolResults,t.toolResults)&&e.modelNames===t.modelNames&&e.cwd===t.cwd&&e.onOpenFile===t.onOpenFile&&e.entryId===t.entryId&&e.onFork===t.onFork&&e.forking===t.forking&&e.onNavigate===t.onNavigate&&e.prevAssistantEntryId===t.prevAssistantEntryId&&e.onEditContent===t.onEditContent&&e.showTimestamp===t.showTimestamp&&e.sessionId===t.sessionId&&e.streamingBashOutput===t.streamingBashOutput&&e.modelLabelVisible===t.modelLabelVisible&&e.longBlockCollapseChars===t.longBlockCollapseChars&&e.recentExpandedBlockKeys===t.recentExpandedBlockKeys);function B8({message:e,entryId:t,onFork:n,forking:r,onNavigate:i,prevAssistantEntryId:a,onEditContent:o,turnNumber:s}){let{t:c}=N(),[l,u]=(0,d.useState)(!1),[f,m]=(0,d.useState)(!1),h=typeof e.content==`string`?e.content:e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
470
|
-
`),g=typeof e.content==`string`?[]:e.content.filter(e=>e.type===`image`),_=
|
|
471
|
-
`);return(0,d.useEffect)(()=>{if(!t)return;let e=setInterval(()=>{if(document.hidden)return;let e=k.current,t=e.map(({block:e})=>e),n=Date.now();e.forEach(({originalIndex:e})=>{A.current.has(e)||A.current.set(e,n)}),M(t=>{let r=!1,i=new Map(t);for(let t=0;t<e.length-1;t++){let a=e[t].originalIndex,o=e[t+1].originalIndex;if(!i.has(a)&&A.current.has(a)){let e=A.current.get(a),t=A.current.get(o)??n;i.set(a,Math.round((t-e)/1e3)),r=!0}}return r?i:t});let r=e[e.length-1];if(r&&r.block.type===`toolCall`){let e=A.current.get(r.originalIndex);e!==void 0&&M(t=>{let i=Math.round((n-e)/1e3);if(t.get(r.originalIndex)===i)return t;let a=new Map(t);return a.set(r.originalIndex,i),a})}let i=0;for(let e of t)e.type===`text`?i+=e.text?.length??0:e.type===`thinking`?i+=e.thinking?.length??0:e.type===`toolCall`&&(i+=JSON.stringify(e.input??{}).length);if(i===0)return;T.current===null&&(T.current=n);let a=(n-T.current)/1e3;a>.5&&O(i/4/a)},300);return()=>{clearInterval(e),T.current=null,O(null)}},[t]),y.length===0&&!t&&!b?null:(0,E.jsxs)(`div`,{style:{marginBottom:16},onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),children:[m&&(0,E.jsxs)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-dim)`,marginBottom:4,display:`flex`,alignItems:`center`,gap:6},children:[h!==void 0&&(0,E.jsx)(
|
|
472
|
-
`).trim():null,c=t?.isError??!1,l=s?.startsWith(`用户选择: `)?s.slice(6):null,u=l!==null&&o.some(e=>e.label===l);return(0,E.jsxs)(`div`,{style:{borderRadius:7,fontSize:`var(--text-base)`,border:c?`1px solid color-mix(in srgb, var(--status-error) 45%, transparent)`:`1px solid var(--border)`,background:c?`color-mix(in srgb, var(--status-error) 5%, transparent)`:`var(--bg-panel)`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:7,padding:`6px 10px`,color:`var(--text-muted)`,fontSize:`var(--text-sm)`},children:[(0,E.jsx)(`span`,{style:{color:c?`var(--status-error)`:`var(--status-info)`,fontFamily:`var(--font-mono)`,fontWeight:600,flexShrink:0},children:`pi_menu`}),(0,E.jsx)(`span`,{children:r(`chat.aiQuestion`)}),n!==void 0&&(0,E.jsxs)(`span`,{style:{marginLeft:`auto`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`,fontVariantNumeric:`tabular-nums`,flexShrink:0},children:[n,`s`]})]}),(0,E.jsxs)(`div`,{style:{padding:`8px 10px`,borderTop:`1px solid var(--border)`,fontSize:`var(--text-base)`,lineHeight:1.5,color:`var(--text-muted)`},children:[a&&(0,E.jsx)(`div`,{style:{fontWeight:600,color:`var(--text)`,marginBottom:6},children:a}),o.length>0&&(0,E.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:3,marginBottom:s&&!u?6:0},children:o.map((e,t)=>{let n=typeof e.label==`string`?e.label:String(e.label??`#${t+1}`),r=typeof e.description==`string`?e.description:null,i=l!==null&&n===l;return(0,E.jsxs)(`div`,{style:{display:`flex`,gap:6,alignItems:`baseline`},children:[(0,E.jsx)(`span`,{style:{color:i?`var(--accent)`:`var(--text-dim)`},children:i?`●`:`○`}),(0,E.jsx)(`span`,{style:{color:i?`var(--accent)`:`var(--text)`,fontWeight:i?600:400},children:n}),r&&(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`,fontSize:`var(--text-sm)`},children:r})]},t)})}),s&&!u&&(0,E.jsx)(`div`,{style:{color:c?`var(--status-error)`:`var(--text-muted)`,fontWeight:600,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:s})]})]})}function
|
|
468
|
+
|(?![\\s\\S])))+`,`m`),alias:i,inside:{line:{pattern:/(.)(?=[\s\S]).*(?:\r\n?|\n)?/,lookbehind:!0},prefix:{pattern:/[\s\S]/,alias:/\w+/.exec(n)[0]}}}}),Object.defineProperty(e.languages.diff,"PREFIXES",{value:t})})(e)}j6.displayName=`docker`,j6.aliases=[`dockerfile`];function j6(e){(function(e){var t=`(?:[ \\t]+(?![ \\t])(?:<SP_BS>)?|<SP_BS>)`.replace(/<SP_BS>/g,function(){return`\\\\[\\r\\n](?:\\s|\\\\[\\r\\n]|#.*(?!.))*(?![\\s#]|\\\\[\\r\\n])`}),n=`"(?:[^"\\\\\\r\\n]|\\\\(?:\\r\\n|[\\s\\S]))*"|'(?:[^'\\\\\\r\\n]|\\\\(?:\\r\\n|[\\s\\S]))*'`,r=`--[\\w-]+=(?:<STR>|(?!["'])(?:[^\\s\\\\]|\\\\.)+)`.replace(/<STR>/g,function(){return n}),i={pattern:RegExp(n),greedy:!0},a={pattern:/(^[ \t]*)#.*/m,lookbehind:!0,greedy:!0};function o(e,n){return e=e.replace(/<OPT>/g,function(){return r}).replace(/<SP>/g,function(){return t}),RegExp(e,n)}e.languages.docker={instruction:{pattern:/(^[ \t]*)(?:ADD|ARG|CMD|COPY|ENTRYPOINT|ENV|EXPOSE|FROM|HEALTHCHECK|LABEL|MAINTAINER|ONBUILD|RUN|SHELL|STOPSIGNAL|USER|VOLUME|WORKDIR)(?=\s)(?:\\.|[^\r\n\\])*(?:\\$(?:\s|#.*$)*(?![\s#])(?:\\.|[^\r\n\\])*)*/im,lookbehind:!0,greedy:!0,inside:{options:{pattern:o(`(^(?:ONBUILD<SP>)?\\w+<SP>)<OPT>(?:<SP><OPT>)*`,`i`),lookbehind:!0,greedy:!0,inside:{property:{pattern:/(^|\s)--[\w-]+/,lookbehind:!0},string:[i,{pattern:/(=)(?!["'])(?:[^\s\\]|\\.)+/,lookbehind:!0}],operator:/\\$/m,punctuation:/=/}},keyword:[{pattern:o(`(^(?:ONBUILD<SP>)?HEALTHCHECK<SP>(?:<OPT><SP>)*)(?:CMD|NONE)\\b`,`i`),lookbehind:!0,greedy:!0},{pattern:o(`(^(?:ONBUILD<SP>)?FROM<SP>(?:<OPT><SP>)*(?!--)[^ \\t\\\\]+<SP>)AS`,`i`),lookbehind:!0,greedy:!0},{pattern:o(`(^ONBUILD<SP>)\\w+`,`i`),lookbehind:!0,greedy:!0},{pattern:/^\w+/,greedy:!0}],comment:a,string:i,variable:/\$(?:\w+|\{[^{}"'\\]*\})/,operator:/\\$/m}},comment:a},e.languages.dockerfile=e.languages.docker})(e)}M6.displayName=`go`,M6.aliases=[];function M6(e){e.register(x6),e.languages.go=e.languages.extend(`clike`,{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),e.languages.insertBefore(`go`,`string`,{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete e.languages.go[`class-name`]}N6.displayName=`scss`,N6.aliases=[];function N6(e){e.register(b6),e.languages.scss=e.languages.extend(`css`,{comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,lookbehind:!0},atrule:{pattern:/@[\w-](?:\([^()]+\)|[^()\s]|\s+(?!\s))*?(?=\s+[{;])/,inside:{rule:/@[\w-]+/}},url:/(?:[-a-z]+-)?url(?=\()/i,selector:{pattern:/(?=\S)[^@;{}()]?(?:[^@;{}()\s]|\s+(?!\s)|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}][^:{}]*[:{][^}]))/,inside:{parent:{pattern:/&/,alias:`important`},placeholder:/%[-\w]+/,variable:/\$[-\w]+|#\{\$[-\w]+\}/}},property:{pattern:/(?:[-\w]|\$[-\w]|#\{\$[-\w]+\})+(?=\s*:)/,inside:{variable:/\$[-\w]+|#\{\$[-\w]+\}/}}}),e.languages.insertBefore(`scss`,`atrule`,{keyword:[/@(?:content|debug|each|else(?: if)?|extend|for|forward|function|if|import|include|mixin|return|use|warn|while)\b/i,{pattern:/( )(?:from|through)(?= )/,lookbehind:!0}]}),e.languages.insertBefore(`scss`,`important`,{variable:/\$[-\w]+|#\{\$[-\w]+\}/}),e.languages.insertBefore(`scss`,`function`,{"module-modifier":{pattern:/\b(?:as|hide|show|with)\b/i,alias:`keyword`},placeholder:{pattern:/%[-\w]+/,alias:`selector`},statement:{pattern:/\B!(?:default|optional)\b/i,alias:`keyword`},boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:`keyword`},operator:{pattern:/(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|not|or)(?=\s)/,lookbehind:!0}}),e.languages.scss.atrule.inside.rest=e.languages.scss}P6.displayName=`json`,P6.aliases=[`webmanifest`];function P6(e){e.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:`keyword`}},e.languages.webmanifest=e.languages.json}F6.displayName=`java`,F6.aliases=[];function F6(e){e.register(x6),(function(e){var t=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=`(?:[a-z]\\w*\\s*\\.\\s*)*(?:[A-Z]\\w*\\s*\\.\\s*)*`,r={pattern:RegExp(`(^|[^\\w.])`+n+`[A-Z](?:[\\d_A-Z]*[a-z]\\w*)?\\b`),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};e.languages.java=e.languages.extend(`clike`,{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(`(^|[^\\w.])`+n+`[A-Z]\\w*(?=\\s+\\w+\\s*[;,=()]|\\s*(?:\\[[\\s,]*\\]\\s*)?::\\s*new\\b)`),lookbehind:!0,inside:r.inside},{pattern:RegExp(`(\\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\\s+)`+n+`[A-Z]\\w*\\b`),lookbehind:!0,inside:r.inside}],keyword:t,function:[e.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),e.languages.insertBefore(`java`,`string`,{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:`string`},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),e.languages.insertBefore(`java`,`class-name`,{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:`punctuation`},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:t,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(`(\\bimport\\s+)`+n+`(?:[A-Z]\\w*|\\*)(?=\\s*;)`),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(`(\\bimport\\s+static\\s+)`+n+`(?:\\w+|\\*)(?=\\s*;)`),lookbehind:!0,alias:`static`,inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(`(\\b(?:exports|import(?:\\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\\s+)(?!<keyword>)[a-z]\\w*(?:\\.[a-z]\\w*)*\\.?`.replace(/<keyword>/g,function(){return t.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(e)}I6.displayName=`typescript`,I6.aliases=[`ts`];function I6(e){e.register(S6),(function(e){e.languages.typescript=e.languages.extend(`javascript`,{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),e.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete e.languages.typescript.parameter,delete e.languages.typescript[`literal-property`];var t=e.languages.extend(`typescript`,{});delete t[`class-name`],e.languages.typescript[`class-name`].inside=t,e.languages.insertBefore(`typescript`,`function`,{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:`operator`},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:`class-name`,inside:t}}}}),e.languages.ts=e.languages.typescript})(e)}L6.displayName=`python`,L6.aliases=[`py`];function L6(e){e.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0},"string-interpolation":{pattern:/(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=\}$)/,lookbehind:!0},"conversion-option":{pattern://,alias:`punctuation`},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:`string`},string:{pattern:/(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^[\t ]*)@\w+(?:\.\w+)*/m,lookbehind:!0,alias:[`annotation`,`punctuation`],inside:{punctuation:/\./}},keyword:/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:False|None|True)\b/,number:/\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,operator:/[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},e.languages.python[`string-interpolation`].inside.interpolation.inside.rest=e.languages.python,e.languages.py=e.languages.python}R6.displayName=`jsx`,R6.aliases=[];function R6(e){e.register(S6),e.register(y6),(function(e){var t=e.util.clone(e.languages.javascript),n=`(?:\\s|\\/\\/.*(?!.)|\\/\\*(?:[^*]|\\*(?!\\/))\\*\\/)`,r=`(?:\\{(?:\\{(?:\\{[^{}]*\\}|[^{}])*\\}|[^{}])*\\})`,i=`(?:\\{<S>*\\.{3}(?:[^{}]|<BRACES>)*\\})`;function a(e,t){return e=e.replace(/<S>/g,function(){return n}).replace(/<BRACES>/g,function(){return r}).replace(/<SPREAD>/g,function(){return i}),RegExp(e,t)}i=a(i).source,e.languages.jsx=e.languages.extend(`markup`,t),e.languages.jsx.tag.pattern=a(`<\\/?(?:[\\w.:-]+(?:<S>+(?:[\\w.:$-]+(?:=(?:"(?:\\\\[\\s\\S]|[^\\\\"])*"|'(?:\\\\[\\s\\S]|[^\\\\'])*'|[^\\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\\/?)?>`),e.languages.jsx.tag.inside.tag.pattern=/^<\/?[^\s>\/]*/,e.languages.jsx.tag.inside[`attr-value`].pattern=/=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/,e.languages.jsx.tag.inside.tag.inside[`class-name`]=/^[A-Z]\w*(?:\.[A-Z]\w*)*$/,e.languages.jsx.tag.inside.comment=t.comment,e.languages.insertBefore(`inside`,`attr-name`,{spread:{pattern:a(`<SPREAD>`),inside:e.languages.jsx}},e.languages.jsx.tag),e.languages.insertBefore(`inside`,`special-attr`,{script:{pattern:a(`=<BRACES>`),alias:`language-javascript`,inside:{"script-punctuation":{pattern:/^=(?=\{)/,alias:`punctuation`},rest:e.languages.jsx}}},e.languages.jsx.tag);var o=function(e){return e?typeof e==`string`?e:typeof e.content==`string`?e.content:e.content.map(o).join(``):``},s=function(t){for(var n=[],r=0;r<t.length;r++){var i=t[r],a=!1;if(typeof i!=`string`&&(i.type===`tag`&&i.content[0]&&i.content[0].type===`tag`?i.content[0].content[0].content===`</`?n.length>0&&n[n.length-1].tagName===o(i.content[0].content[1])&&n.pop():i.content[i.content.length-1].content===`/>`||n.push({tagName:o(i.content[0].content[1]),openedBraces:0}):n.length>0&&i.type===`punctuation`&&i.content===`{`?n[n.length-1].openedBraces++:n.length>0&&n[n.length-1].openedBraces>0&&i.type===`punctuation`&&i.content===`}`?n[n.length-1].openedBraces--:a=!0),(a||typeof i==`string`)&&n.length>0&&n[n.length-1].openedBraces===0){var c=o(i);r<t.length-1&&(typeof t[r+1]==`string`||t[r+1].type===`plain-text`)&&(c+=o(t[r+1]),t.splice(r+1,1)),r>0&&(typeof t[r-1]==`string`||t[r-1].type===`plain-text`)&&(c=o(t[r-1])+c,t.splice(r-1,1),r--),t[r]=new e.Token(`plain-text`,c,null,c)}i.content&&typeof i.content!=`string`&&s(i.content)}};e.hooks.add(`after-tokenize`,function(e){(e.language===`jsx`||e.language===`tsx`)&&s(e.tokens)})})(e)}z6.displayName=`tsx`,z6.aliases=[];function z6(e){e.register(R6),e.register(I6),(function(e){var t=e.util.clone(e.languages.typescript);e.languages.tsx=e.languages.extend(`jsx`,t),delete e.languages.tsx.parameter,delete e.languages.tsx[`literal-property`];var n=e.languages.tsx.tag;n.pattern=RegExp(`(^|[^\\w$]|(?=<\\/))(?:`+n.pattern.source+`)`,n.pattern.flags),n.lookbehind=!0})(e)}B6.displayName=`rust`,B6.aliases=[];function B6(e){(function(e){for(var t=`\\/\\*(?:[^*/]|\\*(?!\\/)|\\/(?!\\*)|<self>)*\\*\\/`,n=0;n<2;n++)t=t.replace(/<self>/g,function(){return t});t=t.replace(/<self>/g,function(){return`[^\\s\\S]`}),e.languages.rust={comment:[{pattern:RegExp(`(^|[^\\\\])`+t),lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,greedy:!0},char:{pattern:/b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,greedy:!0},attribute:{pattern:/#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,greedy:!0,alias:`attr-name`,inside:{string:null}},"closure-params":{pattern:/([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,lookbehind:!0,greedy:!0,inside:{"closure-punctuation":{pattern:/^\||\|$/,alias:`punctuation`},rest:null}},"lifetime-annotation":{pattern:/'\w+/,alias:`symbol`},"fragment-specifier":{pattern:/(\$\w+:)[a-z]+/,lookbehind:!0,alias:`punctuation`},variable:/\$\w+/,"function-definition":{pattern:/(\bfn\s+)\w+/,lookbehind:!0,alias:`function`},"type-definition":{pattern:/(\b(?:enum|struct|trait|type|union)\s+)\w+/,lookbehind:!0,alias:`class-name`},"module-declaration":[{pattern:/(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,lookbehind:!0,alias:`namespace`},{pattern:/(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,lookbehind:!0,alias:`namespace`,inside:{punctuation:/::/}}],keyword:[/\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,/\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/],function:/\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,macro:{pattern:/\b\w+!/,alias:`property`},constant:/\b[A-Z_][A-Z_\d]+\b/,"class-name":/\b[A-Z]\w*\b/,namespace:{pattern:/(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,inside:{punctuation:/::/}},number:/\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,boolean:/\b(?:false|true)\b/,punctuation:/->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,operator:/[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/},e.languages.rust[`closure-params`].inside.rest=e.languages.rust,e.languages.rust.attribute.inside.string=e.languages.rust.string})(e)}var V6={'code[class*="language-"]':{color:`#393A34`,fontFamily:`"Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace`,direction:`ltr`,textAlign:`left`,whiteSpace:`pre`,wordSpacing:`normal`,wordBreak:`normal`,fontSize:`.9em`,lineHeight:`1.2em`,MozTabSize:`4`,OTabSize:`4`,tabSize:`4`,WebkitHyphens:`none`,MozHyphens:`none`,msHyphens:`none`,hyphens:`none`},'pre[class*="language-"]':{color:`#393A34`,fontFamily:`"Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace`,direction:`ltr`,textAlign:`left`,whiteSpace:`pre`,wordSpacing:`normal`,wordBreak:`normal`,fontSize:`.9em`,lineHeight:`1.2em`,MozTabSize:`4`,OTabSize:`4`,tabSize:`4`,WebkitHyphens:`none`,MozHyphens:`none`,msHyphens:`none`,hyphens:`none`,padding:`1em`,margin:`.5em 0`,overflow:`auto`,border:`1px solid #dddddd`,backgroundColor:`white`},'pre > code[class*="language-"]':{fontSize:`1em`},'pre[class*="language-"]::-moz-selection':{background:`#C1DEF1`},'pre[class*="language-"] ::-moz-selection':{background:`#C1DEF1`},'code[class*="language-"]::-moz-selection':{background:`#C1DEF1`},'code[class*="language-"] ::-moz-selection':{background:`#C1DEF1`},'pre[class*="language-"]::selection':{background:`#C1DEF1`},'pre[class*="language-"] ::selection':{background:`#C1DEF1`},'code[class*="language-"]::selection':{background:`#C1DEF1`},'code[class*="language-"] ::selection':{background:`#C1DEF1`},':not(pre) > code[class*="language-"]':{padding:`.2em`,paddingTop:`1px`,paddingBottom:`1px`,background:`#f8f8f8`,border:`1px solid #dddddd`},comment:{color:`#008000`,fontStyle:`italic`},prolog:{color:`#008000`,fontStyle:`italic`},doctype:{color:`#008000`,fontStyle:`italic`},cdata:{color:`#008000`,fontStyle:`italic`},namespace:{Opacity:`.7`},string:{color:`#A31515`},punctuation:{color:`#393A34`},operator:{color:`#393A34`},url:{color:`#36acaa`},symbol:{color:`#36acaa`},number:{color:`#36acaa`},boolean:{color:`#36acaa`},variable:{color:`#36acaa`},constant:{color:`#36acaa`},inserted:{color:`#36acaa`},atrule:{color:`#0000ff`},keyword:{color:`#0000ff`},"attr-value":{color:`#0000ff`},".language-autohotkey .token.selector":{color:`#0000ff`},".language-json .token.boolean":{color:`#0000ff`},".language-json .token.number":{color:`#0000ff`},'code[class*="language-css"]':{color:`#0000ff`},function:{color:`#393A34`},deleted:{color:`#9a050f`},".language-autohotkey .token.tag":{color:`#9a050f`},selector:{color:`#800000`},".language-autohotkey .token.keyword":{color:`#00009f`},important:{color:`#e90`,fontWeight:`bold`},bold:{fontWeight:`bold`},italic:{fontStyle:`italic`},"class-name":{color:`#2B91AF`},".language-json .token.property":{color:`#2B91AF`},tag:{color:`#800000`},"attr-name":{color:`#ff0000`},property:{color:`#ff0000`},regex:{color:`#ff0000`},entity:{color:`#ff0000`},"directive.tag.tag":{background:`#ffff00`,color:`#393A34`},".line-numbers.line-numbers .line-numbers-rows":{borderRightColor:`#a5a5a5`},".line-numbers .line-numbers-rows > span:before":{color:`#2B91AF`},".line-highlight.line-highlight":{background:`linear-gradient(to right, rgba(193, 222, 241, 0.2) 70%, rgba(221, 222, 241, 0))`}},H6={'pre[class*="language-"]':{color:`#d4d4d4`,fontSize:`13px`,textShadow:`none`,fontFamily:`Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace`,direction:`ltr`,textAlign:`left`,whiteSpace:`pre`,wordSpacing:`normal`,wordBreak:`normal`,lineHeight:`1.5`,MozTabSize:`4`,OTabSize:`4`,tabSize:`4`,WebkitHyphens:`none`,MozHyphens:`none`,msHyphens:`none`,hyphens:`none`,padding:`1em`,margin:`.5em 0`,overflow:`auto`,background:`#1e1e1e`},'code[class*="language-"]':{color:`#d4d4d4`,fontSize:`13px`,textShadow:`none`,fontFamily:`Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace`,direction:`ltr`,textAlign:`left`,whiteSpace:`pre`,wordSpacing:`normal`,wordBreak:`normal`,lineHeight:`1.5`,MozTabSize:`4`,OTabSize:`4`,tabSize:`4`,WebkitHyphens:`none`,MozHyphens:`none`,msHyphens:`none`,hyphens:`none`},'pre[class*="language-"]::selection':{textShadow:`none`,background:`#264F78`},'code[class*="language-"]::selection':{textShadow:`none`,background:`#264F78`},'pre[class*="language-"] *::selection':{textShadow:`none`,background:`#264F78`},'code[class*="language-"] *::selection':{textShadow:`none`,background:`#264F78`},':not(pre) > code[class*="language-"]':{padding:`.1em .3em`,borderRadius:`.3em`,color:`#db4c69`,background:`#1e1e1e`},".namespace":{Opacity:`.7`},"doctype.doctype-tag":{color:`#569CD6`},"doctype.name":{color:`#9cdcfe`},comment:{color:`#6a9955`},prolog:{color:`#6a9955`},punctuation:{color:`#d4d4d4`},".language-html .language-css .token.punctuation":{color:`#d4d4d4`},".language-html .language-javascript .token.punctuation":{color:`#d4d4d4`},property:{color:`#9cdcfe`},tag:{color:`#569cd6`},boolean:{color:`#569cd6`},number:{color:`#b5cea8`},constant:{color:`#9cdcfe`},symbol:{color:`#b5cea8`},inserted:{color:`#b5cea8`},unit:{color:`#b5cea8`},selector:{color:`#d7ba7d`},"attr-name":{color:`#9cdcfe`},string:{color:`#ce9178`},char:{color:`#ce9178`},builtin:{color:`#ce9178`},deleted:{color:`#ce9178`},".language-css .token.string.url":{textDecoration:`underline`},operator:{color:`#d4d4d4`},entity:{color:`#569cd6`},"operator.arrow":{color:`#569CD6`},atrule:{color:`#ce9178`},"atrule.rule":{color:`#c586c0`},"atrule.url":{color:`#9cdcfe`},"atrule.url.function":{color:`#dcdcaa`},"atrule.url.punctuation":{color:`#d4d4d4`},keyword:{color:`#569CD6`},"keyword.module":{color:`#c586c0`},"keyword.control-flow":{color:`#c586c0`},function:{color:`#dcdcaa`},"function.maybe-class-name":{color:`#dcdcaa`},regex:{color:`#d16969`},important:{color:`#569cd6`},italic:{fontStyle:`italic`},"class-name":{color:`#4ec9b0`},"maybe-class-name":{color:`#4ec9b0`},console:{color:`#9cdcfe`},parameter:{color:`#9cdcfe`},interpolation:{color:`#9cdcfe`},"punctuation.interpolation-punctuation":{color:`#569cd6`},variable:{color:`#9cdcfe`},"imports.maybe-class-name":{color:`#9cdcfe`},"exports.maybe-class-name":{color:`#9cdcfe`},escape:{color:`#d7ba7d`},"tag.punctuation":{color:`#808080`},cdata:{color:`#808080`},"attr-value":{color:`#ce9178`},"attr-value.punctuation":{color:`#ce9178`},"attr-value.punctuation.attr-equals":{color:`#d4d4d4`},namespace:{color:`#4ec9b0`},'pre[class*="language-javascript"]':{color:`#9cdcfe`},'code[class*="language-javascript"]':{color:`#9cdcfe`},'pre[class*="language-jsx"]':{color:`#9cdcfe`},'code[class*="language-jsx"]':{color:`#9cdcfe`},'pre[class*="language-typescript"]':{color:`#9cdcfe`},'code[class*="language-typescript"]':{color:`#9cdcfe`},'pre[class*="language-tsx"]':{color:`#9cdcfe`},'code[class*="language-tsx"]':{color:`#9cdcfe`},'pre[class*="language-css"]':{color:`#ce9178`},'code[class*="language-css"]':{color:`#ce9178`},'pre[class*="language-html"]':{color:`#d4d4d4`},'code[class*="language-html"]':{color:`#d4d4d4`},".language-regex .token.anchor":{color:`#dcdcaa`},".language-html .token.punctuation":{color:`#808080`},'pre[class*="language-"] > code[class*="language-"]':{position:`relative`,zIndex:`1`},".line-highlight.line-highlight":{background:`#f7ebc6`,boxShadow:`inset 5px 0 0 #f7d87c`,zIndex:`0`}},U6={bash:E6,c:w6,cpp:T6,csharp:k6,css:b6,diff:A6,docker:j6,go:M6,java:F6,javascript:S6,json:P6,jsx:R6,markdown:O6,markup:y6,python:L6,rust:B6,scss:N6,sql:C6,tsx:z6,typescript:I6,yaml:D6};for(let[e,t]of Object.entries(U6))v6.registerLanguage(e,t);var W6=.25,G6=.5,K6=3;function q6({code:e,isStreaming:t,defaultPreview:n=!1}){let{isDark:r}=Xn(),{t:i}=N(),[a,o]=(0,d.useState)(n),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(!1),f=`${r?`dark`:`light`}\n${e}`,p=a&&!t;(0,d.useEffect)(()=>{if(!p)return;let t=!1;return c({key:f,status:`loading`}),(async()=>{let{default:n}=await $1(async()=>{let{default:e}=await import(`./mermaid.core-B5Pfvt4i.js`);return{default:e}},__vite__mapDeps([2,3,4,1,5,6,7,8,9,10,11,12,13,14,15,16,17]));if(n.initialize({startOnLoad:!1,securityLevel:`strict`,suppressErrorRendering:!0,theme:r?`dark`:`default`}),!await n.parse(e,{suppressErrors:!0}))throw Error(`Invalid Mermaid diagram`);let i=typeof crypto<`u`&&`randomUUID`in crypto?`mermaid-${crypto.randomUUID()}`:`mermaid-${Date.now()}-${Math.random().toString(36).slice(2)}`,a=await n.render(i,e);t||c({key:f,status:`ready`,svg:a.svg})})().catch(()=>{t||c({key:f,status:`error`})}),()=>{t=!0}},[e,f,r,p]);let m=(0,E.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),disabled:t,title:i(t?`i18n.previewAfterStreaming`:p?`i18n.showMermaidSource`:`i18n.previewMermaid`),className:[`markdown-code-action`,p?`is-active`:``].filter(Boolean).join(` `),children:i(p?`i18n.source`:`i18n.preview`)});if(!p)return(0,E.jsx)(Z6,{code:e,lang:`mermaid`,headerAction:m});let h=s?.key===f&&s.status===`error`?(0,E.jsx)(`div`,{className:`mermaid-block mermaid-block-error`,children:i(`i18n.invalidMermaid`)}):s?.key!==f||s.status!==`ready`?(0,E.jsx)(`div`,{className:`mermaid-block mermaid-block-loading`,"aria-label":i(`i18n.renderingMermaid`)}):(0,E.jsxs)(E.Fragment,{children:[!l&&(0,E.jsx)(`button`,{type:`button`,className:`mermaid-block mermaid-preview-button`,title:i(`i18n.openMermaidViewer`),"aria-label":i(`i18n.openMermaidViewer`),onClick:()=>u(!0),dangerouslySetInnerHTML:{__html:s.svg}}),l&&(0,E.jsx)(J6,{svg:s.svg,onClose:()=>u(!1)})]});return(0,E.jsxs)(`div`,{className:`markdown-code-block`,children:[(0,E.jsxs)(`div`,{className:`markdown-code-header`,children:[(0,E.jsx)(`span`,{className:`markdown-code-lang`,children:`mermaid`}),m]}),h]})}function J6({svg:e,onClose:t}){let{t:n}=N(),r=(0,d.useRef)(null),[i,a]=(0,d.useState)(1);return(0,d.useEffect)(()=>{let e=r.current;if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,e.showModal(),()=>{document.body.style.overflow=t,e.open&&e.close()}},[]),(0,E.jsx)(`dialog`,{ref:r,className:`mermaid-zoom-dialog`,"aria-label":n(`i18n.mermaidViewer`),onCancel:e=>{e.preventDefault(),t()},onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),t())},children:(0,E.jsxs)(`div`,{className:`mermaid-zoom-layout`,children:[(0,E.jsxs)(`div`,{className:`mermaid-zoom-toolbar`,children:[(0,E.jsx)(`span`,{className:`mermaid-zoom-title`,children:n(`i18n.mermaidDiagram`)}),(0,E.jsxs)(`div`,{className:`mermaid-zoom-actions`,children:[(0,E.jsxs)(`div`,{className:`mermaid-zoom-stepper`,children:[(0,E.jsx)(`button`,{type:`button`,onClick:()=>a(e=>Math.max(G6,e-W6)),disabled:i<=G6,title:n(`i18n.zoomOut`),"aria-label":n(`i18n.zoomOut`),children:(0,E.jsx)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M5 12h14`})})}),(0,E.jsxs)(`span`,{className:`mermaid-zoom-value`,children:[Math.round(i*100),`%`]}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>a(e=>Math.min(K6,e+W6)),disabled:i>=K6,title:n(`i18n.zoomIn`),"aria-label":n(`i18n.zoomIn`),children:(0,E.jsx)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M12 5v14M5 12h14`})})})]}),(0,E.jsx)(`button`,{type:`button`,className:`mermaid-zoom-icon-button`,onClick:()=>a(1),title:n(`i18n.fitToWidth`),"aria-label":n(`i18n.fitToWidth`),children:(0,E.jsx)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M8 3H3v5M16 3h5v5M8 21H3v-5M16 21h5v-5`})})}),(0,E.jsx)(`button`,{type:`button`,className:`mermaid-zoom-icon-button`,onClick:t,title:n(`i18n.close`),"aria-label":n(`i18n.close`),children:(0,E.jsx)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M6 6l12 12M18 6 6 18`})})})]})]}),(0,E.jsx)(`div`,{className:`mermaid-zoom-viewport`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,E.jsx)(`div`,{className:`mermaid-zoom-canvas`,style:{width:`${i*100}%`},dangerouslySetInnerHTML:{__html:e}})})]})})}var Y6=5e3,X6=800;function Z6({code:e,lang:t,headerAction:n,isStreaming:r}){let{isDark:i}=Xn(),{t:a}=N(),[o,s]=(0,d.useState)(!1),c=()=>{bY(e).then(()=>{s(!0),setTimeout(()=>s(!1),1500)})},l=e.length>Y6||r===!0&&e.length>X6;return(0,E.jsxs)(`div`,{className:`markdown-code-block`,children:[(0,E.jsxs)(`div`,{className:`markdown-code-header`,children:[(0,E.jsx)(`span`,{className:`markdown-code-lang`,children:t||`text`}),(0,E.jsxs)(`div`,{className:`markdown-code-actions`,children:[n,(0,E.jsx)(`button`,{onClick:c,className:`markdown-code-action`,children:a(o?`i18n.copied`:`i18n.copy`)})]})]}),l?(0,E.jsx)(`pre`,{className:`markdown-code-plain`,style:{margin:0,padding:`11px 13px`,fontSize:`var(--text-md)`,lineHeight:1.62,borderRadius:0,background:`color-mix(in srgb, var(--bg) 92%, var(--bg-panel))`,overflow:`auto`},children:(0,E.jsx)(`code`,{style:{fontFamily:`var(--font-mono)`},children:e})}):(0,E.jsx)(v6,{language:t||`text`,style:i?H6:V6,showLineNumbers:!0,lineNumberStyle:{color:`var(--text-dim)`,fontStyle:`normal`},customStyle:{margin:0,padding:`11px 13px`,fontSize:`var(--text-md)`,lineHeight:1.62,borderRadius:0,background:`color-mix(in srgb, var(--bg) 92%, var(--bg-panel))`},codeTagProps:{style:{fontFamily:`var(--font-mono)`}},children:e})]})}function Q6({children:e,className:t,isStreaming:n,cwd:r,onOpenFile:i}){let{t:a}=N(),[o,s]=(0,d.useState)(!1),c=!o&&e.length>1e5,l=(0,d.useMemo)(()=>c?e3(e):e,[c,e]),u=(0,d.useMemo)(()=>cG(l),[l]),f=(0,d.useMemo)(()=>({code({className:e,children:t,...r}){let i=e?.replace(`language-`,``).toLowerCase()??``,a=String(t);return e?.includes(`language-`)||a.includes(`
|
|
469
|
+
`)?i===`mermaid`?(0,E.jsx)(q6,{code:a.replace(/\n$/,``),isStreaming:n}):(0,E.jsx)(Z6,{code:a.replace(/\n$/,``),lang:i,isStreaming:n}):(0,E.jsx)(`code`,{className:`markdown-inline-code`,...r,children:t})},pre({children:e}){return(0,E.jsx)(E.Fragment,{children:e})},a({href:e,children:t,...n}){delete n.node;let a=i?HG(e,r):null,o=i;if(!a||!o)return(0,E.jsx)(`a`,{href:e,...n,target:`_blank`,rel:`noopener noreferrer`,children:t});let s=e=>{if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.currentTarget.getAttribute(`target`);t&&t!==`_self`||(e.preventDefault(),o(a))};return(0,E.jsx)(`a`,{href:e,...n,onClick:s,children:t})},img({src:e,alt:t,...n}){delete n.node;let i=typeof e==`string`?HG(e,r):null,a=i?`/api/files/${vG(i)}?type=read`:e;return(0,E.jsx)(`img`,{src:a,alt:t??``,loading:`lazy`,...n})},table({children:e}){return(0,E.jsx)(`div`,{className:`markdown-table-wrap`,children:(0,E.jsx)(`table`,{children:e})})},blockquote({children:e}){return(0,E.jsx)(`blockquote`,{children:e})}}),[r,n,i]);return(0,E.jsxs)(`div`,{className:[`markdown-body`,t].filter(Boolean).join(` `),style:{whiteSpace:`pre-wrap`},children:[(0,E.jsx)(Y4,{remarkPlugins:fG??void 0,rehypePlugins:mG??void 0,components:f,children:u}),c&&(0,E.jsxs)(`button`,{type:`button`,"aria-label":a(`chat.expandMessage`),title:a(`chat.expandMessage`),onClick:()=>s(!0),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:6,width:`100%`,marginTop:6,padding:`5px 0`,border:`none`,borderTop:`1px solid var(--border)`,background:`var(--bg-subtle)`,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-base)`},children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,children:`…`}),(0,E.jsx)(`svg`,{width:p.base,height:p.base,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`m6 9 6 6 6-6`})})]})]})}var{min:$6,max:e8,abs:t8,floor:n8}=Math,r8=(e,t,n)=>$6(n,e8(t,e)),i8=e=>[...e].sort((e,t)=>e-t),a8=setTimeout,o8=typeof queueMicrotask==`function`?queueMicrotask:e=>{Promise.resolve().then(e)},s8=()=>{let e;return[new Promise(t=>{e=t}),e]},c8=e=>{let t;return()=>(e&&=(t=e(),void 0),t)},l8=typeof window<`u`,u8=e=>e.documentElement,d8=e=>e.ownerDocument,f8=e=>e.defaultView,p8=c8(()=>!!/iP(hone|od|ad)/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>0),m8=c8(()=>`scrollBehavior`in u8(document).style),h8=e=>e8(e.t(),e.o()),g8=({i:e,l:t,u:n,h:r,v:i,S:a,t:o,$:s,m:c,p:l},u=0)=>{let d=!!l,f=!!u,p=1,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=null,C=[0,f?e8(u-1,0):-1],w=0,T=!1,E=new Set,D=()=>g-h,O=()=>D()+v+_,k=(e,t)=>{let i=n(e)-v;return t?o()-i-r(e):i},A=e=>{e&&(p8()&&b!==0||S&&x===1?v+=e:_+=e)};return{_:()=>{E.clear()},I:()=>p,i:(t=200)=>{if(!T||f)return C;let n,r;if(y)[n,r]=C;else{let i=e8(0,O()),a=i+m;d||(t=e8(0,t),b!==1&&(i-=t),b!==2&&(a+=t)),[n,r]=C=e(e8(0,i),e8(0,a)),S&&(n=$6(n,S[0]),r=e8(r,S[1]))}return[e8(n,0),$6(r,s()-1)]},k:e=>t(e-h),R:a,u:k,h:r,C:s,T:()=>g,M:()=>b!==0,o:()=>m,O:()=>h,t:o,L:()=>(y=_,_=0,[y,x===2]),H:(e,t)=>{let n=[e,t];return E.add(n),()=>{E.delete(n)}},W:(n,s)=>{let u,C,j=0;switch(n){case 1:{if(s===g&&x===0)break;let e=y;y=0;let t=s-g,n=t8(t);e&&n<t8(e)+1||x!==0||(b=t<0?2:1),f&&=!1,g=s,j=4;let r=D();r>=-m&&r<=o()&&(j+=1,C=n>m);break}case 2:j=8,b!==0&&(u=!0,j+=1),b=0,x=0,S=null;break;case 3:{let e=s.filter(([e,t])=>!a(e,t));if(!e.length)break;A(e.reduce((e,[t,n])=>{let i;if(x===2)i=!0;else if(S&&x===1)i=t<S[0];else{let e=D(),n=k(t),a=r(t);i=b!==1&&x===0?n+a<=e:n<e&&n+a<e+m}return i&&(e+=n-r(t)),e},0));for(let[t,n]of e){let e=r(t),a=i(t,n);d&&(w+=a?n:n-e)}d&&m&&w>m&&(A(l(t(O()))),d=!1),j=3,C=!0;break}case 4:m!==s&&(m||(T=C=!0),m=s,j=3);break;case 5:s[1]?(A(c(s[0],!0)),x=2,j=1):(c(s[0]),j=1);break;case 6:h=s;break;case 7:x=1;break;case 8:S=e(s,s+m),j=1}j&&(p=1+(2147483647&p),u&&v&&(_+=v,v=0),E.forEach(([e,t])=>{j&e&&t(C)}))}}},_8=(e,t,n,r=0,i=t-1)=>{let a=r;for(;r<=i;){let t=n8((r+i)/2);e(t)<=n?(a=t,r=t+1):i=t-1}return r8(a,0,t-1)},v8=(e,t,n)=>{let r=n?`unshift`:`push`;for(let n=0;n<t;n++)e[r](-1);return e},y8=(e,t,n)=>{let r=n&&n[1]||t||40,i=-1,a=0,o=n&&n[0],s=o?v8(o.slice(0,$6(e,o.length)),e8(0,e-o.length)):v8([],e),c=v8([],e+1),l=e=>{let t=s[e];return t===-1?r:t},u=t=>{if(!e)return 0;if(i>=t)return c[t];i<0&&(c[0]=0,i=0);let n=i,r=c[n];for(;n<t;)r+=l(n),c[++n]=r;return i=t,r};return{i:(t,n)=>{let r,i;return a=$6(a,e-1),u(a)<=t?(i=_8(u,e,n,a),r=_8(u,e,t,a,i)):(r=_8(u,e,t,void 0,a),i=_8(u,e,n,r)),a=r,[r,i]},l:t=>_8(u,e,t),u,h:l,v:(e,t)=>{let n=s[e]===-1;return s[e]=t,i=$6(e,i),n},S:(e,t=-1)=>s[e]===t,t:()=>u(e),$:()=>e,m:(t,n)=>{let a=t-e;return i=n?-1:$6(t-1,i),e=t,a>0?(v8(c,a),v8(s,a,n),r*a):(c.splice(a),(n?s.splice(0,-a):s.splice(a)).reduce((e,t)=>e-(t===-1?r:t),0))},p:t?void 0:e=>{let t=0,n=[];s.forEach((r,i)=>{r!==-1&&(r&&n.push(r),i<e&&t++)}),i=-1;let a=i8(n),o=a.length,c=o/2|0,l=o%2==0?(a[c-1]+a[c])/2:a[c],u=r;return((r=l)-u)*e8(e-t,0)},B:()=>[s.slice(),r]}},b8=e=>{let t;return{X(n){(t||=new(f8(d8(n))).ResizeObserver(e)).observe(n)},Y(e){t.unobserve(e)},q(){t&&t.disconnect()}}},x8=(e,t)=>t?-e:e,S8=(e,t,n,r,i,a)=>{let o=Date.now,s=0,c=!1,l=!1,u=!1,d=!1,f=(()=>{let t,n=()=>{t!=null&&clearTimeout(t)},r=()=>{n(),t=a8(()=>{t=null,(()=>{if(c||l)return c=!1,void f();u=!1,e.W(2)})()},150)};return r.A=n,r})(),p=()=>{s=o(),u&&(d=!0),a&&e.W(6,a()),e.W(1,r()),f()},m=t=>{if(c||!e.M()||t.ctrlKey)return;let r=o()-s;150>r&&50<r&&(n?t.deltaX:t.deltaY)&&(c=!0)},h=()=>{l=!0,u=d=!1},g=()=>{l=!1,p8()&&(u=!0)};return t.addEventListener(`scroll`,p),t.addEventListener(`wheel`,m,{passive:!0}),t.addEventListener(`touchstart`,h,{passive:!0}),t.addEventListener(`touchend`,g,{passive:!0}),{q:()=>{t.removeEventListener(`scroll`,p),t.removeEventListener(`wheel`,m),t.removeEventListener(`touchstart`,h),t.removeEventListener(`touchend`,g),f.A()},D:()=>{let[t,n]=e.L();t&&(i(t,n,d),d=!1,n&&e.o()>e.t()&&e.W(1,r()))}}},C8=(e,t,n)=>{let r;return[async(i,a)=>{if(!await t())return;r&&r();let o=()=>{let[t,n]=s8();return r=()=>{n(!1)},e.o()&&a8(r,150),[t,e.H(2,()=>{n(!0)})]};if(a&&m8())e.W(8,i()),o8(async()=>{for(;;){let t=!0;for(let[n,r]=e.i();n<=r;n++)if(e.R(n)){t=!1;break}if(t)break;let[n,r]=o();try{if(!await n)return}finally{r()}}e.W(7),n(i(),a)});else for(;;){let[t,r]=o();try{if(e.W(7),n(i()),!await t)return}finally{r()}}},()=>{r&&r()}]},w8=(e,t)=>{let n,r,i=s8(),a=!1,o=t?`scrollLeft`:`scrollTop`,s=t?`overflowX`:`overflowY`,[c,l]=C8(e,()=>i[0],(e,r)=>{e=x8(e,a),r?n.scrollTo({[t?`left`:`top`]:e,behavior:`smooth`}):n[o]=e}),u=t?`width`:`height`,d=new WeakMap,f=b8(t=>{let r=[];for(let{target:i,contentRect:a}of t)if(i.offsetParent){if(i===n)e.W(4,a[u]);else{let e=d.get(i);e!=null&&r.push([e,a[u]])}}r.length&&e.W(3,r)});return{N(c,u=c.parentElement){f.X(n=u),t&&(a=getComputedStyle(u).direction===`rtl`),r=S8(e,u,t,()=>x8(u[o],a),(t,n,r)=>{if(r){let e=u.style,t=e[s];e[s]=`hidden`,a8(()=>{e[s]=t})}u[o]=x8(e.T()+t,a),n&&l()}),i[1](!0)},_(){f.q(),r&&r.q(),i[1](!1),i=s8()},P:(e,t)=>(d.set(e,t),f.X(e),()=>{d.delete(e),f.Y(e)}),V:()=>a,J:c,j(){r&&r.D()},G:e.O,U:()=>0}},T8=(e,t)=>{e.J(()=>t)},E8=(e,t,n,{align:r,smooth:i,offset:a=0}={})=>{if(n=r8(n,0,t.C()-1),r===`nearest`){let e=t.u(n),i=t.T();if(e<i)r=`start`;else{if(!(e+t.h(n)>i+t.o()))return;r=`end`}}e.J(()=>a+e.G()+t.u(n)+(r===`end`?t.h(n)-(t.o()-e.U()):r===`center`?(t.h(n)-(t.o()-e.U()))/2:0),i)},D8=l8?d.useLayoutEffect:d.useEffect,O8=`current`,k8=(e,t)=>{if(Array.isArray(e))for(let n of e)k8(n,t);else e==null||typeof e==`boolean`||t.push(e)},A8=(e,t)=>e.key??`_`+t,j8=e=>{let t=(0,d.useRef)(null);return t.current||=e()},M8=e=>{let t=(0,d.useRef)(e);return D8(()=>{t[O8]=e},[e]),t},N8=(0,d.memo)(({te:e,oe:t,ne:n,re:r,ie:i,se:a,le:o,ce:s})=>{let c=(0,d.useRef)(null);D8(()=>t(c[O8],n),[n]);let l=(0,d.useMemo)(()=>{let e={contain:`layout style`,position:i&&s?void 0:`absolute`,[o?`height`:`width`]:`100%`,[o?`top`:`left`]:0,[o?`left`:`top`]:r,visibility:!i||s?void 0:`hidden`};return o&&(e.display=`inline-flex`),e},[r,i,s,o]);return(0,E.jsx)(a,typeof a==`string`?{ref:c,style:l,children:e}:{ref:c,style:l,index:n,children:e})}),P8=(e,t)=>(0,d.useMemo)(()=>{if(typeof e==`function`)return[n=>e(t[n],n),t.length];let n=(e=>{let t=[];return k8(e,t),t})(e);return[e=>n[e],n.length]},[e,t]),F8=(0,d.forwardRef)(({children:e,data:t,bufferSize:n,itemSize:r,shift:i,horizontal:a,keepMounted:o,cache:s,startMargin:c=0,ssrCount:l,as:u=`div`,item:f=`div`,scrollRef:p,onScroll:m,onScrollEnd:h},g)=>{let[_,v]=P8(e,t),y=(0,d.useRef)(null),b=(0,d.useRef)(!!l),x=M8(m),S=M8(h),[C,w,T,D]=j8(()=>{let e=!!a,t=y8(v,r,s),n=g8(t,l);return[n,t,w8(n,e),e]});v!==C.C()&&C.W(5,[v,i]),c!==C.O()&&C.W(6,c);let[O,k]=(0,d.useReducer)(C.I,void 0,C.I),A=C.M(),j=C.t(),M=T.V(),N=[],P=e=>{let t=_(e);return(0,E.jsx)(N8,{oe:T.P,ne:e,re:C.u(e,M),ie:C.R(e),se:f,te:t,le:D,ce:b[O8]},A8(t,e))};if(D8(()=>{b[O8]=!1,C.H(1,e=>{e?(0,ii.flushSync)(k):k()}),C.H(4,()=>{x.current&&x.current(C.T())}),C.H(8,()=>{S.current&&S.current()});let e=y[O8];return p?o8(()=>{p.current&&T.N(e,p[O8])}):T.N(e),()=>{C._(),T._()}},[]),D8(()=>{T.j()},[O]),(0,d.useImperativeHandle)(g,()=>({get cache(){return w.B()},get scrollOffset(){return C.T()},get scrollSize(){return h8(C)},get viewportSize(){return C.o()},findItemIndex:C.k,getItemOffset:C.u,getItemSize:C.h,scrollToIndex:(e,t)=>E8(T,C,e,t),scrollTo:e=>T8(T,e),scrollBy:e=>((e,t,n)=>{T8(e,n+t.T())})(T,C,e)}),[]),o){let e=new Set(o);for(let[t,r]=C.i(n);t<=r;t++)e.add(t);i8([...e]).forEach(e=>{N.push(P(e))})}else for(let[e,t]=C.i(n);e<=t;e++)N.push(P(e));return(0,E.jsx)(u,{ref:y,style:{contain:`size style`,overflowAnchor:`none`,flex:`none`,position:`relative`,width:D?j:`100%`,height:D?`100%`:j,pointerEvents:A?`none`:void 0},children:N})}),I8=100,L8=new Map;function R8(e,t,n){let r=`${e}:${t}:${n}`,i=L8.get(r);if(i)return L8.delete(r),L8.set(r,i),i;let a=fetch(`/api/sessions/${encodeURIComponent(e)}/entries/${encodeURIComponent(t)}/thinking?blockIndex=${n}`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();if(typeof t.thinking!=`string`)throw Error(`Invalid thinking response`);return t.thinking}).catch(e=>{throw L8.delete(r),e});if(L8.set(r,a),L8.size>I8){let e=L8.keys().next().value;e&&L8.delete(e)}return a}function z8(e){if(!e)return null;let t=new Date(e),n=new Date,r=t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate(),i=t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});return r?i:`${t.toLocaleDateString([],{month:`short`,day:`numeric`,year:t.getFullYear()===n.getFullYear()?void 0:`numeric`})} ${i}`}function B8(e,t,n){if(t===n||e.role!==`assistant`)return!0;for(let r of e.content??[])if(r.type===`toolCall`&&t?.get(r.toolCallId)!==n?.get(r.toolCallId))return!1;return!0}var V8=(0,d.memo)(function({message:e,isStreaming:t,toolResults:n,modelNames:r,cwd:i,onOpenFile:a,entryId:o,onFork:s,forking:c,onNavigate:l,prevAssistantEntryId:u,onEditContent:d,showTimestamp:f,turnStartTimestamp:p,sessionId:m,streamingBashOutput:h,longBlockCollapseChars:g,recentExpandedBlockKeys:_,modelLabelVisible:v,turnNumber:y}){return e.role===`user`?(0,E.jsx)(H8,{message:e,entryId:o,onFork:s,forking:c,onNavigate:l,prevAssistantEntryId:u,onEditContent:d,turnNumber:y}):e.role===`assistant`?(0,E.jsx)(U8,{message:e,isStreaming:t,toolResults:n,modelNames:r,cwd:i,onOpenFile:a,showTimestamp:f,turnStartTimestamp:p,sessionId:m,entryId:o,longBlockCollapseChars:g,recentExpandedBlockKeys:_,modelLabelVisible:v,turnNumber:y}):e.role===`toolResult`?null:e.role===`custom`?e.customType===`compaction`?(0,E.jsx)(s5,{message:e}):(0,E.jsx)(u5,{message:e,cwd:i,onOpenFile:a}):e.role===`bashExecution`?(0,E.jsx)(y5,{message:e,sessionId:m,streamingOutput:h,longBlockCollapseChars:g}):null},(e,t)=>e.message===t.message&&e.isStreaming===t.isStreaming&&B8(e.message,e.toolResults,t.toolResults)&&e.modelNames===t.modelNames&&e.cwd===t.cwd&&e.onOpenFile===t.onOpenFile&&e.entryId===t.entryId&&e.onFork===t.onFork&&e.forking===t.forking&&e.onNavigate===t.onNavigate&&e.prevAssistantEntryId===t.prevAssistantEntryId&&e.onEditContent===t.onEditContent&&e.showTimestamp===t.showTimestamp&&e.sessionId===t.sessionId&&e.streamingBashOutput===t.streamingBashOutput&&e.modelLabelVisible===t.modelLabelVisible&&e.longBlockCollapseChars===t.longBlockCollapseChars&&e.recentExpandedBlockKeys===t.recentExpandedBlockKeys);function H8({message:e,entryId:t,onFork:n,forking:r,onNavigate:i,prevAssistantEntryId:a,onEditContent:o,turnNumber:s}){let{t:c}=N(),[l,u]=(0,d.useState)(!1),[f,m]=(0,d.useState)(!1),h=typeof e.content==`string`?e.content:e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
470
|
+
`),g=typeof e.content==`string`?[]:e.content.filter(e=>e.type===`image`),_=z8(e.timestamp),v=!!t&&!!n,y=!!a&&!!i;return(0,E.jsxs)(`div`,{style:{marginBottom:16,display:`flex`,flexDirection:`column`,alignItems:`flex-end`},onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,maxWidth:`85%`},children:[s!==void 0&&(0,E.jsx)(rZ,{number:s}),(0,E.jsxs)(`div`,{style:{flex:1,minWidth:0,position:`relative`,background:`var(--user-bg)`,border:`1px solid color-mix(in srgb, var(--accent) 20%, transparent)`,borderRadius:12,padding:`8px 12px`,fontSize:`var(--text-2xl)`,fontFamily:`var(--font-mono)`,lineHeight:1.6,color:`var(--text)`,wordBreak:`break-word`},children:[g.length>0&&(0,E.jsx)(`div`,{style:{display:`flex`,gap:6,flexWrap:`wrap`,marginBottom:h?8:0},children:g.map((e,t)=>{let n=p5(e);return(0,E.jsx)(`img`,{src:n,alt:``,style:{maxWidth:240,maxHeight:240,borderRadius:6,objectFit:`contain`,display:`block`,border:`1px solid color-mix(in srgb, var(--accent) 15%, transparent)`}},t)})}),h&&(0,E.jsx)(`div`,{"data-testid":`user-message`,style:{whiteSpace:`pre-wrap`,wordBreak:`break-word`},children:h})]})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`flex-end`,gap:6,marginTop:3},children:[(0,E.jsx)(`div`,{style:{display:`flex`,gap:3,opacity:+!!l,pointerEvents:l?`auto`:`none`,transition:`opacity 0.12s`},children:(0,E.jsxs)(`button`,{onClick:()=>{bY(h).then(()=>{m(!0),setTimeout(()=>m(!1),1500)})},title:c(`i18n.copyMessage`),style:{display:`flex`,alignItems:`center`,gap:4,padding:`3px 8px`,height:22,background:`none`,border:`none`,borderRadius:5,color:f?`var(--accent)`:`var(--text-dim)`,cursor:`pointer`,fontSize:`var(--text-sm)`,fontWeight:400,whiteSpace:`nowrap`,transition:`color 0.12s`,"--hover-color":`var(--accent)`},className:f?void 0:`hover-shift`,children:[f?(0,E.jsx)(`svg`,{width:p.sm,height:p.sm,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,E.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}):(0,E.jsxs)(`svg`,{width:p.sm,height:p.sm,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`rect`,{x:`9`,y:`9`,width:p.lg,height:p.lg,rx:`2`,ry:`2`}),(0,E.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]}),c(f?`i18n.copied`:`i18n.copy`)]})}),(v||y)&&(0,E.jsxs)(`div`,{style:{display:`flex`,gap:3,opacity:l||r?1:0,pointerEvents:l||r?`auto`:`none`,transition:`opacity 0.12s`},children:[y&&(0,E.jsxs)(`button`,{onClick:()=>{i(a),o?.(h)},title:c(`i18n.editFromHereTitle`),style:{display:`flex`,alignItems:`center`,gap:4,padding:`3px 8px`,height:22,background:`none`,border:`none`,borderRadius:5,color:`var(--text-dim)`,cursor:`pointer`,fontSize:`var(--text-sm)`,fontWeight:400,whiteSpace:`nowrap`,transition:`color 0.12s`,"--hover-color":`var(--accent)`},className:`hover-shift`,children:[(0,E.jsxs)(`svg`,{width:p.sm,height:p.sm,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`polyline`,{points:`15 10 20 15 15 20`}),(0,E.jsx)(`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`})]}),c(`i18n.editFromHere`)]}),v&&(0,E.jsxs)(`button`,{onClick:()=>{n(t)},disabled:r,title:c(r?`i18n.creatingSession`:`i18n.newSessionTitle`),style:{display:`flex`,alignItems:`center`,gap:4,padding:`3px 8px`,height:22,background:`none`,border:`none`,borderRadius:5,color:r?`var(--accent)`:`var(--text-dim)`,cursor:r?`not-allowed`:`pointer`,fontSize:`var(--text-sm)`,fontWeight:400,whiteSpace:`nowrap`,transition:`color 0.12s`,"--hover-color":`var(--accent)`},className:r?void 0:`hover-shift`,children:[(0,E.jsxs)(`svg`,{width:p.sm,height:p.sm,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`line`,{x1:`6`,y1:`3`,x2:`6`,y2:`15`}),(0,E.jsx)(`circle`,{cx:`18`,cy:`6`,r:`3`}),(0,E.jsx)(`circle`,{cx:`6`,cy:`18`,r:`3`}),(0,E.jsx)(`path`,{d:`M18 9a9 9 0 0 1-9 9`})]}),c(r?`i18n.creating`:`i18n.newSession`)]})]}),_&&(0,E.jsx)(`span`,{style:{fontSize:`var(--text-xs)`,color:`var(--text-dim)`},children:_})]})]})}function U8({message:e,isStreaming:t,toolResults:n,modelNames:r,cwd:i,onOpenFile:a,showTimestamp:o,turnStartTimestamp:s,sessionId:c,entryId:l,longBlockCollapseChars:u,recentExpandedBlockKeys:f,modelLabelVisible:m=!0,turnNumber:h}){let{t:g}=N(),_=o?z8(e.timestamp):null,v=(e.content??[]).map((e,t)=>({block:e,originalIndex:t})).filter(({block:e})=>!DY(e,{isStreaming:t})),y=v.map(({block:e})=>e),b=kY(e,{isStreaming:t}),[x,S]=(0,d.useState)(!1),[C,w]=(0,d.useState)(!1),T=(0,d.useRef)(null),[D,O]=(0,d.useState)(null),k=(0,d.useRef)(v);k.current=v;let A=(0,d.useRef)(new Map),[j,M]=(0,d.useState)(new Map),P=(0,d.useMemo)(()=>{if(!e.timestamp||!s)return;let t=Math.round((e.timestamp-s)/1e3);return t>0?t:void 0},[e.timestamp,s]),ee=(0,d.useMemo)(()=>{let t=new Map;if(!n||!e.timestamp)return t;for(let[r,i]of n)if(i.timestamp&&e.timestamp){let n=Math.round((i.timestamp-e.timestamp)/1e3);n>0&&t.set(r,n)}return t},[n,e.timestamp]),F=y.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
471
|
+
`);return(0,d.useEffect)(()=>{if(!t)return;let e=setInterval(()=>{if(document.hidden)return;let e=k.current,t=e.map(({block:e})=>e),n=Date.now();e.forEach(({originalIndex:e})=>{A.current.has(e)||A.current.set(e,n)}),M(t=>{let r=!1,i=new Map(t);for(let t=0;t<e.length-1;t++){let a=e[t].originalIndex,o=e[t+1].originalIndex;if(!i.has(a)&&A.current.has(a)){let e=A.current.get(a),t=A.current.get(o)??n;i.set(a,Math.round((t-e)/1e3)),r=!0}}return r?i:t});let r=e[e.length-1];if(r&&r.block.type===`toolCall`){let e=A.current.get(r.originalIndex);e!==void 0&&M(t=>{let i=Math.round((n-e)/1e3);if(t.get(r.originalIndex)===i)return t;let a=new Map(t);return a.set(r.originalIndex,i),a})}let i=0;for(let e of t)e.type===`text`?i+=e.text?.length??0:e.type===`thinking`?i+=e.thinking?.length??0:e.type===`toolCall`&&(i+=JSON.stringify(e.input??{}).length);if(i===0)return;T.current===null&&(T.current=n);let a=(n-T.current)/1e3;a>.5&&O(i/4/a)},300);return()=>{clearInterval(e),T.current=null,O(null)}},[t]),y.length===0&&!t&&!b?null:(0,E.jsxs)(`div`,{style:{marginBottom:16},onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),children:[m&&(0,E.jsxs)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-dim)`,marginBottom:4,display:`flex`,alignItems:`center`,gap:6},children:[h!==void 0&&(0,E.jsx)(rZ,{number:h}),e.provider&&(0,E.jsx)(`span`,{children:r?.[`${e.provider}/${e.model}`]??r?.[e.model]??e.model}),t&&(()=>{let e=0;for(let t of y)t.type===`text`?e+=t.text?.length??0:t.type===`thinking`?e+=t.thinking?.length??0:t.type===`toolCall`&&(e+=JSON.stringify(t.input??{}).length);let t=Math.round(e/4);return(0,E.jsx)(E.Fragment,{children:t>0&&(0,E.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:4,color:`var(--text)`},title:g(`i18n.estimatedTokens`),children:[(0,E.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:2,fontSize:`var(--text-sm)`,fontWeight:400},children:[(0,E.jsxs)(`svg`,{width:p.xs,height:p.xs,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`line`,{x1:`5`,y1:`1.5`,x2:`5`,y2:`8.5`}),(0,E.jsx)(`polyline`,{points:`2 6 5 8.5 8 6`})]}),t]}),D!==null&&(0,E.jsxs)(`span`,{style:{marginLeft:6,padding:`1px 6px`,borderRadius:4,background:D>=50?`#53b3cb`:D>=30?`#9bc53d`:D>=15?`#f9c22e`:`#e01a4f`,color:`#fff`,fontSize:`var(--text-sm)`,fontWeight:400},children:[D.toFixed(1),` t/s`]})]})})})()]}),(0,E.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:v.map(({block:e,originalIndex:r})=>(0,E.jsx)(q8,{block:e,toolResults:n,isStreaming:t,streamingDuration:j.get(r),toolCallDurations:ee,cwd:i,onOpenFile:a,sessionId:c,entryId:l,blockIndex:r,longBlockCollapseChars:u,recentExpandedBlockKeys:f},`${l??`stream`}-${r}`))}),b&&(0,E.jsxs)(`div`,{role:`alert`,style:{marginTop:y.length>0?8:0,padding:`7px 10px`,border:`1px solid color-mix(in srgb, var(--status-error) 30%, transparent)`,borderRadius:6,background:`color-mix(in srgb, var(--status-error) 7%, transparent)`,color:`var(--status-error)`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-base)`,lineHeight:1.5,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:[`Error: `,b]}),(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:4},children:[e.usage&&!t&&(0,E.jsx)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-dim)`},children:v5(e.usage)}),F&&!t&&(0,E.jsxs)(`button`,{onClick:()=>{bY(F).then(()=>{w(!0),setTimeout(()=>w(!1),1500)})},title:g(`i18n.copyMessage`),style:{display:`flex`,alignItems:`center`,gap:4,padding:`3px 8px`,height:22,background:`none`,border:`none`,borderRadius:5,color:C?`var(--accent)`:`var(--text-dim)`,cursor:`pointer`,fontSize:`var(--text-sm)`,fontWeight:400,whiteSpace:`nowrap`,opacity:+!!x,pointerEvents:x?`auto`:`none`,transition:`opacity 0.12s, color 0.12s`,"--hover-color":`var(--accent)`},className:C?void 0:`hover-shift`,children:[C?(0,E.jsx)(`svg`,{width:p.sm,height:p.sm,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,E.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}):(0,E.jsxs)(`svg`,{width:p.sm,height:p.sm,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`rect`,{x:`9`,y:`9`,width:p.lg,height:p.lg,rx:`2`,ry:`2`}),(0,E.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]}),g(C?`i18n.copied`:`i18n.copy`)]}),_&&!t&&(0,E.jsxs)(`span`,{style:{fontSize:`var(--text-xs)`,color:`var(--text-dim)`,marginLeft:`auto`,fontVariantNumeric:`tabular-nums`},children:[_,P!==void 0&&(0,E.jsxs)(`span`,{children:[` `,`(`,g(`chat.turnDuration`,{duration:ht(P)}),`)`]})]})]})]})}var W8=24;function G8({text:e}){let t=(0,d.useMemo)(()=>e.split(/\r?\n/),[e]);return typeof ResizeObserver>`u`||t.length<50&&e.length<5e3?(0,E.jsx)(`div`,{style:{whiteSpace:`pre-wrap`,overflowWrap:`break-word`},children:e}):(0,E.jsx)(F8,{data:t,itemSize:W8,children:e=>(0,E.jsx)(`div`,{style:{minHeight:W8,lineHeight:`${W8}px`,whiteSpace:`pre-wrap`,overflowWrap:`break-word`},children:e})})}function K8({text:e,threshold:t,t:n,renderFull:r,isStreaming:i=!1,defaultExpanded:a=!1}){let[o,s]=(0,d.useState)(a),c=e.length;if(!(!i&&c>t))return r?(0,E.jsx)(E.Fragment,{children:r()}):i&&e.length>0?(0,E.jsx)(G8,{text:e}):(0,E.jsx)(E.Fragment,{children:e});let l=Math.max(1,Math.floor(t/2)),u=c-l*2,f=(0,E.jsx)(`button`,{type:`button`,"data-long-block-toggle":``,onClick:()=>s(e=>!e),"aria-expanded":o,style:{display:`block`,width:`100%`,margin:`6px 0`,padding:`3px 8px`,border:`1px dashed var(--border)`,borderRadius:6,background:`none`,color:`var(--text-dim)`,fontSize:`var(--text-sm)`,cursor:`pointer`,textAlign:`center`},children:o?n(`longBlock.collapse`):n(`longBlock.expandHint`,{n:u})});return o?(0,E.jsxs)(E.Fragment,{children:[r?r():(0,E.jsx)(G8,{text:e}),f]}):(0,E.jsxs)(E.Fragment,{children:[e.slice(0,l),f,e.slice(c-l)]})}function q8({block:e,toolResults:t,isStreaming:n,streamingDuration:r,toolCallDurations:i,cwd:a,onOpenFile:o,sessionId:s,entryId:c,blockIndex:l,longBlockCollapseChars:u,recentExpandedBlockKeys:d}){let f=!n&&c!==void 0&&(e.type===`thinking`||e.type===`toolCall`)&&d?.has(Je(e.type,c,e.type===`toolCall`?e.toolCallId:void 0,e.type===`thinking`?l:void 0))===!0;if(e.type===`text`)return(0,E.jsx)(J8,{block:e,isStreaming:n,cwd:a,onOpenFile:o});if(e.type===`thinking`)return(0,E.jsx)(Y8,{block:e,sessionId:s,entryId:c,blockIndex:l,isStreaming:n,keepExpanded:f,longBlockCollapseChars:u});if(e.type===`toolCall`){let a=e,o=t?.get(a.toolCallId),s=i?.get(a.toolCallId)??r;return(0,E.jsx)(Z8,{block:a,result:o,duration:s,isStreaming:n,keepExpanded:f,longBlockCollapseChars:u})}return null}function J8({block:e,isStreaming:t,cwd:n,onOpenFile:r}){return(0,E.jsx)(Q6,{isStreaming:t,cwd:n,onOpenFile:r,children:e.text})}function Y8({block:e,sessionId:t,entryId:n,blockIndex:r,isStreaming:i=!1,keepExpanded:a=!1,longBlockCollapseChars:o=200}){let{t:s}=N(),[c,l]=(0,d.useState)(null),[u,f]=(0,d.useState)(!1),[m,h]=(0,d.useState)(null),g=(0,d.useRef)(!1),_=(0,d.useRef)(null);(0,d.useEffect)(()=>{e.deferred&&!g.current&&(g.current=!0,v())},[]);let v=async()=>{if(!(!e.deferred||c!==null)){if(!t||!n){h(s(`i18n.thinkingUnavailable`));return}f(!0),h(null);try{l(await R8(t,n,r))}catch(e){h(e instanceof Error?e.message:String(e))}finally{f(!1)}}},y=e.deferred?c:e.thinking,b=EZ(_,i,[y]);return(0,E.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:6,overflow:`hidden`,fontSize:`var(--text-base)`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,padding:`6px 10px`,color:`var(--status-warning)`,fontSize:`var(--text-base)`,cursor:`default`},children:[(0,E.jsx)(Dr,{size:p.base,fill:`currentColor`,style:{flexShrink:0,color:`var(--bulb-warning)`}}),(0,E.jsx)(`span`,{children:s(`i18n.thinking`)})]}),(0,E.jsx)(`div`,{ref:_,onScroll:b,style:{padding:`4px 10px 8px 28px`,borderTop:`1px solid var(--border)`,fontSize:`var(--text-lg)`,lineHeight:1.6,color:`var(--text-muted)`,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,fontFamily:`var(--font-mono)`,maxHeight:400,overflowY:`auto`,contentVisibility:`auto`,containIntrinsicBlockSize:400},children:u?(0,E.jsxs)(`span`,{style:{color:`var(--text-dim)`},children:[s(`i18n.loading`),`...`]}):m?(0,E.jsx)(`span`,{style:{color:`var(--status-error)`},children:m}):y?(0,E.jsx)(K8,{text:y,threshold:o,t:s,isStreaming:i,defaultExpanded:a}):EY(e)?(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`,fontStyle:`italic`},children:s(`i18n.thinkingEncrypted`)}):(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`},children:s(`i18n.noThinking`)})})]})}function X8({block:e,result:t,duration:n}){let{t:r}=N(),i=e.input??{},a=typeof i.question==`string`?i.question:null,o=Array.isArray(i.options)?i.options:[],s=t?t.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
472
|
+
`).trim():null,c=t?.isError??!1,l=s?.startsWith(`用户选择: `)?s.slice(6):null,u=l!==null&&o.some(e=>e.label===l);return(0,E.jsxs)(`div`,{style:{borderRadius:7,fontSize:`var(--text-base)`,border:c?`1px solid color-mix(in srgb, var(--status-error) 45%, transparent)`:`1px solid var(--border)`,background:c?`color-mix(in srgb, var(--status-error) 5%, transparent)`:`var(--bg-panel)`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:7,padding:`6px 10px`,color:`var(--text-muted)`,fontSize:`var(--text-sm)`},children:[(0,E.jsx)(`span`,{style:{color:c?`var(--status-error)`:`var(--status-info)`,fontFamily:`var(--font-mono)`,fontWeight:600,flexShrink:0},children:`pi_menu`}),(0,E.jsx)(`span`,{children:r(`chat.aiQuestion`)}),n!==void 0&&(0,E.jsxs)(`span`,{style:{marginLeft:`auto`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`,fontVariantNumeric:`tabular-nums`,flexShrink:0},children:[n,`s`]})]}),(0,E.jsxs)(`div`,{style:{padding:`8px 10px`,borderTop:`1px solid var(--border)`,fontSize:`var(--text-base)`,lineHeight:1.5,color:`var(--text-muted)`},children:[a&&(0,E.jsx)(`div`,{style:{fontWeight:600,color:`var(--text)`,marginBottom:6},children:a}),o.length>0&&(0,E.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:3,marginBottom:s&&!u?6:0},children:o.map((e,t)=>{let n=typeof e.label==`string`?e.label:String(e.label??`#${t+1}`),r=typeof e.description==`string`?e.description:null,i=l!==null&&n===l;return(0,E.jsxs)(`div`,{style:{display:`flex`,gap:6,alignItems:`baseline`},children:[(0,E.jsx)(`span`,{style:{color:i?`var(--accent)`:`var(--text-dim)`},children:i?`●`:`○`}),(0,E.jsx)(`span`,{style:{color:i?`var(--accent)`:`var(--text)`,fontWeight:i?600:400},children:n}),r&&(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`,fontSize:`var(--text-sm)`},children:r})]},t)})}),s&&!u&&(0,E.jsx)(`div`,{style:{color:c?`var(--status-error)`:`var(--text-muted)`,fontWeight:600,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:s})]})]})}function Z8({block:e,result:t,duration:n,isStreaming:r=!1,keepExpanded:i=!1,streamingOutput:a,longBlockCollapseChars:o=200}){let{t:s}=N(),c=a??e.streamingOutput,l=(0,d.useRef)(null),u=EZ(l,r,[c]);if(e.toolName===`pi_menu`)return(0,E.jsx)(X8,{block:e,result:t,duration:n});let f=JSON.stringify(e.input,null,2),m=i5(e.toolName),h=t&&!t.isError?r5(t):null,g=t?t.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
473
473
|
`):null,_=g===null?!1:g.trim()===`(no output)`||g.trim()===``,v=t?.isError??!1,y=[m?``:f,h?h.text:g??``].filter(Boolean).join(`
|
|
474
|
-
`),b=!r&&!c&&y.length>o,x=(0,E.jsxs)(E.Fragment,{children:[!m&&(0,E.jsx)(`pre`,{style:{margin:0,color:`var(--text-muted)`,fontSize:`var(--text-base)`,lineHeight:1.5,overflow:`auto`,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:f}),t&&(h?(0,E.jsx)(X8,{diff:h}):(0,E.jsx)(i5,{text:g??``,isEmpty:_,isError:v})),!t&&c!==void 0&&c!==``&&(0,E.jsx)(`div`,{"data-testid":`tool-stream-output`,children:(0,E.jsx)(i5,{text:c,isEmpty:!1,isError:!1,streamRef:l,onStreamScroll:u})})]});return(0,E.jsxs)(`div`,{style:{borderRadius:7,fontSize:`var(--text-base)`,border:v?`1px solid color-mix(in srgb, var(--status-error) 45%, transparent)`:`1px solid var(--border)`,background:v?`color-mix(in srgb, var(--status-error) 5%, transparent)`:`var(--bg)`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:7,width:`100%`,padding:`6px 10px`,color:`var(--text-muted)`,fontSize:`var(--text-base)`,minWidth:0},children:[(0,E.jsx)(ti,{size:p.base,style:{flexShrink:0,color:v?`var(--status-error)`:`var(--status-info)`}}),(0,E.jsx)(`span`,{style:{color:v?`var(--status-error)`:`var(--status-info)`,fontFamily:`var(--font-mono)`,fontWeight:600,fontSize:`var(--text-sm)`,flexShrink:0},children:e.toolName}),(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,flex:1,minWidth:0},children:h5(e)}),n!==void 0&&(0,E.jsxs)(`span`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-dim)`,flexShrink:0,fontVariantNumeric:`tabular-nums`},children:[n,`s`]})]}),(0,E.jsx)(`div`,{style:{padding:`8px 10px`,borderTop:`1px solid var(--border)`,fontSize:`var(--text-base)`,lineHeight:1.5,color:`var(--text-muted)`},children:b?(0,E.jsx)(`div`,{style:{whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:(0,E.jsx)(W8,{text:y,threshold:o,t:s,renderFull:()=>x,isStreaming:r,defaultExpanded:i})}):x})]})}function X8({diff:e}){return(0,E.jsx)(`div`,{style:{borderTop:`1px solid var(--border)`,background:`var(--bg)`},children:(0,E.jsx)(Z8,{text:e.text})})}function Z8({text:e}){let{t}=N(),n=(0,d.useMemo)(()=>TZ(e),[e]);if(!n)return(0,E.jsx)(e5,{text:e});let r=n.length>1;return(0,E.jsx)(`div`,{style:{maxHeight:560,overflowY:`auto`,overflowX:`hidden`,background:`var(--bg)`,contentVisibility:`auto`,containIntrinsicBlockSize:560},children:n.map((e,n)=>(0,E.jsxs)(`div`,{style:{minWidth:0,borderTop:n===0?`none`:`1px solid var(--border)`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-base)`,lineHeight:1.55},children:[r&&(0,E.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`minmax(0, 1fr) minmax(0, 1fr)`,position:`sticky`,top:0,zIndex:1,background:`var(--bg)`,borderBottom:`1px solid var(--border)`},children:[(0,E.jsx)(Q8,{title:e.oldPath||t(`i18n.before`),side:`left`}),(0,E.jsx)(Q8,{title:e.newPath||t(`i18n.after`),side:`right`})]}),(0,E.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`minmax(0, 1fr) minmax(0, 1fr)`},children:e.rows.map((e,t)=>e.type===`hunk`?null:(0,E.jsxs)(`div`,{style:{display:`contents`},children:[(0,E.jsx)($8,{cell:e.left,side:`left`}),(0,E.jsx)($8,{cell:e.right,side:`right`})]},t))})]},n))})}function Q8({title:e,side:t}){return(0,E.jsx)(`div`,{title:e,style:{padding:`5px 10px`,color:`var(--text-dim)`,borderRight:t===`left`?`1px solid var(--border)`:`none`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e})}function $8({cell:e,side:t}){let n=e.type===`added`?`color-mix(in srgb, var(--status-success) 12%, transparent)`:e.type===`removed`?`color-mix(in srgb, var(--status-error) 13%, transparent)`:e.type===`empty`?`var(--bg-subtle)`:`transparent`,r=e.type===`added`?`+`:e.type===`removed`?`-`:` `,i=e.type===`added`?`var(--status-success)`:e.type===`removed`?`var(--status-error)`:`var(--text-dim)`;return(0,E.jsxs)(`div`,{style:{display:`flex`,minWidth:0,background:n,borderRight:t===`left`?`1px solid var(--border)`:`none`},children:[(0,E.jsx)(`span`,{style:{width:42,padding:`0 6px`,textAlign:`right`,color:`var(--text-dim)`,userSelect:`none`,background:`var(--bg)`,borderRight:`1px solid var(--border)`,flexShrink:0},children:e.lineNo??``}),(0,E.jsx)(`span`,{style:{width:18,padding:`0 5px`,color:i,userSelect:`none`,fontWeight:e.type===`context`||e.type===`empty`?400:700,flexShrink:0},children:r}),(0,E.jsx)(`span`,{style:{flex:1,minWidth:0,padding:`0 10px 0 0`,color:e.type===`empty`?`var(--text-dim)`:`var(--text)`,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:e.text||`\xA0`})]})}function e5({text:e}){let t=e.split(/\r?\n/);return(0,E.jsx)(`div`,{style:{maxHeight:520,overflowY:`auto`,overflowX:`hidden`,fontFamily:`var(--font-mono)`,contentVisibility:`auto`,containIntrinsicBlockSize:520,fontSize:`var(--text-base)`,lineHeight:1.55,minWidth:0},children:t.map((e,t)=>{let n=e.startsWith(`@@`)?`hunk`:e.startsWith(`+`)&&!e.startsWith(`+++`)?`added`:e.startsWith(`-`)&&!e.startsWith(`---`)?`removed`:`context`,r=n===`added`?`color-mix(in srgb, var(--status-success) 12%, transparent)`:n===`removed`?`color-mix(in srgb, var(--status-error) 13%, transparent)`:n===`hunk`?`color-mix(in srgb, var(--accent) 12%, transparent)`:`transparent`,i=n===`added`?`var(--status-success)`:n===`removed`?`var(--status-error)`:n===`hunk`?`var(--accent)`:`var(--text)`;return(0,E.jsxs)(`div`,{style:{display:`flex`,background:r,borderLeft:n===`added`?`3px solid var(--status-success)`:n===`removed`?`3px solid var(--status-error)`:n===`hunk`?`3px solid var(--accent)`:`3px solid transparent`},children:[(0,E.jsx)(`span`,{style:{width:48,padding:`0 8px`,color:`var(--text-dim)`,background:`var(--bg)`,borderRight:`1px solid var(--border)`,textAlign:`right`,userSelect:`none`,flexShrink:0},children:t+1}),(0,E.jsx)(`span`,{style:{padding:`0 10px`,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,color:i},children:e||`\xA0`})]},t)})})}function t5(e){let t=e.details;if(!r5(t))return null;let n=typeof t.patch==`string`?t.patch:null;if(n)return{text:n};let r=typeof t.diff==`string`?t.diff:null;return r?{text:r}:null}function n5(e){if(typeof e!=`string`||!e)return!1;let t=e.toLowerCase();return t===`edit`||t.startsWith(`edit_`)||t.endsWith(`.edit`)||t.endsWith(`_edit`)||t.includes(`str_replace`)||t.includes(`replace_editor`)}function r5(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function i5({text:e,isEmpty:t,isError:n,streamRef:r,onStreamScroll:i}){let{t:a}=N();return(0,E.jsx)(`div`,{style:{borderTop:`1px solid ${n?`color-mix(in srgb, var(--status-error) 30%, transparent)`:`var(--border)`}`,background:n?`color-mix(in srgb, var(--status-error) 4%, transparent)`:`var(--bg-subtle)`},children:(0,E.jsx)(`pre`,{ref:r,onScroll:i,style:{margin:0,padding:`8px 10px`,color:n?`var(--status-error)`:t?`var(--text-dim)`:`var(--text-muted)`,fontSize:`var(--text-base)`,lineHeight:1.5,overflow:`auto`,maxHeight:400,background:`var(--bg)`,whiteSpace:`pre-wrap`,wordBreak:`break-all`,fontStyle:t?`italic`:`normal`,opacity:t?.6:1,contentVisibility:`auto`,containIntrinsicBlockSize:400},children:t?a(`i18n.noOutput`):(0,E.jsx)(U8,{text:e})})})}function a5({message:e}){let{t}=N(),n=l5(e.content),r=(0,d.useMemo)(()=>SZ(n),[n]),i=L8(e.timestamp);return(0,E.jsx)(`div`,{style:{marginBottom:16},children:(0,E.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:8,overflow:`hidden`,background:`var(--bg)`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`7px 10px`,borderBottom:`1px solid var(--border)`,background:`var(--bg)`,color:`var(--text-muted)`},children:[(0,E.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,fontWeight:650},children:`compaction`}),i&&(0,E.jsx)(`span`,{style:{marginLeft:`auto`,color:`var(--text-dim)`,fontSize:`var(--text-xs)`},children:i})]}),(0,E.jsxs)(`div`,{style:{padding:`11px 13px 12px`},children:[(0,E.jsx)(`div`,{style:{color:`var(--text)`,fontSize:`var(--text-2xl)`,fontWeight:700,lineHeight:1.35},children:t(`i18n.conversationCompacted`)}),(0,E.jsx)(`div`,{style:{marginTop:3,marginBottom:10,color:`var(--text)`,fontSize:`var(--text-2xl)`,lineHeight:1.5},children:t(`i18n.compactionDescription`)}),r.body?(0,E.jsx)(X6,{className:`markdown-compaction-message`,children:r.body}):(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`,fontSize:`var(--text-base)`},children:t(`i18n.noSummary`)}),(0,E.jsx)(o5,{readFiles:r.readFiles,modifiedFiles:r.modifiedFiles})]})]})})}function o5({readFiles:e,modifiedFiles:t}){let{t:n}=N();if(e.length+t.length===0)return null;let r=[];return e.length>0&&r.push(`${e.length} read`),t.length>0&&r.push(`${t.length} modified`),(0,E.jsxs)(`details`,{className:`compaction-file-details`,children:[(0,E.jsx)(`summary`,{children:n(`i18n.fileContext`,{details:r.join(`, `)})}),t.length>0&&(0,E.jsx)(s5,{title:n(`i18n.modifiedFiles`),files:t}),e.length>0&&(0,E.jsx)(s5,{title:n(`i18n.readFiles`),files:e})]})}function s5({title:e,files:t}){return(0,E.jsxs)(`div`,{className:`compaction-file-section`,children:[(0,E.jsx)(`div`,{className:`compaction-file-title`,children:e}),(0,E.jsx)(`ul`,{className:`compaction-file-list`,children:t.map(e=>(0,E.jsx)(`li`,{children:e},e))})]})}function c5({message:e,cwd:t,onOpenFile:n}){let{t:r}=N(),i=e.display===!1,[a,o]=(0,d.useState)(!i),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(!1),f=l5(e.content),p=u5(e.content),m=e.details!==void 0,h=m?f5(e.details):``,g=p5(e.customType),_=L8(e.timestamp);return(0,E.jsx)(`div`,{style:{marginBottom:16},children:(0,E.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:8,overflow:`hidden`,background:i?`var(--bg-subtle)`:`var(--bg)`,opacity:i&&!a?.82:1},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`7px 10px`,borderBottom:`1px solid var(--border)`,background:`var(--bg)`,color:`var(--text-muted)`,fontSize:`var(--text-base)`},children:[(0,E.jsx)(`span`,{style:{color:`var(--text-muted)`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,fontWeight:650},children:g}),i&&(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`,fontSize:`var(--text-sm)`},children:r(`i18n.hiddenExtensionMessage`)}),_&&(0,E.jsx)(`span`,{style:{marginLeft:`auto`,color:`var(--text-dim)`,fontSize:`var(--text-xs)`},children:_})]}),a?(0,E.jsxs)(`div`,{style:{padding:`6px 9px`},children:[p.length>0&&(0,E.jsx)(`div`,{style:{display:`flex`,gap:6,flexWrap:`wrap`,marginBottom:f?8:0},children:p.map((e,t)=>{let n=d5(e);return n?(0,E.jsx)(`img`,{src:n,alt:``,style:{maxWidth:240,maxHeight:240,borderRadius:6,objectFit:`contain`,display:`block`,border:`1px solid var(--border)`}},t):null})}),f?(0,E.jsx)(X6,{className:`markdown-custom-message`,cwd:t,onOpenFile:n,children:f}):(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`,fontSize:`var(--text-base)`},children:r(`i18n.noMessage`)})]}):(0,E.jsx)(`button`,{onClick:()=>o(!0),style:{display:`block`,width:`100%`,padding:`8px 10px`,border:`none`,background:`transparent`,color:`var(--text-dim)`,cursor:`pointer`,fontSize:`var(--text-base)`,textAlign:`left`},children:f?m5(f):r(`i18n.showExtensionMessage`)}),(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`4px 9px`,borderTop:`1px solid var(--border)`,background:`var(--bg-subtle)`},children:[f||h?(0,E.jsx)(`button`,{onClick:()=>{vY(f||h).then(()=>{u(!0),setTimeout(()=>u(!1),1500)})},style:{padding:`3px 7px`,border:`none`,background:`none`,color:l?`var(--accent)`:`var(--text-dim)`,cursor:`pointer`,fontSize:`var(--text-sm)`},children:r(l?`i18n.copied`:`i18n.copy`)}):null,(m||i)&&(0,E.jsx)(`button`,{onClick:()=>{i?o(e=>!e):c(e=>!e)},style:{marginLeft:`auto`,padding:`3px 7px`,border:`none`,background:`none`,color:`var(--text-dim)`,cursor:`pointer`,fontSize:`var(--text-sm)`},children:r(i?a?`i18n.collapse`:`i18n.expand`:s?`i18n.hideDetails`:`i18n.showDetails`)})]}),m&&(i&&a||!i&&s)&&(0,E.jsx)(`pre`,{style:{margin:0,padding:`9px 10px`,borderTop:`1px solid var(--border)`,background:`var(--bg)`,color:`var(--text-muted)`,fontSize:`var(--text-base)`,lineHeight:1.5,whiteSpace:`pre-wrap`,wordBreak:`break-word`,maxHeight:360,overflow:`auto`,fontFamily:`var(--font-mono)`,contentVisibility:`auto`,containIntrinsicBlockSize:360},children:h})]})})}function l5(e){return typeof e==`string`?e:e.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
475
|
-
`)}function
|
|
474
|
+
`),b=!r&&!c&&y.length>o,x=(0,E.jsxs)(E.Fragment,{children:[!m&&(0,E.jsx)(`pre`,{style:{margin:0,color:`var(--text-muted)`,fontSize:`var(--text-base)`,lineHeight:1.5,overflow:`auto`,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:f}),t&&(h?(0,E.jsx)(Q8,{diff:h}):(0,E.jsx)(o5,{text:g??``,isEmpty:_,isError:v})),!t&&c!==void 0&&c!==``&&(0,E.jsx)(`div`,{"data-testid":`tool-stream-output`,children:(0,E.jsx)(o5,{text:c,isEmpty:!1,isError:!1,streamRef:l,onStreamScroll:u})})]});return(0,E.jsxs)(`div`,{style:{borderRadius:7,fontSize:`var(--text-base)`,border:v?`1px solid color-mix(in srgb, var(--status-error) 45%, transparent)`:`1px solid var(--border)`,background:v?`color-mix(in srgb, var(--status-error) 5%, transparent)`:`var(--bg)`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:7,width:`100%`,padding:`6px 10px`,color:`var(--text-muted)`,fontSize:`var(--text-base)`,minWidth:0},children:[(0,E.jsx)(ti,{size:p.base,style:{flexShrink:0,color:v?`var(--status-error)`:`var(--status-info)`}}),(0,E.jsx)(`span`,{style:{color:v?`var(--status-error)`:`var(--status-info)`,fontFamily:`var(--font-mono)`,fontWeight:600,fontSize:`var(--text-sm)`,flexShrink:0},children:e.toolName}),(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,flex:1,minWidth:0},children:_5(e)}),n!==void 0&&(0,E.jsxs)(`span`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-dim)`,flexShrink:0,fontVariantNumeric:`tabular-nums`},children:[n,`s`]})]}),(0,E.jsx)(`div`,{style:{padding:`8px 10px`,borderTop:`1px solid var(--border)`,fontSize:`var(--text-base)`,lineHeight:1.5,color:`var(--text-muted)`},children:b?(0,E.jsx)(`div`,{style:{whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:(0,E.jsx)(K8,{text:y,threshold:o,t:s,renderFull:()=>x,isStreaming:r,defaultExpanded:i})}):x})]})}function Q8({diff:e}){return(0,E.jsx)(`div`,{style:{borderTop:`1px solid var(--border)`,background:`var(--bg)`},children:(0,E.jsx)($8,{text:e.text})})}function $8({text:e}){let{t}=N(),n=(0,d.useMemo)(()=>DZ(e),[e]);if(!n)return(0,E.jsx)(n5,{text:e});let r=n.length>1;return(0,E.jsx)(`div`,{style:{maxHeight:560,overflowY:`auto`,overflowX:`hidden`,background:`var(--bg)`,contentVisibility:`auto`,containIntrinsicBlockSize:560},children:n.map((e,n)=>(0,E.jsxs)(`div`,{style:{minWidth:0,borderTop:n===0?`none`:`1px solid var(--border)`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-base)`,lineHeight:1.55},children:[r&&(0,E.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`minmax(0, 1fr) minmax(0, 1fr)`,position:`sticky`,top:0,zIndex:1,background:`var(--bg)`,borderBottom:`1px solid var(--border)`},children:[(0,E.jsx)(e5,{title:e.oldPath||t(`i18n.before`),side:`left`}),(0,E.jsx)(e5,{title:e.newPath||t(`i18n.after`),side:`right`})]}),(0,E.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`minmax(0, 1fr) minmax(0, 1fr)`},children:e.rows.map((e,t)=>e.type===`hunk`?null:(0,E.jsxs)(`div`,{style:{display:`contents`},children:[(0,E.jsx)(t5,{cell:e.left,side:`left`}),(0,E.jsx)(t5,{cell:e.right,side:`right`})]},t))})]},n))})}function e5({title:e,side:t}){return(0,E.jsx)(`div`,{title:e,style:{padding:`5px 10px`,color:`var(--text-dim)`,borderRight:t===`left`?`1px solid var(--border)`:`none`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e})}function t5({cell:e,side:t}){let n=e.type===`added`?`color-mix(in srgb, var(--status-success) 12%, transparent)`:e.type===`removed`?`color-mix(in srgb, var(--status-error) 13%, transparent)`:e.type===`empty`?`var(--bg-subtle)`:`transparent`,r=e.type===`added`?`+`:e.type===`removed`?`-`:` `,i=e.type===`added`?`var(--status-success)`:e.type===`removed`?`var(--status-error)`:`var(--text-dim)`;return(0,E.jsxs)(`div`,{style:{display:`flex`,minWidth:0,background:n,borderRight:t===`left`?`1px solid var(--border)`:`none`},children:[(0,E.jsx)(`span`,{style:{width:42,padding:`0 6px`,textAlign:`right`,color:`var(--text-dim)`,userSelect:`none`,background:`var(--bg)`,borderRight:`1px solid var(--border)`,flexShrink:0},children:e.lineNo??``}),(0,E.jsx)(`span`,{style:{width:18,padding:`0 5px`,color:i,userSelect:`none`,fontWeight:e.type===`context`||e.type===`empty`?400:700,flexShrink:0},children:r}),(0,E.jsx)(`span`,{style:{flex:1,minWidth:0,padding:`0 10px 0 0`,color:e.type===`empty`?`var(--text-dim)`:`var(--text)`,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:e.text||`\xA0`})]})}function n5({text:e}){let t=e.split(/\r?\n/);return(0,E.jsx)(`div`,{style:{maxHeight:520,overflowY:`auto`,overflowX:`hidden`,fontFamily:`var(--font-mono)`,contentVisibility:`auto`,containIntrinsicBlockSize:520,fontSize:`var(--text-base)`,lineHeight:1.55,minWidth:0},children:t.map((e,t)=>{let n=e.startsWith(`@@`)?`hunk`:e.startsWith(`+`)&&!e.startsWith(`+++`)?`added`:e.startsWith(`-`)&&!e.startsWith(`---`)?`removed`:`context`,r=n===`added`?`color-mix(in srgb, var(--status-success) 12%, transparent)`:n===`removed`?`color-mix(in srgb, var(--status-error) 13%, transparent)`:n===`hunk`?`color-mix(in srgb, var(--accent) 12%, transparent)`:`transparent`,i=n===`added`?`var(--status-success)`:n===`removed`?`var(--status-error)`:n===`hunk`?`var(--accent)`:`var(--text)`;return(0,E.jsxs)(`div`,{style:{display:`flex`,background:r,borderLeft:n===`added`?`3px solid var(--status-success)`:n===`removed`?`3px solid var(--status-error)`:n===`hunk`?`3px solid var(--accent)`:`3px solid transparent`},children:[(0,E.jsx)(`span`,{style:{width:48,padding:`0 8px`,color:`var(--text-dim)`,background:`var(--bg)`,borderRight:`1px solid var(--border)`,textAlign:`right`,userSelect:`none`,flexShrink:0},children:t+1}),(0,E.jsx)(`span`,{style:{padding:`0 10px`,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,color:i},children:e||`\xA0`})]},t)})})}function r5(e){let t=e.details;if(!a5(t))return null;let n=typeof t.patch==`string`?t.patch:null;if(n)return{text:n};let r=typeof t.diff==`string`?t.diff:null;return r?{text:r}:null}function i5(e){if(typeof e!=`string`||!e)return!1;let t=e.toLowerCase();return t===`edit`||t.startsWith(`edit_`)||t.endsWith(`.edit`)||t.endsWith(`_edit`)||t.includes(`str_replace`)||t.includes(`replace_editor`)}function a5(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function o5({text:e,isEmpty:t,isError:n,streamRef:r,onStreamScroll:i}){let{t:a}=N();return(0,E.jsx)(`div`,{style:{borderTop:`1px solid ${n?`color-mix(in srgb, var(--status-error) 30%, transparent)`:`var(--border)`}`,background:n?`color-mix(in srgb, var(--status-error) 4%, transparent)`:`var(--bg-subtle)`},children:(0,E.jsx)(`pre`,{ref:r,onScroll:i,style:{margin:0,padding:`8px 10px`,color:n?`var(--status-error)`:t?`var(--text-dim)`:`var(--text-muted)`,fontSize:`var(--text-base)`,lineHeight:1.5,overflow:`auto`,maxHeight:400,background:`var(--bg)`,whiteSpace:`pre-wrap`,wordBreak:`break-all`,fontStyle:t?`italic`:`normal`,opacity:t?.6:1,contentVisibility:`auto`,containIntrinsicBlockSize:400},children:t?a(`i18n.noOutput`):(0,E.jsx)(G8,{text:e})})})}function s5({message:e}){let{t}=N(),n=d5(e.content),r=(0,d.useMemo)(()=>wZ(n),[n]),i=z8(e.timestamp);return(0,E.jsx)(`div`,{style:{marginBottom:16},children:(0,E.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:8,overflow:`hidden`,background:`var(--bg)`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`7px 10px`,borderBottom:`1px solid var(--border)`,background:`var(--bg)`,color:`var(--text-muted)`},children:[(0,E.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,fontWeight:650},children:`compaction`}),i&&(0,E.jsx)(`span`,{style:{marginLeft:`auto`,color:`var(--text-dim)`,fontSize:`var(--text-xs)`},children:i})]}),(0,E.jsxs)(`div`,{style:{padding:`11px 13px 12px`},children:[(0,E.jsx)(`div`,{style:{color:`var(--text)`,fontSize:`var(--text-2xl)`,fontWeight:700,lineHeight:1.35},children:t(`i18n.conversationCompacted`)}),(0,E.jsx)(`div`,{style:{marginTop:3,marginBottom:10,color:`var(--text)`,fontSize:`var(--text-2xl)`,lineHeight:1.5},children:t(`i18n.compactionDescription`)}),r.body?(0,E.jsx)(Q6,{className:`markdown-compaction-message`,children:r.body}):(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`,fontSize:`var(--text-base)`},children:t(`i18n.noSummary`)}),(0,E.jsx)(c5,{readFiles:r.readFiles,modifiedFiles:r.modifiedFiles})]})]})})}function c5({readFiles:e,modifiedFiles:t}){let{t:n}=N();if(e.length+t.length===0)return null;let r=[];return e.length>0&&r.push(`${e.length} read`),t.length>0&&r.push(`${t.length} modified`),(0,E.jsxs)(`details`,{className:`compaction-file-details`,children:[(0,E.jsx)(`summary`,{children:n(`i18n.fileContext`,{details:r.join(`, `)})}),t.length>0&&(0,E.jsx)(l5,{title:n(`i18n.modifiedFiles`),files:t}),e.length>0&&(0,E.jsx)(l5,{title:n(`i18n.readFiles`),files:e})]})}function l5({title:e,files:t}){return(0,E.jsxs)(`div`,{className:`compaction-file-section`,children:[(0,E.jsx)(`div`,{className:`compaction-file-title`,children:e}),(0,E.jsx)(`ul`,{className:`compaction-file-list`,children:t.map(e=>(0,E.jsx)(`li`,{children:e},e))})]})}function u5({message:e,cwd:t,onOpenFile:n}){let{t:r}=N(),i=e.display===!1,[a,o]=(0,d.useState)(!i),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(!1),f=d5(e.content),p=f5(e.content),m=e.details!==void 0,h=m?m5(e.details):``,g=h5(e.customType),_=z8(e.timestamp);return(0,E.jsx)(`div`,{style:{marginBottom:16},children:(0,E.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:8,overflow:`hidden`,background:i?`var(--bg-subtle)`:`var(--bg)`,opacity:i&&!a?.82:1},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`7px 10px`,borderBottom:`1px solid var(--border)`,background:`var(--bg)`,color:`var(--text-muted)`,fontSize:`var(--text-base)`},children:[(0,E.jsx)(`span`,{style:{color:`var(--text-muted)`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,fontWeight:650},children:g}),i&&(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`,fontSize:`var(--text-sm)`},children:r(`i18n.hiddenExtensionMessage`)}),_&&(0,E.jsx)(`span`,{style:{marginLeft:`auto`,color:`var(--text-dim)`,fontSize:`var(--text-xs)`},children:_})]}),a?(0,E.jsxs)(`div`,{style:{padding:`6px 9px`},children:[p.length>0&&(0,E.jsx)(`div`,{style:{display:`flex`,gap:6,flexWrap:`wrap`,marginBottom:f?8:0},children:p.map((e,t)=>{let n=p5(e);return n?(0,E.jsx)(`img`,{src:n,alt:``,style:{maxWidth:240,maxHeight:240,borderRadius:6,objectFit:`contain`,display:`block`,border:`1px solid var(--border)`}},t):null})}),f?(0,E.jsx)(Q6,{className:`markdown-custom-message`,cwd:t,onOpenFile:n,children:f}):(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`,fontSize:`var(--text-base)`},children:r(`i18n.noMessage`)})]}):(0,E.jsx)(`button`,{onClick:()=>o(!0),style:{display:`block`,width:`100%`,padding:`8px 10px`,border:`none`,background:`transparent`,color:`var(--text-dim)`,cursor:`pointer`,fontSize:`var(--text-base)`,textAlign:`left`},children:f?g5(f):r(`i18n.showExtensionMessage`)}),(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`4px 9px`,borderTop:`1px solid var(--border)`,background:`var(--bg-subtle)`},children:[f||h?(0,E.jsx)(`button`,{onClick:()=>{bY(f||h).then(()=>{u(!0),setTimeout(()=>u(!1),1500)})},style:{padding:`3px 7px`,border:`none`,background:`none`,color:l?`var(--accent)`:`var(--text-dim)`,cursor:`pointer`,fontSize:`var(--text-sm)`},children:r(l?`i18n.copied`:`i18n.copy`)}):null,(m||i)&&(0,E.jsx)(`button`,{onClick:()=>{i?o(e=>!e):c(e=>!e)},style:{marginLeft:`auto`,padding:`3px 7px`,border:`none`,background:`none`,color:`var(--text-dim)`,cursor:`pointer`,fontSize:`var(--text-sm)`},children:r(i?a?`i18n.collapse`:`i18n.expand`:s?`i18n.hideDetails`:`i18n.showDetails`)})]}),m&&(i&&a||!i&&s)&&(0,E.jsx)(`pre`,{style:{margin:0,padding:`9px 10px`,borderTop:`1px solid var(--border)`,background:`var(--bg)`,color:`var(--text-muted)`,fontSize:`var(--text-base)`,lineHeight:1.5,whiteSpace:`pre-wrap`,wordBreak:`break-word`,maxHeight:360,overflow:`auto`,fontFamily:`var(--font-mono)`,contentVisibility:`auto`,containIntrinsicBlockSize:360},children:h})]})})}function d5(e){return typeof e==`string`?e:e.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
475
|
+
`)}function f5(e){return typeof e==`string`?[]:e.filter(e=>e.type===`image`)}function p5(e){let t=e;return e.source?e.source.type===`base64`?`data:${e.source.media_type};base64,${e.source.data}`:e.source.url??``:t.data?`data:${t.mimeType};base64,${t.data}`:``}function m5(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function h5(e){return e||`extension`}function g5(e){let t=e.replace(/\s+/g,` `).trim();return t?t.length>140?`${t.slice(0,140)}...`:t:`Show extension message`}function _5(e){let t=e.input;if(!t||typeof t!=`object`)return``;let n=Object.keys(t);if(n.length===0)return``;if(`command`in t)return String(t.command).slice(0,120);if(`path`in t)return String(t.path).slice(0,120);if(`file_path`in t)return String(t.file_path).slice(0,120);if(`pattern`in t)return String(t.pattern).slice(0,120);if(`query`in t)return String(t.query).slice(0,120);let r=t[n[0]];if(Array.isArray(r)){let e=r.map(e=>typeof e==`object`&&e&&`topic`in e?String(e.topic):null).filter(e=>e!==null&&e.length>0);return e.length>0?e.join(` | `).slice(0,120):`[${r.length} items]`}return String(r).slice(0,120)}function v5(e){let t=[];return e.input&&t.push(`${e.input.toLocaleString()} in`),e.output&&t.push(`${e.output.toLocaleString()} out`),e.cacheRead&&t.push(`${e.cacheRead.toLocaleString()} cache R`),e.cacheWrite&&t.push(`${e.cacheWrite.toLocaleString()} cache W`),e.cost?.total&&t.push(`$${e.cost.total.toFixed(4)}`),t.join(` · `)}function y5({message:e,sessionId:t,streamingOutput:n,longBlockCollapseChars:r}){let[i,a]=(0,d.useState)(null),[o,s]=(0,d.useState)(!1),[c,l]=(0,d.useState)(null),u=!e.output&&e.exitCode===void 0&&!e.cancelled,f=e.cancelled||e.exitCode!==void 0&&e.exitCode!==0,p=t&&e.fullOutputPath?`/api/agent/${encodeURIComponent(t)}/bash-output?path=${encodeURIComponent(e.fullOutputPath)}`:null,m=e.truncated&&p&&i===null,h=i??e.output;async function g(){if(p){s(!0),l(null);try{let e=await(await fetch(p)).json();e.success?a(e.data?.output??``):l(e.error??`failed`)}catch(e){l(String(e))}finally{s(!1)}}}let _=e.excludeFromContext?`bash (local)`:`bash`,v={type:`toolCall`,toolCallId:`bash-${e.timestamp??``}`,toolName:_,input:{command:e.command}},y=u?void 0:{role:`toolResult`,toolCallId:v.toolCallId,toolName:_,content:h?[{type:`text`,text:h}]:[],isError:f,timestamp:e.timestamp};return(0,E.jsxs)(`div`,{style:{margin:`6px 0`},children:[(0,E.jsx)(Z8,{block:v,result:y,streamingOutput:u?n:void 0,longBlockCollapseChars:r}),e.truncated&&p&&(0,E.jsxs)(`div`,{style:{padding:`4px 10px`,fontSize:`var(--text-sm)`,marginTop:-1},children:[m&&(0,E.jsx)(`button`,{onClick:g,disabled:o,style:{background:`none`,border:`none`,color:`var(--accent)`,cursor:o?`default`:`pointer`,fontSize:`var(--text-sm)`,padding:0,textDecoration:`underline`},children:o?`loading…`:`view full output`}),(0,E.jsx)(`a`,{href:`${p}&download=1`,style:{marginLeft:m?10:0,color:`var(--accent)`,fontSize:`var(--text-sm)`,textDecoration:`underline`},children:`download full output`}),c&&(0,E.jsxs)(`span`,{style:{marginLeft:6,color:`var(--text-dim)`,fontSize:`var(--text-sm)`},children:[`(`,c,`)`]})]})]})}function b5(e){if(e.role===`user`){let t=e;return typeof t.content==`string`?t.content:t.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
476
476
|
`)}if(e.role===`assistant`){let t=[];for(let n of e.content)n.type===`text`?t.push(n.text):n.type===`thinking`?t.push(n.thinking??``):n.type===`toolCall`&&t.push(`${n.toolName}(${JSON.stringify(n.input??{})})`);return t.join(`
|
|
477
477
|
`)}if(e.role===`toolResult`)return e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
478
|
-
`);if(e.role===`bashExecution`){let t=e;return`${t.command}\n${t.output??``}`}return``}var y5=100,b5=44;function x5({messages:e,t,onJump:n}){let[r,i]=(0,d.useState)(``),[a,o]=(0,d.useState)(0),s=(0,d.useRef)(null),c=(0,d.useRef)(null),l=(0,d.useMemo)(()=>e.map((e,t)=>({msgIdx:t,role:e.role,text:v5(e)})),[e]),u=(0,d.useMemo)(()=>{let e=r.trim().toLowerCase();if(!e)return[];let t=[];for(let{msgIdx:n,role:r,text:i}of l){let a=0,o=i.toLowerCase().indexOf(e,a);for(;o!==-1&&t.length<y5;)t.push({msgIdx:n,role:r,text:i,start:o}),a=o+1,o=i.toLowerCase().indexOf(e,a);if(t.length>=y5)break}return t},[l,r]);(0,d.useEffect)(()=>{o(e=>Math.min(e,Math.max(0,u.length-1)))},[u.length]);let f=(0,d.useCallback)(e=>{let t=u[e];t&&(n(t.msgIdx),o(e))},[u,n]),m=(0,d.useCallback)(e=>{if(u.length!==0){if(e.key===`Enter`){e.preventDefault();let t=e.shiftKey?-1:1,n=(a+t+u.length)%u.length;f(n)}else e.key===`ArrowDown`?(e.preventDefault(),f(Math.min(a+1,u.length-1))):e.key===`ArrowUp`&&(e.preventDefault(),f(Math.max(a-1,0)))}},[a,f,u.length]);return(0,d.useEffect)(()=>{(c.current?.children[a])?.scrollIntoView({block:`nearest`})},[a]),(0,E.jsxs)(`div`,{style:{position:`relative`,flex:`1 1 0`,minWidth:0,maxWidth:2040},"data-testid":`search-box`,children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:4,padding:`0 6px`,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:6,height:30,boxSizing:`border-box`},children:[(0,E.jsx)(Hr,{size:p.xl,color:`var(--text-muted)`,style:{flexShrink:0}}),(0,E.jsx)(`input`,{ref:s,value:r,onChange:e=>i(e.target.value),onKeyDown:m,placeholder:t(`chat.searchPlaceholder`),style:{flex:1,minWidth:0,background:`transparent`,border:`none`,outline:`none`,color:`var(--text)`,fontSize:`var(--text-sm)`}}),r&&(0,E.jsx)(`button`,{type:`button`,onClick:()=>{i(``),s.current?.focus()},"aria-label":t(`chat.clearSearch`),style:{border:`none`,background:`transparent`,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-sm)`,flexShrink:0,padding:0},children:`✕`})]}),r.trim()&&(0,E.jsx)(`div`,{ref:c,style:{position:`absolute`,top:`calc(100% + 6px)`,left:0,right:0,maxHeight:`min(55vh, 480px)`,overflowY:`auto`,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:8,boxShadow:`0 8px 24px var(--shadow-color)`,zIndex:60},children:u.length===0?(0,E.jsx)(`div`,{style:{padding:`10px 12px`,fontSize:`var(--text-base)`,color:`var(--text-muted)`},children:t(`chat.searchNoResults`)}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{style:{padding:`6px 12px`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`,borderBottom:`1px solid var(--border)`},children:t(`chat.searchResults`,{count:u.length})}),u.map((e,t)=>{let n=r.trim(),i=Math.max(0,e.start-b5),o=Math.min(e.text.length,e.start+n.length+b5),s=i>0?`…`:``,c=o<e.text.length?`…`:``,l=`${s}${e.text.slice(i,o)}${c}`;return(0,E.jsxs)(`button`,{type:`button`,onClick:()=>f(t),"data-testid":`search-result`,style:{display:`block`,width:`100%`,textAlign:`left`,padding:`8px 12px`,border:`none`,borderBottom:`1px solid var(--border)`,background:t===a?`var(--bg-selected)`:`transparent`,color:`var(--text)`,cursor:`pointer`,fontSize:`var(--text-base)`,lineHeight:1.5},children:[(0,E.jsxs)(`span`,{style:{color:`var(--text-dim)`,marginRight:6,fontSize:`var(--text-sm)`},children:[`#`,e.msgIdx]}),(0,E.jsx)(`span`,{children:S5(l,n)})]},`${e.msgIdx}-${e.start}`)})]})})]})}function S5(e,t){let n=[],r=e,i=0;for(;r.length>0;){let e=r.toLowerCase().indexOf(t.toLowerCase());if(e===-1){n.push(r);break}e>0&&n.push(r.slice(0,e)),n.push((0,E.jsx)(`mark`,{children:r.slice(e,e+t.length)},i++)),r=r.slice(e+t.length)}return n}function C5({modelName:e,messageCount:t,toolCallCount:n,t:r}){let i=[`${t} ${r(t===1?`chat.message`:`chat.messages`)}`];return n>0&&i.push(`${n} ${r(n===1?`chat.toolCall`:`chat.toolCalls`)}`),(0,E.jsxs)(`div`,{"data-testid":`pd-group-header`,style:{display:`flex`,alignItems:`center`,gap:8,width:`auto`,minHeight:24,padding:`3px 10px`,border:`1px solid var(--border)`,borderRadius:8,background:`var(--bg-panel)`,color:`var(--text-muted)`,fontSize:`var(--text-base)`,lineHeight:1.6},children:[e&&(0,E.jsx)(`span`,{style:{fontWeight:700,color:`var(--text)`,whiteSpace:`nowrap`},children:e}),(0,E.jsx)(`span`,{style:{minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:i.join(` · `)})]})}function w5(e){let{rows:t,messages:n,entryIds:r,modelNames:i,messageCwd:a,onOpenFile:o,sessionBusy:s,isNew:c,handleFork:l,forkingEntryId:u,handleNavigate:f,handleEditContent:p,sessionId:m,longBlockCollapseChars:h,recentExpandedBlockKeys:g,isStreaming:_,flashKey:v,itemRef:y,t:b,messageRefs:x,lastUserMsgRef:S,visibleRefIndexByMessage:C,scrollContainerRef:w,virtualizerRef:T,initialCache:D}=e,O=(0,d.useRef)(!1);(0,d.useLayoutEffect)(()=>{if(O.current)return;O.current=!0;let e=w.current;e&&e.scrollHeight>e.clientHeight&&(e.scrollTop=e.scrollHeight)},[w]);let k=new Map;for(let e of n)e.role===`toolResult`&&k.set(e.toolCallId,e);let A=new Map;{let e=0;for(let t=0;t<n.length;t++)n[t].role===`user`?(e+=1,A.set(t,e)):n[t].role===`assistant`&&e>0&&A.set(t,e)}let j=-1;for(let e=n.length-1;e>=0;e--)if(n[e].role===`user`){j=e;break}let M=(e,t)=>n=>{x.current[t]=n,e===j&&(S.current=n)},N=(e,t={})=>{let d=t.messageOverride??n[e],v=d.role===`user`&&e>0&&n[e-1].role===`assistant`?r[e-1]:void 0,y=d.role===`user`||d.role===`assistant`,b=C.get(e),x=!1;if(d.role===`assistant`){x=!0;for(let t=e+1;t<n.length;t++){let e=n[t].role;if(e===`user`)break;if(e===`assistant`){x=!1;break}}x&&_&&e===n.length-1&&(x=!1)}t.showTimestamp!==void 0&&(x=t.showTimestamp);let S;if(d.role===`assistant`){for(let t=e-1;t>=0;t--)if(n[t].role===`user`){S=n[t].timestamp;break}}let w=(0,E.jsx)(z8,{message:d,toolResults:k,modelNames:i,cwd:a,onOpenFile:o,entryId:r[e],onFork:s||c||e===0&&d.role===`user`?void 0:l,forking:u===r[e],onNavigate:s?void 0:f,prevAssistantEntryId:s?void 0:v,onEditContent:p,showTimestamp:x,turnStartTimestamp:S,sessionId:m,longBlockCollapseChars:h,recentExpandedBlockKeys:g,modelLabelVisible:t.modelLabelVisible,turnNumber:d.role===`user`||d.role===`assistant`&&t.isAnswer?A.get(e):void 0},`message-view-${e}`);return!y||t.attachRef===!1||b===void 0?w:(0,E.jsx)(`div`,{ref:M(e,b),children:w},`message-ref-${e}`)},P=e=>e.role!==`assistant`||!e.provider||!e.model?null:i?.[`${e.provider}/${e.model}`]??i?.[e.model]??e.model,ee=e=>{if(e.kind===`groupHeader`){let t=[];for(let r=e.groupUserIdx+1;r<=e.finalAssistantIdx;r++){let e=n[r];if(!e||e.role!==`assistant`)continue;let i=P(e);i&&!t.includes(i)&&t.push(i)}return(0,E.jsx)(C5,{modelName:t.join(` / `)||void 0,messageCount:e.messageCount,toolCallCount:e.toolCallCount,t:b})}return N(e.msgIdx,{attachRef:e.attachRef,messageOverride:e.messageOverride,showTimestamp:e.showTimestamp,modelLabelVisible:e.isProcess||e.isProcessFinal?!1:void 0,isAnswer:e.isAnswer})},F=e=>e.kind===`groupHeader`?8:e.isProcess||e.isProcessFinal?e.groupLast?14:8:0;return(0,E.jsx)(N8,{ref:T,data:t,cache:D,itemSize:200,bufferSize:400,scrollRef:w,children:e=>{let t=e.kind===`groupHeader`&&e.processRefIdx!==void 0?t=>{x.current[e.processRefIdx]=t}:void 0;return(0,E.jsx)(`div`,{className:v===e.key?`search-flash`:void 0,ref:y(e.key,t),style:{marginBottom:F(e)},children:ee(e)},e.key)}})}var T5={position:`relative`,display:`flex`,alignItems:`stretch`,flexShrink:0,width:`100%`,minWidth:0,height:36,gap:4,paddingLeft:4,paddingRight:4,borderBottom:`1px solid var(--border)`,background:`var(--bg)`},E5={display:`flex`,alignItems:`center`,justifyContent:`center`,alignSelf:`center`,width:32,height:32,padding:0,background:`transparent`,border:`1px solid var(--border)`,borderRadius:7,color:`var(--text-muted)`,flexShrink:0,cursor:`pointer`,transition:`color 0.12s, background 0.12s, border-color 0.12s`,"--hover-color":`var(--text)`,"--hover-bg":`var(--bg-selected)`,"--hover-border":`color-mix(in srgb, var(--accent) 35%, transparent)`},D5={display:`flex`,alignItems:`center`,gap:10,paddingLeft:12,paddingRight:12,height:`100%`,border:`none`,fontSize:`var(--text-sm)`,color:`var(--text-muted)`,whiteSpace:`nowrap`,cursor:`pointer`,fontVariantNumeric:`tabular-nums`,transition:`color 0.1s, background 0.1s`,"--hover-color":`var(--text)`},O5={flexShrink:0};function k5(e){return e>=1e6?`${(e/1e6).toPrecision(3)}M`:e>=1e3?`${(e/1e3).toPrecision(3)}K`:String(e)}function A5({sessionStats:e,contextUsage:t,activeTopPanel:n,toggleTopPanel:r,isMobile:i,t:a,locale:o}){let s=e?.tokens,c=e?.cost??0,l=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}k`:String(e),u=c>0?c>=.01?`$${c.toFixed(2)}`:`<$0.01`:null,d=`var(--text-muted)`,f=null;if(t?.contextWindow){let e=t.percent;e!==null&&e>90?d=`var(--status-error)`:e!==null&&e>70&&(d=`color-mix(in srgb, var(--status-warning) 95%, transparent)`),f=e===null?`? / ${l(t.contextWindow)}`:`${e.toFixed(0)}% / ${l(t.contextWindow)}`}let m=[];s&&(m.push(`in: ${s.input.toLocaleString(o)}`),m.push(`out: ${s.output.toLocaleString(o)}`),m.push(`cache read: ${s.cacheRead.toLocaleString(o)}`),m.push(`cache write: ${s.cacheWrite.toLocaleString(o)}`),c>0&&m.push(`cost: $${c.toFixed(4)}`));let h=s?s.input+s.cacheRead+s.cacheWrite:0,g=s&&h>0?s.cacheRead/h*100:null,_=(e,t)=>e===null?null:(0,E.jsx)(oi,{label:`${a(t)} · ${e.toFixed(1)}%`,children:(0,E.jsxs)(`span`,{style:{fontSize:`var(--text-xs)`,padding:`0 4px`,borderRadius:8,border:`1px solid color-mix(in srgb, var(--accent) 45%, transparent)`,background:`color-mix(in srgb, var(--accent) 10%, transparent)`,color:`var(--accent)`},children:[e.toFixed(1),`%`]})});if(t?.contextWindow){let e=t.percent;m.push(`context: ${e===null?`unknown`:`${e.toFixed(1)}%`} of ${t.contextWindow.toLocaleString()} tokens`)}let v=m.join(` | `);return(0,E.jsx)(oi,{label:v||a(`session.title`),wrapperStyle:{marginLeft:`auto`,flex:`0 0 auto`},children:(0,E.jsxs)(`button`,{type:`button`,onClick:()=>r(`session`),"aria-label":a(`session.title`),"aria-pressed":n===`session`,style:{...D5,background:n===`session`?`var(--bg-selected)`:`none`,borderTop:n===`session`?`2px solid var(--accent)`:`2px solid transparent`},className:`hover-shift`,children:[i&&(0,E.jsxs)(`svg`,{width:p.xl,height:p.xl,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,E.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12`,y2:`12`}),(0,E.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12.01`,y2:`8`})]}),!i&&s&&s.input>0&&(0,E.jsxs)(`span`,{style:j5,children:[(0,E.jsxs)(`svg`,{width:p.base,height:p.base,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:`var(--accent)`},children:[(0,E.jsx)(`line`,{x1:`5`,y1:`8.5`,x2:`5`,y2:`1.5`}),(0,E.jsx)(`polyline`,{points:`2 4 5 1.5 8 4`})]}),l(s.input)]}),!i&&s&&s.output>0&&(0,E.jsxs)(`span`,{style:j5,children:[(0,E.jsxs)(`svg`,{width:p.base,height:p.base,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:`var(--status-info)`},children:[(0,E.jsx)(`line`,{x1:`5`,y1:`1.5`,x2:`5`,y2:`8.5`}),(0,E.jsx)(`polyline`,{points:`2 6 5 8.5 8 6`})]}),l(s.output)]}),!i&&s&&s.cacheRead>0&&(0,E.jsxs)(`span`,{style:j5,children:[(0,E.jsxs)(`svg`,{width:p.base,height:p.base,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:`var(--status-success)`},children:[(0,E.jsx)(`path`,{d:`M8.5 5a3.5 3.5 0 1 1-1-2.45`}),(0,E.jsx)(`polyline`,{points:`6.5 1.5 8.5 2.5 7.5 4.5`})]}),l(s.cacheRead),_(g,`session.cacheReadRate`)]}),!i&&s&&s.cacheWrite>0&&(0,E.jsxs)(`span`,{style:j5,children:[(0,E.jsxs)(`svg`,{width:p.base,height:p.base,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:`var(--status-warning)`},children:[(0,E.jsx)(`path`,{d:`M8.5 5a3.5 3.5 0 1 0-1-2.45`}),(0,E.jsx)(`polyline`,{points:`2.5 1.5 4.5 2.5 3.5 4.5`})]}),l(s.cacheWrite)]}),!i&&u&&(0,E.jsx)(`span`,{style:M5,children:u}),f&&(0,E.jsxs)(`span`,{style:{...j5,color:d},children:[(0,E.jsxs)(`svg`,{width:p.base,height:p.base,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`path`,{d:`M1 9 L1 5 Q1 1 5 1 Q9 1 9 5 L9 9`}),(0,E.jsx)(`line`,{x1:`1`,y1:`9`,x2:`9`,y2:`9`})]}),f]})]})})}var j5={display:`flex`,alignItems:`center`,gap:4},M5={display:`flex`,alignItems:`center`,color:`var(--text)`,fontWeight:500},N5={position:`absolute`,top:`100%`,left:0,right:0,zIndex:1500,background:`var(--bg)`,borderBottom:`1px solid var(--border)`,boxShadow:`0 10px 28px var(--shadow-color)`,maxHeight:`calc(100dvh - 80px)`,overflowY:`auto`},P5={padding:`10px 16px`,fontSize:`var(--text-base)`,color:`var(--text-muted)`,fontStyle:`italic`},F5={fontSize:`var(--text-sm)`,fontWeight:700,color:`var(--text)`,marginBottom:6},I5={fontSize:`var(--text-xs)`,borderRadius:8,border:`1px solid color-mix(in srgb, var(--accent) 45%, transparent)`,background:`color-mix(in srgb, var(--accent) 10%, transparent)`,color:`var(--accent)`,whiteSpace:`nowrap`};function L5(e){let[t,n]=(0,d.useState)(null),r=(0,d.useRef)(null);return(0,d.useEffect)(()=>{if(!e){r.current=null,n(null);return}r.current===null&&(r.current=Date.now());let t=()=>{document.hidden||r.current!==null&&n(ht((Date.now()-r.current)/1e3))};t();let i=setInterval(t,1e3),a=()=>{document.hidden||t()};return document.addEventListener(`visibilitychange`,a),()=>{clearInterval(i),document.removeEventListener(`visibilitychange`,a)}},[e]),t}function R5(e){if(e.role!==`user`)return null;if(typeof e.content==`string`){let t=e.content.trim();return t.length>0?t:null}let t=e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
479
|
-
`).trim();return t.length>0?t:null}function z5({session:e,newSessionCwd:t,onAgentEnd:n,onSessionCreated:r,onSessionForked:i,modelsRefreshKey:a,chatInputRef:o,onOpenModelConfig:s,onSessionRenamed:c,windowTitleBase:l,onOpenFile:u,toolbarExtra:f,closedWidgetKeys:m,onCloseWidget:h,onExtensionWidgetsChange:g,onExtensionDialogChange:_}){let{t:v,locale:y}=N(),{scrollStepPx:b,autoReloadSeconds:x,longBlockCollapseChars:S,recentBlocksExpanded:C,widgetGeometries:w,setWidgetGeometry:T,widgetMessages:D,startScreenMessages:O}=ge(),{soundEnabled:k,onSoundToggle:A,playDoneSound:j,unlockAudio:M}=QJ(),P=ne(),ee=oe(),F=(0,d.useRef)(j);F.current=j;let te=(0,d.useRef)(k);te.current=k;let re=(0,d.useRef)(null),ae=(0,d.useCallback)(()=>{te.current&&F.current(),n?.()},[n]),I=(0,d.useCallback)(e=>{o?.current?.insertIfEmpty(e)},[o]),L=(0,d.useCallback)(e=>{o?.current?.fillInput(e)},[o]),[se,R]=(0,d.useState)({kind:`idle`}),ce=pe(),le=(0,d.useRef)(null),[ue,de]=(0,d.useState)(null),fe=pe(),me=(0,d.useRef)(null),he=(0,d.useRef)(null),{activeTopPanel:_e,toggleTopPanel:ve,closeTopPanel:ye}=Me(),be=pe(),xe=(0,d.useCallback)(()=>{be.schedule(()=>{ye()},150)},[be,ye]),Se=be.cancel;(0,d.useEffect)(()=>{ce.cancel(),R({kind:`idle`}),de(null),le.current=e?.id??null},[e?.id,ce]);let Ce=(0,d.useCallback)(()=>{e&&window.open(`/api/sessions/${encodeURIComponent(e.id)}/export?inline=1`,`_blank`,`noopener,noreferrer`)},[e]),we=(0,d.useCallback)((e,t)=>{vY(t).then(()=>{fe.cancel(),de(e),fe.schedule(()=>de(null),1400)})},[fe]),{loading:Te,error:Ee,messages:De,entryIds:Oe,streamState:ke,agentRunning:Ae,bashRunning:je,bashOutput:Ne,pendingBash:Pe,modelNames:Fe,modelList:Ie,modelError:Le,modelScopeWarnings:Re,modelThinkingLevels:ze,modelThinkingLevelMaps:Be,toolPreset:Ve,thinkingLevel:He,retryInfo:Ue,contextUsage:We,forkingEntryId:Ge,isCompacting:Ke,compactError:qe,compactResult:Ye,displayModel:Xe,sessionStats:Ze,systemPrompt:Qe,slashCommands:$e,slashCommandsLoading:et,queuedMessages:tt,notices:nt,noticeModals:rt,dismissNoticeModal:it,extensionDialog:at,extensionCustomUi:ot,extensionStatuses:st,extensionWidgets:ct,respondToExtensionUi:lt,sendExtensionCustomInput:ut,isAutoModelSelection:dt,agentPhase:ft,commandBusy:pt,isNew:mt,tree:gt,sessionIdRef:_t,activeLeafId:vt,loadContext:yt,messagesEndRef:bt,scrollContainerRef:xt,lastUserMsgRef:St,handleSend:Ct,handleAbort:wt,handleFork:Tt,handleNavigate:Et,handleLeafChange:Dt,handleModelChange:Ot,handleCompact:kt,handleSteer:At,handleFollowUp:jt,handlePromptWithStreamingBehavior:Mt,handleAbortCompaction:Nt,handleRecallQueue:Pt,handleBuiltinSlashCommand:Ft,handleToolPresetChange:It,handleThinkingLevelChange:Lt,loadSlashCommands:Rt,setSessionStatsOverride:zt}=UJ({session:e,newSessionCwd:t,onAgentEnd:ae,onSessionCreated:r,onSessionForked:i,modelsRefreshKey:a,chatInputRef:o});(0,d.useEffect)(()=>{g?.(ct)},[ct,g]);let Bt=Ae||je,Vt=(0,d.useCallback)(e=>{Bt?e.startsWith(`/`)?Mt(e,`steer`):At(e):Ct(e)},[Bt,At,Mt,Ct]),Ht=(0,d.useCallback)(async()=>{let t=e?.id;if(!(!t||se.kind===`naming`)){ce.cancel(),ye(),R({kind:`naming`});try{let e=await fetch(`/api/sessions/${encodeURIComponent(t)}/auto-name`,{method:`POST`}),n=await e.json().catch(()=>({}));if(!e.ok||!n.title)throw Error(n.error||`HTTP ${e.status}`);let r=n.title.trim();if(le.current!==t)return;c?.(t,r),zt(e=>e?.sessionId===t?{...e,sessionName:r}:e),R({kind:`success`}),ce.schedule(()=>R({kind:`idle`}),1800)}catch(e){if(le.current!==t)return;let n=e instanceof Error?e.message:String(e);R({kind:`error`,message:n}),ce.schedule(()=>R({kind:`idle`}),5e3)}}},[se.kind,ce,e?.id,ye,c,zt]),Ut=(0,d.useCallback)(async e=>{let t=await Ft(e);return t.handled&&t.action===`openSessionStats`&&ve(`session`),t},[Ft,ve]),Wt=(0,d.useMemo)(()=>{let e=ke.streamingMessage;if(!e||e.role!==`assistant`)return;let t=0;for(let e of De)e.role===`user`&&(t+=1);return t>0?t:void 0},[De,ke.streamingMessage]),Gt=(0,d.useMemo)(()=>{if(C==null)return;let e=[];De.forEach((t,n)=>{t.role===`assistant`&&(t.content??[]).forEach((t,r)=>{t.type===`thinking`?e.push(Je(`thinking`,Oe[n]??``,void 0,r)):t.type===`toolCall`&&e.push(Je(`toolCall`,``,t.toolCallId))})});let t=e.slice(-((C??0)+1));return new Set(t)},[De,Oe,C]),{runningSessionIds:Jt,runningPhaseSince:Yt,runningBusySince:Xt}=Kt(),Zt=e?.id??_t.current??``,$t=Jt.has(Zt)||Ae||pt||je,en=L5($t),tn=qt($t,Yt[Zt]),nn=qt($t,Xt[Zt]),rn=oY(yZ(st)),an=(0,d.useCallback)(()=>{let e=_t.current;e&&yt(e,vt,!0)},[vt,yt,_t]);(0,d.useEffect)(()=>{if(!x||x<=0)return;let e=setInterval(()=>{let e=_t.current;e&&yt(e,vt,!0)},x*1e3);return()=>clearInterval(e)},[x,vt,yt,_t]),(0,d.useEffect)(()=>{!at||re.current===at.id||(re.current=at.id,Rq(`ui-chain`,`4b ExtensionDialog mounted, play sound`,`${at.method} id=${at.id.slice(0,8)} title=${JSON.stringify(at.title)}`),F.current())},[at]),(0,d.useEffect)(()=>{_?.(at!==null)},[at,_]),(0,d.useEffect)(()=>{Qt()},[]),(0,d.useEffect)(()=>{ie(Bt?wt:null)},[Bt,wt]);let on=(0,d.useRef)(``);(0,d.useEffect)(()=>{let e=()=>{if(document.hasFocus())return;let e=ke.isStreaming,t=l?` · ${l}`:``,n;if(at)n=`❓`;else if(Bt){let t=en??``;if(ft?.kind===`running_tools`)n=`🔧 ${t}`.trimEnd();else if(ft?.kind===`running_command`)n=`💻 ${t}`.trimEnd();else if(ft?.kind===`thinking`)n=`💡 ${t}`.trimEnd();else if(ft?.kind===`waiting_model`&&e){let e=[...De].reverse().find(e=>e.role===`assistant`),t=e&&e.role===`assistant`?e.usage:void 0;n=`⬇ ${k5(t?.input??0)}↑ ${k5(t?.output??0)}↓`}else n=`⏳ ${t}`.trimEnd()}else{let e;for(let t=De.length-1;t>=0;t--){let n=De[t];if(!(n.role!==`assistant`||!n.timestamp)){for(let r=t-1;r>=0;r--){let t=De[r];if(t.role===`user`&&t.timestamp){let r=Math.round((n.timestamp-t.timestamp)/1e3);r>0&&(e=r);break}}break}}if(e===void 0)return;n=`✅ ${ht(e)}`}let r=`${n}${t}`;r!==on.current&&(on.current=r,document.title=r)};e();let t=()=>{document.visibilityState===`hidden`&&e()};return document.addEventListener(`visibilitychange`,t),window.addEventListener(`blur`,e),()=>{document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`blur`,e)}},[ft,ke.isStreaming,en,De,Bt,l,at]);let sn=(0,d.useRef)(null);(0,d.useEffect)(()=>{Bt?sn.current===null&&(sn.current=Date.now()):sn.current=null},[Bt]),(0,d.useEffect)(()=>{if(!Bt&&!at)return;let e=()=>{if(!document.hidden||document.hasFocus())return;let e=l?` · ${l}`:``,t;if(at)t=`❓`;else if(Bt){let e=sn.current?ht((Date.now()-sn.current)/1e3):en??``;if(ft?.kind===`running_tools`)t=`🔧 ${e}`.trimEnd();else if(ft?.kind===`running_command`)t=`💻 ${e}`.trimEnd();else if(ft?.kind===`thinking`)t=`💡 ${e}`.trimEnd();else if(ft?.kind===`waiting_model`&&ke.isStreaming){let e=[...De].reverse().find(e=>e.role===`assistant`),n=e&&e.role===`assistant`?e.usage:void 0;t=`⬇ ${k5(n?.input??0)}↑ ${k5(n?.output??0)}↓`}else t=`⏳ ${e}`.trimEnd()}else return;let n=`${t}${e}`;n!==on.current&&(on.current=n,document.title=n)},t=setInterval(e,1e3);return document.addEventListener(`visibilitychange`,e),()=>{clearInterval(t),document.removeEventListener(`visibilitychange`,e)}},[Bt,at,ft,ke.isStreaming,De,l,en]);let[cn,ln]=(0,d.useState)(null),[un,dn]=(0,d.useState)(!0),fn=(0,d.useRef)(new Map),pn=(0,d.useRef)(new Map),mn=(0,d.useRef)(null),hn=(0,d.useRef)(!0),gn=(0,d.useRef)(0),_n=(0,d.useCallback)(()=>{let e=xt.current;e&&(e.scrollTop=e.scrollHeight),hn.current=!0,dn(!0)},[xt]),vn=(0,d.useCallback)(()=>{let e=xt.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight;if(hn.current&&t>0&&e.scrollHeight!==gn.current){gn.current=e.scrollHeight,e.scrollTop=e.scrollHeight;return}t<16?(hn.current=!0,dn(!0)):t>64&&(hn.current=!1,dn(!1)),gn.current=e.scrollHeight},[xt]),yn=(0,d.useRef)(new Map),bn=(0,d.useCallback)((e,t)=>{yn.current.set(e,t);let n=pn.current.get(e);return n||(n=t=>{if(yn.current.get(e)?.(t),!t){fn.current.get(e)?.disconnect(),fn.current.delete(e),yn.current.delete(e);return}let n=fn.current.get(e);n?n.disconnect():(n=new ResizeObserver(()=>{document.hidden||hn.current&&requestAnimationFrame(()=>{if(document.hidden)return;let e=xt.current;e&&hn.current&&(e.scrollTop=e.scrollHeight)})}),fn.current.set(e,n)),n.observe(t)},pn.current.set(e,n)),n},[xt]);(0,d.useEffect)(()=>()=>{fn.current.forEach(e=>e.disconnect()),fn.current.clear(),pn.current.clear(),yn.current.clear()},[]);let xn=e?.id??t??``;(0,d.useEffect)(()=>{if(In(!1),Ln.current=null,fn.current.forEach(e=>e.disconnect()),fn.current.clear(),pn.current.clear(),yn.current.clear(),kn.current=[],St.current=null,xt.current){xt.current.scrollTop=0;let e=xt.current.firstElementChild;if(e&&e.children.length===1){let t=e.firstElementChild;t&&t.style.height&&(t.style.height=`0px`)}}},[xn]),(0,d.useEffect)(()=>{let e=xt.current;if(!e)return;let t=new ResizeObserver(()=>{document.hidden||hn.current&&requestAnimationFrame(()=>{if(document.hidden)return;let e=xt.current;e&&hn.current&&(e.scrollTop=e.scrollHeight)})});return t.observe(e),()=>t.disconnect()},[xt]),(0,d.useEffect)(()=>()=>{},[]);let{isDragOver:Sn,handleDragEnter:Cn,handleDragOver:wn,handleDragLeave:Tn,handleDrop:En}=$J((0,d.useCallback)(e=>{Bt||o?.current?.addImages(e)},[Bt,o])),Dn=De.filter(e=>e.role===`user`||e.role===`assistant`),On=(0,d.useMemo)(()=>{let e=new Set,t=[];for(let n=De.length-1;n>=0;--n){let r=R5(De[n]);if(!(!r||e.has(r))&&(e.add(r),t.push(r),t.length>=50))break}return t.reverse()},[De]),kn=_Z(Dn.length),An=(0,d.useMemo)(()=>{for(let e=De.length-1;e>=0;e--)if(IY(De[e]))return e;return-1},[De]),jn=(0,d.useMemo)(()=>{let e=new Map,t=0;return De.forEach((n,r)=>{(n.role===`user`||n.role===`assistant`)&&e.set(r,t++)}),e},[De]),Mn=(0,d.useMemo)(()=>RY(De,{isLiveTail:(Bt||ke.isStreaming)&&An>=0,lastAnchorIdx:An,visibleRefIndexByMessage:jn}),[De,Bt,ke.isStreaming,An,jn]),Nn=(0,d.useMemo)(()=>zY(Mn),[Mn]),Pn=(0,d.useCallback)(e=>{let t=Nn.get(e);if(t===void 0)return null;let n=mn.current;return n?n.getItemOffset(t):null},[Nn]),[Fn,In]=(0,d.useState)(!1),Ln=(0,d.useRef)(null),Rn=Fn&&Ln.current?[Ln.current,200]:void 0;(0,d.useLayoutEffect)(()=>{Fn||Mn.length!==0&&xt.current&&(Ln.current=Mn.map(e=>e.estimate),In(!0))},[Fn,Mn,xt]);let[zn,Bn]=(0,d.useState)(null),Vn=(0,d.useRef)(null),Hn=(0,d.useCallback)(e=>{let t=Nn.get(e);if(t===void 0)return;let n=mn.current;if(!n)return;n.scrollToIndex(t,{align:`start`,offset:-24,smooth:!0});let r=Mn[t].key;Bn(r),Vn.current&&clearTimeout(Vn.current),Vn.current=setTimeout(()=>{Vn.current=null,Bn(e=>e===r?null:e)},1700)},[Mn,Nn]),Un=mt&&De.length===0&&!ke.isStreaming&&!Bt,Wn=!Ae&&!ke.isStreaming&&!pt&&!je;(0,d.useLayoutEffect)(()=>{if(!O.length||!Wn||!hn.current)return;let e=xt.current;e&&(e.scrollTop=e.scrollHeight)},[O.length,Wn,xt]);let Gn=e?.cwd??t??void 0,Kn=Xe?ze[`${Xe.provider}/${Xe.modelId}`]??null:null,qn=Xe?Be[`${Xe.provider}/${Xe.modelId}`]??null:null,Jn=(0,E.jsx)(fX,{ref:o,onSend:Ct,onAbort:wt,onSteer:Ae?At:void 0,onFollowUp:Ae?jt:void 0,onPromptWithStreamingBehavior:Ae?Mt:void 0,isStreaming:Bt,commandBusy:pt,model:Xe,isAutoModelSelection:dt,modelNames:Fe,modelList:Ie,modelError:Le,modelScopeWarnings:Re,onModelChange:Ot,onCompact:e||mt?kt:void 0,onReloadFromDisk:an,onAbortCompaction:Nt,isCompacting:Ke,compactError:qe,compactResult:Ye,toolPreset:Ve,onToolPresetChange:e||mt?It:void 0,thinkingLevel:He,onThinkingLevelChange:e||mt?Lt:void 0,availableThinkingLevels:Kn,thinkingLevelMap:qn,onOpenModelConfig:s,retryInfo:Ue,queuedMessages:tt,inputHistory:On,onRecallQueue:Pt,slashCommands:$e,slashCommandsLoading:et,onLoadSlashCommands:Rt,onBuiltinCommand:Ut,soundEnabled:k,onSoundToggle:A,onAudioUnlock:M,draftKey:e?.id??(t?`new:${t}`:void 0),cwd:e?.cwd??t});return Te?(0,E.jsx)(`div`,{className:`flex h-full items-center justify-center text-text-muted`,children:v(`chat.loadingSession`)}):Ee?(0,E.jsx)(`div`,{className:`flex h-full items-center justify-center text-red-400`,children:Ee}):(0,E.jsxs)(`div`,{ref:ln,className:`relative flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,style:{paddingBottom:`env(safe-area-inset-bottom)`},onDragEnter:Cn,onDragOver:wn,onDragLeave:Tn,onDrop:En,children:[Sn&&!Bt&&(0,E.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 z-50 flex animate-[drop-zone-in_0.15s_ease_both] items-center justify-center bg-[color-mix(in_srgb,var(--accent)_6%,transparent)] backdrop-blur-[1px]`,children:[(0,E.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:[0,.8,1.6].map(e=>(0,E.jsx)(`div`,{className:`absolute h-[720px] w-[720px] rounded-full border-[1.5px] border-solid border-[color-mix(in_srgb,var(--accent)_50%,transparent)] animate-[drop-ripple_2.4s_ease-out_infinite_backwards]`,style:{transformOrigin:`center`,animationDelay:`${e}s`}},e))}),(0,E.jsxs)(`svg`,{width:`280`,height:`280`,viewBox:`0 0 140 140`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:`drop-shadow-[0_6px_18px_var(--accent-glow)]`,children:[(0,E.jsx)(`rect`,{x:`28`,y:`44`,width:`84`,height:`60`,rx:`8`,fill:`color-mix(in srgb, var(--accent) 8%, transparent)`,stroke:`color-mix(in srgb, var(--accent) 50%, transparent)`,strokeWidth:`1.8`}),(0,E.jsx)(`path`,{d:`M36 100 L54 72 L68 88 L80 74 L104 100Z`,fill:`color-mix(in srgb, var(--accent) 16%, transparent)`,stroke:`color-mix(in srgb, var(--accent) 40%, transparent)`,strokeWidth:`1.4`,strokeLinejoin:`round`}),(0,E.jsx)(`circle`,{cx:`96`,cy:`58`,r:`8`,fill:`color-mix(in srgb, var(--accent) 22%, transparent)`,stroke:`color-mix(in srgb, var(--accent) 55%, transparent)`,strokeWidth:`1.6`}),(0,E.jsxs)(`g`,{stroke:`color-mix(in srgb, var(--accent) 45%, transparent)`,strokeWidth:`1.4`,strokeLinecap:`round`,children:[(0,E.jsx)(`line`,{x1:`96`,y1:`46`,x2:`96`,y2:`43`}),(0,E.jsx)(`line`,{x1:`96`,y1:`70`,x2:`96`,y2:`73`}),(0,E.jsx)(`line`,{x1:`84`,y1:`58`,x2:`81`,y2:`58`}),(0,E.jsx)(`line`,{x1:`108`,y1:`58`,x2:`111`,y2:`58`}),(0,E.jsx)(`line`,{x1:`87.5`,y1:`49.5`,x2:`85.4`,y2:`47.4`}),(0,E.jsx)(`line`,{x1:`104.5`,y1:`66.5`,x2:`106.6`,y2:`68.6`}),(0,E.jsx)(`line`,{x1:`104.5`,y1:`49.5`,x2:`106.6`,y2:`47.4`}),(0,E.jsx)(`line`,{x1:`87.5`,y1:`66.5`,x2:`85.4`,y2:`68.6`})]})]})]}),at&&(0,E.jsx)(H5,{request:at,onRespond:lt}),rt.length>0&&(0,E.jsx)(V5,{modals:rt,onDismiss:it}),ot&&(0,E.jsx)(W5,{request:ot,onInput:ut}),ct.filter(e=>!m.has(e.key)).map((e,t)=>(0,E.jsx)(G5,{widget:e,saved:w[e.key],messages:D[e.key]??[],defaultOffset:t%3==0?{dx:0,dy:0}:t%3==1?{dx:-80,dy:0}:{dx:80,dy:0},onCloseWidget:h,setWidgetGeometry:T,onSend:Vt,fillChatInput:L,portalTarget:cn},e.key)),(0,E.jsxs)(`div`,{ref:me,"data-testid":`chat-toolbar`,style:T5,children:[(0,E.jsx)(oi,{label:v(e?`history.full`:`history.unsaved`),children:(0,E.jsx)(`button`,{onClick:Ce,disabled:!e,"aria-label":v(`history.full`),style:{...E5,color:e?`var(--text-muted)`:`var(--text-dim)`,cursor:e?`pointer`:`not-allowed`,opacity:e?1:.45},className:e?`hover-shift`:void 0,children:(0,E.jsx)(zr,{size:p.base,style:O5})})}),(()=>{let t=!!(e&&(Ze?.userMessages??e.messageCount)>0),n=!e||!t||se.kind===`naming`,r=se.kind===`success`,i=se.kind===`error`,a=se.kind===`naming`?v(`title.generating`):v(r?`title.updated`:i?`title.failed`:`title.generate`),o=e?t?i?se.message:v(`title.generateSession`):v(`title.noMessages`):v(`title.unsaved`);return(0,E.jsx)(oi,{label:o,children:(0,E.jsx)(`button`,{type:`button`,onClick:()=>void Ht(),disabled:n,"aria-label":a,style:{...E5,color:i?`var(--status-error)`:r?`var(--status-success)`:n?`var(--text-dim)`:`var(--text-muted)`,cursor:n?`not-allowed`:`pointer`,opacity:n&&se.kind!==`naming`?.45:1,"--hover-color":i?`var(--status-error)`:`var(--text)`},className:n?void 0:`hover-shift`,children:se.kind===`naming`?(0,E.jsx)(Ar,{className:`animate-spin`,size:p.lg,"aria-hidden":`true`}):r?(0,E.jsx)(ur,{size:p.lg,"aria-hidden":`true`}):(0,E.jsx)(Nr,{size:p.lg,"aria-hidden":`true`,style:O5})})})})(),(0,E.jsx)(oi,{label:v(`i18n.branches`),children:(0,E.jsx)(ZX,{tree:gt,activeLeafId:vt,onLeafChange:Dt,inline:!0,compact:!0,containerRef:me,open:_e===`branches`,onToggle:()=>ve(`branches`),hasSession:!0})}),(0,E.jsx)(oi,{label:v(`system.prompt`),children:(0,E.jsx)(`button`,{ref:he,onClick:()=>ve(`system`),"aria-label":v(`system.prompt`),"aria-pressed":_e===`system`,style:{...E5,background:_e===`system`?`var(--bg-selected)`:`transparent`,borderColor:_e===`system`?`var(--accent)`:`var(--border)`,cursor:`pointer`,color:_e===`system`?`var(--text)`:`var(--text-muted)`,"--hover-color":`var(--text)`},className:`hover-shift`,children:(0,E.jsx)(yr,{size:p.base,style:O5})})}),(0,E.jsx)(oi,{label:v(`session.reload`),children:(0,E.jsx)(`button`,{type:`button`,"data-testid":`chat-toolbar-reload`,onClick:()=>void Ft(`/reload`),"aria-label":v(`session.reload`),style:{...E5,background:`transparent`,borderColor:`var(--border)`,cursor:`pointer`,color:`var(--text-muted)`,"--hover-color":`var(--text)`},className:`hover-shift`,children:(0,E.jsx)(Rr,{size:p.base,style:O5})})}),(0,E.jsx)(`div`,{style:{marginLeft:8,display:`flex`,alignItems:`center`,flex:1,minWidth:0},children:(0,E.jsx)(x5,{messages:De,t:v,onJump:Hn})}),Ze||We?(0,E.jsx)(A5,{sessionStats:Ze,contextUsage:We,activeTopPanel:_e,toggleTopPanel:ve,isMobile:P,t:v,locale:y}):null,f,_e===`system`&&(0,E.jsx)(`div`,{onMouseEnter:Se,onMouseLeave:xe,style:N5,children:Qe?(0,E.jsx)(`div`,{style:{padding:`12px 16px`,color:`var(--text-muted)`,fontSize:`var(--text-base)`,lineHeight:1.6,whiteSpace:`pre-wrap`,fontFamily:`var(--font-mono)`},children:Qe}):Qe===``?(0,E.jsx)(`div`,{style:P5,children:v(`system.empty`)}):(0,E.jsx)(`div`,{style:P5,children:v(`system.load`)})}),_e===`session`&&(0,E.jsx)(`div`,{onMouseEnter:Se,onMouseLeave:xe,style:{...N5,padding:`12px 16px`},children:Ze?(()=>{let e=[...Ze.sessionName?[{label:v(`session.name`),value:Ze.sessionName,copyField:null}]:[],{label:v(`session.file`),value:Ze.sessionFile??v(`session.inMemory`),copyField:`file`},{label:v(`session.id`),value:Ze.sessionId,copyField:`id`}],t=[[v(`session.user`),Ze.userMessages.toLocaleString(y)],[v(`session.assistant`),Ze.assistantMessages.toLocaleString(y)],[v(`session.toolCalls`),Ze.toolCalls.toLocaleString(y)],[v(`session.toolResults`),Ze.toolResults.toLocaleString(y)],[v(`session.total`),Ze.totalMessages.toLocaleString(y)]],n=Ze.tokens.input+Ze.tokens.cacheRead+Ze.tokens.cacheWrite,r=[[v(`session.input`),Ze.tokens.input.toLocaleString(y),{title:v(`session.inputHint`)}],[v(`session.output`),Ze.tokens.output.toLocaleString(y),{title:v(`session.outputHint`)}],...Ze.tokens.cacheRead>0?[[v(`session.cacheRead`),Ze.tokens.cacheRead.toLocaleString(y),{title:v(`session.cacheReadHint`),badge:n>0?(e=>`${e.toFixed(1)}%`)(Ze.tokens.cacheRead/n*100):void 0,badgeTitle:v(`session.cacheReadRate`)}]]:[],...Ze.tokens.cacheWrite>0?[[v(`session.cacheWrite`),Ze.tokens.cacheWrite.toLocaleString(y),{title:v(`session.cacheWriteHint`)}]]:[],[v(`session.total`),Ze.tokens.total.toLocaleString(y),{title:v(`session.totalHint`)}]],i=We??Ze.contextUsage,a=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}k`:String(e),o=[...Ze.cost>0?[[v(`session.cost`),`$${Ze.cost.toFixed(4)}`]]:[],...i?.contextWindow?[[v(`session.context`),`${i.percent===null?`?`:`${i.percent.toFixed(1)}%`} / ${a(i.contextWindow)}`]]:[]],s=(e,t,n=`left`,r=!1)=>(0,E.jsxs)(`div`,{style:{minWidth:0},children:[(0,E.jsx)(`div`,{style:F5,children:e}),(0,E.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:r?`max-content max-content max-content`:`auto minmax(0, 1fr) max-content`,columnGap:r?14:12,rowGap:4,justifyContent:r?`start`:void 0},children:t.map(([t,i,a])=>(0,E.jsxs)(`div`,{style:{display:`contents`},children:[(0,E.jsx)(oi,{label:a?.title,wrapperStyle:{display:`flex`,color:`var(--text-dim)`,whiteSpace:`nowrap`},children:(0,E.jsx)(`div`,{style:{color:`var(--text-dim)`,whiteSpace:`nowrap`},children:t})}),(0,E.jsx)(`div`,{style:{color:`var(--text-muted)`,minWidth:0,overflowWrap:r?`normal`:`anywhere`,textAlign:n,whiteSpace:n===`right`?`nowrap`:`normal`},children:i}),(0,E.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`flex-end`,minWidth:0},children:a?.badge&&(0,E.jsx)(oi,{label:`${a.badgeTitle??``}${a.badgeTitle?` · `:``}${a.badge}`,children:(0,E.jsx)(`span`,{style:{padding:`0 5px`,...I5},children:a.badge})})})]},`${e}:${t}`))})]}),c=(e,t)=>{let n=ue===e;return(0,E.jsx)(oi,{label:v(n?`session.copied`:e===`file`?`session.copyFile`:`session.copyId`),children:(0,E.jsx)(`button`,{type:`button`,onClick:()=>we(e,t),style:{alignSelf:`start`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:22,height:22,marginTop:-2,color:n?`var(--accent)`:`var(--text-dim)`,background:`transparent`,border:`1px solid var(--border)`,borderRadius:4,cursor:`pointer`,flex:`0 0 auto`,transition:`color 0.12s, border-color 0.12s, background 0.12s`,"--hover-color":`var(--accent)`,"--hover-border":`var(--accent)`,"--hover-bg":`var(--bg-hover)`},className:`hover-shift`,children:n?(0,E.jsx)(`svg`,{width:p.base,height:p.base,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}):(0,E.jsxs)(`svg`,{width:p.base,height:p.base,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`rect`,{x:`9`,y:`9`,width:p.lg,height:p.lg,rx:`2`,ry:`2`}),(0,E.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})})})},l=(0,E.jsxs)(`div`,{style:{minWidth:0},children:[(0,E.jsx)(`div`,{style:F5,children:v(`session.infoSection`)}),(0,E.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`auto minmax(0, 1fr) auto`,columnGap:12,rowGap:8,alignItems:`start`},children:e.map(e=>(0,E.jsxs)(`div`,{style:{display:`contents`},children:[(0,E.jsx)(`div`,{style:{color:`var(--text-dim)`,whiteSpace:`nowrap`},children:e.label}),(0,E.jsx)(`div`,{style:{color:`var(--text-muted)`,minWidth:0,overflowWrap:`anywhere`,wordBreak:`break-word`,whiteSpace:`normal`},children:e.value}),(0,E.jsx)(`div`,{children:e.copyField?c(e.copyField,e.value):null})]},`session-info:${e.label}`))})]});return(0,E.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:P?`1fr`:`minmax(360px, 1.7fr) minmax(140px, 0.55fr) minmax(190px, 0.75fr)`,gap:P?16:24,fontSize:`var(--text-base)`,lineHeight:1.5,fontFamily:`var(--font-mono)`},children:[l,s(v(`session.messages`),t),s(v(`session.tokens`),[...r,...o],`right`,!0)]})})():(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--text-muted)`,fontStyle:`italic`},children:v(`session.load`)})})]}),Un?(0,E.jsx)(`div`,{className:`relative flex flex-1 flex-col items-center justify-center overflow-y-auto px-4 py-8`,children:(0,E.jsxs)(`div`,{className:`w-full max-w-[820px]`,children:[(0,E.jsxs)(`div`,{className:`mb-3`,style:{textAlign:`center`,padding:`40px 0`},children:[ee==="default"?(0,E.jsxs)(`div`,{style:{marginBottom:20,fontSize:`var(--text-sm)`,color:`var(--text-muted)`,lineHeight:1.6},children:[v(`notify.permission.bannerHintBefore`),` `,(0,E.jsxs)(`svg`,{width:16,height:16,viewBox:`0 0 24 24`,fill:`none`,stroke:`var(--accent)`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{display:`inline-block`,verticalAlign:-2},children:[(0,E.jsx)(`path`,{d:`M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9`}),(0,E.jsx)(`path`,{d:`M10.3 21a1.94 1.94 0 0 0 3.4 0`})]}),` `,v(`notify.permission.bannerHintAfter`)]}):null,(0,E.jsx)(`div`,{style:{fontSize:`var(--text-6xl)`,fontWeight:700,fontStyle:`italic`,color:`var(--accent)`},children:`Pi Web`}),t?(0,E.jsx)(`div`,{style:{marginTop:6,fontSize:`var(--text-3xl)`,color:`var(--text-muted)`,fontFamily:`var(--font-mono)`},children:t}):null]}),O.length>0&&(0,E.jsx)(`div`,{style:{marginBottom:28},children:(0,E.jsx)(XJ,{messages:O,onSend:Vt,onFillInput:L,testIdPrefix:`start-screen-msg`,wrapperTestId:`start-screen-messages`,center:!0})}),(0,E.jsx)(`div`,{style:{position:`absolute`,top:12,left:0,right:0,zIndex:40,padding:`0 16px`,pointerEvents:`none`},children:(0,E.jsx)(`div`,{style:{maxWidth:820,margin:`0 auto`},children:(0,E.jsx)(B5,{notices:nt,floating:!0,align:`right`})})}),Jn]})}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,E.jsx)(`div`,{style:{position:`absolute`,top:12,left:0,right:P?0:`calc(${gY} + 48px)`,zIndex:40,padding:`0 16px`,pointerEvents:`none`},children:(0,E.jsx)(`div`,{style:{maxWidth:820,margin:`0 auto`},children:(0,E.jsx)(B5,{notices:nt,floating:!0,align:`right`})})}),(0,E.jsx)(`div`,{ref:xt,onScroll:vn,className:`min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto pt-4 [scrollbar-width:none] [overflow-anchor:none]`,style:{paddingRight:48},"data-testid":`message-list`,children:(0,E.jsx)(`div`,{style:{minWidth:0,padding:`0 16px`},children:(0,E.jsxs)(`div`,{style:{width:`100%`,minWidth:0,maxWidth:820,margin:`0 auto`},children:[Fn&&(0,E.jsx)(w5,{rows:Mn,messages:De,entryIds:Oe,modelNames:Fe,messageCwd:Gn,onOpenFile:u,sessionBusy:Bt,isNew:mt,handleFork:Tt,forkingEntryId:Ge,handleNavigate:Et,handleEditContent:I,sessionId:e?.id??_t.current??void 0,longBlockCollapseChars:S,recentExpandedBlockKeys:Gt,isStreaming:ke.isStreaming,flashKey:zn,itemRef:bn,t:v,messageRefs:kn,lastUserMsgRef:St,visibleRefIndexByMessage:jn,scrollContainerRef:xt,virtualizerRef:mn,initialCache:Rn},xn||`empty`),ke.isStreaming&&ke.streamingMessage&&(0,E.jsx)(`div`,{children:(0,E.jsx)(z8,{message:ke.streamingMessage,isStreaming:!0,modelNames:Fe,cwd:Gn,onOpenFile:u,longBlockCollapseChars:S,recentExpandedBlockKeys:Gt,turnNumber:Wt})}),(Ae||pt)&&(ft?.kind===`waiting_model`||ft?.kind===`thinking`||!ke.streamingMessage)&&(ft||pt)&&(0,E.jsx)(`div`,{className:`py-2 text-[0.8125rem] text-text-muted`,children:(0,E.jsx)(JJ,{phase:ft??{kind:`running_command`},elapsed:tn,totalElapsed:nn})}),je&&(0,E.jsx)(`div`,{className:`py-2 text-[0.8125rem] text-text-muted`,children:(0,E.jsx)(JJ,{phase:{kind:`running_command`},elapsed:tn,totalElapsed:nn})}),Pe&&(0,E.jsx)(z8,{message:{role:`bashExecution`,command:Pe.command,output:``,excludeFromContext:Pe.excludeFromContext},streamingBashOutput:Ne,sessionId:e?.id??_t.current??void 0,longBlockCollapseChars:S}),Ae&&(0,E.jsx)(`div`,{style:{height:48}}),(0,E.jsx)(`div`,{ref:bt})]})})}),!un&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`span`,{style:{position:`absolute`,left:0,right:0,bottom:0,height:30,background:`linear-gradient(to bottom, transparent, var(--bg))`,pointerEvents:`none`,zIndex:49}}),(0,E.jsx)(`button`,{type:`button`,onClick:_n,"aria-label":v(`chat.scrollToLatest`),"data-testid":`scroll-to-latest`,style:{position:`absolute`,bottom:0,left:`50%`,transform:`translateX(-50%)`,width:`min(100% / 3, 260px)`,zIndex:50,cursor:`pointer`,background:`transparent`,border:`none`,padding:0,height:30,display:`flex`,alignItems:`flex-end`,justifyContent:`center`},children:(0,E.jsx)(oi,{label:v(`chat.scrollToLatest`),children:(0,E.jsx)(`span`,{style:{position:`absolute`,bottom:4,left:`50%`,transform:`translateX(-50%)`,width:12,height:11,display:`flex`,alignItems:`flex-end`,justifyContent:`center`,cursor:`pointer`},children:(0,E.jsx)(`span`,{style:{position:`relative`,width:0,height:0,borderLeft:`6px solid transparent`,borderRight:`6px solid transparent`,borderTop:`7px solid var(--text-muted)`,pointerEvents:`none`}})})})})]}),P?null:(0,E.jsx)(gZ,{messages:De,streamingMessage:ke.streamingMessage,scrollContainer:xt,messageRefs:kn,resolveMessageOffset:Pn,scrollStepPx:b,onWindowJumpTo:e=>{let t=xt.current;t&&(t.scrollTop=e)}})]}),(0,E.jsxs)(`div`,{className:`relative`,children:[(0,E.jsx)(`div`,{style:{padding:`0 16px`,paddingRight:P?16:64},children:(0,E.jsx)(`div`,{style:{maxWidth:820,margin:`0 auto`}})}),O.length>0&&Wn&&(0,E.jsx)(`div`,{style:{padding:`0 16px`,paddingRight:P?16:64},children:(0,E.jsx)(`div`,{style:{maxWidth:820,margin:`0 auto`,paddingBottom:8},children:(0,E.jsx)(XJ,{messages:O,onSend:Vt,onFillInput:L,testIdPrefix:`start-screen-msg`,wrapperTestId:`start-screen-messages`})})}),Jn]}),(0,E.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,flexShrink:0,minWidth:0,height:36,padding:`0 12px`,borderTop:`1px solid var(--border)`,gap:8},children:(0,E.jsx)(oi,{label:rn,wrapperStyle:{display:`flex`,flex:1,minWidth:0},children:(0,E.jsx)(`div`,{role:`status`,"aria-label":rn,style:{alignSelf:`stretch`,display:`flex`,alignItems:`center`,flex:1,minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-base)`,color:`var(--text-dim)`},children:rn})})})]})]})}function B5({notices:e,floating:t=!1,align:n=`left`}){return e.length===0?null:(0,E.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:n===`right`?`flex-end`:`stretch`,marginBottom:t?0:10},children:e.map((n,r)=>{let i=n.type===`error`?`var(--status-error)`:n.type===`warning`?`var(--status-warning)`:n.type===`success`?`var(--status-success)`:`var(--accent)`;return(0,E.jsxs)(`div`,{className:`notice-shelf-item`,style:{display:`flex`,alignItems:`center`,gap:10,minHeight:60,marginBottom:r===e.length-1?0:6,borderRadius:14,border:`1px solid color-mix(in srgb, var(--border) 70%, transparent)`,background:`var(--bg)`,color:`var(--text-muted)`,width:`fit-content`,maxWidth:`min(100%, 620px)`,boxShadow:t?`0 1px 2px var(--shadow-color), 0 10px 28px -14px var(--shadow-color)`:`0 1px 2px var(--shadow-color), 0 8px 24px -12px var(--shadow-color)`,fontSize:`var(--text-4xl)`,lineHeight:1.45,transformOrigin:`top center`,animation:n.exiting?`notice-shelf-out 0.18s ease-in forwards`:`notice-shelf-in 0.18s ease-out both`,padding:`0 12px`},children:[(0,E.jsx)(`span`,{style:{width:7,height:7,borderRadius:`50%`,background:i,flexShrink:0}}),(0,E.jsx)(`span`,{style:{padding:`14px 0`,minWidth:0,maxWidth:`100%`,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:n.message})]},n.id)})})}function V5({modals:e,onDismiss:t}){let{t:n}=N();return(0,E.jsx)(E.Fragment,{children:e.map((e,r)=>(0,E.jsx)(GX,{variant:e.type===`error`?`error`:`normal`,align:`center`,width:520,height:320,initialOffset:{dx:r%3*24,dy:r%3*24},title:e.type===`error`?n(`chat.notifyErrorTitle`):n(`chat.notifyWarningTitle`),footer:(0,E.jsx)(`button`,{onClick:()=>t(e.id),style:{padding:`6px 14px`,borderRadius:6,border:`1px solid var(--border)`,background:`var(--bg)`,color:`var(--text)`,cursor:`pointer`},children:n(`chat.close`)}),children:(0,E.jsx)(`div`,{style:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,fontSize:`var(--text-lg)`,lineHeight:1.6,color:`var(--text)`},children:e.message})},e.id))})}function H5({request:e,onRespond:t}){let{t:n}=N(),[r,i]=(0,d.useState)(e.method===`editor`?e.prefill??``:``),[a,o]=(0,d.useState)(()=>Date.now());(0,d.useEffect)(()=>{i(e.method===`editor`?e.prefill??``:``),o(Date.now())},[e]),(0,d.useEffect)(()=>{if(!e.expiresAt)return;let t=setInterval(()=>{document.hidden||o(Date.now())},1e3),n=()=>{document.hidden||o(Date.now())};return document.addEventListener(`visibilitychange`,n),()=>{clearInterval(t),document.removeEventListener(`visibilitychange`,n)}},[e.expiresAt]);let s=e.expiresAt?Math.max(0,Math.ceil((e.expiresAt-a)/1e3)):null;(0,d.useEffect)(()=>{s===0&&t(e,{cancelled:!0})},[s===0,e.id]);let c=()=>{e.method===`confirm`?t(e,{confirmed:!0}):t(e,{value:r})},l=e.method===`select`?n(`chat.extensionSelect`):e.method===`confirm`?n(`chat.extensionConfirm`):e.method===`editor`?n(`chat.extensionEditor`):n(`chat.extensionInput`);return(0,E.jsxs)(GX,{testId:`extension-dialog`,title:(0,E.jsxs)(E.Fragment,{children:[l,s!==null&&(0,E.jsxs)(`span`,{style:{color:`var(--text-muted)`,marginLeft:6,fontVariantNumeric:`tabular-nums`},children:[`(`,s,`s)`]})]}),subtitle:n(`chat.extensionRequest`),maxWidth:Math.round(window.innerWidth*.6),footer:(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`button`,{onClick:()=>t(e,{cancelled:!0}),style:{padding:`6px 10px`,borderRadius:6,border:`1px solid var(--border)`,background:`var(--bg)`,color:`var(--text-muted)`,cursor:`pointer`},children:n(`chat.cancel`)}),e.method===`confirm`?(0,E.jsx)(`button`,{onClick:c,style:{padding:`6px 10px`,borderRadius:6,border:`1px solid var(--accent)`,background:`var(--accent)`,color:`var(--on-accent)`,cursor:`pointer`},children:n(`chat.confirm`)}):e.method===`select`?null:(0,E.jsx)(`button`,{onClick:c,style:{padding:`6px 10px`,borderRadius:6,border:`1px solid var(--accent)`,background:`var(--accent)`,color:`var(--on-accent)`,cursor:`pointer`},children:n(`chat.submit`)})]}),children:[(0,E.jsx)(`div`,{style:{marginBottom:12,padding:`9px 10px`,borderRadius:7,border:`1px solid var(--border)`,background:`var(--bg)`,color:`var(--text)`,fontSize:`var(--text-lg)`,lineHeight:1.6,whiteSpace:`pre-wrap`,maxHeight:360,overflowY:`auto`},children:e.title}),`Notification`in window&&Notification.permission===`denied`&&(0,E.jsx)(`div`,{style:{marginBottom:10,padding:`7px 10px`,borderRadius:7,border:`1px solid var(--border-warning, var(--border))`,background:`var(--bg-panel)`,color:`var(--text-dim)`,fontSize:`var(--text-sm)`,lineHeight:1.5},children:n(`chat.questionNotificationDenied`)}),e.method===`confirm`&&(0,E.jsx)(`div`,{style:{color:`var(--text-muted)`,fontSize:`var(--text-lg)`,lineHeight:1.6,whiteSpace:`pre-wrap`},children:e.message}),e.method===`select`&&(0,E.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:e.options.map(n=>(0,E.jsx)(`button`,{onClick:()=>t(e,{value:n}),style:{flex:`1 1 auto`,padding:`9px 10px`,borderRadius:7,border:`1px solid var(--border)`,background:`var(--bg-panel)`,color:`var(--text)`,cursor:`pointer`,textAlign:`left`,fontSize:`var(--text-lg)`},children:n},n))}),e.method===`input`&&(0,E.jsx)(`input`,{autoFocus:!0,value:r,placeholder:e.placeholder,onChange:e=>i(e.target.value),onKeyDown:n=>{n.key===`Enter`&&c(),n.key===`Escape`&&t(e,{cancelled:!0})},style:{width:`100%`,padding:`9px 10px`,borderRadius:7,border:`1px solid var(--border)`,background:`var(--bg-panel)`,color:`var(--text)`,outline:`none`,fontSize:`var(--text-2xl)`}}),e.method===`editor`&&(0,E.jsx)(`textarea`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),onKeyDown:n=>{n.key===`Escape`&&t(e,{cancelled:!0}),(n.metaKey||n.ctrlKey)&&n.key===`Enter`&&c()},style:{width:`100%`,minHeight:220,padding:10,borderRadius:7,border:`1px solid var(--border)`,background:`var(--bg)`,color:`var(--text)`,outline:`none`,resize:`vertical`,fontSize:`var(--text-2xl)`,lineHeight:1.55,fontFamily:`var(--font-mono)`}})]},e.id)}function U5(e,t){return hY(e).map((e,n)=>Object.keys(e.style).length>0?(0,E.jsx)(`span`,{style:e.style,children:e.text},`${t}-${n}`):e.text)}function W5({request:e,onInput:t}){let{t:n}=N(),r=(0,d.useRef)(null),i=(0,d.useRef)(!1),a=fY(e.lines);return(0,d.useEffect)(()=>{r.current?.focus()},[e.id]),(0,E.jsx)(`div`,{style:{position:`absolute`,inset:0,zIndex:95,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:20,background:`rgba(0,0,0,0.18)`},children:(0,E.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,onClick:e=>{e.target.closest(`button`)||r.current?.focus()},style:{position:`relative`,width:`min(920px, 100%)`,maxHeight:`min(760px, calc(100vh - 40px))`,border:`1px solid var(--border)`,borderRadius:8,background:`var(--bg)`,boxShadow:`0 20px 60px var(--shadow-strong)`,overflow:`hidden`,outline:`none`},children:[(0,E.jsx)(`textarea`,{ref:r,"aria-label":n(`chat.extensionInput`),autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,onKeyDown:n=>{if(i.current||n.nativeEvent.isComposing)return;let r=SY(n);r&&(n.preventDefault(),n.stopPropagation(),t(e,r))},onInput:n=>{if(i.current||n.nativeEvent.isComposing)return;let r=n.currentTarget.value;n.currentTarget.value=``,r&&t(e,r)},onCompositionStart:()=>{i.current=!0},onCompositionEnd:n=>{i.current=!1;let r=n.currentTarget;queueMicrotask(()=>{let n=r.value;r.value=``,n&&t(e,n)})},onPaste:n=>{n.preventDefault();let r=n.clipboardData.getData(`text`);r&&t(e,CY(r))},style:{position:`absolute`,width:1,height:1,padding:0,border:0,opacity:0,pointerEvents:`none`}}),(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:12,padding:`10px 12px`,borderBottom:`1px solid var(--border)`},children:[(0,E.jsx)(`div`,{style:{color:`var(--text)`,fontSize:`var(--text-lg)`,fontWeight:650},children:n(`chat.extensionPanel`)}),(0,E.jsx)(`button`,{onClick:()=>t(e,``),style:{padding:`5px 9px`,borderRadius:6,border:`1px solid var(--border)`,background:`var(--bg-panel)`,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-base)`},children:n(`chat.close`)})]}),(0,E.jsx)(`pre`,{style:{margin:0,padding:14,maxHeight:`calc(min(760px, 100vh - 40px) - 48px)`,overflow:`auto`,background:`var(--bg-panel)`,color:`var(--text)`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-lg)`,lineHeight:1.45,whiteSpace:`pre`},children:(a.length?a:[``]).map((e,t,n)=>(0,E.jsxs)(d.Fragment,{children:[U5(e,`line-${t}`),t<n.length-1?`
|
|
480
|
-
`:null]},t))})]})})}function
|
|
478
|
+
`);if(e.role===`bashExecution`){let t=e;return`${t.command}\n${t.output??``}`}return``}var x5=100,S5=44;function C5({messages:e,t,onJump:n}){let[r,i]=(0,d.useState)(``),[a,o]=(0,d.useState)(0),s=(0,d.useRef)(null),c=(0,d.useRef)(null),l=(0,d.useMemo)(()=>e.map((e,t)=>({msgIdx:t,role:e.role,text:b5(e)})),[e]),u=(0,d.useMemo)(()=>{let e=r.trim().toLowerCase();if(!e)return[];let t=[];for(let{msgIdx:n,role:r,text:i}of l){let a=0,o=i.toLowerCase().indexOf(e,a);for(;o!==-1&&t.length<x5;)t.push({msgIdx:n,role:r,text:i,start:o}),a=o+1,o=i.toLowerCase().indexOf(e,a);if(t.length>=x5)break}return t},[l,r]);(0,d.useEffect)(()=>{o(e=>Math.min(e,Math.max(0,u.length-1)))},[u.length]);let f=(0,d.useCallback)(e=>{let t=u[e];t&&(n(t.msgIdx),o(e))},[u,n]),m=(0,d.useCallback)(e=>{if(u.length!==0){if(e.key===`Enter`){e.preventDefault();let t=e.shiftKey?-1:1,n=(a+t+u.length)%u.length;f(n)}else e.key===`ArrowDown`?(e.preventDefault(),f(Math.min(a+1,u.length-1))):e.key===`ArrowUp`&&(e.preventDefault(),f(Math.max(a-1,0)))}},[a,f,u.length]);return(0,d.useEffect)(()=>{(c.current?.children[a])?.scrollIntoView({block:`nearest`})},[a]),(0,E.jsxs)(`div`,{style:{position:`relative`,flex:`1 1 0`,minWidth:0,maxWidth:2040},"data-testid":`search-box`,children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:4,padding:`0 6px`,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:6,height:30,boxSizing:`border-box`},children:[(0,E.jsx)(Hr,{size:p.xl,color:`var(--text-muted)`,style:{flexShrink:0}}),(0,E.jsx)(`input`,{ref:s,value:r,onChange:e=>i(e.target.value),onKeyDown:m,placeholder:t(`chat.searchPlaceholder`),style:{flex:1,minWidth:0,background:`transparent`,border:`none`,outline:`none`,color:`var(--text)`,fontSize:`var(--text-sm)`}}),r&&(0,E.jsx)(`button`,{type:`button`,onClick:()=>{i(``),s.current?.focus()},"aria-label":t(`chat.clearSearch`),style:{border:`none`,background:`transparent`,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-sm)`,flexShrink:0,padding:0},children:`✕`})]}),r.trim()&&(0,E.jsx)(`div`,{ref:c,style:{position:`absolute`,top:`calc(100% + 6px)`,left:0,right:0,maxHeight:`min(55vh, 480px)`,overflowY:`auto`,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:8,boxShadow:`0 8px 24px var(--shadow-color)`,zIndex:60},children:u.length===0?(0,E.jsx)(`div`,{style:{padding:`10px 12px`,fontSize:`var(--text-base)`,color:`var(--text-muted)`},children:t(`chat.searchNoResults`)}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{style:{padding:`6px 12px`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`,borderBottom:`1px solid var(--border)`},children:t(`chat.searchResults`,{count:u.length})}),u.map((e,t)=>{let n=r.trim(),i=Math.max(0,e.start-S5),o=Math.min(e.text.length,e.start+n.length+S5),s=i>0?`…`:``,c=o<e.text.length?`…`:``,l=`${s}${e.text.slice(i,o)}${c}`;return(0,E.jsxs)(`button`,{type:`button`,onClick:()=>f(t),"data-testid":`search-result`,style:{display:`block`,width:`100%`,textAlign:`left`,padding:`8px 12px`,border:`none`,borderBottom:`1px solid var(--border)`,background:t===a?`var(--bg-selected)`:`transparent`,color:`var(--text)`,cursor:`pointer`,fontSize:`var(--text-base)`,lineHeight:1.5},children:[(0,E.jsxs)(`span`,{style:{color:`var(--text-dim)`,marginRight:6,fontSize:`var(--text-sm)`},children:[`#`,e.msgIdx]}),(0,E.jsx)(`span`,{children:w5(l,n)})]},`${e.msgIdx}-${e.start}`)})]})})]})}function w5(e,t){let n=[],r=e,i=0;for(;r.length>0;){let e=r.toLowerCase().indexOf(t.toLowerCase());if(e===-1){n.push(r);break}e>0&&n.push(r.slice(0,e)),n.push((0,E.jsx)(`mark`,{children:r.slice(e,e+t.length)},i++)),r=r.slice(e+t.length)}return n}function T5({modelName:e,messageCount:t,toolCallCount:n,t:r}){let i=[`${t} ${r(t===1?`chat.message`:`chat.messages`)}`];return n>0&&i.push(`${n} ${r(n===1?`chat.toolCall`:`chat.toolCalls`)}`),(0,E.jsxs)(`div`,{"data-testid":`pd-group-header`,style:{display:`flex`,alignItems:`center`,gap:8,width:`auto`,minHeight:24,padding:`3px 10px`,border:`1px solid var(--border)`,borderRadius:8,background:`var(--bg-panel)`,color:`var(--text-muted)`,fontSize:`var(--text-base)`,lineHeight:1.6},children:[e&&(0,E.jsx)(`span`,{style:{fontWeight:700,color:`var(--text)`,whiteSpace:`nowrap`},children:e}),(0,E.jsx)(`span`,{style:{minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:i.join(` · `)})]})}function E5(e){let{rows:t,messages:n,entryIds:r,modelNames:i,messageCwd:a,onOpenFile:o,sessionBusy:s,isNew:c,handleFork:l,forkingEntryId:u,handleNavigate:f,handleEditContent:p,sessionId:m,longBlockCollapseChars:h,recentExpandedBlockKeys:g,isStreaming:_,flashKey:v,itemRef:y,t:b,messageRefs:x,lastUserMsgRef:S,visibleRefIndexByMessage:C,scrollContainerRef:w,virtualizerRef:T,initialCache:D}=e,O=(0,d.useRef)(!1);(0,d.useLayoutEffect)(()=>{if(O.current)return;O.current=!0;let e=w.current;e&&e.scrollHeight>e.clientHeight&&(e.scrollTop=e.scrollHeight)},[w]);let k=new Map;for(let e of n)e.role===`toolResult`&&k.set(e.toolCallId,e);let A=new Map;{let e=0;for(let t=0;t<n.length;t++)n[t].role===`user`?(e+=1,A.set(t,e)):n[t].role===`assistant`&&e>0&&A.set(t,e)}let j=-1;for(let e=n.length-1;e>=0;e--)if(n[e].role===`user`){j=e;break}let M=(e,t)=>n=>{x.current[t]=n,e===j&&(S.current=n)},N=(e,t={})=>{let d=t.messageOverride??n[e],v=d.role===`user`&&e>0&&n[e-1].role===`assistant`?r[e-1]:void 0,y=d.role===`user`||d.role===`assistant`,b=C.get(e),x=!1;if(d.role===`assistant`){x=!0;for(let t=e+1;t<n.length;t++){let e=n[t].role;if(e===`user`)break;if(e===`assistant`){x=!1;break}}x&&_&&e===n.length-1&&(x=!1)}t.showTimestamp!==void 0&&(x=t.showTimestamp);let S;if(d.role===`assistant`){for(let t=e-1;t>=0;t--)if(n[t].role===`user`){S=n[t].timestamp;break}}let w=(0,E.jsx)(V8,{message:d,toolResults:k,modelNames:i,cwd:a,onOpenFile:o,entryId:r[e],onFork:s||c||e===0&&d.role===`user`?void 0:l,forking:u===r[e],onNavigate:s?void 0:f,prevAssistantEntryId:s?void 0:v,onEditContent:p,showTimestamp:x,turnStartTimestamp:S,sessionId:m,longBlockCollapseChars:h,recentExpandedBlockKeys:g,modelLabelVisible:t.modelLabelVisible,turnNumber:d.role===`user`||d.role===`assistant`&&t.isAnswer?A.get(e):void 0},`message-view-${e}`);return!y||t.attachRef===!1||b===void 0?w:(0,E.jsx)(`div`,{ref:M(e,b),children:w},`message-ref-${e}`)},P=e=>e.role!==`assistant`||!e.provider||!e.model?null:i?.[`${e.provider}/${e.model}`]??i?.[e.model]??e.model,ee=e=>{if(e.kind===`groupHeader`){let t=[];for(let r=e.groupUserIdx+1;r<=e.finalAssistantIdx;r++){let e=n[r];if(!e||e.role!==`assistant`)continue;let i=P(e);i&&!t.includes(i)&&t.push(i)}return(0,E.jsx)(T5,{modelName:t.join(` / `)||void 0,messageCount:e.messageCount,toolCallCount:e.toolCallCount,t:b})}return N(e.msgIdx,{attachRef:e.attachRef,messageOverride:e.messageOverride,showTimestamp:e.showTimestamp,modelLabelVisible:e.isProcess||e.isProcessFinal?!1:void 0,isAnswer:e.isAnswer})},F=e=>e.kind===`groupHeader`?8:e.isProcess||e.isProcessFinal?e.groupLast?14:8:0;return(0,E.jsx)(F8,{ref:T,data:t,cache:D,itemSize:200,bufferSize:400,scrollRef:w,children:e=>{let t=e.kind===`groupHeader`&&e.processRefIdx!==void 0?t=>{x.current[e.processRefIdx]=t}:void 0;return(0,E.jsx)(`div`,{className:v===e.key?`search-flash`:void 0,ref:y(e.key,t),style:{marginBottom:F(e)},children:ee(e)},e.key)}})}var D5={position:`relative`,display:`flex`,alignItems:`stretch`,flexShrink:0,width:`100%`,minWidth:0,height:36,gap:4,paddingLeft:4,paddingRight:4,borderBottom:`1px solid var(--border)`,background:`var(--bg)`},O5={display:`flex`,alignItems:`center`,justifyContent:`center`,alignSelf:`center`,width:32,height:32,padding:0,background:`transparent`,border:`1px solid var(--border)`,borderRadius:7,color:`var(--text-muted)`,flexShrink:0,cursor:`pointer`,transition:`color 0.12s, background 0.12s, border-color 0.12s`,"--hover-color":`var(--text)`,"--hover-bg":`var(--bg-selected)`,"--hover-border":`color-mix(in srgb, var(--accent) 35%, transparent)`},k5={display:`flex`,alignItems:`center`,gap:10,paddingLeft:12,paddingRight:12,height:`100%`,border:`none`,fontSize:`var(--text-sm)`,color:`var(--text-muted)`,whiteSpace:`nowrap`,cursor:`pointer`,fontVariantNumeric:`tabular-nums`,transition:`color 0.1s, background 0.1s`,"--hover-color":`var(--text)`},A5={flexShrink:0};function j5(e){return e>=1e6?`${(e/1e6).toPrecision(3)}M`:e>=1e3?`${(e/1e3).toPrecision(3)}K`:String(e)}function M5({sessionStats:e,contextUsage:t,activeTopPanel:n,toggleTopPanel:r,isMobile:i,t:a,locale:o}){let s=e?.tokens,c=e?.cost??0,l=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}k`:String(e),u=c>0?c>=.01?`$${c.toFixed(2)}`:`<$0.01`:null,d=`var(--text-muted)`,f=null;if(t?.contextWindow){let e=t.percent;e!==null&&e>90?d=`var(--status-error)`:e!==null&&e>70&&(d=`color-mix(in srgb, var(--status-warning) 95%, transparent)`),f=e===null?`? / ${l(t.contextWindow)}`:`${e.toFixed(0)}% / ${l(t.contextWindow)}`}let m=[];s&&(m.push(`in: ${s.input.toLocaleString(o)}`),m.push(`out: ${s.output.toLocaleString(o)}`),m.push(`cache read: ${s.cacheRead.toLocaleString(o)}`),m.push(`cache write: ${s.cacheWrite.toLocaleString(o)}`),c>0&&m.push(`cost: $${c.toFixed(4)}`));let h=s?s.input+s.cacheRead+s.cacheWrite:0,g=s&&h>0?s.cacheRead/h*100:null,_=(e,t)=>e===null?null:(0,E.jsx)(oi,{label:`${a(t)} · ${e.toFixed(1)}%`,children:(0,E.jsxs)(`span`,{style:{fontSize:`var(--text-xs)`,padding:`0 4px`,borderRadius:8,border:`1px solid color-mix(in srgb, var(--accent) 45%, transparent)`,background:`color-mix(in srgb, var(--accent) 10%, transparent)`,color:`var(--accent)`},children:[e.toFixed(1),`%`]})});if(t?.contextWindow){let e=t.percent;m.push(`context: ${e===null?`unknown`:`${e.toFixed(1)}%`} of ${t.contextWindow.toLocaleString()} tokens`)}let v=m.join(` | `);return(0,E.jsx)(oi,{label:v||a(`session.title`),wrapperStyle:{marginLeft:`auto`,flex:`0 0 auto`},children:(0,E.jsxs)(`button`,{type:`button`,onClick:()=>r(`session`),"aria-label":a(`session.title`),"aria-pressed":n===`session`,style:{...k5,background:n===`session`?`var(--bg-selected)`:`none`,borderTop:n===`session`?`2px solid var(--accent)`:`2px solid transparent`},className:`hover-shift`,children:[i&&(0,E.jsxs)(`svg`,{width:p.xl,height:p.xl,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,E.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12`,y2:`12`}),(0,E.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12.01`,y2:`8`})]}),!i&&s&&s.input>0&&(0,E.jsxs)(`span`,{style:N5,children:[(0,E.jsxs)(`svg`,{width:p.base,height:p.base,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:`var(--accent)`},children:[(0,E.jsx)(`line`,{x1:`5`,y1:`8.5`,x2:`5`,y2:`1.5`}),(0,E.jsx)(`polyline`,{points:`2 4 5 1.5 8 4`})]}),l(s.input)]}),!i&&s&&s.output>0&&(0,E.jsxs)(`span`,{style:N5,children:[(0,E.jsxs)(`svg`,{width:p.base,height:p.base,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:`var(--status-info)`},children:[(0,E.jsx)(`line`,{x1:`5`,y1:`1.5`,x2:`5`,y2:`8.5`}),(0,E.jsx)(`polyline`,{points:`2 6 5 8.5 8 6`})]}),l(s.output)]}),!i&&s&&s.cacheRead>0&&(0,E.jsxs)(`span`,{style:N5,children:[(0,E.jsxs)(`svg`,{width:p.base,height:p.base,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:`var(--status-success)`},children:[(0,E.jsx)(`path`,{d:`M8.5 5a3.5 3.5 0 1 1-1-2.45`}),(0,E.jsx)(`polyline`,{points:`6.5 1.5 8.5 2.5 7.5 4.5`})]}),l(s.cacheRead),_(g,`session.cacheReadRate`)]}),!i&&s&&s.cacheWrite>0&&(0,E.jsxs)(`span`,{style:N5,children:[(0,E.jsxs)(`svg`,{width:p.base,height:p.base,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:`var(--status-warning)`},children:[(0,E.jsx)(`path`,{d:`M8.5 5a3.5 3.5 0 1 0-1-2.45`}),(0,E.jsx)(`polyline`,{points:`2.5 1.5 4.5 2.5 3.5 4.5`})]}),l(s.cacheWrite)]}),!i&&u&&(0,E.jsx)(`span`,{style:P5,children:u}),f&&(0,E.jsxs)(`span`,{style:{...N5,color:d},children:[(0,E.jsxs)(`svg`,{width:p.base,height:p.base,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`path`,{d:`M1 9 L1 5 Q1 1 5 1 Q9 1 9 5 L9 9`}),(0,E.jsx)(`line`,{x1:`1`,y1:`9`,x2:`9`,y2:`9`})]}),f]})]})})}var N5={display:`flex`,alignItems:`center`,gap:4},P5={display:`flex`,alignItems:`center`,color:`var(--text)`,fontWeight:500},F5={position:`absolute`,top:`100%`,left:0,right:0,zIndex:1500,background:`var(--bg)`,borderBottom:`1px solid var(--border)`,boxShadow:`0 10px 28px var(--shadow-color)`,maxHeight:`calc(100dvh - 80px)`,overflowY:`auto`},I5={padding:`10px 16px`,fontSize:`var(--text-base)`,color:`var(--text-muted)`,fontStyle:`italic`},L5={fontSize:`var(--text-sm)`,fontWeight:700,color:`var(--text)`,marginBottom:6},R5={fontSize:`var(--text-xs)`,borderRadius:8,border:`1px solid color-mix(in srgb, var(--accent) 45%, transparent)`,background:`color-mix(in srgb, var(--accent) 10%, transparent)`,color:`var(--accent)`,whiteSpace:`nowrap`};function z5(e){let[t,n]=(0,d.useState)(null),r=(0,d.useRef)(null);return(0,d.useEffect)(()=>{if(!e){r.current=null,n(null);return}r.current===null&&(r.current=Date.now());let t=()=>{document.hidden||r.current!==null&&n(ht((Date.now()-r.current)/1e3))};t();let i=setInterval(t,1e3),a=()=>{document.hidden||t()};return document.addEventListener(`visibilitychange`,a),()=>{clearInterval(i),document.removeEventListener(`visibilitychange`,a)}},[e]),t}function B5(e){if(e.role!==`user`)return null;if(typeof e.content==`string`){let t=e.content.trim();return t.length>0?t:null}let t=e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
479
|
+
`).trim();return t.length>0?t:null}function V5({session:e,newSessionCwd:t,onAgentEnd:n,onSessionCreated:r,onSessionForked:i,modelsRefreshKey:a,chatInputRef:o,onOpenModelConfig:s,onSessionRenamed:c,windowTitleBase:l,onOpenFile:u,toolbarExtra:f,closedWidgetKeys:m,onCloseWidget:h,onExtensionWidgetsChange:g,onExtensionDialogChange:_}){let{t:v,locale:y}=N(),{scrollStepPx:b,autoReloadSeconds:x,longBlockCollapseChars:S,recentBlocksExpanded:C,widgetGeometries:w,setWidgetGeometry:T,widgetMessages:D,startScreenMessages:O}=ge(),{soundEnabled:k,onSoundToggle:A,playDoneSound:j,unlockAudio:M}=eY(),P=ne(),ee=oe(),F=(0,d.useRef)(j);F.current=j;let te=(0,d.useRef)(k);te.current=k;let re=(0,d.useRef)(null),ae=(0,d.useCallback)(()=>{te.current&&F.current(),n?.()},[n]),I=(0,d.useCallback)(e=>{o?.current?.insertIfEmpty(e)},[o]),L=(0,d.useCallback)(e=>{o?.current?.fillInput(e)},[o]),[se,R]=(0,d.useState)({kind:`idle`}),ce=pe(),le=(0,d.useRef)(null),[ue,de]=(0,d.useState)(null),fe=pe(),me=(0,d.useRef)(null),he=(0,d.useRef)(null),{activeTopPanel:_e,toggleTopPanel:ve,closeTopPanel:ye}=Me(),be=pe(),xe=(0,d.useCallback)(()=>{be.schedule(()=>{ye()},150)},[be,ye]),Se=be.cancel;(0,d.useEffect)(()=>{ce.cancel(),R({kind:`idle`}),de(null),le.current=e?.id??null},[e?.id,ce]);let Ce=(0,d.useCallback)(()=>{e&&window.open(`/api/sessions/${encodeURIComponent(e.id)}/export?inline=1`,`_blank`,`noopener,noreferrer`)},[e]),we=(0,d.useCallback)((e,t)=>{bY(t).then(()=>{fe.cancel(),de(e),fe.schedule(()=>de(null),1400)})},[fe]),{loading:Te,error:Ee,messages:De,entryIds:Oe,streamState:ke,agentRunning:Ae,bashRunning:je,bashOutput:Ne,pendingBash:Pe,modelNames:Fe,modelList:Ie,modelError:Le,modelScopeWarnings:Re,modelThinkingLevels:ze,modelThinkingLevelMaps:Be,toolPreset:Ve,thinkingLevel:He,retryInfo:Ue,contextUsage:We,forkingEntryId:Ge,isCompacting:Ke,compactError:qe,compactResult:Ye,displayModel:Xe,sessionStats:Ze,systemPrompt:Qe,slashCommands:$e,slashCommandsLoading:et,queuedMessages:tt,notices:nt,noticeModals:rt,dismissNoticeModal:it,extensionDialog:at,extensionCustomUi:ot,extensionStatuses:st,extensionWidgets:ct,respondToExtensionUi:lt,sendExtensionCustomInput:ut,isAutoModelSelection:dt,agentPhase:ft,commandBusy:pt,isNew:mt,tree:gt,sessionIdRef:_t,activeLeafId:vt,loadContext:yt,messagesEndRef:bt,scrollContainerRef:xt,lastUserMsgRef:St,handleSend:Ct,handleAbort:wt,handleFork:Tt,handleNavigate:Et,handleLeafChange:Dt,handleModelChange:Ot,handleCompact:kt,handleSteer:At,handleFollowUp:jt,handlePromptWithStreamingBehavior:Mt,handleAbortCompaction:Nt,handleRecallQueue:Pt,handleBuiltinSlashCommand:Ft,handleToolPresetChange:It,handleThinkingLevelChange:Lt,loadSlashCommands:Rt,setSessionStatsOverride:zt}=GJ({session:e,newSessionCwd:t,onAgentEnd:ae,onSessionCreated:r,onSessionForked:i,modelsRefreshKey:a,chatInputRef:o});(0,d.useEffect)(()=>{g?.(ct)},[ct,g]);let Bt=Ae||je,Vt=(0,d.useCallback)(e=>{Bt?e.startsWith(`/`)?Mt(e,`steer`):At(e):Ct(e)},[Bt,At,Mt,Ct]),Ht=(0,d.useCallback)(async()=>{let t=e?.id;if(!(!t||se.kind===`naming`)){ce.cancel(),ye(),R({kind:`naming`});try{let e=await fetch(`/api/sessions/${encodeURIComponent(t)}/auto-name`,{method:`POST`}),n=await e.json().catch(()=>({}));if(!e.ok||!n.title)throw Error(n.error||`HTTP ${e.status}`);let r=n.title.trim();if(le.current!==t)return;c?.(t,r),zt(e=>e?.sessionId===t?{...e,sessionName:r}:e),R({kind:`success`}),ce.schedule(()=>R({kind:`idle`}),1800)}catch(e){if(le.current!==t)return;let n=e instanceof Error?e.message:String(e);R({kind:`error`,message:n}),ce.schedule(()=>R({kind:`idle`}),5e3)}}},[se.kind,ce,e?.id,ye,c,zt]),Ut=(0,d.useCallback)(async e=>{let t=await Ft(e);return t.handled&&t.action===`openSessionStats`&&ve(`session`),t},[Ft,ve]),Wt=(0,d.useMemo)(()=>{let e=ke.streamingMessage;if(!e||e.role!==`assistant`)return;let t=0;for(let e of De)e.role===`user`&&(t+=1);return t>0?t:void 0},[De,ke.streamingMessage]),Gt=(0,d.useMemo)(()=>{if(C==null)return;let e=[];De.forEach((t,n)=>{t.role===`assistant`&&(t.content??[]).forEach((t,r)=>{t.type===`thinking`?e.push(Je(`thinking`,Oe[n]??``,void 0,r)):t.type===`toolCall`&&e.push(Je(`toolCall`,``,t.toolCallId))})});let t=e.slice(-((C??0)+1));return new Set(t)},[De,Oe,C]),{runningSessionIds:Jt,runningPhaseSince:Yt,runningBusySince:Xt}=Kt(),Zt=e?.id??_t.current??``,$t=Jt.has(Zt)||Ae||pt||je,en=z5($t),tn=qt($t,Yt[Zt]),nn=qt($t,Xt[Zt]),rn=cY(xZ(st)),an=(0,d.useCallback)(()=>{let e=_t.current;e&&yt(e,vt,!0)},[vt,yt,_t]);(0,d.useEffect)(()=>{if(!x||x<=0)return;let e=setInterval(()=>{let e=_t.current;e&&yt(e,vt,!0)},x*1e3);return()=>clearInterval(e)},[x,vt,yt,_t]),(0,d.useEffect)(()=>{!at||re.current===at.id||(re.current=at.id,Rq(`ui-chain`,`4b ExtensionDialog mounted, play sound`,`${at.method} id=${at.id.slice(0,8)} title=${JSON.stringify(at.title)}`),F.current())},[at]),(0,d.useEffect)(()=>{_?.(at!==null)},[at,_]),(0,d.useEffect)(()=>{Qt()},[]),(0,d.useEffect)(()=>{ie(Bt?wt:null)},[Bt,wt]);let on=(0,d.useRef)(``);(0,d.useEffect)(()=>{let e=()=>{if(document.hasFocus())return;let e=ke.isStreaming,t=l?` · ${l}`:``,n;if(at)n=`❓`;else if(Bt){let t=en??``;if(ft?.kind===`running_tools`)n=`🔧 ${t}`.trimEnd();else if(ft?.kind===`running_command`)n=`💻 ${t}`.trimEnd();else if(ft?.kind===`thinking`)n=`💡 ${t}`.trimEnd();else if(ft?.kind===`waiting_model`&&e){let e=[...De].reverse().find(e=>e.role===`assistant`),t=e&&e.role===`assistant`?e.usage:void 0;n=`⬇ ${j5(t?.input??0)}↑ ${j5(t?.output??0)}↓`}else n=`⏳ ${t}`.trimEnd()}else{let e;for(let t=De.length-1;t>=0;t--){let n=De[t];if(!(n.role!==`assistant`||!n.timestamp)){for(let r=t-1;r>=0;r--){let t=De[r];if(t.role===`user`&&t.timestamp){let r=Math.round((n.timestamp-t.timestamp)/1e3);r>0&&(e=r);break}}break}}if(e===void 0)return;n=`✅ ${ht(e)}`}let r=`${n}${t}`;r!==on.current&&(on.current=r,document.title=r)};e();let t=()=>{document.visibilityState===`hidden`&&e()};return document.addEventListener(`visibilitychange`,t),window.addEventListener(`blur`,e),()=>{document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`blur`,e)}},[ft,ke.isStreaming,en,De,Bt,l,at]);let sn=(0,d.useRef)(null);(0,d.useEffect)(()=>{Bt?sn.current===null&&(sn.current=Date.now()):sn.current=null},[Bt]),(0,d.useEffect)(()=>{if(!Bt&&!at)return;let e=()=>{if(!document.hidden||document.hasFocus())return;let e=l?` · ${l}`:``,t;if(at)t=`❓`;else if(Bt){let e=sn.current?ht((Date.now()-sn.current)/1e3):en??``;if(ft?.kind===`running_tools`)t=`🔧 ${e}`.trimEnd();else if(ft?.kind===`running_command`)t=`💻 ${e}`.trimEnd();else if(ft?.kind===`thinking`)t=`💡 ${e}`.trimEnd();else if(ft?.kind===`waiting_model`&&ke.isStreaming){let e=[...De].reverse().find(e=>e.role===`assistant`),n=e&&e.role===`assistant`?e.usage:void 0;t=`⬇ ${j5(n?.input??0)}↑ ${j5(n?.output??0)}↓`}else t=`⏳ ${e}`.trimEnd()}else return;let n=`${t}${e}`;n!==on.current&&(on.current=n,document.title=n)},t=setInterval(e,1e3);return document.addEventListener(`visibilitychange`,e),()=>{clearInterval(t),document.removeEventListener(`visibilitychange`,e)}},[Bt,at,ft,ke.isStreaming,De,l,en]);let[cn,ln]=(0,d.useState)(null),[un,dn]=(0,d.useState)(!0),fn=(0,d.useRef)(new Map),pn=(0,d.useRef)(new Map),mn=(0,d.useRef)(null),hn=(0,d.useRef)(!0),gn=(0,d.useRef)(0),_n=(0,d.useCallback)(()=>{let e=xt.current;e&&(e.scrollTop=e.scrollHeight),hn.current=!0,dn(!0)},[xt]),vn=(0,d.useCallback)(()=>{let e=xt.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight;if(hn.current&&t>0&&e.scrollHeight!==gn.current){gn.current=e.scrollHeight,e.scrollTop=e.scrollHeight;return}t<16?(hn.current=!0,dn(!0)):t>64&&(hn.current=!1,dn(!1)),gn.current=e.scrollHeight},[xt]),yn=(0,d.useRef)(new Map),bn=(0,d.useCallback)((e,t)=>{yn.current.set(e,t);let n=pn.current.get(e);return n||(n=t=>{if(yn.current.get(e)?.(t),!t){fn.current.get(e)?.disconnect(),fn.current.delete(e),yn.current.delete(e);return}let n=fn.current.get(e);n?n.disconnect():(n=new ResizeObserver(()=>{document.hidden||hn.current&&requestAnimationFrame(()=>{if(document.hidden)return;let e=xt.current;e&&hn.current&&(e.scrollTop=e.scrollHeight)})}),fn.current.set(e,n)),n.observe(t)},pn.current.set(e,n)),n},[xt]);(0,d.useEffect)(()=>()=>{fn.current.forEach(e=>e.disconnect()),fn.current.clear(),pn.current.clear(),yn.current.clear()},[]);let xn=e?.id??t??``;(0,d.useEffect)(()=>{if(In(!1),Ln.current=null,fn.current.forEach(e=>e.disconnect()),fn.current.clear(),pn.current.clear(),yn.current.clear(),kn.current=[],St.current=null,xt.current){xt.current.scrollTop=0;let e=xt.current.firstElementChild;if(e&&e.children.length===1){let t=e.firstElementChild;t&&t.style.height&&(t.style.height=`0px`)}}},[xn]),(0,d.useEffect)(()=>{let e=xt.current;if(!e)return;let t=new ResizeObserver(()=>{document.hidden||hn.current&&requestAnimationFrame(()=>{if(document.hidden)return;let e=xt.current;e&&hn.current&&(e.scrollTop=e.scrollHeight)})});return t.observe(e),()=>t.disconnect()},[xt]),(0,d.useEffect)(()=>()=>{},[]);let{isDragOver:Sn,handleDragEnter:Cn,handleDragOver:wn,handleDragLeave:Tn,handleDrop:En}=tY((0,d.useCallback)(e=>{Bt||o?.current?.addImages(e)},[Bt,o])),Dn=De.filter(e=>e.role===`user`||e.role===`assistant`),On=(0,d.useMemo)(()=>{let e=new Set,t=[];for(let n=De.length-1;n>=0;--n){let r=B5(De[n]);if(!(!r||e.has(r))&&(e.add(r),t.push(r),t.length>=50))break}return t.reverse()},[De]),kn=yZ(Dn.length),An=(0,d.useMemo)(()=>{for(let e=De.length-1;e>=0;e--)if(RY(De[e]))return e;return-1},[De]),jn=(0,d.useMemo)(()=>{let e=new Map,t=0;return De.forEach((n,r)=>{(n.role===`user`||n.role===`assistant`)&&e.set(r,t++)}),e},[De]),Mn=(0,d.useMemo)(()=>BY(De,{isLiveTail:(Bt||ke.isStreaming)&&An>=0,lastAnchorIdx:An,visibleRefIndexByMessage:jn}),[De,Bt,ke.isStreaming,An,jn]),Nn=(0,d.useMemo)(()=>VY(Mn),[Mn]),Pn=(0,d.useCallback)(e=>{let t=Nn.get(e);if(t===void 0)return null;let n=mn.current;return n?n.getItemOffset(t):null},[Nn]),[Fn,In]=(0,d.useState)(!1),Ln=(0,d.useRef)(null),Rn=Fn&&Ln.current?[Ln.current,200]:void 0;(0,d.useLayoutEffect)(()=>{Fn||Mn.length!==0&&xt.current&&(Ln.current=Mn.map(e=>e.estimate),In(!0))},[Fn,Mn,xt]);let[zn,Bn]=(0,d.useState)(null),Vn=(0,d.useRef)(null),Hn=(0,d.useCallback)(e=>{let t=Nn.get(e);if(t===void 0)return;let n=mn.current;if(!n)return;n.scrollToIndex(t,{align:`start`,offset:-24,smooth:!0});let r=Mn[t].key;Bn(r),Vn.current&&clearTimeout(Vn.current),Vn.current=setTimeout(()=>{Vn.current=null,Bn(e=>e===r?null:e)},1700)},[Mn,Nn]),Un=mt&&De.length===0&&!ke.isStreaming&&!Bt,Wn=!Ae&&!ke.isStreaming&&!pt&&!je;(0,d.useLayoutEffect)(()=>{if(!O.length||!Wn||!hn.current)return;let e=xt.current;e&&(e.scrollTop=e.scrollHeight)},[O.length,Wn,xt]);let Gn=e?.cwd??t??void 0,Kn=Xe?ze[`${Xe.provider}/${Xe.modelId}`]??null:null,qn=Xe?Be[`${Xe.provider}/${Xe.modelId}`]??null:null,Jn=(0,E.jsx)(mX,{ref:o,onSend:Ct,onAbort:wt,onSteer:Ae?At:void 0,onFollowUp:Ae?jt:void 0,onPromptWithStreamingBehavior:Ae?Mt:void 0,isStreaming:Bt,commandBusy:pt,model:Xe,isAutoModelSelection:dt,modelNames:Fe,modelList:Ie,modelError:Le,modelScopeWarnings:Re,onModelChange:Ot,onCompact:e||mt?kt:void 0,onReloadFromDisk:an,onAbortCompaction:Nt,isCompacting:Ke,compactError:qe,compactResult:Ye,toolPreset:Ve,onToolPresetChange:e||mt?It:void 0,thinkingLevel:He,onThinkingLevelChange:e||mt?Lt:void 0,availableThinkingLevels:Kn,thinkingLevelMap:qn,onOpenModelConfig:s,retryInfo:Ue,queuedMessages:tt,inputHistory:On,onRecallQueue:Pt,slashCommands:$e,slashCommandsLoading:et,onLoadSlashCommands:Rt,onBuiltinCommand:Ut,soundEnabled:k,onSoundToggle:A,onAudioUnlock:M,draftKey:e?.id??(t?`new:${t}`:void 0),cwd:e?.cwd??t});return Te?(0,E.jsx)(`div`,{className:`flex h-full items-center justify-center text-text-muted`,children:v(`chat.loadingSession`)}):Ee?(0,E.jsx)(`div`,{className:`flex h-full items-center justify-center text-red-400`,children:Ee}):(0,E.jsxs)(`div`,{ref:ln,className:`relative flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,style:{paddingBottom:`env(safe-area-inset-bottom)`},onDragEnter:Cn,onDragOver:wn,onDragLeave:Tn,onDrop:En,children:[Sn&&!Bt&&(0,E.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 z-50 flex animate-[drop-zone-in_0.15s_ease_both] items-center justify-center bg-[color-mix(in_srgb,var(--accent)_6%,transparent)] backdrop-blur-[1px]`,children:[(0,E.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:[0,.8,1.6].map(e=>(0,E.jsx)(`div`,{className:`absolute h-[720px] w-[720px] rounded-full border-[1.5px] border-solid border-[color-mix(in_srgb,var(--accent)_50%,transparent)] animate-[drop-ripple_2.4s_ease-out_infinite_backwards]`,style:{transformOrigin:`center`,animationDelay:`${e}s`}},e))}),(0,E.jsxs)(`svg`,{width:`280`,height:`280`,viewBox:`0 0 140 140`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:`drop-shadow-[0_6px_18px_var(--accent-glow)]`,children:[(0,E.jsx)(`rect`,{x:`28`,y:`44`,width:`84`,height:`60`,rx:`8`,fill:`color-mix(in srgb, var(--accent) 8%, transparent)`,stroke:`color-mix(in srgb, var(--accent) 50%, transparent)`,strokeWidth:`1.8`}),(0,E.jsx)(`path`,{d:`M36 100 L54 72 L68 88 L80 74 L104 100Z`,fill:`color-mix(in srgb, var(--accent) 16%, transparent)`,stroke:`color-mix(in srgb, var(--accent) 40%, transparent)`,strokeWidth:`1.4`,strokeLinejoin:`round`}),(0,E.jsx)(`circle`,{cx:`96`,cy:`58`,r:`8`,fill:`color-mix(in srgb, var(--accent) 22%, transparent)`,stroke:`color-mix(in srgb, var(--accent) 55%, transparent)`,strokeWidth:`1.6`}),(0,E.jsxs)(`g`,{stroke:`color-mix(in srgb, var(--accent) 45%, transparent)`,strokeWidth:`1.4`,strokeLinecap:`round`,children:[(0,E.jsx)(`line`,{x1:`96`,y1:`46`,x2:`96`,y2:`43`}),(0,E.jsx)(`line`,{x1:`96`,y1:`70`,x2:`96`,y2:`73`}),(0,E.jsx)(`line`,{x1:`84`,y1:`58`,x2:`81`,y2:`58`}),(0,E.jsx)(`line`,{x1:`108`,y1:`58`,x2:`111`,y2:`58`}),(0,E.jsx)(`line`,{x1:`87.5`,y1:`49.5`,x2:`85.4`,y2:`47.4`}),(0,E.jsx)(`line`,{x1:`104.5`,y1:`66.5`,x2:`106.6`,y2:`68.6`}),(0,E.jsx)(`line`,{x1:`104.5`,y1:`49.5`,x2:`106.6`,y2:`47.4`}),(0,E.jsx)(`line`,{x1:`87.5`,y1:`66.5`,x2:`85.4`,y2:`68.6`})]})]})]}),at&&(0,E.jsx)(W5,{request:at,onRespond:lt}),rt.length>0&&(0,E.jsx)(U5,{modals:rt,onDismiss:it}),ot&&(0,E.jsx)(K5,{request:ot,onInput:ut}),ct.filter(e=>!m.has(e.key)).map((e,t)=>(0,E.jsx)(q5,{widget:e,saved:w[e.key],messages:D[e.key]??[],defaultOffset:t%3==0?{dx:0,dy:0}:t%3==1?{dx:-80,dy:0}:{dx:80,dy:0},onCloseWidget:h,setWidgetGeometry:T,onSend:Vt,fillChatInput:L,portalTarget:cn},e.key)),(0,E.jsxs)(`div`,{ref:me,"data-testid":`chat-toolbar`,style:D5,children:[(0,E.jsx)(oi,{label:v(e?`history.full`:`history.unsaved`),children:(0,E.jsx)(`button`,{onClick:Ce,disabled:!e,"aria-label":v(`history.full`),style:{...O5,color:e?`var(--text-muted)`:`var(--text-dim)`,cursor:e?`pointer`:`not-allowed`,opacity:e?1:.45},className:e?`hover-shift`:void 0,children:(0,E.jsx)(zr,{size:p.base,style:A5})})}),(()=>{let t=!!(e&&(Ze?.userMessages??e.messageCount)>0),n=!e||!t||se.kind===`naming`,r=se.kind===`success`,i=se.kind===`error`,a=se.kind===`naming`?v(`title.generating`):v(r?`title.updated`:i?`title.failed`:`title.generate`),o=e?t?i?se.message:v(`title.generateSession`):v(`title.noMessages`):v(`title.unsaved`);return(0,E.jsx)(oi,{label:o,children:(0,E.jsx)(`button`,{type:`button`,onClick:()=>void Ht(),disabled:n,"aria-label":a,style:{...O5,color:i?`var(--status-error)`:r?`var(--status-success)`:n?`var(--text-dim)`:`var(--text-muted)`,cursor:n?`not-allowed`:`pointer`,opacity:n&&se.kind!==`naming`?.45:1,"--hover-color":i?`var(--status-error)`:`var(--text)`},className:n?void 0:`hover-shift`,children:se.kind===`naming`?(0,E.jsx)(Ar,{className:`animate-spin`,size:p.lg,"aria-hidden":`true`}):r?(0,E.jsx)(ur,{size:p.lg,"aria-hidden":`true`}):(0,E.jsx)(Nr,{size:p.lg,"aria-hidden":`true`,style:A5})})})})(),(0,E.jsx)(oi,{label:v(`i18n.branches`),children:(0,E.jsx)($X,{tree:gt,activeLeafId:vt,onLeafChange:Dt,inline:!0,compact:!0,containerRef:me,open:_e===`branches`,onToggle:()=>ve(`branches`),hasSession:!0})}),(0,E.jsx)(oi,{label:v(`system.prompt`),children:(0,E.jsx)(`button`,{ref:he,onClick:()=>ve(`system`),"aria-label":v(`system.prompt`),"aria-pressed":_e===`system`,style:{...O5,background:_e===`system`?`var(--bg-selected)`:`transparent`,borderColor:_e===`system`?`var(--accent)`:`var(--border)`,cursor:`pointer`,color:_e===`system`?`var(--text)`:`var(--text-muted)`,"--hover-color":`var(--text)`},className:`hover-shift`,children:(0,E.jsx)(yr,{size:p.base,style:A5})})}),(0,E.jsx)(oi,{label:v(`session.reload`),children:(0,E.jsx)(`button`,{type:`button`,"data-testid":`chat-toolbar-reload`,onClick:()=>void Ft(`/reload`),"aria-label":v(`session.reload`),style:{...O5,background:`transparent`,borderColor:`var(--border)`,cursor:`pointer`,color:`var(--text-muted)`,"--hover-color":`var(--text)`},className:`hover-shift`,children:(0,E.jsx)(Rr,{size:p.base,style:A5})})}),(0,E.jsx)(`div`,{style:{marginLeft:8,display:`flex`,alignItems:`center`,flex:1,minWidth:0},children:(0,E.jsx)(C5,{messages:De,t:v,onJump:Hn})}),Ze||We?(0,E.jsx)(M5,{sessionStats:Ze,contextUsage:We,activeTopPanel:_e,toggleTopPanel:ve,isMobile:P,t:v,locale:y}):null,f,_e===`system`&&(0,E.jsx)(`div`,{onMouseEnter:Se,onMouseLeave:xe,style:F5,children:Qe?(0,E.jsx)(`div`,{style:{padding:`12px 16px`,color:`var(--text-muted)`,fontSize:`var(--text-base)`,lineHeight:1.6,whiteSpace:`pre-wrap`,fontFamily:`var(--font-mono)`},children:Qe}):Qe===``?(0,E.jsx)(`div`,{style:I5,children:v(`system.empty`)}):(0,E.jsx)(`div`,{style:I5,children:v(`system.load`)})}),_e===`session`&&(0,E.jsx)(`div`,{onMouseEnter:Se,onMouseLeave:xe,style:{...F5,padding:`12px 16px`},children:Ze?(()=>{let e=[...Ze.sessionName?[{label:v(`session.name`),value:Ze.sessionName,copyField:null}]:[],{label:v(`session.file`),value:Ze.sessionFile??v(`session.inMemory`),copyField:`file`},{label:v(`session.id`),value:Ze.sessionId,copyField:`id`}],t=[[v(`session.user`),Ze.userMessages.toLocaleString(y)],[v(`session.assistant`),Ze.assistantMessages.toLocaleString(y)],[v(`session.toolCalls`),Ze.toolCalls.toLocaleString(y)],[v(`session.toolResults`),Ze.toolResults.toLocaleString(y)],[v(`session.total`),Ze.totalMessages.toLocaleString(y)]],n=Ze.tokens.input+Ze.tokens.cacheRead+Ze.tokens.cacheWrite,r=[[v(`session.input`),Ze.tokens.input.toLocaleString(y),{title:v(`session.inputHint`)}],[v(`session.output`),Ze.tokens.output.toLocaleString(y),{title:v(`session.outputHint`)}],...Ze.tokens.cacheRead>0?[[v(`session.cacheRead`),Ze.tokens.cacheRead.toLocaleString(y),{title:v(`session.cacheReadHint`),badge:n>0?(e=>`${e.toFixed(1)}%`)(Ze.tokens.cacheRead/n*100):void 0,badgeTitle:v(`session.cacheReadRate`)}]]:[],...Ze.tokens.cacheWrite>0?[[v(`session.cacheWrite`),Ze.tokens.cacheWrite.toLocaleString(y),{title:v(`session.cacheWriteHint`)}]]:[],[v(`session.total`),Ze.tokens.total.toLocaleString(y),{title:v(`session.totalHint`)}]],i=We??Ze.contextUsage,a=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}k`:String(e),o=[...Ze.cost>0?[[v(`session.cost`),`$${Ze.cost.toFixed(4)}`]]:[],...i?.contextWindow?[[v(`session.context`),`${i.percent===null?`?`:`${i.percent.toFixed(1)}%`} / ${a(i.contextWindow)}`]]:[]],s=(e,t,n=`left`,r=!1)=>(0,E.jsxs)(`div`,{style:{minWidth:0},children:[(0,E.jsx)(`div`,{style:L5,children:e}),(0,E.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:r?`max-content max-content max-content`:`auto minmax(0, 1fr) max-content`,columnGap:r?14:12,rowGap:4,justifyContent:r?`start`:void 0},children:t.map(([t,i,a])=>(0,E.jsxs)(`div`,{style:{display:`contents`},children:[(0,E.jsx)(oi,{label:a?.title,wrapperStyle:{display:`flex`,color:`var(--text-dim)`,whiteSpace:`nowrap`},children:(0,E.jsx)(`div`,{style:{color:`var(--text-dim)`,whiteSpace:`nowrap`},children:t})}),(0,E.jsx)(`div`,{style:{color:`var(--text-muted)`,minWidth:0,overflowWrap:r?`normal`:`anywhere`,textAlign:n,whiteSpace:n===`right`?`nowrap`:`normal`},children:i}),(0,E.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`flex-end`,minWidth:0},children:a?.badge&&(0,E.jsx)(oi,{label:`${a.badgeTitle??``}${a.badgeTitle?` · `:``}${a.badge}`,children:(0,E.jsx)(`span`,{style:{padding:`0 5px`,...R5},children:a.badge})})})]},`${e}:${t}`))})]}),c=(e,t)=>{let n=ue===e;return(0,E.jsx)(oi,{label:v(n?`session.copied`:e===`file`?`session.copyFile`:`session.copyId`),children:(0,E.jsx)(`button`,{type:`button`,onClick:()=>we(e,t),style:{alignSelf:`start`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:22,height:22,marginTop:-2,color:n?`var(--accent)`:`var(--text-dim)`,background:`transparent`,border:`1px solid var(--border)`,borderRadius:4,cursor:`pointer`,flex:`0 0 auto`,transition:`color 0.12s, border-color 0.12s, background 0.12s`,"--hover-color":`var(--accent)`,"--hover-border":`var(--accent)`,"--hover-bg":`var(--bg-hover)`},className:`hover-shift`,children:n?(0,E.jsx)(`svg`,{width:p.base,height:p.base,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}):(0,E.jsxs)(`svg`,{width:p.base,height:p.base,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`rect`,{x:`9`,y:`9`,width:p.lg,height:p.lg,rx:`2`,ry:`2`}),(0,E.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})})})},l=(0,E.jsxs)(`div`,{style:{minWidth:0},children:[(0,E.jsx)(`div`,{style:L5,children:v(`session.infoSection`)}),(0,E.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`auto minmax(0, 1fr) auto`,columnGap:12,rowGap:8,alignItems:`start`},children:e.map(e=>(0,E.jsxs)(`div`,{style:{display:`contents`},children:[(0,E.jsx)(`div`,{style:{color:`var(--text-dim)`,whiteSpace:`nowrap`},children:e.label}),(0,E.jsx)(`div`,{style:{color:`var(--text-muted)`,minWidth:0,overflowWrap:`anywhere`,wordBreak:`break-word`,whiteSpace:`normal`},children:e.value}),(0,E.jsx)(`div`,{children:e.copyField?c(e.copyField,e.value):null})]},`session-info:${e.label}`))})]});return(0,E.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:P?`1fr`:`minmax(360px, 1.7fr) minmax(140px, 0.55fr) minmax(190px, 0.75fr)`,gap:P?16:24,fontSize:`var(--text-base)`,lineHeight:1.5,fontFamily:`var(--font-mono)`},children:[l,s(v(`session.messages`),t),s(v(`session.tokens`),[...r,...o],`right`,!0)]})})():(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--text-muted)`,fontStyle:`italic`},children:v(`session.load`)})})]}),Un?(0,E.jsx)(`div`,{className:`relative flex flex-1 flex-col items-center justify-center overflow-y-auto px-4 py-8`,children:(0,E.jsxs)(`div`,{className:`w-full max-w-[820px]`,children:[(0,E.jsxs)(`div`,{className:`mb-3`,style:{textAlign:`center`,padding:`40px 0`},children:[ee==="default"?(0,E.jsxs)(`div`,{style:{marginBottom:20,fontSize:`var(--text-sm)`,color:`var(--text-muted)`,lineHeight:1.6},children:[v(`notify.permission.bannerHintBefore`),` `,(0,E.jsxs)(`svg`,{width:16,height:16,viewBox:`0 0 24 24`,fill:`none`,stroke:`var(--accent)`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{display:`inline-block`,verticalAlign:-2},children:[(0,E.jsx)(`path`,{d:`M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9`}),(0,E.jsx)(`path`,{d:`M10.3 21a1.94 1.94 0 0 0 3.4 0`})]}),` `,v(`notify.permission.bannerHintAfter`)]}):null,(0,E.jsx)(`div`,{style:{fontSize:`var(--text-6xl)`,fontWeight:700,fontStyle:`italic`,color:`var(--accent)`},children:`Pi Web`}),t?(0,E.jsx)(`div`,{style:{marginTop:6,fontSize:`var(--text-3xl)`,color:`var(--text-muted)`,fontFamily:`var(--font-mono)`},children:t}):null]}),O.length>0&&(0,E.jsx)(`div`,{style:{marginBottom:28},children:(0,E.jsx)(QJ,{messages:O,onSend:Vt,onFillInput:L,testIdPrefix:`start-screen-msg`,wrapperTestId:`start-screen-messages`,center:!0})}),(0,E.jsx)(`div`,{style:{position:`absolute`,top:12,left:0,right:0,zIndex:40,padding:`0 16px`,pointerEvents:`none`},children:(0,E.jsx)(`div`,{style:{maxWidth:820,margin:`0 auto`},children:(0,E.jsx)(H5,{notices:nt,floating:!0,align:`right`})})}),Jn]})}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,E.jsx)(`div`,{style:{position:`absolute`,top:12,left:0,right:P?0:`calc(${vY} + 48px)`,zIndex:40,padding:`0 16px`,pointerEvents:`none`},children:(0,E.jsx)(`div`,{style:{maxWidth:820,margin:`0 auto`},children:(0,E.jsx)(H5,{notices:nt,floating:!0,align:`right`})})}),(0,E.jsx)(`div`,{ref:xt,onScroll:vn,className:`min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto pt-4 [scrollbar-width:none] [overflow-anchor:none]`,style:{paddingRight:48},"data-testid":`message-list`,children:(0,E.jsx)(`div`,{style:{minWidth:0,padding:`0 16px`},children:(0,E.jsxs)(`div`,{style:{width:`100%`,minWidth:0,maxWidth:820,margin:`0 auto`},children:[Fn&&(0,E.jsx)(E5,{rows:Mn,messages:De,entryIds:Oe,modelNames:Fe,messageCwd:Gn,onOpenFile:u,sessionBusy:Bt,isNew:mt,handleFork:Tt,forkingEntryId:Ge,handleNavigate:Et,handleEditContent:I,sessionId:e?.id??_t.current??void 0,longBlockCollapseChars:S,recentExpandedBlockKeys:Gt,isStreaming:ke.isStreaming,flashKey:zn,itemRef:bn,t:v,messageRefs:kn,lastUserMsgRef:St,visibleRefIndexByMessage:jn,scrollContainerRef:xt,virtualizerRef:mn,initialCache:Rn},xn||`empty`),ke.isStreaming&&ke.streamingMessage&&(0,E.jsx)(`div`,{children:(0,E.jsx)(V8,{message:ke.streamingMessage,isStreaming:!0,modelNames:Fe,cwd:Gn,onOpenFile:u,longBlockCollapseChars:S,recentExpandedBlockKeys:Gt,turnNumber:Wt})}),(Ae||pt)&&(ft?.kind===`waiting_model`||ft?.kind===`thinking`||!ke.streamingMessage)&&(ft||pt)&&(0,E.jsx)(`div`,{className:`py-2 text-[0.8125rem] text-text-muted`,children:(0,E.jsx)(XJ,{phase:ft??{kind:`running_command`},elapsed:tn,totalElapsed:nn})}),je&&(0,E.jsx)(`div`,{className:`py-2 text-[0.8125rem] text-text-muted`,children:(0,E.jsx)(XJ,{phase:{kind:`running_command`},elapsed:tn,totalElapsed:nn})}),Pe&&(0,E.jsx)(V8,{message:{role:`bashExecution`,command:Pe.command,output:``,excludeFromContext:Pe.excludeFromContext},streamingBashOutput:Ne,sessionId:e?.id??_t.current??void 0,longBlockCollapseChars:S}),Ae&&(0,E.jsx)(`div`,{style:{height:48}}),(0,E.jsx)(`div`,{ref:bt})]})})}),!un&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`span`,{style:{position:`absolute`,left:0,right:0,bottom:0,height:30,background:`linear-gradient(to bottom, transparent, var(--bg))`,pointerEvents:`none`,zIndex:49}}),(0,E.jsx)(`button`,{type:`button`,onClick:_n,"aria-label":v(`chat.scrollToLatest`),"data-testid":`scroll-to-latest`,style:{position:`absolute`,bottom:0,left:`50%`,transform:`translateX(-50%)`,width:`min(100% / 3, 260px)`,zIndex:50,cursor:`pointer`,background:`transparent`,border:`none`,padding:0,height:30,display:`flex`,alignItems:`flex-end`,justifyContent:`center`},children:(0,E.jsx)(oi,{label:v(`chat.scrollToLatest`),children:(0,E.jsx)(`span`,{style:{position:`absolute`,bottom:4,left:`50%`,transform:`translateX(-50%)`,width:12,height:11,display:`flex`,alignItems:`flex-end`,justifyContent:`center`,cursor:`pointer`},children:(0,E.jsx)(`span`,{style:{position:`relative`,width:0,height:0,borderLeft:`6px solid transparent`,borderRight:`6px solid transparent`,borderTop:`7px solid var(--text-muted)`,pointerEvents:`none`}})})})})]}),P?null:(0,E.jsx)(vZ,{messages:De,streamingMessage:ke.streamingMessage,scrollContainer:xt,messageRefs:kn,resolveMessageOffset:Pn,scrollStepPx:b,onWindowJumpTo:e=>{let t=xt.current;t&&(t.scrollTop=e)}})]}),(0,E.jsxs)(`div`,{className:`relative`,children:[(0,E.jsx)(`div`,{style:{padding:`0 16px`,paddingRight:P?16:64},children:(0,E.jsx)(`div`,{style:{maxWidth:820,margin:`0 auto`}})}),O.length>0&&Wn&&(0,E.jsx)(`div`,{style:{padding:`0 16px`,paddingRight:P?16:64},children:(0,E.jsx)(`div`,{style:{maxWidth:820,margin:`0 auto`,paddingBottom:8},children:(0,E.jsx)(QJ,{messages:O,onSend:Vt,onFillInput:L,testIdPrefix:`start-screen-msg`,wrapperTestId:`start-screen-messages`})})}),Jn]}),(0,E.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,flexShrink:0,minWidth:0,height:36,padding:`0 12px`,borderTop:`1px solid var(--border)`,gap:8},children:(0,E.jsx)(oi,{label:rn,wrapperStyle:{display:`flex`,flex:1,minWidth:0},children:(0,E.jsx)(`div`,{role:`status`,"aria-label":rn,style:{alignSelf:`stretch`,display:`flex`,alignItems:`center`,flex:1,minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-base)`,color:`var(--text-dim)`},children:rn})})})]})]})}function H5({notices:e,floating:t=!1,align:n=`left`}){return e.length===0?null:(0,E.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:n===`right`?`flex-end`:`stretch`,marginBottom:t?0:10},children:e.map((n,r)=>{let i=n.type===`error`?`var(--status-error)`:n.type===`warning`?`var(--status-warning)`:n.type===`success`?`var(--status-success)`:`var(--accent)`;return(0,E.jsxs)(`div`,{className:`notice-shelf-item`,style:{display:`flex`,alignItems:`center`,gap:10,minHeight:60,marginBottom:r===e.length-1?0:6,borderRadius:14,border:`1px solid color-mix(in srgb, var(--border) 70%, transparent)`,background:`var(--bg)`,color:`var(--text-muted)`,width:`fit-content`,maxWidth:`min(100%, 620px)`,boxShadow:t?`0 1px 2px var(--shadow-color), 0 10px 28px -14px var(--shadow-color)`:`0 1px 2px var(--shadow-color), 0 8px 24px -12px var(--shadow-color)`,fontSize:`var(--text-4xl)`,lineHeight:1.45,transformOrigin:`top center`,animation:n.exiting?`notice-shelf-out 0.18s ease-in forwards`:`notice-shelf-in 0.18s ease-out both`,padding:`0 12px`},children:[(0,E.jsx)(`span`,{style:{width:7,height:7,borderRadius:`50%`,background:i,flexShrink:0}}),(0,E.jsx)(`span`,{style:{padding:`14px 0`,minWidth:0,maxWidth:`100%`,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:n.message})]},n.id)})})}function U5({modals:e,onDismiss:t}){let{t:n}=N();return(0,E.jsx)(E.Fragment,{children:e.map((e,r)=>(0,E.jsx)(qX,{variant:e.type===`error`?`error`:`normal`,align:`center`,width:520,height:320,initialOffset:{dx:r%3*24,dy:r%3*24},title:e.type===`error`?n(`chat.notifyErrorTitle`):n(`chat.notifyWarningTitle`),footer:(0,E.jsx)(`button`,{onClick:()=>t(e.id),style:{padding:`6px 14px`,borderRadius:6,border:`1px solid var(--border)`,background:`var(--bg)`,color:`var(--text)`,cursor:`pointer`},children:n(`chat.close`)}),children:(0,E.jsx)(`div`,{style:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,fontSize:`var(--text-lg)`,lineHeight:1.6,color:`var(--text)`},children:e.message})},e.id))})}function W5({request:e,onRespond:t}){let{t:n}=N(),[r,i]=(0,d.useState)(e.method===`editor`?e.prefill??``:``),[a,o]=(0,d.useState)(()=>Date.now());(0,d.useEffect)(()=>{i(e.method===`editor`?e.prefill??``:``),o(Date.now())},[e]),(0,d.useEffect)(()=>{if(!e.expiresAt)return;let t=setInterval(()=>{document.hidden||o(Date.now())},1e3),n=()=>{document.hidden||o(Date.now())};return document.addEventListener(`visibilitychange`,n),()=>{clearInterval(t),document.removeEventListener(`visibilitychange`,n)}},[e.expiresAt]);let s=e.expiresAt?Math.max(0,Math.ceil((e.expiresAt-a)/1e3)):null;(0,d.useEffect)(()=>{s===0&&t(e,{cancelled:!0})},[s===0,e.id]);let c=()=>{e.method===`confirm`?t(e,{confirmed:!0}):t(e,{value:r})},l=e.method===`select`?n(`chat.extensionSelect`):e.method===`confirm`?n(`chat.extensionConfirm`):e.method===`editor`?n(`chat.extensionEditor`):n(`chat.extensionInput`);return(0,E.jsxs)(qX,{testId:`extension-dialog`,title:(0,E.jsxs)(E.Fragment,{children:[l,s!==null&&(0,E.jsxs)(`span`,{style:{color:`var(--text-muted)`,marginLeft:6,fontVariantNumeric:`tabular-nums`},children:[`(`,s,`s)`]})]}),subtitle:n(`chat.extensionRequest`),maxWidth:Math.round(window.innerWidth*.6),footer:(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`button`,{onClick:()=>t(e,{cancelled:!0}),style:{padding:`6px 10px`,borderRadius:6,border:`1px solid var(--border)`,background:`var(--bg)`,color:`var(--text-muted)`,cursor:`pointer`},children:n(`chat.cancel`)}),e.method===`confirm`?(0,E.jsx)(`button`,{onClick:c,style:{padding:`6px 10px`,borderRadius:6,border:`1px solid var(--accent)`,background:`var(--accent)`,color:`var(--on-accent)`,cursor:`pointer`},children:n(`chat.confirm`)}):e.method===`select`?null:(0,E.jsx)(`button`,{onClick:c,style:{padding:`6px 10px`,borderRadius:6,border:`1px solid var(--accent)`,background:`var(--accent)`,color:`var(--on-accent)`,cursor:`pointer`},children:n(`chat.submit`)})]}),children:[(0,E.jsx)(`div`,{style:{marginBottom:12,padding:`9px 10px`,borderRadius:7,border:`1px solid var(--border)`,background:`var(--bg)`,color:`var(--text)`,fontSize:`var(--text-lg)`,lineHeight:1.6,whiteSpace:`pre-wrap`,maxHeight:360,overflowY:`auto`},children:e.title}),`Notification`in window&&Notification.permission===`denied`&&(0,E.jsx)(`div`,{style:{marginBottom:10,padding:`7px 10px`,borderRadius:7,border:`1px solid var(--border-warning, var(--border))`,background:`var(--bg-panel)`,color:`var(--text-dim)`,fontSize:`var(--text-sm)`,lineHeight:1.5},children:n(`chat.questionNotificationDenied`)}),e.method===`confirm`&&(0,E.jsx)(`div`,{style:{color:`var(--text-muted)`,fontSize:`var(--text-lg)`,lineHeight:1.6,whiteSpace:`pre-wrap`},children:e.message}),e.method===`select`&&(0,E.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:e.options.map(n=>(0,E.jsx)(`button`,{onClick:()=>t(e,{value:n}),style:{flex:`1 1 auto`,padding:`9px 10px`,borderRadius:7,border:`1px solid var(--border)`,background:`var(--bg-panel)`,color:`var(--text)`,cursor:`pointer`,textAlign:`left`,fontSize:`var(--text-lg)`},children:n},n))}),e.method===`input`&&(0,E.jsx)(`input`,{autoFocus:!0,value:r,placeholder:e.placeholder,onChange:e=>i(e.target.value),onKeyDown:n=>{n.key===`Enter`&&c(),n.key===`Escape`&&t(e,{cancelled:!0})},style:{width:`100%`,padding:`9px 10px`,borderRadius:7,border:`1px solid var(--border)`,background:`var(--bg-panel)`,color:`var(--text)`,outline:`none`,fontSize:`var(--text-2xl)`}}),e.method===`editor`&&(0,E.jsx)(`textarea`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),onKeyDown:n=>{n.key===`Escape`&&t(e,{cancelled:!0}),(n.metaKey||n.ctrlKey)&&n.key===`Enter`&&c()},style:{width:`100%`,minHeight:220,padding:10,borderRadius:7,border:`1px solid var(--border)`,background:`var(--bg)`,color:`var(--text)`,outline:`none`,resize:`vertical`,fontSize:`var(--text-2xl)`,lineHeight:1.55,fontFamily:`var(--font-mono)`}})]},e.id)}function G5(e,t){return _Y(e).map((e,n)=>Object.keys(e.style).length>0?(0,E.jsx)(`span`,{style:e.style,children:e.text},`${t}-${n}`):e.text)}function K5({request:e,onInput:t}){let{t:n}=N(),r=(0,d.useRef)(null),i=(0,d.useRef)(!1),a=mY(e.lines);return(0,d.useEffect)(()=>{r.current?.focus()},[e.id]),(0,E.jsx)(`div`,{style:{position:`absolute`,inset:0,zIndex:95,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:20,background:`rgba(0,0,0,0.18)`},children:(0,E.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,onClick:e=>{e.target.closest(`button`)||r.current?.focus()},style:{position:`relative`,width:`min(920px, 100%)`,maxHeight:`min(760px, calc(100vh - 40px))`,border:`1px solid var(--border)`,borderRadius:8,background:`var(--bg)`,boxShadow:`0 20px 60px var(--shadow-strong)`,overflow:`hidden`,outline:`none`},children:[(0,E.jsx)(`textarea`,{ref:r,"aria-label":n(`chat.extensionInput`),autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,onKeyDown:n=>{if(i.current||n.nativeEvent.isComposing)return;let r=wY(n);r&&(n.preventDefault(),n.stopPropagation(),t(e,r))},onInput:n=>{if(i.current||n.nativeEvent.isComposing)return;let r=n.currentTarget.value;n.currentTarget.value=``,r&&t(e,r)},onCompositionStart:()=>{i.current=!0},onCompositionEnd:n=>{i.current=!1;let r=n.currentTarget;queueMicrotask(()=>{let n=r.value;r.value=``,n&&t(e,n)})},onPaste:n=>{n.preventDefault();let r=n.clipboardData.getData(`text`);r&&t(e,TY(r))},style:{position:`absolute`,width:1,height:1,padding:0,border:0,opacity:0,pointerEvents:`none`}}),(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:12,padding:`10px 12px`,borderBottom:`1px solid var(--border)`},children:[(0,E.jsx)(`div`,{style:{color:`var(--text)`,fontSize:`var(--text-lg)`,fontWeight:650},children:n(`chat.extensionPanel`)}),(0,E.jsx)(`button`,{onClick:()=>t(e,``),style:{padding:`5px 9px`,borderRadius:6,border:`1px solid var(--border)`,background:`var(--bg-panel)`,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-base)`},children:n(`chat.close`)})]}),(0,E.jsx)(`pre`,{style:{margin:0,padding:14,maxHeight:`calc(min(760px, 100vh - 40px) - 48px)`,overflow:`auto`,background:`var(--bg-panel)`,color:`var(--text)`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-lg)`,lineHeight:1.45,whiteSpace:`pre`},children:(a.length?a:[``]).map((e,t,n)=>(0,E.jsxs)(d.Fragment,{children:[G5(e,`line-${t}`),t<n.length-1?`
|
|
480
|
+
`:null]},t))})]})})}function q5({widget:e,saved:t,messages:n,defaultOffset:r,onCloseWidget:i,setWidgetGeometry:a,onSend:o,fillChatInput:s,portalTarget:c}){let{t:l}=N(),[u,f]=(0,d.useState)(!1),[m,h]=(0,d.useState)(null),g=(0,d.useRef)(null),_=(0,d.useCallback)(t=>{if(u)return;let n=()=>i(e.key,e.lines.join(`
|
|
481
481
|
`));if(window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches){n();return}let r=document.querySelector(`[data-tab-id="widgets"]`)??document.querySelector(`[data-testid="tab-bar"]`);if(!r){n();return}let a=t.currentTarget.getBoundingClientRect(),o=r.getBoundingClientRect(),s=`M ${a.left+a.width/2} ${a.top+a.height/2} L ${o.left+o.width/2} ${o.top+o.height/2}`;f(!0),h(s),window.setTimeout(n,280)},[u,i,e.key,e.lines]);return(0,d.useLayoutEffect)(()=>{if(!m||!g.current)return;let e=g.current;e.style.setProperty(`offset-path`,`path('${m}')`),e.style.setProperty(`offset-rotate`,`0deg`),e.animate([{offsetDistance:`0%`,r:28},{offsetDistance:`100%`,r:2}],{duration:240,easing:`cubic-bezier(0.22, 1, 0.36, 1)`,fill:`forwards`})},[m]),(0,d.useEffect)(()=>{t===void 0?a(e.key,{x:r.dx,y:r.dy,width:560,height:Math.round(window.innerHeight*.6)}):t.collapsed&&i(e.key,e.lines.join(`
|
|
482
|
-
`))},[e.key]),(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(
|
|
483
|
-
`)}),n.length>0&&(0,E.jsx)(`div`,{"data-testid":`widget-bound-messages`,style:{display:`flex`,flexWrap:`wrap`,gap:6,paddingTop:8,borderTop:`1px solid var(--border)`,flexShrink:0},children:n.map((t,n)=>(0,E.jsx)(YJ,{msg:t,onSend:o,onFillInput:s,testId:`widget-send-${e.key}-${n}`},n))})]})}),m&&(0,E.jsx)(`div`,{"data-testid":`widget-collapse-trail`,style:{position:`fixed`,inset:0,zIndex:70,pointerEvents:`none`},children:(0,E.jsx)(`svg`,{width:`100%`,height:`100%`,style:{position:`absolute`,inset:0},children:(0,E.jsx)(`circle`,{ref:g,r:28,fill:`var(--accent)`,fillOpacity:.7})})})]})}var K5={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,svg:`image/svg+xml`,bmp:`image/bmp`,ico:`image/x-icon`,avif:`image/avif`},q5={mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`,oga:`audio/ogg`,opus:`audio/ogg`,m4a:`audio/mp4`,aac:`audio/aac`,flac:`audio/flac`,weba:`audio/webm`,webm:`audio/webm`};function J5(e){return e.replace(/\\/g,`/`).split(`/`).pop()??``}function Y5(e){return J5(e).toLowerCase().split(`.`).pop()??``}function X5(e){return K5[Y5(e)]??null}function Z5(e){return q5[Y5(e)]??null}function Q5(e){let t=Y5(e);return t===`pdf`||t===`docx`?t:null}function $5(e){return X5(e)!==null}function e7(e){return Z5(e)!==null}function t7(e){return Q5(e)!==null}async function n7(e,t){let n=e.split(/[\\/]/).filter(Boolean),r=n.pop();if(!r)throw Error(`Invalid file path`);let i=n.join(`/`)||`/`,a=new FormData;a.append(`files`,new File([t],r,{type:`text/plain`}));let o=await fetch(`/api/files/${vG(i)}?type=upload&conflict=overwrite`,{method:`POST`,body:a});if(!o.ok){let e=`Save failed (${o.status})`;try{let t=await o.json();t?.error&&(e=t.error)}catch{}throw Error(e)}}var r7=(0,d.lazy)(()=>Z1(()=>import(`./CodeMirrorEditor-8bwgbhKt.js`),__vite__mapDeps([18,1]))),i7={source:`Source`,preview:`Preview`,diff:`Diff`},a7={fontFamily:`var(--font-mono)`,fontSize:`var(--text-lg)`,lineHeight:1.6},o7={width:48,minWidth:48,padding:`0 10px`,textAlign:`right`,color:`var(--text-dim)`,background:`var(--bg-panel)`,borderRight:`1px solid var(--border)`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,fontStyle:`normal`,fontVariantNumeric:`tabular-nums`,lineHeight:`20.8px`,userSelect:`none`,flexShrink:0,verticalAlign:`top`};function s7(){return(0,E.jsxs)(`svg`,{width:p.xl,height:p.xl,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,E.jsx)(`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`})]})}function c7(e){return(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(`.file-source-line[data-line-number]`)??null}function l7(e,t){if(!t||t.isCollapsed||t.rangeCount===0)return null;let n=t.getRangeAt(0);if(!e.contains(n.startContainer)||!e.contains(n.endContainer))return null;let r=c7(n.startContainer),i=c7(n.endContainer);if(!r||!i||!e.contains(r)||!e.contains(i))return null;let a=Number(r.dataset.lineNumber),o=Number(i.dataset.lineNumber);if(!Number.isInteger(a)||!Number.isInteger(o))return null;if(a<o){let e=r.querySelector(`.file-source-line-content`);if(e?.contains(n.startContainer)){let t=document.createRange();if(t.selectNodeContents(e),t.setStart(n.startContainer,n.startOffset),t.toString().length===0){let e=r.nextElementSibling;e instanceof HTMLElement&&e.matches(`.file-source-line[data-line-number]`)&&(r=e,a=Number(r.dataset.lineNumber))}}let t=i.querySelector(`.file-source-line-content`);if(t?.contains(n.endContainer)){let e=document.createRange();if(e.selectNodeContents(t),e.setEnd(n.endContainer,n.endOffset),e.toString().length===0){let e=i.previousElementSibling;e instanceof HTMLElement&&e.matches(`.file-source-line[data-line-number]`)&&(i=e,o=Number(i.dataset.lineNumber))}}}return a>o?null:{startLine:a,endLine:o}}function u7({rows:e,stylesheet:t,useInlineStyles:n,wrapLines:r}){return e.map((e,i)=>{let a=e.children??[],o=a[0]?.properties?.className,s=Array.isArray(o)&&o.includes(`react-syntax-highlighter-line-number`),c=s?a[0]:null,l=s?a.slice(1):a;return(0,E.jsxs)(`span`,{className:`file-source-line`,"data-line-number":i+1,style:{display:`flex`,minWidth:`100%`},children:[c&&b3({node:c,stylesheet:t,useInlineStyles:n,key:`source-line-number-${i}`}),(0,E.jsx)(`span`,{className:`file-source-line-content`,style:{flex:`1 1 auto`,minWidth:0,overflowWrap:r?`anywhere`:`normal`,whiteSpace:r?`pre-wrap`:`pre`},children:l.map((e,r)=>b3({node:e,stylesheet:t,useInlineStyles:n,key:`source-token-${i}-${r}`}))})]},`source-line-${i}`)})}function d7(e,t,n,r={}){let i=vG(e),a=new URLSearchParams({type:t});n&&a.set(`sessionId`,n);for(let[e,t]of Object.entries(r))t!==void 0&&a.set(e,String(t));return`/api/files/${i}?${a.toString()}`}function f7({filePath:e,sourceSessionId:t}){let{t:n}=N();return(0,E.jsx)(oi,{label:n(`i18n.downloadFile`),children:(0,E.jsx)(`a`,{href:d7(e,`download`,t),download:yG(e),"aria-label":n(`i18n.downloadFile`),className:`file-viewer-icon-button`,children:(0,E.jsxs)(`svg`,{width:p.xl,height:p.xl,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,E.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,E.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]})})})}function p7(e,t,n){let[r,i]=(0,d.useState)(!1),a=(0,d.useRef)(n);a.current=n;let o=(0,d.useRef)(null);return(0,d.useEffect)(()=>(i(!1),o.current?.(),o.current=Ft({ch:`watch`,filePath:e},e=>{e.event===`connected`?i(!0):e.event===`error`?i(!1):a.current(e)}),()=>{o.current?.(),o.current=null}),[e]),{watching:r,closeWatch:(0,d.useCallback)(()=>{o.current?.(),o.current=null,i(!1)},[])}}function m7({filePath:e,cwd:t,extLabel:n,watching:r,sourceSessionId:i,ellipsis:a,children:o}){let{t:s}=N();return(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,padding:`4px 16px`,borderBottom:`1px solid var(--border)`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`,background:`var(--bg)`,flexShrink:0},children:[(0,E.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`,...a?{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}:{}},title:e,children:xG(e,t)}),(0,E.jsx)(`span`,{style:{marginLeft:`auto`},children:n}),o,(0,E.jsxs)(`span`,{title:s(r?`i18n.liveSync`:`i18n.notWatching`),style:{display:`flex`,alignItems:`center`,gap:4,color:r?`var(--status-success)`:`var(--text-dim)`},children:[(0,E.jsx)(`span`,{style:{width:7,height:7,borderRadius:`50%`,background:r?`var(--status-success)`:`var(--border)`,display:`inline-block`,boxShadow:r?`0 0 4px var(--status-success)`:`none`}}),r?`live`:`static`]}),(0,E.jsx)(f7,{filePath:e,sourceSessionId:i})]})}function h7(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function g7(e){let t=TZ(e);return t?t.flatMap(e=>e.rows.flatMap(e=>{if(e.type===`hunk`)return[];if(e.left.type===`context`&&e.right.type===`context`)return[{type:`unchanged`,text:e.right.text,oldLineNo:e.left.lineNo,newLineNo:e.right.lineNo}];let t=[];return e.left.type===`removed`&&t.push({type:`removed`,text:e.left.text,oldLineNo:e.left.lineNo,newLineNo:null}),e.right.type===`added`&&t.push({type:`added`,text:e.right.text,oldLineNo:null,newLineNo:e.right.lineNo}),t})):[]}function _7({patch:e}){let{t}=N(),n=g7(e);if(!n.some(e=>e.type!==`unchanged`))return(0,E.jsx)(`div`,{style:{padding:`12px 16px`,fontSize:`var(--text-base)`,color:`var(--text-dim)`,fontFamily:`var(--font-mono)`},children:t(`i18n.noChanges`)});let r=new Set(n.flatMap((e,t)=>e.type===`unchanged`?[]:[t])),i=new Set;for(let e of r)for(let t=Math.max(0,e-3);t<=Math.min(n.length-1,e+3);t++)i.add(t);let a=[],o=0;for(;o<n.length;)if(i.has(o)){let e=[];for(;o<n.length&&i.has(o);)e.push(n[o]),o++;a.push({hidden:!1,lines:e})}else{let e=0;for(;o<n.length&&!i.has(o);)e++,o++;a.push({hidden:!0,count:e})}return(0,E.jsx)(`div`,{className:`file-diff-view`,style:{width:`max-content`,minWidth:`100%`,...a7},children:a.map((e,t)=>{if(e.hidden)return(0,E.jsxs)(`div`,{style:{padding:`2px 16px`,color:`var(--text-dim)`,background:`var(--bg-panel)`,fontSize:`var(--text-sm)`,borderTop:`1px solid var(--border)`,borderBottom:`1px solid var(--border)`},children:[`... `,e.count,` unchanged lines ...`]},t);let n=e.lines.map((e,t)=>{let n=e.type===`added`?`color-mix(in srgb, var(--status-success) 12%, transparent)`:e.type===`removed`?`color-mix(in srgb, var(--status-error) 14%, transparent)`:`transparent`,r=e.type===`added`?`+`:e.type===`removed`?`-`:` `,i=e.type===`added`?`var(--status-success)`:e.type===`removed`?`var(--status-error)`:`var(--text-dim)`;return(0,E.jsxs)(`div`,{className:`file-diff-line`,style:{display:`flex`,minWidth:`100%`,background:n,borderLeft:e.type===`added`?`3px solid var(--status-success)`:e.type===`removed`?`3px solid var(--status-error)`:`3px solid transparent`},children:[(0,E.jsx)(`span`,{style:o7,children:e.type===`removed`?e.oldLineNo:e.newLineNo}),(0,E.jsx)(`span`,{style:{minWidth:16,padding:`0 6px`,color:i,userSelect:`none`,flexShrink:0,fontWeight:600},children:r}),(0,E.jsx)(`span`,{className:`file-diff-line-content`,style:{flexShrink:0,padding:`0 8px 0 0`,whiteSpace:`pre`,color:`var(--text)`},children:e.text||`\xA0`})]},t)});return(0,E.jsx)(`div`,{children:n},t)})})}function v7({filePath:e,cwd:t,sourceSessionId:n}){let[r,i]=(0,d.useState)(0),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(null),f=yG(e).toLowerCase().split(`.`).pop()??``;(0,d.useEffect)(()=>{i(0),o(null),c(null),u(null)},[e,n]);let{watching:p}=p7(e,n,e=>{typeof e.size==`number`&&o(e.size),i(e=>e+1)}),m=d7(e,`read`,n,r?{v:r}:void 0),h=a==null?null:h7(a);return(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`hidden`},children:[(0,E.jsxs)(m7,{filePath:e,cwd:t,extLabel:f||`image`,watching:p,sourceSessionId:n,children:[s&&(0,E.jsxs)(`span`,{children:[s.w,` × `,s.h]}),h&&(0,E.jsx)(`span`,{children:h})]}),(0,E.jsx)(`div`,{style:{flex:1,overflow:`auto`,backgroundColor:`var(--bg-panel)`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:16,backgroundImage:`linear-gradient(45deg, var(--bg) 25%, transparent 25%), linear-gradient(-45deg, var(--bg) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--bg) 75%), linear-gradient(-45deg, transparent 75%, var(--bg) 75%)`,backgroundSize:`16px 16px`,backgroundPosition:`0 0, 0 8px, 8px -8px, -8px 0px`},children:l?(0,E.jsx)(`div`,{style:{color:`var(--status-error)`,fontSize:`var(--text-lg)`},children:l}):(0,E.jsx)(`img`,{src:m,alt:e,onLoad:e=>{let t=e.currentTarget;c({w:t.naturalWidth,h:t.naturalHeight})},onError:()=>u(`Failed to load image`),style:{maxWidth:`100%`,maxHeight:`100%`,objectFit:`contain`,boxShadow:`0 2px 8px var(--shadow-color)`}})})]})}function y7({filePath:e,cwd:t,sourceSessionId:n}){let[r,i]=(0,d.useState)(0),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(null),f=yG(e).toLowerCase().split(`.`).pop()??``;(0,d.useEffect)(()=>{i(0),o(null),c(null),u(null)},[e,n]);let{watching:p}=p7(e,n,e=>{typeof e.size==`number`&&o(e.size),c(null),u(null),i(e=>e+1)}),m=d7(e,`read`,n,r?{v:r}:void 0);return(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`hidden`},children:[(0,E.jsxs)(m7,{filePath:e,cwd:t,extLabel:f||`audio`,watching:p,sourceSessionId:n,children:[s!=null&&(0,E.jsx)(`span`,{children:ht(s)}),a!=null&&(0,E.jsx)(`span`,{children:h7(a)})]}),(0,E.jsx)(`div`,{style:{flex:1,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:24,background:`var(--bg-panel)`},children:(0,E.jsxs)(`div`,{style:{width:`min(680px, 100%)`},children:[l&&(0,E.jsx)(`div`,{style:{color:`var(--status-error)`,fontSize:`var(--text-lg)`,marginBottom:12,textAlign:`center`},children:l}),(0,E.jsx)(`audio`,{controls:!0,preload:`metadata`,src:m,onLoadedMetadata:e=>c(e.currentTarget.duration),onError:()=>u(`Failed to load audio`),style:{width:`100%`}},m)]})})]})}function b7({filePath:e,cwd:t,sourceSessionId:n}){let{t:r}=N(),[i,a]=(0,d.useState)(0),[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(null),u=Y5(e),f=u===`pdf`,p=f?d7(e,`read`,n,i?{v:i}:void 0):d7(e,`preview`,n,i?{v:i}:void 0);(0,d.useEffect)(()=>{a(0),s(null),l(null),fetch(d7(e,`meta`,n)).then(e=>e.json()).then(e=>{e.error&&l(e.error),typeof e.size==`number`&&(s(e.size),!f&&e.size>10485760&&l(`DOCX too large for preview (>10MB)`))}).catch(e=>l(String(e)))},[e,f,n]);let{watching:m}=p7(e,n,e=>{if(typeof e.size==`number`&&(s(e.size),!f&&e.size>10485760)){l(`DOCX too large for preview (>10MB)`);return}l(null),a(e=>e+1)});return(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`hidden`},children:[(0,E.jsx)(m7,{filePath:e,cwd:t,extLabel:u===`docx`?`docx preview`:`pdf`,watching:m,sourceSessionId:n,ellipsis:!0,children:o!=null&&(0,E.jsx)(`span`,{children:h7(o)})}),(0,E.jsx)(`div`,{style:{flex:1,minHeight:0,background:`var(--bg-panel)`},children:c?(0,E.jsx)(`div`,{style:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:24,color:`var(--status-error)`,fontSize:`var(--text-lg)`,textAlign:`center`},children:c}):(0,E.jsx)(`iframe`,{src:p,sandbox:f?void 0:`allow-same-origin`,title:r(`i18n.previewFile`,{file:yG(e)}),style:{width:`100%`,height:`100%`,border:`none`,background:f?`var(--bg)`:`#eef1f5`}},p)})]})}function x7({filePath:e,cwd:t,sourceSessionId:n,onOpenFile:r,onMentionLines:i,onSaved:a,gitRefreshKey:o,initialDisplayMode:s}){return $5(e)?(0,E.jsx)(v7,{filePath:e,cwd:t,sourceSessionId:n}):e7(e)?(0,E.jsx)(y7,{filePath:e,cwd:t,sourceSessionId:n}):t7(e)?(0,E.jsx)(b7,{filePath:e,cwd:t,sourceSessionId:n}):(0,E.jsx)(C7,{filePath:e,cwd:t,sourceSessionId:n,onOpenFile:r,onMentionLines:i,onSaved:a,gitRefreshKey:o,initialDisplayMode:s})}function S7({filePath:e,cwd:t,metadata:n,watching:r,isDeletedDiff:i,displayModes:a,effectiveDisplayMode:o,setDisplayMode:s,wrapLines:c,setWrapLines:l,editMode:u,dirty:d,handleSave:f,saveState:m,highlightReady:h,selectedLineRange:g,handleMentionSelectedLines:_,fileContent:v,sourceSessionId:y,t:b,saveError:x,enterEdit:S,cancelEdit:C}){return(0,E.jsxs)(`div`,{className:`file-viewer-toolbar`,style:{display:`flex`,alignItems:`center`,gap:8,padding:`5px 12px`,borderBottom:`1px solid var(--border)`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`,background:`var(--bg)`,flexShrink:0},children:[(0,E.jsx)(oi,{label:e,children:(0,E.jsx)(`span`,{className:`file-viewer-path`,style:{fontFamily:`var(--font-mono)`},children:xG(e,t)})}),(0,E.jsx)(oi,{label:n,children:(0,E.jsx)(`span`,{className:`file-viewer-meta`,children:n})}),!i&&(0,E.jsx)(oi,{label:b(r?`i18n.liveSync`:`i18n.notWatching`),children:(0,E.jsx)(`span`,{"aria-label":b(r?`i18n.liveSync`:`i18n.notWatching`),className:`file-viewer-live-indicator`,style:{background:r?`var(--status-success)`:`var(--border)`,boxShadow:r?`0 0 4px var(--status-success)`:`none`}})}),(0,E.jsxs)(`div`,{className:`file-viewer-controls`,children:[a.length>1&&(0,E.jsx)(`div`,{className:`file-viewer-mode-switch`,"aria-label":b(`i18n.fileViewMode`),children:a.map(e=>{let t=o===e;return(0,E.jsx)(oi,{label:e===`diff`?b(`i18n.compareHead`):void 0,children:(0,E.jsx)(`button`,{type:`button`,onClick:()=>s(e),"aria-pressed":t,className:`file-viewer-mode-button`,style:{background:t?`var(--bg-selected)`:`transparent`,color:t?`var(--text)`:`var(--text-muted)`},children:i7[e]})},e)})}),(0,E.jsxs)(`div`,{className:`file-viewer-actions`,children:[o===`source`&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(oi,{label:b(`i18n.mentionSelectedLines`),children:(0,E.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:_,"aria-label":b(`i18n.mentionSelectedLines`),disabled:!g,className:`file-viewer-icon-button`,children:(0,E.jsx)(s7,{})})}),(0,E.jsx)(oi,{label:b(c?`i18n.disableWrap`:`i18n.enableWrap`),children:(0,E.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-label":b(c?`i18n.disableWrap`:`i18n.enableWrap`),"aria-pressed":c,className:`file-viewer-icon-button`,style:{background:c?`var(--bg-selected)`:`transparent`,color:c?`var(--text)`:`var(--text-muted)`},children:(0,E.jsxs)(`svg`,{width:p.xl,height:p.xl,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`path`,{d:`M4 7V4h16v3`}),(0,E.jsx)(`path`,{d:`M9 20h6`}),(0,E.jsx)(`path`,{d:`M12 4v16`})]})})})]}),o===`source`&&h&&!u&&(0,E.jsx)(`a`,{href:d7(e,`download`,y),download:yG(e),"aria-label":b(`i18n.downloadFile`),className:`file-viewer-icon-button`,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,textDecoration:`none`},children:(0,E.jsxs)(`svg`,{width:p.xl,height:p.xl,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,E.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,E.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]})}),!i&&o===`source`&&(0,E.jsx)(`div`,{className:`file-viewer-edit-controls`,style:{display:`flex`,alignItems:`center`,gap:8,marginLeft:8},children:u?(0,E.jsxs)(E.Fragment,{children:[d&&(0,E.jsx)(oi,{label:b(`i18n.unsavedChanges`),children:(0,E.jsx)(`span`,{"aria-label":b(`i18n.unsavedChanges`),style:{color:`var(--status-warning)`,fontWeight:700},children:`●`})}),(0,E.jsx)(oi,{label:b(`i18n.saveFileShortcut`),children:(0,E.jsx)(`button`,{type:`button`,onClick:f,disabled:!d||m===`saving`,"aria-label":b(`i18n.saveFile`),className:`file-viewer-icon-button`,style:{background:d?`var(--accent)`:`transparent`,color:d?`var(--bg)`:`var(--text-muted)`},children:m===`saving`?(0,E.jsx)(Ar,{size:p.lg,className:`animate-spin`}):(0,E.jsx)(Vr,{size:p.lg})})}),(0,E.jsx)(oi,{label:b(`i18n.cancelEdit`),children:(0,E.jsx)(`button`,{type:`button`,onClick:C,"aria-label":b(`i18n.cancelEdit`),className:`file-viewer-icon-button`,children:(0,E.jsx)(ni,{size:p.lg})})}),m===`error`&&x&&(0,E.jsx)(`span`,{style:{color:`var(--status-error)`,fontSize:`var(--text-sm)`},children:b(`i18n.saveFailed`,{error:x})}),m===`saved`&&!d&&(0,E.jsx)(`span`,{style:{color:`var(--status-success)`,fontSize:`var(--text-sm)`},children:b(`i18n.saved`)})]}):(0,E.jsx)(oi,{label:b(`i18n.editFile`),children:(0,E.jsx)(`button`,{type:`button`,onClick:S,"aria-label":b(`i18n.editFile`),className:`file-viewer-icon-button`,children:(0,E.jsx)(Pr,{size:p.lg})})})}),!i&&(0,E.jsx)(f7,{filePath:e,sourceSessionId:y})]})]})]})}function C7({filePath:e,cwd:t,sourceSessionId:n,onOpenFile:r,onMentionLines:i,onSaved:a,gitRefreshKey:o,initialDisplayMode:s}){let{isDark:c}=Xn(),{t:l}=N(),[u,f]=(0,d.useState)(null),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(!1),[v,y]=(0,d.useState)(!0),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)(`source`),[w,T]=(0,d.useState)(!1),[D,O]=(0,d.useState)(!1),k=(0,d.useRef)(0),A=(0,d.useRef)(null),[j,M]=(0,d.useState)(null),[P,ee]=(0,d.useState)(!1),[F,te]=(0,d.useState)(``),[ne,re]=(0,d.useState)(!1),[ie,ae]=(0,d.useState)(`idle`),[oe,I]=(0,d.useState)(null),L=(0,d.useRef)(!1);L.current=P;let se=(0,d.useCallback)(e=>fetch(d7(e,`read`,n)).then(e=>e.json()).then(e=>e.error?(x(e.error),null):(x(null),f(e),e)).catch(e=>(x(String(e)),null)),[n]),R=(0,d.useCallback)(async e=>{let n=++k.current;if(_(!0),!t){h(null),_(!1);return}try{let r=new URLSearchParams({cwd:t,path:e}),i=await fetch(`/api/git/diff?${r.toString()}`),a=await i.json();if(n!==k.current)return;h(i.ok&&a.supported&&typeof a.patch==`string`?a:null)}catch{n===k.current&&h(null)}finally{n===k.current&&_(!1)}},[t]);(0,d.useEffect)(()=>{y(!0),x(null),f(null),h(null),C(s===`diff`?`diff`:`source`),O(!1),ee(!1),te(``),re(!1),ae(`idle`),I(null),se(e).finally(()=>y(!1))},[e,se]);let{watching:ce,closeWatch:le}=p7(e,n,()=>{L.current||(se(e),R(e))});(0,d.useEffect)(()=>{R(e)},[R,e,o]),(0,d.useEffect)(()=>{u?.language===`markdown`&&s!==`diff`&&C(`preview`)},[u?.language,s]);let ue=m?.supported===!0&&typeof m.patch==`string`,de=ue&&m.status===`deleted`;(0,d.useEffect)(()=>{de&&le()},[de,le]);let fe=(0,d.useMemo)(()=>u?.language===`markdown`?cG(u.content):``,[u]);(0,d.useEffect)(()=>{let e=()=>{let e=A.current;M(i&&S===`source`&&e?l7(e,window.getSelection()):null)};if(e(),!(!i||S!==`source`))return document.addEventListener(`selectionchange`,e),()=>document.removeEventListener(`selectionchange`,e)},[u?.content,S,i]);let pe=(0,d.useCallback)(n=>{!i||!n||i(xG(e,t),n.startLine,n.endLine)},[t,e,i]),me=(0,d.useCallback)(()=>{pe(j)},[pe,j]);(0,d.useEffect)(()=>{if(!i||S!==`source`)return;let e=e=>{if(e.repeat||e.key.toLowerCase()!==`i`||!e.metaKey&&!e.ctrlKey||e.altKey||e.shiftKey)return;let t=e.target;if(t instanceof Element&&t.closest(`input, textarea, [contenteditable='true']`))return;let n=A.current,r=n?l7(n,window.getSelection()):null;r&&(e.preventDefault(),pe(r))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[S,pe,i]);let he=(0,d.useCallback)(()=>{te(u?.content??``),re(!1),ae(`idle`),I(null),ee(!0)},[u?.content]),ge=(0,d.useCallback)(()=>{ee(!1),re(!1),ae(`idle`),I(null),se(e)},[e,se]),_e=(0,d.useCallback)(e=>{te(e),re(e!==(u?.content??``))},[u?.content]),ve=(0,d.useCallback)(async()=>{if(ne){ae(`saving`),I(null);try{await n7(e,F),f(e=>e&&{...e,content:F}),re(!1),ae(`saved`),a?.(e)}catch(e){ae(`error`),I(e instanceof Error?e.message:String(e))}}},[ne,F,e,a]),ye=u?.content??``;if((0,d.useEffect)(()=>{T(!1)},[ye]),(0,d.useEffect)(()=>{if((de?`diff`:S)!==`source`||w)return;let e=setTimeout(()=>T(!0),0);return()=>clearTimeout(e)},[de,S,w]),v||S===`diff`&&g)return(0,E.jsxs)(`div`,{style:{height:`100%`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:12,color:`var(--text-muted)`,fontSize:`var(--text-lg)`},children:[(0,E.jsx)(Ar,{size:p.lg,className:`animate-spin`,"aria-hidden":`true`}),l(`i18n.loading`)]});if(b&&!de)return(0,E.jsx)(`div`,{style:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--status-error)`,fontSize:`var(--text-lg)`},children:b});if(!u&&!de)return null;let be=u?.language??`text`,xe=be===`html`,Se=be===`markdown`,Ce=xe||Se,we=bG(e),Te=ye.split(`
|
|
484
|
-
`),Ee=de?`diff`:S,De=de?[`diff`]:[`source`,...Ce?[`preview`]:[],`diff`],Oe=de?l(`files.deleted`):`${be} · ${Te.length} lines · ${
|
|
485
|
-
`)?r===`mermaid`?(0,E.jsx)(G6,{code:i.replace(/\n$/,``),defaultPreview:!0}):(0,E.jsx)(Y6,{code:i.replace(/\n$/,``),lang:r}):(0,E.jsx)(`code`,{className:e,...n,children:t})},pre({children:e}){return(0,E.jsx)(E.Fragment,{children:e})},a({href:e,children:t,...n}){return delete n.node,(0,E.jsx)(WG,{href:e,markdownDir:we,onOpenFile:r,...n,children:t})},img({src:e,alt:r,...i}){delete i.node;let a=typeof e==`string`?HG(e,we,t??we):null,o=a?d7(a,`read`,n):e;return(0,E.jsx)(`img`,{src:o,alt:r??``,loading:`lazy`,...i})}},children:fe})}):null]})]})}function w7({cwd:e,busy:t,error:n,onCancel:r,onConfirm:i}){let{t:a}=N();return(0,E.jsx)(Ax,{open:!0,onOpenChange:e=>{!e&&!t&&r()},children:(0,E.jsxs)(Px,{className:`w-[440px] gap-0 overflow-hidden rounded-lg p-0`,style:{zIndex:1100,maxWidth:`100%`},showCloseButton:!1,onPointerDownOutside:e=>{t&&e.preventDefault()},onEscapeKeyDown:e=>{t&&e.preventDefault()},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,gap:12,padding:`18px 18px 14px`},children:[(0,E.jsxs)(`svg`,{width:p[`5xl`],height:p[`5xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`var(--status-warning)`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,style:{flexShrink:0,marginTop:1},children:[(0,E.jsx)(`path`,{d:`M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10Z`}),(0,E.jsx)(`path`,{d:`m9 12 2 2 4-4`})]}),(0,E.jsxs)(`div`,{style:{minWidth:0},children:[(0,E.jsx)(Fx,{style:{fontSize:`var(--text-2xl)`,fontWeight:700,color:`var(--text)`,lineHeight:1.4},children:a(`trust.dialogTitle`)}),(0,E.jsx)(Ix,{style:{marginTop:7,fontSize:`var(--text-base)`,lineHeight:1.6,color:`var(--text-muted)`},children:a(`trust.dialogBody`)}),(0,E.jsx)(`code`,{style:{display:`block`,marginTop:10,padding:`8px 10px`,border:`1px solid var(--border)`,borderRadius:5,background:`var(--bg)`,color:`var(--text)`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,overflowWrap:`anywhere`},children:e}),n&&(0,E.jsx)(`div`,{role:`alert`,style:{marginTop:10,color:`var(--status-error)`,fontSize:`var(--text-base)`,lineHeight:1.5},children:n})]})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8,padding:`10px 18px`,borderTop:`1px solid var(--border)`},children:[(0,E.jsx)(kx,{type:`button`,variant:`outline`,onClick:r,disabled:t,className:`h-8 px-3 text-xs`,children:a(`trust.cancel`)}),(0,E.jsx)(kx,{type:`button`,onClick:i,disabled:t,className:`h-8 px-3 text-xs`,style:{cursor:t?`wait`:`pointer`},children:a(t?`trust.trusting`:`trust.trustProject`)})]})]})})}function T7({onCancel:e,onSelect:t,busy:n=!1,error:r}){let{t:i}=N(),[a,o]=(0,d.useState)(!0),[s,c]=(0,d.useState)(``),[l,u]=(0,d.useState)(null),[f,m]=(0,d.useState)(``),[h,g]=(0,d.useState)([]),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(``),[x,S]=(0,d.useState)(null),[C,w]=(0,d.useState)(!0),T=(0,d.useRef)(null),D=(0,d.useCallback)(async e=>{w(!0),S(null);try{let t=await wG(e),n=t.path??e??`/`;c(n),u(t.parentPath??null),m(n),g(t.directories??[]),v(t.drives??null),b(``)}catch(e){S(e instanceof Error?e.message:String(e))}finally{w(!1)}},[]);(0,d.useEffect)(()=>{D()},[D]);let O=e=>{e.preventDefault();let t=f.trim();t&&D(t)},k=f.trim()!==s,A=!!s&&!k&&!n,j=!!l||OG(s),M=y.trim().toLowerCase(),P=e=>!M||e.toLowerCase().includes(M),ee=_===null?[]:_.filter(e=>P(e.name)||P(e.path)),F=h.filter(e=>P(e.name));return(0,E.jsx)(Ax,{open:a,onOpenChange:t=>{!t&&!n&&(o(!1),e())},children:(0,E.jsxs)(Px,{className:`directory-picker-light flex w-[520px] max-w-[calc(100vw-16px)] flex-col gap-0 overflow-hidden p-0`,style:{height:`min(620px, calc(100dvh - 16px))`},showCloseButton:!1,onPointerDownOutside:e=>{n&&e.preventDefault()},onEscapeKeyDown:e=>{n&&e.preventDefault()},onOpenAutoFocus:e=>{e.preventDefault(),T.current?.focus()},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,flexShrink:0,padding:`12px 18px`,borderBottom:`1px solid var(--border)`},children:[(0,E.jsx)(Fx,{style:{fontWeight:700,fontSize:`var(--text-2xl)`,color:`var(--text)`},children:i(`directoryPicker.selectDirectory`)}),(0,E.jsx)(Mx,{asChild:!0,children:(0,E.jsx)(`button`,{type:`button`,disabled:n,title:i(`i18n.close`),"aria-label":i(`i18n.close`),style:{padding:`2px 6px`,border:0,background:`none`,color:`var(--text-muted)`,fontSize:`var(--text-5xl)`,lineHeight:1,cursor:n?`default`:`pointer`,opacity:n?.5:1},children:`×`})})]}),(0,E.jsxs)(`form`,{onSubmit:O,style:{display:`flex`,alignItems:`center`,gap:8,flexShrink:0,padding:`10px 14px`,borderBottom:`1px solid var(--border)`},children:[(0,E.jsx)(`button`,{className:`directory-picker-back`,type:`button`,onClick:()=>void D(l??void 0),disabled:C||!j,title:i(`directoryPicker.goToParent`),"aria-label":i(`directoryPicker.goToParent`),style:{width:36,height:36,padding:0,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,border:`1px solid var(--border)`,borderRadius:6,background:`#ffffff`,color:`var(--text-muted)`,cursor:j?`pointer`:`default`,opacity:j?1:.45},children:(0,E.jsx)(`svg`,{width:p[`3xl`],height:p[`3xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`m18 15-6-6-6 6`})})}),(0,E.jsx)(`label`,{htmlFor:`directory-path`,style:{position:`absolute`,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,border:0},children:i(`directoryPicker.directoryPath`)}),(0,E.jsx)(CG,{className:`directory-picker-path h-9 flex-1 font-mono text-xs`,id:`directory-path`,type:`text`,ref:T,value:f,placeholder:`/path/to/project or ~/project`,autoComplete:`off`,spellCheck:!1,style:TG,onChange:e=>{m(e.target.value),S(null)}}),(0,E.jsx)(`button`,{className:`directory-picker-action`,type:`submit`,disabled:C||!f.trim(),title:i(`directoryPicker.goToDirectory`),style:{minWidth:58,height:36,padding:`0 12px`,border:`1px solid var(--border)`,borderRadius:6,background:`#ffffff`,color:`var(--text-muted)`,cursor:C||!f.trim()?`default`:`pointer`,opacity:C||!f.trim()?.6:1},children:i(`directoryPicker.go`)})]}),(0,E.jsxs)(`div`,{className:`directory-picker-list`,style:{flex:1,minHeight:0,overflow:`auto`,padding:`8px 10px`},children:[C?(0,E.jsx)(`div`,{style:{padding:8,color:`var(--text-dim)`,fontSize:`var(--text-sm)`},children:i(`directoryPicker.loadingDirectories`)}):_===null?F.length>0?F.map(e=>(0,E.jsxs)(`button`,{className:`directory-picker-entry`,type:`button`,onClick:()=>void D(e.path),title:e.path,style:{width:`100%`,minHeight:30,display:`flex`,alignItems:`center`,gap:7,padding:`5px 8px`,border:0,borderRadius:5,background:`none`,color:`var(--text-muted)`,cursor:`pointer`,textAlign:`left`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`},children:[(0,E.jsx)(EG,{}),(0,E.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.name})]},e.path)):(0,E.jsx)(`div`,{style:{padding:8,color:`var(--text-dim)`,fontSize:`var(--text-sm)`},children:i(M?`directoryPicker.noMatches`:`directoryPicker.noSubdirectories`)}):ee.length>0?ee.map(e=>(0,E.jsxs)(`button`,{className:`directory-picker-entry`,type:`button`,onClick:()=>void D(e.path),title:e.path,style:{width:`100%`,minHeight:34,display:`flex`,alignItems:`center`,gap:7,padding:`6px 8px`,border:0,borderRadius:5,background:`none`,color:`var(--text-muted)`,cursor:`pointer`,textAlign:`left`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`},children:[(0,E.jsx)(DG,{}),(0,E.jsx)(`span`,{children:e.name})]},e.path)):(0,E.jsx)(`div`,{style:{padding:8,color:`var(--text-dim)`,fontSize:`var(--text-sm)`},children:i(M?`directoryPicker.noMatches`:`directoryPicker.noDrives`)}),(x||r)&&(0,E.jsx)(`div`,{style:{padding:`8px`,color:`var(--status-error)`,fontSize:`var(--text-sm)`},children:x??r})]}),(0,E.jsxs)(`div`,{className:`directory-picker-footer`,style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,gap:10,flexShrink:0,padding:`10px 18px`,borderTop:`1px solid var(--border)`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,flex:1,minWidth:0},children:[(0,E.jsxs)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,style:{color:`var(--text-dim)`,flexShrink:0},children:[(0,E.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,E.jsx)(`path`,{d:`m21 21-4.3-4.3`})]}),(0,E.jsx)(CG,{className:`directory-picker-search h-8 flex-1`,type:`text`,value:y,placeholder:i(`directoryPicker.search`),"aria-label":i(`directoryPicker.search`),autoComplete:`off`,spellCheck:!1,style:TG,onChange:e=>b(e.target.value)})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,flexShrink:0},children:[(0,E.jsx)(`button`,{className:`directory-picker-action`,type:`button`,onClick:e,disabled:n,style:{padding:`6px 14px`,border:`1px solid var(--border)`,borderRadius:6,background:`none`,color:`var(--text-muted)`,cursor:n?`default`:`pointer`,fontSize:`var(--text-lg)`},children:i(`i18n.cancel`)}),(0,E.jsx)(`button`,{className:`directory-picker-action`,type:`button`,onClick:()=>t(s),disabled:!A,title:i(k?`directoryPicker.openBeforeSelecting`:`directoryPicker.selectCurrentDirectory`),style:{padding:`6px 16px`,border:0,borderRadius:6,background:`var(--accent)`,color:`var(--on-accent)`,fontSize:`var(--text-lg)`,fontWeight:600,opacity:A?1:.6,cursor:A?`pointer`:`default`},children:i(n?`i18n.checking`:`directoryPicker.selectThisFolder`)})]})]})]})})}function E7({visible:e=!0,gap:t=4,items:n}){return e?(0,E.jsx)(`div`,{style:{display:`flex`,gap:t,flexShrink:0},children:n.map(e=>(0,E.jsx)(oi,{label:e.title,children:(0,E.jsx)(`button`,{type:`button`,onClick:e.onClick,disabled:e.disabled,"data-testid":e.testId,"aria-label":e.title,"aria-pressed":e.ariaPressed,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:32,height:32,padding:0,background:e.background??`transparent`,border:`1px solid ${e.borderColor??`var(--border)`}`,borderRadius:7,color:e.color??`var(--text-muted)`,cursor:e.disabled?`default`:`pointer`,flexShrink:0,opacity:e.disabled?.6:1,transition:`background 0.12s, color 0.12s, border-color 0.12s`,"--hover-bg":e.danger?`color-mix(in srgb, var(--status-error) 8%, transparent)`:`var(--bg-selected)`,"--hover-color":e.danger?`var(--status-error)`:`var(--accent)`,"--hover-border":e.danger?`color-mix(in srgb, var(--status-error) 35%, transparent)`:`color-mix(in srgb, var(--accent) 35%, transparent)`},className:e.skipHover?void 0:`hover-shift`,children:e.icon})},e.key))}):null}var D7=2;function O7({scrollStepPx:e=200,wrapperStyle:t,children:n,testId:r,hintTestId:i}){let a=(0,d.useRef)(null),[o,s]=(0,d.useState)({scrollHeight:0,clientHeight:0,scrollTop:0}),c=()=>{if(document.hidden)return;let e=a.current;e&&s({scrollHeight:e.scrollHeight,clientHeight:e.clientHeight,scrollTop:e.scrollTop})};(0,d.useLayoutEffect)(()=>{c();let e=a.current;if(!e)return;let t=new ResizeObserver(c);return t.observe(e),()=>t.disconnect()},[]);let{scrollHeight:l,clientHeight:u,scrollTop:f}=o,p=l-u>20,m=f<=D7,h=f+u>=l-D7,g=t=>{let n=a.current;if(!n)return;let r=Math.max(0,n.scrollHeight-n.clientHeight);n.scrollTo({top:Math.max(0,Math.min(r,n.scrollTop+t*e)),behavior:`smooth`})},_=e=>{let t=a.current;t&&t.scrollTo({top:e===`top`?0:Math.max(0,t.scrollHeight-t.clientHeight),behavior:`smooth`})};return(0,E.jsxs)(`div`,{style:{position:`relative`,...t},children:[(0,E.jsx)(`div`,{ref:a,"data-testid":r,onScroll:c,style:{position:`absolute`,inset:0,overflowY:`auto`,overflowX:`hidden`,padding:0},children:n}),p&&!m&&(0,E.jsx)(Bn,{direction:`up`,visible:!0,testId:i?`${i}-scroll-up`:void 0,onHover:()=>g(-1),onClick:()=>_(`top`)}),p&&!h&&(0,E.jsx)(Bn,{direction:`down`,visible:!0,testId:i?`${i}-scroll-down`:void 0,onHover:()=>g(1),onClick:()=>_(`bottom`)})]})}function k7({...e}){return(0,E.jsx)(fo,{"data-slot":`collapsible`,...e})}function A7({...e}){return(0,E.jsx)(oo,{"data-slot":`collapsible-trigger`,...e})}function j7({...e}){return(0,E.jsx)(co,{"data-slot":`collapsible-content`,...e})}function M7({title:e,titleTooltip:t,open:n,onToggle:r,collapsible:i=!0,actions:a,expandedFlex:o=`1 1 0`,style:s,children:c}){return(0,E.jsxs)(k7,{open:n,onOpenChange:r,style:{borderTop:`1px solid var(--border)`,display:`flex`,flexDirection:`column`,flex:n?o:`0 0 auto`,minHeight:0,overflow:`hidden`,...s},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,flexShrink:0,background:`var(--bg-panel)`},children:[(0,E.jsx)(oi,{label:t??e,children:(0,E.jsx)(A7,{asChild:!0,children:(0,E.jsxs)(`button`,{type:`button`,disabled:!i,style:{display:`flex`,alignItems:`center`,gap:6,flex:`0 0 auto`,height:36,padding:`0 12px`,background:`none`,border:`none`,color:`var(--text-muted)`,cursor:i?`pointer`:`default`,fontSize:`var(--text-base)`,fontWeight:600,letterSpacing:`0.05em`,textTransform:`none`,textAlign:`left`},children:[i&&(0,E.jsx)(`svg`,{width:p.xs,height:p.xs,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{transform:n?`rotate(90deg)`:`none`,transition:`transform 0.15s`,flexShrink:0},children:(0,E.jsx)(`polyline`,{points:`3 2 7 5 3 8`})}),(0,E.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e})]})})}),a&&(0,E.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,marginLeft:`auto`,minWidth:0,gap:6,flexShrink:1,paddingRight:4},children:a})]}),(0,E.jsx)(j7,{style:{display:`flex`,flexDirection:`column`,minHeight:0,flex:1},children:c})]})}function N7({title:e,titleTooltip:t,open:n,onToggle:r,collapsible:i=!0,actions:a,headerExtra:o,expandedFlex:s=`1 1 0`,scrollStepPx:c=200,testId:l,hintTestId:u,rootTestId:d,scrollStyle:f,style:p,children:m}){return(0,E.jsx)(`div`,{"data-testid":d,style:{display:`flex`,flexDirection:`column`,border:`1px solid var(--border)`,borderRadius:0,background:`var(--bg-panel)`,overflow:`hidden`,...p},children:(0,E.jsxs)(M7,{title:e,titleTooltip:t,open:n,onToggle:r,collapsible:i,actions:a,expandedFlex:s,style:{borderTop:`none`},children:[o,(0,E.jsx)(O7,{scrollStepPx:c,wrapperStyle:{flex:1,minHeight:0,...f},testId:l,hintTestId:u,children:m})]})})}function P7(e){return e.error?e.path.split(/[\\/]/).pop()||e.id:e.name||e.firstMessage.slice(0,50)||e.id.slice(0,12)}var F7=(e,t)=>e.replace(/\\/g,`/`)===t.replace(/\\/g,`/`),I7=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``).replace(/^[a-zA-Z]:/,e=>e.toLowerCase()),L7=`pi-web:unread-session-ids`;function R7(){if(typeof window>`u`)return new Set;try{let e=window.localStorage.getItem(L7);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function z7(e){if(!(typeof window>`u`))try{e.size===0?window.localStorage.removeItem(L7):window.localStorage.setItem(L7,JSON.stringify([...e]))}catch{}}function B7(){let[e,t]=(0,d.useState)(()=>R7());return(0,d.useEffect)(()=>{z7(e)},[e]),{unreadSessionIds:e,setUnreadSessionIds:t}}function V7(e){let{selectedCwd:t,selectedCwdProp:n,refreshKey:r,setSelectedCwd:i}=e,[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(``),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(!1),[v,y]=(0,d.useState)(null),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)(``),w=(0,d.useRef)(null),T=(0,d.useRef)(null),E=(0,d.useRef)(null);(0,d.useEffect)(()=>{n&&n!==E.current&&(E.current=n,i(n))},[n,i]);let D=(0,d.useCallback)(()=>{c(!1),u(!1),p(``),h(null),y(null),C(``)},[]),[O,k]=(0,d.useState)(0);(0,d.useLayoutEffect)(()=>{if(!t){o(null),x(null);return}let e=!1;return x(t),fetch(`/api/worktrees?cwd=${encodeURIComponent(t)}`).then(e=>e.json()).then(n=>{if(!e){if(x(null),n.error||!n.projectRoot){o(null);return}o({forCwd:t,projectRoot:n.projectRoot,isGit:n.isGit??!1,isTopLevel:n.isTopLevel??!1,worktrees:n.worktrees??[]})}}).catch(()=>{e||(x(null),o(null))}),()=>{e=!0}},[t,O,r]);let A=(0,d.useCallback)(async()=>{let e=f.trim();if(!(!e||g||!a)){_(!0),h(null);try{let t=await fetch(`/api/worktrees`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:a.projectRoot,branch:e})}),n=await t.json().catch(()=>({}));if(!t.ok||n.error||!n.path){h(n.error??`HTTP ${t.status}`);return}D(),o(t=>t&&{...t,forCwd:n.path,worktrees:[...t.worktrees,{path:n.path,branch:e,isMain:!1}]}),i(n.path),k(e=>e+1)}catch(e){h(e instanceof Error?e.message:String(e))}finally{_(!1)}}},[D,f,g,a,i]),j=(0,d.useCallback)(async(e,n)=>{if(!(!a||g)){_(!0),h(null);try{let r=await fetch(`/api/worktrees`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:a.projectRoot,path:e,force:n})}),o=await r.json().catch(()=>({}));if(!r.ok){if(o.dirty&&!n){y(e);return}h(o.error??`HTTP ${r.status}`);return}D(),t&&e&&F7(t,e)&&i(a.projectRoot),k(e=>e+1)}catch(e){h(e instanceof Error?e.message:String(e))}finally{_(!1)}}},[D,a,g,t,i]);return(0,d.useEffect)(()=>{let e=e=>{w.current&&!w.current.contains(e.target)&&D()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[D]),{worktreeState:a,worktreeLoadingCwd:b,wtDropdownOpen:s,setWtDropdownOpen:c,wtNewOpen:l,setWtNewOpen:u,wtNewBranch:f,setWtNewBranch:p,wtError:m,setWtError:h,wtBusy:g,wtConfirmRemove:v,setWtConfirmRemove:y,wtFilter:S,setWtFilter:C,wtDropdownRef:w,wtNewInputRef:T,closeWorktrees:D,handleCreateWorktree:A,handleRemoveWorktree:j}}function H7({wt:e,selectedCwd:t,homeDir:n,setSelectedCwd:r}){let{t:i}=N(),{worktreeState:a,wtFilter:o,setWtFilter:s,wtDropdownOpen:c,setWtDropdownOpen:l,wtDropdownRef:u,closeWorktrees:d,handleRemoveWorktree:f,wtConfirmRemove:m,setWtConfirmRemove:h,wtBusy:g,wtNewOpen:_,setWtNewOpen:v,wtNewBranch:y,setWtNewBranch:b,wtNewInputRef:x,handleCreateWorktree:S,wtError:C,setWtError:w}=e;if(!a)return null;let T=a.worktrees.find(e=>F7(e.path,t))??a.worktrees.find(e=>e.isMain),D=a.worktrees.length>=8,O=D&&o.trim()?a.worktrees.filter(e=>(e.branch??G7(e.path,n)).toLowerCase().includes(o.trim().toLowerCase())):a.worktrees;return(0,E.jsxs)(`div`,{ref:u,style:{position:`relative`,marginTop:6},children:[(0,E.jsxs)(`button`,{onClick:()=>l(e=>!e),title:T?i(`sidebar.switchWorktreeTitle`,{path:T.path}):i(`sidebar.switchWorktree`),style:{width:`100%`,height:29,boxSizing:`border-box`,display:`flex`,alignItems:`center`,gap:6,padding:`0 10px`,background:`var(--bg-input)`,border:`1px solid var(--border)`,borderRadius:7,cursor:`pointer`,fontSize:`var(--text-sm)`,lineHeight:1.35,color:`var(--text-muted)`,textAlign:`left`},children:[(0,E.jsxs)(`svg`,{width:p.sm,height:p.sm,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0,color:T&&!T.isMain?`var(--accent)`:`var(--text-dim)`},children:[(0,E.jsx)(`line`,{x1:`6`,y1:`3`,x2:`6`,y2:`15`}),(0,E.jsx)(`circle`,{cx:`18`,cy:`6`,r:`3`}),(0,E.jsx)(`circle`,{cx:`6`,cy:`18`,r:`3`}),(0,E.jsx)(`path`,{d:`M18 9a9 9 0 0 1-9 9`})]}),(0,E.jsx)(q7,{text:T?T.branch??G7(T.path,n):`…`,style:{flex:1,fontFamily:`var(--font-mono)`,color:`var(--text)`}}),T?.isMain&&(0,E.jsx)(`span`,{style:{flexShrink:0,color:`var(--text-dim)`,fontSize:`var(--text-xs)`},children:i(`sidebar.main`)}),a.worktrees.length>1&&(0,E.jsx)(`span`,{style:{flexShrink:0,color:`var(--text-dim)`,fontSize:`var(--text-xs)`},children:a.worktrees.length}),(0,E.jsx)(`svg`,{width:`9`,height:`9`,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:(0,E.jsx)(`polyline`,{points:`2 3.5 5 6.5 8 3.5`})})]}),(0,E.jsxs)(Z7,{open:c,style:{position:`absolute`,top:`calc(100% + 4px)`,left:0,right:0,zIndex:100,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:8,boxShadow:`0 6px 20px var(--shadow-color)`,overflow:`hidden`},children:[D&&(0,E.jsx)(`div`,{style:{padding:`6px 8px`,borderBottom:`1px solid var(--border)`},children:(0,E.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(s(``),d())},placeholder:i(`sidebar.filterWorktrees`),autoFocus:!0,style:{width:`100%`,fontSize:`var(--text-sm)`,fontFamily:`var(--font-mono)`,padding:`5px 8px`,border:`1px solid var(--border)`,borderRadius:5,outline:`none`,background:`var(--bg)`,color:`var(--text)`,boxSizing:`border-box`}})}),(0,E.jsxs)(`div`,{style:{maxHeight:`min(40vh, 300px)`,overflowY:`auto`},children:[O.map(e=>{let o=F7(e.path,t)||e.isMain&&!a.worktrees.some(e=>F7(e.path,t));return m===e.path?(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,padding:`7px 10px`,borderBottom:`1px solid var(--border)`,background:`color-mix(in srgb, var(--status-error) 6%, transparent)`},children:[(0,E.jsx)(`span`,{style:{flex:1,fontSize:`var(--text-sm)`,color:`var(--text)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:i(`sidebar.forceRemoveCheckout`)}),(0,E.jsx)(`button`,{onClick:()=>void f(e.path,!0),disabled:g,style:{padding:`3px 9px`,background:`var(--status-error)`,border:`none`,borderRadius:5,color:`var(--on-error)`,fontSize:`var(--text-sm)`,fontWeight:600,cursor:`pointer`,flexShrink:0},children:i(`sidebar.force`)}),(0,E.jsx)(`button`,{onClick:()=>h(null),style:{padding:`3px 9px`,background:`var(--bg-hover)`,border:`1px solid var(--border)`,borderRadius:5,color:`var(--text-muted)`,fontSize:`var(--text-sm)`,cursor:`pointer`,flexShrink:0},children:i(`sidebar.cancel`)})]},e.path):(0,E.jsxs)(`div`,{className:`wt-row`,style:{display:`flex`,alignItems:`center`,borderBottom:`1px solid var(--border)`},children:[(0,E.jsxs)(`button`,{onClick:()=>{r(e.path),d()},title:e.path,style:{flex:1,minWidth:0,display:`flex`,alignItems:`center`,gap:7,padding:`8px 10px`,background:`var(--bg)`,border:`none`,color:o?`var(--text)`:`var(--text-muted)`,cursor:`pointer`,textAlign:`left`,fontSize:`var(--text-sm)`,fontFamily:`var(--font-mono)`},children:[o?(0,E.jsx)(`svg`,{width:p.xs,height:p.xs,viewBox:`0 0 10 10`,fill:`none`,stroke:`var(--accent)`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:(0,E.jsx)(`polyline`,{points:`1.5 5 4 7.5 8.5 2.5`})}):(0,E.jsx)(`span`,{style:{width:10,flexShrink:0}}),(0,E.jsx)(q7,{text:e.branch??G7(e.path,n),style:{flex:1}}),e.isMain&&(0,E.jsx)(`span`,{style:{flexShrink:0,color:`var(--text-dim)`,fontSize:`var(--text-xs)`},children:i(`sidebar.main`)})]}),!e.isMain&&(0,E.jsx)(`button`,{onClick:()=>void f(e.path,!1),disabled:g,title:i(`sidebar.removeWorktreeTitle`,{path:e.path}),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:34,height:28,padding:0,marginRight:4,background:`none`,border:`none`,color:`var(--text-dim)`,cursor:`pointer`,borderRadius:5,flexShrink:0,transition:`color 0.12s, background 0.12s`,"--hover-color":`var(--status-error)`,"--hover-bg":`color-mix(in srgb, var(--status-error) 8%, transparent)`},className:`hover-shift`,children:(0,E.jsxs)(`svg`,{width:p.base,height:p.base,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`polyline`,{points:`3 6 5 6 21 6`}),(0,E.jsx)(`path`,{d:`M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6`}),(0,E.jsx)(`path`,{d:`M10 11v6M14 11v6`}),(0,E.jsx)(`path`,{d:`M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2`})]})})]},e.path)}),D&&O.length===0&&o.trim()&&(0,E.jsx)(`div`,{style:{padding:`8px 10px`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`},children:i(`sidebar.noMatchingWorktrees`)})]}),_?(0,E.jsxs)(`div`,{style:{padding:`6px 8px`},children:[(0,E.jsx)(`input`,{ref:x,value:y,onChange:e=>{b(e.target.value),w(null)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),S()),e.key===`Escape`&&(v(!1),b(``),w(null))},placeholder:i(`sidebar.branchName`),style:{width:`100%`,fontSize:`var(--text-sm)`,fontFamily:`var(--font-mono)`,padding:`5px 8px`,border:`1px solid var(--accent)`,borderRadius:5,outline:`none`,background:`var(--bg)`,color:`var(--text)`,boxSizing:`border-box`}}),(0,E.jsxs)(`div`,{style:{display:`flex`,gap:5,marginTop:5},children:[(0,E.jsx)(`button`,{onClick:()=>void S(),disabled:g||!y.trim(),style:{flex:1,padding:`4px 0`,background:`var(--accent)`,border:`none`,borderRadius:5,color:`var(--on-accent)`,fontSize:`var(--text-sm)`,fontWeight:600,cursor:g||!y.trim()?`not-allowed`:`pointer`,opacity:g||!y.trim()?.65:1},children:i(g?`sidebar.creating`:`sidebar.create`)}),(0,E.jsx)(`button`,{onClick:()=>{v(!1),b(``),w(null)},style:{flex:1,padding:`4px 0`,background:`var(--bg-hover)`,border:`1px solid var(--border)`,borderRadius:5,color:`var(--text-muted)`,fontSize:`var(--text-sm)`,cursor:`pointer`},children:i(`sidebar.cancel`)})]})]}):(0,E.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),v(!0),w(null),setTimeout(()=>x.current?.focus(),0)},title:i(`sidebar.createWorktreeTitle`),style:{display:`flex`,alignItems:`center`,gap:7,width:`100%`,padding:`8px 10px`,background:`none`,border:`none`,color:`var(--text-muted)`,cursor:`pointer`,textAlign:`left`,fontSize:`var(--text-sm)`},children:[(0,E.jsxs)(`svg`,{width:p.xs,height:p.xs,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.1`,strokeLinecap:`round`,style:{flexShrink:0},children:[(0,E.jsx)(`line`,{x1:`5`,y1:`1`,x2:`5`,y2:`9`}),(0,E.jsx)(`line`,{x1:`1`,y1:`5`,x2:`9`,y2:`5`})]}),(0,E.jsx)(`span`,{children:i(`sidebar.newWorktree`)})]}),C&&(0,E.jsx)(`div`,{style:{padding:`5px 10px 8px`,color:`var(--status-error)`,fontSize:`var(--text-sm)`,lineHeight:1.35,overflowWrap:`anywhere`},children:C})]})]})}function U7(e,t){let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/6e4),a=Math.floor(r/36e5),o=Math.floor(r/864e5);return i<1?t(`sidebar.justNow`):i<60?t(`sidebar.minutesAgo`,{count:i}):a<24?t(`sidebar.hoursAgo`,{count:a}):o<7?t(`sidebar.daysAgo`,{count:o}):n.toLocaleDateString()}function W7(e){let t=new Map;for(let n of e){let e=n.projectRoot??n.cwd;if(!e)continue;let r=t.get(e);(!r||n.modified>r)&&t.set(e,n.modified)}return[...t.entries()].sort((e,t)=>t[1].localeCompare(e[1])).map(([e])=>e)}function G7(e,t){return t&&e.startsWith(t)?`~${e.slice(t.length)}`:e}function K7(e){let t=e.split(/[\\/]+/).filter(Boolean);return t.length?t[t.length-1]:e}function q7({text:e,style:t}){return(0,E.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,display:`block`,minWidth:0,lineHeight:1.35,direction:`rtl`,textAlign:`left`,...t},children:(0,E.jsx)(`span`,{style:{unicodeBidi:`plaintext`},children:e})})}function J7({session:e}){return(0,E.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:4,color:`var(--danger)`,minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},title:`${e.path}: ${e.error}`,children:[(0,E.jsxs)(`svg`,{width:p.xs,height:p.xs,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,style:{flexShrink:0},children:[(0,E.jsx)(`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`}),(0,E.jsx)(`path`,{d:`M12 9v4`}),(0,E.jsx)(`path`,{d:`M12 17h.01`})]}),e.error]})}var Y7=140,X7=2e3;function Z7({open:e,children:t,style:n}){let[r,i]=(0,d.useState)(e),[a,o]=(0,d.useState)(e);return(0,d.useEffect)(()=>{let t,n;return e?(i(!0),o(!1),t=window.requestAnimationFrame(()=>{t=window.requestAnimationFrame(()=>o(!0))})):(o(!1),n=setTimeout(()=>i(!1),Y7)),()=>{t!==void 0&&window.cancelAnimationFrame(t),n&&clearTimeout(n)}},[e]),r?(0,E.jsx)(`div`,{style:{...n,opacity:+!!a,transform:a?`translateY(0) scale(1)`:`translateY(-8px) scale(0.96)`,transformOrigin:`top center`,transition:`opacity ${Y7}ms ease, transform ${Y7}ms ease`,pointerEvents:e?`auto`:`none`},children:t}):null}function Q7(e){let t=new Map;for(let n of e)t.set(n.id,{session:n,children:[]});let n=new Map;for(let t of e)t.parentSessionId&&n.set(t.id,t.parentSessionId);function r(e){let r=n.get(e),i=new Set;for(;r;){if(i.has(r))return null;if(i.add(r),t.has(r))return r;r=n.get(r)}return null}let i=[];for(let e of t.values()){let n=r(e.session.id);n?t.get(n).children.push(e):i.push(e)}let a=e=>{e.sort((e,t)=>t.session.modified.localeCompare(e.session.modified)),e.forEach(e=>a(e.children))};return a(i),i}function $7({selectedSessionId:e,selectedSession:t,onSelectSession:n,onNewSession:r,initialSessionId:i,skipInitialProjectSelection:a,onInitialRestoreDone:o,refreshKey:s,onSessionDeleted:c,selectedCwd:l,onCwdChange:u,savedWorkspaces:f,onSavedWorkspacesChange:m,onOpenFile:h}){let{t:g}=N(),[_,v]=(0,d.useState)([]),[y,b]=(0,d.useState)(!0),[x,S]=(0,d.useState)(null),[C,w]=(0,d.useState)(null),[T,D]=(0,d.useState)(``),[O,k]=(0,d.useState)(!1),[A,j]=(0,d.useState)(``),[M,P]=(0,d.useState)(null),[ee,F]=(0,d.useState)(!1),te=V7({selectedCwd:C,selectedCwdProp:l,refreshKey:s,setSelectedCwd:w}),{worktreeState:ne,worktreeLoadingCwd:re}=te,[ie,ae]=(0,d.useState)(!1),[oe,I]=(0,d.useState)(``),L=(0,d.useRef)(null);(0,d.useEffect)(()=>{ie&&L.current?.focus()},[ie]);let[se,R]=(0,d.useState)(!1),[ce,le]=(0,d.useState)(()=>new Set),ue=(0,d.useCallback)(e=>{le(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),de=(0,d.useCallback)(e=>{le(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),Pt(e)},[]),{unreadSessionIds:fe,setUnreadSessionIds:pe}=B7(),me=Jq(),{runningSessionIds:he,runningPhases:ge,runningPhaseSince:_e,runningBusySince:ve,setRunningSessionIds:ye,runningPollAuthoritativeRef:be}=Kt(),Se=(0,d.useRef)(new Set),Ce=(0,d.useRef)(null),we=(0,d.useRef)(0),Te=(0,d.useCallback)(async(e=!1,t=!1)=>{try{e&&b(!0);let n=t?await xe.refresh():await xe.load();v(n.sessions),be.current||ye(new Set(n.runningSessionIds??[]));let r=new Set(n.sessions.map(e=>e.id));pe(e=>{if(e.size===0)return e;let t=new Set([...e].filter(e=>r.has(e)));return t.size===e.size?e:t}),S(null),e||(R(!0),Ce.current&&clearTimeout(Ce.current),Ce.current=setTimeout(()=>R(!1),2e3))}catch(e){S(String(e))}finally{e&&b(!1)}},[pe,ye,be]),Ee=(0,d.useRef)(!1);(0,d.useEffect)(()=>{let e=!Ee.current;Ee.current=!0,Te(e,e)},[Te,s]),(0,d.useEffect)(()=>{z7(fe)},[fe]),(0,d.useEffect)(()=>{let t=[...Se.current].filter(t=>!he.has(t)&&t!==e),n=[...he];if((t.length>0||n.length>0)&&pe(e=>{let r=new Set(e);return n.forEach(e=>r.delete(e)),t.forEach(e=>r.add(e)),r}),t.length>0&&Te(!1),[...he].filter(e=>!_.some(t=>t.id===e)).length>0){let e=Date.now();e-we.current>=X7&&(we.current=e,Te(!1,!0))}Se.current=he},[he,e,_,Te,pe]),(0,d.useEffect)(()=>{e&&(Gq(e),pe(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}))},[e,pe]),(0,d.useEffect)(()=>{fetch(`/api/home`).then(e=>e.json()).then(e=>{e.home&&D(e.home)}).catch(()=>{})},[]);let De=(0,d.useRef)(!1),Oe=(0,d.useCallback)(e=>e?ne&&ne.forCwd&&F7(ne.forCwd,e)||ne?.worktrees.some(t=>F7(t.path,e))?ne.projectRoot:_.find(t=>t.cwd&&F7(t.cwd,e))?.projectRoot??e:null,[ne,_]),ke=(0,d.useRef)(null);(0,d.useEffect)(()=>{ke.current!==C&&(ke.current=C,u?.(C,Oe(C)))},[C,u,Oe]),(0,d.useEffect)(()=>{if(!(_.length===0||a)&&C===null){if(i&&!De.current){De.current=!0;let e=_.find(e=>e.id===i);if(e){w(e.cwd),ue(e.id),n(e,!0);return}o?.()}let e=W7(_);e.length>0&&w(e[0])}},[_,C,i,a,n,o,ue]);let Ae=(0,d.useCallback)(async e=>{let t=(e??A).trim();if(!(!t||ee)){F(!0),P(null);try{let e=await fetch(`/api/cwd/validate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:t})}),n=await e.json().catch(()=>({}));if(!e.ok||n.error){P(n.error??`HTTP ${e.status}`);return}let r=n.cwd??t;if(w(r),k(!1),j(``),m){let e=f??[];e.some(e=>I7(e)===I7(r))||m([...e,r])}}catch(e){P(e instanceof Error?e.message:String(e))}finally{F(!1)}}},[A,ee,f,m]),je=(0,d.useCallback)(async e=>{try{if((await fetch(`/api/sessions/${encodeURIComponent(e.id)}`,{method:`HEAD`})).status===404){S(g(`sidebar.sessionDeleted`)),Te(!1,!0);return}}catch{}e.cwd&&w(e.cwd),ue(e.id),n(e)},[n,g,Te,ue]),Me=(0,d.useCallback)(e=>{let t=e??C;if(!t)return;let n=typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`;r?.(n,t)},[C,r]),[Ne,Pe]=(0,d.useState)({}),[Fe,Ie]=(0,d.useState)(null),[Le,Re]=(0,d.useState)(null),[ze,Be]=(0,d.useState)(!1),Ve=Oe(C),He=_,Ue=!!(ne?.isGit&&ne.isTopLevel&&C&&Ve===ne.projectRoot),We=(C&&ne&&Ve===ne.projectRoot&&!Ue?ne.isGit?{label:g(`sidebar.openRepoRoot`),title:g(`sidebar.openRepoRootTitle`)}:{label:g(`sidebar.gitRepoRootOnly`),title:g(`sidebar.gitRepoRootOnlyTitle`)}:null)??(C&&re===C&&!Ue?{label:g(`sidebar.worktrees`),title:g(`sidebar.checkingWorktrees`)}:null),Ge=(0,d.useCallback)(async e=>{Re(null),Be(!0);try{await Promise.all(e.sessions.map(e=>fetch(`/api/sessions/${encodeURIComponent(e.id)}`,{method:`DELETE`}).then(t=>{t.ok||console.error(`[sidebar] failed to delete ${e.id}:`,t.status)}).catch(t=>console.error(`[sidebar] failed to delete ${e.id}:`,t))));for(let t of e.sessions)c?.(t.id);let t=f??[];m&&t.some(t=>I7(t)===I7(e.root))&&m(t.filter(t=>I7(t)!==I7(e.root))),Te(!1,!0)}finally{Be(!1)}},[c,Te,f,m]),Ke=(0,d.useMemo)(()=>{let e=t&&!He.some(e=>e.id===t.id)?[{...t,projectRoot:t.projectRoot??Oe(t.cwd)??void 0},...He]:He,n=new Map,r=new Map;for(let t of e){let e=t.projectRoot??t.cwd??`unknown`,i=e===`unknown`?e:I7(e);n.has(i)||(n.set(i,[]),r.set(i,e)),n.get(i).push(t)}let i=[...n.entries()].map(([e,t])=>({root:r.get(e)??e,sessions:t})).sort((e,t)=>{let n=e=>Math.max(...e.map(e=>{let t=new Date(e.modified).getTime();return Number.isNaN(t)?0:t}));return n(t.sessions)-n(e.sessions)}),a=[];if(C){let e=Oe(C);e&&!n.has(I7(e))&&a.push({root:e,sessions:[]})}let o=new Set([...n.keys()]);for(let e of a)o.add(I7(e.root));let s=[];for(let e of f??[]){let t=I7(e);o.has(t)||(o.add(t),s.push({root:e,sessions:[]}))}return[...a,...i,...s]},[He,C,Oe,t,f]),qe=oe.trim().toLowerCase(),Je=(0,d.useMemo)(()=>qe?Ke.map(e=>({...e,sessions:e.sessions.filter(e=>P7(e).toLowerCase().includes(qe))})).filter(e=>e.sessions.length>0):Ke,[Ke,qe]);return(0,E.jsxs)(`div`,{"data-testid":`session-sidebar`,style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`hidden`},children:[O&&(0,E.jsx)(T7,{busy:ee,error:M,onCancel:()=>{k(!1),P(null)},onSelect:e=>void Ae(e)}),(0,E.jsxs)(N7,{title:g(`sidebar.workspace`),open:!0,onToggle:()=>{},collapsible:!1,testId:`workspace-scroll`,hintTestId:`workspace`,scrollStyle:{flex:`1 1 auto`,minHeight:80,background:`var(--bg)`},style:{flex:1,minHeight:0},actions:(0,E.jsx)(E7,{items:[{key:`search`,testId:`workspace-search-toggle`,onClick:()=>{ie&&I(``),ae(e=>!e)},title:g(`sidebar.searchSessions`),ariaPressed:ie,color:ie?`var(--accent)`:`var(--text-muted)`,background:ie?`var(--bg-selected)`:void 0,icon:(0,E.jsx)(Hr,{size:p.lg})},{key:`new-workspace`,testId:`new-workspace`,onClick:()=>k(!0),title:g(`sidebar.newWorkspace`),color:`var(--text-muted)`,icon:(0,E.jsx)(xr,{size:p.xl})},{key:`refresh`,testId:`session-refresh`,onClick:()=>Te(!1,!0),title:g(`sidebar.refresh`),skipHover:se,color:se?`var(--status-success)`:`var(--text-muted)`,background:se?`color-mix(in srgb, var(--status-success) 18%, transparent)`:void 0,icon:se?(0,E.jsx)(ur,{size:p.xl,color:`var(--status-success)`,strokeWidth:2.5}):(0,E.jsx)(Rr,{size:p.xl})}]}),headerExtra:(0,E.jsxs)(E.Fragment,{children:[ie&&(0,E.jsxs)(`div`,{"data-testid":`workspace-search`,style:{display:`flex`,alignItems:`center`,gap:4,width:`100%`,minWidth:0,padding:`4px 8px`,background:`var(--bg)`,borderBottom:`1px solid var(--border)`,boxSizing:`border-box`},children:[(0,E.jsx)(Hr,{size:p.lg,color:`var(--text-muted)`,style:{flexShrink:0}}),(0,E.jsx)(`input`,{ref:L,value:oe,onChange:e=>I(e.target.value),placeholder:g(`sidebar.searchSessionsPlaceholder`),"aria-label":g(`sidebar.searchSessions`),style:{flex:1,minWidth:0,background:`transparent`,border:`none`,outline:`none`,color:`var(--text)`,fontSize:`var(--text-sm)`}}),oe&&(0,E.jsx)(`button`,{type:`button`,onClick:()=>{I(``),L.current?.focus()},"aria-label":g(`chat.clearSearch`),style:{border:`none`,background:`transparent`,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-sm)`,flexShrink:0,padding:0},children:`✕`})]}),Ue&&(0,E.jsx)(H7,{wt:te,selectedCwd:C,homeDir:T,setSelectedCwd:w}),We&&(0,E.jsxs)(`button`,{type:`button`,"aria-disabled":`true`,tabIndex:-1,title:We.title,style:{width:`100%`,height:29,boxSizing:`border-box`,marginTop:6,display:`flex`,alignItems:`center`,gap:6,padding:`0 10px`,border:`1px solid var(--border)`,borderRadius:7,background:`var(--bg-hover)`,color:`var(--text-dim)`,fontSize:`var(--text-sm)`,lineHeight:1.35,whiteSpace:`nowrap`,textAlign:`left`,cursor:`default`,opacity:.82},children:[(0,E.jsxs)(`svg`,{width:p.sm,height:p.sm,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,E.jsx)(`line`,{x1:`6`,y1:`3`,x2:`6`,y2:`15`}),(0,E.jsx)(`circle`,{cx:`18`,cy:`6`,r:`3`}),(0,E.jsx)(`circle`,{cx:`6`,cy:`18`,r:`3`}),(0,E.jsx)(`path`,{d:`M18 9a9 9 0 0 1-9 9`})]}),(0,E.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`},children:We.label})]})]}),children:[y&&(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`16px 14px`,color:`var(--text-muted)`,fontSize:`var(--text-base)`},children:[(0,E.jsx)(`div`,{style:{width:14,height:14,border:`2px solid var(--border)`,borderTopColor:`var(--text-dim)`,borderRadius:`50%`,animation:`spin 0.8s linear infinite`,flexShrink:0}}),g(`sidebar.loading`)]}),x&&(0,E.jsx)(`div`,{style:{padding:`12px 14px`,color:`var(--status-error)`,fontSize:`var(--text-base)`},children:x}),!y&&!x&&qe&&Je.length===0&&(0,E.jsx)(`div`,{style:{padding:`16px 14px`,color:`var(--text-muted)`,fontSize:`var(--text-base)`},children:g(`sidebar.searchSessionsNoResults`)}),Je.map(t=>{let n=t.sessions.some(t=>t.id===e)||t.root===Ve;return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(e9,{group:t,groupSelected:n,hoveredGroup:Fe,confirmDeleteGroup:Le,deletingGroup:ze,runningSessionIds:he,interactionBadges:me,collapsed:!!Ne[t.root],setHoveredGroup:Ie,setGroupCollapsed:Pe,setConfirmDeleteGroup:Re,handleDeleteGroup:Ge,handleNewSession:Me,copyText:vY}),(qe||!Ne[t.root])&&(t.sessions.length===0?(0,E.jsx)(`div`,{style:{padding:`10px 14px`,color:`var(--text-muted)`,fontSize:`var(--text-sm)`},children:g(`sidebar.noSessions`)}):Q7(t.sessions).map(t=>(0,E.jsx)(t9,{node:t,selectedSessionId:e,runningSessionIds:he,runningPhases:ge,runningPhaseSince:_e,runningBusySince:ve,unreadSessionIds:fe,seenSessionIds:ce,interactionBadges:me,onSelectSession:je,onRenamed:()=>Te(!1,!0),onSessionDeleted:e=>{c?.(e),Te(!1,!0)},onUnseen:de,depth:0},t.session.id)))]},t.root)})]})]})}function e9({group:e,groupSelected:t,hoveredGroup:n,confirmDeleteGroup:r,deletingGroup:i,runningSessionIds:a,interactionBadges:o,collapsed:s,setHoveredGroup:c,setGroupCollapsed:l,setConfirmDeleteGroup:u,handleDeleteGroup:d,handleNewSession:f,copyText:m}){let{t:h}=N(),g=e.sessions.some(e=>a.has(e.id)),_=e.sessions.some(e=>o.has(e.id));return(0,E.jsx)(`div`,{"data-testid":`workspace-group-header`,onMouseEnter:()=>c(e.root),onMouseLeave:()=>c(null),style:{display:`flex`,alignItems:`center`,gap:4,height:40,padding:`0 2px`,boxSizing:`border-box`,fontSize:`var(--text-base)`,fontFamily:`var(--font-mono)`,color:`var(--text)`,fontWeight:600,textTransform:`none`,letterSpacing:.6,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,cursor:r===e.root?`default`:`pointer`,background:r===e.root?`color-mix(in srgb, var(--status-error) 6%, transparent)`:n===e.root?`var(--bg-hover)`:`var(--bg)`},onClick:r===e.root?void 0:()=>{l(t=>({...t,[e.root]:!t[e.root]}))},children:r===e.root?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`span`,{style:{flex:1,minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:h(`sidebar.deleteWorkspace`,{count:e.sessions.length})}),(0,E.jsxs)(`div`,{style:{display:`flex`,gap:5,flexShrink:0},children:[(0,E.jsx)(`button`,{onClick:t=>{t.stopPropagation(),d(e)},disabled:i,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:4,height:22,padding:`0 9px`,background:`var(--status-error)`,border:`none`,borderRadius:5,color:`var(--on-error)`,cursor:i?`default`:`pointer`,opacity:i?.6:1,fontSize:`var(--text-sm)`,fontWeight:600,whiteSpace:`nowrap`},children:h(`sidebar.delete`)}),(0,E.jsx)(`button`,{onClick:e=>{e.stopPropagation(),u(null)},disabled:i,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:22,padding:`0 9px`,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:5,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-sm)`,fontWeight:500,whiteSpace:`nowrap`},children:h(`sidebar.cancel`)})]})]}):(0,E.jsx)(E.Fragment,{children:(0,E.jsxs)(`div`,{style:{display:`inline-flex`,alignItems:`center`,gap:6,flex:1,minWidth:0,height:38,boxSizing:`border-box`,padding:`0 8px`,border:`none`,borderRadius:0,background:_&&s?`linear-gradient(90deg, transparent 13%, color-mix(in srgb, var(--status-warning) 30%, transparent) 25%, transparent 37%, transparent 63%, color-mix(in srgb, var(--status-warning) 60%, transparent) 75%, transparent 87%), linear-gradient(180deg, transparent calc(100% - 25px), color-mix(in srgb, var(--border) 25%, transparent) 100%)`:g&&s?`linear-gradient(90deg, transparent 13%, color-mix(in srgb, var(--accent) 18%, transparent) 25%, transparent 37%, transparent 63%, color-mix(in srgb, var(--shine-highlight) 50%, transparent) 75%, transparent 87%), linear-gradient(180deg, transparent calc(100% - 25px), color-mix(in srgb, var(--border) 25%, transparent) 100%)`:`linear-gradient(180deg, transparent calc(100% - 25px), color-mix(in srgb, var(--border) 25%, transparent) 100%)`,backgroundSize:(_||g)&&s?`200% 100%, auto`:void 0,animation:(_||g)&&s?`pi-status-shine 1.5s linear infinite`:void 0,boxShadow:`0 2px 8px var(--shadow-color)`,margin:`0 -2px`},children:[(0,E.jsxs)(`span`,{style:{position:`relative`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:30,height:22,flexShrink:0},children:[(0,E.jsx)(`svg`,{width:`30`,height:`22`,viewBox:`0 0 24 24`,fill:t?`color-mix(in srgb, var(--accent) 18%, transparent)`:`var(--bg)`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:t?`var(--accent)`:`var(--text-muted)`,opacity:.95},children:(0,E.jsx)(`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`})}),(0,E.jsx)(`span`,{style:{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -38%)`,color:`var(--text-muted)`,fontSize:`var(--text-xs)`,fontWeight:400,lineHeight:1,textAlign:`center`,fontVariantNumeric:`tabular-nums`,userSelect:`none`},children:e.sessions.length})]}),(0,E.jsx)(oi,{label:e.root,wrapperStyle:{flex:1,minWidth:0,overflow:`hidden`},children:(0,E.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,maxWidth:`100%`,lineHeight:`20px`},children:K7(e.root)})}),n===e.root&&(0,E.jsx)(E7,{items:[{key:`new-session`,onClick:t=>{t.stopPropagation(),f(e.root)},title:h(`sidebar.newSessionTitle`,{path:e.root}),icon:(0,E.jsx)(Ir,{size:p.base})},{key:`copy-path`,onClick:t=>{t.stopPropagation(),m(e.root)},title:h(`sidebar.copyPath`),icon:(0,E.jsx)(hr,{size:p.base})},{key:`delete-workspace`,onClick:t=>{t.stopPropagation(),u(e.root)},title:h(`sidebar.deleteWorkspaceTitle`),danger:!0,icon:(0,E.jsx)(Xr,{size:p.base})}]})]})})})}function t9({node:e,selectedSessionId:t,runningSessionIds:n,runningPhases:r,runningPhaseSince:i,runningBusySince:a,unreadSessionIds:o,seenSessionIds:s,interactionBadges:c,onSelectSession:l,onRenamed:u,onSessionDeleted:f,onUnseen:p,depth:m}){let[h,g]=(0,d.useState)(!1),_=e.children.length>0;return(0,E.jsxs)(`div`,{style:{paddingBottom:1,backgroundImage:`linear-gradient(90deg, transparent, var(--border), transparent)`,backgroundPosition:`0 100%`,backgroundSize:`100% 1px`,backgroundRepeat:`no-repeat`},children:[(0,E.jsxs)(`div`,{style:{position:`relative`},children:[m>0&&(0,E.jsx)(`div`,{style:{position:`absolute`,left:m*12+6,top:0,bottom:0,width:1,background:`var(--border)`,pointerEvents:`none`}}),(0,E.jsx)(i9,{session:e.session,isSelected:e.session.id===t,isRunning:n.has(e.session.id),phase:r[e.session.id],phaseSince:i[e.session.id],busySince:a[e.session.id],isUnread:o.has(e.session.id),isSeen:s.has(e.session.id),hasInteractionBadge:c.has(e.session.id),onClick:()=>l(e.session),onRenamed:u,onDeleted:e=>f?.(e),onUnseen:p,depth:m,hasChildren:_,collapsed:h,onToggleCollapse:()=>g(e=>!e)})]}),_&&!h&&(0,E.jsx)(`div`,{children:e.children.map(e=>(0,E.jsx)(t9,{node:e,selectedSessionId:t,runningSessionIds:n,runningPhases:r,runningPhaseSince:i,runningBusySince:a,unreadSessionIds:o,seenSessionIds:s,interactionBadges:c,onSelectSession:l,onRenamed:u,onSessionDeleted:f,onUnseen:p,depth:m+1},e.session.id))})]})}function n9(){let{t:e}=N();return(0,E.jsx)(`span`,{title:e(`sidebar.newActivity`),"aria-label":e(`sidebar.newSessionActivity`),style:{width:14,height:14,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,color:`var(--accent)`},children:(0,E.jsxs)(`svg`,{width:p.xl,height:p.xl,viewBox:`0 0 14 14`,fill:`none`,"aria-hidden":`true`,style:{display:`block`},children:[(0,E.jsx)(`circle`,{cx:`7`,cy:`7`,r:`2.5`,fill:`currentColor`}),(0,E.jsx)(`circle`,{cx:`7`,cy:`7`,r:`3`,stroke:`currentColor`,strokeWidth:`1.4`,opacity:`0.32`,style:{transformOrigin:`center`,animation:`session-ring-pulse 1.6s ease-in-out infinite`}})]})})}function r9(){let{t:e}=N();return(0,E.jsx)(`span`,{title:e(`sidebar.interactionBadge`),"aria-label":e(`sidebar.interactionBadge`),"data-testid":`interaction-badge`,style:{width:14,height:14,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,color:`var(--status-warning)`,animation:`interaction-badge-blink 1s ease-in-out infinite`},children:(0,E.jsxs)(`svg`,{width:p.xl,height:p.xl,viewBox:`0 0 14 14`,fill:`none`,"aria-hidden":`true`,style:{display:`block`},children:[(0,E.jsx)(`circle`,{cx:`7`,cy:`7`,r:`2.5`,fill:`currentColor`}),(0,E.jsx)(`circle`,{cx:`7`,cy:`7`,r:`3`,stroke:`currentColor`,strokeWidth:`1.4`,opacity:`0.32`,style:{transformOrigin:`center`,animation:`session-ring-pulse 1.6s ease-in-out infinite`}})]})})}function i9({session:e,isSelected:t,isRunning:n,phase:r,phaseSince:i,busySince:a,isUnread:o,isSeen:s=!0,hasInteractionBadge:c=!1,onClick:l,onRenamed:u,onDeleted:f,onUnseen:m,depth:h=0,hasChildren:g=!1,collapsed:_=!1,onToggleCollapse:v}){let{t:y}=N(),b=qt(!!(n&&r),i),x=qt(!!n,a),[S,C]=(0,d.useState)(!1),[w,T]=(0,d.useState)(!1),[D,O]=(0,d.useState)(``),[k,A]=(0,d.useState)(!1),[j,M]=(0,d.useState)(!1),P=(0,d.useRef)(null),ee=e.error?e.path.split(/[\\/]/).pop()||e.id:e.name||e.firstMessage.slice(0,50)||e.id.slice(0,12),F=(0,d.useCallback)(t=>{t.stopPropagation(),O(e.name??``),T(!0),setTimeout(()=>P.current?.select(),0)},[e.name]),te=(0,d.useCallback)(async()=>{let t=D.trim();if(T(!1),t!==(e.name??``))try{await fetch(`/api/sessions/${encodeURIComponent(e.id)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:t})}),u?.()}catch{}},[D,e.id,e.name,u]),ne=(0,d.useCallback)(async()=>{A(!1),M(!0);try{await fetch(`/api/sessions/${encodeURIComponent(e.id)}`,{method:`DELETE`}),f?.(e.id)}catch{M(!1)}},[e.id,f]),re=(0,d.useCallback)(e=>{e.stopPropagation(),e.shiftKey?ne():A(!0)},[ne]),ie=(0,d.useCallback)(e=>{e.stopPropagation(),ne()},[ne]),ae=(0,d.useCallback)(e=>{e.stopPropagation(),A(!1)},[]);return(0,E.jsx)(`div`,{"data-testid":`session-item`,"data-session-id":e.id,onClick:k||w?void 0:l,onMouseEnter:()=>C(!0),onMouseLeave:()=>{C(!1)},style:{height:54,display:`flex`,alignItems:`center`,paddingLeft:h>0?h*12+14:14,paddingRight:8,cursor:k||w?`default`:`pointer`,backgroundColor:k?`color-mix(in srgb, var(--status-error) 6%, transparent)`:S?`var(--bg-hover)`:`transparent`,transition:`background 0.1s`,opacity:j?.5:1,gap:6,overflow:`hidden`},className:t&&!k?`row-selected-gradient`:void 0,children:k?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--text)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:ee}),(0,E.jsxs)(`div`,{style:{marginTop:2,display:`flex`,alignItems:`center`,gap:8,color:`var(--text-dim)`,fontSize:`var(--text-sm)`,minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:[e.error?(0,E.jsx)(J7,{session:e}):(0,E.jsx)(`span`,{title:e.modified,children:U7(e.modified,y)}),(0,E.jsx)(`span`,{children:y(`sidebar.messagesCount`,{count:e.messageCount})})]})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,gap:5,flexShrink:0},children:[(0,E.jsxs)(`button`,{onClick:ie,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:4,height:30,padding:`0 11px`,background:`var(--status-error)`,border:`none`,borderRadius:6,color:`var(--on-error)`,cursor:`pointer`,fontSize:`var(--text-base)`,fontWeight:600,whiteSpace:`nowrap`},children:[(0,E.jsx)(Xr,{size:p.base}),y(`sidebar.delete`)]}),(0,E.jsx)(`button`,{onClick:ae,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:30,padding:`0 11px`,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:6,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-base)`,fontWeight:500,whiteSpace:`nowrap`},children:y(`sidebar.cancel`)})]})]}):w?(0,E.jsx)(`input`,{ref:P,value:D,onChange:e=>O(e.target.value),onBlur:te,onKeyDown:e=>{e.key===`Enter`&&te(),e.key===`Escape`&&T(!1)},autoFocus:!0,style:{flex:1,fontSize:`var(--text-base)`,padding:`5px 8px`,border:`1px solid var(--accent)`,borderRadius:5,outline:`none`,background:`var(--bg)`,color:`var(--text)`,height:30}}):(0,E.jsxs)(E.Fragment,{children:[h>0&&(0,E.jsxs)(`svg`,{width:p.xs,height:p.xs,viewBox:`0 0 24 24`,fill:`none`,stroke:`var(--text-dim)`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,E.jsx)(`line`,{x1:`6`,y1:`3`,x2:`6`,y2:`15`}),(0,E.jsx)(`circle`,{cx:`18`,cy:`6`,r:`3`}),(0,E.jsx)(`circle`,{cx:`6`,cy:`18`,r:`3`}),(0,E.jsx)(`path`,{d:`M18 9a9 9 0 0 1-9 9`})]}),(0,E.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,E.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:5,minWidth:0,fontSize:`var(--text-base)`,fontWeight:t?600:400,lineHeight:1.4,color:s?`var(--text)`:`var(--text-dim)`},title:ee,children:(0,E.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,minWidth:0},children:ee})}),(0,E.jsxs)(`div`,{style:{marginTop:2,display:`flex`,alignItems:`center`,gap:8,color:`var(--text-dim)`,fontSize:`var(--text-sm)`,minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:[e.error?(0,E.jsx)(J7,{session:e}):c?(0,E.jsx)(r9,{}):n?(0,E.jsx)(JJ,{phase:r??{kind:`running_command`},elapsed:b,totalElapsed:x}):o?(0,E.jsx)(n9,{}):(0,E.jsx)(`span`,{title:e.modified,children:U7(e.modified,y)}),!e.error&&n?null:(0,E.jsx)(`span`,{children:y(`sidebar.messagesCount`,{count:e.messageCount})}),e.worktreeBranch&&(0,E.jsxs)(`span`,{title:`Worktree: ${e.cwd}`,style:{display:`flex`,alignItems:`center`,gap:3,color:`var(--accent)`,minWidth:0,overflow:`hidden`},children:[(0,E.jsxs)(`svg`,{width:`9`,height:`9`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,E.jsx)(`line`,{x1:`6`,y1:`3`,x2:`6`,y2:`15`}),(0,E.jsx)(`circle`,{cx:`18`,cy:`6`,r:`3`}),(0,E.jsx)(`circle`,{cx:`6`,cy:`18`,r:`3`}),(0,E.jsx)(`path`,{d:`M18 9a9 9 0 0 1-9 9`})]}),(0,E.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.worktreeBranch})]})]})]}),g&&(0,E.jsx)(oi,{label:_?`Expand forks`:`Collapse forks`,children:(0,E.jsx)(`button`,{onClick:e=>{e.stopPropagation(),v?.()},style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:20,height:20,padding:0,flexShrink:0,background:`none`,border:`none`,color:`var(--text-dim)`,cursor:`pointer`,transform:_?`rotate(-90deg)`:`none`,transition:`transform 0.15s`},children:(0,E.jsx)(`svg`,{width:p.xs,height:p.xs,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,E.jsx)(`polyline`,{points:`2 3.5 5 6.5 8 3.5`})})})}),(0,E.jsx)(E7,{visible:S,items:[...s&&m?[{key:`unseen`,onClick:t=>{t.stopPropagation(),m(e.id)},title:y(`sidebar.disconnect`)||`断开`,icon:(0,E.jsx)(Qr,{size:p.base})}]:[],{key:`copy-path`,onClick:t=>{t.stopPropagation(),vY(e.path)},title:y(`sidebar.copyPath`),icon:(0,E.jsx)(hr,{size:p.base})},{key:`rename`,onClick:F,title:y(`sidebar.rename`),icon:(0,E.jsx)(Pr,{size:p.xl})},{key:`delete`,testId:`session-delete`,onClick:re,title:y(`sidebar.deleteWithShiftClick`),danger:!0,icon:(0,E.jsx)(Xr,{size:p.xl})}]})]})})}function a9(){let{t:e}=N(),t=(0,d.useSyncExternalStore)(bx,xx,xx);if(t.length===0)return null;let n=t[t.length-1],r=t.length;return(0,E.jsx)(jc,{open:!0,onOpenChange:()=>{},children:(0,E.jsxs)(Fc,{children:[(0,E.jsx)(Lc,{style:{position:`fixed`,inset:0,zIndex:1200,background:`rgba(0, 0, 0, 0.45)`}}),(0,E.jsxs)(Vc,{role:`alertdialog`,"aria-modal":`true`,onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),style:{position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,zIndex:1200,maxWidth:480,width:`calc(100% - 48px)`,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:10,padding:`16px 20px`,boxShadow:`0 8px 32px rgba(0, 0, 0, 0.35)`},children:[(0,E.jsxs)(Kc,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:10,fontSize:`var(--text-base)`,fontWeight:600,color:`var(--text)`},children:[(0,E.jsx)(`span`,{style:{color:`var(--status-error)`},children:`⚠`}),(0,E.jsx)(`span`,{children:r>1?e(`errors.titleCount`,{count:r}):e(`errors.title`)})]}),(0,E.jsx)(Jc,{asChild:!0,children:(0,E.jsx)(`div`,{children:n.kind===`api`?(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:6},children:[(0,E.jsxs)(`span`,{style:{fontSize:`var(--text-xs)`,padding:`1px 8px`,borderRadius:999,background:`color-mix(in srgb, var(--status-error) 14%, transparent)`,color:`var(--status-error)`,fontWeight:600,whiteSpace:`nowrap`},children:[`HTTP `,n.status||`ERR`]}),n.context&&(0,E.jsx)(`span`,{style:{fontSize:`var(--text-xs)`,color:`var(--text-dim)`},children:n.context})]}),(0,E.jsx)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text)`,wordBreak:`break-word`},children:n.message})]}):(0,E.jsxs)(`div`,{children:[n.context&&(0,E.jsx)(`div`,{style:{fontSize:`var(--text-xs)`,color:`var(--text-dim)`,marginBottom:6},children:n.context}),(0,E.jsx)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text)`,wordBreak:`break-word`},children:n.message})]})})}),(0,E.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8,marginTop:16},children:[r>1&&(0,E.jsx)(`button`,{type:`button`,onClick:Cx,style:{border:`1px solid var(--border)`,background:`none`,color:`var(--text-muted)`,borderRadius:6,padding:`4px 12px`,fontSize:`var(--text-sm)`,cursor:`pointer`},children:e(`errors.clearAll`)}),(0,E.jsx)(`button`,{type:`button`,onClick:Sx,style:{border:`none`,background:`var(--accent)`,color:`#fff`,borderRadius:6,padding:`4px 14px`,fontSize:`var(--text-sm)`,cursor:`pointer`},children:e(`errors.close`)})]})]})]})})}var o9=[],s9=1,c9=new Set;function l9(){for(let e of c9)e()}function u9(e){return c9.add(e),()=>{c9.delete(e)}}function d9(){return o9}function f9(e){let t={id:s9++,label:e??``};o9=[...o9,t],l9();let n=!1;return()=>{n||(n=!0,o9=o9.filter(e=>e.id!==t.id),l9())}}var p9=new WeakMap;function m9(e){if(!e.isConnected)return()=>{};let t=p9.get(e);if(!t){let n=document.createElement(`div`);n.style.cssText=`position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb, var(--bg) 50%, transparent);z-index:5;`,n.innerHTML=`<div style="width:16px;height:16px;border:2px solid var(--border);border-top-color:var(--text-dim);border-radius:50%;animation:spin 0.8s linear infinite;"></div>`;let r=null;getComputedStyle(e).position===`static`&&(r=e.style.position,e.style.position=`relative`),e.appendChild(n),t={count:0,el:n,prevPosition:r},p9.set(e,t)}t.count++;let n=!1;return()=>{n||(n=!0,t.count--,t.count<=0&&(t.el.remove(),t.prevPosition!==null&&(t.prevPosition?e.style.position=t.prevPosition:e.style.removeProperty(`position`)),p9.delete(e)))}}async function h9(e){try{return await e.json()}catch{return null}}async function g9(e,t,n){let r=n?.loading??`fullscreen`,i=r===`fullscreen`?f9(n?.label):r instanceof HTMLElement?m9(r):null;try{let n;try{n=await fetch(e,t)}catch(e){throw new px(e instanceof Error?e.message:`Network error`,0)}if(!n.ok){let e=await h9(n);throw new px(e&&typeof e==`object`&&`error`in e&&typeof e.error==`string`?e.error:`HTTP ${n.status}`,n.status,e)}let r=await n.text();return r?JSON.parse(r):void 0}catch(e){throw e instanceof px?e:new px(e instanceof Error?e.message:String(e),0)}finally{i?.()}}var _9=3;function v9(){let{t:e}=N(),t=(0,d.useSyncExternalStore)(u9,d9,d9);if(t.length===0)return null;let n=t.slice(0,_9),r=t.length-n.length;return(0,E.jsx)(`div`,{"aria-busy":`true`,style:{position:`fixed`,inset:0,zIndex:1150,background:`color-mix(in srgb, var(--bg) 40%, transparent)`,display:`flex`,alignItems:`center`,justifyContent:`center`,pointerEvents:`none`},children:(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10,minWidth:220,maxWidth:`60vw`,padding:`14px 18px`,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:`var(--radius)`,boxShadow:`0 8px 32px rgba(0,0,0,0.25)`},children:[n.map(t=>(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,fontSize:`var(--text-sm)`,color:`var(--text)`},children:[(0,E.jsx)(`div`,{style:{width:14,height:14,flexShrink:0,border:`2px solid var(--border)`,borderTopColor:`var(--accent)`,borderRadius:`50%`,animation:`spin 0.8s linear infinite`}}),(0,E.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:t.label||e(`loading.inProgress`)})]},t.id)),r>0&&(0,E.jsx)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-dim)`},children:e(`loading.more`,{count:r})})]})})}var y9={};function b9(e,t){return e===`Not found`?t(`files.notFound`):e===`Access denied`?t(`files.accessDenied`):e}async function x9(e,t){return((await g9(`/api/files/${vG(e)}?type=list`,void 0,t)).entries??[]).map(t=>({name:t.name,fullPath:SG(e,t.name),isDir:t.isDir,size:t.size,children:t.isDir?[]:void 0,loaded:!t.isDir}))}async function S9(e,t){return g9(`/api/git/status?${new URLSearchParams({cwd:e}).toString()}`,void 0,t)}var C9={modified:`files.modified`,added:`files.added`,deleted:`files.deleted`,renamed:`files.renamed`,untracked:`files.untracked`,conflict:`files.conflict`},w9={modified:`var(--status-warning)`,added:`var(--status-success)`,deleted:`var(--status-error)`,renamed:`var(--accent)`,untracked:`var(--status-success)`,conflict:`var(--status-error)`};function T9({status:e,t}){return(0,E.jsx)(`span`,{title:t(C9[e.status]),"aria-label":t(C9[e.status]),style:{width:14,height:14,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,color:w9[e.status],fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,fontWeight:600},children:e.code})}function E9(e,t,n,r){return new Promise((i,a)=>{let o=new FormData;t.forEach(e=>o.append(`files`,e,e.name));let s=new XMLHttpRequest;s.open(`POST`,`/api/files/${vG(e)}?type=upload&conflict=${n}`),s.upload.onprogress=e=>{e.lengthComputable&&e.total>0&&r(Math.round(e.loaded/e.total*100))},s.onerror=()=>a(Error(`Network error while uploading files`)),s.onabort=()=>a(Error(`Upload cancelled`)),s.onload=()=>{let e={};try{e=JSON.parse(s.responseText)}catch{s.responseText&&(e.error=s.responseText)}i({status:s.status,data:e})},s.send(o)})}function D9({size:e=11}){return(0,E.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,E.jsx)(`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`})]})}function O9({onClick:e,title:t}){return(0,E.jsx)(oi,{label:t,children:(0,E.jsx)(`button`,{type:`button`,onClick:e,"aria-label":t,style:{width:24,height:24,padding:0,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,border:`none`,borderRadius:4,background:`none`,color:`var(--text-dim)`,cursor:`pointer`,"--hover-color":`var(--text-muted)`,"--hover-bg":`var(--bg-hover)`},className:`hover-shift`,children:(0,E.jsxs)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`m6 6 12 12`}),(0,E.jsx)(`path`,{d:`m18 6-12 12`})]})})})}function k9({node:e,depth:t,cwd:n,onOpenFile:r,onAtMention:i,expandedPaths:a,onToggleExpanded:o,refreshToken:s,highlightedPaths:c,gitStatusByPath:l,changedDirectoryPaths:u,t:f}){let m=a.has(e.fullPath),h=c.has(e.fullPath),g=_G(e.fullPath),_=l.get(g),v=e.isDir&&(_!==void 0||u.has(g)),[y,b]=(0,d.useState)(e.children??[]),[x,S]=(0,d.useState)(e.loaded??!1),[C,w]=(0,d.useState)(!1),T=(0,d.useCallback)(async(t=!1)=>{if(!(x&&!t))try{let t=await x9(e.fullPath,{loading:`silent`});b(t),S(!0)}catch{}},[x,e.fullPath]);(0,d.useEffect)(()=>{m&&x&&T(!0)},[s]);let D=(0,d.useCallback)(()=>{if(e.isDir){let t=!m;o(e.fullPath,t),t&&!x&&T()}else r(e.fullPath,e.name)},[e.isDir,e.fullPath,e.name,x,m,T,r,o]);return(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`div`,{onClick:D,onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),style:{position:`relative`,display:`flex`,alignItems:`center`,gap:4,paddingLeft:8+t*14,paddingRight:8,height:24,cursor:`pointer`,background:C?`var(--bg-hover)`:`transparent`,borderRadius:4,userSelect:`none`},children:[e.isDir&&(0,E.jsx)(`svg`,{width:p.xs,height:p.xs,viewBox:`0 0 10 10`,fill:`none`,stroke:`var(--text-dim)`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0,transform:m?`rotate(90deg)`:`none`,transition:`transform 0.1s`},children:(0,E.jsx)(`polyline`,{points:`3 2 7 5 3 8`})}),!e.isDir&&(0,E.jsx)(`span`,{style:{width:10,flexShrink:0}}),(0,E.jsx)(`span`,{style:{flexShrink:0,display:`flex`,alignItems:`center`},children:e.isDir?(0,E.jsx)(sn,{size:p.xl,open:m}):Fn(e.name,14)}),(0,E.jsx)(`span`,{style:{fontSize:`var(--text-base)`,color:`var(--text)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,flex:1},title:e.fullPath,children:e.name}),h&&(0,E.jsx)(`span`,{title:f(`files.newlyUploaded`),"aria-label":f(`files.newlyUploaded`),style:{width:14,height:14,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,E.jsx)(`span`,{style:{width:6,height:6,borderRadius:`50%`,background:`var(--accent)`}})}),!C&&!e.isDir&&_&&(0,E.jsx)(T9,{status:_,t:f}),!C&&v&&(0,E.jsx)(`span`,{title:f(`files.containsChangedFiles`),"aria-label":f(`files.containsChangedFiles`),style:{width:14,height:14,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,E.jsx)(`span`,{style:{width:6,height:6,borderRadius:`50%`,background:`var(--status-warning)`}})}),i&&C&&(0,E.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),i(xG(e.fullPath,n),e.isDir)},title:f(`files.insertPath`),style:{position:`absolute`,right:e.isDir?4:28,top:`50%`,transform:`translateY(-50%)`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:4,padding:`0 8px`,height:20,background:`var(--bg-panel)`,border:`1px solid var(--border)`,borderRadius:4,color:`var(--accent)`,cursor:`pointer`,fontSize:`var(--text-sm)`,fontWeight:600,whiteSpace:`nowrap`},children:[(0,E.jsx)(D9,{}),f(`files.mention`)]}),C&&!e.isDir&&(0,E.jsx)(`a`,{href:`/api/files/${vG(e.fullPath)}?type=download`,download:!0,onClick:e=>e.stopPropagation(),title:f(`files.download`),style:{position:`absolute`,right:4,top:`50%`,transform:`translateY(-50%)`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:4,padding:`0 5px`,height:20,background:`var(--bg-panel)`,border:`1px solid var(--border)`,borderRadius:4,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-sm)`,fontWeight:600,whiteSpace:`nowrap`,textDecoration:`none`},children:(0,E.jsxs)(`svg`,{width:p.sm,height:p.sm,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,E.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,E.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]})})]}),e.isDir&&m&&(0,E.jsxs)(`div`,{children:[y.map(e=>(0,E.jsx)(k9,{node:e,depth:t+1,cwd:n,onOpenFile:r,onAtMention:i,expandedPaths:a,onToggleExpanded:o,refreshToken:s,highlightedPaths:c,gitStatusByPath:l,changedDirectoryPaths:u,t:f},e.fullPath)),y.length===0&&x&&(0,E.jsx)(`div`,{style:{paddingLeft:8+(t+1)*14,fontSize:`var(--text-sm)`,color:`var(--text-dim)`,height:22,display:`flex`,alignItems:`center`},children:f(`files.empty`)})]})]})}function A9({status:e,cwd:t,onOpenFile:n,onStageToggle:r,unstage:i,t:a}){let[o,s]=(0,d.useState)(!1),c=yG(e.filePath),l=xG(e.filePath,t);return(0,E.jsxs)(`div`,{onClick:()=>n(e.filePath,c,{modeHint:`diff`}),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),title:e.filePath,style:{display:`flex`,alignItems:`center`,gap:6,paddingLeft:10,paddingRight:8,height:24,cursor:`pointer`,background:o?`var(--bg-hover)`:`transparent`,borderRadius:4,userSelect:`none`},children:[r!==void 0&&(0,E.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r(e)},"aria-label":a(i?`files.unstageFile`:`files.stageFile`),style:{width:16,height:16,padding:0,marginLeft:-4,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,border:`none`,borderRadius:4,background:`none`,color:`var(--text-dim)`,cursor:`pointer`,opacity:+!!o,"--hover-color":`var(--text-muted)`,"--hover-bg":`var(--bg-hover)`},className:`hover-shift`,children:(0,E.jsx)(`svg`,{width:p.sm,height:p.sm,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,"aria-hidden":`true`,children:i?(0,E.jsx)(`path`,{d:`M6 12h12`}):(0,E.jsx)(`path`,{d:`M12 5v14M5 12h14`})})}),(0,E.jsx)(T9,{status:e,t:a}),(0,E.jsx)(`span`,{style:{flexShrink:0,display:`flex`,alignItems:`center`,opacity:.85},children:Fn(c,13)}),(0,E.jsx)(`span`,{style:{fontSize:`var(--text-base)`,color:`var(--text)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,flex:1},children:l}),e.lineStats&&(e.lineStats.additions>0||e.lineStats.deletions>0)&&(0,E.jsxs)(`span`,{style:{flexShrink:0,display:`flex`,alignItems:`center`,gap:5,fontFamily:`var(--font-mono)`,fontSize:`var(--text-xs)`,fontVariantNumeric:`tabular-nums`},children:[e.lineStats.additions>0&&(0,E.jsxs)(`span`,{style:{color:`var(--status-success)`},children:[`+`,e.lineStats.additions]}),e.lineStats.deletions>0&&(0,E.jsxs)(`span`,{style:{color:`var(--status-error)`},children:[`-`,e.lineStats.deletions]})]})]})}function j9({message:e,onMessageChange:t,commitBusy:n,canCommit:r,onCommit:i,pushBusy:a,canPush:o,onPush:s,pullBusy:c,canPull:l,onPull:u,aiBusy:f,canAiGenerate:m,onAiGenerate:h,autoGenerateOnEmpty:g,hasModelForAuto:_,aiModelHint:v,t:y}){let b=(0,d.useRef)(null),x=e.trim()===``,S=x&&g&&_&&m&&!f,C=n||!S&&x||!r;return(0,d.useLayoutEffect)(()=>{let e=b.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,120)}px`)},[e]),(0,E.jsx)(`div`,{style:{display:`flex`,padding:`4px 2px 6px`},children:(0,E.jsxs)(`div`,{style:{position:`relative`,display:`flex`,flexDirection:`column`,flex:1,minWidth:0,backgroundColor:`var(--bg)`,backgroundImage:n||f||a||c?`linear-gradient(90deg, transparent 13%, color-mix(in srgb, var(--accent) 18%, transparent) 25%, transparent 37%, transparent 63%, color-mix(in srgb, var(--shine-highlight) 50%, transparent) 75%, transparent 87%)`:void 0,backgroundSize:n||f||a||c?`200% 100%`:void 0,animation:n||f||a||c?`pi-status-shine 1.5s linear infinite`:void 0,borderRadius:6,border:`1px solid var(--border)`},children:[(0,E.jsx)(`textarea`,{ref:b,value:e,disabled:n||f||a||c,placeholder:f?v?`${y(`git.ai.generating`)}(${v})`:y(`git.ai.generating`):y(`files.commitMessagePlaceholder`),onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),C||i())},rows:1,style:{flex:`0 1 auto`,minWidth:0,resize:`none`,boxSizing:`content-box`,overflowY:`auto`,maxHeight:120,fontSize:`var(--text-base)`,lineHeight:1.4,padding:`4px 6px`,color:n||f||a||c?`var(--text-dim)`:`var(--text)`,background:`transparent`,border:`none`,borderRadius:6,outline:`none`}}),(0,E.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:4,padding:`2px 6px 4px`},children:[(0,E.jsx)(oi,{label:(()=>{let e=y(f?`git.ai.generating`:`git.ai.generate`);return v?`${e}(${v})`:e})(),children:(0,E.jsx)(`button`,{onClick:h,disabled:f||!m||n||a||c,"aria-label":y(`git.ai.generate`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:36,height:30,padding:0,flexShrink:0,background:`none`,border:`1px solid transparent`,borderRadius:6,color:f||!m||n||a||c?`var(--text-dim)`:`var(--accent)`,cursor:f||!m||n||a||c?`default`:`pointer`},children:f?(0,E.jsx)(Ar,{size:p.lg,style:{animation:`spin 0.8s linear infinite`}}):(0,E.jsx)(Kr,{size:p.lg})})}),(0,E.jsx)(oi,{label:n?y(`files.committing`):C&&x&&!S?y(`files.commitMessageRequired`):S?`${y(`git.ai.generateAndCommit`)} (Ctrl+Enter)`:`${y(`files.commit`)} (Ctrl+Enter)`,children:(0,E.jsx)(`button`,{onClick:i,disabled:C||c,"aria-label":y(`files.commit`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:36,height:30,padding:0,flexShrink:0,background:`none`,border:`1px solid transparent`,borderRadius:6,color:C||c?`var(--text-dim)`:`var(--accent)`,cursor:C||c?`default`:`pointer`},children:n?(0,E.jsx)(Ar,{size:p[`2xl`],style:{animation:`spin 0.8s linear infinite`}}):(0,E.jsx)(Cr,{size:p[`2xl`]})})}),(0,E.jsx)(oi,{label:y(a?`files.pushing`:o?`files.push`:`files.pushUpToDate`),children:(0,E.jsx)(`button`,{onClick:s,disabled:a||n||c||!o,"aria-label":y(`files.push`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:36,height:30,padding:0,flexShrink:0,background:`none`,border:`1px solid transparent`,borderRadius:6,color:a||n||c||!o?`var(--text-dim)`:`var(--accent)`,cursor:a||n||c||!o?`default`:`pointer`},children:a?(0,E.jsx)(Ar,{size:p.lg,style:{animation:`spin 0.8s linear infinite`}}):(0,E.jsx)(mr,{size:p[`2xl`]})})}),(0,E.jsx)(oi,{label:y(c?`files.pulling`:l?`files.pull`:`files.pullUpToDate`),children:(0,E.jsx)(`button`,{onClick:u,disabled:c||n||a||!l,"aria-label":y(`files.pull`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:36,height:30,padding:0,flexShrink:0,background:`none`,border:`1px solid transparent`,borderRadius:6,color:c||n||a||!l?`var(--text-dim)`:`var(--accent)`,cursor:c||n||a||!l?`default`:`pointer`},children:c?(0,E.jsx)(Ar,{size:p.lg,style:{animation:`spin 0.8s linear infinite`}}):(0,E.jsx)(pr,{size:p[`2xl`]})})})]})]})})}function M9({prefix:e,count:t,additions:n,deletions:r,t:i}){return(0,E.jsxs)(`div`,{"aria-label":i(`files.changeStats`,{count:t,additions:n,deletions:r}),style:{display:`flex`,alignItems:`center`,gap:6,height:24,padding:`0 10px`,fontSize:`var(--text-base)`},children:[e&&(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`},children:e}),(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`},children:i(`files.changedCount`,{count:t})}),(0,E.jsxs)(`span`,{style:{color:w9.added,fontFamily:`var(--font-mono)`},children:[`+`,n]}),(0,E.jsxs)(`span`,{style:{color:w9.deleted,fontFamily:`var(--font-mono)`},children:[`-`,r]})]})}function N9({message:e,onDismiss:t}){let{t:n}=N();return(0,E.jsxs)(`div`,{role:`alert`,style:{display:`flex`,alignItems:`center`,gap:6,marginTop:4,padding:`6px 8px`,fontSize:`var(--text-sm)`,lineHeight:1.35,color:`var(--status-error)`,background:`var(--bg)`,border:`1px solid var(--status-error)`,borderRadius:6},children:[(0,E.jsx)(`span`,{style:{minWidth:0,flex:1,overflowWrap:`anywhere`,maxHeight:140,overflowY:`auto`,whiteSpace:`pre-wrap`},children:e}),(0,E.jsx)(O9,{onClick:t,title:n(`files.dismissError`)})]})}function P9({children:e}){return(0,E.jsx)(`div`,{style:{padding:`0 4px 2px`},children:e})}var F9=(0,d.forwardRef)(function({children:e},t){return(0,E.jsx)(`div`,{ref:t,style:{padding:`2px 4px`},children:e})}),I9=(0,d.forwardRef)(function({cwd:e,onOpenFile:t,refreshKey:n,searchQuery:r,onAtMention:i,onAtMentions:a,onUploadBusyChange:o,changesCollapsed:s,onChangesCountChange:c,sessionId:l,onOpenConfig:u},f){let{t:m}=N(),[h,g]=(0,d.useState)([]),[_,v]=(0,d.useState)(!0),[y,b]=(0,d.useState)(null),x=(0,d.useRef)(null),[S,C]=(0,d.useState)(new Set),[w,T]=(0,d.useState)(0),D=(r??``).trim().toLowerCase(),O=(0,d.useMemo)(()=>{if(!D)return h;function e(t){if(t.name.toLowerCase().includes(D))return t;if(t.isDir&&t.children){let n=t.children.map(e).filter(e=>e!==null);if(n.length>0)return{...t,children:n}}return null}return h.map(e).filter(e=>e!==null)},[h,D]),[k,A]=(0,d.useState)(new Set),[j,M]=(0,d.useState)([]),[P,ee]=(0,d.useState)({additions:0,deletions:0}),[F,te]=(0,d.useState)([]),[ne,re]=(0,d.useState)({additions:0,deletions:0}),ie=(0,d.useMemo)(()=>D?F.filter(t=>xG(t.filePath,e).toLowerCase().includes(D)):F,[F,D,e]),ae=(0,d.useMemo)(()=>D?j.filter(t=>xG(t.filePath,e).toLowerCase().includes(D)):j,[j,D,e]),[oe,I]=(0,d.useState)({branch:null,upstream:null,ahead:0,behind:0,hasUpstream:!1}),[L,se]=(0,d.useState)(null),[R,ce]=(0,d.useState)(``),[le,ue]=(0,d.useState)(!1),[de,fe]=(0,d.useState)(null),[pe,me]=(0,d.useState)(!1),[he,ge]=(0,d.useState)(!1),[_e,ve]=(0,d.useState)(null),[ye,xe]=(0,d.useState)(!1),[Ce,we]=(0,d.useState)(!1),Te=(0,d.useSyncExternalStore)(Se.subscribe,()=>Se.get()?.preferences??y9,()=>y9),Ee=(0,d.useSyncExternalStore)(be.subscribe,()=>be.get()),De=Te.commitMessageAutoGenerateOnEmpty!==!1,Oe=Te.commitStageAllConfirm!==!1,ke=Te.commitMessageUseCurrentModel===!0?!!(l||Ee?.defaultModel||(Ee?.modelList?.length??0)>0):!!(typeof Te.commitMessageModel==`string`&&Te.commitMessageModel),[Ae,je]=(0,d.useState)(!1),[Me,Ne]=(0,d.useState)(null),Pe=(0,d.useRef)(null),[Fe,Ie]=(0,d.useState)(!1),[Le,Re]=(0,d.useState)(null),[ze,Be]=(0,d.useState)(`idle`),[Ve,He]=(0,d.useState)(0),[Ue,We]=(0,d.useState)(null),[Ge,Ke]=(0,d.useState)(null),[qe,Je]=(0,d.useState)(null),Ye=(0,d.useRef)(null),Xe=(0,d.useRef)(null),Ze=`${n??0}:${w}`,Qe=ze!==`idle`,$e=(0,d.useMemo)(()=>new Map(j.map(e=>[_G(e.filePath),e])),[j]),et=(0,d.useMemo)(()=>{let t=new Set,n=_G(e).replace(/\/$/,``);for(let e of j){let r=bG(_G(e.filePath));for(;(r===n||r.startsWith(`${n}/`))&&(t.add(r),r!==n);){let e=bG(r);if(e===r)break;r=e}}return t},[e,j]),tt=(0,d.useCallback)((e,t)=>{C(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),nt=(0,d.useCallback)(t=>{let n=t.uploaded??[],r=t.skipped??[],i=t.errors??[];Ke({uploaded:n,skipped:r,errors:i}),n.length>0&&(A(new Set(n.map(t=>SG(e,t)))),T(e=>e+1))},[e]),rt=(0,d.useCallback)(async(t,n)=>{Je(null),We(null),He(0),Be(`uploading`);try{let{status:r,data:i}=await E9(e,t,n,He);if(r===409&&i.conflicts?.length){Je({files:t,conflicts:i.conflicts,nonReplaceable:i.nonReplaceable??[]});return}if(r<200||r>=300)throw Error(i.error??`Upload failed (HTTP ${r})`);He(100),nt(i)}catch(e){We(e instanceof Error?e.message:String(e))}finally{Be(`idle`)}},[nt,e]),it=(0,d.useCallback)(async t=>{if(!(t.length===0||Qe)){Ke(null),A(new Set),Je(null),We(null),He(0),Be(`checking`);try{let n=await g9(`/api/files/${vG(e)}?type=upload-check`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({fileNames:t.map(e=>e.name)})},{loading:`silent`});if(n.conflicts?.length){Je({files:t,conflicts:n.conflicts,nonReplaceable:n.nonReplaceable??[]});return}await rt(t,`error`)}catch(e){We(e instanceof Error?e.message:String(e))}finally{Be(`idle`)}}},[e,rt,Qe]),at=(0,d.useCallback)(e=>{let t=Array.from(e.target.files??[]);e.target.value=``,it(t)},[it]);(0,d.useImperativeHandle)(f,()=>({openUploadPicker(){Qe||Xe.current?.click()}}),[Qe]);let ot=(0,d.useCallback)(async()=>{je(!0);try{let t=await g9(`/api/git/push`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:e})},{loading:`silent`});console.info(`[git-push] ok:`,t.output||`(empty output)`),Ne({ok:!0,output:t.output??``})}catch(e){let t=e instanceof Error?e.message:String(e);console.info(`[git-push] failed:`,t),Ne({ok:!1,output:t})}finally{je(!1),T(e=>e+1)}},[e]),st=(0,d.useCallback)(async()=>{Ie(!0);try{let t=await g9(`/api/git/pull`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:e})},{loading:`silent`});console.info(`[git-pull] ok:`,t.output||`(empty output)`),Re({ok:!0,output:t.output??``})}catch(e){let t=e instanceof Error?e.message:String(e);console.info(`[git-pull] failed:`,t),Re({ok:!1,output:t})}finally{Ie(!1),T(e=>e+1)}},[e]);(0,d.useEffect)(()=>{if(Pe.current&&clearTimeout(Pe.current),Me)return Pe.current=setTimeout(()=>Ne(null),1e4),()=>{Pe.current&&clearTimeout(Pe.current)}},[Me]);let ct=(0,d.useRef)(null);(0,d.useEffect)(()=>{if(ct.current&&clearTimeout(ct.current),Le)return ct.current=setTimeout(()=>Re(null),1e4),()=>{ct.current&&clearTimeout(ct.current)}},[Le]),(0,d.useEffect)(()=>{o?.(Qe)},[o,Qe]),(0,d.useEffect)(()=>()=>o?.(!1),[o]),(0,d.useEffect)(()=>{let t=Ye.current!==e;Ye.current=e,t&&(C(new Set),A(new Set),Ke(null),Je(null),We(null)),b(null),v(t);let n=!1;return x9(e,{loading:`silent`}).then(e=>{n||g(e)}).catch(e=>{n||(b(e instanceof Error?e.message:String(e)),yx(e,`file explorer`))}).finally(()=>{n||v(!1)}),()=>{n=!0}},[e,n,w]),(0,d.useEffect)(()=>{let t=!1;return S9(e,{loading:`silent`}).then(e=>{if(!t){let t=e.isGitRepository;M(t?e.files:[]),ee(t?{additions:e.additions,deletions:e.deletions}:{additions:0,deletions:0}),te(t?e.stagedFiles:[]),re(t?{additions:e.stagedAdditions,deletions:e.stagedDeletions}:{additions:0,deletions:0}),I(t?{branch:e.branch??null,upstream:e.upstream??null,ahead:e.ahead??0,behind:e.behind??0,hasUpstream:e.hasUpstream??!1}:{branch:null,upstream:null,ahead:0,behind:0,hasUpstream:!1})}}).catch(()=>{t||(M([]),ee({additions:0,deletions:0}),te([]),re({additions:0,deletions:0}),I({branch:null,upstream:null,ahead:0,behind:0,hasUpstream:!1}))}),()=>{t=!0}},[e,n,w]);let lt=(0,d.useCallback)(async(t,n)=>{se(null);try{let r=await fetch(`/api/git/stage`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:e,filePath:t.filePath,action:n?`unstage`:`stage`})}),i=await r.json().catch(()=>({}));if(!r.ok)throw Error(i.error??`Git ${n?`unstage`:`stage`} failed (HTTP ${r.status})`);T(e=>e+1)}catch(e){se(e instanceof Error?e.message:String(e))}},[e]);(0,d.useEffect)(()=>{c?.(j.length+F.length)},[j,F,c]);let ut=(0,d.useCallback)(async(t,n)=>{let r=n??R;ue(!0),fe(null);try{let n=await fetch(`/api/git/commit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:e,message:r,stageAll:t})}),i=await n.json().catch(()=>({}));if(!n.ok)throw Error(i.error??`Commit failed (HTTP ${n.status})`);ce(``),fe(null),me(!1),T(e=>e+1)}catch(e){fe(e instanceof Error?e.message:String(e))}finally{ue(!1)}},[e,R]),dt=(0,d.useCallback)(async()=>{if(he||le||Ae||Ce)return null;let t=Se.get()?.preferences??{};if(Object.keys(t).length===0)try{await Se.refresh(),t=Se.get()?.preferences??{}}catch{}let n=t.commitMessageUseCurrentModel===!0,r=typeof t.commitMessageModel==`string`?t.commitMessageModel:``,i=``,a=``;if(n){if(l)try{let e=await g9(`/api/agent/${encodeURIComponent(l)}`),t=e.state?.model??e.model??null;if(t){let e=t;i=e.provider??``,a=e.id??e.modelId??``}if(!i||!a)try{let e=await g9(`/api/sessions/${encodeURIComponent(l)}/state`);e.model&&(i=e.model.provider,a=e.model.id)}catch{}}catch{}if(!i||!a)try{let e=be.get();if(!e?.defaultModel)try{await be.refresh(),e=be.get()}catch{}if(e?.defaultModel?.provider){let t=e.defaultModel;i=t.provider??``,a=t.modelId??t.id??``}if((!i||!a)&&e?.modelList?.[0]){let t=e.modelList[0];i=t.provider??``,a=t.modelId??t.id??``}}catch{}if(!i||!a)return ve(m(`git.ai.noSessionModel`)),null}else{if(!r)return xe(!0),null;let e=r.indexOf(`/`);if(e===-1||(i=r.slice(0,e),a=r.slice(e+1),!i||!a))return ve(m(`git.ai.invalidModel`)),null}let o=t.commitMessageMaxTokens,s=typeof o==`number`&&Number.isFinite(o)?Math.min(4096,Math.max(64,Math.round(o))):512;ge(!0),ve(null);try{let t=await fetch(`/api/git/generate-commit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:e,provider:i,modelId:a,maxTokens:s})}),n=await t.json().catch(()=>({}));if(!t.ok)throw Error(n.error??`Generate failed (HTTP ${t.status})`);if(!n.message)throw Error(`Empty response`);return ce(n.message),n.message}catch(e){return ve(e instanceof Error?e.message:String(e)),null}finally{ge(!1)}},[he,le,Ae,Ce,e,l,m]),ft=(0,d.useCallback)(async()=>{let t=await S9(e),n=t.isGitRepository;M(n?t.files:[]),ee(n?{additions:t.additions,deletions:t.deletions}:{additions:0,deletions:0}),te(n?t.stagedFiles:[]),re(n?{additions:t.stagedAdditions,deletions:t.stagedDeletions}:{additions:0,deletions:0}),I(n?{branch:t.branch??null,upstream:t.upstream??null,ahead:t.ahead??0,behind:t.behind??0,hasUpstream:t.hasUpstream??!1}:{branch:null,upstream:null,ahead:0,behind:0,hasUpstream:!1});let r=R.trim()===``,i=n?t.stagedFiles??[]:[],a=n?t.files??[]:[],o=i.length+a.length>0;if(r&&De&&ke&&o&&!he&&!le&&!Ae&&!Ce){we(!0);try{let e=await dt();if(!e)return;i.length>0?await ut(!1,e):Oe?me(!0):await ut(!0,e)}finally{we(!1)}return}i.length>0?ut(!1):Oe?me(!0):ut(!0)},[e,R,De,ke,Oe,he,le,Ae,Ce,dt,ut]),pt=Qe||qe!==null||Ue!==null||Ge!==null,mt=(0,d.useCallback)(()=>{!Ge||Ge.uploaded.length===0||a?.(Ge.uploaded.map(t=>xG(SG(e,t),e)))},[e,a,Ge]);return(0,E.jsxs)(`div`,{style:{minHeight:`100%`},children:[(0,E.jsx)(`input`,{ref:Xe,type:`file`,multiple:!0,hidden:!0,onChange:at}),pt&&(0,E.jsxs)(`div`,{style:{padding:`6px 8px`,borderBottom:`1px solid var(--border)`},children:[Qe&&(0,E.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-label":ze===`checking`?m(`files.checking`):m(`files.uploading`,{progress:Ve}),children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8,minHeight:14,color:`var(--text-muted)`},children:[ze===`checking`?(0,E.jsx)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,style:{animation:`spin 0.8s linear infinite`},"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M21 12a9 9 0 1 1-5.7-8.4`})}):(0,E.jsxs)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`M12 16V4`}),(0,E.jsx)(`path`,{d:`m7 9 5-5 5 5`}),(0,E.jsx)(`path`,{d:`M5 20h14`})]}),ze===`uploading`&&(0,E.jsxs)(`span`,{style:{fontSize:`var(--text-xs)`},children:[Ve,`%`]})]}),ze===`uploading`&&(0,E.jsx)(`div`,{style:{height:3,marginTop:4,overflow:`hidden`,borderRadius:2,background:`var(--border)`},children:(0,E.jsx)(`div`,{style:{width:`${Ve}%`,height:`100%`,background:`var(--text-muted)`,transition:`width 120ms ease`}})})]}),qe&&(0,E.jsxs)(`div`,{role:`alert`,style:{padding:7,border:`1px solid color-mix(in srgb, #f59e0b 55%, var(--border))`,borderRadius:4,background:`color-mix(in srgb, #f59e0b 9%, var(--bg-panel))`},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text)`,lineHeight:1.35,overflowWrap:`anywhere`},children:m(`files.conflictSummary`,{count:qe.conflicts.length,countSuffix:qe.conflicts.length===1?``:`s`,files:qe.conflicts.join(`, `)})}),qe.nonReplaceable.length>0&&(0,E.jsx)(`div`,{style:{marginTop:3,fontSize:`var(--text-xs)`,color:`#f59e0b`,lineHeight:1.35,overflowWrap:`anywhere`},children:m(`files.cannotReplace`,{files:qe.nonReplaceable.join(`, `)})}),(0,E.jsxs)(`div`,{style:{display:`flex`,gap:5,marginTop:7},children:[(0,E.jsx)(`button`,{type:`button`,onClick:()=>void rt(qe.files,`overwrite`),style:{height:22,padding:`0 7px`,border:`1px solid var(--status-error)`,borderRadius:4,background:`transparent`,color:`var(--status-error)`,cursor:`pointer`,fontSize:`var(--text-xs)`},children:m(`files.replace`)}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>void rt(qe.files,`skip`),style:{height:22,padding:`0 7px`,border:`1px solid var(--border)`,borderRadius:4,background:`var(--bg-panel)`,color:`var(--text)`,cursor:`pointer`,fontSize:`var(--text-xs)`},children:m(`files.skipExisting`)}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>Je(null),style:{height:22,padding:`0 7px`,border:`none`,borderRadius:4,background:`transparent`,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-xs)`},children:m(`files.cancel`)})]})]}),Ue&&(0,E.jsxs)(`div`,{role:`alert`,style:{display:`flex`,alignItems:`flex-start`,gap:6,fontSize:`var(--text-sm)`,lineHeight:1.35,color:`var(--status-error)`},children:[(0,E.jsx)(`span`,{style:{minWidth:0,flex:1,overflowWrap:`anywhere`},children:Ue}),(0,E.jsx)(O9,{onClick:()=>We(null),title:m(`files.dismissError`)})]}),Ge&&(0,E.jsxs)(`div`,{"aria-live":`polite`,children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,minHeight:22,fontSize:`var(--text-sm)`},children:[(0,E.jsxs)(`div`,{style:{minWidth:0,flex:1,display:`flex`,alignItems:`center`,gap:8},children:[Ge.uploaded.length>0&&(0,E.jsxs)(`span`,{title:`${Ge.uploaded.length} uploaded`,"aria-label":`${Ge.uploaded.length} uploaded`,style:{display:`flex`,alignItems:`center`,gap:3,color:`var(--status-success)`},children:[(0,E.jsx)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`m5 12 4 4L19 6`})}),(0,E.jsx)(`span`,{children:Ge.uploaded.length})]}),Ge.skipped.length>0&&(0,E.jsxs)(`span`,{title:`${Ge.skipped.length} skipped`,"aria-label":`${Ge.skipped.length} skipped`,style:{display:`flex`,alignItems:`center`,gap:3,color:`var(--text-dim)`},children:[(0,E.jsxs)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,E.jsx)(`path`,{d:`M8 12h8`})]}),(0,E.jsx)(`span`,{children:Ge.skipped.length})]}),Ge.errors.length>0&&(0,E.jsxs)(`span`,{title:m(`files.uploadFailed`,{count:Ge.errors.length}),"aria-label":m(`files.uploadFailed`,{count:Ge.errors.length}),style:{display:`flex`,alignItems:`center`,gap:3,color:`var(--status-error)`},children:[(0,E.jsxs)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`M12 3 2.5 20h19L12 3Z`}),(0,E.jsx)(`path`,{d:`M12 9v4`}),(0,E.jsx)(`path`,{d:`M12 17h.01`})]}),(0,E.jsx)(`span`,{children:Ge.errors.length})]})]}),Ge.uploaded.length>0&&a&&(0,E.jsxs)(`button`,{type:`button`,onClick:mt,title:Ge.uploaded.length===1?m(`files.addUploadedFile`):m(`files.addAllUploadedFiles`),"aria-label":Ge.uploaded.length===1?m(`files.addUploadedFile`):m(`files.addAllUploadedFiles`),style:{height:22,padding:`0 7px`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:4,flexShrink:0,border:`1px solid var(--border)`,borderRadius:4,background:`var(--bg-panel)`,color:`var(--accent)`,cursor:`pointer`,fontSize:`var(--text-sm)`,fontWeight:600,whiteSpace:`nowrap`},children:[(0,E.jsx)(D9,{}),m(`files.mention`)]}),(0,E.jsx)(O9,{onClick:()=>Ke(null),title:m(`files.dismissUploadResults`)})]}),Ge.errors.map(e=>(0,E.jsxs)(`div`,{title:e.error,style:{display:`flex`,alignItems:`center`,gap:4,marginTop:3,minWidth:0,fontSize:`var(--text-xs)`,color:`var(--status-error)`},children:[(0,E.jsxs)(`svg`,{width:p.sm,height:p.sm,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},"aria-hidden":`true`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,E.jsx)(`path`,{d:`M12 8v5`}),(0,E.jsx)(`path`,{d:`M12 17h.01`})]}),(0,E.jsx)(`span`,{style:{minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.name})]},e.name))]})]}),!s&&(0,E.jsxs)(P9,{children:[(0,E.jsx)(j9,{message:R,onMessageChange:ce,commitBusy:le||Ce,canCommit:F.length+j.length>0,onCommit:ft,pushBusy:Ae,canPush:oe.hasUpstream?oe.ahead>0:!!oe.branch&&oe.branch!==`HEAD`,onPush:ot,pullBusy:Fe,canPull:oe.hasUpstream&&oe.behind>0,onPull:st,aiBusy:he,canAiGenerate:F.length+j.length>0,onAiGenerate:()=>{ce(``),dt()},autoGenerateOnEmpty:De,hasModelForAuto:ke,aiModelHint:(()=>{if(Te.commitMessageUseCurrentModel===!0)return m(`git.ai.usingCurrentModel`);let e=typeof Te.commitMessageModel==`string`?Te.commitMessageModel:``;return e?m(`git.ai.usingModel`,{model:e}):``})(),t:m}),Me&&(0,E.jsxs)(`div`,{role:`status`,"aria-live":`polite`,style:{marginTop:4,padding:`6px 8px`,borderRadius:6,border:`1px solid ${Me.ok?`var(--status-success)`:`var(--status-error)`}`,background:`var(--bg)`,fontSize:`var(--text-sm)`,lineHeight:1.5},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,marginBottom:4},children:[(0,E.jsx)(`span`,{style:{width:7,height:7,borderRadius:`50%`,background:Me.ok?`var(--status-success)`:`var(--status-error)`,flexShrink:0}}),(0,E.jsx)(`span`,{style:{color:`var(--text-muted)`,flex:1,minWidth:0},children:m(Me.ok?`files.pushSuccess`:`files.pushFailed`)}),(0,E.jsx)(`button`,{onClick:()=>Ne(null),"aria-label":m(`files.dismissError`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:16,height:16,padding:0,background:`none`,border:`none`,borderRadius:4,color:`var(--text-dim)`,cursor:`pointer`,flexShrink:0},children:(0,E.jsx)(ni,{size:p.base})})]}),Me.output&&(0,E.jsx)(`pre`,{style:{margin:0,maxHeight:140,overflow:`auto`,whiteSpace:`pre-wrap`,wordBreak:`break-all`,color:Me.ok?`var(--text-muted)`:`var(--status-error)`,fontFamily:`var(--font-mono)`},children:Me.output})]}),Le&&(0,E.jsxs)(`div`,{role:`status`,"aria-live":`polite`,style:{marginTop:4,padding:`6px 8px`,borderRadius:6,border:`1px solid ${Le.ok?`var(--status-success)`:`var(--status-error)`}`,background:`var(--bg)`,fontSize:`var(--text-sm)`,lineHeight:1.5},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,marginBottom:4},children:[(0,E.jsx)(`span`,{style:{width:7,height:7,borderRadius:`50%`,background:Le.ok?`var(--status-success)`:`var(--status-error)`,flexShrink:0}}),(0,E.jsx)(`span`,{style:{color:`var(--text-muted)`,flex:1,minWidth:0},children:m(Le.ok?`files.pullSuccess`:`files.pullFailed`)}),(0,E.jsx)(`button`,{onClick:()=>Re(null),"aria-label":m(`files.dismissError`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:16,height:16,padding:0,background:`none`,border:`none`,borderRadius:4,color:`var(--text-dim)`,cursor:`pointer`,flexShrink:0},children:(0,E.jsx)(ni,{size:p.base})})]}),Le.output&&(0,E.jsx)(`pre`,{style:{margin:0,maxHeight:140,overflow:`auto`,whiteSpace:`pre-wrap`,wordBreak:`break-all`,color:Le.ok?`var(--text-muted)`:`var(--status-error)`,fontFamily:`var(--font-mono)`},children:Le.output})]}),de&&(0,E.jsx)(N9,{message:de,onDismiss:()=>fe(null)}),L&&(0,E.jsx)(N9,{message:b9(L,m),onDismiss:()=>se(null)}),_e&&(0,E.jsx)(N9,{message:_e,onDismiss:()=>ve(null)}),(0,E.jsx)(M9,{prefix:m(`files.stagedPrefix`),count:ie.length,additions:ne.additions,deletions:ne.deletions,t:m}),ie.length>0?ie.map(n=>(0,E.jsx)(A9,{status:n,cwd:e,onOpenFile:t,onStageToggle:e=>void lt(e,!0),unstage:!0,t:m},`staged-${n.filePath}`)):(0,E.jsx)(`div`,{style:{padding:`8px 10px`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`,textAlign:`center`},children:m(`files.noStagedChanges`)}),(0,E.jsx)(`div`,{style:{height:6}}),(0,E.jsx)(M9,{prefix:m(`files.unstagedPrefix`),count:ae.length,additions:P.additions,deletions:P.deletions,t:m}),ae.length>0?ae.map(n=>(0,E.jsx)(A9,{status:n,cwd:e,onOpenFile:t,onStageToggle:e=>void lt(e,!1),t:m},n.filePath)):(0,E.jsx)(`div`,{style:{padding:`8px 10px`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`,textAlign:`center`},children:m(`files.noUnstagedChanges`)})]}),s&&(0,E.jsxs)(F9,{ref:x,children:[y?(0,E.jsx)(`div`,{style:{padding:`8px 12px`,fontSize:`var(--text-sm)`,color:`var(--status-error)`},children:b9(y,m)}):(D?O:h).map(n=>(0,E.jsx)(k9,{node:n,depth:0,cwd:e,onOpenFile:t,onAtMention:i,expandedPaths:S,onToggleExpanded:tt,refreshToken:Ze,highlightedPaths:k,gitStatusByPath:$e,changedDirectoryPaths:et,t:m},n.fullPath)),!_&&!y&&h.length===0&&(0,E.jsx)(`div`,{style:{padding:`8px 12px`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`},children:m(`files.noFiles`)})]}),(0,E.jsx)(Bx,{open:ye,title:m(`git.ai.notConfiguredTitle`),description:m(`git.ai.notConfiguredDesc`),confirmText:m(`git.ai.goToConfig`),cancelText:m(`sidebar.cancel`),onCancel:()=>xe(!1),onConfirm:()=>{xe(!1),u?.(`git`)},icon:(0,E.jsx)(Kr,{size:p[`5xl`],style:{color:`var(--accent)`}})}),(0,E.jsx)(Bx,{open:pe,title:m(`files.commitTitle`),description:(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{children:m(`files.confirmStageAllCommit`,{count:j.length})}),R.trim()!==``&&(0,E.jsx)(`div`,{style:{marginTop:8,padding:`6px 10px`,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:6,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,color:`var(--text-muted)`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,maxHeight:120,overflowY:`auto`,textAlign:`left`},children:R.trim()})]}),confirmText:m(`files.stageAllAndCommit`),cancelText:m(`sidebar.cancel`),onCancel:()=>me(!1),onConfirm:()=>{me(!1),ut(!0)},icon:(0,E.jsxs)(`svg`,{width:p[`5xl`],height:p[`5xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`var(--status-warning)`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,style:{flexShrink:0,marginTop:1},children:[(0,E.jsx)(`path`,{d:`M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10Z`}),(0,E.jsx)(`path`,{d:`m9 12 2 2 4-4`})]})})]})});function L9({cwd:e,onOpenFile:t,explorerRefreshKey:n,onExplorerRefresh:r,onAtMention:i,onAtMentions:a,sessionId:o,onOpenConfig:s}){let{t:c}=N(),[l,u]=(0,d.useState)(0),[f,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)(0),[_,v]=(0,d.useState)(!0),[y,b]=(0,d.useState)(!1),x=(0,d.useRef)(null),S=(0,d.useRef)(null),[C,w]=(0,d.useState)(!1),[T,D]=(0,d.useState)(``),O=(0,d.useRef)(null);return(0,d.useEffect)(()=>{C&&O.current?.focus()},[C]),(0,d.useEffect)(()=>{n!==void 0&&u(e=>e+1)},[n]),e?(0,E.jsx)(N7,{title:c(`files.explorer`),open:!0,onToggle:()=>{},collapsible:!1,testId:`explorer-scroll`,hintTestId:`explorer`,style:{flex:1,minHeight:0},scrollStyle:{background:`var(--bg)`},actions:(0,E.jsx)(E7,{items:[{key:`git`,onClick:()=>v(e=>!e),title:c(`sidebar.changedFiles`,{count:h}),ariaPressed:!_,color:h>0?`var(--accent)`:`var(--text-muted)`,background:_?void 0:`var(--bg-selected)`,borderColor:_?void 0:`var(--accent)`,icon:(0,E.jsx)(Sr,{size:p.lg})},{key:`search`,testId:`explorer-search-toggle`,onClick:()=>{C&&D(``),w(e=>!e)},title:c(`files.search`),ariaPressed:C,color:C?`var(--accent)`:`var(--text-muted)`,background:C?`var(--bg-selected)`:void 0,icon:(0,E.jsx)(Hr,{size:p.lg})},{key:`upload`,onClick:()=>S.current?.openUploadPicker(),disabled:f,title:c(`sidebar.uploadFilesTitle`),color:`var(--text-muted)`,icon:(0,E.jsx)(Ir,{size:p.base})},{key:`refresh`,onClick:()=>{r?r():u(e=>e+1),b(!0),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>b(!1),2e3)},title:c(`sidebar.refreshExplorer`),skipHover:y,color:y?`var(--status-success)`:`var(--text-muted)`,background:y?`color-mix(in srgb, var(--status-success) 18%, transparent)`:void 0,icon:y?(0,E.jsx)(ur,{size:p.lg,color:`var(--status-success)`,strokeWidth:2.5}):(0,E.jsx)(Rr,{size:p.lg})}]}),headerExtra:C?(0,E.jsxs)(`div`,{"data-testid":`explorer-search`,style:{display:`flex`,alignItems:`center`,gap:4,width:`100%`,minWidth:0,padding:`4px 8px`,background:`var(--bg)`,borderBottom:`1px solid var(--border)`,boxSizing:`border-box`},children:[(0,E.jsx)(Hr,{size:p.lg,color:`var(--text-muted)`,style:{flexShrink:0}}),(0,E.jsx)(`input`,{ref:O,"data-testid":`explorer-search-input`,value:T,onChange:e=>D(e.target.value),placeholder:c(`files.searchPlaceholder`),"aria-label":c(`files.search`),style:{flex:1,minWidth:0,background:`transparent`,border:`none`,outline:`none`,color:`var(--text)`,fontSize:`var(--text-sm)`}}),T&&(0,E.jsx)(`button`,{type:`button`,onClick:()=>{D(``),O.current?.focus()},"aria-label":c(`chat.clearSearch`),style:{border:`none`,background:`transparent`,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-sm)`,display:`flex`,alignItems:`center`,justifyContent:`center`,width:16,height:16,padding:0,flexShrink:0},children:(0,E.jsx)(ni,{size:p.base})})]}):void 0,children:(0,E.jsx)(I9,{ref:S,cwd:e,onOpenFile:t??(()=>{}),refreshKey:l,searchQuery:T,onAtMention:i,onAtMentions:a,onUploadBusyChange:m,changesCollapsed:_,onChangesCountChange:g,sessionId:o,onOpenConfig:s})}):null}function R9({geometries:e,messages:t,onAddMessage:n,onRemoveMessage:r,onUpdateMessage:i,widgets:a,closedKeys:o,onReopen:s}){let{t:c}=N(),[l,u]=(0,d.useState)(null),[f,p]=(0,d.useState)(null),m=(0,d.useRef)(null);(0,d.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]);let h=e=>a.find(t=>t.key===e)?.lines[0],g=(e,t,n)=>{s(e),p({key:e,x:t,y:n}),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>p(null),2500)},_=[...new Set([...Object.keys(e),...o.keys()])].map(t=>[t,e[t]]);return(0,E.jsxs)(`div`,{style:{height:`100%`,display:`flex`,flexDirection:`column`,background:`var(--bg)`},children:[_.length===0?(0,E.jsx)(`div`,{style:{padding:`32px 16px`,textAlign:`center`,color:`var(--text-dim)`,fontSize:`var(--text-lg)`,lineHeight:1.6},children:c(`config.widgets.empty`)}):(0,E.jsx)(`div`,{style:{flex:1,minHeight:0,overflowY:`auto`,padding:10,display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignContent:`flex-start`,gap:6},children:_.map(([e,a])=>{let s=t[e]??[],d=o.has(e),f=h(e);return(0,E.jsxs)(`div`,{"data-testid":`widget-config-item-${e}`,style:{flex:`1 1 200px`,boxSizing:`border-box`,padding:`8px 10px`,borderRadius:5,background:`var(--bg-panel)`,border:`1px solid var(--border)`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:7,flexWrap:`wrap`},children:[(0,E.jsxs)(`div`,{style:{minWidth:0,flex:`1 1 120px`},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,fontWeight:600,fontFamily:`var(--font-mono)`,color:`var(--text)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e}),a&&(0,E.jsxs)(`div`,{style:{marginTop:2,fontSize:`var(--text-sm)`,fontFamily:`var(--font-mono)`,color:`var(--text-dim)`},children:[c(`config.widgets.x`),`: `,a.x,` `,c(`config.widgets.y`),`: `,a.y,` ·`,` `,c(`config.widgets.width`),`: `,a.width,` `,c(`config.widgets.height`),`:`,` `,a.height]})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:4,flexShrink:0},children:[d&&(0,E.jsxs)(`button`,{type:`button`,"data-testid":`widget-expand-${e}`,"aria-label":c(`widgets.reopen`),title:c(`widgets.reopen`),onClick:t=>g(e,t.clientX,t.clientY),style:{display:`flex`,alignItems:`center`,gap:4,padding:`4px 8px`,borderRadius:5,border:`1px solid var(--border)`,background:`var(--bg)`,color:`var(--text-muted)`,fontSize:`var(--text-sm)`,cursor:`pointer`},className:`hover-shift`,children:[(0,E.jsx)(vr,{size:13,"aria-hidden":!0}),c(`widgets.reopen`)]}),(0,E.jsxs)(`button`,{type:`button`,"data-testid":`widget-bind-${e}`,onClick:()=>u(e),style:{display:`flex`,alignItems:`center`,gap:4,padding:`4px 8px`,borderRadius:5,border:`1px solid var(--border)`,background:`var(--bg)`,color:`var(--text-muted)`,fontSize:`var(--text-sm)`,cursor:`pointer`},children:[(0,E.jsx)(Or,{size:13,"aria-hidden":!0}),c(`config.widgets.bind`)]})]})]}),f&&(0,E.jsx)(`div`,{style:{marginTop:4,fontSize:`var(--text-sm)`,color:`var(--text-muted)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:f}),(0,E.jsx)(KK,{messages:s,onAdd:t=>n(e,t),onRemove:t=>r(e,t),onUpdate:(t,n)=>i(e,t,n),bindOpen:l===e,onBindOpenChange:e=>{e||u(null)},ns:`widgets`,bindTestIdPrefix:`widget-bind`,editTestIdPrefix:`widget-edit`,chipTestIdPrefix:`widget-bound-${e}`,bindHintArgs:{key:e}})]},e)})}),f&&(0,E.jsx)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":`widget-expanded-toast`,style:{position:`fixed`,left:Math.min(f.x,window.innerWidth-180),top:f.y+12,transform:`translateX(-50%)`,zIndex:2e3,padding:`8px 12px`,borderRadius:7,border:`1px solid var(--status-success)`,background:`var(--bg)`,color:`var(--text)`,fontSize:`var(--text-base)`,boxShadow:`0 4px 16px var(--shadow-strong)`,whiteSpace:`nowrap`},children:c(`widgets.expandedToChat`,{key:f.key})})]})}var z9=e=>window.history.replaceState(null,``,e),B9=36,V9=176,H9=224,U9=86,W9=116;function G9(){let[e,t]=(0,d.useState)(!1);(0,d.useEffect)(()=>{t(!0)},[]);let[n]=(0,d.useState)(()=>Mq(new URLSearchParams(window.location.search))),{isDark:r,toggleTheme:i}=Xn(),{locale:a,setLocale:o,t:s,supportedLocales:c}=N(),l=ne();Sq();let{settingsValue:u,defaultThinkingLevel:f,setDefaultThinkingLevel:m,compaction:h,retry:g,defaultProjectTrust:_,setDefaultProjectTrust:v,subagents:y,savedWorkspaces:b,handleSavedWorkspacesChange:x,widgetGeometries:S,setWidgetGeometry:C,widgetMessages:w,addWidgetMessage:T,removeWidgetMessage:D,updateWidgetMessage:O,fontScale:k,setFontScale:A}=mt({isDark:r,toggleTheme:i}),{selectedSession:j,effectiveNewSessionCwd:M,showChat:P,projectTrustCwd:ee,refreshKey:F,sessionKey:te,explorerRefreshKey:re,setExplorerRefreshKey:ie,modelsRefreshKey:I,setModelsRefreshKey:L,activeCwd:se,initialCwdStatus:R,initialCwdError:ue,initialSessionRestored:de,projectTrust:me,projectTrustDialogOpen:ge,setProjectTrustDialogOpen:_e,projectTrustBusy:ve,projectTrustError:ye,setProjectTrustError:be,extensionDialogActiveRef:xe,handleSelectSession:Se,handleNewSession:Ce,handleSessionCreated:we,handleAgentEnd:Te,handleSessionRenamed:Ee,handleSessionForked:De,handleSessionDeleted:Oe,handleCwdChange:Ae,handleTrustProject:Me,handleExplorerRefresh:Ne,handleInitialRestoreDone:Pe}=ke({initialNavigation:n,onProjectSwitch:()=>{_t(null),Fe(e=>e.filter(e=>e.kind!==`file`)),Ie(null),z9(`/`)},onSessionSelected:e=>{l&&!e&&Ze(!1)},onTopPanelReset:()=>_t(null)}),{setSavedTabs:Fe,setActiveSavedId:Ie,configTabOpen:Le,configSection:Re,setConfigSection:ze,configTabActive:Be,activeFileTab:Ve,fileTabs:He,modelConfigFocus:Ue,handleOpenFile:We,openConfigTab:Ge,handleOpenModelConfig:Ke,closeConfigTab:qe,handleCloseMainTab:Je}=vq({onSessionSelected:()=>{Tt(!1),l&&Ze(!1)},onRefreshModels:()=>L(e=>e+1)}),Ye=(0,d.useCallback)(e=>{We(e,yG(e),{sourceSessionId:j?.id??null})},[We,j?.id]),[Xe,Ze]=(0,d.useState)(!0),[Qe,$e]=(0,d.useState)(!1),et=(0,d.useRef)(280),tt=(0,d.useRef)(280),nt=(0,d.useCallback)(()=>typeof window>`u`?480:ce({viewportWidth:window.innerWidth,rightPanelOpen:!1,rightPanelWidth:0}),[]),rt=fe({ariaLabel:s(`layout.resizeSidebar`),cssVariable:`--sidebar-width`,defaultWidth:280,getMaxWidth:nt,growthDirection:`right`,maxWidth:480,minWidth:180,storageKey:`pi-sidebar-width`,widthRef:et}),it=rt.reclampWidth,at=fe({ariaLabel:s(`layout.resizeWidgetPanel`),cssVariable:`--widget-panel-width`,defaultWidth:280,getMaxWidth:()=>typeof window>`u`?560:le({viewportWidth:window.innerWidth,sidebarOpen:Xe,sidebarWidth:rt.width}),growthDirection:`left`,maxWidth:560,minWidth:200,storageKey:`pi-widget-panel-width`,widthRef:tt});(0,d.useEffect)(()=>{l&&Ze(!1)},[l]),(0,d.useEffect)(()=>{$e(!0)},[]),(0,d.useEffect)(()=>{it()},[it]);let ot=(0,d.useRef)(null),st=(0,d.useRef)(null),ct=(0,d.useRef)(null),ut=(0,d.useRef)(null),dt=(0,d.useRef)(null),ft=pe(),pt=(0,d.useCallback)(()=>{ft.schedule(()=>{_t(null)},150)},[ft]),ht=ft.cancel,[gt,_t]=(0,d.useState)(null),[vt,yt]=(0,d.useState)(null),bt=(0,d.useCallback)(e=>{l&&Ze(!1),_t(t=>t===e?null:e)},[l]),xt=(0,d.useCallback)(()=>{l&&_t(null),Ze(e=>!e)},[l]);(0,d.useEffect)(()=>{if(!gt)return;let e=()=>{if(document.hidden)return;let e=st.current?.getBoundingClientRect();if(e){if(gt===`language`&&!l&&ut.current){let t=ut.current.getBoundingClientRect(),n=ct.current?.getBoundingClientRect(),r=n?.top??t.top,i=n?.bottom??t.bottom,a=Math.min(V9,n?.width??e.width),o=Math.min(t.left-1,Math.max(n?.left??e.left,(n?.right??e.right)-a)),s=i+4;yt({top:s+U9>window.innerHeight-4?r-U9:s,left:o,width:a});return}if(gt===`fontSize`&&!l&&dt.current){let t=dt.current.getBoundingClientRect(),n=ct.current?.getBoundingClientRect(),r=n?.top??t.top,i=n?.bottom??t.bottom,a=Math.min(H9,n?.width??e.width),o=Math.min(t.left-1,Math.max(n?.left??e.left,(n?.right??e.right)-a)),s=i+4;yt({top:s+W9>window.innerHeight-4?r-W9:s,left:o,width:a});return}yt({top:e.bottom,left:e.left,width:e.width})}};e();let t=new ResizeObserver(e);return st.current&&t.observe(st.current),ut.current&&t.observe(ut.current),dt.current&&t.observe(dt.current),()=>t.disconnect()},[gt,l]);let{widgetPanelOpen:St,setWidgetPanelOpen:Ct,widgetsTabActive:wt,setWidgetsTabActive:Tt,extensionWidgets:Et,closedWidgets:Dt,handleCloseWidget:Ot,handleReopenWidget:kt,handleExtensionWidgetsChange:At,rightSidebarOpen:jt,setRightSidebarOpen:Mt,closedWidgetCount:Nt}=yq({widgetGeometries:S,setWidgetGeometry:C}),Pt=l?St:jt,Ft=(0,d.useCallback)((e,t)=>{ot.current?.insertText(kq(e,t))},[]),It=(0,d.useCallback)(e=>{let t=jq(e);t&&ot.current?.insertText(t)},[]),Lt=(0,d.useCallback)((e,t,n)=>{ot.current?.insertText(Aq(e,t,n))},[]),Rt=n.sessionId;ae({onNewSession:e=>Ce(`kb-${Date.now()}`,e),activeCwd:se});let zt=de&&!P,Bt=[{id:lq,label:s(`tabs.chat`),closable:!1,icon:(0,E.jsx)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`})})},{id:dq,label:s(`tabs.widgets`),badge:Nt,closable:!1,icon:(0,E.jsxs)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1`}),(0,E.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`,rx:`1`}),(0,E.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`}),(0,E.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`,rx:`1`})]})},...Le?[{id:uq,label:s(`config.title`),closable:!0,icon:(0,E.jsx)(Wr,{width:p.lg,height:p.lg,"aria-hidden":`true`})}]:[],...He],Vt=se?yG(se)||se:null,Ht=Vt?`Pi Web · ${Vt}`:`Pi Web`;(0,d.useEffect)(()=>{document.title=Ht},[Ht]),(0,d.useEffect)(()=>{let e=()=>{document.title=Ht};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[Ht]);let Ut=oe(),Wt=(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{ref:ct,style:{padding:`2px 8px`,flexShrink:0,display:`flex`,justifyContent:`space-between`,gap:4},children:[{label:s(`config.title`),onClick:()=>Ge(),disabled:!1,icon:(0,E.jsx)(Wr,{width:p[`3xl`],height:p[`3xl`],"aria-hidden":`true`})},...Ut===`granted`||Ut==="default"||Ut===`denied`?[{label:s(Ut===`granted`?`notify.permission.grantedHint`:Ut===`denied`?`notify.permission.deniedHint`:`notify.permission.requestHint`),ariaLabel:s(Ut===`granted`?`notify.permission.granted`:Ut===`denied`?`notify.permission.denied`:`notify.permission.request`),onClick:Ut===`granted`?()=>{}:()=>Zt(),disabled:!1,testId:`notify-permission`,color:Ut===`granted`?`var(--status-success)`:Ut===`denied`?`var(--status-error)`:`var(--accent)`,icon:(0,E.jsx)(`svg`,{width:p[`3xl`],height:p[`3xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:Ut===`denied`?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`path`,{d:`M8.7 3A6 6 0 0 1 18 8a21.3 21.3 0 0 0 .6 5`}),(0,E.jsx)(`path`,{d:`M17 17H3s3-2 3-9a4.67 4.67 0 0 1 .3-1.7`}),(0,E.jsx)(`path`,{d:`M10.3 21a1.94 1.94 0 0 0 3.4 0`}),(0,E.jsx)(`path`,{d:`m2 2 20 20`})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`path`,{d:`M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9`}),(0,E.jsx)(`path`,{d:`M10.3 21a1.94 1.94 0 0 0 3.4 0`})]})})}]:[],{label:s(r?`theme.light`:`theme.dark`),onClick:()=>i(),disabled:!1,ariaPressed:r,icon:r?(0,E.jsxs)(`svg`,{width:p[`3xl`],height:p[`3xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`5`}),(0,E.jsx)(`line`,{x1:`12`,y1:`1`,x2:`12`,y2:`3`}),(0,E.jsx)(`line`,{x1:`12`,y1:`21`,x2:`12`,y2:`23`}),(0,E.jsx)(`line`,{x1:`4.22`,y1:`4.22`,x2:`5.64`,y2:`5.64`}),(0,E.jsx)(`line`,{x1:`18.36`,y1:`18.36`,x2:`19.78`,y2:`19.78`}),(0,E.jsx)(`line`,{x1:`1`,y1:`12`,x2:`3`,y2:`12`}),(0,E.jsx)(`line`,{x1:`21`,y1:`12`,x2:`23`,y2:`12`}),(0,E.jsx)(`line`,{x1:`4.22`,y1:`19.78`,x2:`5.64`,y2:`18.36`}),(0,E.jsx)(`line`,{x1:`18.36`,y1:`5.64`,x2:`19.78`,y2:`4.22`})]}):(0,E.jsx)(`svg`,{width:p[`3xl`],height:p[`3xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,E.jsx)(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`})})},{label:s(`common.language`),onClick:()=>{l&&Ze(!1),ht(),_t(`language`)},onMouseEnter:()=>{ht(),gt!==`language`&&_t(`language`)},onMouseLeave:pt,disabled:!1,ref:ut,ariaExpanded:gt===`language`,noTooltip:!0,icon:(0,E.jsxs)(`svg`,{width:p[`3xl`],height:p[`3xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,E.jsx)(`line`,{x1:`2`,y1:`12`,x2:`22`,y2:`12`}),(0,E.jsx)(`path`,{d:`M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z`})]})},{label:s(`theme.fontSize`),onClick:()=>{l&&Ze(!1),ht(),_t(`fontSize`)},onMouseEnter:()=>{ht(),gt!==`fontSize`&&_t(`fontSize`)},onMouseLeave:pt,disabled:!1,ref:dt,ariaExpanded:gt===`fontSize`,noTooltip:!0,icon:(0,E.jsxs)(`svg`,{width:p[`3xl`],height:p[`3xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`polyline`,{points:`4 7 4 4 20 4 20 7`}),(0,E.jsx)(`line`,{x1:`9`,y1:`20`,x2:`15`,y2:`20`}),(0,E.jsx)(`line`,{x1:`12`,y1:`4`,x2:`12`,y2:`20`})]})}].map(({label:e,onClick:t,onMouseEnter:n,onMouseLeave:r,disabled:i,icon:a,ref:o,ariaPressed:s,ariaExpanded:c,noTooltip:l,color:u,ariaLabel:d,testId:f})=>{let p=(0,E.jsx)(`button`,{ref:o,onClick:t,disabled:i,"data-testid":f,"aria-label":d??e,"aria-pressed":s,"aria-haspopup":c===void 0?void 0:`menu`,"aria-expanded":c,style:{flex:1,display:`flex`,alignItems:`center`,justifyContent:`center`,height:32,padding:0,background:`none`,border:`none`,borderRadius:9,...u?{color:u}:{color:`var(--text-muted)`},cursor:i?`default`:`pointer`,opacity:i?.35:1,transition:`background 0.12s, color 0.12s`,"--hover-color":`var(--text)`},onMouseEnter:n,onMouseLeave:r,className:`hover-shift`,children:a});return l?(0,E.jsx)(`div`,{style:{flex:1,minWidth:0,display:`flex`},children:p},e):(0,E.jsx)(oi,{label:e,wrapperStyle:{flex:1,minWidth:0,display:`flex`},children:p},e)})}),(0,E.jsx)($7,{selectedSessionId:j?.id??null,selectedSession:j,onSelectSession:Se,onNewSession:Ce,initialSessionId:Rt,skipInitialProjectSelection:n.requestedCwd!==null,onInitialRestoreDone:Pe,refreshKey:F,onSessionDeleted:Oe,selectedCwd:j?.cwd??M,onCwdChange:Ae,savedWorkspaces:b,onSavedWorkspacesChange:x,onOpenFile:We})]});if(!e)return(0,E.jsx)(Nq,{});let Gt=(0,E.jsx)(oi,{label:s(Xe?`sidebar.hide`:`sidebar.show`),children:(0,E.jsx)(`button`,{onClick:xt,"aria-label":s(Xe?`sidebar.hide`:`sidebar.show`),"aria-pressed":Xe,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:B9,height:B9,padding:0,background:`none`,border:`none`,borderRight:`1px solid var(--border)`,color:Xe?`var(--text)`:`var(--text-muted)`,cursor:`pointer`,flexShrink:0,transition:`color 0.12s`,"--hover-color":`var(--text)`},className:`hover-shift`,children:(0,E.jsxs)(`svg`,{width:p[`4xl`],height:p[`4xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`rect`,{x:`3`,y:`3`,width:p[`4xl`],height:p[`4xl`],rx:`2`}),(0,E.jsx)(`line`,{x1:`9`,y1:`3`,x2:`9`,y2:`21`})]})})}),Kt=P&&me?.requiresTrust&&!me.trusted?(0,E.jsx)(oi,{label:s(`trust.resourcesNotLoaded`),wrapperStyle:{height:`100%`},children:(0,E.jsxs)(`button`,{type:`button`,onClick:()=>{be(null),_e(!0)},"aria-label":s(`trust.resourcesNotLoaded`),style:{display:`flex`,alignItems:`center`,gap:6,height:`100%`,padding:l?`0 10px`:`0 12px`,background:`none`,border:`none`,borderLeft:`1px solid var(--border)`,color:`var(--status-warning)`,cursor:`pointer`,flexShrink:0,fontSize:`var(--text-sm)`,whiteSpace:`nowrap`},children:[(0,E.jsxs)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10Z`}),(0,E.jsx)(`path`,{d:`M12 8v4`}),(0,E.jsx)(`path`,{d:`M12 16h.01`})]}),!l&&(0,E.jsx)(`span`,{children:s(`trust.resourcesNotLoaded`)})]})}):null,qt=(0,E.jsx)(oi,{label:s(Pt?`sidebar.hide`:`sidebar.show`),children:(0,E.jsx)(`button`,{onClick:()=>{l?Ct(e=>!e):Mt(e=>!e)},"aria-controls":`widget-panel`,"aria-expanded":Pt,"aria-label":s(Pt?`sidebar.hide`:`sidebar.show`),"data-testid":`widget-panel-toggle`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:36,height:36,padding:0,background:`none`,border:`none`,borderLeft:`1px solid var(--border)`,color:St?`var(--text)`:`var(--text-muted)`,cursor:`pointer`,flexShrink:0,transition:`color 0.12s`,"--hover-color":`var(--text)`},className:`hover-shift`,children:(0,E.jsxs)(`svg`,{width:p[`4xl`],height:p[`4xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`rect`,{x:`3`,y:`3`,width:p[`4xl`],height:p[`4xl`],rx:`2`}),(0,E.jsx)(`line`,{x1:`15`,y1:`3`,x2:`15`,y2:`21`})]})})});return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(he,{value:u,children:(0,E.jsx)(je,{value:{activeTopPanel:gt,toggleTopPanel:bt,closeTopPanel:()=>_t(null)},children:(0,E.jsx)(E.Fragment,{children:(0,E.jsxs)(ai,{delayDuration:0,children:[(0,E.jsx)(`style`,{children:`
|
|
482
|
+
`))},[e.key]),(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(qX,{testId:`widget-dialog`,title:e.key,align:`center`,portalTarget:c,style:{opacity:+!u,transition:`opacity 200ms ease`},headerExtra:(0,E.jsx)(oi,{label:l(`widgets.collapse`),children:(0,E.jsx)(`button`,{type:`button`,"aria-label":l(`widgets.collapse`),onClick:_,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:26,height:26,borderRadius:6,border:`none`,background:`transparent`,color:`var(--text-muted)`,cursor:`pointer`},className:`hover-shift`,children:(0,E.jsx)(jr,{size:p.xl})})}),position:t?{x:t.x,y:t.y}:void 0,size:t?{width:t.width,height:t.height}:void 0,initialOffset:r,onDragStop:(n,r)=>a(e.key,{x:n,y:r,width:t?.width??560,height:t?.height??Math.round(window.innerHeight*.6)}),onResizeStop:(t,n,r,i)=>a(e.key,{x:r,y:i,width:t,height:n}),children:(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:[(0,E.jsx)(`pre`,{style:{margin:0,color:`var(--text-muted)`,fontSize:`var(--text-base)`,lineHeight:1.5,whiteSpace:`pre-wrap`,wordBreak:`break-word`,fontFamily:`var(--font-mono)`},children:e.lines.join(`
|
|
483
|
+
`)}),n.length>0&&(0,E.jsx)(`div`,{"data-testid":`widget-bound-messages`,style:{display:`flex`,flexWrap:`wrap`,gap:6,paddingTop:8,borderTop:`1px solid var(--border)`,flexShrink:0},children:n.map((t,n)=>(0,E.jsx)(ZJ,{msg:t,onSend:o,onFillInput:s,testId:`widget-send-${e.key}-${n}`},n))})]})}),m&&(0,E.jsx)(`div`,{"data-testid":`widget-collapse-trail`,style:{position:`fixed`,inset:0,zIndex:70,pointerEvents:`none`},children:(0,E.jsx)(`svg`,{width:`100%`,height:`100%`,style:{position:`absolute`,inset:0},children:(0,E.jsx)(`circle`,{ref:g,r:28,fill:`var(--accent)`,fillOpacity:.7})})})]})}var J5={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,svg:`image/svg+xml`,bmp:`image/bmp`,ico:`image/x-icon`,avif:`image/avif`},Y5={mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`,oga:`audio/ogg`,opus:`audio/ogg`,m4a:`audio/mp4`,aac:`audio/aac`,flac:`audio/flac`,weba:`audio/webm`,webm:`audio/webm`};function X5(e){return e.replace(/\\/g,`/`).split(`/`).pop()??``}function Z5(e){return X5(e).toLowerCase().split(`.`).pop()??``}function Q5(e){return J5[Z5(e)]??null}function $5(e){return Y5[Z5(e)]??null}function e7(e){let t=Z5(e);return t===`pdf`||t===`docx`?t:null}function t7(e){return Q5(e)!==null}function n7(e){return $5(e)!==null}function r7(e){return e7(e)!==null}async function i7(e,t){let n=e.split(/[\\/]/).filter(Boolean),r=n.pop();if(!r)throw Error(`Invalid file path`);let i=n.join(`/`)||`/`,a=new FormData;a.append(`files`,new File([t],r,{type:`text/plain`}));let o=await fetch(`/api/files/${vG(i)}?type=upload&conflict=overwrite`,{method:`POST`,body:a});if(!o.ok){let e=`Save failed (${o.status})`;try{let t=await o.json();t?.error&&(e=t.error)}catch{}throw Error(e)}}var a7=(0,d.lazy)(()=>$1(()=>import(`./CodeMirrorEditor-DSMafr9-.js`),__vite__mapDeps([18,1]))),o7={source:`Source`,preview:`Preview`,diff:`Diff`},s7={fontFamily:`var(--font-mono)`,fontSize:`var(--text-lg)`,lineHeight:1.6},c7={width:48,minWidth:48,padding:`0 10px`,textAlign:`right`,color:`var(--text-dim)`,background:`var(--bg-panel)`,borderRight:`1px solid var(--border)`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,fontStyle:`normal`,fontVariantNumeric:`tabular-nums`,lineHeight:`20.8px`,userSelect:`none`,flexShrink:0,verticalAlign:`top`};function l7(){return(0,E.jsxs)(`svg`,{width:p.xl,height:p.xl,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,E.jsx)(`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`})]})}function u7(e){return(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(`.file-source-line[data-line-number]`)??null}function d7(e,t){if(!t||t.isCollapsed||t.rangeCount===0)return null;let n=t.getRangeAt(0);if(!e.contains(n.startContainer)||!e.contains(n.endContainer))return null;let r=u7(n.startContainer),i=u7(n.endContainer);if(!r||!i||!e.contains(r)||!e.contains(i))return null;let a=Number(r.dataset.lineNumber),o=Number(i.dataset.lineNumber);if(!Number.isInteger(a)||!Number.isInteger(o))return null;if(a<o){let e=r.querySelector(`.file-source-line-content`);if(e?.contains(n.startContainer)){let t=document.createRange();if(t.selectNodeContents(e),t.setStart(n.startContainer,n.startOffset),t.toString().length===0){let e=r.nextElementSibling;e instanceof HTMLElement&&e.matches(`.file-source-line[data-line-number]`)&&(r=e,a=Number(r.dataset.lineNumber))}}let t=i.querySelector(`.file-source-line-content`);if(t?.contains(n.endContainer)){let e=document.createRange();if(e.selectNodeContents(t),e.setEnd(n.endContainer,n.endOffset),e.toString().length===0){let e=i.previousElementSibling;e instanceof HTMLElement&&e.matches(`.file-source-line[data-line-number]`)&&(i=e,o=Number(i.dataset.lineNumber))}}}return a>o?null:{startLine:a,endLine:o}}function f7({rows:e,stylesheet:t,useInlineStyles:n,wrapLines:r}){return e.map((e,i)=>{let a=e.children??[],o=a[0]?.properties?.className,s=Array.isArray(o)&&o.includes(`react-syntax-highlighter-line-number`),c=s?a[0]:null,l=s?a.slice(1):a;return(0,E.jsxs)(`span`,{className:`file-source-line`,"data-line-number":i+1,style:{display:`flex`,minWidth:`100%`},children:[c&&S3({node:c,stylesheet:t,useInlineStyles:n,key:`source-line-number-${i}`}),(0,E.jsx)(`span`,{className:`file-source-line-content`,style:{flex:`1 1 auto`,minWidth:0,overflowWrap:r?`anywhere`:`normal`,whiteSpace:r?`pre-wrap`:`pre`},children:l.map((e,r)=>S3({node:e,stylesheet:t,useInlineStyles:n,key:`source-token-${i}-${r}`}))})]},`source-line-${i}`)})}function p7(e,t,n,r={}){let i=vG(e),a=new URLSearchParams({type:t});n&&a.set(`sessionId`,n);for(let[e,t]of Object.entries(r))t!==void 0&&a.set(e,String(t));return`/api/files/${i}?${a.toString()}`}function m7({filePath:e,sourceSessionId:t}){let{t:n}=N();return(0,E.jsx)(oi,{label:n(`i18n.downloadFile`),children:(0,E.jsx)(`a`,{href:p7(e,`download`,t),download:yG(e),"aria-label":n(`i18n.downloadFile`),className:`file-viewer-icon-button`,children:(0,E.jsxs)(`svg`,{width:p.xl,height:p.xl,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,E.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,E.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]})})})}function h7(e,t,n){let[r,i]=(0,d.useState)(!1),a=(0,d.useRef)(n);a.current=n;let o=(0,d.useRef)(null);return(0,d.useEffect)(()=>(i(!1),o.current?.(),o.current=Ft({ch:`watch`,filePath:e},e=>{e.event===`connected`?i(!0):e.event===`error`?i(!1):a.current(e)}),()=>{o.current?.(),o.current=null}),[e]),{watching:r,closeWatch:(0,d.useCallback)(()=>{o.current?.(),o.current=null,i(!1)},[])}}function g7({filePath:e,cwd:t,extLabel:n,watching:r,sourceSessionId:i,ellipsis:a,children:o}){let{t:s}=N();return(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,padding:`4px 16px`,borderBottom:`1px solid var(--border)`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`,background:`var(--bg)`,flexShrink:0},children:[(0,E.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`,...a?{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}:{}},title:e,children:xG(e,t)}),(0,E.jsx)(`span`,{style:{marginLeft:`auto`},children:n}),o,(0,E.jsxs)(`span`,{title:s(r?`i18n.liveSync`:`i18n.notWatching`),style:{display:`flex`,alignItems:`center`,gap:4,color:r?`var(--status-success)`:`var(--text-dim)`},children:[(0,E.jsx)(`span`,{style:{width:7,height:7,borderRadius:`50%`,background:r?`var(--status-success)`:`var(--border)`,display:`inline-block`,boxShadow:r?`0 0 4px var(--status-success)`:`none`}}),r?`live`:`static`]}),(0,E.jsx)(m7,{filePath:e,sourceSessionId:i})]})}function _7(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function v7(e){let t=DZ(e);return t?t.flatMap(e=>e.rows.flatMap(e=>{if(e.type===`hunk`)return[];if(e.left.type===`context`&&e.right.type===`context`)return[{type:`unchanged`,text:e.right.text,oldLineNo:e.left.lineNo,newLineNo:e.right.lineNo}];let t=[];return e.left.type===`removed`&&t.push({type:`removed`,text:e.left.text,oldLineNo:e.left.lineNo,newLineNo:null}),e.right.type===`added`&&t.push({type:`added`,text:e.right.text,oldLineNo:null,newLineNo:e.right.lineNo}),t})):[]}function y7({patch:e}){let{t}=N(),n=v7(e);if(!n.some(e=>e.type!==`unchanged`))return(0,E.jsx)(`div`,{style:{padding:`12px 16px`,fontSize:`var(--text-base)`,color:`var(--text-dim)`,fontFamily:`var(--font-mono)`},children:t(`i18n.noChanges`)});let r=new Set(n.flatMap((e,t)=>e.type===`unchanged`?[]:[t])),i=new Set;for(let e of r)for(let t=Math.max(0,e-3);t<=Math.min(n.length-1,e+3);t++)i.add(t);let a=[],o=0;for(;o<n.length;)if(i.has(o)){let e=[];for(;o<n.length&&i.has(o);)e.push(n[o]),o++;a.push({hidden:!1,lines:e})}else{let e=0;for(;o<n.length&&!i.has(o);)e++,o++;a.push({hidden:!0,count:e})}return(0,E.jsx)(`div`,{className:`file-diff-view`,style:{width:`max-content`,minWidth:`100%`,...s7},children:a.map((e,t)=>{if(e.hidden)return(0,E.jsxs)(`div`,{style:{padding:`2px 16px`,color:`var(--text-dim)`,background:`var(--bg-panel)`,fontSize:`var(--text-sm)`,borderTop:`1px solid var(--border)`,borderBottom:`1px solid var(--border)`},children:[`... `,e.count,` unchanged lines ...`]},t);let n=e.lines.map((e,t)=>{let n=e.type===`added`?`color-mix(in srgb, var(--status-success) 12%, transparent)`:e.type===`removed`?`color-mix(in srgb, var(--status-error) 14%, transparent)`:`transparent`,r=e.type===`added`?`+`:e.type===`removed`?`-`:` `,i=e.type===`added`?`var(--status-success)`:e.type===`removed`?`var(--status-error)`:`var(--text-dim)`;return(0,E.jsxs)(`div`,{className:`file-diff-line`,style:{display:`flex`,minWidth:`100%`,background:n,borderLeft:e.type===`added`?`3px solid var(--status-success)`:e.type===`removed`?`3px solid var(--status-error)`:`3px solid transparent`},children:[(0,E.jsx)(`span`,{style:c7,children:e.type===`removed`?e.oldLineNo:e.newLineNo}),(0,E.jsx)(`span`,{style:{minWidth:16,padding:`0 6px`,color:i,userSelect:`none`,flexShrink:0,fontWeight:600},children:r}),(0,E.jsx)(`span`,{className:`file-diff-line-content`,style:{flexShrink:0,padding:`0 8px 0 0`,whiteSpace:`pre`,color:`var(--text)`},children:e.text||`\xA0`})]},t)});return(0,E.jsx)(`div`,{children:n},t)})})}function b7({filePath:e,cwd:t,sourceSessionId:n}){let[r,i]=(0,d.useState)(0),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(null),f=yG(e).toLowerCase().split(`.`).pop()??``;(0,d.useEffect)(()=>{i(0),o(null),c(null),u(null)},[e,n]);let{watching:p}=h7(e,n,e=>{typeof e.size==`number`&&o(e.size),i(e=>e+1)}),m=p7(e,`read`,n,r?{v:r}:void 0),h=a==null?null:_7(a);return(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`hidden`},children:[(0,E.jsxs)(g7,{filePath:e,cwd:t,extLabel:f||`image`,watching:p,sourceSessionId:n,children:[s&&(0,E.jsxs)(`span`,{children:[s.w,` × `,s.h]}),h&&(0,E.jsx)(`span`,{children:h})]}),(0,E.jsx)(`div`,{style:{flex:1,overflow:`auto`,backgroundColor:`var(--bg-panel)`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:16,backgroundImage:`linear-gradient(45deg, var(--bg) 25%, transparent 25%), linear-gradient(-45deg, var(--bg) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--bg) 75%), linear-gradient(-45deg, transparent 75%, var(--bg) 75%)`,backgroundSize:`16px 16px`,backgroundPosition:`0 0, 0 8px, 8px -8px, -8px 0px`},children:l?(0,E.jsx)(`div`,{style:{color:`var(--status-error)`,fontSize:`var(--text-lg)`},children:l}):(0,E.jsx)(`img`,{src:m,alt:e,onLoad:e=>{let t=e.currentTarget;c({w:t.naturalWidth,h:t.naturalHeight})},onError:()=>u(`Failed to load image`),style:{maxWidth:`100%`,maxHeight:`100%`,objectFit:`contain`,boxShadow:`0 2px 8px var(--shadow-color)`}})})]})}function x7({filePath:e,cwd:t,sourceSessionId:n}){let[r,i]=(0,d.useState)(0),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(null),f=yG(e).toLowerCase().split(`.`).pop()??``;(0,d.useEffect)(()=>{i(0),o(null),c(null),u(null)},[e,n]);let{watching:p}=h7(e,n,e=>{typeof e.size==`number`&&o(e.size),c(null),u(null),i(e=>e+1)}),m=p7(e,`read`,n,r?{v:r}:void 0);return(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`hidden`},children:[(0,E.jsxs)(g7,{filePath:e,cwd:t,extLabel:f||`audio`,watching:p,sourceSessionId:n,children:[s!=null&&(0,E.jsx)(`span`,{children:ht(s)}),a!=null&&(0,E.jsx)(`span`,{children:_7(a)})]}),(0,E.jsx)(`div`,{style:{flex:1,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:24,background:`var(--bg-panel)`},children:(0,E.jsxs)(`div`,{style:{width:`min(680px, 100%)`},children:[l&&(0,E.jsx)(`div`,{style:{color:`var(--status-error)`,fontSize:`var(--text-lg)`,marginBottom:12,textAlign:`center`},children:l}),(0,E.jsx)(`audio`,{controls:!0,preload:`metadata`,src:m,onLoadedMetadata:e=>c(e.currentTarget.duration),onError:()=>u(`Failed to load audio`),style:{width:`100%`}},m)]})})]})}function S7({filePath:e,cwd:t,sourceSessionId:n}){let{t:r}=N(),[i,a]=(0,d.useState)(0),[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(null),u=Z5(e),f=u===`pdf`,p=f?p7(e,`read`,n,i?{v:i}:void 0):p7(e,`preview`,n,i?{v:i}:void 0);(0,d.useEffect)(()=>{a(0),s(null),l(null),fetch(p7(e,`meta`,n)).then(e=>e.json()).then(e=>{e.error&&l(e.error),typeof e.size==`number`&&(s(e.size),!f&&e.size>10485760&&l(`DOCX too large for preview (>10MB)`))}).catch(e=>l(String(e)))},[e,f,n]);let{watching:m}=h7(e,n,e=>{if(typeof e.size==`number`&&(s(e.size),!f&&e.size>10485760)){l(`DOCX too large for preview (>10MB)`);return}l(null),a(e=>e+1)});return(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`hidden`},children:[(0,E.jsx)(g7,{filePath:e,cwd:t,extLabel:u===`docx`?`docx preview`:`pdf`,watching:m,sourceSessionId:n,ellipsis:!0,children:o!=null&&(0,E.jsx)(`span`,{children:_7(o)})}),(0,E.jsx)(`div`,{style:{flex:1,minHeight:0,background:`var(--bg-panel)`},children:c?(0,E.jsx)(`div`,{style:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:24,color:`var(--status-error)`,fontSize:`var(--text-lg)`,textAlign:`center`},children:c}):(0,E.jsx)(`iframe`,{src:p,sandbox:f?void 0:`allow-same-origin`,title:r(`i18n.previewFile`,{file:yG(e)}),style:{width:`100%`,height:`100%`,border:`none`,background:f?`var(--bg)`:`#eef1f5`}},p)})]})}function C7({filePath:e,cwd:t,sourceSessionId:n,onOpenFile:r,onMentionLines:i,onSaved:a,gitRefreshKey:o,initialDisplayMode:s}){return t7(e)?(0,E.jsx)(b7,{filePath:e,cwd:t,sourceSessionId:n}):n7(e)?(0,E.jsx)(x7,{filePath:e,cwd:t,sourceSessionId:n}):r7(e)?(0,E.jsx)(S7,{filePath:e,cwd:t,sourceSessionId:n}):(0,E.jsx)(T7,{filePath:e,cwd:t,sourceSessionId:n,onOpenFile:r,onMentionLines:i,onSaved:a,gitRefreshKey:o,initialDisplayMode:s})}function w7({filePath:e,cwd:t,metadata:n,watching:r,isDeletedDiff:i,displayModes:a,effectiveDisplayMode:o,setDisplayMode:s,wrapLines:c,setWrapLines:l,editMode:u,dirty:d,handleSave:f,saveState:m,highlightReady:h,selectedLineRange:g,handleMentionSelectedLines:_,fileContent:v,sourceSessionId:y,t:b,saveError:x,enterEdit:S,cancelEdit:C}){return(0,E.jsxs)(`div`,{className:`file-viewer-toolbar`,style:{display:`flex`,alignItems:`center`,gap:8,padding:`5px 12px`,borderBottom:`1px solid var(--border)`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`,background:`var(--bg)`,flexShrink:0},children:[(0,E.jsx)(oi,{label:e,children:(0,E.jsx)(`span`,{className:`file-viewer-path`,style:{fontFamily:`var(--font-mono)`},children:xG(e,t)})}),(0,E.jsx)(oi,{label:n,children:(0,E.jsx)(`span`,{className:`file-viewer-meta`,children:n})}),!i&&(0,E.jsx)(oi,{label:b(r?`i18n.liveSync`:`i18n.notWatching`),children:(0,E.jsx)(`span`,{"aria-label":b(r?`i18n.liveSync`:`i18n.notWatching`),className:`file-viewer-live-indicator`,style:{background:r?`var(--status-success)`:`var(--border)`,boxShadow:r?`0 0 4px var(--status-success)`:`none`}})}),(0,E.jsxs)(`div`,{className:`file-viewer-controls`,children:[a.length>1&&(0,E.jsx)(`div`,{className:`file-viewer-mode-switch`,"aria-label":b(`i18n.fileViewMode`),children:a.map(e=>{let t=o===e;return(0,E.jsx)(oi,{label:e===`diff`?b(`i18n.compareHead`):void 0,children:(0,E.jsx)(`button`,{type:`button`,onClick:()=>s(e),"aria-pressed":t,className:`file-viewer-mode-button`,style:{background:t?`var(--bg-selected)`:`transparent`,color:t?`var(--text)`:`var(--text-muted)`},children:o7[e]})},e)})}),(0,E.jsxs)(`div`,{className:`file-viewer-actions`,children:[o===`source`&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(oi,{label:b(`i18n.mentionSelectedLines`),children:(0,E.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:_,"aria-label":b(`i18n.mentionSelectedLines`),disabled:!g,className:`file-viewer-icon-button`,children:(0,E.jsx)(l7,{})})}),(0,E.jsx)(oi,{label:b(c?`i18n.disableWrap`:`i18n.enableWrap`),children:(0,E.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-label":b(c?`i18n.disableWrap`:`i18n.enableWrap`),"aria-pressed":c,className:`file-viewer-icon-button`,style:{background:c?`var(--bg-selected)`:`transparent`,color:c?`var(--text)`:`var(--text-muted)`},children:(0,E.jsxs)(`svg`,{width:p.xl,height:p.xl,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`path`,{d:`M4 7V4h16v3`}),(0,E.jsx)(`path`,{d:`M9 20h6`}),(0,E.jsx)(`path`,{d:`M12 4v16`})]})})})]}),o===`source`&&h&&!u&&(0,E.jsx)(`a`,{href:p7(e,`download`,y),download:yG(e),"aria-label":b(`i18n.downloadFile`),className:`file-viewer-icon-button`,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,textDecoration:`none`},children:(0,E.jsxs)(`svg`,{width:p.xl,height:p.xl,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,E.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,E.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]})}),!i&&o===`source`&&(0,E.jsx)(`div`,{className:`file-viewer-edit-controls`,style:{display:`flex`,alignItems:`center`,gap:8,marginLeft:8},children:u?(0,E.jsxs)(E.Fragment,{children:[d&&(0,E.jsx)(oi,{label:b(`i18n.unsavedChanges`),children:(0,E.jsx)(`span`,{"aria-label":b(`i18n.unsavedChanges`),style:{color:`var(--status-warning)`,fontWeight:700},children:`●`})}),(0,E.jsx)(oi,{label:b(`i18n.saveFileShortcut`),children:(0,E.jsx)(`button`,{type:`button`,onClick:f,disabled:!d||m===`saving`,"aria-label":b(`i18n.saveFile`),className:`file-viewer-icon-button`,style:{background:d?`var(--accent)`:`transparent`,color:d?`var(--bg)`:`var(--text-muted)`},children:m===`saving`?(0,E.jsx)(Ar,{size:p.lg,className:`animate-spin`}):(0,E.jsx)(Vr,{size:p.lg})})}),(0,E.jsx)(oi,{label:b(`i18n.cancelEdit`),children:(0,E.jsx)(`button`,{type:`button`,onClick:C,"aria-label":b(`i18n.cancelEdit`),className:`file-viewer-icon-button`,children:(0,E.jsx)(ni,{size:p.lg})})}),m===`error`&&x&&(0,E.jsx)(`span`,{style:{color:`var(--status-error)`,fontSize:`var(--text-sm)`},children:b(`i18n.saveFailed`,{error:x})}),m===`saved`&&!d&&(0,E.jsx)(`span`,{style:{color:`var(--status-success)`,fontSize:`var(--text-sm)`},children:b(`i18n.saved`)})]}):(0,E.jsx)(oi,{label:b(`i18n.editFile`),children:(0,E.jsx)(`button`,{type:`button`,onClick:S,"aria-label":b(`i18n.editFile`),className:`file-viewer-icon-button`,children:(0,E.jsx)(Pr,{size:p.lg})})})}),!i&&(0,E.jsx)(m7,{filePath:e,sourceSessionId:y})]})]})]})}function T7({filePath:e,cwd:t,sourceSessionId:n,onOpenFile:r,onMentionLines:i,onSaved:a,gitRefreshKey:o,initialDisplayMode:s}){let{isDark:c}=Xn(),{t:l}=N(),[u,f]=(0,d.useState)(null),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(!1),[v,y]=(0,d.useState)(!0),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)(`source`),[w,T]=(0,d.useState)(!1),[D,O]=(0,d.useState)(!1),k=(0,d.useRef)(0),A=(0,d.useRef)(null),[j,M]=(0,d.useState)(null),[P,ee]=(0,d.useState)(!1),[F,te]=(0,d.useState)(``),[ne,re]=(0,d.useState)(!1),[ie,ae]=(0,d.useState)(`idle`),[oe,I]=(0,d.useState)(null),L=(0,d.useRef)(!1);L.current=P;let se=(0,d.useCallback)(e=>fetch(p7(e,`read`,n)).then(e=>e.json()).then(e=>e.error?(x(e.error),null):(x(null),f(e),e)).catch(e=>(x(String(e)),null)),[n]),R=(0,d.useCallback)(async e=>{let n=++k.current;if(_(!0),!t){h(null),_(!1);return}try{let r=new URLSearchParams({cwd:t,path:e}),i=await fetch(`/api/git/diff?${r.toString()}`),a=await i.json();if(n!==k.current)return;h(i.ok&&a.supported&&typeof a.patch==`string`?a:null)}catch{n===k.current&&h(null)}finally{n===k.current&&_(!1)}},[t]);(0,d.useEffect)(()=>{y(!0),x(null),f(null),h(null),C(s===`diff`?`diff`:`source`),O(!1),ee(!1),te(``),re(!1),ae(`idle`),I(null),se(e).finally(()=>y(!1))},[e,se]);let{watching:ce,closeWatch:le}=h7(e,n,()=>{L.current||(se(e),R(e))});(0,d.useEffect)(()=>{R(e)},[R,e,o]),(0,d.useEffect)(()=>{u?.language===`markdown`&&s!==`diff`&&C(`preview`)},[u?.language,s]);let ue=m?.supported===!0&&typeof m.patch==`string`,de=ue&&m.status===`deleted`;(0,d.useEffect)(()=>{de&&le()},[de,le]);let fe=(0,d.useMemo)(()=>u?.language===`markdown`?cG(u.content):``,[u]);(0,d.useEffect)(()=>{let e=()=>{let e=A.current;M(i&&S===`source`&&e?d7(e,window.getSelection()):null)};if(e(),!(!i||S!==`source`))return document.addEventListener(`selectionchange`,e),()=>document.removeEventListener(`selectionchange`,e)},[u?.content,S,i]);let pe=(0,d.useCallback)(n=>{!i||!n||i(xG(e,t),n.startLine,n.endLine)},[t,e,i]),me=(0,d.useCallback)(()=>{pe(j)},[pe,j]);(0,d.useEffect)(()=>{if(!i||S!==`source`)return;let e=e=>{if(e.repeat||e.key.toLowerCase()!==`i`||!e.metaKey&&!e.ctrlKey||e.altKey||e.shiftKey)return;let t=e.target;if(t instanceof Element&&t.closest(`input, textarea, [contenteditable='true']`))return;let n=A.current,r=n?d7(n,window.getSelection()):null;r&&(e.preventDefault(),pe(r))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[S,pe,i]);let he=(0,d.useCallback)(()=>{te(u?.content??``),re(!1),ae(`idle`),I(null),ee(!0)},[u?.content]),ge=(0,d.useCallback)(()=>{ee(!1),re(!1),ae(`idle`),I(null),se(e)},[e,se]),_e=(0,d.useCallback)(e=>{te(e),re(e!==(u?.content??``))},[u?.content]),ve=(0,d.useCallback)(async()=>{if(ne){ae(`saving`),I(null);try{await i7(e,F),f(e=>e&&{...e,content:F}),re(!1),ae(`saved`),a?.(e)}catch(e){ae(`error`),I(e instanceof Error?e.message:String(e))}}},[ne,F,e,a]),ye=u?.content??``;if((0,d.useEffect)(()=>{T(!1)},[ye]),(0,d.useEffect)(()=>{if((de?`diff`:S)!==`source`||w)return;let e=setTimeout(()=>T(!0),0);return()=>clearTimeout(e)},[de,S,w]),v||S===`diff`&&g)return(0,E.jsxs)(`div`,{style:{height:`100%`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:12,color:`var(--text-muted)`,fontSize:`var(--text-lg)`},children:[(0,E.jsx)(Ar,{size:p.lg,className:`animate-spin`,"aria-hidden":`true`}),l(`i18n.loading`)]});if(b&&!de)return(0,E.jsx)(`div`,{style:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--status-error)`,fontSize:`var(--text-lg)`},children:b});if(!u&&!de)return null;let be=u?.language??`text`,xe=be===`html`,Se=be===`markdown`,Ce=xe||Se,we=bG(e),Te=ye.split(`
|
|
484
|
+
`),Ee=de?`diff`:S,De=de?[`diff`]:[`source`,...Ce?[`preview`]:[],`diff`],Oe=de?l(`files.deleted`):`${be} · ${Te.length} lines · ${_7(u.size)}`;return(0,E.jsxs)(`div`,{className:`file-viewer-shell`,style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`hidden`},children:[(0,E.jsx)(w7,{filePath:e,cwd:t,metadata:Oe,watching:ce,isDeletedDiff:de,displayModes:De,effectiveDisplayMode:Ee,setDisplayMode:C,wrapLines:D,setWrapLines:O,editMode:P,dirty:ne,handleSave:ve,saveState:ie,saveError:oe,enterEdit:he,cancelEdit:ge,highlightReady:w,selectedLineRange:j,handleMentionSelectedLines:me,fileContent:ye,sourceSessionId:n,t:l}),(0,E.jsxs)(`div`,{ref:A,className:`file-viewer-content`,style:{flex:1,overflow:`auto`,paddingRight:4,background:`var(--bg)`},children:[Ee===`source`&&(0,E.jsx)(`div`,{className:`file-viewer-source`,style:{display:`block`,height:`100%`,overflow:`auto`,background:`var(--bg)`},children:P?(0,E.jsx)(d.Suspense,{fallback:(0,E.jsx)(`div`,{style:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--text-muted)`},children:(0,E.jsx)(Ar,{size:p.lg,className:`animate-spin`,"aria-hidden":`true`})}),children:(0,E.jsx)(a7,{initialValue:F,language:be,isDark:c,onChange:_e,onSave:ve},e)}):w?(0,E.jsx)(v6,{className:D?`file-source-view is-wrapped`:`file-source-view`,language:be===`text`?`plaintext`:be,style:c?H6:V6,showLineNumbers:!0,lineNumberStyle:{...c7},customStyle:{margin:0,padding:0,border:0,background:`var(--bg)`,...s7,width:D?`100%`:`max-content`,minWidth:`100%`,minHeight:`100%`,overflow:`visible`},codeTagProps:{style:{fontFamily:`var(--font-mono)`,overflowWrap:D?`anywhere`:`normal`}},renderer:e=>(0,E.jsx)(f7,{...e,wrapLines:D}),wrapLongLines:D,children:ye}):(0,E.jsx)(`pre`,{className:D?`file-source-view is-wrapped`:`file-source-view`,style:{margin:0,padding:0,border:0,background:`var(--bg)`,...s7,fontFamily:`var(--font-mono)`,whiteSpace:D?`pre-wrap`:`pre`,overflowWrap:D?`anywhere`:`normal`,width:D?`100%`:`max-content`,minWidth:`100%`,minHeight:`100%`,overflow:`visible`},children:ye})}),Ee===`diff`&&ue?(0,E.jsx)(y7,{patch:m.patch}):Ee===`diff`?(0,E.jsx)(`div`,{style:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--text-muted)`,fontSize:`var(--text-lg)`},children:l(`i18n.noChanges`)}):xe&&Ee===`preview`?(0,E.jsx)(`iframe`,{srcDoc:ye,sandbox:`allow-scripts`,style:{width:`100%`,height:`100%`,border:`none`,background:`var(--bg)`},title:l(`i18n.htmlPreview`)}):Se&&Ee===`preview`?(0,E.jsx)(`div`,{className:`markdown-body markdown-file-preview`,style:{padding:`24px 32px`},children:(0,E.jsx)(Ok,{remarkPlugins:pG,rehypePlugins:hG,components:{code({className:e,children:t,...n}){let r=e?.replace(`language-`,``).toLowerCase()??``,i=String(t);return e?.includes(`language-`)||i.includes(`
|
|
485
|
+
`)?r===`mermaid`?(0,E.jsx)(q6,{code:i.replace(/\n$/,``),defaultPreview:!0}):(0,E.jsx)(Z6,{code:i.replace(/\n$/,``),lang:r}):(0,E.jsx)(`code`,{className:e,...n,children:t})},pre({children:e}){return(0,E.jsx)(E.Fragment,{children:e})},a({href:e,children:t,...n}){return delete n.node,(0,E.jsx)(WG,{href:e,markdownDir:we,onOpenFile:r,...n,children:t})},img({src:e,alt:r,...i}){delete i.node;let a=typeof e==`string`?HG(e,we,t??we):null,o=a?p7(a,`read`,n):e;return(0,E.jsx)(`img`,{src:o,alt:r??``,loading:`lazy`,...i})}},children:fe})}):null]})]})}function E7({cwd:e,busy:t,error:n,onCancel:r,onConfirm:i}){let{t:a}=N();return(0,E.jsx)(Ax,{open:!0,onOpenChange:e=>{!e&&!t&&r()},children:(0,E.jsxs)(Px,{className:`w-[440px] gap-0 overflow-hidden rounded-lg p-0`,style:{zIndex:1100,maxWidth:`100%`},showCloseButton:!1,onPointerDownOutside:e=>{t&&e.preventDefault()},onEscapeKeyDown:e=>{t&&e.preventDefault()},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,gap:12,padding:`18px 18px 14px`},children:[(0,E.jsxs)(`svg`,{width:p[`5xl`],height:p[`5xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`var(--status-warning)`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,style:{flexShrink:0,marginTop:1},children:[(0,E.jsx)(`path`,{d:`M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10Z`}),(0,E.jsx)(`path`,{d:`m9 12 2 2 4-4`})]}),(0,E.jsxs)(`div`,{style:{minWidth:0},children:[(0,E.jsx)(Fx,{style:{fontSize:`var(--text-2xl)`,fontWeight:700,color:`var(--text)`,lineHeight:1.4},children:a(`trust.dialogTitle`)}),(0,E.jsx)(Ix,{style:{marginTop:7,fontSize:`var(--text-base)`,lineHeight:1.6,color:`var(--text-muted)`},children:a(`trust.dialogBody`)}),(0,E.jsx)(`code`,{style:{display:`block`,marginTop:10,padding:`8px 10px`,border:`1px solid var(--border)`,borderRadius:5,background:`var(--bg)`,color:`var(--text)`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,overflowWrap:`anywhere`},children:e}),n&&(0,E.jsx)(`div`,{role:`alert`,style:{marginTop:10,color:`var(--status-error)`,fontSize:`var(--text-base)`,lineHeight:1.5},children:n})]})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8,padding:`10px 18px`,borderTop:`1px solid var(--border)`},children:[(0,E.jsx)(kx,{type:`button`,variant:`outline`,onClick:r,disabled:t,className:`h-8 px-3 text-xs`,children:a(`trust.cancel`)}),(0,E.jsx)(kx,{type:`button`,onClick:i,disabled:t,className:`h-8 px-3 text-xs`,style:{cursor:t?`wait`:`pointer`},children:a(t?`trust.trusting`:`trust.trustProject`)})]})]})})}function D7({onCancel:e,onSelect:t,busy:n=!1,error:r}){let{t:i}=N(),[a,o]=(0,d.useState)(!0),[s,c]=(0,d.useState)(``),[l,u]=(0,d.useState)(null),[f,m]=(0,d.useState)(``),[h,g]=(0,d.useState)([]),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(``),[x,S]=(0,d.useState)(null),[C,w]=(0,d.useState)(!0),T=(0,d.useRef)(null),D=(0,d.useCallback)(async e=>{w(!0),S(null);try{let t=await wG(e),n=t.path??e??`/`;c(n),u(t.parentPath??null),m(n),g(t.directories??[]),v(t.drives??null),b(``)}catch(e){S(e instanceof Error?e.message:String(e))}finally{w(!1)}},[]);(0,d.useEffect)(()=>{D()},[D]);let O=e=>{e.preventDefault();let t=f.trim();t&&D(t)},k=f.trim()!==s,A=!!s&&!k&&!n,j=!!l||OG(s),M=y.trim().toLowerCase(),P=e=>!M||e.toLowerCase().includes(M),ee=_===null?[]:_.filter(e=>P(e.name)||P(e.path)),F=h.filter(e=>P(e.name));return(0,E.jsx)(Ax,{open:a,onOpenChange:t=>{!t&&!n&&(o(!1),e())},children:(0,E.jsxs)(Px,{className:`directory-picker-light flex w-[520px] max-w-[calc(100vw-16px)] flex-col gap-0 overflow-hidden p-0`,style:{height:`min(620px, calc(100dvh - 16px))`},showCloseButton:!1,onPointerDownOutside:e=>{n&&e.preventDefault()},onEscapeKeyDown:e=>{n&&e.preventDefault()},onOpenAutoFocus:e=>{e.preventDefault(),T.current?.focus()},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,flexShrink:0,padding:`12px 18px`,borderBottom:`1px solid var(--border)`},children:[(0,E.jsx)(Fx,{style:{fontWeight:700,fontSize:`var(--text-2xl)`,color:`var(--text)`},children:i(`directoryPicker.selectDirectory`)}),(0,E.jsx)(Mx,{asChild:!0,children:(0,E.jsx)(`button`,{type:`button`,disabled:n,title:i(`i18n.close`),"aria-label":i(`i18n.close`),style:{padding:`2px 6px`,border:0,background:`none`,color:`var(--text-muted)`,fontSize:`var(--text-5xl)`,lineHeight:1,cursor:n?`default`:`pointer`,opacity:n?.5:1},children:`×`})})]}),(0,E.jsxs)(`form`,{onSubmit:O,style:{display:`flex`,alignItems:`center`,gap:8,flexShrink:0,padding:`10px 14px`,borderBottom:`1px solid var(--border)`},children:[(0,E.jsx)(`button`,{className:`directory-picker-back`,type:`button`,onClick:()=>void D(l??void 0),disabled:C||!j,title:i(`directoryPicker.goToParent`),"aria-label":i(`directoryPicker.goToParent`),style:{width:36,height:36,padding:0,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,border:`1px solid var(--border)`,borderRadius:6,background:`#ffffff`,color:`var(--text-muted)`,cursor:j?`pointer`:`default`,opacity:j?1:.45},children:(0,E.jsx)(`svg`,{width:p[`3xl`],height:p[`3xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`m18 15-6-6-6 6`})})}),(0,E.jsx)(`label`,{htmlFor:`directory-path`,style:{position:`absolute`,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,border:0},children:i(`directoryPicker.directoryPath`)}),(0,E.jsx)(CG,{className:`directory-picker-path h-9 flex-1 font-mono text-xs`,id:`directory-path`,type:`text`,ref:T,value:f,placeholder:`/path/to/project or ~/project`,autoComplete:`off`,spellCheck:!1,style:TG,onChange:e=>{m(e.target.value),S(null)}}),(0,E.jsx)(`button`,{className:`directory-picker-action`,type:`submit`,disabled:C||!f.trim(),title:i(`directoryPicker.goToDirectory`),style:{minWidth:58,height:36,padding:`0 12px`,border:`1px solid var(--border)`,borderRadius:6,background:`#ffffff`,color:`var(--text-muted)`,cursor:C||!f.trim()?`default`:`pointer`,opacity:C||!f.trim()?.6:1},children:i(`directoryPicker.go`)})]}),(0,E.jsxs)(`div`,{className:`directory-picker-list`,style:{flex:1,minHeight:0,overflow:`auto`,padding:`8px 10px`},children:[C?(0,E.jsx)(`div`,{style:{padding:8,color:`var(--text-dim)`,fontSize:`var(--text-sm)`},children:i(`directoryPicker.loadingDirectories`)}):_===null?F.length>0?F.map(e=>(0,E.jsxs)(`button`,{className:`directory-picker-entry`,type:`button`,onClick:()=>void D(e.path),title:e.path,style:{width:`100%`,minHeight:30,display:`flex`,alignItems:`center`,gap:7,padding:`5px 8px`,border:0,borderRadius:5,background:`none`,color:`var(--text-muted)`,cursor:`pointer`,textAlign:`left`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`},children:[(0,E.jsx)(EG,{}),(0,E.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.name})]},e.path)):(0,E.jsx)(`div`,{style:{padding:8,color:`var(--text-dim)`,fontSize:`var(--text-sm)`},children:i(M?`directoryPicker.noMatches`:`directoryPicker.noSubdirectories`)}):ee.length>0?ee.map(e=>(0,E.jsxs)(`button`,{className:`directory-picker-entry`,type:`button`,onClick:()=>void D(e.path),title:e.path,style:{width:`100%`,minHeight:34,display:`flex`,alignItems:`center`,gap:7,padding:`6px 8px`,border:0,borderRadius:5,background:`none`,color:`var(--text-muted)`,cursor:`pointer`,textAlign:`left`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`},children:[(0,E.jsx)(DG,{}),(0,E.jsx)(`span`,{children:e.name})]},e.path)):(0,E.jsx)(`div`,{style:{padding:8,color:`var(--text-dim)`,fontSize:`var(--text-sm)`},children:i(M?`directoryPicker.noMatches`:`directoryPicker.noDrives`)}),(x||r)&&(0,E.jsx)(`div`,{style:{padding:`8px`,color:`var(--status-error)`,fontSize:`var(--text-sm)`},children:x??r})]}),(0,E.jsxs)(`div`,{className:`directory-picker-footer`,style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,gap:10,flexShrink:0,padding:`10px 18px`,borderTop:`1px solid var(--border)`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,flex:1,minWidth:0},children:[(0,E.jsxs)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,style:{color:`var(--text-dim)`,flexShrink:0},children:[(0,E.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,E.jsx)(`path`,{d:`m21 21-4.3-4.3`})]}),(0,E.jsx)(CG,{className:`directory-picker-search h-8 flex-1`,type:`text`,value:y,placeholder:i(`directoryPicker.search`),"aria-label":i(`directoryPicker.search`),autoComplete:`off`,spellCheck:!1,style:TG,onChange:e=>b(e.target.value)})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,flexShrink:0},children:[(0,E.jsx)(`button`,{className:`directory-picker-action`,type:`button`,onClick:e,disabled:n,style:{padding:`6px 14px`,border:`1px solid var(--border)`,borderRadius:6,background:`none`,color:`var(--text-muted)`,cursor:n?`default`:`pointer`,fontSize:`var(--text-lg)`},children:i(`i18n.cancel`)}),(0,E.jsx)(`button`,{className:`directory-picker-action`,type:`button`,onClick:()=>t(s),disabled:!A,title:i(k?`directoryPicker.openBeforeSelecting`:`directoryPicker.selectCurrentDirectory`),style:{padding:`6px 16px`,border:0,borderRadius:6,background:`var(--accent)`,color:`var(--on-accent)`,fontSize:`var(--text-lg)`,fontWeight:600,opacity:A?1:.6,cursor:A?`pointer`:`default`},children:i(n?`i18n.checking`:`directoryPicker.selectThisFolder`)})]})]})]})})}function O7({visible:e=!0,gap:t=4,items:n}){return e?(0,E.jsx)(`div`,{style:{display:`flex`,gap:t,flexShrink:0},children:n.map(e=>(0,E.jsx)(oi,{label:e.title,children:(0,E.jsx)(`button`,{type:`button`,onClick:e.onClick,disabled:e.disabled,"data-testid":e.testId,"aria-label":e.title,"aria-pressed":e.ariaPressed,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:32,height:32,padding:0,background:e.background??`transparent`,border:`1px solid ${e.borderColor??`var(--border)`}`,borderRadius:7,color:e.color??`var(--text-muted)`,cursor:e.disabled?`default`:`pointer`,flexShrink:0,opacity:e.disabled?.6:1,transition:`background 0.12s, color 0.12s, border-color 0.12s`,"--hover-bg":e.danger?`color-mix(in srgb, var(--status-error) 8%, transparent)`:`var(--bg-selected)`,"--hover-color":e.danger?`var(--status-error)`:`var(--accent)`,"--hover-border":e.danger?`color-mix(in srgb, var(--status-error) 35%, transparent)`:`color-mix(in srgb, var(--accent) 35%, transparent)`},className:e.skipHover?void 0:`hover-shift`,children:e.icon})},e.key))}):null}var k7=2;function A7({scrollStepPx:e=200,wrapperStyle:t,children:n,testId:r,hintTestId:i}){let a=(0,d.useRef)(null),[o,s]=(0,d.useState)({scrollHeight:0,clientHeight:0,scrollTop:0}),c=()=>{if(document.hidden)return;let e=a.current;e&&s({scrollHeight:e.scrollHeight,clientHeight:e.clientHeight,scrollTop:e.scrollTop})};(0,d.useLayoutEffect)(()=>{c();let e=a.current;if(!e)return;let t=new ResizeObserver(c);return t.observe(e),()=>t.disconnect()},[]);let{scrollHeight:l,clientHeight:u,scrollTop:f}=o,p=l-u>20,m=f<=k7,h=f+u>=l-k7,g=t=>{let n=a.current;if(!n)return;let r=Math.max(0,n.scrollHeight-n.clientHeight);n.scrollTo({top:Math.max(0,Math.min(r,n.scrollTop+t*e)),behavior:`smooth`})},_=e=>{let t=a.current;t&&t.scrollTo({top:e===`top`?0:Math.max(0,t.scrollHeight-t.clientHeight),behavior:`smooth`})};return(0,E.jsxs)(`div`,{style:{position:`relative`,...t},children:[(0,E.jsx)(`div`,{ref:a,"data-testid":r,onScroll:c,style:{position:`absolute`,inset:0,overflowY:`auto`,overflowX:`hidden`,padding:0},children:n}),p&&!m&&(0,E.jsx)(Bn,{direction:`up`,visible:!0,testId:i?`${i}-scroll-up`:void 0,onHover:()=>g(-1),onClick:()=>_(`top`)}),p&&!h&&(0,E.jsx)(Bn,{direction:`down`,visible:!0,testId:i?`${i}-scroll-down`:void 0,onHover:()=>g(1),onClick:()=>_(`bottom`)})]})}function j7({...e}){return(0,E.jsx)(fo,{"data-slot":`collapsible`,...e})}function M7({...e}){return(0,E.jsx)(oo,{"data-slot":`collapsible-trigger`,...e})}function N7({...e}){return(0,E.jsx)(co,{"data-slot":`collapsible-content`,...e})}function P7({title:e,titleTooltip:t,open:n,onToggle:r,collapsible:i=!0,actions:a,expandedFlex:o=`1 1 0`,style:s,children:c}){return(0,E.jsxs)(j7,{open:n,onOpenChange:r,style:{borderTop:`1px solid var(--border)`,display:`flex`,flexDirection:`column`,flex:n?o:`0 0 auto`,minHeight:0,overflow:`hidden`,...s},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,flexShrink:0,background:`var(--bg-panel)`},children:[(0,E.jsx)(oi,{label:t??e,children:(0,E.jsx)(M7,{asChild:!0,children:(0,E.jsxs)(`button`,{type:`button`,disabled:!i,style:{display:`flex`,alignItems:`center`,gap:6,flex:`0 0 auto`,height:36,padding:`0 12px`,background:`none`,border:`none`,color:`var(--text-muted)`,cursor:i?`pointer`:`default`,fontSize:`var(--text-base)`,fontWeight:600,letterSpacing:`0.05em`,textTransform:`none`,textAlign:`left`},children:[i&&(0,E.jsx)(`svg`,{width:p.xs,height:p.xs,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{transform:n?`rotate(90deg)`:`none`,transition:`transform 0.15s`,flexShrink:0},children:(0,E.jsx)(`polyline`,{points:`3 2 7 5 3 8`})}),(0,E.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e})]})})}),a&&(0,E.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,marginLeft:`auto`,minWidth:0,gap:6,flexShrink:1,paddingRight:4},children:a})]}),(0,E.jsx)(N7,{style:{display:`flex`,flexDirection:`column`,minHeight:0,flex:1},children:c})]})}function F7({title:e,titleTooltip:t,open:n,onToggle:r,collapsible:i=!0,actions:a,headerExtra:o,expandedFlex:s=`1 1 0`,scrollStepPx:c=200,testId:l,hintTestId:u,rootTestId:d,scrollStyle:f,style:p,children:m}){return(0,E.jsx)(`div`,{"data-testid":d,style:{display:`flex`,flexDirection:`column`,border:`1px solid var(--border)`,borderRadius:0,background:`var(--bg-panel)`,overflow:`hidden`,...p},children:(0,E.jsxs)(P7,{title:e,titleTooltip:t,open:n,onToggle:r,collapsible:i,actions:a,expandedFlex:s,style:{borderTop:`none`},children:[o,(0,E.jsx)(A7,{scrollStepPx:c,wrapperStyle:{flex:1,minHeight:0,...f},testId:l,hintTestId:u,children:m})]})})}function I7(e){return e.error?e.path.split(/[\\/]/).pop()||e.id:e.name||e.firstMessage.slice(0,50)||e.id.slice(0,12)}var L7=(e,t)=>e.replace(/\\/g,`/`)===t.replace(/\\/g,`/`),R7=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``).replace(/^[a-zA-Z]:/,e=>e.toLowerCase()),z7=`pi-web:unread-session-ids`;function B7(){if(typeof window>`u`)return new Set;try{let e=window.localStorage.getItem(z7);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function V7(e){if(!(typeof window>`u`))try{e.size===0?window.localStorage.removeItem(z7):window.localStorage.setItem(z7,JSON.stringify([...e]))}catch{}}function H7(){let[e,t]=(0,d.useState)(()=>B7());return(0,d.useEffect)(()=>{V7(e)},[e]),{unreadSessionIds:e,setUnreadSessionIds:t}}function U7(e){let{selectedCwd:t,selectedCwdProp:n,refreshKey:r,setSelectedCwd:i}=e,[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1),[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(``),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(!1),[v,y]=(0,d.useState)(null),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)(``),w=(0,d.useRef)(null),T=(0,d.useRef)(null),E=(0,d.useRef)(null);(0,d.useEffect)(()=>{n&&n!==E.current&&(E.current=n,i(n))},[n,i]);let D=(0,d.useCallback)(()=>{c(!1),u(!1),p(``),h(null),y(null),C(``)},[]),[O,k]=(0,d.useState)(0);(0,d.useLayoutEffect)(()=>{if(!t){o(null),x(null);return}let e=!1;return x(t),fetch(`/api/worktrees?cwd=${encodeURIComponent(t)}`).then(e=>e.json()).then(n=>{if(!e){if(x(null),n.error||!n.projectRoot){o(null);return}o({forCwd:t,projectRoot:n.projectRoot,isGit:n.isGit??!1,isTopLevel:n.isTopLevel??!1,worktrees:n.worktrees??[]})}}).catch(()=>{e||(x(null),o(null))}),()=>{e=!0}},[t,O,r]);let A=(0,d.useCallback)(async()=>{let e=f.trim();if(!(!e||g||!a)){_(!0),h(null);try{let t=await fetch(`/api/worktrees`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:a.projectRoot,branch:e})}),n=await t.json().catch(()=>({}));if(!t.ok||n.error||!n.path){h(n.error??`HTTP ${t.status}`);return}D(),o(t=>t&&{...t,forCwd:n.path,worktrees:[...t.worktrees,{path:n.path,branch:e,isMain:!1}]}),i(n.path),k(e=>e+1)}catch(e){h(e instanceof Error?e.message:String(e))}finally{_(!1)}}},[D,f,g,a,i]),j=(0,d.useCallback)(async(e,n)=>{if(!(!a||g)){_(!0),h(null);try{let r=await fetch(`/api/worktrees`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:a.projectRoot,path:e,force:n})}),o=await r.json().catch(()=>({}));if(!r.ok){if(o.dirty&&!n){y(e);return}h(o.error??`HTTP ${r.status}`);return}D(),t&&e&&L7(t,e)&&i(a.projectRoot),k(e=>e+1)}catch(e){h(e instanceof Error?e.message:String(e))}finally{_(!1)}}},[D,a,g,t,i]);return(0,d.useEffect)(()=>{let e=e=>{w.current&&!w.current.contains(e.target)&&D()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[D]),{worktreeState:a,worktreeLoadingCwd:b,wtDropdownOpen:s,setWtDropdownOpen:c,wtNewOpen:l,setWtNewOpen:u,wtNewBranch:f,setWtNewBranch:p,wtError:m,setWtError:h,wtBusy:g,wtConfirmRemove:v,setWtConfirmRemove:y,wtFilter:S,setWtFilter:C,wtDropdownRef:w,wtNewInputRef:T,closeWorktrees:D,handleCreateWorktree:A,handleRemoveWorktree:j}}function W7({wt:e,selectedCwd:t,homeDir:n,setSelectedCwd:r}){let{t:i}=N(),{worktreeState:a,wtFilter:o,setWtFilter:s,wtDropdownOpen:c,setWtDropdownOpen:l,wtDropdownRef:u,closeWorktrees:d,handleRemoveWorktree:f,wtConfirmRemove:m,setWtConfirmRemove:h,wtBusy:g,wtNewOpen:_,setWtNewOpen:v,wtNewBranch:y,setWtNewBranch:b,wtNewInputRef:x,handleCreateWorktree:S,wtError:C,setWtError:w}=e;if(!a)return null;let T=a.worktrees.find(e=>L7(e.path,t))??a.worktrees.find(e=>e.isMain),D=a.worktrees.length>=8,O=D&&o.trim()?a.worktrees.filter(e=>(e.branch??q7(e.path,n)).toLowerCase().includes(o.trim().toLowerCase())):a.worktrees;return(0,E.jsxs)(`div`,{ref:u,style:{position:`relative`,marginTop:6},children:[(0,E.jsxs)(`button`,{onClick:()=>l(e=>!e),title:T?i(`sidebar.switchWorktreeTitle`,{path:T.path}):i(`sidebar.switchWorktree`),style:{width:`100%`,height:29,boxSizing:`border-box`,display:`flex`,alignItems:`center`,gap:6,padding:`0 10px`,background:`var(--bg-input)`,border:`1px solid var(--border)`,borderRadius:7,cursor:`pointer`,fontSize:`var(--text-sm)`,lineHeight:1.35,color:`var(--text-muted)`,textAlign:`left`},children:[(0,E.jsxs)(`svg`,{width:p.sm,height:p.sm,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0,color:T&&!T.isMain?`var(--accent)`:`var(--text-dim)`},children:[(0,E.jsx)(`line`,{x1:`6`,y1:`3`,x2:`6`,y2:`15`}),(0,E.jsx)(`circle`,{cx:`18`,cy:`6`,r:`3`}),(0,E.jsx)(`circle`,{cx:`6`,cy:`18`,r:`3`}),(0,E.jsx)(`path`,{d:`M18 9a9 9 0 0 1-9 9`})]}),(0,E.jsx)(Y7,{text:T?T.branch??q7(T.path,n):`…`,style:{flex:1,fontFamily:`var(--font-mono)`,color:`var(--text)`}}),T?.isMain&&(0,E.jsx)(`span`,{style:{flexShrink:0,color:`var(--text-dim)`,fontSize:`var(--text-xs)`},children:i(`sidebar.main`)}),a.worktrees.length>1&&(0,E.jsx)(`span`,{style:{flexShrink:0,color:`var(--text-dim)`,fontSize:`var(--text-xs)`},children:a.worktrees.length}),(0,E.jsx)(`svg`,{width:`9`,height:`9`,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:(0,E.jsx)(`polyline`,{points:`2 3.5 5 6.5 8 3.5`})})]}),(0,E.jsxs)($7,{open:c,style:{position:`absolute`,top:`calc(100% + 4px)`,left:0,right:0,zIndex:100,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:8,boxShadow:`0 6px 20px var(--shadow-color)`,overflow:`hidden`},children:[D&&(0,E.jsx)(`div`,{style:{padding:`6px 8px`,borderBottom:`1px solid var(--border)`},children:(0,E.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(s(``),d())},placeholder:i(`sidebar.filterWorktrees`),autoFocus:!0,style:{width:`100%`,fontSize:`var(--text-sm)`,fontFamily:`var(--font-mono)`,padding:`5px 8px`,border:`1px solid var(--border)`,borderRadius:5,outline:`none`,background:`var(--bg)`,color:`var(--text)`,boxSizing:`border-box`}})}),(0,E.jsxs)(`div`,{style:{maxHeight:`min(40vh, 300px)`,overflowY:`auto`},children:[O.map(e=>{let o=L7(e.path,t)||e.isMain&&!a.worktrees.some(e=>L7(e.path,t));return m===e.path?(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,padding:`7px 10px`,borderBottom:`1px solid var(--border)`,background:`color-mix(in srgb, var(--status-error) 6%, transparent)`},children:[(0,E.jsx)(`span`,{style:{flex:1,fontSize:`var(--text-sm)`,color:`var(--text)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:i(`sidebar.forceRemoveCheckout`)}),(0,E.jsx)(`button`,{onClick:()=>void f(e.path,!0),disabled:g,style:{padding:`3px 9px`,background:`var(--status-error)`,border:`none`,borderRadius:5,color:`var(--on-error)`,fontSize:`var(--text-sm)`,fontWeight:600,cursor:`pointer`,flexShrink:0},children:i(`sidebar.force`)}),(0,E.jsx)(`button`,{onClick:()=>h(null),style:{padding:`3px 9px`,background:`var(--bg-hover)`,border:`1px solid var(--border)`,borderRadius:5,color:`var(--text-muted)`,fontSize:`var(--text-sm)`,cursor:`pointer`,flexShrink:0},children:i(`sidebar.cancel`)})]},e.path):(0,E.jsxs)(`div`,{className:`wt-row`,style:{display:`flex`,alignItems:`center`,borderBottom:`1px solid var(--border)`},children:[(0,E.jsxs)(`button`,{onClick:()=>{r(e.path),d()},title:e.path,style:{flex:1,minWidth:0,display:`flex`,alignItems:`center`,gap:7,padding:`8px 10px`,background:`var(--bg)`,border:`none`,color:o?`var(--text)`:`var(--text-muted)`,cursor:`pointer`,textAlign:`left`,fontSize:`var(--text-sm)`,fontFamily:`var(--font-mono)`},children:[o?(0,E.jsx)(`svg`,{width:p.xs,height:p.xs,viewBox:`0 0 10 10`,fill:`none`,stroke:`var(--accent)`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:(0,E.jsx)(`polyline`,{points:`1.5 5 4 7.5 8.5 2.5`})}):(0,E.jsx)(`span`,{style:{width:10,flexShrink:0}}),(0,E.jsx)(Y7,{text:e.branch??q7(e.path,n),style:{flex:1}}),e.isMain&&(0,E.jsx)(`span`,{style:{flexShrink:0,color:`var(--text-dim)`,fontSize:`var(--text-xs)`},children:i(`sidebar.main`)})]}),!e.isMain&&(0,E.jsx)(`button`,{onClick:()=>void f(e.path,!1),disabled:g,title:i(`sidebar.removeWorktreeTitle`,{path:e.path}),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:34,height:28,padding:0,marginRight:4,background:`none`,border:`none`,color:`var(--text-dim)`,cursor:`pointer`,borderRadius:5,flexShrink:0,transition:`color 0.12s, background 0.12s`,"--hover-color":`var(--status-error)`,"--hover-bg":`color-mix(in srgb, var(--status-error) 8%, transparent)`},className:`hover-shift`,children:(0,E.jsxs)(`svg`,{width:p.base,height:p.base,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`polyline`,{points:`3 6 5 6 21 6`}),(0,E.jsx)(`path`,{d:`M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6`}),(0,E.jsx)(`path`,{d:`M10 11v6M14 11v6`}),(0,E.jsx)(`path`,{d:`M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2`})]})})]},e.path)}),D&&O.length===0&&o.trim()&&(0,E.jsx)(`div`,{style:{padding:`8px 10px`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`},children:i(`sidebar.noMatchingWorktrees`)})]}),_?(0,E.jsxs)(`div`,{style:{padding:`6px 8px`},children:[(0,E.jsx)(`input`,{ref:x,value:y,onChange:e=>{b(e.target.value),w(null)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),S()),e.key===`Escape`&&(v(!1),b(``),w(null))},placeholder:i(`sidebar.branchName`),style:{width:`100%`,fontSize:`var(--text-sm)`,fontFamily:`var(--font-mono)`,padding:`5px 8px`,border:`1px solid var(--accent)`,borderRadius:5,outline:`none`,background:`var(--bg)`,color:`var(--text)`,boxSizing:`border-box`}}),(0,E.jsxs)(`div`,{style:{display:`flex`,gap:5,marginTop:5},children:[(0,E.jsx)(`button`,{onClick:()=>void S(),disabled:g||!y.trim(),style:{flex:1,padding:`4px 0`,background:`var(--accent)`,border:`none`,borderRadius:5,color:`var(--on-accent)`,fontSize:`var(--text-sm)`,fontWeight:600,cursor:g||!y.trim()?`not-allowed`:`pointer`,opacity:g||!y.trim()?.65:1},children:i(g?`sidebar.creating`:`sidebar.create`)}),(0,E.jsx)(`button`,{onClick:()=>{v(!1),b(``),w(null)},style:{flex:1,padding:`4px 0`,background:`var(--bg-hover)`,border:`1px solid var(--border)`,borderRadius:5,color:`var(--text-muted)`,fontSize:`var(--text-sm)`,cursor:`pointer`},children:i(`sidebar.cancel`)})]})]}):(0,E.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),v(!0),w(null),setTimeout(()=>x.current?.focus(),0)},title:i(`sidebar.createWorktreeTitle`),style:{display:`flex`,alignItems:`center`,gap:7,width:`100%`,padding:`8px 10px`,background:`none`,border:`none`,color:`var(--text-muted)`,cursor:`pointer`,textAlign:`left`,fontSize:`var(--text-sm)`},children:[(0,E.jsxs)(`svg`,{width:p.xs,height:p.xs,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.1`,strokeLinecap:`round`,style:{flexShrink:0},children:[(0,E.jsx)(`line`,{x1:`5`,y1:`1`,x2:`5`,y2:`9`}),(0,E.jsx)(`line`,{x1:`1`,y1:`5`,x2:`9`,y2:`5`})]}),(0,E.jsx)(`span`,{children:i(`sidebar.newWorktree`)})]}),C&&(0,E.jsx)(`div`,{style:{padding:`5px 10px 8px`,color:`var(--status-error)`,fontSize:`var(--text-sm)`,lineHeight:1.35,overflowWrap:`anywhere`},children:C})]})]})}function G7(e,t){let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/6e4),a=Math.floor(r/36e5),o=Math.floor(r/864e5);return i<1?t(`sidebar.justNow`):i<60?t(`sidebar.minutesAgo`,{count:i}):a<24?t(`sidebar.hoursAgo`,{count:a}):o<7?t(`sidebar.daysAgo`,{count:o}):n.toLocaleDateString()}function K7(e){let t=new Map;for(let n of e){let e=n.projectRoot??n.cwd;if(!e)continue;let r=t.get(e);(!r||n.modified>r)&&t.set(e,n.modified)}return[...t.entries()].sort((e,t)=>t[1].localeCompare(e[1])).map(([e])=>e)}function q7(e,t){return t&&e.startsWith(t)?`~${e.slice(t.length)}`:e}function J7(e){let t=e.split(/[\\/]+/).filter(Boolean);return t.length?t[t.length-1]:e}function Y7({text:e,style:t}){return(0,E.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,display:`block`,minWidth:0,lineHeight:1.35,direction:`rtl`,textAlign:`left`,...t},children:(0,E.jsx)(`span`,{style:{unicodeBidi:`plaintext`},children:e})})}function X7({session:e}){return(0,E.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:4,color:`var(--danger)`,minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},title:`${e.path}: ${e.error}`,children:[(0,E.jsxs)(`svg`,{width:p.xs,height:p.xs,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,style:{flexShrink:0},children:[(0,E.jsx)(`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`}),(0,E.jsx)(`path`,{d:`M12 9v4`}),(0,E.jsx)(`path`,{d:`M12 17h.01`})]}),e.error]})}var Z7=140,Q7=2e3;function $7({open:e,children:t,style:n}){let[r,i]=(0,d.useState)(e),[a,o]=(0,d.useState)(e);return(0,d.useEffect)(()=>{let t,n;return e?(i(!0),o(!1),t=window.requestAnimationFrame(()=>{t=window.requestAnimationFrame(()=>o(!0))})):(o(!1),n=setTimeout(()=>i(!1),Z7)),()=>{t!==void 0&&window.cancelAnimationFrame(t),n&&clearTimeout(n)}},[e]),r?(0,E.jsx)(`div`,{style:{...n,opacity:+!!a,transform:a?`translateY(0) scale(1)`:`translateY(-8px) scale(0.96)`,transformOrigin:`top center`,transition:`opacity ${Z7}ms ease, transform ${Z7}ms ease`,pointerEvents:e?`auto`:`none`},children:t}):null}function e9(e){let t=new Map;for(let n of e)t.set(n.id,{session:n,children:[]});let n=new Map;for(let t of e)t.parentSessionId&&n.set(t.id,t.parentSessionId);function r(e){let r=n.get(e),i=new Set;for(;r;){if(i.has(r))return null;if(i.add(r),t.has(r))return r;r=n.get(r)}return null}let i=[];for(let e of t.values()){let n=r(e.session.id);n?t.get(n).children.push(e):i.push(e)}let a=e=>{e.sort((e,t)=>t.session.modified.localeCompare(e.session.modified)),e.forEach(e=>a(e.children))};return a(i),i}function t9({selectedSessionId:e,selectedSession:t,onSelectSession:n,onNewSession:r,initialSessionId:i,skipInitialProjectSelection:a,onInitialRestoreDone:o,refreshKey:s,onSessionDeleted:c,selectedCwd:l,onCwdChange:u,savedWorkspaces:f,onSavedWorkspacesChange:m,onOpenFile:h}){let{t:g}=N(),[_,v]=(0,d.useState)([]),[y,b]=(0,d.useState)(!0),[x,S]=(0,d.useState)(null),[C,w]=(0,d.useState)(null),[T,D]=(0,d.useState)(``),[O,k]=(0,d.useState)(!1),[A,j]=(0,d.useState)(``),[M,P]=(0,d.useState)(null),[ee,F]=(0,d.useState)(!1),te=U7({selectedCwd:C,selectedCwdProp:l,refreshKey:s,setSelectedCwd:w}),{worktreeState:ne,worktreeLoadingCwd:re}=te,[ie,ae]=(0,d.useState)(!1),[oe,I]=(0,d.useState)(``),L=(0,d.useRef)(null);(0,d.useEffect)(()=>{ie&&L.current?.focus()},[ie]);let[se,R]=(0,d.useState)(!1),[ce,le]=(0,d.useState)(()=>new Set),ue=(0,d.useCallback)(e=>{le(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),de=(0,d.useCallback)(e=>{le(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),Pt(e)},[]),{unreadSessionIds:fe,setUnreadSessionIds:pe}=H7(),me=Jq(),{runningSessionIds:he,runningPhases:ge,runningPhaseSince:_e,runningBusySince:ve,setRunningSessionIds:ye,runningPollAuthoritativeRef:be}=Kt(),Se=(0,d.useRef)(new Set),Ce=(0,d.useRef)(null),we=(0,d.useRef)(0),Te=(0,d.useCallback)(async(e=!1,t=!1)=>{try{e&&b(!0);let n=t?await xe.refresh():await xe.load();v(n.sessions),be.current||ye(new Set(n.runningSessionIds??[]));let r=new Set(n.sessions.map(e=>e.id));pe(e=>{if(e.size===0)return e;let t=new Set([...e].filter(e=>r.has(e)));return t.size===e.size?e:t}),S(null),e||(R(!0),Ce.current&&clearTimeout(Ce.current),Ce.current=setTimeout(()=>R(!1),2e3))}catch(e){S(String(e))}finally{e&&b(!1)}},[pe,ye,be]),Ee=(0,d.useRef)(!1);(0,d.useEffect)(()=>{let e=!Ee.current;Ee.current=!0,Te(e,e)},[Te,s]),(0,d.useEffect)(()=>{V7(fe)},[fe]),(0,d.useEffect)(()=>{let t=[...Se.current].filter(t=>!he.has(t)&&t!==e),n=[...he];if((t.length>0||n.length>0)&&pe(e=>{let r=new Set(e);return n.forEach(e=>r.delete(e)),t.forEach(e=>r.add(e)),r}),t.length>0&&Te(!1),[...he].filter(e=>!_.some(t=>t.id===e)).length>0){let e=Date.now();e-we.current>=Q7&&(we.current=e,Te(!1,!0))}Se.current=he},[he,e,_,Te,pe]),(0,d.useEffect)(()=>{e&&(Gq(e),pe(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}))},[e,pe]),(0,d.useEffect)(()=>{fetch(`/api/home`).then(e=>e.json()).then(e=>{e.home&&D(e.home)}).catch(()=>{})},[]);let De=(0,d.useRef)(!1),Oe=(0,d.useCallback)(e=>e?ne&&ne.forCwd&&L7(ne.forCwd,e)||ne?.worktrees.some(t=>L7(t.path,e))?ne.projectRoot:_.find(t=>t.cwd&&L7(t.cwd,e))?.projectRoot??e:null,[ne,_]),ke=(0,d.useRef)(null);(0,d.useEffect)(()=>{ke.current!==C&&(ke.current=C,u?.(C,Oe(C)))},[C,u,Oe]),(0,d.useEffect)(()=>{if(!(_.length===0||a)&&C===null){if(i&&!De.current){De.current=!0;let e=_.find(e=>e.id===i);if(e){w(e.cwd),ue(e.id),n(e,!0);return}o?.()}let e=K7(_);e.length>0&&w(e[0])}},[_,C,i,a,n,o,ue]);let Ae=(0,d.useCallback)(async e=>{let t=(e??A).trim();if(!(!t||ee)){F(!0),P(null);try{let e=await fetch(`/api/cwd/validate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:t})}),n=await e.json().catch(()=>({}));if(!e.ok||n.error){P(n.error??`HTTP ${e.status}`);return}let r=n.cwd??t;if(w(r),k(!1),j(``),m){let e=f??[];e.some(e=>R7(e)===R7(r))||m([...e,r])}}catch(e){P(e instanceof Error?e.message:String(e))}finally{F(!1)}}},[A,ee,f,m]),je=(0,d.useCallback)(async e=>{try{if((await fetch(`/api/sessions/${encodeURIComponent(e.id)}`,{method:`HEAD`})).status===404){S(g(`sidebar.sessionDeleted`)),Te(!1,!0);return}}catch{}e.cwd&&w(e.cwd),ue(e.id),n(e)},[n,g,Te,ue]),Me=(0,d.useCallback)(e=>{let t=e??C;if(!t)return;let n=typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`;r?.(n,t)},[C,r]),[Ne,Pe]=(0,d.useState)({}),[Fe,Ie]=(0,d.useState)(null),[Le,Re]=(0,d.useState)(null),[ze,Be]=(0,d.useState)(!1),Ve=Oe(C),He=_,Ue=!!(ne?.isGit&&ne.isTopLevel&&C&&Ve===ne.projectRoot),We=(C&&ne&&Ve===ne.projectRoot&&!Ue?ne.isGit?{label:g(`sidebar.openRepoRoot`),title:g(`sidebar.openRepoRootTitle`)}:{label:g(`sidebar.gitRepoRootOnly`),title:g(`sidebar.gitRepoRootOnlyTitle`)}:null)??(C&&re===C&&!Ue?{label:g(`sidebar.worktrees`),title:g(`sidebar.checkingWorktrees`)}:null),Ge=(0,d.useCallback)(async e=>{Re(null),Be(!0);try{await Promise.all(e.sessions.map(e=>fetch(`/api/sessions/${encodeURIComponent(e.id)}`,{method:`DELETE`}).then(t=>{t.ok||console.error(`[sidebar] failed to delete ${e.id}:`,t.status)}).catch(t=>console.error(`[sidebar] failed to delete ${e.id}:`,t))));for(let t of e.sessions)c?.(t.id);let t=f??[];m&&t.some(t=>R7(t)===R7(e.root))&&m(t.filter(t=>R7(t)!==R7(e.root))),Te(!1,!0)}finally{Be(!1)}},[c,Te,f,m]),Ke=(0,d.useMemo)(()=>{let e=t&&!He.some(e=>e.id===t.id)?[{...t,projectRoot:t.projectRoot??Oe(t.cwd)??void 0},...He]:He,n=new Map,r=new Map;for(let t of e){let e=t.projectRoot??t.cwd??`unknown`,i=e===`unknown`?e:R7(e);n.has(i)||(n.set(i,[]),r.set(i,e)),n.get(i).push(t)}let i=[...n.entries()].map(([e,t])=>({root:r.get(e)??e,sessions:t})).sort((e,t)=>{let n=e=>Math.max(...e.map(e=>{let t=new Date(e.modified).getTime();return Number.isNaN(t)?0:t}));return n(t.sessions)-n(e.sessions)}),a=[];if(C){let e=Oe(C);e&&!n.has(R7(e))&&a.push({root:e,sessions:[]})}let o=new Set([...n.keys()]);for(let e of a)o.add(R7(e.root));let s=[];for(let e of f??[]){let t=R7(e);o.has(t)||(o.add(t),s.push({root:e,sessions:[]}))}return[...a,...i,...s]},[He,C,Oe,t,f]),qe=oe.trim().toLowerCase(),Je=(0,d.useMemo)(()=>qe?Ke.map(e=>({...e,sessions:e.sessions.filter(e=>I7(e).toLowerCase().includes(qe))})).filter(e=>e.sessions.length>0):Ke,[Ke,qe]);return(0,E.jsxs)(`div`,{"data-testid":`session-sidebar`,style:{display:`flex`,flexDirection:`column`,height:`100%`,overflow:`hidden`},children:[O&&(0,E.jsx)(D7,{busy:ee,error:M,onCancel:()=>{k(!1),P(null)},onSelect:e=>void Ae(e)}),(0,E.jsxs)(F7,{title:g(`sidebar.workspace`),open:!0,onToggle:()=>{},collapsible:!1,testId:`workspace-scroll`,hintTestId:`workspace`,scrollStyle:{flex:`1 1 auto`,minHeight:80,background:`var(--bg)`},style:{flex:1,minHeight:0},actions:(0,E.jsx)(O7,{items:[{key:`search`,testId:`workspace-search-toggle`,onClick:()=>{ie&&I(``),ae(e=>!e)},title:g(`sidebar.searchSessions`),ariaPressed:ie,color:ie?`var(--accent)`:`var(--text-muted)`,background:ie?`var(--bg-selected)`:void 0,icon:(0,E.jsx)(Hr,{size:p.lg})},{key:`new-workspace`,testId:`new-workspace`,onClick:()=>k(!0),title:g(`sidebar.newWorkspace`),color:`var(--text-muted)`,icon:(0,E.jsx)(xr,{size:p.xl})},{key:`refresh`,testId:`session-refresh`,onClick:()=>Te(!1,!0),title:g(`sidebar.refresh`),skipHover:se,color:se?`var(--status-success)`:`var(--text-muted)`,background:se?`color-mix(in srgb, var(--status-success) 18%, transparent)`:void 0,icon:se?(0,E.jsx)(ur,{size:p.xl,color:`var(--status-success)`,strokeWidth:2.5}):(0,E.jsx)(Rr,{size:p.xl})}]}),headerExtra:(0,E.jsxs)(E.Fragment,{children:[ie&&(0,E.jsxs)(`div`,{"data-testid":`workspace-search`,style:{display:`flex`,alignItems:`center`,gap:4,width:`100%`,minWidth:0,padding:`4px 8px`,background:`var(--bg)`,borderBottom:`1px solid var(--border)`,boxSizing:`border-box`},children:[(0,E.jsx)(Hr,{size:p.lg,color:`var(--text-muted)`,style:{flexShrink:0}}),(0,E.jsx)(`input`,{ref:L,value:oe,onChange:e=>I(e.target.value),placeholder:g(`sidebar.searchSessionsPlaceholder`),"aria-label":g(`sidebar.searchSessions`),style:{flex:1,minWidth:0,background:`transparent`,border:`none`,outline:`none`,color:`var(--text)`,fontSize:`var(--text-sm)`}}),oe&&(0,E.jsx)(`button`,{type:`button`,onClick:()=>{I(``),L.current?.focus()},"aria-label":g(`chat.clearSearch`),style:{border:`none`,background:`transparent`,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-sm)`,flexShrink:0,padding:0},children:`✕`})]}),Ue&&(0,E.jsx)(W7,{wt:te,selectedCwd:C,homeDir:T,setSelectedCwd:w}),We&&(0,E.jsxs)(`button`,{type:`button`,"aria-disabled":`true`,tabIndex:-1,title:We.title,style:{width:`100%`,height:29,boxSizing:`border-box`,marginTop:6,display:`flex`,alignItems:`center`,gap:6,padding:`0 10px`,border:`1px solid var(--border)`,borderRadius:7,background:`var(--bg-hover)`,color:`var(--text-dim)`,fontSize:`var(--text-sm)`,lineHeight:1.35,whiteSpace:`nowrap`,textAlign:`left`,cursor:`default`,opacity:.82},children:[(0,E.jsxs)(`svg`,{width:p.sm,height:p.sm,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,E.jsx)(`line`,{x1:`6`,y1:`3`,x2:`6`,y2:`15`}),(0,E.jsx)(`circle`,{cx:`18`,cy:`6`,r:`3`}),(0,E.jsx)(`circle`,{cx:`6`,cy:`18`,r:`3`}),(0,E.jsx)(`path`,{d:`M18 9a9 9 0 0 1-9 9`})]}),(0,E.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`},children:We.label})]})]}),children:[y&&(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`16px 14px`,color:`var(--text-muted)`,fontSize:`var(--text-base)`},children:[(0,E.jsx)(`div`,{style:{width:14,height:14,border:`2px solid var(--border)`,borderTopColor:`var(--text-dim)`,borderRadius:`50%`,animation:`spin 0.8s linear infinite`,flexShrink:0}}),g(`sidebar.loading`)]}),x&&(0,E.jsx)(`div`,{style:{padding:`12px 14px`,color:`var(--status-error)`,fontSize:`var(--text-base)`},children:x}),!y&&!x&&qe&&Je.length===0&&(0,E.jsx)(`div`,{style:{padding:`16px 14px`,color:`var(--text-muted)`,fontSize:`var(--text-base)`},children:g(`sidebar.searchSessionsNoResults`)}),Je.map(t=>{let n=t.sessions.some(t=>t.id===e)||t.root===Ve;return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(n9,{group:t,groupSelected:n,hoveredGroup:Fe,confirmDeleteGroup:Le,deletingGroup:ze,runningSessionIds:he,interactionBadges:me,collapsed:!!Ne[t.root],setHoveredGroup:Ie,setGroupCollapsed:Pe,setConfirmDeleteGroup:Re,handleDeleteGroup:Ge,handleNewSession:Me,copyText:bY}),(qe||!Ne[t.root])&&(t.sessions.length===0?(0,E.jsx)(`div`,{style:{padding:`10px 14px`,color:`var(--text-muted)`,fontSize:`var(--text-sm)`},children:g(`sidebar.noSessions`)}):e9(t.sessions).map(t=>(0,E.jsx)(r9,{node:t,selectedSessionId:e,runningSessionIds:he,runningPhases:ge,runningPhaseSince:_e,runningBusySince:ve,unreadSessionIds:fe,seenSessionIds:ce,interactionBadges:me,onSelectSession:je,onRenamed:()=>Te(!1,!0),onSessionDeleted:e=>{c?.(e),Te(!1,!0)},onUnseen:de,depth:0},t.session.id)))]},t.root)})]})]})}function n9({group:e,groupSelected:t,hoveredGroup:n,confirmDeleteGroup:r,deletingGroup:i,runningSessionIds:a,interactionBadges:o,collapsed:s,setHoveredGroup:c,setGroupCollapsed:l,setConfirmDeleteGroup:u,handleDeleteGroup:d,handleNewSession:f,copyText:m}){let{t:h}=N(),g=e.sessions.some(e=>a.has(e.id)),_=e.sessions.some(e=>o.has(e.id));return(0,E.jsx)(`div`,{"data-testid":`workspace-group-header`,onMouseEnter:()=>c(e.root),onMouseLeave:()=>c(null),style:{display:`flex`,alignItems:`center`,gap:4,height:40,padding:`0 2px`,boxSizing:`border-box`,fontSize:`var(--text-base)`,fontFamily:`var(--font-mono)`,color:`var(--text)`,fontWeight:600,textTransform:`none`,letterSpacing:.6,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,cursor:r===e.root?`default`:`pointer`,background:r===e.root?`color-mix(in srgb, var(--status-error) 6%, transparent)`:n===e.root?`var(--bg-hover)`:`var(--bg)`},onClick:r===e.root?void 0:()=>{l(t=>({...t,[e.root]:!t[e.root]}))},children:r===e.root?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`span`,{style:{flex:1,minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:h(`sidebar.deleteWorkspace`,{count:e.sessions.length})}),(0,E.jsxs)(`div`,{style:{display:`flex`,gap:5,flexShrink:0},children:[(0,E.jsx)(`button`,{onClick:t=>{t.stopPropagation(),d(e)},disabled:i,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:4,height:22,padding:`0 9px`,background:`var(--status-error)`,border:`none`,borderRadius:5,color:`var(--on-error)`,cursor:i?`default`:`pointer`,opacity:i?.6:1,fontSize:`var(--text-sm)`,fontWeight:600,whiteSpace:`nowrap`},children:h(`sidebar.delete`)}),(0,E.jsx)(`button`,{onClick:e=>{e.stopPropagation(),u(null)},disabled:i,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:22,padding:`0 9px`,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:5,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-sm)`,fontWeight:500,whiteSpace:`nowrap`},children:h(`sidebar.cancel`)})]})]}):(0,E.jsx)(E.Fragment,{children:(0,E.jsxs)(`div`,{style:{display:`inline-flex`,alignItems:`center`,gap:6,flex:1,minWidth:0,height:38,boxSizing:`border-box`,padding:`0 8px`,border:`none`,borderRadius:0,background:_&&s?`linear-gradient(180deg, transparent calc(100% - 25px), color-mix(in srgb, var(--border) 25%, transparent) 100%)`:g&&s?`linear-gradient(90deg, transparent 13%, color-mix(in srgb, var(--accent) 18%, transparent) 25%, transparent 37%, transparent 63%, color-mix(in srgb, var(--shine-highlight) 50%, transparent) 75%, transparent 87%), linear-gradient(180deg, transparent calc(100% - 25px), color-mix(in srgb, var(--border) 25%, transparent) 100%)`:`linear-gradient(180deg, transparent calc(100% - 25px), color-mix(in srgb, var(--border) 25%, transparent) 100%)`,backgroundSize:g&&s&&!_?`200% 100%, auto`:void 0,animation:_&&s?`interaction-bg-blink 1s ease-in-out infinite`:g&&s?`pi-status-shine 1.5s linear infinite`:void 0,boxShadow:`0 2px 8px var(--shadow-color)`,margin:`0 -2px`},children:[(0,E.jsxs)(`span`,{style:{position:`relative`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:30,height:22,flexShrink:0},children:[(0,E.jsx)(`svg`,{width:`30`,height:`22`,viewBox:`0 0 24 24`,fill:t?`color-mix(in srgb, var(--accent) 18%, transparent)`:`var(--bg)`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:t?`var(--accent)`:`var(--text-muted)`,opacity:.95},children:(0,E.jsx)(`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`})}),(0,E.jsx)(`span`,{style:{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -38%)`,color:`var(--text-muted)`,fontSize:`var(--text-xs)`,fontWeight:400,lineHeight:1,textAlign:`center`,fontVariantNumeric:`tabular-nums`,userSelect:`none`},children:e.sessions.length})]}),(0,E.jsx)(oi,{label:e.root,wrapperStyle:{flex:1,minWidth:0,overflow:`hidden`},children:(0,E.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,maxWidth:`100%`,lineHeight:`20px`},children:J7(e.root)})}),n===e.root&&(0,E.jsx)(O7,{items:[{key:`new-session`,onClick:t=>{t.stopPropagation(),f(e.root)},title:h(`sidebar.newSessionTitle`,{path:e.root}),icon:(0,E.jsx)(Ir,{size:p.base})},{key:`copy-path`,onClick:t=>{t.stopPropagation(),m(e.root)},title:h(`sidebar.copyPath`),icon:(0,E.jsx)(hr,{size:p.base})},{key:`delete-workspace`,onClick:t=>{t.stopPropagation(),u(e.root)},title:h(`sidebar.deleteWorkspaceTitle`),danger:!0,icon:(0,E.jsx)(Xr,{size:p.base})}]})]})})})}function r9({node:e,selectedSessionId:t,runningSessionIds:n,runningPhases:r,runningPhaseSince:i,runningBusySince:a,unreadSessionIds:o,seenSessionIds:s,interactionBadges:c,onSelectSession:l,onRenamed:u,onSessionDeleted:f,onUnseen:p,depth:m}){let[h,g]=(0,d.useState)(!1),_=e.children.length>0;return(0,E.jsxs)(`div`,{style:{paddingBottom:1,backgroundImage:`linear-gradient(90deg, transparent, var(--border), transparent)`,backgroundPosition:`0 100%`,backgroundSize:`100% 1px`,backgroundRepeat:`no-repeat`},children:[(0,E.jsxs)(`div`,{style:{position:`relative`},children:[m>0&&(0,E.jsx)(`div`,{style:{position:`absolute`,left:m*12+6,top:0,bottom:0,width:1,background:`var(--border)`,pointerEvents:`none`}}),(0,E.jsx)(a9,{session:e.session,isSelected:e.session.id===t,isRunning:n.has(e.session.id),phase:r[e.session.id],phaseSince:i[e.session.id],busySince:a[e.session.id],isUnread:o.has(e.session.id),isSeen:s.has(e.session.id),hasInteractionBadge:c.has(e.session.id),onClick:()=>l(e.session),onRenamed:u,onDeleted:e=>f?.(e),onUnseen:p,depth:m,hasChildren:_,collapsed:h,onToggleCollapse:()=>g(e=>!e)})]}),_&&!h&&(0,E.jsx)(`div`,{children:e.children.map(e=>(0,E.jsx)(r9,{node:e,selectedSessionId:t,runningSessionIds:n,runningPhases:r,runningPhaseSince:i,runningBusySince:a,unreadSessionIds:o,seenSessionIds:s,interactionBadges:c,onSelectSession:l,onRenamed:u,onSessionDeleted:f,onUnseen:p,depth:m+1},e.session.id))})]})}function i9(){let{t:e}=N();return(0,E.jsx)(`span`,{title:e(`sidebar.newActivity`),"aria-label":e(`sidebar.newSessionActivity`),style:{width:14,height:14,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,color:`var(--accent)`},children:(0,E.jsxs)(`svg`,{width:p.xl,height:p.xl,viewBox:`0 0 14 14`,fill:`none`,"aria-hidden":`true`,style:{display:`block`},children:[(0,E.jsx)(`circle`,{cx:`7`,cy:`7`,r:`2.5`,fill:`currentColor`}),(0,E.jsx)(`circle`,{cx:`7`,cy:`7`,r:`3`,stroke:`currentColor`,strokeWidth:`1.4`,opacity:`0.32`,style:{transformOrigin:`center`,animation:`session-ring-pulse 1.6s ease-in-out infinite`}})]})})}function a9({session:e,isSelected:t,isRunning:n,phase:r,phaseSince:i,busySince:a,isUnread:o,isSeen:s=!0,hasInteractionBadge:c=!1,onClick:l,onRenamed:u,onDeleted:f,onUnseen:m,depth:h=0,hasChildren:g=!1,collapsed:_=!1,onToggleCollapse:v}){let{t:y}=N(),b=qt(!!(n&&r),i),x=qt(!!n,a),[S,C]=(0,d.useState)(!1),[w,T]=(0,d.useState)(!1),[D,O]=(0,d.useState)(``),[k,A]=(0,d.useState)(!1),[j,M]=(0,d.useState)(!1),P=(0,d.useRef)(null),ee=e.error?e.path.split(/[\\/]/).pop()||e.id:e.name||e.firstMessage.slice(0,50)||e.id.slice(0,12),F=(0,d.useCallback)(t=>{t.stopPropagation(),O(e.name??``),T(!0),setTimeout(()=>P.current?.select(),0)},[e.name]),te=(0,d.useCallback)(async()=>{let t=D.trim();if(T(!1),t!==(e.name??``))try{await fetch(`/api/sessions/${encodeURIComponent(e.id)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:t})}),u?.()}catch{}},[D,e.id,e.name,u]),ne=(0,d.useCallback)(async()=>{A(!1),M(!0);try{await fetch(`/api/sessions/${encodeURIComponent(e.id)}`,{method:`DELETE`}),f?.(e.id)}catch{M(!1)}},[e.id,f]),re=(0,d.useCallback)(e=>{e.stopPropagation(),e.shiftKey?ne():A(!0)},[ne]),ie=(0,d.useCallback)(e=>{e.stopPropagation(),ne()},[ne]),ae=(0,d.useCallback)(e=>{e.stopPropagation(),A(!1)},[]);return(0,E.jsx)(`div`,{"data-testid":`session-item`,"data-session-id":e.id,onClick:k||w?void 0:l,title:c?y(`sidebar.interactionBadge`):void 0,onMouseEnter:()=>C(!0),onMouseLeave:()=>{C(!1)},style:{height:54,animation:c?`interaction-bg-blink 1s ease-in-out infinite`:void 0,display:`flex`,alignItems:`center`,paddingLeft:h>0?h*12+14:14,paddingRight:8,cursor:k||w?`default`:`pointer`,backgroundColor:k?`color-mix(in srgb, var(--status-error) 6%, transparent)`:S?`var(--bg-hover)`:`transparent`,transition:`background 0.1s`,opacity:j?.5:1,gap:6,overflow:`hidden`},className:t&&!k?`row-selected-gradient`:void 0,children:k?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--text)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:ee}),(0,E.jsxs)(`div`,{style:{marginTop:2,display:`flex`,alignItems:`center`,gap:8,color:`var(--text-dim)`,fontSize:`var(--text-sm)`,minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:[e.error?(0,E.jsx)(X7,{session:e}):(0,E.jsx)(`span`,{title:e.modified,children:G7(e.modified,y)}),(0,E.jsx)(`span`,{children:y(`sidebar.messagesCount`,{count:e.messageCount})})]})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,gap:5,flexShrink:0},children:[(0,E.jsxs)(`button`,{onClick:ie,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:4,height:30,padding:`0 11px`,background:`var(--status-error)`,border:`none`,borderRadius:6,color:`var(--on-error)`,cursor:`pointer`,fontSize:`var(--text-base)`,fontWeight:600,whiteSpace:`nowrap`},children:[(0,E.jsx)(Xr,{size:p.base}),y(`sidebar.delete`)]}),(0,E.jsx)(`button`,{onClick:ae,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:30,padding:`0 11px`,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:6,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-base)`,fontWeight:500,whiteSpace:`nowrap`},children:y(`sidebar.cancel`)})]})]}):w?(0,E.jsx)(`input`,{ref:P,value:D,onChange:e=>O(e.target.value),onBlur:te,onKeyDown:e=>{e.key===`Enter`&&te(),e.key===`Escape`&&T(!1)},autoFocus:!0,style:{flex:1,fontSize:`var(--text-base)`,padding:`5px 8px`,border:`1px solid var(--accent)`,borderRadius:5,outline:`none`,background:`var(--bg)`,color:`var(--text)`,height:30}}):(0,E.jsxs)(E.Fragment,{children:[h>0&&(0,E.jsxs)(`svg`,{width:p.xs,height:p.xs,viewBox:`0 0 24 24`,fill:`none`,stroke:`var(--text-dim)`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,E.jsx)(`line`,{x1:`6`,y1:`3`,x2:`6`,y2:`15`}),(0,E.jsx)(`circle`,{cx:`18`,cy:`6`,r:`3`}),(0,E.jsx)(`circle`,{cx:`6`,cy:`18`,r:`3`}),(0,E.jsx)(`path`,{d:`M18 9a9 9 0 0 1-9 9`})]}),(0,E.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,E.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:5,minWidth:0,fontSize:`var(--text-base)`,fontWeight:t?600:400,lineHeight:1.4,color:s?`var(--text)`:`var(--text-dim)`},title:ee,children:(0,E.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,minWidth:0},children:ee})}),(0,E.jsxs)(`div`,{style:{marginTop:2,display:`flex`,alignItems:`center`,gap:8,color:`var(--text-dim)`,fontSize:`var(--text-sm)`,minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:[e.error?(0,E.jsx)(X7,{session:e}):n?(0,E.jsx)(XJ,{phase:r??{kind:`running_command`},elapsed:b,totalElapsed:x}):o?(0,E.jsx)(i9,{}):(0,E.jsx)(`span`,{title:e.modified,children:G7(e.modified,y)}),!e.error&&n?null:(0,E.jsx)(`span`,{children:y(`sidebar.messagesCount`,{count:e.messageCount})}),e.worktreeBranch&&(0,E.jsxs)(`span`,{title:`Worktree: ${e.cwd}`,style:{display:`flex`,alignItems:`center`,gap:3,color:`var(--accent)`,minWidth:0,overflow:`hidden`},children:[(0,E.jsxs)(`svg`,{width:`9`,height:`9`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,E.jsx)(`line`,{x1:`6`,y1:`3`,x2:`6`,y2:`15`}),(0,E.jsx)(`circle`,{cx:`18`,cy:`6`,r:`3`}),(0,E.jsx)(`circle`,{cx:`6`,cy:`18`,r:`3`}),(0,E.jsx)(`path`,{d:`M18 9a9 9 0 0 1-9 9`})]}),(0,E.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.worktreeBranch})]})]})]}),g&&(0,E.jsx)(oi,{label:_?`Expand forks`:`Collapse forks`,children:(0,E.jsx)(`button`,{onClick:e=>{e.stopPropagation(),v?.()},style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:20,height:20,padding:0,flexShrink:0,background:`none`,border:`none`,color:`var(--text-dim)`,cursor:`pointer`,transform:_?`rotate(-90deg)`:`none`,transition:`transform 0.15s`},children:(0,E.jsx)(`svg`,{width:p.xs,height:p.xs,viewBox:`0 0 10 10`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,E.jsx)(`polyline`,{points:`2 3.5 5 6.5 8 3.5`})})})}),(0,E.jsx)(O7,{visible:S,items:[...s&&m?[{key:`unseen`,onClick:t=>{t.stopPropagation(),m(e.id)},title:y(`sidebar.disconnect`)||`断开`,icon:(0,E.jsx)(Qr,{size:p.base})}]:[],{key:`copy-path`,onClick:t=>{t.stopPropagation(),bY(e.path)},title:y(`sidebar.copyPath`),icon:(0,E.jsx)(hr,{size:p.base})},{key:`rename`,onClick:F,title:y(`sidebar.rename`),icon:(0,E.jsx)(Pr,{size:p.xl})},{key:`delete`,testId:`session-delete`,onClick:re,title:y(`sidebar.deleteWithShiftClick`),danger:!0,icon:(0,E.jsx)(Xr,{size:p.xl})}]})]})})}function o9(){let{t:e}=N(),t=(0,d.useSyncExternalStore)(bx,xx,xx);if(t.length===0)return null;let n=t[t.length-1],r=t.length;return(0,E.jsx)(jc,{open:!0,onOpenChange:()=>{},children:(0,E.jsxs)(Fc,{children:[(0,E.jsx)(Lc,{style:{position:`fixed`,inset:0,zIndex:1200,background:`rgba(0, 0, 0, 0.45)`}}),(0,E.jsxs)(Vc,{role:`alertdialog`,"aria-modal":`true`,onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),style:{position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,zIndex:1200,maxWidth:480,width:`calc(100% - 48px)`,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:10,padding:`16px 20px`,boxShadow:`0 8px 32px rgba(0, 0, 0, 0.35)`},children:[(0,E.jsxs)(Kc,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:10,fontSize:`var(--text-base)`,fontWeight:600,color:`var(--text)`},children:[(0,E.jsx)(`span`,{style:{color:`var(--status-error)`},children:`⚠`}),(0,E.jsx)(`span`,{children:r>1?e(`errors.titleCount`,{count:r}):e(`errors.title`)})]}),(0,E.jsx)(Jc,{asChild:!0,children:(0,E.jsx)(`div`,{children:n.kind===`api`?(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:6},children:[(0,E.jsxs)(`span`,{style:{fontSize:`var(--text-xs)`,padding:`1px 8px`,borderRadius:999,background:`color-mix(in srgb, var(--status-error) 14%, transparent)`,color:`var(--status-error)`,fontWeight:600,whiteSpace:`nowrap`},children:[`HTTP `,n.status||`ERR`]}),n.context&&(0,E.jsx)(`span`,{style:{fontSize:`var(--text-xs)`,color:`var(--text-dim)`},children:n.context})]}),(0,E.jsx)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text)`,wordBreak:`break-word`},children:n.message})]}):(0,E.jsxs)(`div`,{children:[n.context&&(0,E.jsx)(`div`,{style:{fontSize:`var(--text-xs)`,color:`var(--text-dim)`,marginBottom:6},children:n.context}),(0,E.jsx)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text)`,wordBreak:`break-word`},children:n.message})]})})}),(0,E.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8,marginTop:16},children:[r>1&&(0,E.jsx)(`button`,{type:`button`,onClick:Cx,style:{border:`1px solid var(--border)`,background:`none`,color:`var(--text-muted)`,borderRadius:6,padding:`4px 12px`,fontSize:`var(--text-sm)`,cursor:`pointer`},children:e(`errors.clearAll`)}),(0,E.jsx)(`button`,{type:`button`,onClick:Sx,style:{border:`none`,background:`var(--accent)`,color:`#fff`,borderRadius:6,padding:`4px 14px`,fontSize:`var(--text-sm)`,cursor:`pointer`},children:e(`errors.close`)})]})]})]})})}var s9=[],c9=1,l9=new Set;function u9(){for(let e of l9)e()}function d9(e){return l9.add(e),()=>{l9.delete(e)}}function f9(){return s9}function p9(e){let t={id:c9++,label:e??``};s9=[...s9,t],u9();let n=!1;return()=>{n||(n=!0,s9=s9.filter(e=>e.id!==t.id),u9())}}var m9=new WeakMap;function h9(e){if(!e.isConnected)return()=>{};let t=m9.get(e);if(!t){let n=document.createElement(`div`);n.style.cssText=`position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb, var(--bg) 50%, transparent);z-index:5;`,n.innerHTML=`<div style="width:16px;height:16px;border:2px solid var(--border);border-top-color:var(--text-dim);border-radius:50%;animation:spin 0.8s linear infinite;"></div>`;let r=null;getComputedStyle(e).position===`static`&&(r=e.style.position,e.style.position=`relative`),e.appendChild(n),t={count:0,el:n,prevPosition:r},m9.set(e,t)}t.count++;let n=!1;return()=>{n||(n=!0,t.count--,t.count<=0&&(t.el.remove(),t.prevPosition!==null&&(t.prevPosition?e.style.position=t.prevPosition:e.style.removeProperty(`position`)),m9.delete(e)))}}async function g9(e){try{return await e.json()}catch{return null}}async function _9(e,t,n){let r=n?.loading??`fullscreen`,i=r===`fullscreen`?p9(n?.label):r instanceof HTMLElement?h9(r):null;try{let n;try{n=await fetch(e,t)}catch(e){throw new px(e instanceof Error?e.message:`Network error`,0)}if(!n.ok){let e=await g9(n);throw new px(e&&typeof e==`object`&&`error`in e&&typeof e.error==`string`?e.error:`HTTP ${n.status}`,n.status,e)}let r=await n.text();return r?JSON.parse(r):void 0}catch(e){throw e instanceof px?e:new px(e instanceof Error?e.message:String(e),0)}finally{i?.()}}var v9=3;function y9(){let{t:e}=N(),t=(0,d.useSyncExternalStore)(d9,f9,f9);if(t.length===0)return null;let n=t.slice(0,v9),r=t.length-n.length;return(0,E.jsx)(`div`,{"aria-busy":`true`,style:{position:`fixed`,inset:0,zIndex:1150,background:`color-mix(in srgb, var(--bg) 40%, transparent)`,display:`flex`,alignItems:`center`,justifyContent:`center`,pointerEvents:`none`},children:(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10,minWidth:220,maxWidth:`60vw`,padding:`14px 18px`,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:`var(--radius)`,boxShadow:`0 8px 32px rgba(0,0,0,0.25)`},children:[n.map(t=>(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,fontSize:`var(--text-sm)`,color:`var(--text)`},children:[(0,E.jsx)(`div`,{style:{width:14,height:14,flexShrink:0,border:`2px solid var(--border)`,borderTopColor:`var(--accent)`,borderRadius:`50%`,animation:`spin 0.8s linear infinite`}}),(0,E.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:t.label||e(`loading.inProgress`)})]},t.id)),r>0&&(0,E.jsx)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text-dim)`},children:e(`loading.more`,{count:r})})]})})}var b9={};function x9(e,t){return e===`Not found`?t(`files.notFound`):e===`Access denied`?t(`files.accessDenied`):e}async function S9(e,t){return((await _9(`/api/files/${vG(e)}?type=list`,void 0,t)).entries??[]).map(t=>({name:t.name,fullPath:SG(e,t.name),isDir:t.isDir,size:t.size,children:t.isDir?[]:void 0,loaded:!t.isDir}))}async function C9(e,t){return _9(`/api/git/status?${new URLSearchParams({cwd:e}).toString()}`,void 0,t)}var w9={modified:`files.modified`,added:`files.added`,deleted:`files.deleted`,renamed:`files.renamed`,untracked:`files.untracked`,conflict:`files.conflict`},T9={modified:`var(--status-warning)`,added:`var(--status-success)`,deleted:`var(--status-error)`,renamed:`var(--accent)`,untracked:`var(--status-success)`,conflict:`var(--status-error)`};function E9({status:e,t}){return(0,E.jsx)(`span`,{title:t(w9[e.status]),"aria-label":t(w9[e.status]),style:{width:14,height:14,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,color:T9[e.status],fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,fontWeight:600},children:e.code})}function D9(e,t,n,r){return new Promise((i,a)=>{let o=new FormData;t.forEach(e=>o.append(`files`,e,e.name));let s=new XMLHttpRequest;s.open(`POST`,`/api/files/${vG(e)}?type=upload&conflict=${n}`),s.upload.onprogress=e=>{e.lengthComputable&&e.total>0&&r(Math.round(e.loaded/e.total*100))},s.onerror=()=>a(Error(`Network error while uploading files`)),s.onabort=()=>a(Error(`Upload cancelled`)),s.onload=()=>{let e={};try{e=JSON.parse(s.responseText)}catch{s.responseText&&(e.error=s.responseText)}i({status:s.status,data:e})},s.send(o)})}function O9({size:e=11}){return(0,E.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,E.jsx)(`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`})]})}function k9({onClick:e,title:t}){return(0,E.jsx)(oi,{label:t,children:(0,E.jsx)(`button`,{type:`button`,onClick:e,"aria-label":t,style:{width:24,height:24,padding:0,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,border:`none`,borderRadius:4,background:`none`,color:`var(--text-dim)`,cursor:`pointer`,"--hover-color":`var(--text-muted)`,"--hover-bg":`var(--bg-hover)`},className:`hover-shift`,children:(0,E.jsxs)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`m6 6 12 12`}),(0,E.jsx)(`path`,{d:`m18 6-12 12`})]})})})}function A9({node:e,depth:t,cwd:n,onOpenFile:r,onAtMention:i,expandedPaths:a,onToggleExpanded:o,refreshToken:s,highlightedPaths:c,gitStatusByPath:l,changedDirectoryPaths:u,t:f}){let m=a.has(e.fullPath),h=c.has(e.fullPath),g=_G(e.fullPath),_=l.get(g),v=e.isDir&&(_!==void 0||u.has(g)),[y,b]=(0,d.useState)(e.children??[]),[x,S]=(0,d.useState)(e.loaded??!1),[C,w]=(0,d.useState)(!1),T=(0,d.useCallback)(async(t=!1)=>{if(!(x&&!t))try{let t=await S9(e.fullPath,{loading:`silent`});b(t),S(!0)}catch{}},[x,e.fullPath]);(0,d.useEffect)(()=>{m&&x&&T(!0)},[s]);let D=(0,d.useCallback)(()=>{if(e.isDir){let t=!m;o(e.fullPath,t),t&&!x&&T()}else r(e.fullPath,e.name)},[e.isDir,e.fullPath,e.name,x,m,T,r,o]);return(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`div`,{onClick:D,onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),style:{position:`relative`,display:`flex`,alignItems:`center`,gap:4,paddingLeft:8+t*14,paddingRight:8,height:24,cursor:`pointer`,background:C?`var(--bg-hover)`:`transparent`,borderRadius:4,userSelect:`none`},children:[e.isDir&&(0,E.jsx)(`svg`,{width:p.xs,height:p.xs,viewBox:`0 0 10 10`,fill:`none`,stroke:`var(--text-dim)`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0,transform:m?`rotate(90deg)`:`none`,transition:`transform 0.1s`},children:(0,E.jsx)(`polyline`,{points:`3 2 7 5 3 8`})}),!e.isDir&&(0,E.jsx)(`span`,{style:{width:10,flexShrink:0}}),(0,E.jsx)(`span`,{style:{flexShrink:0,display:`flex`,alignItems:`center`},children:e.isDir?(0,E.jsx)(sn,{size:p.xl,open:m}):Fn(e.name,14)}),(0,E.jsx)(`span`,{style:{fontSize:`var(--text-base)`,color:`var(--text)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,flex:1},title:e.fullPath,children:e.name}),h&&(0,E.jsx)(`span`,{title:f(`files.newlyUploaded`),"aria-label":f(`files.newlyUploaded`),style:{width:14,height:14,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,E.jsx)(`span`,{style:{width:6,height:6,borderRadius:`50%`,background:`var(--accent)`}})}),!C&&!e.isDir&&_&&(0,E.jsx)(E9,{status:_,t:f}),!C&&v&&(0,E.jsx)(`span`,{title:f(`files.containsChangedFiles`),"aria-label":f(`files.containsChangedFiles`),style:{width:14,height:14,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,E.jsx)(`span`,{style:{width:6,height:6,borderRadius:`50%`,background:`var(--status-warning)`}})}),i&&C&&(0,E.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),i(xG(e.fullPath,n),e.isDir)},title:f(`files.insertPath`),style:{position:`absolute`,right:e.isDir?4:28,top:`50%`,transform:`translateY(-50%)`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:4,padding:`0 8px`,height:20,background:`var(--bg-panel)`,border:`1px solid var(--border)`,borderRadius:4,color:`var(--accent)`,cursor:`pointer`,fontSize:`var(--text-sm)`,fontWeight:600,whiteSpace:`nowrap`},children:[(0,E.jsx)(O9,{}),f(`files.mention`)]}),C&&!e.isDir&&(0,E.jsx)(`a`,{href:`/api/files/${vG(e.fullPath)}?type=download`,download:!0,onClick:e=>e.stopPropagation(),title:f(`files.download`),style:{position:`absolute`,right:4,top:`50%`,transform:`translateY(-50%)`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:4,padding:`0 5px`,height:20,background:`var(--bg-panel)`,border:`1px solid var(--border)`,borderRadius:4,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-sm)`,fontWeight:600,whiteSpace:`nowrap`,textDecoration:`none`},children:(0,E.jsxs)(`svg`,{width:p.sm,height:p.sm,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,E.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,E.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]})})]}),e.isDir&&m&&(0,E.jsxs)(`div`,{children:[y.map(e=>(0,E.jsx)(A9,{node:e,depth:t+1,cwd:n,onOpenFile:r,onAtMention:i,expandedPaths:a,onToggleExpanded:o,refreshToken:s,highlightedPaths:c,gitStatusByPath:l,changedDirectoryPaths:u,t:f},e.fullPath)),y.length===0&&x&&(0,E.jsx)(`div`,{style:{paddingLeft:8+(t+1)*14,fontSize:`var(--text-sm)`,color:`var(--text-dim)`,height:22,display:`flex`,alignItems:`center`},children:f(`files.empty`)})]})]})}function j9({status:e,cwd:t,onOpenFile:n,onStageToggle:r,unstage:i,t:a}){let[o,s]=(0,d.useState)(!1),c=yG(e.filePath),l=xG(e.filePath,t);return(0,E.jsxs)(`div`,{onClick:()=>n(e.filePath,c,{modeHint:`diff`}),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),title:e.filePath,style:{display:`flex`,alignItems:`center`,gap:6,paddingLeft:10,paddingRight:8,height:24,cursor:`pointer`,background:o?`var(--bg-hover)`:`transparent`,borderRadius:4,userSelect:`none`},children:[r!==void 0&&(0,E.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r(e)},"aria-label":a(i?`files.unstageFile`:`files.stageFile`),style:{width:16,height:16,padding:0,marginLeft:-4,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,border:`none`,borderRadius:4,background:`none`,color:`var(--text-dim)`,cursor:`pointer`,opacity:+!!o,"--hover-color":`var(--text-muted)`,"--hover-bg":`var(--bg-hover)`},className:`hover-shift`,children:(0,E.jsx)(`svg`,{width:p.sm,height:p.sm,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,"aria-hidden":`true`,children:i?(0,E.jsx)(`path`,{d:`M6 12h12`}):(0,E.jsx)(`path`,{d:`M12 5v14M5 12h14`})})}),(0,E.jsx)(E9,{status:e,t:a}),(0,E.jsx)(`span`,{style:{flexShrink:0,display:`flex`,alignItems:`center`,opacity:.85},children:Fn(c,13)}),(0,E.jsx)(`span`,{style:{fontSize:`var(--text-base)`,color:`var(--text)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,flex:1},children:l}),e.lineStats&&(e.lineStats.additions>0||e.lineStats.deletions>0)&&(0,E.jsxs)(`span`,{style:{flexShrink:0,display:`flex`,alignItems:`center`,gap:5,fontFamily:`var(--font-mono)`,fontSize:`var(--text-xs)`,fontVariantNumeric:`tabular-nums`},children:[e.lineStats.additions>0&&(0,E.jsxs)(`span`,{style:{color:`var(--status-success)`},children:[`+`,e.lineStats.additions]}),e.lineStats.deletions>0&&(0,E.jsxs)(`span`,{style:{color:`var(--status-error)`},children:[`-`,e.lineStats.deletions]})]})]})}function M9({message:e,onMessageChange:t,commitBusy:n,canCommit:r,onCommit:i,pushBusy:a,canPush:o,onPush:s,pullBusy:c,canPull:l,onPull:u,aiBusy:f,canAiGenerate:m,onAiGenerate:h,autoGenerateOnEmpty:g,hasModelForAuto:_,aiModelHint:v,t:y}){let b=(0,d.useRef)(null),x=e.trim()===``,S=x&&g&&_&&m&&!f,C=n||!S&&x||!r;return(0,d.useLayoutEffect)(()=>{let e=b.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,120)}px`)},[e]),(0,E.jsx)(`div`,{style:{display:`flex`,padding:`4px 2px 6px`},children:(0,E.jsxs)(`div`,{style:{position:`relative`,display:`flex`,flexDirection:`column`,flex:1,minWidth:0,backgroundColor:`var(--bg)`,backgroundImage:n||f||a||c?`linear-gradient(90deg, transparent 13%, color-mix(in srgb, var(--accent) 18%, transparent) 25%, transparent 37%, transparent 63%, color-mix(in srgb, var(--shine-highlight) 50%, transparent) 75%, transparent 87%)`:void 0,backgroundSize:n||f||a||c?`200% 100%`:void 0,animation:n||f||a||c?`pi-status-shine 1.5s linear infinite`:void 0,borderRadius:6,border:`1px solid var(--border)`},children:[(0,E.jsx)(`textarea`,{ref:b,value:e,disabled:n||f||a||c,placeholder:f?v?`${y(`git.ai.generating`)}(${v})`:y(`git.ai.generating`):y(`files.commitMessagePlaceholder`),onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),C||i())},rows:1,style:{flex:`0 1 auto`,minWidth:0,resize:`none`,boxSizing:`content-box`,overflowY:`auto`,maxHeight:120,fontSize:`var(--text-base)`,lineHeight:1.4,padding:`4px 6px`,color:n||f||a||c?`var(--text-dim)`:`var(--text)`,background:`transparent`,border:`none`,borderRadius:6,outline:`none`}}),(0,E.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:4,padding:`2px 6px 4px`},children:[(0,E.jsx)(oi,{label:(()=>{let e=y(f?`git.ai.generating`:`git.ai.generate`);return v?`${e}(${v})`:e})(),children:(0,E.jsx)(`button`,{onClick:h,disabled:f||!m||n||a||c,"aria-label":y(`git.ai.generate`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:36,height:30,padding:0,flexShrink:0,background:`none`,border:`1px solid transparent`,borderRadius:6,color:f||!m||n||a||c?`var(--text-dim)`:`var(--accent)`,cursor:f||!m||n||a||c?`default`:`pointer`},children:f?(0,E.jsx)(Ar,{size:p.lg,style:{animation:`spin 0.8s linear infinite`}}):(0,E.jsx)(Kr,{size:p.lg})})}),(0,E.jsx)(oi,{label:n?y(`files.committing`):C&&x&&!S?y(`files.commitMessageRequired`):S?`${y(`git.ai.generateAndCommit`)} (Ctrl+Enter)`:`${y(`files.commit`)} (Ctrl+Enter)`,children:(0,E.jsx)(`button`,{onClick:i,disabled:C||c,"aria-label":y(`files.commit`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:36,height:30,padding:0,flexShrink:0,background:`none`,border:`1px solid transparent`,borderRadius:6,color:C||c?`var(--text-dim)`:`var(--accent)`,cursor:C||c?`default`:`pointer`},children:n?(0,E.jsx)(Ar,{size:p[`2xl`],style:{animation:`spin 0.8s linear infinite`}}):(0,E.jsx)(Cr,{size:p[`2xl`]})})}),(0,E.jsx)(oi,{label:y(a?`files.pushing`:o?`files.push`:`files.pushUpToDate`),children:(0,E.jsx)(`button`,{onClick:s,disabled:a||n||c||!o,"aria-label":y(`files.push`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:36,height:30,padding:0,flexShrink:0,background:`none`,border:`1px solid transparent`,borderRadius:6,color:a||n||c||!o?`var(--text-dim)`:`var(--accent)`,cursor:a||n||c||!o?`default`:`pointer`},children:a?(0,E.jsx)(Ar,{size:p.lg,style:{animation:`spin 0.8s linear infinite`}}):(0,E.jsx)(mr,{size:p[`2xl`]})})}),(0,E.jsx)(oi,{label:y(c?`files.pulling`:l?`files.pull`:`files.pullUpToDate`),children:(0,E.jsx)(`button`,{onClick:u,disabled:c||n||a||!l,"aria-label":y(`files.pull`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:36,height:30,padding:0,flexShrink:0,background:`none`,border:`1px solid transparent`,borderRadius:6,color:c||n||a||!l?`var(--text-dim)`:`var(--accent)`,cursor:c||n||a||!l?`default`:`pointer`},children:c?(0,E.jsx)(Ar,{size:p.lg,style:{animation:`spin 0.8s linear infinite`}}):(0,E.jsx)(pr,{size:p[`2xl`]})})})]})]})})}function N9({prefix:e,count:t,additions:n,deletions:r,t:i}){return(0,E.jsxs)(`div`,{"aria-label":i(`files.changeStats`,{count:t,additions:n,deletions:r}),style:{display:`flex`,alignItems:`center`,gap:6,height:24,padding:`0 10px`,fontSize:`var(--text-base)`},children:[e&&(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`},children:e}),(0,E.jsx)(`span`,{style:{color:`var(--text-dim)`},children:i(`files.changedCount`,{count:t})}),(0,E.jsxs)(`span`,{style:{color:T9.added,fontFamily:`var(--font-mono)`},children:[`+`,n]}),(0,E.jsxs)(`span`,{style:{color:T9.deleted,fontFamily:`var(--font-mono)`},children:[`-`,r]})]})}function P9({message:e,onDismiss:t}){let{t:n}=N();return(0,E.jsxs)(`div`,{role:`alert`,style:{display:`flex`,alignItems:`center`,gap:6,marginTop:4,padding:`6px 8px`,fontSize:`var(--text-sm)`,lineHeight:1.35,color:`var(--status-error)`,background:`var(--bg)`,border:`1px solid var(--status-error)`,borderRadius:6},children:[(0,E.jsx)(`span`,{style:{minWidth:0,flex:1,overflowWrap:`anywhere`,maxHeight:140,overflowY:`auto`,whiteSpace:`pre-wrap`},children:e}),(0,E.jsx)(k9,{onClick:t,title:n(`files.dismissError`)})]})}function F9({children:e}){return(0,E.jsx)(`div`,{style:{padding:`0 4px 2px`},children:e})}var I9=(0,d.forwardRef)(function({children:e},t){return(0,E.jsx)(`div`,{ref:t,style:{padding:`2px 4px`},children:e})}),L9=(0,d.forwardRef)(function({cwd:e,onOpenFile:t,refreshKey:n,searchQuery:r,onAtMention:i,onAtMentions:a,onUploadBusyChange:o,changesCollapsed:s,onChangesCountChange:c,sessionId:l,onOpenConfig:u},f){let{t:m}=N(),[h,g]=(0,d.useState)([]),[_,v]=(0,d.useState)(!0),[y,b]=(0,d.useState)(null),x=(0,d.useRef)(null),[S,C]=(0,d.useState)(new Set),[w,T]=(0,d.useState)(0),D=(r??``).trim().toLowerCase(),O=(0,d.useMemo)(()=>{if(!D)return h;function e(t){if(t.name.toLowerCase().includes(D))return t;if(t.isDir&&t.children){let n=t.children.map(e).filter(e=>e!==null);if(n.length>0)return{...t,children:n}}return null}return h.map(e).filter(e=>e!==null)},[h,D]),[k,A]=(0,d.useState)(new Set),[j,M]=(0,d.useState)([]),[P,ee]=(0,d.useState)({additions:0,deletions:0}),[F,te]=(0,d.useState)([]),[ne,re]=(0,d.useState)({additions:0,deletions:0}),ie=(0,d.useMemo)(()=>D?F.filter(t=>xG(t.filePath,e).toLowerCase().includes(D)):F,[F,D,e]),ae=(0,d.useMemo)(()=>D?j.filter(t=>xG(t.filePath,e).toLowerCase().includes(D)):j,[j,D,e]),[oe,I]=(0,d.useState)({branch:null,upstream:null,ahead:0,behind:0,hasUpstream:!1}),[L,se]=(0,d.useState)(null),[R,ce]=(0,d.useState)(``),[le,ue]=(0,d.useState)(!1),[de,fe]=(0,d.useState)(null),[pe,me]=(0,d.useState)(!1),[he,ge]=(0,d.useState)(!1),[_e,ve]=(0,d.useState)(null),[ye,xe]=(0,d.useState)(!1),[Ce,we]=(0,d.useState)(!1),Te=(0,d.useSyncExternalStore)(Se.subscribe,()=>Se.get()?.preferences??b9,()=>b9),Ee=(0,d.useSyncExternalStore)(be.subscribe,()=>be.get()),De=Te.commitMessageAutoGenerateOnEmpty!==!1,Oe=Te.commitStageAllConfirm!==!1,ke=Te.commitMessageUseCurrentModel===!0?!!(l||Ee?.defaultModel||(Ee?.modelList?.length??0)>0):!!(typeof Te.commitMessageModel==`string`&&Te.commitMessageModel),[Ae,je]=(0,d.useState)(!1),[Me,Ne]=(0,d.useState)(null),Pe=(0,d.useRef)(null),[Fe,Ie]=(0,d.useState)(!1),[Le,Re]=(0,d.useState)(null),[ze,Be]=(0,d.useState)(`idle`),[Ve,He]=(0,d.useState)(0),[Ue,We]=(0,d.useState)(null),[Ge,Ke]=(0,d.useState)(null),[qe,Je]=(0,d.useState)(null),Ye=(0,d.useRef)(null),Xe=(0,d.useRef)(null),Ze=`${n??0}:${w}`,Qe=ze!==`idle`,$e=(0,d.useMemo)(()=>new Map(j.map(e=>[_G(e.filePath),e])),[j]),et=(0,d.useMemo)(()=>{let t=new Set,n=_G(e).replace(/\/$/,``);for(let e of j){let r=bG(_G(e.filePath));for(;(r===n||r.startsWith(`${n}/`))&&(t.add(r),r!==n);){let e=bG(r);if(e===r)break;r=e}}return t},[e,j]),tt=(0,d.useCallback)((e,t)=>{C(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),nt=(0,d.useCallback)(t=>{let n=t.uploaded??[],r=t.skipped??[],i=t.errors??[];Ke({uploaded:n,skipped:r,errors:i}),n.length>0&&(A(new Set(n.map(t=>SG(e,t)))),T(e=>e+1))},[e]),rt=(0,d.useCallback)(async(t,n)=>{Je(null),We(null),He(0),Be(`uploading`);try{let{status:r,data:i}=await D9(e,t,n,He);if(r===409&&i.conflicts?.length){Je({files:t,conflicts:i.conflicts,nonReplaceable:i.nonReplaceable??[]});return}if(r<200||r>=300)throw Error(i.error??`Upload failed (HTTP ${r})`);He(100),nt(i)}catch(e){We(e instanceof Error?e.message:String(e))}finally{Be(`idle`)}},[nt,e]),it=(0,d.useCallback)(async t=>{if(!(t.length===0||Qe)){Ke(null),A(new Set),Je(null),We(null),He(0),Be(`checking`);try{let n=await _9(`/api/files/${vG(e)}?type=upload-check`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({fileNames:t.map(e=>e.name)})},{loading:`silent`});if(n.conflicts?.length){Je({files:t,conflicts:n.conflicts,nonReplaceable:n.nonReplaceable??[]});return}await rt(t,`error`)}catch(e){We(e instanceof Error?e.message:String(e))}finally{Be(`idle`)}}},[e,rt,Qe]),at=(0,d.useCallback)(e=>{let t=Array.from(e.target.files??[]);e.target.value=``,it(t)},[it]);(0,d.useImperativeHandle)(f,()=>({openUploadPicker(){Qe||Xe.current?.click()}}),[Qe]);let ot=(0,d.useCallback)(async()=>{je(!0);try{let t=await _9(`/api/git/push`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:e})},{loading:`silent`});console.info(`[git-push] ok:`,t.output||`(empty output)`),Ne({ok:!0,output:t.output??``})}catch(e){let t=e instanceof Error?e.message:String(e);console.info(`[git-push] failed:`,t),Ne({ok:!1,output:t})}finally{je(!1),T(e=>e+1)}},[e]),st=(0,d.useCallback)(async()=>{Ie(!0);try{let t=await _9(`/api/git/pull`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:e})},{loading:`silent`});console.info(`[git-pull] ok:`,t.output||`(empty output)`),Re({ok:!0,output:t.output??``})}catch(e){let t=e instanceof Error?e.message:String(e);console.info(`[git-pull] failed:`,t),Re({ok:!1,output:t})}finally{Ie(!1),T(e=>e+1)}},[e]);(0,d.useEffect)(()=>{if(Pe.current&&clearTimeout(Pe.current),Me)return Pe.current=setTimeout(()=>Ne(null),1e4),()=>{Pe.current&&clearTimeout(Pe.current)}},[Me]);let ct=(0,d.useRef)(null);(0,d.useEffect)(()=>{if(ct.current&&clearTimeout(ct.current),Le)return ct.current=setTimeout(()=>Re(null),1e4),()=>{ct.current&&clearTimeout(ct.current)}},[Le]),(0,d.useEffect)(()=>{o?.(Qe)},[o,Qe]),(0,d.useEffect)(()=>()=>o?.(!1),[o]),(0,d.useEffect)(()=>{let t=Ye.current!==e;Ye.current=e,t&&(C(new Set),A(new Set),Ke(null),Je(null),We(null)),b(null),v(t);let n=!1;return S9(e,{loading:`silent`}).then(e=>{n||g(e)}).catch(e=>{n||(b(e instanceof Error?e.message:String(e)),yx(e,`file explorer`))}).finally(()=>{n||v(!1)}),()=>{n=!0}},[e,n,w]),(0,d.useEffect)(()=>{let t=!1;return C9(e,{loading:`silent`}).then(e=>{if(!t){let t=e.isGitRepository;M(t?e.files:[]),ee(t?{additions:e.additions,deletions:e.deletions}:{additions:0,deletions:0}),te(t?e.stagedFiles:[]),re(t?{additions:e.stagedAdditions,deletions:e.stagedDeletions}:{additions:0,deletions:0}),I(t?{branch:e.branch??null,upstream:e.upstream??null,ahead:e.ahead??0,behind:e.behind??0,hasUpstream:e.hasUpstream??!1}:{branch:null,upstream:null,ahead:0,behind:0,hasUpstream:!1})}}).catch(()=>{t||(M([]),ee({additions:0,deletions:0}),te([]),re({additions:0,deletions:0}),I({branch:null,upstream:null,ahead:0,behind:0,hasUpstream:!1}))}),()=>{t=!0}},[e,n,w]);let lt=(0,d.useCallback)(async(t,n)=>{se(null);try{let r=await fetch(`/api/git/stage`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:e,filePath:t.filePath,action:n?`unstage`:`stage`})}),i=await r.json().catch(()=>({}));if(!r.ok)throw Error(i.error??`Git ${n?`unstage`:`stage`} failed (HTTP ${r.status})`);T(e=>e+1)}catch(e){se(e instanceof Error?e.message:String(e))}},[e]);(0,d.useEffect)(()=>{c?.(j.length+F.length)},[j,F,c]);let ut=(0,d.useCallback)(async(t,n)=>{let r=n??R;ue(!0),fe(null);try{let n=await fetch(`/api/git/commit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:e,message:r,stageAll:t})}),i=await n.json().catch(()=>({}));if(!n.ok)throw Error(i.error??`Commit failed (HTTP ${n.status})`);ce(``),fe(null),me(!1),T(e=>e+1)}catch(e){fe(e instanceof Error?e.message:String(e))}finally{ue(!1)}},[e,R]),dt=(0,d.useCallback)(async()=>{if(he||le||Ae||Ce)return null;let t=Se.get()?.preferences??{};if(Object.keys(t).length===0)try{await Se.refresh(),t=Se.get()?.preferences??{}}catch{}let n=t.commitMessageUseCurrentModel===!0,r=typeof t.commitMessageModel==`string`?t.commitMessageModel:``,i=``,a=``;if(n){if(l)try{let e=await _9(`/api/agent/${encodeURIComponent(l)}`),t=e.state?.model??e.model??null;if(t){let e=t;i=e.provider??``,a=e.id??e.modelId??``}if(!i||!a)try{let e=await _9(`/api/sessions/${encodeURIComponent(l)}/state`);e.model&&(i=e.model.provider,a=e.model.id)}catch{}}catch{}if(!i||!a)try{let e=be.get();if(!e?.defaultModel)try{await be.refresh(),e=be.get()}catch{}if(e?.defaultModel?.provider){let t=e.defaultModel;i=t.provider??``,a=t.modelId??t.id??``}if((!i||!a)&&e?.modelList?.[0]){let t=e.modelList[0];i=t.provider??``,a=t.modelId??t.id??``}}catch{}if(!i||!a)return ve(m(`git.ai.noSessionModel`)),null}else{if(!r)return xe(!0),null;let e=r.indexOf(`/`);if(e===-1||(i=r.slice(0,e),a=r.slice(e+1),!i||!a))return ve(m(`git.ai.invalidModel`)),null}let o=t.commitMessageMaxTokens,s=typeof o==`number`&&Number.isFinite(o)?Math.min(4096,Math.max(64,Math.round(o))):512;ge(!0),ve(null);try{let t=await fetch(`/api/git/generate-commit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cwd:e,provider:i,modelId:a,maxTokens:s})}),n=await t.json().catch(()=>({}));if(!t.ok)throw Error(n.error??`Generate failed (HTTP ${t.status})`);if(!n.message)throw Error(`Empty response`);return ce(n.message),n.message}catch(e){return ve(e instanceof Error?e.message:String(e)),null}finally{ge(!1)}},[he,le,Ae,Ce,e,l,m]),ft=(0,d.useCallback)(async()=>{let t=await C9(e),n=t.isGitRepository;M(n?t.files:[]),ee(n?{additions:t.additions,deletions:t.deletions}:{additions:0,deletions:0}),te(n?t.stagedFiles:[]),re(n?{additions:t.stagedAdditions,deletions:t.stagedDeletions}:{additions:0,deletions:0}),I(n?{branch:t.branch??null,upstream:t.upstream??null,ahead:t.ahead??0,behind:t.behind??0,hasUpstream:t.hasUpstream??!1}:{branch:null,upstream:null,ahead:0,behind:0,hasUpstream:!1});let r=R.trim()===``,i=n?t.stagedFiles??[]:[],a=n?t.files??[]:[],o=i.length+a.length>0;if(r&&De&&ke&&o&&!he&&!le&&!Ae&&!Ce){we(!0);try{let e=await dt();if(!e)return;i.length>0?await ut(!1,e):Oe?me(!0):await ut(!0,e)}finally{we(!1)}return}i.length>0?ut(!1):Oe?me(!0):ut(!0)},[e,R,De,ke,Oe,he,le,Ae,Ce,dt,ut]),pt=Qe||qe!==null||Ue!==null||Ge!==null,mt=(0,d.useCallback)(()=>{!Ge||Ge.uploaded.length===0||a?.(Ge.uploaded.map(t=>xG(SG(e,t),e)))},[e,a,Ge]);return(0,E.jsxs)(`div`,{style:{minHeight:`100%`},children:[(0,E.jsx)(`input`,{ref:Xe,type:`file`,multiple:!0,hidden:!0,onChange:at}),pt&&(0,E.jsxs)(`div`,{style:{padding:`6px 8px`,borderBottom:`1px solid var(--border)`},children:[Qe&&(0,E.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-label":ze===`checking`?m(`files.checking`):m(`files.uploading`,{progress:Ve}),children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8,minHeight:14,color:`var(--text-muted)`},children:[ze===`checking`?(0,E.jsx)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,style:{animation:`spin 0.8s linear infinite`},"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M21 12a9 9 0 1 1-5.7-8.4`})}):(0,E.jsxs)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`M12 16V4`}),(0,E.jsx)(`path`,{d:`m7 9 5-5 5 5`}),(0,E.jsx)(`path`,{d:`M5 20h14`})]}),ze===`uploading`&&(0,E.jsxs)(`span`,{style:{fontSize:`var(--text-xs)`},children:[Ve,`%`]})]}),ze===`uploading`&&(0,E.jsx)(`div`,{style:{height:3,marginTop:4,overflow:`hidden`,borderRadius:2,background:`var(--border)`},children:(0,E.jsx)(`div`,{style:{width:`${Ve}%`,height:`100%`,background:`var(--text-muted)`,transition:`width 120ms ease`}})})]}),qe&&(0,E.jsxs)(`div`,{role:`alert`,style:{padding:7,border:`1px solid color-mix(in srgb, #f59e0b 55%, var(--border))`,borderRadius:4,background:`color-mix(in srgb, #f59e0b 9%, var(--bg-panel))`},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-sm)`,color:`var(--text)`,lineHeight:1.35,overflowWrap:`anywhere`},children:m(`files.conflictSummary`,{count:qe.conflicts.length,countSuffix:qe.conflicts.length===1?``:`s`,files:qe.conflicts.join(`, `)})}),qe.nonReplaceable.length>0&&(0,E.jsx)(`div`,{style:{marginTop:3,fontSize:`var(--text-xs)`,color:`#f59e0b`,lineHeight:1.35,overflowWrap:`anywhere`},children:m(`files.cannotReplace`,{files:qe.nonReplaceable.join(`, `)})}),(0,E.jsxs)(`div`,{style:{display:`flex`,gap:5,marginTop:7},children:[(0,E.jsx)(`button`,{type:`button`,onClick:()=>void rt(qe.files,`overwrite`),style:{height:22,padding:`0 7px`,border:`1px solid var(--status-error)`,borderRadius:4,background:`transparent`,color:`var(--status-error)`,cursor:`pointer`,fontSize:`var(--text-xs)`},children:m(`files.replace`)}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>void rt(qe.files,`skip`),style:{height:22,padding:`0 7px`,border:`1px solid var(--border)`,borderRadius:4,background:`var(--bg-panel)`,color:`var(--text)`,cursor:`pointer`,fontSize:`var(--text-xs)`},children:m(`files.skipExisting`)}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>Je(null),style:{height:22,padding:`0 7px`,border:`none`,borderRadius:4,background:`transparent`,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-xs)`},children:m(`files.cancel`)})]})]}),Ue&&(0,E.jsxs)(`div`,{role:`alert`,style:{display:`flex`,alignItems:`flex-start`,gap:6,fontSize:`var(--text-sm)`,lineHeight:1.35,color:`var(--status-error)`},children:[(0,E.jsx)(`span`,{style:{minWidth:0,flex:1,overflowWrap:`anywhere`},children:Ue}),(0,E.jsx)(k9,{onClick:()=>We(null),title:m(`files.dismissError`)})]}),Ge&&(0,E.jsxs)(`div`,{"aria-live":`polite`,children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,minHeight:22,fontSize:`var(--text-sm)`},children:[(0,E.jsxs)(`div`,{style:{minWidth:0,flex:1,display:`flex`,alignItems:`center`,gap:8},children:[Ge.uploaded.length>0&&(0,E.jsxs)(`span`,{title:`${Ge.uploaded.length} uploaded`,"aria-label":`${Ge.uploaded.length} uploaded`,style:{display:`flex`,alignItems:`center`,gap:3,color:`var(--status-success)`},children:[(0,E.jsx)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`m5 12 4 4L19 6`})}),(0,E.jsx)(`span`,{children:Ge.uploaded.length})]}),Ge.skipped.length>0&&(0,E.jsxs)(`span`,{title:`${Ge.skipped.length} skipped`,"aria-label":`${Ge.skipped.length} skipped`,style:{display:`flex`,alignItems:`center`,gap:3,color:`var(--text-dim)`},children:[(0,E.jsxs)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,E.jsx)(`path`,{d:`M8 12h8`})]}),(0,E.jsx)(`span`,{children:Ge.skipped.length})]}),Ge.errors.length>0&&(0,E.jsxs)(`span`,{title:m(`files.uploadFailed`,{count:Ge.errors.length}),"aria-label":m(`files.uploadFailed`,{count:Ge.errors.length}),style:{display:`flex`,alignItems:`center`,gap:3,color:`var(--status-error)`},children:[(0,E.jsxs)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`M12 3 2.5 20h19L12 3Z`}),(0,E.jsx)(`path`,{d:`M12 9v4`}),(0,E.jsx)(`path`,{d:`M12 17h.01`})]}),(0,E.jsx)(`span`,{children:Ge.errors.length})]})]}),Ge.uploaded.length>0&&a&&(0,E.jsxs)(`button`,{type:`button`,onClick:mt,title:Ge.uploaded.length===1?m(`files.addUploadedFile`):m(`files.addAllUploadedFiles`),"aria-label":Ge.uploaded.length===1?m(`files.addUploadedFile`):m(`files.addAllUploadedFiles`),style:{height:22,padding:`0 7px`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:4,flexShrink:0,border:`1px solid var(--border)`,borderRadius:4,background:`var(--bg-panel)`,color:`var(--accent)`,cursor:`pointer`,fontSize:`var(--text-sm)`,fontWeight:600,whiteSpace:`nowrap`},children:[(0,E.jsx)(O9,{}),m(`files.mention`)]}),(0,E.jsx)(k9,{onClick:()=>Ke(null),title:m(`files.dismissUploadResults`)})]}),Ge.errors.map(e=>(0,E.jsxs)(`div`,{title:e.error,style:{display:`flex`,alignItems:`center`,gap:4,marginTop:3,minWidth:0,fontSize:`var(--text-xs)`,color:`var(--status-error)`},children:[(0,E.jsxs)(`svg`,{width:p.sm,height:p.sm,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},"aria-hidden":`true`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,E.jsx)(`path`,{d:`M12 8v5`}),(0,E.jsx)(`path`,{d:`M12 17h.01`})]}),(0,E.jsx)(`span`,{style:{minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.name})]},e.name))]})]}),!s&&(0,E.jsxs)(F9,{children:[(0,E.jsx)(M9,{message:R,onMessageChange:ce,commitBusy:le||Ce,canCommit:F.length+j.length>0,onCommit:ft,pushBusy:Ae,canPush:oe.hasUpstream?oe.ahead>0:!!oe.branch&&oe.branch!==`HEAD`,onPush:ot,pullBusy:Fe,canPull:oe.hasUpstream&&oe.behind>0,onPull:st,aiBusy:he,canAiGenerate:F.length+j.length>0,onAiGenerate:()=>{ce(``),dt()},autoGenerateOnEmpty:De,hasModelForAuto:ke,aiModelHint:(()=>{if(Te.commitMessageUseCurrentModel===!0)return m(`git.ai.usingCurrentModel`);let e=typeof Te.commitMessageModel==`string`?Te.commitMessageModel:``;return e?m(`git.ai.usingModel`,{model:e}):``})(),t:m}),Me&&(0,E.jsxs)(`div`,{role:`status`,"aria-live":`polite`,style:{marginTop:4,padding:`6px 8px`,borderRadius:6,border:`1px solid ${Me.ok?`var(--status-success)`:`var(--status-error)`}`,background:`var(--bg)`,fontSize:`var(--text-sm)`,lineHeight:1.5},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,marginBottom:4},children:[(0,E.jsx)(`span`,{style:{width:7,height:7,borderRadius:`50%`,background:Me.ok?`var(--status-success)`:`var(--status-error)`,flexShrink:0}}),(0,E.jsx)(`span`,{style:{color:`var(--text-muted)`,flex:1,minWidth:0},children:m(Me.ok?`files.pushSuccess`:`files.pushFailed`)}),(0,E.jsx)(`button`,{onClick:()=>Ne(null),"aria-label":m(`files.dismissError`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:16,height:16,padding:0,background:`none`,border:`none`,borderRadius:4,color:`var(--text-dim)`,cursor:`pointer`,flexShrink:0},children:(0,E.jsx)(ni,{size:p.base})})]}),Me.output&&(0,E.jsx)(`pre`,{style:{margin:0,maxHeight:140,overflow:`auto`,whiteSpace:`pre-wrap`,wordBreak:`break-all`,color:Me.ok?`var(--text-muted)`:`var(--status-error)`,fontFamily:`var(--font-mono)`},children:Me.output})]}),Le&&(0,E.jsxs)(`div`,{role:`status`,"aria-live":`polite`,style:{marginTop:4,padding:`6px 8px`,borderRadius:6,border:`1px solid ${Le.ok?`var(--status-success)`:`var(--status-error)`}`,background:`var(--bg)`,fontSize:`var(--text-sm)`,lineHeight:1.5},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,marginBottom:4},children:[(0,E.jsx)(`span`,{style:{width:7,height:7,borderRadius:`50%`,background:Le.ok?`var(--status-success)`:`var(--status-error)`,flexShrink:0}}),(0,E.jsx)(`span`,{style:{color:`var(--text-muted)`,flex:1,minWidth:0},children:m(Le.ok?`files.pullSuccess`:`files.pullFailed`)}),(0,E.jsx)(`button`,{onClick:()=>Re(null),"aria-label":m(`files.dismissError`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:16,height:16,padding:0,background:`none`,border:`none`,borderRadius:4,color:`var(--text-dim)`,cursor:`pointer`,flexShrink:0},children:(0,E.jsx)(ni,{size:p.base})})]}),Le.output&&(0,E.jsx)(`pre`,{style:{margin:0,maxHeight:140,overflow:`auto`,whiteSpace:`pre-wrap`,wordBreak:`break-all`,color:Le.ok?`var(--text-muted)`:`var(--status-error)`,fontFamily:`var(--font-mono)`},children:Le.output})]}),de&&(0,E.jsx)(P9,{message:de,onDismiss:()=>fe(null)}),L&&(0,E.jsx)(P9,{message:x9(L,m),onDismiss:()=>se(null)}),_e&&(0,E.jsx)(P9,{message:_e,onDismiss:()=>ve(null)}),(0,E.jsx)(N9,{prefix:m(`files.stagedPrefix`),count:ie.length,additions:ne.additions,deletions:ne.deletions,t:m}),ie.length>0?ie.map(n=>(0,E.jsx)(j9,{status:n,cwd:e,onOpenFile:t,onStageToggle:e=>void lt(e,!0),unstage:!0,t:m},`staged-${n.filePath}`)):(0,E.jsx)(`div`,{style:{padding:`8px 10px`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`,textAlign:`center`},children:m(`files.noStagedChanges`)}),(0,E.jsx)(`div`,{style:{height:6}}),(0,E.jsx)(N9,{prefix:m(`files.unstagedPrefix`),count:ae.length,additions:P.additions,deletions:P.deletions,t:m}),ae.length>0?ae.map(n=>(0,E.jsx)(j9,{status:n,cwd:e,onOpenFile:t,onStageToggle:e=>void lt(e,!1),t:m},n.filePath)):(0,E.jsx)(`div`,{style:{padding:`8px 10px`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`,textAlign:`center`},children:m(`files.noUnstagedChanges`)})]}),s&&(0,E.jsxs)(I9,{ref:x,children:[y?(0,E.jsx)(`div`,{style:{padding:`8px 12px`,fontSize:`var(--text-sm)`,color:`var(--status-error)`},children:x9(y,m)}):(D?O:h).map(n=>(0,E.jsx)(A9,{node:n,depth:0,cwd:e,onOpenFile:t,onAtMention:i,expandedPaths:S,onToggleExpanded:tt,refreshToken:Ze,highlightedPaths:k,gitStatusByPath:$e,changedDirectoryPaths:et,t:m},n.fullPath)),!_&&!y&&h.length===0&&(0,E.jsx)(`div`,{style:{padding:`8px 12px`,fontSize:`var(--text-sm)`,color:`var(--text-dim)`},children:m(`files.noFiles`)})]}),(0,E.jsx)(Bx,{open:ye,title:m(`git.ai.notConfiguredTitle`),description:m(`git.ai.notConfiguredDesc`),confirmText:m(`git.ai.goToConfig`),cancelText:m(`sidebar.cancel`),onCancel:()=>xe(!1),onConfirm:()=>{xe(!1),u?.(`git`)},icon:(0,E.jsx)(Kr,{size:p[`5xl`],style:{color:`var(--accent)`}})}),(0,E.jsx)(Bx,{open:pe,title:m(`files.commitTitle`),description:(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{children:m(`files.confirmStageAllCommit`,{count:j.length})}),R.trim()!==``&&(0,E.jsx)(`div`,{style:{marginTop:8,padding:`6px 10px`,background:`var(--bg)`,border:`1px solid var(--border)`,borderRadius:6,fontFamily:`var(--font-mono)`,fontSize:`var(--text-sm)`,color:`var(--text-muted)`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,maxHeight:120,overflowY:`auto`,textAlign:`left`},children:R.trim()})]}),confirmText:m(`files.stageAllAndCommit`),cancelText:m(`sidebar.cancel`),onCancel:()=>me(!1),onConfirm:()=>{me(!1),ut(!0)},icon:(0,E.jsxs)(`svg`,{width:p[`5xl`],height:p[`5xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`var(--status-warning)`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,style:{flexShrink:0,marginTop:1},children:[(0,E.jsx)(`path`,{d:`M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10Z`}),(0,E.jsx)(`path`,{d:`m9 12 2 2 4-4`})]})})]})});function R9({cwd:e,onOpenFile:t,explorerRefreshKey:n,onExplorerRefresh:r,onAtMention:i,onAtMentions:a,sessionId:o,onOpenConfig:s}){let{t:c}=N(),[l,u]=(0,d.useState)(0),[f,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)(0),[_,v]=(0,d.useState)(!0),[y,b]=(0,d.useState)(!1),x=(0,d.useRef)(null),S=(0,d.useRef)(null),[C,w]=(0,d.useState)(!1),[T,D]=(0,d.useState)(``),O=(0,d.useRef)(null);return(0,d.useEffect)(()=>{C&&O.current?.focus()},[C]),(0,d.useEffect)(()=>{n!==void 0&&u(e=>e+1)},[n]),e?(0,E.jsx)(F7,{title:c(`files.explorer`),open:!0,onToggle:()=>{},collapsible:!1,testId:`explorer-scroll`,hintTestId:`explorer`,style:{flex:1,minHeight:0},scrollStyle:{background:`var(--bg)`},actions:(0,E.jsx)(O7,{items:[{key:`git`,onClick:()=>v(e=>!e),title:c(`sidebar.changedFiles`,{count:h}),ariaPressed:!_,color:h>0?`var(--accent)`:`var(--text-muted)`,background:_?void 0:`var(--bg-selected)`,borderColor:_?void 0:`var(--accent)`,icon:(0,E.jsx)(Sr,{size:p.lg})},{key:`search`,testId:`explorer-search-toggle`,onClick:()=>{C&&D(``),w(e=>!e)},title:c(`files.search`),ariaPressed:C,color:C?`var(--accent)`:`var(--text-muted)`,background:C?`var(--bg-selected)`:void 0,icon:(0,E.jsx)(Hr,{size:p.lg})},{key:`upload`,onClick:()=>S.current?.openUploadPicker(),disabled:f,title:c(`sidebar.uploadFilesTitle`),color:`var(--text-muted)`,icon:(0,E.jsx)(Ir,{size:p.base})},{key:`refresh`,onClick:()=>{r?r():u(e=>e+1),b(!0),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>b(!1),2e3)},title:c(`sidebar.refreshExplorer`),skipHover:y,color:y?`var(--status-success)`:`var(--text-muted)`,background:y?`color-mix(in srgb, var(--status-success) 18%, transparent)`:void 0,icon:y?(0,E.jsx)(ur,{size:p.lg,color:`var(--status-success)`,strokeWidth:2.5}):(0,E.jsx)(Rr,{size:p.lg})}]}),headerExtra:C?(0,E.jsxs)(`div`,{"data-testid":`explorer-search`,style:{display:`flex`,alignItems:`center`,gap:4,width:`100%`,minWidth:0,padding:`4px 8px`,background:`var(--bg)`,borderBottom:`1px solid var(--border)`,boxSizing:`border-box`},children:[(0,E.jsx)(Hr,{size:p.lg,color:`var(--text-muted)`,style:{flexShrink:0}}),(0,E.jsx)(`input`,{ref:O,"data-testid":`explorer-search-input`,value:T,onChange:e=>D(e.target.value),placeholder:c(`files.searchPlaceholder`),"aria-label":c(`files.search`),style:{flex:1,minWidth:0,background:`transparent`,border:`none`,outline:`none`,color:`var(--text)`,fontSize:`var(--text-sm)`}}),T&&(0,E.jsx)(`button`,{type:`button`,onClick:()=>{D(``),O.current?.focus()},"aria-label":c(`chat.clearSearch`),style:{border:`none`,background:`transparent`,color:`var(--text-muted)`,cursor:`pointer`,fontSize:`var(--text-sm)`,display:`flex`,alignItems:`center`,justifyContent:`center`,width:16,height:16,padding:0,flexShrink:0},children:(0,E.jsx)(ni,{size:p.base})})]}):void 0,children:(0,E.jsx)(L9,{ref:S,cwd:e,onOpenFile:t??(()=>{}),refreshKey:l,searchQuery:T,onAtMention:i,onAtMentions:a,onUploadBusyChange:m,changesCollapsed:_,onChangesCountChange:g,sessionId:o,onOpenConfig:s})}):null}function z9({geometries:e,messages:t,onAddMessage:n,onRemoveMessage:r,onUpdateMessage:i,widgets:a,closedKeys:o,onReopen:s}){let{t:c}=N(),[l,u]=(0,d.useState)(null),[f,p]=(0,d.useState)(null),m=(0,d.useRef)(null);(0,d.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]);let h=e=>a.find(t=>t.key===e)?.lines[0],g=(e,t,n)=>{s(e),p({key:e,x:t,y:n}),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>p(null),2500)},_=[...new Set([...Object.keys(e),...o.keys()])].map(t=>[t,e[t]]);return(0,E.jsxs)(`div`,{style:{height:`100%`,display:`flex`,flexDirection:`column`,background:`var(--bg)`},children:[_.length===0?(0,E.jsx)(`div`,{style:{padding:`32px 16px`,textAlign:`center`,color:`var(--text-dim)`,fontSize:`var(--text-lg)`,lineHeight:1.6},children:c(`config.widgets.empty`)}):(0,E.jsx)(`div`,{style:{flex:1,minHeight:0,overflowY:`auto`,padding:10,display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignContent:`flex-start`,gap:6},children:_.map(([e,a])=>{let s=t[e]??[],d=o.has(e),f=h(e);return(0,E.jsxs)(`div`,{"data-testid":`widget-config-item-${e}`,style:{flex:`1 1 200px`,boxSizing:`border-box`,padding:`8px 10px`,borderRadius:5,background:`var(--bg-panel)`,border:`1px solid var(--border)`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:7,flexWrap:`wrap`},children:[(0,E.jsxs)(`div`,{style:{minWidth:0,flex:`1 1 120px`},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,fontWeight:600,fontFamily:`var(--font-mono)`,color:`var(--text)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e}),a&&(0,E.jsxs)(`div`,{style:{marginTop:2,fontSize:`var(--text-sm)`,fontFamily:`var(--font-mono)`,color:`var(--text-dim)`},children:[c(`config.widgets.x`),`: `,a.x,` `,c(`config.widgets.y`),`: `,a.y,` ·`,` `,c(`config.widgets.width`),`: `,a.width,` `,c(`config.widgets.height`),`:`,` `,a.height]})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:4,flexShrink:0},children:[d&&(0,E.jsxs)(`button`,{type:`button`,"data-testid":`widget-expand-${e}`,"aria-label":c(`widgets.reopen`),title:c(`widgets.reopen`),onClick:t=>g(e,t.clientX,t.clientY),style:{display:`flex`,alignItems:`center`,gap:4,padding:`4px 8px`,borderRadius:5,border:`1px solid var(--border)`,background:`var(--bg)`,color:`var(--text-muted)`,fontSize:`var(--text-sm)`,cursor:`pointer`},className:`hover-shift`,children:[(0,E.jsx)(vr,{size:13,"aria-hidden":!0}),c(`widgets.reopen`)]}),(0,E.jsxs)(`button`,{type:`button`,"data-testid":`widget-bind-${e}`,onClick:()=>u(e),style:{display:`flex`,alignItems:`center`,gap:4,padding:`4px 8px`,borderRadius:5,border:`1px solid var(--border)`,background:`var(--bg)`,color:`var(--text-muted)`,fontSize:`var(--text-sm)`,cursor:`pointer`},children:[(0,E.jsx)(Or,{size:13,"aria-hidden":!0}),c(`config.widgets.bind`)]})]})]}),f&&(0,E.jsx)(`div`,{style:{marginTop:4,fontSize:`var(--text-sm)`,color:`var(--text-muted)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:f}),(0,E.jsx)(KK,{messages:s,onAdd:t=>n(e,t),onRemove:t=>r(e,t),onUpdate:(t,n)=>i(e,t,n),bindOpen:l===e,onBindOpenChange:e=>{e||u(null)},ns:`widgets`,bindTestIdPrefix:`widget-bind`,editTestIdPrefix:`widget-edit`,chipTestIdPrefix:`widget-bound-${e}`,bindHintArgs:{key:e}})]},e)})}),f&&(0,E.jsx)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":`widget-expanded-toast`,style:{position:`fixed`,left:Math.min(f.x,window.innerWidth-180),top:f.y+12,transform:`translateX(-50%)`,zIndex:2e3,padding:`8px 12px`,borderRadius:7,border:`1px solid var(--status-success)`,background:`var(--bg)`,color:`var(--text)`,fontSize:`var(--text-base)`,boxShadow:`0 4px 16px var(--shadow-strong)`,whiteSpace:`nowrap`},children:c(`widgets.expandedToChat`,{key:f.key})})]})}var B9=e=>window.history.replaceState(null,``,e),V9=36,H9=176,U9=224,W9=86,G9=116;function K9(){let[e,t]=(0,d.useState)(!1);(0,d.useEffect)(()=>{t(!0)},[]);let[n]=(0,d.useState)(()=>Mq(new URLSearchParams(window.location.search))),{isDark:r,toggleTheme:i}=Xn(),{locale:a,setLocale:o,t:s,supportedLocales:c}=N(),l=ne();Sq();let{settingsValue:u,defaultThinkingLevel:f,setDefaultThinkingLevel:m,compaction:h,retry:g,defaultProjectTrust:_,setDefaultProjectTrust:v,subagents:y,savedWorkspaces:b,handleSavedWorkspacesChange:x,widgetGeometries:S,setWidgetGeometry:C,widgetMessages:w,addWidgetMessage:T,removeWidgetMessage:D,updateWidgetMessage:O,fontScale:k,setFontScale:A}=mt({isDark:r,toggleTheme:i}),{selectedSession:j,effectiveNewSessionCwd:M,showChat:P,projectTrustCwd:ee,refreshKey:F,sessionKey:te,explorerRefreshKey:re,setExplorerRefreshKey:ie,modelsRefreshKey:I,setModelsRefreshKey:L,activeCwd:se,initialCwdStatus:R,initialCwdError:ue,initialSessionRestored:de,projectTrust:me,projectTrustDialogOpen:ge,setProjectTrustDialogOpen:_e,projectTrustBusy:ve,projectTrustError:ye,setProjectTrustError:be,extensionDialogActiveRef:xe,handleSelectSession:Se,handleNewSession:Ce,handleSessionCreated:we,handleAgentEnd:Te,handleSessionRenamed:Ee,handleSessionForked:De,handleSessionDeleted:Oe,handleCwdChange:Ae,handleTrustProject:Me,handleExplorerRefresh:Ne,handleInitialRestoreDone:Pe}=ke({initialNavigation:n,onProjectSwitch:()=>{_t(null),Fe(e=>e.filter(e=>e.kind!==`file`)),Ie(null),B9(`/`)},onSessionSelected:e=>{l&&!e&&Ze(!1)},onTopPanelReset:()=>_t(null)}),{setSavedTabs:Fe,setActiveSavedId:Ie,configTabOpen:Le,configSection:Re,setConfigSection:ze,configTabActive:Be,activeFileTab:Ve,fileTabs:He,modelConfigFocus:Ue,handleOpenFile:We,openConfigTab:Ge,handleOpenModelConfig:Ke,closeConfigTab:qe,handleCloseMainTab:Je}=vq({onSessionSelected:()=>{Tt(!1),l&&Ze(!1)},onRefreshModels:()=>L(e=>e+1)}),Ye=(0,d.useCallback)(e=>{We(e,yG(e),{sourceSessionId:j?.id??null})},[We,j?.id]),[Xe,Ze]=(0,d.useState)(!0),[Qe,$e]=(0,d.useState)(!1),et=(0,d.useRef)(280),tt=(0,d.useRef)(280),nt=(0,d.useCallback)(()=>typeof window>`u`?480:ce({viewportWidth:window.innerWidth,rightPanelOpen:!1,rightPanelWidth:0}),[]),rt=fe({ariaLabel:s(`layout.resizeSidebar`),cssVariable:`--sidebar-width`,defaultWidth:280,getMaxWidth:nt,growthDirection:`right`,maxWidth:480,minWidth:180,storageKey:`pi-sidebar-width`,widthRef:et}),it=rt.reclampWidth,at=fe({ariaLabel:s(`layout.resizeWidgetPanel`),cssVariable:`--widget-panel-width`,defaultWidth:280,getMaxWidth:()=>typeof window>`u`?560:le({viewportWidth:window.innerWidth,sidebarOpen:Xe,sidebarWidth:rt.width}),growthDirection:`left`,maxWidth:560,minWidth:200,storageKey:`pi-widget-panel-width`,widthRef:tt});(0,d.useEffect)(()=>{l&&Ze(!1)},[l]),(0,d.useEffect)(()=>{$e(!0)},[]),(0,d.useEffect)(()=>{it()},[it]);let ot=(0,d.useRef)(null),st=(0,d.useRef)(null),ct=(0,d.useRef)(null),ut=(0,d.useRef)(null),dt=(0,d.useRef)(null),ft=pe(),pt=(0,d.useCallback)(()=>{ft.schedule(()=>{_t(null)},150)},[ft]),ht=ft.cancel,[gt,_t]=(0,d.useState)(null),[vt,yt]=(0,d.useState)(null),bt=(0,d.useCallback)(e=>{l&&Ze(!1),_t(t=>t===e?null:e)},[l]),xt=(0,d.useCallback)(()=>{l&&_t(null),Ze(e=>!e)},[l]);(0,d.useEffect)(()=>{if(!gt)return;let e=()=>{if(document.hidden)return;let e=st.current?.getBoundingClientRect();if(e){if(gt===`language`&&!l&&ut.current){let t=ut.current.getBoundingClientRect(),n=ct.current?.getBoundingClientRect(),r=n?.top??t.top,i=n?.bottom??t.bottom,a=Math.min(H9,n?.width??e.width),o=Math.min(t.left-1,Math.max(n?.left??e.left,(n?.right??e.right)-a)),s=i+4;yt({top:s+W9>window.innerHeight-4?r-W9:s,left:o,width:a});return}if(gt===`fontSize`&&!l&&dt.current){let t=dt.current.getBoundingClientRect(),n=ct.current?.getBoundingClientRect(),r=n?.top??t.top,i=n?.bottom??t.bottom,a=Math.min(U9,n?.width??e.width),o=Math.min(t.left-1,Math.max(n?.left??e.left,(n?.right??e.right)-a)),s=i+4;yt({top:s+G9>window.innerHeight-4?r-G9:s,left:o,width:a});return}yt({top:e.bottom,left:e.left,width:e.width})}};e();let t=new ResizeObserver(e);return st.current&&t.observe(st.current),ut.current&&t.observe(ut.current),dt.current&&t.observe(dt.current),()=>t.disconnect()},[gt,l]);let{widgetPanelOpen:St,setWidgetPanelOpen:Ct,widgetsTabActive:wt,setWidgetsTabActive:Tt,extensionWidgets:Et,closedWidgets:Dt,handleCloseWidget:Ot,handleReopenWidget:kt,handleExtensionWidgetsChange:At,rightSidebarOpen:jt,setRightSidebarOpen:Mt,closedWidgetCount:Nt}=yq({widgetGeometries:S,setWidgetGeometry:C}),Pt=l?St:jt,Ft=(0,d.useCallback)((e,t)=>{ot.current?.insertText(kq(e,t))},[]),It=(0,d.useCallback)(e=>{let t=jq(e);t&&ot.current?.insertText(t)},[]),Lt=(0,d.useCallback)((e,t,n)=>{ot.current?.insertText(Aq(e,t,n))},[]),Rt=n.sessionId;ae({onNewSession:e=>Ce(`kb-${Date.now()}`,e),activeCwd:se});let zt=de&&!P,Bt=[{id:lq,label:s(`tabs.chat`),closable:!1,icon:(0,E.jsx)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`})})},{id:dq,label:s(`tabs.widgets`),badge:Nt,closable:!1,icon:(0,E.jsxs)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1`}),(0,E.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`,rx:`1`}),(0,E.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`}),(0,E.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`,rx:`1`})]})},...Le?[{id:uq,label:s(`config.title`),closable:!0,icon:(0,E.jsx)(Wr,{width:p.lg,height:p.lg,"aria-hidden":`true`})}]:[],...He],Vt=se?yG(se)||se:null,Ht=Vt?`Pi Web · ${Vt}`:`Pi Web`;(0,d.useEffect)(()=>{document.title=Ht},[Ht]),(0,d.useEffect)(()=>{let e=()=>{document.title=Ht};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[Ht]);let Ut=oe(),Wt=(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{ref:ct,style:{padding:`2px 8px`,flexShrink:0,display:`flex`,justifyContent:`space-between`,gap:4},children:[{label:s(`config.title`),onClick:()=>Ge(),disabled:!1,icon:(0,E.jsx)(Wr,{width:p[`3xl`],height:p[`3xl`],"aria-hidden":`true`})},...Ut===`granted`||Ut==="default"||Ut===`denied`?[{label:s(Ut===`granted`?`notify.permission.grantedHint`:Ut===`denied`?`notify.permission.deniedHint`:`notify.permission.requestHint`),ariaLabel:s(Ut===`granted`?`notify.permission.granted`:Ut===`denied`?`notify.permission.denied`:`notify.permission.request`),onClick:Ut===`granted`?()=>{}:()=>Zt(),disabled:!1,testId:`notify-permission`,color:Ut===`granted`?`var(--status-success)`:Ut===`denied`?`var(--status-error)`:`var(--accent)`,icon:(0,E.jsx)(`svg`,{width:p[`3xl`],height:p[`3xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:Ut===`denied`?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`path`,{d:`M8.7 3A6 6 0 0 1 18 8a21.3 21.3 0 0 0 .6 5`}),(0,E.jsx)(`path`,{d:`M17 17H3s3-2 3-9a4.67 4.67 0 0 1 .3-1.7`}),(0,E.jsx)(`path`,{d:`M10.3 21a1.94 1.94 0 0 0 3.4 0`}),(0,E.jsx)(`path`,{d:`m2 2 20 20`})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`path`,{d:`M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9`}),(0,E.jsx)(`path`,{d:`M10.3 21a1.94 1.94 0 0 0 3.4 0`})]})})}]:[],{label:s(r?`theme.light`:`theme.dark`),onClick:()=>i(),disabled:!1,ariaPressed:r,icon:r?(0,E.jsxs)(`svg`,{width:p[`3xl`],height:p[`3xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`5`}),(0,E.jsx)(`line`,{x1:`12`,y1:`1`,x2:`12`,y2:`3`}),(0,E.jsx)(`line`,{x1:`12`,y1:`21`,x2:`12`,y2:`23`}),(0,E.jsx)(`line`,{x1:`4.22`,y1:`4.22`,x2:`5.64`,y2:`5.64`}),(0,E.jsx)(`line`,{x1:`18.36`,y1:`18.36`,x2:`19.78`,y2:`19.78`}),(0,E.jsx)(`line`,{x1:`1`,y1:`12`,x2:`3`,y2:`12`}),(0,E.jsx)(`line`,{x1:`21`,y1:`12`,x2:`23`,y2:`12`}),(0,E.jsx)(`line`,{x1:`4.22`,y1:`19.78`,x2:`5.64`,y2:`18.36`}),(0,E.jsx)(`line`,{x1:`18.36`,y1:`5.64`,x2:`19.78`,y2:`4.22`})]}):(0,E.jsx)(`svg`,{width:p[`3xl`],height:p[`3xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,E.jsx)(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`})})},{label:s(`common.language`),onClick:()=>{l&&Ze(!1),ht(),_t(`language`)},onMouseEnter:()=>{ht(),gt!==`language`&&_t(`language`)},onMouseLeave:pt,disabled:!1,ref:ut,ariaExpanded:gt===`language`,noTooltip:!0,icon:(0,E.jsxs)(`svg`,{width:p[`3xl`],height:p[`3xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,E.jsx)(`line`,{x1:`2`,y1:`12`,x2:`22`,y2:`12`}),(0,E.jsx)(`path`,{d:`M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z`})]})},{label:s(`theme.fontSize`),onClick:()=>{l&&Ze(!1),ht(),_t(`fontSize`)},onMouseEnter:()=>{ht(),gt!==`fontSize`&&_t(`fontSize`)},onMouseLeave:pt,disabled:!1,ref:dt,ariaExpanded:gt===`fontSize`,noTooltip:!0,icon:(0,E.jsxs)(`svg`,{width:p[`3xl`],height:p[`3xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`polyline`,{points:`4 7 4 4 20 4 20 7`}),(0,E.jsx)(`line`,{x1:`9`,y1:`20`,x2:`15`,y2:`20`}),(0,E.jsx)(`line`,{x1:`12`,y1:`4`,x2:`12`,y2:`20`})]})}].map(({label:e,onClick:t,onMouseEnter:n,onMouseLeave:r,disabled:i,icon:a,ref:o,ariaPressed:s,ariaExpanded:c,noTooltip:l,color:u,ariaLabel:d,testId:f})=>{let p=(0,E.jsx)(`button`,{ref:o,onClick:t,disabled:i,"data-testid":f,"aria-label":d??e,"aria-pressed":s,"aria-haspopup":c===void 0?void 0:`menu`,"aria-expanded":c,style:{flex:1,display:`flex`,alignItems:`center`,justifyContent:`center`,height:32,padding:0,background:`none`,border:`none`,borderRadius:9,...u?{color:u}:{color:`var(--text-muted)`},cursor:i?`default`:`pointer`,opacity:i?.35:1,transition:`background 0.12s, color 0.12s`,"--hover-color":`var(--text)`},onMouseEnter:n,onMouseLeave:r,className:`hover-shift`,children:a});return l?(0,E.jsx)(`div`,{style:{flex:1,minWidth:0,display:`flex`},children:p},e):(0,E.jsx)(oi,{label:e,wrapperStyle:{flex:1,minWidth:0,display:`flex`},children:p},e)})}),(0,E.jsx)(t9,{selectedSessionId:j?.id??null,selectedSession:j,onSelectSession:Se,onNewSession:Ce,initialSessionId:Rt,skipInitialProjectSelection:n.requestedCwd!==null,onInitialRestoreDone:Pe,refreshKey:F,onSessionDeleted:Oe,selectedCwd:j?.cwd??M,onCwdChange:Ae,savedWorkspaces:b,onSavedWorkspacesChange:x,onOpenFile:We})]});if(!e)return(0,E.jsx)(Nq,{});let Gt=(0,E.jsx)(oi,{label:s(Xe?`sidebar.hide`:`sidebar.show`),children:(0,E.jsx)(`button`,{onClick:xt,"aria-label":s(Xe?`sidebar.hide`:`sidebar.show`),"aria-pressed":Xe,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:V9,height:V9,padding:0,background:`none`,border:`none`,borderRight:`1px solid var(--border)`,color:Xe?`var(--text)`:`var(--text-muted)`,cursor:`pointer`,flexShrink:0,transition:`color 0.12s`,"--hover-color":`var(--text)`},className:`hover-shift`,children:(0,E.jsxs)(`svg`,{width:p[`4xl`],height:p[`4xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`rect`,{x:`3`,y:`3`,width:p[`4xl`],height:p[`4xl`],rx:`2`}),(0,E.jsx)(`line`,{x1:`9`,y1:`3`,x2:`9`,y2:`21`})]})})}),Kt=P&&me?.requiresTrust&&!me.trusted?(0,E.jsx)(oi,{label:s(`trust.resourcesNotLoaded`),wrapperStyle:{height:`100%`},children:(0,E.jsxs)(`button`,{type:`button`,onClick:()=>{be(null),_e(!0)},"aria-label":s(`trust.resourcesNotLoaded`),style:{display:`flex`,alignItems:`center`,gap:6,height:`100%`,padding:l?`0 10px`:`0 12px`,background:`none`,border:`none`,borderLeft:`1px solid var(--border)`,color:`var(--status-warning)`,cursor:`pointer`,flexShrink:0,fontSize:`var(--text-sm)`,whiteSpace:`nowrap`},children:[(0,E.jsxs)(`svg`,{width:p.lg,height:p.lg,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10Z`}),(0,E.jsx)(`path`,{d:`M12 8v4`}),(0,E.jsx)(`path`,{d:`M12 16h.01`})]}),!l&&(0,E.jsx)(`span`,{children:s(`trust.resourcesNotLoaded`)})]})}):null,qt=(0,E.jsx)(oi,{label:s(Pt?`sidebar.hide`:`sidebar.show`),children:(0,E.jsx)(`button`,{onClick:()=>{l?Ct(e=>!e):Mt(e=>!e)},"aria-controls":`widget-panel`,"aria-expanded":Pt,"aria-label":s(Pt?`sidebar.hide`:`sidebar.show`),"data-testid":`widget-panel-toggle`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,width:36,height:36,padding:0,background:`none`,border:`none`,borderLeft:`1px solid var(--border)`,color:St?`var(--text)`:`var(--text-muted)`,cursor:`pointer`,flexShrink:0,transition:`color 0.12s`,"--hover-color":`var(--text)`},className:`hover-shift`,children:(0,E.jsxs)(`svg`,{width:p[`4xl`],height:p[`4xl`],viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`rect`,{x:`3`,y:`3`,width:p[`4xl`],height:p[`4xl`],rx:`2`}),(0,E.jsx)(`line`,{x1:`15`,y1:`3`,x2:`15`,y2:`21`})]})})});return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(he,{value:u,children:(0,E.jsx)(je,{value:{activeTopPanel:gt,toggleTopPanel:bt,closeTopPanel:()=>_t(null)},children:(0,E.jsx)(E.Fragment,{children:(0,E.jsxs)(ai,{delayDuration:0,children:[(0,E.jsx)(`style`,{children:`
|
|
486
486
|
@media (max-width: 640px) {
|
|
487
487
|
.sidebar-overlay-backdrop.sidebar-mobile-pending {
|
|
488
488
|
opacity: 0 !important;
|
|
@@ -493,4 +493,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
493
493
|
box-shadow: none;
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
|
-
`}),(0,E.jsx)(an,{}),(0,E.jsxs)(`div`,{style:{display:`flex`,width:`100%`,height:`var(--app-viewport-height, 100dvh)`,paddingLeft:`env(safe-area-inset-left)`,paddingRight:`env(safe-area-inset-right)`,overflow:`hidden`,background:`var(--bg)`},children:[(0,E.jsx)(`div`,{className:`sidebar-overlay-backdrop${Qe?``:` sidebar-mobile-pending`}`,onClick:()=>Ze(!1),style:{position:`fixed`,inset:0,zIndex:199,background:`var(--overlay)`,opacity:+!!Xe,pointerEvents:Xe?`auto`:`none`,transition:`opacity 0.25s ease`}}),(0,E.jsx)(`div`,{ref:rt.panelRef,id:`session-sidebar`,className:`sidebar-container${Xe?` sidebar-open`:` sidebar-closed`}${Qe?``:` sidebar-mobile-pending`}${rt.isResizing?` sidebar-resizing`:``}`,"data-testid":`sidebar`,style:{"--sidebar-width":`${rt.width}px`,background:`var(--bg-panel)`,borderRight:`1px solid var(--border)`,display:`flex`,flexDirection:`column`,flexShrink:0,paddingTop:`env(safe-area-inset-top)`,paddingBottom:`env(safe-area-inset-bottom)`,zIndex:200},children:Wt}),Xe&&(0,E.jsx)(oi,{label:`${s(`layout.resizeSidebar`)}: ${s(`layout.resizeHint`)}`,wrapperStyle:{display:`flex`,flex:`0 0 0`,width:0},children:(0,E.jsx)(`div`,{...rt.separatorProps,"aria-controls":`session-sidebar`,className:`panel-resize-handle sidebar-resize-handle${rt.isResizing?` is-resizing`:``}`,"data-resize-handle":`sidebar`})}),(0,E.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`,minWidth:0},children:[gt&&vt&&(0,E.jsxs)(`div`,{onMouseEnter:ht,onMouseLeave:pt,style:{position:`fixed`,top:vt.top,left:vt.left,width:vt.width,maxHeight:`calc(100dvh - ${vt.top}px)`,overflowY:`auto`,zIndex:1500},children:[gt===`language`&&(0,E.jsx)(`div`,{role:`menu`,"aria-label":s(`common.language`),style:{background:`var(--bg-panel)`,border:`1px solid var(--border)`,overflow:`hidden`,padding:4},children:c.map(e=>(0,E.jsx)(`button`,{type:`button`,onClick:()=>{o(e.id),_t(null)},role:`menuitemradio`,"aria-checked":a===e.id,style:{display:`flex`,alignItems:`center`,width:`100%`,height:34,padding:`0 10px`,border:`none`,borderRadius:4,background:a===e.id?`var(--bg-selected)`:`transparent`,color:`var(--text)`,cursor:`pointer`,textAlign:`left`,fontSize:`var(--text-base)`,transition:`background 0.1s`},className:a===e.id?void 0:`hover-shift`,children:(0,E.jsx)(`span`,{children:e.label})},e.id))}),gt===`fontSize`&&(0,E.jsxs)(`div`,{role:`menu`,"aria-label":s(`theme.fontSize`),style:{background:`var(--bg-panel)`,border:`1px solid var(--border)`,padding:`10px 12px 12px`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,fontSize:`var(--text-base)`,color:`var(--text-muted)`,marginBottom:8},children:[(0,E.jsx)(`span`,{children:s(`theme.fontSize`)}),(0,E.jsxs)(`span`,{style:{fontFamily:`var(--font-mono)`,color:`var(--text)`,fontWeight:600},children:[Math.round(k*100),`%`]})]}),(0,E.jsx)(`input`,{type:`range`,min:.85,max:1.3,step:.05,value:k,onChange:e=>A(Number(e.target.value)),"aria-label":s(`theme.fontSize`),style:{width:`100%`,accentColor:`var(--accent)`,cursor:`pointer`}}),(0,E.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,fontSize:`var(--text-xs)`,color:`var(--text-dim)`,marginTop:4},children:[(0,E.jsx)(`span`,{children:`85%`}),(0,E.jsx)(`span`,{children:`130%`})]})]})]}),(0,E.jsxs)(Gn,{tabs:Bt,activeTabId:Be?uq:wt?dq:Ve?fq(Ve.filePath):lq,leftExtra:Gt,rightExtra:qt,onSelectTab:e=>{if(e===`widgets`){Tt(!0),Ie(null);return}Tt(!1),Ie(e===`chat`?null:e)},onCloseTab:Je,tabBarRef:st,overlay:(0,E.jsxs)(E.Fragment,{children:[R===`validating`&&(0,E.jsxs)(`div`,{role:`status`,style:{height:`100%`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:8,padding:24,color:`var(--text-muted)`,textAlign:`center`},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-xl)`,color:`var(--text)`},children:s(`workspace.opening`)}),(0,E.jsx)(`div`,{style:{maxWidth:`min(720px, 100%)`,overflowWrap:`anywhere`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-base)`},children:n.requestedCwd})]}),R===`error`&&(0,E.jsxs)(`div`,{role:`alert`,style:{height:`100%`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:8,padding:24,color:`var(--text-muted)`,textAlign:`center`},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-xl)`,color:`var(--status-error)`},children:s(`workspace.unable`)}),(0,E.jsx)(`div`,{style:{maxWidth:`min(720px, 100%)`,overflowWrap:`anywhere`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-base)`},children:n.requestedCwd}),(0,E.jsx)(`div`,{style:{maxWidth:720,fontSize:`var(--text-base)`},children:ue})]}),zt&&(se?(0,E.jsx)(`div`,{style:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--text-muted)`,fontSize:`var(--text-2xl)`},children:s(`workspace.selectSession`)}):(0,E.jsxs)(`div`,{style:{height:`100%`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:12,userSelect:`none`},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-6xl)`,fontWeight:700,fontStyle:`italic`,color:`var(--accent)`},children:`Pi Web`}),(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--text-muted)`},children:s(`workspace.selectWorkspace`)})]}))]}),children:[(0,E.jsx)(Un,{id:uq,testId:`config-tab-pane`,children:(0,E.jsx)(sq,{section:Re,onSectionChange:ze,cwd:ee,sessionId:j?.id??null,onClose:qe,onOpenFile:We,sidebarWidth:rt.width,onSidebarWidthChange:rt.setWidth,widgetPanelWidth:at.width,onWidgetPanelWidthChange:at.setWidth,modelConfigFocus:Ue,defaultThinkingLevel:f,onDefaultThinkingLevelChange:m,compaction:h,onCompactionChange:e=>lt({firstPaint:{compaction:e}}),retry:g,onRetryChange:e=>lt({firstPaint:{retry:e}}),defaultProjectTrust:_,onDefaultProjectTrustChange:v,subagents:y,onSubagentsChange:e=>lt({firstPaint:{subagents:{defaultModel:e.defaultModel||void 0,defaultThinking:e.defaultThinking||void 0}}})})}),(0,E.jsx)(Un,{id:Ve?fq(Ve.filePath):`file:`,testId:`file-tab-pane`,children:Ve&&(0,E.jsx)(x7,{filePath:Ve.filePath,cwd:se??void 0,sourceSessionId:Ve.sourceSessionId,gitRefreshKey:re,initialDisplayMode:Ve.initialDisplayMode,onMentionLines:Lt,onSaved:()=>ie(e=>e+1),onOpenFile:e=>We(e,yG(e),{sourceSessionId:Ve.sourceSessionId})})}),(0,E.jsx)(Un,{id:lq,keepAlive:!0,testId:`chat-tab-pane`,scroll:`hidden`,activeWhen:P,children:(0,E.jsx)(`div`,{style:{flex:1,minHeight:0,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:(0,E.jsx)(z5,{session:j,newSessionCwd:M,onAgentEnd:Te,onSessionCreated:we,onSessionForked:De,modelsRefreshKey:I,onOpenModelConfig:Ke,chatInputRef:ot,onOpenFile:Ye,onSessionRenamed:Ee,windowTitleBase:Vt,toolbarExtra:Kt,closedWidgetKeys:Dt,onCloseWidget:Ot,onExtensionWidgetsChange:At,onExtensionDialogChange:e=>{xe.current=e}},te)})}),(0,E.jsx)(Un,{id:dq,keepAlive:!0,testId:`widgets-tab-pane`,zIndex:1,activeWhen:P,children:(0,E.jsx)(R9,{geometries:S,messages:w,onAddMessage:T,onRemoveMessage:D,onUpdateMessage:O,widgets:Et,closedKeys:Dt,onReopen:kt})})]})]}),Pt&&(0,E.jsx)(oi,{label:`${s(`layout.resizeWidgetPanel`)}: ${s(`layout.resizeHint`)}`,wrapperStyle:{display:`flex`,flex:`0 0 0`,width:0},children:(0,E.jsx)(`div`,{...at.separatorProps,"aria-controls":`widget-panel`,className:`panel-resize-handle widget-panel-resize-handle${at.isResizing?` is-resizing`:``}`,"data-resize-handle":`widget-panel`})}),!l&&!jt?null:(0,E.jsx)(`div`,{ref:at.panelRef,"aria-controls":`widget-panel`,style:l?{position:`fixed`,inset:0,zIndex:250,display:`flex`,flexDirection:`column`}:{"--widget-panel-width":`${at.width}px`,width:`var(--widget-panel-width)`,display:`flex`,flexDirection:`column`,minWidth:0,overflow:`hidden`,borderLeft:`1px solid var(--border)`,background:`var(--bg)`},children:(0,E.jsx)(L9,{cwd:j?.cwd??M,onOpenFile:We,explorerRefreshKey:re,onExplorerRefresh:Ne,onAtMention:Ft,onAtMentions:It,sessionId:j?.id??null,onOpenConfig:e=>Ge(e)})})]}),ge&&ee&&(0,E.jsx)(w7,{cwd:ee,busy:ve,error:ye,onCancel:()=>{ve||_e(!1)},onConfirm:()=>void Me()})]})})})}),(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(a9,{}),(0,E.jsx)(v9,{})]})]})}var K9=class extends d.Component{constructor(...e){super(...e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){yx(e,`render error`)}render(){return this.state.hasError?(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:12,height:`100vh`,color:`var(--text)`,fontSize:`var(--text-base)`},children:[(0,E.jsx)(`span`,{children:`⚠️`}),(0,E.jsx)(`span`,{children:`Something went wrong while rendering.`}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>{this.setState({hasError:!1})},style:{border:`1px solid var(--border)`,background:`none`,color:`var(--text)`,borderRadius:6,padding:`4px 14px`,cursor:`pointer`},children:`Try again`})]}):this.props.children}};function q9(){return(0,d.useEffect)(()=>{if(!(`serviceWorker`in navigator))return;let e=()=>{navigator.serviceWorker.register(`/sw.js?v=0.14.2`,{scope:`/`,updateViaCache:`none`}).catch(e=>{console.error(`Failed to register the Pi Web service worker:`,e)})};if(document.readyState===`complete`){e();return}return window.addEventListener(`load`,e,{once:!0}),()=>window.removeEventListener(`load`,e)},[]),null}var J9=`piE2eFixtureDir`;function Y9(){return typeof window>`u`?null:new URL(window.location.href).searchParams.get(`piE2eFixtureDir`)}function X9(){if(typeof document>`u`)return;let e=Y9();e&&(document.cookie=`${J9}=${encodeURIComponent(e)}; path=/; SameSite=Lax`)}async function Z9(){X9(),Iq(!0),zq();let e=Lq(`boot`),t=null;try{let n=await Se.load();e(`preferences catalog loaded`,`locale=${n.firstPaint?.locale}`);let r=n.firstPaint?.locale;(r===`en`||r===`zh-CN`)&&(t=r,document.documentElement.lang=r===`zh-CN`?`zh-CN`:`en`);let i=n.theme;if(i===`dark`?document.documentElement.classList.add(`dark`):document.documentElement.classList.remove(`dark`),i)try{localStorage.setItem(`pi-theme`,i)}catch{}}catch{}e(`root render`),window.addEventListener(`unhandledrejection`,e=>{yx(e.reason,`unhandled promise rejection`)}),window.addEventListener(`error`,e=>{let t=(e.error instanceof Error?e.error.message:``)||e.message||``;t.includes(`ResizeObserver loop`)||t.startsWith(`Script error`)||yx(e.error??e.message,`uncaught error`)}),(0,f.createRoot)(document.getElementById(`root`)).render((0,E.jsx)(d.StrictMode,{children:(0,E.jsx)(K9,{children:(0,E.jsxs)(M,{initialLocale:t,children:[(0,E.jsx)(G9,{}),(0,E.jsx)(q9,{})]})})}))}Z9();export{Z1 as a,Y4 as i,Z0 as n,T as o,G4 as r,i as s,C0 as t};
|
|
496
|
+
`}),(0,E.jsx)(an,{}),(0,E.jsxs)(`div`,{style:{display:`flex`,width:`100%`,height:`var(--app-viewport-height, 100dvh)`,paddingLeft:`env(safe-area-inset-left)`,paddingRight:`env(safe-area-inset-right)`,overflow:`hidden`,background:`var(--bg)`},children:[(0,E.jsx)(`div`,{className:`sidebar-overlay-backdrop${Qe?``:` sidebar-mobile-pending`}`,onClick:()=>Ze(!1),style:{position:`fixed`,inset:0,zIndex:199,background:`var(--overlay)`,opacity:+!!Xe,pointerEvents:Xe?`auto`:`none`,transition:`opacity 0.25s ease`}}),(0,E.jsx)(`div`,{ref:rt.panelRef,id:`session-sidebar`,className:`sidebar-container${Xe?` sidebar-open`:` sidebar-closed`}${Qe?``:` sidebar-mobile-pending`}${rt.isResizing?` sidebar-resizing`:``}`,"data-testid":`sidebar`,style:{"--sidebar-width":`${rt.width}px`,background:`var(--bg-panel)`,borderRight:`1px solid var(--border)`,display:`flex`,flexDirection:`column`,flexShrink:0,paddingTop:`env(safe-area-inset-top)`,paddingBottom:`env(safe-area-inset-bottom)`,zIndex:200},children:Wt}),Xe&&(0,E.jsx)(oi,{label:`${s(`layout.resizeSidebar`)}: ${s(`layout.resizeHint`)}`,wrapperStyle:{display:`flex`,flex:`0 0 0`,width:0},children:(0,E.jsx)(`div`,{...rt.separatorProps,"aria-controls":`session-sidebar`,className:`panel-resize-handle sidebar-resize-handle${rt.isResizing?` is-resizing`:``}`,"data-resize-handle":`sidebar`})}),(0,E.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`,minWidth:0},children:[gt&&vt&&(0,E.jsxs)(`div`,{onMouseEnter:ht,onMouseLeave:pt,style:{position:`fixed`,top:vt.top,left:vt.left,width:vt.width,maxHeight:`calc(100dvh - ${vt.top}px)`,overflowY:`auto`,zIndex:1500},children:[gt===`language`&&(0,E.jsx)(`div`,{role:`menu`,"aria-label":s(`common.language`),style:{background:`var(--bg-panel)`,border:`1px solid var(--border)`,overflow:`hidden`,padding:4},children:c.map(e=>(0,E.jsx)(`button`,{type:`button`,onClick:()=>{o(e.id),_t(null)},role:`menuitemradio`,"aria-checked":a===e.id,style:{display:`flex`,alignItems:`center`,width:`100%`,height:34,padding:`0 10px`,border:`none`,borderRadius:4,background:a===e.id?`var(--bg-selected)`:`transparent`,color:`var(--text)`,cursor:`pointer`,textAlign:`left`,fontSize:`var(--text-base)`,transition:`background 0.1s`},className:a===e.id?void 0:`hover-shift`,children:(0,E.jsx)(`span`,{children:e.label})},e.id))}),gt===`fontSize`&&(0,E.jsxs)(`div`,{role:`menu`,"aria-label":s(`theme.fontSize`),style:{background:`var(--bg-panel)`,border:`1px solid var(--border)`,padding:`10px 12px 12px`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,fontSize:`var(--text-base)`,color:`var(--text-muted)`,marginBottom:8},children:[(0,E.jsx)(`span`,{children:s(`theme.fontSize`)}),(0,E.jsxs)(`span`,{style:{fontFamily:`var(--font-mono)`,color:`var(--text)`,fontWeight:600},children:[Math.round(k*100),`%`]})]}),(0,E.jsx)(`input`,{type:`range`,min:.85,max:1.3,step:.05,value:k,onChange:e=>A(Number(e.target.value)),"aria-label":s(`theme.fontSize`),style:{width:`100%`,accentColor:`var(--accent)`,cursor:`pointer`}}),(0,E.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,fontSize:`var(--text-xs)`,color:`var(--text-dim)`,marginTop:4},children:[(0,E.jsx)(`span`,{children:`85%`}),(0,E.jsx)(`span`,{children:`130%`})]})]})]}),(0,E.jsxs)(Gn,{tabs:Bt,activeTabId:Be?uq:wt?dq:Ve?fq(Ve.filePath):lq,leftExtra:Gt,rightExtra:qt,onSelectTab:e=>{if(e===`widgets`){Tt(!0),Ie(null);return}Tt(!1),Ie(e===`chat`?null:e)},onCloseTab:Je,tabBarRef:st,overlay:(0,E.jsxs)(E.Fragment,{children:[R===`validating`&&(0,E.jsxs)(`div`,{role:`status`,style:{height:`100%`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:8,padding:24,color:`var(--text-muted)`,textAlign:`center`},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-xl)`,color:`var(--text)`},children:s(`workspace.opening`)}),(0,E.jsx)(`div`,{style:{maxWidth:`min(720px, 100%)`,overflowWrap:`anywhere`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-base)`},children:n.requestedCwd})]}),R===`error`&&(0,E.jsxs)(`div`,{role:`alert`,style:{height:`100%`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:8,padding:24,color:`var(--text-muted)`,textAlign:`center`},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-xl)`,color:`var(--status-error)`},children:s(`workspace.unable`)}),(0,E.jsx)(`div`,{style:{maxWidth:`min(720px, 100%)`,overflowWrap:`anywhere`,fontFamily:`var(--font-mono)`,fontSize:`var(--text-base)`},children:n.requestedCwd}),(0,E.jsx)(`div`,{style:{maxWidth:720,fontSize:`var(--text-base)`},children:ue})]}),zt&&(se?(0,E.jsx)(`div`,{style:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--text-muted)`,fontSize:`var(--text-2xl)`},children:s(`workspace.selectSession`)}):(0,E.jsxs)(`div`,{style:{height:`100%`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:12,userSelect:`none`},children:[(0,E.jsx)(`div`,{style:{fontSize:`var(--text-6xl)`,fontWeight:700,fontStyle:`italic`,color:`var(--accent)`},children:`Pi Web`}),(0,E.jsx)(`div`,{style:{fontSize:`var(--text-base)`,color:`var(--text-muted)`},children:s(`workspace.selectWorkspace`)})]}))]}),children:[(0,E.jsx)(Un,{id:uq,testId:`config-tab-pane`,children:(0,E.jsx)(sq,{section:Re,onSectionChange:ze,cwd:ee,sessionId:j?.id??null,onClose:qe,onOpenFile:We,sidebarWidth:rt.width,onSidebarWidthChange:rt.setWidth,widgetPanelWidth:at.width,onWidgetPanelWidthChange:at.setWidth,modelConfigFocus:Ue,defaultThinkingLevel:f,onDefaultThinkingLevelChange:m,compaction:h,onCompactionChange:e=>lt({firstPaint:{compaction:e}}),retry:g,onRetryChange:e=>lt({firstPaint:{retry:e}}),defaultProjectTrust:_,onDefaultProjectTrustChange:v,subagents:y,onSubagentsChange:e=>lt({firstPaint:{subagents:{defaultModel:e.defaultModel||void 0,defaultThinking:e.defaultThinking||void 0}}})})}),(0,E.jsx)(Un,{id:Ve?fq(Ve.filePath):`file:`,testId:`file-tab-pane`,children:Ve&&(0,E.jsx)(C7,{filePath:Ve.filePath,cwd:se??void 0,sourceSessionId:Ve.sourceSessionId,gitRefreshKey:re,initialDisplayMode:Ve.initialDisplayMode,onMentionLines:Lt,onSaved:()=>ie(e=>e+1),onOpenFile:e=>We(e,yG(e),{sourceSessionId:Ve.sourceSessionId})})}),(0,E.jsx)(Un,{id:lq,keepAlive:!0,testId:`chat-tab-pane`,scroll:`hidden`,activeWhen:P,children:(0,E.jsx)(`div`,{style:{flex:1,minHeight:0,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:(0,E.jsx)(V5,{session:j,newSessionCwd:M,onAgentEnd:Te,onSessionCreated:we,onSessionForked:De,modelsRefreshKey:I,onOpenModelConfig:Ke,chatInputRef:ot,onOpenFile:Ye,onSessionRenamed:Ee,windowTitleBase:Vt,toolbarExtra:Kt,closedWidgetKeys:Dt,onCloseWidget:Ot,onExtensionWidgetsChange:At,onExtensionDialogChange:e=>{xe.current=e}},te)})}),(0,E.jsx)(Un,{id:dq,keepAlive:!0,testId:`widgets-tab-pane`,zIndex:1,activeWhen:P,children:(0,E.jsx)(z9,{geometries:S,messages:w,onAddMessage:T,onRemoveMessage:D,onUpdateMessage:O,widgets:Et,closedKeys:Dt,onReopen:kt})})]})]}),Pt&&(0,E.jsx)(oi,{label:`${s(`layout.resizeWidgetPanel`)}: ${s(`layout.resizeHint`)}`,wrapperStyle:{display:`flex`,flex:`0 0 0`,width:0},children:(0,E.jsx)(`div`,{...at.separatorProps,"aria-controls":`widget-panel`,className:`panel-resize-handle widget-panel-resize-handle${at.isResizing?` is-resizing`:``}`,"data-resize-handle":`widget-panel`})}),!l&&!jt?null:(0,E.jsx)(`div`,{ref:at.panelRef,"aria-controls":`widget-panel`,style:l?{position:`fixed`,inset:0,zIndex:250,display:`flex`,flexDirection:`column`}:{"--widget-panel-width":`${at.width}px`,width:`var(--widget-panel-width)`,display:`flex`,flexDirection:`column`,minWidth:0,overflow:`hidden`,borderLeft:`1px solid var(--border)`,background:`var(--bg)`},children:(0,E.jsx)(R9,{cwd:j?.cwd??M,onOpenFile:We,explorerRefreshKey:re,onExplorerRefresh:Ne,onAtMention:Ft,onAtMentions:It,sessionId:j?.id??null,onOpenConfig:e=>Ge(e)})})]}),ge&&ee&&(0,E.jsx)(E7,{cwd:ee,busy:ve,error:ye,onCancel:()=>{ve||_e(!1)},onConfirm:()=>void Me()})]})})})}),(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(o9,{}),(0,E.jsx)(y9,{})]})]})}var q9=class extends d.Component{constructor(...e){super(...e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){yx(e,`render error`)}render(){return this.state.hasError?(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:12,height:`100vh`,color:`var(--text)`,fontSize:`var(--text-base)`},children:[(0,E.jsx)(`span`,{children:`⚠️`}),(0,E.jsx)(`span`,{children:`Something went wrong while rendering.`}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>{this.setState({hasError:!1})},style:{border:`1px solid var(--border)`,background:`none`,color:`var(--text)`,borderRadius:6,padding:`4px 14px`,cursor:`pointer`},children:`Try again`})]}):this.props.children}};function J9(){return(0,d.useEffect)(()=>{if(!(`serviceWorker`in navigator))return;let e=()=>{navigator.serviceWorker.register(`/sw.js?v=0.14.3`,{scope:`/`,updateViaCache:`none`}).catch(e=>{console.error(`Failed to register the Pi Web service worker:`,e)})};if(document.readyState===`complete`){e();return}return window.addEventListener(`load`,e,{once:!0}),()=>window.removeEventListener(`load`,e)},[]),null}var Y9=`piE2eFixtureDir`;function X9(){return typeof window>`u`?null:new URL(window.location.href).searchParams.get(`piE2eFixtureDir`)}function Z9(){if(typeof document>`u`)return;let e=X9();e&&(document.cookie=`${Y9}=${encodeURIComponent(e)}; path=/; SameSite=Lax`)}async function Q9(){Z9(),Iq(!0),zq();let e=Lq(`boot`),t=null;try{let n=await Se.load();e(`preferences catalog loaded`,`locale=${n.firstPaint?.locale}`);let r=n.firstPaint?.locale;(r===`en`||r===`zh-CN`)&&(t=r,document.documentElement.lang=r===`zh-CN`?`zh-CN`:`en`);let i=n.theme;if(i===`dark`?document.documentElement.classList.add(`dark`):document.documentElement.classList.remove(`dark`),i)try{localStorage.setItem(`pi-theme`,i)}catch{}}catch{}e(`root render`),window.addEventListener(`unhandledrejection`,e=>{yx(e.reason,`unhandled promise rejection`)}),window.addEventListener(`error`,e=>{let t=(e.error instanceof Error?e.error.message:``)||e.message||``;t.includes(`ResizeObserver loop`)||t.startsWith(`Script error`)||yx(e.error??e.message,`uncaught error`)}),(0,f.createRoot)(document.getElementById(`root`)).render((0,E.jsx)(d.StrictMode,{children:(0,E.jsx)(q9,{children:(0,E.jsxs)(M,{initialLocale:t,children:[(0,E.jsx)(K9,{}),(0,E.jsx)(J9,{})]})})}))}Q9();export{$1 as a,Z4 as i,$0 as n,T as o,q4 as r,i as s,T0 as t};
|