toyon 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/CHANGELOG.md +36 -0
  2. package/dist/cli.js +1 -1
  3. package/dist/daemon.js +659 -213
  4. package/dist/shell/assets/{Editor-Dq4a0gFv.js → Editor-v7DPr3mY.js} +82 -82
  5. package/dist/shell/assets/Editor-v7DPr3mY.js.br +0 -0
  6. package/dist/shell/assets/Editor-v7DPr3mY.js.gz +0 -0
  7. package/dist/shell/assets/{XTerm-BfuBg96X.js → XTerm-CxU9R8q7.js} +1 -1
  8. package/dist/shell/assets/XTerm-CxU9R8q7.js.br +0 -0
  9. package/dist/shell/assets/XTerm-CxU9R8q7.js.gz +0 -0
  10. package/dist/shell/assets/{cssMode-An1EUPnJ.js → cssMode-DD5SBqGU.js} +1 -1
  11. package/dist/shell/assets/cssMode-DD5SBqGU.js.br +0 -0
  12. package/dist/shell/assets/cssMode-DD5SBqGU.js.gz +0 -0
  13. package/dist/shell/assets/{freemarker2-PYOY2M7v.js → freemarker2-CZ3XZhjv.js} +1 -1
  14. package/dist/shell/assets/freemarker2-CZ3XZhjv.js.br +0 -0
  15. package/dist/shell/assets/freemarker2-CZ3XZhjv.js.gz +0 -0
  16. package/dist/shell/assets/{grammar-e2yQ-Xdq.js → grammar-DqAbMw7d.js} +1 -1
  17. package/dist/shell/assets/grammar-DqAbMw7d.js.br +0 -0
  18. package/dist/shell/assets/grammar-DqAbMw7d.js.gz +0 -0
  19. package/dist/shell/assets/{handlebars-BtSTwhBl.js → handlebars-CzZa_iMI.js} +1 -1
  20. package/dist/shell/assets/handlebars-CzZa_iMI.js.br +0 -0
  21. package/dist/shell/assets/handlebars-CzZa_iMI.js.gz +0 -0
  22. package/dist/shell/assets/{html-lmman0qi.js → html-uU_fKUCO.js} +1 -1
  23. package/dist/shell/assets/html-uU_fKUCO.js.br +0 -0
  24. package/dist/shell/assets/html-uU_fKUCO.js.gz +0 -0
  25. package/dist/shell/assets/{htmlMode-CYUUrmIv.js → htmlMode-DmuqvqLQ.js} +1 -1
  26. package/dist/shell/assets/htmlMode-DmuqvqLQ.js.br +0 -0
  27. package/dist/shell/assets/htmlMode-DmuqvqLQ.js.gz +0 -0
  28. package/dist/shell/assets/index-DMZqXgxq.js +295 -0
  29. package/dist/shell/assets/index-DMZqXgxq.js.br +0 -0
  30. package/dist/shell/assets/index-DMZqXgxq.js.gz +0 -0
  31. package/dist/shell/assets/index-LFCDUSQF.css +1 -0
  32. package/dist/shell/assets/index-LFCDUSQF.css.br +0 -0
  33. package/dist/shell/assets/index-LFCDUSQF.css.gz +0 -0
  34. package/dist/shell/assets/{javascript-CHVOacyY.js → javascript-CvDukmsa.js} +1 -1
  35. package/dist/shell/assets/{jsonMode-WaLJvHyp.js → jsonMode-C8ZGvKb7.js} +1 -1
  36. package/dist/shell/assets/jsonMode-C8ZGvKb7.js.br +0 -0
  37. package/dist/shell/assets/jsonMode-C8ZGvKb7.js.gz +0 -0
  38. package/dist/shell/assets/{liquid-Bhzd8TLd.js → liquid-CSFER4cS.js} +1 -1
  39. package/dist/shell/assets/liquid-CSFER4cS.js.br +0 -0
  40. package/dist/shell/assets/liquid-CSFER4cS.js.gz +0 -0
  41. package/dist/shell/assets/{lspLanguageFeatures-DS22S_fR.js → lspLanguageFeatures-Bnq8PCF_.js} +1 -1
  42. package/dist/shell/assets/lspLanguageFeatures-Bnq8PCF_.js.br +0 -0
  43. package/dist/shell/assets/lspLanguageFeatures-Bnq8PCF_.js.gz +0 -0
  44. package/dist/shell/assets/{mdx-1x45Dt5R.js → mdx-DN7UGs67.js} +1 -1
  45. package/dist/shell/assets/mdx-DN7UGs67.js.br +0 -0
  46. package/dist/shell/assets/mdx-DN7UGs67.js.gz +0 -0
  47. package/dist/shell/assets/{python-B0fHYRyj.js → python-Cdtmy77f.js} +1 -1
  48. package/dist/shell/assets/python-Cdtmy77f.js.br +0 -0
  49. package/dist/shell/assets/python-Cdtmy77f.js.gz +0 -0
  50. package/dist/shell/assets/{razor-C48vGnF3.js → razor-BzMJ8H5n.js} +1 -1
  51. package/dist/shell/assets/razor-BzMJ8H5n.js.br +0 -0
  52. package/dist/shell/assets/razor-BzMJ8H5n.js.gz +0 -0
  53. package/dist/shell/assets/toyon-mono-bold-1tbrivW1.woff2 +0 -0
  54. package/dist/shell/assets/toyon-mono-regular-BUtE4EFW.woff2 +0 -0
  55. package/dist/shell/assets/{tsMode-2SIN2sKE.js → tsMode-B_VeTgWt.js} +1 -1
  56. package/dist/shell/assets/tsMode-B_VeTgWt.js.br +0 -0
  57. package/dist/shell/assets/tsMode-B_VeTgWt.js.gz +0 -0
  58. package/dist/shell/assets/{xml-DPJN-pu8.js → xml-Cdv7rs1C.js} +1 -1
  59. package/dist/shell/assets/xml-Cdv7rs1C.js.br +0 -0
  60. package/dist/shell/assets/xml-Cdv7rs1C.js.gz +0 -0
  61. package/dist/shell/assets/{yaml-CDzmW7EM.js → yaml-Co_E2Q5j.js} +1 -1
  62. package/dist/shell/assets/yaml-Co_E2Q5j.js.br +0 -0
  63. package/dist/shell/assets/yaml-Co_E2Q5j.js.gz +0 -0
  64. package/dist/shell/index.html +2 -2
  65. package/package.json +1 -1
  66. package/dist/shell/assets/Editor-Dq4a0gFv.js.br +0 -0
  67. package/dist/shell/assets/Editor-Dq4a0gFv.js.gz +0 -0
  68. package/dist/shell/assets/XTerm-BfuBg96X.js.br +0 -0
  69. package/dist/shell/assets/XTerm-BfuBg96X.js.gz +0 -0
  70. package/dist/shell/assets/cssMode-An1EUPnJ.js.br +0 -0
  71. package/dist/shell/assets/cssMode-An1EUPnJ.js.gz +0 -0
  72. package/dist/shell/assets/freemarker2-PYOY2M7v.js.br +0 -0
  73. package/dist/shell/assets/freemarker2-PYOY2M7v.js.gz +0 -0
  74. package/dist/shell/assets/grammar-e2yQ-Xdq.js.br +0 -0
  75. package/dist/shell/assets/grammar-e2yQ-Xdq.js.gz +0 -0
  76. package/dist/shell/assets/handlebars-BtSTwhBl.js.br +0 -0
  77. package/dist/shell/assets/handlebars-BtSTwhBl.js.gz +0 -0
  78. package/dist/shell/assets/html-lmman0qi.js.br +0 -0
  79. package/dist/shell/assets/html-lmman0qi.js.gz +0 -0
  80. package/dist/shell/assets/htmlMode-CYUUrmIv.js.br +0 -0
  81. package/dist/shell/assets/htmlMode-CYUUrmIv.js.gz +0 -0
  82. package/dist/shell/assets/index-BDzHAr7c.css +0 -1
  83. package/dist/shell/assets/index-BDzHAr7c.css.br +0 -0
  84. package/dist/shell/assets/index-BDzHAr7c.css.gz +0 -0
  85. package/dist/shell/assets/index-o7SjsIYr.js +0 -294
  86. package/dist/shell/assets/index-o7SjsIYr.js.br +0 -0
  87. package/dist/shell/assets/index-o7SjsIYr.js.gz +0 -0
  88. package/dist/shell/assets/jsonMode-WaLJvHyp.js.br +0 -0
  89. package/dist/shell/assets/jsonMode-WaLJvHyp.js.gz +0 -0
  90. package/dist/shell/assets/liquid-Bhzd8TLd.js.br +0 -0
  91. package/dist/shell/assets/liquid-Bhzd8TLd.js.gz +0 -0
  92. package/dist/shell/assets/lspLanguageFeatures-DS22S_fR.js.br +0 -0
  93. package/dist/shell/assets/lspLanguageFeatures-DS22S_fR.js.gz +0 -0
  94. package/dist/shell/assets/mdx-1x45Dt5R.js.br +0 -0
  95. package/dist/shell/assets/mdx-1x45Dt5R.js.gz +0 -0
  96. package/dist/shell/assets/python-B0fHYRyj.js.br +0 -0
  97. package/dist/shell/assets/python-B0fHYRyj.js.gz +0 -0
  98. package/dist/shell/assets/razor-C48vGnF3.js.br +0 -0
  99. package/dist/shell/assets/razor-C48vGnF3.js.gz +0 -0
  100. package/dist/shell/assets/toyon-mono-bold-u3Ky0k2u.woff2 +0 -0
  101. package/dist/shell/assets/toyon-mono-regular-BC3CdGld.woff2 +0 -0
  102. package/dist/shell/assets/tsMode-2SIN2sKE.js.br +0 -0
  103. package/dist/shell/assets/tsMode-2SIN2sKE.js.gz +0 -0
  104. package/dist/shell/assets/xml-DPJN-pu8.js.br +0 -0
  105. package/dist/shell/assets/xml-DPJN-pu8.js.gz +0 -0
  106. package/dist/shell/assets/yaml-CDzmW7EM.js.br +0 -0
  107. package/dist/shell/assets/yaml-CDzmW7EM.js.gz +0 -0
@@ -1,294 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Editor-Dq4a0gFv.js","assets/grammar-e2yQ-Xdq.js","assets/Editor-CB2SckMT.css","assets/XTerm-BfuBg96X.js","assets/XTerm-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
2
- var MI=Object.defineProperty;var LI=(e,t,n)=>t in e?MI(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var _t=(e,t,n)=>LI(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const s of o)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(o){const s={};return o.integrity&&(s.integrity=o.integrity),o.referrerPolicy&&(s.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?s.credentials="include":o.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(o){if(o.ep)return;o.ep=!0;const s=n(o);fetch(o.href,s)}})();function IS(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var lg={exports:{}},eu={},ug={exports:{}},on={};/**
3
- * @license React
4
- * react.production.min.js
5
- *
6
- * Copyright (c) Facebook, Inc. and its affiliates.
7
- *
8
- * This source code is licensed under the MIT license found in the
9
- * LICENSE file in the root directory of this source tree.
10
- */var wb;function PI(){if(wb)return on;wb=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.iterator;function g(B){return B===null||typeof B!="object"?null:(B=p&&B[p]||B["@@iterator"],typeof B=="function"?B:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,v={};function x(B,Q,ue){this.props=B,this.context=Q,this.refs=v,this.updater=ue||y}x.prototype.isReactComponent={},x.prototype.setState=function(B,Q){if(typeof B!="object"&&typeof B!="function"&&B!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,B,Q,"setState")},x.prototype.forceUpdate=function(B){this.updater.enqueueForceUpdate(this,B,"forceUpdate")};function N(){}N.prototype=x.prototype;function S(B,Q,ue){this.props=B,this.context=Q,this.refs=v,this.updater=ue||y}var T=S.prototype=new N;T.constructor=S,w(T,x.prototype),T.isPureReactComponent=!0;var j=Array.isArray,$=Object.prototype.hasOwnProperty,R={current:null},A={key:!0,ref:!0,__self:!0,__source:!0};function I(B,Q,ue){var he,Ne={},De=null,Be=null;if(Q!=null)for(he in Q.ref!==void 0&&(Be=Q.ref),Q.key!==void 0&&(De=""+Q.key),Q)$.call(Q,he)&&!A.hasOwnProperty(he)&&(Ne[he]=Q[he]);var Z=arguments.length-2;if(Z===1)Ne.children=ue;else if(1<Z){for(var J=Array(Z),pe=0;pe<Z;pe++)J[pe]=arguments[pe+2];Ne.children=J}if(B&&B.defaultProps)for(he in Z=B.defaultProps,Z)Ne[he]===void 0&&(Ne[he]=Z[he]);return{$$typeof:e,type:B,key:De,ref:Be,props:Ne,_owner:R.current}}function M(B,Q){return{$$typeof:e,type:B.type,key:Q,ref:B.ref,props:B.props,_owner:B._owner}}function P(B){return typeof B=="object"&&B!==null&&B.$$typeof===e}function F(B){var Q={"=":"=0",":":"=2"};return"$"+B.replace(/[=:]/g,function(ue){return Q[ue]})}var q=/\/+/g;function W(B,Q){return typeof B=="object"&&B!==null&&B.key!=null?F(""+B.key):Q.toString(36)}function ee(B,Q,ue,he,Ne){var De=typeof B;(De==="undefined"||De==="boolean")&&(B=null);var Be=!1;if(B===null)Be=!0;else switch(De){case"string":case"number":Be=!0;break;case"object":switch(B.$$typeof){case e:case t:Be=!0}}if(Be)return Be=B,Ne=Ne(Be),B=he===""?"."+W(Be,0):he,j(Ne)?(ue="",B!=null&&(ue=B.replace(q,"$&/")+"/"),ee(Ne,Q,ue,"",function(pe){return pe})):Ne!=null&&(P(Ne)&&(Ne=M(Ne,ue+(!Ne.key||Be&&Be.key===Ne.key?"":(""+Ne.key).replace(q,"$&/")+"/")+B)),Q.push(Ne)),1;if(Be=0,he=he===""?".":he+":",j(B))for(var Z=0;Z<B.length;Z++){De=B[Z];var J=he+W(De,Z);Be+=ee(De,Q,ue,J,Ne)}else if(J=g(B),typeof J=="function")for(B=J.call(B),Z=0;!(De=B.next()).done;)De=De.value,J=he+W(De,Z++),Be+=ee(De,Q,ue,J,Ne);else if(De==="object")throw Q=String(B),Error("Objects are not valid as a React child (found: "+(Q==="[object Object]"?"object with keys {"+Object.keys(B).join(", ")+"}":Q)+"). If you meant to render a collection of children, use an array instead.");return Be}function V(B,Q,ue){if(B==null)return B;var he=[],Ne=0;return ee(B,he,"","",function(De){return Q.call(ue,De,Ne++)}),he}function te(B){if(B._status===-1){var Q=B._result;Q=Q(),Q.then(function(ue){(B._status===0||B._status===-1)&&(B._status=1,B._result=ue)},function(ue){(B._status===0||B._status===-1)&&(B._status=2,B._result=ue)}),B._status===-1&&(B._status=0,B._result=Q)}if(B._status===1)return B._result.default;throw B._result}var K={current:null},C={transition:null},oe={ReactCurrentDispatcher:K,ReactCurrentBatchConfig:C,ReactCurrentOwner:R};function U(){throw Error("act(...) is not supported in production builds of React.")}return on.Children={map:V,forEach:function(B,Q,ue){V(B,function(){Q.apply(this,arguments)},ue)},count:function(B){var Q=0;return V(B,function(){Q++}),Q},toArray:function(B){return V(B,function(Q){return Q})||[]},only:function(B){if(!P(B))throw Error("React.Children.only expected to receive a single React element child.");return B}},on.Component=x,on.Fragment=n,on.Profiler=o,on.PureComponent=S,on.StrictMode=r,on.Suspense=u,on.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=oe,on.act=U,on.cloneElement=function(B,Q,ue){if(B==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+B+".");var he=w({},B.props),Ne=B.key,De=B.ref,Be=B._owner;if(Q!=null){if(Q.ref!==void 0&&(De=Q.ref,Be=R.current),Q.key!==void 0&&(Ne=""+Q.key),B.type&&B.type.defaultProps)var Z=B.type.defaultProps;for(J in Q)$.call(Q,J)&&!A.hasOwnProperty(J)&&(he[J]=Q[J]===void 0&&Z!==void 0?Z[J]:Q[J])}var J=arguments.length-2;if(J===1)he.children=ue;else if(1<J){Z=Array(J);for(var pe=0;pe<J;pe++)Z[pe]=arguments[pe+2];he.children=Z}return{$$typeof:e,type:B.type,key:Ne,ref:De,props:he,_owner:Be}},on.createContext=function(B){return B={$$typeof:a,_currentValue:B,_currentValue2:B,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},B.Provider={$$typeof:s,_context:B},B.Consumer=B},on.createElement=I,on.createFactory=function(B){var Q=I.bind(null,B);return Q.type=B,Q},on.createRef=function(){return{current:null}},on.forwardRef=function(B){return{$$typeof:l,render:B}},on.isValidElement=P,on.lazy=function(B){return{$$typeof:h,_payload:{_status:-1,_result:B},_init:te}},on.memo=function(B,Q){return{$$typeof:f,type:B,compare:Q===void 0?null:Q}},on.startTransition=function(B){var Q=C.transition;C.transition={};try{B()}finally{C.transition=Q}},on.unstable_act=U,on.useCallback=function(B,Q){return K.current.useCallback(B,Q)},on.useContext=function(B){return K.current.useContext(B)},on.useDebugValue=function(){},on.useDeferredValue=function(B){return K.current.useDeferredValue(B)},on.useEffect=function(B,Q){return K.current.useEffect(B,Q)},on.useId=function(){return K.current.useId()},on.useImperativeHandle=function(B,Q,ue){return K.current.useImperativeHandle(B,Q,ue)},on.useInsertionEffect=function(B,Q){return K.current.useInsertionEffect(B,Q)},on.useLayoutEffect=function(B,Q){return K.current.useLayoutEffect(B,Q)},on.useMemo=function(B,Q){return K.current.useMemo(B,Q)},on.useReducer=function(B,Q,ue){return K.current.useReducer(B,Q,ue)},on.useRef=function(B){return K.current.useRef(B)},on.useState=function(B){return K.current.useState(B)},on.useSyncExternalStore=function(B,Q,ue){return K.current.useSyncExternalStore(B,Q,ue)},on.useTransition=function(){return K.current.useTransition()},on.version="18.3.1",on}var yb;function Nw(){return yb||(yb=1,ug.exports=PI()),ug.exports}/**
11
- * @license React
12
- * react-jsx-runtime.production.min.js
13
- *
14
- * Copyright (c) Facebook, Inc. and its affiliates.
15
- *
16
- * This source code is licensed under the MIT license found in the
17
- * LICENSE file in the root directory of this source tree.
18
- */var vb;function DI(){if(vb)return eu;vb=1;var e=Nw(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(l,u,f){var h,p={},g=null,y=null;f!==void 0&&(g=""+f),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(y=u.ref);for(h in u)r.call(u,h)&&!s.hasOwnProperty(h)&&(p[h]=u[h]);if(l&&l.defaultProps)for(h in u=l.defaultProps,u)p[h]===void 0&&(p[h]=u[h]);return{$$typeof:t,type:l,key:g,ref:y,props:p,_owner:o.current}}return eu.Fragment=n,eu.jsx=a,eu.jsxs=a,eu}var bb;function zI(){return bb||(bb=1,lg.exports=DI()),lg.exports}var d=zI(),E=Nw();const FI=IS(E);var dg={exports:{}},fo={},fg={exports:{}},hg={};/**
19
- * @license React
20
- * scheduler.production.min.js
21
- *
22
- * Copyright (c) Facebook, Inc. and its affiliates.
23
- *
24
- * This source code is licensed under the MIT license found in the
25
- * LICENSE file in the root directory of this source tree.
26
- */var xb;function BI(){return xb||(xb=1,(function(e){function t(C,oe){var U=C.length;C.push(oe);e:for(;0<U;){var B=U-1>>>1,Q=C[B];if(0<o(Q,oe))C[B]=oe,C[U]=Q,U=B;else break e}}function n(C){return C.length===0?null:C[0]}function r(C){if(C.length===0)return null;var oe=C[0],U=C.pop();if(U!==oe){C[0]=U;e:for(var B=0,Q=C.length,ue=Q>>>1;B<ue;){var he=2*(B+1)-1,Ne=C[he],De=he+1,Be=C[De];if(0>o(Ne,U))De<Q&&0>o(Be,Ne)?(C[B]=Be,C[De]=U,B=De):(C[B]=Ne,C[he]=U,B=he);else if(De<Q&&0>o(Be,U))C[B]=Be,C[De]=U,B=De;else break e}}return oe}function o(C,oe){var U=C.sortIndex-oe.sortIndex;return U!==0?U:C.id-oe.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var a=Date,l=a.now();e.unstable_now=function(){return a.now()-l}}var u=[],f=[],h=1,p=null,g=3,y=!1,w=!1,v=!1,x=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function T(C){for(var oe=n(f);oe!==null;){if(oe.callback===null)r(f);else if(oe.startTime<=C)r(f),oe.sortIndex=oe.expirationTime,t(u,oe);else break;oe=n(f)}}function j(C){if(v=!1,T(C),!w)if(n(u)!==null)w=!0,te($);else{var oe=n(f);oe!==null&&K(j,oe.startTime-C)}}function $(C,oe){w=!1,v&&(v=!1,N(I),I=-1),y=!0;var U=g;try{for(T(oe),p=n(u);p!==null&&(!(p.expirationTime>oe)||C&&!F());){var B=p.callback;if(typeof B=="function"){p.callback=null,g=p.priorityLevel;var Q=B(p.expirationTime<=oe);oe=e.unstable_now(),typeof Q=="function"?p.callback=Q:p===n(u)&&r(u),T(oe)}else r(u);p=n(u)}if(p!==null)var ue=!0;else{var he=n(f);he!==null&&K(j,he.startTime-oe),ue=!1}return ue}finally{p=null,g=U,y=!1}}var R=!1,A=null,I=-1,M=5,P=-1;function F(){return!(e.unstable_now()-P<M)}function q(){if(A!==null){var C=e.unstable_now();P=C;var oe=!0;try{oe=A(!0,C)}finally{oe?W():(R=!1,A=null)}}else R=!1}var W;if(typeof S=="function")W=function(){S(q)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,V=ee.port2;ee.port1.onmessage=q,W=function(){V.postMessage(null)}}else W=function(){x(q,0)};function te(C){A=C,R||(R=!0,W())}function K(C,oe){I=x(function(){C(e.unstable_now())},oe)}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(C){C.callback=null},e.unstable_continueExecution=function(){w||y||(w=!0,te($))},e.unstable_forceFrameRate=function(C){0>C||125<C?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):M=0<C?Math.floor(1e3/C):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(C){switch(g){case 1:case 2:case 3:var oe=3;break;default:oe=g}var U=g;g=oe;try{return C()}finally{g=U}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(C,oe){switch(C){case 1:case 2:case 3:case 4:case 5:break;default:C=3}var U=g;g=C;try{return oe()}finally{g=U}},e.unstable_scheduleCallback=function(C,oe,U){var B=e.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?B+U:B):U=B,C){case 1:var Q=-1;break;case 2:Q=250;break;case 5:Q=1073741823;break;case 4:Q=1e4;break;default:Q=5e3}return Q=U+Q,C={id:h++,callback:oe,priorityLevel:C,startTime:U,expirationTime:Q,sortIndex:-1},U>B?(C.sortIndex=U,t(f,C),n(u)===null&&C===n(f)&&(v?(N(I),I=-1):v=!0,K(j,U-B))):(C.sortIndex=Q,t(u,C),w||y||(w=!0,te($))),C},e.unstable_shouldYield=F,e.unstable_wrapCallback=function(C){var oe=g;return function(){var U=g;g=oe;try{return C.apply(this,arguments)}finally{g=U}}}})(hg)),hg}var Eb;function UI(){return Eb||(Eb=1,fg.exports=BI()),fg.exports}/**
27
- * @license React
28
- * react-dom.production.min.js
29
- *
30
- * Copyright (c) Facebook, Inc. and its affiliates.
31
- *
32
- * This source code is licensed under the MIT license found in the
33
- * LICENSE file in the root directory of this source tree.
34
- */var Sb;function HI(){if(Sb)return fo;Sb=1;var e=Nw(),t=UI();function n(i){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+i,m=1;m<arguments.length;m++)c+="&args[]="+encodeURIComponent(arguments[m]);return"Minified React error #"+i+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function s(i,c){a(i,c),a(i+"Capture",c)}function a(i,c){for(o[i]=c,i=0;i<c.length;i++)r.add(c[i])}var l=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,h={},p={};function g(i){return u.call(p,i)?!0:u.call(h,i)?!1:f.test(i)?p[i]=!0:(h[i]=!0,!1)}function y(i,c,m,k){if(m!==null&&m.type===0)return!1;switch(typeof c){case"function":case"symbol":return!0;case"boolean":return k?!1:m!==null?!m.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function w(i,c,m,k){if(c===null||typeof c>"u"||y(i,c,m,k))return!0;if(k)return!1;if(m!==null)switch(m.type){case 3:return!c;case 4:return c===!1;case 5:return isNaN(c);case 6:return isNaN(c)||1>c}return!1}function v(i,c,m,k,b,_,O){this.acceptsBooleans=c===2||c===3||c===4,this.attributeName=k,this.attributeNamespace=b,this.mustUseProperty=m,this.propertyName=i,this.type=c,this.sanitizeURL=_,this.removeEmptyString=O}var x={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){x[i]=new v(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var c=i[0];x[c]=new v(c,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){x[i]=new v(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){x[i]=new v(i,2,!1,i,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(i){x[i]=new v(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){x[i]=new v(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){x[i]=new v(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){x[i]=new v(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){x[i]=new v(i,5,!1,i.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function S(i){return i[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(i){var c=i.replace(N,S);x[c]=new v(c,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var c=i.replace(N,S);x[c]=new v(c,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var c=i.replace(N,S);x[c]=new v(c,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){x[i]=new v(i,1,!1,i.toLowerCase(),null,!1,!1)}),x.xlinkHref=new v("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){x[i]=new v(i,1,!1,i.toLowerCase(),null,!0,!0)});function T(i,c,m,k){var b=x.hasOwnProperty(c)?x[c]:null;(b!==null?b.type!==0:k||!(2<c.length)||c[0]!=="o"&&c[0]!=="O"||c[1]!=="n"&&c[1]!=="N")&&(w(c,m,b,k)&&(m=null),k||b===null?g(c)&&(m===null?i.removeAttribute(c):i.setAttribute(c,""+m)):b.mustUseProperty?i[b.propertyName]=m===null?b.type===3?!1:"":m:(c=b.attributeName,k=b.attributeNamespace,m===null?i.removeAttribute(c):(b=b.type,m=b===3||b===4&&m===!0?"":""+m,k?i.setAttributeNS(k,c,m):i.setAttribute(c,m))))}var j=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,$=Symbol.for("react.element"),R=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),P=Symbol.for("react.provider"),F=Symbol.for("react.context"),q=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),ee=Symbol.for("react.suspense_list"),V=Symbol.for("react.memo"),te=Symbol.for("react.lazy"),K=Symbol.for("react.offscreen"),C=Symbol.iterator;function oe(i){return i===null||typeof i!="object"?null:(i=C&&i[C]||i["@@iterator"],typeof i=="function"?i:null)}var U=Object.assign,B;function Q(i){if(B===void 0)try{throw Error()}catch(m){var c=m.stack.trim().match(/\n( *(at )?)/);B=c&&c[1]||""}return`
35
- `+B+i}var ue=!1;function he(i,c){if(!i||ue)return"";ue=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(c)if(c=function(){throw Error()},Object.defineProperty(c.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(c,[])}catch(ke){var k=ke}Reflect.construct(i,[],c)}else{try{c.call()}catch(ke){k=ke}i.call(c.prototype)}else{try{throw Error()}catch(ke){k=ke}i()}}catch(ke){if(ke&&k&&typeof ke.stack=="string"){for(var b=ke.stack.split(`
36
- `),_=k.stack.split(`
37
- `),O=b.length-1,X=_.length-1;1<=O&&0<=X&&b[O]!==_[X];)X--;for(;1<=O&&0<=X;O--,X--)if(b[O]!==_[X]){if(O!==1||X!==1)do if(O--,X--,0>X||b[O]!==_[X]){var re=`
38
- `+b[O].replace(" at new "," at ");return i.displayName&&re.includes("<anonymous>")&&(re=re.replace("<anonymous>",i.displayName)),re}while(1<=O&&0<=X);break}}}finally{ue=!1,Error.prepareStackTrace=m}return(i=i?i.displayName||i.name:"")?Q(i):""}function Ne(i){switch(i.tag){case 5:return Q(i.type);case 16:return Q("Lazy");case 13:return Q("Suspense");case 19:return Q("SuspenseList");case 0:case 2:case 15:return i=he(i.type,!1),i;case 11:return i=he(i.type.render,!1),i;case 1:return i=he(i.type,!0),i;default:return""}}function De(i){if(i==null)return null;if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case A:return"Fragment";case R:return"Portal";case M:return"Profiler";case I:return"StrictMode";case W:return"Suspense";case ee:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case F:return(i.displayName||"Context")+".Consumer";case P:return(i._context.displayName||"Context")+".Provider";case q:var c=i.render;return i=i.displayName,i||(i=c.displayName||c.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case V:return c=i.displayName||null,c!==null?c:De(i.type)||"Memo";case te:c=i._payload,i=i._init;try{return De(i(c))}catch{}}return null}function Be(i){var c=i.type;switch(i.tag){case 24:return"Cache";case 9:return(c.displayName||"Context")+".Consumer";case 10:return(c._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return i=c.render,i=i.displayName||i.name||"",c.displayName||(i!==""?"ForwardRef("+i+")":"ForwardRef");case 7:return"Fragment";case 5:return c;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return De(c);case 8:return c===I?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c}return null}function Z(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function J(i){var c=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(c==="checkbox"||c==="radio")}function pe(i){var c=J(i)?"checked":"value",m=Object.getOwnPropertyDescriptor(i.constructor.prototype,c),k=""+i[c];if(!i.hasOwnProperty(c)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var b=m.get,_=m.set;return Object.defineProperty(i,c,{configurable:!0,get:function(){return b.call(this)},set:function(O){k=""+O,_.call(this,O)}}),Object.defineProperty(i,c,{enumerable:m.enumerable}),{getValue:function(){return k},setValue:function(O){k=""+O},stopTracking:function(){i._valueTracker=null,delete i[c]}}}}function de(i){i._valueTracker||(i._valueTracker=pe(i))}function ie(i){if(!i)return!1;var c=i._valueTracker;if(!c)return!0;var m=c.getValue(),k="";return i&&(k=J(i)?i.checked?"true":"false":i.value),i=k,i!==m?(c.setValue(i),!0):!1}function ye(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}function _e(i,c){var m=c.checked;return U({},c,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:m??i._wrapperState.initialChecked})}function be(i,c){var m=c.defaultValue==null?"":c.defaultValue,k=c.checked!=null?c.checked:c.defaultChecked;m=Z(c.value!=null?c.value:m),i._wrapperState={initialChecked:k,initialValue:m,controlled:c.type==="checkbox"||c.type==="radio"?c.checked!=null:c.value!=null}}function $e(i,c){c=c.checked,c!=null&&T(i,"checked",c,!1)}function Ze(i,c){$e(i,c);var m=Z(c.value),k=c.type;if(m!=null)k==="number"?(m===0&&i.value===""||i.value!=m)&&(i.value=""+m):i.value!==""+m&&(i.value=""+m);else if(k==="submit"||k==="reset"){i.removeAttribute("value");return}c.hasOwnProperty("value")?en(i,c.type,m):c.hasOwnProperty("defaultValue")&&en(i,c.type,Z(c.defaultValue)),c.checked==null&&c.defaultChecked!=null&&(i.defaultChecked=!!c.defaultChecked)}function rt(i,c,m){if(c.hasOwnProperty("value")||c.hasOwnProperty("defaultValue")){var k=c.type;if(!(k!=="submit"&&k!=="reset"||c.value!==void 0&&c.value!==null))return;c=""+i._wrapperState.initialValue,m||c===i.value||(i.value=c),i.defaultValue=c}m=i.name,m!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,m!==""&&(i.name=m)}function en(i,c,m){(c!=="number"||ye(i.ownerDocument)!==i)&&(m==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+m&&(i.defaultValue=""+m))}var Xt=Array.isArray;function Et(i,c,m,k){if(i=i.options,c){c={};for(var b=0;b<m.length;b++)c["$"+m[b]]=!0;for(m=0;m<i.length;m++)b=c.hasOwnProperty("$"+i[m].value),i[m].selected!==b&&(i[m].selected=b),b&&k&&(i[m].defaultSelected=!0)}else{for(m=""+Z(m),c=null,b=0;b<i.length;b++){if(i[b].value===m){i[b].selected=!0,k&&(i[b].defaultSelected=!0);return}c!==null||i[b].disabled||(c=i[b])}c!==null&&(c.selected=!0)}}function Ke(i,c){if(c.dangerouslySetInnerHTML!=null)throw Error(n(91));return U({},c,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function Qt(i,c){var m=c.value;if(m==null){if(m=c.children,c=c.defaultValue,m!=null){if(c!=null)throw Error(n(92));if(Xt(m)){if(1<m.length)throw Error(n(93));m=m[0]}c=m}c==null&&(c=""),m=c}i._wrapperState={initialValue:Z(m)}}function Ot(i,c){var m=Z(c.value),k=Z(c.defaultValue);m!=null&&(m=""+m,m!==i.value&&(i.value=m),c.defaultValue==null&&i.defaultValue!==m&&(i.defaultValue=m)),k!=null&&(i.defaultValue=""+k)}function Zt(i){var c=i.textContent;c===i._wrapperState.initialValue&&c!==""&&c!==null&&(i.value=c)}function Ge(i){switch(i){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function nn(i,c){return i==null||i==="http://www.w3.org/1999/xhtml"?Ge(c):i==="http://www.w3.org/2000/svg"&&c==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var pn,It=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(c,m,k,b){MSApp.execUnsafeLocalFunction(function(){return i(c,m,k,b)})}:i})(function(i,c){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=c;else{for(pn=pn||document.createElement("div"),pn.innerHTML="<svg>"+c.valueOf().toString()+"</svg>",c=pn.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;c.firstChild;)i.appendChild(c.firstChild)}});function gt(i,c){if(c){var m=i.firstChild;if(m&&m===i.lastChild&&m.nodeType===3){m.nodeValue=c;return}}i.textContent=c}var Vt={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Cn=["Webkit","ms","Moz","O"];Object.keys(Vt).forEach(function(i){Cn.forEach(function(c){c=c+i.charAt(0).toUpperCase()+i.substring(1),Vt[c]=Vt[i]})});function Ce(i,c,m){return c==null||typeof c=="boolean"||c===""?"":m||typeof c!="number"||c===0||Vt.hasOwnProperty(i)&&Vt[i]?(""+c).trim():c+"px"}function Pt(i,c){i=i.style;for(var m in c)if(c.hasOwnProperty(m)){var k=m.indexOf("--")===0,b=Ce(m,c[m],k);m==="float"&&(m="cssFloat"),k?i.setProperty(m,b):i[m]=b}}var Dt=U({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Wt(i,c){if(c){if(Dt[i]&&(c.children!=null||c.dangerouslySetInnerHTML!=null))throw Error(n(137,i));if(c.dangerouslySetInnerHTML!=null){if(c.children!=null)throw Error(n(60));if(typeof c.dangerouslySetInnerHTML!="object"||!("__html"in c.dangerouslySetInnerHTML))throw Error(n(61))}if(c.style!=null&&typeof c.style!="object")throw Error(n(62))}}function Dn(i,c){if(i.indexOf("-")===-1)return typeof c.is=="string";switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ne=null;function we(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Ye=null,ot=null,zt=null;function Kt(i){if(i=zl(i)){if(typeof Ye!="function")throw Error(n(280));var c=i.stateNode;c&&(c=Od(c),Ye(i.stateNode,i.type,c))}}function D(i){ot?zt?zt.push(i):zt=[i]:ot=i}function se(){if(ot){var i=ot,c=zt;if(zt=ot=null,Kt(i),c)for(i=0;i<c.length;i++)Kt(c[i])}}function Se(i,c){return i(c)}function ze(){}var Ut=!1;function qt(i,c,m){if(Ut)return i(c,m);Ut=!0;try{return Se(i,c,m)}finally{Ut=!1,(ot!==null||zt!==null)&&(ze(),se())}}function Oe(i,c){var m=i.stateNode;if(m===null)return null;var k=Od(m);if(k===null)return null;m=k[c];e:switch(c){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(k=!k.disabled)||(i=i.type,k=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!k;break e;default:i=!1}if(i)return null;if(m&&typeof m!="function")throw Error(n(231,c,typeof m));return m}var Fe=!1;if(l)try{var et={};Object.defineProperty(et,"passive",{get:function(){Fe=!0}}),window.addEventListener("test",et,et),window.removeEventListener("test",et,et)}catch{Fe=!1}function Ft(i,c,m,k,b,_,O,X,re){var ke=Array.prototype.slice.call(arguments,3);try{c.apply(m,ke)}catch(Ae){this.onError(Ae)}}var jt=!1,On=null,Mn=!1,yn=null,tn={onError:function(i){jt=!0,On=i}};function _n(i,c,m,k,b,_,O,X,re){jt=!1,On=null,Ft.apply(tn,arguments)}function Mt(i,c,m,k,b,_,O,X,re){if(_n.apply(this,arguments),jt){if(jt){var ke=On;jt=!1,On=null}else throw Error(n(198));Mn||(Mn=!0,yn=ke)}}function mn(i){var c=i,m=i;if(i.alternate)for(;c.return;)c=c.return;else{i=c;do c=i,(c.flags&4098)!==0&&(m=c.return),i=c.return;while(i)}return c.tag===3?m:null}function rr(i){if(i.tag===13){var c=i.memoizedState;if(c===null&&(i=i.alternate,i!==null&&(c=i.memoizedState)),c!==null)return c.dehydrated}return null}function Ct(i){if(mn(i)!==i)throw Error(n(188))}function le(i){var c=i.alternate;if(!c){if(c=mn(i),c===null)throw Error(n(188));return c!==i?null:i}for(var m=i,k=c;;){var b=m.return;if(b===null)break;var _=b.alternate;if(_===null){if(k=b.return,k!==null){m=k;continue}break}if(b.child===_.child){for(_=b.child;_;){if(_===m)return Ct(b),i;if(_===k)return Ct(b),c;_=_.sibling}throw Error(n(188))}if(m.return!==k.return)m=b,k=_;else{for(var O=!1,X=b.child;X;){if(X===m){O=!0,m=b,k=_;break}if(X===k){O=!0,k=b,m=_;break}X=X.sibling}if(!O){for(X=_.child;X;){if(X===m){O=!0,m=_,k=b;break}if(X===k){O=!0,k=_,m=b;break}X=X.sibling}if(!O)throw Error(n(189))}}if(m.alternate!==k)throw Error(n(190))}if(m.tag!==3)throw Error(n(188));return m.stateNode.current===m?i:c}function qe(i){return i=le(i),i!==null?Xe(i):null}function Xe(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var c=Xe(i);if(c!==null)return c;i=i.sibling}return null}var pt=t.unstable_scheduleCallback,wt=t.unstable_cancelCallback,En=t.unstable_shouldYield,Lr=t.unstable_requestPaint,un=t.unstable_now,vr=t.unstable_getCurrentPriorityLevel,Qn=t.unstable_ImmediatePriority,Bt=t.unstable_UserBlockingPriority,dn=t.unstable_NormalPriority,ve=t.unstable_LowPriority,Le=t.unstable_IdlePriority,At=null,yt=null;function rn(i){if(yt&&typeof yt.onCommitFiberRoot=="function")try{yt.onCommitFiberRoot(At,i,void 0,(i.current.flags&128)===128)}catch{}}var Gt=Math.clz32?Math.clz32:hn,Jn=Math.log,Zr=Math.LN2;function hn(i){return i>>>=0,i===0?32:31-(Jn(i)/Zr|0)|0}var Yt=64,zn=4194304;function or(i){switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return i&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return i}}function br(i,c){var m=i.pendingLanes;if(m===0)return 0;var k=0,b=i.suspendedLanes,_=i.pingedLanes,O=m&268435455;if(O!==0){var X=O&~b;X!==0?k=or(X):(_&=O,_!==0&&(k=or(_)))}else O=m&~b,O!==0?k=or(O):_!==0&&(k=or(_));if(k===0)return 0;if(c!==0&&c!==k&&(c&b)===0&&(b=k&-k,_=c&-c,b>=_||b===16&&(_&4194240)!==0))return c;if((k&4)!==0&&(k|=m&16),c=i.entangledLanes,c!==0)for(i=i.entanglements,c&=k;0<c;)m=31-Gt(c),b=1<<m,k|=i[m],c&=~b;return k}function pr(i,c){switch(i){case 1:case 2:case 4:return c+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return c+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Gr(i,c){for(var m=i.suspendedLanes,k=i.pingedLanes,b=i.expirationTimes,_=i.pendingLanes;0<_;){var O=31-Gt(_),X=1<<O,re=b[O];re===-1?((X&m)===0||(X&k)!==0)&&(b[O]=pr(X,c)):re<=c&&(i.expiredLanes|=X),_&=~X}}function ro(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function Ro(){var i=Yt;return Yt<<=1,(Yt&4194240)===0&&(Yt=64),i}function $r(i){for(var c=[],m=0;31>m;m++)c.push(i);return c}function G(i,c,m){i.pendingLanes|=c,c!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,c=31-Gt(c),i[c]=m}function me(i,c){var m=i.pendingLanes&~c;i.pendingLanes=c,i.suspendedLanes=0,i.pingedLanes=0,i.expiredLanes&=c,i.mutableReadLanes&=c,i.entangledLanes&=c,c=i.entanglements;var k=i.eventTimes;for(i=i.expirationTimes;0<m;){var b=31-Gt(m),_=1<<b;c[b]=0,k[b]=-1,i[b]=-1,m&=~_}}function Je(i,c){var m=i.entangledLanes|=c;for(i=i.entanglements;m;){var k=31-Gt(m),b=1<<k;b&c|i[k]&c&&(i[k]|=c),m&=~b}}var Ve=0;function He(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var bn,an,cn,sr,mr,Te=!1,H=[],Y=null,ce=null,xe=null,Ie=new Map,Qe=new Map,$t=[],ut="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Zn(i,c){switch(i){case"focusin":case"focusout":Y=null;break;case"dragenter":case"dragleave":ce=null;break;case"mouseover":case"mouseout":xe=null;break;case"pointerover":case"pointerout":Ie.delete(c.pointerId);break;case"gotpointercapture":case"lostpointercapture":Qe.delete(c.pointerId)}}function Sn(i,c,m,k,b,_){return i===null||i.nativeEvent!==_?(i={blockedOn:c,domEventName:m,eventSystemFlags:k,nativeEvent:_,targetContainers:[b]},c!==null&&(c=zl(c),c!==null&&an(c)),i):(i.eventSystemFlags|=k,c=i.targetContainers,b!==null&&c.indexOf(b)===-1&&c.push(b),i)}function ei(i,c,m,k,b){switch(c){case"focusin":return Y=Sn(Y,i,c,m,k,b),!0;case"dragenter":return ce=Sn(ce,i,c,m,k,b),!0;case"mouseover":return xe=Sn(xe,i,c,m,k,b),!0;case"pointerover":var _=b.pointerId;return Ie.set(_,Sn(Ie.get(_)||null,i,c,m,k,b)),!0;case"gotpointercapture":return _=b.pointerId,Qe.set(_,Sn(Qe.get(_)||null,i,c,m,k,b)),!0}return!1}function Hn(i){var c=aa(i.target);if(c!==null){var m=mn(c);if(m!==null){if(c=m.tag,c===13){if(c=rr(m),c!==null){i.blockedOn=c,mr(i.priority,function(){cn(m)});return}}else if(c===3&&m.stateNode.current.memoizedState.isDehydrated){i.blockedOn=m.tag===3?m.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Zi(i){if(i.blockedOn!==null)return!1;for(var c=i.targetContainers;0<c.length;){var m=ri(i.domEventName,i.eventSystemFlags,c[0],i.nativeEvent);if(m===null){m=i.nativeEvent;var k=new m.constructor(m.type,m);ne=k,m.target.dispatchEvent(k),ne=null}else return c=zl(m),c!==null&&an(c),i.blockedOn=m,!1;c.shift()}return!0}function oo(i,c,m){Zi(i)&&m.delete(c)}function ud(){Te=!1,Y!==null&&Zi(Y)&&(Y=null),ce!==null&&Zi(ce)&&(ce=null),xe!==null&&Zi(xe)&&(xe=null),Ie.forEach(oo),Qe.forEach(oo)}function Ss(i,c){i.blockedOn===c&&(i.blockedOn=null,Te||(Te=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,ud)))}function ti(i){function c(b){return Ss(b,i)}if(0<H.length){Ss(H[0],i);for(var m=1;m<H.length;m++){var k=H[m];k.blockedOn===i&&(k.blockedOn=null)}}for(Y!==null&&Ss(Y,i),ce!==null&&Ss(ce,i),xe!==null&&Ss(xe,i),Ie.forEach(c),Qe.forEach(c),m=0;m<$t.length;m++)k=$t[m],k.blockedOn===i&&(k.blockedOn=null);for(;0<$t.length&&(m=$t[0],m.blockedOn===null);)Hn(m),m.blockedOn===null&&$t.shift()}var _s=j.ReactCurrentBatchConfig,Qa=!0;function Wp(i,c,m,k){var b=Ve,_=_s.transition;_s.transition=null;try{Ve=1,ni(i,c,m,k)}finally{Ve=b,_s.transition=_}}function Kp(i,c,m,k){var b=Ve,_=_s.transition;_s.transition=null;try{Ve=4,ni(i,c,m,k)}finally{Ve=b,_s.transition=_}}function ni(i,c,m,k){if(Qa){var b=ri(i,c,m,k);if(b===null)Jp(i,c,k,vo,m),Zn(i,k);else if(ei(b,i,c,m,k))k.stopPropagation();else if(Zn(i,k),c&4&&-1<ut.indexOf(i)){for(;b!==null;){var _=zl(b);if(_!==null&&bn(_),_=ri(i,c,m,k),_===null&&Jp(i,c,k,vo,m),_===b)break;b=_}b!==null&&k.stopPropagation()}else Jp(i,c,k,null,m)}}var vo=null;function ri(i,c,m,k){if(vo=null,i=we(k),i=aa(i),i!==null)if(c=mn(i),c===null)i=null;else if(m=c.tag,m===13){if(i=rr(c),i!==null)return i;i=null}else if(m===3){if(c.stateNode.current.memoizedState.isDehydrated)return c.tag===3?c.stateNode.containerInfo:null;i=null}else c!==i&&(i=null);return vo=i,null}function gl(i){switch(i){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(vr()){case Qn:return 1;case Bt:return 4;case dn:case ve:return 16;case Le:return 536870912;default:return 16}default:return 16}}var bo=null,oi=null,Gi=null;function Vi(){if(Gi)return Gi;var i,c=oi,m=c.length,k,b="value"in bo?bo.value:bo.textContent,_=b.length;for(i=0;i<m&&c[i]===b[i];i++);var O=m-i;for(k=1;k<=O&&c[m-k]===b[_-k];k++);return Gi=b.slice(i,1<k?1-k:void 0)}function Yi(i){var c=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&c===13&&(i=13)):i=c,i===10&&(i=13),32<=i||i===13?i:0}function si(){return!0}function Cr(){return!1}function Vr(i){function c(m,k,b,_,O){this._reactName=m,this._targetInst=b,this.type=k,this.nativeEvent=_,this.target=O,this.currentTarget=null;for(var X in i)i.hasOwnProperty(X)&&(m=i[X],this[X]=m?m(_):_[X]);return this.isDefaultPrevented=(_.defaultPrevented!=null?_.defaultPrevented:_.returnValue===!1)?si:Cr,this.isPropagationStopped=Cr,this}return U(c.prototype,{preventDefault:function(){this.defaultPrevented=!0;var m=this.nativeEvent;m&&(m.preventDefault?m.preventDefault():typeof m.returnValue!="unknown"&&(m.returnValue=!1),this.isDefaultPrevented=si)},stopPropagation:function(){var m=this.nativeEvent;m&&(m.stopPropagation?m.stopPropagation():typeof m.cancelBubble!="unknown"&&(m.cancelBubble=!0),this.isPropagationStopped=si)},persist:function(){},isPersistent:si}),c}var ii={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},kl=Vr(ii),Ns=U({},ii,{view:0,detail:0}),wl=Vr(Ns),cs,Xi,ai,Ja=U({},Ns,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:An,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==ai&&(ai&&i.type==="mousemove"?(cs=i.screenX-ai.screenX,Xi=i.screenY-ai.screenY):Xi=cs=0,ai=i),cs)},movementY:function(i){return"movementY"in i?i.movementY:Xi}}),dd=Vr(Ja),qp=U({},Ja,{dataTransfer:0}),fd=Vr(qp),Zp=U({},Ns,{relatedTarget:0}),ec=Vr(Zp),Gp=U({},ii,{animationName:0,elapsedTime:0,pseudoElement:0}),hd=Vr(Gp),Pr=U({},ii,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),pd=Vr(Pr),md=U({},ii,{data:0}),Qi=Vr(md),Vp={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},yl={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},vl={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function tc(i){var c=this.nativeEvent;return c.getModifierState?c.getModifierState(i):(i=vl[i])?!!c[i]:!1}function An(){return tc}var gd=U({},Ns,{key:function(i){if(i.key){var c=Vp[i.key]||i.key;if(c!=="Unidentified")return c}return i.type==="keypress"?(i=Yi(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?yl[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:An,charCode:function(i){return i.type==="keypress"?Yi(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Yi(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),nc=Vr(gd),bl=U({},Ja,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ji=Vr(bl),rc=U({},Ns,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:An}),ci=Vr(rc),kd=U({},ii,{propertyName:0,elapsedTime:0,pseudoElement:0}),xl=Vr(kd),El=U({},Ja,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),wd=Vr(El),Iv=[9,13,27,32],oc=l&&"CompositionEvent"in window,ls=null;l&&"documentMode"in document&&(ls=document.documentMode);var yd=l&&"TextEvent"in window&&!ls,Sl=l&&(!oc||ls&&8<ls&&11>=ls),_l=" ",cr=!1;function ea(i,c){switch(i){case"keyup":return Iv.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function vd(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Zo=!1;function bd(i,c){switch(i){case"compositionend":return vd(c);case"keypress":return c.which!==32?null:(cr=!0,_l);case"textInput":return i=c.data,i===_l&&cr?null:i;default:return null}}function ta(i,c){if(Zo)return i==="compositionend"||!oc&&ea(i,c)?(i=Vi(),Gi=oi=bo=null,Zo=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1<c.char.length)return c.char;if(c.which)return String.fromCharCode(c.which)}return null;case"compositionend":return Sl&&c.locale!=="ko"?null:c.data;default:return null}}var na={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function sc(i){var c=i&&i.nodeName&&i.nodeName.toLowerCase();return c==="input"?!!na[i.type]:c==="textarea"}function xd(i,c,m,k){D(k),c=Ad(c,"onChange"),0<c.length&&(m=new kl("onChange","change",null,m,k),i.push({event:m,listeners:c}))}var Ts=null,ra=null;function Ed(i){Ov(i,0)}function oa(i){var c=hc(i);if(ie(c))return i}function Sd(i,c){if(i==="change")return c}var Nl=!1;if(l){var so;if(l){var Tl="oninput"in document;if(!Tl){var us=document.createElement("div");us.setAttribute("oninput","return;"),Tl=typeof us.oninput=="function"}so=Tl}else so=!1;Nl=so&&(!document.documentMode||9<document.documentMode)}function sa(){Ts&&(Ts.detachEvent("onpropertychange",_d),ra=Ts=null)}function _d(i){if(i.propertyName==="value"&&oa(ra)){var c=[];xd(c,ra,i,we(i)),qt(Ed,c)}}function ic(i,c,m){i==="focusin"?(sa(),Ts=c,ra=m,Ts.attachEvent("onpropertychange",_d)):i==="focusout"&&sa()}function jl(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return oa(ra)}function $l(i,c){if(i==="click")return oa(c)}function Nd(i,c){if(i==="input"||i==="change")return oa(c)}function Yp(i,c){return i===c&&(i!==0||1/i===1/c)||i!==i&&c!==c}var Yr=typeof Object.is=="function"?Object.is:Yp;function li(i,c){if(Yr(i,c))return!0;if(typeof i!="object"||i===null||typeof c!="object"||c===null)return!1;var m=Object.keys(i),k=Object.keys(c);if(m.length!==k.length)return!1;for(k=0;k<m.length;k++){var b=m[k];if(!u.call(c,b)||!Yr(i[b],c[b]))return!1}return!0}function Cl(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Al(i,c){var m=Cl(i);i=0;for(var k;m;){if(m.nodeType===3){if(k=i+m.textContent.length,i<=c&&k>=c)return{node:m,offset:c-i};i=k}e:{for(;m;){if(m.nextSibling){m=m.nextSibling;break e}m=m.parentNode}m=void 0}m=Cl(m)}}function Td(i,c){return i&&c?i===c?!0:i&&i.nodeType===3?!1:c&&c.nodeType===3?Td(i,c.parentNode):"contains"in i?i.contains(c):i.compareDocumentPosition?!!(i.compareDocumentPosition(c)&16):!1:!1}function Il(){for(var i=window,c=ye();c instanceof i.HTMLIFrameElement;){try{var m=typeof c.contentWindow.location.href=="string"}catch{m=!1}if(m)i=c.contentWindow;else break;c=ye(i.document)}return c}function ac(i){var c=i&&i.nodeName&&i.nodeName.toLowerCase();return c&&(c==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||c==="textarea"||i.contentEditable==="true")}function jd(i){var c=Il(),m=i.focusedElem,k=i.selectionRange;if(c!==m&&m&&m.ownerDocument&&Td(m.ownerDocument.documentElement,m)){if(k!==null&&ac(m)){if(c=k.start,i=k.end,i===void 0&&(i=c),"selectionStart"in m)m.selectionStart=c,m.selectionEnd=Math.min(i,m.value.length);else if(i=(c=m.ownerDocument||document)&&c.defaultView||window,i.getSelection){i=i.getSelection();var b=m.textContent.length,_=Math.min(k.start,b);k=k.end===void 0?_:Math.min(k.end,b),!i.extend&&_>k&&(b=k,k=_,_=b),b=Al(m,_);var O=Al(m,k);b&&O&&(i.rangeCount!==1||i.anchorNode!==b.node||i.anchorOffset!==b.offset||i.focusNode!==O.node||i.focusOffset!==O.offset)&&(c=c.createRange(),c.setStart(b.node,b.offset),i.removeAllRanges(),_>k?(i.addRange(c),i.extend(O.node,O.offset)):(c.setEnd(O.node,O.offset),i.addRange(c)))}}for(c=[],i=m;i=i.parentNode;)i.nodeType===1&&c.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof m.focus=="function"&&m.focus(),m=0;m<c.length;m++)i=c[m],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var $d=l&&"documentMode"in document&&11>=document.documentMode,js=null,cc=null,ui=null,lc=!1;function Rl(i,c,m){var k=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;lc||js==null||js!==ye(k)||(k=js,"selectionStart"in k&&ac(k)?k={start:k.selectionStart,end:k.selectionEnd}:(k=(k.ownerDocument&&k.ownerDocument.defaultView||window).getSelection(),k={anchorNode:k.anchorNode,anchorOffset:k.anchorOffset,focusNode:k.focusNode,focusOffset:k.focusOffset}),ui&&li(ui,k)||(ui=k,k=Ad(cc,"onSelect"),0<k.length&&(c=new kl("onSelect","select",null,c,m),i.push({event:c,listeners:k}),c.target=js)))}function ia(i,c){var m={};return m[i.toLowerCase()]=c.toLowerCase(),m["Webkit"+i]="webkit"+c,m["Moz"+i]="moz"+c,m}var $s={animationend:ia("Animation","AnimationEnd"),animationiteration:ia("Animation","AnimationIteration"),animationstart:ia("Animation","AnimationStart"),transitionend:ia("Transition","TransitionEnd")},z={},Re={};l&&(Re=document.createElement("div").style,"AnimationEvent"in window||(delete $s.animationend.animation,delete $s.animationiteration.animation,delete $s.animationstart.animation),"TransitionEvent"in window||delete $s.transitionend.transition);function dt(i){if(z[i])return z[i];if(!$s[i])return i;var c=$s[i],m;for(m in c)if(c.hasOwnProperty(m)&&m in Re)return z[i]=c[m];return i}var St=dt("animationend"),er=dt("animationiteration"),tr=dt("animationstart"),di=dt("transitionend"),Ol=new Map,xo="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function ds(i,c){Ol.set(i,c),s(c,[i])}for(var uc=0;uc<xo.length;uc++){var Xp=xo[uc],WA=Xp.toLowerCase(),KA=Xp[0].toUpperCase()+Xp.slice(1);ds(WA,"on"+KA)}ds(St,"onAnimationEnd"),ds(er,"onAnimationIteration"),ds(tr,"onAnimationStart"),ds("dblclick","onDoubleClick"),ds("focusin","onFocus"),ds("focusout","onBlur"),ds(di,"onTransitionEnd"),a("onMouseEnter",["mouseout","mouseover"]),a("onMouseLeave",["mouseout","mouseover"]),a("onPointerEnter",["pointerout","pointerover"]),a("onPointerLeave",["pointerout","pointerover"]),s("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),s("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),s("onBeforeInput",["compositionend","keypress","textInput","paste"]),s("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),s("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),s("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ml="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),qA=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ml));function Rv(i,c,m){var k=i.type||"unknown-event";i.currentTarget=m,Mt(k,c,void 0,i),i.currentTarget=null}function Ov(i,c){c=(c&4)!==0;for(var m=0;m<i.length;m++){var k=i[m],b=k.event;k=k.listeners;e:{var _=void 0;if(c)for(var O=k.length-1;0<=O;O--){var X=k[O],re=X.instance,ke=X.currentTarget;if(X=X.listener,re!==_&&b.isPropagationStopped())break e;Rv(b,X,ke),_=re}else for(O=0;O<k.length;O++){if(X=k[O],re=X.instance,ke=X.currentTarget,X=X.listener,re!==_&&b.isPropagationStopped())break e;Rv(b,X,ke),_=re}}}if(Mn)throw i=yn,Mn=!1,yn=null,i}function Fn(i,c){var m=c[sm];m===void 0&&(m=c[sm]=new Set);var k=i+"__bubble";m.has(k)||(Mv(c,i,2,!1),m.add(k))}function Qp(i,c,m){var k=0;c&&(k|=4),Mv(m,i,k,c)}var Cd="_reactListening"+Math.random().toString(36).slice(2);function Ll(i){if(!i[Cd]){i[Cd]=!0,r.forEach(function(m){m!=="selectionchange"&&(qA.has(m)||Qp(m,!1,i),Qp(m,!0,i))});var c=i.nodeType===9?i:i.ownerDocument;c===null||c[Cd]||(c[Cd]=!0,Qp("selectionchange",!1,c))}}function Mv(i,c,m,k){switch(gl(c)){case 1:var b=Wp;break;case 4:b=Kp;break;default:b=ni}m=b.bind(null,c,m,i),b=void 0,!Fe||c!=="touchstart"&&c!=="touchmove"&&c!=="wheel"||(b=!0),k?b!==void 0?i.addEventListener(c,m,{capture:!0,passive:b}):i.addEventListener(c,m,!0):b!==void 0?i.addEventListener(c,m,{passive:b}):i.addEventListener(c,m,!1)}function Jp(i,c,m,k,b){var _=k;if((c&1)===0&&(c&2)===0&&k!==null)e:for(;;){if(k===null)return;var O=k.tag;if(O===3||O===4){var X=k.stateNode.containerInfo;if(X===b||X.nodeType===8&&X.parentNode===b)break;if(O===4)for(O=k.return;O!==null;){var re=O.tag;if((re===3||re===4)&&(re=O.stateNode.containerInfo,re===b||re.nodeType===8&&re.parentNode===b))return;O=O.return}for(;X!==null;){if(O=aa(X),O===null)return;if(re=O.tag,re===5||re===6){k=_=O;continue e}X=X.parentNode}}k=k.return}qt(function(){var ke=_,Ae=we(m),Pe=[];e:{var je=Ol.get(i);if(je!==void 0){var tt=kl,at=i;switch(i){case"keypress":if(Yi(m)===0)break e;case"keydown":case"keyup":tt=nc;break;case"focusin":at="focus",tt=ec;break;case"focusout":at="blur",tt=ec;break;case"beforeblur":case"afterblur":tt=ec;break;case"click":if(m.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":tt=dd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":tt=fd;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":tt=ci;break;case St:case er:case tr:tt=hd;break;case di:tt=xl;break;case"scroll":tt=wl;break;case"wheel":tt=wd;break;case"copy":case"cut":case"paste":tt=pd;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":tt=Ji}var lt=(c&4)!==0,ir=!lt&&i==="scroll",fe=lt?je!==null?je+"Capture":null:je;lt=[];for(var ae=ke,ge;ae!==null;){ge=ae;var Ue=ge.stateNode;if(ge.tag===5&&Ue!==null&&(ge=Ue,fe!==null&&(Ue=Oe(ae,fe),Ue!=null&&lt.push(Pl(ae,Ue,ge)))),ir)break;ae=ae.return}0<lt.length&&(je=new tt(je,at,null,m,Ae),Pe.push({event:je,listeners:lt}))}}if((c&7)===0){e:{if(je=i==="mouseover"||i==="pointerover",tt=i==="mouseout"||i==="pointerout",je&&m!==ne&&(at=m.relatedTarget||m.fromElement)&&(aa(at)||at[Cs]))break e;if((tt||je)&&(je=Ae.window===Ae?Ae:(je=Ae.ownerDocument)?je.defaultView||je.parentWindow:window,tt?(at=m.relatedTarget||m.toElement,tt=ke,at=at?aa(at):null,at!==null&&(ir=mn(at),at!==ir||at.tag!==5&&at.tag!==6)&&(at=null)):(tt=null,at=ke),tt!==at)){if(lt=dd,Ue="onMouseLeave",fe="onMouseEnter",ae="mouse",(i==="pointerout"||i==="pointerover")&&(lt=Ji,Ue="onPointerLeave",fe="onPointerEnter",ae="pointer"),ir=tt==null?je:hc(tt),ge=at==null?je:hc(at),je=new lt(Ue,ae+"leave",tt,m,Ae),je.target=ir,je.relatedTarget=ge,Ue=null,aa(Ae)===ke&&(lt=new lt(fe,ae+"enter",at,m,Ae),lt.target=ge,lt.relatedTarget=ir,Ue=lt),ir=Ue,tt&&at)t:{for(lt=tt,fe=at,ae=0,ge=lt;ge;ge=dc(ge))ae++;for(ge=0,Ue=fe;Ue;Ue=dc(Ue))ge++;for(;0<ae-ge;)lt=dc(lt),ae--;for(;0<ge-ae;)fe=dc(fe),ge--;for(;ae--;){if(lt===fe||fe!==null&&lt===fe.alternate)break t;lt=dc(lt),fe=dc(fe)}lt=null}else lt=null;tt!==null&&Lv(Pe,je,tt,lt,!1),at!==null&&ir!==null&&Lv(Pe,ir,at,lt,!0)}}e:{if(je=ke?hc(ke):window,tt=je.nodeName&&je.nodeName.toLowerCase(),tt==="select"||tt==="input"&&je.type==="file")var ft=Sd;else if(sc(je))if(Nl)ft=Nd;else{ft=jl;var vt=ic}else(tt=je.nodeName)&&tt.toLowerCase()==="input"&&(je.type==="checkbox"||je.type==="radio")&&(ft=$l);if(ft&&(ft=ft(i,ke))){xd(Pe,ft,m,Ae);break e}vt&&vt(i,je,ke),i==="focusout"&&(vt=je._wrapperState)&&vt.controlled&&je.type==="number"&&en(je,"number",je.value)}switch(vt=ke?hc(ke):window,i){case"focusin":(sc(vt)||vt.contentEditable==="true")&&(js=vt,cc=ke,ui=null);break;case"focusout":ui=cc=js=null;break;case"mousedown":lc=!0;break;case"contextmenu":case"mouseup":case"dragend":lc=!1,Rl(Pe,m,Ae);break;case"selectionchange":if($d)break;case"keydown":case"keyup":Rl(Pe,m,Ae)}var bt;if(oc)e:{switch(i){case"compositionstart":var Lt="onCompositionStart";break e;case"compositionend":Lt="onCompositionEnd";break e;case"compositionupdate":Lt="onCompositionUpdate";break e}Lt=void 0}else Zo?ea(i,m)&&(Lt="onCompositionEnd"):i==="keydown"&&m.keyCode===229&&(Lt="onCompositionStart");Lt&&(Sl&&m.locale!=="ko"&&(Zo||Lt!=="onCompositionStart"?Lt==="onCompositionEnd"&&Zo&&(bt=Vi()):(bo=Ae,oi="value"in bo?bo.value:bo.textContent,Zo=!0)),vt=Ad(ke,Lt),0<vt.length&&(Lt=new Qi(Lt,i,null,m,Ae),Pe.push({event:Lt,listeners:vt}),bt?Lt.data=bt:(bt=vd(m),bt!==null&&(Lt.data=bt)))),(bt=yd?bd(i,m):ta(i,m))&&(ke=Ad(ke,"onBeforeInput"),0<ke.length&&(Ae=new Qi("onBeforeInput","beforeinput",null,m,Ae),Pe.push({event:Ae,listeners:ke}),Ae.data=bt))}Ov(Pe,c)})}function Pl(i,c,m){return{instance:i,listener:c,currentTarget:m}}function Ad(i,c){for(var m=c+"Capture",k=[];i!==null;){var b=i,_=b.stateNode;b.tag===5&&_!==null&&(b=_,_=Oe(i,m),_!=null&&k.unshift(Pl(i,_,b)),_=Oe(i,c),_!=null&&k.push(Pl(i,_,b))),i=i.return}return k}function dc(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function Lv(i,c,m,k,b){for(var _=c._reactName,O=[];m!==null&&m!==k;){var X=m,re=X.alternate,ke=X.stateNode;if(re!==null&&re===k)break;X.tag===5&&ke!==null&&(X=ke,b?(re=Oe(m,_),re!=null&&O.unshift(Pl(m,re,X))):b||(re=Oe(m,_),re!=null&&O.push(Pl(m,re,X)))),m=m.return}O.length!==0&&i.push({event:c,listeners:O})}var ZA=/\r\n?/g,GA=/\u0000|\uFFFD/g;function Pv(i){return(typeof i=="string"?i:""+i).replace(ZA,`
39
- `).replace(GA,"")}function Id(i,c,m){if(c=Pv(c),Pv(i)!==c&&m)throw Error(n(425))}function Rd(){}var em=null,tm=null;function nm(i,c){return i==="textarea"||i==="noscript"||typeof c.children=="string"||typeof c.children=="number"||typeof c.dangerouslySetInnerHTML=="object"&&c.dangerouslySetInnerHTML!==null&&c.dangerouslySetInnerHTML.__html!=null}var rm=typeof setTimeout=="function"?setTimeout:void 0,VA=typeof clearTimeout=="function"?clearTimeout:void 0,Dv=typeof Promise=="function"?Promise:void 0,YA=typeof queueMicrotask=="function"?queueMicrotask:typeof Dv<"u"?function(i){return Dv.resolve(null).then(i).catch(XA)}:rm;function XA(i){setTimeout(function(){throw i})}function om(i,c){var m=c,k=0;do{var b=m.nextSibling;if(i.removeChild(m),b&&b.nodeType===8)if(m=b.data,m==="/$"){if(k===0){i.removeChild(b),ti(c);return}k--}else m!=="$"&&m!=="$?"&&m!=="$!"||k++;m=b}while(m);ti(c)}function fi(i){for(;i!=null;i=i.nextSibling){var c=i.nodeType;if(c===1||c===3)break;if(c===8){if(c=i.data,c==="$"||c==="$!"||c==="$?")break;if(c==="/$")return null}}return i}function zv(i){i=i.previousSibling;for(var c=0;i;){if(i.nodeType===8){var m=i.data;if(m==="$"||m==="$!"||m==="$?"){if(c===0)return i;c--}else m==="/$"&&c++}i=i.previousSibling}return null}var fc=Math.random().toString(36).slice(2),fs="__reactFiber$"+fc,Dl="__reactProps$"+fc,Cs="__reactContainer$"+fc,sm="__reactEvents$"+fc,QA="__reactListeners$"+fc,JA="__reactHandles$"+fc;function aa(i){var c=i[fs];if(c)return c;for(var m=i.parentNode;m;){if(c=m[Cs]||m[fs]){if(m=c.alternate,c.child!==null||m!==null&&m.child!==null)for(i=zv(i);i!==null;){if(m=i[fs])return m;i=zv(i)}return c}i=m,m=i.parentNode}return null}function zl(i){return i=i[fs]||i[Cs],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function hc(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function Od(i){return i[Dl]||null}var im=[],pc=-1;function hi(i){return{current:i}}function Bn(i){0>pc||(i.current=im[pc],im[pc]=null,pc--)}function Ln(i,c){pc++,im[pc]=i.current,i.current=c}var pi={},Dr=hi(pi),io=hi(!1),ca=pi;function mc(i,c){var m=i.type.contextTypes;if(!m)return pi;var k=i.stateNode;if(k&&k.__reactInternalMemoizedUnmaskedChildContext===c)return k.__reactInternalMemoizedMaskedChildContext;var b={},_;for(_ in m)b[_]=c[_];return k&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=c,i.__reactInternalMemoizedMaskedChildContext=b),b}function ao(i){return i=i.childContextTypes,i!=null}function Md(){Bn(io),Bn(Dr)}function Fv(i,c,m){if(Dr.current!==pi)throw Error(n(168));Ln(Dr,c),Ln(io,m)}function Bv(i,c,m){var k=i.stateNode;if(c=c.childContextTypes,typeof k.getChildContext!="function")return m;k=k.getChildContext();for(var b in k)if(!(b in c))throw Error(n(108,Be(i)||"Unknown",b));return U({},m,k)}function Ld(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||pi,ca=Dr.current,Ln(Dr,i),Ln(io,io.current),!0}function Uv(i,c,m){var k=i.stateNode;if(!k)throw Error(n(169));m?(i=Bv(i,c,ca),k.__reactInternalMemoizedMergedChildContext=i,Bn(io),Bn(Dr),Ln(Dr,i)):Bn(io),Ln(io,m)}var As=null,Pd=!1,am=!1;function Hv(i){As===null?As=[i]:As.push(i)}function eI(i){Pd=!0,Hv(i)}function mi(){if(!am&&As!==null){am=!0;var i=0,c=Ve;try{var m=As;for(Ve=1;i<m.length;i++){var k=m[i];do k=k(!0);while(k!==null)}As=null,Pd=!1}catch(b){throw As!==null&&(As=As.slice(i+1)),pt(Qn,mi),b}finally{Ve=c,am=!1}}return null}var gc=[],kc=0,Dd=null,zd=0,Oo=[],Mo=0,la=null,Is=1,Rs="";function ua(i,c){gc[kc++]=zd,gc[kc++]=Dd,Dd=i,zd=c}function Wv(i,c,m){Oo[Mo++]=Is,Oo[Mo++]=Rs,Oo[Mo++]=la,la=i;var k=Is;i=Rs;var b=32-Gt(k)-1;k&=~(1<<b),m+=1;var _=32-Gt(c)+b;if(30<_){var O=b-b%5;_=(k&(1<<O)-1).toString(32),k>>=O,b-=O,Is=1<<32-Gt(c)+b|m<<b|k,Rs=_+i}else Is=1<<_|m<<b|k,Rs=i}function cm(i){i.return!==null&&(ua(i,1),Wv(i,1,0))}function lm(i){for(;i===Dd;)Dd=gc[--kc],gc[kc]=null,zd=gc[--kc],gc[kc]=null;for(;i===la;)la=Oo[--Mo],Oo[Mo]=null,Rs=Oo[--Mo],Oo[Mo]=null,Is=Oo[--Mo],Oo[Mo]=null}var Eo=null,So=null,Wn=!1,Go=null;function Kv(i,c){var m=zo(5,null,null,0);m.elementType="DELETED",m.stateNode=c,m.return=i,c=i.deletions,c===null?(i.deletions=[m],i.flags|=16):c.push(m)}function qv(i,c){switch(i.tag){case 5:var m=i.type;return c=c.nodeType!==1||m.toLowerCase()!==c.nodeName.toLowerCase()?null:c,c!==null?(i.stateNode=c,Eo=i,So=fi(c.firstChild),!0):!1;case 6:return c=i.pendingProps===""||c.nodeType!==3?null:c,c!==null?(i.stateNode=c,Eo=i,So=null,!0):!1;case 13:return c=c.nodeType!==8?null:c,c!==null?(m=la!==null?{id:Is,overflow:Rs}:null,i.memoizedState={dehydrated:c,treeContext:m,retryLane:1073741824},m=zo(18,null,null,0),m.stateNode=c,m.return=i,i.child=m,Eo=i,So=null,!0):!1;default:return!1}}function um(i){return(i.mode&1)!==0&&(i.flags&128)===0}function dm(i){if(Wn){var c=So;if(c){var m=c;if(!qv(i,c)){if(um(i))throw Error(n(418));c=fi(m.nextSibling);var k=Eo;c&&qv(i,c)?Kv(k,m):(i.flags=i.flags&-4097|2,Wn=!1,Eo=i)}}else{if(um(i))throw Error(n(418));i.flags=i.flags&-4097|2,Wn=!1,Eo=i}}}function Zv(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;Eo=i}function Fd(i){if(i!==Eo)return!1;if(!Wn)return Zv(i),Wn=!0,!1;var c;if((c=i.tag!==3)&&!(c=i.tag!==5)&&(c=i.type,c=c!=="head"&&c!=="body"&&!nm(i.type,i.memoizedProps)),c&&(c=So)){if(um(i))throw Gv(),Error(n(418));for(;c;)Kv(i,c),c=fi(c.nextSibling)}if(Zv(i),i.tag===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));e:{for(i=i.nextSibling,c=0;i;){if(i.nodeType===8){var m=i.data;if(m==="/$"){if(c===0){So=fi(i.nextSibling);break e}c--}else m!=="$"&&m!=="$!"&&m!=="$?"||c++}i=i.nextSibling}So=null}}else So=Eo?fi(i.stateNode.nextSibling):null;return!0}function Gv(){for(var i=So;i;)i=fi(i.nextSibling)}function wc(){So=Eo=null,Wn=!1}function fm(i){Go===null?Go=[i]:Go.push(i)}var tI=j.ReactCurrentBatchConfig;function Fl(i,c,m){if(i=m.ref,i!==null&&typeof i!="function"&&typeof i!="object"){if(m._owner){if(m=m._owner,m){if(m.tag!==1)throw Error(n(309));var k=m.stateNode}if(!k)throw Error(n(147,i));var b=k,_=""+i;return c!==null&&c.ref!==null&&typeof c.ref=="function"&&c.ref._stringRef===_?c.ref:(c=function(O){var X=b.refs;O===null?delete X[_]:X[_]=O},c._stringRef=_,c)}if(typeof i!="string")throw Error(n(284));if(!m._owner)throw Error(n(290,i))}return i}function Bd(i,c){throw i=Object.prototype.toString.call(c),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(c).join(", ")+"}":i))}function Vv(i){var c=i._init;return c(i._payload)}function Yv(i){function c(fe,ae){if(i){var ge=fe.deletions;ge===null?(fe.deletions=[ae],fe.flags|=16):ge.push(ae)}}function m(fe,ae){if(!i)return null;for(;ae!==null;)c(fe,ae),ae=ae.sibling;return null}function k(fe,ae){for(fe=new Map;ae!==null;)ae.key!==null?fe.set(ae.key,ae):fe.set(ae.index,ae),ae=ae.sibling;return fe}function b(fe,ae){return fe=Ei(fe,ae),fe.index=0,fe.sibling=null,fe}function _(fe,ae,ge){return fe.index=ge,i?(ge=fe.alternate,ge!==null?(ge=ge.index,ge<ae?(fe.flags|=2,ae):ge):(fe.flags|=2,ae)):(fe.flags|=1048576,ae)}function O(fe){return i&&fe.alternate===null&&(fe.flags|=2),fe}function X(fe,ae,ge,Ue){return ae===null||ae.tag!==6?(ae=rg(ge,fe.mode,Ue),ae.return=fe,ae):(ae=b(ae,ge),ae.return=fe,ae)}function re(fe,ae,ge,Ue){var ft=ge.type;return ft===A?Ae(fe,ae,ge.props.children,Ue,ge.key):ae!==null&&(ae.elementType===ft||typeof ft=="object"&&ft!==null&&ft.$$typeof===te&&Vv(ft)===ae.type)?(Ue=b(ae,ge.props),Ue.ref=Fl(fe,ae,ge),Ue.return=fe,Ue):(Ue=ff(ge.type,ge.key,ge.props,null,fe.mode,Ue),Ue.ref=Fl(fe,ae,ge),Ue.return=fe,Ue)}function ke(fe,ae,ge,Ue){return ae===null||ae.tag!==4||ae.stateNode.containerInfo!==ge.containerInfo||ae.stateNode.implementation!==ge.implementation?(ae=og(ge,fe.mode,Ue),ae.return=fe,ae):(ae=b(ae,ge.children||[]),ae.return=fe,ae)}function Ae(fe,ae,ge,Ue,ft){return ae===null||ae.tag!==7?(ae=wa(ge,fe.mode,Ue,ft),ae.return=fe,ae):(ae=b(ae,ge),ae.return=fe,ae)}function Pe(fe,ae,ge){if(typeof ae=="string"&&ae!==""||typeof ae=="number")return ae=rg(""+ae,fe.mode,ge),ae.return=fe,ae;if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case $:return ge=ff(ae.type,ae.key,ae.props,null,fe.mode,ge),ge.ref=Fl(fe,null,ae),ge.return=fe,ge;case R:return ae=og(ae,fe.mode,ge),ae.return=fe,ae;case te:var Ue=ae._init;return Pe(fe,Ue(ae._payload),ge)}if(Xt(ae)||oe(ae))return ae=wa(ae,fe.mode,ge,null),ae.return=fe,ae;Bd(fe,ae)}return null}function je(fe,ae,ge,Ue){var ft=ae!==null?ae.key:null;if(typeof ge=="string"&&ge!==""||typeof ge=="number")return ft!==null?null:X(fe,ae,""+ge,Ue);if(typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case $:return ge.key===ft?re(fe,ae,ge,Ue):null;case R:return ge.key===ft?ke(fe,ae,ge,Ue):null;case te:return ft=ge._init,je(fe,ae,ft(ge._payload),Ue)}if(Xt(ge)||oe(ge))return ft!==null?null:Ae(fe,ae,ge,Ue,null);Bd(fe,ge)}return null}function tt(fe,ae,ge,Ue,ft){if(typeof Ue=="string"&&Ue!==""||typeof Ue=="number")return fe=fe.get(ge)||null,X(ae,fe,""+Ue,ft);if(typeof Ue=="object"&&Ue!==null){switch(Ue.$$typeof){case $:return fe=fe.get(Ue.key===null?ge:Ue.key)||null,re(ae,fe,Ue,ft);case R:return fe=fe.get(Ue.key===null?ge:Ue.key)||null,ke(ae,fe,Ue,ft);case te:var vt=Ue._init;return tt(fe,ae,ge,vt(Ue._payload),ft)}if(Xt(Ue)||oe(Ue))return fe=fe.get(ge)||null,Ae(ae,fe,Ue,ft,null);Bd(ae,Ue)}return null}function at(fe,ae,ge,Ue){for(var ft=null,vt=null,bt=ae,Lt=ae=0,Sr=null;bt!==null&&Lt<ge.length;Lt++){bt.index>Lt?(Sr=bt,bt=null):Sr=bt.sibling;var vn=je(fe,bt,ge[Lt],Ue);if(vn===null){bt===null&&(bt=Sr);break}i&&bt&&vn.alternate===null&&c(fe,bt),ae=_(vn,ae,Lt),vt===null?ft=vn:vt.sibling=vn,vt=vn,bt=Sr}if(Lt===ge.length)return m(fe,bt),Wn&&ua(fe,Lt),ft;if(bt===null){for(;Lt<ge.length;Lt++)bt=Pe(fe,ge[Lt],Ue),bt!==null&&(ae=_(bt,ae,Lt),vt===null?ft=bt:vt.sibling=bt,vt=bt);return Wn&&ua(fe,Lt),ft}for(bt=k(fe,bt);Lt<ge.length;Lt++)Sr=tt(bt,fe,Lt,ge[Lt],Ue),Sr!==null&&(i&&Sr.alternate!==null&&bt.delete(Sr.key===null?Lt:Sr.key),ae=_(Sr,ae,Lt),vt===null?ft=Sr:vt.sibling=Sr,vt=Sr);return i&&bt.forEach(function(Si){return c(fe,Si)}),Wn&&ua(fe,Lt),ft}function lt(fe,ae,ge,Ue){var ft=oe(ge);if(typeof ft!="function")throw Error(n(150));if(ge=ft.call(ge),ge==null)throw Error(n(151));for(var vt=ft=null,bt=ae,Lt=ae=0,Sr=null,vn=ge.next();bt!==null&&!vn.done;Lt++,vn=ge.next()){bt.index>Lt?(Sr=bt,bt=null):Sr=bt.sibling;var Si=je(fe,bt,vn.value,Ue);if(Si===null){bt===null&&(bt=Sr);break}i&&bt&&Si.alternate===null&&c(fe,bt),ae=_(Si,ae,Lt),vt===null?ft=Si:vt.sibling=Si,vt=Si,bt=Sr}if(vn.done)return m(fe,bt),Wn&&ua(fe,Lt),ft;if(bt===null){for(;!vn.done;Lt++,vn=ge.next())vn=Pe(fe,vn.value,Ue),vn!==null&&(ae=_(vn,ae,Lt),vt===null?ft=vn:vt.sibling=vn,vt=vn);return Wn&&ua(fe,Lt),ft}for(bt=k(fe,bt);!vn.done;Lt++,vn=ge.next())vn=tt(bt,fe,Lt,vn.value,Ue),vn!==null&&(i&&vn.alternate!==null&&bt.delete(vn.key===null?Lt:vn.key),ae=_(vn,ae,Lt),vt===null?ft=vn:vt.sibling=vn,vt=vn);return i&&bt.forEach(function(OI){return c(fe,OI)}),Wn&&ua(fe,Lt),ft}function ir(fe,ae,ge,Ue){if(typeof ge=="object"&&ge!==null&&ge.type===A&&ge.key===null&&(ge=ge.props.children),typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case $:e:{for(var ft=ge.key,vt=ae;vt!==null;){if(vt.key===ft){if(ft=ge.type,ft===A){if(vt.tag===7){m(fe,vt.sibling),ae=b(vt,ge.props.children),ae.return=fe,fe=ae;break e}}else if(vt.elementType===ft||typeof ft=="object"&&ft!==null&&ft.$$typeof===te&&Vv(ft)===vt.type){m(fe,vt.sibling),ae=b(vt,ge.props),ae.ref=Fl(fe,vt,ge),ae.return=fe,fe=ae;break e}m(fe,vt);break}else c(fe,vt);vt=vt.sibling}ge.type===A?(ae=wa(ge.props.children,fe.mode,Ue,ge.key),ae.return=fe,fe=ae):(Ue=ff(ge.type,ge.key,ge.props,null,fe.mode,Ue),Ue.ref=Fl(fe,ae,ge),Ue.return=fe,fe=Ue)}return O(fe);case R:e:{for(vt=ge.key;ae!==null;){if(ae.key===vt)if(ae.tag===4&&ae.stateNode.containerInfo===ge.containerInfo&&ae.stateNode.implementation===ge.implementation){m(fe,ae.sibling),ae=b(ae,ge.children||[]),ae.return=fe,fe=ae;break e}else{m(fe,ae);break}else c(fe,ae);ae=ae.sibling}ae=og(ge,fe.mode,Ue),ae.return=fe,fe=ae}return O(fe);case te:return vt=ge._init,ir(fe,ae,vt(ge._payload),Ue)}if(Xt(ge))return at(fe,ae,ge,Ue);if(oe(ge))return lt(fe,ae,ge,Ue);Bd(fe,ge)}return typeof ge=="string"&&ge!==""||typeof ge=="number"?(ge=""+ge,ae!==null&&ae.tag===6?(m(fe,ae.sibling),ae=b(ae,ge),ae.return=fe,fe=ae):(m(fe,ae),ae=rg(ge,fe.mode,Ue),ae.return=fe,fe=ae),O(fe)):m(fe,ae)}return ir}var yc=Yv(!0),Xv=Yv(!1),Ud=hi(null),Hd=null,vc=null,hm=null;function pm(){hm=vc=Hd=null}function mm(i){var c=Ud.current;Bn(Ud),i._currentValue=c}function gm(i,c,m){for(;i!==null;){var k=i.alternate;if((i.childLanes&c)!==c?(i.childLanes|=c,k!==null&&(k.childLanes|=c)):k!==null&&(k.childLanes&c)!==c&&(k.childLanes|=c),i===m)break;i=i.return}}function bc(i,c){Hd=i,hm=vc=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&c)!==0&&(co=!0),i.firstContext=null)}function Lo(i){var c=i._currentValue;if(hm!==i)if(i={context:i,memoizedValue:c,next:null},vc===null){if(Hd===null)throw Error(n(308));vc=i,Hd.dependencies={lanes:0,firstContext:i}}else vc=vc.next=i;return c}var da=null;function km(i){da===null?da=[i]:da.push(i)}function Qv(i,c,m,k){var b=c.interleaved;return b===null?(m.next=m,km(c)):(m.next=b.next,b.next=m),c.interleaved=m,Os(i,k)}function Os(i,c){i.lanes|=c;var m=i.alternate;for(m!==null&&(m.lanes|=c),m=i,i=i.return;i!==null;)i.childLanes|=c,m=i.alternate,m!==null&&(m.childLanes|=c),m=i,i=i.return;return m.tag===3?m.stateNode:null}var gi=!1;function wm(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Jv(i,c){i=i.updateQueue,c.updateQueue===i&&(c.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,effects:i.effects})}function Ms(i,c){return{eventTime:i,lane:c,tag:0,payload:null,callback:null,next:null}}function ki(i,c,m){var k=i.updateQueue;if(k===null)return null;if(k=k.shared,(gn&2)!==0){var b=k.pending;return b===null?c.next=c:(c.next=b.next,b.next=c),k.pending=c,Os(i,m)}return b=k.interleaved,b===null?(c.next=c,km(k)):(c.next=b.next,b.next=c),k.interleaved=c,Os(i,m)}function Wd(i,c,m){if(c=c.updateQueue,c!==null&&(c=c.shared,(m&4194240)!==0)){var k=c.lanes;k&=i.pendingLanes,m|=k,c.lanes=m,Je(i,m)}}function e0(i,c){var m=i.updateQueue,k=i.alternate;if(k!==null&&(k=k.updateQueue,m===k)){var b=null,_=null;if(m=m.firstBaseUpdate,m!==null){do{var O={eventTime:m.eventTime,lane:m.lane,tag:m.tag,payload:m.payload,callback:m.callback,next:null};_===null?b=_=O:_=_.next=O,m=m.next}while(m!==null);_===null?b=_=c:_=_.next=c}else b=_=c;m={baseState:k.baseState,firstBaseUpdate:b,lastBaseUpdate:_,shared:k.shared,effects:k.effects},i.updateQueue=m;return}i=m.lastBaseUpdate,i===null?m.firstBaseUpdate=c:i.next=c,m.lastBaseUpdate=c}function Kd(i,c,m,k){var b=i.updateQueue;gi=!1;var _=b.firstBaseUpdate,O=b.lastBaseUpdate,X=b.shared.pending;if(X!==null){b.shared.pending=null;var re=X,ke=re.next;re.next=null,O===null?_=ke:O.next=ke,O=re;var Ae=i.alternate;Ae!==null&&(Ae=Ae.updateQueue,X=Ae.lastBaseUpdate,X!==O&&(X===null?Ae.firstBaseUpdate=ke:X.next=ke,Ae.lastBaseUpdate=re))}if(_!==null){var Pe=b.baseState;O=0,Ae=ke=re=null,X=_;do{var je=X.lane,tt=X.eventTime;if((k&je)===je){Ae!==null&&(Ae=Ae.next={eventTime:tt,lane:0,tag:X.tag,payload:X.payload,callback:X.callback,next:null});e:{var at=i,lt=X;switch(je=c,tt=m,lt.tag){case 1:if(at=lt.payload,typeof at=="function"){Pe=at.call(tt,Pe,je);break e}Pe=at;break e;case 3:at.flags=at.flags&-65537|128;case 0:if(at=lt.payload,je=typeof at=="function"?at.call(tt,Pe,je):at,je==null)break e;Pe=U({},Pe,je);break e;case 2:gi=!0}}X.callback!==null&&X.lane!==0&&(i.flags|=64,je=b.effects,je===null?b.effects=[X]:je.push(X))}else tt={eventTime:tt,lane:je,tag:X.tag,payload:X.payload,callback:X.callback,next:null},Ae===null?(ke=Ae=tt,re=Pe):Ae=Ae.next=tt,O|=je;if(X=X.next,X===null){if(X=b.shared.pending,X===null)break;je=X,X=je.next,je.next=null,b.lastBaseUpdate=je,b.shared.pending=null}}while(!0);if(Ae===null&&(re=Pe),b.baseState=re,b.firstBaseUpdate=ke,b.lastBaseUpdate=Ae,c=b.shared.interleaved,c!==null){b=c;do O|=b.lane,b=b.next;while(b!==c)}else _===null&&(b.shared.lanes=0);pa|=O,i.lanes=O,i.memoizedState=Pe}}function t0(i,c,m){if(i=c.effects,c.effects=null,i!==null)for(c=0;c<i.length;c++){var k=i[c],b=k.callback;if(b!==null){if(k.callback=null,k=m,typeof b!="function")throw Error(n(191,b));b.call(k)}}}var Bl={},hs=hi(Bl),Ul=hi(Bl),Hl=hi(Bl);function fa(i){if(i===Bl)throw Error(n(174));return i}function ym(i,c){switch(Ln(Hl,c),Ln(Ul,i),Ln(hs,Bl),i=c.nodeType,i){case 9:case 11:c=(c=c.documentElement)?c.namespaceURI:nn(null,"");break;default:i=i===8?c.parentNode:c,c=i.namespaceURI||null,i=i.tagName,c=nn(c,i)}Bn(hs),Ln(hs,c)}function xc(){Bn(hs),Bn(Ul),Bn(Hl)}function n0(i){fa(Hl.current);var c=fa(hs.current),m=nn(c,i.type);c!==m&&(Ln(Ul,i),Ln(hs,m))}function vm(i){Ul.current===i&&(Bn(hs),Bn(Ul))}var Gn=hi(0);function qd(i){for(var c=i;c!==null;){if(c.tag===13){var m=c.memoizedState;if(m!==null&&(m=m.dehydrated,m===null||m.data==="$?"||m.data==="$!"))return c}else if(c.tag===19&&c.memoizedProps.revealOrder!==void 0){if((c.flags&128)!==0)return c}else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===i)break;for(;c.sibling===null;){if(c.return===null||c.return===i)return null;c=c.return}c.sibling.return=c.return,c=c.sibling}return null}var bm=[];function xm(){for(var i=0;i<bm.length;i++)bm[i]._workInProgressVersionPrimary=null;bm.length=0}var Zd=j.ReactCurrentDispatcher,Em=j.ReactCurrentBatchConfig,ha=0,Vn=null,gr=null,xr=null,Gd=!1,Wl=!1,Kl=0,nI=0;function zr(){throw Error(n(321))}function Sm(i,c){if(c===null)return!1;for(var m=0;m<c.length&&m<i.length;m++)if(!Yr(i[m],c[m]))return!1;return!0}function _m(i,c,m,k,b,_){if(ha=_,Vn=c,c.memoizedState=null,c.updateQueue=null,c.lanes=0,Zd.current=i===null||i.memoizedState===null?iI:aI,i=m(k,b),Wl){_=0;do{if(Wl=!1,Kl=0,25<=_)throw Error(n(301));_+=1,xr=gr=null,c.updateQueue=null,Zd.current=cI,i=m(k,b)}while(Wl)}if(Zd.current=Xd,c=gr!==null&&gr.next!==null,ha=0,xr=gr=Vn=null,Gd=!1,c)throw Error(n(300));return i}function Nm(){var i=Kl!==0;return Kl=0,i}function ps(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return xr===null?Vn.memoizedState=xr=i:xr=xr.next=i,xr}function Po(){if(gr===null){var i=Vn.alternate;i=i!==null?i.memoizedState:null}else i=gr.next;var c=xr===null?Vn.memoizedState:xr.next;if(c!==null)xr=c,gr=i;else{if(i===null)throw Error(n(310));gr=i,i={memoizedState:gr.memoizedState,baseState:gr.baseState,baseQueue:gr.baseQueue,queue:gr.queue,next:null},xr===null?Vn.memoizedState=xr=i:xr=xr.next=i}return xr}function ql(i,c){return typeof c=="function"?c(i):c}function Tm(i){var c=Po(),m=c.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=i;var k=gr,b=k.baseQueue,_=m.pending;if(_!==null){if(b!==null){var O=b.next;b.next=_.next,_.next=O}k.baseQueue=b=_,m.pending=null}if(b!==null){_=b.next,k=k.baseState;var X=O=null,re=null,ke=_;do{var Ae=ke.lane;if((ha&Ae)===Ae)re!==null&&(re=re.next={lane:0,action:ke.action,hasEagerState:ke.hasEagerState,eagerState:ke.eagerState,next:null}),k=ke.hasEagerState?ke.eagerState:i(k,ke.action);else{var Pe={lane:Ae,action:ke.action,hasEagerState:ke.hasEagerState,eagerState:ke.eagerState,next:null};re===null?(X=re=Pe,O=k):re=re.next=Pe,Vn.lanes|=Ae,pa|=Ae}ke=ke.next}while(ke!==null&&ke!==_);re===null?O=k:re.next=X,Yr(k,c.memoizedState)||(co=!0),c.memoizedState=k,c.baseState=O,c.baseQueue=re,m.lastRenderedState=k}if(i=m.interleaved,i!==null){b=i;do _=b.lane,Vn.lanes|=_,pa|=_,b=b.next;while(b!==i)}else b===null&&(m.lanes=0);return[c.memoizedState,m.dispatch]}function jm(i){var c=Po(),m=c.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=i;var k=m.dispatch,b=m.pending,_=c.memoizedState;if(b!==null){m.pending=null;var O=b=b.next;do _=i(_,O.action),O=O.next;while(O!==b);Yr(_,c.memoizedState)||(co=!0),c.memoizedState=_,c.baseQueue===null&&(c.baseState=_),m.lastRenderedState=_}return[_,k]}function r0(){}function o0(i,c){var m=Vn,k=Po(),b=c(),_=!Yr(k.memoizedState,b);if(_&&(k.memoizedState=b,co=!0),k=k.queue,$m(a0.bind(null,m,k,i),[i]),k.getSnapshot!==c||_||xr!==null&&xr.memoizedState.tag&1){if(m.flags|=2048,Zl(9,i0.bind(null,m,k,b,c),void 0,null),Er===null)throw Error(n(349));(ha&30)!==0||s0(m,c,b)}return b}function s0(i,c,m){i.flags|=16384,i={getSnapshot:c,value:m},c=Vn.updateQueue,c===null?(c={lastEffect:null,stores:null},Vn.updateQueue=c,c.stores=[i]):(m=c.stores,m===null?c.stores=[i]:m.push(i))}function i0(i,c,m,k){c.value=m,c.getSnapshot=k,c0(c)&&l0(i)}function a0(i,c,m){return m(function(){c0(c)&&l0(i)})}function c0(i){var c=i.getSnapshot;i=i.value;try{var m=c();return!Yr(i,m)}catch{return!0}}function l0(i){var c=Os(i,1);c!==null&&Qo(c,i,1,-1)}function u0(i){var c=ps();return typeof i=="function"&&(i=i()),c.memoizedState=c.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ql,lastRenderedState:i},c.queue=i,i=i.dispatch=sI.bind(null,Vn,i),[c.memoizedState,i]}function Zl(i,c,m,k){return i={tag:i,create:c,destroy:m,deps:k,next:null},c=Vn.updateQueue,c===null?(c={lastEffect:null,stores:null},Vn.updateQueue=c,c.lastEffect=i.next=i):(m=c.lastEffect,m===null?c.lastEffect=i.next=i:(k=m.next,m.next=i,i.next=k,c.lastEffect=i)),i}function d0(){return Po().memoizedState}function Vd(i,c,m,k){var b=ps();Vn.flags|=i,b.memoizedState=Zl(1|c,m,void 0,k===void 0?null:k)}function Yd(i,c,m,k){var b=Po();k=k===void 0?null:k;var _=void 0;if(gr!==null){var O=gr.memoizedState;if(_=O.destroy,k!==null&&Sm(k,O.deps)){b.memoizedState=Zl(c,m,_,k);return}}Vn.flags|=i,b.memoizedState=Zl(1|c,m,_,k)}function f0(i,c){return Vd(8390656,8,i,c)}function $m(i,c){return Yd(2048,8,i,c)}function h0(i,c){return Yd(4,2,i,c)}function p0(i,c){return Yd(4,4,i,c)}function m0(i,c){if(typeof c=="function")return i=i(),c(i),function(){c(null)};if(c!=null)return i=i(),c.current=i,function(){c.current=null}}function g0(i,c,m){return m=m!=null?m.concat([i]):null,Yd(4,4,m0.bind(null,c,i),m)}function Cm(){}function k0(i,c){var m=Po();c=c===void 0?null:c;var k=m.memoizedState;return k!==null&&c!==null&&Sm(c,k[1])?k[0]:(m.memoizedState=[i,c],i)}function w0(i,c){var m=Po();c=c===void 0?null:c;var k=m.memoizedState;return k!==null&&c!==null&&Sm(c,k[1])?k[0]:(i=i(),m.memoizedState=[i,c],i)}function y0(i,c,m){return(ha&21)===0?(i.baseState&&(i.baseState=!1,co=!0),i.memoizedState=m):(Yr(m,c)||(m=Ro(),Vn.lanes|=m,pa|=m,i.baseState=!0),c)}function rI(i,c){var m=Ve;Ve=m!==0&&4>m?m:4,i(!0);var k=Em.transition;Em.transition={};try{i(!1),c()}finally{Ve=m,Em.transition=k}}function v0(){return Po().memoizedState}function oI(i,c,m){var k=bi(i);if(m={lane:k,action:m,hasEagerState:!1,eagerState:null,next:null},b0(i))x0(c,m);else if(m=Qv(i,c,m,k),m!==null){var b=Qr();Qo(m,i,k,b),E0(m,c,k)}}function sI(i,c,m){var k=bi(i),b={lane:k,action:m,hasEagerState:!1,eagerState:null,next:null};if(b0(i))x0(c,b);else{var _=i.alternate;if(i.lanes===0&&(_===null||_.lanes===0)&&(_=c.lastRenderedReducer,_!==null))try{var O=c.lastRenderedState,X=_(O,m);if(b.hasEagerState=!0,b.eagerState=X,Yr(X,O)){var re=c.interleaved;re===null?(b.next=b,km(c)):(b.next=re.next,re.next=b),c.interleaved=b;return}}catch{}finally{}m=Qv(i,c,b,k),m!==null&&(b=Qr(),Qo(m,i,k,b),E0(m,c,k))}}function b0(i){var c=i.alternate;return i===Vn||c!==null&&c===Vn}function x0(i,c){Wl=Gd=!0;var m=i.pending;m===null?c.next=c:(c.next=m.next,m.next=c),i.pending=c}function E0(i,c,m){if((m&4194240)!==0){var k=c.lanes;k&=i.pendingLanes,m|=k,c.lanes=m,Je(i,m)}}var Xd={readContext:Lo,useCallback:zr,useContext:zr,useEffect:zr,useImperativeHandle:zr,useInsertionEffect:zr,useLayoutEffect:zr,useMemo:zr,useReducer:zr,useRef:zr,useState:zr,useDebugValue:zr,useDeferredValue:zr,useTransition:zr,useMutableSource:zr,useSyncExternalStore:zr,useId:zr,unstable_isNewReconciler:!1},iI={readContext:Lo,useCallback:function(i,c){return ps().memoizedState=[i,c===void 0?null:c],i},useContext:Lo,useEffect:f0,useImperativeHandle:function(i,c,m){return m=m!=null?m.concat([i]):null,Vd(4194308,4,m0.bind(null,c,i),m)},useLayoutEffect:function(i,c){return Vd(4194308,4,i,c)},useInsertionEffect:function(i,c){return Vd(4,2,i,c)},useMemo:function(i,c){var m=ps();return c=c===void 0?null:c,i=i(),m.memoizedState=[i,c],i},useReducer:function(i,c,m){var k=ps();return c=m!==void 0?m(c):c,k.memoizedState=k.baseState=c,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:c},k.queue=i,i=i.dispatch=oI.bind(null,Vn,i),[k.memoizedState,i]},useRef:function(i){var c=ps();return i={current:i},c.memoizedState=i},useState:u0,useDebugValue:Cm,useDeferredValue:function(i){return ps().memoizedState=i},useTransition:function(){var i=u0(!1),c=i[0];return i=rI.bind(null,i[1]),ps().memoizedState=i,[c,i]},useMutableSource:function(){},useSyncExternalStore:function(i,c,m){var k=Vn,b=ps();if(Wn){if(m===void 0)throw Error(n(407));m=m()}else{if(m=c(),Er===null)throw Error(n(349));(ha&30)!==0||s0(k,c,m)}b.memoizedState=m;var _={value:m,getSnapshot:c};return b.queue=_,f0(a0.bind(null,k,_,i),[i]),k.flags|=2048,Zl(9,i0.bind(null,k,_,m,c),void 0,null),m},useId:function(){var i=ps(),c=Er.identifierPrefix;if(Wn){var m=Rs,k=Is;m=(k&~(1<<32-Gt(k)-1)).toString(32)+m,c=":"+c+"R"+m,m=Kl++,0<m&&(c+="H"+m.toString(32)),c+=":"}else m=nI++,c=":"+c+"r"+m.toString(32)+":";return i.memoizedState=c},unstable_isNewReconciler:!1},aI={readContext:Lo,useCallback:k0,useContext:Lo,useEffect:$m,useImperativeHandle:g0,useInsertionEffect:h0,useLayoutEffect:p0,useMemo:w0,useReducer:Tm,useRef:d0,useState:function(){return Tm(ql)},useDebugValue:Cm,useDeferredValue:function(i){var c=Po();return y0(c,gr.memoizedState,i)},useTransition:function(){var i=Tm(ql)[0],c=Po().memoizedState;return[i,c]},useMutableSource:r0,useSyncExternalStore:o0,useId:v0,unstable_isNewReconciler:!1},cI={readContext:Lo,useCallback:k0,useContext:Lo,useEffect:$m,useImperativeHandle:g0,useInsertionEffect:h0,useLayoutEffect:p0,useMemo:w0,useReducer:jm,useRef:d0,useState:function(){return jm(ql)},useDebugValue:Cm,useDeferredValue:function(i){var c=Po();return gr===null?c.memoizedState=i:y0(c,gr.memoizedState,i)},useTransition:function(){var i=jm(ql)[0],c=Po().memoizedState;return[i,c]},useMutableSource:r0,useSyncExternalStore:o0,useId:v0,unstable_isNewReconciler:!1};function Vo(i,c){if(i&&i.defaultProps){c=U({},c),i=i.defaultProps;for(var m in i)c[m]===void 0&&(c[m]=i[m]);return c}return c}function Am(i,c,m,k){c=i.memoizedState,m=m(k,c),m=m==null?c:U({},c,m),i.memoizedState=m,i.lanes===0&&(i.updateQueue.baseState=m)}var Qd={isMounted:function(i){return(i=i._reactInternals)?mn(i)===i:!1},enqueueSetState:function(i,c,m){i=i._reactInternals;var k=Qr(),b=bi(i),_=Ms(k,b);_.payload=c,m!=null&&(_.callback=m),c=ki(i,_,b),c!==null&&(Qo(c,i,b,k),Wd(c,i,b))},enqueueReplaceState:function(i,c,m){i=i._reactInternals;var k=Qr(),b=bi(i),_=Ms(k,b);_.tag=1,_.payload=c,m!=null&&(_.callback=m),c=ki(i,_,b),c!==null&&(Qo(c,i,b,k),Wd(c,i,b))},enqueueForceUpdate:function(i,c){i=i._reactInternals;var m=Qr(),k=bi(i),b=Ms(m,k);b.tag=2,c!=null&&(b.callback=c),c=ki(i,b,k),c!==null&&(Qo(c,i,k,m),Wd(c,i,k))}};function S0(i,c,m,k,b,_,O){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(k,_,O):c.prototype&&c.prototype.isPureReactComponent?!li(m,k)||!li(b,_):!0}function _0(i,c,m){var k=!1,b=pi,_=c.contextType;return typeof _=="object"&&_!==null?_=Lo(_):(b=ao(c)?ca:Dr.current,k=c.contextTypes,_=(k=k!=null)?mc(i,b):pi),c=new c(m,_),i.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,c.updater=Qd,i.stateNode=c,c._reactInternals=i,k&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=b,i.__reactInternalMemoizedMaskedChildContext=_),c}function N0(i,c,m,k){i=c.state,typeof c.componentWillReceiveProps=="function"&&c.componentWillReceiveProps(m,k),typeof c.UNSAFE_componentWillReceiveProps=="function"&&c.UNSAFE_componentWillReceiveProps(m,k),c.state!==i&&Qd.enqueueReplaceState(c,c.state,null)}function Im(i,c,m,k){var b=i.stateNode;b.props=m,b.state=i.memoizedState,b.refs={},wm(i);var _=c.contextType;typeof _=="object"&&_!==null?b.context=Lo(_):(_=ao(c)?ca:Dr.current,b.context=mc(i,_)),b.state=i.memoizedState,_=c.getDerivedStateFromProps,typeof _=="function"&&(Am(i,c,_,m),b.state=i.memoizedState),typeof c.getDerivedStateFromProps=="function"||typeof b.getSnapshotBeforeUpdate=="function"||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(c=b.state,typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount(),c!==b.state&&Qd.enqueueReplaceState(b,b.state,null),Kd(i,m,b,k),b.state=i.memoizedState),typeof b.componentDidMount=="function"&&(i.flags|=4194308)}function Ec(i,c){try{var m="",k=c;do m+=Ne(k),k=k.return;while(k);var b=m}catch(_){b=`
40
- Error generating stack: `+_.message+`
41
- `+_.stack}return{value:i,source:c,stack:b,digest:null}}function Rm(i,c,m){return{value:i,source:null,stack:m??null,digest:c??null}}function Om(i,c){try{console.error(c.value)}catch(m){setTimeout(function(){throw m})}}var lI=typeof WeakMap=="function"?WeakMap:Map;function T0(i,c,m){m=Ms(-1,m),m.tag=3,m.payload={element:null};var k=c.value;return m.callback=function(){sf||(sf=!0,Vm=k),Om(i,c)},m}function j0(i,c,m){m=Ms(-1,m),m.tag=3;var k=i.type.getDerivedStateFromError;if(typeof k=="function"){var b=c.value;m.payload=function(){return k(b)},m.callback=function(){Om(i,c)}}var _=i.stateNode;return _!==null&&typeof _.componentDidCatch=="function"&&(m.callback=function(){Om(i,c),typeof k!="function"&&(yi===null?yi=new Set([this]):yi.add(this));var O=c.stack;this.componentDidCatch(c.value,{componentStack:O!==null?O:""})}),m}function $0(i,c,m){var k=i.pingCache;if(k===null){k=i.pingCache=new lI;var b=new Set;k.set(c,b)}else b=k.get(c),b===void 0&&(b=new Set,k.set(c,b));b.has(m)||(b.add(m),i=EI.bind(null,i,c,m),c.then(i,i))}function C0(i){do{var c;if((c=i.tag===13)&&(c=i.memoizedState,c=c!==null?c.dehydrated!==null:!0),c)return i;i=i.return}while(i!==null);return null}function A0(i,c,m,k,b){return(i.mode&1)===0?(i===c?i.flags|=65536:(i.flags|=128,m.flags|=131072,m.flags&=-52805,m.tag===1&&(m.alternate===null?m.tag=17:(c=Ms(-1,1),c.tag=2,ki(m,c,1))),m.lanes|=1),i):(i.flags|=65536,i.lanes=b,i)}var uI=j.ReactCurrentOwner,co=!1;function Xr(i,c,m,k){c.child=i===null?Xv(c,null,m,k):yc(c,i.child,m,k)}function I0(i,c,m,k,b){m=m.render;var _=c.ref;return bc(c,b),k=_m(i,c,m,k,_,b),m=Nm(),i!==null&&!co?(c.updateQueue=i.updateQueue,c.flags&=-2053,i.lanes&=~b,Ls(i,c,b)):(Wn&&m&&cm(c),c.flags|=1,Xr(i,c,k,b),c.child)}function R0(i,c,m,k,b){if(i===null){var _=m.type;return typeof _=="function"&&!ng(_)&&_.defaultProps===void 0&&m.compare===null&&m.defaultProps===void 0?(c.tag=15,c.type=_,O0(i,c,_,k,b)):(i=ff(m.type,null,k,c,c.mode,b),i.ref=c.ref,i.return=c,c.child=i)}if(_=i.child,(i.lanes&b)===0){var O=_.memoizedProps;if(m=m.compare,m=m!==null?m:li,m(O,k)&&i.ref===c.ref)return Ls(i,c,b)}return c.flags|=1,i=Ei(_,k),i.ref=c.ref,i.return=c,c.child=i}function O0(i,c,m,k,b){if(i!==null){var _=i.memoizedProps;if(li(_,k)&&i.ref===c.ref)if(co=!1,c.pendingProps=k=_,(i.lanes&b)!==0)(i.flags&131072)!==0&&(co=!0);else return c.lanes=i.lanes,Ls(i,c,b)}return Mm(i,c,m,k,b)}function M0(i,c,m){var k=c.pendingProps,b=k.children,_=i!==null?i.memoizedState:null;if(k.mode==="hidden")if((c.mode&1)===0)c.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ln(_c,_o),_o|=m;else{if((m&1073741824)===0)return i=_!==null?_.baseLanes|m:m,c.lanes=c.childLanes=1073741824,c.memoizedState={baseLanes:i,cachePool:null,transitions:null},c.updateQueue=null,Ln(_c,_o),_o|=i,null;c.memoizedState={baseLanes:0,cachePool:null,transitions:null},k=_!==null?_.baseLanes:m,Ln(_c,_o),_o|=k}else _!==null?(k=_.baseLanes|m,c.memoizedState=null):k=m,Ln(_c,_o),_o|=k;return Xr(i,c,b,m),c.child}function L0(i,c){var m=c.ref;(i===null&&m!==null||i!==null&&i.ref!==m)&&(c.flags|=512,c.flags|=2097152)}function Mm(i,c,m,k,b){var _=ao(m)?ca:Dr.current;return _=mc(c,_),bc(c,b),m=_m(i,c,m,k,_,b),k=Nm(),i!==null&&!co?(c.updateQueue=i.updateQueue,c.flags&=-2053,i.lanes&=~b,Ls(i,c,b)):(Wn&&k&&cm(c),c.flags|=1,Xr(i,c,m,b),c.child)}function P0(i,c,m,k,b){if(ao(m)){var _=!0;Ld(c)}else _=!1;if(bc(c,b),c.stateNode===null)ef(i,c),_0(c,m,k),Im(c,m,k,b),k=!0;else if(i===null){var O=c.stateNode,X=c.memoizedProps;O.props=X;var re=O.context,ke=m.contextType;typeof ke=="object"&&ke!==null?ke=Lo(ke):(ke=ao(m)?ca:Dr.current,ke=mc(c,ke));var Ae=m.getDerivedStateFromProps,Pe=typeof Ae=="function"||typeof O.getSnapshotBeforeUpdate=="function";Pe||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(X!==k||re!==ke)&&N0(c,O,k,ke),gi=!1;var je=c.memoizedState;O.state=je,Kd(c,k,O,b),re=c.memoizedState,X!==k||je!==re||io.current||gi?(typeof Ae=="function"&&(Am(c,m,Ae,k),re=c.memoizedState),(X=gi||S0(c,m,X,k,je,re,ke))?(Pe||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount()),typeof O.componentDidMount=="function"&&(c.flags|=4194308)):(typeof O.componentDidMount=="function"&&(c.flags|=4194308),c.memoizedProps=k,c.memoizedState=re),O.props=k,O.state=re,O.context=ke,k=X):(typeof O.componentDidMount=="function"&&(c.flags|=4194308),k=!1)}else{O=c.stateNode,Jv(i,c),X=c.memoizedProps,ke=c.type===c.elementType?X:Vo(c.type,X),O.props=ke,Pe=c.pendingProps,je=O.context,re=m.contextType,typeof re=="object"&&re!==null?re=Lo(re):(re=ao(m)?ca:Dr.current,re=mc(c,re));var tt=m.getDerivedStateFromProps;(Ae=typeof tt=="function"||typeof O.getSnapshotBeforeUpdate=="function")||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(X!==Pe||je!==re)&&N0(c,O,k,re),gi=!1,je=c.memoizedState,O.state=je,Kd(c,k,O,b);var at=c.memoizedState;X!==Pe||je!==at||io.current||gi?(typeof tt=="function"&&(Am(c,m,tt,k),at=c.memoizedState),(ke=gi||S0(c,m,ke,k,je,at,re)||!1)?(Ae||typeof O.UNSAFE_componentWillUpdate!="function"&&typeof O.componentWillUpdate!="function"||(typeof O.componentWillUpdate=="function"&&O.componentWillUpdate(k,at,re),typeof O.UNSAFE_componentWillUpdate=="function"&&O.UNSAFE_componentWillUpdate(k,at,re)),typeof O.componentDidUpdate=="function"&&(c.flags|=4),typeof O.getSnapshotBeforeUpdate=="function"&&(c.flags|=1024)):(typeof O.componentDidUpdate!="function"||X===i.memoizedProps&&je===i.memoizedState||(c.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||X===i.memoizedProps&&je===i.memoizedState||(c.flags|=1024),c.memoizedProps=k,c.memoizedState=at),O.props=k,O.state=at,O.context=re,k=ke):(typeof O.componentDidUpdate!="function"||X===i.memoizedProps&&je===i.memoizedState||(c.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||X===i.memoizedProps&&je===i.memoizedState||(c.flags|=1024),k=!1)}return Lm(i,c,m,k,_,b)}function Lm(i,c,m,k,b,_){L0(i,c);var O=(c.flags&128)!==0;if(!k&&!O)return b&&Uv(c,m,!1),Ls(i,c,_);k=c.stateNode,uI.current=c;var X=O&&typeof m.getDerivedStateFromError!="function"?null:k.render();return c.flags|=1,i!==null&&O?(c.child=yc(c,i.child,null,_),c.child=yc(c,null,X,_)):Xr(i,c,X,_),c.memoizedState=k.state,b&&Uv(c,m,!0),c.child}function D0(i){var c=i.stateNode;c.pendingContext?Fv(i,c.pendingContext,c.pendingContext!==c.context):c.context&&Fv(i,c.context,!1),ym(i,c.containerInfo)}function z0(i,c,m,k,b){return wc(),fm(b),c.flags|=256,Xr(i,c,m,k),c.child}var Pm={dehydrated:null,treeContext:null,retryLane:0};function Dm(i){return{baseLanes:i,cachePool:null,transitions:null}}function F0(i,c,m){var k=c.pendingProps,b=Gn.current,_=!1,O=(c.flags&128)!==0,X;if((X=O)||(X=i!==null&&i.memoizedState===null?!1:(b&2)!==0),X?(_=!0,c.flags&=-129):(i===null||i.memoizedState!==null)&&(b|=1),Ln(Gn,b&1),i===null)return dm(c),i=c.memoizedState,i!==null&&(i=i.dehydrated,i!==null)?((c.mode&1)===0?c.lanes=1:i.data==="$!"?c.lanes=8:c.lanes=1073741824,null):(O=k.children,i=k.fallback,_?(k=c.mode,_=c.child,O={mode:"hidden",children:O},(k&1)===0&&_!==null?(_.childLanes=0,_.pendingProps=O):_=hf(O,k,0,null),i=wa(i,k,m,null),_.return=c,i.return=c,_.sibling=i,c.child=_,c.child.memoizedState=Dm(m),c.memoizedState=Pm,i):zm(c,O));if(b=i.memoizedState,b!==null&&(X=b.dehydrated,X!==null))return dI(i,c,O,k,X,b,m);if(_){_=k.fallback,O=c.mode,b=i.child,X=b.sibling;var re={mode:"hidden",children:k.children};return(O&1)===0&&c.child!==b?(k=c.child,k.childLanes=0,k.pendingProps=re,c.deletions=null):(k=Ei(b,re),k.subtreeFlags=b.subtreeFlags&14680064),X!==null?_=Ei(X,_):(_=wa(_,O,m,null),_.flags|=2),_.return=c,k.return=c,k.sibling=_,c.child=k,k=_,_=c.child,O=i.child.memoizedState,O=O===null?Dm(m):{baseLanes:O.baseLanes|m,cachePool:null,transitions:O.transitions},_.memoizedState=O,_.childLanes=i.childLanes&~m,c.memoizedState=Pm,k}return _=i.child,i=_.sibling,k=Ei(_,{mode:"visible",children:k.children}),(c.mode&1)===0&&(k.lanes=m),k.return=c,k.sibling=null,i!==null&&(m=c.deletions,m===null?(c.deletions=[i],c.flags|=16):m.push(i)),c.child=k,c.memoizedState=null,k}function zm(i,c){return c=hf({mode:"visible",children:c},i.mode,0,null),c.return=i,i.child=c}function Jd(i,c,m,k){return k!==null&&fm(k),yc(c,i.child,null,m),i=zm(c,c.pendingProps.children),i.flags|=2,c.memoizedState=null,i}function dI(i,c,m,k,b,_,O){if(m)return c.flags&256?(c.flags&=-257,k=Rm(Error(n(422))),Jd(i,c,O,k)):c.memoizedState!==null?(c.child=i.child,c.flags|=128,null):(_=k.fallback,b=c.mode,k=hf({mode:"visible",children:k.children},b,0,null),_=wa(_,b,O,null),_.flags|=2,k.return=c,_.return=c,k.sibling=_,c.child=k,(c.mode&1)!==0&&yc(c,i.child,null,O),c.child.memoizedState=Dm(O),c.memoizedState=Pm,_);if((c.mode&1)===0)return Jd(i,c,O,null);if(b.data==="$!"){if(k=b.nextSibling&&b.nextSibling.dataset,k)var X=k.dgst;return k=X,_=Error(n(419)),k=Rm(_,k,void 0),Jd(i,c,O,k)}if(X=(O&i.childLanes)!==0,co||X){if(k=Er,k!==null){switch(O&-O){case 4:b=2;break;case 16:b=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:b=32;break;case 536870912:b=268435456;break;default:b=0}b=(b&(k.suspendedLanes|O))!==0?0:b,b!==0&&b!==_.retryLane&&(_.retryLane=b,Os(i,b),Qo(k,i,b,-1))}return tg(),k=Rm(Error(n(421))),Jd(i,c,O,k)}return b.data==="$?"?(c.flags|=128,c.child=i.child,c=SI.bind(null,i),b._reactRetry=c,null):(i=_.treeContext,So=fi(b.nextSibling),Eo=c,Wn=!0,Go=null,i!==null&&(Oo[Mo++]=Is,Oo[Mo++]=Rs,Oo[Mo++]=la,Is=i.id,Rs=i.overflow,la=c),c=zm(c,k.children),c.flags|=4096,c)}function B0(i,c,m){i.lanes|=c;var k=i.alternate;k!==null&&(k.lanes|=c),gm(i.return,c,m)}function Fm(i,c,m,k,b){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:c,rendering:null,renderingStartTime:0,last:k,tail:m,tailMode:b}:(_.isBackwards=c,_.rendering=null,_.renderingStartTime=0,_.last=k,_.tail=m,_.tailMode=b)}function U0(i,c,m){var k=c.pendingProps,b=k.revealOrder,_=k.tail;if(Xr(i,c,k.children,m),k=Gn.current,(k&2)!==0)k=k&1|2,c.flags|=128;else{if(i!==null&&(i.flags&128)!==0)e:for(i=c.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&B0(i,m,c);else if(i.tag===19)B0(i,m,c);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===c)break e;for(;i.sibling===null;){if(i.return===null||i.return===c)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}k&=1}if(Ln(Gn,k),(c.mode&1)===0)c.memoizedState=null;else switch(b){case"forwards":for(m=c.child,b=null;m!==null;)i=m.alternate,i!==null&&qd(i)===null&&(b=m),m=m.sibling;m=b,m===null?(b=c.child,c.child=null):(b=m.sibling,m.sibling=null),Fm(c,!1,b,m,_);break;case"backwards":for(m=null,b=c.child,c.child=null;b!==null;){if(i=b.alternate,i!==null&&qd(i)===null){c.child=b;break}i=b.sibling,b.sibling=m,m=b,b=i}Fm(c,!0,m,null,_);break;case"together":Fm(c,!1,null,null,void 0);break;default:c.memoizedState=null}return c.child}function ef(i,c){(c.mode&1)===0&&i!==null&&(i.alternate=null,c.alternate=null,c.flags|=2)}function Ls(i,c,m){if(i!==null&&(c.dependencies=i.dependencies),pa|=c.lanes,(m&c.childLanes)===0)return null;if(i!==null&&c.child!==i.child)throw Error(n(153));if(c.child!==null){for(i=c.child,m=Ei(i,i.pendingProps),c.child=m,m.return=c;i.sibling!==null;)i=i.sibling,m=m.sibling=Ei(i,i.pendingProps),m.return=c;m.sibling=null}return c.child}function fI(i,c,m){switch(c.tag){case 3:D0(c),wc();break;case 5:n0(c);break;case 1:ao(c.type)&&Ld(c);break;case 4:ym(c,c.stateNode.containerInfo);break;case 10:var k=c.type._context,b=c.memoizedProps.value;Ln(Ud,k._currentValue),k._currentValue=b;break;case 13:if(k=c.memoizedState,k!==null)return k.dehydrated!==null?(Ln(Gn,Gn.current&1),c.flags|=128,null):(m&c.child.childLanes)!==0?F0(i,c,m):(Ln(Gn,Gn.current&1),i=Ls(i,c,m),i!==null?i.sibling:null);Ln(Gn,Gn.current&1);break;case 19:if(k=(m&c.childLanes)!==0,(i.flags&128)!==0){if(k)return U0(i,c,m);c.flags|=128}if(b=c.memoizedState,b!==null&&(b.rendering=null,b.tail=null,b.lastEffect=null),Ln(Gn,Gn.current),k)break;return null;case 22:case 23:return c.lanes=0,M0(i,c,m)}return Ls(i,c,m)}var H0,Bm,W0,K0;H0=function(i,c){for(var m=c.child;m!==null;){if(m.tag===5||m.tag===6)i.appendChild(m.stateNode);else if(m.tag!==4&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===c)break;for(;m.sibling===null;){if(m.return===null||m.return===c)return;m=m.return}m.sibling.return=m.return,m=m.sibling}},Bm=function(){},W0=function(i,c,m,k){var b=i.memoizedProps;if(b!==k){i=c.stateNode,fa(hs.current);var _=null;switch(m){case"input":b=_e(i,b),k=_e(i,k),_=[];break;case"select":b=U({},b,{value:void 0}),k=U({},k,{value:void 0}),_=[];break;case"textarea":b=Ke(i,b),k=Ke(i,k),_=[];break;default:typeof b.onClick!="function"&&typeof k.onClick=="function"&&(i.onclick=Rd)}Wt(m,k);var O;m=null;for(ke in b)if(!k.hasOwnProperty(ke)&&b.hasOwnProperty(ke)&&b[ke]!=null)if(ke==="style"){var X=b[ke];for(O in X)X.hasOwnProperty(O)&&(m||(m={}),m[O]="")}else ke!=="dangerouslySetInnerHTML"&&ke!=="children"&&ke!=="suppressContentEditableWarning"&&ke!=="suppressHydrationWarning"&&ke!=="autoFocus"&&(o.hasOwnProperty(ke)?_||(_=[]):(_=_||[]).push(ke,null));for(ke in k){var re=k[ke];if(X=b!=null?b[ke]:void 0,k.hasOwnProperty(ke)&&re!==X&&(re!=null||X!=null))if(ke==="style")if(X){for(O in X)!X.hasOwnProperty(O)||re&&re.hasOwnProperty(O)||(m||(m={}),m[O]="");for(O in re)re.hasOwnProperty(O)&&X[O]!==re[O]&&(m||(m={}),m[O]=re[O])}else m||(_||(_=[]),_.push(ke,m)),m=re;else ke==="dangerouslySetInnerHTML"?(re=re?re.__html:void 0,X=X?X.__html:void 0,re!=null&&X!==re&&(_=_||[]).push(ke,re)):ke==="children"?typeof re!="string"&&typeof re!="number"||(_=_||[]).push(ke,""+re):ke!=="suppressContentEditableWarning"&&ke!=="suppressHydrationWarning"&&(o.hasOwnProperty(ke)?(re!=null&&ke==="onScroll"&&Fn("scroll",i),_||X===re||(_=[])):(_=_||[]).push(ke,re))}m&&(_=_||[]).push("style",m);var ke=_;(c.updateQueue=ke)&&(c.flags|=4)}},K0=function(i,c,m,k){m!==k&&(c.flags|=4)};function Gl(i,c){if(!Wn)switch(i.tailMode){case"hidden":c=i.tail;for(var m=null;c!==null;)c.alternate!==null&&(m=c),c=c.sibling;m===null?i.tail=null:m.sibling=null;break;case"collapsed":m=i.tail;for(var k=null;m!==null;)m.alternate!==null&&(k=m),m=m.sibling;k===null?c||i.tail===null?i.tail=null:i.tail.sibling=null:k.sibling=null}}function Fr(i){var c=i.alternate!==null&&i.alternate.child===i.child,m=0,k=0;if(c)for(var b=i.child;b!==null;)m|=b.lanes|b.childLanes,k|=b.subtreeFlags&14680064,k|=b.flags&14680064,b.return=i,b=b.sibling;else for(b=i.child;b!==null;)m|=b.lanes|b.childLanes,k|=b.subtreeFlags,k|=b.flags,b.return=i,b=b.sibling;return i.subtreeFlags|=k,i.childLanes=m,c}function hI(i,c,m){var k=c.pendingProps;switch(lm(c),c.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Fr(c),null;case 1:return ao(c.type)&&Md(),Fr(c),null;case 3:return k=c.stateNode,xc(),Bn(io),Bn(Dr),xm(),k.pendingContext&&(k.context=k.pendingContext,k.pendingContext=null),(i===null||i.child===null)&&(Fd(c)?c.flags|=4:i===null||i.memoizedState.isDehydrated&&(c.flags&256)===0||(c.flags|=1024,Go!==null&&(Qm(Go),Go=null))),Bm(i,c),Fr(c),null;case 5:vm(c);var b=fa(Hl.current);if(m=c.type,i!==null&&c.stateNode!=null)W0(i,c,m,k,b),i.ref!==c.ref&&(c.flags|=512,c.flags|=2097152);else{if(!k){if(c.stateNode===null)throw Error(n(166));return Fr(c),null}if(i=fa(hs.current),Fd(c)){k=c.stateNode,m=c.type;var _=c.memoizedProps;switch(k[fs]=c,k[Dl]=_,i=(c.mode&1)!==0,m){case"dialog":Fn("cancel",k),Fn("close",k);break;case"iframe":case"object":case"embed":Fn("load",k);break;case"video":case"audio":for(b=0;b<Ml.length;b++)Fn(Ml[b],k);break;case"source":Fn("error",k);break;case"img":case"image":case"link":Fn("error",k),Fn("load",k);break;case"details":Fn("toggle",k);break;case"input":be(k,_),Fn("invalid",k);break;case"select":k._wrapperState={wasMultiple:!!_.multiple},Fn("invalid",k);break;case"textarea":Qt(k,_),Fn("invalid",k)}Wt(m,_),b=null;for(var O in _)if(_.hasOwnProperty(O)){var X=_[O];O==="children"?typeof X=="string"?k.textContent!==X&&(_.suppressHydrationWarning!==!0&&Id(k.textContent,X,i),b=["children",X]):typeof X=="number"&&k.textContent!==""+X&&(_.suppressHydrationWarning!==!0&&Id(k.textContent,X,i),b=["children",""+X]):o.hasOwnProperty(O)&&X!=null&&O==="onScroll"&&Fn("scroll",k)}switch(m){case"input":de(k),rt(k,_,!0);break;case"textarea":de(k),Zt(k);break;case"select":case"option":break;default:typeof _.onClick=="function"&&(k.onclick=Rd)}k=b,c.updateQueue=k,k!==null&&(c.flags|=4)}else{O=b.nodeType===9?b:b.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=Ge(m)),i==="http://www.w3.org/1999/xhtml"?m==="script"?(i=O.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof k.is=="string"?i=O.createElement(m,{is:k.is}):(i=O.createElement(m),m==="select"&&(O=i,k.multiple?O.multiple=!0:k.size&&(O.size=k.size))):i=O.createElementNS(i,m),i[fs]=c,i[Dl]=k,H0(i,c,!1,!1),c.stateNode=i;e:{switch(O=Dn(m,k),m){case"dialog":Fn("cancel",i),Fn("close",i),b=k;break;case"iframe":case"object":case"embed":Fn("load",i),b=k;break;case"video":case"audio":for(b=0;b<Ml.length;b++)Fn(Ml[b],i);b=k;break;case"source":Fn("error",i),b=k;break;case"img":case"image":case"link":Fn("error",i),Fn("load",i),b=k;break;case"details":Fn("toggle",i),b=k;break;case"input":be(i,k),b=_e(i,k),Fn("invalid",i);break;case"option":b=k;break;case"select":i._wrapperState={wasMultiple:!!k.multiple},b=U({},k,{value:void 0}),Fn("invalid",i);break;case"textarea":Qt(i,k),b=Ke(i,k),Fn("invalid",i);break;default:b=k}Wt(m,b),X=b;for(_ in X)if(X.hasOwnProperty(_)){var re=X[_];_==="style"?Pt(i,re):_==="dangerouslySetInnerHTML"?(re=re?re.__html:void 0,re!=null&&It(i,re)):_==="children"?typeof re=="string"?(m!=="textarea"||re!=="")&&gt(i,re):typeof re=="number"&&gt(i,""+re):_!=="suppressContentEditableWarning"&&_!=="suppressHydrationWarning"&&_!=="autoFocus"&&(o.hasOwnProperty(_)?re!=null&&_==="onScroll"&&Fn("scroll",i):re!=null&&T(i,_,re,O))}switch(m){case"input":de(i),rt(i,k,!1);break;case"textarea":de(i),Zt(i);break;case"option":k.value!=null&&i.setAttribute("value",""+Z(k.value));break;case"select":i.multiple=!!k.multiple,_=k.value,_!=null?Et(i,!!k.multiple,_,!1):k.defaultValue!=null&&Et(i,!!k.multiple,k.defaultValue,!0);break;default:typeof b.onClick=="function"&&(i.onclick=Rd)}switch(m){case"button":case"input":case"select":case"textarea":k=!!k.autoFocus;break e;case"img":k=!0;break e;default:k=!1}}k&&(c.flags|=4)}c.ref!==null&&(c.flags|=512,c.flags|=2097152)}return Fr(c),null;case 6:if(i&&c.stateNode!=null)K0(i,c,i.memoizedProps,k);else{if(typeof k!="string"&&c.stateNode===null)throw Error(n(166));if(m=fa(Hl.current),fa(hs.current),Fd(c)){if(k=c.stateNode,m=c.memoizedProps,k[fs]=c,(_=k.nodeValue!==m)&&(i=Eo,i!==null))switch(i.tag){case 3:Id(k.nodeValue,m,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&Id(k.nodeValue,m,(i.mode&1)!==0)}_&&(c.flags|=4)}else k=(m.nodeType===9?m:m.ownerDocument).createTextNode(k),k[fs]=c,c.stateNode=k}return Fr(c),null;case 13:if(Bn(Gn),k=c.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(Wn&&So!==null&&(c.mode&1)!==0&&(c.flags&128)===0)Gv(),wc(),c.flags|=98560,_=!1;else if(_=Fd(c),k!==null&&k.dehydrated!==null){if(i===null){if(!_)throw Error(n(318));if(_=c.memoizedState,_=_!==null?_.dehydrated:null,!_)throw Error(n(317));_[fs]=c}else wc(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;Fr(c),_=!1}else Go!==null&&(Qm(Go),Go=null),_=!0;if(!_)return c.flags&65536?c:null}return(c.flags&128)!==0?(c.lanes=m,c):(k=k!==null,k!==(i!==null&&i.memoizedState!==null)&&k&&(c.child.flags|=8192,(c.mode&1)!==0&&(i===null||(Gn.current&1)!==0?kr===0&&(kr=3):tg())),c.updateQueue!==null&&(c.flags|=4),Fr(c),null);case 4:return xc(),Bm(i,c),i===null&&Ll(c.stateNode.containerInfo),Fr(c),null;case 10:return mm(c.type._context),Fr(c),null;case 17:return ao(c.type)&&Md(),Fr(c),null;case 19:if(Bn(Gn),_=c.memoizedState,_===null)return Fr(c),null;if(k=(c.flags&128)!==0,O=_.rendering,O===null)if(k)Gl(_,!1);else{if(kr!==0||i!==null&&(i.flags&128)!==0)for(i=c.child;i!==null;){if(O=qd(i),O!==null){for(c.flags|=128,Gl(_,!1),k=O.updateQueue,k!==null&&(c.updateQueue=k,c.flags|=4),c.subtreeFlags=0,k=m,m=c.child;m!==null;)_=m,i=k,_.flags&=14680066,O=_.alternate,O===null?(_.childLanes=0,_.lanes=i,_.child=null,_.subtreeFlags=0,_.memoizedProps=null,_.memoizedState=null,_.updateQueue=null,_.dependencies=null,_.stateNode=null):(_.childLanes=O.childLanes,_.lanes=O.lanes,_.child=O.child,_.subtreeFlags=0,_.deletions=null,_.memoizedProps=O.memoizedProps,_.memoizedState=O.memoizedState,_.updateQueue=O.updateQueue,_.type=O.type,i=O.dependencies,_.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),m=m.sibling;return Ln(Gn,Gn.current&1|2),c.child}i=i.sibling}_.tail!==null&&un()>Nc&&(c.flags|=128,k=!0,Gl(_,!1),c.lanes=4194304)}else{if(!k)if(i=qd(O),i!==null){if(c.flags|=128,k=!0,m=i.updateQueue,m!==null&&(c.updateQueue=m,c.flags|=4),Gl(_,!0),_.tail===null&&_.tailMode==="hidden"&&!O.alternate&&!Wn)return Fr(c),null}else 2*un()-_.renderingStartTime>Nc&&m!==1073741824&&(c.flags|=128,k=!0,Gl(_,!1),c.lanes=4194304);_.isBackwards?(O.sibling=c.child,c.child=O):(m=_.last,m!==null?m.sibling=O:c.child=O,_.last=O)}return _.tail!==null?(c=_.tail,_.rendering=c,_.tail=c.sibling,_.renderingStartTime=un(),c.sibling=null,m=Gn.current,Ln(Gn,k?m&1|2:m&1),c):(Fr(c),null);case 22:case 23:return eg(),k=c.memoizedState!==null,i!==null&&i.memoizedState!==null!==k&&(c.flags|=8192),k&&(c.mode&1)!==0?(_o&1073741824)!==0&&(Fr(c),c.subtreeFlags&6&&(c.flags|=8192)):Fr(c),null;case 24:return null;case 25:return null}throw Error(n(156,c.tag))}function pI(i,c){switch(lm(c),c.tag){case 1:return ao(c.type)&&Md(),i=c.flags,i&65536?(c.flags=i&-65537|128,c):null;case 3:return xc(),Bn(io),Bn(Dr),xm(),i=c.flags,(i&65536)!==0&&(i&128)===0?(c.flags=i&-65537|128,c):null;case 5:return vm(c),null;case 13:if(Bn(Gn),i=c.memoizedState,i!==null&&i.dehydrated!==null){if(c.alternate===null)throw Error(n(340));wc()}return i=c.flags,i&65536?(c.flags=i&-65537|128,c):null;case 19:return Bn(Gn),null;case 4:return xc(),null;case 10:return mm(c.type._context),null;case 22:case 23:return eg(),null;case 24:return null;default:return null}}var tf=!1,Br=!1,mI=typeof WeakSet=="function"?WeakSet:Set,st=null;function Sc(i,c){var m=i.ref;if(m!==null)if(typeof m=="function")try{m(null)}catch(k){nr(i,c,k)}else m.current=null}function Um(i,c,m){try{m()}catch(k){nr(i,c,k)}}var q0=!1;function gI(i,c){if(em=Qa,i=Il(),ac(i)){if("selectionStart"in i)var m={start:i.selectionStart,end:i.selectionEnd};else e:{m=(m=i.ownerDocument)&&m.defaultView||window;var k=m.getSelection&&m.getSelection();if(k&&k.rangeCount!==0){m=k.anchorNode;var b=k.anchorOffset,_=k.focusNode;k=k.focusOffset;try{m.nodeType,_.nodeType}catch{m=null;break e}var O=0,X=-1,re=-1,ke=0,Ae=0,Pe=i,je=null;t:for(;;){for(var tt;Pe!==m||b!==0&&Pe.nodeType!==3||(X=O+b),Pe!==_||k!==0&&Pe.nodeType!==3||(re=O+k),Pe.nodeType===3&&(O+=Pe.nodeValue.length),(tt=Pe.firstChild)!==null;)je=Pe,Pe=tt;for(;;){if(Pe===i)break t;if(je===m&&++ke===b&&(X=O),je===_&&++Ae===k&&(re=O),(tt=Pe.nextSibling)!==null)break;Pe=je,je=Pe.parentNode}Pe=tt}m=X===-1||re===-1?null:{start:X,end:re}}else m=null}m=m||{start:0,end:0}}else m=null;for(tm={focusedElem:i,selectionRange:m},Qa=!1,st=c;st!==null;)if(c=st,i=c.child,(c.subtreeFlags&1028)!==0&&i!==null)i.return=c,st=i;else for(;st!==null;){c=st;try{var at=c.alternate;if((c.flags&1024)!==0)switch(c.tag){case 0:case 11:case 15:break;case 1:if(at!==null){var lt=at.memoizedProps,ir=at.memoizedState,fe=c.stateNode,ae=fe.getSnapshotBeforeUpdate(c.elementType===c.type?lt:Vo(c.type,lt),ir);fe.__reactInternalSnapshotBeforeUpdate=ae}break;case 3:var ge=c.stateNode.containerInfo;ge.nodeType===1?ge.textContent="":ge.nodeType===9&&ge.documentElement&&ge.removeChild(ge.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Ue){nr(c,c.return,Ue)}if(i=c.sibling,i!==null){i.return=c.return,st=i;break}st=c.return}return at=q0,q0=!1,at}function Vl(i,c,m){var k=c.updateQueue;if(k=k!==null?k.lastEffect:null,k!==null){var b=k=k.next;do{if((b.tag&i)===i){var _=b.destroy;b.destroy=void 0,_!==void 0&&Um(c,m,_)}b=b.next}while(b!==k)}}function nf(i,c){if(c=c.updateQueue,c=c!==null?c.lastEffect:null,c!==null){var m=c=c.next;do{if((m.tag&i)===i){var k=m.create;m.destroy=k()}m=m.next}while(m!==c)}}function Hm(i){var c=i.ref;if(c!==null){var m=i.stateNode;switch(i.tag){case 5:i=m;break;default:i=m}typeof c=="function"?c(i):c.current=i}}function Z0(i){var c=i.alternate;c!==null&&(i.alternate=null,Z0(c)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(c=i.stateNode,c!==null&&(delete c[fs],delete c[Dl],delete c[sm],delete c[QA],delete c[JA])),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}function G0(i){return i.tag===5||i.tag===3||i.tag===4}function V0(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||G0(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function Wm(i,c,m){var k=i.tag;if(k===5||k===6)i=i.stateNode,c?m.nodeType===8?m.parentNode.insertBefore(i,c):m.insertBefore(i,c):(m.nodeType===8?(c=m.parentNode,c.insertBefore(i,m)):(c=m,c.appendChild(i)),m=m._reactRootContainer,m!=null||c.onclick!==null||(c.onclick=Rd));else if(k!==4&&(i=i.child,i!==null))for(Wm(i,c,m),i=i.sibling;i!==null;)Wm(i,c,m),i=i.sibling}function Km(i,c,m){var k=i.tag;if(k===5||k===6)i=i.stateNode,c?m.insertBefore(i,c):m.appendChild(i);else if(k!==4&&(i=i.child,i!==null))for(Km(i,c,m),i=i.sibling;i!==null;)Km(i,c,m),i=i.sibling}var Ar=null,Yo=!1;function wi(i,c,m){for(m=m.child;m!==null;)Y0(i,c,m),m=m.sibling}function Y0(i,c,m){if(yt&&typeof yt.onCommitFiberUnmount=="function")try{yt.onCommitFiberUnmount(At,m)}catch{}switch(m.tag){case 5:Br||Sc(m,c);case 6:var k=Ar,b=Yo;Ar=null,wi(i,c,m),Ar=k,Yo=b,Ar!==null&&(Yo?(i=Ar,m=m.stateNode,i.nodeType===8?i.parentNode.removeChild(m):i.removeChild(m)):Ar.removeChild(m.stateNode));break;case 18:Ar!==null&&(Yo?(i=Ar,m=m.stateNode,i.nodeType===8?om(i.parentNode,m):i.nodeType===1&&om(i,m),ti(i)):om(Ar,m.stateNode));break;case 4:k=Ar,b=Yo,Ar=m.stateNode.containerInfo,Yo=!0,wi(i,c,m),Ar=k,Yo=b;break;case 0:case 11:case 14:case 15:if(!Br&&(k=m.updateQueue,k!==null&&(k=k.lastEffect,k!==null))){b=k=k.next;do{var _=b,O=_.destroy;_=_.tag,O!==void 0&&((_&2)!==0||(_&4)!==0)&&Um(m,c,O),b=b.next}while(b!==k)}wi(i,c,m);break;case 1:if(!Br&&(Sc(m,c),k=m.stateNode,typeof k.componentWillUnmount=="function"))try{k.props=m.memoizedProps,k.state=m.memoizedState,k.componentWillUnmount()}catch(X){nr(m,c,X)}wi(i,c,m);break;case 21:wi(i,c,m);break;case 22:m.mode&1?(Br=(k=Br)||m.memoizedState!==null,wi(i,c,m),Br=k):wi(i,c,m);break;default:wi(i,c,m)}}function X0(i){var c=i.updateQueue;if(c!==null){i.updateQueue=null;var m=i.stateNode;m===null&&(m=i.stateNode=new mI),c.forEach(function(k){var b=_I.bind(null,i,k);m.has(k)||(m.add(k),k.then(b,b))})}}function Xo(i,c){var m=c.deletions;if(m!==null)for(var k=0;k<m.length;k++){var b=m[k];try{var _=i,O=c,X=O;e:for(;X!==null;){switch(X.tag){case 5:Ar=X.stateNode,Yo=!1;break e;case 3:Ar=X.stateNode.containerInfo,Yo=!0;break e;case 4:Ar=X.stateNode.containerInfo,Yo=!0;break e}X=X.return}if(Ar===null)throw Error(n(160));Y0(_,O,b),Ar=null,Yo=!1;var re=b.alternate;re!==null&&(re.return=null),b.return=null}catch(ke){nr(b,c,ke)}}if(c.subtreeFlags&12854)for(c=c.child;c!==null;)Q0(c,i),c=c.sibling}function Q0(i,c){var m=i.alternate,k=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(Xo(c,i),ms(i),k&4){try{Vl(3,i,i.return),nf(3,i)}catch(lt){nr(i,i.return,lt)}try{Vl(5,i,i.return)}catch(lt){nr(i,i.return,lt)}}break;case 1:Xo(c,i),ms(i),k&512&&m!==null&&Sc(m,m.return);break;case 5:if(Xo(c,i),ms(i),k&512&&m!==null&&Sc(m,m.return),i.flags&32){var b=i.stateNode;try{gt(b,"")}catch(lt){nr(i,i.return,lt)}}if(k&4&&(b=i.stateNode,b!=null)){var _=i.memoizedProps,O=m!==null?m.memoizedProps:_,X=i.type,re=i.updateQueue;if(i.updateQueue=null,re!==null)try{X==="input"&&_.type==="radio"&&_.name!=null&&$e(b,_),Dn(X,O);var ke=Dn(X,_);for(O=0;O<re.length;O+=2){var Ae=re[O],Pe=re[O+1];Ae==="style"?Pt(b,Pe):Ae==="dangerouslySetInnerHTML"?It(b,Pe):Ae==="children"?gt(b,Pe):T(b,Ae,Pe,ke)}switch(X){case"input":Ze(b,_);break;case"textarea":Ot(b,_);break;case"select":var je=b._wrapperState.wasMultiple;b._wrapperState.wasMultiple=!!_.multiple;var tt=_.value;tt!=null?Et(b,!!_.multiple,tt,!1):je!==!!_.multiple&&(_.defaultValue!=null?Et(b,!!_.multiple,_.defaultValue,!0):Et(b,!!_.multiple,_.multiple?[]:"",!1))}b[Dl]=_}catch(lt){nr(i,i.return,lt)}}break;case 6:if(Xo(c,i),ms(i),k&4){if(i.stateNode===null)throw Error(n(162));b=i.stateNode,_=i.memoizedProps;try{b.nodeValue=_}catch(lt){nr(i,i.return,lt)}}break;case 3:if(Xo(c,i),ms(i),k&4&&m!==null&&m.memoizedState.isDehydrated)try{ti(c.containerInfo)}catch(lt){nr(i,i.return,lt)}break;case 4:Xo(c,i),ms(i);break;case 13:Xo(c,i),ms(i),b=i.child,b.flags&8192&&(_=b.memoizedState!==null,b.stateNode.isHidden=_,!_||b.alternate!==null&&b.alternate.memoizedState!==null||(Gm=un())),k&4&&X0(i);break;case 22:if(Ae=m!==null&&m.memoizedState!==null,i.mode&1?(Br=(ke=Br)||Ae,Xo(c,i),Br=ke):Xo(c,i),ms(i),k&8192){if(ke=i.memoizedState!==null,(i.stateNode.isHidden=ke)&&!Ae&&(i.mode&1)!==0)for(st=i,Ae=i.child;Ae!==null;){for(Pe=st=Ae;st!==null;){switch(je=st,tt=je.child,je.tag){case 0:case 11:case 14:case 15:Vl(4,je,je.return);break;case 1:Sc(je,je.return);var at=je.stateNode;if(typeof at.componentWillUnmount=="function"){k=je,m=je.return;try{c=k,at.props=c.memoizedProps,at.state=c.memoizedState,at.componentWillUnmount()}catch(lt){nr(k,m,lt)}}break;case 5:Sc(je,je.return);break;case 22:if(je.memoizedState!==null){tb(Pe);continue}}tt!==null?(tt.return=je,st=tt):tb(Pe)}Ae=Ae.sibling}e:for(Ae=null,Pe=i;;){if(Pe.tag===5){if(Ae===null){Ae=Pe;try{b=Pe.stateNode,ke?(_=b.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none"):(X=Pe.stateNode,re=Pe.memoizedProps.style,O=re!=null&&re.hasOwnProperty("display")?re.display:null,X.style.display=Ce("display",O))}catch(lt){nr(i,i.return,lt)}}}else if(Pe.tag===6){if(Ae===null)try{Pe.stateNode.nodeValue=ke?"":Pe.memoizedProps}catch(lt){nr(i,i.return,lt)}}else if((Pe.tag!==22&&Pe.tag!==23||Pe.memoizedState===null||Pe===i)&&Pe.child!==null){Pe.child.return=Pe,Pe=Pe.child;continue}if(Pe===i)break e;for(;Pe.sibling===null;){if(Pe.return===null||Pe.return===i)break e;Ae===Pe&&(Ae=null),Pe=Pe.return}Ae===Pe&&(Ae=null),Pe.sibling.return=Pe.return,Pe=Pe.sibling}}break;case 19:Xo(c,i),ms(i),k&4&&X0(i);break;case 21:break;default:Xo(c,i),ms(i)}}function ms(i){var c=i.flags;if(c&2){try{e:{for(var m=i.return;m!==null;){if(G0(m)){var k=m;break e}m=m.return}throw Error(n(160))}switch(k.tag){case 5:var b=k.stateNode;k.flags&32&&(gt(b,""),k.flags&=-33);var _=V0(i);Km(i,_,b);break;case 3:case 4:var O=k.stateNode.containerInfo,X=V0(i);Wm(i,X,O);break;default:throw Error(n(161))}}catch(re){nr(i,i.return,re)}i.flags&=-3}c&4096&&(i.flags&=-4097)}function kI(i,c,m){st=i,J0(i)}function J0(i,c,m){for(var k=(i.mode&1)!==0;st!==null;){var b=st,_=b.child;if(b.tag===22&&k){var O=b.memoizedState!==null||tf;if(!O){var X=b.alternate,re=X!==null&&X.memoizedState!==null||Br;X=tf;var ke=Br;if(tf=O,(Br=re)&&!ke)for(st=b;st!==null;)O=st,re=O.child,O.tag===22&&O.memoizedState!==null?nb(b):re!==null?(re.return=O,st=re):nb(b);for(;_!==null;)st=_,J0(_),_=_.sibling;st=b,tf=X,Br=ke}eb(i)}else(b.subtreeFlags&8772)!==0&&_!==null?(_.return=b,st=_):eb(i)}}function eb(i){for(;st!==null;){var c=st;if((c.flags&8772)!==0){var m=c.alternate;try{if((c.flags&8772)!==0)switch(c.tag){case 0:case 11:case 15:Br||nf(5,c);break;case 1:var k=c.stateNode;if(c.flags&4&&!Br)if(m===null)k.componentDidMount();else{var b=c.elementType===c.type?m.memoizedProps:Vo(c.type,m.memoizedProps);k.componentDidUpdate(b,m.memoizedState,k.__reactInternalSnapshotBeforeUpdate)}var _=c.updateQueue;_!==null&&t0(c,_,k);break;case 3:var O=c.updateQueue;if(O!==null){if(m=null,c.child!==null)switch(c.child.tag){case 5:m=c.child.stateNode;break;case 1:m=c.child.stateNode}t0(c,O,m)}break;case 5:var X=c.stateNode;if(m===null&&c.flags&4){m=X;var re=c.memoizedProps;switch(c.type){case"button":case"input":case"select":case"textarea":re.autoFocus&&m.focus();break;case"img":re.src&&(m.src=re.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(c.memoizedState===null){var ke=c.alternate;if(ke!==null){var Ae=ke.memoizedState;if(Ae!==null){var Pe=Ae.dehydrated;Pe!==null&&ti(Pe)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Br||c.flags&512&&Hm(c)}catch(je){nr(c,c.return,je)}}if(c===i){st=null;break}if(m=c.sibling,m!==null){m.return=c.return,st=m;break}st=c.return}}function tb(i){for(;st!==null;){var c=st;if(c===i){st=null;break}var m=c.sibling;if(m!==null){m.return=c.return,st=m;break}st=c.return}}function nb(i){for(;st!==null;){var c=st;try{switch(c.tag){case 0:case 11:case 15:var m=c.return;try{nf(4,c)}catch(re){nr(c,m,re)}break;case 1:var k=c.stateNode;if(typeof k.componentDidMount=="function"){var b=c.return;try{k.componentDidMount()}catch(re){nr(c,b,re)}}var _=c.return;try{Hm(c)}catch(re){nr(c,_,re)}break;case 5:var O=c.return;try{Hm(c)}catch(re){nr(c,O,re)}}}catch(re){nr(c,c.return,re)}if(c===i){st=null;break}var X=c.sibling;if(X!==null){X.return=c.return,st=X;break}st=c.return}}var wI=Math.ceil,rf=j.ReactCurrentDispatcher,qm=j.ReactCurrentOwner,Do=j.ReactCurrentBatchConfig,gn=0,Er=null,lr=null,Ir=0,_o=0,_c=hi(0),kr=0,Yl=null,pa=0,of=0,Zm=0,Xl=null,lo=null,Gm=0,Nc=1/0,Ps=null,sf=!1,Vm=null,yi=null,af=!1,vi=null,cf=0,Ql=0,Ym=null,lf=-1,uf=0;function Qr(){return(gn&6)!==0?un():lf!==-1?lf:lf=un()}function bi(i){return(i.mode&1)===0?1:(gn&2)!==0&&Ir!==0?Ir&-Ir:tI.transition!==null?(uf===0&&(uf=Ro()),uf):(i=Ve,i!==0||(i=window.event,i=i===void 0?16:gl(i.type)),i)}function Qo(i,c,m,k){if(50<Ql)throw Ql=0,Ym=null,Error(n(185));G(i,m,k),((gn&2)===0||i!==Er)&&(i===Er&&((gn&2)===0&&(of|=m),kr===4&&xi(i,Ir)),uo(i,k),m===1&&gn===0&&(c.mode&1)===0&&(Nc=un()+500,Pd&&mi()))}function uo(i,c){var m=i.callbackNode;Gr(i,c);var k=br(i,i===Er?Ir:0);if(k===0)m!==null&&wt(m),i.callbackNode=null,i.callbackPriority=0;else if(c=k&-k,i.callbackPriority!==c){if(m!=null&&wt(m),c===1)i.tag===0?eI(ob.bind(null,i)):Hv(ob.bind(null,i)),YA(function(){(gn&6)===0&&mi()}),m=null;else{switch(He(k)){case 1:m=Qn;break;case 4:m=Bt;break;case 16:m=dn;break;case 536870912:m=Le;break;default:m=dn}m=fb(m,rb.bind(null,i))}i.callbackPriority=c,i.callbackNode=m}}function rb(i,c){if(lf=-1,uf=0,(gn&6)!==0)throw Error(n(327));var m=i.callbackNode;if(Tc()&&i.callbackNode!==m)return null;var k=br(i,i===Er?Ir:0);if(k===0)return null;if((k&30)!==0||(k&i.expiredLanes)!==0||c)c=df(i,k);else{c=k;var b=gn;gn|=2;var _=ib();(Er!==i||Ir!==c)&&(Ps=null,Nc=un()+500,ga(i,c));do try{bI();break}catch(X){sb(i,X)}while(!0);pm(),rf.current=_,gn=b,lr!==null?c=0:(Er=null,Ir=0,c=kr)}if(c!==0){if(c===2&&(b=ro(i),b!==0&&(k=b,c=Xm(i,b))),c===1)throw m=Yl,ga(i,0),xi(i,k),uo(i,un()),m;if(c===6)xi(i,k);else{if(b=i.current.alternate,(k&30)===0&&!yI(b)&&(c=df(i,k),c===2&&(_=ro(i),_!==0&&(k=_,c=Xm(i,_))),c===1))throw m=Yl,ga(i,0),xi(i,k),uo(i,un()),m;switch(i.finishedWork=b,i.finishedLanes=k,c){case 0:case 1:throw Error(n(345));case 2:ka(i,lo,Ps);break;case 3:if(xi(i,k),(k&130023424)===k&&(c=Gm+500-un(),10<c)){if(br(i,0)!==0)break;if(b=i.suspendedLanes,(b&k)!==k){Qr(),i.pingedLanes|=i.suspendedLanes&b;break}i.timeoutHandle=rm(ka.bind(null,i,lo,Ps),c);break}ka(i,lo,Ps);break;case 4:if(xi(i,k),(k&4194240)===k)break;for(c=i.eventTimes,b=-1;0<k;){var O=31-Gt(k);_=1<<O,O=c[O],O>b&&(b=O),k&=~_}if(k=b,k=un()-k,k=(120>k?120:480>k?480:1080>k?1080:1920>k?1920:3e3>k?3e3:4320>k?4320:1960*wI(k/1960))-k,10<k){i.timeoutHandle=rm(ka.bind(null,i,lo,Ps),k);break}ka(i,lo,Ps);break;case 5:ka(i,lo,Ps);break;default:throw Error(n(329))}}}return uo(i,un()),i.callbackNode===m?rb.bind(null,i):null}function Xm(i,c){var m=Xl;return i.current.memoizedState.isDehydrated&&(ga(i,c).flags|=256),i=df(i,c),i!==2&&(c=lo,lo=m,c!==null&&Qm(c)),i}function Qm(i){lo===null?lo=i:lo.push.apply(lo,i)}function yI(i){for(var c=i;;){if(c.flags&16384){var m=c.updateQueue;if(m!==null&&(m=m.stores,m!==null))for(var k=0;k<m.length;k++){var b=m[k],_=b.getSnapshot;b=b.value;try{if(!Yr(_(),b))return!1}catch{return!1}}}if(m=c.child,c.subtreeFlags&16384&&m!==null)m.return=c,c=m;else{if(c===i)break;for(;c.sibling===null;){if(c.return===null||c.return===i)return!0;c=c.return}c.sibling.return=c.return,c=c.sibling}}return!0}function xi(i,c){for(c&=~Zm,c&=~of,i.suspendedLanes|=c,i.pingedLanes&=~c,i=i.expirationTimes;0<c;){var m=31-Gt(c),k=1<<m;i[m]=-1,c&=~k}}function ob(i){if((gn&6)!==0)throw Error(n(327));Tc();var c=br(i,0);if((c&1)===0)return uo(i,un()),null;var m=df(i,c);if(i.tag!==0&&m===2){var k=ro(i);k!==0&&(c=k,m=Xm(i,k))}if(m===1)throw m=Yl,ga(i,0),xi(i,c),uo(i,un()),m;if(m===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=c,ka(i,lo,Ps),uo(i,un()),null}function Jm(i,c){var m=gn;gn|=1;try{return i(c)}finally{gn=m,gn===0&&(Nc=un()+500,Pd&&mi())}}function ma(i){vi!==null&&vi.tag===0&&(gn&6)===0&&Tc();var c=gn;gn|=1;var m=Do.transition,k=Ve;try{if(Do.transition=null,Ve=1,i)return i()}finally{Ve=k,Do.transition=m,gn=c,(gn&6)===0&&mi()}}function eg(){_o=_c.current,Bn(_c)}function ga(i,c){i.finishedWork=null,i.finishedLanes=0;var m=i.timeoutHandle;if(m!==-1&&(i.timeoutHandle=-1,VA(m)),lr!==null)for(m=lr.return;m!==null;){var k=m;switch(lm(k),k.tag){case 1:k=k.type.childContextTypes,k!=null&&Md();break;case 3:xc(),Bn(io),Bn(Dr),xm();break;case 5:vm(k);break;case 4:xc();break;case 13:Bn(Gn);break;case 19:Bn(Gn);break;case 10:mm(k.type._context);break;case 22:case 23:eg()}m=m.return}if(Er=i,lr=i=Ei(i.current,null),Ir=_o=c,kr=0,Yl=null,Zm=of=pa=0,lo=Xl=null,da!==null){for(c=0;c<da.length;c++)if(m=da[c],k=m.interleaved,k!==null){m.interleaved=null;var b=k.next,_=m.pending;if(_!==null){var O=_.next;_.next=b,k.next=O}m.pending=k}da=null}return i}function sb(i,c){do{var m=lr;try{if(pm(),Zd.current=Xd,Gd){for(var k=Vn.memoizedState;k!==null;){var b=k.queue;b!==null&&(b.pending=null),k=k.next}Gd=!1}if(ha=0,xr=gr=Vn=null,Wl=!1,Kl=0,qm.current=null,m===null||m.return===null){kr=1,Yl=c,lr=null;break}e:{var _=i,O=m.return,X=m,re=c;if(c=Ir,X.flags|=32768,re!==null&&typeof re=="object"&&typeof re.then=="function"){var ke=re,Ae=X,Pe=Ae.tag;if((Ae.mode&1)===0&&(Pe===0||Pe===11||Pe===15)){var je=Ae.alternate;je?(Ae.updateQueue=je.updateQueue,Ae.memoizedState=je.memoizedState,Ae.lanes=je.lanes):(Ae.updateQueue=null,Ae.memoizedState=null)}var tt=C0(O);if(tt!==null){tt.flags&=-257,A0(tt,O,X,_,c),tt.mode&1&&$0(_,ke,c),c=tt,re=ke;var at=c.updateQueue;if(at===null){var lt=new Set;lt.add(re),c.updateQueue=lt}else at.add(re);break e}else{if((c&1)===0){$0(_,ke,c),tg();break e}re=Error(n(426))}}else if(Wn&&X.mode&1){var ir=C0(O);if(ir!==null){(ir.flags&65536)===0&&(ir.flags|=256),A0(ir,O,X,_,c),fm(Ec(re,X));break e}}_=re=Ec(re,X),kr!==4&&(kr=2),Xl===null?Xl=[_]:Xl.push(_),_=O;do{switch(_.tag){case 3:_.flags|=65536,c&=-c,_.lanes|=c;var fe=T0(_,re,c);e0(_,fe);break e;case 1:X=re;var ae=_.type,ge=_.stateNode;if((_.flags&128)===0&&(typeof ae.getDerivedStateFromError=="function"||ge!==null&&typeof ge.componentDidCatch=="function"&&(yi===null||!yi.has(ge)))){_.flags|=65536,c&=-c,_.lanes|=c;var Ue=j0(_,X,c);e0(_,Ue);break e}}_=_.return}while(_!==null)}cb(m)}catch(ft){c=ft,lr===m&&m!==null&&(lr=m=m.return);continue}break}while(!0)}function ib(){var i=rf.current;return rf.current=Xd,i===null?Xd:i}function tg(){(kr===0||kr===3||kr===2)&&(kr=4),Er===null||(pa&268435455)===0&&(of&268435455)===0||xi(Er,Ir)}function df(i,c){var m=gn;gn|=2;var k=ib();(Er!==i||Ir!==c)&&(Ps=null,ga(i,c));do try{vI();break}catch(b){sb(i,b)}while(!0);if(pm(),gn=m,rf.current=k,lr!==null)throw Error(n(261));return Er=null,Ir=0,kr}function vI(){for(;lr!==null;)ab(lr)}function bI(){for(;lr!==null&&!En();)ab(lr)}function ab(i){var c=db(i.alternate,i,_o);i.memoizedProps=i.pendingProps,c===null?cb(i):lr=c,qm.current=null}function cb(i){var c=i;do{var m=c.alternate;if(i=c.return,(c.flags&32768)===0){if(m=hI(m,c,_o),m!==null){lr=m;return}}else{if(m=pI(m,c),m!==null){m.flags&=32767,lr=m;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{kr=6,lr=null;return}}if(c=c.sibling,c!==null){lr=c;return}lr=c=i}while(c!==null);kr===0&&(kr=5)}function ka(i,c,m){var k=Ve,b=Do.transition;try{Do.transition=null,Ve=1,xI(i,c,m,k)}finally{Do.transition=b,Ve=k}return null}function xI(i,c,m,k){do Tc();while(vi!==null);if((gn&6)!==0)throw Error(n(327));m=i.finishedWork;var b=i.finishedLanes;if(m===null)return null;if(i.finishedWork=null,i.finishedLanes=0,m===i.current)throw Error(n(177));i.callbackNode=null,i.callbackPriority=0;var _=m.lanes|m.childLanes;if(me(i,_),i===Er&&(lr=Er=null,Ir=0),(m.subtreeFlags&2064)===0&&(m.flags&2064)===0||af||(af=!0,fb(dn,function(){return Tc(),null})),_=(m.flags&15990)!==0,(m.subtreeFlags&15990)!==0||_){_=Do.transition,Do.transition=null;var O=Ve;Ve=1;var X=gn;gn|=4,qm.current=null,gI(i,m),Q0(m,i),jd(tm),Qa=!!em,tm=em=null,i.current=m,kI(m),Lr(),gn=X,Ve=O,Do.transition=_}else i.current=m;if(af&&(af=!1,vi=i,cf=b),_=i.pendingLanes,_===0&&(yi=null),rn(m.stateNode),uo(i,un()),c!==null)for(k=i.onRecoverableError,m=0;m<c.length;m++)b=c[m],k(b.value,{componentStack:b.stack,digest:b.digest});if(sf)throw sf=!1,i=Vm,Vm=null,i;return(cf&1)!==0&&i.tag!==0&&Tc(),_=i.pendingLanes,(_&1)!==0?i===Ym?Ql++:(Ql=0,Ym=i):Ql=0,mi(),null}function Tc(){if(vi!==null){var i=He(cf),c=Do.transition,m=Ve;try{if(Do.transition=null,Ve=16>i?16:i,vi===null)var k=!1;else{if(i=vi,vi=null,cf=0,(gn&6)!==0)throw Error(n(331));var b=gn;for(gn|=4,st=i.current;st!==null;){var _=st,O=_.child;if((st.flags&16)!==0){var X=_.deletions;if(X!==null){for(var re=0;re<X.length;re++){var ke=X[re];for(st=ke;st!==null;){var Ae=st;switch(Ae.tag){case 0:case 11:case 15:Vl(8,Ae,_)}var Pe=Ae.child;if(Pe!==null)Pe.return=Ae,st=Pe;else for(;st!==null;){Ae=st;var je=Ae.sibling,tt=Ae.return;if(Z0(Ae),Ae===ke){st=null;break}if(je!==null){je.return=tt,st=je;break}st=tt}}}var at=_.alternate;if(at!==null){var lt=at.child;if(lt!==null){at.child=null;do{var ir=lt.sibling;lt.sibling=null,lt=ir}while(lt!==null)}}st=_}}if((_.subtreeFlags&2064)!==0&&O!==null)O.return=_,st=O;else e:for(;st!==null;){if(_=st,(_.flags&2048)!==0)switch(_.tag){case 0:case 11:case 15:Vl(9,_,_.return)}var fe=_.sibling;if(fe!==null){fe.return=_.return,st=fe;break e}st=_.return}}var ae=i.current;for(st=ae;st!==null;){O=st;var ge=O.child;if((O.subtreeFlags&2064)!==0&&ge!==null)ge.return=O,st=ge;else e:for(O=ae;st!==null;){if(X=st,(X.flags&2048)!==0)try{switch(X.tag){case 0:case 11:case 15:nf(9,X)}}catch(ft){nr(X,X.return,ft)}if(X===O){st=null;break e}var Ue=X.sibling;if(Ue!==null){Ue.return=X.return,st=Ue;break e}st=X.return}}if(gn=b,mi(),yt&&typeof yt.onPostCommitFiberRoot=="function")try{yt.onPostCommitFiberRoot(At,i)}catch{}k=!0}return k}finally{Ve=m,Do.transition=c}}return!1}function lb(i,c,m){c=Ec(m,c),c=T0(i,c,1),i=ki(i,c,1),c=Qr(),i!==null&&(G(i,1,c),uo(i,c))}function nr(i,c,m){if(i.tag===3)lb(i,i,m);else for(;c!==null;){if(c.tag===3){lb(c,i,m);break}else if(c.tag===1){var k=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof k.componentDidCatch=="function"&&(yi===null||!yi.has(k))){i=Ec(m,i),i=j0(c,i,1),c=ki(c,i,1),i=Qr(),c!==null&&(G(c,1,i),uo(c,i));break}}c=c.return}}function EI(i,c,m){var k=i.pingCache;k!==null&&k.delete(c),c=Qr(),i.pingedLanes|=i.suspendedLanes&m,Er===i&&(Ir&m)===m&&(kr===4||kr===3&&(Ir&130023424)===Ir&&500>un()-Gm?ga(i,0):Zm|=m),uo(i,c)}function ub(i,c){c===0&&((i.mode&1)===0?c=1:(c=zn,zn<<=1,(zn&130023424)===0&&(zn=4194304)));var m=Qr();i=Os(i,c),i!==null&&(G(i,c,m),uo(i,m))}function SI(i){var c=i.memoizedState,m=0;c!==null&&(m=c.retryLane),ub(i,m)}function _I(i,c){var m=0;switch(i.tag){case 13:var k=i.stateNode,b=i.memoizedState;b!==null&&(m=b.retryLane);break;case 19:k=i.stateNode;break;default:throw Error(n(314))}k!==null&&k.delete(c),ub(i,m)}var db;db=function(i,c,m){if(i!==null)if(i.memoizedProps!==c.pendingProps||io.current)co=!0;else{if((i.lanes&m)===0&&(c.flags&128)===0)return co=!1,fI(i,c,m);co=(i.flags&131072)!==0}else co=!1,Wn&&(c.flags&1048576)!==0&&Wv(c,zd,c.index);switch(c.lanes=0,c.tag){case 2:var k=c.type;ef(i,c),i=c.pendingProps;var b=mc(c,Dr.current);bc(c,m),b=_m(null,c,k,i,b,m);var _=Nm();return c.flags|=1,typeof b=="object"&&b!==null&&typeof b.render=="function"&&b.$$typeof===void 0?(c.tag=1,c.memoizedState=null,c.updateQueue=null,ao(k)?(_=!0,Ld(c)):_=!1,c.memoizedState=b.state!==null&&b.state!==void 0?b.state:null,wm(c),b.updater=Qd,c.stateNode=b,b._reactInternals=c,Im(c,k,i,m),c=Lm(null,c,k,!0,_,m)):(c.tag=0,Wn&&_&&cm(c),Xr(null,c,b,m),c=c.child),c;case 16:k=c.elementType;e:{switch(ef(i,c),i=c.pendingProps,b=k._init,k=b(k._payload),c.type=k,b=c.tag=TI(k),i=Vo(k,i),b){case 0:c=Mm(null,c,k,i,m);break e;case 1:c=P0(null,c,k,i,m);break e;case 11:c=I0(null,c,k,i,m);break e;case 14:c=R0(null,c,k,Vo(k.type,i),m);break e}throw Error(n(306,k,""))}return c;case 0:return k=c.type,b=c.pendingProps,b=c.elementType===k?b:Vo(k,b),Mm(i,c,k,b,m);case 1:return k=c.type,b=c.pendingProps,b=c.elementType===k?b:Vo(k,b),P0(i,c,k,b,m);case 3:e:{if(D0(c),i===null)throw Error(n(387));k=c.pendingProps,_=c.memoizedState,b=_.element,Jv(i,c),Kd(c,k,null,m);var O=c.memoizedState;if(k=O.element,_.isDehydrated)if(_={element:k,isDehydrated:!1,cache:O.cache,pendingSuspenseBoundaries:O.pendingSuspenseBoundaries,transitions:O.transitions},c.updateQueue.baseState=_,c.memoizedState=_,c.flags&256){b=Ec(Error(n(423)),c),c=z0(i,c,k,m,b);break e}else if(k!==b){b=Ec(Error(n(424)),c),c=z0(i,c,k,m,b);break e}else for(So=fi(c.stateNode.containerInfo.firstChild),Eo=c,Wn=!0,Go=null,m=Xv(c,null,k,m),c.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling;else{if(wc(),k===b){c=Ls(i,c,m);break e}Xr(i,c,k,m)}c=c.child}return c;case 5:return n0(c),i===null&&dm(c),k=c.type,b=c.pendingProps,_=i!==null?i.memoizedProps:null,O=b.children,nm(k,b)?O=null:_!==null&&nm(k,_)&&(c.flags|=32),L0(i,c),Xr(i,c,O,m),c.child;case 6:return i===null&&dm(c),null;case 13:return F0(i,c,m);case 4:return ym(c,c.stateNode.containerInfo),k=c.pendingProps,i===null?c.child=yc(c,null,k,m):Xr(i,c,k,m),c.child;case 11:return k=c.type,b=c.pendingProps,b=c.elementType===k?b:Vo(k,b),I0(i,c,k,b,m);case 7:return Xr(i,c,c.pendingProps,m),c.child;case 8:return Xr(i,c,c.pendingProps.children,m),c.child;case 12:return Xr(i,c,c.pendingProps.children,m),c.child;case 10:e:{if(k=c.type._context,b=c.pendingProps,_=c.memoizedProps,O=b.value,Ln(Ud,k._currentValue),k._currentValue=O,_!==null)if(Yr(_.value,O)){if(_.children===b.children&&!io.current){c=Ls(i,c,m);break e}}else for(_=c.child,_!==null&&(_.return=c);_!==null;){var X=_.dependencies;if(X!==null){O=_.child;for(var re=X.firstContext;re!==null;){if(re.context===k){if(_.tag===1){re=Ms(-1,m&-m),re.tag=2;var ke=_.updateQueue;if(ke!==null){ke=ke.shared;var Ae=ke.pending;Ae===null?re.next=re:(re.next=Ae.next,Ae.next=re),ke.pending=re}}_.lanes|=m,re=_.alternate,re!==null&&(re.lanes|=m),gm(_.return,m,c),X.lanes|=m;break}re=re.next}}else if(_.tag===10)O=_.type===c.type?null:_.child;else if(_.tag===18){if(O=_.return,O===null)throw Error(n(341));O.lanes|=m,X=O.alternate,X!==null&&(X.lanes|=m),gm(O,m,c),O=_.sibling}else O=_.child;if(O!==null)O.return=_;else for(O=_;O!==null;){if(O===c){O=null;break}if(_=O.sibling,_!==null){_.return=O.return,O=_;break}O=O.return}_=O}Xr(i,c,b.children,m),c=c.child}return c;case 9:return b=c.type,k=c.pendingProps.children,bc(c,m),b=Lo(b),k=k(b),c.flags|=1,Xr(i,c,k,m),c.child;case 14:return k=c.type,b=Vo(k,c.pendingProps),b=Vo(k.type,b),R0(i,c,k,b,m);case 15:return O0(i,c,c.type,c.pendingProps,m);case 17:return k=c.type,b=c.pendingProps,b=c.elementType===k?b:Vo(k,b),ef(i,c),c.tag=1,ao(k)?(i=!0,Ld(c)):i=!1,bc(c,m),_0(c,k,b),Im(c,k,b,m),Lm(null,c,k,!0,i,m);case 19:return U0(i,c,m);case 22:return M0(i,c,m)}throw Error(n(156,c.tag))};function fb(i,c){return pt(i,c)}function NI(i,c,m,k){this.tag=i,this.key=m,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=c,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=k,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function zo(i,c,m,k){return new NI(i,c,m,k)}function ng(i){return i=i.prototype,!(!i||!i.isReactComponent)}function TI(i){if(typeof i=="function")return ng(i)?1:0;if(i!=null){if(i=i.$$typeof,i===q)return 11;if(i===V)return 14}return 2}function Ei(i,c){var m=i.alternate;return m===null?(m=zo(i.tag,c,i.key,i.mode),m.elementType=i.elementType,m.type=i.type,m.stateNode=i.stateNode,m.alternate=i,i.alternate=m):(m.pendingProps=c,m.type=i.type,m.flags=0,m.subtreeFlags=0,m.deletions=null),m.flags=i.flags&14680064,m.childLanes=i.childLanes,m.lanes=i.lanes,m.child=i.child,m.memoizedProps=i.memoizedProps,m.memoizedState=i.memoizedState,m.updateQueue=i.updateQueue,c=i.dependencies,m.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext},m.sibling=i.sibling,m.index=i.index,m.ref=i.ref,m}function ff(i,c,m,k,b,_){var O=2;if(k=i,typeof i=="function")ng(i)&&(O=1);else if(typeof i=="string")O=5;else e:switch(i){case A:return wa(m.children,b,_,c);case I:O=8,b|=8;break;case M:return i=zo(12,m,c,b|2),i.elementType=M,i.lanes=_,i;case W:return i=zo(13,m,c,b),i.elementType=W,i.lanes=_,i;case ee:return i=zo(19,m,c,b),i.elementType=ee,i.lanes=_,i;case K:return hf(m,b,_,c);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case P:O=10;break e;case F:O=9;break e;case q:O=11;break e;case V:O=14;break e;case te:O=16,k=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return c=zo(O,m,c,b),c.elementType=i,c.type=k,c.lanes=_,c}function wa(i,c,m,k){return i=zo(7,i,k,c),i.lanes=m,i}function hf(i,c,m,k){return i=zo(22,i,k,c),i.elementType=K,i.lanes=m,i.stateNode={isHidden:!1},i}function rg(i,c,m){return i=zo(6,i,null,c),i.lanes=m,i}function og(i,c,m){return c=zo(4,i.children!==null?i.children:[],i.key,c),c.lanes=m,c.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},c}function jI(i,c,m,k,b){this.tag=c,this.containerInfo=i,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=$r(0),this.expirationTimes=$r(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=$r(0),this.identifierPrefix=k,this.onRecoverableError=b,this.mutableSourceEagerHydrationData=null}function sg(i,c,m,k,b,_,O,X,re){return i=new jI(i,c,m,X,re),c===1?(c=1,_===!0&&(c|=8)):c=0,_=zo(3,null,null,c),i.current=_,_.stateNode=i,_.memoizedState={element:k,isDehydrated:m,cache:null,transitions:null,pendingSuspenseBoundaries:null},wm(_),i}function $I(i,c,m){var k=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:R,key:k==null?null:""+k,children:i,containerInfo:c,implementation:m}}function hb(i){if(!i)return pi;i=i._reactInternals;e:{if(mn(i)!==i||i.tag!==1)throw Error(n(170));var c=i;do{switch(c.tag){case 3:c=c.stateNode.context;break e;case 1:if(ao(c.type)){c=c.stateNode.__reactInternalMemoizedMergedChildContext;break e}}c=c.return}while(c!==null);throw Error(n(171))}if(i.tag===1){var m=i.type;if(ao(m))return Bv(i,m,c)}return c}function pb(i,c,m,k,b,_,O,X,re){return i=sg(m,k,!0,i,b,_,O,X,re),i.context=hb(null),m=i.current,k=Qr(),b=bi(m),_=Ms(k,b),_.callback=c??null,ki(m,_,b),i.current.lanes=b,G(i,b,k),uo(i,k),i}function pf(i,c,m,k){var b=c.current,_=Qr(),O=bi(b);return m=hb(m),c.context===null?c.context=m:c.pendingContext=m,c=Ms(_,O),c.payload={element:i},k=k===void 0?null:k,k!==null&&(c.callback=k),i=ki(b,c,O),i!==null&&(Qo(i,b,O,_),Wd(i,b,O)),O}function mf(i){if(i=i.current,!i.child)return null;switch(i.child.tag){case 5:return i.child.stateNode;default:return i.child.stateNode}}function mb(i,c){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var m=i.retryLane;i.retryLane=m!==0&&m<c?m:c}}function ig(i,c){mb(i,c),(i=i.alternate)&&mb(i,c)}function CI(){return null}var gb=typeof reportError=="function"?reportError:function(i){console.error(i)};function ag(i){this._internalRoot=i}gf.prototype.render=ag.prototype.render=function(i){var c=this._internalRoot;if(c===null)throw Error(n(409));pf(i,c,null,null)},gf.prototype.unmount=ag.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var c=i.containerInfo;ma(function(){pf(null,i,null,null)}),c[Cs]=null}};function gf(i){this._internalRoot=i}gf.prototype.unstable_scheduleHydration=function(i){if(i){var c=sr();i={blockedOn:null,target:i,priority:c};for(var m=0;m<$t.length&&c!==0&&c<$t[m].priority;m++);$t.splice(m,0,i),m===0&&Hn(i)}};function cg(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function kf(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function kb(){}function AI(i,c,m,k,b){if(b){if(typeof k=="function"){var _=k;k=function(){var ke=mf(O);_.call(ke)}}var O=pb(c,k,i,0,null,!1,!1,"",kb);return i._reactRootContainer=O,i[Cs]=O.current,Ll(i.nodeType===8?i.parentNode:i),ma(),O}for(;b=i.lastChild;)i.removeChild(b);if(typeof k=="function"){var X=k;k=function(){var ke=mf(re);X.call(ke)}}var re=sg(i,0,!1,null,null,!1,!1,"",kb);return i._reactRootContainer=re,i[Cs]=re.current,Ll(i.nodeType===8?i.parentNode:i),ma(function(){pf(c,re,m,k)}),re}function wf(i,c,m,k,b){var _=m._reactRootContainer;if(_){var O=_;if(typeof b=="function"){var X=b;b=function(){var re=mf(O);X.call(re)}}pf(c,O,i,b)}else O=AI(m,c,i,b,k);return mf(O)}bn=function(i){switch(i.tag){case 3:var c=i.stateNode;if(c.current.memoizedState.isDehydrated){var m=or(c.pendingLanes);m!==0&&(Je(c,m|1),uo(c,un()),(gn&6)===0&&(Nc=un()+500,mi()))}break;case 13:ma(function(){var k=Os(i,1);if(k!==null){var b=Qr();Qo(k,i,1,b)}}),ig(i,1)}},an=function(i){if(i.tag===13){var c=Os(i,134217728);if(c!==null){var m=Qr();Qo(c,i,134217728,m)}ig(i,134217728)}},cn=function(i){if(i.tag===13){var c=bi(i),m=Os(i,c);if(m!==null){var k=Qr();Qo(m,i,c,k)}ig(i,c)}},sr=function(){return Ve},mr=function(i,c){var m=Ve;try{return Ve=i,c()}finally{Ve=m}},Ye=function(i,c,m){switch(c){case"input":if(Ze(i,m),c=m.name,m.type==="radio"&&c!=null){for(m=i;m.parentNode;)m=m.parentNode;for(m=m.querySelectorAll("input[name="+JSON.stringify(""+c)+'][type="radio"]'),c=0;c<m.length;c++){var k=m[c];if(k!==i&&k.form===i.form){var b=Od(k);if(!b)throw Error(n(90));ie(k),Ze(k,b)}}}break;case"textarea":Ot(i,m);break;case"select":c=m.value,c!=null&&Et(i,!!m.multiple,c,!1)}},Se=Jm,ze=ma;var II={usingClientEntryPoint:!1,Events:[zl,hc,Od,D,se,Jm]},Jl={findFiberByHostInstance:aa,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},RI={bundleType:Jl.bundleType,version:Jl.version,rendererPackageName:Jl.rendererPackageName,rendererConfig:Jl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:j.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=qe(i),i===null?null:i.stateNode},findFiberByHostInstance:Jl.findFiberByHostInstance||CI,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var yf=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!yf.isDisabled&&yf.supportsFiber)try{At=yf.inject(RI),yt=yf}catch{}}return fo.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=II,fo.createPortal=function(i,c){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!cg(c))throw Error(n(200));return $I(i,c,null,m)},fo.createRoot=function(i,c){if(!cg(i))throw Error(n(299));var m=!1,k="",b=gb;return c!=null&&(c.unstable_strictMode===!0&&(m=!0),c.identifierPrefix!==void 0&&(k=c.identifierPrefix),c.onRecoverableError!==void 0&&(b=c.onRecoverableError)),c=sg(i,1,!1,null,null,m,!1,k,b),i[Cs]=c.current,Ll(i.nodeType===8?i.parentNode:i),new ag(c)},fo.findDOMNode=function(i){if(i==null)return null;if(i.nodeType===1)return i;var c=i._reactInternals;if(c===void 0)throw typeof i.render=="function"?Error(n(188)):(i=Object.keys(i).join(","),Error(n(268,i)));return i=qe(c),i=i===null?null:i.stateNode,i},fo.flushSync=function(i){return ma(i)},fo.hydrate=function(i,c,m){if(!kf(c))throw Error(n(200));return wf(null,i,c,!0,m)},fo.hydrateRoot=function(i,c,m){if(!cg(i))throw Error(n(405));var k=m!=null&&m.hydratedSources||null,b=!1,_="",O=gb;if(m!=null&&(m.unstable_strictMode===!0&&(b=!0),m.identifierPrefix!==void 0&&(_=m.identifierPrefix),m.onRecoverableError!==void 0&&(O=m.onRecoverableError)),c=pb(c,null,i,1,m??null,b,!1,_,O),i[Cs]=c.current,Ll(i),k)for(i=0;i<k.length;i++)m=k[i],b=m._getVersion,b=b(m._source),c.mutableSourceEagerHydrationData==null?c.mutableSourceEagerHydrationData=[m,b]:c.mutableSourceEagerHydrationData.push(m,b);return new gf(c)},fo.render=function(i,c,m){if(!kf(c))throw Error(n(200));return wf(null,i,c,!1,m)},fo.unmountComponentAtNode=function(i){if(!kf(i))throw Error(n(40));return i._reactRootContainer?(ma(function(){wf(null,null,i,!1,function(){i._reactRootContainer=null,i[Cs]=null})}),!0):!1},fo.unstable_batchedUpdates=Jm,fo.unstable_renderSubtreeIntoContainer=function(i,c,m,k){if(!kf(m))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return wf(i,c,m,!1,k)},fo.version="18.3.1-next-f1338f8080-20240426",fo}var _b;function RS(){if(_b)return dg.exports;_b=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),dg.exports=HI(),dg.exports}var OS=RS(),vf={},Nb;function WI(){if(Nb)return vf;Nb=1;var e=RS();return vf.createRoot=e.createRoot,vf.hydrateRoot=e.hydrateRoot,vf}var KI=WI();const Pi="shell",MS="check",Pa="ToolSearch",Tw="AskUserQuestion",jw="handoff",LS="worktrees",PS="own";function bf(e){const t=[];for(const n of e){const r=t.at(-1),{event:o}=n;o.type==="text-delta"&&(r==null?void 0:r.event.type)==="text-delta"&&r.event.messageId===o.messageId?t[t.length-1]={seq:r.seq,event:{...r.event,text:r.event.text+o.text}}:o.type==="thinking-delta"&&(r==null?void 0:r.event.type)==="thinking-delta"?t[t.length-1]={seq:r.seq,event:{type:"thinking-delta",text:r.event.text+o.text}}:o.type==="tool-delta"&&(r==null?void 0:r.event.type)==="tool-delta"&&r.event.toolId===o.toolId?t[t.length-1]={seq:r.seq,event:{...o,text:r.event.text+o.text}}:t.push(n)}return t}const qI=new Set(["edit","delete","move","execute"]),ZI=new Set(["Edit","Write","MultiEdit","NotebookEdit","Bash"]);function DS(e){return e.kind?qI.has(e.kind):ZI.has(e.name)}const GI=["read","edit","delete","move","search","execute","fetch"];function $w(e){return GI.includes(e??"")}function zS(e,t){return($w(e.kind)||e.name===Tw||e.name===Pa)&&Bh(t)}const VI=/^(?:mcp__(.+?)__(.+)|([A-Za-z0-9_-]+)\/([A-Za-z0-9_-]+))$/;function YI(e){const t=VI.exec(e);if(!t)return null;const n=t[1]??t[3]??"",r=t[2]??t[4]??"";return{server:n,tool:r.replace(/[_-]+/g," ").trim()}}function Bh(e){if(!e||typeof e!="object")return!0;const t=e;return Object.keys(t).every(n=>n==="locations"&&Array.isArray(t[n])&&t[n].length===0)}const Uh=[{id:"auto",name:"auto",description:"edits and sandboxed commands run; a plan still asks"},{id:"ask",name:"ask",description:"every edit and command is a card before it runs"},{id:"plan",name:"plan",description:"read and propose only; approving the plan starts the work"}],ok="auto";function XI(e){return e.branch.startsWith("toyon/")}function QI(e){return e.unread===!0||e.lastTurn!=null&&(e.seenAt==null||e.seenAt<e.lastTurn.at)}const Hh=e=>e==="running"||e==="starting"||e==="preparing"||e==="cold",Bo="shell",Ks="login";function JI(e,t){return`${e}/${t}`}function eR(e,t,n,r=0){var s;let o=e;for(let a=r;a>0;a--){let l=o.length-1;for(;l>=0&&((s=o[l])==null?void 0:s.proc)!==t;)l--;if(l<0)break;o=o===e?[...o]:o,o.splice(l,1)}return n?[...o,{proc:t,line:n}]:o}const is=e=>e==="working"||e==="waiting",tR=["use","always","off"];function FS(e){return e.find(t=>t.id==="default")}function nR(e,t){const n=FS(e);if(n){if(t!==void 0&&t!==n.id){const r=e.find(o=>o.id===t);if(r)return r}if(n.description)return e.find(r=>r!==n&&r.name===n.description)}}function rR(e,t){if(t.some(o=>o.id===e))return e;const n=Tb(e);if(n===void 0)return;if(t.some(o=>o.id===n))return n;if(n!==Cw(e))return;let r;for(const o of t){if(Tb(o.id)!==n)continue;const s=oR(o.id);s!==void 0&&(r===void 0||s>r.version)&&(r={id:o.id,version:s})}return r==null?void 0:r.id}const BS=/(?:^|[./])claude-(?:(\d{1,2})(?:-(\d{1,2})(?!\d))?-)?([a-z]+)(?:-(\d{1,2})(?!\d)(?:-(\d{1,2})(?!\d))?)?/;function Cw(e){return e.replace(/\[[^\]]*\]$/,"")}function Tb(e){var r;const t=Cw(e),n=(r=t.match(BS))==null?void 0:r[3];return n||(/^[a-z]+$/.test(t)?t:void 0)}function oR(e){const t=Cw(e).match(BS);if(!t)return;const n=t[1]??t[4];if(n===void 0)return;const r=t[1]!==void 0?t[2]:t[5];return Number(n)+Number(r??0)/100}function Tn(e){return e.worktree!==void 0}function Di(e){return e.kind==="main"}function Wh(e){return e.kind==="spare"}function Tr(e){return Wh(e)||Di(e)}function Kh(e){return e.kind==="worktree"}function US(e){return e.kind==="worktree"&&XI(e)}function Na(e){var t;return e.kind==="worktree"&&((t=e.from)==null?void 0:t.kind)!=="pr"}function Kf(e){return e.kind==="worktree"}function qh(e){return!!e.branch&&!e.locked&&!(e.worktree&&Tr(e.worktree))}const Da=e=>{var t;return e.promptedAt??((t=e.lastTurn)==null?void 0:t.at)??e.createdAt},jb=e=>Tr(e)?0:1;function sR(e){return[...e].sort((t,n)=>jb(t.worktree)-jb(n.worktree)||Da(n.worktree)-Da(t.worktree))}function $b(e,t){const n=new Map;for(const r of e)n.set(r.id,r.promptedAt??0);for(const r of t){if(!Tn(r)||r.worktree.kind==="spare")continue;const o=r.worktree.repoId;n.set(o,Math.max(n.get(o)??0,Da(r.worktree)))}return[...e].sort((r,o)=>(n.get(o.id)??0)-(n.get(r.id)??0))}function iR(e,t){var o,s;const n=t.counts(e.id);if(n.dirty===void 0||n.ahead===void 0)return"its changes are not counted yet";if(n.dirty>0)return"it has uncommitted changes";if(n.ahead>0)return"it has commits not on main";if(t.drafted(e.id))return"unsent text waits in its composer";if(t.pending(e.id))return"its agent is still busy";if(e.landed)return null;const r=(o=e.lastTurn)==null?void 0:o.end;return r?r==="stopped"?"its last turn was stopped":r==="failed"?"its last turn failed":r==="asking"?"its agent is waiting on an answer":QI(e)?"its last reply is unread":e.planned?"it showed a plan":((s=e.pr)==null?void 0:s.state)==="open"?"its pull request is still open":null:"its agent has not run yet"}const Cb="not opened in ";function aR(e){const t=e.lastIndexOf(Cb);return t<0?{what:e}:{what:e.slice(0,t).replace(/,\s*$/,""),idle:e.slice(t+Cb.length)}}const HS={image:6,paste:4,file:8,pick:8},cR={image:"image",paste:"paste",file:"file",pick:"element"},lR={image:"Image",paste:"Pasted text"},WS=(e,t)=>`${lR[e]} ${t}`,Aw=e=>`at most ${HS[e]} ${cR[e]}s per message`,uR=(e,t)=>e.filter(n=>n.kind===t).length,dR=(e,t)=>Math.max(0,HS[t]-uR(e,t));function sk(e){const t={image:1,paste:1,file:1,pick:1};for(const n of e)for(const r of n??[])t[r.kind]=Math.max(t[r.kind],r.n+1);return t}function Iw(e,t){const n={...t};return e.map(r=>[r,n[r.kind]++])}function wu(e,t){const n={...e};for(const r of t)n[r.kind]++;return n}function Rw(e){return e>=1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}const Hc=e=>`card:${e}`,qf=[{id:"quick-open",key:"p"},{id:"commands",key:"p",shift:!0,bareAlias:"F1"},{id:"search",key:"f",shift:!0},{id:"chats",key:"g"},{id:"changes",key:"b",ctrlAlias:{key:"g",shift:!0}},{id:"files",key:"e",shift:!0},{id:"panel-tab-prev",key:"ArrowLeft",alt:!0,textKeeps:!0,emptyGives:!0},{id:"panel-tab-next",key:"ArrowRight",alt:!0,textKeeps:!0,emptyGives:!0},{id:"composer",key:"l"},{id:"rail",key:"k",shift:!0},{id:"keys",key:","},{id:"terminal",key:"j",ctrlAlias:{key:"`"}},{id:"design",key:"d"},{id:"term-tab",key:"`",ctrl:!0,shift:!0},{id:"pick",key:"e"},{id:"inspect",key:"i"},{id:"zen",key:"."},{id:"new",key:"k",aliases:["n"]},{id:"worktree",key:"1-9"},{id:"wt-prev",key:"ArrowUp",alt:!0,ctrlAlias:{key:"Tab",shift:!0},cmdShiftAlias:["[","{"]},{id:"wt-next",key:"ArrowDown",alt:!0,ctrlAlias:{key:"Tab"},cmdShiftAlias:["]","}"]},{id:"wt-unseen-prev",key:"ArrowUp",alt:!0,shift:!0},{id:"wt-unseen-next",key:"ArrowDown",alt:!0,shift:!0},{id:"wt-back",key:"ArrowLeft",textKeeps:!0,emptyGives:!0},{id:"wt-forward",key:"ArrowRight",textKeeps:!0,emptyGives:!0},{id:"wt-archive",key:"Backspace",alt:!0,textKeeps:!0,emptyGives:!0},{id:"mark-unread",key:"u",alt:!0,textKeeps:!0},{id:"project",key:"o",ctrlAlias:{key:"r",hostOnly:!0},cmdShiftAlias:["o"]},{id:"refs",key:"g",shift:!0},{id:"routes",key:"u"},{id:"reload",key:"r"},{id:"back",key:"["},{id:"forward",key:"]"},{id:"close",key:"w"}],fR=new Set(["zen","close","back","forward","wt-back","wt-forward"]),hR={"wt-back":"back","wt-forward":"forward"};function pR(e){if(!e||e.id==="worktree")return e;const t=hR[e.id];return t?{id:t}:e}function KS(e,{guest:t=!1}={}){var r,o;if(e.altKey){if(e.metaKey||e.ctrlKey)return null;const s=qf.find(a=>a.alt&&!!a.shift===e.shiftKey&&(a.key===e.key||a.key.length===1&&e.code===`Key${a.key.toUpperCase()}`));return s&&s.id!=="worktree"?{id:s.id}:null}if(!e.metaKey&&!e.ctrlKey){if(e.shiftKey||t)return null;const s=qf.find(a=>a.bareAlias===e.key);return s&&s.id!=="worktree"?{id:s.id}:null}if(!!e.ctrlKey===e.metaKey)return null;const n=e.key.length===1?e.key.toLowerCase():e.key;if(e.metaKey&&!e.shiftKey&&n>="1"&&n<="9")return{id:"worktree",digit:Number(n)};for(const s of qf){if(s.id==="worktree")continue;const a=s.ctrlAlias;if(a&&e.ctrlKey&&a.key===n&&!!a.shift===e.shiftKey&&!(t&&a.hostOnly))return{id:s.id};if(e.metaKey&&e.shiftKey&&((r=s.cmdShiftAlias)!=null&&r.includes(n)))return{id:s.id};if(!s.alt&&!(e.ctrlKey&&!s.ctrl||!!s.shift!==e.shiftKey)&&(s.key===n||(o=s.aliases)!=null&&o.includes(n)))return{id:s.id}}return null}function mR(e){return e.altKey||e.key.toLowerCase()!=="s"?!1:!!e.ctrlKey!==e.metaKey}function qS(e){const t=qf.find(n=>n.id===e);if(!t)throw new Error(`unknown chord ${e}`);return t}function gR(e,t){return e===t-1?"⌘9":e<8?`⌘${e+1}`:void 0}function kR(e,t){return t===0?null:e===9?t-1:e-1<t?e-1:null}function wR(e){const t=e;return t!=null&&t.tagName?t.isContentEditable||t.tagName==="TEXTAREA"?!0:t.tagName==="INPUT"&&!["button","checkbox","radio","range","submit","reset"].includes(t.type??""):!1}function yR(e){var n;const t=e;return(t==null?void 0:t.tagName)!=="TEXTAREA"&&(t==null?void 0:t.tagName)!=="INPUT"?!1:t.value===""&&!((n=t.closest)!=null&&n.call(t,".monaco-editor, .xterm"))}function vR(e,t){const n=qS(e);return!!n.textKeeps&&wR(t)&&!(n.emptyGives&&yR(t))}const bR=["Find","Preview","Panels","Worktrees"],yu={"quick-open":{label:"jump to file",section:"Find"},commands:{label:"command palette",section:"Find",advertise:{key:"F1",when:"firefox"}},search:{label:"search in files",section:"Find"},chats:{label:"search in chats",section:"Find"},pick:{label:"element to chat",section:"Preview"},inspect:{label:"element to code",section:"Preview"},zen:{label:"full-bleed preview",section:"Preview"},routes:{label:"go to page",section:"Preview"},reload:{label:"reload the preview",section:"Preview"},back:{label:"back in the preview",section:"Preview",hidden:!0},forward:{label:"forward in the preview",section:"Preview",hidden:!0},composer:{label:"chat panel, with the editor's selection",section:"Panels"},changes:{label:"changes panel",section:"Panels"},files:{label:"files panel",section:"Panels"},terminal:{label:"terminal",section:"Panels"},rail:{label:"worktree panel",section:"Panels"},"panel-tab-next":{label:"next panel tab",section:"Panels"},"panel-tab-prev":{label:"previous panel tab",section:"Panels",hidden:!0},"term-tab":{label:"next terminal tab",section:"Panels"},design:{label:"design system",section:"Panels"},keys:{label:"settings & shortcuts",section:"Panels"},close:{label:"close the pane",section:"Panels",hidden:!0},new:{label:"new worktree",section:"Worktrees",advertise:{key:"n",when:"pwa"}},worktree:{label:"switch worktree",section:"Worktrees"},"wt-prev":{label:"previous worktree",section:"Worktrees",advertise:{key:"Tab",when:"pwa"}},"wt-next":{label:"next worktree",section:"Worktrees",advertise:{key:"Tab",when:"pwa"}},"wt-back":{label:"back to the last worktree viewed",section:"Worktrees"},"wt-forward":{label:"forward through viewed worktrees",section:"Worktrees",hidden:!0},"wt-unseen-prev":{label:"previous worktree worth a look",section:"Worktrees",hidden:!0},"wt-unseen-next":{label:"next worktree worth a look",section:"Worktrees"},"wt-archive":{label:"archive worktree",section:"Worktrees"},"mark-unread":{label:"mark worktree unread",section:"Worktrees"},project:{label:"open project",section:"Worktrees"},refs:{label:"open a branch or PR",section:"Worktrees"}},xR={ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Backspace:"⌫",Tab:"Tab"};function ER(e,t={}){var l;const n=qS(e),r=yu[e],o=r.advertise&&t[r.advertise.when]?r.advertise.key:n.key;if(o===n.bareAlias)return o;const s=o==="1-9"?"1-9":xR[o]??o.toUpperCase(),a=o!==n.key&&o===((l=n.ctrlAlias)==null?void 0:l.key)?n.ctrlAlias:void 0;return a?`⌃${a.shift?"⇧":""}${s}`:`${n.alt?"⌥":n.ctrl?"⌃":"⌘"}${n.shift?"⇧":""}${s}`}function SR(e){return Object.keys(yu).filter(t=>yu[t].section===e&&!yu[t].hidden)}const Ab={m:6e4,h:60*6e4};function _R(e){const[t,n]=NR(e);return`${t}${n.charAt(0)}`}function NR(e){const t=e/Ab.h;if(t>=1&&Number.isInteger(t))return[t,"hour"];const n=e/Ab.m;return n>=1&&Number.isInteger(n)?[n,"minute"]:n>=60?[Math.round(n),"minute"]:[Math.max(1,Math.round(e/1e3)),"second"]}const Tu={folder:{shared:".toyon/settings.json",local:".toyon/settings.local.json"},root:{shared:"toyon.json",local:"toyon.local.json"}};function ZS(e){return typeof e=="string"?e:e.cmd}function TR(e){return typeof e=="string"?[]:e.setup??[]}function jR(e){return typeof e=="string"?[]:e.teardown??[]}function GS(e){return typeof e=="string"?{}:e.remotes??{}}function VS(e){return e&&"remote"in e?e.remote:void 0}function Zh(e){return e&&"by"in e?e:void 0}function $R(e){return[...e.setup??[],...e.teardown??[],...Object.values(e.run).flatMap(n=>[ZS(n),...TR(n),...jR(n)])].some(n=>n.includes("TOYON_WORKTREE"))}function CR(e){return e===Tu.folder.local||e===Tu.root.local}function AR(e){return CR(e)?"local":"shared"}function IR(e,t){return(Object.values(Tu).find(r=>r.shared===e||r.local===e)??Tu.folder)[t]}const RR=e=>`https://${e}/`;function OR(e){let t=e.trim();if(t==="")return null;/^[a-z]+:\/\//i.test(t)||(t=`https://${t}`);let n;try{n=new URL(t)}catch{return null}return LR(n.origin)?n.origin:null}function MR(e){return e.toLowerCase().endsWith(".fly.dev")}function LR(e){let t;try{t=new URL(e)}catch{return!1}return t.origin!==e?!1:t.protocol==="https:"||t.protocol==="http:"&&Gh(t.hostname)}const PR="toyon_grant";function Gh(e){return e==="127.0.0.1"||e==="::1"||e==="[::1]"||e==="localhost"||e.endsWith(".localhost")}function DR(e,t,n){return e.replace("{id}",t).replace("{port}",String(n))}const zR=4401,FR=25e4;function BR(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;let r=0;for(;r<e.length-n&&r<t.length-n&&e[e.length-1-r]===t[t.length-1-r];)r++;const o=e.slice(0,n).map(s=>({mark:" ",value:s}));return o.push(...UR(e.slice(n,e.length-r),t.slice(n,t.length-r))),o.push(...e.slice(e.length-r).map(s=>({mark:" ",value:s}))),o}function UR(e,t){if(e.length===0)return t.map(l=>({mark:"+",value:l}));if(t.length===0)return e.map(l=>({mark:"-",value:l}));if((e.length+1)*(t.length+1)>FR)return[...e.map(l=>({mark:"-",value:l})),...t.map(l=>({mark:"+",value:l}))];const n=t.length+1,r=new Uint32Array((e.length+1)*n);for(let l=e.length-1;l>=0;l--)for(let u=t.length-1;u>=0;u--)r[l*n+u]=e[l]===t[u]?(r[(l+1)*n+u+1]??0)+1:Math.max(r[(l+1)*n+u]??0,r[l*n+u+1]??0);const o=[];let s=0,a=0;for(;s<e.length&&a<t.length;)e[s]===t[a]?(o.push({mark:" ",value:e[s]}),s++,a++):(r[(s+1)*n+a]??0)>=(r[s*n+a+1]??0)?(o.push({mark:"-",value:e[s]}),s++):(o.push({mark:"+",value:t[a]}),a++);for(;s<e.length;)o.push({mark:"-",value:e[s++]});for(;a<t.length;)o.push({mark:"+",value:t[a++]});return o}const HR=/[\p{L}\p{N}_$]+|\s+|[^\s\p{L}\p{N}_$]/gu;function Ib(e){return e.match(HR)??[]}const WR=.4;function KR(e,t){if(e===t)return null;const n=BR(Ib(e),Ib(t));let r=0;for(const o of n)o.mark===" "&&(r+=o.value.length);return r<WR*Math.max(e.length,t.length)?null:{before:Rb(n,"-"),after:Rb(n,"+")}}function Rb(e,t){const n=[];for(const r of e){if(r.mark!==" "&&r.mark!==t)continue;const o=r.mark===t,s=n[n.length-1];s&&s.changed===o?s.text+=r.value:n.push({text:r.value,changed:o})}for(let r=1;r<n.length-1;r++){const o=n[r];o&&(o.changed?o.changed=o.text.trim()!=="":o.changed=o.text.length<=2)}return YS(n)}function Ob(e){const t=[[]];for(const n of e){const r=n.text.split(`
42
- `);for(const[o,s]of r.entries())o>0&&t.push([]),s&&t[t.length-1].push({text:s,changed:n.changed})}return t.map(YS)}function YS(e){const t=[];for(const n of e){const r=t[t.length-1];r&&r.changed===n.changed?r.text+=n.text:t.push({...n})}return t}const qR=[{id:"merge",name:"here",description:"onto main in this checkout; nothing is pushed"},{id:"push",name:"push",description:"onto main on origin, straight from the worktree; main here follows"},{id:"pr",name:"pull request",description:"the branch is pushed and a pull request opened on GitHub"}],ZR=[{id:"merge",name:"merge commit",description:"the commits stay as they are, under one merge commit"},{id:"squash",name:"squash",description:"the work becomes one commit on main"},{id:"rebase",name:"rebase",description:"the commits go on main as they are, no merge commit"}],GR=[{id:"you",name:"you merge it",description:"the chat offers merge once GitHub would take the PR"},{id:"github",name:"GitHub merges it",description:"auto-merge: GitHub merges the PR itself once its rules allow (checks, reviewers, or nothing); where main has a merge queue, it queues the PR instead"}],ik="merge",ak="merge";function Ri(e){var n,r,o;const t=((n=e.land)==null?void 0:n.route)??ik;return{land:t,automerge:t==="pr"&&((r=e.land)==null?void 0:r.automerge)===!0,...(o=e.land)!=null&&o.method?{merge:e.land.method}:{}}}function Vh(e){return e.base??e.defaultBranch}function VR(e){return e.base!==void 0&&e.base!==e.defaultBranch}function YR(e){return!!e.pr&&(e.lands??[]).some(t=>{var n;return t.pr===((n=e.pr)==null?void 0:n.number)})}function XR(e){return{land:"a land",commit:"a commit","sync-main":"a sync","pull-main":"a pull"}[e]}function Ow(e,t){return e.landed&&(t??0)>0?{...e,landed:!1}:e}function Yh(e){return YR(e)&&!e.landed?void 0:e.pr}function Mw(e,t){const n=Yh(t);return e.land==="pr"&&(!n||n.state==="closed")?"create pr":"land"}function sh(e,t="main"){const n={merge:"merge into",squash:"squash onto",rebase:"rebase onto"}[e.merge??ak];switch(e.land){case"merge":return`Commit and ${n} ${t} here`;case"push":return`Commit, ${n} ${t} on origin and push it`;case"pr":return e.automerge?"Commit, push the branch and create a PR that GitHub merges when its rules allow":"Commit, push the branch and create a PR"}}const XS=e=>e.includes("U")||e==="AA"||e==="DD";function QS(e){return XS(e)?null:e[1]!=="D"&&e!=="D "}function Lw(e,t){const n=[];for(const r of t)r.xy!=="??"&&(XS(r.xy)?n.push(`${r.xy}${r.path}`):"ADRC".includes(r.xy.charAt(0))&&n.push(`${r.xy.charAt(0)}${r.path}`));return[e??"",...n.sort()].join("\0")}function JS(e){const t=[];for(const n of e)n.xy==="??"?t.push(`+${n.path}`):QS(n.xy)===!1&&t.push(`-${n.path}`);return t.sort().join("\0")}const Mb=new WeakMap;function e_(e,t){let n=Mb.get(e);n||(n=new Set(e),Mb.set(e,n));const r=new Set,o=new Set;for(const a of t){const l=QS(a.xy);l!==null&&(l?n.has(a.path)||r.add(a.path):n.has(a.path)&&o.add(a.path))}return{key:[...[...r].map(a=>`+${a}`),...[...o].map(a=>`-${a}`)].sort().join("\0"),added:[...r],gone:o}}function t_(e,t){return t.added.length===0&&t.gone.size===0?e:(t.gone.size>0?e.filter(r=>!t.gone.has(r)):e).concat(t.added)}function n_(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function Lb(e,t="|"){return e.map(n=>s_(n)).join(t)}function ck(e,t){return typeof t=="bigint"?t.toString():t}function Xh(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function QR(e){return e==null}function Pw(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function JR(e,t){const n=e/t,r=Math.round(n),o=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}function ko(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Wi(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function eO(e){return JSON.stringify(e)}function tO(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const r_="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ju(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const nO=Xh(()=>{var e;if(as.jitless||typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function $u(e){if(ju(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ju(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function o_(e){return $u(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const rO=new Set(["string","number","symbol"]);function Yc(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ki(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function mt(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function s_(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function oO(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const sO={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function iO(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=Wi(e._zod.def,{get shape(){const a={};for(const l of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,l))throw new Error(`Unrecognized key: "${String(l)}"`);t[l]&&ko(a,l,n.shape[l])}return ko(this,"shape",a),a},checks:[]});return Ki(e,s)}function aO(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=Wi(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const l of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,l))throw new Error(`Unrecognized key: "${String(l)}"`);t[l]&&delete a[l]}return ko(this,"shape",a),a},checks:[]});return Ki(e,s)}function cO(e,t){if(!$u(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const a of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(s,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=Wi(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return ko(this,"shape",s),s}});return Ki(e,o)}function lO(e,t){if(!$u(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Wi(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return ko(this,"shape",r),r}});return Ki(e,n)}function uO(e,t){var r,o;if(!((r=t==null?void 0:t._zod)!=null&&r.def))throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if((o=e._zod.def.checks)!=null&&o.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=Wi(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t._zod.def.shape};return ko(this,"shape",s),s},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Ki(e,n)}function Pb(e,t,n,r="partial"){const s=t._zod.def.checks;if(s&&s.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const l=Wi(t._zod.def,{get shape(){const u=t._zod.def.shape,f={...u};if(n)for(const h of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(u,h))throw new Error(`Unrecognized key: "${String(h)}"`);n[h]&&(f[h]=e?new e({type:"optional",innerType:u[h]}):u[h])}else for(const h of Reflect.ownKeys(u))f[h]=e?new e({type:"optional",innerType:u[h]}):u[h];return ko(this,"shape",f),f},checks:[]});return Ki(t,l)}function dO(e,t,n){const r=Wi(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const a of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(s,a))throw new Error(`Unrecognized key: "${String(a)}"`);n[a]&&(s[a]=new e({type:"nonoptional",innerType:o[a]}))}else for(const a of Reflect.ownKeys(o))s[a]=new e({type:"nonoptional",innerType:o[a]});return ko(this,"shape",s),s}});return Ki(t,r)}function Mc(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function fO(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0;return!1}function Qh(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function tu(e){return typeof e=="string"?e:e==null?void 0:e.message}function Db(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function ul(e,t,n){var g,y,w,v,x,N,S,T,j,$;var r;const o=(y=(g=e.inst)==null?void 0:g._zod)==null?void 0:y.traits;o!=null&&o.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const s=e.schema!==e.inst?(v=(w=e.schema)==null?void 0:w._zod.def)==null?void 0:v.error:void 0,a=e.message?e.message:tu((S=(N=(x=e.inst)==null?void 0:x._zod.def)==null?void 0:N.error)==null?void 0:S.call(N,e))??tu(s==null?void 0:s(e))??tu((T=t==null?void 0:t.error)==null?void 0:T.call(t,e))??tu((j=n.customError)==null?void 0:j.call(n,e))??tu(($=n.localeError)==null?void 0:$.call(n,e))??"Invalid input",{inst:l,schema:u,continue:f,input:h,...p}=e;return p.path??(p.path=[]),p.message=a,t!=null&&t.reportInput&&(p.input=h),p}const hO=/[\uD800-\uDBFF]/;function Dw(e){const t=e.length;if(!hO.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320&&(n--,r++);return n}function zw(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function pO(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";const n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Cu(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function mO(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):gO(e,n,r.value)}}function Xc(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function i_(e,t,n){return Xc(e,t,n,!1)}function gO(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Xc(this,t,n.bind(this))},set(r){Xc(this,t,r)}})}function kO(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let pg,Ci=!1;const wO={configurable:!0,get(){Ci=!0}};function jn(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&pg!==e._zod){pg=void 0;return}pg=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,wO);const o=Ci;Ci=!1;try{const s=n(this);return Ci?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),Ci=Ci||o,s}catch(s){throw delete this[t],Ci=Ci||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function yO(e,t,n,r){const o=kO(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){const s={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:s})}})}const vO="~constantCatch";function bO(e){const t=()=>e;return t[vO]=!0,t}var zb;const mg={value:void 0,enumerable:!1};let Fb="captureStackTrace"in Error?Error:null;function xO(e){const t=Fb;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return Fb=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function Ee(e,t,n,r){const o={};function s(g){this.def=g,this.constr=p,this.traits=new Set}s.prototype=o;const a=n,l=a&&new WeakSet;function u(g,y){if(!g._zod){mg.value=new s(y);try{Object.defineProperty(g,"_zod",mg)}finally{mg.value=void 0}}if(g._zod.traits.has(e))return;if(g._zod.traits.add(e),t(g,y),l){const v=Object.getPrototypeOf(g),x=g._zod.constr.prototype;let N=v;for(;N&&N!==x;)N=Object.getPrototypeOf(N);const S=N??v;l.has(S)||(l.add(S),mO(S,a))}const w=p.prototype;for(const v in w)Object.prototype.hasOwnProperty.call(w,v)&&(v in g||(g[v]=w[v].bind(g)))}const f=(r==null?void 0:r.Parent)??Object;class h extends f{}Object.defineProperty(h,"name",{value:e});function p(g){var x;const y=r!=null&&r.Parent?xO(h):this;u(y,g);const w=y._zod.deferred;if(w){for(const N of w)N();y._zod.deferred=void 0}const v=(x=globalThis.__zod_globalConfig)==null?void 0:x.postProcessor;return v&&v(y),y}return Object.defineProperty(p,"init",{value:u}),Object.defineProperty(p,Symbol.hasInstance,{value:g=>{var y,w;return r!=null&&r.Parent&&g instanceof r.Parent?!0:(w=(y=g==null?void 0:g._zod)==null?void 0:y.traits)==null?void 0:w.has(e)}}),Object.defineProperty(p,"name",{value:e}),p}class Wc extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class a_ extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(zb=globalThis).__zod_globalConfig??(zb.__zod_globalConfig={});const as=globalThis.__zod_globalConfig;function qi(e){return e&&Object.assign(as,e),as}function EO(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,ck,2)),e.message}function SO(e){this._zod.message=e}const _O={get:EO,set:SO,enumerable:!0,configurable:!0},gg={value:void 0,enumerable:!1},kg={value:void 0,enumerable:!1},Bb=new WeakSet([Object.prototype,Error.prototype]),c_=(e,t)=>{e.name="$ZodError",gg.value=e._zod,Object.defineProperty(e,"_zod",gg),kg.value=t,Object.defineProperty(e,"issues",kg),gg.value=void 0,kg.value=void 0,Object.defineProperty(e,"message",_O);const n=Object.getPrototypeOf(e);Bb.has(n)||(Bb.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},l_=Ee("$ZodError",c_),u_=Ee("$ZodError",c_,void 0,{Parent:Error});function NO(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function TO(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?NO(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n}}function jO(e,t=n=>n.message){const n={_errors:[]},r=(o,s=[])=>{for(const a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(l=>r({issues:l},[...s,...a.path]));else if(a.code==="invalid_key")r({issues:a.issues},[...s,...a.path]);else if(a.code==="invalid_element")r({issues:a.issues},[...s,...a.path]);else{const l=[...s,...a.path];if(l.length===0)n._errors.push(t(a));else{let u=n,f=0;for(;f<l.length;){const h=l[f],p=f===l.length-1;if(h==="_errors"){p&&u._errors.push(t(a)),f++;continue}Object.prototype.hasOwnProperty.call(u,h)||Object.defineProperty(u,h,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const g=u[h];p&&g._errors.push(t(a)),u=g,f++}}}};return r(e),n}function Jh(e,t){return{callee:(t==null?void 0:t.callee)??e,Err:t==null?void 0:t.Err}}const Fw=e=>{const t=(n,r,o,s)=>{const a=o?{...o,async:!1}:{async:!1},l=n._zod.run({value:r,issues:[]},a);if(l instanceof Promise)throw new Wc;if(l.issues.length){const u=new((s==null?void 0:s.Err)??e)(l.issues.map(f=>ul(f,a,qi())));throw r_(u,(s==null?void 0:s.callee)??t),u}return l.value};return t},Bw=e=>{const t=async(n,r,o,s)=>{const a=o?{...o,async:!0}:{async:!0};let l=n._zod.run({value:r,issues:[]},a);if(l instanceof Promise&&(l=await l),l.issues.length){const u=new((s==null?void 0:s.Err)??e)(l.issues.map(f=>ul(f,a,qi())));throw r_(u,(s==null?void 0:s.callee)??t),u}return l.value};return t},ep=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new Wc;return s.issues.length?{success:!1,error:new(e??l_)(s.issues.map(a=>ul(a,o,qi())))}:{success:!0,data:s.value}},$O=ep(u_),tp=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(a=>ul(a,o,qi())))}:{success:!0,data:s.value}},CO=tp(u_),AO=e=>{const t=Fw(e),n=(r,o,s,a)=>{const l=s?{...s,direction:"backward"}:{direction:"backward"};return t(r,o,l,Jh(n,a))};return n},IO=e=>{const t=Fw(e),n=(r,o,s,a)=>t(r,o,s,Jh(n,a));return n},RO=e=>{const t=Bw(e),n=async(r,o,s,a)=>{const l=s?{...s,direction:"backward"}:{direction:"backward"};return await t(r,o,l,Jh(n,a))};return n},OO=e=>{const t=Bw(e),n=async(r,o,s,a)=>await t(r,o,s,Jh(n,a));return n},MO=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return ep(e)(t,n,o)},LO=e=>(t,n,r)=>ep(e)(t,n,r),PO=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return tp(e)(t,n,o)},DO=e=>async(t,n,r)=>tp(e)(t,n,r),zO=/^[cC][0-9a-z]{6,}$/,FO=/^[0-9a-z]+$/,BO=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,UO=/^[0-9a-vA-V]{20}$/,HO=/^[A-Za-z0-9]{27}$/,WO=/^[a-zA-Z0-9_-]{21}$/;function KO(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const qO=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ZO=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ub=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,GO=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,VO="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function YO(){return new RegExp(VO,"u")}const XO=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,QO=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,JO=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,eM=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,tM=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,d_=/^[A-Za-z0-9_-]*$/,nM=/^https?$/,rM=/^\+[1-9]\d{6,14}$/,f_="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function oM(e){return new RegExp(`^${e}$`)}const sM=oM(f_);function lk(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function iM(e){return new RegExp(`^${lk(e)}$`)}function aM(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${lk({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${lk({precision:e.precision})}`:n;return new RegExp(`^${f_}T(?:${r})$`)}const cM=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},lM=/^-?\d+$/,uM=/^-?\d+(?:\.\d+)?$/,dM=/^(?:true|false)$/i,fM=/^[^A-Z]*$/,hM=/^[^a-z]*$/,yo=Ee("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Uw=e=>{const t=e.value;return!QR(t)&&t.length!==void 0},ih={number:"number",bigint:"bigint",object:"date"},h_=Ee("$ZodCheckLessThan",(e,t)=>{yo.init(e,t);const n=ih[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:ih[typeof r.value]??n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),p_=Ee("$ZodCheckGreaterThan",(e,t)=>{yo.init(e,t);const n=ih[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:ih[typeof r.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),pM=Ee("$ZodCheckMultipleOf",(e,t)=>{yo.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):JR(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),mM=Ee("$ZodCheckNumberFormat",(e,t)=>{var a;yo.init(e,t),t.format=t.format||"float64";const n=(a=t.format)==null?void 0:a.includes("int"),r=n?"int":"number",[o,s]=sO[t.format];e._zod.onattach.push(l=>{const u=l._zod.bag;u.format=t.format,u.minimum=o,u.maximum=s,n&&(u.pattern=lM)}),e._zod.check=l=>{const u=l.value;if(n){if(!Number.isInteger(u)){l.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:u,inst:e});return}if(!Number.isSafeInteger(u)){u>0?l.issues.push({input:u,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):l.issues.push({input:u,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}u<o&&l.issues.push({origin:"number",input:u,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),u>s&&l.issues.push({origin:"number",input:u,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),gM=Ee("$ZodCheckMaxLength",(e,t)=>{var n;yo.init(e,t),(n=e._zod.def).when??(n.when=Uw),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value,s=o.length;if((typeof o=="string"&&s>t.maximum?Dw(o):s)<=t.maximum)return;const l=zw(o);r.issues.push({origin:l,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),kM=Ee("$ZodCheckMinLength",(e,t)=>{var n;yo.init(e,t),(n=e._zod.def).when??(n.when=Uw),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value,s=o.length;if((typeof o=="string"&&s>=t.minimum&&s<t.minimum*2?Dw(o):s)>=t.minimum)return;const l=zw(o);r.issues.push({origin:l,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),wM=Ee("$ZodCheckLengthEquals",(e,t)=>{var n;yo.init(e,t),(n=e._zod.def).when??(n.when=Uw),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,s=o.length,a=typeof o=="string"&&s>=t.length&&s<=t.length*2?Dw(o):s;if(a===t.length)return;const l=zw(o),u=a>t.length;r.issues.push({origin:l,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),np=Ee("$ZodCheckStringFormat",(e,t)=>{var n,r;yo.init(e,t),e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),yM=Ee("$ZodCheckRegex",(e,t)=>{np.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),vM=Ee("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=fM),np.init(e,t)}),bM=Ee("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=hM),np.init(e,t)}),xM=Ee("$ZodCheckIncludes",(e,t)=>{yo.init(e,t);const n=Yc(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),EM=Ee("$ZodCheckStartsWith",(e,t)=>{yo.init(e,t);const n=new RegExp(`^${Yc(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),SM=Ee("$ZodCheckEndsWith",(e,t)=>{yo.init(e,t);const n=new RegExp(`.*${Yc(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),_M=Ee("$ZodCheckOverwrite",(e,t)=>{yo.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class NM{constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
43
- `).filter(a=>a),o=Math.min(...r.map(a=>a.length-a.trimStart().length)),s=r.map(a=>a.slice(o)).map(a=>" ".repeat(this.indent*2)+a);for(const a of s)this.content.push(a)}compile(){const t=Function,n=(this==null?void 0:this.content)??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
44
- ${n.join(`
45
- `)}
46
- };`)(...Object.values(this.closed))}}const TM={major:4,minor:5,patch:4},Kn=Ee("$ZodType",(e,t)=>{var s;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=TM;const r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r!=null&&r.length?[...r]:[];for(const a of o)for(const l of a._zod.onattach)l(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),(s=e._zod.deferred)==null||s.push(()=>{e._zod.run=e._zod.parse});else{const a=(u,f,h)=>{if(u.memo)return u;let p=Mc(u),g;for(const y of f){if(y._zod.def.when){if(fO(u)||!y._zod.def.when(u))continue}else if(p)continue;const w=u.issues.length,v=y._zod.check(u);if(v instanceof Promise&&(h==null?void 0:h.async)===!1)throw new Wc;if(g||v instanceof Promise)g=(g??Promise.resolve()).then(async()=>{await v,u.issues.length!==w&&(Db(u.issues,w,e),p||(p=Mc(u,w)))});else{if(u.issues.length===w)continue;Db(u.issues,w,e),p||(p=Mc(u,w))}}return g?g.then(()=>u):u},l=(u,f,h)=>{if(Mc(u))return u.aborted=!0,u;const p=a(f,o,h);if(p instanceof Promise){if(h.async===!1)throw new Wc;return p.then(g=>e._zod.parse(g,h))}return e._zod.parse(p,h)};e._zod.run=(u,f)=>{if(f.skipChecks)return e._zod.parse(u,f);if(f.direction==="backward"){const p=e._zod.parse({value:u.value,issues:[]},{...f,skipChecks:!0});return p instanceof Promise?p.then(g=>l(g,u,f)):l(p,u,f)}const h=e._zod.parse(u,f);if(h instanceof Promise){if(f.async===!1)throw new Wc;return h.then(p=>a(p,o,f))}return a(h,o,f)}}},{get"~standard"(){return i_(this,"~standard",m_(this))},set"~standard"(e){Xc(this,"~standard",e)}}),Hb=e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}};function m_(e){return{validate:t=>{try{return Hb($O(e,t))}catch{return CO(e,t).then(Hb)}},vendor:"zod",version:1}}const Hw=Ee("$ZodString",(e,t)=>{var n;Kn.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??cM(e._zod.bag),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),qn=Ee("$ZodStringFormat",(e,t)=>{np.init(e,t),Hw.init(e,t)}),jM=Ee("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ZO),qn.init(e,t)}),$M=Ee("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ub(r))}else t.pattern??(t.pattern=Ub());qn.init(e,t)}),CM=Ee("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=GO),qn.init(e,t)}),g_=1,k_=2;function AM(e,t){var n;if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===nM.source&&!/^https?:\/\//i.test(e))return g_;try{return new URL(e)}catch{return k_}}const IM=/[\t\n\r]/g;function RM(e){return e.replace(IM,"")}function OM(e,t){return t.lastIndex=0,t.test(e.hostname)}function MM(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const LM=Ee("$ZodURL",(e,t)=>{qn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=AM(r,t);if(o===g_){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===k_){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!OM(o,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!MM(o,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?o.href:RM(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),PM=Ee("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=YO()),qn.init(e,t)}),DM=Ee("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?WO:KO(t.length)),qn.init(e,t)}),zM=Ee("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=zO),qn.init(e,t)}),FM=Ee("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=FO),qn.init(e,t)}),BM=Ee("$ZodULID",(e,t)=>{t.pattern??(t.pattern=BO),qn.init(e,t)}),UM=Ee("$ZodXID",(e,t)=>{t.pattern??(t.pattern=UO),qn.init(e,t)}),HM=Ee("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=HO),qn.init(e,t)}),WM=Ee("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=aM(t)),qn.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(n=>{n._zod.bag.laxFormat=!0}))}),KM=Ee("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=sM),qn.init(e,t)}),qM=Ee("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=iM(t)),qn.init(e,t)}),ZM=Ee("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=qO),qn.init(e,t)}),GM=Ee("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=XO),qn.init(e,t),e._zod.bag.format="ipv4"}),VM=/^[0-9a-fA-F:.]+$/;function w_(e){if(!VM.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}const YM=Ee("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=QO),qn.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{w_(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),XM=Ee("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=JO),qn.init(e,t)});function QM(e){const t=e.split("/");if(t.length!==2)return!1;const[n,r]=t;if(!r)return!1;const o=Number(r);return`${o}`!==r||o<0||o>128?!1:w_(n)}const JM=Ee("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=eM),qn.init(e,t),e._zod.check=n=>{QM(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function y_(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const e2=Ee("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=tM),qn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{y_(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function t2(e){if(!d_.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return y_(n)}const n2=Ee("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=d_),qn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{t2(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),r2=Ee("$ZodE164",(e,t)=>{t.pattern??(t.pattern=rM),qn.init(e,t)});function o2(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&(o==null?void 0:o.typ)!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const s2=Ee("$ZodJWT",(e,t)=>{qn.init(e,t),e._zod.check=n=>{o2(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),v_=Ee("$ZodNumber",(e,t)=>{Kn.init(e,t),e._zod.pattern=e._zod.bag.pattern??uM,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),i2=Ee("$ZodNumberFormat",(e,t)=>{mM.init(e,t),v_.init(e,t)}),a2=Ee("$ZodBoolean",(e,t)=>{Kn.init(e,t),e._zod.pattern=dM,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),c2=Ee("$ZodUnknown",(e,t)=>{Kn.init(e,t),e._zod.parse=n=>n}),l2=Ee("$ZodNever",(e,t)=>{Kn.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Wb(e,t,n){e.issues.length&&t.issues.push(...Qh(n,e.issues)),t.value[n]=e.value}const u2=Ee("$ZodArray",(e,t)=>{Kn.init(e,t);const n=as.memoizer;n==null||n.attach(e),e._zod.parse=(r,o)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),r;r.value=n?n.alloc(e,r,Array(s.length),o):Array(s.length);const a=[];for(let l=0;l<s.length;l++){const u=s[l],f=t.element._zod.run({value:u,issues:[]},o);f instanceof Promise?a.push(f.then(h=>Wb(h,r,l))):Wb(f,r,l)}return a.length?Promise.all(a).then(()=>r):r}});function ah(e,t,n,r,o,s){const a=n in r,l=s==="optional";if(!(!a&&l&&o==="optional")){if(e.issues.length){if(o!==void 0&&l&&!a)return;t.issues.push(...Qh(n,e.issues))}if(!a&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?a&&(t.value[n]=void 0):t.value[n]=e.value}}const d2=[];function b_(e){var a,l,u,f;const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:d2,o=r.length?[...t,...r]:t;for(const h of o)if(!((f=(u=(l=(a=e.shape)==null?void 0:a[h])==null?void 0:l._zod)==null?void 0:u.traits)!=null&&f.has("$ZodType")))throw new Error(`Invalid element at key "${String(h)}": expected a Zod schema`);const s=oO(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function x_(e,t,n,r,o,s){const a=[],l=o.keySet,u=o.catchall._zod,f=u.def.type,h=u.optin,p=u.optout;for(const g in t){if(l.has(g))continue;if(g==="__proto__"){f==="never"&&a.push(g);continue}if(f==="never"){a.push(g);continue}const y=u.run({value:t[g],issues:[]},r);y instanceof Promise?e.push(y.then(w=>ah(w,n,g,t,h,p))):ah(y,n,g,t,h,p)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const uk=new WeakMap,f2=Ee("$ZodObject",(e,t)=>{Kn.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const u=t.shape;uk.set(t,u),Object.defineProperty(t,"shape",{get:()=>{const f={...u};return Object.defineProperty(t,"shape",{value:f}),uk.set(t,f),f}})}const r=Xh(()=>b_(t));jn(e,"propValues",u=>{const f=u.def.shape,h={};for(const p in f){const g=f[p]._zod;if(g.values){Object.prototype.hasOwnProperty.call(h,p)||ko(h,p,new Set);for(const y of g.values)h[p].add(y);g.optin!==void 0&&h[p].add(void 0)}}return h});const o=ju,s=t.catchall;let a;const l=as.memoizer;l==null||l.attach(e),e._zod.parse=(u,f)=>{a??(a=r.value);const h=u.value;if(!o(h))return u.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),u;u.value=l?l.alloc(e,u,{},f):{};const p=[],g=a.shape;for(const y of a.allKeys){if(y==="__proto__")continue;const w=g[y],v=w._zod.optin,x=w._zod.optout,N=w._zod.run({value:h[y],issues:[]},f);N instanceof Promise?p.push(N.then(S=>ah(S,u,y,h,v,x))):ah(N,u,y,h,v,x)}return s?x_(p,h,u,f,r.value,e):p.length?Promise.all(p).then(()=>u):u}}),h2=Ee("$ZodObjectJIT",(e,t)=>{f2.init(e,t);const n=e._zod.parse,r=Xh(()=>b_(t)),o=as.memoizer,s=y=>{var $,R;const w=r.value,v=w.symbolKeys,x=new NM(["payload","ctx"],{shape:y,inst:e,memo:o,syms:v}),N=A=>`shape[${A}]._zod.run({ value: input[${A}], issues: [] }, ctx)`,S=(A,I)=>`
47
- for (let i = 0; i < ${A}.issues.length; i++) {
48
- const iss = ${A}.issues[i];
49
- iss.path = iss.path ? [${I}, ...iss.path] : [${I}];
50
- payload.issues.push(iss);
51
- }`;x.write("const input = payload.value;");const T=Object.create(null);let j=0;for(const A of w.allKeys)T[A]=`key_${j++}`;x.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const A of w.allKeys){if(A==="__proto__")continue;const I=T[A],M=typeof A=="symbol"?`syms[${v.indexOf(A)}]`:eO(A),P=`${M} in input`,F=y[A],q=($=F==null?void 0:F._zod)==null?void 0:$.optin,W=q!==void 0,ee=((R=F==null?void 0:F._zod)==null?void 0:R.optout)==="optional";if(x.write(`const ${I} = ${N(M)};`),W&&ee){const V=q==="optional"?`${I}_present`:`${I}.value !== undefined || ${I}_present`;x.write(`
52
- const ${I}_present = ${P};
53
- if (!${I}.issues.length || ${I}_present) {
54
- if (${I}.issues.length) {${S(I,M)}
55
- }
56
-
57
- if (${V}) {
58
- newResult[${M}] = ${I}.value;
59
- }
60
- }
61
-
62
- `)}else W?x.write(`
63
- if (${I}.issues.length) {${S(I,M)}
64
- }
65
-
66
- if (${I}.value === undefined) {
67
- if (${P}) {
68
- newResult[${M}] = undefined;
69
- }
70
- } else {
71
- newResult[${M}] = ${I}.value;
72
- }
73
-
74
- `):x.write(`
75
- const ${I}_present = ${P};
76
- if (${I}.issues.length) {${S(I,M)}
77
- }
78
- if (!${I}_present && !${I}.issues.length) {
79
- payload.issues.push({
80
- code: "invalid_type",
81
- expected: "nonoptional",
82
- input: undefined,
83
- path: [${M}]
84
- });
85
- }
86
-
87
- if (${I}_present) {
88
- newResult[${M}] = ${I}.value;
89
- }
90
-
91
- `)}return x.write("payload.value = newResult;"),x.write("return payload;"),x.compile()};let a;const l=ju,u=!as.jitless,h=u&&nO.value,p=t.catchall;let g;e._zod.parse=(y,w)=>{g??(g=r.value);const v=y.value;return l(v)?u&&h&&(w==null?void 0:w.async)===!1&&w.jitless!==!0?(a||(a=s(t.shape)),y=a(y,w),p?x_([],v,y,w,g,e):y):n(y,w):(y.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),y)}});function Kb(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const o=e.filter(s=>!Mc(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(a=>ul(a,r,qi())))}),t)}const E_=Ee("$ZodUnion",(e,t)=>{Kn.init(e,t),jn(e,"optin",r=>r.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),jn(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),jn(e,"values",r=>{if(r.def.options.every(o=>o._zod.values))return new Set(r.def.options.flatMap(o=>Array.from(o._zod.values)))}),jn(e,"pattern",r=>{if(r.def.options.every(o=>o._zod.pattern)){const o=r.def.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>Pw(s.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let s=!1;const a=[];for(const l of t.options){const u=l._zod.run({value:r.value,issues:[]},o);if(u instanceof Promise)a.push(u),s=!0;else{if(u.issues.length===0)return u;a.push(u)}}return s?Promise.all(a).then(l=>Kb(l,r,e,o)):Kb(a,r,e,o)}}),p2=Ee("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,E_.init(e,t);const n=e._zod.parse;jn(e,"propValues",o=>{const s={};for(const a of o.def.options){const l=a._zod.propValues;if(!l||Object.keys(l).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);for(const[u,f]of Object.entries(l)){Object.prototype.hasOwnProperty.call(s,u)||ko(s,u,new Set);for(const h of f)s[u].add(h)}}return s}),t.options.forEach((o,s)=>{const a=uk.get(o._zod.def);if(a&&!Object.prototype.hasOwnProperty.call(a,t.discriminator))throw new Error(`Invalid discriminated union option at index "${s}"`)});const r=Xh(()=>{var a;const o=t.options,s=new Map;for(const l of o){const u=(a=l._zod.propValues)==null?void 0:a[t.discriminator];if(!u||u.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(l)}"`);for(const f of u){if(s.has(f))throw new Error(`Duplicate discriminator value "${String(f)}"`);s.set(f,l)}}return s});e._zod.parse=(o,s)=>{const a=o.value;if(!ju(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;const l=r.value.get(a==null?void 0:a[t.discriminator]);return l?l._zod.run(o,s):t.unionFallback||s.direction==="backward"?n(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:a,path:[t.discriminator],inst:e}),o)}}),m2=Ee("$ZodIntersection",(e,t)=>{Kn.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,s=t.left._zod.run({value:o,issues:[]},r),a=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||a instanceof Promise?Promise.all([s,a]).then(([u,f])=>qb(n,u,f)):qb(n,s,a)}});function dk(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if($u(e)&&$u(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(const s of r){if(s==="__proto__")continue;const a=dk(e[s],t[s]);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};o[s]=a.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],s=t[r],a=dk(o,s);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function qb(e,t,n){const r=new Map;let o;const s=new Map,a=(f,h)=>{var g,y;let p;if(f.code==="unrecognized_keys"&&!((g=f.path)!=null&&g.length))o??(o=f),p=f.keys;else if(f.code==="invalid_key"&&f.origin==="record"&&((y=f.path)==null?void 0:y.length)===1){const w=String(f.path[0]);s.has(w)||s.set(w,f),p=[w]}else return!1;for(const w of p)r.has(w)||r.set(w,{}),r.get(w)[h]=!0;return!0};for(const f of t.issues)a(f,"l")||e.issues.push(f);for(const f of n.issues)a(f,"r")||e.issues.push(f);const l=[...r].filter(([,f])=>f.l&&f.r).map(([f])=>f);if(l.length){const f=o?l.filter(h=>o.keys.includes(h)):[];f.length&&e.issues.push({...o,keys:f});for(const h of l)!f.includes(h)&&s.has(h)&&e.issues.push(s.get(h))}const u=dk(t.value,n.value);if(!u.valid){if(Mc(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}const g2=Ee("$ZodTuple",(e,t)=>{Kn.init(e,t);const n=t.items,r=as.memoizer;r==null||r.attach(e),e._zod.parse=(o,s)=>{const a=o.value;if(!Array.isArray(a))return o.issues.push({input:a,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=r?r.alloc(e,o,[],s):[];const l=[],u=Zb(n,"optin"),f=Zb(n,"optout");if(!t.rest){if(a.length<u)return o.issues.push({code:"too_small",minimum:u,inclusive:!0,input:a,inst:e,origin:"array"}),o;a.length>n.length&&o.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:a,inst:e,origin:"array"})}const h=new Array(n.length);for(let p=0;p<n.length;p++){const g=n[p]._zod.run({value:a[p],issues:[]},s);g instanceof Promise?l.push(g.then(y=>{h[p]=y})):h[p]=g}if(t.rest){let p=n.length-1;const g=a.slice(n.length);for(const y of g){p++;const w=t.rest._zod.run({value:y,issues:[]},s);w instanceof Promise?l.push(w.then(v=>Gb(v,o,p))):Gb(w,o,p)}}return l.length?Promise.all(l).then(()=>Vb(h,o,n,a,f)):Vb(h,o,n,a,f)}});function Zb(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function Gb(e,t,n){e.issues.length&&t.issues.push(...Qh(n,e.issues)),t.value[n]=e.value}function Vb(e,t,n,r,o){for(let s=0;s<n.length;s++){const a=e[s],l=s<r.length;if(!l&&s>=o&&n[s]._zod.optin==="optional"){t.value.length=s;break}if(a.issues.length){if(!l&&s>=o){t.value.length=s;break}t.issues.push(...Qh(s,a.issues))}t.value[s]=a.value}for(let s=t.value.length-1;s>=r.length&&(n[s]._zod.optout==="optional"&&t.value[s]===void 0);s--)t.value.length=s;return t}const k2=Ee("$ZodEnum",(e,t)=>{Kn.init(e,t);const n=n_(t.entries),r=new Set(n);e._zod.values=r;const o=n.filter(s=>rO.has(typeof s));e._zod.pattern=new RegExp(o.length?`^(${o.map(s=>Yc(s.toString())).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(s,a)=>{const l=s.value;return r.has(l)||s.issues.push({code:"invalid_value",values:n,input:l,inst:e}),s}}),w2=Ee("$ZodLiteral",(e,t)=>{Kn.init(e,t);const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(t.values.length?`^(${t.values.map(r=>typeof r=="string"?Yc(r):r?Yc(r.toString()):String(r)).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(r,o)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),y2=Ee("$ZodTransform",(e,t)=>{var n;Kn.init(e,t),e._zod.optin="optional",(n=as.memoizer)==null||n.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new a_(e.constructor.name);const s=t.transform(r.value,r);if(o.async)return(s instanceof Promise?s:Promise.resolve(s)).then(l=>(r.value=l,r));if(s instanceof Promise)throw new Wc;return r.value=s,r}});function Yb(e,t){return e.value=t.issues.length?void 0:t.value,e}const S_=Ee("$ZodOptional",(e,t)=>{Kn.init(e,t),jn(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",jn(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),jn(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Pw(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;const o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(s=>Yb(n,s)):Yb(n,o)}return t.innerType._zod.run(n,r)}}),v2=Ee("$ZodExactOptional",(e,t)=>{S_.init(e,t),jn(e,"values",n=>n.def.innerType._zod.values),jn(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),b2=Ee("$ZodNullable",(e,t)=>{Kn.init(e,t),jn(e,"optin",n=>n.def.innerType._zod.optin),jn(e,"optout",n=>n.def.innerType._zod.optout),jn(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Pw(r.source)}|null)$`):void 0}),jn(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),x2=Ee("$ZodDefault",(e,t)=>{Kn.init(e,t),e._zod.optin="defaulted",jn(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>Xb(s,t)):Xb(o,t)}});function Xb(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const E2=Ee("$ZodPrefault",(e,t)=>{Kn.init(e,t),e._zod.optin="defaulted",jn(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),S2=Ee("$ZodNonOptional",(e,t)=>{Kn.init(e,t),jn(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>Qb(s,e)):Qb(o,e)}});function Qb(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function Jb(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>ul(o,r,qi()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const _2=Ee("$ZodCatch",(e,t)=>{Kn.init(e,t),jn(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),jn(e,"optout",n=>n.def.innerType._zod.optout),jn(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(s=>Jb(n,s,t,r)):Jb(n,o,t,r)}}),N2=Ee("$ZodPipe",(e,t)=>{Kn.init(e,t),jn(e,"values",n=>n.def.in._zod.values),jn(e,"optin",n=>n.def.in._zod.optin),jn(e,"optout",n=>n.def.out._zod.optout),jn(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(a=>xf(a,t.in,r)):xf(s,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>xf(s,t.out,r)):xf(o,t.out,r)}});function xf(e,t,n){return e.issues.some(r=>r.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const T2=Ee("$ZodReadonly",(e,t)=>{Kn.init(e,t),jn(e,"propValues",n=>n.def.innerType._zod.propValues),jn(e,"values",n=>n.def.innerType._zod.values),jn(e,"optin",n=>{var r,o;return(o=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:o.optin}),jn(e,"optout",n=>{var r,o;return(o=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:o.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(ex):ex(o)}});function ex(e){return e.memo||(e.value=Object.freeze(e.value)),e}const j2=Ee("$ZodCustom",(e,t)=>{yo.init(e,t),Kn.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>tx(s,n,r,e));tx(o,n,r,e)}});function tx(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(Cu(o))}}class $2 extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const fk="~memo",nx=[];function wg(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const rx=new WeakMap;function __(e,t){const n=rx.get(e);if(n!==void 0)return n;if(t.has(e))return!0;t.add(e);let r=!1;const o=l=>{!r&&(l!=null&&l._zod)&&__(l,t)&&(r=!0)},s=e._zod.def;switch(s.type){case"object":{for(const l of Reflect.ownKeys(s.shape))o(s.shape[l]);o(s.catchall);break}case"array":o(s.element);break;case"tuple":for(const l of s.items)o(l);o(s.rest);break;case"record":case"map":o(s.keyType),o(s.valueType);break;case"set":o(s.valueType);break;case"union":for(const l of s.options)o(l);break;case"intersection":o(s.left),o(s.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(s.innerType);break;case"pipe":o(s.in),o(s.out);break;case"function":o(s.input),o(s.output);break;case"lazy":o(e._zod.innerType);break;case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const l in s){const u=Object.getOwnPropertyDescriptor(s,l);if(!u||u.get)continue;const f=u.value;if(!(!f||typeof f!="object")){if(f._zod)o(f);else if(Array.isArray(f))for(const h of f)o(h)}}}return t.delete(e),rx.set(e,r),r}function C2(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}let Ef;const Sf=[],A2={alloc(e,t,n){const r=Ef;if(!r)return n;Ef=void 0;const o={value:n,issues:null};return r.set(t.value,o),Sf.push(o),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const n=e._zod.parse,r=(o,s)=>{if(s.direction!=="backward"&&R2(s,o.value))throw new $2;return n(o,s)};e._zod.parse=r,e._zod.run===n&&(e._zod.run=r)})},attach(e){var t;let n,r,o;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const s=e._zod.parse,a=(l,u)=>{if(n===void 0&&(n=__(e,new Set),!n))return e._zod.parse=s,e._zod.run===a&&(e._zod.run=s),s(l,u);const f=l.value;if(f===null||typeof f!="object")return s(l,u);let h=u[fk];h||(h={buckets:new Map,backEdges:void 0},u[fk]=h);let p;r===u?p=o:(p=C2(h,e),r=u,o=p);const g=p.get(f);if(g)return l.value=g.value,g.issues?g.issues.length&&l.issues.push(...wg(g.issues)):(l.memo=!0,h.backEdges??(h.backEdges=new Set),h.backEdges.add(g.value)),l;Ef=p;const y=Sf.length,w=s(l,u);Ef=void 0;const v=Sf.length>y?Sf.pop():void 0;return w instanceof Promise?w.then(x=>(v&&(v.issues=x.issues.length?wg(x.issues):nx),x)):(v&&(v.issues=w.issues.length?wg(w.issues):nx),w)};e._zod.parse=a,e._zod.run===s&&(e._zod.run=a)})}};function I2(){return A2}function R2(e,t){var r;const n=(r=e[fk])==null?void 0:r.backEdges;return n!==void 0&&t!==null&&typeof t=="object"&&n.has(t)}const O2=()=>{const e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}const n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",credit_card:"credit card number",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(s,a){return s==="number"&&typeof a=="number"&&!Number.isFinite(a)?String(a):r[s]??s}return s=>{switch(s.code){case"invalid_type":{const a=o(s.expected),l=pO(s.input),u=o(l,s.input);return`Invalid input: expected ${a}, received ${u}`}case"invalid_value":return s.values.length===1?`Invalid input: expected ${s_(s.values[0])}`:`Invalid option: expected one of ${Lb(s.values,"|")}`;case"too_big":{const a=s.exact?"exactly ":s.inclusive?"<=":"<",l=t(s.origin);return l?`Too big: expected ${s.origin??"value"} to have ${a}${s.maximum.toString()} ${l.unit??"elements"}`:`Too big: expected ${s.origin??"value"} to be ${a}${s.maximum.toString()}`}case"too_small":{const a=s.exact?"exactly ":s.inclusive?">=":">",l=t(s.origin);return l?`Too small: expected ${s.origin} to have ${a}${s.minimum.toString()} ${l.unit}`:`Too small: expected ${s.origin} to be ${a}${s.minimum.toString()}`}case"invalid_format":{const a=s;return a.format==="starts_with"?`Invalid string: must start with "${a.prefix}"`:a.format==="ends_with"?`Invalid string: must end with "${a.suffix}"`:a.format==="includes"?`Invalid string: must include "${a.includes}"`:a.format==="regex"?`Invalid string: must match pattern ${a.pattern}`:`Invalid ${n[a.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${Lb(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Invalid discriminator value. Expected ${s.options.map(l=>`'${l}'`).join(" | ")}`:s.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function M2(){return{localeError:O2()}}var ox;class L2{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function P2(){return new L2}(ox=globalThis).__zod_globalRegistry??(ox.__zod_globalRegistry=P2());const uu=globalThis.__zod_globalRegistry;function D2(e,t){return new e({type:"string",...mt(t)})}function z2(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...mt(t)})}function F2(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...mt(t)})}function B2(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...mt(t)})}function U2(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...mt(t)})}function H2(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...mt(t)})}function W2(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...mt(t)})}function K2(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...mt(t)})}function q2(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...mt(t)})}function Z2(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...mt(t)})}function G2(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...mt(t)})}function V2(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...mt(t)})}function Y2(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...mt(t)})}function X2(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...mt(t)})}function Q2(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...mt(t)})}function J2(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...mt(t)})}function eL(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...mt(t)})}function tL(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...mt(t)})}function nL(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...mt(t)})}function rL(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...mt(t)})}function oL(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...mt(t)})}function sL(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...mt(t)})}function iL(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...mt(t)})}function aL(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...mt(t)})}function cL(e,t){return new e({type:"string",format:"date",check:"string_format",...mt(t)})}function lL(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...mt(t)})}function uL(e,t){return new e({type:"string",format:"duration",check:"string_format",...mt(t)})}function dL(e,t){return new e({type:"number",checks:[],...mt(t)})}function fL(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...mt(t)})}function hL(e,t){return new e({type:"boolean",...mt(t)})}function pL(e){return new e({type:"unknown"})}function mL(e,t){return new e({type:"never",...mt(t)})}function sx(e,t){return new h_({check:"less_than",...mt(t),value:e,inclusive:!1})}function yg(e,t){return new h_({check:"less_than",...mt(t),value:e,inclusive:!0})}function ix(e,t){return new p_({check:"greater_than",...mt(t),value:e,inclusive:!1})}function vg(e,t){return new p_({check:"greater_than",...mt(t),value:e,inclusive:!0})}function ax(e,t){return new pM({check:"multiple_of",...mt(t),value:e})}function N_(e,t){return new gM({check:"max_length",...mt(t),maximum:e})}function ch(e,t){return new kM({check:"min_length",...mt(t),minimum:e})}function T_(e,t){return new wM({check:"length_equals",...mt(t),length:e})}function gL(e,t){return new yM({check:"string_format",format:"regex",...mt(t),pattern:e})}function kL(e){return new vM({check:"string_format",format:"lowercase",...mt(e)})}function wL(e){return new bM({check:"string_format",format:"uppercase",...mt(e)})}function yL(e,t){return new xM({check:"string_format",format:"includes",...mt(t),includes:e})}function vL(e,t){return new EM({check:"string_format",format:"starts_with",...mt(t),prefix:e})}function bL(e,t){return new SM({check:"string_format",format:"ends_with",...mt(t),suffix:e})}function dl(e){return new _M({check:"overwrite",tx:e})}function xL(e){return dl(t=>t.normalize(e))}function EL(){return dl(e=>e.trim())}function SL(){return dl(e=>e.toLowerCase())}function _L(){return dl(e=>e.toUpperCase())}function NL(){return dl(e=>tO(e))}function TL(e,t,n){return new e({type:"array",element:t,...mt(n)})}function jL(e,t,n){return new e({type:"custom",check:"custom",fn:t,...mt(n)})}function $L(e,t){const n=CL(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(Cu(o,r.value,n._zod.def));else{const s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=r.value),s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),r.issues.push(Cu(s))}},e(r.value,r)),t);return n}function CL(e,t){const n=new yo({check:"custom",...mt(t)});return n._zod.check=e,n}function vu(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&ko(e,r,n[r]);return e}function j_(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??uu,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",intersections:[],deferred:[],external:(e==null?void 0:e.external)??void 0}}function zi(e,t,n,r,o){const s=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:o}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw new Error(o);return Object.assign(n,s),!0}function yr(e,t,n={path:[],schemaPath:[]}){var h,p;var r;const o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const l=(p=(h=e._zod).toJSONSchema)==null?void 0:p.call(h);if(l)a.schema=l;else{const g={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,g);else{const w=a.schema,v=t.processors[o.type];if(!v)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);v(e,t,w,g)}const y=e._zod.parent;y&&(a.ref||(a.ref=y),yr(y,t,g),t.seen.get(y).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&vu(a.schema,u),t.io==="input"&&eo(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&"_prefault"in a.schema&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function cx(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function $_(e,t){var a,l,u,f;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const r=new Map;for(const h of e.seen.entries()){const p=(a=e.metadataRegistry.get(h[0]))==null?void 0:a.id;if(p){const g=r.get(p);if(g&&g!==h[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(p,h[0])}}const o=h=>{var v;const p=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const x=(v=e.external.registry.get(h[0]))==null?void 0:v.id,N=e.external.uri??(T=>T);if(x)return{ref:N(x)};const S=h[1].defId??h[1].schema.id??`schema${e.counter++}`;return h[1].defId=S,{defId:S,ref:`${N("__shared")}#/${p}/${cx(S)}`}}const g="#",y=`${g}/${p}/`;if(h[1]===n&&!h[1].schema.id)return{ref:g};const w=h[1].schema.id??`__schema${e.counter++}`;return{defId:w,ref:y+cx(w)}},s=h=>{if(h[1].schema.$ref)return;const p=h[1],{ref:g,defId:y}=o(h);p.def={...p.schema},y&&(p.defId=y);const w=p.schema;for(const v in w)delete w[v];w.$ref=g};if(e.cycles==="throw")for(const h of e.seen.entries()){const p=h[1];if(p.cycle)throw new Error(`Cycle detected: #/${(l=p.cycle)==null?void 0:l.join("/")}/<root>
92
-
93
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const h of e.seen.entries()){const p=h[1];if(t===h[0]){s(h);continue}if(e.external){const y=(u=e.external.registry.get(h[0]))==null?void 0:u.id;if(t!==h[0]&&y){s(h);continue}}if((f=e.metadataRegistry.get(h[0]))==null?void 0:f.id){s(h);continue}if(p.cycle){s(h);continue}if(p.count>1&&e.reused==="ref"){s(h);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function C_(e){const t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;const n=[];for(const r of t){if(!r||typeof r!="object")return;C_(r);const o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;const s=r.type;for(const a of Array.isArray(s)?s:[s]){if(typeof a!="string")return;n.includes(a)||n.push(a)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const A_=new Set(["type","properties","required","additionalProperties"]),lx=["oneOf","anyOf"];function ux(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function hk(e){var s;const t=[];for(const a of e){if(typeof a!="object"||a.type!=="object")return null;for(const l in a)if(!A_.has(l))return null;t.push(a)}const n={},r=new Set;for(const a of t){for(const l in a.properties){if(Object.prototype.hasOwnProperty.call(n,l))continue;const u=[];for(const h of t){const p=((s=h.properties)==null?void 0:s[l])??ux(h);p!=null&&(u.some(g=>JSON.stringify(g)===JSON.stringify(p))||u.push(p))}const f=u.length===1?u[0]:hk(u)??{allOf:u};ko(n,l,f)}for(const l of a.required??[])r.add(l)}const o={type:"object",properties:n};if(r.size&&(o.required=[...r]),t.every(a=>a.additionalProperties===!1))o.additionalProperties=!1;else{const a=[];for(const l of t){const u=ux(l);u&&!a.some(f=>JSON.stringify(f)===JSON.stringify(u))&&a.push(u)}a.length===1?o.additionalProperties=a[0]:a.length>1&&(o.additionalProperties={allOf:a})}return o}function AL(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const o of A_)if(o in e)return;const n=t.filter(o=>lx.some(s=>Array.isArray(o[s])));let r=null;if(!n.length)r=hk(t);else{const o=n[0],s=lx.find(u=>Array.isArray(o[u]));if(Object.keys(o).length!==1)return;const a=t.filter(u=>u!==o),l=o[s].map(u=>hk([...a,u]));if(l.some(u=>!u))return;r={[s]:l}}r&&(delete e.allOf,vu(e,r))}function I_(e,t){var l,u,f,h;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=p=>{const g=e.seen.get(p);if(g.ref===null)return;const y=g.def??g.schema,w={...y},v=g.ref;if(g.ref=null,v){r(v);const N=e.seen.get(v),S=N.schema;if(S.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(y.allOf=y.allOf??[],y.allOf.push(S)):vu(y,S),vu(y,w),p._zod.parent===v)for(const j in y)j==="$ref"||j==="allOf"||j in w||delete y[j];if(S.$ref&&N.def)for(const j in y)j==="$ref"||j==="allOf"||j in N.def&&JSON.stringify(y[j])===JSON.stringify(N.def[j])&&delete y[j]}const x=p._zod.parent;if(x&&x!==v){r(x);const N=e.seen.get(x);if(N!=null&&N.schema.$ref&&(y.$ref=N.schema.$ref,N.def))for(const S in y)S==="$ref"||S==="allOf"||S in N.def&&JSON.stringify(y[S])===JSON.stringify(N.def[S])&&delete y[S]}e.override({zodSchema:p,jsonSchema:y,path:g.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const p of[...e.seen.entries()].reverse())r(p[0]);if(e.target!=="openapi-3.0")for(const p of e.seen.entries())C_(p[1].def??p[1].schema);for(const p of e.deferred)p();if(e.intersections.length){const p=new Map;for(const g of e.seen.values())for(const y of[g.schema,g.def]){const w=y==null?void 0:y.allOf;if(!Array.isArray(w))continue;const v=p.get(w);v?v.push(y):p.set(w,[y])}for(const g of e.intersections)for(const y of p.get(g)??[])AL(y)}}const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,(l=e.external)!=null&&l.uri){const p=(u=e.external.registry.get(t))==null?void 0:u.id;if(!p)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(p)}vu(o,n.defId?n.schema:n.def??n.schema);const s=(f=e.metadataRegistry.get(t))==null?void 0:f.id;s!==void 0&&o.id===s&&delete o.id;const a=((h=e.external)==null?void 0:h.defs)??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const p of e.seen.entries()){const g=p[1];g.def&&g.defId&&(g.def.id===g.defId&&delete g.def.id,ko(a,g.defId,g.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?o.$defs=a:o.definitions=a);try{const p=JSON.parse(JSON.stringify(o));return Object.defineProperty(p,"~standard",{value:{...t["~standard"],jsonSchema:{input:lh(t,"input",e.processors),output:lh(t,"output",e.processors)}},enumerable:!1,writable:!1}),p}catch{throw new Error("Error converting schema to JSON.")}}function eo(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return eo(r.element,n);if(r.type==="set")return eo(r.valueType,n);if(r.type==="lazy")return eo(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return eo(r.innerType,n);if(r.type==="intersection")return eo(r.left,n)||eo(r.right,n);if(r.type==="record"||r.type==="map")return eo(r.keyType,n)||eo(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:eo(r.in,n)||eo(r.out,n);if(r.type==="object"){for(const o in r.shape)if(eo(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(eo(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(eo(o,n))return!0;return!!(r.rest&&eo(r.rest,n))}return!1}const IL=(e,t={})=>n=>{const r=j_({...n,processors:t});return yr(e,r),$_(r,e),I_(r,e)},lh=(e,t,n={})=>r=>{const{libraryOptions:o,target:s}=r??{},a=j_({...o??{},target:s,io:t,processors:n});return yr(e,a),$_(a,e),I_(a,e)},RL={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},OL=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:s,maximum:a,format:l,patterns:u,contentEncoding:f,laxFormat:h}=e._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof a=="number"&&(o.maxLength=a),l&&(o.format=RL[l]??l,o.format===""&&delete o.format,(l==="time"||h)&&delete o.format),f&&(o.contentEncoding=f),u&&u.size>0){const p=[...u];p.length===1?o.pattern=p[0].source:p.length>1&&(o.allOf=[...p.map(g=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},ML=(e,t,n,r)=>{const o=n,{minimum:s,maximum:a,format:l,multipleOf:u,exclusiveMaximum:f,exclusiveMinimum:h}=e._zod.bag;typeof l=="string"&&l.includes("int")?o.type="integer":o.type="number";const p=typeof h=="number"&&h>=(s??Number.NEGATIVE_INFINITY),g=typeof f=="number"&&f<=(a??Number.POSITIVE_INFINITY),y=t.target==="draft-04"||t.target==="openapi-3.0";p?y?(o.minimum=h,o.exclusiveMinimum=!0):o.exclusiveMinimum=h:typeof s=="number"&&(o.minimum=s),g?y?(o.maximum=f,o.exclusiveMaximum=!0):o.exclusiveMaximum=f:typeof a=="number"&&(o.maximum=a),typeof u=="number"&&(Number.isFinite(u)&&u!==0?o.multipleOf=Math.abs(u):zi(e,t,o,r,`A multipleOf divisor of ${u} cannot be represented in JSON Schema`))},LL=(e,t,n,r)=>{n.type="boolean"},PL=(e,t,n,r)=>{n.not={}},DL=(e,t,n,r)=>{},zL=(e,t,n,r)=>{const o=e._zod.def,s=n_(o.entries);if(s.length===0){n.not={};return}s.every(a=>typeof a=="number")&&(n.type="number"),s.every(a=>typeof a=="string")&&(n.type="string"),n.enum=s},FL=(e,t,n,r)=>{const o=e._zod.def;if(o.values.length===0){n.not={};return}const s=[];for(const a of o.values)if(a===void 0){if(zi(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(zi(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(a))}else s.push(a);if(s.length!==0)if(s.length===1){const a=s[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else s.every(a=>typeof a=="number")&&(n.type="number"),s.every(a=>typeof a=="string")&&(n.type="string"),s.every(a=>typeof a=="boolean")&&(n.type="boolean"),s.every(a=>a===null)&&(n.type="null"),n.enum=s},BL=(e,t,n,r)=>{zi(e,t,n,r,"Custom types cannot be represented in JSON Schema")},UL=(e,t,n,r)=>{zi(e,t,n,r,"Transforms cannot be represented in JSON Schema")},HL=(e,t,n,r)=>{const o=n,s=e._zod.def,{minimum:a,maximum:l}=e._zod.bag;typeof a=="number"&&(o.minItems=a),typeof l=="number"&&(o.maxItems=l),o.type="array",o.items=yr(s.element,t,{...r,path:[...r.path,"items"]})};function uh(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?uh(t.out):t.type==="catch"?uh(t.innerType):e._zod.optin}const WL=(e,t,n,r)=>{var h;const o=n,s=e._zod.def,a=s.shape;if(Object.getOwnPropertySymbols(a).length&&zi(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const p in a)ko(o.properties,p,yr(a[p],t,{...r,path:[...r.path,"properties",p]}));const u=new Set(Object.keys(a)),f=new Set([...u].filter(p=>{const g=s.shape[p];return t.io==="input"?uh(g)===void 0:g._zod.optout===void 0}));f.size>0&&(o.required=Array.from(f)),((h=s.catchall)==null?void 0:h._zod.def.type)==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=yr(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},KL=(e,t,n,r)=>{const o=e._zod.def,s=o.inclusive===!1,a=o.options.map((l,u)=>yr(l,t,{...r,path:[...r.path,s?"oneOf":"anyOf",u]}));s?n.oneOf=a:n.anyOf=a},qL=(e,t,n,r)=>{const o=e._zod.def,s=yr(o.left,t,{...r,path:[...r.path,"allOf",0]}),a=yr(o.right,t,{...r,path:[...r.path,"allOf",1]}),l=f=>"allOf"in f&&Object.keys(f).length===1,u=[...l(s)?s.allOf:[s],...l(a)?a.allOf:[a]];n.allOf=u,t.intersections.push(u)},ZL=(e,t,n,r)=>{const o=n,s=e._zod.def;o.type="array";const a=t.target==="draft-2020-12"?"prefixItems":"items",l=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",u=s.items.map((v,x)=>yr(v,t,{...r,path:[...r.path,a,x]})),f=s.rest?yr(s.rest,t,{...r,path:[...r.path,l,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null;let h=s.items.length;for(;h>0;){const v=s.items[h-1];if(!(t.io==="input"?uh(v)!==void 0:v._zod.optout==="optional"))break;h--}const p=s.items.length,g=!s.rest;t.target==="draft-2020-12"?(o.prefixItems=u,g?o.items=!1:f&&(o.items=f),h>0&&(o.minItems=h),g&&(o.maxItems=p)):t.target==="openapi-3.0"?(o.items={anyOf:u},f&&o.items.anyOf.push(f),h>0&&(o.minItems=h),g&&(o.maxItems=p)):(o.items=u,g?o.additionalItems=!1:f&&(o.additionalItems=f),h>0&&(o.minItems=h),g&&(o.maxItems=p));const{minimum:y,maximum:w}=e._zod.bag;typeof y=="number"&&(o.minItems=y),typeof w=="number"&&(o.maxItems=w)},GL=(e,t,n,r)=>{const o=e._zod.def,s=yr(o.innerType,t,r),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=o.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},VL=(e,t,n,r)=>{const o=e._zod.def;yr(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},Ww=Symbol();function R_(e,t,n,r,o){let s=!1;const a=JSON.stringify(e,(l,u)=>typeof u!="bigint"?u:(s=!0,null));return s?(zi(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),Ww):JSON.parse(a)}const YL=(e,t,n,r)=>{const o=e._zod.def;yr(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType;const a=R_(o.defaultValue,e,t,n,r);a!==Ww&&(n.default=a)},XL=(e,t,n,r)=>{const o=e._zod.def;yr(o.innerType,t,r);const s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;const a=R_(o.defaultValue,e,t,n,r);a!==Ww&&(n._prefault=a)},QL=(e,t,n,r)=>{const o=e._zod.def;yr(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{zi(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=a},JL=(e,t,n,r)=>{const o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?s?o.out:o.in:o.out;yr(a,t,r);const l=t.seen.get(e);l.ref=a},eP=(e,t,n,r)=>{const o=e._zod.def;yr(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,n.readOnly=!0},O_=(e,t,n,r)=>{const o=e._zod.def;yr(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},dx=new WeakSet([Object.prototype,Error.prototype]);function _f(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){const r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}const tP=(e,t)=>{l_.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);dx.has(n)||(dx.add(n),_f(n,"format",r=>o=>jO(r,o)),_f(n,"flatten",r=>o=>TO(r,o)),_f(n,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,ck,2)}),_f(n,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,ck,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},qo=Ee("ZodError",tP,void 0,{Parent:Error}),nP=Fw(qo),rP=Bw(qo),oP=ep(qo),sP=tp(qo),iP=AO(qo),aP=IO(qo),cP=RO(qo),lP=OO(qo),uP=MO(qo),dP=LO(qo),fP=PO(qo),hP=DO(qo);function pP(){as.localeError||qi(M2())}function rp(){as.memoizer||qi({memoizer:I2()})}const Yn=Ee("ZodType",(e,t)=>(pP(),Kn.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(Wi(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Ki(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(fD(e,t))},superRefine(e,t){return this.check(hD(e,t))},overwrite(e){return this.check(dl(e))},optional(){return px(this)},exactOptional(){return eD(this)},nullable(){return mx(this)},nullish(){return px(mx(this))},nonoptional(e){return iD(this,e)},array(){return Aa(this)},or(e){return KP([this,e])},and(e){return VP(this,e)},transform(e){return gx(this,JP(e))},default(e){return rD(this,e)},prefault(e){return sD(this,e)},catch(e){return cD(this,e)},pipe(e){return gx(this,e)},readonly(){return dD(this)},describe(e){const t=this.clone();return uu.add(t,{description:e}),t},meta(...e){if(e.length===0)return uu.get(this);const t=this.clone();return uu.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return i_(this,"~standard",{...m_(this),jsonSchema:{input:lh(this,"input"),output:lh(this,"output")}})},set"~standard"(e){Xc(this,"~standard",e)},parse:function e(t,n){return nP(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await rP(this,t,n,{callee:e})},safeParse(e,t){return oP(this,e,t)},async safeParseAsync(e,t){return sP(this,e,t)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(e){Xc(this,"spa",e)},encode:function e(t,n){return iP(this,t,n,{callee:e})},decode:function e(t,n){return aP(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await cP(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await lP(this,t,n,{callee:e})},safeEncode(e,t){return uP(this,e,t)},safeDecode(e,t){return dP(this,e,t)},async safeEncodeAsync(e,t){return fP(this,e,t)},async safeDecodeAsync(e,t){return hP(this,e,t)},toJSONSchema(e){return IL(this,{})(e)},get description(){var e;return(e=uu.get(this))==null?void 0:e.description},get _def(){return this._zod.def}}),M_=Ee("_ZodString",(e,t)=>{Hw.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(r,o,s)=>OL(e,r,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null},{regex(...e){return this.check(gL(...e))},includes(...e){return this.check(yL(...e))},startsWith(...e){return this.check(vL(...e))},endsWith(...e){return this.check(bL(...e))},min(...e){return this.check(ch(...e))},max(...e){return this.check(N_(...e))},length(...e){return this.check(T_(...e))},nonempty(...e){return this.check(ch(1,...e))},lowercase(e){return this.check(kL(e))},uppercase(e){return this.check(wL(e))},trim(){return this.check(EL())},normalize(...e){return this.check(xL(...e))},toLowerCase(){return this.check(SL())},toUpperCase(){return this.check(_L())},slugify(){return this.check(NL())}}),mP=Ee("ZodString",(e,t)=>{Hw.init(e,t),M_.init(e,t)},{email(e){return this.check(z2(vP,e))},url(e){return this.check(K2(xP,e))},jwt(e){return this.check(iL(PP,e))},emoji(e){return this.check(q2(EP,e))},guid(e){return this.check(F2(bP,e))},uuid(e){return this.check(B2(Nf,e))},uuidv4(e){return this.check(U2(Nf,e))},uuidv6(e){return this.check(H2(Nf,e))},uuidv7(e){return this.check(W2(Nf,e))},nanoid(e){return this.check(Z2(SP,e))},cuid(e){return this.check(G2(_P,e))},cuid2(e){return this.check(V2(NP,e))},ulid(e){return this.check(Y2(TP,e))},base64(e){return this.check(rL(OP,e))},base64url(e){return this.check(oL(MP,e))},xid(e){return this.check(X2(jP,e))},ksuid(e){return this.check(Q2($P,e))},ipv4(e){return this.check(J2(CP,e))},ipv6(e){return this.check(eL(AP,e))},cidrv4(e){return this.check(tL(IP,e))},cidrv6(e){return this.check(nL(RP,e))},e164(e){return this.check(sL(LP,e))},datetime(e){return this.check(aL(gP,e))},date(e){return this.check(cL(kP,e))},time(e){return this.check(lL(wP,e))},duration(e){return this.check(uL(yP,e))}});function $n(e){return D2(mP,e)}const Xn=Ee("ZodStringFormat",(e,t)=>{qn.init(e,t),M_.init(e,t)}),gP=Ee("ZodISODateTime",(e,t)=>{WM.init(e,t),Xn.init(e,t)}),kP=Ee("ZodISODate",(e,t)=>{KM.init(e,t),Xn.init(e,t)}),wP=Ee("ZodISOTime",(e,t)=>{qM.init(e,t),Xn.init(e,t)}),yP=Ee("ZodISODuration",(e,t)=>{ZM.init(e,t),Xn.init(e,t)}),vP=Ee("ZodEmail",(e,t)=>{CM.init(e,t),Xn.init(e,t)}),bP=Ee("ZodGUID",(e,t)=>{jM.init(e,t),Xn.init(e,t)}),Nf=Ee("ZodUUID",(e,t)=>{$M.init(e,t),Xn.init(e,t)}),xP=Ee("ZodURL",(e,t)=>{LM.init(e,t),Xn.init(e,t)}),EP=Ee("ZodEmoji",(e,t)=>{PM.init(e,t),Xn.init(e,t)}),SP=Ee("ZodNanoID",(e,t)=>{DM.init(e,t),Xn.init(e,t)}),_P=Ee("ZodCUID",(e,t)=>{zM.init(e,t),Xn.init(e,t)}),NP=Ee("ZodCUID2",(e,t)=>{FM.init(e,t),Xn.init(e,t)}),TP=Ee("ZodULID",(e,t)=>{BM.init(e,t),Xn.init(e,t)}),jP=Ee("ZodXID",(e,t)=>{UM.init(e,t),Xn.init(e,t)}),$P=Ee("ZodKSUID",(e,t)=>{HM.init(e,t),Xn.init(e,t)}),CP=Ee("ZodIPv4",(e,t)=>{GM.init(e,t),Xn.init(e,t)}),AP=Ee("ZodIPv6",(e,t)=>{YM.init(e,t),Xn.init(e,t)}),IP=Ee("ZodCIDRv4",(e,t)=>{XM.init(e,t),Xn.init(e,t)}),RP=Ee("ZodCIDRv6",(e,t)=>{JM.init(e,t),Xn.init(e,t)}),OP=Ee("ZodBase64",(e,t)=>{e2.init(e,t),Xn.init(e,t)}),MP=Ee("ZodBase64URL",(e,t)=>{n2.init(e,t),Xn.init(e,t)}),LP=Ee("ZodE164",(e,t)=>{r2.init(e,t),Xn.init(e,t)}),PP=Ee("ZodJWT",(e,t)=>{s2.init(e,t),Xn.init(e,t)}),L_=Ee("ZodNumber",(e,t)=>{v_.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(r,o,s)=>ML(e,r,o,s);const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null},{gt(e,t){return this.check(ix(e,t))},gte(e,t){return this.check(vg(e,t))},min(e,t){return this.check(vg(e,t))},lt(e,t){return this.check(sx(e,t))},lte(e,t){return this.check(yg(e,t))},max(e,t){return this.check(yg(e,t))},int(e){return this.check(fx(e))},safe(e){return this.check(fx(e))},positive(e){return this.check(ix(0,e))},nonnegative(e){return this.check(vg(0,e))},negative(e){return this.check(sx(0,e))},nonpositive(e){return this.check(yg(0,e))},multipleOf(e,t){return this.check(ax(e,t))},step(e,t){return this.check(ax(e,t))},finite(){return this}});function Fs(e){return dL(L_,e)}const DP=Ee("ZodNumberFormat",(e,t)=>{i2.init(e,t),L_.init(e,t)});function fx(e){return fL(DP,e)}const zP=Ee("ZodBoolean",(e,t)=>{a2.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>LL(e,n,r)});function Fo(e){return hL(zP,e)}const FP=Ee("ZodUnknown",(e,t)=>{c2.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>DL()});function hx(){return pL(FP)}const BP=Ee("ZodNever",(e,t)=>{l2.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>PL(e,n,r)});function UP(e){return mL(BP,e)}const HP=Ee("ZodArray",(e,t)=>{rp(),u2.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>HL(e,n,r,o),e.element=t.element},{min(e,t){return this.check(ch(e,t))},nonempty(e){return this.check(ch(1,e))},max(e,t){return this.check(N_(e,t))},length(e,t){return this.check(T_(e,t))},unwrap(){return this.element}});function Aa(e,t){return TL(HP,e,t)}const WP=Ee("ZodObject",(e,t)=>{rp(),h2.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>WL(e,n,r,o),yO(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return Lc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:hx()})},loose(){return this.clone({...this._zod.def,catchall:hx()})},strict(){return this.clone({...this._zod.def,catchall:UP()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return cO(this,e)},safeExtend(e){return lO(this,e)},merge(e){return uO(this,e)},pick(e){return iO(this,e)},omit(e){return aO(this,e)},partial(...e){return Pb(Kw,this,e[0])},exactPartial(...e){return Pb(z_,this,e[0],"exactPartial")},required(...e){return dO(F_,this,e[0])}});function _r(e,t){const n={type:"object",shape:e??{},...mt(t)};return new WP(n)}const P_=Ee("ZodUnion",(e,t)=>{E_.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>KL(e,n,r,o),e.options=t.options});function KP(e,t){return new P_({type:"union",options:e,...mt(t)})}const qP=Ee("ZodDiscriminatedUnion",(e,t)=>{P_.init(e,t),p2.init(e,t)});function ZP(e,t,n){return new qP({type:"union",options:t,discriminator:e,...mt(n)})}const GP=Ee("ZodIntersection",(e,t)=>{m2.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>qL(e,n,r,o)});function VP(e,t){return new GP({type:"intersection",left:e,right:t})}const YP=Ee("ZodTuple",(e,t)=>{rp(),g2.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ZL(e,n,r,o)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){var t;const e=this._zod.def;if((t=e.checks)!=null&&t.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(n=>new Kw({type:"optional",innerType:n}))})}});function D_(e,t,n){const r=t instanceof Kn,o=r?n:t,s=r?t:null;return new YP({type:"tuple",items:e,rest:s,...mt(o)})}const pk=Ee("ZodEnum",(e,t)=>{k2.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(r,o,s)=>zL(e,r,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const s={};for(const a of r)if(n.has(a))s[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new pk({...t,checks:[],...mt(o),entries:s})},e.exclude=(r,o)=>{const s={...t.entries};for(const a of r)if(n.has(a))delete s[a];else throw new Error(`Key ${a} not found in enum`);return new pk({...t,checks:[],...mt(o),entries:s})}});function Lc(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new pk({type:"enum",entries:n,...mt(t)})}const XP=Ee("ZodLiteral",(e,t)=>{w2.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>FL(e,n,r,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Jr(e,t){return new XP({type:"literal",values:Array.isArray(e)?e:[e],...mt(t)})}const QP=Ee("ZodTransform",(e,t)=>{rp(),y2.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>UL(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new a_(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(Cu(s,n.value,t));else{const a=s;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=n.value),a.inst??(a.inst=e),n.issues.push(Cu(a))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n)):(n.value=o,n)}});function JP(e){return new QP({type:"transform",transform:e})}const Kw=Ee("ZodOptional",(e,t)=>{S_.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>O_(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function px(e){return new Kw({type:"optional",innerType:e})}const z_=Ee("ZodExactOptional",(e,t)=>{v2.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>O_(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function eD(e){return new z_({type:"optional",innerType:e})}const tD=Ee("ZodNullable",(e,t)=>{b2.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>GL(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function mx(e){return new tD({type:"nullable",innerType:e})}const nD=Ee("ZodDefault",(e,t)=>{x2.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>YL(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function rD(e,t){return new nD({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():o_(t)}})}const oD=Ee("ZodPrefault",(e,t)=>{E2.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>XL(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function sD(e,t){return new oD({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():o_(t)}})}const F_=Ee("ZodNonOptional",(e,t)=>{S2.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>VL(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function iD(e,t){return new F_({type:"nonoptional",innerType:e,...mt(t)})}const aD=Ee("ZodCatch",(e,t)=>{_2.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>QL(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function cD(e,t){return new aD({type:"catch",innerType:e,catchValue:typeof t=="function"?t:bO(t)})}const lD=Ee("ZodPipe",(e,t)=>{N2.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>JL(e,n,r,o),e.in=t.in,e.out=t.out});function gx(e,t){return new lD({type:"pipe",in:e,out:t})}const uD=Ee("ZodReadonly",(e,t)=>{T2.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>eP(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function dD(e){return new uD({type:"readonly",innerType:e})}const B_=Ee("ZodCustom",(e,t)=>{j2.init(e,t),Yn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>BL(e,n,r,o)});function fD(e,t={}){return jL(B_,e,t)}function hD(e,t){return $L(e,t)}function pD(e,t={}){const n=new B_({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...mt(t)});return n._zod.bag.Class=e,n._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}const mD=["off","tailscale","any"],gD={updates:!0,deploy:!0,remote:"any",agents:null,customAgents:!0,brandedListener:!0,planSignIn:!0};_r({updates:Fo().optional(),deploy:Fo().optional(),remote:Lc(mD).optional(),agents:Aa($n()).optional(),customAgents:Fo().optional(),brandedListener:Fo().optional(),planSignIn:Fo().optional()});const kD={...gD,source:null,problem:null};function wD(e){const t=[];return e.updates||t.push("updates off"),e.deploy||t.push("deploy off"),e.remote!=="any"&&t.push(`remote ${e.remote}`),e.agents!==null&&t.push(`agents ${e.agents.join(", ")||"none"}`),e.customAgents||t.push("custom agents off"),e.brandedListener||t.push("toyon.localhost listener off"),e.planSignIn||t.push("plan sign-in off"),t}const bg=6e3,kx=1500;function yD(e){if(e.length<=bg)return e;const t=e.length-bg;return`${e.slice(0,kx)}
94
- [${t} characters cut here]
95
- ${e.slice(e.length-(bg-kx))}`}const Ta=149,vD=2e3,dh=5e6,bD=["image/png","image/jpeg","image/gif","image/webp"],wx=2576,xg=5*1024*1024,xD=1200,ED=10,SD=1e5,yx=100*1024*1024,_D="pasted-text.txt";function ND(e){return e.t==="term-data"||e.t==="term-snapshot"||e.t==="term-exit"}function TD(e){return e.t==="file-read"||e.t==="file-written"||e.t==="file-blame"}const jD=80;function qw(e){var r;const t=e.split(`
96
- `),n=((r=t.find(o=>o.trim().length>0))==null?void 0:r.trim())??"";return{chars:e.length,lines:t.length,preview:n.slice(0,jD)}}function U_(e){return e.length>=xD||e.split(`
97
- `).length>=ED}function $D({startLine:e,endLine:t}){return e===t?`${e}`:`${e}-${t}`}function CD(e){return`${e.path.slice(e.path.lastIndexOf("/")+1)} (${$D(e)})`}const AD=/\u001B(?:\[[0-?]*[ -/]*[@-~]|\][^\u0007]*(?:\u0007|\u001B\\))/g;function ID(e){return e.replace(AD,"")}function H_(e){const t=/^\s*#{1,6}[ \t]+(.+?)[ \t#]*(?:\r?\n|$)/.exec(e);return t?{title:t[1].trim(),rest:e.slice(t[0].length)}:{title:null,rest:e}}function RD(e){const t=e.plan.trim();return H_(t).title===null?`# ${e.title}
98
-
99
- ${t}
100
- `:`${t}
101
- `}const W_="Projects";function OD(e){for(const t of e){const n=t.codePointAt(0)??0;if(n<32||n===127)return!0}return!1}function Au(e){const t=e.trim();return t?t.length>100?"that name is too long: keep it under 100 characters":t.includes("/")||t.includes("\\")?"a project name cannot contain a slash":/\s/.test(t)?"a project name cannot contain spaces":OD(t)?"a project name cannot contain control characters":t==="."||t===".."?`"${t}" is not a project name`:t.startsWith("-")||t.startsWith(".")?"a project name cannot start with a dot or a dash":null:"a project name is required"}const MD=/^(?:https?|ssh|git|file):\/\/\S+$/i,K_=/^[\w.-]+@[\w.-]+:\S+$/,LD=/^[\w-]+(?:\.[\w-]+)+\/\S+$/;function vx(e){const t=e.trim(),n=LD.test(t)?`https://${t}`:t;if(!MD.test(n)&&!K_.test(n))return null;const r=PD(n),o=zD((r==null?void 0:r.url)??n);return!o||Au(o)?null:r?{url:r.url,name:o,...r.branch?{branch:r.branch}:{}}:{url:n,name:o}}const Eg={"github.com":e=>{if(e.length<2)return null;const[t,...n]=e.slice(2),r=t==="tree"?n.join("/"):t==="blob"||t==="commits"?n[0]:void 0;return{repo:e.slice(0,2),branch:r}},"gitlab.com":e=>{const t=e.indexOf("-");if(t<2)return e.length>=2&&t<0?{repo:e}:null;const[n,...r]=e.slice(t+1),o=n==="tree"?r.join("/"):n==="blob"||n==="commits"?r[0]:void 0;return{repo:e.slice(0,t),branch:o}},"codeberg.org":e=>{if(e.length<2)return null;const[t,n,...r]=e.slice(2),o=t==="src"&&n==="branch"?r[0]:void 0;return{repo:e.slice(0,2),branch:o}}};function PD(e){var o;if(!/^https?:\/\//i.test(e))return null;let t;try{t=new URL(e)}catch{return null}const n=(o=Eg[t.hostname.toLowerCase()])==null?void 0:o.call(Eg,t.pathname.split("/").filter(Boolean));if(!n)return null;const r=n.branch?DD(n.branch).replace(/\/+$/,""):"";return{url:`${t.protocol}//${t.host}/${n.repo.join("/")}`,...r?{branch:r}:{}}}function DD(e){try{return decodeURIComponent(e)}catch{return e}}function zD(e){var o;const t=((o=e.split(/[?#]/)[0])==null?void 0:o.replace(/\/+$/,""))??"";return((K_.test(t)?t.split(":")[1]??"":t).split("/").pop()??"").replace(/\.git$/i,"")}const FD=_r({component:$n().nullable(),file:$n().nullable(),line:Fs().nullable(),callFile:$n().nullable().default(null),callLine:Fs().nullable().default(null),tag:$n(),selector:$n()}),BD=_r({tag:$n().max(40),id:$n().max(200),classes:Aa($n().max(120)).max(16),text:$n().max(200),attrs:Aa(D_([$n().max(40),$n().max(200)])).max(12)}),UD=D_([Fs(),Fs()]),HD=FD.extend({classes:$n(),text:$n(),html:$n(),route:$n(),element:BD}),WD=ZP("type",[_r({type:Jr("loaded"),url:$n(),title:$n()}),_r({type:Jr("navigated"),url:$n(),title:$n().optional()}),_r({type:Jr("traversed"),dir:Lc(["back","forward"]).optional()}),_r({type:Jr("title"),title:$n()}),_r({type:Jr("links"),links:Aa(_r({path:$n().max(2048),text:$n().max(120)})).max(200)}),_r({type:Jr("hmr")}),_r({type:Jr("touch"),phase:Lc(["start","move","end","cancel"]),x:Fs(),y:Fs()}),_r({type:Jr("page-error"),message:$n(),source:$n().optional(),line:Fs().optional()}),HD.extend({type:Jr("picked"),verb:Lc(["chat","code"]).default("chat"),site:Lc(["call","source"]).default("source")}),_r({type:Jr("pick-cancel")}),_r({type:Jr("highlight-miss"),path:$n(),fileMatched:Fs(),withSource:Fs(),ranges:Aa(UD).nullable()}),_r({type:Jr("drag-files"),over:Fo().default(!0)}),_r({type:Jr("drop-files"),files:Aa(pD(File))}),_r({type:Jr("focus"),gesture:Fo()}),_r({type:Jr("key"),key:$n(),code:$n().optional(),meta:Fo(),ctrl:Fo().optional(),shift:Fo().optional(),alt:Fo().optional(),up:Fo().optional()})]);function q_(e){const t=WD.safeParse(e);return t.success?t.data:null}const KD=["rows","repos","visits","themes"];function qD(e){return KD.map(t=>e[t]??"").join(".")}const ZD=/["“”]([^"“”]*)["“”]?|(\S+)/g;function Z_(e){const t=new Set;for(const n of e.matchAll(ZD)){const r=(n[1]??n[2]??"").replace(/\s+/g," ").trim().toLowerCase();r&&t.add(r)}return[...t]}const GD="now",VD="http://preview.invalid",YD=200;function bx(e){const t=e==null?void 0:e.replace(/\s+/g," ").trim().slice(0,YD).trim();return t||void 0}function op(e){let t;try{t=new URL(e,VD)}catch{return null}if(t.pathname.startsWith("/__toyon"))return null;const n=xx(t.pathname)||"/",r=t.hash.startsWith("#/")?xx(t.hash.split("?")[0]??""):"";return r.length>1?`${n}${r}`:n}const xx=e=>e.replace(/\/+$/,""),XD={static:4,mixed:3.5,param:3,optional:2,"optional-static":2,splat:1},fh=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function G_(e){const t=/^\[\[\.\.\.([^\]]*)\]\]$/.exec(e);if(t)return{kind:"splat",name:t[1]||"path",min:0};const n=/^\[\.\.\.([^\]]*)\]$/.exec(e);if(n)return{kind:"splat",name:n[1]||"path",min:1};const r=/^\[\[([^\]]+)\]\]$/.exec(e)??/^:([\w-]+)\?$/.exec(e)??/^\{-\$([\w-]+)\}$/.exec(e);if(r)return{kind:"optional",name:r[1]};const o=/^\[([^\]=]+)(?:=[^\]]*)?\]$/.exec(e)??/^:([\w-]+)$/.exec(e)??/^\$([\w-]+)$/.exec(e);if(o)return{kind:"param",name:o[1]};if(e==="*"||e==="$")return{kind:"splat",name:"path",min:0};if(/^[^[{:$*?]+\?$/.test(e))return{kind:"optional-static",text:e.slice(0,-1)};if(/[[{]/.test(e)){const s=[];let a="",l=0;for(const f of e.matchAll(/\[([^\]=]+)(?:=[^\]]*)?\]|\{\$([\w-]+)\}/g)){const h=e.slice(l,f.index);h&&(s.push({text:h}),a+=fh(h)),s.push({name:f[1]??f[2]??"param"}),a+="[^/]+?",l=(f.index??0)+f[0].length}const u=e.slice(l);if(u&&(s.push({text:u}),a+=fh(u)),s.some(f=>"name"in f))return{kind:"mixed",pattern:a,parts:s}}return{kind:"static",text:e}}function QD(e){const t=e.split("/").filter(Boolean).map(G_);if(t.every(r=>r.kind==="static"))return null;let n="";for(const r of t)r.kind==="static"?n+=`/${fh(r.text)}`:r.kind==="optional-static"?n+=`(?:/${fh(r.text)})?`:r.kind==="param"?n+="/[^/]+":r.kind==="optional"?n+="(?:/[^/]+)?":r.kind==="splat"?n+=r.min?"/.+":"(?:/.*)?":n+=`/${r.pattern}`;return{path:e,re:new RegExp(`^${n}$`),specificity:t.reduce((r,o)=>r+XD[o.kind],0),statics:t.filter(r=>r.kind==="static").length}}function JD(e,t){let n=null;for(const r of e)r.statics===0||!r.re.test(t)||(!n||r.specificity>n.specificity)&&(n=r);return n}function sp(e){let t="";const n=[],r=o=>{n.push([t.length,t.length+o.length]),t+=o};for(const o of e.split("/").filter(Boolean).map(G_))if(t+="/",o.kind==="static"||o.kind==="optional-static")t+=o.text;else if(o.kind==="mixed")for(const s of o.parts)"name"in s?r(s.name):t+=s.text;else r(o.name);return t||(t="/"),{text:t,params:n,literal:n.length>0?t.slice(0,n[0][0]):t}}const Xu={id:"toyon-dark",family:"Toyon",name:"Toyon Dark",kind:"dark",source:"builtin",pair:"toyon-light",colors:{surface0:"#32302d",surface1:"#3d3835",surface2:"#504943",element0:"#504943",element1:"#675c55",border0:"#504943",border1:"#675c55",text0:"#e6dcb6",text1:"#9e927e",text2:"#6a6055",red:"#ff4929",orange:"#fa891e",yellow:"#fcbe03",green:"#78c945",aqua:"#4dc7a7",blue:"#69a9e8",purple:"#ca94ca",diffAdd:"#6fae5f29",diffDel:"#c07f6a29"},syntax:{comment:"#6a6055",keyword:"#df714e",string:"#a5bd4d",number:"#ca94ca",type:"#f5bf3a",function:"#6bc198",variable:"#81a99d"},link:"#83a9cf"},V_={id:"toyon-light",family:"Toyon",name:"Toyon Light",kind:"light",source:"builtin",pair:"toyon-dark",colors:{surface0:"#f8f2e8",surface1:"#efe8dc",surface2:"#dfd7c9",element0:"#dfd7c9",element1:"#c7bdac",border0:"#dfd7c9",border1:"#c7bdac",text0:"#463627",text1:"#6e5e51",text2:"#b4aa9f",red:"#b02e15",orange:"#b15b02",yellow:"#ac7e02",green:"#3c8c03",aqua:"#01775c",blue:"#12689e",purple:"#865889",diffAdd:"#4f7a3d2e",diffDel:"#9c5a452e"},syntax:{comment:"#b4aa9f",keyword:"#b54d2d",string:"#697f1e",number:"#865889",type:"#ac7e02",function:"#397f5f",variable:"#57796f"},link:"#3e6888"},e4={id:"gruvbox-dark-soft",family:"Gruvbox",name:"Gruvbox Dark Soft",kind:"dark",source:"builtin",pair:"gruvbox-light",colors:{surface0:"#32302f",surface1:"#3c3836",surface2:"#504945",element0:"#504945",element1:"#665c54",border0:"#504945",border1:"#665c54",text0:"#ebdbb2",text1:"#a89984",text2:"#928374",red:"#fb4934",orange:"#fe8019",yellow:"#fabd2f",green:"#b8bb26",aqua:"#8ec07c",blue:"#83a598",purple:"#d3869b",diffAdd:"#b8bb261f",diffDel:"#fb49341f"},syntax:{comment:"#928374",keyword:"#fb4934",string:"#b8bb26",number:"#d3869b",type:"#fabd2f",function:"#8ec07c",variable:"#83a598"}},t4={id:"gruvbox-light",family:"Gruvbox",name:"Gruvbox Light",kind:"light",source:"builtin",pair:"gruvbox-dark-soft",colors:{surface0:"#f4f2ee",surface1:"#ebe8e2",surface2:"#dcd8d0",element0:"#dcd8d0",element1:"#c3beb4",border0:"#dcd8d0",border1:"#c3beb4",text0:"#3c3836",text1:"#655f5a",text2:"#837c74",red:"#9d0006",orange:"#af3a03",yellow:"#b57614",green:"#79740e",aqua:"#427b58",blue:"#076678",purple:"#8f3f71",diffAdd:"#79740e26",diffDel:"#9d000626"},syntax:{comment:"#837c74",keyword:"#9d0006",string:"#79740e",number:"#8f3f71",type:"#b57614",function:"#427b58",variable:"#076678"}},n4={id:"vscode-dark-modern",family:"VS Code Modern",pair:"vscode-light-modern",name:"VS Code Dark Modern",kind:"dark",source:"builtin",colors:{surface0:"#1f1f1f",surface1:"#181818",surface2:"#2a2d2e",element0:"#2a2d2e",element1:"#2b2b2b",border0:"#2a2d2e",border1:"#2b2b2b",text0:"#cccccc",text1:"#9d9d9d",text2:"#6e7681",red:"#f85149",orange:"#0078d4",yellow:"#f5f543",green:"#23d18b",aqua:"#29b8db",blue:"#4daafc",purple:"#d670d6",diffAdd:"#23d18b1f",diffDel:"#f851491f"},syntax:{comment:"#6a9955",keyword:"#569cd6",string:"#ce9178",number:"#b5cea8",type:"#4ec9b0",function:"#dcdcaa",variable:"#9cdcfe"}},r4={id:"vscode-light-modern",family:"VS Code Modern",pair:"vscode-dark-modern",name:"VS Code Light Modern",kind:"light",source:"builtin",colors:{surface0:"#ffffff",surface1:"#f8f8f8",surface2:"#f2f2f2",element0:"#f2f2f2",element1:"#e5e5e5",border0:"#f2f2f2",border1:"#e5e5e5",text0:"#3b3b3b",text1:"#3b3b3b",text2:"#6e7681",red:"#f85149",orange:"#005fb8",yellow:"#949800",green:"#00bc00",aqua:"#0598bc",blue:"#005fb8",purple:"#bc05bc",diffAdd:"#00bc001f",diffDel:"#f851491f"},syntax:{comment:"#008000",keyword:"#0000ff",string:"#a31515",number:"#098658",type:"#267f99",function:"#795e26",variable:"#001080"}},o4={id:"vscode-2026-dark",family:"VS Code 2026",pair:"vscode-2026-light",name:"VS Code Dark 2026",kind:"dark",source:"builtin",colors:{surface0:"#121314",surface1:"#191a1b",surface2:"#2b2c2d",element0:"#2b2c2d",element1:"#2a2b2c",border0:"#2b2c2d",border1:"#2a2b2c",text0:"#bbbebf",text1:"#8c8c8c",text2:"#555555",red:"#f48771",orange:"#2d6e8a",yellow:"#e5ba7d",green:"#73c991",aqua:"#29b8db",blue:"#48a0c7",purple:"#d670d6",diffAdd:"#347d3926",diffDel:"#c93c3726"},syntax:{comment:"#8b949e",keyword:"#ff7b72",string:"#a5d6ff",number:"#b5cea8",type:"#4ec9b0",function:"#dcdcaa",variable:"#ffa657"}},s4={id:"vscode-2026-light",family:"VS Code 2026",pair:"vscode-2026-dark",name:"VS Code Light 2026",kind:"light",source:"builtin",colors:{surface0:"#ffffff",surface1:"#fafafd",surface2:"#e6e6e9",element0:"#e6e6e9",element1:"#f0f1f2",border0:"#e6e6e9",border1:"#f0f1f2",text0:"#202020",text1:"#606060",text2:"#bbbbbb",red:"#ad0707",orange:"#0069cc",yellow:"#667309",green:"#587c0c",aqua:"#0598bc",blue:"#0069cc",purple:"#bc05bc",diffAdd:"#587c0c26",diffDel:"#ad070726"},syntax:{comment:"#6e7781",keyword:"#cf222e",string:"#0a3069",number:"#098658",type:"#267f99",function:"#795e26",variable:"#953800"}},i4={id:"tokyo-night",family:"Tokyo Night",name:"Tokyo Night",kind:"dark",source:"builtin",pair:"tokyo-night-light",colors:{surface0:"#1a1b26",surface1:"#16161e",surface2:"#13131a",element0:"#13131a",element1:"#101014",border0:"#13131a",border1:"#101014",text0:"#a9b1d6",text1:"#515670",text2:"#545c7e",red:"#f7768e",orange:"#3d59a1",yellow:"#e0af68",green:"#73daca",aqua:"#7dcfff",blue:"#7aa2f7",purple:"#bb9af7",diffAdd:"#41a6b520",diffDel:"#db4b4b22"},syntax:{comment:"#51597d",keyword:"#bb9af7",string:"#9ece6a",number:"#ff9e64",type:"#0db9d7",function:"#0db9d7",variable:"#c0caf5"}},a4={id:"tokyo-night-light",family:"Tokyo Night",name:"Tokyo Night Light",kind:"light",source:"builtin",pair:"tokyo-night",colors:{surface0:"#e6e7ed",surface1:"#d6d8df",surface2:"#e1e2e8",element0:"#e1e2e8",element1:"#c1c2c7",border0:"#e1e2e8",border1:"#c1c2c7",text0:"#343b59",text1:"#707280",text2:"#707280",red:"#8c4351",orange:"#2959aa",yellow:"#8f5e15",green:"#33635c",aqua:"#006c86",blue:"#2959aa",purple:"#7b43ba",diffAdd:"#2d9c9120",diffDel:"#e8686812"},syntax:{comment:"#888b94",keyword:"#65359d",string:"#385f0d",number:"#965027",type:"#006c86",function:"#006c86",variable:"#343b58"}},c4={id:"rose-pine",family:"Rosé Pine",name:"Rosé Pine",kind:"dark",source:"builtin",pair:"rose-pine-dawn",colors:{surface0:"#191724",surface1:"#191724",surface2:"#221f2e",element0:"#221f2e",element1:"#191724",border0:"#221f2e",border1:"#191724",text0:"#e0def4",text1:"#908caa",text2:"#908caa",red:"#eb6f92",orange:"#ebbcba",yellow:"#f6c177",green:"#31748f",aqua:"#ebbcba",blue:"#9ccfd8",purple:"#c4a7e7",diffAdd:"#9ccfd826",diffDel:"#eb6f9226"},syntax:{comment:"#6e6a86",keyword:"#31748f",string:"#f6c177",number:"#ebbcba",type:"#9ccfd8",function:"#eb6f92",variable:"#ebbcba"}},l4={id:"rose-pine-dawn",family:"Rosé Pine",name:"Rosé Pine Dawn",kind:"light",source:"builtin",pair:"rose-pine",colors:{surface0:"#faf4ed",surface1:"#faf4ed",surface2:"#f3ede8",element0:"#f3ede8",element1:"#faf4ed",border0:"#f3ede8",border1:"#faf4ed",text0:"#575279",text1:"#797593",text2:"#797593",red:"#b4637a",orange:"#d7827e",yellow:"#ea9d34",green:"#286983",aqua:"#d7827e",blue:"#56949f",purple:"#907aa9",diffAdd:"#56949f26",diffDel:"#b4637a26"},syntax:{comment:"#9893a5",keyword:"#286983",string:"#ea9d34",number:"#d7827e",type:"#56949f",function:"#b4637a",variable:"#d7827e"}},u4={id:"one-dark-pro",family:"One Dark Pro",name:"One Dark Pro",kind:"dark",source:"builtin",pair:"one-light",colors:{surface0:"#282c34",surface1:"#21252b",surface2:"#2c313a",element0:"#2c313a",element1:"#3e4452",border0:"#2c313a",border1:"#3e4452",text0:"#abb2bf",text1:"#abb2bf",text2:"#495162",red:"#e05561",orange:"#4d78cc",yellow:"#d18f52",green:"#8cc265",aqua:"#42b3c2",blue:"#4aa5f0",purple:"#c162de",diffAdd:"#00809b33",diffDel:"#e055611f"},syntax:{comment:"#7f848e",keyword:"#c678dd",string:"#98c379",number:"#d19a66",type:"#e5c07b",function:"#56b6c2",variable:"#e06c75"}},d4={id:"one-light",family:"One Dark Pro",name:"One Light",kind:"light",source:"builtin",pair:"one-dark-pro",colors:{surface0:"#fafafa",surface1:"#eaeaeb",surface2:"#e4e4e5",element0:"#e4e4e5",element1:"#e5e5e6",border0:"#e4e4e5",border1:"#e5e5e6",text0:"#383a42",text1:"#3b3b3b",text2:"#9d9d9f",red:"#cd3131",orange:"#526fff",yellow:"#949800",green:"#00bc00",aqua:"#0598bc",blue:"#0451a5",purple:"#bc05bc",diffAdd:"#00809b33",diffDel:"#cd31311f"},syntax:{comment:"#a0a1a7",keyword:"#a626a4",string:"#50a14f",number:"#986801",type:"#0184bc",function:"#0184bc",variable:"#e45649"}},f4={id:"solarized-dark",family:"Solarized",name:"Solarized Dark",kind:"dark",source:"builtin",pair:"solarized-light",colors:{surface0:"#002b36",surface1:"#00212b",surface2:"#003846",element0:"#003846",element1:"#2b2b4a",border0:"#003846",border1:"#2b2b4a",text0:"#839496",text1:"#93a1a1",text2:"#4a6166",red:"#dc322f",orange:"#197271",yellow:"#b58900",green:"#859900",aqua:"#2aa198",blue:"#268bd2",purple:"#d33682",diffAdd:"#8599001f",diffDel:"#dc322f1f"},syntax:{comment:"#586e75",keyword:"#859900",string:"#2aa198",number:"#d33682",type:"#859900",function:"#268bd2",variable:"#268bd2"}},h4={id:"solarized-light",family:"Solarized",name:"Solarized Light",kind:"light",source:"builtin",pair:"solarized-dark",colors:{surface0:"#fdf6e3",surface1:"#eee8d5",surface2:"#eae0c0",element0:"#eae0c0",element1:"#ddd6c1",border0:"#eae0c0",border1:"#ddd6c1",text0:"#657b83",text1:"#586e75",text2:"#a3aba5",red:"#dc322f",orange:"#b58900",yellow:"#b58900",green:"#859900",aqua:"#2aa198",blue:"#268bd2",purple:"#d33682",diffAdd:"#8599001f",diffDel:"#dc322f1f"},syntax:{comment:"#93a1a1",keyword:"#859900",string:"#2aa198",number:"#d33682",type:"#859900",function:"#268bd2",variable:"#268bd2"}},p4={id:"nord",family:"Nord",name:"Nord",kind:"dark",source:"builtin",colors:{surface0:"#2e3440",surface1:"#2e3440",surface2:"#3b4252",element0:"#3b4252",element1:"#3b4252",border0:"#3b4252",border1:"#3b4252",text0:"#d8dee9",text1:"#c7cdd8",text2:"#4c566a",red:"#bf616a",orange:"#88c0d0",yellow:"#ebcb8b",green:"#a3be8c",aqua:"#88c0d0",blue:"#81a1c1",purple:"#b48ead",diffAdd:"#81a1c133",diffDel:"#bf616a4d"},syntax:{comment:"#616e88",keyword:"#81a1c1",string:"#a3be8c",number:"#b48ead",type:"#8fbcbb",function:"#88c0d0",variable:"#d8dee9"}},m4={id:"catppuccin-mocha",family:"Catppuccin",name:"Catppuccin Mocha",kind:"dark",source:"builtin",pair:"catppuccin-latte",colors:{surface0:"#1e1e2e",surface1:"#181825",surface2:"#313244",element0:"#313244",element1:"#45475a",border0:"#313244",border1:"#45475a",text0:"#cdd6f4",text1:"#a6adc8",text2:"#7f849c",red:"#f38ba8",orange:"#fab387",yellow:"#f9e2af",green:"#a6e3a1",aqua:"#94e2d5",blue:"#89b4fa",purple:"#cba6f7",diffAdd:"#a6e3a11f",diffDel:"#f38ba81f"},syntax:{comment:"#9399b2",keyword:"#cba6f7",string:"#a6e3a1",number:"#fab387",type:"#f9e2af",function:"#89b4fa",variable:"#cdd6f4"}},g4={id:"catppuccin-latte",family:"Catppuccin",name:"Catppuccin Latte",kind:"light",source:"builtin",pair:"catppuccin-mocha",colors:{surface0:"#eff1f5",surface1:"#e6e9ef",surface2:"#ccd0da",element0:"#ccd0da",element1:"#bcc0cc",border0:"#ccd0da",border1:"#bcc0cc",text0:"#4c4f69",text1:"#6c6f85",text2:"#8c8fa1",red:"#d20f39",orange:"#fe640b",yellow:"#df8e1d",green:"#40a02b",aqua:"#179299",blue:"#1e66f5",purple:"#8839ef",diffAdd:"#40a02b1f",diffDel:"#d20f391f"},syntax:{comment:"#7c7f93",keyword:"#8839ef",string:"#40a02b",number:"#fe640b",type:"#df8e1d",function:"#1e66f5",variable:"#4c4f69"}},k4=[i4,a4,c4,l4,u4,d4,f4,h4,p4,m4,g4],Zf=[Xu,V_,e4,t4,n4,r4,o4,s4,...k4],w4={mode:"dark",light:V_.id,dark:Xu.id},y4=["surface0","surface1","surface2","element0","element1","border0","border1","text0","text1","text2","red","orange","yellow","green","aqua","blue","purple","diffAdd","diffDel"];function v4(e){return`--${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function mk(e){return Y_(Ia(e))}function Y_(e){return e>.008856?116*e**(1/3)-16:903.3*e}function Zw(e,t){const n=mk(e)+t,r=za(e);if(!r)return e;let o=0,s=2;for(let a=0;a<24;a++){const l=(o+s)/2,u=Qc(Math.min(255,r[0]*l),Math.min(255,r[1]*l),Math.min(255,r[2]*l));mk(u)<n?o=l:s=l}return Qc(Math.min(255,r[0]*o),Math.min(255,r[1]*o),Math.min(255,r[2]*o))}function b4(e){return Zw(e.colors.surface1,-4)}function x4(e){return Zw(e.colors.surface0,-4)}const Ex=["surface0","surface1","surface2","element0","element1","border0","border1"];function E4(e){if(e.kind!=="dark")return e;const t=Ex.reduce((o,s)=>Ia(e.colors[s])<Ia(e.colors[o])?s:o),n=e.colors[t];if(Ia(n)<=0)return e;const r={...e.colors};for(const o of[...Ex,"text1","text2"]){const s=O4(e.colors[o],n)*.05-.05;r[o]=Zw(r[o],Y_(s)-mk(r[o]))}return r.surface0="#000000",r.surface1="#000000",{...e,colors:r}}function Sx(e){return R4(e,.55)}function S4(e){const t=e.colors,n=e.syntax??{};return{comment:n.comment??t.text2,keyword:n.keyword??t.orange,string:n.string??t.green,number:n.number??t.purple,type:n.type??t.yellow,function:n.function??t.aqua,variable:n.variable??t.blue}}function _4(e){const t={};for(const n of y4)t[v4(n)]=e.colors[n];t["--ink0"]=e.colors.text0,t["--ink1"]=e.colors.text1,t["--ink2"]=e.colors.text2;for(const[n,r]of Object.entries(S4(e)))t[`--syntax-${n}`]=r;return t["--accent"]=Gw(e),t["--fault"]=N4(e),t["--link"]=T4(e),t["--sunken"]=b4(e),t["--sunken-floor"]=x4(e),t["--scrim"]=I4(e.colors.surface0,.7),t["--shadow"]=e.kind==="dark"?"#00000066":"#0000002e",t["--diff-add-word"]=Sx(e.colors.diffAdd),t["--diff-del-word"]=Sx(e.colors.diffDel),t}function Gw(e){return Yw(e.accent??"")??e.colors.orange}function N4(e){return Gw(e)===Yw(e.colors.orange)?e.colors.red:e.colors.orange}function T4(e){return Yw(e.link??"")??e.colors.blue}function j4(e){return e==="system"||e==="daylight"}function Vw(e,t){return e.mode==="system"?t.system?"dark":"light":e.mode==="daylight"?t.daylight?"dark":"light":e.mode}function ip(e,t,n){const r=Vw(e,n);return t.find(o=>o.id===e[r])??Zf.find(o=>o.kind===r)??Xu}function $4(e,t){if(e.pair){const a=t.find(l=>l.id===e.pair);if(a&&a.kind!==e.kind)return a}const n=e.kind==="dark"?"light":"dark",r=a=>a.toLowerCase().replace(/\b(dark|light)\b/g,"*").replace(/\s+/g," ").trim(),o=r(e.name);if(!o.includes("*"))return null;const s=e.id.startsWith("vscode:")?e.id.slice(0,e.id.lastIndexOf(":")+1):null;return t.find(a=>a.kind===n&&a.source===e.source&&(!s||a.id.startsWith(s))&&r(a.name)===o)??null}function C4(e){const t=[],n=new Set,r=o=>o.family??(o.name.replace(/\b(dark|light)\b/gi,"").replace(/\s+/g," ").trim()||o.name);for(const o of e){if(n.has(o.id))continue;const s=$4(o,e),a={name:r(o)};a[o.kind]=o,n.add(o.id),s&&(a[s.kind]=s,n.add(s.id)),t.push(a)}return t}function A4(e,t){const n={...e};return t.dark&&(n.dark=t.dark.id),t.light&&(n.light=t.light.id),!j4(n.mode)&&!t[n.mode]&&(n.mode=t.dark?"dark":"light"),n}function za(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());if(!t)return null;let n=t[1];if((n.length===3||n.length===4)&&(n=[...n].map(o=>o+o).join("")),n.length!==6&&n.length!==8)return null;const r=o=>parseInt(n.slice(o,o+2),16);return[r(0),r(2),r(4),n.length===8?r(6)/255:1]}function Yw(e){const t=za(e);return t?Qc(t[0],t[1],t[2],t[3]):null}function Qc(e,t,n,r=1){const o=s=>Math.round(Math.max(0,Math.min(255,s))).toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}${r>=1?"":o(r*255)}`}function I4(e,t){const n=za(e);return n?Qc(n[0],n[1],n[2],t):e}function R4(e,t){const n=za(e);return n?Qc(n[0],n[1],n[2],Math.min(1,n[3]*t)):e}function GX(e,t){const n=za(e),r=za(t);if(!n||!r)return e;const o=n[3];return Qc(n[0]*o+r[0]*(1-o),n[1]*o+r[1]*(1-o),n[2]*o+r[2]*(1-o))}function Ia(e){const t=za(e);if(!t)return 0;const n=r=>{const o=r/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4};return .2126*n(t[0])+.7152*n(t[1])+.0722*n(t[2])}function O4(e,t){const n=Ia(e),r=Ia(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function M4(e){return Ia(e)>.179?"#1d2021":"#fbf1c7"}function gk(e){if(e===null||e==="")return"the npm registry";try{return new URL(e).host}catch{return e}}function X_(e,t){const n=_x(e),r=_x(t);if(!n||!r)return!1;for(let o=0;o<3;o++){const s=n.nums[o]??0,a=r.nums[o]??0;if(s!==a)return s>a}return n.pre===r.pre?!1:n.pre===null?!0:r.pre===null?!1:n.pre>r.pre}function _x(e){const t=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(e.trim());return t?{nums:[Number(t[1]),Number(t[2]),Number(t[3])],pre:t[4]??null}:null}const L4=[[/\.(png|jpe?g|gif|webp|avif|bmp|ico)$/i,"image"],[/\.(mp4|m4v|webm|mov)$/i,"video"]];function P4(e){var t;return((t=L4.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const D4=[[/\.(md|markdown)$/i,"markdown"],[/\.html?$/i,"html"],[/\.svg$/i,"svg"]];function Wa(e){var t;return((t=D4.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const it={active:"toyon-active",phoneRow:"toyon-phone-row",repo:"toyon-repo",lastActive:"toyon-last",discoveredOpen:"toyon-disc",archivedOpen:"toyon-arch",committedShut:"toyon-committed-shut",turnOpen:"toyon-turn-open",treeOpen:"toyon-tree",token:"toyon-token",theme:"toyon-theme",daylight:"toyon-sun",changesWidth:"toyon-changes-w",chatWidth:"toyon-chat-w",editorHeight:"toyon-dh",editorFull:"toyon-dfull",editorWrap:"toyon-dwrap",editorSplit:"toyon-dsplit",designHeight:"toyon-dsh",designFull:"toyon-dsfull",termHeight:"toyon-th",rail:"toyon-rail",railWidth:"toyon-rail-w",chatSide:"toyon-chat-side",clipboardOffer:"toyon-clipboard-offer",blackGround:"toyon-black",installOffered:"toyon-install-offered",layouts:"toyon-layouts",client:"toyon-client",ground:"toyon-ground",version:"toyon-version"},z4=[it.active,it.repo,it.lastActive,it.discoveredOpen,it.archivedOpen,it.committedShut,it.turnOpen,it.treeOpen,it.phoneRow,it.version],Gf=(e,t)=>`${e}@${t}`,F4="toyon",nu="snapshots",mo={hello:e=>`hello@${e}`,chat:(e,t)=>`chat@${e}/${t}`,chats:e=>`chat@${e}/`};function B4(e,t=typeof localStorage>"u"?null:localStorage,n=typeof sessionStorage>"u"?null:sessionStorage){const r=a=>({get(l){try{return(a==null?void 0:a.getItem(Gf(l,e)))??null}catch{return null}},set(l,u){try{a==null||a.setItem(Gf(l,e),u)}catch{}},remove(l){try{a==null||a.removeItem(Gf(l,e))}catch{}}}),o=r(t),s=r(n);return{...o,session:{get:s.get,set:s.set},clear(){for(const a of[t,n])for(const l of kk(a).filter(u=>u.endsWith(`@${e}`)))try{a==null||a.removeItem(l)}catch{}}}}function kk(e){const t=[];try{for(let n=0;n<((e==null?void 0:e.length)??0);n++){const r=e==null?void 0:e.key(n);r!=null&&t.push(r)}}catch{}return t}const U4="orch-";function H4(e,t=typeof localStorage>"u"?null:localStorage,n=typeof sessionStorage>"u"?null:sessionStorage){for(const[r,o]of[[t,["active","token","theme","editorHeight","editorFull"]],[n,["client"]]])for(const s of o){const a=it[s],l=U4+a.slice(6);Nx(r,l,a)}for(const[r,o]of[[t,z4.filter(s=>s!==it.phoneRow)],[n,[it.phoneRow]]]){const s=kk(r).filter(a=>!a.includes("@"));for(const a of o)for(const l of s.filter(u=>u===a))Nx(r,l,Gf(l,e))}for(const r of kk(t))W4.some(o=>r.startsWith(o))&&K4(t,r)}const W4=["toyon-profile-","toyon-mode-","toyon-model-","toyon-effort-","toyon-mono-face"];function K4(e,t){try{e==null||e.removeItem(t)}catch{}}function Nx(e,t,n){try{const r=e==null?void 0:e.getItem(t);if(r==null)return;(e==null?void 0:e.getItem(n))===null&&e.setItem(n,r),e==null||e.removeItem(t)}catch{}}function Q_(){const e=location.hash.match(/token=([a-f0-9]+)/);if(e!=null&&e[1])return J_(e[1]),e[1];try{return localStorage.getItem(it.token)??sessionStorage.getItem(it.token)??""}catch{return""}}function J_(e){try{localStorage.setItem(it.token,e)}catch{}}function hh(){return Q_()!==""}function Xw(e,t){const n=new URL(e),r=`token=${t}`,o=s=>`&v=${encodeURIComponent(s??"")}`;return{origin:n.origin,host:n.hostname,token:t,ws:`${n.protocol==="https:"?"wss":"ws"}://${n.host}/ws?${r}`,attachment:(s,a)=>`${n.origin}/attachments/${s}/${a}?${r}`,attachmentWhere:(s,a)=>`${n.origin}/attachments/${s}/${a}?${r}&where`,upload:s=>`${n.origin}/uploads/${s}?${r}`,worktreeFile:(s,a,l)=>`${n.origin}/files/${s}/${a.split("/").map(encodeURIComponent).join("/")}?${r}${o(l)}`,loose:(s,a)=>`${n.origin}/loose/${encodeURIComponent(s)}?${r}${o(a)}`,health:`${n.origin}/health`,restart:s=>`${n.origin}/restart?${r}${s?`&${GD}`:""}`,uploads:s=>`${n.origin}/uploads?kind=${s}`,tailnet:`${n.origin}/tailnet`,remote:`${n.origin}/remote`,tailscale:`${n.origin}/tailscale`,machines:`${n.origin}/machines`,knockAnswer:s=>`${n.origin}/knock/${s}/answer`,previewGrant:`${n.origin}/preview-grant`,frame:`${n.origin}/frame`,changelog:`${n.origin}/changelog`}}const Ka=e=>({authorization:`Bearer ${e.token}`});async function q4(e,t,n,r){try{await n.slice(0,1).arrayBuffer()}catch{return"could not be read"}return new Promise(o=>{const s=new XMLHttpRequest;s.open("POST",e.uploads(t)),s.setRequestHeader("authorization",Ka(e).authorization),s.setRequestHeader("content-type",n.type||"application/octet-stream"),r&&(s.upload.onprogress=a=>a.lengthComputable&&r(a.loaded/a.total)),s.onload=()=>{if(s.status>=502&&s.status<=504)return o(null);if(s.status<200||s.status>=300)return o(s.responseText||"could not be attached");try{o(JSON.parse(s.responseText))}catch{o("could not be attached")}},s.onerror=()=>o(null),s.onabort=()=>o(null),s.send(n)})}async function Z4(e,t=!1){try{const n=await fetch(e.restart(t),{method:"POST"});return n.ok?null:await n.text()||"Toyon did not restart"}catch{return null}}async function eN(e){try{const t=await fetch(e.restart(!1),{signal:AbortSignal.timeout(2e3)});if(!t.ok)return null;const{waiting:n,asking:r}=await t.json();return Array.isArray(n)?{waiting:n,asking:Array.isArray(r)?r:[]}:null}catch{return null}}async function G4(e){var t;try{const n=await fetch(e.changelog,{headers:Ka(e)});return!n.ok||!((t=n.headers.get("content-type"))!=null&&t.startsWith("text/markdown"))?null:await n.text()}catch{return null}}async function V4(e,t){try{const n=await fetch(t,{headers:Ka(e)});return n.ok?await n.json():null}catch{return null}}async function ap(e,t,n,r){try{const o=await fetch(t,{method:"POST",headers:{...Ka(e),"content-type":"application/json"},body:JSON.stringify(n)});return o.ok?null:await o.text()||`refused (${o.status})`}catch{return r}}const Y4=e=>V4(e,e.tailnet),X4=e=>ap(e,e.remote,{tailscale:!0},"Toyon is not answering; try again once it is back."),Q4=e=>ap(e,e.remote,{off:!0},"Toyon is not answering; try again once it is back.");async function tN(e,t,n){try{const r=await fetch(t,{method:"POST",headers:{...Ka(e),"content-type":"application/json"},body:JSON.stringify(n)});return r.ok?await r.json():null}catch{return null}}const nN="Toyon is not answering; try again once it is back.",J4=async e=>{const t=await tN(e,e.tailscale,{up:!0});return t===null?nN:t.refused},ez=async e=>await tN(e,e.tailscale,{login:!0})??{why:nN},tz=(e,t,n)=>ap(e,e.machines,{origin:t,token:n},"Toyon here is not answering; the machine is not listed yet."),nz=(e,t,n)=>ap(e,e.knockAnswer(t),{letIn:n},"Toyon is not answering");async function rN(e){try{const t=await fetch(e.previewGrant,{method:"POST",headers:Ka(e)});return t.ok?await t.json():null}catch{return null}}async function rz(e,t){try{const n=await fetch(e.frame,{method:"POST",headers:{...Ka(e),"content-type":"application/json"},body:JSON.stringify(t)});return n.ok?await n.json():n.status===400||n.status===503?await n.text():null}catch{return null}}const oz=2e3;async function oN(e,t,n){let r;try{const o=await fetch(`${e}/knock`,{method:"POST",signal:t});if(o.status===429)return"full";if(!o.ok)return"not-toyon";r=await o.json()}catch{return t.aborted?"gone":"unreachable"}if(typeof r.id!="string"||typeof r.word!="string")return"not-toyon";for(n(r.word);!t.aborted;){try{const o=await fetch(`${e}/knock/${r.id}`,{cache:"no-store",signal:t});if(o.status===404)return"gone";if(o.ok){const s=await o.json();if(s.state==="let-in"&&typeof s.token=="string"&&s.token)return{token:s.token};if(s.state==="refused")return"refused"}}catch{}await new Promise(o=>setTimeout(o,oz))}return"gone"}async function wk(e){try{const t=await fetch(e.health,{signal:AbortSignal.timeout(2e3)});return t.ok?(await t.json()).pid??null:null}catch{return null}}const sz=1e3,iz=3e4,az=1500,cz=5e3,Tx=50,lz=e=>e.t==="chat"||e.t==="create-worktree"||e.t==="restore-worktree";class uz{constructor(t,n,r,o={},s={}){_t(this,"ws",null);_t(this,"queue",[]);_t(this,"closed",!1);_t(this,"attempt",0);_t(this,"timer",null);_t(this,"downAt",null);_t(this,"downCode",0);_t(this,"sayTimer",null);_t(this,"sentDown",new Set);_t(this,"drops",0);_t(this,"urls");_t(this,"suspended",!1);_t(this,"connectDeadline");_t(this,"settle");_t(this,"backoffMin");_t(this,"wake",()=>{var n;if(this.closed||this.suspended||document.visibilityState!=="visible"||((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN)return;this.timer&&clearTimeout(this.timer),this.timer=null,this.attempt=0,this.drops=0,this.downAt!==null&&(this.downAt=Date.now(),this.onStatus(!1,null),this.armSay());const t=this.ws;this.connect(),t==null||t.close()});this.onMsg=n,this.onStatus=r,this.hooks=s,this.connectDeadline=o.connectDeadline??cz,this.settle=o.settle??az,this.backoffMin=o.backoffMin??sz,this.urls=Xw(t.origin,t.token),this.suspended=s.held??!1,this.connect(),document.addEventListener("visibilitychange",this.wake),window.addEventListener("online",this.wake)}suspend(){if(this.suspended||this.closed)return;this.suspended=!0,this.timer&&clearTimeout(this.timer),this.timer=null;const t=this.ws;this.ws=null,t==null||t.close(),this.onStatus(!1,null)}resume(){!this.suspended||this.closed||(this.suspended=!1,this.attempt=0,this.connect())}async diagnose(t){if(t===zR)return"unauthorized";if(this.drops<2)return null;try{return(await fetch(this.urls.health,{signal:AbortSignal.timeout(2e3)})).ok?"blocked":"down"}catch{return"down"}}say(t){this.downAt??(this.downAt=Date.now()),this.downCode=t,this.armSay()}armSay(){if(this.downAt===null)return;const t=this.downAt,n=()=>!this.closed&&this.downAt===t&&document.visibilityState==="visible";this.sayTimer&&clearTimeout(this.sayTimer),this.sayTimer=setTimeout(()=>{n()&&this.diagnose(this.downCode).then(r=>{n()&&this.onStatus(!1,r)})},Math.max(0,t+this.settle-Date.now()))}connect(){var s,a;if(this.closed||this.suspended)return;const t=((a=(s=this.hooks).known)==null?void 0:a.call(s))??null,n=new WebSocket(t===null?this.urls.ws:`${this.urls.ws}&known=${t}`);this.ws=n;let r=!1;const o=setTimeout(()=>{n.readyState===WebSocket.CONNECTING&&n.close()},this.connectDeadline);n.onmessage=l=>{if(!r){r=!0,clearTimeout(o),this.attempt=0,this.drops=0,this.downAt=null,this.sayTimer&&clearTimeout(this.sayTimer),this.sayTimer=null,this.onStatus(!0);for(const u of this.queue)n.send(u.raw);this.queue=[]}try{this.onMsg(JSON.parse(l.data))}catch{}},n.onclose=l=>{if(clearTimeout(o),this.ws!==n||(this.onStatus(!1),this.closed||this.suspended))return;this.drops++,this.say(l.code);const u=Math.min(iz,this.backoffMin*2**this.attempt++);this.timer=setTimeout(()=>this.connect(),u/2+Math.random()*(u/2))},n.onerror=()=>n.close()}send(t){const n=JSON.stringify(t);if(this.ws&&this.ws.readyState===WebSocket.OPEN){this.ws.send(n);return}if(t.t.startsWith("term-"))return;const r=t.t==="subscribe"||t.t==="unsubscribe"?`sub:${t.worktreeId}`:t.t==="view"?"view":null;r&&(this.queue=this.queue.filter(o=>o.key!==r)),lz(t)&&t.boxId&&this.sentDown.add(t.boxId),this.queue.push({key:r,raw:n}),this.queue.length>Tx&&this.queue.splice(0,this.queue.length-Tx)}sentWhileDown(){const t=[...this.sentDown];return this.sentDown.clear(),t}dispose(){var t;this.closed=!0,this.timer&&clearTimeout(this.timer),this.sayTimer&&clearTimeout(this.sayTimer),document.removeEventListener("visibilitychange",this.wake),window.removeEventListener("online",this.wake),(t=this.ws)==null||t.close()}}function Qw(e){return e==="cancelled"||e==="expired"}function sN(e){const t=e.findLast(n=>n.kind==="ask"||Qu(n));return(t==null?void 0:t.kind)!=="ask"||t.ask.kind!=="question"?null:Qw(t.outcome)?t:null}function dz(e){if(e.ask.kind==="permission")return e.ask.title;const t=e.ask.questions.map(n=>n.header).filter(n=>!!n);return t.length>0?t.join(", "):e.ask.message}function fz(e){return e.map(()=>({selected:[]}))}function jx(e,t,n,r){return e.map((o,s)=>{if(s!==t)return o;const a=o.selected.includes(n);return r?{...o,selected:a?o.selected.filter(l=>l!==n):[...o.selected,n]}:{...o,selected:[n]}})}function iN(e,t,n){return e.map((r,o)=>{if(o!==t)return r;const{note:s,...a}=r;return n===void 0?a:{...a,note:n}})}function $x(e,t,n,r){return e.map((o,s)=>s!==t?o:{selected:n&&!r?[]:o.selected,note:o.note??""})}function du(e,t){const n=e[t];return n&&n.note!==void 0&&!n.note.trim()?iN(e,t,void 0):e}function hz(e){return e?e.options.length+(e.note?1:0):0}function Cx(e,t){return!!(e!=null&&e.note)&&t===e.options.length}function aN(e,t){return!!e&&e.note!==void 0&&(t||e.selected.length===0)}function Ra(e){var t;return!!e&&(e.selected.length>0||!!((t=e.note)!=null&&t.trim()))}function pz(e,t){return!!(e!=null&&e.multi)&&Ra(t)}function Sg(e,t){return e.every((n,r)=>!n.required||Ra(t[r]))}function cN(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(s=>{var a;return ey(((a=e.options.find(l=>l.value===s))==null?void 0:a.label)??s)}),r=(o=t==null?void 0:t.note)==null?void 0:o.trim();return n.length===0?r||"skipped":r?`${n.join(", ")}: ${r}`:n.join(", ")}function lN(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(s=>{var a;return ey(((a=e.options.find(l=>l.value===s))==null?void 0:a.label)??s)}),r=((o=t==null?void 0:t.note)==null?void 0:o.trim())||void 0;return n.length>0?r?{pick:n.join(", "),note:r}:{pick:n.join(", ")}:r&&e.note?{pick:e.note.label,note:r}:{pick:r??"skipped"}}function Jw(e,t){return e.map((n,r)=>yk(e,n,cN(n,t==null?void 0:t[r])))}function yk(e,t,n){return e.length>1&&t.header?`${t.header} · ${n}`:n}function mz(e,t){return e.map((n,r)=>{const o=t==null?void 0:t[r],s=gz(n,o);if(s.length===0)return{pick:yk(e,n,cN(n,o)),descriptions:s};const a=lN(n,o);return{pick:yk(e,n,a.pick),descriptions:s,note:a.note}})}function gz(e,t){return((t==null?void 0:t.selected)??[]).map(n=>{var r,o;return((o=(r=e.options.find(s=>s.value===n))==null?void 0:r.description)==null?void 0:o.trim())??""}).filter(Boolean)}function kz(e){return e.outcome!=="answered"||e.ask.kind!=="question"?null:{message:e.ask.message,questions:e.ask.questions,answers:e.answers}}function wz(e){if(e.outcome!=="answered")return null;const t=(e.answers??[]).map(n=>{var r;return((r=n.note)==null?void 0:r.trim())??""}).filter(Boolean);return t.length>0?t.join(`
102
- `):null}function yz(e){if(e.outcome!=="answered"||e.ask.kind!=="permission"||e.toolId)return null;const t=e.ask.choices.find(r=>r.id===e.choiceId);if(!t)return null;const n=e.ask.plan??null;return{file:n,text:n?"":e.ask.detail??"",choice:t.name}}function Pc(e,t){if(!e)return 0;if(aN(t,!!e.multi)&&e.note)return e.options.length;const n=t!=null&&t.selected[0]?e.options.findIndex(r=>r.value===t.selected[0]):-1;return n===-1?0:n}function vz(e,t,n){return Math.max(0,Math.min(n-1,e+t))}function bz(e,t,n){const r=e.length;for(let o=1;o<=r;o++){const s=(n+o)%r;if(!Ra(t[s]))return s}return-1}function Dc(e){return e.length>1?e.length:-1}function xz(e){return e.length+(Dc(e)===-1?0:1)}function Ez(e,t,n){const r=bz(e,t,n);if(r!==-1)return{current:r,cursor:Pc(e[r],t[r]),send:!1};const o=Dc(e);return o!==-1?{current:o,cursor:0,send:!1}:{current:n,cursor:Pc(e[n],t[n]),send:!0}}const uN=/\s*\(recommended\)\s*$/i;function Sz(e){return uN.test(e)}function ey(e){return e.replace(uN,"")}const _z={skipped:"you skipped this",cancelled:"the turn was stopped before you answered",expired:"Toyon restarted before you answered"};function Nz(e,t){const n=t??0;return n===0?null:`${n} behind ${e}`}function cp(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function dN(e,t){if(t.fetchFailed)return`could not reach origin${t.fetchedAt?` since ${cp(t.fetchedAt)}`:""}: ${t.fetchFailed}`;const n=t.behind??0;return n===0?null:t.stale==="diverged"?`${e} has diverged from origin`:t.stale==="dirty"&&t.dirty>0?`${n} behind origin; an uncommitted file on ${e} is in the pull's way`:`${n} behind origin`}function Tz(e){return e.stale!=="diverged"}function Jc(e,t){return`main has ${e} uncommitted ${e===1?"file":"files"}; ${t} runs on them too`}function fN(e,t,n,r){return n!==null&&r===n.host?`${DR(n.previews,e,t)}/`:r.endsWith(".localhost")?`http://w${e}.${r}:${t}/`:Gh(r)?`http://${r==="localhost"?"127.0.0.1":r}:${t}/`:`https://${r}:${t}/`}function Ax(e){return e.ranges.map(([t,n])=>[t+e.offset,n+e.offset])}function hN(e,t){if(t&&e.startsWith(`${t}/`))return e.slice(t.length+1);const n=e.lastIndexOf("/src/");return n>=0?e.slice(n+1):e}function jz(e){var r;const t=(r=e.source)==null?void 0:r.replace(/[?#].*$/,""),n=t?` (${hN(t)}:${e.line??"?"})`:"";return`${e.message}${n}`.slice(0,vD)}function Tf(e,t){return!Number.isFinite(e)||e<=0?t:Math.min(Math.max(e,170),Math.floor(window.innerWidth*.5))}const $z=new Set(["running","starting","preparing","crashed","unreachable"]);function Zs(e){var n,r,o;if(e.agent==="waiting")return"waiting";if(e.agent==="working"&&e.stopping)return"stopping";if(e.agent==="working")return"working";const t=e.procs.some(s=>$z.has(s.status));return t&&(e.agent==="error"||((r=(n=e.worktree)==null?void 0:n.lastTurn)==null?void 0:r.end)==="failed")?"failed":e.background?"background":t&&((o=e.worktree)!=null&&o.landed)&&!e.dirty?"landed":e.procs.some(s=>s.status==="crashed"||s.status==="unreachable")?"crashed":e.procs.some(s=>s.status==="running")?"running":e.procs.some(s=>s.status==="starting")?"starting":e.procs.some(s=>s.status==="preparing")?"preparing":e.procs.some(s=>s.status==="asleep")?"asleep":"idle"}const Cz={waiting:"Waiting for you",stopping:"Agent stopping",working:"Agent working",background:"Running in the background",failed:"Agent failed",landed:"Landed",crashed:"Crashed",running:"Running",starting:"Starting",preparing:"Setting up",asleep:"Asleep",idle:"Idle"};function ty(e,t=!1){const n=Zs(e);return n==="idle"&&t?"Not set up":n==="background"&&e.wakes?`Wakes ${cp(e.wakes)}`:Cz[n]}const Az={preparing:"Setting up",starting:"Starting",running:"Running",unreachable:"Not answering",crashed:"Crashed",stopped:"Stopped",asleep:"Asleep"};function ny(e){return Az[e]}const Iz=new Set(["idle","asleep","running","starting","preparing","background","landed"]);function lp(e,t){return t&&Iz.has(Zs(e))?t:null}const Rz={land:"Landing",commit:"Committing","sync-main":"Syncing with main","pull-main":"Pulling"};function ry(e){return Rz[e]}function pN(e,t){return lp(e,t??void 0)?"background":Zs(e)}function mN(e,t,n=!1){const r=lp(e,t??void 0);return r?ry(r):ty(e,n)}function gN(e){const t=e.filter(o=>o.status==="crashed"||o.status==="unreachable"),n=t[0];if(!n)return null;const r=t.map(o=>o.status==="unreachable"?`${o.name} never answered on :${o.port}`:`${o.name} crashed on :${o.port}`).join(", ");return{dead:t,tip:`${r} · click to open its tab`,stream:n.name}}function kN(e){const t=e.lastIndexOf("/");return t<0?{name:e,dir:""}:{name:e.slice(t+1),dir:e.slice(0,t)}}const wN=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}).compare;function ph(e){const t=[];for(let n=e.indexOf("/");n!==-1;n=e.indexOf("/",n+1))t.push(e.slice(0,n));return t}function yN(e){const t=new Set;for(const n of e)for(const r of ph(n))t.add(r);return[...t].sort(wN)}function oy(e){return e.includes("A")||e==="??"?"added":e.includes("D")?"deleted":""}function sy(e){if(e==="??")return"A";if(e==="UU"||e==="AA"||e==="DD"||e.includes("U"))return"C";const t=e.trim()[0]??"";return t==="T"?"M":t||"·"}const Oz=/Firefox\//.test(navigator.userAgent);function iy(){const e=t=>{var n;return((n=globalThis.matchMedia)==null?void 0:n.call(globalThis,`(display-mode: ${t})`).matches)??!1};return e("standalone")||e("window-controls-overlay")}const Mz=/Chrome\//.test(navigator.userAgent)&&iy(),Ht=e=>ER(e,{firefox:Oz,pwa:Mz});function ay(e){return e.component?`<${e.component} />`:`<${e.tag}>`}function vk(e,t){return e.worktree&&Tr(e.worktree)&&t?t.defaultBranch:e.name}function cy(e){const t=Math.max(0,e/1e3),n=(a,l)=>`${a} ${l}${a===1?"":"s"}`;if(t<60)return"a moment";const r=t/60;if(r<60)return n(Math.floor(r),"minute");const o=r/60;if(o<24)return n(Math.floor(o),"hour");const s=o/24;return s<7?n(Math.floor(s),"day"):s<365?n(Math.floor(s/7),"week"):n(Math.floor(s/365),"year")}function dr(e){const t=Math.max(0,(Date.now()-e)/1e3);if(t<60)return"now";const n=t/60;if(n<60)return`${Math.floor(n)}m`;const r=n/60;if(r<24)return`${Math.floor(r)}h`;const o=r/24;return o<7?`${Math.floor(o)}d`:o<365?`${Math.floor(o/7)}w`:`${Math.floor(o/365)}y`}function ja(e){const t=Math.max(0,Math.floor(e));return t<100?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Lz(e,t,n,r){var a;if(!t)return null;const o=e.filter(Tn).filter(l=>l.repoId===t&&(l.worktree.agent??r)===n);return((a=o.find(l=>Tr(l.worktree))??o[0])==null?void 0:a.id)??null}const Pz=200;function Dz(e,t){const n=new Map(e.map(r=>[r.path,r]));for(const r of t){if(n.size>=Pz)break;const o=op(r.path);o&&!n.has(o)&&n.set(o,{path:o,text:r.text})}return n.size===e.length?e:[...n.values()]}function vN(e){return e!==void 0&&!e.routes.some(t=>!t.endpoint)}const Fi=e=>"uploading"in e&&e.uploading===!0;function Kc(e){switch(e.kind){case"image":case"file":{const{key:t,local:n,uploading:r,progress:o,...s}=e;return s}case"paste":{const{key:t,chars:n,lines:r,preview:o,...s}=e;return s}case"pick":{const{key:t,...n}=e;return n}}}const ly=e=>e.filter(t=>!Fi(t)).map(Kc);let zz=0;function bk(e,t){const n=new Map(t.filter(o=>!Fi(o)).map(o=>[JSON.stringify(Kc(o)),o]));return[...e.map(o=>{const s=JSON.stringify(o),a=n.get(s);if(a)return n.delete(s),a;const l=`d${++zz}`;return o.kind==="paste"?{...o,key:l,...qw(o.text)}:{...o,key:l}}),...t.filter(Fi)]}const xk="out:",Fz=(e,t,n)=>`${xk}${e}:${t}:${n}`;function ws(e){if(!e.startsWith(xk))return null;const t=e.slice(xk.length),n=t.indexOf(":"),r=t.indexOf(":",n+1);return n<0||r<0?null:{clientId:t.slice(0,n),source:t.slice(r+1)}}function fu(e,t,n,r){const o=r.length?ly(r):void 0;switch(e.t){case"chat":return{...e,text:n,attachments:o,boxId:t};case"create-worktree":return{...e,prompt:n,attachments:o,boxId:t};case"restore-worktree":case"adopt-worktree":return{...e,message:{text:n,attachments:o},boxId:t};case"agent-answer":return{...e,attachments:o,boxId:t}}}function Bz(e,t){const n=new Set,r=[];for(const o of e){if(n.has(o.log))continue;const s=t[o.id];if(!s||s.attachments.some(Fi)){n.add(o.log);continue}r.push(o.id)}return r}const bN=e=>e.flatMap(t=>"upload"in t&&t.upload?[t.upload]:[]);function Uz(e){const t=n=>bN(n.items).some(r=>!n.before.includes(r));return[...e.filter(t),...e.filter(n=>!t(n))]}function Hz(e,t){const n=new Map(t.rows.map(a=>[a.id,a])),r=new Map(e.map(a=>[a.id,a])),o=[];let s=!0;for(const a of t.ids){const l=n.get(a)??r.get(a);l?o.push(l):s=!1}return{rows:o,complete:s}}const jc=300,Wz=20;function Kz(e,t){return e.rows.length===0&&e.repos.length===0?null:{protocol:Ta,at:t,version:e.version,machine:e.machine??"",install:e.install,registry:e.registry,repos:e.repos,rows:e.rows,trunks:e.trunks,themePrefs:e.themePrefs,agents:e.agents,defaultAgent:e.defaultAgent,agentChosen:e.agentChosen,home:e.home,folderDialog:e.folderDialog,keepAwake:e.keepAwake,remote:e.remote,tailscale:e.tailscale,machines:e.handed,gitIdentity:e.gitIdentity,visits:e.visits,managed:e.managed}}const Ix=e=>(e==null?void 0:e.protocol)===Ta,qz={rows:"",repos:"",visits:"",themes:""};function Zz(e){const{at:t,...n}=e;return{t:"hello",...n,rows:e.rows.map(Gz),trunks:Object.fromEntries(Object.entries(e.trunks).map(([r,o])=>[r,Vz(o)])),stamps:qz,themes:[],drafts:{},attachments:{},knocks:[],letIn:!1,self:null,update:null,globalInstall:null,pending:[]}}function Gz(e){const{stopping:t,shipping:n,queued:r,syncQueued:o,...s}=e;return{...s,agent:e.agent==="working"?"idle":e.agent,procs:[],login:!1}}function Vz(e){const{shipping:t,...n}=e;return n}function Yz(e){let t=null;for(const{event:n}of e){const r=n.ts;typeof r=="number"&&(t===null||r>t)&&(t=r)}return t}function jf(e,t){return e.length>t?e.slice(e.length-t):[...e]}function Xz(e,t,n=Wz){const r=new Set(t.map(a=>a.id)),o=Object.keys(e).filter(a=>!r.has(a)),s=Object.entries(e).filter(([a])=>r.has(a)).sort((a,l)=>l[1].at-a[1].at);return[...o,...s.slice(n).map(([a])=>a)]}class Qz{constructor(){_t(this,"events",[]);_t(this,"seq",-1);_t(this,"whole",!1)}reset(t,n,r){this.events=jf(bf(t),jc),this.seq=n,this.whole=r}extend(t,n){this.events.push(...t),n>this.seq&&(this.seq=n),this.events.length>jc*2&&(this.events=jf(bf(this.events),jc))}since(){return this.whole&&this.seq>=0?this.seq:void 0}add(t,n){this.events.push({seq:t,event:n}),t>this.seq&&(this.seq=t),this.events.length>jc*2&&(this.events=jf(bf(this.events),jc))}snapshot(t,n){return this.events=jf(bf(this.events),jc),{protocol:Ta,at:n,events:[...this.events],seq:this.seq,...t?{draft:t}:{}}}}const Jz={ids:[],at:-1};function $f(e,t,n){if(e.ids[e.at]===n)return e;const o=[...e.ids.length?e.ids.slice(0,e.at+1):t?[t]:[],n].slice(-50);return{ids:o,at:o.length-1}}function e3(e,t,n,r){for(let o=e.at+r;o>=0&&o<e.ids.length;o+=r){const s=e.ids[o];if(s!==void 0&&s!==n&&t.has(s))return{at:o,id:s}}return null}function Ek(e,t){if(e.ids.every(o=>t.has(o)))return e;const n=[];let r=-1;return e.ids.forEach((o,s)=>{t.has(o)&&(n[n.length-1]!==o&&n.push(o),s<=e.at&&(r=n.length-1))}),{ids:n,at:n.length?Math.max(r,0):-1}}function Qu(e){return e.kind==="user"||e.kind==="handed"}function xN(e){return e.map(t=>Qu(t)?t.attachments:void 0)}const Vf=["files","changes","history"],t3=e=>Vf.includes(e),qa=e=>(e==null?void 0:e.worktree.id)??null,el="new-project",Za=Object.freeze({chat:[],log:[],queue:[],page:{},turn:{edits:!1,hmr:!1},changedRanges:{},commitFiles:{},search:null,design:null,draft:"",attachments:[],commands:[],termStream:Bo}),up=e=>({...e,phase:"editing",repoId:null}),EN=()=>up({mode:"create",name:"",parent:`~/${W_}`}),n3=Object.freeze({changes:!1,changesTab:"files",chat:!0,term:!1,design:!1});function r3(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.changes=="boolean"&&t3(t.changesTab)&&typeof t.chat=="boolean"&&typeof t.term=="boolean"&&typeof t.design=="boolean"}function ho(e,t){const n=e.layout;let r=!1;for(const o of Object.keys(t))t[o]!==n[o]&&(r=!0);return r?{...e,layout:{...n,...t}}:e}function uy(e,t){return{...e,layout:t,changesAuto:!1}}const Bi=e=>Wa(e)?"preview":"file",o3=(e,t)=>e===t||!!e&&!!t&&e.at===t.at&&(e.at!=="tree"||t.at!=="tree"||e.worktreeId===t.worktreeId&&e.dir===t.dir)&&(e.at!=="rail"||t.at!=="rail"||e.worktreeId===t.worktreeId),ru=(e,t)=>e.worktreeId===t.worktreeId&&e.path===t.path&&e.ref===t.ref&&e.since===t.since;function SN(e,t,n,r){var s;if(!r.fiber)return r;const o=(s=Or(e,t).changedRanges[n])==null?void 0:s.offset;return o===void 0?r:{n:r.n-o}}function s3(e){const t=e.cached??Xu,n={connected:!1,connectFailure:null,repos:[],rows:[],activeRepoId:null,visible:[],lent:null,archiving:[],shipping:{},visibleDiscovered:[],discoveredOpen:e.storedDiscoveredOpen??{},archivedOpen:e.storedArchivedOpen??{},committedShut:e.storedCommittedShut??{},turnOpen:e.storedTurnOpen??{},treeOpen:e.storedTreeOpen??{},treeReveal:null,refs:{},chats:{},archived:{},archivedPage:null,lastActive:e.storedLastActive??{},pendingOpen:!1,activeId:null,viewed:Jz,carryTo:null,clientId:e.clientId,storedActive:e.storedActive??null,storedRepo:e.storedRepo??null,heard:!1,heardAt:null,recalledAt:null,stamps:null,local:{},editor:null,openUrl:null,reloadReq:null,dragFiles:null,sharing:null,picking:!1,overlay:null,paletteReturn:null,incompatible:!1,layout:n3,focusChanges:0,editCommit:0,focusChat:0,walked:0,railOpen:e.storedRailOpen??!1,chatSide:e.storedChatSide??"left",blackGround:e.storedBlackGround??!1,focusRail:0,railPeek:!1,unreadHold:null,layouts:e.storedLayouts??{},screen:e.storedActive&&e.storedPhoneRow?"chat":"home",left:null,frame:e.frame??"desk",touch:e.touch??!1,reading:!1,typing:!1,changesAuto:!0,zen:!1,zenFile:!1,focusTerm:0,termRun:null,termTall:0,previewSize:null,themes:Zf.some(o=>o.id===t.id)?Zf:[...Zf,t],themePrefs:{...w4,mode:t.kind,[t.kind]:t.id},previewTheme:null,systemDark:e.systemDark??!0,daylight:e.daylight??null,paths:{query:"",entries:[],target:null},home:"",folderDialog:!1,keepAwake:null,remote:null,machine:null,managed:kD,letIn:!1,knocks:[],tailscale:null,handed:[],gitIdentity:!0,self:null,rebuilt:!1,update:null,globalInstall:null,updateCheck:null,version:"",install:"none",registry:null,ranBefore:e.storedVersion??null,notesPage:!1,notesSeen:!1,choosingFolder:!1,newProject:null,autoSend:null,outbox:[],chosenFolder:null,pending:[],activeImportId:null,agents:[],defaultAgent:"claude",agentChosen:!1,agentConfigs:{},draft:null,trunks:{},visits:{}},r=e.storedRepo?n.layouts[e.storedRepo]:void 0;return r?uy(n,r):n}function _N(e){var t;return{system:e.systemDark,daylight:((t=e.daylight)==null?void 0:t.dark)??e.systemDark}}function i3(e){return e.previewTheme??ip(e.themePrefs,e.themes,_N(e))}function Or(e,t){return t&&e.local[t]||Za}function dy(e,t){const n=Or(e,t);return n.draft.trim()!==""||n.attachments.length>0}function Kr(e,t){return t&&e.rows.find(n=>n.id===t)||null}function NN(e,t){const n=Kr(e,t);return n?is(n.agent)||!!e.shipping[n.id]||(n.queued??0)>0:!1}function Jt(e,t){const n=Kr(e,t);return n&&Tn(n)?n:null}function TN(e){var o;const t=Jt(e,e.activeId);if(!t||!Di(t.worktree)||t.agent!=="idle"||!((o=Hi(e,t.repoId))!=null&&o.empty))return!1;const n=bs(e,t.repoId),r=e.rows.some(s=>{var a;return s.repoId===t.repoId&&((a=s.worktree)==null?void 0:a.kind)==="worktree"});return!!(n!=null&&n.needsSetup)&&!r&&Or(e,t.id).chat.length===0}function dp(e){return e.newProject!==null||TN(e)}function a3(e){return e.incompatible||dp(e)}function c3(e){return(!e.needsSetup||!!e.assumed)&&Object.keys(e.config.run).length===0}function mh(e){return!!(e!=null&&e.needsSetup)&&!e.assumed}function fy(e){const t=e.archivedPage?null:Kr(e,e.activeId);return(t==null?void 0:t.repoId)??e.activeRepoId}function Co(e){const t=bs(e,fy(e));return!!t&&c3(t)}function Ui(e){return e.zen&&e.zenFile&&!Co(e)}function jN(e){return e.layout.chat&&!Co(e)&&!e.archivedPage&&!py(e)?{a:"toggle-chat"}:{a:"focus-chat"}}function Sk(e,t){var n;return!e.activeRepoId||!((n=e.archived[e.activeRepoId])!=null&&n.some(r=>r.id===t))?e:{...e,archivedPage:t,notesPage:!1,editor:null,screen:"chat"}}function ts(e){return Co(e)?e:ho(e,{chat:!0})}function bs(e,t){return t&&e.repos.find(n=>n.id===t)||null}function $N(e,t){if(!t)return null;const n=e.rows.filter(Tn).filter(r=>r.repoId===t);return n.find(r=>Wh(r.worktree))??n.find(r=>Di(r.worktree))??null}function Hi(e,t){return t&&e.trunks[t]||null}function zc(e){return Co(e)||e.archivedPage||e.notesPage?null:e.activeId}function fp(e){return e.procs.some(t=>t.status==="running"||t.status==="starting"||t.status==="preparing")}function Iu(e){if(e.archivedPage||e.notesPage)return null;const t=Jt(e,e.activeId);return t&&fp(t)?{worktreeId:t.worktree.id,repoId:t.repoId}:null}function _k(e){const t=zc(e),n=Jt(e,t);return n?{id:n.worktree.id,act:fp(n)?"frame":"start"}:null}function hy(e,t,n){const r=e.worktree.from;if(e.repoId===t||(r==null?void 0:r.kind)!=="worktree"||r.origin.repoId!==t)return null;const o=n.find(s=>s.id===r.origin.id);return o&&Tn(o)&&o.repoId===t?o:null}function l3(e,t,n){var s;const r=e.worktree.from;if((r==null?void 0:r.kind)!=="worktree")return null;const o=t.find(a=>a.id===r.origin.id);return o&&Tn(o)?o.worktree.title:((s=n.find(a=>a.id===r.origin.id))==null?void 0:s.title)??null}function CN(e,t){return e.repoId!==t&&(e.agent==="waiting"||!!e.unseen)}function hp(e,t,n,r){return e.repoId===t||hy(e,t,n)!==null||CN(e,t)||e.id===r}function AN(e,t,n){return!e||!t||!Tn(e)||e.repoId===t||hy(e,t,n)?null:CN(e,t)?e.id:null}function IN(e,t){return t.length?e.filter(n=>!t.includes(n.id)):e}function u3(e,t,n,r){const o=IN(e,n).filter(Tn);return sR(t?o.filter(s=>hp(s,t,o,r)):o)}function d3(e,t){const n=e.filter(r=>!Tn(r));return t?n.filter(r=>r.repoId===t):n}function Oa(e,t,n=e.rows){var l;const r=n.filter(Tn),o=e.archiving.length?r.filter(u=>!e.archiving.includes(u.id)):r,s=t?e.lastActive[t]:void 0;if(s&&o.some(u=>u.id===s))return s;const a=t?o.filter(u=>u.repoId===t):o;return((l=a.find(u=>Wh(u.worktree))??a.find(u=>Di(u.worktree))??a[0])==null?void 0:l.id)??null}function Rx(e,t){const n=Object.entries(e),r=n.filter(([o])=>!t(o));return r.length===n.length?e:Object.fromEntries(r)}function RN(e,t,n){const r={};for(const a of t)a.shipping&&(r[a.id]=a.shipping);for(const a of Object.values(n))a.shipping&&(r[a.id]=a.shipping);for(const[a,l]of Object.entries(e))!l.sent||r[a]||(t.some(u=>u.id===a)||HN({trunks:n},a))&&(r[a]=l);const o=Object.keys(r);return o.length===Object.keys(e).length&&o.every(a=>f3(e[a],r[a]))?e:r}const f3=(e,t)=>!!e&&!!t&&e.op===t.op&&e.step===t.step&&e.sent===t.sent;function Ii(e,t){var p;const n=Kr(e,t),r=!!n&&Tn(n)&&!!e.activeRepoId&&hp(n,e.activeRepoId,e.rows,e.lent),o=r&&e.lent!==t?AN(n,e.activeRepoId,e.rows):r?e.lent:null,s=r?e.activeRepoId:(n==null?void 0:n.repoId)??e.activeRepoId,a=n&&Tn(n)?{...e.lastActive,[n.repoId]:n.id}:e.lastActive,l=e.activeId!==t?e.activeId:null,u=l?e.local[l]:void 0,f=u&&((p=u.mark)==null?void 0:p.by)==="reveal"?Fc(u,"reveal"):null,h=l&&f?{...e.local,[l]:f}:e.local;return{...e,activeId:t,activeRepoId:s,lent:o,lastActive:a,editor:null,archivedPage:null,notesPage:!1,local:h}}function tl(e){return Wo(e)?"history":e.layout.changesTab}function h3(e,t){const n=tl(e);if(Wo(e))return n;const r=Vf.length;return Vf[(Vf.indexOf(n)+t+r)%r]??"changes"}function py(e){if(e.archivedPage)return null;const t=Kr(e,e.activeId);return t&&!Tn(t)?t:null}function p3(e){return e.notesSeen||e.ranBefore===null||!X_(e.version,e.ranBefore)?null:e.version}const m3=800;function ON(e,t){return e.left&&t-e.left.at<m3?e.left.face:null}function g3(e,t){var n,r;return{id:e.id,repoId:e.repoId,title:e.worktree.title,branch:e.worktree.branch,path:e.path,createdAt:e.worktree.createdAt,archivedAt:t,restorable:!0,transcript:e.transcript??"",...e.sessionId?{sessionId:e.sessionId}:{},...e.dirty?{uncommitted:!0,dirty:e.dirty}:{},...e.worktree.landed?{landed:!0}:{},...(n=e.worktree.lands)!=null&&n.length?{lands:e.worktree.lands}:{},...((r=e.usage)==null?void 0:r.cost)!==void 0?{cost:e.usage.cost}:{}}}function k3(e,t){let n=e;for(const[r,o]of Object.entries(e))o.some(s=>t.includes(s.id))&&(n={...n,[r]:o.filter(s=>!t.includes(s.id))});return n}function Wo(e){var t;return!e.archivedPage||!e.activeRepoId?null:((t=e.archived[e.activeRepoId])==null?void 0:t.find(n=>n.id===e.archivedPage))??null}function MN(e,t){for(const n of Object.values(e.archived)){const r=n.find(o=>o.id===t);if(r)return r}return null}function gh(e){const t=new Set(e.rows.map(n=>n.id));for(const n of Object.values(e.archived))for(const r of n)t.add(r.id);return t}function Yf(e){return e.archivedPage??e.activeId}function w3(e,t){var n;if(t)return(n=Kr(e,t)??MN(e,t))==null?void 0:n.repoId}function Fc(e,t){var o;if(((o=e.mark)==null?void 0:o.by)!==t)return e;const{mark:n,...r}=e;return r}const LN=e=>e.kind==="theme"||e.kind==="appearance"||e.kind==="keep-awake"||e.kind==="agent"||e.kind==="agent-page"||e.kind==="choose-folder"||e.kind==="handoff";let y3=0;function Ru(e){if(!e.sending)return e;const{sending:t,...n}=e;return n}function v3(e,t){const n=Object.keys(e.local).filter(o=>{var s;return((s=e.local[o])==null?void 0:s.sending)&&(!t||o===t)});if(n.length===0)return e;const r={...e.local};for(const o of n)r[o]=Ru(r[o]);return{...e,local:r}}function b3(e,t,n,r){var a;let o=e;const s=n?(a=o[n])==null?void 0:a.sending:void 0;if(s&&n&&r&&r!==n){const l=o[r]??Za,u=l.chat.some(f=>f.kind==="user")?{at:s.at}:s;o={...o,[n]:Ru(o[n]),[r]:{...l,sending:u}}}for(const l of t){const u=o[l.id];u!=null&&u.sending&&!u.sending.message&&is(l.agent)&&(o={...o,[l.id]:Ru(u)})}return o}function kt(e,t,n){return{...e,local:{...e.local,[t]:n(e.local[t]??Za)}}}function Ox(e,t){const n=e.find(r=>r.kind==="tool"&&!r.done&&!r.parentToolId&&!r.background);if(n)return(t==null?void 0:t.id)===n.id?t:{id:n.id,at:Date.now()}}function x3(e,t){const n=t.type==="agent-question"||t.type==="agent-permission"||t.type==="handoff-proposed"&&!t.held||t.type==="handoff-shown",r=t.type==="agent-ask-end"||t.type==="handoff-go"||t.type==="handoff-declined"?t.id:null;if(!n&&!r)return e;const o=t.type==="agent-ask-end"&&Qw(t.outcome),s=t.type==="agent-ask-end"&&t.outcome==="expired"?t.id:null,{card:a,cardParked:l,askRevived:u,...f}=e;return{...f,...a&&!n&&(a.id!==r||o)?{card:a}:{},...l&&!n&&l!==r?{cardParked:l}:{},...s?{askRevived:s}:u&&!n?{askRevived:u}:{}}}function E3(e,t,n){return kt(e,t,r=>({...r,chat:[...r.chat,n],chatAt:Date.now()}))}function PN(e,t,n){return E3(ts(e),t,{kind:"error",text:n})}function Nk(e,t){const n=qa(Jt(e,e.activeId));return n?kt(ts(e),n,r=>({...r,notice:t})):e}function Mx(e,t,n){return Jt(e,t)?PN(e,t,n):Nk(e,n)}function S3(e,t){const n=e.paletteReturn;return!t||!n?{overlay:null,paletteReturn:null}:{overlay:{kind:n.mode},paletteReturn:n}}function _3(e){const t=e.activeRepoId;if(!t)return e;const n=e.layouts[t];return n?uy(e,n):e.frame==="desk"?{...e,layouts:{...e.layouts,[t]:e.layout}}:e}function N3(e){return e.a==="server"&&e.msg.t==="git-status"}function T3(e){return{agent:e.defaultAgent}}function j3(e){const t=Jt(e,e.activeId);return!!t&&Tr(t.worktree)&&!e.archivedPage&&!dp(e)?e.draft?e:{...e,draft:T3(e)}:e.draft?{...e,draft:null}:e}function DN(e){var r;const t=e.archivedPage,n=t!==null&&((r=e.editor)==null?void 0:r.worktreeId)===t&&Jt(e,t)===null;return{...e,archivedPage:null,...n?{editor:null}:{}}}function $3(e){const t=e.activeRepoId;if(!t)return e;const n=Jt(e,e.activeId);return!n||n.repoId===t||hp(n,t,IN(e.rows,e.archiving),e.lent)?e:Ii(e,Oa(e,t))}function zN(e,t,n){const r=t.some(s=>!e.knocks.some(a=>a.id===s.id)),o={...e,knocks:t,letIn:n};return r&&o.overlay===null?Oi(o,{a:"open",overlay:{kind:"devices"}}):o}const C3=e=>{var t;return e.frame==="desk"&&(e.remote!==null||((t=e.tailscale)==null?void 0:t.state)==="ready")},A3=new Set(["toggle-chat","toggle-changes","toggle-rail","toggle-terminal","toggle-design"]);function Oi(e,t){let n=j3($3(I3(e,t)));return n.unreadHold!==null&&n.activeId!==n.unreadHold&&(n={...n,unreadHold:null}),Ui(e)&&n.zen&&(A3.has(t.a)||n.activeId!==e.activeId||n.focusChat!==e.focusChat||n.focusChanges!==e.focusChanges||n.focusRail!==e.focusRail||n.focusTerm!==e.focusTerm||!n.editor&&t.a!=="close-editor")&&(n={...n,zen:!1}),n.zenFile&&!(n.zen&&n.editor)&&(n={...n,zenFile:!1}),n.archivedPage!==null&&(Wo(n)===null||Jt(n,n.archivedPage)!==null)&&(n=DN(n)),n.activeRepoId!==e.activeRepoId?n=_3(n):n.frame==="desk"&&n.activeRepoId&&!N3(t)&&n.layout!==e.layout&&(n={...n,layouts:{...n.layouts,[n.activeRepoId]:n.layout}}),n.rows===e.rows&&n.activeRepoId===e.activeRepoId&&n.archiving===e.archiving&&n.lent===e.lent?n:{...n,visible:u3(n.rows,n.activeRepoId,n.archiving,n.lent),visibleDiscovered:d3(n.rows,n.activeRepoId)}}function I3(e,t){var n,r,o,s,a,l,u,f;switch(t.a){case"connected":return{...e,connected:t.v,connectFailure:t.v?null:t.failure===void 0?e.connectFailure:t.failure,local:t.v?e.local:z3(e.local)};case"activate":return{...Ii(e,t.id),viewed:$f(e.viewed,Yf(e),t.id),carryTo:null,screen:t.id?"chat":"home"};case"viewed-land":{const h=e.viewed.ids[t.at];if(h===void 0)return e;const p={...e.viewed,at:t.at};if(e.rows.some(w=>w.id===h))return{...Ii(e,h),viewed:p,carryTo:null,screen:"chat"};const g=MN(e,h);if(!g)return e;const y=g.repoId===e.activeRepoId?e:{...Ii(e,Oa(e,g.repoId)),activeRepoId:g.repoId,lent:null,carryTo:null};return{...Sk(y,h),viewed:p}}case"open-draft":{if(dp(e))return e;const h=((n=$N(e,e.activeRepoId))==null?void 0:n.id)??null;return h?ts({...Ii(e,h),viewed:$f(e.viewed,Yf(e),h),carryTo:h,overlay:null,paletteReturn:null,focusChat:e.focusChat+1,screen:"chat"}):e}case"draft-carry":return e.draft?{...e,draft:{...e.draft,carry:t.v}}:e;case"draft-agent":return e.draft?{...e,draft:{...e.draft,agent:t.id}}:e;case"open-archived":{const h=Sk(e,t.id);return h===e?e:{...h,viewed:$f(e.viewed,Yf(e),t.id)}}case"close-archived":{if(!e.archivedPage)return e;const h=DN(e);return e.activeId?{...h,viewed:$f(e.viewed,e.archivedPage,e.activeId)}:h}case"open-release-notes":return e.newProject?e:{...e,notesPage:!0,notesSeen:!0,overlay:null,paletteReturn:null,editor:null};case"close-release-notes":return e.notesPage?{...e,notesPage:!1}:e;case"sending":return kt(e,t.id,h=>({...h,sending:{message:t.message,at:Date.now()}}));case"sent-box":return kt(e,t.id,({notice:h,...p})=>({...Fc(p,"walk"),draft:"",attachments:[],sent:(p.sent??0)+1}));case"answered":return kt(e,t.id,h=>({...h,sent:(h.sent??0)+1}));case"hold-send":{const h=e.local[t.id];if(!h)return e;const p=Fz(e.clientId,++y3,t.id),g={...Za,draft:t.text,attachments:h.attachments,outgoing:{frame:t.frame,log:t.log}},y=kt(e,t.id,({notice:w,...v})=>({...Fc(v,"walk"),draft:"",attachments:[]}));return{...y,local:{...y.local,[p]:g},outbox:[...e.outbox,{id:p,log:t.log,kinds:h.attachments.map(w=>w.kind)}]}}case"sent-out":{const h=e.local[t.id],p=h==null?void 0:h.outgoing;if(!h||!p)return e;const{[t.id]:g,...y}=e.local,w={...e,local:y,outbox:e.outbox.filter(T=>T.id!==t.id)},v=h.draft,x=h.attachments.length?ly(h.attachments):void 0,N=T=>({...T,sent:(T.sent??0)+1});if(p.frame.t==="restore-worktree"||p.frame.t==="adopt-worktree")return kt(w,p.log,T=>({...N(T),sending:{message:{text:v,attachments:x},at:Date.now()}}));if(p.frame.t==="agent-answer")return kt(w,p.log,N);const S=p.frame.t==="chat"&&NN(e,p.log);return kt(w,p.log,T=>S?N(T):{...N(T),sending:{message:{text:v,attachments:x},at:Date.now()}})}case"unsend":{const h=e.local[t.id],p=(r=ws(t.id))==null?void 0:r.source;if(!(h!=null&&h.outgoing)||!p)return e;const{[t.id]:g,...y}=e.local,w={...e,local:y,outbox:e.outbox.filter(v=>v.id!==t.id)};return kt(ts(w),p,v=>({...v,draft:v.draft||h.draft,attachments:[...h.attachments,...v.attachments],...t.notice?{notice:t.notice}:{}}))}case"drop-out":{if(!((o=e.local[t.id])!=null&&o.outgoing))return e;const{[t.id]:h,...p}=e.local;return{...e,local:p,outbox:e.outbox.filter(g=>g.id!==t.id)}}case"archive-worktrees":{const h=t.ids.filter($=>!e.archiving.includes($)&&Jt(e,$));if(h.length===0)return e;const p=Date.now();let g=e.archived;for(const $ of h){const R=Jt(e,$);R&&(g={...g,[R.repoId]:[g3(R,p),...g[R.repoId]??[]]})}const y={...e,archiving:[...e.archiving,...h],archived:g};if(!e.activeId||!h.includes(e.activeId))return y;const w=e.visible.filter($=>$.id===e.activeId||!y.archiving.includes($.id)),v=w.findIndex($=>$.id===e.activeId),x=[$=>$.agent==="waiting",$=>Kh($.worktree)&&!!$.worktree.landed&&$.agent==="idle",$=>!!$.unseen,$=>$.agent==="working",$=>!Tr($.worktree)&&Zs($)==="running"],N=$=>{for(const R of x){const A=$(R);if(A)return A.id}},S=N($=>w.findLast((R,A)=>A<v&&$(R))),j=Ii(y,S??N($=>w.find((R,A)=>A>v&&$(R)))??Oa(y,e.activeRepoId));return e.frame==="phone"?{...j,screen:"home"}:j}case"shipping":return e.shipping[t.id]||!(Kr(e,t.id)||HN(e,t.id))?e:{...e,shipping:{...e.shipping,[t.id]:{op:t.op,sent:!0}}};case"activate-repo":{if(!bs(e,t.id))return e;const h=e.newProject?{...e,newProject:null}:e;if(t.id===e.activeRepoId)return h;const p=Oa(h,t.id);return{...Ii(h,p),carryTo:null,activeRepoId:t.id,lent:null,pendingOpen:!1}}case"open-repo":return{...e,pendingOpen:!0};case"new-project":return{...e,newProject:t.v,overlay:null,paletteReturn:null,previewTheme:null,editor:null,notesPage:!1};case"new-project-set":{if(!e.newProject)return e;const h="name"in t.v||"parent"in t.v||"url"in t.v||"mode"in t.v,{error:p,...g}=e.newProject;return{...e,newProject:{...h?g:e.newProject,...t.v}}}case"close-new-project":return e.newProject&&e.repos.length>0?{...e,newProject:null,choosingFolder:!1}:e;case"auto-sent":return e.autoSend?{...e,autoSend:null}:e;case"watch-import":return{...e,activeImportId:t.id};case"close-editor":return{...e,editor:null};case"open-file":{const h=t.v,p=e.editor,g=p&&ru(p,h)?p:null,y=h.line&&SN(e,h.worktreeId,h.path,h.line);return{...e,editor:{worktreeId:h.worktreeId,path:h.path,...h.ref?{ref:h.ref}:{},...h.since?{since:h.since}:{},view:h.view??(g==null?void 0:g.view)??null,marks:h.view?!1:(g==null?void 0:g.marks)??!0,...(h.picked?h.view==="preview":p!=null&&p.reads)?{reads:!0}:{},seq:h.seq,disk:(g==null?void 0:g.disk)??null,...y?{line:y}:{},...h.piece?{piece:h.piece}:{},focus:h.focus,conflict:(g==null?void 0:g.conflict)??null,blame:(g==null?void 0:g.blame)??null}}}case"open-loose":{const h=t.v,p={before:h.text,after:h.text,version:null,writable:(h.source.kind==="handle"||h.source.kind==="grant")&&!h.tooLarge&&!h.binary,binary:h.binary,tooLarge:h.tooLarge};return{...e,editor:{worktreeId:h.worktreeId,path:h.name,view:Bi(h.name),marks:!1,seq:h.seq,disk:p,focus:!0,conflict:null,blame:null,loose:{source:h.source}}}}case"editor-read":{const h=e.editor;if(!h||h.loose||!ru(h,t.file))return e;const p=t.disk;if(!p){const x=PN(e,h.worktreeId,t.error??`could not read ${h.path}`);return h.disk?x:{...x,editor:null}}const g=Bi(h.path),y=h.reads&&g==="preview"?g:null,w=Wa(h.path)==="markdown"?"preview":"diff",v=p.before===""?h.view&&h.view!=="diff"?h.view:g:h.view??y??(p.before===p.after?g:w);return{...e,editor:{...h,view:v,disk:p}}}case"editor-conflict":{const h=e.editor;return h&&!h.loose&&ru(h,t.file)?{...e,editor:{...h,conflict:t.theirs}}:e}case"editor-view":return e.editor?{...e,editor:{...e.editor,view:t.v,marks:t.marks??!1,reads:t.v==="preview",line:void 0}}:e;case"editor-marks":return e.editor?{...e,editor:{...e.editor,marks:t.v}}:e;case"editor-refused":{const h=e.editor;if(!h||!ru(h,t.file))return e;const p=h.loose&&h.disk?{...h.disk,writable:!1}:h.disk;return{...e,editor:{...h,refused:t.message,disk:p}}}case"editor-blame":{const h=e.editor;return h&&!h.loose&&ru(h,t.file)?{...e,editor:{...h,blame:t.blame}}:e}case"notice":return kt(ts(e),((s=ws(t.id))==null?void 0:s.source)??t.id,h=>({...h,notice:t.text}));case"link-refused":return kt(e,t.id,({refusedLink:h,...p})=>t.v?{...p,refusedLink:t.v}:p);case"card-draft":return kt(e,t.id,h=>({...h,card:t.card}));case"card-park":return kt(e,t.id,h=>({...h,cardParked:t.cardId}));case"card-unpark":return kt(e,t.id,({cardParked:h,...p})=>p);case"ask-revive":return kt(e,t.id,({askRevived:h,...p})=>t.askId?{...p,askRevived:t.askId}:p);case"opened-url":return e.openUrl?{...e,openUrl:null}:e;case"set-draft":return kt(e,t.id,h=>{const{notice:p,...g}=Fc(h,"walk");return{...g,draft:t.text,...p!==void 0&&t.text===""?{notice:p}:{}}});case"move-box":return UN(e,t.from,t.to);case"walk":return kt(e,t.id,h=>({...Fc(h,"walk"),draft:t.text,...t.walk?{mark:{by:"walk",at:t.walk.at,from:t.walk.from}}:{}}));case"reveal":return kt(ts(e),t.id,h=>{var p;return{...h,mark:{by:"reveal",seq:t.seq,n:((p=h.mark)==null?void 0:p.by)==="reveal"?h.mark.n+1:1}}});case"attach":return kt(ts(e),t.id,({notice:h,...p})=>({...p,attachments:[...p.attachments,...t.items]}));case"upload-progress":return(a=e.local[t.id])!=null&&a.attachments.some(h=>h.key===t.key&&Fi(h))?kt(e,t.id,h=>({...h,attachments:h.attachments.map(p=>p.key===t.key?{...p,progress:t.progress}:p)})):e;case"attached":return(l=e.local[t.id])!=null&&l.attachments.some(h=>h.key===t.key)?kt(e,t.id,h=>({...h,attachments:h.attachments.map(p=>p.key===t.key?t.item:p)})):e;case"detach":{const h=kt(e,t.id,({notice:p,...g})=>({...g,attachments:g.attachments.filter(y=>y.key!==t.key)}));return(u=e.local[t.id])!=null&&u.outgoing?Oi(h,{a:"unsend",id:t.id}):h}case"clear-attachments":return kt(e,t.id,({notice:h,...p})=>p.attachments.length?{...p,attachments:[]}:p);case"hmr":return kt(e,t.id,h=>({...h,turn:{...h.turn,hmr:!0}}));case"page":return kt(e,t.id,h=>({...h,page:{url:t.url??h.page.url,title:t.title??h.page.title}}));case"links":return kt(e,t.id,h=>{const p=Dz(h.links??[],t.links);return p===h.links?h:{...h,links:p}});case"drag-files":return o3(e.dragFiles,t.v)?e:{...e,dragFiles:t.v};case"sharing":return e.sharing===t.v?e:{...e,sharing:t.v};case"set-picking":return{...e,picking:t.v};case"preview-size":return e.previewSize===t.text?e:{...e,previewSize:t.text};case"open":return{...e,overlay:t.overlay,previewTheme:null,paletteReturn:LN(t.overlay)?e.paletteReturn:null};case"choosing-folder":return{...e,choosingFolder:t.v};case"close":return{...e,previewTheme:null,...S3(e,t.back)};case"toggle":return((f=e.overlay)==null?void 0:f.kind)===t.overlay.kind?Oi(e,{a:"close"}):Oi(e,{a:"open",overlay:t.overlay});case"palette-return":return{...e,paletteReturn:t.v};case"toggle-changes":return{...ho(e,{changes:!e.layout.changes}),changesAuto:!1};case"focus-changes":return{...ho(e,{changes:!0,changesTab:t.tab&&!Wo(e)?t.tab:e.layout.changesTab}),changesAuto:!1,focusChanges:e.focusChanges+1};case"changes-tab":return ho(e,{changesTab:t.v});case"edit-commit":return{...ho(e,{changes:!0}),changesAuto:!1,editCommit:e.editCommit+1};case"toggle-chat":return Co(e)?e:ho(e,{chat:!e.layout.chat});case"focus-chat":return{...ts(e),focusChat:e.focusChat+1};case"walked":return{...e,walked:e.walked+1};case"show-chat":return ts(e);case"hold-unread":return{...e,unreadHold:t.id};case"toggle-rail":return{...e,railOpen:!e.railOpen};case"toggle-chat-side":return{...e,chatSide:e.chatSide==="left"?"right":"left"};case"toggle-black-ground":return{...e,blackGround:!e.blackGround};case"update-check":return{...e,updateCheck:"asking"};case"update-check-settle":return e.updateCheck===t.check?{...e,updateCheck:null}:e;case"focus-rail":return{...e,railOpen:!0,focusRail:e.focusRail+1,screen:"home"};case"screen":return e.screen===t.to&&!e.editor?e:{...t.to==="changes"&&e.screen!=="changes"?ho(e,{changesTab:"changes"}):e,screen:t.to,editor:null,left:t.to==="home"&&e.screen!=="home"?{face:e.screen,at:Date.now()}:e.left};case"frame":{if(e.frame===t.v)return e;const h={...e,frame:t.v};if(t.v!=="desk"||!h.activeRepoId)return h;const p=h.layouts[h.activeRepoId];return p?uy(h,p):h}case"touch":return e.touch===t.v?e:{...e,touch:t.v};case"reading":return e.reading===t.on?e:{...e,reading:t.on};case"typing":return e.typing===t.on?e:{...e,typing:t.on};case"rail-peek":return e.railPeek===t.on?e:{...e,railPeek:t.on};case"toggle-discovered":{const h=e.activeRepoId;return h?{...e,discoveredOpen:{...e.discoveredOpen,[h]:!e.discoveredOpen[h]}}:e}case"toggle-archived":{const h=e.activeRepoId;return h?{...e,archivedOpen:{...e.archivedOpen,[h]:!e.archivedOpen[h]}}:e}case"toggle-committed":{const h=e.activeRepoId;return h?{...e,committedShut:{...e.committedShut,[h]:!e.committedShut[h]}}:e}case"toggle-turn":{const h=e.activeRepoId;return h?{...e,turnOpen:{...e.turnOpen,[h]:!e.turnOpen[h]}}:e}case"tree-folder":{const h=e.treeOpen[t.worktreeId]??[];if(h.includes(t.path)===t.open)return e;const p=t.open?[...h,t.path]:h.filter(y=>y!==t.path),g={...e.treeOpen};return p.length>0?g[t.worktreeId]=p:delete g[t.worktreeId],{...e,treeOpen:g}}case"tree-reveal":{const h=e.treeOpen[t.worktreeId]??[],p=[];for(let w=t.path.indexOf("/");w!==-1;w=t.path.indexOf("/",w+1))p.push(t.path.slice(0,w));p.push(t.path);const g=p.filter(w=>!h.includes(w)),y=g.length?{...e.treeOpen,[t.worktreeId]:[...h,...g]}:e.treeOpen;return{...ho(e,{changes:!0,changesTab:"files"}),changesAuto:!1,focusChanges:e.focusChanges+1,treeOpen:y,treeReveal:{worktreeId:t.worktreeId,path:t.path}}}case"files-asked":return kt(e,t.worktreeId,h=>({...h,filesFor:{index:t.index,disk:t.disk}}));case"toggle-zen":return Co(e)?e:{...e,zen:!e.zen,zenFile:!e.zen&&!!t.file&&!!e.editor};case"zen-page":return e.zenFile?{...e,zenFile:!1}:e;case"toggle-terminal":return ho(e,{term:!e.layout.term});case"focus-terminal":return{...ho(e,{term:!0}),focusTerm:e.focusTerm+1};case"toggle-design":return Co(e)?e:ho(e,{design:!e.layout.design});case"term-stream":return kt({...ho(e,{term:!0}),termTall:t.tall?e.termTall+1:e.termTall},t.id,h=>({...h,termStream:t.stream}));case"term-run":return kt({...ho(e,{term:!0}),focusTerm:e.focusTerm+1,termRun:{id:t.id,command:t.command}},t.id,h=>({...h,termStream:Bo}));case"term-ran":return e.termRun?{...e,termRun:null}:e;case"preview-theme":return{...e,previewTheme:t.theme};case"system-dark":return{...e,systemDark:t.v};case"incompatible":return t.v===!1?{...e,incompatible:!1}:{...e,incompatible:!0,connected:!1};case"server":return K3(e,t.msg);case"recall":return W3(e,t.hello,t.chats)}}function FN(e,t){const n=Object.entries(e),r=n.filter(([o])=>t.some(s=>s.id===o));return r.length===n.length?e:Object.fromEntries(r)}function BN(e,t,n){const r=new Set(t.map(a=>a.id));n&&r.add(n);const o=([a,l])=>r.has(a)||!!l.draft||l.attachments.length>0,s=Object.entries(e);return s.every(o)?e:Object.fromEntries(s.filter(o))}function R3(e,t,n){var o;let r=e;for(const s of n){if(!((o=s.worktree)!=null&&o.landed)||s.dirty!==0||t.some(f=>{var h;return f.id===s.id&&((h=f.worktree)==null?void 0:h.landed)}))continue;const a=r[s.id];if(!(a!=null&&a.git)||a.git.files.length===0)continue;r===e&&(r={...e});const{extras:l,...u}=a.git;r[s.id]={...a,git:{...u,files:[]}}}return r}function O3(e,t){const{version:n,files:r,ahead:o,behind:s,unpushed:a,head:l}=t,u={version:n,files:r,...o===void 0?{}:{ahead:o},...s===void 0?{}:{behind:s},...a===void 0?{}:{unpushed:a},...l===void 0?{}:{head:l}};if(t.extras)return{...u,extras:t.extras};const f=new Map(e==null?void 0:e.files.map(y=>[y.path,y])),h=r.map(y=>{const w=f.get(y.path);return w&&w.xy===y.xy&&w.add!==void 0?{...y,add:w.add,del:w.del}:y}),p=e!=null&&e.extras&&e.head===l?e.extras:void 0,g=p&&r.length===0&&p.turn?{committed:p.committed}:p;return{...u,files:h,...g?{extras:g}:{}}}function M3(e,t,n){if(!e||e.head!==t.head)return{};if(e.version===t.version)return n;const r=new Set([...e.files,...t.files].map(s=>s.path));let o=n;for(const s of Object.keys(n))r.has(s)&&(o===n&&(o={...n}),delete o[s]);return o}function L3(e){let t=e;for(const[n,r]of Object.entries(e))!r.git||r.git.version===0||(t===e&&(t={...e}),t[n]={...r,git:{...r.git,version:0}});return t}function _g(e,t){return e!==void 0&&e.length===t.length&&e.every((n,r)=>n===t[r])}function P3(e){if(!e.tracked||!e.git||Lw(e.git.head,e.git.files)!==e.trackedAt)return e;const t=e_(e.tracked,e.git.files);return t.key===e.filesDelta?e:{...e,files:t_(e.tracked,t),filesDelta:t.key}}function D3(e,t){if(!e.filesFor)return e;const n=Lw(t.head,t.files);return{...e,filesFor:{index:n,disk:JS(t.files)},...e.tracked?{trackedAt:n}:{}}}function z3(e){let t=e;for(const[n,r]of Object.entries(e)){if(r.filesFor===void 0)continue;t===e&&(t={...e});const{filesFor:o,...s}=r;t[n]=s}return t}function F3(e,t){let n=e;for(const[r,o]of Object.entries(t)){const s=n[r];s!=null&&s.draft||ws(r)||(n===e&&(n={...e}),n[r]={...s??Za,draft:o})}return n}function B3(e,t){let n=e;for(const[r,o]of Object.entries(t)){const s=n[r];s!=null&&s.attachments.length||ws(r)||(n===e&&(n={...e}),n[r]={...s??Za,attachments:bk(o,[])})}return n}function U3(e,t){const n=new Set(t.map(r=>r.id));return Object.values(e).every(r=>n.has(r))?e:Object.fromEntries(Object.entries(e).filter(([,r])=>n.has(r)))}function Ds(e,t){const n=new Set(t.map(r=>r.id));return Object.keys(e).every(r=>n.has(r))?e:Object.fromEntries(Object.entries(e).filter(([r])=>n.has(r)))}function Lx(e){const t=e.newProject;if((t==null?void 0:t.phase)!=="creating"||!t.repoId)return e;const n=$N(e,t.repoId);if(!n)return e;const r=Or(e,el);return!r.draft.trim()&&r.attachments.length===0?{...e,newProject:null}:{...UN(e,el,n.id),newProject:null,autoSend:n.id}}function UN(e,t,n){const r=e.local[t];if(!r)return e;const o=kt(e,n,s=>({...s,draft:r.draft,attachments:r.attachments}));return kt(o,t,s=>({...s,draft:"",attachments:[]}))}function Cf(e,t,n){return e.stamps?{...e.stamps,[t]:n}:null}function H3(e){return e.stamps?qD(e.stamps):null}function HN(e,t){return Object.values(e.trunks).some(n=>n.id===t)}function WN(e,t,n){var w;const{rows:r,repos:o,trunks:s,visits:a}=t.same?e:t,l=v=>!!v&&r.some(x=>x.id===v),u=v=>!!v&&o.some(x=>x.id===v),f=u(e.activeRepoId)?e.activeRepoId:u(e.storedRepo)?e.storedRepo:null,h=l(e.activeId)?e.activeId:l(e.storedActive)?e.storedActive:Oa(e,f,r),p=r.find(v=>v.id===h),g=!!f&&!!p&&Tn(p)&&hp(p,f,r,e.lent),y={...e,heard:!n,heardAt:n?e.heardAt:Date.now(),recalledAt:n?e.recalledAt:null,stamps:n?null:t.stamps,repos:o,rows:r,activeId:h,lent:g?e.lent===h?e.lent:AN(p??null,f,r):null,activeRepoId:g?f:(p==null?void 0:p.repoId)??f??((w=o[0])==null?void 0:w.id)??null,trunks:s,archiving:e.archiving.length?[]:e.archiving,shipping:RN({},r,s),local:L3(BN(B3(F3(e.local,t.drafts),t.attachments),r,e.archivedPage)),lastActive:U3(e.lastActive,r),viewed:Ek(e.viewed,gh({rows:r,archived:Ds(e.archived,o)})),treeOpen:FN(e.treeOpen,r),discoveredOpen:Ds(e.discoveredOpen,o),archivedOpen:Ds(e.archivedOpen,o),committedShut:Ds(e.committedShut,o),turnOpen:Ds(e.turnOpen,o),refs:Ds(e.refs,o),chats:Ds(e.chats,o),archived:Ds(e.archived,o),themes:!n&&t.themes?t.themes:e.themes,themePrefs:!n&&t.themePrefs?t.themePrefs:e.themePrefs,agents:t.agents,defaultAgent:t.defaultAgent,agentChosen:t.agentChosen,home:t.home,folderDialog:t.folderDialog,keepAwake:t.keepAwake,remote:t.remote,machine:t.machine,managed:t.managed,tailscale:t.tailscale,handed:t.machines,gitIdentity:t.gitIdentity,newProject:e.newProject??(!n&&o.length===0&&r.length===0&&t.pending.length===0?EN():null),pending:n?e.pending:t.pending,visits:a,self:n?e.self:t.self,update:n?e.update:t.update,globalInstall:n?e.globalInstall:t.globalInstall,updateCheck:!n&&e.updateCheck==="asking"?null:e.updateCheck,version:n?e.version:t.version,install:n?e.install:t.install,registry:n?e.registry:t.registry,activeImportId:t.pending.some(v=>v.id===e.activeImportId)?e.activeImportId:null};return n?y:zN(y,t.knocks,t.letIn)}function Tk(e,t=[]){let n=t,r;for(const{seq:o,event:s}of e)n=qN(n,s,o),s.type==="usage"&&(r=KN(s));return r?{chat:n,usage:r}:{chat:n}}function W3(e,t,n){var s;let r=WN(e,Zz(t),!0);r={...r,recalledAt:t.at};for(const[a,l]of Object.entries(n))if(r.rows.some(u=>u.id===a))try{const{chat:u,usage:f}=Tk(l.events);r=kt(r,a,h=>({...h,chat:ZN(u),chatAt:Yz(l.events)??t.at,running:void 0,...f?{usage:f}:{},...l.draft&&!h.draft?{draft:l.draft}:{}}))}catch{}const o=r.activeId;return o&&r.screen!=="home"&&!(((s=r.local[o])==null?void 0:s.chat.length)??0)&&(r={...r,screen:"home"}),r}function K3(e,t){var n,r,o,s,a,l,u,f,h,p,g,y,w,v,x,N;switch(t.t){case"hello":return WN(e,t,!1);case"self":{const S=((n=e.self)==null?void 0:n.building)===!0&&e.self.rebuild&&!((r=t.self)!=null&&r.building);return{...e,self:t.self,rebuilt:e.rebuilt||S&&((o=t.self)==null?void 0:o.buildFailed)===void 0}}case"remote":return{...e,remote:t.remote,machine:t.machine};case"machines":return{...e,handed:t.machines};case"tailscale":return{...e,tailscale:t.tailscale};case"knocks":return zN(e,t.knocks,t.letIn);case"update":return{...e,update:t.update};case"global-install":return{...e,globalInstall:t.globalInstall};case"update-checked":return{...e,updateCheck:t.check};case"visits":return{...e,visits:{...e.visits,[t.repoId]:t.pages},stamps:Cf(e,"visits",t.stamp)};case"themes":return{...e,themes:t.themes,themePrefs:t.prefs,stamps:Cf(e,"themes",t.stamp)};case"daylight":return{...e,daylight:{dark:t.dark,until:t.until}};case"keep-awake":return{...e,keepAwake:t.mode};case"agents":return{...e,agents:t.agents,defaultAgent:t.defaultAgent,agentChosen:t.agentChosen};case"agent-config":{const{t:S,...T}=t;return{...e,agentConfigs:{...e.agentConfigs,[T.agent]:T}}}case"pending-repos":{const S=new Set(e.pending.map(A=>A.id)),T=t.pending.find(A=>!S.has(A.id)),j=T&&e.pendingOpen?T.id:e.activeImportId,$=t.pending.some(A=>A.id===j),R=t.pending.some(A=>A.id===j&&A.error);return{...e,pending:t.pending,activeImportId:$?j:null,pendingOpen:R?!1:e.pendingOpen,newProject:T&&e.pendingOpen&&((s=e.newProject)==null?void 0:s.phase)==="creating"?null:e.newProject}}case"path-entries":return{...e,paths:{query:t.query,entries:t.entries,target:t.target}};case"folder-chosen":return{...e,chosenFolder:{seq:(((a=e.chosenFolder)==null?void 0:a.seq)??0)+1,folder:t.folder}};case"refs":return{...e,refs:{...e.refs,[t.repoId]:{query:t.query,refs:t.refs}}};case"chat-hits":return{...e,chats:{...e.chats,[t.repoId]:{query:t.query,hits:t.hits,truncated:t.truncated,asks:t.asks}}};case"archived":{const S=(e.archived[t.repoId]??[]).filter(j=>e.archiving.includes(j.id)&&!t.items.some($=>$.id===j.id)),T={...e.archived,[t.repoId]:S.length?[...S,...t.items]:t.items};return{...e,archived:T,viewed:Ek(e.viewed,gh({rows:e.rows,archived:T}))}}case"draft":return t.clientId===e.clientId||ws(t.boxId)?e:kt(e,t.boxId,S=>{var T;return S.draft===t.text||((T=S.mark)==null?void 0:T.by)==="walk"?S:{...S,draft:t.text}});case"attachments":return t.clientId===e.clientId||ws(t.boxId)?e:kt(e,t.boxId,S=>({...S,attachments:bk(t.items,S.attachments)}));case"repos":{const S=new Set(e.repos.map(P=>P.id)),T=t.repos.find(P=>!S.has(P.id));let j=e.activeRepoId,$=e.pendingOpen,R=e.newProject;T&&($||!j)?(j=T.id,$=!1,R&&R.phase!=="unmaking"&&(R={...R,phase:"creating",repoId:T.id})):t.repos.some(P=>P.id===j)||(j=((l=t.repos[0])==null?void 0:l.id)??null),(R==null?void 0:R.phase)==="unmaking"&&!t.repos.some(P=>P.id===(R==null?void 0:R.repoId))&&(R={...R,phase:"editing",repoId:null}),t.repos.length===0&&!R&&(R=EN());const A=e.gitIdentity||t.repos.some(P=>P.made&&!S.has(P.id)),I=Cf(e,"repos",t.stamp),M=Ds(e.visits,t.repos);return j===e.activeRepoId?{...e,repos:t.repos,stamps:I,visits:M,pendingOpen:$,newProject:R,gitIdentity:A}:Lx({...e,repos:t.repos,stamps:I,visits:M,pendingOpen:$,newProject:R,gitIdentity:A,activeRepoId:j,activeId:Oa(e,j),editor:null})}case"worktrees":{const{rows:S,complete:T}=Hz(e.rows,t),j=t.trunks??e.trunks;let $=e.activeId;(!$||!S.some(P=>P.id===$))&&($=Oa(e,e.activeRepoId,S));const R=new Set(e.rows.map(P=>P.id)),A=P=>{var F;return((F=P.worktree)==null?void 0:F.kind)==="worktree"&&P.worktree.createdBy===e.clientId},I=S.find(P=>!R.has(P.id)&&A(P));I&&e.rows.length>0&&($=I.id);const M=e.archiving.filter(P=>S.some(F=>F.id===P));return Lx({...Ii({...e,rows:S,trunks:j,stamps:Cf(e,"rows",T?t.stamp:""),archiving:M.length===e.archiving.length?e.archiving:M,shipping:RN(e.shipping,S,j),local:BN(b3(R3(e.local,e.rows,S),S,e.activeId,$===(I==null?void 0:I.id)?I.id:void 0),S,e.archivedPage),treeOpen:FN(e.treeOpen,S),viewed:Ek(e.viewed,gh({rows:S,archived:e.archived}))},$),editor:$===e.activeId?e.editor:null,...I&&$===I.id?{carryTo:I.id}:{},...$===e.activeId?{activeRepoId:e.activeRepoId}:{},archivedPage:I?null:e.archivedPage,notesPage:I?!1:e.notesPage})}case"log":return kt(e,t.worktreeId,S=>({...S,log:eR(S.log.slice(-400),t.proc,t.line,t.retract)}));case"agent":{const S=t.event,T=t.worktreeId;let j=kt(e,T,$=>{const R=qN($.chat,S,t.seq),A=S.type==="turn-end",I=A||S.type==="agent-error"||S.type==="agent-auth-required",P=S.type==="tool-start"||S.type==="tool-end"||A||S.type==="tool-update"&&S.background?Ox(R,$.running):$.running;let F=$.turn;S.type==="turn-start"?F={edits:!1,hmr:!1}:S.type==="tool-start"&&DS(S)&&(F={...F,edits:!0});const q=S.type==="session-info"&&S.model?S.model:$.model,W=S.type==="session-info"&&S.effort?S.effort:$.effort,ee=S.type==="usage"?{...KN(S),heard:Date.now()}:$.usage,V=e.rows.find(oe=>oe.id===T),te=is(V==null?void 0:V.agent),K=$.sending?te?Ru($):{...$,sending:{at:$.sending.at}}:$,C=x3(S.type==="user-message"?K:I?Ru($):$,S);return{...S.type==="user-message"?Fc(C,"reveal"):C,chat:R,...R!==$.chat?{chatAt:Date.now()}:{},...P!==$.running?{running:P}:{},turn:F,...q!==$.model?{model:q}:{},...W!==$.effort?{effort:W}:{},...ee!==$.usage?{usage:ee}:{}}});if(S.type==="agent-ask-end"&&!Qw(S.outcome)&&((u=j.local[Hc(S.id)])!=null&&u.attachments.length)&&(j=kt(j,Hc(S.id),$=>({...$,attachments:[]}))),S.type==="user-message"){const $=sN(((f=e.local[T])==null?void 0:f.chat)??[]),R=$?Hc($.id):null,A=R?((h=j.local[R])==null?void 0:h.attachments)??[]:[];R&&A.length&&(j=kt(j,R,I=>({...I,attachments:[]})),j=kt(j,T,I=>({...I,attachments:[...I.attachments,...A]})))}if(S.type==="turn-end"){const $=j.local[T].turn;$.edits&&!$.hmr&&(j={...j,reloadReq:{id:T,n:(((p=j.reloadReq)==null?void 0:p.n)??0)+1}})}return(S.type==="agent-question"||S.type==="agent-permission"||S.type==="handoff-proposed"&&!S.held||S.type==="handoff-shown")&&T===e.activeId&&(j=ts(j)),j}case"backfill":{const S=T=>t.events.some(({event:j})=>j.type==="user-message"&&j.text===T);return kt(e,t.worktreeId,({sending:T,...j})=>{const{chat:$,usage:R}=t.after!==void 0?Tk(t.events,j.chat):Tk(t.events);return{...j,...T&&!(T.message&&S(T.message.text))?{sending:T}:{},chat:$,chatAt:Date.now(),running:Ox($,j.running),log:t.log??j.log,...R?{usage:R}:{}}})}case"git-status":{const S=(g=e.local[t.worktreeId])==null?void 0:g.git;if(t.version>0&&S&&t.version<S.version||t.version>0&&S&&t.version===S.version&&!t.extras)return e;let T=e.layout.changes,j=e.changesAuto;const $=((y=t.extras)==null?void 0:y.committed.length)??0;e.changesAuto&&t.worktreeId===e.activeId&&!T&&(t.files.length>0||$>0)&&(T=!0,j=!1);const R=t.worktreeId===e.archivedPage?Wo(e):null;R&&(t.files.length>0||$>0||R.landed)&&(T=!0);const A=kt(e,t.worktreeId,I=>{const M=O3(I.git,t),P={...I,git:M,changedRanges:M3(I.git,M,I.changedRanges)};return P3(I.git?P:D3(P,M))});return{...ho(A,{changes:T}),changesAuto:j}}case"pr-comments":return kt(e,t.worktreeId,S=>({...S,prComments:t.comments}));case"changed-ranges":{const S=kt(e,t.worktreeId,j=>({...j,changedRanges:{...j.changedRanges,[t.path]:{ranges:t.ranges,offset:t.lineOffset}}})),T=S.editor;return!((w=T==null?void 0:T.line)!=null&&w.fiber)||T.worktreeId!==t.worktreeId||T.path!==t.path?S:{...S,editor:{...T,line:SN(S,T.worktreeId,T.path,T.line)}}}case"shipped":{const S=t.worktreeId,T={...e,shipping:Rx(e.shipping,j=>{var $;return j===S&&(($=e.shipping[j])==null?void 0:$.sent)===!0}),openUrl:t.ok&&t.url?t.url:e.openUrl};return!t.ok&&!t.asked?S?Mx(T,S,t.message):Nk(T,t.message):T}case"files":return kt(e,t.worktreeId,S=>{var M;const T=_g(S.tracked,t.paths)?S.tracked:t.paths,j=_g(S.submodules,t.submodules)?S.submodules:t.submodules,$=e_(T,((M=S.git)==null?void 0:M.files)??[]),R=T===S.tracked&&$.key===S.filesDelta?S.files:void 0,{trackedAt:A,...I}=S;return{...I,tracked:T,...S.filesFor?{trackedAt:S.filesFor.index}:{},submodules:j,files:R??t_(T,$),filesDelta:$.key}});case"ignored-files":return _g((v=e.local[t.worktreeId])==null?void 0:v.ignored,t.ignored)?e:kt(e,t.worktreeId,S=>({...S,ignored:t.ignored}));case"search-results":return kt(e,t.worktreeId,S=>({...S,search:{query:t.query,hits:t.hits,truncated:t.truncated}}));case"element-sources":{if(e.editor&&e.editor.seq>t.seq)return e;const[S]=t.hits;if(!S)return kt(e,t.worktreeId,j=>({...j,notice:"nothing in the source matches this element"}));if(!t.sure)return Oi(e,{a:"open",overlay:{kind:"element-sources",worktreeId:t.worktreeId,hits:t.hits}});const T=Oi(e,{a:"open-file",v:{worktreeId:t.worktreeId,path:S.path,view:"file",line:{n:S.line},focus:!0,seq:t.seq}});return T.layout.changes?T:Oi(T,{a:"toggle-changes"})}case"design-index":return kt(e,t.worktreeId,S=>({...S,design:t.index}));case"routes":return kt(e,t.worktreeId,S=>({...S,pages:{routes:t.routes,unseen:t.unseen}}));case"queue":return kt(e,t.worktreeId,S=>({...S,queue:t.items}));case"agent-commands":return kt(e,t.worktreeId,S=>({...S,commands:t.commands}));case"git-log":return kt(e,t.worktreeId,S=>({...S,commits:t.commits}));case"git-commit":return kt(e,t.worktreeId,S=>({...S,commitFiles:{...S.commitFiles,[t.sha]:t.files}}));case"error":{const S=t.worktreeId,T=e.newProject,j=(T==null?void 0:T.phase)==="creating"&&!T.repoId,$=S?e.archiving.includes(S)?[S]:[]:e.archiving,R={...v3(e,S),archiving:$.length?e.archiving.filter(A=>!$.includes(A)):e.archiving,archived:$.length?k3(e.archived,$):e.archived,shipping:Rx(e.shipping,A=>!S||A===S),newProject:j?{...T,phase:"editing",error:t.message}:(T==null?void 0:T.phase)==="unmaking"?null:T,pendingOpen:j?!1:e.pendingOpen,updateCheck:!S&&e.updateCheck==="asking"?null:e.updateCheck};return j?R:S?Mx(R,S,t.message):Nk(R,t.message)}case"unsent":{const S=((x=ws(t.boxId))==null?void 0:x.source)??t.boxId,T=!Kr(e,S)&&!!e.activeRepoId&&((N=e.archived[e.activeRepoId])==null?void 0:N.some(j=>j.id===S));return kt(ts(T?Sk(e,S):e),S,({sending:j,...$})=>({...$,draft:$.draft||t.text,attachments:[...bk(t.items,[]),...$.attachments],notice:t.message}))}default:return e}}function KN(e){return{used:e.used,size:e.size,...e.cost!==void 0?{cost:e.cost}:{}}}function q3(e,t){const n=t.trim();return n!==""&&(e.trim()===n||e.trim().endsWith(`: ${n}`))}function qN(e,t,n){var s,a,l,u;const r=e[e.length-1],o=n===void 0?{}:{seq:n};switch(t.type){case"fix-asked":return[...e,{kind:"asked",about:t.kind,why:t.why,...t.toolId?{toolId:t.toolId}:{}}];case"user-message":return[...e,{kind:"user",text:t.text,...(s=t.attachments)!=null&&s.length?{attachments:t.attachments}:{},...o}];case"handed":return[...e,{kind:"handed",via:t.via,...t.body?{body:t.body}:{},...t.path?{path:t.path}:{},...t.note?{note:t.note}:{},origin:t.origin,...(a=t.attachments)!=null&&a.length?{attachments:t.attachments}:{},...o,ts:t.ts}];case"text-delta":{const f=t.messageId?{messageId:t.messageId}:{};if((r==null?void 0:r.kind)==="assistant"&&r.messageId===t.messageId)return[...e.slice(0,-1),{...r,text:r.text+t.text}];const h=t.messageId===void 0?-1:Z3(e,t.messageId);if(h!==-1){const p=e.slice(),g=p[h];return p[h]={...g,text:g.text+t.text},p}return[...e,{kind:"assistant",text:t.text,...o,...f}]}case"picture":{const{type:f,...h}=t;let p=e.findLastIndex(w=>w.kind==="assistant"&&w.text.includes(h.path));if(p===-1&&(p=e.findLastIndex(w=>w.kind==="assistant")),p===-1)return e;const g=e.slice(),y=g[p];return g[p]={...y,pictures:[...(y.pictures??[]).filter(w=>w.path!==h.path),h]},g}case"thinking-delta":return(r==null?void 0:r.kind)==="thinking"?[...e.slice(0,-1),{...r,text:r.text+t.text}]:[...e,{kind:"thinking",text:t.text}];case"tool-start":return[...e,{kind:"tool",id:t.toolId,name:t.name,input:t.input,done:!1,...t.kind?{toolKind:t.kind}:{},...t.title?{title:t.title}:{},...t.parentToolId?{parentToolId:t.parentToolId}:{},...t.subagent?{subagent:!0}:{}}];case"tool-update":{const f=e.findLastIndex(g=>g.kind==="tool"&&g.id===t.toolId);if(f===-1)return e;const h=e.slice(),p=h[f];return h[f]={...p,...t.name?{name:t.name}:{},...t.title?{title:t.title}:{},...t.input!==void 0?{input:t.input}:{},...t.kind?{toolKind:t.kind}:{},...t.background?{background:!0}:{},...t.until?{until:t.until}:{}},h}case"tool-delta":{const f=e.findLastIndex(g=>g.kind==="tool"&&g.id===t.toolId);if(f===-1)return e;const h=e.slice(),p=h[f];return h[f]={...p,output:(p.output??"")+t.text},h}case"tool-end":{const f=e.findLastIndex(g=>g.kind==="tool"&&g.id===t.toolId);if(f===-1)return e;const h=e.slice(),p=h[f];return h[f]={...p,output:t.output,isError:t.isError,...(l=t.images)!=null&&l.length?{images:t.images}:{},...t.detached?{detached:!0}:{},...t.fixable?{fixable:t.fixable}:{},...t.cut?{cut:!0}:{},done:!0},h}case"agent-error":return(r==null?void 0:r.kind)==="assistant"&&q3(t.message,r.text)?[...e.slice(0,-1),{kind:"error",text:t.message,...o}]:[...e,{kind:"error",text:t.message,...o}];case"agent-blocked":return[...e,{kind:"blocked",tool:t.tool,path:t.path,reason:t.reason}];case"grafted":return[...e,{kind:"grafted",title:t.title,branch:t.branch}];case"model-switched":return[...e,{kind:"switched",name:t.name,...t.asked?{asked:t.asked}:{}}];case"landed":return[...e,{kind:"landed",text:t.message,...t.mark?{mark:t.mark}:{},...t.url?{url:t.url}:{},...t.held?{held:t.held}:{},ts:t.ts}];case"piece-landed":return[...e,{kind:"piece-landed",worktreeId:t.worktreeId,repoName:t.repoName,title:t.title,...t.url?{url:t.url}:{},...t.same?{same:!0}:{},...t.again?{again:!0}:{},...t.awaited?{awaited:!0}:{},ts:t.ts}];case"handoff-proposed":{const f=t.held?e.findLast(p=>p.kind==="ask"&&!p.outcome&&p.ask.kind==="permission"&&!!p.ask.plan):void 0,h=(f==null?void 0:f.kind)==="ask"&&f.ask.kind==="permission"?{companion:f.id,plan:f.ask.plan}:{};return[...e,{kind:"handoff",id:t.id,pieces:t.pieces,fates:Object.fromEntries(t.pieces.map(p=>[p.id,p.fate])),mode:t.mode,...t.held?{held:!0}:{},...t.plan?{plan:t.plan}:{},...t.by?{by:t.by}:{},...h,state:t.held?"held":"proposed",outcomes:[],later:[],ts:t.ts}]}case"handoff-stale":{const f=ya(e,t.id,["held","proposed"]);return f===-1?e:e.with(f,{...e[f],stale:!0})}case"handoff-shown":{const f=ya(e,t.id,["held","proposed"]);if(f===-1)return e;const h=e[f];return e.with(f,{...h,state:"proposed",...t.plan?{plan:t.plan}:{}})}case"handoff-fate":{const f=ya(e,t.id,["held","proposed"]);if(f===-1)return e;const h=e[f];return e.with(f,{...h,fates:{...h.fates,[t.pieceId]:t.fate}})}case"handoff-go":{const f=ya(e,t.id,["held","proposed"]);if(f===-1)return e;const h=e[f];if(h.state!=="proposed")return e.with(f,{...h,state:"going"});const p={go:!0,...t.note?{note:t.note}:{}};return Px(e,f,{...h,state:"going",answered:p,ts:t.ts})}case"handoff-piece":{const f=ya(e,t.id,["going"]);if(f===-1)return e;const h=e[f];return e.with(f,{...h,outcomes:[...h.outcomes,t.outcome]})}case"handoff":{const f=ya(e,t.id,["held","proposed","going"]);return f===-1?[...e,{kind:"handoff",id:t.id,pieces:[],fates:{},mode:ok,state:"done",outcomes:t.outcomes,later:[],ts:t.ts}]:e.with(f,{...e[f],state:"done",outcomes:t.outcomes})}case"handoff-declined":{const f=ya(e,t.id,["held","proposed","going"]);if(f===-1)return e;const h=e[f],{companion:p,...g}=h,y=t.plan?{...g,plan:t.plan}:h;return y.state==="proposed"&&!t.reason?Px(e,f,{...y,state:"declined",answered:{go:!1,...t.note?{note:t.note}:{}},ts:t.ts}):e.with(f,{...y,state:"declined",...t.reason?{reason:t.reason}:{}})}case"piece-made":case"piece-dropped":{const f=e.findLastIndex(v=>v.kind==="handoff"&&v.id===t.id),h=f===-1?void 0:e[f],p=t.type==="piece-made"?{pieceId:t.pieceId,worktreeId:t.worktreeId,title:t.title}:{pieceId:t.pieceId,reason:t.reason},g=t.type==="piece-made"?t.title:(u=h==null?void 0:h.pieces.find(v=>v.id===t.pieceId))==null?void 0:u.title,y={kind:"piece-later",id:t.id,...g?{title:g}:{},...p,ts:t.ts};return[...h?e.with(f,{...h,later:[...h.later,p]}):e,y]}case"restored":return[...e,{kind:"restored",archivedAt:t.archivedAt,branch:t.branch,uncommitted:t.uncommitted,ts:t.ts}];case"adopted":return[...e,{kind:"adopted",branch:t.branch,ts:t.ts}];case"owned":return[...e,{kind:"owned",names:t.names,by:t.by,...t.file?{file:t.file}:{},ts:t.ts}];case"own-failed":return[...e,{kind:"own-failed",name:t.name,cmd:t.cmd,exit:t.exit,ts:t.ts}];case"agent-auth-required":return[...e,{kind:"auth",agent:t.agent,agentName:t.agentName,methods:t.methods,...t.rejected?{rejected:!0}:{},...t.withheld?{withheld:!0}:{},...t.provider?{provider:t.provider}:{},...t.detail?{detail:t.detail}:{},...t.refresh?{refresh:t.refresh}:{},done:!1}];case"agent-auth-ok":return e.some(f=>f.kind==="auth"&&!f.done)?e.map(f=>f.kind==="auth"&&!f.done?{...f,done:!0}:f):e;case"agent-question":return Dx(e,t.toolId,{kind:"ask",id:t.id,ask:{kind:"question",message:t.message,questions:t.questions}});case"agent-permission":{const f={kind:"ask",id:t.id,ask:{kind:"permission",title:t.title,...t.command?{command:t.command}:{},...t.detail?{detail:t.detail}:{},...t.plan?{plan:t.plan}:{},...t.handoff?{handoff:t.handoff}:{},choices:t.choices}},h=t.handoff?e.findLastIndex(y=>y.kind==="handoff"&&y.id===t.handoff):-1,p=h===-1?e:e.with(h,{...e[h],companion:t.id,...t.plan&&!e[h].plan?{plan:t.plan}:{}}),g=p.findLast(y=>y.kind==="tool"&&y.id===t.toolId);return(g==null?void 0:g.kind)!=="tool"||t.plan||g.toolKind==="switch_mode"?Dx(p,t.toolId,f):[...p,{...f,toolId:g.id}]}case"agent-ask-end":{const f=e.findLastIndex(g=>g.kind==="ask"&&g.id===t.id&&!g.outcome);if(f===-1)return e;const h=e[f];if(h.toolId&&G3(h,t.choiceId))return[...e.slice(0,f),...e.slice(f+1)];const p=e.slice();return p[f]={...p[f],outcome:t.outcome,...t.answers?{answers:t.answers}:{},...t.choiceId?{choiceId:t.choiceId}:{}},p}case"turn-end":{const f=ZN(e);return t.stopReason==="interrupted"?[...f,{kind:"stopped",...o}]:f}default:return e}}function ZN(e){const t=n=>n.kind==="tool"&&!n.done&&!n.background;return e.some(t)?e.map(n=>t(n)?{...n,done:!0}:n):e}function Z3(e,t){const n=s=>Qu(s)||s.kind==="handoff"&&!!s.answered;let r=e.length-1;for(;r>=0&&n(e[r]);)r--;const o=e[r];return(o==null?void 0:o.kind)==="assistant"&&o.messageId===t?r:-1}function ya(e,t,n){return e.findLastIndex(r=>r.kind==="handoff"&&r.id===t&&n.includes(r.state))}function Px(e,t,n){return[...e.slice(0,t),...e.slice(t+1),n]}function G3(e,t){var n;return e.ask.kind!=="permission"||!t?!1:!!((n=e.ask.choices.find(r=>r.id===t))!=null&&n.kind.startsWith("allow"))}function Dx(e,t,n){const r=t?e.findLastIndex(o=>o.kind==="tool"&&o.id===t):-1;return r===-1?[...e,n]:[...e.slice(0,r),...e.slice(r+1),n]}function V3(e){let t=e;const n=new Set;return{getState:()=>t,dispatch(r){const o=Oi(t,r);if(o!==t){t=o;for(const s of n)s()}},subscribe(r){return n.add(r),()=>n.delete(r)}}}const GN=E.createContext(null),my=E.createContext(null),VN=E.createContext(null);function Y3({store:e,sock:t,files:n,children:r}){return d.jsx(GN.Provider,{value:e,children:d.jsx(my.Provider,{value:t,children:d.jsx(VN.Provider,{value:n,children:r})})})}const YN=E.createContext(null),XN=E.createContext(null);function X3({machines:e,children:t}){const n=E.useSyncExternalStore(e.subscribe,e.active);return d.jsx(YN.Provider,{value:e,children:d.jsx(XN.Provider,{value:n,children:d.jsx(Y3,{store:n.store,sock:n.sock,files:n.files,children:d.jsx(E.Fragment,{children:t},n.origin)})})})}function xs(){const e=E.useContext(YN);if(!e)throw new Error("useMachines outside <MachinesProvider>");return e}function Gs(){const e=E.useContext(XN);if(!e)throw new Error("useMachine outside <MachinesProvider>");return e}function gy(){const e=xs();return E.useSyncExternalStore(e.subscribe,e.list)}function ou(e,t){return E.useSyncExternalStore(e.store.subscribe,()=>t(e.store.getState()))}const jk=(e,t)=>e.length===t.length&&e.every((n,r)=>n===t[r]);function QN(){const e=xs(),t=Gs(),n=gy(),r=E.useMemo(()=>n.filter(l=>l!==t),[n,t]),o=E.useRef(null),s=E.useCallback(l=>{const u=r.map(f=>f.store.subscribe(l));return()=>{for(const f of u)f()}},[r]),a=E.useCallback(()=>{const l=r.map(p=>e.displayName(p.origin)),u=r.map(p=>p.store.getState().repos),f=o.current;if(f&&f.others===r&&jk(f.names,l)&&jk(f.repos,u))return f.value;const h=r.map((p,g)=>({origin:p.origin,name:l[g]??p.origin,repos:u[g]??[]}));return o.current={others:r,names:l,repos:u,value:h},h},[r,e]);return E.useSyncExternalStore(s,a)}function JN(){const e=Gs(),t=gy(),n=E.useMemo(()=>t.filter(a=>a!==e),[t,e]),r=E.useRef(null),o=E.useCallback(a=>{const l=n.map(u=>u.store.subscribe(a));return()=>{for(const u of l)u()}},[n]),s=E.useCallback(()=>{const a=n.map(f=>{const h=f.store.getState();return h.connected&&!h.incompatible?h.rows:zx}),l=r.current;if(l&&l.others===n&&jk(l.rows,a))return l.value;const u=n.map((f,h)=>({origin:f.origin,rows:(a[h]??zx).filter(Tn)}));return r.current={others:n,rows:a,value:u},u},[n]);return E.useSyncExternalStore(o,s)}const zx=[];function VX(){return Gs().terminals}function Pn(){const e=E.useContext(GN);if(!e)throw new Error("useStore outside <StoreProvider>");return e}function L(e){const t=Pn();return E.useSyncExternalStore(t.subscribe,()=>e(t.getState()))}function ky(){const e=L(n=>n.systemDark),t=L(n=>{var r;return(r=n.daylight)==null?void 0:r.dark});return{system:e,daylight:t??e}}function ht(){return Pn().dispatch}function nt(){return E.useContext(my)}function Mr(){const e=E.useContext(my);return(e==null?void 0:e.urls)??Xw(location.origin,"")}function wy(){return E.useContext(VN)}function Q3(e=!1,t=!0){const n=E.useRef(null);return E.useEffect(()=>{if(!t)return;const r=()=>{const s=n.current;!s||document.activeElement===s||(s.focus(),e&&s instanceof HTMLInputElement&&s.select())};r();const o=requestAnimationFrame(r);return()=>cancelAnimationFrame(o)},[e,t]),n}function ks(e,t,n,r=J3){const o=()=>{try{return n(r.get(e))??t}catch{return t}},[s,a]=E.useState(()=>({key:e,value:o()}));return s.key!==e&&a({key:e,value:o()}),[s.key===e?s.value:o(),f=>{a({key:e,value:f});try{r.set(e,typeof f=="boolean"?f?"1":"0":String(f))}catch{}}]}const J3={get:e=>localStorage.getItem(e),set:(e,t)=>localStorage.setItem(e,t)};function e6(e,t){const[n,r]=E.useState(!0);return E.useLayoutEffect(()=>{const o=e.current;if(!o)return;const s=()=>r(o.clientWidth>=t);s();const a=new ResizeObserver(s);return a.observe(o),()=>a.disconnect()},[e,t]),n}function qc(e,t){return n=>{n.preventDefault(),document.body.classList.add("resizing");const r=n.currentTarget;r.classList.add("active");const o=a=>{const l=e(a,r);l!==null&&t(l)},s=()=>{document.body.classList.remove("resizing"),r.classList.remove("active"),window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",s)};window.addEventListener("pointermove",o),window.addEventListener("pointerup",s)}}function eT(e,t){const[n,r]=E.useState(!1);return E.useEffect(()=>{if(!e){r(!1);return}const o=setTimeout(()=>r(!0),t);return()=>clearTimeout(o)},[e,t]),n}function yy(e,t){const[n,r]=E.useState(void 0);return E.useEffect(()=>{if(e===void 0){r(void 0);return}const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),n}function YX(){const[e,t]=E.useState(!1);return E.useEffect(()=>{var r;let n=!0;return(r=document.fonts)==null||r.ready.then(()=>{n&&t(!0)}),()=>{n=!1}},[]),e}const vy=1500;function Mi(e){const[t,n]=E.useState(()=>Date.now()),r=e!==void 0;return E.useEffect(()=>{if(!r)return;n(Date.now());const o=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(o)},[r]),r?Math.max(0,Math.floor((t-e)/1e3)):0}function t6(){const[e,t]=E.useState(window.innerWidth);return E.useEffect(()=>{const n=()=>t(window.innerWidth);return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),e}function n6(e){const t=E.useRef(null);return E.useLayoutEffect(()=>{const n=t.current;if(!n)return;t.current=null;const r=n.closest(e);if(!r)return;const o=r.getBoundingClientRect(),s=n.getBoundingClientRect(),a=parseFloat(getComputedStyle(r).getPropertyValue("--scroll-foot"))||0,l=s.bottom-(o.bottom-a);if(l<=0)return;const u=parseFloat(getComputedStyle(r).paddingTop)||0;r.scrollTop+=Math.min(l,Math.max(0,s.top-o.top-u))}),n=>{t.current=n}}const Ng=40,r6=1200,o6=150,s6=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]);function tT(e,t){const n=E.useRef(!0),r=E.useRef(Number.NEGATIVE_INFINITY),o=E.useRef(!1),[s,a]=E.useState(!1),[l,u]=E.useState(!1),[f,h]=E.useState(!1),[p,g]=E.useState(null),y=E.useCallback($=>{n.current=$,e.current&&(e.current.style.overflowAnchor=$?"none":"")},[e]),w=E.useRef(null),v=E.useRef(null);ct([t],()=>{n.current||h(!0)});const x=E.useCallback(()=>n.current,[]),N=E.useCallback(()=>{const $=e.current;$&&(y($.scrollHeight-$.scrollTop-$.clientHeight<Ng),a(!n.current),u($.scrollTop>=Ng),n.current&&h(!1))},[e,y]),S=E.useCallback($=>{Math.abs($)<4||(g($<0?"up":"down"),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>g(null),r6))},[]),T=E.useCallback(()=>{const $=e.current;$&&($.scrollTop=$.scrollHeight,y(!0),a(!1),h(!1))},[e,y]),j=E.useCallback(()=>{const $=e.current;$&&(r.current=performance.now(),$.scrollTop=0)},[e]);return E.useEffect(()=>{const $=e.current;if(!$)return;y(n.current);const R=()=>o.current||performance.now()-r.current<o6,A=()=>{n.current&&!R()?u($.scrollTop>=Ng):N()};$.addEventListener("scroll",A,{passive:!0});const I=()=>{r.current=performance.now()},M=C=>{I(),S(C.deltaY)},P=C=>{var oe;I(),w.current=((oe=C.touches[0])==null?void 0:oe.clientY)??null},F=C=>{var U;I();const oe=(U=C.touches[0])==null?void 0:U.clientY;oe===void 0||w.current===null||(S(w.current-oe),w.current=oe)},q=()=>{o.current=!0},W=()=>{o.current=!1},ee=C=>{if(!s6.has(C.key))return;const oe=C.target;(oe===document.body||oe instanceof Node&&$.contains(oe))&&I()};$.addEventListener("wheel",M,{passive:!0}),$.addEventListener("touchstart",P,{passive:!0}),$.addEventListener("touchmove",F,{passive:!0}),$.addEventListener("pointerdown",q,{passive:!0}),window.addEventListener("pointerup",W,{passive:!0}),window.addEventListener("pointercancel",W,{passive:!0}),document.addEventListener("keydown",ee);const V=()=>{$.scrollTop=$.scrollHeight},te=new ResizeObserver(()=>{n.current&&V()});te.observe($);for(const C of $.children)te.observe(C);const K=new MutationObserver(C=>{for(const oe of C){for(const U of oe.addedNodes)U instanceof Element&&te.observe(U);for(const U of oe.removedNodes)U instanceof Element&&te.unobserve(U)}n.current&&V()});return K.observe($,{childList:!0}),()=>{$.removeEventListener("scroll",A),$.removeEventListener("wheel",M),$.removeEventListener("touchstart",P),$.removeEventListener("touchmove",F),$.removeEventListener("pointerdown",q),window.removeEventListener("pointerup",W),window.removeEventListener("pointercancel",W),document.removeEventListener("keydown",ee),K.disconnect(),te.disconnect(),v.current&&clearTimeout(v.current)}},[e,N,S,y]),{offEnd:s,offStart:l,away:f,moving:p,pinned:x,jump:T,start:j,read:N}}function Fx(e,t,n){const r=document.createRange();return r.selectNodeContents(e),r.setEnd(t,n),r.toString().length}function Bx(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=0,o=null;for(let s=n.nextNode();s;s=n.nextNode()){if(r+s.data.length>=t)return[s,t-r];r+=s.data.length,o=s}return o?[o,o.data.length]:[e,0]}function nT(e,t){E.useLayoutEffect(()=>{const n=e.current;if(!n)return;const r=window.getSelection(),o=g=>!!g&&n.contains(g),s=r&&r.rangeCount>0&&o(r.anchorNode)?Fx(n,r.anchorNode,r.anchorOffset):null,a=r&&r.rangeCount>0&&o(r.focusNode)?Fx(n,r.focusNode,r.focusOffset):null,l=r&&(s!==null||a!==null)?[r.anchorNode,r.anchorOffset,r.focusNode,r.focusOffset]:null;if(n.innerHTML=t,!r||!l)return;const[u,f]=s===null?[l[0],l[1]]:Bx(n,s),[h,p]=a===null?[l[2],l[3]]:Bx(n,a);u&&h&&r.setBaseAndExtent(u,f,h,p)},[e,t])}function ct(e,t){const n=E.useRef(t);n.current=t,E.useEffect(()=>n.current(),e)}function rT(e){const[t,n]=E.useState({left:0,right:0});return E.useLayoutEffect(()=>{if(!e)return;const r=()=>{const s=e.getBoundingClientRect();let{left:a,right:l}=s;const u=e.closest("[data-pinned]");if(u){const h=u.getBoundingClientRect(),p=u.offsetWidth/h.width;a=u.offsetLeft+(a-h.left)*p,l=u.offsetLeft+(l-h.left)*p}const f={left:Math.round(a),right:Math.round(l)};n(h=>h.left===f.left&&h.right===f.right?h:f)};r();const o=new ResizeObserver(r);return o.observe(e),window.addEventListener("resize",r),()=>{o.disconnect(),window.removeEventListener("resize",r)}},[e]),t}function Ux(){const[e,t]=E.useState(null);return[t,rT(e)]}function XX(e){e.ctrlKey&&e.stopPropagation()}function oT(e,t){return e.defaultPrevented||e.ctrlKey?!1:t<1.01}function QX(e){E.useEffect(()=>{const t=e.current;if(!t)return;const n=r=>{var o;oT(r,((o=window.visualViewport)==null?void 0:o.scale)??1)&&r.preventDefault()};return t.addEventListener("wheel",n,{passive:!1}),()=>t.removeEventListener("wheel",n)},[e])}const sT={axis:null,dx:0,dy:0,across:0,at:Number.NEGATIVE_INFINITY},i6=2,a6=4,c6=300;function l6(e,t,n){const r=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=r>o?"x":"y",a=n-e.at<=c6?e:sT;if(a.axis===null){const u=a.dx+r,f=a.dy+o,h=Math.max(u,f)>=i6?u>f?"x":"y":null;return{scrolls:h!==null&&h===s,next:{axis:h,dx:u,dy:f,across:0,at:n}}}const l=Math.max(0,a.across+(a.axis==="x"?o-r:r-o));return s===a.axis?{scrolls:!0,next:{...a,across:l,at:n}}:l>=a6?{scrolls:!0,next:{...a,axis:s,across:0,at:n}}:{scrolls:!1,next:{...a,across:l,at:n}}}function JX(e){E.useEffect(()=>{const t=e.current;if(!t)return;let n=sT;const r=o=>{var l;if(o.ctrlKey)return;const{scrolls:s,next:a}=l6(n,o,o.timeStamp);n=a,!s&&(o.stopPropagation(),oT(o,((l=window.visualViewport)==null?void 0:l.scale)??1)&&o.preventDefault())};return t.addEventListener("wheel",r,{capture:!0,passive:!1}),()=>t.removeEventListener("wheel",r,{capture:!0})},[e])}function u6(e){E.useEffect(()=>{const t=window.visualViewport;if(!t)return;const n=()=>{const r=e.current;r&&(t.scale<1.01?delete r.dataset.zoomed:r.dataset.zoomed="")};return n(),t.addEventListener("resize",n),()=>t.removeEventListener("resize",n)},[e])}function d6(e){E.useEffect(()=>{const t=window.visualViewport;if(!t)return;const n=()=>{var r;(r=e.current)==null||r.style.setProperty("--visible-height",`${Math.round(t.height)}px`)};return n(),t.addEventListener("resize",n),()=>t.removeEventListener("resize",n)},[e])}function f6(e){E.useEffect(()=>{const t=window.visualViewport;if(!t)return;const n=()=>{const r=e.current;if(r){if(t.scale<1.01){delete r.dataset.pinned;return}r.dataset.pinned="",r.style.setProperty("--pin-x",`${t.offsetLeft}px`),r.style.setProperty("--pin-y",`${t.offsetTop}px`),r.style.setProperty("--pin-scale",String(1/t.scale))}};return n(),t.addEventListener("resize",n),t.addEventListener("scroll",n),()=>{t.removeEventListener("resize",n),t.removeEventListener("scroll",n)}},[e])}function h6(e,t,n){const[r,o]=E.useState(),s=E.useRef(e);return s.current=e,E.useEffect(()=>{if(!n)return;let a=!0,l;const u=()=>void s.current().then(f=>{a&&(o(f),l=setTimeout(u,t))});return u(),()=>{a=!1,clearTimeout(l)}},[t,n]),r}const fl=()=>L(e=>e.activeId),iT=()=>eT(!L(e=>e.connected),900),p6=e=>!e.connected&&(e.connectFailure==="down"||e.connectFailure==="blocked"),aT=()=>L(p6),Vs=()=>L(e=>Jt(e,e.activeId)),by=()=>L(e=>Kr(e,e.activeId)),cT=()=>L(e=>e.rows),xy=()=>L(e=>e.visible),m6=()=>L(e=>e.visibleDiscovered),g6=()=>L(e=>e.activeRepoId?e.discoveredOpen[e.activeRepoId]??!1:!1),Hx=[],k6=()=>L(e=>e.activeRepoId?e.archived[e.activeRepoId]??Hx:Hx),w6=()=>L(e=>e.activeRepoId?e.archivedOpen[e.activeRepoId]??!1:!1),y6=()=>L(e=>!(e.activeRepoId&&e.committedShut[e.activeRepoId])),v6=()=>L(e=>!!(e.activeRepoId&&e.turnOpen[e.activeRepoId])),Ga=()=>L(Wo),Ey=()=>L(py),b6=()=>L(e=>bs(e,e.activeRepoId)),hl=()=>L(e=>bs(e,fy(e))),lT=e=>L(t=>Or(t,e)),Rt=(e,t)=>L(n=>Or(n,e)[t]),x6=()=>L(e=>e.overlay),pp=()=>L(i3),uT=()=>L(TN),Ju=()=>L(a3),ed=()=>L(Co),E6=()=>L(e=>e.newProject),Ys=()=>L(e=>e.touch),td=e=>L(t=>t.chatSide==="left"==(e==="chat")?"right":"left"),S6=()=>L(e=>e.draft),Sy=()=>L(zc),_6=()=>L(e=>{const t=Kr(e,e.activeId),n=t?e.repos.find(r=>r.id===t.repoId):null;return mh(n)?n:null});function N6(e){return e.image?{kind:"image",blob:e.image,sig:`image:${e.image.type}:${e.image.size}`}:e.text&&U_(e.text)?{kind:"text",text:e.text,sig:`text:${e.text}`}:null}function T6(){try{return localStorage.getItem(it.clipboardOffer)==="1"}catch{return!1}}let qs={access:"none",on:typeof localStorage<"u"&&T6(),offer:null},$k="";const Ck=new Set;function mp(e){qs={...qs,...e};for(const t of Ck)t()}async function j6(){let e,t;for(const n of await navigator.clipboard.read()){const r=n.types.find(o=>o.startsWith("image/"));r?e??(e=await n.getType(r)):n.types.includes("text/plain")&&(t??(t=await(await n.getType("text/plain")).text()))}return N6({image:e,text:t})}async function gp({taken:e=!1,asking:t=!1}={}){if(!qs.on||!(qs.access==="granted"||t&&qs.access==="prompt"))return;let n;try{n=await j6()}catch{return}e&&($k=(n==null?void 0:n.sig)??""),mp({offer:n&&n.sig!==$k?n:null})}const $6=()=>void gp();let Wx=!1;function C6(){var e,t;Wx||(Wx=!0,!(!((e=navigator.clipboard)!=null&&e.read)||!((t=navigator.permissions)!=null&&t.query))&&navigator.permissions.query({name:"clipboard-read"}).then(n=>{const r=()=>{mp({access:n.state,...n.state==="denied"?{offer:null}:{}})};n.onchange=r,r(),window.addEventListener("focus",$6),document.hasFocus()&&gp()},()=>{}))}function A6(e){return Ck.add(e),C6(),()=>{Ck.delete(e)}}const I6=()=>qs;function R6(e){try{localStorage.setItem(it.clipboardOffer,e?"1":"0")}catch{}mp({on:e,offer:null}),e&&gp({asking:!0})}function dT(){qs.offer&&($k=qs.offer.sig),mp({offer:null})}const O6=()=>void gp({taken:!0});function M6(){return E.useSyncExternalStore(A6,()=>qs.offer)}const fT="application/x-toyon-source";function eQ(e){const t=e.endColumn===1&&e.endLineNumber>e.startLineNumber?e.endLineNumber-1:e.endLineNumber;return{startLine:e.startLineNumber,endLine:t}}function L6(e,t){e.setData(fT,JSON.stringify(t))}const Kx=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1;function P6(e,t){const n=e.getData(fT);if(!n||!t)return null;let r;try{r=JSON.parse(n)}catch{return null}if(!r||r.worktreeId!==t||typeof r.path!="string"||!r.path)return null;const{startLine:o,endLine:s,ref:a}=r;return!Kx(o)||!Kx(s)||s<o?null:{path:r.path,startLine:o,endLine:s,...typeof a=="string"?{ref:a}:{}}}const hT=e=>({left:e.x,top:e.y,right:e.x,bottom:e.y});function D6(e,t){return t.matchWidth===void 0?void 0:Math.max(0,e.right-e.left+t.matchWidth)}const z6=new Set(["top","bottom"]),Tg={top:"bottom",bottom:"top",left:"right",right:"left"};function jg(e,t,n,r,o){const s=n==="top"||n==="left";return o?s?e.end+r-t:e.start-r:s?e.start-r-t:e.end+r}function qx(e,t,n,r,o){return n==="top"||n==="left"?e>=o:e+t<=r-o}function $g(e,t,n,r){return n==="center"?e.start+(e.end-e.start)/2-t/2:n==="start"?e.start-r:e.end+r-t}function Zx(e,t,n,r,o){return n==="start"?e+t<=r-o:e>=o}const Gx=(e,t,n,r)=>n||!r?e:t,Vx=(e,t,n,r)=>Math.max(r,Math.min(e,n-r-t));function F6(e,t,n,r){const{offset:o=0,alignOffset:s=0,cover:a=!1,flip:l="none",margin:u=8}=r,f=z6.has(r.side),h=f?{a:{start:e.top,end:e.bottom},size:t.h,limit:n.h}:{a:{start:e.left,end:e.right},size:t.w,limit:n.w},p=f?{a:{start:e.left,end:e.right},size:t.w,limit:n.w}:{a:{start:e.top,end:e.bottom},size:t.h,limit:n.h};let g=r.side;if(l==="side"||l==="both"){const x=jg(h.a,h.size,g,o,a),N=jg(h.a,h.size,Tg[g],o,a);g=Gx(g,Tg[g],qx(x,h.size,g,h.limit,u),qx(N,h.size,Tg[g],h.limit,u))}let y=r.align??"center";if((l==="align"||l==="both")&&y!=="center"){const x=y==="start"?"end":"start",N=$g(p.a,p.size,y,s),S=$g(p.a,p.size,x,s);y=Gx(y,x,Zx(N,p.size,y,p.limit,u),Zx(S,p.size,x,p.limit,u))}const w=Vx(jg(h.a,h.size,g,o,a),h.size,h.limit,u),v=Vx($g(p.a,p.size,y,s),p.size,p.limit,u);return f?{x:v,y:w,side:g,align:y}:{x:w,y:v,side:g,align:y}}function B6(e,t,n){var s,a;const r=e.length;if(r===0)return-1;let o=t<0?n===1?0:r-1:(t+n+r)%r;for(let l=0;l<r&&((s=e[o])!=null&&s.disabled);l++)o=(o+n+r)%r;return(a=e[o])!=null&&a.disabled?-1:o}const pT={sep:!0},ys=e=>!("sep"in e);function kp(e){const t=[];for(const n of e)(ys(n)||t.length>0&&ys(t[t.length-1]))&&t.push(n);for(;t.length>0&&!ys(t[t.length-1]);)t.pop();return t}const Un=e=>kp(e.flatMap((t,n)=>n?[pT,...t]:t));let $c=null,U6=0;const Ak=new Set,Yx=()=>{for(const e of Ak)e()},go={get:()=>$c,subscribe(e){return Ak.add(e),()=>{Ak.delete(e)}},open(e){const t=kp(e.items);if(t.length===0)return go.close();$c={...e,items:t,id:++U6},Yx()},close(){$c&&($c=null,Yx())},toggle(e){$c&&$c.target===e.target?go.close():go.open(e)}};function _y(){return E.useSyncExternalStore(go.subscribe,go.get)}function mT(e){const t=e.nativeEvent;return t&&"pointerType"in t?t.pointerType==="":e.clientX===0&&e.clientY===0}function H6(e,t){return mT(e)?{anchor:(t.querySelector('[data-state~="cursor"]')??t).getBoundingClientRect()}:{at:{x:e.clientX,y:e.clientY}}}function W6(e){const t=e.anchor;return t?{rect:t,placement:{side:"bottom",align:e.align==="right"?"end":"start",offset:4,margin:4,...e.toggles?{flip:"side"}:{}}}:{rect:hT(e.at??{x:0,y:0}),placement:{side:"bottom",align:"start",margin:4}}}function K6(e){if(mT(e))return"keyboard";const t=e.nativeEvent;return t&&"pointerType"in t&&t.pointerType==="touch"?"touch":"pointer"}function xn(e){return E.useMemo(()=>({contextMenu(t,n){return{onContextMenu:r=>{const o=t(K6(r),r.target);if(o===null){r.stopPropagation();return}const s=kp(o);if(s.length===0)return;r.preventDefault(),r.stopPropagation();const a=r.currentTarget;go.open({items:s,owner:e,key:n,target:a,...H6(r,a)})}}},dropdown(t,n="left",r,o){return{"aria-haspopup":"menu",onClick:s=>{s.stopPropagation();const a=s.currentTarget;go.toggle({items:t(),...o?{head:o()}:{},owner:e,key:r,target:a,toggles:!0,anchor:a.getBoundingClientRect(),align:n})}}},openUnder(t,n,r){go.open({items:n(),owner:e,key:r,target:t,toggles:!0,anchor:t.getBoundingClientRect(),align:"left"})}}),[e])}function Rr(e){e&&window.open(e,"_blank","noopener,noreferrer")}function Ny(e){const t=e.target.closest("a");t&&t.target!=="_blank"&&e.preventDefault()}const gT=e=>({id:"open-out",label:iy()?"open in the browser":"open in a new tab",onClick:()=>Rr(e)}),sn=e=>{var t;return void((t=navigator.clipboard)==null?void 0:t.writeText(e).catch(()=>{}))};function kT(e,t){const n=navigator.clipboard;if(n){if(typeof ClipboardItem>"u"||!n.write){e==="text/plain"&&t.then(r=>r.text()).then(sn,()=>{});return}n.write([new ClipboardItem({[e]:t})]).catch(()=>{})}}const wT=e=>kT("text/plain",fetch(e).then(t=>t.blob())),q6=e=>kT("image/png",Z6(e));async function Z6(e){const t=await(await fetch(e)).blob();if(t.type==="image/png")return t;const n=await createImageBitmap(t);try{const r=document.createElement("canvas");return r.width=n.width,r.height=n.height,r.getContext("2d").drawImage(n,0,0),await new Promise((o,s)=>r.toBlob(a=>a?o(a):s(new Error("could not encode image")),"image/png"))}finally{n.close()}}function wp(e){return Gh(e)}function wo(e){return(e==null?void 0:e.urls.host)??(typeof location=="object"?location.hostname:"127.0.0.1")}function Ko(e,t,n="reveal in Finder"){return!e||!wp(t)?[]:[{id:"reveal",label:n,onClick:e}]}function yp(e,t,{sock:n,dispatch:r}){var u,f,h,p;if(!n)return;const o=t.local[e]??Za,s=((u=o.git)==null?void 0:u.files)??[],a=Lw((f=o.git)==null?void 0:f.head,s),l=JS(s);((h=o.filesFor)==null?void 0:h.index)===a&&o.filesFor.disk===l||(r({a:"files-asked",worktreeId:e,index:a,disk:l}),n.send({t:"list-files",worktreeId:e,tracked:((p=o.filesFor)==null?void 0:p.index)!==a}))}const G6=["diff","file","preview"],V6=(e,t)=>G6.filter(n=>!(n==="preview"&&!Wa(e))&&!(n==="diff"&&t));let Y6=0;const $o=()=>++Y6;function Rn({dispatch:e},{focus:t=!0,...n}){e({a:"open-file",v:{...n,focus:t,seq:$o()}})}function X6({dispatch:e},t,n){e({a:"open-loose",v:{worktreeId:t,name:`PR #${n} comments`,text:"",binary:!1,tooLarge:!1,source:{kind:"pr-comments"},seq:$o()}})}const Ik=new Map;function yT(e,t,n=""){const{sock:r}=e;if(!r)return Promise.resolve("not connected to the daemon");const o=$o();return new Promise(s=>{Ik.set(o,a=>{a.ok?(Rn(e,{...t,view:Bi(t.path)}),s(null)):s(a.reason==="changed"?"a file is already there":a.message??"the file was not made")}),r.send({t:"write-file",...t,content:n,base:null,seq:o})})}function Q6(e){const t=Ik.get(e.seq);return t?(Ik.delete(e.seq),t(e),!0):!1}function J6({dispatch:e},t){e({a:"tree-reveal",...t})}function Hs(e,t,{discard:n=!1,ref:r,since:o,showing:s,noDiff:a=!1,kept:l=!1,select:u},f){const{sock:h,dispatch:p}=f,g=V6(t,a).filter(S=>S!==s).map(S=>({id:`view:${S}`,label:`view ${S}`,onClick:()=>s?p({a:"editor-view",v:S}):Rn(f,{worktreeId:e.id,path:t,view:S,picked:!0,ref:r,since:o})})),y=`${e.dir}/${t}`,w=l?[]:Ko(()=>h==null?void 0:h.send({t:"reveal",worktreeId:e.id,path:t}),wo(h));return Un([g,[{id:"copy-path",label:"copy path",onClick:()=>sn(y)}],w,u?[{id:"select",label:"select…",onClick:()=>u(t)}]:[],n?[{id:"discard",label:"discard changes…",danger:!0,onClick:()=>{window.confirm(vT([t]))&&(h==null||h.send({t:"discard-files",worktreeId:e.id,paths:[t]}))}}]:[]])}function vT(e){if(e.length===1)return`Discard uncommitted changes to ${e[0]}?`;const t=e.slice(0,12),n=e.length-t.length,r=[...t,...n>0?[`and ${n} more`]:[]].join(`
103
- `);return`Discard uncommitted changes to ${e.length} files?
104
-
105
- ${r}`}const Ao=(e,t,n)=>e.dispatch({a:"notice",id:t,text:n});function vp(e,t,n){var o;const r=dR(((o=e.getState().local[t])==null?void 0:o.attachments)??[],n);return r===0&&Ao(e,t,Aw(n)),r}const e5=1e3,t5=1e4,bT=new WeakMap;function n5(e,t){bT.set(e,t)}async function xT(e,t,n,r){var w,v;const{local:o,...s}=n;e.dispatch({a:"attach",id:t,items:[{...n,upload:"",uploading:!0}]});const a=()=>{var x;return(x=Object.entries(e.getState().local).find(([,N])=>N.attachments.some(S=>S.key===n.key)))==null?void 0:x[0]},l=bT.get(e);let u=-1;const f=x=>{const N=Math.min(99,Math.floor(x*100)),S=a();N===u||S===void 0||(u=N,e.dispatch({a:"upload-progress",id:S,key:n.key,progress:N}))},h=()=>(u=-1,l?q4(l,n.kind,r,f):Promise.resolve(null));let p=await h();const g=p===null;g&&Ao(e,a()??t,`${n.name}: Toyon is not answering; it attaches once it is back`);for(let x=e5;p===null&&a()!==void 0;x=Math.min(x*2,t5))await new Promise(N=>setTimeout(N,x)),a()!==void 0&&(p=await h());const y=a();if(!(p===null||y===void 0))if(typeof p=="string")e.dispatch({a:"detach",id:y,key:n.key}),Ao(e,y,`${n.name}: ${p}`);else{const x=s.kind==="file"?{...s,...p}:{...s,upload:p.upload,bytes:p.bytes};e.dispatch({a:"attached",id:y,key:n.key,item:x});const N=(v=e.getState().local[((w=ws(y))==null?void 0:w.source)??y])==null?void 0:v.notice;g&&(N!=null&&N.startsWith(`${n.name}: Toyon is not answering`))&&Ao(e,y,"")}o&&URL.revokeObjectURL(o)}function Ty(e,t,n){if(!t||n.length===0)return;const r=vp(e,t,"file");if(r!==0){for(const o of n.slice(0,r)){const s=o.name||"file";if(o.size>yx){Ao(e,t,`${s}: larger than ${Rw(yx)}`);continue}const a={kind:"file",key:crypto.randomUUID(),upload:"",name:s,bytes:o.size,text:!1};xT(e,t,a,o)}n.length>r&&Ao(e,t,`kept ${r} of ${n.length}: ${Aw("file")}`)}}function jy(e,t,n,r={}){if(!t)return;const o=ID(r.source?n.replace(/\r?\n$/,""):n);if(o.length>SD)return r.source?Ao(e,t,"that paste is too large; save it in the worktree and reference it with @path"):Ty(e,t,[new File([o],_D,{type:"text/plain"})]);vp(e,t,"paste")!==0&&e.dispatch({a:"attach",id:t,items:[{kind:"paste",key:crypto.randomUUID(),text:o,...r,...qw(o)}]})}function ET(e,t,n,r){e.dispatch({a:"set-draft",id:n,text:""}),t==null||t.send({t:"unqueue",worktreeId:n,index:r,edit:!0})}function Xf(e,t){var s;const n=e.getState(),r=Jt(n,n.activeId),o=qa(r);if(t&&o&&t.worktreeId===(r==null?void 0:r.worktree.id)&&t.text.trim()){const a="source"in t?{source:t.source}:{name:t.name};(((s=n.local[o])==null?void 0:s.attachments)??[]).some(u=>{var y;if(u.kind!=="paste")return!1;if(!("source"in t))return u.name===t.name&&u.text===t.text;const{path:f,startLine:h,endLine:p,ref:g}=t.source;return((y=u.source)==null?void 0:y.path)===f&&u.source.startLine===h&&u.source.endLine===p&&u.source.ref===g})||jy(e,o,t.text,a)}e.dispatch(t||Ui(n)?{a:"focus-chat"}:jN(n))}function $y(e,t){return t!==e.activeId?null:qa(Jt(e,t))}const ST=(e,t)=>`@${e}${t?"/":""}`,Cy=e=>`${e.map(t=>ST(t.path,t.folder)).join(" ")} `;function _T(e,t,n){const r=t>0&&!/\s/.test(e[t-1]??"")?" ":"";return{text:`${e.slice(0,t)}${r}${n}${e.slice(t)}`,caret:t+r.length+n.length}}function NT(e,t,n){var o;const r=((o=e.getState().local[t])==null?void 0:o.draft)??"";e.dispatch({a:"set-draft",id:t,text:_T(r,r.length,n).text}),e.dispatch({a:"focus-chat"})}function Ay(e,t,n){const r=$y(e.getState(),t);r&&NT(e,r,n)}function r5(e,t,n,r){Ay(e,t,Cy([{path:n,folder:r}]))}function o5(e,t,n){n.length!==0&&Ay(e,t,Cy(n.map(r=>({path:r,folder:!1}))))}function Xx(e,t,n){Ay(e,t,n)}function s5(e,t){return Jt(e,t)?t:null}function i5(e,t){var r;const n=(r=Jt(e,t))==null?void 0:r.worktree;return n?[n.path]:[]}function Qx(e,t){if(!e)return e;const n=t.find(r=>e.startsWith(`${r}/`));return n?e.slice(n.length+1):e}function a5(e,t,n){var g;e.dispatch({a:"set-picking",v:!1});const r=e.getState(),o=s5(r,t);if(!o)return;const{classes:s,route:a,element:l,...u}=n,f=i5(r,t),h={...u,file:Qx(u.file,f),callFile:Qx(u.callFile,f)};!(((g=r.local[o])==null?void 0:g.attachments)??[]).some(y=>y.kind==="pick"&&y.selector===h.selector)&&vp(e,o,"pick")>0&&e.dispatch({a:"attach",id:o,items:[{kind:"pick",key:crypto.randomUUID(),...h}]}),e.dispatch({a:"focus-chat"})}function c5(e,t=[],n=[]){const r={path:"",name:"",kind:"folder",children:[],ignored:!1},o=new Map([["",r]]),s=u=>{const f=o.get(u);if(f)return f;const h=u.lastIndexOf("/"),p={path:u,name:u.slice(h+1),kind:"folder",children:[],ignored:!1};return s(h===-1?"":u.slice(0,h)).children.push(p),o.set(u,p),p},a=(u,f,h=!1)=>{const p=u.lastIndexOf("/");s(p===-1?"":u.slice(0,p)).children.push({path:u,name:u.slice(p+1),kind:f,children:[],ignored:h})};for(const u of e)a(u,"file");for(const u of t)a(u,"submodule");for(const u of n)u.endsWith("/")?a(u.slice(0,-1),"ignored",!0):a(u,"file",!0);const l=u=>{const f=h=>h.kind==="file"?1:0;u.children.sort((h,p)=>f(h)-f(p)||wN(h.name,p.name));for(const h of u.children)h.kind==="folder"&&l(h)};return l(r),r.children}function l5(e,t){const n=[],r=(o,s)=>{for(const a of o){const l=a.kind==="folder"&&t(a.path);n.push({path:a.path,name:a.name,depth:s,kind:a.kind,open:l,ignored:a.ignored}),l&&r(a.children,s+1)}};return r(e,0),n}const TT=e=>{const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)};function u5(e,t){const n=t.trim().replace(/^(\.\/|\/)+/,"");return n===""?{error:"name the file"}:n.endsWith("/")?{error:"name a file: its folders are made with it"}:n.split("/").some(o=>o===""||o==="."||o==="..")?{error:"a plain path, inside the worktree"}:{path:e?`${e}/${n}`:n}}function d5(e){const t=new Map,n=new Set;for(const r of e){const o=r.path.endsWith("/")?r.path.slice(0,-1):r.path;o===r.path?t.set(o,r):n.add(o);for(const s of ph(o))n.add(s)}return{files:t,folders:n}}function f5(e){const t=e.findLast(n=>n.kind==="handoff"&&n.state!=="declined");return(t==null?void 0:t.kind)==="handoff"?t:null}function h5(e,t,n){const r=e.findLast(o=>o.kind==="handoff"&&o.state!=="declined"&&(o.plan??n)===t);return(r==null?void 0:r.kind)==="handoff"?r:null}function p5(e){return e.pieces.flatMap(t=>{const n=e.outcomes.find(o=>o.pieceId===t.id),r=(n==null?void 0:n.fate)==="worktree"?n.worktreeId:void 0;return!r&&(Xs(e,t)!=="worktree"||t.after)?[]:[{pieceId:t.id,title:(n==null?void 0:n.title)??t.title,...r?{worktreeId:r}:{},...n!=null&&n.repoName?{repoName:n.repoName}:{}}]})}function m5(e){return!!e.plan&&!e.companion}function g5(e,t){const n=e.findIndex(o=>o.kind==="tool"&&o.id===t);if(n<0)return;const r=e.slice(n+1).find(o=>o.kind==="handoff");return(r==null?void 0:r.kind)==="handoff"?r.plan:void 0}function Xs(e,t){return e.fates[t.id]??t.fate}function nd(e,t){var r;const n=t.after;return n?"piece"in n?{kind:"piece",title:((r=e.pieces.find(o=>o.id===n.piece))==null?void 0:r.title)??"another piece"}:{kind:"branch",...n}:null}function Iy(e){const t={worktrees:0,queued:0,sent:0,here:0,skipped:0};for(const n of e.pieces){const r=Xs(e,n);r==="worktree"?n.after?t.queued++:t.worktrees++:r==="send"?t.sent++:r==="here"?t.here++:t.skipped++}return t}const jT=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,k5=e=>e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function w5(e,t){const n=Iy(e),r=[];if(n.here&&r.push("this plan here"),n.worktrees&&r.push(`${jT(n.worktrees,"worktree")} now`),n.queued){const s=e.pieces.filter(u=>Xs(e,u)==="worktree"&&u.after),a=s.every(u=>u.after&&"id"in u.after&&u.after.id===t),l=s.length===1?nd(e,s[0]):null;r.push(a?`${n.queued} when this branch lands`:l?`1 when ${l.kind==="branch"?l.branch:l.title} lands`:`${n.queued} queued`)}n.sent&&r.push(`${n.sent} sent on`);const o=n.skipped?`; ${n.skipped} skipped`:"";return r.length===0?`Starts nothing${o}.`:`Starts ${k5(r)}${o}.`}function Rk(e){var s;const t=e.pieces.length===1?e.pieces[0]:void 0;if(t)return t.fate==="send"?`Send ${t.title} to ${((s=t.to)==null?void 0:s.title)??"the worktree"}?`:t.fate==="here"?`Keep ${t.title} here?`:t.project?`Continue in ${t.project.name}?`:t.after?`Queue a worktree for ${t.title}?`:`Start a worktree for ${t.title}?`;const n=Iy(e),o=[n.worktrees?`start ${jT(n.worktrees,"worktree")}`:"",n.queued?`queue ${n.queued}`:"",n.sent?`send ${n.sent}`:"",n.here?`do ${n.here} here`:"",n.skipped?`skip ${n.skipped}`:""].filter(Boolean).join(", ");return`${o.charAt(0).toUpperCase()}${o.slice(1)}?`}function $T(e,t){var l;const n=nd(e,t),r=n?` once ${n.kind==="branch"?n.branch:n.title} lands`:"",o=t.project?{fate:"worktree",label:`start a worktree in ${t.project.name}`,description:`a copy of that project, with this text as its plan${r}`}:{fate:"worktree",label:n?"queue a worktree":"start a worktree",description:`a copy of this project, with this text as its plan${r}`},s={fate:"here",label:"do it here",description:"this worktree's agent, after its turn"},a={fate:null,label:"not now"};return t.fate==="send"?[{fate:"send",label:`send to ${((l=t.to)==null?void 0:l.title)??"the worktree"}`,description:"that worktree's agent, as a message"},a]:t.fate==="here"?[s,o,a]:t.project?[o,a]:[o,s,a]}const y5=[{fate:"worktree",label:"go"},{fate:null,label:"not now"}];function v5(e){const t=e.findIndex(n=>n.fate===null);return t<0?null:t}function b5(e,t){return e.fate===null?"what to change, sent with your not now":t?e.fate==="here"?"a note for this worktree's agent, sent with it":"a note for the agent there, sent with it":"a note for every agent this hands to, sent with go"}function x5(e,t){var n;return t==="worktree"?e.project?`new worktree in ${e.project.name}`:"new worktree":t==="here"?"here":t==="skip"?"skip":`sent to ${((n=e.to)==null?void 0:n.title)??"the worktree"}`}function E5(e,t,n){var r;if(t==="worktree"){const o=e.project?` in ${e.project.name}`:"",s=n?`, once ${n.kind==="branch"?n.branch:n.title} lands`:"";return`Starts as a new worktree${o}${s}, with this text as its plan.`}return t==="here"?"This worktree's agent does it.":t==="send"?`Goes to ${((r=e.to)==null?void 0:r.title)??"that worktree"}'s agent as a message.`:"Skipped: nothing happens to it."}function S5(e){var s;const t=e.answered;if(!t)return null;if(!t.go)return t.note?`not now
106
- ${t.note}`:"not now";const n=e.pieces.length===1?e.pieces[0]:void 0,o=(n?(s=$T(e,n).find(a=>a.fate===Xs(e,n)))==null?void 0:s.label:void 0)??"go";return t.note?`${o}
107
- ${t.note}`:o}function Jx(e,t,n,r){const o=r==null?void 0:r.trim();return{t:"handoff-answer",worktreeId:t,id:e.id,go:n,...o?{note:o}:{}}}function CT(e,t,n,r){return{t:"handoff-fate",worktreeId:t,id:e.id,pieceId:n,fate:r}}function _5(e,t=[]){if(e.fate==="send")return["send","skip"];const n=e.after;return!!n&&"piece"in n&&t.findIndex(o=>o.id===n.piece)>t.findIndex(o=>o.id===e.id)?["here","skip"]:e.project?["worktree","skip"]:["here","worktree","skip"]}const Ou=e=>e.state==="held"||e.state==="proposed";function AT(e){const t=n=>n.fate==="here"?0:n.fate==="worktree"?n.after?2:1:3;return[...e.pieces].sort((n,r)=>t(n)-t(r))}function N5(e,t){const n=nd(e,t),r=n?{word:`after ${n.title}`}:null;if(Ou(e)){const s=Xs(e,t);return s==="worktree"?{word:t.after?"queued":"worktree"}:s==="send"?{word:"sent"}:s==="here"&&r?r:{word:s}}const o=Mu(e,t);return o.kind==="worktree"||o.kind==="sent"&&o.worktreeId?{worktreeId:o.worktreeId,...o.title?{title:o.title}:{}}:o.kind==="here"&&r?r:{word:o.kind==="sent"?"sent":o.kind}}function T5(e,t,n){if(n||Ou(e))return!0;const r=Mu(e,t);return r.kind==="here"?!!t.after:r.kind!=="skipped"&&r.kind!=="starting"}function Mu(e,t){if(e.state==="going")return{kind:"starting"};const n=e.outcomes.find(a=>a.pieceId===t.id),r=e.later.findLast(a=>a.pieceId===t.id);if(!n)return{kind:"skipped"};if(n.error)return{kind:"failed",error:n.error};if(n.fate==="here")return{kind:"here"};if(n.fate==="skip")return{kind:"skipped"};const o=n.repoName?{repoName:n.repoName}:{};if(n.fate==="send")return{kind:"sent",...n.worktreeId?{worktreeId:n.worktreeId}:{},...n.title?{title:n.title}:{},...o};const s=n.worktreeId?n:r!=null&&r.worktreeId?r:null;return s!=null&&s.worktreeId?{kind:"worktree",worktreeId:s.worktreeId,...s.title?{title:s.title}:{},..."repoName"in s&&s.repoName?{repoName:s.repoName}:{}}:r!=null&&r.reason?{kind:"dropped",reason:r.reason}:{kind:"queued",after:nd(e,t),...n.after?{said:n.after}:{}}}function j5(e,t){var o;if(t)return"plan";const n=AT(e),r=Ou(e)?void 0:n.find(s=>Xs(e,s)==="here");return(r==null?void 0:r.id)??((o=n[0])==null?void 0:o.id)??"plan"}function $5(e){if(e.state!=="done")return[];const t=new Map;for(const n of e.pieces){const r=n.after;if(!r||Xs(e,n)!=="here")continue;if("id"in r){t.set(r.id,r.title);continue}const o=e.pieces.find(a=>a.id===r.piece),s=o?Mu(e,o):null;((s==null?void 0:s.kind)==="worktree"||(s==null?void 0:s.kind)==="sent"&&s.worktreeId)&&t.set(s.worktreeId,s.title??(o==null?void 0:o.title)??"the worktree")}return[...t].map(([n,r])=>({id:n,title:r}))}function Ry(e){const t=e.findLast(n=>n.kind==="ask"&&!n.outcome||n.kind==="handoff"&&n.state==="proposed");return(t==null?void 0:t.kind)==="ask"||(t==null?void 0:t.kind)==="handoff"?t:null}function C5(e){const t=e?Ry(e.chat):null;return(t==null?void 0:t.kind)!=="ask"||t.ask.kind!=="question"||(e==null?void 0:e.cardParked)===t.id?null:Hc(t.id)}function A5(e){return e.kind==="ask"?dz(e):Rk(e)}const IT=new Set(bD),I5=/^image\.[a-z0-9]+$/i,R5=e=>I5.test(e.name),O5=(e,t)=>e===t||e.name===t.name&&e.size===t.size&&e.type===t.type&&e.lastModified===t.lastModified;function M5(e){if(!e)return[];const t=[];for(const s of Array.from(e.items??[])){if(s.kind!=="file"||!s.type.startsWith("image/"))continue;const a=s.getAsFile();a&&t.push(a)}if(t.length===0)for(const s of Array.from(e.files??[]))s.type.startsWith("image/")&&t.push(s);const n=[];for(const s of t)n.some(a=>O5(a,s))||n.push(s);const r=n.filter(s=>!R5(s));if(r.length>0)return r;const o=n.find(s=>IT.has(s.type))??n[0];return o?[o]:[]}function L5(e){if(!e)return[];const t=[];for(const n of Array.from(e.items??[])){if(n.kind!=="file"||n.type.startsWith("image/"))continue;const r=n.getAsFile();r&&t.push(r)}if(t.length===0)for(const n of Array.from(e.files??[]))n.type.startsWith("image/")||t.push(n);return t}async function P5(e,t){if(e.size>t)return null;try{return new TextDecoder("utf-8",{fatal:!0}).decode(await e.arrayBuffer())}catch{return null}}async function D5(e){try{return await createImageBitmap(e)}catch{throw new Error(`${e.name||"image"}: not a readable image`)}}function e1(e,t,n){const r=document.createElement("canvas");return r.width=Math.max(1,Math.round(e.width*t)),r.height=Math.max(1,Math.round(e.height*t)),r.getContext("2d").drawImage(e,0,0,r.width,r.height),new Promise((o,s)=>r.toBlob(a=>a?o(a):s(new Error("could not encode image")),n,.9))}async function z5(e){const t=await D5(e);try{const n=Math.max(t.width,t.height);let r=e,o=e.type,s=t.width,a=t.height;if(!IT.has(o)||n>wx||e.size>xg){const l=o==="image/jpeg"?"image/jpeg":"image/png";let u=Math.min(1,wx/n);for(r=await e1(t,u,l);r.size>xg&&u>.1;)u*=.7,r=await e1(t,u,l);if(r.size>xg)throw new Error(`${e.name||"image"}: too large even after downscaling`);o=l,s=Math.max(1,Math.round(t.width*u)),a=Math.max(1,Math.round(t.height*u))}return{blob:r,name:e.name||`pasted.${o==="image/jpeg"?"jpg":"png"}`,mimeType:o,width:s,height:a}}finally{t.close()}}const bu={el:null},F5=80,B5=2e3;let Io=null,Ok;const RT=(e,t)=>{clearTimeout(Ok),Ok=setTimeout(()=>My(e),t)};function Oy(e,t){Io??(Io={refused:!1}),e.dispatch({a:"drag-files",v:Io.refused?null:t}),RT(e,B5)}function OT(e){Io&&RT(e,F5)}const U5=()=>(Io==null?void 0:Io.refused)??!1;function My(e){Io&&(clearTimeout(Ok),Io=null,e.dispatch({a:"drag-files",v:null}))}function H5(e){Io&&(Io.refused=!0,e.dispatch({a:"drag-files",v:null}))}let W5=0;function K5(e){const{blob:t,...n}=e;return{kind:"image",key:`img${++W5}`,...n,upload:"",bytes:t.size,local:URL.createObjectURL(t)}}async function bp(e,t,n){var a;if(!t||n.length===0)return;const r=vp(e,t,"image");if(r===0)return;const o=await Promise.allSettled(n.slice(0,r).map(z5));for(const l of o)l.status==="fulfilled"&&xT(e,t,K5(l.value),l.value.blob);const s=o.find(l=>l.status==="rejected");s?Ao(e,t,String(((a=s.reason)==null?void 0:a.message)??s.reason)):n.length>r&&Ao(e,t,`kept ${r} of ${n.length}: ${Aw("image")}`)}function q5(e,t,n){n.kind==="image"?bp(e,t,[new File([n.blob],"image.png",{type:n.blob.type})]):jy(e,t,n.text),dT()}function kh(e,t,n){const r=o=>o.type.startsWith("image/");bp(e,t,n.filter(r)),Ty(e,t,n.filter(o=>!r(o)))}function MT(e,t){const n=document.createElement("input");n.type="file",n.multiple=!0,n.onchange=()=>kh(e,t,Array.from(n.files??[])),n.click()}function Va(e){const t=e.getState();if(t.newProject)return el;const n=Wo(t)??py(t);if(n)return n.id;const r=Jt(t,t.activeId);return C5(r?t.local[r.worktree.id]:void 0)??qa(r)}function LT(e,t,n=Va(e)){kh(e,n,t.filter(o=>!o.folder).map(o=>o.file));const r=t.find(o=>o.folder);n&&r&&Ao(e,n,`${r.file.name}: a folder cannot be attached; drop its files`)}const Mk=Promise.resolve(null);function Z5(e){var n,r,o;if(!e)return[];const t=[];for(const s of Array.from(e.items)){if(s.kind!=="file")continue;const a=s.getAsFile();if(!a)continue;const l=((n=s.getAsFileSystemHandle)==null?void 0:n.call(s).then(u=>(u==null?void 0:u.kind)==="file"?u:null,()=>null))??Mk;t.push({file:a,handle:l,folder:((o=(r=s.webkitGetAsEntry)==null?void 0:r.call(s))==null?void 0:o.isDirectory)===!0})}if(t.length===0)for(const s of Array.from(e.files))t.push({file:s,handle:Mk});return t}const G5=e=>e.map(t=>({file:t,handle:Mk}));async function PT(e){const t=dh*4;if(e.size>t)return{text:"",tooLarge:!0};const n=await P5(e,t);return n===null?null:n.length>dh?{text:"",tooLarge:!0}:{text:n,tooLarge:!1}}async function V5(e,t){const n=Va(e),r=e.getState().activeId,o=h=>n&&Ao(e,n,h),s=t.filter(h=>h.file.type.startsWith("image/")).map(h=>h.file);s.length&&bp(e,n,s);const a=t.filter(h=>!h.file.type.startsWith("image/")),l=a[0];if(!l||!r)return;const u=await PT(l.file);if(!u)return void o(`${l.file.name}: not a text file`);const f=await l.handle;e.dispatch({a:"open-loose",v:{worktreeId:r,name:l.file.name,...u,binary:!1,source:f?{kind:"handle",handle:f}:{kind:"bytes"},seq:$o()}}),a.length>1&&o(`opened ${l.file.name}; one file opens at a time`)}async function Y5(e,t,n,r){const o=$y(e.getState(),n.worktreeId)??Va(e),s=l=>o&&Ao(e,o,l),a={sock:t,dispatch:l=>e.dispatch(l)};for(const{file:l}of r){const u=await PT(l);if(!u){s(`${l.name}: not a text file`);continue}if(u.tooLarge){s(`${l.name}: too large to add here`);continue}const f=n.dir?`${n.dir}/${l.name}`:l.name,h=await yT(a,{worktreeId:n.worktreeId,path:f},u.text);h&&s(`${l.name}: ${h}`)}}function X5(e){const t=Va(e);t&&Ao(e,t,"drop a file on the chat to attach it, on the preview to open it, or on a folder to add it")}function DT(e,t,n,r){const o=(Io==null?void 0:Io.refused)??!1;My(e),!(o||r.length===0)&&(n?n.at==="chat"||n.at==="centre"&&e.getState().newProject?LT(e,r):n.at==="centre"?V5(e,r):n.at==="rail"?Q5(e,n,r):Y5(e,t,n,r):X5(e))}function Q5(e,t,n){const r=Jt(e.getState(),t.worktreeId);r&&(e.dispatch(Tr(r.worktree)?{a:"open-draft"}:{a:"activate",id:r.worktree.id}),LT(e,n,qa(r)))}const Lk=e=>!!e&&Array.from(e.types).includes("Files");function t1(e,t){var l,u;const n=t instanceof Element?t:t instanceof Node?t.parentElement:null;if(!n)return null;if((l=bu.el)!=null&&l.contains(n))return Va(e)?{at:"chat"}:null;const r=(u=n.closest(".rail [data-wt]"))==null?void 0:u.dataset.wt;if(r)return Jt(e.getState(),r)?{at:"rail",worktreeId:r}:null;const o=n.closest(".tree"),s=o==null?void 0:o.dataset.worktree;if(o&&s){const f=n.closest("[data-path]"),h=f==null?void 0:f.dataset.kind;if(h==="submodule")return null;const p=(f==null?void 0:f.dataset.path)??"";return{at:"tree",worktreeId:s,dir:h==="file"?TT(p):p}}if(!n.closest(".center-root")||n.closest('[data-pane="terminal"], [data-pane="design"]'))return null;const a=e.getState();return a.activeId||a.newProject?{at:"centre"}:null}function J5(){const e=Pn(),t=nt();E.useEffect(()=>{const n=a=>{a.defaultPrevented||!Lk(a.dataTransfer)||(a.preventDefault(),Oy(e,t1(e,a.target)),a.dataTransfer&&(a.dataTransfer.dropEffect=e.getState().dragFiles?"copy":"none"))},r=a=>{a.defaultPrevented||!Lk(a.dataTransfer)||(a.preventDefault(),DT(e,t,t1(e,a.target),Z5(a.dataTransfer)))},o=()=>OT(e),s=a=>{a.key==="Escape"&&H5(e)};return window.addEventListener("dragover",n),window.addEventListener("drop",r),window.addEventListener("dragleave",o),window.addEventListener("keydown",s,!0),()=>{window.removeEventListener("dragover",n),window.removeEventListener("drop",r),window.removeEventListener("dragleave",o),window.removeEventListener("keydown",s,!0)}},[e,t])}function zT(e,t,n){const r=Pn(),o=E.useRef(!1);return{onPaste:u=>{O6();const f=M5(u.clipboardData);if(f.length>0)return u.preventDefault(),void bp(r,e,f);const h=L5(u.clipboardData);if(h.length>0)return u.preventDefault(),Ty(r,e,h);if(o.current)return;const p=u.clipboardData.getData("text/plain");if(p.trim()&&(n!=null&&n(p))){u.preventDefault();return}const g=p.trim()?P6(u.clipboardData,t):null;!(g&&p.includes(`
108
- `))&&!U_(p)||(u.preventDefault(),jy(r,e,p,g?{source:g}:{}))},onPasteKey:u=>{o.current=(u.metaKey||u.ctrlKey)&&u.shiftKey&&u.key.toLowerCase()==="v"},onPasteKeyUp:()=>{o.current=!1}}}function eF(e,t,n){const r=E.useRef(n);r.current=n,E.useEffect(()=>{const o=e.current;if(!o)return;const s=a=>{const{inputType:l,data:u,isComposing:f}=a;a.target!==t.current||f||!u||l!=="insertText"&&l!=="insertFromPaste"||r.current(u)&&a.preventDefault()};return o.addEventListener("beforeinput",s),()=>o.removeEventListener("beforeinput",s)},[e,t])}const tF=640,nF=1e3,FT=`(max-width: ${tF}px), ((hover: none) and (max-width: ${nF}px))`,BT="(hover: none)",Ly=()=>{var e;return(e=window.matchMedia)!=null&&e.call(window,FT).matches?"phone":"desk"},rF=()=>{var e;return((e=window.matchMedia)==null?void 0:e.call(window,BT).matches)??!1},UT=()=>window.top!==window;function oF(e){const t=(o,s)=>{var u;const a=(u=window.matchMedia)==null?void 0:u.call(window,o);if(!a)return()=>{};const l=f=>s(f.matches);return a.addEventListener("change",l),()=>a.removeEventListener("change",l)},n=t(FT,o=>e.dispatch({a:"frame",v:o?"phone":"desk"})),r=t(BT,o=>e.dispatch({a:"touch",v:o}));return()=>{n(),r()}}const HT=(e,t)=>{const n=e.indexOf("#"),[r,o]=n===-1?[e,""]:[e.slice(0,n),e.slice(n)];return`${r}${r.includes("?")?"&":"?"}${PR}=${encodeURIComponent(t)}${o}`},Pk=(e,t)=>!e.serving&&t!==null,sF=3e3;function WT(e,t,n){const[r,o]=E.useState(()=>new Map),s=E.useRef(new Set),a=E.useRef(t);a.current=t;const l=E.useRef(new Map),u=E.useCallback((f,h)=>{s.current.has(f)||(s.current.add(f),rN(e.sock.urls).then(p=>{if(s.current.delete(f),!!a.current.some(y=>y.id===f&&y.url===h)){if(!p){l.current.set(f,setTimeout(()=>{l.current.delete(f),a.current.some(y=>y.id===f&&y.url===h)&&u(f,h)},sF));return}o(y=>new Map(y).set(f,{url:h,src:HT(h,p.code)}))}}))},[e]);return E.useEffect(()=>{const f=l.current;return()=>{for(const h of f.values())clearTimeout(h);f.clear()}},[]),E.useEffect(()=>{var h;if(!n)return;for(const p of t)((h=r.get(p.id))==null?void 0:h.url)!==p.url&&u(p.id,p.url);const f=new Set(t.map(p=>p.id));[...r.keys()].some(p=>!f.has(p))&&o(p=>new Map([...p].filter(([g])=>f.has(g))))},[n,t,r,u]),{urlOf:f=>{var h,p;return n?((h=r.get(f))==null?void 0:h.src)??null:((p=t.find(g=>g.id===f))==null?void 0:p.url)??null},renew:f=>{const h=t.find(p=>p.id===f);!h||!n||(o(p=>{const g=new Map(p);return g.delete(f),g}),u(f,h.url))}}}function iF(e,t,n){var o;const r=E.useRef([]);return t===null?r.current.length>0&&(r.current=[]):((o=r.current[0])==null?void 0:o.url)!==t&&(r.current=[{id:"one",url:t}]),WT(e,r.current,n).urlOf("one")}function aF(e,t,n){if(!n){Rr(t);return}const r=window.open("","_blank");r&&(r.opener=null),rN(e.sock.urls).then(o=>{const s=o?HT(t,o.code):t;r?r.location.href=s:Rr(s)})}function We(...e){return e.filter(Boolean).join(" ")}const cF={branch:"M4.5 5.1v5.8 M11.5 6.6c0 2.6-7 1.6-7 4.3 M4.5 1.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M4.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 3.4a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z",chat:"M2.5 3.5a1.5 1.5 0 0 1 1.5-1.5h8a1.5 1.5 0 0 1 1.5 1.5v6a1.5 1.5 0 0 1-1.5 1.5H7l-3.2 2.6V11H4a1.5 1.5 0 0 1-1.5-1.5z",settings:"M12.38 6.99 14.05 7.26 14.05 8.74 12.38 9.01 11.82 10.38 12.81 11.76 11.76 12.81 10.38 11.82 9.01 12.38 8.74 14.05 7.26 14.05 6.99 12.38 5.62 11.82 4.24 12.81 3.19 11.76 4.18 10.38 3.62 9.01 1.95 8.74 1.95 7.26 3.62 6.99 4.18 5.62 3.19 4.24 4.24 3.19 5.62 4.18 6.99 3.62 7.26 1.95 8.74 1.95 9.01 3.62 10.38 4.18 11.76 3.19 12.81 4.24 11.82 5.62z M8 6.4a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z",zen:"M2 6V3a1 1 0 0 1 1-1h3 M10 2h3a1 1 0 0 1 1 1v3 M14 10v3a1 1 0 0 1-1 1h-3 M6 14H3a1 1 0 0 1-1-1v-3",back:"M9.5 3.5 5 8l4.5 4.5",forward:"M6.5 3.5 11 8l-4.5 4.5",reload:"M13.5 2.5v3.5H10 M12.4 9.2a4.8 4.8 0 1 1-1-4.9l2.1 1.7",pick:"M8 4.2a3.8 3.8 0 1 0 0 7.6 3.8 3.8 0 1 0 0-7.6z M8 1.5v2.7 M8 11.8v2.7 M1.5 8h2.7 M11.8 8h2.7",inspect:"M6.5 13.5h-3a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1h9a1 1 0 0 1 1 1v3 M8.2 8.2l5.3 2-2.3.9-.9 2.3z",terminal:"M2 3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1z M4.8 5.6 7.4 8l-2.6 2.4 M8.6 10.6h2.8",close:"M4.2 4.2 11.8 11.8 M11.8 4.2 4.2 11.8",edit:"M10.6 2.6 13.4 5.4 5.8 13H3v-2.8z M9.2 4l2.8 2.8 M3 10.2l2.8 2.8",check:"M3.4 8.4 6.4 11.4 12.6 4.6",split:"M2.5 2.5h11v11h-11z M2.5 8h11",columns:"M2.5 2.5h11v11h-11z M8 2.5v11",full:"M2.5 2.5h11v11h-11z",more:"M3.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M7.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M11.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z",caret:"M4.5 6.5 8 10l3.5-3.5","caret-up":"M4.5 9.5 8 6l3.5 3.5",stop:"M4.5 4.5h7v7h-7z",send:"M8 13V3.2 M4 7.2 8 3.2l4 4",external:"M9 3h4v4 M13 3 8 8 M11.5 9.5V13H3V4.5h3.5",plus:"M8 3.5v9 M3.5 8h9",download:"M8 2.5v7.4 M4.9 6.8 8 9.9l3.1-3.1 M3 13h10",copy:"M5.5 5.5h8v8h-8z M10.5 5.5v-3h-8v8h3",pull:"M8 3.2v7.4 M4.9 7.4 8 10.6l3.1-3.2",text:"M3.5 3.5h9 M3.5 6.5h9 M3.5 9.5h9 M3.5 12.5h5",wrap:"M3.5 4h9 M3.5 8h7a2 2 0 0 1 0 4H8 M9.5 10.5 8 12l1.5 1.5 M3.5 12h2.5",file:"M4.5 2.5h4.5l2.5 2.5v8.5h-7z M9 2.5V5h2.5",diff:"M8 2.8v5 M5.5 5.3h5 M5.5 11.2h5",folder:"M2.2 3.9a1 1 0 0 1 1-1h2.9l1.5 1.7h5.2a1 1 0 0 1 1 1v5.9a1 1 0 0 1-1 1H3.2a1 1 0 0 1-1-1z",book:"M8 4.6c-1.2-1-2.7-1.4-4.4-1.3v7.6c1.7-.1 3.2.3 4.4 1.3 1.2-1 2.7-1.4 4.4-1.3V3.3c-1.7-.1-3.2.3-4.4 1.3z M8 4.6v8.6",eye:"M2 8c1.6-2.9 3.6-4.3 6-4.3s4.4 1.4 6 4.3c-1.6 2.9-3.6 4.3-6 4.3S3.6 10.9 2 8z M8 6.1a1.9 1.9 0 1 0 0 3.8 1.9 1.9 0 1 0 0-3.8z",trash:"M3.6 4.6h8.8 M6.4 4.6V3.2a.7.7 0 0 1 .7-.7h1.8a.7.7 0 0 1 .7.7v1.4 M5 4.6l.55 8.1a.9.9 0 0 0 .9.84h3.1a.9.9 0 0 0 .9-.84L11 4.6",move:"M2.8 8h9.2 M8.9 4.9 12 8l-3.1 3.1",search:"M7.2 2.6a4.6 4.6 0 1 0 0 9.2 4.6 4.6 0 1 0 0-9.2z M10.5 10.5 13.5 13.5",run:"M3.4 4.2 7.6 8l-4.2 3.8 M9 11.8h4",slash:"M8.4 3.2 4.6 12.2 M9.6 11.8h3.4",bulb:"M4.8 8.8a4 4 0 1 1 6.4 0L9.5 10.6v1.4H6.5v-1.4z M6.7 13.8h2.6",spawn:"M2.3 5.8a3 3 0 1 0 6 0a3 3 0 1 0-6 0z M9.4 11.4a1.9 1.9 0 1 0 3.8 0a1.9 1.9 0 1 0-3.8 0z",handoff:"M1.7 4.5a1.6 1.6 0 1 0 3.2 0a1.6 1.6 0 1 0-3.2 0z M4.9 4.5h4.6 M9.4 4.5a1.6 1.6 0 1 0 3.2 0a1.6 1.6 0 1 0-3.2 0z M4.9 4.5c2.6 0 1.6 7 4.3 7h4 M12.1 9.7l1.8 1.8-1.8 1.8",globe:"M8 2.2a5.8 5.8 0 1 0 0 11.6 5.8 5.8 0 1 0 0-11.6z M2.2 8h11.6 M8 2.2c-3 3.4-3 8.2 0 11.6 3-3.4 3-8.2 0-11.6z",worktrees:"M3.15 4a.65 .65 0 1 0 1.3 0a.65 .65 0 1 0-1.3 0z M7.4 4h5.4 M3.15 8a.65 .65 0 1 0 1.3 0a.65 .65 0 1 0-1.3 0z M7.4 8h5.4 M3.15 12a.65 .65 0 1 0 1.3 0a.65 .65 0 1 0-1.3 0z M7.4 12h5.4",swap:"M3 6.2h9.2 M9.7 3.7 12.2 6.2 9.7 8.7 M13 10.2H3.8 M6.3 7.7 3.8 10.2l2.5 2.5",palette:"M2.3 8.4C2.3 4.7 5 2.2 8.5 2.2c3.4 0 5.2 2.2 5.2 4.6 0 1.9-1.4 2.6-2.7 2.8-.9.15-1.3.7-1.1 1.4.2.9-.5 2.2-2.1 2.2-3.2 0-5.5-2-5.5-4.8z M5 6.2a.5.5 0 1 0 0 1 .5.5 0 1 0 0-1z M7.8 4.9a.5.5 0 1 0 0 1 .5.5 0 1 0 0-1z M11 5.8a.5.5 0 1 0 0 1 .5.5 0 1 0 0-1z",lock:"M4.4 7.3h7.2v6.1H4.4z M6.2 7.3V5.5a1.8 1.8 0 0 1 3.6 0v1.8",phone:"M5.4 2.2h5.2a1.2 1.2 0 0 1 1.2 1.2v9.2a1.2 1.2 0 0 1-1.2 1.2H5.4a1.2 1.2 0 0 1-1.2-1.2V3.4a1.2 1.2 0 0 1 1.2-1.2z M7.1 11.6h1.8",laptop:"M3.4 3.4h9.2a1 1 0 0 1 1 1v6.2H2.4V4.4a1 1 0 0 1 1-1z M1.5 12.6h13",devices:"M8.8 11.2H3.2a1 1 0 0 1-1-1V4.2a1 1 0 0 1 1-1h8.8a1 1 0 0 1 1 1v1.3 M4.6 13.6h4.2 M10.6 6.9h3a.9.9 0 0 1 .9.9v5a.9.9 0 0 1-.9.9h-3a.9.9 0 0 1-.9-.9v-5a.9.9 0 0 1 .9-.9z M11.6 12.1h1",pr:"M4.5 5.1v5.8 M4.5 1.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M4.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 10.9V6.6a2 2 0 0 0-2-2H8 M9.6 2.9 7.9 4.6l1.7 1.7",clock:"M8 2.2a5.8 5.8 0 1 0 0 11.6 5.8 5.8 0 1 0 0-11.6z M8 4.8V8l2.2 1.4",archive:"M2.4 3.2h11.2v2.8H2.4z M3.4 6v6.1a.9.9 0 0 0 .9.9h7.4a.9.9 0 0 0 .9-.9V6 M6.6 8.6h2.8",attach:"M13.7 7.4 8.2 12.9a3.6 3.6 0 0 1-5.1-5.1l5.5-5.5a2.4 2.4 0 0 1 3.4 3.4l-5.5 5.5a1.2 1.2 0 0 1-1.7-1.7l5.1-5.1",cube:"M8 2.4 13.2 5.2v5.6L8 13.6 2.8 10.8V5.2z M2.8 5.2 8 8l5.2-2.8 M8 8v5.6",dot:"M8 4.6a3.4 3.4 0 1 0 0 6.8 3.4 3.4 0 1 0 0-6.8z"};function xt({name:e,className:t}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:cF[e]})})}function wh({className:e}){return d.jsxs("span",{className:We("spinner",e),"aria-hidden":"true",children:[d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{})]})}const lF='button, a[href], input, textarea, select, summary, label, [role="button"], [role="menuitem"]';function n1(e){var n;const t=e;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,lF))??t??null}function uF(e,t){var r,o,s;if(e.box.contains(t)||(r=e.trigger)!=null&&r.contains(t))return!0;const n=(s=(o=t.closest)==null?void 0:o.call(t,"[aria-controls]"))==null?void 0:s.getAttribute("aria-controls");return!!n&&n===e.box.id}function dF(e,t){if(!t)return null;for(let n=e.length-1;n>=0;n--){const r=e[n];if(r!=null&&r.box.contains(t))return r}return null}function fF(e,t){const n=new Set;for(const r of e)if(uF(r,t))for(let o=r;o;o=o.parent)n.add(o);return e.filter(r=>!n.has(r)&&r.dismiss).reverse()}const hF=e=>{setTimeout(e,0)};function pF({schedule:e=hF}={}){let t=[],n=null,r=!1;const o=new Set,s=()=>{for(const l of[...o])l()},a=l=>{var u;for(const f of[...t].reverse())(u=f.dismiss)==null||u.call(f,l)};return{register(l){const u=l.trigger??(l.from===void 0?n:null),f={box:l.box,trigger:u,parent:dF(t,l.from??u),dismiss:l.dismiss,onKey:l.onKey,back:l.back};return t=[...t,f],s(),f},unregister(l){t=t.filter(u=>u!==l),s()},top:()=>t[t.length-1]??null,open:()=>t,watch(l){return o.add(l),()=>o.delete(l)},shut(l){var u;l.back?l.back():(u=l.dismiss)==null||u.call(l,"outside")},install(l){const u=l.document,f=v=>{var S;const x=v.target,N=x?fF(t,x):[];for(const T of N)(S=T.dismiss)==null||S.call(T,"outside");r=N.length>0&&v.pointerType==="touch",r&&v.preventDefault(),n=n1(v.target)},h=()=>e(()=>n=null),p=()=>{r=!1,h()},g=v=>{if(r){r=!1,v.preventDefault(),v.stopPropagation();return}n||(n=n1(v.target),h())},y=v=>{var N;const x=t[t.length-1];(N=x==null?void 0:x.onKey)==null||N.call(x,v)},w=()=>e(()=>{var v;((v=u.activeElement)==null?void 0:v.tagName)==="IFRAME"&&a("frame")});return u.addEventListener("pointerdown",f,!0),u.addEventListener("pointerup",h,!0),u.addEventListener("pointercancel",p,!0),u.addEventListener("click",g,!0),l.addEventListener("keydown",y,!0),l.addEventListener("blur",w),()=>{u.removeEventListener("pointerdown",f,!0),u.removeEventListener("pointerup",h,!0),u.removeEventListener("pointercancel",p,!0),u.removeEventListener("click",g,!0),l.removeEventListener("keydown",y,!0),l.removeEventListener("blur",w)}}}}const nl=pF(),mF=()=>nl.open().some(e=>!!e.dismiss);function gF(){return E.useSyncExternalStore(nl.watch,mF,()=>!1)}const Cg=typeof HTMLElement<"u"&&"showPopover"in HTMLElement.prototype,r1=e=>(e==null?void 0:e.getBoundingClientRect())??null;function kF(e,t,n,r){const o=e.querySelector(t);if(!o)return null;const s=e.getBoundingClientRect(),a=o.getBoundingClientRect();return{offset:n==="top"?s.bottom-a.bottom:a.top-s.top,alignOffset:r==="end"?s.right-a.right:a.left-s.left}}function Qs({className:e,anchor:t,placement:n,coverBy:r,track:o=t==="parent",raiseKey:s,onDismiss:a,onKey:l,onBack:u,trigger:f,from:h,boxRef:p,handle:g,children:y,...w}){const v=E.useRef(null),x=E.useRef({anchor:t,placement:n,coverBy:r,onDismiss:a,onKey:l,onBack:u,trigger:f,from:h});x.current={anchor:t,placement:n,coverBy:r,onDismiss:a,onKey:l,onBack:u,trigger:f,from:h};const N=E.useCallback(()=>{const T=v.current,{anchor:j,placement:$,coverBy:R}=x.current;if(!T||!j||!$)return;const A=j==="parent"?r1(T.parentElement):j();if(!A)return;const I=D6(A,$);I!==void 0&&(T.style.width=`${I}px`);for(let M=0;M<2;M++){const P=R?kF(T,R,T.dataset.side??"",T.dataset.align??""):null,F=F6(A,{w:T.offsetWidth,h:T.offsetHeight},{w:window.innerWidth,h:window.innerHeight},P?{...$,...P}:$);T.style.left=`${F.x}px`,T.style.top=`${F.y}px`;const q=T.dataset.side!==F.side||T.dataset.align!==F.align;if(T.dataset.side=F.side,T.dataset.align=F.align,!q)break}},[]);E.useImperativeHandle(g,()=>({update:N}),[N]),E.useLayoutEffect(()=>{const T=v.current;if(!T)return;p&&(p.current=T),Cg&&(T.popover="manual",T.matches(":popover-open")||T.showPopover());const{onDismiss:j,onKey:$,onBack:R,trigger:A,from:I}=x.current,M=j||$?nl.register({box:T,trigger:A,from:I,dismiss:j?P=>{var F,q;return(q=(F=x.current).onDismiss)==null?void 0:q.call(F,P)}:void 0,onKey:$?P=>{var F,q;return(q=(F=x.current).onKey)==null?void 0:q.call(F,P)}:void 0,back:R?()=>{var P,F;return(F=(P=x.current).onBack)==null?void 0:F.call(P)}:void 0}):null;return()=>{M&&nl.unregister(M),p&&(p.current=null),Cg&&T.isConnected&&T.matches(":popover-open")&&T.hidePopover()}},[p]),E.useLayoutEffect(N),E.useLayoutEffect(()=>{if(!o)return;let T=0,j="";const $=()=>{const R=v.current,{anchor:A}=x.current,I=R&&A?A==="parent"?r1(R.parentElement):A():null;if(R&&I){const M=`${I.left},${I.top},${I.right},${I.bottom},${R.offsetWidth},${R.offsetHeight},${window.innerWidth},${window.innerHeight}`;M!==j&&(j=M,N())}T=requestAnimationFrame($)};return T=requestAnimationFrame($),()=>cancelAnimationFrame(T)},[o,N]);const S=E.useRef(!0);return ct([s],()=>{if(S.current){S.current=!1;return}const T=v.current;!Cg||!(T!=null&&T.matches(":popover-open"))||(T.hidePopover(),T.showPopover(),N())}),d.jsx("div",{ref:v,className:We("float",e),...w,children:y})}const wF=/^[⌘⇧⌥⌃]+/;function ss({k:e,chip:t=!1,className:n}){var a;const r=(a=e.match(wF))==null?void 0:a[0],o=r?e.slice(r.length):e,s=["kbd",t?"kbd-chip":"",n??""].filter(Boolean).join(" ");return d.jsxs("kbd",{className:s,children:[r&&d.jsx("span",{className:"kbd-mod",children:r}),o]})}function Nt(e,t,{placement:n,align:r,detail:o,card:s,dot:a,name:l,aside:u,also:f}={}){const h=l?`${e}: ${l}`:e,p=(Array.isArray(o)?o:[o]).filter(y=>!!y),g=[h,...p,...u??[]].join(", ");return{"data-tip":e,"data-tip-key":t,"data-tip-placement":n,"data-tip-align":r,"data-tip-detail":p.length?p.join(`
109
- `):void 0,"data-tip-card":s||l||u!=null&&u.length?"":void 0,"data-tip-dot":a,"data-tip-name":l,"data-tip-aside":u!=null&&u.length?u.join(`
110
- `):void 0,"data-tip-also":f==null?void 0:f.text,"data-tip-also-key":f==null?void 0:f.key,"aria-label":t?`${g} (${t})`:g}}const yF=120,vF=600,bF=150,o1=6,xF=18,Ag=8;function s1(e){const t=e.dataset.tipPlacement;return t==="follow"||t==="top"||t==="bottom"||t==="left"||t==="right"?t:"bottom"}function EF(e){const t=e.dataset.tipAlign;return t==="start"||t==="center"||t==="end"?t:void 0}function KT(e,t){return e==="follow"?{side:"bottom",align:"start",offset:xF,alignOffset:-12,flip:"both",margin:Ag}:e==="left"||e==="right"?{side:e,align:t??"start",offset:o1,flip:"both",margin:Ag}:{side:e,align:t??"center",offset:o1,flip:"both",margin:Ag}}function SF(e,t){return e.placement==="follow"?hT(t):e.el.getBoundingClientRect()}function qT(){var u;const[e,t]=E.useState(null),n=E.useRef(null),r=E.useRef(null),o=E.useRef({x:0,y:0}),s=Ys();if(E.useEffect(()=>{if(s)return;let f=0,h=0,p=null,g=!1,y=0;const w=()=>{window.clearTimeout(f),window.clearTimeout(h)},v=()=>{w(),g&&(y=Date.now()),g=!1,p=null,t(null)},x=(I,M)=>{var F,q;const P=I.dataset.tip;if(!P)return v();w(),g=!0,t({el:I,text:P,key:I.dataset.tipKey,detail:(F=I.dataset.tipDetail)==null?void 0:F.split(`
111
- `),card:I.dataset.tipCard!==void 0,dot:I.dataset.tipDot,name:I.dataset.tipName,aside:(q=I.dataset.tipAside)==null?void 0:q.split(`
112
- `),also:I.dataset.tipAlso&&I.dataset.tipAlsoKey?{text:I.dataset.tipAlso,key:I.dataset.tipAlsoKey}:void 0,placement:M,align:EF(I)})},N=I=>{const M=I.target;if(!(M instanceof Element))return null;const P=M.closest("[data-tip], .float");return(P==null?void 0:P.dataset.tip)!==void 0?P:null},S=I=>{o.current={x:I.clientX,y:I.clientY};const M=N(I);if(M===p)return;if(w(),p=M,!M){g&&(h=window.setTimeout(v,bF));return}const P=s1(M);if(g||Date.now()-y<vF)return x(M,P);f=window.setTimeout(()=>x(M,P),yF)},T=I=>{I.relatedTarget||v()},j=I=>{const M=N(I);if(M!=null&&M.matches(":focus-visible")){w(),p=M;const P=s1(M);x(M,P==="follow"?"bottom":P)}},$=()=>v(),R=I=>{I.key!=="Shift"&&I.key!=="Control"&&I.key!=="Alt"&&I.key!=="Meta"&&v()},A=I=>{p&&I.target instanceof Node&&I.target.contains(p)&&v()};return document.addEventListener("mouseover",S),document.addEventListener("mouseout",T),document.addEventListener("mousedown",v),document.addEventListener("keydown",R),document.addEventListener("scroll",A,!0),document.addEventListener("focusin",j),document.addEventListener("focusout",$),window.addEventListener("blur",v),()=>{w(),document.removeEventListener("mouseover",S),document.removeEventListener("mouseout",T),document.removeEventListener("mousedown",v),document.removeEventListener("keydown",R),document.removeEventListener("scroll",A,!0),document.removeEventListener("focusin",j),document.removeEventListener("focusout",$),window.removeEventListener("blur",v)}},[s]),E.useLayoutEffect(()=>{e&&!e.el.isConnected&&t(null)},[e]),E.useEffect(()=>{if((e==null?void 0:e.placement)!=="follow")return;const f=h=>{var p;o.current={x:h.clientX,y:h.clientY},(p=r.current)==null||p.update()};return document.addEventListener("mousemove",f),()=>document.removeEventListener("mousemove",f)},[e]),!e)return null;const a=e.dot?d.jsxs("span",{className:"tooltip-words",children:[d.jsx("span",{className:`dot ${e.dot} tooltip-dot`}),e.text]}):e.text,l=d.jsxs(d.Fragment,{children:[a,e.key&&d.jsx(ss,{k:e.key,className:"tooltip-key"})]});return d.jsxs(Qs,{className:We("tooltip",e.card&&"tooltip-card"),role:"tooltip",boxRef:n,handle:r,anchor:()=>SF(e,o.current),placement:KT(e.placement,e.align),track:!1,raiseKey:e,children:[e.also?d.jsxs("div",{className:"tooltip-pair",children:[d.jsx("span",{children:a}),e.key?d.jsx(ss,{k:e.key,className:"tooltip-key"}):d.jsx("span",{}),d.jsx("span",{className:"tooltip-also",children:e.also.text}),d.jsx(ss,{k:e.also.key,className:"tooltip-key"})]}):e.name?d.jsxs("div",{className:"tooltip-head",children:[d.jsx("span",{children:l}),d.jsx("span",{className:"tooltip-name",children:e.name})]}):l,(u=e.detail)==null?void 0:u.map((f,h)=>d.jsx("div",{className:"tooltip-detail",children:f},h)),e.aside&&d.jsx("div",{className:"tooltip-foot",children:e.aside.map(f=>d.jsx("span",{children:f},f))})]})}const _F={sm:"",md:"btn-md",lg:"btn-lg"},NF={ghost:"",outline:"btn-outline",field:"btn-outline btn-field",inline:"btn-inline"},ZT={primary:"tone-primary",quiet:"tone-quiet",danger:"tone-danger",strong:"tone-strong",chrome:"tone-chrome"};function Me({variant:e="ghost",size:t="sm",tone:n,on:r,mono:o,busy:s,className:a,type:l="button",disabled:u,children:f,...h}){const p=We("btn",NF[e],_F[t],n&&ZT[n],r&&"on",o&&"btn-mono",s&&"btn-busy",a);return d.jsxs("button",{className:p,type:l,disabled:s||u,"aria-busy":s||void 0,...h,children:[s&&d.jsx(wh,{}),f]})}function Tt({icon:e,label:t,hint:n,detail:r,also:o,placement:s,tipAlign:a,silent:l,badge:u,tone:f,on:h,className:p,type:g="button",...y}){const w=We("btn-icon",f&&ZT[f],h&&"on",p),v=Nt(t,n,{detail:r,also:o,placement:s,align:a});return d.jsxs("button",{className:w,type:g,...l?{"aria-label":v["aria-label"]}:v,...y,children:[typeof e=="string"?d.jsx(xt,{name:e}):e,u]})}function rd(e,t,n){return n===0?0:(e+t+n)%n}function i1(e,t,n){return e>=0?rd(e,t,n):n===0?-1:t>0?0:n-1}function GT(e,t,n){var s;const r=e.length,o=n.toLowerCase();for(let a=1;a<=r;a++){const l=(Math.max(t,-1)+a)%r;if((s=e[l])!=null&&s.trim().toLowerCase().startsWith(o))return l}return-1}function Ig(e,t){return e&&e.length>t.length&&e.toLowerCase().startsWith(t.toLowerCase())?e.slice(t.length):null}function TF(e,t){if(e==null)return null;if(typeof e=="string"){const o=Ig(e,t);return o?{text:o,accept:o,params:[]}:null}const n=Ig(e.show,t);if(!n)return null;const r=(e.params??[]).map(([o,s])=>[Math.max(o,t.length)-t.length,s-t.length]).filter(([o,s])=>s>o);return{text:n,accept:Ig(e.accept,t),params:r}}function VT(e){const{results:t,keyOf:n,q:r,onPick:o,listRef:s,onActive:a,onSide:l,completionOf:u,narrowTo:f,setQ:h,tabPicks:p,onIdlePick:g}=e,[y,w]=E.useState(()=>{var R;return e.idle?-1:Math.max(0,((R=e.initialIndex)==null?void 0:R.call(e,t))??0)}),v=y>=0&&t[y]?n(t[y]):null,x=E.useRef(a);x.current=a,ct([v],()=>{var R,A,I;(A=(R=s.current)==null?void 0:R.querySelector('.picker-item[data-state~="cursor"]'))==null||A.scrollIntoView({block:"nearest"}),(I=x.current)==null||I.call(x,y>=0?t[y]??null:null)});const N=y<0?-1:Math.min(y,Math.max(0,t.length-1)),S=N>=0?t[N]??null:null,T=S?TF(u==null?void 0:u(S,r),r):null,j=R=>{const A=f==null?void 0:f(R,r);if(A==null)return o(R,r);h==null||h(A),w(0)};return{index:N,active:S,ghost:T,setIndex:w,pick:j,onKeyDown:R=>{if(R.key==="ArrowDown")R.preventDefault(),w(i1(N,1,t.length));else if(R.key==="ArrowUp")R.preventDefault(),w(i1(N,-1,t.length));else if((R.key==="ArrowLeft"||R.key==="ArrowRight")&&l&&S)R.preventDefault(),l(S,R.key==="ArrowLeft"?-1:1);else if(R.key==="Tab"&&(T!=null&&T.accept))R.preventDefault(),h==null||h(r+T.accept),w(0);else if(R.key==="Tab"&&p&&S)R.preventDefault(),j(S);else if(R.key==="Enter"&&S)R.preventDefault(),j(S);else if(R.key==="Enter"&&N<0&&g)R.preventDefault(),g(r);else return!1;return!0}}}function fr(e){const t=Object.keys(e).filter(n=>e[n]);return t.length>0?t.join(" "):void 0}const jF=new Set(["Shift","Meta","Control","Alt","CapsLock","Fn"]);function YT(){const e=_y(),t=Pn();return E.useEffect(()=>{if(!e)return;const n=()=>{e.target.isConnected||go.close()},r=new MutationObserver(n);r.observe(document.body,{childList:!0,subtree:!0});const o=t.subscribe(n);return()=>{r.disconnect(),o()}},[e,t]),e?d.jsx($F,{spec:e},e.id):null}function $F({spec:e}){const t=e.items,n=t.filter(ys),[r,o]=E.useState(-1),s=E.useRef({idx:r,items:n});s.current={idx:r,items:n};const a=E.useRef(null),l=p=>{var g,y;{const w=()=>go.close(),{idx:v,items:x}=s.current;if(jF.has(p.key))return;if(p.key==="ArrowDown"||p.key==="ArrowUp"){p.preventDefault(),p.stopPropagation();const N=p.key==="ArrowDown"?1:-1;o(B6(x,v,N));return}if((p.key==="Enter"||p.key===" ")&&v>=0&&x[v]&&!x[v].disabled){p.preventDefault(),p.stopPropagation(),x[v].onClick(),w();return}if(p.key==="Escape"){p.stopPropagation(),w();return}if(p.key.length===1&&!p.metaKey&&!p.ctrlKey&&!p.altKey){p.preventDefault(),p.stopPropagation();const N=Array.from(((g=a.current)==null?void 0:g.querySelectorAll(".menu-label"))??[],T=>T.textContent??""),S=GT(N,v,p.key);S>=0&&!((y=x[S])!=null&&y.disabled)&&o(S);return}w()}};E.useEffect(()=>{const p=()=>go.close();return window.addEventListener("blur",p),window.addEventListener("resize",p),document.addEventListener("scroll",p,!0),()=>{window.removeEventListener("blur",p),window.removeEventListener("resize",p),document.removeEventListener("scroll",p,!0)}},[]);const{rect:u,placement:f}=W6(e),h=n.some(p=>p.checked);return d.jsxs(Qs,{className:We("menu",e.head!==void 0&&"menu-headed"),role:"menu",boxRef:a,anchor:()=>u,placement:f,track:!1,from:e.target,trigger:e.toggles?e.target:null,onDismiss:()=>go.close(),onKey:l,onContextMenu:p=>p.preventDefault(),children:[e.head!==void 0&&d.jsx("div",{className:"menu-head",children:e.head}),t.map((p,g)=>{if(!ys(p))return d.jsx("hr",{className:"menu-sep"},`sep-${g}`);const y=n.indexOf(p);return d.jsx(CF,{item:p,gutter:h,cursor:y===r,onEnter:()=>o(y)},p.id)})]})}function CF({item:e,gutter:t,cursor:n,onEnter:r}){const o=e.disabled!==void 0,s=e.detail??e.disabled;return d.jsxs("button",{...e.checked===void 0?{role:"menuitem"}:{role:"menuitemcheckbox","aria-checked":e.checked},"aria-disabled":o||void 0,className:We("row row-keyed",e.danger&&"danger",s!==void 0&&"row-tall",o&&"disabled"),"data-state":fr({cursor:n,checked:e.checked}),onMouseMove:o||n?void 0:r,onClick:()=>{o||(e.onClick(),go.close())},children:[t&&d.jsx("span",{className:"menu-check",children:e.checked&&d.jsx(xt,{name:"check",className:"icon-inline"})}),d.jsxs("span",{className:"menu-text",children:[d.jsx("span",{className:"menu-label",children:e.label}),s!==void 0&&d.jsx("span",{className:"menu-detail row-dim",children:s})]}),e.key&&d.jsx(ss,{k:e.key,className:"menu-key row-dim"})]})}const yh=8,AF=104,IF=.25,XT=220,Dk=.5,RF=100;function OF(e,t){return Math.max(0,-QT(e,t))}function QT(e,t){const n=e.filter(a=>t-a.t<=RF);if(n.length<2)return 0;const r=n[0],o=n[n.length-1],s=o.t-r.t;return s>0?(o.x-r.x)/s:0}function MF(e,t,n){return e>0?e:n>0&&t>=Dk?1:0}function LF({dx:e,dy:t}){return Math.abs(e)<yh&&Math.abs(t)<yh?null:Math.abs(e)>Math.abs(t)&&e<0?"slide":"other"}function PF(e,t,n=AF){const r=Math.max(0,-e),o=t*n,s=Math.min(t,Math.floor(r/n)),a=r<=o?r:o+(r-o)*IF,l=Math.min(1,r/(n/2));return{step:s,x:-a,well:l}}function JT(e,t){const n=E.useRef(t);n.current=t,E.useEffect(()=>{const r=e.current;if(!r)return;let o=null,s=null,a=!1,l=0,u=[],f=0,h=0;const p=(T,j,$,R)=>{T.el.dataset.slide!==R&&(T.el.dataset.slide=R,T.el.offsetWidth),T.el.style.setProperty("--slide-x",`${j}px`),T.el.style.setProperty("--slide-well",`${Math.round($*100)}%`)},g=T=>{T.el.style.removeProperty("--slide-x"),T.el.style.removeProperty("--slide-well"),delete T.el.dataset.slide},y=(T=0)=>{var I;const j=o,$=a,R=j?MF(l,T,j.rungs):0,A=R!==l;o=null,s=null,a=!1,l=0,u=[],!(!j||!$)&&(A&&(n.current.onSlide({key:j.key,step:R}),(I=navigator.vibrate)==null||I.call(navigator,8)),p(j,0,0,"settle"),R>0&&n.current.onPick(j.key,R),f=window.setTimeout(()=>{g(j),n.current.onSlide(null)},XT))};let w=null;const v=T=>{if(!T.isPrimary||T.pointerType==="mouse"&&T.button!==0)return y();const j=T.target instanceof Element?n.current.rowOf(T.target):null;!j||j.el.dataset.slide||(window.clearTimeout(f),o=j,w=T.pointerId,s={x:T.clientX,y:T.clientY})},x=T=>{var I;const j=o;if(!j||!s||T.pointerId!==w)return;const $=T.clientX-s.x,R=T.clientY-s.y;if(!a){const M=LF({dx:$,dy:R});if(M==="other"&&(o=null,s=null,w=null),M!=="slide")return;a=!0;try{j.el.setPointerCapture(T.pointerId)}catch{}n.current.onSlide({key:j.key,step:0})}u.push({x:T.clientX,t:T.timeStamp}),u.length>8&&u.shift();const A=PF($,j.rungs,j.rung);p(j,A.x,A.well,"drag"),A.step!==l&&(l=A.step,n.current.onSlide({key:j.key,step:l}),l>0&&((I=navigator.vibrate)==null||I.call(navigator,8)))},N=T=>{T.pointerId===w&&(a&&(h=T.timeStamp+400),w=null,y(T.type==="pointerup"?OF(u,T.timeStamp):0))},S=T=>{T.timeStamp>=h||(T.preventDefault(),T.stopPropagation())};return r.addEventListener("pointerdown",v),r.addEventListener("pointermove",x),r.addEventListener("pointerup",N),r.addEventListener("pointercancel",N),r.addEventListener("click",S,!0),()=>{window.clearTimeout(f),r.removeEventListener("pointerdown",v),r.removeEventListener("pointermove",x),r.removeEventListener("pointerup",N),r.removeEventListener("pointercancel",N),r.removeEventListener("click",S,!0)}},[e])}const ej=1/3,DF=220;function zF({dx:e,dy:t}){return Math.abs(e)<yh&&Math.abs(t)<yh?null:Math.abs(e)<=Math.abs(t)?"other":e<0?"left":"right"}function FF(e,t,n){return n==="left"?Math.min(0,Math.max(-t,e)):Math.max(0,Math.min(t,e))}function BF(e,t,n,r){const o=n==="left"?-r:r;return o>=Dk?!0:o<=-Dk?!1:Math.abs(e)>=t*ej}function UF(e,t){for(let n=e;n!==t&&n instanceof HTMLElement;n=n.parentElement){const r=getComputedStyle(n).overflowX;if((r==="auto"||r==="scroll")&&n.scrollWidth>n.clientWidth+1)return n}return null}const a1=-1;function HF(e,t){const n=E.useRef(t);n.current=t;const r=E.useRef(()=>{});return E.useEffect(()=>{const o=e.current;if(!o)return;let s=null,a=null,l=null,u=!1,f=0,h=null,p=null,g=0,y=null,w=[],v=0,x=0;const N=(q,W)=>{const ee=p;ee&&(ee.dataset.swipe!==W&&(ee.dataset.swipe=W,ee.offsetWidth),ee.style.translate=`${q}px`)},S=()=>{const q=p;p=null,q&&(delete q.dataset.swipe,q.offsetWidth,q.style.removeProperty("translate"))},T=()=>{s=null,a=null,l=null,u=!1,h=null,g=0,y=null,w=[]},j=q=>{try{o.setPointerCapture(q.pointerId)}catch{}},$=q=>{var V,te;const W=h,ee=(p==null?void 0:p.clientWidth)??0;T(),W&&(N(q?W==="left"?-ee:ee:0,"settle"),(te=(V=n.current).onSettle)==null||te.call(V,q),v=window.setTimeout(()=>{OS.flushSync(()=>n.current.onEnd(q)),S()},DF))},R=q=>{var ee;if(q.pointerType==="mouse")return;if(!q.isPrimary)return h?$(!1):T();if(p||(((ee=window.visualViewport)==null?void 0:ee.scale)??1)>1.01)return;const W=q.target instanceof Element?q.target:null;!W||W.closest("textarea, input, [contenteditable], iframe, .float")||(window.clearTimeout(v),s={x:q.clientX,y:q.clientY},a=W,l=UF(W,o),y=q.pointerId,f=q.clientX)},A=(q,W,ee,V)=>{if(!s||!a)return;const te=q-s.x,K=W-s.y;if(u&&l){l.scrollLeft-=q-f,f=q;return}if(!h){const C=zF({dx:te,dy:K});if(C===null)return;if(C==="other")return T();if(l){u=!0,f=q,V&&j(V);return}const oe=n.current.take(a,C);if(!oe)return T();p=oe,h=C,V&&j(V)}w.push({x:q,t:ee}),w.length>8&&w.shift(),g=FF(te,(p==null?void 0:p.clientWidth)??0,h),N(g,"drag")},I=(q,W)=>{var K;if(!h)return T();const ee=(p==null?void 0:p.clientWidth)??0,V=W?QT(w,q):0,te=W&&BF(g,ee,h,V);te&&Math.abs(g)<ee*ej&&((K=navigator.vibrate)==null||K.call(navigator,8)),$(te)},M=q=>{q.pointerId===y&&A(q.clientX,q.clientY,q.timeStamp,q)},P=q=>{q.pointerId===y&&((h||u)&&(x=q.timeStamp+400),I(q.timeStamp,q.type==="pointerup"))};r.current=q=>{const W=performance.now();if(q.phase==="start"){if(p||s)return;s={x:q.x,y:q.y},a=o,l=null,y=a1;return}if(y===a1){if(q.phase==="move")return A(q.x+g,q.y,W);I(W,q.phase==="end")}};const F=q=>{q.timeStamp>=x||(q.preventDefault(),q.stopPropagation())};return o.addEventListener("pointerdown",R),o.addEventListener("pointermove",M),o.addEventListener("pointerup",P),o.addEventListener("pointercancel",P),o.addEventListener("click",F,!0),()=>{r.current=()=>{},window.clearTimeout(v),o.removeEventListener("pointerdown",R),o.removeEventListener("pointermove",M),o.removeEventListener("pointerup",P),o.removeEventListener("pointercancel",P),o.removeEventListener("click",F,!0)}},[e]),E.useCallback(o=>r.current(o),[])}function Ya({items:e,current:t,onPick:n,fill:r,font:o,segmented:s,dense:a,quiet:l,end:u,label:f,owner:h}){const p=xn(h),g=E.useRef(null),y=Math.max(0,e.findIndex(v=>v.id===t)),w=v=>{var S,T;if(v.key!=="ArrowLeft"&&v.key!=="ArrowRight")return;v.preventDefault();const x=e.findIndex(j=>j.id===t),N=e[rd(x,v.key==="ArrowRight"?1:-1,e.length)];N&&(n(N.id),(T=(S=g.current)==null?void 0:S.querySelectorAll('[role="tab"]')[e.indexOf(N)])==null||T.focus())};return d.jsxs("div",{className:We("tabs",r&&"tabs-fill",o==="mono"&&"tabs-mono",s&&"tabs-segmented",a&&"tabs-dense",l&&"tabs-quiet"),children:[d.jsx("div",{className:"tabs-list",role:"tablist","aria-label":f,ref:g,onKeyDown:w,style:s?{"--tabs-at":y,"--tabs-count":e.length}:void 0,children:e.map(v=>{const x=v.id===t;return d.jsxs("div",{className:We("tab",x&&!!v.trail&&"tab-trailed",v.fit&&"tab-fit",v.far&&"tab-far"),"data-state":fr({current:x}),...v.menu?p.contextMenu(v.menu):{},children:[d.jsxs("button",{type:"button",className:"tab-btn",role:"tab","aria-selected":x,tabIndex:x?0:-1,onClick:()=>n(v.id),...v.tip,...v.ariaLabel?{"aria-label":v.ariaLabel}:{},children:[v.lead,v.label]}),x&&v.trail&&d.jsx("span",{className:"tab-trail",children:v.trail})]},v.id)})}),u&&d.jsx("span",{className:"tabs-end",children:u})]})}function Es({anchor:e="top",wide:t,foot:n,children:r}){const o=d.jsx("div",{className:We("view",e==="line"&&"view-anchored",t&&"view-wide"),children:r});return n?d.jsxs("div",{className:"view-stack",children:[o,n]}):o}const tj=e=>`Toyon restarts once ${e.join(", ")} ${e.length===1?"finishes":"finish"}`,WF=(e,t)=>[...e,...t.filter(n=>!e.includes(n))];function KF(e,t,n){const r=[...t],o=[...n],s=(l,u)=>{const f=l.indexOf(u);return f===-1?!1:(l.splice(f,1),!0)};return[...e.map(l=>s(r,l)?{name:l,dot:"working",note:null}:s(o,l)?{name:l,dot:"waiting",note:"asking you"}:{name:l,dot:"idle",note:"finished"}),...o.map(l=>({name:l,dot:"waiting",note:"asking you"}))]}function qF(e,t){return`${e>=t?`Toyon restarts once ${e===1?"this chat finishes its reply":`these ${e} chats finish their replies`}`:`${t-e} of ${t} chats have finished; Toyon restarts after the ${e===1?"last one":`other ${e}`}`}, and this page reloads when it is back. Restarting now stops ${e===1?"it":"them"} mid-reply.`}function ZF(e){if(!e)return null;if(e.restarting&&e.restarting.length>0){const t=e.restarting.length;return{word:t===1?"restarts after a reply":`restarts after ${t} replies`,text:tj(e.restarting),retry:!1,busy:!0}}if(e.failed){const t=e.failed.line.replace(/\.$/,"");return{word:"update failed",text:`Installing Toyon ${e.failed.version} stopped: ${t}. To update by hand, run ${e.failed.command}`,retry:!0,busy:!1}}return null}let zk=!1;function GF(){zk=!0}function Zc({title:e,body:t,action:n,pane:r,children:o}){return d.jsxs("div",{className:We("crash",r&&"in-pane"),children:[d.jsx("div",{className:"crash-title",children:e}),t&&d.jsx("div",{className:"crash-body",children:t}),o,n]})}const c1={title:"Toyon was updated",body:"This page is still running the old build. Reload to pick up the new one."};class Py extends E.Component{constructor(){super(...arguments);_t(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,r){console.error("[toyon] render error",n,r.componentStack)}render(){const{error:n}=this.state;return n?d.jsx(Zc,{pane:this.props.pane,title:zk?c1.title:"Toyon hit an error",body:zk?c1.body:n.message||String(n),action:d.jsx(Me,{variant:"outline",onClick:()=>window.location.reload(),children:"reload"})}):this.props.children}}const Fk={title:"Toyon was updated",waiting:"Restarting Toyon. This page reloads when it is back.",foreign:e=>`Toyon on ${e} speaks another version than this app. Update Toyon there; this page needs no reload.`},VF=1e3,l1={held:[],asking:[],seen:[]};async function u1(e,t,n){for(;;){await new Promise(s=>setTimeout(s,VF));const[r,o]=await Promise.all([wk(e),eN(e)]);if(r!==null&&r!==t)break;n(o??{waiting:[],asking:[]})}window.location.reload()}function nj({foreign:e}={}){return e?d.jsx(YF,{name:e}):d.jsx(XF,{})}function YF({name:e}){const t=xs(),n=t.list()[0];return d.jsx(Zc,{title:`Toyon on ${e} was updated`,body:Fk.foreign(e),action:n&&d.jsxs(Me,{variant:"outline",onClick:()=>t.activate(n.origin),children:["back to ",t.displayName(n.origin)]})})}function XF(){const e=Mr(),[t,n]=E.useState(!0),[r,o]=E.useState(null),[s,a]=E.useState(l1),l=E.useRef(null),u=E.useCallback(w=>a(v=>({held:w.waiting,asking:w.asking,seen:WF(v.seen,w.waiting)})),[]),f=E.useCallback(async w=>{n(!0),o(null);const v=l.current??{pid:await wk(e)},x=await Z4(e,w);if(x){n(l.current!==null),o(x);return}w&&a(l1),!l.current&&(l.current=v,u1(e,v.pid,u))},[u,e]);E.useEffect(()=>{let w=!0;return(async()=>{const[v,x]=await Promise.all([wk(e),eN(e)]);if(!(!w||l.current)){if(x===null){f(!1);return}l.current={pid:v},u(x),u1(e,v,u)}})(),()=>{w=!1}},[u,f,e]);const h=t&&s.held.length>0,p=h?KF(s.seen,s.held,s.asking):[],g=p.filter(w=>w.dot==="working").length,y=p.filter(w=>w.dot!=="waiting").length;return d.jsx(Zc,{title:Fk.title,body:r??(h?qF(g,y):Fk.waiting),action:h?d.jsx(Me,{variant:"outline",onClick:()=>void f(!0),children:"restart now"}):d.jsx(Me,{variant:"outline",busy:t,onClick:()=>void f(!1),children:"restart"}),children:p.length>0&&d.jsx("ul",{className:"crash-list",children:p.map((w,v)=>d.jsxs("li",{className:We("crash-row",w.dot!=="working"&&"row-dim"),children:[d.jsx("span",{className:We("dot",w.dot)}),d.jsx("span",{className:"crash-row-name",children:w.name}),w.note&&d.jsx("span",{className:"crash-row-note",children:w.note})]},v))})})}const $a=(e,t=!1)=>({text:e,live:t}),QF={probing:"connecting to daemon",down:"the daemon is not running.\nrun `toyon` in your repo to start it; `toyon doctor` says what it can see",blocked:"the daemon is up, but this page's websocket never connected.\na proxy, VPN or browser extension is the usual cause; `toyon doctor` checks from the terminal",unauthorized:"this page's token is not the running daemon's.\nrun `toyon` again and open the link it prints"},JF={probing:e=>`connecting to ${e}`,down:e=>`Toyon on ${e} is not answering.
113
- is Tailscale on here, and is Toyon running there?`,blocked:e=>`Toyon on ${e} is up, but this page's websocket to it never connected.
114
- a proxy, VPN or browser extension is the usual cause`,unauthorized:e=>`this page's token for ${e} is not the one running there.
115
- forget ${e} here and pair it again`},e8="no access token for this address.\nrun `toyon` or `toyon open` in your repo to get a signed-in page";function rj(e){if(e.standing&&!e.connected&&e.connectFailure!=="unauthorized")return null;if(!e.connected&&(!e.heard||e.connectFailure)){const t=e.connectFailure===null;return e.machine?$a(JF[e.connectFailure??"probing"](e.machine),t):e.hasToken?$a(QF[e.connectFailure??"probing"],t):$a(e8)}return e.title===null?$a(e.heard?`nothing open yet.
116
- press ${e.projectChord} to open a project, or type a name there to start a new one`:""):null}function t8(e){const t=rj(e);return t!==null?t:e.needsSetup&&e.busy?$a(`building in ${e.title}; the preview appears once it starts`,!0):e.needsSetup&&e.treeEmpty?$a(`${e.title} is empty so far; say what to build`):e.treeEmpty&&e.landsFrom?$a(`nothing runs on main until ${e.landsFrom} lands`):null}const fn={post:(e,t)=>{},broadcast:e=>{}};function Lu(e,t,n,r){const o=t===r;fn.post(e,o?{type:"pick-cancel"}:{type:"pick-start",verb:r}),n({a:"set-picking",v:o?!1:r})}function oj(e){return[{id:"copy-sha",label:`copy ${e.short}`,onClick:()=>sn(e.sha)},{id:"copy-subject",label:"copy subject",onClick:()=>sn(e.subject)}]}function xp(e,t,n){var o,s;const r=e[t];if(!r)return null;if(n==="ArrowRight")return r.open===void 0?null:r.open?(((o=e[t+1])==null?void 0:o.depth)??-1)>r.depth?{do:"to",at:t+1}:null:{do:"open",at:t};if(r.open)return{do:"close",at:t};for(let a=t-1;a>=0;a--)if((((s=e[a])==null?void 0:s.depth)??0)<r.depth)return{do:"to",at:a};return null}const sj="application/x-toyon-mention";let Fa=null;const Ep=()=>!Ys();function n8(e){return e.kind==="worktree"?`@${e.title} `:Cy(e.items)}function r8(e){return e.kind==="worktree"?e.branch:e.items.map(t=>t.path).join(" ")}function Pu(e,t){e.dataTransfer.setData(sj,"1"),e.dataTransfer.setData("text/plain",r8(t)),e.dataTransfer.effectAllowed="copy",Fa=t}function od(e){Fa=null,My(e)}function ij(e,t){const n=e.getState().activeId;return(t.kind==="paths"?t.worktreeId===n:t.worktreeId!==n)?Va(e):null}const aj=e=>Fa!==null&&Array.from(e.dataTransfer.types).includes(sj);function o8(e,t){if(!aj(t)||!Fa)return;t.preventDefault();const n=ij(e,Fa)!==null;t.dataTransfer.dropEffect=n?"copy":"none",n&&Oy(e,{at:"chat"})}function cj(e,t){if(!aj(t)||!Fa)return null;t.preventDefault();const n=Fa,r=U5();if(od(e),r)return null;const o=ij(e,n);return o?{boxId:o,words:n8(n)}:null}function s8(e,t,n){const r=e.ownerDocument;if(typeof r.caretPositionFromPoint!="function")return null;const o=r.caretPositionFromPoint(t,n);return(o==null?void 0:o.offsetNode)===e?o.offset:null}const lj=e=>Object.entries(e.worktree.sources??{}).filter(([,t])=>Zh(t.at)).map(([t])=>t),i8=e=>sh(Ri((e==null?void 0:e.config)??{}),e==null?void 0:e.defaultBranch).toLowerCase();function Li(e,t,n){t({a:"shipping",id:n.worktreeId,op:n.t}),e==null||e.send(n)}const uj=(e,t)=>iR(e.worktree,{pending:()=>e.agent!=="idle"||(e.queued??0)>0||!!e.shipping,drafted:t,counts:()=>({dirty:e.dirty,ahead:e.ahead})});function Gc(e,t,n){if(n.length!==0){t({a:"archive-worktrees",ids:n});for(const r of n)e==null||e.send({t:"archive-worktree",worktreeId:r})}}function dj(e,t,n){t({a:"hold-unread",id:n}),e==null||e.send({t:"mark-unread",worktreeId:n})}function fj(e,t,n){return{rename(r){if(!US(r.worktree))return;const o=window.prompt("Rename worktree (its branch follows as a slug):",r.worktree.title);o!=null&&o.trim()&&(e==null||e.send({t:"rename-worktree",worktreeId:r.worktree.id,title:o.trim()}))},ownProcs(r){for(const o of r.borrowed??[])e==null||e.send({t:"set-proc-source",worktreeId:r.worktree.id,name:o.name,source:"here"})},shareProcs(r){const o=lj(r);if(window.confirm(`Stop this worktree's own ${o.join(", ")} and use main's?
117
-
118
- What they hold that main's do not (a database of their own) is not carried over.`))for(const a of o)e==null||e.send({t:"set-proc-source",worktreeId:r.worktree.id,name:a,source:"main"})},archive(r){var a;if(!Kh(r.worktree))return;const o=uj(r,n);if(!o)return Gc(e,t,[r.worktree.id]);window.confirm(`Archive worktree "${r.worktree.title}"? ${(a=o[0])==null?void 0:a.toUpperCase()}${o.slice(1)}.
119
-
120
- Its directory and branch (${r.worktree.branch}) go. The chat, its draft, the commits and any uncommitted changes are kept, and the project menu can restore it.`)&&Gc(e,t,[r.worktree.id])}}}function hj(e,t,n,{sock:r,dispatch:o},s){var R;const a=e.worktree.id,l=fj(r,o,n.drafted),u=[],f=[],h=[],p=[],g=[],y=[];is(e.agent)&&u.push({id:"stop",label:"stop agent",onClick:()=>r==null?void 0:r.send({t:"stop-agent",worktreeId:a})});const w=!n.shipping[a],v=n.frame==="phone";((e.dirty??0)>0||(e.ahead??0)>0||!v&&!n.layout.changes)&&u.push({id:"changes",label:`view changes${(e.dirty??0)>0?` (${e.dirty})`:""}`,onClick:()=>{o({a:"activate",id:a}),v?o({a:"screen",to:"changes"}):n.layout.changes||o({a:"toggle-changes"})}}),f.push({id:"copy-branch",label:"copy branch name",onClick:()=>sn(e.worktree.branch)}),f.push(...Ko(()=>r==null?void 0:r.send({t:"reveal",worktreeId:a}),s.hostname)),v||f.push({id:"copy-path",label:"copy path",onClick:()=>sn(e.path)});const{transcript:x,sessionId:N}=e,S=!!x&&!Tr(e.worktree);S&&wp(s.hostname)&&f.push({id:"reveal-transcript",label:"reveal transcript in Finder",onClick:()=>r==null?void 0:r.send({t:"reveal-transcript",worktreeId:a})});const T=!v&&!!s.palette;T&&S&&f.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>sn(x)}),T&&N&&f.push({id:"copy-session",label:"copy session id",onClick:()=>sn(N)}),!Di(e.worktree)&&((R=e.borrowed)!=null&&R.length)&&g.push({id:"own-procs",label:`run ${e.borrowed.map(A=>A.name).join(", ")} here`,detail:"on main now",onClick:()=>l.ownProcs(e)});const j=lj(e);if(!Di(e.worktree)&&j.length>0&&g.push({id:"share-procs",label:`use main's ${j.join(", ")}…`,detail:"runs here now",danger:!0,onClick:()=>l.shareProcs(e)}),US(e.worktree)&&h.push({id:"rename",label:"rename…",onClick:()=>l.rename(e)}),s.graft&&Kf(e.worktree)){const A=s.graft;h.push({id:"graft",label:"graft with…",onClick:()=>A(a)})}h.push({id:"unread",label:"mark as unread",key:Ht("mark-unread"),disabled:e.unseen?"already unread":void 0,onClick:()=>dj(r,o,a)});const $=w?void 0:"waiting on the one in progress";if(e.syncQueued)p.push({id:"sync",label:"call off the sync from main",onClick:()=>r==null?void 0:r.send({t:"unqueue-sync",worktreeId:a})});else if(qh(e)&&(e.behind??0)>0){const A=is(e.agent)&&(e.dirty??0)>0;p.push({id:"sync",label:`sync from main${A?" after the turn":""} (${e.behind} behind)`,disabled:$,onClick:()=>Li(r,o,{t:"sync-main",worktreeId:a})})}return Na(e.worktree)&&!(e.worktree.landed&&e.dirty===0)&&p.push({id:"land",label:Mw(Ri((t==null?void 0:t.config)??{}),Ow(e.worktree,e.dirty)),detail:i8(t),disabled:$,onClick:()=>Li(r,o,{t:"land",worktreeId:a})}),e.worktree.kind==="worktree"&&p.push({id:"handoff",label:"continue elsewhere…",sub:!0,onClick:()=>o({a:"open",overlay:{kind:"handoff",worktreeId:a}})}),Kh(e.worktree)&&y.push({id:"archive",label:uj(e,n.drafted)?"archive…":"archive",key:Ht("wt-archive"),danger:!0,onClick:()=>l.archive(e)}),Un([u,f,h,p,g,y])}function a8(e,t,{sock:n,dispatch:r},o){const s=[],a=t.frame==="phone",l=[{id:"adopt",label:"take over",disabled:e.locked?`held by ${e.lockReason??"another tool"}`:void 0,onClick:()=>n==null?void 0:n.send({t:"adopt-worktree",worktreeId:e.id,clientId:t.clientId})}];return qh(e)&&(e.behind??0)>0&&s.push({id:"sync",label:`sync from main (${e.behind} behind)`,onClick:()=>n==null?void 0:n.send({t:"sync-main",worktreeId:e.id})}),a||s.push({id:"shell",label:"open a shell here",onClick:()=>{r({a:"activate",id:e.id}),r({a:"focus-terminal"})}}),s.push(...Ko(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id}),o)),Un([l,s,a?[]:[{id:"copy-path",label:"copy path",onClick:()=>sn(e.path)}]])}const c8={sm:"",md:"field-md",lg:"field-lg"};function pj({size:e="sm",font:t,bare:n,rule:r,className:o}){const s=t??(e==="lg"?"ui":"mono");return We("field",c8[e],s==="ui"&&"field-ui",s==="lead"&&"field-lead",n&&"field-bare",r&&"field-rule",o)}const Ho=E.forwardRef(function({size:t,font:n,bare:r,rule:o,className:s,...a},l){return d.jsx("input",{ref:l,className:pj({size:t,font:n,bare:r,rule:o,className:s}),...a})}),Du=E.forwardRef(function({size:t,font:n,bare:r,rule:o,className:s,...a},l){return d.jsx("textarea",{ref:l,className:pj({size:t,font:n,bare:r,rule:o,className:s}),...a})}),no=e=>/[.!?…]$/.test(e)?e:`${e}.`,mj=160;function Sp(e,t=mj){const n=e.replace(/\s+/g," ").trim();if(n.length<=t)return n;const r=n.slice(0,t);return`${r.slice(0,Math.max(r.lastIndexOf(" "),1)).trimEnd()}…`}function Dy(e){return e.subjects.length?Sp(e.subjects.join("; ")):void 0}function gj(e){const t=Dy(e);if(t)return e.pr===void 0?t:Sp(`PR #${e.pr}: ${t}`)}function zy(e,t=3){const n=[];for(const a of e??[]){const l=gj(a);l&&n.push({at:a.at,line:l})}if(n.length===0)return[];const r=n.slice(-t),o=n.length-r.length,s=r.map(({at:a,line:l})=>n.length===1?no(l):`${Fy(jo(dr(a)))}: ${no(l)}`);return o>0?[`${o} earlier landing${o===1?"":"s"}.`,...s]:s}const l8="checks running",u8="checks failed",kj="preview up";function d8(e){if(e.state!=="open")return[];const t=[];return(e.checks==="pending"||e.checks==="fail")&&t.push({text:e.checks==="fail"?u8:l8,url:`${e.url}/checks`,tip:"Open the checks on GitHub",open:"open the checks"}),e.preview&&t.push({text:kj,url:e.preview,tip:`Open the branch on ${new URL(e.preview).hostname}`,open:"open the preview"}),t}function f8(e,t){const n=[];let r=e;for(const o of t){const s=new RegExp(`(^|; |, )${o.text.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?=;|\\.|$)`).exec(r);if(!s)continue;const a=s.index+(s[1]??"").length;a>0&&n.push(r.slice(0,a)),n.push(o),r=r.slice(a+o.text.length)}return r&&n.push(r),n}function zs(e){const t=`PR #${e.number}`;if(e.state==="merged")return`${t} merged.`;if(e.state==="closed")return`${t} was closed without merging.`;const n=e.preview?`; ${kj}.`:".";if(e.queued){if(e.queued==="failed")return`${t} failed in the merge queue${n}`;const r={waiting:"",checking:"; the queue's checks are running",merging:"; merging now"}[e.queued];return`${t} in the merge queue${r}${n}`}if(e.automerge){const r=e.review==="review_required"?"it is approved and checks pass":"checks pass";return`${t} open; GitHub ${e.queue?"queues":"merges"} it when ${r}${n}`}return e.mergeable===!1?`${t} open; it conflicts with main${n}`:e.review==="changes_requested"?`${t} open; changes requested${n}`:e.checks==="fail"?`${t} open; checks failed${n}`:e.checks==="pending"?`${t} open; checks running${n}`:e.review==="review_required"?`${t} open; waiting on review${n}`:e.review==="approved"?`${t} approved${e.checks==="pass"?", checks pass":""}${n}`:`${t} open and ready to merge${n}`}function wj(e){return e.queue?"Add the PR to the merge queue; GitHub merges it in turn":"Merge the PR now, by the method the repo allows"}function yj(e){return e.state==="open"&&!e.automerge&&!e.queued&&e.mergeable!==!1&&e.review!=="changes_requested"&&e.review!=="review_required"&&e.checks!=="fail"&&e.checks!=="pending"}const Fy=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function By(e,t,n){return t===0||e!=null&&e.subject?null:!e||e.stale?"unwritten":e.check==="pending"?"pending":e.check==="fail"?null:e.unanswered||n?"unanswered":"unasked"}function vj(e,t){return e!=null&&e.stale?`The work changed since this was written. ${t?"Run the check again and refresh":"Refresh"} the message.`:`${t?"Run the repo's check here and write":"Write"} the recap and the commit message.`}const h8="No commit message yet: one is written before the commit.";function p8(e){return e?`No commit message: ${e} has no quick model to write one. Write it in the changes panel.`:"No commit message yet: write one in the changes panel."}function Af(e,t=0,n=!0,r){var o,s;if(e.check==="pending")return"Checking the work…";if(e.check==="fail"){const a=(s=(o=e.checkTail)==null?void 0:o.split(`
121
- `).find(l=>l.trim()))==null?void 0:s.trim();return`Check failed${a?`: ${no(a)}`:"."}`}return By(e,t,n)==="unasked"?p8(r):null}function d1(e,t){const n=m8(e,t);return n?no(Fy(n)):""}function m8(e,t){const n=t>0?`${t} ${t===1?"file":"files"} changed`:"",r=e.check==="pass"?"check passed":"";return[n,r].filter(Boolean).join(", ")}const bj=e=>/^[A-Z][a-z]+(\s|$)/.test(e)?`${e.charAt(0).toLowerCase()}${e.slice(1)}`:e;function g8(e,t){const n=t??0;return n>0?`${n} behind ${e}; land takes it in first.`:""}function k8(e){return e>0?no(Fy(`${e} ${e===1?"file":"files"} changed`)):""}function w8(e){return e.stale?"Changed since this was written.":e.why?`Not ready: ${no(bj(e.why))}`:null}function If(e){return no(e)}const jo=e=>e==="now"?"just now":`${e} ago`;function y8(e,t,n){switch(e){case"asking":return`Waiting on you${n==="now"?"":` for ${n}`}${t.ask?`: ${no(t.ask)}`:"."}`;case"failed":return t.auth?`Stopped ${jo(n)}: not logged in.`:t.error?`Failed ${jo(n)}: ${no(t.error)}`:`Failed ${jo(n)}.`;case"stopped":return t.planBack?`Sent the plan back ${jo(n)}. Say what to change.`:`Stopped ${jo(n)}.`;case"done":return t.cut?`Ended early ${jo(n)} (${t.cut}).`:`Finished ${jo(n)}.`}}function Uy(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?no(t):y8(e.end,e.facts,dr(e.at))}function v8(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?`Last stop, ${jo(dr(e.at))}: ${no(bj(t))}`:void 0}function zu(e,t){var n,r;return(r=(n=e==null?void 0:e.worktree)==null?void 0:n.runs)==null?void 0:r.find(o=>o.kind===t)}function Hy(e){return(e==null?void 0:e.status)==="running"||(e==null?void 0:e.status)==="detached"}function xj(e){const t=e&&e.status!=="terminated"?e.since:void 0,n=yy(t,vy);return t!==void 0&&n===t?e:void 0}function Ej(e,t){const n=e.stage?[e.stage]:[];switch(e.status){case"queued":return[...n,"queued"];case"running":return[...n,`${ja(t)} of ${_R(e.timeoutMs)}`];case"detached":return[...n,ja(t),"detached"];case"terminated":return[e.why??"stopped"]}}function vh(e,t,n){return[e,...Ej(t,n)].join(" · ")}const Bk={queued:"Asked for, not started yet.",running:"Running under the daemon's watch. It is killed at the ceiling.",detached:"The daemon restarted under it. It runs on, unwatched, until it ends or is stopped.",terminated:"Killed: at its ceiling, or by a stop."};function Sj(e){switch(e){case"setup":return"Stop this setup command; the next one runs";case"check":return"Stop the check; it reads as failed until it runs again";case"commit":return"Stop the commit and the hooks it is running; nothing is committed"}}function b8({active:e,ahead:t,behind:n,unpushed:r,dirty:o}){var nn,pn,It;const s=nt(),a=ht(),l=xn("changes"),u=Tn(e)?e.worktree:null,f=e.id,h=L(gt=>{var Vt;return(Vt=gt.shipping[f])==null?void 0:Vt.op}),p=L(gt=>{var Vt;return(Vt=gt.shipping[f])==null?void 0:Vt.step}),g=yy(p,vy),y=zu(e,"commit"),w=zu(e,"check"),v=h?y:w,x=xj(v),N=Mi(Hy(x)?x==null?void 0:x.since:void 0),[S,T]=E.useState("");ct([f],()=>T("")),ct([o],()=>{o||T("")});const j=E.useRef(null),$=(nn=u==null?void 0:u.landing)!=null&&nn.subject?u.landing.body?`${u.landing.subject}
122
-
123
- ${u.landing.body}`:u.landing.subject:null,R=()=>{S===""&&$&&T($);const gt=j.current;gt&&(gt.focus(),requestAnimationFrame(()=>gt.setSelectionRange(gt.value.length,gt.value.length)))},A=L(gt=>gt.editCommit);ct([A],()=>{A&&R()});const I=S.trim()||void 0,M=L(gt=>{var Vt;return!!((Vt=gt.agents.find(Cn=>Cn.id===((u==null?void 0:u.agent)??gt.defaultAgent)))!=null&&Vt.quick)}),P=u==null?void 0:u.landing,F=I?null:By(P,o?1:0,M),q=(P==null?void 0:P.check)==="pending",W=!!(P!=null&&P.stale),ee=()=>{h||s==null||s.send({t:"judge",worktreeId:f})},V=()=>{h||!I&&!$||Li(s,a,{t:"commit",worktreeId:f,message:I??$??""})},te=()=>{h||Li(s,a,{t:"land",worktreeId:f,...I?{message:I}:{}})},K=((pn=u==null?void 0:u.landing)==null?void 0:pn.check)==="fail",C=!!(u!=null&&u.landed)&&!o,oe=u?Ow(u,o?1:0):void 0,U=oe?Yh(oe):void 0,B=(U==null?void 0:U.state)==="open",Q=B&&(o||r>0),ue=q||W||!!F&&F!=="unanswered",he=!!u&&Na(u)&&!C&&(o||t>0)&&!K&&!B&&!ue,Ne=!!u&&Q&&!K&&!ue,De=!!u&&Na(u)&&!q&&(W||F==="unwritten")&&!is(e.agent),Be=L(gt=>gt.repos.find(Vt=>Vt.id===e.repoId)??null),Z=Ri((Be==null?void 0:Be.config)??{}),J=sh(Z,Be==null?void 0:Be.defaultBranch),pe=Mw(Z,oe??{}),de=Be?Vh(Be):"main",ie=qh(e)?Nz(de,n):null,ye=is(e.agent),_e=o&&!u?"commit or discard the changes here first":void 0,be=!!e.syncQueued,$e=o&&ye?`Merge ${de} into this worktree once the turn ends, uncommitted changes kept`:`Merge ${de} into this worktree${o?", uncommitted changes kept":""}`,Ze=B&&!Q&&yj(U),rt=he?pe:Ne?"update":Ze?"land":(U==null?void 0:U.state)==="merged"?"pull":"land",en=h==="commit"?g??"commit":h==="land"?g?`${rt}: ${g}`:rt:null,Xt=en&&x?vh(en,x,N):en,Et=E.useRef(!1);Xt?o&&(Et.current=!0):Et.current=!1;const Ke=!!u&&(o||Et.current),Qt=Ke&&!!Xt,Ot=h?null:v?x?Ej(x,N).join(" · "):null:q?"writing the message":null,Zt=x&&(x.status==="running"||x.status==="detached")?x:null,Ge=Zt&&d.jsx(Tt,{icon:"stop",tone:"danger",label:Sj(Zt.kind),onClick:()=>s==null?void 0:s.send({t:"run-stop",worktreeId:f,kind:Zt.kind})});return d.jsxs("div",{className:"composer commit-box",children:[Ke&&d.jsx("div",{className:"composer-field",children:Qt?d.jsx("div",{className:"commit-running live-text","data-tip":x?Bk[x.status]:void 0,children:Xt}):d.jsx(Du,{size:"lg",bare:!0,ref:j,value:S,onChange:gt=>T(gt.target.value),onKeyDown:gt=>{gt.key==="Enter"&&(gt.metaKey||gt.ctrlKey)?(gt.preventDefault(),V()):gt.key==="Tab"&&!gt.shiftKey&&S===""&&$&&(gt.preventDefault(),R())},placeholder:$??(F==="unanswered"?"no message yet: landing writes one, or write one here":F==="unasked"?"no message yet: write one here to commit or land":"commit message…")})}),d.jsxs("div",{className:"hint composer-knobs",children:[d.jsxs("span",{className:"commit-where",children:[d.jsx(xt,{name:"branch",className:"icon-inline"}),d.jsx("span",{className:"branch-name",children:e.branch??"detached"}),t>0&&d.jsxs("span",{className:"badge-ahead","data-tip":`${t} commit(s) ahead of ${de}`,children:[t," ahead"]}),C&&d.jsxs("span",{className:"badge-landed","data-tip":`Merged into ${de}`,children:[d.jsx(xt,{name:"check",className:"icon-inline"})," landed"]})]}),d.jsxs("span",{className:"commit-acts",children:[Xt?d.jsxs(d.Fragment,{children:[!Qt&&d.jsx("span",{className:"live-text",children:Xt}),Ge]}):d.jsxs(d.Fragment,{children:[u&&o&&d.jsx(Me,{disabled:!I&&!$||!!h,onClick:V,...Nt($&&!I?"Commit with the suggested message":"git add -A && git commit","⌘⏎"),children:"commit"}),u&&he&&d.jsx(Me,{tone:"primary",disabled:!!h,"data-tip":J,onClick:te,children:pe}),De&&d.jsx(Me,{tone:"primary",disabled:!!h,"data-tip":vj(P,!!((It=Be==null?void 0:Be.config.check)!=null&&It.trim())),onClick:ee,children:"check"}),q&&d.jsx("span",{className:"live-text",children:"check"}),Ne&&U&&d.jsx(Me,{tone:"primary",disabled:!!h,"data-tip":`Commit, take ${de} in and push the branch; PR #${U.number} takes the new commits`,onClick:te,children:"update"}),Ze&&d.jsx(Me,{tone:"primary",disabled:!!h,"data-tip":wj(U),onClick:te,children:"land"})]}),U&&d.jsxs(Me,{"data-tip":`Open PR #${U.number} on GitHub`,onClick:()=>Rr(U.url),...l.contextMenu(()=>[{id:"open-pr",label:"open on GitHub",onClick:()=>Rr(U.url)},{id:"copy-link",label:"copy link",onClick:()=>sn(U.url)}]),children:["view ",d.jsx(xt,{name:"external",className:"icon-inline"})]}),(U==null?void 0:U.preview)&&d.jsxs(Me,{"data-tip":`Open the branch on ${new URL(U.preview).hostname}`,onClick:()=>Rr(U.preview),...l.contextMenu(()=>[{id:"open-preview",label:"open the preview",onClick:()=>Rr(U.preview)},{id:"copy-preview",label:"copy link",onClick:()=>sn(U.preview??"")}]),children:["preview ",d.jsx(xt,{name:"external",className:"icon-inline"})]})]})]}),(ie||Ot)&&d.jsxs("div",{className:"composer-notes",children:[Ot&&d.jsxs("div",{className:"hint composer-note","data-tip":x?Bk[x.status]:void 0,children:[d.jsx("span",{children:Ot}),Ge]}),ie&&d.jsxs("div",{className:"hint composer-note",children:[d.jsx("span",{children:ie}),h==="sync-main"?d.jsx("span",{className:"live-text",children:g?`sync: ${g}`:"sync"}):be?d.jsx("span",{className:"live-text","data-tip":"Runs once the turn ends, the uncommitted changes kept. The row's menu calls it off",children:"syncing after next turn"}):d.jsx(Me,{variant:"outline",disabled:!!h||!!_e,"data-tip":_e??$e,onClick:()=>Li(s,a,{t:"sync-main",worktreeId:f}),children:"sync"})]})]})]})}const x8=E.memo(function({c:t,id:n,selected:r,onToggle:o}){const s=xn("changes"),a=td("changes");return d.jsxs("button",{className:"row row-sm log-row row-edge",id:n,"data-state":fr({current:r,cursor:r}),role:"option","aria-selected":r,tabIndex:-1,onClick:()=>o(t.sha),...s.contextMenu(()=>oj(t)),"data-tip":`${t.subject}
124
- ${t.short} · ${t.author}`,"data-tip-placement":a,children:[d.jsx("span",{className:"subject",children:t.subject}),d.jsx("span",{className:"at row-dim",children:dr(t.at)})]})});function E8(e,t){const n=Kr(e,t);if(!n||!Tn(n))return"take this worktree over to change files here";if(Di(n.worktree))return"start a worktree to change files"}function _j(e,t,n,r){return{id:"new-file",label:"new file…",disabled:E8(e.getState(),t),onClick:()=>r(n)}}function S8(e,t,n,r){const{worktreeId:o,dir:s,path:a,folder:l,newIn:u}=e,f=$y(t.getState(),o)?void 0:"take this worktree over to talk to an agent here",h=ST(a,l),p=[...l?[]:[{id:"open",label:"open",onClick:()=>Rn(n,{worktreeId:o,path:a,view:Bi(a)})}],{id:"add-to-chat",label:"add to chat",disabled:f,onClick:()=>r5(t,o,a,l)}],g=[_j(t,o,u,r),{id:"ask-rename",label:"ask the agent to rename…",disabled:f,onClick:()=>Xx(t,o,`Rename ${h} to `)},{id:"ask-delete",label:"ask the agent to delete…",disabled:f,onClick:()=>Xx(t,o,`Delete ${h} and update whatever still uses it`)}],y=[...Ko(()=>{var w;return(w=n.sock)==null?void 0:w.send({t:"reveal",worktreeId:o,path:a})},wo(n.sock)),{id:"copy-path",label:"copy path",onClick:()=>sn(`${s}/${a}`)},{id:"copy-relative-path",label:"copy relative path",onClick:()=>sn(a)}];return Un([p,y,g])}function _8(e,t,n,r){return Un([[_j(t,e.worktreeId,"",r)],Ko(()=>{var o;return(o=n.sock)==null?void 0:o.send({t:"reveal",worktreeId:e.worktreeId})},wo(n.sock))])}const Rf=[],N8=[],f1=new Set,h1=e=>`tree-row-${e}`;function T8({worktreeId:e,dir:t,openPath:n,openRef:r,rootRef:o}){const s=Pn(),a=nt(),l=ht(),u=Rt(e,"files"),f=Rt(e,"submodules"),h=Rt(e,"ignored"),p=Rt(e,"git"),g=(p==null?void 0:p.files)??N8,y=p==null?void 0:p.version,w=L(ie=>ie.connected);ct([e,y,w,a],()=>yp(e,s.getState(),{sock:a,dispatch:l}));const v=L(ie=>{var ye;return((ye=ie.dragFiles)==null?void 0:ye.at)==="tree"&&ie.dragFiles.worktreeId===e?ie.dragFiles.dir:null}),x=L(ie=>ie.treeOpen[e]??Rf),N=E.useMemo(()=>new Set(x),[x]),[S,T]=E.useState(f1);ct([e,n,r],()=>T(n&&!r?new Set(ph(n).filter(ie=>!N.has(ie))):f1));const j=E.useCallback(ie=>N.has(ie)||S.has(ie),[N,S]),$=E.useCallback(ie=>{const ye=N.has(ie)||S.has(ie);if(ye&&S.has(ie)){const _e=new Set(S);_e.delete(ie),T(_e)}l({a:"tree-folder",worktreeId:e,path:ie,open:!ye})},[N,S,e,l]),R=E.useMemo(()=>c5(u??Rf,f??Rf,h??Rf),[u,f,h]),A=E.useMemo(()=>l5(R,j),[R,j]),I=E.useMemo(()=>d5(g),[g]),M=L(ie=>ie.treeReveal),P=M&&M.worktreeId===e?M:null,[F,q]=E.useState(()=>(P==null?void 0:P.path)??null),[W,ee]=E.useState({worktreeId:e,linked:P});(W.worktreeId!==e||W.linked!==P)&&(ee({worktreeId:e,linked:P}),q((P==null?void 0:P.path)??null));const[V,te]=E.useState(!1),K=E.useMemo(()=>{if(F===null)return-1;const ie=A.findIndex(ye=>ye.path===F);if(ie>=0)return ie;for(const ye of ph(F).reverse()){const _e=A.findIndex(be=>be.path===ye);if(_e>=0)return _e}return-1},[A,F]);ct([K,V],()=>{var ie,ye;V&&((ye=(ie=o.current)==null?void 0:ie.querySelector('[data-state~="cursor"]'))==null||ye.scrollIntoView({block:"nearest"}))});const C=E.useCallback((ie,ye)=>Rn({dispatch:l},{worktreeId:e,path:ie,view:Bi(ie),focus:ye}),[e,a,l]),oe=E.useCallback(ie=>{q(ie.path),ie.kind==="folder"?$(ie.path):ie.kind==="file"&&C(ie.path,!1)},[$,C]),U=ie=>{var be;if(ie.metaKey||ie.ctrlKey||ie.altKey)return;const ye=A[K],_e=$e=>{const Ze=A[$e];Ze&&(q(Ze.path),Ze.kind==="file"&&C(Ze.path,!1))};switch(ie.key){case"ArrowDown":case"ArrowUp":ie.preventDefault(),_e(K<0?0:rd(K,ie.key==="ArrowDown"?1:-1,A.length));return;case" ":ie.preventDefault(),(ye==null?void 0:ye.kind)==="file"?C(ye.path,!1):(ye==null?void 0:ye.kind)==="folder"&&$(ye.path);return;case"Enter":ie.preventDefault(),(ye==null?void 0:ye.kind)==="file"?C(ye.path,!0):(ye==null?void 0:ye.kind)==="folder"&&$(ye.path);return;case"ArrowRight":case"ArrowLeft":{ie.preventDefault();const $e=A.map(rt=>rt.kind==="folder"?{depth:rt.depth,open:rt.open}:{depth:rt.depth}),Ze=xp($e,K,ie.key);(Ze==null?void 0:Ze.do)==="to"?_e(Ze.at):Ze&&ye&&$(ye.path);return}case"Escape":ie.stopPropagation(),n!==null?l({a:"close-editor"}):(be=document.activeElement)==null||be.blur();return}if(ie.key.length===1){const $e=GT(A.map(Ze=>Ze.name),K,ie.key);$e>=0&&(ie.preventDefault(),_e($e))}},[B,Q]=E.useState(null),ue=E.useRef(0),he=E.useCallback(ie=>{ie&&!j(ie)&&$(ie),ue.current++,Q({dir:ie,error:null,busy:!1})},[j,$]),Ne=E.useCallback(()=>{ue.current++,Q(null)},[]),De=E.useCallback(ie=>{if(!B||B.busy)return;const ye=u5(B.dir,ie);if("error"in ye){Q({...B,error:ye.error});return}const _e=++ue.current;Q({...B,error:null,busy:!0}),yT({sock:a,dispatch:l},{worktreeId:e,path:ye.path}).then(be=>{be===null&&q(ye.path),_e===ue.current&&Q(be===null?null:{...B,error:be,busy:!1})})},[B,e,a,l]),Be=xn("tree"),Z=E.useCallback(ie=>S8({worktreeId:e,dir:t,path:ie.path,folder:ie.kind!=="file",newIn:ie.kind==="folder"||ie.kind==="ignored"?ie.path:TT(ie.path)},s,{sock:a,dispatch:l},he),[e,t,s,a,l,he]),J=E.useCallback((ie,ye)=>{ie.kind==="file"&&fn.post(e,ye?{type:"highlight-file",path:ie.path,ranges:null}:{type:"highlight-clear"})},[e]),pe=E.useCallback((ie,ye)=>Pu(ye,{kind:"paths",worktreeId:e,items:[{path:ie.path,folder:ie.kind!=="file"}]}),[e]),de=E.useCallback(()=>od(s),[s]);return d.jsx("div",{className:We("tree",v===""&&"drop-over"),role:"tree","aria-label":"files","data-worktree":e,"aria-activedescendant":V&&K>=0?h1(K):void 0,tabIndex:0,ref:o,onKeyDown:U,onFocus:()=>{var ie;te(!0),F===null&&q(n&&A.some(ye=>ye.path===n)?n:((ie=A[0])==null?void 0:ie.path)??null)},onBlur:ie=>!ie.currentTarget.contains(ie.relatedTarget)&&te(!1),onMouseDown:ie=>{if(ie.button!==0)return;const ye=ie.target.closest("[data-path]");(ye==null?void 0:ye.dataset.path)!==void 0&&q(ye.dataset.path)},...Be.contextMenu(ie=>{const ye=A[K];return ie==="keyboard"&&ye?Z(ye):_8({worktreeId:e},s,{sock:a},he)}),children:u===void 0?d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"listing files"})}):A.length===0&&!B?d.jsx("div",{className:"empty",children:"no files"}):j8(A.map((ie,ye)=>d.jsx(C8,{row:ie,id:h1(ye),status:I.files.get(ie.path),changedInside:ie.kind!=="file"&&I.folders.has(ie.path),current:V?ye===K:!r&&ie.path===n,cursor:V&&ye===K,dropOver:v===ie.path,onPress:oe,menu:Z,onHover:J,onDragStart:pe,onDragEnd:de},ie.path)),B&&(()=>{var ye;const ie=B.dir===""?-1:A.findIndex(_e=>_e.path===B.dir);return{at:ie,node:d.jsx($8,{depth:ie>=0?(((ye=A[ie])==null?void 0:ye.depth)??0)+1:0,error:B.error,onSubmit:De,onCancel:Ne},"new-file")}})())})}function j8(e,t){return t?[...e.slice(0,t.at+1),t.node,...e.slice(t.at+1)]:e}function $8({depth:e,error:t,onSubmit:n,onCancel:r}){const[o,s]=E.useState(""),a={"--tree-depth":e},l=e===0||void 0;return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"row row-sm tree-row row-rails","data-kind":"file","data-root":l,style:a,children:[d.jsx("span",{className:"tree-caret row-dim"}),d.jsx(Ho,{bare:!0,font:"mono",autoFocus:!0,className:"tree-new-name","aria-label":"new file name","aria-invalid":t!==null||void 0,placeholder:"name",value:o,onChange:u=>s(u.target.value),onKeyDown:u=>{u.stopPropagation(),u.key==="Enter"?(u.preventDefault(),n(o)):u.key==="Escape"&&(u.preventDefault(),r())},onBlur:r})]}),t&&d.jsxs("div",{className:"tree-row tree-new-error row-rails","data-root":l,style:a,children:[d.jsx("span",{className:"tree-caret"}),d.jsx("span",{className:"hint",children:t})]})]})}const C8=E.memo(function({row:t,id:n,status:r,changedInside:o,current:s,cursor:a,dropOver:l,onPress:u,menu:f,onHover:h,onDragStart:p,onDragEnd:g}){const y=xn("tree"),w=Ep(),v=td("changes"),x=t.kind==="submodule",N=x?"A submodule: its files belong to its own repository":t.kind==="ignored"?"Ignored by git, so what is inside is not listed":null;return d.jsxs("div",{role:"treeitem",id:n,"aria-level":t.depth+1,"aria-expanded":t.kind==="folder"?t.open:void 0,"aria-selected":a,className:We("row row-sm tree-row row-rails row-edge",l&&"drop-over"),"data-state":fr({current:s,cursor:a}),"data-kind":t.kind,"data-path":t.path,style:{"--tree-depth":t.depth},draggable:w&&!x,onDragStart:S=>p(t,S),onDragEnd:g,onClick:()=>u(t),onMouseEnter:()=>h(t,!0),onMouseLeave:()=>h(t,!1),...y.contextMenu(()=>f(t)),...N?Nt(N,void 0,{placement:v}):{},children:[d.jsx("span",{className:"tree-caret row-dim",children:t.kind==="folder"&&d.jsx(xt,{name:"caret",className:We("icon-inline disc-caret",!t.open&&"shut")})}),d.jsx("span",{className:We("tree-name",(x||t.ignored)&&"row-dim"),children:t.name}),r?d.jsx("span",{className:`xy ${oy(r.xy)}`,children:sy(r.xy)}):o&&d.jsx("span",{className:"dot tree-changed"})]})});function Nj({f:e}){return e.add===void 0&&e.del===void 0?null:d.jsxs("span",{className:"counts",children:[e.add?d.jsxs("span",{className:"add",children:["+",e.add]}):null,e.del?d.jsxs("span",{className:"del",children:["−",e.del]}):null]})}const Of=E.memo(function({f:t,id:n,active:r,selected:o,checking:s=!1,checked:a=!1,onOpen:l,onCheck:u,onRead:f,menu:h,onHover:p,onDragStart:g,onDragEnd:y}){const w=xn("changes"),v=Ep(),x=td("changes"),{name:N,dir:S}=kN(t.path),T=!!f&&!!Wa(t.path)&&!t.xy.includes("D");return d.jsxs("div",{className:"row row-sm git-file row-edge",id:n,"data-state":fr({current:r,cursor:o,checked:a}),role:"option","aria-selected":o,tabIndex:-1,onClick:j=>u&&(s||j.shiftKey)?u(t.path):l(t.path),draggable:v&&!!g,onDragStart:g&&(j=>g(t.path,j)),onDragEnd:y,...w.contextMenu(()=>h(t.path)),onMouseEnter:()=>p(t.path,!0),onMouseLeave:()=>p(t.path,!1),"data-tip":S?t.path:void 0,"data-tip-placement":x,children:[s&&d.jsx("input",{type:"checkbox",className:"changes-check",checked:a,readOnly:!0,tabIndex:-1}),d.jsxs("span",{className:`xy ${oy(t.xy)}`,children:[sy(t.xy),T&&d.jsx(Tt,{icon:"eye",className:"git-file-read",label:"Read this file rendered",placement:x,tabIndex:-1,onClick:j=>{j.stopPropagation(),f(t.path)}})]}),d.jsxs("span",{className:"path",children:[d.jsx("span",{className:"name",children:N}),S&&d.jsx("span",{className:"dir row-dim",children:S})]}),d.jsx(Nj,{f:t})]})}),p1=new Set(["test","tests","__tests__","spec","e2e","__snapshots__","__mocks__","fixtures","testdata"]),A8=/([._-]tests?\.[^.]+$)|([._]specs?\.[^.]+$)|(^tests?[._-])|(^conftest\.py$)|(\.snap$)|([a-z0-9](Tests?|Spec)\.[^.]+$)/;function bh(e){const t=(e.endsWith("/")?e.slice(0,-1):e).split("/"),n=t.pop()??"";return e.endsWith("/")&&p1.has(n.toLowerCase())?!0:t.some(r=>p1.has(r.toLowerCase()))||A8.test(n)}function Qf(e){const t=e.filter(n=>!bh(n.path));return t.length===0||t.length===e.length?{files:e,source:t.length}:{files:[...t,...e.filter(n=>bh(n.path))],source:t.length}}const Mf=[];function I8(e,t){var a,l;const n=Qf((e==null?void 0:e.files)??Mf),r=(a=e==null?void 0:e.extras)==null?void 0:a.turn,o=Qf(r&&t.turn?r.files:Mf),s=Qf(t.committed?((l=e==null?void 0:e.extras)==null?void 0:l.committed)??Mf:Mf);return{files:n.files,fileSource:n.source,turned:o.files,turnedSource:o.source,turnBase:r==null?void 0:r.base,committed:s.files,committedSource:s.source}}const R8={added:"A",changed:"M",removed:"D"},O8={added:"added",changed:"",removed:"deleted"},M8=E.memo(function({tests:t,id:n,cursor:r,onPick:o}){return t.map((s,a)=>d.jsxs("button",{className:"row row-sm changes-test row-rails row-edge",id:`${n}-t${a}`,"data-state":fr({current:r===a,cursor:r===a}),"data-sub":!0,role:"option","aria-selected":r===a,tabIndex:-1,onClick:()=>o(a),"data-tip":[...s.group,s.name].join(" · "),"data-tip-placement":"follow",children:[d.jsx("span",{className:`xy ${O8[s.change]}`,children:R8[s.change]}),d.jsx("span",{className:"name",children:s.name})]},a))}),Uk="(?<q>[\"'`])(?<name>(?:\\\\.|(?!\\k<q>).)*)\\k<q>",m1={tests:[new RegExp(`^\\s*(?:test|it)(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Uk}`)],groups:[new RegExp(`^\\s*describe(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Uk}`)]},L8={js:m1,py:{tests:[/^\s*(?:async\s+)?def\s+(?<name>test\w*)\s*\(/],groups:[/^\s*class\s+(?<name>Test\w*)/]},go:{tests:[/^func\s+(?<name>(?:Test|Benchmark|Fuzz|Example)\w*)\s*\(/,/^\s+\w+\.Run\(\s*"(?<name>(?:\\.|[^"\\])*)"/]},rs:{mark:/^\s*#\[(?:\w+::)*(?:test|rstest|test_case)\b/,tests:[/\bfn\s+(?<name>\w+)/]},jvm:{mark:/^\s*@(?:Test|ParameterizedTest|RepeatedTest|TestFactory)\b/,tests:[/\b(?:void|fun)\s+(?<name>`[^`]+`|\w+)\s*\(/]},cs:{mark:/^\s*\[(?:Test|TestCase|Fact|Theory|TestMethod)\b/,tests:[/\b(?:void|Task)\s+(?<name>\w+)\s*\(/]},rb:{tests:[new RegExp(`^\\s*(?:it|specify|test|scenario)\\s*\\(?\\s*${Uk}`),/^\s*def\s+(?<name>test_\w+)/],groups:[/^\s*(?:RSpec\.)?(?:describe|context|feature)\s*\(?\s*(?<name>"[^"]*"|'[^']*'|[\w:]+)/]},exs:{tests:[/^\s*test\s+"(?<name>(?:\\.|[^"\\])*)"/],groups:[/^\s*describe\s+"(?<name>(?:\\.|[^"\\])*)"/]},swift:{tests:[/^\s*(?:@Test\s+)?func\s+(?<name>test\w*)\s*\(/]},php:{tests:[/\bfunction\s+(?<name>test\w*)\s*\(/,...m1.tests]}},P8={js:"js",jsx:"js",mjs:"js",cjs:"js",ts:"js",tsx:"js",mts:"js",cts:"js",py:"py",go:"go",rs:"rs",java:"jvm",kt:"jvm",cs:"cs",rb:"rb",exs:"exs",swift:"swift",php:"php"},D8=3,z8=/^\s*(?:[)}\]]|end\b)/,Rg=e=>e.length-e.trimStart().length;function g1(e,t){var n,r;for(const o of t??[]){const s=(r=(n=o.exec(e))==null?void 0:n.groups)==null?void 0:r.name;if(s!==void 0)return s.replace(/^(["'`])(.*)\1$/,"$2")}return null}function k1(e,t){const n=t.split(`
125
- `),r=[],o=[];let s=Number.NEGATIVE_INFINITY;return n.forEach((a,l)=>{var g,y,w;if(a.trim()==="")return;const u=Rg(a);for(;o.length>0&&(((g=o.at(-1))==null?void 0:g.indent)??0)>=u;)o.pop();(y=e.mark)!=null&&y.test(a)&&(s=l);const h=!e.mark||l-s<=D8?g1(a,e.tests):null,p=h??g1(a,e.groups);if(p!==null){if(h!==null){s=Number.NEGATIVE_INFINITY;let v=l+1;for(;v<n.length&&(((w=n[v])==null?void 0:w.trim())===""||Rg(n[v]??"")>u);)v++;v<n.length&&Rg(n[v]??"")===u&&z8.test(n[v]??"")&&v++;const x=n.slice(l,v).map(N=>N.trim()).join(`
126
- `).trim();r.push({group:o.map(N=>N.name),name:p,line:l,end:v,body:x})}o.push({indent:u,name:p})}}),r}function w1(e){const t=new Map;for(const n of e){const r=[...n.group,n.name].join(`
127
- `);let o=0;for(;t.has(`${r}
128
- ${o}`);)o++;t.set(`${r}
129
- ${o}`,n)}return t}function F8(e,t,n){const r=L8[P8[e.slice(e.lastIndexOf(".")+1).toLowerCase()]??""];if(!r)return[];const o=w1(k1(r,t)),s=w1(k1(r,n)),a=[];for(const[h,p]of s){const g=o.get(h);(g==null?void 0:g.body)!==p.body&&a.push({name:p.name,group:p.group,change:g?"changed":"added",line:p.line+1})}const l=n.split(`
130
- `).length;let u=1;for(const[h,p]of o){const g=s.get(h);g?u=Math.min(g.end+1,l):a.push({name:p.name,group:p.group,change:"removed",line:u})}const f=h=>h.change==="removed"?0:1;return a.sort((h,p)=>h.line-p.line||f(h)-f(p))}const B8=[];function U8(e,t,n,r){const o=t?n>0?"no changes of its own":`same as ${e}`:"no changes";if(!r)return o;const s=dr(r.at);return`${o}, last commit ${s==="now"?"just now":`${s} ago`}`}const y1='[role="option"]:not([data-sub])',v1=[];function Tj({width:e,placement:t="dock"}){var Ro,$r;const n=t==="screen",r=nt(),o=ht(),s=Pn(),a=fl(),l=Ga(),u=(l==null?void 0:l.id)??a,f=Vs(),h=L(G=>G.layout.changes),p=Ju(),g=L(G=>G.focusChanges),y=Rt(u,"git"),w=L(G=>G.editor&&G.editor.worktreeId===u?G.editor.path:null),v=L(G=>G.editor&&G.editor.worktreeId===u?G.editor.ref??null:null),x=L(G=>G.editor&&G.editor.worktreeId===u?G.editor.since??null:null),N=L(G=>G.editor&&G.editor.worktreeId===u?G.editor.view:null),S=L(G=>!!G.editor&&G.editor.worktreeId===u&&G.editor.marks),T=(((Ro=y==null?void 0:y.extras)==null?void 0:Ro.committed)??B8).length>0,j=y6(),$=($r=y==null?void 0:y.extras)==null?void 0:$r.turn,R=v6(),A=E.useMemo(()=>I8(y,{turn:R,committed:j}),[y,R,j]),{files:I,fileSource:M,turned:P,turnedSource:F,turnBase:q,committed:W,committedSource:ee}=A,V=I.length,te=I.length+P.length,K=L(G=>G.editor&&G.editor.worktreeId===u?G.editor.disk:null),C=E.useMemo(()=>w!==null&&K&&bh(w)?F8(w,K.before,K.after):v1,[w,K]),[oe,U]=E.useState(!1);ct([w,v,x],()=>U(!1));const B=M>0?I.length-M:0,Q=ee>0?W.length-ee:0,ue=F>0?P.length-F:0,he=I.length===0,Ne=E.useMemo(()=>{if(I.length===0)return;const G=I.reduce((He,bn)=>He+(bn.add??0),0),me=I.reduce((He,bn)=>He+(bn.del??0),0),Je=[G>0&&`+${G}`,me>0&&`−${me}`].filter(Boolean).join(" "),Ve=`${I.length} uncommitted ${I.length===1?"file":"files"}`;return Je?`${Ve}, ${Je}`:Ve},[I]),De=!!y&&he&&(y.ahead??0)===0,Be=L(tl),Z=l!==null||Be==="changes",J=l!==null||Be==="history",pe=E.useCallback(G=>o({a:"changes-tab",v:G}),[o]),de=E.useRef(Be);de.current=Be;const ie=E.useRef(null),ye=by(),_e=L(G=>{const me=bs(G,ye==null?void 0:ye.repoId);return me?Vh(me):"main"}),be=Rt(u,"commits"),$e=Rt(u,"commitFiles"),[Ze,rt]=E.useState(null),en=E.useRef(null);en.current=Ze;const Xt=E.useRef(null),Et=Rt(u,"changedRanges"),Ke=E.useCallback((G,me)=>{if(!u||l)return;if(!me){Xt.current=null,fn.post(u,{type:"highlight-clear"});return}Xt.current=G;const Je=Et[G];Je?fn.post(u,{type:"highlight-file",path:G,ranges:Ax(Je)}):r==null||r.send({t:"changed-ranges",worktreeId:u,path:G})},[u,l,Et,r]);E.useEffect(()=>{const G=Xt.current;if(!G||!u)return;const me=Et[G];me&&fn.post(u,{type:"highlight-file",path:G,ranges:Ax(me)})},[Et,u]);const Qt=l&&I.length>0?(y==null?void 0:y.head)??null:null,Ot=E.useCallback((G,me=!1,Je,Ve)=>u&&Rn({dispatch:o},{worktreeId:u,path:G,focus:me,ref:Qt??void 0,since:Je,...Ve?{view:Ve,picked:!0}:{}}),[u,Qt,r,o]),Zt=E.useMemo(()=>l?I:[...I,...P,...W],[l,I,P,W]),Ge=E.useMemo(()=>{const G=[];for(const me of be??[])if(G.push({commit:me}),me.sha===Ze)for(const Je of Qf($e[me.sha]??[]).files)G.push({commit:me,file:Je});return G},[be,Ze,$e]),nn=E.useMemo(()=>Ge.filter(G=>!G.file&&G.commit.ahead).length,[Ge]),pn=E.useMemo(()=>Ge.findIndex(G=>!G.file&&!G.commit.ahead),[Ge]),It=l?Zt.length:0,gt=(Z?Zt.length:0)+(J?Ge.length:0),Vt=E.useMemo(()=>{const G=new Map;if(!l||I.length===0&&Ge.every(Je=>Je.commit.landedAt))return G;let me;return Ge.forEach((Je,Ve)=>{const He=!!Je.commit.landedAt;He!==me&&(me=He,G.set(Ve,He?"landed":"not landed"))}),G},[l,I,Ge]),Cn=E.useRef(null),[{row:Ce,at:Pt},Dt]=E.useReducer((G,me)=>typeof me=="number"?{row:me,at:-1}:me,{row:0,at:-1}),[Wt,Dn]=E.useState(!1),ne=(G,me)=>Wt?mn(G):me,we=G=>`changes-row-${G}`,[Ye,ot]=E.useState(!1),[zt,Kt]=E.useState([]),D=E.useCallback(()=>{ot(!1),Kt([])},[]),se=E.useCallback(G=>{ot(!0),Kt(me=>me.includes(G)?me.filter(Je=>Je!==G):[...me,G])},[]),Se=E.useMemo(()=>I.filter(G=>zt.includes(G.path)).map(G=>G.path),[I,zt]);ct([I],()=>Kt(G=>{const me=G.filter(Je=>I.some(Ve=>Ve.path===Je));return me.length===G.length?G:me})),ct([Ye],()=>{if(!Ye)return;const G=me=>me.key==="Escape"&&D();return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)}),ct([u,Be],()=>{Dt(0),D()});const ze=y==null?void 0:y.head,Ut=E.useRef("");E.useEffect(()=>{if(!(J||De)||!u)return;const G=`${u}:${ze??""}`;Ut.current!==G&&(Ut.current=G,r==null||r.send({t:"git-log",worktreeId:u}))},[J,De,u,ze,r]);const qt=E.useCallback(G=>{rt(me=>me===G?null:G),u&&!$e[G]&&(r==null||r.send({t:"git-commit",worktreeId:u,sha:G}))},[u,$e,r]);ct([Ce,Pt,Wt],()=>{var G,me;Wt&&((me=(G=Cn.current)==null?void 0:G.querySelector('[data-state~="cursor"]'))==null||me.scrollIntoView({block:"nearest"}))});const Oe=E.useRef(-1),Fe=G=>G>=V&&G<te?q:void 0,et=G=>{var me;return((me=Zt[G])==null?void 0:me.path)===w&&(x??void 0)===Fe(G)&&(G<V?v===Qt:!v)};Oe.current=Z?Zt.findIndex((G,me)=>et(me)):-1,E.useEffect(()=>{if(!g)return;const G=de.current==="files";Oe.current>=0&&Dt(Oe.current);const me=requestAnimationFrame(()=>{var Je;return(Je=(G?ie:Cn).current)==null?void 0:Je.focus()});return()=>cancelAnimationFrame(me)},[g]);const Ft=E.useCallback((G,me=!1)=>{const Je=Zt[G];Je&&(Dt(G),Ot(Je.path,me,G>=V&&G<te?q:void 0),Ke(Je.path,!0))},[Zt,Ot,Ke,V,te,q]),jt=E.useCallback((G,me=!1,Je)=>{const Ve=en.current;u&&Ve&&Rn({dispatch:o},{worktreeId:u,path:G,ref:Ve,focus:me,...Je?{view:Je,picked:!0}:{}})},[u,r,o]),On=E.useCallback(G=>{const me=Ge[G-It];me&&(Dt(G),me.file&&jt(me.file.path))},[Ge,It,jt]),Mn=E.useCallback(G=>{const me=Ge[G-It];me&&(Dt(G),me.file?jt(me.file.path,!0):qt(me.commit.sha))},[Ge,It,jt,qt]),yn=G=>J&&G>=It,tn=G=>{if(w===null)return!1;if(Z&&G<Zt.length)return et(G);const me=yn(G)?Ge[G-It]:void 0;return!!(me!=null&&me.file)&&v===me.commit.sha&&me.file.path===w},_n=G=>tn(G)&&!oe?C:v1,Mt=Pt<_n(Ce).length?Pt:-1,mn=G=>Wt&&Ce===G&&Mt<0,rr=()=>{var me,Je;const G=[];for(let Ve=0;Ve<gt;Ve++){const He=yn(Ve)?Ge[Ve-It]:void 0,bn=He?(me=He.file)==null?void 0:me.path:(Je=Zt[Ve])==null?void 0:Je.path,an=He!=null&&He.file?1:0,cn=_n(Ve);He&&!He.file?G.push({row:Ve,at:-1,depth:an,open:He.commit.sha===Ze}):bn!==void 0&&bh(bn)?G.push({row:Ve,at:-1,depth:an,open:cn.length>0}):G.push({row:Ve,at:-1,depth:an});for(let sr=0;sr<cn.length;sr++)G.push({row:Ve,at:sr,depth:an+1})}return G},Ct=(G,me=!1)=>{const Je=C[G];!Je||!u||w===null||Rn({dispatch:o},{worktreeId:u,path:w,ref:v??void 0,since:x??void 0,line:{n:Je.line},focus:me})},le=G=>_n(G).length>0&&d.jsx(M8,{tests:C,id:we(G),cursor:Wt&&Ce===G?Mt:-1,onPick:me=>{Dt({row:G,at:me}),Ct(me)}}),qe=G=>{var me;if(Ye&&G.key==="Escape")G.preventDefault(),G.stopPropagation(),D();else if(Ye&&G.key===" "){G.preventDefault();const Je=Z&&Ce<I.length?I[Ce]:void 0;Je&&se(Je.path)}else if(G.key==="ArrowDown"&&Mt+1<_n(Ce).length)G.preventDefault(),Dt({row:Ce,at:Mt+1}),Ct(Mt+1);else if(G.key==="ArrowUp"&&Mt>=0)G.preventDefault(),Mt===0?Dt(Ce):(Dt({row:Ce,at:Mt-1}),Ct(Mt-1));else if(G.key==="Enter"&&Mt>=0)G.preventDefault(),Ct(Mt,!0);else if(G.key==="ArrowDown"||G.key==="ArrowUp"){G.preventDefault();const Je=rd(Ce,G.key==="ArrowDown"?1:-1,gt);yn(Je)?On(Je):Ft(Je)}else if(G.key==="Enter")G.preventDefault(),yn(Ce)?Mn(Ce):Ft(Ce,!0);else if(G.key==="ArrowRight"||G.key==="ArrowLeft"){G.preventDefault();const Je=rr(),Ve=xp(Je,Je.findIndex(an=>an.row===Ce&&an.at===Mt),G.key),He=Ve&&Je[Ve.at];if(!Ve||!He)return;const bn=yn(He.row)?Ge[He.row-It]:void 0;Ve.do==="to"?He.at>=0?(Dt({row:He.row,at:He.at}),Ct(He.at)):bn!=null&&bn.file&&He.row>Ce?On(He.row):Dt(He.row):bn&&!bn.file?qt(bn.commit.sha):Ve.do==="close"?U(!0):tn(He.row)?U(!1):bn!=null&&bn.file?On(He.row):Ft(He.row)}else G.key==="Escape"&&(G.stopPropagation(),w!==null?o({a:"close-editor"}):(me=document.activeElement)==null||me.blur())},Xe=l?l.id:f==null?void 0:f.worktree.id,pt=l?l.path:f?f.worktree.path:"",wt=l!==null,En=E.useMemo(()=>Xe?(G,me)=>Pu(me,{kind:"paths",worktreeId:Xe,items:[{path:G,folder:!1}]}):void 0,[Xe]),Lr=E.useRef(Se);Lr.current=Se;const un=E.useMemo(()=>Xe?(G,me)=>{const Je=Lr.current;if(!Je.includes(G))return En==null?void 0:En(G,me);Pu(me,{kind:"paths",worktreeId:Xe,items:Je.map(Ve=>({path:Ve,folder:!1}))})}:void 0,[Xe,En]),vr=E.useCallback(()=>od(s),[s]),Qn=E.useCallback(G=>Xe?Hs({id:Xe,dir:pt},G,{discard:!wt,kept:wt,ref:Qt??void 0,select:wt?void 0:se},{sock:r,dispatch:o}):[],[Xe,pt,wt,Qt,se,r,o]),Bt=E.useCallback(G=>Xe?Hs({id:Xe,dir:pt},G,{kept:wt},{sock:r,dispatch:o}):[],[Xe,pt,wt,r,o]),dn=E.useCallback(G=>Xe?Hs({id:Xe,dir:pt},G,{kept:wt,since:q},{sock:r,dispatch:o}):[],[Xe,pt,wt,q,r,o]),ve=E.useCallback(G=>Xe?Hs({id:Xe,dir:pt},G,{ref:en.current??void 0,kept:wt},{sock:r,dispatch:o}):[],[Xe,pt,wt,r,o]),Le=xn("changes"),At=()=>{if(Z&&Ce<Zt.length){const me=Zt[Ce];return me?(Ce<V?Qn:Ce<te?dn:Bt)(me.path):[]}const G=yn(Ce)?Ge[Ce-It]:void 0;return G?G.file?ve(G.file.path):oj(G.commit):[]},yt=E.useCallback(()=>{if(N!=="preview"||!K||w===null)return!1;const G=K.before===""||K.before===K.after;return Wa(w)==="markdown"?G||S?!1:(o({a:"editor-marks",v:!0}),!0):(o({a:"editor-view",v:G?"file":"diff"}),!0)},[N,S,K,w,o]),rn=(G,me,Je)=>{const Ve=Zt.findIndex((He,bn)=>bn>=G&&He.path===me);Dt(Ve),!(!Je&&et(Ve)&&yt())&&(!Je&&et(Ve)&&C.length>0?U(He=>!He):Ot(me,!1,Fe(Ve),Je))},Gt=E.useRef(rn);Gt.current=rn;const Jn=E.useCallback(G=>Gt.current(0,G),[]),Zr=E.useCallback(G=>Gt.current(V,G),[V]),hn=E.useCallback(G=>Gt.current(te,G),[te]),Yt=E.useCallback(G=>Gt.current(0,G,"preview"),[]),zn=E.useCallback(G=>Gt.current(V,G,"preview"),[V]),or=E.useCallback(G=>Gt.current(te,G,"preview"),[te]),br=E.useCallback(G=>{Dt(It+Ge.findIndex(me=>!me.file&&me.commit.sha===G)),qt(G)},[Ge,It,qt]),pr=E.useCallback(G=>{Dt(It+Ge.findIndex(Je=>{var Ve;return((Ve=Je.file)==null?void 0:Ve.path)===G}));const me=G===w&&v===en.current;me&&yt()||(me&&C.length>0?U(Je=>!Je):jt(G))},[Ge,It,jt,w,v,C,yt]),Gr=E.useCallback(G=>{Dt(It+Ge.findIndex(me=>{var Je;return((Je=me.file)==null?void 0:Je.path)===G})),jt(G,!1,"preview")},[Ge,It,jt]),ro=E.useCallback(()=>{},[]);return d.jsxs("div",{className:We("changes-dock",n&&"changes-screen",!n&&(!h||p)&&"collapsed"),style:n?void 0:{width:e},children:[!l&&d.jsx(Ya,{fill:!n,quiet:n,owner:"changes-tabs",label:"changes panel",items:[{id:"files",label:d.jsx(xt,{name:"folder",className:"icon-inline"}),fit:!0,ariaLabel:"files",tip:Nt("files",Ht("files"))},{id:"changes",label:"changes",tip:Nt("changes",Ht("changes"),{detail:Ne})},{id:"history",label:"history"}],current:Be,onPick:pe}),Be==="files"&&u?d.jsx(T8,{worktreeId:u,dir:f?f.worktree.path:(ye==null?void 0:ye.path)??"",openPath:w,openRef:v,rootRef:ie}):d.jsxs("div",{className:We("changes-list",J&&"history"),role:"listbox","aria-label":l?"kept work":J?"commits":"changed files","aria-activedescendant":Wt&&Ce>=0&&Ce<gt?Mt<0?we(Ce):`${we(Ce)}-t${Mt}`:void 0,tabIndex:0,ref:Cn,onKeyDown:qe,onFocus:()=>Dn(!0),onMouseDown:G=>{var Ve;if(G.button!==0)return;G.preventDefault();const me=G.target.closest(y1),Je=me?Array.from(G.currentTarget.querySelectorAll(y1)).indexOf(me):-1;Je>=0&&Dt(Je),(Ve=Cn.current)==null||Ve.focus()},onBlur:G=>!G.currentTarget.contains(G.relatedTarget)&&Dn(!1),...Le.contextMenu(G=>G==="keyboard"?At():[]),children:[Z&&I.length>0&&d.jsxs(d.Fragment,{children:[(T||((y==null?void 0:y.ahead)??0)>0||l)&&d.jsx("div",{className:"section-title section-row",children:"uncommitted"}),I.map((G,me)=>d.jsxs(E.Fragment,{children:[B>0&&me===M&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(Of,{f:G,id:we(me),active:ne(me,tn(me)),selected:mn(me),checking:Ye,checked:zt.includes(G.path),onOpen:Jn,onCheck:wt?void 0:se,onRead:Yt,menu:Qn,onHover:Ke,onDragStart:un,onDragEnd:vr}),le(me)]},`${G.xy}:${G.path}`))]}),Z&&!l&&$&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":R,"data-tip":"What changed since your last message","data-tip-placement":"follow",onClick:()=>o({a:"toggle-turn"}),onKeyDown:G=>(G.key==="Enter"||G.key===" ")&&G.stopPropagation(),children:["last turn",d.jsx(xt,{name:"caret",className:We("icon-inline disc-caret",!R&&"shut")})]}),P.map((G,me)=>d.jsxs(E.Fragment,{children:[ue>0&&me===F&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(Of,{f:G,id:we(V+me),active:ne(V+me,tn(V+me)),selected:mn(V+me),onOpen:Zr,onRead:zn,menu:dn,onHover:Ke,onDragStart:En,onDragEnd:vr}),le(V+me)]},`t-${G.path}`))]}),Z&&!l&&T&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":j,"data-tip":`Committed on this branch, not yet on ${_e}`,"data-tip-placement":"follow",onClick:()=>o({a:"toggle-committed"}),onKeyDown:G=>(G.key==="Enter"||G.key===" ")&&G.stopPropagation(),children:["committed",d.jsx(xt,{name:"caret",className:We("icon-inline disc-caret",!j&&"shut")})]}),W.map((G,me)=>d.jsxs(E.Fragment,{children:[Q>0&&me===ee&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(Of,{f:G,id:we(te+me),active:ne(te+me,tn(te+me)),selected:mn(te+me),onOpen:hn,onRead:or,menu:Bt,onHover:Ke,onDragStart:En,onDragEnd:vr}),le(te+me)]},`c-${G.path}`))]}),Z&&!l&&De&&d.jsx("div",{className:"empty",children:U8(_e,!!ye&&qh(ye),(y==null?void 0:y.behind)??0,be==null?void 0:be[0])}),J&&Ge.map((G,me)=>d.jsxs(E.Fragment,{children:[l&&Vt.has(me)&&d.jsx("div",{className:"section-title section-row",children:Vt.get(me)}),!l&&nn>0&&me===0&&d.jsx("div",{className:"section-title section-row",children:"on this branch"}),!l&&nn>0&&me===pn&&d.jsx("div",{className:"section-title section-row",children:_e}),G.file?d.jsxs(d.Fragment,{children:[d.jsx(Of,{f:G.file,id:we(It+me),active:ne(It+me,tn(It+me)),selected:mn(It+me),onOpen:pr,onRead:Gr,menu:ve,onHover:ro,onDragStart:En,onDragEnd:vr}),le(It+me)]}):d.jsx(x8,{c:G.commit,id:we(It+me),selected:mn(It+me),onToggle:br})]},G.file?`${G.commit.sha}:${G.file.path}`:G.commit.sha)),J&&be===void 0&&d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"reading history"})}),J&&(be==null?void 0:be.length)===0&&I.length===0&&d.jsx("div",{className:"empty",children:"no commits yet"})]}),Ye&&d.jsxs("div",{className:"changes-pick",children:[d.jsxs(Me,{size:"md",tone:"danger",disabled:Se.length===0,"data-tip":"Throw away the uncommitted changes to every checked file",onClick:()=>{!Xe||Se.length===0||window.confirm(vT(Se))&&(r==null||r.send({t:"discard-files",worktreeId:Xe,paths:Se}),D())},children:["discard ",Se.length,"…"]}),d.jsx(Me,{size:"md",disabled:Se.length===0,"data-tip":"Name every checked file in the chat",onClick:()=>{Xe&&o5(s,Xe,Se),D()},children:"add to chat"}),d.jsx(Tt,{icon:"close",label:"Cancel",hint:"esc",onClick:D})]}),ye&&!l&&d.jsx(b8,{active:ye,ahead:(y==null?void 0:y.ahead)??ye.ahead??0,behind:(y==null?void 0:y.behind)??ye.behind??0,unpushed:(y==null?void 0:y.unpushed)??ye.unpushed??0,dirty:!he})]})}function H8(e){var t;if((e==null?void 0:e.kind)==="account")return[(t=e.account)==null?void 0:t.email,e.label].filter(Boolean).join(" · ")}function b1(e){if(e<1e3)return String(Math.round(e));const t=e/1e3;return`${t<10?t.toFixed(1).replace(/\.0$/,""):Math.round(t)}k`}function sd(e){return e>0&&e<.005?"<$0.01":`$${e.toFixed(2)}`}function W8(e){const t=`${Math.round(100*e)}% full`;return e<.5?`${t}: plenty of room, no need yet`:e<.8?`${t}: worth doing between tasks`:`${t}: do it before the next task`}function K8(e){if(!(e<.5))return e<.8?"worth compacting between tasks":"compact before the next task"}const jj=["five_hour","seven_day","seven_day_overage_included"],q8={five_hour:"the 5-hour window",seven_day:"the week",seven_day_overage_included:"the Fable week"},Z8={five_hour:"5-hour",seven_day:"this week",seven_day_overage_included:"Fable week"};function $j(e,t){return jj.flatMap(n=>{const r=e.windows[n];return r&&r.resetsAt>t?[{key:n,used:r.used,resetsAt:r.resetsAt}]:[]})}function G8(e,t){return Math.min(1,Math.max(0,...$j(e,t).map(n=>n.used)))}const V8=e=>`${Math.round(100*e)}%`;function x1(e,t){const n=$j(e,t).map(r=>`${V8(r.used)} of ${q8[r.key]}`);return n.length?n.join(", "):"plan windows reset"}function Y8(e,t,n){const r=new Date(e),o=new Date(t),s=r.toDateString()===o.toDateString();return new Intl.DateTimeFormat(n,{...s?{}:{month:"short",day:"numeric"},hour:"numeric",minute:"2-digit"}).format(r)}function X8(e,t,n=r=>Y8(r,t)){return jj.flatMap(r=>{const o=e.windows[r];if(!o)return[];const s=Z8[r];if(o.resetsAt<=t)return[{key:r,name:s,used:0,sub:`reset ${n(o.resetsAt)}, read again on the next reply`}];const a=e.binding===r&&e.status==="rejected"?", out until then":"";return[{key:r,name:s,used:o.used,sub:`resets ${n(o.resetsAt)}${a}`}]})}function Q8(e){const t=e.auto?"Auto archived":"Archived",n=e.auto?"Merged, auto archived":"Merged",r=e.landed?n:e.uncommitted?`${t} with uncommitted changes`:t;return e.restorable?r:`${r}, commits not kept`}function Cj(e){const t=[e.landed?"merged":e.uncommitted?"uncommitted changes":null];return e.restorable||t.push("commits not kept"),e.cost!==void 0&&t.push(sd(e.cost)),t.push(dr(e.archivedAt)),t.filter(Boolean).join(" · ")}function Aj({sock:e},t,n){e==null||e.send({t:"restore-worktree",archiveId:t,clientId:n})}function Jf(e,t,{sock:n,dispatch:r}){const o=[{id:"restore",label:"restore",disabled:e.restorable?void 0:"its commits were not kept",onClick:()=>{Aj({sock:n},e.id,t.clientId),r({a:"close"})}}],s=[{id:"copy-branch",label:"copy branch name",onClick:()=>sn(e.branch)}];s.push(...Ko(()=>n==null?void 0:n.send({t:"reveal-transcript",worktreeId:e.id}),wo(n),"reveal transcript in Finder"));const{sessionId:a}=e;return t.frame!=="phone"&&a&&s.push({id:"copy-session",label:"copy session id",onClick:()=>sn(a)}),Un([o,s,[{id:"delete",label:"delete…",danger:!0,onClick:()=>{window.confirm(`Delete "${e.title}"?
131
-
132
- Its chat, attachments and kept commits go with it, and it cannot be restored.`)&&(n==null||n.send({t:"delete-archived",archiveId:e.id}))}}]])}const J8=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function Ij(e){const[t,n]=E.useState(()=>Date.now());return E.useEffect(()=>{const r=setInterval(()=>n(Date.now()),6e4);return()=>clearInterval(r)},[]),`${cy(t-e)} ago`}function ar({icon:e,word:t,tone:n,at:r,below:o,under:s,children:a,...l}){const u=r!==void 0?{"data-tip":`${t} ${J8.format(r)}`,"data-tip-placement":"top"}:null,f=(Array.isArray(o)?o:[o]).filter(h=>h!=null&&h!==!1);return d.jsx("div",{...l,className:"daemon-row row-edge","data-tone":n,children:d.jsxs("div",{className:"daemon-head",children:[d.jsxs("span",{...u,className:"daemon-tag",children:[d.jsx(xt,{name:e,className:"icon-inline"}),t]}),d.jsxs("div",{className:"daemon-body",children:[d.jsx("div",{className:"daemon-line",children:a}),f.map((h,p)=>d.jsx("div",{className:"daemon-below row-dim",children:h},p)),s]})]})})}function e9({item:e}){const t=nt(),n=L(u=>u.clientId),r=e.uncommitted?"its chat, commits and uncommitted changes":"its chat and commits",o=e.cost!==void 0?`; the session cost ${sd(e.cost)}`:"",s=e.restorable?`Toyon kept ${r}${o}. A message sent below restores it first.`:`Its commits were not kept, so there is nothing to restore${o}; its row's menu on the rail can delete it.`,a=Ij(e.archivedAt),l=zy(e.lands);return d.jsxs(ar,{icon:"archive",word:"archived",tone:"quiet",at:e.archivedAt,below:[...l,s],children:[d.jsxs("span",{className:"daemon-text",children:[a,e.landed?", after it was merged into main":""]}),e.restorable&&d.jsx(Me,{variant:"inline",tone:"strong",onClick:()=>Aj({sock:t},e.id,n),children:"restore"})]})}function Ma(e,t,n,r,o){const{layout:s}=e.getState();Rn({dispatch:e.dispatch},{worktreeId:n,path:r,view:"file",line:{n:o,fiber:!0}}),s.changes||e.dispatch({a:"toggle-changes"})}function t9(e){let t=0;return e.map(n=>{const r={start:t,len:n};return t+=n,r})}function n9(e,t){if(!t)return[];const n=new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"giu"),r=[];for(const o of e.matchAll(n))r.push({start:o.index,end:o.index+o[0].length});return r}function E1(e,t,n){let r=0,o=e.length-1;for(;r<o;){const a=r+o>>1,l=e[a];(n?t>l.start+l.len:t>=l.start+l.len)?r=a+1:o=a}const s=e[r];return{i:r,at:t-s.start}}function r9(e,t){return{from:E1(e,t.start,!1),to:E1(e,t.end,!0)}}function S1(e,t){if(e.length===0)return-1;const n=e.findIndex(r=>r.start>=t);return n===-1?0:n}function o9(e,t,n){return t===0?-1:(e+n+t)%t}function Wy(e){return e.key==="f"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function s9({label:e,query:t,onQuery:n,seed:r,seq:o,status:s,none:a,onStep:l,onClose:u}){const f=E.useRef(null);return ct([o],()=>{var h,p;r&&n(r),(h=f.current)==null||h.focus(),(p=f.current)==null||p.select()}),d.jsxs("div",{className:"find",children:[d.jsx(Ho,{ref:f,autoFocus:!0,value:t,onChange:h=>n(h.target.value),placeholder:"find…","aria-label":e,className:"find-field",spellCheck:!1,onKeyDown:h=>{if(h.key==="Escape"){h.preventDefault(),h.stopPropagation(),u();return}if(h.key==="Enter"){h.preventDefault(),l(h.shiftKey?-1:1);return}if(Wy(h)){h.preventDefault(),h.stopPropagation(),h.currentTarget.select();return}h.key.toLowerCase()==="g"&&(h.metaKey||h.ctrlKey)&&!h.altKey&&(h.preventDefault(),h.stopPropagation(),l(h.shiftKey?-1:1))}}),d.jsx("span",{className:"find-count","aria-live":"polite",children:s}),d.jsx(Tt,{icon:"caret",label:"Previous match",hint:"⇧↩",className:"find-prev",disabled:a,onClick:()=>l(-1)}),d.jsx(Tt,{icon:"caret",label:"Next match",hint:"↩",disabled:a,onClick:()=>l(1)}),d.jsx(Tt,{icon:"close",label:"Close",hint:"esc",onClick:u})]})}const Rj="find",Oj="find-current",Mj=typeof CSS<"u"&&"highlights"in CSS;function i9(e){const t=e.parentElement;return t?typeof t.checkVisibility=="function"?t.checkVisibility():!0:!1}function a9(e,t){const n=e instanceof Element?e:e.parentElement;return!!(n!=null&&n.closest(t))}function c9(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,o=>o instanceof Element?t&&o.matches(t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT),r=[];for(let o=n.nextNode();o;o=n.nextNode()){const s=o;s.data.length>0&&i9(s)&&r.push(s)}return r}const Hk={matches:[],ranges:[]};function l9(e,t,n){if(!t)return Hk;const r=c9(e,n),o=n9(r.map(l=>l.data).join(""),t),s=t9(r.map(l=>l.data.length)),a=o.map(l=>{const{from:u,to:f}=r9(s,l),h=document.createRange();return h.setStart(r[u.i],u.at),h.setEnd(r[f.i],f.at),h});return{matches:o,ranges:a}}function u9(e,t){Mj&&(CSS.highlights.set(Rj,new Highlight(...e.filter((n,r)=>r!==t))),CSS.highlights.set(Oj,new Highlight(...e[t]?[e[t]]:[])))}function d9(){Mj&&(CSS.highlights.delete(Rj),CSS.highlights.delete(Oj))}function f9(e,t){if(e.length===0)return-1;const n=t.getBoundingClientRect().top,r=e.findIndex(o=>o.getBoundingClientRect().bottom>=n);return r===-1?0:r}const _1=48;function h9(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=parseFloat(getComputedStyle(e).getPropertyValue("--scroll-foot"))||0;n.top>=r.top+_1&&n.bottom<=r.bottom-o-_1||(e.scrollTop+=n.top-r.top-r.height/3)}function Lj({root:e,body:t,seed:n,seq:r,onClose:o,onReveal:s,skip:a}){const[l,u]=E.useState(n),[f,h]=E.useState(Hk),[p,g]=E.useState(-1),y=E.useRef({found:Hk,at:-1}),w=E.useRef(""),v=E.useRef(!1),[x,N]=E.useState(0);E.useLayoutEffect(()=>{const $=t.current;if(!$)return;let R=0;const A=new MutationObserver(I=>{a&&I.every(M=>a9(M.target,a))||R||(R=requestAnimationFrame(()=>{R=0,N(M=>M+1)}))});return A.observe($,{childList:!0,characterData:!0,subtree:!0,attributes:!0}),()=>{A.disconnect(),R&&cancelAnimationFrame(R)}},[t,a]),E.useLayoutEffect(()=>{const $=t.current;if(!$)return;const R=l9($,l,a),A=l!==w.current;w.current=l,A&&(v.current=!0);const{found:I,at:M}=y.current;let P;A?I.matches[M]?P=S1(R.matches,I.matches[M].start):P=e.current?f9(R.ranges,e.current):S1(R.matches,0):P=Math.min(M,R.matches.length-1),y.current={found:R,at:P},h(R),g(P)},[l,x,a]),E.useLayoutEffect(()=>{u9(f.ranges,p);const $=f.ranges[p];$&&(v.current&&e.current&&(h9(e.current,$),s==null||s()),v.current=!1)},[f,p,e,s]),E.useLayoutEffect(()=>d9,[]);const S=f.matches.length,T=$=>{if(S===0)return;v.current=!0;const R=o9(y.current.at,S,$);y.current={...y.current,at:R},g(R)},j=()=>o(f.ranges[p]??null);return d.jsx(s9,{label:"find in this document",query:l,onQuery:u,seed:n,seq:r,status:l?S===0?"no matches":`${p+1}/${S}`:"",none:S===0,onStep:T,onClose:j})}function Pj(e){return e.key==="a"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function Dj(e,t,n,r,o){E.useEffect(()=>{let s=!1;const a=u=>{const f=u.target instanceof Element?u.target:null;s=!!e.current&&!!f&&e.current.contains(f)&&!(o&&f.closest(o))},l=u=>{const f=e.current;if(!f||u.defaultPrevented||!t(u))return;const h=document.activeElement;o&&(h!=null&&h.closest(o))||!(h&&h!==document.body?f.contains(h):s)&&!(r!=null&&r(h))||(u.preventDefault(),n(f,u))};return window.addEventListener("pointerdown",a,!0),window.addEventListener("keydown",l),()=>{window.removeEventListener("pointerdown",a,!0),window.removeEventListener("keydown",l)}},[e,t,n,r,o])}function p9(e,t){const n=E.useCallback(r=>{var o;return zj(r,(o=t==null?void 0:t.upTo)==null?void 0:o.call(t,r))},[t]);Dj(e,Pj,n,void 0,t==null?void 0:t.except)}function Wk(e){const t=window.getSelection();if(!t||t.isCollapsed||t.rangeCount===0||!e.contains(t.getRangeAt(0).commonAncestorContainer))return null;const n=t.toString().replace(/^\n+|\n+$/g,"");return n.trim()?n:null}function zj(e,t){const n=document.createRange();n.selectNodeContents(e),t&&n.setEndBefore(t);const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(n))}function m9(e){return e.shiftKey||e.altKey||e.metaKey||e.ctrlKey?null:e.key==="ArrowLeft"?-1:e.key==="ArrowRight"?1:null}function g9(e,t,n){const r=e+n;return r<0||r>=t?null:r}const Fj=E.createContext(null),k9="input, textarea, [contenteditable]";function N1(e){return[...e.values()].filter(t=>{var n;return(n=t.el())==null?void 0:n.isConnected}).sort((t,n)=>{const r=t.el(),o=n.el();return!r||!o||r===o?0:r.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1})}function _p({children:e}){const t=E.useRef(new Map),[n,r]=E.useState(null),o=E.useRef(n);o.current=n;const s=E.useMemo(()=>{const l=u=>{const f=N1(t.current),h=f.findIndex(p=>p.id===u);r(h<0?null:{id:u,at:h,of:f.length})};return{register(u){return t.current.set(u.id,u),()=>{var f;t.current.delete(u.id),((f=o.current)==null?void 0:f.id)===u.id&&r(null)}},open:l,step(u){const f=o.current;if(!f)return;const h=N1(t.current),p=h.findIndex(w=>w.id===f.id),g=p<0?null:g9(p,h.length,u),y=g===null?void 0:h[g];y&&l(y.id)},close(){var h,p,g;const u=o.current;if(r(null),!u)return;const f=document.activeElement;f!=null&&f.matches(k9)||(g=(p=(h=t.current.get(u.id))==null?void 0:h.el())==null?void 0:p.querySelector(".chip-link"))==null||g.focus({preventScroll:!0})}}},[]),a=E.useMemo(()=>({api:s,shown:n}),[s,n]);return d.jsx(Fj.Provider,{value:a,children:e})}function w9(e,t){const n=E.useContext(Fj),r=E.useId(),[o,s]=E.useState(!1),a=n==null?void 0:n.api;if(E.useLayoutEffect(()=>{if(!(!a||!t))return a.register({id:r,el:()=>e.current})},[a,r,t,e]),!a)return{open:o,show:()=>s(!0),close:()=>s(!1),nav:void 0};const l=(n==null?void 0:n.shown)??null,u=(l==null?void 0:l.id)===r;return{open:u,show:()=>a.open(r),close:a.close,nav:u&&l?{at:l.at,of:l.of,step:a.step}:void 0}}function Kk(e,t){const n=e.filter(o=>o.id!==t),r=n.filter(o=>o.agent==="waiting"||o.unseen).length;return r===0?null:{n:r,tier:n.some(o=>o.agent==="waiting")?"waiting":"unseen"}}function Bj(e,t,n){const r=f=>e.map((h,p)=>f(h)&&h.id!==t?p:-1).filter(h=>h>=0),s=[()=>r(f=>f.agent==="waiting"),()=>r(f=>!!f.unseen),()=>r(f=>f.agent==="working")].reduce((f,h)=>f.length>0?f:h(),[]),a=e.findIndex(f=>f.id===t),l=n>0?s.find(f=>f>a)??s[0]:s.findLast(f=>f<a)??s[s.length-1],u=l===void 0?void 0:e[l];return u?{activate:u.id}:null}function Ky(e,t,n){const r=Bj(e,t,n);if(r)return r;const o=e[0];return o&&o.id!==t?{activate:o.id}:null}function y9(e,t,n){const r=[Kk(e,t),...n.map(o=>Kk(o.rows,null))].filter(o=>o!==null);return r.length===0?null:{n:r.reduce((o,s)=>o+s.n,0),tier:r.some(o=>o.tier==="waiting")?"waiting":"unseen"}}function v9(e,t,n){const r=[s=>s.agent==="waiting",s=>!!s.unseen];for(const s of r){if(e.some(a=>s(a)&&a.id!==t)){const a=Bj(e,t,1);return a&&{origin:null,activate:a.activate}}for(const a of n){const l=a.rows.find(s);if(l)return{origin:a.origin,activate:l.id}}}const o=Ky(e,t,1);return o&&{origin:null,activate:o.activate}}function qy(e){const t=document.querySelector(`.pane[data-pane="${e}"]`);return!!t&&(t.classList.contains("full")||t.contains(document.activeElement))}function Zy({kind:e,className:t,height:n,resizable:r=!0,onDragStart:o,title:s,tabs:a,actions:l,menu:u,full:f,onToggleFull:h,onClose:p,closeHint:g="esc",children:y}){const w=xn("pane"),v=h&&d.jsx(Tt,{icon:"full",tone:"chrome",on:f,"aria-pressed":!!f,label:"Full height: hide the preview",onClick:h}),x=d.jsxs("span",{className:"pane-shape",children:[v,d.jsx(Tt,{icon:"close",label:"Close",hint:g,onClick:p})]});return d.jsxs("div",{className:`pane ${t}`,"data-pane":e,tabIndex:-1,style:n===void 0?void 0:{height:n},children:[r&&d.jsx("div",{className:"pane-resize",onPointerDown:o}),d.jsx("div",{className:We("pane-head",a&&"pane-head-tabs"),...w.contextMenu(()=>(u==null?void 0:u())??[]),children:a?d.jsx(Ya,{...a,end:d.jsxs(d.Fragment,{children:[l,x]})}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"pane-title",children:s}),l,x]})}),y]})}function Uj(e,{sock:t,dispatch:n}){var p,g;const r=y=>y?"hide":"show",o=e.repos.some(y=>y.id===e.activeRepoId),s=(p=Jt(e,e.activeId))==null?void 0:p.worktree.id,a=[];o&&(a.push({id:"new",label:"new worktree…",key:Ht("new"),onClick:()=>n({a:"open-draft"})}),a.push({id:"refs",label:"open a branch or PR…",key:Ht("refs"),onClick:()=>n({a:"open",overlay:{kind:"refs"}})})),s&&(a.push({id:"jump",label:"jump to file…",key:Ht("quick-open"),onClick:()=>n({a:"open",overlay:{kind:"quick-open"}})}),a.push({id:"search",label:"search in files…",key:Ht("search"),onClick:()=>n({a:"open",overlay:{kind:"search"}})})),Iu(e)&&a.push({id:"routes",label:"go to page…",key:Ht("routes"),onClick:()=>n({a:"open",overlay:{kind:"routes"}})}),o&&a.push({id:"chats",label:"search chats…",key:Ht("chats"),onClick:()=>n({a:"open",overlay:{kind:"chats"}})});const l=Ky(e.visible,e.activeId,1);l&&a.push({id:"wt-unseen-next",label:"next that needs you",key:Ht("wt-unseen-next"),onClick:()=>n({a:"activate",id:l.activate})}),a.push({id:"project",label:e.repos.length>1?"switch project…":"open project…",key:Ht("project"),onClick:()=>n({a:"open",overlay:{kind:"projects",form:"center"}})});const u=[{id:"changes",label:`${r(e.layout.changes)} changes panel`,key:Ht("changes"),onClick:()=>n({a:"toggle-changes"})},{id:"files",label:`${r(e.layout.changes&&tl(e)==="files")} files`,key:Ht("files"),onClick:()=>n(e.layout.changes&&tl(e)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"})},{id:"chat",label:`${r(e.layout.chat)} chat panel`,key:Ht("composer"),onClick:()=>n({a:"toggle-chat"})},{id:"terminal",label:`${r(e.layout.term)} terminal`,key:Ht("terminal"),onClick:()=>n({a:"toggle-terminal"})},{id:"rail",label:`${r(e.railOpen)} worktree panel`,key:Ht("rail"),onClick:()=>n({a:"toggle-rail"})},{id:"design",label:`${r(e.layout.design)} design system`,key:Ht("design"),onClick:()=>n({a:"toggle-design"})},{id:"zen",label:"full-bleed preview",key:Ht("zen"),onClick:()=>n({a:"toggle-zen",file:qy("editor")})}],f=[{id:"commands",label:"command palette",key:Ht("commands"),onClick:()=>n({a:"open",overlay:{kind:"commands"}})},{id:"keys",label:"settings & shortcuts",key:Ht("keys"),onClick:()=>n({a:"open",overlay:{kind:"keys"}})}];(g=e.self)!=null&&g.restart&&f.push({id:"restart-daemon",label:"restart Toyon",onClick:()=>t==null?void 0:t.send({t:"restart-daemon"})}),f.push({id:"devices",label:e.knocks.length>0?`let a device in (${e.knocks.length})`:"your devices",onClick:()=>n({a:"open",overlay:{kind:"devices"}})});const h=Co(e)?new Set(["chat","design","zen"]):null;return Un([a,h?u.filter(y=>!h.has(y.id)):u,f])}function qk(e,t){const n=e.get(t);if(!n||n.serving)return[];const r=e.displayName(t),o=[];e.active().origin!==t&&o.push({id:`machine:${t}`,label:`switch to ${r}`,onClick:()=>e.activate(t)});const s=[{id:`forget-machine:${t}`,label:`forget ${r}…`,danger:!0,onClick:()=>{window.confirm(`Forget ${r}?
133
-
134
- It leaves your list, here and in every browser Toyon on this machine serves, and this browser forgets what it had selected there. Toyon on that machine is not touched; pair again to list it.`)&&e.serving().sock.send({t:"forget-machine",origin:t})}}];return Un([o,s])}function Gy(e,t,{sock:n}){return[{id:`restart:${e.name}`,label:`restart ${e.name}`,detail:`${e.status} on :${e.port}`,onClick:()=>n==null?void 0:n.send({t:"term-restart",worktreeId:t,stream:e.name})}]}function Hj(e,{sock:t}){return[{id:"restart:shell",label:"restart shell",onClick:()=>t==null?void 0:t.send({t:"term-restart",worktreeId:e,stream:Bo})}]}function b9(e,t,n,r){return Un([[...e.flatMap(o=>Gy(o,t,r)),...Hj(t,r)],[{id:"terminal",label:`${n?"hide":"show"} terminal`,onClick:()=>r.dispatch({a:"toggle-terminal"})}]])}function Fu({sock:e,dispatch:t},n){t({a:"open-repo"}),e==null||e.send(n)}function Wj(e,t){const{parent:n,name:r}=Yy(t);Fu(e,{t:"create-repo",mode:"init",parent:n,name:r})}function x9(e,{sock:t,dispatch:n}){return[{id:`cancel-import:${e.id}`,label:e.error?"dismiss":"stop the clone",danger:!e.error,onClick:()=>{t==null||t.send({t:"cancel-import",id:e.id}),n({a:"watch-import",id:null})}}]}function Np(e,t,{sock:n,dispatch:r},o){const s=o.filter(u=>Tn(u)&&u.worktree.repoId===e.id&&Kh(u.worktree)).length,a=[];e.id!==t&&a.push({id:`repo:${e.id}`,label:`switch to ${e.name}`,onClick:()=>r({a:"activate-repo",id:e.id})});const l=[{id:`setup:${e.id}`,label:"project settings…",detail:e.configFile,onClick:()=>r({a:"open",overlay:{kind:"setup",repoId:e.id}})},{id:`forget:${e.id}`,label:"forget project…",danger:!0,onClick:()=>{window.confirm(E9(e.name,s))&&(n==null||n.send({t:"forget-repo",repoId:e.id}))}}];return Un([a,l])}function E9(e,t){const n=t===0?"":`Its ${t===1?"worktree is":`${t} worktrees are`} archived first, with the chats, commits and uncommitted changes kept. `;return`Forget ${e}?
135
-
136
- ${n}Its procs stop, it leaves the project list, and the chat on main is deleted. The checkout is not touched, and archived worktrees come back when you open it again.`}const xh={dark:"dark",light:"light",system:"follow system",daylight:"follow daylight"},Eh={use:"while in use",always:"always",off:"off"};function S9(e){const t=document.createElement("input");t.type="file",t.accept=".json,.jsonc,application/json",t.onchange=()=>{var r;const n=(r=t.files)==null?void 0:r[0];n&&n.text().then(o=>e(n.name,o))},t.click()}function Kj(e,{sock:t,dispatch:n}){var a;const r=e.themePrefs,o=l=>{var u;return((u=e.themes.find(f=>f.id===l))==null?void 0:u.name)??l},s=I6();return Un([[{id:"theme",label:"theme…",detail:ip(r,e.themes,_N(e)).name,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"theme"}})},{id:"appearance",topic:"theme",label:"light or dark…",detail:xh[r.mode],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"appearance"}})}],[{id:"agent",label:"default agent…",detail:((a=e.agents.find(l=>l.id===e.defaultAgent))==null?void 0:a.name)??e.defaultAgent,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"agent"}})}],[{id:"chat-side",label:"chat side",detail:e.chatSide,onClick:()=>n({a:"toggle-chat-side"})},...e.frame==="phone"?[{id:"black-ground",topic:"theme",label:"OLED black",detail:e.blackGround?"on":"off",onClick:()=>n({a:"toggle-black-ground"})}]:[],...s.access==="none"?[]:[{id:"clipboard-offer",label:"offer what is copied",detail:s.access==="denied"?"blocked in site settings":s.on?"on":"off",onClick:()=>R6(!s.on)}]],...e.keepAwake===null?[]:[[{id:"keep-awake",label:"keep awake…",detail:Eh[e.keepAwake],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"keep-awake"}})}]],[{id:"theme-import",topic:"theme",label:"import a VS Code theme…",onClick:()=>S9((l,u)=>t==null?void 0:t.send({t:"import-theme",name:l,source:u}))},{id:"theme-rescan",topic:"theme",label:"rescan editor themes",onClick:()=>t==null?void 0:t.send({t:"rescan-themes"})}],[{id:"theme-dark",topic:"theme",label:"dark slot override…",detail:o(r.dark),sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"dark"}})},{id:"theme-light",topic:"theme",label:"light slot override…",detail:o(r.light),sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"light"}})}]])}function _9(e,t,n,r,o,s={machines:[],switchTo:()=>{},forget:()=>{}}){const a=[],l=(g,y,w,v,x)=>a.push({id:g,label:y,hint:v,run:w,sub:x}),u=(g,y)=>{for(const w of g){if(!ys(w)||w.disabled!==void 0||w.checked)continue;const v=w.key??(typeof w.detail=="string"?w.detail:void 0),x=y?`${y.scope}:${w.id}`:w.id,N=w.topic?`${w.topic}: ${w.label}`:w.label;l(x,y?`${N} · ${y.name}`:N,w.onClick,v,w.sub)}},f={sock:n,dispatch:t},h=r,p=h==null?void 0:h.worktree.id;if(u(Uj(e,f).filter(g=>!ys(g)||g.id!=="commands")),o&&u(Np(o,o.id,f,e.rows),{scope:"project",name:o.name}),p&&!Co(e)){l("pick",e.picking==="chat"?"cancel element picker":"pick an element for the chat",()=>Lu(p,e.picking,t,"chat"),Ht("pick")),l("inspect",e.picking==="code"?"cancel element picker":"pick an element to open its code",()=>Lu(p,e.picking,t,"code"),Ht("inspect"));const g=_k(e);(g==null?void 0:g.act)==="start"?l("reload","start the preview",()=>n==null?void 0:n.send({t:"preview-start",worktreeId:g.id})):l("reload","reload preview",()=>fn.post(p,{type:"reload"}))}if(u(Kj(e,f)),h&&p){const g=e.repos.find(y=>y.id===h.worktree.repoId)??null;u(hj(h,g,e,f,{hostname:e.hostname,palette:!0}),{scope:"wt",name:vk(h,g)});for(const y of h.procs)u(Gy(y,p,f))}e.visible.forEach((g,y)=>{var x;if(g.worktree.id===p)return;const v=!!e.activeRepoId&&g.repoId!==e.activeRepoId?` in ${((x=e.repos.find(N=>N.id===g.repoId))==null?void 0:x.name)??g.repoId}`:"";l(`go:${g.worktree.id}`,`switch to ${vk(g,o)}${v}`,()=>t({a:"activate",id:g.worktree.id}),gR(y,e.visible.length))});for(const g of e.repos)g.id!==(o==null?void 0:o.id)&&l(`repo:${g.id}`,`switch to project ${g.name}`,()=>t({a:"activate-repo",id:g.id}));for(const g of s.machines){for(const y of g.repos)l(`machine:${g.origin}:${y.id}`,`switch to project ${y.name} on ${g.name}`,()=>s.switchTo(g.origin,y.id));l(`forget-machine:${g.origin}`,`forget ${g.name}`,()=>s.forget(g.origin))}return a}function qj(){const e=ht(),t=nt(),{host:n}=Mr(),r=Pn(),o=xs(),s=QN(),a=L(K=>K.picking),l=L(K=>K.layout),u=L(K=>K.chatSide),f=L(K=>K.blackGround),h=L(K=>K.keepAwake),p=L(K=>K.railOpen),g=L(K=>K.themePrefs),y=L(K=>K.themes),w=L(K=>K.systemDark),v=L(K=>K.daylight),x=L(K=>K.rows),N=L(K=>K.visible),S=L(K=>K.activeId),T=L(K=>K.activeRepoId),j=L(K=>K.repos),$=L(K=>K.agents),R=L(K=>K.defaultAgent),A=L(K=>K.shipping),I=L(K=>K.remote),M=L(K=>K.managed),P=L(K=>K.frame),F=L(K=>K.self),q=L(K=>K.archivedPage),W=L(K=>K.notesPage),ee=L(K=>K.archived),V=L(K=>K.knocks),te=L(K=>K.tailscale);return E.useMemo(()=>{const K={picking:a,layout:l,chatSide:u,blackGround:f,keepAwake:h,railOpen:p,themePrefs:g,themes:y,systemDark:w,daylight:v,rows:x,visible:N,activeId:S,activeRepoId:T,repos:j,agents:$,defaultAgent:R,shipping:A,frame:P,self:F,archivedPage:q,notesPage:W,archived:ee,knocks:V,hostname:n,drafted:oe=>dy(r.getState(),oe)},C={machines:s,switchTo:(oe,U)=>{var B;(B=o.get(oe))==null||B.store.dispatch({a:"activate-repo",id:U}),o.activate(oe)},forget:oe=>{const U=qk(o,oe).find(B=>ys(B)&&B.id.startsWith("forget-machine:"));U&&ys(U)&&U.onClick()}};return _9(K,e,t,Jt(K,S),bs(K,T),C)},[a,l,u,f,h,p,g,y,w,v,x,N,S,T,j,$,R,A,I,M,P,F,q,W,ee,V,te,e,t,n,r,o,s])}function Zj(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=[];for(const o of e){const s=Zk(o.label.toLowerCase(),n);s>0&&r.push({c:o,score:s})}return r.sort((o,s)=>s.score-o.score),r.map(o=>o.c)}function Zk(e,t){const n=Vy(e,t);if(!n)return 0;let r=0,o=0,s=-1;for(const a of n)o=a===s+1?o+1:1,r+=o+(Gj(e,a)?3:0),s=a;return r+Math.max(0,40-e.length/4)}const Gj=(e,t)=>t===0||/[\s:\-–—·/.(]/.test(e[t-1]);function Vy(e,t){const n=e.toLowerCase(),r=[];let o=0;for(const s of t.toLowerCase()){let a=-1;if(n[o]===s)a=o;else if(s===" ")a=n.indexOf(" ",o);else for(let l=n.indexOf(s,o);l!==-1;l=n.indexOf(s,l+1))if(Gj(n,l)){a=l;break}if(a===-1)return null;r.push(a),o=a+1}return r}const os=(e,...t)=>{const n=e.trim().toLowerCase();return!n||t.some(r=>r==null?void 0:r.toLowerCase().includes(n))},Bu=e=>/^(~|\/|\.\.?\/)/.test(e.trim());function Yy(e){const t=e.trim().replace(/\/+$/,""),n=t.lastIndexOf("/");return n<0?{parent:"",name:t}:{parent:t.slice(0,n)||"/",name:t.slice(n+1)}}function N9(e,t,n){const r=e.map(f=>f.path.slice(0,f.path.lastIndexOf("/"))).filter(Boolean),o=e.find(f=>f.id===t),s=o==null?void 0:o.path.slice(0,o.path.lastIndexOf("/")),a=new Map;for(const f of r)a.set(f,(a.get(f)??0)+1);let l="",u=0;for(const[f,h]of[...a].sort(([p],[g])=>p.localeCompare(g)))(h>u||h===u&&f===s)&&(l=f,u=h);return l?Xy(l,n):`~/${W_}`}function Xy(e,t){return t&&(e===t||e.startsWith(`${t}/`))?`~${e.slice(t.length)}`:e}function Vj(e,t){return`${e.replace(/\/+$/,"")}/${t.trim()}`}function T9(e){const t=e.query.trim();if(e.urlOnly){const a=vx(t);return a?[{kind:"clone",...a}]:[]}const n=()=>e.entries.map(a=>({kind:a.isFile?"file":"dir",entry:a}));if(!Bu(t)){const a=e.repos.filter(g=>os(t,g.name,g.path)).map(g=>({kind:"repo",repo:g})),l=e.pending.filter(g=>os(t,g.name,g.url)).map(g=>({kind:"pending",pending:g})),u=[...a,...l],f=(e.others??[]).flatMap(g=>g.repos.length===0?os(t,g.name)?[{kind:"machine",machine:g}]:[]:g.repos.filter(y=>os(t,y.name,y.path,g.name)).map(y=>({kind:"repo",repo:y,machine:g})));if(!t){const g=a.find(w=>w.kind==="repo"&&w.repo.id===e.current);return[...g?[g,...a.filter(w=>w!==g)]:a,...l,{kind:"disk"},{kind:"new"},{kind:"from-url"},{kind:"add-machine"},...f]}const h=vx(t);if(h)return u.length>0?u:[{kind:"clone",...h}];const p=g=>g.toLowerCase()===t.toLowerCase();return e.repos.some(g=>p(g.name))||e.pending.some(g=>p(g.name))?[...u,...f]:Au(t)?[...u,...f]:[...u,{kind:"create",name:t,parent:null},...f]}if(e.answered.trim()!==t||!e.target)return n();const{target:r}=e;if(r.exists){const a=t.replace(/\/+$/,"")||"/";if(r.isRepo)return[...n(),{kind:"open",path:a}];if(!r.isDir)return n();const l=rl(a,e.home);return l==="/"||l===e.home||e.repos.some(f=>f.path.startsWith(`${l}/`))?n():[...n(),{kind:"init",path:a}]}if(t.endsWith("/"))return n();if(!r.parentExists)return[];const{parent:o,name:s}=Yy(t);return Au(s)?n():[...n(),{kind:"create",name:s,parent:o}]}function rl(e,t){return t&&(e==="~"||e.startsWith("~/"))?`${t}${e.slice(1)}`:e}function Yj(e,t){const n=rl(e,t).replace(/\/+$/,"");return n.startsWith("/")?Xy(n.slice(0,n.lastIndexOf("/"))||"/",t):null}function Gk(e,t){const n=rl(e,t).replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||"/"}function j9(e){const t=e.query.trim(),n=t.lastIndexOf("/"),r=n<0?"":t.slice(0,n)||"/",o=rl(r,e.home);if(!Bu(t)||!o.startsWith("/"))return[];const s=t.slice(n+1).toLowerCase(),a=e.answered.trim()===t?e.target:null,l=!a||(s?a.parentExists:a.exists&&a.isDir&&!a.isRepo),u=e.entries.filter(h=>{if(h.isRepo||h.isFile)return!1;const p=rl(h.path,e.home);return(p.slice(0,p.lastIndexOf("/"))||"/")===o&&h.name.toLowerCase().startsWith(s)}),f=Yj(r,e.home);return[...l?[{kind:"here",path:r}]:[],...f?[{kind:"up",path:f}]:[],...u.map(h=>({kind:"dir",entry:h}))]}const $9=e=>e.t==="open-path"||e.t==="open-loose"||e.t==="open-clone"||e.t==="open-worktree",Ca=new Map,C9=16;function Vk({sock:e,dispatch:t},n,r){const o=Xj({worktreeId:n,href:r.href});t({a:"link-refused",id:n,v:null}),e==null||e.send({t:"open-by-path",path:r.path,seq:o})}function A9(e,t){e==null||e.send({t:"open-by-path",path:t,seq:Xj(null)})}function Xj(e){const t=$o();Ca.set(t,e);for(const n of Ca.keys()){if(Ca.size<=C9)break;Ca.delete(n)}return t}function I9(e,t){if(!Ca.has(t.seq))return;const n=Ca.get(t.seq);Ca.delete(t.seq),n?e.dispatch({a:"link-refused",id:n.worktreeId,v:{href:n.href,message:t.message}}):e.dispatch({a:"server",msg:{t:"error",message:t.message}})}function R9(e,t,n){var s;const r=e.getState();if(n.t==="open-clone"){const{t:a,parent:l,...u}=n;e.dispatch({a:"new-project",v:up({mode:"clone",parent:Xy(l,r.home),...u})});return}if(n.t==="open-worktree"){Kr(r,n.worktreeId)&&r.activeId!==n.worktreeId&&e.dispatch({a:"activate",id:n.worktreeId});return}if(n.t==="open-path"){const a={dispatch:u=>e.dispatch(u)};if(Kr(r,n.worktreeId)){r.activeId!==n.worktreeId&&e.dispatch({a:"activate",id:n.worktreeId}),Rn(a,{worktreeId:n.worktreeId,path:n.path});return}const l=Object.keys(r.trunks).find(u=>{var f;return((f=r.trunks[u])==null?void 0:f.id)===n.worktreeId});if(!l)return;if(((s=Kr(r,r.activeId))==null?void 0:s.repoId)!==l){const u=r.rows.find(f=>f.repoId===l);if(!u)return;e.dispatch({a:"activate",id:u.id})}Rn(a,{worktreeId:n.worktreeId,path:n.path});return}const o=r.activeId;if(!o){e.dispatch({a:"server",msg:{t:"error",message:`open a project first; ${n.name} needs a window to open in`}});return}e.dispatch({a:"open-loose",v:{worktreeId:o,name:n.name,text:n.text,binary:n.binary,tooLarge:n.tooLarge,source:{kind:"grant",id:n.id,path:n.path,version:n.version},seq:$o()}})}function Qy({open:e,remove:t},n){const r=n==null?void 0:n.sock,o=n&&r?()=>r.send({t:"reveal-attachment",worktreeId:n.worktreeId,file:n.file}):void 0,s=n&&r?r.urls.attachmentWhere(n.worktreeId,n.file):void 0;return[[...e?[{id:"open",label:"open full size",onClick:e}]:[],...Ko(o,wo(r),"reveal the copy")],s?[{id:"copy-path",label:"copy path",onClick:()=>wT(s)}]:[],t?[{id:"remove",label:"remove",onClick:t}]:[]]}function Ba(e,t={},n){return Un([[{id:"copy-image",label:"copy image",onClick:()=>q6(e)}],...Qy(t,n)])}function Qj({text:e,href:t}){return e!==void 0?[{id:"copy-text",label:"copy text",onClick:()=>sn(e)}]:t?[{id:"copy-text",label:"copy text",onClick:()=>wT(t)}]:[]}function O9(e,t={}){return Un([Qj(e),...Qy(t)])}function M9(e,t={},n){return Un([Qj(e),...Qy(t,n)])}function Jj(e){return[gT(e),{id:"copy-link",label:"copy link",onClick:()=>sn(e)}]}function Tp(e,t,n){if(e.kind==="worktree"){const{id:o,archived:s}=e;return()=>n.dispatch(s?{a:"open-archived",id:o}:{a:"activate",id:o})}if(e.kind==="outside"&&e.folder)return L9(e.path,n);if(!t)return null;if(e.kind==="outside")return()=>Vk(n,t,e);if(e.kind==="path")return()=>Vk(n,t,{href:e.path,path:e.path});if(e.kind!=="file")return null;const r=e.file;return r.folder?()=>J6(n,{worktreeId:t,path:r.path}):()=>Rn(n,{worktreeId:t,path:r.path,...r.line?{line:{n:r.line}}:{}})}function L9(e,{sock:t}){return!t||!wp(wo(t))?null:()=>t.send({t:"reveal-path",path:e})}function P9(e,t,n){const r=e.kind==="outside"&&e.folder?null:Tp(e,t,n),{sock:o}=n,s=e.kind==="file"?t?()=>o==null?void 0:o.send({t:"reveal",worktreeId:t,path:e.file.path}):void 0:()=>o==null?void 0:o.send({t:"reveal-path",path:e.path}),a=e.kind==="file"?e.file.path:e.path;return[[...r?[{id:"open",label:"open",onClick:r}]:[],...Ko(s,wo(o))],[{id:"copy-path",label:"copy path",onClick:()=>sn(a)}]]}function D9(e,t){const n=Tp(e,null,t);return[n?[{id:"open",label:e.archived?"open archived chat":"open chat",onClick:n}]:[],[{id:"copy-branch",label:"copy branch",onClick:()=>sn(e.branch)}]]}function Yk(e){return e?[{id:"copy-code",label:"copy code",onClick:()=>sn(e)}]:[]}function _i(e,t,n,r={},o="pointer"){if(o==="touch"&&!r.link&&!r.code)return null;const{dispatch:s,sock:a}=n,l=r.link,u=l?l.kind==="out"?[Jj(l.href)]:l.kind==="worktree"?D9(l,n):P9(l,t,n):[],f=[{id:"copy",label:"copy message",onClick:()=>sn(e.text)}],h=[];return e.kind==="user"&&t&&h.push({id:"draft",label:"edit in composer",onClick:()=>{const p=e.seq;if(p===void 0||!a)return s({a:"set-draft",id:t,text:e.text});s({a:"set-draft",id:t,text:""}),a.send({t:"redraft",worktreeId:t,seq:p})}}),Un([Yk(r.code),...u,f,h])}function e$(e,t,n){return[Ko(t,n),[{id:"copy-path",label:"copy path",onClick:()=>sn(e)}]]}function Jy(e,t,n){return Un(e$(e,t,n))}function z9(e,t){const n=e.callFile??e.file,r=n?e$(n,void 0,t.host):[],o=t.remove?[{id:"remove",label:"remove",onClick:t.remove}]:[];return Un([...r,o])}const T1=8,F9=.7,B9=100,U9=80,H9=220;function j1({dx:e,dy:t}){return Math.abs(e)<T1&&Math.abs(t)<T1?null:Math.abs(t)>Math.abs(e)?"away":"other"}function W9(e,t){const n=e.filter(s=>t-s.t<=B9),r=n[0],o=n[n.length-1];return!r||!o||o.t===r.t?0:(o.y-r.y)/(o.t-r.t)}const K9=e=>Math.abs(e)>=F9;function q9(e,t){return Math.min(H9,Math.max(U9,e/Math.abs(t)))}const Bc={s:1,x:0,y:0},Z9=2.5,$1=.5,C1=4,Rc=e=>e.s===1&&e.x===0&&e.y===0;function G9(e,t){return Math.max(C1,t>0?e/t:C1)}function eh(e,t,n,r){const o=(n.x-e.x)/e.s,s=(n.y-e.y)/e.s;return{s:t,x:r.x-o*t,y:r.y-s*t}}function Sa(e,t){return{s:e.s,x:A1(e.x,(t.w*e.s-t.W)/2),y:A1(e.y,(t.h*e.s-t.H)/2)}}const A1=(e,t)=>t<=0?0:Math.min(t,Math.max(-t,e));function I1(e,t){const n=Math.min(t.max,Math.max(1,e.s));return n===1?Bc:Sa({...e,s:n},t)}function R1(e,t,n){return Rc(e)?Sa(eh(e,Math.min(Z9,n.max),t,t),n):Bc}const V9=400,O1=300,Y9=32,M1=260,X9=.01,L1=(e,t)=>Math.hypot(t.clientX-e.clientX,t.clientY-e.clientY),P1=(e,t)=>({x:(e.clientX+t.clientX)/2,y:(e.clientY+t.clientY)/2}),Cc=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),Og=(e,t,n)=>Math.min(n,Math.max(t,e));function Q9(e,t,n){const r=E.useRef(n);r.current=n,E.useEffect(()=>{const o=e.current;if(!o)return;let s=null,a=!1,l=[],u=0,f=Bc,h=null,p=null,g=null,y=0,w=0;const v=()=>{const W=o.querySelector(t);if(!W)return null;const ee=o.getBoundingClientRect(),V=W.offsetWidth,te=W.offsetHeight,K=W instanceof HTMLImageElement?W.naturalWidth:V;return{centre:{x:ee.left+W.offsetLeft+V/2,y:ee.top+W.offsetTop+te/2},bounds:{w:V,h:te,W:o.clientWidth,H:o.clientHeight,max:G9(K,V)}}},x=(W,ee,V)=>{V!==void 0&&o.style.setProperty("--swipe-ms",`${V}ms`),o.dataset.swipe!==ee&&(o.dataset.swipe=ee,o.offsetWidth),o.style.setProperty("--swipe-y",`${W}px`),o.style.setProperty("--swipe-fade",`${Math.min(1,Math.abs(W)/(window.innerHeight/2))}`)},N=()=>{o.style.removeProperty("--swipe-y"),o.style.removeProperty("--swipe-fade"),o.style.removeProperty("--swipe-ms"),delete o.dataset.swipe},S=(W,ee)=>{if(f=W,window.clearTimeout(w),ee?(o.dataset.zoom!==ee&&(o.dataset.zoom=ee,o.offsetWidth),w=window.setTimeout(()=>delete o.dataset.zoom,M1)):delete o.dataset.zoom,Rc(W)){o.style.removeProperty("--zoom-s"),o.style.removeProperty("--zoom-x"),o.style.removeProperty("--zoom-y");return}o.style.setProperty("--zoom-s",`${W.s}`),o.style.setProperty("--zoom-x",`${W.x}px`),o.style.setProperty("--zoom-y",`${W.y}px`)},T=()=>{const W=a;s=null,a=!1,l=[],h=null,p=null,W&&(x(0,"settle"),u=window.setTimeout(N,M1))},j=W=>{var C;const ee=W.target,V=ee===o||!!(ee!=null&&ee.closest(t));if((((C=window.visualViewport)==null?void 0:C.scale)??1)>1.01)return T();if(o.dataset.swipe==="leave")return;const te=W.touches[0],K=W.touches[1];if(te&&K&&W.touches.length===2&&V){T(),window.clearTimeout(y),g=null,h={d:L1(te,K),m:P1(te,K),z:f};return}if(W.touches.length!==1||!te||!V)return T();window.clearTimeout(u),s={x:te.clientX,y:te.clientY,at:W.timeStamp},l=[{y:te.clientY,t:W.timeStamp}],p=Rc(f)?null:f},$=W=>{const ee=W.touches[0],V=W.touches[1];if(h&&ee&&V){W.preventDefault();const C=v();if(!C)return;const oe=Og(h.z.s*L1(ee,V)/h.d,$1,C.bounds.max);S(Sa(eh(h.z,oe,Cc(h.m,C.centre),Cc(P1(ee,V),C.centre)),C.bounds));return}if(!s||!ee)return;const te=ee.clientX-s.x,K=ee.clientY-s.y;if(p){W.preventDefault();const C=v();C&&S(Sa({s:p.s,x:p.x+te,y:p.y+K},C.bounds));return}if(!a){const C=j1({dx:te,dy:K});if(C==="other"&&(s=null),C!=="away")return;a=!0}W.preventDefault(),l.push({y:ee.clientY,t:W.timeStamp}),l.length>16&&l.shift(),x(K,"drag")},R=W=>{if(h){if(W.touches.length>=2)return;const Q=v();S(Q?I1(f,Q.bounds):Bc,"settle"),h=null;const ue=W.touches[0];ue&&!Rc(f)&&(s={x:ue.clientX,y:ue.clientY,at:W.timeStamp},p=f);return}const ee=W.changedTouches[0];if(!s||!ee)return;const V={x:ee.clientX,y:ee.clientY},te=V.y-s.y,K=W.timeStamp-s.at;if(!a&&K<V9&&W.target!==o&&j1({dx:V.x-s.x,dy:te})===null){if(W.preventDefault(),s=null,p=null,g&&W.timeStamp-g.t<O1&&Math.hypot(V.x-g.p.x,V.y-g.p.y)<Y9){window.clearTimeout(y),g=null;const Q=v();S(Q?R1(f,Cc(V,Q.centre),Q.bounds):Bc,"settle");return}g={p:V,t:W.timeStamp},Rc(f)&&(y=window.setTimeout(()=>r.current(),O1));return}if(p){p=null,s=null,l=[];return}const oe=W9(l,W.timeStamp);if(!a||!K9(oe))return T();s=null,a=!1,l=[];const U=Math.sign(oe)*window.innerHeight,B=q9(Math.abs(U-te),oe);x(U,"leave",B),u=window.setTimeout(()=>r.current(),B)},A=W=>{var V;if(!((V=W.target)!=null&&V.closest(t)))return;const ee=v();ee&&S(R1(f,Cc({x:W.clientX,y:W.clientY},ee.centre),ee.bounds),"settle")},I=W=>{const ee=v();if(ee)if(W.ctrlKey){W.preventDefault();const V=Cc({x:W.clientX,y:W.clientY},ee.centre),te=Og(f.s*Math.exp(-W.deltaY*X9),1,ee.bounds.max);S(Sa(eh(f,te,V,V),ee.bounds))}else Rc(f)||(W.preventDefault(),S(Sa({s:f.s,x:f.x-W.deltaX,y:f.y-W.deltaY},ee.bounds)))};let M=null;const P=W=>{if(h)return;W.preventDefault();const ee=v(),V=W;ee&&(M={z:f,p:Cc({x:V.clientX,y:V.clientY},ee.centre)})},F=W=>{if(h)return;W.preventDefault();const ee=v();if(!M||!ee)return;const V=Og(M.z.s*W.scale,$1,ee.bounds.max);S(Sa(eh(M.z,V,M.p,M.p),ee.bounds))},q=W=>{if(h)return;W.preventDefault(),M=null;const ee=v();S(ee?I1(f,ee.bounds):Bc,"settle")};return o.addEventListener("touchstart",j,{passive:!0}),o.addEventListener("touchmove",$,{passive:!1}),o.addEventListener("touchend",R),o.addEventListener("touchcancel",T),o.addEventListener("dblclick",A),o.addEventListener("wheel",I,{passive:!1}),o.addEventListener("gesturestart",P),o.addEventListener("gesturechange",F),o.addEventListener("gestureend",q),()=>{window.clearTimeout(u),window.clearTimeout(y),window.clearTimeout(w),o.removeEventListener("touchstart",j),o.removeEventListener("touchmove",$),o.removeEventListener("touchend",R),o.removeEventListener("touchcancel",T),o.removeEventListener("dblclick",A),o.removeEventListener("wheel",I),o.removeEventListener("gesturestart",P),o.removeEventListener("gesturechange",F),o.removeEventListener("gestureend",q)}},[e,t])}function id({owner:e,onClose:t,menu:n,nav:r,children:o}){const s=xn(e),a=E.useRef(null);return Q9(a,"img",t),d.jsxs(Qs,{className:"attach-full scrim",boxRef:a,onDismiss:t,onKey:l=>{if(l.key==="Escape"){l.stopPropagation(),t();return}const u=r&&m9(l);u&&(l.preventDefault(),l.stopPropagation(),r.step(u))},onClick:l=>{l.target===l.currentTarget&&t()},...n&&s.contextMenu(n),children:[o,d.jsxs("div",{className:"attach-head",children:[r&&r.of>1&&d.jsxs("span",{className:"attach-count",children:[r.at+1," of ",r.of]}),d.jsx(Tt,{icon:"close",label:"Close",tone:"quiet",onClick:t})]})]})}function J9({item:e}){if(!e.outcome)return null;const t=_z[e.outcome];if(e.ask.kind==="permission"){const{title:n,choices:r}=e.ask,o=r.find(s=>s.id===e.choiceId);return d.jsxs("div",{className:"ask-closed",children:[!e.toolId&&d.jsx("div",{className:"ask-lead",children:n}),d.jsx("div",{className:"ask-answered",children:o?o.name:t??"closed"})]})}return d.jsxs("div",{className:"ask-closed",children:[d.jsx("div",{className:"ask-lead",children:e.ask.message}),d.jsx("div",{className:"ask-answered",children:t??"closed"})]})}function t$(e,t){if(!t||t.startsWith("#")||t.startsWith("/")||/^[a-z][a-z\d+.-]*:/i.test(t))return null;const n=t.split(/[?#]/)[0]??"";if(!n)return null;const r=e?e.split("/"):[];for(const o of n.split("/"))if(!(o===""||o==="."))if(o===".."){if(!r.length)return null;r.pop()}else r.push(decodeURIComponent(o));return r.length?r.join("/"):null}const eB=e=>e.slice(0,Math.max(0,e.lastIndexOf("/")));function ev(e,t){let n;try{n=decodeURIComponent(t)}catch{return null}const r=n.match(/#L(\d+)(?:-L?\d+)?$/i);r?n=n.slice(0,r.index):n=n.split(/[?#]/)[0]??"";const o=n.match(/:(\d+)(?::\d+)?$/);o&&(n=n.slice(0,o.index));const s=e.replace(/\/+$/,"");if(!s||!n.startsWith(`${s}/`))return null;const a=n.endsWith("/"),l=n.slice(s.length+1).replace(/\/+$/,"");if(!l||l.split("/").some(h=>h===".."))return null;if(a)return{path:l,folder:!0};const u=(r==null?void 0:r[1])??(o==null?void 0:o[1]),f=u?Number.parseInt(u,10):void 0;return f&&f>0?{path:l,line:f}:{path:l}}function n$(e){return!e||/^[/\\#?]/.test(e)||/^[a-z][a-z\d+.-]*:/i.test(e)?null:ev("/root",`/root/${e.replace(/^(?:\.\/+)+/,"")}`)}function r$(e){var t;return((t=e.match(/^file:\/\/(?:localhost)?(\/.*)$/i))==null?void 0:t[1])??e}function o$(e){if(!e.startsWith("/")||e.startsWith("//"))return null;let t;try{t=decodeURIComponent(e)}catch{return null}if(t.length>1&&t.endsWith("/"))return{path:t.replace(/\/+$/,""),folder:!0};const n=t.match(/:(\d+)(?::\d+)?$/);if(!n)return{path:t};const r=Number.parseInt(n[1]??"",10),o=t.slice(0,n.index);return r>0?{path:o,line:r}:{path:o}}function tB(e){return e.length<2||!e.startsWith("/")||e.startsWith("//")||/\s/.test(e)?null:e}function jp(e,t){const n=e.closest("[data-worktree]"),r=n==null?void 0:n.getAttribute("data-worktree");if(n&&r)return{kind:"worktree",id:r,branch:n.getAttribute("data-branch")??"",archived:n.hasAttribute("data-archived")};const o=e.closest("a, code[data-path]");if(!o)return null;const s=o.getAttribute("data-path");if(s)return{kind:"path",path:s};const a=o.getAttribute("href");if(!a)return null;const l=t?ev(t,a)??n$(a):null;if(l)return{kind:"file",file:l};const u=o$(a);return u?{kind:"outside",href:a,...u}:{kind:"out",href:a}}function tv(e,t,n,r){var s,a;const o=jp(e.target,t);if(!(!o||o.kind==="path")){if(o.kind==="out"){((s=e.target.closest("a"))==null?void 0:s.target)!=="_blank"&&e.preventDefault();return}e.preventDefault(),(a=Tp(o,n,r))==null||a()}}const nB=150,rB=e=>({side:e,align:"center",offset:12,flip:"side",margin:8});function s$({chip:e,className:t,children:n}){const[r,o]=E.useState(!1),s=td("chat");E.useEffect(()=>{const l=e.current;if(!l)return;let u=0;const f=()=>{window.clearTimeout(u),o(!1)},h=()=>{window.clearTimeout(u),u=window.setTimeout(()=>o(!0),nB)};return l.addEventListener("mouseenter",h),l.addEventListener("mouseleave",f),l.addEventListener("mousedown",f),()=>{window.clearTimeout(u),l.removeEventListener("mouseenter",h),l.removeEventListener("mouseleave",f),l.removeEventListener("mousedown",f)}},[e]);const a=()=>{var h;const l=e.current;if(!l)return null;const u=l.getBoundingClientRect(),f=((h=l.closest(".chat-log"))==null?void 0:h.getBoundingClientRect())??u;return{left:f.left,right:f.right,top:u.top,bottom:u.bottom}};return r?d.jsx(Qs,{className:We("chip-peek",t),anchor:a,placement:rB(s),track:!0,children:n}):null}function nv({className:e,label:t,tip:n,peek:r,full:o,menu:s,removeLabel:a,onRemove:l}){const u=E.useRef(null),f=xn("chat"),h=o!==void 0,p=w9(u,h);return d.jsxs("div",{ref:u,className:We("pick-chip row row-sm",e),"data-tip":h?"Open full size":n,"data-tip-placement":"follow",...f.contextMenu(()=>s({open:h?p.show:void 0,remove:l})),children:[h?d.jsx("button",{type:"button",className:"chip-link",onClick:p.show,children:t}):t,l&&d.jsx(Tt,{icon:"close",label:a,tone:"quiet",onClick:l}),h&&r!==void 0&&d.jsx(s$,{chip:u,children:r}),p.open&&h&&d.jsx(id,{owner:"chat",onClose:p.close,menu:()=>s(),nav:p.nav,children:o})]})}/*! @license DOMPurify 3.4.14 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.14/LICENSE */function D1(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 oB(e){if(Array.isArray(e))return e}function sB(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,s,a,l=[],u=!0,f=!1;try{if(s=(n=n.call(e)).next,t!==0)for(;!(u=(r=s.call(n)).done)&&(l.push(r.value),l.length!==t);u=!0);}catch(h){f=!0,o=h}finally{try{if(!u&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(f)throw o}}return l}}function iB(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
137
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function aB(e,t){return oB(e)||sB(e,t)||cB(e,t)||iB()}function cB(e,t){if(e){if(typeof e=="string")return D1(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)?D1(e,t):void 0}}const i$=Object.entries,z1=Object.setPrototypeOf,lB=Object.isFrozen,uB=Object.getPrototypeOf,dB=Object.getOwnPropertyDescriptor;let wr=Object.freeze,jr=Object.seal,Oc=Object.create,a$=typeof Reflect<"u"&&Reflect,Xk=a$.apply,Qk=a$.construct;wr||(wr=function(t){return t});jr||(jr=function(t){return t});Xk||(Xk=function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),s=2;s<r;s++)o[s-2]=arguments[s];return t.apply(n,o)});Qk||(Qk=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new t(...r)});const xa=hr(Array.prototype.forEach),fB=hr(Array.prototype.lastIndexOf),F1=hr(Array.prototype.pop),su=hr(Array.prototype.push),hB=hr(Array.prototype.splice),Vc=Array.isArray,hu=hr(String.prototype.toLowerCase),Mg=hr(String.prototype.toString),B1=hr(String.prototype.match),iu=hr(String.prototype.replace),U1=hr(String.prototype.indexOf),pB=hr(String.prototype.trim),mB=hr(Number.prototype.toString),gB=hr(Boolean.prototype.toString),H1=typeof BigInt>"u"?null:hr(BigInt.prototype.toString),W1=typeof Symbol>"u"?null:hr(Symbol.prototype.toString),po=hr(Object.prototype.hasOwnProperty),au=hr(Object.prototype.toString),Ur=hr(RegExp.prototype.test),va=kB(TypeError);function hr(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return Xk(e,t,r)}}function kB(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Qk(e,n)}}function kn(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:hu;if(z1&&z1(e,null),!Vc(t))return e;let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const s=n(o);s!==o&&(lB(t)||(t[r]=s),o=s)}e[o]=!0}return e}function wB(e){for(let t=0;t<e.length;t++)po(e,t)||(e[t]=null);return e}function To(e){const t=Oc(null);for(const r of i$(e)){var n=aB(r,2);const o=n[0],s=n[1];po(e,o)&&(Vc(s)?t[o]=wB(s):s&&typeof s=="object"&&s.constructor===Object?t[o]=To(s):t[o]=s)}return t}function yB(e){switch(typeof e){case"string":return e;case"number":return mB(e);case"boolean":return gB(e);case"bigint":return H1?H1(e):"0";case"symbol":return W1?W1(e):"Symbol()";case"undefined":return au(e);case"function":case"object":{if(e===null)return au(e);const t=e,n=es(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:au(r)}return au(e)}default:return au(e)}}function es(e,t){for(;e!==null;){const r=dB(e,t);if(r){if(r.get)return hr(r.get);if(typeof r.value=="function")return hr(r.value)}e=uB(e)}function n(){return null}return n}function vB(e){try{return Ur(e,""),!0}catch{return!1}}const K1=wr(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Lg=wr(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Pg=wr(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),bB=wr(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Dg=wr(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),xB=wr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),q1=wr(["#text"]),Z1=wr(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),zg=wr(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),G1=wr(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Lf=wr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),EB=jr(/{{[\w\W]*|^[\w\W]*}}/g),SB=jr(/<%[\w\W]*|^[\w\W]*%>/g),_B=jr(/\${[\w\W]*/g),NB=jr(/^data-[\-\w.\u00B7-\uFFFF]+$/),TB=jr(/^aria-[\-\w]+$/),V1=jr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),jB=jr(/^(?:\w+script|data):/i),$B=jr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),CB=jr(/^html$/i),AB=jr(/^[a-z][.\w]*(-[.\w]+)+$/i),Y1=jr(/<[/\w!]/g),X1=jr(/<[/\w]/g),IB=jr(/<\/no(script|embed|frames)/i),RB=jr(/\/>/i),No={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},c$=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],OB=wr(kn({},c$)),MB=(function(){const e={};return xa(c$,t=>{e[t]=jr(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),wr(e)})(),LB=function(){return typeof window>"u"?null:window},PB=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));const s="dompurify"+(r?"#"+r:"");try{return t.createPolicy(s,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Q1=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Ni=function(t,n,r,o){return po(t,n)&&Vc(t[n])?kn(o.base?To(o.base):{},t[n],o.transform):r},Fg=function(t,n,r){const o=po(t,n)?t[n]:void 0;return o&&typeof o=="object"?To(o):r()};function l$(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:LB();const t=Te=>l$(Te);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==No.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,o=r.currentScript;e.DocumentFragment;const s=e.HTMLTemplateElement,a=e.Node,l=e.Element,u=e.NodeFilter,f=e.NamedNodeMap;f===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const h=e.DOMParser,p=e.trustedTypes,g=l.prototype,y=es(g,"cloneNode"),w=es(g,"remove"),v=es(g,"nextSibling"),x=es(g,"childNodes"),N=es(g,"parentNode"),S=es(g,"shadowRoot"),T=es(g,"attributes"),j=a&&a.prototype?es(a.prototype,"nodeType"):null,$=a&&a.prototype?es(a.prototype,"nodeName"):null,R=a&&a.prototype?es(a.prototype,"ownerDocument"):null,A=function(H){return j?j(H):H.nodeType},I=function(H){return $?$(H):H.nodeName};if(typeof s=="function"){const Te=n.createElement("template");Te.content&&Te.content.ownerDocument&&(n=Te.content.ownerDocument)}let M,P="",F,q=!1,W=0;const ee=function(){if(W>0)throw va('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},V=function(H){ee(),W++;try{return M.createHTML(H)}finally{W--}},te=function(H){ee(),W++;try{return M.createScriptURL(H)}finally{W--}},K=function(){return q||(F=PB(p,o),q=!0),F},C=n,oe=C.implementation,U=C.createNodeIterator,B=C.createDocumentFragment,Q=C.getElementsByTagName,ue=r.importNode;let he=Q1();t.isSupported=typeof i$=="function"&&typeof N=="function"&&oe&&oe.createHTMLDocument!==void 0;const Ne=EB,De=SB,Be=_B,Z=NB,J=TB,pe=jB,de=$B,ie=AB;let ye=V1,_e=null;const be=kn({},[...K1,...Lg,...Pg,...Dg,...q1]);let $e=null;const Ze=kn({},[...Z1,...zg,...G1,...Lf]);let rt=Object.seal(Oc(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),en=null,Xt=null;const Et=Object.seal(Oc(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ke=!0,Qt=!0,Ot=!1,Zt=!0,Ge=!1,nn=!0,pn=!1,It=!1,gt=null,Vt=null,Cn=!1,Ce=!1,Pt=!1,Dt=!1,Wt=!0,Dn=!1;const ne="user-content-";let we=!0,Ye=!1,ot={},zt=null;const Kt=kn({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let D=null;const se=kn({},["audio","video","img","source","image","track"]);let Se=null;const ze=kn({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ut="http://www.w3.org/1998/Math/MathML",qt="http://www.w3.org/2000/svg",Oe="http://www.w3.org/1999/xhtml";let Fe=Oe,et=!1,Ft=null;const jt=kn({},[Ut,qt,Oe],Mg),On=wr(["mi","mo","mn","ms","mtext"]);let Mn=kn({},On);const yn=wr(["annotation-xml"]);let tn=kn({},yn);const _n=kn({},["title","style","font","a","script"]);let Mt=null;const mn=["application/xhtml+xml","text/html"],rr="text/html";let Ct=null,le=null;const qe=n.createElement("form"),Xe=function(H){return H instanceof RegExp||H instanceof Function},pt=function(){let H=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(le&&le===H)return;(!H||typeof H!="object")&&(H={}),H=To(H),Mt=mn.indexOf(H.PARSER_MEDIA_TYPE)===-1?rr:H.PARSER_MEDIA_TYPE,Ct=Mt==="application/xhtml+xml"?Mg:hu,_e=Ni(H,"ALLOWED_TAGS",be,{transform:Ct}),$e=Ni(H,"ALLOWED_ATTR",Ze,{transform:Ct}),Ft=Ni(H,"ALLOWED_NAMESPACES",jt,{transform:Mg}),Se=Ni(H,"ADD_URI_SAFE_ATTR",ze,{transform:Ct,base:ze}),D=Ni(H,"ADD_DATA_URI_TAGS",se,{transform:Ct,base:se}),zt=Ni(H,"FORBID_CONTENTS",Kt,{transform:Ct}),en=Ni(H,"FORBID_TAGS",To({}),{transform:Ct}),Xt=Ni(H,"FORBID_ATTR",To({}),{transform:Ct}),ot=po(H,"USE_PROFILES")?H.USE_PROFILES&&typeof H.USE_PROFILES=="object"?To(H.USE_PROFILES):H.USE_PROFILES:!1,Ke=H.ALLOW_ARIA_ATTR!==!1,Qt=H.ALLOW_DATA_ATTR!==!1,Ot=H.ALLOW_UNKNOWN_PROTOCOLS||!1,Zt=H.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ge=H.SAFE_FOR_TEMPLATES||!1,nn=H.SAFE_FOR_XML!==!1,pn=H.WHOLE_DOCUMENT||!1,Ce=H.RETURN_DOM||!1,Pt=H.RETURN_DOM_FRAGMENT||!1,Dt=H.RETURN_TRUSTED_TYPE||!1,Cn=H.FORCE_BODY||!1,Wt=H.SANITIZE_DOM!==!1,Dn=H.SANITIZE_NAMED_PROPS||!1,we=H.KEEP_CONTENT!==!1,Ye=H.IN_PLACE||!1,ye=vB(H.ALLOWED_URI_REGEXP)?H.ALLOWED_URI_REGEXP:V1,Fe=typeof H.NAMESPACE=="string"?H.NAMESPACE:Oe,Mn=Fg(H,"MATHML_TEXT_INTEGRATION_POINTS",()=>kn({},On)),tn=Fg(H,"HTML_INTEGRATION_POINTS",()=>kn({},yn));const Y=Fg(H,"CUSTOM_ELEMENT_HANDLING",()=>Oc(null));if(rt=Oc(null),po(Y,"tagNameCheck")&&Xe(Y.tagNameCheck)&&(rt.tagNameCheck=Y.tagNameCheck),po(Y,"attributeNameCheck")&&Xe(Y.attributeNameCheck)&&(rt.attributeNameCheck=Y.attributeNameCheck),po(Y,"allowCustomizedBuiltInElements")&&typeof Y.allowCustomizedBuiltInElements=="boolean"&&(rt.allowCustomizedBuiltInElements=Y.allowCustomizedBuiltInElements),jr(rt),Ge&&(Qt=!1),Pt&&(Ce=!0),ot&&(_e=kn({},q1),$e=Oc(null),ot.html===!0&&(kn(_e,K1),kn($e,Z1)),ot.svg===!0&&(kn(_e,Lg),kn($e,zg),kn($e,Lf)),ot.svgFilters===!0&&(kn(_e,Pg),kn($e,zg),kn($e,Lf)),ot.mathMl===!0&&(kn(_e,Dg),kn($e,G1),kn($e,Lf))),Et.tagCheck=null,Et.attributeCheck=null,po(H,"ADD_TAGS")&&(typeof H.ADD_TAGS=="function"?Et.tagCheck=H.ADD_TAGS:Vc(H.ADD_TAGS)&&(_e===be&&(_e=To(_e)),kn(_e,H.ADD_TAGS,Ct))),po(H,"ADD_ATTR")&&(typeof H.ADD_ATTR=="function"?Et.attributeCheck=H.ADD_ATTR:Vc(H.ADD_ATTR)&&($e===Ze&&($e=To($e)),kn($e,H.ADD_ATTR,Ct))),po(H,"ADD_FORBID_CONTENTS")&&Vc(H.ADD_FORBID_CONTENTS)&&(zt===Kt&&(zt=To(zt)),kn(zt,H.ADD_FORBID_CONTENTS,Ct)),we&&(_e["#text"]=!0),pn&&kn(_e,["html","head","body"]),_e.table&&(kn(_e,["tbody"]),delete en.tbody),H.TRUSTED_TYPES_POLICY){if(typeof H.TRUSTED_TYPES_POLICY.createHTML!="function")throw va('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof H.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw va('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const ce=M;M=H.TRUSTED_TYPES_POLICY;try{P=V("")}catch(xe){throw M=ce,xe}}else H.TRUSTED_TYPES_POLICY===null?(M=void 0,P=""):(M===void 0&&(M=K()),M&&typeof P=="string"&&(P=V("")));wr&&wr(H),le=H},wt=kn({},[...Lg,...Pg,...bB]),En=kn({},[...Dg,...xB]),Lr=function(H,Y,ce){return Y.namespaceURI===Oe?H==="svg":Y.namespaceURI===Ut?H==="svg"&&(ce==="annotation-xml"||Mn[ce]):!!wt[H]},un=function(H,Y,ce){return Y.namespaceURI===Oe?H==="math":Y.namespaceURI===qt?H==="math"&&tn[ce]:!!En[H]},vr=function(H,Y,ce){return Y.namespaceURI===qt&&!tn[ce]||Y.namespaceURI===Ut&&!Mn[ce]?!1:!En[H]&&(_n[H]||!wt[H])},Qn=function(H){let Y=N(H);(!Y||!Y.tagName)&&(Y={namespaceURI:Fe,tagName:"template"});const ce=hu(H.tagName),xe=hu(Y.tagName);return Ft[H.namespaceURI]?H.namespaceURI===qt?Lr(ce,Y,xe):H.namespaceURI===Ut?un(ce,Y,xe):H.namespaceURI===Oe?vr(ce,Y,xe):!!(Mt==="application/xhtml+xml"&&Ft[H.namespaceURI]):!1},Bt=function(H){su(t.removed,{element:H});try{N(H).removeChild(H)}catch{if(w(H),!N(H))throw va("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},dn=function(H,Y,ce){try{H.removeAttributeNode(Y)}catch{try{H.removeAttribute(ce)}catch{}}},ve=function(H){yt(H);const Y=x(H);if(Y){const xe=[];xa(Y,Ie=>{su(xe,Ie)}),xa(xe,Ie=>{try{w(Ie)}catch{}})}const ce=T(H);if(ce)for(let xe=ce.length-1;xe>=0;--xe){const Ie=ce[xe],Qe=Ie&&Ie.name;typeof Qe=="string"&&dn(H,Ie,Qe)}},Le=function(H,Y,ce){if(!ce)try{ce=Y.getAttributeNode(H)}catch{ce=null}su(t.removed,{attribute:ce||null,from:Y});try{ce?Y.removeAttributeNode(ce):Y.removeAttribute(H)}catch{try{Y.removeAttribute(H)}catch{}}if(H==="is")if(Ce||Pt)try{Bt(Y)}catch{}else try{Y.setAttribute(H,"")}catch{}},At=function(H){const Y=T(H);if(Y)for(let ce=Y.length-1;ce>=0;--ce){const xe=Y[ce],Ie=xe&&xe.name;typeof Ie!="string"||$e[Ct(Ie)]||dn(H,xe,Ie)}},yt=function(H){const Y=[H];for(;Y.length>0;){const ce=Y.pop();A(ce)===No.element&&At(ce);const Ie=x(ce);if(Ie)for(let Qe=Ie.length-1;Qe>=0;--Qe)Y.push(Ie[Qe])}},rn=function(H,Y){return nn?H==="patchsrc"?!0:H==="for"&&Y!=="label"&&Y!=="output":!1},Gt=function(H){if(!nn)return;const Y=[H];for(;Y.length>0;){const ce=Y.pop(),xe=A(ce);if(xe===No.processingInstruction||xe===No.comment&&Ur(X1,ce.data)){try{w(ce)}catch{}continue}if(xe===No.element){const Qe=ce,$t=Ct(I(ce));try{Qe.hasAttribute&&Qe.hasAttribute("patchsrc")&&Qe.removeAttribute("patchsrc"),Qe.hasAttribute&&Qe.hasAttribute("for")&&rn("for",$t)&&Qe.removeAttribute("for")}catch{}}const Ie=x(ce);if(Ie)for(let Qe=Ie.length-1;Qe>=0;--Qe)Y.push(Ie[Qe])}},Jn=function(H){let Y=null,ce=null;if(Cn)H="<remove></remove>"+H;else{const Qe=B1(H,/^[\r\n\t ]+/);ce=Qe&&Qe[0]}Mt==="application/xhtml+xml"&&Fe===Oe&&(H='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+H+"</body></html>");const xe=M?V(H):H;if(Fe===Oe)try{Y=new h().parseFromString(xe,Mt)}catch{}if(!Y||!Y.documentElement){Y=oe.createDocument(Fe,"template",null);try{Y.documentElement.innerHTML=et?P:xe}catch{}}const Ie=Y.body||Y.documentElement;return H&&ce&&Ie.insertBefore(n.createTextNode(ce),Ie.childNodes[0]||null),Fe===Oe?Q.call(Y,pn?"html":"body")[0]:pn?Y.documentElement:Ie},Zr=function(H){const Y=R?R(H):H.ownerDocument;return U.call(Y||H,H,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},hn=function(H){return H=iu(H,Ne," "),H=iu(H,De," "),H=iu(H,Be," "),H},Yt=function(H){var Y;H.normalize();const ce=R?R(H):H.ownerDocument,xe=U.call(ce||H,H,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let Ie=xe.nextNode();for(;Ie;)Ie.data=hn(Ie.data),Ie=xe.nextNode();const Qe=(Y=H.querySelectorAll)===null||Y===void 0?void 0:Y.call(H,"template");Qe&&xa(Qe,$t=>{or($t.content)&&Yt($t.content)})},zn=function(H){const Y=$?$(H):null;return typeof Y!="string"||Ct(Y)!=="form"?!1:typeof H.nodeName!="string"||typeof H.textContent!="string"||typeof H.removeChild!="function"||H.attributes!==T(H)||typeof H.removeAttribute!="function"||typeof H.setAttribute!="function"||typeof H.namespaceURI!="string"||typeof H.insertBefore!="function"||typeof H.hasChildNodes!="function"||H.nodeType!==j(H)||H.childNodes!==x(H)},or=function(H){if(!j||typeof H!="object"||H===null)return!1;try{return j(H)===No.documentFragment}catch{return!1}},br=function(H){if(!j||typeof H!="object"||H===null)return!1;try{return typeof j(H)=="number"}catch{return!1}};function pr(Te,H,Y){Te.length!==0&&xa(Te,ce=>{ce.call(t,H,Y,le)})}const Gr=function(H,Y){return!!(nn&&H.hasChildNodes()&&!br(H.firstElementChild)&&Ur(Y1,H.textContent)&&Ur(Y1,H.innerHTML)||nn&&H.namespaceURI===Oe&&OB[Y]&&(br(H.firstElementChild)||typeof H.textContent=="string"&&Ur(MB[Y],H.textContent))||H.nodeType===No.processingInstruction||nn&&H.nodeType===No.comment&&Ur(X1,H.data))},ro=function(H,Y){if(H instanceof RegExp)return Ur(H,Y);if(H instanceof Function){for(var ce=arguments.length,xe=new Array(ce>2?ce-2:0),Ie=2;Ie<ce;Ie++)xe[Ie-2]=arguments[Ie];return!!H(Y,...xe)}return!1},Ro=function(H,Y,ce){if(!en[Y]&&He(Y)&&ro(rt.tagNameCheck,Y))return!1;if(we&&!zt[Y]){const xe=N(H),Ie=x(H);if(Ie&&xe){const Qe=Ie.length;for(let $t=Qe-1;$t>=0;--$t){const ut=H===ce?y(Ie[$t],!0):Ie[$t];xe.insertBefore(ut,v(H))}}}return Bt(H),!0},$r=function(H,Y,ce,xe){return H.length===0?Y:Y===ce||Y===xe?To(Y):Y},G=function(H,Y){return H===Y||N(H)!==null?!1:(Ye&&yt(H),!0)},me=function(H,Y){if(pr(he.beforeSanitizeElements,H,null),G(H,Y))return!0;if(zn(H))return Bt(H),!0;const ce=Ct(I(H));if(_e=$r(he.uponSanitizeElement,_e,be,gt),pr(he.uponSanitizeElement,H,{tagName:ce,allowedTags:_e}),G(H,Y))return!0;if(Gr(H,ce))return Bt(H),!0;if(en[ce]||!(Et.tagCheck instanceof Function&&Et.tagCheck(ce))&&!_e[ce]){const Ie=Ro(H,ce,Y);return Ie===!1&&pr(he.afterSanitizeElements,H,null),Ie}if(A(H)===No.element&&!Qn(H)||(ce==="noscript"||ce==="noembed"||ce==="noframes")&&Ur(IB,H.innerHTML))return Bt(H),!0;if(Ge&&H.nodeType===No.text){const Ie=hn(H.textContent);H.textContent!==Ie&&(su(t.removed,{element:H.cloneNode()}),H.textContent=Ie)}return pr(he.afterSanitizeElements,H,null),!1},Je=function(H,Y,ce){if(Xt[Y]||rn(Y,H)||Wt&&(Y==="id"||Y==="name")&&(ce in n||ce in qe))return!1;const xe=$e[Y]||Et.attributeCheck instanceof Function&&Et.attributeCheck(Y,H);return Qt&&Ur(Z,Y)||Ke&&Ur(J,Y)?!0:xe?Se[Y]||Ur(ye,iu(ce,de,""))||(Y==="src"||Y==="xlink:href"||Y==="href")&&H!=="script"&&U1(ce,"data:")===0&&D[H]||Ot&&!Ur(pe,iu(ce,de,""))?!0:!ce:He(H)&&ro(rt.tagNameCheck,H)&&ro(rt.attributeNameCheck,Y,H)||Y==="is"&&rt.allowCustomizedBuiltInElements&&ro(rt.tagNameCheck,ce)},Ve=kn({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),He=function(H){return!Ve[hu(H)]&&Ur(ie,H)},bn=function(H,Y,ce,xe){if(M&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!ce)switch(p.getAttributeType(H,Y)){case"TrustedHTML":return V(xe);case"TrustedScriptURL":return te(xe)}return xe},an=function(H,Y,ce,xe){try{ce?H.setAttributeNS(ce,Y,xe):H.setAttribute(Y,xe),zn(H)?Bt(H):F1(t.removed)}catch{Le(Y,H)}},cn=function(H){pr(he.beforeSanitizeAttributes,H,null);const Y=H.attributes;if(!Y||zn(H))return;$e=$r(he.uponSanitizeAttribute,$e,Ze,Vt);const ce={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$e,forceKeepAttr:void 0};let xe=Y.length;const Ie=Ct(H.nodeName);for(;xe--;){const Qe=Y[xe],$t=Qe.name,ut=Qe.namespaceURI,Zn=Qe.value,Sn=Ct($t),ei=Zn;let Hn=$t==="value"?ei:pB(ei);if(ce.attrName=Sn,ce.attrValue=Hn,ce.keepAttr=!0,ce.forceKeepAttr=void 0,pr(he.uponSanitizeAttribute,H,ce),Hn=ce.attrValue,Dn&&(Sn==="id"||Sn==="name")&&U1(Hn,ne)!==0&&(Le($t,H,Qe),Hn=ne+Hn),nn&&Ur(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Hn)){Le($t,H,Qe);continue}if(Sn==="attributename"&&B1(Hn,"href")){Le($t,H,Qe);continue}if(!ce.forceKeepAttr){if(!ce.keepAttr){Le($t,H,Qe);continue}if(!Zt&&Ur(RB,Hn)){Le($t,H,Qe);continue}if(Ge&&(Hn=hn(Hn)),!Je(Ie,Sn,Hn)){Le($t,H,Qe);continue}Hn=bn(Ie,Sn,ut,Hn),Hn!==ei&&an(H,$t,ut,Hn)}}pr(he.afterSanitizeAttributes,H,null)},sr=function(H){let Y=null;const ce=Zr(H);for(pr(he.beforeSanitizeShadowDOM,H,null);Y=ce.nextNode();)if(pr(he.uponSanitizeShadowNode,Y,null),me(Y,H),cn(Y),or(Y.content)&&sr(Y.content),A(Y)===No.element){const xe=S(Y);or(xe)&&(mr(xe),sr(xe))}pr(he.afterSanitizeShadowDOM,H,null)},mr=function(H){const Y=[{node:H,shadow:null}];for(;Y.length>0;){const ce=Y.pop();if(ce.shadow){sr(ce.shadow);continue}const xe=ce.node,Qe=A(xe)===No.element,$t=x(xe);if($t)for(let ut=$t.length-1;ut>=0;--ut)Y.push({node:$t[ut],shadow:null});if(Qe){const ut=$?$(xe):null;if(typeof ut=="string"&&Ct(ut)==="template"){const Zn=xe.content;or(Zn)&&Y.push({node:Zn,shadow:null})}}if(Qe){const ut=S(xe);or(ut)&&Y.push({node:null,shadow:ut},{node:ut,shadow:null})}}};return t.sanitize=function(Te){let H=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Y=null,ce=null,xe=null,Ie=null;if(et=!Te,et&&(Te="<!-->"),typeof Te!="string"&&!br(Te)&&(Te=yB(Te),typeof Te!="string"))throw va("dirty is not a string, aborting");if(!t.isSupported)return Te;It?(_e=gt,$e=Vt):pt(H),(he.uponSanitizeElement.length>0||he.uponSanitizeAttribute.length>0)&&(_e=To(_e)),he.uponSanitizeAttribute.length>0&&($e=To($e)),t.removed=[];const Qe=Ye&&typeof Te!="string"&&br(Te);if(Qe){Gt(Te);const Zn=I(Te);if(typeof Zn=="string"){const Sn=Ct(Zn);if(!_e[Sn]||en[Sn])throw ve(Te),va("root node is forbidden and cannot be sanitized in-place")}if(zn(Te))throw ve(Te),va("root node is clobbered and cannot be sanitized in-place");try{mr(Te)}catch(Sn){throw ve(Te),Sn}}else if(br(Te))Y=Jn("<!---->"),ce=Y.ownerDocument.importNode(Te,!0),ce.nodeType===No.element&&ce.nodeName==="BODY"||ce.nodeName==="HTML"?Y=ce:Y.appendChild(ce),mr(ce);else{if(!Ce&&!Ge&&!pn&&Te.indexOf("<")===-1)return M&&Dt?V(Te):Te;if(Y=Jn(Te),!Y)return Ce?null:Dt?P:""}Y&&Cn&&Bt(Y.firstChild);const $t=Qe?Te:Y;try{const Zn=Zr($t);for(;xe=Zn.nextNode();)me(xe,$t),cn(xe),or(xe.content)&&sr(xe.content)}catch(Zn){throw Qe&&(ve(Te),xa(t.removed,Sn=>{Sn.element&&yt(Sn.element)})),Zn}if(Qe)return xa(t.removed,Zn=>{Zn.element&&yt(Zn.element)}),Ge&&Yt(Te),Te;if(Ce){if(Ge&&Yt(Y),Pt)for(Ie=B.call(Y.ownerDocument);Y.firstChild;)Ie.appendChild(Y.firstChild);else Ie=Y;return($e.shadowroot||$e.shadowrootmode)&&(Ie=ue.call(r,Ie,!0)),Ie}let ut=pn?Y.outerHTML:Y.innerHTML;return pn&&_e["!doctype"]&&Y.ownerDocument&&Y.ownerDocument.doctype&&Y.ownerDocument.doctype.name&&Ur(CB,Y.ownerDocument.doctype.name)&&(ut="<!DOCTYPE "+Y.ownerDocument.doctype.name+`>
138
- `+ut),Ge&&(ut=hn(ut)),M&&Dt?V(ut):ut},t.setConfig=function(){let Te=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};pt(Te),It=!0,gt=_e,Vt=$e},t.clearConfig=function(){le=null,It=!1,gt=null,Vt=null,M=F,P=""},t.isValidAttribute=function(Te,H,Y){le||pt({});const ce=Ct(Te),xe=Ct(H);return Je(ce,xe,Y)},t.addHook=function(Te,H){typeof H=="function"&&po(he,Te)&&su(he[Te],H)},t.removeHook=function(Te,H){if(po(he,Te)){if(H!==void 0){const Y=fB(he[Te],H);return Y===-1?void 0:hB(he[Te],Y,1)[0]}return F1(he[Te])}},t.removeHooks=function(Te){po(he,Te)&&(he[Te]=[])},t.removeAllHooks=function(){he=Q1()},t}var DB=l$();function rv(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Xa=rv();function u$(e){Xa=e}var _a={exec:()=>null};function Ac(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),o=t[r];return o||(o=e(r),t[r]=o),o}}function ln(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(o,s)=>{let a=typeof s=="string"?s:s.source;return a=a.replace(Wr.caret,"$1"),n=n.replace(o,a),r},getRegex:()=>new RegExp(n,t)};return r}var zB=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Wr={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=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Ac(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Ac(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Ac(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Ac(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Ac(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:Ac(e=>new RegExp(`^ {0,${e}}>`))},FB=/^(?:[ \t]*(?:\n|$))+/,BB=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,UB=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ad=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,HB=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ov=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,d$=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,f$=ln(d$).replace(/bull/g,ov).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}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),WB=ln(d$).replace(/bull/g,ov).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}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),sv=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,KB=/^[^\n]+/,iv=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,qB=ln(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",iv).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ZB=ln(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,ov).getRegex(),$p="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",av=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,GB=ln("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\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",av).replace("tag",$p).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),h$=e=>ln(sv).replace("hr",ad).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",e).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",$p).getRegex(),VB=h$(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),YB=h$(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),XB=ln(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",YB).getRegex(),cv={blockquote:XB,code:BB,def:qB,fences:UB,heading:HB,hr:ad,html:GB,lheading:f$,list:ZB,newline:FB,paragraph:VB,table:_a,text:KB},J1=ln("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ad).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",$p).getRegex(),QB={...cv,lheading:WB,table:J1,paragraph:ln(sv).replace("hr",ad).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",J1).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",$p).getRegex()},JB={...cv,html:ln(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",av).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:_a,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ln(sv).replace("hr",ad).replace("heading",` *#{1,6} *[^
139
- ]`).replace("lheading",f$).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},eU=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,tU=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,p$=/^( {2,}|\\)\n(?!\s*$)/,nU=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Js=/[\p{P}\p{S}]/u,pl=/[\s\p{P}\p{S}]/u,cd=/[^\s\p{P}\p{S}]/u,rU=ln(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,pl).getRegex(),oU=/[\p{Pi}\p{Ps}"']/u,m$=/(?!~)[\p{P}\p{S}]/u,sU=/(?!~)[\s\p{P}\p{S}]/u,iU=/(?:[^\s\p{P}\p{S}]|~)/u,aU=ln(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",zB?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),g$=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,cU=ln(g$,"u").replace(/punct/g,Js).getRegex(),lU=ln(g$,"u").replace(/punct/g,m$).getRegex(),uU=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,dU=ln(uU,"u").replace(/openQuote/g,oU).replace(/punct/g,Js).getRegex(),k$="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",fU=ln(k$,"gu").replace(/notPunctSpace/g,cd).replace(/punctSpace/g,pl).replace(/punct/g,Js).getRegex(),hU=ln(k$,"gu").replace(/notPunctSpace/g,iU).replace(/punctSpace/g,sU).replace(/punct/g,m$).getRegex(),pU="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",mU=ln(pU,"gu").replace(/notPunctSpace/g,cd).replace(/punctSpace/g,pl).replace(/punct/g,Js).getRegex(),gU=ln("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,cd).replace(/punctSpace/g,pl).replace(/punct/g,Js).getRegex(),kU="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",wU=ln(kU,"gu").replace(/notPunctSpace/g,cd).replace(/punctSpace/g,pl).replace(/punct/g,Js).getRegex(),yU=ln(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Js).getRegex(),vU="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",bU=ln(vU,"gu").replace(/notPunctSpace/g,cd).replace(/punctSpace/g,pl).replace(/punct/g,Js).getRegex(),xU=ln(/\\(punct)/,"gu").replace(/punct/g,Js).getRegex(),EU=ln(/^<(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(),SU=ln(av).replace("(?:-->|$)","-->").getRegex(),_U=ln("^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",SU).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Sh=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,NU=ln(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Sh).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),w$=ln(/^!?\[(label)\]\[(ref)\]/).replace("label",Sh).replace("ref",iv).getRegex(),y$=ln(/^!?\[(ref)\](?:\[\])?/).replace("ref",iv).getRegex(),TU=ln("reflink|nolink(?!\\()","g").replace("reflink",w$).replace("nolink",y$).getRegex(),eE=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,lv={_backpedal:_a,anyPunctuation:xU,autolink:EU,blockSkip:aU,br:p$,code:tU,del:_a,delLDelim:_a,delRDelim:_a,emStrongLDelim:cU,emStrongRDelimAst:fU,emStrongRDelimUnd:gU,escape:eU,link:NU,nolink:y$,punctuation:rU,reflink:w$,reflinkSearch:TU,tag:_U,text:nU,url:_a},jU={...lv,emStrongLDelim:dU,emStrongRDelimAst:mU,emStrongRDelimUnd:wU,link:ln(/^!?\[(label)\]\((.*?)\)/).replace("label",Sh).getRegex(),reflink:ln(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Sh).getRegex()},Jk={...lv,emStrongRDelimAst:hU,emStrongLDelim:lU,delLDelim:yU,delRDelim:bU,url:ln(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",eE).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:ln(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",eE).getRegex()},$U={...Jk,br:ln(p$).replace("{2,}","*").getRegex(),text:ln(Jk.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Pf={normal:cv,gfm:QB,pedantic:JB},cu={normal:lv,gfm:Jk,breaks:$U,pedantic:jU},CU={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},tE=e=>CU[e];function gs(e,t){if(t){if(Wr.escapeTest.test(e))return e.replace(Wr.escapeReplace,tE)}else if(Wr.escapeTestNoEncode.test(e))return e.replace(Wr.escapeReplaceNoEncode,tE);return e}function nE(e){try{e=encodeURI(e).replace(Wr.percentDecode,"%")}catch{return null}return e}function rE(e,t){var s;let n=e.replace(Wr.findPipe,(a,l,u)=>{let f=!1,h=l;for(;--h>=0&&u[h]==="\\";)f=!f;return f?"|":" |"}),r=n.split(Wr.splitPipe),o=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(Wr.slashPipe,"|");return r}function Ti(e,t,n){let r=e.length;if(r===0)return"";let o=0;for(;o<r&&e.charAt(r-o-1)===t;)o++;return e.slice(0,r-o)}function oE(e){let t=e.split(`
140
- `),n=t.length-1;for(;n>=0&&Wr.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
141
- `)}function AU(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 IU(e,t=0){let n=t,r="";for(let o of e)if(o===" "){let s=4-n%4;r+=" ".repeat(s),n+=s}else r+=o,n++;return r}function sE(e,t,n,r,o){let s=t.href,a=t.title||null,l=e[1].replace(o.other.outputLinkReplace,"$1"),u=e[0].charAt(0)==="!";r.state.inLink=!0;let f=r.state.linkEmitted,h=r.state.inRawBlock;r.state.linkEmitted=!1;let p=r.inlineTokens(l),g=r.state.linkEmitted;if(r.state.linkEmitted=f,r.state.inLink=!1,!u){if(g){r.state.inRawBlock=h;return}r.state.linkEmitted=!0}return{type:u?"image":"link",raw:n,href:s,title:a,text:l,tokens:p}}function RU(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let o=r[1];return t.split(`
142
- `).map(s=>{let a=s.match(n.other.beginningSpace);if(a===null)return s;let[l]=a;return l.length>=o.length?s.slice(o.length):s}).join(`
143
- `)}var _h=class{constructor(e){_t(this,"options");_t(this,"rules");_t(this,"lexer");this.options=e||Xa}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 n=this.options.pedantic?t[0]:oE(t[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=RU(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=Ti(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:Ti(t[0],`
144
- `),depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Ti(t[0],`
145
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Ti(t[0],`
146
- `).split(`
147
- `),r="",o="",s=[];for(;n.length>0;){let a=!1,l=[],u;for(u=0;u<n.length;u++)if(this.rules.other.blockquoteStart.test(n[u]))l.push(n[u]),a=!0;else if(!a)l.push(n[u]);else break;n=n.slice(u);let f=l.join(`
148
- `),h=f.replace(this.rules.other.blockquoteSetextReplace,`
149
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
150
- ${f}`:f,o=o?`${o}
151
- ${h}`:h;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,s,!0),this.lexer.state.top=p,n.length===0)break;let g=s.at(-1);if((g==null?void 0:g.type)==="code")break;if((g==null?void 0:g.type)==="blockquote"){let y=g,w=n.join(`
152
- `),v=y.raw+`
153
- `+w.replace(this.rules.other.blockquoteSetextReplace2,""),x=this.blockquote(v);s[s.length-1]=x,r=`${r}
154
- ${w}`,o=o.substring(0,o.length-y.text.length)+x.text;break}else if((g==null?void 0:g.type)==="list"){let y=g,w=y.raw+`
155
- `+n.join(`
156
- `),v=this.list(w);s[s.length-1]=v,r=r.substring(0,r.length-g.raw.length)+v.raw,o=o.substring(0,o.length-y.raw.length)+v.raw,n=w.substring(s.at(-1).raw.length).split(`
157
- `);continue}}return{type:"blockquote",raw:r,tokens:s,text:o}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,o={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 s=this.rules.other.listItemRegex(n),a=!1;for(;e;){let u=!1,f="",h="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;f=t[0],e=e.substring(f.length);let p=IU(t[2].split(`
158
- `,1)[0],t[1].length),g=e.split(`
159
- `,1)[0],y=!p.trim(),w=0;if(this.options.pedantic?(w=2,h=p.trimStart()):y?w=t[1].length+1:(w=p.search(this.rules.other.nonSpaceChar),w=w>4?1:w,h=p.slice(w),w+=t[1].length),y&&this.rules.other.blankLine.test(g)&&(f+=g+`
160
- `,e=e.substring(g.length+1),u=!0),!u){let v=this.rules.other.nextBulletRegex(w),x=this.rules.other.hrRegex(w),N=this.rules.other.fencesBeginRegex(w),S=this.rules.other.headingBeginRegex(w),T=this.rules.other.htmlBeginRegex(w),j=this.rules.other.blockquoteBeginRegex(w);for(;e;){let $=e.split(`
161
- `,1)[0],R;if(g=$,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),R=g):R=g.replace(this.rules.other.tabCharGlobal," "),N.test(g)||S.test(g)||T.test(g)||j.test(g)||v.test(g)||x.test(g))break;if(R.search(this.rules.other.nonSpaceChar)>=w||!g.trim())h+=`
162
- `+R.slice(w);else{if(y||p.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||N.test(p)||S.test(p)||x.test(p))break;h+=`
163
- `+g}y=!g.trim(),f+=$+`
164
- `,e=e.substring($.length+1),p=R.slice(w)}}o.loose||(a?o.loose=!0:this.rules.other.doubleBlankLine.test(f)&&(a=!0)),o.items.push({type:"list_item",raw:f,task:!!this.options.gfm&&this.rules.other.listIsTask.test(h),loose:!1,text:h,tokens:[]}),o.raw+=f}let l=o.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let u of o.items)if(this.lexer.state.top=!1,u.tokens=this.lexer.blockTokens(u.text,[]),!o.loose){let f=u.tokens.filter(p=>p.type==="space"),h=f.length>0&&f.some(p=>this.rules.other.anyLine.test(p.raw));o.loose=h}for(let u of o.items){let f=u.tokens[0];if(u.task&&((f==null?void 0:f.type)==="text"||(f==null?void 0:f.type)==="paragraph")){u.text=u.text.replace(this.rules.other.listReplaceTask,""),f.raw=f.raw.replace(this.rules.other.listReplaceTask,""),f.text=f.text.replace(this.rules.other.listReplaceTask,"");for(let p=this.lexer.inlineQueue.length-1;p>=0;p--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[p].src)){this.lexer.inlineQueue[p].src=this.lexer.inlineQueue[p].src.replace(this.rules.other.listReplaceTask,"");break}let h=this.rules.other.listTaskCheckbox.exec(u.raw);if(h){let p={type:"checkbox",raw:h[0]+" ",checked:h[0]!=="[ ]"};u.checked=p.checked,o.loose?u.tokens[0]&&["paragraph","text"].includes(u.tokens[0].type)&&"tokens"in u.tokens[0]&&u.tokens[0].tokens?(u.tokens[0].raw=p.raw+u.tokens[0].raw,u.tokens[0].text=p.raw+u.tokens[0].text,u.tokens[0].tokens.unshift(p)):u.tokens.unshift({type:"paragraph",raw:p.raw,text:p.raw,tokens:[p]}):u.tokens.unshift(p)}}else u.task&&(u.task=!1)}if(o.loose)for(let u of o.items){u.loose=!0;for(let f of u.tokens)f.type==="text"&&(f.type="paragraph")}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=oE(t[0]);return{type:"html",block:!0,raw:n,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:n}}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",o=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:Ti(t[0],`
165
- `),href:r,title:o}}}table(e){var a;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=rE(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=(a=t[3])!=null&&a.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
166
- `):[],s={type:"table",raw:Ti(t[0],`
167
- `),header:[],align:[],rows:[]};if(n.length===r.length){for(let l of r)this.rules.other.tableAlignRight.test(l)?s.align.push("right"):this.rules.other.tableAlignCenter.test(l)?s.align.push("center"):this.rules.other.tableAlignLeft.test(l)?s.align.push("left"):s.align.push(null);for(let l=0;l<n.length;l++)s.header.push({text:n[l],tokens:this.lexer.inline(n[l]),header:!0,align:s.align[l]});for(let l of o)s.rows.push(rE(l,s.header.length).map((u,f)=>({text:u,tokens:this.lexer.inline(u),header:!1,align:s.align[f]})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:Ti(t[0],`
168
- `),depth:t[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
169
- `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}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 n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let s=Ti(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{let s=AU(t[2],"()");if(s===-2)return;if(s>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let r=t[2],o="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],o=s[3])}else o=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),sE(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:o&&o.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 r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),o=t[r.toLowerCase()];if(!o){let s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return sE(n,o,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 o=[...r[0]].length-1,s,a,l=o,u=0,f=r[0][0],h=n===f,p=f==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,t=t.slice(-1*e.length+o);(r=p.exec(t))!==null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(a=[...s].length,r[3]||r[4]){l+=a;continue}else if(r[5]||r[6]){if(o%3&&!((o+a)%3)){u+=a;continue}if(h)break}if(l-=a,l>0)continue;a=Math.min(a,a+l+u);let g=[...r[0]][0].length,y=e.slice(0,o+r.index+g+a);if(Math.min(o,a)%2){let v=y.slice(1,-1);return{type:"em",raw:y,text:v,tokens:this.lexer.inlineTokens(v)}}let w=y.slice(2,-2);return{type:"strong",raw:y,text:w,tokens:this.lexer.inlineTokens(w)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),o=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&o&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}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 o=[...r[0]].length-1,s,a,l=o,u=this.rules.inline.delRDelim;for(u.lastIndex=0,t=t.slice(-1*e.length+o);(r=u.exec(t))!==null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(a=[...s].length,a!==o))continue;if(r[3]||r[4]){l+=a;continue}if(l-=a,l>0)continue;a=Math.min(a,a+l);let f=[...r[0]][0].length,h=e.slice(0,o+r.index+f+a),p=h.slice(o,-o);return{type:"del",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let r,o;if(t[2]==="@")r=t[0],o="mailto:"+r;else{let s;do s=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(s!==t[0]);r=t[0],t[1]==="www."?o="http://"+t[0]:o=t[0]}return{type:"link",raw:t[0],text:r,href:o,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},ns=class ew{constructor(t){_t(this,"tokens");_t(this,"options");_t(this,"state");_t(this,"inlineQueue");_t(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Xa,this.options.tokenizer=this.options.tokenizer||new _h,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,top:!0};let n={other:Wr,block:Pf.normal,inline:cu.normal};this.options.pedantic?(n.block=Pf.pedantic,n.inline=cu.pedantic):this.options.gfm&&(n.block=Pf.gfm,this.options.breaks?n.inline=cu.breaks:n.inline=cu.gfm),this.tokenizer.rules=n}static get rules(){return{block:Pf,inline:cu}}static lex(t,n){return new ew(n).lex(t)}static lexInline(t,n){return new ew(n).inlineTokens(t)}lex(t){t=t.replace(Wr.carriageReturn,`
170
- `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],r=!1){var s,a,l;this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(Wr.tabCharGlobal," ").replace(Wr.spaceLine,""));let o=1/0;for(;t;){if(t.length<o)o=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let u;if((a=(s=this.options.extensions)==null?void 0:s.block)!=null&&a.some(h=>(u=h.call({lexer:this},t,n))?(t=t.substring(u.raw.length),n.push(u),!0):!1))continue;if(u=this.tokenizer.space(t)){t=t.substring(u.raw.length);let h=n.at(-1);u.raw.length===1&&h!==void 0?h.raw+=`
171
- `:n.push(u);continue}if(u=this.tokenizer.code(t)){t=t.substring(u.raw.length);let h=n.at(-1);(h==null?void 0:h.type)==="paragraph"||(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
172
- `)?"":`
173
- `)+u.raw,h.text+=`
174
- `+u.text,this.inlineQueue.at(-1).src=h.text):n.push(u);continue}if(u=this.tokenizer.fences(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.heading(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.hr(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.blockquote(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.list(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.html(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.def(t)){t=t.substring(u.raw.length);let h=n.at(-1);(h==null?void 0:h.type)==="paragraph"||(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
175
- `)?"":`
176
- `)+u.raw,h.text+=`
177
- `+u.raw,this.inlineQueue.at(-1).src=h.text):this.tokens.links[u.tag]||(this.tokens.links[u.tag]={href:u.href,title:u.title},n.push(u));continue}if(u=this.tokenizer.table(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.lheading(t)){t=t.substring(u.raw.length),n.push(u);continue}let f=t;if((l=this.options.extensions)!=null&&l.startBlock){let h=1/0,p=t.slice(1),g;this.options.extensions.startBlock.forEach(y=>{g=y.call({lexer:this},p),typeof g=="number"&&g>=0&&(h=Math.min(h,g))}),h<1/0&&h>=0&&(f=t.substring(0,h+1))}if(this.state.top&&(u=this.tokenizer.paragraph(f))){let h=n.at(-1);r&&(h==null?void 0:h.type)==="paragraph"?(h.raw+=(h.raw.endsWith(`
178
- `)?"":`
179
- `)+u.raw,h.text+=`
180
- `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=h.text):n.push(u),r=f.length!==t.length,t=t.substring(u.raw.length);continue}if(u=this.tokenizer.text(t)){t=t.substring(u.raw.length);let h=n.at(-1);(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
181
- `)?"":`
182
- `)+u.raw,h.text+=`
183
- `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=h.text):n.push(u);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}linkInText(t){if(!t.includes("["))return!1;let n=this.tokenizer.rules.inline.link;for(let r of t.matchAll(this.tokenizer.rules.inline.blockSkip))if(n.test(r[0])&&t.charAt(r.index-1)!=="!")return!0;for(let r of t.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let o=r[0],s=o.lastIndexOf("[");if(!(o.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,o.slice(s+1,-1)))&&!(s>1&&this.linkInText(o.slice(1,s-1))))return!0}return!1}inlineTokens(t,n=[]){var l,u,f,h,p;this.tokenizer.lexer=this;let r=t;if(this.tokens.links&&t.includes("[")){let g=this.tokenizer.rules.inline.reflinkSearch,y=w=>{let v=w.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,w.slice(v+1,-1)))return w;if(v>1&&w.charAt(0)!=="!"){let x=w.slice(1,v-1);if(this.linkInText(x))return"["+x.replace(g,y)+"]["+"a".repeat(w.length-v-2)+"]"}return"["+"a".repeat(w.length-2)+"]"};r=r.replace(g,y)}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,g=>"+".repeat(g.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(g,y,w)=>{let v=w?w.length:0;return g.slice(0,v)+"["+"a".repeat(g.length-v-2)+"]"}),r=((u=(l=this.options.hooks)==null?void 0:l.emStrongMask)==null?void 0:u.call({lexer:this},r))??r;let o=!1,s="",a=1/0;for(;t;){if(t.length<a)a=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}o||(s=""),o=!1;let g;if((h=(f=this.options.extensions)==null?void 0:f.inline)!=null&&h.some(w=>(g=w.call({lexer:this},t,n))?(t=t.substring(g.raw.length),n.push(g),!0):!1))continue;if(g=this.tokenizer.escape(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.tag(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.link(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(g.raw.length);let w=n.at(-1);g.type==="text"&&(w==null?void 0:w.type)==="text"?(w.raw+=g.raw,w.text+=g.text):n.push(g);continue}if(g=this.tokenizer.emStrong(t,r,s)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.codespan(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.br(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.del(t,r,s)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.autolink(t)){t=t.substring(g.raw.length),n.push(g);continue}if(!this.state.inLink&&(g=this.tokenizer.url(t))){t=t.substring(g.raw.length),n.push(g);continue}let y=t;if((p=this.options.extensions)!=null&&p.startInline){let w=1/0,v=t.slice(1),x;this.options.extensions.startInline.forEach(N=>{x=N.call({lexer:this},v),typeof x=="number"&&x>=0&&(w=Math.min(w,x))}),w<1/0&&w>=0&&(y=t.substring(0,w+1))}if(g=this.tokenizer.inlineText(y)){t=t.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(s=g.raw.slice(-1)),o=!0;let w=n.at(-1);(w==null?void 0:w.type)==="text"?(w.raw+=g.raw,w.text+=g.text):n.push(g);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return n}infiniteLoopError(t){let n="Infinite loop on byte: "+t;if(this.options.silent)console.error(n);else throw new Error(n)}},Uu=class{constructor(e){_t(this,"options");_t(this,"parser");this.options=e||Xa}space(e){return""}code({text:e,lang:t,escaped:n}){var s;let r=(s=(t||"").match(Wr.notSpaceStart))==null?void 0:s[0],o=e.replace(Wr.endingNewline,"")+`
184
- `;return r?'<pre><code class="language-'+gs(r)+'">'+(n?o:gs(o,!0))+`</code></pre>
185
- `:"<pre><code>"+(n?o:gs(o,!0))+`</code></pre>
186
- `}blockquote({tokens:e}){return`<blockquote>
187
- ${this.parser.parse(e)}</blockquote>
188
- `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
189
- `}hr(e){return`<hr>
190
- `}list(e){let t=e.ordered,n=e.start,r="";for(let a=0;a<e.items.length;a++){let l=e.items[a];r+=this.listitem(l)}let o=t?"ol":"ul",s=t&&n!==1?' start="'+n+'"':"";return"<"+o+s+`>
191
- `+r+"</"+o+`>
192
- `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
193
- `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
194
- `}table(e){let t="",n="";for(let o=0;o<e.header.length;o++)n+=this.tablecell(e.header[o]);t+=this.tablerow({text:n});let r="";for(let o=0;o<e.rows.length;o++){let s=e.rows[o];n="";for(let a=0;a<s.length;a++)n+=this.tablecell(s[a]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
195
- <thead>
196
- `+t+`</thead>
197
- `+r+`</table>
198
- `}tablerow({text:e}){return`<tr>
199
- ${e}</tr>
200
- `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
201
- `}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>${gs(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),o=nE(e);if(o===null)return r;e=o;let s='<a href="'+e+'"';return t&&(s+=' title="'+gs(t)+'"'),s+=">"+r+"</a>",s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let o=nE(e);if(o===null)return gs(n);e=o;let s=`<img src="${e}" alt="${gs(n)}"`;return t&&(s+=` title="${gs(t)}"`),s+=">",s}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:gs(e.text)}},uv=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}},rs=class tw{constructor(t){_t(this,"options");_t(this,"renderer");_t(this,"textRenderer");this.options=t||Xa,this.options.renderer=this.options.renderer||new Uu,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new uv}static parse(t,n){return new tw(n).parse(t)}static parseInline(t,n){return new tw(n).parseInline(t)}parse(t){var r,o;this.renderer.parser=this;let n="";for(let s=0;s<t.length;s++){let a=t[s];if((o=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&o[a.type]){let u=a,f=this.options.extensions.renderers[u.type].call({parser:this},u);if(f!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(u.type)){n+=f||"";continue}}let l=a;switch(l.type){case"space":{n+=this.renderer.space(l);break}case"hr":{n+=this.renderer.hr(l);break}case"heading":{n+=this.renderer.heading(l);break}case"code":{n+=this.renderer.code(l);break}case"table":{n+=this.renderer.table(l);break}case"blockquote":{n+=this.renderer.blockquote(l);break}case"list":{n+=this.renderer.list(l);break}case"checkbox":{n+=this.renderer.checkbox(l);break}case"html":{n+=this.renderer.html(l);break}case"def":{n+=this.renderer.def(l);break}case"paragraph":{n+=this.renderer.paragraph(l);break}case"text":{n+=this.renderer.text(l);break}default:{let u='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return n}parseInline(t,n=this.renderer){var o,s;this.renderer.parser=this;let r="";for(let a=0;a<t.length;a++){let l=t[a];if((s=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&s[l.type]){let f=this.options.extensions.renderers[l.type].call({parser:this},l);if(f!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(l.type)){r+=f||"";continue}}let u=l;switch(u.type){case"escape":{r+=n.text(u);break}case"html":{r+=n.html(u);break}case"link":{r+=n.link(u);break}case"image":{r+=n.image(u);break}case"checkbox":{r+=n.checkbox(u);break}case"strong":{r+=n.strong(u);break}case"em":{r+=n.em(u);break}case"codespan":{r+=n.codespan(u);break}case"br":{r+=n.br(u);break}case"del":{r+=n.del(u);break}case"text":{r+=n.text(u);break}default:{let f='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(f),"";throw new Error(f)}}}return r}},Wf,pu=(Wf=class{constructor(e){_t(this,"options");_t(this,"block");this.options=e||Xa}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?ns.lex:ns.lexInline}provideParser(e=this.block){return e?rs.parse:rs.parseInline}},_t(Wf,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),_t(Wf,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Wf),OU=class{constructor(...e){_t(this,"defaults",rv());_t(this,"options",this.setOptions);_t(this,"parse",this.parseMarkdown(!0));_t(this,"parseInline",this.parseMarkdown(!1));_t(this,"Parser",rs);_t(this,"Renderer",Uu);_t(this,"TextRenderer",uv);_t(this,"Lexer",ns);_t(this,"Tokenizer",_h);_t(this,"Hooks",pu);this.use(...e)}walkTokens(e,t){var r,o;let n=[];for(let s of e)switch(n=n.concat(t.call(this,s)),s.type){case"table":{let a=s;for(let l of a.header)n=n.concat(this.walkTokens(l.tokens,t));for(let l of a.rows)for(let u of l)n=n.concat(this.walkTokens(u.tokens,t));break}case"list":{let a=s;n=n.concat(this.walkTokens(a.items,t));break}default:{let a=s;(o=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&o[a.type]?this.defaults.extensions.childTokens[a.type].forEach(l=>{let u=a[l].flat(1/0);n=n.concat(this.walkTokens(u,t))}):a.tokens&&(n=n.concat(this.walkTokens(a.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if("renderer"in o){let s=t.renderers[o.name];s?t.renderers[o.name]=function(...a){let l=o.renderer.apply(this,a);return l===!1&&(l=s.apply(this,a)),l}:t.renderers[o.name]=o.renderer}if("tokenizer"in o){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[o.level];s?s.unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}"childTokens"in o&&o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){let o=this.defaults.renderer||new Uu(this.defaults);for(let s in n.renderer){if(!(s in o))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let a=s,l=n.renderer[a],u=o[a];o[a]=(...f)=>{let h=l.apply(o,f);return h===!1&&(h=u.apply(o,f)),h||""}}r.renderer=o}if(n.tokenizer){let o=this.defaults.tokenizer||new _h(this.defaults);for(let s in n.tokenizer){if(!(s in o))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let a=s,l=n.tokenizer[a],u=o[a];o[a]=(...f)=>{let h=l.apply(o,f);return h===!1&&(h=u.apply(o,f)),h}}r.tokenizer=o}if(n.hooks){let o=this.defaults.hooks||new pu;for(let s in n.hooks){if(!(s in o))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let a=s,l=n.hooks[a],u=o[a];pu.passThroughHooks.has(s)?o[a]=f=>{if(this.defaults.async&&pu.passThroughHooksRespectAsync.has(s))return(async()=>{let p=await l.call(o,f);return u.call(o,p)})();let h=l.call(o,f);return u.call(o,h)}:o[a]=(...f)=>{if(this.defaults.async)return(async()=>{let p=await l.apply(o,f);return p===!1&&(p=await u.apply(o,f)),p})();let h=l.apply(o,f);return h===!1&&(h=u.apply(o,f)),h}}r.hooks=o}if(n.walkTokens){let o=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(a){let l=[];return l.push(s.call(this,a)),o&&(l=l.concat(o.call(this,a))),l}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ns.lex(e,t??this.defaults)}parser(e,t){return rs.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},o={...this.defaults,...r},s=this.onError(!!o.silent,!!o.async);if(this.defaults.async===!0&&r.async===!1)return s(new 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 s(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(o.hooks&&(o.hooks.options=o,o.hooks.block=e),o.async)return(async()=>{let a=o.hooks?await o.hooks.preprocess(t):t,l=await(o.hooks?await o.hooks.provideLexer(e):e?ns.lex:ns.lexInline)(a,o),u=o.hooks?await o.hooks.processAllTokens(l):l;o.walkTokens&&await Promise.all(this.walkTokens(u,o.walkTokens));let f=await(o.hooks?await o.hooks.provideParser(e):e?rs.parse:rs.parseInline)(u,o);return o.hooks?await o.hooks.postprocess(f):f})().catch(s);try{o.hooks&&(t=o.hooks.preprocess(t));let a=(o.hooks?o.hooks.provideLexer(e):e?ns.lex:ns.lexInline)(t,o);o.hooks&&(a=o.hooks.processAllTokens(a)),o.walkTokens&&this.walkTokens(a,o.walkTokens);let l=(o.hooks?o.hooks.provideParser(e):e?rs.parse:rs.parseInline)(a,o);return o.hooks&&(l=o.hooks.postprocess(l)),l}catch(a){return s(a)}}}onError(e,t){return n=>{if(n.message+=`
202
- Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+gs(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},Ua=new OU;function Nn(e,t){return Ua.parse(e,t)}Nn.options=Nn.setOptions=function(e){return Ua.setOptions(e),Nn.defaults=Ua.defaults,u$(Nn.defaults),Nn};Nn.getDefaults=rv;Nn.defaults=Xa;function MU(...e){return Ua.use(...e),Nn.defaults=Ua.defaults,u$(Nn.defaults),Nn}Nn.use=MU;Nn.walkTokens=function(e,t){return Ua.walkTokens(e,t)};Nn.parseInline=Ua.parseInline;Nn.Parser=rs;Nn.parser=rs.parse;Nn.Renderer=Uu;Nn.TextRenderer=uv;Nn.Lexer=ns;Nn.lexer=ns.lex;Nn.Tokenizer=_h;Nn.Hooks=pu;Nn.parse=Nn;Nn.options;Nn.setOptions;Nn.walkTokens;Nn.parseInline;rs.parse;ns.lex;const Ha=100,LU=e=>e.type==="text-delta"||e.type==="thinking-delta"||e.type==="tool-delta";function PU(e,t){if(e.worktreeId!==t.worktreeId||e.event.type!==t.event.type)return!1;switch(e.event.type){case"text-delta":return e.event.messageId===t.event.messageId;case"tool-delta":return e.event.toolId===t.event.toolId;default:return!0}}const DU={now:()=>performance.now(),after:(e,t)=>void setTimeout(t,e)};function zU(e,t=DU){let n=[],r=!1,o=Number.NEGATIVE_INFINITY;const s=()=>{if(r=!1,n.length===0)return;const a=n;n=[],o=t.now();for(const l of a)e(l)};return a=>{if(a.t==="agent"&&LU(a.event)){const l={...a,event:{...a.event}},u=t.now();if(n.length===0&&u-o>=Ha){o=u,e(l);return}const f=n[n.length-1];f&&PU(f,l)?f.event={...f.event,text:f.event.text+l.event.text}:n.push(l),r||(r=!0,t.after(Math.max(0,o+Ha-u),s));return}s(),e(a)}}const v$="#toyon-link-pending",FU=/!?\[([^[\]\n]*)(?:\]\(([^()\s]*))?$/;function BU(e){const t=e.lastIndexOf(`
203
- `)+1,n=e.slice(t),r=FU.exec(n);return!r||UU(e.slice(0,t))||HU(n.slice(0,r.index))?e:`${e.slice(0,t)}${n.slice(0,r.index)}[${r[1]}](${v$})`}function UU(e){let t=!1;for(const n of e.split(`
204
- `))/^\s*(```|~~~)/.test(n)&&(t=!t);return t}function HU(e){let t=0;for(const n of e)n==="`"&&t++;return t%2===1}const Bg="__[a-z][a-z0-9_]*[a-z0-9]__",WU=new RegExp(`^(?:${Bg}\\.)+${Bg}|^${Bg}(?=\\.\\w|\\(|["'])`),KU={name:"dunder",level:"inline",start:e=>e.indexOf("__"),tokenizer(e){const t=WU.exec(e);if(t)return{type:"dunder",raw:t[0],text:t[0]}},renderer:e=>e.text},Uo=e=>e.replace(/[&<>]/g,t=>t==="&"?"&amp;":t==="<"?"&lt;":"&gt;");function qU({text:e}){return Uo(e)}const ZU="[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})?",GU="[\\w.-]*[\\w-]",dv=`(${ZU}\\/${GU})#(\\d+)`,b$=new RegExp(`(^|[^\\w./@-])${dv}(?![\\w-])`),VU=new RegExp(`^${dv}(?![\\w-])`),YU=new RegExp(`^${dv}$`),XU=new RegExp(b$.source,"g"),QU=/^https?:\/\/\S+$/;function JU(e){const t=[];for(const n of e.matchAll(XU)){const r=n.index+(n[1]??"").length;t.push({start:r,end:n.index+n[0].length})}return t}function fv(e){const t=YU.exec(e);return t?`https://github.com/${t[1]}/issues/${t[2]}`:null}function x$(e){return QU.test(e)?e:fv(e)}function e7({text:e}){const t=`<code>${Uo(e)}</code>`,n=x$(e);return n?`<a href="${E$(n)}">${t}</a>`:t}const E$=e=>Uo(e).replace(/"/g,"&quot;"),t7={name:"githubRef",level:"inline",start:e=>{const t=b$.exec(e);return t?t.index+t[1].length:void 0},tokenizer(e){const t=VU.exec(e);if(t)return{type:"githubRef",raw:t[0],text:t[0],href:fv(t[0])}},renderer:e=>`<a href="${E$(e.href)}">${Uo(e.text)}</a>`};function n7(e){return`<div class="md-table">${r7.call(this,e)}</div>
205
- `}function r7(e){if(e.header.some(n=>n.text.trim()))return Uu.prototype.table.call(this,e);let t="";for(const n of e.rows){let r="";for(const o of n)r+=this.tablecell(o);t+=this.tablerow({text:r})}return`<table>
206
- <tbody>${t}</tbody></table>
207
- `}function o7(e){const t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const o={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},s=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),a={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},l={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,o]};o.contains.push(l);const u={match:/\\"/},f={className:"string",begin:/'/,end:/'/},h={match:/\\'/},p={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},g=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],y=e.SHEBANG({binary:`(${g.join("|")})`,relevance:10}),w={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},v=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],x=["true","false"],N={match:/(\/[a-z._-]+)+/},S=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],T=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],j=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],$=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:v,literal:x,built_in:[...S,...T,"set","shopt",...j,...$]},contains:[y,e.SHEBANG(),w,p,s,a,N,l,u,f,h,n]}}const s7=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},UNICODE_RANGE:{scope:"number",begin:/\b[Uu]\+[0-9A-Fa-f][0-9A-Fa-f?]{0,5}(-[0-9A-Fa-f][0-9A-Fa-f]{0,5})?/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),i7=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],a7=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],c7=[...i7,...a7],l7=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),u7=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),d7=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),f7=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","corner-bottom-left-shape","corner-bottom-right-shape","corner-shape","corner-top-left-shape","corner-top-right-shape","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","unicode-range","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function h7(e){const t=e.regex,n=s7(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},o="and or not only",s=/@-?\w[\w]*(-\w+)*/,a="[a-zA-Z-][a-zA-Z0-9_-]*",l=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+a,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+u7.join("|")+")"},{begin:":(:)?("+d7.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+f7.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,n.UNICODE_RANGE,...l,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...l,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:s},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:o,attribute:l7.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...l,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+c7.join("|")+")\\b"}]}}function p7(e){const s={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:s,illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"string",variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\b0[bB](_?[01])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[e.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:s,illegal:/["']/}]}]}}function m7(e){const t=e.regex,n={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:e.NUMBER_RE}]},r=e.COMMENT();r.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];const o={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},s={className:"literal",begin:/\bon|off|true|false|yes|no\b/},a={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},l={begin:/\[/,end:/\]/,contains:[r,s,o,a,n,"self"],relevance:0},u=/[A-Za-z0-9_-]+/,f=/"(\\"|[^"])*"/,h=/'[^']*'/,p=t.either(u,f,h),g=t.concat(p,"(\\s*\\.\\s*",p,")*",t.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:g,className:"attr",starts:{end:/$/,contains:[r,l,s,o,a,n]}}]}}const iE="[A-Za-z$_][0-9A-Za-z$_]*",g7=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],k7=["true","false","null","undefined","NaN","Infinity"],S$=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],_$=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],N$=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],w7=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],y7=[].concat(N$,S$,_$);function v7(e){const t=e.regex,n=(C,{after:oe})=>{const U="</"+C[0].slice(1);return C.input.indexOf(U,oe)!==-1},r=iE,o={begin:"<>",end:"</>"},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,a={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(C,oe)=>{const U=C[0].length+C.index,B=C.input[U];if(B==="<"||B===","){oe.ignoreMatch();return}B===">"&&(n(C,{after:U})||oe.ignoreMatch());let Q;const ue=C.input.substring(U);if(Q=ue.match(/^\s*=/)){oe.ignoreMatch();return}if((Q=ue.match(/^\s+extends\s+/))&&Q.index===0){oe.ignoreMatch();return}}},l={$pattern:iE,keyword:g7,literal:k7,built_in:y7,"variable.language":w7},u="[0-9](_?[0-9])*",f=`\\.(${u})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",p={className:"number",variants:[{begin:`(\\b(${h})((${f})|\\.)?|(${f}))[eE][+-]?(${u})\\b`},{begin:`\\b(${h})\\b((${f})\\b|\\.)?|(${f})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},w={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},v={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},x={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},S={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},T=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,v,x,{match:/\$\d+/},p];g.contains=T.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(T)});const j=[].concat(S,g.contains),$=j.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(j)}]),R={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:$},A={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},I={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...S$,..._$]}},M={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},P={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],illegal:/%/},F={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function q(C){return t.concat("(?!",C.join("|"),")")}const W={match:t.concat(/\b/,q([...N$,"super","import","await"].map(C=>`${C}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},ee={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},V={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},R]},te="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",K={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(te)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:$,CLASS_REFERENCE:I},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),M,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,v,x,S,{match:/\$\d+/},p,I,{scope:"attr",match:r+t.lookahead(":"),relevance:0},K,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[S,e.REGEXP_MODE,{className:"function",begin:te,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:$}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:s},{begin:a.begin,"on:begin":a.isTrulyOpeningTag,end:a.end}],subLanguage:"xml",contains:[{begin:a.begin,end:a.end,skip:!0,contains:["self"]}]}]},P,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[R,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},ee,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[R]},W,F,A,V,{match:/\$[(.]/}]}}const b7="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",x7={scope:"number",match:b7,relevance:0};function E7(e){const t={className:"attr",begin:/(("(\\.|[^\\"\r\n])*")|('(\\.|[^\\'\r\n])*'))(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],o={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc","json5"],keywords:{literal:r},contains:[t,n,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,o,x7,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function S7(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={match:/^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/},o={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},s={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},a={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},l=/[A-Za-z][A-Za-z0-9+.-]*/,u={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,l,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},f={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},h={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},p=e.inherit(f,{contains:[]}),g=e.inherit(h,{contains:[]});f.contains.push(g),h.contains.push(p);let y=[n,u];return[f,h,p,g].forEach(N=>{N.contains=N.contains.concat(y)}),y=y.concat(f,h),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:y},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:y}]}]},n,s,r,f,h,{className:"quote",begin:"^>\\s+",contains:y,end:"$"},o,u,a,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function _7(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","lazy","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],l={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","aiter","all","anext","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozendict","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","sentinel","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},u={className:"meta",begin:/^(>>>|\.\.\.) /},f={className:"subst",begin:/\{/,end:/\}/,keywords:l,illegal:/#/},h={begin:/\{\{/,relevance:0},p={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,u,h,f]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u,h,f]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,h,f]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,h,f]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},g="[0-9](_?[0-9])*",y=`(\\b(${g}))?\\.(${g})|\\b(${g})\\.`,w=`\\b|${r.join("|")}`,v={className:"number",relevance:0,variants:[{begin:`(\\b(${g})|(${y}))[eE][+-]?(${g})[jJ]?(?=${w})`},{begin:`(${y})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${w})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${w})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${w})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${w})`},{begin:`\\b(${g})[jJ](?=${w})`}]},x={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:l,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},N={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:["self",u,v,p,e.HASH_COMMENT_MODE]}]};return f.contains=[p,v,u],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:l,illegal:/(<\/|\?)|=>/,contains:[u,v,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},p,x,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[N]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[v,N,p]}]}}function N7(e){const t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),o=t.concat(n,e.IDENT_RE),s={scope:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!(?:let|for|while|if|else|match)\b)/,o,t.lookahead(/\s*\(/))},a="([ui](8|16|32|64|128|size)|f(16|32|64|128))?",l=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","raw","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],u=["true","false","Some","None","Ok","Err"],f=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],h=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f16","f32","f64","f128","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:h,keyword:l,literal:u,built_in:f},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{scope:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|"|\\|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{scope:"number",variants:[{begin:"\\b0b([01_]+)"+a},{begin:"\\b0o([0-7_]+)"+a},{begin:"\\b0x([A-Fa-f0-9_]+)"+a},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+a}],relevance:0},{begin:[/\bsafe/,/\s+/,/extern/],scope:{1:"keyword",3:"keyword"}},{begin:[/fn/,/\s+/,r],scope:{1:"keyword",3:"title.function"}},{scope:"meta",begin:"#!?\\[",end:"\\]",contains:[{scope:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],scope:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],scope:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],scope:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],scope:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:f,type:h}},{scope:"punctuation",begin:"->"},s]}}const Nh="[A-Za-z$_][0-9A-Za-z$_]*",T$=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],j$=["true","false","null","undefined","NaN","Infinity"],$$=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],C$=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],A$=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],I$=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],R$=[].concat(A$,$$,C$);function T7(e){const t=e.regex,n=(C,{after:oe})=>{const U="</"+C[0].slice(1);return C.input.indexOf(U,oe)!==-1},r=Nh,o={begin:"<>",end:"</>"},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,a={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(C,oe)=>{const U=C[0].length+C.index,B=C.input[U];if(B==="<"||B===","){oe.ignoreMatch();return}B===">"&&(n(C,{after:U})||oe.ignoreMatch());let Q;const ue=C.input.substring(U);if(Q=ue.match(/^\s*=/)){oe.ignoreMatch();return}if((Q=ue.match(/^\s+extends\s+/))&&Q.index===0){oe.ignoreMatch();return}}},l={$pattern:Nh,keyword:T$,literal:j$,built_in:R$,"variable.language":I$},u="[0-9](_?[0-9])*",f=`\\.(${u})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",p={className:"number",variants:[{begin:`(\\b(${h})((${f})|\\.)?|(${f}))[eE][+-]?(${u})\\b`},{begin:`\\b(${h})\\b((${f})\\b|\\.)?|(${f})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},w={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},v={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},x={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},S={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},T=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,v,x,{match:/\$\d+/},p];g.contains=T.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(T)});const j=[].concat(S,g.contains),$=j.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(j)}]),R={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:$},A={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},I={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...$$,...C$]}},M={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},P={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],illegal:/%/},F={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function q(C){return t.concat("(?!",C.join("|"),")")}const W={match:t.concat(/\b/,q([...A$,"super","import","await"].map(C=>`${C}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},ee={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},V={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},R]},te="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",K={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(te)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:$,CLASS_REFERENCE:I},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),M,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,v,x,S,{match:/\$\d+/},p,I,{scope:"attr",match:r+t.lookahead(":"),relevance:0},K,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[S,e.REGEXP_MODE,{className:"function",begin:te,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:$}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:s},{begin:a.begin,"on:begin":a.isTrulyOpeningTag,end:a.end}],subLanguage:"xml",contains:[{begin:a.begin,end:a.end,skip:!0,contains:["self"]}]}]},P,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[R,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},ee,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[R]},W,F,A,V,{match:/\$[(.]/}]}}function j7(e){const t=e.regex,n=T7(e),r=Nh,o=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],s={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},a={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:o},contains:[n.exports.CLASS_REFERENCE]},l={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},u=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],f={$pattern:Nh,keyword:T$.concat(u),literal:j$,built_in:R$.concat(o),"variable.language":I$},h={className:"meta",begin:"@"+r},p=(v,x,N)=>{const S=v.contains.findIndex(T=>T.label===x);if(S===-1)throw new Error("can not find mode to replace");v.contains.splice(S,1,N)};Object.assign(n.keywords,f),n.exports.PARAMS_CONTAINS.push(h);const g=n.contains.find(v=>v.scope==="attr"),y=Object.assign({},g,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,g,y]),n.contains=n.contains.concat([h,s,a,y]),p(n,"shebang",e.SHEBANG()),p(n,"use_strict",l);const w=n.contains.find(v=>v.label==="func.def");return w.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function $7(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,o={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},s={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},a=e.inherit(s,{begin:/\(/,end:/\)/}),l=e.inherit(e.APOS_STRING_MODE,{className:"string"}),u=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),f={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[o]},{begin:/'/,end:/'/,contains:[o]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[s,u,l,a,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[s,a,u,l]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},o,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[u]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[f],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:"css"}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[f],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:"javascript"}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:f}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function C7(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},o={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},s={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},a={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,o]},l=e.inherit(a,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),g={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},y={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},w={begin:/\{/,end:/\}/,contains:[y],illegal:"\\n",relevance:0},v={begin:"\\[",end:"\\]",contains:[y],illegal:"\\n",relevance:0},x=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},g,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},w,v,s,a],N=[...x];return N.pop(),N.push(l),y.contains=N,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:x}}var Ug,aE;function A7(){if(aE)return Ug;aE=1;function e(D){return D instanceof Map?D.clear=D.delete=D.set=function(){throw new Error("map is read-only")}:D instanceof Set&&(D.add=D.clear=D.delete=function(){throw new Error("set is read-only")}),Object.freeze(D),Object.getOwnPropertyNames(D).forEach(se=>{const Se=D[se],ze=typeof Se;(ze==="object"||ze==="function")&&!Object.isFrozen(Se)&&e(Se)}),D}class t{constructor(se){se.data===void 0&&(se.data={}),this.data=se.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(D){return D.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(D,...se){const Se=Object.create(null);for(const ze in D)Se[ze]=D[ze];return se.forEach(function(ze){for(const Ut in ze)Se[Ut]=ze[Ut]}),Se}const o="</span>",s=D=>!!D.scope,a=(D,{prefix:se})=>{if(D.startsWith("language:"))return D.replace("language:","language-");if(D.includes(".")){const Se=D.split(".");return[`${se}${Se.shift()}`,...Se.map((ze,Ut)=>`${ze}${"_".repeat(Ut+1)}`)].join(" ")}return`${se}${D}`};class l{constructor(se,Se){this.buffer="",this.classPrefix=Se.classPrefix,se.walk(this)}addText(se){this.buffer+=n(se)}openNode(se){if(!s(se))return;const Se=a(se.scope,{prefix:this.classPrefix});this.span(Se)}closeNode(se){s(se)&&(this.buffer+=o)}value(){return this.buffer}span(se){this.buffer+=`<span class="${se}">`}}const u=(D={})=>{const se={children:[]};return Object.assign(se,D),se};class f{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(se){this.top.children.push(se)}openNode(se){const Se=u({scope:se});this.add(Se),this.stack.push(Se)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(se){return this.constructor._walk(se,this.rootNode)}static _walk(se,Se){return typeof Se=="string"?se.addText(Se):Se.children&&(se.openNode(Se),Se.children.forEach(ze=>this._walk(se,ze)),se.closeNode(Se)),se}static _collapse(se){typeof se!="string"&&se.children&&(se.children.every(Se=>typeof Se=="string")?se.children=[se.children.join("")]:se.children.forEach(Se=>{f._collapse(Se)}))}}class h extends f{constructor(se){super(),this.options=se}addText(se){se!==""&&this.add(se)}startScope(se){this.openNode(se)}endScope(){this.closeNode()}__addSublanguage(se,Se){const ze=se.root;Se&&(ze.scope=`language:${Se}`),this.add(ze)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function p(D){return D?typeof D=="string"?D:D.source:null}function g(D){return v("(?=",D,")")}function y(D){return v("(?:",D,")*")}function w(D){return v("(?:",D,")?")}function v(...D){return D.map(Se=>p(Se)).join("")}function x(D){const se=D[D.length-1];return typeof se=="object"&&se.constructor===Object?(D.splice(D.length-1,1),se):{}}function N(...D){return"("+(x(D).capture?"":"?:")+D.map(ze=>p(ze)).join("|")+")"}function S(D){return new RegExp(D.toString()+"|").exec("").length-1}function T(D,se){const Se=D&&D.exec(se);return Se&&Se.index===0}const j=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function $(D,{joinWith:se}){let Se=0;return D.map(ze=>{Se+=1;const Ut=Se;let qt=p(ze),Oe="";for(;qt.length>0;){const Fe=j.exec(qt);if(!Fe){Oe+=qt;break}Oe+=qt.substring(0,Fe.index),qt=qt.substring(Fe.index+Fe[0].length),Fe[0][0]==="\\"&&Fe[1]?Oe+="\\"+String(Number(Fe[1])+Ut):(Oe+=Fe[0],Fe[0]==="("&&Se++)}return Oe}).map(ze=>`(${ze})`).join(se)}const R=/\b\B/,A="[a-zA-Z]\\w*",I="[a-zA-Z_]\\w*",M="\\b\\d+(\\.\\d+)?",P="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",F="\\b(0b[01]+)",q="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",W=(D={})=>{const se=/^#![ ]*\//;return D.binary&&(D.begin=v(se,/.*\b/,D.binary,/\b.*/)),r({scope:"meta",begin:se,end:/$/,relevance:0,"on:begin":(Se,ze)=>{Se.index!==0&&ze.ignoreMatch()}},D)},ee={begin:"\\\\[\\s\\S]",relevance:0},V={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[ee]},te={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[ee]},K={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},C=function(D,se,Se={}){const ze=r({scope:"comment",begin:D,end:se,contains:[]},Se);ze.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const Ut=N("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return ze.contains.push({begin:v(/[ ]+/,"(",Ut,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),ze},oe=C("//","$"),U=C("/\\*","\\*/"),B=C("#","$"),Q={scope:"number",begin:M,relevance:0},ue={scope:"number",begin:P,relevance:0},he={scope:"number",begin:F,relevance:0},Ne={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[ee,{begin:/\[/,end:/\]/,relevance:0,contains:[ee]}]},De={scope:"title",begin:A,relevance:0},Be={scope:"title",begin:I,relevance:0},Z={begin:"\\.\\s*"+I,relevance:0};var pe=Object.freeze({__proto__:null,APOS_STRING_MODE:V,BACKSLASH_ESCAPE:ee,BINARY_NUMBER_MODE:he,BINARY_NUMBER_RE:F,COMMENT:C,C_BLOCK_COMMENT_MODE:U,C_LINE_COMMENT_MODE:oe,C_NUMBER_MODE:ue,C_NUMBER_RE:P,END_SAME_AS_BEGIN:function(D){return Object.assign(D,{"on:begin":(se,Se)=>{Se.data._beginMatch=se[1]},"on:end":(se,Se)=>{Se.data._beginMatch!==se[1]&&Se.ignoreMatch()}})},HASH_COMMENT_MODE:B,IDENT_RE:A,MATCH_NOTHING_RE:R,METHOD_GUARD:Z,NUMBER_MODE:Q,NUMBER_RE:M,PHRASAL_WORDS_MODE:K,QUOTE_STRING_MODE:te,REGEXP_MODE:Ne,RE_STARTERS_RE:q,SHEBANG:W,TITLE_MODE:De,UNDERSCORE_IDENT_RE:I,UNDERSCORE_TITLE_MODE:Be});function de(D,se){D.input[D.index-1]==="."&&se.ignoreMatch()}function ie(D,se){D.className!==void 0&&(D.scope=D.className,delete D.className)}function ye(D,se){se&&D.beginKeywords&&(D.begin="\\b("+D.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",D.__beforeBegin=de,D.keywords=D.keywords||D.beginKeywords,delete D.beginKeywords,D.relevance===void 0&&(D.relevance=0))}function _e(D,se){Array.isArray(D.illegal)&&(D.illegal=N(...D.illegal))}function be(D,se){if(D.match){if(D.begin||D.end)throw new Error("begin & end are not supported with match");D.begin=D.match,delete D.match}}function $e(D,se){D.relevance===void 0&&(D.relevance=1)}const Ze=(D,se)=>{if(!D.beforeMatch)return;if(D.starts)throw new Error("beforeMatch cannot be used with starts");const Se=Object.assign({},D);Object.keys(D).forEach(ze=>{delete D[ze]}),D.keywords=Se.keywords,D.begin=v(Se.beforeMatch,g(Se.begin)),D.starts={relevance:0,contains:[Object.assign(Se,{endsParent:!0})]},D.relevance=0,delete Se.beforeMatch},rt=["of","and","for","in","not","or","if","then","parent","list","value"],en="keyword";function Xt(D,se,Se=en){const ze=Object.create(null);return typeof D=="string"?Ut(Se,D.split(" ")):Array.isArray(D)?Ut(Se,D):Object.keys(D).forEach(function(qt){Object.assign(ze,Xt(D[qt],se,qt))}),ze;function Ut(qt,Oe){se&&(Oe=Oe.map(Fe=>Fe.toLowerCase())),Oe.forEach(function(Fe){const et=Fe.split("|");ze[et[0]]=[qt,Et(et[0],et[1])]})}}function Et(D,se){return se?Number(se):Ke(D)?0:1}function Ke(D){return rt.includes(D.toLowerCase())}const Qt={},Ot=D=>{console.error(D)},Zt=(D,...se)=>{console.log(`WARN: ${D}`,...se)},Ge=(D,se)=>{Qt[`${D}/${se}`]||(console.log(`Deprecated as of ${D}. ${se}`),Qt[`${D}/${se}`]=!0)},nn=new Error;function pn(D,se,{key:Se}){let ze=0;const Ut=D[Se],qt={},Oe={};for(let Fe=1;Fe<=se.length;Fe++)Oe[Fe+ze]=Ut[Fe],qt[Fe+ze]=!0,ze+=S(se[Fe-1]);D[Se]=Oe,D[Se]._emit=qt,D[Se]._multi=!0}function It(D){if(Array.isArray(D.begin)){if(D.skip||D.excludeBegin||D.returnBegin)throw Ot("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),nn;if(typeof D.beginScope!="object"||D.beginScope===null)throw Ot("beginScope must be object"),nn;pn(D,D.begin,{key:"beginScope"}),D.begin=$(D.begin,{joinWith:""})}}function gt(D){if(Array.isArray(D.end)){if(D.skip||D.excludeEnd||D.returnEnd)throw Ot("skip, excludeEnd, returnEnd not compatible with endScope: {}"),nn;if(typeof D.endScope!="object"||D.endScope===null)throw Ot("endScope must be object"),nn;pn(D,D.end,{key:"endScope"}),D.end=$(D.end,{joinWith:""})}}function Vt(D){D.scope&&typeof D.scope=="object"&&D.scope!==null&&(D.beginScope=D.scope,delete D.scope)}function Cn(D){Vt(D),typeof D.beginScope=="string"&&(D.beginScope={_wrap:D.beginScope}),typeof D.endScope=="string"&&(D.endScope={_wrap:D.endScope}),It(D),gt(D)}function Ce(D){function se(Oe,Fe){return new RegExp(p(Oe),"m"+(D.case_insensitive?"i":"")+(D.unicodeRegex?"u":"")+(Fe?"g":""))}class Se{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Fe,et){et.position=this.position++,this.matchIndexes[this.matchAt]=et,this.regexes.push([et,Fe]),this.matchAt+=S(Fe)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Fe=this.regexes.map(et=>et[1]);this.matcherRe=se($(Fe,{joinWith:"|"}),!0),this.lastIndex=0}exec(Fe){this.matcherRe.lastIndex=this.lastIndex;const et=this.matcherRe.exec(Fe);if(!et)return null;const Ft=et.findIndex((On,Mn)=>Mn>0&&On!==void 0),jt=this.matchIndexes[Ft];return et.splice(0,Ft),Object.assign(et,jt)}}class ze{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Fe){if(this.multiRegexes[Fe])return this.multiRegexes[Fe];const et=new Se;return this.rules.slice(Fe).forEach(([Ft,jt])=>et.addRule(Ft,jt)),et.compile(),this.multiRegexes[Fe]=et,et}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Fe,et){this.rules.push([Fe,et]),et.type==="begin"&&this.count++}exec(Fe){const et=this.getMatcher(this.regexIndex);et.lastIndex=this.lastIndex;let Ft=et.exec(Fe);if(this.resumingScanAtSamePosition()&&!(Ft&&Ft.index===this.lastIndex)){const jt=this.getMatcher(0);jt.lastIndex=this.lastIndex+1,Ft=jt.exec(Fe)}return Ft&&(this.regexIndex+=Ft.position+1,this.regexIndex===this.count&&this.considerAll()),Ft}}function Ut(Oe){const Fe=new ze;return Oe.contains.forEach(et=>Fe.addRule(et.begin,{rule:et,type:"begin"})),Oe.terminatorEnd&&Fe.addRule(Oe.terminatorEnd,{type:"end"}),Oe.illegal&&Fe.addRule(Oe.illegal,{type:"illegal"}),Fe}function qt(Oe,Fe){const et=Oe;if(Oe.isCompiled)return et;[ie,be,Cn,Ze].forEach(jt=>jt(Oe,Fe)),D.compilerExtensions.forEach(jt=>jt(Oe,Fe)),Oe.__beforeBegin=null,[ye,_e,$e].forEach(jt=>jt(Oe,Fe)),Oe.isCompiled=!0;let Ft=null;return typeof Oe.keywords=="object"&&Oe.keywords.$pattern&&(Oe.keywords=Object.assign({},Oe.keywords),Ft=Oe.keywords.$pattern,delete Oe.keywords.$pattern),Ft=Ft||/\w+/,Oe.keywords&&(Oe.keywords=Xt(Oe.keywords,D.case_insensitive)),et.keywordPatternRe=se(Ft,!0),Fe&&(Oe.begin||(Oe.begin=/\B|\b/),et.beginRe=se(et.begin),!Oe.end&&!Oe.endsWithParent&&(Oe.end=/\B|\b/),Oe.end&&(et.endRe=se(et.end)),et.terminatorEnd=p(et.end)||"",Oe.endsWithParent&&Fe.terminatorEnd&&(et.terminatorEnd+=(Oe.end?"|":"")+Fe.terminatorEnd)),Oe.illegal&&(et.illegalRe=se(Oe.illegal)),Oe.contains||(Oe.contains=[]),Oe.contains=[].concat(...Oe.contains.map(function(jt){return Dt(jt==="self"?Oe:jt)})),Oe.contains.forEach(function(jt){qt(jt,et)}),Oe.starts&&qt(Oe.starts,Fe),et.matcher=Ut(et),et}if(D.compilerExtensions||(D.compilerExtensions=[]),D.contains&&D.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return D.classNameAliases=r(D.classNameAliases||{}),qt(D)}function Pt(D){return D?D.endsWithParent||Pt(D.starts):!1}function Dt(D){return D.variants&&!D.cachedVariants&&(D.cachedVariants=D.variants.map(function(se){return r(D,{variants:null},se)})),D.cachedVariants?D.cachedVariants:Pt(D)?r(D,{starts:D.starts?r(D.starts):null}):Object.isFrozen(D)?r(D):D}var Wt="11.11.2";class Dn extends Error{constructor(se,Se){super(se),this.name="HTMLInjectionError",this.html=Se}}const ne=n,we=r,Ye=Symbol("nomatch"),ot=7,zt=function(D){const se=Object.create(null),Se=Object.create(null),ze=[];let Ut=!0;const qt="Could not find the language '{}', did you forget to load/include a language module?",Oe={disableAutodetect:!0,name:"Plain text",contains:[]};let Fe={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:h};function et(ve){return Fe.noHighlightRe.test(ve)}function Ft(ve){let Le=ve.className+" ";Le+=ve.parentNode?ve.parentNode.className:"";const At=Fe.languageDetectRe.exec(Le);if(At){const yt=wt(At[1]);return yt||(Zt(qt.replace("{}",At[1])),Zt("Falling back to no-highlight mode for this block.",ve)),yt?At[1]:"no-highlight"}return Le.split(/\s+/).find(yt=>et(yt)||wt(yt))}function jt(ve,Le,At){let yt="",rn="";typeof Le=="object"?(yt=ve,At=Le.ignoreIllegals,rn=Le.language):(Ge("10.7.0","highlight(lang, code, ...args) has been deprecated."),Ge("10.7.0",`Please use highlight(code, options) instead.
208
- https://github.com/highlightjs/highlight.js/issues/2277`),rn=ve,yt=Le),At===void 0&&(At=!0);const Gt={code:yt,language:rn};Bt("before:highlight",Gt);const Jn=Gt.result?Gt.result:On(Gt.language,Gt.code,At);return Jn.code=Gt.code,Bt("after:highlight",Jn),Jn}function On(ve,Le,At,yt){const rn=Object.create(null);function Gt(Y,ce){return Y.keywords[ce]}function Jn(){if(!He.keywords){an.addText(cn);return}let Y=0;He.keywordPatternRe.lastIndex=0;let ce=He.keywordPatternRe.exec(cn),xe="";for(;ce;){xe+=cn.substring(Y,ce.index);const Ie=me.case_insensitive?ce[0].toLowerCase():ce[0],Qe=Gt(He,Ie);if(Qe){const[$t,ut]=Qe;if(an.addText(xe),xe="",rn[Ie]=(rn[Ie]||0)+1,rn[Ie]<=ot&&(sr+=ut),$t.startsWith("_"))xe+=ce[0];else{const Zn=me.classNameAliases[$t]||$t;Yt(ce[0],Zn)}}else xe+=ce[0];Y=He.keywordPatternRe.lastIndex,ce=He.keywordPatternRe.exec(cn)}xe+=cn.substring(Y),an.addText(xe)}function Zr(){if(cn==="")return;let Y=null;if(typeof He.subLanguage=="string"){if(!se[He.subLanguage]){an.addText(cn);return}Y=On(He.subLanguage,cn,!0,bn[He.subLanguage]),bn[He.subLanguage]=Y._top}else Y=yn(cn,He.subLanguage.length?He.subLanguage:null);He.relevance>0&&(sr+=Y.relevance),an.__addSublanguage(Y._emitter,Y.language)}function hn(){He.subLanguage!=null?Zr():Jn(),cn=""}function Yt(Y,ce){Y!==""&&(an.startScope(ce),an.addText(Y),an.endScope())}function zn(Y,ce){let xe=1;const Ie=ce.length-1;for(;xe<=Ie;){if(!Y._emit[xe]){xe++;continue}const Qe=me.classNameAliases[Y[xe]]||Y[xe],$t=ce[xe];Qe?Yt($t,Qe):(cn=$t,Jn(),cn=""),xe++}}function or(Y,ce){return Y.scope&&typeof Y.scope=="string"&&an.openNode(me.classNameAliases[Y.scope]||Y.scope),Y.beginScope&&(Y.beginScope._wrap?(Yt(cn,me.classNameAliases[Y.beginScope._wrap]||Y.beginScope._wrap),cn=""):Y.beginScope._multi&&(zn(Y.beginScope,ce),cn="")),He=Object.create(Y,{parent:{value:He}}),He}function br(Y,ce,xe){let Ie=T(Y.endRe,xe);if(Ie){if(Y["on:end"]){const Qe=new t(Y);Y["on:end"](ce,Qe),Qe.isMatchIgnored&&(Ie=!1)}if(Ie){for(;Y.endsParent&&Y.parent;)Y=Y.parent;return Y}}if(Y.endsWithParent)return br(Y.parent,ce,xe)}function pr(Y){return He.matcher.regexIndex===0?(cn+=Y[0],1):(H=!0,0)}function Gr(Y){const ce=Y[0],xe=Y.rule,Ie=new t(xe),Qe=[xe.__beforeBegin,xe["on:begin"]];for(const $t of Qe)if($t&&($t(Y,Ie),Ie.isMatchIgnored))return pr(ce);return xe.skip?cn+=ce:(xe.excludeBegin&&(cn+=ce),hn(),!xe.returnBegin&&!xe.excludeBegin&&(cn=ce)),or(xe,Y),xe.returnBegin?0:ce.length}function ro(Y){const ce=Y[0],xe=Le.substring(Y.index),Ie=br(He,Y,xe);if(!Ie)return Ye;const Qe=He;He.endScope&&He.endScope._wrap?(hn(),Yt(ce,He.endScope._wrap)):He.endScope&&He.endScope._multi?(hn(),zn(He.endScope,Y)):Qe.skip?cn+=ce:(Qe.returnEnd||Qe.excludeEnd||(cn+=ce),hn(),Qe.excludeEnd&&(cn=ce));do He.scope&&an.closeNode(),!He.skip&&!He.subLanguage&&(sr+=He.relevance),He=He.parent;while(He!==Ie.parent);return Ie.starts&&or(Ie.starts,Y),Qe.returnEnd?0:ce.length}function Ro(){const Y=[];for(let ce=He;ce!==me;ce=ce.parent)ce.scope&&Y.unshift(ce.scope);Y.forEach(ce=>an.openNode(ce))}let $r={};function G(Y,ce){const xe=ce&&ce[0];if(cn+=Y,xe==null)return hn(),0;if($r.type==="begin"&&ce.type==="end"&&$r.index===ce.index&&xe===""){if(cn+=Le.slice(ce.index,ce.index+1),!Ut){const Ie=new Error(`0 width match regex (${ve})`);throw Ie.languageName=ve,Ie.badRule=$r.rule,Ie}return 1}if($r=ce,ce.type==="begin")return Gr(ce);if(ce.type==="illegal"&&!At){const Ie=new Error('Illegal lexeme "'+xe+'" for mode "'+(He.scope||"<unnamed>")+'"');throw Ie.mode=He,Ie}else if(ce.type==="end"){const Ie=ro(ce);if(Ie!==Ye)return Ie}if(ce.type==="illegal"&&xe==="")return ce.index===Le.length||(cn+=`
209
- `),1;if(Te>1e5&&Te>ce.index*3)throw new Error("potential infinite loop, way more iterations than matches");return cn+=xe,xe.length}const me=wt(ve);if(!me)throw Ot(qt.replace("{}",ve)),new Error('Unknown language: "'+ve+'"');const Je=Ce(me);let Ve="",He=yt||Je;const bn={},an=new Fe.__emitter(Fe);Ro();let cn="",sr=0,mr=0,Te=0,H=!1;try{if(me.__emitTokens)me.__emitTokens(Le,an);else{for(He.matcher.considerAll();;){Te++,H?H=!1:He.matcher.considerAll(),He.matcher.lastIndex=mr;const Y=He.matcher.exec(Le);if(!Y)break;const ce=Le.substring(mr,Y.index),xe=G(ce,Y);mr=Y.index+xe}G(Le.substring(mr))}return an.finalize(),Ve=an.toHTML(),{language:ve,value:Ve,relevance:sr,illegal:!1,_emitter:an,_top:He}}catch(Y){if(Y.message&&Y.message.includes("Illegal"))return{language:ve,value:ne(Le),illegal:!0,relevance:0,_illegalBy:{message:Y.message,index:mr,context:Le.slice(mr-100,mr+100),mode:Y.mode,resultSoFar:Ve},_emitter:an};if(Ut)return{language:ve,value:ne(Le),illegal:!1,relevance:0,errorRaised:Y,_emitter:an,_top:He};throw Y}}function Mn(ve){const Le={value:ne(ve),illegal:!1,relevance:0,_top:Oe,_emitter:new Fe.__emitter(Fe)};return Le._emitter.addText(ve),Le}function yn(ve,Le){Le=Le||Fe.languages||Object.keys(se);const At=Mn(ve),yt=Le.filter(wt).filter(Lr).map(hn=>On(hn,ve,!1));yt.unshift(At);const rn=yt.sort((hn,Yt)=>{if(hn.relevance!==Yt.relevance)return Yt.relevance-hn.relevance;if(hn.language&&Yt.language){if(wt(hn.language).supersetOf===Yt.language)return 1;if(wt(Yt.language).supersetOf===hn.language)return-1}return 0}),[Gt,Jn]=rn,Zr=Gt;return Zr.secondBest=Jn,Zr}function tn(ve,Le,At){const yt=Le&&Se[Le]||At;ve.classList.add("hljs"),ve.classList.add(`language-${yt}`)}function _n(ve){let Le=null;const At=Ft(ve);if(et(At))return;if(Bt("before:highlightElement",{el:ve,language:At}),ve.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",ve);return}if(ve.children.length>0&&(Fe.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(ve)),Fe.throwUnescapedHTML))throw new Dn("One of your code blocks includes unescaped HTML.",ve.innerHTML);Le=ve;const yt=Le.textContent,rn=At?jt(yt,{language:At,ignoreIllegals:!0}):yn(yt);ve.innerHTML=rn.value,ve.dataset.highlighted="yes",tn(ve,At,rn.language),ve.result={language:rn.language,re:rn.relevance,relevance:rn.relevance},rn.secondBest&&(ve.secondBest={language:rn.secondBest.language,relevance:rn.secondBest.relevance}),Bt("after:highlightElement",{el:ve,result:rn,text:yt})}function Mt(ve){Fe=we(Fe,ve)}const mn=()=>{le(),Ge("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function rr(){le(),Ge("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Ct=!1;function le(){function ve(){le()}if(document.readyState==="loading"){Ct||window.addEventListener("DOMContentLoaded",ve,!1),Ct=!0;return}document.querySelectorAll(Fe.cssSelector).forEach(_n)}function qe(ve,Le){let At=null;try{At=Le(D)}catch(yt){if(Ot("Language definition for '{}' could not be registered.".replace("{}",ve)),Ut)Ot(yt);else throw yt;At=Oe}At.name||(At.name=ve),se[ve]=At,At.rawDefinition=Le.bind(null,D),At.aliases&&En(At.aliases,{languageName:ve})}function Xe(ve){delete se[ve];for(const Le of Object.keys(Se))Se[Le]===ve&&delete Se[Le]}function pt(){return Object.keys(se)}function wt(ve){return ve=(ve||"").toLowerCase(),se[ve]||se[Se[ve]]}function En(ve,{languageName:Le}){typeof ve=="string"&&(ve=[ve]),ve.forEach(At=>{Se[At.toLowerCase()]=Le})}function Lr(ve){const Le=wt(ve);return Le&&!Le.disableAutodetect}function un(ve){ve["before:highlightBlock"]&&!ve["before:highlightElement"]&&(ve["before:highlightElement"]=Le=>{ve["before:highlightBlock"](Object.assign({block:Le.el},Le))}),ve["after:highlightBlock"]&&!ve["after:highlightElement"]&&(ve["after:highlightElement"]=Le=>{ve["after:highlightBlock"](Object.assign({block:Le.el},Le))})}function vr(ve){un(ve),ze.push(ve)}function Qn(ve){const Le=ze.indexOf(ve);Le!==-1&&ze.splice(Le,1)}function Bt(ve,Le){const At=ve;ze.forEach(function(yt){yt[At]&&yt[At](Le)})}function dn(ve){return Ge("10.7.0","highlightBlock will be removed entirely in v12.0"),Ge("10.7.0","Please use highlightElement now."),_n(ve)}Object.assign(D,{highlight:jt,highlightAuto:yn,highlightAll:le,highlightElement:_n,highlightBlock:dn,configure:Mt,initHighlighting:mn,initHighlightingOnLoad:rr,registerLanguage:qe,unregisterLanguage:Xe,listLanguages:pt,getLanguage:wt,registerAliases:En,autoDetection:Lr,inherit:we,addPlugin:vr,removePlugin:Qn}),D.debugMode=function(){Ut=!1},D.safeMode=function(){Ut=!0},D.versionString=Wt,D.regex={concat:v,lookahead:g,either:N,optional:w,anyNumberOfTimes:y};for(const ve in pe)typeof pe[ve]=="object"&&e(pe[ve]);return Object.assign(D,pe),D},Kt=zt({});return Kt.newInstance=()=>zt({}),Ug=Kt,Kt.HighlightJS=Kt,Kt.default=Kt,Ug}var I7=A7();const R7=IS(I7),cE={},O7="hljs-";function M7(e){const t=R7.newInstance();return e&&s(e),{highlight:n,highlightAuto:r,listLanguages:o,register:s,registerAlias:a,registered:l};function n(u,f,h){const p=h||cE,g=typeof p.prefix=="string"?p.prefix:O7;if(!t.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");t.configure({__emitter:L7,classPrefix:g});const y=t.highlight(f,{ignoreIllegals:!0,language:u});if(y.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:y.errorRaised});const w=y._emitter.root,v=w.data;return v.language=y.language,v.relevance=y.relevance,w}function r(u,f){const p=(f||cE).subset||o();let g=-1,y=0,w;for(;++g<p.length;){const v=p[g];if(!t.getLanguage(v))continue;const x=n(v,u,f);x.data&&x.data.relevance!==void 0&&x.data.relevance>y&&(y=x.data.relevance,w=x)}return w||{type:"root",children:[],data:{language:void 0,relevance:y}}}function o(){return t.listLanguages()}function s(u,f){if(typeof u=="string")t.registerLanguage(u,f);else{let h;for(h in u)Object.hasOwn(u,h)&&t.registerLanguage(h,u[h])}}function a(u,f){if(typeof u=="string")t.registerAliases(typeof f=="string"?f:[...f],{languageName:u});else{let h;for(h in u)if(Object.hasOwn(u,h)){const p=u[h];t.registerAliases(typeof p=="string"?p:[...p],{languageName:h})}}}function l(u){return!!t.getLanguage(u)}}class L7{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const r=this.stack[this.stack.length-1],o=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:o}):r.children.push(...o)}openNode(t){const n=this,r=t.split(".").map(function(a,l){return l?a+"_".repeat(l):n.options.classPrefix+a}),o=this.stack[this.stack.length-1],s={type:"element",tagName:"span",properties:{className:r},children:[]};o.children.push(s),this.stack.push(s)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const O$=M7({bash:o7,css:h7,go:p7,ini:m7,javascript:v7,json:E7,markdown:S7,python:_7,rust:N7,typescript:j7,xml:$7,yaml:C7}),lE={ts:"typescript",tsx:"typescript",mts:"typescript",cts:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",json:"json",jsonc:"json",css:"css",scss:"css",less:"css",html:"xml",htm:"xml",xml:"xml",svg:"xml",vue:"xml",md:"markdown",mdx:"markdown",markdown:"markdown",py:"python",pyi:"python",rs:"rust",go:"go",java:"javascript",kt:"javascript",c:"javascript",h:"javascript",cc:"javascript",cpp:"javascript",hpp:"javascript",cs:"javascript",swift:"javascript",yml:"yaml",yaml:"yaml",toml:"ini",ini:"ini",env:"ini",sh:"bash",bash:"bash",zsh:"bash",fish:"bash"};function Cp(e,t){const n=e&&(lE[e]??(O$.registered(e)?e:null));if(n)return n;const r=t.lastIndexOf("."),o=r<0?"":t.slice(r+1).toLowerCase();return(o?lE[o]:null)??null}const P7=/^(?:diff --git a\/\S+ b\/(\S+)|\+\+\+ (?:b\/)?(\S+))$/gm;function D7(e){const t=new Set;for(const n of e.matchAll(P7)){const r=n[1]??n[2]??"";r&&r!=="/dev/null"&&t.add(r)}return t.size===1?[...t][0]:""}const z7={comment:"comment",quote:"comment",doctag:"comment",keyword:"keyword",literal:"keyword",meta:"keyword","meta-keyword":"keyword",operator:"keyword","selector-tag":"keyword",tag:"keyword",string:"string",regexp:"string","meta-string":"string","template-tag":"string",symbol:"string",number:"number",type:"type",built_in:"type",class:"type",class_:"type","selector-class":"type","selector-id":"type",title:"function",function_:"function",function:"function",variable:"variable",language_:"variable",constant_:"variable",attr:"variable",attribute:"variable",property:"variable",params:"variable",name:"variable"};function M$(e,t){const n=[[]],r=(s,a)=>{const l=s.split(`
210
- `);for(const[u,f]of l.entries()){if(u>0&&n.push([]),!f)continue;const h=n[n.length-1],p=h[h.length-1];p&&p.scope===a?p.text+=f:h.push({text:f,scope:a})}},o=(s,a)=>{for(const l of s)l.type==="text"?r(l.value,a):l.type==="element"&&o(l.children,F7(l)??a)};try{o(O$.highlight(t,e).children,"")}catch{return e.split(`
211
- `).map(s=>s?[{text:s,scope:""}]:[])}return n}function F7(e){var r;const t=((r=e.properties)==null?void 0:r.className)??[];let n=null;for(const o of t){const s=z7[o.startsWith("hljs-")?o.slice(5):o];s&&(n=s)}return n}const uE=/^\d+\t/;function Ap(e,t){if(!t)return[];const n=e.split(`
212
- `),r=uE.test(n[0]??""),o=r?n.map(a=>{var l;return((l=uE.exec(a))==null?void 0:l[0])??""}):[],s=r?n.map((a,l)=>a.slice(o[l].length)).join(`
213
- `):e;return M$(s,t).map((a,l)=>{const u=a.map(h=>({text:h.text,changed:!1,scope:h.scope})),f=o[l];return f?[{text:f,changed:!1,scope:""},...u]:u})}function B7(e,t){var r;const n=new Array(e.length);if(t){let o=0;for(let s=0;s<=e.length;s++){const a=(r=e[s])==null?void 0:r.kind;s<e.length&&a!=="hunk"&&a!=="meta"||(U7(e,o,s,t,n),o=s+1)}}return e.map((o,s)=>K7(o.spans,n[s],o.text))}function U7(e,t,n,r,o){var s,a;for(const l of["del","add"]){const u=[];for(let p=t;p<n;p++){const g=(s=e[p])==null?void 0:s.kind;(g===""||g===l)&&u.push(p)}if(u.length===0)continue;const f=u.map(p=>{var g;return((g=e[p])==null?void 0:g.text)??""}).join(`
214
- `),h=M$(f,r);for(const[p,g]of u.entries())(l==="add"||((a=e[g])==null?void 0:a.kind)==="del")&&(o[g]=h[p])}}const Ip="link",H7=/https?:\/\/[^\s<>"'`]+/g,L$=/https?:\/\//;function P$(e){const t=[];for(const n of e.matchAll(H7)){const r=n.index+W7(n[0]).length;r>n.index&&t.push({start:n.index,end:r})}return t}const dE={")":"(","]":"[","}":"{"};function W7(e){let t=e.length;for(;t>0;){const n=e[t-1];if(".,;:!?".includes(n))t--;else if(dE[n]&&fE(e.slice(0,t),dE[n])<fE(e.slice(0,t),n))t--;else break}return e.slice(0,t)}function fE(e,t){let n=0;for(const r of e)r===t&&n++;return n}function D$(e){const t=e.map(l=>l.text).join("");if(!L$.test(t))return e;const n=P$(t);if(!n.length)return e;const r=[];let o=0,s=0,a=null;for(const l of e){let u=0;for(;u<l.text.length;){const f=n[s],h=o+u;if(f&&h>=f.start){const p=Math.min(f.end,o+l.text.length)-h;a||(a={text:"",changed:!1,scope:Ip},r.push(a)),a.text+=l.text.slice(u,u+p),a.changed||(a.changed=l.changed),u+=p,h+p>=f.end&&(a=null,s++)}else{const p=f?Math.min(f.start-o,l.text.length):l.text.length;r.push({text:l.text.slice(u,p),changed:l.changed,scope:l.scope}),u=p}}o+=l.text.length}return r}const Th=e=>e.map(D$);function hv(e){return L$.test(e)?e.split(`
215
- `).map(t=>D$(t?[{text:t,changed:!1,scope:""}]:[])):[]}function z$(e){const t=e[e.length-1],n=t==null?void 0:t[t.length-1];return!n||n.scope!==Ip?e:[...e.slice(0,-1),[...t.slice(0,-1),{...n,scope:""}]]}function K7(e,t,n){if(!(e!=null&&e.length)&&!(t!=null&&t.length))return n?[{text:n,changed:!1,scope:""}]:[];const r=[],o=e!=null&&e.length?e:[{text:n,changed:!1}],s=t!=null&&t.length?t:[{text:n,scope:""}];let a=0,l=0,u=0,f=0;for(;a<o.length&&l<s.length;){const h=o[a],p=s[l],g=Math.min(h.text.length-u,p.text.length-f);if(g>0){const y={text:h.text.slice(u,u+g),changed:h.changed,scope:p.scope},w=r[r.length-1];w&&w.changed===y.changed&&w.scope===y.scope?w.text+=y.text:r.push(y)}u+=g,f+=g,u>=h.text.length&&(a++,u=0),f>=p.text.length&&(l++,f=0)}return r}const q7=/^[^\s]*$/,Z7=e=>e.split(/\s+/).slice(1).every(t=>!t||/[a-z0-9]/i.test(t));function Hg(e,t,n){if(e.startsWith("!"))return null;if(e.startsWith("/")){const a=e.indexOf(" "),l=a===-1?e.length:a;if(!(e.indexOf("/",1)!==-1&&e.indexOf("/",1)<l)&&t<=l)return{kind:"command",query:e.slice(1,t),from:0,to:l}}const r=e.lastIndexOf("@",Math.max(0,t-1));if(r===-1||r>=t||r>0&&!/\s/.test(e[r-1]??""))return null;const o=e.slice(r+1,t);if(!q7.test(o)&&!(Z7(o)&&(n!=null&&n(o))))return null;let s=t;for(;s<e.length&&!/\s/.test(e[s]??"");)s++;return{kind:"file",query:o,from:r,to:s}}const nw=new Map,hE={files:new Set,folders:new Set,worktrees:nw,titled:[]},pE=new WeakMap;function F$(e,t=nw){let n;if(e?(n=pE.get(e),n||(n={...hE,files:new Set(e),folders:new Set(yN(e))},pE.set(e,n))):n=hE,t===nw)return n;const r=[...t].map(([o,s])=>({...s,branch:o})).sort((o,s)=>s.title.length-o.title.length);return{...n,worktrees:t,titled:r}}function B$(e,t){const n=new Map;for(const{branch:r,...o}of e)n.set(r,o);for(const r of t??[])n.has(r.branch)||n.set(r.branch,{id:r.id,title:r.title,archived:!0});return n}const G7=/^[ \t]*(?<ticks>`{3,})[ \t]*(?<lang>[^`\s]*)[^`\n]*$/;function V7(e){var s;const t=[],n=a=>{if(!a)return;const l=t.at(-1);(l==null?void 0:l.kind)==="prose"?l.text+=a:t.push({kind:"prose",text:a})};let r=0,o=0;for(;r<e.length;){const a=e.indexOf("`",r);if(a===-1)break;const l=e.lastIndexOf(`
216
- `,a-1)+1,u=e.indexOf(`
217
- `,a),f=(s=G7.exec(e.slice(l,u===-1?e.length:u)))==null?void 0:s.groups;if(f!=null&&f.ticks){const w=f.ticks.length,v=new RegExp(`^[ \\t]*\`{${w},}[ \\t]*$`,"m"),x=u===-1?e.length:u+1,N=v.exec(e.slice(x));let S=e.length,T=e.slice(x);N&&(T=e.slice(x,x+N.index),S=x+N.index+N[0].length,e[S]===`
218
- `&&S++),n(e.slice(o,l)),t.push({kind:"block",text:e.slice(l,S),code:T.replace(/\n$/,""),lang:f.lang??""}),o=r=S;continue}let h=1;for(;e[a+h]==="`";)h++;const p=new RegExp(`(?<!\`)\`{${h}}(?!\`)`,"g");p.lastIndex=a+h;const g=p.exec(e);if(!g){r=a+h;continue}let y=e.slice(a+h,g.index);y.length>2&&y.startsWith(" ")&&y.endsWith(" ")&&y.trim()&&(y=y.slice(1,-1)),n(e.slice(o,a)),t.push({kind:"code",text:e.slice(a,g.index+h),code:y}),o=r=g.index+h}return n(e.slice(o)),t}const Y7=/(^|\s)(@\S+)/g,X7=/[.,;:!?)\]}'"]$/,Q7=/^[.,;:!?)\]}'"]*(\s|$)/;function mE(e,t){if(e==="changes")return{kind:"changes",text:"@changes"};if(t.files.has(e))return{kind:"file",text:`@${e}`,path:e};const n=e.replace(/\/+$/,"");if(n&&t.folders.has(n))return{kind:"folder",text:`@${e}`,path:n};const r=t.worktrees.get(e);return r?{kind:"worktree",text:`@${e}`,branch:e,...r}:null}function J7(e,t){const n=e.toLowerCase();for(const r of t.titled){const o=r.title.toLowerCase();if(o&&n.startsWith(o)&&Q7.test(e.slice(o.length)))return{kind:"worktree",text:`@${e.slice(0,o.length)}`,...r}}return null}function Rp(e){const t=[];return e.archived?t.push("archived"):(e.state&&t.push(e.state),e.at!==void 0&&t.push(`last sent ${jo(dr(e.at))}`)),e.branch&&t.push(e.branch),e.dir&&t.push(e.dir),{text:e.title,detail:t,dot:e.archived?"archived":e.dot}}function eH(e,t,n){let r=0;for(const o of pv(e,n)){if(r===t)return o.kind!=="text";r+=o.text.length}return!1}function pv(e,t){const n=[];for(const r of V7(e))r.kind==="prose"?tH(r.text,n.length===0,t,n):n.push(r);return n}function tH(e,t,n,r){const o=[];for(const l of e.matchAll(Y7)){if(l.index===0&&!l[1]&&!t)continue;const u=l.index+(l[1]??"").length,f=J7(e.slice(u+1),n);let h=(l[2]??"").slice(1),p=f&&/\s/.test(f.text)?f:mE(h,n);for(;!p&&X7.test(h);)h=h.slice(0,-1),p=h?mE(h,n):null;p??(p=f),p&&o.push({start:u,span:p})}for(const l of P$(e)){const u=e.slice(l.start,l.end);o.push({start:l.start,span:{kind:"url",text:u,href:u}})}for(const l of JU(e)){const u=e.slice(l.start,l.end);o.push({start:l.start,span:{kind:"url",text:u,href:fv(u)??u}})}o.sort((l,u)=>l.start-u.start);let s=0;const a=l=>{if(!l)return;const u=r.at(-1);(u==null?void 0:u.kind)==="text"?u.text+=l:r.push({kind:"text",text:l})};for(const{start:l,span:u}of o)l<s||(a(e.slice(s,l)),r.push(u),s=l+u.text.length);a(e.slice(s))}function gE(e,t){return pv(e,t).map(n=>n.kind==="worktree"?`@${n.branch}`:n.text).join("")}function nH(e,t,n){return{text:e.slice(0,t.from)+n+e.slice(t.to),caret:t.from+n.length}}function rH(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=s=>e.map((a,l)=>({c:a,i:l,score:s(a)})).filter(a=>a.score>0).sort((a,l)=>l.score-a.score||a.i-l.i).map(a=>a.c),o=r(s=>Zk(s.name,n));return o.length>0?o:r(s=>Zk(s.description,n))}const kE=e=>e.slice(e.lastIndexOf("/")+1);function oH(e,t,n){const r=[],o=new Set;for(const s of e){const a=s.worktree;if(a.repoId!==n)continue;const l=kE(a.path);o.has(l)||(o.add(l),r.push({dir:l,id:a.id,title:a.title,branch:a.branch}))}for(const s of t??[]){const a=kE(s.path);s.repoId!==n||o.has(a)||(o.add(a),r.push({dir:a,id:s.id,title:s.title,branch:s.branch,archived:!0}))}return r}const wE=new WeakMap;function sH(e,t){let n=wE.get(e.visible);n||(n=new Map,wE.set(e.visible,n));const r=e.archived[t],o=n.get(t);if(o&&o.archived===r)return o.key;const s=JSON.stringify(oH(e.visible,r,t));return n.set(t,{archived:r,key:s}),s}function iH(e){const t=new Map;for(const n of JSON.parse(e))t.set(n.dir,n);return n=>t.get(n)??null}const U$="wt-[0-9a-f]{4}",aH=new RegExp(`(^|[^\\w\\-/\`])\`?${U$}(?![\\w\\-/\`])`),cH=new RegExp(`^(\`?)(${U$})\\1(?![\\w\\-/\`])`),ba=e=>Uo(e).replace(/"/g,"&quot;");function lH(e){return{name:"worktree",level:"inline",start:t=>{const n=aH.exec(t);return n?n.index+n[1].length:void 0},tokenizer(t){const n=cH.exec(t);if(n)return{type:"worktree",raw:n[0],text:n[2],code:n[1]!==""}},renderer(t){var l;const n=t.text,r=((l=e())==null?void 0:l(n))??null;if(!r)return t.code?`<code>${n}</code>`:n;const o=Rp({id:r.id,title:r.title,branch:r.branch,dir:n,...r.archived?{archived:!0}:{}}),s=r.archived?' data-archived=""':"",a=o.dot?` data-tip-dot="${ba(o.dot)}"`:"";return`<span class="chat-mention" data-worktree="${ba(r.id)}" data-branch="${ba(r.branch)}" data-dir="${ba(n)}"${s} data-tip="${ba(o.text)}" data-tip-detail="${ba(o.detail.join(`
219
- `))}"${a} data-tip-placement="follow">@${Uo(r.title)}<span class="chat-mention-dot"><span class="dot${o.dot?` ${ba(o.dot)}`:""}"></span></span></span>`}}}const uH=4*Ha;function dH(e,t,n){if(!e)return{from:t,to:t,at:n,span:Ha};const r=Math.min(H$(e,n),t),o=Math.min(Math.max(n-e.at,Ha),uH);return{from:r,to:t,at:n,span:o}}function H$(e,t){const n=t-e.at;return n>=e.span?e.to:e.from+Math.floor((e.to-e.from)*Math.max(0,n)/e.span)}function fH(e,t){if(t>=e.length)return e;const n=e.charCodeAt(t);return e.slice(0,n>=56320&&n<=57343?t+1:t)}Nn.use({extensions:[KU,t7,lH(()=>wn==null?void 0:wn.worktrees)],renderer:{code({text:e,lang:t}){const n=Cp((t??"").trim().toLowerCase().split(/\s+/)[0]??"","");let r=n?Th(Ap(e,n)):hv(e);return r.length?(wn!=null&&wn.streaming&&th.trimEnd().endsWith(e.trimEnd())&&(r=z$(r)),`<pre><code>${r.map(s=>s.map(a=>a.scope===Ip?`<a href="${Uo(a.text)}">${Uo(a.text)}</a>`:a.scope?`<span class="sy-${a.scope}">${Uo(a.text)}</span>`:Uo(a.text)).join("")).join(`
220
- `)}</code></pre>
221
- `):!1},codespan:e7,html(e){return wn!=null&&wn.keepHtml?!1:qU(e)},image({href:e,text:t}){if(wn!=null&&wn.base||/^(https?:|data:)/i.test(e))return!1;const n=wn==null?void 0:wn.stills,r=n==null?void 0:n.pictures.find(u=>u.path===e),o=Uo(t);if(r&&n){const u=n.urls.attachment(n.worktreeId,r.file);return`<button type="button" class="md-still" data-file="${Df(r.file)}" data-tip="Open full size" data-tip-placement="follow"><img src="${Df(u)}" alt="${Df(t)}"></button>`}const s=r$(e),a=wn==null?void 0:wn.fileRoot,l=s.startsWith("/")?s:a?`${a}/${s}`:null;return l?`<a href="${Df(l)}">${o}</a>`:o},table:n7}});const Df=e=>Uo(e).replace(/"/g,"&quot;"),Hu=DB(window);let wn=null,th="";const hH={USE_PROFILES:{html:!0},FORBID_TAGS:["style","form","button","textarea","select","map","area"],FORBID_ATTR:["style","id"],ALLOW_DATA_ATTR:!1},pH=/^(?:sy-[\w-]+|md-table)$/;Hu.addHook("uponSanitizeElement",e=>{var n;if(!(wn!=null&&wn.keepHtml)||e.nodeName!=="INPUT")return;const t=e;((n=t.getAttribute("type"))==null?void 0:n.toLowerCase())==="checkbox"?t.setAttribute("disabled",""):t.remove()});Hu.addHook("uponSanitizeAttribute",(e,t)=>{e.tagName==="A"&&t.attrName==="href"&&(t.attrValue=r$(t.attrValue)),wn!=null&&wn.keepHtml&&t.attrName==="class"&&(t.attrValue=t.attrValue.split(/\s+/).filter(n=>pH.test(n)).join(" "),t.attrValue||(t.keepAttr=!1))});Hu.addHook("afterSanitizeAttributes",e=>{const t=e.tagName==="A"?e.getAttribute("href")??"":"";if(t===v$){e.removeAttribute("href"),e.classList.add("link-pending","live-text");return}/^https?:/i.test(t)&&(e.setAttribute("target","_blank"),e.setAttribute("rel","noreferrer"));const n=wn!=null&&wn.fileRoot?ev(wn.fileRoot,t)??n$(t):null,r=n?null:o$(t);if(n?(e.classList.add("file-link"),e.setAttribute("data-tip",n.folder?`${n.path}/`:`${n.path}${n.line?`:${n.line}`:""}`),e.setAttribute("data-tip-placement","follow")):r&&(e.classList.add("file-link"),e.setAttribute("data-tip",r.folder?`${r.path}/`:`${r.path}${r.line?`:${r.line}`:""}`),e.setAttribute("data-tip-placement","follow")),e.tagName==="CODE"&&!e.closest("pre, a")){const s=tB(e.textContent??"");s&&e.setAttribute("data-path",s)}const o=wn==null?void 0:wn.base;if(e.tagName==="IMG"&&o){const s=t$(o.dir,e.getAttribute("src")??"");s&&e.setAttribute("src",o.urls.worktreeFile(o.worktreeId,s,o.version))}});function La(e,t){wn=t??null,th=t!=null&&t.streaming?BU(e):e;try{const n=Nn.parse(th,{async:!1,breaks:!(t!=null&&t.keepHtml)});return t!=null&&t.keepHtml?Hu.sanitize(n,hH):Hu.sanitize(n)}finally{wn=null,th=""}}function mH(e,t){const[n,r]=E.useState(e),o=E.useRef(null);return E.useEffect(()=>{if(!t){o.current=null;return}o.current=dH(o.current,e.length,performance.now());let s=0;const a=()=>{const l=o.current;if(!l)return;const u=H$(l,performance.now());r(fH(e,u)),u<l.to&&(s=requestAnimationFrame(a))};return a(),()=>cancelAnimationFrame(s)},[e,t]),t?n:e}function ol(e,t){var v,x,N,S;const[n,r]=E.useState(()=>La(e,t)),o=E.useRef(0),s=(v=t==null?void 0:t.base)==null?void 0:v.worktreeId,a=(x=t==null?void 0:t.base)==null?void 0:x.dir,l=(N=t==null?void 0:t.base)==null?void 0:N.version,u=(S=t==null?void 0:t.base)==null?void 0:S.urls,f=t==null?void 0:t.fileRoot,h=t==null?void 0:t.worktrees,p=t==null?void 0:t.stills,g=!!(t!=null&&t.keepHtml),y=!!(t!=null&&t.streaming),w=mH(e,y);return E.useEffect(()=>{const T=s!==void 0&&a!==void 0&&u!==void 0?{worktreeId:s,dir:a,version:l??null,urls:u}:void 0,j=T||f||h||p||g||y?{base:T,fileRoot:f,worktrees:h,stills:p,keepHtml:g,streaming:y}:void 0,$=performance.now()-o.current;if(y||$>=Ha){o.current=performance.now(),r(La(w,j));return}const R=setTimeout(()=>{o.current=performance.now(),r(La(w,j))},Ha-$);return()=>clearTimeout(R)},[w,s,a,l,u,f,h,p,g,y]),n}const gH=/^ {0,3}(`{3,}|~{3,})/,kH=/^#{1,6} \S/,wH=/^\s*(?:[-*+]|\d+[.)]) \S/,yH=/^> ?\S/,vH=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/,bH=/\[[^\]\n]+\]\((?:https?:|\.{0,2}\/|#)[^)\s]*\)/,xH=/\*\*[^\s*][^*\n]*\*\*/;function EH(e){var s,a;const t=e.split(`
222
- `),n=new Set;let r=null,o=0;for(let l=0;l<t.length;l++){const u=t[l],f=(s=gH.exec(u))==null?void 0:s[1];if(r){f!=null&&f.startsWith(r)&&(r=null,n.add("fence"));continue}if(f){r=f;continue}kH.test(u)&&!((a=t[l+1])!=null&&a.trim())&&n.add("heading"),wH.test(u)&&++o===2&&n.add("list"),yH.test(u)&&n.add("quote"),vH.test(u)&&n.add("table"),bH.test(u)&&n.add("link"),xH.test(u)&&n.add("bold")}return n.size}function SH(e,t){if(t)return Wa(t)==="markdown"?"rendered":"plain";const n=EH(e);return n>=2?"rendered":n===1?"source":"plain"}function Op({n:e,name:t,source:n,lines:r,chars:o,preview:s,text:a,href:l,onRemove:u,className:f=""}){const h=(n==null?void 0:n.path)??t??"",p=h.includes("/")?h.slice(0,h.lastIndexOf("/")):"",g=n?[p,n.ref?`at ${n.ref.slice(0,7)}`:""].filter(Boolean).join(" "):[p,`${r} ${r===1?"line":"lines"}`,`${o.toLocaleString()} chars`,s].filter(Boolean).join(" · "),y=d.jsxs(d.Fragment,{children:[d.jsx(xt,{name:"text",className:"icon-inline"}),d.jsxs("span",{className:"pick-target",children:[d.jsx("b",{children:t?t.slice(t.lastIndexOf("/")+1):n?CD(n):WS("paste",e)}),g&&d.jsxs("span",{className:"pick-file row-dim",children:[" · ",g]})]})]}),w=a!==void 0||l!==void 0;return d.jsx(nv,{className:We("paste-chip",f),label:y,tip:s||void 0,peek:w?d.jsx(q$,{text:a,href:l}):void 0,full:w?d.jsx(K$,{text:a,href:l,path:h||void 0}):void 0,menu:v=>O9({text:a,href:l},v),removeLabel:"Remove attachment",onRemove:u})}function W$(e,t){const[n,r]=E.useState(e??null),[o,s]=E.useState(!1);return E.useEffect(()=>{if(e!==void 0||!t)return;let a=!0;return fetch(t).then(l=>l.ok?l.text():Promise.reject(new Error(String(l.status)))).then(l=>{a&&r(l)}).catch(()=>{a&&s(!0)}),()=>{a=!1}},[e,t]),{text:e??n,failed:o}}function K$({text:e,href:t,path:n}){const{text:r,failed:o}=W$(e,t),s=E.useMemo(()=>r?SH(r,n):"plain",[r,n]),[a,l]=E.useState(null);if(o)return d.jsx("p",{className:"paste-full hint",children:"Toyon could not read that back."});if(!r||s==="plain")return d.jsx("pre",{className:"paste-full paste-text",children:r});const u=a??s==="rendered";return d.jsxs("div",{className:"paste-full paste-doc",children:[d.jsx("div",{className:"paste-doc-head",children:d.jsxs(Me,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>l(!u),"data-tip":u?"Text: read it as it was sent":"Preview: read it rendered",children:[d.jsx(xt,{name:u?"text":"book",className:"icon-inline"})," ",u?"text":"preview"]})}),u?d.jsx(_H,{text:r}):d.jsx("pre",{className:"paste-doc-body paste-text",children:r})]})}function _H({text:e}){const t=E.useMemo(()=>La(e),[e]);return d.jsx("div",{className:"paste-doc-body md md-preview",onClick:Ny,dangerouslySetInnerHTML:{__html:t}})}const NH=2e4;function q$({text:e,href:t}){const{text:n}=W$(e,t);return n?d.jsx("pre",{className:"paste-peek paste-text",children:n.slice(0,NH)}):null}function Mp({name:e,bytes:t,href:n,kept:r,uploading:o,progress:s,onRemove:a,className:l=""}){const u=nt();return d.jsx(nv,{className:We("file-chip",l),label:d.jsxs(d.Fragment,{children:[d.jsx(xt,{name:"file",className:"icon-inline"}),d.jsxs("span",{className:"pick-target",children:[d.jsx("b",{children:e}),d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",Rw(t),s!==void 0?d.jsxs(d.Fragment,{children:[" ","· ",d.jsxs("span",{className:"pick-progress",children:[s,"%"]})]}):o&&" · uploading"]})]})]}),tip:e,peek:n?d.jsx(q$,{href:n}):void 0,full:n?d.jsx(K$,{href:n,path:e}):void 0,menu:f=>M9({href:n},f,r&&{...r,sock:u}),removeLabel:"Remove attachment",onRemove:a})}function sl({rows:e,cursor:t,onCursor:n,onPick:r,onHint:o,hover:s=!1,plain:a=!1}){const l=Ys(),u=!l&&!a,f=E.useRef(null),[h,p]=E.useState(null),g=l&&!!o;JT(f,{rowOf:w=>{if(!g||w.closest("textarea"))return null;const v=w.closest(".slide"),x=v==null?void 0:v.dataset.row,N=x===void 0?void 0:e[Number(x)];return v&&x!==void 0&&(N!=null&&N.hint)&&!N.field?{el:v,key:x,rungs:1,rung:120}:null},onSlide:p,onPick:w=>o==null?void 0:o(Number(w))});const y=w=>{var v;w.target instanceof HTMLTextAreaElement||(w.preventDefault(),(v=w.currentTarget.querySelector("textarea"))==null||v.focus())};return d.jsx("div",{className:We("choices",s&&"choices-hover",l&&"choices-touch",a&&"choices-plain"),ref:f,children:e.map((w,v)=>{const x=!l&&t===v,N=fr({cursor:x,checked:w.checked}),S=w.tone==="deny"&&"choice-deny",T=()=>n==null?void 0:n(v),j=R=>{var M;if(!g)return R;const A=(h==null?void 0:h.key)===String(v)?h.step:null,I=A!==null&&A>0&&((M=w.hint)==null?void 0:M.on)!==!1;return d.jsxs("div",{className:"slide","data-row":v,children:[R,A!==null&&w.hint&&d.jsxs("span",{className:"slide-verb","data-rung":I?"hint":void 0,"aria-hidden":"true",children:[d.jsx("span",{className:"slide-word",children:w.hint.label}),d.jsx(xt,{name:w.hint.icon})]})]},v)},$=d.jsxs(d.Fragment,{children:[u&&d.jsx(ss,{k:String(v+1),className:"choice-num row-dim"}),d.jsx("span",{className:"choice-label",children:w.label}),u&&w.hint&&d.jsxs("span",{className:We("choice-hint row-dim",x&&w.hint.on!==!1&&"on"),children:[d.jsx(ss,{k:w.hint.k})," ",w.hint.label]}),w.description&&d.jsx("span",{className:"choice-desc",children:w.description}),w.sample&&d.jsx("pre",{className:"choice-sample",children:w.sample})]});return w.field?j(d.jsxs("div",{className:We("picker-item choice row-edge",S),"data-state":N,onMouseMove:T,onMouseDown:y,children:[$,d.jsx(Du,{ref:w.field.ref,bare:!0,font:"ui",rows:1,className:"choice-field",enterKeyHint:w.field.enterKeyHint,placeholder:w.field.placeholder,value:w.field.value,onChange:R=>{var A;return(A=w.field)==null?void 0:A.onChange(R.target.value)}}),l&&w.field.onSend&&d.jsx(Tt,{className:"choice-send",icon:"send",tone:"primary",label:"Send",onClick:w.field.onSend})]},v)):j(d.jsx("button",{type:"button",className:We("picker-item choice row-edge",S),"data-state":N,disabled:w.disabled,onMouseMove:T,onClick:()=>r(v),children:$},v))})})}function Z$({hints:e,note:t,className:n=""}){return d.jsxs("div",{className:`key-hints ${n}`.trim(),children:[e.map(([r,o])=>d.jsxs("span",{className:"key-hint",children:[d.jsx(ss,{k:r}),o]},r)),t&&d.jsx("span",{className:"key-note",children:t})]})}function Wu({anchored:e=!1,...t}){return e?d.jsx(TH,{...t,anchored:e===!0?{}:e}):d.jsx(jH,{...t})}function TH({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,anchored:o,coverBy:s,id:a,children:l}){const{onKey:u,back:f}=G$(t);return d.jsx(Qs,{className:We(r?"":"overlay-box","anchored",n),id:a,anchor:"parent",placement:{side:"bottom",align:"start",cover:!0,margin:0,...o},coverBy:s,onDismiss:e?()=>e():void 0,onKey:u,onBack:()=>f()||(e==null?void 0:e()),children:l})}function jH({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,id:o,children:s}){const{onKey:a,back:l}=G$(t);return d.jsx(Qs,{className:"overlay scrim",id:o,onDismiss:e?()=>e():void 0,onKey:a,onBack:()=>l()||(e==null?void 0:e()),onClick:u=>{e&&u.target===u.currentTarget&&e()},children:d.jsx("div",{className:We(r?"":"overlay-box",n),children:s})})}function G$(e){const t=Pn(),n=()=>{if(e)return e(),!0;const o=t.getState();return!o.overlay||o.choosingFolder?!1:(t.dispatch({a:"close",back:LN(o.overlay)}),!0)};return{onKey:o=>{o.key==="Escape"&&n()&&o.stopPropagation()},back:n}}function $H(e){const t=e.value.length;e.setSelectionRange(t,t)}function CH({text:e,params:t}){if(t.length===0)return e;const n=[];let r=0;for(const[o,s]of t)o>r&&n.push(e.slice(r,o)),n.push(d.jsx("span",{className:"picker-ghost-param",children:e.slice(o,s)},o)),r=s;return r<e.length&&n.push(e.slice(r)),n}function qr({items:e,filter:t,keyOf:n,row:r,rowClass:o,rowTitle:s,onPick:a,onBack:l,onActive:u,onSide:f,onTab:h,onQuery:p,completionOf:g,narrowTo:y,placeholder:w,initialQuery:v="",initialIndex:x,selectOnMount:N=!1,idleWhen:S,onIdlePick:T,anchored:j=!1,onEscape:$,lead:R,trailing:A,empty:I="no matches",footer:M,keys:P,rowMenu:F,groupOf:q,groupHead:W,headAlone:ee=!1,field:V}){const te=xn("picker"),[K,C]=E.useState(v),oe=E.useMemo(()=>t(e,K),[e,K,t]),U=E.useRef(null),B=Ys(),Q=Q3(N,!B&&!V);E.useEffect(()=>{if(!p)return;const _e=setTimeout(()=>p(K),150);return()=>clearTimeout(_e)},[K,p]);const ue=VT({results:oe,keyOf:n,q:K,onPick:a,listRef:U,onActive:u,onSide:f,completionOf:g,narrowTo:y,setQ:C,initialIndex:x,idle:(S==null?void 0:S(v))??!1,onIdlePick:T}),{index:he,ghost:Ne}=ue,De=V?V.open:!0;ct([De,v],()=>{!V||De||(C(v),ue.setIndex(S!=null&&S(v)?-1:0))}),ct([De],()=>{if(!V||!De||B)return;const _e=()=>{const $e=Q.current;!$e||document.activeElement===$e||($e.focus(),N&&$e.select())};_e();const be=requestAnimationFrame(_e);return()=>cancelAnimationFrame(be)});const Be=E.useRef(!1),Z=typeof P=="function"?P(ue.active,K):P,J=[];Z!=null&&Z.nav&&J.push(["↑↓",Z.nav]),Z!=null&&Z.side&&f&&J.push(["←→",Z.side]),Z!=null&&Z.complete&&(Ne!=null&&Ne.accept)&&J.push(["tab",Z.complete]),Z!=null&&Z.tab&&h&&J.push(["tab",Z.tab]),Z!=null&&Z.pick&&J.push(["enter",Z.pick]),Z!=null&&Z.back&&J.push(["esc",Z.back]);const pe=_e=>d.jsxs("div",{...V==null?void 0:V.attrs,className:We("picker-input",V&&"picker-field",V==null?void 0:V.className),"data-open":(V==null?void 0:V.open)||void 0,onMouseDown:be=>{var $e;be.target.closest("input, .float")||(be.preventDefault(),($e=Q.current)==null||$e.focus())},children:[R,d.jsxs("div",{className:"picker-caret",children:[d.jsx(Ho,{font:"mono",bare:!0,ref:Q,value:K,spellCheck:!1,"aria-controls":V==null?void 0:V.id,"aria-expanded":V?V.open:void 0,onFocus:()=>{V&&!V.open&&V.onOpen()},onBlur:be=>{const $e=be.relatedTarget;V!=null&&V.open&&$e instanceof Element&&!$e.closest(".float")&&l()},onMouseDown:be=>{const $e=document.activeElement!==be.currentTarget;if(Be.current=$e,V&&$e){const Ze=document.getSelection();Ze&&(!Ze.isCollapsed||Ze.toString()!=="")&&Ze.removeAllRanges()}},onClick:be=>{if(!V||!Be.current)return;Be.current=!1;const $e=be.currentTarget;setTimeout(()=>{document.activeElement===$e&&$e.selectionStart===$e.selectionEnd&&$e.select()},0)},onChange:be=>{C(be.target.value),ue.setIndex(S!=null&&S(be.target.value)?-1:0),V&&!V.open&&V.onOpen()},onKeyDown:be=>{var $e;if(V&&!V.open){if(be.key==="ArrowDown"||be.key==="ArrowUp")V.onOpen();else if(be.key==="Escape"){$H(be.currentTarget),be.currentTarget.blur();return}}if(F&&ue.active&&(be.key==="ContextMenu"||be.key==="F10"&&be.shiftKey)){const Ze=($e=U.current)==null?void 0:$e.querySelector('[data-state~="cursor"]');if(Ze){be.preventDefault(),be.stopPropagation(),go.open({items:F(ue.active),owner:"picker",target:Ze,anchor:Ze.getBoundingClientRect()});return}}ue.onKeyDown(be)||!h||be.key!=="Tab"||be.shiftKey||(be.preventDefault(),h())},placeholder:w}),Ne&&d.jsxs("div",{className:"picker-ghost","aria-hidden":"true",children:[d.jsx("span",{className:"picker-typed",children:K}),CH(Ne)]})]}),A,_e]}),de=new Map;if(q)for(const _e of oe)de.set(q(_e),(de.get(q(_e))??0)+1);const ie=d.jsxs("div",{className:"picker-list",ref:U,onMouseDown:_e=>{V&&_e.target!==_e.currentTarget&&_e.preventDefault()},children:[oe.map((_e,be)=>{const $e=q==null?void 0:q(_e),Ze=$e!==void 0&&(ee||de.size>1)&&(be===0||(q==null?void 0:q(oe[be-1]))!==$e)?d.jsx("div",{className:"picker-group",children:(W==null?void 0:W($e,de.get($e)??0))??$e}):null;return d.jsxs(E.Fragment,{children:[Ze,d.jsx("button",{className:We("picker-item",o==null?void 0:o(_e)),"data-state":fr({cursor:be===he}),title:s==null?void 0:s(_e),onMouseMove:()=>be!==he&&ue.setIndex(be),onClick:()=>{var rt;ue.pick(_e),(rt=Q.current)==null||rt.focus()},...te.contextMenu(()=>(F==null?void 0:F(_e))??[]),children:r(_e,be===he,K)})]},n(_e))}),oe.length===0&&d.jsx("div",{className:"empty",children:typeof I=="function"?I(K):I}),M==null?void 0:M(K,oe)]}),ye=J.length>0&&d.jsx(Z$,{hints:J});return V?pe(V.open&&d.jsxs(Wu,{onClose:l,onEscape:$,boxClass:"picker",anchored:j,id:V.id,children:[ie,ye]})):d.jsxs(Wu,{onClose:l,onEscape:$,boxClass:"picker",anchored:j,coverBy:R?".picker-input > *:first-child":A?".picker-input > *:last-child":void 0,children:[pe(),ie,ye]})}function Bs({value:e,reads:t,options:n,onChange:r,placeholder:o,hint:s,className:a,onClose:l}){const[u,f]=E.useState(!1),h=()=>{f(!1),l==null||l()},p=t??e,g=n.find(w=>w.id===p),y=(g==null?void 0:g.chip)??(g==null?void 0:g.label)??p;return d.jsxs("span",{className:"chip-picker",children:[d.jsx(Me,{variant:"ghost",tone:"chrome",mono:!0,on:u,className:We("chip-picker-btn",a),...Nt(s),onClick:()=>u?h():f(!0),children:y}),u&&d.jsx(qr,{anchored:{flip:"both",margin:0},onEscape:h,items:n,filter:(w,v)=>{const x=v.trim().toLowerCase().split(/\s+/).filter(Boolean);return w.filter(N=>{const S=`${N.prefix??""} ${N.label??N.id} ${N.suffix??""} ${N.id}`.toLowerCase();return x.every(T=>S.includes(T))})},keyOf:w=>w.id,initialIndex:w=>Math.max(0,w.findIndex(v=>v.id===e)),lead:d.jsx(Me,{tone:"chrome",mono:!0,on:!0,className:"chip-picker-lead",onClick:h,children:y}),placeholder:o,rowClass:()=>"picker-row",row:w=>d.jsxs(d.Fragment,{children:[w.id===e&&d.jsx("span",{className:"row-current","aria-hidden":"true"}),d.jsxs("span",{className:We("chip-option",w.disabled&&"chip-option-off"),"aria-disabled":w.disabled,children:[d.jsxs("span",{className:"chip-option-name",children:[w.prefix?`${w.prefix} `:null,w.label??w.id,w.suffix?d.jsx("span",{className:"chip-option-suffix",children:` ${w.suffix}`}):null]}),w.description&&d.jsx("span",{className:"chip-option-desc row-dim",children:w.description})]})]}),onPick:w=>{w.disabled||(r(w.id),h())},onBack:h})]})}const mv=e=>e.startsWith("remote:")?e.slice(7):null;function AH(e,t){var o,s;const n=(s=(o=t.worktree.sources)==null?void 0:o[e])==null?void 0:s.at,r=VS(n);return r!==void 0?`remote:${r}`:Zh(n)?"here":"main"}function V$(e,t,n,r){var x,N,S,T;const o=AH(e,t),s=((x=t.remoteBehind)==null?void 0:x.includes(e))??!1,a=(r==null?void 0:r.dirty)??0,l=(S=(N=t.borrowed)==null?void 0:N.find(j=>j.name===e))==null?void 0:S.status,u=l!==void 0&&!Hh(l),f=((T=t.procs)==null?void 0:T.some(j=>j.name===e&&j.status==="preparing"))??!1,h=["main runs it for every worktree",...a>0?[Jc(a,e)]:[],...u?[`main's ${e} is ${l}`]:[],...f?[`${e} is setting up here and takes over once it answers`]:[]].join("; "),p={id:"main",label:"main",chip:`${e} · main`,description:h},g={id:"here",label:"here",chip:`${e} · here`,description:f?"this worktree is setting up its own":"this worktree runs its own"},y=Object.entries(GS(n.config.run[e]??"")).map(([j,$])=>({id:`remote:${j}`,label:j,chip:`${e} · ${j}`,description:$})),w=s?[g,p,...y]:[p,g,...y];let v;if(s)v=`${e} edits here are not what the page is talking to; pick here to run them`;else if(o==="main"){const j=f?"; its own is setting up here":a>0?`; ${Jc(a,e)}`:"";v=`${e} runs on main for every worktree${j}. Click to change`}else o==="here"?v=`${e} runs here: this worktree's own. Click to change`:v=`${e} points at ${mv(o)} for this worktree. Click to change`;return{value:o,held:s,hint:v,options:w}}function IH(e,t,n,r){if(t===n)return null;const o=mv(n),a={t:"set-proc-source",worktreeId:r,name:e,source:o!==null?{remote:o}:n==="main"?"main":"here"};return n==="main"&&t==="here"?{msg:a,confirm:`Stop this worktree's own ${e} and use main's?
223
-
224
- What they hold that main's do not (a database of their own) is not carried over.`}:{msg:a}}function Y$(e,t,n,r,o){const s=IH(t,n,r,o);s&&(s.confirm&&!window.confirm(s.confirm)||e==null||e.send(s.msg))}function RH({name:e,wt:t,repo:n,trunk:r,onClose:o}){const s=nt(),{value:a,held:l,hint:u,options:f}=V$(e,t,n,r);return d.jsx(Bs,{value:a,options:f,onChange:h=>Y$(s,e,a,h,t.worktree.id),onClose:o,className:We("source-chip",l&&"source-held"),hint:u,placeholder:`where ${e} runs for this worktree`})}function OH(e,t,n,r,o){var g,y;const s=`this worktree changed ${t??"what it runs on"}`;if(!n||!r||!(e in(r.tier??{})))return{word:"ran here",text:`${e} ran here: ${s}`,value:null,rows:[]};const{value:a,options:l}=V$(e,n,r,o),u=l.map(w=>({...w,current:w.id===a})),f=(y=(g=n.procs)==null?void 0:g.find(w=>w.name===e))==null?void 0:y.status,h=a==="here"||f==="preparing";let p;if(h){const w=f??"starting",v=w==="running"?`${e} runs here`:`${e} is ${ny(w).toLowerCase()} here`;p=w==="preparing"||w==="starting"?`${v}: ${s}; the page reaches main's until it answers`:`${v}: ${s}`}else a==="main"?p=`${e} runs on main for every worktree again; it ran here after ${s}`:p=`${e} points at ${mv(a)} for this worktree; it ran here after ${s}`;return{word:h?"runs here":"ran here",text:p,value:a,rows:u}}function MH({item:e,worktreeId:t}){return d.jsx(d.Fragment,{children:e.names.map(n=>d.jsx(LH,{name:n,file:e.file,ts:e.ts,worktreeId:t},n))})}function LH({name:e,file:t,ts:n,worktreeId:r}){const o=nt(),s=L(h=>Jt(h,r)),a=L(h=>bs(h,s==null?void 0:s.repoId)),l=L(h=>Hi(h,s==null?void 0:s.repoId)),u=OH(e,t,s,a,l),f=s&&u.value!==null?{id:s.worktree.id,value:u.value}:null;return d.jsx(ar,{icon:"run",word:u.word,tone:"quiet",at:n,under:f&&d.jsx(sl,{hover:!0,plain:!0,rows:u.rows.map(h=>({label:h.label??h.id,description:h.description,checked:h.current})),onPick:h=>{const p=u.rows[h];p&&Y$(o,e,f.value,p.id,f.id)}}),children:d.jsx("span",{className:"daemon-text",children:u.text})})}function X$(e){return e.replace(/^([\t ]*)\*\*(\S(?:[^\n]*\S)?)\*\*([\t ]*)$/gm,"$1$2$3")}const Q$=120,PH=/^\*\*(\S(?:[^\n]*\S)?)\*\*$/;function J$(e){var n,r;const t=[];for(const o of e.split(/\n[\t ]*\n/)){const s=o.trim();if(!s)continue;const a=((r=(n=PH.exec(s))==null?void 0:n[1])==null?void 0:r.replace(/`/g,""))??"";if(!a||a.length>Q$)return[];t.push(a)}return t}function eC(e){const t=J$(e);if(t.length)return t.at(-1);const n=X$(e).trim().replace(/`/g,"");return n&&!n.includes(`
225
- `)&&n.length<=Q$?n:""}const DH={read:"read",edit:"edit",delete:"delete",move:"move",search:"search",execute:"run",think:"think",fetch:"fetch",switch_mode:"mode",other:"tool"},yE={read:"book",edit:"edit",delete:"trash",move:"move",search:"search",execute:"run",think:"bulb",fetch:"globe",switch_mode:"swap",other:"dot"},tC="Skill",nC="ScheduleWakeup",Wg=new Map([[Tw,"chat"],["Monitor","clock"],[nC,"clock"],["TaskOutput","terminal"],[tC,"slash"],[jw,"handoff"],[LS,"worktrees"],[PS,"run"],["EnterPlanMode","swap"]]),zH=new Map([["Read","read"],["Edit","edit"],["Write","edit"],["MultiEdit","edit"],["NotebookEdit","edit"],["Bash","execute"],["Grep","search"],["Glob","search"],["WebSearch","fetch"],["WebFetch","fetch"],["EnterPlanMode","switch_mode"],["ExitPlanMode","switch_mode"]]);function FH(e){const t=e.input&&typeof e.input=="object"?e.input.names:void 0,n=Array.isArray(t)?t.filter(r=>typeof r=="string"):[];return n.length>0?`run ${n.join(", ")} here`:"run it here"}function rw(e){var o,s;if(e.name!==Pa)return null;const t=/^select:(.*)$/.exec(Nr(e,"query").trim()),n=(s=(o=t==null?void 0:t[1])==null?void 0:o.split(",")[0])==null?void 0:s.trim();if(!n)return null;const r=zH.get(n);return r?{name:n,kind:r}:{name:n}}function BH(e){if(e.name!==tC)return"";const t=Nr(e,"skill").trim();if(!t)return"";const n=Nr(e,"args").trim();return n?`/${t} ${n}`:`/${t}`}const ow={grep:"search",rg:"search",ag:"search",ack:"search",find:"search",fd:"search",cat:"book",head:"book",tail:"book",nl:"book",less:"book",bat:"book",ls:"folder",tree:"folder",mkdir:"folder",rm:"trash",rmdir:"trash",mv:"move",curl:"globe",wget:"globe",git:"branch"},UH=/(^|\s)(-[A-Za-z]*[iI]|--in-place)/,vE=String.raw`(?:"[^"]*"|'[^']*'|[^\s;&|]+)`,bE=new RegExp(String.raw`^\s*(?:(?:cd|echo)\s+${vE}\s*(?:&&|;)|mkdir(?:\s+${vE})+\s*(?:&&|;)|(?:export\s+)?[A-Za-z_]\w*=(?:"[^"]*"|'[^']*'|[^\s;&|()\`]*)\s*(?:&&|;|(?=\s)))\s*`),HH=/^python[\d.]*$/,WH=new RegExp(`open\\([^)]*,\\s*["'][wax]|(?<!std(?:out|err))\\.write\\(|\\.write_text\\(`);function rC(e){let t=e;for(let n=t.replace(bE,"");n!==t;n=t.replace(bE,""))t=n;return t}const KH=new RegExp("(?<![0-9&])>{1,2}\\s*(?!\\/dev\\/null|&)[^\\s&>]"),oC=/&&|;|\n|\|/;function qH(e){return e.split(oC).some(t=>/^\s*(?:\S*\/)?sed\s/.test(t)&&UH.test(t))}function ZH(e){return e.split(/&&|;|\n/).map(t=>rC(t).trim().split(/\s+/)[0]??"").filter(Boolean).every(t=>ow[t.slice(t.lastIndexOf("/")+1)]==="trash")}function GH(e){const t=rC(e).trim(),n=t.split(/\s+/)[0]??"",r=n.slice(n.lastIndexOf("/")+1),o=r==="sed"?qH(e)?void 0:"book":ow[r];if(o==="book"||o==="search"){const s=t.split(oC)[0]??"";if(KH.test(s))return r==="cat"&&s.includes("<<")?"edit":void 0}if(!(o==="trash"&&!ZH(t)))return o||(HH.test(r)?t.includes("<<")&&WH.test(t)?"edit":void 0:ow[r])}function Nr(e,t){const n=e.input,r=n?n[t]:void 0;return typeof r=="string"?r:""}function VH(e){if(e.name!==jw)return"";const t=e.input;if(!Array.isArray(t==null?void 0:t.pieces))return"";const n=t.pieces.map(o=>o&&typeof o=="object"?o.title:void 0).filter(o=>typeof o=="string"&&o.trim()!=="").map(o=>o.trim());return n.length===0?"":`offered ${n.length===1?n[0]:`${n.slice(0,-1).join(", ")} and ${n.at(-1)}`}`}function YH(e){return e.name===LS&&!Nr(e,"query").trim()?"the open ones and the newest archived":""}const XH=/^(?:\/(?:usr\/)?bin\/)?(?:ba|z|da)?sh\s+(?:-[a-zA-Z]+\s+)*(?:'([^']*)'|"((?:[^"\\]|\\.)*)")\s*$/;function sC(e){const t=XH.exec(e.trim());return t?t[1]!==void 0?t[1]:(t[2]??"").replace(/\\(["\\$`])/g,"$1"):e}const QH="Guardian Review";function iC(e){return e.toolKind==="think"&&e.title===QH}function JH(e){const t=o=>{var a,l;return((l=(a=[...e.matchAll(new RegExp(`^${o}:[ \\t]*(.+)$`,"gm"))].at(-1))==null?void 0:a[1])==null?void 0:l.trim().toLowerCase())??""},n=t("Status"),r=t("Risk");return!n||n==="in progress"?"reviewing":r?`${n}, ${r} risk`:n}function Ku(e,t=[]){const n=sC(Nr(e,"command")),r=e.name===Pa?"":Nr(e,"query"),o=e.name===nC?Nr(e,"reason"):"",s=e.name===PS?FH(e):"",a=aC(e)||n||Nr(e,"path")||Nr(e,"pattern")||r||o||s,l=YI(e.name),u=a||BH(e)||VH(e)||YH(e)||(e.title&&e.title!==e.name?e.title:"")||(l?l.tool:""),f=Lp(Nr(e,"description")||(l?Nr(e,"rationale"):"")||u,t),h=e.toolKind&&e.toolKind in yE?e.toolKind:"other",p=DH[h],g=e.name===Tw,y=h!=="other"||Wg.has(e.name),w=e.name===e.title||e.name===Pi||e.name===MS,v=l?l.server:f&&(y||w||e.name===Pa)?"":e.name,x=v&&v.toLowerCase()!==p?v:f?"":p,N=(h==="execute"||h==="other")&&n?GH(n):void 0;return{label:g?"ask":p,name:x,icon:Wg.get(e.name)??Wg.get(e.title??"")??N??(l&&h==="other"?"cube":yE[h]),hint:f===x?"":f,command:n&&n!==f?n:""}}const eW=/^Async agent launched/m;function tW(e){if(!e.subagent)return!1;const t=e.input;return!!e.detached||(t==null?void 0:t.run_in_background)===!0||!!e.output&&eW.test(e.output)}const nW={read:"choosing a file",edit:"writing the change",delete:"choosing a file",move:"choosing the files",search:"writing the search",execute:"writing the command",fetch:"writing the url"};function rW(e){const t=e.toolKind;return e.subagent?Nr(e,"prompt")?"":"writing the brief":!Bh(e.input)||!zS({name:e.name,kind:t},e.input)?"":$w(t)?nW[t]:"writing the question"}function sw(e,t){const n=cC(t),r=n[0],o=Nr(e,"description");return o&&r&&!r.code&&r.text===o?n.slice(1):n}function il(e){return aC(e)||Nr(e,"path")}function oW(e){return Nr(e,"description")}function aC(e){return Nr(e,"file_path")||Nr(e,"filepath")||Nr(e,"filePath")||sW(e)}function sW(e){const t=e.input,n=Array.isArray(t==null?void 0:t.locations)?t.locations[0]:void 0,r=n&&typeof n=="object"?n.path:void 0;return typeof r=="string"?r:""}function Lp(e,t){if(!e.startsWith("/"))return e;for(const n of t)if(n&&e.startsWith(`${n}/`))return e.slice(n.length+1);return e}const iW=/^(`{3,})([\w+#.-]*)\s*$/;function cC(e){var l;const t=[];let n=[],r="",o=!1,s=0;const a=()=>{const u=n.join(`
226
- `).replace(/^\n+|\n+$/g,"");u.trim()&&t.push({code:o,diff:aW(u,r),lang:o?r:"",text:u}),n=[]};for(const u of e.split(`
227
- `)){const f=iW.exec(u),h=((l=f==null?void 0:f[1])==null?void 0:l.length)??0;if(!f||o&&(h<s||f[2])){n.push(u);continue}a(),o=!o,s=o?h:0,r=o?(f[2]??"").toLowerCase():""}return a(),t}function aW(e,t){return t==="diff"||t==="patch"||/^diff --git /m.test(e)||/^@@ .*@@/m.test(e)?!0:/^--- /m.test(e)&&/^[+-]/m.test(e)}const cW=/^(diff --git |index [0-9a-f]+\.\.|new file mode |deleted file mode |similarity index |rename (from|to) |Binary files )/;function lW(e){const t=[];for(const n of e.split(`
228
- `)){const r=dW(n);if(r==="meta"&&!n.startsWith("diff --git "))continue;const o=r==="add"||r==="del"||n.startsWith(" ");t.push({kind:r,text:o?n.slice(1):n})}return uW(t),t}function uW(e){var t,n,r,o;for(let s=0;s<e.length;){if(((t=e[s])==null?void 0:t.kind)!=="del"&&((n=e[s])==null?void 0:n.kind)!=="add"){s++;continue}let a=s;for(;((r=e[a])==null?void 0:r.kind)==="del";)a++;let l=a;for(;((o=e[l])==null?void 0:o.kind)==="add";)l++;const u=e.slice(s,a),f=e.slice(a,l),h=u.length>0&&f.length>0?KR(u.map(p=>p.text).join(`
229
- `),f.map(p=>p.text).join(`
230
- `)):null;h&&(xE(u,Ob(h.before)),xE(f,Ob(h.after)));for(const p of[...u,...f])p.spans??(p.spans=[]);s=l}}function xE(e,t){if(t.length===e.length)for(const[n,r]of e.entries())r.spans=t[n]}function dW(e){return e.startsWith("@@")?"hunk":e.startsWith("+++")||e.startsWith("---")||cW.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":""}function fW(e){const t=e.tools.at(-1);return t.done||t.parentToolId?!1:t.name===Pi?!t.background:!!t.background}const lC=new Set(["read","edit","fetch"]);function gv(e,t){if(e.isError||!e.toolKind||!lC.has(e.toolKind)||$w(e.toolKind)&&Bh(e.input))return"";const{hint:n}=Ku(e,t);return n?`${e.parentToolId??""}
231
- ${e.toolKind}
232
- ${n}`:""}function EE(e,t,n){if(!t||!("tools"in t)||e.done||e.isError||!e.toolKind||!lC.has(e.toolKind))return!1;const r=t.tools[0];return r.toolKind===e.toolKind&&r.parentToolId===e.parentToolId&&gv(r,n)!==""}function hW(e,t){const n=e.length-1,r=e[n];if(!r||!("tools"in r)||r.next)return-1;const o=r.tools[0],s=r.tools.at(-1);return o.parentToolId||!s.done||s.isError?-1:(o.toolKind==="edit"||o.toolKind==="read"&&r.tools.length>1)&&gv(o,t)?n:-1}function uC(e){const t=new Set;for(const n of e)n.kind==="tool"&&(n.subagent&&t.add(n.id),n.parentToolId&&t.add(n.parentToolId));return t}function pW(e){return!e.done||e.isError?!1:!!e.cut||!e.output&&zS({name:e.name,kind:e.toolKind},e.input)}const SE=new WeakMap;function mW(e,t,n){if(e.name!==Pa||e.isError)return e;if(!e.done)return null;if(!rw(e))return t?e:null;if(!t||!n)return null;let r=SE.get(e);if(!r){const o=rw(e),{output:s,title:a,toolKind:l,...u}=e;r={...u,name:o.name,input:{},done:!1,...o.kind?{toolKind:o.kind}:{}},SE.set(e,r)}return r}function gW(e,t){return t&&(e==null?void 0:e.kind)==="tool"&&e.name===Pa&&e.done&&!e.isError&&rw(e)!==null}function kW(e,t,n=!1){const r=uC(e),o=[],s=new Map;let a="";for(const[l,u]of e.entries()){if(u.kind!=="tool"){a="",o.push({at:l,item:u});continue}if(pW(u))continue;const f=mW(u,l===e.length-1,n);if(!f)continue;if(r.has(f.id)){a="";const y={at:l,spawn:f,run:[],end:l};s.set(f.id,{entry:y,key:""}),o.push(y);continue}const h=gv(f,t),p=f.parentToolId?s.get(f.parentToolId):void 0;if(p){const y=p.entry.run,w=y.at(-1);h&&h===p.key&&w?w.tools.push(f):!h&&EE(f,w,t)?w.next=f:y.push({at:l,tools:[f]}),p.key=h,p.entry.end=l;continue}const g=o.at(-1);if(h&&h===a&&g&&"tools"in g){g.tools.push(f);continue}if(!h&&EE(f,g,t)){g.next=f;continue}a=h,o.push({at:l,tools:[f]})}return o}function wW(e){return e.reduce((t,n)=>t+n.tools.length,0)}function yW(e){const t=new Set,n=new Set;let r=!0;for(let s=e.length-1;s>=0;s--){const a=e[s];if(a.kind!=="tool"||!a.parentToolId){r=!1;continue}n.add(a.parentToolId),(r||!a.done)&&t.add(a.parentToolId)}let o=!0;for(let s=e.length-1;s>=0;s--){const a=e[s];Qu(a)&&(o=!1),!(a.kind!=="tool"||!a.subagent)&&(a.isError?t.delete(a.id):a.done?tW(a)?o&&!n.has(a.id)&&t.add(a.id):t.delete(a.id):t.add(a.id))}return t}function vW(e,t){const n=[],r=[];let o=-1;for(const s of e)"spawn"in s?t.has(s.spawn.id)?n.push(s):(o=Math.max(o,s.end),r.push({key:o,entry:s})):"tools"in s&&fW(s)?n.push(s):r.push({key:s.at,entry:s});return r.sort((s,a)=>s.key-a.key),{flow:r.map(s=>s.entry),floating:n}}function bW(e,t=!1){const n=uC(e);return gW(e.at(-1),t)?!0:e.some(r=>r.kind==="tool"&&!r.done&&!r.parentToolId&&!r.background&&r.name!==Pa&&(!n.has(r.id)||Bh(r.input)))}function dC(e,t=!1){const n=new Set;let r=!1,o=!1;return e.forEach((s,a)=>{if(!("tools"in s)||!t&&s.tools[0].parentToolId)return;const l=s.tools.at(-1);if(l.done||l.background||l.name===Pi)return;const u=DS({name:l.name,kind:l.toolKind});(o||r&&u)&&n.add(a),r=!0,o||(o=u)}),n}function xW(e){return e.findIndex(t=>!t.tools.at(-1).done)}function kv(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function fC(e,t){return!e||!t?e===t:e.length===t.length&&e.every((n,r)=>{var o,s;return n.at===((o=t[r])==null?void 0:o.at)&&n.next===((s=t[r])==null?void 0:s.next)&&kv(n.tools,t[r].tools)})}function EW(e,t){if(e.length===0)return t;const n=new Map;for(const s of e)n.set(s.at,s);let r=e.length===t.length;const o=t.map((s,a)=>{const l=n.get(s.at),u=l!==void 0&&SW(l,s)?l:s;return u!==e[a]&&(r=!1),u});return r?e:o}function SW(e,t){return"spawn"in e?"spawn"in t&&e.spawn===t.spawn&&e.end===t.end&&fC(e.run,t.run):"tools"in e?"tools"in t&&e.next===t.next&&kv(e.tools,t.tools):"item"in t&&e.item===t.item}function _W(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(!("spawn"in n)){if("tools"in n){const r=n.tools[0];if((r==null?void 0:r.toolKind)==="think"&&!iC(r))return t;continue}if(n.item.kind==="thinking"){if(!n.item.text.trim())continue;return eC(n.item.text)?-1:t}if(NW(n.item))return-1}}return-1}function NW(e){return e.kind==="assistant"?!!e.text.trim():e.kind==="ask"?e.ask.kind==="question"||!!e.outcome:!0}function TW(e,t){for(let n=e.length-1;n>=0;n--){const r=e[n];if("seq"in r&&r.seq!==void 0&&r.seq<=t)return n}return-1}function Pp(e,t,n,r={}){var s;if(!t)return[];const o=[];for(const a of e){const l=a.worktree;if(l.repoId!==t||l.id===n||l.kind!=="worktree")continue;const u=(s=r[l.id])==null?void 0:s.op;o.push({id:l.id,title:l.title,branch:l.branch,dir:l.path.slice(l.path.lastIndexOf("/")+1),dot:pN(a,u),state:mN(a,u),at:Da(l)})}return o}function hC(e,t){const n=e.trim();if(!n||/\s/.test(n))return null;const r=t.find(o=>o.branch===n||o.dir===n);return r?`@${r.title} `:null}function jW(e,t){return/[/-]/.test(e)?hC(e,t):null}const _E=e=>e.toLowerCase().replace(/[^a-z0-9]/g,"");function NE(e,t){const n=_E(e);if(!n)return!e.trim();const r=/\s$/.test(e);return[t.title,t.branch].some(o=>{const s=_E(o);return s.includes(n)&&(!r||!s.endsWith(n))})}function to({id:e,title:t,inert:n}){const r=nt(),o=ht(),s=L(w=>w.visible),a=L(w=>w.shipping),l=L(w=>Jt(w,e)),u=L(w=>l?null:Object.values(w.archived).flat().find(v=>v.id===e)??null),f=E.useMemo(()=>l?Pp(s,l.worktree.repoId,null,a).find(w=>w.id===e)??null:null,[s,a,l,e]),h=(f==null?void 0:f.branch)??(u==null?void 0:u.branch);if(!h)return d.jsx("span",{children:t??e});const p=Rp(f??{title:(u==null?void 0:u.title)??t??h,archived:!0,branch:h}),g=Nt(p.text,void 0,{placement:"follow",dot:p.dot,detail:p.detail}),y=Tp({kind:"worktree",id:e,archived:!f},null,{sock:r,dispatch:o});return d.jsxs("span",{className:"chat-mention","data-worktree":e,"data-branch":h,"data-archived":f?void 0:"",...g,onClick:n?void 0:w=>{w.stopPropagation(),y==null||y()},children:["@",p.text,p.dot&&d.jsx("span",{className:"chat-mention-dot",children:d.jsx("span",{className:`dot ${p.dot}`})})]})}function $W(e){const t=e.body??"";return e.note?`${t.trimEnd()}
233
-
234
- ---
235
-
236
- You added: ${e.note}
237
- `:t}function CW({item:e,worktreeId:t,marked:n,children:r}){nt();const o=ht(),s=e.via==="plan",a=()=>{if(s&&e.path&&t){Rn({dispatch:o},{worktreeId:t,path:e.path,view:"preview"});return}o({a:"open-loose",v:{worktreeId:t??e.origin.id,name:`${e.origin.title}.md`,text:$W(e),binary:!1,tooLarge:!1,source:{kind:"text"},seq:$o()}})};return d.jsx(ar,{icon:"handoff",word:s?"plan":"piece",tone:"accent",at:e.ts,"data-state":fr({cursor:n}),below:[e.note?`you added: ${e.note}`:void 0,r],children:d.jsxs("span",{className:"daemon-text",children:["from ",d.jsx(to,{id:e.origin.id,title:e.origin.title}),e.origin.project?` in ${e.origin.project}`:""," · ",d.jsx(Me,{variant:"inline","data-tip":s?"Read the plan this worktree was given, beside the chat":"Read the message beside the chat",onClick:a,children:s?"the plan":"the message"})]})})}function TE({item:e,worktreeId:t}){var y;nt();const n=ht();if(e.state==="held"||e.state==="proposed")return null;const r=e.plan,o=r&&t?d.jsx(Me,{variant:"inline",onClick:()=>Rn({dispatch:n},{worktreeId:t,path:r,view:"preview"}),children:e.companion?"the plan":"the list"}):null;if(e.state==="going"){const w=p5(e);return d.jsx(ar,{icon:"handoff",word:"handed off",tone:"accent",at:e.ts,children:d.jsx("span",{className:"daemon-text",children:w.length===0?d.jsx("span",{className:"live-text",children:"starting"}):w.map((v,x)=>d.jsxs(E.Fragment,{children:[x>0&&(x===w.length-1?" and ":", "),v.worktreeId?d.jsx(to,{id:v.worktreeId,title:v.title}):d.jsxs("span",{className:"handoff-wait",children:[v.title,d.jsx("span",{className:"dot idle"})]}),v.repoName?` in ${v.repoName}`:""]},v.pieceId))})})}if(e.state==="declined")return d.jsx(ar,{icon:"close",word:"not handed off",tone:"quiet",at:e.ts,below:e.reason,children:d.jsxs("span",{className:"daemon-text",children:["nothing started",o&&d.jsxs(d.Fragment,{children:[" · ",o]})]})});const s=w=>e.pieces.find(v=>v.id===w),a=w=>{var v;return((v=s(w))==null?void 0:v.title)??w},l=e.outcomes.filter(w=>w.fate==="worktree"&&w.worktreeId),u=e.outcomes.filter(w=>w.fate==="worktree"&&w.after),f=e.outcomes.filter(w=>w.fate==="send"&&w.worktreeId),h=e.outcomes.filter(w=>w.fate==="here").length,p=e.outcomes.filter(w=>w.error),g=[];for(const w of l)g.push(d.jsxs("span",{children:[d.jsx(to,{id:w.worktreeId,title:w.title??a(w.pieceId)}),w.repoName?` in ${w.repoName}`:""]},w.pieceId));for(const w of u){const v=(y=s(w.pieceId))==null?void 0:y.after;g.push(d.jsxs("span",{children:[a(w.pieceId)," queued after"," ",v&&"id"in v?v.id===t?"this branch":d.jsx(to,{id:v.id,title:v.branch}):w.after]},w.pieceId))}for(const w of f)g.push(d.jsxs("span",{children:[a(w.pieceId)," sent to ",d.jsx(to,{id:w.worktreeId,title:w.title}),w.repoName?` in ${w.repoName}`:""]},w.pieceId));return h&&g.push(d.jsx("span",{children:`${h} here`},"here")),d.jsx(ar,{icon:"handoff",word:"handed off",tone:"accent",at:e.ts,below:p.length?p.map(w=>`${a(w.pieceId)}: ${w.error}`).join("; "):void 0,children:d.jsxs("span",{className:"daemon-text",children:[g.length===0?"nothing started":g.map((w,v)=>d.jsxs("span",{children:[v>0&&", ",w]},v)),o&&d.jsxs(d.Fragment,{children:[" · ",o]})]})})}function AW({item:e}){return e.worktreeId?d.jsx(ar,{icon:"handoff",word:"handed off",tone:"accent",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:[d.jsx(to,{id:e.worktreeId,title:e.title??"the worktree"})," started, its branch having landed"]})}):d.jsx(ar,{icon:"close",word:"dropped",tone:"quiet",at:e.ts,below:e.reason,children:d.jsx("span",{className:"daemon-text",children:e.title??"a queued worktree"})})}function IW({item:e}){return d.jsx(ar,{icon:"check",word:e.again?"landed again":"landed",tone:"aqua",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:[e.same?d.jsx(to,{id:e.worktreeId,title:e.title}):`${e.title} in ${e.repoName}`,e.awaited&&", which the work here waited for",e.url&&d.jsxs(d.Fragment,{children:[" ","·"," ",d.jsx(Me,{variant:"inline",onClick:()=>Rr(e.url),children:"the PR"})]})]})})}function Dp({src:e,n:t,name:n,width:r,height:o,bytes:s,kept:a,uploading:l,progress:u,onRemove:f,className:h=""}){const p=nt();return d.jsx(nv,{className:We("image-chip",h),label:d.jsxs(d.Fragment,{children:[d.jsx("img",{className:"image-thumb",src:e,alt:n,width:40,height:40}),d.jsxs("span",{className:"pick-target",children:[d.jsx("b",{children:WS("image",t)}),d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",n," · ",r,"×",o," · ",Rw(s),u!==void 0?d.jsxs(d.Fragment,{children:[" ","· ",d.jsxs("span",{className:"pick-progress",children:[u,"%"]})]}):l&&" · uploading"]})]})]}),peek:d.jsx("img",{src:e,alt:n,style:{aspectRatio:`${r} / ${o}`}}),full:d.jsx("img",{src:e,alt:n}),menu:g=>Ba(e,g,a&&{...a,sock:p}),removeLabel:"Remove image",onRemove:f})}function RW({img:e,worktreeId:t,src:n}){return d.jsx(Dp,{className:"in-chat",src:n,...e,kept:{worktreeId:t,file:e.file}})}function xu({pieces:e}){return d.jsx(d.Fragment,{children:e.map((t,n)=>{if(t.scope===Ip)return d.jsx("a",{className:t.changed?"ch":void 0,href:t.text,target:"_blank",rel:"noreferrer",children:t.text},n);const r=`${t.changed?"ch ":""}${t.scope?`sy-${t.scope}`:""}`.trim();return r?d.jsx("span",{className:r,children:t.text},n):d.jsx(E.Fragment,{children:t.text},n)})})}function OW({code:e,lang:t}){const n=Cp(t.toLowerCase(),""),r=n?Th(Ap(e,n)):hv(e);return d.jsx("pre",{children:d.jsx("code",{children:r.length?r.map((o,s)=>d.jsxs(E.Fragment,{children:[s>0&&`
238
- `,d.jsx(xu,{pieces:o})]},s)):e})})}const MW=/(^|\s)@\S/;function qu({text:e,worktreeId:t,root:n,inField:r}){const o=Pn(),s=nt(),a=L(x=>{var N;return t?(N=x.local[t])==null?void 0:N.files:void 0}),l=L(x=>x.visible),u=L(x=>x.shipping),f=L(x=>w3(x,t)),h=L(x=>f?x.archived[f]:void 0),p=E.useMemo(()=>B$(Pp(l,f,t,u),h),[l,u,h,f,t]),g=E.useMemo(()=>F$(a,p),[a,p]),y=E.useMemo(()=>pv(e,g),[e,g]),w=L(x=>!!Kr(x,t)),v=a===void 0&&t&&w&&MW.test(e)?t:null;return E.useEffect(()=>{v&&yp(v,o.getState(),{sock:s,dispatch:o.dispatch})},[v,o,s]),d.jsx(d.Fragment,{children:y.map((x,N)=>{if(x.kind==="text")return x.text;if(x.kind==="code"){if(r)return x.text;const $=x$(x.code),R=d.jsx("code",{children:x.code},N);return $?d.jsx("a",{className:"chat-url",href:$,target:"_blank",rel:"noreferrer",children:R},N):R}if(x.kind==="block")return r?x.text:d.jsx(OW,{code:x.code,lang:x.lang},N);if(x.kind==="url")return d.jsx("a",{className:"chat-url",href:x.href,target:"_blank",rel:"noreferrer",tabIndex:r?-1:void 0,children:x.text},N);if(x.kind==="changes"){const $=Nt("this worktree's uncommitted files",void 0,{placement:"follow"});return d.jsx("span",{className:"chat-mention","data-changes":"",...$,children:x.text},N)}if(x.kind==="worktree"){const $=Rp(x),R=Nt($.text,void 0,{placement:"follow",dot:$.dot,detail:$.detail});return d.jsx("span",{className:"chat-mention","data-worktree":x.id,"data-branch":x.branch,"data-archived":x.archived?"":void 0,...R,children:r?x.text:d.jsxs(d.Fragment,{children:["@",$.text,$.dot&&d.jsx("span",{className:"chat-mention-dot",children:d.jsx("span",{className:`dot ${$.dot}`})})]})},N)}if(!n||!t)return x.text;const S=x.kind==="folder",T=`${n}/${x.path}${S?"/":""}`,j=Nt(S?`${x.path}/`:x.path,void 0,{placement:"follow"});return d.jsx("a",{className:"chat-mention",href:T,tabIndex:r?-1:void 0,...j,children:x.text},N)})})}function Zu(e,t,n,r){if(e.target.closest("[data-changes]")){n&&r.dispatch({a:"focus-changes",tab:"changes"});return}tv(e,t,n,r)}function LW(e){return e.length<2||!e.every(t=>{var n;return t.length===1&&((n=t[0])==null?void 0:n.diff)})?null:DW(e.map(t=>t[0].text))}const PW=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function DW(e,t=3){let n=[];for(const r of e){const o=zW(r);if(!o)return null;const s=FW(n,o);if(!s)return null;n=s}return n.some(r=>r.kind!=="same")?BW(n,t):null}function zW(e){const t=[];let n=null;for(const r of e.split(`
239
- `)){const o=PW.exec(r);if(o){n={oldStart:Number(o[1]),newStart:Number(o[2]),ops:[]},t.push(n);continue}if(!n)return null;const s=r[0];if(s===" "||s==="-"||s==="+")n.ops.push({mark:s,text:r.slice(1)});else if(r==="")n.ops.push({mark:" ",text:""});else return null}return t.length>0?t:null}function FW(e,t){const n=[];let r=0,o=0,s=0,a=0;const l=h=>{h.kind==="same"?o=h.a-h.c:h.kind==="add"?o-=1:o+=1},u=()=>{for(;r<e.length&&e[r].kind==="del";)n.push(e[r]),l(e[r]),r++},f=h=>{for(let p=h;p<e.length;p++){const g=e[p];if(g.kind!=="del")return g.c}return Number.POSITIVE_INFINITY};for(const h of t){if(h.oldStart<=a)return null;for(;r<e.length;){const y=e[r];if((y.kind==="del"?f(r):y.c)>=h.oldStart)break;n.push(y.kind==="del"?y:{...y,c:y.c+s}),l(y),r++}let p=h.oldStart,g=h.newStart;for(const y of h.ops){if(u(),y.mark==="+"){n.push({kind:"add",c:g,text:y.text}),g++;continue}const w=e[r],v=w&&w.kind!=="del"&&w.c===p?w:void 0;if(v){if(v.text!==y.text)return null;r++,l(v),y.mark===" "?n.push({...v,c:g}):v.kind==="same"&&n.push({kind:"del",a:v.a,text:v.text})}else y.mark===" "?n.push({kind:"same",a:p+o,c:g,text:y.text}):n.push({kind:"del",a:p+o,text:y.text});y.mark===" "&&g++,p++}s=g-p,a=p-1}for(;r<e.length;r++){const h=e[r];n.push(h.kind==="del"?h:{...h,c:h.c+s})}return n}function BW(e,t){const n=[];for(const r of HW(e))for(const[o,s]of WW(r.rows,t)){const a=UW(r.rows.slice(o,s)),l=a.filter(p=>p.kind!=="add").length,u=a.filter(p=>p.kind!=="del").length,f=a.find(p=>p.kind!=="add"),h=a.find(p=>p.kind!=="del");n.push(`@@ -${f?f.a:r.oldAt[o]},${l} +${h?h.c:r.newAt[o]},${u} @@`,...a.map(p=>`${p.kind==="add"?"+":p.kind==="del"?"-":" "}${p.text}`))}return n.join(`
240
- `)}function UW(e){const t=[];for(let n=0;n<e.length;){if(e[n].kind==="same"){t.push(e[n]),n++;continue}let r=n;for(;r<e.length&&e[r].kind!=="same";)r++;const o=e.slice(n,r);t.push(...o.filter(s=>s.kind==="del"),...o.filter(s=>s.kind==="add")),n=r}return t}function HW(e){const t=[];let n=null,r=1,o=1;for(const s of e){const a=s.kind==="add"?r:s.a,l=s.kind==="del"?o:s.c;(!n||a!==r||l!==o)&&(n={rows:[],oldAt:[],newAt:[]},t.push(n)),n.rows.push(s),n.oldAt.push(a),n.newAt.push(l),r=a+(s.kind==="add"?0:1),o=l+(s.kind==="del"?0:1)}return t}function WW(e,t){const n=[];let r=0;for(;r<e.length;){if(e[r].kind==="same"){r++;continue}let o=r,s=r;for(;s<e.length;){if(e[s].kind!=="same"){o=s,s++;continue}let a=0;for(;s+a<e.length&&e[s+a].kind==="same";)a++;if(a>t*2||s+a>=e.length)break;s+=a}n.push([Math.max(0,r-t),Math.min(e.length,o+t+1)]),r=o+t+1}return n}function zp({pick:e,worktreeId:t,tipText:n,onHover:r,onOpen:o,onRemove:s,className:a=""}){const l=e.callFile,u=e.file,f=l?{path:l,line:e.callLine}:u?{path:u,line:e.line}:null,h=l&&u?{path:u,line:e.line}:null,p=(S,T)=>`${S}${T?`:${T}`:""}`,g=S=>S.split("/").pop()??S,y=(S,T,j,$)=>o?d.jsx("button",{className:"pick-open","data-tip":$,onClick:()=>o(S,T??1),children:j}):j,w=xn("chat"),{host:v}=Mr(),x=E.useRef(null),N=s?()=>{r==null||r(!1),s()}:void 0;return d.jsxs("div",{ref:x,className:We("pick-chip row row-sm",a),"data-tip":n,onMouseEnter:()=>r==null?void 0:r(!0),onMouseLeave:()=>r==null?void 0:r(!1),...w.contextMenu(()=>z9(e,{remove:N,host:v})),children:[d.jsxs("span",{className:"pick-target",children:[d.jsx(xt,{name:"pick",className:"icon-inline"})," ",ay(e),f&&d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",y(f.path,f.line,p(g(f.path),f.line),`Open ${p(f.path,f.line)}`)]}),h&&d.jsxs("span",{className:"pick-file row-dim",children:[" ","·"," ",y(h.path,h.line,p(h.path.split("/").pop()??h.path,h.line),`Open the component: ${p(h.path,h.line)}`)]})]}),N&&d.jsx(Tt,{icon:"close",label:"Remove attachment",tone:"quiet",onClick:N}),t&&(f==null?void 0:f.line)&&d.jsx(s$,{chip:x,children:d.jsx(ZW,{worktreeId:t,path:f.path,line:f.line})})]})}const KW=6,qW=16;function ZW({worktreeId:e,path:t,line:n}){const r=wy(),o=nt(),s=L(p=>{var g;return((g=Wo(p))==null?void 0:g.id)===e}),a=L(p=>{var g;return s?0:(g=Or(p,e).changedRanges[t])==null?void 0:g.offset}),[l,u]=E.useState(null);E.useEffect(()=>{let p=!0;return s||o==null||o.send({t:"changed-ranges",worktreeId:e,path:t}),r==null||r.look(e,t).then(g=>{p&&u(g)}),()=>{p=!1}},[r,o,e,t,s]);const f=E.useMemo(()=>{if(l===null||a===void 0)return null;const p=l.split(`
241
- `),g=n-a,y=Math.max(1,g-KW),w=Math.min(p.length,g+qW);if(y>w)return null;const v=p.slice(y-1,w);return{from:y,at:g,slice:v,painted:Ap(v.join(`
242
- `),Cp("",t))}},[l,a,n,t]);if(!f)return null;const h=String(f.from+f.slice.length-1).length;return d.jsx("pre",{className:"pick-peek",children:f.slice.map((p,g)=>{const y=f.from+g,w=f.painted[g];return d.jsxs("span",{className:"pick-peek-line","data-state":y===f.at?"current":void 0,children:[d.jsx("span",{className:"pick-peek-n",children:String(y).padStart(h)}),w!=null&&w.length?d.jsx(xu,{pieces:w}):p||" "]},y)})})}function GW(e){return e.startsWith("!")?e.slice(1).trim():null}function wv(e){if(e.kind!=="tool"||e.name!==Pi&&e.name!==MS)return null;const t=e.input;return typeof(t==null?void 0:t.command)=="string"?t.command:null}function pC(e){var t;return e.kind!=="tool"||e.name!==Pi||(t=e.input)!=null&&t.landing?null:wv(e)}function VW(e){return e.length>0&&e.every(t=>t.kind==="tool"&&pC(t)!==null&&t.done&&!t.isError)}function YW(e){const t=[],n=new Set(e.flatMap(r=>r.kind==="asked"&&r.toolId?[r.toolId]:[]));for(let r=e.length-1;r>=0;r--){const o=e[r];if(Qu(o))break;if(o.kind!=="tool"||!o.done||n.has(o.id))continue;const s=wv(o);if(s===null)continue;const a=cC(o.output??"").map(u=>u.text).join(`
243
- `),l=yD(a);t.unshift(`$ ${s}${l?`
244
- ${l}`:""}`)}if(t.length!==0)return`Shell commands the user ran since their last message, and what each printed:
245
- ${t.join(`
246
- `)}`}const jE={diff:"Open this file's diff in the editor pane",file:"Open this file in the editor pane",preview:"Read this file rendered in the editor pane"};function mC(e,t,n,r,o){const s=e[0];if(!s||!n)return[];const a=Lp(o||il(s),t);return a?a.startsWith("/")?[{label:"open",tip:jE.file,open:()=>Vk(r,n.id,{href:a,path:a})}]:[...Bi(a)==="preview"?["preview"]:[],...s.toolKind==="edit"?["diff"]:[],"file"].map(u=>({label:`open ${u}`,tip:jE[u],open:()=>Rn(r,{worktreeId:n.id,path:a,view:u})})):[]}const XW=(...e)=>mC(...e)[0]??null;function QW(e,t,n,r,o,s,a){const{sock:l}=r,u=e[0];if(!u)return[];const f=s?Jj(s):[],h=[],p=Lp(a||il(u),t),g=mC(e,t,n,r,a).map(T=>({id:T.label.replace(" ","-"),label:T.label,onClick:T.open}));p&&!p.startsWith("/")&&n?h.push(...g,...Ko(()=>l==null?void 0:l.send({t:"reveal",worktreeId:n.id,path:p}),wo(l))):p.startsWith("/")&&h.push(...g,...Ko(()=>l==null?void 0:l.send({t:"reveal-path",path:p}),wo(l)));const y=[],w=a||il(u);p&&w&&y.push({id:"copy-path",label:"copy path",onClick:()=>sn(w)});const v=Ku(u,t).command,x=oW(u);x&&x!==v&&y.push({id:"copy-description",label:"copy description",onClick:()=>sn(x)}),v&&y.push({id:"copy-command",label:"copy command",onClick:()=>sn(v)});const N=e.map(T=>T.output??"").filter(Boolean).join(`
247
- `);N&&y.push({id:"copy-output",label:"copy output",onClick:()=>sn(N)});const S=o.leaf?[]:[{id:"fold",label:o.open?"collapse":"expand",onClick:o.toggle}];return Un([f,h,y,S])}const gC=e=>e.replace(/\n$/,""),JW=1500,$E=4,kC=".md pre, .card-code pre";function wC(e){return e.closest(kC)}function iw(e){const t=wC(e);return t?gC(t.textContent??""):null}const CE=[],yC=e=>[...e.querySelectorAll(kC)];function vC(e,t,n){const r=e.getBoundingClientRect(),o=t.getBoundingClientRect();return{pre:t,nth:n,top:o.top-r.top+e.scrollTop+$E,right:r.left+e.clientLeft+e.clientWidth-o.right+$E}}function AE(e,t){const n=yC(e).map((o,s)=>vC(e,o,s));return n.length===t.length&&n.every((o,s)=>{var a,l,u;return o.pre===((a=t[s])==null?void 0:a.pre)&&o.top===((l=t[s])==null?void 0:l.top)&&o.right===((u=t[s])==null?void 0:u.right)})?t:n}function yv(e){const t=Ys(),[n,r]=E.useState(null),[o,s]=E.useState(CE),[a,l]=E.useState(null);return E.useEffect(()=>{const f=e.current;if(t||!f)return;const h=g=>{if(!(g.target instanceof Element)||g.target.closest(".code-copy"))return;const y=wC(g.target);r(y&&f.contains(y)?vC(f,y,yC(f).indexOf(y)):null)},p=()=>r(null);return f.addEventListener("pointerover",h),f.addEventListener("pointerleave",p),()=>{f.removeEventListener("pointerover",h),f.removeEventListener("pointerleave",p)}},[e,t]),E.useLayoutEffect(()=>{const f=e.current;t&&f&&s(h=>AE(f,h))}),E.useEffect(()=>{const f=e.current;if(!t||!f)return;const h=new ResizeObserver(()=>s(p=>AE(f,p)));return h.observe(f),f.firstElementChild&&h.observe(f.firstElementChild),()=>h.disconnect()},[e,t]),E.useEffect(()=>{if(a===null)return;const f=setTimeout(()=>l(null),JW);return()=>clearTimeout(f)},[a]),(t?o:n!=null&&n.pre.isConnected?[n]:CE).map(({pre:f,nth:h,top:p,right:g})=>{const y=a===h;return d.jsx(Tt,{className:"code-copy",style:{top:p,right:g},icon:y?"check":"copy",label:y?"Copied":"Copy code",onClick:()=>{sn(gC(f.textContent??"")),l(h)}},h)})}function eK(e){for(const t of e.split(`
248
- `)){const n=/^#{1,6}\s+(.+?)\s*#*\s*$/.exec(t);if(n)return n[1];if(t.trim()&&!t.startsWith("<!--"))return null}return null}function tK(e){return e.slice(e.lastIndexOf("/")+1).replace(/\.md$/,"")}const zf=new Map;function vv(e,t){var l;const n=wy(),r=(l=Rt(e,"git"))==null?void 0:l.version,o=e&&t?`${e}
249
- ${t}`:null,[,s]=E.useState(0);return ct([n,e,t,r],()=>{if(!n||!o||!e||!t)return;let u=!0;return n.look(e,t).then(f=>{if(!u||f===null)return;const h=eK(f);zf.has(o)&&zf.get(o)===h||(zf.set(o,h),s(p=>p+1))}),()=>{u=!1}}),(o?zf.get(o)??null:null)??(t?tK(t):"")}function bC(e){const t=L(r=>{var o;return(o=Jt(r,e))==null?void 0:o.worktree.repoId}),n=L(r=>t?sH(r,t):"");return E.useMemo(()=>n?iH(n):void 0,[n])}function Kg({text:e,menu:t,marked:n,worktreeId:r,fileRoot:o,streaming:s,pictures:a}){const l=bC(r),u=Mr(),f=E.useMemo(()=>r&&(a!=null&&a.length)?{worktreeId:r,urls:u,pictures:a}:void 0,[r,u,a]),h=ol(e,{fileRoot:o,streaming:s,worktrees:l,stills:f}),p=nt(),g=ht(),y=xn("chat"),[w,v]=E.useState(null),x=$=>{const R=$.closest("button.md-still"),A=R==null?void 0:R.querySelector("img");return R&&A&&r?{src:A.src,alt:A.alt,file:R.dataset.file??"",kept:{worktreeId:r,file:R.dataset.file??"",sock:p}}:null},N=E.useRef(null);nT(N,h);const S=L($=>{var R;return r?(R=$.local[r])==null?void 0:R.refusedLink:void 0});ct([h,S],()=>{var R;const $=N.current;if($)for(const A of $.querySelectorAll("a.file-link, code[data-path]")){const I=A.getAttribute("href")??A.dataset.path,M=S!==void 0&&I===S.href;A.classList.toggle("file-link-refused",M),M?((R=A.dataset).tipWas??(R.tipWas=A.dataset.tip??""),A.dataset.tip=S.message,A.dataset.tipPlacement="bottom",A.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0}))):A.dataset.tipWas!==void 0&&(A.dataset.tipWas?(A.dataset.tip=A.dataset.tipWas,A.dataset.tipPlacement="follow"):(delete A.dataset.tip,delete A.dataset.tipPlacement),delete A.dataset.tipWas)}});const T=E.useRef(null),j=yv(T);return d.jsxs("div",{ref:T,className:"msg-assistant md row-edge","data-state":fr({cursor:n}),...y.contextMenu(($,R)=>{const A=x(R);return A?Ba(A.src,{open:()=>v(A)},A.kept):t(jp(R,o),iw(R),$)}),onClick:$=>{const R=x($.target);R?v(R):tv($,o,r,{sock:p,dispatch:g})},children:[d.jsx("div",{ref:N}),j,w&&r&&d.jsx(id,{owner:"chat",onClose:()=>v(null),menu:()=>Ba(w.src,{},{worktreeId:r,file:w.file,sock:p}),children:d.jsx("img",{src:w.src,alt:w.alt})})]})}const qg=40;function xC(e,t,n=!1){return e.map((r,o)=>{const s=Cp(r.lang,t||(r.diff?D7(r.text):"")),a=r.diff?lW(r.text):[];let l=r.diff?Th(B7(a,s)):r.code&&s?Th(Ap(r.text,s)):hv(r.text);return n&&o===e.length-1&&(l=z$(l)),{...r,lines:a,painted:l}})}function EC({blocks:e,path:t,worktreeId:n}){nt();const r=ht();return d.jsx("div",{className:"tool-out",children:e.map((o,s)=>o.diff?d.jsxs("pre",{className:"tool-block diff",children:[o.lines.slice(0,qg).map((a,l)=>{var u;return a.kind==="hunk"?d.jsx("span",{className:"dl hunk",title:a.text},l):d.jsx("span",{className:`dl ${a.kind}`,children:(u=o.painted[l])!=null&&u.length?d.jsx(xu,{pieces:o.painted[l]}):a.text||" "},l)}),o.lines.length>qg&&d.jsxs("button",{type:"button",className:"dl more",disabled:!t||!n,"data-tip":t&&n?"Open this file's diff":void 0,onClick:()=>n&&Rn({dispatch:r},{worktreeId:n,path:t,view:"diff"}),children:[o.lines.length-qg," more lines"]})]},s):o.code?d.jsx("pre",{className:"tool-block",children:o.painted.length?o.painted.map((a,l)=>d.jsxs(E.Fragment,{children:[l>0?`
250
- `:null,d.jsx(xu,{pieces:a})]},l)):o.text},s):d.jsx("p",{className:"tool-note",children:o.painted.length?o.painted.map((a,l)=>d.jsxs(E.Fragment,{children:[l>0?`
251
- `:null,d.jsx(xu,{pieces:a})]},l)):o.text},s))})}function nK({image:e,worktreeId:t}){const n=Mr().attachment(t,e.file),r={worktreeId:t,file:e.file,sock:nt()},[o,s]=E.useState(!1),a=xn("chat");return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"tool-image","data-tip":"Open full size","data-tip-placement":"follow",onClick:()=>s(!0),...a.contextMenu(()=>Ba(n,{open:()=>s(!0)},r)),children:d.jsx("img",{src:n,alt:e.file})}),o&&d.jsx(id,{owner:"chat",onClose:()=>s(!1),menu:()=>Ba(n,{},r),children:d.jsx("img",{src:n,alt:e.file})})]})}const rK=E.memo(function({item:t,roots:n,worktreeId:r}){const o=E.useMemo(()=>xC(sw(t,t.output??""),il(t),!t.done),[t]),s=Ku(t,n).command,a=r?t.images??[]:[];return!s&&o.length===0&&a.length===0?null:d.jsxs("div",{className:"tool-part",children:[s&&d.jsx("pre",{className:"tool-block cmd",children:s}),o.length>0&&d.jsx(EC,{blocks:o,path:SC(t,n),worktreeId:r}),a.length>0&&r&&d.jsx("div",{className:"tool-out",children:a.map(l=>d.jsx(nK,{image:l,worktreeId:r},l.file))})]})});function SC(e,t){const n=Lp(il(e),t??[]);return n.startsWith("/")?"":n}const oK=E.memo(function({text:t,item:n,roots:r,worktreeId:o}){const s=il(n),a=E.useMemo(()=>xC([{code:!0,diff:!0,lang:"diff",text:t}],s),[t,s]);return d.jsx("div",{className:"tool-part",children:d.jsx(EC,{blocks:a,path:SC(n,r),worktreeId:o})})});function aw({className:e,state:t,auto:n,leaf:r,growing:o,label:s,summary:a,menu:l,children:u}){const[f,h]=E.useState(null),p=E.useRef(null),g=E.useRef(null),y=tT(g),w=n6(".chat-log"),v=!r&&(f??n),[x,N]=E.useState(v);E.useEffect(()=>{v&&N(!0)},[v]);const S=()=>{r||(v||w(p.current),h(!v))},T=xn("chat");return d.jsxs("details",{ref:p,className:We(e,r&&"leaf"),"data-state":t,open:v,onToggle:j=>{if(!j.currentTarget.open||o)return;const $=g.current;$&&($.scrollTop=0,y.read())},...T.contextMenu((j,$)=>l({open:v,leaf:!!r,toggle:S},$)),tabIndex:-1,onPointerDown:()=>{var j;return(j=p.current)==null?void 0:j.focus({preventScroll:!0})},onKeyDown:j=>{if((j.key==="ArrowLeft"||j.key==="ArrowRight")&&!r){if(j.shiftKey||j.altKey||j.metaKey||j.ctrlKey)return;xp([{depth:0,open:v}],0,j.key)&&S();return}j.key!=="Escape"||!v||(j.stopPropagation(),h(!1))},children:[d.jsx("summary",{"aria-label":s,tabIndex:r?-1:void 0,onClick:j=>{j.preventDefault(),S()},children:a}),d.jsx("div",{className:"tool-body",ref:g,children:v||x?u:null})]})}function _C({text:e,live:t,className:n}){const r=E.useRef(null);return E.useEffect(()=>{const o=r.current;if(!t||!o)return;const s=new ResizeObserver(([a])=>{a&&o.style.setProperty("--line",`${a.contentRect.width}px`)});return s.observe(o),()=>{s.disconnect(),o.style.removeProperty("--line")}},[t]),d.jsx("span",{ref:r,className:We("tool-hint",n),children:t?d.jsx("span",{className:"live-text",children:e}):e})}function sK({markdown:e,streaming:t,worktreeId:n,fileRoot:r}){const o=bC(n),s=ol(e,r||t||o?{fileRoot:r,streaming:t,worktrees:o}:void 0),a=nt(),l=ht(),u=E.useRef(null);nT(u,s);const f=E.useRef(null),h=yv(f);return d.jsx("div",{className:"tool-part",children:d.jsxs("div",{ref:f,className:"tool-out thought-out md",onClick:p=>tv(p,r,n,{sock:a,dispatch:l}),children:[d.jsx("div",{ref:u}),h]})})}const iK=E.memo(function({item:t,open:n,streaming:r,worktreeId:o,fileRoot:s}){const a=J$(t.text),l=a.slice(0,-1),u=r?"Thinking":"Thought",f=d.jsx(sK,{markdown:a.length?l.join(`
252
-
253
- `):X$(t.text),streaming:r,worktreeId:o,fileRoot:s}),h=a.at(-1)??(r?"":eC(t.text));if(h){const p=l.length===0;return d.jsx(aw,{className:"tool-row",auto:!1,leaf:p,growing:r,label:h,menu:(g,y)=>Un([Yk(iw(y)),[{id:"copy",label:"copy thought",onClick:()=>sn(t.text)}],...p?[]:[[{id:"fold",label:g.open?"collapse":"expand",onClick:g.toggle}]]]),summary:d.jsxs(d.Fragment,{children:[d.jsx(xt,{name:"bulb",className:"tool-icon"}),d.jsx(_C,{className:"thought-line",text:h,live:!!r})]}),children:p?null:f})}return d.jsx(aw,{className:"tool-row",auto:!!n,growing:r,label:u,menu:(p,g)=>Un([Yk(iw(g)),[{id:"copy",label:"copy thought",onClick:()=>sn(t.text)}],[{id:"fold",label:p.open?"collapse":"expand",onClick:p.toggle}]]),summary:d.jsxs(d.Fragment,{children:[d.jsx(xt,{name:"bulb",className:"tool-icon"}),d.jsx("span",{className:We("tool-name",r&&"live-text"),children:u})]}),children:f})}),Ea=6,aK={land:"the land",commit:"the commit","sync-main":"the sync","pull-main":"the pull"},Ff=E.memo(function e({tools:t,run:n,next:r,live:o,working:s,held:a,since:l,queued:u,roots:f,worktreeId:h,marked:p}){const g=t[0],y=E.useMemo(()=>LW(t.map(Z=>sw(Z,Z.output??""))),[t]),w=t.at(-1)??g,v=!w.done,x=v&&!!w.background,S=(v||!!r||!!a)&&!u||!!s,T=v&&!!u,j=Mi((v||s)&&!w.until?l:void 0),$=n?xW(n):-1,R=E.useMemo(()=>n?dC(n,!0):void 0,[n]),A=!!o,I=Ku(g,f),M=v?rW(g):"",{label:P,icon:F}=I,q=iC(g),W=M?"":q?"Guardian":I.name,ee=M&&g.subagent?I.hint:"",V=ee||M||(q?JH(g.output??""):I.hint),te=!(n&&n.length>0)&&!y&&t.every(Z=>{var J;return!Ku(Z,f).command&&sw(Z,Z.output??"").length===0&&!((J=Z.images)!=null&&J.length)}),K=n?wW(n):0,C=VW(t),oe=x?w.until?`wakes ${cp(w.until)}`:"in the background":"",U=[P,V].filter(Boolean).join(" ")+(oe?`, ${oe}`:"")+(T?", queued":"")+(C?", done":""),B=M?"":n?`${K} ${K===1?"call":"calls"}`:t.length>1?`×${t.length}`:"",Q=Pn(),ue=nt(),he=L(Z=>{var J;return h?(J=Z.shipping[h])==null?void 0:J.op:void 0}),Ne=v&&g.name===Pi&&h?{worktreeId:h,toolId:w.id}:null,De=L(Z=>g.name===jw?g5(Or(Z,h).chat,g.id):void 0),Be=v?null:(()=>{const Z=Jt(Q.getState(),h),J={sock:ue,dispatch:Q.dispatch};return XW(t,f??[],Z?{id:Z.worktree.id}:null,J,De)})();return d.jsxs(aw,{className:We("tool-row",t.some(Z=>Z.isError)&&"error",g.parentToolId&&"nested",n&&"spawn",T&&"queued"),state:fr({cursor:p}),auto:A,leaf:te,growing:S,label:n&&B?`${U}, ${B}`:t.length>1?`${U}, ${t.length} calls`:U,menu:(Z,J)=>{const pe=Jt(Q.getState(),h),de=pe?{id:pe.worktree.id}:null,ie=jp(J,null),ye=(ie==null?void 0:ie.kind)==="out"?ie.href:null;return QW(t,f??[],de,{sock:ue,dispatch:Q.dispatch},Z,ye,De)},summary:d.jsxs(d.Fragment,{children:[d.jsx(xt,{name:n?"spawn":F,className:"tool-icon"}),W&&d.jsx("span",{className:We("tool-name",S&&!V&&"live-text"),children:W}),M&&!ee?d.jsx("span",{className:"tool-writing","data-tip":V,children:d.jsx(wh,{})}):V&&d.jsx(_C,{text:V,live:S}),oe&&d.jsx("span",{className:"tool-status",children:oe}),T&&d.jsx("span",{className:"tool-status",children:"queued"}),C&&d.jsx(xt,{name:"check",className:"tool-done"}),j>=Ea&&d.jsx("span",{className:We("tool-age",$>=0&&"tool-age-folded"),children:ja(j)}),B&&d.jsx("span",{className:"tool-count",children:B}),ee&&d.jsx("span",{className:"tool-writing","data-tip":M,children:d.jsx(wh,{})}),Ne&&d.jsx(Tt,{icon:"stop",className:"tool-stop",label:he?`Stop ${aK[he]}: this step is killed, and what it printed so far stays`:x?"Kill what the command left running; what it printed so far stays":"Kill the command and everything it started; what it printed so far stays",onClick:Z=>{Z.preventDefault(),Z.stopPropagation(),ue==null||ue.send({t:"exec-stop",...Ne})}}),Be&&d.jsx(Tt,{icon:"eye",className:"tool-open",label:Be.tip,onClick:Z=>{Z.preventDefault(),Z.stopPropagation(),Be.open()}})]}),children:[n&&n.length>0&&d.jsx("div",{className:"spawn-run",children:n.map((Z,J)=>d.jsx(e,{tools:Z.tools,next:Z.next,since:J===$?l:void 0,queued:R==null?void 0:R.has(J),roots:f,worktreeId:h},Z.at))}),y?d.jsx(oK,{text:y,item:g,roots:f,worktreeId:h}):t.map(Z=>d.jsx(rK,{item:Z,roots:f,worktreeId:h},Z.id))]})},(e,t)=>e.live===t.live&&e.working===t.working&&e.held===t.held&&e.since===t.since&&e.queued===t.queued&&e.next===t.next&&e.roots===t.roots&&e.worktreeId===t.worktreeId&&e.marked===t.marked&&kv(e.tools,t.tools)&&fC(e.run,t.run));function cK({item:e}){const t=nt(),n=ht(),r=L(v=>v.activeId),o=L(v=>v.layout.term),s=L(v=>{var x;return((x=v.rows.find(N=>N.id===v.activeId))==null?void 0:x.login)??!1}),a=L(v=>v.managed.problem),[l,u]=E.useState(""),[f,h]=E.useState(null),p=E.useRef(!1);if(ct([s],()=>{s&&p.current&&r&&n({a:"term-stream",id:r,stream:Ks,tall:!0})}),ct([e.done],()=>{e.done&&p.current&&o&&n({a:"toggle-terminal"}),p.current=!1}),!r)return null;const g=e.provider==="aws",y=(v,x)=>{t==null||t.send({t:"agent-auth",worktreeId:r,methodId:v,...x?{apiKey:x}:{}})},w=e.methods.find(v=>v.id===f);return d.jsxs("div",{className:`auth-card ${e.done?"done":""}`,children:[d.jsx("div",{className:"auth-title","data-tip":e.done?void 0:e.detail,children:e.done?`${e.agentName} is logged in`:e.provider==="aws"?`${e.agentName}'s AWS session expired`:e.rejected?`${e.agentName}'s credentials were refused`:`${e.agentName} is not logged in`}),!e.done&&d.jsxs("div",{className:"auth-methods",children:[e.methods.map((v,x)=>v.needsKey?d.jsx(Me,{variant:"outline",on:f===v.id,"data-tip":v.description,onClick:()=>h(f===v.id?null:v.id),children:v.name},v.id):d.jsx(Me,{variant:"outline",tone:g&&x===0?"primary":void 0,"data-tip":v.kind==="terminal"&&!v.description?"opens in the terminal pane":v.description,onClick:()=>{y(v.id),v.kind==="terminal"&&(p.current=!0)},children:v.name},v.id)),d.jsx(Me,{variant:g?"ghost":"outline",tone:g?"quiet":void 0,"data-tip":"after logging in elsewhere (the terminal, another window)",onClick:()=>t==null?void 0:t.send({t:"agent-retry",worktreeId:r}),children:"send again"})]}),!e.done&&s&&d.jsx("div",{className:"hint auth-hint",children:e.provider==="aws"?"the login tab below opens the browser to sign in. Your message sends once you are in.":"paste the code into the login tab below and press Enter; it stays hidden as you paste. Your message sends once you are in."}),!e.done&&e.refresh&&d.jsxs("div",{className:"hint auth-hint",children:["your Claude settings refresh it with ",d.jsx("code",{children:e.refresh}),", which got no session this time"]}),!e.done&&e.withheld&&d.jsx("div",{className:"hint auth-hint",children:a?"the policy file on this machine is invalid, so signing in with a Claude plan is off until it is fixed; toyon doctor says why":"signing in with a Claude plan is managed by your organization"}),!e.done&&w&&d.jsxs("form",{className:"auth-key",onSubmit:v=>{v.preventDefault(),l.trim()&&(y(w.id,l.trim()),u(""),h(null))},children:[d.jsx(Ho,{type:"password",autoFocus:!0,placeholder:`${w.name} for ${e.agentName}`,value:l,onChange:v=>u(v.target.value)}),d.jsx(Me,{type:"submit",children:"use key"})]})]})}const lK=E.memo(function({item:t,worktreeId:n,onPickHover:r,marked:o,streaming:s}){const a=Pn(),l=nt(),u=Mr(),f=xn("chat"),h={sock:l,dispatch:a.dispatch},p=()=>{var y;return(y=Jt(a.getState(),n))==null?void 0:y.worktree.path},g=y=>y&&n&&d.jsx(_p,{children:d.jsx("div",{className:"msg-attachments",children:y.map(w=>w.kind==="image"?d.jsx(RW,{img:w,worktreeId:n,src:u.attachment(n,w.file)},`${w.kind}-${w.n}`):w.kind==="file"?d.jsx(Mp,{className:"in-chat",name:w.name,bytes:w.bytes,href:w.text?u.attachment(n,w.file):void 0,kept:{worktreeId:n,file:w.file}},`${w.kind}-${w.n}`):w.kind==="paste"?d.jsx(Op,{className:"in-chat",n:w.n,name:w.name,source:w.source,lines:w.lines,chars:w.chars,preview:w.preview,href:u.attachment(n,w.file)},`${w.kind}-${w.n}`):d.jsx(zp,{pick:w,className:"in-chat",tipText:"Hover to highlight on the page",onHover:v=>r==null?void 0:r(w,v),worktreeId:n,onOpen:(v,x)=>Ma(a,l,n,v,x)},`${w.kind}-${w.n}`))})});switch(t.kind){case"user":{const y=g(t.attachments),w=p();return d.jsxs("div",{className:"msg-user row-edge","data-state":fr({cursor:o}),...f.contextMenu((v,x)=>_i(t,n??null,h,{link:jp(x,w)},v)),onClick:v=>Zu(v,w,n,h),children:[y,d.jsx(qu,{text:t.text,worktreeId:n,root:w})]})}case"assistant":return d.jsx(Kg,{text:t.text,menu:(y,w,v)=>_i(t,n??null,h,{link:y,code:w},v),marked:o,worktreeId:n,fileRoot:p(),streaming:s,pictures:t.pictures});case"error":return d.jsx("div",{className:"msg-assistant msg-error",...f.contextMenu(y=>_i(t,n??null,h,{},y)),children:t.text});case"auth":return d.jsx(cK,{item:t});case"ask":{const y=kz(t);if(y){const T={kind:"assistant",text:Jw(y.questions,y.answers).join(`
254
- `)};return d.jsxs(d.Fragment,{children:[d.jsx(Kg,{text:y.message,menu:(j,$,R)=>_i({kind:"assistant",text:y.message},n??null,h,{link:j,code:$},R),worktreeId:n,fileRoot:p()}),d.jsx("div",{className:"msg-user row-edge","data-state":fr({cursor:o}),...f.contextMenu(j=>_i(T,n??null,h,{},j)),children:mz(y.questions,y.answers).map((j,$)=>{var R;return d.jsxs("div",{children:[j.pick,j.descriptions.map((A,I)=>d.jsx("div",{className:"msg-pick-desc",children:A},I)),j.note&&d.jsx("div",{children:j.note})]},((R=y.questions[$])==null?void 0:R.id)??$)})})]})}const w=yz(t);if(!w)return d.jsx(J9,{item:t});const v=w.file,x={kind:"assistant",text:w.choice};return d.jsxs(d.Fragment,{children:[v?d.jsx(uK,{file:v,worktreeId:n}):w.text&&d.jsx(Kg,{text:w.text,menu:(N,S,T)=>_i({kind:"assistant",text:w.text},n??null,h,{link:N,code:S},T),worktreeId:n,fileRoot:p()}),d.jsx("div",{className:"msg-user",...f.contextMenu(N=>_i(x,n??null,h,{},N)),children:w.choice})]})}case"blocked":return d.jsxs(ar,{icon:"lock",word:"blocked",tone:"red",below:t.reason,...f.contextMenu(()=>Jy(t.path,void 0,wo(h.sock))),children:[d.jsx("span",{className:"tool-name",children:t.tool}),t.path&&d.jsx("span",{className:"tool-hint",children:t.path})]});case"grafted":return d.jsx(ar,{icon:"pull",word:"grafted",tone:"accent",below:t.branch,"data-tip":`what follows was said in ${t.title} before it was merged in here`,"data-tip-placement":"follow",children:d.jsx("span",{className:"daemon-text",children:t.title})});case"switched":return d.jsx(ar,{icon:"swap",word:"model",tone:"quiet",below:t.asked?`${t.asked} is not on the agent's list`:"the agent switched to it",children:d.jsx("span",{className:"daemon-text",children:t.name})});case"asked":return d.jsx(ar,{icon:"send",word:"asked",tone:"quiet",children:d.jsx("span",{className:"daemon-text",children:t.why})});case"stopped":return d.jsx(ar,{icon:"stop",word:"stopped",tone:"quiet"});case"landed":return d.jsx(fK,{item:t});case"handed":return d.jsx(CW,{item:t,worktreeId:n,marked:o,children:g(t.attachments)});case"piece-landed":return d.jsx(IW,{item:t});case"handoff":{const y=S5(t);if(!y)return d.jsx(TE,{item:t,worktreeId:n});const w={kind:"assistant",text:y};return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"msg-user",...f.contextMenu(v=>_i(w,n??null,h,{},v)),children:y}),d.jsx(TE,{item:t,worktreeId:n})]})}case"piece-later":return d.jsx(AW,{item:t});case"restored":return d.jsx(dK,{item:t});case"adopted":return d.jsx(ar,{icon:"branch",word:"taken over",tone:"quiet",at:t.ts,children:d.jsxs("span",{className:"daemon-text",children:["on ",t.branch,", its own branch"]})});case"owned":{if(t.by==="edit")return d.jsx(MH,{item:t,worktreeId:n});const y=t.by==="agent"?"the agent asked for it before changing the backend":"asked for";return d.jsx(ar,{icon:"run",word:"runs here",tone:"quiet",at:t.ts,children:d.jsxs("span",{className:"daemon-text",children:[t.names.join(", "),": ",y]})})}case"own-failed":return d.jsx(ar,{icon:"run",word:"setup failed",tone:"quiet",at:t.ts,children:d.jsxs("span",{className:"daemon-text",children:[t.name," (exit ",t.exit,"): ",t.cmd,"; the page still reaches main's ",t.name]})})}});function uK({file:e,worktreeId:t}){const n=nt(),r=ht(),o=xn("chat"),s=vv(t??void 0,e);return d.jsx(ar,{icon:"file",word:"plan",tone:"quiet",...o.contextMenu(()=>Jy(e,t?()=>n==null?void 0:n.send({t:"reveal",worktreeId:t,path:e}):void 0,wo(n))),children:d.jsx("span",{className:"daemon-text",children:d.jsx(Me,{variant:"inline",tone:"strong","data-tip":e,onClick:()=>t&&Rn({dispatch:r},{worktreeId:t,path:e,view:"preview"}),children:s})})})}function dK({item:e}){return d.jsx(ar,{icon:"reload",word:"restored",tone:"quiet",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:["after ",cy(e.ts-e.archivedAt)," in the archive, back on ",e.branch,e.uncommitted?" with its uncommitted changes":""]})})}function fK({item:e}){const t=Ij(e.ts),n=e.mark&&Dy(e.mark),r=`${e.text}, ${t}`,o=e.url&&d.jsx(Me,{variant:"inline",onClick:()=>Rr(e.url),children:"the PR"}),s=e.held&&`Not marked landed: ${no(e.held)}`;return d.jsx(ar,{icon:"check",word:"landed",tone:"aqua",at:e.ts,below:[n?r:void 0,s],children:d.jsxs("span",{className:"daemon-text",children:[n??r,o&&d.jsxs(d.Fragment,{children:[" · ",o]})]})})}const Fp=".jump-seat, .draft-intro, .chat-input";function hK(e){const t=e instanceof Element?e:e.parentElement;return!!(t!=null&&t.closest(Fp))}function IE(e,t){const n=new Map(t.map(r=>[r.id,r]));for(const r of e.querySelectorAll(`.chat-mention[data-dir]:not([data-archived], :is(${Fp}) *)`)){const o=n.get(r.dataset.worktree??"");if(!o)continue;const s=Rp({...o,dir:r.dataset.dir}),a=r.querySelector(".dot"),l=`dot ${o.dot}`;a&&a.className!==l&&(a.className=l);const u=s.detail.join(`
255
- `);r.dataset.tipDetail!==u&&(r.dataset.tipDetail=u),r.dataset.tipDot!==o.dot&&(r.dataset.tipDot=o.dot)}}function pK(e,t){const n=L(s=>s.visible),r=L(s=>s.shipping),o=L(s=>{var a;return(a=Jt(s,t))==null?void 0:a.worktree.repoId});E.useEffect(()=>{const s=e.current;if(!s||!o)return;const a=Pp(n,o,null,r);IE(s,a);let l=0;const u=new MutationObserver(f=>{f.every(h=>hK(h.target))||(cancelAnimationFrame(l),l=requestAnimationFrame(()=>IE(s,a)))});return u.observe(s,{childList:!0,subtree:!0}),()=>{u.disconnect(),cancelAnimationFrame(l)}},[e,n,r,o])}const NC=e=>e===""||e==="!";function RE(e,t){const n=new Set,r=[];for(let o=e.length-1;o>=0;o--){const s=e[o],a=pC(s),l=a!==null?`!${a}`:t?null:s.kind==="user"?s.text:s.kind==="ask"?wz(s):null;l===null||!l.trim()||n.has(l)||(n.add(l),r.push({text:l,at:o}))}return r}function mK(e,t,n,r){if(!t){if(r!=="up"&&r!=="first"||!NC(n))return null;const l=RE(e,n==="!"),u=r==="up"?l[0]:l.at(-1);return u?{walk:{at:u.at,from:n},text:u.text}:null}if(r==="box")return{walk:null,text:t.from};const o=RE(e,t.from==="!"),s=r==="first"?o.length-1:o.findIndex(l=>l.at===t.at)+(r==="up"?1:-1);if(s<0)return{walk:null,text:t.from};const a=o[s];return a?{walk:{at:a.at,from:t.from},text:a.text}:{walk:t,text:n}}function gK(e,t,n,r){const o=new Map;return{rows:t.map((a,l)=>{const u=n(a,l),f=e.get(a.at),h=f&&f.row.kind===u.kind&&kK(f.row.props,u.props)?f.el:r(a,u);return o.set(a.at,{row:u,el:h}),h}),cache:o}}function kK(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){if(!(o in t))return!1;const s=e[o],a=t[o];if(!Object.is(s,a)&&(!Array.isArray(s)||!Array.isArray(a)||s.length!==a.length||!s.every((l,u)=>Object.is(l,a[u]))))return!1}return!0}const wK=4;function yK(e,t,n){const r=Math.max(t,0);return n?e>=r+1:e>=r+wK}function vK(e,t,n){E.useEffect(()=>{const r=e.current,o=r==null?void 0:r.parentElement,s=r==null?void 0:r.querySelector(":scope > .chat-input");if(!r||!o||!s){n(!1);return}let a=0,l=!1,u=0,f=0;const h=()=>o.style.setProperty("--cover",`${l?f:u}px`),p=()=>{if(u=s.offsetHeight,f=u,t&&s.classList.contains("foldable")){const x=r.scrollTop;s.classList.add("fold-measure"),f=s.offsetHeight,s.classList.remove("fold-measure"),r.scrollTop=x}a=u-f,o.style.setProperty("--fold",`${a}px`),o.style.setProperty("--keep",`${f}px`),h()},g=()=>{if(!t)return;const x=yK(r.scrollHeight-r.scrollTop-r.clientHeight,a,l);x!==l&&(l=x,h(),n(l))};p(),g(),r.addEventListener("scroll",g,{passive:!0});const y=new ResizeObserver(()=>{p(),g()});y.observe(s);let w=s.className;const v=new MutationObserver(()=>{s.className!==w&&(w=s.className,p(),g())});return v.observe(s,{attributes:!0,attributeFilter:["class"]}),()=>{r.removeEventListener("scroll",g),y.disconnect(),v.disconnect();for(const x of["--fold","--keep","--cover"])o.style.removeProperty(x);n(!1)}},[e,t,n])}const bK={get current(){return bu.el}},xK={upTo:e=>e.querySelector(":scope > .jump-seat"),except:Fp};function cw({items:e,next:t,worktreeId:n,onOpen:r}){const o=Mr();return d.jsx(_p,{children:d.jsx("div",{className:"msg-attachments",children:Iw(e,t).map(([s,a])=>s.kind==="image"?d.jsx(Dp,{className:"in-chat",src:"local"in s&&s.local||o.upload(s.upload),n:a,name:s.name,width:s.width,height:s.height,bytes:s.bytes,progress:"progress"in s?s.progress:void 0},`image-${a}`):s.kind==="file"?d.jsx(Mp,{className:"in-chat",name:s.name,bytes:s.bytes,href:s.text&&s.upload?o.upload(s.upload):void 0,progress:"progress"in s?s.progress:void 0},`file-${a}`):s.kind==="paste"?d.jsx(Op,{className:"in-chat",n:a,name:s.name,source:s.source,...qw(s.text),text:s.text},`paste-${a}`):d.jsx(zp,{className:"in-chat",pick:s,worktreeId:n,onOpen:r},`pick-${a}`))})})}function EK({entry:e,next:t,worktreeId:n,root:r,onOpen:o}){const s=ht(),a=nt(),l=Rt(e.id,"draft"),u=Rt(e.id,"attachments");return d.jsxs("div",{className:"msg-user queued-msg",onClick:f=>Zu(f,r,n,{sock:a,dispatch:s}),children:[d.jsxs("span",{className:"queued-tag",children:[d.jsx(xt,{name:"clock",className:"icon-inline"}),d.jsx("span",{className:"live-text",children:"uploading"})]}),d.jsxs("span",{className:"queued-actions",children:[d.jsx(Tt,{icon:"edit",label:"Edit: puts it back in the input",onClick:()=>s({a:"unsend",id:e.id})}),d.jsx(Tt,{icon:"close",label:"Remove: it is not sent",onClick:()=>s({a:"drop-out",id:e.id})})]}),d.jsxs("div",{className:"queued-text",children:[u.length>0&&d.jsx(cw,{items:u,next:t,worktreeId:n,onOpen:o}),d.jsx(qu,{text:l,worktreeId:n,root:r})]})]})}const SK=new Set;function Zg({active:e,archived:t,found:n,lead:r,tail:o,foot:s}){var Kt;const a=nt(),l=Pn(),u=ht(),f=L(D=>D.frame==="phone"),h=(e==null?void 0:e.worktree.id)??(t==null?void 0:t.id)??(n==null?void 0:n.id)??null,p=Rt(h,"chat"),g=Rt(h,"queue"),y=Rt(h,"sending"),w=E.useMemo(()=>sk(xN(p)),[p]),v=E.useMemo(()=>{let D=w;return g.map(se=>{const Se=D;return D=wu(D,se.attachments??[]),Se})},[g,w]),x=L(D=>D.outbox),N=E.useMemo(()=>{let D=g.reduce((se,Se)=>wu(se,Se.attachments??[]),w);return x.filter(se=>se.log===h).map(se=>{const Se=D;return D=wu(D,se.kinds.map(ze=>({kind:ze}))),{entry:se,next:Se}})},[x,h,g,w]),S=y!=null&&y.message?g.findIndex(D=>{var se;return D.text===((se=y.message)==null?void 0:se.text)}):-1,T=E.useRef(null);pK(T,h),p9(T,xK);const[j,$]=E.useState(null),R=E.useCallback(()=>{const D=(T.current&&Wk(T.current))??"";$(se=>({seed:D||(se==null?void 0:se.seed)||"",seq:((se==null?void 0:se.seq)??0)+1}))},[]),A=E.useCallback(D=>!(D!=null&&D.closest("[data-pane]"))&&!l.getState().overlay,[l]);Dj(bK,Wy,R,A);const I=D=>{if($(null),D){const se=window.getSelection();se==null||se.removeAllRanges(),se==null||se.addRange(D)}},M=tT(T,p);ct([h],()=>M.jump());const P=M.offStart&&M.moving==="up",F=M.offEnd&&(M.moving==="down"||M.away),q=D=>D.preventDefault(),W=(P||F)&&d.jsxs("div",{className:We("jump",M.away&&"jump-news"),children:[P&&d.jsx("button",{className:"jump-up",onMouseDown:q,onClick:M.start,"data-tip":"Jump to start",children:d.jsx(xt,{name:"caret-up",className:"icon-inline"})}),F&&d.jsxs("button",{className:"jump-down",onMouseDown:q,onClick:M.jump,"data-tip":"Jump to latest",children:[d.jsx(xt,{name:"caret",className:"icon-inline"}),M.away&&" new messages"]})]}),ee=E.useCallback(D=>u({a:"reading",on:D}),[u]);vK(T,f,ee);const V=Rt(h,"mark"),te=(V==null?void 0:V.by)==="walk"?V.at:void 0,K=E.useRef(null),C=()=>{const D=T.current,se=D==null?void 0:D.querySelector(':scope > [data-state~="cursor"]');if(!D||!se)return;const Se=parseFloat(getComputedStyle(D).paddingTop)||0;D.scrollTop+=se.getBoundingClientRect().top-D.getBoundingClientRect().top-Se,M.read()};ct([te],()=>{const D=T.current;if(D){if(te===void 0){const se=K.current;if(K.current=null,!se||!NC(Or(l.getState(),h).draft))return;se.bottom?M.jump():(D.scrollTop=se.top,M.read());return}K.current??(K.current={bottom:M.pinned(),top:D.scrollTop}),C()}});const oe=Rt(h,"sent");ct([oe],()=>{oe&&M.jump()});const U=N.length,B=E.useRef(U);ct([U],()=>{U>B.current&&M.jump(),B.current=U});const Q=(V==null?void 0:V.by)==="reveal"?V:void 0,ue=E.useMemo(()=>Q?TW(p,Q.seq):-1,[p,Q]),he=te??(ue>=0?ue:void 0);ct([Q==null?void 0:Q.n,ue],()=>{ue>=0&&C()});const Ne=E.useCallback((D,se)=>{h&&(se?fn.post(h,{type:"highlight-selector",selector:D.selector,label:ay(D)}):fn.post(h,{type:"highlight-clear"}))},[h]),De=is(e==null?void 0:e.agent),Be=Rt(h,"cardParked"),Z=E.useMemo(()=>{const D=Ry(p);return!!D&&Be!==D.id},[p,Be]),J=e==null?void 0:e.worktree,pe=(J==null?void 0:J.path)??(t==null?void 0:t.path)??(n==null?void 0:n.path),de=E.useMemo(()=>pe?[pe]:[],[pe]),ie=E.useMemo(()=>kW(p,de,De),[p,de,De]),ye=E.useMemo(()=>De?yW(p):SK,[De,p]),_e=E.useMemo(()=>vW(ie,ye),[ie,ye]),be=_e.floating,$e=E.useRef([]),Ze=E.useMemo(()=>($e.current=EW($e.current,_e.flow),$e.current),[_e]),rt=(e==null?void 0:e.agent)==="working",en=rt||(e==null?void 0:e.agent)==="waiting",Xt=E.useMemo(()=>en?_W(Ze):-1,[en,Ze]),Et=Ze.at(-1),Ke=rt&&Et&&"item"in Et&&(Et.item.kind==="thinking"||Et.item.kind==="assistant")?Ze.length-1:-1,Qt=(Kt=ie.findLast(D=>{var se;return"tools"in D&&((se=D.tools[0])==null?void 0:se.name)===Pi}))==null?void 0:Kt.at,Ot=Rt(h,"chatAt"),Zt=Mi(De?Ot:void 0),Ge=Rt(h,"usage"),nn=(Ge==null?void 0:Ge.heard)!==void 0&&Ot!==void 0&&Ge.heard>Ot?Ge.heard:void 0,pn=Mi(De?nn:void 0),It=Mi(y&&!De?y.at:void 0),gt=bW(p,De),Vt=be.length>0,Cn=Ke>=0||gt||Vt,Ce=rt&&!Cn&&Zt<Ea?hW(Ze,de):-1,Pt=E.useMemo(()=>dC(Ze),[Ze]),Dt=Rt(h,"running"),Wt=D=>Dt&&D.tools.some(se=>se.id===Dt.id)?Dt.at:void 0,Dn=e==null?void 0:e.worktree.path,ne=D=>`${h??""}:${D}`,we=(D,se)=>"spawn"in D?{kind:"tool",props:{tools:[D.spawn],run:D.run,roots:de,worktreeId:h}}:"tools"in D?{kind:"tool",props:{tools:D.tools,next:D.next,live:se===Xt||D.at===Qt,held:se===Ce,since:Wt(D),queued:Pt.has(se),roots:de,worktreeId:h,marked:D.at===he}}:D.item.kind==="thinking"?{kind:"thought",props:{item:D.item,open:se===Xt,streaming:se===Ke,worktreeId:h,fileRoot:Dn}}:{kind:"item",props:{item:D.item,worktreeId:h,onPickHover:Ne,marked:D.at===he,streaming:rt&&se===Ze.length-1}},Ye=E.useRef(new Map),ot=gK(Ye.current,Ze,we,(D,se)=>se.kind==="tool"?d.jsx(Ff,{...se.props},ne(D.at)):se.kind==="thought"?d.jsx(iK,{...se.props},ne(D.at)):d.jsx(lK,{...se.props},ne(D.at)));Ye.current=ot.cache;const zt=d.jsxs("div",{className:"chat-wrap",children:[d.jsxs("div",{className:"chat-log",ref:T,children:[r,ot.rows,be.map(D=>{var se;return"spawn"in D?d.jsx(Ff,{tools:[D.spawn],run:D.run,working:!0,since:Ot,roots:de,worktreeId:h},ne(D.at)):((se=D.tools[0])==null?void 0:se.name)===Pi?d.jsx(Ff,{tools:D.tools,live:D.at===Qt,since:Wt(D),roots:de,worktreeId:h,marked:D.at===he},ne(D.at)):d.jsx(Ff,{tools:D.tools,since:Ot,roots:de,worktreeId:h},ne(D.at))}),h&&(y==null?void 0:y.message)&&d.jsxs("div",{className:"msg-user",onClick:D=>Zu(D,pe,h,{sock:a,dispatch:u}),children:[y.message.attachments&&d.jsx(cw,{items:y.message.attachments,next:w,worktreeId:h,onOpen:(D,se)=>Ma(l,a,h,D,se)}),d.jsx(qu,{text:y.message.text,worktreeId:h,root:pe})]}),e&&(y||De&&!(e.agent==="waiting"&&Z)&&!gt&&!Vt&&Ce<0&&!(Cn&&Zt<Ea))&&d.jsx("div",{className:"working-row",children:e.agent==="waiting"?"waiting for your answer…":Cn?Zt>=Ea&&d.jsxs("span",{children:["quiet for",d.jsx("span",{className:"working-num",children:ja(Zt)})]}):d.jsxs("span",{className:"working-mark",children:[d.jsx(wh,{}),!De&&y?It>=Ea&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"waiting for the agent"}),d.jsx("span",{className:"working-num",children:ja(It)})]}):nn!==void 0?pn>=Ea&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"thinking"}),d.jsx("span",{className:"working-num",children:ja(pn)})]}):Zt>=Ea&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"waiting for the model"}),d.jsx("span",{className:"working-num",children:ja(Zt)})]})]})}),h&&g.map((D,se)=>se===S?null:d.jsxs("div",{className:"msg-user queued-msg",onClick:Se=>Zu(Se,pe,h,{sock:a,dispatch:u}),children:[d.jsxs("span",{className:"queued-tag",children:[d.jsx(xt,{name:"clock",className:"icon-inline"}),"queued"]}),d.jsxs("span",{className:"queued-actions",children:[d.jsx(Tt,{icon:"edit",label:"Edit: removes from queue, puts it back in the input",onClick:()=>ET(l,a,h,se)}),d.jsx(Tt,{icon:"close",label:"Remove from queue",onClick:()=>a==null?void 0:a.send({t:"unqueue",worktreeId:h,index:se})})]}),d.jsxs("div",{className:"queued-text",children:[D.attachments&&d.jsx(cw,{items:D.attachments,next:v[se]??w,worktreeId:h,onOpen:(Se,ze)=>Ma(l,a,h,Se,ze)}),d.jsx(qu,{text:D.text,worktreeId:h,root:pe})]})]},`q-${se}`)),h&&N.map(({entry:D,next:se})=>d.jsx(EK,{entry:D,next:se,worktreeId:h,root:pe,onOpen:(Se,ze)=>Ma(l,a,h,Se,ze)},D.id)),o,d.jsx("div",{className:"jump-seat",children:W}),f&&s]}),j&&d.jsx(Lj,{root:T,body:T,skip:Fp,seed:j.seed,seq:j.seq,onClose:I,onReveal:M.read})]});return f?zt:d.jsxs(d.Fragment,{children:[zt,s]})}function _K(e){return e.offer?e.offer.state!=="offered"?!0:e.agent==="idle"&&e.chat.some(t=>t.kind==="assistant"):!1}const NK=/EACCES|EPERM|permission denied/i,TK="https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally";function jK(e){return{why:e.line.replace(/\.$/,""),permissions:NK.test(e.line),command:e.command}}function $K(){try{return localStorage.getItem(it.installOffered)==="1"}catch{return!1}}let jh={prompt:null,offered:typeof localStorage<"u"&&$K()};const lw=new Set;function uw(e){jh={...jh,...e};for(const t of lw)t()}typeof window<"u"&&(window.addEventListener("beforeinstallprompt",e=>{e.preventDefault(),uw({prompt:e})}),window.addEventListener("appinstalled",()=>uw({prompt:null})));function TC(e){return lw.add(e),()=>{lw.delete(e)}}function jC(){return E.useSyncExternalStore(TC,()=>jh.prompt)}function CK(){return E.useSyncExternalStore(TC,()=>jh.offered)}function OE(){try{localStorage.setItem(it.installOffered,"1")}catch{}uw({offered:!0})}function AK(e){return!e.prompt||e.offered||e.agent!=="idle"?!1:e.chat.some(t=>t.kind==="assistant")}function bv(e,{sock:t}){var o;const n=[];e.canLogout&&((o=e.auth)==null?void 0:o.kind)!=="none"&&n.push({id:"logout",label:"log out",danger:!0,onClick:()=>t==null?void 0:t.send({t:"agent-logout",agent:e.id})});const r=xv(e);return r&&n.push({id:"install",label:r,onClick:()=>t==null?void 0:t.send($C(e))}),n}function xv(e){return e.install?e.install==="missing"?"install":e.install.held?"install anyway":"install again":null}function $C(e){const t=xv(e)==="install anyway";return{t:"install-agent",agent:e.id,...t?{anyway:!0}:{}}}const Bp=e=>e.reason??"not installed",IK={side:"top",align:"start",offset:4,alignOffset:-10,matchWidth:-20,flip:"side",margin:8};function RK({results:e,keyOf:t,row:n,rowClass:r,nav:o,listRef:s,empty:a,note:l,groupOf:u,groupHead:f}){const h=new Set(u?e.map(u):[]);return d.jsxs(Qs,{className:"inline-picker",anchor:"parent",placement:IK,children:[d.jsxs("div",{className:"picker-list",ref:s,children:[e.map((p,g)=>{const y=u==null?void 0:u(p),w=y!==void 0&&h.size>1&&(g===0||(u==null?void 0:u(e[g-1]))!==y)?d.jsx("div",{className:"picker-group",children:(f==null?void 0:f(y))??y}):null;return d.jsxs(E.Fragment,{children:[w,d.jsx("button",{className:We("picker-item",r==null?void 0:r(p)),"data-state":fr({cursor:g===o.index}),onMouseMove:()=>g!==o.index&&o.setIndex(g),onMouseDown:v=>v.preventDefault(),onClick:()=>o.pick(p),children:n(p,g===o.index)})]},t(p))}),e.length===0&&d.jsx("div",{className:"empty",children:a})]}),d.jsx(Z$,{hints:[["↑↓","moves"],["tab","inserts"],["esc","dismisses"]],note:l})]})}const ME=e=>Math.max(0,Math.min(1,Number.isFinite(e)?e:0));function OK({fraction:e,level:t,className:n}){const o=2*Math.PI*5.5,s=ME(e),a=E.useId(),l=3.5,u=2*l*ME(t);return d.jsxs("svg",{className:We("ring",n),viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[t!==void 0&&d.jsxs(d.Fragment,{children:[d.jsx("clipPath",{id:a,children:d.jsx("circle",{cx:"7",cy:"7",r:l})}),d.jsx("rect",{className:"ring-level",clipPath:`url(#${a})`,x:"0",y:7+l-u,width:"14",height:u})]}),d.jsx("circle",{className:"ring-track",cx:"7",cy:"7",r:5.5}),d.jsx("circle",{className:"ring-fill",cx:"7",cy:"7",r:5.5,strokeDasharray:`${o*s} ${o}`})]})}function MK(e,t=Tu.folder.shared){return`New project: ${e}. The repository is empty apart from a root commit. Pick the mainstream stack for what the message describes, and say which in your first sentence; if the message names a stack, that wins. Scaffold it in this directory, write its .gitignore before installing anything, make it start on $PORT, and write ${t}.`}const Ws="";function CC(e,t){return!e||t.length===0?e:rR(e,t)??Ws}function LK(e){var f;const t=DK(e.name);if(t){const h=[t.qualifier,e.description||e.name].filter(Boolean).join(" · ");return{label:t.label,version:t.version,description:h}}const n=e.name.match(/^([A-Za-z]+)-(\d+(?:\.\d+)*)(?:-([A-Z][a-z]+))?$/);if(n!=null&&n[1]&&n[2])return{label:n[3]??n[1],version:n[2],...e.description?{description:e.description}:{}};const[r="",...o]=(e.description??"").split(" · "),s=e.name.replace(/\s*\([^)]*\)$/,""),a=r.match(/^(.+?) (\d+(?:\.\d+)*)(?: with (.+))?$/);if(!(a!=null&&a[2])||a[1]!==s)return{label:e.name,...e.description?{description:e.description}:{}};const u=[a[3]??((f=e.name.match(/\(([^)]*)\)$/))==null?void 0:f[1]),...o].filter(Boolean).join(" · ");return{label:s,version:a[2],...u?{description:u}:{}}}const PK=/(?:^|[./])claude-(?:(\d{1,2}(?:-\d{1,2}(?!\d))?)-)?([a-z]+)(?:-(\d{1,2}(?:-\d{1,2}(?!\d))?))?(?:-\d{8})?(?:-v\d+(?::\d+)?)?(?:@\d{8})?(?:\[(\d+m)\])?$/;function DK(e){const t=e.match(PK),n=t==null?void 0:t[2],r=(t==null?void 0:t[3])??(t==null?void 0:t[1]);if(!(!n||!r))return{label:n.charAt(0).toUpperCase()+n.slice(1),version:r.replace("-","."),...t[4]?{qualifier:`${t[4].toUpperCase()} context`}:{}}}function AC(e,t,n,r,o){const s=FS(e),a=nR(e,o),l=x=>a&&x===(s==null?void 0:s.id)?a.id:x,u=CC(t,e),f=l(u||n||(s==null?void 0:s.id)||Ws),h=l(u||(s==null?void 0:s.id)||Ws),p=a?e.filter(x=>x!==s):e,g=p.some(x=>x.id===f),y=p.map(x=>({c:x,words:LK(x)})),w=x=>[x.label,x.version].filter(Boolean).join(" "),v=[...s?[]:[{id:Ws,label:r.label,description:r.description}],...y.map(({c:x,words:N})=>{const S=y.filter(j=>w(j.words)===w(N)).length===1?N:void 0,T=S?S.description:x.description;return{id:x.id,label:S?S.label:x.name,...S!=null&&S.version?{suffix:S.version}:{},...S!=null&&S.version&&y.some(j=>j.c!==x&&j.words.label===S.label)?{chip:w(S)}:{},description:x===a?["default",T].filter(Boolean).join(" · "):T}}),...f&&!g?[{id:f,label:f}]:[]];if(f!==h){const x=v.find(T=>T.id===f),N=v.findIndex(T=>T.id===h),S=v[N];if(S){const T=(x==null?void 0:x.chip)??(x==null?void 0:x.label)??f;v[N]={...S,description:[`${T} now`,S.description].filter(Boolean).join(" · ")}}}return{rows:v,shown:f,picked:h}}const lu=(e,t)=>`${e} ${t}`;function zK(e){const t=e.indexOf(" ");return t<0?{agent:e,model:Ws}:{agent:e.slice(0,t),model:e.slice(t+1)}}function FK(e,t,n){const r=e.length>1;let o=lu(t,n);return{rows:e.flatMap(a=>{var h;const l=a.short??a.name,u=a.id===t;if(!a.available||!((h=a.models)!=null&&h.length))return u&&(o=lu(a.id,Ws)),[{id:lu(a.id,Ws),label:l,description:a.available?a.checkFailed??"its own default model; the rest are listed once it has run":Bp(a),disabled:!a.available}];const f=AC(a.models,u?n:Ws,void 0,{label:`${l} default`,description:`whatever ${a.name} runs when nothing is asked for`},a.defaultModel);return u&&(o=lu(a.id,f.shown)),f.rows.map(p=>({...p,id:lu(a.id,p.id),...r&&p.id!==Ws?{prefix:l}:{}}))}),shown:o}}function IC({choices:e,value:t,current:n,runs:r,what:o,defaultLabel:s,defaultDescription:a,placeholder:l,className:u,onChange:f,onClose:h}){const{rows:p,shown:g,picked:y}=E.useMemo(()=>AC(e,t,n,{label:s,description:a},r),[e,t,n,r,s,a]);if(e.length===0)return null;const w=p.find(x=>x.id===g),v=(w==null?void 0:w.chip)??(w==null?void 0:w.label)??g;return d.jsx(Bs,{value:y,reads:g,options:p,onChange:f,onClose:h,className:u,hint:CC(t,e)?`asked for ${v}; click to change`:`${v}, the agent's choice; click to pick ${o}`,placeholder:l})}function LE({efforts:e,value:t,current:n,runs:r,onChange:o,onClose:s}){return d.jsx(IC,{choices:e,value:t,current:n,runs:r,what:"an effort level",defaultLabel:"default effort",defaultDescription:"the level the agent runs at when nothing is asked for",placeholder:"how hard the agent thinks here",className:"effort-chip",onChange:o,onClose:s})}const BK=e=>{var t;return((t=Uh.find(n=>n.id===e))==null?void 0:t.description)??""};function PE({value:e,onChange:t,onClose:n}){return d.jsx(Bs,{value:e,options:Uh.map(r=>({id:r.id,label:r.name,description:r.description})),onChange:t,onClose:n,className:We("mode-chip",e!=="auto"&&"mode-held"),hint:`${e}: ${BK(e)}. Click to change`,placeholder:"what the agent may do without asking"})}function DE({models:e,value:t,current:n,runs:r,onChange:o,onClose:s}){return d.jsx(IC,{choices:e,value:t,current:n,runs:r,what:"a model",defaultLabel:"default model",defaultDescription:"whatever the agent runs when nothing is asked for",placeholder:"which model answers here",className:"model-chip",onChange:o,onClose:s})}function UK({agents:e,agent:t,model:n,onChange:r,onClose:o}){const{rows:s,shown:a}=E.useMemo(()=>FK(e,t,n),[e,t,n]);if(s.length===0)return null;const l=s.find(f=>f.id===a),u=l?[l.prefix,l.label,l.suffix].filter(Boolean).join(" "):n;return d.jsx(Bs,{value:a,options:s,onChange:f=>{const h=zK(f);r(h.agent,h.model)},onClose:o,className:"model-chip",hint:`${u} works on the new worktree; click to change`,placeholder:"which agent and model work on it"})}function HK(e){const t=[],n=new Map,r=new Map;for(const s of[...e].sort((a,l)=>a.at-l.at)){if(s.review){t.push({root:s,replies:[]});continue}const a=s.replyTo?n.get(s.replyTo):void 0;if(a){a.replies.push(s);continue}const l={root:s,replies:[]};n.set(s.id,l);const u=s.path??"";r.set(u,[...r.get(u)??[],l])}const o=[...r.entries()].sort(([s],[a])=>s.localeCompare(a)).map(([s,a])=>({path:s,threads:a.sort((l,u)=>(l.root.line??0)-(u.root.line??0))}));return{reviews:t,files:o}}const Ev=e=>e.line===void 0?null:e.startLine!==void 0?`${e.startLine}-${e.line}`:String(e.line);function RC(e){return e==="changes_requested"?"requested changes":e==="approved"?"approved":"reviewed"}const zE=e=>e.split(`
256
- `).map(t=>t?`> ${t}`:">").join(`
257
- `);function WK({root:e,replies:t}){const n=Ev(e),r=e.path?`${e.path}${n?` ${e.startLine===void 0?"line":"lines"} ${n}`:""}`:null,s=[`${e.review?`${e.author} ${e.review==="changes_requested"?"requested changes on":RC(e.review)} the pull request`:r?`${e.author} commented on ${r} in the pull request`:`${e.author} commented on the pull request`}, ${e.url}`];e.body&&s.push(zE(e.body));for(const a of t)s.push(`${a.author} replied:
258
- ${zE(a.body)}`);return s.join(`
259
-
260
- `)}function KK({root:e}){if(!e.path)return`review from ${e.author}`;const t=e.path.slice(e.path.lastIndexOf("/")+1),n=Ev(e);return`${t}${n?` (${n})`:""} from ${e.author}`}function OC(e,t){const n=t.length===0?"":t.length<=2?` from ${t.join(" and ")}`:` from ${t[0]} and ${t.length-1} others`;return{count:`${e} ${e===1?"comment":"comments"}`,rest:n}}function al(e,t,n){if(!t)return e;const r=new Set(t.map(a=>a-n)),o=[];let s="";for(let a=0;a<e.length;a++)r.has(a)?(s&&o.push(s),s="",o.push(d.jsx("b",{className:"hit",children:e[a]},a))):s+=e[a];return s&&o.push(s),o}function qK({c:e,query:t}){const n=t.trim();return d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"picker-name",children:["/",al(e.name,n?Vy(e.name,n):null,0)]}),d.jsx("span",{className:"picker-desc row-dim",children:e.description})]})}function In({label:e,hint:t,current:n=!1}){return d.jsxs(d.Fragment,{children:[n&&d.jsx("span",{className:"row-current","aria-hidden":"true"}),d.jsx("span",{className:"picker-label",children:e}),t?d.jsx("span",{className:"picker-hint row-dim",children:t}):null]})}function ZK(e,t,{sock:n}){return[{id:`forget-visit:${t}`,label:"remove from this list",onClick:()=>n==null?void 0:n.send({t:"forget-visit",repoId:e,path:t})}]}const GK=/ \| | - | \u2013 | \u2014 | \u00b7 |: /,VK=/^(\d+|[0-9a-f]{8}-[0-9a-f-]{27}|[0-9a-f]{12,})$/i,YK=/^[[:$*{]|\[/;function XK(e){const t=new Map,n=e.filter(s=>!!s.title);if(new Set(n.map(s=>s.path)).size<2)return t;const r=n.map(s=>({path:s.path,parts:s.title.split(GK).map(a=>a.trim()).filter(Boolean)})),o=new Map;for(const{path:s,parts:a}of r)for(const l of a)o.set(l,(o.get(l)??new Set).add(s));for(const{path:s,parts:a}of r){const l=a.filter(u=>{var f;return(((f=o.get(u))==null?void 0:f.size)??0)<2});l.length>0&&t.set(s,l.join(" "))}return t}function Sv(e){const t=e.replace(/\?[^#]*/,"").split(/[/#]/).filter(Boolean);for(let n=t.length-1;n>=0;n--){let r=t[n];try{r=decodeURIComponent(r)}catch{}if(VK.test(r)||YK.test(r))continue;const o=r.replace(/[-_.]+/g," ").trim();if(o)return o[0].toUpperCase()+o.slice(1)}return"Home"}const Gg=8,QK=3,JK=50,eq=3;function tq(e,t,n=[]){const r=new Map,o=[],s=new Map;for(const a of(t==null?void 0:t.routes)??[]){if(a.endpoint)continue;const l=a.dynamic?QD(a.path):null;l?(o.push(l),s.set(a.path,a)):r.set(a.path,a)}return{history:e,statics:r,templates:o,templateRoutes:s,unseen:(t==null?void 0:t.unseen)??{},titles:XK(e),links:new Map(n.map(a=>[a.path,a.text]))}}function nq(e){if(!e)return"/";try{const t=new URL(e);return t.pathname+t.search+t.hash}catch{return"/"}}function rq(e){const t=e.trim();return/^[/?#]/.test(t)?t:`/${t}`}function oq(e,t){const n=/^[/?#]/.test(t)?e:e.replace(/^\//,"");return t&&n.toLowerCase().startsWith(t.toLowerCase())?n:null}const MC=e=>/^\[\[?\.\.\.|^\*$|^\$$/.test(e),mu=e=>MC(e)||/[[:$*{]/.test(e)&&!/^[^[{:$*]+\?$/.test(e),sq=e=>sp(`/${e}`).text.slice(1),_v=e=>e.split("/").filter(Boolean);function Nv(e,t){const n=t.startsWith("/"),r=t.replace(/^\//,"").split("/"),o=_v(e);let s="";const a=[],l=p=>{const g=sq(p);a.push([s.length,s.length+g.length]),s+=g};for(let p=0;p<r.length;p++){const g=r[p],y=o[p];if(y===void 0)return null;if(p<r.length-1){if(MC(y))return{show:t,accept:t};if(mu(y)){if(!g)return null}else if(g.toLowerCase()!==y.toLowerCase())return null;s+=`${mu(y)?g:y}/`;continue}if(mu(y))g?s+=g:l(y);else{if(!y.toLowerCase().startsWith(g.toLowerCase()))return null;s+=y}}for(const p of o.slice(r.length))s+="/",mu(p)?l(p):s+=p;const u=n?1:0,f=(n?"/":"")+s,h=a[0];return{show:f,accept:h?f.slice(0,h[0]+u):f,params:a.map(([p,g])=>[p+u,g+u])}}function iq(e,t){const n=Nv(e,t);return n?n.accept.length>t.length?n.accept:t:sp(e).literal}function LC(e,t){if(e.kind==="go")return null;if(e.template){const n=Nv(e.path,t);return n&&n.show.length>t.length?n:null}return oq(e.path,t)}const aq=e=>e.trim().replace(/^\//,"").toLowerCase();function PC(e,t){for(let n=0;n<e.length;n++)if("/-_.#".includes(e[n])&&e.startsWith(t,n+1))return!0;return!1}function cq(e,t,n){const r=e.replace(/^\//,"").toLowerCase(),o=t.toLowerCase();return r===n?100:r.startsWith(n)?80:PC(r,n)?60:o.startsWith(n)?50:o.split(/\s+/).some(s=>s.startsWith(n))?45:r.includes(n)||o.includes(n)?20:0}function lq(e,t){const{text:n,literal:r}=sp(e);return r.replace(/^\//,"").toLowerCase().startsWith(t)?80:Nv(e,t)?70:PC(n.replace(/^\//,"").toLowerCase(),t)?60:0}function uq(e,t){const n=_v(e).findIndex(mu);return n>=0&&t.split("/").length>n}function Eu(e,t,n){var l;const r=e.statics.get(t),o=r?null:JD(e.templates,t),s=(r==null?void 0:r.file)??(o?(l=e.templateRoutes.get(o.path))==null?void 0:l.file:void 0),a=s?e.unseen[s]:void 0;return{kind:"page",path:t,title:e.titles.get(t)||e.links.get(t)||Sv(t),template:!1,visited:n<Number.POSITIVE_INFINITY,...s?{file:s}:{},...a?{badge:a}:{},rank:n,group:(o==null?void 0:o.path)??t,score:0}}function DC(e,t){const n=e.unseen[t.file];return{kind:"page",path:t.path,title:Sv(t.path),template:!0,visited:!1,file:t.file,...n?{badge:n}:{},rank:Number.POSITIVE_INFINITY,group:t.path,score:0}}function nh({rank:e,group:t,score:n,...r}){return r}const $h=e=>_v(e).length,Ch=e=>e.badge==="new"?0:e.badge==="changed"?1:2;function dq(e,t){const n=new Set,r=[];e.history.forEach((h,p)=>{if(h.path===t)return;const g=Eu(e,h.path,p);n.has(g.group)||(n.add(g.group),r.push(g))});const o=new Set(r.map(h=>h.path)),s=r.filter(h=>h.badge);for(const[h,p]of e.statics)e.unseen[p.file]&&h!==t&&!o.has(h)&&s.push(Eu(e,h,Number.POSITIVE_INFINITY));for(const h of e.templateRoutes.values())e.unseen[h.file]&&!n.has(h.path)&&s.push(DC(e,h));s.sort((h,p)=>Ch(h)-Ch(p)||h.rank-p.rank);const a=r.filter(h=>!h.badge),l=s.slice(0,Gg-Math.min(QK,a.length));for(const h of a)l.length<Gg&&l.push(h);const u=new Set(l.map(h=>h.path)),f=[...e.statics.keys(),...[...e.links.keys()].filter(h=>!e.statics.has(h))].filter(h=>h!==t&&!u.has(h)&&!o.has(h)).sort((h,p)=>$h(h)-$h(p)||(h<p?-1:h>p?1:0));for(const h of f){if(l.length>=Gg)break;l.push(Eu(e,h,Number.POSITIVE_INFINITY))}return l.map(nh)}function fq(e,t,n){const r=aq(t),o=rq(t),s=new Map;e.history.forEach((y,w)=>{y.path!==n&&s.set(y.path,Eu(e,y.path,w))});for(const y of[...e.statics.keys(),...e.links.keys()])y!==n&&!s.has(y)&&s.set(y,Eu(e,y,Number.POSITIVE_INFINITY));const a=[];for(const y of s.values()){const w=cq(y.path,y.title,r);w>0&&a.push({...y,score:w})}let l=null;for(const y of e.templates){const w=e.templateRoutes.get(y.path);if(!l&&!e.statics.has(o)&&y.re.test(o)){l=w;continue}const v=lq(y.path,r);v>=60&&a.push({...DC(e,w),score:v})}a.sort((y,w)=>w.score-y.score||y.rank-w.rank||Ch(y)-Ch(w)||$h(y.path)-$h(w.path)||(y.path<w.path?-1:y.path>w.path?1:0));const u=new Map,f=[];for(const y of a){if(!y.template&&y.group!==y.path){const w=u.get(y.group)??0;if(w>=eq&&!uq(y.group,r))continue;u.set(y.group,w+1)}if(f.push(y),f.length>=JK)break}if(f.some(y=>y.score===100))return f.map(nh);const h={kind:"go",path:o,...l?{title:Sv(l.path)}:{}},p=f[0];return!l&&p!==void 0&&p.score>=80&&hq(p.path,r)?[...f.map(nh),h]:[h,...f.map(nh)]}function hq(e,t){const n=e.replace(/^\//,"").toLowerCase().slice(t.length);return!t.endsWith("/")&&n.length>0&&!/^[/?#]/.test(n)}function zC(e,{query:t,current:n,here:r}){return t===n||t.trim()===""?dq(e,r):fq(e,t,r)}const pq=[],mq=[];function FC(e,t){const n=L(s=>(t?s.visits[t]:void 0)??pq),r=Rt(e,"pages"),o=Rt(e,"links");return ct([e],()=>{vN(r)&&fn.post(e,{type:"links"})}),E.useMemo(()=>tq(n,r,o),[n,r,o])}function gq({row:e}){if(e.kind!=="page"||!e.template)return d.jsx("span",{className:"bar-route-path row-dim",children:e.path});const{text:t,params:n}=sp(e.path),r=[];let o=0;for(const[s,a]of n)s>o&&r.push(t.slice(o,s)),r.push(d.jsx("span",{className:"bar-route-param",children:t.slice(s,a)},s)),o=a;return o<t.length&&r.push(t.slice(o)),d.jsx("span",{className:"bar-route-path row-dim",children:r})}function BC({row:e}){return e.kind==="go"?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"picker-label",children:e.path}),e.title?d.jsx("span",{className:"bar-route-path row-dim",children:e.title}):null,d.jsx("span",{className:"picker-hint row-dim",children:"as typed"})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"picker-label",children:e.title}),d.jsx(gq,{row:e}),e.badge?d.jsx("span",{className:e.badge==="new"?"badge-new":"badge-changed",children:e.badge}):null]})}const UC=e=>e.kind==="page"&&e.file?e.file:e.path,HC=(e,t)=>e.kind==="page"&&e.template?iq(e.path,t):null,WC=e=>e.kind==="page"&&e.template?"fills in the parameter":"goes there";function KC(e,t,n){return e.kind!=="page"?[]:kp([...e.file&&t.dir?Hs({id:t.worktreeId,dir:t.dir},e.file,{},n):[],pT,...e.visited?ZK(t.repoId,e.path,n):[]])}function kq({worktreeId:e,repoId:t,url:n,open:r}){const o=ht(),s=nt(),a=L(w=>{const v=Jt(w,e);return v?v.worktree.path:null}),l=FC(e,t),u=nq(n),f=n?op(n):null,h=E.useCallback((w,v)=>zC(l,{query:v,current:u,here:f}),[l,u,f]),p=E.useCallback(w=>w===u||w.trim()==="",[u]),g=()=>o({a:"close"}),y=E.useMemo(()=>({open:r,onOpen:()=>o({a:"open",overlay:{kind:"routes"}}),id:"routes",className:"bar-path",attrs:Nt("Go to a page",Ht("routes"))}),[r,o]);return d.jsx(qr,{anchored:{matchWidth:0,cover:!1,offset:-1},field:y,items:mq,filter:h,initialQuery:u,selectOnMount:!0,idleWhen:p,onIdlePick:w=>{w.trim()===""?fn.post(e,{type:"navigate",path:"/"}):fn.post(e,{type:"reload"}),g()},keyOf:w=>`${w.kind}:${w.path}`,rowClass:()=>"picker-row",rowTitle:UC,completionOf:(w,v)=>p(v)?null:LC(w,v),narrowTo:HC,onPick:w=>{fn.post(e,{type:"navigate",path:w.path}),g()},onBack:g,rowMenu:w=>KC(w,{worktreeId:e,repoId:t,dir:a},{sock:s,dispatch:o}),placeholder:"type a path",keys:(w,v)=>({complete:"completes the path",pick:w?WC(w):v.trim()===""?"goes to the root":"reloads",back:"closes"}),empty:"no pages yet; type a path",row:w=>d.jsx(BC,{row:w})})}function qC(e,t){const n=t.trim();return d.jsx(In,{label:al(e.label,n?Vy(e.label,n):null,0),hint:e.hint&&d.jsx(ss,{k:e.hint})})}function ZC({anchored:e,trailing:t}){const n=ht(),r=qj(),o=L(s=>{var a;return((a=s.paletteReturn)==null?void 0:a.mode)==="commands"?s.paletteReturn.q:""});return d.jsx(qr,{anchored:e,trailing:t,items:r,filter:Zj,rowClass:()=>"picker-row",keyOf:s=>s.id,onPick:(s,a)=>{s.sub?n({a:"palette-return",v:{mode:"commands",q:a}}):n({a:"close"}),s.run()},onBack:()=>n({a:"close"}),placeholder:"run a command…",initialQuery:o,empty:"no matching command",row:(s,a,l)=>qC(s,l)})}function GC(e,t){const n=new Map(t.map(a=>[a.path,a])),r=t.filter(a=>a.xy==="??"&&a.path.endsWith("/")).map(a=>a.path),o=e.map(a=>{const l=n.get(a)??(r.some(u=>a.startsWith(u))?{path:a,xy:"??"}:void 0);return l?{path:a,status:l}:{path:a}}),s=new Set(e);for(const a of t)!s.has(a.path)&&!a.path.endsWith("/")&&o.push({path:a.path,status:a});return o}function FE(e,t){const n=e.split("/"),r=t.split("/");for(let o=0;;o++){const s=n[o],a=r[o];if(s===void 0||a===void 0)return n.length-r.length;const l=o===n.length-1,u=o===r.length-1;if(l!==u)return l?-1:1;if(s!==a)return s<a?-1:1}}function VC(e,t,n,r=50){const o=GC(e,t),s=n.trim().toLowerCase();if(!s){const l=new Map(t.map((p,g)=>[p.path,g])),u=p=>{var g;return l.get(((g=p.status)==null?void 0:g.path)??"")??l.get(p.path)??Number.MAX_SAFE_INTEGER},f=o.filter(p=>p.status).sort((p,g)=>u(p)-u(g)||FE(p.path,g.path)),h=o.filter(p=>!p.status).sort((p,g)=>FE(p.path,g.path));return{rows:[...f,...h].slice(0,r),changed:Math.min(f.length,r)}}const a=XC(o,s);return a.sort((l,u)=>u.score-l.score||l.row.path.localeCompare(u.row.path)),{rows:a.slice(0,r).map(l=>l.row),changed:0}}function YC(e,t){const n=e.toLowerCase(),r=BE(n,t);return r<=0?0:BE(n.slice(n.lastIndexOf("/")+1),t)>0?r+10:r}function XC(e,t){const n=[];for(const r of e){const o=YC(r.path,t);o>0&&n.push({row:r,score:r.status?o+4:o})}return n}function wq(e,t,n,r,o){const s=r.trim().toLowerCase();if(!s)return VC(e,n,r,o).rows.map(u=>({kind:"file",path:u.path,status:u.status}));const a=XC(GC(e,n),s).map(({row:u,score:f})=>({row:{kind:"file",path:u.path,status:u.status},score:f}));for(const u of t){const f=YC(u,s);f>0&&a.push({row:{kind:"folder",path:u},score:f})}const l=u=>u.kind==="folder"?1:0;return a.sort((u,f)=>f.score-u.score||l(u.row)-l(f.row)||u.row.path.localeCompare(f.row.path)),a.slice(0,o).map(u=>u.row)}function yq(e,t){const n=e.toLowerCase(),r=[];let o=0;for(const s of t.toLowerCase()){const a=n.indexOf(s,o);if(a===-1)return null;r.push(a),o=a+1}return r}function BE(e,t){let n=0,r=0,o=0;for(const s of t){const a=e.indexOf(s,r);if(a===-1)return 0;o=a===r?o+1:1,n+=o+(a===0||e[a-1]==="/"||e[a-1]==="."?3:0),r=a+1}return n+Math.max(0,40-e.length/4)}function vq(e){const t=e.lastIndexOf("/");return t===-1?[e,""]:[e.slice(t+1),e.slice(0,t+1)]}const UE=[],bq=[],xq=[];function Eq({worktreeId:e}){var x;const t=ht(),n=nt(),r=Pn(),o=L(N=>N.connected);ct([e,o,n],()=>yp(e,r.getState(),{sock:n,dispatch:t}));const s=lT(e),a=s.files??bq,l=((x=s.git)==null?void 0:x.files)??xq,u=qj(),f=L(N=>{var S;return((S=N.paletteReturn)==null?void 0:S.mode)==="quick-open"?N.paletteReturn.q:""}),h=L(N=>{var T;const S=(T=Jt(N,e))==null?void 0:T.worktree;return S?S.path:null}),p=L(N=>{var S;return((S=Jt(N,e))==null?void 0:S.repoId)??null}),g=L(N=>{var S;return((S=Iu(N))==null?void 0:S.worktreeId)===e}),y=FC(e,p),w=s.page.url?op(s.page.url):null,v=E.useCallback((N,S)=>S.startsWith(">")?Zj(u,S.slice(1)).map(T=>({kind:"cmd",c:T})):S.startsWith("/")?g?zC(y,{query:S,current:"/",here:w}).map(T=>({kind:"page",page:T})):UE:VC(a,l,S).rows.map(T=>({kind:"file",path:T.path,status:T.status})),[u,a,l,g,y,w]);return d.jsx(qr,{items:UE,filter:v,keyOf:N=>N.kind==="cmd"?`c:${N.c.id}`:N.kind==="page"?`p:${N.page.kind}:${N.page.path}`:`f:${N.path}`,rowClass:N=>N.kind==="file"?"qo-file":"picker-row",rowTitle:N=>N.kind==="page"?UC(N.page):void 0,completionOf:(N,S)=>N.kind==="page"?LC(N.page,S):null,narrowTo:(N,S)=>N.kind==="page"?HC(N.page,S):null,onPick:(N,S)=>{N.kind==="cmd"?(N.c.sub?t({a:"palette-return",v:{mode:"quick-open",q:S}}):t({a:"close"}),N.c.run()):N.kind==="page"?(fn.post(e,{type:"navigate",path:N.page.path}),t({a:"close"})):(Rn({dispatch:t},{worktreeId:e,path:N.path,view:Bi(N.path)}),t({a:"close"}))},onBack:()=>t({a:"close"}),rowMenu:N=>N.kind==="file"&&h?Hs({id:e,dir:h},N.path,{},{sock:n,dispatch:t}):N.kind==="page"&&p?KC(N.page,{worktreeId:e,repoId:p,dir:h},{sock:n,dispatch:t}):[],placeholder:"jump to file · type > for commands, / for pages",keys:(N,S)=>S.startsWith("/")?{complete:"completes the path",pick:(N==null?void 0:N.kind)==="page"?WC(N.page):void 0,back:"closes"}:{pick:"opens",back:"closes"},initialQuery:f,empty:N=>N.startsWith(">")?"no matching command":N.startsWith("/")?g?"no pages yet; type a path":"no preview running":"no matches",row:(N,S,T)=>N.kind==="cmd"?qC(N.c,T.slice(1)):N.kind==="page"?d.jsx(BC,{row:N.page}):dw(N.path,N.status,T,{gutter:l.length>0})})}function dw(e,t,n,{folder:r=!1,gutter:o=!0}={}){const[s,a]=vq(e),l=n.trim()?yq(e,n.trim()):null;return d.jsxs(d.Fragment,{children:[o&&d.jsx("span",{className:`xy ${t?oy(t.xy):""}`,children:t?sy(t.xy):""}),d.jsxs("span",{className:"name",children:[al(s,l,a.length),r&&"/"]}),d.jsx("span",{className:"dir row-dim",children:a&&d.jsxs(d.Fragment,{children:["‎",al(a,l,0),"‎"]})}),t&&d.jsx(Nj,{f:t})]})}function Sq(e,t,n){var a;if(!e)return null;if(e.available)return e.checkFailed?{kind:"unready",text:e.checkFailed,retry:null}:((a=e.auth)==null?void 0:a.kind)==="none"?{kind:"unready",text:e.loginHint??`${e.name} is not logged in`,retry:null}:null;const r=n?t.find(l=>l.available&&l.id!==e.id):void 0,o=r?{other:r}:{};return e.installing?{kind:"installing",text:`${e.name} is installing`,retry:null,...o}:{kind:"failed",text:typeof e.install=="object"?`${e.name} did not install: ${e.install.failed}`:`${e.name} is not ready: ${Bp(e)}`,retry:xv(e),...o}}function Us({icon:e,verb:t,tip:n,onPress:r,busy:o,onDismiss:s,className:a,children:l}){return d.jsxs("div",{className:We("composer-offer",a),children:[d.jsx(xt,{name:e,className:"icon-inline"}),d.jsxs("span",{className:We("composer-offer-line",o&&"live-text"),children:[t&&d.jsxs(d.Fragment,{children:[d.jsx(Me,{variant:"inline",tone:"strong","data-tip":n,onClick:r,children:t})," "]}),l]}),s&&d.jsx(Tt,{icon:"close",tone:"quiet",className:"composer-offer-close",label:"Not this one",onClick:s})]})}function QC({item:e,n:t,onRemove:n}){const r=Mr();return e.kind==="image"?d.jsx(Dp,{src:e.local??r.upload(e.upload),n:t,name:e.name,width:e.width,height:e.height,bytes:e.bytes,uploading:e.uploading,progress:e.progress,onRemove:n}):e.kind==="file"?d.jsx(Mp,{name:e.name,bytes:e.bytes,href:e.text&&e.upload?r.upload(e.upload):void 0,uploading:e.uploading,progress:e.progress,onRemove:n}):d.jsx(Op,{n:t,name:e.name,source:e.source,lines:e.lines,chars:e.chars,preview:e.preview,text:e.text,onRemove:n})}function JC({children:e}){return d.jsx("code",{className:"composer-offer-whole",children:e})}function _q({children:e}){var n;if(!e.includes("://"))return d.jsx(JC,{children:e});const t=[];for(const r of e.split(" ")){const o=t.length-1;r.includes("://")||o<0||(n=t[o])!=null&&n.includes("://")?t.push(r):t[o]=`${t[o]} ${r}`}return d.jsx("code",{children:t.map((r,o)=>d.jsxs(E.Fragment,{children:[o>0&&" ",r.includes("://")?r.split(new RegExp("(?=\\/)(?<![:/])")).map((s,a)=>d.jsxs(E.Fragment,{children:[a>0&&d.jsx("wbr",{}),d.jsx("span",{className:"composer-offer-whole",children:s})]},a)):d.jsx("span",{className:"composer-offer-whole",children:r})]},o))})}function Nq({offer:e,onInstall:t,onDismiss:n}){if(e.state==="installing")return d.jsx(Us,{icon:"download",busy:!0,children:"Installing Toyon with npm"});if(e.state==="installed")return d.jsxs(Us,{icon:"check",className:"composer-offer-long",onDismiss:n,children:["Toyon is installed. In a new terminal, ",d.jsx(JC,{children:"toyon restart"})," moves onto it."]});if(e.state==="failed"){const r=jK(e);return d.jsxs(Us,{icon:"download",verb:"try again",tip:"Run the install again",className:"composer-offer-long",onPress:t,onDismiss:n,children:[r.why,"."," ",r.permissions&&d.jsxs(d.Fragment,{children:[d.jsx("a",{href:TK,target:"_blank",rel:"noreferrer",children:"npm's guide"})," ","covers this error."," "]}),"By hand: ",d.jsx(_q,{children:r.command})]})}return d.jsx(Us,{icon:"download",verb:"install",tip:"Toyon started with npx does not update itself and leaves no toyon command. This runs npm install -g toyon.",onPress:t,onDismiss:n,children:"Toyon for good, so it updates itself"})}function eA(e){return gu(e.key)&&(e.metaKey||e.ctrlKey)&&!e.altKey?!1:e.metaKey||e.ctrlKey||e.altKey}const tA=e=>e.length===1&&e>="1"&&e<="9",gu=e=>e==="Enter"||e==="NumpadEnter";function Tq(e,t,n){const r=gu(e.key)&&(e.metaKey||e.ctrlKey);return t?e.key==="Escape"||e.key==="Tab"&&!e.shiftKey?{kind:"field-leave"}:r?{kind:"submit"}:gu(e.key)&&!e.shiftKey?{kind:"field-enter"}:{kind:"typing"}:eA(e)?{kind:"chord"}:e.key==="Escape"?{kind:"escape"}:r?{kind:"submit"}:gu(e.key)||e.key===" "&&n.spacePicks?n.cursor===void 0?{kind:"submit"}:{kind:"pick",at:n.cursor,by:gu(e.key)?"enter":"space"}:e.key==="ArrowUp"||e.key==="ArrowDown"?n.cursor===void 0?null:{kind:"cursor",to:rd(n.cursor,e.key==="ArrowUp"?-1:1,n.count)}:tA(e.key)&&Number(e.key)<=n.count?{kind:"pick",at:Number(e.key)-1,by:"digit"}:null}function Tv(e,t){var o,s,a,l;const n=e.target instanceof HTMLTextAreaElement,r=Tq(e,n,t);if(!r)return!1;switch(r.kind){case"chord":case"typing":return!0;case"escape":case"field-leave":return e.preventDefault(),e.stopPropagation(),(o=r.kind==="escape"?t.onEscape:t.onFieldLeave)==null||o(),!0;case"submit":return e.preventDefault(),t.onSubmit?t.onSubmit():n?(s=t.onFieldEnter)==null||s.call(t):t.cursor!==void 0&&t.onPick(t.cursor,"enter"),!0;case"pick":return e.preventDefault(),t.onPick(r.at,r.by),!0;case"cursor":return e.preventDefault(),(a=t.onCursor)==null||a.call(t,r.to),!0;case"field-enter":return e.preventDefault(),(l=t.onFieldEnter)==null||l.call(t),!0}}function nA(e){return!e||e===document.body?!1:e.closest(".monaco-editor, .xterm")?!0:(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&!e.closest(".chat-input")}function jq(e,t){ct([t],()=>{const o=requestAnimationFrame(()=>{var s;nA(document.activeElement)||(s=e.current)==null||s.focus()});return()=>cancelAnimationFrame(o)});const n=E.useRef(!1),r=E.useCallback(()=>{requestAnimationFrame(()=>{var o;document.activeElement===document.body&&((o=e.current)==null||o.focus())})},[e]);return E.useEffect(()=>{const o=()=>{n.current=!0},s=()=>{n.current=!1,r()};return window.addEventListener("pointerdown",o,!0),window.addEventListener("pointerup",s,!0),window.addEventListener("pointercancel",s,!0),()=>{window.removeEventListener("pointerdown",o,!0),window.removeEventListener("pointerup",s,!0),window.removeEventListener("pointercancel",s,!0)}},[r]),o=>{!o.relatedTarget&&!n.current&&r()}}function Ah(e){var n,r;const t=document.activeElement;nA(t)||t&&((n=e.current)!=null&&n.contains(t))||(r=e.current)==null||r.focus({preventScroll:!0})}function Ih({root:e,id:t,onKeyDown:n,onKeyUp:r,onPaste:o,children:s}){const a=jq(e,t);return d.jsx("div",{ref:e,className:"card",tabIndex:-1,onKeyDown:n,onKeyUp:r,onPaste:o,onBlur:a,children:s})}function Gu({children:e,sub:t}){return d.jsxs("div",{className:"card-head",children:[d.jsx("div",{className:"card-text",children:e}),t&&d.jsx("div",{className:"card-sub",children:t})]})}function fw(e){const t=E.useRef(null),n=yv(t);return"html"in e?d.jsxs("div",{ref:t,className:"card-band md",children:[d.jsx("div",{onClick:Ny,dangerouslySetInnerHTML:{__html:e.html}}),n]}):d.jsxs("div",{ref:t,className:"card-band card-code",children:[d.jsx("pre",{children:e.code}),n]})}function $q({children:e}){return d.jsx("div",{className:"card-foot",children:e})}function Cq(e){const t=e.findIndex(n=>n.kind.startsWith("reject"));return t<0?null:t}function rA(e){const{key:t}=e;return t.length!==1||t===" "||t==="n"||tA(t)||eA(e)?null:t}const Aq=[{selected:[]}];function Iq({item:e,worktreeId:t,rootRef:n}){var oe,U;const r=nt(),o=ht(),s=Rt(t,"card"),a=L(B=>{var Q;return(Q=Jt(B,t))==null?void 0:Q.worktree.mode})??e.mode,l=a==="plan"?"auto":a,u=(s==null?void 0:s.id)===e.id?s.draft:Aq,f=(oe=u[0])==null?void 0:oe.note,h=f!==void 0,p=h?Number(((U=u[0])==null?void 0:U.selected[0])??0):-1,g=B=>o({a:"card-draft",id:t,card:{id:e.id,draft:B,current:0}}),y=E.useRef(null),[w,v]=E.useState(0),[x,N]=E.useState(null),S=x!==null,T=e.pieces.length===1?e.pieces[0]:void 0,j=e.plan,$=()=>{j&&Rn({dispatch:o},{worktreeId:t,path:j,view:"preview"})},R=L(B=>B.activeId),A=L(B=>B.frame==="phone");ct([e.id,j],()=>{j&&!T&&R===t&&!A&&Rn({dispatch:o},{worktreeId:t,path:j,view:"preview",focus:!1})});const I=E.useMemo(()=>T?La(T.plan):"",[T]),M=E.useMemo(()=>T?$T(e,T):y5,[e,T]),P=B=>{if(S||!r)return;const Q=M[B];Q&&(Q.fate===null?r.send(Jx(e,t,!1,f)):(T&&Q.fate!==Xs(e,T)&&r.send(CT(e,t,T.id,Q.fate)),r.send(Jx(e,t,!0,f)),N(B)),o({a:"answered",id:t}))},F=(B,Q)=>{S||!M[B]||(g([{selected:[String(B)],note:Q}]),v(B),requestAnimationFrame(()=>{const ue=y.current;ue&&(ue.focus(),ue.setSelectionRange(ue.value.length,ue.value.length))}))},q=()=>o({a:"card-park",id:t,cardId:e.id}),W=()=>{var Q;const B=du(u,0);B!==u&&g(B),(Q=n.current)==null||Q.focus()},ee=B=>{if(Tv(B,{count:M.length,cursor:w,onCursor:v,onPick:P,onEscape:q,onFieldEnter:()=>P(p),onFieldLeave:W}))return;if(B.key==="n"){B.preventDefault(),F(w,f??"");return}const Q=rA(B);if(Q!==null){if(B.preventDefault(),Q==="r"&&j&&!T&&!h)return $();F(h?p:v5(M)??w,(f??"")+Q)}},V=M.map((B,Q)=>({label:B.label,...x===Q?{description:"starting"}:B.description?{description:B.description}:{},hint:{k:"n",label:"add context",icon:"edit",on:!h},tone:B.fate===null?"deny":void 0,checked:h&&Q===p,field:h&&Q===p?{ref:y,value:f??"",placeholder:b5(B,!!T),enterKeyHint:"send",onChange:ue=>g([{selected:[String(p)],note:ue}]),onSend:()=>P(p)}:void 0,disabled:S}));if(T)return d.jsxs(Ih,{root:n,id:e.id,onKeyDown:ee,children:[d.jsx(Gu,{sub:d.jsxs(d.Fragment,{children:[T.project?`Starts a worktree in ${T.project.name}, in ${l} mode${l==="auto"?", which runs without asking":""}, with this as its plan. `:"","Nothing has started yet."]}),children:Rk(e)}),d.jsx(fw,{html:I}),d.jsx(sl,{rows:V,cursor:w,onCursor:B=>{v(B),Ah(n)},onPick:P,onHint:B=>F(B,f??"")})]});const te=Iy(e),K=te.worktrees+te.queued>0,C=j?d.jsx(Me,{variant:"inline","data-tip":"Open it beside the box; any row can still be moved (r)",onClick:()=>$(),children:"The list is on its page"}):"The list is the agent's";return d.jsxs(Ih,{root:n,id:e.id,onKeyDown:ee,children:[d.jsx(Gu,{sub:d.jsxs(d.Fragment,{children:[C,"."," ",K?`New worktrees start in ${l} mode${l==="auto"?", which runs without asking":""}. `:"","Nothing has started yet."]}),children:Rk(e)}),d.jsx(sl,{rows:V,cursor:w,onCursor:B=>{v(B),Ah(n)},onPick:P,onHint:B=>F(B,f??"")})]})}function Rq(e,t){if(t.queued>0||t.sending||t.card)return null;const n=e.at(-1);if(!n)return null;if(n.kind==="stopped"||n.kind==="error"){if(n.seq===void 0)return null;const o=`${n.kind}:${n.seq}`;return t.dismissed.has(o)?null:n.kind==="stopped"?{verb:"continue",key:o,after:"stop"}:{verb:"continue",key:o,after:"error",...Oq(e)?{again:!0}:{}}}if(n.kind!=="tool"||!n.done||!n.fixable||t.dismissed.has(n.id)||e.some(o=>o.kind==="asked"&&o.toolId===n.id))return null;const r=wv(n);return r===null?null:{verb:"fix",key:n.id,toolId:n.id,command:r}}function Oq(e){const[t,n,r]=e.slice(-3);return(r==null?void 0:r.kind)==="error"&&(n==null?void 0:n.kind)==="asked"&&n.about==="failed"&&(t==null?void 0:t.kind)==="error"&&t.text===r.text}let hw=new Set;const pw=new Set;function Mq(e){return pw.add(e),()=>{pw.delete(e)}}function HE(e){hw=new Set(hw).add(e);for(const t of pw)t()}function Lq(){return E.useSyncExternalStore(Mq,()=>hw)}const Pq=e=>Uh.some(t=>t.id===e);function Dq(e){return[...Uh.map(t=>({name:t.id,description:t.description,hint:"[<description>]"})),{name:"check",description:"run the repo's check here and write the recap and the commit message",hint:"[<note for the commit message>]"},{name:"land",description:e},{name:"archive",description:"archive this worktree once its work has landed"},{name:"handoff",description:"a new worktree for part of this work, here or in another project, born with a plan for it",hint:"[<project>] [<message>]"}]}function zq(e,t,n){const r=e.trim();if(!r)return{pick:!0};const o=t.find(h=>h.id===n),s=r.search(/\s/),a=s===-1?r:r.slice(0,s),l=s===-1?void 0:r.slice(s).trim()||void 0,u=a.toLowerCase(),f=u==="here"?o:t.find(h=>h.name.toLowerCase()===u);return f?{repo:f,...l?{text:l}:{}}:o?{repo:o,text:r}:{pick:!0}}function oA(e,t){const n=new Set(e.map(o=>o.name)),r=t.filter(o=>!n.has(o.name));return{yours:r.filter(o=>o.origin),own:e,rest:r.filter(o=>!o.origin)}}function WE(e,t){const n=oA(e,t);return[...n.yours,...n.own,...n.rest]}function KE(e,t){const n=oA(e,t);return{rows:[...n.yours,...n.own],more:n.rest.length}}function Fq(e,t){var r;const n=/^\/(\S+) $/.exec(e);return n?((r=t.find(o=>o.name===n[1]))==null?void 0:r.hint)??null:null}function Bq(e,t){const n=/^\/(\S*)([\s\S]*)$/.exec(e);if(!n)return null;const r=n[1]??"";return t.some(o=>o.name===r)?{name:r,args:(n[2]??"").trim()}:null}function Uq(e,t){var r;const n=[];for(const o of e){const s=Zh((r=t==null?void 0:t[o])==null?void 0:r.at);!s||s.by==="hand"||(s.by==="agent"?n.push(`Running its own ${o} here now: the agent asked for it before changing the backend.`):n.push(`Running its own ${o} here now: this branch changed ${s.file??"it"}.`))}return n.length>0?n.join(" "):null}const qE=[{selected:[]}];function Hq({item:e,ask:t,worktreeId:n,rootRef:r}){var q;const o=nt(),s=ht(),a=L(W=>W.activeId),l=Rt(n,"card"),u=(l==null?void 0:l.id)===e.id?l.draft:qE,f=(q=u[0])==null?void 0:q.note,h=f!==void 0,p=h?t.choices.findIndex(W=>{var ee;return W.id===((ee=u[0])==null?void 0:ee.selected[0])}):-1,g=E.useRef(null),[y,w]=E.useState(0),v=t.plan,x=E.useMemo(()=>t.detail&&!v?La(t.detail):"",[t.detail,v]),N=L(W=>W.frame==="phone"),S=()=>{v&&a===n&&!N&&Rn({dispatch:s},{worktreeId:n,path:v,view:"preview",focus:!1})};ct([e.id,v],S);const T=t.handoff,j=L(W=>{var V;const ee=T?(V=Or(W,n).chat)==null?void 0:V.find(te=>te.kind==="handoff"&&te.id===T):null;return(ee==null?void 0:ee.kind)==="handoff"?ee:null}),$=W=>s({a:"card-draft",id:n,card:{id:e.id,draft:W,current:0}}),R=(W,ee)=>{const V=t.choices[W];V&&($([{selected:[V.id],note:ee}]),w(W),requestAnimationFrame(()=>{const te=g.current;te&&(te.focus(),te.setSelectionRange(te.value.length,te.value.length))}))},A=W=>{const ee=t.choices[W];if(!ee)return;const V=f==null?void 0:f.trim();o==null||o.send({t:"agent-decide",worktreeId:n,askId:e.id,choiceId:ee.id,...V?{note:V}:{}}),s({a:"answered",id:n})},I=()=>s({a:"card-park",id:n,cardId:e.id}),M=()=>{var W;f!=null&&f.trim()||$(qE),(W=r.current)==null||W.focus()},P=W=>{if(Tv(W,{count:t.choices.length,cursor:y,onCursor:w,onPick:A,onEscape:I,onFieldEnter:()=>A(p),onFieldLeave:M}))return;if(W.key==="n"){W.preventDefault(),R(y,f??"");return}const ee=rA(W);ee!==null&&(W.preventDefault(),R(h?p:Cq(t.choices)??y,(f??"")+ee))},F=t.choices.map((W,ee)=>{const V=W.kind.startsWith("reject"),te=h&&ee===p;return{label:W.name,tone:V?"deny":void 0,hint:{k:"n",label:"add context",icon:"edit",on:!h},checked:te,field:te?{ref:g,value:f,placeholder:V?"what to change, sent with your no":"a note for the work, sent with your yes",enterKeyHint:"send",onChange:K=>$([{selected:[W.id],note:K}]),onSend:()=>A(p)}:void 0}});return d.jsxs(Ih,{root:r,id:e.id,onKeyDown:P,children:[d.jsx(Gu,{sub:j?d.jsxs(d.Fragment,{children:[w5(j,n)," ",d.jsx(Me,{variant:"inline","data-tip":"Read the list at the head of the plan; any row can still be moved",onClick:()=>v&&Rn({dispatch:s},{worktreeId:n,path:v,view:"preview"}),children:"The list is on the plan"}),"."]}):void 0,children:t.title}),t.command&&d.jsx(fw,{code:sC(t.command)}),x&&d.jsx(fw,{html:x}),d.jsx(sl,{rows:F,cursor:y,onCursor:W=>{w(W),Ah(r)},onPick:A,onHint:W=>R(W,f??"")})]})}function Wq({item:e,ask:t,worktreeId:n,rootRef:r,numbers:o,onAnswer:s}){const a=nt(),l=ht(),u=Pn(),f=L(J=>J.clientId),{message:h,questions:p}=t,g=Hc(e.id),y=Rt(g,"attachments"),w=zT(g,n),v=Rt(n,"card"),x=E.useMemo(()=>(v==null?void 0:v.id)===e.id?v:{id:e.id,draft:fz(p),current:0},[v,e.id,p]),{draft:N,current:S}=x,T=S===Dc(p),j=p[S],$=N[S],R=!!(j!=null&&j.multi),[A,I]=E.useState(()=>Pc(j,$)),M=E.useRef(null);E.useEffect(()=>{const J=window.visualViewport;if(!J)return;const pe=()=>{M.current&&M.current===document.activeElement&&M.current.scrollIntoView({block:"nearest"})};return J.addEventListener("resize",pe),()=>J.removeEventListener("resize",pe)},[]);const P=(J,pe)=>l({a:"card-draft",id:n,card:{id:e.id,draft:J,current:pe}}),F=aT(),q=J=>{if(F)return;if(s){J&&s(J);return}const pe=J?y:[],de={t:"agent-answer",worktreeId:n,askId:e.id,...J?{answers:J}:{}};pe.some(Fi)?l({a:"hold-send",id:g,log:n,text:Jw(p,J).join(`
261
- `),frame:de}):(a==null||a.send({...de,...pe.length?{attachments:pe.map(Kc),boxId:g,clientId:f}:{}}),pe.length&&l({a:"clear-attachments",id:g})),l({a:"answered",id:n})},W=()=>l(s?{a:"ask-revive",id:n}:{a:"card-park",id:n,cardId:e.id}),ee=()=>{Sg(p,N)&&q(N)},V=J=>{I(Pc(p[J],N[J])),P(N,J)},te=J=>{j!=null&&j.note&&(P($x(N,S,J,R),S),requestAnimationFrame(()=>{var pe;return(pe=M.current)==null?void 0:pe.focus()}))},K=J=>{if(!(j!=null&&j.note))return;const pe=j.options[J];if(I(J),!pe||R)return te(!pe);P($x(jx(N,S,pe.value,!1),S,!1,!1),S),requestAnimationFrame(()=>{var de;return(de=M.current)==null?void 0:de.focus()})},C=()=>K(A),oe=J=>{const pe=Ez(p,J,S);I(pe.cursor),P(J,pe.current),pe.send&&Sg(p,J)&&q(J)},U=J=>{if(Cx(j,J))return I(J),te(!0);const pe=j==null?void 0:j.options[J];if(!j||!pe)return;const de=jx(du(N,S),S,pe.value,R);if(R){I(J),P(de,S);return}oe(de)},B=J=>{if(!R||Cx(j,J)||!pz(j,N[S]))return U(J);oe(du(N,S))},Q=()=>{var pe;const J=du(N,S);J!==N&&(P(J,S),I(Pc(j,J[S]))),(pe=r.current)==null||pe.focus()},ue=()=>{var pe;const J=du(N,S);if((pe=r.current)==null||pe.focus(),!Ra(J[S])){J!==N&&(P(J,S),I(Pc(j,J[S])));return}oe(J)},he=J=>{if(w.onPasteKey(J),!Tv(J,{count:T?p.length:hz(j),cursor:T?void 0:A,spacePicks:R,onCursor:I,onPick:(pe,de)=>T?V(pe):de==="enter"?B(pe):U(pe),onSubmit:ee,onEscape:W,onFieldEnter:ue,onFieldLeave:Q})){if(J.key==="ArrowLeft"||J.key==="ArrowRight"||J.key==="Tab"){J.preventDefault();const pe=J.key==="ArrowLeft"||J.key==="Tab"&&J.shiftKey;return V(vz(S,pe?-1:1,xz(p)))}if(J.key==="n"&&(j!=null&&j.note))return J.preventDefault(),C();if(J.key==="s"&&!s)return J.preventDefault(),q()}},Ne=J=>p.length===1&&!J.multi,De=(J,pe)=>d.jsxs($q,{children:[(!J||!Ne(J))&&d.jsx(Me,{variant:"outline",size:"md",disabled:F||!Sg(p,N),onClick:ee,children:"send"}),(J==null?void 0:J.note)&&pe&&pe.selected.length>0&&pe.note===void 0&&d.jsxs(Me,{tone:"quiet",size:"md",onClick:()=>te(!1),children:[d.jsx(ss,{k:"n",chip:!0}),"add a note"]}),!s&&d.jsxs(Me,{tone:"quiet",size:"md",onClick:()=>q(),children:[d.jsx(ss,{k:"s",chip:!0}),"skip"]}),d.jsx(Tt,{className:"card-attach",icon:"attach",tone:"chrome",label:"Attach a picture or a file",onClick:()=>MT(u,g)})]}),Be=y.length>0&&d.jsx(_p,{children:d.jsx("div",{className:"card-chips",children:Iw(y,o).map(([J,pe])=>{const de=()=>l({a:"detach",id:g,key:J.key});return J.kind==="pick"?null:d.jsx(QC,{item:J,n:pe,onRemove:de},J.key)})})}),Z=(J,pe)=>{const de=pe===S,ie=N[pe],ye=aN(ie,!!J.multi),_e=$e=>({ref:de?M:void 0,value:(ie==null?void 0:ie.note)??"",placeholder:$e,enterKeyHint:Dc(p)===-1?"send":"next",onChange:Ze=>P(iN(N,pe,Ze),pe),...Dc(p)===-1?{onSend:ue}:{}}),be=J.options.map($e=>{const Ze=!!(ie!=null&&ie.selected.includes($e.value));return{label:d.jsxs(d.Fragment,{children:[ey($e.label),Sz($e.label)&&d.jsx("span",{className:"badge-recommended",children:"recommended"})]}),description:$e.description,sample:$e.preview,hint:J.note&&!J.multi?{k:"n",label:"add a note",icon:"edit",on:(ie==null?void 0:ie.note)===void 0}:void 0,checked:Ze,field:Ze&&!ye&&(ie==null?void 0:ie.note)!==void 0?_e("a note for the agent, sent with your pick"):void 0}});return J.note&&be.push({label:J.note.label,description:ye?void 0:"your own answer",checked:ye,field:ye?_e("your own answer"):void 0}),d.jsxs("div",{className:We("card-page",!de&&"card-page-off"),children:[d.jsx(Gu,{children:J.text||h}),de&&Be,d.jsx(sl,{rows:be,cursor:de?A:void 0,onCursor:$e=>{I($e),Ah(r)},onPick:$e=>{var Ze;U($e),(Ze=r.current)==null||Ze.focus()},onHint:K}),De(J,ie)]},J.id)};return d.jsxs(Ih,{root:r,id:e.id,onKeyDown:he,onKeyUp:w.onPasteKeyUp,onPaste:w.onPaste,children:[p.length>1&&d.jsx("div",{className:"card-tabs",children:d.jsx(Ya,{label:"questions",owner:"ask",items:[...p.map((J,pe)=>({id:String(pe),label:J.header||`question ${pe+1}`,lead:d.jsx("span",{className:We("dot card-step",Ra(N[pe])&&"answered")})})),{id:String(p.length),label:"send",far:!0}],current:String(S),onPick:J=>{var pe;V(Number(J)),(pe=r.current)==null||pe.focus()}})}),d.jsxs("div",{className:"card-pages",children:[p.map(Z),Dc(p)!==-1&&d.jsxs("div",{className:We("card-page",!T&&"card-page-off"),children:[d.jsx(Gu,{children:"Send these answers?"}),T&&Be,d.jsx(sl,{hover:!0,rows:p.map((J,pe)=>{const de=Ra(N[pe])?lN(J,N[pe]):void 0;return{label:d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"row-dim",children:J.header||`question ${pe+1}`})," ",d.jsx("span",{className:We(!de&&"row-dim"),children:de?de.pick:"no answer yet"})]}),description:de==null?void 0:de.note}}),onPick:J=>{var pe;V(J),(pe=r.current)==null||pe.focus()}}),De()]})]})]})}const Kq=KT("top"),qq=5*6e4;function sA({usage:e,limits:t,auth:n,now:r}){const o=t?X8(t,r):[],s=o.length?H8(n):void 0,a=t&&r-t.at>qq?cy(r-t.at):null,l=(e==null?void 0:e.cost)!==void 0?` · ${sd(e.cost)}`:"";return d.jsxs("div",{className:"usage-figures",children:[e&&d.jsx(ZE,{name:"context",used:e.used/e.size,sub:`${b1(e.used)} of ${b1(e.size)}${l}`}),s&&d.jsx("div",{className:"usage-who section-title",children:s}),o.map(u=>d.jsx(ZE,{name:u.name,used:u.used,sub:u.sub},u.key)),a&&d.jsxs("div",{className:"usage-stale hint",children:["read ",a," ago"]})]})}function Zq({onClose:e,...t}){return d.jsx(Qs,{className:"usage-panel",anchor:"parent",placement:Kq,onDismiss:e,onKey:n=>{n.key==="Escape"&&(n.stopPropagation(),e())},children:d.jsx(sA,{...t})})}function ZE({name:e,used:t,sub:n}){const r=Math.max(0,Math.min(1,t));return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"usage-row",children:[d.jsx("span",{className:"usage-name",children:e}),d.jsx("span",{className:"meter",children:d.jsx("span",{className:"meter-fill",style:{"--meter":r}})}),d.jsxs("span",{className:"usage-fig",children:[Math.round(100*t),"%"]})]}),d.jsx("div",{className:"usage-sub hint",children:n})]})}function iA(e,t,n){const r=E.useRef(n);r.current=n,ct([e,t,n==null?void 0:n.id],()=>{if(!e||!t)return;const o=()=>{const s=r.current;s!=null&&s.available&&e.send({t:"agent-check",agent:s.id})};return o(),window.addEventListener("focus",o),()=>window.removeEventListener("focus",o)})}const GE="not answering; send once Toyon is back",VE=[],Gq=[],Vq=new Set(["ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),Yq=150,Xq=3,YE=e=>({kind:"cmd",c:e});function Qq(e,t,n){var r;return((r=n.find(o=>o.proposalId===e.proposalId&&o.pieceId===t))==null?void 0:r.title)??"another piece"}function Jq(e,t,n,r,o){return e==="command"?r?n===0?d.jsx("span",{className:"live-text",children:"starting the agent to see what it offers"}):"no matching command":"no session has run this agent yet, so it has offered no commands":o?"no worktree by that name; files can be named once this one runs here":t?"no matches":d.jsx("span",{className:"live-text",children:"listing files"})}function eZ(e){return e.kind==="cmd"?`/${e.c.name} `:e.kind==="folder"?`@${e.path}/ `:e.kind==="worktree"?`@${e.title} `:e.kind==="changes"?"@changes ":`@${e.path} `}function Su({active:e,draft:t,archived:n,found:r,project:o,greenfield:s,placement:a="dock"}){var Il,ac,jd,$d,js,cc,ui,lc,Rl,ia,$s;const l=a==="screen",u=ht(),f=nt(),h=Pn(),p=!!t,g=(e==null?void 0:e.worktree.id)??null,y=e==null?void 0:e.worktree.repoId,w=o?el:n?n.id:r?r.id:qa(e),v=!!n||!!r,x=n?n.restorable:!!r&&!r.locked,N=Rt(w,"draft"),S=Rt(w,"attachments"),T=Rt(w,"notice"),j=Object.entries((e==null?void 0:e.worktree.sources)??{}).filter(([,z])=>Zh(z.at)).map(([z])=>z).join(","),$=E.useRef({id:g,owns:j});ct([g,j],()=>{const z=$.current;if($.current={id:g,owns:j},z.id!==g||z.owns===j||!j||!w||n)return;const Re=new Set(z.owns.split(",").filter(Boolean)),dt=Uq(j.split(",").filter(St=>!Re.has(St)),e==null?void 0:e.worktree.sources);dt&&u({a:"notice",id:w,text:dt})});const R=Rt(w,"mark"),A=(R==null?void 0:R.by)==="walk"?R:void 0,I=Rt(g,"chat"),M=Rt(g,"queue"),P=E.useMemo(()=>g&&!p?Ry(I):null,[g,p,I]),F=Rt(g,"cardParked"),q=Rt(g,"sending"),W=E.useMemo(()=>g&&!p&&!q?sN(I):null,[g,p,q,I]),ee=Rt(g,"askRevived"),V=!P&&W&&ee===W.id?W:null,te=P&&F!==P.id?P:V,K=V?Hc(V.id):null,C=Rt(K,"attachments"),oe=P?F===P.id?P:null:W&&!V?W:null,U=E.useRef(null),B=Ys(),Q=Sy(),ue=Rt(Q,"page"),he=ed(),Ne=M6(),De=jC(),Be=CK(),Z=L(z=>z.globalInstall),J=!!De&&!!g&&!p&&!te&&AK({prompt:De,offered:Be,agent:e==null?void 0:e.agent,chat:I}),pe=Lq(),de=E.useMemo(()=>g&&!p?Rq(I,{queued:M.length,sending:!!q,card:!!(te||oe),dismissed:pe}):null,[g,p,I,M.length,q,te,oe,pe]),ie=z=>w&&u({a:"set-draft",id:w,text:z}),ye=L(z=>z.clientId),_e=L(z=>z.repos),be=L(z=>z.repos.find(Re=>Re.id===(e==null?void 0:e.worktree.repoId))??null),$e=L(z=>z.defaultAgent),Ze=L(z=>z.agentChosen),rt=p||!!s||!!o,en=!rt&&!!e&&!e.worktree.agent,Xt=rt||en,Et=(t==null?void 0:t.agent)??$e,Ke=L(z=>z.agents.find(Re=>Re.id===(Xt?Et:e==null?void 0:e.worktree.agent)));iA(f,g??(rt?"new":null),Ke);const Qt=!!(Ke!=null&&Ke.quick),Ot=(Ke==null?void 0:Ke.models)??VE,Zt=(Ke==null?void 0:Ke.efforts)??VE,Ge=Ke==null?void 0:Ke.defaultModel,nn=Ke==null?void 0:Ke.defaultEffort,pn=((Il=Ke==null?void 0:Ke.picks)==null?void 0:Il.model)??"",It=((ac=Ke==null?void 0:Ke.picks)==null?void 0:ac.effort)??"",gt=(z,Re,dt)=>f==null?void 0:f.send({t:"set-agent-pick",agent:z,field:Re,value:dt}),Vt=z=>gt(Et,"model",z),Cn=z=>gt(Et,"effort",z),Ce=L(z=>z.agents),Pt=(z,Re)=>{gt(z,"model",Re),z!==Et&&Dt(z)},Dt=z=>{p?u({a:"draft-agent",id:z}):f==null||f.send({t:"set-default-agent",agent:z})},Wt=Sq(Ke,Ce,Xt),Dn=Wt==null?void 0:Wt.other,ne=Rt(g,"model"),we=Rt(g,"effort"),Ye=Rt(g,"usage")??(e==null?void 0:e.usage),ot=((jd=be==null?void 0:be.picks)==null?void 0:jd.mode)??ok,zt=z=>{be&&(f==null||f.send({t:"set-repo-pick",repoId:be.id,field:"mode",value:z}))},Kt=(e==null?void 0:e.worktree.mode)??ok,D=L(z=>z.picking),se=L(z=>z.layout.term),Se=gN((e==null?void 0:e.procs)??[]),ze=xn("composer"),Ut=Rt(g,"files"),qt=E.useMemo(()=>yN(Ut??Gq),[Ut]),Oe=L(z=>z.visible),Fe=L(z=>z.shipping),et=y??(n==null?void 0:n.repoId)??(r==null?void 0:r.repoId),Ft=E.useMemo(()=>Pp(Oe,et,g,Fe),[Oe,et,g,Fe]),jt=L(z=>et?z.archived[et]:void 0),On=E.useMemo(()=>B$(Ft,jt),[Ft,jt]),Mn=E.useMemo(()=>F$(Ut,On),[Ut,On]),yn=E.useMemo(()=>[...Ft,...(jt??[]).map(z=>({title:z.title,branch:z.branch,dir:z.path.slice(z.path.lastIndexOf("/")+1)}))],[Ft,jt]),tn=Rt(g,"git"),_n=(tn==null?void 0:tn.files.length)??(e==null?void 0:e.dirty)??0,Mt=(tn==null?void 0:tn.unpushed)??(e==null?void 0:e.unpushed)??0,mn=L(z=>{var Re;return g?(Re=z.shipping[g])==null?void 0:Re.op:void 0}),rr=L(z=>{var Re;return g?(Re=z.shipping[g])==null?void 0:Re.step:void 0}),Ct=L(z=>Hi(z,y)),le=L(z=>{var Re;return Ct?(Re=z.shipping[Ct.id])==null?void 0:Re.op:void 0}),qe=Ct&&be&&rt?dN(be.defaultBranch,Ct):null,Xe=L(z=>p?Lz(z.rows,y,Et,$e):g),pt=Rt(Xe,"commands"),wt=pt.some(z=>z.name==="compact"),En=is(e==null?void 0:e.agent),Lr=L(z=>NN(z,g)),un=En&&!!g&&!p,vr=e==null?void 0:e.worktree.lastTurn,Qn=!N.trim()&&S.length===0,Bt=!p&&!s&&Qn&&!En?vr:void 0,dn=!p&&!s&&e&&Na(e.worktree)?e.worktree.landing:void 0,ve=!!(dn!=null&&dn.ready)&&!dn.stale&&!Af(dn,_n,Qt,Ke==null?void 0:Ke.name),Le=Qn&&(!En||ve)?dn:void 0,At=_n>0&&!!(Le!=null&&Le.subject),yt=_n||((($d=tn==null?void 0:tn.extras)==null?void 0:$d.committed.length)??0),rn=!p&&!s&&Qn&&!En&&!!e,Gt=!!(e!=null&&e.worktree.landed)&&_n===0,Jn=rn&&Gt,Zr=e?Ow(e.worktree,_n):void 0,hn=Zr?Yh(Zr):void 0,Yt=rn&&!Jn?hn:void 0,zn=!Gt&&(hn==null?void 0:hn.state)==="open"?hn:void 0,or=!!zn&&(_n>0||Mt>0),br=(hn==null?void 0:hn.state)==="closed",pr=Ri((be==null?void 0:be.config)??{}),Gr=E.useMemo(()=>Dq(sh(Ri((be==null?void 0:be.config)??{}),be==null?void 0:be.defaultBranch)),[be]),ro=()=>g&&(f==null?void 0:f.send({t:"chat",worktreeId:g,text:"/compact"})),Ro=rt?"nothing to compact until the first reply":wt?En?"wait for the turn to end":void 0:"this agent offers no compact command",$r=wt&&Ye?K8(Ye.used/Ye.size):void 0,G=Ke==null?void 0:Ke.limits,me=rt?void 0:Ye,Je=(!!g||rt)&&!!(me||G),Ve=Date.now(),[He,bn]=E.useState(!1),an=E.useRef(0),cn=B?()=>d.jsx(sA,{usage:me,limits:G,auth:Ke==null?void 0:Ke.auth,now:Date.now()}):void 0,sr=()=>{window.clearTimeout(an.current),bn(!1)};ct([g],sr);const mr=_y(),Te=(mr==null?void 0:mr.owner)==="composer"&&mr.key==="usage";ct([Te],()=>{Te&&sr()});const H=()=>[{id:"compact",label:"compact the context",detail:Ro||!Ye?void 0:W8(Ye.used/Ye.size),disabled:Ro,onClick:ro}],[Y,ce]=E.useState(0),[xe,Ie]=E.useState(null),Qe=E.useRef(null),$t=w&&!o?Hg(N,Y,z=>Ft.some(Re=>NE(z,Re))):null,ut=v&&($t==null?void 0:$t.kind)==="command"?null:$t,Zn=ut==null?void 0:ut.kind,Sn=ut==null?void 0:ut.query,ei=E.useMemo(()=>{if(Sn===void 0)return[];if(Zn==="command")return Sn.trim()?rH(WE(Gr,pt),Sn).slice(0,8).map(YE):KE(Gr,pt).rows.map(YE);const z=[],Re=(tn==null?void 0:tn.files.length)??0;Re>0&&"changes".startsWith(Sn.toLowerCase())&&z.push({kind:"changes",n:Re});const dt=Sn.trim(),St=dt?Ft.filter(er=>NE(dt,er)):Ft.slice(0,Xq);return z.push(...St.map(er=>({kind:"worktree",...er}))),z.push(...wq(Ut??[],qt,(tn==null?void 0:tn.files)??[],Sn,8)),z},[Zn,Sn,Ut,qt,tn,pt,Gr,Ft]),Hn=ut!==null&&ut.from!==xe&&!A&&!(ut.kind==="file"&&eH(N,ut.from,Mn)),Zi=Zn==="command"&&Sn!==void 0&&!Sn.trim()?KE(Gr,pt).more:0,oo=E.useRef(null),ud=E.useRef(null),Ss=E.useRef(null),ti=(z,Re,dt,St)=>{var di;const{text:er,caret:tr}=_T(N.slice(0,Re)+N.slice(dt),Re,St);ie(er),Ie(((di=Hg(er,tr))==null?void 0:di.from)??null),requestAnimationFrame(()=>{z.focus(),z.setSelectionRange(tr,tr),ce(tr)})},_s=z=>{const Re=oo.current;return!z||!Re?!1:(ti(Re,Re.selectionStart,Re.selectionEnd,z),!0)},{onPaste:Qa,onPasteKey:Wp,onPasteKeyUp:Kp}=zT(w,g,z=>_s(hC(z,yn)));eF(ud,oo,z=>_s(jW(z,yn)));const ni=()=>{var z;return(z=U.current??oo.current)==null?void 0:z.focus()},vo=ni;ct([s?e==null?void 0:e.worktree.id:null],()=>{if(!s)return;const z=requestAnimationFrame(()=>{var dt;const Re=document.activeElement;(!Re||Re===document.body)&&((dt=oo.current)==null||dt.focus())});return()=>cancelAnimationFrame(z)});const ri=L(z=>z.focusChat),gl=E.useRef(ri),bo=!!uT();ct([ri],()=>{if(ri===gl.current||(gl.current=ri,bo!==!!s))return;const z=requestAnimationFrame(ni);return()=>cancelAnimationFrame(z)});const oi=te==null?void 0:te.id,Gi=E.useRef({id:g,cardUpId:oi});ct([g,oi],()=>{const z=Gi.current;if(Gi.current={id:g,cardUpId:oi},oi||!z.cardUpId||z.id!==g||bo!==!!s||B&&!oe)return;const Re=requestAnimationFrame(()=>{var St;const dt=document.activeElement;(!dt||dt===document.body)&&((St=oo.current)==null||St.focus())});return()=>cancelAnimationFrame(Re)});const Vi=L(z=>z.walked),Yi=E.useRef(Vi);ct([Vi],()=>{if(Vi===Yi.current||(Yi.current=Vi,bo!==!!s))return;const z=requestAnimationFrame(()=>{const Re=document.activeElement;(!Re||Re===document.body||Re.closest(".rail"))&&ni()});return()=>cancelAnimationFrame(z)});const si=VT({results:ei,keyOf:z=>z.kind==="cmd"?`c:${z.c.name}`:z.kind==="changes"?"changes":z.kind==="worktree"?`w:${z.id}`:`f:${z.path}`,q:(ut==null?void 0:ut.query)??"",listRef:Qe,tabPicks:!0,onPick:z=>{if(!ut)return;const{text:Re,caret:dt}=nH(N,ut,eZ(z));ie(Re),Ie(ut.from),requestAnimationFrame(()=>{const St=oo.current;St&&(St.focus(),St.setSelectionRange(dt,dt),ce(dt))})}}),Cr=g||v?GW(N):null,Vr=E.useMemo(()=>WE(Gr,pt),[Gr,pt]),ii=Fq(N,Vr),kl=Cr===""&&e?p?" a command to run in the new worktree's terminal":` a command to run in ${e.worktree.title}; the agent sees its output with your next message`:null,Ns=ii??kl,wl=(e==null?void 0:e.worktree.title)??"untitled",cs=(js=vr==null?void 0:vr.recap)==null?void 0:js.text,Xi=()=>{g&&Li(f,u,{t:"land",worktreeId:g})},ai=z=>{g&&(f==null||f.send({t:"judge",worktreeId:g,...z?{note:z}:{}}))},Ja=!!((cc=be==null?void 0:be.config.check)!=null&&cc.trim()),dd=By(dn,_n,Qt),qp=rn&&!mn&&!rt&&Na(e.worktree)&&!Gt&&!br&&yt>0&&(!dn||!!dn.stale),fd="Archive this worktree when you are done here; the rail's archived section brings it back with its chat.",Zp=or?"update":Mw(pr,Zr??{}),ec=be?Vh(be):"main",Gp=or&&zn?`Commit, take ${ec} in and push the branch; PR #${zn.number} takes the new commits.`:`${sh(pr,be==null?void 0:be.defaultBranch)}.`,hd=Yt&&!cs?{links:d8(Yt)}:{},Pr=g?Jn?{word:"archive",kind:"archive",line:(hn==null?void 0:hn.state)==="merged"?zs(hn):`landed on ${(be==null?void 0:be.defaultBranch)??"main"}.`,tip:fd,run:()=>Gc(f,u,[g])}:(Yt==null?void 0:Yt.state)==="open"&&!or?yj(Yt)?{word:"land",kind:"merge",line:If(cs??zs(Yt)),tip:`${zs(Yt)} ${wj(Yt)}.`,...hd,run:Xi,ships:!0}:{word:"view",kind:"view",line:If(cs??zs(Yt)),tip:`${zs(Yt)} Open the PR on GitHub.`,...hd,run:()=>Rr(Yt.url)}:(Yt==null?void 0:Yt.state)==="closed"?{word:"archive",kind:"archive",line:zs(Yt),tip:`${zs(Yt)} ${fd}`,run:()=>Gc(f,u,[g])}:qp?{word:"check",kind:"check",line:(dn==null?void 0:dn.subject)??If(cs??k8(yt)),tip:vj(dn,Ja),run:ai}:Le!=null&&Le.ready&&!Af(Le,_n,Qt,Ke==null?void 0:Ke.name)?{word:Zp,kind:"ship",line:Le.subject??If(cs??(d1(Le,yt)||"ready")),tip:[d1(Le,yt),g8(ec,e==null?void 0:e.behind),Gp,Le.subject&&_n>0?"Tab from the word edits the message first.":"",dd==="unanswered"?h8:""].filter(Boolean).join(" "),run:Xi,ships:!0}:null:null,pd=(ui=e==null?void 0:e.worktree.lands)==null?void 0:ui.at(-1),md=pd&&Dy(pd),Qi=E.useMemo(()=>{const z=I?f5(I):null;return(z?$5(z):[]).filter(Re=>{const dt=Oe.find(St=>St.worktree.id===Re.id);return!!dt&&!dt.worktree.landed})},[I,Oe]),Vp=Qi.length>0?d.jsxs(d.Fragment,{children:["After"," ",Qi.map((z,Re)=>d.jsxs(E.Fragment,{children:[Re>0&&(Re===Qi.length-1?" and ":", "),d.jsx(to,{id:z.id,title:z.title})]},z.id))," ",Qi.length===1?"lands":"land","."]}):null,yl=((Pr==null?void 0:Pr.kind)==="ship"||(Pr==null?void 0:Pr.kind)==="check")&&Le?Vp??w8(Le):(Pr==null?void 0:Pr.word)==="archive"&&md?no(md):null,vl=E.useRef(null);mn!=="land"&&(vl.current=g&&(Pr!=null&&Pr.ships)?{id:g,verb:Pr,under:yl}:null);const tc=mn==="land"&&Qn&&((lc=vl.current)==null?void 0:lc.id)===g?vl.current:null,An=tc?tc.verb:Pr,gd=(Rl=An==null?void 0:An.links)!=null&&Rl.length?f8(An.line,An.links):null,nc=!!(An!=null&&An.ships)&&mn==="land",bl=yy(rr,vy),Ji=zu(e,"commit"),rc=zu(e,"check"),ci=xj(nc?Ji:rc),kd=Mi(Hy(ci)?ci==null?void 0:ci.since:void 0),xl=Le?Le.check==="pending"&&rc&&ci===rc?vh("Checking the work",rc,kd):Af(Le,_n,Qt,Ke==null?void 0:Ke.name):null,El=An&&nc?bl?`${An.word}: ${bl}`:`${An.word} ${An.line}`:null,wd=El&&Ji&&ci===Ji?vh(El,Ji,kd):El,oc=n?n.restorable?`message agent on ${n.title}; sending restores it first`:"its commits were not kept, so it cannot come back":r?r.locked?`held by ${r.lockReason??"another tool"}; Toyon takes it over once the lock goes`:`message agent on ${r.name}; sending takes it over first`:o?`describe ${o.name||"the app"}; return makes it`:e?An?"":xl||(Yt?zs(Yt):Bt?Uy(Bt):s?`describe ${wl}…`:rt?"describe a change":l?`message agent on ${wl}`:`message agent on ${wl}; / for a command, ! for a shell command`):"no worktree selected",ls=N!==""||Ns||!e?null:nc?bl?null:tc?tc.under:yl:An?yl:Yt||xl?cs??(Le==null?void 0:Le.subject)??null:null,yd=E.useRef(!1);E.useEffect(()=>{const z=Hn&&!yd.current;yd.current=Hn,z&&((ut==null?void 0:ut.kind)==="file"&&g?yp(g,h.getState(),{sock:f,dispatch:u}):(ut==null?void 0:ut.kind)==="command"&&Xe&&pt.length===0&&(f==null||f.send({t:"list-commands",worktreeId:Xe})))},[Hn,ut==null?void 0:ut.kind,pt.length,g,Xe,f,h,u]);const Sl=()=>{if(!e)return;const z=[],Re=ue;if(Re.url)try{const er=new URL(Re.url);z.push(`current route: ${er.pathname}${er.search}`)}catch{}Re.title&&z.push(`page title: ${Re.title}`);const dt=[];s&&dt.push(MK(e.worktree.title,be==null?void 0:be.configFile)),z.length>0&&dt.push(`What the user is looking at right now:
262
- ${z.join(`
263
- `)}`);const St=YW(I);return St&&dt.push(St),dt.length>0?dt:void 0},_l=z=>{rt?zt(z):g&&z!==Kt&&(f==null||f.send({t:"set-worktree-mode",worktreeId:g,mode:z}))},cr=z=>w&&u({a:"notice",id:w,text:z}),ea=aT(),vd=(z,Re="")=>{if(!e||!g)return;if(z==="handoff"){if(rt)return cr("a new worktree has nothing to continue yet");const St=zq(Re,_e,e.worktree.repoId);"pick"in St?u({a:"open",overlay:{kind:"handoff",worktreeId:g}}):f==null||f.send({t:"handoff-ask",worktreeId:g,repoId:St.repo.id,...St.text?{text:St.text}:{}});return}if(z==="archive"){Gt||br?Gc(f,u,[g]):cr("archive is for a landed worktree; this one has not landed");return}if(z==="check"){rt||!Na(e.worktree)?cr("nothing to check from here"):En?cr("wait for the turn to end"):yt===0?cr("nothing to check: no changes here"):ai(Re||void 0);return}const dt=dn?Af(dn,_n,Qt,Ke==null?void 0:Ke.name):null;rt||!Na(e.worktree)?cr("nothing to land from here"):Gt?cr(`already landed on ${(be==null?void 0:be.defaultBranch)??"main"}`):dt?cr(dt):En&&(!dn||dn.stale)?cr("wait for the turn to end"):dn!=null&&dn.stale?cr("the work changed since this was checked; check again first"):Xi()},Zo=S.some(Fi),bd=()=>{var z;B&&((z=oo.current)==null||z.blur())},ta=()=>{w&&(f==null||f.send({t:"set-draft",boxId:w,text:N,clientId:ye})),bd()},na=(z,Re,dt,St)=>{u({a:"hold-send",id:z,log:Re,text:dt,frame:St}),bd()},sc=()=>{if(!w)return;const z=Bq(N,Gr),Re=z&&Pq(z.name)?z.name:void 0;if(o){if(o.busy)return;if(ea)return cr(GE);if(o.why)return cr(o.why);(Et!==$e||!Ze)&&(f==null||f.send({t:"set-default-agent",agent:Et})),ta(),o.create();return}if(Qn)return;if(ea&&!(Re&&!(z!=null&&z.args)))return cr(GE);const dt=Cr===null&&(!z||!!Re&&!!z.args);if(Wt&&Wt.kind!=="unready"&&Ke&&dt){cr(Wt.kind==="installing"?`${Ke.name} is still installing`:Wt.retry?`nothing runs here until ${Ke.name} is installed`:Wt.text);return}const St=gE(N.trim(),Mn),er=()=>({text:St,attachments:S.length?S.map(Kc):void 0});if(n){if(!n.restorable)return;if(Cr!==null){cr("nothing runs here until it is restored");return}const xo={t:"restore-worktree",archiveId:n.id,clientId:ye};if(Zo)return na(w,w,St,xo);ta(),f==null||f.send(fu(xo,w,St,S)),u({a:"sending",id:w,message:er()}),u({a:"sent-box",id:w});return}if(r){if(r.locked)return;if(Cr!==null){cr("nothing runs here until Toyon takes it over; its menu on the rail opens a shell");return}const xo={t:"adopt-worktree",worktreeId:r.id,clientId:ye};if(Zo)return na(w,w,St,xo);ta(),f==null||f.send(fu(xo,w,St,S)),u({a:"sending",id:w,message:er()}),u({a:"sent-box",id:w});return}if(!e||!g)return;if(Cr!==null){if(Cr&&mn&&!p){cr(`${XR(mn)} is running here; run the command once it is done`);return}Cr&&p?u({a:"term-run",id:g,command:Cr}):Cr&&(f==null||f.send({t:"exec",worktreeId:g,command:Cr})),ie("");return}if(z&&!Re){vd(z.name,z.args),ie("");return}if(Re&&!(z!=null&&z.args)){_l(Re),ie("");return}const tr=z?gE(z.args,Mn):St,di=Sl(),Ol=S.length?S.map(Kc):void 0;if(Re&&_l(Re),rt){const xo=Wh(e.worktree)?{worktreeId:g}:{},ds={clientId:ye,repoId:e.worktree.repoId,context:di,agent:Et,...Re?{mode:Re}:{},...t!=null&&t.carry?{carry:!0}:{}};(Et!==$e||!Ze)&&(f==null||f.send({t:"set-default-agent",agent:Et}));const uc={t:"create-worktree",...ds,...xo};Zo?na(w,w,tr,uc):(ta(),f==null||f.send(fu(uc,w,tr,S)),u({a:"sending",id:w,message:{text:tr,attachments:Ol}}),u({a:"sent-box",id:w}))}else{const xo={t:"chat",worktreeId:g,clientId:ye,context:di};Zo?na(w,g,tr,xo):(ta(),f==null||f.send(fu(xo,w,tr,S)),Lr||u({a:"sending",id:g,message:{text:tr,attachments:Ol}}),u({a:"sent-box",id:w}))}s&&u({a:"show-chat"})},xd=z=>{if(!g||(V==null?void 0:V.ask.kind)!=="question")return;if(!z.some(Ra))return u({a:"ask-revive",id:g});const Re=Jw(V.ask.questions,z).join(`
264
- `),dt={t:"chat",worktreeId:g,clientId:ye,context:Sl()};if(K&&C.some(Fi))na(K,g,Re,dt);else{const St=C.length?C.map(Kc):void 0,er=St&&K?{attachments:St,boxId:K}:{};f==null||f.send({...dt,text:Re,...er}),St&&K&&u({a:"clear-attachments",id:K}),u({a:"sending",id:g,message:{text:Re,attachments:St}})}u({a:"answered",id:g}),u({a:"ask-revive",id:g})},Ts=L(z=>z.autoSend);ct([Ts,g],()=>{!Ts||Ts!==g||Qn||bo!==!!s||(u({a:"auto-sent"}),sc())});const ra=()=>{const z=S[S.length-1];return!w||!z?!1:(u({a:"detach",id:w,key:z.key}),!0)},Ed=z=>{w&&(u({a:"walk",id:w,walk:z.walk,text:z.text}),requestAnimationFrame(()=>{var Re;(Re=oo.current)==null||Re.setSelectionRange(z.text.length,z.text.length),ce(z.text.length)}))},oa=()=>{w&&A&&u({a:"walk",id:w,walk:null,text:N})},Sd=rt?[]:xN(I),Nl=rt?[]:M.flatMap(z=>z.attachments??[]),so=e==null?void 0:e.worktree.plan,Tl=vv(e==null?void 0:e.worktree.id,so),us=((ia=e==null?void 0:e.worktree.from)==null?void 0:ia.kind)==="worktree"?e.worktree.from:null,sa=us?I.find(z=>z.kind==="handed"&&z.via==="plan"):void 0,_d=(sa==null?void 0:sa.kind)==="handed"?sa.origin.title:us==null?void 0:us.ref,ic=zn&&(($s=e==null?void 0:e.worktree.prComments)==null?void 0:$s.pr)===zn.number?e.worktree.prComments:void 0,jl=ic&&ic.count>0?OC(ic.count,ic.authors):null,$l=(e==null?void 0:e.worktree.queued)??[],Nd=un&&!te,Yp=L(z=>z.reading),[Yr,li]=E.useState(!1),Cl=l&&!oe&&(te?!Yr:Qn&&!Ne),Al=Cl&&Yp;E.useEffect(()=>{if(l)return u({a:"typing",on:Yr}),()=>u({a:"typing",on:!1})},[l,Yr,u]);const Td=z=>{if(!Al||z.target instanceof Element&&z.target.closest("button, a, [role=button]"))return;const Re=z.currentTarget.closest(".chat-log");Re&&(Re.scrollTop=Re.scrollHeight)};return d.jsxs("div",{ref:ud,className:We("composer chat-input",Nd&&"stopping",Cl&&"foldable",Al&&"lean"),onClick:Td,onFocus:z=>li(z.target instanceof HTMLTextAreaElement),onBlur:()=>li(!1),children:[(so||us)&&e&&d.jsxs("div",{className:"composer-plan",...so?ze.contextMenu(()=>Jy(so,()=>f==null?void 0:f.send({t:"reveal",worktreeId:e.worktree.id,path:so}),wo(f))):{},children:[d.jsx(xt,{name:so?"text":"handoff",className:"icon-inline"}),so&&d.jsx(Me,{variant:"inline",className:"composer-plan-path","data-tip":so,onClick:()=>Rn({dispatch:u},{worktreeId:e.worktree.id,path:so,view:"preview"}),children:Tl}),us&&d.jsxs("span",{className:"composer-plan-from",children:[so?" from ":"from ",d.jsx(to,{id:us.origin.id,title:_d})]})]}),zn&&jl&&e&&d.jsxs("div",{className:"composer-plan",children:[d.jsx(xt,{name:"pr",className:"icon-inline"}),d.jsx(Me,{variant:"inline",tone:"strong","data-tip":"Read them beside the chat",onClick:()=>X6({dispatch:u},e.worktree.id,zn.number),children:jl.count}),d.jsxs("span",{className:"row-dim",children:[" on PR #",zn.number,jl.rest,zn.review==="changes_requested"?", changes requested":zn.review==="approved"?", approved":""]})]}),oe&&g&&d.jsx(Us,{icon:"chat",verb:"answer",tip:"Bring the question back into the box",onPress:()=>{u(oe.kind==="ask"&&oe.outcome?{a:"ask-revive",id:g,askId:oe.id}:{a:"card-unpark",id:g}),u({a:"focus-chat"})},children:A5(oe)}),(de==null?void 0:de.verb)==="fix"&&"toolId"in de&&g&&d.jsxs(Us,{icon:"run",verb:de.verb,tip:"Send the agent what it printed and ask for a fix",onPress:()=>f==null?void 0:f.send({t:"fix",worktreeId:g,toolId:de.toolId}),onDismiss:()=>HE(de.key),children:["what failed in ",d.jsx("code",{children:de.command})]}),(de==null?void 0:de.verb)==="continue"&&g&&d.jsx(Us,{icon:"send",verb:de.verb,tip:de.after==="stop"?"Send the agent on from where its turn stopped":de.again?"The last press ended in this same error. Send the agent on once more, or wait it out.":"Send the agent on from where its turn failed",onPress:()=>f==null?void 0:f.send({t:"continue",worktreeId:g}),onDismiss:()=>HE(de.key),children:de.after==="stop"?"where it stopped":de.again?"after the same error again":"after the error"}),Ne&&w&&!te&&(e||x||o)&&d.jsx(Us,{icon:"copy",verb:"attach",tip:"Attach it, as a paste would",onPress:()=>{q5(h,w,Ne),ni()},onDismiss:dT,children:Ne.kind==="image"?"the image you copied":`the text you copied, ${Ne.text.split(`
265
- `).length} lines`}),J&&d.jsx(Us,{icon:"download",verb:"install",tip:"Install Toyon as an app: a window of its own, with a Dock icon and no browser bar",onPress:()=>{OE(),De==null||De.prompt()},onDismiss:OE,children:"Toyon as a window of its own, with a Dock icon and no browser bar"}),Z&&g&&!p&&!te&&!J&&wp(wo(f))&&_K({offer:Z,agent:e==null?void 0:e.agent,chat:I})&&d.jsx(Nq,{offer:Z,onInstall:()=>f==null?void 0:f.send({t:"install-global"}),onDismiss:()=>f==null?void 0:f.send({t:"dismiss-global-install"})}),w&&!te&&Cr===null&&d.jsx(_p,{children:Iw(S,wu(sk(Sd),Nl)).map(([z,Re])=>{const dt=()=>u({a:"detach",id:w,key:z.key});return z.kind!=="pick"?d.jsx(QC,{item:z,n:Re,onRemove:dt},z.key):d.jsx(zp,{pick:z,tipText:z.html,onHover:St=>Q&&fn.post(Q,St?{type:"highlight-selector",selector:z.selector,label:ay(z)}:{type:"highlight-clear"}),worktreeId:g,onOpen:(St,er)=>g&&Ma(h,f,g,St,er),onRemove:dt},z.key)})}),Hn&&ut&&d.jsx(RK,{results:ei,keyOf:z=>z.kind==="cmd"?`c:${z.c.name}`:z.kind==="changes"?"changes":z.kind==="worktree"?`w:${z.id}`:z.kind==="folder"?`d:${z.path}`:`f:${z.path}`,rowClass:z=>z.kind==="file"||z.kind==="folder"?"qo-file":z.kind==="changes"||z.kind==="worktree"?"picker-row":"picker-row picker-cmd",nav:si,listRef:Qe,empty:Jq(ut.kind,Ut,pt.length,Xe!==null,v),note:Zi>0?`type to find ${Zi} more`:void 0,groupOf:z=>z.kind==="worktree"?"worktrees":z.kind==="cmd"?"commands":"files",row:z=>{const Re=((tn==null?void 0:tn.files.length)??0)>0;return z.kind==="file"?dw(z.path,z.status,ut.query,{gutter:Re}):z.kind==="folder"?dw(z.path,void 0,ut.query,{folder:!0,gutter:Re}):z.kind==="changes"?d.jsx(In,{label:"@changes",hint:`${z.n} uncommitted ${z.n===1?"file":"files"}`}):z.kind==="worktree"?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:`dot ${z.dot}`}),d.jsx(In,{label:z.title,hint:dr(z.at)})]}):d.jsx(qK,{c:z.c,query:ut.query})}}),te&&g?te.kind==="handoff"?d.jsx(Iq,{item:te,worktreeId:g,rootRef:U},te.id):te.ask.kind==="question"?d.jsx(Wq,{item:te,ask:te.ask,worktreeId:g,rootRef:U,numbers:wu(sk(Sd),Nl),onAnswer:V?xd:void 0},te.id):d.jsx(Hq,{item:te,ask:te.ask,worktreeId:g,rootRef:U},te.id):d.jsxs("div",{className:We("composer-field",Cr!==null&&"shell",A&&"recalled"),children:[d.jsx(Du,{size:"lg",bare:!0,font:Cr!==null?"mono":"ui",ref:oo,value:N,onChange:z=>{var tr;const Re=z.target.value,dt=z.target.selectionStart??Re.length;ie(Re),ce(dt),si.setIndex(0);const{inputType:St}=z.nativeEvent;Ie(St==="insertFromPaste"||St==="insertFromDrop"?((tr=Hg(Re,dt))==null?void 0:tr.from)??null:null)},onKeyUp:z=>{Kp(),ce(z.currentTarget.selectionStart??0)},onClick:z=>{ce(z.currentTarget.selectionStart??0),oa()},onPaste:Qa,onDrop:z=>{const Re=cj(h,z);if(!Re)return;z.stopPropagation();const dt=z.currentTarget,St=s8(dt,z.clientX,z.clientY)??N.length;ti(dt,St,St,Re.words)},onScroll:z=>{Ss.current&&(Ss.current.scrollTop=z.currentTarget.scrollTop)},onKeyDown:z=>{var Re;if(Wp(z),!z.nativeEvent.isComposing){if(Hn){if(z.key==="Escape"){z.preventDefault(),z.stopPropagation(),Ie((ut==null?void 0:ut.from)??null);return}if(si.onKeyDown(z))return}if((z.key==="ArrowUp"||z.key==="ArrowDown")&&!z.altKey&&!z.ctrlKey){const dt=z.key==="ArrowUp",St=M.at(-1);if(dt&&!z.metaKey&&!A&&N===""&&g&&!p&&St!==void 0){z.preventDefault(),ET(h,f,g,M.length-1);return}const er=z.metaKey?dt?"first":"box":dt?"up":"down",tr=g?mK(I,A??null,N,er):null;if(tr){z.preventDefault(),(tr.walk!==A||tr.text!==N)&&Ed(tr);return}}if(A&&z.key==="Escape"){z.preventDefault(),z.stopPropagation(),Ed({walk:null,text:A.from});return}if(z.key==="Escape"&&En&&g&&!p){z.preventDefault(),z.stopPropagation(),f==null||f.send({t:"stop-agent",worktreeId:g});return}if(A&&Vq.has(z.key)&&oa(),z.key==="Tab"&&!z.shiftKey&&N===""){const dt=(Re=z.currentTarget.closest(".composer"))==null?void 0:Re.querySelector(".composer-verb");if(dt&&!dt.disabled){z.preventDefault(),dt.focus();return}if(At){z.preventDefault(),u({a:"edit-commit"});return}}z.key==="Enter"&&(B?z.metaKey||z.ctrlKey:!z.shiftKey)?(z.preventDefault(),sc()):z.key==="Backspace"&&N===""&&ra()&&z.preventDefault()}},placeholder:ls||An?"":oc,disabled:o?o.busy:!e&&!x}),Ns&&d.jsxs("div",{className:"composer-ghost","aria-hidden":"true",children:[d.jsx("span",{className:"picker-typed",children:N}),Ns]}),(g||v)&&Cr===null&&N.includes("@")&&d.jsx("div",{ref:Ss,className:"composer-ghost composer-marks","aria-hidden":"true",onClick:z=>Zu(z,e==null?void 0:e.worktree.path,g,{sock:f,dispatch:u}),children:d.jsx(qu,{text:N,worktreeId:g??w,root:e==null?void 0:e.worktree.path,inField:!0})}),(ls||An)&&d.jsxs("div",{className:"composer-ghost composer-standing","aria-hidden":An?void 0:"true",children:[d.jsx("span",{className:We("composer-placeholder",nc&&"live-text"),children:wd||(An?d.jsxs(d.Fragment,{children:[d.jsx(Me,{variant:"inline",tone:"strong",className:"composer-verb",disabled:!!An.ships&&!!mn||ea,...Nt(An.tip,void 0,{placement:"top"}),onClick:()=>{var z;An.run(),B||(z=oo.current)==null||z.focus()},onKeyDown:z=>{z.key==="Tab"&&!z.shiftKey&&At&&(z.preventDefault(),u({a:"edit-commit"}))},children:An.word})," ",d.jsx("span",{className:"composer-verb-line",children:gd?gd.map(z=>typeof z=="string"?z:d.jsxs(Me,{variant:"inline",className:"composer-verb-tail",...Nt(z.tip,void 0,{placement:"top"}),onClick:()=>{var Re;Rr(z.url),B||(Re=oo.current)==null||Re.focus()},...ze.contextMenu(()=>[{id:"open-link",label:z.open,onClick:()=>Rr(z.url)},{id:"copy-link",label:"copy link",onClick:()=>sn(z.url)}]),children:[z.text," ",d.jsx(xt,{name:"external",className:"icon-inline"})]},z.text)):An.line})]}):oc)}),ls&&d.jsxs(d.Fragment,{children:[`
266
- `,d.jsx("span",{className:"composer-subline",children:ls})]})]}),Nd&&d.jsx(Tt,{icon:"stop",tone:"danger",className:We("composer-stop",(e==null?void 0:e.stopping)&&"pending"),label:e!=null&&e.stopping?"Stopping: the agent is winding down; press again to send the stop once more":`Stop the agent (context up to here is kept${M.length?"; queued messages go next":""})`,hint:"esc",onClick:()=>g&&(f==null?void 0:f.send({t:"stop-agent",worktreeId:g}))})]}),T&&d.jsx("div",{className:"hint composer-notice",role:"status",children:T}),!te&&d.jsxs("div",{className:"hint composer-knobs",children:[d.jsxs("span",{className:"spawn-left",children:[Xt?Ce.length>1?d.jsx(UK,{agents:Ce,agent:Et,model:pn,onChange:Pt,onClose:vo}):d.jsx(DE,{models:Ot,value:pn,runs:Ge,onChange:Vt,onClose:vo}):e&&d.jsx(DE,{models:Ot,value:e.worktree.model??"",current:ne,runs:Ge,onChange:z=>f==null?void 0:f.send({t:"set-worktree-model",worktreeId:e.worktree.id,model:z}),onClose:vo}),Xt?d.jsx(LE,{efforts:Zt,value:It,runs:nn,onChange:Cn,onClose:vo}):e&&d.jsx(LE,{efforts:Zt,value:e.worktree.effort??"",current:we,runs:nn,onChange:z=>f==null?void 0:f.send({t:"set-worktree-effort",worktreeId:e.worktree.id,effort:z}),onClose:vo}),rt?!o&&d.jsx(PE,{value:ot,onChange:zt,onClose:vo}):e&&d.jsx(PE,{value:Kt,onChange:z=>f==null?void 0:f.send({t:"set-worktree-mode",worktreeId:e.worktree.id,mode:z}),onClose:vo}),e&&!rt&&!v&&be&&!Di(e.worktree)&&Object.keys(be.tier??{}).map(z=>d.jsx(RH,{name:z,wt:e,repo:be,trunk:Ct,onClose:vo},z)),Je&&d.jsxs("span",{className:"usage-knob",onMouseEnter:()=>{Te||(window.clearTimeout(an.current),an.current=window.setTimeout(()=>bn(!0),Yq))},onMouseLeave:()=>{window.clearTimeout(an.current),bn(!1)},onFocus:z=>{Te||!z.target.matches(":focus-visible")||(window.clearTimeout(an.current),bn(!0))},onBlur:sr,children:[d.jsx(Tt,{icon:d.jsx(OK,{fraction:me?me.used/me.size:0,level:G?G8(G,Ve):void 0}),tone:"chrome",on:Te,silent:!0,label:me?`${Math.round(100*me.used/me.size)}% of context`:G?x1(G,Ve):"",detail:[...me&&G?[x1(G,Ve)]:[],...$r?[$r]:[]],...ze.dropdown(H,"left","usage",cn),...ze.contextMenu(H,"usage")}),He&&d.jsx(Zq,{usage:me,limits:G,auth:Ke==null?void 0:Ke.auth,now:Ve,onClose:sr})]})]}),d.jsxs("span",{className:"spawn-tools",children:[w&&(e||x||o)&&d.jsx(Tt,{icon:"attach",tone:"chrome",label:l?"Attach a picture or a file":"Attach a picture or a file, or drop one here",onClick:()=>MT(h,w)}),!s&&!v&&!l&&!o&&d.jsx(Tt,{icon:"terminal",tone:"chrome",on:se,className:"composer-term",disabled:!e,label:Se?Se.tip:"Terminal",hint:Ht("terminal"),badge:Se&&d.jsx("span",{className:"composer-term-dot"}),onClick:()=>{u(Se&&!se&&g?{a:"term-stream",id:g,stream:Se.stream}:{a:"toggle-terminal"})},...ze.contextMenu(()=>e&&g?b9(e.procs,g,se,{sock:f,dispatch:h.dispatch}):[])}),!s&&!he&&!v&&!l&&!o&&d.jsx(Tt,{icon:"pick",label:"Pick an element on the page to attach",hint:Ht("pick"),on:D==="chat",disabled:!Q,onClick:()=>Q&&Lu(Q,D,u,"chat")}),B&&w&&(e||x||o)&&d.jsx(Tt,{icon:"send",tone:"primary",label:o?"Create the project":"Send",disabled:ea||(o?o.busy:Qn),onMouseDown:z=>z.preventDefault(),onClick:sc})]})]}),(Wt||qe&&Ct||$l.length>0)&&d.jsxs("div",{className:"composer-notes",children:[$l.map(z=>d.jsx("div",{className:"hint composer-note",children:d.jsxs("span",{children:[z.title," starts when"," ","id"in z.after?z.after.id===(e==null?void 0:e.worktree.id)?"this branch":d.jsx(to,{id:z.after.id}):Qq(z,z.after.piece,$l)," ","lands"]})},`${z.proposalId}/${z.pieceId}`)),Wt&&Ke&&d.jsxs("div",{className:"hint composer-note",role:"status",children:[d.jsx("span",{children:Wt.text}),(Wt.retry||Dn)&&d.jsxs("span",{className:"composer-note-actions",children:[Wt.retry&&d.jsx(Me,{variant:"outline",onClick:()=>f==null?void 0:f.send($C(Ke)),children:Wt.retry}),Dn&&d.jsxs(Me,{variant:"outline","data-tip":`${Dn.name} is installed and takes this message instead`,onClick:()=>Dt(Dn.id),children:["use ",Dn.name]})]})]}),qe&&Ct&&d.jsxs("div",{className:"hint composer-note",children:[d.jsx("span",{children:qe}),Tz(Ct)&&d.jsx(Me,{variant:"outline",busy:le==="pull-main",disabled:!!le,"data-tip":"Fast-forward main to origin",onClick:()=>Li(f,u,{t:"pull-main",worktreeId:Ct.id}),children:"pull"})]})]})]})}function tZ({children:e,className:t,tip:n,...r}){return d.jsxs("label",{className:We("check",t),"data-tip":n,children:[d.jsx("input",{type:"checkbox",className:"check-box",...r}),d.jsx("span",{children:e})]})}function nZ({draft:e,lead:t}){const n=ht(),r=L(a=>bs(a,t==null?void 0:t.repoId)),o=L(a=>{var l;return((l=Hi(a,t==null?void 0:t.repoId))==null?void 0:l.dirty)??0});return!!t&&!!r&&o>0?d.jsx("div",{className:"draft-intro",children:d.jsx("div",{className:"draft-notes",children:d.jsxs(tZ,{className:"hint draft-note",checked:!!e.carry,tip:`Move the ${o} uncommitted ${o===1?"file":"files"} into the new worktree, leaving ${r.defaultBranch} clean`,onChange:a=>n({a:"draft-carry",v:a.currentTarget.checked}),children:[d.jsxs("span",{className:"badge-dirty",children:["~",o]})," on ",r.defaultBranch," come along"]})})}):null}function rZ({row:e}){const t=nt(),n=L(a=>a.clientId),r=L(a=>a.home),o=r&&e.path.startsWith(`${r}/`)?`~${e.path.slice(r.length)}`:e.path,s=e.locked?"Toyon would be working in a directory something else is using, so taking it over waits for the lock to go.":"A message sent below takes over this branch.";return d.jsxs(ar,{icon:e.locked?"lock":"branch",word:e.locked?"held":"discovered",tone:"quiet",below:s,children:[d.jsxs("span",{className:"daemon-text",children:[e.locked&&`by ${e.lockReason??"another tool"}, at `,d.jsx("span",{className:"tool-hint",children:o})]}),!e.locked&&d.jsx(Me,{variant:"inline",tone:"strong",onClick:()=>t==null?void 0:t.send({t:"adopt-worktree",worktreeId:e.id,clientId:n}),children:"take over"})]})}function _u({placement:e,className:t,width:n,archived:r,found:o}){const s=ht(),a=Vs(),l=S6(),u=Rt(a==null?void 0:a.worktree.id,"sending"),f=hl(),h=e==="centre"&&!r&&(f!=null&&f.assumed)?f:null,p=L(v=>{var x;return((x=v.dragFiles)==null?void 0:x.at)==="chat"}),g=Pn(),y=E.useMemo(()=>({onDragOver:v=>o8(g,v),onDrop:v=>{const x=cj(g,v);x&&NT(g,x.boxId,x.words)}}),[g]),w=d.jsxs(d.Fragment,{children:[!r&&!o&&l&&!u&&d.jsx(nZ,{draft:l,lead:a}),r?d.jsx(Su,{active:null,archived:r,placement:e}):o?d.jsx(Su,{active:null,found:o,placement:e}):d.jsx(Su,{active:a,draft:l,placement:e})]});return d.jsx("div",{className:We(e==="dock"?"chat-dock":e==="centre"?"chat-centre":"chat-screen",t,p&&"drop-over"),style:n===void 0?void 0:{width:n},...y,ref:v=>{var x;v?bu.el=v:(x=bu.el)!=null&&x.isConnected||(bu.el=null)},children:r?d.jsx(Zg,{active:null,archived:r,tail:d.jsx(e9,{item:r}),foot:w}):o?d.jsx(Zg,{active:null,found:o,tail:d.jsx(rZ,{row:o}),foot:w}):d.jsx(Zg,{active:a,lead:h&&d.jsxs("p",{className:"hint chat-centre-note",children:[h.name," has ",d.jsx("code",{children:h.assumed})," and no dev server, so it is chat only for now."," ",d.jsx(Me,{variant:"inline",onClick:()=>s({a:"open",overlay:{kind:"setup",repoId:h.id}}),children:"add a dev server"})]}),foot:w})})}const oZ="modulepreload",sZ=function(e){return"/"+e},XE={},mw=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let a=function(f){return Promise.all(f.map(h=>Promise.resolve(h).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),u=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));o=a(n.map(f=>{if(f=sZ(f),f in XE)return;XE[f]=!0;const h=f.endsWith(".css"),p=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${p}`))return;const g=document.createElement("link");if(g.rel=h?"stylesheet":oZ,h||(g.as="script"),g.crossOrigin="",g.href=f,u&&g.setAttribute("nonce",u),document.head.appendChild(g),h)return new Promise((y,w)=>{g.addEventListener("load",y),g.addEventListener("error",()=>w(Error(`Unable to preload CSS for ${f}`)))})}))}function s(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return o.then(a=>{for(const l of a||[])l.status==="rejected"&&s(l.reason);return t().catch(s)})},jv=800;function iZ(e,t,n,r){if(r.version===e.version)return"same";const o=t===e.text&&n===null;return r.version===null?o?"gone":"conflict":r.after===t||r.after===n?"adopt":o?"apply":"conflict"}const Jo=e=>`${e.worktreeId}
267
- ${e.ref??""}
268
- ${e.since??""}
269
- ${e.path}`;class aZ{constructor(t){_t(this,"files",new Map);_t(this,"looks",new Map);this.d=t}start(){var s,a;let t=this.d.store.getState();const n=this.d.store.subscribe(()=>{const l=this.d.store.getState(),u=t;t=l,this.follow(u,l)}),r=()=>{const l=this.d.store.getState().editor;l&&!l.loose&&this.refresh(Jo(l))};(s=this.d.win)==null||s.addEventListener("focus",r);const o=()=>{for(const[l,u]of this.files)u.timer!==void 0&&this.saveNow(l)};return(a=this.d.win)==null||a.addEventListener("pagehide",o),()=>{var l,u;n(),(l=this.d.win)==null||l.removeEventListener("focus",r),(u=this.d.win)==null||u.removeEventListener("pagehide",o)}}receive(t){const n=t.t==="file-read"?this.looks.get(t.seq):void 0;if(n&&t.t==="file-read"){this.looks.delete(t.seq),n(t.error||t.binary||t.tooLarge||t.version===null?null:t.after);return}const r=this.files.get(Jo(t));if(!r)return;if(t.t==="file-blame"){this.blamed(r,t);return}const o=r.out;!o||o.seq!==t.seq||(r.out=null,t.t==="file-read"?this.read(r,t):o.write!==void 0&&this.written(r,o.write,t),this.next(r))}look(t,n){if(!this.d.store.getState().connected)return Promise.resolve(null);const r=$o();return new Promise(o=>{this.looks.set(r,o),this.d.send({t:"read-file",worktreeId:t,path:n,seq:r})})}bind(t){const n=Jo(t);return{attach:r=>this.attach(n,r),edited:()=>this.edited(n),saveNow:()=>this.saveNow(n)}}reload(t){var o;const n=this.files.get(Jo(t)),r=n==null?void 0:n.conflict;!n||!r||(this.cancelTimer(n),n.pending=null,n.base={text:r.after,version:r.version},this.setConflict(n,null),r.version===null?this.d.store.dispatch({a:"close-editor"}):(o=n.buffer)==null||o.replace(r.after),this.next(n))}keepMine(t){const n=this.files.get(Jo(t)),r=n==null?void 0:n.conflict;!(n!=null&&n.buffer)||!r||(n.base={text:r.after,version:r.version},this.setConflict(n,null),n.pending=n.buffer.text(),this.next(n))}follow(t,n){var s,a,l,u;t.connected&&!n.connected&&this.dropped();const r=(s=n.editor)!=null&&s.loose?null:n.editor,o=(a=t.editor)!=null&&a.loose?null:t.editor;if(o&&(!r||Jo(o)!==Jo(r))&&this.closed(Jo(o)),r&&(!o||o.seq!==r.seq)&&this.opened(r),!t.connected&&n.connected)for(const f of this.files.values())f.reread=!0,this.next(f);else r&&o&&o.seq===r.seq&&((l=Or(t,r.worktreeId).git)==null?void 0:l.version)!==((u=Or(n,r.worktreeId).git)==null?void 0:u.version)&&this.refresh(Jo(r))}opened(t){const n=Jo(t);let r=this.files.get(n);r||(r={file:{worktreeId:t.worktreeId,path:t.path,...t.ref?{ref:t.ref}:{},...t.since?{since:t.since}:{}},open:!0,base:null,out:null,pending:null,reread:!1,writable:!1,conflict:null,buffer:null,timer:void 0,blame:null},this.files.set(n,r)),r.open=!0,r.reread=!0,r.conflict&&this.d.store.dispatch({a:"editor-conflict",file:r.file,theirs:r.conflict}),this.next(r)}closed(t){const n=this.files.get(t);n&&(n.open=!1,this.next(n))}refresh(t){const n=this.files.get(t);!n||n.file.ref||(n.reread=!0,this.next(n))}dropped(){for(const t of this.looks.values())t(null);this.looks.clear();for(const t of this.files.values())t.out&&(t.out.write!==void 0&&(t.pending??(t.pending=t.out.write)),t.out=null,t.reread=!0)}next(t){var a;if(t.out||!this.d.store.getState().connected)return;const{worktreeId:n,path:r,ref:o,since:s}=t.file;if(t.reread){t.reread=!1;const l=$o();t.out={seq:l},this.d.send({t:"read-file",worktreeId:n,path:r,ref:o,since:s,seq:l});return}if(t.pending!==null&&t.base&&t.pending===t.base.text&&(t.pending=null),t.pending!==null&&t.writable&&!t.conflict&&!o){const l=t.pending,u=$o();t.pending=null,t.out={seq:u,write:l},this.d.send({t:"write-file",worktreeId:n,path:r,content:l,base:((a=t.base)==null?void 0:a.version)??null,seq:u});return}!t.open&&!t.buffer&&t.pending===null&&!t.conflict&&this.files.delete(Jo(t.file))}read(t,n){var g,y;const{file:r}=t;if(n.error){t.open&&this.d.store.dispatch({a:"editor-read",file:r,disk:null,error:n.error});return}const{before:o,after:s,version:a,writable:l,binary:u,tooLarge:f}=n;t.writable=l,t.open&&(this.d.store.dispatch({a:"editor-read",file:r,disk:{before:o,after:s,version:a,writable:l,binary:u,tooLarge:f}}),!u&&!f&&(a!==null||r.ref)&&this.askBlame(t,a));const h={after:t.buffer?t.buffer.normalize(s):s,version:a};if(!t.base){t.base={text:h.after,version:a};return}const p=((g=t.buffer)==null?void 0:g.text())??t.pending??t.base.text;switch(iZ(t.base,p,t.pending,h)){case"same":break;case"adopt":t.base={text:h.after,version:a};break;case"apply":(y=t.buffer)==null||y.replace(h.after),t.base={text:h.after,version:a};break;case"gone":t.base={text:"",version:null},t.open&&this.d.store.dispatch({a:"close-editor"});break;case"conflict":this.setConflict(t,h);return}this.setConflict(t,null)}askBlame(t,n){const r=$o();t.blame={seq:r,version:n};const{worktreeId:o,path:s,ref:a}=t.file;this.d.send({t:"blame-file",worktreeId:o,path:s,ref:a,seq:r})}blamed(t,n){const r=t.blame;if(!r||r.seq!==n.seq||(t.blame=null,!t.open))return;const{commits:o,lines:s}=n;this.d.store.dispatch({a:"editor-blame",file:t.file,blame:{commits:o,lines:s,version:r.version}})}written(t,n,r){if(r.ok){t.base={text:n,version:r.version};return}if(r.reason==="changed"){t.pending??(t.pending=n),t.reread=!0;return}t.writable=!1,t.pending=null,this.d.store.dispatch({a:"editor-refused",file:t.file,message:r.message??`not saved: ${t.file.path}`})}setConflict(t,n){t.conflict===n||t.conflict&&n&&t.conflict.version===n.version||(t.conflict=n,t.open&&this.d.store.dispatch({a:"editor-conflict",file:t.file,theirs:n}))}attach(t,n){const r=this.files.get(t);if(r){if(n){r.buffer=n,r.base&&(r.base={...r.base,text:n.normalize(r.base.text)}),r.conflict&&r.pending!==null&&n.replace(r.pending);return}r.buffer&&((r.timer!==void 0||r.conflict)&&(r.pending=r.buffer.text()),this.cancelTimer(r),r.buffer=null,this.next(r))}}edited(t){const n=this.files.get(t);!(n!=null&&n.buffer)||!n.writable||n.file.ref||(this.cancelTimer(n),n.timer=this.d.timers.set(()=>{n.timer=void 0,this.saveNow(t)},jv))}saveNow(t){const n=this.files.get(t);if(!(n!=null&&n.buffer))return;this.cancelTimer(n);const r=n.buffer.text();r.length>dh||(n.pending=r,this.next(n))}cancelTimer(t){t.timer!==void 0&&(this.d.timers.clear(t.timer),t.timer=void 0)}}const aA={attach:()=>{},edited:()=>{},saveNow:()=>{}},cZ=e=>({timers:{set:(t,n)=>setTimeout(t,n),clear:t=>clearTimeout(t)},win:typeof window>"u"?null:window,send:e}),gw=new Map;function lZ(e){const t=gw.get(e.seq);return t?(gw.delete(e.seq),t(e),!0):!1}function uZ(e,t,n,r){if(e.kind==="bytes"||e.kind==="text"||e.kind==="pr-comments")return aA;if(e.kind==="grant")return dZ(e,t,n,r);const o=e.handle;let s=null,a,l=null,u=Promise.resolve(),f=!1;const h=()=>(l??(l=(async()=>await o.queryPermission({mode:"readwrite"})==="granted"?!0:await o.requestPermission({mode:"readwrite"})==="granted")().catch(()=>!1)),l),p=()=>{a!==void 0&&r.timers.clear(a),a=void 0},g=()=>{f||(f=!0,p(),n(`read-only: the browser would not save ${t}`))},y=async x=>{if(!await h())return g();const N=await o.createWritable();await N.write(x),await N.close()},w=()=>{if(!s||f)return;p();const x=s.text();u=u.then(()=>y(x)).catch(g)},v=()=>{a!==void 0&&w()};return{attach(x){var N,S;if(x){s=x,(N=r.win)==null||N.addEventListener("pagehide",v);return}a!==void 0&&w(),s=null,(S=r.win)==null||S.removeEventListener("pagehide",v)},edited(){!s||f||(h().then(x=>{x||g()}),p(),a=r.timers.set(w,jv))},saveNow:w}}function dZ(e,t,n,r){let o=null,s,a=e.version,l=!1,u=null,f=!1;const h=()=>{s!==void 0&&r.timers.clear(s),s=void 0},p=v=>{f||(f=!0,h(),u=null,n(v))},g=v=>{if(!r.send)return;const x=$o();l=!0,gw.set(x,N=>{if(l=!1,N.ok?a=N.version:N.reason==="changed"?p(`read-only: ${t} changed on disk; open it again to edit`):p(N.message??`not saved: ${t}`),u!==null&&!f){const S=u;u=null,g(S)}}),r.send({t:"write-loose",id:e.id,content:v,base:a,seq:x})},y=()=>{if(!o||f)return;h();const v=o.text();v.length>dh||(l?u=v:g(v))},w=()=>{s!==void 0&&y()};return{attach(v){var x,N;if(v){o=v,(x=r.win)==null||x.addEventListener("pagehide",w);return}s!==void 0&&y(),o=null,(N=r.win)==null||N.removeEventListener("pagehide",w)},edited(){!o||f||(h(),s=r.timers.set(y,jv))},saveNow:y}}const QE=900;function fZ(){return ks(it.editorSplit,!1,e=>e===null?void 0:e==="1")}const JE=[{id:"file",label:"file",tip:Nt("File: as it is now, with no diff")},{id:"inline",label:"inline",tip:Nt("Inline: old and new in one column")},{id:"split",label:"split",tip:Nt("Split: old beside new, taking the chat's room when the pane is too narrow for both")}];function hZ({at:e,onPick:t,columns:n=!0}){return d.jsx("span",{className:"editor-pair",children:d.jsx(Ya,{items:n?JE:JE.filter(r=>r.id!=="split"),current:e,onPick:r=>{r!==e&&t(r)},segmented:!0,dense:!0,font:"mono",label:"the diff",owner:"pane"})})}function pZ({src:e,path:t,full:n,onFull:r}){const o=xn("editor");return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"editor-image",onClick:()=>r(!0),...o.contextMenu(()=>Ba(e,{open:()=>r(!0)})),children:d.jsx("img",{src:e,alt:t})}),n&&d.jsx(id,{owner:"editor",onClose:()=>r(!1),menu:()=>Ba(e),children:d.jsx("img",{src:e,alt:t})})]})}function mZ({src:e,path:t}){return d.jsx("div",{className:"editor-video",children:d.jsx("video",{src:e,controls:!0,preload:"metadata",title:t})})}const gZ={image:pZ,video:mZ};function kZ({kind:e,src:t,path:n,openSeq:r,focus:o,full:s,onFull:a}){const l=E.useRef(null);ct([r],()=>{var f;o&&((f=l.current)==null||f.focus())});const u=gZ[e];return d.jsx("div",{ref:l,className:"editor-viewer",tabIndex:-1,children:d.jsx(u,{src:t,path:n,full:s,onFull:a})})}const cl="document-came",ll="document-gone",wZ=4e6;function cA(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;let r=0;for(;r<e.length-n&&r<t.length-n&&e[e.length-1-r]===t[t.length-1-r];)r++;const o=e.length-n-r,s=t.length-n-r,a=[];for(let l=0;l<n;l++)a.push({k:"same",o:l,n:l});if(o*s>wZ){for(let l=0;l<o;l++)a.push({k:"gone",o:n+l});for(let l=0;l<s;l++)a.push({k:"came",n:n+l})}else if(o&&s){const l=Array.from({length:o+1},()=>new Uint16Array(s+1));for(let h=o-1;h>=0;h--)for(let p=s-1;p>=0;p--)l[h][p]=e[n+h]===t[n+p]?l[h+1][p+1]+1:Math.max(l[h+1][p],l[h][p+1]);let u=0,f=0;for(;u<o&&f<s;)e[n+u]===t[n+f]?a.push({k:"same",o:n+u++,n:n+f++}):l[u+1][f]>=l[u][f+1]?a.push({k:"gone",o:n+u++}):a.push({k:"came",n:n+f++});for(;u<o;u++)a.push({k:"gone",o:n+u});for(;f<s;f++)a.push({k:"came",n:n+f})}else{for(let l=0;l<o;l++)a.push({k:"gone",o:n+l});for(let l=0;l<s;l++)a.push({k:"came",n:n+l})}for(let l=0;l<r;l++)a.push({k:"same",o:n+o+l,n:n+s+l});return a}function Up(e){return e.classList.contains("md-table")?"table":e.tagName==="UL"||e.tagName==="OL"?"list":"leaf"}const Nu=e=>Up(e)==="table"?Array.from(e.querySelectorAll("tr")):Array.from(e.children),Rh=e=>Array.from(e.children);function eS(e){var n;const t=Up(e);return t!=="table"?`${e.tagName} ${t}`:`table ${((n=e.querySelector("tr"))==null?void 0:n.children.length)??0}`}function Oh(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let r=n.nextNode();r;r=n.nextNode())t.push(r.data);return t.join(" ").replace(/\s+/g," ").trim()}const tS=new WeakMap;function nS(e){let t=tS.get(e);if(!t){const n=new Map,r=Oh(e).split(" ").filter(Boolean);for(const o of r)n.set(o,(n.get(o)??0)+1);t={count:r.length,words:n},tS.set(e,t)}return t}function yZ(e,t){if(eS(e)!==eS(t))return 0;if(e.tagName==="TR"&&e.children[0]&&t.children[0]&&Oh(e.children[0])===Oh(t.children[0]))return 1;const[n,r]=[nS(e),nS(t)];if(!n.count||!r.count)return 0;let o=0;for(const[s,a]of n.words)o+=Math.min(a,r.words.get(s)??0);return 2*o/(n.count+r.count)}const rS=.5;function $v(e,t){const n=s=>`${s.tagName}
270
- ${s.innerHTML}`,r=cA(e.map(n),t.map(n)),o=[];for(let s=0;s<r.length;){const a=r[s];if(a.k==="same"){o.push(a),s++;continue}const l=[],u=[];for(;s<r.length&&r[s].k!=="same";s++){const y=r[s];y.k==="gone"?l.push(y.o):y.k==="came"&&u.push(y.n)}const f=l.map(y=>u.map(w=>yZ(e[y],t[w]))),h=Array.from({length:l.length+1},()=>new Float64Array(u.length+1));for(let y=l.length-1;y>=0;y--)for(let w=u.length-1;w>=0;w--){const v=f[y][w]>=rS?h[y+1][w+1]+f[y][w]:0;h[y][w]=Math.max(h[y+1][w],h[y][w+1],v)}let p=0,g=0;for(;p<l.length&&g<u.length;){const y=f[p][g];y>=rS&&h[p][g]===h[p+1][g+1]+y?o.push({k:"edit",o:l[p++],n:u[g++]}):h[p+1][g]>=h[p][g+1]?o.push({k:"gone",o:l[p++]}):o.push({k:"came",n:u[g++]})}for(;p<l.length;p++)o.push({k:"gone",o:l[p]});for(;g<u.length;g++)o.push({k:"came",n:u[g]})}return o}const vZ=/[\p{L}\p{N}]+(?:['’_-][\p{L}\p{N}]+)*|[^\s\p{L}\p{N}]/gu,lA=new Set(["IMG","INPUT"]),uA=new Set(["A","ABBR","B","BR","CODE","DEL","EM","I","INS","KBD","MARK","S","SMALL","SPAN","STRONG","SUB","SUP","U"]),kw=e=>!!e&&uA.has(e.tagName);function Mh(e){const t=[],n=o=>{let s="";for(let a=o.parentNode;a&&a!==e;a=a.parentNode){const l=a;s+=l.tagName==="A"?`A ${l.getAttribute("href")??""}>`:`${l.tagName}>`}return s},r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT);for(let o=r.nextNode();o;o=r.nextNode()){if(o.nodeType===Node.ELEMENT_NODE){const l=o;lA.has(l.tagName)&&t.push({key:n(l)+l.outerHTML,el:l});continue}const s=o,a=n(s);for(const l of s.data.matchAll(vZ))t.push({key:a+l[0],node:s,start:l.index,end:l.index+l[0].length})}return t}function Vg(e,t){const n=e[t-1],r=e[t];return!n||!r||!("node"in n)||!("node"in r)?!0:n.node===r.node?/\s/.test(n.node.data.slice(n.end,r.start)):n.end<n.node.data.length||r.start>0}function dA(e,t){const n=cA(e.map(s=>s.key),t.map(s=>s.key)),r=[];for(const s of n){const a=s.k==="same",l=r[r.length-1];l&&l.same===a?l.ops.push(s):r.push({same:a,ops:[s]})}const o=s=>{const a=s.ops.filter(l=>l.k!=="came").length;return Math.max(a,s.ops.length-(s.same?0:a))};for(let s=1;s<r.length-1;){const[a,l,u]=[r[s-1],r[s],r[s+1]];if(!l.same||o(l)>=Math.min(o(a),o(u))){s++;continue}const f=l.ops.flatMap(h=>h.k==="same"?[{k:"gone",o:h.o},{k:"came",n:h.n}]:[]);r.splice(s-1,3,{same:!1,ops:[...a.ops,...f,...u.ops]}),s=Math.max(1,s-2)}return r.flatMap(s=>s.ops)}function ww(e,t,n,r,o,s=[]){const a=()=>{const p=document.createElement(r);return p.className=o,p},l=new Map,u=p=>{let g=l.get(p);return g||(g=[],l.set(p,g)),g},f=new Map;t.forEach((p,g)=>{if(!n[g])return;if("el"in p){const x=a();p.el.replaceWith(x),x.append(p.el),f.set(p.el,x);return}const y=u(p.node),w=t[g-1],v=y[y.length-1];v&&n[g-1]&&w&&"node"in w&&w.node===p.node?v.end=p.end:y.push({start:p.start,end:p.end})});const h=(p,g)=>{for(let y=g;kw(y)&&y!==e;y=y.parentNode)for(const w of p)if(typeof w!="string")for(const v of w.querySelectorAll(y.tagName))v.replaceWith(...v.childNodes);return p};for(const{before:p,nodes:g,back:y=0}of s){if(!p){e.append(...g);continue}if("el"in p){const x=f.get(p.el)??p.el;x.before(...h(g,x.parentNode));continue}const w=!y&&t.find(x=>"node"in x&&x.node===p.node)===p;let v=p.node;for(;w&&!v.previousSibling&&v.parentNode!==e&&kw(v.parentNode);)v=v.parentNode;h(g,v.parentNode),v!==p.node?v.before(...g):u(p.node).push({start:p.start-y,end:p.start-y,nodes:g})}for(const[p,g]of l){g.sort((y,w)=>w.start-y.start||(y.nodes?1:0)-(w.nodes?1:0));for(const y of g){if(y.nodes){p.splitText(y.start).before(...y.nodes);continue}p.splitText(y.end);const w=p.splitText(y.start),v=a();w.replaceWith(v),v.append(w)}}}function oS(e,t){const[n,r]=[Mh(e),Mh(t)],o=[],s=[];for(const a of dA(n,r))a.k==="gone"?o[a.o]=!0:a.k==="came"&&(s[a.n]=!0);ww(e,n,o,"del",ll),ww(t,r,s,"ins",cl)}function bZ(e,t,n){const r=document.createRange();"el"in t?r.setStartBefore(t.el):r.setStart(t.node,t.start),"el"in n?r.setEndAfter(n.el):r.setEnd(n.node,n.end);const o=document.createElement("del");o.className=ll;let s=r.cloneContents();if(Array.from(s.querySelectorAll("*")).some(l=>!uA.has(l.tagName)&&!lA.has(l.tagName)))return o.textContent=Oh(s),o;let a=r.commonAncestorContainer;for(a.nodeType===Node.TEXT_NODE&&(a=a.parentNode);kw(a)&&a!==e;a=a.parentNode){const l=a.cloneNode(!1);l.appendChild(s),s=l}return o.append(s),o}function sS(e,t){const n=t.cloneNode(!0),[r,o]=[Mh(e),Mh(n)],s=dA(r,o),a=[],l=[];for(let u=0,f=0;u<s.length;){const h=s[u];if(h.k==="same"){f=h.n+1,u++;continue}const p=[];for(;u<s.length&&s[u].k!=="same";u++){const N=s[u];N.k==="gone"?p.push(N.o):N.k==="came"&&(a[N.n]=!0)}if(!p.length)continue;const[g,y]=[p[0],p[p.length-1]],w=bZ(e,r[g],r[y]),v=o[f],x=Vg(r,g);if(!v||!Vg(o,f))l.push({before:v,nodes:x?[" ",w]:[w]});else if(x)l.push({before:v,nodes:Vg(r,y+1)||a[f]?[w," "]:[w]});else{const N="node"in v?v.start-v.node.data.slice(0,v.start).trimEnd().length:0;l.push(N?{before:v,nodes:[w],back:N}:{before:v,nodes:[w," "]})}}return ww(n,o,a,"ins",cl,l),n}function fA(e,t){const n=Up(e);if(n==="leaf"){oS(e,t);return}const[r,o]=[Nu(e),Nu(t)];for(const s of $v(r,o))if(s.k==="gone")r[s.o].classList.add(ll);else if(s.k==="came")o[s.n].classList.add(cl);else if(s.k==="edit"&&n==="list")fA(r[s.o],o[s.n]);else if(s.k==="edit"){const[a,l]=[Rh(r[s.o]),Rh(o[s.n])];a.forEach((u,f)=>{const h=l[f];h&&u.innerHTML!==h.innerHTML&&oS(u,h)})}}function hA(e,t){const n=Up(e);if(n==="leaf")return sS(e,t);const r=t.cloneNode(!0),[o,s,a]=[Nu(e),Nu(t),Nu(r)],l=$v(o,s);return l.forEach((u,f)=>{var y;if(u.k==="same")return;if(u.k==="came"){a[u.n].classList.add(cl);return}if(u.k==="edit"&&n==="list"){a[u.n].replaceWith(hA(o[u.o],s[u.n]));return}if(u.k==="edit"){const w=Rh(o[u.o]);Rh(a[u.n]).forEach((v,x)=>{const N=w[x];N&&N.innerHTML!==v.innerHTML&&v.replaceWith(sS(N,v))});return}const h=o[u.o].cloneNode(!0);h.classList.add(ll);const p=l.slice(f+1).find(w=>w.k!=="gone"),g=p&&a[p.n];if(g&&((y=g.parentElement)==null?void 0:y.tagName)!=="THEAD")g.before(h);else{const w=r.querySelector("tbody")??r.querySelector("table")??r;g?w.prepend(h):w.append(h)}}),r}function iS(e){const t=document.createElement("template");return t.innerHTML=e,Array.from(t.content.childNodes).flatMap(n=>{var o;if(n.nodeType===Node.ELEMENT_NODE)return[n];if(n.nodeType!==Node.TEXT_NODE||!((o=n.textContent)!=null&&o.trim()))return[];const r=document.createElement("p");return r.append(n),[r]})}function xZ(e,t,n){const r=iS(e),o=iS(t),s=$v(r,o),a=document.createElement("div");if(!n){for(const f of s)f.k==="edit"?a.append(hA(r[f.o],o[f.n])):f.k==="gone"?(r[f.o].classList.add(ll),a.append(r[f.o])):(f.k==="came"&&o[f.n].classList.add(cl),a.append(o[f.n]));return a.innerHTML}const l=()=>{const f=document.createElement("div"),h=document.createElement("div");return a.append(f,h),{was:f,now:h}};let u=null;for(const f of s){if(f.k==="gone"||f.k==="came"){u??(u=l()),f.k==="gone"?(r[f.o].classList.add(ll),u.was.append(r[f.o])):(o[f.n].classList.add(cl),u.now.append(o[f.n]));continue}u=null,f.k==="edit"&&fA(r[f.o],o[f.n]);const{was:h,now:p}=l();h.append(r[f.o]),p.append(o[f.n])}return a.innerHTML}function EZ(e){const t=[];return e.map(n=>{for(;t.length&&t[t.length-1]>=n;)t.pop();if(n===1)return 0;const r=t.length;return t.push(n),r})}function SZ(e){const t=new Map,n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")).filter(o=>!o.closest(".document-gone, .document-split > :nth-child(odd)")),r=EZ(n.map(o=>Number(o.tagName[1])));return n.map((o,s)=>{var u;const a=((u=o.textContent)==null?void 0:u.trim())??"",l=t.get(a)??0;return t.set(a,l+1),{id:`${l}
271
- ${a}`,level:Number(o.tagName[1]),depth:r[s],text:a,el:o}})}const _Z=48,NZ=16;function Cv({html:e,before:t,split:n=!1,openSeq:r=0,focus:o=!0,onLink:s,onChat:a,lead:l}){const u=E.useRef(null),f=E.useRef(null),h=E.useMemo(()=>t===void 0?e:xZ(t,e,n),[t,e,n]),[p,g]=E.useState([]),[y,w]=E.useState(-1),[v,x]=E.useState(null),N=$=>{var R;if(x(null),$){const A=window.getSelection();A==null||A.removeAllRanges(),A==null||A.addRange($)}(R=u.current)==null||R.focus()};ct([r],()=>{var $;o&&(($=u.current)==null||$.focus())}),ct([h],()=>{g(f.current?SZ(f.current):[])}),E.useLayoutEffect(()=>{const $=u.current;if(!$)return;let R=0;const A=()=>{if(R=0,$.scrollTop+$.clientHeight>=$.scrollHeight-1){w(p.length-1);return}const M=$.scrollTop+_Z;let P=-1;for(let F=0;F<p.length;F++)p[F].el.offsetTop<=M&&(P=F);w(P)},I=()=>{R||(R=requestAnimationFrame(A))};return A(),$.addEventListener("scroll",I),()=>{$.removeEventListener("scroll",I),R&&cancelAnimationFrame(R)}},[p]);const S=$=>{var A,I;const R=(A=p[$])==null?void 0:A.el;(I=u.current)==null||I.scrollTo({top:Math.max(0,R?R.offsetTop-NZ:0),behavior:"smooth"})},T=$=>{const R=$.target.closest("a"),A=R==null?void 0:R.getAttribute("href");!A||(R==null?void 0:R.target)==="_blank"||($.preventDefault(),s==null||s(A))},j=$=>{var R;if(Wy($)){$.preventDefault(),$.stopPropagation();const A=(f.current&&Wk(f.current))??"";x(I=>({seed:A||(I==null?void 0:I.seed)||"",seq:((I==null?void 0:I.seq)??0)+1}));return}if($.key==="Escape"&&v){$.stopPropagation(),N(null);return}if(Pj($)&&f.current){$.preventDefault(),zj(f.current);return}if(a&&((R=KS($))==null?void 0:R.id)==="composer"&&f.current){const A=Wk(f.current);if(!A)return;$.preventDefault(),$.stopPropagation(),a(A)}};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{ref:u,className:"document",tabIndex:-1,onClick:T,onKeyDown:j,children:[l,d.jsx("div",{ref:f,className:We("md md-preview",t!==void 0&&n&&"document-split"),dangerouslySetInnerHTML:{__html:h}})]}),v&&d.jsx(Lj,{root:u,body:f,seed:v.seed,seq:v.seq,onClose:N}),d.jsx(TZ,{heads:p,at:y,onJump:S})]})}function TZ({heads:e,at:t,onJump:n}){const[r,o]=E.useState(!1),s=E.useRef(null);return e.length<2?null:d.jsxs(d.Fragment,{children:[d.jsx("div",{ref:s,className:"document-outline","aria-hidden":!0,onPointerEnter:a=>{a.pointerType==="mouse"&&o(!0)},onClick:()=>o(a=>!a),children:e.map((a,l)=>d.jsx("span",{className:"document-outline-tick","data-level":a.level,"data-state":fr({current:l===t})},a.id))}),r&&d.jsx(Qs,{className:"document-outline-list",anchor:()=>{var a;return((a=s.current)==null?void 0:a.getBoundingClientRect())??null},placement:{side:"right",align:"center",cover:!0},trigger:s.current,onDismiss:()=>o(!1),onPointerLeave:a=>{a.pointerType==="mouse"&&o(!1)},children:e.map((a,l)=>d.jsx("button",{type:"button",className:"row document-outline-row","data-level":a.level,"data-state":fr({current:l===t}),onClick:()=>n(l),children:d.jsx("span",{className:"document-outline-label",style:{"--outline-depth":a.depth},children:a.text})},a.id))})]})}function pA({text:e,before:t,marks:n=!1,split:r=!1,path:o,worktreeId:s,version:a,openSeq:l,focus:u,onChat:f,lead:h}){nt();const p=Mr(),g=ht(),y=eB(o),w={keepHtml:!0,base:a===void 0?void 0:{worktreeId:s,dir:y,version:a,urls:p}},v=ol(e,w),x=ol(t??"",w),N=S=>{const T=t$(y,S);T&&Rn({dispatch:g},{worktreeId:s,path:T,view:Bi(T)})};return d.jsx(Cv,{html:v,before:n&&t!==void 0?x:void 0,split:r,openSeq:l,focus:u,onLink:N,onChat:f,lead:h})}function jZ({refs:e,worktreeId:t}){const n=Mr();return e.length===0?null:d.jsx("div",{className:"editor-piece-chips",children:e.map(r=>r.kind==="image"?d.jsx(Dp,{className:"in-chat",src:n.attachment(t,r.file),n:r.n,name:r.name,width:r.width,height:r.height,bytes:r.bytes},`image-${r.n}`):r.kind==="file"?d.jsx(Mp,{className:"in-chat",name:r.name,bytes:r.bytes,href:r.text?n.attachment(t,r.file):void 0},`file-${r.n}`):r.kind==="paste"?d.jsx(Op,{className:"in-chat",n:r.n,name:r.name,source:r.source,lines:r.lines,chars:r.chars,preview:r.preview,href:n.attachment(t,r.file)},`paste-${r.n}`):d.jsx(zp,{className:"in-chat",pick:r,worktreeId:t},`pick-${r.n}`))})}function $Z(e){const t="repoName"in e&&e.repoName?` in ${e.repoName}`:"";switch(e.kind){case"starting":return"Starting.";case"failed":return`Could not start: ${e.error}`;case"here":return"This worktree's agent does it.";case"skipped":return"Skipped: nothing happened to it.";case"dropped":return e.reason;case"sent":return`Sent to ${e.title??"the worktree"}${t}.`;case"worktree":return`A worktree of its own${t}: ${e.title??"open it from the line above its text"}.`;case"queued":return`Queued until ${e.after?e.after.kind==="branch"?e.after.branch:e.after.title:e.said??"its turn"} lands.`}}function CZ(e,t,n,r){const o=L(s=>s.visible);return E.useMemo(()=>{if(!e)return;const s=[];t!==null&&s.push({id:"plan",label:t});for(const a of AT(e)){const l=N5(e,a),u="worktreeId"in l?o.find(f=>f.worktree.id===l.worktreeId):void 0;s.push({id:a.id,lead:u?d.jsx("span",{className:`dot ${Zs(u)}`}):null,label:a.title})}if(!(s.length<2))return{items:s,current:n,onPick:r,owner:"handoff",label:"the plan and what it hands off",segmented:!0}},[e,t,n,r,o])}function AZ({tabs:e}){const t=E.useRef(null),[n,r]=E.useState({start:!1,end:!1});return ct([e.items],()=>{var l;const o=(l=t.current)==null?void 0:l.querySelector(".tabs-list");if(!o)return;const s=()=>{const u=o.scrollLeft,f=u>1,h=u+o.clientWidth<o.scrollWidth-1;r(p=>p.start===f&&p.end===h?p:{start:f,end:h})};s(),o.addEventListener("scroll",s,{passive:!0});const a=new ResizeObserver(s);return a.observe(o),()=>{o.removeEventListener("scroll",s),a.disconnect()}}),ct([e.current],()=>{var o,s;(s=(o=t.current)==null?void 0:o.querySelector('.tabs-list [data-state~="current"]'))==null||s.scrollIntoView({block:"nearest",inline:"nearest"})}),d.jsxs("div",{ref:t,className:"editor-handoff-track","data-more-start":n.start?"":void 0,"data-more-end":n.end?"":void 0,children:[d.jsx("span",{className:"editor-handoff-mark",...Nt("Handed off from this plan"),children:d.jsx(xt,{name:"handoff"})}),d.jsx(Ya,{...e})]})}function IZ({item:e,piece:t}){var o,s;const n=Mu(e,t),r="repoName"in n&&n.repoName?` in ${n.repoName}`:"";switch(n.kind){case"starting":return d.jsx("span",{className:"live-text",children:"starting"});case"failed":case"skipped":case"dropped":return d.jsx(d.Fragment,{children:$Z(n)});case"sent":return d.jsxs(d.Fragment,{children:["Sent to ",n.worktreeId?d.jsx(to,{id:n.worktreeId,title:n.title}):n.title??"the worktree",r,"."]});case"worktree":return d.jsxs(d.Fragment,{children:["A worktree of its own",r,": ",d.jsx(to,{id:n.worktreeId,title:n.title}),"."]});case"queued":return d.jsxs(d.Fragment,{children:["Queued until"," ",((o=n.after)==null?void 0:o.kind)==="branch"?d.jsx(to,{id:n.after.id,title:n.after.branch}):((s=n.after)==null?void 0:s.title)??n.said??"its turn"," ","lands."]});case"here":{const a=t.after,l=a&&"piece"in a?e.pieces.find(h=>h.id===a.piece):void 0,u=l?Mu(e,l):null,f=a&&"id"in a?d.jsx(to,{id:a.id,title:a.title}):u&&(u.kind==="worktree"||u.kind==="sent")&&u.worktreeId?d.jsx(to,{id:u.worktreeId,title:u.title??(l==null?void 0:l.title)}):l?l.title:null;return f?d.jsxs(d.Fragment,{children:["This worktree's agent does it, once ",f," lands."]}):d.jsx(d.Fragment,{children:"This worktree's agent does it."})}}}function RZ({item:e,piece:t,alone:n,worktreeId:r,path:o,version:s,openSeq:a,focus:l,onChat:u}){const f=nt(),h=T=>f==null?void 0:f.send(CT(e,r,t.id,T)),p=Xs(e,t),g=nd(e,t),y=Ou(e)?_5(t,e.pieces).filter(T=>T!==p):[],{title:w,rest:v}=E.useMemo(()=>H_(RD(t)),[t]),x=ol(`# ${w}`),N=T5(e,t,n)&&d.jsx("p",{className:"editor-piece-line hint",children:Ou(e)?d.jsxs(d.Fragment,{children:[e.stale&&"The plan changed since these were read. ",E5(t,p,g),y.length>0&&d.jsxs(d.Fragment,{children:[" ","Instead:"," ",y.map((T,j)=>d.jsxs("span",{children:[j>0&&" · ",d.jsx(Me,{variant:"inline",onClick:()=>h(T),children:T==="send"&&t.to?`send to ${t.to.title}`:x5(t,T)})]},T))]})]}):d.jsx(IZ,{item:e,piece:t})}),S=d.jsxs("div",{className:"md md-preview editor-piece-head",children:[d.jsx("div",{dangerouslySetInnerHTML:{__html:x}}),N,d.jsx(jZ,{refs:t.attachments,worktreeId:r})]});return d.jsx(pA,{text:v,path:o,worktreeId:r,version:s,openSeq:a,focus:l,onChat:u,lead:S})}function OZ(e){return`/${e.replace(/(^|\/)index\.html?$/i,"$1").split("/").map(encodeURIComponent).join("/")}`}const aS=6e4,MZ=3e3,LZ=e=>e.kind==="worktree"?`w:${e.worktreeId}:${e.path}`:e.kind==="loose"?`g:${e.grantId}`:`t:${e.text}`;function PZ({source:e,path:t,version:n,openSeq:r,focus:o}){const s=E.useRef(null);ct([r],()=>{var y;o&&((y=s.current)==null||y.focus())});const a=Mr(),[l,u]=E.useState(null),[f,h]=E.useState(null),p=E.useRef(e);p.current=e;const g=LZ(e);return E.useEffect(()=>{let y=!1,w;const v=()=>{rz(a,p.current).then(x=>{if(!y){if(x===null){w=setTimeout(v,MZ);return}if(typeof x=="string"){h(x),u(null);return}h(null),u(x.url),w=setTimeout(v,Math.max(x.ms-aS,aS))}})};return v(),()=>{y=!0,clearTimeout(w)}},[a,g,n]),d.jsx("div",{ref:s,className:"editor-viewer",tabIndex:-1,children:f!==null?d.jsx("p",{className:"hint",children:f}):l!==null&&d.jsx("iframe",{className:"editor-frame",title:t,sandbox:"allow-scripts",referrerPolicy:"no-referrer",src:l})})}function DZ({worktreeId:e,openSeq:t,focus:n}){const r=nt(),o=L(p=>{var g;return(g=Jt(p,e))==null?void 0:g.worktree.pr}),s=L(p=>{var g;return(g=Jt(p,e))==null?void 0:g.worktree.prComments}),a=L(p=>Or(p,e).prComments),l=s==null?void 0:s.version;ct([r,e,l],()=>{r==null||r.send({t:"pr-comments",worktreeId:e})});const u=E.useMemo(()=>HK(a??[]),[a]),f=OC((a==null?void 0:a.length)??0,(s==null?void 0:s.authors)??[]),h=d.jsxs("div",{className:"md md-preview pr-page",children:[d.jsx("h1",{children:o?`PR #${o.number}`:"Pull request"}),d.jsxs("p",{className:"pr-page-byline",children:[a===void 0?"reading what reviewers wrote":a.length===0?"no comments yet":d.jsxs(d.Fragment,{children:[f.count,f.rest]}),o&&d.jsxs(d.Fragment,{children:[" · ",d.jsx(Me,{variant:"inline",tone:"quiet",onClick:()=>Rr(o.url),children:"on GitHub"})]})]}),u.reviews.map(p=>d.jsx(cS,{thread:p,worktreeId:e},p.root.id)),u.files.map(p=>d.jsxs("section",{children:[p.path&&d.jsx("h2",{className:"pr-page-path",children:p.path}),p.threads.map(g=>d.jsx(cS,{thread:g,worktreeId:e},g.root.id))]},p.path))]});return d.jsx(Cv,{html:"",openSeq:t,focus:n,lead:h})}function cS({thread:e,worktreeId:t}){const n=Pn();nt();const{root:r,replies:o}=e,s=L(u=>u.activeId===t&&qa(Jt(u,t))!==null),a=Ev(r),l=r.review?d.jsx("span",{className:"pr-page-verb","data-review":r.review,children:RC(r.review)}):r.path&&a?d.jsxs(Me,{variant:"inline","data-tip":"Open the diff at this line",onClick:()=>r.path&&Rn({dispatch:n.dispatch},{worktreeId:t,path:r.path,view:"diff",...r.line?{line:{n:r.line}}:{}}),children:[r.startLine===void 0?"line":"lines"," ",a]}):null;return d.jsxs("div",{className:"pr-page-thread",children:[d.jsxs("div",{className:"pr-page-head",children:[d.jsx("span",{className:"pr-page-author",children:r.author}),l,d.jsx("span",{className:"pr-page-gap"}),d.jsx(lS,{url:r.url}),s&&d.jsx(Me,{variant:"outline",tone:"quiet","data-tip":"Put this in the message box for the agent",onClick:()=>Xf(n,{worktreeId:t,text:WK(e),name:KK(e)}),children:"add to chat"})]}),r.body&&d.jsx(uS,{text:r.body}),o.map(u=>d.jsxs("div",{className:"pr-page-reply",children:[d.jsxs("div",{className:"pr-page-head",children:[d.jsx("span",{className:"pr-page-author",children:u.author}),d.jsx("span",{className:"pr-page-gap"}),d.jsx(lS,{url:u.url})]}),d.jsx(uS,{text:u.body})]},u.id))]})}function lS({url:e}){return d.jsx(Me,{variant:"inline",tone:"quiet",onClick:()=>Rr(e),children:"GitHub"})}function uS({text:e}){const t=E.useMemo(()=>La(e),[e]);return d.jsx("div",{className:"pr-page-body",onClick:Ny,dangerouslySetInnerHTML:{__html:t}})}function zZ({text:e,path:t,openSeq:n,focus:r,full:o,onFull:s}){const a=E.useRef(null);ct([n],()=>{var u;r&&((u=a.current)==null||u.focus())});const l=E.useMemo(()=>`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`,[e]);return d.jsxs("div",{ref:a,className:"editor-viewer editor-svg",tabIndex:-1,children:[d.jsx("button",{type:"button",className:"editor-image",onClick:()=>s(!0),children:d.jsx("img",{src:l,alt:t})}),o&&d.jsx(id,{owner:"editor",onClose:()=>s(!1),children:d.jsx("img",{className:"editor-svg-full",src:l,alt:t})})]})}function FZ(){return ks(it.editorWrap,!1,e=>e===null?void 0:e==="1")}const BZ=E.lazy(async()=>{const[e]=await Promise.all([mw(()=>import("./Editor-Dq4a0gFv.js").then(t=>t.E),__vite__mapDeps([0,1,2])),mw(()=>import("./grammar-e2yQ-Xdq.js"),[]).then(t=>t.grammarsReady)]);return e});function dS({what:e}){return eT(!0,3e3)?d.jsx("div",{className:"empty",children:d.jsxs("span",{className:"live-text",children:["loading ",e]})}):null}const UZ=()=>{},HZ=[],WZ=[{id:"preview",label:"preview",tip:Nt("Preview: read it rendered")},{id:"code",label:"code",tip:Nt("Code: read and edit the text")}];function KZ({path:e,note:t,title:n,worktreeId:r}){const o=Pn(),s=Ep(),a=kN(e),l=n??a.name,u=n?"":a.dir;return d.jsxs("span",{className:"editor-title","data-tip":u||n?e:void 0,draggable:s&&!!r,onDragStart:r?f=>Pu(f,{kind:"paths",worktreeId:r,items:[{path:e,folder:!1}]}):void 0,onDragEnd:r?()=>od(o):void 0,children:[d.jsxs("span",{className:"editor-name",children:[l,t]}),u&&d.jsx("span",{className:"editor-dir row-dim",children:u})]})}function mA({editor:e,height:t,full:n=!1,onToggleFull:r,onDragStart:o,placement:s="stack"}){const a=s==="screen",l=ht(),u=Pn(),f=nt(),h=Mr(),p=wy(),g=pp(),{worktreeId:y,path:w,ref:v,since:x}=e,N=e.loose,S=(N==null?void 0:N.source.kind)==="pr-comments",T=L(Ce=>{var Pt;return((Pt=Wo(Ce))==null?void 0:Pt.id)===y}),j=L(Ce=>{var Dt,Wt;const Pt=(Dt=Jt(Ce,y))==null?void 0:Dt.worktree;return Pt?Pt.path:(Wt=Wo(Ce))==null?void 0:Wt.path}),$=v!==void 0,R=L(Ce=>{var Pt;return(Pt=Jt(Ce,y))==null?void 0:Pt.worktree.plan}),A=!N&&!$&&R===w,I=vv(A?y:void 0,A?w:void 0),M=L(Ce=>h5(Or(Ce,y).chat??HZ,w,R)),P=$||N||e.view!=="preview"?null:M,[F,q]=E.useState(null);ct([P==null?void 0:P.id,w],()=>q(null)),ct([e.seq],()=>{e.piece&&q(e.piece)});const W=!!P&&!m5(P),ee=P?F!==null&&(F==="plan"?W:P.pieces.some(Ce=>Ce.id===F))?F:j5(P,W):"plan",V=P&&ee!=="plan"?P.pieces.find(Ce=>Ce.id===ee)??null:null,te=CZ(P,W?"Plan":null,ee,q),K=E.useMemo(()=>N?uZ(N.source,w,Ce=>l({a:"editor-refused",file:{worktreeId:y,path:w},message:Ce}),cZ(f?Ce=>f.send(Ce):null)):(p==null?void 0:p.bind({worktreeId:y,path:w,...v?{ref:v}:{},...x?{since:x}:{}}))??aA,[p,y,w,v,x,N,l,f]),C=L(Ce=>Or(Ce,y).changedRanges[w]);E.useEffect(()=>{!C&&!$&&!T&&!N&&(f==null||f.send({t:"changed-ranges",worktreeId:y,path:w}))},[y,w,C,$,T,N,f]);const oe=(C==null?void 0:C.offset)??0,U=e.disk,B=Wa(w),Q=e.view??(B==="markdown"?"preview":"diff"),ue=!!U&&(U.before===""||U.before===U.after),he=(N==null?void 0:N.source.kind)==="grant"?N.source:null,Ne=$||T||N&&!he?null:P4(w),[De,Be]=E.useState(!1),Z=Ne==="image"||Q==="preview"&&B==="svg"&&!!U&&!U.binary&&!U.tooLarge,[J,pe]=FZ(),de=!!U&&!S&&!Ne&&!U.binary&&!U.tooLarge&&Q!=="preview",ie=Q==="preview"&&B==="markdown"&&!!U&&!S&&!Ne&&!U.binary&&!U.tooLarge&&!ue&&!V,ye=ie&&e.marks,_e=!S&&!Ne&&!(U&&(U.binary||U.tooLarge)),be=_e&&!!B,$e=_e&&!N&&!ue&&(Q!=="preview"||ie),Ze=Q==="preview"?ye:Q==="diff",rt=Ce=>l(Q==="preview"?{a:"editor-marks",v:Ce}:{a:"editor-view",v:Ce?"diff":"file"}),en=Ce=>{Ce!==(Q==="preview"?"preview":"code")&&l(Ce==="preview"?{a:"editor-view",v:"preview",marks:Q==="diff"}:{a:"editor-view",v:ue||N||ie&&!ye?"file":"diff"})},[Xt,Et]=fZ(),Ke=E.useRef(null),Qt=e6(Ke,QE),Ot=E.useRef(!1),Zt=L(Ce=>Ce.layout.chat);ct([Zt],()=>{Zt&&(Ot.current=!1)});const Ge=E.useCallback(()=>{if(!Ot.current)return;Ot.current=!1;const Ce=u.getState();!Ce.layout.chat&&!Co(Ce)&&l({a:"show-chat"})},[u,l]),nn=Ce=>{var Wt;if(Et(Ce),!Ce){Ge();return}const Pt=u.getState(),Dt=((Wt=Ke.current)==null?void 0:Wt.clientWidth)??Number.POSITIVE_INFINITY;Pt.layout.chat&&!Co(Pt)&&!Ui(Pt)&&Dt<QE&&(Ot.current=!0,l({a:"toggle-chat"}))};E.useEffect(()=>Ge,[Ge]);const pn=Ce=>{if(Ce==="file"){rt(!1),Ge();return}Ze||rt(!0),nn(Ce==="split")},It=e.line&&!e.line.fiber?e.line.n:void 0,Vt=L(Ce=>{var Pt;return((Pt=Iu(Ce))==null?void 0:Pt.worktreeId)===y})&&!a&&!$&&!T&&!N&&B==="html",Cn=()=>{fn.post(y,{type:"navigate",path:OZ(w)}),Ui(u.getState())?l({a:"zen-page"}):n&&(r==null||r())};return d.jsxs(Zy,{kind:"editor",className:We("editor-pane",n&&"full"),height:n||a?void 0:t,resizable:!n&&!a,onDragStart:o??UZ,title:d.jsx(KZ,{path:w,note:$?` at ${v==null?void 0:v.slice(0,7)}`:x?", last turn":void 0,title:A&&I?I:void 0,worktreeId:N?void 0:y}),menu:()=>j&&!N?Hs({id:y,dir:j},w,{discard:!$&&!T,kept:T,ref:v,showing:e.view??void 0,noDiff:ue},{sock:f,dispatch:l}):[],onClose:()=>l({a:"close-editor"}),full:n,onToggleFull:a?void 0:r,actions:d.jsxs(d.Fragment,{children:[be&&d.jsx("span",{className:"editor-pair",children:d.jsx(Ya,{items:WZ,current:Q==="preview"?"preview":"code",onPick:en,segmented:!0,dense:!0,font:"mono",label:"the page or its text",owner:"pane"})}),Z&&d.jsxs(Me,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>Be(!0),"data-tip":"Full size: see the picture over the window",children:[d.jsx(xt,{name:"zen",className:"icon-inline"})," full size"]}),$e&&d.jsx(hZ,{at:Ze?Xt&&!a?"split":"inline":"file",onPick:pn,columns:!a}),Vt&&d.jsxs(Me,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:Cn,"data-tip":"Run: open the page in the preview, with its scripts on",children:[d.jsx(xt,{name:"run",className:"icon-inline"})," run"]}),de&&d.jsx(Tt,{icon:"wrap",tone:"chrome",on:J,"aria-pressed":J,label:"Wrap lines: fold a long line at the pane's edge",onClick:()=>pe(!J)})]}),children:[U&&d.jsx(qZ,{editor:e,disk:U,files:p}),te&&d.jsx(AZ,{tabs:te}),d.jsx("div",{className:"editor-body",ref:Ke,children:S?d.jsx(DZ,{worktreeId:y,openSeq:e.seq,focus:e.focus}):U?Ne?d.jsx(kZ,{kind:Ne,src:he?h.loose(he.id,he.version):h.worktreeFile(y,w,U.version),path:w,openSeq:e.seq,focus:e.focus,full:De,onFull:Be}):U.binary?d.jsx("div",{className:"empty",children:"not a text file: open it in another editor"}):U.tooLarge?d.jsx("div",{className:"empty",children:"too large to open here: open it in another editor"}):Q==="preview"&&P&&V?d.jsx(RZ,{item:P,piece:V,alone:!te,worktreeId:y,path:w,version:$||T||N?void 0:U.version,openSeq:e.seq,focus:e.focus,onChat:Ce=>Xf(u,{worktreeId:y,text:Ce,name:w})}):Q==="preview"&&B==="svg"?d.jsx(zZ,{text:U.after,path:w,openSeq:e.seq,focus:e.focus,full:De,onFull:Be}):Q==="preview"&&B==="html"?d.jsx(PZ,{source:he?{kind:"loose",grantId:he.id}:$||T||N?{kind:"text",text:U.after}:{kind:"worktree",worktreeId:y,path:w},path:w,version:U.version,openSeq:e.seq,focus:e.focus}):Q==="preview"?d.jsx(pA,{text:U.after,before:ie?U.before:void 0,marks:ye,split:Xt&&Qt&&!a,path:w,worktreeId:y,version:$||T||N?void 0:U.version,openSeq:e.seq,focus:e.focus,onChat:Ce=>Xf(u,{worktreeId:y,text:Ce,name:w})}):d.jsx(Py,{pane:!0,children:d.jsx(E.Suspense,{fallback:d.jsx(dS,{what:Q}),children:d.jsx(BZ,{file:{worktreeId:y,path:w,...v?{ref:v}:{},...x?{since:x}:{}},disk:U,blame:e.blame,view:Q,openSeq:e.seq,line:It,focus:e.focus,readOnly:$||!U.writable||a,numbers:!a,wrap:J,split:Xt,theme:g,sync:K,onCopy:N?void 0:(Ce,Pt,Dt)=>L6(Dt,{worktreeId:y,path:Ce,...Pt,...v?{ref:v}:{}}),onChat:(Ce,Pt)=>Xf(u,Pt&&(N?{worktreeId:y,text:Pt.text,name:Ce}:{worktreeId:y,text:Pt.text,source:{path:Ce,startLine:Pt.startLine,endLine:Pt.endLine,...v?{ref:v}:{}}})),onNew:()=>u.dispatch({a:"open-draft"}),onLineHover:$||N?void 0:Ce=>{Ce==null?fn.post(y,{type:"highlight-clear"}):fn.post(y,{type:"highlight-file",path:w,ranges:[[Ce+oe,Ce+oe]]})}},`${y}
272
- ${N?"loose":v??x??""}
273
- ${w}`)})}):d.jsx(dS,{what:w},w)})]})}function qZ({editor:e,disk:t,files:n}){var f,h;const{worktreeId:r,path:o,ref:s,since:a,conflict:l}=e,u={worktreeId:r,path:o,...s?{ref:s}:{},...a?{since:a}:{}};if(l){const p=l.version===null;return d.jsxs("div",{className:"editor-note",children:[d.jsx("span",{className:"editor-note-text",children:p?"deleted on disk; your edits are not saved":"changed on disk; your edits are not saved"}),d.jsx(Me,{variant:"outline",onClick:()=>n==null?void 0:n.reload(u),"data-tip":p?"Close the file; your edits go with it":"Take the file as it is on disk; undo brings your edits back",children:p?"close":"reload"}),d.jsx(Me,{variant:"outline",tone:"danger",onClick:()=>n==null?void 0:n.keepMine(u),"data-tip":p?"Save your edits as the file again":"Save your edits over the file on disk",children:"keep mine"})]})}return e.refused?d.jsx("div",{className:"editor-note",children:d.jsx("span",{className:"hint",children:e.refused})}):((f=e.loose)==null?void 0:f.source.kind)==="pr-comments"?null:((h=e.loose)==null?void 0:h.source.kind)==="text"&&!t.writable?d.jsx("div",{className:"editor-note",children:d.jsx("span",{className:"hint",children:"read-only: the message as it was sent, kept in the chat and not in a file"})}):e.loose&&!t.writable&&!t.tooLarge&&!t.binary?d.jsx("div",{className:"editor-note",children:d.jsxs("span",{className:"hint",children:["read-only: ",o," is not in a project; drop it on a folder in files to add it"]})}):s===void 0&&!t.writable&&!t.binary&&!t.tooLarge?d.jsx("div",{className:"editor-note",children:d.jsx("span",{className:"hint",children:"read-only: Toyon does not run this worktree"})}):null}function gA(e,t,n=!1){var o;const r=((o=t.find(s=>s.id===(e==null?void 0:e.repoId)))==null?void 0:o.defaultBranch)??"the default branch";return e!=null&&e.building?{text:`Rebuilding Toyon from ${r}`,busy:!0}:e!=null&&e.buildFailed?{text:"Rebuilding Toyon stopped",detail:e.buildFailed,build:"try again",busy:!1}:e!=null&&e.rebuild?{text:`Toyon's shell is behind ${r}`,build:"rebuild",busy:!1}:e!=null&&e.restart?{text:n?`Toyon itself is behind ${r}; this page reloads once it has restarted`:`Toyon itself is behind ${r}`,restart:!0,busy:!1}:n?{text:"Toyon's shell was rebuilt while this page was open",reload:!0,busy:!1}:null}const ZZ=(e,t)=>{const n=gk(t);switch(e){case"npm":case"bun":return`installed with ${e}. A newer version from ${n} installs itself when nothing is busy; press to check now and install one if it is out`;case"npx":return`run with npx, which fetches the newest version from ${n} itself. Press to check for one now`;case"none":return"run from a checkout, which does not update itself. Press to check for a newer release"}},GZ="https://toyon.dev",Lh="https://github.com/toyon-dev/toyon",VZ=e=>`${Lh}/releases/tag/v${e}`,YZ=`${Lh}/releases/latest`,XZ=4e3;function QZ(e,t,n,r){if(r==="asking")return{value:`${e} checking`,text:`Asking ${gk(n)} for the newest version`,act:"check",busy:!0};const o=gk(r.registry),s={act:"check",busy:!1};if(r.latest===null)return{...s,value:`${e} no answer`,text:`Could not reach ${o}. Press to ask again`,settles:!0};if(X_(r.latest,e)){const a=t==="none"?"This copy runs from a checkout, so pull to get it":t==="npx"?`This copy runs with npx, so run npx toyon@${r.latest} to use it`:"It installs once no chat is replying";return{...s,value:`${r.latest} out`,text:`Toyon ${r.latest} is out. ${a}`}}return{...s,value:`${e} up to date`,text:`Toyon ${e} is the newest version ${o} lists. Press to ask again`,settles:!0}}function JZ(e,t,n,r,o,s=!1,a=null,l=null){if(n){if(n.restarting){const f=n.installed??n.running,h=n.restarting.length>0?tj(n.restarting):"Toyon is restarting; this page reloads when it is back";return{value:`${f} restarting`,text:h,act:"restart",busy:!0}}if(n.installing){const f=n.latest??n.installed??n.running;return{value:`${f} installing`,text:`Installing Toyon ${f}`,act:"update",busy:!0}}if(n.failed){const f=n.failed.line.replace(/\.$/,"");return{value:`${n.running} update failed`,text:`Installing Toyon ${n.failed.version} stopped: ${f}. Press to try again, or run ${n.failed.command}`,act:"update",busy:!1}}if(n.installed)return{value:`${n.installed} ready`,text:`Toyon ${n.installed} is installed and ${n.running} is still running. It restarts onto the new one when nothing is busy; press to restart now`,act:"restart",busy:!1};if(n.latest)return{value:`${n.latest} out`,text:n.method==="npx"?`Toyon ${n.latest} is out. This copy runs with npx, so run npx toyon@${n.latest} to use it`:`Toyon ${n.latest} is out and installs when nothing is busy; press to install now`,act:"update",busy:!1}}const u=gA(r,o,s);return u?u.busy?{value:`${e} rebuilding`,text:u.text,act:"rebuild",busy:!0}:u.reload?{value:`${e} rebuilt`,text:u.text,act:"reload",busy:!1}:u.build==="try again"?{value:`${e} rebuild stopped`,text:u.text,detail:u.detail,act:"rebuild",busy:!1}:{value:`${e} behind`,text:u.text,act:u.build?"rebuild":"restart",busy:!1}:l?QZ(e,t,a,l):{value:e,text:`Toyon ${e}, ${ZZ(t,a)}`,act:"check",busy:!1}}function eG(e,t,n){const r=o=>()=>Rr(o);return Un([t?[{id:"check-update",label:"check for updates",...t.off?{disabled:t.off}:{},onClick:t.run}]:[],[n?{id:"release-notes",label:"release notes",onClick:n}:{id:"release-notes",label:`release notes for ${e}`,onClick:r(VZ(e))},{id:"latest-release",label:"latest release",onClick:r(YZ)},{id:"site",label:"toyon.dev",onClick:r(GZ)},{id:"repo",label:"Toyon on GitHub",onClick:r(Lh)},{id:"report",label:"report a problem",onClick:r(`${Lh}/issues/new`)}],[{id:"copy-version",label:"copy version",onClick:()=>sn(e)}]])}const tG=bR.map(e=>({title:e,rows:SR(e).map(t=>[Ht(t),yu[t].label])}));function nG(){const e=ht(),t=nt(),n=xn("keys"),r=L(g=>g.themePrefs),o=L(g=>g.themes),s=L(g=>g.chatSide),a=L(g=>g.keepAwake),l=ky(),u=L(g=>g.agents),f=hl(),h=L(g=>g.rows),p=g=>{e({a:"palette-return",v:{mode:"keys",q:""}}),e(g)};return d.jsxs(Wu,{bare:!0,boxClass:"keys-stack",id:"keys-help",onClose:()=>e({a:"close"}),children:[d.jsxs("div",{className:"keys-card",children:[d.jsxs("div",{children:[f&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"section-title keys-h",children:f.name}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"processes"}),d.jsx(Me,{variant:"field",mono:!0,className:"keys-chip","data-tip":`edit the install + start commands in ${f.configFile}`,onClick:()=>e({a:"open",overlay:{kind:"setup",repoId:f.id}}),...n.contextMenu(()=>Np(f,f.id,{sock:t,dispatch:e},h)),children:d.jsx("span",{className:"keys-v",children:Object.keys(f.config.run).join(" + ")||"not set up"})})]})]}),d.jsx("div",{className:"section-title keys-h",children:"Agents"}),u.map(g=>d.jsx(sG,{agent:g},g.id))]}),d.jsxs("div",{children:[d.jsx("div",{className:"section-title keys-h",children:"Appearance"}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"mode"}),d.jsx(Me,{variant:"field",mono:!0,onClick:()=>p({a:"open",overlay:{kind:"appearance"}}),children:xh[r.mode]})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"theme"}),d.jsx(Me,{variant:"field",mono:!0,onClick:()=>p({a:"open",overlay:{kind:"theme",slot:"theme"}}),children:ip(r,o,l).name})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"chat side"}),d.jsx(Me,{variant:"field",mono:!0,onClick:()=>e({a:"toggle-chat-side"}),children:s})]}),d.jsx("div",{className:"section-title keys-h",children:"Toyon"}),a!==null&&d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"keep awake"}),d.jsx(Me,{variant:"field",mono:!0,onClick:()=>p({a:"open",overlay:{kind:"keep-awake"}}),children:Eh[a]})]}),d.jsx(rG,{}),d.jsx(oG,{})]})]}),d.jsx("div",{className:"keys-card",children:tG.map(g=>d.jsxs("div",{children:[d.jsx("div",{className:"section-title keys-h",children:g.title}),g.rows.map(([y,w])=>d.jsxs("div",{className:"keys-row",children:[d.jsx(ss,{k:y}),d.jsx("span",{className:"keys-d",children:w})]},y))]},g.title))})]})}function rG(){const e=nt(),t=ht(),n=xn("keys"),r=L(T=>T.version),o=L(T=>T.install),s=L(T=>T.registry),a=L(T=>T.update),l=L(T=>T.self),u=L(T=>T.rebuilt),f=L(T=>T.repos),h=L(T=>T.managed.updates),p=L(T=>T.updateCheck),g=L(T=>T.frame),y=L(T=>T.newProject!==null),w=JZ(r,o,a,l,f,u,s,p),v=!h&&(w.act==="update"||w.act==="check"),x=w.settles&&p&&p!=="asking"?p:null;E.useEffect(()=>{if(!x)return;const T=()=>t({a:"update-check-settle",check:x}),j=setTimeout(T,XZ);return()=>{clearTimeout(j),T()}},[x,t]);const N=()=>{w.act==="restart"?e==null||e.send({t:"restart-daemon"}):w.act==="reload"?window.location.reload():w.act==="rebuild"&&l?e==null||e.send({t:"run-after-land",repoId:l.repoId}):w.act==="update"?e==null||e.send({t:"update-now"}):w.act==="check"&&e&&(t({a:"update-check"}),e.send({t:"check-update"}))},S=()=>eG(r,w.act==="check"&&!w.busy?{run:N,...v?{off:"managed by your organization"}:{}}:null,g==="phone"||y?void 0:()=>t({a:"open-release-notes"}));return d.jsxs("div",{className:"keys-setting",...n.contextMenu(S),children:[d.jsx("span",{className:"keys-d",children:"version"}),d.jsx(Me,{variant:"field",mono:!0,busy:w.busy,disabled:v,onClick:N,...Nt(v?"updates are managed by your organization":w.text,void 0,{detail:w.detail}),children:w.value})]})}function oG(){const e=L(n=>n.managed);if(e.source===null)return null;const t=e.problem?"the policy file on this machine is invalid, so everything it governs is off; toyon doctor says why":`managed by your organization: ${wD(e).join(", ")||"nothing turned off"}`;return d.jsx("div",{className:"hint",children:t})}function kA(e){return e.available?e.auth?e.auth.kind==="none"?"not logged in":e.auth.label:e.checkFailed?"not ready":"ready":e.installing?"installing":"not installed"}function wA(e){var n,r;return e.available?e.checkFailed?e.checkFailed:e.auth?[e.auth.detail,(n=e.auth.account)==null?void 0:n.email,(r=e.auth.account)==null?void 0:r.organization].filter(Boolean).join(" · ")||e.auth.label:"installed; it names the account it runs on the first time it runs":Bp(e)}function sG({agent:e}){const t=ht(),n=nt(),r=xn("keys");return d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:e.name}),d.jsx(Me,{variant:"field",mono:!0,"data-tip":wA(e),...r.contextMenu(()=>bv(e,{sock:n})),onClick:()=>{t({a:"palette-return",v:{mode:"keys",q:""}}),t({a:"open",overlay:{kind:"agent-page",agent:e.id}})},children:kA(e)})]})}function iG({agentId:e}){const t=ht(),n=nt(),r=hl(),o=L(g=>g.home),s=L(g=>g.agents.find(y=>y.id===e)??null),a=L(g=>g.agentConfigs[e]??null),l=xn("keys");if(E.useEffect(()=>{n==null||n.send({t:"agent-config",agent:e,...r?{repoId:r.id}:{}})},[n,e,r]),iA(n,e,s??void 0),!s)return null;const u=bv(s,{sock:n}),f=()=>t({a:"close",back:!0}),h=g=>o&&g.startsWith(`${o}/`)?`~${g.slice(o.length)}`:g,p=g=>n==null?void 0:n.send({t:"reveal-agent-file",agent:e,file:g.id,...r?{repoId:r.id}:{}});return d.jsx(Wu,{bare:!0,boxClass:"keys-stack",onClose:f,children:d.jsxs("div",{className:"keys-card keys-settings",children:[d.jsx("div",{className:"agent-page-back",children:d.jsx(Tt,{icon:"back",label:"back to settings",hint:"esc",onClick:f})}),d.jsx("div",{className:"section-title keys-h",children:s.name}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"signed in"}),d.jsx(Me,{variant:"field",mono:!0,"data-tip":wA(s),disabled:u.length===0,...l.dropdown(()=>u,"right"),children:kA(s)})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"commit messages"}),d.jsx("span",{className:"keys-d",children:s.quick?"its quick model writes one after each turn":"none: it offers no small model, so you write them in the changes panel"})]}),d.jsx("div",{className:"section-title keys-h",children:"MCP servers it will load"}),a===null?d.jsx("div",{className:"keys-setting",children:d.jsx("span",{className:"keys-d live-text",children:"reading"})}):a.servers.length===0?d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"none configured"}),d.jsx("span",{className:"keys-d",children:"add one with the agent's own CLI, or a .mcp.json in the repo"})]}):a.servers.map(g=>d.jsx(aG,{s:g},`${g.scope}:${g.name}`)),a&&a.files.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"section-title keys-h",children:"the files it reads"}),a.files.map(g=>d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:g.label}),g.exists?d.jsx(Me,{variant:"field",mono:!0,"data-tip":`reveal ${h(g.path)} in Finder`,onClick:()=>p(g),children:h(g.path)}):d.jsxs("span",{className:"keys-d",children:["not present: ",h(g.path)]})]},g.id))]})]})})}function aG({s:e}){return d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{children:e.name}),d.jsx("span",{className:"keys-d",children:e.detail?`${e.scope} · ${e.detail}`:e.scope})]})}function cG(){const e=ht(),t=nt(),n=L(o=>o.agents),r=L(o=>o.defaultAgent);return d.jsx(qr,{items:n,filter:(o,s)=>o.filter(a=>os(s,a.name,a.id)),rowClass:o=>o.available?"picker-row":"picker-row dim",keyOf:o=>o.id,initialIndex:o=>Math.max(0,o.findIndex(s=>s.id===r)),onPick:o=>{o.available&&(t==null||t.send({t:"set-default-agent",agent:o.id}),e({a:"close"}))},onBack:()=>e({a:"close",back:!0}),rowMenu:o=>bv(o,{sock:t}),placeholder:"default agent for new worktrees",row:o=>d.jsx(In,{label:o.name,current:o.id===r,hint:o.available?o.checkFailed??(o.sandboxed?void 0:"unsandboxed"):Bp(o)})})}const lG=["dark","light","system","daylight"],uG=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"});function dG(){const e=ht(),t=nt(),n=L(u=>u.themePrefs),r=L(u=>u.themes),o=ky(),s=L(u=>u.daylight),a=u=>{var f;return((f=r.find(h=>h.id===n[Vw({...n,mode:u},o)]))==null?void 0:f.name)??""},l=u=>{if(u==="system")return`${o.system?"dark":"light"} now · ${a(u)}`;if(u!=="daylight")return a(u);const f=s&&s.until>Date.now()?` · ${o.daylight?"light":"dark"} at ${uG.format(s.until)}`:"";return`${o.daylight?"dark":"light"} now${f} · ${a(u)}`};return d.jsx(qr,{items:lG,filter:(u,f)=>u.filter(h=>os(f,xh[h])),rowClass:()=>"picker-row",keyOf:u=>u,initialIndex:u=>u.indexOf(n.mode),onActive:u=>e({a:"preview-theme",theme:u?ip({...n,mode:u},r,o):null}),onPick:u=>{t==null||t.send({t:"set-theme",prefs:{...n,mode:u}}),e({a:"close"})},onBack:()=>e({a:"close",back:!0}),placeholder:"light/dark mode",keys:{nav:"preview",pick:"keeps",back:"reverts"},row:u=>d.jsx(In,{label:xh[u],current:u===n.mode,hint:l(u)})})}const fG=2,yw=e=>Z_(e).join(" ").length<fG,hG=e=>({kind:"chat",id:e.id,name:e.name,hint:e.branch??"",fields:[e.name,e.branch??""]}),pG=e=>({kind:"chat",id:e.id,name:e.title,hint:Cj(e),fields:[e.title,e.branch],prompt:e.prompt,archived:e});function mG(e,t,n){const r=Z_(t),o=n==="all"&&!yw(t);return e.filter(s=>{if(s.kind==="hit")return o;const a=n==="names"&&s.prompt?[...s.fields,s.prompt]:s.fields;return r.every(l=>a.some(u=>u.toLowerCase().includes(l)))})}const gG=e=>e.flatMap(([t,n])=>Array.from({length:n},(r,o)=>t+o));function kG({repoId:e,scope:t}){const n=ht(),r=nt(),o=L(j=>j.clientId),s=L(j=>j.frame),a=L(j=>j.chats[e]),l=xy(),u=L(j=>j.archived[e]),[f,h]=E.useState(t),p=E.useCallback(()=>h(j=>j==="all"?"names":"all"),[]);E.useEffect(()=>{r==null||r.send({t:"list-archived",repoId:e})},[r,e]);const g=E.useMemo(()=>[...l.filter(j=>!Tr(j.worktree)).map(hG),...(u??[]).map(pG)],[l,u]),y=E.useMemo(()=>new Map(g.map(j=>[j.id,j])),[g]),w=E.useMemo(()=>[...g,...((a==null?void 0:a.hits)??[]).map(j=>({kind:"hit",hit:j}))],[g,a]),v=E.useMemo(()=>{const j=new Map;for(const $ of(a==null?void 0:a.hits)??[])j.set($.worktreeId,Math.max(j.get($.worktreeId)??0,$.ts));return j},[a]),x=E.useCallback((j,$)=>mG(j,$,f),[f]),N=E.useCallback(j=>{f==="all"&&!yw(j)&&(r==null||r.send({t:"search-chats",repoId:e,query:j.trim()}))},[r,e,f]),S=j=>!a||a.query!==j.trim(),T=j=>f==="all"&&!yw(j);return d.jsx(qr,{items:w,filter:x,onQuery:N,onTab:p,trailing:d.jsx(Me,{tone:"chrome",on:f==="names","aria-pressed":f==="names",onClick:p,children:"names only"}),keyOf:j=>j.kind==="hit"?`h:${j.hit.worktreeId}:${j.hit.seq}`:`w:${j.id}`,rowClass:j=>j.kind==="hit"?"chats-hit":We("picker-row",j.archived&&!j.archived.restorable&&"dim"),rowTitle:j=>{var $;return j.kind==="hit"?j.hit.text:(($=j.archived)==null?void 0:$.prompt)??j.name},groupOf:j=>j.kind==="hit"?`h:${j.hit.worktreeId}`:j.archived?"archived":"open",groupHead:(j,$)=>{if(!j.startsWith("h:"))return`${j} · ${$}`;const R=j.slice(2),A=y.get(R),I=a==null?void 0:a.asks[R],M=v.get(R)??0;return d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"chats-name",children:[(A==null?void 0:A.name)??"a worktree",(A==null?void 0:A.archived)&&d.jsxs(d.Fragment,{children:[" ",d.jsx("span",{className:"row-dim",children:"archived"})]})]}),M>0&&d.jsx("span",{className:"picker-group-tail",children:dr(M)}),I&&d.jsx("span",{className:"picker-group-line",children:Sp(I,mj*2)})]})},headAlone:!0,onPick:j=>{const $=j.kind==="hit"?j.hit.worktreeId:j.id,R=j.kind==="hit"?j.hit.archived:!!j.archived;n(R?{a:"open-archived",id:$}:{a:"activate",id:$}),j.kind==="hit"&&n({a:"reveal",id:$,seq:j.hit.seq}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:j=>j.kind==="chat"&&j.archived?Jf(j.archived,{clientId:o,frame:s},{sock:r,dispatch:n}):[],placeholder:f==="names"?"find a chat by name…":"search in chats…",keys:j=>({nav:"moves",tab:f==="names"?"searches messages too":"searches names only",pick:j?j.kind==="hit"?"opens the chat there":"opens its chat":void 0,back:"closes"}),empty:j=>j.trim()?T(j)?S(j)?d.jsx("span",{className:"live-text",children:"searching"}):"no chat says that":"no chat is named that":u?"no chats yet":d.jsx("span",{className:"live-text",children:"looking"}),footer:(j,$)=>{const R=$.filter(A=>A.kind==="hit").length;return a!=null&&a.truncated&&!S(j)&&R>0?d.jsxs("div",{className:"empty",children:["showing the first ",R,"; narrow the search"]}):null},row:j=>j.kind==="chat"?d.jsx(In,{label:j.name,hint:j.hint}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"chats-text",children:al(j.hit.text,gG(j.hit.match),0)}),d.jsxs("span",{className:"chats-said row-dim",children:[j.hit.role==="user"?"you":"the agent",j.hit.ts>0&&dr(j.hit.ts)!==dr(v.get(j.hit.worktreeId)??0)?` · ${dr(j.hit.ts)}`:""]})]})})}const ml=function(e,t){let o=e;const s=ku[t];let a=null,l=0,u=null;const f=[],h={},p=function(A,I){l=o*4+17,a=(function(M){const P=new Array(M);for(let F=0;F<M;F+=1){P[F]=new Array(M);for(let q=0;q<M;q+=1)P[F][q]=null}return P})(l),g(0,0),g(l-7,0),g(0,l-7),v(),w(),N(A,I),o>=7&&x(A),u==null&&(u=j(o,s,f)),S(u,I)},g=function(A,I){for(let M=-1;M<=7;M+=1)if(!(A+M<=-1||l<=A+M))for(let P=-1;P<=7;P+=1)I+P<=-1||l<=I+P||(0<=M&&M<=6&&(P==0||P==6)||0<=P&&P<=6&&(M==0||M==6)||2<=M&&M<=4&&2<=P&&P<=4?a[A+M][I+P]=!0:a[A+M][I+P]=!1)},y=function(){let A=0,I=0;for(let M=0;M<8;M+=1){p(!0,M);const P=$i.getLostPoint(h);(M==0||A>P)&&(A=P,I=M)}return I},w=function(){for(let A=8;A<l-8;A+=1)a[A][6]==null&&(a[A][6]=A%2==0);for(let A=8;A<l-8;A+=1)a[6][A]==null&&(a[6][A]=A%2==0)},v=function(){const A=$i.getPatternPosition(o);for(let I=0;I<A.length;I+=1)for(let M=0;M<A.length;M+=1){const P=A[I],F=A[M];if(a[P][F]==null)for(let q=-2;q<=2;q+=1)for(let W=-2;W<=2;W+=1)q==-2||q==2||W==-2||W==2||q==0&&W==0?a[P+q][F+W]=!0:a[P+q][F+W]=!1}},x=function(A){const I=$i.getBCHTypeNumber(o);for(let M=0;M<18;M+=1){const P=!A&&(I>>M&1)==1;a[Math.floor(M/3)][M%3+l-8-3]=P}for(let M=0;M<18;M+=1){const P=!A&&(I>>M&1)==1;a[M%3+l-8-3][Math.floor(M/3)]=P}},N=function(A,I){const M=s<<3|I,P=$i.getBCHTypeInfo(M);for(let F=0;F<15;F+=1){const q=!A&&(P>>F&1)==1;F<6?a[F][8]=q:F<8?a[F+1][8]=q:a[l-15+F][8]=q}for(let F=0;F<15;F+=1){const q=!A&&(P>>F&1)==1;F<8?a[8][l-F-1]=q:F<9?a[8][15-F-1+1]=q:a[8][15-F-1]=q}a[l-8][8]=!A},S=function(A,I){let M=-1,P=l-1,F=7,q=0;const W=$i.getMaskFunction(I);for(let ee=l-1;ee>0;ee-=2)for(ee==6&&(ee-=1);;){for(let V=0;V<2;V+=1)if(a[P][ee-V]==null){let te=!1;q<A.length&&(te=(A[q]>>>F&1)==1),W(P,ee-V)&&(te=!te),a[P][ee-V]=te,F-=1,F==-1&&(q+=1,F=7)}if(P+=M,P<0||l<=P){P-=M,M=-M;break}}},T=function(A,I){let M=0,P=0,F=0;const q=new Array(I.length),W=new Array(I.length);for(let K=0;K<I.length;K+=1){const C=I[K].dataCount,oe=I[K].totalCount-C;P=Math.max(P,C),F=Math.max(F,oe),q[K]=new Array(C);for(let ue=0;ue<q[K].length;ue+=1)q[K][ue]=255&A.getBuffer()[ue+M];M+=C;const U=$i.getErrorCorrectPolynomial(oe),Q=Vu(q[K],U.getLength()-1).mod(U);W[K]=new Array(U.getLength()-1);for(let ue=0;ue<W[K].length;ue+=1){const he=ue+Q.getLength()-W[K].length;W[K][ue]=he>=0?Q.getAt(he):0}}let ee=0;for(let K=0;K<I.length;K+=1)ee+=I[K].totalCount;const V=new Array(ee);let te=0;for(let K=0;K<P;K+=1)for(let C=0;C<I.length;C+=1)K<q[C].length&&(V[te]=q[C][K],te+=1);for(let K=0;K<F;K+=1)for(let C=0;C<I.length;C+=1)K<W[C].length&&(V[te]=W[C][K],te+=1);return V},j=function(A,I,M){const P=fS.getRSBlocks(A,I),F=hS();for(let W=0;W<M.length;W+=1){const ee=M[W];F.put(ee.getMode(),4),F.put(ee.getLength(),$i.getLengthInBits(ee.getMode(),A)),ee.write(F)}let q=0;for(let W=0;W<P.length;W+=1)q+=P[W].dataCount;if(F.getLengthInBits()>q*8)throw"code length overflow. ("+F.getLengthInBits()+">"+q*8+")";for(F.getLengthInBits()+4<=q*8&&F.put(0,4);F.getLengthInBits()%8!=0;)F.putBit(!1);for(;!(F.getLengthInBits()>=q*8||(F.put(236,8),F.getLengthInBits()>=q*8));)F.put(17,8);return T(F,P)};h.addData=function(A,I){I=I||"Byte";let M=null;switch(I){case"Numeric":M=wG(A);break;case"Alphanumeric":M=yG(A);break;case"Byte":M=vG(A);break;case"Kanji":M=bG(A);break;default:throw"mode:"+I}f.push(M),u=null},h.isDark=function(A,I){if(A<0||l<=A||I<0||l<=I)throw A+","+I;return a[A][I]},h.getModuleCount=function(){return l},h.make=function(){if(o<1){let A=1;for(;A<40;A++){const I=fS.getRSBlocks(A,s),M=hS();for(let F=0;F<f.length;F++){const q=f[F];M.put(q.getMode(),4),M.put(q.getLength(),$i.getLengthInBits(q.getMode(),A)),q.write(M)}let P=0;for(let F=0;F<I.length;F++)P+=I[F].dataCount;if(M.getLengthInBits()<=P*8)break}o=A}p(!1,y())},h.createTableTag=function(A,I){A=A||2,I=typeof I>"u"?A*4:I;let M="";M+='<table style="',M+=" border-width: 0px; border-style: none;",M+=" border-collapse: collapse;",M+=" padding: 0px; margin: "+I+"px;",M+='">',M+="<tbody>";for(let P=0;P<h.getModuleCount();P+=1){M+="<tr>";for(let F=0;F<h.getModuleCount();F+=1)M+='<td style="',M+=" border-width: 0px; border-style: none;",M+=" border-collapse: collapse;",M+=" padding: 0px; margin: 0px;",M+=" width: "+A+"px;",M+=" height: "+A+"px;",M+=" background-color: ",M+=h.isDark(P,F)?"#000000":"#ffffff",M+=";",M+='"/>';M+="</tr>"}return M+="</tbody>",M+="</table>",M},h.createSvgTag=function(A,I,M,P){let F={};typeof arguments[0]=="object"&&(F=arguments[0],A=F.cellSize,I=F.margin,M=F.alt,P=F.title),A=A||2,I=typeof I>"u"?A*4:I,M=typeof M=="string"?{text:M}:M||{},M.text=M.text||null,M.id=M.text?M.id||"qrcode-description":null,P=typeof P=="string"?{text:P}:P||{},P.text=P.text||null,P.id=P.text?P.id||"qrcode-title":null;const q=h.getModuleCount()*A+I*2;let W,ee,V,te,K="",C;for(C="l"+A+",0 0,"+A+" -"+A+",0 0,-"+A+"z ",K+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',K+=F.scalable?"":' width="'+q+'px" height="'+q+'px"',K+=' viewBox="0 0 '+q+" "+q+'" ',K+=' preserveAspectRatio="xMinYMin meet"',K+=P.text||M.text?' role="img" aria-labelledby="'+$([P.id,M.id].join(" ").trim())+'"':"",K+=">",K+=P.text?'<title id="'+$(P.id)+'">'+$(P.text)+"</title>":"",K+=M.text?'<description id="'+$(M.id)+'">'+$(M.text)+"</description>":"",K+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',K+='<path d="',V=0;V<h.getModuleCount();V+=1)for(te=V*A+I,W=0;W<h.getModuleCount();W+=1)h.isDark(V,W)&&(ee=W*A+I,K+="M"+ee+","+te+C);return K+='" stroke="transparent" fill="black"/>',K+="</svg>",K},h.createDataURL=function(A,I){A=A||2,I=typeof I>"u"?A*4:I;const M=h.getModuleCount()*A+I*2,P=I,F=M-I;return _G(M,M,function(q,W){if(P<=q&&q<F&&P<=W&&W<F){const ee=Math.floor((q-P)/A),V=Math.floor((W-P)/A);return h.isDark(V,ee)?0:1}else return 1})},h.createImgTag=function(A,I,M){A=A||2,I=typeof I>"u"?A*4:I;const P=h.getModuleCount()*A+I*2;let F="";return F+="<img",F+=' src="',F+=h.createDataURL(A,I),F+='"',F+=' width="',F+=P,F+='"',F+=' height="',F+=P,F+='"',M&&(F+=' alt="',F+=$(M),F+='"'),F+="/>",F};const $=function(A){let I="";for(let M=0;M<A.length;M+=1){const P=A.charAt(M);switch(P){case"<":I+="&lt;";break;case">":I+="&gt;";break;case"&":I+="&amp;";break;case'"':I+="&quot;";break;default:I+=P;break}}return I},R=function(A){A=typeof A>"u"?2:A;const M=h.getModuleCount()*1+A*2,P=A,F=M-A;let q,W,ee,V,te;const K={"██":"█","█ ":"▀"," █":"▄"," ":" "},C={"██":"▀","█ ":"▀"," █":" "," ":" "};let oe="";for(q=0;q<M;q+=2){for(ee=Math.floor((q-P)/1),V=Math.floor((q+1-P)/1),W=0;W<M;W+=1)te="█",P<=W&&W<F&&P<=q&&q<F&&h.isDark(ee,Math.floor((W-P)/1))&&(te=" "),P<=W&&W<F&&P<=q+1&&q+1<F&&h.isDark(V,Math.floor((W-P)/1))?te+=" ":te+="█",oe+=A<1&&q+1>=F?C[te]:K[te];oe+=`
274
- `}return M%2&&A>0?oe.substring(0,oe.length-M-1)+Array(M+1).join("▀"):oe.substring(0,oe.length-1)};return h.createASCII=function(A,I){if(A=A||1,A<2)return R(I);A-=1,I=typeof I>"u"?A*2:I;const M=h.getModuleCount()*A+I*2,P=I,F=M-I;let q,W,ee,V;const te=Array(A+1).join("██"),K=Array(A+1).join(" ");let C="",oe="";for(q=0;q<M;q+=1){for(ee=Math.floor((q-P)/A),oe="",W=0;W<M;W+=1)V=1,P<=W&&W<F&&P<=q&&q<F&&h.isDark(ee,Math.floor((W-P)/A))&&(V=0),oe+=V?te:K;for(ee=0;ee<A;ee+=1)C+=oe+`
275
- `}return C.substring(0,C.length-1)},h.renderTo2dContext=function(A,I){I=I||2;const M=h.getModuleCount();for(let P=0;P<M;P++)for(let F=0;F<M;F++)A.fillStyle=h.isDark(P,F)?"black":"white",A.fillRect(F*I,P*I,I,I)},h};ml.stringToBytes=function(e){const t=[];for(let n=0;n<e.length;n+=1){const r=e.charCodeAt(n);t.push(r&255)}return t};ml.createStringToBytes=function(e,t){const n=(function(){const o=EG(e),s=function(){const u=o.read();if(u==-1)throw"eof";return u};let a=0;const l={};for(;;){const u=o.read();if(u==-1)break;const f=s(),h=s(),p=s(),g=String.fromCharCode(u<<8|f),y=h<<8|p;l[g]=y,a+=1}if(a!=t)throw a+" != "+t;return l})(),r=63;return function(o){const s=[];for(let a=0;a<o.length;a+=1){const l=o.charCodeAt(a);if(l<128)s.push(l);else{const u=n[o.charAt(a)];typeof u=="number"?(u&255)==u?s.push(u):(s.push(u>>>8),s.push(u&255)):s.push(r)}}return s}};const Hr={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},ku={L:1,M:0,Q:3,H:2},ji={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},$i=(function(){const e=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],t=1335,n=7973,r=21522,o={},s=function(a){let l=0;for(;a!=0;)l+=1,a>>>=1;return l};return o.getBCHTypeInfo=function(a){let l=a<<10;for(;s(l)-s(t)>=0;)l^=t<<s(l)-s(t);return(a<<10|l)^r},o.getBCHTypeNumber=function(a){let l=a<<12;for(;s(l)-s(n)>=0;)l^=n<<s(l)-s(n);return a<<12|l},o.getPatternPosition=function(a){return e[a-1]},o.getMaskFunction=function(a){switch(a){case ji.PATTERN000:return function(l,u){return(l+u)%2==0};case ji.PATTERN001:return function(l,u){return l%2==0};case ji.PATTERN010:return function(l,u){return u%3==0};case ji.PATTERN011:return function(l,u){return(l+u)%3==0};case ji.PATTERN100:return function(l,u){return(Math.floor(l/2)+Math.floor(u/3))%2==0};case ji.PATTERN101:return function(l,u){return l*u%2+l*u%3==0};case ji.PATTERN110:return function(l,u){return(l*u%2+l*u%3)%2==0};case ji.PATTERN111:return function(l,u){return(l*u%3+(l+u)%2)%2==0};default:throw"bad maskPattern:"+a}},o.getErrorCorrectPolynomial=function(a){let l=Vu([1],0);for(let u=0;u<a;u+=1)l=l.multiply(Vu([1,Ai.gexp(u)],0));return l},o.getLengthInBits=function(a,l){if(1<=l&&l<10)switch(a){case Hr.MODE_NUMBER:return 10;case Hr.MODE_ALPHA_NUM:return 9;case Hr.MODE_8BIT_BYTE:return 8;case Hr.MODE_KANJI:return 8;default:throw"mode:"+a}else if(l<27)switch(a){case Hr.MODE_NUMBER:return 12;case Hr.MODE_ALPHA_NUM:return 11;case Hr.MODE_8BIT_BYTE:return 16;case Hr.MODE_KANJI:return 10;default:throw"mode:"+a}else if(l<41)switch(a){case Hr.MODE_NUMBER:return 14;case Hr.MODE_ALPHA_NUM:return 13;case Hr.MODE_8BIT_BYTE:return 16;case Hr.MODE_KANJI:return 12;default:throw"mode:"+a}else throw"type:"+l},o.getLostPoint=function(a){const l=a.getModuleCount();let u=0;for(let p=0;p<l;p+=1)for(let g=0;g<l;g+=1){let y=0;const w=a.isDark(p,g);for(let v=-1;v<=1;v+=1)if(!(p+v<0||l<=p+v))for(let x=-1;x<=1;x+=1)g+x<0||l<=g+x||v==0&&x==0||w==a.isDark(p+v,g+x)&&(y+=1);y>5&&(u+=3+y-5)}for(let p=0;p<l-1;p+=1)for(let g=0;g<l-1;g+=1){let y=0;a.isDark(p,g)&&(y+=1),a.isDark(p+1,g)&&(y+=1),a.isDark(p,g+1)&&(y+=1),a.isDark(p+1,g+1)&&(y+=1),(y==0||y==4)&&(u+=3)}for(let p=0;p<l;p+=1)for(let g=0;g<l-6;g+=1)a.isDark(p,g)&&!a.isDark(p,g+1)&&a.isDark(p,g+2)&&a.isDark(p,g+3)&&a.isDark(p,g+4)&&!a.isDark(p,g+5)&&a.isDark(p,g+6)&&(u+=40);for(let p=0;p<l;p+=1)for(let g=0;g<l-6;g+=1)a.isDark(g,p)&&!a.isDark(g+1,p)&&a.isDark(g+2,p)&&a.isDark(g+3,p)&&a.isDark(g+4,p)&&!a.isDark(g+5,p)&&a.isDark(g+6,p)&&(u+=40);let f=0;for(let p=0;p<l;p+=1)for(let g=0;g<l;g+=1)a.isDark(g,p)&&(f+=1);const h=Math.abs(100*f/l/l-50)/5;return u+=h*10,u},o})(),Ai=(function(){const e=new Array(256),t=new Array(256);for(let r=0;r<8;r+=1)e[r]=1<<r;for(let r=8;r<256;r+=1)e[r]=e[r-4]^e[r-5]^e[r-6]^e[r-8];for(let r=0;r<255;r+=1)t[e[r]]=r;const n={};return n.glog=function(r){if(r<1)throw"glog("+r+")";return t[r]},n.gexp=function(r){for(;r<0;)r+=255;for(;r>=256;)r-=255;return e[r]},n})(),Vu=function(e,t){if(typeof e.length>"u")throw e.length+"/"+t;const n=(function(){let o=0;for(;o<e.length&&e[o]==0;)o+=1;const s=new Array(e.length-o+t);for(let a=0;a<e.length-o;a+=1)s[a]=e[a+o];return s})(),r={};return r.getAt=function(o){return n[o]},r.getLength=function(){return n.length},r.multiply=function(o){const s=new Array(r.getLength()+o.getLength()-1);for(let a=0;a<r.getLength();a+=1)for(let l=0;l<o.getLength();l+=1)s[a+l]^=Ai.gexp(Ai.glog(r.getAt(a))+Ai.glog(o.getAt(l)));return Vu(s,0)},r.mod=function(o){if(r.getLength()-o.getLength()<0)return r;const s=Ai.glog(r.getAt(0))-Ai.glog(o.getAt(0)),a=new Array(r.getLength());for(let l=0;l<r.getLength();l+=1)a[l]=r.getAt(l);for(let l=0;l<o.getLength();l+=1)a[l]^=Ai.gexp(Ai.glog(o.getAt(l))+s);return Vu(a,0).mod(o)},r},fS=(function(){const e=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t=function(o,s){const a={};return a.totalCount=o,a.dataCount=s,a},n={},r=function(o,s){switch(s){case ku.L:return e[(o-1)*4+0];case ku.M:return e[(o-1)*4+1];case ku.Q:return e[(o-1)*4+2];case ku.H:return e[(o-1)*4+3];default:return}};return n.getRSBlocks=function(o,s){const a=r(o,s);if(typeof a>"u")throw"bad rs block @ typeNumber:"+o+"/errorCorrectionLevel:"+s;const l=a.length/3,u=[];for(let f=0;f<l;f+=1){const h=a[f*3+0],p=a[f*3+1],g=a[f*3+2];for(let y=0;y<h;y+=1)u.push(t(p,g))}return u},n})(),hS=function(){const e=[];let t=0;const n={};return n.getBuffer=function(){return e},n.getAt=function(r){const o=Math.floor(r/8);return(e[o]>>>7-r%8&1)==1},n.put=function(r,o){for(let s=0;s<o;s+=1)n.putBit((r>>>o-s-1&1)==1)},n.getLengthInBits=function(){return t},n.putBit=function(r){const o=Math.floor(t/8);e.length<=o&&e.push(0),r&&(e[o]|=128>>>t%8),t+=1},n},wG=function(e){const t=Hr.MODE_NUMBER,n=e,r={};r.getMode=function(){return t},r.getLength=function(a){return n.length},r.write=function(a){const l=n;let u=0;for(;u+2<l.length;)a.put(o(l.substring(u,u+3)),10),u+=3;u<l.length&&(l.length-u==1?a.put(o(l.substring(u,u+1)),4):l.length-u==2&&a.put(o(l.substring(u,u+2)),7))};const o=function(a){let l=0;for(let u=0;u<a.length;u+=1)l=l*10+s(a.charAt(u));return l},s=function(a){if("0"<=a&&a<="9")return a.charCodeAt(0)-48;throw"illegal char :"+a};return r},yG=function(e){const t=Hr.MODE_ALPHA_NUM,n=e,r={};r.getMode=function(){return t},r.getLength=function(s){return n.length},r.write=function(s){const a=n;let l=0;for(;l+1<a.length;)s.put(o(a.charAt(l))*45+o(a.charAt(l+1)),11),l+=2;l<a.length&&s.put(o(a.charAt(l)),6)};const o=function(s){if("0"<=s&&s<="9")return s.charCodeAt(0)-48;if("A"<=s&&s<="Z")return s.charCodeAt(0)-65+10;switch(s){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+s}};return r},vG=function(e){const t=Hr.MODE_8BIT_BYTE,n=ml.stringToBytes(e),r={};return r.getMode=function(){return t},r.getLength=function(o){return n.length},r.write=function(o){for(let s=0;s<n.length;s+=1)o.put(n[s],8)},r},bG=function(e){const t=Hr.MODE_KANJI,n=ml.stringToBytes;(function(s,a){const l=n(s);if(l.length!=2||(l[0]<<8|l[1])!=a)throw"sjis not supported."})("友",38726);const r=n(e),o={};return o.getMode=function(){return t},o.getLength=function(s){return~~(r.length/2)},o.write=function(s){const a=r;let l=0;for(;l+1<a.length;){let u=(255&a[l])<<8|255&a[l+1];if(33088<=u&&u<=40956)u-=33088;else if(57408<=u&&u<=60351)u-=49472;else throw"illegal char at "+(l+1)+"/"+u;u=(u>>>8&255)*192+(u&255),s.put(u,13),l+=2}if(l<a.length)throw"illegal char at "+(l+1)},o},yA=function(){const e=[],t={};return t.writeByte=function(n){e.push(n&255)},t.writeShort=function(n){t.writeByte(n),t.writeByte(n>>>8)},t.writeBytes=function(n,r,o){r=r||0,o=o||n.length;for(let s=0;s<o;s+=1)t.writeByte(n[s+r])},t.writeString=function(n){for(let r=0;r<n.length;r+=1)t.writeByte(n.charCodeAt(r))},t.toByteArray=function(){return e},t.toString=function(){let n="";n+="[";for(let r=0;r<e.length;r+=1)r>0&&(n+=","),n+=e[r];return n+="]",n},t},xG=function(){let e=0,t=0,n=0,r="";const o={},s=function(l){r+=String.fromCharCode(a(l&63))},a=function(l){if(l<0)throw"n:"+l;if(l<26)return 65+l;if(l<52)return 97+(l-26);if(l<62)return 48+(l-52);if(l==62)return 43;if(l==63)return 47;throw"n:"+l};return o.writeByte=function(l){for(e=e<<8|l&255,t+=8,n+=1;t>=6;)s(e>>>t-6),t-=6},o.flush=function(){if(t>0&&(s(e<<6-t),e=0,t=0),n%3!=0){const l=3-n%3;for(let u=0;u<l;u+=1)r+="="}},o.toString=function(){return r},o},EG=function(e){const t=e;let n=0,r=0,o=0;const s={};s.read=function(){for(;o<8;){if(n>=t.length){if(o==0)return-1;throw"unexpected end of file./"+o}const u=t.charAt(n);if(n+=1,u=="=")return o=0,-1;if(u.match(/^\s$/))continue;r=r<<6|a(u.charCodeAt(0)),o+=6}const l=r>>>o-8&255;return o-=8,l};const a=function(l){if(65<=l&&l<=90)return l-65;if(97<=l&&l<=122)return l-97+26;if(48<=l&&l<=57)return l-48+52;if(l==43)return 62;if(l==47)return 63;throw"c:"+l};return s},SG=function(e,t){const n=e,r=t,o=new Array(e*t),s={};s.setPixel=function(f,h,p){o[h*n+f]=p},s.write=function(f){f.writeString("GIF87a"),f.writeShort(n),f.writeShort(r),f.writeByte(128),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(255),f.writeByte(255),f.writeByte(255),f.writeString(","),f.writeShort(0),f.writeShort(0),f.writeShort(n),f.writeShort(r),f.writeByte(0);const h=2,p=l(h);f.writeByte(h);let g=0;for(;p.length-g>255;)f.writeByte(255),f.writeBytes(p,g,255),g+=255;f.writeByte(p.length-g),f.writeBytes(p,g,p.length-g),f.writeByte(0),f.writeString(";")};const a=function(f){const h=f;let p=0,g=0;const y={};return y.write=function(w,v){if(w>>>v)throw"length over";for(;p+v>=8;)h.writeByte(255&(w<<p|g)),v-=8-p,w>>>=8-p,g=0,p=0;g=w<<p|g,p=p+v},y.flush=function(){p>0&&h.writeByte(g)},y},l=function(f){const h=1<<f,p=(1<<f)+1;let g=f+1;const y=u();for(let S=0;S<h;S+=1)y.add(String.fromCharCode(S));y.add(String.fromCharCode(h)),y.add(String.fromCharCode(p));const w=yA(),v=a(w);v.write(h,g);let x=0,N=String.fromCharCode(o[x]);for(x+=1;x<o.length;){const S=String.fromCharCode(o[x]);x+=1,y.contains(N+S)?N=N+S:(v.write(y.indexOf(N),g),y.size()<4095&&(y.size()==1<<g&&(g+=1),y.add(N+S)),N=S)}return v.write(y.indexOf(N),g),v.write(p,g),v.flush(),w.toByteArray()},u=function(){const f={};let h=0;const p={};return p.add=function(g){if(p.contains(g))throw"dup key:"+g;f[g]=h,h+=1},p.size=function(){return h},p.indexOf=function(g){return f[g]},p.contains=function(g){return typeof f[g]<"u"},p};return s},_G=function(e,t,n){const r=SG(e,t);for(let l=0;l<t;l+=1)for(let u=0;u<e;u+=1)r.setPixel(u,l,n(u,l));const o=yA();r.write(o);const s=xG(),a=o.toByteArray();for(let l=0;l<a.length;l+=1)s.writeByte(a[l]);return s.flush(),"data:image/gif;base64,"+s};ml.stringToBytes;function NG(e){const t=ml(0,"M");t.addData(e,"Byte"),t.make();const n=t.getModuleCount();return Array.from({length:n},(r,o)=>Array.from({length:n},(s,a)=>t.isDark(o,a)))}const ur={title:"Your devices",scan:"Scan with your phone's camera to open this machine there, then let the phone in here.",turnOn:"Turn on, and your phone opens this machine at its tailnet name. Anyone on your tailnet you let in gets a shell here.",hereOff:"Tailscale on this machine is not connected, so nothing on your tailnet can reach it.",noneOnTailnet:"No other device is on your tailnet yet.",noPhone:"No phone has joined your tailnet. Install Tailscale on it and sign in to the same account.",knocking:"Let in the one whose words match the other screen.",missing:"A machine with no Toyon needs the phone button pressed on it, or `toyon remote --tailscale`.",listed:"listed",request:"request access",notAnswering:"not answering right now",offline:"offline",noToyon:"no Toyon",placeholder:"https://",notAnAddress:"That is not a Toyon address. It is https:// and the machine's name, as its screen shows it.",asking:e=>`Asking ${Ph(e)}.`,waiting:(e,t)=>`Toyon on ${Ph(e)} is asking whether to let ${t} in.`,added:e=>`Added ${e}.`,notKept:e=>`Let in, but not listed: ${e}`,add:"add"};function TG(e,t){return e.reached?e.toyon&&!e.toyon.answering?ur.notAnswering:t?ur.listed:e.toyon?null:ur.noToyon:ur.offline}function pS(e){var t;return(t=e.toyon)!=null&&t.answering?0:e.toyon?1:e.reached?2:3}function Ph(e){try{return new URL(e).host}catch{return e}}function vA(e,t,n){const r=Ph(t);switch(e){case"refused":return`${r} did not let ${n} in.`;case"gone":return`${r} stopped waiting. Ask again, and answer there within five minutes.`;case"full":return`${r} has too many devices waiting already. Answer or turn those away there first.`;case"not-toyon":return`${r} is not a Toyon machine, or has no remote name set up.`;case"unreachable":return`${r} did not answer. Is Tailscale on here, and is Toyon running there?`}}function jG(e,t,n){const r=(o,s)=>({word:o,note:s,offer:null});switch(t==null?void 0:t.state){case"not-installed":return r("no Tailscale","Tailscale is not installed on this machine, so nothing on your tailnet can reach it.");case"not-running":return r("Tailscale not running","Tailscale is not running on this machine, so nothing on your tailnet can reach it.");case"disconnected":return{word:null,note:"Tailscale on this machine is switched off, so nothing on your tailnet can reach it.",offer:"connect"};case"signed-out":return{word:null,note:"Tailscale on this machine is signed out, so nothing on your tailnet can reach it.",offer:"sign-in"};case"needs-approval":return r("not approved",t.line)}if(e===null)return r("not asked","Toyon could not ask Tailscale here just now.");if(e!==void 0&&!e.here)return r("not connected",ur.hereOff);if(n===null&&t!==null&&t.state!=="ready")switch(t.state){case"magicdns-off":return r("MagicDNS off",t.line);case"https-off":return r("HTTPS off",t.line);default:return r(null,t.line)}return r(null,null)}const $G=e=>e==="phone"?"phone":"laptop";function mS({rows:e}){return d.jsx("div",{className:"tailnet-list",children:e.map(t=>d.jsxs("div",{className:"tailnet-row",children:[d.jsxs("div",{className:"tailnet-peer",children:[d.jsx("span",{className:We("dot tailnet-dot",t.reached===null?"tailnet-asking":t.reached?"tailnet-reached":"tailnet-unreached"),role:"img","aria-label":t.reached===null?"asking":t.reached?"connected":"not connected"}),d.jsx(xt,{name:t.icon,className:"tailnet-kind"}),d.jsx("span",{className:"tailnet-name",children:t.name}),t.host&&d.jsx("span",{className:"hint tailnet-host",children:t.host})]}),t.right!==void 0&&t.right!==null&&d.jsx("span",{className:We("tailnet-right",typeof t.right=="string"&&"hint"),children:t.right})]},t.key))})}const gS=(e,t)=>{var n;return{key:e.host||e.name,name:((n=e.toyon)==null?void 0:n.machine)??e.name,host:e.kind==="machine"&&e.host?e.host:void 0,reached:e.reached,icon:$G(e.kind),right:t}},Yg=4;function CG({text:e}){const{size:t,d:n}=E.useMemo(()=>{const r=NG(e);let o="";return r.forEach((s,a)=>{s.forEach((l,u)=>{l&&(o+=`M${u+Yg} ${a+Yg}h1v1h-1z`)})}),{size:r.length+Yg*2,d:o}},[e]);return d.jsx("svg",{className:"devices-qr",viewBox:`0 0 ${t} ${t}`,shapeRendering:"crispEdges",role:"img","aria-label":"This machine's address",children:d.jsx("path",{d:n})})}const AG=5e3;function IG(e){return e.from===null?"A device that opened this address":`A Toyon page at ${Ph(e.from)}`}function RG({knock:e,letIn:t,onAnswer:n}){return d.jsxs("div",{className:We("devices-knock",t!==null&&"devices-knock-done"),children:[d.jsxs("div",{className:"devices-knock-line",children:[d.jsx("span",{className:"knock-word",children:e.word}),d.jsx("span",{className:"devices-from",children:t===null?`${IG(e)} wants in.`:t?"is in.":"was turned away."})]}),t===null&&d.jsxs("div",{className:"devices-actions",children:[d.jsx(Me,{tone:"primary",onClick:()=>n(!0),children:"let in"}),d.jsx(Me,{variant:"outline",onClick:()=>n(!1),children:"not now"})]})]})}function OG({host:e,noPhone:t}){return d.jsxs("div",{className:"devices-address",children:[d.jsx("div",{className:"devices-frame",children:d.jsx(CG,{text:RR(e)})}),d.jsxs("div",{className:"devices-about",children:[d.jsx("p",{className:"devices-line",children:ur.scan}),t&&d.jsx("p",{className:"devices-note",children:ur.noPhone})]})]})}function MG(e){const t=e.devices.filter(r=>r.kind==="phone"),n=e.devices.map((r,o)=>({d:r,i:o})).filter(({d:r})=>r.kind==="machine").sort((r,o)=>pS(r.d)-pS(o.d)||r.i-o.i).map(({d:r})=>r);return[...t,...n]}function LG(){const e=ht(),t=xs(),n=Mr(),r=L(de=>de.frame==="desk"),o=L(de=>{var ie;return((ie=de.remote)==null?void 0:ie.host)??null}),s=L(de=>de.machine),a=L(de=>de.tailscale),l=L(de=>de.knocks),[u,f]=E.useState(""),[h,p]=E.useState({kind:"idle"}),[g,y]=E.useState([]),w=()=>e({a:"close"}),v=h.kind==="asking"||h.kind==="waiting",x=h6(()=>Y4(n),AG,!v),N=E.useRef(new AbortController);E.useEffect(()=>()=>N.current.abort(),[]);const S=async de=>{if(v)return;const ie=N.current.signal;p({kind:"asking",origin:de});const ye=await oN(de,ie,$e=>p({kind:"waiting",origin:de,word:$e}));if(ie.aborted)return;if(typeof ye=="string"){p({kind:"failed",line:vA(ye,de,"this page")});return}const _e=t.serving(),be=await tz(Xw(_e.origin,_e.token),de,ye.token);p(be?{kind:"failed",line:ur.notKept(be)}:{kind:"added",name:t.displayName(de)})},T=()=>{const de=OR(u);de?S(de):p({kind:"failed",line:ur.notAnAddress})},j=()=>{N.current.abort(),N.current=new AbortController,p({kind:"idle"})},$=(de,ie)=>{y(ye=>ye.some(_e=>_e.knock.id===de.id)?ye:[...ye,{knock:de,letIn:ie}]),nz(n,de.id,ie)},R=l.filter(de=>!g.some(ie=>ie.knock.id===de.id)),A=[...g,...R.map(de=>({knock:de,letIn:null}))],[I,M]=E.useState(!1),[P,F]=E.useState(null),q=async de=>{M(!0),F(null);const ie=await(de?X4(n):Q4(n));M(!1),ie&&F(ie)},W=(x==null?void 0:x.here)===!0,ee=jG(x,a,o),V=o!==null,te=r&&(W||x===void 0)?d.jsx(Me,{variant:"outline",size:"sm",on:V,"aria-pressed":V,busy:I,disabled:!V&&(a==null?void 0:a.state)!=="ready",onClick:()=>void q(!V),...Nt(V?"Take this machine's name off your tailnet":"Give this machine a name on your tailnet"),children:V?"on":"off"}):null,[K,C]=E.useState(!1),[oe,U]=E.useState(null),B=de=>{window.open(de,"_blank","noopener")===null?U(de):U(null)},Q=async de=>{if(C(!0),F(null),de==="connect"){const ie=await J4(n);ie&&F(ie)}else{const ie=await ez(n);"url"in ie?B(ie.url):F(ie.why)}C(!1)},ue=r&&ee.offer!==null?oe!==null?d.jsx(Me,{variant:"outline",size:"sm",onClick:()=>B(oe),children:"open the sign-in page"}):d.jsx(Me,{variant:"outline",size:"sm",busy:K,onClick:()=>void Q(ee.offer??"connect"),...ee.note?Nt(ee.note):{},children:ee.offer==="connect"?"connect":"sign in"}):null,he=ee.word===null&&te===null&&ue===null?"this machine":d.jsxs(d.Fragment,{children:[ee.word&&d.jsx("span",{className:"hint",children:ee.word}),te??ue]}),Ne=[{key:"self",name:s??"This machine",host:o??void 0,reached:x===void 0?null:W,icon:"laptop",right:he}],De=x?MG(x).map(de=>{if(de.kind==="phone"||de.host==="")return gS(de,de.reached?void 0:"not answering");const ie=`https://${de.host}`,ye=TG(de,t.get(ie)!==null);return gS(de,ye??d.jsx(Me,{variant:"outline",size:"sm",disabled:v,onClick:()=>void S(ie),children:ur.request}))}):[],Be=r&&o!==null&&x!==null&&(x===void 0||x.here),Z=x==null?void 0:x.devices.some(de=>de.kind==="machine"&&de.host!==""&&de.reached&&de.toyon===null),J=Be&&x!==void 0&&!x.devices.some(de=>de.kind==="phone"),pe=(()=>{switch(h.kind){case"asking":return ur.asking(h.origin);case"waiting":return ur.waiting(h.origin,h.word);case"added":return ur.added(h.name);case"failed":return h.line;case"idle":return null}})();return d.jsxs(Wu,{boxClass:"devices-card",onClose:w,children:[d.jsx("div",{className:"devices-title",children:ur.title}),d.jsx(mS,{rows:Ne}),ee.note&&ee.offer===null&&d.jsx("p",{className:"devices-note",children:ee.note}),P&&d.jsx("p",{className:"devices-note",children:P}),r&&!V&&(a==null?void 0:a.state)==="ready"&&d.jsx("p",{className:"devices-note",children:ur.turnOn}),Be&&o!==null&&d.jsx(OG,{host:o,noPhone:J}),h.kind==="waiting"&&d.jsx("div",{className:"knock-word devices-word",children:h.word}),pe&&d.jsx("p",{className:We("devices-line",h.kind==="failed"&&"devices-failed"),children:pe}),x!==void 0&&d.jsxs(d.Fragment,{children:[De.length>0&&d.jsx("div",{className:"devices-others",children:d.jsx(mS,{rows:De})}),(x==null?void 0:x.devices.length)===0&&d.jsx("p",{className:"devices-note",children:ur.noneOnTailnet}),Z&&d.jsx("p",{className:"devices-note",children:ur.missing})]}),!v&&d.jsxs("form",{className:"devices-form",onSubmit:de=>{de.preventDefault(),T()},children:[d.jsx(Ho,{size:"md",font:"ui",value:u,placeholder:ur.placeholder,"aria-label":"Address of the other machine",onChange:de=>f(de.target.value),className:"devices-field"}),d.jsx(Me,{type:"submit",variant:"outline",disabled:!u.trim(),children:ur.add})]}),v&&d.jsx("div",{className:"devices-actions",children:d.jsx(Me,{tone:"quiet",onClick:j,children:"cancel"})}),R.length>0&&d.jsx("p",{className:"devices-line devices-centred",children:ur.knocking}),A.map(de=>d.jsx(RG,{knock:de.knock,letIn:de.letIn,onAnswer:ie=>$(de.knock,ie)},de.knock.id))]})}function PG({worktreeId:e,hits:t}){const n=ht(),r=nt(),o=L(l=>l.layout.changes),s=L(l=>{var f;const u=(f=Jt(l,e))==null?void 0:f.worktree;return u?u.path:null}),a=E.useCallback((l,u)=>{const f=u.trim().toLowerCase();return f?l.filter(h=>`${h.path}:${h.line} ${h.text}`.toLowerCase().includes(f)):l},[]);return d.jsx(qr,{items:t,filter:a,keyOf:l=>`${l.path}:${l.line}`,rowClass:()=>"search-hit",rowTitle:l=>`${l.path}:${l.line}`,onPick:l=>{Rn({dispatch:n},{worktreeId:e,path:l.path,view:"file",line:{n:l.line}}),o||n({a:"toggle-changes"}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:l=>s?Hs({id:e,dir:s},l.path,{},{sock:r,dispatch:n}):[],placeholder:"lines that could write this element",row:l=>d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"search-loc",children:[l.path,":",l.line]}),d.jsx("span",{className:"search-text",children:l.text})]})})}function DG({project:e}){const t=ht(),n=nt(),r=L(f=>f.paths),o=L(f=>f.home),s=E.useCallback(f=>{Bu(f)&&(n==null||n.send({t:"browse-path",path:f}))},[n]),a=E.useCallback((f,h)=>j9({query:h,entries:r.entries,target:r.target,answered:r.query,home:o}),[r,o]),l=Au(e.name)?null:e.name.trim(),u=f=>`${f.replace(/\/+$/,"")}/`;return d.jsx(qr,{initialQuery:u(e.parent),lead:d.jsx("span",{className:"picker-chip",children:l??"new project"}),items:[],filter:a,keyOf:f=>f.kind==="dir"?`d:${f.entry.path}`:`${f.kind}:${f.path}`,rowClass:()=>"picker-row folder-row",onQuery:s,completionOf:f=>f.kind==="dir"?u(f.entry.path):null,narrowTo:f=>f.kind==="dir"?u(f.entry.path):f.kind==="up"?u(f.path):null,onPick:f=>{f.kind==="here"&&(t({a:"new-project-set",v:{mode:e.mode==="init"?"create":e.mode,parent:f.path}}),t({a:"close"}))},onBack:()=>t({a:"close"}),placeholder:"type a folder path",keys:f=>({complete:"completes the path",pick:(f==null?void 0:f.kind)==="here"?"chooses it":(f==null?void 0:f.kind)==="up"?"goes up":"opens it",back:"goes back"}),empty:"no such folder",row:f=>f.kind==="here"?d.jsx(In,{label:`put ${l??"it"} in ${Gk(f.path,o)}`,hint:d.jsx("bdi",{children:l?Vj(f.path,l):f.path})}):f.kind==="up"?d.jsx(In,{label:`up to ${Gk(f.path,o)}`,hint:d.jsx("bdi",{children:f.path})}):d.jsx(In,{label:f.entry.name})})}function zG({worktreeId:e}){const t=ht(),n=nt(),r=L(g=>g.clientId),o=L(g=>Jt(g,e)),s=L(g=>g.repos),l=Rt(e,"draft").trim(),u=o==null?void 0:o.worktree.repoId,f=E.useMemo(()=>[...s.filter(g=>g.id===u),...s.filter(g=>g.id!==u)],[s,u]),h=()=>t({a:"close"}),p=g=>{if(!o)return h();n==null||n.send({t:"handoff-ask",worktreeId:e,repoId:g.id,...l?{text:l}:{}}),l&&(n==null||n.send({t:"set-draft",boxId:e,text:"",clientId:r}),t({a:"set-draft",id:e,text:""})),h()};return d.jsx(qr,{lead:d.jsx("span",{className:"picker-chip",children:(o==null?void 0:o.worktree.title)??"worktree"}),items:f,filter:(g,y)=>g.filter(w=>w.id===u&&os(y,"here")||os(y,w.name,w.path)),keyOf:g=>g.id,row:g=>d.jsx(In,{label:g.id===u?"a new worktree here":g.name,hint:g.path}),onPick:p,onBack:()=>t({a:"close",back:!0}),placeholder:"continue where?",empty:"no project is open",footer:l?()=>d.jsxs("div",{className:"empty",children:["with your message: ",l.split(`
276
- `)[0]]}):void 0})}const FG={use:"an agent working, a question waiting, a phone connected",always:"whenever Toyon runs, on battery too",off:"the Mac sleeps when it would anyway"};function BG(){const e=ht(),t=nt(),n=L(r=>r.keepAwake);return d.jsx(qr,{items:[...tR],filter:(r,o)=>r.filter(s=>os(o,Eh[s])),rowClass:()=>"picker-row",keyOf:r=>r,initialIndex:r=>Math.max(0,n?r.indexOf(n):0),onPick:r=>{t==null||t.send({t:"set-keep-awake",mode:r}),e({a:"close"})},onBack:()=>e({a:"close",back:!0}),placeholder:"keep awake",row:r=>d.jsx(In,{label:Eh[r],current:r===n,hint:FG[r]})})}function UG(e,t){if(t.incompatible)return`update Toyon on ${e}`;if(t.suspended)return"sleeping";if(!t.connected)return t.connectFailure?"not answering":"connecting";const n=Kk(t.rows,null);return n?`${n.n} ${n.tier==="waiting"?"waiting":"unread"}`:"all quiet"}function vw(e){try{return MR(new URL(e).hostname)}catch{return!1}}function HG(e){const t=new Set,n=e.build({...e.serving,serving:!0}),r=[];let o=n,s=[n];const a=()=>{s=[n,...r];for(const w of t)w()},l=new Map,u=w=>{var x;if(w.serving)return;(((x=w.store.getState().remote)==null?void 0:x.front)==="edge"||vw(w.origin))&&w!==o?w.sock.suspend():w.sock.resume()},f=w=>{var x;let v=(x=w.store.getState().remote)==null?void 0:x.front;l.set(w.origin,w.store.subscribe(()=>{var S;const N=(S=w.store.getState().remote)==null?void 0:S.front;N!==v&&(v=N,u(w))}))},h=()=>s,p={list:h,active:()=>o,serving:()=>n,get:w=>h().find(v=>v.origin===w)??null,displayName(w){const v=h().find(N=>N.origin===w);return v?h().filter(N=>N.name===v.name).length>1?`${v.name} (${new URL(v.origin).host})`:v.name:w},activate(w){const v=h().find(N=>N.origin===w);if(!v||v===o)return;const x=o;o=v,u(x),u(v),a()},add(w){var N;const v=r.find(S=>S.origin===w.origin);if(w.origin===n.origin)return n;if(v){if(v.token===w.token)return v;(N=l.get(v.origin))==null||N(),v.dispose(),r.splice(r.indexOf(v),1),o===v&&(o=n)}const x=e.build({...w,serving:!1});return r.push(x),f(x),vw(x.origin)&&x.sock.suspend(),a(),x},remove(w){var x;const v=r.find(N=>N.origin===w);v&&((x=l.get(w))==null||x(),l.delete(w),v.dispose(),v.storage.clear(),v.forget(),r.splice(r.indexOf(v),1),o===v&&(o=n),a())},broadcast(w){for(const v of h())v.store.dispatch(w)},subscribe(w){return t.add(w),()=>t.delete(w)}},g=w=>{for(const v of w)p.add(v);for(const v of[...r])w.some(x=>x.origin===v.origin)||p.remove(v.origin)};let y=n.store.getState().handed;return n.store.subscribe(()=>{const w=n.store.getState().handed;w!==y&&(y=w,g(y))}),g(y),p}function Av({form:e,anchored:t}){var K;const n=ht(),r=nt(),o=xs(),s=Gs(),a=o.displayName(s.origin),l=L(C=>C.repos),u=L(C=>C.newProject?null:C.activeRepoId),f=L(C=>C.rows),h=L(C=>C.paths),p=L(C=>C.home),g=L(C=>C.pending),y=L(C=>C.folderDialog),w=e==="url",v=E.useRef(""),x=E.useMemo(()=>$b(l,f),[l,f]),N=QN(),S=JN(),T=E.useMemo(()=>N.map(C=>{var oe;return{...C,repos:$b(C.repos,((oe=S.find(U=>U.origin===C.origin))==null?void 0:oe.rows)??[])}}),[N,S]),j=E.useCallback(C=>{v.current=C,Bu(C)&&(r==null||r.send({t:"browse-path",path:C}))},[r]),$=E.useCallback((C,oe)=>T9({query:oe,repos:x,pending:g,entries:[...h.entries].sort((U,B)=>Number(B.isRepo)-Number(U.isRepo)),target:h.target,answered:h.query,home:p,others:T,current:u,urlOnly:w}),[x,h,g,p,T,u,w]),R=()=>n({a:"close"}),A=()=>n({a:"close",back:!0}),I={sock:r,dispatch:n},M=C=>Fu(I,{t:"register-repo",path:C}),P=(C,oe)=>Fu(I,{t:"create-repo",mode:"create",parent:C,name:oe}),F=(C,oe,U)=>n({a:"new-project",v:up({mode:C,name:oe,parent:N9(l,u,p),...U})}),q=()=>n({a:"open",overlay:{kind:"projects",form:"disk"}}),W=()=>n({a:"open",overlay:{kind:"projects",form:"url"}}),ee=()=>{const C=v.current.trim(),oe=C.lastIndexOf("/"),U=Bu(C)&&oe>=0?C.slice(0,oe)||"/":"~";r==null||r.send({t:"choose-file",start:U}),R()},V=()=>n({a:"open",overlay:{kind:"devices"}}),te=(C,oe)=>{const U=o.get(C);U&&(U.store.dispatch({a:"activate-repo",id:oe}),o.activate(C))};return d.jsx(qr,{anchored:e==="pill"&&(t??!0),initialQuery:e==="disk"?"~/":"",lead:e==="disk"||w?void 0:d.jsx("span",{className:"picker-chip",children:((K=l.find(C=>C.id===u))==null?void 0:K.name)??"no project"}),trailing:w?void 0:e==="disk"?y?d.jsx(Tt,{icon:"file",label:"Open a file from Finder",onClick:ee}):void 0:d.jsx(Tt,{icon:"folder",label:"Find a project or file on disk",onClick:q}),items:[],filter:$,initialIndex:C=>C.findIndex(oe=>oe.kind==="repo"&&!oe.machine&&oe.repo.id===u),groupOf:C=>C.kind==="machine"||C.kind==="repo"&&C.machine?C.machine.origin:s.origin,groupHead:C=>C===s.origin?a:d.jsx(WG,{origin:C}),keyOf:C=>C.kind==="repo"?C.machine?`${C.machine.origin}:${C.repo.id}`:C.repo.id:C.kind==="dir"?`d:${C.entry.path}`:C.kind==="file"?`f:${C.entry.path}`:C.kind==="open"?`open:${C.path}`:C.kind==="init"?`init:${C.path}`:C.kind==="pending"?`p:${C.pending.id}`:C.kind==="clone"?`clone:${C.url}`:C.kind==="new"?"new-project":C.kind==="disk"?"open-folder":C.kind==="from-url"?"from-url":C.kind==="add-machine"?"add-machine":C.kind==="machine"?`machine:${C.machine.origin}`:`new:${C.parent??""}/${C.name}`,rowClass:C=>We("picker-row",(C.kind==="new"||C.kind==="disk"||C.kind==="from-url"||C.kind==="add-machine")&&"new-project-row"),onQuery:j,completionOf:C=>C.kind==="dir"?C.entry.isRepo?C.entry.path:`${C.entry.path}/`:C.kind==="file"?C.entry.path:null,narrowTo:C=>C.kind==="dir"&&!C.entry.isRepo?`${C.entry.path}/`:null,onPick:C=>{if(C.kind==="clone")return F("clone",C.name,{url:C.url,...C.branch?{branch:C.branch}:{}});if(C.kind==="create"&&!C.parent)return F("create",C.name);if(C.kind==="new")return F("create","");if(C.kind==="disk")return q();if(C.kind==="from-url")return W();if(C.kind==="add-machine")return V();C.kind==="machine"?o.activate(C.machine.origin):C.kind==="pending"?n({a:"watch-import",id:C.pending.id}):C.kind==="repo"&&C.machine?te(C.machine.origin,C.repo.id):C.kind==="repo"?n({a:"activate-repo",id:C.repo.id}):C.kind==="open"?M(C.path):C.kind==="file"?A9(r,C.entry.path):C.kind==="init"?Wj(I,C.path):C.kind==="dir"?M(C.entry.path):C.parent&&P(C.parent,C.name),R()},onBack:A,rowMenu:C=>C.kind==="machine"||C.kind==="repo"&&C.machine?qk(o,C.machine.origin):C.kind==="repo"?Np(C.repo,u,I,f):C.kind==="pending"?x9(C.pending,I):[],placeholder:w?"paste a git URL, like https://github.com/you/app":l.length>1?"switch project, or type a name or path":"type a name or a path to start",keys:C=>({complete:"completes the path",pick:(C==null?void 0:C.kind)==="dir"&&!C.entry.isRepo?"descends":(C==null?void 0:C.kind)==="pending"?"watches it":(C==null?void 0:C.kind)==="create"?C.parent?"creates it":"names it":(C==null?void 0:C.kind)==="clone"?"clones it":(C==null?void 0:C.kind)==="new"?"starts one":(C==null?void 0:C.kind)==="disk"?"browses":(C==null?void 0:C.kind)==="from-url"?"asks for one":(C==null?void 0:C.kind)==="add-machine"?"adds one":(C==null?void 0:C.kind)==="machine"||(C==null?void 0:C.kind)==="repo"&&C.machine?"switches machine":"opens",back:"closes"}),empty:w?C=>C.trim()?"not a git URL yet; paste the address of a repository, or of a page on GitHub, GitLab or Codeberg":"the address of a repository, or of a branch, file or pull request on GitHub, GitLab or Codeberg":"nothing here; keep typing a path (~/… or /…)",row:C=>C.kind==="repo"?d.jsx(In,{label:C.repo.name,current:!C.machine&&C.repo.id===u}):C.kind==="pending"?d.jsx(In,{label:C.pending.name,hint:C.pending.error?"import failed":d.jsx("span",{className:"live-text",children:"importing"})}):C.kind==="dir"?d.jsx(In,{label:C.entry.name,hint:C.entry.isRepo?"git repo":void 0}):C.kind==="file"?d.jsx(In,{label:C.entry.name,hint:"file"}):C.kind==="open"?d.jsx(In,{label:`open ${C.path}`,hint:"register with this daemon"}):C.kind==="init"?d.jsx(In,{label:`open ${C.path}`,hint:"no git yet; starts it here with the files in it"}):C.kind==="clone"?d.jsx(In,{label:`clone ${C.name}`,hint:C.branch?`${kS(C.url)} · ${C.branch}`:kS(C.url)}):C.kind==="new"?d.jsx(In,{label:d.jsxs(d.Fragment,{children:[d.jsx(xt,{name:"plus",className:"icon-inline"}),"new project"]})}):C.kind==="disk"?d.jsx(In,{label:d.jsxs(d.Fragment,{children:[d.jsx(xt,{name:"folder",className:"icon-inline"}),"open folder or file"]})}):C.kind==="from-url"?d.jsx(In,{label:d.jsxs(d.Fragment,{children:[d.jsx(xt,{name:"globe",className:"icon-inline"}),"clone from a URL"]})}):C.kind==="add-machine"?d.jsx(In,{label:d.jsxs(d.Fragment,{children:[d.jsx(xt,{name:"devices",className:"icon-inline"}),"add a machine"]})}):C.kind==="machine"?d.jsx(In,{label:`switch to ${o.displayName(C.machine.origin)}`}):d.jsx(In,{label:`create ${C.name}`,hint:C.parent?`in ${C.parent}`:"new project"})})}function WG({origin:e}){const t=xs(),n=t.get(e)??t.active(),r=ou(n,p=>p.rows),o=ou(n,p=>p.connected),s=ou(n,p=>p.connectFailure),a=ou(n,p=>p.incompatible),l=ou(n,p=>{var g;return(g=p.remote)==null?void 0:g.front}),u=t.displayName(e),f=UG(u,{rows:r.filter(Tn),connected:o,connectFailure:s,incompatible:a,suspended:(l==="edge"||vw(e))&&!o}),h=/^\d+ /.test(f);return d.jsxs(d.Fragment,{children:[u,d.jsx("span",{className:We("picker-group-tail",h&&"picker-group-owed"),children:f})]})}function kS(e){const t=e.match(/^[a-z+]+:\/\/(?:[^@/]*@)?([^/:]+)/i)??e.match(/^[^@]+@([^:]+):/);return(t==null?void 0:t[1])??"git remote"}function KG(e){const t=[];if(e.pr){const r=e.pr.url;t.push({id:"open-pr",label:"open on GitHub",onClick:()=>Rr(r)}),t.push({id:"copy-link",label:"copy link",onClick:()=>sn(r)})}const n=[{id:"copy-ref",label:e.kind==="pr"?"copy PR number":"copy branch name",onClick:()=>sn(e.ref)}];return Un([t,n])}const qG=[],ZG={branch:"branch",remote:"globe",pr:"pr"},wS={pr:0,branch:1,remote:2},GG={pr:"pull requests",branch:"branches",remote:"remote branches"};function VG({repoId:e}){const t=ht(),n=nt(),r=L(p=>p.clientId),o=L(p=>p.refs[e]),s=L(p=>p.rows),a=p=>{var g;return((g=s.find(y=>y.id===p))==null?void 0:g.name)??"a worktree"},l=E.useCallback(p=>[...p].sort((g,y)=>wS[g.kind]-wS[y.kind]),[]),u=E.useCallback(p=>n==null?void 0:n.send({t:"search-refs",repoId:e,query:p.trim()}),[n,e]),f=p=>!o||o.query!==p.trim(),h=p=>p.openIn?`open in ${a(p.openIn)}`:p.merged?"merged":p.pr?`${p.pr.author}${p.pr.draft?" · draft":""}${p.pr.fork?" · fork":""}`:p.subject??"";return d.jsx(qr,{items:(o==null?void 0:o.refs)??qG,filter:l,onQuery:u,keyOf:p=>`${p.kind}:${p.ref}`,rowClass:()=>"picker-row ref-row",onPick:p=>{p.openIn?t({a:"activate",id:p.openIn}):n==null||n.send({t:"open-ref",repoId:e,kind:p.kind,ref:p.ref,clientId:r,...p.pr?{pr:{title:p.pr.title,url:p.pr.url}}:{}}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:KG,groupOf:p=>p.kind,groupHead:(p,g)=>`${GG[p]} · ${g}`,placeholder:"open a branch or PR…",keys:p=>({nav:"moves",pick:p!=null&&p.openIn?"switches to it":"opens it as a worktree",back:"closes"}),empty:p=>f(p)?d.jsx("span",{className:"live-text",children:"looking"}):p.trim()?"no branch or PR matches":"no unmerged branches or open PRs",row:p=>d.jsx(In,{label:d.jsxs(d.Fragment,{children:[d.jsx(xt,{name:ZG[p.kind],className:"icon-inline"}),d.jsx("span",{className:"ref-name",children:p.name})]}),hint:h(p)})})}const yS=[],Xg=2;function YG(e,t){const n=t.trim().toLowerCase(),r=e.toLowerCase();if(!n||r.length!==e.length)return null;const o=[];for(let s=r.indexOf(n);s!==-1;s=r.indexOf(n,s+n.length))for(let a=0;a<n.length;a++)o.push(s+a);return o.length?o:null}function XG({worktreeId:e}){const t=ht(),n=nt(),r=lT(e).search,o=L(f=>f.layout.changes),s=L(f=>{var p;const h=(p=Jt(f,e))==null?void 0:p.worktree;return h?h.path:null}),a=E.useCallback((f,h)=>h.trim().length>=Xg?f:yS,[]),l=E.useCallback(f=>{const h=f.trim();h.length>=Xg&&(n==null||n.send({t:"search",worktreeId:e,query:h}))},[n,e]),u=f=>!r||r.query.trim()!==f.trim();return E.useEffect(()=>()=>n==null?void 0:n.send({t:"search-stop"}),[n]),d.jsx(qr,{items:(r==null?void 0:r.hits)??yS,filter:a,onQuery:l,keyOf:f=>`${f.path}:${f.line}`,rowClass:()=>"search-hit",rowTitle:f=>`${f.path}:${f.line}`,onPick:f=>{Rn({dispatch:t},{worktreeId:e,path:f.path,view:"file",line:{n:f.line}}),o||t({a:"toggle-changes"}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:f=>s?Hs({id:e,dir:s},f.path,{},{sock:n,dispatch:t}):[],placeholder:"search in files…",empty:f=>f.trim().length<Xg?"type at least two characters":u(f)?d.jsx("span",{className:"live-text",children:"searching"}):"no matches",footer:(f,h)=>r!=null&&r.truncated&&!u(f)&&h.length>0?d.jsx("div",{className:"empty",children:"not every match is shown; narrow the search"}):null,row:(f,h,p)=>d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"search-loc",children:[f.path,":",f.line]}),d.jsx("span",{className:"search-text",children:al(f.text,YG(f.text,p),0)})]})})}const vS=e=>e.source==="file"?"~/.toyon/themes":e.source==="vscode"?"VS Code":"";function QG({slot:e}){const t=ht(),n=nt(),r=L(S=>S.themePrefs),o=L(S=>S.themes),s=ky(),a=Vw(r,s),l=r[e==="theme"?a:e],u=()=>t({a:"close"}),f=()=>t({a:"close",back:!0}),h=S=>t({a:"preview-theme",theme:S}),[p,g]=E.useState(null),[y,w]=E.useState(null),v=(S,T)=>S[T??a]??S.dark??S.light??null,x=E.useMemo(()=>C4(o),[o]),N=E.useMemo(()=>o.filter(S=>S.kind===e),[o,e]);return ct([p,y],()=>{e==="theme"&&h(p?v(p,y):null)}),e!=="theme"?d.jsx(qr,{items:N,filter:(S,T)=>S.filter(j=>os(T,j.name,j.id)),rowClass:()=>"picker-row",keyOf:S=>S.id,initialIndex:S=>S.findIndex(T=>T.id===l),onActive:h,onPick:S=>{n==null||n.send({t:"set-theme",prefs:{...r,[e]:S.id}}),u()},onBack:f,placeholder:`${e} slot override`,keys:{nav:"preview",pick:"keeps",back:"reverts"},empty:"no matching theme",row:S=>d.jsx(In,{label:S.name,current:S.id===l,hint:vS(S)})}):d.jsx(qr,{items:x,filter:(S,T)=>S.filter(j=>{var $,R;return os(T,j.name,($=j.dark)==null?void 0:$.name,(R=j.light)==null?void 0:R.name)}),rowClass:()=>"picker-row",keyOf:S=>{var T,j;return S.name+(((T=S.dark)==null?void 0:T.id)??((j=S.light)==null?void 0:j.id))},initialIndex:S=>S.findIndex(T=>{var j,$;return((j=T.dark)==null?void 0:j.id)===l||(($=T.light)==null?void 0:$.id)===l}),onActive:g,onSide:S=>{var T;S.dark&&S.light&&w((((T=v(S,y))==null?void 0:T.kind)??a)==="dark"?"light":"dark")},onPick:S=>{n==null||n.send({t:"set-theme",prefs:A4(r,S)}),u()},onBack:f,placeholder:"theme",keys:{nav:"preview",side:"dark/light",pick:"keeps",back:"reverts"},empty:"no matching theme",row:(S,T)=>{var A,I;const j=v(S,T?y:null),$=vS(S.dark??S.light),R=((A=S.dark)==null?void 0:A.id)===l||((I=S.light)==null?void 0:I.id)===l;return d.jsx(In,{label:S.name,current:R,hint:d.jsxs("span",{className:"theme-kinds",children:[$&&d.jsx("span",{children:$}),d.jsx("span",{className:"kind","data-state":fr({current:T&&(j==null?void 0:j.kind)==="dark"}),children:S.dark?"dark":""}),d.jsx("span",{className:"kind","data-state":fr({current:T&&(j==null?void 0:j.kind)==="light"}),children:S.light?"light":""})]})})}})}function bA(){const e=x6(),t=L(s=>s.frame==="phone"),n=fl(),r=L(s=>s.activeRepoId),o=L(s=>s.newProject);return d.jsxs(d.Fragment,{children:[(e==null?void 0:e.kind)==="quick-open"&&n&&d.jsx(Eq,{worktreeId:n}),(e==null?void 0:e.kind)==="search"&&n&&d.jsx(XG,{worktreeId:n}),(e==null?void 0:e.kind)==="element-sources"&&d.jsx(PG,{worktreeId:e.worktreeId,hits:e.hits}),(e==null?void 0:e.kind)==="refs"&&r&&d.jsx(VG,{repoId:r}),(e==null?void 0:e.kind)==="chats"&&r&&d.jsx(kG,{repoId:r,scope:e.names?"names":"all"}),(e==null?void 0:e.kind)==="keys"&&d.jsx(nG,{}),(e==null?void 0:e.kind)==="devices"&&d.jsx(LG,{}),(e==null?void 0:e.kind)==="theme"&&d.jsx(QG,{slot:e.slot}),(e==null?void 0:e.kind)==="appearance"&&d.jsx(dG,{}),(e==null?void 0:e.kind)==="keep-awake"&&d.jsx(BG,{}),(e==null?void 0:e.kind)==="agent"&&d.jsx(cG,{}),(e==null?void 0:e.kind)==="agent-page"&&d.jsx(iG,{agentId:e.agent}),(e==null?void 0:e.kind)==="handoff"&&d.jsx(zG,{worktreeId:e.worktreeId}),(e==null?void 0:e.kind)==="commands"&&!t&&d.jsx(ZC,{}),(e==null?void 0:e.kind)==="projects"&&e.form!=="pill"&&d.jsx(Av,{form:e.form},e.form),(e==null?void 0:e.kind)==="choose-folder"&&o&&d.jsx(DG,{project:o})]})}const rh="Lost the daemon; retrying",bS="Not answering";function JG(e,t){return e!=="down"&&e!=="blocked"?rh:t===null?bS:`${bS}; as of ${jo(dr(t))}`}const eV="Not run by Toyon",xA="new worktree",EA=e=>`started from ${e}`,tV=(e,t)=>`in ${e}, ${EA(t)}`,nV=e=>`in ${e}, here while it needs you`,rV=new Set(["waiting","stopping","working","background","starting","preparing","failed","crashed"]);function bw(e,t){if(!Tn(e))return e.locked?`Held by ${e.lockReason??"another tool"}`:t.path;if(t.op)return ry(t.op);if(Tr(e.worktree))return xA;const n=ty(e,t.needsSetup),r=e.worktree.lastTurn;return!rV.has(Zs(e))&&r?Uy(r):t.at&&t.at!=="now"?`${n} · ${t.at}`:n}function oV(e,t){if(!Tn(e)||t)return!1;const n=Zs(e);return(n==="idle"||n==="asleep")&&!e.unseen}function sV(e){const t=e.worktree.lastTurn,n=e.worktree.landed?zy(e.worktree.lands):[],r=t?(is(e.agent)?v8:Uy)(t):void 0,o=Yh(e.worktree),s=o&&!e.worktree.landed?zs(o):void 0;return[...n,r,s].filter(a=>!!a)}function iV(e,t,n,r){let o;const s=(h,p)=>{const g=p==null?void 0:p[p.length-1];g&&(!o||g.at>o.mark.at)&&(o={title:h,mark:g})};for(const h of e)h.worktree&&s(h.worktree.title,h.worktree.lands);for(const h of t)s(h.title,h.lands);const a=o&&gj(o.mark),l=o?`Landed ${o.title} ${jo(dr(o.mark.at))}${a?`: ${no(a)}`:"."}`:void 0,u=n?dN(r,n):null,f=u?no(`${u.charAt(0).toUpperCase()}${u.slice(1)}`):n!=null&&n.fetchedAt?`Level with origin, fetched ${jo(dr(n.fetchedAt))}.`:void 0;return[l,f].filter(h=>!!h)}function aV(e){const t=e.prompt?Sp(e.prompt):"";return[...t?[t]:[],...zy(e.lands)]}function cV(e){const n=[e.auto&&lV(e.auto,!!e.landed),e.cost!==void 0?sd(e.cost):void 0].filter(r=>!!r);return n.length?n:void 0}function lV(e,t){const{what:n,idle:r}=aR(e);return r?`${t?"":`${n}, `}${r} idle`:n}const xS=25;function uV(e,t){if(e.length<=xS+1)return{shown:e,rest:0};const n=e.slice(0,xS),r=t?e.find(o=>o.id===t):void 0;return r&&!n.includes(r)&&n.push(r),{shown:n,rest:e.length-n.length}}function dV(e,t,n){const r=e.indexOf(t);return r<0?null:e[r+(n?1:-1)]??null}const fV=.5;function hV(e){const t=e.usage,n=t&&t.size>0?t.used/t.size:0,r=[n>=fV?`${Math.round(100*n)}% of context`:void 0,e.queued?`${e.queued} queued`:void 0,(t==null?void 0:t.cost)!==void 0?sd(t.cost):void 0].filter(o=>!!o);return r.length?r:void 0}function pV(e){const t=e.filter(ys).find(n=>n.id==="archive")??null;return[...t?[{id:"archive",label:t.label,icon:"archive",item:t}]:[],{id:"more",label:"more",icon:"more",item:null}]}function SA(e){return e.altKey?"Alt":e.ctrlKey?"Control":e.metaKey?"Meta":null}function xw(e,t){return t==="Alt"?e.altKey:t==="Control"?e.ctrlKey:e.metaKey}const mV=200,_A={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};function gV(){let e=null;return{press(t){e=SA(t)},holds(t){return e!==null&&xw(t,e)},keyup(t){e&&t===e&&(e=null)},mods(t){e&&!xw(t,e)&&(e=null)}}}function kV(e,t=_A){let n=null,r=!1,o=null;const s=()=>{r||(r=!0,e(!0))},a=()=>{o!==null&&(t.clear(o),o=null)},l=()=>{a(),n=null,r&&(r=!1,e(!1))};return{press(u){const f=n!==null;n=SA(u),a(),n&&(f?s():o=t.set(()=>{o=null,s()},mV))},keyup(u){n&&u===n&&l()},mods(u){n&&!xw(u,n)&&l()},end:l}}const wV=350,yV=80,vV=2e3;function bV(e,t=_A){let n=!1,r=null,o=null,s=null,a=null;const l=()=>{r&&(t.clear(r.pending),r=null)},u=()=>{s!==null&&t.clear(s),a!==null&&t.clear(a),s=null,a=null},f=()=>{l(),u(),o=null,n&&(n=!1,e(!1))};return{over(h){u(),a=t.set(f,vV),n||(n=!0,e(!0)),(r==null?void 0:r.id)!==(h==null?void 0:h.id)&&(l(),!(!h||h.id===o)&&(o=null,r={id:h.id,pending:t.set(()=>{r=null,o=h.id,h.land()},wV)}))},leave(){n&&(s!==null&&t.clear(s),s=t.set(f,yV))},end:f}}const Bf=e=>e>999?"1k+":String(e);function NA({width:e,placement:t="strip"}){const n=t==="screen",r=Ys(),o=Ep(),s=td("chat"),a=ht(),l=nt(),{host:u}=Mr(),f=xy(),h=f[0]&&Tr(f[0].worktree)?f[0]:null,p=h?f.slice(1):f,g=L(ne=>Hi(ne,ne.activeRepoId)),y=ne=>h&&ne.id===h.id&&g?{behind:g.behind,dirty:g.dirty}:ne,[,w]=E.useState(0);E.useEffect(()=>{const ne=setInterval(()=>w(we=>we+1),6e4);return()=>clearInterval(ne)},[]);const v=m6(),x=g6(),N=k6(),S=w6(),T=(ne,we,Ye)=>{ne.key!=="ArrowLeft"&&ne.key!=="ArrowRight"||ne.shiftKey||ne.altKey||ne.metaKey||ne.ctrlKey||(ne.preventDefault(),xp([{depth:0,open:we}],0,ne.key)&&a({a:Ye}))},j=Ga(),$=L(ne=>ne.notesPage),R=L(ne=>ne.clientId),A=L(ne=>ne.frame),I=L(ne=>ne.activeRepoId),M=L(ne=>ne.connected);E.useEffect(()=>{l&&M&&I&&l.send({t:"list-archived",repoId:I})},[l,M,I]);const P=fl(),F=iT(),q=L(ne=>ne.layout),W=L(ne=>ne.railOpen),ee=L(ne=>ne.railPeek),V=E.useRef(null),[te,K]=E.useState(!1);ct([ee],()=>{var ne;ee&&!n&&!r&&!((ne=V.current)!=null&&ne.matches(":hover"))&&K(!0)}),E.useEffect(()=>{if(!te)return;let ne=null;const we=Ye=>{if(!ne){ne={x:Ye.clientX,y:Ye.clientY};return}Math.abs(Ye.clientX-ne.x)+Math.abs(Ye.clientY-ne.y)<3||K(!1)};return window.addEventListener("pointermove",we),()=>window.removeEventListener("pointermove",we)},[te]);const[C,oe]=E.useState(!1),U=E.useMemo(()=>bV(oe),[]);E.useEffect(()=>()=>U.end(),[U]);const B=L(ne=>{var we;return((we=ne.dragFiles)==null?void 0:we.at)==="rail"?ne.dragFiles.worktreeId:null}),Q=L(ne=>ne.focusRail),ue=E.useRef(Q),he=E.useRef(null);ct([Q],()=>{if(Q===ue.current)return;ue.current=Q;const ne=requestAnimationFrame(()=>{var we,Ye;return(Ye=(we=he.current)==null?void 0:we.querySelector('[data-state~="current"]'))==null?void 0:Ye.focus()});return()=>cancelAnimationFrame(ne)});const Ne=(ne,we,Ye,ot,zt)=>{var D,se;if(ne.key!=="ArrowUp"&&ne.key!=="ArrowDown"||ne.altKey||ne.ctrlKey||ne.metaKey)return;ne.preventDefault();const Kt=dV(we,Ye,ne.key==="ArrowDown");Kt!==null&&(zt(Kt),(se=(D=he.current)==null?void 0:D.querySelector(`[${ot}="${Kt}"]`))==null||se.focus())},De=L(ne=>ne.repos),Be=L(ne=>ne.shipping),Z=L(ne=>ne.rows),J=ne=>De.find(we=>we.id===ne.repoId)??null,pe=ne=>I?hy(ne,I,Z):null,de=ne=>I&&ne.repoId!==I?J(ne):null,ie=xn("rail"),ye=Pn(),_e=_y(),be=L(ne=>ne.home),$e=ne=>{const we=ne.worktree?ne.worktree.path:ne.path;return be&&we.startsWith(`${be}/`)?`~${we.slice(be.length)}`:we},[Ze,rt]=E.useState(!1),[en,Xt]=E.useState([]),Et=ne=>{!Kf(ne.worktree)||de(ne)||(rt(!0),Xt(we=>we.includes(ne.worktree.id)?we.filter(Ye=>Ye!==ne.worktree.id):[...we,ne.worktree.id]))},Ke=()=>{rt(!1),Xt([])};ct([Ze],()=>{const ne=we=>we.key==="Escape"&&Ke();return Ze&&window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)});const Qt={sock:l,dispatch:a},Ot=ne=>dy(ye.getState(),ne),Zt=ne=>{rt(!0),Xt(we=>ne===P||we.includes(ne)?we:[...we,ne])},Ge=ne=>Tn(ne)?hj(ne,J(ne),{layout:q,shipping:Be,frame:A,drafted:Ot},Qt,{...de(ne)?{}:{graft:Zt},hostname:u}):a8(ne,{clientId:R,frame:A},Qt,u),[nn,pn]=E.useState(null),It=ne=>Tn(ne)?pV(Ge(ne)):[],gt=L(ne=>ne.left);JT(he,{rowOf:ne=>{if(!n||Ze||ON({left:gt},Date.now()))return null;const we=ne.closest(".slide"),Ye=we==null?void 0:we.dataset.row,ot=Ye?f.find(zt=>zt.id===Ye):void 0;return we&&Ye&&ot?{el:we,key:Ye,rungs:It(ot).length}:null},onSlide:pn,onPick:(ne,we)=>{var zt;const Ye=f.find(Kt=>Kt.id===ne),ot=Ye?It(Ye)[we-1]:void 0;if(!(!Ye||!ot)){if(ot.id==="more"){const Kt=(zt=he.current)==null?void 0:zt.querySelector(`.slide[data-row="${ne}"]`);Kt&&ie.openUnder(Kt,()=>Ge(Ye),ne)}else if(ot.item&&!ot.item.disabled){const Kt=ot.item.onClick;window.setTimeout(Kt,XT)}}}});const Vt=uV(N,(j==null?void 0:j.id)??null),Cn=Vt.shown.some(ne=>(ne.dirty??0)>0),Ce=ne=>d.jsxs("button",{type:"button",className:We("row row-edge row-quiet rail-disc-item rail-arch-item",(_e==null?void 0:_e.owner)==="rail"&&_e.key===ne.id&&"menu-open"),"data-state":fr({current:!n&&(j==null?void 0:j.id)===ne.id}),"data-arch":ne.id,...Nt(Q8(ne),void 0,{placement:s,card:!0,detail:aV(ne),aside:cV(ne)}),onClick:()=>a({a:"open-archived",id:ne.id}),onKeyDown:we=>Ne(we,Vt.shown.map(Ye=>Ye.id),ne.id,"data-arch",Ye=>a({a:"open-archived",id:Ye})),...ie.contextMenu(()=>Jf(ne,{clientId:R,frame:A},Qt),ne.id),children:[d.jsxs("span",{className:"rail-gut",onClick:r?we=>{we.stopPropagation(),ie.openUnder(we.currentTarget,()=>Jf(ne,{clientId:R,frame:A},Qt),ne.id)}:void 0,children:[d.jsx("span",{className:"rail-at row-dim",children:dr(ne.archivedAt)}),d.jsx("span",{className:"rail-more",...Nt("Actions"),onClick:we=>{we.stopPropagation(),ie.openUnder(we.currentTarget,()=>Jf(ne,{clientId:R,frame:A},Qt),ne.id)},children:d.jsx(xt,{name:"more"})})]}),d.jsx("span",{className:"branch",children:ne.title}),Cn&&d.jsx("span",{className:"rail-counts",children:d.jsx("span",{className:"rail-count row-dim","data-tip":ne.dirty?`${ne.dirty} uncommitted, kept`:void 0,children:ne.dirty?`~${Bf(ne.dirty)}`:""})}),ne.auto?d.jsx("span",{className:"rail-glyph rail-auto row-dim",children:d.jsx(xt,{name:"clock",className:"icon-inline"})}):d.jsx("span",{className:"dot"}),n&&d.jsx("span",{className:"rail-at rail-at-end row-dim",children:dr(ne.archivedAt)})]},ne.id),Pt=[...f,...v].map(y),Dt=["ahead","dirty","behind"].filter(ne=>Pt.some(we=>(we[ne]??0)>0)),Wt=ne=>{const we=Dt.findIndex(Ye=>(ne[Ye]??0)>0);return new Set(we<0?[]:Dt.slice(we))},Dn=ne=>{var _n;const we=Tn(ne)?ne:null,Ye=!!we&&Tr(we.worktree),ot=y(ne),zt=De.find(Mt=>Mt.id===ne.repoId)??null,Kt=zt?Vh(zt):"main",D=zt&&VR(zt)&&(g!=null&&g.fetchedAt)?` as of ${cp(g.fetchedAt)}`:"",se=Wt(ot),Se=!!ot.ahead&&!ot.dirty,ze=ne.id,Ut=(_e==null?void 0:_e.owner)==="rail"&&_e.key===ze,qt=we?pe(we):null,Oe=we?de(we):null,Fe=we&&!Oe?l3(we,Z,N):null,et=we&&!Oe&&Ze&&Kf(we.worktree)&&ze!==P,Ft=we&&we.worktree.kind==="worktree"&&!Oe?{title:we.worktree.title,branch:we.worktree.branch}:null,jt=lp(ne,(_n=Be[ze])==null?void 0:_n.op),On=d.jsxs("button",{type:"button",className:We("row row-edge",we?"rail-item":"row-quiet rail-disc-item",n&&oV(ne,jt)&&"row-quiet",Ut&&"menu-open",B===ze&&"drop-over"),"data-state":fr({current:!n&&ze===P&&!j&&!$,checked:en.includes(ze)}),...we?Nt(F?rh:mN(ne,jt,mh(J(we))),void 0,{placement:s,card:!0,aside:hV(ne),detail:Tr(we.worktree)?iV(f,N,g,Kt):[...Oe?[qt?tV(Oe.name,qt.worktree.title):nV(Oe.name)]:Fe?[EA(Fe)]:[],...sV(we)],dot:F?void 0:pN(ne,jt)}):Nt(F?rh:ne.locked?`Held by ${ne.lockReason??"another tool"}`:eV,void 0,{placement:s,card:!0,detail:$e(ne),dot:F||ne.locked?void 0:"discovered"}),"data-wt":ze,draggable:o&&Ft!==null,onDragStart:Ft!==null?Mt=>Pu(Mt,{kind:"worktree",worktreeId:ze,...Ft}):void 0,onDragEnd:()=>od(ye),onKeyDown:Mt=>{if(Ze)return;const mn=(we?f:v).map(rr=>rr.id);Ne(Mt,mn,ze,"data-wt",rr=>a({a:"activate",id:rr}))},onClick:Mt=>{we&&!Oe&&(Ze||Mt.shiftKey)?ze===P?rt(!0):Et(we):Ye&&!n?a({a:"open-draft"}):(a({a:"activate",id:ze}),we&&!r&&a({a:"walked"}))},...ie.contextMenu(()=>Ge(ne),ze),children:[d.jsx("span",{className:"rail-gut",onClick:r&&!Ze?Mt=>{Mt.stopPropagation(),ie.openUnder(Mt.currentTarget,()=>Ge(ne),ze)}:void 0,children:et?d.jsx("input",{type:"checkbox",className:"rail-graft-check",checked:en.includes(ze),readOnly:!0,tabIndex:-1}):!Ze&&d.jsxs(d.Fragment,{children:[we&&!Ye&&d.jsx("span",{className:"rail-at row-dim",children:dr(Da(we.worktree))}),d.jsx("span",{className:"rail-more",...Nt("Actions"),onClick:Mt=>{Mt.stopPropagation(),ie.openUnder(Mt.currentTarget,()=>Ge(ne),ze)},children:d.jsx(xt,{name:"more"})})]})}),Ye?d.jsxs("span",{className:"branch rail-main-label",children:[d.jsx(xt,{name:"plus",className:"icon-inline"}),"new worktree"]}):d.jsx("span",{className:We("branch",(we==null?void 0:we.worktree.unnamed)&&"row-dim"),children:vk(ne,we?J(we):null)}),(we==null?void 0:we.worktree.mode)&&we.worktree.mode!=="auto"&&d.jsx("span",{className:"rail-badge badge-mode","data-tip":`${we.worktree.mode} mode: the agent waits for you`,children:we.worktree.mode}),Oe&&d.jsx("span",{className:"rail-guest row-dim",children:Oe.name}),d.jsxs("span",{className:"rail-counts",children:[se.has("ahead")&&d.jsx("span",{className:"rail-count badge-ahead","data-tip":ot.ahead?`${ot.ahead} ahead of ${Kt}`:void 0,children:ot.ahead?`+${Bf(ot.ahead)}`:""}),se.has("dirty")&&!Se&&d.jsx("span",{className:"rail-count badge-dirty","data-tip":ot.dirty?`${ot.dirty} uncommitted${Ye?" on main":""}`:void 0,children:ot.dirty?`~${Bf(ot.dirty)}`:""}),se.has("behind")&&d.jsx("span",{className:"rail-count rail-behind row-dim","data-tip":ot.behind?`${ot.behind} behind ${Ye?"origin":Kt}${Ye?"":D}`:void 0,children:ot.behind?Bf(ot.behind):""}),n&&we&&d.jsx("span",{className:"rail-at row-dim",children:Ye?"":dr(Da(we.worktree))})]}),(()=>{if(jt)return d.jsx("span",{className:"dot background"});if(ne.locked)return d.jsx("span",{className:"rail-glyph rail-lock row-dim",children:d.jsx(xt,{name:"lock",className:"icon-inline"})});if(!we)return d.jsx("span",{className:"dot discovered"});const Mt=Ze||F?null:gN(ne.procs),mn=ne.unseen?" unseen":"",rr=Zs(ne);return Ye&&!Mt&&rr!=="crashed"&&!F?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:`dot ${rr} rail-main-dot`}),d.jsx("span",{className:"rail-glyph rail-main-strip",children:d.jsx(xt,{name:"plus"})})]}):!Mt||rr!=="crashed"?d.jsx("span",{className:`dot ${rr}${mn}`}):d.jsx("span",{className:`dot crashed clickable${mn}`,...Nt(Mt.tip),onClick:Ct=>{Ct.stopPropagation(),a({a:"activate",id:ze}),a({a:"term-stream",id:ze,stream:Mt.stream})}})})(),n&&d.jsx("span",{className:"rail-say row-dim",children:bw(ne,{needsSetup:mh(we?J(we):null),path:$e(ne),op:jt})})]},ze);if(!n||!we)return On;const Mn=(nn==null?void 0:nn.key)===ze?nn.step:null,yn=Mn===null?null:It(ne)[Math.max(0,Mn-1)],tn=!!yn&&Mn!==null&&Mn>0&&(yn.id==="more"||!!yn.item&&!yn.item.disabled);return d.jsxs("div",{className:"slide","data-row":ze,children:[On,yn&&d.jsxs("span",{className:"slide-verb","data-rung":tn?yn.id:void 0,"aria-hidden":"true",children:[d.jsx("span",{className:"slide-word",children:yn.label}),d.jsx(xt,{name:yn.icon})]})]},ze)};return d.jsx("div",{ref:V,className:We("rail",n&&"rail-screen",!n&&(Ze||(_e==null?void 0:_e.owner)==="rail"||ee||C)&&"hold",te&&"quiet",(n||W)&&"pinned",F&&"offline"),style:e!==void 0&&!n?{"--rail-width":`${e}px`}:void 0,onClick:r&&!n&&!W?ne=>{ne.target instanceof Element&&ne.target.closest("button, .rail-gut")||a({a:"toggle-rail"})}:void 0,onDragOver:ne=>{var zt;if(!Lk(ne.dataTransfer))return;const we=ne.target instanceof Element?(zt=ne.target.closest("[data-wt]"))==null?void 0:zt.dataset.wt:void 0,Ye=we?[...f,...v].find(Kt=>Kt.id===we):void 0;if(!Ye||Ze||Ye.id===P)return U.over(null);const ot=!n&&Tn(Ye)&&Tr(Ye.worktree);U.over({id:Ye.id,land:()=>a(ot?{a:"open-draft"}:{a:"activate",id:Ye.id})})},onDragLeave:U.leave,onDrop:U.end,children:d.jsx("div",{className:"rail-panel","data-tip":F?rh:void 0,"data-tip-placement":"follow",children:d.jsxs("div",{className:"rail-list",ref:he,children:[h&&!n&&Dn(h),p.map(Dn),Ze&&d.jsxs("div",{className:"rail-graft",children:[(()=>{const ne=f.find(ot=>ot.worktree.id===P&&Kf(ot.worktree)&&!de(ot)),we=en.filter(ot=>ot!==(ne==null?void 0:ne.worktree.id)),Ye=we.map(ot=>{var zt;return((zt=f.find(Kt=>Kt.worktree.id===ot))==null?void 0:zt.worktree.title)??ot}).join(", ");return d.jsxs(Me,{size:"md",tone:"primary",disabled:!ne||we.length===0,"data-tip":ne?`Merge the checked worktrees into ${ne.worktree.title} and remove them`:"Select a worktree to graft onto",onClick:()=>{ne&&window.confirm(`Graft ${Ye} onto ${ne.worktree.title}?
277
-
278
- Their branches are merged in, then their directories and branches are removed.`)&&(l==null||l.send({t:"graft",targetId:ne.worktree.id,sourceIds:we}),Ke())},children:["graft ",we.length]})})(),d.jsxs(Me,{size:"md",disabled:!en.some(ne=>{var we;return(((we=f.find(Ye=>Ye.worktree.id===ne))==null?void 0:we.behind)??0)>0}),"data-tip":"Pull main into every selected worktree that's behind",onClick:()=>{for(const ne of en){const we=f.find(Ye=>Ye.worktree.id===ne);((we==null?void 0:we.behind)??0)>0&&Li(l,a,{t:"sync-main",worktreeId:ne})}Ke()},children:[d.jsx(xt,{name:"pull",className:"icon-inline"})," sync"]}),d.jsx(Me,{size:"md",tone:"danger",disabled:en.length===0,"data-tip":"Archive all selected worktrees; their chats and work are kept",onClick:()=>{window.confirm(`Archive ${en.length} worktree(s)?
279
-
280
- Their directories and branches go. The chats, commits and any uncommitted changes are kept, and each can be restored.`)&&(Gc(l,a,en),Ke())},children:"archive…"}),d.jsx(Tt,{icon:"close",label:"Cancel",hint:"esc",onClick:Ke})]}),!Ze&&v.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{className:"section-title section-row section-fold rail-disc-head","aria-expanded":x,...Nt(`${v.length} worktree${v.length===1?"":"s"} here that Toyon did not make`,void 0,{placement:s}),onClick:()=>a({a:"toggle-discovered"}),onKeyDown:ne=>T(ne,x,"toggle-discovered"),children:[d.jsx("span",{className:"rail-gut",children:d.jsx(xt,{name:"caret",className:We("icon-inline disc-caret",!x&&"shut")})}),d.jsx("span",{className:"rail-label",children:"discovered"})]}),x&&v.map(Dn)]}),!Ze&&N.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold rail-disc-head","aria-expanded":S,...Nt(`${N.length} archived worktree${N.length===1?"":"s"}, kept with ${N.length===1?"its chat":"their chats"}`,void 0,{placement:s}),onClick:()=>a({a:"toggle-archived"}),onKeyDown:ne=>T(ne,S,"toggle-archived"),children:[d.jsx("span",{className:"rail-gut",children:d.jsx(xt,{name:"caret",className:We("icon-inline disc-caret",!S&&"shut")})}),d.jsx("span",{className:"rail-label",children:"archived"})]}),S&&Vt.shown.map(Ce),S&&Vt.rest>0&&I&&d.jsxs("button",{type:"button",className:"row row-quiet rail-disc-item rail-arch-item",...Nt("Find an older one by its name, branch or first message",void 0,{placement:s}),onClick:()=>a({a:"open",overlay:{kind:"chats",names:!0}}),children:[d.jsx("span",{className:"rail-gut"}),d.jsxs("span",{className:"branch row-dim",children:[Vt.rest," more"]}),d.jsx("span",{className:"dot"})]})]})]})})})}const Dh=["home","chat","preview","changes"],xV=(e,t)=>Dh.indexOf(t)<Dh.indexOf(e)?"left":"right";function EV(e,t,n,r=null){if(e==="home")return t!=="left"||!r||r==="home"?null:r==="preview"&&!n?"chat":r;const o=Dh.filter(a=>a!=="preview"||n),s=o.indexOf(e);return s<0?null:o[s+(t==="right"?-1:1)]??null}function SV({screen:e,tabs:t,fold:n,beside:r=!1,away:o=!1}){const s=ht(),a=xs(),l=Gs(),u=L(he=>he.reading),f=L(he=>he.typing),h=b6(),p=hl(),g=L(he=>he.repos),y=Vs(),w=fl(),v=Ga(),x=Ey(),N=xy(),S=iT(),T=L(he=>he.connectFailure),j=L(he=>he.recalledAt??he.heardAt);Mi(S&&j!==null?j:void 0);const $=JG(T,j),R=JN(),A=y9(N,w,R),I=N.find(he=>Tr(he.worktree)),M=e==="home",P=!M&&!v&&!!y&&Tr(y.worktree),F=L(he=>{var Ne;return P&&y?lp(y,(Ne=he.shipping[y.id])==null?void 0:Ne.op):null}),q=gy().length,W=a.displayName(l.origin),ee=M?(h==null?void 0:h.name)??W:P?xA:(v==null?void 0:v.title)??(y==null?void 0:y.worktree.title)??(x==null?void 0:x.name)??null,V=N.filter(he=>!Tr(he.worktree)).length,te=V===0?"no worktrees yet":`${V} ${V===1?"worktree":"worktrees"}`,K=L(he=>he.sharing),C=M?S?$:K||(h&&q>1?`${W} · ${te}`:te):v?Cj(v):S?$:P?F?ry(F):(h==null?void 0:h.name)??null:y?bw(y,{needsSetup:mh(p),path:y.worktree.path,at:dr(Da(y.worktree))}):x?bw(x,{needsSetup:!1,path:x.path}):null,oe=!M&&!v&&!!y&&Zs(y)==="waiting",U=L(he=>{var Ne;return((Ne=he.overlay)==null?void 0:Ne.kind)==="projects"&&he.overlay.form==="pill"})&&!r,B=L(he=>{var Ne;return((Ne=he.overlay)==null?void 0:Ne.kind)==="commands"})&&!r,Q=d.jsxs("div",{className:"phone-title",children:[M&&(g.length>1||q>1)?d.jsxs("span",{className:"phone-drop phone-switch",children:[d.jsxs(Me,{tone:"chrome",on:U,onClick:()=>s({a:"toggle",overlay:{kind:"projects",form:"pill"}}),children:[d.jsx("span",{className:"phone-name",children:ee}),d.jsx(xt,{name:"caret",className:"icon-inline"})]}),U&&d.jsx(Av,{form:"pill",anchored:{margin:6}})]}):d.jsx("span",{className:"phone-name",children:ee}),C&&d.jsx("span",{className:We("phone-sub",oe&&"phone-sub-asks"),children:C})]}),ue=A&&d.jsxs(Me,{size:"md",tone:"primary",onClick:()=>{const he=v9(N,w,R);if(!he)return;if(he.origin===null)return s({a:"activate",id:he.activate});const Ne=a.get(he.origin);Ne&&(Ne.store.dispatch({a:"activate",id:he.activate}),a.activate(he.origin))},children:[A.n," ",A.tier]});return d.jsxs("div",{className:"phone-bar",children:[d.jsxs("div",{className:"phone-bar-row",children:[!M&&d.jsx(Tt,{icon:"back",label:"Worktrees",tone:"chrome",onClick:()=>s({a:"screen",to:"home"})}),t?d.jsx("div",{className:"phone-tabs",children:t}):Q,!t&&ue,M&&I&&d.jsx(Tt,{icon:"plus",label:"New worktree",tone:"chrome",onClick:()=>s({a:"activate",id:I.id})}),d.jsxs("span",{className:"phone-drop",children:[d.jsx(Tt,{icon:"more",label:"Menu",tone:"chrome",on:B,onClick:()=>s({a:"toggle",overlay:{kind:"commands"}})}),B&&d.jsx(ZC,{anchored:{flip:"align",margin:6},trailing:d.jsx(Tt,{icon:"close",label:"Close",tone:"chrome",onClick:()=>s({a:"close"})})})]})]}),t&&!n&&d.jsx("div",{className:"phone-title-seat","data-away":u||f||o||void 0,children:d.jsxs("div",{className:"phone-title-strip",children:[Q,ue]})})]})}const oh="toyonDepth",TA="toyonOver",Qg=-1;function Jg(e){return e.frame!=="phone"||!e.heard&&e.recalledAt===null?null:e.screen!=="home"&&(Kr(e,e.activeId)!==null||Wo(e)!==null)?1+(e.editor?1:0):0}const jA=(()=>{const e=new Set;return{watch(t){return e.add(t),()=>e.delete(t)},tell(t){for(const n of e)n(t)}}})(),ek=e=>{const t=e&&typeof e=="object"?e[oh]:void 0;return typeof t=="number"?t:null},_V=e=>!!e&&typeof e=="object"&&e[TA]===!0;function NV(e,t=window,n=nl,r=jA){const o=t.history;let s=ek(o.state)??Qg,a=ek(o.state)!==null,l=null;const u=()=>{const T=n.open();l&&!T.includes(l)&&(l=null);for(let j=T.length-1;j>=0;j--){const $=T[j];if($!=null&&$.dismiss&&$!==l)return $}return null};let f=!1;const h=()=>{const T=Jg(e.getState());if(T===null||f)return;a||(o.replaceState({[oh]:Qg},""),a=!0);const j=T+(u()?1:0);if(j!==s)if(j>s){for(let $=s+1;$<=j;$++)o.pushState({[oh]:$,[TA]:$>T},"");s=j}else o.go(-1),f=!0};let p=!1;const g=()=>{p||(p=!0,queueMicrotask(()=>{p=!1,h()}))},y=(T,j)=>{const $=u();if($){l=$,n.shut($);return}const R=j===0?"home":T.screen;e.dispatch({a:"screen",to:R})},w=T=>{const j=f;f=!1,s=ek(T.state)??Qg;const $=e.getState(),R=Jg($);if(R===null)return;if(s<0){o.pushState({[oh]:0},""),s=0,h();return}if(j){h();return}const A=R+(u()?1:0);A!==s&&(A>s?y($,s):A===0&&$.activeId&&!_V(T.state)&&e.dispatch({a:"screen",to:"chat"}),h())},v=T=>{if(f){f=!1,h();return}const j=e.getState(),$=Jg(j);$===null||$===0||j.screen==="preview"&&!j.editor&&$===1||T.dir==="forward"||y(j,$+(u()?1:0)-1)};t.addEventListener("popstate",w);const x=e.subscribe(h),N=n.watch(g),S=r.watch(v);return h(),()=>{t.removeEventListener("popstate",w),x(),N(),S()}}function TV({gated:e,active:t,url:n,onTouch:r}){const o=fp(t),s=iF(Gs(),o?n:null,e),a=E.useRef(null),l=E.useRef(r);return l.current=r,E.useEffect(()=>{if(!s)return;const u=new URL(s,location.href).origin,f=h=>{var y,w;const p=(y=a.current)==null?void 0:y.contentWindow;if(!p||h.source!==p||h.origin!==u||!((w=h.data)!=null&&w.__toyon))return;const g=q_(h.data);(g==null?void 0:g.type)==="traversed"?jA.tell({dir:g.dir??null}):(g==null?void 0:g.type)==="touch"?l.current(g):(g==null?void 0:g.type)==="loaded"&&p.postMessage({__toyon:!0,type:"touches",on:!0},u)};return window.addEventListener("message",f),()=>window.removeEventListener("message",f)},[s]),d.jsx("div",{className:"phone-preview",children:o&&s?d.jsx("iframe",{ref:a,className:"phone-preview-frame",src:s,title:t.worktree.title}):d.jsx(Es,{wide:!0,children:d.jsx("p",{className:"status-line",children:ty(t)})})})}function jV(e){return e.incompatible?{kind:"updated",foreign:e.serving?null:e.machine}:e.said?{kind:"say"}:e.onWorktree?e.editor?{kind:"editor"}:{kind:"tab",tab:e.tab}:{kind:"home"}}const $V=hh(),CV=!UT(),AV={current:null};function IV(){const e=E.useRef(null),t=E.useRef(null),n=E.useRef(null);u6(e),d6(e);const r=ht(),o=L(ue=>ue.screen),s=Vs(),a=Ga(),l=Ey(),u=L(ue=>ue.editor),f=L(ue=>ue.left),h=L(ue=>ue.remote),p=ed(),g=L(ue=>ue.connected),y=L(ue=>ue.heard),w=L(ue=>ue.recalledAt!==null||ue.heard),v=L(ue=>ue.connectFailure),x=Ys(),N=Gs(),S=xs(),[T,j]=E.useState(null),[$,R]=E.useState(null),A=L(ue=>ue.incompatible),I=rj({connected:g,heard:y,standing:w,connectFailure:v,hasToken:N.serving?$V:!0,projectChord:Ht("project"),title:(s==null?void 0:s.worktree.title)??null,machine:N.serving?null:S.displayName(N.origin)}),M=o!=="home"&&(s!==null||a!==null||l!==null),P=!M&&T!==null&&T!=="home",F=!p&&!a?s:null,q=M||P?F:null,{host:W}=Mr(),ee=q?fN(q.worktree.id,q.worktree.proxyPort,h,W):null,V=o==="preview"&&!q?"chat":o,te=jV({incompatible:A,serving:N.serving,machine:S.displayName(N.origin),said:I!==null,onWorktree:M,editor:u!==null,tab:V}),K=te.kind==="home"?"home":te.kind==="tab"?te.tab:null,C=q!==null&&ee!==null,oe=HF(CV?e:AV,{take:(ue,he)=>{if(T!==null)return null;const Ne=te.kind==="tab"?te.tab:te.kind==="home"?"home":null;if(!Ne)return null;const De=Ne==="home"?ON({left:f},Date.now()):null;if(he==="left"&&!De&&ue.closest(".slide"))return null;const Be=EV(Ne,he,F!==null,De);return Be?(j(Be),(Be==="home"||Ne==="home"?t:n).current):null},onSettle:ue=>{ue&&T&&R(T)},onEnd:ue=>{ue&&T&&r({a:"screen",to:T}),j(null),R(null)}}),U=(ue,he)=>d.jsx(SV,{screen:ue==="home"?"home":"chat",beside:he,fold:ue!=="chat"||u!==null,away:!he&&T!==null&&T!=="home",tabs:ue!=="home"&&I===null&&d.jsx(Ya,{fill:!0,segmented:!0,owner:"phone-tabs",label:"worktree",items:Q,current:$&&$!=="home"?$:ue,onPick:Ne=>r({a:"screen",to:Ne})})}),B=te.kind==="updated"?d.jsx(nj,{foreign:te.foreign??void 0}):te.kind==="say"&&I?d.jsx(Es,{wide:!0,children:d.jsx("p",{className:We("status-line",I.live&&"live-text"),children:I.text})}):te.kind==="editor"&&u?d.jsx(mA,{editor:u,placement:"screen"}):null,Q=[{id:"chat",label:"chat"},...q&&ee?[{id:"preview",label:"preview",trail:d.jsx(Tt,{icon:"external",label:"Open in browser",tone:"chrome",onClick:()=>aF(N,ee,Pk(N,h))})}]:[],{id:"changes",label:"code"}];return d.jsxs("div",{ref:e,className:"app phone","data-chat-side":"left","data-touch":x||void 0,"data-hover":!x||void 0,children:[d.jsx(qT,{}),d.jsx(YT,{}),d.jsx("div",{className:"phone-screen",children:d.jsxs("div",{className:"center-root",children:[d.jsxs("div",{className:"phone-track",ref:t,children:[(!M||T==="home")&&d.jsxs("div",{className:"phone-face","data-side":M?"left":void 0,children:[U("home",M),!M&&K===null?B:d.jsx(NA,{placement:"screen"})]},"home"),(M||P)&&d.jsxs("div",{className:"phone-face","data-side":P?"right":void 0,children:[U(P&&T?T:V,P),d.jsxs("div",{className:"phone-track",ref:n,children:[K===null&&d.jsx("div",{className:"phone-face",children:B},"cover"),Dh.map(ue=>{if(ue==="home")return null;const he=P?ue===T:ue===K,Ne=ue===T&&!he;return!he&&!Ne&&!(ue==="preview"&&C)?null:d.jsx("div",{className:"phone-face",hidden:!he&&!Ne,"data-side":Ne&&K?xV(K,ue):void 0,children:ue==="chat"?d.jsx(_u,{placement:"screen",archived:a,found:l}):ue==="changes"?d.jsx(Tj,{placement:"screen"}):q&&ee?d.jsx(TV,{gated:Pk(N,h),active:q,url:ee,onTouch:oe},q.worktree.id):null},ue)})]})]},"worktree")]}),d.jsx(bA,{})]})})]})}function RV(){try{const e=localStorage.getItem(it.theme);if(e){const t=JSON.parse(e);if(t!=null&&t.colors&&typeof t.colors.surface0=="string")return t}}catch{}return Xu}function OV(){if(Ly()!=="phone")return"surface0";try{const e=sessionStorage.getItem(it.ground);if(e==="surface0"||e==="surface1")return e}catch{}return"surface1"}function $A(e,t={}){var s,a;const n=document.documentElement;for(const[l,u]of Object.entries(_4(e)))n.style.setProperty(l,u);n.style.colorScheme=e.kind,n.dataset.theme=e.kind;const r=t.ground??OV();n.dataset.ground=r;const o=Ly()==="phone"?e.colors[r]:e.colors.surface1;if((s=document.querySelector('meta[name="theme-color"]'))==null||s.setAttribute("content",o),(a=document.querySelector('link[rel="manifest"]'))==null||a.setAttribute("href",t.black?"/manifest.json?black=1":"/manifest.json"),t.remember!==!1)try{localStorage.setItem(it.theme,JSON.stringify(e))}catch{}}function CA(e){const t=Gw(e);return{type:"theme",accent:t,accentFg:M4(t)}}function MV(){var e;return((e=window.matchMedia)==null?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)??!0}const LV=12*36e5;function PV(){try{const e=localStorage.getItem(it.daylight);if(!e)return null;const t=JSON.parse(e);if(typeof(t==null?void 0:t.dark)!="boolean"||typeof t.until!="number")return null;const n=Date.now()-t.until;return n<0?t:n<LV?{dark:!t.dark,until:0}:null}catch{return null}}function DV(e){try{localStorage.setItem(it.daylight,JSON.stringify(e))}catch{}}function zV(e){var r;const t=(r=window.matchMedia)==null?void 0:r.call(window,"(prefers-color-scheme: dark)");if(!t)return()=>{};const n=o=>e(o.matches);return t.addEventListener("change",n),()=>t.removeEventListener("change",n)}function FV(e,t){return{word:`what's new in ${t}`,text:`Toyon updated from ${e} to ${t} since you last opened it here. Press to read what changed`}}function ES(e,t){return t==="reading"?"Reading the release notes":`No release notes could be read from Toyon ${e}.`}function BV(){const e=Mr(),t=L(s=>s.version),[n,r]=E.useState(void 0);E.useEffect(()=>{let s=!0;return G4(e).then(a=>{s&&r(a)}),()=>{s=!1}},[e]);const o=ol(n??"",{keepHtml:!0});return n?d.jsx("div",{className:"notes-page",children:d.jsx(Cv,{html:o})}):d.jsx(Es,{wide:!0,children:d.jsx("p",{className:"status-line",children:n===void 0?d.jsx("span",{className:"live-text",children:ES(t,"reading")}):ES(t,"missing")})})}function Ew(e,t){return[{id:"copy-name",label:"copy name",detail:e,onClick:()=>sn(e)},{id:"copy-value",label:"copy value",detail:t,onClick:()=>sn(t)}]}function Sw(e){return[{id:"copy-value",label:"copy value",detail:e,onClick:()=>sn(e)}]}function UV(e,t,{sock:n},r){return t?Un([[{id:"source",label:"open source",onClick:r}],Ko(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id,path:t}),wo(n)),[{id:"copy-path",label:"copy path",onClick:()=>sn(t)}]]):[]}function Yu(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());if(!t)return null;const n=t[1],r=n.length===3||n.length===4?[...n].map(s=>s+s).join(""):n;if(r.length!==6&&r.length!==8)return null;const o=Number.parseInt(r.slice(0,6),16);return[o>>16&255,o>>8&255,o&255]}function HV(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());return t?t[1].length===4||t[1].length===8:!1}function SS([e,t,n]){const r=o=>{const s=o/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function AA(e,t){if(HV(e))return null;const n=Yu(e);if(!n)return null;const r=Yu(t);if(!r)return null;const[o,s]=[SS(n),SS(r)];return`${((Math.max(o,s)+.05)/(Math.min(o,s)+.05)).toFixed(2)}:1`}function WV({worktreeId:e,height:t,full:n,onToggleFull:r,onDragStart:o}){const s=ht(),a=nt(),l=L(f=>Or(f,e).design);E.useEffect(()=>{l||a==null||a.send({t:"design-scan",worktreeId:e})},[l,e,a]),E.useEffect(()=>()=>fn.post(e,{type:"highlight-clear"}),[e]);const u={outline:f=>fn.post(e,f),clear:()=>fn.post(e,{type:"highlight-clear"}),open:f=>Rn({dispatch:s},{worktreeId:e,path:f})};return d.jsx(Zy,{kind:"design",className:We("design-pane",n&&"full"),height:n?void 0:t,resizable:!n,onDragStart:o,title:l?d.jsx("span",{children:GV(l)}):void 0,onClose:()=>s({a:"toggle-design"}),closeHint:Ht("design"),full:n,onToggleFull:r,actions:d.jsxs(Me,{variant:"outline",onClick:()=>a==null?void 0:a.send({t:"design-scan",worktreeId:e}),"data-tip":"Scan this worktree again",children:[d.jsx(xt,{name:"reload",className:"icon-inline"})," rescan"]}),children:l?d.jsxs("div",{className:"design-body",style:ZV,onMouseLeave:u.clear,children:[l.tokens.length===0&&l.literals.length>0?d.jsx(eY,{literals:l.literals,outline:u.outline,clear:u.clear}):d.jsx(QV,{tokens:l.tokens,coverage:l.coverage,outline:u.outline,clear:u.clear}),d.jsx(lY,{index:l,outline:u.outline,clear:u.clear,onOpen:u.open}),d.jsx(uY,{index:l,outline:u.outline,clear:u.clear,onOpen:u.open})]}):d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"reading the design system"})})})}const KV=720,qV=132,ZV={"--design-column":`${KV}px`,"--design-cell":`${qV}px`};function GV(e){const t=Object.values(e.coverage.files).reduce((r,o)=>r+o,0),n=e.coverage.stylesheets;return`${t} file${t===1?"":"s"} read, ${n} stylesheet${n===1?"":"s"}`}const Uc=e=>`${e} use${e===1?"":"s"}`;function Hp({title:e,note:t,children:n}){return d.jsxs("section",{className:"design-section",children:[d.jsxs("h2",{className:"design-h",children:[e,t&&d.jsx("span",{className:"design-note",children:t})]}),n]})}function zh({children:e}){return d.jsx("p",{className:"design-gap",children:e})}const VV=[{kind:"font",label:"type"},{kind:"color",label:"color"},{kind:"length",label:"size & radius"},{kind:"shadow",label:"shadow"},{kind:"other",label:"computed"}];function YV(e){return e.find(t=>t.kind==="color"&&Yu(t.resolved??t.value)!==null)}function XV(e){if(e.stylesheets===0)return"No stylesheet was read, so there is no palette or type scale to show.";const t=e.files,n=(t.scss??0)+(t.sass??0)+(t.less??0)+(t.styl??0),r="No custom properties, and no colors or sizes written out in the stylesheets.";return n>0?`${r} Sass, Less and Stylus variables are not read yet.`:r}function QV({tokens:e,coverage:t,outline:n,clear:r}){const o=YV(e),s=o&&(o.resolved??o.value),a=new Map;for(const u of e){const f=(u.resolved??u.value).trim().toLowerCase();a.set(f,[...a.get(f)??[],u.name])}const l=u=>(a.get((u.resolved??u.value).trim().toLowerCase())??[]).filter(f=>f!==u.name);return d.jsx(Hp,{title:"Tokens",children:e.length===0?d.jsx(zh,{children:XV(t)}):VV.map(({kind:u,label:f})=>{const h=e.filter(g=>g.kind===u);if(h.length===0)return null;const p=RA(h.map(g=>g.value));return d.jsxs("div",{className:"design-group",children:[u!=="font"&&d.jsx("span",{className:"design-group-name",children:f}),u==="font"?d.jsx(OA,{groups:sY(h),outline:n,clear:r}):d.jsx("div",{className:"design-breakout",style:IA(h.length),children:d.jsx("div",{className:"design-grid",children:h.map(g=>{const y=g.resolved??g.value,w=g.kind==="color"&&s?AA(y,s):null;return d.jsx(MA,{kind:g.kind,name:g.name,lines:g.resolved?[g.value,g.resolved]:[g.value],actual:y,ratio:w,largest:p,tipText:aY(g,w,o,l(g)),menu:()=>Ew(g.name,y),outline:n,clear:r},g.name)})})})]},u)})})}const JV=[{role:"color",kind:"color",label:"color"},{role:"radius",kind:"length",label:"radius"},{role:"shadow",kind:"shadow",label:"shadow"}];function eY({literals:e,outline:t,clear:n}){const r=e.find(s=>s.ground&&Yu(s.value)!==null),o=iY(e);return d.jsxs(Hp,{title:"Values",note:"written out in the rules; no custom properties",children:[o.length>0&&d.jsx("div",{className:"design-group",children:d.jsx(OA,{groups:o,outline:t,clear:n})}),JV.map(({role:s,kind:a,label:l})=>{const u=e.filter(h=>h.role===s);if(u.length===0)return null;const f=RA(u.map(h=>h.value));return d.jsxs("div",{className:"design-group",children:[d.jsx("span",{className:"design-group-name",children:l}),d.jsx("div",{className:"design-breakout",style:IA(u.length),children:d.jsx("div",{className:"design-grid",children:u.map(h=>{const p=a==="color"&&r?AA(h.value,r.value):null;return d.jsx(MA,{kind:a,name:h.value,lines:[Uc(h.uses)],actual:h.value,ratio:p,largest:f,tipText:cY(h,p,r),menu:()=>Sw(h.value),outline:t,clear:n},h.value)})})})]},s)})]})}function IA(e){const t="var(--design-cell)",n=`min(round(down, 100%, ${t}), calc(${e} * ${t}))`,r=`round(down, var(--design-column), ${t})`,o=`round(down, max(0px, calc((${n} - ${r}) / 2)), ${t})`;return{width:n,marginLeft:`max(0px, calc((100% - var(--design-column)) / 2 - ${o}))`}}function RA(e){return e.reduce((t,n)=>Math.max(t,Math.abs(Number.parseFloat(n))||0),0)}const tY=["color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color","outline-color"];function nY(e,t){if(!e)return[];const n=getComputedStyle(e);return t.map(r=>[r,n.getPropertyValue(r)])}const _w=e=>(e.split(",")[0]??e).replace(/["']/g,"").trim();function rY(e){const t=/^[1-9]00\s+([\d.]+)px(?:\s*\/\s*([\d.]+)(px)?)?\s+(.+)$/.exec(e.trim());if(!t)return{family:_w(e),size:null,lead:null};const n=Number(t[1]),r=t[2]?Number(t[2]):null,o=r===null?null:Math.round((t[3]?r:n*r)*100)/100;return{family:_w(t[4]??""),size:n,lead:o}}function tk(e){const t=Number.parseFloat(e);return e.endsWith("em")?t*16:e.endsWith("pt")?t*4/3:e.endsWith("%")?t/100*16:t}function oY(e,t){if(!e)return null;const n=Number.parseFloat(e),r=/^[\d.]+$/.test(e)?t*n:e.endsWith("px")?n:null;return r===null?null:Math.round(r*100)/100}function sY(e){const t=e.map(n=>({token:n,actual:n.resolved??n.value,...rY(n.resolved??n.value)}));return[...new Set(t.map(n=>n.family))].map(n=>{const r=t.filter(s=>s.family===n),o=r.find(s=>s.size===null);return{family:n,stack:o?o.actual:n,name:o==null?void 0:o.token.name,label:o?o.token.name:n,tipText:o?`${o.token.name}
281
- ${o.actual}`:void 0,menu:()=>o?Ew(o.token.name,o.actual):[],rows:r.filter(s=>s.size!==null).sort((s,a)=>(a.size??0)-(s.size??0)).map(s=>({key:s.token.name,sample:`${s.family} ${s.size}${s.lead===null?"":`/${s.lead}`}`,style:{font:s.actual},name:s.token.name,label:s.token.name,tipText:`${s.token.name}
282
- ${s.actual}`,menu:()=>Ew(s.token.name,s.actual)}))}})}function iY(e){const t=e.filter(o=>o.role==="family"),n=e.filter(o=>o.role==="size");return[...new Set([...t.map(o=>o.value),...n.map(o=>o.family??"initial")])].map(o=>{const s=t.find(l=>l.value===o),a=o==="initial"?"default face":_w(o);return{family:a,stack:o,name:s?Uc(s.uses):void 0,label:a,tipText:s?`${s.value}
283
- ${Uc(s.uses)}: ${s.selectors.join(", ")}`:void 0,menu:()=>s?Sw(s.value):[],rows:n.filter(l=>(l.family??"initial")===o).sort((l,u)=>tk(u.value)-tk(l.value)).map(l=>{const u=tk(l.value),f=oY(l.lead,u),h=l.value.endsWith("px")?`${u}`:l.value;return{key:`${l.value}/${l.lead??""}`,sample:`${a} ${h}${f===null?"":`/${f}`}`,style:{fontFamily:o,fontSize:l.value,lineHeight:l.lead},name:Uc(l.uses),label:l.value,tipText:`${l.value}${l.lead?` / ${l.lead}`:""}
284
- ${Uc(l.uses)}: ${l.selectors.join(", ")}`,menu:()=>Sw(l.value)}})}})}function OA({groups:e,outline:t,clear:n}){const r=(s,a,l)=>t({type:"highlight-computed",props:nY(s.currentTarget.querySelector(".design-face-sample"),a?["font-family","font-size","line-height"]:["font-family"]),match:"all",label:l}),o=xn("design");return d.jsx("div",{className:"design-faces",children:e.map(s=>d.jsxs("div",{className:"design-face-group",children:[d.jsxs("div",{className:"design-face-head row-edge",onMouseEnter:a=>r(a,!1,s.label),onMouseLeave:n,...o.contextMenu(s.menu),...s.tipText?Nt(s.tipText,void 0,{placement:"follow"}):{},children:[d.jsx("span",{className:"design-face-sample design-face-family",style:{fontFamily:s.stack},children:s.family}),s.name&&d.jsx("span",{className:"design-face-name row-dim",children:s.name})]}),s.rows.map(a=>d.jsxs("div",{className:"design-face row-edge",onMouseEnter:l=>r(l,!0,a.label),onMouseLeave:n,...o.contextMenu(a.menu),...Nt(a.tipText,void 0,{placement:"follow"}),children:[d.jsx("span",{className:"design-face-sample",style:a.style,children:a.sample}),d.jsx("span",{className:"design-face-name row-dim",children:a.name})]},a.key))]},s.stack))})}function MA({kind:e,name:t,lines:n,actual:r,ratio:o,largest:s,tipText:a,menu:l,outline:u,clear:f}){const h=e==="color"&&Yu(r)!==null,p=e==="length"?Number.parseFloat(r):Number.NaN,g=xn("design");return d.jsxs("div",{className:"design-cell","data-kind":e,...g.contextMenu(l),onMouseEnter:h?y=>{const w=y.currentTarget.querySelector(".design-fill"),v=w?getComputedStyle(w).backgroundColor:"";u({type:"highlight-computed",props:tY.map(x=>[x,v]),match:"any",label:t})}:void 0,onMouseLeave:h?f:void 0,...Nt(a),children:[e==="color"&&d.jsx("div",{className:"design-sample",children:h&&d.jsx("span",{className:"design-fill",style:{background:r}})}),d.jsxs("div",{className:"design-plate",children:[d.jsx("span",{className:"design-cell-name",children:t}),n.map((y,w)=>d.jsxs("span",{className:"design-cell-line",children:[d.jsx("span",{className:"design-cell-value",children:y}),w===0&&o&&d.jsx("span",{className:"design-cell-note",children:o})]},y)),Number.isFinite(p)&&s>0&&d.jsx("span",{className:"design-scale",style:{width:`${Math.max(2,Math.abs(p)/s*100)}%`}})]})]})}function aY(e,t,n,r=[]){const o=[e.name,e.resolved?`${e.value} resolves to ${e.resolved}`:e.value];if(r.length>0&&o.push(`same value as ${r.join(", ")}`),t&&n){const s=e.name===n.name;o.push(s?"the ground these ratios are measured against":`${t} against ${n.name}`)}return o.join(`
285
- `)}function cY(e,t,n){const r=[e.value,`${Uc(e.uses)}: ${e.selectors.join(", ")}`];return t&&n&&r.push(e===n?"the page background these ratios are measured against":`${t} against the page background`),r.join(`
286
- `)}function LA({shared:e,rest:t}){return e.length===0?d.jsx("ul",{className:"design-rows",children:t}):d.jsxs(d.Fragment,{children:[d.jsx("ul",{className:"design-rows",children:e}),t.length>0&&d.jsxs("details",{className:"design-tail",children:[d.jsxs("summary",{className:"row-edge",children:[d.jsx("span",{className:"design-count row-dim",children:t.length}),"used once or never"]}),d.jsx("ul",{className:"design-rows",children:t})]})]})}function lY({index:e,outline:t,clear:n,onOpen:r}){const{components:o,typed:s}=e;if(o.length===0)return null;const a=o.filter(f=>f.imports>=2),l=o.filter(f=>f.imports<2),u=f=>d.jsx(PA,{count:f.imports,name:f.name,path:f.path,onEnter:()=>t({type:"highlight-file",path:f.path,ranges:null}),onLeave:n,onOpen:()=>r(f.path),children:f.variants.length>0&&d.jsx("span",{className:"design-variants",children:f.variants.map(h=>d.jsxs("span",{className:"design-variant",children:[h.prop,": ",h.values.join(" · ")]},h.prop))})},`${f.path}:${f.name}`);return d.jsxs(Hp,{title:"Components",note:`${a.length} reused of ${o.length}`,children:[!s&&d.jsx(zh,{children:"No TypeScript in this project, so the values each prop allows are not listed."}),d.jsx(LA,{shared:a.map(u),rest:l.map(u)})]})}function uY({index:e,outline:t,clear:n,onOpen:r}){const{classes:o,coverage:s}=e,a=o.filter(g=>g.uses>0),l=o.filter(g=>g.uses>=2),u=o.filter(g=>g.uses<2),f=l.filter(g=>g.unwrapped).length,h=o.length?`${l.length} reused of ${o.length}`+(f?`, ${f} with no component of their name`:""):void 0,p=g=>d.jsx(dY,{cls:g,outline:t,clear:n,onOpen:r},g.name);return d.jsx(Hp,{title:"Classes",note:h,children:o.length===0?d.jsx(zh,{children:"No stylesheet in this project defines a class. Utility-first CSS generates its own."}):a.length===0?d.jsx(zh,{children:s.classAttrs>0?`${s.classAttrs} class attributes were read, and none names a class this scan can follow. That is what a CSS Modules project looks like from here.`:"No class attribute anywhere in the source that was read. The markup may live in a file type this scan does not open."}):d.jsx(LA,{shared:l.map(p),rest:u.map(p)})})}function dY({cls:e,outline:t,clear:n,onOpen:r}){return d.jsx(PA,{count:e.uses,name:`.${e.name}`,path:e.path,onEnter:()=>t({type:"highlight-selector",selector:`.${e.name}`,label:`.${e.name}`}),onLeave:n,onOpen:()=>e.path&&r(e.path),children:e.unwrapped&&d.jsx("span",{className:"design-tag",children:"no component"})})}function PA({count:e,name:t,path:n,onEnter:r,onLeave:o,onOpen:s,children:a}){const l=Vs(),u=nt();ht();const f=xn("design");return d.jsx("li",{children:d.jsxs("button",{type:"button",className:"design-row row-edge",onMouseEnter:r,onFocus:r,onMouseLeave:o,onBlur:o,onClick:s,disabled:!n,...f.contextMenu(()=>l?UV({id:l.worktree.id},n,{sock:u},s):[]),children:[d.jsx("span",{className:"design-count row-dim",children:e}),d.jsx("span",{className:"design-name",children:t}),d.jsx("span",{className:"design-path row-dim",children:n}),a]})})}function fY(e,t){const n=[`${e.name} runs on main for every worktree; this one reaches it at its usual address.`];return t>0&&n.push(`${Jc(t,e.name)[0].toUpperCase()}${Jc(t,e.name).slice(1)}.`),Hh(e.status)||n.push(`Main's ${e.name} is ${ny(e.status).toLowerCase()}.`),n.join(" ")}function hY({procs:e,borrowed:t,pointed:n,dirty:r}){return[...e.map(o=>({kind:"proc",proc:o})),...t.map(o=>({kind:"borrowed",name:o.name,dot:Hh(o.status)?"borrowed":o.status,tip:fY(o,r)})),...Object.entries(n).map(([o,s])=>({kind:"pointed",name:o,remote:s,tip:`${o} points at ${s} for this worktree`}))]}function pY({worktreeId:e,procs:t,borrowed:n,pointed:r,dirty:o,login:s,current:a,onRestart:l}){const u=nt();ht();const f={sock:u},h=(g,y)=>d.jsx(Tt,{icon:"reload",label:y,onClick:()=>l(g)}),p={id:Ks,label:"login",tip:Nt("The agent's login; it closes once you are in",void 0,{placement:"top"}),trail:h(Ks,"Run the login again")};return s&&a===Ks?[p]:[{id:Bo,label:"shell",tip:Nt("A shell in this worktree",void 0,{placement:"top"}),menu:()=>Hj(e,f),trail:h(Bo,"Restart the shell")},...s?[p]:[],...hY({procs:t,borrowed:n,pointed:r,dirty:o}).map(g=>{if(g.kind==="proc"){const y=g.proc;return{id:y.name,label:y.name,lead:d.jsx("span",{className:`dot ${y.status}`}),tip:Nt(ny(y.status),void 0,{placement:"top",dot:y.status,name:y.name,detail:y.command,aside:[`:${y.port}`]}),menu:()=>Gy(y,e,f),trail:h(y.name,`Restart ${y.name}`)}}return{id:g.name,label:g.name,lead:d.jsx("span",{className:`dot ${g.kind==="borrowed"?g.dot:"borrowed"}`}),tip:Nt(g.tip,void 0,{placement:"top"})}})]}const mY=E.lazy(()=>mw(()=>import("./XTerm-BfuBg96X.js"),__vite__mapDeps([3,4]))),gY=[],kY={};function wY({worktreeId:e,opened:t,height:n,onDragStart:r}){const o=ht(),s=nt(),a=pp(),l=L(te=>te.connected),u=L(te=>te.focusTerm),f=Vs(),h=(f==null?void 0:f.procs)??[],p=(f==null?void 0:f.borrowed)??gY,g=E.useMemo(()=>{const te={};for(const[K,C]of Object.entries((f==null?void 0:f.worktree.sources)??{})){const oe=VS(C.at);oe!==void 0&&(te[K]=oe)}return Object.keys(te).length>0?te:kY},[f==null?void 0:f.worktree.sources]),y=(f==null?void 0:f.login)??!1,w=L(te=>{var K;return((K=Hi(te,f==null?void 0:f.repoId))==null?void 0:K.dirty)??0}),v=L(te=>bs(te,f==null?void 0:f.repoId)),x=Rt(e,"termStream"),N=L(te=>{var K;return((K=te.termRun)==null?void 0:K.id)===e&&x===Bo?te.termRun.command:null}),[S,T]=E.useState(null),j=p.find(te=>te.name===x),$=j!==void 0,R=g[x];E.useEffect(()=>{x===Bo||(x===Ks?y:h.some(K=>K.name===x)||p.some(K=>K.name===x)||x in g)||o({a:"term-stream",id:e,stream:Bo})},[h,p,g,y,x,e,o]);const A=te=>{te!==x&&(T(null),o({a:"term-stream",id:e,stream:te}))},I=E.useRef(!1),[M,P]=E.useState(0),F=te=>{te===Bo&&te===x&&(I.current=!0),s==null||s.send({t:"term-restart",worktreeId:e,stream:te}),te===Ks&&te===x&&(T(null),P(K=>K+1))},q=(te,K)=>{if(te)return T(null);if(I.current){I.current=!1,P(C=>C+1);return}T({code:K})},W=pY({worktreeId:e,procs:h,borrowed:p,pointed:g,dirty:w,login:y,current:x,onRestart:F}),ee=E.useRef(!t),V=!ee.current;return E.useEffect(()=>{ee.current=!1},[]),d.jsxs(Zy,{kind:"terminal",className:"term-pane",height:n,onDragStart:r,tabs:{items:W,current:x,onPick:A,font:"mono",owner:"terminal",label:"terminal streams"},onClose:()=>o({a:"toggle-terminal"}),closeHint:Ht("terminal"),children:[d.jsxs("div",{className:"term-body",children:[j&&d.jsx(Zc,{pane:!0,title:`${x} runs on main`,body:["Every worktree reaches main's copy until its own changes touch it, or until asked.",...w>0?[`${Jc(w,x)[0].toUpperCase()}${Jc(w,x).slice(1)}.`]:[],...Hh(j.status)?[]:[`Main's ${x} is ${j.status}; every worktree reaching it is down until it is back.`]].join(" "),action:d.jsx(Me,{variant:"outline",onClick:()=>s==null?void 0:s.send({t:"set-proc-source",worktreeId:e,name:x,source:"here"}),children:"run it here"})}),R!==void 0&&!$&&d.jsx(Zc,{pane:!0,title:`${x} points at ${R}`,body:`The page here talks to ${GS((v==null?void 0:v.config.run[x])??"")[R]??R}; nothing runs here.`,action:d.jsx(Me,{variant:"outline",onClick:()=>s==null?void 0:s.send({t:"set-proc-source",worktreeId:e,name:x,source:"here"}),children:"run it here"})}),d.jsx(Py,{pane:!0,children:d.jsx(E.Suspense,{fallback:d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"loading terminal"})}),children:d.jsx(mY,{worktreeId:e,stream:x,theme:a,sock:s,connected:l,focusOnMount:V,focusReq:u,onAlive:q,run:N,onRan:()=>o({a:"term-ran"}),onEscape:()=>o({a:"toggle-terminal"})},`${x}:${M}`)})})]}),S!==null&&!$&&R===void 0&&d.jsx(Zc,{pane:!0,title:x===Bo?"the shell exited":x===Ks?"the login did not finish":`${x} exited`,body:S.code===void 0?void 0:`exit code ${S.code}`,action:d.jsx(Me,{variant:"outline",onClick:()=>F(x),children:"restart"})})]})}function yY(e){return e==="reserved"?"checking out a fresh worktree":e==="warming"?"copying dependencies and running setup":"starting dev servers"}const vY="preview off; it starts when the agent writes a file";function bY({worktree:e,log:t}){const n=nt(),r=ht(),o=e.procs,s=v=>n==null?void 0:n.send({t:"term-restart",worktreeId:e.id,stream:v.name}),a=o.some(v=>v.status==="crashed"||v.status==="unreachable"),l=L(v=>v.clientId),u=zu(e,"setup"),f=u&&u.status!=="terminated"?u:null,h=Mi(Hy(f??void 0)?f==null?void 0:f.since:void 0),p=!!e.worktree.parked&&o.length===0,g=()=>n==null?void 0:n.send({t:"preview-start",worktreeId:e.id}),y=f&&(f.status==="running"||f.status==="detached"),w=()=>n==null?void 0:n.send({t:"fix-preview",worktreeId:e.id,clientId:l});return d.jsxs(Es,{wide:!0,children:[o.length===0?d.jsx("div",{className:"status-line",children:f?d.jsx("span",{className:"live-text","data-tip":Bk[f.status],children:vh("setup",f,h)}):p?vY:d.jsx("span",{className:"live-text",children:yY(e.worktree.phase)})}):d.jsx("ul",{className:"boot-procs",children:o.map(v=>d.jsxs("li",{className:We("boot-proc",(v.status==="crashed"||v.status==="unreachable")&&"boot-bad"),children:[d.jsx("span",{className:"boot-name",children:v.name}),d.jsx("span",{className:"boot-status",children:xY(v)}),(v.status==="crashed"||v.status==="unreachable")&&d.jsx(Me,{variant:"outline",onClick:()=>s(v),children:"restart"}),v.detail&&v.status!=="asleep"&&d.jsx("div",{className:"boot-detail",children:v.detail})]},v.name))}),p&&d.jsx("div",{className:"status-actions",children:d.jsx(Me,{variant:"outline",size:"lg",onClick:g,children:"start preview"})}),y&&d.jsx("div",{className:"status-actions",children:d.jsx(Me,{variant:"outline","data-tip":Sj("setup"),onClick:()=>n==null?void 0:n.send({t:"run-stop",worktreeId:e.id,kind:"setup"}),children:"stop setup"})}),a&&d.jsxs("div",{className:"status-actions",children:[e.agent==="idle"&&d.jsx(Me,{variant:"outline",size:"lg",onClick:w,children:"ask the agent to fix it"}),d.jsx(Me,{onClick:()=>r({a:"open",overlay:{kind:"setup",repoId:e.repoId}}),children:"edit setup"})]}),t.length>0&&d.jsx("pre",{className:"status-tail",children:t.slice(-30).map(v=>`[${v.proc}] ${v.line}`).join(`
287
- `)})]})}function xY(e){switch(e.status){case"preparing":return`setting up for :${e.port}`;case"starting":return`starting on :${e.port}`;case"running":return`running on :${e.boundPort??e.port}`;case"unreachable":return"never answered";case"crashed":return e.exitCode!=null?`crashed (exit ${e.exitCode})`:"crashed";case"stopped":return"stopped";case"asleep":return`asleep${e.detail?`: ${e.detail}`:""}; opens when you look`}}function EY(e){const{leaving:t,arriving:n}=e;return!t||!n||t===n||n!==e.carryTo?null:e.repoOf(t)===e.repoOf(n)?t:null}function _S(e){if(!e)return"/";try{const t=new URL(e);return`${t.pathname}${t.search}${t.hash}`}catch{return"/"}}function SY(e){return e.previewId===null?null:e.painted?e.previewId:e.ready?e.carry&&e.mounted.includes(e.carry)?e.carry:e.previewId:null}function _Y({active:e}){const t=ht(),n=nt(),r=hl(),o=L(l=>l.home),s=e.worktree.title,a=()=>{r!=null&&r.made&&(t({a:"new-project",v:{...up({mode:r.made==="git"?"init":"create",name:r.name,parent:Yj(r.path,o)??r.path}),phase:"unmaking",repoId:r.id}}),t({a:"move-box",from:e.worktree.id,to:el}),n==null||n.send({t:"unmake-repo",repoId:r.id}))};return d.jsx(Es,{anchor:"line",foot:d.jsx("div",{className:"composer view-foot",children:d.jsx(Su,{active:e,greenfield:!0})}),children:d.jsx("p",{className:"form-title",children:r!=null&&r.made?d.jsx(Me,{variant:"inline",onClick:a,...Nt("Rename or move this project"),children:s}):s})})}function NY({pending:e}){const t=ht(),n=nt(),r=!!e.error,o=()=>{n==null||n.send({t:"cancel-import",id:e.id}),t({a:"watch-import",id:null})},s=E.useRef(null);return E.useEffect(()=>{var a;return(a=s.current)==null?void 0:a.scrollTo({top:s.current.scrollHeight})},[e.lines.length]),d.jsxs(Es,{wide:!0,children:[d.jsxs("p",{className:"status-line",children:[r?"could not import":"importing"," ",e.name]}),d.jsxs("p",{children:["from ",d.jsx("code",{children:e.url}),e.branch&&d.jsxs(d.Fragment,{children:[" ","on ",d.jsx("code",{children:e.branch})]})," ","into ",d.jsx("code",{children:e.parent})]}),r?d.jsx("p",{className:"import-error",children:e.error}):d.jsx("p",{className:"hint",children:"the whole history is cloned, so worktrees, land and graft all work on it straight away."}),d.jsx("div",{className:"status-tail",ref:s,children:e.lines.length===0&&!r?d.jsx("span",{className:"live-text",children:"starting git"}):e.lines.map((a,l)=>d.jsx("div",{children:a},l))}),d.jsx("div",{className:"status-actions",children:d.jsx(Me,{variant:"outline",size:"lg",onClick:o,children:r?"dismiss":"stop"})})]})}const TY=150,jY=/^[^\s@]+@[^\s@]+$/,$Y=14;function CY({project:e}){var oe;const t=ht(),n=nt(),r=L(U=>U.repos),o=L(U=>U.home),s=L(U=>U.folderDialog),a=L(U=>U.gitIdentity),l=L(U=>U.choosingFolder),u=L(U=>U.chosenFolder),f=L(U=>U.paths),[h,p]=E.useState({name:"",email:""}),[g,y]=E.useState(null),w=E.useRef(null),{mode:v,name:x,parent:N}=e,S=v==="clone",T=v==="init",j=e.phase==="editing",$=x.trim(),R=T||!$?null:Au(x),A=!T&&$&&!R?Vj(N,$):null,I=Gk(N,o),M=A!==null&&f.query===A&&((oe=f.target)==null?void 0:oe.exists)===!0,P=!a&&!S,F=!P||h.name.trim()!==""&&jY.test(h.email.trim()),q=j?g?"the folder you chose is already a project: open it, or choose another":!T&&!$?"name the project first":R??(M?`${I} already has a folder called ${$}`:F?null:"git needs your name and email first"):null;E.useEffect(()=>{if(!A)return;const U=setTimeout(()=>n==null?void 0:n.send({t:"browse-path",path:A}),TY);return()=>clearTimeout(U)},[A,n]),ct([e.phase],()=>{var U;e.phase==="editing"&&((U=w.current)==null||U.focus())}),ct([e.error],()=>{e.error&&t({a:"notice",id:el,text:e.error})});const W={sock:n,dispatch:t},ee=()=>{q||!j||(t({a:"new-project-set",v:{phase:"creating"}}),Fu(W,{t:"create-repo",mode:v,parent:N.trim(),name:$,...S&&e.url?{url:e.url,...e.branch?{branch:e.branch}:{}}:{},...P?{identity:{name:h.name.trim(),email:h.email.trim()}}:{}}))},V=U=>{const B=r.find(Q=>Q.path===rl(U,o));B?t({a:"activate-repo",id:B.id}):Fu(W,{t:"register-repo",path:U})},te=U=>{const B=Yy(U);t({a:"new-project-set",v:{mode:"init",parent:B.parent,name:B.name}})},K=U=>{s?(t({a:"choosing-folder",v:U}),n==null||n.send({t:"choose-folder",start:N,purpose:U})):t(U==="location"?{a:"open",overlay:{kind:"choose-folder"}}:{a:"open",overlay:{kind:"projects",form:"disk"}})};ct([u==null?void 0:u.seq],()=>{var B,Q;if(!l||!u)return;t({a:"choosing-folder",v:!1});const U=u.folder;if(!U){(B=w.current)==null||B.focus();return}if(l==="open"){U.kind==="project"?V(U.path):P?te(U.path):Wj(W,U.path);return}if(y(U.kind==="project"?U.path:null),U.kind!=="project"){if(U.kind==="empty"&&!S){te(U.path);return}t({a:"new-project-set",v:{mode:S?"clone":"create",parent:U.path}}),(Q=w.current)==null||Q.focus()}});const C=T?"the folder you chose becomes the project":g?null:M?`${I} already has a folder called ${$}`:R;return d.jsxs(Es,{anchor:"line",foot:d.jsx("div",{className:"composer view-foot",children:d.jsx(Su,{active:null,project:{name:$,why:q,busy:!j,create:ee}})}),children:[S&&d.jsxs("p",{className:"new-project-url",children:[e.url,e.branch&&d.jsxs("span",{className:"hint",children:[" on ",e.branch]})]}),d.jsxs("div",{className:"form-head",children:[T?d.jsx("p",{className:"form-title",children:x}):d.jsx(Ho,{ref:w,bare:!0,font:"lead",className:"new-project-field",autoFocus:!0,spellCheck:!1,autoComplete:"off",value:x,placeholder:"Project name",disabled:!j,style:{width:`${Math.max(x.length+1,$Y)}ch`},onChange:U=>t({a:"new-project-set",v:{name:U.target.value}}),onKeyDown:U=>{U.key==="Enter"&&(U.preventDefault(),t({a:"focus-chat"}))}}),d.jsxs("span",{className:"new-project-where",children:[d.jsx("span",{className:"hint",children:"in"}),d.jsx("span",{className:"new-project-parent",...Nt(N),children:I}),d.jsx(Tt,{icon:"folder",label:s?"Choose in Finder":"Choose a folder",className:"new-project-folder",on:l==="location",disabled:!j,onClick:()=>K("location")})]})]}),C&&d.jsx("p",{className:"hint",children:C}),g&&d.jsxs("p",{className:"hint",children:["the folder you chose is already a project:"," ",d.jsx(Me,{variant:"inline",autoFocus:!0,onClick:()=>V(g),children:"open it"}),", or choose another"]}),P&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"new-project-identity",children:[d.jsx(Ho,{size:"md",font:"ui",rule:!0,value:h.name,placeholder:"Your name",autoComplete:"name",disabled:!j,onChange:U=>p({...h,name:U.target.value})}),d.jsx(Ho,{size:"md",font:"ui",rule:!0,type:"email",value:h.email,placeholder:"Email",autoComplete:"email",disabled:!j,onChange:U=>p({...h,email:U.target.value})})]}),d.jsx("p",{className:"hint",children:"git labels the work you save with these, and asks only once"})]}),!S&&j&&d.jsx(Me,{tone:"quiet",className:"new-project-open",onClick:()=>K("open"),children:"or open a folder you already have"})]})}function Ic({label:e,hint:t,children:n}){return d.jsxs("label",{className:"form-row",children:[d.jsx("span",{className:"form-label",children:e}),d.jsxs("div",{className:"form-control",children:[n,t&&d.jsx("span",{className:"hint",children:t})]})]})}function AY(e,t,n,r){const o=[n.envUrl?`\`${n.envUrl.name}\` in \`${n.envUrl.file}\``:null,n.compose?`the compose stack in \`${n.compose}\``:null].filter(Boolean).join(" and "),s=r[0]??"api",a=r.length>0?`the shared command${r.length>1?"s":""} \`${r.join("`, `")}\``:"the command that serves the database";return[`Toyon runs several worktrees of this repo (${e.name}) at once, each with its own copy of the code, and right now they would all share ${o}: a migration run in one worktree changes the database every other worktree is using.`,"",`Give each worktree its own. Every command Toyon runs gets \`TOYON_WORKTREE\` (the worktree's id, empty in the main checkout) and \`TOYON_ROOT\` (the main checkout). A command's own \`setup\` and \`teardown\` run where that command runs: never on main, in a worktree once it runs its own, and nowhere while the worktree points the command at a remote. Edit \`${t}\` so that ${a} carries the recipe, in this shape:`,"```json",`{ "run": { "${s}": { "cmd": "<its command>", "setup": ["uv sync", "createdb -T app_template \\"app_$TOYON_WORKTREE\\""], "teardown": ["dropdb --if-exists \\"app_$TOYON_WORKTREE\\""] } } }`,"```",'- `setup` makes the worktree\'s own database with the same schema and seed data. Postgres refuses to copy a database with connections open, so copy from a template nothing serves: `createdb -T <db>_template "<db>_$TOYON_WORKTREE"`, making `<db>_template` once from the seed if it does not exist. Keep it seed-sized, since every worktree copies it. A hosted database that branches (the repo already uses one, or its README says so) gets a branch named for the worktree instead. A compose stack: bring it up under `-p "<name>_$TOYON_WORKTREE"` and seed it the way the README does.',"- `teardown` drops it again (`dropdb --if-exists ...`, the branch deleted, or `docker compose -p ... down -v`).","- the command points at it, with the base database on main: put the URL in front of `cmd`, named `<db>${TOYON_WORKTREE:+_$TOYON_WORKTREE}`. `setup` does not see what `cmd` sets, so a migration step in `setup` needs the URL in front of it too.",'- a database container every worktree shares (each with its own database inside it) is `{ "cmd": "docker compose up db", "paths": [] }` in `run`: main runs it once for everyone and no worktree ever runs its own.',"- the top-level `setup` is for the page: leave the install there and put what the backend needs under the backend's own `setup`.","","Read the README and the existing env files for the database's name and credentials. Do not run any migration yourself, and do not start any server; Toyon picks the file up as soon as it is written."].join(`
288
- `)}function IY(e,t){return[`This repo (${e.name}) has no Toyon settings yet, so Toyon does not know how to install its dependencies or start its dev server.`,"",`Work it out from the repo itself (package manager, scripts, framework, a README) and write \`${t}\` in this shape:`,"```json",'{ "setup": ["<install command>"], "run": { "web": "<start command>" } }',"```",'`setup` runs once in each new worktree. A worktree starts with the branch\'s files only: `node_modules` and the `.env` files are copied in for it, but any other gitignored file the project needs (a local database, a test cache such as `.testmondata`) is not, so add a `cp` from `$TOYON_ROOT`, the main checkout, when you find one in `.gitignore`. Never copy a virtualenv or another dependency tree that holds absolute paths; reinstall it instead. Every command in `run` must run in the foreground and listen on the port in the PORT environment variable, which Toyon sets per worktree; a tool that takes its port from a flag needs the flag (Vite: `--port $PORT --strictPort`, and with npm the `--` before it). Name one entry per server if there are several. If the project has nothing to run (a library, a CLI), write `"run": {}` and say so. Do not start any server yourself; toyon picks the file up as soon as it is written.'].join(`
289
- `)}const RY=[{id:"auto",label:"auto",chip:"shared: auto",description:"main runs it for every worktree when the command names a folder Toyon can watch; a worktree that changes it runs its own"},{id:"trunk",label:"always",chip:"shared: always",description:"main runs it for every worktree; a worktree that changes a folder the command names runs its own, and nothing flips a command that names none"},{id:"copy",label:"never",chip:"shared: never",description:"every worktree runs its own"}];function OY(e,t,n,r){var a;const o=r.config.run[e.trim()];if(o===void 0||ZS(o)!==t.trim()||n==="copy")return null;const s=(a=r.tier)==null?void 0:a[e.trim()];return s&&s.paths.length>0?`main runs it; a worktree that changes ${s.paths.join(", ")} runs its own`:s||n==="trunk"?"main runs it for every worktree; no change here flips it":"every worktree runs its own: the command names nothing Toyon can watch"}let MY=1;const Fh=(e,t,n="auto",r={})=>({id:MY++,name:e,cmd:t,from:n,rest:r});function LY(e,t){if(typeof t=="string")return Fh(e,t);const{cmd:n,from:r,...o}=t;return Fh(e,n,r??"auto",o)}const PY=[{id:"shared",label:"committed",description:"in the repo; everyone who opens it gets these settings"},{id:"local",label:"kept local",description:"in a file git never sees; for when only you use Toyon here"}];function DY({repo:e,onClose:t}){const n=nt(),r=Pn(),o=L(Z=>Z.clientId),s=L(Z=>Z.rows.find(J=>{var pe;return Tn(J)&&J.id===((pe=Hi(Z,e.id))==null?void 0:pe.id)})??null),a=L(Z=>{var J;return((J=Hi(Z,e.id))==null?void 0:J.id)??null});E.useEffect(()=>{if(!t)return;const Z=J=>J.key==="Escape"&&t();return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[t]);const[l]=E.useState(()=>Object.keys(e.config.run).length>0),[u,f]=E.useState(()=>{const Z=Object.entries(e.config.run).map(([J,pe])=>LY(J,pe));return Z.length>0?Z:[Fh("web","")]}),[h,p]=E.useState(()=>(e.config.setup??[]).join(`
290
- `)),[g,y]=E.useState(()=>(e.config.teardown??[]).join(`
291
- `)),[w,v]=E.useState(()=>e.config.check??""),[x,N]=E.useState(()=>Ri(e.config).land),[S,T]=E.useState(()=>Ri(e.config).automerge),[j,$]=E.useState(()=>Ri(e.config).merge??"default"),[R,A]=E.useState(()=>AR(e.configFile)),I=IR(e.configFile,R),M=!!e.remote&&x==="pr",P=u.length>1,F=u.some(Z=>Z.name.trim()&&Z.cmd.trim()),W=!!s&&!t&&!l&&!F,ee=(Z,J)=>f(u.map((pe,de)=>de===Z?{...pe,...J}:pe)),V=Z=>Z.split(`
292
- `).map(J=>J.trim()).filter(Boolean),te=()=>V(h),K=()=>V(g),C=()=>{const{check:Z,land:J,teardown:pe,...de}=e.config,ie=e.remote?x:ik,ye=j==="default"||ie!=="pr"&&j===ak?void 0:j,_e={...ie!==ik?{route:ie}:{},...ie==="pr"&&S?{automerge:!0}:{},...ye?{method:ye}:{}};return{...de,setup:te(),...K().length>0?{teardown:K()}:{},...w.trim()?{check:w.trim()}:{},...Object.keys(_e).length>0?{land:_e}:{}}},oe=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...C(),run:Object.fromEntries(u.filter(Z=>Z.name.trim()&&Z.cmd.trim()).map((Z,J)=>{const pe={...Z.rest,cmd:Z.cmd.trim(),...J>0&&Z.from!=="auto"?{from:Z.from}:{}};return[Z.name.trim(),Object.keys(pe).length===1?pe.cmd:pe]}))},kind:R}),t==null||t()},U=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...C(),run:{}},kind:R}),t==null||t()},B=()=>n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:IY(e,I)}),Q=e.services,ue=[h,g,...u.flatMap(Z=>[Z.cmd,...Z.rest.setup??[],...Z.rest.teardown??[]])].some(Z=>Z.includes("TOYON_WORKTREE"))||$R(e.config),he=Q?[Q.envUrl?`the database at ${Q.envUrl.name} in ${Q.envUrl.file}`:null,Q.compose?`the stack in ${Q.compose}`:null].filter(Boolean).join(" and "):"",Ne=u.filter((Z,J)=>J>0&&Z.from!=="copy"&&Z.name.trim()).map(Z=>Z.name.trim()),De=()=>Q&&(n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:AY(e,I,Q,Ne)})),Be=(Z,J)=>d.jsxs("div",{className:"setup-proc",children:[P&&d.jsx(Ho,{size:"md",rule:!0,className:"setup-name",value:Z.name,placeholder:"name",...Nt("Process name, shown in the status bar"),onChange:pe=>ee(J,{name:pe.target.value})}),d.jsx(Ho,{size:"md",rule:!0,className:"setup-cmd",value:Z.cmd,placeholder:"npm run dev",onChange:pe=>ee(J,{cmd:pe.target.value})}),P&&d.jsx(Tt,{icon:"close",label:"Remove",onClick:()=>f(u.filter((pe,de)=>de!==J))}),P&&J>0&&d.jsxs("div",{className:"setup-source",children:[d.jsx(Bs,{value:Z.from,options:RY,onChange:pe=>ee(J,{from:pe}),hint:"whether main runs it once for every worktree",placeholder:"who runs it"}),(()=>{const pe=OY(Z.name,Z.cmd,Z.from,e);return pe?d.jsx("span",{className:"hint setup-source-hint",children:pe}):null})()]})]},Z.id);return d.jsxs(Es,{children:[d.jsxs("p",{className:"form-title",children:["how does ",e.name," start?"]}),Q&&!ue&&d.jsxs("p",{className:"hint setup-shared-note",children:["Worktrees will share ",he,", migrations included."," ",d.jsx(Me,{tone:"quiet",disabled:!s,onClick:De,children:"ask the agent to keep them apart"})]}),d.jsx(Ic,{label:"install",hint:"once per new worktree; one command per line",children:d.jsx(Du,{size:"md",rule:!0,rows:Math.max(1,h.split(`
293
- `).length),value:h,placeholder:"bun install",onChange:Z=>p(Z.target.value)})}),d.jsx(Ic,{label:"remove",hint:"once when a worktree goes, before its directory does; one command per line",children:d.jsx(Du,{size:"md",rule:!0,rows:Math.max(1,g.split(`
294
- `).length),value:g,placeholder:'dropdb --if-exists "app_$TOYON_WORKTREE"',onChange:Z=>y(Z.target.value)})}),d.jsx(Ic,{label:"check",hint:"runs after each of the agent's turns; the work lands only when it passes",children:d.jsx(Ho,{size:"md",rule:!0,value:w,placeholder:"bun run check",onChange:Z=>v(Z.target.value)})}),e.remote&&d.jsx(Ic,{label:"land",hint:"where a worktree's finished work goes; one way per repo",children:d.jsxs("div",{className:"setup-land",children:[d.jsx(Bs,{value:x,options:qR.map(Z=>({id:Z.id,label:Z.name,description:Z.description})),onChange:N,hint:"where the work goes",placeholder:"where work lands"}),M&&d.jsx(Bs,{value:S?"github":"you",options:GR.map(Z=>({id:Z.id,label:Z.name,description:Z.description})),onChange:Z=>T(Z==="github"),hint:"who merges the pull request",placeholder:"who merges it"})]})}),d.jsx(Ic,{label:"merge",hint:M?"how GitHub merges the pull request; only what the repo allows":"how the commits arrive on main",children:d.jsx(Bs,{value:j==="default"&&!M?ak:j,options:[...M?[{id:"default",label:"what the repo allows",description:"the repo's allowed methods on GitHub: squash, else a merge commit, else rebase"}]:[],...ZR.map(Z=>({id:Z.id,label:Z.name,description:Z.description}))],onChange:$,hint:"how the commits arrive on main",placeholder:"how the commits arrive"})}),d.jsx(Ic,{label:"start",hint:d.jsxs(d.Fragment,{children:["must listen on ",d.jsx("code",{...Nt("Toyon sets a different port for each worktree"),children:"$PORT"}),e.guess&&a&&d.jsxs(d.Fragment,{children:[" · from ",d.jsx(Me,{mono:!0,tone:"quiet",...Nt(`open ${e.guess} in the editor pane`),onClick:()=>Ma(r,n,a,e.guess??"",1),children:e.guess})]})]}),children:u[0]&&Be(u[0],0)}),u.slice(1).map((Z,J)=>d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsx("div",{className:"form-control",children:Be(Z,J+1)})]},Z.id)),!P&&d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsx("span",{className:"hint setup-tier-hint",children:"one command: every worktree runs its own"})]}),d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsxs(Me,{tone:"quiet",onClick:()=>f([...u,Fh("","")]),children:[d.jsx(xt,{name:"plus",className:"icon-inline"})," another process"]})]}),d.jsxs("div",{className:"form-knobs",children:[d.jsx(Bs,{value:R,options:PY,onChange:A,hint:"whether the settings file is committed with the repo or kept out of git",placeholder:"committed or kept local"}),d.jsx("span",{className:"form-sign",children:I}),t&&d.jsx(Me,{onClick:t,children:"cancel"}),(!l||t)&&d.jsx(Me,{...Nt("This project has no dev server: chat, changes and the terminal work, the preview stays empty"),onClick:U,children:"no dev server"}),W&&s?d.jsx(Me,{variant:"outline",size:"lg",disabled:s.agent!=="idle",...Nt("The agent reads the repo and writes the settings file; the daemon picks it up as soon as it lands"),onClick:B,children:"let the agent work it out"}):d.jsxs(Me,{variant:"outline",size:"lg",disabled:!F,...t?Nt("Restarts every worktree of this repo. Other keys in the file are kept."):{},onClick:oe,children:[t?"save + restart":"start"," ",d.jsx(xt,{name:"forward",className:"icon-inline"})]})]})]})}function zY(e){return`${Math.round(e.w)} × ${Math.round(e.h)}`}function FY(e){return e.w>0&&e.h>0}function BY(e,t,n){E.useEffect(()=>{if(!e||!t){n(null);return}const r=new ResizeObserver(o=>{var l;const s=(l=o[o.length-1])==null?void 0:l.contentRect;if(!s)return;const a={w:s.width,h:s.height};n(FY(a)?zY(a):null)});return r.observe(e),()=>{r.disconnect(),n(null)}},[e,t,n])}const UY=1500,HY={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};class WY{constructor(t,n,r=HY){_t(this,"frames",new Map);this.send=t,this.sendTitle=n,this.timers=r}note(t,n,r){const o=this.frame(t);o.timer!==null&&(this.timers.clear(o.timer),o.timer=null),o.pending=null,r!==void 0&&(o.title=bx(r));const s=op(n);if(!s){o.sent=null;return}if(s===o.sent){this.renamed(t,o);return}o.pending=s,o.timer=this.timers.set(()=>{o.timer=null,o.pending=null,o.sent=s,o.sentTitle=o.title,this.send(t,s,o.title)},UY)}title(t,n){const r=this.frame(t);r.title=bx(n),r.pending===null&&this.renamed(t,r)}dispose(){for(const t of this.frames.values())t.timer!==null&&this.timers.clear(t.timer);this.frames.clear()}frame(t){let n=this.frames.get(t);return n||(n={sent:null,pending:null,timer:null},this.frames.set(t,n)),n}renamed(t,n){!n.sent||!n.title||n.title===n.sentTitle||(n.sentTitle=n.title,this.sendTitle(t,n.sent,n.title))}}const KY=hh(),qY=2*6e4;function NS(e){e==null||e.setAttribute("src",e.src)}const ZY=8e3;function GY(e,t){try{const n=new URL(e,t);return n.origin===new URL(t).origin?n.href:null}catch{return null}}function VY({onRoot:e}){const t=E.useRef(null),n=E.useCallback(le=>{t.current=le,e(le)},[e]),r=ht(),o=Pn(),s=nt(),a=E.useRef(s);a.current=s;const[l]=E.useState(()=>new WY((le,qe,Xe)=>{var pt,wt;(pt=a.current)==null||pt.send({t:"visit",worktreeId:le,path:qe,title:Xe}),vN((wt=o.getState().local[le])==null?void 0:wt.pages)&&fn.post(le,{type:"links"})},(le,qe,Xe)=>{var pt;return(pt=a.current)==null?void 0:pt.send({t:"page-title",worktreeId:le,path:qe,title:Xe})}));E.useEffect(()=>()=>l.dispose(),[l]);const u=cT(),f=fl(),h=Vs(),p=L(le=>le.connected),g=L(le=>le.heard),y=L(le=>le.recalledAt!==null),w=L(le=>le.connectFailure),v=L(le=>le.remote),{host:x}=Mr(),N=Gs(),S=xs(),T=L(le=>le.editor),j=uT(),$=E6(),R=L(le=>le.notesPage),A=Ju(),I=L(le=>le.layout.term)&&!A,M=L(le=>le.focusTerm),P=E.useRef(!1),F=E.useRef(M),q=!P.current||M!==F.current;E.useEffect(()=>{P.current=I&&!!f,F.current=M});const W=ed(),ee=L(le=>le.layout.design)&&!A&&!W,V=L(le=>le.reloadReq),te=pp(),K=E.useRef(te);K.current=te;const C=L(le=>le.zen),oe=L(Ui),U=L(le=>{var qe;return((qe=le.dragFiles)==null?void 0:qe.at)==="centre"}),B=E.useRef(C);B.current=C;const Q=Rt(f,"log"),ue=L(le=>le.incompatible),he=_6(),Ne=L(le=>{var qe;return((qe=le.overlay)==null?void 0:qe.kind)==="setup"?le.repos.find(Xe=>Xe.id===le.overlay.repoId)??null:null}),De=(h==null?void 0:h.worktree.empty)===!0,Be=is(h==null?void 0:h.agent),Z=he&&!De&&!Be?he:null,J=Z??Ne,pe=L(le=>le.pending.find(qe=>qe.id===le.activeImportId)??null),[de,ie]=E.useState([]),ye=E.useMemo(()=>de.map(le=>le.id),[de]),_e=E.useRef(new Map),be=E.useRef(new Map),[$e,Ze]=E.useState([]),rt=E.useRef(new Set),en=E.useRef(new Set),Xt=E.useRef(le=>NS(_e.current.get(le)));E.useEffect(()=>{fn.post=(le,qe)=>{var Xe,pt;if(qe.type==="reload"&&rt.current.has(le))return Xt.current(le);(pt=(Xe=_e.current.get(le))==null?void 0:Xe.contentWindow)==null||pt.postMessage({__toyon:!0,...qe},be.current.get(le)??"*")},fn.broadcast=le=>{var qe;for(const[Xe,pt]of _e.current)(qe=pt.contentWindow)==null||qe.postMessage({__toyon:!0,...le},be.current.get(Xe)??"*")}},[]),E.useEffect(()=>{let le=null;const qe=wt=>{wt.target instanceof HTMLElement&&wt.target.tagName!=="IFRAME"&&(le=wt.target)},Xe=wt=>{wt.relatedTarget===null&&setTimeout(()=>{document.activeElement===document.body&&(le=null)},0)},pt=wt=>{var En,Lr,un,vr,Qn;if((En=wt.data)!=null&&En.__toyon)for(const[Bt,dn]of _e.current){if(dn.contentWindow!==wt.source)continue;if(wt.origin!==be.current.get(Bt))return;const ve=q_(wt.data);if(!ve)return;switch(ve.type){case"key":window.dispatchEvent(new KeyboardEvent(ve.up?"keyup":"keydown",{key:ve.key,code:ve.code,metaKey:ve.meta,ctrlKey:!!ve.ctrl,shiftKey:!!ve.shift,altKey:!!ve.alt}));break;case"hmr":r({a:"hmr",id:Bt}),(Lr=a.current)==null||Lr.send({t:"page-loaded",worktreeId:Bt});break;case"loaded":rt.current.delete(Bt),en.current.add(Bt),Ze(Le=>Le.includes(Bt)?Le:[...Le,Bt]),fn.post(Bt,CA(K.current)),fn.post(Bt,{type:"zen",on:B.current}),r({a:"hmr",id:Bt}),r({a:"page",id:Bt,url:ve.url,title:ve.title}),(un=a.current)==null||un.send({t:"page-loaded",worktreeId:Bt}),l.note(Bt,ve.url,ve.title);break;case"navigated":r({a:"page",id:Bt,url:ve.url,...ve.title!==void 0?{title:ve.title}:{}}),l.note(Bt,ve.url,ve.title);break;case"title":r({a:"page",id:Bt,title:ve.title}),l.title(Bt,ve.title);break;case"links":r({a:"links",id:Bt,links:ve.links});break;case"page-error":{const Le=jz(ve);Le&&((vr=a.current)==null||vr.send({t:"page-error",worktreeId:Bt,message:Le}));break}case"picked":{const{type:Le,verb:At,site:yt,...rn}=ve,Gt=yt==="call"?{file:rn.callFile,line:rn.callLine}:{file:rn.file,line:rn.line};if(At==="code"){r({a:"set-picking",v:!1});const Jn=(Qn=Jt(o.getState(),Bt))==null?void 0:Qn.worktree;Gt.file?Ma(o,s,Bt,hN(Gt.file,Jn==null?void 0:Jn.path),Gt.line??1):s==null||s.send({t:"find-element",worktreeId:Bt,seq:$o(),element:rn.element})}else a5(o,Bt,rn);break}case"pick-cancel":r({a:"set-picking",v:!1});break;case"drag-files":ve.over?Oy(o,o.getState().activeId?{at:"centre"}:null):OT(o);break;case"drop-files":DT(o,s,o.getState().activeId?{at:"centre"}:null,G5(ve.files));break;case"focus":ve.gesture?le=null:document.activeElement===dn&&(le!=null&&le.isConnected)&&le!==document.body&&le.focus();break;case"highlight-miss":console.warn(`[toyon] highlight miss on ${ve.path}: ${ve.fileMatched} elements from this file, ${ve.withSource} elements with source info on page, ranges=${JSON.stringify(ve.ranges)}`);break}return}};return window.addEventListener("message",pt),document.addEventListener("focusin",qe),document.addEventListener("focusout",Xe),()=>{window.removeEventListener("message",pt),document.removeEventListener("focusin",qe),document.removeEventListener("focusout",Xe)}},[r,o,s,l]),E.useEffect(()=>{fn.broadcast({type:"zen",on:C})},[C]);const Et=E.useRef(new Map);ct([V==null?void 0:V.id,V==null?void 0:V.n],()=>{if(!V)return;const{id:le}=V;clearTimeout(Et.current.get(le)),Et.current.set(le,setTimeout(()=>{Et.current.delete(le),fn.post(le,{type:"reload"})},1200))});const Ke=by(),Qt=Ke&&!Tn(Ke)?Ke:null,Ot=Ga(),Zt=!!h&&h.procs.some(le=>le.status==="running"),Ge=Sy(),nn=Ge!==null&&Ge===f&&Zt;E.useEffect(()=>{var le;if(Ge&&nn&&!ye.includes(Ge)){const qe=_S((le=o.getState().local[Ge])==null?void 0:le.page.url);ie(Xe=>[...Xe,{id:Ge,path:qe}])}},[Ge,nn,ye,o]);const pn=u.filter(le=>Tn(le)&&le.procs.some(qe=>qe.status==="asleep")).map(le=>le.id).join(" ");E.useEffect(()=>{const le=new Set(pn.split(" ").filter(Boolean));ye.some(qe=>le.has(qe))&&ie(qe=>qe.filter(Xe=>!le.has(Xe.id)))},[pn,ye]);const It=ye.join(" ");E.useEffect(()=>{const le=It.split(" ").filter(qe=>qe&&qe!==Ge).map(qe=>setTimeout(()=>ie(Xe=>Xe.filter(pt=>pt.id!==qe)),qY));return()=>{for(const qe of le)clearTimeout(qe)}},[It,Ge]),E.useEffect(()=>{Ze(le=>le.every(qe=>ye.includes(qe))?le:le.filter(qe=>ye.includes(qe)))},[ye]);const gt=E.useMemo(()=>u.filter(Tn).flatMap(le=>{const qe=de.find(pt=>pt.id===le.id);if(!qe)return[];const Xe=fN(le.worktree.id,le.worktree.proxyPort,v,x);return[{id:le.worktree.id,port:le.worktree.proxyPort,title:le.worktree.title,url:GY(qe.path,Xe)??Xe}]}),[u,de,v,x]),Vt=Pk(N,v),Cn=WT(N,gt,Vt);Xt.current=le=>{var Xe;const qe=_S((Xe=o.getState().local[le])==null?void 0:Xe.page.url);if(de.some(pt=>pt.id===le&&pt.path!==qe)){ie(pt=>pt.map(wt=>wt.id===le?{...wt,path:qe}:wt));return}Vt?Cn.renew(le):NS(_e.current.get(le))};const Ce=gt.filter(le=>{var qe;return(qe=u.find(Xe=>Xe.id===le.id))==null?void 0:qe.procs.some(Xe=>Xe.status==="running")}).map(le=>le.id).join(" ");ct([Ce],()=>{for(const le of Ce.split(" "))rt.current.has(le)&&Xt.current(le)});const Pt=L(le=>le.carryTo),[Dt,Wt]=E.useState(null),[Dn,ne]=E.useState(Ge),we=E.useRef(null);Dn!==Ge&&(ne(Ge),Wt(EY({leaving:we.current,arriving:Ge,carryTo:Pt,repoOf:le=>{var qe;return((qe=u.find(Xe=>Xe.id===le))==null?void 0:qe.repoId)??null}}))),E.useEffect(()=>{if(!Dt)return;const le=setTimeout(()=>Wt(null),ZY);return()=>clearTimeout(le)},[Dt]);const Ye=Ge!==null&&$e.includes(Ge),ot=SY({previewId:Ge,painted:Ye,ready:nn,carry:Dt,mounted:ye}),zt=ot!==null&&ot!==Ge;E.useEffect(()=>{we.current=ot});const Kt=ot!==null&&!J&&!pe&&!R&&!A&&!W,[D,se]=E.useState(null),Se=E.useCallback(le=>r({a:"preview-size",text:le}),[r]);BY(D,Kt,Se);const[ze,Ut]=ks(it.editorHeight,0,le=>{const qe=Number(le);return Number.isFinite(qe)&&qe>=120?qe:0}),[qt,Oe]=ks(it.designHeight,0,le=>{const qe=Number(le);return Number.isFinite(qe)&&qe>0?qe:0}),[Fe,et]=ks(it.designFull,!1,le=>le===null?void 0:le==="1"),[Ft,jt]=ks(it.editorFull,!1,le=>le===null?void 0:le==="1"),[On,Mn]=ks(it.termHeight,240,le=>{const qe=Number(le);return Number.isFinite(qe)&&qe>=140?qe:void 0}),yn=L(le=>le.termTall);ct([yn],()=>{const le=t.current;yn&&le&&Mn(Math.max(On,Math.round(le.clientHeight/2)))});const tn=le=>(qe,Xe)=>{const pt=Xe.parentElement,wt=t.current;if(!pt||!wt)return null;let En=0;for(const un of Array.from(wt.querySelectorAll(":scope > .pane")))un!==pt&&!un.classList.contains("full")&&(En+=un.offsetHeight);const Lr=Math.max(wt.clientHeight-En-80,le);return Math.min(Math.max(pt.getBoundingClientRect().bottom-qe.clientY,le),Lr)},_n=qc(tn(120),le=>Ut(Math.round(le))),Mt=qc(tn(160),le=>Oe(Math.round(le))),mn=qc(tn(140),le=>Mn(Math.round(le))),rr=L(le=>{var qe,Xe;return h&&Tr(h.worktree)?((Xe=(qe=le.rows.find(pt=>{var wt;return pt.repoId===h.worktree.repoId&&((wt=pt.worktree)==null?void 0:wt.kind)==="worktree"}))==null?void 0:qe.worktree)==null?void 0:Xe.title)??null:null}),Ct=t8({connected:p,heard:g,standing:y,connectFailure:w,hasToken:N.serving?KY:!0,projectChord:Ht("project"),title:(h==null?void 0:h.worktree.title)??null,machine:N.serving?null:S.displayName(N.origin),needsSetup:!!he,busy:Be,treeEmpty:De,landsFrom:rr});return d.jsxs("div",{className:"center-root",ref:n,children:[d.jsx("div",{className:We("center-area",U&&"drop-over"),style:{display:oe||!(C&&!W)&&!Ot&&!R&&(T&&Ft||ee&&Fe)?"none":void 0},children:d.jsxs("div",{className:"frames-wrap",ref:se,children:[gt.map(le=>d.jsx("iframe",{ref:qe=>{qe?(_e.current.set(le.id,qe),be.current.set(le.id,new URL(le.url).origin)):(_e.current.delete(le.id),be.current.delete(le.id),rt.current.delete(le.id),en.current.delete(le.id))},onLoad:()=>{en.current.delete(le.id)?rt.current.delete(le.id):rt.current.add(le.id)},src:Cn.urlOf(le.id)??void 0,title:le.title,style:{display:Kt&&le.id===ot?"block":"none"}},le.id)),$?d.jsx(CY,{project:$}):R?d.jsx(BV,{}):d.jsxs(d.Fragment,{children:[pe&&d.jsx(NY,{pending:pe},pe.id),j&&h&&!pe&&d.jsx(_Y,{active:h},h.worktree.id),J&&!pe&&!j&&d.jsx(DY,{repo:J,onClose:Z?void 0:()=>r({a:"close"})},`${J.id}:${JSON.stringify(J.config)}`),Qt&&!J&&!pe&&!Ot&&d.jsx(_u,{placement:"centre",found:Qt},Qt.id),Ot&&!J&&!pe&&d.jsx(_u,{placement:"centre",archived:Ot},Ot.id),!Zt&&!Qt&&!Ot&&!J&&!pe&&!j&&ue&&d.jsx(nj,{foreign:N.serving?void 0:S.displayName(N.origin)}),!Zt&&!Qt&&!Ot&&!J&&!pe&&!j&&!ue&&(Ct!==null?d.jsx(Es,{wide:!0,children:d.jsx("p",{className:We("status-line",Ct.live&&"live-text"),children:Ct.text})}):W?d.jsx(_u,{placement:"centre"}):zt?null:h&&d.jsx(bY,{worktree:h,log:Q}))]})]})}),T&&d.jsx(mA,{editor:T,height:Ft?"100%":ze>0?ze:"45%",full:Ft||oe,onToggleFull:oe?void 0:()=>jt(!Ft),onDragStart:_n}),ee&&f&&!Ot&&!R&&d.jsx(WV,{worktreeId:f,height:Fe?"100%":qt>0?qt:"55%",full:Fe,onToggleFull:()=>et(!Fe),onDragStart:Mt},`design:${f}`),I&&f&&!Ot&&!R&&d.jsx(wY,{worktreeId:f,opened:q,height:On,onDragStart:mn},`term:${f}`),d.jsx(bA,{})]})}function YY({width:e}){const t=L(r=>r.layout.chat),n=Ju();return d.jsx(_u,{placement:"dock",className:!t||n?"collapsed":void 0,width:e})}function XY(e,t){const n=[];return e&&(n.push(gT(e)),n.push({id:"copy-url",label:"copy URL",onClick:()=>sn(e)})),Un([n,[{id:"reload",label:"reload preview",key:Ht("reload"),onClick:t.reload}]])}const QY=520,nk=8;function JY({winW:e,centre:t,leadRight:n,toolsLeft:r}){const o=t.right-t.left,s=Math.max(0,Math.min(QY,Math.floor(e*.4),o-2*nk)),a=t.left+(o-s)/2,l=n+nk,u=r-nk-s,f=Math.max(Math.min(a,u),l);return{left:Math.round(f),width:s}}function eX({center:e}){const t=t6(),n=rT(e),r=E.useRef(null);f6(r);const o=gF(),[s,a]=Ux(),[l,u]=Ux(),f=JY({winW:t,centre:n,leadRight:a.right,toolsLeft:u.left}),h=ht(),p=nt(),g=Pn(),y=xn("bar"),w=Vs(),v=ed(),x=L(K=>K.zen)&&!v,N=L(K=>K.layout.changes),S=L(K=>K.layout.chat),T=Ju(),j=L(K=>K.layout.design),$=L(K=>{var C;return((C=K.overlay)==null?void 0:C.kind)==="keys"}),R=jC(),A=(w==null?void 0:w.worktree.id)??null,I=L(K=>K.archivedPage!==null||K.notesPage),M=!!w&&fp(w)&&!I,P=L(K=>K.chatSide)==="left",F={tipAlign:"start"},q={tipAlign:"end"},W=!T&&d.jsx(Tt,{icon:"branch",label:"Changes panel",hint:Ht("changes"),tone:"chrome",on:N,...P?q:F,onClick:()=>h({a:"toggle-changes"})}),ee=!T&&!v&&d.jsx(Tt,{icon:"chat",label:"Chat panel",hint:Ht("composer"),tone:"chrome",on:S,...P?F:q,onClick:()=>h({a:"toggle-chat"})}),V=L(K=>K.railOpen),te=!T&&d.jsx(Tt,{icon:"worktrees",label:"Worktree panel",hint:Ht("rail"),tone:"chrome",on:V,...P?F:q,onClick:()=>h({a:"toggle-rail"})});return d.jsxs("div",{className:"top-bar",ref:r,"data-float-up":o||void 0,children:[x&&d.jsx("span",{className:"bar-zen-title",children:(w==null?void 0:w.worktree.title)??"Toyon"}),d.jsxs("span",{className:"bar-lead",ref:s,children:[P?te:W,P&&ee,d.jsx(tX,{}),R&&d.jsx(ld,{icon:"download","data-tip":"Install Toyon as an app (own window, dock icon)",onClick:()=>void R.prompt(),children:"install app"}),d.jsx(rX,{}),d.jsx(oX,{}),d.jsx(sX,{})]}),!v&&d.jsx(nX,{worktreeId:A,repoId:(w==null?void 0:w.repoId)??null,ready:M,left:f.left,width:f.width}),d.jsx("span",{className:"bar-grow"}),d.jsxs("span",{className:"bar-tools",ref:l,children:[d.jsx(iX,{}),d.jsx(Tt,{icon:"settings",label:"Settings & shortcuts",hint:Ht("keys"),tone:"chrome",on:$,...q,"aria-controls":"keys-help","aria-expanded":$,onClick:()=>h({a:"toggle",overlay:{kind:"keys"}}),...y.contextMenu(()=>Kj(g.getState(),{sock:p,dispatch:h}))}),!T&&!v&&d.jsx(Tt,{icon:"palette",label:"Design system",hint:Ht("design"),tone:"chrome",on:j,...q,onClick:()=>h({a:"toggle-design"})}),P?W:ee,!P&&te,!v&&d.jsx(Tt,{icon:"zen",className:"bar-zen",label:"Full-bleed preview",hint:Ht("zen"),tone:"chrome",on:x,...q,onClick:()=>h({a:"toggle-zen",file:qy("editor")})})]})]})}function tX(){const e=ht(),t=nt(),n=hl(),r=L(p=>p.activeRepoId),o=L(p=>p.rows),s=L(p=>p.repos),a=xn("bar"),l=()=>Un([[{id:"project",label:s.length>1?"switch project…":"open project…",key:Ht("project"),onClick:()=>e({a:"open",overlay:{kind:"projects",form:"pill"}})},{id:"project-disk",label:"find a project on disk…",onClick:()=>e({a:"open",overlay:{kind:"projects",form:"disk"}})}],n?Np(n,r,{sock:t,dispatch:e},o):[]]),u=L(p=>{var g;return((g=p.overlay)==null?void 0:g.kind)==="projects"&&p.overlay.form==="pill"}),f=L(p=>p.heard),h=L(p=>p.newProject!==null);return d.jsxs("span",{className:"bar-project",children:[d.jsx(Me,{tone:"chrome",className:"bar-pill",on:u,...Nt(s.length>1?"Switch project":"Open a project",Ht("project")),onClick:()=>e({a:"toggle",overlay:{kind:"projects",form:"pill"}}),...a.contextMenu(l),children:d.jsx("span",{className:"bar-project-name",children:h?"new project":(n==null?void 0:n.name)??(f?"open project":"")})}),u&&d.jsx(Av,{form:"pill"})]})}function nX({worktreeId:e,repoId:t,ready:n,left:r,width:o}){const s=Rt(e,"page").url,a=ht(),l=L(y=>{var w;return((w=y.overlay)==null?void 0:w.kind)==="routes"}),u=L(y=>y.previewSize);ct([e,n],()=>{l&&a({a:"close"})});const h=xn("bar").contextMenu(()=>n?XY(s,{reload:()=>e&&fn.post(e,{type:"reload"})}):[]),p=L(y=>y.picking),g=Sy();return d.jsxs("div",{className:"bar-center",style:{left:r,width:o},children:[d.jsx(Tt,{icon:"back",label:"Back",hint:Ht("back"),disabled:!n,onClick:()=>e&&fn.post(e,{type:"back"}),...h}),d.jsx(Tt,{icon:"forward",label:"Forward",hint:Ht("forward"),disabled:!n,onClick:()=>e&&fn.post(e,{type:"forward"}),...h}),d.jsx(Tt,{icon:"reload",label:"Reload preview",hint:Ht("reload"),disabled:!n,onClick:()=>e&&fn.post(e,{type:"reload"}),...h}),d.jsxs("span",{className:"bar-route",children:[n&&e&&t?d.jsx(kq,{worktreeId:e,repoId:t,url:s,open:l},e):d.jsx(Ho,{className:"bar-path",value:"",readOnly:!0,disabled:!0}),u&&d.jsx("span",{className:"bar-size",children:u})]}),d.jsx(Tt,{icon:"inspect",label:"Pick an element to open its code",hint:Ht("inspect"),also:{text:"Add an element to chat",key:Ht("pick")},on:p==="code",disabled:!n||!g,onClick:()=>g&&Lu(g,p,a,"code")})]})}function ld({icon:e,busy:t,children:n,...r}){return d.jsxs(Me,{disabled:t,...r,children:[!t&&d.jsx(xt,{name:e,className:"icon-inline"}),d.jsx("span",{className:We(t&&"live-text"),children:n})]})}function rX(){const e=L(u=>u.self),t=L(u=>u.rebuilt),n=L(u=>u.repos),r=nt(),o=L(u=>{var f;return((f=u.update)==null?void 0:f.restarting)!=null}),s=gA(e,n,t);if(!s||o)return null;const a=s.busy?"rebuilding":s.reload?"reload Toyon":s.build==="rebuild"?"rebuild Toyon":s.build??"restart Toyon",l=()=>{s.reload?window.location.reload():e&&(r==null||r.send(s.build?{t:"run-after-land",repoId:e.repoId}:{t:"restart-daemon"}))};return d.jsx(ld,{icon:"reload",busy:s.busy,onClick:l,...Nt(s.text,void 0,{detail:s.detail}),children:a})}function oX(){const e=L(o=>o.update),t=L(o=>o.managed.updates),n=nt(),r=ZF(e);return!r||!t?null:d.jsx(ld,{icon:"reload",busy:r.busy,onClick:()=>{r.retry&&(n==null||n.send({t:"update-now"}))},...Nt(r.text),children:r.word})}function sX(){const e=ht(),t=L(p3),n=L(a=>a.ranBefore),r=L(a=>a.newProject!==null);if(!t||!n||r)return null;const{word:o,text:s}=FV(n,t);return d.jsx(ld,{icon:"book",onClick:()=>e({a:"open-release-notes"}),...Nt(s),children:o})}function iX(){const e=ht(),t=L(C3),n=L(s=>s.letIn),r=L(s=>{var a;return((a=s.overlay)==null?void 0:a.kind)==="devices"});if(!t)return null;const o=()=>e({a:"toggle",overlay:{kind:"devices"}});return n?d.jsx(Tt,{icon:"devices",label:"Your devices",tone:"chrome",on:r,tipAlign:"end","aria-expanded":r,onClick:o}):d.jsx(ld,{icon:"devices","aria-expanded":r,onClick:o,...Nt("Open this machine on your phone, and let it in"),children:"open on phone"})}function aX(e,t,n){return t==="left"?n-e.left:e.right-n}const cX="input, textarea, [contenteditable], .monaco-editor, .xterm, iframe";function lX(){const e=Pn(),t=ht(),n=nt(),r=Ju(),o=Ys(),s=ed(),a=L(U=>U.zen)&&!s,l=L(Ui),u=Ga(),f=L(U=>U.notesPage),h=!!Ey()||!!u||f,p=L(U=>U.layout.changes)&&!r,g=L(U=>U.layout.chat)&&!r&&!s&&!h,y=L(U=>U.chatSide),w=L(U=>U.railOpen),[v,x]=ks(it.changesWidth,220,U=>U?Tf(Number(U),220):void 0),[N,S]=ks(it.chatWidth,380,U=>U?Tf(Number(U),380):void 0),[T,j]=ks(it.railWidth,280,U=>U?Tf(Number(U),280):void 0),$=(U,B,Q)=>{const ue=B.classList.contains("left")?"left":"right",he=ue==="left"?B.previousElementSibling:B.nextElementSibling;return he?Tf(aX(he.getBoundingClientRect(),ue,U.clientX),Q):null},R=qc((U,B)=>$(U,B,220),x),A=qc((U,B)=>$(U,B,380),S),I=qc((U,B)=>$(U,B,280),j),[M,P]=E.useState(null),q=xn("app").contextMenu(()=>Uj(e.getState(),{sock:n,dispatch:t})),W=d.jsx(Tj,{width:v}),ee=!s&&!h&&d.jsx(YY,{width:N}),V=!r&&d.jsx(NA,{width:T}),te=U=>!r&&w&&d.jsx("div",{className:`dock-resize ${U}`,onPointerDown:I}),K=y==="left",C=K?{dock:ee,open:g,drag:A}:{dock:W,open:p,drag:R},oe=K?{dock:W,open:p,drag:R}:{dock:ee,open:g,drag:A};return d.jsxs("div",{className:We("app",a&&"zen",l&&"zen-file"),"data-chat-side":y,"data-touch":o||void 0,"data-hover":!o||void 0,onContextMenu:U=>{U.defaultPrevented||U.target instanceof Element&&U.target.closest(cX)||q.onContextMenu(U)},children:[d.jsx(qT,{}),d.jsx(YT,{}),d.jsx(eX,{center:M}),d.jsxs("div",{className:"docks",children:[K&&V,K&&te("left"),C.dock,C.open&&d.jsx("div",{className:"dock-resize left",onPointerDown:C.drag}),d.jsx(VY,{onRoot:P}),oe.open&&d.jsx("div",{className:"dock-resize right",onPointerDown:oe.drag}),oe.dock,!K&&te("right"),!K&&V]})]})}function uX(e,t,n,r){if(!n)return null;const o=e.findIndex(u=>u.id===n);if(o>=0){const u=e[(o+r+e.length)%e.length];return u&&u.id!==n?{activate:u.id}:null}const s=t.findIndex(u=>u.id===n);if(s<0)return null;const a=t[s+r];if(a)return{activate:a.id};const l=e[e.length-1];return r<0&&l?{activate:l.id}:null}const dX=new Set(["design","chats"]),fX=new Set(["back","forward"]),hX=new Set(["wt-back","wt-forward"]),pX=new Set(["project","commands","keys","zen"]);function mX(){const e=Pn(),t=nt();E.useEffect(()=>{const n=kV(p=>e.dispatch({a:"rail-peek",on:p})),r=n.end,o=p=>{e.getState().railOpen||n.press(p)},s=gV(),a=p=>{n.keyup(p.key),s.keyup(p.key)},l=p=>{n.mods(p),s.mods(p)},u=()=>{var w,v;const p=e.getState();if(Ui(p)){e.dispatch({a:"close-editor"});return}const y=((v=(w=document.activeElement)==null?void 0:w.closest("[data-pane]"))==null?void 0:v.dataset.pane)??(p.layout.term?"terminal":p.editor?"editor":p.layout.design?"design":null);y==="terminal"?e.dispatch({a:"toggle-terminal"}):y==="editor"?e.dispatch({a:"close-editor"}):y==="design"&&e.dispatch({a:"toggle-design"})},f=p=>{p.key!=="Escape"||!e.getState().choosingFolder||(p.stopImmediatePropagation(),t==null||t.send({t:"cancel-folder"}),e.dispatch({a:"choosing-folder",v:!1}))},h=p=>{var R,A,I,M;l(p),mR(p)&&!p.defaultPrevented&&p.preventDefault();const g=e.getState(),{dispatch:y}=e,w=(P,F={a:"activate",id:P})=>{const q=document.activeElement,W=!q||q===document.body||!!q.closest(".rail, .chat-input");y(F),W&&y({a:"walked"})},v=KS(p,{guest:!!((R=document.activeElement)!=null&&R.closest(".xterm"))}),x=Ui(g),N=g.zen&&!Co(g)&&!x,S=N?pR(v):v;if(N&&!g.overlay&&!g.picking&&!(S&&fR.has(S.id)))return;const T=P=>P&&!x;if((S==null?void 0:S.id)==="close"&&!iy()||!!((A=document.activeElement)!=null&&A.closest(".monaco-editor"))&&S&&dX.has(S.id))return;const $=S&&hX.has(S.id)&&s.holds(p);if(!(S&&!$&&vR(S.id,document.activeElement))&&!(S&&fX.has(S.id)&&!(zc(g)&&Iu(g)))&&!((S==null?void 0:S.id)==="reload"&&!_k(g))){if(S){const P=p.defaultPrevented;if(p.preventDefault(),g.newProject&&!pX.has(S.id))return;switch(S.id){case"worktree":{const F=kR(S.digit,g.visible.length),q=F===null?void 0:g.visible[F];q&&w(q.id);break}case"wt-prev":case"wt-next":{const F=uX(g.visible,g.visibleDiscovered,g.activeId,S.id==="wt-next"?1:-1);F&&w(F.activate),o(p);break}case"wt-unseen-prev":case"wt-unseen-next":{const F=Ky(g.visible,g.activeId,S.id==="wt-unseen-next"?1:-1);F&&w(F.activate),o(p);break}case"wt-back":case"wt-forward":{const F=e3(g.viewed,gh(g),Yf(g),S.id==="wt-forward"?1:-1);F&&(w(F.id,{a:"viewed-land",at:F.at}),s.press(p)),o(p);break}case"mark-unread":g.activeId&&!g.draft&&g.visible.some(F=>F.id===g.activeId)&&dj(t,y,g.activeId);break;case"wt-archive":{if(p.repeat||P)break;const F=g.draft||g.archivedPage?void 0:g.visible.find(q=>q.id===g.activeId);F&&fj(t,y,q=>dy(g,q)).archive(F);break}case"new":y({a:"open-draft"});break;case"project":y({a:"toggle",overlay:{kind:"projects",form:"center"}});break;case"quick-open":((I=g.overlay)==null?void 0:I.kind)==="quick-open"?y({a:"close"}):g.activeId&&y({a:"open",overlay:{kind:"quick-open"}});break;case"routes":((M=g.overlay)==null?void 0:M.kind)==="routes"?y({a:"close"}):Iu(g)&&y({a:"open",overlay:{kind:"routes"}});break;case"reload":{const F=_k(g);if(!F)break;F.act==="frame"?fn.post(F.id,{type:"reload"}):t==null||t.send({t:"preview-start",worktreeId:F.id});break}case"back":case"forward":{const F=zc(g);F&&fn.post(F,{type:S.id});break}case"pick":case"inspect":{const F=zc(g);F&&Lu(F,g.picking,y,S.id==="pick"?"chat":"code");break}case"search":g.activeId&&y({a:"toggle",overlay:{kind:"search"}});break;case"refs":g.activeRepoId&&y({a:"toggle",overlay:{kind:"refs"}});break;case"chats":g.activeRepoId&&y({a:"toggle",overlay:{kind:"chats"}});break;case"commands":y({a:"toggle",overlay:{kind:"commands"}});break;case"zen":y({a:"toggle-zen",file:qy("editor")});break;case"close":!N&&!g.overlay&&u();break;case"changes":y(T(g.layout.changes)&&(tl(g)==="changes"||Wo(g)!==null)?{a:"toggle-changes"}:{a:"focus-changes",tab:"changes"});break;case"files":y(T(g.layout.changes)&&tl(g)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"});break;case"panel-tab-prev":case"panel-tab-next":if(dp(g))break;y(g.layout.changes?{a:"focus-changes",tab:h3(g,S.id==="panel-tab-next"?1:-1)}:{a:"focus-changes"});break;case"composer":y(x?{a:"focus-chat"}:jN(g));break;case"rail":y(T(g.railOpen)?{a:"toggle-rail"}:{a:"focus-rail"});break;case"keys":y({a:"toggle",overlay:{kind:"keys"}});break;case"terminal":y(T(g.layout.term)?{a:"toggle-terminal"}:{a:"focus-terminal"});break;case"design":y(x&&g.layout.design?{a:"toggle-zen"}:{a:"toggle-design"});break;case"term-tab":{if(x){y({a:"focus-terminal"});break}const F=g.rows.find(V=>V.id===g.activeId);if(!F)break;const q=Or(g,g.activeId).termStream;if(F.login&&q===Ks)break;const W=[Bo,...F.login?[Ks]:[],...F.procs.map(V=>V.name)],ee=W.indexOf(q);y({a:"term-stream",id:F.id,stream:W[(ee+1)%W.length]??Bo});break}}}else if(p.key==="Escape")if(g.newProject)g.newProject.phase==="editing"&&y({a:"close-new-project"});else if(g.picking){const P=zc(g);P&&fn.post(P,{type:"pick-cancel"}),y({a:"set-picking",v:!1})}else g.notesPage?y({a:"close-release-notes"}):g.archivedPage?y({a:"close-archived"}):g.activeImportId?y({a:"watch-import",id:null}):u()}};return window.addEventListener("keydown",f,!0),window.addEventListener("keydown",h),window.addEventListener("keyup",a),window.addEventListener("pointermove",l),window.addEventListener("pointerdown",l),window.addEventListener("blur",r),()=>{window.removeEventListener("keydown",f,!0),window.removeEventListener("keydown",h),window.removeEventListener("keyup",a),window.removeEventListener("pointermove",l),window.removeEventListener("pointerdown",l),window.removeEventListener("blur",r),r()}},[e,t]),E.useEffect(()=>{const n=r=>{if(r.key!=="Alt"&&r.key!=="Shift")return;const o=e.getState();o.picking&&o.activeId&&fn.post(o.activeId,{type:"pick-mods",alt:r.altKey,shift:r.shiftKey})};return window.addEventListener("keydown",n),window.addEventListener("keyup",n),()=>{window.removeEventListener("keydown",n),window.removeEventListener("keyup",n)}},[e])}const gX=3,kX=2e3,wX=200,yX=5e3;function vX(){const e=ht(),t=nt(),n=Gs(),{storage:r}=n,o=fl(),s=L(Z=>Z.activeRepoId),a=Vs(),l=by(),u=L(Z=>Z.connected),f=L(Z=>Z.daylight),h=L(Z=>{var J;return((J=Z.daylight)==null?void 0:J.until)??0}),p=Ga(),g=L(Z=>Z.notesPage),y=L(Z=>Z.version),w=L(Z=>Z.railOpen),v=L(Z=>Z.chatSide),x=L(Z=>Z.layouts),N=L(Z=>Z.lastActive),S=L(Z=>Z.discoveredOpen),T=L(Z=>Z.archivedOpen),j=L(Z=>Z.committedShut),$=L(Z=>Z.turnOpen),R=L(Z=>Z.treeOpen),A=pp(),I=L(Z=>Z.previewTheme!==null),M=L(Z=>Z.openUrl),P=cT();E.useEffect(()=>nl.install(window),[]);const F=E.useRef([]),q=E.useCallback(Z=>t==null?void 0:t.send({t:"subscribe",worktreeId:Z,since:n.since(Z)}),[t,n]);E.useEffect(()=>{if(!t||!u||!o)return;const Z=[o,...F.current.filter(J=>J!==o)];for(const J of Z.splice(gX))t.send({t:"unsubscribe",worktreeId:J});F.current.includes(o)||q(o),F.current=Z},[o,u,t,q]),E.useEffect(()=>{if(!(!t||!u))for(const Z of F.current)q(Z)},[u,t,q]);const W=E.useRef(void 0);E.useEffect(()=>{if(!t||!u)return;let Z;const J=()=>{const ie=document.visibilityState==="visible"?o:null;t.send({t:"view",worktreeId:ie}),W.current=ie},pe=()=>{clearTimeout(Z),Z=setTimeout(J,wX)};W.current===void 0||W.current===o||document.visibilityState!=="visible"?J():pe();const de=()=>document.visibilityState==="visible"?pe():J();return document.addEventListener("visibilitychange",de),()=>{clearTimeout(Z),document.removeEventListener("visibilitychange",de)}},[o,u,t]);const ee=(p==null?void 0:p.id)??null;E.useEffect(()=>{if(!(!t||!u||!ee))return q(ee),()=>t.send({t:"unsubscribe",worktreeId:ee})},[ee,u,t,q]),E.useEffect(()=>{const Z=new Set(P.map(pe=>pe.id)),J=F.current.filter(pe=>!Z.has(pe));if(J.length!==0&&(F.current=F.current.filter(pe=>Z.has(pe)),!(!t||!u)))for(const pe of J)t.send({t:"unsubscribe",worktreeId:pe})},[P,u,t]);const V=g?"Release notes":(p==null?void 0:p.title)??(l==null?void 0:l.name)??null;E.useEffect(()=>{document.title=V?`${V} · Toyon`:"Toyon"},[V]);const te=!!(a!=null&&a.unseen),K=L(Z=>Z.unreadHold!==null&&Z.unreadHold===Z.activeId);E.useEffect(()=>{if(!t||!o||!te||K)return;let Z;const J=()=>document.visibilityState==="visible"&&document.hasFocus(),pe=()=>{clearTimeout(Z),J()&&(Z=setTimeout(()=>{J()&&t.send({t:"seen",worktreeId:o})},kX))},de=()=>clearTimeout(Z);return pe(),window.addEventListener("focus",pe),window.addEventListener("blur",de),()=>{de(),window.removeEventListener("focus",pe),window.removeEventListener("blur",de)}},[t,o,te,K]);const C=E.useRef(0),oe=L(Z=>fy(Z));E.useEffect(()=>{if(!t||!u||!s)return;const Z=()=>{Date.now()-C.current<yX||(C.current=Date.now(),t.send({t:"refresh-git",repoId:s}),oe&&oe!==s&&t.send({t:"refresh-git",repoId:oe}))};return window.addEventListener("focus",Z),()=>window.removeEventListener("focus",Z)},[t,u,s,oe]);const U=L(Z=>Z.frame==="phone"&&Z.screen==="home"?"surface1":"surface0");E.useEffect(()=>{try{sessionStorage.setItem(it.ground,U)}catch{}},[U]);const B=L(Z=>Z.frame==="phone"),Q=L(Z=>Z.blackGround),ue=E.useMemo(()=>B&&Q?E4(A):A,[B,Q,A]);E.useEffect(()=>{try{localStorage.setItem(it.blackGround,Q?"1":"0")}catch{}},[Q]),E.useEffect(()=>{$A(ue,{remember:!I,ground:U,black:ue!==A}),fn.broadcast(CA(ue))},[ue,A,I,U]);const he=E.useCallback(()=>{t==null||t.send({t:"zone",tz:Intl.DateTimeFormat().resolvedOptions().timeZone})},[t]);E.useEffect(()=>{if(!u)return;he();const Z=()=>{document.visibilityState==="visible"&&he()};return document.addEventListener("visibilitychange",Z),()=>document.removeEventListener("visibilitychange",Z)},[u,he]),E.useEffect(()=>{if(!u||h<=Date.now())return;const Z=setTimeout(he,h-Date.now()+1e3);return()=>clearTimeout(Z)},[u,h,he]),E.useEffect(()=>{f&&f.until>0&&DV(f)},[f]),E.useEffect(()=>{o&&r.set(it.active,o)},[o,r]),E.useEffect(()=>{y&&r.set(it.version,y)},[y,r]);const Ne=L(Z=>Z.frame==="phone"?Z.screen!=="home":null);E.useEffect(()=>{Ne!==null&&r.session.set(it.phoneRow,Ne?"1":"0")},[Ne,r]),E.useEffect(()=>{s&&r.set(it.repo,s)},[s,r]),E.useEffect(()=>{try{localStorage.setItem(it.rail,w?"1":"0")}catch{}},[w]),E.useEffect(()=>{try{localStorage.setItem(it.chatSide,v)}catch{}},[v]),E.useEffect(()=>{try{localStorage.setItem(it.layouts,JSON.stringify(x))}catch{}},[x]),E.useEffect(()=>{r.set(it.lastActive,JSON.stringify(N))},[N,r]),E.useEffect(()=>{r.set(it.discoveredOpen,JSON.stringify(S))},[S,r]),E.useEffect(()=>{r.set(it.archivedOpen,JSON.stringify(T))},[T,r]),E.useEffect(()=>{r.set(it.committedShut,JSON.stringify(j))},[j,r]),E.useEffect(()=>{r.set(it.turnOpen,JSON.stringify($))},[$,r]),E.useEffect(()=>{r.set(it.treeOpen,JSON.stringify(R))},[R,r]),mX(),J5();const De=E.useRef(null);return E.useEffect(()=>{!M||De.current===M||(De.current=M,Rr(M),e({a:"opened-url"}))},[M,e]),L(Z=>Z.frame)==="phone"?d.jsx(IV,{}):d.jsx(lX,{})}function bX({origin:e,machine:t,onToken:n}){const[r,o]=E.useState({kind:"asking"}),[s,a]=E.useState(0),l=URL.canParse(e)&&Gh(new URL(e).hostname);return ct([s],()=>{const u=new AbortController;return o({kind:"asking"}),oN(e,u.signal,f=>o({kind:"waiting",word:f})).then(f=>{if(!u.signal.aborted){if(typeof f=="string"){o({kind:"failed",failure:f});return}o({kind:"in"}),n(f.token)}}),()=>u.abort()}),d.jsxs(Es,{children:[r.kind==="waiting"&&d.jsx("div",{className:"knock-word",children:r.word}),d.jsx("p",{className:"status-line",children:r.kind==="asking"?`Asking Toyon on ${t} to let this device in.`:r.kind==="waiting"?`Toyon on ${t} is asking whether to let these two words in. Say yes there.`:r.kind==="in"?"Let in. Opening.":vA(r.failure,e,"this device")}),l&&r.kind!=="in"&&d.jsxs("p",{className:"status-line",children:["This is the machine Toyon runs on, so a terminal here can do it too: ",d.jsx("code",{children:"toyon"})," opens the shell already let in."]}),r.kind==="failed"&&d.jsx("div",{className:"status-actions",children:d.jsx(Me,{variant:"outline",onClick:()=>a(u=>u+1),children:"ask again"})})]})}const rk="toyon-shared",xX="x-toyon-name";async function EX(e=globalThis.caches){var t;try{if(!e||!await e.has(rk))return[];const n=await e.open(rk),r=[];for(const o of await n.keys()){const s=await n.match(o);if(!s)continue;const a=decodeURIComponent(s.headers.get(xX)??"")||"shared",l=((t=(s.headers.get("content-type")??"").split(";")[0])==null?void 0:t.trim())??"";r.push(new File([await s.blob()],a,{type:l}))}return await e.delete(rk),r}catch{return[]}}function TS(e,t=()=>!0){const n=()=>t()?Va(e):null;return new Promise(r=>{const o=n();if(o)return r(o);const s=e.subscribe(()=>{const a=n();a&&(s(),r(a))})})}function SX(e){const[t]=e;if(e.length===1&&t)return`pick a chat for ${t.name}`;const n=e.every(r=>r.type.startsWith("image/"))?"images":"files";return`pick a chat for ${e.length} ${n}`}async function _X(e,t){const n=await EX(t);if(n.length===0)return;if(e.getState().frame!=="phone"){kh(e,await TS(e),n);return}e.dispatch({a:"screen",to:"home"}),e.dispatch({a:"sharing",v:SX(n)});const r=await TS(e,()=>e.getState().screen!=="home");e.dispatch({a:"sharing",v:null}),kh(e,r,n)}function NX(){const e=new Map;return{on(t,n){let r=e.get(t);return r||(r=new Set,e.set(t,r)),r.add(n),()=>{r.delete(n),r.size===0&&e.delete(t)}},deliver(t){for(const n of e.get(JI(t.worktreeId,t.stream))??[])n(t)}}}const TX=2e3,jX=1500;function $X(e,t,n,r={}){const o=r.timers??{set:(R,A)=>setTimeout(R,A),clear:R=>clearTimeout(R)},s=r.now??(()=>Date.now()),a=r.win??(typeof window>"u"?null:window),l=new Map,u=R=>{let A=l.get(R);return A||(A=new Qz,l.set(R,A)),A},f=new Map,h=new Map,p=R=>{var P;o.clear(h.get(R)),h.delete(R);const A=e.getState();if(R===""){if(!A.heard)return;const F=Kz(A,s());if(!F)return;const q=Xz(Object.fromEntries([...f].map(([W,ee])=>[W,{at:ee}])),A.rows);for(const W of q)f.delete(W),l.delete(W);t.putHello(n,F).then(()=>q.length?t.dropChats(n,q):void 0);return}const I=l.get(R);if(!I||!A.rows.some(F=>F.id===R))return;const M=s();f.set(R,M),t.putChat(n,R,I.snapshot((P=A.local[R])==null?void 0:P.draft,M))},g=R=>{h.has(R)||h.set(R,o.set(()=>p(R),TX))},y=()=>{for(const R of[...h.keys()])p(R)};let w=e.getState();const v=new Map,x=e.subscribe(()=>{var A;const R=e.getState();if(R.heard&&(!w.heard||R.rows!==w.rows||R.repos!==w.repos||R.trunks!==w.trunks||R.handed!==w.handed||R.visits!==w.visits)&&g(""),R.local!==w.local)for(const I of l.keys()){const M=((A=R.local[I])==null?void 0:A.draft)??"";(v.get(I)??"")!==M&&(v.set(I,M),g(I))}w=R}),N=()=>{var R;((R=a==null?void 0:a.document)==null?void 0:R.visibilityState)==="hidden"&&y()};a==null||a.addEventListener("visibilitychange",N),a==null||a.addEventListener("pagehide",y);const S=Promise.all([t.hello(n),t.chats(n)]);let T;const j=new Promise(R=>{T=o.set(()=>R(null),jX)});return{recalled:Promise.race([S,j]).then(R=>{if(o.clear(T),!R)return;const[A,I]=R;for(const[P,F]of Object.entries(I))f.set(P,F.at);if(!A||!Ix(A)||e.getState().heard)return;const M={};for(const[P,F]of Object.entries(I))Ix(F)&&(M[P]=F);try{e.dispatch({a:"recall",hello:A,chats:M})}catch(P){console.error("the last-known machine could not be recalled; dropping it",P),f.clear(),t.clear(n);return}for(const[P,F]of Object.entries(M))u(P).reset(F.events,F.seq,!1),v.set(P,F.draft??"")}).catch(R=>{console.error("the last-known machine could not be read",R)}),hear(R){var A;if(R.t==="backfill"){const I=u(R.worktreeId);g(R.worktreeId);const M=(((A=e.getState().local[R.worktreeId])==null?void 0:A.chat.length)??0)>0;if(R.after!==void 0&&R.after===I.since()&&M)return I.extend(R.events,R.last),R;if(I.reset(R.events,R.last,R.after===void 0),R.after===void 0)return R;const{after:P,...F}=R;return F}return R.t==="agent"&&(u(R.worktreeId).add(R.seq,R.event),g(R.worktreeId)),R},since:R=>{var A;return(A=l.get(R))==null?void 0:A.since()},forget(){for(const R of[...h.keys()])o.clear(h.get(R)),h.delete(R);l.clear(),f.clear(),t.clear(n)},dispose(){x(),a==null||a.removeEventListener("visibilitychange",N),a==null||a.removeEventListener("pagehide",y),y()}}}function CX(){const e=new Map,t=n=>{const r=mo.chats(n),o={};for(const[s,a]of e)s.startsWith(r)&&(o[s.slice(r.length)]=a);return o};return{hello:async n=>e.get(mo.hello(n))??null,putHello:async(n,r)=>void e.set(mo.hello(n),r),chats:async n=>t(n),putChat:async(n,r,o)=>void e.set(mo.chat(n,r),o),dropChats:async(n,r)=>{for(const o of r)e.delete(mo.chat(n,o))},clear:async n=>{e.delete(mo.hello(n));for(const r of[...e.keys()])r.startsWith(mo.chats(n))&&e.delete(r)}}}function DA(){if(typeof indexedDB>"u")return CX();let e=null;const t=()=>(e??(e=new Promise((s,a)=>{const l=indexedDB.open(F4,1);l.onupgradeneeded=()=>l.result.createObjectStore(nu),l.onsuccess=()=>s(l.result),l.onerror=()=>a(l.error),l.onblocked=()=>a(new Error("blocked"))}).catch(s=>{throw e=null,s})),e),n=async(s,a)=>{const l=(await t()).transaction(nu,s).objectStore(nu);return new Promise((u,f)=>{const h=a(l);h.onsuccess=()=>u(h.result),h.onerror=()=>f(h.error)})},r=s=>{const a=mo.chats(s);return IDBKeyRange.bound(a,`${a}￿`)},o=async(s,a)=>{try{return await s}catch{return a}};return{hello:s=>o(n("readonly",a=>a.get(mo.hello(s))),void 0).then(a=>a??null),putHello:(s,a)=>o(n("readwrite",l=>l.put(a,mo.hello(s))),void 0).then(()=>{}),chats:async s=>{const a=mo.chats(s),[l,u]=await o((async()=>{const h=(await t()).transaction(nu,"readonly").objectStore(nu),p=g=>new Promise((y,w)=>{g.onsuccess=()=>y(g.result),g.onerror=()=>w(g.error)});return Promise.all([p(h.getAllKeys(r(s))),p(h.getAll(r(s)))])})(),[[],[]]),f={};return l.forEach((h,p)=>{const g=u[p];typeof h=="string"&&g&&(f[h.slice(a.length)]=g)}),f},putChat:(s,a,l)=>o(n("readwrite",u=>u.put(l,mo.chat(s,a))),void 0).then(()=>{}),dropChats:async(s,a)=>{for(const l of a)await o(n("readwrite",u=>u.delete(mo.chat(s,l))),void 0)},clear:async s=>{await o(n("readwrite",a=>a.delete(mo.hello(s))),void 0),await o(n("readwrite",a=>a.delete(r(s))),void 0)}}}function AX(e){try{const t=new URL(e),n=t.hostname.split(".")[0]??t.hostname;return t.port&&(n==="127"||n==="localhost")?`${t.hostname}:${t.port}`:n}catch{return e}}function IX(e){const t={};try{const n=JSON.parse(e??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))r3(o)&&(t[r]=o)}catch{}return t}function RX(e){const t={};try{const n=JSON.parse(e??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))typeof o=="string"&&o&&(t[r]=o)}catch{}return t}function Uf(e){const t={};try{const n=JSON.parse(e??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))typeof o=="boolean"&&(t[r]=o)}catch{}return t}function OX(e){const t={};try{const n=JSON.parse(e??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))Array.isArray(o)&&o.every(s=>typeof s=="string")&&o.length>0&&(t[r]=o)}catch{}return t}const MX=400,LX=2e3;function zA(){const e=new Map;return{another(t,n=0){return(e.get(t)??0)===n?!1:(e.set(t,n),!0)}}}function FA(e,t,n){const r=e.getState(),o=[];for(const[s,a]of t){if(a===n||r.local[s])continue;const l=ws(s);l&&l.clientId!==r.clientId||o.push(s)}return o}function PX(e,t){const n=new Map,r=new Map,o=zA(),s=u=>{var h,p;clearTimeout((h=r.get(u))==null?void 0:h.timer),r.delete(u);const f=e.getState().local[u];!f||((p=f.mark)==null?void 0:p.by)==="walk"||(n.get(u)??"")!==f.draft&&(n.set(u,f.draft),t.send({t:"set-draft",boxId:u,text:f.draft,clientId:e.getState().clientId}))},a=()=>{for(const u of[...r.keys()])s(u)},l=e.subscribe(()=>{var u,f,h;for(const[p,g]of Object.entries(e.getState().local)){if(o.another(p,g.sent)&&(clearTimeout((u=r.get(p))==null?void 0:u.timer),r.delete(p),n.set(p,"")),((f=g.mark)==null?void 0:f.by)==="walk"||(n.get(p)??"")===g.draft)continue;if(!g.draft){s(p);continue}const y=r.get(p);if((y==null?void 0:y.text)===g.draft)continue;clearTimeout(y==null?void 0:y.timer);const w=(y==null?void 0:y.since)??Date.now(),v=Math.max(0,Math.min(MX,w+LX-Date.now()));r.set(p,{text:g.draft,timer:setTimeout(s,v,p),since:w})}for(const p of FA(e,n,""))clearTimeout((h=r.get(p))==null?void 0:h.timer),r.delete(p),n.set(p,""),t.send({t:"set-draft",boxId:p,text:"",clientId:e.getState().clientId})});return window.addEventListener("focusout",a),window.addEventListener("pagehide",a),{hello(u){n.clear();for(const[f,h]of Object.entries(u))n.set(f,h)},heard(u,f){return r.has(u)?!1:(n.set(u,f),!0)},dispose(){l();for(const u of r.values())clearTimeout(u.timer);r.clear(),window.removeEventListener("focusout",a),window.removeEventListener("pagehide",a)}}}function DX(e,t){const n=new Map,r=new Map,o=zA(),s=e.subscribe(()=>{const a=[];for(const[l,u]of Object.entries(e.getState().local)){if(o.another(l,u.sent)&&r.set(l,"[]"),n.get(l)===u.attachments)continue;n.set(l,u.attachments);const f=ly(u.attachments),h=JSON.stringify(f),p=r.get(l)??"[]";p!==h&&(r.set(l,h),a.push({id:l,items:f,before:bN(JSON.parse(p))}))}for(const l of FA(e,r,"[]"))r.set(l,"[]"),a.push({id:l,items:[],before:[]});for(const l of Uz(a))t.send({t:"set-attachments",boxId:l.id,items:l.items,clientId:e.getState().clientId})});return{hello(a){r.clear(),n.clear();for(const[l,u]of Object.entries(a))r.set(l,JSON.stringify(u))},heard(a,l){r.set(a,JSON.stringify(l))},dispose:s}}function zX(e,t){return e.subscribe(()=>{for(const n of Bz(e.getState().outbox,e.getState().local)){const r=e.getState(),o=r.local[n];o!=null&&o.outgoing&&(t.send({t:"set-draft",boxId:n,text:o.draft,clientId:r.clientId}),t.send(fu(o.outgoing.frame,n,o.draft,o.attachments)),e.dispatch({a:"sent-out",id:n}))}})}const jS="not sent: the page reloaded while an upload was on its way; attach it again and send";function $S(e,t,n){var a;const r=e.getState(),o=new Set([...Object.keys(n.drafts),...Object.keys(n.attachments)]),s=[];for(const l of o){const u=ws(l);if((u==null?void 0:u.clientId)!==r.clientId||(a=r.local[l])!=null&&a.outgoing)continue;const f=n.drafts[l]??"",h=n.attachments[l]??[],p=n.drafts[u.source]??"",g=[...h,...n.attachments[u.source]??[]],y=p||f,w=r.clientId;g.length&&t.send({t:"set-attachments",boxId:u.source,items:g,clientId:w}),y!==p&&t.send({t:"set-draft",boxId:u.source,text:y,clientId:w}),t.send({t:"set-attachments",boxId:l,items:[],clientId:w}),t.send({t:"set-draft",boxId:l,text:"",clientId:w}),delete n.drafts[l],delete n.attachments[l],y&&(n.drafts[u.source]=y),g.length&&(n.attachments[u.source]=g),s.push(u.source)}return s}function FX(e,t){const n=(t.storage??B4)(e.origin),r=V3(s3({cached:t.cached,systemDark:t.systemDark,daylight:t.daylight,storedActive:n.get(it.active),storedPhoneRow:n.session.get(it.phoneRow)==="1",storedRepo:n.get(it.repo),storedVersion:n.get(it.version),storedRailOpen:Hf(it.rail)==="1",storedChatSide:Hf(it.chatSide)==="right"?"right":"left",storedBlackGround:Hf(it.blackGround)==="1",storedLayouts:IX(Hf(it.layouts)),storedLastActive:RX(n.get(it.lastActive)),storedDiscoveredOpen:Uf(n.get(it.discoveredOpen)),storedArchivedOpen:Uf(n.get(it.archivedOpen)),storedCommittedShut:Uf(n.get(it.committedShut)),storedTurnOpen:Uf(n.get(it.turnOpen)),storedTreeOpen:OX(n.get(it.treeOpen)),clientId:t.clientId,frame:t.frame,touch:t.touch})),o=NX(),s={version:null,protocol:null},a=zU(v=>r.dispatch({a:"server",msg:v}));let l,u,f;const h=$X(r,t.snapshots??DA(),e.origin);let p=[];const g=new uz(e,v=>{if(v.t==="hello"){if(s.protocol=v.protocol,e.serving){const{rebuilt:N,update:S}=r.getState(),T=N&&(S==null?void 0:S.restarting)!=null;if(s.version!==null&&(T||v.version!==s.version||v.protocol!==Ta)){g.dispose(),t.reload();return}if(v.protocol!==Ta){r.dispatch({a:"incompatible"}),g.dispose();return}}else if(v.protocol!==Ta){r.dispatch({a:"incompatible"}),g.suspend();return}else r.getState().incompatible&&r.dispatch({a:"incompatible",v:!1});s.version=v.version;const x=new Set(g.sentWhileDown());if(x.size){const N=S=>Object.fromEntries(Object.entries(S).filter(([T])=>!x.has(T)));v.drafts=N(v.drafts),v.attachments=N(v.attachments)}p=$S(r,g,v),l.hello(v.drafts),u.hello(v.attachments)}if(v.t==="attachments"&&v.clientId!==r.getState().clientId&&u.heard(v.boxId,v.items),!(v.t==="draft"&&v.clientId!==r.getState().clientId&&!l.heard(v.boxId,v.text))){if(ND(v)){o.deliver(v);return}if(TD(v)){if(v.t==="file-written"&&Q6(v))return;f.receive(v);return}if(v.t==="loose-written"){lZ(v);return}if($9(v)){R9(r,g,v);return}if(v.t==="open-refused"){I9(r,v);return}a(h.hear(v));for(const x of p.splice(0))r.dispatch({a:"notice",id:x,text:jS})}},(v,x)=>r.dispatch({a:"connected",v,failure:x}),{},{known:()=>H3(r.getState()),held:e.serving});n5(r,g.urls),f=new aZ({store:r,send:v=>g.send(v),timers:{set:(v,x)=>setTimeout(v,x),clear:v=>clearTimeout(v)},win:window});const y=f.start();l=PX(r,g),u=DX(r,g);const w=zX(r,g);return{origin:e.origin,serving:e.serving,token:e.token,get name(){return r.getState().machine??AX(e.origin)},store:r,sock:g,files:f,terminals:o,storage:n,heard:s,recalled:h.recalled,forget:()=>h.forget(),boot(v){try{if((v==null?void 0:v.t)==="hello"&&v.protocol===Ta){s.version??(s.version=v.version);const x=$S(r,g,v);u.hello(v.attachments),r.dispatch({a:"server",msg:v});for(const N of x)r.dispatch({a:"notice",id:N,text:jS})}}finally{g.resume()}},since:v=>{var x;return(x=r.getState().local[v])!=null&&x.chat.length?h.since(v):void 0},dispose(){g.dispose(),y(),l.dispose(),u.dispose(),w(),h.dispose()}}}function Hf(e){try{return localStorage.getItem(e)}catch{return null}}window.__toyonShell=!0;const BA=UT();BA&&(document.documentElement.dataset.framed="");H4(location.origin);const UA=RV();$A(UA);function BX(e,t){try{return e.getItem(t)}catch{return null}}function UX(){const e=BX(sessionStorage,it.client);if(e)return e;const t=Math.random().toString(36).slice(2,10);try{sessionStorage.setItem(it.client,t)}catch{}return t}const HX={cached:UA,systemDark:MV(),daylight:PV(),clientId:UX(),frame:Ly(),touch:rF(),reload:()=>window.location.reload(),snapshots:DA()},vs=HG({serving:{origin:location.origin,token:Q_()},build:e=>FX(e,HX)});oF({dispatch:e=>vs.broadcast(e)});zV(e=>vs.broadcast({a:"system-dark",v:e}));const HA=e=>BA?()=>{}:NV(e);let CS=HA(vs.active().store),AS=vs.active();vs.subscribe(()=>{const e=vs.active();e!==AS&&(AS=e,CS(),e.store.getState().frame==="phone"&&e.store.dispatch({a:"screen",to:"home"}),CS=HA(e.store))});window.addEventListener("vite:preloadError",GF);const WX=Promise.all([(window.toyonBoot??Promise.resolve(null)).then(e=>{const t=e;vs.active().boot(t&&typeof t=="object"&&t.t==="hello"?t:null)}),vs.active().recalled]).catch(e=>{console.error("boot",e)});function KX(e){J_(e),window.location.reload()}const qX=KI.createRoot(document.getElementById("root"));WX.then(()=>{var e;OS.flushSync(()=>qX.render(d.jsx(FI.StrictMode,{children:d.jsx(Py,{children:hh()?d.jsx(X3,{machines:vs,children:d.jsx(vX,{})}):d.jsx(bX,{origin:location.origin,machine:location.host,onToken:KX})})}))),document.documentElement.style.removeProperty("background"),document.documentElement.style.removeProperty("--boot-ink"),(e=document.getElementById("boot"))==null||e.remove(),hh()&&_X(vs.active().store)});"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{});export{Qs as F,pT as S,mw as _,dr as a,Gw as b,QX as c,ct as d,QE as e,eQ as f,YX as g,I4 as h,Xu as i,d as j,VX as k,KS as l,go as m,qS as n,Rr as o,XX as p,JI as q,E as r,S4 as s,kp as t,JX as u,s9 as v,Sx as w,Wy as x,GX as y};