toyon 0.21.0 → 0.22.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 (105) hide show
  1. package/README.md +2 -2
  2. package/dist/CHANGELOG.md +26 -0
  3. package/dist/bridge.js +1 -1
  4. package/dist/cli.js +2 -2
  5. package/dist/daemon.js +216 -72
  6. package/dist/shell/assets/{Editor-D_bxx8PL.js → Editor-1fCgxkUp.js} +177 -177
  7. package/dist/shell/assets/Editor-1fCgxkUp.js.br +0 -0
  8. package/dist/shell/assets/Editor-1fCgxkUp.js.gz +0 -0
  9. package/dist/shell/assets/{XTerm-DNFNsoHC.js → XTerm-B_hkTWne.js} +1 -1
  10. package/dist/shell/assets/XTerm-B_hkTWne.js.br +0 -0
  11. package/dist/shell/assets/XTerm-B_hkTWne.js.gz +0 -0
  12. package/dist/shell/assets/{cssMode-BxHmuU8y.js → cssMode-1LqDnQzX.js} +1 -1
  13. package/dist/shell/assets/cssMode-1LqDnQzX.js.br +0 -0
  14. package/dist/shell/assets/cssMode-1LqDnQzX.js.gz +0 -0
  15. package/dist/shell/assets/{freemarker2-Cx9ZoWdp.js → freemarker2-BJFDEJKJ.js} +1 -1
  16. package/dist/shell/assets/freemarker2-BJFDEJKJ.js.br +0 -0
  17. package/dist/shell/assets/freemarker2-BJFDEJKJ.js.gz +0 -0
  18. package/dist/shell/assets/{grammar-DlhzivAk.js → grammar-DVeERVO3.js} +1 -1
  19. package/dist/shell/assets/grammar-DVeERVO3.js.br +0 -0
  20. package/dist/shell/assets/grammar-DVeERVO3.js.gz +0 -0
  21. package/dist/shell/assets/{handlebars-D0MhpM71.js → handlebars-BGFLy2DH.js} +1 -1
  22. package/dist/shell/assets/handlebars-BGFLy2DH.js.br +0 -0
  23. package/dist/shell/assets/handlebars-BGFLy2DH.js.gz +0 -0
  24. package/dist/shell/assets/{html-Da9gyCH4.js → html-CPJflvc5.js} +1 -1
  25. package/dist/shell/assets/html-CPJflvc5.js.br +0 -0
  26. package/dist/shell/assets/html-CPJflvc5.js.gz +0 -0
  27. package/dist/shell/assets/{htmlMode-CGo3ddCJ.js → htmlMode-CjqzceBV.js} +1 -1
  28. package/dist/shell/assets/htmlMode-CjqzceBV.js.br +0 -0
  29. package/dist/shell/assets/htmlMode-CjqzceBV.js.gz +0 -0
  30. package/dist/shell/assets/index-DdrVWdNt.js +292 -0
  31. package/dist/shell/assets/index-DdrVWdNt.js.br +0 -0
  32. package/dist/shell/assets/index-DdrVWdNt.js.gz +0 -0
  33. package/dist/shell/assets/index-Dx-i3szQ.css +1 -0
  34. package/dist/shell/assets/index-Dx-i3szQ.css.br +0 -0
  35. package/dist/shell/assets/index-Dx-i3szQ.css.gz +0 -0
  36. package/dist/shell/assets/{javascript-BXQxakKJ.js → javascript-B4CelO-C.js} +1 -1
  37. package/dist/shell/assets/{jsonMode-DT4ON4ij.js → jsonMode-C2JxYuT6.js} +1 -1
  38. package/dist/shell/assets/jsonMode-C2JxYuT6.js.br +0 -0
  39. package/dist/shell/assets/jsonMode-C2JxYuT6.js.gz +0 -0
  40. package/dist/shell/assets/{liquid-Bm6Hq-FF.js → liquid-BfXRgBm_.js} +1 -1
  41. package/dist/shell/assets/liquid-BfXRgBm_.js.br +0 -0
  42. package/dist/shell/assets/liquid-BfXRgBm_.js.gz +0 -0
  43. package/dist/shell/assets/{lspLanguageFeatures-DWvAzXxS.js → lspLanguageFeatures-CAi6hRgs.js} +1 -1
  44. package/dist/shell/assets/lspLanguageFeatures-CAi6hRgs.js.br +0 -0
  45. package/dist/shell/assets/lspLanguageFeatures-CAi6hRgs.js.gz +0 -0
  46. package/dist/shell/assets/{mdx-DNcDUEs7.js → mdx-DeBYGdge.js} +1 -1
  47. package/dist/shell/assets/mdx-DeBYGdge.js.br +0 -0
  48. package/dist/shell/assets/mdx-DeBYGdge.js.gz +0 -0
  49. package/dist/shell/assets/{python-BgETNCIe.js → python-CFhHKm43.js} +1 -1
  50. package/dist/shell/assets/python-CFhHKm43.js.br +0 -0
  51. package/dist/shell/assets/python-CFhHKm43.js.gz +0 -0
  52. package/dist/shell/assets/{razor-Cf_D69YI.js → razor-C-gkU4Y9.js} +1 -1
  53. package/dist/shell/assets/razor-C-gkU4Y9.js.br +0 -0
  54. package/dist/shell/assets/razor-C-gkU4Y9.js.gz +0 -0
  55. package/dist/shell/assets/{tsMode-BQA_zU_Q.js → tsMode-8E7grKbo.js} +1 -1
  56. package/dist/shell/assets/tsMode-8E7grKbo.js.br +0 -0
  57. package/dist/shell/assets/tsMode-8E7grKbo.js.gz +0 -0
  58. package/dist/shell/assets/{xml-DrZtVQVT.js → xml-CBoTF2r1.js} +1 -1
  59. package/dist/shell/assets/xml-CBoTF2r1.js.br +0 -0
  60. package/dist/shell/assets/xml-CBoTF2r1.js.gz +0 -0
  61. package/dist/shell/assets/{yaml-CzR4Kx36.js → yaml-CyKxhzxl.js} +1 -1
  62. package/dist/shell/assets/yaml-CyKxhzxl.js.br +0 -0
  63. package/dist/shell/assets/yaml-CyKxhzxl.js.gz +0 -0
  64. package/dist/shell/index.html +2 -2
  65. package/package.json +1 -1
  66. package/dist/shell/assets/Editor-D_bxx8PL.js.br +0 -0
  67. package/dist/shell/assets/Editor-D_bxx8PL.js.gz +0 -0
  68. package/dist/shell/assets/XTerm-DNFNsoHC.js.br +0 -0
  69. package/dist/shell/assets/XTerm-DNFNsoHC.js.gz +0 -0
  70. package/dist/shell/assets/cssMode-BxHmuU8y.js.br +0 -0
  71. package/dist/shell/assets/cssMode-BxHmuU8y.js.gz +0 -0
  72. package/dist/shell/assets/freemarker2-Cx9ZoWdp.js.br +0 -0
  73. package/dist/shell/assets/freemarker2-Cx9ZoWdp.js.gz +0 -0
  74. package/dist/shell/assets/grammar-DlhzivAk.js.br +0 -0
  75. package/dist/shell/assets/grammar-DlhzivAk.js.gz +0 -0
  76. package/dist/shell/assets/handlebars-D0MhpM71.js.br +0 -0
  77. package/dist/shell/assets/handlebars-D0MhpM71.js.gz +0 -0
  78. package/dist/shell/assets/html-Da9gyCH4.js.br +0 -0
  79. package/dist/shell/assets/html-Da9gyCH4.js.gz +0 -0
  80. package/dist/shell/assets/htmlMode-CGo3ddCJ.js.br +0 -0
  81. package/dist/shell/assets/htmlMode-CGo3ddCJ.js.gz +0 -0
  82. package/dist/shell/assets/index-DJ0qL1Ze.css +0 -1
  83. package/dist/shell/assets/index-DJ0qL1Ze.css.br +0 -0
  84. package/dist/shell/assets/index-DJ0qL1Ze.css.gz +0 -0
  85. package/dist/shell/assets/index-DMDdU-hM.js +0 -288
  86. package/dist/shell/assets/index-DMDdU-hM.js.br +0 -0
  87. package/dist/shell/assets/index-DMDdU-hM.js.gz +0 -0
  88. package/dist/shell/assets/jsonMode-DT4ON4ij.js.br +0 -0
  89. package/dist/shell/assets/jsonMode-DT4ON4ij.js.gz +0 -0
  90. package/dist/shell/assets/liquid-Bm6Hq-FF.js.br +0 -0
  91. package/dist/shell/assets/liquid-Bm6Hq-FF.js.gz +0 -0
  92. package/dist/shell/assets/lspLanguageFeatures-DWvAzXxS.js.br +0 -0
  93. package/dist/shell/assets/lspLanguageFeatures-DWvAzXxS.js.gz +0 -0
  94. package/dist/shell/assets/mdx-DNcDUEs7.js.br +0 -0
  95. package/dist/shell/assets/mdx-DNcDUEs7.js.gz +0 -0
  96. package/dist/shell/assets/python-BgETNCIe.js.br +0 -0
  97. package/dist/shell/assets/python-BgETNCIe.js.gz +0 -0
  98. package/dist/shell/assets/razor-Cf_D69YI.js.br +0 -0
  99. package/dist/shell/assets/razor-Cf_D69YI.js.gz +0 -0
  100. package/dist/shell/assets/tsMode-BQA_zU_Q.js.br +0 -0
  101. package/dist/shell/assets/tsMode-BQA_zU_Q.js.gz +0 -0
  102. package/dist/shell/assets/xml-DrZtVQVT.js.br +0 -0
  103. package/dist/shell/assets/xml-DrZtVQVT.js.gz +0 -0
  104. package/dist/shell/assets/yaml-CzR4Kx36.js.br +0 -0
  105. package/dist/shell/assets/yaml-CzR4Kx36.js.gz +0 -0
@@ -1,288 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Editor-D_bxx8PL.js","assets/grammar-DlhzivAk.js","assets/Editor-CB2SckMT.css","assets/XTerm-DNFNsoHC.js","assets/XTerm-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
2
- var JC=Object.defineProperty;var eA=(e,t,n)=>t in e?JC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Tt=(e,t,n)=>eA(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 xE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Mm={exports:{}},Bc={},Lm={exports:{}},en={};/**
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 $0;function tA(){if($0)return en;$0=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"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),m=Symbol.iterator;function g(W){return W===null||typeof W!="object"?null:(W=m&&W[m]||W["@@iterator"],typeof W=="function"?W:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,v={};function _(W,re,fe){this.props=W,this.context=re,this.refs=v,this.updater=fe||y}_.prototype.isReactComponent={},_.prototype.setState=function(W,re){if(typeof W!="object"&&typeof W!="function"&&W!=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,W,re,"setState")},_.prototype.forceUpdate=function(W){this.updater.enqueueForceUpdate(this,W,"forceUpdate")};function x(){}x.prototype=_.prototype;function N(W,re,fe){this.props=W,this.context=re,this.refs=v,this.updater=fe||y}var T=N.prototype=new x;T.constructor=N,w(T,_.prototype),T.isPureReactComponent=!0;var j=Array.isArray,C=Object.prototype.hasOwnProperty,I={current:null},A={key:!0,ref:!0,__self:!0,__source:!0};function M(W,re,fe){var pe,Te={},je=null,de=null;if(re!=null)for(pe in re.ref!==void 0&&(de=re.ref),re.key!==void 0&&(je=""+re.key),re)C.call(re,pe)&&!A.hasOwnProperty(pe)&&(Te[pe]=re[pe]);var J=arguments.length-2;if(J===1)Te.children=fe;else if(1<J){for(var te=Array(J),ve=0;ve<J;ve++)te[ve]=arguments[ve+2];Te.children=te}if(W&&W.defaultProps)for(pe in J=W.defaultProps,J)Te[pe]===void 0&&(Te[pe]=J[pe]);return{$$typeof:e,type:W,key:je,ref:de,props:Te,_owner:I.current}}function O(W,re){return{$$typeof:e,type:W.type,key:re,ref:W.ref,props:W.props,_owner:W._owner}}function z(W){return typeof W=="object"&&W!==null&&W.$$typeof===e}function B(W){var re={"=":"=0",":":"=2"};return"$"+W.replace(/[=:]/g,function(fe){return re[fe]})}var H=/\/+/g;function Y(W,re){return typeof W=="object"&&W!==null&&W.key!=null?B(""+W.key):re.toString(36)}function ie(W,re,fe,pe,Te){var je=typeof W;(je==="undefined"||je==="boolean")&&(W=null);var de=!1;if(W===null)de=!0;else switch(je){case"string":case"number":de=!0;break;case"object":switch(W.$$typeof){case e:case t:de=!0}}if(de)return de=W,Te=Te(de),W=pe===""?"."+Y(de,0):pe,j(Te)?(fe="",W!=null&&(fe=W.replace(H,"$&/")+"/"),ie(Te,re,fe,"",function(ve){return ve})):Te!=null&&(z(Te)&&(Te=O(Te,fe+(!Te.key||de&&de.key===Te.key?"":(""+Te.key).replace(H,"$&/")+"/")+W)),re.push(Te)),1;if(de=0,pe=pe===""?".":pe+":",j(W))for(var J=0;J<W.length;J++){je=W[J];var te=pe+Y(je,J);de+=ie(je,re,fe,te,Te)}else if(te=g(W),typeof te=="function")for(W=te.call(W),J=0;!(je=W.next()).done;)je=je.value,te=pe+Y(je,J++),de+=ie(je,re,fe,te,Te);else if(je==="object")throw re=String(W),Error("Objects are not valid as a React child (found: "+(re==="[object Object]"?"object with keys {"+Object.keys(W).join(", ")+"}":re)+"). If you meant to render a collection of children, use an array instead.");return de}function Q(W,re,fe){if(W==null)return W;var pe=[],Te=0;return ie(W,pe,"","",function(je){return re.call(fe,je,Te++)}),pe}function le(W){if(W._status===-1){var re=W._result;re=re(),re.then(function(fe){(W._status===0||W._status===-1)&&(W._status=1,W._result=fe)},function(fe){(W._status===0||W._status===-1)&&(W._status=2,W._result=fe)}),W._status===-1&&(W._status=0,W._result=re)}if(W._status===1)return W._result.default;throw W._result}var U={current:null},$={transition:null},q={ReactCurrentDispatcher:U,ReactCurrentBatchConfig:$,ReactCurrentOwner:I};function V(){throw Error("act(...) is not supported in production builds of React.")}return en.Children={map:Q,forEach:function(W,re,fe){Q(W,function(){re.apply(this,arguments)},fe)},count:function(W){var re=0;return Q(W,function(){re++}),re},toArray:function(W){return Q(W,function(re){return re})||[]},only:function(W){if(!z(W))throw Error("React.Children.only expected to receive a single React element child.");return W}},en.Component=_,en.Fragment=n,en.Profiler=o,en.PureComponent=N,en.StrictMode=r,en.Suspense=u,en.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=q,en.act=V,en.cloneElement=function(W,re,fe){if(W==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+W+".");var pe=w({},W.props),Te=W.key,je=W.ref,de=W._owner;if(re!=null){if(re.ref!==void 0&&(je=re.ref,de=I.current),re.key!==void 0&&(Te=""+re.key),W.type&&W.type.defaultProps)var J=W.type.defaultProps;for(te in re)C.call(re,te)&&!A.hasOwnProperty(te)&&(pe[te]=re[te]===void 0&&J!==void 0?J[te]:re[te])}var te=arguments.length-2;if(te===1)pe.children=fe;else if(1<te){J=Array(te);for(var ve=0;ve<te;ve++)J[ve]=arguments[ve+2];pe.children=J}return{$$typeof:e,type:W.type,key:Te,ref:je,props:pe,_owner:de}},en.createContext=function(W){return W={$$typeof:a,_currentValue:W,_currentValue2:W,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},W.Provider={$$typeof:s,_context:W},W.Consumer=W},en.createElement=M,en.createFactory=function(W){var re=M.bind(null,W);return re.type=W,re},en.createRef=function(){return{current:null}},en.forwardRef=function(W){return{$$typeof:c,render:W}},en.isValidElement=z,en.lazy=function(W){return{$$typeof:f,_payload:{_status:-1,_result:W},_init:le}},en.memo=function(W,re){return{$$typeof:h,type:W,compare:re===void 0?null:re}},en.startTransition=function(W){var re=$.transition;$.transition={};try{W()}finally{$.transition=re}},en.unstable_act=V,en.useCallback=function(W,re){return U.current.useCallback(W,re)},en.useContext=function(W){return U.current.useContext(W)},en.useDebugValue=function(){},en.useDeferredValue=function(W){return U.current.useDeferredValue(W)},en.useEffect=function(W,re){return U.current.useEffect(W,re)},en.useId=function(){return U.current.useId()},en.useImperativeHandle=function(W,re,fe){return U.current.useImperativeHandle(W,re,fe)},en.useInsertionEffect=function(W,re){return U.current.useInsertionEffect(W,re)},en.useLayoutEffect=function(W,re){return U.current.useLayoutEffect(W,re)},en.useMemo=function(W,re){return U.current.useMemo(W,re)},en.useReducer=function(W,re,fe){return U.current.useReducer(W,re,fe)},en.useRef=function(W){return U.current.useRef(W)},en.useState=function(W){return U.current.useState(W)},en.useSyncExternalStore=function(W,re,fe){return U.current.useSyncExternalStore(W,re,fe)},en.useTransition=function(){return U.current.useTransition()},en.version="18.3.1",en}var C0;function Kk(){return C0||(C0=1,Lm.exports=tA()),Lm.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 A0;function nA(){if(A0)return Bc;A0=1;var e=Kk(),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(c,u,h){var f,m={},g=null,y=null;h!==void 0&&(g=""+h),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(y=u.ref);for(f in u)r.call(u,f)&&!s.hasOwnProperty(f)&&(m[f]=u[f]);if(c&&c.defaultProps)for(f in u=c.defaultProps,u)m[f]===void 0&&(m[f]=u[f]);return{$$typeof:t,type:c,key:g,ref:y,props:m,_owner:o.current}}return Bc.Fragment=n,Bc.jsx=a,Bc.jsxs=a,Bc}var I0;function rA(){return I0||(I0=1,Mm.exports=nA()),Mm.exports}var d=rA(),S=Kk();const oA=xE(S);var Pm={exports:{}},oo={},Dm={exports:{}},zm={};/**
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 R0;function sA(){return R0||(R0=1,(function(e){function t($,q){var V=$.length;$.push(q);e:for(;0<V;){var W=V-1>>>1,re=$[W];if(0<o(re,q))$[W]=q,$[V]=re,V=W;else break e}}function n($){return $.length===0?null:$[0]}function r($){if($.length===0)return null;var q=$[0],V=$.pop();if(V!==q){$[0]=V;e:for(var W=0,re=$.length,fe=re>>>1;W<fe;){var pe=2*(W+1)-1,Te=$[pe],je=pe+1,de=$[je];if(0>o(Te,V))je<re&&0>o(de,Te)?($[W]=de,$[je]=V,W=je):($[W]=Te,$[pe]=V,W=pe);else if(je<re&&0>o(de,V))$[W]=de,$[je]=V,W=je;else break e}}return q}function o($,q){var V=$.sortIndex-q.sortIndex;return V!==0?V:$.id-q.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var a=Date,c=a.now();e.unstable_now=function(){return a.now()-c}}var u=[],h=[],f=1,m=null,g=3,y=!1,w=!1,v=!1,_=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,N=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($){for(var q=n(h);q!==null;){if(q.callback===null)r(h);else if(q.startTime<=$)r(h),q.sortIndex=q.expirationTime,t(u,q);else break;q=n(h)}}function j($){if(v=!1,T($),!w)if(n(u)!==null)w=!0,le(C);else{var q=n(h);q!==null&&U(j,q.startTime-$)}}function C($,q){w=!1,v&&(v=!1,x(M),M=-1),y=!0;var V=g;try{for(T(q),m=n(u);m!==null&&(!(m.expirationTime>q)||$&&!B());){var W=m.callback;if(typeof W=="function"){m.callback=null,g=m.priorityLevel;var re=W(m.expirationTime<=q);q=e.unstable_now(),typeof re=="function"?m.callback=re:m===n(u)&&r(u),T(q)}else r(u);m=n(u)}if(m!==null)var fe=!0;else{var pe=n(h);pe!==null&&U(j,pe.startTime-q),fe=!1}return fe}finally{m=null,g=V,y=!1}}var I=!1,A=null,M=-1,O=5,z=-1;function B(){return!(e.unstable_now()-z<O)}function H(){if(A!==null){var $=e.unstable_now();z=$;var q=!0;try{q=A(!0,$)}finally{q?Y():(I=!1,A=null)}}else I=!1}var Y;if(typeof N=="function")Y=function(){N(H)};else if(typeof MessageChannel<"u"){var ie=new MessageChannel,Q=ie.port2;ie.port1.onmessage=H,Y=function(){Q.postMessage(null)}}else Y=function(){_(H,0)};function le($){A=$,I||(I=!0,Y())}function U($,q){M=_(function(){$(e.unstable_now())},q)}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($){$.callback=null},e.unstable_continueExecution=function(){w||y||(w=!0,le(C))},e.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<$?Math.floor(1e3/$):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function($){switch(g){case 1:case 2:case 3:var q=3;break;default:q=g}var V=g;g=q;try{return $()}finally{g=V}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function($,q){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var V=g;g=$;try{return q()}finally{g=V}},e.unstable_scheduleCallback=function($,q,V){var W=e.unstable_now();switch(typeof V=="object"&&V!==null?(V=V.delay,V=typeof V=="number"&&0<V?W+V:W):V=W,$){case 1:var re=-1;break;case 2:re=250;break;case 5:re=1073741823;break;case 4:re=1e4;break;default:re=5e3}return re=V+re,$={id:f++,callback:q,priorityLevel:$,startTime:V,expirationTime:re,sortIndex:-1},V>W?($.sortIndex=V,t(h,$),n(u)===null&&$===n(h)&&(v?(x(M),M=-1):v=!0,U(j,V-W))):($.sortIndex=re,t(u,$),w||y||(w=!0,le(C))),$},e.unstable_shouldYield=B,e.unstable_wrapCallback=function($){var q=g;return function(){var V=g;g=q;try{return $.apply(this,arguments)}finally{g=V}}}})(zm)),zm}var O0;function iA(){return O0||(O0=1,Dm.exports=sA()),Dm.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 M0;function aA(){if(M0)return oo;M0=1;var e=Kk(),t=iA();function n(i){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+i,p=1;p<arguments.length;p++)l+="&args[]="+encodeURIComponent(arguments[p]);return"Minified React error #"+i+"; visit "+l+" 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,l){a(i,l),a(i+"Capture",l)}function a(i,l){for(o[i]=l,i=0;i<l.length;i++)r.add(l[i])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,h=/^[: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]*$/,f={},m={};function g(i){return u.call(m,i)?!0:u.call(f,i)?!1:h.test(i)?m[i]=!0:(f[i]=!0,!1)}function y(i,l,p,k){if(p!==null&&p.type===0)return!1;switch(typeof l){case"function":case"symbol":return!0;case"boolean":return k?!1:p!==null?!p.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function w(i,l,p,k){if(l===null||typeof l>"u"||y(i,l,p,k))return!0;if(k)return!1;if(p!==null)switch(p.type){case 3:return!l;case 4:return l===!1;case 5:return isNaN(l);case 6:return isNaN(l)||1>l}return!1}function v(i,l,p,k,b,E,R){this.acceptsBooleans=l===2||l===3||l===4,this.attributeName=k,this.attributeNamespace=b,this.mustUseProperty=p,this.propertyName=i,this.type=l,this.sanitizeURL=E,this.removeEmptyString=R}var _={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){_[i]=new v(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var l=i[0];_[l]=new v(l,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){_[i]=new v(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){_[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){_[i]=new v(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){_[i]=new v(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){_[i]=new v(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){_[i]=new v(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){_[i]=new v(i,5,!1,i.toLowerCase(),null,!1,!1)});var x=/[\-:]([a-z])/g;function N(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 l=i.replace(x,N);_[l]=new v(l,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var l=i.replace(x,N);_[l]=new v(l,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var l=i.replace(x,N);_[l]=new v(l,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){_[i]=new v(i,1,!1,i.toLowerCase(),null,!1,!1)}),_.xlinkHref=new v("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){_[i]=new v(i,1,!1,i.toLowerCase(),null,!0,!0)});function T(i,l,p,k){var b=_.hasOwnProperty(l)?_[l]:null;(b!==null?b.type!==0:k||!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(w(l,p,b,k)&&(p=null),k||b===null?g(l)&&(p===null?i.removeAttribute(l):i.setAttribute(l,""+p)):b.mustUseProperty?i[b.propertyName]=p===null?b.type===3?!1:"":p:(l=b.attributeName,k=b.attributeNamespace,p===null?i.removeAttribute(l):(b=b.type,p=b===3||b===4&&p===!0?"":""+p,k?i.setAttributeNS(k,l,p):i.setAttribute(l,p))))}var j=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,C=Symbol.for("react.element"),I=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),O=Symbol.for("react.profiler"),z=Symbol.for("react.provider"),B=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),Y=Symbol.for("react.suspense"),ie=Symbol.for("react.suspense_list"),Q=Symbol.for("react.memo"),le=Symbol.for("react.lazy"),U=Symbol.for("react.offscreen"),$=Symbol.iterator;function q(i){return i===null||typeof i!="object"?null:(i=$&&i[$]||i["@@iterator"],typeof i=="function"?i:null)}var V=Object.assign,W;function re(i){if(W===void 0)try{throw Error()}catch(p){var l=p.stack.trim().match(/\n( *(at )?)/);W=l&&l[1]||""}return`
35
- `+W+i}var fe=!1;function pe(i,l){if(!i||fe)return"";fe=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(l)if(l=function(){throw Error()},Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch(ye){var k=ye}Reflect.construct(i,[],l)}else{try{l.call()}catch(ye){k=ye}i.call(l.prototype)}else{try{throw Error()}catch(ye){k=ye}i()}}catch(ye){if(ye&&k&&typeof ye.stack=="string"){for(var b=ye.stack.split(`
36
- `),E=k.stack.split(`
37
- `),R=b.length-1,G=E.length-1;1<=R&&0<=G&&b[R]!==E[G];)G--;for(;1<=R&&0<=G;R--,G--)if(b[R]!==E[G]){if(R!==1||G!==1)do if(R--,G--,0>G||b[R]!==E[G]){var ee=`
38
- `+b[R].replace(" at new "," at ");return i.displayName&&ee.includes("<anonymous>")&&(ee=ee.replace("<anonymous>",i.displayName)),ee}while(1<=R&&0<=G);break}}}finally{fe=!1,Error.prepareStackTrace=p}return(i=i?i.displayName||i.name:"")?re(i):""}function Te(i){switch(i.tag){case 5:return re(i.type);case 16:return re("Lazy");case 13:return re("Suspense");case 19:return re("SuspenseList");case 0:case 2:case 15:return i=pe(i.type,!1),i;case 11:return i=pe(i.type.render,!1),i;case 1:return i=pe(i.type,!0),i;default:return""}}function je(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 I:return"Portal";case O:return"Profiler";case M:return"StrictMode";case Y:return"Suspense";case ie:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case B:return(i.displayName||"Context")+".Consumer";case z:return(i._context.displayName||"Context")+".Provider";case H:var l=i.render;return i=i.displayName,i||(i=l.displayName||l.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case Q:return l=i.displayName||null,l!==null?l:je(i.type)||"Memo";case le:l=i._payload,i=i._init;try{return je(i(l))}catch{}}return null}function de(i){var l=i.type;switch(i.tag){case 24:return"Cache";case 9:return(l.displayName||"Context")+".Consumer";case 10:return(l._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return i=l.render,i=i.displayName||i.name||"",l.displayName||(i!==""?"ForwardRef("+i+")":"ForwardRef");case 7:return"Fragment";case 5:return l;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return je(l);case 8:return l===M?"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 l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l}return null}function J(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function te(i){var l=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function ve(i){var l=te(i)?"checked":"value",p=Object.getOwnPropertyDescriptor(i.constructor.prototype,l),k=""+i[l];if(!i.hasOwnProperty(l)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var b=p.get,E=p.set;return Object.defineProperty(i,l,{configurable:!0,get:function(){return b.call(this)},set:function(R){k=""+R,E.call(this,R)}}),Object.defineProperty(i,l,{enumerable:p.enumerable}),{getValue:function(){return k},setValue:function(R){k=""+R},stopTracking:function(){i._valueTracker=null,delete i[l]}}}}function ce(i){i._valueTracker||(i._valueTracker=ve(i))}function ae(i){if(!i)return!1;var l=i._valueTracker;if(!l)return!0;var p=l.getValue(),k="";return i&&(k=te(i)?i.checked?"true":"false":i.value),i=k,i!==p?(l.setValue(i),!0):!1}function xe(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 Re(i,l){var p=l.checked;return V({},l,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??i._wrapperState.initialChecked})}function ge(i,l){var p=l.defaultValue==null?"":l.defaultValue,k=l.checked!=null?l.checked:l.defaultChecked;p=J(l.value!=null?l.value:p),i._wrapperState={initialChecked:k,initialValue:p,controlled:l.type==="checkbox"||l.type==="radio"?l.checked!=null:l.value!=null}}function Ee(i,l){l=l.checked,l!=null&&T(i,"checked",l,!1)}function We(i,l){Ee(i,l);var p=J(l.value),k=l.type;if(p!=null)k==="number"?(p===0&&i.value===""||i.value!=p)&&(i.value=""+p):i.value!==""+p&&(i.value=""+p);else if(k==="submit"||k==="reset"){i.removeAttribute("value");return}l.hasOwnProperty("value")?ln(i,l.type,p):l.hasOwnProperty("defaultValue")&&ln(i,l.type,J(l.defaultValue)),l.checked==null&&l.defaultChecked!=null&&(i.defaultChecked=!!l.defaultChecked)}function Ye(i,l,p){if(l.hasOwnProperty("value")||l.hasOwnProperty("defaultValue")){var k=l.type;if(!(k!=="submit"&&k!=="reset"||l.value!==void 0&&l.value!==null))return;l=""+i._wrapperState.initialValue,p||l===i.value||(i.value=l),i.defaultValue=l}p=i.name,p!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,p!==""&&(i.name=p)}function ln(i,l,p){(l!=="number"||xe(i.ownerDocument)!==i)&&(p==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+p&&(i.defaultValue=""+p))}var cn=Array.isArray;function gt(i,l,p,k){if(i=i.options,l){l={};for(var b=0;b<p.length;b++)l["$"+p[b]]=!0;for(p=0;p<i.length;p++)b=l.hasOwnProperty("$"+i[p].value),i[p].selected!==b&&(i[p].selected=b),b&&k&&(i[p].defaultSelected=!0)}else{for(p=""+J(p),l=null,b=0;b<i.length;b++){if(i[b].value===p){i[b].selected=!0,k&&(i[b].defaultSelected=!0);return}l!==null||i[b].disabled||(l=i[b])}l!==null&&(l.selected=!0)}}function Ue(i,l){if(l.dangerouslySetInnerHTML!=null)throw Error(n(91));return V({},l,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function zt(i,l){var p=l.value;if(p==null){if(p=l.children,l=l.defaultValue,p!=null){if(l!=null)throw Error(n(92));if(cn(p)){if(1<p.length)throw Error(n(93));p=p[0]}l=p}l==null&&(l=""),p=l}i._wrapperState={initialValue:J(p)}}function pt(i,l){var p=J(l.value),k=J(l.defaultValue);p!=null&&(p=""+p,p!==i.value&&(i.value=p),l.defaultValue==null&&i.defaultValue!==p&&(i.defaultValue=p)),k!=null&&(i.defaultValue=""+k)}function At(i){var l=i.textContent;l===i._wrapperState.initialValue&&l!==""&&l!==null&&(i.value=l)}function Kt(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 xt(i,l){return i==null||i==="http://www.w3.org/1999/xhtml"?Kt(l):i==="http://www.w3.org/2000/svg"&&l==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var un,Ct=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(l,p,k,b){MSApp.execUnsafeLocalFunction(function(){return i(l,p,k,b)})}:i})(function(i,l){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=l;else{for(un=un||document.createElement("div"),un.innerHTML="<svg>"+l.valueOf().toString()+"</svg>",l=un.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;l.firstChild;)i.appendChild(l.firstChild)}});function Ut(i,l){if(l){var p=i.firstChild;if(p&&p===i.lastChild&&p.nodeType===3){p.nodeValue=l;return}}i.textContent=l}var Et={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},er=["Webkit","ms","Moz","O"];Object.keys(Et).forEach(function(i){er.forEach(function(l){l=l+i.charAt(0).toUpperCase()+i.substring(1),Et[l]=Et[i]})});function Qt(i,l,p){return l==null||typeof l=="boolean"||l===""?"":p||typeof l!="number"||l===0||Et.hasOwnProperty(i)&&Et[i]?(""+l).trim():l+"px"}function Nn(i,l){i=i.style;for(var p in l)if(l.hasOwnProperty(p)){var k=p.indexOf("--")===0,b=Qt(p,l[p],k);p==="float"&&(p="cssFloat"),k?i.setProperty(p,b):i[p]=b}}var Zn=V({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 nn(i,l){if(l){if(Zn[i]&&(l.children!=null||l.dangerouslySetInnerHTML!=null))throw Error(n(137,i));if(l.dangerouslySetInnerHTML!=null){if(l.children!=null)throw Error(n(60));if(typeof l.dangerouslySetInnerHTML!="object"||!("__html"in l.dangerouslySetInnerHTML))throw Error(n(61))}if(l.style!=null&&typeof l.style!="object")throw Error(n(62))}}function X(i,l){if(i.indexOf("-")===-1)return typeof l.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 be=null;function Ve(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Qe=null,Ht=null,St=null;function bn(i){if(i=Nc(i)){if(typeof Qe!="function")throw Error(n(280));var l=i.stateNode;l&&(l=wd(l),Qe(i.stateNode,i.type,l))}}function P(i){Ht?St?St.push(i):St=[i]:Ht=i}function ne(){if(Ht){var i=Ht,l=St;if(St=Ht=null,bn(i),l)for(i=0;i<l.length;i++)bn(l[i])}}function Se(i,l){return i(l)}function Ge(){}var It=!1;function Pt(i,l,p){if(It)return i(l,p);It=!0;try{return Se(i,l,p)}finally{It=!1,(Ht!==null||St!==null)&&(Ge(),ne())}}function De(i,l){var p=i.stateNode;if(p===null)return null;var k=wd(p);if(k===null)return null;p=k[l];e:switch(l){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(p&&typeof p!="function")throw Error(n(231,l,typeof p));return p}var ze=!1;if(c)try{var Ke={};Object.defineProperty(Ke,"passive",{get:function(){ze=!0}}),window.addEventListener("test",Ke,Ke),window.removeEventListener("test",Ke,Ke)}catch{ze=!1}function Vt(i,l,p,k,b,E,R,G,ee){var ye=Array.prototype.slice.call(arguments,3);try{l.apply(p,ye)}catch(Ie){this.onError(Ie)}}var Yt=!1,yn=null,_t=!1,gn=null,xn={onError:function(i){Yt=!0,yn=i}};function Rt(i,l,p,k,b,E,R,G,ee){Yt=!1,yn=null,Vt.apply(xn,arguments)}function Mn(i,l,p,k,b,E,R,G,ee){if(Rt.apply(this,arguments),Yt){if(Yt){var ye=yn;Yt=!1,yn=null}else throw Error(n(198));_t||(_t=!0,gn=ye)}}function rn(i){var l=i,p=i;if(i.alternate)for(;l.return;)l=l.return;else{i=l;do l=i,(l.flags&4098)!==0&&(p=l.return),i=l.return;while(i)}return l.tag===3?p:null}function cr(i){if(i.tag===13){var l=i.memoizedState;if(l===null&&(i=i.alternate,i!==null&&(l=i.memoizedState)),l!==null)return l.dehydrated}return null}function se(i){if(rn(i)!==i)throw Error(n(188))}function Ne(i){var l=i.alternate;if(!l){if(l=rn(i),l===null)throw Error(n(188));return l!==i?null:i}for(var p=i,k=l;;){var b=p.return;if(b===null)break;var E=b.alternate;if(E===null){if(k=b.return,k!==null){p=k;continue}break}if(b.child===E.child){for(E=b.child;E;){if(E===p)return se(b),i;if(E===k)return se(b),l;E=E.sibling}throw Error(n(188))}if(p.return!==k.return)p=b,k=E;else{for(var R=!1,G=b.child;G;){if(G===p){R=!0,p=b,k=E;break}if(G===k){R=!0,k=b,p=E;break}G=G.sibling}if(!R){for(G=E.child;G;){if(G===p){R=!0,p=E,k=b;break}if(G===k){R=!0,k=E,p=b;break}G=G.sibling}if(!R)throw Error(n(189))}}if(p.alternate!==k)throw Error(n(190))}if(p.tag!==3)throw Error(n(188));return p.stateNode.current===p?i:l}function rt(i){return i=Ne(i),i!==null?yt(i):null}function yt(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var l=yt(i);if(l!==null)return l;i=i.sibling}return null}var jt=t.unstable_scheduleCallback,Ln=t.unstable_cancelCallback,Or=t.unstable_shouldYield,Gn=t.unstable_requestPaint,Xt=t.unstable_now,Qr=t.unstable_getCurrentPriorityLevel,ft=t.unstable_ImmediatePriority,Un=t.unstable_UserBlockingPriority,ot=t.unstable_NormalPriority,$e=t.unstable_LowPriority,qe=t.unstable_IdlePriority,kt=null,ut=null;function fn(i){if(ut&&typeof ut.onCommitFiberRoot=="function")try{ut.onCommitFiberRoot(kt,i,void 0,(i.current.flags&128)===128)}catch{}}var Wt=Math.clz32?Math.clz32:An,sn=Math.log,tr=Math.LN2;function An(i){return i>>>=0,i===0?32:31-(sn(i)/tr|0)|0}var Pn=64,br=4194304;function Z(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 we(i,l){var p=i.pendingLanes;if(p===0)return 0;var k=0,b=i.suspendedLanes,E=i.pingedLanes,R=p&268435455;if(R!==0){var G=R&~b;G!==0?k=Z(G):(E&=R,E!==0&&(k=Z(E)))}else R=p&~b,R!==0?k=Z(R):E!==0&&(k=Z(E));if(k===0)return 0;if(l!==0&&l!==k&&(l&b)===0&&(b=k&-k,E=l&-l,b>=E||b===16&&(E&4194240)!==0))return l;if((k&4)!==0&&(k|=p&16),l=i.entangledLanes,l!==0)for(i=i.entanglements,l&=k;0<l;)p=31-Wt(l),b=1<<p,k|=i[p],l&=~b;return k}function Ze(i,l){switch(i){case 1:case 2:case 4:return l+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 l+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 qt(i,l){for(var p=i.suspendedLanes,k=i.pingedLanes,b=i.expirationTimes,E=i.pendingLanes;0<E;){var R=31-Wt(E),G=1<<R,ee=b[R];ee===-1?((G&p)===0||(G&k)!==0)&&(b[R]=Ze(G,l)):ee<=l&&(i.expiredLanes|=G),E&=~G}}function wt(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function dn(){var i=Pn;return Pn<<=1,(Pn&4194240)===0&&(Pn=64),i}function ir(i){for(var l=[],p=0;31>p;p++)l.push(i);return l}function mr(i,l,p){i.pendingLanes|=l,l!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,l=31-Wt(l),i[l]=p}function ar(i,l){var p=i.pendingLanes&~l;i.pendingLanes=l,i.suspendedLanes=0,i.pingedLanes=0,i.expiredLanes&=l,i.mutableReadLanes&=l,i.entangledLanes&=l,l=i.entanglements;var k=i.eventTimes;for(i=i.expirationTimes;0<p;){var b=31-Wt(p),E=1<<b;l[b]=0,k[b]=-1,i[b]=-1,p&=~E}}function po(i,l){var p=i.entangledLanes|=l;for(i=i.entanglements;p;){var k=31-Wt(p),b=1<<k;b&l|i[k]&l&&(i[k]|=l),p&=~b}}var Zt=0;function Nt(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var jo,Tn,Jt,qr,Mr,Ce=!1,F=[],K=null,ue=null,ke=null,Le=new Map,He=new Map,Ot=[],hn="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 nr(i,l){switch(i){case"focusin":case"focusout":K=null;break;case"dragenter":case"dragleave":ue=null;break;case"mouseover":case"mouseout":ke=null;break;case"pointerover":case"pointerout":Le.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":He.delete(l.pointerId)}}function kn(i,l,p,k,b,E){return i===null||i.nativeEvent!==E?(i={blockedOn:l,domEventName:p,eventSystemFlags:k,nativeEvent:E,targetContainers:[b]},l!==null&&(l=Nc(l),l!==null&&Tn(l)),i):(i.eventSystemFlags|=k,l=i.targetContainers,b!==null&&l.indexOf(b)===-1&&l.push(b),i)}function Us(i,l,p,k,b){switch(l){case"focusin":return K=kn(K,i,l,p,k,b),!0;case"dragenter":return ue=kn(ue,i,l,p,k,b),!0;case"mouseover":return ke=kn(ke,i,l,p,k,b),!0;case"pointerover":var E=b.pointerId;return Le.set(E,kn(Le.get(E)||null,i,l,p,k,b)),!0;case"gotpointercapture":return E=b.pointerId,He.set(E,kn(He.get(E)||null,i,l,p,k,b)),!0}return!1}function rr(i){var l=Gi(i.target);if(l!==null){var p=rn(l);if(p!==null){if(l=p.tag,l===13){if(l=cr(p),l!==null){i.blockedOn=l,Mr(i.priority,function(){Jt(p)});return}}else if(l===3&&p.stateNode.current.memoizedState.isDehydrated){i.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Di(i){if(i.blockedOn!==null)return!1;for(var l=i.targetContainers;0<l.length;){var p=Pa(i.domEventName,i.eventSystemFlags,l[0],i.nativeEvent);if(p===null){p=i.nativeEvent;var k=new p.constructor(p.type,p);be=k,p.target.dispatchEvent(k),be=null}else return l=Nc(p),l!==null&&Tn(l),i.blockedOn=p,!1;l.shift()}return!0}function nc(i,l,p){Di(i)&&p.delete(l)}function mp(){Ce=!1,K!==null&&Di(K)&&(K=null),ue!==null&&Di(ue)&&(ue=null),ke!==null&&Di(ke)&&(ke=null),Le.forEach(nc),He.forEach(nc)}function zi(i,l){i.blockedOn===l&&(i.blockedOn=null,Ce||(Ce=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,mp)))}function Fi(i){function l(b){return zi(b,i)}if(0<F.length){zi(F[0],i);for(var p=1;p<F.length;p++){var k=F[p];k.blockedOn===i&&(k.blockedOn=null)}}for(K!==null&&zi(K,i),ue!==null&&zi(ue,i),ke!==null&&zi(ke,i),Le.forEach(l),He.forEach(l),p=0;p<Ot.length;p++)k=Ot[p],k.blockedOn===i&&(k.blockedOn=null);for(;0<Ot.length&&(p=Ot[0],p.blockedOn===null);)rr(p),p.blockedOn===null&&Ot.shift()}var Ho=j.ReactCurrentBatchConfig,$o=!0;function La(i,l,p,k){var b=Zt,E=Ho.transition;Ho.transition=null;try{Zt=1,Hs(i,l,p,k)}finally{Zt=b,Ho.transition=E}}function Xu(i,l,p,k){var b=Zt,E=Ho.transition;Ho.transition=null;try{Zt=4,Hs(i,l,p,k)}finally{Zt=b,Ho.transition=E}}function Hs(i,l,p,k){if($o){var b=Pa(i,l,p,k);if(b===null)_p(i,l,k,ws,p),nr(i,k);else if(Us(b,i,l,p,k))k.stopPropagation();else if(nr(i,k),l&4&&-1<hn.indexOf(i)){for(;b!==null;){var E=Nc(b);if(E!==null&&jo(E),E=Pa(i,l,p,k),E===null&&_p(i,l,k,ws,p),E===b)break;b=E}b!==null&&k.stopPropagation()}else _p(i,l,k,null,p)}}var ws=null;function Pa(i,l,p,k){if(ws=null,i=Ve(k),i=Gi(i),i!==null)if(l=rn(i),l===null)i=null;else if(p=l.tag,p===13){if(i=cr(l),i!==null)return i;i=null}else if(p===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;i=null}else l!==i&&(i=null);return ws=i,null}function Bi(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(Qr()){case ft:return 1;case Un:return 4;case ot:case $e:return 16;case qe:return 536870912;default:return 16}default:return 16}}var Wo=null,Ui=null,gr=null;function Qu(){if(gr)return gr;var i,l=Ui,p=l.length,k,b="value"in Wo?Wo.value:Wo.textContent,E=b.length;for(i=0;i<p&&l[i]===b[i];i++);var R=p-i;for(k=1;k<=R&&l[p-k]===b[E-k];k++);return gr=b.slice(i,1<k?1-k:void 0)}function Da(i){var l=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&l===13&&(i=13)):i=l,i===10&&(i=13),32<=i||i===13?i:0}function za(){return!0}function Fa(){return!1}function $r(i){function l(p,k,b,E,R){this._reactName=p,this._targetInst=b,this.type=k,this.nativeEvent=E,this.target=R,this.currentTarget=null;for(var G in i)i.hasOwnProperty(G)&&(p=i[G],this[G]=p?p(E):E[G]);return this.isDefaultPrevented=(E.defaultPrevented!=null?E.defaultPrevented:E.returnValue===!1)?za:Fa,this.isPropagationStopped=Fa,this}return V(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=za)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=za)},persist:function(){},isPersistent:za}),l}var mo={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Hi=$r(mo),Ws=V({},mo,{view:0,detail:0}),gp=$r(Ws),Wi,rc,Ks,Ba=V({},Ws,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:qs,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!==Ks&&(Ks&&i.type==="mousemove"?(Wi=i.screenX-Ks.screenX,rc=i.screenY-Ks.screenY):rc=Wi=0,Ks=i),Wi)},movementY:function(i){return"movementY"in i?i.movementY:rc}}),oc=$r(Ba),kp=V({},Ba,{dataTransfer:0}),Ju=$r(kp),Lr=V({},Ws,{relatedTarget:0}),Ua=$r(Lr),ed=V({},mo,{animationName:0,elapsedTime:0,pseudoElement:0}),Ha=$r(ed),wp=V({},mo,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),sc=$r(wp),ic=V({},mo,{data:0}),Ki=$r(ic),Dn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},td={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"},Wa={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ac(i){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(i):(i=Wa[i])?!!l[i]:!1}function qs(){return ac}var Ka=V({},Ws,{key:function(i){if(i.key){var l=Dn[i.key]||i.key;if(l!=="Unidentified")return l}return i.type==="keypress"?(i=Da(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?td[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:qs,charCode:function(i){return i.type==="keypress"?Da(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Da(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Zs=$r(Ka),nd=V({},Ba,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),qa=$r(nd),lc=V({},Ws,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:qs}),rd=$r(lc),Uy=V({},mo,{propertyName:0,elapsedTime:0,pseudoElement:0}),od=$r(Uy),Za=V({},Ba,{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}),sd=$r(Za),id=[9,13,27,32],Ga=c&&"CompositionEvent"in window,Vn=null;c&&"documentMode"in document&&(Vn=document.documentMode);var Va=c&&"TextEvent"in window&&!Vn,ad=c&&(!Ga||Vn&&8<Vn&&11>=Vn),qi=" ",cc=!1;function Gs(i,l){switch(i){case"keyup":return id.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Vs(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var is=!1;function yp(i,l){switch(i){case"compositionend":return Vs(l);case"keypress":return l.which!==32?null:(cc=!0,qi);case"textInput":return i=l.data,i===qi&&cc?null:i;default:return null}}function uc(i,l){if(is)return i==="compositionend"||!Ga&&Gs(i,l)?(i=Qu(),gr=Ui=Wo=null,is=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return ad&&l.locale!=="ko"?null:l.data;default:return null}}var vp={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 dc(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l==="input"?!!vp[i.type]:l==="textarea"}function fc(i,l,p,k){P(k),l=md(l,"onChange"),0<l.length&&(p=new Hi("onChange","change",null,p,k),i.push({event:p,listeners:l}))}var Ys=null,Xs=null;function Co(i){Ky(i,0)}function Ya(i){var l=ol(i);if(ae(l))return i}function ys(i,l){if(i==="change")return l}var Zi=!1;if(c){var hc;if(c){var Qs="oninput"in document;if(!Qs){var Xa=document.createElement("div");Xa.setAttribute("oninput","return;"),Qs=typeof Xa.oninput=="function"}hc=Qs}else hc=!1;Zi=hc&&(!document.documentMode||9<document.documentMode)}function Qa(){Ys&&(Ys.detachEvent("onpropertychange",pc),Xs=Ys=null)}function pc(i){if(i.propertyName==="value"&&Ya(Xs)){var l=[];fc(l,Xs,i,Ve(i)),Pt(Co,l)}}function bp(i,l,p){i==="focusin"?(Qa(),Ys=l,Xs=p,Ys.attachEvent("onpropertychange",pc)):i==="focusout"&&Qa()}function mc(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Ya(Xs)}function ld(i,l){if(i==="click")return Ya(l)}function cd(i,l){if(i==="input"||i==="change")return Ya(l)}function ud(i,l){return i===l&&(i!==0||1/i===1/l)||i!==i&&l!==l}var go=typeof Object.is=="function"?Object.is:ud;function Js(i,l){if(go(i,l))return!0;if(typeof i!="object"||i===null||typeof l!="object"||l===null)return!1;var p=Object.keys(i),k=Object.keys(l);if(p.length!==k.length)return!1;for(k=0;k<p.length;k++){var b=p[k];if(!u.call(l,b)||!go(i[b],l[b]))return!1}return!0}function gc(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function kc(i,l){var p=gc(i);i=0;for(var k;p;){if(p.nodeType===3){if(k=i+p.textContent.length,i<=l&&k>=l)return{node:p,offset:l-i};i=k}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=gc(p)}}function wc(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?wc(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yc(){for(var i=window,l=xe();l instanceof i.HTMLIFrameElement;){try{var p=typeof l.contentWindow.location.href=="string"}catch{p=!1}if(p)i=l.contentWindow;else break;l=xe(i.document)}return l}function Ja(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}function dd(i){var l=yc(),p=i.focusedElem,k=i.selectionRange;if(l!==p&&p&&p.ownerDocument&&wc(p.ownerDocument.documentElement,p)){if(k!==null&&Ja(p)){if(l=k.start,i=k.end,i===void 0&&(i=l),"selectionStart"in p)p.selectionStart=l,p.selectionEnd=Math.min(i,p.value.length);else if(i=(l=p.ownerDocument||document)&&l.defaultView||window,i.getSelection){i=i.getSelection();var b=p.textContent.length,E=Math.min(k.start,b);k=k.end===void 0?E:Math.min(k.end,b),!i.extend&&E>k&&(b=k,k=E,E=b),b=kc(p,E);var R=kc(p,k);b&&R&&(i.rangeCount!==1||i.anchorNode!==b.node||i.anchorOffset!==b.offset||i.focusNode!==R.node||i.focusOffset!==R.offset)&&(l=l.createRange(),l.setStart(b.node,b.offset),i.removeAllRanges(),E>k?(i.addRange(l),i.extend(R.node,R.offset)):(l.setEnd(R.node,R.offset),i.addRange(l)))}}for(l=[],i=p;i=i.parentNode;)i.nodeType===1&&l.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;p<l.length;p++)i=l[p],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var fd=c&&"documentMode"in document&&11>=document.documentMode,vs=null,el=null,ei=null,tl=!1;function D(i,l,p){var k=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;tl||vs==null||vs!==xe(k)||(k=vs,"selectionStart"in k&&Ja(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}),ei&&Js(ei,k)||(ei=k,k=md(el,"onSelect"),0<k.length&&(l=new Hi("onSelect","select",null,l,p),i.push({event:l,listeners:k}),l.target=vs)))}function Oe(i,l){var p={};return p[i.toLowerCase()]=l.toLowerCase(),p["Webkit"+i]="webkit"+l,p["Moz"+i]="moz"+l,p}var ct={animationend:Oe("Animation","AnimationEnd"),animationiteration:Oe("Animation","AnimationIteration"),animationstart:Oe("Animation","AnimationStart"),transitionend:Oe("Transition","TransitionEnd")},$t={},or={};c&&(or=document.createElement("div").style,"AnimationEvent"in window||(delete ct.animationend.animation,delete ct.animationiteration.animation,delete ct.animationstart.animation),"TransitionEvent"in window||delete ct.transitionend.transition);function Hn(i){if($t[i])return $t[i];if(!ct[i])return i;var l=ct[i],p;for(p in l)if(l.hasOwnProperty(p)&&p in or)return $t[i]=l[p];return i}var ti=Hn("animationend"),vc=Hn("animationiteration"),ko=Hn("animationstart"),hd=Hn("transitionend"),bc=new Map,Hy="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 ni(i,l){bc.set(i,l),s(l,[i])}for(var xp=0;xp<Hy.length;xp++){var Ep=Hy[xp],lC=Ep.toLowerCase(),cC=Ep[0].toUpperCase()+Ep.slice(1);ni(lC,"on"+cC)}ni(ti,"onAnimationEnd"),ni(vc,"onAnimationIteration"),ni(ko,"onAnimationStart"),ni("dblclick","onDoubleClick"),ni("focusin","onFocus"),ni("focusout","onBlur"),ni(hd,"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 xc="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(" "),uC=new Set("cancel close invalid load scroll toggle".split(" ").concat(xc));function Wy(i,l,p){var k=i.type||"unknown-event";i.currentTarget=p,Mn(k,l,void 0,i),i.currentTarget=null}function Ky(i,l){l=(l&4)!==0;for(var p=0;p<i.length;p++){var k=i[p],b=k.event;k=k.listeners;e:{var E=void 0;if(l)for(var R=k.length-1;0<=R;R--){var G=k[R],ee=G.instance,ye=G.currentTarget;if(G=G.listener,ee!==E&&b.isPropagationStopped())break e;Wy(b,G,ye),E=ee}else for(R=0;R<k.length;R++){if(G=k[R],ee=G.instance,ye=G.currentTarget,G=G.listener,ee!==E&&b.isPropagationStopped())break e;Wy(b,G,ye),E=ee}}}if(_t)throw i=gn,_t=!1,gn=null,i}function zn(i,l){var p=l[Ap];p===void 0&&(p=l[Ap]=new Set);var k=i+"__bubble";p.has(k)||(qy(l,i,2,!1),p.add(k))}function Sp(i,l,p){var k=0;l&&(k|=4),qy(p,i,k,l)}var pd="_reactListening"+Math.random().toString(36).slice(2);function Ec(i){if(!i[pd]){i[pd]=!0,r.forEach(function(p){p!=="selectionchange"&&(uC.has(p)||Sp(p,!1,i),Sp(p,!0,i))});var l=i.nodeType===9?i:i.ownerDocument;l===null||l[pd]||(l[pd]=!0,Sp("selectionchange",!1,l))}}function qy(i,l,p,k){switch(Bi(l)){case 1:var b=La;break;case 4:b=Xu;break;default:b=Hs}p=b.bind(null,l,p,i),b=void 0,!ze||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(b=!0),k?b!==void 0?i.addEventListener(l,p,{capture:!0,passive:b}):i.addEventListener(l,p,!0):b!==void 0?i.addEventListener(l,p,{passive:b}):i.addEventListener(l,p,!1)}function _p(i,l,p,k,b){var E=k;if((l&1)===0&&(l&2)===0&&k!==null)e:for(;;){if(k===null)return;var R=k.tag;if(R===3||R===4){var G=k.stateNode.containerInfo;if(G===b||G.nodeType===8&&G.parentNode===b)break;if(R===4)for(R=k.return;R!==null;){var ee=R.tag;if((ee===3||ee===4)&&(ee=R.stateNode.containerInfo,ee===b||ee.nodeType===8&&ee.parentNode===b))return;R=R.return}for(;G!==null;){if(R=Gi(G),R===null)return;if(ee=R.tag,ee===5||ee===6){k=E=R;continue e}G=G.parentNode}}k=k.return}Pt(function(){var ye=E,Ie=Ve(p),Pe=[];e:{var Ae=bc.get(i);if(Ae!==void 0){var Xe=Hi,nt=i;switch(i){case"keypress":if(Da(p)===0)break e;case"keydown":case"keyup":Xe=Zs;break;case"focusin":nt="focus",Xe=Ua;break;case"focusout":nt="blur",Xe=Ua;break;case"beforeblur":case"afterblur":Xe=Ua;break;case"click":if(p.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Xe=oc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Xe=Ju;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Xe=rd;break;case ti:case vc:case ko:Xe=Ha;break;case hd:Xe=od;break;case"scroll":Xe=gp;break;case"wheel":Xe=sd;break;case"copy":case"cut":case"paste":Xe=sc;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Xe=qa}var st=(l&4)!==0,lr=!st&&i==="scroll",he=st?Ae!==null?Ae+"Capture":null:Ae;st=[];for(var oe=ye,me;oe!==null;){me=oe;var Fe=me.stateNode;if(me.tag===5&&Fe!==null&&(me=Fe,he!==null&&(Fe=De(oe,he),Fe!=null&&st.push(Sc(oe,Fe,me)))),lr)break;oe=oe.return}0<st.length&&(Ae=new Xe(Ae,nt,null,p,Ie),Pe.push({event:Ae,listeners:st}))}}if((l&7)===0){e:{if(Ae=i==="mouseover"||i==="pointerover",Xe=i==="mouseout"||i==="pointerout",Ae&&p!==be&&(nt=p.relatedTarget||p.fromElement)&&(Gi(nt)||nt[bs]))break e;if((Xe||Ae)&&(Ae=Ie.window===Ie?Ie:(Ae=Ie.ownerDocument)?Ae.defaultView||Ae.parentWindow:window,Xe?(nt=p.relatedTarget||p.toElement,Xe=ye,nt=nt?Gi(nt):null,nt!==null&&(lr=rn(nt),nt!==lr||nt.tag!==5&&nt.tag!==6)&&(nt=null)):(Xe=null,nt=ye),Xe!==nt)){if(st=oc,Fe="onMouseLeave",he="onMouseEnter",oe="mouse",(i==="pointerout"||i==="pointerover")&&(st=qa,Fe="onPointerLeave",he="onPointerEnter",oe="pointer"),lr=Xe==null?Ae:ol(Xe),me=nt==null?Ae:ol(nt),Ae=new st(Fe,oe+"leave",Xe,p,Ie),Ae.target=lr,Ae.relatedTarget=me,Fe=null,Gi(Ie)===ye&&(st=new st(he,oe+"enter",nt,p,Ie),st.target=me,st.relatedTarget=lr,Fe=st),lr=Fe,Xe&&nt)t:{for(st=Xe,he=nt,oe=0,me=st;me;me=nl(me))oe++;for(me=0,Fe=he;Fe;Fe=nl(Fe))me++;for(;0<oe-me;)st=nl(st),oe--;for(;0<me-oe;)he=nl(he),me--;for(;oe--;){if(st===he||he!==null&&st===he.alternate)break t;st=nl(st),he=nl(he)}st=null}else st=null;Xe!==null&&Zy(Pe,Ae,Xe,st,!1),nt!==null&&lr!==null&&Zy(Pe,lr,nt,st,!0)}}e:{if(Ae=ye?ol(ye):window,Xe=Ae.nodeName&&Ae.nodeName.toLowerCase(),Xe==="select"||Xe==="input"&&Ae.type==="file")var it=ys;else if(dc(Ae))if(Zi)it=cd;else{it=mc;var vt=bp}else(Xe=Ae.nodeName)&&Xe.toLowerCase()==="input"&&(Ae.type==="checkbox"||Ae.type==="radio")&&(it=ld);if(it&&(it=it(i,ye))){fc(Pe,it,p,Ie);break e}vt&&vt(i,Ae,ye),i==="focusout"&&(vt=Ae._wrapperState)&&vt.controlled&&Ae.type==="number"&&ln(Ae,"number",Ae.value)}switch(vt=ye?ol(ye):window,i){case"focusin":(dc(vt)||vt.contentEditable==="true")&&(vs=vt,el=ye,ei=null);break;case"focusout":ei=el=vs=null;break;case"mousedown":tl=!0;break;case"contextmenu":case"mouseup":case"dragend":tl=!1,D(Pe,p,Ie);break;case"selectionchange":if(fd)break;case"keydown":case"keyup":D(Pe,p,Ie)}var bt;if(Ga)e:{switch(i){case"compositionstart":var Dt="onCompositionStart";break e;case"compositionend":Dt="onCompositionEnd";break e;case"compositionupdate":Dt="onCompositionUpdate";break e}Dt=void 0}else is?Gs(i,p)&&(Dt="onCompositionEnd"):i==="keydown"&&p.keyCode===229&&(Dt="onCompositionStart");Dt&&(ad&&p.locale!=="ko"&&(is||Dt!=="onCompositionStart"?Dt==="onCompositionEnd"&&is&&(bt=Qu()):(Wo=Ie,Ui="value"in Wo?Wo.value:Wo.textContent,is=!0)),vt=md(ye,Dt),0<vt.length&&(Dt=new Ki(Dt,i,null,p,Ie),Pe.push({event:Dt,listeners:vt}),bt?Dt.data=bt:(bt=Vs(p),bt!==null&&(Dt.data=bt)))),(bt=Va?yp(i,p):uc(i,p))&&(ye=md(ye,"onBeforeInput"),0<ye.length&&(Ie=new Ki("onBeforeInput","beforeinput",null,p,Ie),Pe.push({event:Ie,listeners:ye}),Ie.data=bt))}Ky(Pe,l)})}function Sc(i,l,p){return{instance:i,listener:l,currentTarget:p}}function md(i,l){for(var p=l+"Capture",k=[];i!==null;){var b=i,E=b.stateNode;b.tag===5&&E!==null&&(b=E,E=De(i,p),E!=null&&k.unshift(Sc(i,E,b)),E=De(i,l),E!=null&&k.push(Sc(i,E,b))),i=i.return}return k}function nl(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function Zy(i,l,p,k,b){for(var E=l._reactName,R=[];p!==null&&p!==k;){var G=p,ee=G.alternate,ye=G.stateNode;if(ee!==null&&ee===k)break;G.tag===5&&ye!==null&&(G=ye,b?(ee=De(p,E),ee!=null&&R.unshift(Sc(p,ee,G))):b||(ee=De(p,E),ee!=null&&R.push(Sc(p,ee,G)))),p=p.return}R.length!==0&&i.push({event:l,listeners:R})}var dC=/\r\n?/g,fC=/\u0000|\uFFFD/g;function Gy(i){return(typeof i=="string"?i:""+i).replace(dC,`
39
- `).replace(fC,"")}function gd(i,l,p){if(l=Gy(l),Gy(i)!==l&&p)throw Error(n(425))}function kd(){}var Np=null,Tp=null;function jp(i,l){return i==="textarea"||i==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var $p=typeof setTimeout=="function"?setTimeout:void 0,hC=typeof clearTimeout=="function"?clearTimeout:void 0,Vy=typeof Promise=="function"?Promise:void 0,pC=typeof queueMicrotask=="function"?queueMicrotask:typeof Vy<"u"?function(i){return Vy.resolve(null).then(i).catch(mC)}:$p;function mC(i){setTimeout(function(){throw i})}function Cp(i,l){var p=l,k=0;do{var b=p.nextSibling;if(i.removeChild(p),b&&b.nodeType===8)if(p=b.data,p==="/$"){if(k===0){i.removeChild(b),Fi(l);return}k--}else p!=="$"&&p!=="$?"&&p!=="$!"||k++;p=b}while(p);Fi(l)}function ri(i){for(;i!=null;i=i.nextSibling){var l=i.nodeType;if(l===1||l===3)break;if(l===8){if(l=i.data,l==="$"||l==="$!"||l==="$?")break;if(l==="/$")return null}}return i}function Yy(i){i=i.previousSibling;for(var l=0;i;){if(i.nodeType===8){var p=i.data;if(p==="$"||p==="$!"||p==="$?"){if(l===0)return i;l--}else p==="/$"&&l++}i=i.previousSibling}return null}var rl=Math.random().toString(36).slice(2),as="__reactFiber$"+rl,_c="__reactProps$"+rl,bs="__reactContainer$"+rl,Ap="__reactEvents$"+rl,gC="__reactListeners$"+rl,kC="__reactHandles$"+rl;function Gi(i){var l=i[as];if(l)return l;for(var p=i.parentNode;p;){if(l=p[bs]||p[as]){if(p=l.alternate,l.child!==null||p!==null&&p.child!==null)for(i=Yy(i);i!==null;){if(p=i[as])return p;i=Yy(i)}return l}i=p,p=i.parentNode}return null}function Nc(i){return i=i[as]||i[bs],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function ol(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function wd(i){return i[_c]||null}var Ip=[],sl=-1;function oi(i){return{current:i}}function Fn(i){0>sl||(i.current=Ip[sl],Ip[sl]=null,sl--)}function In(i,l){sl++,Ip[sl]=i.current,i.current=l}var si={},Pr=oi(si),Jr=oi(!1),Vi=si;function il(i,l){var p=i.type.contextTypes;if(!p)return si;var k=i.stateNode;if(k&&k.__reactInternalMemoizedUnmaskedChildContext===l)return k.__reactInternalMemoizedMaskedChildContext;var b={},E;for(E in p)b[E]=l[E];return k&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=l,i.__reactInternalMemoizedMaskedChildContext=b),b}function eo(i){return i=i.childContextTypes,i!=null}function yd(){Fn(Jr),Fn(Pr)}function Xy(i,l,p){if(Pr.current!==si)throw Error(n(168));In(Pr,l),In(Jr,p)}function Qy(i,l,p){var k=i.stateNode;if(l=l.childContextTypes,typeof k.getChildContext!="function")return p;k=k.getChildContext();for(var b in k)if(!(b in l))throw Error(n(108,de(i)||"Unknown",b));return V({},p,k)}function vd(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||si,Vi=Pr.current,In(Pr,i),In(Jr,Jr.current),!0}function Jy(i,l,p){var k=i.stateNode;if(!k)throw Error(n(169));p?(i=Qy(i,l,Vi),k.__reactInternalMemoizedMergedChildContext=i,Fn(Jr),Fn(Pr),In(Pr,i)):Fn(Jr),In(Jr,p)}var xs=null,bd=!1,Rp=!1;function ev(i){xs===null?xs=[i]:xs.push(i)}function wC(i){bd=!0,ev(i)}function ii(){if(!Rp&&xs!==null){Rp=!0;var i=0,l=Zt;try{var p=xs;for(Zt=1;i<p.length;i++){var k=p[i];do k=k(!0);while(k!==null)}xs=null,bd=!1}catch(b){throw xs!==null&&(xs=xs.slice(i+1)),jt(ft,ii),b}finally{Zt=l,Rp=!1}}return null}var al=[],ll=0,xd=null,Ed=0,Ao=[],Io=0,Yi=null,Es=1,Ss="";function Xi(i,l){al[ll++]=Ed,al[ll++]=xd,xd=i,Ed=l}function tv(i,l,p){Ao[Io++]=Es,Ao[Io++]=Ss,Ao[Io++]=Yi,Yi=i;var k=Es;i=Ss;var b=32-Wt(k)-1;k&=~(1<<b),p+=1;var E=32-Wt(l)+b;if(30<E){var R=b-b%5;E=(k&(1<<R)-1).toString(32),k>>=R,b-=R,Es=1<<32-Wt(l)+b|p<<b|k,Ss=E+i}else Es=1<<E|p<<b|k,Ss=i}function Op(i){i.return!==null&&(Xi(i,1),tv(i,1,0))}function Mp(i){for(;i===xd;)xd=al[--ll],al[ll]=null,Ed=al[--ll],al[ll]=null;for(;i===Yi;)Yi=Ao[--Io],Ao[Io]=null,Ss=Ao[--Io],Ao[Io]=null,Es=Ao[--Io],Ao[Io]=null}var wo=null,yo=null,Wn=!1,Ko=null;function nv(i,l){var p=Lo(5,null,null,0);p.elementType="DELETED",p.stateNode=l,p.return=i,l=i.deletions,l===null?(i.deletions=[p],i.flags|=16):l.push(p)}function rv(i,l){switch(i.tag){case 5:var p=i.type;return l=l.nodeType!==1||p.toLowerCase()!==l.nodeName.toLowerCase()?null:l,l!==null?(i.stateNode=l,wo=i,yo=ri(l.firstChild),!0):!1;case 6:return l=i.pendingProps===""||l.nodeType!==3?null:l,l!==null?(i.stateNode=l,wo=i,yo=null,!0):!1;case 13:return l=l.nodeType!==8?null:l,l!==null?(p=Yi!==null?{id:Es,overflow:Ss}:null,i.memoizedState={dehydrated:l,treeContext:p,retryLane:1073741824},p=Lo(18,null,null,0),p.stateNode=l,p.return=i,i.child=p,wo=i,yo=null,!0):!1;default:return!1}}function Lp(i){return(i.mode&1)!==0&&(i.flags&128)===0}function Pp(i){if(Wn){var l=yo;if(l){var p=l;if(!rv(i,l)){if(Lp(i))throw Error(n(418));l=ri(p.nextSibling);var k=wo;l&&rv(i,l)?nv(k,p):(i.flags=i.flags&-4097|2,Wn=!1,wo=i)}}else{if(Lp(i))throw Error(n(418));i.flags=i.flags&-4097|2,Wn=!1,wo=i}}}function ov(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;wo=i}function Sd(i){if(i!==wo)return!1;if(!Wn)return ov(i),Wn=!0,!1;var l;if((l=i.tag!==3)&&!(l=i.tag!==5)&&(l=i.type,l=l!=="head"&&l!=="body"&&!jp(i.type,i.memoizedProps)),l&&(l=yo)){if(Lp(i))throw sv(),Error(n(418));for(;l;)nv(i,l),l=ri(l.nextSibling)}if(ov(i),i.tag===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));e:{for(i=i.nextSibling,l=0;i;){if(i.nodeType===8){var p=i.data;if(p==="/$"){if(l===0){yo=ri(i.nextSibling);break e}l--}else p!=="$"&&p!=="$!"&&p!=="$?"||l++}i=i.nextSibling}yo=null}}else yo=wo?ri(i.stateNode.nextSibling):null;return!0}function sv(){for(var i=yo;i;)i=ri(i.nextSibling)}function cl(){yo=wo=null,Wn=!1}function Dp(i){Ko===null?Ko=[i]:Ko.push(i)}var yC=j.ReactCurrentBatchConfig;function Tc(i,l,p){if(i=p.ref,i!==null&&typeof i!="function"&&typeof i!="object"){if(p._owner){if(p=p._owner,p){if(p.tag!==1)throw Error(n(309));var k=p.stateNode}if(!k)throw Error(n(147,i));var b=k,E=""+i;return l!==null&&l.ref!==null&&typeof l.ref=="function"&&l.ref._stringRef===E?l.ref:(l=function(R){var G=b.refs;R===null?delete G[E]:G[E]=R},l._stringRef=E,l)}if(typeof i!="string")throw Error(n(284));if(!p._owner)throw Error(n(290,i))}return i}function _d(i,l){throw i=Object.prototype.toString.call(l),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":i))}function iv(i){var l=i._init;return l(i._payload)}function av(i){function l(he,oe){if(i){var me=he.deletions;me===null?(he.deletions=[oe],he.flags|=16):me.push(oe)}}function p(he,oe){if(!i)return null;for(;oe!==null;)l(he,oe),oe=oe.sibling;return null}function k(he,oe){for(he=new Map;oe!==null;)oe.key!==null?he.set(oe.key,oe):he.set(oe.index,oe),oe=oe.sibling;return he}function b(he,oe){return he=pi(he,oe),he.index=0,he.sibling=null,he}function E(he,oe,me){return he.index=me,i?(me=he.alternate,me!==null?(me=me.index,me<oe?(he.flags|=2,oe):me):(he.flags|=2,oe)):(he.flags|=1048576,oe)}function R(he){return i&&he.alternate===null&&(he.flags|=2),he}function G(he,oe,me,Fe){return oe===null||oe.tag!==6?(oe=$m(me,he.mode,Fe),oe.return=he,oe):(oe=b(oe,me),oe.return=he,oe)}function ee(he,oe,me,Fe){var it=me.type;return it===A?Ie(he,oe,me.props.children,Fe,me.key):oe!==null&&(oe.elementType===it||typeof it=="object"&&it!==null&&it.$$typeof===le&&iv(it)===oe.type)?(Fe=b(oe,me.props),Fe.ref=Tc(he,oe,me),Fe.return=he,Fe):(Fe=Vd(me.type,me.key,me.props,null,he.mode,Fe),Fe.ref=Tc(he,oe,me),Fe.return=he,Fe)}function ye(he,oe,me,Fe){return oe===null||oe.tag!==4||oe.stateNode.containerInfo!==me.containerInfo||oe.stateNode.implementation!==me.implementation?(oe=Cm(me,he.mode,Fe),oe.return=he,oe):(oe=b(oe,me.children||[]),oe.return=he,oe)}function Ie(he,oe,me,Fe,it){return oe===null||oe.tag!==7?(oe=sa(me,he.mode,Fe,it),oe.return=he,oe):(oe=b(oe,me),oe.return=he,oe)}function Pe(he,oe,me){if(typeof oe=="string"&&oe!==""||typeof oe=="number")return oe=$m(""+oe,he.mode,me),oe.return=he,oe;if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case C:return me=Vd(oe.type,oe.key,oe.props,null,he.mode,me),me.ref=Tc(he,null,oe),me.return=he,me;case I:return oe=Cm(oe,he.mode,me),oe.return=he,oe;case le:var Fe=oe._init;return Pe(he,Fe(oe._payload),me)}if(cn(oe)||q(oe))return oe=sa(oe,he.mode,me,null),oe.return=he,oe;_d(he,oe)}return null}function Ae(he,oe,me,Fe){var it=oe!==null?oe.key:null;if(typeof me=="string"&&me!==""||typeof me=="number")return it!==null?null:G(he,oe,""+me,Fe);if(typeof me=="object"&&me!==null){switch(me.$$typeof){case C:return me.key===it?ee(he,oe,me,Fe):null;case I:return me.key===it?ye(he,oe,me,Fe):null;case le:return it=me._init,Ae(he,oe,it(me._payload),Fe)}if(cn(me)||q(me))return it!==null?null:Ie(he,oe,me,Fe,null);_d(he,me)}return null}function Xe(he,oe,me,Fe,it){if(typeof Fe=="string"&&Fe!==""||typeof Fe=="number")return he=he.get(me)||null,G(oe,he,""+Fe,it);if(typeof Fe=="object"&&Fe!==null){switch(Fe.$$typeof){case C:return he=he.get(Fe.key===null?me:Fe.key)||null,ee(oe,he,Fe,it);case I:return he=he.get(Fe.key===null?me:Fe.key)||null,ye(oe,he,Fe,it);case le:var vt=Fe._init;return Xe(he,oe,me,vt(Fe._payload),it)}if(cn(Fe)||q(Fe))return he=he.get(me)||null,Ie(oe,he,Fe,it,null);_d(oe,Fe)}return null}function nt(he,oe,me,Fe){for(var it=null,vt=null,bt=oe,Dt=oe=0,Sr=null;bt!==null&&Dt<me.length;Dt++){bt.index>Dt?(Sr=bt,bt=null):Sr=bt.sibling;var wn=Ae(he,bt,me[Dt],Fe);if(wn===null){bt===null&&(bt=Sr);break}i&&bt&&wn.alternate===null&&l(he,bt),oe=E(wn,oe,Dt),vt===null?it=wn:vt.sibling=wn,vt=wn,bt=Sr}if(Dt===me.length)return p(he,bt),Wn&&Xi(he,Dt),it;if(bt===null){for(;Dt<me.length;Dt++)bt=Pe(he,me[Dt],Fe),bt!==null&&(oe=E(bt,oe,Dt),vt===null?it=bt:vt.sibling=bt,vt=bt);return Wn&&Xi(he,Dt),it}for(bt=k(he,bt);Dt<me.length;Dt++)Sr=Xe(bt,he,Dt,me[Dt],Fe),Sr!==null&&(i&&Sr.alternate!==null&&bt.delete(Sr.key===null?Dt:Sr.key),oe=E(Sr,oe,Dt),vt===null?it=Sr:vt.sibling=Sr,vt=Sr);return i&&bt.forEach(function(mi){return l(he,mi)}),Wn&&Xi(he,Dt),it}function st(he,oe,me,Fe){var it=q(me);if(typeof it!="function")throw Error(n(150));if(me=it.call(me),me==null)throw Error(n(151));for(var vt=it=null,bt=oe,Dt=oe=0,Sr=null,wn=me.next();bt!==null&&!wn.done;Dt++,wn=me.next()){bt.index>Dt?(Sr=bt,bt=null):Sr=bt.sibling;var mi=Ae(he,bt,wn.value,Fe);if(mi===null){bt===null&&(bt=Sr);break}i&&bt&&mi.alternate===null&&l(he,bt),oe=E(mi,oe,Dt),vt===null?it=mi:vt.sibling=mi,vt=mi,bt=Sr}if(wn.done)return p(he,bt),Wn&&Xi(he,Dt),it;if(bt===null){for(;!wn.done;Dt++,wn=me.next())wn=Pe(he,wn.value,Fe),wn!==null&&(oe=E(wn,oe,Dt),vt===null?it=wn:vt.sibling=wn,vt=wn);return Wn&&Xi(he,Dt),it}for(bt=k(he,bt);!wn.done;Dt++,wn=me.next())wn=Xe(bt,he,Dt,wn.value,Fe),wn!==null&&(i&&wn.alternate!==null&&bt.delete(wn.key===null?Dt:wn.key),oe=E(wn,oe,Dt),vt===null?it=wn:vt.sibling=wn,vt=wn);return i&&bt.forEach(function(QC){return l(he,QC)}),Wn&&Xi(he,Dt),it}function lr(he,oe,me,Fe){if(typeof me=="object"&&me!==null&&me.type===A&&me.key===null&&(me=me.props.children),typeof me=="object"&&me!==null){switch(me.$$typeof){case C:e:{for(var it=me.key,vt=oe;vt!==null;){if(vt.key===it){if(it=me.type,it===A){if(vt.tag===7){p(he,vt.sibling),oe=b(vt,me.props.children),oe.return=he,he=oe;break e}}else if(vt.elementType===it||typeof it=="object"&&it!==null&&it.$$typeof===le&&iv(it)===vt.type){p(he,vt.sibling),oe=b(vt,me.props),oe.ref=Tc(he,vt,me),oe.return=he,he=oe;break e}p(he,vt);break}else l(he,vt);vt=vt.sibling}me.type===A?(oe=sa(me.props.children,he.mode,Fe,me.key),oe.return=he,he=oe):(Fe=Vd(me.type,me.key,me.props,null,he.mode,Fe),Fe.ref=Tc(he,oe,me),Fe.return=he,he=Fe)}return R(he);case I:e:{for(vt=me.key;oe!==null;){if(oe.key===vt)if(oe.tag===4&&oe.stateNode.containerInfo===me.containerInfo&&oe.stateNode.implementation===me.implementation){p(he,oe.sibling),oe=b(oe,me.children||[]),oe.return=he,he=oe;break e}else{p(he,oe);break}else l(he,oe);oe=oe.sibling}oe=Cm(me,he.mode,Fe),oe.return=he,he=oe}return R(he);case le:return vt=me._init,lr(he,oe,vt(me._payload),Fe)}if(cn(me))return nt(he,oe,me,Fe);if(q(me))return st(he,oe,me,Fe);_d(he,me)}return typeof me=="string"&&me!==""||typeof me=="number"?(me=""+me,oe!==null&&oe.tag===6?(p(he,oe.sibling),oe=b(oe,me),oe.return=he,he=oe):(p(he,oe),oe=$m(me,he.mode,Fe),oe.return=he,he=oe),R(he)):p(he,oe)}return lr}var ul=av(!0),lv=av(!1),Nd=oi(null),Td=null,dl=null,zp=null;function Fp(){zp=dl=Td=null}function Bp(i){var l=Nd.current;Fn(Nd),i._currentValue=l}function Up(i,l,p){for(;i!==null;){var k=i.alternate;if((i.childLanes&l)!==l?(i.childLanes|=l,k!==null&&(k.childLanes|=l)):k!==null&&(k.childLanes&l)!==l&&(k.childLanes|=l),i===p)break;i=i.return}}function fl(i,l){Td=i,zp=dl=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&l)!==0&&(to=!0),i.firstContext=null)}function Ro(i){var l=i._currentValue;if(zp!==i)if(i={context:i,memoizedValue:l,next:null},dl===null){if(Td===null)throw Error(n(308));dl=i,Td.dependencies={lanes:0,firstContext:i}}else dl=dl.next=i;return l}var Qi=null;function Hp(i){Qi===null?Qi=[i]:Qi.push(i)}function cv(i,l,p,k){var b=l.interleaved;return b===null?(p.next=p,Hp(l)):(p.next=b.next,b.next=p),l.interleaved=p,_s(i,k)}function _s(i,l){i.lanes|=l;var p=i.alternate;for(p!==null&&(p.lanes|=l),p=i,i=i.return;i!==null;)i.childLanes|=l,p=i.alternate,p!==null&&(p.childLanes|=l),p=i,i=i.return;return p.tag===3?p.stateNode:null}var ai=!1;function Wp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function uv(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,effects:i.effects})}function Ns(i,l){return{eventTime:i,lane:l,tag:0,payload:null,callback:null,next:null}}function li(i,l,p){var k=i.updateQueue;if(k===null)return null;if(k=k.shared,(pn&2)!==0){var b=k.pending;return b===null?l.next=l:(l.next=b.next,b.next=l),k.pending=l,_s(i,p)}return b=k.interleaved,b===null?(l.next=l,Hp(k)):(l.next=b.next,b.next=l),k.interleaved=l,_s(i,p)}function jd(i,l,p){if(l=l.updateQueue,l!==null&&(l=l.shared,(p&4194240)!==0)){var k=l.lanes;k&=i.pendingLanes,p|=k,l.lanes=p,po(i,p)}}function dv(i,l){var p=i.updateQueue,k=i.alternate;if(k!==null&&(k=k.updateQueue,p===k)){var b=null,E=null;if(p=p.firstBaseUpdate,p!==null){do{var R={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};E===null?b=E=R:E=E.next=R,p=p.next}while(p!==null);E===null?b=E=l:E=E.next=l}else b=E=l;p={baseState:k.baseState,firstBaseUpdate:b,lastBaseUpdate:E,shared:k.shared,effects:k.effects},i.updateQueue=p;return}i=p.lastBaseUpdate,i===null?p.firstBaseUpdate=l:i.next=l,p.lastBaseUpdate=l}function $d(i,l,p,k){var b=i.updateQueue;ai=!1;var E=b.firstBaseUpdate,R=b.lastBaseUpdate,G=b.shared.pending;if(G!==null){b.shared.pending=null;var ee=G,ye=ee.next;ee.next=null,R===null?E=ye:R.next=ye,R=ee;var Ie=i.alternate;Ie!==null&&(Ie=Ie.updateQueue,G=Ie.lastBaseUpdate,G!==R&&(G===null?Ie.firstBaseUpdate=ye:G.next=ye,Ie.lastBaseUpdate=ee))}if(E!==null){var Pe=b.baseState;R=0,Ie=ye=ee=null,G=E;do{var Ae=G.lane,Xe=G.eventTime;if((k&Ae)===Ae){Ie!==null&&(Ie=Ie.next={eventTime:Xe,lane:0,tag:G.tag,payload:G.payload,callback:G.callback,next:null});e:{var nt=i,st=G;switch(Ae=l,Xe=p,st.tag){case 1:if(nt=st.payload,typeof nt=="function"){Pe=nt.call(Xe,Pe,Ae);break e}Pe=nt;break e;case 3:nt.flags=nt.flags&-65537|128;case 0:if(nt=st.payload,Ae=typeof nt=="function"?nt.call(Xe,Pe,Ae):nt,Ae==null)break e;Pe=V({},Pe,Ae);break e;case 2:ai=!0}}G.callback!==null&&G.lane!==0&&(i.flags|=64,Ae=b.effects,Ae===null?b.effects=[G]:Ae.push(G))}else Xe={eventTime:Xe,lane:Ae,tag:G.tag,payload:G.payload,callback:G.callback,next:null},Ie===null?(ye=Ie=Xe,ee=Pe):Ie=Ie.next=Xe,R|=Ae;if(G=G.next,G===null){if(G=b.shared.pending,G===null)break;Ae=G,G=Ae.next,Ae.next=null,b.lastBaseUpdate=Ae,b.shared.pending=null}}while(!0);if(Ie===null&&(ee=Pe),b.baseState=ee,b.firstBaseUpdate=ye,b.lastBaseUpdate=Ie,l=b.shared.interleaved,l!==null){b=l;do R|=b.lane,b=b.next;while(b!==l)}else E===null&&(b.shared.lanes=0);ta|=R,i.lanes=R,i.memoizedState=Pe}}function fv(i,l,p){if(i=l.effects,l.effects=null,i!==null)for(l=0;l<i.length;l++){var k=i[l],b=k.callback;if(b!==null){if(k.callback=null,k=p,typeof b!="function")throw Error(n(191,b));b.call(k)}}}var jc={},ls=oi(jc),$c=oi(jc),Cc=oi(jc);function Ji(i){if(i===jc)throw Error(n(174));return i}function Kp(i,l){switch(In(Cc,l),In($c,i),In(ls,jc),i=l.nodeType,i){case 9:case 11:l=(l=l.documentElement)?l.namespaceURI:xt(null,"");break;default:i=i===8?l.parentNode:l,l=i.namespaceURI||null,i=i.tagName,l=xt(l,i)}Fn(ls),In(ls,l)}function hl(){Fn(ls),Fn($c),Fn(Cc)}function hv(i){Ji(Cc.current);var l=Ji(ls.current),p=xt(l,i.type);l!==p&&(In($c,i),In(ls,p))}function qp(i){$c.current===i&&(Fn(ls),Fn($c))}var Yn=oi(0);function Cd(i){for(var l=i;l!==null;){if(l.tag===13){var p=l.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||p.data==="$?"||p.data==="$!"))return l}else if(l.tag===19&&l.memoizedProps.revealOrder!==void 0){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===i)break;for(;l.sibling===null;){if(l.return===null||l.return===i)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var Zp=[];function Gp(){for(var i=0;i<Zp.length;i++)Zp[i]._workInProgressVersionPrimary=null;Zp.length=0}var Ad=j.ReactCurrentDispatcher,Vp=j.ReactCurrentBatchConfig,ea=0,Xn=null,kr=null,xr=null,Id=!1,Ac=!1,Ic=0,vC=0;function Dr(){throw Error(n(321))}function Yp(i,l){if(l===null)return!1;for(var p=0;p<l.length&&p<i.length;p++)if(!go(i[p],l[p]))return!1;return!0}function Xp(i,l,p,k,b,E){if(ea=E,Xn=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,Ad.current=i===null||i.memoizedState===null?SC:_C,i=p(k,b),Ac){E=0;do{if(Ac=!1,Ic=0,25<=E)throw Error(n(301));E+=1,xr=kr=null,l.updateQueue=null,Ad.current=NC,i=p(k,b)}while(Ac)}if(Ad.current=Md,l=kr!==null&&kr.next!==null,ea=0,xr=kr=Xn=null,Id=!1,l)throw Error(n(300));return i}function Qp(){var i=Ic!==0;return Ic=0,i}function cs(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return xr===null?Xn.memoizedState=xr=i:xr=xr.next=i,xr}function Oo(){if(kr===null){var i=Xn.alternate;i=i!==null?i.memoizedState:null}else i=kr.next;var l=xr===null?Xn.memoizedState:xr.next;if(l!==null)xr=l,kr=i;else{if(i===null)throw Error(n(310));kr=i,i={memoizedState:kr.memoizedState,baseState:kr.baseState,baseQueue:kr.baseQueue,queue:kr.queue,next:null},xr===null?Xn.memoizedState=xr=i:xr=xr.next=i}return xr}function Rc(i,l){return typeof l=="function"?l(i):l}function Jp(i){var l=Oo(),p=l.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=i;var k=kr,b=k.baseQueue,E=p.pending;if(E!==null){if(b!==null){var R=b.next;b.next=E.next,E.next=R}k.baseQueue=b=E,p.pending=null}if(b!==null){E=b.next,k=k.baseState;var G=R=null,ee=null,ye=E;do{var Ie=ye.lane;if((ea&Ie)===Ie)ee!==null&&(ee=ee.next={lane:0,action:ye.action,hasEagerState:ye.hasEagerState,eagerState:ye.eagerState,next:null}),k=ye.hasEagerState?ye.eagerState:i(k,ye.action);else{var Pe={lane:Ie,action:ye.action,hasEagerState:ye.hasEagerState,eagerState:ye.eagerState,next:null};ee===null?(G=ee=Pe,R=k):ee=ee.next=Pe,Xn.lanes|=Ie,ta|=Ie}ye=ye.next}while(ye!==null&&ye!==E);ee===null?R=k:ee.next=G,go(k,l.memoizedState)||(to=!0),l.memoizedState=k,l.baseState=R,l.baseQueue=ee,p.lastRenderedState=k}if(i=p.interleaved,i!==null){b=i;do E=b.lane,Xn.lanes|=E,ta|=E,b=b.next;while(b!==i)}else b===null&&(p.lanes=0);return[l.memoizedState,p.dispatch]}function em(i){var l=Oo(),p=l.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=i;var k=p.dispatch,b=p.pending,E=l.memoizedState;if(b!==null){p.pending=null;var R=b=b.next;do E=i(E,R.action),R=R.next;while(R!==b);go(E,l.memoizedState)||(to=!0),l.memoizedState=E,l.baseQueue===null&&(l.baseState=E),p.lastRenderedState=E}return[E,k]}function pv(){}function mv(i,l){var p=Xn,k=Oo(),b=l(),E=!go(k.memoizedState,b);if(E&&(k.memoizedState=b,to=!0),k=k.queue,tm(wv.bind(null,p,k,i),[i]),k.getSnapshot!==l||E||xr!==null&&xr.memoizedState.tag&1){if(p.flags|=2048,Oc(9,kv.bind(null,p,k,b,l),void 0,null),Er===null)throw Error(n(349));(ea&30)!==0||gv(p,l,b)}return b}function gv(i,l,p){i.flags|=16384,i={getSnapshot:l,value:p},l=Xn.updateQueue,l===null?(l={lastEffect:null,stores:null},Xn.updateQueue=l,l.stores=[i]):(p=l.stores,p===null?l.stores=[i]:p.push(i))}function kv(i,l,p,k){l.value=p,l.getSnapshot=k,yv(l)&&vv(i)}function wv(i,l,p){return p(function(){yv(l)&&vv(i)})}function yv(i){var l=i.getSnapshot;i=i.value;try{var p=l();return!go(i,p)}catch{return!0}}function vv(i){var l=_s(i,1);l!==null&&Vo(l,i,1,-1)}function bv(i){var l=cs();return typeof i=="function"&&(i=i()),l.memoizedState=l.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Rc,lastRenderedState:i},l.queue=i,i=i.dispatch=EC.bind(null,Xn,i),[l.memoizedState,i]}function Oc(i,l,p,k){return i={tag:i,create:l,destroy:p,deps:k,next:null},l=Xn.updateQueue,l===null?(l={lastEffect:null,stores:null},Xn.updateQueue=l,l.lastEffect=i.next=i):(p=l.lastEffect,p===null?l.lastEffect=i.next=i:(k=p.next,p.next=i,i.next=k,l.lastEffect=i)),i}function xv(){return Oo().memoizedState}function Rd(i,l,p,k){var b=cs();Xn.flags|=i,b.memoizedState=Oc(1|l,p,void 0,k===void 0?null:k)}function Od(i,l,p,k){var b=Oo();k=k===void 0?null:k;var E=void 0;if(kr!==null){var R=kr.memoizedState;if(E=R.destroy,k!==null&&Yp(k,R.deps)){b.memoizedState=Oc(l,p,E,k);return}}Xn.flags|=i,b.memoizedState=Oc(1|l,p,E,k)}function Ev(i,l){return Rd(8390656,8,i,l)}function tm(i,l){return Od(2048,8,i,l)}function Sv(i,l){return Od(4,2,i,l)}function _v(i,l){return Od(4,4,i,l)}function Nv(i,l){if(typeof l=="function")return i=i(),l(i),function(){l(null)};if(l!=null)return i=i(),l.current=i,function(){l.current=null}}function Tv(i,l,p){return p=p!=null?p.concat([i]):null,Od(4,4,Nv.bind(null,l,i),p)}function nm(){}function jv(i,l){var p=Oo();l=l===void 0?null:l;var k=p.memoizedState;return k!==null&&l!==null&&Yp(l,k[1])?k[0]:(p.memoizedState=[i,l],i)}function $v(i,l){var p=Oo();l=l===void 0?null:l;var k=p.memoizedState;return k!==null&&l!==null&&Yp(l,k[1])?k[0]:(i=i(),p.memoizedState=[i,l],i)}function Cv(i,l,p){return(ea&21)===0?(i.baseState&&(i.baseState=!1,to=!0),i.memoizedState=p):(go(p,l)||(p=dn(),Xn.lanes|=p,ta|=p,i.baseState=!0),l)}function bC(i,l){var p=Zt;Zt=p!==0&&4>p?p:4,i(!0);var k=Vp.transition;Vp.transition={};try{i(!1),l()}finally{Zt=p,Vp.transition=k}}function Av(){return Oo().memoizedState}function xC(i,l,p){var k=fi(i);if(p={lane:k,action:p,hasEagerState:!1,eagerState:null,next:null},Iv(i))Rv(l,p);else if(p=cv(i,l,p,k),p!==null){var b=Gr();Vo(p,i,k,b),Ov(p,l,k)}}function EC(i,l,p){var k=fi(i),b={lane:k,action:p,hasEagerState:!1,eagerState:null,next:null};if(Iv(i))Rv(l,b);else{var E=i.alternate;if(i.lanes===0&&(E===null||E.lanes===0)&&(E=l.lastRenderedReducer,E!==null))try{var R=l.lastRenderedState,G=E(R,p);if(b.hasEagerState=!0,b.eagerState=G,go(G,R)){var ee=l.interleaved;ee===null?(b.next=b,Hp(l)):(b.next=ee.next,ee.next=b),l.interleaved=b;return}}catch{}finally{}p=cv(i,l,b,k),p!==null&&(b=Gr(),Vo(p,i,k,b),Ov(p,l,k))}}function Iv(i){var l=i.alternate;return i===Xn||l!==null&&l===Xn}function Rv(i,l){Ac=Id=!0;var p=i.pending;p===null?l.next=l:(l.next=p.next,p.next=l),i.pending=l}function Ov(i,l,p){if((p&4194240)!==0){var k=l.lanes;k&=i.pendingLanes,p|=k,l.lanes=p,po(i,p)}}var Md={readContext:Ro,useCallback:Dr,useContext:Dr,useEffect:Dr,useImperativeHandle:Dr,useInsertionEffect:Dr,useLayoutEffect:Dr,useMemo:Dr,useReducer:Dr,useRef:Dr,useState:Dr,useDebugValue:Dr,useDeferredValue:Dr,useTransition:Dr,useMutableSource:Dr,useSyncExternalStore:Dr,useId:Dr,unstable_isNewReconciler:!1},SC={readContext:Ro,useCallback:function(i,l){return cs().memoizedState=[i,l===void 0?null:l],i},useContext:Ro,useEffect:Ev,useImperativeHandle:function(i,l,p){return p=p!=null?p.concat([i]):null,Rd(4194308,4,Nv.bind(null,l,i),p)},useLayoutEffect:function(i,l){return Rd(4194308,4,i,l)},useInsertionEffect:function(i,l){return Rd(4,2,i,l)},useMemo:function(i,l){var p=cs();return l=l===void 0?null:l,i=i(),p.memoizedState=[i,l],i},useReducer:function(i,l,p){var k=cs();return l=p!==void 0?p(l):l,k.memoizedState=k.baseState=l,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:l},k.queue=i,i=i.dispatch=xC.bind(null,Xn,i),[k.memoizedState,i]},useRef:function(i){var l=cs();return i={current:i},l.memoizedState=i},useState:bv,useDebugValue:nm,useDeferredValue:function(i){return cs().memoizedState=i},useTransition:function(){var i=bv(!1),l=i[0];return i=bC.bind(null,i[1]),cs().memoizedState=i,[l,i]},useMutableSource:function(){},useSyncExternalStore:function(i,l,p){var k=Xn,b=cs();if(Wn){if(p===void 0)throw Error(n(407));p=p()}else{if(p=l(),Er===null)throw Error(n(349));(ea&30)!==0||gv(k,l,p)}b.memoizedState=p;var E={value:p,getSnapshot:l};return b.queue=E,Ev(wv.bind(null,k,E,i),[i]),k.flags|=2048,Oc(9,kv.bind(null,k,E,p,l),void 0,null),p},useId:function(){var i=cs(),l=Er.identifierPrefix;if(Wn){var p=Ss,k=Es;p=(k&~(1<<32-Wt(k)-1)).toString(32)+p,l=":"+l+"R"+p,p=Ic++,0<p&&(l+="H"+p.toString(32)),l+=":"}else p=vC++,l=":"+l+"r"+p.toString(32)+":";return i.memoizedState=l},unstable_isNewReconciler:!1},_C={readContext:Ro,useCallback:jv,useContext:Ro,useEffect:tm,useImperativeHandle:Tv,useInsertionEffect:Sv,useLayoutEffect:_v,useMemo:$v,useReducer:Jp,useRef:xv,useState:function(){return Jp(Rc)},useDebugValue:nm,useDeferredValue:function(i){var l=Oo();return Cv(l,kr.memoizedState,i)},useTransition:function(){var i=Jp(Rc)[0],l=Oo().memoizedState;return[i,l]},useMutableSource:pv,useSyncExternalStore:mv,useId:Av,unstable_isNewReconciler:!1},NC={readContext:Ro,useCallback:jv,useContext:Ro,useEffect:tm,useImperativeHandle:Tv,useInsertionEffect:Sv,useLayoutEffect:_v,useMemo:$v,useReducer:em,useRef:xv,useState:function(){return em(Rc)},useDebugValue:nm,useDeferredValue:function(i){var l=Oo();return kr===null?l.memoizedState=i:Cv(l,kr.memoizedState,i)},useTransition:function(){var i=em(Rc)[0],l=Oo().memoizedState;return[i,l]},useMutableSource:pv,useSyncExternalStore:mv,useId:Av,unstable_isNewReconciler:!1};function qo(i,l){if(i&&i.defaultProps){l=V({},l),i=i.defaultProps;for(var p in i)l[p]===void 0&&(l[p]=i[p]);return l}return l}function rm(i,l,p,k){l=i.memoizedState,p=p(k,l),p=p==null?l:V({},l,p),i.memoizedState=p,i.lanes===0&&(i.updateQueue.baseState=p)}var Ld={isMounted:function(i){return(i=i._reactInternals)?rn(i)===i:!1},enqueueSetState:function(i,l,p){i=i._reactInternals;var k=Gr(),b=fi(i),E=Ns(k,b);E.payload=l,p!=null&&(E.callback=p),l=li(i,E,b),l!==null&&(Vo(l,i,b,k),jd(l,i,b))},enqueueReplaceState:function(i,l,p){i=i._reactInternals;var k=Gr(),b=fi(i),E=Ns(k,b);E.tag=1,E.payload=l,p!=null&&(E.callback=p),l=li(i,E,b),l!==null&&(Vo(l,i,b,k),jd(l,i,b))},enqueueForceUpdate:function(i,l){i=i._reactInternals;var p=Gr(),k=fi(i),b=Ns(p,k);b.tag=2,l!=null&&(b.callback=l),l=li(i,b,k),l!==null&&(Vo(l,i,k,p),jd(l,i,k))}};function Mv(i,l,p,k,b,E,R){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(k,E,R):l.prototype&&l.prototype.isPureReactComponent?!Js(p,k)||!Js(b,E):!0}function Lv(i,l,p){var k=!1,b=si,E=l.contextType;return typeof E=="object"&&E!==null?E=Ro(E):(b=eo(l)?Vi:Pr.current,k=l.contextTypes,E=(k=k!=null)?il(i,b):si),l=new l(p,E),i.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,l.updater=Ld,i.stateNode=l,l._reactInternals=i,k&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=b,i.__reactInternalMemoizedMaskedChildContext=E),l}function Pv(i,l,p,k){i=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(p,k),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(p,k),l.state!==i&&Ld.enqueueReplaceState(l,l.state,null)}function om(i,l,p,k){var b=i.stateNode;b.props=p,b.state=i.memoizedState,b.refs={},Wp(i);var E=l.contextType;typeof E=="object"&&E!==null?b.context=Ro(E):(E=eo(l)?Vi:Pr.current,b.context=il(i,E)),b.state=i.memoizedState,E=l.getDerivedStateFromProps,typeof E=="function"&&(rm(i,l,E,p),b.state=i.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof b.getSnapshotBeforeUpdate=="function"||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(l=b.state,typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount(),l!==b.state&&Ld.enqueueReplaceState(b,b.state,null),$d(i,p,b,k),b.state=i.memoizedState),typeof b.componentDidMount=="function"&&(i.flags|=4194308)}function pl(i,l){try{var p="",k=l;do p+=Te(k),k=k.return;while(k);var b=p}catch(E){b=`
40
- Error generating stack: `+E.message+`
41
- `+E.stack}return{value:i,source:l,stack:b,digest:null}}function sm(i,l,p){return{value:i,source:null,stack:p??null,digest:l??null}}function im(i,l){try{console.error(l.value)}catch(p){setTimeout(function(){throw p})}}var TC=typeof WeakMap=="function"?WeakMap:Map;function Dv(i,l,p){p=Ns(-1,p),p.tag=3,p.payload={element:null};var k=l.value;return p.callback=function(){Hd||(Hd=!0,bm=k),im(i,l)},p}function zv(i,l,p){p=Ns(-1,p),p.tag=3;var k=i.type.getDerivedStateFromError;if(typeof k=="function"){var b=l.value;p.payload=function(){return k(b)},p.callback=function(){im(i,l)}}var E=i.stateNode;return E!==null&&typeof E.componentDidCatch=="function"&&(p.callback=function(){im(i,l),typeof k!="function"&&(ui===null?ui=new Set([this]):ui.add(this));var R=l.stack;this.componentDidCatch(l.value,{componentStack:R!==null?R:""})}),p}function Fv(i,l,p){var k=i.pingCache;if(k===null){k=i.pingCache=new TC;var b=new Set;k.set(l,b)}else b=k.get(l),b===void 0&&(b=new Set,k.set(l,b));b.has(p)||(b.add(p),i=BC.bind(null,i,l,p),l.then(i,i))}function Bv(i){do{var l;if((l=i.tag===13)&&(l=i.memoizedState,l=l!==null?l.dehydrated!==null:!0),l)return i;i=i.return}while(i!==null);return null}function Uv(i,l,p,k,b){return(i.mode&1)===0?(i===l?i.flags|=65536:(i.flags|=128,p.flags|=131072,p.flags&=-52805,p.tag===1&&(p.alternate===null?p.tag=17:(l=Ns(-1,1),l.tag=2,li(p,l,1))),p.lanes|=1),i):(i.flags|=65536,i.lanes=b,i)}var jC=j.ReactCurrentOwner,to=!1;function Zr(i,l,p,k){l.child=i===null?lv(l,null,p,k):ul(l,i.child,p,k)}function Hv(i,l,p,k,b){p=p.render;var E=l.ref;return fl(l,b),k=Xp(i,l,p,k,E,b),p=Qp(),i!==null&&!to?(l.updateQueue=i.updateQueue,l.flags&=-2053,i.lanes&=~b,Ts(i,l,b)):(Wn&&p&&Op(l),l.flags|=1,Zr(i,l,k,b),l.child)}function Wv(i,l,p,k,b){if(i===null){var E=p.type;return typeof E=="function"&&!jm(E)&&E.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(l.tag=15,l.type=E,Kv(i,l,E,k,b)):(i=Vd(p.type,null,k,l,l.mode,b),i.ref=l.ref,i.return=l,l.child=i)}if(E=i.child,(i.lanes&b)===0){var R=E.memoizedProps;if(p=p.compare,p=p!==null?p:Js,p(R,k)&&i.ref===l.ref)return Ts(i,l,b)}return l.flags|=1,i=pi(E,k),i.ref=l.ref,i.return=l,l.child=i}function Kv(i,l,p,k,b){if(i!==null){var E=i.memoizedProps;if(Js(E,k)&&i.ref===l.ref)if(to=!1,l.pendingProps=k=E,(i.lanes&b)!==0)(i.flags&131072)!==0&&(to=!0);else return l.lanes=i.lanes,Ts(i,l,b)}return am(i,l,p,k,b)}function qv(i,l,p){var k=l.pendingProps,b=k.children,E=i!==null?i.memoizedState:null;if(k.mode==="hidden")if((l.mode&1)===0)l.memoizedState={baseLanes:0,cachePool:null,transitions:null},In(gl,vo),vo|=p;else{if((p&1073741824)===0)return i=E!==null?E.baseLanes|p:p,l.lanes=l.childLanes=1073741824,l.memoizedState={baseLanes:i,cachePool:null,transitions:null},l.updateQueue=null,In(gl,vo),vo|=i,null;l.memoizedState={baseLanes:0,cachePool:null,transitions:null},k=E!==null?E.baseLanes:p,In(gl,vo),vo|=k}else E!==null?(k=E.baseLanes|p,l.memoizedState=null):k=p,In(gl,vo),vo|=k;return Zr(i,l,b,p),l.child}function Zv(i,l){var p=l.ref;(i===null&&p!==null||i!==null&&i.ref!==p)&&(l.flags|=512,l.flags|=2097152)}function am(i,l,p,k,b){var E=eo(p)?Vi:Pr.current;return E=il(l,E),fl(l,b),p=Xp(i,l,p,k,E,b),k=Qp(),i!==null&&!to?(l.updateQueue=i.updateQueue,l.flags&=-2053,i.lanes&=~b,Ts(i,l,b)):(Wn&&k&&Op(l),l.flags|=1,Zr(i,l,p,b),l.child)}function Gv(i,l,p,k,b){if(eo(p)){var E=!0;vd(l)}else E=!1;if(fl(l,b),l.stateNode===null)Dd(i,l),Lv(l,p,k),om(l,p,k,b),k=!0;else if(i===null){var R=l.stateNode,G=l.memoizedProps;R.props=G;var ee=R.context,ye=p.contextType;typeof ye=="object"&&ye!==null?ye=Ro(ye):(ye=eo(p)?Vi:Pr.current,ye=il(l,ye));var Ie=p.getDerivedStateFromProps,Pe=typeof Ie=="function"||typeof R.getSnapshotBeforeUpdate=="function";Pe||typeof R.UNSAFE_componentWillReceiveProps!="function"&&typeof R.componentWillReceiveProps!="function"||(G!==k||ee!==ye)&&Pv(l,R,k,ye),ai=!1;var Ae=l.memoizedState;R.state=Ae,$d(l,k,R,b),ee=l.memoizedState,G!==k||Ae!==ee||Jr.current||ai?(typeof Ie=="function"&&(rm(l,p,Ie,k),ee=l.memoizedState),(G=ai||Mv(l,p,G,k,Ae,ee,ye))?(Pe||typeof R.UNSAFE_componentWillMount!="function"&&typeof R.componentWillMount!="function"||(typeof R.componentWillMount=="function"&&R.componentWillMount(),typeof R.UNSAFE_componentWillMount=="function"&&R.UNSAFE_componentWillMount()),typeof R.componentDidMount=="function"&&(l.flags|=4194308)):(typeof R.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=k,l.memoizedState=ee),R.props=k,R.state=ee,R.context=ye,k=G):(typeof R.componentDidMount=="function"&&(l.flags|=4194308),k=!1)}else{R=l.stateNode,uv(i,l),G=l.memoizedProps,ye=l.type===l.elementType?G:qo(l.type,G),R.props=ye,Pe=l.pendingProps,Ae=R.context,ee=p.contextType,typeof ee=="object"&&ee!==null?ee=Ro(ee):(ee=eo(p)?Vi:Pr.current,ee=il(l,ee));var Xe=p.getDerivedStateFromProps;(Ie=typeof Xe=="function"||typeof R.getSnapshotBeforeUpdate=="function")||typeof R.UNSAFE_componentWillReceiveProps!="function"&&typeof R.componentWillReceiveProps!="function"||(G!==Pe||Ae!==ee)&&Pv(l,R,k,ee),ai=!1,Ae=l.memoizedState,R.state=Ae,$d(l,k,R,b);var nt=l.memoizedState;G!==Pe||Ae!==nt||Jr.current||ai?(typeof Xe=="function"&&(rm(l,p,Xe,k),nt=l.memoizedState),(ye=ai||Mv(l,p,ye,k,Ae,nt,ee)||!1)?(Ie||typeof R.UNSAFE_componentWillUpdate!="function"&&typeof R.componentWillUpdate!="function"||(typeof R.componentWillUpdate=="function"&&R.componentWillUpdate(k,nt,ee),typeof R.UNSAFE_componentWillUpdate=="function"&&R.UNSAFE_componentWillUpdate(k,nt,ee)),typeof R.componentDidUpdate=="function"&&(l.flags|=4),typeof R.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof R.componentDidUpdate!="function"||G===i.memoizedProps&&Ae===i.memoizedState||(l.flags|=4),typeof R.getSnapshotBeforeUpdate!="function"||G===i.memoizedProps&&Ae===i.memoizedState||(l.flags|=1024),l.memoizedProps=k,l.memoizedState=nt),R.props=k,R.state=nt,R.context=ee,k=ye):(typeof R.componentDidUpdate!="function"||G===i.memoizedProps&&Ae===i.memoizedState||(l.flags|=4),typeof R.getSnapshotBeforeUpdate!="function"||G===i.memoizedProps&&Ae===i.memoizedState||(l.flags|=1024),k=!1)}return lm(i,l,p,k,E,b)}function lm(i,l,p,k,b,E){Zv(i,l);var R=(l.flags&128)!==0;if(!k&&!R)return b&&Jy(l,p,!1),Ts(i,l,E);k=l.stateNode,jC.current=l;var G=R&&typeof p.getDerivedStateFromError!="function"?null:k.render();return l.flags|=1,i!==null&&R?(l.child=ul(l,i.child,null,E),l.child=ul(l,null,G,E)):Zr(i,l,G,E),l.memoizedState=k.state,b&&Jy(l,p,!0),l.child}function Vv(i){var l=i.stateNode;l.pendingContext?Xy(i,l.pendingContext,l.pendingContext!==l.context):l.context&&Xy(i,l.context,!1),Kp(i,l.containerInfo)}function Yv(i,l,p,k,b){return cl(),Dp(b),l.flags|=256,Zr(i,l,p,k),l.child}var cm={dehydrated:null,treeContext:null,retryLane:0};function um(i){return{baseLanes:i,cachePool:null,transitions:null}}function Xv(i,l,p){var k=l.pendingProps,b=Yn.current,E=!1,R=(l.flags&128)!==0,G;if((G=R)||(G=i!==null&&i.memoizedState===null?!1:(b&2)!==0),G?(E=!0,l.flags&=-129):(i===null||i.memoizedState!==null)&&(b|=1),In(Yn,b&1),i===null)return Pp(l),i=l.memoizedState,i!==null&&(i=i.dehydrated,i!==null)?((l.mode&1)===0?l.lanes=1:i.data==="$!"?l.lanes=8:l.lanes=1073741824,null):(R=k.children,i=k.fallback,E?(k=l.mode,E=l.child,R={mode:"hidden",children:R},(k&1)===0&&E!==null?(E.childLanes=0,E.pendingProps=R):E=Yd(R,k,0,null),i=sa(i,k,p,null),E.return=l,i.return=l,E.sibling=i,l.child=E,l.child.memoizedState=um(p),l.memoizedState=cm,i):dm(l,R));if(b=i.memoizedState,b!==null&&(G=b.dehydrated,G!==null))return $C(i,l,R,k,G,b,p);if(E){E=k.fallback,R=l.mode,b=i.child,G=b.sibling;var ee={mode:"hidden",children:k.children};return(R&1)===0&&l.child!==b?(k=l.child,k.childLanes=0,k.pendingProps=ee,l.deletions=null):(k=pi(b,ee),k.subtreeFlags=b.subtreeFlags&14680064),G!==null?E=pi(G,E):(E=sa(E,R,p,null),E.flags|=2),E.return=l,k.return=l,k.sibling=E,l.child=k,k=E,E=l.child,R=i.child.memoizedState,R=R===null?um(p):{baseLanes:R.baseLanes|p,cachePool:null,transitions:R.transitions},E.memoizedState=R,E.childLanes=i.childLanes&~p,l.memoizedState=cm,k}return E=i.child,i=E.sibling,k=pi(E,{mode:"visible",children:k.children}),(l.mode&1)===0&&(k.lanes=p),k.return=l,k.sibling=null,i!==null&&(p=l.deletions,p===null?(l.deletions=[i],l.flags|=16):p.push(i)),l.child=k,l.memoizedState=null,k}function dm(i,l){return l=Yd({mode:"visible",children:l},i.mode,0,null),l.return=i,i.child=l}function Pd(i,l,p,k){return k!==null&&Dp(k),ul(l,i.child,null,p),i=dm(l,l.pendingProps.children),i.flags|=2,l.memoizedState=null,i}function $C(i,l,p,k,b,E,R){if(p)return l.flags&256?(l.flags&=-257,k=sm(Error(n(422))),Pd(i,l,R,k)):l.memoizedState!==null?(l.child=i.child,l.flags|=128,null):(E=k.fallback,b=l.mode,k=Yd({mode:"visible",children:k.children},b,0,null),E=sa(E,b,R,null),E.flags|=2,k.return=l,E.return=l,k.sibling=E,l.child=k,(l.mode&1)!==0&&ul(l,i.child,null,R),l.child.memoizedState=um(R),l.memoizedState=cm,E);if((l.mode&1)===0)return Pd(i,l,R,null);if(b.data==="$!"){if(k=b.nextSibling&&b.nextSibling.dataset,k)var G=k.dgst;return k=G,E=Error(n(419)),k=sm(E,k,void 0),Pd(i,l,R,k)}if(G=(R&i.childLanes)!==0,to||G){if(k=Er,k!==null){switch(R&-R){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|R))!==0?0:b,b!==0&&b!==E.retryLane&&(E.retryLane=b,_s(i,b),Vo(k,i,b,-1))}return Tm(),k=sm(Error(n(421))),Pd(i,l,R,k)}return b.data==="$?"?(l.flags|=128,l.child=i.child,l=UC.bind(null,i),b._reactRetry=l,null):(i=E.treeContext,yo=ri(b.nextSibling),wo=l,Wn=!0,Ko=null,i!==null&&(Ao[Io++]=Es,Ao[Io++]=Ss,Ao[Io++]=Yi,Es=i.id,Ss=i.overflow,Yi=l),l=dm(l,k.children),l.flags|=4096,l)}function Qv(i,l,p){i.lanes|=l;var k=i.alternate;k!==null&&(k.lanes|=l),Up(i.return,l,p)}function fm(i,l,p,k,b){var E=i.memoizedState;E===null?i.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:k,tail:p,tailMode:b}:(E.isBackwards=l,E.rendering=null,E.renderingStartTime=0,E.last=k,E.tail=p,E.tailMode=b)}function Jv(i,l,p){var k=l.pendingProps,b=k.revealOrder,E=k.tail;if(Zr(i,l,k.children,p),k=Yn.current,(k&2)!==0)k=k&1|2,l.flags|=128;else{if(i!==null&&(i.flags&128)!==0)e:for(i=l.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&Qv(i,p,l);else if(i.tag===19)Qv(i,p,l);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===l)break e;for(;i.sibling===null;){if(i.return===null||i.return===l)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}k&=1}if(In(Yn,k),(l.mode&1)===0)l.memoizedState=null;else switch(b){case"forwards":for(p=l.child,b=null;p!==null;)i=p.alternate,i!==null&&Cd(i)===null&&(b=p),p=p.sibling;p=b,p===null?(b=l.child,l.child=null):(b=p.sibling,p.sibling=null),fm(l,!1,b,p,E);break;case"backwards":for(p=null,b=l.child,l.child=null;b!==null;){if(i=b.alternate,i!==null&&Cd(i)===null){l.child=b;break}i=b.sibling,b.sibling=p,p=b,b=i}fm(l,!0,p,null,E);break;case"together":fm(l,!1,null,null,void 0);break;default:l.memoizedState=null}return l.child}function Dd(i,l){(l.mode&1)===0&&i!==null&&(i.alternate=null,l.alternate=null,l.flags|=2)}function Ts(i,l,p){if(i!==null&&(l.dependencies=i.dependencies),ta|=l.lanes,(p&l.childLanes)===0)return null;if(i!==null&&l.child!==i.child)throw Error(n(153));if(l.child!==null){for(i=l.child,p=pi(i,i.pendingProps),l.child=p,p.return=l;i.sibling!==null;)i=i.sibling,p=p.sibling=pi(i,i.pendingProps),p.return=l;p.sibling=null}return l.child}function CC(i,l,p){switch(l.tag){case 3:Vv(l),cl();break;case 5:hv(l);break;case 1:eo(l.type)&&vd(l);break;case 4:Kp(l,l.stateNode.containerInfo);break;case 10:var k=l.type._context,b=l.memoizedProps.value;In(Nd,k._currentValue),k._currentValue=b;break;case 13:if(k=l.memoizedState,k!==null)return k.dehydrated!==null?(In(Yn,Yn.current&1),l.flags|=128,null):(p&l.child.childLanes)!==0?Xv(i,l,p):(In(Yn,Yn.current&1),i=Ts(i,l,p),i!==null?i.sibling:null);In(Yn,Yn.current&1);break;case 19:if(k=(p&l.childLanes)!==0,(i.flags&128)!==0){if(k)return Jv(i,l,p);l.flags|=128}if(b=l.memoizedState,b!==null&&(b.rendering=null,b.tail=null,b.lastEffect=null),In(Yn,Yn.current),k)break;return null;case 22:case 23:return l.lanes=0,qv(i,l,p)}return Ts(i,l,p)}var e0,hm,t0,n0;e0=function(i,l){for(var p=l.child;p!==null;){if(p.tag===5||p.tag===6)i.appendChild(p.stateNode);else if(p.tag!==4&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===l)break;for(;p.sibling===null;){if(p.return===null||p.return===l)return;p=p.return}p.sibling.return=p.return,p=p.sibling}},hm=function(){},t0=function(i,l,p,k){var b=i.memoizedProps;if(b!==k){i=l.stateNode,Ji(ls.current);var E=null;switch(p){case"input":b=Re(i,b),k=Re(i,k),E=[];break;case"select":b=V({},b,{value:void 0}),k=V({},k,{value:void 0}),E=[];break;case"textarea":b=Ue(i,b),k=Ue(i,k),E=[];break;default:typeof b.onClick!="function"&&typeof k.onClick=="function"&&(i.onclick=kd)}nn(p,k);var R;p=null;for(ye in b)if(!k.hasOwnProperty(ye)&&b.hasOwnProperty(ye)&&b[ye]!=null)if(ye==="style"){var G=b[ye];for(R in G)G.hasOwnProperty(R)&&(p||(p={}),p[R]="")}else ye!=="dangerouslySetInnerHTML"&&ye!=="children"&&ye!=="suppressContentEditableWarning"&&ye!=="suppressHydrationWarning"&&ye!=="autoFocus"&&(o.hasOwnProperty(ye)?E||(E=[]):(E=E||[]).push(ye,null));for(ye in k){var ee=k[ye];if(G=b!=null?b[ye]:void 0,k.hasOwnProperty(ye)&&ee!==G&&(ee!=null||G!=null))if(ye==="style")if(G){for(R in G)!G.hasOwnProperty(R)||ee&&ee.hasOwnProperty(R)||(p||(p={}),p[R]="");for(R in ee)ee.hasOwnProperty(R)&&G[R]!==ee[R]&&(p||(p={}),p[R]=ee[R])}else p||(E||(E=[]),E.push(ye,p)),p=ee;else ye==="dangerouslySetInnerHTML"?(ee=ee?ee.__html:void 0,G=G?G.__html:void 0,ee!=null&&G!==ee&&(E=E||[]).push(ye,ee)):ye==="children"?typeof ee!="string"&&typeof ee!="number"||(E=E||[]).push(ye,""+ee):ye!=="suppressContentEditableWarning"&&ye!=="suppressHydrationWarning"&&(o.hasOwnProperty(ye)?(ee!=null&&ye==="onScroll"&&zn("scroll",i),E||G===ee||(E=[])):(E=E||[]).push(ye,ee))}p&&(E=E||[]).push("style",p);var ye=E;(l.updateQueue=ye)&&(l.flags|=4)}},n0=function(i,l,p,k){p!==k&&(l.flags|=4)};function Mc(i,l){if(!Wn)switch(i.tailMode){case"hidden":l=i.tail;for(var p=null;l!==null;)l.alternate!==null&&(p=l),l=l.sibling;p===null?i.tail=null:p.sibling=null;break;case"collapsed":p=i.tail;for(var k=null;p!==null;)p.alternate!==null&&(k=p),p=p.sibling;k===null?l||i.tail===null?i.tail=null:i.tail.sibling=null:k.sibling=null}}function zr(i){var l=i.alternate!==null&&i.alternate.child===i.child,p=0,k=0;if(l)for(var b=i.child;b!==null;)p|=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;)p|=b.lanes|b.childLanes,k|=b.subtreeFlags,k|=b.flags,b.return=i,b=b.sibling;return i.subtreeFlags|=k,i.childLanes=p,l}function AC(i,l,p){var k=l.pendingProps;switch(Mp(l),l.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return zr(l),null;case 1:return eo(l.type)&&yd(),zr(l),null;case 3:return k=l.stateNode,hl(),Fn(Jr),Fn(Pr),Gp(),k.pendingContext&&(k.context=k.pendingContext,k.pendingContext=null),(i===null||i.child===null)&&(Sd(l)?l.flags|=4:i===null||i.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,Ko!==null&&(Sm(Ko),Ko=null))),hm(i,l),zr(l),null;case 5:qp(l);var b=Ji(Cc.current);if(p=l.type,i!==null&&l.stateNode!=null)t0(i,l,p,k,b),i.ref!==l.ref&&(l.flags|=512,l.flags|=2097152);else{if(!k){if(l.stateNode===null)throw Error(n(166));return zr(l),null}if(i=Ji(ls.current),Sd(l)){k=l.stateNode,p=l.type;var E=l.memoizedProps;switch(k[as]=l,k[_c]=E,i=(l.mode&1)!==0,p){case"dialog":zn("cancel",k),zn("close",k);break;case"iframe":case"object":case"embed":zn("load",k);break;case"video":case"audio":for(b=0;b<xc.length;b++)zn(xc[b],k);break;case"source":zn("error",k);break;case"img":case"image":case"link":zn("error",k),zn("load",k);break;case"details":zn("toggle",k);break;case"input":ge(k,E),zn("invalid",k);break;case"select":k._wrapperState={wasMultiple:!!E.multiple},zn("invalid",k);break;case"textarea":zt(k,E),zn("invalid",k)}nn(p,E),b=null;for(var R in E)if(E.hasOwnProperty(R)){var G=E[R];R==="children"?typeof G=="string"?k.textContent!==G&&(E.suppressHydrationWarning!==!0&&gd(k.textContent,G,i),b=["children",G]):typeof G=="number"&&k.textContent!==""+G&&(E.suppressHydrationWarning!==!0&&gd(k.textContent,G,i),b=["children",""+G]):o.hasOwnProperty(R)&&G!=null&&R==="onScroll"&&zn("scroll",k)}switch(p){case"input":ce(k),Ye(k,E,!0);break;case"textarea":ce(k),At(k);break;case"select":case"option":break;default:typeof E.onClick=="function"&&(k.onclick=kd)}k=b,l.updateQueue=k,k!==null&&(l.flags|=4)}else{R=b.nodeType===9?b:b.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=Kt(p)),i==="http://www.w3.org/1999/xhtml"?p==="script"?(i=R.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof k.is=="string"?i=R.createElement(p,{is:k.is}):(i=R.createElement(p),p==="select"&&(R=i,k.multiple?R.multiple=!0:k.size&&(R.size=k.size))):i=R.createElementNS(i,p),i[as]=l,i[_c]=k,e0(i,l,!1,!1),l.stateNode=i;e:{switch(R=X(p,k),p){case"dialog":zn("cancel",i),zn("close",i),b=k;break;case"iframe":case"object":case"embed":zn("load",i),b=k;break;case"video":case"audio":for(b=0;b<xc.length;b++)zn(xc[b],i);b=k;break;case"source":zn("error",i),b=k;break;case"img":case"image":case"link":zn("error",i),zn("load",i),b=k;break;case"details":zn("toggle",i),b=k;break;case"input":ge(i,k),b=Re(i,k),zn("invalid",i);break;case"option":b=k;break;case"select":i._wrapperState={wasMultiple:!!k.multiple},b=V({},k,{value:void 0}),zn("invalid",i);break;case"textarea":zt(i,k),b=Ue(i,k),zn("invalid",i);break;default:b=k}nn(p,b),G=b;for(E in G)if(G.hasOwnProperty(E)){var ee=G[E];E==="style"?Nn(i,ee):E==="dangerouslySetInnerHTML"?(ee=ee?ee.__html:void 0,ee!=null&&Ct(i,ee)):E==="children"?typeof ee=="string"?(p!=="textarea"||ee!=="")&&Ut(i,ee):typeof ee=="number"&&Ut(i,""+ee):E!=="suppressContentEditableWarning"&&E!=="suppressHydrationWarning"&&E!=="autoFocus"&&(o.hasOwnProperty(E)?ee!=null&&E==="onScroll"&&zn("scroll",i):ee!=null&&T(i,E,ee,R))}switch(p){case"input":ce(i),Ye(i,k,!1);break;case"textarea":ce(i),At(i);break;case"option":k.value!=null&&i.setAttribute("value",""+J(k.value));break;case"select":i.multiple=!!k.multiple,E=k.value,E!=null?gt(i,!!k.multiple,E,!1):k.defaultValue!=null&&gt(i,!!k.multiple,k.defaultValue,!0);break;default:typeof b.onClick=="function"&&(i.onclick=kd)}switch(p){case"button":case"input":case"select":case"textarea":k=!!k.autoFocus;break e;case"img":k=!0;break e;default:k=!1}}k&&(l.flags|=4)}l.ref!==null&&(l.flags|=512,l.flags|=2097152)}return zr(l),null;case 6:if(i&&l.stateNode!=null)n0(i,l,i.memoizedProps,k);else{if(typeof k!="string"&&l.stateNode===null)throw Error(n(166));if(p=Ji(Cc.current),Ji(ls.current),Sd(l)){if(k=l.stateNode,p=l.memoizedProps,k[as]=l,(E=k.nodeValue!==p)&&(i=wo,i!==null))switch(i.tag){case 3:gd(k.nodeValue,p,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&gd(k.nodeValue,p,(i.mode&1)!==0)}E&&(l.flags|=4)}else k=(p.nodeType===9?p:p.ownerDocument).createTextNode(k),k[as]=l,l.stateNode=k}return zr(l),null;case 13:if(Fn(Yn),k=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(Wn&&yo!==null&&(l.mode&1)!==0&&(l.flags&128)===0)sv(),cl(),l.flags|=98560,E=!1;else if(E=Sd(l),k!==null&&k.dehydrated!==null){if(i===null){if(!E)throw Error(n(318));if(E=l.memoizedState,E=E!==null?E.dehydrated:null,!E)throw Error(n(317));E[as]=l}else cl(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;zr(l),E=!1}else Ko!==null&&(Sm(Ko),Ko=null),E=!0;if(!E)return l.flags&65536?l:null}return(l.flags&128)!==0?(l.lanes=p,l):(k=k!==null,k!==(i!==null&&i.memoizedState!==null)&&k&&(l.child.flags|=8192,(l.mode&1)!==0&&(i===null||(Yn.current&1)!==0?wr===0&&(wr=3):Tm())),l.updateQueue!==null&&(l.flags|=4),zr(l),null);case 4:return hl(),hm(i,l),i===null&&Ec(l.stateNode.containerInfo),zr(l),null;case 10:return Bp(l.type._context),zr(l),null;case 17:return eo(l.type)&&yd(),zr(l),null;case 19:if(Fn(Yn),E=l.memoizedState,E===null)return zr(l),null;if(k=(l.flags&128)!==0,R=E.rendering,R===null)if(k)Mc(E,!1);else{if(wr!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(R=Cd(i),R!==null){for(l.flags|=128,Mc(E,!1),k=R.updateQueue,k!==null&&(l.updateQueue=k,l.flags|=4),l.subtreeFlags=0,k=p,p=l.child;p!==null;)E=p,i=k,E.flags&=14680066,R=E.alternate,R===null?(E.childLanes=0,E.lanes=i,E.child=null,E.subtreeFlags=0,E.memoizedProps=null,E.memoizedState=null,E.updateQueue=null,E.dependencies=null,E.stateNode=null):(E.childLanes=R.childLanes,E.lanes=R.lanes,E.child=R.child,E.subtreeFlags=0,E.deletions=null,E.memoizedProps=R.memoizedProps,E.memoizedState=R.memoizedState,E.updateQueue=R.updateQueue,E.type=R.type,i=R.dependencies,E.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),p=p.sibling;return In(Yn,Yn.current&1|2),l.child}i=i.sibling}E.tail!==null&&Xt()>kl&&(l.flags|=128,k=!0,Mc(E,!1),l.lanes=4194304)}else{if(!k)if(i=Cd(R),i!==null){if(l.flags|=128,k=!0,p=i.updateQueue,p!==null&&(l.updateQueue=p,l.flags|=4),Mc(E,!0),E.tail===null&&E.tailMode==="hidden"&&!R.alternate&&!Wn)return zr(l),null}else 2*Xt()-E.renderingStartTime>kl&&p!==1073741824&&(l.flags|=128,k=!0,Mc(E,!1),l.lanes=4194304);E.isBackwards?(R.sibling=l.child,l.child=R):(p=E.last,p!==null?p.sibling=R:l.child=R,E.last=R)}return E.tail!==null?(l=E.tail,E.rendering=l,E.tail=l.sibling,E.renderingStartTime=Xt(),l.sibling=null,p=Yn.current,In(Yn,k?p&1|2:p&1),l):(zr(l),null);case 22:case 23:return Nm(),k=l.memoizedState!==null,i!==null&&i.memoizedState!==null!==k&&(l.flags|=8192),k&&(l.mode&1)!==0?(vo&1073741824)!==0&&(zr(l),l.subtreeFlags&6&&(l.flags|=8192)):zr(l),null;case 24:return null;case 25:return null}throw Error(n(156,l.tag))}function IC(i,l){switch(Mp(l),l.tag){case 1:return eo(l.type)&&yd(),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return hl(),Fn(Jr),Fn(Pr),Gp(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 5:return qp(l),null;case 13:if(Fn(Yn),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(n(340));cl()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return Fn(Yn),null;case 4:return hl(),null;case 10:return Bp(l.type._context),null;case 22:case 23:return Nm(),null;case 24:return null;default:return null}}var zd=!1,Fr=!1,RC=typeof WeakSet=="function"?WeakSet:Set,et=null;function ml(i,l){var p=i.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(k){sr(i,l,k)}else p.current=null}function pm(i,l,p){try{p()}catch(k){sr(i,l,k)}}var r0=!1;function OC(i,l){if(Np=$o,i=yc(),Ja(i)){if("selectionStart"in i)var p={start:i.selectionStart,end:i.selectionEnd};else e:{p=(p=i.ownerDocument)&&p.defaultView||window;var k=p.getSelection&&p.getSelection();if(k&&k.rangeCount!==0){p=k.anchorNode;var b=k.anchorOffset,E=k.focusNode;k=k.focusOffset;try{p.nodeType,E.nodeType}catch{p=null;break e}var R=0,G=-1,ee=-1,ye=0,Ie=0,Pe=i,Ae=null;t:for(;;){for(var Xe;Pe!==p||b!==0&&Pe.nodeType!==3||(G=R+b),Pe!==E||k!==0&&Pe.nodeType!==3||(ee=R+k),Pe.nodeType===3&&(R+=Pe.nodeValue.length),(Xe=Pe.firstChild)!==null;)Ae=Pe,Pe=Xe;for(;;){if(Pe===i)break t;if(Ae===p&&++ye===b&&(G=R),Ae===E&&++Ie===k&&(ee=R),(Xe=Pe.nextSibling)!==null)break;Pe=Ae,Ae=Pe.parentNode}Pe=Xe}p=G===-1||ee===-1?null:{start:G,end:ee}}else p=null}p=p||{start:0,end:0}}else p=null;for(Tp={focusedElem:i,selectionRange:p},$o=!1,et=l;et!==null;)if(l=et,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,et=i;else for(;et!==null;){l=et;try{var nt=l.alternate;if((l.flags&1024)!==0)switch(l.tag){case 0:case 11:case 15:break;case 1:if(nt!==null){var st=nt.memoizedProps,lr=nt.memoizedState,he=l.stateNode,oe=he.getSnapshotBeforeUpdate(l.elementType===l.type?st:qo(l.type,st),lr);he.__reactInternalSnapshotBeforeUpdate=oe}break;case 3:var me=l.stateNode.containerInfo;me.nodeType===1?me.textContent="":me.nodeType===9&&me.documentElement&&me.removeChild(me.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Fe){sr(l,l.return,Fe)}if(i=l.sibling,i!==null){i.return=l.return,et=i;break}et=l.return}return nt=r0,r0=!1,nt}function Lc(i,l,p){var k=l.updateQueue;if(k=k!==null?k.lastEffect:null,k!==null){var b=k=k.next;do{if((b.tag&i)===i){var E=b.destroy;b.destroy=void 0,E!==void 0&&pm(l,p,E)}b=b.next}while(b!==k)}}function Fd(i,l){if(l=l.updateQueue,l=l!==null?l.lastEffect:null,l!==null){var p=l=l.next;do{if((p.tag&i)===i){var k=p.create;p.destroy=k()}p=p.next}while(p!==l)}}function mm(i){var l=i.ref;if(l!==null){var p=i.stateNode;switch(i.tag){case 5:i=p;break;default:i=p}typeof l=="function"?l(i):l.current=i}}function o0(i){var l=i.alternate;l!==null&&(i.alternate=null,o0(l)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(l=i.stateNode,l!==null&&(delete l[as],delete l[_c],delete l[Ap],delete l[gC],delete l[kC])),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 s0(i){return i.tag===5||i.tag===3||i.tag===4}function i0(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||s0(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 gm(i,l,p){var k=i.tag;if(k===5||k===6)i=i.stateNode,l?p.nodeType===8?p.parentNode.insertBefore(i,l):p.insertBefore(i,l):(p.nodeType===8?(l=p.parentNode,l.insertBefore(i,p)):(l=p,l.appendChild(i)),p=p._reactRootContainer,p!=null||l.onclick!==null||(l.onclick=kd));else if(k!==4&&(i=i.child,i!==null))for(gm(i,l,p),i=i.sibling;i!==null;)gm(i,l,p),i=i.sibling}function km(i,l,p){var k=i.tag;if(k===5||k===6)i=i.stateNode,l?p.insertBefore(i,l):p.appendChild(i);else if(k!==4&&(i=i.child,i!==null))for(km(i,l,p),i=i.sibling;i!==null;)km(i,l,p),i=i.sibling}var Cr=null,Zo=!1;function ci(i,l,p){for(p=p.child;p!==null;)a0(i,l,p),p=p.sibling}function a0(i,l,p){if(ut&&typeof ut.onCommitFiberUnmount=="function")try{ut.onCommitFiberUnmount(kt,p)}catch{}switch(p.tag){case 5:Fr||ml(p,l);case 6:var k=Cr,b=Zo;Cr=null,ci(i,l,p),Cr=k,Zo=b,Cr!==null&&(Zo?(i=Cr,p=p.stateNode,i.nodeType===8?i.parentNode.removeChild(p):i.removeChild(p)):Cr.removeChild(p.stateNode));break;case 18:Cr!==null&&(Zo?(i=Cr,p=p.stateNode,i.nodeType===8?Cp(i.parentNode,p):i.nodeType===1&&Cp(i,p),Fi(i)):Cp(Cr,p.stateNode));break;case 4:k=Cr,b=Zo,Cr=p.stateNode.containerInfo,Zo=!0,ci(i,l,p),Cr=k,Zo=b;break;case 0:case 11:case 14:case 15:if(!Fr&&(k=p.updateQueue,k!==null&&(k=k.lastEffect,k!==null))){b=k=k.next;do{var E=b,R=E.destroy;E=E.tag,R!==void 0&&((E&2)!==0||(E&4)!==0)&&pm(p,l,R),b=b.next}while(b!==k)}ci(i,l,p);break;case 1:if(!Fr&&(ml(p,l),k=p.stateNode,typeof k.componentWillUnmount=="function"))try{k.props=p.memoizedProps,k.state=p.memoizedState,k.componentWillUnmount()}catch(G){sr(p,l,G)}ci(i,l,p);break;case 21:ci(i,l,p);break;case 22:p.mode&1?(Fr=(k=Fr)||p.memoizedState!==null,ci(i,l,p),Fr=k):ci(i,l,p);break;default:ci(i,l,p)}}function l0(i){var l=i.updateQueue;if(l!==null){i.updateQueue=null;var p=i.stateNode;p===null&&(p=i.stateNode=new RC),l.forEach(function(k){var b=HC.bind(null,i,k);p.has(k)||(p.add(k),k.then(b,b))})}}function Go(i,l){var p=l.deletions;if(p!==null)for(var k=0;k<p.length;k++){var b=p[k];try{var E=i,R=l,G=R;e:for(;G!==null;){switch(G.tag){case 5:Cr=G.stateNode,Zo=!1;break e;case 3:Cr=G.stateNode.containerInfo,Zo=!0;break e;case 4:Cr=G.stateNode.containerInfo,Zo=!0;break e}G=G.return}if(Cr===null)throw Error(n(160));a0(E,R,b),Cr=null,Zo=!1;var ee=b.alternate;ee!==null&&(ee.return=null),b.return=null}catch(ye){sr(b,l,ye)}}if(l.subtreeFlags&12854)for(l=l.child;l!==null;)c0(l,i),l=l.sibling}function c0(i,l){var p=i.alternate,k=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(Go(l,i),us(i),k&4){try{Lc(3,i,i.return),Fd(3,i)}catch(st){sr(i,i.return,st)}try{Lc(5,i,i.return)}catch(st){sr(i,i.return,st)}}break;case 1:Go(l,i),us(i),k&512&&p!==null&&ml(p,p.return);break;case 5:if(Go(l,i),us(i),k&512&&p!==null&&ml(p,p.return),i.flags&32){var b=i.stateNode;try{Ut(b,"")}catch(st){sr(i,i.return,st)}}if(k&4&&(b=i.stateNode,b!=null)){var E=i.memoizedProps,R=p!==null?p.memoizedProps:E,G=i.type,ee=i.updateQueue;if(i.updateQueue=null,ee!==null)try{G==="input"&&E.type==="radio"&&E.name!=null&&Ee(b,E),X(G,R);var ye=X(G,E);for(R=0;R<ee.length;R+=2){var Ie=ee[R],Pe=ee[R+1];Ie==="style"?Nn(b,Pe):Ie==="dangerouslySetInnerHTML"?Ct(b,Pe):Ie==="children"?Ut(b,Pe):T(b,Ie,Pe,ye)}switch(G){case"input":We(b,E);break;case"textarea":pt(b,E);break;case"select":var Ae=b._wrapperState.wasMultiple;b._wrapperState.wasMultiple=!!E.multiple;var Xe=E.value;Xe!=null?gt(b,!!E.multiple,Xe,!1):Ae!==!!E.multiple&&(E.defaultValue!=null?gt(b,!!E.multiple,E.defaultValue,!0):gt(b,!!E.multiple,E.multiple?[]:"",!1))}b[_c]=E}catch(st){sr(i,i.return,st)}}break;case 6:if(Go(l,i),us(i),k&4){if(i.stateNode===null)throw Error(n(162));b=i.stateNode,E=i.memoizedProps;try{b.nodeValue=E}catch(st){sr(i,i.return,st)}}break;case 3:if(Go(l,i),us(i),k&4&&p!==null&&p.memoizedState.isDehydrated)try{Fi(l.containerInfo)}catch(st){sr(i,i.return,st)}break;case 4:Go(l,i),us(i);break;case 13:Go(l,i),us(i),b=i.child,b.flags&8192&&(E=b.memoizedState!==null,b.stateNode.isHidden=E,!E||b.alternate!==null&&b.alternate.memoizedState!==null||(vm=Xt())),k&4&&l0(i);break;case 22:if(Ie=p!==null&&p.memoizedState!==null,i.mode&1?(Fr=(ye=Fr)||Ie,Go(l,i),Fr=ye):Go(l,i),us(i),k&8192){if(ye=i.memoizedState!==null,(i.stateNode.isHidden=ye)&&!Ie&&(i.mode&1)!==0)for(et=i,Ie=i.child;Ie!==null;){for(Pe=et=Ie;et!==null;){switch(Ae=et,Xe=Ae.child,Ae.tag){case 0:case 11:case 14:case 15:Lc(4,Ae,Ae.return);break;case 1:ml(Ae,Ae.return);var nt=Ae.stateNode;if(typeof nt.componentWillUnmount=="function"){k=Ae,p=Ae.return;try{l=k,nt.props=l.memoizedProps,nt.state=l.memoizedState,nt.componentWillUnmount()}catch(st){sr(k,p,st)}}break;case 5:ml(Ae,Ae.return);break;case 22:if(Ae.memoizedState!==null){f0(Pe);continue}}Xe!==null?(Xe.return=Ae,et=Xe):f0(Pe)}Ie=Ie.sibling}e:for(Ie=null,Pe=i;;){if(Pe.tag===5){if(Ie===null){Ie=Pe;try{b=Pe.stateNode,ye?(E=b.style,typeof E.setProperty=="function"?E.setProperty("display","none","important"):E.display="none"):(G=Pe.stateNode,ee=Pe.memoizedProps.style,R=ee!=null&&ee.hasOwnProperty("display")?ee.display:null,G.style.display=Qt("display",R))}catch(st){sr(i,i.return,st)}}}else if(Pe.tag===6){if(Ie===null)try{Pe.stateNode.nodeValue=ye?"":Pe.memoizedProps}catch(st){sr(i,i.return,st)}}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;Ie===Pe&&(Ie=null),Pe=Pe.return}Ie===Pe&&(Ie=null),Pe.sibling.return=Pe.return,Pe=Pe.sibling}}break;case 19:Go(l,i),us(i),k&4&&l0(i);break;case 21:break;default:Go(l,i),us(i)}}function us(i){var l=i.flags;if(l&2){try{e:{for(var p=i.return;p!==null;){if(s0(p)){var k=p;break e}p=p.return}throw Error(n(160))}switch(k.tag){case 5:var b=k.stateNode;k.flags&32&&(Ut(b,""),k.flags&=-33);var E=i0(i);km(i,E,b);break;case 3:case 4:var R=k.stateNode.containerInfo,G=i0(i);gm(i,G,R);break;default:throw Error(n(161))}}catch(ee){sr(i,i.return,ee)}i.flags&=-3}l&4096&&(i.flags&=-4097)}function MC(i,l,p){et=i,u0(i)}function u0(i,l,p){for(var k=(i.mode&1)!==0;et!==null;){var b=et,E=b.child;if(b.tag===22&&k){var R=b.memoizedState!==null||zd;if(!R){var G=b.alternate,ee=G!==null&&G.memoizedState!==null||Fr;G=zd;var ye=Fr;if(zd=R,(Fr=ee)&&!ye)for(et=b;et!==null;)R=et,ee=R.child,R.tag===22&&R.memoizedState!==null?h0(b):ee!==null?(ee.return=R,et=ee):h0(b);for(;E!==null;)et=E,u0(E),E=E.sibling;et=b,zd=G,Fr=ye}d0(i)}else(b.subtreeFlags&8772)!==0&&E!==null?(E.return=b,et=E):d0(i)}}function d0(i){for(;et!==null;){var l=et;if((l.flags&8772)!==0){var p=l.alternate;try{if((l.flags&8772)!==0)switch(l.tag){case 0:case 11:case 15:Fr||Fd(5,l);break;case 1:var k=l.stateNode;if(l.flags&4&&!Fr)if(p===null)k.componentDidMount();else{var b=l.elementType===l.type?p.memoizedProps:qo(l.type,p.memoizedProps);k.componentDidUpdate(b,p.memoizedState,k.__reactInternalSnapshotBeforeUpdate)}var E=l.updateQueue;E!==null&&fv(l,E,k);break;case 3:var R=l.updateQueue;if(R!==null){if(p=null,l.child!==null)switch(l.child.tag){case 5:p=l.child.stateNode;break;case 1:p=l.child.stateNode}fv(l,R,p)}break;case 5:var G=l.stateNode;if(p===null&&l.flags&4){p=G;var ee=l.memoizedProps;switch(l.type){case"button":case"input":case"select":case"textarea":ee.autoFocus&&p.focus();break;case"img":ee.src&&(p.src=ee.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(l.memoizedState===null){var ye=l.alternate;if(ye!==null){var Ie=ye.memoizedState;if(Ie!==null){var Pe=Ie.dehydrated;Pe!==null&&Fi(Pe)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Fr||l.flags&512&&mm(l)}catch(Ae){sr(l,l.return,Ae)}}if(l===i){et=null;break}if(p=l.sibling,p!==null){p.return=l.return,et=p;break}et=l.return}}function f0(i){for(;et!==null;){var l=et;if(l===i){et=null;break}var p=l.sibling;if(p!==null){p.return=l.return,et=p;break}et=l.return}}function h0(i){for(;et!==null;){var l=et;try{switch(l.tag){case 0:case 11:case 15:var p=l.return;try{Fd(4,l)}catch(ee){sr(l,p,ee)}break;case 1:var k=l.stateNode;if(typeof k.componentDidMount=="function"){var b=l.return;try{k.componentDidMount()}catch(ee){sr(l,b,ee)}}var E=l.return;try{mm(l)}catch(ee){sr(l,E,ee)}break;case 5:var R=l.return;try{mm(l)}catch(ee){sr(l,R,ee)}}}catch(ee){sr(l,l.return,ee)}if(l===i){et=null;break}var G=l.sibling;if(G!==null){G.return=l.return,et=G;break}et=l.return}}var LC=Math.ceil,Bd=j.ReactCurrentDispatcher,wm=j.ReactCurrentOwner,Mo=j.ReactCurrentBatchConfig,pn=0,Er=null,ur=null,Ar=0,vo=0,gl=oi(0),wr=0,Pc=null,ta=0,Ud=0,ym=0,Dc=null,no=null,vm=0,kl=1/0,js=null,Hd=!1,bm=null,ui=null,Wd=!1,di=null,Kd=0,zc=0,xm=null,qd=-1,Zd=0;function Gr(){return(pn&6)!==0?Xt():qd!==-1?qd:qd=Xt()}function fi(i){return(i.mode&1)===0?1:(pn&2)!==0&&Ar!==0?Ar&-Ar:yC.transition!==null?(Zd===0&&(Zd=dn()),Zd):(i=Zt,i!==0||(i=window.event,i=i===void 0?16:Bi(i.type)),i)}function Vo(i,l,p,k){if(50<zc)throw zc=0,xm=null,Error(n(185));mr(i,p,k),((pn&2)===0||i!==Er)&&(i===Er&&((pn&2)===0&&(Ud|=p),wr===4&&hi(i,Ar)),ro(i,k),p===1&&pn===0&&(l.mode&1)===0&&(kl=Xt()+500,bd&&ii()))}function ro(i,l){var p=i.callbackNode;qt(i,l);var k=we(i,i===Er?Ar:0);if(k===0)p!==null&&Ln(p),i.callbackNode=null,i.callbackPriority=0;else if(l=k&-k,i.callbackPriority!==l){if(p!=null&&Ln(p),l===1)i.tag===0?wC(m0.bind(null,i)):ev(m0.bind(null,i)),pC(function(){(pn&6)===0&&ii()}),p=null;else{switch(Nt(k)){case 1:p=ft;break;case 4:p=Un;break;case 16:p=ot;break;case 536870912:p=qe;break;default:p=ot}p=E0(p,p0.bind(null,i))}i.callbackPriority=l,i.callbackNode=p}}function p0(i,l){if(qd=-1,Zd=0,(pn&6)!==0)throw Error(n(327));var p=i.callbackNode;if(wl()&&i.callbackNode!==p)return null;var k=we(i,i===Er?Ar:0);if(k===0)return null;if((k&30)!==0||(k&i.expiredLanes)!==0||l)l=Gd(i,k);else{l=k;var b=pn;pn|=2;var E=k0();(Er!==i||Ar!==l)&&(js=null,kl=Xt()+500,ra(i,l));do try{zC();break}catch(G){g0(i,G)}while(!0);Fp(),Bd.current=E,pn=b,ur!==null?l=0:(Er=null,Ar=0,l=wr)}if(l!==0){if(l===2&&(b=wt(i),b!==0&&(k=b,l=Em(i,b))),l===1)throw p=Pc,ra(i,0),hi(i,k),ro(i,Xt()),p;if(l===6)hi(i,k);else{if(b=i.current.alternate,(k&30)===0&&!PC(b)&&(l=Gd(i,k),l===2&&(E=wt(i),E!==0&&(k=E,l=Em(i,E))),l===1))throw p=Pc,ra(i,0),hi(i,k),ro(i,Xt()),p;switch(i.finishedWork=b,i.finishedLanes=k,l){case 0:case 1:throw Error(n(345));case 2:oa(i,no,js);break;case 3:if(hi(i,k),(k&130023424)===k&&(l=vm+500-Xt(),10<l)){if(we(i,0)!==0)break;if(b=i.suspendedLanes,(b&k)!==k){Gr(),i.pingedLanes|=i.suspendedLanes&b;break}i.timeoutHandle=$p(oa.bind(null,i,no,js),l);break}oa(i,no,js);break;case 4:if(hi(i,k),(k&4194240)===k)break;for(l=i.eventTimes,b=-1;0<k;){var R=31-Wt(k);E=1<<R,R=l[R],R>b&&(b=R),k&=~E}if(k=b,k=Xt()-k,k=(120>k?120:480>k?480:1080>k?1080:1920>k?1920:3e3>k?3e3:4320>k?4320:1960*LC(k/1960))-k,10<k){i.timeoutHandle=$p(oa.bind(null,i,no,js),k);break}oa(i,no,js);break;case 5:oa(i,no,js);break;default:throw Error(n(329))}}}return ro(i,Xt()),i.callbackNode===p?p0.bind(null,i):null}function Em(i,l){var p=Dc;return i.current.memoizedState.isDehydrated&&(ra(i,l).flags|=256),i=Gd(i,l),i!==2&&(l=no,no=p,l!==null&&Sm(l)),i}function Sm(i){no===null?no=i:no.push.apply(no,i)}function PC(i){for(var l=i;;){if(l.flags&16384){var p=l.updateQueue;if(p!==null&&(p=p.stores,p!==null))for(var k=0;k<p.length;k++){var b=p[k],E=b.getSnapshot;b=b.value;try{if(!go(E(),b))return!1}catch{return!1}}}if(p=l.child,l.subtreeFlags&16384&&p!==null)p.return=l,l=p;else{if(l===i)break;for(;l.sibling===null;){if(l.return===null||l.return===i)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function hi(i,l){for(l&=~ym,l&=~Ud,i.suspendedLanes|=l,i.pingedLanes&=~l,i=i.expirationTimes;0<l;){var p=31-Wt(l),k=1<<p;i[p]=-1,l&=~k}}function m0(i){if((pn&6)!==0)throw Error(n(327));wl();var l=we(i,0);if((l&1)===0)return ro(i,Xt()),null;var p=Gd(i,l);if(i.tag!==0&&p===2){var k=wt(i);k!==0&&(l=k,p=Em(i,k))}if(p===1)throw p=Pc,ra(i,0),hi(i,l),ro(i,Xt()),p;if(p===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=l,oa(i,no,js),ro(i,Xt()),null}function _m(i,l){var p=pn;pn|=1;try{return i(l)}finally{pn=p,pn===0&&(kl=Xt()+500,bd&&ii())}}function na(i){di!==null&&di.tag===0&&(pn&6)===0&&wl();var l=pn;pn|=1;var p=Mo.transition,k=Zt;try{if(Mo.transition=null,Zt=1,i)return i()}finally{Zt=k,Mo.transition=p,pn=l,(pn&6)===0&&ii()}}function Nm(){vo=gl.current,Fn(gl)}function ra(i,l){i.finishedWork=null,i.finishedLanes=0;var p=i.timeoutHandle;if(p!==-1&&(i.timeoutHandle=-1,hC(p)),ur!==null)for(p=ur.return;p!==null;){var k=p;switch(Mp(k),k.tag){case 1:k=k.type.childContextTypes,k!=null&&yd();break;case 3:hl(),Fn(Jr),Fn(Pr),Gp();break;case 5:qp(k);break;case 4:hl();break;case 13:Fn(Yn);break;case 19:Fn(Yn);break;case 10:Bp(k.type._context);break;case 22:case 23:Nm()}p=p.return}if(Er=i,ur=i=pi(i.current,null),Ar=vo=l,wr=0,Pc=null,ym=Ud=ta=0,no=Dc=null,Qi!==null){for(l=0;l<Qi.length;l++)if(p=Qi[l],k=p.interleaved,k!==null){p.interleaved=null;var b=k.next,E=p.pending;if(E!==null){var R=E.next;E.next=b,k.next=R}p.pending=k}Qi=null}return i}function g0(i,l){do{var p=ur;try{if(Fp(),Ad.current=Md,Id){for(var k=Xn.memoizedState;k!==null;){var b=k.queue;b!==null&&(b.pending=null),k=k.next}Id=!1}if(ea=0,xr=kr=Xn=null,Ac=!1,Ic=0,wm.current=null,p===null||p.return===null){wr=1,Pc=l,ur=null;break}e:{var E=i,R=p.return,G=p,ee=l;if(l=Ar,G.flags|=32768,ee!==null&&typeof ee=="object"&&typeof ee.then=="function"){var ye=ee,Ie=G,Pe=Ie.tag;if((Ie.mode&1)===0&&(Pe===0||Pe===11||Pe===15)){var Ae=Ie.alternate;Ae?(Ie.updateQueue=Ae.updateQueue,Ie.memoizedState=Ae.memoizedState,Ie.lanes=Ae.lanes):(Ie.updateQueue=null,Ie.memoizedState=null)}var Xe=Bv(R);if(Xe!==null){Xe.flags&=-257,Uv(Xe,R,G,E,l),Xe.mode&1&&Fv(E,ye,l),l=Xe,ee=ye;var nt=l.updateQueue;if(nt===null){var st=new Set;st.add(ee),l.updateQueue=st}else nt.add(ee);break e}else{if((l&1)===0){Fv(E,ye,l),Tm();break e}ee=Error(n(426))}}else if(Wn&&G.mode&1){var lr=Bv(R);if(lr!==null){(lr.flags&65536)===0&&(lr.flags|=256),Uv(lr,R,G,E,l),Dp(pl(ee,G));break e}}E=ee=pl(ee,G),wr!==4&&(wr=2),Dc===null?Dc=[E]:Dc.push(E),E=R;do{switch(E.tag){case 3:E.flags|=65536,l&=-l,E.lanes|=l;var he=Dv(E,ee,l);dv(E,he);break e;case 1:G=ee;var oe=E.type,me=E.stateNode;if((E.flags&128)===0&&(typeof oe.getDerivedStateFromError=="function"||me!==null&&typeof me.componentDidCatch=="function"&&(ui===null||!ui.has(me)))){E.flags|=65536,l&=-l,E.lanes|=l;var Fe=zv(E,G,l);dv(E,Fe);break e}}E=E.return}while(E!==null)}y0(p)}catch(it){l=it,ur===p&&p!==null&&(ur=p=p.return);continue}break}while(!0)}function k0(){var i=Bd.current;return Bd.current=Md,i===null?Md:i}function Tm(){(wr===0||wr===3||wr===2)&&(wr=4),Er===null||(ta&268435455)===0&&(Ud&268435455)===0||hi(Er,Ar)}function Gd(i,l){var p=pn;pn|=2;var k=k0();(Er!==i||Ar!==l)&&(js=null,ra(i,l));do try{DC();break}catch(b){g0(i,b)}while(!0);if(Fp(),pn=p,Bd.current=k,ur!==null)throw Error(n(261));return Er=null,Ar=0,wr}function DC(){for(;ur!==null;)w0(ur)}function zC(){for(;ur!==null&&!Or();)w0(ur)}function w0(i){var l=x0(i.alternate,i,vo);i.memoizedProps=i.pendingProps,l===null?y0(i):ur=l,wm.current=null}function y0(i){var l=i;do{var p=l.alternate;if(i=l.return,(l.flags&32768)===0){if(p=AC(p,l,vo),p!==null){ur=p;return}}else{if(p=IC(p,l),p!==null){p.flags&=32767,ur=p;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{wr=6,ur=null;return}}if(l=l.sibling,l!==null){ur=l;return}ur=l=i}while(l!==null);wr===0&&(wr=5)}function oa(i,l,p){var k=Zt,b=Mo.transition;try{Mo.transition=null,Zt=1,FC(i,l,p,k)}finally{Mo.transition=b,Zt=k}return null}function FC(i,l,p,k){do wl();while(di!==null);if((pn&6)!==0)throw Error(n(327));p=i.finishedWork;var b=i.finishedLanes;if(p===null)return null;if(i.finishedWork=null,i.finishedLanes=0,p===i.current)throw Error(n(177));i.callbackNode=null,i.callbackPriority=0;var E=p.lanes|p.childLanes;if(ar(i,E),i===Er&&(ur=Er=null,Ar=0),(p.subtreeFlags&2064)===0&&(p.flags&2064)===0||Wd||(Wd=!0,E0(ot,function(){return wl(),null})),E=(p.flags&15990)!==0,(p.subtreeFlags&15990)!==0||E){E=Mo.transition,Mo.transition=null;var R=Zt;Zt=1;var G=pn;pn|=4,wm.current=null,OC(i,p),c0(p,i),dd(Tp),$o=!!Np,Tp=Np=null,i.current=p,MC(p),Gn(),pn=G,Zt=R,Mo.transition=E}else i.current=p;if(Wd&&(Wd=!1,di=i,Kd=b),E=i.pendingLanes,E===0&&(ui=null),fn(p.stateNode),ro(i,Xt()),l!==null)for(k=i.onRecoverableError,p=0;p<l.length;p++)b=l[p],k(b.value,{componentStack:b.stack,digest:b.digest});if(Hd)throw Hd=!1,i=bm,bm=null,i;return(Kd&1)!==0&&i.tag!==0&&wl(),E=i.pendingLanes,(E&1)!==0?i===xm?zc++:(zc=0,xm=i):zc=0,ii(),null}function wl(){if(di!==null){var i=Nt(Kd),l=Mo.transition,p=Zt;try{if(Mo.transition=null,Zt=16>i?16:i,di===null)var k=!1;else{if(i=di,di=null,Kd=0,(pn&6)!==0)throw Error(n(331));var b=pn;for(pn|=4,et=i.current;et!==null;){var E=et,R=E.child;if((et.flags&16)!==0){var G=E.deletions;if(G!==null){for(var ee=0;ee<G.length;ee++){var ye=G[ee];for(et=ye;et!==null;){var Ie=et;switch(Ie.tag){case 0:case 11:case 15:Lc(8,Ie,E)}var Pe=Ie.child;if(Pe!==null)Pe.return=Ie,et=Pe;else for(;et!==null;){Ie=et;var Ae=Ie.sibling,Xe=Ie.return;if(o0(Ie),Ie===ye){et=null;break}if(Ae!==null){Ae.return=Xe,et=Ae;break}et=Xe}}}var nt=E.alternate;if(nt!==null){var st=nt.child;if(st!==null){nt.child=null;do{var lr=st.sibling;st.sibling=null,st=lr}while(st!==null)}}et=E}}if((E.subtreeFlags&2064)!==0&&R!==null)R.return=E,et=R;else e:for(;et!==null;){if(E=et,(E.flags&2048)!==0)switch(E.tag){case 0:case 11:case 15:Lc(9,E,E.return)}var he=E.sibling;if(he!==null){he.return=E.return,et=he;break e}et=E.return}}var oe=i.current;for(et=oe;et!==null;){R=et;var me=R.child;if((R.subtreeFlags&2064)!==0&&me!==null)me.return=R,et=me;else e:for(R=oe;et!==null;){if(G=et,(G.flags&2048)!==0)try{switch(G.tag){case 0:case 11:case 15:Fd(9,G)}}catch(it){sr(G,G.return,it)}if(G===R){et=null;break e}var Fe=G.sibling;if(Fe!==null){Fe.return=G.return,et=Fe;break e}et=G.return}}if(pn=b,ii(),ut&&typeof ut.onPostCommitFiberRoot=="function")try{ut.onPostCommitFiberRoot(kt,i)}catch{}k=!0}return k}finally{Zt=p,Mo.transition=l}}return!1}function v0(i,l,p){l=pl(p,l),l=Dv(i,l,1),i=li(i,l,1),l=Gr(),i!==null&&(mr(i,1,l),ro(i,l))}function sr(i,l,p){if(i.tag===3)v0(i,i,p);else for(;l!==null;){if(l.tag===3){v0(l,i,p);break}else if(l.tag===1){var k=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof k.componentDidCatch=="function"&&(ui===null||!ui.has(k))){i=pl(p,i),i=zv(l,i,1),l=li(l,i,1),i=Gr(),l!==null&&(mr(l,1,i),ro(l,i));break}}l=l.return}}function BC(i,l,p){var k=i.pingCache;k!==null&&k.delete(l),l=Gr(),i.pingedLanes|=i.suspendedLanes&p,Er===i&&(Ar&p)===p&&(wr===4||wr===3&&(Ar&130023424)===Ar&&500>Xt()-vm?ra(i,0):ym|=p),ro(i,l)}function b0(i,l){l===0&&((i.mode&1)===0?l=1:(l=br,br<<=1,(br&130023424)===0&&(br=4194304)));var p=Gr();i=_s(i,l),i!==null&&(mr(i,l,p),ro(i,p))}function UC(i){var l=i.memoizedState,p=0;l!==null&&(p=l.retryLane),b0(i,p)}function HC(i,l){var p=0;switch(i.tag){case 13:var k=i.stateNode,b=i.memoizedState;b!==null&&(p=b.retryLane);break;case 19:k=i.stateNode;break;default:throw Error(n(314))}k!==null&&k.delete(l),b0(i,p)}var x0;x0=function(i,l,p){if(i!==null)if(i.memoizedProps!==l.pendingProps||Jr.current)to=!0;else{if((i.lanes&p)===0&&(l.flags&128)===0)return to=!1,CC(i,l,p);to=(i.flags&131072)!==0}else to=!1,Wn&&(l.flags&1048576)!==0&&tv(l,Ed,l.index);switch(l.lanes=0,l.tag){case 2:var k=l.type;Dd(i,l),i=l.pendingProps;var b=il(l,Pr.current);fl(l,p),b=Xp(null,l,k,i,b,p);var E=Qp();return l.flags|=1,typeof b=="object"&&b!==null&&typeof b.render=="function"&&b.$$typeof===void 0?(l.tag=1,l.memoizedState=null,l.updateQueue=null,eo(k)?(E=!0,vd(l)):E=!1,l.memoizedState=b.state!==null&&b.state!==void 0?b.state:null,Wp(l),b.updater=Ld,l.stateNode=b,b._reactInternals=l,om(l,k,i,p),l=lm(null,l,k,!0,E,p)):(l.tag=0,Wn&&E&&Op(l),Zr(null,l,b,p),l=l.child),l;case 16:k=l.elementType;e:{switch(Dd(i,l),i=l.pendingProps,b=k._init,k=b(k._payload),l.type=k,b=l.tag=KC(k),i=qo(k,i),b){case 0:l=am(null,l,k,i,p);break e;case 1:l=Gv(null,l,k,i,p);break e;case 11:l=Hv(null,l,k,i,p);break e;case 14:l=Wv(null,l,k,qo(k.type,i),p);break e}throw Error(n(306,k,""))}return l;case 0:return k=l.type,b=l.pendingProps,b=l.elementType===k?b:qo(k,b),am(i,l,k,b,p);case 1:return k=l.type,b=l.pendingProps,b=l.elementType===k?b:qo(k,b),Gv(i,l,k,b,p);case 3:e:{if(Vv(l),i===null)throw Error(n(387));k=l.pendingProps,E=l.memoizedState,b=E.element,uv(i,l),$d(l,k,null,p);var R=l.memoizedState;if(k=R.element,E.isDehydrated)if(E={element:k,isDehydrated:!1,cache:R.cache,pendingSuspenseBoundaries:R.pendingSuspenseBoundaries,transitions:R.transitions},l.updateQueue.baseState=E,l.memoizedState=E,l.flags&256){b=pl(Error(n(423)),l),l=Yv(i,l,k,p,b);break e}else if(k!==b){b=pl(Error(n(424)),l),l=Yv(i,l,k,p,b);break e}else for(yo=ri(l.stateNode.containerInfo.firstChild),wo=l,Wn=!0,Ko=null,p=lv(l,null,k,p),l.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(cl(),k===b){l=Ts(i,l,p);break e}Zr(i,l,k,p)}l=l.child}return l;case 5:return hv(l),i===null&&Pp(l),k=l.type,b=l.pendingProps,E=i!==null?i.memoizedProps:null,R=b.children,jp(k,b)?R=null:E!==null&&jp(k,E)&&(l.flags|=32),Zv(i,l),Zr(i,l,R,p),l.child;case 6:return i===null&&Pp(l),null;case 13:return Xv(i,l,p);case 4:return Kp(l,l.stateNode.containerInfo),k=l.pendingProps,i===null?l.child=ul(l,null,k,p):Zr(i,l,k,p),l.child;case 11:return k=l.type,b=l.pendingProps,b=l.elementType===k?b:qo(k,b),Hv(i,l,k,b,p);case 7:return Zr(i,l,l.pendingProps,p),l.child;case 8:return Zr(i,l,l.pendingProps.children,p),l.child;case 12:return Zr(i,l,l.pendingProps.children,p),l.child;case 10:e:{if(k=l.type._context,b=l.pendingProps,E=l.memoizedProps,R=b.value,In(Nd,k._currentValue),k._currentValue=R,E!==null)if(go(E.value,R)){if(E.children===b.children&&!Jr.current){l=Ts(i,l,p);break e}}else for(E=l.child,E!==null&&(E.return=l);E!==null;){var G=E.dependencies;if(G!==null){R=E.child;for(var ee=G.firstContext;ee!==null;){if(ee.context===k){if(E.tag===1){ee=Ns(-1,p&-p),ee.tag=2;var ye=E.updateQueue;if(ye!==null){ye=ye.shared;var Ie=ye.pending;Ie===null?ee.next=ee:(ee.next=Ie.next,Ie.next=ee),ye.pending=ee}}E.lanes|=p,ee=E.alternate,ee!==null&&(ee.lanes|=p),Up(E.return,p,l),G.lanes|=p;break}ee=ee.next}}else if(E.tag===10)R=E.type===l.type?null:E.child;else if(E.tag===18){if(R=E.return,R===null)throw Error(n(341));R.lanes|=p,G=R.alternate,G!==null&&(G.lanes|=p),Up(R,p,l),R=E.sibling}else R=E.child;if(R!==null)R.return=E;else for(R=E;R!==null;){if(R===l){R=null;break}if(E=R.sibling,E!==null){E.return=R.return,R=E;break}R=R.return}E=R}Zr(i,l,b.children,p),l=l.child}return l;case 9:return b=l.type,k=l.pendingProps.children,fl(l,p),b=Ro(b),k=k(b),l.flags|=1,Zr(i,l,k,p),l.child;case 14:return k=l.type,b=qo(k,l.pendingProps),b=qo(k.type,b),Wv(i,l,k,b,p);case 15:return Kv(i,l,l.type,l.pendingProps,p);case 17:return k=l.type,b=l.pendingProps,b=l.elementType===k?b:qo(k,b),Dd(i,l),l.tag=1,eo(k)?(i=!0,vd(l)):i=!1,fl(l,p),Lv(l,k,b),om(l,k,b,p),lm(null,l,k,!0,i,p);case 19:return Jv(i,l,p);case 22:return qv(i,l,p)}throw Error(n(156,l.tag))};function E0(i,l){return jt(i,l)}function WC(i,l,p,k){this.tag=i,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=l,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 Lo(i,l,p,k){return new WC(i,l,p,k)}function jm(i){return i=i.prototype,!(!i||!i.isReactComponent)}function KC(i){if(typeof i=="function")return jm(i)?1:0;if(i!=null){if(i=i.$$typeof,i===H)return 11;if(i===Q)return 14}return 2}function pi(i,l){var p=i.alternate;return p===null?(p=Lo(i.tag,l,i.key,i.mode),p.elementType=i.elementType,p.type=i.type,p.stateNode=i.stateNode,p.alternate=i,i.alternate=p):(p.pendingProps=l,p.type=i.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=i.flags&14680064,p.childLanes=i.childLanes,p.lanes=i.lanes,p.child=i.child,p.memoizedProps=i.memoizedProps,p.memoizedState=i.memoizedState,p.updateQueue=i.updateQueue,l=i.dependencies,p.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},p.sibling=i.sibling,p.index=i.index,p.ref=i.ref,p}function Vd(i,l,p,k,b,E){var R=2;if(k=i,typeof i=="function")jm(i)&&(R=1);else if(typeof i=="string")R=5;else e:switch(i){case A:return sa(p.children,b,E,l);case M:R=8,b|=8;break;case O:return i=Lo(12,p,l,b|2),i.elementType=O,i.lanes=E,i;case Y:return i=Lo(13,p,l,b),i.elementType=Y,i.lanes=E,i;case ie:return i=Lo(19,p,l,b),i.elementType=ie,i.lanes=E,i;case U:return Yd(p,b,E,l);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case z:R=10;break e;case B:R=9;break e;case H:R=11;break e;case Q:R=14;break e;case le:R=16,k=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return l=Lo(R,p,l,b),l.elementType=i,l.type=k,l.lanes=E,l}function sa(i,l,p,k){return i=Lo(7,i,k,l),i.lanes=p,i}function Yd(i,l,p,k){return i=Lo(22,i,k,l),i.elementType=U,i.lanes=p,i.stateNode={isHidden:!1},i}function $m(i,l,p){return i=Lo(6,i,null,l),i.lanes=p,i}function Cm(i,l,p){return l=Lo(4,i.children!==null?i.children:[],i.key,l),l.lanes=p,l.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},l}function qC(i,l,p,k,b){this.tag=l,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=ir(0),this.expirationTimes=ir(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ir(0),this.identifierPrefix=k,this.onRecoverableError=b,this.mutableSourceEagerHydrationData=null}function Am(i,l,p,k,b,E,R,G,ee){return i=new qC(i,l,p,G,ee),l===1?(l=1,E===!0&&(l|=8)):l=0,E=Lo(3,null,null,l),i.current=E,E.stateNode=i,E.memoizedState={element:k,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Wp(E),i}function ZC(i,l,p){var k=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:I,key:k==null?null:""+k,children:i,containerInfo:l,implementation:p}}function S0(i){if(!i)return si;i=i._reactInternals;e:{if(rn(i)!==i||i.tag!==1)throw Error(n(170));var l=i;do{switch(l.tag){case 3:l=l.stateNode.context;break e;case 1:if(eo(l.type)){l=l.stateNode.__reactInternalMemoizedMergedChildContext;break e}}l=l.return}while(l!==null);throw Error(n(171))}if(i.tag===1){var p=i.type;if(eo(p))return Qy(i,p,l)}return l}function _0(i,l,p,k,b,E,R,G,ee){return i=Am(p,k,!0,i,b,E,R,G,ee),i.context=S0(null),p=i.current,k=Gr(),b=fi(p),E=Ns(k,b),E.callback=l??null,li(p,E,b),i.current.lanes=b,mr(i,b,k),ro(i,k),i}function Xd(i,l,p,k){var b=l.current,E=Gr(),R=fi(b);return p=S0(p),l.context===null?l.context=p:l.pendingContext=p,l=Ns(E,R),l.payload={element:i},k=k===void 0?null:k,k!==null&&(l.callback=k),i=li(b,l,R),i!==null&&(Vo(i,b,R,E),jd(i,b,R)),R}function Qd(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 N0(i,l){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var p=i.retryLane;i.retryLane=p!==0&&p<l?p:l}}function Im(i,l){N0(i,l),(i=i.alternate)&&N0(i,l)}function GC(){return null}var T0=typeof reportError=="function"?reportError:function(i){console.error(i)};function Rm(i){this._internalRoot=i}Jd.prototype.render=Rm.prototype.render=function(i){var l=this._internalRoot;if(l===null)throw Error(n(409));Xd(i,l,null,null)},Jd.prototype.unmount=Rm.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var l=i.containerInfo;na(function(){Xd(null,i,null,null)}),l[bs]=null}};function Jd(i){this._internalRoot=i}Jd.prototype.unstable_scheduleHydration=function(i){if(i){var l=qr();i={blockedOn:null,target:i,priority:l};for(var p=0;p<Ot.length&&l!==0&&l<Ot[p].priority;p++);Ot.splice(p,0,i),p===0&&rr(i)}};function Om(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function ef(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function j0(){}function VC(i,l,p,k,b){if(b){if(typeof k=="function"){var E=k;k=function(){var ye=Qd(R);E.call(ye)}}var R=_0(l,k,i,0,null,!1,!1,"",j0);return i._reactRootContainer=R,i[bs]=R.current,Ec(i.nodeType===8?i.parentNode:i),na(),R}for(;b=i.lastChild;)i.removeChild(b);if(typeof k=="function"){var G=k;k=function(){var ye=Qd(ee);G.call(ye)}}var ee=Am(i,0,!1,null,null,!1,!1,"",j0);return i._reactRootContainer=ee,i[bs]=ee.current,Ec(i.nodeType===8?i.parentNode:i),na(function(){Xd(l,ee,p,k)}),ee}function tf(i,l,p,k,b){var E=p._reactRootContainer;if(E){var R=E;if(typeof b=="function"){var G=b;b=function(){var ee=Qd(R);G.call(ee)}}Xd(l,R,i,b)}else R=VC(p,l,i,b,k);return Qd(R)}jo=function(i){switch(i.tag){case 3:var l=i.stateNode;if(l.current.memoizedState.isDehydrated){var p=Z(l.pendingLanes);p!==0&&(po(l,p|1),ro(l,Xt()),(pn&6)===0&&(kl=Xt()+500,ii()))}break;case 13:na(function(){var k=_s(i,1);if(k!==null){var b=Gr();Vo(k,i,1,b)}}),Im(i,1)}},Tn=function(i){if(i.tag===13){var l=_s(i,134217728);if(l!==null){var p=Gr();Vo(l,i,134217728,p)}Im(i,134217728)}},Jt=function(i){if(i.tag===13){var l=fi(i),p=_s(i,l);if(p!==null){var k=Gr();Vo(p,i,l,k)}Im(i,l)}},qr=function(){return Zt},Mr=function(i,l){var p=Zt;try{return Zt=i,l()}finally{Zt=p}},Qe=function(i,l,p){switch(l){case"input":if(We(i,p),l=p.name,p.type==="radio"&&l!=null){for(p=i;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll("input[name="+JSON.stringify(""+l)+'][type="radio"]'),l=0;l<p.length;l++){var k=p[l];if(k!==i&&k.form===i.form){var b=wd(k);if(!b)throw Error(n(90));ae(k),We(k,b)}}}break;case"textarea":pt(i,p);break;case"select":l=p.value,l!=null&&gt(i,!!p.multiple,l,!1)}},Se=_m,Ge=na;var YC={usingClientEntryPoint:!1,Events:[Nc,ol,wd,P,ne,_m]},Fc={findFiberByHostInstance:Gi,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},XC={bundleType:Fc.bundleType,version:Fc.version,rendererPackageName:Fc.rendererPackageName,rendererConfig:Fc.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=rt(i),i===null?null:i.stateNode},findFiberByHostInstance:Fc.findFiberByHostInstance||GC,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 nf=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!nf.isDisabled&&nf.supportsFiber)try{kt=nf.inject(XC),ut=nf}catch{}}return oo.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=YC,oo.createPortal=function(i,l){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Om(l))throw Error(n(200));return ZC(i,l,null,p)},oo.createRoot=function(i,l){if(!Om(i))throw Error(n(299));var p=!1,k="",b=T0;return l!=null&&(l.unstable_strictMode===!0&&(p=!0),l.identifierPrefix!==void 0&&(k=l.identifierPrefix),l.onRecoverableError!==void 0&&(b=l.onRecoverableError)),l=Am(i,1,!1,null,null,p,!1,k,b),i[bs]=l.current,Ec(i.nodeType===8?i.parentNode:i),new Rm(l)},oo.findDOMNode=function(i){if(i==null)return null;if(i.nodeType===1)return i;var l=i._reactInternals;if(l===void 0)throw typeof i.render=="function"?Error(n(188)):(i=Object.keys(i).join(","),Error(n(268,i)));return i=rt(l),i=i===null?null:i.stateNode,i},oo.flushSync=function(i){return na(i)},oo.hydrate=function(i,l,p){if(!ef(l))throw Error(n(200));return tf(null,i,l,!0,p)},oo.hydrateRoot=function(i,l,p){if(!Om(i))throw Error(n(405));var k=p!=null&&p.hydratedSources||null,b=!1,E="",R=T0;if(p!=null&&(p.unstable_strictMode===!0&&(b=!0),p.identifierPrefix!==void 0&&(E=p.identifierPrefix),p.onRecoverableError!==void 0&&(R=p.onRecoverableError)),l=_0(l,null,i,1,p??null,b,!1,E,R),i[bs]=l.current,Ec(i),k)for(i=0;i<k.length;i++)p=k[i],b=p._getVersion,b=b(p._source),l.mutableSourceEagerHydrationData==null?l.mutableSourceEagerHydrationData=[p,b]:l.mutableSourceEagerHydrationData.push(p,b);return new Jd(l)},oo.render=function(i,l,p){if(!ef(l))throw Error(n(200));return tf(null,i,l,!1,p)},oo.unmountComponentAtNode=function(i){if(!ef(i))throw Error(n(40));return i._reactRootContainer?(na(function(){tf(null,null,i,!1,function(){i._reactRootContainer=null,i[bs]=null})}),!0):!1},oo.unstable_batchedUpdates=_m,oo.unstable_renderSubtreeIntoContainer=function(i,l,p,k){if(!ef(p))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return tf(i,l,p,!1,k)},oo.version="18.3.1-next-f1338f8080-20240426",oo}var L0;function EE(){if(L0)return Pm.exports;L0=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(),Pm.exports=aA(),Pm.exports}var SE=EE(),rf={},P0;function lA(){if(P0)return rf;P0=1;var e=EE();return rf.createRoot=e.createRoot,rf.hydrateRoot=e.hydrateRoot,rf}var cA=lA();const $i="shell",_E="check",ba="ToolSearch",qk="AskUserQuestion",uA="handoff",dA="worktrees";function of(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 fA=new Set(["edit","delete","move","execute"]),hA=new Set(["Edit","Write","MultiEdit","NotebookEdit","Bash"]);function NE(e){return e.kind?fA.has(e.kind):hA.has(e.name)}const pA=["read","edit","delete","move","search","execute","fetch"];function Zk(e){return pA.includes(e??"")}function TE(e,t){return(Zk(e.kind)||e.name===qk||e.name===ba)&&wh(t)}const mA=/^(?:mcp__(.+?)__(.+)|([A-Za-z0-9_-]+)\/([A-Za-z0-9_-]+))$/;function gA(e){const t=mA.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 wh(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 yh=[{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"}],jg="auto";function kA(e){return e.branch.startsWith("toyon/")}function wA(e){return e.unread===!0||e.lastTurn!=null&&(e.seenAt==null||e.seenAt<e.lastTurn.at)}const Do="shell",Ls="login";function yA(e,t){return`${e}/${t}`}function vA(e,t,n,r=0){var s;let o=e;for(let a=r;a>0;a--){let c=o.length-1;for(;c>=0&&((s=o[c])==null?void 0:s.proc)!==t;)c--;if(c<0)break;o=o===e?[...o]:o,o.splice(c,1)}return n?[...o,{proc:t,line:n}]:o}const os=e=>e==="working"||e==="waiting",bA=["use","always","off"];function jE(e){return e.find(t=>t.id==="default")}function xA(e,t){const n=jE(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 EA(e,t){if(t.some(o=>o.id===e))return e;const n=D0(e);if(n===void 0)return;if(t.some(o=>o.id===n))return n;if(n!==Gk(e))return;let r;for(const o of t){if(D0(o.id)!==n)continue;const s=SA(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 $E=/(?:^|[./])claude-(?:(\d{1,2})(?:-(\d{1,2})(?!\d))?-)?([a-z]+)(?:-(\d{1,2})(?!\d)(?:-(\d{1,2})(?!\d))?)?/;function Gk(e){return e.replace(/\[[^\]]*\]$/,"")}function D0(e){var r;const t=Gk(e),n=(r=t.match($E))==null?void 0:r[3];return n||(/^[a-z]+$/.test(t)?t:void 0)}function SA(e){const t=Gk(e).match($E);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 Sn(e){return e.worktree!==void 0}function xa(e){return e.kind==="main"}function Lu(e){return e.kind==="spare"}function Tr(e){return Lu(e)||xa(e)}function vh(e){return e.kind==="worktree"}function CE(e){return e.kind==="worktree"&&kA(e)}function da(e){var t;return e.kind==="worktree"&&((t=e.from)==null?void 0:t.kind)!=="pr"}function jf(e){return e.kind==="worktree"}function bh(e){return!!e.branch&&!e.locked&&!(e.worktree&&Tr(e.worktree))}const Ea=e=>{var t;return e.promptedAt??((t=e.lastTurn)==null?void 0:t.at)??e.createdAt},z0=e=>Tr(e)?0:1;function _A(e){return[...e].sort((t,n)=>z0(t.worktree)-z0(n.worktree)||Ea(n.worktree)-Ea(t.worktree))}function F0(e,t){const n=new Map;for(const r of e)n.set(r.id,r.promptedAt??0);for(const r of t){if(!Sn(r)||r.worktree.kind==="spare")continue;const o=r.worktree.repoId;n.set(o,Math.max(n.get(o)??0,Ea(r.worktree)))}return[...e].sort((r,o)=>(n.get(o.id)??0)-(n.get(r.id)??0))}function NA(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":wA(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 B0="not opened in ";function TA(e){const t=e.lastIndexOf(B0);return t<0?{what:e}:{what:e.slice(0,t).replace(/,\s*$/,""),idle:e.slice(t+B0.length)}}const AE={image:6,paste:4,file:8,pick:8},jA={image:"image",paste:"paste",file:"file",pick:"element"},$A={image:"Image",paste:"Pasted text"},IE=(e,t)=>`${$A[e]} ${t}`,Vk=e=>`at most ${AE[e]} ${jA[e]}s per message`,CA=(e,t)=>e.filter(n=>n.kind===t).length,AA=(e,t)=>Math.max(0,AE[t]-CA(e,t));function $g(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 Yk(e,t){const n={...t};return e.map(r=>[r,n[r.kind]++])}function su(e,t){const n={...e};for(const r of t)n[r.kind]++;return n}function Xk(e){return e>=1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}const Rl=e=>`card:${e}`,$f=[{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},{id:"panel-tab-next",key:"ArrowRight",alt:!0,textKeeps:!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-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:"ArrowLeft",textKeeps:!0},{id:"forward",key:"ArrowRight",textKeeps:!0},{id:"close",key:"w"}],IA=new Set(["zen","close","back","forward"]);function RE(e,{guest:t=!1}={}){var r,o;if(e.altKey){if(e.metaKey||e.ctrlKey)return null;const s=$f.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=$f.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 $f){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 RA(e){return e.altKey||e.key.toLowerCase()!=="s"?!1:!!e.ctrlKey!==e.metaKey}function OE(e){const t=$f.find(n=>n.id===e);if(!t)throw new Error(`unknown chord ${e}`);return t}function OA(e,t){return e===t-1?"⌘9":e<8?`⌘${e+1}`:void 0}function MA(e,t){return t===0?null:e===9?t-1:e-1<t?e-1:null}function LA(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 PA(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 DA(e,t){const n=OE(e);return!!n.textKeeps&&LA(t)&&!(n.emptyGives&&PA(t))}const zA=["Find","Preview","Panels","Worktrees"],iu={"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-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"}},FA={ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Backspace:"⌫",Tab:"Tab"};function BA(e,t={}){var c;const n=OE(e),r=iu[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":FA[o]??o.toUpperCase(),a=o!==n.key&&o===((c=n.ctrlAlias)==null?void 0:c.key)?n.ctrlAlias:void 0;return a?`⌃${a.shift?"⇧":""}${s}`:`${n.alt?"⌥":n.ctrl?"⌃":"⌘"}${n.shift?"⇧":""}${s}`}function UA(e){return Object.keys(iu).filter(t=>iu[t].section===e&&!iu[t].hidden)}const U0={m:6e4,h:60*6e4};function HA(e){const[t,n]=WA(e);return`${t}${n.charAt(0)}`}function WA(e){const t=e/U0.h;if(t>=1&&Number.isInteger(t))return[t,"hour"];const n=e/U0.m;return n>=1&&Number.isInteger(n)?[n,"minute"]:n>=60?[Math.round(n),"minute"]:[Math.max(1,Math.round(e/1e3)),"second"]}const fu={folder:{shared:".toyon/settings.json",local:".toyon/settings.local.json"},root:{shared:"toyon.json",local:"toyon.local.json"}};function ME(e){return typeof e=="string"?e:e.cmd}function KA(e){return typeof e!="string"&&e.from==="trunk"}function qA(e){return[...e.setup??[],...e.teardown??[],...Object.values(e.run).map(ME),...Object.values(e.profiles??{}).flatMap(n=>Object.values(n.env??{}))].some(n=>n.includes("TOYON_WORKTREE"))}function ZA(e){return e===fu.folder.local||e===fu.root.local}function GA(e){return ZA(e)?"local":"shared"}function VA(e,t){return(Object.values(fu).find(r=>r.shared===e||r.local===e)??fu.folder)[t]}const YA=e=>`https://${e}/`;function XA(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 JA(n.origin)?n.origin:null}function QA(e){return e.toLowerCase().endsWith(".fly.dev")}function JA(e){let t;try{t=new URL(e)}catch{return!1}return t.origin!==e?!1:t.protocol==="https:"||t.protocol==="http:"&&Qk(t.hostname)}const eI="toyon_grant";function Qk(e){return e==="127.0.0.1"||e==="::1"||e==="[::1]"||e==="localhost"||e.endsWith(".localhost")}function tI(e,t,n){return e.replace("{id}",t).replace("{port}",String(n))}const nI=4401,rI=25e4;function oI(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(...sI(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 sI(e,t){if(e.length===0)return t.map(c=>({mark:"+",value:c}));if(t.length===0)return e.map(c=>({mark:"-",value:c}));if((e.length+1)*(t.length+1)>rI)return[...e.map(c=>({mark:"-",value:c})),...t.map(c=>({mark:"+",value:c}))];const n=t.length+1,r=new Uint32Array((e.length+1)*n);for(let c=e.length-1;c>=0;c--)for(let u=t.length-1;u>=0;u--)r[c*n+u]=e[c]===t[u]?(r[(c+1)*n+u+1]??0)+1:Math.max(r[(c+1)*n+u]??0,r[c*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 iI=/[\p{L}\p{N}_$]+|\s+|[^\s\p{L}\p{N}_$]/gu;function H0(e){return e.match(iI)??[]}const aI=.4;function lI(e,t){if(e===t)return null;const n=oI(H0(e),H0(t));let r=0;for(const o of n)o.mark===" "&&(r+=o.value.length);return r<aI*Math.max(e.length,t.length)?null:{before:W0(n,"-"),after:W0(n,"+")}}function W0(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 LE(n)}function K0(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(LE)}function LE(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 cI=[{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"}],uI=[{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"}],dI=[{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"}],Cg="merge",Ag="merge";function _i(e){var n,r,o;const t=((n=e.land)==null?void 0:n.route)??Cg;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 xh(e){return e.base??e.defaultBranch}function fI(e){return e.base!==void 0&&e.base!==e.defaultBranch}function hI(e){return!!e.pr&&(e.lands??[]).some(t=>{var n;return t.pr===((n=e.pr)==null?void 0:n.number)})}function pI(e){return{land:"a land",commit:"a commit","sync-main":"a sync","pull-main":"a pull"}[e]}function Eh(e){return hI(e)&&!e.landed?void 0:e.pr}function Jk(e,t){const n=Eh(t);return e.land==="pr"&&(!n||n.state==="closed")?"create pr":"land"}function Bf(e,t="main"){const n={merge:"merge into",squash:"squash onto",rebase:"rebase onto"}[e.merge??Ag];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"}}function PE(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 q0(e,t="|"){return e.map(n=>FE(n)).join(t)}function Ig(e,t){return typeof t=="bigint"?t.toString():t}function Sh(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function mI(e){return e==null}function ew(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function gI(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 uo(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ri(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function kI(e){return JSON.stringify(e)}function wI(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const DE="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function hu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const yI=Sh(()=>{var e;if(ss.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 pu(e){if(hu(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(hu(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function zE(e){return pu(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const vI=new Set(["string","number","symbol"]);function zl(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Oi(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 dt(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 FE(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function bI(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const xI={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 EI(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=Ri(e._zod.def,{get shape(){const a={};for(const c of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,c))throw new Error(`Unrecognized key: "${String(c)}"`);t[c]&&uo(a,c,n.shape[c])}return uo(this,"shape",a),a},checks:[]});return Oi(e,s)}function SI(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=Ri(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const c of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,c))throw new Error(`Unrecognized key: "${String(c)}"`);t[c]&&delete a[c]}return uo(this,"shape",a),a},checks:[]});return Oi(e,s)}function _I(e,t){if(!pu(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=Ri(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return uo(this,"shape",s),s}});return Oi(e,o)}function NI(e,t){if(!pu(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Ri(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return uo(this,"shape",r),r}});return Oi(e,n)}function TI(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=Ri(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t._zod.def.shape};return uo(this,"shape",s),s},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Oi(e,n)}function Z0(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 c=Ri(t._zod.def,{get shape(){const u=t._zod.def.shape,h={...u};if(n)for(const f of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(u,f))throw new Error(`Unrecognized key: "${String(f)}"`);n[f]&&(h[f]=e?new e({type:"optional",innerType:u[f]}):u[f])}else for(const f of Reflect.ownKeys(u))h[f]=e?new e({type:"optional",innerType:u[f]}):u[f];return uo(this,"shape",h),h},checks:[]});return Oi(t,c)}function jI(e,t,n){const r=Ri(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 uo(this,"shape",s),s}});return Oi(t,r)}function _l(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 $I(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 _h(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Uc(e){return typeof e=="string"?e:e==null?void 0:e.message}function G0(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function Yl(e,t,n){var g,y,w,v,_,x,N,T,j,C;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:Uc((N=(x=(_=e.inst)==null?void 0:_._zod.def)==null?void 0:x.error)==null?void 0:N.call(x,e))??Uc(s==null?void 0:s(e))??Uc((T=t==null?void 0:t.error)==null?void 0:T.call(t,e))??Uc((j=n.customError)==null?void 0:j.call(n,e))??Uc((C=n.localeError)==null?void 0:C.call(n,e))??"Invalid input",{inst:c,schema:u,continue:h,input:f,...m}=e;return m.path??(m.path=[]),m.message=a,t!=null&&t.reportInput&&(m.input=f),m}const CI=/[\uD800-\uDBFF]/;function tw(e){const t=e.length;if(!CI.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 nw(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function AI(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 mu(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function II(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):RI(e,n,r.value)}}function Fl(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function BE(e,t,n){return Fl(e,t,n,!1)}function RI(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Fl(this,t,n.bind(this))},set(r){Fl(this,t,r)}})}function OI(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let Fm,bi=!1;const MI={configurable:!0,get(){bi=!0}};function _n(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&Fm!==e._zod){Fm=void 0;return}Fm=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,MI);const o=bi;bi=!1;try{const s=n(this);return bi?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),bi=bi||o,s}catch(s){throw delete this[t],bi=bi||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function LI(e,t,n,r){const o=OI(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 PI="~constantCatch";function DI(e){const t=()=>e;return t[PI]=!0,t}var V0;const Bm={value:void 0,enumerable:!1};let Y0="captureStackTrace"in Error?Error:null;function zI(e){const t=Y0;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return Y0=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function _e(e,t,n,r){const o={};function s(g){this.def=g,this.constr=m,this.traits=new Set}s.prototype=o;const a=n,c=a&&new WeakSet;function u(g,y){if(!g._zod){Bm.value=new s(y);try{Object.defineProperty(g,"_zod",Bm)}finally{Bm.value=void 0}}if(g._zod.traits.has(e))return;if(g._zod.traits.add(e),t(g,y),c){const v=Object.getPrototypeOf(g),_=g._zod.constr.prototype;let x=v;for(;x&&x!==_;)x=Object.getPrototypeOf(x);const N=x??v;c.has(N)||(c.add(N),II(N,a))}const w=m.prototype;for(const v in w)Object.prototype.hasOwnProperty.call(w,v)&&(v in g||(g[v]=w[v].bind(g)))}const h=(r==null?void 0:r.Parent)??Object;class f extends h{}Object.defineProperty(f,"name",{value:e});function m(g){var _;const y=r!=null&&r.Parent?zI(f):this;u(y,g);const w=y._zod.deferred;if(w){for(const x of w)x();y._zod.deferred=void 0}const v=(_=globalThis.__zod_globalConfig)==null?void 0:_.postProcessor;return v&&v(y),y}return Object.defineProperty(m,"init",{value:u}),Object.defineProperty(m,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(m,"name",{value:e}),m}class Ol extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class UE extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(V0=globalThis).__zod_globalConfig??(V0.__zod_globalConfig={});const ss=globalThis.__zod_globalConfig;function Mi(e){return e&&Object.assign(ss,e),ss}function FI(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Ig,2)),e.message}function BI(e){this._zod.message=e}const UI={get:FI,set:BI,enumerable:!0,configurable:!0},Um={value:void 0,enumerable:!1},Hm={value:void 0,enumerable:!1},X0=new WeakSet([Object.prototype,Error.prototype]),HE=(e,t)=>{e.name="$ZodError",Um.value=e._zod,Object.defineProperty(e,"_zod",Um),Hm.value=t,Object.defineProperty(e,"issues",Hm),Um.value=void 0,Hm.value=void 0,Object.defineProperty(e,"message",UI);const n=Object.getPrototypeOf(e);X0.has(n)||(X0.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})}}))},WE=_e("$ZodError",HE),KE=_e("$ZodError",HE,void 0,{Parent:Error});function HI(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 WI(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?HI(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n}}function KI(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(c=>r({issues:c},[...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 c=[...s,...a.path];if(c.length===0)n._errors.push(t(a));else{let u=n,h=0;for(;h<c.length;){const f=c[h],m=h===c.length-1;if(f==="_errors"){m&&u._errors.push(t(a)),h++;continue}Object.prototype.hasOwnProperty.call(u,f)||Object.defineProperty(u,f,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const g=u[f];m&&g._errors.push(t(a)),u=g,h++}}}};return r(e),n}function Nh(e,t){return{callee:(t==null?void 0:t.callee)??e,Err:t==null?void 0:t.Err}}const rw=e=>{const t=(n,r,o,s)=>{const a=o?{...o,async:!1}:{async:!1},c=n._zod.run({value:r,issues:[]},a);if(c instanceof Promise)throw new Ol;if(c.issues.length){const u=new((s==null?void 0:s.Err)??e)(c.issues.map(h=>Yl(h,a,Mi())));throw DE(u,(s==null?void 0:s.callee)??t),u}return c.value};return t},ow=e=>{const t=async(n,r,o,s)=>{const a=o?{...o,async:!0}:{async:!0};let c=n._zod.run({value:r,issues:[]},a);if(c instanceof Promise&&(c=await c),c.issues.length){const u=new((s==null?void 0:s.Err)??e)(c.issues.map(h=>Yl(h,a,Mi())));throw DE(u,(s==null?void 0:s.callee)??t),u}return c.value};return t},Th=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 Ol;return s.issues.length?{success:!1,error:new(e??WE)(s.issues.map(a=>Yl(a,o,Mi())))}:{success:!0,data:s.value}},qI=Th(KE),jh=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=>Yl(a,o,Mi())))}:{success:!0,data:s.value}},ZI=jh(KE),GI=e=>{const t=rw(e),n=(r,o,s,a)=>{const c=s?{...s,direction:"backward"}:{direction:"backward"};return t(r,o,c,Nh(n,a))};return n},VI=e=>{const t=rw(e),n=(r,o,s,a)=>t(r,o,s,Nh(n,a));return n},YI=e=>{const t=ow(e),n=async(r,o,s,a)=>{const c=s?{...s,direction:"backward"}:{direction:"backward"};return await t(r,o,c,Nh(n,a))};return n},XI=e=>{const t=ow(e),n=async(r,o,s,a)=>await t(r,o,s,Nh(n,a));return n},QI=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Th(e)(t,n,o)},JI=e=>(t,n,r)=>Th(e)(t,n,r),eR=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return jh(e)(t,n,o)},tR=e=>async(t,n,r)=>jh(e)(t,n,r),nR=/^[cC][0-9a-z]{6,}$/,rR=/^[0-9a-z]+$/,oR=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,sR=/^[0-9a-vA-V]{20}$/,iR=/^[A-Za-z0-9]{27}$/,aR=/^[a-zA-Z0-9_-]{21}$/;function lR(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const cR=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,uR=/^([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})$/,Q0=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)$/,dR=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,fR="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function hR(){return new RegExp(fR,"u")}const pR=/^(?:(?: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])$/,mR=/^(([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}|:))$/,gR=/^((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])$/,kR=/^(([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])$/,wR=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,qE=/^[A-Za-z0-9_-]*$/,yR=/^https?$/,vR=/^\+[1-9]\d{6,14}$/,ZE="(?:(?:\\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 bR(e){return new RegExp(`^${e}$`)}const xR=bR(ZE);function Rg(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 ER(e){return new RegExp(`^${Rg(e)}$`)}function SR(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${Rg({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${Rg({precision:e.precision})}`:n;return new RegExp(`^${ZE}T(?:${r})$`)}const _R=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}$`)},NR=/^-?\d+$/,TR=/^-?\d+(?:\.\d+)?$/,jR=/^(?:true|false)$/i,$R=/^[^A-Z]*$/,CR=/^[^a-z]*$/,ho=_e("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),sw=e=>{const t=e.value;return!mI(t)&&t.length!==void 0},Uf={number:"number",bigint:"bigint",object:"date"},GE=_e("$ZodCheckLessThan",(e,t)=>{ho.init(e,t);const n=Uf[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:Uf[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})}}),VE=_e("$ZodCheckGreaterThan",(e,t)=>{ho.init(e,t);const n=Uf[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:Uf[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})}}),AR=_e("$ZodCheckMultipleOf",(e,t)=>{ho.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):gI(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})}}),IR=_e("$ZodCheckNumberFormat",(e,t)=>{var a;ho.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]=xI[t.format];e._zod.onattach.push(c=>{const u=c._zod.bag;u.format=t.format,u.minimum=o,u.maximum=s,n&&(u.pattern=NR)}),e._zod.check=c=>{const u=c.value;if(n){if(!Number.isInteger(u)){c.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:u,inst:e});return}if(!Number.isSafeInteger(u)){u>0?c.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}):c.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&&c.issues.push({origin:"number",input:u,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),u>s&&c.issues.push({origin:"number",input:u,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),RR=_e("$ZodCheckMaxLength",(e,t)=>{var n;ho.init(e,t),(n=e._zod.def).when??(n.when=sw),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?tw(o):s)<=t.maximum)return;const c=nw(o);r.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),OR=_e("$ZodCheckMinLength",(e,t)=>{var n;ho.init(e,t),(n=e._zod.def).when??(n.when=sw),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?tw(o):s)>=t.minimum)return;const c=nw(o);r.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),MR=_e("$ZodCheckLengthEquals",(e,t)=>{var n;ho.init(e,t),(n=e._zod.def).when??(n.when=sw),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?tw(o):s;if(a===t.length)return;const c=nw(o),u=a>t.length;r.issues.push({origin:c,...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})}}),$h=_e("$ZodCheckStringFormat",(e,t)=>{var n,r;ho.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=()=>{})}),LR=_e("$ZodCheckRegex",(e,t)=>{$h.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})}}),PR=_e("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=$R),$h.init(e,t)}),DR=_e("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=CR),$h.init(e,t)}),zR=_e("$ZodCheckIncludes",(e,t)=>{ho.init(e,t);const n=zl(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})}}),FR=_e("$ZodCheckStartsWith",(e,t)=>{ho.init(e,t);const n=new RegExp(`^${zl(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})}}),BR=_e("$ZodCheckEndsWith",(e,t)=>{ho.init(e,t);const n=new RegExp(`.*${zl(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})}}),UR=_e("$ZodCheckOverwrite",(e,t)=>{ho.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class HR{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 WR={major:4,minor:5,patch:4},Kn=_e("$ZodType",(e,t)=>{var s;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=WR;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 c of a._zod.onattach)c(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,h,f)=>{if(u.memo)return u;let m=_l(u),g;for(const y of h){if(y._zod.def.when){if($I(u)||!y._zod.def.when(u))continue}else if(m)continue;const w=u.issues.length,v=y._zod.check(u);if(v instanceof Promise&&(f==null?void 0:f.async)===!1)throw new Ol;if(g||v instanceof Promise)g=(g??Promise.resolve()).then(async()=>{await v,u.issues.length!==w&&(G0(u.issues,w,e),m||(m=_l(u,w)))});else{if(u.issues.length===w)continue;G0(u.issues,w,e),m||(m=_l(u,w))}}return g?g.then(()=>u):u},c=(u,h,f)=>{if(_l(u))return u.aborted=!0,u;const m=a(h,o,f);if(m instanceof Promise){if(f.async===!1)throw new Ol;return m.then(g=>e._zod.parse(g,f))}return e._zod.parse(m,f)};e._zod.run=(u,h)=>{if(h.skipChecks)return e._zod.parse(u,h);if(h.direction==="backward"){const m=e._zod.parse({value:u.value,issues:[]},{...h,skipChecks:!0});return m instanceof Promise?m.then(g=>c(g,u,h)):c(m,u,h)}const f=e._zod.parse(u,h);if(f instanceof Promise){if(h.async===!1)throw new Ol;return f.then(m=>a(m,o,h))}return a(f,o,h)}}},{get"~standard"(){return BE(this,"~standard",YE(this))},set"~standard"(e){Fl(this,"~standard",e)}}),J0=e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}};function YE(e){return{validate:t=>{try{return J0(qI(e,t))}catch{return ZI(e,t).then(J0)}},vendor:"zod",version:1}}const iw=_e("$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()??_R(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=_e("$ZodStringFormat",(e,t)=>{$h.init(e,t),iw.init(e,t)}),KR=_e("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=uR),qn.init(e,t)}),qR=_e("$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=Q0(r))}else t.pattern??(t.pattern=Q0());qn.init(e,t)}),ZR=_e("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=dR),qn.init(e,t)}),XE=1,QE=2;function GR(e,t){var n;if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===yR.source&&!/^https?:\/\//i.test(e))return XE;try{return new URL(e)}catch{return QE}}const VR=/[\t\n\r]/g;function YR(e){return e.replace(VR,"")}function XR(e,t){return t.lastIndex=0,t.test(e.hostname)}function QR(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const JR=_e("$ZodURL",(e,t)=>{qn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=GR(r,t);if(o===XE){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===QE){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!XR(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&&!QR(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:YR(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),eO=_e("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=hR()),qn.init(e,t)}),tO=_e("$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?aR:lR(t.length)),qn.init(e,t)}),nO=_e("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=nR),qn.init(e,t)}),rO=_e("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=rR),qn.init(e,t)}),oO=_e("$ZodULID",(e,t)=>{t.pattern??(t.pattern=oR),qn.init(e,t)}),sO=_e("$ZodXID",(e,t)=>{t.pattern??(t.pattern=sR),qn.init(e,t)}),iO=_e("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=iR),qn.init(e,t)}),aO=_e("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=SR(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}))}),lO=_e("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=xR),qn.init(e,t)}),cO=_e("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=ER(t)),qn.init(e,t)}),uO=_e("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=cR),qn.init(e,t)}),dO=_e("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=pR),qn.init(e,t),e._zod.bag.format="ipv4"}),fO=/^[0-9a-fA-F:.]+$/;function JE(e){if(!fO.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}const hO=_e("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=mR),qn.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{JE(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),pO=_e("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=gR),qn.init(e,t)});function mO(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:JE(n)}const gO=_e("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=kR),qn.init(e,t),e._zod.check=n=>{mO(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function eS(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const kO=_e("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=wR),qn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{eS(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function wO(e){if(!qE.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return eS(n)}const yO=_e("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=qE),qn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{wO(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),vO=_e("$ZodE164",(e,t)=>{t.pattern??(t.pattern=vR),qn.init(e,t)});function bO(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 xO=_e("$ZodJWT",(e,t)=>{qn.init(e,t),e._zod.check=n=>{bO(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),tS=_e("$ZodNumber",(e,t)=>{Kn.init(e,t),e._zod.pattern=e._zod.bag.pattern??TR,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}}),EO=_e("$ZodNumberFormat",(e,t)=>{IR.init(e,t),tS.init(e,t)}),SO=_e("$ZodBoolean",(e,t)=>{Kn.init(e,t),e._zod.pattern=jR,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}}),_O=_e("$ZodUnknown",(e,t)=>{Kn.init(e,t),e._zod.parse=n=>n}),NO=_e("$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 eb(e,t,n){e.issues.length&&t.issues.push(..._h(n,e.issues)),t.value[n]=e.value}const TO=_e("$ZodArray",(e,t)=>{Kn.init(e,t);const n=ss.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 c=0;c<s.length;c++){const u=s[c],h=t.element._zod.run({value:u,issues:[]},o);h instanceof Promise?a.push(h.then(f=>eb(f,r,c))):eb(h,r,c)}return a.length?Promise.all(a).then(()=>r):r}});function Hf(e,t,n,r,o,s){const a=n in r,c=s==="optional";if(!(!a&&c&&o==="optional")){if(e.issues.length){if(o!==void 0&&c&&!a)return;t.issues.push(..._h(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 jO=[];function nS(e){var a,c,u,h;const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:jO,o=r.length?[...t,...r]:t;for(const f of o)if(!((h=(u=(c=(a=e.shape)==null?void 0:a[f])==null?void 0:c._zod)==null?void 0:u.traits)!=null&&h.has("$ZodType")))throw new Error(`Invalid element at key "${String(f)}": expected a Zod schema`);const s=bI(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function rS(e,t,n,r,o,s){const a=[],c=o.keySet,u=o.catchall._zod,h=u.def.type,f=u.optin,m=u.optout;for(const g in t){if(c.has(g))continue;if(g==="__proto__"){h==="never"&&a.push(g);continue}if(h==="never"){a.push(g);continue}const y=u.run({value:t[g],issues:[]},r);y instanceof Promise?e.push(y.then(w=>Hf(w,n,g,t,f,m))):Hf(y,n,g,t,f,m)}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 Og=new WeakMap,$O=_e("$ZodObject",(e,t)=>{Kn.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const u=t.shape;Og.set(t,u),Object.defineProperty(t,"shape",{get:()=>{const h={...u};return Object.defineProperty(t,"shape",{value:h}),Og.set(t,h),h}})}const r=Sh(()=>nS(t));_n(e,"propValues",u=>{const h=u.def.shape,f={};for(const m in h){const g=h[m]._zod;if(g.values){Object.prototype.hasOwnProperty.call(f,m)||uo(f,m,new Set);for(const y of g.values)f[m].add(y);g.optin!==void 0&&f[m].add(void 0)}}return f});const o=hu,s=t.catchall;let a;const c=ss.memoizer;c==null||c.attach(e),e._zod.parse=(u,h)=>{a??(a=r.value);const f=u.value;if(!o(f))return u.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),u;u.value=c?c.alloc(e,u,{},h):{};const m=[],g=a.shape;for(const y of a.allKeys){if(y==="__proto__")continue;const w=g[y],v=w._zod.optin,_=w._zod.optout,x=w._zod.run({value:f[y],issues:[]},h);x instanceof Promise?m.push(x.then(N=>Hf(N,u,y,f,v,_))):Hf(x,u,y,f,v,_)}return s?rS(m,f,u,h,r.value,e):m.length?Promise.all(m).then(()=>u):u}}),CO=_e("$ZodObjectJIT",(e,t)=>{$O.init(e,t);const n=e._zod.parse,r=Sh(()=>nS(t)),o=ss.memoizer,s=y=>{var C,I;const w=r.value,v=w.symbolKeys,_=new HR(["payload","ctx"],{shape:y,inst:e,memo:o,syms:v}),x=A=>`shape[${A}]._zod.run({ value: input[${A}], issues: [] }, ctx)`,N=(A,M)=>`
47
- for (let i = 0; i < ${A}.issues.length; i++) {
48
- const iss = ${A}.issues[i];
49
- iss.path = iss.path ? [${M}, ...iss.path] : [${M}];
50
- payload.issues.push(iss);
51
- }`;_.write("const input = payload.value;");const T=Object.create(null);let j=0;for(const A of w.allKeys)T[A]=`key_${j++}`;_.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const A of w.allKeys){if(A==="__proto__")continue;const M=T[A],O=typeof A=="symbol"?`syms[${v.indexOf(A)}]`:kI(A),z=`${O} in input`,B=y[A],H=(C=B==null?void 0:B._zod)==null?void 0:C.optin,Y=H!==void 0,ie=((I=B==null?void 0:B._zod)==null?void 0:I.optout)==="optional";if(_.write(`const ${M} = ${x(O)};`),Y&&ie){const Q=H==="optional"?`${M}_present`:`${M}.value !== undefined || ${M}_present`;_.write(`
52
- const ${M}_present = ${z};
53
- if (!${M}.issues.length || ${M}_present) {
54
- if (${M}.issues.length) {${N(M,O)}
55
- }
56
-
57
- if (${Q}) {
58
- newResult[${O}] = ${M}.value;
59
- }
60
- }
61
-
62
- `)}else Y?_.write(`
63
- if (${M}.issues.length) {${N(M,O)}
64
- }
65
-
66
- if (${M}.value === undefined) {
67
- if (${z}) {
68
- newResult[${O}] = undefined;
69
- }
70
- } else {
71
- newResult[${O}] = ${M}.value;
72
- }
73
-
74
- `):_.write(`
75
- const ${M}_present = ${z};
76
- if (${M}.issues.length) {${N(M,O)}
77
- }
78
- if (!${M}_present && !${M}.issues.length) {
79
- payload.issues.push({
80
- code: "invalid_type",
81
- expected: "nonoptional",
82
- input: undefined,
83
- path: [${O}]
84
- });
85
- }
86
-
87
- if (${M}_present) {
88
- newResult[${O}] = ${M}.value;
89
- }
90
-
91
- `)}return _.write("payload.value = newResult;"),_.write("return payload;"),_.compile()};let a;const c=hu,u=!ss.jitless,f=u&&yI.value,m=t.catchall;let g;e._zod.parse=(y,w)=>{g??(g=r.value);const v=y.value;return c(v)?u&&f&&(w==null?void 0:w.async)===!1&&w.jitless!==!0?(a||(a=s(t.shape)),y=a(y,w),m?rS([],v,y,w,g,e):y):n(y,w):(y.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),y)}});function tb(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=>!_l(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=>Yl(a,r,Mi())))}),t)}const oS=_e("$ZodUnion",(e,t)=>{Kn.init(e,t),_n(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),_n(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),_n(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)))}),_n(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=>ew(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 c of t.options){const u=c._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(c=>tb(c,r,e,o)):tb(a,r,e,o)}}),AO=_e("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,oS.init(e,t);const n=e._zod.parse;_n(e,"propValues",o=>{const s={};for(const a of o.def.options){const c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);for(const[u,h]of Object.entries(c)){Object.prototype.hasOwnProperty.call(s,u)||uo(s,u,new Set);for(const f of h)s[u].add(f)}}return s}),t.options.forEach((o,s)=>{const a=Og.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=Sh(()=>{var a;const o=t.options,s=new Map;for(const c of o){const u=(a=c._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(c)}"`);for(const h of u){if(s.has(h))throw new Error(`Duplicate discriminator value "${String(h)}"`);s.set(h,c)}}return s});e._zod.parse=(o,s)=>{const a=o.value;if(!hu(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;const c=r.value.get(a==null?void 0:a[t.discriminator]);return c?c._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)}}),IO=_e("$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,h])=>nb(n,u,h)):nb(n,s,a)}});function Mg(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(pu(e)&&pu(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=Mg(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=Mg(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 nb(e,t,n){const r=new Map;let o;const s=new Map,a=(h,f)=>{var g,y;let m;if(h.code==="unrecognized_keys"&&!((g=h.path)!=null&&g.length))o??(o=h),m=h.keys;else if(h.code==="invalid_key"&&h.origin==="record"&&((y=h.path)==null?void 0:y.length)===1){const w=String(h.path[0]);s.has(w)||s.set(w,h),m=[w]}else return!1;for(const w of m)r.has(w)||r.set(w,{}),r.get(w)[f]=!0;return!0};for(const h of t.issues)a(h,"l")||e.issues.push(h);for(const h of n.issues)a(h,"r")||e.issues.push(h);const c=[...r].filter(([,h])=>h.l&&h.r).map(([h])=>h);if(c.length){const h=o?c.filter(f=>o.keys.includes(f)):[];h.length&&e.issues.push({...o,keys:h});for(const f of c)!h.includes(f)&&s.has(f)&&e.issues.push(s.get(f))}const u=Mg(t.value,n.value);if(!u.valid){if(_l(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}const RO=_e("$ZodTuple",(e,t)=>{Kn.init(e,t);const n=t.items,r=ss.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 c=[],u=rb(n,"optin"),h=rb(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 f=new Array(n.length);for(let m=0;m<n.length;m++){const g=n[m]._zod.run({value:a[m],issues:[]},s);g instanceof Promise?c.push(g.then(y=>{f[m]=y})):f[m]=g}if(t.rest){let m=n.length-1;const g=a.slice(n.length);for(const y of g){m++;const w=t.rest._zod.run({value:y,issues:[]},s);w instanceof Promise?c.push(w.then(v=>ob(v,o,m))):ob(w,o,m)}}return c.length?Promise.all(c).then(()=>sb(f,o,n,a,h)):sb(f,o,n,a,h)}});function rb(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 ob(e,t,n){e.issues.length&&t.issues.push(..._h(n,e.issues)),t.value[n]=e.value}function sb(e,t,n,r,o){for(let s=0;s<n.length;s++){const a=e[s],c=s<r.length;if(!c&&s>=o&&n[s]._zod.optin==="optional"){t.value.length=s;break}if(a.issues.length){if(!c&&s>=o){t.value.length=s;break}t.issues.push(..._h(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 OO=_e("$ZodEnum",(e,t)=>{Kn.init(e,t);const n=PE(t.entries),r=new Set(n);e._zod.values=r;const o=n.filter(s=>vI.has(typeof s));e._zod.pattern=new RegExp(o.length?`^(${o.map(s=>zl(s.toString())).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(s,a)=>{const c=s.value;return r.has(c)||s.issues.push({code:"invalid_value",values:n,input:c,inst:e}),s}}),MO=_e("$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"?zl(r):r?zl(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}}),LO=_e("$ZodTransform",(e,t)=>{var n;Kn.init(e,t),e._zod.optin="optional",(n=ss.memoizer)==null||n.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new UE(e.constructor.name);const s=t.transform(r.value,r);if(o.async)return(s instanceof Promise?s:Promise.resolve(s)).then(c=>(r.value=c,r));if(s instanceof Promise)throw new Ol;return r.value=s,r}});function ib(e,t){return e.value=t.issues.length?void 0:t.value,e}const sS=_e("$ZodOptional",(e,t)=>{Kn.init(e,t),_n(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",_n(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),_n(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${ew(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=>ib(n,s)):ib(n,o)}return t.innerType._zod.run(n,r)}}),PO=_e("$ZodExactOptional",(e,t)=>{sS.init(e,t),_n(e,"values",n=>n.def.innerType._zod.values),_n(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),DO=_e("$ZodNullable",(e,t)=>{Kn.init(e,t),_n(e,"optin",n=>n.def.innerType._zod.optin),_n(e,"optout",n=>n.def.innerType._zod.optout),_n(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${ew(r.source)}|null)$`):void 0}),_n(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)}),zO=_e("$ZodDefault",(e,t)=>{Kn.init(e,t),e._zod.optin="defaulted",_n(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=>ab(s,t)):ab(o,t)}});function ab(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const FO=_e("$ZodPrefault",(e,t)=>{Kn.init(e,t),e._zod.optin="defaulted",_n(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))}),BO=_e("$ZodNonOptional",(e,t)=>{Kn.init(e,t),_n(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=>lb(s,e)):lb(o,e)}});function lb(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 cb(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>Yl(o,r,Mi()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const UO=_e("$ZodCatch",(e,t)=>{Kn.init(e,t),_n(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),_n(e,"optout",n=>n.def.innerType._zod.optout),_n(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=>cb(n,s,t,r)):cb(n,o,t,r)}}),HO=_e("$ZodPipe",(e,t)=>{Kn.init(e,t),_n(e,"values",n=>n.def.in._zod.values),_n(e,"optin",n=>n.def.in._zod.optin),_n(e,"optout",n=>n.def.out._zod.optout),_n(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=>sf(a,t.in,r)):sf(s,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>sf(s,t.out,r)):sf(o,t.out,r)}});function sf(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 WO=_e("$ZodReadonly",(e,t)=>{Kn.init(e,t),_n(e,"propValues",n=>n.def.innerType._zod.propValues),_n(e,"values",n=>n.def.innerType._zod.values),_n(e,"optin",n=>{var r,o;return(o=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:o.optin}),_n(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(ub):ub(o)}});function ub(e){return e.memo||(e.value=Object.freeze(e.value)),e}const KO=_e("$ZodCustom",(e,t)=>{ho.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=>db(s,n,r,e));db(o,n,r,e)}});function db(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(mu(o))}}class qO extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const Lg="~memo",fb=[];function Wm(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const hb=new WeakMap;function iS(e,t){const n=hb.get(e);if(n!==void 0)return n;if(t.has(e))return!0;t.add(e);let r=!1;const o=c=>{!r&&(c!=null&&c._zod)&&iS(c,t)&&(r=!0)},s=e._zod.def;switch(s.type){case"object":{for(const c of Reflect.ownKeys(s.shape))o(s.shape[c]);o(s.catchall);break}case"array":o(s.element);break;case"tuple":for(const c of s.items)o(c);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 c of s.options)o(c);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 c in s){const u=Object.getOwnPropertyDescriptor(s,c);if(!u||u.get)continue;const h=u.value;if(!(!h||typeof h!="object")){if(h._zod)o(h);else if(Array.isArray(h))for(const f of h)o(f)}}}return t.delete(e),hb.set(e,r),r}function ZO(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}let af;const lf=[],GO={alloc(e,t,n){const r=af;if(!r)return n;af=void 0;const o={value:n,issues:null};return r.set(t.value,o),lf.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"&&YO(s,o.value))throw new qO;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=(c,u)=>{if(n===void 0&&(n=iS(e,new Set),!n))return e._zod.parse=s,e._zod.run===a&&(e._zod.run=s),s(c,u);const h=c.value;if(h===null||typeof h!="object")return s(c,u);let f=u[Lg];f||(f={buckets:new Map,backEdges:void 0},u[Lg]=f);let m;r===u?m=o:(m=ZO(f,e),r=u,o=m);const g=m.get(h);if(g)return c.value=g.value,g.issues?g.issues.length&&c.issues.push(...Wm(g.issues)):(c.memo=!0,f.backEdges??(f.backEdges=new Set),f.backEdges.add(g.value)),c;af=m;const y=lf.length,w=s(c,u);af=void 0;const v=lf.length>y?lf.pop():void 0;return w instanceof Promise?w.then(_=>(v&&(v.issues=_.issues.length?Wm(_.issues):fb),_)):(v&&(v.issues=w.issues.length?Wm(w.issues):fb),w)};e._zod.parse=a,e._zod.run===s&&(e._zod.run=a)})}};function VO(){return GO}function YO(e,t){var r;const n=(r=e[Lg])==null?void 0:r.backEdges;return n!==void 0&&t!==null&&typeof t=="object"&&n.has(t)}const XO=()=>{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),c=AI(s.input),u=o(c,s.input);return`Invalid input: expected ${a}, received ${u}`}case"invalid_value":return s.values.length===1?`Invalid input: expected ${FE(s.values[0])}`:`Invalid option: expected one of ${q0(s.values,"|")}`;case"too_big":{const a=s.exact?"exactly ":s.inclusive?"<=":"<",c=t(s.origin);return c?`Too big: expected ${s.origin??"value"} to have ${a}${s.maximum.toString()} ${c.unit??"elements"}`:`Too big: expected ${s.origin??"value"} to be ${a}${s.maximum.toString()}`}case"too_small":{const a=s.exact?"exactly ":s.inclusive?">=":">",c=t(s.origin);return c?`Too small: expected ${s.origin} to have ${a}${s.minimum.toString()} ${c.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":""}: ${q0(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(c=>`'${c}'`).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 QO(){return{localeError:XO()}}var pb;class JO{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 e2(){return new JO}(pb=globalThis).__zod_globalRegistry??(pb.__zod_globalRegistry=e2());const Xc=globalThis.__zod_globalRegistry;function t2(e,t){return new e({type:"string",...dt(t)})}function n2(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...dt(t)})}function r2(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...dt(t)})}function o2(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...dt(t)})}function s2(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...dt(t)})}function i2(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...dt(t)})}function a2(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...dt(t)})}function l2(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...dt(t)})}function c2(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...dt(t)})}function u2(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...dt(t)})}function d2(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...dt(t)})}function f2(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...dt(t)})}function h2(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...dt(t)})}function p2(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...dt(t)})}function m2(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...dt(t)})}function g2(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...dt(t)})}function k2(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...dt(t)})}function w2(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...dt(t)})}function y2(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...dt(t)})}function v2(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...dt(t)})}function b2(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...dt(t)})}function x2(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...dt(t)})}function E2(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...dt(t)})}function S2(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...dt(t)})}function _2(e,t){return new e({type:"string",format:"date",check:"string_format",...dt(t)})}function N2(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...dt(t)})}function T2(e,t){return new e({type:"string",format:"duration",check:"string_format",...dt(t)})}function j2(e,t){return new e({type:"number",checks:[],...dt(t)})}function $2(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...dt(t)})}function C2(e,t){return new e({type:"boolean",...dt(t)})}function A2(e){return new e({type:"unknown"})}function I2(e,t){return new e({type:"never",...dt(t)})}function mb(e,t){return new GE({check:"less_than",...dt(t),value:e,inclusive:!1})}function Km(e,t){return new GE({check:"less_than",...dt(t),value:e,inclusive:!0})}function gb(e,t){return new VE({check:"greater_than",...dt(t),value:e,inclusive:!1})}function qm(e,t){return new VE({check:"greater_than",...dt(t),value:e,inclusive:!0})}function kb(e,t){return new AR({check:"multiple_of",...dt(t),value:e})}function aS(e,t){return new RR({check:"max_length",...dt(t),maximum:e})}function Wf(e,t){return new OR({check:"min_length",...dt(t),minimum:e})}function lS(e,t){return new MR({check:"length_equals",...dt(t),length:e})}function R2(e,t){return new LR({check:"string_format",format:"regex",...dt(t),pattern:e})}function O2(e){return new PR({check:"string_format",format:"lowercase",...dt(e)})}function M2(e){return new DR({check:"string_format",format:"uppercase",...dt(e)})}function L2(e,t){return new zR({check:"string_format",format:"includes",...dt(t),includes:e})}function P2(e,t){return new FR({check:"string_format",format:"starts_with",...dt(t),prefix:e})}function D2(e,t){return new BR({check:"string_format",format:"ends_with",...dt(t),suffix:e})}function Xl(e){return new UR({check:"overwrite",tx:e})}function z2(e){return Xl(t=>t.normalize(e))}function F2(){return Xl(e=>e.trim())}function B2(){return Xl(e=>e.toLowerCase())}function U2(){return Xl(e=>e.toUpperCase())}function H2(){return Xl(e=>wI(e))}function W2(e,t,n){return new e({type:"array",element:t,...dt(n)})}function K2(e,t,n){return new e({type:"custom",check:"custom",fn:t,...dt(n)})}function q2(e,t){const n=Z2(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(mu(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(mu(s))}},e(r.value,r)),t);return n}function Z2(e,t){const n=new ho({check:"custom",...dt(t)});return n._zod.check=e,n}function au(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&uo(e,r,n[r]);return e}function cS(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)??Xc,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 Ci(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 vr(e,t,n={path:[],schemaPath:[]}){var f,m;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 c=(m=(f=e._zod).toJSONSchema)==null?void 0:m.call(f);if(c)a.schema=c;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),vr(y,t,g),t.seen.get(y).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&au(a.schema,u),t.io==="input"&&Yr(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 wb(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function uS(e,t){var a,c,u,h;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 f of e.seen.entries()){const m=(a=e.metadataRegistry.get(f[0]))==null?void 0:a.id;if(m){const g=r.get(m);if(g&&g!==f[0])throw new Error(`Duplicate schema id "${m}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(m,f[0])}}const o=f=>{var v;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const _=(v=e.external.registry.get(f[0]))==null?void 0:v.id,x=e.external.uri??(T=>T);if(_)return{ref:x(_)};const N=f[1].defId??f[1].schema.id??`schema${e.counter++}`;return f[1].defId=N,{defId:N,ref:`${x("__shared")}#/${m}/${wb(N)}`}}const g="#",y=`${g}/${m}/`;if(f[1]===n&&!f[1].schema.id)return{ref:g};const w=f[1].schema.id??`__schema${e.counter++}`;return{defId:w,ref:y+wb(w)}},s=f=>{if(f[1].schema.$ref)return;const m=f[1],{ref:g,defId:y}=o(f);m.def={...m.schema},y&&(m.defId=y);const w=m.schema;for(const v in w)delete w[v];w.$ref=g};if(e.cycles==="throw")for(const f of e.seen.entries()){const m=f[1];if(m.cycle)throw new Error(`Cycle detected: #/${(c=m.cycle)==null?void 0:c.join("/")}/<root>
92
-
93
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const f of e.seen.entries()){const m=f[1];if(t===f[0]){s(f);continue}if(e.external){const y=(u=e.external.registry.get(f[0]))==null?void 0:u.id;if(t!==f[0]&&y){s(f);continue}}if((h=e.metadataRegistry.get(f[0]))==null?void 0:h.id){s(f);continue}if(m.cycle){s(f);continue}if(m.count>1&&e.reused==="ref"){s(f);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function dS(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;dS(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 fS=new Set(["type","properties","required","additionalProperties"]),yb=["oneOf","anyOf"];function vb(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Pg(e){var s;const t=[];for(const a of e){if(typeof a!="object"||a.type!=="object")return null;for(const c in a)if(!fS.has(c))return null;t.push(a)}const n={},r=new Set;for(const a of t){for(const c in a.properties){if(Object.prototype.hasOwnProperty.call(n,c))continue;const u=[];for(const f of t){const m=((s=f.properties)==null?void 0:s[c])??vb(f);m!=null&&(u.some(g=>JSON.stringify(g)===JSON.stringify(m))||u.push(m))}const h=u.length===1?u[0]:Pg(u)??{allOf:u};uo(n,c,h)}for(const c of a.required??[])r.add(c)}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 c of t){const u=vb(c);u&&!a.some(h=>JSON.stringify(h)===JSON.stringify(u))&&a.push(u)}a.length===1?o.additionalProperties=a[0]:a.length>1&&(o.additionalProperties={allOf:a})}return o}function G2(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const o of fS)if(o in e)return;const n=t.filter(o=>yb.some(s=>Array.isArray(o[s])));let r=null;if(!n.length)r=Pg(t);else{const o=n[0],s=yb.find(u=>Array.isArray(o[u]));if(Object.keys(o).length!==1)return;const a=t.filter(u=>u!==o),c=o[s].map(u=>Pg([...a,u]));if(c.some(u=>!u))return;r={[s]:c}}r&&(delete e.allOf,au(e,r))}function hS(e,t){var c,u,h,f;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=m=>{const g=e.seen.get(m);if(g.ref===null)return;const y=g.def??g.schema,w={...y},v=g.ref;if(g.ref=null,v){r(v);const x=e.seen.get(v),N=x.schema;if(N.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(y.allOf=y.allOf??[],y.allOf.push(N)):au(y,N),au(y,w),m._zod.parent===v)for(const j in y)j==="$ref"||j==="allOf"||j in w||delete y[j];if(N.$ref&&x.def)for(const j in y)j==="$ref"||j==="allOf"||j in x.def&&JSON.stringify(y[j])===JSON.stringify(x.def[j])&&delete y[j]}const _=m._zod.parent;if(_&&_!==v){r(_);const x=e.seen.get(_);if(x!=null&&x.schema.$ref&&(y.$ref=x.schema.$ref,x.def))for(const N in y)N==="$ref"||N==="allOf"||N in x.def&&JSON.stringify(y[N])===JSON.stringify(x.def[N])&&delete y[N]}e.override({zodSchema:m,jsonSchema:y,path:g.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const m of[...e.seen.entries()].reverse())r(m[0]);if(e.target!=="openapi-3.0")for(const m of e.seen.entries())dS(m[1].def??m[1].schema);for(const m of e.deferred)m();if(e.intersections.length){const m=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=m.get(w);v?v.push(y):m.set(w,[y])}for(const g of e.intersections)for(const y of m.get(g)??[])G2(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,(c=e.external)!=null&&c.uri){const m=(u=e.external.registry.get(t))==null?void 0:u.id;if(!m)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(m)}au(o,n.defId?n.schema:n.def??n.schema);const s=(h=e.metadataRegistry.get(t))==null?void 0:h.id;s!==void 0&&o.id===s&&delete o.id;const a=((f=e.external)==null?void 0:f.defs)??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const m of e.seen.entries()){const g=m[1];g.def&&g.defId&&(g.def.id===g.defId&&delete g.def.id,uo(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 m=JSON.parse(JSON.stringify(o));return Object.defineProperty(m,"~standard",{value:{...t["~standard"],jsonSchema:{input:Kf(t,"input",e.processors),output:Kf(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function Yr(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 Yr(r.element,n);if(r.type==="set")return Yr(r.valueType,n);if(r.type==="lazy")return Yr(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 Yr(r.innerType,n);if(r.type==="intersection")return Yr(r.left,n)||Yr(r.right,n);if(r.type==="record"||r.type==="map")return Yr(r.keyType,n)||Yr(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Yr(r.in,n)||Yr(r.out,n);if(r.type==="object"){for(const o in r.shape)if(Yr(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(Yr(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(Yr(o,n))return!0;return!!(r.rest&&Yr(r.rest,n))}return!1}const V2=(e,t={})=>n=>{const r=cS({...n,processors:t});return vr(e,r),uS(r,e),hS(r,e)},Kf=(e,t,n={})=>r=>{const{libraryOptions:o,target:s}=r??{},a=cS({...o??{},target:s,io:t,processors:n});return vr(e,a),uS(a,e),hS(a,e)},Y2={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},X2=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:s,maximum:a,format:c,patterns:u,contentEncoding:h,laxFormat:f}=e._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof a=="number"&&(o.maxLength=a),c&&(o.format=Y2[c]??c,o.format===""&&delete o.format,(c==="time"||f)&&delete o.format),h&&(o.contentEncoding=h),u&&u.size>0){const m=[...u];m.length===1?o.pattern=m[0].source:m.length>1&&(o.allOf=[...m.map(g=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},Q2=(e,t,n,r)=>{const o=n,{minimum:s,maximum:a,format:c,multipleOf:u,exclusiveMaximum:h,exclusiveMinimum:f}=e._zod.bag;typeof c=="string"&&c.includes("int")?o.type="integer":o.type="number";const m=typeof f=="number"&&f>=(s??Number.NEGATIVE_INFINITY),g=typeof h=="number"&&h<=(a??Number.POSITIVE_INFINITY),y=t.target==="draft-04"||t.target==="openapi-3.0";m?y?(o.minimum=f,o.exclusiveMinimum=!0):o.exclusiveMinimum=f:typeof s=="number"&&(o.minimum=s),g?y?(o.maximum=h,o.exclusiveMaximum=!0):o.exclusiveMaximum=h:typeof a=="number"&&(o.maximum=a),typeof u=="number"&&(Number.isFinite(u)&&u!==0?o.multipleOf=Math.abs(u):Ci(e,t,o,r,`A multipleOf divisor of ${u} cannot be represented in JSON Schema`))},J2=(e,t,n,r)=>{n.type="boolean"},eM=(e,t,n,r)=>{n.not={}},tM=(e,t,n,r)=>{},nM=(e,t,n,r)=>{const o=e._zod.def,s=PE(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},rM=(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(Ci(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(Ci(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},oM=(e,t,n,r)=>{Ci(e,t,n,r,"Custom types cannot be represented in JSON Schema")},sM=(e,t,n,r)=>{Ci(e,t,n,r,"Transforms cannot be represented in JSON Schema")},iM=(e,t,n,r)=>{const o=n,s=e._zod.def,{minimum:a,maximum:c}=e._zod.bag;typeof a=="number"&&(o.minItems=a),typeof c=="number"&&(o.maxItems=c),o.type="array",o.items=vr(s.element,t,{...r,path:[...r.path,"items"]})};function qf(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?qf(t.out):t.type==="catch"?qf(t.innerType):e._zod.optin}const aM=(e,t,n,r)=>{var f;const o=n,s=e._zod.def,a=s.shape;if(Object.getOwnPropertySymbols(a).length&&Ci(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const m in a)uo(o.properties,m,vr(a[m],t,{...r,path:[...r.path,"properties",m]}));const u=new Set(Object.keys(a)),h=new Set([...u].filter(m=>{const g=s.shape[m];return t.io==="input"?qf(g)===void 0:g._zod.optout===void 0}));h.size>0&&(o.required=Array.from(h)),((f=s.catchall)==null?void 0:f._zod.def.type)==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=vr(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},lM=(e,t,n,r)=>{const o=e._zod.def,s=o.inclusive===!1,a=o.options.map((c,u)=>vr(c,t,{...r,path:[...r.path,s?"oneOf":"anyOf",u]}));s?n.oneOf=a:n.anyOf=a},cM=(e,t,n,r)=>{const o=e._zod.def,s=vr(o.left,t,{...r,path:[...r.path,"allOf",0]}),a=vr(o.right,t,{...r,path:[...r.path,"allOf",1]}),c=h=>"allOf"in h&&Object.keys(h).length===1,u=[...c(s)?s.allOf:[s],...c(a)?a.allOf:[a]];n.allOf=u,t.intersections.push(u)},uM=(e,t,n,r)=>{const o=n,s=e._zod.def;o.type="array";const a=t.target==="draft-2020-12"?"prefixItems":"items",c=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",u=s.items.map((v,_)=>vr(v,t,{...r,path:[...r.path,a,_]})),h=s.rest?vr(s.rest,t,{...r,path:[...r.path,c,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null;let f=s.items.length;for(;f>0;){const v=s.items[f-1];if(!(t.io==="input"?qf(v)!==void 0:v._zod.optout==="optional"))break;f--}const m=s.items.length,g=!s.rest;t.target==="draft-2020-12"?(o.prefixItems=u,g?o.items=!1:h&&(o.items=h),f>0&&(o.minItems=f),g&&(o.maxItems=m)):t.target==="openapi-3.0"?(o.items={anyOf:u},h&&o.items.anyOf.push(h),f>0&&(o.minItems=f),g&&(o.maxItems=m)):(o.items=u,g?o.additionalItems=!1:h&&(o.additionalItems=h),f>0&&(o.minItems=f),g&&(o.maxItems=m));const{minimum:y,maximum:w}=e._zod.bag;typeof y=="number"&&(o.minItems=y),typeof w=="number"&&(o.maxItems=w)},dM=(e,t,n,r)=>{const o=e._zod.def,s=vr(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"}]},fM=(e,t,n,r)=>{const o=e._zod.def;vr(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},aw=Symbol();function pS(e,t,n,r,o){let s=!1;const a=JSON.stringify(e,(c,u)=>typeof u!="bigint"?u:(s=!0,null));return s?(Ci(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),aw):JSON.parse(a)}const hM=(e,t,n,r)=>{const o=e._zod.def;vr(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType;const a=pS(o.defaultValue,e,t,n,r);a!==aw&&(n.default=a)},pM=(e,t,n,r)=>{const o=e._zod.def;vr(o.innerType,t,r);const s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;const a=pS(o.defaultValue,e,t,n,r);a!==aw&&(n._prefault=a)},mM=(e,t,n,r)=>{const o=e._zod.def;vr(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{Ci(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=a},gM=(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;vr(a,t,r);const c=t.seen.get(e);c.ref=a},kM=(e,t,n,r)=>{const o=e._zod.def;vr(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,n.readOnly=!0},mS=(e,t,n,r)=>{const o=e._zod.def;vr(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},bb=new WeakSet([Object.prototype,Error.prototype]);function cf(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 wM=(e,t)=>{WE.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);bb.has(n)||(bb.add(n),cf(n,"format",r=>o=>KI(r,o)),cf(n,"flatten",r=>o=>WI(r,o)),cf(n,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,Ig,2)}),cf(n,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,Ig,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Uo=_e("ZodError",wM,void 0,{Parent:Error}),yM=rw(Uo),vM=ow(Uo),bM=Th(Uo),xM=jh(Uo),EM=GI(Uo),SM=VI(Uo),_M=YI(Uo),NM=XI(Uo),TM=QI(Uo),jM=JI(Uo),$M=eR(Uo),CM=tR(Uo);function AM(){ss.localeError||Mi(QO())}function Ch(){ss.memoizer||Mi({memoizer:VO()})}const Qn=_e("ZodType",(e,t)=>(AM(),Kn.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(Ri(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 Oi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check($L(e,t))},superRefine(e,t){return this.check(CL(e,t))},overwrite(e){return this.check(Xl(e))},optional(){return Sb(this)},exactOptional(){return kL(this)},nullable(){return _b(this)},nullish(){return Sb(_b(this))},nonoptional(e){return EL(this,e)},array(){return ga(this)},or(e){return lL([this,e])},and(e){return fL(this,e)},transform(e){return Nb(this,gL(e))},default(e){return vL(this,e)},prefault(e){return xL(this,e)},catch(e){return _L(this,e)},pipe(e){return Nb(this,e)},readonly(){return jL(this)},describe(e){const t=this.clone();return Xc.add(t,{description:e}),t},meta(...e){if(e.length===0)return Xc.get(this);const t=this.clone();return Xc.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 BE(this,"~standard",{...YE(this),jsonSchema:{input:Kf(this,"input"),output:Kf(this,"output")}})},set"~standard"(e){Fl(this,"~standard",e)},parse:function e(t,n){return yM(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await vM(this,t,n,{callee:e})},safeParse(e,t){return bM(this,e,t)},async safeParseAsync(e,t){return xM(this,e,t)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(e){Fl(this,"spa",e)},encode:function e(t,n){return EM(this,t,n,{callee:e})},decode:function e(t,n){return SM(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await _M(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await NM(this,t,n,{callee:e})},safeEncode(e,t){return TM(this,e,t)},safeDecode(e,t){return jM(this,e,t)},async safeEncodeAsync(e,t){return $M(this,e,t)},async safeDecodeAsync(e,t){return CM(this,e,t)},toJSONSchema(e){return V2(this,{})(e)},get description(){var e;return(e=Xc.get(this))==null?void 0:e.description},get _def(){return this._zod.def}}),gS=_e("_ZodString",(e,t)=>{iw.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(r,o,s)=>X2(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(R2(...e))},includes(...e){return this.check(L2(...e))},startsWith(...e){return this.check(P2(...e))},endsWith(...e){return this.check(D2(...e))},min(...e){return this.check(Wf(...e))},max(...e){return this.check(aS(...e))},length(...e){return this.check(lS(...e))},nonempty(...e){return this.check(Wf(1,...e))},lowercase(e){return this.check(O2(e))},uppercase(e){return this.check(M2(e))},trim(){return this.check(F2())},normalize(...e){return this.check(z2(...e))},toLowerCase(){return this.check(B2())},toUpperCase(){return this.check(U2())},slugify(){return this.check(H2())}}),IM=_e("ZodString",(e,t)=>{iw.init(e,t),gS.init(e,t)},{email(e){return this.check(n2(PM,e))},url(e){return this.check(l2(zM,e))},jwt(e){return this.check(E2(eL,e))},emoji(e){return this.check(c2(FM,e))},guid(e){return this.check(r2(DM,e))},uuid(e){return this.check(o2(uf,e))},uuidv4(e){return this.check(s2(uf,e))},uuidv6(e){return this.check(i2(uf,e))},uuidv7(e){return this.check(a2(uf,e))},nanoid(e){return this.check(u2(BM,e))},cuid(e){return this.check(d2(UM,e))},cuid2(e){return this.check(f2(HM,e))},ulid(e){return this.check(h2(WM,e))},base64(e){return this.check(v2(XM,e))},base64url(e){return this.check(b2(QM,e))},xid(e){return this.check(p2(KM,e))},ksuid(e){return this.check(m2(qM,e))},ipv4(e){return this.check(g2(ZM,e))},ipv6(e){return this.check(k2(GM,e))},cidrv4(e){return this.check(w2(VM,e))},cidrv6(e){return this.check(y2(YM,e))},e164(e){return this.check(x2(JM,e))},datetime(e){return this.check(S2(RM,e))},date(e){return this.check(_2(OM,e))},time(e){return this.check(N2(MM,e))},duration(e){return this.check(T2(LM,e))}});function jn(e){return t2(IM,e)}const Jn=_e("ZodStringFormat",(e,t)=>{qn.init(e,t),gS.init(e,t)}),RM=_e("ZodISODateTime",(e,t)=>{aO.init(e,t),Jn.init(e,t)}),OM=_e("ZodISODate",(e,t)=>{lO.init(e,t),Jn.init(e,t)}),MM=_e("ZodISOTime",(e,t)=>{cO.init(e,t),Jn.init(e,t)}),LM=_e("ZodISODuration",(e,t)=>{uO.init(e,t),Jn.init(e,t)}),PM=_e("ZodEmail",(e,t)=>{ZR.init(e,t),Jn.init(e,t)}),DM=_e("ZodGUID",(e,t)=>{KR.init(e,t),Jn.init(e,t)}),uf=_e("ZodUUID",(e,t)=>{qR.init(e,t),Jn.init(e,t)}),zM=_e("ZodURL",(e,t)=>{JR.init(e,t),Jn.init(e,t)}),FM=_e("ZodEmoji",(e,t)=>{eO.init(e,t),Jn.init(e,t)}),BM=_e("ZodNanoID",(e,t)=>{tO.init(e,t),Jn.init(e,t)}),UM=_e("ZodCUID",(e,t)=>{nO.init(e,t),Jn.init(e,t)}),HM=_e("ZodCUID2",(e,t)=>{rO.init(e,t),Jn.init(e,t)}),WM=_e("ZodULID",(e,t)=>{oO.init(e,t),Jn.init(e,t)}),KM=_e("ZodXID",(e,t)=>{sO.init(e,t),Jn.init(e,t)}),qM=_e("ZodKSUID",(e,t)=>{iO.init(e,t),Jn.init(e,t)}),ZM=_e("ZodIPv4",(e,t)=>{dO.init(e,t),Jn.init(e,t)}),GM=_e("ZodIPv6",(e,t)=>{hO.init(e,t),Jn.init(e,t)}),VM=_e("ZodCIDRv4",(e,t)=>{pO.init(e,t),Jn.init(e,t)}),YM=_e("ZodCIDRv6",(e,t)=>{gO.init(e,t),Jn.init(e,t)}),XM=_e("ZodBase64",(e,t)=>{kO.init(e,t),Jn.init(e,t)}),QM=_e("ZodBase64URL",(e,t)=>{yO.init(e,t),Jn.init(e,t)}),JM=_e("ZodE164",(e,t)=>{vO.init(e,t),Jn.init(e,t)}),eL=_e("ZodJWT",(e,t)=>{xO.init(e,t),Jn.init(e,t)}),kS=_e("ZodNumber",(e,t)=>{tS.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(r,o,s)=>Q2(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(gb(e,t))},gte(e,t){return this.check(qm(e,t))},min(e,t){return this.check(qm(e,t))},lt(e,t){return this.check(mb(e,t))},lte(e,t){return this.check(Km(e,t))},max(e,t){return this.check(Km(e,t))},int(e){return this.check(xb(e))},safe(e){return this.check(xb(e))},positive(e){return this.check(gb(0,e))},nonnegative(e){return this.check(qm(0,e))},negative(e){return this.check(mb(0,e))},nonpositive(e){return this.check(Km(0,e))},multipleOf(e,t){return this.check(kb(e,t))},step(e,t){return this.check(kb(e,t))},finite(){return this}});function Cs(e){return j2(kS,e)}const tL=_e("ZodNumberFormat",(e,t)=>{EO.init(e,t),kS.init(e,t)});function xb(e){return $2(tL,e)}const nL=_e("ZodBoolean",(e,t)=>{SO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>J2(e,n,r)});function Po(e){return C2(nL,e)}const rL=_e("ZodUnknown",(e,t)=>{_O.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>tM()});function Eb(){return A2(rL)}const oL=_e("ZodNever",(e,t)=>{NO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>eM(e,n,r)});function sL(e){return I2(oL,e)}const iL=_e("ZodArray",(e,t)=>{Ch(),TO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>iM(e,n,r,o),e.element=t.element},{min(e,t){return this.check(Wf(e,t))},nonempty(e){return this.check(Wf(1,e))},max(e,t){return this.check(aS(e,t))},length(e,t){return this.check(lS(e,t))},unwrap(){return this.element}});function ga(e,t){return W2(iL,e,t)}const aL=_e("ZodObject",(e,t)=>{Ch(),CO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>aM(e,n,r,o),LI(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return Nl(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Eb()})},loose(){return this.clone({...this._zod.def,catchall:Eb()})},strict(){return this.clone({...this._zod.def,catchall:sL()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return _I(this,e)},safeExtend(e){return NI(this,e)},merge(e){return TI(this,e)},pick(e){return EI(this,e)},omit(e){return SI(this,e)},partial(...e){return Z0(lw,this,e[0])},exactPartial(...e){return Z0(vS,this,e[0],"exactPartial")},required(...e){return jI(bS,this,e[0])}});function _r(e,t){const n={type:"object",shape:e??{},...dt(t)};return new aL(n)}const wS=_e("ZodUnion",(e,t)=>{oS.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>lM(e,n,r,o),e.options=t.options});function lL(e,t){return new wS({type:"union",options:e,...dt(t)})}const cL=_e("ZodDiscriminatedUnion",(e,t)=>{wS.init(e,t),AO.init(e,t)});function uL(e,t,n){return new cL({type:"union",options:t,discriminator:e,...dt(n)})}const dL=_e("ZodIntersection",(e,t)=>{IO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>cM(e,n,r,o)});function fL(e,t){return new dL({type:"intersection",left:e,right:t})}const hL=_e("ZodTuple",(e,t)=>{Ch(),RO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>uM(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 lw({type:"optional",innerType:n}))})}});function yS(e,t,n){const r=t instanceof Kn,o=r?n:t,s=r?t:null;return new hL({type:"tuple",items:e,rest:s,...dt(o)})}const Dg=_e("ZodEnum",(e,t)=>{OO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(r,o,s)=>nM(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 Dg({...t,checks:[],...dt(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 Dg({...t,checks:[],...dt(o),entries:s})}});function Nl(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Dg({type:"enum",entries:n,...dt(t)})}const pL=_e("ZodLiteral",(e,t)=>{MO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>rM(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 Vr(e,t){return new pL({type:"literal",values:Array.isArray(e)?e:[e],...dt(t)})}const mL=_e("ZodTransform",(e,t)=>{Ch(),LO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>sM(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new UE(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(mu(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(mu(a))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n)):(n.value=o,n)}});function gL(e){return new mL({type:"transform",transform:e})}const lw=_e("ZodOptional",(e,t)=>{sS.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>mS(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Sb(e){return new lw({type:"optional",innerType:e})}const vS=_e("ZodExactOptional",(e,t)=>{PO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>mS(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function kL(e){return new vS({type:"optional",innerType:e})}const wL=_e("ZodNullable",(e,t)=>{DO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>dM(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function _b(e){return new wL({type:"nullable",innerType:e})}const yL=_e("ZodDefault",(e,t)=>{zO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>hM(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function vL(e,t){return new yL({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():zE(t)}})}const bL=_e("ZodPrefault",(e,t)=>{FO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>pM(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function xL(e,t){return new bL({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():zE(t)}})}const bS=_e("ZodNonOptional",(e,t)=>{BO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>fM(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function EL(e,t){return new bS({type:"nonoptional",innerType:e,...dt(t)})}const SL=_e("ZodCatch",(e,t)=>{UO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>mM(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function _L(e,t){return new SL({type:"catch",innerType:e,catchValue:typeof t=="function"?t:DI(t)})}const NL=_e("ZodPipe",(e,t)=>{HO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>gM(e,n,r,o),e.in=t.in,e.out=t.out});function Nb(e,t){return new NL({type:"pipe",in:e,out:t})}const TL=_e("ZodReadonly",(e,t)=>{WO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>kM(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function jL(e){return new TL({type:"readonly",innerType:e})}const xS=_e("ZodCustom",(e,t)=>{KO.init(e,t),Qn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>oM(e,n,r,o)});function $L(e,t={}){return K2(xS,e,t)}function CL(e,t){return q2(e,t)}function AL(e,t={}){const n=new xS({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...dt(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 IL=["off","tailscale","any"],RL={updates:!0,deploy:!0,remote:"any",agents:null,customAgents:!0,brandedListener:!0,planSignIn:!0};_r({updates:Po().optional(),deploy:Po().optional(),remote:Nl(IL).optional(),agents:ga(jn()).optional(),customAgents:Po().optional(),brandedListener:Po().optional(),planSignIn:Po().optional()});const OL={...RL,source:null,problem:null};function ML(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 Zm=6e3,Tb=1500;function LL(e){if(e.length<=Zm)return e;const t=e.length-Zm;return`${e.slice(0,Tb)}
94
- [${t} characters cut here]
95
- ${e.slice(e.length-(Zm-Tb))}`}const fa=142,PL=2e3,Zf=5e6,DL=["image/png","image/jpeg","image/gif","image/webp"],jb=2576,Gm=5*1024*1024,zL=1200,FL=10,BL=1e5,$b=100*1024*1024,UL="pasted-text.txt";function HL(e){return e.t==="term-data"||e.t==="term-snapshot"||e.t==="term-exit"}function WL(e){return e.t==="file-read"||e.t==="file-written"||e.t==="file-blame"}const KL=80;function cw(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,KL)}}function ES(e){return e.length>=zL||e.split(`
97
- `).length>=FL}function qL({startLine:e,endLine:t}){return e===t?`${e}`:`${e}-${t}`}function ZL(e){return`${e.path.slice(e.path.lastIndexOf("/")+1)} (${qL(e)})`}const GL=/\u001B(?:\[[0-?]*[ -/]*[@-~]|\][^\u0007]*(?:\u0007|\u001B\\))/g;function VL(e){return e.replace(GL,"")}function SS(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 YL(e){const t=e.plan.trim();return SS(t).title===null?`# ${e.title}
98
-
99
- ${t}
100
- `:`${t}
101
- `}const _S="Projects";function XL(e){for(const t of e){const n=t.codePointAt(0)??0;if(n<32||n===127)return!0}return!1}function gu(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":XL(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 QL=/^(?:https?|ssh|git|file):\/\/\S+$/i,NS=/^[\w.-]+@[\w.-]+:\S+$/,JL=/^[\w-]+(?:\.[\w-]+)+\/\S+$/;function Cb(e){const t=e.trim(),n=JL.test(t)?`https://${t}`:t;if(!QL.test(n)&&!NS.test(n))return null;const r=eP(n),o=nP((r==null?void 0:r.url)??n);return!o||gu(o)?null:r?{url:r.url,name:o,...r.branch?{branch:r.branch}:{}}:{url:n,name:o}}const Vm={"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 eP(e){var o;if(!/^https?:\/\//i.test(e))return null;let t;try{t=new URL(e)}catch{return null}const n=(o=Vm[t.hostname.toLowerCase()])==null?void 0:o.call(Vm,t.pathname.split("/").filter(Boolean));if(!n)return null;const r=n.branch?tP(n.branch).replace(/\/+$/,""):"";return{url:`${t.protocol}//${t.host}/${n.repo.join("/")}`,...r?{branch:r}:{}}}function tP(e){try{return decodeURIComponent(e)}catch{return e}}function nP(e){var o;const t=((o=e.split(/[?#]/)[0])==null?void 0:o.replace(/\/+$/,""))??"";return((NS.test(t)?t.split(":")[1]??"":t).split("/").pop()??"").replace(/\.git$/i,"")}const rP=_r({component:jn().nullable(),file:jn().nullable(),line:Cs().nullable(),callFile:jn().nullable().default(null),callLine:Cs().nullable().default(null),tag:jn(),selector:jn()}),oP=_r({tag:jn().max(40),id:jn().max(200),classes:ga(jn().max(120)).max(16),text:jn().max(200),attrs:ga(yS([jn().max(40),jn().max(200)])).max(12)}),sP=yS([Cs(),Cs()]),iP=rP.extend({classes:jn(),text:jn(),html:jn(),route:jn(),element:oP}),aP=uL("type",[_r({type:Vr("loaded"),url:jn(),title:jn()}),_r({type:Vr("navigated"),url:jn(),title:jn().optional()}),_r({type:Vr("traversed"),dir:Nl(["back","forward"]).optional()}),_r({type:Vr("title"),title:jn()}),_r({type:Vr("links"),links:ga(_r({path:jn().max(2048),text:jn().max(120)})).max(200)}),_r({type:Vr("hmr")}),_r({type:Vr("touch"),phase:Nl(["start","move","end","cancel"]),x:Cs(),y:Cs()}),_r({type:Vr("page-error"),message:jn(),source:jn().optional(),line:Cs().optional()}),iP.extend({type:Vr("picked"),verb:Nl(["chat","code"]).default("chat"),site:Nl(["call","source"]).default("source")}),_r({type:Vr("pick-cancel")}),_r({type:Vr("highlight-miss"),path:jn(),fileMatched:Cs(),withSource:Cs(),ranges:ga(sP).nullable()}),_r({type:Vr("drag-files"),over:Po().default(!0)}),_r({type:Vr("drop-files"),files:ga(AL(File))}),_r({type:Vr("focus"),gesture:Po()}),_r({type:Vr("key"),key:jn(),code:jn().optional(),meta:Po(),ctrl:Po().optional(),shift:Po().optional(),alt:Po().optional(),up:Po().optional()})]);function TS(e){const t=aP.safeParse(e);return t.success?t.data:null}const lP=["rows","repos","visits","themes"];function cP(e){return lP.map(t=>e[t]??"").join(".")}const uP=/["“”]([^"“”]*)["“”]?|(\S+)/g;function jS(e){const t=new Set;for(const n of e.matchAll(uP)){const r=(n[1]??n[2]??"").replace(/\s+/g," ").trim().toLowerCase();r&&t.add(r)}return[...t]}const dP="now",fP="http://preview.invalid",hP=200;function Ab(e){const t=e==null?void 0:e.replace(/\s+/g," ").trim().slice(0,hP).trim();return t||void 0}function Ah(e){let t;try{t=new URL(e,fP)}catch{return null}if(t.pathname.startsWith("/__toyon"))return null;const n=Ib(t.pathname)||"/",r=t.hash.startsWith("#/")?Ib(t.hash.split("?")[0]??""):"";return r.length>1?`${n}${r}`:n}const Ib=e=>e.replace(/\/+$/,""),pP={static:4,mixed:3.5,param:3,optional:2,"optional-static":2,splat:1},Gf=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function $S(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="",c=0;for(const h of e.matchAll(/\[([^\]=]+)(?:=[^\]]*)?\]|\{\$([\w-]+)\}/g)){const f=e.slice(c,h.index);f&&(s.push({text:f}),a+=Gf(f)),s.push({name:h[1]??h[2]??"param"}),a+="[^/]+?",c=(h.index??0)+h[0].length}const u=e.slice(c);if(u&&(s.push({text:u}),a+=Gf(u)),s.some(h=>"name"in h))return{kind:"mixed",pattern:a,parts:s}}return{kind:"static",text:e}}function mP(e){const t=e.split("/").filter(Boolean).map($S);if(t.every(r=>r.kind==="static"))return null;let n="";for(const r of t)r.kind==="static"?n+=`/${Gf(r.text)}`:r.kind==="optional-static"?n+=`(?:/${Gf(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+pP[o.kind],0),statics:t.filter(r=>r.kind==="static").length}}function gP(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 Ih(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($S))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 Pu={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"},CS={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"},kP={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"}},wP={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"}},yP={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"}},vP={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"}},bP={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"}},xP={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"}},EP={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"}},SP={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"}},_P={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"}},NP={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"}},TP={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"}},jP={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"}},$P={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"}},CP={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"}},AP={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"}},IP={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"}},RP={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"}},OP=[EP,SP,_P,NP,TP,jP,$P,CP,AP,IP,RP],Cf=[Pu,CS,kP,wP,yP,vP,bP,xP,...OP],MP={mode:"dark",light:CS.id,dark:Pu.id},LP=["surface0","surface1","surface2","element0","element1","border0","border1","text0","text1","text2","red","orange","yellow","green","aqua","blue","purple","diffAdd","diffDel"];function PP(e){return`--${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function zg(e){return AS(ka(e))}function AS(e){return e>.008856?116*e**(1/3)-16:903.3*e}function uw(e,t){const n=zg(e)+t,r=Sa(e);if(!r)return e;let o=0,s=2;for(let a=0;a<24;a++){const c=(o+s)/2,u=Bl(Math.min(255,r[0]*c),Math.min(255,r[1]*c),Math.min(255,r[2]*c));zg(u)<n?o=c:s=c}return Bl(Math.min(255,r[0]*o),Math.min(255,r[1]*o),Math.min(255,r[2]*o))}function DP(e){return uw(e.colors.surface1,-4)}function zP(e){return uw(e.colors.surface0,-4)}const Rb=["surface0","surface1","surface2","element0","element1","border0","border1"];function FP(e){if(e.kind!=="dark")return e;const t=Rb.reduce((o,s)=>ka(e.colors[s])<ka(e.colors[o])?s:o),n=e.colors[t];if(ka(n)<=0)return e;const r={...e.colors};for(const o of[...Rb,"text1","text2"]){const s=XP(e.colors[o],n)*.05-.05;r[o]=uw(r[o],AS(s)-zg(r[o]))}return r.surface0="#000000",r.surface1="#000000",{...e,colors:r}}function Ob(e){return YP(e,.55)}function BP(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 UP(e){const t={};for(const n of LP)t[PP(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(BP(e)))t[`--syntax-${n}`]=r;return t["--accent"]=dw(e),t["--fault"]=HP(e),t["--link"]=WP(e),t["--sunken"]=DP(e),t["--sunken-floor"]=zP(e),t["--scrim"]=VP(e.colors.surface0,.7),t["--shadow"]=e.kind==="dark"?"#00000066":"#0000002e",t["--diff-add-word"]=Ob(e.colors.diffAdd),t["--diff-del-word"]=Ob(e.colors.diffDel),t}function dw(e){return hw(e.accent??"")??e.colors.orange}function HP(e){return dw(e)===hw(e.colors.orange)?e.colors.red:e.colors.orange}function WP(e){return hw(e.link??"")??e.colors.blue}function KP(e){return e==="system"||e==="daylight"}function fw(e,t){return e.mode==="system"?t.system?"dark":"light":e.mode==="daylight"?t.daylight?"dark":"light":e.mode}function Rh(e,t,n){const r=fw(e,n);return t.find(o=>o.id===e[r])??Cf.find(o=>o.kind===r)??Pu}function qP(e,t){if(e.pair){const a=t.find(c=>c.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 ZP(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=qP(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 GP(e,t){const n={...e};return t.dark&&(n.dark=t.dark.id),t.light&&(n.light=t.light.id),!KP(n.mode)&&!t[n.mode]&&(n.mode=t.dark?"dark":"light"),n}function Sa(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 hw(e){const t=Sa(e);return t?Bl(t[0],t[1],t[2],t[3]):null}function Bl(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 VP(e,t){const n=Sa(e);return n?Bl(n[0],n[1],n[2],t):e}function YP(e,t){const n=Sa(e);return n?Bl(n[0],n[1],n[2],Math.min(1,n[3]*t)):e}function hV(e,t){const n=Sa(e),r=Sa(t);if(!n||!r)return e;const o=n[3];return Bl(n[0]*o+r[0]*(1-o),n[1]*o+r[1]*(1-o),n[2]*o+r[2]*(1-o))}function ka(e){const t=Sa(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 XP(e,t){const n=ka(e),r=ka(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function QP(e){return ka(e)>.179?"#1d2021":"#fbf1c7"}function Fg(e){if(e===null||e==="")return"the npm registry";try{return new URL(e).host}catch{return e}}function IS(e,t){const n=Mb(e),r=Mb(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 Mb(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 JP=[[/\.(png|jpe?g|gif|webp|avif|bmp|ico)$/i,"image"],[/\.(mp4|m4v|webm|mov)$/i,"video"]];function e4(e){var t;return((t=JP.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const t4=[[/\.(md|markdown)$/i,"markdown"],[/\.html?$/i,"html"]];function ku(e){var t;return((t=t4.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const tt={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",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"},n4=[tt.active,tt.repo,tt.lastActive,tt.discoveredOpen,tt.archivedOpen,tt.committedShut,tt.turnOpen,tt.treeOpen,tt.phoneRow,tt.version],Af=(e,t)=>`${e}@${t}`,r4="toyon",Hc="snapshots",ao={hello:e=>`hello@${e}`,chat:(e,t)=>`chat@${e}/${t}`,chats:e=>`chat@${e}/`};function o4(e,t=typeof localStorage>"u"?null:localStorage,n=typeof sessionStorage>"u"?null:sessionStorage){const r=a=>({get(c){try{return(a==null?void 0:a.getItem(Af(c,e)))??null}catch{return null}},set(c,u){try{a==null||a.setItem(Af(c,e),u)}catch{}},remove(c){try{a==null||a.removeItem(Af(c,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 c of Bg(a).filter(u=>u.endsWith(`@${e}`)))try{a==null||a.removeItem(c)}catch{}}}}function Bg(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 s4="orch-";function i4(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=tt[s],c=s4+a.slice(6);Lb(r,c,a)}for(const[r,o]of[[t,n4.filter(s=>s!==tt.phoneRow)],[n,[tt.phoneRow]]]){const s=Bg(r).filter(a=>!a.includes("@"));for(const a of o)for(const c of s.filter(u=>u===a))Lb(r,c,Af(c,e))}for(const r of Bg(t))a4.some(o=>r.startsWith(o))&&l4(t,r)}const a4=["toyon-profile-","toyon-mode-","toyon-model-","toyon-effort-"];function l4(e,t){try{e==null||e.removeItem(t)}catch{}}function Lb(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 RS(){const e=location.hash.match(/token=([a-f0-9]+)/);if(e!=null&&e[1])return OS(e[1]),e[1];try{return localStorage.getItem(tt.token)??sessionStorage.getItem(tt.token)??""}catch{return""}}function OS(e){try{localStorage.setItem(tt.token,e)}catch{}}function Vf(){return RS()!==""}function pw(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,c)=>`${n.origin}/files/${s}/${a.split("/").map(encodeURIComponent).join("/")}?${r}${o(c)}`,loose:(s,a)=>`${n.origin}/loose/${encodeURIComponent(s)}?${r}${o(a)}`,health:`${n.origin}/health`,restart:s=>`${n.origin}/restart?${r}${s?`&${dP}`:""}`,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 $a=e=>({authorization:`Bearer ${e.token}`});async function c4(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",$a(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 u4(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 MS(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 d4(e){var t;try{const n=await fetch(e.changelog,{headers:$a(e)});return!n.ok||!((t=n.headers.get("content-type"))!=null&&t.startsWith("text/markdown"))?null:await n.text()}catch{return null}}async function f4(e,t){try{const n=await fetch(t,{headers:$a(e)});return n.ok?await n.json():null}catch{return null}}async function Oh(e,t,n,r){try{const o=await fetch(t,{method:"POST",headers:{...$a(e),"content-type":"application/json"},body:JSON.stringify(n)});return o.ok?null:await o.text()||`refused (${o.status})`}catch{return r}}const h4=e=>f4(e,e.tailnet),p4=e=>Oh(e,e.remote,{tailscale:!0},"Toyon is not answering; try again once it is back."),m4=e=>Oh(e,e.remote,{off:!0},"Toyon is not answering; try again once it is back.");async function LS(e,t,n){try{const r=await fetch(t,{method:"POST",headers:{...$a(e),"content-type":"application/json"},body:JSON.stringify(n)});return r.ok?await r.json():null}catch{return null}}const PS="Toyon is not answering; try again once it is back.",g4=async e=>{const t=await LS(e,e.tailscale,{up:!0});return t===null?PS:t.refused},k4=async e=>await LS(e,e.tailscale,{login:!0})??{why:PS},w4=(e,t,n)=>Oh(e,e.machines,{origin:t,token:n},"Toyon here is not answering; the machine is not listed yet."),y4=(e,t,n)=>Oh(e,e.knockAnswer(t),{letIn:n},"Toyon is not answering");async function DS(e){try{const t=await fetch(e.previewGrant,{method:"POST",headers:$a(e)});return t.ok?await t.json():null}catch{return null}}async function v4(e,t){try{const n=await fetch(e.frame,{method:"POST",headers:{...$a(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 b4=2e3;async function zS(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,b4))}return"gone"}async function Ug(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 x4=1e3,E4=3e4,S4=1500,_4=5e3,Pb=50,N4=e=>e.t==="chat"||e.t==="create-worktree"||e.t==="restore-worktree";class T4{constructor(t,n,r,o={},s={}){Tt(this,"ws",null);Tt(this,"queue",[]);Tt(this,"closed",!1);Tt(this,"attempt",0);Tt(this,"timer",null);Tt(this,"downAt",null);Tt(this,"downCode",0);Tt(this,"sayTimer",null);Tt(this,"sentDown",new Set);Tt(this,"drops",0);Tt(this,"urls");Tt(this,"suspended",!1);Tt(this,"connectDeadline");Tt(this,"settle");Tt(this,"backoffMin");Tt(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??_4,this.settle=o.settle??S4,this.backoffMin=o.backoffMin??x4,this.urls=pw(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===nI)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=c=>{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(c.data))}catch{}},n.onclose=c=>{if(clearTimeout(o),this.ws!==n||(this.onStatus(!1),this.closed||this.suspended))return;this.drops++,this.say(c.code);const u=Math.min(E4,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)),N4(t)&&t.boxId&&this.sentDown.add(t.boxId),this.queue.push({key:r,raw:n}),this.queue.length>Pb&&this.queue.splice(0,this.queue.length-Pb)}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 mw(e){return e==="cancelled"||e==="expired"}function FS(e){const t=e.findLast(n=>n.kind==="ask"||Du(n));return(t==null?void 0:t.kind)!=="ask"||t.ask.kind!=="question"?null:mw(t.outcome)?t:null}function j4(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 $4(e){return e.map(()=>({selected:[]}))}function Db(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(c=>c!==n):[...o.selected,n]}:{...o,selected:[n]}})}function Yf(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 zb(e,t,n,r){return e.map((o,s)=>s!==t?o:{selected:n&&!r?[]:o.selected,note:o.note??""})}function Qc(e,t){const n=e[t];return n&&n.note!==void 0&&!n.note.trim()?Yf(e,t,void 0):e}function C4(e){return e?e.options.length+(e.note?1:0):0}function Fb(e,t){return!!(e!=null&&e.note)&&t===e.options.length}function BS(e,t){return!!e&&e.note!==void 0&&(t||e.selected.length===0)}function wa(e){var t;return!!e&&(e.selected.length>0||!!((t=e.note)!=null&&t.trim()))}function A4(e,t){return!!(e!=null&&e.multi)&&wa(t)}function Ym(e,t){return e.every((n,r)=>!n.required||wa(t[r]))}function I4(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(s=>{var a;return kw(((a=e.options.find(c=>c.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 R4(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(s=>{var a;return kw(((a=e.options.find(c=>c.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 gw(e,t){return e.map((n,r)=>{const o=I4(n,t==null?void 0:t[r]);return e.length>1&&n.header?`${n.header} · ${o}`:o})}function O4(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 M4(e){return e.outcome!=="answered"||e.ask.kind!=="question"?null:{message:e.ask.message,questions:e.ask.questions,answers:e.answers}}function L4(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 P4(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 Tl(e,t){if(!e)return 0;if(BS(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 D4(e,t,n){return Math.max(0,Math.min(n-1,e+t))}function z4(e,t,n){const r=e.length;for(let o=1;o<=r;o++){const s=(n+o)%r;if(!wa(t[s]))return s}return-1}function jl(e){return e.length>1?e.length:-1}function F4(e){return e.length+(jl(e)===-1?0:1)}function B4(e,t,n){const r=z4(e,t,n);if(r!==-1)return{current:r,cursor:Tl(e[r],t[r]),send:!1};const o=jl(e);return o!==-1?{current:o,cursor:0,send:!1}:{current:n,cursor:Tl(e[n],t[n]),send:!0}}const US=/\s*\(recommended\)\s*$/i;function U4(e){return US.test(e)}function kw(e){return e.replace(US,"")}const H4={skipped:"you skipped this",cancelled:"the turn was stopped before you answered",expired:"Toyon restarted before you answered"};function W4(e,t){const n=t??0;return n===0?null:`${n} behind ${e}`}function Mh(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function HS(e,t){if(t.fetchFailed)return`could not reach origin${t.fetchedAt?` since ${Mh(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 K4(e){return e.stale!=="diverged"}function WS(e,t,n,r){return n!==null&&r===n.host?`${tI(n.previews,e,t)}/`:r.endsWith(".localhost")?`http://w${e}.${r}:${t}/`:Qk(r)?`http://${r==="localhost"?"127.0.0.1":r}:${t}/`:`https://${r}:${t}/`}function Bb(e){return e.ranges.map(([t,n])=>[t+e.offset,n+e.offset])}function KS(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 q4(e){var r;const t=(r=e.source)==null?void 0:r.replace(/[?#].*$/,""),n=t?` (${KS(t)}:${e.line??"?"})`:"";return`${e.message}${n}`.slice(0,PL)}function df(e,t){return!Number.isFinite(e)||e<=0?t:Math.min(Math.max(e,170),Math.floor(window.innerWidth*.5))}function ps(e){var t,n,r;return e.agent==="waiting"?"waiting":e.agent==="working"&&e.stopping?"stopping":e.agent==="working"?"working":e.agent==="error"||((n=(t=e.worktree)==null?void 0:t.lastTurn)==null?void 0:n.end)==="failed"?"failed":e.background?"background":(r=e.worktree)!=null&&r.landed&&!e.dirty?"landed":e.procs.some(o=>o.status==="crashed"||o.status==="unreachable")?"crashed":e.procs.some(o=>o.status==="running")?"running":e.procs.some(o=>o.status==="starting")?"starting":e.procs.some(o=>o.status==="asleep")?"asleep":"idle"}const Z4={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",asleep:"Asleep",idle:"Idle"};function Lh(e,t=!1){const n=ps(e);return n==="idle"&&t?"Not set up":n==="background"&&e.wakes?`Wakes ${Mh(e.wakes)}`:Z4[n]}const G4={starting:"Starting",running:"Running",unreachable:"Not answering",crashed:"Crashed",stopped:"Stopped",asleep:"Asleep"};function V4(e){return G4[e]}const Y4=new Set(["idle","asleep","running","starting","background","landed"]);function qS(e,t){return t&&Y4.has(ps(e))?t:null}const X4={land:"Landing",commit:"Committing","sync-main":"Syncing with main","pull-main":"Pulling"};function ww(e){return X4[e]}function ZS(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 GS(e){const t=e.lastIndexOf("/");return t<0?{name:e,dir:""}:{name:e.slice(t+1),dir:e.slice(0,t)}}const VS=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}).compare;function Xf(e){const t=[];for(let n=e.indexOf("/");n!==-1;n=e.indexOf("/",n+1))t.push(e.slice(0,n));return t}function YS(e){const t=new Set;for(const n of e)for(const r of Xf(n))t.add(r);return[...t].sort(VS)}function yw(e){return e.includes("A")||e==="??"?"added":e.includes("D")?"deleted":""}function vw(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 Q4=/Firefox\//.test(navigator.userAgent);function bw(){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 J4=/Chrome\//.test(navigator.userAgent)&&bw(),Bt=e=>BA(e,{firefox:Q4,pwa:J4});function xw(e){return e.component?`<${e.component} />`:`<${e.tag}>`}function Hg(e,t){return e.worktree&&Tr(e.worktree)&&t?t.defaultBranch:e.name}function Ew(e){const t=Math.max(0,e/1e3),n=(a,c)=>`${a} ${c}${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 fr(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 ha(e){const t=Math.max(0,Math.floor(e));return t<100?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function eD(e,t,n,r){var a;if(!t)return null;const o=e.filter(Sn).filter(c=>c.repoId===t&&(c.worktree.agent??r)===n);return((a=o.find(c=>Tr(c.worktree))??o[0])==null?void 0:a.id)??null}const tD=200;function nD(e,t){const n=new Map(e.map(r=>[r.path,r]));for(const r of t){if(n.size>=tD)break;const o=Ah(r.path);o&&!n.has(o)&&n.set(o,{path:o,text:r.text})}return n.size===e.length?e:[...n.values()]}function XS(e){return e!==void 0&&!e.routes.some(t=>!t.endpoint)}const Ai=e=>"uploading"in e&&e.uploading===!0;function Ml(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 Sw=e=>e.filter(t=>!Ai(t)).map(Ml);let rD=0;function Wg(e,t){const n=new Map(t.filter(o=>!Ai(o)).map(o=>[JSON.stringify(Ml(o)),o]));return[...e.map(o=>{const s=JSON.stringify(o),a=n.get(s);if(a)return n.delete(s),a;const c=`d${++rD}`;return o.kind==="paste"?{...o,key:c,...cw(o.text)}:{...o,key:c}}),...t.filter(Ai)]}const Kg="out:",oD=(e,t,n)=>`${Kg}${e}:${t}:${n}`;function fs(e){if(!e.startsWith(Kg))return null;const t=e.slice(Kg.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 Jc(e,t,n,r){const o=r.length?Sw(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 sD(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(Ai)){n.add(o.log);continue}r.push(o.id)}return r}const QS=e=>e.flatMap(t=>"upload"in t&&t.upload?[t.upload]:[]);function iD(e){const t=n=>QS(n.items).some(r=>!n.before.includes(r));return[...e.filter(t),...e.filter(n=>!t(n))]}function aD(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 c=n.get(a)??r.get(a);c?o.push(c):s=!1}return{rows:o,complete:s}}const yl=300,lD=20;function cD(e,t){return e.rows.length===0&&e.repos.length===0?null:{protocol:fa,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 Ub=e=>(e==null?void 0:e.protocol)===fa,uD={rows:"",repos:"",visits:"",themes:""};function dD(e){const{at:t,...n}=e;return{t:"hello",...n,rows:e.rows.map(fD),trunks:Object.fromEntries(Object.entries(e.trunks).map(([r,o])=>[r,hD(o)])),stamps:uD,themes:[],drafts:{},attachments:{},knocks:[],letIn:!1,self:null,update:null,globalInstall:null,pending:[]}}function fD(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 hD(e){const{shipping:t,...n}=e;return n}function pD(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 ff(e,t){return e.length>t?e.slice(e.length-t):[...e]}function mD(e,t,n=lD){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,c)=>c[1].at-a[1].at);return[...o,...s.slice(n).map(([a])=>a)]}class gD{constructor(){Tt(this,"events",[]);Tt(this,"seq",-1);Tt(this,"whole",!1)}reset(t,n,r){this.events=ff(of(t),yl),this.seq=n,this.whole=r}extend(t,n){this.events.push(...t),n>this.seq&&(this.seq=n),this.events.length>yl*2&&(this.events=ff(of(this.events),yl))}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>yl*2&&(this.events=ff(of(this.events),yl))}snapshot(t,n){return this.events=ff(of(this.events),yl),{protocol:fa,at:n,events:[...this.events],seq:this.seq,...t?{draft:t}:{}}}}function Du(e){return e.kind==="user"||e.kind==="handed"}function JS(e){return e.map(t=>Du(t)?t.attachments:void 0)}const If=["files","changes","history"],kD=e=>If.includes(e),Ca=e=>(e==null?void 0:e.worktree.id)??null,Ul="new-project",Aa=Object.freeze({chat:[],log:[],queue:[],page:{},turn:{edits:!1,hmr:!1},changedRanges:{},commitFiles:{},search:null,design:null,draft:"",attachments:[],commands:[],termStream:Do}),Ph=e=>({...e,phase:"editing",repoId:null}),e_=()=>Ph({mode:"create",name:"",parent:`~/${_S}`}),wD=Object.freeze({changes:!1,changesTab:"files",chat:!0,term:!1,design:!1});function yD(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.changes=="boolean"&&kD(t.changesTab)&&typeof t.chat=="boolean"&&typeof t.term=="boolean"&&typeof t.design=="boolean"}function so(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 _w(e,t){return{...e,layout:t,changesAuto:!1}}const Ii=e=>ku(e)?"preview":"file",vD=(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),Wc=(e,t)=>e.worktreeId===t.worktreeId&&e.path===t.path&&e.ref===t.ref&&e.since===t.since;function t_(e,t,n,r){var s;if(!r.fiber)return r;const o=(s=Wr(e,t).changedRanges[n])==null?void 0:s.offset;return o===void 0?r:{n:r.n-o}}function bD(e){const t=e.cached??Pu,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,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:wD,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,focusTerm:0,termRun:null,termTall:0,previewSize:null,themes:Cf.some(o=>o.id===t.id)?Cf:[...Cf,t],themePrefs:{...MP,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:OL,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?_w(n,r):n}function n_(e){var t;return{system:e.systemDark,daylight:((t=e.daylight)==null?void 0:t.dark)??e.systemDark}}function xD(e){return e.previewTheme??Rh(e.themePrefs,e.themes,n_(e))}function Wr(e,t){return t&&e.local[t]||Aa}function Nw(e,t){const n=Wr(e,t);return n.draft.trim()!==""||n.attachments.length>0}function To(e,t){return t&&e.rows.find(n=>n.id===t)||null}function r_(e,t){const n=To(e,t);return n?os(n.agent)||!!e.shipping[n.id]||(n.queued??0)>0:!1}function Gt(e,t){const n=To(e,t);return n&&Sn(n)?n:null}function o_(e){var o;const t=Gt(e,e.activeId);if(!t||!xa(t.worktree)||t.agent!=="idle"||!((o=Hl(e,t.repoId))!=null&&o.empty))return!1;const n=Li(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&&Wr(e,t.id).chat.length===0}function Dh(e){return e.newProject!==null||o_(e)}function ED(e){return e.incompatible||Dh(e)}function SD(e){return(!e.needsSetup||!!e.assumed)&&Object.keys(e.config.run).length===0}function Qf(e){return!!(e!=null&&e.needsSetup)&&!e.assumed}function Tw(e){const t=e.archivedPage?null:To(e,e.activeId);return(t==null?void 0:t.repoId)??e.activeRepoId}function ns(e){const t=Li(e,Tw(e));return!!t&&SD(t)}function s_(e){return e.layout.chat&&!ns(e)&&!e.archivedPage&&!$w(e)?{a:"toggle-chat"}:{a:"focus-chat"}}function i_(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 Qo(e){return ns(e)?e:so(e,{chat:!0})}function Li(e,t){return t&&e.repos.find(n=>n.id===t)||null}function a_(e,t){if(!t)return null;const n=e.rows.filter(Sn).filter(r=>r.repoId===t);return n.find(r=>Lu(r.worktree))??n.find(r=>xa(r.worktree))??null}function Hl(e,t){return t&&e.trunks[t]||null}function $l(e){return ns(e)||e.archivedPage||e.notesPage?null:e.activeId}function zh(e){return e.procs.some(t=>t.status==="running"||t.status==="starting")}function wu(e){if(e.archivedPage||e.notesPage)return null;const t=Gt(e,e.activeId);return t&&zh(t)?{worktreeId:t.worktree.id,repoId:t.repoId}:null}function qg(e){const t=$l(e),n=Gt(e,t);return n?{id:n.worktree.id,act:zh(n)?"frame":"start"}:null}function jw(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&&Sn(o)&&o.repoId===t?o:null}function _D(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&&Sn(o)?o.worktree.title:((s=n.find(a=>a.id===r.origin.id))==null?void 0:s.title)??null}function l_(e,t){return e.repoId!==t&&(e.agent==="waiting"||!!e.unseen)}function Fh(e,t,n,r){return e.repoId===t||jw(e,t,n)!==null||l_(e,t)||e.id===r}function c_(e,t,n){return!e||!t||!Sn(e)||e.repoId===t||jw(e,t,n)?null:l_(e,t)?e.id:null}function u_(e,t){return t.length?e.filter(n=>!t.includes(n.id)):e}function ND(e,t,n,r){const o=u_(e,n).filter(Sn);return _A(t?o.filter(s=>Fh(s,t,o,r)):o)}function TD(e,t){const n=e.filter(r=>!Sn(r));return t?n.filter(r=>r.repoId===t):n}function Wl(e,t,n=e.rows){var c;const r=n.filter(Sn),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((c=a.find(u=>Lu(u.worktree))??a.find(u=>xa(u.worktree))??a[0])==null?void 0:c.id)??null}function Hb(e,t){const n=Object.entries(e),r=n.filter(([o])=>!t(o));return r.length===n.length?e:Object.fromEntries(r)}function d_(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,c]of Object.entries(e))!c.sent||r[a]||(t.some(u=>u.id===a)||v_({trunks:n},a))&&(r[a]=c);const o=Object.keys(r);return o.length===Object.keys(e).length&&o.every(a=>jD(e[a],r[a]))?e:r}const jD=(e,t)=>!!e&&!!t&&e.op===t.op&&e.step===t.step&&e.sent===t.sent;function Cl(e,t){var m;const n=To(e,t),r=!!n&&Sn(n)&&!!e.activeRepoId&&Fh(n,e.activeRepoId,e.rows,e.lent),o=r&&e.lent!==t?c_(n,e.activeRepoId,e.rows):r?e.lent:null,s=r?e.activeRepoId:(n==null?void 0:n.repoId)??e.activeRepoId,a=n&&Sn(n)?{...e.lastActive,[n.repoId]:n.id}:e.lastActive,c=e.activeId!==t?e.activeId:null,u=c?e.local[c]:void 0,h=u&&((m=u.mark)==null?void 0:m.by)==="reveal"?Al(u,"reveal"):null,f=c&&h?{...e.local,[c]:h}:e.local;return{...e,activeId:t,activeRepoId:s,lent:o,lastActive:a,editor:null,archivedPage:null,notesPage:!1,local:f}}function Kl(e){return Fo(e)?"history":e.layout.changesTab}function $D(e,t){const n=Kl(e);if(Fo(e))return n;const r=If.length;return If[(If.indexOf(n)+t+r)%r]??"changes"}function $w(e){if(e.archivedPage)return null;const t=To(e,e.activeId);return t&&!Sn(t)?t:null}function CD(e){return e.notesSeen||e.ranBefore===null||!IS(e.version,e.ranBefore)?null:e.version}const AD=800;function f_(e,t){return e.left&&t-e.left.at<AD?e.left.face:null}function ID(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 RD(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 Fo(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 Al(e,t){var o;if(((o=e.mark)==null?void 0:o.by)!==t)return e;const{mark:n,...r}=e;return r}const h_=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 OD=0;function yu(e){if(!e.sending)return e;const{sending:t,...n}=e;return n}function MD(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]=yu(r[o]);return{...e,local:r}}function LD(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 c=o[r]??Aa,u=c.chat.some(h=>h.kind==="user")?{at:s.at}:s;o={...o,[n]:yu(o[n]),[r]:{...c,sending:u}}}for(const c of t){const u=o[c.id];u!=null&&u.sending&&!u.sending.message&&os(c.agent)&&(o={...o,[c.id]:yu(u)})}return o}function mt(e,t,n){return{...e,local:{...e.local,[t]:n(e.local[t]??Aa)}}}function Wb(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 PD(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"&&mw(t.outcome),s=t.type==="agent-ask-end"&&t.outcome==="expired"?t.id:null,{card:a,cardParked:c,askRevived:u,...h}=e;return{...h,...a&&!n&&(a.id!==r||o)?{card:a}:{},...c&&!n&&c!==r?{cardParked:c}:{},...s?{askRevived:s}:u&&!n?{askRevived:u}:{}}}function DD(e,t,n){return mt(e,t,r=>({...r,chat:[...r.chat,n],chatAt:Date.now()}))}function p_(e,t,n){return DD(Qo(e),t,{kind:"error",text:n})}function Zg(e,t){const n=Ca(Gt(e,e.activeId));return n?mt(Qo(e),n,r=>({...r,notice:t})):e}function Kb(e,t,n){return Gt(e,t)?p_(e,t,n):Zg(e,n)}function zD(e,t){const n=e.paletteReturn;return!t||!n?{overlay:null,paletteReturn:null}:{overlay:{kind:n.mode},paletteReturn:n}}function FD(e){const t=e.activeRepoId;if(!t)return e;const n=e.layouts[t];return n?_w(e,n):e.frame==="desk"?{...e,layouts:{...e.layouts,[t]:e.layout}}:e}function BD(e){return e.a==="server"&&e.msg.t==="git-status"}function UD(e){return{agent:e.defaultAgent}}function HD(e){const t=Gt(e,e.activeId);return!!t&&Tr(t.worktree)&&!e.archivedPage&&!Dh(e)?e.draft?e:{...e,draft:UD(e)}:e.draft?{...e,draft:null}:e}function m_(e){var r;const t=e.archivedPage,n=t!==null&&((r=e.editor)==null?void 0:r.worktreeId)===t&&Gt(e,t)===null;return{...e,archivedPage:null,...n?{editor:null}:{}}}function WD(e){const t=e.activeRepoId;if(!t)return e;const n=Gt(e,e.activeId);return!n||n.repoId===t||Fh(n,t,u_(e.rows,e.archiving),e.lent)?e:Cl(e,Wl(e,t))}function g_(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?Ni(o,{a:"open",overlay:{kind:"devices"}}):o}const KD=e=>{var t;return e.frame==="desk"&&(e.remote!==null||((t=e.tailscale)==null?void 0:t.state)==="ready")};function Ni(e,t){let n=HD(WD(qD(e,t)));return n.unreadHold!==null&&n.activeId!==n.unreadHold&&(n={...n,unreadHold:null}),n.archivedPage!==null&&(Fo(n)===null||Gt(n,n.archivedPage)!==null)&&(n=m_(n)),n.activeRepoId!==e.activeRepoId?n=FD(n):n.frame==="desk"&&n.activeRepoId&&!BD(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:ND(n.rows,n.activeRepoId,n.archiving,n.lent),visibleDiscovered:TD(n.rows,n.activeRepoId)}}function qD(e,t){var n,r,o,s,a,c,u,h;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:XD(e.local)};case"activate":return{...Cl(e,t.id),carryTo:null,screen:t.id?"chat":"home"};case"open-draft":{if(Dh(e))return e;const f=((n=a_(e,e.activeRepoId))==null?void 0:n.id)??null;return f?Qo({...Cl(e,f),carryTo:f,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"draft-profile":return e.draft?{...e,draft:{...e.draft,profile:t.profile}}:e;case"open-archived":return i_(e,t.id);case"close-archived":return e.archivedPage?m_(e):e;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 mt(e,t.id,f=>({...f,sending:{message:t.message,at:Date.now()}}));case"sent-box":return mt(e,t.id,({notice:f,...m})=>({...Al(m,"walk"),draft:"",attachments:[],sent:(m.sent??0)+1}));case"answered":return mt(e,t.id,f=>({...f,sent:(f.sent??0)+1}));case"hold-send":{const f=e.local[t.id];if(!f)return e;const m=oD(e.clientId,++OD,t.id),g={...Aa,draft:t.text,attachments:f.attachments,outgoing:{frame:t.frame,log:t.log}},y=mt(e,t.id,({notice:w,...v})=>({...Al(v,"walk"),draft:"",attachments:[]}));return{...y,local:{...y.local,[m]:g},outbox:[...e.outbox,{id:m,log:t.log,kinds:f.attachments.map(w=>w.kind)}]}}case"sent-out":{const f=e.local[t.id],m=f==null?void 0:f.outgoing;if(!f||!m)return e;const{[t.id]:g,...y}=e.local,w={...e,local:y,outbox:e.outbox.filter(T=>T.id!==t.id)},v=f.draft,_=f.attachments.length?Sw(f.attachments):void 0,x=T=>({...T,sent:(T.sent??0)+1});if(m.frame.t==="restore-worktree"||m.frame.t==="adopt-worktree")return mt(w,m.log,T=>({...x(T),sending:{message:{text:v,attachments:_},at:Date.now()}}));if(m.frame.t==="agent-answer")return mt(w,m.log,x);const N=m.frame.t==="chat"&&r_(e,m.log);return mt(w,m.log,T=>N?x(T):{...x(T),sending:{message:{text:v,attachments:_},at:Date.now()}})}case"unsend":{const f=e.local[t.id],m=(r=fs(t.id))==null?void 0:r.source;if(!(f!=null&&f.outgoing)||!m)return e;const{[t.id]:g,...y}=e.local,w={...e,local:y,outbox:e.outbox.filter(v=>v.id!==t.id)};return mt(Qo(w),m,v=>({...v,draft:v.draft||f.draft,attachments:[...f.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]:f,...m}=e.local;return{...e,local:m,outbox:e.outbox.filter(g=>g.id!==t.id)}}case"archive-worktrees":{const f=t.ids.filter(C=>!e.archiving.includes(C)&&Gt(e,C));if(f.length===0)return e;const m=Date.now();let g=e.archived;for(const C of f){const I=Gt(e,C);I&&(g={...g,[I.repoId]:[ID(I,m),...g[I.repoId]??[]]})}const y={...e,archiving:[...e.archiving,...f],archived:g};if(!e.activeId||!f.includes(e.activeId))return y;const w=e.visible.filter(C=>C.id===e.activeId||!y.archiving.includes(C.id)),v=w.findIndex(C=>C.id===e.activeId),_=[C=>C.agent==="waiting",C=>vh(C.worktree)&&!!C.worktree.landed&&C.agent==="idle",C=>!!C.unseen,C=>C.agent==="working",C=>!Tr(C.worktree)&&ps(C)==="running"],x=C=>{for(const I of _){const A=C(I);if(A)return A.id}},N=x(C=>w.findLast((I,A)=>A<v&&C(I))),j=Cl(y,N??x(C=>w.find((I,A)=>A>v&&C(I)))??Wl(y,e.activeRepoId));return e.frame==="phone"?{...j,screen:"home"}:j}case"shipping":return e.shipping[t.id]||!(To(e,t.id)||v_(e,t.id))?e:{...e,shipping:{...e.shipping,[t.id]:{op:t.op,sent:!0}}};case"activate-repo":{if(!Li(e,t.id))return e;const f=e.newProject?{...e,newProject:null}:e;if(t.id===e.activeRepoId)return f;const m=Wl(f,t.id);return{...Cl(f,m),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 f="name"in t.v||"parent"in t.v||"url"in t.v||"mode"in t.v,{error:m,...g}=e.newProject;return{...e,newProject:{...f?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 f=t.v,m=e.editor,g=m&&Wc(m,f)?m:null,y=f.line&&t_(e,f.worktreeId,f.path,f.line);return{...e,editor:{worktreeId:f.worktreeId,path:f.path,...f.ref?{ref:f.ref}:{},...f.since?{since:f.since}:{},view:f.view??(g==null?void 0:g.view)??null,seq:f.seq,disk:(g==null?void 0:g.disk)??null,...y?{line:y}:{},...f.piece?{piece:f.piece}:{},focus:f.focus,conflict:(g==null?void 0:g.conflict)??null,blame:(g==null?void 0:g.blame)??null}}}case"open-loose":{const f=t.v,m={before:f.text,after:f.text,version:null,writable:(f.source.kind==="handle"||f.source.kind==="grant")&&!f.tooLarge&&!f.binary,binary:f.binary,tooLarge:f.tooLarge};return{...e,editor:{worktreeId:f.worktreeId,path:f.name,view:Ii(f.name),seq:f.seq,disk:m,focus:!0,conflict:null,blame:null,loose:{source:f.source}}}}case"editor-read":{const f=e.editor;if(!f||f.loose||!Wc(f,t.file))return e;const m=t.disk;if(!m){const w=p_(e,f.worktreeId,t.error??`could not read ${f.path}`);return f.disk?w:{...w,editor:null}}const g=Ii(f.path),y=m.before===""?f.view&&f.view!=="diff"?f.view:g:f.view??(m.before===m.after?g:"diff");return{...e,editor:{...f,view:y,disk:m}}}case"editor-conflict":{const f=e.editor;return f&&!f.loose&&Wc(f,t.file)?{...e,editor:{...f,conflict:t.theirs}}:e}case"editor-view":return e.editor?{...e,editor:{...e.editor,view:t.v,line:void 0}}:e;case"editor-refused":{const f=e.editor;if(!f||!Wc(f,t.file))return e;const m=f.loose&&f.disk?{...f.disk,writable:!1}:f.disk;return{...e,editor:{...f,refused:t.message,disk:m}}}case"editor-blame":{const f=e.editor;return f&&!f.loose&&Wc(f,t.file)?{...e,editor:{...f,blame:t.blame}}:e}case"notice":return mt(Qo(e),((s=fs(t.id))==null?void 0:s.source)??t.id,f=>({...f,notice:t.text}));case"link-refused":return mt(e,t.id,({refusedLink:f,...m})=>t.v?{...m,refusedLink:t.v}:m);case"card-draft":return mt(e,t.id,f=>({...f,card:t.card}));case"card-park":return mt(e,t.id,f=>({...f,cardParked:t.cardId}));case"card-unpark":return mt(e,t.id,({cardParked:f,...m})=>m);case"ask-revive":return mt(e,t.id,({askRevived:f,...m})=>t.askId?{...m,askRevived:t.askId}:m);case"opened-url":return e.openUrl?{...e,openUrl:null}:e;case"set-draft":return mt(e,t.id,f=>{const{notice:m,...g}=Al(f,"walk");return{...g,draft:t.text,...m!==void 0&&t.text===""?{notice:m}:{}}});case"move-box":return y_(e,t.from,t.to);case"walk":return mt(e,t.id,f=>({...Al(f,"walk"),draft:t.text,...t.walk?{mark:{by:"walk",at:t.walk.at,from:t.walk.from}}:{}}));case"reveal":return mt(Qo(e),t.id,f=>{var m;return{...f,mark:{by:"reveal",seq:t.seq,n:((m=f.mark)==null?void 0:m.by)==="reveal"?f.mark.n+1:1}}});case"attach":return mt(Qo(e),t.id,({notice:f,...m})=>({...m,attachments:[...m.attachments,...t.items]}));case"upload-progress":return(a=e.local[t.id])!=null&&a.attachments.some(f=>f.key===t.key&&Ai(f))?mt(e,t.id,f=>({...f,attachments:f.attachments.map(m=>m.key===t.key?{...m,progress:t.progress}:m)})):e;case"attached":return(c=e.local[t.id])!=null&&c.attachments.some(f=>f.key===t.key)?mt(e,t.id,f=>({...f,attachments:f.attachments.map(m=>m.key===t.key?t.item:m)})):e;case"detach":{const f=mt(e,t.id,({notice:m,...g})=>({...g,attachments:g.attachments.filter(y=>y.key!==t.key)}));return(u=e.local[t.id])!=null&&u.outgoing?Ni(f,{a:"unsend",id:t.id}):f}case"clear-attachments":return mt(e,t.id,({notice:f,...m})=>m.attachments.length?{...m,attachments:[]}:m);case"hmr":return mt(e,t.id,f=>({...f,turn:{...f.turn,hmr:!0}}));case"page":return mt(e,t.id,f=>({...f,page:{url:t.url??f.page.url,title:t.title??f.page.title}}));case"links":return mt(e,t.id,f=>{const m=nD(f.links??[],t.links);return m===f.links?f:{...f,links:m}});case"drag-files":return vD(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:h_(t.overlay)?e.paletteReturn:null};case"choosing-folder":return{...e,choosingFolder:t.v};case"close":return{...e,previewTheme:null,...zD(e,t.back)};case"toggle":return((h=e.overlay)==null?void 0:h.kind)===t.overlay.kind?Ni(e,{a:"close"}):Ni(e,{a:"open",overlay:t.overlay});case"palette-return":return{...e,paletteReturn:t.v};case"toggle-changes":return{...so(e,{changes:!e.layout.changes}),changesAuto:!1};case"focus-changes":return{...so(e,{changes:!0,changesTab:t.tab&&!Fo(e)?t.tab:e.layout.changesTab}),changesAuto:!1,focusChanges:e.focusChanges+1};case"changes-tab":return so(e,{changesTab:t.v});case"edit-commit":return{...so(e,{changes:!0}),changesAuto:!1,editCommit:e.editCommit+1};case"toggle-chat":return ns(e)?e:so(e,{chat:!e.layout.chat});case"focus-chat":return{...Qo(e),focusChat:e.focusChat+1};case"walked":return{...e,walked:e.walked+1};case"show-chat":return Qo(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"?so(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 f={...e,frame:t.v};if(t.v!=="desk"||!f.activeRepoId)return f;const m=f.layouts[f.activeRepoId];return m?_w(f,m):f}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 f=e.activeRepoId;return f?{...e,discoveredOpen:{...e.discoveredOpen,[f]:!e.discoveredOpen[f]}}:e}case"toggle-archived":{const f=e.activeRepoId;return f?{...e,archivedOpen:{...e.archivedOpen,[f]:!e.archivedOpen[f]}}:e}case"toggle-committed":{const f=e.activeRepoId;return f?{...e,committedShut:{...e.committedShut,[f]:!e.committedShut[f]}}:e}case"toggle-turn":{const f=e.activeRepoId;return f?{...e,turnOpen:{...e.turnOpen,[f]:!e.turnOpen[f]}}:e}case"tree-folder":{const f=e.treeOpen[t.worktreeId]??[];if(f.includes(t.path)===t.open)return e;const m=t.open?[...f,t.path]:f.filter(y=>y!==t.path),g={...e.treeOpen};return m.length>0?g[t.worktreeId]=m:delete g[t.worktreeId],{...e,treeOpen:g}}case"tree-reveal":{const f=e.treeOpen[t.worktreeId]??[],m=[];for(let w=t.path.indexOf("/");w!==-1;w=t.path.indexOf("/",w+1))m.push(t.path.slice(0,w));m.push(t.path);const g=m.filter(w=>!f.includes(w)),y=g.length?{...e.treeOpen,[t.worktreeId]:[...f,...g]}:e.treeOpen;return{...so(e,{changes:!0,changesTab:"files"}),changesAuto:!1,focusChanges:e.focusChanges+1,treeOpen:y,treeReveal:{worktreeId:t.worktreeId,path:t.path}}}case"files-asked":return mt(e,t.worktreeId,f=>({...f,filesFor:t.key}));case"toggle-zen":return ns(e)?e:{...e,zen:!e.zen};case"toggle-terminal":return so(e,{term:!e.layout.term});case"focus-terminal":return{...so(e,{term:!0}),focusTerm:e.focusTerm+1};case"toggle-design":return ns(e)?e:so(e,{design:!e.layout.design});case"term-stream":return mt({...so(e,{term:!0}),termTall:t.tall?e.termTall+1:e.termTall},t.id,f=>({...f,termStream:t.stream}));case"term-run":return mt({...so(e,{term:!0}),focusTerm:e.focusTerm+1,termRun:{id:t.id,command:t.command}},t.id,f=>({...f,termStream:Do}));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 rz(e,t.msg);case"recall":return nz(e,t.hello,t.chats)}}function k_(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 w_(e,t,n){const r=new Set(t.map(a=>a.id));n&&r.add(n);const o=([a,c])=>r.has(a)||!!c.draft||c.attachments.length>0,s=Object.entries(e);return s.every(o)?e:Object.fromEntries(s.filter(o))}function ZD(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(h=>{var f;return h.id===s.id&&((f=h.worktree)==null?void 0:f.landed)}))continue;const a=r[s.id];if(!(a!=null&&a.git)||a.git.files.length===0)continue;r===e&&(r={...e});const{extras:c,...u}=a.git;r[s.id]={...a,git:{...u,files:[]}}}return r}function GD(e,t){const{version:n,files:r,ahead:o,behind:s,unpushed:a,head:c}=t,u={version:n,files:r,...o===void 0?{}:{ahead:o},...s===void 0?{}:{behind:s},...a===void 0?{}:{unpushed:a},...c===void 0?{}:{head:c}};if(t.extras)return{...u,extras:t.extras};const h=new Map(e==null?void 0:e.files.map(y=>[y.path,y])),f=r.map(y=>{const w=h.get(y.path);return w&&w.xy===y.xy&&w.add!==void 0?{...y,add:w.add,del:w.del}:y}),m=e!=null&&e.extras&&e.head===c?e.extras:void 0,g=m&&r.length===0&&m.turn?{committed:m.committed}:m;return{...u,files:f,...g?{extras:g}:{}}}function VD(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 YD(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 XD(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 QD(e,t){let n=e;for(const[r,o]of Object.entries(t)){const s=n[r];s!=null&&s.draft||fs(r)||(n===e&&(n={...e}),n[r]={...s??Aa,draft:o})}return n}function JD(e,t){let n=e;for(const[r,o]of Object.entries(t)){const s=n[r];s!=null&&s.attachments.length||fs(r)||(n===e&&(n={...e}),n[r]={...s??Aa,attachments:Wg(o,[])})}return n}function ez(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 xi(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 qb(e){const t=e.newProject;if((t==null?void 0:t.phase)!=="creating"||!t.repoId)return e;const n=a_(e,t.repoId);if(!n)return e;const r=Wr(e,Ul);return!r.draft.trim()&&r.attachments.length===0?{...e,newProject:null}:{...y_(e,Ul,n.id),newProject:null,autoSend:n.id}}function y_(e,t,n){const r=e.local[t];if(!r)return e;const o=mt(e,n,s=>({...s,draft:r.draft,attachments:r.attachments}));return mt(o,t,s=>({...s,draft:"",attachments:[]}))}function hf(e,t,n){return e.stamps?{...e.stamps,[t]:n}:null}function tz(e){return e.stamps?cP(e.stamps):null}function v_(e,t){return Object.values(e.trunks).some(n=>n.id===t)}function b_(e,t,n){var w;const{rows:r,repos:o,trunks:s,visits:a}=t.same?e:t,c=v=>!!v&&r.some(_=>_.id===v),u=v=>!!v&&o.some(_=>_.id===v),h=u(e.activeRepoId)?e.activeRepoId:u(e.storedRepo)?e.storedRepo:null,f=c(e.activeId)?e.activeId:c(e.storedActive)?e.storedActive:Wl(e,h,r),m=r.find(v=>v.id===f),g=!!h&&!!m&&Sn(m)&&Fh(m,h,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:f,lent:g?e.lent===f?e.lent:c_(m??null,h,r):null,activeRepoId:g?h:(m==null?void 0:m.repoId)??h??((w=o[0])==null?void 0:w.id)??null,trunks:s,archiving:e.archiving.length?[]:e.archiving,shipping:d_({},r,s),local:YD(w_(JD(QD(e.local,t.drafts),t.attachments),r,e.archivedPage)),lastActive:ez(e.lastActive,r),treeOpen:k_(e.treeOpen,r),discoveredOpen:xi(e.discoveredOpen,o),archivedOpen:xi(e.archivedOpen,o),committedShut:xi(e.committedShut,o),turnOpen:xi(e.turnOpen,o),refs:xi(e.refs,o),chats:xi(e.chats,o),archived:xi(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?e_():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:g_(y,t.knocks,t.letIn)}function Gg(e,t=[]){let n=t,r;for(const{seq:o,event:s}of e)n=E_(n,s,o),s.type==="usage"&&(r=x_(s));return r?{chat:n,usage:r}:{chat:n}}function nz(e,t,n){var s;let r=b_(e,dD(t),!0);r={...r,recalledAt:t.at};for(const[a,c]of Object.entries(n))if(r.rows.some(u=>u.id===a))try{const{chat:u,usage:h}=Gg(c.events);r=mt(r,a,f=>({...f,chat:S_(u),chatAt:pD(c.events)??t.at,running:void 0,...h?{usage:h}:{},...c.draft&&!f.draft?{draft:c.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 rz(e,t){var n,r,o,s,a,c,u,h,f,m,g,y,w,v,_;switch(t.t){case"hello":return b_(e,t,!1);case"self":{const x=((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||x&&((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 g_(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:hf(e,"visits",t.stamp)};case"themes":return{...e,themes:t.themes,themePrefs:t.prefs,stamps:hf(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:x,...N}=t;return{...e,agentConfigs:{...e.agentConfigs,[N.agent]:N}}}case"pending-repos":{const x=new Set(e.pending.map(I=>I.id)),N=t.pending.find(I=>!x.has(I.id)),T=N&&e.pendingOpen?N.id:e.activeImportId,j=t.pending.some(I=>I.id===T),C=t.pending.some(I=>I.id===T&&I.error);return{...e,pending:t.pending,activeImportId:j?T:null,pendingOpen:C?!1:e.pendingOpen,newProject:N&&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 x=(e.archived[t.repoId]??[]).filter(N=>e.archiving.includes(N.id)&&!t.items.some(T=>T.id===N.id));return{...e,archived:{...e.archived,[t.repoId]:x.length?[...x,...t.items]:t.items}}}case"draft":return t.clientId===e.clientId||fs(t.boxId)?e:mt(e,t.boxId,x=>{var N;return x.draft===t.text||((N=x.mark)==null?void 0:N.by)==="walk"?x:{...x,draft:t.text}});case"attachments":return t.clientId===e.clientId||fs(t.boxId)?e:mt(e,t.boxId,x=>({...x,attachments:Wg(t.items,x.attachments)}));case"repos":{const x=new Set(e.repos.map(O=>O.id)),N=t.repos.find(O=>!x.has(O.id));let T=e.activeRepoId,j=e.pendingOpen,C=e.newProject;N&&(j||!T)?(T=N.id,j=!1,C&&C.phase!=="unmaking"&&(C={...C,phase:"creating",repoId:N.id})):t.repos.some(O=>O.id===T)||(T=((c=t.repos[0])==null?void 0:c.id)??null),(C==null?void 0:C.phase)==="unmaking"&&!t.repos.some(O=>O.id===(C==null?void 0:C.repoId))&&(C={...C,phase:"editing",repoId:null}),t.repos.length===0&&!C&&(C=e_());const I=e.gitIdentity||t.repos.some(O=>O.made&&!x.has(O.id)),A=hf(e,"repos",t.stamp),M=xi(e.visits,t.repos);return T===e.activeRepoId?{...e,repos:t.repos,stamps:A,visits:M,pendingOpen:j,newProject:C,gitIdentity:I}:qb({...e,repos:t.repos,stamps:A,visits:M,pendingOpen:j,newProject:C,gitIdentity:I,activeRepoId:T,activeId:Wl(e,T),editor:null})}case"worktrees":{const{rows:x,complete:N}=aD(e.rows,t),T=t.trunks??e.trunks;let j=e.activeId;(!j||!x.some(O=>O.id===j))&&(j=Wl(e,e.activeRepoId,x));const C=new Set(e.rows.map(O=>O.id)),I=O=>{var z;return((z=O.worktree)==null?void 0:z.kind)==="worktree"&&O.worktree.createdBy===e.clientId},A=x.find(O=>!C.has(O.id)&&I(O));A&&e.rows.length>0&&(j=A.id);const M=e.archiving.filter(O=>x.some(z=>z.id===O));return qb({...Cl({...e,rows:x,trunks:T,stamps:hf(e,"rows",N?t.stamp:""),archiving:M.length===e.archiving.length?e.archiving:M,shipping:d_(e.shipping,x,T),local:w_(LD(ZD(e.local,e.rows,x),x,e.activeId,j===(A==null?void 0:A.id)?A.id:void 0),x,e.archivedPage),treeOpen:k_(e.treeOpen,x)},j),editor:j===e.activeId?e.editor:null,...A&&j===A.id?{carryTo:A.id}:{},...j===e.activeId?{activeRepoId:e.activeRepoId}:{},archivedPage:A?null:e.archivedPage,notesPage:A?!1:e.notesPage})}case"log":return mt(e,t.worktreeId,x=>({...x,log:vA(x.log.slice(-400),t.proc,t.line,t.retract)}));case"agent":{const x=t.event,N=t.worktreeId;let T=mt(e,N,j=>{const C=E_(j.chat,x,t.seq),I=x.type==="turn-end",A=I||x.type==="agent-error"||x.type==="agent-auth-required",O=x.type==="tool-start"||x.type==="tool-end"||I||x.type==="tool-update"&&x.background?Wb(C,j.running):j.running;let z=j.turn;x.type==="turn-start"?z={edits:!1,hmr:!1}:x.type==="tool-start"&&NE(x)&&(z={...z,edits:!0});const B=x.type==="session-info"&&x.model?x.model:j.model,H=x.type==="session-info"&&x.effort?x.effort:j.effort,Y=x.type==="usage"?{...x_(x),heard:Date.now()}:j.usage,ie=e.rows.find($=>$.id===N),Q=os(ie==null?void 0:ie.agent),le=j.sending?Q?yu(j):{...j,sending:{at:j.sending.at}}:j,U=PD(x.type==="user-message"?le:A?yu(j):j,x);return{...x.type==="user-message"?Al(U,"reveal"):U,chat:C,...C!==j.chat?{chatAt:Date.now()}:{},...O!==j.running?{running:O}:{},turn:z,...B!==j.model?{model:B}:{},...H!==j.effort?{effort:H}:{},...Y!==j.usage?{usage:Y}:{}}});if(x.type==="agent-ask-end"&&!mw(x.outcome)&&((u=T.local[Rl(x.id)])!=null&&u.attachments.length)&&(T=mt(T,Rl(x.id),j=>({...j,attachments:[]}))),x.type==="user-message"){const j=FS(((h=e.local[N])==null?void 0:h.chat)??[]),C=j?Rl(j.id):null,I=C?((f=T.local[C])==null?void 0:f.attachments)??[]:[];C&&I.length&&(T=mt(T,C,A=>({...A,attachments:[]})),T=mt(T,N,A=>({...A,attachments:[...A.attachments,...I]})))}if(x.type==="turn-end"){const j=T.local[N].turn;j.edits&&!j.hmr&&(T={...T,reloadReq:{id:N,n:(((m=T.reloadReq)==null?void 0:m.n)??0)+1}})}return(x.type==="agent-question"||x.type==="agent-permission"||x.type==="handoff-proposed"&&!x.held||x.type==="handoff-shown")&&N===e.activeId&&(T=Qo(T)),T}case"backfill":{const x=N=>t.events.some(({event:T})=>T.type==="user-message"&&T.text===N);return mt(e,t.worktreeId,({sending:N,...T})=>{const{chat:j,usage:C}=t.after!==void 0?Gg(t.events,T.chat):Gg(t.events);return{...T,...N&&!(N.message&&x(N.message.text))?{sending:N}:{},chat:j,chatAt:Date.now(),running:Wb(j,T.running),log:t.log??T.log,...C?{usage:C}:{}}})}case"git-status":{const x=(g=e.local[t.worktreeId])==null?void 0:g.git;if(t.version>0&&x&&t.version<x.version||t.version>0&&x&&t.version===x.version&&!t.extras)return e;let N=e.layout.changes,T=e.changesAuto;const j=((y=t.extras)==null?void 0:y.committed.length)??0;e.changesAuto&&t.worktreeId===e.activeId&&!N&&(t.files.length>0||j>0)&&(N=!0,T=!1);const C=t.worktreeId===e.archivedPage?Fo(e):null;C&&(t.files.length>0||j>0||C.landed)&&(N=!0);const I=mt(e,t.worktreeId,A=>{const M=GD(A.git,t);return{...A,git:M,changedRanges:VD(A.git,M,A.changedRanges)}});return{...so(I,{changes:N}),changesAuto:T}}case"pr-comments":return mt(e,t.worktreeId,x=>({...x,prComments:t.comments}));case"changed-ranges":{const x=mt(e,t.worktreeId,T=>({...T,changedRanges:{...T.changedRanges,[t.path]:{ranges:t.ranges,offset:t.lineOffset}}})),N=x.editor;return!((w=N==null?void 0:N.line)!=null&&w.fiber)||N.worktreeId!==t.worktreeId||N.path!==t.path?x:{...x,editor:{...N,line:t_(x,N.worktreeId,N.path,N.line)}}}case"shipped":{const x=t.worktreeId,N={...e,shipping:Hb(e.shipping,T=>{var j;return T===x&&((j=e.shipping[T])==null?void 0:j.sent)===!0}),openUrl:t.ok&&t.url?t.url:e.openUrl};return!t.ok&&!t.asked?x?Kb(N,x,t.message):Zg(N,t.message):N}case"files":return mt(e,t.worktreeId,x=>({...x,files:t.paths,submodules:t.submodules,ignored:t.ignored}));case"search-results":return mt(e,t.worktreeId,x=>({...x,search:{query:t.query,hits:t.hits,truncated:t.truncated}}));case"element-sources":{if(e.editor&&e.editor.seq>t.seq)return e;const[x]=t.hits;if(!x)return mt(e,t.worktreeId,T=>({...T,notice:"nothing in the source matches this element"}));if(!t.sure)return Ni(e,{a:"open",overlay:{kind:"element-sources",worktreeId:t.worktreeId,hits:t.hits}});const N=Ni(e,{a:"open-file",v:{worktreeId:t.worktreeId,path:x.path,view:"file",line:{n:x.line},focus:!0,seq:t.seq}});return N.layout.changes?N:Ni(N,{a:"toggle-changes"})}case"design-index":return mt(e,t.worktreeId,x=>({...x,design:t.index}));case"routes":return mt(e,t.worktreeId,x=>({...x,pages:{routes:t.routes,unseen:t.unseen}}));case"queue":return mt(e,t.worktreeId,x=>({...x,queue:t.items}));case"agent-commands":return mt(e,t.worktreeId,x=>({...x,commands:t.commands}));case"git-log":return mt(e,t.worktreeId,x=>({...x,commits:t.commits}));case"git-commit":return mt(e,t.worktreeId,x=>({...x,commitFiles:{...x.commitFiles,[t.sha]:t.files}}));case"error":{const x=t.worktreeId,N=e.newProject,T=(N==null?void 0:N.phase)==="creating"&&!N.repoId,j=x?e.archiving.includes(x)?[x]:[]:e.archiving,C={...MD(e,x),archiving:j.length?e.archiving.filter(I=>!j.includes(I)):e.archiving,archived:j.length?RD(e.archived,j):e.archived,shipping:Hb(e.shipping,I=>!x||I===x),newProject:T?{...N,phase:"editing",error:t.message}:(N==null?void 0:N.phase)==="unmaking"?null:N,pendingOpen:T?!1:e.pendingOpen,updateCheck:!x&&e.updateCheck==="asking"?null:e.updateCheck};return T?C:x?Kb(C,x,t.message):Zg(C,t.message)}case"unsent":{const x=((v=fs(t.boxId))==null?void 0:v.source)??t.boxId,N=!To(e,x)&&!!e.activeRepoId&&((_=e.archived[e.activeRepoId])==null?void 0:_.some(T=>T.id===x));return mt(Qo(N?i_(e,x):e),x,({sending:T,...j})=>({...j,draft:j.draft||t.text,attachments:[...Wg(t.items,[]),...j.attachments],notice:t.message}))}default:return e}}function x_(e){return{used:e.used,size:e.size,...e.cost!==void 0?{cost:e.cost}:{}}}function oz(e,t){const n=t.trim();return n!==""&&(e.trim()===n||e.trim().endsWith(`: ${n}`))}function E_(e,t,n){var s,a,c,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 h=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 f=t.messageId===void 0?-1:sz(e,t.messageId);if(f!==-1){const m=e.slice(),g=m[f];return m[f]={...g,text:g.text+t.text},m}return[...e,{kind:"assistant",text:t.text,...o,...h}]}case"picture":{const{type:h,...f}=t;let m=e.findLastIndex(w=>w.kind==="assistant"&&w.text.includes(f.path));if(m===-1&&(m=e.findLastIndex(w=>w.kind==="assistant")),m===-1)return e;const g=e.slice(),y=g[m];return g[m]={...y,pictures:[...(y.pictures??[]).filter(w=>w.path!==f.path),f]},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 h=e.findLastIndex(g=>g.kind==="tool"&&g.id===t.toolId);if(h===-1)return e;const f=e.slice(),m=f[h];return f[h]={...m,...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}:{}},f}case"tool-delta":{const h=e.findLastIndex(g=>g.kind==="tool"&&g.id===t.toolId);if(h===-1)return e;const f=e.slice(),m=f[h];return f[h]={...m,output:(m.output??"")+t.text},f}case"tool-end":{const h=e.findLastIndex(g=>g.kind==="tool"&&g.id===t.toolId);if(h===-1)return e;const f=e.slice(),m=f[h];return f[h]={...m,output:t.output,isError:t.isError,...(c=t.images)!=null&&c.length?{images:t.images}:{},...t.detached?{detached:!0}:{},...t.fixable?{fixable:t.fixable}:{},...t.cut?{cut:!0}:{},done:!0},f}case"agent-error":return(r==null?void 0:r.kind)==="assistant"&&oz(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 h=t.held?e.findLast(m=>m.kind==="ask"&&!m.outcome&&m.ask.kind==="permission"&&!!m.ask.plan):void 0,f=(h==null?void 0:h.kind)==="ask"&&h.ask.kind==="permission"?{companion:h.id,plan:h.ask.plan}:{};return[...e,{kind:"handoff",id:t.id,pieces:t.pieces,fates:Object.fromEntries(t.pieces.map(m=>[m.id,m.fate])),mode:t.mode,...t.held?{held:!0}:{},...t.plan?{plan:t.plan}:{},...t.by?{by:t.by}:{},...f,state:t.held?"held":"proposed",outcomes:[],later:[],ts:t.ts}]}case"handoff-stale":{const h=vl(e,t.id,["held","proposed"]);return h===-1?e:e.with(h,{...e[h],stale:!0})}case"handoff-shown":{const h=vl(e,t.id,["held","proposed"]);if(h===-1)return e;const f=e[h];return e.with(h,{...f,state:"proposed",...t.plan?{plan:t.plan}:{}})}case"handoff-fate":{const h=vl(e,t.id,["held","proposed"]);if(h===-1)return e;const f=e[h];return e.with(h,{...f,fates:{...f.fates,[t.pieceId]:t.fate}})}case"handoff-go":{const h=vl(e,t.id,["held","proposed"]);if(h===-1)return e;const f=e[h];if(f.state!=="proposed")return e.with(h,{...f,state:"going"});const m={go:!0,...t.note?{note:t.note}:{}};return Zb(e,h,{...f,state:"going",answered:m,ts:t.ts})}case"handoff":{const h=vl(e,t.id,["held","proposed","going"]);return h===-1?[...e,{kind:"handoff",id:t.id,pieces:[],fates:{},mode:jg,state:"done",outcomes:t.outcomes,later:[],ts:t.ts}]:e.with(h,{...e[h],state:"done",outcomes:t.outcomes})}case"handoff-declined":{const h=vl(e,t.id,["held","proposed","going"]);if(h===-1)return e;const f=e[h],{companion:m,...g}=f,y=t.plan?{...g,plan:t.plan}:f;return y.state==="proposed"&&!t.reason?Zb(e,h,{...y,state:"declined",answered:{go:!1},ts:t.ts}):e.with(h,{...y,state:"declined",...t.reason?{reason:t.reason}:{}})}case"piece-made":case"piece-dropped":{const h=e.findLastIndex(v=>v.kind==="handoff"&&v.id===t.id),f=h===-1?void 0:e[h],m=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=f==null?void 0:f.pieces.find(v=>v.id===t.pieceId))==null?void 0:u.title,y={kind:"piece-later",id:t.id,...g?{title:g}:{},...m,ts:t.ts};return[...f?e.with(h,{...f,later:[...f.later,m]}):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"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(h=>h.kind==="auth"&&!h.done)?e.map(h=>h.kind==="auth"&&!h.done?{...h,done:!0}:h):e;case"agent-question":return Gb(e,t.toolId,{kind:"ask",id:t.id,ask:{kind:"question",message:t.message,questions:t.questions}});case"agent-permission":{const h={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}},f=t.handoff?e.findLastIndex(y=>y.kind==="handoff"&&y.id===t.handoff):-1,m=f===-1?e:e.with(f,{...e[f],companion:t.id,...t.plan&&!e[f].plan?{plan:t.plan}:{}}),g=m.findLast(y=>y.kind==="tool"&&y.id===t.toolId);return(g==null?void 0:g.kind)!=="tool"||t.plan||g.toolKind==="switch_mode"?Gb(m,t.toolId,h):[...m,{...h,toolId:g.id}]}case"agent-ask-end":{const h=e.findLastIndex(g=>g.kind==="ask"&&g.id===t.id&&!g.outcome);if(h===-1)return e;const f=e[h];if(f.toolId&&iz(f,t.choiceId))return[...e.slice(0,h),...e.slice(h+1)];const m=e.slice();return m[h]={...m[h],outcome:t.outcome,...t.answers?{answers:t.answers}:{},...t.choiceId?{choiceId:t.choiceId}:{}},m}case"turn-end":{const h=S_(e);return t.stopReason==="interrupted"?[...h,{kind:"stopped",...o}]:h}default:return e}}function S_(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 sz(e,t){const n=s=>Du(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 vl(e,t,n){return e.findLastIndex(r=>r.kind==="handoff"&&r.id===t&&n.includes(r.state))}function Zb(e,t,n){return[...e.slice(0,t),...e.slice(t+1),n]}function iz(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 Gb(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 az(e){let t=e;const n=new Set;return{getState:()=>t,dispatch(r){const o=Ni(t,r);if(o!==t){t=o;for(const s of n)s()}},subscribe(r){return n.add(r),()=>n.delete(r)}}}const __=S.createContext(null),Cw=S.createContext(null),N_=S.createContext(null);function lz({store:e,sock:t,files:n,children:r}){return d.jsx(__.Provider,{value:e,children:d.jsx(Cw.Provider,{value:t,children:d.jsx(N_.Provider,{value:n,children:r})})})}const T_=S.createContext(null),j_=S.createContext(null);function cz({machines:e,children:t}){const n=S.useSyncExternalStore(e.subscribe,e.active);return d.jsx(T_.Provider,{value:e,children:d.jsx(j_.Provider,{value:n,children:d.jsx(lz,{store:n.store,sock:n.sock,files:n.files,children:d.jsx(S.Fragment,{children:t},n.origin)})})})}function gs(){const e=S.useContext(T_);if(!e)throw new Error("useMachines outside <MachinesProvider>");return e}function Ds(){const e=S.useContext(j_);if(!e)throw new Error("useMachine outside <MachinesProvider>");return e}function Aw(){const e=gs();return S.useSyncExternalStore(e.subscribe,e.list)}function Kc(e,t){return S.useSyncExternalStore(e.store.subscribe,()=>t(e.store.getState()))}const Vg=(e,t)=>e.length===t.length&&e.every((n,r)=>n===t[r]);function $_(){const e=gs(),t=Ds(),n=Aw(),r=S.useMemo(()=>n.filter(c=>c!==t),[n,t]),o=S.useRef(null),s=S.useCallback(c=>{const u=r.map(h=>h.store.subscribe(c));return()=>{for(const h of u)h()}},[r]),a=S.useCallback(()=>{const c=r.map(m=>e.displayName(m.origin)),u=r.map(m=>m.store.getState().repos),h=o.current;if(h&&h.others===r&&Vg(h.names,c)&&Vg(h.repos,u))return h.value;const f=r.map((m,g)=>({origin:m.origin,name:c[g]??m.origin,repos:u[g]??[]}));return o.current={others:r,names:c,repos:u,value:f},f},[r,e]);return S.useSyncExternalStore(s,a)}function C_(){const e=Ds(),t=Aw(),n=S.useMemo(()=>t.filter(a=>a!==e),[t,e]),r=S.useRef(null),o=S.useCallback(a=>{const c=n.map(u=>u.store.subscribe(a));return()=>{for(const u of c)u()}},[n]),s=S.useCallback(()=>{const a=n.map(h=>{const f=h.store.getState();return f.connected&&!f.incompatible?f.rows:Vb}),c=r.current;if(c&&c.others===n&&Vg(c.rows,a))return c.value;const u=n.map((h,f)=>({origin:h.origin,rows:(a[f]??Vb).filter(Sn)}));return r.current={others:n,rows:a,value:u},u},[n]);return S.useSyncExternalStore(o,s)}const Vb=[];function pV(){return Ds().terminals}function On(){const e=S.useContext(__);if(!e)throw new Error("useStore outside <StoreProvider>");return e}function L(e){const t=On();return S.useSyncExternalStore(t.subscribe,()=>e(t.getState()))}function Iw(){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 lt(){return On().dispatch}function Je(){return S.useContext(Cw)}function Rr(){const e=S.useContext(Cw);return(e==null?void 0:e.urls)??pw(location.origin,"")}function Rw(){return S.useContext(N_)}function uz(e=!1,t=!0){const n=S.useRef(null);return S.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 As(e,t,n,r=dz){const o=()=>{try{return n(r.get(e))??t}catch{return t}},[s,a]=S.useState(()=>({key:e,value:o()}));return s.key!==e&&a({key:e,value:o()}),[s.key===e?s.value:o(),h=>{a({key:e,value:h});try{r.set(e,typeof h=="boolean"?h?"1":"0":String(h))}catch{}}]}const dz={get:e=>localStorage.getItem(e),set:(e,t)=>localStorage.setItem(e,t)};function Ll(e,t){return n=>{n.preventDefault(),document.body.classList.add("resizing");const r=n.currentTarget;r.classList.add("active");const o=a=>{const c=e(a,r);c!==null&&t(c)},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 A_(e,t){const[n,r]=S.useState(!1);return S.useEffect(()=>{if(!e){r(!1);return}const o=setTimeout(()=>r(!0),t);return()=>clearTimeout(o)},[e,t]),n}function Ow(e,t){const[n,r]=S.useState(void 0);return S.useEffect(()=>{if(e===void 0){r(void 0);return}const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),n}const Mw=1500;function Ti(e){const[t,n]=S.useState(()=>Date.now()),r=e!==void 0;return S.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 fz(){const[e,t]=S.useState(window.innerWidth);return S.useEffect(()=>{const n=()=>t(window.innerWidth);return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),e}function hz(e){const t=S.useRef(null);return S.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,c=s.bottom-(o.bottom-a);if(c<=0)return;const u=parseFloat(getComputedStyle(r).paddingTop)||0;r.scrollTop+=Math.min(c,Math.max(0,s.top-o.top-u))}),n=>{t.current=n}}const Xm=40,pz=1200,mz=150,gz=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]);function I_(e,t){const n=S.useRef(!0),r=S.useRef(Number.NEGATIVE_INFINITY),o=S.useRef(!1),[s,a]=S.useState(!1),[c,u]=S.useState(!1),[h,f]=S.useState(!1),[m,g]=S.useState(null),y=S.useCallback(C=>{n.current=C,e.current&&(e.current.style.overflowAnchor=C?"none":"")},[e]),w=S.useRef(null),v=S.useRef(null);at([t],()=>{n.current||f(!0)});const _=S.useCallback(()=>n.current,[]),x=S.useCallback(()=>{const C=e.current;C&&(y(C.scrollHeight-C.scrollTop-C.clientHeight<Xm),a(!n.current),u(C.scrollTop>=Xm),n.current&&f(!1))},[e,y]),N=S.useCallback(C=>{Math.abs(C)<4||(g(C<0?"up":"down"),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>g(null),pz))},[]),T=S.useCallback(()=>{const C=e.current;C&&(C.scrollTop=C.scrollHeight,y(!0),a(!1),f(!1))},[e,y]),j=S.useCallback(()=>{const C=e.current;C&&(r.current=performance.now(),C.scrollTop=0)},[e]);return S.useEffect(()=>{const C=e.current;if(!C)return;y(n.current);const I=()=>o.current||performance.now()-r.current<mz,A=()=>{n.current&&!I()?u(C.scrollTop>=Xm):x()};C.addEventListener("scroll",A,{passive:!0});const M=()=>{r.current=performance.now()},O=$=>{M(),N($.deltaY)},z=$=>{var q;M(),w.current=((q=$.touches[0])==null?void 0:q.clientY)??null},B=$=>{var V;M();const q=(V=$.touches[0])==null?void 0:V.clientY;q===void 0||w.current===null||(N(w.current-q),w.current=q)},H=()=>{o.current=!0},Y=()=>{o.current=!1},ie=$=>{if(!gz.has($.key))return;const q=$.target;(q===document.body||q instanceof Node&&C.contains(q))&&M()};C.addEventListener("wheel",O,{passive:!0}),C.addEventListener("touchstart",z,{passive:!0}),C.addEventListener("touchmove",B,{passive:!0}),C.addEventListener("pointerdown",H,{passive:!0}),window.addEventListener("pointerup",Y,{passive:!0}),window.addEventListener("pointercancel",Y,{passive:!0}),document.addEventListener("keydown",ie);const Q=()=>{C.scrollTop=C.scrollHeight},le=new ResizeObserver(()=>{n.current&&Q()});le.observe(C);for(const $ of C.children)le.observe($);const U=new MutationObserver($=>{for(const q of $){for(const V of q.addedNodes)V instanceof Element&&le.observe(V);for(const V of q.removedNodes)V instanceof Element&&le.unobserve(V)}n.current&&Q()});return U.observe(C,{childList:!0}),()=>{C.removeEventListener("scroll",A),C.removeEventListener("wheel",O),C.removeEventListener("touchstart",z),C.removeEventListener("touchmove",B),C.removeEventListener("pointerdown",H),window.removeEventListener("pointerup",Y),window.removeEventListener("pointercancel",Y),document.removeEventListener("keydown",ie),U.disconnect(),le.disconnect(),v.current&&clearTimeout(v.current)}},[e,x,N,y]),{offEnd:s,offStart:c,away:h,moving:m,pinned:_,jump:T,start:j,read:x}}function Yb(e,t,n){const r=document.createRange();return r.selectNodeContents(e),r.setEnd(t,n),r.toString().length}function Xb(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 R_(e,t){S.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)?Yb(n,r.anchorNode,r.anchorOffset):null,a=r&&r.rangeCount>0&&o(r.focusNode)?Yb(n,r.focusNode,r.focusOffset):null,c=r&&(s!==null||a!==null)?[r.anchorNode,r.anchorOffset,r.focusNode,r.focusOffset]:null;if(n.innerHTML=t,!r||!c)return;const[u,h]=s===null?[c[0],c[1]]:Xb(n,s),[f,m]=a===null?[c[2],c[3]]:Xb(n,a);u&&f&&r.setBaseAndExtent(u,h,f,m)},[e,t])}function at(e,t){const n=S.useRef(t);n.current=t,S.useEffect(()=>n.current(),e)}function O_(e){const[t,n]=S.useState({left:0,right:0});return S.useLayoutEffect(()=>{if(!e)return;const r=()=>{const s=e.getBoundingClientRect();let{left:a,right:c}=s;const u=e.closest("[data-pinned]");if(u){const f=u.getBoundingClientRect(),m=u.offsetWidth/f.width;a=u.offsetLeft+(a-f.left)*m,c=u.offsetLeft+(c-f.left)*m}const h={left:Math.round(a),right:Math.round(c)};n(f=>f.left===h.left&&f.right===h.right?f:h)};r();const o=new ResizeObserver(r);return o.observe(e),window.addEventListener("resize",r),()=>{o.disconnect(),window.removeEventListener("resize",r)}},[e]),t}function Qb(){const[e,t]=S.useState(null);return[t,O_(e)]}function mV(e){e.ctrlKey&&e.stopPropagation()}function M_(e,t){return e.defaultPrevented||e.ctrlKey?!1:t<1.01}function gV(e){S.useEffect(()=>{const t=e.current;if(!t)return;const n=r=>{var o;M_(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 L_={axis:null,dx:0,dy:0,at:Number.NEGATIVE_INFINITY},kz=2,wz=4,yz=300;function vz(e,t,n){const r=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=r>o?"x":"y",a=n-e.at<=yz?e:L_;if(a.axis===null){const u=a.dx+r,h=a.dy+o,f=Math.max(u,h)>=kz?u>h?"x":"y":null;return{scrolls:f!==null&&f===s,next:{axis:f,dx:u,dy:h,at:n}}}return s===a.axis?{scrolls:!0,next:{...a,at:n}}:(s==="x"?r:o)>=wz?{scrolls:!0,next:{...a,axis:s,at:n}}:{scrolls:!1,next:{...a,at:n}}}function kV(e){S.useEffect(()=>{const t=e.current;if(!t)return;let n=L_;const r=o=>{var c;if(o.ctrlKey)return;const{scrolls:s,next:a}=vz(n,o,o.timeStamp);n=a,!s&&(o.stopPropagation(),M_(o,((c=window.visualViewport)==null?void 0:c.scale)??1)&&o.preventDefault())};return t.addEventListener("wheel",r,{capture:!0,passive:!1}),()=>t.removeEventListener("wheel",r,{capture:!0})},[e])}function bz(e){S.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 xz(e){S.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 Ez(e){S.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 Sz(e,t,n){const[r,o]=S.useState(),s=S.useRef(e);return s.current=e,S.useEffect(()=>{if(!n)return;let a=!0,c;const u=()=>void s.current().then(h=>{a&&(o(h),c=setTimeout(u,t))});return u(),()=>{a=!1,clearTimeout(c)}},[t,n]),r}const Ql=()=>L(e=>e.activeId),P_=()=>A_(!L(e=>e.connected),900),_z=e=>!e.connected&&(e.connectFailure==="down"||e.connectFailure==="blocked"),D_=()=>L(_z),zs=()=>L(e=>Gt(e,e.activeId)),Lw=()=>L(e=>To(e,e.activeId)),z_=()=>L(e=>e.rows),Pw=()=>L(e=>e.visible),Nz=()=>L(e=>e.visibleDiscovered),Tz=()=>L(e=>e.activeRepoId?e.discoveredOpen[e.activeRepoId]??!1:!1),Jb=[],jz=()=>L(e=>e.activeRepoId?e.archived[e.activeRepoId]??Jb:Jb),$z=()=>L(e=>e.activeRepoId?e.archivedOpen[e.activeRepoId]??!1:!1),Cz=()=>L(e=>!(e.activeRepoId&&e.committedShut[e.activeRepoId])),Az=()=>L(e=>!!(e.activeRepoId&&e.turnOpen[e.activeRepoId])),Ia=()=>L(Fo),Dw=()=>L($w),Iz=()=>L(e=>Li(e,e.activeRepoId)),Jl=()=>L(e=>Li(e,Tw(e))),F_=e=>L(t=>Wr(t,e)),Mt=(e,t)=>L(n=>Wr(n,e)[t]),Rz=()=>L(e=>e.overlay),Bh=()=>L(xD),B_=()=>L(o_),zu=()=>L(ED),Fu=()=>L(ns),Oz=()=>L(e=>e.newProject),Ra=()=>L(e=>e.touch),Bu=e=>L(t=>t.chatSide==="left"==(e==="chat")?"right":"left"),Mz=()=>L(e=>e.draft),zw=()=>L($l),Lz=()=>L(e=>{const t=To(e,e.activeId),n=t?e.repos.find(r=>r.id===t.repoId):null;return Qf(n)?n:null});function Pz(e){return e.image?{kind:"image",blob:e.image,sig:`image:${e.image.type}:${e.image.size}`}:e.text&&ES(e.text)?{kind:"text",text:e.text,sig:`text:${e.text}`}:null}function Dz(){try{return localStorage.getItem(tt.clipboardOffer)==="1"}catch{return!1}}let Ps={access:"none",on:typeof localStorage<"u"&&Dz(),offer:null},Yg="";const Xg=new Set;function Uh(e){Ps={...Ps,...e};for(const t of Xg)t()}async function zz(){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 Pz({image:e,text:t})}async function Hh({taken:e=!1,asking:t=!1}={}){if(!Ps.on||!(Ps.access==="granted"||t&&Ps.access==="prompt"))return;let n;try{n=await zz()}catch{return}e&&(Yg=(n==null?void 0:n.sig)??""),Uh({offer:n&&n.sig!==Yg?n:null})}const Fz=()=>void Hh();let ex=!1;function Bz(){var e,t;ex||(ex=!0,!(!((e=navigator.clipboard)!=null&&e.read)||!((t=navigator.permissions)!=null&&t.query))&&navigator.permissions.query({name:"clipboard-read"}).then(n=>{const r=()=>{Uh({access:n.state,...n.state==="denied"?{offer:null}:{}})};n.onchange=r,r(),window.addEventListener("focus",Fz),document.hasFocus()&&Hh()},()=>{}))}function Uz(e){return Xg.add(e),Bz(),()=>{Xg.delete(e)}}const Hz=()=>Ps;function Wz(e){try{localStorage.setItem(tt.clipboardOffer,e?"1":"0")}catch{}Uh({on:e,offer:null}),e&&Hh({asking:!0})}function U_(){Ps.offer&&(Yg=Ps.offer.sig),Uh({offer:null})}const Kz=()=>void Hh({taken:!0});function qz(){return S.useSyncExternalStore(Uz,()=>Ps.offer)}const H_="application/x-toyon-source";function wV(e){const t=e.endColumn===1&&e.endLineNumber>e.startLineNumber?e.endLineNumber-1:e.endLineNumber;return{startLine:e.startLineNumber,endLine:t}}function Zz(e,t){e.setData(H_,JSON.stringify(t))}const tx=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1;function Gz(e,t){const n=e.getData(H_);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!tx(o)||!tx(s)||s<o?null:{path:r.path,startLine:o,endLine:s,...typeof a=="string"?{ref:a}:{}}}const W_=e=>({left:e.x,top:e.y,right:e.x,bottom:e.y});function Vz(e,t){return t.matchWidth===void 0?void 0:Math.max(0,e.right-e.left+t.matchWidth)}const Yz=new Set(["top","bottom"]),Qm={top:"bottom",bottom:"top",left:"right",right:"left"};function Jm(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 nx(e,t,n,r,o){return n==="top"||n==="left"?e>=o:e+t<=r-o}function eg(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 rx(e,t,n,r,o){return n==="start"?e+t<=r-o:e>=o}const ox=(e,t,n,r)=>n||!r?e:t,sx=(e,t,n,r)=>Math.max(r,Math.min(e,n-r-t));function Xz(e,t,n,r){const{offset:o=0,alignOffset:s=0,cover:a=!1,flip:c="none",margin:u=8}=r,h=Yz.has(r.side),f=h?{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},m=h?{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(c==="side"||c==="both"){const _=Jm(f.a,f.size,g,o,a),x=Jm(f.a,f.size,Qm[g],o,a);g=ox(g,Qm[g],nx(_,f.size,g,f.limit,u),nx(x,f.size,Qm[g],f.limit,u))}let y=r.align??"center";if((c==="align"||c==="both")&&y!=="center"){const _=y==="start"?"end":"start",x=eg(m.a,m.size,y,s),N=eg(m.a,m.size,_,s);y=ox(y,_,rx(x,m.size,y,m.limit,u),rx(N,m.size,_,m.limit,u))}const w=sx(Jm(f.a,f.size,g,o,a),f.size,f.limit,u),v=sx(eg(m.a,m.size,y,s),m.size,m.limit,u);return h?{x:v,y:w,side:g,align:y}:{x:w,y:v,side:g,align:y}}function Qz(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 c=0;c<r&&((s=e[o])!=null&&s.disabled);c++)o=(o+n+r)%r;return(a=e[o])!=null&&a.disabled?-1:o}const K_={sep:!0},hs=e=>!("sep"in e);function Wh(e){const t=[];for(const n of e)(hs(n)||t.length>0&&hs(t[t.length-1]))&&t.push(n);for(;t.length>0&&!hs(t[t.length-1]);)t.pop();return t}const Bn=e=>Wh(e.flatMap((t,n)=>n?[K_,...t]:t));let bl=null,Jz=0;const Qg=new Set,ix=()=>{for(const e of Qg)e()},co={get:()=>bl,subscribe(e){return Qg.add(e),()=>{Qg.delete(e)}},open(e){const t=Wh(e.items);if(t.length===0)return co.close();bl={...e,items:t,id:++Jz},ix()},close(){bl&&(bl=null,ix())},toggle(e){bl&&bl.target===e.target?co.close():co.open(e)}};function Fw(){return S.useSyncExternalStore(co.subscribe,co.get)}function q_(e){const t=e.nativeEvent;return t&&"pointerType"in t?t.pointerType==="":e.clientX===0&&e.clientY===0}function e3(e,t){return q_(e)?{anchor:(t.querySelector('[data-state~="cursor"]')??t).getBoundingClientRect()}:{at:{x:e.clientX,y:e.clientY}}}function t3(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:W_(e.at??{x:0,y:0}),placement:{side:"bottom",align:"start",margin:4}}}function vn(e){return S.useMemo(()=>({contextMenu(t,n){return{onContextMenu:r=>{const o=Wh(t(q_(r)?"keyboard":"pointer",r.target));if(o.length===0)return;r.preventDefault(),r.stopPropagation();const s=r.currentTarget;co.open({items:o,owner:e,key:n,target:s,...e3(r,s)})}}},dropdown(t,n="left",r,o){return{"aria-haspopup":"menu",onClick:s=>{s.stopPropagation();const a=s.currentTarget;co.toggle({items:t(),...o?{head:o()}:{},owner:e,key:r,target:a,toggles:!0,anchor:a.getBoundingClientRect(),align:n})}}},openUnder(t,n,r){co.open({items:n(),owner:e,key:r,target:t,toggles:!0,anchor:t.getBoundingClientRect(),align:"left"})}}),[e])}const Z_=e=>({id:"open-out",label:bw()?"open in the browser":"open in a new tab",onClick:()=>window.open(e,"_blank")}),tn=e=>{var t;return void((t=navigator.clipboard)==null?void 0:t.writeText(e).catch(()=>{}))};function G_(e,t){const n=navigator.clipboard;if(n){if(typeof ClipboardItem>"u"||!n.write){e==="text/plain"&&t.then(r=>r.text()).then(tn,()=>{});return}n.write([new ClipboardItem({[e]:t})]).catch(()=>{})}}const V_=e=>G_("text/plain",fetch(e).then(t=>t.blob())),n3=e=>G_("image/png",r3(e));async function r3(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 Kh(e){return Qk(e)}function fo(e){return(e==null?void 0:e.urls.host)??(typeof location=="object"?location.hostname:"127.0.0.1")}function Bo(e,t,n="reveal in Finder"){return!e||!Kh(t)?[]:[{id:"reveal",label:n,onClick:e}]}function o3(e,t){const n=[];for(const r of t)r.xy.includes("D")?n.push(`-${r.path}`):/[?ARC]/.test(r.xy)&&n.push(`+${r.path}`);return`${e??""}
103
- ${n.sort().join(`
104
- `)}`}function qh(e,t,{sock:n,dispatch:r}){var a,c;if(!n)return;const o=t.local[e]??Aa,s=o3((a=o.git)==null?void 0:a.head,((c=o.git)==null?void 0:c.files)??[]);o.filesFor!==s&&(r({a:"files-asked",worktreeId:e,key:s}),n.send({t:"list-files",worktreeId:e}))}const s3=["diff","file","preview"],Y_=(e,t)=>s3.filter(n=>!(n==="preview"&&!ku(e))&&!(n==="diff"&&t));let i3=0;const So=()=>++i3;function Rn({dispatch:e},{focus:t=!0,...n}){e({a:"open-file",v:{...n,focus:t,seq:So()}})}function a3({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:So()}})}const Jg=new Map;function X_(e,t,n=""){const{sock:r}=e;if(!r)return Promise.resolve("not connected to the daemon");const o=So();return new Promise(s=>{Jg.set(o,a=>{a.ok?(Rn(e,{...t,view:Ii(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 l3(e){const t=Jg.get(e.seq);return t?(Jg.delete(e.seq),t(e),!0):!1}function c3({dispatch:e},t){e({a:"tree-reveal",...t})}function Os(e,t,{discard:n=!1,ref:r,since:o,showing:s,noDiff:a=!1,kept:c=!1,select:u},h){const{sock:f,dispatch:m}=h,g=Y_(t,a).filter(N=>N!==s).map(N=>({id:`view:${N}`,label:`view ${N}`,onClick:()=>s?m({a:"editor-view",v:N}):Rn(h,{worktreeId:e.id,path:t,view:N,ref:r,since:o})})),y=`${e.dir}/${t}`,w=c?[]:Bo(()=>f==null?void 0:f.send({t:"reveal",worktreeId:e.id,path:t}),fo(f));return Bn([g,[{id:"copy-path",label:"copy path",onClick:()=>tn(y)}],w,u?[{id:"select",label:"select…",onClick:()=>u(t)}]:[],n?[{id:"discard",label:"discard changes…",danger:!0,onClick:()=>{window.confirm(Q_([t]))&&(f==null||f.send({t:"discard-files",worktreeId:e.id,paths:[t]}))}}]:[]])}function Q_(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(`
105
- `);return`Discard uncommitted changes to ${e.length} files?
106
-
107
- ${r}`}const _o=(e,t,n)=>e.dispatch({a:"notice",id:t,text:n});function Zh(e,t,n){var o;const r=AA(((o=e.getState().local[t])==null?void 0:o.attachments)??[],n);return r===0&&_o(e,t,Vk(n)),r}const u3=1e3,d3=1e4,J_=new WeakMap;function f3(e,t){J_.set(e,t)}async function eN(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 _;return(_=Object.entries(e.getState().local).find(([,x])=>x.attachments.some(N=>N.key===n.key)))==null?void 0:_[0]},c=J_.get(e);let u=-1;const h=_=>{const x=Math.min(99,Math.floor(_*100)),N=a();x===u||N===void 0||(u=x,e.dispatch({a:"upload-progress",id:N,key:n.key,progress:x}))},f=()=>(u=-1,c?c4(c,n.kind,r,h):Promise.resolve(null));let m=await f();const g=m===null;g&&_o(e,a()??t,`${n.name}: Toyon is not answering; it attaches once it is back`);for(let _=u3;m===null&&a()!==void 0;_=Math.min(_*2,d3))await new Promise(x=>setTimeout(x,_)),a()!==void 0&&(m=await f());const y=a();if(!(m===null||y===void 0))if(typeof m=="string")e.dispatch({a:"detach",id:y,key:n.key}),_o(e,y,`${n.name}: ${m}`);else{const _=s.kind==="file"?{...s,...m}:{...s,upload:m.upload,bytes:m.bytes};e.dispatch({a:"attached",id:y,key:n.key,item:_});const x=(v=e.getState().local[((w=fs(y))==null?void 0:w.source)??y])==null?void 0:v.notice;g&&(x!=null&&x.startsWith(`${n.name}: Toyon is not answering`))&&_o(e,y,"")}o&&URL.revokeObjectURL(o)}function Bw(e,t,n){if(!t||n.length===0)return;const r=Zh(e,t,"file");if(r!==0){for(const o of n.slice(0,r)){const s=o.name||"file";if(o.size>$b){_o(e,t,`${s}: larger than ${Xk($b)}`);continue}const a={kind:"file",key:crypto.randomUUID(),upload:"",name:s,bytes:o.size,text:!1};eN(e,t,a,o)}n.length>r&&_o(e,t,`kept ${r} of ${n.length}: ${Vk("file")}`)}}function Uw(e,t,n,r={}){if(!t)return;const o=VL(r.source?n.replace(/\r?\n$/,""):n);if(o.length>BL)return r.source?_o(e,t,"that paste is too large; save it in the worktree and reference it with @path"):Bw(e,t,[new File([o],UL,{type:"text/plain"})]);Zh(e,t,"paste")!==0&&e.dispatch({a:"attach",id:t,items:[{kind:"paste",key:crypto.randomUUID(),text:o,...r,...cw(o)}]})}function tN(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 Rf(e,t){var s;const n=e.getState(),r=Gt(n,n.activeId),o=Ca(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:h,startLine:f,endLine:m,ref:g}=t.source;return((y=u.source)==null?void 0:y.path)===h&&u.source.startLine===f&&u.source.endLine===m&&u.source.ref===g})||Uw(e,o,t.text,a)}e.dispatch(t?{a:"focus-chat"}:s_(n))}function Hw(e,t){return t!==e.activeId?null:Ca(Gt(e,t))}const nN=(e,t)=>`@${e}${t?"/":""}`,Ww=e=>`${e.map(t=>nN(t.path,t.folder)).join(" ")} `;function rN(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 oN(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:rN(r,r.length,n).text}),e.dispatch({a:"focus-chat"})}function Kw(e,t,n){const r=Hw(e.getState(),t);r&&oN(e,r,n)}function h3(e,t,n,r){Kw(e,t,Ww([{path:n,folder:r}]))}function p3(e,t,n){n.length!==0&&Kw(e,t,Ww(n.map(r=>({path:r,folder:!1}))))}function ax(e,t,n){Kw(e,t,n)}function m3(e,t){return Gt(e,t)?t:null}function g3(e,t){var r;const n=(r=Gt(e,t))==null?void 0:r.worktree;return n?[n.path]:[]}function lx(e,t){if(!e)return e;const n=t.find(r=>e.startsWith(`${r}/`));return n?e.slice(n.length+1):e}function k3(e,t,n){var g;e.dispatch({a:"set-picking",v:!1});const r=e.getState(),o=m3(r,t);if(!o)return;const{classes:s,route:a,element:c,...u}=n,h=g3(r,t),f={...u,file:lx(u.file,h),callFile:lx(u.callFile,h)};!(((g=r.local[o])==null?void 0:g.attachments)??[]).some(y=>y.kind==="pick"&&y.selector===f.selector)&&Zh(e,o,"pick")>0&&e.dispatch({a:"attach",id:o,items:[{kind:"pick",key:crypto.randomUUID(),...f}]}),e.dispatch({a:"focus-chat"})}function w3(e,t=[],n=[]){const r={path:"",name:"",kind:"folder",children:[],ignored:!1},o=new Map([["",r]]),s=u=>{const h=o.get(u);if(h)return h;const f=u.lastIndexOf("/"),m={path:u,name:u.slice(f+1),kind:"folder",children:[],ignored:!1};return s(f===-1?"":u.slice(0,f)).children.push(m),o.set(u,m),m},a=(u,h,f=!1)=>{const m=u.lastIndexOf("/");s(m===-1?"":u.slice(0,m)).children.push({path:u,name:u.slice(m+1),kind:h,children:[],ignored:f})};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 c=u=>{const h=f=>f.kind==="file"?1:0;u.children.sort((f,m)=>h(f)-h(m)||VS(f.name,m.name));for(const f of u.children)f.kind==="folder"&&c(f)};return c(r),r.children}function y3(e,t){const n=[],r=(o,s)=>{for(const a of o){const c=a.kind==="folder"&&t(a.path);n.push({path:a.path,name:a.name,depth:s,kind:a.kind,open:c,ignored:a.ignored}),c&&r(a.children,s+1)}};return r(e,0),n}const sN=e=>{const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)};function v3(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 b3(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 Xf(o))n.add(s)}return{files:t,folders:n}}function iN(e){const t=e.findLast(n=>n.kind==="handoff"&&n.state!=="declined");return(t==null?void 0:t.kind)==="handoff"?t:null}function x3(e){return!!e.plan&&!e.companion}function Pi(e,t){return e.fates[t.id]??t.fate}function Uu(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 aN(e){const t={worktrees:0,queued:0,sent:0,here:0,skipped:0};for(const n of e.pieces){const r=Pi(e,n);r==="worktree"?n.after?t.queued++:t.worktrees++:r==="send"?t.sent++:r==="here"?t.here++:t.skipped++}return t}const lN=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,E3=e=>e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function S3(e,t){const n=aN(e),r=[];if(n.here&&r.push("this plan here"),n.worktrees&&r.push(`${lN(n.worktrees,"worktree")} now`),n.queued){const s=e.pieces.filter(u=>Pi(e,u)==="worktree"&&u.after),a=s.every(u=>u.after&&"id"in u.after&&u.after.id===t),c=s.length===1?Uu(e,s[0]):null;r.push(a?`${n.queued} when this branch lands`:c?`1 when ${c.kind==="branch"?c.branch:c.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 ${E3(r)}${o}.`}function ek(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=aN(e),o=[n.worktrees?`start ${lN(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 cN(e,t){var c;const n=Uu(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 ${((c=t.to)==null?void 0:c.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]}function _3(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 N3(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 T3(e){var s;const t=e.answered;if(!t)return null;if(!t.go)return"not now";const n=e.pieces.length===1?e.pieces[0]:void 0,o=(n?(s=cN(e,n).find(a=>a.fate===Pi(e,n)))==null?void 0:s.label:void 0)??"go";return t.note?`${o}
108
- ${t.note}`:o}function cx(e,t,n,r){const o=n?r==null?void 0:r.trim():void 0;return{t:"handoff-answer",worktreeId:t,id:e.id,go:n,...o?{note:o}:{}}}function uN(e,t,n,r){return{t:"handoff-fate",worktreeId:t,id:e.id,pieceId:n,fate:r}}function j3(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 vu=e=>e.state==="held"||e.state==="proposed";function dN(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 $3(e,t){const n=Uu(e,t),r=n?{word:`after ${n.title}`}:null;if(vu(e)){const s=Pi(e,t);return s==="worktree"?{word:t.after?"queued":"worktree"}:s==="send"?{word:"sent"}:s==="here"&&r?r:{word:s}}const o=bu(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 C3(e,t,n){if(n||vu(e))return!0;const r=bu(e,t);return r.kind==="here"?!!t.after:r.kind!=="skipped"&&r.kind!=="starting"}function bu(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:Uu(e,t),...n.after?{said:n.after}:{}}}function A3(e,t){var o;if(t)return"plan";const n=dN(e),r=vu(e)?void 0:n.find(s=>Pi(e,s)==="here");return(r==null?void 0:r.id)??((o=n[0])==null?void 0:o.id)??"plan"}function I3(e){if(e.state!=="done")return[];const t=new Map;for(const n of e.pieces){const r=n.after;if(!r||Pi(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?bu(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 qw(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 R3(e){const t=e?qw(e.chat):null;return(t==null?void 0:t.kind)!=="ask"||t.ask.kind!=="question"||(e==null?void 0:e.cardParked)===t.id?null:Rl(t.id)}function O3(e){return e.kind==="ask"?j4(e):ek(e)}const fN=new Set(DL),M3=/^image\.[a-z0-9]+$/i,L3=e=>M3.test(e.name),P3=(e,t)=>e===t||e.name===t.name&&e.size===t.size&&e.type===t.type&&e.lastModified===t.lastModified;function D3(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=>P3(a,s))||n.push(s);const r=n.filter(s=>!L3(s));if(r.length>0)return r;const o=n.find(s=>fN.has(s.type))??n[0];return o?[o]:[]}function z3(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 F3(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 B3(e){try{return await createImageBitmap(e)}catch{throw new Error(`${e.name||"image"}: not a readable image`)}}function ux(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 U3(e){const t=await B3(e);try{const n=Math.max(t.width,t.height);let r=e,o=e.type,s=t.width,a=t.height;if(!fN.has(o)||n>jb||e.size>Gm){const c=o==="image/jpeg"?"image/jpeg":"image/png";let u=Math.min(1,jb/n);for(r=await ux(t,u,c);r.size>Gm&&u>.1;)u*=.7,r=await ux(t,u,c);if(r.size>Gm)throw new Error(`${e.name||"image"}: too large even after downscaling`);o=c,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 lu={el:null},H3=80,W3=2e3;let No=null,tk;const hN=(e,t)=>{clearTimeout(tk),tk=setTimeout(()=>Gw(e),t)};function Zw(e,t){No??(No={refused:!1}),e.dispatch({a:"drag-files",v:No.refused?null:t}),hN(e,W3)}function pN(e){No&&hN(e,H3)}const K3=()=>(No==null?void 0:No.refused)??!1;function Gw(e){No&&(clearTimeout(tk),No=null,e.dispatch({a:"drag-files",v:null}))}function q3(e){No&&(No.refused=!0,e.dispatch({a:"drag-files",v:null}))}let Z3=0;function G3(e){const{blob:t,...n}=e;return{kind:"image",key:`img${++Z3}`,...n,upload:"",bytes:t.size,local:URL.createObjectURL(t)}}async function Gh(e,t,n){var a;if(!t||n.length===0)return;const r=Zh(e,t,"image");if(r===0)return;const o=await Promise.allSettled(n.slice(0,r).map(U3));for(const c of o)c.status==="fulfilled"&&eN(e,t,G3(c.value),c.value.blob);const s=o.find(c=>c.status==="rejected");s?_o(e,t,String(((a=s.reason)==null?void 0:a.message)??s.reason)):n.length>r&&_o(e,t,`kept ${r} of ${n.length}: ${Vk("image")}`)}function V3(e,t,n){n.kind==="image"?Gh(e,t,[new File([n.blob],"image.png",{type:n.blob.type})]):Uw(e,t,n.text),U_()}function Jf(e,t,n){const r=o=>o.type.startsWith("image/");Gh(e,t,n.filter(r)),Bw(e,t,n.filter(o=>!r(o)))}function mN(e,t){const n=document.createElement("input");n.type="file",n.multiple=!0,n.onchange=()=>Jf(e,t,Array.from(n.files??[])),n.click()}function Oa(e){const t=e.getState();if(t.newProject)return Ul;const n=Fo(t)??$w(t);if(n)return n.id;const r=Gt(t,t.activeId);return R3(r?t.local[r.worktree.id]:void 0)??Ca(r)}function gN(e,t,n=Oa(e)){Jf(e,n,t.filter(o=>!o.folder).map(o=>o.file));const r=t.find(o=>o.folder);n&&r&&_o(e,n,`${r.file.name}: a folder cannot be attached; drop its files`)}const nk=Promise.resolve(null);function Y3(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 c=((n=s.getAsFileSystemHandle)==null?void 0:n.call(s).then(u=>(u==null?void 0:u.kind)==="file"?u:null,()=>null))??nk;t.push({file:a,handle:c,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:nk});return t}const X3=e=>e.map(t=>({file:t,handle:nk}));async function kN(e){const t=Zf*4;if(e.size>t)return{text:"",tooLarge:!0};const n=await F3(e,t);return n===null?null:n.length>Zf?{text:"",tooLarge:!0}:{text:n,tooLarge:!1}}async function Q3(e,t){const n=Oa(e),r=e.getState().activeId,o=f=>n&&_o(e,n,f),s=t.filter(f=>f.file.type.startsWith("image/")).map(f=>f.file);s.length&&Gh(e,n,s);const a=t.filter(f=>!f.file.type.startsWith("image/")),c=a[0];if(!c||!r)return;const u=await kN(c.file);if(!u)return void o(`${c.file.name}: not a text file`);const h=await c.handle;e.dispatch({a:"open-loose",v:{worktreeId:r,name:c.file.name,...u,binary:!1,source:h?{kind:"handle",handle:h}:{kind:"bytes"},seq:So()}}),a.length>1&&o(`opened ${c.file.name}; one file opens at a time`)}async function J3(e,t,n,r){const o=Hw(e.getState(),n.worktreeId)??Oa(e),s=c=>o&&_o(e,o,c),a={sock:t,dispatch:c=>e.dispatch(c)};for(const{file:c}of r){const u=await kN(c);if(!u){s(`${c.name}: not a text file`);continue}if(u.tooLarge){s(`${c.name}: too large to add here`);continue}const h=n.dir?`${n.dir}/${c.name}`:c.name,f=await X_(a,{worktreeId:n.worktreeId,path:h},u.text);f&&s(`${c.name}: ${f}`)}}function e6(e){const t=Oa(e);t&&_o(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 wN(e,t,n,r){const o=(No==null?void 0:No.refused)??!1;Gw(e),!(o||r.length===0)&&(n?n.at==="chat"||n.at==="centre"&&e.getState().newProject?gN(e,r):n.at==="centre"?Q3(e,r):n.at==="rail"?t6(e,n,r):J3(e,t,n,r):e6(e))}function t6(e,t,n){const r=Gt(e.getState(),t.worktreeId);r&&(e.dispatch(Tr(r.worktree)?{a:"open-draft"}:{a:"activate",id:r.worktree.id}),gN(e,n,Ca(r)))}const rk=e=>!!e&&Array.from(e.types).includes("Files");function dx(e,t){var c,u;const n=t instanceof Element?t:t instanceof Node?t.parentElement:null;if(!n)return null;if((c=lu.el)!=null&&c.contains(n))return Oa(e)?{at:"chat"}:null;const r=(u=n.closest(".rail [data-wt]"))==null?void 0:u.dataset.wt;if(r)return Gt(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 h=n.closest("[data-path]"),f=h==null?void 0:h.dataset.kind;if(f==="submodule")return null;const m=(h==null?void 0:h.dataset.path)??"";return{at:"tree",worktreeId:s,dir:f==="file"?sN(m):m}}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 n6(){const e=On(),t=Je();S.useEffect(()=>{const n=a=>{a.defaultPrevented||!rk(a.dataTransfer)||(a.preventDefault(),Zw(e,dx(e,a.target)),a.dataTransfer&&(a.dataTransfer.dropEffect=e.getState().dragFiles?"copy":"none"))},r=a=>{a.defaultPrevented||!rk(a.dataTransfer)||(a.preventDefault(),wN(e,t,dx(e,a.target),Y3(a.dataTransfer)))},o=()=>pN(e),s=a=>{a.key==="Escape"&&q3(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 yN(e,t,n){const r=On(),o=S.useRef(!1);return{onPaste:u=>{Kz();const h=D3(u.clipboardData);if(h.length>0)return u.preventDefault(),void Gh(r,e,h);const f=z3(u.clipboardData);if(f.length>0)return u.preventDefault(),Bw(r,e,f);if(o.current)return;const m=u.clipboardData.getData("text/plain");if(m.trim()&&(n!=null&&n(m))){u.preventDefault();return}const g=m.trim()?Gz(u.clipboardData,t):null;!(g&&m.includes(`
109
- `))&&!ES(m)||(u.preventDefault(),Uw(r,e,m,g?{source:g}:{}))},onPasteKey:u=>{o.current=(u.metaKey||u.ctrlKey)&&u.shiftKey&&u.key.toLowerCase()==="v"},onPasteKeyUp:()=>{o.current=!1}}}function r6(e,t,n){const r=S.useRef(n);r.current=n,S.useEffect(()=>{const o=e.current;if(!o)return;const s=a=>{const{inputType:c,data:u,isComposing:h}=a;a.target!==t.current||h||!u||c!=="insertText"&&c!=="insertFromPaste"||r.current(u)&&a.preventDefault()};return o.addEventListener("beforeinput",s),()=>o.removeEventListener("beforeinput",s)},[e,t])}const o6=640,s6=1e3,vN=`(max-width: ${o6}px), ((hover: none) and (max-width: ${s6}px))`,bN="(hover: none)",Vw=()=>{var e;return(e=window.matchMedia)!=null&&e.call(window,vN).matches?"phone":"desk"},i6=()=>{var e;return((e=window.matchMedia)==null?void 0:e.call(window,bN).matches)??!1},xN=()=>window.top!==window;function a6(e){const t=(o,s)=>{var u;const a=(u=window.matchMedia)==null?void 0:u.call(window,o);if(!a)return()=>{};const c=h=>s(h.matches);return a.addEventListener("change",c),()=>a.removeEventListener("change",c)},n=t(vN,o=>e.dispatch({a:"frame",v:o?"phone":"desk"})),r=t(bN,o=>e.dispatch({a:"touch",v:o}));return()=>{n(),r()}}const EN=(e,t)=>{const n=e.indexOf("#"),[r,o]=n===-1?[e,""]:[e.slice(0,n),e.slice(n)];return`${r}${r.includes("?")?"&":"?"}${eI}=${encodeURIComponent(t)}${o}`},ok=(e,t)=>!e.serving&&t!==null,l6=3e3;function SN(e,t,n){const[r,o]=S.useState(()=>new Map),s=S.useRef(new Set),a=S.useRef(t);a.current=t;const c=S.useRef(new Map),u=S.useCallback((h,f)=>{s.current.has(h)||(s.current.add(h),DS(e.sock.urls).then(m=>{if(s.current.delete(h),!!a.current.some(y=>y.id===h&&y.url===f)){if(!m){c.current.set(h,setTimeout(()=>{c.current.delete(h),a.current.some(y=>y.id===h&&y.url===f)&&u(h,f)},l6));return}o(y=>new Map(y).set(h,{url:f,src:EN(f,m.code)}))}}))},[e]);return S.useEffect(()=>{const h=c.current;return()=>{for(const f of h.values())clearTimeout(f);h.clear()}},[]),S.useEffect(()=>{var f;if(!n)return;for(const m of t)((f=r.get(m.id))==null?void 0:f.url)!==m.url&&u(m.id,m.url);const h=new Set(t.map(m=>m.id));[...r.keys()].some(m=>!h.has(m))&&o(m=>new Map([...m].filter(([g])=>h.has(g))))},[n,t,r,u]),{urlOf:h=>{var f,m;return n?((f=r.get(h))==null?void 0:f.src)??null:((m=t.find(g=>g.id===h))==null?void 0:m.url)??null},renew:h=>{const f=t.find(m=>m.id===h);!f||!n||(o(m=>{const g=new Map(m);return g.delete(h),g}),u(h,f.url))}}}function c6(e,t,n){var o;const r=S.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}]),SN(e,r.current,n).urlOf("one")}function u6(e,t,n){if(!n){window.open(t,"_blank");return}const r=window.open("","_blank");DS(e.sock.urls).then(o=>{const s=o?EN(t,o.code):t;r?r.location.href=s:window.open(s,"_blank")})}function Be(...e){return e.filter(Boolean).join(" ")}const d6={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",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",layers:"M6 2.5h7.5V10 M2.5 6h8v7.5h-8z",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",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 ht({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:d6[e]})})}function eh({className:e}){return d.jsxs("span",{className:Be("spinner",e),"aria-hidden":"true",children:[d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{})]})}const f6='button, a[href], input, textarea, select, summary, label, [role="button"], [role="menuitem"]';function fx(e){var n;const t=e;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,f6))??t??null}function h6(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 p6(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 m6(e,t){const n=new Set;for(const r of e)if(h6(r,t))for(let o=r;o;o=o.parent)n.add(o);return e.filter(r=>!n.has(r)&&r.dismiss).reverse()}const g6=e=>{setTimeout(e,0)};function k6({schedule:e=g6}={}){let t=[],n=null,r=!1;const o=new Set,s=()=>{for(const c of[...o])c()},a=c=>{var u;for(const h of[...t].reverse())(u=h.dismiss)==null||u.call(h,c)};return{register(c){const u=c.trigger??(c.from===void 0?n:null),h={box:c.box,trigger:u,parent:p6(t,c.from??u),dismiss:c.dismiss,onKey:c.onKey,back:c.back};return t=[...t,h],s(),h},unregister(c){t=t.filter(u=>u!==c),s()},top:()=>t[t.length-1]??null,open:()=>t,watch(c){return o.add(c),()=>o.delete(c)},shut(c){var u;c.back?c.back():(u=c.dismiss)==null||u.call(c,"outside")},install(c){const u=c.document,h=v=>{var N;const _=v.target,x=_?m6(t,_):[];for(const T of x)(N=T.dismiss)==null||N.call(T,"outside");r=x.length>0&&v.pointerType==="touch",r&&v.preventDefault(),n=fx(v.target)},f=()=>e(()=>n=null),m=()=>{r=!1,f()},g=v=>{if(r){r=!1,v.preventDefault(),v.stopPropagation();return}n||(n=fx(v.target),f())},y=v=>{var x;const _=t[t.length-1];(x=_==null?void 0:_.onKey)==null||x.call(_,v)},w=()=>e(()=>{var v;((v=u.activeElement)==null?void 0:v.tagName)==="IFRAME"&&a("frame")});return u.addEventListener("pointerdown",h,!0),u.addEventListener("pointerup",f,!0),u.addEventListener("pointercancel",m,!0),u.addEventListener("click",g,!0),c.addEventListener("keydown",y,!0),c.addEventListener("blur",w),()=>{u.removeEventListener("pointerdown",h,!0),u.removeEventListener("pointerup",f,!0),u.removeEventListener("pointercancel",m,!0),u.removeEventListener("click",g,!0),c.removeEventListener("keydown",y,!0),c.removeEventListener("blur",w)}}}}const ql=k6(),w6=()=>ql.open().some(e=>!!e.dismiss);function y6(){return S.useSyncExternalStore(ql.watch,w6,()=>!1)}const tg=typeof HTMLElement<"u"&&"showPopover"in HTMLElement.prototype,hx=e=>(e==null?void 0:e.getBoundingClientRect())??null;function v6(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 Fs({className:e,anchor:t,placement:n,coverBy:r,track:o=t==="parent",raiseKey:s,onDismiss:a,onKey:c,onBack:u,trigger:h,from:f,boxRef:m,handle:g,children:y,...w}){const v=S.useRef(null),_=S.useRef({anchor:t,placement:n,coverBy:r,onDismiss:a,onKey:c,onBack:u,trigger:h,from:f});_.current={anchor:t,placement:n,coverBy:r,onDismiss:a,onKey:c,onBack:u,trigger:h,from:f};const x=S.useCallback(()=>{const T=v.current,{anchor:j,placement:C,coverBy:I}=_.current;if(!T||!j||!C)return;const A=j==="parent"?hx(T.parentElement):j();if(!A)return;const M=Vz(A,C);M!==void 0&&(T.style.width=`${M}px`);for(let O=0;O<2;O++){const z=I?v6(T,I,T.dataset.side??"",T.dataset.align??""):null,B=Xz(A,{w:T.offsetWidth,h:T.offsetHeight},{w:window.innerWidth,h:window.innerHeight},z?{...C,...z}:C);T.style.left=`${B.x}px`,T.style.top=`${B.y}px`;const H=T.dataset.side!==B.side||T.dataset.align!==B.align;if(T.dataset.side=B.side,T.dataset.align=B.align,!H)break}},[]);S.useImperativeHandle(g,()=>({update:x}),[x]),S.useLayoutEffect(()=>{const T=v.current;if(!T)return;m&&(m.current=T),tg&&(T.popover="manual",T.matches(":popover-open")||T.showPopover());const{onDismiss:j,onKey:C,onBack:I,trigger:A,from:M}=_.current,O=j||C?ql.register({box:T,trigger:A,from:M,dismiss:j?z=>{var B,H;return(H=(B=_.current).onDismiss)==null?void 0:H.call(B,z)}:void 0,onKey:C?z=>{var B,H;return(H=(B=_.current).onKey)==null?void 0:H.call(B,z)}:void 0,back:I?()=>{var z,B;return(B=(z=_.current).onBack)==null?void 0:B.call(z)}:void 0}):null;return()=>{O&&ql.unregister(O),m&&(m.current=null),tg&&T.isConnected&&T.matches(":popover-open")&&T.hidePopover()}},[m]),S.useLayoutEffect(x),S.useLayoutEffect(()=>{if(!o)return;let T=0,j="";const C=()=>{const I=v.current,{anchor:A}=_.current,M=I&&A?A==="parent"?hx(I.parentElement):A():null;if(I&&M){const O=`${M.left},${M.top},${M.right},${M.bottom},${I.offsetWidth},${I.offsetHeight},${window.innerWidth},${window.innerHeight}`;O!==j&&(j=O,x())}T=requestAnimationFrame(C)};return T=requestAnimationFrame(C),()=>cancelAnimationFrame(T)},[o,x]);const N=S.useRef(!0);return at([s],()=>{if(N.current){N.current=!1;return}const T=v.current;!tg||!(T!=null&&T.matches(":popover-open"))||(T.hidePopover(),T.showPopover(),x())}),d.jsx("div",{ref:v,className:Be("float",e),...w,children:y})}const b6=/^[⌘⇧⌥⌃]+/;function rs({k:e,chip:t=!1,className:n}){var a;const r=(a=e.match(b6))==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 Ft(e,t,{placement:n,align:r,detail:o,card:s,dot:a,name:c,aside:u,also:h}={}){const f=c?`${e}: ${c}`:e,m=(Array.isArray(o)?o:[o]).filter(y=>!!y),g=[f,...m,...u??[]].join(", ");return{"data-tip":e,"data-tip-key":t,"data-tip-placement":n,"data-tip-align":r,"data-tip-detail":m.length?m.join(`
110
- `):void 0,"data-tip-card":s||c||u!=null&&u.length?"":void 0,"data-tip-dot":a,"data-tip-name":c,"data-tip-aside":u!=null&&u.length?u.join(`
111
- `):void 0,"data-tip-also":h==null?void 0:h.text,"data-tip-also-key":h==null?void 0:h.key,"aria-label":t?`${g} (${t})`:g}}const x6=120,E6=600,S6=150,px=6,_6=18,ng=8;function mx(e){const t=e.dataset.tipPlacement;return t==="follow"||t==="top"||t==="bottom"||t==="left"||t==="right"?t:"bottom"}function N6(e){const t=e.dataset.tipAlign;return t==="start"||t==="center"||t==="end"?t:void 0}function _N(e,t){return e==="follow"?{side:"bottom",align:"start",offset:_6,alignOffset:-12,flip:"both",margin:ng}:e==="left"||e==="right"?{side:e,align:t??"start",offset:px,flip:"both",margin:ng}:{side:e,align:t??"center",offset:px,flip:"both",margin:ng}}function T6(e,t){return e.placement==="follow"?W_(t):e.el.getBoundingClientRect()}function NN(){var u;const[e,t]=S.useState(null),n=S.useRef(null),r=S.useRef(null),o=S.useRef({x:0,y:0}),s=Ra();if(S.useEffect(()=>{if(s)return;let h=0,f=0,m=null,g=!1,y=0;const w=()=>{window.clearTimeout(h),window.clearTimeout(f)},v=()=>{w(),g&&(y=Date.now()),g=!1,m=null,t(null)},_=(M,O)=>{var B,H;const z=M.dataset.tip;if(!z)return v();w(),g=!0,t({el:M,text:z,key:M.dataset.tipKey,detail:(B=M.dataset.tipDetail)==null?void 0:B.split(`
112
- `),card:M.dataset.tipCard!==void 0,dot:M.dataset.tipDot,name:M.dataset.tipName,aside:(H=M.dataset.tipAside)==null?void 0:H.split(`
113
- `),also:M.dataset.tipAlso&&M.dataset.tipAlsoKey?{text:M.dataset.tipAlso,key:M.dataset.tipAlsoKey}:void 0,placement:O,align:N6(M)})},x=M=>{const O=M.target;if(!(O instanceof Element))return null;const z=O.closest("[data-tip], .float");return(z==null?void 0:z.dataset.tip)!==void 0?z:null},N=M=>{o.current={x:M.clientX,y:M.clientY};const O=x(M);if(O===m)return;if(w(),m=O,!O){g&&(f=window.setTimeout(v,S6));return}const z=mx(O);if(g||Date.now()-y<E6)return _(O,z);h=window.setTimeout(()=>_(O,z),x6)},T=M=>{M.relatedTarget||v()},j=M=>{const O=x(M);if(O!=null&&O.matches(":focus-visible")){w(),m=O;const z=mx(O);_(O,z==="follow"?"bottom":z)}},C=()=>v(),I=M=>{M.key!=="Shift"&&M.key!=="Control"&&M.key!=="Alt"&&M.key!=="Meta"&&v()},A=M=>{m&&M.target instanceof Node&&M.target.contains(m)&&v()};return document.addEventListener("mouseover",N),document.addEventListener("mouseout",T),document.addEventListener("mousedown",v),document.addEventListener("keydown",I),document.addEventListener("scroll",A,!0),document.addEventListener("focusin",j),document.addEventListener("focusout",C),window.addEventListener("blur",v),()=>{w(),document.removeEventListener("mouseover",N),document.removeEventListener("mouseout",T),document.removeEventListener("mousedown",v),document.removeEventListener("keydown",I),document.removeEventListener("scroll",A,!0),document.removeEventListener("focusin",j),document.removeEventListener("focusout",C),window.removeEventListener("blur",v)}},[s]),S.useLayoutEffect(()=>{e&&!e.el.isConnected&&t(null)},[e]),S.useEffect(()=>{if((e==null?void 0:e.placement)!=="follow")return;const h=f=>{var m;o.current={x:f.clientX,y:f.clientY},(m=r.current)==null||m.update()};return document.addEventListener("mousemove",h),()=>document.removeEventListener("mousemove",h)},[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,c=d.jsxs(d.Fragment,{children:[a,e.key&&d.jsx(rs,{k:e.key,className:"tooltip-key"})]});return d.jsxs(Fs,{className:Be("tooltip",e.card&&"tooltip-card"),role:"tooltip",boxRef:n,handle:r,anchor:()=>T6(e,o.current),placement:_N(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(rs,{k:e.key,className:"tooltip-key"}):d.jsx("span",{}),d.jsx("span",{className:"tooltip-also",children:e.also.text}),d.jsx(rs,{k:e.also.key,className:"tooltip-key"})]}):e.name?d.jsxs("div",{className:"tooltip-head",children:[d.jsx("span",{children:c}),d.jsx("span",{className:"tooltip-name",children:e.name})]}):c,(u=e.detail)==null?void 0:u.map((h,f)=>d.jsx("div",{className:"tooltip-detail",children:h},f)),e.aside&&d.jsx("div",{className:"tooltip-foot",children:e.aside.map(h=>d.jsx("span",{children:h},h))})]})}const j6={sm:"",md:"btn-md",lg:"btn-lg"},$6={ghost:"",outline:"btn-outline",field:"btn-outline btn-field",inline:"btn-inline"},TN={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:c="button",disabled:u,children:h,...f}){const m=Be("btn",$6[e],j6[t],n&&TN[n],r&&"on",o&&"btn-mono",s&&"btn-busy",a);return d.jsxs("button",{className:m,type:c,disabled:s||u,"aria-busy":s||void 0,...f,children:[s&&d.jsx(eh,{}),h]})}function Lt({icon:e,label:t,hint:n,detail:r,also:o,placement:s,tipAlign:a,silent:c,badge:u,tone:h,on:f,className:m,type:g="button",...y}){const w=Be("btn-icon",h&&TN[h],f&&"on",m),v=Ft(t,n,{detail:r,also:o,placement:s,align:a});return d.jsxs("button",{className:w,type:g,...c?{"aria-label":v["aria-label"]}:v,...y,children:[typeof e=="string"?d.jsx(ht,{name:e}):e,u]})}function Hu(e,t,n){return n===0?0:(e+t+n)%n}function gx(e,t,n){return e>=0?Hu(e,t,n):n===0?-1:t>0?0:n-1}function jN(e,t,n){var s;const r=e.length,o=n.toLowerCase();for(let a=1;a<=r;a++){const c=(Math.max(t,-1)+a)%r;if((s=e[c])!=null&&s.trim().toLowerCase().startsWith(o))return c}return-1}function rg(e,t){return e&&e.length>t.length&&e.toLowerCase().startsWith(t.toLowerCase())?e.slice(t.length):null}function C6(e,t){if(e==null)return null;if(typeof e=="string"){const o=rg(e,t);return o?{text:o,accept:o,params:[]}:null}const n=rg(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:rg(e.accept,t),params:r}}function $N(e){const{results:t,keyOf:n,q:r,onPick:o,listRef:s,onActive:a,onSide:c,completionOf:u,narrowTo:h,setQ:f,tabPicks:m,onIdlePick:g}=e,[y,w]=S.useState(()=>{var I;return e.idle?-1:Math.max(0,((I=e.initialIndex)==null?void 0:I.call(e,t))??0)}),v=y>=0&&t[y]?n(t[y]):null,_=S.useRef(a);_.current=a,at([v],()=>{var I,A,M;(A=(I=s.current)==null?void 0:I.querySelector('.picker-item[data-state~="cursor"]'))==null||A.scrollIntoView({block:"nearest"}),(M=_.current)==null||M.call(_,y>=0?t[y]??null:null)});const x=y<0?-1:Math.min(y,Math.max(0,t.length-1)),N=x>=0?t[x]??null:null,T=N?C6(u==null?void 0:u(N,r),r):null,j=I=>{const A=h==null?void 0:h(I,r);if(A==null)return o(I,r);f==null||f(A),w(0)};return{index:x,active:N,ghost:T,setIndex:w,pick:j,onKeyDown:I=>{if(I.key==="ArrowDown")I.preventDefault(),w(gx(x,1,t.length));else if(I.key==="ArrowUp")I.preventDefault(),w(gx(x,-1,t.length));else if((I.key==="ArrowLeft"||I.key==="ArrowRight")&&c&&N)I.preventDefault(),c(N,I.key==="ArrowLeft"?-1:1);else if(I.key==="Tab"&&(T!=null&&T.accept))I.preventDefault(),f==null||f(r+T.accept),w(0);else if(I.key==="Tab"&&m&&N)I.preventDefault(),j(N);else if(I.key==="Enter"&&N)I.preventDefault(),j(N);else if(I.key==="Enter"&&x<0&&g)I.preventDefault(),g(r);else return!1;return!0}}}function hr(e){const t=Object.keys(e).filter(n=>e[n]);return t.length>0?t.join(" "):void 0}const A6=new Set(["Shift","Meta","Control","Alt","CapsLock","Fn"]);function CN(){const e=Fw(),t=On();return S.useEffect(()=>{if(!e)return;const n=()=>{e.target.isConnected||co.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(I6,{spec:e},e.id):null}function I6({spec:e}){const t=e.items,n=t.filter(hs),[r,o]=S.useState(-1),s=S.useRef({idx:r,items:n});s.current={idx:r,items:n};const a=S.useRef(null),c=m=>{var g,y;{const w=()=>co.close(),{idx:v,items:_}=s.current;if(A6.has(m.key))return;if(m.key==="ArrowDown"||m.key==="ArrowUp"){m.preventDefault(),m.stopPropagation();const x=m.key==="ArrowDown"?1:-1;o(Qz(_,v,x));return}if((m.key==="Enter"||m.key===" ")&&v>=0&&_[v]&&!_[v].disabled){m.preventDefault(),m.stopPropagation(),_[v].onClick(),w();return}if(m.key==="Escape"){m.stopPropagation(),w();return}if(m.key.length===1&&!m.metaKey&&!m.ctrlKey&&!m.altKey){m.preventDefault(),m.stopPropagation();const x=Array.from(((g=a.current)==null?void 0:g.querySelectorAll(".menu-label"))??[],T=>T.textContent??""),N=jN(x,v,m.key);N>=0&&!((y=_[N])!=null&&y.disabled)&&o(N);return}w()}};S.useEffect(()=>{const m=()=>co.close();return window.addEventListener("blur",m),window.addEventListener("resize",m),document.addEventListener("scroll",m,!0),()=>{window.removeEventListener("blur",m),window.removeEventListener("resize",m),document.removeEventListener("scroll",m,!0)}},[]);const{rect:u,placement:h}=t3(e),f=n.some(m=>m.checked);return d.jsxs(Fs,{className:Be("menu",e.head!==void 0&&"menu-headed"),role:"menu",boxRef:a,anchor:()=>u,placement:h,track:!1,from:e.target,trigger:e.toggles?e.target:null,onDismiss:()=>co.close(),onKey:c,onContextMenu:m=>m.preventDefault(),children:[e.head!==void 0&&d.jsx("div",{className:"menu-head",children:e.head}),t.map((m,g)=>{if(!hs(m))return d.jsx("hr",{className:"menu-sep"},`sep-${g}`);const y=n.indexOf(m);return d.jsx(R6,{item:m,gutter:f,cursor:y===r,onEnter:()=>o(y)},m.id)})]})}function R6({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:Be("row row-keyed",e.danger&&"danger",s!==void 0&&"row-tall",o&&"disabled"),"data-state":hr({cursor:n,checked:e.checked}),onMouseMove:o||n?void 0:r,onClick:()=>{o||(e.onClick(),co.close())},children:[t&&d.jsx("span",{className:"menu-check",children:e.checked&&d.jsx(ht,{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(rs,{k:e.key,className:"menu-key row-dim"})]})}const th=8,O6=104,M6=.25,AN=220,sk=.5,L6=100;function P6(e,t){return Math.max(0,-IN(e,t))}function IN(e,t){const n=e.filter(a=>t-a.t<=L6);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 D6(e,t,n){return e>0?e:n>0&&t>=sk?1:0}function z6({dx:e,dy:t}){return Math.abs(e)<th&&Math.abs(t)<th?null:Math.abs(e)>Math.abs(t)&&e<0?"slide":"other"}function F6(e,t,n=O6){const r=Math.max(0,-e),o=t*n,s=Math.min(t,Math.floor(r/n)),a=r<=o?r:o+(r-o)*M6,c=Math.min(1,r/(n/2));return{step:s,x:-a,well:c}}function RN(e,t){const n=S.useRef(t);n.current=t,S.useEffect(()=>{const r=e.current;if(!r)return;let o=null,s=null,a=!1,c=0,u=[],h=0,f=0;const m=(T,j,C,I)=>{T.el.dataset.slide!==I&&(T.el.dataset.slide=I,T.el.offsetWidth),T.el.style.setProperty("--slide-x",`${j}px`),T.el.style.setProperty("--slide-well",`${Math.round(C*100)}%`)},g=T=>{T.el.style.removeProperty("--slide-x"),T.el.style.removeProperty("--slide-well"),delete T.el.dataset.slide},y=(T=0)=>{var M;const j=o,C=a,I=j?D6(c,T,j.rungs):0,A=I!==c;o=null,s=null,a=!1,c=0,u=[],!(!j||!C)&&(A&&(n.current.onSlide({key:j.key,step:I}),(M=navigator.vibrate)==null||M.call(navigator,8)),m(j,0,0,"settle"),I>0&&n.current.onPick(j.key,I),h=window.setTimeout(()=>{g(j),n.current.onSlide(null)},AN))};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(h),o=j,w=T.pointerId,s={x:T.clientX,y:T.clientY})},_=T=>{var M;const j=o;if(!j||!s||T.pointerId!==w)return;const C=T.clientX-s.x,I=T.clientY-s.y;if(!a){const O=z6({dx:C,dy:I});if(O==="other"&&(o=null,s=null,w=null),O!=="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=F6(C,j.rungs,j.rung);m(j,A.x,A.well,"drag"),A.step!==c&&(c=A.step,n.current.onSlide({key:j.key,step:c}),c>0&&((M=navigator.vibrate)==null||M.call(navigator,8)))},x=T=>{T.pointerId===w&&(a&&(f=T.timeStamp+400),w=null,y(T.type==="pointerup"?P6(u,T.timeStamp):0))},N=T=>{T.timeStamp>=f||(T.preventDefault(),T.stopPropagation())};return r.addEventListener("pointerdown",v),r.addEventListener("pointermove",_),r.addEventListener("pointerup",x),r.addEventListener("pointercancel",x),r.addEventListener("click",N,!0),()=>{window.clearTimeout(h),r.removeEventListener("pointerdown",v),r.removeEventListener("pointermove",_),r.removeEventListener("pointerup",x),r.removeEventListener("pointercancel",x),r.removeEventListener("click",N,!0)}},[e])}const ON=1/3,B6=220;function U6({dx:e,dy:t}){return Math.abs(e)<th&&Math.abs(t)<th?null:Math.abs(e)<=Math.abs(t)?"other":e<0?"left":"right"}function H6(e,t,n){return n==="left"?Math.min(0,Math.max(-t,e)):Math.max(0,Math.min(t,e))}function W6(e,t,n,r){const o=n==="left"?-r:r;return o>=sk?!0:o<=-sk?!1:Math.abs(e)>=t*ON}function K6(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 kx=-1;function q6(e,t){const n=S.useRef(t);n.current=t;const r=S.useRef(()=>{});return S.useEffect(()=>{const o=e.current;if(!o)return;let s=null,a=null,c=null,u=!1,h=0,f=null,m=null,g=0,y=null,w=[],v=0,_=0;const x=(H,Y)=>{const ie=m;ie&&(ie.dataset.swipe!==Y&&(ie.dataset.swipe=Y,ie.offsetWidth),ie.style.translate=`${H}px`)},N=()=>{const H=m;m=null,H&&(delete H.dataset.swipe,H.offsetWidth,H.style.removeProperty("translate"))},T=()=>{s=null,a=null,c=null,u=!1,f=null,g=0,y=null,w=[]},j=H=>{try{o.setPointerCapture(H.pointerId)}catch{}},C=H=>{var Q,le;const Y=f,ie=(m==null?void 0:m.clientWidth)??0;T(),Y&&(x(H?Y==="left"?-ie:ie:0,"settle"),(le=(Q=n.current).onSettle)==null||le.call(Q,H),v=window.setTimeout(()=>{SE.flushSync(()=>n.current.onEnd(H)),N()},B6))},I=H=>{var ie;if(H.pointerType==="mouse")return;if(!H.isPrimary)return f?C(!1):T();if(m||(((ie=window.visualViewport)==null?void 0:ie.scale)??1)>1.01)return;const Y=H.target instanceof Element?H.target:null;!Y||Y.closest("textarea, input, [contenteditable], iframe, .float")||(window.clearTimeout(v),s={x:H.clientX,y:H.clientY},a=Y,c=K6(Y,o),y=H.pointerId,h=H.clientX)},A=(H,Y,ie,Q)=>{if(!s||!a)return;const le=H-s.x,U=Y-s.y;if(u&&c){c.scrollLeft-=H-h,h=H;return}if(!f){const $=U6({dx:le,dy:U});if($===null)return;if($==="other")return T();if(c){u=!0,h=H,Q&&j(Q);return}const q=n.current.take(a,$);if(!q)return T();m=q,f=$,Q&&j(Q)}w.push({x:H,t:ie}),w.length>8&&w.shift(),g=H6(le,(m==null?void 0:m.clientWidth)??0,f),x(g,"drag")},M=(H,Y)=>{var U;if(!f)return T();const ie=(m==null?void 0:m.clientWidth)??0,Q=Y?IN(w,H):0,le=Y&&W6(g,ie,f,Q);le&&Math.abs(g)<ie*ON&&((U=navigator.vibrate)==null||U.call(navigator,8)),C(le)},O=H=>{H.pointerId===y&&A(H.clientX,H.clientY,H.timeStamp,H)},z=H=>{H.pointerId===y&&((f||u)&&(_=H.timeStamp+400),M(H.timeStamp,H.type==="pointerup"))};r.current=H=>{const Y=performance.now();if(H.phase==="start"){if(m||s)return;s={x:H.x,y:H.y},a=o,c=null,y=kx;return}if(y===kx){if(H.phase==="move")return A(H.x+g,H.y,Y);M(Y,H.phase==="end")}};const B=H=>{H.timeStamp>=_||(H.preventDefault(),H.stopPropagation())};return o.addEventListener("pointerdown",I),o.addEventListener("pointermove",O),o.addEventListener("pointerup",z),o.addEventListener("pointercancel",z),o.addEventListener("click",B,!0),()=>{r.current=()=>{},window.clearTimeout(v),o.removeEventListener("pointerdown",I),o.removeEventListener("pointermove",O),o.removeEventListener("pointerup",z),o.removeEventListener("pointercancel",z),o.removeEventListener("click",B,!0)}},[e]),S.useCallback(o=>r.current(o),[])}function Wu({items:e,current:t,onPick:n,fill:r,font:o,segmented:s,quiet:a,end:c,label:u,owner:h}){const f=vn(h),m=S.useRef(null),g=Math.max(0,e.findIndex(w=>w.id===t)),y=w=>{var x,N;if(w.key!=="ArrowLeft"&&w.key!=="ArrowRight")return;w.preventDefault();const v=e.findIndex(T=>T.id===t),_=e[Hu(v,w.key==="ArrowRight"?1:-1,e.length)];_&&(n(_.id),(N=(x=m.current)==null?void 0:x.querySelectorAll('[role="tab"]')[e.indexOf(_)])==null||N.focus())};return d.jsxs("div",{className:Be("tabs",r&&"tabs-fill",o==="mono"&&"tabs-mono",s&&"tabs-segmented",a&&"tabs-quiet"),children:[d.jsx("div",{className:"tabs-list",role:"tablist","aria-label":u,ref:m,onKeyDown:y,style:s?{"--tabs-at":g,"--tabs-count":e.length}:void 0,children:e.map(w=>{const v=w.id===t;return d.jsxs("div",{className:Be("tab",v&&!!w.trail&&"tab-trailed",w.fit&&"tab-fit",w.far&&"tab-far"),"data-state":hr({current:v}),...w.menu?f.contextMenu(w.menu):{},children:[d.jsxs("button",{type:"button",className:"tab-btn",role:"tab","aria-selected":v,tabIndex:v?0:-1,onClick:()=>n(w.id),...w.tip,...w.ariaLabel?{"aria-label":w.ariaLabel}:{},children:[w.lead,w.label]}),v&&w.trail&&d.jsx("span",{className:"tab-trail",children:w.trail})]},w.id)})}),c&&d.jsx("span",{className:"tabs-end",children:c})]})}function ks({anchor:e="top",wide:t,foot:n,children:r}){const o=d.jsx("div",{className:Be("view",e==="line"&&"view-anchored",t&&"view-wide"),children:r});return n?d.jsxs("div",{className:"view-stack",children:[o,n]}):o}const MN=e=>`Toyon restarts once ${e.join(", ")} ${e.length===1?"finishes":"finish"}`,Z6=(e,t)=>[...e,...t.filter(n=>!e.includes(n))];function G6(e,t,n){const r=[...t],o=[...n],s=(c,u)=>{const h=c.indexOf(u);return h===-1?!1:(c.splice(h,1),!0)};return[...e.map(c=>s(r,c)?{name:c,dot:"working",note:null}:s(o,c)?{name:c,dot:"waiting",note:"asking you"}:{name:c,dot:"idle",note:"finished"}),...o.map(c=>({name:c,dot:"waiting",note:"asking you"}))]}function V6(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 Y6(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:MN(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 ik=!1;function X6(){ik=!0}function xu({title:e,body:t,action:n,pane:r,children:o}){return d.jsxs("div",{className:Be("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 wx={title:"Toyon was updated",body:"This page is still running the old build. Reload to pick up the new one."};class Yw extends S.Component{constructor(){super(...arguments);Tt(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(xu,{pane:this.props.pane,title:ik?wx.title:"Toyon hit an error",body:ik?wx.body:n.message||String(n),action:d.jsx(Me,{variant:"outline",onClick:()=>window.location.reload(),children:"reload"})}):this.props.children}}const ak={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.`},Q6=1e3,yx={held:[],asking:[],seen:[]};async function vx(e,t,n){for(;;){await new Promise(s=>setTimeout(s,Q6));const[r,o]=await Promise.all([Ug(e),MS(e)]);if(r!==null&&r!==t)break;n(o??{waiting:[],asking:[]})}window.location.reload()}function LN({foreign:e}={}){return e?d.jsx(J6,{name:e}):d.jsx(e5,{})}function J6({name:e}){const t=gs(),n=t.list()[0];return d.jsx(xu,{title:`Toyon on ${e} was updated`,body:ak.foreign(e),action:n&&d.jsxs(Me,{variant:"outline",onClick:()=>t.activate(n.origin),children:["back to ",t.displayName(n.origin)]})})}function e5(){const e=Rr(),[t,n]=S.useState(!0),[r,o]=S.useState(null),[s,a]=S.useState(yx),c=S.useRef(null),u=S.useCallback(w=>a(v=>({held:w.waiting,asking:w.asking,seen:Z6(v.seen,w.waiting)})),[]),h=S.useCallback(async w=>{n(!0),o(null);const v=c.current??{pid:await Ug(e)},_=await u4(e,w);if(_){n(c.current!==null),o(_);return}w&&a(yx),!c.current&&(c.current=v,vx(e,v.pid,u))},[u,e]);S.useEffect(()=>{let w=!0;return(async()=>{const[v,_]=await Promise.all([Ug(e),MS(e)]);if(!(!w||c.current)){if(_===null){h(!1);return}c.current={pid:v},u(_),vx(e,v,u)}})(),()=>{w=!1}},[u,h,e]);const f=t&&s.held.length>0,m=f?G6(s.seen,s.held,s.asking):[],g=m.filter(w=>w.dot==="working").length,y=m.filter(w=>w.dot!=="waiting").length;return d.jsx(xu,{title:ak.title,body:r??(f?V6(g,y):ak.waiting),action:f?d.jsx(Me,{variant:"outline",onClick:()=>void h(!0),children:"restart now"}):d.jsx(Me,{variant:"outline",busy:t,onClick:()=>void h(!1),children:"restart"}),children:m.length>0&&d.jsx("ul",{className:"crash-list",children:m.map((w,v)=>d.jsxs("li",{className:Be("crash-row",w.dot!=="working"&&"row-dim"),children:[d.jsx("span",{className:Be("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 pa=(e,t=!1)=>({text:e,live:t}),t5={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"},n5={probing:e=>`connecting to ${e}`,down:e=>`Toyon on ${e} is not answering.
114
- 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.
115
- a proxy, VPN or browser extension is the usual cause`,unauthorized:e=>`this page's token for ${e} is not the one running there.
116
- forget ${e} here and pair it again`},r5="no access token for this address.\nrun `toyon` or `toyon open` in your repo to get a signed-in page";function PN(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?pa(n5[e.connectFailure??"probing"](e.machine),t):e.hasToken?pa(t5[e.connectFailure??"probing"],t):pa(r5)}return e.title===null?pa(e.heard?`nothing open yet.
117
- press ${e.projectChord} to open a project, or type a name there to start a new one`:""):null}function o5(e){const t=PN(e);return t!==null?t:e.needsSetup&&e.busy?pa(`building in ${e.title}; the preview appears once it starts`,!0):e.needsSetup&&e.treeEmpty?pa(`${e.title} is empty so far; say what to build`):e.treeEmpty&&e.landsFrom?pa(`nothing runs on main until ${e.landsFrom} lands`):null}const an={post:(e,t)=>{},broadcast:e=>{}};function Eu(e,t,n,r){const o=t===r;an.post(e,o?{type:"pick-cancel"}:{type:"pick-start",verb:r}),n({a:"set-picking",v:o?!1:r})}function DN(e){return[{id:"copy-sha",label:`copy ${e.short}`,onClick:()=>tn(e.sha)},{id:"copy-subject",label:"copy subject",onClick:()=>tn(e.subject)}]}function Vh(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 zN="application/x-toyon-mention";let _a=null;function s5(e){return e.kind==="worktree"?`@${e.title} `:Ww(e.items)}function i5(e){return e.kind==="worktree"?e.branch:e.items.map(t=>t.path).join(" ")}function Su(e,t){e.dataTransfer.setData(zN,"1"),e.dataTransfer.setData("text/plain",i5(t)),e.dataTransfer.effectAllowed="copy",_a=t}function Ku(e){_a=null,Gw(e)}function FN(e,t){const n=e.getState().activeId;return(t.kind==="paths"?t.worktreeId===n:t.worktreeId!==n)?Oa(e):null}const BN=e=>_a!==null&&Array.from(e.dataTransfer.types).includes(zN);function a5(e,t){if(!BN(t)||!_a)return;t.preventDefault();const n=FN(e,_a)!==null;t.dataTransfer.dropEffect=n?"copy":"none",n&&Zw(e,{at:"chat"})}function UN(e,t){if(!BN(t)||!_a)return null;t.preventDefault();const n=_a,r=K3();if(Ku(e),r)return null;const o=FN(e,n);return o?{boxId:o,words:s5(n)}:null}function l5(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}function Yh(e){return e!=null&&e.config.profiles?Object.keys(e.config.profiles):[]}function HN(e,t){const n=Yh(t);if(n.length!==0)return e.profile&&n.includes(e.profile)?e.profile:t==null?void 0:t.config.defaultProfile}const c5=e=>Bf(_i((e==null?void 0:e.config)??{}),e==null?void 0:e.defaultBranch).toLowerCase();function ji(e,t,n){t({a:"shipping",id:n.worktreeId,op:n.t}),e==null||e.send(n)}const WN=(e,t)=>NA(e.worktree,{pending:()=>e.agent!=="idle"||(e.queued??0)>0||!!e.shipping,drafted:t,counts:()=>({dirty:e.dirty,ahead:e.ahead})});function Pl(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 KN(e,t,n){t({a:"hold-unread",id:n}),e==null||e.send({t:"mark-unread",worktreeId:n})}function qN(e,t,n){return{rename(r){if(!CE(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()}))},setProfile(r,o){e==null||e.send({t:"set-worktree-profile",worktreeId:r.worktree.id,profile:o})},ownProcs(r){e==null||e.send({t:"own-procs",worktreeId:r.worktree.id})},shareProcs(r){const o=(r.worktree.owns??[]).join(", ");window.confirm(`Stop this worktree's own ${o} and use main's?
118
-
119
- What they hold that main's do not (a database of their own) is not carried over.`)&&(e==null||e.send({t:"share-procs",worktreeId:r.worktree.id}))},archive(r){var a;if(!vh(r.worktree))return;const o=WN(r,n);if(!o)return Pl(e,t,[r.worktree.id]);window.confirm(`Archive worktree "${r.worktree.title}"? ${(a=o[0])==null?void 0:a.toUpperCase()}${o.slice(1)}.
120
-
121
- 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.`)&&Pl(e,t,[r.worktree.id])}}}function ZN(e,t,n,{sock:r,dispatch:o},s){var I,A;const a=e.worktree.id,c=qN(r,o,n.drafted),u=[],h=[],f=[],m=[],g=[],y=[];os(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"})}}),h.push({id:"copy-branch",label:"copy branch name",onClick:()=>tn(e.worktree.branch)}),h.push(...Bo(()=>r==null?void 0:r.send({t:"reveal",worktreeId:a}),s.hostname)),v||h.push({id:"copy-path",label:"copy path",onClick:()=>tn(e.path)});const{transcript:_,sessionId:x}=e,N=!!_&&!Tr(e.worktree);N&&Kh(s.hostname)&&h.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&&N&&h.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>tn(_)}),T&&x&&h.push({id:"copy-session",label:"copy session id",onClick:()=>tn(x)});const j=HN(e.worktree,t);for(const M of Lu(e.worktree)?[]:Yh(t))g.push({id:`profile:${M}`,label:`run with ${M}`,checked:M===j,onClick:()=>c.setProfile(e,M)});if(!xa(e.worktree)&&((I=e.borrowed)!=null&&I.length)&&g.push({id:"own-procs",label:`run ${e.borrowed.join(", ")} here`,detail:"on main now",onClick:()=>c.ownProcs(e)}),!xa(e.worktree)&&((A=e.worktree.owns)!=null&&A.length)&&g.push({id:"share-procs",label:`use main's ${e.worktree.owns.join(", ")}…`,detail:"runs here now",danger:!0,onClick:()=>c.shareProcs(e)}),CE(e.worktree)&&f.push({id:"rename",label:"rename…",onClick:()=>c.rename(e)}),s.graft&&jf(e.worktree)){const M=s.graft;f.push({id:"graft",label:"graft with…",onClick:()=>M(a)})}f.push({id:"unread",label:"mark as unread",key:Bt("mark-unread"),disabled:e.unseen?"already unread":void 0,onClick:()=>KN(r,o,a)});const C=w?void 0:"waiting on the one in progress";if(e.syncQueued)m.push({id:"sync",label:"call off the sync from main",onClick:()=>r==null?void 0:r.send({t:"unqueue-sync",worktreeId:a})});else if(bh(e)&&(e.behind??0)>0){const M=os(e.agent)&&(e.dirty??0)>0;m.push({id:"sync",label:`sync from main${M?" after the turn":""} (${e.behind} behind)`,disabled:C,onClick:()=>ji(r,o,{t:"sync-main",worktreeId:a})})}return da(e.worktree)&&!(e.worktree.landed&&e.dirty===0)&&m.push({id:"land",label:Jk(_i((t==null?void 0:t.config)??{}),e.worktree),detail:c5(t),disabled:C,onClick:()=>ji(r,o,{t:"land",worktreeId:a})}),e.worktree.kind==="worktree"&&m.push({id:"handoff",label:"continue elsewhere…",sub:!0,onClick:()=>o({a:"open",overlay:{kind:"handoff",worktreeId:a}})}),vh(e.worktree)&&y.push({id:"archive",label:WN(e,n.drafted)?"archive…":"archive",key:Bt("wt-archive"),danger:!0,onClick:()=>c.archive(e)}),Bn([u,h,f,m,g,y])}function u5(e,t,{sock:n,dispatch:r},o){const s=[],a=t.frame==="phone",c=[{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 bh(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(...Bo(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id}),o)),Bn([c,s,a?[]:[{id:"copy-path",label:"copy path",onClick:()=>tn(e.path)}]])}const d5={sm:"",md:"field-md",lg:"field-lg"};function GN({size:e="sm",font:t,bare:n,rule:r,className:o}){const s=t??(e==="lg"?"ui":"mono");return Be("field",d5[e],s==="ui"&&"field-ui",s==="lead"&&"field-lead",n&&"field-bare",r&&"field-rule",o)}const zo=S.forwardRef(function({size:t,font:n,bare:r,rule:o,className:s,...a},c){return d.jsx("input",{ref:c,className:GN({size:t,font:n,bare:r,rule:o,className:s}),...a})}),_u=S.forwardRef(function({size:t,font:n,bare:r,rule:o,className:s,...a},c){return d.jsx("textarea",{ref:c,className:GN({size:t,font:n,bare:r,rule:o,className:s}),...a})}),Xr=e=>/[.!?…]$/.test(e)?e:`${e}.`,VN=160;function Xh(e,t=VN){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 Xw(e){return e.subjects.length?Xh(e.subjects.join("; ")):void 0}function YN(e){const t=Xw(e);if(t)return e.pr===void 0?t:Xh(`PR #${e.pr}: ${t}`)}function Qw(e,t=3){const n=[];for(const a of e??[]){const c=YN(a);c&&n.push({at:a.at,line:c})}if(n.length===0)return[];const r=n.slice(-t),o=n.length-r.length,s=r.map(({at:a,line:c})=>n.length===1?Xr(c):`${Jw(Eo(fr(a)))}: ${Xr(c)}`);return o>0?[`${o} earlier landing${o===1?"":"s"}.`,...s]:s}const f5="checks running",h5="checks failed",XN="preview up";function p5(e){if(e.state!=="open")return[];const t=[];return(e.checks==="pending"||e.checks==="fail")&&t.push({text:e.checks==="fail"?h5:f5,url:`${e.url}/checks`,tip:"Open the checks on GitHub",open:"open the checks"}),e.preview&&t.push({text:XN,url:e.preview,tip:`Open the branch on ${new URL(e.preview).hostname}`,open:"open the preview"}),t}function m5(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 $s(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?`; ${XN}.`:".";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 QN(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 JN(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 Jw=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function ey(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 eT(e,t,n=null){return e!=null&&e.stale?`The work changed since this was written. ${t?"Run the check again and refresh":"Refresh"} the message.`:n==="unanswered"?`The model did not answer with a message. ${t?"Run the check again and ask":"Ask"} for it again.`:`${t?"Run the repo's check here and write":"Write"} the recap and the commit message.`}function g5(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 pf(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(`
122
- `).find(c=>c.trim()))==null?void 0:s.trim();return`Check failed${a?`: ${Xr(a)}`:"."}`}return ey(e,t,n)==="unasked"?g5(r):null}function bx(e,t){const n=k5(e,t);return n?Xr(Jw(n)):""}function k5(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 tT=e=>/^[A-Z][a-z]+(\s|$)/.test(e)?`${e.charAt(0).toLowerCase()}${e.slice(1)}`:e;function w5(e,t){const n=t??0;return n>0?`${n} behind ${e}; land takes it in first.`:""}function y5(e){return e>0?Xr(Jw(`${e} ${e===1?"file":"files"} changed`)):""}function v5(e,t=null){return e.stale?"Changed since this was written.":t==="unanswered"?"No message yet: the model did not answer.":e.why?`Not ready: ${Xr(tT(e.why))}`:null}function mf(e){return Xr(e)}const Eo=e=>e==="now"?"just now":`${e} ago`;function b5(e,t,n){switch(e){case"asking":return`Waiting on you${n==="now"?"":` for ${n}`}${t.ask?`: ${Xr(t.ask)}`:"."}`;case"failed":return t.auth?`Stopped ${Eo(n)}: not logged in.`:t.error?`Failed ${Eo(n)}: ${Xr(t.error)}`:`Failed ${Eo(n)}.`;case"stopped":return t.planBack?`Sent the plan back ${Eo(n)}. Say what to change.`:`Stopped ${Eo(n)}.`;case"done":return t.cut?`Ended early ${Eo(n)} (${t.cut}).`:`Finished ${Eo(n)}.`}}function ty(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?Xr(t):b5(e.end,e.facts,fr(e.at))}function x5(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?`Last stop, ${Eo(fr(e.at))}: ${Xr(tT(t))}`:void 0}function Nu(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 ny(e){return(e==null?void 0:e.status)==="running"||(e==null?void 0:e.status)==="detached"}function nT(e){const t=e&&e.status!=="terminated"?e.since:void 0,n=Ow(t,Mw);return t!==void 0&&n===t?e:void 0}function rT(e,t){const n=e.stage?[e.stage]:[];switch(e.status){case"queued":return[...n,"queued"];case"running":return[...n,`${ha(t)} of ${HA(e.timeoutMs)}`];case"detached":return[...n,ha(t),"detached"];case"terminated":return[e.why??"stopped"]}}function nh(e,t,n){return[e,...rT(t,n)].join(" · ")}const lk={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 oT(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 E5({active:e,ahead:t,behind:n,unpushed:r,dirty:o}){var Kt,xt,un;const s=Je(),a=lt(),c=vn("changes"),u=Sn(e)?e.worktree:null,h=e.id,f=L(Ct=>{var Ut;return(Ut=Ct.shipping[h])==null?void 0:Ut.op}),m=L(Ct=>{var Ut;return(Ut=Ct.shipping[h])==null?void 0:Ut.step}),g=Ow(m,Mw),y=Nu(e,"commit"),w=Nu(e,"check"),v=f?y:w,_=nT(v),x=Ti(ny(_)?_==null?void 0:_.since:void 0),[N,T]=S.useState("");at([h],()=>T("")),at([o],()=>{o||T("")});const j=S.useRef(null),C=(Kt=u==null?void 0:u.landing)!=null&&Kt.subject?u.landing.body?`${u.landing.subject}
123
-
124
- ${u.landing.body}`:u.landing.subject:null,I=()=>{N===""&&C&&T(C);const Ct=j.current;Ct&&(Ct.focus(),requestAnimationFrame(()=>Ct.setSelectionRange(Ct.value.length,Ct.value.length)))},A=L(Ct=>Ct.editCommit);at([A],()=>{A&&I()});const M=N.trim()||void 0,O=L(Ct=>{var Ut;return!!((Ut=Ct.agents.find(Et=>Et.id===((u==null?void 0:u.agent)??Ct.defaultAgent)))!=null&&Ut.quick)}),z=u==null?void 0:u.landing,B=M?null:ey(z,o?1:0,O),H=(z==null?void 0:z.check)==="pending",Y=!!(z!=null&&z.stale),ie=()=>{f||s==null||s.send({t:"judge",worktreeId:h})},Q=()=>{f||!M&&!C||ji(s,a,{t:"commit",worktreeId:h,message:M??C??""})},le=()=>{f||ji(s,a,{t:"land",worktreeId:h,...M?{message:M}:{}})},U=((xt=u==null?void 0:u.landing)==null?void 0:xt.check)==="fail",$=!!(u!=null&&u.landed)&&!o,q=u?Eh({...u,landed:$}):void 0,V=(q==null?void 0:q.state)==="open",W=V&&(o||r>0),re=H||Y||!!B,fe=!!u&&da(u)&&!$&&(o||t>0)&&!U&&!V&&!re,pe=!!u&&W&&!U&&!re,Te=!!u&&da(u)&&!H&&(Y||B==="unwritten"||B==="unanswered")&&!os(e.agent),je=L(Ct=>Ct.repos.find(Ut=>Ut.id===e.repoId)??null),de=_i((je==null?void 0:je.config)??{}),J=Bf(de,je==null?void 0:je.defaultBranch),te=Jk(de,u??{}),ve=je?xh(je):"main",ce=bh(e)?W4(ve,n):null,ae=os(e.agent),xe=o&&!u?"commit or discard the changes here first":void 0,Re=!!e.syncQueued,ge=o&&ae?`Merge ${ve} into this worktree once the turn ends, uncommitted changes kept`:`Merge ${ve} into this worktree${o?", uncommitted changes kept":""}`,Ee=V&&!W&&JN(q),We=fe?te:pe?"update":Ee?"land":(q==null?void 0:q.state)==="merged"?"pull":"land",Ye=f==="commit"?g??"commit":f==="land"?g?`${We}: ${g}`:We:null,ln=Ye&&_?nh(Ye,_,x):Ye,cn=S.useRef(!1);ln?o&&(cn.current=!0):cn.current=!1;const gt=!!u&&(o||cn.current),Ue=gt&&!!ln,zt=f?null:v?_?rT(_,x).join(" · "):null:H?"writing the message":null,pt=_&&(_.status==="running"||_.status==="detached")?_:null,At=pt&&d.jsx(Lt,{icon:"stop",tone:"danger",label:oT(pt.kind),onClick:()=>s==null?void 0:s.send({t:"run-stop",worktreeId:h,kind:pt.kind})});return d.jsxs("div",{className:"composer commit-box",children:[gt&&d.jsx("div",{className:"composer-field",children:Ue?d.jsx("div",{className:"commit-running live-text","data-tip":_?lk[_.status]:void 0,children:ln}):d.jsx(_u,{size:"lg",bare:!0,ref:j,value:N,onChange:Ct=>T(Ct.target.value),onKeyDown:Ct=>{Ct.key==="Enter"&&(Ct.metaKey||Ct.ctrlKey)?(Ct.preventDefault(),Q()):Ct.key==="Tab"&&!Ct.shiftKey&&N===""&&C&&(Ct.preventDefault(),I())},placeholder:C??(B==="unanswered"?"no message yet: the model did not answer. Check again, or write one here":B==="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(ht,{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 ${ve}`,children:[t," ahead"]}),$&&d.jsxs("span",{className:"badge-landed","data-tip":`Merged into ${ve}`,children:[d.jsx(ht,{name:"check",className:"icon-inline"})," landed"]})]}),d.jsxs("span",{className:"commit-acts",children:[ln?d.jsxs(d.Fragment,{children:[!Ue&&d.jsx("span",{className:"live-text",children:ln}),At]}):d.jsxs(d.Fragment,{children:[u&&o&&d.jsx(Me,{disabled:!M&&!C||!!f,onClick:Q,...Ft(C&&!M?"Commit with the suggested message":"git add -A && git commit","⌘⏎"),children:"commit"}),u&&fe&&d.jsx(Me,{tone:"primary",disabled:!!f,"data-tip":J,onClick:le,children:te}),Te&&d.jsx(Me,{tone:"primary",disabled:!!f,"data-tip":eT(z,!!((un=je==null?void 0:je.config.check)!=null&&un.trim()),B),onClick:ie,children:"check"}),H&&d.jsx("span",{className:"live-text",children:"check"}),pe&&q&&d.jsx(Me,{tone:"primary",disabled:!!f,"data-tip":`Commit, take ${ve} in and push the branch; PR #${q.number} takes the new commits`,onClick:le,children:"update"}),Ee&&d.jsx(Me,{tone:"primary",disabled:!!f,"data-tip":QN(q),onClick:le,children:"land"})]}),q&&d.jsxs(Me,{"data-tip":`Open PR #${q.number} on GitHub`,onClick:()=>window.open(q.url,"_blank"),...c.contextMenu(()=>[{id:"open-pr",label:"open on GitHub",onClick:()=>window.open(q.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>tn(q.url)}]),children:["view ",d.jsx(ht,{name:"external",className:"icon-inline"})]}),(q==null?void 0:q.preview)&&d.jsxs(Me,{"data-tip":`Open the branch on ${new URL(q.preview).hostname}`,onClick:()=>window.open(q.preview,"_blank"),...c.contextMenu(()=>[{id:"open-preview",label:"open the preview",onClick:()=>window.open(q.preview,"_blank")},{id:"copy-preview",label:"copy link",onClick:()=>tn(q.preview??"")}]),children:["preview ",d.jsx(ht,{name:"external",className:"icon-inline"})]})]})]}),(ce||zt)&&d.jsxs("div",{className:"composer-notes",children:[zt&&d.jsxs("div",{className:"hint composer-note","data-tip":_?lk[_.status]:void 0,children:[d.jsx("span",{children:zt}),At]}),ce&&d.jsxs("div",{className:"hint composer-note",children:[d.jsx("span",{children:ce}),f==="sync-main"?d.jsx("span",{className:"live-text",children:g?`sync: ${g}`:"sync"}):Re?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:!!f||!!xe,"data-tip":xe??ge,onClick:()=>ji(s,a,{t:"sync-main",worktreeId:h}),children:"sync"})]})]})]})}const S5=S.memo(function({c:t,id:n,selected:r,onToggle:o}){const s=vn("changes"),a=Bu("changes");return d.jsxs("button",{className:"row row-sm log-row row-edge",id:n,"data-state":hr({current:r,cursor:r}),role:"option","aria-selected":r,tabIndex:-1,onClick:()=>o(t.sha),...s.contextMenu(()=>DN(t)),"data-tip":`${t.subject}
125
- ${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:fr(t.at)})]})});function _5(e,t){const n=To(e,t);if(!n||!Sn(n))return"take this worktree over to change files here";if(xa(n.worktree))return"start a worktree to change files"}function sT(e,t,n,r){return{id:"new-file",label:"new file…",disabled:_5(e.getState(),t),onClick:()=>r(n)}}function N5(e,t,n,r){const{worktreeId:o,dir:s,path:a,folder:c,newIn:u}=e,h=Hw(t.getState(),o)?void 0:"take this worktree over to talk to an agent here",f=nN(a,c),m=[...c?[]:[{id:"open",label:"open",onClick:()=>Rn(n,{worktreeId:o,path:a,view:Ii(a)})}],{id:"add-to-chat",label:"add to chat",disabled:h,onClick:()=>h3(t,o,a,c)}],g=[sT(t,o,u,r),{id:"ask-rename",label:"ask the agent to rename…",disabled:h,onClick:()=>ax(t,o,`Rename ${f} to `)},{id:"ask-delete",label:"ask the agent to delete…",disabled:h,onClick:()=>ax(t,o,`Delete ${f} and update whatever still uses it`)}],y=[...Bo(()=>{var w;return(w=n.sock)==null?void 0:w.send({t:"reveal",worktreeId:o,path:a})},fo(n.sock)),{id:"copy-path",label:"copy path",onClick:()=>tn(`${s}/${a}`)},{id:"copy-relative-path",label:"copy relative path",onClick:()=>tn(a)}];return Bn([m,y,g])}function T5(e,t,n,r){return Bn([[sT(t,e.worktreeId,"",r)],Bo(()=>{var o;return(o=n.sock)==null?void 0:o.send({t:"reveal",worktreeId:e.worktreeId})},fo(n.sock))])}const gf=[],j5=[],xx=new Set,Ex=e=>`tree-row-${e}`;function $5({worktreeId:e,dir:t,openPath:n,openRef:r,rootRef:o}){const s=On(),a=Je(),c=lt(),u=Mt(e,"files"),h=Mt(e,"submodules"),f=Mt(e,"ignored"),m=Mt(e,"git"),g=(m==null?void 0:m.files)??j5,y=m==null?void 0:m.version,w=L(ae=>ae.connected);at([e,y,w,a],()=>qh(e,s.getState(),{sock:a,dispatch:c}));const v=L(ae=>{var xe;return((xe=ae.dragFiles)==null?void 0:xe.at)==="tree"&&ae.dragFiles.worktreeId===e?ae.dragFiles.dir:null}),_=L(ae=>ae.treeOpen[e]??gf),x=S.useMemo(()=>new Set(_),[_]),[N,T]=S.useState(xx);at([e,n,r],()=>T(n&&!r?new Set(Xf(n).filter(ae=>!x.has(ae))):xx));const j=S.useCallback(ae=>x.has(ae)||N.has(ae),[x,N]),C=S.useCallback(ae=>{const xe=x.has(ae)||N.has(ae);if(xe&&N.has(ae)){const Re=new Set(N);Re.delete(ae),T(Re)}c({a:"tree-folder",worktreeId:e,path:ae,open:!xe})},[x,N,e,c]),I=S.useMemo(()=>w3(u??gf,h??gf,f??gf),[u,h,f]),A=S.useMemo(()=>y3(I,j),[I,j]),M=S.useMemo(()=>b3(g),[g]),O=L(ae=>ae.treeReveal),z=O&&O.worktreeId===e?O:null,[B,H]=S.useState(()=>(z==null?void 0:z.path)??null),[Y,ie]=S.useState({worktreeId:e,linked:z});(Y.worktreeId!==e||Y.linked!==z)&&(ie({worktreeId:e,linked:z}),H((z==null?void 0:z.path)??null));const[Q,le]=S.useState(!1),U=S.useMemo(()=>{if(B===null)return-1;const ae=A.findIndex(xe=>xe.path===B);if(ae>=0)return ae;for(const xe of Xf(B).reverse()){const Re=A.findIndex(ge=>ge.path===xe);if(Re>=0)return Re}return-1},[A,B]);at([U,Q],()=>{var ae,xe;Q&&((xe=(ae=o.current)==null?void 0:ae.querySelector('[data-state~="cursor"]'))==null||xe.scrollIntoView({block:"nearest"}))});const $=S.useCallback((ae,xe)=>Rn({dispatch:c},{worktreeId:e,path:ae,view:Ii(ae),focus:xe}),[e,a,c]),q=S.useCallback(ae=>{H(ae.path),ae.kind==="folder"?C(ae.path):ae.kind==="file"&&$(ae.path,!1)},[C,$]),V=ae=>{var ge;if(ae.metaKey||ae.ctrlKey||ae.altKey)return;const xe=A[U],Re=Ee=>{const We=A[Ee];We&&(H(We.path),We.kind==="file"&&$(We.path,!1))};switch(ae.key){case"ArrowDown":case"ArrowUp":ae.preventDefault(),Re(U<0?0:Hu(U,ae.key==="ArrowDown"?1:-1,A.length));return;case" ":ae.preventDefault(),(xe==null?void 0:xe.kind)==="file"?$(xe.path,!1):(xe==null?void 0:xe.kind)==="folder"&&C(xe.path);return;case"Enter":ae.preventDefault(),(xe==null?void 0:xe.kind)==="file"?$(xe.path,!0):(xe==null?void 0:xe.kind)==="folder"&&C(xe.path);return;case"ArrowRight":case"ArrowLeft":{ae.preventDefault();const Ee=A.map(Ye=>Ye.kind==="folder"?{depth:Ye.depth,open:Ye.open}:{depth:Ye.depth}),We=Vh(Ee,U,ae.key);(We==null?void 0:We.do)==="to"?Re(We.at):We&&xe&&C(xe.path);return}case"Escape":ae.stopPropagation(),n!==null?c({a:"close-editor"}):(ge=document.activeElement)==null||ge.blur();return}if(ae.key.length===1){const Ee=jN(A.map(We=>We.name),U,ae.key);Ee>=0&&(ae.preventDefault(),Re(Ee))}},[W,re]=S.useState(null),fe=S.useRef(0),pe=S.useCallback(ae=>{ae&&!j(ae)&&C(ae),fe.current++,re({dir:ae,error:null,busy:!1})},[j,C]),Te=S.useCallback(()=>{fe.current++,re(null)},[]),je=S.useCallback(ae=>{if(!W||W.busy)return;const xe=v3(W.dir,ae);if("error"in xe){re({...W,error:xe.error});return}const Re=++fe.current;re({...W,error:null,busy:!0}),X_({sock:a,dispatch:c},{worktreeId:e,path:xe.path}).then(ge=>{ge===null&&H(xe.path),Re===fe.current&&re(ge===null?null:{...W,error:ge,busy:!1})})},[W,e,a,c]),de=vn("tree"),J=S.useCallback(ae=>N5({worktreeId:e,dir:t,path:ae.path,folder:ae.kind!=="file",newIn:ae.kind==="folder"||ae.kind==="ignored"?ae.path:sN(ae.path)},s,{sock:a,dispatch:c},pe),[e,t,s,a,c,pe]),te=S.useCallback((ae,xe)=>{ae.kind==="file"&&an.post(e,xe?{type:"highlight-file",path:ae.path,ranges:null}:{type:"highlight-clear"})},[e]),ve=S.useCallback((ae,xe)=>Su(xe,{kind:"paths",worktreeId:e,items:[{path:ae.path,folder:ae.kind!=="file"}]}),[e]),ce=S.useCallback(()=>Ku(s),[s]);return d.jsx("div",{className:Be("tree",v===""&&"drop-over"),role:"tree","aria-label":"files","data-worktree":e,"aria-activedescendant":Q&&U>=0?Ex(U):void 0,tabIndex:0,ref:o,onKeyDown:V,onFocus:()=>{var ae;le(!0),B===null&&H(n&&A.some(xe=>xe.path===n)?n:((ae=A[0])==null?void 0:ae.path)??null)},onBlur:ae=>!ae.currentTarget.contains(ae.relatedTarget)&&le(!1),onMouseDown:ae=>{if(ae.button!==0)return;const xe=ae.target.closest("[data-path]");(xe==null?void 0:xe.dataset.path)!==void 0&&H(xe.dataset.path)},...de.contextMenu(ae=>{const xe=A[U];return ae==="keyboard"&&xe?J(xe):T5({worktreeId:e},s,{sock:a},pe)}),children:u===void 0?d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"listing files"})}):A.length===0&&!W?d.jsx("div",{className:"empty",children:"no files"}):C5(A.map((ae,xe)=>d.jsx(I5,{row:ae,id:Ex(xe),status:M.files.get(ae.path),changedInside:ae.kind!=="file"&&M.folders.has(ae.path),current:Q?xe===U:!r&&ae.path===n,cursor:Q&&xe===U,dropOver:v===ae.path,onPress:q,menu:J,onHover:te,onDragStart:ve,onDragEnd:ce},ae.path)),W&&(()=>{var xe;const ae=W.dir===""?-1:A.findIndex(Re=>Re.path===W.dir);return{at:ae,node:d.jsx(A5,{depth:ae>=0?(((xe=A[ae])==null?void 0:xe.depth)??0)+1:0,error:W.error,onSubmit:je,onCancel:Te},"new-file")}})())})}function C5(e,t){return t?[...e.slice(0,t.at+1),t.node,...e.slice(t.at+1)]:e}function A5({depth:e,error:t,onSubmit:n,onCancel:r}){const[o,s]=S.useState(""),a={"--tree-depth":e},c=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":c,style:a,children:[d.jsx("span",{className:"tree-caret row-dim"}),d.jsx(zo,{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":c,style:a,children:[d.jsx("span",{className:"tree-caret"}),d.jsx("span",{className:"hint",children:t})]})]})}const I5=S.memo(function({row:t,id:n,status:r,changedInside:o,current:s,cursor:a,dropOver:c,onPress:u,menu:h,onHover:f,onDragStart:m,onDragEnd:g}){const y=vn("tree"),w=Bu("changes"),v=t.kind==="submodule",_=v?"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:Be("row row-sm tree-row row-rails row-edge",c&&"drop-over"),"data-state":hr({current:s,cursor:a}),"data-kind":t.kind,"data-path":t.path,style:{"--tree-depth":t.depth},draggable:!v,onDragStart:x=>m(t,x),onDragEnd:g,onClick:()=>u(t),onMouseEnter:()=>f(t,!0),onMouseLeave:()=>f(t,!1),...y.contextMenu(()=>h(t)),..._?Ft(_,void 0,{placement:w}):{},children:[d.jsx("span",{className:"tree-caret row-dim",children:t.kind==="folder"&&d.jsx(ht,{name:"caret",className:Be("icon-inline disc-caret",!t.open&&"shut")})}),d.jsx("span",{className:Be("tree-name",(v||t.ignored)&&"row-dim"),children:t.name}),r?d.jsx("span",{className:`xy ${yw(r.xy)}`,children:vw(r.xy)}):o&&d.jsx("span",{className:"dot tree-changed"})]})});function iT({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 kf=S.memo(function({f:t,id:n,active:r,selected:o,checking:s=!1,checked:a=!1,onOpen:c,onCheck:u,menu:h,onHover:f,onDragStart:m,onDragEnd:g}){const y=vn("changes"),w=Bu("changes"),{name:v,dir:_}=GS(t.path);return d.jsxs("button",{className:"row row-sm git-file row-edge",id:n,"data-state":hr({current:r,cursor:o,checked:a}),role:"option","aria-selected":o,tabIndex:-1,onClick:x=>u&&(s||x.shiftKey)?u(t.path):c(t.path),draggable:!!m,onDragStart:m&&(x=>m(t.path,x)),onDragEnd:g,...y.contextMenu(()=>h(t.path)),onMouseEnter:()=>f(t.path,!0),onMouseLeave:()=>f(t.path,!1),"data-tip":_?t.path:void 0,"data-tip-placement":w,children:[s&&d.jsx("input",{type:"checkbox",className:"changes-check",checked:a,readOnly:!0,tabIndex:-1}),d.jsx("span",{className:`xy ${yw(t.xy)}`,children:vw(t.xy)}),d.jsxs("span",{className:"path",children:[d.jsx("span",{className:"name",children:v}),_&&d.jsx("span",{className:"dir row-dim",children:_})]}),d.jsx(iT,{f:t})]})}),Sx=new Set(["test","tests","__tests__","spec","e2e","__snapshots__","__mocks__","fixtures","testdata"]),R5=/([._-]tests?\.[^.]+$)|([._]specs?\.[^.]+$)|(^tests?[._-])|(^conftest\.py$)|(\.snap$)|([a-z0-9](Tests?|Spec)\.[^.]+$)/;function rh(e){const t=(e.endsWith("/")?e.slice(0,-1):e).split("/"),n=t.pop()??"";return e.endsWith("/")&&Sx.has(n.toLowerCase())?!0:t.some(r=>Sx.has(r.toLowerCase()))||R5.test(n)}function Of(e){const t=e.filter(n=>!rh(n.path));return t.length===0||t.length===e.length?{files:e,source:t.length}:{files:[...t,...e.filter(n=>rh(n.path))],source:t.length}}const wf=[];function O5(e,t){var a,c;const n=Of((e==null?void 0:e.files)??wf),r=(a=e==null?void 0:e.extras)==null?void 0:a.turn,o=Of(r&&t.turn?r.files:wf),s=Of(t.committed?((c=e==null?void 0:e.extras)==null?void 0:c.committed)??wf:wf);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 M5={added:"A",changed:"M",removed:"D"},L5={added:"added",changed:"",removed:"deleted"},P5=S.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":hr({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 ${L5[s.change]}`,children:M5[s.change]}),d.jsx("span",{className:"name",children:s.name})]},a))}),ck="(?<q>[\"'`])(?<name>(?:\\\\.|(?!\\k<q>).)*)\\k<q>",_x={tests:[new RegExp(`^\\s*(?:test|it)(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${ck}`)],groups:[new RegExp(`^\\s*describe(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${ck}`)]},D5={js:_x,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*${ck}`),/^\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*\(/,..._x.tests]}},z5={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"},F5=3,B5=/^\s*(?:[)}\]]|end\b)/,og=e=>e.length-e.trimStart().length;function Nx(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 Tx(e,t){const n=t.split(`
126
- `),r=[],o=[];let s=Number.NEGATIVE_INFINITY;return n.forEach((a,c)=>{var g,y,w;if(a.trim()==="")return;const u=og(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=c);const f=!e.mark||c-s<=F5?Nx(a,e.tests):null,m=f??Nx(a,e.groups);if(m!==null){if(f!==null){s=Number.NEGATIVE_INFINITY;let v=c+1;for(;v<n.length&&(((w=n[v])==null?void 0:w.trim())===""||og(n[v]??"")>u);)v++;v<n.length&&og(n[v]??"")===u&&B5.test(n[v]??"")&&v++;const _=n.slice(c,v).map(x=>x.trim()).join(`
127
- `).trim();r.push({group:o.map(x=>x.name),name:m,line:c,end:v,body:_})}o.push({indent:u,name:m})}}),r}function jx(e){const t=new Map;for(const n of e){const r=[...n.group,n.name].join(`
128
- `);let o=0;for(;t.has(`${r}
129
- ${o}`);)o++;t.set(`${r}
130
- ${o}`,n)}return t}function U5(e,t,n){const r=D5[z5[e.slice(e.lastIndexOf(".")+1).toLowerCase()]??""];if(!r)return[];const o=jx(Tx(r,t)),s=jx(Tx(r,n)),a=[];for(const[f,m]of s){const g=o.get(f);(g==null?void 0:g.body)!==m.body&&a.push({name:m.name,group:m.group,change:g?"changed":"added",line:m.line+1})}const c=n.split(`
131
- `).length;let u=1;for(const[f,m]of o){const g=s.get(f);g?u=Math.min(g.end+1,c):a.push({name:m.name,group:m.group,change:"removed",line:u})}const h=f=>f.change==="removed"?0:1;return a.sort((f,m)=>f.line-m.line||h(f)-h(m))}const H5=[];function W5(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=fr(r.at);return`${o}, last commit ${s==="now"?"just now":`${s} ago`}`}const $x='[role="option"]:not([data-sub])',Cx=[];function aT({width:e,placement:t="dock"}){var Pn,br;const n=t==="screen",r=Je(),o=lt(),s=On(),a=Ql(),c=Ia(),u=(c==null?void 0:c.id)??a,h=zs(),f=L(Z=>Z.layout.changes),m=zu(),g=L(Z=>Z.focusChanges),y=Mt(u,"git"),w=L(Z=>Z.editor&&Z.editor.worktreeId===u?Z.editor.path:null),v=L(Z=>Z.editor&&Z.editor.worktreeId===u?Z.editor.ref??null:null),_=L(Z=>Z.editor&&Z.editor.worktreeId===u?Z.editor.since??null:null),x=(((Pn=y==null?void 0:y.extras)==null?void 0:Pn.committed)??H5).length>0,N=Cz(),T=(br=y==null?void 0:y.extras)==null?void 0:br.turn,j=Az(),C=S.useMemo(()=>O5(y,{turn:j,committed:N}),[y,j,N]),{files:I,fileSource:A,turned:M,turnedSource:O,turnBase:z,committed:B,committedSource:H}=C,Y=I.length,ie=I.length+M.length,Q=L(Z=>Z.editor&&Z.editor.worktreeId===u?Z.editor.disk:null),le=S.useMemo(()=>w!==null&&Q&&rh(w)?U5(w,Q.before,Q.after):Cx,[w,Q]),[U,$]=S.useState(!1);at([w,v,_],()=>$(!1));const q=A>0?I.length-A:0,V=H>0?B.length-H:0,W=O>0?M.length-O:0,re=I.length===0,fe=S.useMemo(()=>{if(I.length===0)return;const Z=I.reduce((wt,dn)=>wt+(dn.add??0),0),we=I.reduce((wt,dn)=>wt+(dn.del??0),0),Ze=[Z>0&&`+${Z}`,we>0&&`−${we}`].filter(Boolean).join(" "),qt=`${I.length} uncommitted ${I.length===1?"file":"files"}`;return Ze?`${qt}, ${Ze}`:qt},[I]),pe=!!y&&re&&(y.ahead??0)===0,Te=L(Kl),je=c!==null||Te==="changes",de=c!==null||Te==="history",J=S.useCallback(Z=>o({a:"changes-tab",v:Z}),[o]),te=S.useRef(Te);te.current=Te;const ve=S.useRef(null),ce=Lw(),ae=L(Z=>{const we=Li(Z,ce==null?void 0:ce.repoId);return we?xh(we):"main"}),xe=Mt(u,"commits"),Re=Mt(u,"commitFiles"),[ge,Ee]=S.useState(null),We=S.useRef(null);We.current=ge;const Ye=S.useRef(null),ln=Mt(u,"changedRanges"),cn=S.useCallback((Z,we)=>{if(!u||c)return;if(!we){Ye.current=null,an.post(u,{type:"highlight-clear"});return}Ye.current=Z;const Ze=ln[Z];Ze?an.post(u,{type:"highlight-file",path:Z,ranges:Bb(Ze)}):r==null||r.send({t:"changed-ranges",worktreeId:u,path:Z})},[u,c,ln,r]);S.useEffect(()=>{const Z=Ye.current;if(!Z||!u)return;const we=ln[Z];we&&an.post(u,{type:"highlight-file",path:Z,ranges:Bb(we)})},[ln,u]);const gt=c&&I.length>0?(y==null?void 0:y.head)??null:null,Ue=S.useCallback((Z,we=!1,Ze)=>u&&Rn({dispatch:o},{worktreeId:u,path:Z,focus:we,ref:gt??void 0,since:Ze}),[u,gt,r,o]),zt=S.useMemo(()=>c?I:[...I,...M,...B],[c,I,M,B]),pt=S.useMemo(()=>{const Z=[];for(const we of xe??[])if(Z.push({commit:we}),we.sha===ge)for(const Ze of Of(Re[we.sha]??[]).files)Z.push({commit:we,file:Ze});return Z},[xe,ge,Re]),At=S.useMemo(()=>pt.filter(Z=>!Z.file&&Z.commit.ahead).length,[pt]),Kt=S.useMemo(()=>pt.findIndex(Z=>!Z.file&&!Z.commit.ahead),[pt]),xt=c?zt.length:0,un=(je?zt.length:0)+(de?pt.length:0),Ct=S.useMemo(()=>{const Z=new Map;if(!c||I.length===0&&pt.every(Ze=>Ze.commit.landedAt))return Z;let we;return pt.forEach((Ze,qt)=>{const wt=!!Ze.commit.landedAt;wt!==we&&(we=wt,Z.set(qt,wt?"landed":"not landed"))}),Z},[c,I,pt]),Ut=S.useRef(null),[{row:Et,at:er},Qt]=S.useReducer((Z,we)=>typeof we=="number"?{row:we,at:-1}:we,{row:0,at:-1}),[Nn,Zn]=S.useState(!1),nn=(Z,we)=>Nn?Rt(Z):we,X=Z=>`changes-row-${Z}`,[be,Ve]=S.useState(!1),[Qe,Ht]=S.useState([]),St=S.useCallback(()=>{Ve(!1),Ht([])},[]),bn=S.useCallback(Z=>{Ve(!0),Ht(we=>we.includes(Z)?we.filter(Ze=>Ze!==Z):[...we,Z])},[]),P=S.useMemo(()=>I.filter(Z=>Qe.includes(Z.path)).map(Z=>Z.path),[I,Qe]);at([I],()=>Ht(Z=>{const we=Z.filter(Ze=>I.some(qt=>qt.path===Ze));return we.length===Z.length?Z:we})),at([be],()=>{if(!be)return;const Z=we=>we.key==="Escape"&&St();return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)}),at([u,Te],()=>{Qt(0),St()});const ne=y==null?void 0:y.head,Se=S.useRef("");S.useEffect(()=>{if(!(de||pe)||!u)return;const Z=`${u}:${ne??""}`;Se.current!==Z&&(Se.current=Z,r==null||r.send({t:"git-log",worktreeId:u}))},[de,pe,u,ne,r]);const Ge=S.useCallback(Z=>{Ee(we=>we===Z?null:Z),u&&!Re[Z]&&(r==null||r.send({t:"git-commit",worktreeId:u,sha:Z}))},[u,Re,r]);at([Et,er,Nn],()=>{var Z,we;Nn&&((we=(Z=Ut.current)==null?void 0:Z.querySelector('[data-state~="cursor"]'))==null||we.scrollIntoView({block:"nearest"}))});const It=S.useRef(-1),Pt=Z=>Z>=Y&&Z<ie?z:void 0,De=Z=>{var we;return((we=zt[Z])==null?void 0:we.path)===w&&(_??void 0)===Pt(Z)&&(Z<Y?v===gt:!v)};It.current=je?zt.findIndex((Z,we)=>De(we)):-1,S.useEffect(()=>{if(!g)return;const Z=te.current==="files";It.current>=0&&Qt(It.current);const we=requestAnimationFrame(()=>{var Ze;return(Ze=(Z?ve:Ut).current)==null?void 0:Ze.focus()});return()=>cancelAnimationFrame(we)},[g]);const ze=S.useCallback((Z,we=!1)=>{const Ze=zt[Z];Ze&&(Qt(Z),Ue(Ze.path,we,Z>=Y&&Z<ie?z:void 0),cn(Ze.path,!0))},[zt,Ue,cn,Y,ie,z]),Ke=S.useCallback((Z,we=!1)=>{const Ze=We.current;u&&Ze&&Rn({dispatch:o},{worktreeId:u,path:Z,ref:Ze,focus:we})},[u,r,o]),Vt=S.useCallback(Z=>{const we=pt[Z-xt];we&&(Qt(Z),we.file&&Ke(we.file.path))},[pt,xt,Ke]),Yt=S.useCallback(Z=>{const we=pt[Z-xt];we&&(Qt(Z),we.file?Ke(we.file.path,!0):Ge(we.commit.sha))},[pt,xt,Ke,Ge]),yn=Z=>de&&Z>=xt,_t=Z=>{if(w===null)return!1;if(je&&Z<zt.length)return De(Z);const we=yn(Z)?pt[Z-xt]:void 0;return!!(we!=null&&we.file)&&v===we.commit.sha&&we.file.path===w},gn=Z=>_t(Z)&&!U?le:Cx,xn=er<gn(Et).length?er:-1,Rt=Z=>Nn&&Et===Z&&xn<0,Mn=()=>{var we,Ze;const Z=[];for(let qt=0;qt<un;qt++){const wt=yn(qt)?pt[qt-xt]:void 0,dn=wt?(we=wt.file)==null?void 0:we.path:(Ze=zt[qt])==null?void 0:Ze.path,ir=wt!=null&&wt.file?1:0,mr=gn(qt);wt&&!wt.file?Z.push({row:qt,at:-1,depth:ir,open:wt.commit.sha===ge}):dn!==void 0&&rh(dn)?Z.push({row:qt,at:-1,depth:ir,open:mr.length>0}):Z.push({row:qt,at:-1,depth:ir});for(let ar=0;ar<mr.length;ar++)Z.push({row:qt,at:ar,depth:ir+1})}return Z},rn=(Z,we=!1)=>{const Ze=le[Z];!Ze||!u||w===null||Rn({dispatch:o},{worktreeId:u,path:w,ref:v??void 0,since:_??void 0,line:{n:Ze.line},focus:we})},cr=Z=>gn(Z).length>0&&d.jsx(P5,{tests:le,id:X(Z),cursor:Nn&&Et===Z?xn:-1,onPick:we=>{Qt({row:Z,at:we}),rn(we)}}),se=Z=>{var we;if(be&&Z.key==="Escape")Z.preventDefault(),Z.stopPropagation(),St();else if(be&&Z.key===" "){Z.preventDefault();const Ze=je&&Et<I.length?I[Et]:void 0;Ze&&bn(Ze.path)}else if(Z.key==="ArrowDown"&&xn+1<gn(Et).length)Z.preventDefault(),Qt({row:Et,at:xn+1}),rn(xn+1);else if(Z.key==="ArrowUp"&&xn>=0)Z.preventDefault(),xn===0?Qt(Et):(Qt({row:Et,at:xn-1}),rn(xn-1));else if(Z.key==="Enter"&&xn>=0)Z.preventDefault(),rn(xn,!0);else if(Z.key==="ArrowDown"||Z.key==="ArrowUp"){Z.preventDefault();const Ze=Hu(Et,Z.key==="ArrowDown"?1:-1,un);yn(Ze)?Vt(Ze):ze(Ze)}else if(Z.key==="Enter")Z.preventDefault(),yn(Et)?Yt(Et):ze(Et,!0);else if(Z.key==="ArrowRight"||Z.key==="ArrowLeft"){Z.preventDefault();const Ze=Mn(),qt=Vh(Ze,Ze.findIndex(ir=>ir.row===Et&&ir.at===xn),Z.key),wt=qt&&Ze[qt.at];if(!qt||!wt)return;const dn=yn(wt.row)?pt[wt.row-xt]:void 0;qt.do==="to"?wt.at>=0?(Qt({row:wt.row,at:wt.at}),rn(wt.at)):dn!=null&&dn.file&&wt.row>Et?Vt(wt.row):Qt(wt.row):dn&&!dn.file?Ge(dn.commit.sha):qt.do==="close"?$(!0):_t(wt.row)?$(!1):dn!=null&&dn.file?Vt(wt.row):ze(wt.row)}else Z.key==="Escape"&&(Z.stopPropagation(),w!==null?o({a:"close-editor"}):(we=document.activeElement)==null||we.blur())},Ne=c?c.id:h==null?void 0:h.worktree.id,rt=c?c.path:h?h.worktree.path:"",yt=c!==null,jt=S.useMemo(()=>Ne?(Z,we)=>Su(we,{kind:"paths",worktreeId:Ne,items:[{path:Z,folder:!1}]}):void 0,[Ne]),Ln=S.useRef(P);Ln.current=P;const Or=S.useMemo(()=>Ne?(Z,we)=>{const Ze=Ln.current;if(!Ze.includes(Z))return jt==null?void 0:jt(Z,we);Su(we,{kind:"paths",worktreeId:Ne,items:Ze.map(qt=>({path:qt,folder:!1}))})}:void 0,[Ne,jt]),Gn=S.useCallback(()=>Ku(s),[s]),Xt=S.useCallback(Z=>Ne?Os({id:Ne,dir:rt},Z,{discard:!yt,kept:yt,ref:gt??void 0,select:yt?void 0:bn},{sock:r,dispatch:o}):[],[Ne,rt,yt,gt,bn,r,o]),Qr=S.useCallback(Z=>Ne?Os({id:Ne,dir:rt},Z,{kept:yt},{sock:r,dispatch:o}):[],[Ne,rt,yt,r,o]),ft=S.useCallback(Z=>Ne?Os({id:Ne,dir:rt},Z,{kept:yt,since:z},{sock:r,dispatch:o}):[],[Ne,rt,yt,z,r,o]),Un=S.useCallback(Z=>Ne?Os({id:Ne,dir:rt},Z,{ref:We.current??void 0,kept:yt},{sock:r,dispatch:o}):[],[Ne,rt,yt,r,o]),ot=vn("changes"),$e=()=>{if(je&&Et<zt.length){const we=zt[Et];return we?(Et<Y?Xt:Et<ie?ft:Qr)(we.path):[]}const Z=yn(Et)?pt[Et-xt]:void 0;return Z?Z.file?Un(Z.file.path):DN(Z.commit):[]},qe=(Z,we)=>{const Ze=zt.findIndex((qt,wt)=>wt>=Z&&qt.path===we);Qt(Ze),De(Ze)&&le.length>0?$(qt=>!qt):Ue(we,!1,Pt(Ze))},kt=S.useRef(qe);kt.current=qe;const ut=S.useCallback(Z=>kt.current(0,Z),[]),fn=S.useCallback(Z=>kt.current(Y,Z),[Y]),Wt=S.useCallback(Z=>kt.current(ie,Z),[ie]),sn=S.useCallback(Z=>{Qt(xt+pt.findIndex(we=>!we.file&&we.commit.sha===Z)),Ge(Z)},[pt,xt,Ge]),tr=S.useCallback(Z=>{Qt(xt+pt.findIndex(we=>{var Ze;return((Ze=we.file)==null?void 0:Ze.path)===Z})),Z===w&&v===We.current&&le.length>0?$(we=>!we):Ke(Z)},[pt,xt,Ke,w,v,le]),An=S.useCallback(()=>{},[]);return d.jsxs("div",{className:Be("changes-dock",n&&"changes-screen",!n&&(!f||m)&&"collapsed"),style:n?void 0:{width:e},children:[!c&&d.jsx(Wu,{fill:!n,quiet:n,owner:"changes-tabs",label:"changes panel",items:[{id:"files",label:d.jsx(ht,{name:"folder",className:"icon-inline"}),fit:!0,ariaLabel:"files",tip:Ft("files",Bt("files"))},{id:"changes",label:"changes",tip:Ft("changes",Bt("changes"),{detail:fe})},{id:"history",label:"history"}],current:Te,onPick:J}),Te==="files"&&u?d.jsx($5,{worktreeId:u,dir:h?h.worktree.path:(ce==null?void 0:ce.path)??"",openPath:w,openRef:v,rootRef:ve}):d.jsxs("div",{className:Be("changes-list",de&&"history"),role:"listbox","aria-label":c?"kept work":de?"commits":"changed files","aria-activedescendant":Nn&&Et>=0&&Et<un?xn<0?X(Et):`${X(Et)}-t${xn}`:void 0,tabIndex:0,ref:Ut,onKeyDown:se,onFocus:()=>Zn(!0),onMouseDown:Z=>{var qt;if(Z.button!==0)return;Z.preventDefault();const we=Z.target.closest($x),Ze=we?Array.from(Z.currentTarget.querySelectorAll($x)).indexOf(we):-1;Ze>=0&&Qt(Ze),(qt=Ut.current)==null||qt.focus()},onBlur:Z=>!Z.currentTarget.contains(Z.relatedTarget)&&Zn(!1),...ot.contextMenu(Z=>Z==="keyboard"?$e():[]),children:[je&&I.length>0&&d.jsxs(d.Fragment,{children:[(x||((y==null?void 0:y.ahead)??0)>0||c)&&d.jsx("div",{className:"section-title section-row",children:"uncommitted"}),I.map((Z,we)=>d.jsxs(S.Fragment,{children:[q>0&&we===A&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(kf,{f:Z,id:X(we),active:nn(we,_t(we)),selected:Rt(we),checking:be,checked:Qe.includes(Z.path),onOpen:ut,onCheck:yt?void 0:bn,menu:Xt,onHover:cn,onDragStart:Or,onDragEnd:Gn}),cr(we)]},`${Z.xy}:${Z.path}`))]}),je&&!c&&T&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":j,"data-tip":"What changed since your last message","data-tip-placement":"follow",onClick:()=>o({a:"toggle-turn"}),onKeyDown:Z=>(Z.key==="Enter"||Z.key===" ")&&Z.stopPropagation(),children:["last turn",d.jsx(ht,{name:"caret",className:Be("icon-inline disc-caret",!j&&"shut")})]}),M.map((Z,we)=>d.jsxs(S.Fragment,{children:[W>0&&we===O&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(kf,{f:Z,id:X(Y+we),active:nn(Y+we,_t(Y+we)),selected:Rt(Y+we),onOpen:fn,menu:ft,onHover:cn,onDragStart:jt,onDragEnd:Gn}),cr(Y+we)]},`t-${Z.path}`))]}),je&&!c&&x&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":N,"data-tip":`Committed on this branch, not yet on ${ae}`,"data-tip-placement":"follow",onClick:()=>o({a:"toggle-committed"}),onKeyDown:Z=>(Z.key==="Enter"||Z.key===" ")&&Z.stopPropagation(),children:["committed",d.jsx(ht,{name:"caret",className:Be("icon-inline disc-caret",!N&&"shut")})]}),B.map((Z,we)=>d.jsxs(S.Fragment,{children:[V>0&&we===H&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(kf,{f:Z,id:X(ie+we),active:nn(ie+we,_t(ie+we)),selected:Rt(ie+we),onOpen:Wt,menu:Qr,onHover:cn,onDragStart:jt,onDragEnd:Gn}),cr(ie+we)]},`c-${Z.path}`))]}),je&&!c&&pe&&d.jsx("div",{className:"empty",children:W5(ae,!!ce&&bh(ce),(y==null?void 0:y.behind)??0,xe==null?void 0:xe[0])}),de&&pt.map((Z,we)=>d.jsxs(S.Fragment,{children:[c&&Ct.has(we)&&d.jsx("div",{className:"section-title section-row",children:Ct.get(we)}),!c&&At>0&&we===0&&d.jsx("div",{className:"section-title section-row",children:"on this branch"}),!c&&At>0&&we===Kt&&d.jsx("div",{className:"section-title section-row",children:ae}),Z.file?d.jsxs(d.Fragment,{children:[d.jsx(kf,{f:Z.file,id:X(xt+we),active:nn(xt+we,_t(xt+we)),selected:Rt(xt+we),onOpen:tr,menu:Un,onHover:An,onDragStart:jt,onDragEnd:Gn}),cr(xt+we)]}):d.jsx(S5,{c:Z.commit,id:X(xt+we),selected:Rt(xt+we),onToggle:sn})]},Z.file?`${Z.commit.sha}:${Z.file.path}`:Z.commit.sha)),de&&xe===void 0&&d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"reading history"})}),de&&(xe==null?void 0:xe.length)===0&&I.length===0&&d.jsx("div",{className:"empty",children:"no commits yet"})]}),be&&d.jsxs("div",{className:"changes-pick",children:[d.jsxs(Me,{size:"md",tone:"danger",disabled:P.length===0,"data-tip":"Throw away the uncommitted changes to every checked file",onClick:()=>{!Ne||P.length===0||window.confirm(Q_(P))&&(r==null||r.send({t:"discard-files",worktreeId:Ne,paths:P}),St())},children:["discard ",P.length,"…"]}),d.jsx(Me,{size:"md",disabled:P.length===0,"data-tip":"Name every checked file in the chat",onClick:()=>{Ne&&p3(s,Ne,P),St()},children:"add to chat"}),d.jsx(Lt,{icon:"close",label:"Cancel",hint:"esc",onClick:St})]}),ce&&!c&&d.jsx(E5,{active:ce,ahead:(y==null?void 0:y.ahead)??ce.ahead??0,behind:(y==null?void 0:y.behind)??ce.behind??0,unpushed:(y==null?void 0:y.unpushed)??ce.unpushed??0,dirty:!re})]})}function K5(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 Ax(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 qu(e){return e>0&&e<.005?"<$0.01":`$${e.toFixed(2)}`}function q5(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 Z5(e){if(!(e<.5))return e<.8?"worth compacting between tasks":"compact before the next task"}const lT=["five_hour","seven_day","seven_day_overage_included"],G5={five_hour:"the 5-hour window",seven_day:"the week",seven_day_overage_included:"the Fable week"},V5={five_hour:"5-hour",seven_day:"this week",seven_day_overage_included:"Fable week"};function cT(e,t){return lT.flatMap(n=>{const r=e.windows[n];return r&&r.resetsAt>t?[{key:n,used:r.used,resetsAt:r.resetsAt}]:[]})}function Y5(e,t){return Math.min(1,Math.max(0,...cT(e,t).map(n=>n.used)))}const X5=e=>`${Math.round(100*e)}%`;function Ix(e,t){const n=cT(e,t).map(r=>`${X5(r.used)} of ${G5[r.key]}`);return n.length?n.join(", "):"plan windows reset"}function Q5(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 J5(e,t,n=r=>Q5(r,t)){return lT.flatMap(r=>{const o=e.windows[r];if(!o)return[];const s=V5[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":e.binding===r&&e.status==="allowed_warning"?", nearly out":"";return[{key:r,name:s,used:o.used,sub:`resets ${n(o.resetsAt)}${a}`}]})}function eF(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 uT(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(qu(e.cost)),t.push(fr(e.archivedAt)),t.filter(Boolean).join(" · ")}function dT({sock:e},t,n){e==null||e.send({t:"restore-worktree",archiveId:t,clientId:n})}function Mf(e,t,{sock:n,dispatch:r}){const o=[{id:"restore",label:"restore",disabled:e.restorable?void 0:"its commits were not kept",onClick:()=>{dT({sock:n},e.id,t.clientId),r({a:"close"})}}],s=[{id:"copy-branch",label:"copy branch name",onClick:()=>tn(e.branch)}];s.push(...Bo(()=>n==null?void 0:n.send({t:"reveal-transcript",worktreeId:e.id}),fo(n),"reveal transcript in Finder"));const{sessionId:a}=e;return t.frame!=="phone"&&a&&s.push({id:"copy-session",label:"copy session id",onClick:()=>tn(a)}),Bn([o,s,[{id:"delete",label:"delete…",danger:!0,onClick:()=>{window.confirm(`Delete "${e.title}"?
132
-
133
- 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 tF=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function fT(e){const[t,n]=S.useState(()=>Date.now());return S.useEffect(()=>{const r=setInterval(()=>n(Date.now()),6e4);return()=>clearInterval(r)},[]),`${Ew(t-e)} ago`}function Nr({icon:e,word:t,tone:n,at:r,below:o,children:s,...a}){const c=r!==void 0?{"data-tip":`${t} ${tF.format(r)}`,"data-tip-placement":"top"}:null,u=(Array.isArray(o)?o:[o]).filter(h=>h!=null&&h!==!1);return d.jsx("div",{...a,className:"daemon-row row-edge","data-tone":n,children:d.jsxs("div",{className:"daemon-head",children:[d.jsxs("span",{...c,className:"daemon-tag",children:[d.jsx(ht,{name:e,className:"icon-inline"}),t]}),d.jsxs("div",{className:"daemon-body",children:[d.jsx("div",{className:"daemon-line",children:s}),u.map((h,f)=>d.jsx("div",{className:"daemon-below row-dim",children:h},f))]})]})})}function nF({item:e}){const t=Je(),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 ${qu(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=fT(e.archivedAt),c=Qw(e.lands);return d.jsxs(Nr,{icon:"archive",word:"archived",tone:"quiet",at:e.archivedAt,below:[...c,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:()=>dT({sock:t},e.id,n),children:"restore"})]})}function ya(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 rF(e){let t=0;return e.map(n=>{const r={start:t,len:n};return t+=n,r})}function oF(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 Rx(e,t,n){let r=0,o=e.length-1;for(;r<o;){const a=r+o>>1,c=e[a];(n?t>c.start+c.len:t>=c.start+c.len)?r=a+1:o=a}const s=e[r];return{i:r,at:t-s.start}}function sF(e,t){return{from:Rx(e,t.start,!1),to:Rx(e,t.end,!0)}}function Ox(e,t){if(e.length===0)return-1;const n=e.findIndex(r=>r.start>=t);return n===-1?0:n}function iF(e,t,n){return t===0?-1:(e+n+t)%t}function ry(e){return e.key==="f"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function aF({label:e,query:t,onQuery:n,seed:r,seq:o,status:s,none:a,onStep:c,onClose:u}){const h=S.useRef(null);return at([o],()=>{var f,m;r&&n(r),(f=h.current)==null||f.focus(),(m=h.current)==null||m.select()}),d.jsxs("div",{className:"find",children:[d.jsx(zo,{ref:h,autoFocus:!0,value:t,onChange:f=>n(f.target.value),placeholder:"find…","aria-label":e,className:"find-field",spellCheck:!1,onKeyDown:f=>{if(f.key==="Escape"){f.preventDefault(),f.stopPropagation(),u();return}if(f.key==="Enter"){f.preventDefault(),c(f.shiftKey?-1:1);return}if(ry(f)){f.preventDefault(),f.stopPropagation(),f.currentTarget.select();return}f.key.toLowerCase()==="g"&&(f.metaKey||f.ctrlKey)&&!f.altKey&&(f.preventDefault(),f.stopPropagation(),c(f.shiftKey?-1:1))}}),d.jsx("span",{className:"find-count","aria-live":"polite",children:s}),d.jsx(Lt,{icon:"caret",label:"Previous match",hint:"⇧↩",className:"find-prev",disabled:a,onClick:()=>c(-1)}),d.jsx(Lt,{icon:"caret",label:"Next match",hint:"↩",disabled:a,onClick:()=>c(1)}),d.jsx(Lt,{icon:"close",label:"Close",hint:"esc",onClick:u})]})}const hT="find",pT="find-current",mT=typeof CSS<"u"&&"highlights"in CSS;function lF(e){const t=e.parentElement;return t?typeof t.checkVisibility=="function"?t.checkVisibility():!0:!1}function cF(e,t){const n=e instanceof Element?e:e.parentElement;return!!(n!=null&&n.closest(t))}function uF(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&&lF(s)&&r.push(s)}return r}const uk={matches:[],ranges:[]};function dF(e,t,n){if(!t)return uk;const r=uF(e,n),o=oF(r.map(c=>c.data).join(""),t),s=rF(r.map(c=>c.data.length)),a=o.map(c=>{const{from:u,to:h}=sF(s,c),f=document.createRange();return f.setStart(r[u.i],u.at),f.setEnd(r[h.i],h.at),f});return{matches:o,ranges:a}}function fF(e,t){mT&&(CSS.highlights.set(hT,new Highlight(...e.filter((n,r)=>r!==t))),CSS.highlights.set(pT,new Highlight(...e[t]?[e[t]]:[])))}function hF(){mT&&(CSS.highlights.delete(hT),CSS.highlights.delete(pT))}function pF(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 Mx=48;function mF(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=parseFloat(getComputedStyle(e).getPropertyValue("--scroll-foot"))||0;n.top>=r.top+Mx&&n.bottom<=r.bottom-o-Mx||(e.scrollTop+=n.top-r.top-r.height/3)}function gT({root:e,body:t,seed:n,seq:r,onClose:o,onReveal:s,skip:a}){const[c,u]=S.useState(n),[h,f]=S.useState(uk),[m,g]=S.useState(-1),y=S.useRef({found:uk,at:-1}),w=S.useRef(""),v=S.useRef(!1),[_,x]=S.useState(0);S.useLayoutEffect(()=>{const C=t.current;if(!C)return;let I=0;const A=new MutationObserver(M=>{a&&M.every(O=>cF(O.target,a))||I||(I=requestAnimationFrame(()=>{I=0,x(O=>O+1)}))});return A.observe(C,{childList:!0,characterData:!0,subtree:!0,attributes:!0}),()=>{A.disconnect(),I&&cancelAnimationFrame(I)}},[t,a]),S.useLayoutEffect(()=>{const C=t.current;if(!C)return;const I=dF(C,c,a),A=c!==w.current;w.current=c,A&&(v.current=!0);const{found:M,at:O}=y.current;let z;A?M.matches[O]?z=Ox(I.matches,M.matches[O].start):z=e.current?pF(I.ranges,e.current):Ox(I.matches,0):z=Math.min(O,I.matches.length-1),y.current={found:I,at:z},f(I),g(z)},[c,_,a]),S.useLayoutEffect(()=>{fF(h.ranges,m);const C=h.ranges[m];C&&(v.current&&e.current&&(mF(e.current,C),s==null||s()),v.current=!1)},[h,m,e,s]),S.useLayoutEffect(()=>hF,[]);const N=h.matches.length,T=C=>{if(N===0)return;v.current=!0;const I=iF(y.current.at,N,C);y.current={...y.current,at:I},g(I)},j=()=>o(h.ranges[m]??null);return d.jsx(aF,{label:"find in this document",query:c,onQuery:u,seed:n,seq:r,status:c?N===0?"no matches":`${m+1}/${N}`:"",none:N===0,onStep:T,onClose:j})}function kT(e){return e.key==="a"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function wT(e,t,n,r,o){S.useEffect(()=>{let s=!1;const a=u=>{const h=u.target instanceof Element?u.target:null;s=!!e.current&&!!h&&e.current.contains(h)&&!(o&&h.closest(o))},c=u=>{const h=e.current;if(!h||u.defaultPrevented||!t(u))return;const f=document.activeElement;o&&(f!=null&&f.closest(o))||!(f&&f!==document.body?h.contains(f):s)&&!(r!=null&&r(f))||(u.preventDefault(),n(h,u))};return window.addEventListener("pointerdown",a,!0),window.addEventListener("keydown",c),()=>{window.removeEventListener("pointerdown",a,!0),window.removeEventListener("keydown",c)}},[e,t,n,r,o])}function gF(e,t){const n=S.useCallback(r=>{var o;return yT(r,(o=t==null?void 0:t.upTo)==null?void 0:o.call(t,r))},[t]);wT(e,kT,n,void 0,t==null?void 0:t.except)}function dk(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 yT(e,t){const n=document.createRange();n.selectNodeContents(e),t&&n.setEndBefore(t);const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(n))}function kF(e){return e.shiftKey||e.altKey||e.metaKey||e.ctrlKey?null:e.key==="ArrowLeft"?-1:e.key==="ArrowRight"?1:null}function wF(e,t,n){const r=e+n;return r<0||r>=t?null:r}const vT=S.createContext(null),yF="input, textarea, [contenteditable]";function Lx(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 Qh({children:e}){const t=S.useRef(new Map),[n,r]=S.useState(null),o=S.useRef(n);o.current=n;const s=S.useMemo(()=>{const c=u=>{const h=Lx(t.current),f=h.findIndex(m=>m.id===u);r(f<0?null:{id:u,at:f,of:h.length})};return{register(u){return t.current.set(u.id,u),()=>{var h;t.current.delete(u.id),((h=o.current)==null?void 0:h.id)===u.id&&r(null)}},open:c,step(u){const h=o.current;if(!h)return;const f=Lx(t.current),m=f.findIndex(w=>w.id===h.id),g=m<0?null:wF(m,f.length,u),y=g===null?void 0:f[g];y&&c(y.id)},close(){var f,m,g;const u=o.current;if(r(null),!u)return;const h=document.activeElement;h!=null&&h.matches(yF)||(g=(m=(f=t.current.get(u.id))==null?void 0:f.el())==null?void 0:m.querySelector(".chip-link"))==null||g.focus({preventScroll:!0})}}},[]),a=S.useMemo(()=>({api:s,shown:n}),[s,n]);return d.jsx(vT.Provider,{value:a,children:e})}function vF(e,t){const n=S.useContext(vT),r=S.useId(),[o,s]=S.useState(!1),a=n==null?void 0:n.api;if(S.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 c=(n==null?void 0:n.shown)??null,u=(c==null?void 0:c.id)===r;return{open:u,show:()=>a.open(r),close:a.close,nav:u&&c?{at:c.at,of:c.of,step:a.step}:void 0}}function fk(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 bT(e,t,n){const r=h=>e.map((f,m)=>h(f)&&f.id!==t?m:-1).filter(f=>f>=0),s=[()=>r(h=>h.agent==="waiting"),()=>r(h=>!!h.unseen),()=>r(h=>h.agent==="working")].reduce((h,f)=>h.length>0?h:f(),[]),a=e.findIndex(h=>h.id===t),c=n>0?s.find(h=>h>a)??s[0]:s.findLast(h=>h<a)??s[s.length-1],u=c===void 0?void 0:e[c];return u?{activate:u.id}:null}function oy(e,t,n){const r=bT(e,t,n);if(r)return r;const o=e[0];return o&&o.id!==t?{activate:o.id}:null}function bF(e,t,n){const r=[fk(e,t),...n.map(o=>fk(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 xF(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=bT(e,t,1);return a&&{origin:null,activate:a.activate}}for(const a of n){const c=a.rows.find(s);if(c)return{origin:a.origin,activate:c.id}}}const o=oy(e,t,1);return o&&{origin:null,activate:o.activate}}function xT(e,{sock:t,dispatch:n}){var m,g;const r=y=>y?"hide":"show",o=e.repos.some(y=>y.id===e.activeRepoId),s=(m=Gt(e,e.activeId))==null?void 0:m.worktree.id,a=[];o&&(a.push({id:"new",label:"new worktree…",key:Bt("new"),onClick:()=>n({a:"open-draft"})}),a.push({id:"refs",label:"open a branch or PR…",key:Bt("refs"),onClick:()=>n({a:"open",overlay:{kind:"refs"}})})),s&&(a.push({id:"jump",label:"jump to file…",key:Bt("quick-open"),onClick:()=>n({a:"open",overlay:{kind:"quick-open"}})}),a.push({id:"search",label:"search in files…",key:Bt("search"),onClick:()=>n({a:"open",overlay:{kind:"search"}})})),wu(e)&&a.push({id:"routes",label:"go to page…",key:Bt("routes"),onClick:()=>n({a:"open",overlay:{kind:"routes"}})}),o&&a.push({id:"chats",label:"search chats…",key:Bt("chats"),onClick:()=>n({a:"open",overlay:{kind:"chats"}})});const c=oy(e.visible,e.activeId,1);c&&a.push({id:"wt-unseen-next",label:"next that needs you",key:Bt("wt-unseen-next"),onClick:()=>n({a:"activate",id:c.activate})}),a.push({id:"project",label:e.repos.length>1?"switch project…":"open project…",key:Bt("project"),onClick:()=>n({a:"open",overlay:{kind:"projects",form:"center"}})});const u=[{id:"changes",label:`${r(e.layout.changes)} changes panel`,key:Bt("changes"),onClick:()=>n({a:"toggle-changes"})},{id:"files",label:`${r(e.layout.changes&&Kl(e)==="files")} files`,key:Bt("files"),onClick:()=>n(e.layout.changes&&Kl(e)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"})},{id:"chat",label:`${r(e.layout.chat)} chat panel`,key:Bt("composer"),onClick:()=>n({a:"toggle-chat"})},{id:"terminal",label:`${r(e.layout.term)} terminal`,key:Bt("terminal"),onClick:()=>n({a:"toggle-terminal"})},{id:"rail",label:`${r(e.railOpen)} worktree panel`,key:Bt("rail"),onClick:()=>n({a:"toggle-rail"})},{id:"design",label:`${r(e.layout.design)} design system`,key:Bt("design"),onClick:()=>n({a:"toggle-design"})},{id:"zen",label:"full-bleed preview",key:Bt("zen"),onClick:()=>n({a:"toggle-zen"})}],h=[{id:"commands",label:"command palette",key:Bt("commands"),onClick:()=>n({a:"open",overlay:{kind:"commands"}})},{id:"keys",label:"settings & shortcuts",key:Bt("keys"),onClick:()=>n({a:"open",overlay:{kind:"keys"}})}];(g=e.self)!=null&&g.restart&&h.push({id:"restart-daemon",label:"restart Toyon",onClick:()=>t==null?void 0:t.send({t:"restart-daemon"})}),h.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 f=ns(e)?new Set(["chat","design","zen"]):null;return Bn([a,f?u.filter(y=>!f.has(y.id)):u,h])}function hk(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}?
134
-
135
- 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 Bn([o,s])}function sy(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 ET(e,{sock:t}){return[{id:"restart:shell",label:"restart shell",onClick:()=>t==null?void 0:t.send({t:"term-restart",worktreeId:e,stream:Do})}]}function EF(e,t,n,r){return Bn([[...e.flatMap(o=>sy(o,t,r)),...ET(t,r)],[{id:"terminal",label:`${n?"hide":"show"} terminal`,onClick:()=>r.dispatch({a:"toggle-terminal"})}]])}function Tu({sock:e,dispatch:t},n){t({a:"open-repo"}),e==null||e.send(n)}function ST(e,t){const{parent:n,name:r}=ay(t);Tu(e,{t:"create-repo",mode:"init",parent:n,name:r})}function SF(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 Jh(e,t,{sock:n,dispatch:r},o){const s=o.filter(u=>Sn(u)&&u.worktree.repoId===e.id&&vh(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 c=[{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(_F(e.name,s))&&(n==null||n.send({t:"forget-repo",repoId:e.id}))}}];return Bn([a,c])}function _F(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}?
136
-
137
- ${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 oh={dark:"dark",light:"light",system:"follow system",daylight:"follow daylight"},sh={use:"while in use",always:"always",off:"off"};function NF(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 _T(e,{sock:t,dispatch:n}){var a;const r=e.themePrefs,o=c=>{var u;return((u=e.themes.find(h=>h.id===c))==null?void 0:u.name)??c},s=Hz();return Bn([[{id:"theme",label:"theme…",detail:Rh(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:oh[r.mode],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"appearance"}})}],[{id:"agent",label:"default agent…",detail:((a=e.agents.find(c=>c.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:()=>Wz(!s.on)}]],...e.keepAwake===null?[]:[[{id:"keep-awake",label:"keep awake…",detail:sh[e.keepAwake],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"keep-awake"}})}]],[{id:"theme-import",topic:"theme",label:"import a VS Code theme…",onClick:()=>NF((c,u)=>t==null?void 0:t.send({t:"import-theme",name:c,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 TF(e,t,n,r,o,s={machines:[],switchTo:()=>{},forget:()=>{}}){const a=[],c=(g,y,w,v,_)=>a.push({id:g,label:y,hint:v,run:w,sub:_}),u=(g,y)=>{for(const w of g){if(!hs(w)||w.disabled!==void 0||w.checked)continue;const v=w.key??(typeof w.detail=="string"?w.detail:void 0),_=y?`${y.scope}:${w.id}`:w.id,x=w.topic?`${w.topic}: ${w.label}`:w.label;c(_,y?`${x} · ${y.name}`:x,w.onClick,v,w.sub)}},h={sock:n,dispatch:t},f=r,m=f==null?void 0:f.worktree.id;if(u(xT(e,h).filter(g=>!hs(g)||g.id!=="commands")),o&&u(Jh(o,o.id,h,e.rows),{scope:"project",name:o.name}),m&&!ns(e)){c("pick",e.picking==="chat"?"cancel element picker":"pick an element for the chat",()=>Eu(m,e.picking,t,"chat"),Bt("pick")),c("inspect",e.picking==="code"?"cancel element picker":"pick an element to open its code",()=>Eu(m,e.picking,t,"code"),Bt("inspect"));const g=qg(e);(g==null?void 0:g.act)==="start"?c("reload","start the preview",()=>n==null?void 0:n.send({t:"preview-start",worktreeId:g.id})):c("reload","reload preview",()=>an.post(m,{type:"reload"}))}if(u(_T(e,h)),f&&m){const g=e.repos.find(y=>y.id===f.worktree.repoId)??null;u(ZN(f,g,e,h,{hostname:e.hostname,palette:!0}),{scope:"wt",name:Hg(f,g)});for(const y of f.procs)u(sy(y,m,h))}e.visible.forEach((g,y)=>{var _;if(g.worktree.id===m)return;const v=!!e.activeRepoId&&g.repoId!==e.activeRepoId?` in ${((_=e.repos.find(x=>x.id===g.repoId))==null?void 0:_.name)??g.repoId}`:"";c(`go:${g.worktree.id}`,`switch to ${Hg(g,o)}${v}`,()=>t({a:"activate",id:g.worktree.id}),OA(y,e.visible.length))});for(const g of e.repos)g.id!==(o==null?void 0:o.id)&&c(`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)c(`machine:${g.origin}:${y.id}`,`switch to project ${y.name} on ${g.name}`,()=>s.switchTo(g.origin,y.id));c(`forget-machine:${g.origin}`,`forget ${g.name}`,()=>s.forget(g.origin))}return a}function NT(){const e=lt(),t=Je(),{host:n}=Rr(),r=On(),o=gs(),s=$_(),a=L(U=>U.picking),c=L(U=>U.layout),u=L(U=>U.chatSide),h=L(U=>U.blackGround),f=L(U=>U.keepAwake),m=L(U=>U.railOpen),g=L(U=>U.themePrefs),y=L(U=>U.themes),w=L(U=>U.systemDark),v=L(U=>U.daylight),_=L(U=>U.rows),x=L(U=>U.visible),N=L(U=>U.activeId),T=L(U=>U.activeRepoId),j=L(U=>U.repos),C=L(U=>U.agents),I=L(U=>U.defaultAgent),A=L(U=>U.shipping),M=L(U=>U.remote),O=L(U=>U.managed),z=L(U=>U.frame),B=L(U=>U.self),H=L(U=>U.archivedPage),Y=L(U=>U.notesPage),ie=L(U=>U.archived),Q=L(U=>U.knocks),le=L(U=>U.tailscale);return S.useMemo(()=>{const U={picking:a,layout:c,chatSide:u,blackGround:h,keepAwake:f,railOpen:m,themePrefs:g,themes:y,systemDark:w,daylight:v,rows:_,visible:x,activeId:N,activeRepoId:T,repos:j,agents:C,defaultAgent:I,shipping:A,frame:z,self:B,archivedPage:H,notesPage:Y,archived:ie,knocks:Q,hostname:n,drafted:q=>Nw(r.getState(),q)},$={machines:s,switchTo:(q,V)=>{var W;(W=o.get(q))==null||W.store.dispatch({a:"activate-repo",id:V}),o.activate(q)},forget:q=>{const V=hk(o,q).find(W=>hs(W)&&W.id.startsWith("forget-machine:"));V&&hs(V)&&V.onClick()}};return TF(U,e,t,Gt(U,N),Li(U,T),$)},[a,c,u,h,f,m,g,y,w,v,_,x,N,T,j,C,I,A,M,O,z,B,H,Y,ie,Q,le,e,t,n,r,o,s])}function TT(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=[];for(const o of e){const s=pk(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 pk(e,t){const n=iy(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+(jT(e,a)?3:0),s=a;return r+Math.max(0,40-e.length/4)}const jT=(e,t)=>t===0||/[\s:\-–—·/.(]/.test(e[t-1]);function iy(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 c=n.indexOf(s,o);c!==-1;c=n.indexOf(s,c+1))if(jT(n,c)){a=c;break}if(a===-1)return null;r.push(a),o=a+1}return r}const ts=(e,...t)=>{const n=e.trim().toLowerCase();return!n||t.some(r=>r==null?void 0:r.toLowerCase().includes(n))},ju=e=>/^(~|\/|\.\.?\/)/.test(e.trim());function ay(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 jF(e,t,n){const r=e.map(h=>h.path.slice(0,h.path.lastIndexOf("/"))).filter(Boolean),o=e.find(h=>h.id===t),s=o==null?void 0:o.path.slice(0,o.path.lastIndexOf("/")),a=new Map;for(const h of r)a.set(h,(a.get(h)??0)+1);let c="",u=0;for(const[h,f]of[...a].sort(([m],[g])=>m.localeCompare(g)))(f>u||f===u&&h===s)&&(c=h,u=f);return c?ly(c,n):`~/${_S}`}function ly(e,t){return t&&(e===t||e.startsWith(`${t}/`))?`~${e.slice(t.length)}`:e}function $T(e,t){return`${e.replace(/\/+$/,"")}/${t.trim()}`}function $F(e){const t=e.query.trim();if(e.urlOnly){const a=Cb(t);return a?[{kind:"clone",...a}]:[]}const n=()=>e.entries.map(a=>({kind:a.isFile?"file":"dir",entry:a}));if(!ju(t)){const a=e.repos.filter(g=>ts(t,g.name,g.path)).map(g=>({kind:"repo",repo:g})),c=e.pending.filter(g=>ts(t,g.name,g.url)).map(g=>({kind:"pending",pending:g})),u=[...a,...c],h=(e.others??[]).flatMap(g=>g.repos.length===0?ts(t,g.name)?[{kind:"machine",machine:g}]:[]:g.repos.filter(y=>ts(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,...c,{kind:"disk"},{kind:"new"},{kind:"from-url"},{kind:"add-machine"},...h]}const f=Cb(t);if(f)return u.length>0?u:[{kind:"clone",...f}];const m=g=>g.toLowerCase()===t.toLowerCase();return e.repos.some(g=>m(g.name))||e.pending.some(g=>m(g.name))?[...u,...h]:gu(t)?[...u,...h]:[...u,{kind:"create",name:t,parent:null},...h]}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 c=Zl(a,e.home);return c==="/"||c===e.home||e.repos.some(h=>h.path.startsWith(`${c}/`))?n():[...n(),{kind:"init",path:a}]}if(t.endsWith("/"))return n();if(!r.parentExists)return[];const{parent:o,name:s}=ay(t);return gu(s)?n():[...n(),{kind:"create",name:s,parent:o}]}function Zl(e,t){return t&&(e==="~"||e.startsWith("~/"))?`${t}${e.slice(1)}`:e}function CT(e,t){const n=Zl(e,t).replace(/\/+$/,"");return n.startsWith("/")?ly(n.slice(0,n.lastIndexOf("/"))||"/",t):null}function mk(e,t){const n=Zl(e,t).replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||"/"}function CF(e){const t=e.query.trim(),n=t.lastIndexOf("/"),r=n<0?"":t.slice(0,n)||"/",o=Zl(r,e.home);if(!ju(t)||!o.startsWith("/"))return[];const s=t.slice(n+1).toLowerCase(),a=e.answered.trim()===t?e.target:null,c=!a||(s?a.parentExists:a.exists&&a.isDir&&!a.isRepo),u=e.entries.filter(f=>{if(f.isRepo||f.isFile)return!1;const m=Zl(f.path,e.home);return(m.slice(0,m.lastIndexOf("/"))||"/")===o&&f.name.toLowerCase().startsWith(s)}),h=CT(r,e.home);return[...c?[{kind:"here",path:r}]:[],...h?[{kind:"up",path:h}]:[],...u.map(f=>({kind:"dir",entry:f}))]}const AF=e=>e.t==="open-path"||e.t==="open-loose"||e.t==="open-clone",ma=new Map,IF=16;function gk({sock:e,dispatch:t},n,r){const o=AT({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 RF(e,t){e==null||e.send({t:"open-by-path",path:t,seq:AT(null)})}function AT(e){const t=So();ma.set(t,e);for(const n of ma.keys()){if(ma.size<=IF)break;ma.delete(n)}return t}function OF(e,t){if(!ma.has(t.seq))return;const n=ma.get(t.seq);ma.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 MF(e,t,n){var s;const r=e.getState();if(n.t==="open-clone"){const{t:a,parent:c,...u}=n;e.dispatch({a:"new-project",v:Ph({mode:"clone",parent:ly(c,r.home),...u})});return}if(n.t==="open-path"){const a={dispatch:u=>e.dispatch(u)};if(To(r,n.worktreeId)){r.activeId!==n.worktreeId&&e.dispatch({a:"activate",id:n.worktreeId}),Rn(a,{worktreeId:n.worktreeId,path:n.path});return}const c=Object.keys(r.trunks).find(u=>{var h;return((h=r.trunks[u])==null?void 0:h.id)===n.worktreeId});if(!c)return;if(((s=To(r,r.activeId))==null?void 0:s.repoId)!==c){const u=r.rows.find(h=>h.repoId===c);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:So()}})}function cy({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}]:[],...Bo(o,fo(r),"reveal the copy")],s?[{id:"copy-path",label:"copy path",onClick:()=>V_(s)}]:[],t?[{id:"remove",label:"remove",onClick:t}]:[]]}function Na(e,t={},n){return Bn([[{id:"copy-image",label:"copy image",onClick:()=>n3(e)}],...cy(t,n)])}function IT({text:e,href:t}){return e!==void 0?[{id:"copy-text",label:"copy text",onClick:()=>tn(e)}]:t?[{id:"copy-text",label:"copy text",onClick:()=>V_(t)}]:[]}function LF(e,t={}){return Bn([IT(e),...cy(t)])}function PF(e,t={},n){return Bn([IT(e),...cy(t,n)])}function RT(e){return[Z_(e),{id:"copy-link",label:"copy link",onClick:()=>tn(e)}]}function ep(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 DF(e.path,n);if(!t)return null;if(e.kind==="outside")return()=>gk(n,t,e);if(e.kind==="path")return()=>gk(n,t,{href:e.path,path:e.path});if(e.kind!=="file")return null;const r=e.file;return r.folder?()=>c3(n,{worktreeId:t,path:r.path}):()=>Rn(n,{worktreeId:t,path:r.path,...r.line?{line:{n:r.line}}:{}})}function DF(e,{sock:t}){return!t||!Kh(fo(t))?null:()=>t.send({t:"reveal-path",path:e})}function zF(e,t,n){const r=e.kind==="outside"&&e.folder?null:ep(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}]:[],...Bo(s,fo(o))],[{id:"copy-path",label:"copy path",onClick:()=>tn(a)}]]}function FF(e,t){const n=ep(e,null,t);return[n?[{id:"open",label:e.archived?"open archived chat":"open chat",onClick:n}]:[],[{id:"copy-branch",label:"copy branch",onClick:()=>tn(e.branch)}]]}function kk(e){return e?[{id:"copy-code",label:"copy code",onClick:()=>tn(e)}]:[]}function gi(e,t,n,r={}){const{dispatch:o,sock:s}=n,a=r.link,c=a?a.kind==="out"?[RT(a.href)]:a.kind==="worktree"?FF(a,n):zF(a,t,n):[],u=[{id:"copy",label:"copy message",onClick:()=>tn(e.text)}],h=[];return e.kind==="user"&&t&&h.push({id:"draft",label:"edit in composer",onClick:()=>{const f=e.seq;if(f===void 0||!s)return o({a:"set-draft",id:t,text:e.text});o({a:"set-draft",id:t,text:""}),s.send({t:"redraft",worktreeId:t,seq:f})}}),Bn([kk(r.code),...c,u,h])}function OT(e,t,n){return[Bo(t,n),[{id:"copy-path",label:"copy path",onClick:()=>tn(e)}]]}function uy(e,t,n){return Bn(OT(e,t,n))}function BF(e,t){const n=e.callFile??e.file,r=n?OT(n,void 0,t.host):[],o=t.remove?[{id:"remove",label:"remove",onClick:t.remove}]:[];return Bn([...r,o])}const Px=8,UF=.7,HF=100,WF=400,KF=260,qF=80,ZF=220;function Dx({dx:e,dy:t}){return Math.abs(e)<Px&&Math.abs(t)<Px?null:Math.abs(t)>Math.abs(e)?"away":"other"}function GF(e,t){const n=e.filter(s=>t-s.t<=HF),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 VF=e=>Math.abs(e)>=UF;function YF(e,t){return Math.min(ZF,Math.max(qF,e/Math.abs(t)))}function XF(e,t,n){const r=S.useRef(n);r.current=n,S.useEffect(()=>{const o=e.current;if(!o)return;let s=null,a=!1,c=[],u=0;const h=(v,_,x)=>{x!==void 0&&o.style.setProperty("--swipe-ms",`${x}ms`),o.dataset.swipe!==_&&(o.dataset.swipe=_,o.offsetWidth),o.style.setProperty("--swipe-y",`${v}px`),o.style.setProperty("--swipe-fade",`${Math.min(1,Math.abs(v)/(window.innerHeight/2))}`)},f=()=>{o.style.removeProperty("--swipe-y"),o.style.removeProperty("--swipe-fade"),o.style.removeProperty("--swipe-ms"),delete o.dataset.swipe},m=()=>{const v=a;s=null,a=!1,c=[],v&&(h(0,"settle"),u=window.setTimeout(f,KF))},g=v=>{var N;const _=v.touches[0],x=v.target;if(v.touches.length!==1||!_||(((N=window.visualViewport)==null?void 0:N.scale)??1)>1.01)return m();o.dataset.swipe==="leave"||!(x===o||x!=null&&x.closest(t))||(window.clearTimeout(u),s={x:_.clientX,y:_.clientY,at:v.timeStamp},c=[{y:_.clientY,t:v.timeStamp}])},y=v=>{const _=v.touches[0];if(!s||!_)return;const x=_.clientX-s.x,N=_.clientY-s.y;if(!a){const T=Dx({dx:x,dy:N});if(T==="other"&&(s=null),T!=="away")return;a=!0}v.preventDefault(),c.push({y:_.clientY,t:v.timeStamp}),c.length>16&&c.shift(),h(N,"drag")},w=v=>{const _=v.changedTouches[0];if(!s||!_)return;const x=_.clientY-s.y,N=v.timeStamp-s.at;if(!a&&N<WF&&v.target!==o&&Dx({dx:_.clientX-s.x,dy:x})===null){v.preventDefault(),s=null,r.current();return}const j=GF(c,v.timeStamp);if(!a||!VF(j))return m();s=null,a=!1,c=[];const C=Math.sign(j)*window.innerHeight,I=YF(Math.abs(C-x),j);h(C,"leave",I),u=window.setTimeout(()=>r.current(),I)};return o.addEventListener("touchstart",g,{passive:!0}),o.addEventListener("touchmove",y,{passive:!1}),o.addEventListener("touchend",w),o.addEventListener("touchcancel",m),()=>{window.clearTimeout(u),o.removeEventListener("touchstart",g),o.removeEventListener("touchmove",y),o.removeEventListener("touchend",w),o.removeEventListener("touchcancel",m)}},[e,t])}function tp({owner:e,onClose:t,menu:n,nav:r,children:o}){const s=vn(e),a=S.useRef(null);return XF(a,"img",t),d.jsxs(Fs,{className:"attach-full scrim",boxRef:a,onDismiss:t,onKey:c=>{if(c.key==="Escape"){c.stopPropagation(),t();return}const u=r&&kF(c);u&&(c.preventDefault(),c.stopPropagation(),r.step(u))},onClick:c=>{c.target===c.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(Lt,{icon:"close",label:"Close",tone:"quiet",onClick:t})]})]})}function QF({item:e}){if(!e.outcome)return null;const t=H4[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 MT(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 JF=e=>e.slice(0,Math.max(0,e.lastIndexOf("/")));function LT(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("/"),c=n.slice(s.length+1).replace(/\/+$/,"");if(!c||c.split("/").some(f=>f===".."))return null;if(a)return{path:c,folder:!0};const u=(r==null?void 0:r[1])??(o==null?void 0:o[1]),h=u?Number.parseInt(u,10):void 0;return h&&h>0?{path:c,line:h}:{path:c}}function PT(e){var t;return((t=e.match(/^file:\/\/(?:localhost)?(\/.*)$/i))==null?void 0:t[1])??e}function DT(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 e8(e){return e.length<2||!e.startsWith("/")||e.startsWith("//")||/\s/.test(e)?null:e}function np(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 c=t?LT(t,a):null;if(c)return{kind:"file",file:c};const u=DT(a);return u?{kind:"outside",href:a,...u}:{kind:"out",href:a}}function dy(e,t,n,r){var s;const o=np(e.target,t);!o||o.kind==="path"||o.kind==="out"||(e.preventDefault(),(s=ep(o,n,r))==null||s())}const t8=150,n8=e=>({side:e,align:"center",offset:12,flip:"side",margin:8});function zT({chip:e,className:t,children:n}){const[r,o]=S.useState(!1),s=Bu("chat");S.useEffect(()=>{const c=e.current;if(!c)return;let u=0;const h=()=>{window.clearTimeout(u),o(!1)},f=()=>{window.clearTimeout(u),u=window.setTimeout(()=>o(!0),t8)};return c.addEventListener("mouseenter",f),c.addEventListener("mouseleave",h),c.addEventListener("mousedown",h),()=>{window.clearTimeout(u),c.removeEventListener("mouseenter",f),c.removeEventListener("mouseleave",h),c.removeEventListener("mousedown",h)}},[e]);const a=()=>{var f;const c=e.current;if(!c)return null;const u=c.getBoundingClientRect(),h=((f=c.closest(".chat-log"))==null?void 0:f.getBoundingClientRect())??u;return{left:h.left,right:h.right,top:u.top,bottom:u.bottom}};return r?d.jsx(Fs,{className:Be("chip-peek",t),anchor:a,placement:n8(s),track:!0,children:n}):null}function fy({className:e,label:t,tip:n,peek:r,full:o,menu:s,removeLabel:a,onRemove:c}){const u=S.useRef(null),h=vn("chat"),f=o!==void 0,m=vF(u,f);return d.jsxs("div",{ref:u,className:Be("pick-chip row row-sm",e),"data-tip":f?"Open full size":n,"data-tip-placement":"follow",...h.contextMenu(()=>s({open:f?m.show:void 0,remove:c})),children:[f?d.jsx("button",{type:"button",className:"chip-link",onClick:m.show,children:t}):t,c&&d.jsx(Lt,{icon:"close",label:a,tone:"quiet",onClick:c}),f&&r!==void 0&&d.jsx(zT,{chip:u,children:r}),m.open&&f&&d.jsx(tp,{owner:"chat",onClose:m.close,menu:()=>s(),nav:m.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 zx(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 r8(e){if(Array.isArray(e))return e}function o8(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,s,a,c=[],u=!0,h=!1;try{if(s=(n=n.call(e)).next,t!==0)for(;!(u=(r=s.call(n)).done)&&(c.push(r.value),c.length!==t);u=!0);}catch(f){h=!0,o=f}finally{try{if(!u&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(h)throw o}}return c}}function s8(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
138
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function i8(e,t){return r8(e)||o8(e,t)||a8(e,t)||s8()}function a8(e,t){if(e){if(typeof e=="string")return zx(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)?zx(e,t):void 0}}const FT=Object.entries,Fx=Object.setPrototypeOf,l8=Object.isFrozen,c8=Object.getPrototypeOf,u8=Object.getOwnPropertyDescriptor;let yr=Object.freeze,jr=Object.seal,Sl=Object.create,BT=typeof Reflect<"u"&&Reflect,wk=BT.apply,yk=BT.construct;yr||(yr=function(t){return t});jr||(jr=function(t){return t});wk||(wk=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)});yk||(yk=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 la=pr(Array.prototype.forEach),d8=pr(Array.prototype.lastIndexOf),Bx=pr(Array.prototype.pop),qc=pr(Array.prototype.push),f8=pr(Array.prototype.splice),Dl=Array.isArray,eu=pr(String.prototype.toLowerCase),sg=pr(String.prototype.toString),Ux=pr(String.prototype.match),Zc=pr(String.prototype.replace),Hx=pr(String.prototype.indexOf),h8=pr(String.prototype.trim),p8=pr(Number.prototype.toString),m8=pr(Boolean.prototype.toString),Wx=typeof BigInt>"u"?null:pr(BigInt.prototype.toString),Kx=typeof Symbol>"u"?null:pr(Symbol.prototype.toString),io=pr(Object.prototype.hasOwnProperty),Gc=pr(Object.prototype.toString),Br=pr(RegExp.prototype.test),ia=g8(TypeError);function pr(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 wk(e,t,r)}}function g8(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return yk(e,n)}}function mn(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:eu;if(Fx&&Fx(e,null),!Dl(t))return e;let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const s=n(o);s!==o&&(l8(t)||(t[r]=s),o=s)}e[o]=!0}return e}function k8(e){for(let t=0;t<e.length;t++)io(e,t)||(e[t]=null);return e}function xo(e){const t=Sl(null);for(const r of FT(e)){var n=i8(r,2);const o=n[0],s=n[1];io(e,o)&&(Dl(s)?t[o]=k8(s):s&&typeof s=="object"&&s.constructor===Object?t[o]=xo(s):t[o]=s)}return t}function w8(e){switch(typeof e){case"string":return e;case"number":return p8(e);case"boolean":return m8(e);case"bigint":return Wx?Wx(e):"0";case"symbol":return Kx?Kx(e):"Symbol()";case"undefined":return Gc(e);case"function":case"object":{if(e===null)return Gc(e);const t=e,n=Xo(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:Gc(r)}return Gc(e)}default:return Gc(e)}}function Xo(e,t){for(;e!==null;){const r=u8(e,t);if(r){if(r.get)return pr(r.get);if(typeof r.value=="function")return pr(r.value)}e=c8(e)}function n(){return null}return n}function y8(e){try{return Br(e,""),!0}catch{return!1}}const qx=yr(["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"]),ig=yr(["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"]),ag=yr(["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"]),v8=yr(["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"]),lg=yr(["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"]),b8=yr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Zx=yr(["#text"]),Gx=yr(["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"]),cg=yr(["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"]),Vx=yr(["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"]),yf=yr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),x8=jr(/{{[\w\W]*|^[\w\W]*}}/g),E8=jr(/<%[\w\W]*|^[\w\W]*%>/g),S8=jr(/\${[\w\W]*/g),_8=jr(/^data-[\-\w.\u00B7-\uFFFF]+$/),N8=jr(/^aria-[\-\w]+$/),Yx=jr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),T8=jr(/^(?:\w+script|data):/i),j8=jr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),$8=jr(/^html$/i),C8=jr(/^[a-z][.\w]*(-[.\w]+)+$/i),Xx=jr(/<[/\w!]/g),Qx=jr(/<[/\w]/g),A8=jr(/<\/no(script|embed|frames)/i),I8=jr(/\/>/i),bo={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},UT=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],R8=yr(mn({},UT)),O8=(function(){const e={};return la(UT,t=>{e[t]=jr(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),yr(e)})(),M8=function(){return typeof window>"u"?null:window},L8=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}},Jx=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},ki=function(t,n,r,o){return io(t,n)&&Dl(t[n])?mn(o.base?xo(o.base):{},t[n],o.transform):r},ug=function(t,n,r){const o=io(t,n)?t[n]:void 0;return o&&typeof o=="object"?xo(o):r()};function HT(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:M8();const t=Ce=>HT(Ce);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==bo.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,c=e.Element,u=e.NodeFilter,h=e.NamedNodeMap;h===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const f=e.DOMParser,m=e.trustedTypes,g=c.prototype,y=Xo(g,"cloneNode"),w=Xo(g,"remove"),v=Xo(g,"nextSibling"),_=Xo(g,"childNodes"),x=Xo(g,"parentNode"),N=Xo(g,"shadowRoot"),T=Xo(g,"attributes"),j=a&&a.prototype?Xo(a.prototype,"nodeType"):null,C=a&&a.prototype?Xo(a.prototype,"nodeName"):null,I=a&&a.prototype?Xo(a.prototype,"ownerDocument"):null,A=function(F){return j?j(F):F.nodeType},M=function(F){return C?C(F):F.nodeName};if(typeof s=="function"){const Ce=n.createElement("template");Ce.content&&Ce.content.ownerDocument&&(n=Ce.content.ownerDocument)}let O,z="",B,H=!1,Y=0;const ie=function(){if(Y>0)throw ia('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.')},Q=function(F){ie(),Y++;try{return O.createHTML(F)}finally{Y--}},le=function(F){ie(),Y++;try{return O.createScriptURL(F)}finally{Y--}},U=function(){return H||(B=L8(m,o),H=!0),B},$=n,q=$.implementation,V=$.createNodeIterator,W=$.createDocumentFragment,re=$.getElementsByTagName,fe=r.importNode;let pe=Jx();t.isSupported=typeof FT=="function"&&typeof x=="function"&&q&&q.createHTMLDocument!==void 0;const Te=x8,je=E8,de=S8,J=_8,te=N8,ve=T8,ce=j8,ae=C8;let xe=Yx,Re=null;const ge=mn({},[...qx,...ig,...ag,...lg,...Zx]);let Ee=null;const We=mn({},[...Gx,...cg,...Vx,...yf]);let Ye=Object.seal(Sl(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}})),ln=null,cn=null;const gt=Object.seal(Sl(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ue=!0,zt=!0,pt=!1,At=!0,Kt=!1,xt=!0,un=!1,Ct=!1,Ut=null,Et=null,er=!1,Qt=!1,Nn=!1,Zn=!1,nn=!0,X=!1;const be="user-content-";let Ve=!0,Qe=!1,Ht={},St=null;const bn=mn({},["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 P=null;const ne=mn({},["audio","video","img","source","image","track"]);let Se=null;const Ge=mn({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),It="http://www.w3.org/1998/Math/MathML",Pt="http://www.w3.org/2000/svg",De="http://www.w3.org/1999/xhtml";let ze=De,Ke=!1,Vt=null;const Yt=mn({},[It,Pt,De],sg),yn=yr(["mi","mo","mn","ms","mtext"]);let _t=mn({},yn);const gn=yr(["annotation-xml"]);let xn=mn({},gn);const Rt=mn({},["title","style","font","a","script"]);let Mn=null;const rn=["application/xhtml+xml","text/html"],cr="text/html";let se=null,Ne=null;const rt=n.createElement("form"),yt=function(F){return F instanceof RegExp||F instanceof Function},jt=function(){let F=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ne&&Ne===F)return;(!F||typeof F!="object")&&(F={}),F=xo(F),Mn=rn.indexOf(F.PARSER_MEDIA_TYPE)===-1?cr:F.PARSER_MEDIA_TYPE,se=Mn==="application/xhtml+xml"?sg:eu,Re=ki(F,"ALLOWED_TAGS",ge,{transform:se}),Ee=ki(F,"ALLOWED_ATTR",We,{transform:se}),Vt=ki(F,"ALLOWED_NAMESPACES",Yt,{transform:sg}),Se=ki(F,"ADD_URI_SAFE_ATTR",Ge,{transform:se,base:Ge}),P=ki(F,"ADD_DATA_URI_TAGS",ne,{transform:se,base:ne}),St=ki(F,"FORBID_CONTENTS",bn,{transform:se}),ln=ki(F,"FORBID_TAGS",xo({}),{transform:se}),cn=ki(F,"FORBID_ATTR",xo({}),{transform:se}),Ht=io(F,"USE_PROFILES")?F.USE_PROFILES&&typeof F.USE_PROFILES=="object"?xo(F.USE_PROFILES):F.USE_PROFILES:!1,Ue=F.ALLOW_ARIA_ATTR!==!1,zt=F.ALLOW_DATA_ATTR!==!1,pt=F.ALLOW_UNKNOWN_PROTOCOLS||!1,At=F.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Kt=F.SAFE_FOR_TEMPLATES||!1,xt=F.SAFE_FOR_XML!==!1,un=F.WHOLE_DOCUMENT||!1,Qt=F.RETURN_DOM||!1,Nn=F.RETURN_DOM_FRAGMENT||!1,Zn=F.RETURN_TRUSTED_TYPE||!1,er=F.FORCE_BODY||!1,nn=F.SANITIZE_DOM!==!1,X=F.SANITIZE_NAMED_PROPS||!1,Ve=F.KEEP_CONTENT!==!1,Qe=F.IN_PLACE||!1,xe=y8(F.ALLOWED_URI_REGEXP)?F.ALLOWED_URI_REGEXP:Yx,ze=typeof F.NAMESPACE=="string"?F.NAMESPACE:De,_t=ug(F,"MATHML_TEXT_INTEGRATION_POINTS",()=>mn({},yn)),xn=ug(F,"HTML_INTEGRATION_POINTS",()=>mn({},gn));const K=ug(F,"CUSTOM_ELEMENT_HANDLING",()=>Sl(null));if(Ye=Sl(null),io(K,"tagNameCheck")&&yt(K.tagNameCheck)&&(Ye.tagNameCheck=K.tagNameCheck),io(K,"attributeNameCheck")&&yt(K.attributeNameCheck)&&(Ye.attributeNameCheck=K.attributeNameCheck),io(K,"allowCustomizedBuiltInElements")&&typeof K.allowCustomizedBuiltInElements=="boolean"&&(Ye.allowCustomizedBuiltInElements=K.allowCustomizedBuiltInElements),jr(Ye),Kt&&(zt=!1),Nn&&(Qt=!0),Ht&&(Re=mn({},Zx),Ee=Sl(null),Ht.html===!0&&(mn(Re,qx),mn(Ee,Gx)),Ht.svg===!0&&(mn(Re,ig),mn(Ee,cg),mn(Ee,yf)),Ht.svgFilters===!0&&(mn(Re,ag),mn(Ee,cg),mn(Ee,yf)),Ht.mathMl===!0&&(mn(Re,lg),mn(Ee,Vx),mn(Ee,yf))),gt.tagCheck=null,gt.attributeCheck=null,io(F,"ADD_TAGS")&&(typeof F.ADD_TAGS=="function"?gt.tagCheck=F.ADD_TAGS:Dl(F.ADD_TAGS)&&(Re===ge&&(Re=xo(Re)),mn(Re,F.ADD_TAGS,se))),io(F,"ADD_ATTR")&&(typeof F.ADD_ATTR=="function"?gt.attributeCheck=F.ADD_ATTR:Dl(F.ADD_ATTR)&&(Ee===We&&(Ee=xo(Ee)),mn(Ee,F.ADD_ATTR,se))),io(F,"ADD_FORBID_CONTENTS")&&Dl(F.ADD_FORBID_CONTENTS)&&(St===bn&&(St=xo(St)),mn(St,F.ADD_FORBID_CONTENTS,se)),Ve&&(Re["#text"]=!0),un&&mn(Re,["html","head","body"]),Re.table&&(mn(Re,["tbody"]),delete ln.tbody),F.TRUSTED_TYPES_POLICY){if(typeof F.TRUSTED_TYPES_POLICY.createHTML!="function")throw ia('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof F.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ia('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const ue=O;O=F.TRUSTED_TYPES_POLICY;try{z=Q("")}catch(ke){throw O=ue,ke}}else F.TRUSTED_TYPES_POLICY===null?(O=void 0,z=""):(O===void 0&&(O=U()),O&&typeof z=="string"&&(z=Q("")));yr&&yr(F),Ne=F},Ln=mn({},[...ig,...ag,...v8]),Or=mn({},[...lg,...b8]),Gn=function(F,K,ue){return K.namespaceURI===De?F==="svg":K.namespaceURI===It?F==="svg"&&(ue==="annotation-xml"||_t[ue]):!!Ln[F]},Xt=function(F,K,ue){return K.namespaceURI===De?F==="math":K.namespaceURI===Pt?F==="math"&&xn[ue]:!!Or[F]},Qr=function(F,K,ue){return K.namespaceURI===Pt&&!xn[ue]||K.namespaceURI===It&&!_t[ue]?!1:!Or[F]&&(Rt[F]||!Ln[F])},ft=function(F){let K=x(F);(!K||!K.tagName)&&(K={namespaceURI:ze,tagName:"template"});const ue=eu(F.tagName),ke=eu(K.tagName);return Vt[F.namespaceURI]?F.namespaceURI===Pt?Gn(ue,K,ke):F.namespaceURI===It?Xt(ue,K,ke):F.namespaceURI===De?Qr(ue,K,ke):!!(Mn==="application/xhtml+xml"&&Vt[F.namespaceURI]):!1},Un=function(F){qc(t.removed,{element:F});try{x(F).removeChild(F)}catch{if(w(F),!x(F))throw ia("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},ot=function(F,K,ue){try{F.removeAttributeNode(K)}catch{try{F.removeAttribute(ue)}catch{}}},$e=function(F){ut(F);const K=_(F);if(K){const ke=[];la(K,Le=>{qc(ke,Le)}),la(ke,Le=>{try{w(Le)}catch{}})}const ue=T(F);if(ue)for(let ke=ue.length-1;ke>=0;--ke){const Le=ue[ke],He=Le&&Le.name;typeof He=="string"&&ot(F,Le,He)}},qe=function(F,K,ue){if(!ue)try{ue=K.getAttributeNode(F)}catch{ue=null}qc(t.removed,{attribute:ue||null,from:K});try{ue?K.removeAttributeNode(ue):K.removeAttribute(F)}catch{try{K.removeAttribute(F)}catch{}}if(F==="is")if(Qt||Nn)try{Un(K)}catch{}else try{K.setAttribute(F,"")}catch{}},kt=function(F){const K=T(F);if(K)for(let ue=K.length-1;ue>=0;--ue){const ke=K[ue],Le=ke&&ke.name;typeof Le!="string"||Ee[se(Le)]||ot(F,ke,Le)}},ut=function(F){const K=[F];for(;K.length>0;){const ue=K.pop();A(ue)===bo.element&&kt(ue);const Le=_(ue);if(Le)for(let He=Le.length-1;He>=0;--He)K.push(Le[He])}},fn=function(F,K){return xt?F==="patchsrc"?!0:F==="for"&&K!=="label"&&K!=="output":!1},Wt=function(F){if(!xt)return;const K=[F];for(;K.length>0;){const ue=K.pop(),ke=A(ue);if(ke===bo.processingInstruction||ke===bo.comment&&Br(Qx,ue.data)){try{w(ue)}catch{}continue}if(ke===bo.element){const He=ue,Ot=se(M(ue));try{He.hasAttribute&&He.hasAttribute("patchsrc")&&He.removeAttribute("patchsrc"),He.hasAttribute&&He.hasAttribute("for")&&fn("for",Ot)&&He.removeAttribute("for")}catch{}}const Le=_(ue);if(Le)for(let He=Le.length-1;He>=0;--He)K.push(Le[He])}},sn=function(F){let K=null,ue=null;if(er)F="<remove></remove>"+F;else{const He=Ux(F,/^[\r\n\t ]+/);ue=He&&He[0]}Mn==="application/xhtml+xml"&&ze===De&&(F='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+F+"</body></html>");const ke=O?Q(F):F;if(ze===De)try{K=new f().parseFromString(ke,Mn)}catch{}if(!K||!K.documentElement){K=q.createDocument(ze,"template",null);try{K.documentElement.innerHTML=Ke?z:ke}catch{}}const Le=K.body||K.documentElement;return F&&ue&&Le.insertBefore(n.createTextNode(ue),Le.childNodes[0]||null),ze===De?re.call(K,un?"html":"body")[0]:un?K.documentElement:Le},tr=function(F){const K=I?I(F):F.ownerDocument;return V.call(K||F,F,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},An=function(F){return F=Zc(F,Te," "),F=Zc(F,je," "),F=Zc(F,de," "),F},Pn=function(F){var K;F.normalize();const ue=I?I(F):F.ownerDocument,ke=V.call(ue||F,F,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let Le=ke.nextNode();for(;Le;)Le.data=An(Le.data),Le=ke.nextNode();const He=(K=F.querySelectorAll)===null||K===void 0?void 0:K.call(F,"template");He&&la(He,Ot=>{Z(Ot.content)&&Pn(Ot.content)})},br=function(F){const K=C?C(F):null;return typeof K!="string"||se(K)!=="form"?!1:typeof F.nodeName!="string"||typeof F.textContent!="string"||typeof F.removeChild!="function"||F.attributes!==T(F)||typeof F.removeAttribute!="function"||typeof F.setAttribute!="function"||typeof F.namespaceURI!="string"||typeof F.insertBefore!="function"||typeof F.hasChildNodes!="function"||F.nodeType!==j(F)||F.childNodes!==_(F)},Z=function(F){if(!j||typeof F!="object"||F===null)return!1;try{return j(F)===bo.documentFragment}catch{return!1}},we=function(F){if(!j||typeof F!="object"||F===null)return!1;try{return typeof j(F)=="number"}catch{return!1}};function Ze(Ce,F,K){Ce.length!==0&&la(Ce,ue=>{ue.call(t,F,K,Ne)})}const qt=function(F,K){return!!(xt&&F.hasChildNodes()&&!we(F.firstElementChild)&&Br(Xx,F.textContent)&&Br(Xx,F.innerHTML)||xt&&F.namespaceURI===De&&R8[K]&&(we(F.firstElementChild)||typeof F.textContent=="string"&&Br(O8[K],F.textContent))||F.nodeType===bo.processingInstruction||xt&&F.nodeType===bo.comment&&Br(Qx,F.data))},wt=function(F,K){if(F instanceof RegExp)return Br(F,K);if(F instanceof Function){for(var ue=arguments.length,ke=new Array(ue>2?ue-2:0),Le=2;Le<ue;Le++)ke[Le-2]=arguments[Le];return!!F(K,...ke)}return!1},dn=function(F,K,ue){if(!ln[K]&&Nt(K)&&wt(Ye.tagNameCheck,K))return!1;if(Ve&&!St[K]){const ke=x(F),Le=_(F);if(Le&&ke){const He=Le.length;for(let Ot=He-1;Ot>=0;--Ot){const hn=F===ue?y(Le[Ot],!0):Le[Ot];ke.insertBefore(hn,v(F))}}}return Un(F),!0},ir=function(F,K,ue,ke){return F.length===0?K:K===ue||K===ke?xo(K):K},mr=function(F,K){return F===K||x(F)!==null?!1:(Qe&&ut(F),!0)},ar=function(F,K){if(Ze(pe.beforeSanitizeElements,F,null),mr(F,K))return!0;if(br(F))return Un(F),!0;const ue=se(M(F));if(Re=ir(pe.uponSanitizeElement,Re,ge,Ut),Ze(pe.uponSanitizeElement,F,{tagName:ue,allowedTags:Re}),mr(F,K))return!0;if(qt(F,ue))return Un(F),!0;if(ln[ue]||!(gt.tagCheck instanceof Function&&gt.tagCheck(ue))&&!Re[ue]){const Le=dn(F,ue,K);return Le===!1&&Ze(pe.afterSanitizeElements,F,null),Le}if(A(F)===bo.element&&!ft(F)||(ue==="noscript"||ue==="noembed"||ue==="noframes")&&Br(A8,F.innerHTML))return Un(F),!0;if(Kt&&F.nodeType===bo.text){const Le=An(F.textContent);F.textContent!==Le&&(qc(t.removed,{element:F.cloneNode()}),F.textContent=Le)}return Ze(pe.afterSanitizeElements,F,null),!1},po=function(F,K,ue){if(cn[K]||fn(K,F)||nn&&(K==="id"||K==="name")&&(ue in n||ue in rt))return!1;const ke=Ee[K]||gt.attributeCheck instanceof Function&&gt.attributeCheck(K,F);return zt&&Br(J,K)||Ue&&Br(te,K)?!0:ke?Se[K]||Br(xe,Zc(ue,ce,""))||(K==="src"||K==="xlink:href"||K==="href")&&F!=="script"&&Hx(ue,"data:")===0&&P[F]||pt&&!Br(ve,Zc(ue,ce,""))?!0:!ue:Nt(F)&&wt(Ye.tagNameCheck,F)&&wt(Ye.attributeNameCheck,K,F)||K==="is"&&Ye.allowCustomizedBuiltInElements&&wt(Ye.tagNameCheck,ue)},Zt=mn({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Nt=function(F){return!Zt[eu(F)]&&Br(ae,F)},jo=function(F,K,ue,ke){if(O&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!ue)switch(m.getAttributeType(F,K)){case"TrustedHTML":return Q(ke);case"TrustedScriptURL":return le(ke)}return ke},Tn=function(F,K,ue,ke){try{ue?F.setAttributeNS(ue,K,ke):F.setAttribute(K,ke),br(F)?Un(F):Bx(t.removed)}catch{qe(K,F)}},Jt=function(F){Ze(pe.beforeSanitizeAttributes,F,null);const K=F.attributes;if(!K||br(F))return;Ee=ir(pe.uponSanitizeAttribute,Ee,We,Et);const ue={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ee,forceKeepAttr:void 0};let ke=K.length;const Le=se(F.nodeName);for(;ke--;){const He=K[ke],Ot=He.name,hn=He.namespaceURI,nr=He.value,kn=se(Ot),Us=nr;let rr=Ot==="value"?Us:h8(Us);if(ue.attrName=kn,ue.attrValue=rr,ue.keepAttr=!0,ue.forceKeepAttr=void 0,Ze(pe.uponSanitizeAttribute,F,ue),rr=ue.attrValue,X&&(kn==="id"||kn==="name")&&Hx(rr,be)!==0&&(qe(Ot,F,He),rr=be+rr),xt&&Br(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,rr)){qe(Ot,F,He);continue}if(kn==="attributename"&&Ux(rr,"href")){qe(Ot,F,He);continue}if(!ue.forceKeepAttr){if(!ue.keepAttr){qe(Ot,F,He);continue}if(!At&&Br(I8,rr)){qe(Ot,F,He);continue}if(Kt&&(rr=An(rr)),!po(Le,kn,rr)){qe(Ot,F,He);continue}rr=jo(Le,kn,hn,rr),rr!==Us&&Tn(F,Ot,hn,rr)}}Ze(pe.afterSanitizeAttributes,F,null)},qr=function(F){let K=null;const ue=tr(F);for(Ze(pe.beforeSanitizeShadowDOM,F,null);K=ue.nextNode();)if(Ze(pe.uponSanitizeShadowNode,K,null),ar(K,F),Jt(K),Z(K.content)&&qr(K.content),A(K)===bo.element){const ke=N(K);Z(ke)&&(Mr(ke),qr(ke))}Ze(pe.afterSanitizeShadowDOM,F,null)},Mr=function(F){const K=[{node:F,shadow:null}];for(;K.length>0;){const ue=K.pop();if(ue.shadow){qr(ue.shadow);continue}const ke=ue.node,He=A(ke)===bo.element,Ot=_(ke);if(Ot)for(let hn=Ot.length-1;hn>=0;--hn)K.push({node:Ot[hn],shadow:null});if(He){const hn=C?C(ke):null;if(typeof hn=="string"&&se(hn)==="template"){const nr=ke.content;Z(nr)&&K.push({node:nr,shadow:null})}}if(He){const hn=N(ke);Z(hn)&&K.push({node:null,shadow:hn},{node:hn,shadow:null})}}};return t.sanitize=function(Ce){let F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},K=null,ue=null,ke=null,Le=null;if(Ke=!Ce,Ke&&(Ce="<!-->"),typeof Ce!="string"&&!we(Ce)&&(Ce=w8(Ce),typeof Ce!="string"))throw ia("dirty is not a string, aborting");if(!t.isSupported)return Ce;Ct?(Re=Ut,Ee=Et):jt(F),(pe.uponSanitizeElement.length>0||pe.uponSanitizeAttribute.length>0)&&(Re=xo(Re)),pe.uponSanitizeAttribute.length>0&&(Ee=xo(Ee)),t.removed=[];const He=Qe&&typeof Ce!="string"&&we(Ce);if(He){Wt(Ce);const nr=M(Ce);if(typeof nr=="string"){const kn=se(nr);if(!Re[kn]||ln[kn])throw $e(Ce),ia("root node is forbidden and cannot be sanitized in-place")}if(br(Ce))throw $e(Ce),ia("root node is clobbered and cannot be sanitized in-place");try{Mr(Ce)}catch(kn){throw $e(Ce),kn}}else if(we(Ce))K=sn("<!---->"),ue=K.ownerDocument.importNode(Ce,!0),ue.nodeType===bo.element&&ue.nodeName==="BODY"||ue.nodeName==="HTML"?K=ue:K.appendChild(ue),Mr(ue);else{if(!Qt&&!Kt&&!un&&Ce.indexOf("<")===-1)return O&&Zn?Q(Ce):Ce;if(K=sn(Ce),!K)return Qt?null:Zn?z:""}K&&er&&Un(K.firstChild);const Ot=He?Ce:K;try{const nr=tr(Ot);for(;ke=nr.nextNode();)ar(ke,Ot),Jt(ke),Z(ke.content)&&qr(ke.content)}catch(nr){throw He&&($e(Ce),la(t.removed,kn=>{kn.element&&ut(kn.element)})),nr}if(He)return la(t.removed,nr=>{nr.element&&ut(nr.element)}),Kt&&Pn(Ce),Ce;if(Qt){if(Kt&&Pn(K),Nn)for(Le=W.call(K.ownerDocument);K.firstChild;)Le.appendChild(K.firstChild);else Le=K;return(Ee.shadowroot||Ee.shadowrootmode)&&(Le=fe.call(r,Le,!0)),Le}let hn=un?K.outerHTML:K.innerHTML;return un&&Re["!doctype"]&&K.ownerDocument&&K.ownerDocument.doctype&&K.ownerDocument.doctype.name&&Br($8,K.ownerDocument.doctype.name)&&(hn="<!DOCTYPE "+K.ownerDocument.doctype.name+`>
139
- `+hn),Kt&&(hn=An(hn)),O&&Zn?Q(hn):hn},t.setConfig=function(){let Ce=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};jt(Ce),Ct=!0,Ut=Re,Et=Ee},t.clearConfig=function(){Ne=null,Ct=!1,Ut=null,Et=null,O=B,z=""},t.isValidAttribute=function(Ce,F,K){Ne||jt({});const ue=se(Ce),ke=se(F);return po(ue,ke,K)},t.addHook=function(Ce,F){typeof F=="function"&&io(pe,Ce)&&qc(pe[Ce],F)},t.removeHook=function(Ce,F){if(io(pe,Ce)){if(F!==void 0){const K=d8(pe[Ce],F);return K===-1?void 0:f8(pe[Ce],K,1)[0]}return Bx(pe[Ce])}},t.removeHooks=function(Ce){io(pe,Ce)&&(pe[Ce]=[])},t.removeAllHooks=function(){pe=Jx()},t}var P8=HT();function hy(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ma=hy();function WT(e){Ma=e}var ua={exec:()=>null};function xl(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 on(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(Hr.caret,"$1"),n=n.replace(o,a),r},getRegex:()=>new RegExp(n,t)};return r}var D8=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Hr={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:xl(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:xl(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:xl(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:xl(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:xl(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:xl(e=>new RegExp(`^ {0,${e}}>`))},z8=/^(?:[ \t]*(?:\n|$))+/,F8=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,B8=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Zu=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,U8=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,py=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,KT=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,qT=on(KT).replace(/bull/g,py).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(),H8=on(KT).replace(/bull/g,py).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(),my=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,W8=/^[^\n]+/,gy=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,K8=on(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",gy).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),q8=on(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,py).getRegex(),rp="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",ky=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Z8=on("^ {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",ky).replace("tag",rp).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ZT=e=>on(my).replace("hr",Zu).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",rp).getRegex(),G8=ZT(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),V8=ZT(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Y8=on(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",V8).getRegex(),wy={blockquote:Y8,code:F8,def:K8,fences:B8,heading:U8,hr:Zu,html:Z8,lheading:qT,list:q8,newline:z8,paragraph:G8,table:ua,text:W8},e1=on("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Zu).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",rp).getRegex(),X8={...wy,lheading:H8,table:e1,paragraph:on(my).replace("hr",Zu).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",e1).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",rp).getRegex()},Q8={...wy,html:on(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ky).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:ua,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:on(my).replace("hr",Zu).replace("heading",` *#{1,6} *[^
140
- ]`).replace("lheading",qT).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},J8=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,e9=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,GT=/^( {2,}|\\)\n(?!\s*$)/,t9=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Bs=/[\p{P}\p{S}]/u,ec=/[\s\p{P}\p{S}]/u,Gu=/[^\s\p{P}\p{S}]/u,n9=on(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ec).getRegex(),r9=/[\p{Pi}\p{Ps}"']/u,VT=/(?!~)[\p{P}\p{S}]/u,o9=/(?!~)[\s\p{P}\p{S}]/u,s9=/(?:[^\s\p{P}\p{S}]|~)/u,i9=on(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",D8?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),YT=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,a9=on(YT,"u").replace(/punct/g,Bs).getRegex(),l9=on(YT,"u").replace(/punct/g,VT).getRegex(),c9=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,u9=on(c9,"u").replace(/openQuote/g,r9).replace(/punct/g,Bs).getRegex(),XT="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",d9=on(XT,"gu").replace(/notPunctSpace/g,Gu).replace(/punctSpace/g,ec).replace(/punct/g,Bs).getRegex(),f9=on(XT,"gu").replace(/notPunctSpace/g,s9).replace(/punctSpace/g,o9).replace(/punct/g,VT).getRegex(),h9="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",p9=on(h9,"gu").replace(/notPunctSpace/g,Gu).replace(/punctSpace/g,ec).replace(/punct/g,Bs).getRegex(),m9=on("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Gu).replace(/punctSpace/g,ec).replace(/punct/g,Bs).getRegex(),g9="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",k9=on(g9,"gu").replace(/notPunctSpace/g,Gu).replace(/punctSpace/g,ec).replace(/punct/g,Bs).getRegex(),w9=on(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Bs).getRegex(),y9="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",v9=on(y9,"gu").replace(/notPunctSpace/g,Gu).replace(/punctSpace/g,ec).replace(/punct/g,Bs).getRegex(),b9=on(/\\(punct)/,"gu").replace(/punct/g,Bs).getRegex(),x9=on(/^<(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(),E9=on(ky).replace("(?:-->|$)","-->").getRegex(),S9=on("^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",E9).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ih=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,_9=on(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ih).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),QT=on(/^!?\[(label)\]\[(ref)\]/).replace("label",ih).replace("ref",gy).getRegex(),JT=on(/^!?\[(ref)\](?:\[\])?/).replace("ref",gy).getRegex(),N9=on("reflink|nolink(?!\\()","g").replace("reflink",QT).replace("nolink",JT).getRegex(),t1=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,yy={_backpedal:ua,anyPunctuation:b9,autolink:x9,blockSkip:i9,br:GT,code:e9,del:ua,delLDelim:ua,delRDelim:ua,emStrongLDelim:a9,emStrongRDelimAst:d9,emStrongRDelimUnd:m9,escape:J8,link:_9,nolink:JT,punctuation:n9,reflink:QT,reflinkSearch:N9,tag:S9,text:t9,url:ua},T9={...yy,emStrongLDelim:u9,emStrongRDelimAst:p9,emStrongRDelimUnd:k9,link:on(/^!?\[(label)\]\((.*?)\)/).replace("label",ih).getRegex(),reflink:on(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ih).getRegex()},vk={...yy,emStrongRDelimAst:f9,emStrongLDelim:l9,delLDelim:w9,delRDelim:v9,url:on(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",t1).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:on(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",t1).getRegex()},j9={...vk,br:on(GT).replace("{2,}","*").getRegex(),text:on(vk.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},vf={normal:wy,gfm:X8,pedantic:Q8},Vc={normal:yy,gfm:vk,breaks:j9,pedantic:T9},$9={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},n1=e=>$9[e];function ds(e,t){if(t){if(Hr.escapeTest.test(e))return e.replace(Hr.escapeReplace,n1)}else if(Hr.escapeTestNoEncode.test(e))return e.replace(Hr.escapeReplaceNoEncode,n1);return e}function r1(e){try{e=encodeURI(e).replace(Hr.percentDecode,"%")}catch{return null}return e}function o1(e,t){var s;let n=e.replace(Hr.findPipe,(a,c,u)=>{let h=!1,f=c;for(;--f>=0&&u[f]==="\\";)h=!h;return h?"|":" |"}),r=n.split(Hr.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(Hr.slashPipe,"|");return r}function wi(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 s1(e){let t=e.split(`
141
- `),n=t.length-1;for(;n>=0&&Hr.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
142
- `)}function C9(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 A9(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 i1(e,t,n,r,o){let s=t.href,a=t.title||null,c=e[1].replace(o.other.outputLinkReplace,"$1"),u=e[0].charAt(0)==="!";r.state.inLink=!0;let h=r.state.linkEmitted,f=r.state.inRawBlock;r.state.linkEmitted=!1;let m=r.inlineTokens(c),g=r.state.linkEmitted;if(r.state.linkEmitted=h,r.state.inLink=!1,!u){if(g){r.state.inRawBlock=f;return}r.state.linkEmitted=!0}return{type:u?"image":"link",raw:n,href:s,title:a,text:c,tokens:m}}function I9(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let o=r[1];return t.split(`
143
- `).map(s=>{let a=s.match(n.other.beginningSpace);if(a===null)return s;let[c]=a;return c.length>=o.length?s.slice(o.length):s}).join(`
144
- `)}var ah=class{constructor(e){Tt(this,"options");Tt(this,"rules");Tt(this,"lexer");this.options=e||Ma}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]:s1(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=I9(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=wi(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:wi(t[0],`
145
- `),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:wi(t[0],`
146
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=wi(t[0],`
147
- `).split(`
148
- `),r="",o="",s=[];for(;n.length>0;){let a=!1,c=[],u;for(u=0;u<n.length;u++)if(this.rules.other.blockquoteStart.test(n[u]))c.push(n[u]),a=!0;else if(!a)c.push(n[u]);else break;n=n.slice(u);let h=c.join(`
149
- `),f=h.replace(this.rules.other.blockquoteSetextReplace,`
150
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
151
- ${h}`:h,o=o?`${o}
152
- ${f}`:f;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(f,s,!0),this.lexer.state.top=m,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(`
153
- `),v=y.raw+`
154
- `+w.replace(this.rules.other.blockquoteSetextReplace2,""),_=this.blockquote(v);s[s.length-1]=_,r=`${r}
155
- ${w}`,o=o.substring(0,o.length-y.text.length)+_.text;break}else if((g==null?void 0:g.type)==="list"){let y=g,w=y.raw+`
156
- `+n.join(`
157
- `),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(`
158
- `);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,h="",f="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;h=t[0],e=e.substring(h.length);let m=A9(t[2].split(`
159
- `,1)[0],t[1].length),g=e.split(`
160
- `,1)[0],y=!m.trim(),w=0;if(this.options.pedantic?(w=2,f=m.trimStart()):y?w=t[1].length+1:(w=m.search(this.rules.other.nonSpaceChar),w=w>4?1:w,f=m.slice(w),w+=t[1].length),y&&this.rules.other.blankLine.test(g)&&(h+=g+`
161
- `,e=e.substring(g.length+1),u=!0),!u){let v=this.rules.other.nextBulletRegex(w),_=this.rules.other.hrRegex(w),x=this.rules.other.fencesBeginRegex(w),N=this.rules.other.headingBeginRegex(w),T=this.rules.other.htmlBeginRegex(w),j=this.rules.other.blockquoteBeginRegex(w);for(;e;){let C=e.split(`
162
- `,1)[0],I;if(g=C,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),I=g):I=g.replace(this.rules.other.tabCharGlobal," "),x.test(g)||N.test(g)||T.test(g)||j.test(g)||v.test(g)||_.test(g))break;if(I.search(this.rules.other.nonSpaceChar)>=w||!g.trim())f+=`
163
- `+I.slice(w);else{if(y||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||x.test(m)||N.test(m)||_.test(m))break;f+=`
164
- `+g}y=!g.trim(),h+=C+`
165
- `,e=e.substring(C.length+1),m=I.slice(w)}}o.loose||(a?o.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(a=!0)),o.items.push({type:"list_item",raw:h,task:!!this.options.gfm&&this.rules.other.listIsTask.test(f),loose:!1,text:f,tokens:[]}),o.raw+=h}let c=o.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.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 h=u.tokens.filter(m=>m.type==="space"),f=h.length>0&&h.some(m=>this.rules.other.anyLine.test(m.raw));o.loose=f}for(let u of o.items){let h=u.tokens[0];if(u.task&&((h==null?void 0:h.type)==="text"||(h==null?void 0:h.type)==="paragraph")){u.text=u.text.replace(this.rules.other.listReplaceTask,""),h.raw=h.raw.replace(this.rules.other.listReplaceTask,""),h.text=h.text.replace(this.rules.other.listReplaceTask,"");for(let m=this.lexer.inlineQueue.length-1;m>=0;m--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[m].src)){this.lexer.inlineQueue[m].src=this.lexer.inlineQueue[m].src.replace(this.rules.other.listReplaceTask,"");break}let f=this.rules.other.listTaskCheckbox.exec(u.raw);if(f){let m={type:"checkbox",raw:f[0]+" ",checked:f[0]!=="[ ]"};u.checked=m.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=m.raw+u.tokens[0].raw,u.tokens[0].text=m.raw+u.tokens[0].text,u.tokens[0].tokens.unshift(m)):u.tokens.unshift({type:"paragraph",raw:m.raw,text:m.raw,tokens:[m]}):u.tokens.unshift(m)}}else u.task&&(u.task=!1)}if(o.loose)for(let u of o.items){u.loose=!0;for(let h of u.tokens)h.type==="text"&&(h.type="paragraph")}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=s1(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:wi(t[0],`
166
- `),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=o1(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(`
167
- `):[],s={type:"table",raw:wi(t[0],`
168
- `),header:[],align:[],rows:[]};if(n.length===r.length){for(let c of r)this.rules.other.tableAlignRight.test(c)?s.align.push("right"):this.rules.other.tableAlignCenter.test(c)?s.align.push("center"):this.rules.other.tableAlignLeft.test(c)?s.align.push("left"):s.align.push(null);for(let c=0;c<n.length;c++)s.header.push({text:n[c],tokens:this.lexer.inline(n[c]),header:!0,align:s.align[c]});for(let c of o)s.rows.push(o1(c,s.header.length).map((u,h)=>({text:u,tokens:this.lexer.inline(u),header:!1,align:s.align[h]})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:wi(t[0],`
169
- `),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)===`
170
- `?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=wi(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{let s=C9(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)),i1(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 i1(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,c=o,u=0,h=r[0][0],f=n===h,m=h==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(m.lastIndex=0,t=t.slice(-1*e.length+o);(r=m.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]){c+=a;continue}else if(r[5]||r[6]){if(o%3&&!((o+a)%3)){u+=a;continue}if(f)break}if(c-=a,c>0)continue;a=Math.min(a,a+c+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,c=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]){c+=a;continue}if(c-=a,c>0)continue;a=Math.min(a,a+c);let h=[...r[0]][0].length,f=e.slice(0,o+r.index+h+a),m=f.slice(o,-o);return{type:"del",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}}}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}}}},Jo=class bk{constructor(t){Tt(this,"tokens");Tt(this,"options");Tt(this,"state");Tt(this,"inlineQueue");Tt(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ma,this.options.tokenizer=this.options.tokenizer||new ah,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:Hr,block:vf.normal,inline:Vc.normal};this.options.pedantic?(n.block=vf.pedantic,n.inline=Vc.pedantic):this.options.gfm&&(n.block=vf.gfm,this.options.breaks?n.inline=Vc.breaks:n.inline=Vc.gfm),this.tokenizer.rules=n}static get rules(){return{block:vf,inline:Vc}}static lex(t,n){return new bk(n).lex(t)}static lexInline(t,n){return new bk(n).inlineTokens(t)}lex(t){t=t.replace(Hr.carriageReturn,`
171
- `),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,c;this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(Hr.tabCharGlobal," ").replace(Hr.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(f=>(u=f.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 f=n.at(-1);u.raw.length===1&&f!==void 0?f.raw+=`
172
- `:n.push(u);continue}if(u=this.tokenizer.code(t)){t=t.substring(u.raw.length);let f=n.at(-1);(f==null?void 0:f.type)==="paragraph"||(f==null?void 0:f.type)==="text"?(f.raw+=(f.raw.endsWith(`
173
- `)?"":`
174
- `)+u.raw,f.text+=`
175
- `+u.text,this.inlineQueue.at(-1).src=f.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 f=n.at(-1);(f==null?void 0:f.type)==="paragraph"||(f==null?void 0:f.type)==="text"?(f.raw+=(f.raw.endsWith(`
176
- `)?"":`
177
- `)+u.raw,f.text+=`
178
- `+u.raw,this.inlineQueue.at(-1).src=f.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 h=t;if((c=this.options.extensions)!=null&&c.startBlock){let f=1/0,m=t.slice(1),g;this.options.extensions.startBlock.forEach(y=>{g=y.call({lexer:this},m),typeof g=="number"&&g>=0&&(f=Math.min(f,g))}),f<1/0&&f>=0&&(h=t.substring(0,f+1))}if(this.state.top&&(u=this.tokenizer.paragraph(h))){let f=n.at(-1);r&&(f==null?void 0:f.type)==="paragraph"?(f.raw+=(f.raw.endsWith(`
179
- `)?"":`
180
- `)+u.raw,f.text+=`
181
- `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=f.text):n.push(u),r=h.length!==t.length,t=t.substring(u.raw.length);continue}if(u=this.tokenizer.text(t)){t=t.substring(u.raw.length);let f=n.at(-1);(f==null?void 0:f.type)==="text"?(f.raw+=(f.raw.endsWith(`
182
- `)?"":`
183
- `)+u.raw,f.text+=`
184
- `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=f.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 c,u,h,f,m;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 _=w.slice(1,v-1);if(this.linkInText(_))return"["+_.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=(c=this.options.hooks)==null?void 0:c.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((f=(h=this.options.extensions)==null?void 0:h.inline)!=null&&f.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((m=this.options.extensions)!=null&&m.startInline){let w=1/0,v=t.slice(1),_;this.options.extensions.startInline.forEach(x=>{_=x.call({lexer:this},v),typeof _=="number"&&_>=0&&(w=Math.min(w,_))}),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)}},$u=class{constructor(e){Tt(this,"options");Tt(this,"parser");this.options=e||Ma}space(e){return""}code({text:e,lang:t,escaped:n}){var s;let r=(s=(t||"").match(Hr.notSpaceStart))==null?void 0:s[0],o=e.replace(Hr.endingNewline,"")+`
185
- `;return r?'<pre><code class="language-'+ds(r)+'">'+(n?o:ds(o,!0))+`</code></pre>
186
- `:"<pre><code>"+(n?o:ds(o,!0))+`</code></pre>
187
- `}blockquote({tokens:e}){return`<blockquote>
188
- ${this.parser.parse(e)}</blockquote>
189
- `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
190
- `}hr(e){return`<hr>
191
- `}list(e){let t=e.ordered,n=e.start,r="";for(let a=0;a<e.items.length;a++){let c=e.items[a];r+=this.listitem(c)}let o=t?"ol":"ul",s=t&&n!==1?' start="'+n+'"':"";return"<"+o+s+`>
192
- `+r+"</"+o+`>
193
- `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
194
- `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
195
- `}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>
196
- <thead>
197
- `+t+`</thead>
198
- `+r+`</table>
199
- `}tablerow({text:e}){return`<tr>
200
- ${e}</tr>
201
- `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
202
- `}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>${ds(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=r1(e);if(o===null)return r;e=o;let s='<a href="'+e+'"';return t&&(s+=' title="'+ds(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=r1(e);if(o===null)return ds(n);e=o;let s=`<img src="${e}" alt="${ds(n)}"`;return t&&(s+=` title="${ds(t)}"`),s+=">",s}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:ds(e.text)}},vy=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}},es=class xk{constructor(t){Tt(this,"options");Tt(this,"renderer");Tt(this,"textRenderer");this.options=t||Ma,this.options.renderer=this.options.renderer||new $u,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new vy}static parse(t,n){return new xk(n).parse(t)}static parseInline(t,n){return new xk(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,h=this.options.extensions.renderers[u.type].call({parser:this},u);if(h!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(u.type)){n+=h||"";continue}}let c=a;switch(c.type){case"space":{n+=this.renderer.space(c);break}case"hr":{n+=this.renderer.hr(c);break}case"heading":{n+=this.renderer.heading(c);break}case"code":{n+=this.renderer.code(c);break}case"table":{n+=this.renderer.table(c);break}case"blockquote":{n+=this.renderer.blockquote(c);break}case"list":{n+=this.renderer.list(c);break}case"checkbox":{n+=this.renderer.checkbox(c);break}case"html":{n+=this.renderer.html(c);break}case"def":{n+=this.renderer.def(c);break}case"paragraph":{n+=this.renderer.paragraph(c);break}case"text":{n+=this.renderer.text(c);break}default:{let u='Token with "'+c.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 c=t[a];if((s=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&s[c.type]){let h=this.options.extensions.renderers[c.type].call({parser:this},c);if(h!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(c.type)){r+=h||"";continue}}let u=c;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 h='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(h),"";throw new Error(h)}}}return r}},Tf,tu=(Tf=class{constructor(e){Tt(this,"options");Tt(this,"block");this.options=e||Ma}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Jo.lex:Jo.lexInline}provideParser(e=this.block){return e?es.parse:es.parseInline}},Tt(Tf,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),Tt(Tf,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Tf),R9=class{constructor(...e){Tt(this,"defaults",hy());Tt(this,"options",this.setOptions);Tt(this,"parse",this.parseMarkdown(!0));Tt(this,"parseInline",this.parseMarkdown(!1));Tt(this,"Parser",es);Tt(this,"Renderer",$u);Tt(this,"TextRenderer",vy);Tt(this,"Lexer",Jo);Tt(this,"Tokenizer",ah);Tt(this,"Hooks",tu);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 c of a.header)n=n.concat(this.walkTokens(c.tokens,t));for(let c of a.rows)for(let u of c)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(c=>{let u=a[c].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 c=o.renderer.apply(this,a);return c===!1&&(c=s.apply(this,a)),c}: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 $u(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,c=n.renderer[a],u=o[a];o[a]=(...h)=>{let f=c.apply(o,h);return f===!1&&(f=u.apply(o,h)),f||""}}r.renderer=o}if(n.tokenizer){let o=this.defaults.tokenizer||new ah(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,c=n.tokenizer[a],u=o[a];o[a]=(...h)=>{let f=c.apply(o,h);return f===!1&&(f=u.apply(o,h)),f}}r.tokenizer=o}if(n.hooks){let o=this.defaults.hooks||new tu;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,c=n.hooks[a],u=o[a];tu.passThroughHooks.has(s)?o[a]=h=>{if(this.defaults.async&&tu.passThroughHooksRespectAsync.has(s))return(async()=>{let m=await c.call(o,h);return u.call(o,m)})();let f=c.call(o,h);return u.call(o,f)}:o[a]=(...h)=>{if(this.defaults.async)return(async()=>{let m=await c.apply(o,h);return m===!1&&(m=await u.apply(o,h)),m})();let f=c.apply(o,h);return f===!1&&(f=u.apply(o,h)),f}}r.hooks=o}if(n.walkTokens){let o=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(a){let c=[];return c.push(s.call(this,a)),o&&(c=c.concat(o.call(this,a))),c}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Jo.lex(e,t??this.defaults)}parser(e,t){return es.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,c=await(o.hooks?await o.hooks.provideLexer(e):e?Jo.lex:Jo.lexInline)(a,o),u=o.hooks?await o.hooks.processAllTokens(c):c;o.walkTokens&&await Promise.all(this.walkTokens(u,o.walkTokens));let h=await(o.hooks?await o.hooks.provideParser(e):e?es.parse:es.parseInline)(u,o);return o.hooks?await o.hooks.postprocess(h):h})().catch(s);try{o.hooks&&(t=o.hooks.preprocess(t));let a=(o.hooks?o.hooks.provideLexer(e):e?Jo.lex:Jo.lexInline)(t,o);o.hooks&&(a=o.hooks.processAllTokens(a)),o.walkTokens&&this.walkTokens(a,o.walkTokens);let c=(o.hooks?o.hooks.provideParser(e):e?es.parse:es.parseInline)(a,o);return o.hooks&&(c=o.hooks.postprocess(c)),c}catch(a){return s(a)}}}onError(e,t){return n=>{if(n.message+=`
203
- Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+ds(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},Ta=new R9;function En(e,t){return Ta.parse(e,t)}En.options=En.setOptions=function(e){return Ta.setOptions(e),En.defaults=Ta.defaults,WT(En.defaults),En};En.getDefaults=hy;En.defaults=Ma;function O9(...e){return Ta.use(...e),En.defaults=Ta.defaults,WT(En.defaults),En}En.use=O9;En.walkTokens=function(e,t){return Ta.walkTokens(e,t)};En.parseInline=Ta.parseInline;En.Parser=es;En.parser=es.parse;En.Renderer=$u;En.TextRenderer=vy;En.Lexer=Jo;En.lexer=Jo.lex;En.Tokenizer=ah;En.Hooks=tu;En.parse=En;En.options;En.setOptions;En.walkTokens;En.parseInline;es.parse;Jo.lex;const ja=100,M9=e=>e.type==="text-delta"||e.type==="thinking-delta"||e.type==="tool-delta";function L9(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 P9={now:()=>performance.now(),after:(e,t)=>void setTimeout(t,e)};function D9(e,t=P9){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 c of a)e(c)};return a=>{if(a.t==="agent"&&M9(a.event)){const c={...a,event:{...a.event}},u=t.now();if(n.length===0&&u-o>=ja){o=u,e(c);return}const h=n[n.length-1];h&&L9(h,c)?h.event={...h.event,text:h.event.text+c.event.text}:n.push(c),r||(r=!0,t.after(Math.max(0,o+ja-u),s));return}s(),e(a)}}const ej="#toyon-link-pending",z9=/!?\[([^[\]\n]*)(?:\]\(([^()\s]*))?$/;function F9(e){const t=e.lastIndexOf(`
204
- `)+1,n=e.slice(t),r=z9.exec(n);return!r||B9(e.slice(0,t))||U9(n.slice(0,r.index))?e:`${e.slice(0,t)}${n.slice(0,r.index)}[${r[1]}](${ej})`}function B9(e){let t=!1;for(const n of e.split(`
205
- `))/^\s*(```|~~~)/.test(n)&&(t=!t);return t}function U9(e){let t=0;for(const n of e)n==="`"&&t++;return t%2===1}const dg="__[a-z][a-z0-9_]*[a-z0-9]__",H9=new RegExp(`^(?:${dg}\\.)+${dg}|^${dg}(?=\\.\\w|\\(|["'])`),W9={name:"dunder",level:"inline",start:e=>e.indexOf("__"),tokenizer(e){const t=H9.exec(e);if(t)return{type:"dunder",raw:t[0],text:t[0]}},renderer:e=>e.text},Is=e=>e.replace(/[&<>]/g,t=>t==="&"?"&amp;":t==="<"?"&lt;":"&gt;");function K9({text:e}){return Is(e)}function q9(e){return`<div class="md-table">${Z9.call(this,e)}</div>
206
- `}function Z9(e){if(e.header.some(n=>n.text.trim()))return $u.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>
207
- <tbody>${t}</tbody></table>
208
- `}const G9=/^[^\s]*$/,V9=e=>e.split(/\s+/).slice(1).every(t=>!t||/[a-z0-9]/i.test(t));function fg(e,t,n){if(e.startsWith("!"))return null;if(e.startsWith("/")){const a=e.indexOf(" "),c=a===-1?e.length:a;if(!(e.indexOf("/",1)!==-1&&e.indexOf("/",1)<c)&&t<=c)return{kind:"command",query:e.slice(1,t),from:0,to:c}}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(!G9.test(o)&&!(V9(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 Ek=new Map,a1={files:new Set,folders:new Set,worktrees:Ek,titled:[]},l1=new WeakMap;function tj(e,t=Ek){let n;if(e?(n=l1.get(e),n||(n={...a1,files:new Set(e),folders:new Set(YS(e))},l1.set(e,n))):n=a1,t===Ek)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 nj(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 Y9=/(^|\s)(@\S+)/g,X9=/[.,;:!?)\]}'"]$/,Q9=/^[.,;:!?)\]}'"]*(\s|$)/;function c1(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 J9(e,t){const n=e.toLowerCase();for(const r of t.titled){const o=r.title.toLowerCase();if(o&&n.startsWith(o)&&Q9.test(e.slice(o.length)))return{kind:"worktree",text:`@${e.slice(0,o.length)}`,...r}}return null}function op(e){const t=[];return e.archived?t.push("archived"):(e.state&&t.push(e.state),e.at!==void 0&&t.push(`last sent ${Eo(fr(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 eB(e,t,n){let r=0;for(const o of by(e,n)){if(r===t)return o.kind!=="text";r+=o.text.length}return!1}function by(e,t){const n=[];let r=0;const o=s=>{if(!s)return;const a=n.at(-1);(a==null?void 0:a.kind)==="text"?a.text+=s:n.push({kind:"text",text:s})};for(const s of e.matchAll(Y9)){const a=s.index+(s[1]??"").length;if(a<r)continue;const c=J9(e.slice(a+1),t);let u=(s[2]??"").slice(1),h=c&&/\s/.test(c.text)?c:c1(u,t);for(;!h&&X9.test(u);)u=u.slice(0,-1),h=u?c1(u,t):null;h??(h=c),h&&(o(e.slice(r,a)),n.push(h),r=a+h.text.length)}return o(e.slice(r)),n}function u1(e,t){return by(e,t).map(n=>n.kind==="worktree"?`@${n.branch}`:n.text).join("")}function tB(e,t,n){return{text:e.slice(0,t.from)+n+e.slice(t.to),caret:t.from+n.length}}function nB(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=s=>e.map((a,c)=>({c:a,i:c,score:s(a)})).filter(a=>a.score>0).sort((a,c)=>c.score-a.score||a.i-c.i).map(a=>a.c),o=r(s=>pk(s.name,n));return o.length>0?o:r(s=>pk(s.description,n))}const d1=e=>e.slice(e.lastIndexOf("/")+1);function rB(e,t,n){const r=[],o=new Set;for(const s of e){const a=s.worktree;if(a.repoId!==n)continue;const c=d1(a.path);o.has(c)||(o.add(c),r.push({dir:c,id:a.id,title:a.title,branch:a.branch}))}for(const s of t??[]){const a=d1(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 f1=new WeakMap;function oB(e,t){let n=f1.get(e.visible);n||(n=new Map,f1.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(rB(e.visible,r,t));return n.set(t,{archived:r,key:s}),s}function sB(e){const t=new Map;for(const n of JSON.parse(e))t.set(n.dir,n);return n=>t.get(n)??null}const rj="wt-[0-9a-f]{4}",iB=new RegExp(`(^|[^\\w\\-/\`])\`?${rj}(?![\\w\\-/\`])`),aB=new RegExp(`^(\`?)(${rj})\\1(?![\\w\\-/\`])`),aa=e=>Is(e).replace(/"/g,"&quot;");function lB(e){return{name:"worktree",level:"inline",start:t=>{const n=iB.exec(t);return n?n.index+n[1].length:void 0},tokenizer(t){const n=aB.exec(t);if(n)return{type:"worktree",raw:n[0],text:n[2],code:n[1]!==""}},renderer(t){var c;const n=t.text,r=((c=e())==null?void 0:c(n))??null;if(!r)return t.code?`<code>${n}</code>`:n;const o=op({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="${aa(o.dot)}"`:"";return`<span class="chat-mention" data-worktree="${aa(r.id)}" data-branch="${aa(r.branch)}" data-dir="${aa(n)}"${s} data-tip="${aa(o.text)}" data-tip-detail="${aa(o.detail.join(`
209
- `))}"${a} data-tip-placement="follow">@${Is(r.title)}<span class="chat-mention-dot"><span class="dot${o.dot?` ${aa(o.dot)}`:""}"></span></span></span>`}}}const cB=4*ja;function uB(e,t,n){if(!e)return{from:t,to:t,at:n,span:ja};const r=Math.min(oj(e,n),t),o=Math.min(Math.max(n-e.at,ja),cB);return{from:r,to:t,at:n,span:o}}function oj(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 dB(e,t){if(t>=e.length)return e;const n=e.charCodeAt(t);return e.slice(0,n>=56320&&n<=57343?t+1:t)}function fB(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"})]}},c={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,o]};o.contains.push(c);const u={match:/\\"/},h={className:"string",begin:/'/,end:/'/},f={match:/\\'/},m={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"],_=["true","false"],x={match:/(\/[a-z._-]+)+/},N=["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"],C=["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:_,built_in:[...N,...T,"set","shopt",...j,...C]},contains:[y,e.SHEBANG(),w,m,s,a,x,c,u,h,f,n]}}const hB=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_-]*/}}),pB=["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"],mB=["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"],gB=[...pB,...mB],kB=["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(),wB=["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(),yB=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),vB=["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 bB(e){const t=e.regex,n=hB(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_-]*",c=[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:":("+wB.join("|")+")"},{begin:":(:)?("+yB.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+vB.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,n.UNICODE_RANGE,...c,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...c,{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:kB.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...c,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+gB.join("|")+")\\b"}]}}function xB(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 EB(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:"'"}]},c={begin:/\[/,end:/\]/,contains:[r,s,o,a,n,"self"],relevance:0},u=/[A-Za-z0-9_-]+/,h=/"(\\"|[^"])*"/,f=/'[^']*'/,m=t.either(u,h,f),g=t.concat(m,"(\\s*\\.\\s*",m,")*",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,c,s,o,a,n]}}]}}const h1="[A-Za-z$_][0-9A-Za-z$_]*",SB=["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"],_B=["true","false","null","undefined","NaN","Infinity"],sj=["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"],ij=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],aj=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],NB=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],TB=[].concat(aj,sj,ij);function jB(e){const t=e.regex,n=($,{after:q})=>{const V="</"+$[0].slice(1);return $.input.indexOf(V,q)!==-1},r=h1,o={begin:"<>",end:"</>"},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,a={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:($,q)=>{const V=$[0].length+$.index,W=$.input[V];if(W==="<"||W===","){q.ignoreMatch();return}W===">"&&(n($,{after:V})||q.ignoreMatch());let re;const fe=$.input.substring(V);if(re=fe.match(/^\s*=/)){q.ignoreMatch();return}if((re=fe.match(/^\s+extends\s+/))&&re.index===0){q.ignoreMatch();return}}},c={$pattern:h1,keyword:SB,literal:_B,built_in:TB,"variable.language":NB},u="[0-9](_?[0-9])*",h=`\\.(${u})`,f="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${f})((${h})|\\.)?|(${h}))[eE][+-]?(${u})\\b`},{begin:`\\b(${f})\\b((${h})\\b|\\.)?|(${h})\\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:c,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"}},_={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},N={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,_,{match:/\$\d+/},m];g.contains=T.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(T)});const j=[].concat(N,g.contains),C=j.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(j)}]),I={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:C},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"}}]},M={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:{_:[...sj,...ij]}},O={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},z={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[I],illegal:/%/},B={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function H($){return t.concat("(?!",$.join("|"),")")}const Y={match:t.concat(/\b/,H([...aj,"super","import","await"].map($=>`${$}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},ie={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},Q={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},I]},le="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",U={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(le)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[I]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:C,CLASS_REFERENCE:M},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),O,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,v,_,N,{match:/\$\d+/},m,M,{scope:"attr",match:r+t.lookahead(":"),relevance:0},U,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[N,e.REGEXP_MODE,{className:"function",begin:le,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:c,contains:C}]}]},{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"]}]}]},z,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[I,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},ie,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[I]},Y,B,A,Q,{match:/\$[(.]/}]}}const $B="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",CB={scope:"number",match:$B,relevance:0};function AB(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,CB,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function IB(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}]},c=/[A-Za-z][A-Za-z0-9+.-]*/,u={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,c,/:\/\/.*?\)/),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}]},h={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},f={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},m=e.inherit(h,{contains:[]}),g=e.inherit(f,{contains:[]});h.contains.push(g),f.contains.push(m);let y=[n,u];return[h,f,m,g].forEach(x=>{x.contains=x.contains.concat(y)}),y=y.concat(h,f),{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,h,f,{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 RB(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"],c={$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:/^(>>>|\.\.\.) /},h={className:"subst",begin:/\{/,end:/\}/,keywords:c,illegal:/#/},f={begin:/\{\{/,relevance:0},m={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,f,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u,f,h]},{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,f,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,f,h]},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})`}]},_={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:c,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},x={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:["self",u,v,m,e.HASH_COMMENT_MODE]}]};return h.contains=[m,v,u],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:c,illegal:/(<\/|\?)|=>/,contains:[u,v,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},m,_,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[x]},{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,x,m]}]}}function OB(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))?",c=["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"],h=["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!"],f=["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:f,keyword:c,literal:u,built_in:h},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:h,type:f}},{scope:"punctuation",begin:"->"},s]}}const lh="[A-Za-z$_][0-9A-Za-z$_]*",lj=["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"],cj=["true","false","null","undefined","NaN","Infinity"],uj=["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"],dj=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],fj=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],hj=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],pj=[].concat(fj,uj,dj);function MB(e){const t=e.regex,n=($,{after:q})=>{const V="</"+$[0].slice(1);return $.input.indexOf(V,q)!==-1},r=lh,o={begin:"<>",end:"</>"},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,a={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:($,q)=>{const V=$[0].length+$.index,W=$.input[V];if(W==="<"||W===","){q.ignoreMatch();return}W===">"&&(n($,{after:V})||q.ignoreMatch());let re;const fe=$.input.substring(V);if(re=fe.match(/^\s*=/)){q.ignoreMatch();return}if((re=fe.match(/^\s+extends\s+/))&&re.index===0){q.ignoreMatch();return}}},c={$pattern:lh,keyword:lj,literal:cj,built_in:pj,"variable.language":hj},u="[0-9](_?[0-9])*",h=`\\.(${u})`,f="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${f})((${h})|\\.)?|(${h}))[eE][+-]?(${u})\\b`},{begin:`\\b(${f})\\b((${h})\\b|\\.)?|(${h})\\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:c,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"}},_={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},N={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,_,{match:/\$\d+/},m];g.contains=T.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(T)});const j=[].concat(N,g.contains),C=j.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(j)}]),I={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:C},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"}}]},M={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:{_:[...uj,...dj]}},O={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},z={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[I],illegal:/%/},B={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function H($){return t.concat("(?!",$.join("|"),")")}const Y={match:t.concat(/\b/,H([...fj,"super","import","await"].map($=>`${$}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},ie={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},Q={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},I]},le="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",U={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(le)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[I]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:C,CLASS_REFERENCE:M},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),O,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,v,_,N,{match:/\$\d+/},m,M,{scope:"attr",match:r+t.lookahead(":"),relevance:0},U,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[N,e.REGEXP_MODE,{className:"function",begin:le,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:c,contains:C}]}]},{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"]}]}]},z,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[I,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},ie,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[I]},Y,B,A,Q,{match:/\$[(.]/}]}}function LB(e){const t=e.regex,n=MB(e),r=lh,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]},c={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},u=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],h={$pattern:lh,keyword:lj.concat(u),literal:cj,built_in:pj.concat(o),"variable.language":hj},f={className:"meta",begin:"@"+r},m=(v,_,x)=>{const N=v.contains.findIndex(T=>T.label===_);if(N===-1)throw new Error("can not find mode to replace");v.contains.splice(N,1,x)};Object.assign(n.keywords,h),n.exports.PARAMS_CONTAINS.push(f);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([f,s,a,y]),m(n,"shebang",e.SHEBANG()),m(n,"use_strict",c);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 PB(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:/\)/}),c=e.inherit(e.APOS_STRING_MODE,{className:"string"}),u=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),h={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,c,a,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[s,a,u,c]}]}]},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:[h],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:"css"}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[h],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:h}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function DB(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]},c=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},_=[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],x=[..._];return x.pop(),x.push(c),y.contains=x,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:_}}var hg,p1;function zB(){if(p1)return hg;p1=1;function e(P){return P instanceof Map?P.clear=P.delete=P.set=function(){throw new Error("map is read-only")}:P instanceof Set&&(P.add=P.clear=P.delete=function(){throw new Error("set is read-only")}),Object.freeze(P),Object.getOwnPropertyNames(P).forEach(ne=>{const Se=P[ne],Ge=typeof Se;(Ge==="object"||Ge==="function")&&!Object.isFrozen(Se)&&e(Se)}),P}class t{constructor(ne){ne.data===void 0&&(ne.data={}),this.data=ne.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(P){return P.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(P,...ne){const Se=Object.create(null);for(const Ge in P)Se[Ge]=P[Ge];return ne.forEach(function(Ge){for(const It in Ge)Se[It]=Ge[It]}),Se}const o="</span>",s=P=>!!P.scope,a=(P,{prefix:ne})=>{if(P.startsWith("language:"))return P.replace("language:","language-");if(P.includes(".")){const Se=P.split(".");return[`${ne}${Se.shift()}`,...Se.map((Ge,It)=>`${Ge}${"_".repeat(It+1)}`)].join(" ")}return`${ne}${P}`};class c{constructor(ne,Se){this.buffer="",this.classPrefix=Se.classPrefix,ne.walk(this)}addText(ne){this.buffer+=n(ne)}openNode(ne){if(!s(ne))return;const Se=a(ne.scope,{prefix:this.classPrefix});this.span(Se)}closeNode(ne){s(ne)&&(this.buffer+=o)}value(){return this.buffer}span(ne){this.buffer+=`<span class="${ne}">`}}const u=(P={})=>{const ne={children:[]};return Object.assign(ne,P),ne};class h{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(ne){this.top.children.push(ne)}openNode(ne){const Se=u({scope:ne});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(ne){return this.constructor._walk(ne,this.rootNode)}static _walk(ne,Se){return typeof Se=="string"?ne.addText(Se):Se.children&&(ne.openNode(Se),Se.children.forEach(Ge=>this._walk(ne,Ge)),ne.closeNode(Se)),ne}static _collapse(ne){typeof ne!="string"&&ne.children&&(ne.children.every(Se=>typeof Se=="string")?ne.children=[ne.children.join("")]:ne.children.forEach(Se=>{h._collapse(Se)}))}}class f extends h{constructor(ne){super(),this.options=ne}addText(ne){ne!==""&&this.add(ne)}startScope(ne){this.openNode(ne)}endScope(){this.closeNode()}__addSublanguage(ne,Se){const Ge=ne.root;Se&&(Ge.scope=`language:${Se}`),this.add(Ge)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function m(P){return P?typeof P=="string"?P:P.source:null}function g(P){return v("(?=",P,")")}function y(P){return v("(?:",P,")*")}function w(P){return v("(?:",P,")?")}function v(...P){return P.map(Se=>m(Se)).join("")}function _(P){const ne=P[P.length-1];return typeof ne=="object"&&ne.constructor===Object?(P.splice(P.length-1,1),ne):{}}function x(...P){return"("+(_(P).capture?"":"?:")+P.map(Ge=>m(Ge)).join("|")+")"}function N(P){return new RegExp(P.toString()+"|").exec("").length-1}function T(P,ne){const Se=P&&P.exec(ne);return Se&&Se.index===0}const j=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function C(P,{joinWith:ne}){let Se=0;return P.map(Ge=>{Se+=1;const It=Se;let Pt=m(Ge),De="";for(;Pt.length>0;){const ze=j.exec(Pt);if(!ze){De+=Pt;break}De+=Pt.substring(0,ze.index),Pt=Pt.substring(ze.index+ze[0].length),ze[0][0]==="\\"&&ze[1]?De+="\\"+String(Number(ze[1])+It):(De+=ze[0],ze[0]==="("&&Se++)}return De}).map(Ge=>`(${Ge})`).join(ne)}const I=/\b\B/,A="[a-zA-Z]\\w*",M="[a-zA-Z_]\\w*",O="\\b\\d+(\\.\\d+)?",z="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",B="\\b(0b[01]+)",H="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",Y=(P={})=>{const ne=/^#![ ]*\//;return P.binary&&(P.begin=v(ne,/.*\b/,P.binary,/\b.*/)),r({scope:"meta",begin:ne,end:/$/,relevance:0,"on:begin":(Se,Ge)=>{Se.index!==0&&Ge.ignoreMatch()}},P)},ie={begin:"\\\\[\\s\\S]",relevance:0},Q={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[ie]},le={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[ie]},U={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/},$=function(P,ne,Se={}){const Ge=r({scope:"comment",begin:P,end:ne,contains:[]},Se);Ge.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 It=x("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 Ge.contains.push({begin:v(/[ ]+/,"(",It,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Ge},q=$("//","$"),V=$("/\\*","\\*/"),W=$("#","$"),re={scope:"number",begin:O,relevance:0},fe={scope:"number",begin:z,relevance:0},pe={scope:"number",begin:B,relevance:0},Te={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[ie,{begin:/\[/,end:/\]/,relevance:0,contains:[ie]}]},je={scope:"title",begin:A,relevance:0},de={scope:"title",begin:M,relevance:0},J={begin:"\\.\\s*"+M,relevance:0};var ve=Object.freeze({__proto__:null,APOS_STRING_MODE:Q,BACKSLASH_ESCAPE:ie,BINARY_NUMBER_MODE:pe,BINARY_NUMBER_RE:B,COMMENT:$,C_BLOCK_COMMENT_MODE:V,C_LINE_COMMENT_MODE:q,C_NUMBER_MODE:fe,C_NUMBER_RE:z,END_SAME_AS_BEGIN:function(P){return Object.assign(P,{"on:begin":(ne,Se)=>{Se.data._beginMatch=ne[1]},"on:end":(ne,Se)=>{Se.data._beginMatch!==ne[1]&&Se.ignoreMatch()}})},HASH_COMMENT_MODE:W,IDENT_RE:A,MATCH_NOTHING_RE:I,METHOD_GUARD:J,NUMBER_MODE:re,NUMBER_RE:O,PHRASAL_WORDS_MODE:U,QUOTE_STRING_MODE:le,REGEXP_MODE:Te,RE_STARTERS_RE:H,SHEBANG:Y,TITLE_MODE:je,UNDERSCORE_IDENT_RE:M,UNDERSCORE_TITLE_MODE:de});function ce(P,ne){P.input[P.index-1]==="."&&ne.ignoreMatch()}function ae(P,ne){P.className!==void 0&&(P.scope=P.className,delete P.className)}function xe(P,ne){ne&&P.beginKeywords&&(P.begin="\\b("+P.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",P.__beforeBegin=ce,P.keywords=P.keywords||P.beginKeywords,delete P.beginKeywords,P.relevance===void 0&&(P.relevance=0))}function Re(P,ne){Array.isArray(P.illegal)&&(P.illegal=x(...P.illegal))}function ge(P,ne){if(P.match){if(P.begin||P.end)throw new Error("begin & end are not supported with match");P.begin=P.match,delete P.match}}function Ee(P,ne){P.relevance===void 0&&(P.relevance=1)}const We=(P,ne)=>{if(!P.beforeMatch)return;if(P.starts)throw new Error("beforeMatch cannot be used with starts");const Se=Object.assign({},P);Object.keys(P).forEach(Ge=>{delete P[Ge]}),P.keywords=Se.keywords,P.begin=v(Se.beforeMatch,g(Se.begin)),P.starts={relevance:0,contains:[Object.assign(Se,{endsParent:!0})]},P.relevance=0,delete Se.beforeMatch},Ye=["of","and","for","in","not","or","if","then","parent","list","value"],ln="keyword";function cn(P,ne,Se=ln){const Ge=Object.create(null);return typeof P=="string"?It(Se,P.split(" ")):Array.isArray(P)?It(Se,P):Object.keys(P).forEach(function(Pt){Object.assign(Ge,cn(P[Pt],ne,Pt))}),Ge;function It(Pt,De){ne&&(De=De.map(ze=>ze.toLowerCase())),De.forEach(function(ze){const Ke=ze.split("|");Ge[Ke[0]]=[Pt,gt(Ke[0],Ke[1])]})}}function gt(P,ne){return ne?Number(ne):Ue(P)?0:1}function Ue(P){return Ye.includes(P.toLowerCase())}const zt={},pt=P=>{console.error(P)},At=(P,...ne)=>{console.log(`WARN: ${P}`,...ne)},Kt=(P,ne)=>{zt[`${P}/${ne}`]||(console.log(`Deprecated as of ${P}. ${ne}`),zt[`${P}/${ne}`]=!0)},xt=new Error;function un(P,ne,{key:Se}){let Ge=0;const It=P[Se],Pt={},De={};for(let ze=1;ze<=ne.length;ze++)De[ze+Ge]=It[ze],Pt[ze+Ge]=!0,Ge+=N(ne[ze-1]);P[Se]=De,P[Se]._emit=Pt,P[Se]._multi=!0}function Ct(P){if(Array.isArray(P.begin)){if(P.skip||P.excludeBegin||P.returnBegin)throw pt("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),xt;if(typeof P.beginScope!="object"||P.beginScope===null)throw pt("beginScope must be object"),xt;un(P,P.begin,{key:"beginScope"}),P.begin=C(P.begin,{joinWith:""})}}function Ut(P){if(Array.isArray(P.end)){if(P.skip||P.excludeEnd||P.returnEnd)throw pt("skip, excludeEnd, returnEnd not compatible with endScope: {}"),xt;if(typeof P.endScope!="object"||P.endScope===null)throw pt("endScope must be object"),xt;un(P,P.end,{key:"endScope"}),P.end=C(P.end,{joinWith:""})}}function Et(P){P.scope&&typeof P.scope=="object"&&P.scope!==null&&(P.beginScope=P.scope,delete P.scope)}function er(P){Et(P),typeof P.beginScope=="string"&&(P.beginScope={_wrap:P.beginScope}),typeof P.endScope=="string"&&(P.endScope={_wrap:P.endScope}),Ct(P),Ut(P)}function Qt(P){function ne(De,ze){return new RegExp(m(De),"m"+(P.case_insensitive?"i":"")+(P.unicodeRegex?"u":"")+(ze?"g":""))}class Se{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(ze,Ke){Ke.position=this.position++,this.matchIndexes[this.matchAt]=Ke,this.regexes.push([Ke,ze]),this.matchAt+=N(ze)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const ze=this.regexes.map(Ke=>Ke[1]);this.matcherRe=ne(C(ze,{joinWith:"|"}),!0),this.lastIndex=0}exec(ze){this.matcherRe.lastIndex=this.lastIndex;const Ke=this.matcherRe.exec(ze);if(!Ke)return null;const Vt=Ke.findIndex((yn,_t)=>_t>0&&yn!==void 0),Yt=this.matchIndexes[Vt];return Ke.splice(0,Vt),Object.assign(Ke,Yt)}}class Ge{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(ze){if(this.multiRegexes[ze])return this.multiRegexes[ze];const Ke=new Se;return this.rules.slice(ze).forEach(([Vt,Yt])=>Ke.addRule(Vt,Yt)),Ke.compile(),this.multiRegexes[ze]=Ke,Ke}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(ze,Ke){this.rules.push([ze,Ke]),Ke.type==="begin"&&this.count++}exec(ze){const Ke=this.getMatcher(this.regexIndex);Ke.lastIndex=this.lastIndex;let Vt=Ke.exec(ze);if(this.resumingScanAtSamePosition()&&!(Vt&&Vt.index===this.lastIndex)){const Yt=this.getMatcher(0);Yt.lastIndex=this.lastIndex+1,Vt=Yt.exec(ze)}return Vt&&(this.regexIndex+=Vt.position+1,this.regexIndex===this.count&&this.considerAll()),Vt}}function It(De){const ze=new Ge;return De.contains.forEach(Ke=>ze.addRule(Ke.begin,{rule:Ke,type:"begin"})),De.terminatorEnd&&ze.addRule(De.terminatorEnd,{type:"end"}),De.illegal&&ze.addRule(De.illegal,{type:"illegal"}),ze}function Pt(De,ze){const Ke=De;if(De.isCompiled)return Ke;[ae,ge,er,We].forEach(Yt=>Yt(De,ze)),P.compilerExtensions.forEach(Yt=>Yt(De,ze)),De.__beforeBegin=null,[xe,Re,Ee].forEach(Yt=>Yt(De,ze)),De.isCompiled=!0;let Vt=null;return typeof De.keywords=="object"&&De.keywords.$pattern&&(De.keywords=Object.assign({},De.keywords),Vt=De.keywords.$pattern,delete De.keywords.$pattern),Vt=Vt||/\w+/,De.keywords&&(De.keywords=cn(De.keywords,P.case_insensitive)),Ke.keywordPatternRe=ne(Vt,!0),ze&&(De.begin||(De.begin=/\B|\b/),Ke.beginRe=ne(Ke.begin),!De.end&&!De.endsWithParent&&(De.end=/\B|\b/),De.end&&(Ke.endRe=ne(Ke.end)),Ke.terminatorEnd=m(Ke.end)||"",De.endsWithParent&&ze.terminatorEnd&&(Ke.terminatorEnd+=(De.end?"|":"")+ze.terminatorEnd)),De.illegal&&(Ke.illegalRe=ne(De.illegal)),De.contains||(De.contains=[]),De.contains=[].concat(...De.contains.map(function(Yt){return Zn(Yt==="self"?De:Yt)})),De.contains.forEach(function(Yt){Pt(Yt,Ke)}),De.starts&&Pt(De.starts,ze),Ke.matcher=It(Ke),Ke}if(P.compilerExtensions||(P.compilerExtensions=[]),P.contains&&P.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return P.classNameAliases=r(P.classNameAliases||{}),Pt(P)}function Nn(P){return P?P.endsWithParent||Nn(P.starts):!1}function Zn(P){return P.variants&&!P.cachedVariants&&(P.cachedVariants=P.variants.map(function(ne){return r(P,{variants:null},ne)})),P.cachedVariants?P.cachedVariants:Nn(P)?r(P,{starts:P.starts?r(P.starts):null}):Object.isFrozen(P)?r(P):P}var nn="11.11.2";class X extends Error{constructor(ne,Se){super(ne),this.name="HTMLInjectionError",this.html=Se}}const be=n,Ve=r,Qe=Symbol("nomatch"),Ht=7,St=function(P){const ne=Object.create(null),Se=Object.create(null),Ge=[];let It=!0;const Pt="Could not find the language '{}', did you forget to load/include a language module?",De={disableAutodetect:!0,name:"Plain text",contains:[]};let ze={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:f};function Ke($e){return ze.noHighlightRe.test($e)}function Vt($e){let qe=$e.className+" ";qe+=$e.parentNode?$e.parentNode.className:"";const kt=ze.languageDetectRe.exec(qe);if(kt){const ut=Ln(kt[1]);return ut||(At(Pt.replace("{}",kt[1])),At("Falling back to no-highlight mode for this block.",$e)),ut?kt[1]:"no-highlight"}return qe.split(/\s+/).find(ut=>Ke(ut)||Ln(ut))}function Yt($e,qe,kt){let ut="",fn="";typeof qe=="object"?(ut=$e,kt=qe.ignoreIllegals,fn=qe.language):(Kt("10.7.0","highlight(lang, code, ...args) has been deprecated."),Kt("10.7.0",`Please use highlight(code, options) instead.
210
- https://github.com/highlightjs/highlight.js/issues/2277`),fn=$e,ut=qe),kt===void 0&&(kt=!0);const Wt={code:ut,language:fn};Un("before:highlight",Wt);const sn=Wt.result?Wt.result:yn(Wt.language,Wt.code,kt);return sn.code=Wt.code,Un("after:highlight",sn),sn}function yn($e,qe,kt,ut){const fn=Object.create(null);function Wt(K,ue){return K.keywords[ue]}function sn(){if(!Nt.keywords){Tn.addText(Jt);return}let K=0;Nt.keywordPatternRe.lastIndex=0;let ue=Nt.keywordPatternRe.exec(Jt),ke="";for(;ue;){ke+=Jt.substring(K,ue.index);const Le=ar.case_insensitive?ue[0].toLowerCase():ue[0],He=Wt(Nt,Le);if(He){const[Ot,hn]=He;if(Tn.addText(ke),ke="",fn[Le]=(fn[Le]||0)+1,fn[Le]<=Ht&&(qr+=hn),Ot.startsWith("_"))ke+=ue[0];else{const nr=ar.classNameAliases[Ot]||Ot;Pn(ue[0],nr)}}else ke+=ue[0];K=Nt.keywordPatternRe.lastIndex,ue=Nt.keywordPatternRe.exec(Jt)}ke+=Jt.substring(K),Tn.addText(ke)}function tr(){if(Jt==="")return;let K=null;if(typeof Nt.subLanguage=="string"){if(!ne[Nt.subLanguage]){Tn.addText(Jt);return}K=yn(Nt.subLanguage,Jt,!0,jo[Nt.subLanguage]),jo[Nt.subLanguage]=K._top}else K=gn(Jt,Nt.subLanguage.length?Nt.subLanguage:null);Nt.relevance>0&&(qr+=K.relevance),Tn.__addSublanguage(K._emitter,K.language)}function An(){Nt.subLanguage!=null?tr():sn(),Jt=""}function Pn(K,ue){K!==""&&(Tn.startScope(ue),Tn.addText(K),Tn.endScope())}function br(K,ue){let ke=1;const Le=ue.length-1;for(;ke<=Le;){if(!K._emit[ke]){ke++;continue}const He=ar.classNameAliases[K[ke]]||K[ke],Ot=ue[ke];He?Pn(Ot,He):(Jt=Ot,sn(),Jt=""),ke++}}function Z(K,ue){return K.scope&&typeof K.scope=="string"&&Tn.openNode(ar.classNameAliases[K.scope]||K.scope),K.beginScope&&(K.beginScope._wrap?(Pn(Jt,ar.classNameAliases[K.beginScope._wrap]||K.beginScope._wrap),Jt=""):K.beginScope._multi&&(br(K.beginScope,ue),Jt="")),Nt=Object.create(K,{parent:{value:Nt}}),Nt}function we(K,ue,ke){let Le=T(K.endRe,ke);if(Le){if(K["on:end"]){const He=new t(K);K["on:end"](ue,He),He.isMatchIgnored&&(Le=!1)}if(Le){for(;K.endsParent&&K.parent;)K=K.parent;return K}}if(K.endsWithParent)return we(K.parent,ue,ke)}function Ze(K){return Nt.matcher.regexIndex===0?(Jt+=K[0],1):(F=!0,0)}function qt(K){const ue=K[0],ke=K.rule,Le=new t(ke),He=[ke.__beforeBegin,ke["on:begin"]];for(const Ot of He)if(Ot&&(Ot(K,Le),Le.isMatchIgnored))return Ze(ue);return ke.skip?Jt+=ue:(ke.excludeBegin&&(Jt+=ue),An(),!ke.returnBegin&&!ke.excludeBegin&&(Jt=ue)),Z(ke,K),ke.returnBegin?0:ue.length}function wt(K){const ue=K[0],ke=qe.substring(K.index),Le=we(Nt,K,ke);if(!Le)return Qe;const He=Nt;Nt.endScope&&Nt.endScope._wrap?(An(),Pn(ue,Nt.endScope._wrap)):Nt.endScope&&Nt.endScope._multi?(An(),br(Nt.endScope,K)):He.skip?Jt+=ue:(He.returnEnd||He.excludeEnd||(Jt+=ue),An(),He.excludeEnd&&(Jt=ue));do Nt.scope&&Tn.closeNode(),!Nt.skip&&!Nt.subLanguage&&(qr+=Nt.relevance),Nt=Nt.parent;while(Nt!==Le.parent);return Le.starts&&Z(Le.starts,K),He.returnEnd?0:ue.length}function dn(){const K=[];for(let ue=Nt;ue!==ar;ue=ue.parent)ue.scope&&K.unshift(ue.scope);K.forEach(ue=>Tn.openNode(ue))}let ir={};function mr(K,ue){const ke=ue&&ue[0];if(Jt+=K,ke==null)return An(),0;if(ir.type==="begin"&&ue.type==="end"&&ir.index===ue.index&&ke===""){if(Jt+=qe.slice(ue.index,ue.index+1),!It){const Le=new Error(`0 width match regex (${$e})`);throw Le.languageName=$e,Le.badRule=ir.rule,Le}return 1}if(ir=ue,ue.type==="begin")return qt(ue);if(ue.type==="illegal"&&!kt){const Le=new Error('Illegal lexeme "'+ke+'" for mode "'+(Nt.scope||"<unnamed>")+'"');throw Le.mode=Nt,Le}else if(ue.type==="end"){const Le=wt(ue);if(Le!==Qe)return Le}if(ue.type==="illegal"&&ke==="")return ue.index===qe.length||(Jt+=`
211
- `),1;if(Ce>1e5&&Ce>ue.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Jt+=ke,ke.length}const ar=Ln($e);if(!ar)throw pt(Pt.replace("{}",$e)),new Error('Unknown language: "'+$e+'"');const po=Qt(ar);let Zt="",Nt=ut||po;const jo={},Tn=new ze.__emitter(ze);dn();let Jt="",qr=0,Mr=0,Ce=0,F=!1;try{if(ar.__emitTokens)ar.__emitTokens(qe,Tn);else{for(Nt.matcher.considerAll();;){Ce++,F?F=!1:Nt.matcher.considerAll(),Nt.matcher.lastIndex=Mr;const K=Nt.matcher.exec(qe);if(!K)break;const ue=qe.substring(Mr,K.index),ke=mr(ue,K);Mr=K.index+ke}mr(qe.substring(Mr))}return Tn.finalize(),Zt=Tn.toHTML(),{language:$e,value:Zt,relevance:qr,illegal:!1,_emitter:Tn,_top:Nt}}catch(K){if(K.message&&K.message.includes("Illegal"))return{language:$e,value:be(qe),illegal:!0,relevance:0,_illegalBy:{message:K.message,index:Mr,context:qe.slice(Mr-100,Mr+100),mode:K.mode,resultSoFar:Zt},_emitter:Tn};if(It)return{language:$e,value:be(qe),illegal:!1,relevance:0,errorRaised:K,_emitter:Tn,_top:Nt};throw K}}function _t($e){const qe={value:be($e),illegal:!1,relevance:0,_top:De,_emitter:new ze.__emitter(ze)};return qe._emitter.addText($e),qe}function gn($e,qe){qe=qe||ze.languages||Object.keys(ne);const kt=_t($e),ut=qe.filter(Ln).filter(Gn).map(An=>yn(An,$e,!1));ut.unshift(kt);const fn=ut.sort((An,Pn)=>{if(An.relevance!==Pn.relevance)return Pn.relevance-An.relevance;if(An.language&&Pn.language){if(Ln(An.language).supersetOf===Pn.language)return 1;if(Ln(Pn.language).supersetOf===An.language)return-1}return 0}),[Wt,sn]=fn,tr=Wt;return tr.secondBest=sn,tr}function xn($e,qe,kt){const ut=qe&&Se[qe]||kt;$e.classList.add("hljs"),$e.classList.add(`language-${ut}`)}function Rt($e){let qe=null;const kt=Vt($e);if(Ke(kt))return;if(Un("before:highlightElement",{el:$e,language:kt}),$e.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",$e);return}if($e.children.length>0&&(ze.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($e)),ze.throwUnescapedHTML))throw new X("One of your code blocks includes unescaped HTML.",$e.innerHTML);qe=$e;const ut=qe.textContent,fn=kt?Yt(ut,{language:kt,ignoreIllegals:!0}):gn(ut);$e.innerHTML=fn.value,$e.dataset.highlighted="yes",xn($e,kt,fn.language),$e.result={language:fn.language,re:fn.relevance,relevance:fn.relevance},fn.secondBest&&($e.secondBest={language:fn.secondBest.language,relevance:fn.secondBest.relevance}),Un("after:highlightElement",{el:$e,result:fn,text:ut})}function Mn($e){ze=Ve(ze,$e)}const rn=()=>{Ne(),Kt("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function cr(){Ne(),Kt("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let se=!1;function Ne(){function $e(){Ne()}if(document.readyState==="loading"){se||window.addEventListener("DOMContentLoaded",$e,!1),se=!0;return}document.querySelectorAll(ze.cssSelector).forEach(Rt)}function rt($e,qe){let kt=null;try{kt=qe(P)}catch(ut){if(pt("Language definition for '{}' could not be registered.".replace("{}",$e)),It)pt(ut);else throw ut;kt=De}kt.name||(kt.name=$e),ne[$e]=kt,kt.rawDefinition=qe.bind(null,P),kt.aliases&&Or(kt.aliases,{languageName:$e})}function yt($e){delete ne[$e];for(const qe of Object.keys(Se))Se[qe]===$e&&delete Se[qe]}function jt(){return Object.keys(ne)}function Ln($e){return $e=($e||"").toLowerCase(),ne[$e]||ne[Se[$e]]}function Or($e,{languageName:qe}){typeof $e=="string"&&($e=[$e]),$e.forEach(kt=>{Se[kt.toLowerCase()]=qe})}function Gn($e){const qe=Ln($e);return qe&&!qe.disableAutodetect}function Xt($e){$e["before:highlightBlock"]&&!$e["before:highlightElement"]&&($e["before:highlightElement"]=qe=>{$e["before:highlightBlock"](Object.assign({block:qe.el},qe))}),$e["after:highlightBlock"]&&!$e["after:highlightElement"]&&($e["after:highlightElement"]=qe=>{$e["after:highlightBlock"](Object.assign({block:qe.el},qe))})}function Qr($e){Xt($e),Ge.push($e)}function ft($e){const qe=Ge.indexOf($e);qe!==-1&&Ge.splice(qe,1)}function Un($e,qe){const kt=$e;Ge.forEach(function(ut){ut[kt]&&ut[kt](qe)})}function ot($e){return Kt("10.7.0","highlightBlock will be removed entirely in v12.0"),Kt("10.7.0","Please use highlightElement now."),Rt($e)}Object.assign(P,{highlight:Yt,highlightAuto:gn,highlightAll:Ne,highlightElement:Rt,highlightBlock:ot,configure:Mn,initHighlighting:rn,initHighlightingOnLoad:cr,registerLanguage:rt,unregisterLanguage:yt,listLanguages:jt,getLanguage:Ln,registerAliases:Or,autoDetection:Gn,inherit:Ve,addPlugin:Qr,removePlugin:ft}),P.debugMode=function(){It=!1},P.safeMode=function(){It=!0},P.versionString=nn,P.regex={concat:v,lookahead:g,either:x,optional:w,anyNumberOfTimes:y};for(const $e in ve)typeof ve[$e]=="object"&&e(ve[$e]);return Object.assign(P,ve),P},bn=St({});return bn.newInstance=()=>St({}),hg=bn,bn.HighlightJS=bn,bn.default=bn,hg}var FB=zB();const BB=xE(FB),m1={},UB="hljs-";function HB(e){const t=BB.newInstance();return e&&s(e),{highlight:n,highlightAuto:r,listLanguages:o,register:s,registerAlias:a,registered:c};function n(u,h,f){const m=f||m1,g=typeof m.prefix=="string"?m.prefix:UB;if(!t.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");t.configure({__emitter:WB,classPrefix:g});const y=t.highlight(h,{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,h){const m=(h||m1).subset||o();let g=-1,y=0,w;for(;++g<m.length;){const v=m[g];if(!t.getLanguage(v))continue;const _=n(v,u,h);_.data&&_.data.relevance!==void 0&&_.data.relevance>y&&(y=_.data.relevance,w=_)}return w||{type:"root",children:[],data:{language:void 0,relevance:y}}}function o(){return t.listLanguages()}function s(u,h){if(typeof u=="string")t.registerLanguage(u,h);else{let f;for(f in u)Object.hasOwn(u,f)&&t.registerLanguage(f,u[f])}}function a(u,h){if(typeof u=="string")t.registerAliases(typeof h=="string"?h:[...h],{languageName:u});else{let f;for(f in u)if(Object.hasOwn(u,f)){const m=u[f];t.registerAliases(typeof m=="string"?m:[...m],{languageName:f})}}}function c(u){return!!t.getLanguage(u)}}class WB{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,c){return c?a+"_".repeat(c):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 mj=HB({bash:fB,css:bB,go:xB,ini:EB,javascript:jB,json:AB,markdown:IB,python:RB,rust:OB,typescript:LB,xml:PB,yaml:DB}),g1={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 xy(e,t){const n=e&&(g1[e]??(mj.registered(e)?e:null));if(n)return n;const r=t.lastIndexOf("."),o=r<0?"":t.slice(r+1).toLowerCase();return(o?g1[o]:null)??null}const KB=/^(?:diff --git a\/\S+ b\/(\S+)|\+\+\+ (?:b\/)?(\S+))$/gm;function qB(e){const t=new Set;for(const n of e.matchAll(KB)){const r=n[1]??n[2]??"";r&&r!=="/dev/null"&&t.add(r)}return t.size===1?[...t][0]:""}const ZB={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 gj(e,t){const n=[[]],r=(s,a)=>{const c=s.split(`
212
- `);for(const[u,h]of c.entries()){if(u>0&&n.push([]),!h)continue;const f=n[n.length-1],m=f[f.length-1];m&&m.scope===a?m.text+=h:f.push({text:h,scope:a})}},o=(s,a)=>{for(const c of s)c.type==="text"?r(c.value,a):c.type==="element"&&o(c.children,GB(c)??a)};try{o(mj.highlight(t,e).children,"")}catch{return e.split(`
213
- `).map(s=>s?[{text:s,scope:""}]:[])}return n}function GB(e){var r;const t=((r=e.properties)==null?void 0:r.className)??[];let n=null;for(const o of t){const s=ZB[o.startsWith("hljs-")?o.slice(5):o];s&&(n=s)}return n}const k1=/^\d+\t/;function Ey(e,t){if(!t)return[];const n=e.split(`
214
- `),r=k1.test(n[0]??""),o=r?n.map(a=>{var c;return((c=k1.exec(a))==null?void 0:c[0])??""}):[],s=r?n.map((a,c)=>a.slice(o[c].length)).join(`
215
- `):e;return gj(s,t).map((a,c)=>{const u=a.map(f=>({text:f.text,changed:!1,scope:f.scope})),h=o[c];return h?[{text:h,changed:!1,scope:""},...u]:u})}function VB(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"||(YB(e,o,s,t,n),o=s+1)}}return e.map((o,s)=>eU(o.spans,n[s],o.text))}function YB(e,t,n,r,o){var s,a;for(const c of["del","add"]){const u=[];for(let m=t;m<n;m++){const g=(s=e[m])==null?void 0:s.kind;(g===""||g===c)&&u.push(m)}if(u.length===0)continue;const h=u.map(m=>{var g;return((g=e[m])==null?void 0:g.text)??""}).join(`
216
- `),f=gj(h,r);for(const[m,g]of u.entries())(c==="add"||((a=e[g])==null?void 0:a.kind)==="del")&&(o[g]=f[m])}}const sp="link",XB=/https?:\/\/[^\s<>"'`]+/g,kj=/https?:\/\//;function QB(e){const t=[];for(const n of e.matchAll(XB)){const r=n.index+JB(n[0]).length;r>n.index&&t.push({start:n.index,end:r})}return t}const w1={")":"(","]":"[","}":"{"};function JB(e){let t=e.length;for(;t>0;){const n=e[t-1];if(".,;:!?".includes(n))t--;else if(w1[n]&&y1(e.slice(0,t),w1[n])<y1(e.slice(0,t),n))t--;else break}return e.slice(0,t)}function y1(e,t){let n=0;for(const r of e)r===t&&n++;return n}function wj(e){const t=e.map(c=>c.text).join("");if(!kj.test(t))return e;const n=QB(t);if(!n.length)return e;const r=[];let o=0,s=0,a=null;for(const c of e){let u=0;for(;u<c.text.length;){const h=n[s],f=o+u;if(h&&f>=h.start){const m=Math.min(h.end,o+c.text.length)-f;a||(a={text:"",changed:!1,scope:sp},r.push(a)),a.text+=c.text.slice(u,u+m),a.changed||(a.changed=c.changed),u+=m,f+m>=h.end&&(a=null,s++)}else{const m=h?Math.min(h.start-o,c.text.length):c.text.length;r.push({text:c.text.slice(u,m),changed:c.changed,scope:c.scope}),u=m}}o+=c.text.length}return r}const Sk=e=>e.map(wj);function yj(e){return kj.test(e)?e.split(`
217
- `).map(t=>wj(t?[{text:t,changed:!1,scope:""}]:[])):[]}function vj(e){const t=e[e.length-1],n=t==null?void 0:t[t.length-1];return!n||n.scope!==sp?e:[...e.slice(0,-1),[...t.slice(0,-1),{...n,scope:""}]]}function eU(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,c=0,u=0,h=0;for(;a<o.length&&c<s.length;){const f=o[a],m=s[c],g=Math.min(f.text.length-u,m.text.length-h);if(g>0){const y={text:f.text.slice(u,u+g),changed:f.changed,scope:m.scope},w=r[r.length-1];w&&w.changed===y.changed&&w.scope===y.scope?w.text+=y.text:r.push(y)}u+=g,h+=g,u>=f.text.length&&(a++,u=0),h>=m.text.length&&(c++,h=0)}return r}En.use({extensions:[W9,lB(()=>$n==null?void 0:$n.worktrees)],renderer:{code({text:e,lang:t}){const n=xy((t??"").trim().toLowerCase().split(/\s+/)[0]??"","");let r=n?Sk(Ey(e,n)):yj(e);return r.length?($n!=null&&$n.streaming&&Lf.trimEnd().endsWith(e.trimEnd())&&(r=vj(r)),`<pre><code>${r.map(s=>s.map(a=>a.scope===sp?`<a href="${Is(a.text)}">${Is(a.text)}</a>`:a.scope?`<span class="sy-${a.scope}">${Is(a.text)}</span>`:Is(a.text)).join("")).join(`
218
- `)}</code></pre>
219
- `):!1},html(e){return $n!=null&&$n.keepHtml?!1:K9(e)},image({href:e,text:t}){if($n!=null&&$n.base||/^(https?:|data:)/i.test(e))return!1;const n=$n==null?void 0:$n.stills,r=n==null?void 0:n.pictures.find(u=>u.path===e),o=Is(t);if(r&&n){const u=n.urls.attachment(n.worktreeId,r.file);return`<button type="button" class="md-still" data-file="${bf(r.file)}" data-tip="Open full size" data-tip-placement="follow"><img src="${bf(u)}" alt="${bf(t)}"></button>`}const s=PT(e),a=$n==null?void 0:$n.fileRoot,c=s.startsWith("/")?s:a?`${a}/${s}`:null;return c?`<a href="${bf(c)}">${o}</a>`:o},table:q9}});const bf=e=>Is(e).replace(/"/g,"&quot;"),Sy=P8(window);let $n=null,Lf="";Sy.addHook("uponSanitizeAttribute",(e,t)=>{e.tagName==="A"&&t.attrName==="href"&&(t.attrValue=PT(t.attrValue))});Sy.addHook("afterSanitizeAttributes",e=>{const t=e.tagName==="A"?e.getAttribute("href")??"":"";if(t===ej){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=$n!=null&&$n.fileRoot?LT($n.fileRoot,t):null,r=n?null:DT(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=e8(e.textContent??"");s&&e.setAttribute("data-path",s)}const o=$n==null?void 0:$n.base;if(e.tagName==="IMG"&&o){const s=MT(o.dir,e.getAttribute("src")??"");s&&e.setAttribute("src",o.urls.worktreeFile(o.worktreeId,s,o.version))}});function va(e,t){$n=t??null,Lf=t!=null&&t.streaming?F9(e):e;try{return Sy.sanitize(En.parse(Lf,{async:!1}))}finally{$n=null,Lf=""}}function tU(e,t){const[n,r]=S.useState(e),o=S.useRef(null);return S.useEffect(()=>{if(!t){o.current=null;return}o.current=uB(o.current,e.length,performance.now());let s=0;const a=()=>{const c=o.current;if(!c)return;const u=oj(c,performance.now());r(dB(e,u)),u<c.to&&(s=requestAnimationFrame(a))};return a(),()=>cancelAnimationFrame(s)},[e,t]),t?n:e}function Vu(e,t){var v,_,x,N;const[n,r]=S.useState(()=>va(e,t)),o=S.useRef(0),s=(v=t==null?void 0:t.base)==null?void 0:v.worktreeId,a=(_=t==null?void 0:t.base)==null?void 0:_.dir,c=(x=t==null?void 0:t.base)==null?void 0:x.version,u=(N=t==null?void 0:t.base)==null?void 0:N.urls,h=t==null?void 0:t.fileRoot,f=t==null?void 0:t.worktrees,m=t==null?void 0:t.stills,g=!!(t!=null&&t.keepHtml),y=!!(t!=null&&t.streaming),w=tU(e,y);return S.useEffect(()=>{const T=s!==void 0&&a!==void 0&&u!==void 0?{worktreeId:s,dir:a,version:c??null,urls:u}:void 0,j=T||h||f||m||g||y?{base:T,fileRoot:h,worktrees:f,stills:m,keepHtml:g,streaming:y}:void 0,C=performance.now()-o.current;if(y||C>=ja){o.current=performance.now(),r(va(w,j));return}const I=setTimeout(()=>{o.current=performance.now(),r(va(w,j))},ja-C);return()=>clearTimeout(I)},[w,s,a,c,u,h,f,m,g,y]),n}const nU=/^ {0,3}(`{3,}|~{3,})/,rU=/^#{1,6} \S/,oU=/^\s*(?:[-*+]|\d+[.)]) \S/,sU=/^> ?\S/,iU=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/,aU=/\[[^\]\n]+\]\((?:https?:|\.{0,2}\/|#)[^)\s]*\)/,lU=/\*\*[^\s*][^*\n]*\*\*/;function cU(e){var s,a;const t=e.split(`
220
- `),n=new Set;let r=null,o=0;for(let c=0;c<t.length;c++){const u=t[c],h=(s=nU.exec(u))==null?void 0:s[1];if(r){h!=null&&h.startsWith(r)&&(r=null,n.add("fence"));continue}if(h){r=h;continue}rU.test(u)&&!((a=t[c+1])!=null&&a.trim())&&n.add("heading"),oU.test(u)&&++o===2&&n.add("list"),sU.test(u)&&n.add("quote"),iU.test(u)&&n.add("table"),aU.test(u)&&n.add("link"),lU.test(u)&&n.add("bold")}return n.size}function uU(e,t){if(t)return ku(t)==="markdown"?"rendered":"plain";const n=cU(e);return n>=2?"rendered":n===1?"source":"plain"}function ip({n:e,name:t,source:n,lines:r,chars:o,preview:s,text:a,href:c,onRemove:u,className:h=""}){const f=(n==null?void 0:n.path)??t??"",m=f.includes("/")?f.slice(0,f.lastIndexOf("/")):"",g=n?[m,n.ref?`at ${n.ref.slice(0,7)}`:""].filter(Boolean).join(" "):[m,`${r} ${r===1?"line":"lines"}`,`${o.toLocaleString()} chars`,s].filter(Boolean).join(" · "),y=d.jsxs(d.Fragment,{children:[d.jsx(ht,{name:"text",className:"icon-inline"}),d.jsxs("span",{className:"pick-target",children:[d.jsx("b",{children:t?t.slice(t.lastIndexOf("/")+1):n?ZL(n):IE("paste",e)}),g&&d.jsxs("span",{className:"pick-file row-dim",children:[" · ",g]})]})]}),w=a!==void 0||c!==void 0;return d.jsx(fy,{className:Be("paste-chip",h),label:y,tip:s||void 0,peek:w?d.jsx(Ej,{text:a,href:c}):void 0,full:w?d.jsx(xj,{text:a,href:c,path:f||void 0}):void 0,menu:v=>LF({text:a,href:c},v),removeLabel:"Remove attachment",onRemove:u})}function bj(e,t){const[n,r]=S.useState(e??null),[o,s]=S.useState(!1);return S.useEffect(()=>{if(e!==void 0||!t)return;let a=!0;return fetch(t).then(c=>c.ok?c.text():Promise.reject(new Error(String(c.status)))).then(c=>{a&&r(c)}).catch(()=>{a&&s(!0)}),()=>{a=!1}},[e,t]),{text:e??n,failed:o}}function xj({text:e,href:t,path:n}){const{text:r,failed:o}=bj(e,t),s=S.useMemo(()=>r?uU(r,n):"plain",[r,n]),[a,c]=S.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:()=>c(!u),"data-tip":u?"Text: read it as it was sent":"Preview: read it rendered",children:[d.jsx(ht,{name:u?"text":"book",className:"icon-inline"})," ",u?"text":"preview"]})}),u?d.jsx(dU,{text:r}):d.jsx("pre",{className:"paste-doc-body paste-text",children:r})]})}function dU({text:e}){const t=S.useMemo(()=>va(e),[e]);return d.jsx("div",{className:"paste-doc-body md md-preview",onClick:n=>{const r=n.target.closest("a");r&&r.target!=="_blank"&&n.preventDefault()},dangerouslySetInnerHTML:{__html:t}})}const fU=2e4;function Ej({text:e,href:t}){const{text:n}=bj(e,t);return n?d.jsx("pre",{className:"paste-peek paste-text",children:n.slice(0,fU)}):null}function ap({name:e,bytes:t,href:n,kept:r,uploading:o,progress:s,onRemove:a,className:c=""}){const u=Je();return d.jsx(fy,{className:Be("file-chip",c),label:d.jsxs(d.Fragment,{children:[d.jsx(ht,{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:[" ","· ",Xk(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(Ej,{href:n}):void 0,full:n?d.jsx(xj,{href:n,path:e}):void 0,menu:h=>PF({href:n},h,r&&{...r,sock:u}),removeLabel:"Remove attachment",onRemove:a})}function Sj(e){return e.replace(/^([\t ]*)\*\*(\S(?:[^\n]*\S)?)\*\*([\t ]*)$/gm,"$1$2$3")}const _j=120,hU=/^\*\*(\S(?:[^\n]*\S)?)\*\*$/;function Nj(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=hU.exec(s))==null?void 0:n[1])==null?void 0:r.replace(/`/g,""))??"";if(!a||a.length>_j)return[];t.push(a)}return t}function Tj(e){const t=Nj(e);if(t.length)return t.at(-1);const n=Sj(e).trim().replace(/`/g,"");return n&&!n.includes(`
221
- `)&&n.length<=_j?n:""}const pU={read:"read",edit:"edit",delete:"delete",move:"move",search:"search",execute:"run",think:"think",fetch:"fetch",switch_mode:"mode",other:"tool"},v1={read:"book",edit:"edit",delete:"trash",move:"move",search:"search",execute:"run",think:"bulb",fetch:"globe",switch_mode:"swap",other:"dot"},jj="Skill",$j="ScheduleWakeup",pg=new Map([[qk,"chat"],["Monitor","clock"],[$j,"clock"],["TaskOutput","terminal"],[jj,"layers"],[uA,"handoff"],[dA,"worktrees"],["EnterPlanMode","swap"]]),mU=new Map([["Read","read"],["Edit","edit"],["Write","edit"],["MultiEdit","edit"],["NotebookEdit","edit"],["Bash","execute"],["Grep","search"],["Glob","search"],["WebSearch","search"],["WebFetch","fetch"],["EnterPlanMode","switch_mode"],["ExitPlanMode","switch_mode"]]);function _k(e){var o,s;if(e.name!==ba)return null;const t=/^select:(.*)$/.exec(Ir(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=mU.get(n);return r?{name:n,kind:r}:{name:n}}function gU(e){if(e.name!==jj)return"";const t=Ir(e,"skill").trim();if(!t)return"";const n=Ir(e,"args").trim();return n?`/${t} ${n}`:`/${t}`}const Nk={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"},kU=/(^|\s)(-[A-Za-z]*[iI]|--in-place)/,b1=String.raw`(?:"[^"]*"|'[^']*'|[^\s;&|]+)`,x1=new RegExp(String.raw`^\s*(?:(?:cd|echo)\s+${b1}\s*(?:&&|;)|mkdir(?:\s+${b1})+\s*(?:&&|;)|(?:export\s+)?[A-Za-z_]\w*=(?:"[^"]*"|'[^']*'|[^\s;&|()\`]*)\s*(?:&&|;|(?=\s)))\s*`),wU=/^python[\d.]*$/,yU=new RegExp(`open\\([^)]*,\\s*["'][wax]|(?<!std(?:out|err))\\.write\\(|\\.write_text\\(`);function Cj(e){let t=e;for(let n=t.replace(x1,"");n!==t;n=t.replace(x1,""))t=n;return t}const vU=new RegExp("(?<![0-9&])>{1,2}\\s*(?!\\/dev\\/null|&)[^\\s&>]"),Aj=/&&|;|\n|\|/;function bU(e){return e.split(Aj).some(t=>/^\s*(?:\S*\/)?sed\s/.test(t)&&kU.test(t))}function xU(e){return e.split(/&&|;|\n/).map(t=>Cj(t).trim().split(/\s+/)[0]??"").filter(Boolean).every(t=>Nk[t.slice(t.lastIndexOf("/")+1)]==="trash")}function EU(e){const t=Cj(e).trim(),n=t.split(/\s+/)[0]??"",r=n.slice(n.lastIndexOf("/")+1),o=r==="sed"?bU(e)?void 0:"book":Nk[r];if(o==="book"||o==="search"){const s=t.split(Aj)[0]??"";if(vU.test(s))return r==="cat"&&s.includes("<<")?"edit":void 0}if(!(o==="trash"&&!xU(t)))return o||(wU.test(r)?t.includes("<<")&&yU.test(t)?"edit":void 0:Nk[r])}function Ir(e,t){const n=e.input,r=n?n[t]:void 0;return typeof r=="string"?r:""}const SU=/^(?:\/(?:usr\/)?bin\/)?(?:ba|z|da)?sh\s+(?:-[a-zA-Z]+\s+)*(?:'([^']*)'|"((?:[^"\\]|\\.)*)")\s*$/;function Ij(e){const t=SU.exec(e.trim());return t?t[1]!==void 0?t[1]:(t[2]??"").replace(/\\(["\\$`])/g,"$1"):e}const _U="Guardian Review";function Rj(e){return e.toolKind==="think"&&e.title===_U}function NU(e){const t=o=>{var a,c;return((c=(a=[...e.matchAll(new RegExp(`^${o}:[ \\t]*(.+)$`,"gm"))].at(-1))==null?void 0:a[1])==null?void 0:c.trim().toLowerCase())??""},n=t("Status"),r=t("Risk");return!n||n==="in progress"?"reviewing":r?`${n}, ${r} risk`:n}function Cu(e,t=[]){const n=Ij(Ir(e,"command")),r=e.name===ba?"":Ir(e,"query"),o=e.name===$j?Ir(e,"reason"):"",s=Oj(e)||n||Ir(e,"path")||Ir(e,"pattern")||r||o,a=gA(e.name),c=s||gU(e)||(e.title&&e.title!==e.name?e.title:"")||(a?a.tool:""),u=lp(Ir(e,"description")||(a?Ir(e,"rationale"):"")||c,t),h=e.toolKind&&e.toolKind in v1?e.toolKind:"other",f=pU[h],m=e.name===qk,g=h!=="other"||pg.has(e.name),y=e.name===e.title||e.name===$i||e.name===_E,w=a?a.server:u&&(g||y||e.name===ba)?"":e.name,v=w&&w.toLowerCase()!==f?w:u?"":f,_=(h==="execute"||h==="other")&&n?EU(n):void 0;return{label:m?"ask":f,name:v,icon:pg.get(e.name)??pg.get(e.title??"")??_??(a&&h==="other"?"cube":v1[h]),hint:u===v?"":u,command:n&&n!==u?n:""}}const TU=/^Async agent launched/m;function jU(e){if(!e.subagent)return!1;const t=e.input;return!!e.detached||(t==null?void 0:t.run_in_background)===!0||!!e.output&&TU.test(e.output)}const $U={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 CU(e){const t=e.toolKind;return e.subagent?Ir(e,"prompt")?"":"writing the brief":!wh(e.input)||!TE({name:e.name,kind:t},e.input)?"":Zk(t)?$U[t]:"writing the question"}function Tk(e,t){const n=Mj(t),r=n[0],o=Ir(e,"description");return o&&r&&!r.code&&r.text===o?n.slice(1):n}function Gl(e){return Oj(e)||Ir(e,"path")}function AU(e){return Ir(e,"description")}function Oj(e){return Ir(e,"file_path")||Ir(e,"filepath")||Ir(e,"filePath")||IU(e)}function IU(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 RU=/^(`{3,})([\w+#.-]*)\s*$/;function Mj(e){var c;const t=[];let n=[],r="",o=!1,s=0;const a=()=>{const u=n.join(`
222
- `).replace(/^\n+|\n+$/g,"");u.trim()&&t.push({code:o,diff:OU(u,r),lang:o?r:"",text:u}),n=[]};for(const u of e.split(`
223
- `)){const h=RU.exec(u),f=((c=h==null?void 0:h[1])==null?void 0:c.length)??0;if(!h||o&&(f<s||h[2])){n.push(u);continue}a(),o=!o,s=o?f:0,r=o?(h[2]??"").toLowerCase():""}return a(),t}function OU(e,t){return t==="diff"||t==="patch"||/^diff --git /m.test(e)||/^@@ .*@@/m.test(e)?!0:/^--- /m.test(e)&&/^[+-]/m.test(e)}const MU=/^(diff --git |index [0-9a-f]+\.\.|new file mode |deleted file mode |similarity index |rename (from|to) |Binary files )/;function LU(e){const t=[];for(const n of e.split(`
224
- `)){const r=DU(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 PU(t),t}function PU(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 c=a;for(;((o=e[c])==null?void 0:o.kind)==="add";)c++;const u=e.slice(s,a),h=e.slice(a,c),f=u.length>0&&h.length>0?lI(u.map(m=>m.text).join(`
225
- `),h.map(m=>m.text).join(`
226
- `)):null;f&&(E1(u,K0(f.before)),E1(h,K0(f.after)));for(const m of[...u,...h])m.spans??(m.spans=[]);s=c}}function E1(e,t){if(t.length===e.length)for(const[n,r]of e.entries())r.spans=t[n]}function DU(e){return e.startsWith("@@")?"hunk":e.startsWith("+++")||e.startsWith("---")||MU.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":""}function zU(e){const t=e.tools.at(-1);return t.done||t.parentToolId?!1:t.name===$i?!t.background:!!t.background}const Lj=new Set(["read","edit","fetch"]);function _y(e,t){if(e.isError||!e.toolKind||!Lj.has(e.toolKind)||Zk(e.toolKind)&&wh(e.input))return"";const{hint:n}=Cu(e,t);return n?`${e.parentToolId??""}
227
- ${e.toolKind}
228
- ${n}`:""}function S1(e,t,n){if(!t||!("tools"in t)||e.done||e.isError||!e.toolKind||!Lj.has(e.toolKind))return!1;const r=t.tools[0];return r.toolKind===e.toolKind&&r.parentToolId===e.parentToolId&&_y(r,n)!==""}function FU(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.toolKind!=="edit"||o.parentToolId||!s.done||s.isError?-1:_y(o,t)?n:-1}function Pj(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 BU(e){return!e.done||e.isError?!1:!!e.cut||!e.output&&TE({name:e.name,kind:e.toolKind},e.input)}const _1=new WeakMap;function UU(e,t,n){if(e.name!==ba||e.isError)return e;if(!e.done)return null;if(!_k(e))return t?e:null;if(!t||!n)return null;let r=_1.get(e);if(!r){const o=_k(e),{output:s,title:a,toolKind:c,...u}=e;r={...u,name:o.name,input:{},done:!1,...o.kind?{toolKind:o.kind}:{}},_1.set(e,r)}return r}function HU(e,t){return t&&(e==null?void 0:e.kind)==="tool"&&e.name===ba&&e.done&&!e.isError&&_k(e)!==null}function WU(e,t,n=!1){const r=Pj(e),o=[],s=new Map;let a="";for(const[c,u]of e.entries()){if(u.kind!=="tool"){a="",o.push({at:c,item:u});continue}if(BU(u))continue;const h=UU(u,c===e.length-1,n);if(!h)continue;if(r.has(h.id)){a="";const y={at:c,spawn:h,run:[],end:c};s.set(h.id,{entry:y,key:""}),o.push(y);continue}const f=_y(h,t),m=h.parentToolId?s.get(h.parentToolId):void 0;if(m){const y=m.entry.run,w=y.at(-1);f&&f===m.key&&w?w.tools.push(h):!f&&S1(h,w,t)?w.next=h:y.push({at:c,tools:[h]}),m.key=f,m.entry.end=c;continue}const g=o.at(-1);if(f&&f===a&&g&&"tools"in g){g.tools.push(h);continue}if(!f&&S1(h,g,t)){g.next=h;continue}a=f,o.push({at:c,tools:[h]})}return o}function KU(e){return e.reduce((t,n)=>t+n.tools.length,0)}function qU(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];Du(a)&&(o=!1),!(a.kind!=="tool"||!a.subagent)&&(a.isError?t.delete(a.id):a.done?jU(a)?o&&!n.has(a.id)&&t.add(a.id):t.delete(a.id):t.add(a.id))}return t}function ZU(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&&zU(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 GU(e,t=!1){const n=Pj(e);return HU(e.at(-1),t)?!0:e.some(r=>r.kind==="tool"&&!r.done&&!r.parentToolId&&!r.background&&r.name!==ba&&(!n.has(r.id)||wh(r.input)))}function Dj(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 c=s.tools.at(-1);if(c.done||c.background||c.name===$i)return;const u=NE({name:c.name,kind:c.toolKind});(o||r&&u)&&n.add(a),r=!0,o||(o=u)}),n}function VU(e){return e.findIndex(t=>!t.tools.at(-1).done)}function Ny(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function zj(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)&&Ny(n.tools,t[r].tools)})}function YU(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 c=n.get(s.at),u=c!==void 0&&XU(c,s)?c:s;return u!==e[a]&&(r=!1),u});return r?e:o}function XU(e,t){return"spawn"in e?"spawn"in t&&e.spawn===t.spawn&&e.end===t.end&&zj(e.run,t.run):"tools"in e?"tools"in t&&e.next===t.next&&Ny(e.tools,t.tools):"item"in t&&e.item===t.item}function QU(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"&&!Rj(r))return t;continue}if(n.item.kind==="thinking"){if(!n.item.text.trim())continue;return Tj(n.item.text)?-1:t}if(JU(n.item))return-1}}return-1}function JU(e){return e.kind==="assistant"?!!e.text.trim():e.kind==="ask"?e.ask.kind==="question"||!!e.outcome:!0}function e7(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 cp(e,t,n){if(!t)return[];const r=[];for(const o of e){const s=o.worktree;s.repoId!==t||s.id===n||s.kind!=="worktree"||r.push({id:s.id,title:s.title,branch:s.branch,dir:s.path.slice(s.path.lastIndexOf("/")+1),dot:ps(o),state:Lh(o),at:Ea(s)})}return r}function Fj(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 t7(e,t){return/[/-]/.test(e)?Fj(e,t):null}const N1=e=>e.toLowerCase().replace(/[^a-z0-9]/g,"");function T1(e,t){const n=N1(e);if(!n)return!e.trim();const r=/\s$/.test(e);return[t.title,t.branch].some(o=>{const s=N1(o);return s.includes(n)&&(!r||!s.endsWith(n))})}function lo({id:e,title:t,inert:n}){const r=Je(),o=lt(),s=L(y=>y.visible),a=L(y=>Gt(y,e)),c=L(y=>a?null:Object.values(y.archived).flat().find(w=>w.id===e)??null),u=S.useMemo(()=>a?cp(s,a.worktree.repoId,null).find(y=>y.id===e)??null:null,[s,a,e]),h=(u==null?void 0:u.branch)??(c==null?void 0:c.branch);if(!h)return d.jsx("span",{children:t??e});const f=op(u??{title:(c==null?void 0:c.title)??t??h,archived:!0,branch:h}),m=Ft(f.text,void 0,{placement:"follow",dot:f.dot,detail:f.detail}),g=ep({kind:"worktree",id:e,archived:!u},null,{sock:r,dispatch:o});return d.jsxs("span",{className:"chat-mention","data-worktree":e,"data-branch":h,"data-archived":u?void 0:"",...m,onClick:n?void 0:y=>{y.stopPropagation(),g==null||g()},children:["@",f.text,f.dot&&d.jsx("span",{className:"chat-mention-dot",children:d.jsx("span",{className:`dot ${f.dot}`})})]})}function n7(e){const t=e.body??"";return e.note?`${t.trimEnd()}
229
-
230
- ---
231
-
232
- You added: ${e.note}
233
- `:t}function r7({item:e,worktreeId:t,marked:n,children:r}){Je();const o=lt(),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:n7(e),binary:!1,tooLarge:!1,source:{kind:"text"},seq:So()}})};return d.jsx(Nr,{icon:"handoff",word:s?"plan":"piece",tone:"accent",at:e.ts,"data-state":hr({cursor:n}),below:[e.note?`you added: ${e.note}`:void 0,r],children:d.jsxs("span",{className:"daemon-text",children:["from ",d.jsx(lo,{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 j1({item:e,worktreeId:t}){var y;Je();const n=lt();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")return d.jsx(Nr,{icon:"handoff",word:"handed off",tone:"accent",at:e.ts,children:d.jsx("span",{className:"daemon-text",children:d.jsx("span",{className:"live-text",children:"starting the worktrees"})})});if(e.state==="declined")return d.jsx(Nr,{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},c=e.outcomes.filter(w=>w.fate==="worktree"&&w.worktreeId),u=e.outcomes.filter(w=>w.fate==="worktree"&&w.after),h=e.outcomes.filter(w=>w.fate==="send"&&w.worktreeId),f=e.outcomes.filter(w=>w.fate==="here").length,m=e.outcomes.filter(w=>w.error),g=[];for(const w of c)g.push(d.jsxs("span",{children:[d.jsx(lo,{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(lo,{id:v.id,title:v.branch}):w.after]},w.pieceId))}for(const w of h)g.push(d.jsxs("span",{children:[a(w.pieceId)," sent to ",d.jsx(lo,{id:w.worktreeId,title:w.title}),w.repoName?` in ${w.repoName}`:""]},w.pieceId));return f&&g.push(d.jsx("span",{children:`${f} here`},"here")),d.jsx(Nr,{icon:"handoff",word:"handed off",tone:"accent",at:e.ts,below:m.length?m.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 o7({item:e}){return e.worktreeId?d.jsx(Nr,{icon:"handoff",word:"handed off",tone:"accent",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:[d.jsx(lo,{id:e.worktreeId,title:e.title??"the worktree"})," started, its branch having landed"]})}):d.jsx(Nr,{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 s7({item:e}){return d.jsx(Nr,{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(lo,{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:()=>window.open(e.url,"_blank"),children:"the PR"})]})]})})}function up({src:e,n:t,name:n,width:r,height:o,bytes:s,kept:a,uploading:c,progress:u,onRemove:h,className:f=""}){const m=Je();return d.jsx(fy,{className:Be("image-chip",f),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:IE("image",t)}),d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",n," · ",r,"×",o," · ",Xk(s),u!==void 0?d.jsxs(d.Fragment,{children:[" ","· ",d.jsxs("span",{className:"pick-progress",children:[u,"%"]})]}):c&&" · uploading"]})]})]}),peek:d.jsx("img",{src:e,alt:n,style:{aspectRatio:`${r} / ${o}`}}),full:d.jsx("img",{src:e,alt:n}),menu:g=>Na(e,g,a&&{...a,sock:m}),removeLabel:"Remove image",onRemove:h})}function i7({img:e,worktreeId:t,src:n}){return d.jsx(up,{className:"in-chat",src:n,...e,kept:{worktreeId:t,file:e.file}})}const a7=/(^|\s)@\S/;function Ty({text:e,worktreeId:t,root:n,inField:r}){const o=On(),s=Je(),a=L(w=>{var v;return t?(v=w.local[t])==null?void 0:v.files:void 0}),c=L(w=>w.visible),u=L(w=>{var v;return(v=Gt(w,t))==null?void 0:v.worktree.repoId}),h=L(w=>u?w.archived[u]:void 0),f=S.useMemo(()=>nj(cp(c,u,t),h),[c,h,u,t]),m=S.useMemo(()=>tj(a,f),[a,f]),g=S.useMemo(()=>by(e,m),[e,m]),y=a===void 0&&t&&a7.test(e)?t:null;return S.useEffect(()=>{y&&qh(y,o.getState(),{sock:s,dispatch:o.dispatch})},[y,o,s]),d.jsx(d.Fragment,{children:g.map((w,v)=>{if(w.kind==="text")return w.text;if(w.kind==="changes"){const T=Ft("this worktree's uncommitted files",void 0,{placement:"follow"});return d.jsx("span",{className:"chat-mention","data-changes":"",...T,children:w.text},v)}if(w.kind==="worktree"){const T=op(w),j=Ft(T.text,void 0,{placement:"follow",dot:T.dot,detail:T.detail});return d.jsx("span",{className:"chat-mention","data-worktree":w.id,"data-branch":w.branch,"data-archived":w.archived?"":void 0,...j,children:r?w.text:d.jsxs(d.Fragment,{children:["@",T.text,T.dot&&d.jsx("span",{className:"chat-mention-dot",children:d.jsx("span",{className:`dot ${T.dot}`})})]})},v)}if(!n||!t)return w.text;const _=w.kind==="folder",x=`${n}/${w.path}${_?"/":""}`,N=Ft(_?`${w.path}/`:w.path,void 0,{placement:"follow"});return d.jsx("a",{className:"chat-mention",href:x,tabIndex:r?-1:void 0,...N,children:w.text},v)})})}function jy(e,t,n,r){if(e.target.closest("[data-changes]")){n&&r.dispatch({a:"focus-changes",tab:"changes"});return}dy(e,t,n,r)}function l7(e){return e.length<2||!e.every(t=>{var n;return t.length===1&&((n=t[0])==null?void 0:n.diff)})?null:u7(e.map(t=>t[0].text))}const c7=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function u7(e,t=3){let n=[];for(const r of e){const o=d7(r);if(!o)return null;const s=f7(n,o);if(!s)return null;n=s}return n.some(r=>r.kind!=="same")?h7(n,t):null}function d7(e){const t=[];let n=null;for(const r of e.split(`
234
- `)){const o=c7.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 f7(e,t){const n=[];let r=0,o=0,s=0,a=0;const c=f=>{f.kind==="same"?o=f.a-f.c:f.kind==="add"?o-=1:o+=1},u=()=>{for(;r<e.length&&e[r].kind==="del";)n.push(e[r]),c(e[r]),r++},h=f=>{for(let m=f;m<e.length;m++){const g=e[m];if(g.kind!=="del")return g.c}return Number.POSITIVE_INFINITY};for(const f of t){if(f.oldStart<=a)return null;for(;r<e.length;){const y=e[r];if((y.kind==="del"?h(r):y.c)>=f.oldStart)break;n.push(y.kind==="del"?y:{...y,c:y.c+s}),c(y),r++}let m=f.oldStart,g=f.newStart;for(const y of f.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===m?w:void 0;if(v){if(v.text!==y.text)return null;r++,c(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:m+o,c:g,text:y.text}):n.push({kind:"del",a:m+o,text:y.text});y.mark===" "&&g++,m++}s=g-m,a=m-1}for(;r<e.length;r++){const f=e[r];n.push(f.kind==="del"?f:{...f,c:f.c+s})}return n}function h7(e,t){const n=[];for(const r of m7(e))for(const[o,s]of g7(r.rows,t)){const a=p7(r.rows.slice(o,s)),c=a.filter(m=>m.kind!=="add").length,u=a.filter(m=>m.kind!=="del").length,h=a.find(m=>m.kind!=="add"),f=a.find(m=>m.kind!=="del");n.push(`@@ -${h?h.a:r.oldAt[o]},${c} +${f?f.c:r.newAt[o]},${u} @@`,...a.map(m=>`${m.kind==="add"?"+":m.kind==="del"?"-":" "}${m.text}`))}return n.join(`
235
- `)}function p7(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 m7(e){const t=[];let n=null,r=1,o=1;for(const s of e){const a=s.kind==="add"?r:s.a,c=s.kind==="del"?o:s.c;(!n||a!==r||c!==o)&&(n={rows:[],oldAt:[],newAt:[]},t.push(n)),n.rows.push(s),n.oldAt.push(a),n.newAt.push(c),r=a+(s.kind==="add"?0:1),o=c+(s.kind==="del"?0:1)}return t}function g7(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 Pf({pieces:e}){return d.jsx(d.Fragment,{children:e.map((t,n)=>{if(t.scope===sp)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(S.Fragment,{children:t.text},n)})})}function dp({pick:e,worktreeId:t,tipText:n,onHover:r,onOpen:o,onRemove:s,className:a=""}){const c=e.callFile,u=e.file,h=c?{path:c,line:e.callLine}:u?{path:u,line:e.line}:null,f=c&&u?{path:u,line:e.line}:null,m=(N,T)=>`${N}${T?`:${T}`:""}`,g=N=>N.split("/").pop()??N,y=(N,T,j,C)=>o?d.jsx("button",{className:"pick-open","data-tip":C,onClick:()=>o(N,T??1),children:j}):j,w=vn("chat"),{host:v}=Rr(),_=S.useRef(null),x=s?()=>{r==null||r(!1),s()}:void 0;return d.jsxs("div",{ref:_,className:Be("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(()=>BF(e,{remove:x,host:v})),children:[d.jsxs("span",{className:"pick-target",children:[d.jsx(ht,{name:"pick",className:"icon-inline"})," ",xw(e),h&&d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",y(h.path,h.line,m(g(h.path),h.line),`Open ${m(h.path,h.line)}`)]}),f&&d.jsxs("span",{className:"pick-file row-dim",children:[" ","·"," ",y(f.path,f.line,m(f.path.split("/").pop()??f.path,f.line),`Open the component: ${m(f.path,f.line)}`)]})]}),x&&d.jsx(Lt,{icon:"close",label:"Remove attachment",tone:"quiet",onClick:x}),t&&(h==null?void 0:h.line)&&d.jsx(zT,{chip:_,children:d.jsx(y7,{worktreeId:t,path:h.path,line:h.line})})]})}const k7=6,w7=16;function y7({worktreeId:e,path:t,line:n}){const r=Rw(),o=Je(),s=L(m=>{var g;return((g=Fo(m))==null?void 0:g.id)===e}),a=L(m=>{var g;return s?0:(g=Wr(m,e).changedRanges[t])==null?void 0:g.offset}),[c,u]=S.useState(null);S.useEffect(()=>{let m=!0;return s||o==null||o.send({t:"changed-ranges",worktreeId:e,path:t}),r==null||r.look(e,t).then(g=>{m&&u(g)}),()=>{m=!1}},[r,o,e,t,s]);const h=S.useMemo(()=>{if(c===null||a===void 0)return null;const m=c.split(`
236
- `),g=n-a,y=Math.max(1,g-k7),w=Math.min(m.length,g+w7);if(y>w)return null;const v=m.slice(y-1,w);return{from:y,at:g,slice:v,painted:Ey(v.join(`
237
- `),xy("",t))}},[c,a,n,t]);if(!h)return null;const f=String(h.from+h.slice.length-1).length;return d.jsx("pre",{className:"pick-peek",children:h.slice.map((m,g)=>{const y=h.from+g,w=h.painted[g];return d.jsxs("span",{className:"pick-peek-line","data-state":y===h.at?"current":void 0,children:[d.jsx("span",{className:"pick-peek-n",children:String(y).padStart(f)}),w!=null&&w.length?d.jsx(Pf,{pieces:w}):m||" "]},y)})})}function v7(e){return e.startsWith("!")?e.slice(1).trim():null}function $y(e){if(e.kind!=="tool"||e.name!==$i&&e.name!==_E)return null;const t=e.input;return typeof(t==null?void 0:t.command)=="string"?t.command:null}function Bj(e){var t;return e.kind!=="tool"||e.name!==$i||(t=e.input)!=null&&t.landing?null:$y(e)}function b7(e){return e.length>0&&e.every(t=>t.kind==="tool"&&Bj(t)!==null&&t.done&&!t.isError)}function x7(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(Du(o))break;if(o.kind!=="tool"||!o.done||n.has(o.id))continue;const s=$y(o);if(s===null)continue;const a=Mj(o.output??"").map(u=>u.text).join(`
238
- `),c=LL(a);t.unshift(`$ ${s}${c?`
239
- ${c}`:""}`)}if(t.length!==0)return`Shell commands the user ran since their last message, and what each printed:
240
- ${t.join(`
241
- `)}`}const $1={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 Uj(e,t,n,r){const o=e[0];if(!o||!n)return[];const s=lp(Gl(o),t);return s?s.startsWith("/")?[{label:"open",tip:$1.file,open:()=>gk(r,n.id,{href:s,path:s})}]:[...Ii(s)==="preview"?["preview"]:[],...o.toolKind==="edit"?["diff"]:[],"file"].map(c=>({label:`open ${c}`,tip:$1[c],open:()=>Rn(r,{worktreeId:n.id,path:s,view:c})})):[]}const E7=(...e)=>Uj(...e)[0]??null;function S7(e,t,n,r,o,s){const{sock:a}=r,c=e[0];if(!c)return[];const u=s?RT(s):[],h=[],f=lp(Gl(c),t),m=Uj(e,t,n,r).map(N=>({id:N.label.replace(" ","-"),label:N.label,onClick:N.open}));f&&!f.startsWith("/")&&n?h.push(...m,...Bo(()=>a==null?void 0:a.send({t:"reveal",worktreeId:n.id,path:f}),fo(a))):f.startsWith("/")&&h.push(...m,...Bo(()=>a==null?void 0:a.send({t:"reveal-path",path:f}),fo(a)));const g=[],y=Gl(c);f&&y&&g.push({id:"copy-path",label:"copy path",onClick:()=>tn(y)});const w=Cu(c,t).command,v=AU(c);v&&v!==w&&g.push({id:"copy-description",label:"copy description",onClick:()=>tn(v)}),w&&g.push({id:"copy-command",label:"copy command",onClick:()=>tn(w)});const _=e.map(N=>N.output??"").filter(Boolean).join(`
242
- `);_&&g.push({id:"copy-output",label:"copy output",onClick:()=>tn(_)});const x=o.leaf?[]:[{id:"fold",label:o.open?"collapse":"expand",onClick:o.toggle}];return Bn([u,h,g,x])}const Hj=e=>e.replace(/\n$/,""),_7=1500,C1=4;function Wj(e){return e.closest(".md pre, .card-code pre")}function jk(e){const t=Wj(e);return t?Hj(t.textContent??""):null}function N7(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{pre:t,top:r.top-n.top+e.scrollTop+C1,right:n.left+e.clientLeft+e.clientWidth-r.right+C1}}function Cy(e){const[t,n]=S.useState(null),[r,o]=S.useState(null);if(S.useEffect(()=>{const h=e.current;if(!h)return;const f=g=>{if(!(g.target instanceof Element)||g.target.closest(".code-copy"))return;const y=Wj(g.target);n(y&&h.contains(y)?N7(h,y):null)},m=()=>n(null);return h.addEventListener("pointerover",f),h.addEventListener("pointerleave",m),()=>{h.removeEventListener("pointerover",f),h.removeEventListener("pointerleave",m)}},[e]),S.useEffect(()=>{if(!r)return;const h=setTimeout(()=>o(null),_7);return()=>clearTimeout(h)},[r]),!(t!=null&&t.pre.isConnected))return null;const{pre:s,top:a,right:c}=t,u=r===s;return d.jsx(Lt,{className:"code-copy",style:{top:a,right:c},icon:u?"check":"copy",label:u?"Copied":"Copy code",onClick:()=>{tn(Hj(s.textContent??"")),o(s)}})}function T7(e){for(const t of e.split(`
243
- `)){const n=/^#{1,6}\s+(.+?)\s*#*\s*$/.exec(t);if(n)return n[1];if(t.trim()&&!t.startsWith("<!--"))return null}return null}function j7(e){return e.slice(e.lastIndexOf("/")+1).replace(/\.md$/,"")}const xf=new Map;function Ay(e,t){var c;const n=Rw(),r=(c=Mt(e,"git"))==null?void 0:c.version,o=e&&t?`${e}
244
- ${t}`:null,[,s]=S.useState(0);return at([n,e,t,r],()=>{if(!n||!o||!e||!t)return;let u=!0;return n.look(e,t).then(h=>{if(!u||h===null)return;const f=T7(h);xf.has(o)&&xf.get(o)===f||(xf.set(o,f),s(m=>m+1))}),()=>{u=!1}}),(o?xf.get(o)??null:null)??(t?j7(t):"")}function Kj(e){const t=L(r=>{var o;return(o=Gt(r,e))==null?void 0:o.worktree.repoId}),n=L(r=>t?oB(r,t):"");return S.useMemo(()=>n?sB(n):void 0,[n])}function mg({text:e,menu:t,marked:n,worktreeId:r,fileRoot:o,streaming:s,pictures:a}){const c=Kj(r),u=Rr(),h=S.useMemo(()=>r&&(a!=null&&a.length)?{worktreeId:r,urls:u,pictures:a}:void 0,[r,u,a]),f=Vu(e,{fileRoot:o,streaming:s,worktrees:c,stills:h}),m=Je(),g=lt(),y=vn("chat"),[w,v]=S.useState(null),_=C=>{const I=C.closest("button.md-still"),A=I==null?void 0:I.querySelector("img");return I&&A&&r?{src:A.src,alt:A.alt,file:I.dataset.file??"",kept:{worktreeId:r,file:I.dataset.file??"",sock:m}}:null},x=S.useRef(null);R_(x,f);const N=L(C=>{var I;return r?(I=C.local[r])==null?void 0:I.refusedLink:void 0});at([f,N],()=>{var I;const C=x.current;if(C)for(const A of C.querySelectorAll("a.file-link, code[data-path]")){const M=A.getAttribute("href")??A.dataset.path,O=N!==void 0&&M===N.href;A.classList.toggle("file-link-refused",O),O?((I=A.dataset).tipWas??(I.tipWas=A.dataset.tip??""),A.dataset.tip=N.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=S.useRef(null),j=Cy(T);return d.jsxs("div",{ref:T,className:"msg-assistant md row-edge","data-state":hr({cursor:n}),...y.contextMenu((C,I)=>{const A=_(I);return A?Na(A.src,{open:()=>v(A)},A.kept):t(np(I,o),jk(I))}),onClick:C=>{const I=_(C.target);I?v(I):dy(C,o,r,{sock:m,dispatch:g})},children:[d.jsx("div",{ref:x}),j,w&&r&&d.jsx(tp,{owner:"chat",onClose:()=>v(null),menu:()=>Na(w.src,{},{worktreeId:r,file:w.file,sock:m}),children:d.jsx("img",{src:w.src,alt:w.alt})})]})}const gg=40;function qj(e,t,n=!1){return e.map((r,o)=>{const s=xy(r.lang,t||(r.diff?qB(r.text):"")),a=r.diff?LU(r.text):[];let c=r.diff?Sk(VB(a,s)):r.code&&s?Sk(Ey(r.text,s)):yj(r.text);return n&&o===e.length-1&&(c=vj(c)),{...r,lines:a,painted:c}})}function Zj({blocks:e,path:t,worktreeId:n}){Je();const r=lt();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,gg).map((a,c)=>{var u;return a.kind==="hunk"?d.jsx("span",{className:"dl hunk",title:a.text},c):d.jsx("span",{className:`dl ${a.kind}`,children:(u=o.painted[c])!=null&&u.length?d.jsx(Pf,{pieces:o.painted[c]}):a.text||" "},c)}),o.lines.length>gg&&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-gg," more lines"]})]},s):o.code?d.jsx("pre",{className:"tool-block",children:o.painted.length?o.painted.map((a,c)=>d.jsxs(S.Fragment,{children:[c>0?`
245
- `:null,d.jsx(Pf,{pieces:a})]},c)):o.text},s):d.jsx("p",{className:"tool-note",children:o.painted.length?o.painted.map((a,c)=>d.jsxs(S.Fragment,{children:[c>0?`
246
- `:null,d.jsx(Pf,{pieces:a})]},c)):o.text},s))})}function $7({image:e,worktreeId:t}){const n=Rr().attachment(t,e.file),r={worktreeId:t,file:e.file,sock:Je()},[o,s]=S.useState(!1),a=vn("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(()=>Na(n,{open:()=>s(!0)},r)),children:d.jsx("img",{src:n,alt:e.file})}),o&&d.jsx(tp,{owner:"chat",onClose:()=>s(!1),menu:()=>Na(n,{},r),children:d.jsx("img",{src:n,alt:e.file})})]})}const C7=S.memo(function({item:t,roots:n,worktreeId:r}){const o=S.useMemo(()=>qj(Tk(t,t.output??""),Gl(t),!t.done),[t]),s=Cu(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(Zj,{blocks:o,path:Gj(t,n),worktreeId:r}),a.length>0&&r&&d.jsx("div",{className:"tool-out",children:a.map(c=>d.jsx($7,{image:c,worktreeId:r},c.file))})]})});function Gj(e,t){const n=lp(Gl(e),t??[]);return n.startsWith("/")?"":n}const A7=S.memo(function({text:t,item:n,roots:r,worktreeId:o}){const s=Gl(n),a=S.useMemo(()=>qj([{code:!0,diff:!0,lang:"diff",text:t}],s),[t,s]);return d.jsx("div",{className:"tool-part",children:d.jsx(Zj,{blocks:a,path:Gj(n,r),worktreeId:o})})});function $k({className:e,state:t,auto:n,leaf:r,growing:o,label:s,summary:a,menu:c,children:u}){const[h,f]=S.useState(null),m=S.useRef(null),g=S.useRef(null),y=I_(g),w=hz(".chat-log"),v=!r&&(h??n),[_,x]=S.useState(v);S.useEffect(()=>{v&&x(!0)},[v]);const N=()=>{r||(v||w(m.current),f(!v))},T=vn("chat");return d.jsxs("details",{ref:m,className:Be(e,r&&"leaf"),"data-state":t,open:v,onToggle:j=>{if(!j.currentTarget.open||o)return;const C=g.current;C&&(C.scrollTop=0,y.read())},...T.contextMenu((j,C)=>c({open:v,leaf:!!r,toggle:N},C)),tabIndex:-1,onPointerDown:()=>{var j;return(j=m.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;Vh([{depth:0,open:v}],0,j.key)&&N();return}j.key!=="Escape"||!v||(j.stopPropagation(),f(!1))},children:[d.jsx("summary",{"aria-label":s,tabIndex:r?-1:void 0,onClick:j=>{j.preventDefault(),N()},children:a}),d.jsx("div",{className:"tool-body",ref:g,children:v||_?u:null})]})}function I7({markdown:e,streaming:t,worktreeId:n,fileRoot:r}){const o=Kj(n),s=Vu(e,r||t||o?{fileRoot:r,streaming:t,worktrees:o}:void 0),a=Je(),c=lt(),u=S.useRef(null);R_(u,s);const h=S.useRef(null),f=Cy(h);return d.jsx("div",{className:"tool-part",children:d.jsxs("div",{ref:h,className:"tool-out thought-out md",onClick:m=>dy(m,r,n,{sock:a,dispatch:c}),children:[d.jsx("div",{ref:u}),f]})})}const R7=S.memo(function({item:t,open:n,streaming:r,worktreeId:o,fileRoot:s}){const a=Nj(t.text),c=a.slice(0,-1),u=r?"Thinking":"Thought",h=d.jsx(I7,{markdown:a.length?c.join(`
247
-
248
- `):Sj(t.text),streaming:r,worktreeId:o,fileRoot:s}),f=a.at(-1)??(r?"":Tj(t.text));if(f){const m=c.length===0;return d.jsx($k,{className:"tool-row",auto:!1,leaf:m,growing:r,label:f,menu:(g,y)=>Bn([kk(jk(y)),[{id:"copy",label:"copy thought",onClick:()=>tn(t.text)}],...m?[]:[[{id:"fold",label:g.open?"collapse":"expand",onClick:g.toggle}]]]),summary:d.jsxs(d.Fragment,{children:[d.jsx(ht,{name:"bulb",className:"tool-icon"}),d.jsx("span",{className:"tool-hint thought-line",children:r?d.jsx("span",{className:"live-text",children:f}):f})]}),children:m?null:h})}return d.jsx($k,{className:"tool-row",auto:!!n,growing:r,label:u,menu:(m,g)=>Bn([kk(jk(g)),[{id:"copy",label:"copy thought",onClick:()=>tn(t.text)}],[{id:"fold",label:m.open?"collapse":"expand",onClick:m.toggle}]]),summary:d.jsxs(d.Fragment,{children:[d.jsx(ht,{name:"bulb",className:"tool-icon"}),d.jsx("span",{className:Be("tool-name",r&&"live-text"),children:u})]}),children:h})}),ca=6,O7={land:"the land",commit:"the commit","sync-main":"the sync","pull-main":"the pull"},Ef=S.memo(function e({tools:t,run:n,next:r,live:o,working:s,held:a,since:c,queued:u,roots:h,worktreeId:f,marked:m}){const g=t[0],y=S.useMemo(()=>l7(t.map(de=>Tk(de,de.output??""))),[t]),w=t.at(-1)??g,v=!w.done,_=v&&!!w.background,N=(v||!!r||!!a)&&!u||!!s,T=v&&!!u,j=Ti((v||s)&&!w.until?c:void 0),C=n?VU(n):-1,I=S.useMemo(()=>n?Dj(n,!0):void 0,[n]),A=!!o,M=Cu(g,h),O=v?CU(g):"",{label:z,icon:B}=M,H=Rj(g),Y=O?"":H?"Guardian":M.name,ie=O&&g.subagent?M.hint:"",Q=ie||O||(H?NU(g.output??""):M.hint),le=!(n&&n.length>0)&&!y&&t.every(de=>{var J;return!Cu(de,h).command&&Tk(de,de.output??"").length===0&&!((J=de.images)!=null&&J.length)}),U=n?KU(n):0,$=b7(t),q=_?w.until?`wakes ${Mh(w.until)}`:"in the background":"",V=[z,Q].filter(Boolean).join(" ")+(q?`, ${q}`:"")+(T?", queued":"")+($?", done":""),W=O?"":n?`${U} ${U===1?"call":"calls"}`:t.length>1?`×${t.length}`:"",re=On(),fe=Je(),pe=L(de=>{var J;return f?(J=de.shipping[f])==null?void 0:J.op:void 0}),Te=v&&g.name===$i&&f?{worktreeId:f,toolId:w.id}:null,je=v?null:(()=>{const de=Gt(re.getState(),f);return E7(t,h??[],de?{id:de.worktree.id}:null,{sock:fe,dispatch:re.dispatch})})();return d.jsxs($k,{className:Be("tool-row",t.some(de=>de.isError)&&"error",g.parentToolId&&"nested",n&&"spawn",T&&"queued"),state:hr({cursor:m}),auto:A,leaf:le,growing:N,label:n&&W?`${V}, ${W}`:t.length>1?`${V}, ${t.length} calls`:V,menu:(de,J)=>{const te=Gt(re.getState(),f),ve=te?{id:te.worktree.id}:null,ce=np(J,null),ae=(ce==null?void 0:ce.kind)==="out"?ce.href:null;return S7(t,h??[],ve,{sock:fe,dispatch:re.dispatch},de,ae)},summary:d.jsxs(d.Fragment,{children:[d.jsx(ht,{name:n?"spawn":B,className:"tool-icon"}),Y&&d.jsx("span",{className:Be("tool-name",N&&!Q&&"live-text"),children:Y}),O&&!ie?d.jsx("span",{className:"tool-writing","data-tip":Q,children:d.jsx(eh,{})}):Q&&d.jsx("span",{className:"tool-hint",children:N?d.jsx("span",{className:"live-text",children:Q}):Q}),q&&d.jsx("span",{className:"tool-status",children:q}),T&&d.jsx("span",{className:"tool-status",children:"queued"}),$&&d.jsx(ht,{name:"check",className:"tool-done"}),j>=ca&&d.jsx("span",{className:Be("tool-age",C>=0&&"tool-age-folded"),children:ha(j)}),W&&d.jsx("span",{className:"tool-count",children:W}),ie&&d.jsx("span",{className:"tool-writing","data-tip":O,children:d.jsx(eh,{})}),Te&&d.jsx(Lt,{icon:"stop",className:"tool-stop",label:pe?`Stop ${O7[pe]}: this step is killed, and what it printed so far stays`:_?"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:de=>{de.preventDefault(),de.stopPropagation(),fe==null||fe.send({t:"exec-stop",...Te})}}),je&&d.jsx(Lt,{icon:"eye",className:"tool-open",label:je.tip,onClick:de=>{de.preventDefault(),de.stopPropagation(),je.open()}})]}),children:[n&&n.length>0&&d.jsx("div",{className:"spawn-run",children:n.map((de,J)=>d.jsx(e,{tools:de.tools,next:de.next,since:J===C?c:void 0,queued:I==null?void 0:I.has(J),roots:h,worktreeId:f},de.at))}),y?d.jsx(A7,{text:y,item:g,roots:h,worktreeId:f}):t.map(de=>d.jsx(C7,{item:de,roots:h,worktreeId:f},de.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&&Ny(e.tools,t.tools)&&zj(e.run,t.run));function M7({item:e}){const t=Je(),n=lt(),r=L(v=>v.activeId),o=L(v=>v.layout.term),s=L(v=>{var _;return((_=v.rows.find(x=>x.id===v.activeId))==null?void 0:_.login)??!1}),a=L(v=>v.managed.problem),[c,u]=S.useState(""),[h,f]=S.useState(null),m=S.useRef(!1);if(at([s],()=>{s&&m.current&&r&&n({a:"term-stream",id:r,stream:Ls,tall:!0})}),at([e.done],()=>{e.done&&m.current&&o&&n({a:"toggle-terminal"}),m.current=!1}),!r)return null;const g=e.provider==="aws",y=(v,_)=>{t==null||t.send({t:"agent-auth",worktreeId:r,methodId:v,..._?{apiKey:_}:{}})},w=e.methods.find(v=>v.id===h);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,_)=>v.needsKey?d.jsx(Me,{variant:"outline",on:h===v.id,"data-tip":v.description,onClick:()=>f(h===v.id?null:v.id),children:v.name},v.id):d.jsx(Me,{variant:"outline",tone:g&&_===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"&&(m.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(),c.trim()&&(y(w.id,c.trim()),u(""),f(null))},children:[d.jsx(zo,{type:"password",autoFocus:!0,placeholder:`${w.name} for ${e.agentName}`,value:c,onChange:v=>u(v.target.value)}),d.jsx(Me,{type:"submit",children:"use key"})]})]})}const L7=S.memo(function({item:t,worktreeId:n,onPickHover:r,marked:o,streaming:s}){const a=On(),c=Je(),u=Rr(),h=vn("chat"),f={sock:c,dispatch:a.dispatch},m=()=>{var y;return(y=Gt(a.getState(),n))==null?void 0:y.worktree.path},g=y=>y&&n&&d.jsx(Qh,{children:d.jsx("div",{className:"msg-attachments",children:y.map(w=>w.kind==="image"?d.jsx(i7,{img:w,worktreeId:n,src:u.attachment(n,w.file)},`${w.kind}-${w.n}`):w.kind==="file"?d.jsx(ap,{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(ip,{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(dp,{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,_)=>ya(a,c,n,v,_)},`${w.kind}-${w.n}`))})});switch(t.kind){case"user":{const y=g(t.attachments),w=m();return d.jsxs("div",{className:"msg-user row-edge","data-state":hr({cursor:o}),...h.contextMenu((v,_)=>gi(t,n??null,f,{link:np(_,w)})),onClick:v=>jy(v,w,n,f),children:[y,d.jsx(Ty,{text:t.text,worktreeId:n,root:w})]})}case"assistant":return d.jsx(mg,{text:t.text,menu:(y,w)=>gi(t,n??null,f,{link:y,code:w}),marked:o,worktreeId:n,fileRoot:m(),streaming:s,pictures:t.pictures});case"error":return d.jsx("div",{className:"msg-assistant msg-error",...h.contextMenu(()=>gi(t,n??null,f)),children:t.text});case"auth":return d.jsx(M7,{item:t});case"ask":{const y=M4(t);if(y){const x=gw(y.questions,y.answers),T={kind:"assistant",text:x.join(`
249
- `)};return d.jsxs(d.Fragment,{children:[d.jsx(mg,{text:y.message,menu:(j,C)=>gi({kind:"assistant",text:y.message},n??null,f,{link:j,code:C}),worktreeId:n,fileRoot:m()}),d.jsx("div",{className:"msg-user row-edge","data-state":hr({cursor:o}),...h.contextMenu(()=>gi(T,n??null,f)),children:y.questions.map((j,C)=>{var I;return d.jsxs("div",{children:[x[C],O4(j,(I=y.answers)==null?void 0:I[C]).map((A,M)=>d.jsx("div",{children:A},M))]},j.id)})})]})}const w=P4(t);if(!w)return d.jsx(QF,{item:t});const v=w.file,_={kind:"assistant",text:w.choice};return d.jsxs(d.Fragment,{children:[v?d.jsx(P7,{file:v,worktreeId:n}):w.text&&d.jsx(mg,{text:w.text,menu:(x,N)=>gi({kind:"assistant",text:w.text},n??null,f,{link:x,code:N}),worktreeId:n,fileRoot:m()}),d.jsx("div",{className:"msg-user",...h.contextMenu(()=>gi(_,n??null,f)),children:w.choice})]})}case"blocked":return d.jsxs(Nr,{icon:"lock",word:"blocked",tone:"red",below:t.reason,...h.contextMenu(()=>uy(t.path,void 0,fo(f.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(Nr,{icon:"layers",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(Nr,{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(Nr,{icon:"send",word:"asked",tone:"quiet",children:d.jsx("span",{className:"daemon-text",children:t.why})});case"stopped":return d.jsx(Nr,{icon:"stop",word:"stopped",tone:"quiet"});case"landed":return d.jsx(z7,{item:t});case"handed":return d.jsx(r7,{item:t,worktreeId:n,marked:o,children:g(t.attachments)});case"piece-landed":return d.jsx(s7,{item:t});case"handoff":{const y=T3(t);if(!y)return d.jsx(j1,{item:t,worktreeId:n});const w={kind:"assistant",text:y};return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"msg-user",...h.contextMenu(()=>gi(w,n??null,f)),children:y}),d.jsx(j1,{item:t,worktreeId:n})]})}case"piece-later":return d.jsx(o7,{item:t});case"restored":return d.jsx(D7,{item:t});case"adopted":return d.jsx(Nr,{icon:"branch",word:"taken over",tone:"quiet",at:t.ts,children:d.jsxs("span",{className:"daemon-text",children:["on ",t.branch,", its own branch"]})})}});function P7({file:e,worktreeId:t}){const n=Je(),r=lt(),o=vn("chat"),s=Ay(t??void 0,e);return d.jsx(Nr,{icon:"file",word:"plan",tone:"quiet",...o.contextMenu(()=>uy(e,t?()=>n==null?void 0:n.send({t:"reveal",worktreeId:t,path:e}):void 0,fo(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 D7({item:e}){return d.jsx(Nr,{icon:"reload",word:"restored",tone:"quiet",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:["after ",Ew(e.ts-e.archivedAt)," in the archive, back on ",e.branch,e.uncommitted?" with its uncommitted changes":""]})})}function z7({item:e}){const t=fT(e.ts),n=e.mark&&Xw(e.mark),r=`${e.text}, ${t}`,o=e.url&&d.jsx(Me,{variant:"inline",onClick:()=>window.open(e.url,"_blank"),children:"the PR"}),s=e.held&&`Not marked landed: ${Xr(e.held)}`;return d.jsx(Nr,{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 F7(e){const t=e instanceof Element?e:e.parentElement;return!!(t!=null&&t.closest(fp))}function A1(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=op({...o,dir:r.dataset.dir}),a=r.querySelector(".dot"),c=`dot ${o.dot}`;a&&a.className!==c&&(a.className=c);const u=s.detail.join(`
250
- `);r.dataset.tipDetail!==u&&(r.dataset.tipDetail=u),r.dataset.tipDot!==o.dot&&(r.dataset.tipDot=o.dot)}}function B7(e,t){const n=L(o=>o.visible),r=L(o=>{var s;return(s=Gt(o,t))==null?void 0:s.worktree.repoId});S.useEffect(()=>{const o=e.current;if(!o||!r)return;const s=cp(n,r,null);A1(o,s);let a=0;const c=new MutationObserver(u=>{u.every(h=>F7(h.target))||(cancelAnimationFrame(a),a=requestAnimationFrame(()=>A1(o,s)))});return c.observe(o,{childList:!0,subtree:!0}),()=>{c.disconnect(),cancelAnimationFrame(a)}},[e,n,r])}const Vj=e=>e===""||e==="!";function I1(e,t){const n=new Set,r=[];for(let o=e.length-1;o>=0;o--){const s=e[o],a=Bj(s),c=a!==null?`!${a}`:t?null:s.kind==="user"?s.text:s.kind==="ask"?L4(s):null;c===null||!c.trim()||n.has(c)||(n.add(c),r.push({text:c,at:o}))}return r}function U7(e,t,n,r){if(!t){if(r!=="up"&&r!=="first"||!Vj(n))return null;const c=I1(e,n==="!"),u=r==="up"?c[0]:c.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=I1(e,t.from==="!"),s=r==="first"?o.length-1:o.findIndex(c=>c.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 H7(e,t,n,r){const o=new Map;return{rows:t.map((a,c)=>{const u=n(a,c),h=e.get(a.at),f=h&&h.row.kind===u.kind&&W7(h.row.props,u.props)?h.el:r(a,u);return o.set(a.at,{row:u,el:f}),f}),cache:o}}function W7(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((c,u)=>Object.is(c,a[u]))))return!1}return!0}const K7=4;function q7(e,t,n){const r=Math.max(t,0);return n?e>=r+1:e>=r+K7}function Z7(e,t,n){S.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,c=!1,u=0,h=0;const f=()=>o.style.setProperty("--cover",`${c?h:u}px`),m=()=>{if(u=s.offsetHeight,h=u,t&&s.classList.contains("foldable")){const _=r.scrollTop;s.classList.add("fold-measure"),h=s.offsetHeight,s.classList.remove("fold-measure"),r.scrollTop=_}a=u-h,o.style.setProperty("--fold",`${a}px`),o.style.setProperty("--keep",`${h}px`),f()},g=()=>{if(!t)return;const _=q7(r.scrollHeight-r.scrollTop-r.clientHeight,a,c);_!==c&&(c=_,f(),n(c))};m(),g(),r.addEventListener("scroll",g,{passive:!0});const y=new ResizeObserver(()=>{m(),g()});y.observe(s);let w=s.className;const v=new MutationObserver(()=>{s.className!==w&&(w=s.className,m(),g())});return v.observe(s,{attributes:!0,attributeFilter:["class"]}),()=>{r.removeEventListener("scroll",g),y.disconnect(),v.disconnect();for(const _ of["--fold","--keep","--cover"])o.style.removeProperty(_);n(!1)}},[e,t,n])}const G7={get current(){return lu.el}},V7={upTo:e=>e.querySelector(":scope > .jump-seat"),except:fp};function Ck({items:e,next:t,worktreeId:n,onOpen:r}){const o=Rr();return d.jsx(Qh,{children:d.jsx("div",{className:"msg-attachments",children:Yk(e,t).map(([s,a])=>s.kind==="image"?d.jsx(up,{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(ap,{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(ip,{className:"in-chat",n:a,name:s.name,source:s.source,...cw(s.text),text:s.text},`paste-${a}`):d.jsx(dp,{className:"in-chat",pick:s,worktreeId:n,onOpen:r},`pick-${a}`))})})}function Y7({entry:e,next:t,worktreeId:n,onOpen:r}){const o=lt(),s=Mt(e.id,"draft"),a=Mt(e.id,"attachments");return d.jsxs("div",{className:"msg-user queued-msg",children:[d.jsxs("span",{className:"queued-tag",children:[d.jsx(ht,{name:"clock",className:"icon-inline"}),d.jsx("span",{className:"live-text",children:"uploading"})]}),d.jsxs("span",{className:"queued-actions",children:[d.jsx(Lt,{icon:"edit",label:"Edit: puts it back in the input",onClick:()=>o({a:"unsend",id:e.id})}),d.jsx(Lt,{icon:"close",label:"Remove: it is not sent",onClick:()=>o({a:"drop-out",id:e.id})})]}),d.jsxs("div",{className:"queued-text",children:[a.length>0&&d.jsx(Ck,{items:a,next:t,worktreeId:n,onOpen:r}),s]})]})}const X7=new Set;function kg({active:e,archived:t,found:n,lead:r,tail:o,foot:s}){var bn;const a=Je(),c=On(),u=lt(),h=L(P=>P.frame==="phone"),f=(e==null?void 0:e.worktree.id)??(t==null?void 0:t.id)??(n==null?void 0:n.id)??null,m=Mt(f,"chat"),g=Mt(f,"queue"),y=Mt(f,"sending"),w=S.useMemo(()=>$g(JS(m)),[m]),v=S.useMemo(()=>{let P=w;return g.map(ne=>{const Se=P;return P=su(P,ne.attachments??[]),Se})},[g,w]),_=L(P=>P.outbox),x=S.useMemo(()=>{let P=g.reduce((ne,Se)=>su(ne,Se.attachments??[]),w);return _.filter(ne=>ne.log===f).map(ne=>{const Se=P;return P=su(P,ne.kinds.map(Ge=>({kind:Ge}))),{entry:ne,next:Se}})},[_,f,g,w]),N=y!=null&&y.message?g.findIndex(P=>{var ne;return P.text===((ne=y.message)==null?void 0:ne.text)}):-1,T=S.useRef(null);B7(T,f),gF(T,V7);const[j,C]=S.useState(null),I=S.useCallback(()=>{const P=(T.current&&dk(T.current))??"";C(ne=>({seed:P||(ne==null?void 0:ne.seed)||"",seq:((ne==null?void 0:ne.seq)??0)+1}))},[]),A=S.useCallback(P=>!(P!=null&&P.closest("[data-pane]"))&&!c.getState().overlay,[c]);wT(G7,ry,I,A);const M=P=>{if(C(null),P){const ne=window.getSelection();ne==null||ne.removeAllRanges(),ne==null||ne.addRange(P)}},O=I_(T,m);at([f],()=>O.jump());const z=O.offStart&&O.moving==="up",B=O.offEnd&&(O.moving==="down"||O.away),H=P=>P.preventDefault(),Y=(z||B)&&d.jsxs("div",{className:Be("jump",O.away&&"jump-news"),children:[z&&d.jsx("button",{className:"jump-up",onMouseDown:H,onClick:O.start,"data-tip":"Jump to start",children:d.jsx(ht,{name:"caret-up",className:"icon-inline"})}),B&&d.jsxs("button",{className:"jump-down",onMouseDown:H,onClick:O.jump,"data-tip":"Jump to latest",children:[d.jsx(ht,{name:"caret",className:"icon-inline"}),O.away&&" new messages"]})]}),ie=S.useCallback(P=>u({a:"reading",on:P}),[u]);Z7(T,h,ie);const Q=Mt(f,"mark"),le=(Q==null?void 0:Q.by)==="walk"?Q.at:void 0,U=S.useRef(null),$=()=>{const P=T.current,ne=P==null?void 0:P.querySelector(':scope > [data-state~="cursor"]');if(!P||!ne)return;const Se=parseFloat(getComputedStyle(P).paddingTop)||0;P.scrollTop+=ne.getBoundingClientRect().top-P.getBoundingClientRect().top-Se,O.read()};at([le],()=>{const P=T.current;if(P){if(le===void 0){const ne=U.current;if(U.current=null,!ne||!Vj(Wr(c.getState(),f).draft))return;ne.bottom?O.jump():(P.scrollTop=ne.top,O.read());return}U.current??(U.current={bottom:O.pinned(),top:P.scrollTop}),$()}});const q=Mt(f,"sent");at([q],()=>{q&&O.jump()});const V=x.length,W=S.useRef(V);at([V],()=>{V>W.current&&O.jump(),W.current=V});const re=(Q==null?void 0:Q.by)==="reveal"?Q:void 0,fe=S.useMemo(()=>re?e7(m,re.seq):-1,[m,re]),pe=le??(fe>=0?fe:void 0);at([re==null?void 0:re.n,fe],()=>{fe>=0&&$()});const Te=S.useCallback((P,ne)=>{f&&(ne?an.post(f,{type:"highlight-selector",selector:P.selector,label:xw(P)}):an.post(f,{type:"highlight-clear"}))},[f]),je=os(e==null?void 0:e.agent),de=Mt(f,"cardParked"),J=S.useMemo(()=>{const P=qw(m);return!!P&&de!==P.id},[m,de]),te=e==null?void 0:e.worktree,ve=(te==null?void 0:te.path)??(t==null?void 0:t.path)??(n==null?void 0:n.path),ce=S.useMemo(()=>ve?[ve]:[],[ve]),ae=S.useMemo(()=>WU(m,ce,je),[m,ce,je]),xe=S.useMemo(()=>je?qU(m):X7,[je,m]),Re=S.useMemo(()=>ZU(ae,xe),[ae,xe]),ge=Re.floating,Ee=S.useRef([]),We=S.useMemo(()=>(Ee.current=YU(Ee.current,Re.flow),Ee.current),[Re]),Ye=(e==null?void 0:e.agent)==="working",ln=Ye||(e==null?void 0:e.agent)==="waiting",cn=S.useMemo(()=>ln?QU(We):-1,[ln,We]),gt=We.at(-1),Ue=Ye&&gt&&"item"in gt&&(gt.item.kind==="thinking"||gt.item.kind==="assistant")?We.length-1:-1,zt=(bn=ae.findLast(P=>{var ne;return"tools"in P&&((ne=P.tools[0])==null?void 0:ne.name)===$i}))==null?void 0:bn.at,pt=Mt(f,"chatAt"),At=Ti(je?pt:void 0),Kt=Mt(f,"usage"),xt=(Kt==null?void 0:Kt.heard)!==void 0&&pt!==void 0&&Kt.heard>pt?Kt.heard:void 0,un=Ti(je?xt:void 0),Ct=Ti(y&&!je?y.at:void 0),Ut=GU(m,je),Et=ge.length>0,er=Ue>=0||Ut||Et,Qt=Ye&&!er&&At<ca?FU(We,ce):-1,Nn=S.useMemo(()=>Dj(We),[We]),Zn=Mt(f,"running"),nn=P=>Zn&&P.tools.some(ne=>ne.id===Zn.id)?Zn.at:void 0,X=e==null?void 0:e.worktree.path,be=P=>`${f??""}:${P}`,Ve=(P,ne)=>"spawn"in P?{kind:"tool",props:{tools:[P.spawn],run:P.run,roots:ce,worktreeId:f}}:"tools"in P?{kind:"tool",props:{tools:P.tools,next:P.next,live:ne===cn||P.at===zt,held:ne===Qt,since:nn(P),queued:Nn.has(ne),roots:ce,worktreeId:f,marked:P.at===pe}}:P.item.kind==="thinking"?{kind:"thought",props:{item:P.item,open:ne===cn,streaming:ne===Ue,worktreeId:f,fileRoot:X}}:{kind:"item",props:{item:P.item,worktreeId:f,onPickHover:Te,marked:P.at===pe,streaming:Ye&&ne===We.length-1}},Qe=S.useRef(new Map),Ht=H7(Qe.current,We,Ve,(P,ne)=>ne.kind==="tool"?d.jsx(Ef,{...ne.props},be(P.at)):ne.kind==="thought"?d.jsx(R7,{...ne.props},be(P.at)):d.jsx(L7,{...ne.props},be(P.at)));Qe.current=Ht.cache;const St=d.jsxs("div",{className:"chat-wrap",children:[d.jsxs("div",{className:"chat-log",ref:T,children:[r,Ht.rows,ge.map(P=>{var ne;return"spawn"in P?d.jsx(Ef,{tools:[P.spawn],run:P.run,working:!0,since:pt,roots:ce,worktreeId:f},be(P.at)):((ne=P.tools[0])==null?void 0:ne.name)===$i?d.jsx(Ef,{tools:P.tools,live:P.at===zt,since:nn(P),roots:ce,worktreeId:f,marked:P.at===pe},be(P.at)):d.jsx(Ef,{tools:P.tools,since:pt,roots:ce,worktreeId:f},be(P.at))}),f&&(y==null?void 0:y.message)&&d.jsxs("div",{className:"msg-user",onClick:P=>jy(P,ve,f,{sock:a,dispatch:u}),children:[y.message.attachments&&d.jsx(Ck,{items:y.message.attachments,next:w,worktreeId:f,onOpen:(P,ne)=>ya(c,a,f,P,ne)}),d.jsx(Ty,{text:y.message.text,worktreeId:f,root:ve})]}),e&&(y||je&&!(e.agent==="waiting"&&J)&&!Ut&&!Et&&Qt<0&&!(er&&At<ca))&&d.jsx("div",{className:"working-row",children:e.agent==="waiting"?"waiting for your answer…":er?At>=ca&&d.jsxs("span",{children:["quiet for",d.jsx("span",{className:"working-num",children:ha(At)})]}):d.jsxs("span",{className:"working-mark",children:[d.jsx(eh,{}),!je&&y?Ct>=ca&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"waiting for the agent"}),d.jsx("span",{className:"working-num",children:ha(Ct)})]}):xt!==void 0?un>=ca&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"thinking"}),d.jsx("span",{className:"working-num",children:ha(un)})]}):At>=ca&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"waiting for the model"}),d.jsx("span",{className:"working-num",children:ha(At)})]})]})}),f&&g.map((P,ne)=>ne===N?null:d.jsxs("div",{className:"msg-user queued-msg",children:[d.jsxs("span",{className:"queued-tag",children:[d.jsx(ht,{name:"clock",className:"icon-inline"}),"queued"]}),d.jsxs("span",{className:"queued-actions",children:[d.jsx(Lt,{icon:"edit",label:"Edit: removes from queue, puts it back in the input",onClick:()=>tN(c,a,f,ne)}),d.jsx(Lt,{icon:"close",label:"Remove from queue",onClick:()=>a==null?void 0:a.send({t:"unqueue",worktreeId:f,index:ne})})]}),d.jsxs("div",{className:"queued-text",children:[P.attachments&&d.jsx(Ck,{items:P.attachments,next:v[ne]??w,worktreeId:f,onOpen:(Se,Ge)=>ya(c,a,f,Se,Ge)}),P.text]})]},`q-${ne}`)),f&&x.map(({entry:P,next:ne})=>d.jsx(Y7,{entry:P,next:ne,worktreeId:f,onOpen:(Se,Ge)=>ya(c,a,f,Se,Ge)},P.id)),o,d.jsx("div",{className:"jump-seat",children:Y}),h&&s]}),j&&d.jsx(gT,{root:T,body:T,skip:fp,seed:j.seed,seq:j.seq,onClose:M,onReveal:O.read})]});return h?St:d.jsxs(d.Fragment,{children:[St,s]})}function Q7(e){return e.offer?e.offer.state!=="offered"?!0:e.agent==="idle"&&e.chat.some(t=>t.kind==="assistant"):!1}const J7=/EACCES|EPERM|permission denied/i,eH="https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally";function tH(e){return{why:e.line.replace(/\.$/,""),permissions:J7.test(e.line),command:e.command}}function nH(){try{return localStorage.getItem(tt.installOffered)==="1"}catch{return!1}}let ch={prompt:null,offered:typeof localStorage<"u"&&nH()};const Ak=new Set;function Ik(e){ch={...ch,...e};for(const t of Ak)t()}typeof window<"u"&&(window.addEventListener("beforeinstallprompt",e=>{e.preventDefault(),Ik({prompt:e})}),window.addEventListener("appinstalled",()=>Ik({prompt:null})));function Yj(e){return Ak.add(e),()=>{Ak.delete(e)}}function Xj(){return S.useSyncExternalStore(Yj,()=>ch.prompt)}function rH(){return S.useSyncExternalStore(Yj,()=>ch.offered)}function R1(){try{localStorage.setItem(tt.installOffered,"1")}catch{}Ik({offered:!0})}function oH(e){return!e.prompt||e.offered||e.agent!=="idle"?!1:e.chat.some(t=>t.kind==="assistant")}function Qj({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(rs,{k:r}),o]},r)),t&&d.jsx("span",{className:"key-note",children:t})]})}const sH={side:"top",align:"start",offset:4,alignOffset:-10,matchWidth:-20,flip:"side",margin:8};function iH({results:e,keyOf:t,row:n,rowClass:r,nav:o,listRef:s,empty:a,note:c,groupOf:u,groupHead:h}){const f=new Set(u?e.map(u):[]);return d.jsxs(Fs,{className:"inline-picker",anchor:"parent",placement:sH,children:[d.jsxs("div",{className:"picker-list",ref:s,children:[e.map((m,g)=>{const y=u==null?void 0:u(m),w=y!==void 0&&f.size>1&&(g===0||(u==null?void 0:u(e[g-1]))!==y)?d.jsx("div",{className:"picker-group",children:(h==null?void 0:h(y))??y}):null;return d.jsxs(S.Fragment,{children:[w,d.jsx("button",{className:Be("picker-item",r==null?void 0:r(m)),"data-state":hr({cursor:g===o.index}),onMouseMove:()=>g!==o.index&&o.setIndex(g),onMouseDown:v=>v.preventDefault(),onClick:()=>o.pick(m),children:n(m,g===o.index)})]},t(m))}),e.length===0&&d.jsx("div",{className:"empty",children:a})]}),d.jsx(Qj,{hints:[["↑↓","moves"],["tab","inserts"],["esc","dismisses"]],note:c})]})}const O1=e=>Math.max(0,Math.min(1,Number.isFinite(e)?e:0));function aH({fraction:e,level:t,className:n}){const o=2*Math.PI*5.5,s=O1(e),a=S.useId(),c=3.5,u=2*c*O1(t);return d.jsxs("svg",{className:Be("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:c})}),d.jsx("rect",{className:"ring-level",clipPath:`url(#${a})`,x:"0",y:7+c-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 lH(e,t=fu.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}.`}function Au({anchored:e=!1,...t}){return e?d.jsx(cH,{...t,anchored:e===!0?{}:e}):d.jsx(uH,{...t})}function cH({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,anchored:o,coverBy:s,id:a,children:c}){const{onKey:u,back:h}=Jj(t);return d.jsx(Fs,{className:Be(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:()=>h()||(e==null?void 0:e()),children:c})}function uH({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,id:o,children:s}){const{onKey:a,back:c}=Jj(t);return d.jsx(Fs,{className:"overlay scrim",id:o,onDismiss:e?()=>e():void 0,onKey:a,onBack:()=>c()||(e==null?void 0:e()),onClick:u=>{e&&u.target===u.currentTarget&&e()},children:d.jsx("div",{className:Be(r?"":"overlay-box",n),children:s})})}function Jj(e){const t=On(),n=()=>{if(e)return e(),!0;const o=t.getState();return!o.overlay||o.choosingFolder?!1:(t.dispatch({a:"close",back:h_(o.overlay)}),!0)};return{onKey:o=>{o.key==="Escape"&&n()&&o.stopPropagation()},back:n}}function dH(e){const t=e.value.length;e.setSelectionRange(t,t)}function fH({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 Kr({items:e,filter:t,keyOf:n,row:r,rowClass:o,rowTitle:s,onPick:a,onBack:c,onActive:u,onSide:h,onTab:f,onQuery:m,completionOf:g,narrowTo:y,placeholder:w,initialQuery:v="",initialIndex:_,selectOnMount:x=!1,idleWhen:N,onIdlePick:T,anchored:j=!1,onEscape:C,lead:I,trailing:A,empty:M="no matches",footer:O,keys:z,rowMenu:B,groupOf:H,groupHead:Y,headAlone:ie=!1,field:Q}){const le=vn("picker"),[U,$]=S.useState(v),q=S.useMemo(()=>t(e,U),[e,U,t]),V=S.useRef(null),W=Ra(),re=uz(x,!W&&!Q);S.useEffect(()=>{if(!m)return;const Re=setTimeout(()=>m(U),150);return()=>clearTimeout(Re)},[U,m]);const fe=$N({results:q,keyOf:n,q:U,onPick:a,listRef:V,onActive:u,onSide:h,completionOf:g,narrowTo:y,setQ:$,initialIndex:_,idle:(N==null?void 0:N(v))??!1,onIdlePick:T}),{index:pe,ghost:Te}=fe,je=Q?Q.open:!0;at([je,v],()=>{!Q||je||($(v),fe.setIndex(N!=null&&N(v)?-1:0))}),at([je],()=>{if(!Q||!je||W)return;const Re=()=>{const Ee=re.current;!Ee||document.activeElement===Ee||(Ee.focus(),x&&Ee.select())};Re();const ge=requestAnimationFrame(Re);return()=>cancelAnimationFrame(ge)});const de=S.useRef(!1),J=typeof z=="function"?z(fe.active,U):z,te=[];J!=null&&J.nav&&te.push(["↑↓",J.nav]),J!=null&&J.side&&h&&te.push(["←→",J.side]),J!=null&&J.complete&&(Te!=null&&Te.accept)&&te.push(["tab",J.complete]),J!=null&&J.tab&&f&&te.push(["tab",J.tab]),J!=null&&J.pick&&te.push(["enter",J.pick]),J!=null&&J.back&&te.push(["esc",J.back]);const ve=Re=>d.jsxs("div",{...Q==null?void 0:Q.attrs,className:Be("picker-input",Q&&"picker-field",Q==null?void 0:Q.className),"data-open":(Q==null?void 0:Q.open)||void 0,onMouseDown:ge=>{var Ee;ge.target.closest("input, .float")||(ge.preventDefault(),(Ee=re.current)==null||Ee.focus())},children:[I,d.jsxs("div",{className:"picker-caret",children:[d.jsx(zo,{font:"mono",bare:!0,ref:re,value:U,spellCheck:!1,"aria-controls":Q==null?void 0:Q.id,"aria-expanded":Q?Q.open:void 0,onFocus:()=>{Q&&!Q.open&&Q.onOpen()},onBlur:ge=>{const Ee=ge.relatedTarget;Q!=null&&Q.open&&Ee instanceof Element&&!Ee.closest(".float")&&c()},onMouseDown:ge=>{const Ee=document.activeElement!==ge.currentTarget;if(de.current=Ee,Q&&Ee){const We=document.getSelection();We&&(!We.isCollapsed||We.toString()!=="")&&We.removeAllRanges()}},onClick:ge=>{if(!Q||!de.current)return;de.current=!1;const Ee=ge.currentTarget;setTimeout(()=>{document.activeElement===Ee&&Ee.selectionStart===Ee.selectionEnd&&Ee.select()},0)},onChange:ge=>{$(ge.target.value),fe.setIndex(N!=null&&N(ge.target.value)?-1:0),Q&&!Q.open&&Q.onOpen()},onKeyDown:ge=>{var Ee;if(Q&&!Q.open){if(ge.key==="ArrowDown"||ge.key==="ArrowUp")Q.onOpen();else if(ge.key==="Escape"){dH(ge.currentTarget),ge.currentTarget.blur();return}}if(B&&fe.active&&(ge.key==="ContextMenu"||ge.key==="F10"&&ge.shiftKey)){const We=(Ee=V.current)==null?void 0:Ee.querySelector('[data-state~="cursor"]');if(We){ge.preventDefault(),ge.stopPropagation(),co.open({items:B(fe.active),owner:"picker",target:We,anchor:We.getBoundingClientRect()});return}}fe.onKeyDown(ge)||!f||ge.key!=="Tab"||ge.shiftKey||(ge.preventDefault(),f())},placeholder:w}),Te&&d.jsxs("div",{className:"picker-ghost","aria-hidden":"true",children:[d.jsx("span",{className:"picker-typed",children:U}),fH(Te)]})]}),A,Re]}),ce=new Map;if(H)for(const Re of q)ce.set(H(Re),(ce.get(H(Re))??0)+1);const ae=d.jsxs("div",{className:"picker-list",ref:V,onMouseDown:Re=>{Q&&Re.target!==Re.currentTarget&&Re.preventDefault()},children:[q.map((Re,ge)=>{const Ee=H==null?void 0:H(Re),We=Ee!==void 0&&(ie||ce.size>1)&&(ge===0||(H==null?void 0:H(q[ge-1]))!==Ee)?d.jsx("div",{className:"picker-group",children:(Y==null?void 0:Y(Ee,ce.get(Ee)??0))??Ee}):null;return d.jsxs(S.Fragment,{children:[We,d.jsx("button",{className:Be("picker-item",o==null?void 0:o(Re)),"data-state":hr({cursor:ge===pe}),title:s==null?void 0:s(Re),onMouseMove:()=>ge!==pe&&fe.setIndex(ge),onClick:()=>{var Ye;fe.pick(Re),(Ye=re.current)==null||Ye.focus()},...le.contextMenu(()=>(B==null?void 0:B(Re))??[]),children:r(Re,ge===pe,U)})]},n(Re))}),q.length===0&&d.jsx("div",{className:"empty",children:typeof M=="function"?M(U):M}),O==null?void 0:O(U,q)]}),xe=te.length>0&&d.jsx(Qj,{hints:te});return Q?ve(Q.open&&d.jsxs(Au,{onClose:c,onEscape:C,boxClass:"picker",anchored:j,id:Q.id,children:[ae,xe]})):d.jsxs(Au,{onClose:c,onEscape:C,boxClass:"picker",anchored:j,coverBy:I?".picker-input > *:first-child":A?".picker-input > *:last-child":void 0,children:[ve(),ae,xe]})}function Si({value:e,reads:t,options:n,onChange:r,placeholder:o,hint:s,className:a,onClose:c}){const[u,h]=S.useState(!1),f=()=>{h(!1),c==null||c()},m=t??e,g=n.find(w=>w.id===m),y=(g==null?void 0:g.chip)??(g==null?void 0:g.label)??m;return d.jsxs("span",{className:"chip-picker",children:[d.jsx(Me,{variant:"ghost",tone:"chrome",mono:!0,on:u,className:Be("chip-picker-btn",a),...Ft(s),onClick:()=>u?f():h(!0),children:y}),u&&d.jsx(Kr,{anchored:{flip:"both",margin:0},onEscape:f,items:n,filter:(w,v)=>{const _=v.trim().toLowerCase().split(/\s+/).filter(Boolean);return w.filter(x=>{const N=`${x.prefix??""} ${x.label??x.id} ${x.suffix??""} ${x.id}`.toLowerCase();return _.every(T=>N.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:f,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:Be("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),f())},onBack:f})]})}function Iy(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=e$(e);return r&&n.push({id:"install",label:r,onClick:()=>t==null?void 0:t.send({t:"install-agent",agent:e.id})}),n}function e$(e){return e.install?e.install==="missing"?"install":"install again":null}const hp=e=>e.reason??"not installed",Ms="";function t$(e,t){return!e||t.length===0?e:EA(e,t)??Ms}function hH(e){var h;const t=mH(e.name);if(t){const f=[t.qualifier,e.description||e.name].filter(Boolean).join(" · ");return{label:t.label,version:t.version,description:f}}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]??((h=e.name.match(/\(([^)]*)\)$/))==null?void 0:h[1]),...o].filter(Boolean).join(" · ");return{label:s,version:a[2],...u?{description:u}:{}}}const pH=/(?:^|[./])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 mH(e){const t=e.match(pH),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 n$(e,t,n,r,o){const s=jE(e),a=xA(e,o),c=_=>a&&_===(s==null?void 0:s.id)?a.id:_,u=t$(t,e),h=c(u||n||(s==null?void 0:s.id)||Ms),f=c(u||(s==null?void 0:s.id)||Ms),m=a?e.filter(_=>_!==s):e,g=m.some(_=>_.id===h),y=m.map(_=>({c:_,words:hH(_)})),w=_=>[_.label,_.version].filter(Boolean).join(" "),v=[...s?[]:[{id:Ms,label:r.label,description:r.description}],...y.map(({c:_,words:x})=>{const N=y.filter(j=>w(j.words)===w(x)).length===1?x:void 0,T=N?N.description:_.description;return{id:_.id,label:N?N.label:_.name,...N!=null&&N.version?{suffix:N.version}:{},...N!=null&&N.version&&y.some(j=>j.c!==_&&j.words.label===N.label)?{chip:w(N)}:{},description:_===a?["default",T].filter(Boolean).join(" · "):T}}),...h&&!g?[{id:h,label:h}]:[]];if(h!==f){const _=v.find(T=>T.id===h),x=v.findIndex(T=>T.id===f),N=v[x];if(N){const T=(_==null?void 0:_.chip)??(_==null?void 0:_.label)??h;v[x]={...N,description:[`${T} now`,N.description].filter(Boolean).join(" · ")}}}return{rows:v,shown:h,picked:f}}const Yc=(e,t)=>`${e} ${t}`;function gH(e){const t=e.indexOf(" ");return t<0?{agent:e,model:Ms}:{agent:e.slice(0,t),model:e.slice(t+1)}}function kH(e,t,n){const r=e.length>1;let o=Yc(t,n);return{rows:e.flatMap(a=>{var f;const c=a.short??a.name,u=a.id===t;if(!a.available||!((f=a.models)!=null&&f.length))return u&&(o=Yc(a.id,Ms)),[{id:Yc(a.id,Ms),label:c,description:a.available?a.checkFailed??"its own default model; the rest are listed once it has run":hp(a),disabled:!a.available}];const h=n$(a.models,u?n:Ms,void 0,{label:`${c} default`,description:`whatever ${a.name} runs when nothing is asked for`},a.defaultModel);return u&&(o=Yc(a.id,h.shown)),h.rows.map(m=>({...m,id:Yc(a.id,m.id),...r&&m.id!==Ms?{prefix:c}:{}}))}),shown:o}}function r$({choices:e,value:t,current:n,runs:r,what:o,defaultLabel:s,defaultDescription:a,placeholder:c,className:u,onChange:h,onClose:f}){const{rows:m,shown:g,picked:y}=S.useMemo(()=>n$(e,t,n,{label:s,description:a},r),[e,t,n,r,s,a]);if(e.length===0)return null;const w=m.find(_=>_.id===g),v=(w==null?void 0:w.chip)??(w==null?void 0:w.label)??g;return d.jsx(Si,{value:y,reads:g,options:m,onChange:h,onClose:f,className:u,hint:t$(t,e)?`asked for ${v}; click to change`:`${v}, the agent's choice; click to pick ${o}`,placeholder:c})}function M1({efforts:e,value:t,current:n,runs:r,onChange:o,onClose:s}){return d.jsx(r$,{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 wH=e=>{var t;return((t=yh.find(n=>n.id===e))==null?void 0:t.description)??""};function L1({value:e,onChange:t,onClose:n}){return d.jsx(Si,{value:e,options:yh.map(r=>({id:r.id,label:r.name,description:r.description})),onChange:t,onClose:n,className:Be("mode-chip",e!=="auto"&&"mode-held"),hint:`${e}: ${wH(e)}. Click to change`,placeholder:"what the agent may do without asking"})}function P1({models:e,value:t,current:n,runs:r,onChange:o,onClose:s}){return d.jsx(r$,{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 yH({agents:e,agent:t,model:n,onChange:r,onClose:o}){const{rows:s,shown:a}=S.useMemo(()=>kH(e,t,n),[e,t,n]);if(s.length===0)return null;const c=s.find(h=>h.id===a),u=c?[c.prefix,c.label,c.suffix].filter(Boolean).join(" "):n;return d.jsx(Si,{value:a,options:s,onChange:h=>{const f=gH(h);r(f.agent,f.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 vH(e){const t=[],n=new Map,r=new Map;for(const s of[...e].sort((a,c)=>a.at-c.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 c={root:s,replies:[]};n.set(s.id,c);const u=s.path??"";r.set(u,[...r.get(u)??[],c])}const o=[...r.entries()].sort(([s],[a])=>s.localeCompare(a)).map(([s,a])=>({path:s,threads:a.sort((c,u)=>(c.root.line??0)-(u.root.line??0))}));return{reviews:t,files:o}}const Ry=e=>e.line===void 0?null:e.startLine!==void 0?`${e.startLine}-${e.line}`:String(e.line);function o$(e){return e==="changes_requested"?"requested changes":e==="approved"?"approved":"reviewed"}const D1=e=>e.split(`
251
- `).map(t=>t?`> ${t}`:">").join(`
252
- `);function bH({root:e,replies:t}){const n=Ry(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":o$(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(D1(e.body));for(const a of t)s.push(`${a.author} replied:
253
- ${D1(a.body)}`);return s.join(`
254
-
255
- `)}function xH({root:e}){if(!e.path)return`review from ${e.author}`;const t=e.path.slice(e.path.lastIndexOf("/")+1),n=Ry(e);return`${t}${n?` (${n})`:""} from ${e.author}`}function s$(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 Vl(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 EH({c:e,query:t}){const n=t.trim();return d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"picker-name",children:["/",Vl(e.name,n?iy(e.name,n):null,0)]}),d.jsx("span",{className:"picker-desc row-dim",children:e.description})]})}function Cn({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 SH(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 _H=/ \| | - | \u2013 | \u2014 | \u00b7 |: /,NH=/^(\d+|[0-9a-f]{8}-[0-9a-f-]{27}|[0-9a-f]{12,})$/i,TH=/^[[:$*{]|\[/;function jH(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(_H).map(a=>a.trim()).filter(Boolean)})),o=new Map;for(const{path:s,parts:a}of r)for(const c of a)o.set(c,(o.get(c)??new Set).add(s));for(const{path:s,parts:a}of r){const c=a.filter(u=>{var h;return(((h=o.get(u))==null?void 0:h.size)??0)<2});c.length>0&&t.set(s,c.join(" "))}return t}function Oy(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(NH.test(r)||TH.test(r))continue;const o=r.replace(/[-_.]+/g," ").trim();if(o)return o[0].toUpperCase()+o.slice(1)}return"Home"}const wg=8,$H=3,CH=50,AH=3;function IH(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 c=a.dynamic?mP(a.path):null;c?(o.push(c),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:jH(e),links:new Map(n.map(a=>[a.path,a.text]))}}function RH(e){if(!e)return"/";try{const t=new URL(e);return t.pathname+t.search+t.hash}catch{return"/"}}function OH(e){const t=e.trim();return/^[/?#]/.test(t)?t:`/${t}`}function MH(e,t){const n=/^[/?#]/.test(t)?e:e.replace(/^\//,"");return t&&n.toLowerCase().startsWith(t.toLowerCase())?n:null}const i$=e=>/^\[\[?\.\.\.|^\*$|^\$$/.test(e),nu=e=>i$(e)||/[[:$*{]/.test(e)&&!/^[^[{:$*]+\?$/.test(e),LH=e=>Ih(`/${e}`).text.slice(1),My=e=>e.split("/").filter(Boolean);function Ly(e,t){const n=t.startsWith("/"),r=t.replace(/^\//,"").split("/"),o=My(e);let s="";const a=[],c=m=>{const g=LH(m);a.push([s.length,s.length+g.length]),s+=g};for(let m=0;m<r.length;m++){const g=r[m],y=o[m];if(y===void 0)return null;if(m<r.length-1){if(i$(y))return{show:t,accept:t};if(nu(y)){if(!g)return null}else if(g.toLowerCase()!==y.toLowerCase())return null;s+=`${nu(y)?g:y}/`;continue}if(nu(y))g?s+=g:c(y);else{if(!y.toLowerCase().startsWith(g.toLowerCase()))return null;s+=y}}for(const m of o.slice(r.length))s+="/",nu(m)?c(m):s+=m;const u=n?1:0,h=(n?"/":"")+s,f=a[0];return{show:h,accept:f?h.slice(0,f[0]+u):h,params:a.map(([m,g])=>[m+u,g+u])}}function PH(e,t){const n=Ly(e,t);return n?n.accept.length>t.length?n.accept:t:Ih(e).literal}function a$(e,t){if(e.kind==="go")return null;if(e.template){const n=Ly(e.path,t);return n&&n.show.length>t.length?n:null}return MH(e.path,t)}const DH=e=>e.trim().replace(/^\//,"").toLowerCase();function l$(e,t){for(let n=0;n<e.length;n++)if("/-_.#".includes(e[n])&&e.startsWith(t,n+1))return!0;return!1}function zH(e,t,n){const r=e.replace(/^\//,"").toLowerCase(),o=t.toLowerCase();return r===n?100:r.startsWith(n)?80:l$(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 FH(e,t){const{text:n,literal:r}=Ih(e);return r.replace(/^\//,"").toLowerCase().startsWith(t)?80:Ly(e,t)?70:l$(n.replace(/^\//,"").toLowerCase(),t)?60:0}function BH(e,t){const n=My(e).findIndex(nu);return n>=0&&t.split("/").length>n}function cu(e,t,n){var c;const r=e.statics.get(t),o=r?null:gP(e.templates,t),s=(r==null?void 0:r.file)??(o?(c=e.templateRoutes.get(o.path))==null?void 0:c.file:void 0),a=s?e.unseen[s]:void 0;return{kind:"page",path:t,title:e.titles.get(t)||e.links.get(t)||Oy(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 c$(e,t){const n=e.unseen[t.file];return{kind:"page",path:t.path,title:Oy(t.path),template:!0,visited:!1,file:t.file,...n?{badge:n}:{},rank:Number.POSITIVE_INFINITY,group:t.path,score:0}}function Df({rank:e,group:t,score:n,...r}){return r}const uh=e=>My(e).length,dh=e=>e.badge==="new"?0:e.badge==="changed"?1:2;function UH(e,t){const n=new Set,r=[];e.history.forEach((f,m)=>{if(f.path===t)return;const g=cu(e,f.path,m);n.has(g.group)||(n.add(g.group),r.push(g))});const o=new Set(r.map(f=>f.path)),s=r.filter(f=>f.badge);for(const[f,m]of e.statics)e.unseen[m.file]&&f!==t&&!o.has(f)&&s.push(cu(e,f,Number.POSITIVE_INFINITY));for(const f of e.templateRoutes.values())e.unseen[f.file]&&!n.has(f.path)&&s.push(c$(e,f));s.sort((f,m)=>dh(f)-dh(m)||f.rank-m.rank);const a=r.filter(f=>!f.badge),c=s.slice(0,wg-Math.min($H,a.length));for(const f of a)c.length<wg&&c.push(f);const u=new Set(c.map(f=>f.path)),h=[...e.statics.keys(),...[...e.links.keys()].filter(f=>!e.statics.has(f))].filter(f=>f!==t&&!u.has(f)&&!o.has(f)).sort((f,m)=>uh(f)-uh(m)||(f<m?-1:f>m?1:0));for(const f of h){if(c.length>=wg)break;c.push(cu(e,f,Number.POSITIVE_INFINITY))}return c.map(Df)}function HH(e,t,n){const r=DH(t),o=OH(t),s=new Map;e.history.forEach((y,w)=>{y.path!==n&&s.set(y.path,cu(e,y.path,w))});for(const y of[...e.statics.keys(),...e.links.keys()])y!==n&&!s.has(y)&&s.set(y,cu(e,y,Number.POSITIVE_INFINITY));const a=[];for(const y of s.values()){const w=zH(y.path,y.title,r);w>0&&a.push({...y,score:w})}let c=null;for(const y of e.templates){const w=e.templateRoutes.get(y.path);if(!c&&!e.statics.has(o)&&y.re.test(o)){c=w;continue}const v=FH(y.path,r);v>=60&&a.push({...c$(e,w),score:v})}a.sort((y,w)=>w.score-y.score||y.rank-w.rank||dh(y)-dh(w)||uh(y.path)-uh(w.path)||(y.path<w.path?-1:y.path>w.path?1:0));const u=new Map,h=[];for(const y of a){if(!y.template&&y.group!==y.path){const w=u.get(y.group)??0;if(w>=AH&&!BH(y.group,r))continue;u.set(y.group,w+1)}if(h.push(y),h.length>=CH)break}if(h.some(y=>y.score===100))return h.map(Df);const f={kind:"go",path:o,...c?{title:Oy(c.path)}:{}},m=h[0];return!c&&m!==void 0&&m.score>=80&&WH(m.path,r)?[...h.map(Df),f]:[f,...h.map(Df)]}function WH(e,t){const n=e.replace(/^\//,"").toLowerCase().slice(t.length);return!t.endsWith("/")&&n.length>0&&!/^[/?#]/.test(n)}function u$(e,{query:t,current:n,here:r}){return t===n||t.trim()===""?UH(e,r):HH(e,t,r)}const KH=[],qH=[];function d$(e,t){const n=L(s=>(t?s.visits[t]:void 0)??KH),r=Mt(e,"pages"),o=Mt(e,"links");return at([e],()=>{XS(r)&&an.post(e,{type:"links"})}),S.useMemo(()=>IH(n,r,o),[n,r,o])}function ZH({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}=Ih(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 f$({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(ZH,{row:e}),e.badge?d.jsx("span",{className:e.badge==="new"?"badge-new":"badge-changed",children:e.badge}):null]})}const h$=e=>e.kind==="page"&&e.file?e.file:e.path,p$=(e,t)=>e.kind==="page"&&e.template?PH(e.path,t):null,m$=e=>e.kind==="page"&&e.template?"fills in the parameter":"goes there";function g$(e,t,n){return e.kind!=="page"?[]:Wh([...e.file&&t.dir?Os({id:t.worktreeId,dir:t.dir},e.file,{},n):[],K_,...e.visited?SH(t.repoId,e.path,n):[]])}function GH({worktreeId:e,repoId:t,url:n,open:r}){const o=lt(),s=Je(),a=L(w=>{const v=Gt(w,e);return v?v.worktree.path:null}),c=d$(e,t),u=RH(n),h=n?Ah(n):null,f=S.useCallback((w,v)=>u$(c,{query:v,current:u,here:h}),[c,u,h]),m=S.useCallback(w=>w===u||w.trim()==="",[u]),g=()=>o({a:"close"}),y=S.useMemo(()=>({open:r,onOpen:()=>o({a:"open",overlay:{kind:"routes"}}),id:"routes",className:"bar-path",attrs:Ft("Go to a page",Bt("routes"))}),[r,o]);return d.jsx(Kr,{anchored:{matchWidth:0,cover:!1,offset:-1},field:y,items:qH,filter:f,initialQuery:u,selectOnMount:!0,idleWhen:m,onIdlePick:w=>{w.trim()===""?an.post(e,{type:"navigate",path:"/"}):an.post(e,{type:"reload"}),g()},keyOf:w=>`${w.kind}:${w.path}`,rowClass:()=>"picker-row",rowTitle:h$,completionOf:(w,v)=>m(v)?null:a$(w,v),narrowTo:p$,onPick:w=>{an.post(e,{type:"navigate",path:w.path}),g()},onBack:g,rowMenu:w=>g$(w,{worktreeId:e,repoId:t,dir:a},{sock:s,dispatch:o}),placeholder:"type a path",keys:(w,v)=>({complete:"completes the path",pick:w?m$(w):v.trim()===""?"goes to the root":"reloads",back:"closes"}),empty:"no pages yet; type a path",row:w=>d.jsx(f$,{row:w})})}function k$(e,t){const n=t.trim();return d.jsx(Cn,{label:Vl(e.label,n?iy(e.label,n):null,0),hint:e.hint&&d.jsx(rs,{k:e.hint})})}function w$({anchored:e,trailing:t}){const n=lt(),r=NT(),o=L(s=>{var a;return((a=s.paletteReturn)==null?void 0:a.mode)==="commands"?s.paletteReturn.q:""});return d.jsx(Kr,{anchored:e,trailing:t,items:r,filter:TT,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,c)=>k$(s,c)})}function y$(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 c=n.get(a)??(r.some(u=>a.startsWith(u))?{path:a,xy:"??"}:void 0);return c?{path:a,status:c}:{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 z1(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 c=o===n.length-1,u=o===r.length-1;if(c!==u)return c?-1:1;if(s!==a)return s<a?-1:1}}function v$(e,t,n,r=50){const o=y$(e,t),s=n.trim().toLowerCase();if(!s){const c=new Map(t.map((m,g)=>[m.path,g])),u=m=>{var g;return c.get(((g=m.status)==null?void 0:g.path)??"")??c.get(m.path)??Number.MAX_SAFE_INTEGER},h=o.filter(m=>m.status).sort((m,g)=>u(m)-u(g)||z1(m.path,g.path)),f=o.filter(m=>!m.status).sort((m,g)=>z1(m.path,g.path));return{rows:[...h,...f].slice(0,r),changed:Math.min(h.length,r)}}const a=x$(o,s);return a.sort((c,u)=>u.score-c.score||c.row.path.localeCompare(u.row.path)),{rows:a.slice(0,r).map(c=>c.row),changed:0}}function b$(e,t){const n=e.toLowerCase(),r=F1(n,t);return r<=0?0:F1(n.slice(n.lastIndexOf("/")+1),t)>0?r+10:r}function x$(e,t){const n=[];for(const r of e){const o=b$(r.path,t);o>0&&n.push({row:r,score:r.status?o+4:o})}return n}function VH(e,t,n,r,o){const s=r.trim().toLowerCase();if(!s)return v$(e,n,r,o).rows.map(u=>({kind:"file",path:u.path,status:u.status}));const a=x$(y$(e,n),s).map(({row:u,score:h})=>({row:{kind:"file",path:u.path,status:u.status},score:h}));for(const u of t){const h=b$(u,s);h>0&&a.push({row:{kind:"folder",path:u},score:h})}const c=u=>u.kind==="folder"?1:0;return a.sort((u,h)=>h.score-u.score||c(u.row)-c(h.row)||u.row.path.localeCompare(h.row.path)),a.slice(0,o).map(u=>u.row)}function YH(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 F1(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 XH(e){const t=e.lastIndexOf("/");return t===-1?[e,""]:[e.slice(t+1),e.slice(0,t+1)]}const B1=[],QH=[],JH=[];function eW({worktreeId:e}){var _;const t=lt(),n=Je(),r=On(),o=L(x=>x.connected);at([e,o,n],()=>qh(e,r.getState(),{sock:n,dispatch:t}));const s=F_(e),a=s.files??QH,c=((_=s.git)==null?void 0:_.files)??JH,u=NT(),h=L(x=>{var N;return((N=x.paletteReturn)==null?void 0:N.mode)==="quick-open"?x.paletteReturn.q:""}),f=L(x=>{var T;const N=(T=Gt(x,e))==null?void 0:T.worktree;return N?N.path:null}),m=L(x=>{var N;return((N=Gt(x,e))==null?void 0:N.repoId)??null}),g=L(x=>{var N;return((N=wu(x))==null?void 0:N.worktreeId)===e}),y=d$(e,m),w=s.page.url?Ah(s.page.url):null,v=S.useCallback((x,N)=>N.startsWith(">")?TT(u,N.slice(1)).map(T=>({kind:"cmd",c:T})):N.startsWith("/")?g?u$(y,{query:N,current:"/",here:w}).map(T=>({kind:"page",page:T})):B1:v$(a,c,N).rows.map(T=>({kind:"file",path:T.path,status:T.status})),[u,a,c,g,y,w]);return d.jsx(Kr,{items:B1,filter:v,keyOf:x=>x.kind==="cmd"?`c:${x.c.id}`:x.kind==="page"?`p:${x.page.kind}:${x.page.path}`:`f:${x.path}`,rowClass:x=>x.kind==="file"?"qo-file":"picker-row",rowTitle:x=>x.kind==="page"?h$(x.page):void 0,completionOf:(x,N)=>x.kind==="page"?a$(x.page,N):null,narrowTo:(x,N)=>x.kind==="page"?p$(x.page,N):null,onPick:(x,N)=>{x.kind==="cmd"?(x.c.sub?t({a:"palette-return",v:{mode:"quick-open",q:N}}):t({a:"close"}),x.c.run()):x.kind==="page"?(an.post(e,{type:"navigate",path:x.page.path}),t({a:"close"})):(Rn({dispatch:t},{worktreeId:e,path:x.path,view:Ii(x.path)}),t({a:"close"}))},onBack:()=>t({a:"close"}),rowMenu:x=>x.kind==="file"&&f?Os({id:e,dir:f},x.path,{},{sock:n,dispatch:t}):x.kind==="page"&&m?g$(x.page,{worktreeId:e,repoId:m,dir:f},{sock:n,dispatch:t}):[],placeholder:"jump to file · type > for commands, / for pages",keys:(x,N)=>N.startsWith("/")?{complete:"completes the path",pick:(x==null?void 0:x.kind)==="page"?m$(x.page):void 0,back:"closes"}:{pick:"opens",back:"closes"},initialQuery:h,empty:x=>x.startsWith(">")?"no matching command":x.startsWith("/")?g?"no pages yet; type a path":"no preview running":"no matches",row:(x,N,T)=>x.kind==="cmd"?k$(x.c,T.slice(1)):x.kind==="page"?d.jsx(f$,{row:x.page}):Rk(x.path,x.status,T,{gutter:c.length>0})})}function Rk(e,t,n,{folder:r=!1,gutter:o=!0}={}){const[s,a]=XH(e),c=n.trim()?YH(e,n.trim()):null;return d.jsxs(d.Fragment,{children:[o&&d.jsx("span",{className:`xy ${t?yw(t.xy):""}`,children:t?vw(t.xy):""}),d.jsxs("span",{className:"name",children:[Vl(s,c,a.length),r&&"/"]}),d.jsx("span",{className:"dir row-dim",children:a&&d.jsxs(d.Fragment,{children:["‎",Vl(a,c,0),"‎"]})}),t&&d.jsx(iT,{f:t})]})}function tW(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(c=>c.available&&c.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: ${hp(e)}`,retry:e$(e),...o}}function Rs({icon:e,verb:t,tip:n,onPress:r,busy:o,onDismiss:s,className:a,children:c}){return d.jsxs("div",{className:Be("composer-offer",a),children:[d.jsx(ht,{name:e,className:"icon-inline"}),d.jsxs("span",{className:Be("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})," "]}),c]}),s&&d.jsx(Lt,{icon:"close",tone:"quiet",className:"composer-offer-close",label:"Not this one",onClick:s})]})}function E$({item:e,n:t,onRemove:n}){const r=Rr();return e.kind==="image"?d.jsx(up,{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(ap,{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(ip,{n:t,name:e.name,source:e.source,lines:e.lines,chars:e.chars,preview:e.preview,text:e.text,onRemove:n})}function S$({children:e}){return d.jsx("code",{className:"composer-offer-whole",children:e})}function nW({children:e}){var n;if(!e.includes("://"))return d.jsx(S$,{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(S.Fragment,{children:[o>0&&" ",r.includes("://")?r.split(new RegExp("(?=\\/)(?<![:/])")).map((s,a)=>d.jsxs(S.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 rW({offer:e,onInstall:t,onDismiss:n}){if(e.state==="installing")return d.jsx(Rs,{icon:"download",busy:!0,children:"Installing Toyon with npm"});if(e.state==="installed")return d.jsxs(Rs,{icon:"check",className:"composer-offer-long",onDismiss:n,children:["Toyon is installed. In a new terminal, ",d.jsx(S$,{children:"toyon restart"})," moves onto it."]});if(e.state==="failed"){const r=tH(e);return d.jsxs(Rs,{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:eH,target:"_blank",rel:"noreferrer",children:"npm's guide"})," ","covers this error."," "]}),"By hand: ",d.jsx(nW,{children:r.command})]})}return d.jsx(Rs,{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 Iu({rows:e,cursor:t,onCursor:n,onPick:r,onHint:o,hover:s=!1}){const a=Ra(),c=S.useRef(null),[u,h]=S.useState(null),f=a&&!!o;RN(c,{rowOf:g=>{if(!f||g.closest("textarea"))return null;const y=g.closest(".slide"),w=y==null?void 0:y.dataset.row,v=w===void 0?void 0:e[Number(w)];return y&&w!==void 0&&(v!=null&&v.hint)&&!v.field?{el:y,key:w,rungs:1,rung:120}:null},onSlide:h,onPick:g=>o==null?void 0:o(Number(g))});const m=g=>{var y;g.target instanceof HTMLTextAreaElement||(g.preventDefault(),(y=g.currentTarget.querySelector("textarea"))==null||y.focus())};return d.jsx("div",{className:Be("choices",s&&"choices-hover",a&&"choices-touch"),ref:c,children:e.map((g,y)=>{const w=!a&&t===y,v=hr({cursor:w,checked:g.checked}),_=g.tone==="deny"&&"choice-deny",x=()=>n==null?void 0:n(y),N=j=>{var A;if(!f)return j;const C=(u==null?void 0:u.key)===String(y)?u.step:null,I=C!==null&&C>0&&((A=g.hint)==null?void 0:A.on)!==!1;return d.jsxs("div",{className:"slide","data-row":y,children:[j,C!==null&&g.hint&&d.jsxs("span",{className:"slide-verb","data-rung":I?"hint":void 0,"aria-hidden":"true",children:[d.jsx("span",{className:"slide-word",children:g.hint.label}),d.jsx(ht,{name:g.hint.icon})]})]},y)},T=d.jsxs(d.Fragment,{children:[!a&&d.jsx(rs,{k:String(y+1),className:"choice-num row-dim"}),d.jsx("span",{className:"choice-label",children:g.label}),!a&&g.hint&&d.jsxs("span",{className:Be("choice-hint row-dim",w&&g.hint.on!==!1&&"on"),children:[d.jsx(rs,{k:g.hint.k})," ",g.hint.label]}),g.description&&d.jsx("span",{className:"choice-desc",children:g.description}),g.sample&&d.jsx("pre",{className:"choice-sample",children:g.sample})]});return g.field?N(d.jsxs("div",{className:Be("picker-item choice row-edge",_),"data-state":v,onMouseMove:x,onMouseDown:m,children:[T,d.jsx(_u,{ref:g.field.ref,bare:!0,font:"ui",rows:1,className:"choice-field",enterKeyHint:g.field.enterKeyHint,placeholder:g.field.placeholder,value:g.field.value,onChange:j=>{var C;return(C=g.field)==null?void 0:C.onChange(j.target.value)}}),a&&g.field.onSend&&d.jsx(Lt,{className:"choice-send",icon:"send",tone:"primary",label:"Send",onClick:g.field.onSend})]},y)):N(d.jsx("button",{type:"button",className:Be("picker-item choice row-edge",_),"data-state":v,disabled:g.disabled,onMouseMove:x,onClick:()=>r(y),children:T},y))})})}function _$(e){return ru(e.key)&&(e.metaKey||e.ctrlKey)&&!e.altKey?!1:e.metaKey||e.ctrlKey||e.altKey}const N$=e=>e.length===1&&e>="1"&&e<="9",ru=e=>e==="Enter"||e==="NumpadEnter";function oW(e,t,n){const r=ru(e.key)&&(e.metaKey||e.ctrlKey);return t?e.key==="Escape"||e.key==="Tab"&&!e.shiftKey?{kind:"field-leave"}:r?{kind:"submit"}:ru(e.key)&&!e.shiftKey?{kind:"field-enter"}:{kind:"typing"}:_$(e)?{kind:"chord"}:e.key==="Escape"?{kind:"escape"}:r?{kind:"submit"}:ru(e.key)||e.key===" "&&n.spacePicks?n.cursor===void 0?{kind:"submit"}:{kind:"pick",at:n.cursor,by:ru(e.key)?"enter":"space"}:e.key==="ArrowUp"||e.key==="ArrowDown"?n.cursor===void 0?null:{kind:"cursor",to:Hu(n.cursor,e.key==="ArrowUp"?-1:1,n.count)}:N$(e.key)&&Number(e.key)<=n.count?{kind:"pick",at:Number(e.key)-1,by:"digit"}:null}function Py(e,t){var o,s,a,c;const n=e.target instanceof HTMLTextAreaElement,r=oW(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(),(c=t.onFieldEnter)==null||c.call(t),!0}}function T$(e){return!e||e===document.body?!1:e.closest(".monaco-editor, .xterm")?!0:(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&!e.closest(".chat-input")}function sW(e,t){at([t],()=>{const o=requestAnimationFrame(()=>{var s;T$(document.activeElement)||(s=e.current)==null||s.focus()});return()=>cancelAnimationFrame(o)});const n=S.useRef(!1),r=S.useCallback(()=>{requestAnimationFrame(()=>{var o;document.activeElement===document.body&&((o=e.current)==null||o.focus())})},[e]);return S.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 fh(e){var n,r;const t=document.activeElement;T$(t)||t&&((n=e.current)!=null&&n.contains(t))||(r=e.current)==null||r.focus({preventScroll:!0})}function hh({root:e,id:t,onKeyDown:n,onKeyUp:r,onPaste:o,children:s}){const a=sW(e,t);return d.jsx("div",{ref:e,className:"card",tabIndex:-1,onKeyDown:n,onKeyUp:r,onPaste:o,onBlur:a,children:s})}function Ru({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 Ok(e){const t=S.useRef(null),n=Cy(t);return"html"in e?d.jsxs("div",{ref:t,className:"card-band md",children:[d.jsx("div",{dangerouslySetInnerHTML:{__html:e.html}}),n]}):d.jsxs("div",{ref:t,className:"card-band card-code",children:[d.jsx("pre",{children:e.code}),n]})}function iW({children:e}){return d.jsx("div",{className:"card-foot",children:e})}const aW=[{selected:[]}];function lW({item:e,worktreeId:t,rootRef:n}){var Q,le;const r=Je(),o=lt(),s=Mt(t,"card"),a=L(U=>{var $;return($=Gt(U,t))==null?void 0:$.worktree.mode})??e.mode,c=a==="plan"?"auto":a,u=(s==null?void 0:s.id)===e.id?s.draft:aW,h=(Q=u[0])==null?void 0:Q.note,f=h!==void 0,m=f?Number(((le=u[0])==null?void 0:le.selected[0])??0):-1,g=(U,$=0)=>o({a:"card-draft",id:t,card:{id:e.id,draft:[{...U[0]??{selected:[]},selected:[String($)]}],current:0}}),y=S.useRef(null),[w,v]=S.useState(0),[_,x]=S.useState(null),N=_!==null,T=e.pieces.length===1?e.pieces[0]:void 0,j=e.plan,C=()=>{j&&Rn({dispatch:o},{worktreeId:t,path:j,view:"preview"})},I=S.useMemo(()=>T?va(T.plan):"",[T]),A=S.useMemo(()=>T?cN(e,T):[{fate:"worktree",label:"go"},{fate:null,label:"not now"}],[e,T]),M=U=>{if(N||!r)return;const $=A[U];$&&($.fate===null?r.send(cx(e,t,!1,void 0)):(T&&$.fate!==Pi(e,T)&&r.send(uN(e,t,T.id,$.fate)),r.send(cx(e,t,!0,h)),x(U)),o({a:"answered",id:t}))},O=()=>{const U=A[w],$=U&&U.fate!==null?w:A.findIndex(q=>q.fate!==null);$!==-1&&((!f||m!==$)&&g(Yf(u,0,h??""),$),v($),requestAnimationFrame(()=>{var q;return(q=y.current)==null?void 0:q.focus()}))},z=()=>o({a:"card-park",id:t,cardId:e.id}),B=()=>{var $;const U=Qc(u,0);U!==u&&g(U,m),($=n.current)==null||$.focus()},H=U=>{Py(U,{count:A.length,cursor:w,onCursor:v,onPick:M,onEscape:z,onFieldEnter:()=>M(m),onFieldLeave:B})||(U.key==="n"?(U.preventDefault(),O()):U.key==="r"&&j&&!T&&(U.preventDefault(),C()))},Y=A.map((U,$)=>({label:U.label,..._===$?{description:"starting"}:U.description?{description:U.description}:{},...U.fate!==null?{hint:{k:"n",label:"add context",icon:"edit",on:!f}}:{},tone:U.fate===null?"deny":void 0,checked:f&&$===m,field:f&&$===m?{ref:y,value:h??"",placeholder:T?U.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",enterKeyHint:"send",onChange:q=>g(Yf(u,0,q),m),onSend:()=>M(m)}:void 0,disabled:N}));if(T)return d.jsxs(hh,{root:n,id:e.id,onKeyDown:H,children:[d.jsx(Ru,{sub:d.jsxs(d.Fragment,{children:[T.project?`Starts a worktree in ${T.project.name}, in ${c} mode${c==="auto"?", which runs without asking":""}, with this as its plan. `:"","Nothing has started yet."]}),children:ek(e)}),d.jsx(Ok,{html:I}),d.jsx(Iu,{rows:Y,cursor:w,onCursor:U=>{v(U),fh(n)},onPick:M})]});const ie=j?d.jsx(Me,{variant:"inline","data-tip":"Open it beside the box; any row can still be moved (r)",onClick:()=>C(),children:"The list is on its page"}):"The list is the agent's";return d.jsxs(hh,{root:n,id:e.id,onKeyDown:H,children:[d.jsx(Ru,{sub:d.jsxs(d.Fragment,{children:[ie,". Nothing has started yet."]}),children:ek(e)}),d.jsx(Iu,{rows:Y,cursor:w,onCursor:U=>{v(U),fh(n)},onPick:M})]})}function cW(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",...uW(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=$y(n);return r===null?null:{verb:"fix",key:n.id,toolId:n.id,command:r}}function uW(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 Mk=new Set;const Lk=new Set;function dW(e){return Lk.add(e),()=>{Lk.delete(e)}}function U1(e){Mk=new Set(Mk).add(e);for(const t of Lk)t()}function fW(){return S.useSyncExternalStore(dW,()=>Mk)}const hW=e=>yh.some(t=>t.id===e);function pW(e){return[...yh.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 mW(e,t,n){const r=e.trim();if(!r)return{pick:!0};const o=t.find(f=>f.id===n),s=r.search(/\s/),a=s===-1?r:r.slice(0,s),c=s===-1?void 0:r.slice(s).trim()||void 0,u=a.toLowerCase(),h=u==="here"?o:t.find(f=>f.name.toLowerCase()===u);return h?{repo:h,...c?{text:c}:{}}:o?{repo:o,text:r}:{pick:!0}}function j$(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 H1(e,t){const n=j$(e,t);return[...n.yours,...n.own,...n.rest]}function W1(e,t){const n=j$(e,t);return{rows:[...n.yours,...n.own],more:n.rest.length}}function gW(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 kW(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 wW(e){const t=e.findIndex(n=>n.kind.startsWith("reject"));return t<0?null:t}function yW(e){const{key:t}=e;return t.length!==1||t===" "||t==="n"||N$(t)||_$(e)?null:t}const K1=[{selected:[]}];function vW({item:e,ask:t,worktreeId:n,rootRef:r}){var H;const o=Je(),s=lt(),a=L(Y=>Y.activeId),c=Mt(n,"card"),u=(c==null?void 0:c.id)===e.id?c.draft:K1,h=(H=u[0])==null?void 0:H.note,f=h!==void 0,m=f?t.choices.findIndex(Y=>{var ie;return Y.id===((ie=u[0])==null?void 0:ie.selected[0])}):-1,g=S.useRef(null),[y,w]=S.useState(0),v=t.plan,_=S.useMemo(()=>t.detail&&!v?va(t.detail):"",[t.detail,v]),x=L(Y=>Y.frame==="phone"),N=()=>{v&&a===n&&!x&&Rn({dispatch:s},{worktreeId:n,path:v,view:"preview",focus:!1})};at([e.id,v],N);const T=t.handoff,j=L(Y=>{var Q;const ie=T?(Q=Wr(Y,n).chat)==null?void 0:Q.find(le=>le.kind==="handoff"&&le.id===T):null;return(ie==null?void 0:ie.kind)==="handoff"?ie:null}),C=Y=>s({a:"card-draft",id:n,card:{id:e.id,draft:Y,current:0}}),I=(Y,ie)=>{const Q=t.choices[Y];Q&&(C([{selected:[Q.id],note:ie}]),w(Y),requestAnimationFrame(()=>{const le=g.current;le&&(le.focus(),le.setSelectionRange(le.value.length,le.value.length))}))},A=Y=>{const ie=t.choices[Y];if(!ie)return;const Q=h==null?void 0:h.trim();o==null||o.send({t:"agent-decide",worktreeId:n,askId:e.id,choiceId:ie.id,...Q?{note:Q}:{}}),s({a:"answered",id:n})},M=()=>s({a:"card-park",id:n,cardId:e.id}),O=()=>{var Y;h!=null&&h.trim()||C(K1),(Y=r.current)==null||Y.focus()},z=Y=>{if(Py(Y,{count:t.choices.length,cursor:y,onCursor:w,onPick:A,onEscape:M,onFieldEnter:()=>A(m),onFieldLeave:O}))return;if(Y.key==="n"){Y.preventDefault(),I(y,h??"");return}const ie=yW(Y);ie!==null&&(Y.preventDefault(),I(f?m:wW(t.choices)??y,(h??"")+ie))},B=t.choices.map((Y,ie)=>{const Q=Y.kind.startsWith("reject"),le=f&&ie===m;return{label:Y.name,tone:Q?"deny":void 0,hint:{k:"n",label:"add context",icon:"edit",on:!f},checked:le,field:le?{ref:g,value:h,placeholder:Q?"what to change, sent with your no":"a note for the work, sent with your yes",enterKeyHint:"send",onChange:U=>C([{selected:[Y.id],note:U}]),onSend:()=>A(m)}:void 0}});return d.jsxs(hh,{root:r,id:e.id,onKeyDown:z,children:[d.jsx(Ru,{sub:j?d.jsxs(d.Fragment,{children:[S3(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(Ok,{code:Ij(t.command)}),_&&d.jsx(Ok,{html:_}),d.jsx(Iu,{rows:B,cursor:y,onCursor:Y=>{w(Y),fh(r)},onPick:A,onHint:Y=>I(Y,h??"")})]})}function bW({item:e,ask:t,worktreeId:n,rootRef:r,numbers:o,onAnswer:s}){const a=Je(),c=lt(),u=On(),h=L(te=>te.clientId),{message:f,questions:m}=t,g=Rl(e.id),y=Mt(g,"attachments"),w=yN(g,n),v=Mt(n,"card"),_=S.useMemo(()=>(v==null?void 0:v.id)===e.id?v:{id:e.id,draft:$4(m),current:0},[v,e.id,m]),{draft:x,current:N}=_,T=N===jl(m),j=m[N],C=x[N],I=!!(j!=null&&j.multi),[A,M]=S.useState(()=>Tl(j,C)),O=S.useRef(null);S.useEffect(()=>{const te=window.visualViewport;if(!te)return;const ve=()=>{O.current&&O.current===document.activeElement&&O.current.scrollIntoView({block:"nearest"})};return te.addEventListener("resize",ve),()=>te.removeEventListener("resize",ve)},[]);const z=(te,ve)=>c({a:"card-draft",id:n,card:{id:e.id,draft:te,current:ve}}),B=D_(),H=te=>{if(B)return;if(s){te&&s(te);return}const ve=te?y:[],ce={t:"agent-answer",worktreeId:n,askId:e.id,...te?{answers:te}:{}};ve.some(Ai)?c({a:"hold-send",id:g,log:n,text:gw(m,te).join(`
256
- `),frame:ce}):(a==null||a.send({...ce,...ve.length?{attachments:ve.map(Ml),boxId:g,clientId:h}:{}}),ve.length&&c({a:"clear-attachments",id:g})),c({a:"answered",id:n})},Y=()=>c(s?{a:"ask-revive",id:n}:{a:"card-park",id:n,cardId:e.id}),ie=()=>{Ym(m,x)&&H(x)},Q=te=>{M(Tl(m[te],x[te])),z(x,te)},le=te=>{j!=null&&j.note&&(z(zb(x,N,te,I),N),requestAnimationFrame(()=>{var ve;return(ve=O.current)==null?void 0:ve.focus()}))},U=te=>{if(!(j!=null&&j.note))return;const ve=j.options[te];if(M(te),!ve||I)return le(!ve);z(zb(Db(x,N,ve.value,!1),N,!1,!1),N),requestAnimationFrame(()=>{var ce;return(ce=O.current)==null?void 0:ce.focus()})},$=()=>U(A),q=te=>{const ve=B4(m,te,N);M(ve.cursor),z(te,ve.current),ve.send&&Ym(m,te)&&H(te)},V=te=>{if(Fb(j,te))return M(te),le(!0);const ve=j==null?void 0:j.options[te];if(!j||!ve)return;const ce=Db(Qc(x,N),N,ve.value,I);if(I){M(te),z(ce,N);return}q(ce)},W=te=>{if(!I||Fb(j,te)||!A4(j,x[N]))return V(te);q(Qc(x,N))},re=()=>{var ve;const te=Qc(x,N);te!==x&&(z(te,N),M(Tl(j,te[N]))),(ve=r.current)==null||ve.focus()},fe=()=>{var ve;const te=Qc(x,N);if((ve=r.current)==null||ve.focus(),!wa(te[N])){te!==x&&(z(te,N),M(Tl(j,te[N])));return}q(te)},pe=te=>{if(w.onPasteKey(te),!Py(te,{count:T?m.length:C4(j),cursor:T?void 0:A,spacePicks:I,onCursor:M,onPick:(ve,ce)=>T?Q(ve):ce==="enter"?W(ve):V(ve),onSubmit:ie,onEscape:Y,onFieldEnter:fe,onFieldLeave:re})){if(te.key==="ArrowLeft"||te.key==="ArrowRight"||te.key==="Tab"){te.preventDefault();const ve=te.key==="ArrowLeft"||te.key==="Tab"&&te.shiftKey;return Q(D4(N,ve?-1:1,F4(m)))}if(te.key==="n"&&(j!=null&&j.note))return te.preventDefault(),$();if(te.key==="s"&&!s)return te.preventDefault(),H()}},Te=te=>m.length===1&&!te.multi,je=(te,ve)=>d.jsxs(iW,{children:[(!te||!Te(te))&&d.jsx(Me,{variant:"outline",size:"md",disabled:B||!Ym(m,x),onClick:ie,children:"send"}),(te==null?void 0:te.note)&&ve&&ve.selected.length>0&&ve.note===void 0&&d.jsxs(Me,{tone:"quiet",size:"md",onClick:()=>le(!1),children:[d.jsx(rs,{k:"n",chip:!0}),"add a note"]}),!s&&d.jsxs(Me,{tone:"quiet",size:"md",onClick:()=>H(),children:[d.jsx(rs,{k:"s",chip:!0}),"skip"]}),d.jsx(Lt,{className:"card-attach",icon:"attach",tone:"chrome",label:"Attach a picture or a file",onClick:()=>mN(u,g)})]}),de=y.length>0&&d.jsx(Qh,{children:d.jsx("div",{className:"card-chips",children:Yk(y,o).map(([te,ve])=>{const ce=()=>c({a:"detach",id:g,key:te.key});return te.kind==="pick"?null:d.jsx(E$,{item:te,n:ve,onRemove:ce},te.key)})})}),J=(te,ve)=>{const ce=ve===N,ae=x[ve],xe=BS(ae,!!te.multi),Re=Ee=>({ref:ce?O:void 0,value:(ae==null?void 0:ae.note)??"",placeholder:Ee,enterKeyHint:jl(m)===-1?"send":"next",onChange:We=>z(Yf(x,ve,We),ve),...jl(m)===-1?{onSend:fe}:{}}),ge=te.options.map(Ee=>{const We=!!(ae!=null&&ae.selected.includes(Ee.value));return{label:d.jsxs(d.Fragment,{children:[kw(Ee.label),U4(Ee.label)&&d.jsx("span",{className:"badge-recommended",children:"recommended"})]}),description:Ee.description,sample:Ee.preview,hint:te.note&&!te.multi?{k:"n",label:"add a note",icon:"edit",on:(ae==null?void 0:ae.note)===void 0}:void 0,checked:We,field:We&&!xe&&(ae==null?void 0:ae.note)!==void 0?Re("a note for the agent, sent with your pick"):void 0}});return te.note&&ge.push({label:te.note.label,description:xe?void 0:"your own answer",checked:xe,field:xe?Re("your own answer"):void 0}),d.jsxs("div",{className:Be("card-page",!ce&&"card-page-off"),children:[d.jsx(Ru,{children:te.text||f}),ce&&de,d.jsx(Iu,{rows:ge,cursor:ce?A:void 0,onCursor:Ee=>{M(Ee),fh(r)},onPick:Ee=>{var We;V(Ee),(We=r.current)==null||We.focus()},onHint:U}),je(te,ae)]},te.id)};return d.jsxs(hh,{root:r,id:e.id,onKeyDown:pe,onKeyUp:w.onPasteKeyUp,onPaste:w.onPaste,children:[m.length>1&&d.jsx("div",{className:"card-tabs",children:d.jsx(Wu,{label:"questions",owner:"ask",items:[...m.map((te,ve)=>({id:String(ve),label:te.header||`question ${ve+1}`,lead:d.jsx("span",{className:Be("dot card-step",wa(x[ve])&&"answered")})})),{id:String(m.length),label:"send",far:!0}],current:String(N),onPick:te=>{var ve;Q(Number(te)),(ve=r.current)==null||ve.focus()}})}),d.jsxs("div",{className:"card-pages",children:[m.map(J),jl(m)!==-1&&d.jsxs("div",{className:Be("card-page",!T&&"card-page-off"),children:[d.jsx(Ru,{children:"Send these answers?"}),T&&de,d.jsx(Iu,{hover:!0,rows:m.map((te,ve)=>{const ce=wa(x[ve])?R4(te,x[ve]):void 0;return{label:d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"row-dim",children:te.header||`question ${ve+1}`})," ",d.jsx("span",{className:Be(!ce&&"row-dim"),children:ce?ce.pick:"no answer yet"})]}),description:ce==null?void 0:ce.note}}),onPick:te=>{var ve;Q(te),(ve=r.current)==null||ve.focus()}}),je()]})]})]})}const xW=_N("top"),EW=5*6e4;function $$({usage:e,limits:t,auth:n,now:r}){const o=t?J5(t,r):[],s=o.length?K5(n):void 0,a=t&&r-t.at>EW?Ew(r-t.at):null,c=(e==null?void 0:e.cost)!==void 0?` · ${qu(e.cost)}`:"";return d.jsxs("div",{className:"usage-figures",children:[e&&d.jsx(q1,{name:"context",used:e.used/e.size,sub:`${Ax(e.used)} of ${Ax(e.size)}${c}`}),s&&d.jsx("div",{className:"usage-who section-title",children:s}),o.map(u=>d.jsx(q1,{name:u.name,used:u.used,sub:u.sub},u.key)),a&&d.jsxs("div",{className:"usage-stale hint",children:["read ",a," ago"]})]})}function SW({onClose:e,...t}){return d.jsx(Fs,{className:"usage-panel",anchor:"parent",placement:xW,onDismiss:e,onKey:n=>{n.key==="Escape"&&(n.stopPropagation(),e())},children:d.jsx($$,{...t})})}function q1({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 C$(e,t,n){const r=S.useRef(n);r.current=n,at([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 Z1="not answering; send once Toyon is back",G1=[],_W=[],NW=new Set(["ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),TW=150,jW=3,V1=e=>({kind:"cmd",c:e});function $W(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 CW(e,t,n,r){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":t?"no matches":d.jsx("span",{className:"live-text",children:"listing files"})}function AW(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 uu({active:e,draft:t,archived:n,found:r,project:o,greenfield:s,placement:a="dock"}){var Js,gc,kc,wc,yc,Ja,dd,fd,vs,el,ei,tl;const c=a==="screen",u=lt(),h=Je(),f=On(),m=!!t,g=(e==null?void 0:e.worktree.id)??null,y=e==null?void 0:e.worktree.repoId,w=o?Ul:n?n.id:r?r.id:Ca(e),v=!!n||!!r,_=n?n.restorable:!!r&&!r.locked,x=Mt(w,"draft"),N=Mt(w,"attachments"),T=Mt(w,"notice"),j=((Js=e==null?void 0:e.worktree.owns)==null?void 0:Js.join(", "))??"",C=S.useRef({id:g,owns:j});at([g,j],()=>{const D=C.current;C.current={id:g,owns:j},!(D.id!==g||D.owns===j||!j||!w||n)&&u({a:"notice",id:w,text:`Running its own ${j} here now: this branch changed it.`})});const I=Mt(w,"mark"),A=(I==null?void 0:I.by)==="walk"?I:void 0,M=Mt(g,"chat"),O=Mt(g,"queue"),z=S.useMemo(()=>g&&!m?qw(M):null,[g,m,M]),B=Mt(g,"cardParked"),H=Mt(g,"sending"),Y=S.useMemo(()=>g&&!m&&!H?FS(M):null,[g,m,H,M]),ie=Mt(g,"askRevived"),Q=!z&&Y&&ie===Y.id?Y:null,le=z&&B!==z.id?z:Q,U=Q?Rl(Q.id):null,$=Mt(U,"attachments"),q=z?B===z.id?z:null:Y&&!Q?Y:null,V=S.useRef(null),W=Ra(),re=zw(),fe=Mt(re,"page"),pe=Fu(),Te=qz(),je=Xj(),de=rH(),J=L(D=>D.globalInstall),te=!!je&&!!g&&!m&&!le&&oH({prompt:je,offered:de,agent:e==null?void 0:e.agent,chat:M}),ve=fW(),ce=S.useMemo(()=>g&&!m?cW(M,{queued:O.length,sending:!!H,card:!!(le||q),dismissed:ve}):null,[g,m,M,O.length,H,le,q,ve]),ae=D=>w&&u({a:"set-draft",id:w,text:D}),xe=L(D=>D.clientId),Re=L(D=>D.repos),ge=L(D=>D.repos.find(Oe=>Oe.id===(e==null?void 0:e.worktree.repoId))??null),Ee=L(D=>D.defaultAgent),We=L(D=>D.agentChosen),Ye=m||!!s||!!o,ln=!Ye&&!!e&&!e.worktree.agent,cn=Ye||ln,gt=(t==null?void 0:t.agent)??Ee,Ue=L(D=>D.agents.find(Oe=>Oe.id===(cn?gt:e==null?void 0:e.worktree.agent)));C$(h,g??(Ye?"new":null),Ue);const zt=!!(Ue!=null&&Ue.quick),pt=(Ue==null?void 0:Ue.models)??G1,At=(Ue==null?void 0:Ue.efforts)??G1,Kt=Ue==null?void 0:Ue.defaultModel,xt=Ue==null?void 0:Ue.defaultEffort,un=((gc=Ue==null?void 0:Ue.picks)==null?void 0:gc.model)??"",Ct=((kc=Ue==null?void 0:Ue.picks)==null?void 0:kc.effort)??"",Ut=(D,Oe,ct)=>h==null?void 0:h.send({t:"set-agent-pick",agent:D,field:Oe,value:ct}),Et=D=>Ut(gt,"model",D),er=D=>Ut(gt,"effort",D),Qt=L(D=>D.agents),Nn=(D,Oe)=>{Ut(D,"model",Oe),D!==gt&&Zn(D)},Zn=D=>{m?u({a:"draft-agent",id:D}):h==null||h.send({t:"set-default-agent",agent:D})},nn=tW(Ue,Qt,cn),X=nn==null?void 0:nn.other,be=Mt(g,"model"),Ve=Mt(g,"effort"),Qe=Mt(g,"usage")??(e==null?void 0:e.usage),Ht=((wc=ge==null?void 0:ge.picks)==null?void 0:wc.mode)??jg,St=D=>{ge&&(h==null||h.send({t:"set-repo-pick",repoId:ge.id,field:"mode",value:D}))},bn=(e==null?void 0:e.worktree.mode)??jg,P=L(D=>D.picking),ne=L(D=>D.layout.term),Se=ZS((e==null?void 0:e.procs)??[]),Ge=vn("composer"),It=Mt(g,"files"),Pt=S.useMemo(()=>YS(It??_W),[It]),De=L(D=>D.visible),ze=S.useMemo(()=>cp(De,y,g),[De,y,g]),Ke=L(D=>y?D.archived[y]:void 0),Vt=S.useMemo(()=>nj(ze,Ke),[ze,Ke]),Yt=S.useMemo(()=>tj(It,Vt),[It,Vt]),yn=S.useMemo(()=>[...ze,...(Ke??[]).map(D=>({title:D.title,branch:D.branch,dir:D.path.slice(D.path.lastIndexOf("/")+1)}))],[ze,Ke]),_t=Mt(g,"git"),gn=(_t==null?void 0:_t.files.length)??(e==null?void 0:e.dirty)??0,xn=(_t==null?void 0:_t.unpushed)??(e==null?void 0:e.unpushed)??0,Rt=L(D=>{var Oe;return g?(Oe=D.shipping[g])==null?void 0:Oe.op:void 0}),Mn=L(D=>{var Oe;return g?(Oe=D.shipping[g])==null?void 0:Oe.step:void 0}),rn=L(D=>Hl(D,y)),cr=L(D=>{var Oe;return rn?(Oe=D.shipping[rn.id])==null?void 0:Oe.op:void 0}),se=rn&&ge&&Ye?HS(ge.defaultBranch,rn):null,Ne=L(D=>m?eD(D.rows,y,gt,Ee):g),rt=Mt(Ne,"commands"),yt=rt.some(D=>D.name==="compact"),jt=os(e==null?void 0:e.agent),Ln=L(D=>r_(D,g)),Or=jt&&!!g&&!m,Gn=e==null?void 0:e.worktree.lastTurn,Xt=!x.trim()&&N.length===0,Qr=!m&&!s&&Xt&&!jt?Gn:void 0,ft=!m&&!s&&e&&da(e.worktree)?e.worktree.landing:void 0,Un=!!(ft!=null&&ft.ready)&&!ft.stale&&!pf(ft,gn,zt,Ue==null?void 0:Ue.name),ot=Xt&&(!jt||Un)?ft:void 0,$e=gn>0&&!!(ot!=null&&ot.subject),qe=gn||(((yc=_t==null?void 0:_t.extras)==null?void 0:yc.committed.length)??0),kt=!m&&!s&&Xt&&!jt&&!!e,ut=!!(e!=null&&e.worktree.landed)&&gn===0,fn=kt&&ut,Wt=e?Eh({...e.worktree,landed:ut}):void 0,sn=kt&&!fn?Wt:void 0,tr=!ut&&(Wt==null?void 0:Wt.state)==="open"?Wt:void 0,An=!!tr&&(gn>0||xn>0),Pn=(Wt==null?void 0:Wt.state)==="closed",br=_i((ge==null?void 0:ge.config)??{}),Z=S.useMemo(()=>pW(Bf(_i((ge==null?void 0:ge.config)??{}),ge==null?void 0:ge.defaultBranch)),[ge]),we=()=>g&&(h==null?void 0:h.send({t:"chat",worktreeId:g,text:"/compact"})),Ze=Ye?"nothing to compact until the first reply":yt?jt?"wait for the turn to end":void 0:"this agent offers no compact command",qt=yt&&Qe?Z5(Qe.used/Qe.size):void 0,wt=Ue==null?void 0:Ue.limits,dn=Ye?void 0:Qe,ir=(!!g||Ye)&&!!(dn||wt),mr=Date.now(),[ar,po]=S.useState(!1),Zt=S.useRef(0),Nt=W?()=>d.jsx($$,{usage:dn,limits:wt,auth:Ue==null?void 0:Ue.auth,now:Date.now()}):void 0,jo=()=>{window.clearTimeout(Zt.current),po(!1)};at([g],jo);const Tn=Fw(),Jt=(Tn==null?void 0:Tn.owner)==="composer"&&Tn.key==="usage";at([Jt],()=>{Jt&&jo()});const qr=()=>[{id:"compact",label:"compact the context",detail:Ze||!Qe?void 0:q5(Qe.used/Qe.size),disabled:Ze,onClick:we}],[Mr,Ce]=S.useState(0),[F,K]=S.useState(null),ue=S.useRef(null),ke=w&&!v&&!o?fg(x,Mr,D=>ze.some(Oe=>T1(D,Oe))):null,Le=ke==null?void 0:ke.kind,He=ke==null?void 0:ke.query,Ot=S.useMemo(()=>{if(He===void 0)return[];if(Le==="command")return He.trim()?nB(H1(Z,rt),He).slice(0,8).map(V1):W1(Z,rt).rows.map(V1);const D=[],Oe=(_t==null?void 0:_t.files.length)??0;Oe>0&&"changes".startsWith(He.toLowerCase())&&D.push({kind:"changes",n:Oe});const ct=He.trim(),$t=ct?ze.filter(or=>T1(ct,or)):ze.slice(0,jW);return D.push(...$t.map(or=>({kind:"worktree",...or}))),D.push(...VH(It??[],Pt,(_t==null?void 0:_t.files)??[],He,8)),D},[Le,He,It,Pt,_t,rt,Z,ze]),hn=ke!==null&&ke.from!==F&&!A&&!(ke.kind==="file"&&eB(x,ke.from,Yt)),nr=Le==="command"&&He!==void 0&&!He.trim()?W1(Z,rt).more:0,kn=S.useRef(null),Us=S.useRef(null),rr=S.useRef(null),Di=(D,Oe,ct,$t)=>{var ti;const{text:or,caret:Hn}=rN(x.slice(0,Oe)+x.slice(ct),Oe,$t);ae(or),K(((ti=fg(or,Hn))==null?void 0:ti.from)??null),requestAnimationFrame(()=>{D.focus(),D.setSelectionRange(Hn,Hn),Ce(Hn)})},nc=D=>{const Oe=kn.current;return!D||!Oe?!1:(Di(Oe,Oe.selectionStart,Oe.selectionEnd,D),!0)},{onPaste:mp,onPasteKey:zi,onPasteKeyUp:Fi}=yN(w,g,D=>nc(Fj(D,yn)));r6(Us,kn,D=>nc(t7(D,yn)));const Ho=()=>{var D;return(D=V.current??kn.current)==null?void 0:D.focus()},$o=Ho;at([s?e==null?void 0:e.worktree.id:null],()=>{if(!s)return;const D=requestAnimationFrame(()=>{var ct;const Oe=document.activeElement;(!Oe||Oe===document.body)&&((ct=kn.current)==null||ct.focus())});return()=>cancelAnimationFrame(D)});const La=L(D=>D.focusChat),Xu=S.useRef(La),Hs=!!B_();at([La],()=>{if(La===Xu.current||(Xu.current=La,Hs!==!!s))return;const D=requestAnimationFrame(Ho);return()=>cancelAnimationFrame(D)});const ws=le==null?void 0:le.id,Pa=S.useRef({id:g,cardUpId:ws});at([g,ws],()=>{const D=Pa.current;if(Pa.current={id:g,cardUpId:ws},ws||!D.cardUpId||D.id!==g||Hs!==!!s||W&&!q)return;const Oe=requestAnimationFrame(()=>{var $t;const ct=document.activeElement;(!ct||ct===document.body)&&(($t=kn.current)==null||$t.focus())});return()=>cancelAnimationFrame(Oe)});const Bi=L(D=>D.walked),Wo=S.useRef(Bi);at([Bi],()=>{if(Bi===Wo.current||(Wo.current=Bi,Hs!==!!s))return;const D=requestAnimationFrame(()=>{const Oe=document.activeElement;(!Oe||Oe===document.body||Oe.closest(".rail"))&&Ho()});return()=>cancelAnimationFrame(D)});const Ui=$N({results:Ot,keyOf:D=>D.kind==="cmd"?`c:${D.c.name}`:D.kind==="changes"?"changes":D.kind==="worktree"?`w:${D.id}`:`f:${D.path}`,q:(ke==null?void 0:ke.query)??"",listRef:ue,tabPicks:!0,onPick:D=>{if(!ke)return;const{text:Oe,caret:ct}=tB(x,ke,AW(D));ae(Oe),K(ke.from),requestAnimationFrame(()=>{const $t=kn.current;$t&&($t.focus(),$t.setSelectionRange(ct,ct),Ce(ct))})}}),gr=g||v?v7(x):null,Qu=S.useMemo(()=>H1(Z,rt),[Z,rt]),Da=gW(x,Qu),za=gr===""&&e?m?" 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,Fa=Da??za,$r=(e==null?void 0:e.worktree.title)??"untitled",mo=(Ja=Gn==null?void 0:Gn.recap)==null?void 0:Ja.text,Hi=()=>{g&&ji(h,u,{t:"land",worktreeId:g})},Ws=D=>{g&&(h==null||h.send({t:"judge",worktreeId:g,...D?{note:D}:{}}))},gp=!!((dd=ge==null?void 0:ge.config.check)!=null&&dd.trim()),Wi=ey(ft,gn,zt),rc=kt&&!Rt&&!Ye&&da(e.worktree)&&!ut&&!Pn&&qe>0&&(!ft||!!ft.stale||Wi==="unanswered"),Ks="Archive this worktree when you are done here; the rail's archived section brings it back with its chat.",Ba=An?"update":Jk(br,(e==null?void 0:e.worktree)??{}),oc=ge?xh(ge):"main",kp=An&&tr?`Commit, take ${oc} in and push the branch; PR #${tr.number} takes the new commits.`:`${Bf(br,ge==null?void 0:ge.defaultBranch)}.`,Ju=sn&&!mo?{links:p5(sn)}:{},Lr=g?fn?{word:"archive",kind:"archive",line:(Wt==null?void 0:Wt.state)==="merged"?$s(Wt):`landed on ${(ge==null?void 0:ge.defaultBranch)??"main"}.`,tip:Ks,run:()=>Pl(h,u,[g])}:(sn==null?void 0:sn.state)==="open"&&!An?JN(sn)?{word:"land",kind:"merge",line:mf(mo??$s(sn)),tip:`${$s(sn)} ${QN(sn)}.`,...Ju,run:Hi,ships:!0}:{word:"view",kind:"view",line:mf(mo??$s(sn)),tip:`${$s(sn)} Open the PR on GitHub.`,...Ju,run:()=>window.open(sn.url,"_blank")}:(sn==null?void 0:sn.state)==="closed"?{word:"archive",kind:"archive",line:$s(sn),tip:`${$s(sn)} ${Ks}`,run:()=>Pl(h,u,[g])}:rc?{word:"check",kind:"check",line:(ft==null?void 0:ft.subject)??mf(mo??y5(qe)),tip:eT(ft,gp,Wi),run:Ws}:ot!=null&&ot.ready&&!pf(ot,gn,zt,Ue==null?void 0:Ue.name)?{word:Ba,kind:"ship",line:ot.subject??mf(mo??(bx(ot,qe)||"ready")),tip:[bx(ot,qe),w5(oc,e==null?void 0:e.behind),kp,ot.subject&&gn>0?"Tab from the word edits the message first.":""].filter(Boolean).join(" "),run:Hi,ships:!0}:null:null,Ua=(fd=e==null?void 0:e.worktree.lands)==null?void 0:fd.at(-1),ed=Ua&&Xw(Ua),Ha=S.useMemo(()=>{const D=M?iN(M):null;return(D?I3(D):[]).filter(Oe=>{const ct=De.find($t=>$t.worktree.id===Oe.id);return!!ct&&!ct.worktree.landed})},[M,De]),wp=Ha.length>0?d.jsxs(d.Fragment,{children:["After"," ",Ha.map((D,Oe)=>d.jsxs(S.Fragment,{children:[Oe>0&&(Oe===Ha.length-1?" and ":", "),d.jsx(lo,{id:D.id,title:D.title})]},D.id))," ",Ha.length===1?"lands":"land","."]}):null,sc=((Lr==null?void 0:Lr.kind)==="ship"||(Lr==null?void 0:Lr.kind)==="check")&&ot?wp??v5(ot,Wi):(Lr==null?void 0:Lr.word)==="archive"&&ed?Xr(ed):null,ic=S.useRef(null);Rt!=="land"&&(ic.current=g&&(Lr!=null&&Lr.ships)?{id:g,verb:Lr,under:sc}:null);const Ki=Rt==="land"&&Xt&&((vs=ic.current)==null?void 0:vs.id)===g?ic.current:null,Dn=Ki?Ki.verb:Lr,td=(el=Dn==null?void 0:Dn.links)!=null&&el.length?m5(Dn.line,Dn.links):null,Wa=!!(Dn!=null&&Dn.ships)&&Rt==="land",ac=Ow(Mn,Mw),qs=Nu(e,"commit"),Ka=Nu(e,"check"),Zs=nT(Wa?qs:Ka),nd=Ti(ny(Zs)?Zs==null?void 0:Zs.since:void 0),qa=ot?ot.check==="pending"&&Ka&&Zs===Ka?nh("Checking the work",Ka,nd):pf(ot,gn,zt,Ue==null?void 0:Ue.name):null,lc=Dn&&Wa?ac?`${Dn.word}: ${ac}`:`${Dn.word} ${Dn.line}`:null,rd=lc&&qs&&Zs===qs?nh(lc,qs,nd):lc,od=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?Dn?"":qa||(sn?$s(sn):Qr?ty(Qr):s?`describe ${$r}…`:Ye?"describe a change":c?`message agent on ${$r}`:`message agent on ${$r}; / for a command, ! for a shell command`):"no worktree selected",Za=x!==""||Fa||!e?null:Wa?ac?null:Ki?Ki.under:sc:Dn?sc:sn||qa?mo??(ot==null?void 0:ot.subject)??null:null,sd=S.useRef(!1);S.useEffect(()=>{const D=hn&&!sd.current;sd.current=hn,D&&((ke==null?void 0:ke.kind)==="file"&&g?qh(g,f.getState(),{sock:h,dispatch:u}):(ke==null?void 0:ke.kind)==="command"&&Ne&&rt.length===0&&(h==null||h.send({t:"list-commands",worktreeId:Ne})))},[hn,ke==null?void 0:ke.kind,rt.length,g,Ne,h,f,u]);const id=()=>{if(!e)return;const D=[],Oe=fe;if(Oe.url)try{const or=new URL(Oe.url);D.push(`current route: ${or.pathname}${or.search}`)}catch{}Oe.title&&D.push(`page title: ${Oe.title}`);const ct=[];s&&ct.push(lH(e.worktree.title,ge==null?void 0:ge.configFile)),D.length>0&&ct.push(`What the user is looking at right now:
257
- ${D.join(`
258
- `)}`);const $t=x7(M);return $t&&ct.push($t),ct.length>0?ct:void 0},Ga=D=>{Ye?St(D):g&&D!==bn&&(h==null||h.send({t:"set-worktree-mode",worktreeId:g,mode:D}))},Vn=D=>w&&u({a:"notice",id:w,text:D}),Va=D_(),ad=(D,Oe="")=>{if(!e||!g)return;if(D==="handoff"){if(Ye)return Vn("a new worktree has nothing to continue yet");const $t=mW(Oe,Re,e.worktree.repoId);"pick"in $t?u({a:"open",overlay:{kind:"handoff",worktreeId:g}}):h==null||h.send({t:"handoff-ask",worktreeId:g,repoId:$t.repo.id,...$t.text?{text:$t.text}:{}});return}if(D==="archive"){ut||Pn?Pl(h,u,[g]):Vn("archive is for a landed worktree; this one has not landed");return}if(D==="check"){Ye||!da(e.worktree)?Vn("nothing to check from here"):jt?Vn("wait for the turn to end"):qe===0?Vn("nothing to check: no changes here"):Ws(Oe||void 0);return}const ct=ft?pf(ft,gn,zt,Ue==null?void 0:Ue.name):null;Ye||!da(e.worktree)?Vn("nothing to land from here"):ut?Vn(`already landed on ${(ge==null?void 0:ge.defaultBranch)??"main"}`):ct?Vn(ct):jt&&(!ft||ft.stale)?Vn("wait for the turn to end"):ft!=null&&ft.stale?Vn("the work changed since this was checked; check again first"):Hi()},qi=N.some(Ai),cc=()=>{var D;W&&((D=kn.current)==null||D.blur())},Gs=()=>{w&&(h==null||h.send({t:"set-draft",boxId:w,text:x,clientId:xe})),cc()},Vs=(D,Oe,ct,$t)=>{u({a:"hold-send",id:D,log:Oe,text:ct,frame:$t}),cc()},is=()=>{if(!w)return;const D=kW(x,Z),Oe=D&&hW(D.name)?D.name:void 0;if(o){if(o.busy)return;if(Va)return Vn(Z1);if(o.why)return Vn(o.why);(gt!==Ee||!We)&&(h==null||h.send({t:"set-default-agent",agent:gt})),Gs(),o.create();return}if(Xt)return;if(Va&&!(Oe&&!(D!=null&&D.args)))return Vn(Z1);const ct=gr===null&&(!D||!!Oe&&!!D.args);if(nn&&nn.kind!=="unready"&&Ue&&ct){Vn(nn.kind==="installing"?`${Ue.name} is still installing`:nn.retry?`nothing runs here until ${Ue.name} is installed`:nn.text);return}const $t=u1(x.trim(),Yt),or=()=>({text:$t,attachments:N.length?N.map(Ml):void 0});if(n){if(!n.restorable)return;if(gr!==null){Vn("nothing runs here until it is restored");return}const ko={t:"restore-worktree",archiveId:n.id,clientId:xe};if(qi)return Vs(w,w,$t,ko);Gs(),h==null||h.send(Jc(ko,w,$t,N)),u({a:"sending",id:w,message:or()}),u({a:"sent-box",id:w});return}if(r){if(r.locked)return;if(gr!==null){Vn("nothing runs here until Toyon takes it over; its menu on the rail opens a shell");return}const ko={t:"adopt-worktree",worktreeId:r.id,clientId:xe};if(qi)return Vs(w,w,$t,ko);Gs(),h==null||h.send(Jc(ko,w,$t,N)),u({a:"sending",id:w,message:or()}),u({a:"sent-box",id:w});return}if(!e||!g)return;if(gr!==null){if(gr&&Rt&&!m){Vn(`${pI(Rt)} is running here; run the command once it is done`);return}gr&&m?u({a:"term-run",id:g,command:gr}):gr&&(h==null||h.send({t:"exec",worktreeId:g,command:gr})),ae("");return}if(D&&!Oe){ad(D.name,D.args),ae("");return}if(Oe&&!(D!=null&&D.args)){Ga(Oe),ae("");return}const Hn=D?u1(D.args,Yt):$t,ti=id(),vc=N.length?N.map(Ml):void 0;if(Oe&&Ga(Oe),Ye){const ko=Lu(e.worktree)?{worktreeId:g}:{},hd={clientId:xe,repoId:e.worktree.repoId,context:ti,agent:gt,...t!=null&&t.profile?{profile:t.profile}:{},...Oe?{mode:Oe}:{},...t!=null&&t.carry?{carry:!0}:{}};(gt!==Ee||!We)&&(h==null||h.send({t:"set-default-agent",agent:gt}));const bc={t:"create-worktree",...hd,...ko};qi?Vs(w,w,Hn,bc):(Gs(),h==null||h.send(Jc(bc,w,Hn,N)),u({a:"sending",id:w,message:{text:Hn,attachments:vc}}),u({a:"sent-box",id:w}))}else{const ko={t:"chat",worktreeId:g,clientId:xe,context:ti};qi?Vs(w,g,Hn,ko):(Gs(),h==null||h.send(Jc(ko,w,Hn,N)),Ln||u({a:"sending",id:g,message:{text:Hn,attachments:vc}}),u({a:"sent-box",id:w}))}s&&u({a:"show-chat"})},yp=D=>{if(!g||(Q==null?void 0:Q.ask.kind)!=="question")return;if(!D.some(wa))return u({a:"ask-revive",id:g});const Oe=gw(Q.ask.questions,D).join(`
259
- `),ct={t:"chat",worktreeId:g,clientId:xe,context:id()};if(U&&$.some(Ai))Vs(U,g,Oe,ct);else{const $t=$.length?$.map(Ml):void 0,or=$t&&U?{attachments:$t,boxId:U}:{};h==null||h.send({...ct,text:Oe,...or}),$t&&U&&u({a:"clear-attachments",id:U}),u({a:"sending",id:g,message:{text:Oe,attachments:$t}})}u({a:"answered",id:g}),u({a:"ask-revive",id:g})},uc=L(D=>D.autoSend);at([uc,g],()=>{!uc||uc!==g||Xt||Hs!==!!s||(u({a:"auto-sent"}),is())});const vp=()=>{const D=N[N.length-1];return!w||!D?!1:(u({a:"detach",id:w,key:D.key}),!0)},dc=D=>{w&&(u({a:"walk",id:w,walk:D.walk,text:D.text}),requestAnimationFrame(()=>{var Oe;(Oe=kn.current)==null||Oe.setSelectionRange(D.text.length,D.text.length),Ce(D.text.length)}))},fc=()=>{w&&A&&u({a:"walk",id:w,walk:null,text:x})},Ys=Ye?[]:JS(M),Xs=Ye?[]:O.flatMap(D=>D.attachments??[]),Co=e==null?void 0:e.worktree.plan,Ya=Ay(e==null?void 0:e.worktree.id,Co),ys=((ei=e==null?void 0:e.worktree.from)==null?void 0:ei.kind)==="worktree"?e.worktree.from:null,Zi=ys?M.find(D=>D.kind==="handed"&&D.via==="plan"):void 0,hc=(Zi==null?void 0:Zi.kind)==="handed"?Zi.origin.title:ys==null?void 0:ys.ref,Qs=tr&&((tl=e==null?void 0:e.worktree.prComments)==null?void 0:tl.pr)===tr.number?e.worktree.prComments:void 0,Xa=Qs&&Qs.count>0?s$(Qs.count,Qs.authors):null,Qa=(e==null?void 0:e.worktree.queued)??[],pc=Or&&!le,bp=L(D=>D.reading),[mc,ld]=S.useState(!1),cd=c&&!q&&(le?!mc:Xt&&!Te),ud=cd&&bp;S.useEffect(()=>{if(c)return u({a:"typing",on:mc}),()=>u({a:"typing",on:!1})},[c,mc,u]);const go=D=>{if(!ud||D.target instanceof Element&&D.target.closest("button, a, [role=button]"))return;const Oe=D.currentTarget.closest(".chat-log");Oe&&(Oe.scrollTop=Oe.scrollHeight)};return d.jsxs("div",{ref:Us,className:Be("composer chat-input",pc&&"stopping",cd&&"foldable",ud&&"lean"),onClick:go,onFocus:D=>ld(D.target instanceof HTMLTextAreaElement),onBlur:()=>ld(!1),children:[(Co||ys)&&e&&d.jsxs("div",{className:"composer-plan",...Co?Ge.contextMenu(()=>uy(Co,()=>h==null?void 0:h.send({t:"reveal",worktreeId:e.worktree.id,path:Co}),fo(h))):{},children:[d.jsx(ht,{name:Co?"text":"handoff",className:"icon-inline"}),Co&&d.jsx(Me,{variant:"inline",className:"composer-plan-path","data-tip":Co,onClick:()=>Rn({dispatch:u},{worktreeId:e.worktree.id,path:Co,view:"preview"}),children:Ya}),ys&&d.jsxs("span",{className:"composer-plan-from",children:[Co?" from ":"from ",d.jsx(lo,{id:ys.origin.id,title:hc})]})]}),tr&&Xa&&e&&d.jsxs("div",{className:"composer-plan",children:[d.jsx(ht,{name:"pr",className:"icon-inline"}),d.jsx(Me,{variant:"inline",tone:"strong","data-tip":"Read them beside the chat",onClick:()=>a3({dispatch:u},e.worktree.id,tr.number),children:Xa.count}),d.jsxs("span",{className:"row-dim",children:["on PR #",tr.number,Xa.rest,tr.review==="changes_requested"?", changes requested":tr.review==="approved"?", approved":""]})]}),q&&g&&d.jsx(Rs,{icon:"chat",verb:"answer",tip:"Bring the question back into the box",onPress:()=>{u(q.kind==="ask"&&q.outcome?{a:"ask-revive",id:g,askId:q.id}:{a:"card-unpark",id:g}),u({a:"focus-chat"})},children:O3(q)}),(ce==null?void 0:ce.verb)==="fix"&&"toolId"in ce&&g&&d.jsxs(Rs,{icon:"run",verb:ce.verb,tip:"Send the agent what it printed and ask for a fix",onPress:()=>h==null?void 0:h.send({t:"fix",worktreeId:g,toolId:ce.toolId}),onDismiss:()=>U1(ce.key),children:["what failed in ",d.jsx("code",{children:ce.command})]}),(ce==null?void 0:ce.verb)==="continue"&&g&&d.jsx(Rs,{icon:"send",verb:ce.verb,tip:ce.after==="stop"?"Send the agent on from where its turn stopped":ce.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:()=>h==null?void 0:h.send({t:"continue",worktreeId:g}),onDismiss:()=>U1(ce.key),children:ce.after==="stop"?"where it stopped":ce.again?"after the same error again":"after the error"}),Te&&w&&!le&&(e||_||o)&&d.jsx(Rs,{icon:"copy",verb:"attach",tip:"Attach it, as a paste would",onPress:()=>{V3(f,w,Te),Ho()},onDismiss:U_,children:Te.kind==="image"?"the image you copied":`the text you copied, ${Te.text.split(`
260
- `).length} lines`}),te&&d.jsx(Rs,{icon:"download",verb:"install",tip:"Install Toyon as an app: a window of its own, with a Dock icon and no browser bar",onPress:()=>{R1(),je==null||je.prompt()},onDismiss:R1,children:"Toyon as a window of its own, with a Dock icon and no browser bar"}),J&&g&&!m&&!le&&!te&&Kh(fo(h))&&Q7({offer:J,agent:e==null?void 0:e.agent,chat:M})&&d.jsx(rW,{offer:J,onInstall:()=>h==null?void 0:h.send({t:"install-global"}),onDismiss:()=>h==null?void 0:h.send({t:"dismiss-global-install"})}),w&&!le&&gr===null&&d.jsx(Qh,{children:Yk(N,su($g(Ys),Xs)).map(([D,Oe])=>{const ct=()=>u({a:"detach",id:w,key:D.key});return D.kind!=="pick"?d.jsx(E$,{item:D,n:Oe,onRemove:ct},D.key):d.jsx(dp,{pick:D,tipText:D.html,onHover:$t=>re&&an.post(re,$t?{type:"highlight-selector",selector:D.selector,label:xw(D)}:{type:"highlight-clear"}),worktreeId:g,onOpen:($t,or)=>g&&ya(f,h,g,$t,or),onRemove:ct},D.key)})}),hn&&ke&&d.jsx(iH,{results:Ot,keyOf:D=>D.kind==="cmd"?`c:${D.c.name}`:D.kind==="changes"?"changes":D.kind==="worktree"?`w:${D.id}`:D.kind==="folder"?`d:${D.path}`:`f:${D.path}`,rowClass:D=>D.kind==="file"||D.kind==="folder"?"qo-file":D.kind==="changes"||D.kind==="worktree"?"picker-row":"picker-row picker-cmd",nav:Ui,listRef:ue,empty:CW(ke.kind,It,rt.length,Ne!==null),note:nr>0?`type to find ${nr} more`:void 0,groupOf:D=>D.kind==="worktree"?"worktrees":D.kind==="cmd"?"commands":"files",row:D=>{const Oe=((_t==null?void 0:_t.files.length)??0)>0;return D.kind==="file"?Rk(D.path,D.status,ke.query,{gutter:Oe}):D.kind==="folder"?Rk(D.path,void 0,ke.query,{folder:!0,gutter:Oe}):D.kind==="changes"?d.jsx(Cn,{label:"@changes",hint:`${D.n} uncommitted ${D.n===1?"file":"files"}`}):D.kind==="worktree"?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:`dot ${D.dot}`}),d.jsx(Cn,{label:D.title,hint:fr(D.at)})]}):d.jsx(EH,{c:D.c,query:ke.query})}}),le&&g?le.kind==="handoff"?d.jsx(lW,{item:le,worktreeId:g,rootRef:V},le.id):le.ask.kind==="question"?d.jsx(bW,{item:le,ask:le.ask,worktreeId:g,rootRef:V,numbers:su($g(Ys),Xs),onAnswer:Q?yp:void 0},le.id):d.jsx(vW,{item:le,ask:le.ask,worktreeId:g,rootRef:V},le.id):d.jsxs("div",{className:Be("composer-field",gr!==null&&"shell",A&&"recalled"),children:[d.jsx(_u,{size:"lg",bare:!0,font:gr!==null?"mono":"ui",ref:kn,value:x,onChange:D=>{var Hn;const Oe=D.target.value,ct=D.target.selectionStart??Oe.length;ae(Oe),Ce(ct),Ui.setIndex(0);const{inputType:$t}=D.nativeEvent;K($t==="insertFromPaste"||$t==="insertFromDrop"?((Hn=fg(Oe,ct))==null?void 0:Hn.from)??null:null)},onKeyUp:D=>{Fi(),Ce(D.currentTarget.selectionStart??0)},onClick:D=>{Ce(D.currentTarget.selectionStart??0),fc()},onPaste:mp,onDrop:D=>{const Oe=UN(f,D);if(!Oe)return;D.stopPropagation();const ct=D.currentTarget,$t=l5(ct,D.clientX,D.clientY)??x.length;Di(ct,$t,$t,Oe.words)},onScroll:D=>{rr.current&&(rr.current.scrollTop=D.currentTarget.scrollTop)},onKeyDown:D=>{var Oe;if(zi(D),!D.nativeEvent.isComposing){if(hn){if(D.key==="Escape"){D.preventDefault(),D.stopPropagation(),K((ke==null?void 0:ke.from)??null);return}if(Ui.onKeyDown(D))return}if((D.key==="ArrowUp"||D.key==="ArrowDown")&&!D.altKey&&!D.ctrlKey){const ct=D.key==="ArrowUp",$t=O.at(-1);if(ct&&!D.metaKey&&!A&&x===""&&g&&!m&&$t!==void 0){D.preventDefault(),tN(f,h,g,O.length-1);return}const or=D.metaKey?ct?"first":"box":ct?"up":"down",Hn=g?U7(M,A??null,x,or):null;if(Hn){D.preventDefault(),(Hn.walk!==A||Hn.text!==x)&&dc(Hn);return}}if(A&&D.key==="Escape"){D.preventDefault(),D.stopPropagation(),dc({walk:null,text:A.from});return}if(D.key==="Escape"&&jt&&g&&!m){D.preventDefault(),D.stopPropagation(),h==null||h.send({t:"stop-agent",worktreeId:g});return}if(A&&NW.has(D.key)&&fc(),D.key==="Tab"&&!D.shiftKey&&x===""){const ct=(Oe=D.currentTarget.closest(".composer"))==null?void 0:Oe.querySelector(".composer-verb");if(ct&&!ct.disabled){D.preventDefault(),ct.focus();return}if($e){D.preventDefault(),u({a:"edit-commit"});return}}D.key==="Enter"&&(W?D.metaKey||D.ctrlKey:!D.shiftKey)?(D.preventDefault(),is()):D.key==="Backspace"&&x===""&&vp()&&D.preventDefault()}},placeholder:Za||Dn?"":od,disabled:o?o.busy:!e&&!_}),Fa&&d.jsxs("div",{className:"composer-ghost","aria-hidden":"true",children:[d.jsx("span",{className:"picker-typed",children:x}),Fa]}),g&&gr===null&&x.includes("@")&&d.jsx("div",{ref:rr,className:"composer-ghost composer-marks","aria-hidden":"true",onClick:D=>jy(D,e==null?void 0:e.worktree.path,g,{sock:h,dispatch:u}),children:d.jsx(Ty,{text:x,worktreeId:g,root:e==null?void 0:e.worktree.path,inField:!0})}),(Za||Dn)&&d.jsxs("div",{className:"composer-ghost composer-standing","aria-hidden":Dn?void 0:"true",children:[d.jsx("span",{className:Be("composer-placeholder",Wa&&"live-text"),children:rd||(Dn?d.jsxs(d.Fragment,{children:[d.jsx(Me,{variant:"inline",tone:"strong",className:"composer-verb",disabled:!!Dn.ships&&!!Rt||Va,...Ft(Dn.tip,void 0,{placement:"top"}),onClick:()=>{var D;Dn.run(),W||(D=kn.current)==null||D.focus()},onKeyDown:D=>{D.key==="Tab"&&!D.shiftKey&&$e&&(D.preventDefault(),u({a:"edit-commit"}))},children:Dn.word})," ",d.jsx("span",{className:"composer-verb-line",children:td?td.map(D=>typeof D=="string"?D:d.jsxs(Me,{variant:"inline",className:"composer-verb-tail",...Ft(D.tip,void 0,{placement:"top"}),onClick:()=>{var Oe;window.open(D.url,"_blank"),W||(Oe=kn.current)==null||Oe.focus()},...Ge.contextMenu(()=>[{id:"open-link",label:D.open,onClick:()=>window.open(D.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>tn(D.url)}]),children:[D.text," ",d.jsx(ht,{name:"external",className:"icon-inline"})]},D.text)):Dn.line})]}):od)}),Za&&d.jsxs(d.Fragment,{children:[`
261
- `,d.jsx("span",{className:"composer-subline",children:Za})]})]}),pc&&d.jsx(Lt,{icon:"stop",tone:"danger",className:Be("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${O.length?"; queued messages go next":""})`,hint:"esc",onClick:()=>g&&(h==null?void 0:h.send({t:"stop-agent",worktreeId:g}))})]}),T&&d.jsx("div",{className:"hint composer-notice",role:"status",children:T}),!le&&d.jsxs("div",{className:"hint composer-knobs",children:[d.jsxs("span",{className:"spawn-left",children:[cn?Qt.length>1?d.jsx(yH,{agents:Qt,agent:gt,model:un,onChange:Nn,onClose:$o}):d.jsx(P1,{models:pt,value:un,runs:Kt,onChange:Et,onClose:$o}):e&&d.jsx(P1,{models:pt,value:e.worktree.model??"",current:be,runs:Kt,onChange:D=>h==null?void 0:h.send({t:"set-worktree-model",worktreeId:e.worktree.id,model:D}),onClose:$o}),cn?d.jsx(M1,{efforts:At,value:Ct,runs:xt,onChange:er,onClose:$o}):e&&d.jsx(M1,{efforts:At,value:e.worktree.effort??"",current:Ve,runs:xt,onChange:D=>h==null?void 0:h.send({t:"set-worktree-effort",worktreeId:e.worktree.id,effort:D}),onClose:$o}),Ye?!o&&d.jsx(L1,{value:Ht,onChange:St,onClose:$o}):e&&d.jsx(L1,{value:bn,onChange:D=>h==null?void 0:h.send({t:"set-worktree-mode",worktreeId:e.worktree.id,mode:D}),onClose:$o}),ir&&d.jsxs("span",{className:"usage-knob",onMouseEnter:()=>{Jt||(window.clearTimeout(Zt.current),Zt.current=window.setTimeout(()=>po(!0),TW))},onMouseLeave:()=>{window.clearTimeout(Zt.current),po(!1)},onFocus:D=>{Jt||!D.target.matches(":focus-visible")||(window.clearTimeout(Zt.current),po(!0))},onBlur:jo,children:[d.jsx(Lt,{icon:d.jsx(aH,{fraction:dn?dn.used/dn.size:0,level:wt?Y5(wt,mr):void 0}),tone:"chrome",on:Jt,silent:!0,label:dn?`${Math.round(100*dn.used/dn.size)}% of context`:wt?Ix(wt,mr):"",detail:[...dn&&wt?[Ix(wt,mr)]:[],...qt?[qt]:[]],...Ge.dropdown(qr,"left","usage",Nt),...Ge.contextMenu(qr,"usage")}),ar&&d.jsx(SW,{usage:dn,limits:wt,auth:Ue==null?void 0:Ue.auth,now:mr,onClose:jo})]})]}),d.jsxs("span",{className:"spawn-tools",children:[w&&(e||_||o)&&d.jsx(Lt,{icon:"attach",tone:"chrome",label:c?"Attach a picture or a file":"Attach a picture or a file, or drop one here",onClick:()=>mN(f,w)}),!s&&!v&&!c&&!o&&d.jsx(Lt,{icon:"terminal",tone:"chrome",on:ne,className:"composer-term",disabled:!e,label:Se?Se.tip:"Terminal",hint:Bt("terminal"),badge:Se&&d.jsx("span",{className:"composer-term-dot"}),onClick:()=>{u(Se&&!ne&&g?{a:"term-stream",id:g,stream:Se.stream}:{a:"toggle-terminal"})},...Ge.contextMenu(()=>e&&g?EF(e.procs,g,ne,{sock:h,dispatch:f.dispatch}):[])}),!s&&!pe&&!v&&!c&&!o&&d.jsx(Lt,{icon:"pick",label:"Pick an element on the page to attach",hint:Bt("pick"),on:P==="chat",disabled:!re,onClick:()=>re&&Eu(re,P,u,"chat")}),W&&w&&(e||_||o)&&d.jsx(Lt,{icon:"send",tone:"primary",label:o?"Create the project":"Send",disabled:Va||(o?o.busy:Xt),onMouseDown:D=>D.preventDefault(),onClick:is})]})]}),(nn||se&&rn||Qa.length>0)&&d.jsxs("div",{className:"composer-notes",children:[Qa.map(D=>d.jsx("div",{className:"hint composer-note",children:d.jsxs("span",{children:[D.title," starts when"," ","id"in D.after?D.after.id===(e==null?void 0:e.worktree.id)?"this branch":d.jsx(lo,{id:D.after.id}):$W(D,D.after.piece,Qa)," ","lands"]})},`${D.proposalId}/${D.pieceId}`)),nn&&Ue&&d.jsxs("div",{className:"hint composer-note",role:"status",children:[d.jsx("span",{children:nn.text}),(nn.retry||X)&&d.jsxs("span",{className:"composer-note-actions",children:[nn.retry&&d.jsx(Me,{variant:"outline",onClick:()=>h==null?void 0:h.send({t:"install-agent",agent:Ue.id}),children:nn.retry}),X&&d.jsxs(Me,{variant:"outline","data-tip":`${X.name} is installed and takes this message instead`,onClick:()=>Zn(X.id),children:["use ",X.name]})]})]}),se&&rn&&d.jsxs("div",{className:"hint composer-note",children:[d.jsx("span",{children:se}),K4(rn)&&d.jsx(Me,{variant:"outline",busy:cr==="pull-main",disabled:!!cr,"data-tip":"Fast-forward main to origin",onClick:()=>ji(h,u,{t:"pull-main",worktreeId:rn.id}),children:"pull"})]})]})]})}function A$({children:e,className:t,tip:n,...r}){return d.jsxs("label",{className:Be("check",t),"data-tip":n,children:[d.jsx("input",{type:"checkbox",className:"check-box",...r}),d.jsx("span",{children:e})]})}function IW(e){var r;const t=Yh(e);if(t.length===0)return;const n=(r=e==null?void 0:e.picks)==null?void 0:r.profile;return n&&t.includes(n)?n:e==null?void 0:e.config.defaultProfile}function RW({repo:e,value:t,onChange:n,onClose:r}){const o=Yh(e);if(o.length===0||!t)return null;const s=(e==null?void 0:e.config.profiles)??{},a=(e==null?void 0:e.configFile)??"the settings",c=u=>{var m;const h=((m=s[u])==null?void 0:m.run)??[],f=h.length>0?`runs ${h.join(", ")}`:"runs nothing";return u===(e==null?void 0:e.config.defaultProfile)?`${f}; the default in ${a}`:f};return d.jsx(Si,{value:t,options:o.map(u=>({id:u,description:c(u)})),onChange:n,onClose:r,hint:o.length>1?`${t}: ${c(t)}. Click to change`:`the only profile in ${a}`,placeholder:"the profile the worktree runs"})}function OW({draft:e,lead:t}){const n=lt(),r=Je(),o=L(h=>Li(h,t==null?void 0:t.repoId)),s=e.profile??IW(o),a=h=>{n({a:"draft-profile",profile:h}),o&&(r==null||r.send({t:"set-repo-pick",repoId:o.id,field:"profile",value:h}))},c=L(h=>{var f;return((f=Hl(h,t==null?void 0:t.repoId))==null?void 0:f.dirty)??0}),u=!!t&&!!o&&c>0;return!s&&!u?null:d.jsxs("div",{className:"draft-intro",children:[s&&d.jsx("div",{className:"draft-row hint",children:d.jsx(RW,{repo:o,value:s,onChange:a})}),u&&d.jsx("div",{className:"draft-notes",children:d.jsxs(A$,{className:"hint draft-note",checked:!!e.carry,tip:`Move the ${c} uncommitted ${c===1?"file":"files"} into the new worktree, leaving ${o.defaultBranch} clean`,onChange:h=>n({a:"draft-carry",v:h.currentTarget.checked}),children:[d.jsxs("span",{className:"badge-dirty",children:["~",c]})," on ",o.defaultBranch," come along"]})})]})}function MW({row:e}){const t=Je(),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(Nr,{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 du({placement:e,className:t,width:n,archived:r,found:o}){const s=lt(),a=zs(),c=Mz(),u=Mt(a==null?void 0:a.worktree.id,"sending"),h=Jl(),f=e==="centre"&&!r&&(h!=null&&h.assumed)?h:null,m=L(v=>{var _;return((_=v.dragFiles)==null?void 0:_.at)==="chat"}),g=On(),y=S.useMemo(()=>({onDragOver:v=>a5(g,v),onDrop:v=>{const _=UN(g,v);_&&oN(g,_.boxId,_.words)}}),[g]),w=d.jsxs(d.Fragment,{children:[!r&&!o&&c&&!u&&d.jsx(OW,{draft:c,lead:a}),r?d.jsx(uu,{active:null,archived:r,placement:e}):o?d.jsx(uu,{active:null,found:o,placement:e}):d.jsx(uu,{active:a,draft:c,placement:e})]});return d.jsx("div",{className:Be(e==="dock"?"chat-dock":e==="centre"?"chat-centre":"chat-screen",t,m&&"drop-over"),style:n===void 0?void 0:{width:n},...y,ref:v=>{var _;v?lu.el=v:(_=lu.el)!=null&&_.isConnected||(lu.el=null)},children:r?d.jsx(kg,{active:null,archived:r,tail:d.jsx(nF,{item:r}),foot:w}):o?d.jsx(kg,{active:null,found:o,tail:d.jsx(MW,{row:o}),foot:w}):d.jsx(kg,{active:a,lead:f&&d.jsxs("p",{className:"hint chat-centre-note",children:[f.name," has ",d.jsx("code",{children:f.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:f.id}}),children:"add a dev server"})]}),foot:w})})}const LW="modulepreload",PW=function(e){return"/"+e},Y1={},Pk=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let a=function(h){return Promise.all(h.map(f=>Promise.resolve(f).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),u=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));o=a(n.map(h=>{if(h=PW(h),h in Y1)return;Y1[h]=!0;const f=h.endsWith(".css"),m=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${m}`))return;const g=document.createElement("link");if(g.rel=f?"stylesheet":LW,f||(g.as="script"),g.crossOrigin="",g.href=h,u&&g.setAttribute("nonce",u),document.head.appendChild(g),f)return new Promise((y,w)=>{g.addEventListener("load",y),g.addEventListener("error",()=>w(Error(`Unable to preload CSS for ${h}`)))})}))}function s(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return o.then(a=>{for(const c of a||[])c.status==="rejected"&&s(c.reason);return t().catch(s)})},Dy=800;function DW(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 Yo=e=>`${e.worktreeId}
262
- ${e.ref??""}
263
- ${e.since??""}
264
- ${e.path}`;class zW{constructor(t){Tt(this,"files",new Map);Tt(this,"looks",new Map);this.d=t}start(){var s,a;let t=this.d.store.getState();const n=this.d.store.subscribe(()=>{const c=this.d.store.getState(),u=t;t=c,this.follow(u,c)}),r=()=>{const c=this.d.store.getState().editor;c&&!c.loose&&this.refresh(Yo(c))};(s=this.d.win)==null||s.addEventListener("focus",r);const o=()=>{for(const[c,u]of this.files)u.timer!==void 0&&this.saveNow(c)};return(a=this.d.win)==null||a.addEventListener("pagehide",o),()=>{var c,u;n(),(c=this.d.win)==null||c.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(Yo(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=So();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=Yo(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(Yo(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(Yo(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,c,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||Yo(o)!==Yo(r))&&this.closed(Yo(o)),r&&(!o||o.seq!==r.seq)&&this.opened(r),!t.connected&&n.connected)for(const h of this.files.values())h.reread=!0,this.next(h);else r&&o&&o.seq===r.seq&&((c=Wr(t,r.worktreeId).git)==null?void 0:c.version)!==((u=Wr(n,r.worktreeId).git)==null?void 0:u.version)&&this.refresh(Yo(r))}opened(t){const n=Yo(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 c=So();t.out={seq:c},this.d.send({t:"read-file",worktreeId:n,path:r,ref:o,since:s,seq:c});return}if(t.pending!==null&&t.base&&t.pending===t.base.text&&(t.pending=null),t.pending!==null&&t.writable&&!t.conflict&&!o){const c=t.pending,u=So();t.pending=null,t.out={seq:u,write:c},this.d.send({t:"write-file",worktreeId:n,path:r,content:c,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(Yo(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:c,binary:u,tooLarge:h}=n;t.writable=c,t.open&&(this.d.store.dispatch({a:"editor-read",file:r,disk:{before:o,after:s,version:a,writable:c,binary:u,tooLarge:h}}),!u&&!h&&(a!==null||r.ref)&&this.askBlame(t,a));const f={after:t.buffer?t.buffer.normalize(s):s,version:a};if(!t.base){t.base={text:f.after,version:a};return}const m=((g=t.buffer)==null?void 0:g.text())??t.pending??t.base.text;switch(DW(t.base,m,t.pending,f)){case"same":break;case"adopt":t.base={text:f.after,version:a};break;case"apply":(y=t.buffer)==null||y.replace(f.after),t.base={text:f.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,f);return}this.setConflict(t,null)}askBlame(t,n){const r=So();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)},Dy))}saveNow(t){const n=this.files.get(t);if(!(n!=null&&n.buffer))return;this.cancelTimer(n);const r=n.buffer.text();r.length>Zf||(n.pending=r,this.next(n))}cancelTimer(t){t.timer!==void 0&&(this.d.timers.clear(t.timer),t.timer=void 0)}}const I$={attach:()=>{},edited:()=>{},saveNow:()=>{}},FW=e=>({timers:{set:(t,n)=>setTimeout(t,n),clear:t=>clearTimeout(t)},win:typeof window>"u"?null:window,send:e}),Dk=new Map;function BW(e){const t=Dk.get(e.seq);return t?(Dk.delete(e.seq),t(e),!0):!1}function UW(e,t,n,r){if(e.kind==="bytes"||e.kind==="text"||e.kind==="pr-comments")return I$;if(e.kind==="grant")return HW(e,t,n,r);const o=e.handle;let s=null,a,c=null,u=Promise.resolve(),h=!1;const f=()=>(c??(c=(async()=>await o.queryPermission({mode:"readwrite"})==="granted"?!0:await o.requestPermission({mode:"readwrite"})==="granted")().catch(()=>!1)),c),m=()=>{a!==void 0&&r.timers.clear(a),a=void 0},g=()=>{h||(h=!0,m(),n(`read-only: the browser would not save ${t}`))},y=async _=>{if(!await f())return g();const x=await o.createWritable();await x.write(_),await x.close()},w=()=>{if(!s||h)return;m();const _=s.text();u=u.then(()=>y(_)).catch(g)},v=()=>{a!==void 0&&w()};return{attach(_){var x,N;if(_){s=_,(x=r.win)==null||x.addEventListener("pagehide",v);return}a!==void 0&&w(),s=null,(N=r.win)==null||N.removeEventListener("pagehide",v)},edited(){!s||h||(f().then(_=>{_||g()}),m(),a=r.timers.set(w,Dy))},saveNow:w}}function HW(e,t,n,r){let o=null,s,a=e.version,c=!1,u=null,h=!1;const f=()=>{s!==void 0&&r.timers.clear(s),s=void 0},m=v=>{h||(h=!0,f(),u=null,n(v))},g=v=>{if(!r.send)return;const _=So();c=!0,Dk.set(_,x=>{if(c=!1,x.ok?a=x.version:x.reason==="changed"?m(`read-only: ${t} changed on disk; open it again to edit`):m(x.message??`not saved: ${t}`),u!==null&&!h){const N=u;u=null,g(N)}}),r.send({t:"write-loose",id:e.id,content:v,base:a,seq:_})},y=()=>{if(!o||h)return;f();const v=o.text();v.length>Zf||(c?u=v:g(v))},w=()=>{s!==void 0&&y()};return{attach(v){var _,x;if(v){o=v,(_=r.win)==null||_.addEventListener("pagehide",w);return}s!==void 0&&y(),o=null,(x=r.win)==null||x.removeEventListener("pagehide",w)},edited(){!o||h||(f(),s=r.timers.set(y,Dy))},saveNow:y}}function zy({kind:e,className:t,height:n,resizable:r=!0,onDragStart:o,title:s,tabs:a,actions:c,menu:u,full:h,onToggleFull:f,onClose:m,closeHint:g="esc",children:y}){const w=vn("pane"),v=f&&d.jsxs(Me,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:f,"data-tip":h?"Split view: show the preview above":"Full height: hide the preview",children:[d.jsx(ht,{name:h?"split":"full",className:"icon-inline"})," ",h?"split":"full"]}),_=d.jsxs("span",{className:"pane-shape",children:[v,d.jsx(Lt,{icon:"close",label:"Close",hint:g,onClick:m})]});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:Be("pane-head",a&&"pane-head-tabs"),...w.contextMenu(()=>(u==null?void 0:u())??[]),children:a?d.jsx(Wu,{...a,end:d.jsxs(d.Fragment,{children:[c,_]})}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"pane-title",children:s}),c,_]})}),y]})}function WW({src:e,path:t,full:n,onFull:r}){const o=vn("editor");return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"editor-image",onClick:()=>r(!0),...o.contextMenu(()=>Na(e,{open:()=>r(!0)})),children:d.jsx("img",{src:e,alt:t})}),n&&d.jsx(tp,{owner:"editor",onClose:()=>r(!1),menu:()=>Na(e),children:d.jsx("img",{src:e,alt:t})})]})}function KW({src:e,path:t}){return d.jsx("div",{className:"editor-video",children:d.jsx("video",{src:e,controls:!0,preload:"metadata",title:t})})}const qW={image:WW,video:KW};function ZW({kind:e,src:t,path:n,openSeq:r,focus:o,full:s,onFull:a}){const c=S.useRef(null);at([r],()=>{var h;o&&((h=c.current)==null||h.focus())});const u=qW[e];return d.jsx("div",{ref:c,className:"editor-viewer",tabIndex:-1,children:d.jsx(u,{src:t,path:n,full:s,onFull:a})})}function GW(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 VW(e){const t=new Map,n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=GW(n.map(o=>Number(o.tagName[1])));return n.map((o,s)=>{var u;const a=((u=o.textContent)==null?void 0:u.trim())??"",c=t.get(a)??0;return t.set(a,c+1),{id:`${c}
265
- ${a}`,level:Number(o.tagName[1]),depth:r[s],text:a,el:o}})}const YW=48,XW=16;function Fy({html:e,openSeq:t=0,focus:n=!0,onLink:r,onChat:o,lead:s}){const a=S.useRef(null),c=S.useRef(null),[u,h]=S.useState([]),[f,m]=S.useState(-1),[g,y]=S.useState(null),w=N=>{var T;if(y(null),N){const j=window.getSelection();j==null||j.removeAllRanges(),j==null||j.addRange(N)}(T=a.current)==null||T.focus()};at([t],()=>{var N;n&&((N=a.current)==null||N.focus())}),at([e],()=>{h(c.current?VW(c.current):[])}),S.useLayoutEffect(()=>{const N=a.current;if(!N)return;let T=0;const j=()=>{if(T=0,N.scrollTop+N.clientHeight>=N.scrollHeight-1){m(u.length-1);return}const I=N.scrollTop+YW;let A=-1;for(let M=0;M<u.length;M++)u[M].el.offsetTop<=I&&(A=M);m(A)},C=()=>{T||(T=requestAnimationFrame(j))};return j(),N.addEventListener("scroll",C),()=>{N.removeEventListener("scroll",C),T&&cancelAnimationFrame(T)}},[u]);const v=N=>{var j,C;const T=(j=u[N])==null?void 0:j.el;(C=a.current)==null||C.scrollTo({top:Math.max(0,T?T.offsetTop-XW:0),behavior:"smooth"})},_=N=>{const T=N.target.closest("a"),j=T==null?void 0:T.getAttribute("href");!j||(T==null?void 0:T.target)==="_blank"||(N.preventDefault(),r==null||r(j))},x=N=>{var T;if(ry(N)){N.preventDefault(),N.stopPropagation();const j=(c.current&&dk(c.current))??"";y(C=>({seed:j||(C==null?void 0:C.seed)||"",seq:((C==null?void 0:C.seq)??0)+1}));return}if(N.key==="Escape"&&g){N.stopPropagation(),w(null);return}if(kT(N)&&c.current){N.preventDefault(),yT(c.current);return}if(o&&((T=RE(N))==null?void 0:T.id)==="composer"&&c.current){const j=dk(c.current);if(!j)return;N.preventDefault(),N.stopPropagation(),o(j)}};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{ref:a,className:"document",tabIndex:-1,onClick:_,onKeyDown:x,children:[s,d.jsx("div",{ref:c,className:"md md-preview",dangerouslySetInnerHTML:{__html:e}})]}),g&&d.jsx(gT,{root:a,body:c,seed:g.seed,seq:g.seq,onClose:w}),d.jsx(QW,{heads:u,at:f,onJump:v})]})}function QW({heads:e,at:t,onJump:n}){const[r,o]=S.useState(!1),s=S.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,c)=>d.jsx("span",{className:"document-outline-tick","data-level":a.level,"data-state":hr({current:c===t})},a.id))}),r&&d.jsx(Fs,{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,c)=>d.jsx("button",{type:"button",className:"row document-outline-row","data-level":a.level,"data-state":hr({current:c===t}),onClick:()=>n(c),children:d.jsx("span",{className:"document-outline-label",style:{"--outline-depth":a.depth},children:a.text})},a.id))})]})}function R$({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:s,onChat:a,lead:c}){Je();const u=Rr(),h=lt(),f=JF(t),m=Vu(e,{keepHtml:!0,base:r===void 0?void 0:{worktreeId:n,dir:f,version:r,urls:u}}),g=y=>{const w=MT(f,y);w&&Rn({dispatch:h},{worktreeId:n,path:w,view:Ii(w)})};return d.jsx(Fy,{html:m,openSeq:o,focus:s,onLink:g,onChat:a,lead:c})}function JW({refs:e,worktreeId:t}){const n=Rr();return e.length===0?null:d.jsx("div",{className:"editor-piece-chips",children:e.map(r=>r.kind==="image"?d.jsx(up,{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(ap,{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(ip,{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(dp,{className:"in-chat",pick:r,worktreeId:t},`pick-${r.n}`))})}function eK(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 tK(e,t,n,r){const o=L(s=>s.visible);return S.useMemo(()=>{if(!e)return;const s=[];t!==null&&s.push({id:"plan",label:t});for(const a of dN(e)){const c=$3(e,a),u="worktreeId"in c?o.find(h=>h.worktree.id===c.worktreeId):void 0;s.push({id:a.id,lead:u?d.jsx("span",{className:`dot ${ps(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 nK({tabs:e}){const t=S.useRef(null),[n,r]=S.useState({start:!1,end:!1});return at([e.items],()=>{var c;const o=(c=t.current)==null?void 0:c.querySelector(".tabs-list");if(!o)return;const s=()=>{const u=o.scrollLeft,h=u>1,f=u+o.clientWidth<o.scrollWidth-1;r(m=>m.start===h&&m.end===f?m:{start:h,end:f})};s(),o.addEventListener("scroll",s,{passive:!0});const a=new ResizeObserver(s);return a.observe(o),()=>{o.removeEventListener("scroll",s),a.disconnect()}}),at([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",...Ft("Handed off from this plan"),children:d.jsx(ht,{name:"handoff"})}),d.jsx(Wu,{...e})]})}function rK({item:e,piece:t}){var o,s;const n=bu(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:eK(n)});case"sent":return d.jsxs(d.Fragment,{children:["Sent to ",n.worktreeId?d.jsx(lo,{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(lo,{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(lo,{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,c=a&&"piece"in a?e.pieces.find(f=>f.id===a.piece):void 0,u=c?bu(e,c):null,h=a&&"id"in a?d.jsx(lo,{id:a.id,title:a.title}):u&&(u.kind==="worktree"||u.kind==="sent")&&u.worktreeId?d.jsx(lo,{id:u.worktreeId,title:u.title??(c==null?void 0:c.title)}):c?c.title:null;return h?d.jsxs(d.Fragment,{children:["This worktree's agent does it, once ",h," lands."]}):d.jsx(d.Fragment,{children:"This worktree's agent does it."})}}}function oK({item:e,piece:t,alone:n,worktreeId:r,path:o,version:s,openSeq:a,focus:c,onChat:u}){const h=Je(),f=T=>h==null?void 0:h.send(uN(e,r,t.id,T)),m=Pi(e,t),g=Uu(e,t),y=vu(e)?j3(t,e.pieces).filter(T=>T!==m):[],{title:w,rest:v}=S.useMemo(()=>SS(YL(t)),[t]),_=Vu(`# ${w}`),x=C3(e,t,n)&&d.jsx("p",{className:"editor-piece-line hint",children:vu(e)?d.jsxs(d.Fragment,{children:[e.stale&&"The plan changed since these were read. ",N3(t,m,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:()=>f(T),children:T==="send"&&t.to?`send to ${t.to.title}`:_3(t,T)})]},T))]})]}):d.jsx(rK,{item:e,piece:t})}),N=d.jsxs("div",{className:"md md-preview editor-piece-head",children:[d.jsx("div",{dangerouslySetInnerHTML:{__html:_}}),x,d.jsx(JW,{refs:t.attachments,worktreeId:r})]});return d.jsx(R$,{text:v,path:o,worktreeId:r,version:s,openSeq:a,focus:c,onChat:u,lead:N})}function sK(e){return`/${e.replace(/(^|\/)index\.html?$/i,"$1").split("/").map(encodeURIComponent).join("/")}`}const X1=6e4,iK=3e3,aK=e=>e.kind==="worktree"?`w:${e.worktreeId}:${e.path}`:e.kind==="loose"?`g:${e.grantId}`:`t:${e.text}`;function lK({source:e,path:t,version:n,openSeq:r,focus:o}){const s=S.useRef(null);at([r],()=>{var y;o&&((y=s.current)==null||y.focus())});const a=Rr(),[c,u]=S.useState(null),[h,f]=S.useState(null),m=S.useRef(e);m.current=e;const g=aK(e);return S.useEffect(()=>{let y=!1,w;const v=()=>{v4(a,m.current).then(_=>{if(!y){if(_===null){w=setTimeout(v,iK);return}if(typeof _=="string"){f(_),u(null);return}f(null),u(_.url),w=setTimeout(v,Math.max(_.ms-X1,X1))}})};return v(),()=>{y=!0,clearTimeout(w)}},[a,g,n]),d.jsx("div",{ref:s,className:"editor-viewer",tabIndex:-1,children:h!==null?d.jsx("p",{className:"hint",children:h}):c!==null&&d.jsx("iframe",{className:"editor-frame",title:t,sandbox:"allow-scripts",referrerPolicy:"no-referrer",src:c})})}function cK({worktreeId:e,openSeq:t,focus:n}){const r=Je(),o=L(m=>{var g;return(g=Gt(m,e))==null?void 0:g.worktree.pr}),s=L(m=>{var g;return(g=Gt(m,e))==null?void 0:g.worktree.prComments}),a=L(m=>Wr(m,e).prComments),c=s==null?void 0:s.version;at([r,e,c],()=>{r==null||r.send({t:"pr-comments",worktreeId:e})});const u=S.useMemo(()=>vH(a??[]),[a]),h=s$((a==null?void 0:a.length)??0,(s==null?void 0:s.authors)??[]),f=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:[h.count,h.rest]}),o&&d.jsxs(d.Fragment,{children:[" · ",d.jsx(Me,{variant:"inline",tone:"quiet",onClick:()=>window.open(o.url,"_blank"),children:"on GitHub"})]})]}),u.reviews.map(m=>d.jsx(Q1,{thread:m,worktreeId:e},m.root.id)),u.files.map(m=>d.jsxs("section",{children:[m.path&&d.jsx("h2",{className:"pr-page-path",children:m.path}),m.threads.map(g=>d.jsx(Q1,{thread:g,worktreeId:e},g.root.id))]},m.path))]});return d.jsx(Fy,{html:"",openSeq:t,focus:n,lead:f})}function Q1({thread:e,worktreeId:t}){const n=On();Je();const{root:r,replies:o}=e,s=L(u=>u.activeId===t&&Ca(Gt(u,t))!==null),a=Ry(r),c=r.review?d.jsx("span",{className:"pr-page-verb","data-review":r.review,children:o$(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}),c,d.jsx("span",{className:"pr-page-gap"}),d.jsx(J1,{url:r.url}),s&&d.jsx(Me,{variant:"outline",tone:"quiet","data-tip":"Put this in the message box for the agent",onClick:()=>Rf(n,{worktreeId:t,text:bH(e),name:xH(e)}),children:"add to chat"})]}),r.body&&d.jsx(eE,{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(J1,{url:u.url})]}),d.jsx(eE,{text:u.body})]},u.id))]})}function J1({url:e}){return d.jsx(Me,{variant:"inline",tone:"quiet",onClick:()=>window.open(e,"_blank"),children:"GitHub"})}function eE({text:e}){const t=S.useMemo(()=>va(e),[e]);return d.jsx("div",{className:"pr-page-body",dangerouslySetInnerHTML:{__html:t}})}function uK(){return As(tt.editorWrap,!1,e=>e===null?void 0:e==="1")}function dK({wrap:e,onWrap:t}){return d.jsxs(Me,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>t(!e),"data-tip":e?"Unwrap lines: one line per row, scroll sideways for the rest":"Wrap lines: fold a long line at the pane's edge",children:[d.jsx(ht,{name:"wrap",className:"icon-inline"})," ",e?"unwrap":"wrap"]})}const fK=S.lazy(async()=>{const[e]=await Promise.all([Pk(()=>import("./Editor-D_bxx8PL.js").then(t=>t.E),__vite__mapDeps([0,1,2])),Pk(()=>import("./grammar-DlhzivAk.js"),[]).then(t=>t.grammarsReady)]);return e});function tE({what:e}){return A_(!0,3e3)?d.jsx("div",{className:"empty",children:d.jsxs("span",{className:"live-text",children:["loading ",e]})}):null}const hK=()=>{},pK=[],mK={diff:"diff",file:"text",preview:"book"};function gK({path:e,note:t,title:n,worktreeId:r}){const o=On(),s=GS(e),a=n??s.name,c=n?"":s.dir;return d.jsxs("span",{className:"editor-title","data-tip":c||n?e:void 0,draggable:!!r,onDragStart:r?u=>Su(u,{kind:"paths",worktreeId:r,items:[{path:e,folder:!1}]}):void 0,onDragEnd:r?()=>Ku(o):void 0,children:[d.jsxs("span",{className:"editor-name",children:[a,t]}),c&&d.jsx("span",{className:"editor-dir row-dim",children:c})]})}function kK(e,t){return e==="diff"?"Diff view: show what changed":e==="preview"?"Preview: read it rendered":t==="diff"?"File view: hide the diff":"File view: edit the text"}function O$({editor:e,height:t,full:n=!1,onToggleFull:r,onDragStart:o,placement:s="stack"}){const a=s==="screen",c=lt(),u=On(),h=Je(),f=Rr(),m=Rw(),g=Bh(),{worktreeId:y,path:w,ref:v,since:_}=e,x=e.loose,N=(x==null?void 0:x.source.kind)==="pr-comments",T=L(ge=>{var Ee;return((Ee=Fo(ge))==null?void 0:Ee.id)===y}),j=L(ge=>{var We,Ye;const Ee=(We=Gt(ge,y))==null?void 0:We.worktree;return Ee?Ee.path:(Ye=Fo(ge))==null?void 0:Ye.path}),C=v!==void 0,I=L(ge=>{var Ee;return(Ee=Gt(ge,y))==null?void 0:Ee.worktree.plan}),A=!x&&!C&&I===w,M=Ay(A?y:void 0,A?w:void 0),O=L(ge=>iN(Wr(ge,y).chat??pK)),z=S.useMemo(()=>{if(C||x||e.view!=="preview"||!O)return null;const ge=O.plan??I;return ge&&w===ge?O:null},[C,x,e.view,I,w,O]),[B,H]=S.useState(null);at([z==null?void 0:z.id,w],()=>H(null)),at([e.seq],()=>{e.piece&&H(e.piece)});const Y=!!z&&!x3(z),ie=z?B!==null&&(B==="plan"?Y:z.pieces.some(ge=>ge.id===B))?B:A3(z,Y):"plan",Q=z&&ie!=="plan"?z.pieces.find(ge=>ge.id===ie)??null:null,le=tK(z,Y?"Plan":null,ie,H),U=S.useMemo(()=>x?UW(x.source,w,ge=>c({a:"editor-refused",file:{worktreeId:y,path:w},message:ge}),FW(h?ge=>h.send(ge):null)):(m==null?void 0:m.bind({worktreeId:y,path:w,...v?{ref:v}:{},..._?{since:_}:{}}))??I$,[m,y,w,v,_,x,c,h]),$=L(ge=>Wr(ge,y).changedRanges[w]);S.useEffect(()=>{!$&&!C&&!T&&!x&&(h==null||h.send({t:"changed-ranges",worktreeId:y,path:w}))},[y,w,$,C,T,x,h]);const q=($==null?void 0:$.offset)??0,V=e.disk,W=e.view??"diff",re=!!V&&(V.before===""||V.before===V.after),fe=N?[]:Y_(w,re).filter(ge=>ge!==W&&!(x&&ge==="diff")),pe=(x==null?void 0:x.source.kind)==="grant"?x.source:null,Te=C||T||x&&!pe?null:e4(w),[je,de]=S.useState(!1),[J,te]=uK(),ve=!!V&&!N&&!Te&&!V.binary&&!V.tooLarge&&W!=="preview",ce=e.line&&!e.line.fiber?e.line.n:void 0,xe=L(ge=>{var Ee;return((Ee=wu(ge))==null?void 0:Ee.worktreeId)===y})&&!a&&!C&&!T&&!x&&ku(w)==="html",Re=()=>{an.post(y,{type:"navigate",path:sK(w)}),n&&(r==null||r())};return d.jsxs(zy,{kind:"editor",className:Be("editor-pane",n&&"full"),height:n||a?void 0:t,resizable:!n&&!a,onDragStart:o??hK,title:d.jsx(gK,{path:w,note:C?` at ${v==null?void 0:v.slice(0,7)}`:_?", last turn":void 0,title:A&&M?M:void 0,worktreeId:x?void 0:y}),menu:()=>j&&!x?Os({id:y,dir:j},w,{discard:!C&&!T,kept:T,ref:v,showing:e.view??void 0,noDiff:re},{sock:h,dispatch:c}):[],onClose:()=>c({a:"close-editor"}),full:n,onToggleFull:a?void 0:r,actions:d.jsxs(d.Fragment,{children:[!Te&&fe.length>0&&d.jsx("span",{className:"editor-views",children:fe.map(ge=>d.jsxs(Me,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>c({a:"editor-view",v:ge}),"data-tip":kK(ge,W),children:[d.jsx(ht,{name:mK[ge],className:"icon-inline"})," ",ge]},ge))}),Te==="image"&&d.jsxs(Me,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>de(!0),"data-tip":"Full size: see the picture over the window",children:[d.jsx(ht,{name:"zen",className:"icon-inline"})," full size"]}),ve&&d.jsx(dK,{wrap:J,onWrap:te}),xe&&d.jsxs(Me,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:Re,"data-tip":"Run: open the page in the preview, with its scripts on",children:[d.jsx(ht,{name:"run",className:"icon-inline"})," run"]})]}),children:[V&&d.jsx(wK,{editor:e,disk:V,files:m}),le&&d.jsx(nK,{tabs:le}),d.jsx("div",{className:"editor-body",children:N?d.jsx(cK,{worktreeId:y,openSeq:e.seq,focus:e.focus}):V?Te?d.jsx(ZW,{kind:Te,src:pe?f.loose(pe.id,pe.version):f.worktreeFile(y,w,V.version),path:w,openSeq:e.seq,focus:e.focus,full:je,onFull:de}):V.binary?d.jsx("div",{className:"empty",children:"not a text file: open it in another editor"}):V.tooLarge?d.jsx("div",{className:"empty",children:"too large to open here: open it in another editor"}):W==="preview"&&z&&Q?d.jsx(oK,{item:z,piece:Q,alone:!le,worktreeId:y,path:w,version:C||T||x?void 0:V.version,openSeq:e.seq,focus:e.focus,onChat:ge=>Rf(u,{worktreeId:y,text:ge,name:w})}):W==="preview"&&ku(w)==="html"?d.jsx(lK,{source:pe?{kind:"loose",grantId:pe.id}:C||T||x?{kind:"text",text:V.after}:{kind:"worktree",worktreeId:y,path:w},path:w,version:V.version,openSeq:e.seq,focus:e.focus}):W==="preview"?d.jsx(R$,{text:V.after,path:w,worktreeId:y,version:C||T||x?void 0:V.version,openSeq:e.seq,focus:e.focus,onChat:ge=>Rf(u,{worktreeId:y,text:ge,name:w})}):d.jsx(Yw,{pane:!0,children:d.jsx(S.Suspense,{fallback:d.jsx(tE,{what:W}),children:d.jsx(fK,{file:{worktreeId:y,path:w,...v?{ref:v}:{},..._?{since:_}:{}},disk:V,blame:e.blame,view:W,openSeq:e.seq,line:ce,focus:e.focus,readOnly:C||!V.writable||a,numbers:!a,wrap:J,theme:g,sync:U,onCopy:x?void 0:(ge,Ee,We)=>Zz(We,{worktreeId:y,path:ge,...Ee,...v?{ref:v}:{}}),onChat:(ge,Ee)=>Rf(u,Ee&&(x?{worktreeId:y,text:Ee.text,name:ge}:{worktreeId:y,text:Ee.text,source:{path:ge,startLine:Ee.startLine,endLine:Ee.endLine,...v?{ref:v}:{}}})),onNew:()=>u.dispatch({a:"open-draft"}),onLineHover:C||x?void 0:ge=>{ge==null?an.post(y,{type:"highlight-clear"}):an.post(y,{type:"highlight-file",path:w,ranges:[[ge+q,ge+q]]})}},`${y}
266
- ${x?"loose":v??_??""}
267
- ${w}`)})}):d.jsx(tE,{what:w},w)})]})}function wK({editor:e,disk:t,files:n}){var h,f;const{worktreeId:r,path:o,ref:s,since:a,conflict:c}=e,u={worktreeId:r,path:o,...s?{ref:s}:{},...a?{since:a}:{}};if(c){const m=c.version===null;return d.jsxs("div",{className:"editor-note",children:[d.jsx("span",{className:"editor-note-text",children:m?"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":m?"Close the file; your edits go with it":"Take the file as it is on disk; undo brings your edits back",children:m?"close":"reload"}),d.jsx(Me,{variant:"outline",tone:"danger",onClick:()=>n==null?void 0:n.keepMine(u),"data-tip":m?"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})}):((h=e.loose)==null?void 0:h.source.kind)==="pr-comments"?null:((f=e.loose)==null?void 0:f.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 M$(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 yK=(e,t)=>{const n=Fg(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"}},ph="https://github.com/toyon-dev/toyon",vK=e=>`${ph}/releases/tag/v${e}`,bK=`${ph}/releases/latest`,xK=4e3;function EK(e,t,n,r){if(r==="asking")return{value:`${e} checking`,text:`Asking ${Fg(n)} for the newest version`,act:"check",busy:!0};const o=Fg(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(IS(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 SK(e,t,n,r,o,s=!1,a=null,c=null){if(n){if(n.restarting){const h=n.installed??n.running,f=n.restarting.length>0?MN(n.restarting):"Toyon is restarting; this page reloads when it is back";return{value:`${h} restarting`,text:f,act:"restart",busy:!0}}if(n.installing){const h=n.latest??n.installed??n.running;return{value:`${h} installing`,text:`Installing Toyon ${h}`,act:"update",busy:!0}}if(n.failed){const h=n.failed.line.replace(/\.$/,"");return{value:`${n.running} update failed`,text:`Installing Toyon ${n.failed.version} stopped: ${h}. 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=M$(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}:c?EK(e,t,a,c):{value:e,text:`Toyon ${e}, ${yK(t,a)}`,act:"check",busy:!1}}function _K(e,t,n){const r=o=>()=>window.open(o,"_blank");return Bn([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(vK(e))},{id:"latest-release",label:"latest release",onClick:r(bK)},{id:"repo",label:"Toyon on GitHub",onClick:r(ph)},{id:"report",label:"report a problem",onClick:r(`${ph}/issues/new`)}],[{id:"copy-version",label:"copy version",onClick:()=>tn(e)}]])}const NK=zA.map(e=>({title:e,rows:UA(e).map(t=>[Bt(t),iu[t].label])}));function TK(){const e=lt(),t=Je(),n=vn("keys"),r=L(g=>g.themePrefs),o=L(g=>g.themes),s=L(g=>g.chatSide),a=L(g=>g.keepAwake),c=Iw(),u=L(g=>g.agents),h=Jl(),f=L(g=>g.rows),m=g=>{e({a:"palette-return",v:{mode:"keys",q:""}}),e(g)};return d.jsxs(Au,{bare:!0,boxClass:"keys-stack",id:"keys-help",onClose:()=>e({a:"close"}),children:[d.jsxs("div",{className:"keys-card",children:[d.jsxs("div",{children:[h&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"section-title keys-h",children:h.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 ${h.configFile}`,onClick:()=>e({a:"open",overlay:{kind:"setup",repoId:h.id}}),...n.contextMenu(()=>Jh(h,h.id,{sock:t,dispatch:e},f)),children:d.jsx("span",{className:"keys-v",children:Object.keys(h.config.run).join(" + ")||"not set up"})})]})]}),d.jsx("div",{className:"section-title keys-h",children:"Agents"}),u.map(g=>d.jsx(CK,{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:()=>m({a:"open",overlay:{kind:"appearance"}}),children:oh[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:()=>m({a:"open",overlay:{kind:"theme",slot:"theme"}}),children:Rh(r,o,c).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:()=>m({a:"open",overlay:{kind:"keep-awake"}}),children:sh[a]})]}),d.jsx(jK,{}),d.jsx($K,{})]})]}),d.jsx("div",{className:"keys-card",children:NK.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(rs,{k:y}),d.jsx("span",{className:"keys-d",children:w})]},y))]},g.title))})]})}function jK(){const e=Je(),t=lt(),n=vn("keys"),r=L(T=>T.version),o=L(T=>T.install),s=L(T=>T.registry),a=L(T=>T.update),c=L(T=>T.self),u=L(T=>T.rebuilt),h=L(T=>T.repos),f=L(T=>T.managed.updates),m=L(T=>T.updateCheck),g=L(T=>T.frame),y=L(T=>T.newProject!==null),w=SK(r,o,a,c,h,u,s,m),v=!f&&(w.act==="update"||w.act==="check"),_=w.settles&&m&&m!=="asking"?m:null;S.useEffect(()=>{if(!_)return;const T=()=>t({a:"update-check-settle",check:_}),j=setTimeout(T,xK);return()=>{clearTimeout(j),T()}},[_,t]);const x=()=>{w.act==="restart"?e==null||e.send({t:"restart-daemon"}):w.act==="reload"?window.location.reload():w.act==="rebuild"&&c?e==null||e.send({t:"run-after-land",repoId:c.repoId}):w.act==="update"?e==null||e.send({t:"update-now"}):w.act==="check"&&e&&(t({a:"update-check"}),e.send({t:"check-update"}))},N=()=>_K(r,w.act==="check"&&!w.busy?{run:x,...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(N),children:[d.jsx("span",{className:"keys-d",children:"version"}),d.jsx(Me,{variant:"field",mono:!0,busy:w.busy,disabled:v,onClick:x,...Ft(v?"updates are managed by your organization":w.text,void 0,{detail:w.detail}),children:w.value})]})}function $K(){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: ${ML(e).join(", ")||"nothing turned off"}`;return d.jsx("div",{className:"hint",children:t})}function L$(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 P$(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":hp(e)}function CK({agent:e}){const t=lt(),n=Je(),r=vn("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":P$(e),...r.contextMenu(()=>Iy(e,{sock:n})),onClick:()=>{t({a:"palette-return",v:{mode:"keys",q:""}}),t({a:"open",overlay:{kind:"agent-page",agent:e.id}})},children:L$(e)})]})}function AK({agentId:e}){const t=lt(),n=Je(),r=Jl(),o=L(g=>g.home),s=L(g=>g.agents.find(y=>y.id===e)??null),a=L(g=>g.agentConfigs[e]??null),c=vn("keys");if(S.useEffect(()=>{n==null||n.send({t:"agent-config",agent:e,...r?{repoId:r.id}:{}})},[n,e,r]),C$(n,e,s??void 0),!s)return null;const u=Iy(s,{sock:n}),h=()=>t({a:"close",back:!0}),f=g=>o&&g.startsWith(`${o}/`)?`~${g.slice(o.length)}`:g,m=g=>n==null?void 0:n.send({t:"reveal-agent-file",agent:e,file:g.id,...r?{repoId:r.id}:{}});return d.jsx(Au,{bare:!0,boxClass:"keys-stack",onClose:h,children:d.jsxs("div",{className:"keys-card keys-settings",children:[d.jsx("div",{className:"agent-page-back",children:d.jsx(Lt,{icon:"back",label:"back to settings",hint:"esc",onClick:h})}),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":P$(s),disabled:u.length===0,...c.dropdown(()=>u,"right"),children:L$(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(IK,{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 ${f(g.path)} in Finder`,onClick:()=>m(g),children:f(g.path)}):d.jsxs("span",{className:"keys-d",children:["not present: ",f(g.path)]})]},g.id))]})]})})}function IK({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 RK(){const e=lt(),t=Je(),n=L(o=>o.agents),r=L(o=>o.defaultAgent);return d.jsx(Kr,{items:n,filter:(o,s)=>o.filter(a=>ts(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=>Iy(o,{sock:t}),placeholder:"default agent for new worktrees",row:o=>d.jsx(Cn,{label:o.name,current:o.id===r,hint:o.available?o.checkFailed??(o.sandboxed?void 0:"unsandboxed"):hp(o)})})}const OK=["dark","light","system","daylight"],MK=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"});function LK(){const e=lt(),t=Je(),n=L(u=>u.themePrefs),r=L(u=>u.themes),o=Iw(),s=L(u=>u.daylight),a=u=>{var h;return((h=r.find(f=>f.id===n[fw({...n,mode:u},o)]))==null?void 0:h.name)??""},c=u=>{if(u==="system")return`${o.system?"dark":"light"} now · ${a(u)}`;if(u!=="daylight")return a(u);const h=s&&s.until>Date.now()?` · ${o.daylight?"light":"dark"} at ${MK.format(s.until)}`:"";return`${o.daylight?"dark":"light"} now${h} · ${a(u)}`};return d.jsx(Kr,{items:OK,filter:(u,h)=>u.filter(f=>ts(h,oh[f])),rowClass:()=>"picker-row",keyOf:u=>u,initialIndex:u=>u.indexOf(n.mode),onActive:u=>e({a:"preview-theme",theme:u?Rh({...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(Cn,{label:oh[u],current:u===n.mode,hint:c(u)})})}const PK=2,zk=e=>jS(e).join(" ").length<PK,DK=e=>({kind:"chat",id:e.id,name:e.name,hint:e.branch??"",fields:[e.name,e.branch??""]}),zK=e=>({kind:"chat",id:e.id,name:e.title,hint:uT(e),fields:[e.title,e.branch],prompt:e.prompt,archived:e});function FK(e,t,n){const r=jS(t),o=n==="all"&&!zk(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(c=>a.some(u=>u.toLowerCase().includes(c)))})}const BK=e=>e.flatMap(([t,n])=>Array.from({length:n},(r,o)=>t+o));function UK({repoId:e,scope:t}){const n=lt(),r=Je(),o=L(j=>j.clientId),s=L(j=>j.frame),a=L(j=>j.chats[e]),c=Pw(),u=L(j=>j.archived[e]),[h,f]=S.useState(t),m=S.useCallback(()=>f(j=>j==="all"?"names":"all"),[]);S.useEffect(()=>{r==null||r.send({t:"list-archived",repoId:e})},[r,e]);const g=S.useMemo(()=>[...c.filter(j=>!Tr(j.worktree)).map(DK),...(u??[]).map(zK)],[c,u]),y=S.useMemo(()=>new Map(g.map(j=>[j.id,j])),[g]),w=S.useMemo(()=>[...g,...((a==null?void 0:a.hits)??[]).map(j=>({kind:"hit",hit:j}))],[g,a]),v=S.useMemo(()=>{const j=new Map;for(const C of(a==null?void 0:a.hits)??[])j.set(C.worktreeId,Math.max(j.get(C.worktreeId)??0,C.ts));return j},[a]),_=S.useCallback((j,C)=>FK(j,C,h),[h]),x=S.useCallback(j=>{h==="all"&&!zk(j)&&(r==null||r.send({t:"search-chats",repoId:e,query:j.trim()}))},[r,e,h]),N=j=>!a||a.query!==j.trim(),T=j=>h==="all"&&!zk(j);return d.jsx(Kr,{items:w,filter:_,onQuery:x,onTab:m,trailing:d.jsx(Me,{tone:"chrome",on:h==="names","aria-pressed":h==="names",onClick:m,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":Be("picker-row",j.archived&&!j.archived.restorable&&"dim"),rowTitle:j=>{var C;return j.kind==="hit"?j.hit.text:((C=j.archived)==null?void 0:C.prompt)??j.name},groupOf:j=>j.kind==="hit"?`h:${j.hit.worktreeId}`:j.archived?"archived":"open",groupHead:(j,C)=>{if(!j.startsWith("h:"))return`${j} · ${C}`;const I=j.slice(2),A=y.get(I),M=a==null?void 0:a.asks[I],O=v.get(I)??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"})]})]}),O>0&&d.jsx("span",{className:"picker-group-tail",children:fr(O)}),M&&d.jsx("span",{className:"picker-group-line",children:Xh(M,VN*2)})]})},headAlone:!0,onPick:j=>{const C=j.kind==="hit"?j.hit.worktreeId:j.id,I=j.kind==="hit"?j.hit.archived:!!j.archived;n(I?{a:"open-archived",id:C}:{a:"activate",id:C}),j.kind==="hit"&&n({a:"reveal",id:C,seq:j.hit.seq}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:j=>j.kind==="chat"&&j.archived?Mf(j.archived,{clientId:o,frame:s},{sock:r,dispatch:n}):[],placeholder:h==="names"?"find a chat by name…":"search in chats…",keys:j=>({nav:"moves",tab:h==="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)?N(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,C)=>{const I=C.filter(A=>A.kind==="hit").length;return a!=null&&a.truncated&&!N(j)&&I>0?d.jsxs("div",{className:"empty",children:["showing the first ",I,"; narrow the search"]}):null},row:j=>j.kind==="chat"?d.jsx(Cn,{label:j.name,hint:j.hint}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"chats-text",children:Vl(j.hit.text,BK(j.hit.match),0)}),d.jsxs("span",{className:"chats-said row-dim",children:[j.hit.role==="user"?"you":"the agent",j.hit.ts>0&&fr(j.hit.ts)!==fr(v.get(j.hit.worktreeId)??0)?` · ${fr(j.hit.ts)}`:""]})]})})}const tc=function(e,t){let o=e;const s=ou[t];let a=null,c=0,u=null;const h=[],f={},m=function(A,M){c=o*4+17,a=(function(O){const z=new Array(O);for(let B=0;B<O;B+=1){z[B]=new Array(O);for(let H=0;H<O;H+=1)z[B][H]=null}return z})(c),g(0,0),g(c-7,0),g(0,c-7),v(),w(),x(A,M),o>=7&&_(A),u==null&&(u=j(o,s,h)),N(u,M)},g=function(A,M){for(let O=-1;O<=7;O+=1)if(!(A+O<=-1||c<=A+O))for(let z=-1;z<=7;z+=1)M+z<=-1||c<=M+z||(0<=O&&O<=6&&(z==0||z==6)||0<=z&&z<=6&&(O==0||O==6)||2<=O&&O<=4&&2<=z&&z<=4?a[A+O][M+z]=!0:a[A+O][M+z]=!1)},y=function(){let A=0,M=0;for(let O=0;O<8;O+=1){m(!0,O);const z=vi.getLostPoint(f);(O==0||A>z)&&(A=z,M=O)}return M},w=function(){for(let A=8;A<c-8;A+=1)a[A][6]==null&&(a[A][6]=A%2==0);for(let A=8;A<c-8;A+=1)a[6][A]==null&&(a[6][A]=A%2==0)},v=function(){const A=vi.getPatternPosition(o);for(let M=0;M<A.length;M+=1)for(let O=0;O<A.length;O+=1){const z=A[M],B=A[O];if(a[z][B]==null)for(let H=-2;H<=2;H+=1)for(let Y=-2;Y<=2;Y+=1)H==-2||H==2||Y==-2||Y==2||H==0&&Y==0?a[z+H][B+Y]=!0:a[z+H][B+Y]=!1}},_=function(A){const M=vi.getBCHTypeNumber(o);for(let O=0;O<18;O+=1){const z=!A&&(M>>O&1)==1;a[Math.floor(O/3)][O%3+c-8-3]=z}for(let O=0;O<18;O+=1){const z=!A&&(M>>O&1)==1;a[O%3+c-8-3][Math.floor(O/3)]=z}},x=function(A,M){const O=s<<3|M,z=vi.getBCHTypeInfo(O);for(let B=0;B<15;B+=1){const H=!A&&(z>>B&1)==1;B<6?a[B][8]=H:B<8?a[B+1][8]=H:a[c-15+B][8]=H}for(let B=0;B<15;B+=1){const H=!A&&(z>>B&1)==1;B<8?a[8][c-B-1]=H:B<9?a[8][15-B-1+1]=H:a[8][15-B-1]=H}a[c-8][8]=!A},N=function(A,M){let O=-1,z=c-1,B=7,H=0;const Y=vi.getMaskFunction(M);for(let ie=c-1;ie>0;ie-=2)for(ie==6&&(ie-=1);;){for(let Q=0;Q<2;Q+=1)if(a[z][ie-Q]==null){let le=!1;H<A.length&&(le=(A[H]>>>B&1)==1),Y(z,ie-Q)&&(le=!le),a[z][ie-Q]=le,B-=1,B==-1&&(H+=1,B=7)}if(z+=O,z<0||c<=z){z-=O,O=-O;break}}},T=function(A,M){let O=0,z=0,B=0;const H=new Array(M.length),Y=new Array(M.length);for(let U=0;U<M.length;U+=1){const $=M[U].dataCount,q=M[U].totalCount-$;z=Math.max(z,$),B=Math.max(B,q),H[U]=new Array($);for(let fe=0;fe<H[U].length;fe+=1)H[U][fe]=255&A.getBuffer()[fe+O];O+=$;const V=vi.getErrorCorrectPolynomial(q),re=Ou(H[U],V.getLength()-1).mod(V);Y[U]=new Array(V.getLength()-1);for(let fe=0;fe<Y[U].length;fe+=1){const pe=fe+re.getLength()-Y[U].length;Y[U][fe]=pe>=0?re.getAt(pe):0}}let ie=0;for(let U=0;U<M.length;U+=1)ie+=M[U].totalCount;const Q=new Array(ie);let le=0;for(let U=0;U<z;U+=1)for(let $=0;$<M.length;$+=1)U<H[$].length&&(Q[le]=H[$][U],le+=1);for(let U=0;U<B;U+=1)for(let $=0;$<M.length;$+=1)U<Y[$].length&&(Q[le]=Y[$][U],le+=1);return Q},j=function(A,M,O){const z=nE.getRSBlocks(A,M),B=rE();for(let Y=0;Y<O.length;Y+=1){const ie=O[Y];B.put(ie.getMode(),4),B.put(ie.getLength(),vi.getLengthInBits(ie.getMode(),A)),ie.write(B)}let H=0;for(let Y=0;Y<z.length;Y+=1)H+=z[Y].dataCount;if(B.getLengthInBits()>H*8)throw"code length overflow. ("+B.getLengthInBits()+">"+H*8+")";for(B.getLengthInBits()+4<=H*8&&B.put(0,4);B.getLengthInBits()%8!=0;)B.putBit(!1);for(;!(B.getLengthInBits()>=H*8||(B.put(236,8),B.getLengthInBits()>=H*8));)B.put(17,8);return T(B,z)};f.addData=function(A,M){M=M||"Byte";let O=null;switch(M){case"Numeric":O=HK(A);break;case"Alphanumeric":O=WK(A);break;case"Byte":O=KK(A);break;case"Kanji":O=qK(A);break;default:throw"mode:"+M}h.push(O),u=null},f.isDark=function(A,M){if(A<0||c<=A||M<0||c<=M)throw A+","+M;return a[A][M]},f.getModuleCount=function(){return c},f.make=function(){if(o<1){let A=1;for(;A<40;A++){const M=nE.getRSBlocks(A,s),O=rE();for(let B=0;B<h.length;B++){const H=h[B];O.put(H.getMode(),4),O.put(H.getLength(),vi.getLengthInBits(H.getMode(),A)),H.write(O)}let z=0;for(let B=0;B<M.length;B++)z+=M[B].dataCount;if(O.getLengthInBits()<=z*8)break}o=A}m(!1,y())},f.createTableTag=function(A,M){A=A||2,M=typeof M>"u"?A*4:M;let O="";O+='<table style="',O+=" border-width: 0px; border-style: none;",O+=" border-collapse: collapse;",O+=" padding: 0px; margin: "+M+"px;",O+='">',O+="<tbody>";for(let z=0;z<f.getModuleCount();z+=1){O+="<tr>";for(let B=0;B<f.getModuleCount();B+=1)O+='<td style="',O+=" border-width: 0px; border-style: none;",O+=" border-collapse: collapse;",O+=" padding: 0px; margin: 0px;",O+=" width: "+A+"px;",O+=" height: "+A+"px;",O+=" background-color: ",O+=f.isDark(z,B)?"#000000":"#ffffff",O+=";",O+='"/>';O+="</tr>"}return O+="</tbody>",O+="</table>",O},f.createSvgTag=function(A,M,O,z){let B={};typeof arguments[0]=="object"&&(B=arguments[0],A=B.cellSize,M=B.margin,O=B.alt,z=B.title),A=A||2,M=typeof M>"u"?A*4:M,O=typeof O=="string"?{text:O}:O||{},O.text=O.text||null,O.id=O.text?O.id||"qrcode-description":null,z=typeof z=="string"?{text:z}:z||{},z.text=z.text||null,z.id=z.text?z.id||"qrcode-title":null;const H=f.getModuleCount()*A+M*2;let Y,ie,Q,le,U="",$;for($="l"+A+",0 0,"+A+" -"+A+",0 0,-"+A+"z ",U+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',U+=B.scalable?"":' width="'+H+'px" height="'+H+'px"',U+=' viewBox="0 0 '+H+" "+H+'" ',U+=' preserveAspectRatio="xMinYMin meet"',U+=z.text||O.text?' role="img" aria-labelledby="'+C([z.id,O.id].join(" ").trim())+'"':"",U+=">",U+=z.text?'<title id="'+C(z.id)+'">'+C(z.text)+"</title>":"",U+=O.text?'<description id="'+C(O.id)+'">'+C(O.text)+"</description>":"",U+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',U+='<path d="',Q=0;Q<f.getModuleCount();Q+=1)for(le=Q*A+M,Y=0;Y<f.getModuleCount();Y+=1)f.isDark(Q,Y)&&(ie=Y*A+M,U+="M"+ie+","+le+$);return U+='" stroke="transparent" fill="black"/>',U+="</svg>",U},f.createDataURL=function(A,M){A=A||2,M=typeof M>"u"?A*4:M;const O=f.getModuleCount()*A+M*2,z=M,B=O-M;return YK(O,O,function(H,Y){if(z<=H&&H<B&&z<=Y&&Y<B){const ie=Math.floor((H-z)/A),Q=Math.floor((Y-z)/A);return f.isDark(Q,ie)?0:1}else return 1})},f.createImgTag=function(A,M,O){A=A||2,M=typeof M>"u"?A*4:M;const z=f.getModuleCount()*A+M*2;let B="";return B+="<img",B+=' src="',B+=f.createDataURL(A,M),B+='"',B+=' width="',B+=z,B+='"',B+=' height="',B+=z,B+='"',O&&(B+=' alt="',B+=C(O),B+='"'),B+="/>",B};const C=function(A){let M="";for(let O=0;O<A.length;O+=1){const z=A.charAt(O);switch(z){case"<":M+="&lt;";break;case">":M+="&gt;";break;case"&":M+="&amp;";break;case'"':M+="&quot;";break;default:M+=z;break}}return M},I=function(A){A=typeof A>"u"?2:A;const O=f.getModuleCount()*1+A*2,z=A,B=O-A;let H,Y,ie,Q,le;const U={"██":"█","█ ":"▀"," █":"▄"," ":" "},$={"██":"▀","█ ":"▀"," █":" "," ":" "};let q="";for(H=0;H<O;H+=2){for(ie=Math.floor((H-z)/1),Q=Math.floor((H+1-z)/1),Y=0;Y<O;Y+=1)le="█",z<=Y&&Y<B&&z<=H&&H<B&&f.isDark(ie,Math.floor((Y-z)/1))&&(le=" "),z<=Y&&Y<B&&z<=H+1&&H+1<B&&f.isDark(Q,Math.floor((Y-z)/1))?le+=" ":le+="█",q+=A<1&&H+1>=B?$[le]:U[le];q+=`
268
- `}return O%2&&A>0?q.substring(0,q.length-O-1)+Array(O+1).join("▀"):q.substring(0,q.length-1)};return f.createASCII=function(A,M){if(A=A||1,A<2)return I(M);A-=1,M=typeof M>"u"?A*2:M;const O=f.getModuleCount()*A+M*2,z=M,B=O-M;let H,Y,ie,Q;const le=Array(A+1).join("██"),U=Array(A+1).join(" ");let $="",q="";for(H=0;H<O;H+=1){for(ie=Math.floor((H-z)/A),q="",Y=0;Y<O;Y+=1)Q=1,z<=Y&&Y<B&&z<=H&&H<B&&f.isDark(ie,Math.floor((Y-z)/A))&&(Q=0),q+=Q?le:U;for(ie=0;ie<A;ie+=1)$+=q+`
269
- `}return $.substring(0,$.length-1)},f.renderTo2dContext=function(A,M){M=M||2;const O=f.getModuleCount();for(let z=0;z<O;z++)for(let B=0;B<O;B++)A.fillStyle=f.isDark(z,B)?"black":"white",A.fillRect(B*M,z*M,M,M)},f};tc.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};tc.createStringToBytes=function(e,t){const n=(function(){const o=GK(e),s=function(){const u=o.read();if(u==-1)throw"eof";return u};let a=0;const c={};for(;;){const u=o.read();if(u==-1)break;const h=s(),f=s(),m=s(),g=String.fromCharCode(u<<8|h),y=f<<8|m;c[g]=y,a+=1}if(a!=t)throw a+" != "+t;return c})(),r=63;return function(o){const s=[];for(let a=0;a<o.length;a+=1){const c=o.charCodeAt(a);if(c<128)s.push(c);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 Ur={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},ou={L:1,M:0,Q:3,H:2},yi={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},vi=(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 c=0;for(;a!=0;)c+=1,a>>>=1;return c};return o.getBCHTypeInfo=function(a){let c=a<<10;for(;s(c)-s(t)>=0;)c^=t<<s(c)-s(t);return(a<<10|c)^r},o.getBCHTypeNumber=function(a){let c=a<<12;for(;s(c)-s(n)>=0;)c^=n<<s(c)-s(n);return a<<12|c},o.getPatternPosition=function(a){return e[a-1]},o.getMaskFunction=function(a){switch(a){case yi.PATTERN000:return function(c,u){return(c+u)%2==0};case yi.PATTERN001:return function(c,u){return c%2==0};case yi.PATTERN010:return function(c,u){return u%3==0};case yi.PATTERN011:return function(c,u){return(c+u)%3==0};case yi.PATTERN100:return function(c,u){return(Math.floor(c/2)+Math.floor(u/3))%2==0};case yi.PATTERN101:return function(c,u){return c*u%2+c*u%3==0};case yi.PATTERN110:return function(c,u){return(c*u%2+c*u%3)%2==0};case yi.PATTERN111:return function(c,u){return(c*u%3+(c+u)%2)%2==0};default:throw"bad maskPattern:"+a}},o.getErrorCorrectPolynomial=function(a){let c=Ou([1],0);for(let u=0;u<a;u+=1)c=c.multiply(Ou([1,Ei.gexp(u)],0));return c},o.getLengthInBits=function(a,c){if(1<=c&&c<10)switch(a){case Ur.MODE_NUMBER:return 10;case Ur.MODE_ALPHA_NUM:return 9;case Ur.MODE_8BIT_BYTE:return 8;case Ur.MODE_KANJI:return 8;default:throw"mode:"+a}else if(c<27)switch(a){case Ur.MODE_NUMBER:return 12;case Ur.MODE_ALPHA_NUM:return 11;case Ur.MODE_8BIT_BYTE:return 16;case Ur.MODE_KANJI:return 10;default:throw"mode:"+a}else if(c<41)switch(a){case Ur.MODE_NUMBER:return 14;case Ur.MODE_ALPHA_NUM:return 13;case Ur.MODE_8BIT_BYTE:return 16;case Ur.MODE_KANJI:return 12;default:throw"mode:"+a}else throw"type:"+c},o.getLostPoint=function(a){const c=a.getModuleCount();let u=0;for(let m=0;m<c;m+=1)for(let g=0;g<c;g+=1){let y=0;const w=a.isDark(m,g);for(let v=-1;v<=1;v+=1)if(!(m+v<0||c<=m+v))for(let _=-1;_<=1;_+=1)g+_<0||c<=g+_||v==0&&_==0||w==a.isDark(m+v,g+_)&&(y+=1);y>5&&(u+=3+y-5)}for(let m=0;m<c-1;m+=1)for(let g=0;g<c-1;g+=1){let y=0;a.isDark(m,g)&&(y+=1),a.isDark(m+1,g)&&(y+=1),a.isDark(m,g+1)&&(y+=1),a.isDark(m+1,g+1)&&(y+=1),(y==0||y==4)&&(u+=3)}for(let m=0;m<c;m+=1)for(let g=0;g<c-6;g+=1)a.isDark(m,g)&&!a.isDark(m,g+1)&&a.isDark(m,g+2)&&a.isDark(m,g+3)&&a.isDark(m,g+4)&&!a.isDark(m,g+5)&&a.isDark(m,g+6)&&(u+=40);for(let m=0;m<c;m+=1)for(let g=0;g<c-6;g+=1)a.isDark(g,m)&&!a.isDark(g+1,m)&&a.isDark(g+2,m)&&a.isDark(g+3,m)&&a.isDark(g+4,m)&&!a.isDark(g+5,m)&&a.isDark(g+6,m)&&(u+=40);let h=0;for(let m=0;m<c;m+=1)for(let g=0;g<c;g+=1)a.isDark(g,m)&&(h+=1);const f=Math.abs(100*h/c/c-50)/5;return u+=f*10,u},o})(),Ei=(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})(),Ou=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 c=0;c<o.getLength();c+=1)s[a+c]^=Ei.gexp(Ei.glog(r.getAt(a))+Ei.glog(o.getAt(c)));return Ou(s,0)},r.mod=function(o){if(r.getLength()-o.getLength()<0)return r;const s=Ei.glog(r.getAt(0))-Ei.glog(o.getAt(0)),a=new Array(r.getLength());for(let c=0;c<r.getLength();c+=1)a[c]=r.getAt(c);for(let c=0;c<o.getLength();c+=1)a[c]^=Ei.gexp(Ei.glog(o.getAt(c))+s);return Ou(a,0).mod(o)},r},nE=(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 ou.L:return e[(o-1)*4+0];case ou.M:return e[(o-1)*4+1];case ou.Q:return e[(o-1)*4+2];case ou.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 c=a.length/3,u=[];for(let h=0;h<c;h+=1){const f=a[h*3+0],m=a[h*3+1],g=a[h*3+2];for(let y=0;y<f;y+=1)u.push(t(m,g))}return u},n})(),rE=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},HK=function(e){const t=Ur.MODE_NUMBER,n=e,r={};r.getMode=function(){return t},r.getLength=function(a){return n.length},r.write=function(a){const c=n;let u=0;for(;u+2<c.length;)a.put(o(c.substring(u,u+3)),10),u+=3;u<c.length&&(c.length-u==1?a.put(o(c.substring(u,u+1)),4):c.length-u==2&&a.put(o(c.substring(u,u+2)),7))};const o=function(a){let c=0;for(let u=0;u<a.length;u+=1)c=c*10+s(a.charAt(u));return c},s=function(a){if("0"<=a&&a<="9")return a.charCodeAt(0)-48;throw"illegal char :"+a};return r},WK=function(e){const t=Ur.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 c=0;for(;c+1<a.length;)s.put(o(a.charAt(c))*45+o(a.charAt(c+1)),11),c+=2;c<a.length&&s.put(o(a.charAt(c)),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},KK=function(e){const t=Ur.MODE_8BIT_BYTE,n=tc.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},qK=function(e){const t=Ur.MODE_KANJI,n=tc.stringToBytes;(function(s,a){const c=n(s);if(c.length!=2||(c[0]<<8|c[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 c=0;for(;c+1<a.length;){let u=(255&a[c])<<8|255&a[c+1];if(33088<=u&&u<=40956)u-=33088;else if(57408<=u&&u<=60351)u-=49472;else throw"illegal char at "+(c+1)+"/"+u;u=(u>>>8&255)*192+(u&255),s.put(u,13),c+=2}if(c<a.length)throw"illegal char at "+(c+1)},o},D$=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},ZK=function(){let e=0,t=0,n=0,r="";const o={},s=function(c){r+=String.fromCharCode(a(c&63))},a=function(c){if(c<0)throw"n:"+c;if(c<26)return 65+c;if(c<52)return 97+(c-26);if(c<62)return 48+(c-52);if(c==62)return 43;if(c==63)return 47;throw"n:"+c};return o.writeByte=function(c){for(e=e<<8|c&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 c=3-n%3;for(let u=0;u<c;u+=1)r+="="}},o.toString=function(){return r},o},GK=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 c=r>>>o-8&255;return o-=8,c};const a=function(c){if(65<=c&&c<=90)return c-65;if(97<=c&&c<=122)return c-97+26;if(48<=c&&c<=57)return c-48+52;if(c==43)return 62;if(c==47)return 63;throw"c:"+c};return s},VK=function(e,t){const n=e,r=t,o=new Array(e*t),s={};s.setPixel=function(h,f,m){o[f*n+h]=m},s.write=function(h){h.writeString("GIF87a"),h.writeShort(n),h.writeShort(r),h.writeByte(128),h.writeByte(0),h.writeByte(0),h.writeByte(0),h.writeByte(0),h.writeByte(0),h.writeByte(255),h.writeByte(255),h.writeByte(255),h.writeString(","),h.writeShort(0),h.writeShort(0),h.writeShort(n),h.writeShort(r),h.writeByte(0);const f=2,m=c(f);h.writeByte(f);let g=0;for(;m.length-g>255;)h.writeByte(255),h.writeBytes(m,g,255),g+=255;h.writeByte(m.length-g),h.writeBytes(m,g,m.length-g),h.writeByte(0),h.writeString(";")};const a=function(h){const f=h;let m=0,g=0;const y={};return y.write=function(w,v){if(w>>>v)throw"length over";for(;m+v>=8;)f.writeByte(255&(w<<m|g)),v-=8-m,w>>>=8-m,g=0,m=0;g=w<<m|g,m=m+v},y.flush=function(){m>0&&f.writeByte(g)},y},c=function(h){const f=1<<h,m=(1<<h)+1;let g=h+1;const y=u();for(let N=0;N<f;N+=1)y.add(String.fromCharCode(N));y.add(String.fromCharCode(f)),y.add(String.fromCharCode(m));const w=D$(),v=a(w);v.write(f,g);let _=0,x=String.fromCharCode(o[_]);for(_+=1;_<o.length;){const N=String.fromCharCode(o[_]);_+=1,y.contains(x+N)?x=x+N:(v.write(y.indexOf(x),g),y.size()<4095&&(y.size()==1<<g&&(g+=1),y.add(x+N)),x=N)}return v.write(y.indexOf(x),g),v.write(m,g),v.flush(),w.toByteArray()},u=function(){const h={};let f=0;const m={};return m.add=function(g){if(m.contains(g))throw"dup key:"+g;h[g]=f,f+=1},m.size=function(){return f},m.indexOf=function(g){return h[g]},m.contains=function(g){return typeof h[g]<"u"},m};return s},YK=function(e,t,n){const r=VK(e,t);for(let c=0;c<t;c+=1)for(let u=0;u<e;u+=1)r.setPixel(u,c,n(u,c));const o=D$();r.write(o);const s=ZK(),a=o.toByteArray();for(let c=0;c<a.length;c+=1)s.writeByte(a[c]);return s.flush(),"data:image/gif;base64,"+s};tc.stringToBytes;function XK(e){const t=tc(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 dr={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 ${mh(e)}.`,waiting:(e,t)=>`Toyon on ${mh(e)} is asking whether to let ${t} in.`,added:e=>`Added ${e}.`,notKept:e=>`Let in, but not listed: ${e}`,add:"add"};function QK(e,t){return e.reached?e.toyon&&!e.toyon.answering?dr.notAnswering:t?dr.listed:e.toyon?null:dr.noToyon:dr.offline}function oE(e){var t;return(t=e.toyon)!=null&&t.answering?0:e.toyon?1:e.reached?2:3}function mh(e){try{return new URL(e).host}catch{return e}}function z$(e,t,n){const r=mh(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 JK(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",dr.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 eq=e=>e==="phone"?"phone":"laptop";function sE({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:Be("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(ht,{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:Be("tailnet-right",typeof t.right=="string"&&"hint"),children:t.right})]},t.key))})}const iE=(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:eq(e.kind),right:t}},yg=4;function tq({text:e}){const{size:t,d:n}=S.useMemo(()=>{const r=XK(e);let o="";return r.forEach((s,a)=>{s.forEach((c,u)=>{c&&(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 nq=5e3;function rq(e){return e.from===null?"A device that opened this address":`A Toyon page at ${mh(e.from)}`}function oq({knock:e,letIn:t,onAnswer:n}){return d.jsxs("div",{className:Be("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?`${rq(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 sq({host:e,noPhone:t}){return d.jsxs("div",{className:"devices-address",children:[d.jsx("div",{className:"devices-frame",children:d.jsx(tq,{text:YA(e)})}),d.jsxs("div",{className:"devices-about",children:[d.jsx("p",{className:"devices-line",children:dr.scan}),t&&d.jsx("p",{className:"devices-note",children:dr.noPhone})]})]})}function iq(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)=>oE(r.d)-oE(o.d)||r.i-o.i).map(({d:r})=>r);return[...t,...n]}function aq(){const e=lt(),t=gs(),n=Rr(),r=L(ce=>ce.frame==="desk"),o=L(ce=>{var ae;return((ae=ce.remote)==null?void 0:ae.host)??null}),s=L(ce=>ce.machine),a=L(ce=>ce.tailscale),c=L(ce=>ce.knocks),[u,h]=S.useState(""),[f,m]=S.useState({kind:"idle"}),[g,y]=S.useState([]),w=()=>e({a:"close"}),v=f.kind==="asking"||f.kind==="waiting",_=Sz(()=>h4(n),nq,!v),x=S.useRef(new AbortController);S.useEffect(()=>()=>x.current.abort(),[]);const N=async ce=>{if(v)return;const ae=x.current.signal;m({kind:"asking",origin:ce});const xe=await zS(ce,ae,Ee=>m({kind:"waiting",origin:ce,word:Ee}));if(ae.aborted)return;if(typeof xe=="string"){m({kind:"failed",line:z$(xe,ce,"this page")});return}const Re=t.serving(),ge=await w4(pw(Re.origin,Re.token),ce,xe.token);m(ge?{kind:"failed",line:dr.notKept(ge)}:{kind:"added",name:t.displayName(ce)})},T=()=>{const ce=XA(u);ce?N(ce):m({kind:"failed",line:dr.notAnAddress})},j=()=>{x.current.abort(),x.current=new AbortController,m({kind:"idle"})},C=(ce,ae)=>{y(xe=>xe.some(Re=>Re.knock.id===ce.id)?xe:[...xe,{knock:ce,letIn:ae}]),y4(n,ce.id,ae)},I=c.filter(ce=>!g.some(ae=>ae.knock.id===ce.id)),A=[...g,...I.map(ce=>({knock:ce,letIn:null}))],[M,O]=S.useState(!1),[z,B]=S.useState(null),H=async ce=>{O(!0),B(null);const ae=await(ce?p4(n):m4(n));O(!1),ae&&B(ae)},Y=(_==null?void 0:_.here)===!0,ie=JK(_,a,o),Q=o!==null,le=r&&(Y||_===void 0)?d.jsx(Me,{variant:"outline",size:"sm",on:Q,"aria-pressed":Q,busy:M,disabled:!Q&&(a==null?void 0:a.state)!=="ready",onClick:()=>void H(!Q),...Ft(Q?"Take this machine's name off your tailnet":"Give this machine a name on your tailnet"),children:Q?"on":"off"}):null,[U,$]=S.useState(!1),[q,V]=S.useState(null),W=ce=>{window.open(ce,"_blank","noopener")===null?V(ce):V(null)},re=async ce=>{if($(!0),B(null),ce==="connect"){const ae=await g4(n);ae&&B(ae)}else{const ae=await k4(n);"url"in ae?W(ae.url):B(ae.why)}$(!1)},fe=r&&ie.offer!==null?q!==null?d.jsx(Me,{variant:"outline",size:"sm",onClick:()=>W(q),children:"open the sign-in page"}):d.jsx(Me,{variant:"outline",size:"sm",busy:U,onClick:()=>void re(ie.offer??"connect"),...ie.note?Ft(ie.note):{},children:ie.offer==="connect"?"connect":"sign in"}):null,pe=ie.word===null&&le===null&&fe===null?"this machine":d.jsxs(d.Fragment,{children:[ie.word&&d.jsx("span",{className:"hint",children:ie.word}),le??fe]}),Te=[{key:"self",name:s??"This machine",host:o??void 0,reached:_===void 0?null:Y,icon:"laptop",right:pe}],je=_?iq(_).map(ce=>{if(ce.kind==="phone"||ce.host==="")return iE(ce,ce.reached?void 0:"not answering");const ae=`https://${ce.host}`,xe=QK(ce,t.get(ae)!==null);return iE(ce,xe??d.jsx(Me,{variant:"outline",size:"sm",disabled:v,onClick:()=>void N(ae),children:dr.request}))}):[],de=r&&o!==null&&_!==null&&(_===void 0||_.here),J=_==null?void 0:_.devices.some(ce=>ce.kind==="machine"&&ce.host!==""&&ce.reached&&ce.toyon===null),te=de&&_!==void 0&&!_.devices.some(ce=>ce.kind==="phone"),ve=(()=>{switch(f.kind){case"asking":return dr.asking(f.origin);case"waiting":return dr.waiting(f.origin,f.word);case"added":return dr.added(f.name);case"failed":return f.line;case"idle":return null}})();return d.jsxs(Au,{boxClass:"devices-card",onClose:w,children:[d.jsx("div",{className:"devices-title",children:dr.title}),d.jsx(sE,{rows:Te}),ie.note&&ie.offer===null&&d.jsx("p",{className:"devices-note",children:ie.note}),z&&d.jsx("p",{className:"devices-note",children:z}),r&&!Q&&(a==null?void 0:a.state)==="ready"&&d.jsx("p",{className:"devices-note",children:dr.turnOn}),de&&o!==null&&d.jsx(sq,{host:o,noPhone:te}),f.kind==="waiting"&&d.jsx("div",{className:"knock-word devices-word",children:f.word}),ve&&d.jsx("p",{className:Be("devices-line",f.kind==="failed"&&"devices-failed"),children:ve}),_!==void 0&&d.jsxs(d.Fragment,{children:[je.length>0&&d.jsx("div",{className:"devices-others",children:d.jsx(sE,{rows:je})}),(_==null?void 0:_.devices.length)===0&&d.jsx("p",{className:"devices-note",children:dr.noneOnTailnet}),J&&d.jsx("p",{className:"devices-note",children:dr.missing})]}),!v&&d.jsxs("form",{className:"devices-form",onSubmit:ce=>{ce.preventDefault(),T()},children:[d.jsx(zo,{size:"md",font:"ui",value:u,placeholder:dr.placeholder,"aria-label":"Address of the other machine",onChange:ce=>h(ce.target.value),className:"devices-field"}),d.jsx(Me,{type:"submit",variant:"outline",disabled:!u.trim(),children:dr.add})]}),v&&d.jsx("div",{className:"devices-actions",children:d.jsx(Me,{tone:"quiet",onClick:j,children:"cancel"})}),I.length>0&&d.jsx("p",{className:"devices-line devices-centred",children:dr.knocking}),A.map(ce=>d.jsx(oq,{knock:ce.knock,letIn:ce.letIn,onAnswer:ae=>C(ce.knock,ae)},ce.knock.id))]})}function lq({worktreeId:e,hits:t}){const n=lt(),r=Je(),o=L(c=>c.layout.changes),s=L(c=>{var h;const u=(h=Gt(c,e))==null?void 0:h.worktree;return u?u.path:null}),a=S.useCallback((c,u)=>{const h=u.trim().toLowerCase();return h?c.filter(f=>`${f.path}:${f.line} ${f.text}`.toLowerCase().includes(h)):c},[]);return d.jsx(Kr,{items:t,filter:a,keyOf:c=>`${c.path}:${c.line}`,rowClass:()=>"search-hit",rowTitle:c=>`${c.path}:${c.line}`,onPick:c=>{Rn({dispatch:n},{worktreeId:e,path:c.path,view:"file",line:{n:c.line}}),o||n({a:"toggle-changes"}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:c=>s?Os({id:e,dir:s},c.path,{},{sock:r,dispatch:n}):[],placeholder:"lines that could write this element",row:c=>d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"search-loc",children:[c.path,":",c.line]}),d.jsx("span",{className:"search-text",children:c.text})]})})}function cq({project:e}){const t=lt(),n=Je(),r=L(h=>h.paths),o=L(h=>h.home),s=S.useCallback(h=>{ju(h)&&(n==null||n.send({t:"browse-path",path:h}))},[n]),a=S.useCallback((h,f)=>CF({query:f,entries:r.entries,target:r.target,answered:r.query,home:o}),[r,o]),c=gu(e.name)?null:e.name.trim(),u=h=>`${h.replace(/\/+$/,"")}/`;return d.jsx(Kr,{initialQuery:u(e.parent),lead:d.jsx("span",{className:"picker-chip",children:c??"new project"}),items:[],filter:a,keyOf:h=>h.kind==="dir"?`d:${h.entry.path}`:`${h.kind}:${h.path}`,rowClass:()=>"picker-row folder-row",onQuery:s,completionOf:h=>h.kind==="dir"?u(h.entry.path):null,narrowTo:h=>h.kind==="dir"?u(h.entry.path):h.kind==="up"?u(h.path):null,onPick:h=>{h.kind==="here"&&(t({a:"new-project-set",v:{mode:e.mode==="init"?"create":e.mode,parent:h.path}}),t({a:"close"}))},onBack:()=>t({a:"close"}),placeholder:"type a folder path",keys:h=>({complete:"completes the path",pick:(h==null?void 0:h.kind)==="here"?"chooses it":(h==null?void 0:h.kind)==="up"?"goes up":"opens it",back:"goes back"}),empty:"no such folder",row:h=>h.kind==="here"?d.jsx(Cn,{label:`put ${c??"it"} in ${mk(h.path,o)}`,hint:d.jsx("bdi",{children:c?$T(h.path,c):h.path})}):h.kind==="up"?d.jsx(Cn,{label:`up to ${mk(h.path,o)}`,hint:d.jsx("bdi",{children:h.path})}):d.jsx(Cn,{label:h.entry.name})})}function uq({worktreeId:e}){const t=lt(),n=Je(),r=L(g=>g.clientId),o=L(g=>Gt(g,e)),s=L(g=>g.repos),c=Mt(e,"draft").trim(),u=o==null?void 0:o.worktree.repoId,h=S.useMemo(()=>[...s.filter(g=>g.id===u),...s.filter(g=>g.id!==u)],[s,u]),f=()=>t({a:"close"}),m=g=>{if(!o)return f();n==null||n.send({t:"handoff-ask",worktreeId:e,repoId:g.id,...c?{text:c}:{}}),c&&(n==null||n.send({t:"set-draft",boxId:e,text:"",clientId:r}),t({a:"set-draft",id:e,text:""})),f()};return d.jsx(Kr,{lead:d.jsx("span",{className:"picker-chip",children:(o==null?void 0:o.worktree.title)??"worktree"}),items:h,filter:(g,y)=>g.filter(w=>w.id===u&&ts(y,"here")||ts(y,w.name,w.path)),keyOf:g=>g.id,row:g=>d.jsx(Cn,{label:g.id===u?"a new worktree here":g.name,hint:g.path}),onPick:m,onBack:()=>t({a:"close",back:!0}),placeholder:"continue where?",empty:"no project is open",footer:c?()=>d.jsxs("div",{className:"empty",children:["with your message: ",c.split(`
270
- `)[0]]}):void 0})}const dq={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 fq(){const e=lt(),t=Je(),n=L(r=>r.keepAwake);return d.jsx(Kr,{items:[...bA],filter:(r,o)=>r.filter(s=>ts(o,sh[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(Cn,{label:sh[r],current:r===n,hint:dq[r]})})}function hq(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=fk(t.rows,null);return n?`${n.n} ${n.tier==="waiting"?"waiting":"unread"}`:"all quiet"}function Fk(e){try{return QA(new URL(e).hostname)}catch{return!1}}function pq(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()},c=new Map,u=w=>{var _;if(w.serving)return;(((_=w.store.getState().remote)==null?void 0:_.front)==="edge"||Fk(w.origin))&&w!==o?w.sock.suspend():w.sock.resume()},h=w=>{var _;let v=(_=w.store.getState().remote)==null?void 0:_.front;c.set(w.origin,w.store.subscribe(()=>{var N;const x=(N=w.store.getState().remote)==null?void 0:N.front;x!==v&&(v=x,u(w))}))},f=()=>s,m={list:f,active:()=>o,serving:()=>n,get:w=>f().find(v=>v.origin===w)??null,displayName(w){const v=f().find(x=>x.origin===w);return v?f().filter(x=>x.name===v.name).length>1?`${v.name} (${new URL(v.origin).host})`:v.name:w},activate(w){const v=f().find(x=>x.origin===w);if(!v||v===o)return;const _=o;o=v,u(_),u(v),a()},add(w){var x;const v=r.find(N=>N.origin===w.origin);if(w.origin===n.origin)return n;if(v){if(v.token===w.token)return v;(x=c.get(v.origin))==null||x(),v.dispose(),r.splice(r.indexOf(v),1),o===v&&(o=n)}const _=e.build({...w,serving:!1});return r.push(_),h(_),Fk(_.origin)&&_.sock.suspend(),a(),_},remove(w){var _;const v=r.find(x=>x.origin===w);v&&((_=c.get(w))==null||_(),c.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 f())v.store.dispatch(w)},subscribe(w){return t.add(w),()=>t.delete(w)}},g=w=>{for(const v of w)m.add(v);for(const v of[...r])w.some(_=>_.origin===v.origin)||m.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),m}function By({form:e,anchored:t}){var U;const n=lt(),r=Je(),o=gs(),s=Ds(),a=o.displayName(s.origin),c=L($=>$.repos),u=L($=>$.newProject?null:$.activeRepoId),h=L($=>$.rows),f=L($=>$.paths),m=L($=>$.home),g=L($=>$.pending),y=L($=>$.folderDialog),w=e==="url",v=S.useRef(""),_=S.useMemo(()=>F0(c,h),[c,h]),x=$_(),N=C_(),T=S.useMemo(()=>x.map($=>{var q;return{...$,repos:F0($.repos,((q=N.find(V=>V.origin===$.origin))==null?void 0:q.rows)??[])}}),[x,N]),j=S.useCallback($=>{v.current=$,ju($)&&(r==null||r.send({t:"browse-path",path:$}))},[r]),C=S.useCallback(($,q)=>$F({query:q,repos:_,pending:g,entries:[...f.entries].sort((V,W)=>Number(W.isRepo)-Number(V.isRepo)),target:f.target,answered:f.query,home:m,others:T,current:u,urlOnly:w}),[_,f,g,m,T,u,w]),I=()=>n({a:"close"}),A=()=>n({a:"close",back:!0}),M={sock:r,dispatch:n},O=$=>Tu(M,{t:"register-repo",path:$}),z=($,q)=>Tu(M,{t:"create-repo",mode:"create",parent:$,name:q}),B=($,q,V)=>n({a:"new-project",v:Ph({mode:$,name:q,parent:jF(c,u,m),...V})}),H=()=>n({a:"open",overlay:{kind:"projects",form:"disk"}}),Y=()=>n({a:"open",overlay:{kind:"projects",form:"url"}}),ie=()=>{const $=v.current.trim(),q=$.lastIndexOf("/"),V=ju($)&&q>=0?$.slice(0,q)||"/":"~";r==null||r.send({t:"choose-file",start:V}),I()},Q=()=>n({a:"open",overlay:{kind:"devices"}}),le=($,q)=>{const V=o.get($);V&&(V.store.dispatch({a:"activate-repo",id:q}),o.activate($))};return d.jsx(Kr,{anchored:e==="pill"&&(t??!0),initialQuery:e==="disk"?"~/":"",lead:e==="disk"||w?void 0:d.jsx("span",{className:"picker-chip",children:((U=c.find($=>$.id===u))==null?void 0:U.name)??"no project"}),trailing:w?void 0:e==="disk"?y?d.jsx(Lt,{icon:"file",label:"Open a file from Finder",onClick:ie}):void 0:d.jsx(Lt,{icon:"folder",label:"Find a project or file on disk",onClick:H}),items:[],filter:C,initialIndex:$=>$.findIndex(q=>q.kind==="repo"&&!q.machine&&q.repo.id===u),groupOf:$=>$.kind==="machine"||$.kind==="repo"&&$.machine?$.machine.origin:s.origin,groupHead:$=>$===s.origin?a:d.jsx(mq,{origin:$}),keyOf:$=>$.kind==="repo"?$.machine?`${$.machine.origin}:${$.repo.id}`:$.repo.id:$.kind==="dir"?`d:${$.entry.path}`:$.kind==="file"?`f:${$.entry.path}`:$.kind==="open"?`open:${$.path}`:$.kind==="init"?`init:${$.path}`:$.kind==="pending"?`p:${$.pending.id}`:$.kind==="clone"?`clone:${$.url}`:$.kind==="new"?"new-project":$.kind==="disk"?"open-folder":$.kind==="from-url"?"from-url":$.kind==="add-machine"?"add-machine":$.kind==="machine"?`machine:${$.machine.origin}`:`new:${$.parent??""}/${$.name}`,rowClass:$=>Be("picker-row",($.kind==="new"||$.kind==="disk"||$.kind==="from-url"||$.kind==="add-machine")&&"new-project-row"),onQuery:j,completionOf:$=>$.kind==="dir"?$.entry.isRepo?$.entry.path:`${$.entry.path}/`:$.kind==="file"?$.entry.path:null,narrowTo:$=>$.kind==="dir"&&!$.entry.isRepo?`${$.entry.path}/`:null,onPick:$=>{if($.kind==="clone")return B("clone",$.name,{url:$.url,...$.branch?{branch:$.branch}:{}});if($.kind==="create"&&!$.parent)return B("create",$.name);if($.kind==="new")return B("create","");if($.kind==="disk")return H();if($.kind==="from-url")return Y();if($.kind==="add-machine")return Q();$.kind==="machine"?o.activate($.machine.origin):$.kind==="pending"?n({a:"watch-import",id:$.pending.id}):$.kind==="repo"&&$.machine?le($.machine.origin,$.repo.id):$.kind==="repo"?n({a:"activate-repo",id:$.repo.id}):$.kind==="open"?O($.path):$.kind==="file"?RF(r,$.entry.path):$.kind==="init"?ST(M,$.path):$.kind==="dir"?O($.entry.path):$.parent&&z($.parent,$.name),I()},onBack:A,rowMenu:$=>$.kind==="machine"||$.kind==="repo"&&$.machine?hk(o,$.machine.origin):$.kind==="repo"?Jh($.repo,u,M,h):$.kind==="pending"?SF($.pending,M):[],placeholder:w?"paste a git URL, like https://github.com/you/app":c.length>1?"switch project, or type a name or path":"type a name or a path to start",keys:$=>({complete:"completes the path",pick:($==null?void 0:$.kind)==="dir"&&!$.entry.isRepo?"descends":($==null?void 0:$.kind)==="pending"?"watches it":($==null?void 0:$.kind)==="create"?$.parent?"creates it":"names it":($==null?void 0:$.kind)==="clone"?"clones it":($==null?void 0:$.kind)==="new"?"starts one":($==null?void 0:$.kind)==="disk"?"browses":($==null?void 0:$.kind)==="from-url"?"asks for one":($==null?void 0:$.kind)==="add-machine"?"adds one":($==null?void 0:$.kind)==="machine"||($==null?void 0:$.kind)==="repo"&&$.machine?"switches machine":"opens",back:"closes"}),empty:w?$=>$.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:$=>$.kind==="repo"?d.jsx(Cn,{label:$.repo.name,current:!$.machine&&$.repo.id===u}):$.kind==="pending"?d.jsx(Cn,{label:$.pending.name,hint:$.pending.error?"import failed":d.jsx("span",{className:"live-text",children:"importing"})}):$.kind==="dir"?d.jsx(Cn,{label:$.entry.name,hint:$.entry.isRepo?"git repo":void 0}):$.kind==="file"?d.jsx(Cn,{label:$.entry.name,hint:"file"}):$.kind==="open"?d.jsx(Cn,{label:`open ${$.path}`,hint:"register with this daemon"}):$.kind==="init"?d.jsx(Cn,{label:`open ${$.path}`,hint:"no git yet; starts it here with the files in it"}):$.kind==="clone"?d.jsx(Cn,{label:`clone ${$.name}`,hint:$.branch?`${aE($.url)} · ${$.branch}`:aE($.url)}):$.kind==="new"?d.jsx(Cn,{label:d.jsxs(d.Fragment,{children:[d.jsx(ht,{name:"plus",className:"icon-inline"}),"new project"]})}):$.kind==="disk"?d.jsx(Cn,{label:d.jsxs(d.Fragment,{children:[d.jsx(ht,{name:"folder",className:"icon-inline"}),"open folder or file"]})}):$.kind==="from-url"?d.jsx(Cn,{label:d.jsxs(d.Fragment,{children:[d.jsx(ht,{name:"globe",className:"icon-inline"}),"clone from a URL"]})}):$.kind==="add-machine"?d.jsx(Cn,{label:d.jsxs(d.Fragment,{children:[d.jsx(ht,{name:"devices",className:"icon-inline"}),"add a machine"]})}):$.kind==="machine"?d.jsx(Cn,{label:`switch to ${o.displayName($.machine.origin)}`}):d.jsx(Cn,{label:`create ${$.name}`,hint:$.parent?`in ${$.parent}`:"new project"})})}function mq({origin:e}){const t=gs(),n=t.get(e)??t.active(),r=Kc(n,m=>m.rows),o=Kc(n,m=>m.connected),s=Kc(n,m=>m.connectFailure),a=Kc(n,m=>m.incompatible),c=Kc(n,m=>{var g;return(g=m.remote)==null?void 0:g.front}),u=t.displayName(e),h=hq(u,{rows:r.filter(Sn),connected:o,connectFailure:s,incompatible:a,suspended:(c==="edge"||Fk(e))&&!o}),f=/^\d+ /.test(h);return d.jsxs(d.Fragment,{children:[u,d.jsx("span",{className:Be("picker-group-tail",f&&"picker-group-owed"),children:h})]})}function aE(e){const t=e.match(/^[a-z+]+:\/\/(?:[^@/]*@)?([^/:]+)/i)??e.match(/^[^@]+@([^:]+):/);return(t==null?void 0:t[1])??"git remote"}function gq(e){const t=[];if(e.pr){const r=e.pr.url;t.push({id:"open-pr",label:"open on GitHub",onClick:()=>window.open(r,"_blank")}),t.push({id:"copy-link",label:"copy link",onClick:()=>tn(r)})}const n=[{id:"copy-ref",label:e.kind==="pr"?"copy PR number":"copy branch name",onClick:()=>tn(e.ref)}];return Bn([t,n])}const kq=[],wq={branch:"branch",remote:"globe",pr:"pr"},lE={pr:0,branch:1,remote:2},yq={pr:"pull requests",branch:"branches",remote:"remote branches"};function vq({repoId:e}){const t=lt(),n=Je(),r=L(m=>m.clientId),o=L(m=>m.refs[e]),s=L(m=>m.rows),a=m=>{var g;return((g=s.find(y=>y.id===m))==null?void 0:g.name)??"a worktree"},c=S.useCallback(m=>[...m].sort((g,y)=>lE[g.kind]-lE[y.kind]),[]),u=S.useCallback(m=>n==null?void 0:n.send({t:"search-refs",repoId:e,query:m.trim()}),[n,e]),h=m=>!o||o.query!==m.trim(),f=m=>m.openIn?`open in ${a(m.openIn)}`:m.merged?"merged":m.pr?`${m.pr.author}${m.pr.draft?" · draft":""}${m.pr.fork?" · fork":""}`:m.subject??"";return d.jsx(Kr,{items:(o==null?void 0:o.refs)??kq,filter:c,onQuery:u,keyOf:m=>`${m.kind}:${m.ref}`,rowClass:()=>"picker-row ref-row",onPick:m=>{m.openIn?t({a:"activate",id:m.openIn}):n==null||n.send({t:"open-ref",repoId:e,kind:m.kind,ref:m.ref,clientId:r,...m.pr?{pr:{title:m.pr.title,url:m.pr.url}}:{}}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:gq,groupOf:m=>m.kind,groupHead:(m,g)=>`${yq[m]} · ${g}`,placeholder:"open a branch or PR…",keys:m=>({nav:"moves",pick:m!=null&&m.openIn?"switches to it":"opens it as a worktree",back:"closes"}),empty:m=>h(m)?d.jsx("span",{className:"live-text",children:"looking"}):m.trim()?"no branch or PR matches":"no unmerged branches or open PRs",row:m=>d.jsx(Cn,{label:d.jsxs(d.Fragment,{children:[d.jsx(ht,{name:wq[m.kind],className:"icon-inline"}),d.jsx("span",{className:"ref-name",children:m.name})]}),hint:f(m)})})}const cE=[],vg=2;function bq(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 xq({worktreeId:e}){const t=lt(),n=Je(),r=F_(e).search,o=L(h=>h.layout.changes),s=L(h=>{var m;const f=(m=Gt(h,e))==null?void 0:m.worktree;return f?f.path:null}),a=S.useCallback((h,f)=>f.trim().length>=vg?h:cE,[]),c=S.useCallback(h=>{const f=h.trim();f.length>=vg&&(n==null||n.send({t:"search",worktreeId:e,query:f}))},[n,e]),u=h=>!r||r.query.trim()!==h.trim();return S.useEffect(()=>()=>n==null?void 0:n.send({t:"search-stop"}),[n]),d.jsx(Kr,{items:(r==null?void 0:r.hits)??cE,filter:a,onQuery:c,keyOf:h=>`${h.path}:${h.line}`,rowClass:()=>"search-hit",rowTitle:h=>`${h.path}:${h.line}`,onPick:h=>{Rn({dispatch:t},{worktreeId:e,path:h.path,view:"file",line:{n:h.line}}),o||t({a:"toggle-changes"}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:h=>s?Os({id:e,dir:s},h.path,{},{sock:n,dispatch:t}):[],placeholder:"search in files…",empty:h=>h.trim().length<vg?"type at least two characters":u(h)?d.jsx("span",{className:"live-text",children:"searching"}):"no matches",footer:(h,f)=>r!=null&&r.truncated&&!u(h)&&f.length>0?d.jsx("div",{className:"empty",children:"not every match is shown; narrow the search"}):null,row:(h,f,m)=>d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"search-loc",children:[h.path,":",h.line]}),d.jsx("span",{className:"search-text",children:Vl(h.text,bq(h.text,m),0)})]})})}const uE=e=>e.source==="file"?"~/.toyon/themes":e.source==="vscode"?"VS Code":"";function Eq({slot:e}){const t=lt(),n=Je(),r=L(N=>N.themePrefs),o=L(N=>N.themes),s=Iw(),a=fw(r,s),c=r[e==="theme"?a:e],u=()=>t({a:"close"}),h=()=>t({a:"close",back:!0}),f=N=>t({a:"preview-theme",theme:N}),[m,g]=S.useState(null),[y,w]=S.useState(null),v=(N,T)=>N[T??a]??N.dark??N.light??null,_=S.useMemo(()=>ZP(o),[o]),x=S.useMemo(()=>o.filter(N=>N.kind===e),[o,e]);return at([m,y],()=>{e==="theme"&&f(m?v(m,y):null)}),e!=="theme"?d.jsx(Kr,{items:x,filter:(N,T)=>N.filter(j=>ts(T,j.name,j.id)),rowClass:()=>"picker-row",keyOf:N=>N.id,initialIndex:N=>N.findIndex(T=>T.id===c),onActive:f,onPick:N=>{n==null||n.send({t:"set-theme",prefs:{...r,[e]:N.id}}),u()},onBack:h,placeholder:`${e} slot override`,keys:{nav:"preview",pick:"keeps",back:"reverts"},empty:"no matching theme",row:N=>d.jsx(Cn,{label:N.name,current:N.id===c,hint:uE(N)})}):d.jsx(Kr,{items:_,filter:(N,T)=>N.filter(j=>{var C,I;return ts(T,j.name,(C=j.dark)==null?void 0:C.name,(I=j.light)==null?void 0:I.name)}),rowClass:()=>"picker-row",keyOf:N=>{var T,j;return N.name+(((T=N.dark)==null?void 0:T.id)??((j=N.light)==null?void 0:j.id))},initialIndex:N=>N.findIndex(T=>{var j,C;return((j=T.dark)==null?void 0:j.id)===c||((C=T.light)==null?void 0:C.id)===c}),onActive:g,onSide:N=>{var T;N.dark&&N.light&&w((((T=v(N,y))==null?void 0:T.kind)??a)==="dark"?"light":"dark")},onPick:N=>{n==null||n.send({t:"set-theme",prefs:GP(r,N)}),u()},onBack:h,placeholder:"theme",keys:{nav:"preview",side:"dark/light",pick:"keeps",back:"reverts"},empty:"no matching theme",row:(N,T)=>{var A,M;const j=v(N,T?y:null),C=uE(N.dark??N.light),I=((A=N.dark)==null?void 0:A.id)===c||((M=N.light)==null?void 0:M.id)===c;return d.jsx(Cn,{label:N.name,current:I,hint:d.jsxs("span",{className:"theme-kinds",children:[C&&d.jsx("span",{children:C}),d.jsx("span",{className:"kind","data-state":hr({current:T&&(j==null?void 0:j.kind)==="dark"}),children:N.dark?"dark":""}),d.jsx("span",{className:"kind","data-state":hr({current:T&&(j==null?void 0:j.kind)==="light"}),children:N.light?"light":""})]})})}})}function F$(){const e=Rz(),t=L(s=>s.frame==="phone"),n=Ql(),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(eW,{worktreeId:n}),(e==null?void 0:e.kind)==="search"&&n&&d.jsx(xq,{worktreeId:n}),(e==null?void 0:e.kind)==="element-sources"&&d.jsx(lq,{worktreeId:e.worktreeId,hits:e.hits}),(e==null?void 0:e.kind)==="refs"&&r&&d.jsx(vq,{repoId:r}),(e==null?void 0:e.kind)==="chats"&&r&&d.jsx(UK,{repoId:r,scope:e.names?"names":"all"}),(e==null?void 0:e.kind)==="keys"&&d.jsx(TK,{}),(e==null?void 0:e.kind)==="devices"&&d.jsx(aq,{}),(e==null?void 0:e.kind)==="theme"&&d.jsx(Eq,{slot:e.slot}),(e==null?void 0:e.kind)==="appearance"&&d.jsx(LK,{}),(e==null?void 0:e.kind)==="keep-awake"&&d.jsx(fq,{}),(e==null?void 0:e.kind)==="agent"&&d.jsx(RK,{}),(e==null?void 0:e.kind)==="agent-page"&&d.jsx(AK,{agentId:e.agent}),(e==null?void 0:e.kind)==="handoff"&&d.jsx(uq,{worktreeId:e.worktreeId}),(e==null?void 0:e.kind)==="commands"&&!t&&d.jsx(w$,{}),(e==null?void 0:e.kind)==="projects"&&e.form!=="pill"&&d.jsx(By,{form:e.form},e.form),(e==null?void 0:e.kind)==="choose-folder"&&o&&d.jsx(cq,{project:o})]})}const zf="Lost the daemon; retrying",dE="Not answering";function Sq(e,t){return e!=="down"&&e!=="blocked"?zf:t===null?dE:`${dE}; as of ${Eo(fr(t))}`}const _q="Not run by Toyon",B$="new worktree",U$=e=>`started from ${e}`,Nq=(e,t)=>`in ${e}, ${U$(t)}`,Tq=e=>`in ${e}, here while it needs you`,jq=new Set(["waiting","stopping","working","background","starting","failed","crashed"]);function Bk(e,t){if(!Sn(e))return e.locked?`Held by ${e.lockReason??"another tool"}`:t.path;if(t.op)return ww(t.op);if(Tr(e.worktree))return B$;const n=Lh(e,t.needsSetup),r=e.worktree.lastTurn;return!jq.has(ps(e))&&r?ty(r):t.at&&t.at!=="now"?`${n} · ${t.at}`:n}function $q(e,t){if(!Sn(e)||t)return!1;const n=ps(e);return(n==="idle"||n==="asleep")&&!e.unseen}function Cq(e){const t=e.worktree.lastTurn,n=e.worktree.landed?Qw(e.worktree.lands):[],r=t?(os(e.agent)?x5:ty)(t):void 0,o=Eh(e.worktree),s=o&&!e.worktree.landed?$s(o):void 0;return[...n,r,s].filter(a=>!!a)}function Aq(e,t,n,r){let o;const s=(f,m)=>{const g=m==null?void 0:m[m.length-1];g&&(!o||g.at>o.mark.at)&&(o={title:f,mark:g})};for(const f of e)f.worktree&&s(f.worktree.title,f.worktree.lands);for(const f of t)s(f.title,f.lands);const a=o&&YN(o.mark),c=o?`Landed ${o.title} ${Eo(fr(o.mark.at))}${a?`: ${Xr(a)}`:"."}`:void 0,u=n?HS(r,n):null,h=u?Xr(`${u.charAt(0).toUpperCase()}${u.slice(1)}`):n!=null&&n.fetchedAt?`Level with origin, fetched ${Eo(fr(n.fetchedAt))}.`:void 0;return[c,h].filter(f=>!!f)}function Iq(e){const t=e.prompt?Xh(e.prompt):"";return[...t?[t]:[],...Qw(e.lands)]}function Rq(e){const n=[e.auto&&Oq(e.auto,!!e.landed),e.cost!==void 0?qu(e.cost):void 0].filter(r=>!!r);return n.length?n:void 0}function Oq(e,t){const{what:n,idle:r}=TA(e);return r?`${t?"":`${n}, `}${r} idle`:n}const fE=25;function Mq(e,t){if(e.length<=fE+1)return{shown:e,rest:0};const n=e.slice(0,fE),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 Lq(e,t,n){const r=e.indexOf(t);return r<0?null:e[r+(n?1:-1)]??null}const Pq=.5;function Dq(e){const t=e.usage,n=t&&t.size>0?t.used/t.size:0,r=[n>=Pq?`${Math.round(100*n)}% of context`:void 0,e.queued?`${e.queued} queued`:void 0,(t==null?void 0:t.cost)!==void 0?qu(t.cost):void 0].filter(o=>!!o);return r.length?r:void 0}function zq(e){const t=e.filter(hs).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 Fq(e){return e.altKey?"Alt":e.ctrlKey?"Control":e.metaKey?"Meta":null}function Bq(e,t){return t==="Alt"?e.altKey:t==="Control"?e.ctrlKey:e.metaKey}const Uq=200,H$={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};function Hq(e,t=H$){let n=null,r=!1,o=null;const s=()=>{r||(r=!0,e(!0))},a=()=>{o!==null&&(t.clear(o),o=null)},c=()=>{a(),n=null,r&&(r=!1,e(!1))};return{press(u){const h=n!==null;n=Fq(u),a(),n&&(h?s():o=t.set(()=>{o=null,s()},Uq))},keyup(u){n&&u===n&&c()},mods(u){n&&!Bq(u,n)&&c()},end:c}}const Wq=350,Kq=80,qq=2e3;function Zq(e,t=H$){let n=!1,r=null,o=null,s=null,a=null;const c=()=>{r&&(t.clear(r.pending),r=null)},u=()=>{s!==null&&t.clear(s),a!==null&&t.clear(a),s=null,a=null},h=()=>{c(),u(),o=null,n&&(n=!1,e(!1))};return{over(f){u(),a=t.set(h,qq),n||(n=!0,e(!0)),(r==null?void 0:r.id)!==(f==null?void 0:f.id)&&(c(),!(!f||f.id===o)&&(o=null,r={id:f.id,pending:t.set(()=>{r=null,o=f.id,f.land()},Wq)}))},leave(){n&&(s!==null&&t.clear(s),s=t.set(h,Kq))},end:h}}const Sf=e=>e>999?"1k+":String(e);function W$({width:e,placement:t="strip"}){const n=t==="screen",r=Ra(),o=Bu("chat"),s=lt(),a=Je(),{host:c}=Rr(),u=Pw(),h=u[0]&&Tr(u[0].worktree)?u[0]:null,f=h?u.slice(1):u,m=L(X=>Hl(X,X.activeRepoId)),g=X=>h&&X.id===h.id&&m?{behind:m.behind,dirty:m.dirty}:X,[,y]=S.useState(0);S.useEffect(()=>{const X=setInterval(()=>y(be=>be+1),6e4);return()=>clearInterval(X)},[]);const w=Nz(),v=Tz(),_=jz(),x=$z(),N=(X,be,Ve)=>{X.key!=="ArrowLeft"&&X.key!=="ArrowRight"||X.shiftKey||X.altKey||X.metaKey||X.ctrlKey||(X.preventDefault(),Vh([{depth:0,open:be}],0,X.key)&&s({a:Ve}))},T=Ia(),j=L(X=>X.notesPage),C=L(X=>X.clientId),I=L(X=>X.frame),A=L(X=>X.activeRepoId),M=L(X=>X.connected);S.useEffect(()=>{a&&M&&A&&a.send({t:"list-archived",repoId:A})},[a,M,A]);const O=Ql(),z=P_(),B=L(X=>X.layout),H=L(X=>X.railOpen),Y=L(X=>X.railPeek),ie=S.useRef(null),[Q,le]=S.useState(!1);at([Y],()=>{var X;Y&&!n&&!r&&!((X=ie.current)!=null&&X.matches(":hover"))&&le(!0)}),S.useEffect(()=>{if(!Q)return;let X=null;const be=Ve=>{if(!X){X={x:Ve.clientX,y:Ve.clientY};return}Math.abs(Ve.clientX-X.x)+Math.abs(Ve.clientY-X.y)<3||le(!1)};return window.addEventListener("pointermove",be),()=>window.removeEventListener("pointermove",be)},[Q]);const[U,$]=S.useState(!1),q=S.useMemo(()=>Zq($),[]);S.useEffect(()=>()=>q.end(),[q]);const V=L(X=>{var be;return((be=X.dragFiles)==null?void 0:be.at)==="rail"?X.dragFiles.worktreeId:null}),W=L(X=>X.focusRail),re=S.useRef(W),fe=S.useRef(null);at([W],()=>{if(W===re.current)return;re.current=W;const X=requestAnimationFrame(()=>{var be,Ve;return(Ve=(be=fe.current)==null?void 0:be.querySelector('[data-state~="current"]'))==null?void 0:Ve.focus()});return()=>cancelAnimationFrame(X)});const pe=(X,be,Ve,Qe,Ht)=>{var bn,P;if(X.key!=="ArrowUp"&&X.key!=="ArrowDown"||X.altKey||X.ctrlKey||X.metaKey)return;X.preventDefault();const St=Lq(be,Ve,X.key==="ArrowDown");St!==null&&(Ht(St),(P=(bn=fe.current)==null?void 0:bn.querySelector(`[${Qe}="${St}"]`))==null||P.focus())},Te=L(X=>X.repos),je=L(X=>X.shipping),de=L(X=>X.rows),J=X=>Te.find(be=>be.id===X.repoId)??null,te=X=>A?jw(X,A,de):null,ve=X=>A&&X.repoId!==A?J(X):null,ce=vn("rail"),ae=On(),xe=Fw(),Re=L(X=>X.home),ge=X=>{const be=X.worktree?X.worktree.path:X.path;return Re&&be.startsWith(`${Re}/`)?`~${be.slice(Re.length)}`:be},[Ee,We]=S.useState(!1),[Ye,ln]=S.useState([]),cn=X=>{!jf(X.worktree)||ve(X)||(We(!0),ln(be=>be.includes(X.worktree.id)?be.filter(Ve=>Ve!==X.worktree.id):[...be,X.worktree.id]))},gt=()=>{We(!1),ln([])};at([Ee],()=>{const X=be=>be.key==="Escape"&&gt();return Ee&&window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)});const Ue={sock:a,dispatch:s},zt=X=>Nw(ae.getState(),X),pt=X=>{We(!0),ln(be=>X===O||be.includes(X)?be:[...be,X])},At=X=>Sn(X)?ZN(X,J(X),{layout:B,shipping:je,frame:I,drafted:zt},Ue,{...ve(X)?{}:{graft:pt},hostname:c}):u5(X,{clientId:C,frame:I},Ue,c),[Kt,xt]=S.useState(null),un=X=>Sn(X)?zq(At(X)):[],Ct=L(X=>X.left);RN(fe,{rowOf:X=>{if(!n||Ee||f_({left:Ct},Date.now()))return null;const be=X.closest(".slide"),Ve=be==null?void 0:be.dataset.row,Qe=Ve?u.find(Ht=>Ht.id===Ve):void 0;return be&&Ve&&Qe?{el:be,key:Ve,rungs:un(Qe).length}:null},onSlide:xt,onPick:(X,be)=>{var Ht;const Ve=u.find(St=>St.id===X),Qe=Ve?un(Ve)[be-1]:void 0;if(!(!Ve||!Qe)){if(Qe.id==="more"){const St=(Ht=fe.current)==null?void 0:Ht.querySelector(`.slide[data-row="${X}"]`);St&&ce.openUnder(St,()=>At(Ve),X)}else if(Qe.item&&!Qe.item.disabled){const St=Qe.item.onClick;window.setTimeout(St,AN)}}}});const Ut=Mq(_,(T==null?void 0:T.id)??null),Et=Ut.shown.some(X=>(X.dirty??0)>0),er=X=>d.jsxs("button",{type:"button",className:Be("row row-edge row-quiet rail-disc-item rail-arch-item",(xe==null?void 0:xe.owner)==="rail"&&xe.key===X.id&&"menu-open"),"data-state":hr({current:!n&&(T==null?void 0:T.id)===X.id}),"data-arch":X.id,...Ft(eF(X),void 0,{placement:o,card:!0,detail:Iq(X),aside:Rq(X)}),onClick:()=>s({a:"open-archived",id:X.id}),onKeyDown:be=>pe(be,Ut.shown.map(Ve=>Ve.id),X.id,"data-arch",Ve=>s({a:"open-archived",id:Ve})),...ce.contextMenu(()=>Mf(X,{clientId:C,frame:I},Ue),X.id),children:[d.jsxs("span",{className:"rail-gut",onClick:r?be=>{be.stopPropagation(),ce.openUnder(be.currentTarget,()=>Mf(X,{clientId:C,frame:I},Ue),X.id)}:void 0,children:[d.jsx("span",{className:"rail-at row-dim",children:fr(X.archivedAt)}),d.jsx("span",{className:"rail-more",...Ft("Actions"),onClick:be=>{be.stopPropagation(),ce.openUnder(be.currentTarget,()=>Mf(X,{clientId:C,frame:I},Ue),X.id)},children:d.jsx(ht,{name:"more"})})]}),d.jsx("span",{className:"branch",children:X.title}),Et&&d.jsx("span",{className:"rail-counts",children:d.jsx("span",{className:"rail-count row-dim","data-tip":X.dirty?`${X.dirty} uncommitted, kept`:void 0,children:X.dirty?`~${Sf(X.dirty)}`:""})}),X.auto?d.jsx("span",{className:"rail-glyph rail-auto row-dim",children:d.jsx(ht,{name:"clock",className:"icon-inline"})}):d.jsx("span",{className:"dot"}),n&&d.jsx("span",{className:"rail-at rail-at-end row-dim",children:fr(X.archivedAt)})]},X.id),Qt=[...u,...w].map(g),Nn=["ahead","dirty","behind"].filter(X=>Qt.some(be=>(be[X]??0)>0)),Zn=X=>{const be=Nn.findIndex(Ve=>(X[Ve]??0)>0);return new Set(be<0?[]:Nn.slice(be))},nn=X=>{var xn;const be=Sn(X)?X:null,Ve=!!be&&Tr(be.worktree),Qe=g(X),Ht=Te.find(Rt=>Rt.id===X.repoId)??null,St=Ht?xh(Ht):"main",bn=Ht&&fI(Ht)&&(m!=null&&m.fetchedAt)?` as of ${Mh(m.fetchedAt)}`:"",P=Zn(Qe),ne=!!Qe.ahead&&!Qe.dirty,Se=X.id,Ge=(xe==null?void 0:xe.owner)==="rail"&&xe.key===Se,It=be?te(be):null,Pt=be?ve(be):null,De=be&&!Pt?_D(be,de,_):null,ze=be&&!Pt&&Ee&&jf(be.worktree)&&Se!==O,Ke=be&&be.worktree.kind==="worktree"&&!Pt?{title:be.worktree.title,branch:be.worktree.branch}:null,Vt=qS(X,(xn=je[Se])==null?void 0:xn.op),Yt=d.jsxs("button",{type:"button",className:Be("row row-edge",be?"rail-item":"row-quiet rail-disc-item",n&&$q(X,Vt)&&"row-quiet",Ge&&"menu-open",V===Se&&"drop-over"),"data-state":hr({current:!n&&Se===O&&!T&&!j,checked:Ye.includes(Se)}),...be?Ft(z?zf:Vt?ww(Vt):Lh(X,Qf(J(be))),void 0,{placement:o,card:!0,aside:Dq(X),detail:Tr(be.worktree)?Aq(u,_,m,St):[...Pt?[It?Nq(Pt.name,It.worktree.title):Tq(Pt.name)]:De?[U$(De)]:[],...Cq(be)],dot:z?void 0:Vt?"background":ps(X)}):Ft(z?zf:X.locked?`Held by ${X.lockReason??"another tool"}`:_q,void 0,{placement:o,card:!0,detail:ge(X),dot:z||X.locked?void 0:"discovered"}),"data-wt":Se,draggable:Ke!==null,onDragStart:Ke!==null?Rt=>Su(Rt,{kind:"worktree",worktreeId:Se,...Ke}):void 0,onDragEnd:()=>Ku(ae),onKeyDown:Rt=>{if(Ee)return;const Mn=(be?u:w).map(rn=>rn.id);pe(Rt,Mn,Se,"data-wt",rn=>s({a:"activate",id:rn}))},onClick:Rt=>{be&&!Pt&&(Ee||Rt.shiftKey)?Se===O?We(!0):cn(be):Ve&&!n?s({a:"open-draft"}):(s({a:"activate",id:Se}),be&&!r&&s({a:"walked"}))},...ce.contextMenu(()=>At(X),Se),children:[d.jsx("span",{className:"rail-gut",onClick:r&&!Ee?Rt=>{Rt.stopPropagation(),ce.openUnder(Rt.currentTarget,()=>At(X),Se)}:void 0,children:ze?d.jsx("input",{type:"checkbox",className:"rail-graft-check",checked:Ye.includes(Se),readOnly:!0,tabIndex:-1}):!Ee&&d.jsxs(d.Fragment,{children:[be&&!Ve&&d.jsx("span",{className:"rail-at row-dim",children:fr(Ea(be.worktree))}),d.jsx("span",{className:"rail-more",...Ft("Actions"),onClick:Rt=>{Rt.stopPropagation(),ce.openUnder(Rt.currentTarget,()=>At(X),Se)},children:d.jsx(ht,{name:"more"})})]})}),Ve?d.jsxs("span",{className:"branch rail-main-label",children:[d.jsx(ht,{name:"plus",className:"icon-inline"}),"new worktree"]}):d.jsx("span",{className:Be("branch",(be==null?void 0:be.worktree.unnamed)&&"row-dim"),children:Hg(X,be?J(be):null)}),(be==null?void 0:be.worktree.mode)&&be.worktree.mode!=="auto"&&d.jsx("span",{className:"rail-badge badge-mode","data-tip":`${be.worktree.mode} mode: the agent waits for you`,children:be.worktree.mode}),be&&(()=>{const Rt=J(be),Mn=HN(be.worktree,Rt);return Mn&&Mn!==(Rt==null?void 0:Rt.config.defaultProfile)?d.jsx("span",{className:"rail-badge badge-profile","data-tip":`runs the ${Mn} profile`,children:Mn}):null})(),Pt&&d.jsx("span",{className:"rail-guest row-dim",children:Pt.name}),d.jsxs("span",{className:"rail-counts",children:[P.has("ahead")&&d.jsx("span",{className:"rail-count badge-ahead","data-tip":Qe.ahead?`${Qe.ahead} ahead of ${St}`:void 0,children:Qe.ahead?`+${Sf(Qe.ahead)}`:""}),P.has("dirty")&&!ne&&d.jsx("span",{className:"rail-count badge-dirty","data-tip":Qe.dirty?`${Qe.dirty} uncommitted${Ve?" on main":""}`:void 0,children:Qe.dirty?`~${Sf(Qe.dirty)}`:""}),P.has("behind")&&d.jsx("span",{className:"rail-count rail-behind row-dim","data-tip":Qe.behind?`${Qe.behind} behind ${Ve?"origin":St}${Ve?"":bn}`:void 0,children:Qe.behind?Sf(Qe.behind):""}),n&&be&&d.jsx("span",{className:"rail-at row-dim",children:Ve?"":fr(Ea(be.worktree))})]}),(()=>{if(Vt)return d.jsx("span",{className:"dot background"});if(X.locked)return d.jsx("span",{className:"rail-glyph rail-lock row-dim",children:d.jsx(ht,{name:"lock",className:"icon-inline"})});if(!be)return d.jsx("span",{className:"dot discovered"});const Rt=Ee||z?null:ZS(X.procs),Mn=X.unseen?" unseen":"",rn=ps(X);return Ve&&!Rt&&rn!=="crashed"&&!z?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:`dot ${rn} rail-main-dot`}),d.jsx("span",{className:"rail-glyph rail-main-strip",children:d.jsx(ht,{name:"plus"})})]}):!Rt||rn!=="crashed"?d.jsx("span",{className:`dot ${rn}${Mn}`}):d.jsx("span",{className:`dot crashed clickable${Mn}`,...Ft(Rt.tip),onClick:cr=>{cr.stopPropagation(),s({a:"activate",id:Se}),s({a:"term-stream",id:Se,stream:Rt.stream})}})})(),n&&d.jsx("span",{className:"rail-say row-dim",children:Bk(X,{needsSetup:Qf(be?J(be):null),path:ge(X),op:Vt})})]},Se);if(!n||!be)return Yt;const yn=(Kt==null?void 0:Kt.key)===Se?Kt.step:null,_t=yn===null?null:un(X)[Math.max(0,yn-1)],gn=!!_t&&yn!==null&&yn>0&&(_t.id==="more"||!!_t.item&&!_t.item.disabled);return d.jsxs("div",{className:"slide","data-row":Se,children:[Yt,_t&&d.jsxs("span",{className:"slide-verb","data-rung":gn?_t.id:void 0,"aria-hidden":"true",children:[d.jsx("span",{className:"slide-word",children:_t.label}),d.jsx(ht,{name:_t.icon})]})]},Se)};return d.jsx("div",{ref:ie,className:Be("rail",n&&"rail-screen",!n&&(Ee||(xe==null?void 0:xe.owner)==="rail"||Y||U)&&"hold",Q&&"quiet",(n||H)&&"pinned",z&&"offline"),style:e!==void 0&&!n?{"--rail-width":`${e}px`}:void 0,onClick:r&&!n&&!H?X=>{X.target instanceof Element&&X.target.closest("button, .rail-gut")||s({a:"toggle-rail"})}:void 0,onDragOver:X=>{var Ht;if(!rk(X.dataTransfer))return;const be=X.target instanceof Element?(Ht=X.target.closest("[data-wt]"))==null?void 0:Ht.dataset.wt:void 0,Ve=be?[...u,...w].find(St=>St.id===be):void 0;if(!Ve||Ee||Ve.id===O)return q.over(null);const Qe=!n&&Sn(Ve)&&Tr(Ve.worktree);q.over({id:Ve.id,land:()=>s(Qe?{a:"open-draft"}:{a:"activate",id:Ve.id})})},onDragLeave:q.leave,onDrop:q.end,children:d.jsx("div",{className:"rail-panel","data-tip":z?zf:void 0,"data-tip-placement":"follow",children:d.jsxs("div",{className:"rail-list",ref:fe,children:[h&&!n&&nn(h),f.map(nn),Ee&&d.jsxs("div",{className:"rail-graft",children:[(()=>{const X=u.find(Qe=>Qe.worktree.id===O&&jf(Qe.worktree)&&!ve(Qe)),be=Ye.filter(Qe=>Qe!==(X==null?void 0:X.worktree.id)),Ve=be.map(Qe=>{var Ht;return((Ht=u.find(St=>St.worktree.id===Qe))==null?void 0:Ht.worktree.title)??Qe}).join(", ");return d.jsxs(Me,{size:"md",tone:"primary",disabled:!X||be.length===0,"data-tip":X?`Merge the checked worktrees into ${X.worktree.title} and remove them`:"Select a worktree to graft onto",onClick:()=>{X&&window.confirm(`Graft ${Ve} onto ${X.worktree.title}?
271
-
272
- Their branches are merged in, then their directories and branches are removed.`)&&(a==null||a.send({t:"graft",targetId:X.worktree.id,sourceIds:be}),gt())},children:["graft ",be.length]})})(),d.jsxs(Me,{size:"md",disabled:!Ye.some(X=>{var be;return(((be=u.find(Ve=>Ve.worktree.id===X))==null?void 0:be.behind)??0)>0}),"data-tip":"Pull main into every selected worktree that's behind",onClick:()=>{for(const X of Ye){const be=u.find(Ve=>Ve.worktree.id===X);((be==null?void 0:be.behind)??0)>0&&ji(a,s,{t:"sync-main",worktreeId:X})}gt()},children:[d.jsx(ht,{name:"pull",className:"icon-inline"})," sync"]}),d.jsx(Me,{size:"md",tone:"danger",disabled:Ye.length===0,"data-tip":"Archive all selected worktrees; their chats and work are kept",onClick:()=>{window.confirm(`Archive ${Ye.length} worktree(s)?
273
-
274
- Their directories and branches go. The chats, commits and any uncommitted changes are kept, and each can be restored.`)&&(Pl(a,s,Ye),gt())},children:"archive…"}),d.jsx(Lt,{icon:"close",label:"Cancel",hint:"esc",onClick:gt})]}),!Ee&&w.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{className:"section-title section-row section-fold rail-disc-head","aria-expanded":v,...Ft(`${w.length} worktree${w.length===1?"":"s"} here that Toyon did not make`,void 0,{placement:o}),onClick:()=>s({a:"toggle-discovered"}),onKeyDown:X=>N(X,v,"toggle-discovered"),children:[d.jsx("span",{className:"rail-gut",children:d.jsx(ht,{name:"caret",className:Be("icon-inline disc-caret",!v&&"shut")})}),d.jsx("span",{className:"rail-label",children:"discovered"})]}),v&&w.map(nn)]}),!Ee&&_.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold rail-disc-head","aria-expanded":x,...Ft(`${_.length} archived worktree${_.length===1?"":"s"}, kept with ${_.length===1?"its chat":"their chats"}`,void 0,{placement:o}),onClick:()=>s({a:"toggle-archived"}),onKeyDown:X=>N(X,x,"toggle-archived"),children:[d.jsx("span",{className:"rail-gut",children:d.jsx(ht,{name:"caret",className:Be("icon-inline disc-caret",!x&&"shut")})}),d.jsx("span",{className:"rail-label",children:"archived"})]}),x&&Ut.shown.map(er),x&&Ut.rest>0&&A&&d.jsxs("button",{type:"button",className:"row row-quiet rail-disc-item rail-arch-item",...Ft("Find an older one by its name, branch or first message",void 0,{placement:o}),onClick:()=>s({a:"open",overlay:{kind:"chats",names:!0}}),children:[d.jsx("span",{className:"rail-gut"}),d.jsxs("span",{className:"branch row-dim",children:[Ut.rest," more"]}),d.jsx("span",{className:"dot"})]})]})]})})})}const gh=["home","chat","preview","changes"],Gq=(e,t)=>gh.indexOf(t)<gh.indexOf(e)?"left":"right";function Vq(e,t,n,r=null){if(e==="home")return t!=="left"||!r||r==="home"?null:r==="preview"&&!n?"chat":r;const o=gh.filter(a=>a!=="preview"||n),s=o.indexOf(e);return s<0?null:o[s+(t==="right"?-1:1)]??null}function Yq({screen:e,tabs:t,fold:n,beside:r=!1,away:o=!1}){const s=lt(),a=gs(),c=Ds(),u=L(pe=>pe.reading),h=L(pe=>pe.typing),f=Iz(),m=Jl(),g=L(pe=>pe.repos),y=zs(),w=Ql(),v=Ia(),_=Dw(),x=Pw(),N=P_(),T=L(pe=>pe.connectFailure),j=L(pe=>pe.recalledAt??pe.heardAt);Ti(N&&j!==null?j:void 0);const C=Sq(T,j),I=C_(),A=bF(x,w,I),M=x.find(pe=>Tr(pe.worktree)),O=e==="home",z=!O&&!v&&!!y&&Tr(y.worktree),B=L(pe=>{var Te;return z&&y?qS(y,(Te=pe.shipping[y.id])==null?void 0:Te.op):null}),H=Aw().length,Y=a.displayName(c.origin),ie=O?(f==null?void 0:f.name)??Y:z?B$:(v==null?void 0:v.title)??(y==null?void 0:y.worktree.title)??(_==null?void 0:_.name)??null,Q=x.filter(pe=>!Tr(pe.worktree)).length,le=Q===0?"no worktrees yet":`${Q} ${Q===1?"worktree":"worktrees"}`,U=L(pe=>pe.sharing),$=O?N?C:U||(f&&H>1?`${Y} · ${le}`:le):v?uT(v):N?C:z?B?ww(B):(f==null?void 0:f.name)??null:y?Bk(y,{needsSetup:Qf(m),path:y.worktree.path,at:fr(Ea(y.worktree))}):_?Bk(_,{needsSetup:!1,path:_.path}):null,q=!O&&!v&&!!y&&ps(y)==="waiting",V=L(pe=>{var Te;return((Te=pe.overlay)==null?void 0:Te.kind)==="projects"&&pe.overlay.form==="pill"})&&!r,W=L(pe=>{var Te;return((Te=pe.overlay)==null?void 0:Te.kind)==="commands"})&&!r,re=d.jsxs("div",{className:"phone-title",children:[O&&(g.length>1||H>1)?d.jsxs("span",{className:"phone-drop phone-switch",children:[d.jsxs(Me,{tone:"chrome",on:V,onClick:()=>s({a:"toggle",overlay:{kind:"projects",form:"pill"}}),children:[d.jsx("span",{className:"phone-name",children:ie}),d.jsx(ht,{name:"caret",className:"icon-inline"})]}),V&&d.jsx(By,{form:"pill",anchored:{margin:6}})]}):d.jsx("span",{className:"phone-name",children:ie}),$&&d.jsx("span",{className:Be("phone-sub",q&&"phone-sub-asks"),children:$})]}),fe=A&&d.jsxs(Me,{size:"md",tone:"primary",onClick:()=>{const pe=xF(x,w,I);if(!pe)return;if(pe.origin===null)return s({a:"activate",id:pe.activate});const Te=a.get(pe.origin);Te&&(Te.store.dispatch({a:"activate",id:pe.activate}),a.activate(pe.origin))},children:[A.n," ",A.tier]});return d.jsxs("div",{className:"phone-bar",children:[d.jsxs("div",{className:"phone-bar-row",children:[!O&&d.jsx(Lt,{icon:"back",label:"Worktrees",tone:"chrome",onClick:()=>s({a:"screen",to:"home"})}),t?d.jsx("div",{className:"phone-tabs",children:t}):re,!t&&fe,O&&M&&d.jsx(Lt,{icon:"plus",label:"New worktree",tone:"chrome",onClick:()=>s({a:"activate",id:M.id})}),d.jsxs("span",{className:"phone-drop",children:[d.jsx(Lt,{icon:"more",label:"Menu",tone:"chrome",on:W,onClick:()=>s({a:"toggle",overlay:{kind:"commands"}})}),W&&d.jsx(w$,{anchored:{flip:"align",margin:6},trailing:d.jsx(Lt,{icon:"close",label:"Close",tone:"chrome",onClick:()=>s({a:"close"})})})]})]}),t&&!n&&d.jsx("div",{className:"phone-title-seat","data-away":u||h||o||void 0,children:d.jsxs("div",{className:"phone-title-strip",children:[re,fe]})})]})}const Ff="toyonDepth",K$="toyonOver",bg=-1;function xg(e){return e.frame!=="phone"||!e.heard&&e.recalledAt===null?null:e.screen!=="home"&&(To(e,e.activeId)!==null||Fo(e)!==null)?1+(e.editor?1:0):0}const q$=(()=>{const e=new Set;return{watch(t){return e.add(t),()=>e.delete(t)},tell(t){for(const n of e)n(t)}}})(),Eg=e=>{const t=e&&typeof e=="object"?e[Ff]:void 0;return typeof t=="number"?t:null},Xq=e=>!!e&&typeof e=="object"&&e[K$]===!0;function Qq(e,t=window,n=ql,r=q$){const o=t.history;let s=Eg(o.state)??bg,a=Eg(o.state)!==null,c=null;const u=()=>{const T=n.open();c&&!T.includes(c)&&(c=null);for(let j=T.length-1;j>=0;j--){const C=T[j];if(C!=null&&C.dismiss&&C!==c)return C}return null};let h=!1;const f=()=>{const T=xg(e.getState());if(T===null||h)return;a||(o.replaceState({[Ff]:bg},""),a=!0);const j=T+(u()?1:0);if(j!==s)if(j>s){for(let C=s+1;C<=j;C++)o.pushState({[Ff]:C,[K$]:C>T},"");s=j}else o.go(-1),h=!0};let m=!1;const g=()=>{m||(m=!0,queueMicrotask(()=>{m=!1,f()}))},y=(T,j)=>{const C=u();if(C){c=C,n.shut(C);return}const I=j===0?"home":T.screen;e.dispatch({a:"screen",to:I})},w=T=>{const j=h;h=!1,s=Eg(T.state)??bg;const C=e.getState(),I=xg(C);if(I===null)return;if(s<0){o.pushState({[Ff]:0},""),s=0,f();return}if(j){f();return}const A=I+(u()?1:0);A!==s&&(A>s?y(C,s):A===0&&C.activeId&&!Xq(T.state)&&e.dispatch({a:"screen",to:"chat"}),f())},v=T=>{if(h){h=!1,f();return}const j=e.getState(),C=xg(j);C===null||C===0||j.screen==="preview"&&!j.editor&&C===1||T.dir==="forward"||y(j,C+(u()?1:0)-1)};t.addEventListener("popstate",w);const _=e.subscribe(f),x=n.watch(g),N=r.watch(v);return f(),()=>{t.removeEventListener("popstate",w),_(),x(),N()}}function Jq({gated:e,active:t,url:n,onTouch:r}){const o=zh(t),s=c6(Ds(),o?n:null,e),a=S.useRef(null),c=S.useRef(r);return c.current=r,S.useEffect(()=>{if(!s)return;const u=new URL(s,location.href).origin,h=f=>{var y,w;const m=(y=a.current)==null?void 0:y.contentWindow;if(!m||f.source!==m||f.origin!==u||!((w=f.data)!=null&&w.__toyon))return;const g=TS(f.data);(g==null?void 0:g.type)==="traversed"?q$.tell({dir:g.dir??null}):(g==null?void 0:g.type)==="touch"?c.current(g):(g==null?void 0:g.type)==="loaded"&&m.postMessage({__toyon:!0,type:"touches",on:!0},u)};return window.addEventListener("message",h),()=>window.removeEventListener("message",h)},[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(ks,{wide:!0,children:d.jsx("p",{className:"status-line",children:Lh(t)})})})}function eZ(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 tZ=Vf(),nZ=!xN(),rZ={current:null};function oZ(){const e=S.useRef(null),t=S.useRef(null),n=S.useRef(null);bz(e),xz(e);const r=lt(),o=L(fe=>fe.screen),s=zs(),a=Ia(),c=Dw(),u=L(fe=>fe.editor),h=L(fe=>fe.left),f=L(fe=>fe.remote),m=Fu(),g=L(fe=>fe.connected),y=L(fe=>fe.heard),w=L(fe=>fe.recalledAt!==null||fe.heard),v=L(fe=>fe.connectFailure),_=Ra(),x=Ds(),N=gs(),[T,j]=S.useState(null),[C,I]=S.useState(null),A=L(fe=>fe.incompatible),M=PN({connected:g,heard:y,standing:w,connectFailure:v,hasToken:x.serving?tZ:!0,projectChord:Bt("project"),title:(s==null?void 0:s.worktree.title)??null,machine:x.serving?null:N.displayName(x.origin)}),O=o!=="home"&&(s!==null||a!==null||c!==null),z=!O&&T!==null&&T!=="home",B=!m&&!a?s:null,H=O||z?B:null,{host:Y}=Rr(),ie=H?WS(H.worktree.id,H.worktree.proxyPort,f,Y):null,Q=o==="preview"&&!H?"chat":o,le=eZ({incompatible:A,serving:x.serving,machine:N.displayName(x.origin),said:M!==null,onWorktree:O,editor:u!==null,tab:Q}),U=le.kind==="home"?"home":le.kind==="tab"?le.tab:null,$=H!==null&&ie!==null,q=q6(nZ?e:rZ,{take:(fe,pe)=>{if(T!==null)return null;const Te=le.kind==="tab"?le.tab:le.kind==="home"?"home":null;if(!Te)return null;const je=Te==="home"?f_({left:h},Date.now()):null;if(pe==="left"&&!je&&fe.closest(".slide"))return null;const de=Vq(Te,pe,B!==null,je);return de?(j(de),(de==="home"||Te==="home"?t:n).current):null},onSettle:fe=>{fe&&T&&I(T)},onEnd:fe=>{fe&&T&&r({a:"screen",to:T}),j(null),I(null)}}),V=(fe,pe)=>d.jsx(Yq,{screen:fe==="home"?"home":"chat",beside:pe,fold:fe!=="chat"||u!==null,away:!pe&&T!==null&&T!=="home",tabs:fe!=="home"&&M===null&&d.jsx(Wu,{fill:!0,segmented:!0,owner:"phone-tabs",label:"worktree",items:re,current:C&&C!=="home"?C:fe,onPick:Te=>r({a:"screen",to:Te})})}),W=le.kind==="updated"?d.jsx(LN,{foreign:le.foreign??void 0}):le.kind==="say"&&M?d.jsx(ks,{wide:!0,children:d.jsx("p",{className:Be("status-line",M.live&&"live-text"),children:M.text})}):le.kind==="editor"&&u?d.jsx(O$,{editor:u,placement:"screen"}):null,re=[{id:"chat",label:"chat"},...H&&ie?[{id:"preview",label:"preview",trail:d.jsx(Lt,{icon:"external",label:"Open in browser",tone:"chrome",onClick:()=>u6(x,ie,ok(x,f))})}]:[],{id:"changes",label:"code"}];return d.jsxs("div",{ref:e,className:"app phone","data-chat-side":"left","data-touch":_||void 0,"data-hover":!_||void 0,children:[d.jsx(NN,{}),d.jsx(CN,{}),d.jsx("div",{className:"phone-screen",children:d.jsxs("div",{className:"center-root",children:[d.jsxs("div",{className:"phone-track",ref:t,children:[(!O||T==="home")&&d.jsxs("div",{className:"phone-face","data-side":O?"left":void 0,children:[V("home",O),!O&&U===null?W:d.jsx(W$,{placement:"screen"})]},"home"),(O||z)&&d.jsxs("div",{className:"phone-face","data-side":z?"right":void 0,children:[V(z&&T?T:Q,z),d.jsxs("div",{className:"phone-track",ref:n,children:[U===null&&d.jsx("div",{className:"phone-face",children:W},"cover"),gh.map(fe=>{if(fe==="home")return null;const pe=z?fe===T:fe===U,Te=fe===T&&!pe;return!pe&&!Te&&!(fe==="preview"&&$)?null:d.jsx("div",{className:"phone-face",hidden:!pe&&!Te,"data-side":Te&&U?Gq(U,fe):void 0,children:fe==="chat"?d.jsx(du,{placement:"screen",archived:a,found:c}):fe==="changes"?d.jsx(aT,{placement:"screen"}):H&&ie?d.jsx(Jq,{gated:ok(x,f),active:H,url:ie,onTouch:q},H.worktree.id):null},fe)})]})]},"worktree")]}),d.jsx(F$,{})]})})]})}function sZ(){try{const e=localStorage.getItem(tt.theme);if(e){const t=JSON.parse(e);if(t!=null&&t.colors&&typeof t.colors.surface0=="string")return t}}catch{}return Pu}function iZ(){if(Vw()!=="phone")return"surface0";try{const e=sessionStorage.getItem(tt.ground);if(e==="surface0"||e==="surface1")return e}catch{}return"surface1"}function Z$(e,t={}){var s,a;const n=document.documentElement;for(const[c,u]of Object.entries(UP(e)))n.style.setProperty(c,u);n.style.colorScheme=e.kind,n.dataset.theme=e.kind;const r=t.ground??iZ();n.dataset.ground=r;const o=Vw()==="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(tt.theme,JSON.stringify(e))}catch{}}function G$(e){const t=dw(e);return{type:"theme",accent:t,accentFg:QP(t)}}function aZ(){var e;return((e=window.matchMedia)==null?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)??!0}const lZ=12*36e5;function cZ(){try{const e=localStorage.getItem(tt.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<lZ?{dark:!t.dark,until:0}:null}catch{return null}}function uZ(e){try{localStorage.setItem(tt.daylight,JSON.stringify(e))}catch{}}function dZ(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 fZ(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 hE(e,t){return t==="reading"?"Reading the release notes":`No release notes could be read from Toyon ${e}.`}function hZ(){const e=Rr(),t=L(s=>s.version),[n,r]=S.useState(void 0);S.useEffect(()=>{let s=!0;return d4(e).then(a=>{s&&r(a)}),()=>{s=!1}},[e]);const o=Vu(n??"",{keepHtml:!0});return n?d.jsx("div",{className:"notes-page",children:d.jsx(Fy,{html:o})}):d.jsx(ks,{wide:!0,children:d.jsx("p",{className:"status-line",children:n===void 0?d.jsx("span",{className:"live-text",children:hE(t,"reading")}):hE(t,"missing")})})}function Uk(e,t){return[{id:"copy-name",label:"copy name",detail:e,onClick:()=>tn(e)},{id:"copy-value",label:"copy value",detail:t,onClick:()=>tn(t)}]}function Hk(e){return[{id:"copy-value",label:"copy value",detail:e,onClick:()=>tn(e)}]}function pZ(e,t,{sock:n},r){return t?Bn([[{id:"source",label:"open source",onClick:r}],Bo(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id,path:t}),fo(n)),[{id:"copy-path",label:"copy path",onClick:()=>tn(t)}]]):[]}function Mu(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 mZ(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());return t?t[1].length===4||t[1].length===8:!1}function pE([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 V$(e,t){if(mZ(e))return null;const n=Mu(e);if(!n)return null;const r=Mu(t);if(!r)return null;const[o,s]=[pE(n),pE(r)];return`${((Math.max(o,s)+.05)/(Math.min(o,s)+.05)).toFixed(2)}:1`}function gZ({worktreeId:e,height:t,full:n,onToggleFull:r,onDragStart:o}){const s=lt(),a=Je(),c=L(h=>Wr(h,e).design);S.useEffect(()=>{c||a==null||a.send({t:"design-scan",worktreeId:e})},[c,e,a]),S.useEffect(()=>()=>an.post(e,{type:"highlight-clear"}),[e]);const u={outline:h=>an.post(e,h),clear:()=>an.post(e,{type:"highlight-clear"}),open:h=>Rn({dispatch:s},{worktreeId:e,path:h})};return d.jsx(zy,{kind:"design",className:Be("design-pane",n&&"full"),height:n?void 0:t,resizable:!n,onDragStart:o,title:c?d.jsx("span",{children:vZ(c)}):void 0,onClose:()=>s({a:"toggle-design"}),closeHint:Bt("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(ht,{name:"reload",className:"icon-inline"})," rescan"]}),children:c?d.jsxs("div",{className:"design-body",style:yZ,onMouseLeave:u.clear,children:[c.tokens.length===0&&c.literals.length>0?d.jsx(NZ,{literals:c.literals,outline:u.outline,clear:u.clear}):d.jsx(SZ,{tokens:c.tokens,coverage:c.coverage,outline:u.outline,clear:u.clear}),d.jsx(MZ,{index:c,outline:u.outline,clear:u.clear,onOpen:u.open}),d.jsx(LZ,{index:c,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 kZ=720,wZ=132,yZ={"--design-column":`${kZ}px`,"--design-cell":`${wZ}px`};function vZ(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 Il=e=>`${e} use${e===1?"":"s"}`;function pp({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 kh({children:e}){return d.jsx("p",{className:"design-gap",children:e})}const bZ=[{kind:"font",label:"type"},{kind:"color",label:"color"},{kind:"length",label:"size & radius"},{kind:"shadow",label:"shadow"},{kind:"other",label:"computed"}];function xZ(e){return e.find(t=>t.kind==="color"&&Mu(t.resolved??t.value)!==null)}function EZ(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 SZ({tokens:e,coverage:t,outline:n,clear:r}){const o=xZ(e),s=o&&(o.resolved??o.value),a=new Map;for(const u of e){const h=(u.resolved??u.value).trim().toLowerCase();a.set(h,[...a.get(h)??[],u.name])}const c=u=>(a.get((u.resolved??u.value).trim().toLowerCase())??[]).filter(h=>h!==u.name);return d.jsx(pp,{title:"Tokens",children:e.length===0?d.jsx(kh,{children:EZ(t)}):bZ.map(({kind:u,label:h})=>{const f=e.filter(g=>g.kind===u);if(f.length===0)return null;const m=X$(f.map(g=>g.value));return d.jsxs("div",{className:"design-group",children:[u!=="font"&&d.jsx("span",{className:"design-group-name",children:h}),u==="font"?d.jsx(Q$,{groups:AZ(f),outline:n,clear:r}):d.jsx("div",{className:"design-breakout",style:Y$(f.length),children:d.jsx("div",{className:"design-grid",children:f.map(g=>{const y=g.resolved??g.value,w=g.kind==="color"&&s?V$(y,s):null;return d.jsx(J$,{kind:g.kind,name:g.name,lines:g.resolved?[g.value,g.resolved]:[g.value],actual:y,ratio:w,largest:m,tipText:RZ(g,w,o,c(g)),menu:()=>Uk(g.name,y),outline:n,clear:r},g.name)})})})]},u)})})}const _Z=[{role:"color",kind:"color",label:"color"},{role:"radius",kind:"length",label:"radius"},{role:"shadow",kind:"shadow",label:"shadow"}];function NZ({literals:e,outline:t,clear:n}){const r=e.find(s=>s.ground&&Mu(s.value)!==null),o=IZ(e);return d.jsxs(pp,{title:"Values",note:"written out in the rules; no custom properties",children:[o.length>0&&d.jsx("div",{className:"design-group",children:d.jsx(Q$,{groups:o,outline:t,clear:n})}),_Z.map(({role:s,kind:a,label:c})=>{const u=e.filter(f=>f.role===s);if(u.length===0)return null;const h=X$(u.map(f=>f.value));return d.jsxs("div",{className:"design-group",children:[d.jsx("span",{className:"design-group-name",children:c}),d.jsx("div",{className:"design-breakout",style:Y$(u.length),children:d.jsx("div",{className:"design-grid",children:u.map(f=>{const m=a==="color"&&r?V$(f.value,r.value):null;return d.jsx(J$,{kind:a,name:f.value,lines:[Il(f.uses)],actual:f.value,ratio:m,largest:h,tipText:OZ(f,m,r),menu:()=>Hk(f.value),outline:t,clear:n},f.value)})})})]},s)})]})}function Y$(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 X$(e){return e.reduce((t,n)=>Math.max(t,Math.abs(Number.parseFloat(n))||0),0)}const TZ=["color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color","outline-color"];function jZ(e,t){if(!e)return[];const n=getComputedStyle(e);return t.map(r=>[r,n.getPropertyValue(r)])}const Wk=e=>(e.split(",")[0]??e).replace(/["']/g,"").trim();function $Z(e){const t=/^[1-9]00\s+([\d.]+)px(?:\s*\/\s*([\d.]+)(px)?)?\s+(.+)$/.exec(e.trim());if(!t)return{family:Wk(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:Wk(t[4]??""),size:n,lead:o}}function Sg(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 CZ(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 AZ(e){const t=e.map(n=>({token:n,actual:n.resolved??n.value,...$Z(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}
275
- ${o.actual}`:void 0,menu:()=>o?Uk(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}
276
- ${s.actual}`,menu:()=>Uk(s.token.name,s.actual)}))}})}function IZ(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(c=>c.value===o),a=o==="initial"?"default face":Wk(o);return{family:a,stack:o,name:s?Il(s.uses):void 0,label:a,tipText:s?`${s.value}
277
- ${Il(s.uses)}: ${s.selectors.join(", ")}`:void 0,menu:()=>s?Hk(s.value):[],rows:n.filter(c=>(c.family??"initial")===o).sort((c,u)=>Sg(u.value)-Sg(c.value)).map(c=>{const u=Sg(c.value),h=CZ(c.lead,u),f=c.value.endsWith("px")?`${u}`:c.value;return{key:`${c.value}/${c.lead??""}`,sample:`${a} ${f}${h===null?"":`/${h}`}`,style:{fontFamily:o,fontSize:c.value,lineHeight:c.lead},name:Il(c.uses),label:c.value,tipText:`${c.value}${c.lead?` / ${c.lead}`:""}
278
- ${Il(c.uses)}: ${c.selectors.join(", ")}`,menu:()=>Hk(c.value)}})}})}function Q$({groups:e,outline:t,clear:n}){const r=(s,a,c)=>t({type:"highlight-computed",props:jZ(s.currentTarget.querySelector(".design-face-sample"),a?["font-family","font-size","line-height"]:["font-family"]),match:"all",label:c}),o=vn("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?Ft(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:c=>r(c,!0,a.label),onMouseLeave:n,...o.contextMenu(a.menu),...Ft(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 J$({kind:e,name:t,lines:n,actual:r,ratio:o,largest:s,tipText:a,menu:c,outline:u,clear:h}){const f=e==="color"&&Mu(r)!==null,m=e==="length"?Number.parseFloat(r):Number.NaN,g=vn("design");return d.jsxs("div",{className:"design-cell","data-kind":e,...g.contextMenu(c),onMouseEnter:f?y=>{const w=y.currentTarget.querySelector(".design-fill"),v=w?getComputedStyle(w).backgroundColor:"";u({type:"highlight-computed",props:TZ.map(_=>[_,v]),match:"any",label:t})}:void 0,onMouseLeave:f?h:void 0,...Ft(a),children:[e==="color"&&d.jsx("div",{className:"design-sample",children:f&&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(m)&&s>0&&d.jsx("span",{className:"design-scale",style:{width:`${Math.max(2,Math.abs(m)/s*100)}%`}})]})]})}function RZ(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(`
279
- `)}function OZ(e,t,n){const r=[e.value,`${Il(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(`
280
- `)}function eC({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 MZ({index:e,outline:t,clear:n,onOpen:r}){const{components:o,typed:s}=e;if(o.length===0)return null;const a=o.filter(h=>h.imports>=2),c=o.filter(h=>h.imports<2),u=h=>d.jsx(tC,{count:h.imports,name:h.name,path:h.path,onEnter:()=>t({type:"highlight-file",path:h.path,ranges:null}),onLeave:n,onOpen:()=>r(h.path),children:h.variants.length>0&&d.jsx("span",{className:"design-variants",children:h.variants.map(f=>d.jsxs("span",{className:"design-variant",children:[f.prop,": ",f.values.join(" · ")]},f.prop))})},`${h.path}:${h.name}`);return d.jsxs(pp,{title:"Components",note:`${a.length} reused of ${o.length}`,children:[!s&&d.jsx(kh,{children:"No TypeScript in this project, so the values each prop allows are not listed."}),d.jsx(eC,{shared:a.map(u),rest:c.map(u)})]})}function LZ({index:e,outline:t,clear:n,onOpen:r}){const{classes:o,coverage:s}=e,a=o.filter(g=>g.uses>0),c=o.filter(g=>g.uses>=2),u=o.filter(g=>g.uses<2),h=c.filter(g=>g.unwrapped).length,f=o.length?`${c.length} reused of ${o.length}`+(h?`, ${h} with no component of their name`:""):void 0,m=g=>d.jsx(PZ,{cls:g,outline:t,clear:n,onOpen:r},g.name);return d.jsx(pp,{title:"Classes",note:f,children:o.length===0?d.jsx(kh,{children:"No stylesheet in this project defines a class. Utility-first CSS generates its own."}):a.length===0?d.jsx(kh,{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(eC,{shared:c.map(m),rest:u.map(m)})})}function PZ({cls:e,outline:t,clear:n,onOpen:r}){return d.jsx(tC,{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 tC({count:e,name:t,path:n,onEnter:r,onLeave:o,onOpen:s,children:a}){const c=zs(),u=Je();lt();const h=vn("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,...h.contextMenu(()=>c?pZ({id:c.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 DZ({worktreeId:e,procs:t,borrowed:n,login:r,current:o,onRestart:s}){const a=Je();lt();const c={sock:a},u=(f,m)=>d.jsx(Lt,{icon:"reload",label:m,onClick:()=>s(f)}),h={id:Ls,label:"login",tip:Ft("The agent's login; it closes once you are in",void 0,{placement:"top"}),trail:u(Ls,"Run the login again")};return r&&o===Ls?[h]:[{id:Do,label:"shell",tip:Ft("A shell in this worktree",void 0,{placement:"top"}),menu:()=>ET(e,c),trail:u(Do,"Restart the shell")},...r?[h]:[],...t.map(f=>({id:f.name,label:f.name,lead:d.jsx("span",{className:`dot ${f.status}`}),tip:Ft(V4(f.status),void 0,{placement:"top",dot:f.status,name:f.name,detail:f.command,aside:[`:${f.port}`]}),menu:()=>sy(f,e,c),trail:u(f.name,`Restart ${f.name}`)})),...n.map(f=>({id:f,label:f,lead:d.jsx("span",{className:"dot borrowed"}),tip:Ft(`${f} runs on main for every worktree; this one reaches it at its usual address`,void 0,{placement:"top"})}))]}const zZ=S.lazy(()=>Pk(()=>import("./XTerm-DNFNsoHC.js"),__vite__mapDeps([3,4]))),FZ=[];function BZ({worktreeId:e,opened:t,height:n,onDragStart:r}){const o=lt(),s=Je(),a=Bh(),c=L(B=>B.connected),u=L(B=>B.focusTerm),h=zs(),f=(h==null?void 0:h.procs)??[],m=(h==null?void 0:h.borrowed)??FZ,g=(h==null?void 0:h.login)??!1,y=Mt(e,"termStream"),w=L(B=>{var H;return((H=B.termRun)==null?void 0:H.id)===e&&y===Do?B.termRun.command:null}),[v,_]=S.useState(null),x=m.includes(y);S.useEffect(()=>{y===Do||(y===Ls?g:f.some(H=>H.name===y)||m.includes(y))||o({a:"term-stream",id:e,stream:Do})},[f,m,g,y,e,o]);const N=B=>{B!==y&&(_(null),o({a:"term-stream",id:e,stream:B}))},T=S.useRef(!1),[j,C]=S.useState(0),I=B=>{B===Do&&B===y&&(T.current=!0),s==null||s.send({t:"term-restart",worktreeId:e,stream:B}),B===Ls&&B===y&&(_(null),C(H=>H+1))},A=(B,H)=>{if(B)return _(null);if(T.current){T.current=!1,C(Y=>Y+1);return}_({code:H})},M=DZ({worktreeId:e,procs:f,borrowed:m,login:g,current:y,onRestart:I}),O=S.useRef(!t),z=!O.current;return S.useEffect(()=>{O.current=!1},[]),d.jsxs(zy,{kind:"terminal",className:"term-pane",height:n,onDragStart:r,tabs:{items:M,current:y,onPick:N,font:"mono",owner:"terminal",label:"terminal streams"},onClose:()=>o({a:"toggle-terminal"}),closeHint:Bt("terminal"),children:[d.jsxs("div",{className:"term-body",children:[x&&d.jsx(xu,{pane:!0,title:`${y} runs on main`,body:"Every worktree reaches main's copy until its own changes touch it, or until asked.",action:d.jsx(Me,{variant:"outline",onClick:()=>s==null?void 0:s.send({t:"own-procs",worktreeId:e,names:[y]}),children:"run it here"})}),d.jsx(Yw,{pane:!0,children:d.jsx(S.Suspense,{fallback:d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"loading terminal"})}),children:d.jsx(zZ,{worktreeId:e,stream:y,theme:a,sock:s,connected:c,focusOnMount:z,focusReq:u,onAlive:A,run:w,onRan:()=>o({a:"term-ran"}),onEscape:()=>o({a:"toggle-terminal"})},`${y}:${j}`)})})]}),v!==null&&!x&&d.jsx(xu,{pane:!0,title:y===Do?"the shell exited":y===Ls?"the login did not finish":`${y} exited`,body:v.code===void 0?void 0:`exit code ${v.code}`,action:d.jsx(Me,{variant:"outline",onClick:()=>I(y),children:"restart"})})]})}function UZ(e){return e==="reserved"?"checking out a fresh worktree":e==="warming"?"copying dependencies and running setup":"starting dev servers"}const HZ="preview off; it starts when the agent writes a file";function WZ({worktree:e,log:t}){const n=Je(),r=lt(),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"),c=L(v=>v.clientId),u=Nu(e,"setup"),h=u&&u.status!=="terminated"?u:null,f=Ti(ny(h??void 0)?h==null?void 0:h.since:void 0),m=!!e.worktree.parked&&o.length===0,g=()=>n==null?void 0:n.send({t:"preview-start",worktreeId:e.id}),y=h&&(h.status==="running"||h.status==="detached"),w=()=>n==null?void 0:n.send({t:"fix-preview",worktreeId:e.id,clientId:c});return d.jsxs(ks,{wide:!0,children:[o.length===0?d.jsx("div",{className:"status-line",children:h?d.jsx("span",{className:"live-text","data-tip":lk[h.status],children:nh("setup",h,f)}):m?HZ:d.jsx("span",{className:"live-text",children:UZ(e.worktree.phase)})}):d.jsx("ul",{className:"boot-procs",children:o.map(v=>d.jsxs("li",{className:Be("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:KZ(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))}),m&&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":oT("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(`
281
- `)})]})}function KZ(e){switch(e.status){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 qZ(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 mE(e){if(!e)return"/";try{const t=new URL(e);return`${t.pathname}${t.search}${t.hash}`}catch{return"/"}}function ZZ(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 GZ({active:e}){const t=lt(),n=Je(),r=Jl(),o=L(c=>c.home),s=e.worktree.title,a=()=>{r!=null&&r.made&&(t({a:"new-project",v:{...Ph({mode:r.made==="git"?"init":"create",name:r.name,parent:CT(r.path,o)??r.path}),phase:"unmaking",repoId:r.id}}),t({a:"move-box",from:e.worktree.id,to:Ul}),n==null||n.send({t:"unmake-repo",repoId:r.id}))};return d.jsx(ks,{anchor:"line",foot:d.jsx("div",{className:"composer view-foot",children:d.jsx(uu,{active:e,greenfield:!0})}),children:d.jsx("p",{className:"form-title",children:r!=null&&r.made?d.jsx(Me,{variant:"inline",onClick:a,...Ft("Rename or move this project"),children:s}):s})})}function VZ({pending:e}){const t=lt(),n=Je(),r=!!e.error,o=()=>{n==null||n.send({t:"cancel-import",id:e.id}),t({a:"watch-import",id:null})},s=S.useRef(null);return S.useEffect(()=>{var a;return(a=s.current)==null?void 0:a.scrollTo({top:s.current.scrollHeight})},[e.lines.length]),d.jsxs(ks,{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,c)=>d.jsx("div",{children:a},c))}),d.jsx("div",{className:"status-actions",children:d.jsx(Me,{variant:"outline",size:"lg",onClick:o,children:r?"dismiss":"stop"})})]})}const YZ=150,XZ=/^[^\s@]+@[^\s@]+$/,QZ=14;function JZ({project:e}){var q;const t=lt(),n=Je(),r=L(V=>V.repos),o=L(V=>V.home),s=L(V=>V.folderDialog),a=L(V=>V.gitIdentity),c=L(V=>V.choosingFolder),u=L(V=>V.chosenFolder),h=L(V=>V.paths),[f,m]=S.useState({name:"",email:""}),[g,y]=S.useState(null),w=S.useRef(null),{mode:v,name:_,parent:x}=e,N=v==="clone",T=v==="init",j=e.phase==="editing",C=_.trim(),I=T||!C?null:gu(_),A=!T&&C&&!I?$T(x,C):null,M=mk(x,o),O=A!==null&&h.query===A&&((q=h.target)==null?void 0:q.exists)===!0,z=!a&&!N,B=!z||f.name.trim()!==""&&XZ.test(f.email.trim()),H=j?g?"the folder you chose is already a project: open it, or choose another":!T&&!C?"name the project first":I??(O?`${M} already has a folder called ${C}`:B?null:"git needs your name and email first"):null;S.useEffect(()=>{if(!A)return;const V=setTimeout(()=>n==null?void 0:n.send({t:"browse-path",path:A}),YZ);return()=>clearTimeout(V)},[A,n]),at([e.phase],()=>{var V;e.phase==="editing"&&((V=w.current)==null||V.focus())}),at([e.error],()=>{e.error&&t({a:"notice",id:Ul,text:e.error})});const Y={sock:n,dispatch:t},ie=()=>{H||!j||(t({a:"new-project-set",v:{phase:"creating"}}),Tu(Y,{t:"create-repo",mode:v,parent:x.trim(),name:C,...N&&e.url?{url:e.url,...e.branch?{branch:e.branch}:{}}:{},...z?{identity:{name:f.name.trim(),email:f.email.trim()}}:{}}))},Q=V=>{const W=r.find(re=>re.path===Zl(V,o));W?t({a:"activate-repo",id:W.id}):Tu(Y,{t:"register-repo",path:V})},le=V=>{const W=ay(V);t({a:"new-project-set",v:{mode:"init",parent:W.parent,name:W.name}})},U=V=>{s?(t({a:"choosing-folder",v:V}),n==null||n.send({t:"choose-folder",start:x,purpose:V})):t(V==="location"?{a:"open",overlay:{kind:"choose-folder"}}:{a:"open",overlay:{kind:"projects",form:"disk"}})};at([u==null?void 0:u.seq],()=>{var W,re;if(!c||!u)return;t({a:"choosing-folder",v:!1});const V=u.folder;if(!V){(W=w.current)==null||W.focus();return}if(c==="open"){V.kind==="project"?Q(V.path):z?le(V.path):ST(Y,V.path);return}if(y(V.kind==="project"?V.path:null),V.kind!=="project"){if(V.kind==="empty"&&!N){le(V.path);return}t({a:"new-project-set",v:{mode:N?"clone":"create",parent:V.path}}),(re=w.current)==null||re.focus()}});const $=T?"the folder you chose becomes the project":g?null:O?`${M} already has a folder called ${C}`:I;return d.jsxs(ks,{anchor:"line",foot:d.jsx("div",{className:"composer view-foot",children:d.jsx(uu,{active:null,project:{name:C,why:H,busy:!j,create:ie}})}),children:[N&&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:_}):d.jsx(zo,{ref:w,bare:!0,font:"lead",className:"new-project-field",autoFocus:!0,spellCheck:!1,autoComplete:"off",value:_,placeholder:"Project name",disabled:!j,style:{width:`${Math.max(_.length+1,QZ)}ch`},onChange:V=>t({a:"new-project-set",v:{name:V.target.value}}),onKeyDown:V=>{V.key==="Enter"&&(V.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",...Ft(x),children:M}),d.jsx(Lt,{icon:"folder",label:s?"Choose in Finder":"Choose a folder",className:"new-project-folder",on:c==="location",disabled:!j,onClick:()=>U("location")})]})]}),$&&d.jsx("p",{className:"hint",children:$}),g&&d.jsxs("p",{className:"hint",children:["the folder you chose is already a project:"," ",d.jsx(Me,{variant:"inline",autoFocus:!0,onClick:()=>Q(g),children:"open it"}),", or choose another"]}),z&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"new-project-identity",children:[d.jsx(zo,{size:"md",font:"ui",rule:!0,value:f.name,placeholder:"Your name",autoComplete:"name",disabled:!j,onChange:V=>m({...f,name:V.target.value})}),d.jsx(zo,{size:"md",font:"ui",rule:!0,type:"email",value:f.email,placeholder:"Email",autoComplete:"email",disabled:!j,onChange:V=>m({...f,email:V.target.value})})]}),d.jsx("p",{className:"hint",children:"git labels the work you save with these, and asks only once"})]}),!N&&j&&d.jsx(Me,{tone:"quiet",className:"new-project-open",onClick:()=>U("open"),children:"or open a folder you already have"})]})}function El({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 eG(e,t,n){const r=[n.envUrl?`\`${n.envUrl.name}\` in \`${n.envUrl.file}\``:null,n.compose?`the compose stack in \`${n.compose}\``:null].filter(Boolean).join(" and ");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 ${r}: 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, which never runs setup) and \`TOYON_ROOT\` (the main checkout). Edit \`${t}\` so that:`,'- `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 running commands point at it, with the base database in the main checkout: put the URL in front of the command in `run`, or in a profile's `env`, named `<db>${TOYON_WORKTREE:+_$TOYON_WORKTREE}`. `setup` does not see what `run` sets, so a migration step in `setup` needs the URL in front of it too.",'- a database container the worktrees share (each with its own database inside it) is marked `{ "cmd": ..., "from": "trunk", "paths": [] }` in `run`, so the main checkout runs it once for everyone.',"","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(`
282
- `)}function tG(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(`
283
- `)}let nG=1;const _g=(e,t,n=!1)=>({id:nG++,name:e,cmd:t,shared:n}),rG=[{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 oG({repo:e,onClose:t}){const n=Je(),r=On(),o=L(de=>de.clientId),s=L(de=>de.rows.find(J=>{var te;return Sn(J)&&J.id===((te=Hl(de,e.id))==null?void 0:te.id)})??null),a=L(de=>{var J;return((J=Hl(de,e.id))==null?void 0:J.id)??null});S.useEffect(()=>{if(!t)return;const de=J=>J.key==="Escape"&&t();return window.addEventListener("keydown",de),()=>window.removeEventListener("keydown",de)},[t]);const[c]=S.useState(()=>Object.keys(e.config.run).length>0),[u,h]=S.useState(()=>{const de=Object.entries(e.config.run).map(([J,te])=>_g(J,ME(te),KA(te)));return de.length>0?de:[_g("web","")]}),[f,m]=S.useState(()=>(e.config.setup??[]).join(`
284
- `)),[g,y]=S.useState(()=>(e.config.teardown??[]).join(`
285
- `)),[w,v]=S.useState(()=>e.config.check??""),[_,x]=S.useState(()=>_i(e.config).land),[N,T]=S.useState(()=>_i(e.config).automerge),[j,C]=S.useState(()=>_i(e.config).merge??"default"),[I,A]=S.useState(()=>GA(e.configFile)),M=VA(e.configFile,I),O=!!e.remote&&_==="pr",z=u.length>1,B=u.some(de=>de.name.trim()&&de.cmd.trim()),Y=!!s&&!t&&!c&&!B,ie=(de,J)=>h(u.map((te,ve)=>ve===de?{...te,...J}:te)),Q=de=>de.split(`
286
- `).map(J=>J.trim()).filter(Boolean),le=()=>Q(f),U=()=>Q(g),$=()=>{const{check:de,land:J,teardown:te,...ve}=e.config,ce=e.remote?_:Cg,ae=j==="default"||ce!=="pr"&&j===Ag?void 0:j,xe={...ce!==Cg?{route:ce}:{},...ce==="pr"&&N?{automerge:!0}:{},...ae?{method:ae}:{}};return{...ve,setup:le(),...U().length>0?{teardown:U()}:{},...w.trim()?{check:w.trim()}:{},...Object.keys(xe).length>0?{land:xe}:{}}},q=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...$(),run:Object.fromEntries(u.filter(de=>de.name.trim()&&de.cmd.trim()).map((de,J)=>[de.name.trim(),de.shared&&J>0?{cmd:de.cmd.trim(),from:"trunk"}:de.cmd.trim()]))},kind:I}),t==null||t()},V=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...$(),run:{}},kind:I}),t==null||t()},W=()=>n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:tG(e,M)}),re=e.services,fe=[f,g,...u.map(de=>de.cmd)].some(de=>de.includes("TOYON_WORKTREE"))||qA(e.config),pe=re?[re.envUrl?`the database at ${re.envUrl.name} in ${re.envUrl.file}`:null,re.compose?`the stack in ${re.compose}`:null].filter(Boolean).join(" and "):"",Te=()=>re&&(n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:eG(e,M,re)})),je=(de,J)=>d.jsxs("div",{className:"setup-proc",children:[z&&d.jsx(zo,{size:"md",rule:!0,className:"setup-name",value:de.name,placeholder:"name",...Ft("Process name, shown in the status bar"),onChange:te=>ie(J,{name:te.target.value})}),d.jsx(zo,{size:"md",rule:!0,className:"setup-cmd",value:de.cmd,placeholder:"npm run dev",onChange:te=>ie(J,{cmd:te.target.value})}),z&&d.jsx(Lt,{icon:"close",label:"Remove",onClick:()=>h(u.filter((te,ve)=>ve!==J))}),z&&J>0&&d.jsx(A$,{className:"setup-shared",checked:de.shared,onChange:te=>ie(J,{shared:te.target.checked}),tip:"Main runs it once for every worktree; a worktree whose changes touch it runs its own",children:"shared from main"})]},de.id);return d.jsxs(ks,{children:[d.jsxs("p",{className:"form-title",children:["how does ",e.name," start?"]}),re&&!fe&&d.jsxs("p",{className:"hint setup-shared-note",children:["Worktrees will share ",pe,", migrations included."," ",d.jsx(Me,{tone:"quiet",disabled:!s,onClick:Te,children:"ask the agent to keep them apart"})]}),d.jsx(El,{label:"install",hint:"once per new worktree; one command per line",children:d.jsx(_u,{size:"md",rule:!0,rows:Math.max(1,f.split(`
287
- `).length),value:f,placeholder:"bun install",onChange:de=>m(de.target.value)})}),d.jsx(El,{label:"remove",hint:"once when a worktree goes, before its directory does; one command per line",children:d.jsx(_u,{size:"md",rule:!0,rows:Math.max(1,g.split(`
288
- `).length),value:g,placeholder:'dropdb --if-exists "app_$TOYON_WORKTREE"',onChange:de=>y(de.target.value)})}),d.jsx(El,{label:"check",hint:"runs after each of the agent's turns; the work lands only when it passes",children:d.jsx(zo,{size:"md",rule:!0,value:w,placeholder:"bun run check",onChange:de=>v(de.target.value)})}),e.remote&&d.jsx(El,{label:"land",hint:"where a worktree's finished work goes; one way per repo",children:d.jsxs("div",{className:"setup-land",children:[d.jsx(Si,{value:_,options:cI.map(de=>({id:de.id,label:de.name,description:de.description})),onChange:x,hint:"where the work goes",placeholder:"where work lands"}),O&&d.jsx(Si,{value:N?"github":"you",options:dI.map(de=>({id:de.id,label:de.name,description:de.description})),onChange:de=>T(de==="github"),hint:"who merges the pull request",placeholder:"who merges it"})]})}),d.jsx(El,{label:"merge",hint:O?"how GitHub merges the pull request; only what the repo allows":"how the commits arrive on main",children:d.jsx(Si,{value:j==="default"&&!O?Ag:j,options:[...O?[{id:"default",label:"what the repo allows",description:"the repo's allowed methods on GitHub: squash, else a merge commit, else rebase"}]:[],...uI.map(de=>({id:de.id,label:de.name,description:de.description}))],onChange:C,hint:"how the commits arrive on main",placeholder:"how the commits arrive"})}),d.jsx(El,{label:"start",hint:d.jsxs(d.Fragment,{children:["must listen on ",d.jsx("code",{...Ft("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",...Ft(`open ${e.guess} in the editor pane`),onClick:()=>ya(r,n,a,e.guess??"",1),children:e.guess})]})]}),children:u[0]&&je(u[0],0)}),u.slice(1).map((de,J)=>d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsx("div",{className:"form-control",children:je(de,J+1)})]},de.id)),d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsxs(Me,{tone:"quiet",onClick:()=>h([...u,_g("","")]),children:[d.jsx(ht,{name:"plus",className:"icon-inline"})," another process"]})]}),d.jsxs("div",{className:"form-knobs",children:[d.jsx(Si,{value:I,options:rG,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:M}),t&&d.jsx(Me,{onClick:t,children:"cancel"}),(!c||t)&&d.jsx(Me,{...Ft("This project has no dev server: chat, changes and the terminal work, the preview stays empty"),onClick:V,children:"no dev server"}),Y&&s?d.jsx(Me,{variant:"outline",size:"lg",disabled:s.agent!=="idle",...Ft("The agent reads the repo and writes the settings file; the daemon picks it up as soon as it lands"),onClick:W,children:"let the agent work it out"}):d.jsxs(Me,{variant:"outline",size:"lg",disabled:!B,...t?Ft("Restarts every worktree of this repo. Profiles and other keys in the file are kept."):{},onClick:q,children:[t?"save + restart":"start"," ",d.jsx(ht,{name:"forward",className:"icon-inline"})]})]})]})}function sG(e){return`${Math.round(e.w)} × ${Math.round(e.h)}`}function iG(e){return e.w>0&&e.h>0}function aG(e,t,n){S.useEffect(()=>{if(!e||!t){n(null);return}const r=new ResizeObserver(o=>{var c;const s=(c=o[o.length-1])==null?void 0:c.contentRect;if(!s)return;const a={w:s.width,h:s.height};n(iG(a)?sG(a):null)});return r.observe(e),()=>{r.disconnect(),n(null)}},[e,t,n])}const lG=1500,cG={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};class uG{constructor(t,n,r=cG){Tt(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=Ab(r));const s=Ah(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)},lG)}title(t,n){const r=this.frame(t);r.title=Ab(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 dG=Vf(),fG=2*6e4;function gE(e){e==null||e.setAttribute("src",e.src)}const hG=8e3;function pG(e,t){try{const n=new URL(e,t);return n.origin===new URL(t).origin?n.href:null}catch{return null}}function mG({onRoot:e}){const t=S.useRef(null),n=S.useCallback(se=>{t.current=se,e(se)},[e]),r=lt(),o=On(),s=Je(),a=S.useRef(s);a.current=s;const[c]=S.useState(()=>new uG((se,Ne,rt)=>{var yt,jt;(yt=a.current)==null||yt.send({t:"visit",worktreeId:se,path:Ne,title:rt}),XS((jt=o.getState().local[se])==null?void 0:jt.pages)&&an.post(se,{type:"links"})},(se,Ne,rt)=>{var yt;return(yt=a.current)==null?void 0:yt.send({t:"page-title",worktreeId:se,path:Ne,title:rt})}));S.useEffect(()=>()=>c.dispose(),[c]);const u=z_(),h=Ql(),f=zs(),m=L(se=>se.connected),g=L(se=>se.heard),y=L(se=>se.recalledAt!==null),w=L(se=>se.connectFailure),v=L(se=>se.remote),{host:_}=Rr(),x=Ds(),N=gs(),T=L(se=>se.editor),j=B_(),C=Oz(),I=L(se=>se.notesPage),A=zu(),M=L(se=>se.layout.term)&&!A,O=L(se=>se.focusTerm),z=S.useRef(!1),B=S.useRef(O),H=!z.current||O!==B.current;S.useEffect(()=>{z.current=M&&!!h,B.current=O});const Y=Fu(),ie=L(se=>se.layout.design)&&!A&&!Y,Q=L(se=>se.reloadReq),le=Bh(),U=S.useRef(le);U.current=le;const $=L(se=>se.zen),q=L(se=>{var Ne;return((Ne=se.dragFiles)==null?void 0:Ne.at)==="centre"}),V=S.useRef($);V.current=$;const W=Mt(h,"log"),re=L(se=>se.incompatible),fe=Lz(),pe=L(se=>{var Ne;return((Ne=se.overlay)==null?void 0:Ne.kind)==="setup"?se.repos.find(rt=>rt.id===se.overlay.repoId)??null:null}),Te=(f==null?void 0:f.worktree.empty)===!0,je=os(f==null?void 0:f.agent),de=fe&&!Te&&!je?fe:null,J=de??pe,te=L(se=>se.pending.find(Ne=>Ne.id===se.activeImportId)??null),[ve,ce]=S.useState([]),ae=S.useMemo(()=>ve.map(se=>se.id),[ve]),xe=S.useRef(new Map),Re=S.useRef(new Map),[ge,Ee]=S.useState([]),We=S.useRef(new Set),Ye=S.useRef(new Set),ln=S.useRef(se=>gE(xe.current.get(se)));S.useEffect(()=>{an.post=(se,Ne)=>{var rt,yt;if(Ne.type==="reload"&&We.current.has(se))return ln.current(se);(yt=(rt=xe.current.get(se))==null?void 0:rt.contentWindow)==null||yt.postMessage({__toyon:!0,...Ne},Re.current.get(se)??"*")},an.broadcast=se=>{var Ne;for(const[rt,yt]of xe.current)(Ne=yt.contentWindow)==null||Ne.postMessage({__toyon:!0,...se},Re.current.get(rt)??"*")}},[]),S.useEffect(()=>{let se=null;const Ne=jt=>{jt.target instanceof HTMLElement&&jt.target.tagName!=="IFRAME"&&(se=jt.target)},rt=jt=>{jt.relatedTarget===null&&setTimeout(()=>{document.activeElement===document.body&&(se=null)},0)},yt=jt=>{var Ln,Or,Gn,Xt,Qr;if((Ln=jt.data)!=null&&Ln.__toyon)for(const[ft,Un]of xe.current){if(Un.contentWindow!==jt.source)continue;if(jt.origin!==Re.current.get(ft))return;const ot=TS(jt.data);if(!ot)return;switch(ot.type){case"key":window.dispatchEvent(new KeyboardEvent(ot.up?"keyup":"keydown",{key:ot.key,code:ot.code,metaKey:ot.meta,ctrlKey:!!ot.ctrl,shiftKey:!!ot.shift,altKey:!!ot.alt}));break;case"hmr":r({a:"hmr",id:ft}),(Or=a.current)==null||Or.send({t:"page-loaded",worktreeId:ft});break;case"loaded":We.current.delete(ft),Ye.current.add(ft),Ee($e=>$e.includes(ft)?$e:[...$e,ft]),an.post(ft,G$(U.current)),an.post(ft,{type:"zen",on:V.current}),r({a:"hmr",id:ft}),r({a:"page",id:ft,url:ot.url,title:ot.title}),(Gn=a.current)==null||Gn.send({t:"page-loaded",worktreeId:ft}),c.note(ft,ot.url,ot.title);break;case"navigated":r({a:"page",id:ft,url:ot.url,...ot.title!==void 0?{title:ot.title}:{}}),c.note(ft,ot.url,ot.title);break;case"title":r({a:"page",id:ft,title:ot.title}),c.title(ft,ot.title);break;case"links":r({a:"links",id:ft,links:ot.links});break;case"page-error":{const $e=q4(ot);$e&&((Xt=a.current)==null||Xt.send({t:"page-error",worktreeId:ft,message:$e}));break}case"picked":{const{type:$e,verb:qe,site:kt,...ut}=ot,fn=kt==="call"?{file:ut.callFile,line:ut.callLine}:{file:ut.file,line:ut.line};if(qe==="code"){r({a:"set-picking",v:!1});const Wt=(Qr=Gt(o.getState(),ft))==null?void 0:Qr.worktree;fn.file?ya(o,s,ft,KS(fn.file,Wt==null?void 0:Wt.path),fn.line??1):s==null||s.send({t:"find-element",worktreeId:ft,seq:So(),element:ut.element})}else k3(o,ft,ut);break}case"pick-cancel":r({a:"set-picking",v:!1});break;case"drag-files":ot.over?Zw(o,o.getState().activeId?{at:"centre"}:null):pN(o);break;case"drop-files":wN(o,s,o.getState().activeId?{at:"centre"}:null,X3(ot.files));break;case"focus":ot.gesture?se=null:document.activeElement===Un&&(se!=null&&se.isConnected)&&se!==document.body&&se.focus();break;case"highlight-miss":console.warn(`[toyon] highlight miss on ${ot.path}: ${ot.fileMatched} elements from this file, ${ot.withSource} elements with source info on page, ranges=${JSON.stringify(ot.ranges)}`);break}return}};return window.addEventListener("message",yt),document.addEventListener("focusin",Ne),document.addEventListener("focusout",rt),()=>{window.removeEventListener("message",yt),document.removeEventListener("focusin",Ne),document.removeEventListener("focusout",rt)}},[r,o,s,c]),S.useEffect(()=>{an.broadcast({type:"zen",on:$})},[$]);const cn=S.useRef(new Map);at([Q==null?void 0:Q.id,Q==null?void 0:Q.n],()=>{if(!Q)return;const{id:se}=Q;clearTimeout(cn.current.get(se)),cn.current.set(se,setTimeout(()=>{cn.current.delete(se),an.post(se,{type:"reload"})},1200))});const gt=Lw(),Ue=gt&&!Sn(gt)?gt:null,zt=Ia(),pt=!!f&&f.procs.some(se=>se.status==="running"),At=zw(),Kt=At!==null&&At===h&&pt;S.useEffect(()=>{var se;if(At&&Kt&&!ae.includes(At)){const Ne=mE((se=o.getState().local[At])==null?void 0:se.page.url);ce(rt=>[...rt,{id:At,path:Ne}])}},[At,Kt,ae,o]);const xt=u.filter(se=>Sn(se)&&se.procs.some(Ne=>Ne.status==="asleep")).map(se=>se.id).join(" ");S.useEffect(()=>{const se=new Set(xt.split(" ").filter(Boolean));ae.some(Ne=>se.has(Ne))&&ce(Ne=>Ne.filter(rt=>!se.has(rt.id)))},[xt,ae]);const un=ae.join(" ");S.useEffect(()=>{const se=un.split(" ").filter(Ne=>Ne&&Ne!==At).map(Ne=>setTimeout(()=>ce(rt=>rt.filter(yt=>yt.id!==Ne)),fG));return()=>{for(const Ne of se)clearTimeout(Ne)}},[un,At]),S.useEffect(()=>{Ee(se=>se.every(Ne=>ae.includes(Ne))?se:se.filter(Ne=>ae.includes(Ne)))},[ae]);const Ct=S.useMemo(()=>u.filter(Sn).flatMap(se=>{const Ne=ve.find(yt=>yt.id===se.id);if(!Ne)return[];const rt=WS(se.worktree.id,se.worktree.proxyPort,v,_);return[{id:se.worktree.id,port:se.worktree.proxyPort,title:se.worktree.title,url:pG(Ne.path,rt)??rt}]}),[u,ve,v,_]),Ut=ok(x,v),Et=SN(x,Ct,Ut);ln.current=se=>{var rt;const Ne=mE((rt=o.getState().local[se])==null?void 0:rt.page.url);if(ve.some(yt=>yt.id===se&&yt.path!==Ne)){ce(yt=>yt.map(jt=>jt.id===se?{...jt,path:Ne}:jt));return}Ut?Et.renew(se):gE(xe.current.get(se))};const er=Ct.filter(se=>{var Ne;return(Ne=u.find(rt=>rt.id===se.id))==null?void 0:Ne.procs.some(rt=>rt.status==="running")}).map(se=>se.id).join(" ");at([er],()=>{for(const se of er.split(" "))We.current.has(se)&&ln.current(se)});const Qt=L(se=>se.carryTo),[Nn,Zn]=S.useState(null),[nn,X]=S.useState(At),be=S.useRef(null);nn!==At&&(X(At),Zn(qZ({leaving:be.current,arriving:At,carryTo:Qt,repoOf:se=>{var Ne;return((Ne=u.find(rt=>rt.id===se))==null?void 0:Ne.repoId)??null}}))),S.useEffect(()=>{if(!Nn)return;const se=setTimeout(()=>Zn(null),hG);return()=>clearTimeout(se)},[Nn]);const Ve=At!==null&&ge.includes(At),Qe=ZZ({previewId:At,painted:Ve,ready:Kt,carry:Nn,mounted:ae}),Ht=Qe!==null&&Qe!==At;S.useEffect(()=>{be.current=Qe});const St=Qe!==null&&!J&&!te&&!I&&!A&&!Y,[bn,P]=S.useState(null),ne=S.useCallback(se=>r({a:"preview-size",text:se}),[r]);aG(bn,St,ne);const[Se,Ge]=As(tt.editorHeight,0,se=>{const Ne=Number(se);return Number.isFinite(Ne)&&Ne>=120?Ne:0}),[It,Pt]=As(tt.designHeight,0,se=>{const Ne=Number(se);return Number.isFinite(Ne)&&Ne>0?Ne:0}),[De,ze]=As(tt.designFull,!1,se=>se===null?void 0:se==="1"),[Ke,Vt]=As(tt.editorFull,!1,se=>se===null?void 0:se==="1"),[Yt,yn]=As(tt.termHeight,240,se=>{const Ne=Number(se);return Number.isFinite(Ne)&&Ne>=140?Ne:void 0}),_t=L(se=>se.termTall);at([_t],()=>{const se=t.current;_t&&se&&yn(Math.max(Yt,Math.round(se.clientHeight/2)))});const gn=se=>(Ne,rt)=>{const yt=rt.parentElement,jt=t.current;if(!yt||!jt)return null;let Ln=0;for(const Gn of Array.from(jt.querySelectorAll(":scope > .pane")))Gn!==yt&&!Gn.classList.contains("full")&&(Ln+=Gn.offsetHeight);const Or=Math.max(jt.clientHeight-Ln-80,se);return Math.min(Math.max(yt.getBoundingClientRect().bottom-Ne.clientY,se),Or)},xn=Ll(gn(120),se=>Ge(Math.round(se))),Rt=Ll(gn(160),se=>Pt(Math.round(se))),Mn=Ll(gn(140),se=>yn(Math.round(se))),rn=L(se=>{var Ne,rt;return f&&Tr(f.worktree)?((rt=(Ne=se.rows.find(yt=>{var jt;return yt.repoId===f.worktree.repoId&&((jt=yt.worktree)==null?void 0:jt.kind)==="worktree"}))==null?void 0:Ne.worktree)==null?void 0:rt.title)??null:null}),cr=o5({connected:m,heard:g,standing:y,connectFailure:w,hasToken:x.serving?dG:!0,projectChord:Bt("project"),title:(f==null?void 0:f.worktree.title)??null,machine:x.serving?null:N.displayName(x.origin),needsSetup:!!fe,busy:je,treeEmpty:Te,landsFrom:rn});return d.jsxs("div",{className:"center-root",ref:n,children:[d.jsx("div",{className:Be("center-area",q&&"drop-over"),style:{display:!($&&!Y)&&!zt&&!I&&(T&&Ke||ie&&De)?"none":void 0},children:d.jsxs("div",{className:"frames-wrap",ref:P,children:[Ct.map(se=>d.jsx("iframe",{ref:Ne=>{Ne?(xe.current.set(se.id,Ne),Re.current.set(se.id,new URL(se.url).origin)):(xe.current.delete(se.id),Re.current.delete(se.id),We.current.delete(se.id),Ye.current.delete(se.id))},onLoad:()=>{Ye.current.delete(se.id)?We.current.delete(se.id):We.current.add(se.id)},src:Et.urlOf(se.id)??void 0,title:se.title,style:{display:St&&se.id===Qe?"block":"none"}},se.id)),C?d.jsx(JZ,{project:C}):I?d.jsx(hZ,{}):d.jsxs(d.Fragment,{children:[te&&d.jsx(VZ,{pending:te},te.id),j&&f&&!te&&d.jsx(GZ,{active:f},f.worktree.id),J&&!te&&!j&&d.jsx(oG,{repo:J,onClose:de?void 0:()=>r({a:"close"})},`${J.id}:${JSON.stringify(J.config)}`),Ue&&!J&&!te&&!zt&&d.jsx(du,{placement:"centre",found:Ue},Ue.id),zt&&!J&&!te&&d.jsx(du,{placement:"centre",archived:zt},zt.id),!pt&&!Ue&&!zt&&!J&&!te&&!j&&re&&d.jsx(LN,{foreign:x.serving?void 0:N.displayName(x.origin)}),!pt&&!Ue&&!zt&&!J&&!te&&!j&&!re&&(cr!==null?d.jsx(ks,{wide:!0,children:d.jsx("p",{className:Be("status-line",cr.live&&"live-text"),children:cr.text})}):Y?d.jsx(du,{placement:"centre"}):Ht?null:f&&d.jsx(WZ,{worktree:f,log:W}))]})]})}),T&&d.jsx(O$,{editor:T,height:Ke?"100%":Se>0?Se:"45%",full:Ke,onToggleFull:()=>Vt(!Ke),onDragStart:xn}),ie&&h&&!zt&&!I&&d.jsx(gZ,{worktreeId:h,height:De?"100%":It>0?It:"55%",full:De,onToggleFull:()=>ze(!De),onDragStart:Rt},`design:${h}`),M&&h&&!zt&&!I&&d.jsx(BZ,{worktreeId:h,opened:H,height:Yt,onDragStart:Mn},`term:${h}`),d.jsx(F$,{})]})}function gG({width:e}){const t=L(r=>r.layout.chat),n=zu();return d.jsx(du,{placement:"dock",className:!t||n?"collapsed":void 0,width:e})}function kG(e,t){const n=[];return e&&(n.push(Z_(e)),n.push({id:"copy-url",label:"copy URL",onClick:()=>tn(e)})),Bn([n,[{id:"reload",label:"reload preview",key:Bt("reload"),onClick:t.reload}]])}const wG=520,Ng=8;function yG({winW:e,centre:t,leadRight:n,toolsLeft:r}){const o=t.right-t.left,s=Math.max(0,Math.min(wG,Math.floor(e*.4),o-2*Ng)),a=t.left+(o-s)/2,c=n+Ng,u=r-Ng-s,h=Math.max(Math.min(a,u),c);return{left:Math.round(h),width:s}}function vG({center:e}){const t=fz(),n=O_(e),r=S.useRef(null);Ez(r);const o=y6(),[s,a]=Qb(),[c,u]=Qb(),h=yG({winW:t,centre:n,leadRight:a.right,toolsLeft:u.left}),f=lt(),m=Je(),g=On(),y=vn("bar"),w=zs(),v=Fu(),_=L(U=>U.zen)&&!v,x=L(U=>U.layout.changes),N=L(U=>U.layout.chat),T=zu(),j=L(U=>U.layout.design),C=L(U=>{var $;return(($=U.overlay)==null?void 0:$.kind)==="keys"}),I=Xj(),A=(w==null?void 0:w.worktree.id)??null,M=L(U=>U.archivedPage!==null||U.notesPage),O=!!w&&zh(w)&&!M,z=L(U=>U.chatSide)==="left",B={tipAlign:"start"},H={tipAlign:"end"},Y=!T&&d.jsx(Lt,{icon:"branch",label:"Changes panel",hint:Bt("changes"),tone:"chrome",on:x,...z?H:B,onClick:()=>f({a:"toggle-changes"})}),ie=!T&&!v&&d.jsx(Lt,{icon:"chat",label:"Chat panel",hint:Bt("composer"),tone:"chrome",on:N,...z?B:H,onClick:()=>f({a:"toggle-chat"})}),Q=L(U=>U.railOpen),le=!T&&d.jsx(Lt,{icon:"worktrees",label:"Worktree panel",hint:Bt("rail"),tone:"chrome",on:Q,...z?B:H,onClick:()=>f({a:"toggle-rail"})});return d.jsxs("div",{className:"top-bar",ref:r,"data-float-up":o||void 0,children:[_&&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:[z?le:Y,z&&ie,d.jsx(bG,{}),I&&d.jsx(Yu,{icon:"download","data-tip":"Install Toyon as an app (own window, dock icon)",onClick:()=>void I.prompt(),children:"install app"}),d.jsx(EG,{}),d.jsx(SG,{}),d.jsx(_G,{})]}),!v&&d.jsx(xG,{worktreeId:A,repoId:(w==null?void 0:w.repoId)??null,ready:O,left:h.left,width:h.width}),d.jsx("span",{className:"bar-grow"}),d.jsxs("span",{className:"bar-tools",ref:c,children:[d.jsx(NG,{}),d.jsx(Lt,{icon:"settings",label:"Settings & shortcuts",hint:Bt("keys"),tone:"chrome",on:C,...H,"aria-controls":"keys-help","aria-expanded":C,onClick:()=>f({a:"toggle",overlay:{kind:"keys"}}),...y.contextMenu(()=>_T(g.getState(),{sock:m,dispatch:f}))}),!T&&!v&&d.jsx(Lt,{icon:"palette",label:"Design system",hint:Bt("design"),tone:"chrome",on:j,...H,onClick:()=>f({a:"toggle-design"})}),z?Y:ie,!z&&le,!v&&d.jsx(Lt,{icon:"zen",className:"bar-zen",label:"Full-bleed preview",hint:Bt("zen"),tone:"chrome",on:_,...H,onClick:()=>f({a:"toggle-zen"})})]})]})}function bG(){const e=lt(),t=Je(),n=Jl(),r=L(m=>m.activeRepoId),o=L(m=>m.rows),s=L(m=>m.repos),a=vn("bar"),c=()=>Bn([[{id:"project",label:s.length>1?"switch project…":"open project…",key:Bt("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?Jh(n,r,{sock:t,dispatch:e},o):[]]),u=L(m=>{var g;return((g=m.overlay)==null?void 0:g.kind)==="projects"&&m.overlay.form==="pill"}),h=L(m=>m.heard),f=L(m=>m.newProject!==null);return d.jsxs("span",{className:"bar-project",children:[d.jsx(Me,{tone:"chrome",className:"bar-pill",on:u,...Ft(s.length>1?"Switch project":"Open a project",Bt("project")),onClick:()=>e({a:"toggle",overlay:{kind:"projects",form:"pill"}}),...a.contextMenu(c),children:d.jsx("span",{className:"bar-project-name",children:f?"new project":(n==null?void 0:n.name)??(h?"open project":"")})}),u&&d.jsx(By,{form:"pill"})]})}function xG({worktreeId:e,repoId:t,ready:n,left:r,width:o}){const s=Mt(e,"page").url,a=lt(),c=L(y=>{var w;return((w=y.overlay)==null?void 0:w.kind)==="routes"}),u=L(y=>y.previewSize);at([e,n],()=>{c&&a({a:"close"})});const f=vn("bar").contextMenu(()=>n?kG(s,{reload:()=>e&&an.post(e,{type:"reload"})}):[]),m=L(y=>y.picking),g=zw();return d.jsxs("div",{className:"bar-center",style:{left:r,width:o},children:[d.jsx(Lt,{icon:"back",label:"Back",hint:Bt("back"),disabled:!n,onClick:()=>e&&an.post(e,{type:"back"}),...f}),d.jsx(Lt,{icon:"forward",label:"Forward",hint:Bt("forward"),disabled:!n,onClick:()=>e&&an.post(e,{type:"forward"}),...f}),d.jsx(Lt,{icon:"reload",label:"Reload preview",hint:Bt("reload"),disabled:!n,onClick:()=>e&&an.post(e,{type:"reload"}),...f}),d.jsxs("span",{className:"bar-route",children:[n&&e&&t?d.jsx(GH,{worktreeId:e,repoId:t,url:s,open:c},e):d.jsx(zo,{className:"bar-path",value:"",readOnly:!0,disabled:!0}),u&&d.jsx("span",{className:"bar-size",children:u})]}),d.jsx(Lt,{icon:"inspect",label:"Pick an element to open its code",hint:Bt("inspect"),also:{text:"Add an element to chat",key:Bt("pick")},on:m==="code",disabled:!n||!g,onClick:()=>g&&Eu(g,m,a,"code")})]})}function Yu({icon:e,busy:t,children:n,...r}){return d.jsxs(Me,{disabled:t,...r,children:[!t&&d.jsx(ht,{name:e,className:"icon-inline"}),d.jsx("span",{className:Be(t&&"live-text"),children:n})]})}function EG(){const e=L(u=>u.self),t=L(u=>u.rebuilt),n=L(u=>u.repos),r=Je(),o=L(u=>{var h;return((h=u.update)==null?void 0:h.restarting)!=null}),s=M$(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",c=()=>{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(Yu,{icon:"reload",busy:s.busy,onClick:c,...Ft(s.text,void 0,{detail:s.detail}),children:a})}function SG(){const e=L(o=>o.update),t=L(o=>o.managed.updates),n=Je(),r=Y6(e);return!r||!t?null:d.jsx(Yu,{icon:"reload",busy:r.busy,onClick:()=>{r.retry&&(n==null||n.send({t:"update-now"}))},...Ft(r.text),children:r.word})}function _G(){const e=lt(),t=L(CD),n=L(a=>a.ranBefore),r=L(a=>a.newProject!==null);if(!t||!n||r)return null;const{word:o,text:s}=fZ(n,t);return d.jsx(Yu,{icon:"book",onClick:()=>e({a:"open-release-notes"}),...Ft(s),children:o})}function NG(){const e=lt(),t=L(KD),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(Lt,{icon:"devices",label:"Your devices",tone:"chrome",on:r,tipAlign:"end","aria-expanded":r,onClick:o}):d.jsx(Yu,{icon:"devices","aria-expanded":r,onClick:o,...Ft("Open this machine on your phone, and let it in"),children:"open on phone"})}function TG(e,t,n){return t==="left"?n-e.left:e.right-n}const jG="input, textarea, [contenteditable], .monaco-editor, .xterm, iframe";function $G(){const e=On(),t=lt(),n=Je(),r=zu(),o=Ra(),s=Fu(),a=L(q=>q.zen)&&!s,c=Ia(),u=L(q=>q.notesPage),h=!!Dw()||!!c||u,f=L(q=>q.layout.changes)&&!r,m=L(q=>q.layout.chat)&&!r&&!s&&!h,g=L(q=>q.chatSide),y=L(q=>q.railOpen),[w,v]=As(tt.changesWidth,220,q=>q?df(Number(q),220):void 0),[_,x]=As(tt.chatWidth,380,q=>q?df(Number(q),380):void 0),[N,T]=As(tt.railWidth,280,q=>q?df(Number(q),280):void 0),j=(q,V,W)=>{const re=V.classList.contains("left")?"left":"right",fe=re==="left"?V.previousElementSibling:V.nextElementSibling;return fe?df(TG(fe.getBoundingClientRect(),re,q.clientX),W):null},C=Ll((q,V)=>j(q,V,220),v),I=Ll((q,V)=>j(q,V,380),x),A=Ll((q,V)=>j(q,V,280),T),[M,O]=S.useState(null),B=vn("app").contextMenu(()=>xT(e.getState(),{sock:n,dispatch:t})),H=d.jsx(aT,{width:w}),Y=!s&&!h&&d.jsx(gG,{width:_}),ie=!r&&d.jsx(W$,{width:N}),Q=q=>!r&&y&&d.jsx("div",{className:`dock-resize ${q}`,onPointerDown:A}),le=g==="left",U=le?{dock:Y,open:m,drag:I}:{dock:H,open:f,drag:C},$=le?{dock:H,open:f,drag:C}:{dock:Y,open:m,drag:I};return d.jsxs("div",{className:Be("app",a&&"zen"),"data-chat-side":g,"data-touch":o||void 0,"data-hover":!o||void 0,onContextMenu:q=>{q.defaultPrevented||q.target instanceof Element&&q.target.closest(jG)||B.onContextMenu(q)},children:[d.jsx(NN,{}),d.jsx(CN,{}),d.jsx(vG,{center:M}),d.jsxs("div",{className:"docks",children:[le&&ie,le&&Q("left"),U.dock,U.open&&d.jsx("div",{className:"dock-resize left",onPointerDown:U.drag}),d.jsx(mG,{onRoot:O}),$.open&&d.jsx("div",{className:"dock-resize right",onPointerDown:$.drag}),$.dock,!le&&Q("right"),!le&&ie]})]})}function CG(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 c=e[e.length-1];return r<0&&c?{activate:c.id}:null}const AG=new Set(["design","chats"]),IG=new Set(["back","forward"]),RG=new Set(["project","commands","keys","zen"]);function OG(){const e=On(),t=Je();S.useEffect(()=>{const n=Hq(f=>e.dispatch({a:"rail-peek",on:f})),r=n.end,o=f=>{e.getState().railOpen||n.press(f)},s=f=>n.keyup(f.key),a=f=>n.mods(f),c=()=>{var y,w;const f=e.getState(),g=((w=(y=document.activeElement)==null?void 0:y.closest("[data-pane]"))==null?void 0:w.dataset.pane)??(f.layout.term?"terminal":f.editor?"editor":f.layout.design?"design":null);g==="terminal"?e.dispatch({a:"toggle-terminal"}):g==="editor"?e.dispatch({a:"close-editor"}):g==="design"&&e.dispatch({a:"toggle-design"})},u=f=>{f.key!=="Escape"||!e.getState().choosingFolder||(f.stopImmediatePropagation(),t==null||t.send({t:"cancel-folder"}),e.dispatch({a:"choosing-folder",v:!1}))},h=f=>{var _,x,N,T;a(f),RA(f)&&!f.defaultPrevented&&f.preventDefault();const m=e.getState(),{dispatch:g}=e,y=j=>{const C=document.activeElement,I=!C||C===document.body||!!C.closest(".rail, .chat-input");g({a:"activate",id:j}),I&&g({a:"walked"})},w=RE(f,{guest:!!((_=document.activeElement)!=null&&_.closest(".xterm"))});if(!(m.zen&&!ns(m)&&!m.overlay&&!m.picking&&!(w&&IA.has(w.id))||(w==null?void 0:w.id)==="close"&&!bw()||(x=document.activeElement)!=null&&x.closest(".monaco-editor")&&w&&AG.has(w.id))&&!(w&&DA(w.id,document.activeElement))&&!(w&&IG.has(w.id)&&!($l(m)&&wu(m)))&&!((w==null?void 0:w.id)==="reload"&&!qg(m))){if(w){const j=f.defaultPrevented;if(f.preventDefault(),m.newProject&&!RG.has(w.id))return;switch(w.id){case"worktree":{const C=MA(w.digit,m.visible.length),I=C===null?void 0:m.visible[C];I&&y(I.id);break}case"wt-prev":case"wt-next":{const C=CG(m.visible,m.visibleDiscovered,m.activeId,w.id==="wt-next"?1:-1);C&&y(C.activate),o(f);break}case"wt-unseen-prev":case"wt-unseen-next":{const C=oy(m.visible,m.activeId,w.id==="wt-unseen-next"?1:-1);C&&y(C.activate),o(f);break}case"mark-unread":m.activeId&&!m.draft&&m.visible.some(C=>C.id===m.activeId)&&KN(t,g,m.activeId);break;case"wt-archive":{if(f.repeat||j)break;const C=m.draft||m.archivedPage?void 0:m.visible.find(I=>I.id===m.activeId);C&&qN(t,g,I=>Nw(m,I)).archive(C);break}case"new":g({a:"open-draft"});break;case"project":g({a:"toggle",overlay:{kind:"projects",form:"center"}});break;case"quick-open":((N=m.overlay)==null?void 0:N.kind)==="quick-open"?g({a:"close"}):m.activeId&&g({a:"open",overlay:{kind:"quick-open"}});break;case"routes":((T=m.overlay)==null?void 0:T.kind)==="routes"?g({a:"close"}):wu(m)&&g({a:"open",overlay:{kind:"routes"}});break;case"reload":{const C=qg(m);if(!C)break;C.act==="frame"?an.post(C.id,{type:"reload"}):t==null||t.send({t:"preview-start",worktreeId:C.id});break}case"back":case"forward":{const C=$l(m);C&&an.post(C,{type:w.id});break}case"pick":case"inspect":{const C=$l(m);C&&Eu(C,m.picking,g,w.id==="pick"?"chat":"code");break}case"search":m.activeId&&g({a:"toggle",overlay:{kind:"search"}});break;case"refs":m.activeRepoId&&g({a:"toggle",overlay:{kind:"refs"}});break;case"chats":m.activeRepoId&&g({a:"toggle",overlay:{kind:"chats"}});break;case"commands":g({a:"toggle",overlay:{kind:"commands"}});break;case"zen":g({a:"toggle-zen"});break;case"close":!(m.zen&&!ns(m))&&!m.overlay&&c();break;case"changes":g(m.layout.changes&&(Kl(m)==="changes"||Fo(m)!==null)?{a:"toggle-changes"}:{a:"focus-changes",tab:"changes"});break;case"files":g(m.layout.changes&&Kl(m)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"});break;case"panel-tab-prev":case"panel-tab-next":if(Dh(m))break;g(m.layout.changes?{a:"focus-changes",tab:$D(m,w.id==="panel-tab-next"?1:-1)}:{a:"focus-changes"});break;case"composer":g(s_(m));break;case"rail":g(m.railOpen?{a:"toggle-rail"}:{a:"focus-rail"});break;case"keys":g({a:"toggle",overlay:{kind:"keys"}});break;case"terminal":g(m.layout.term?{a:"toggle-terminal"}:{a:"focus-terminal"});break;case"design":g({a:"toggle-design"});break;case"term-tab":{const C=m.rows.find(O=>O.id===m.activeId);if(!C)break;const I=Wr(m,m.activeId).termStream;if(C.login&&I===Ls)break;const A=[Do,...C.login?[Ls]:[],...C.procs.map(O=>O.name)],M=A.indexOf(I);g({a:"term-stream",id:C.id,stream:A[(M+1)%A.length]??Do});break}}}else if(f.key==="Escape")if(m.newProject)m.newProject.phase==="editing"&&g({a:"close-new-project"});else if(m.picking){const j=$l(m);j&&an.post(j,{type:"pick-cancel"}),g({a:"set-picking",v:!1})}else m.notesPage?g({a:"close-release-notes"}):m.archivedPage?g({a:"close-archived"}):m.activeImportId?g({a:"watch-import",id:null}):c()}};return window.addEventListener("keydown",u,!0),window.addEventListener("keydown",h),window.addEventListener("keyup",s),window.addEventListener("pointermove",a),window.addEventListener("pointerdown",a),window.addEventListener("blur",r),()=>{window.removeEventListener("keydown",u,!0),window.removeEventListener("keydown",h),window.removeEventListener("keyup",s),window.removeEventListener("pointermove",a),window.removeEventListener("pointerdown",a),window.removeEventListener("blur",r),r()}},[e,t]),S.useEffect(()=>{const n=r=>{if(r.key!=="Alt"&&r.key!=="Shift")return;const o=e.getState();o.picking&&o.activeId&&an.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 MG=3,LG=2e3,PG=200,DG=5e3;function zG(){const e=lt(),t=Je(),n=Ds(),{storage:r}=n,o=Ql(),s=L(J=>J.activeRepoId),a=zs(),c=Lw(),u=L(J=>J.connected),h=L(J=>J.daylight),f=L(J=>{var te;return((te=J.daylight)==null?void 0:te.until)??0}),m=Ia(),g=L(J=>J.notesPage),y=L(J=>J.version),w=L(J=>J.railOpen),v=L(J=>J.chatSide),_=L(J=>J.layouts),x=L(J=>J.lastActive),N=L(J=>J.discoveredOpen),T=L(J=>J.archivedOpen),j=L(J=>J.committedShut),C=L(J=>J.turnOpen),I=L(J=>J.treeOpen),A=Bh(),M=L(J=>J.previewTheme!==null),O=L(J=>J.openUrl),z=z_();S.useEffect(()=>ql.install(window),[]);const B=S.useRef([]),H=S.useCallback(J=>t==null?void 0:t.send({t:"subscribe",worktreeId:J,since:n.since(J)}),[t,n]);S.useEffect(()=>{if(!t||!u||!o)return;const J=[o,...B.current.filter(te=>te!==o)];for(const te of J.splice(MG))t.send({t:"unsubscribe",worktreeId:te});B.current.includes(o)||H(o),B.current=J},[o,u,t,H]),S.useEffect(()=>{if(!(!t||!u))for(const J of B.current)H(J)},[u,t,H]);const Y=S.useRef(void 0);S.useEffect(()=>{if(!t||!u)return;let J;const te=()=>{const ae=document.visibilityState==="visible"?o:null;t.send({t:"view",worktreeId:ae}),Y.current=ae},ve=()=>{clearTimeout(J),J=setTimeout(te,PG)};Y.current===void 0||Y.current===o||document.visibilityState!=="visible"?te():ve();const ce=()=>document.visibilityState==="visible"?ve():te();return document.addEventListener("visibilitychange",ce),()=>{clearTimeout(J),document.removeEventListener("visibilitychange",ce)}},[o,u,t]);const ie=(m==null?void 0:m.id)??null;S.useEffect(()=>{if(!(!t||!u||!ie))return H(ie),()=>t.send({t:"unsubscribe",worktreeId:ie})},[ie,u,t,H]),S.useEffect(()=>{const J=new Set(z.map(ve=>ve.id)),te=B.current.filter(ve=>!J.has(ve));if(te.length!==0&&(B.current=B.current.filter(ve=>J.has(ve)),!(!t||!u)))for(const ve of te)t.send({t:"unsubscribe",worktreeId:ve})},[z,u,t]);const Q=g?"Release notes":(m==null?void 0:m.title)??(c==null?void 0:c.name)??null;S.useEffect(()=>{document.title=Q?`${Q} · Toyon`:"Toyon"},[Q]);const le=!!(a!=null&&a.unseen),U=L(J=>J.unreadHold!==null&&J.unreadHold===J.activeId);S.useEffect(()=>{if(!t||!o||!le||U)return;let J;const te=()=>document.visibilityState==="visible"&&document.hasFocus(),ve=()=>{clearTimeout(J),te()&&(J=setTimeout(()=>{te()&&t.send({t:"seen",worktreeId:o})},LG))},ce=()=>clearTimeout(J);return ve(),window.addEventListener("focus",ve),window.addEventListener("blur",ce),()=>{ce(),window.removeEventListener("focus",ve),window.removeEventListener("blur",ce)}},[t,o,le,U]);const $=S.useRef(0),q=L(J=>Tw(J));S.useEffect(()=>{if(!t||!u||!s)return;const J=()=>{Date.now()-$.current<DG||($.current=Date.now(),t.send({t:"refresh-git",repoId:s}),q&&q!==s&&t.send({t:"refresh-git",repoId:q}))};return window.addEventListener("focus",J),()=>window.removeEventListener("focus",J)},[t,u,s,q]);const V=L(J=>J.frame==="phone"&&J.screen==="home"?"surface1":"surface0");S.useEffect(()=>{try{sessionStorage.setItem(tt.ground,V)}catch{}},[V]);const W=L(J=>J.frame==="phone"),re=L(J=>J.blackGround),fe=S.useMemo(()=>W&&re?FP(A):A,[W,re,A]);S.useEffect(()=>{try{localStorage.setItem(tt.blackGround,re?"1":"0")}catch{}},[re]),S.useEffect(()=>{Z$(fe,{remember:!M,ground:V,black:fe!==A}),an.broadcast(G$(fe))},[fe,A,M,V]);const pe=S.useCallback(()=>{t==null||t.send({t:"zone",tz:Intl.DateTimeFormat().resolvedOptions().timeZone})},[t]);S.useEffect(()=>{if(!u)return;pe();const J=()=>{document.visibilityState==="visible"&&pe()};return document.addEventListener("visibilitychange",J),()=>document.removeEventListener("visibilitychange",J)},[u,pe]),S.useEffect(()=>{if(!u||f<=Date.now())return;const J=setTimeout(pe,f-Date.now()+1e3);return()=>clearTimeout(J)},[u,f,pe]),S.useEffect(()=>{h&&h.until>0&&uZ(h)},[h]),S.useEffect(()=>{o&&r.set(tt.active,o)},[o,r]),S.useEffect(()=>{y&&r.set(tt.version,y)},[y,r]);const Te=L(J=>J.frame==="phone"?J.screen!=="home":null);S.useEffect(()=>{Te!==null&&r.session.set(tt.phoneRow,Te?"1":"0")},[Te,r]),S.useEffect(()=>{s&&r.set(tt.repo,s)},[s,r]),S.useEffect(()=>{try{localStorage.setItem(tt.rail,w?"1":"0")}catch{}},[w]),S.useEffect(()=>{try{localStorage.setItem(tt.chatSide,v)}catch{}},[v]),S.useEffect(()=>{try{localStorage.setItem(tt.layouts,JSON.stringify(_))}catch{}},[_]),S.useEffect(()=>{r.set(tt.lastActive,JSON.stringify(x))},[x,r]),S.useEffect(()=>{r.set(tt.discoveredOpen,JSON.stringify(N))},[N,r]),S.useEffect(()=>{r.set(tt.archivedOpen,JSON.stringify(T))},[T,r]),S.useEffect(()=>{r.set(tt.committedShut,JSON.stringify(j))},[j,r]),S.useEffect(()=>{r.set(tt.turnOpen,JSON.stringify(C))},[C,r]),S.useEffect(()=>{r.set(tt.treeOpen,JSON.stringify(I))},[I,r]),OG(),n6();const je=S.useRef(null);return S.useEffect(()=>{!O||je.current===O||(je.current=O,window.open(O,"_blank"),e({a:"opened-url"}))},[O,e]),L(J=>J.frame)==="phone"?d.jsx(oZ,{}):d.jsx($G,{})}function FG({origin:e,machine:t,onToken:n}){const[r,o]=S.useState({kind:"asking"}),[s,a]=S.useState(0);return at([s],()=>{const c=new AbortController;return o({kind:"asking"}),zS(e,c.signal,u=>o({kind:"waiting",word:u})).then(u=>{if(!c.signal.aborted){if(typeof u=="string"){o({kind:"failed",failure:u});return}o({kind:"in"}),n(u.token)}}),()=>c.abort()}),d.jsxs(ks,{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.":z$(r.failure,e,"this device")}),r.kind==="failed"&&d.jsx("div",{className:"status-actions",children:d.jsx(Me,{variant:"outline",onClick:()=>a(c=>c+1),children:"ask again"})})]})}const Tg="toyon-shared",BG="x-toyon-name";async function UG(e=globalThis.caches){var t;try{if(!e||!await e.has(Tg))return[];const n=await e.open(Tg),r=[];for(const o of await n.keys()){const s=await n.match(o);if(!s)continue;const a=decodeURIComponent(s.headers.get(BG)??"")||"shared",c=((t=(s.headers.get("content-type")??"").split(";")[0])==null?void 0:t.trim())??"";r.push(new File([await s.blob()],a,{type:c}))}return await e.delete(Tg),r}catch{return[]}}function kE(e,t=()=>!0){const n=()=>t()?Oa(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 HG(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 WG(e,t){const n=await UG(t);if(n.length===0)return;if(e.getState().frame!=="phone"){Jf(e,await kE(e),n);return}e.dispatch({a:"screen",to:"home"}),e.dispatch({a:"sharing",v:HG(n)});const r=await kE(e,()=>e.getState().screen!=="home");e.dispatch({a:"sharing",v:null}),Jf(e,r,n)}function KG(){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(yA(t.worktreeId,t.stream))??[])n(t)}}}const qG=2e3,ZG=1500;function GG(e,t,n,r={}){const o=r.timers??{set:(I,A)=>setTimeout(I,A),clear:I=>clearTimeout(I)},s=r.now??(()=>Date.now()),a=r.win??(typeof window>"u"?null:window),c=new Map,u=I=>{let A=c.get(I);return A||(A=new gD,c.set(I,A)),A},h=new Map,f=new Map,m=I=>{var z;o.clear(f.get(I)),f.delete(I);const A=e.getState();if(I===""){if(!A.heard)return;const B=cD(A,s());if(!B)return;const H=mD(Object.fromEntries([...h].map(([Y,ie])=>[Y,{at:ie}])),A.rows);for(const Y of H)h.delete(Y),c.delete(Y);t.putHello(n,B).then(()=>H.length?t.dropChats(n,H):void 0);return}const M=c.get(I);if(!M||!A.rows.some(B=>B.id===I))return;const O=s();h.set(I,O),t.putChat(n,I,M.snapshot((z=A.local[I])==null?void 0:z.draft,O))},g=I=>{f.has(I)||f.set(I,o.set(()=>m(I),qG))},y=()=>{for(const I of[...f.keys()])m(I)};let w=e.getState();const v=new Map,_=e.subscribe(()=>{var A;const I=e.getState();if(I.heard&&(!w.heard||I.rows!==w.rows||I.repos!==w.repos||I.trunks!==w.trunks||I.handed!==w.handed||I.visits!==w.visits)&&g(""),I.local!==w.local)for(const M of c.keys()){const O=((A=I.local[M])==null?void 0:A.draft)??"";(v.get(M)??"")!==O&&(v.set(M,O),g(M))}w=I}),x=()=>{var I;((I=a==null?void 0:a.document)==null?void 0:I.visibilityState)==="hidden"&&y()};a==null||a.addEventListener("visibilitychange",x),a==null||a.addEventListener("pagehide",y);const N=Promise.all([t.hello(n),t.chats(n)]);let T;const j=new Promise(I=>{T=o.set(()=>I(null),ZG)});return{recalled:Promise.race([N,j]).then(I=>{if(o.clear(T),!I)return;const[A,M]=I;for(const[z,B]of Object.entries(M))h.set(z,B.at);if(!A||!Ub(A)||e.getState().heard)return;const O={};for(const[z,B]of Object.entries(M))Ub(B)&&(O[z]=B);try{e.dispatch({a:"recall",hello:A,chats:O})}catch(z){console.error("the last-known machine could not be recalled; dropping it",z),h.clear(),t.clear(n);return}for(const[z,B]of Object.entries(O))u(z).reset(B.events,B.seq,!1),v.set(z,B.draft??"")}).catch(I=>{console.error("the last-known machine could not be read",I)}),hear(I){var A;if(I.t==="backfill"){const M=u(I.worktreeId);g(I.worktreeId);const O=(((A=e.getState().local[I.worktreeId])==null?void 0:A.chat.length)??0)>0;if(I.after!==void 0&&I.after===M.since()&&O)return M.extend(I.events,I.last),I;if(M.reset(I.events,I.last,I.after===void 0),I.after===void 0)return I;const{after:z,...B}=I;return B}return I.t==="agent"&&(u(I.worktreeId).add(I.seq,I.event),g(I.worktreeId)),I},since:I=>{var A;return(A=c.get(I))==null?void 0:A.since()},forget(){for(const I of[...f.keys()])o.clear(f.get(I)),f.delete(I);c.clear(),h.clear(),t.clear(n)},dispose(){_(),a==null||a.removeEventListener("visibilitychange",x),a==null||a.removeEventListener("pagehide",y),y()}}}function VG(){const e=new Map,t=n=>{const r=ao.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(ao.hello(n))??null,putHello:async(n,r)=>void e.set(ao.hello(n),r),chats:async n=>t(n),putChat:async(n,r,o)=>void e.set(ao.chat(n,r),o),dropChats:async(n,r)=>{for(const o of r)e.delete(ao.chat(n,o))},clear:async n=>{e.delete(ao.hello(n));for(const r of[...e.keys()])r.startsWith(ao.chats(n))&&e.delete(r)}}}function nC(){if(typeof indexedDB>"u")return VG();let e=null;const t=()=>(e??(e=new Promise((s,a)=>{const c=indexedDB.open(r4,1);c.onupgradeneeded=()=>c.result.createObjectStore(Hc),c.onsuccess=()=>s(c.result),c.onerror=()=>a(c.error),c.onblocked=()=>a(new Error("blocked"))}).catch(s=>{throw e=null,s})),e),n=async(s,a)=>{const c=(await t()).transaction(Hc,s).objectStore(Hc);return new Promise((u,h)=>{const f=a(c);f.onsuccess=()=>u(f.result),f.onerror=()=>h(f.error)})},r=s=>{const a=ao.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(ao.hello(s))),void 0).then(a=>a??null),putHello:(s,a)=>o(n("readwrite",c=>c.put(a,ao.hello(s))),void 0).then(()=>{}),chats:async s=>{const a=ao.chats(s),[c,u]=await o((async()=>{const f=(await t()).transaction(Hc,"readonly").objectStore(Hc),m=g=>new Promise((y,w)=>{g.onsuccess=()=>y(g.result),g.onerror=()=>w(g.error)});return Promise.all([m(f.getAllKeys(r(s))),m(f.getAll(r(s)))])})(),[[],[]]),h={};return c.forEach((f,m)=>{const g=u[m];typeof f=="string"&&g&&(h[f.slice(a.length)]=g)}),h},putChat:(s,a,c)=>o(n("readwrite",u=>u.put(c,ao.chat(s,a))),void 0).then(()=>{}),dropChats:async(s,a)=>{for(const c of a)await o(n("readwrite",u=>u.delete(ao.chat(s,c))),void 0)},clear:async s=>{await o(n("readwrite",a=>a.delete(ao.hello(s))),void 0),await o(n("readwrite",a=>a.delete(r(s))),void 0)}}}function YG(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 XG(e){const t={};try{const n=JSON.parse(e??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))yD(o)&&(t[r]=o)}catch{}return t}function QG(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 _f(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 JG(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 eV=400,tV=2e3;function rC(){const e=new Map;return{another(t,n=0){return(e.get(t)??0)===n?!1:(e.set(t,n),!0)}}}function oC(e,t,n){const r=e.getState(),o=[];for(const[s,a]of t){if(a===n||r.local[s])continue;const c=fs(s);c&&c.clientId!==r.clientId||o.push(s)}return o}function nV(e,t){const n=new Map,r=new Map,o=rC(),s=u=>{var f,m;clearTimeout((f=r.get(u))==null?void 0:f.timer),r.delete(u);const h=e.getState().local[u];!h||((m=h.mark)==null?void 0:m.by)==="walk"||(n.get(u)??"")!==h.draft&&(n.set(u,h.draft),t.send({t:"set-draft",boxId:u,text:h.draft,clientId:e.getState().clientId}))},a=()=>{for(const u of[...r.keys()])s(u)},c=e.subscribe(()=>{var u,h,f;for(const[m,g]of Object.entries(e.getState().local)){if(o.another(m,g.sent)&&(clearTimeout((u=r.get(m))==null?void 0:u.timer),r.delete(m),n.set(m,"")),((h=g.mark)==null?void 0:h.by)==="walk"||(n.get(m)??"")===g.draft)continue;if(!g.draft){s(m);continue}const y=r.get(m);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(eV,w+tV-Date.now()));r.set(m,{text:g.draft,timer:setTimeout(s,v,m),since:w})}for(const m of oC(e,n,""))clearTimeout((f=r.get(m))==null?void 0:f.timer),r.delete(m),n.set(m,""),t.send({t:"set-draft",boxId:m,text:"",clientId:e.getState().clientId})});return window.addEventListener("focusout",a),window.addEventListener("pagehide",a),{hello(u){n.clear();for(const[h,f]of Object.entries(u))n.set(h,f)},heard(u,h){return r.has(u)?!1:(n.set(u,h),!0)},dispose(){c();for(const u of r.values())clearTimeout(u.timer);r.clear(),window.removeEventListener("focusout",a),window.removeEventListener("pagehide",a)}}}function rV(e,t){const n=new Map,r=new Map,o=rC(),s=e.subscribe(()=>{const a=[];for(const[c,u]of Object.entries(e.getState().local)){if(o.another(c,u.sent)&&r.set(c,"[]"),n.get(c)===u.attachments)continue;n.set(c,u.attachments);const h=Sw(u.attachments),f=JSON.stringify(h),m=r.get(c)??"[]";m!==f&&(r.set(c,f),a.push({id:c,items:h,before:QS(JSON.parse(m))}))}for(const c of oC(e,r,"[]"))r.set(c,"[]"),a.push({id:c,items:[],before:[]});for(const c of iD(a))t.send({t:"set-attachments",boxId:c.id,items:c.items,clientId:e.getState().clientId})});return{hello(a){r.clear(),n.clear();for(const[c,u]of Object.entries(a))r.set(c,JSON.stringify(u))},heard(a,c){r.set(a,JSON.stringify(c))},dispose:s}}function oV(e,t){return e.subscribe(()=>{for(const n of sD(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(Jc(o.outgoing.frame,n,o.draft,o.attachments)),e.dispatch({a:"sent-out",id:n}))}})}const wE="not sent: the page reloaded while an upload was on its way; attach it again and send";function yE(e,t,n){var a;const r=e.getState(),o=new Set([...Object.keys(n.drafts),...Object.keys(n.attachments)]),s=[];for(const c of o){const u=fs(c);if((u==null?void 0:u.clientId)!==r.clientId||(a=r.local[c])!=null&&a.outgoing)continue;const h=n.drafts[c]??"",f=n.attachments[c]??[],m=n.drafts[u.source]??"",g=[...f,...n.attachments[u.source]??[]],y=m||h,w=r.clientId;g.length&&t.send({t:"set-attachments",boxId:u.source,items:g,clientId:w}),y!==m&&t.send({t:"set-draft",boxId:u.source,text:y,clientId:w}),t.send({t:"set-attachments",boxId:c,items:[],clientId:w}),t.send({t:"set-draft",boxId:c,text:"",clientId:w}),delete n.drafts[c],delete n.attachments[c],y&&(n.drafts[u.source]=y),g.length&&(n.attachments[u.source]=g),s.push(u.source)}return s}function sV(e,t){const n=(t.storage??o4)(e.origin),r=az(bD({cached:t.cached,systemDark:t.systemDark,daylight:t.daylight,storedActive:n.get(tt.active),storedPhoneRow:n.session.get(tt.phoneRow)==="1",storedRepo:n.get(tt.repo),storedVersion:n.get(tt.version),storedRailOpen:Nf(tt.rail)==="1",storedChatSide:Nf(tt.chatSide)==="right"?"right":"left",storedBlackGround:Nf(tt.blackGround)==="1",storedLayouts:XG(Nf(tt.layouts)),storedLastActive:QG(n.get(tt.lastActive)),storedDiscoveredOpen:_f(n.get(tt.discoveredOpen)),storedArchivedOpen:_f(n.get(tt.archivedOpen)),storedCommittedShut:_f(n.get(tt.committedShut)),storedTurnOpen:_f(n.get(tt.turnOpen)),storedTreeOpen:JG(n.get(tt.treeOpen)),clientId:t.clientId,frame:t.frame,touch:t.touch})),o=KG(),s={version:null,protocol:null},a=D9(v=>r.dispatch({a:"server",msg:v}));let c,u,h;const f=GG(r,t.snapshots??nC(),e.origin);let m=[];const g=new T4(e,v=>{if(v.t==="hello"){if(s.protocol=v.protocol,e.serving){const{rebuilt:x,update:N}=r.getState(),T=x&&(N==null?void 0:N.restarting)!=null;if(s.version!==null&&(T||v.version!==s.version||v.protocol!==fa)){g.dispose(),t.reload();return}if(v.protocol!==fa){r.dispatch({a:"incompatible"}),g.dispose();return}}else if(v.protocol!==fa){r.dispatch({a:"incompatible"}),g.suspend();return}else r.getState().incompatible&&r.dispatch({a:"incompatible",v:!1});s.version=v.version;const _=new Set(g.sentWhileDown());if(_.size){const x=N=>Object.fromEntries(Object.entries(N).filter(([T])=>!_.has(T)));v.drafts=x(v.drafts),v.attachments=x(v.attachments)}m=yE(r,g,v),c.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&&!c.heard(v.boxId,v.text))){if(HL(v)){o.deliver(v);return}if(WL(v)){if(v.t==="file-written"&&l3(v))return;h.receive(v);return}if(v.t==="loose-written"){BW(v);return}if(AF(v)){MF(r,g,v);return}if(v.t==="open-refused"){OF(r,v);return}a(f.hear(v));for(const _ of m.splice(0))r.dispatch({a:"notice",id:_,text:wE})}},(v,_)=>r.dispatch({a:"connected",v,failure:_}),{},{known:()=>tz(r.getState()),held:e.serving});f3(r,g.urls),h=new zW({store:r,send:v=>g.send(v),timers:{set:(v,_)=>setTimeout(v,_),clear:v=>clearTimeout(v)},win:window});const y=h.start();c=nV(r,g),u=rV(r,g);const w=oV(r,g);return{origin:e.origin,serving:e.serving,token:e.token,get name(){return r.getState().machine??YG(e.origin)},store:r,sock:g,files:h,terminals:o,storage:n,heard:s,recalled:f.recalled,forget:()=>f.forget(),boot(v){try{if((v==null?void 0:v.t)==="hello"&&v.protocol===fa){s.version??(s.version=v.version);const _=yE(r,g,v);u.hello(v.attachments),r.dispatch({a:"server",msg:v});for(const x of _)r.dispatch({a:"notice",id:x,text:wE})}}finally{g.resume()}},since:v=>{var _;return(_=r.getState().local[v])!=null&&_.chat.length?f.since(v):void 0},dispose(){g.dispose(),y(),c.dispose(),u.dispose(),w(),f.dispose()}}}function Nf(e){try{return localStorage.getItem(e)}catch{return null}}window.__toyonShell=!0;const sC=xN();sC&&(document.documentElement.dataset.framed="");i4(location.origin);const iC=sZ();Z$(iC);function iV(e,t){try{return e.getItem(t)}catch{return null}}function aV(){const e=iV(sessionStorage,tt.client);if(e)return e;const t=Math.random().toString(36).slice(2,10);try{sessionStorage.setItem(tt.client,t)}catch{}return t}const lV={cached:iC,systemDark:aZ(),daylight:cZ(),clientId:aV(),frame:Vw(),touch:i6(),reload:()=>window.location.reload(),snapshots:nC()},ms=pq({serving:{origin:location.origin,token:RS()},build:e=>sV(e,lV)});a6({dispatch:e=>ms.broadcast(e)});dZ(e=>ms.broadcast({a:"system-dark",v:e}));const aC=e=>sC?()=>{}:Qq(e);let vE=aC(ms.active().store),bE=ms.active();ms.subscribe(()=>{const e=ms.active();e!==bE&&(bE=e,vE(),e.store.getState().frame==="phone"&&e.store.dispatch({a:"screen",to:"home"}),vE=aC(e.store))});window.addEventListener("vite:preloadError",X6);const cV=Promise.all([(window.toyonBoot??Promise.resolve(null)).then(e=>{const t=e;ms.active().boot(t&&typeof t=="object"&&t.t==="hello"?t:null)}),ms.active().recalled]).catch(e=>{console.error("boot",e)});function uV(e){OS(e),window.location.reload()}const dV=cA.createRoot(document.getElementById("root"));cV.then(()=>{var e;SE.flushSync(()=>dV.render(d.jsx(oA.StrictMode,{children:d.jsx(Yw,{children:Vf()?d.jsx(cz,{machines:ms,children:d.jsx(zG,{})}):d.jsx(FG,{origin:location.origin,machine:location.host,onToken:uV})})}))),document.documentElement.style.removeProperty("background"),document.documentElement.style.removeProperty("--boot-ink"),(e=document.getElementById("boot"))==null||e.remove(),Vf()&&WG(ms.active().store)});"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{});export{Fs as F,Pk as _,fr as a,dw as b,gV as c,at as d,wV as e,pV as f,OE as g,VP as h,yA as i,d as j,aF as k,ry as l,RE as m,hV as n,mV as p,S as r,BP as s,Pu as t,kV as u,Ob as w};