toyon 0.10.0 → 0.11.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.
- package/dist/cli.js +23 -23
- package/dist/daemon.js +1481 -440
- package/dist/shell/assets/{Editor-DL0q1Bu5.js → Editor-Cs_OeWSx.js} +3 -3
- package/dist/shell/assets/XTerm-Dc6Bk52B.js +58 -0
- package/dist/shell/assets/{cssMode-Et22hXpa.js → cssMode-D8uDYrHJ.js} +1 -1
- package/dist/shell/assets/{freemarker2-Clz20PcM.js → freemarker2-DlU9uDzS.js} +1 -1
- package/dist/shell/assets/{grammar-CPvdB3az.js → grammar-BSzyJU-q.js} +1 -1
- package/dist/shell/assets/{handlebars-B4nvXAx8.js → handlebars-B66kGi_7.js} +1 -1
- package/dist/shell/assets/{html-DPIGgBLK.js → html-D6juOeyd.js} +1 -1
- package/dist/shell/assets/{htmlMode-C2LaVuEX.js → htmlMode-CbTT-4ZV.js} +1 -1
- package/dist/shell/assets/index-B4KJ--q9.css +1 -0
- package/dist/shell/assets/index-Cj-6Xixu.js +268 -0
- package/dist/shell/assets/{javascript-CnwJfTbN.js → javascript-CHwG4FvH.js} +1 -1
- package/dist/shell/assets/{jsonMode-8znCTiqR.js → jsonMode-DzTEiaKX.js} +1 -1
- package/dist/shell/assets/{liquid-Bdm-1CUh.js → liquid-wddZX4zw.js} +1 -1
- package/dist/shell/assets/{lspLanguageFeatures-B1DMU7yH.js → lspLanguageFeatures-BlqDZ6dO.js} +1 -1
- package/dist/shell/assets/{mdx-Ktcqo9Jf.js → mdx-Dlz2LIv9.js} +1 -1
- package/dist/shell/assets/{python-QX--d8LR.js → python-DvkArqZY.js} +1 -1
- package/dist/shell/assets/{razor-C0LrXteG.js → razor-bDLQ0jQf.js} +1 -1
- package/dist/shell/assets/{tsMode-BtYCp6db.js → tsMode-B_NomV_y.js} +1 -1
- package/dist/shell/assets/{xml-BXbaQ9MG.js → xml-CBYJrQiV.js} +1 -1
- package/dist/shell/assets/{yaml-C6FhaU_C.js → yaml-DnmVK8S2.js} +1 -1
- package/dist/shell/index.html +2 -2
- package/package.json +1 -1
- package/dist/shell/assets/XTerm-C9YH4Lh2.js +0 -58
- package/dist/shell/assets/index-2QusTgw-.js +0 -262
- package/dist/shell/assets/index-TaJLoLSd.css +0 -1
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Editor-Cs_OeWSx.js","assets/grammar-BSzyJU-q.js","assets/Editor-CB2SckMT.css","assets/XTerm-Dc6Bk52B.js","assets/XTerm-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
var $T=Object.defineProperty;var OT=(e,t,n)=>t in e?$T(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var jt=(e,t,n)=>OT(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 i of o)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();function Qb(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Qh={exports:{}},jl={},Xh={exports:{}},Zt={};/**
|
|
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 jw;function MT(){if(jw)return Zt;jw=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"),i=Symbol.for("react.provider"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),g=Symbol.iterator;function m(P){return P===null||typeof P!="object"?null:(P=g&&P[g]||P["@@iterator"],typeof P=="function"?P:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,b={};function E(P,W,xe){this.props=P,this.context=W,this.refs=b,this.updater=xe||y}E.prototype.isReactComponent={},E.prototype.setState=function(P,W){if(typeof P!="object"&&typeof P!="function"&&P!=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,P,W,"setState")},E.prototype.forceUpdate=function(P){this.updater.enqueueForceUpdate(this,P,"forceUpdate")};function N(){}N.prototype=E.prototype;function j(P,W,xe){this.props=P,this.context=W,this.refs=b,this.updater=xe||y}var T=j.prototype=new N;T.constructor=j,w(T,E.prototype),T.isPureReactComponent=!0;var O=Array.isArray,U=Object.prototype.hasOwnProperty,Q={current:null},R={key:!0,ref:!0,__self:!0,__source:!0};function I(P,W,xe){var ce,me={},_e=null,ae=null;if(W!=null)for(ce in W.ref!==void 0&&(ae=W.ref),W.key!==void 0&&(_e=""+W.key),W)U.call(W,ce)&&!R.hasOwnProperty(ce)&&(me[ce]=W[ce]);var be=arguments.length-2;if(be===1)me.children=xe;else if(1<be){for(var ze=Array(be),re=0;re<be;re++)ze[re]=arguments[re+2];me.children=ze}if(P&&P.defaultProps)for(ce in be=P.defaultProps,be)me[ce]===void 0&&(me[ce]=be[ce]);return{$$typeof:e,type:P,key:_e,ref:ae,props:me,_owner:Q.current}}function _(P,W){return{$$typeof:e,type:P.type,key:W,ref:P.ref,props:P.props,_owner:P._owner}}function L(P){return typeof P=="object"&&P!==null&&P.$$typeof===e}function z(P){var W={"=":"=0",":":"=2"};return"$"+P.replace(/[=:]/g,function(xe){return W[xe]})}var F=/\/+/g;function ee(P,W){return typeof P=="object"&&P!==null&&P.key!=null?z(""+P.key):W.toString(36)}function se(P,W,xe,ce,me){var _e=typeof P;(_e==="undefined"||_e==="boolean")&&(P=null);var ae=!1;if(P===null)ae=!0;else switch(_e){case"string":case"number":ae=!0;break;case"object":switch(P.$$typeof){case e:case t:ae=!0}}if(ae)return ae=P,me=me(ae),P=ce===""?"."+ee(ae,0):ce,O(me)?(xe="",P!=null&&(xe=P.replace(F,"$&/")+"/"),se(me,W,xe,"",function(re){return re})):me!=null&&(L(me)&&(me=_(me,xe+(!me.key||ae&&ae.key===me.key?"":(""+me.key).replace(F,"$&/")+"/")+P)),W.push(me)),1;if(ae=0,ce=ce===""?".":ce+":",O(P))for(var be=0;be<P.length;be++){_e=P[be];var ze=ce+ee(_e,be);ae+=se(_e,W,xe,ze,me)}else if(ze=m(P),typeof ze=="function")for(P=ze.call(P),be=0;!(_e=P.next()).done;)_e=_e.value,ze=ce+ee(_e,be++),ae+=se(_e,W,xe,ze,me);else if(_e==="object")throw W=String(P),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(P).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.");return ae}function fe(P,W,xe){if(P==null)return P;var ce=[],me=0;return se(P,ce,"","",function(_e){return W.call(xe,_e,me++)}),ce}function ke(P){if(P._status===-1){var W=P._result;W=W(),W.then(function(xe){(P._status===0||P._status===-1)&&(P._status=1,P._result=xe)},function(xe){(P._status===0||P._status===-1)&&(P._status=2,P._result=xe)}),P._status===-1&&(P._status=0,P._result=W)}if(P._status===1)return P._result.default;throw P._result}var ne={current:null},A={transition:null},q={ReactCurrentDispatcher:ne,ReactCurrentBatchConfig:A,ReactCurrentOwner:Q};function ie(){throw Error("act(...) is not supported in production builds of React.")}return Zt.Children={map:fe,forEach:function(P,W,xe){fe(P,function(){W.apply(this,arguments)},xe)},count:function(P){var W=0;return fe(P,function(){W++}),W},toArray:function(P){return fe(P,function(W){return W})||[]},only:function(P){if(!L(P))throw Error("React.Children.only expected to receive a single React element child.");return P}},Zt.Component=E,Zt.Fragment=n,Zt.Profiler=o,Zt.PureComponent=j,Zt.StrictMode=r,Zt.Suspense=c,Zt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=q,Zt.act=ie,Zt.cloneElement=function(P,W,xe){if(P==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+P+".");var ce=w({},P.props),me=P.key,_e=P.ref,ae=P._owner;if(W!=null){if(W.ref!==void 0&&(_e=W.ref,ae=Q.current),W.key!==void 0&&(me=""+W.key),P.type&&P.type.defaultProps)var be=P.type.defaultProps;for(ze in W)U.call(W,ze)&&!R.hasOwnProperty(ze)&&(ce[ze]=W[ze]===void 0&&be!==void 0?be[ze]:W[ze])}var ze=arguments.length-2;if(ze===1)ce.children=xe;else if(1<ze){be=Array(ze);for(var re=0;re<ze;re++)be[re]=arguments[re+2];ce.children=be}return{$$typeof:e,type:P.type,key:me,ref:_e,props:ce,_owner:ae}},Zt.createContext=function(P){return P={$$typeof:l,_currentValue:P,_currentValue2:P,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},P.Provider={$$typeof:i,_context:P},P.Consumer=P},Zt.createElement=I,Zt.createFactory=function(P){var W=I.bind(null,P);return W.type=P,W},Zt.createRef=function(){return{current:null}},Zt.forwardRef=function(P){return{$$typeof:u,render:P}},Zt.isValidElement=L,Zt.lazy=function(P){return{$$typeof:p,_payload:{_status:-1,_result:P},_init:ke}},Zt.memo=function(P,W){return{$$typeof:h,type:P,compare:W===void 0?null:W}},Zt.startTransition=function(P){var W=A.transition;A.transition={};try{P()}finally{A.transition=W}},Zt.unstable_act=ie,Zt.useCallback=function(P,W){return ne.current.useCallback(P,W)},Zt.useContext=function(P){return ne.current.useContext(P)},Zt.useDebugValue=function(){},Zt.useDeferredValue=function(P){return ne.current.useDeferredValue(P)},Zt.useEffect=function(P,W){return ne.current.useEffect(P,W)},Zt.useId=function(){return ne.current.useId()},Zt.useImperativeHandle=function(P,W,xe){return ne.current.useImperativeHandle(P,W,xe)},Zt.useInsertionEffect=function(P,W){return ne.current.useInsertionEffect(P,W)},Zt.useLayoutEffect=function(P,W){return ne.current.useLayoutEffect(P,W)},Zt.useMemo=function(P,W){return ne.current.useMemo(P,W)},Zt.useReducer=function(P,W,xe){return ne.current.useReducer(P,W,xe)},Zt.useRef=function(P){return ne.current.useRef(P)},Zt.useState=function(P){return ne.current.useState(P)},Zt.useSyncExternalStore=function(P,W,xe){return ne.current.useSyncExternalStore(P,W,xe)},Zt.useTransition=function(){return ne.current.useTransition()},Zt.version="18.3.1",Zt}var Cw;function Um(){return Cw||(Cw=1,Xh.exports=MT()),Xh.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 Aw;function LT(){if(Aw)return jl;Aw=1;var e=Um(),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,i={key:!0,ref:!0,__self:!0,__source:!0};function l(u,c,h){var p,g={},m=null,y=null;h!==void 0&&(m=""+h),c.key!==void 0&&(m=""+c.key),c.ref!==void 0&&(y=c.ref);for(p in c)r.call(c,p)&&!i.hasOwnProperty(p)&&(g[p]=c[p]);if(u&&u.defaultProps)for(p in c=u.defaultProps,c)g[p]===void 0&&(g[p]=c[p]);return{$$typeof:t,type:u,key:m,ref:y,props:g,_owner:o.current}}return jl.Fragment=n,jl.jsx=l,jl.jsxs=l,jl}var Iw;function PT(){return Iw||(Iw=1,Qh.exports=LT()),Qh.exports}var f=PT(),S=Um();const DT=Qb(S);var $u={},Jh={exports:{}},Kr={},ep={exports:{}},tp={};/**
|
|
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 Rw;function zT(){return Rw||(Rw=1,(function(e){function t(A,q){var ie=A.length;A.push(q);e:for(;0<ie;){var P=ie-1>>>1,W=A[P];if(0<o(W,q))A[P]=q,A[ie]=W,ie=P;else break e}}function n(A){return A.length===0?null:A[0]}function r(A){if(A.length===0)return null;var q=A[0],ie=A.pop();if(ie!==q){A[0]=ie;e:for(var P=0,W=A.length,xe=W>>>1;P<xe;){var ce=2*(P+1)-1,me=A[ce],_e=ce+1,ae=A[_e];if(0>o(me,ie))_e<W&&0>o(ae,me)?(A[P]=ae,A[_e]=ie,P=_e):(A[P]=me,A[ce]=ie,P=ce);else if(_e<W&&0>o(ae,ie))A[P]=ae,A[_e]=ie,P=_e;else break e}}return q}function o(A,q){var ie=A.sortIndex-q.sortIndex;return ie!==0?ie:A.id-q.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,u=l.now();e.unstable_now=function(){return l.now()-u}}var c=[],h=[],p=1,g=null,m=3,y=!1,w=!1,b=!1,E=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,j=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(A){for(var q=n(h);q!==null;){if(q.callback===null)r(h);else if(q.startTime<=A)r(h),q.sortIndex=q.expirationTime,t(c,q);else break;q=n(h)}}function O(A){if(b=!1,T(A),!w)if(n(c)!==null)w=!0,ke(U);else{var q=n(h);q!==null&&ne(O,q.startTime-A)}}function U(A,q){w=!1,b&&(b=!1,N(I),I=-1),y=!0;var ie=m;try{for(T(q),g=n(c);g!==null&&(!(g.expirationTime>q)||A&&!z());){var P=g.callback;if(typeof P=="function"){g.callback=null,m=g.priorityLevel;var W=P(g.expirationTime<=q);q=e.unstable_now(),typeof W=="function"?g.callback=W:g===n(c)&&r(c),T(q)}else r(c);g=n(c)}if(g!==null)var xe=!0;else{var ce=n(h);ce!==null&&ne(O,ce.startTime-q),xe=!1}return xe}finally{g=null,m=ie,y=!1}}var Q=!1,R=null,I=-1,_=5,L=-1;function z(){return!(e.unstable_now()-L<_)}function F(){if(R!==null){var A=e.unstable_now();L=A;var q=!0;try{q=R(!0,A)}finally{q?ee():(Q=!1,R=null)}}else Q=!1}var ee;if(typeof j=="function")ee=function(){j(F)};else if(typeof MessageChannel<"u"){var se=new MessageChannel,fe=se.port2;se.port1.onmessage=F,ee=function(){fe.postMessage(null)}}else ee=function(){E(F,0)};function ke(A){R=A,Q||(Q=!0,ee())}function ne(A,q){I=E(function(){A(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(A){A.callback=null},e.unstable_continueExecution=function(){w||y||(w=!0,ke(U))},e.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):_=0<A?Math.floor(1e3/A):5},e.unstable_getCurrentPriorityLevel=function(){return m},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(A){switch(m){case 1:case 2:case 3:var q=3;break;default:q=m}var ie=m;m=q;try{return A()}finally{m=ie}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(A,q){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var ie=m;m=A;try{return q()}finally{m=ie}},e.unstable_scheduleCallback=function(A,q,ie){var P=e.unstable_now();switch(typeof ie=="object"&&ie!==null?(ie=ie.delay,ie=typeof ie=="number"&&0<ie?P+ie:P):ie=P,A){case 1:var W=-1;break;case 2:W=250;break;case 5:W=1073741823;break;case 4:W=1e4;break;default:W=5e3}return W=ie+W,A={id:p++,callback:q,priorityLevel:A,startTime:ie,expirationTime:W,sortIndex:-1},ie>P?(A.sortIndex=ie,t(h,A),n(c)===null&&A===n(h)&&(b?(N(I),I=-1):b=!0,ne(O,ie-P))):(A.sortIndex=W,t(c,A),w||y||(w=!0,ke(U))),A},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(A){var q=m;return function(){var ie=m;m=q;try{return A.apply(this,arguments)}finally{m=ie}}}})(tp)),tp}var $w;function FT(){return $w||($w=1,ep.exports=zT()),ep.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 Ow;function BT(){if(Ow)return Kr;Ow=1;var e=Um(),t=FT();function n(s){for(var a="https://reactjs.org/docs/error-decoder.html?invariant="+s,d=1;d<arguments.length;d++)a+="&args[]="+encodeURIComponent(arguments[d]);return"Minified React error #"+s+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function i(s,a){l(s,a),l(s+"Capture",a)}function l(s,a){for(o[s]=a,s=0;s<a.length;s++)r.add(a[s])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),c=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]*$/,p={},g={};function m(s){return c.call(g,s)?!0:c.call(p,s)?!1:h.test(s)?g[s]=!0:(p[s]=!0,!1)}function y(s,a,d,k){if(d!==null&&d.type===0)return!1;switch(typeof a){case"function":case"symbol":return!0;case"boolean":return k?!1:d!==null?!d.acceptsBooleans:(s=s.toLowerCase().slice(0,5),s!=="data-"&&s!=="aria-");default:return!1}}function w(s,a,d,k){if(a===null||typeof a>"u"||y(s,a,d,k))return!0;if(k)return!1;if(d!==null)switch(d.type){case 3:return!a;case 4:return a===!1;case 5:return isNaN(a);case 6:return isNaN(a)||1>a}return!1}function b(s,a,d,k,v,x,C){this.acceptsBooleans=a===2||a===3||a===4,this.attributeName=k,this.attributeNamespace=v,this.mustUseProperty=d,this.propertyName=s,this.type=a,this.sanitizeURL=x,this.removeEmptyString=C}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(s){E[s]=new b(s,0,!1,s,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(s){var a=s[0];E[a]=new b(a,1,!1,s[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(s){E[s]=new b(s,2,!1,s.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(s){E[s]=new b(s,2,!1,s,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(s){E[s]=new b(s,3,!1,s.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(s){E[s]=new b(s,3,!0,s,null,!1,!1)}),["capture","download"].forEach(function(s){E[s]=new b(s,4,!1,s,null,!1,!1)}),["cols","rows","size","span"].forEach(function(s){E[s]=new b(s,6,!1,s,null,!1,!1)}),["rowSpan","start"].forEach(function(s){E[s]=new b(s,5,!1,s.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function j(s){return s[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(s){var a=s.replace(N,j);E[a]=new b(a,1,!1,s,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(s){var a=s.replace(N,j);E[a]=new b(a,1,!1,s,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(s){var a=s.replace(N,j);E[a]=new b(a,1,!1,s,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(s){E[s]=new b(s,1,!1,s.toLowerCase(),null,!1,!1)}),E.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(s){E[s]=new b(s,1,!1,s.toLowerCase(),null,!0,!0)});function T(s,a,d,k){var v=E.hasOwnProperty(a)?E[a]:null;(v!==null?v.type!==0:k||!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(w(a,d,v,k)&&(d=null),k||v===null?m(a)&&(d===null?s.removeAttribute(a):s.setAttribute(a,""+d)):v.mustUseProperty?s[v.propertyName]=d===null?v.type===3?!1:"":d:(a=v.attributeName,k=v.attributeNamespace,d===null?s.removeAttribute(a):(v=v.type,d=v===3||v===4&&d===!0?"":""+d,k?s.setAttributeNS(k,a,d):s.setAttribute(a,d))))}var O=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,U=Symbol.for("react.element"),Q=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),L=Symbol.for("react.provider"),z=Symbol.for("react.context"),F=Symbol.for("react.forward_ref"),ee=Symbol.for("react.suspense"),se=Symbol.for("react.suspense_list"),fe=Symbol.for("react.memo"),ke=Symbol.for("react.lazy"),ne=Symbol.for("react.offscreen"),A=Symbol.iterator;function q(s){return s===null||typeof s!="object"?null:(s=A&&s[A]||s["@@iterator"],typeof s=="function"?s:null)}var ie=Object.assign,P;function W(s){if(P===void 0)try{throw Error()}catch(d){var a=d.stack.trim().match(/\n( *(at )?)/);P=a&&a[1]||""}return`
|
|
35
|
+
`+P+s}var xe=!1;function ce(s,a){if(!s||xe)return"";xe=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(a)if(a=function(){throw Error()},Object.defineProperty(a.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(a,[])}catch(le){var k=le}Reflect.construct(s,[],a)}else{try{a.call()}catch(le){k=le}s.call(a.prototype)}else{try{throw Error()}catch(le){k=le}s()}}catch(le){if(le&&k&&typeof le.stack=="string"){for(var v=le.stack.split(`
|
|
36
|
+
`),x=k.stack.split(`
|
|
37
|
+
`),C=v.length-1,H=x.length-1;1<=C&&0<=H&&v[C]!==x[H];)H--;for(;1<=C&&0<=H;C--,H--)if(v[C]!==x[H]){if(C!==1||H!==1)do if(C--,H--,0>H||v[C]!==x[H]){var G=`
|
|
38
|
+
`+v[C].replace(" at new "," at ");return s.displayName&&G.includes("<anonymous>")&&(G=G.replace("<anonymous>",s.displayName)),G}while(1<=C&&0<=H);break}}}finally{xe=!1,Error.prepareStackTrace=d}return(s=s?s.displayName||s.name:"")?W(s):""}function me(s){switch(s.tag){case 5:return W(s.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return s=ce(s.type,!1),s;case 11:return s=ce(s.type.render,!1),s;case 1:return s=ce(s.type,!0),s;default:return""}}function _e(s){if(s==null)return null;if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case R:return"Fragment";case Q:return"Portal";case _:return"Profiler";case I:return"StrictMode";case ee:return"Suspense";case se:return"SuspenseList"}if(typeof s=="object")switch(s.$$typeof){case z:return(s.displayName||"Context")+".Consumer";case L:return(s._context.displayName||"Context")+".Provider";case F:var a=s.render;return s=s.displayName,s||(s=a.displayName||a.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case fe:return a=s.displayName||null,a!==null?a:_e(s.type)||"Memo";case ke:a=s._payload,s=s._init;try{return _e(s(a))}catch{}}return null}function ae(s){var a=s.type;switch(s.tag){case 24:return"Cache";case 9:return(a.displayName||"Context")+".Consumer";case 10:return(a._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return s=a.render,s=s.displayName||s.name||"",a.displayName||(s!==""?"ForwardRef("+s+")":"ForwardRef");case 7:return"Fragment";case 5:return a;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return _e(a);case 8:return a===I?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a}return null}function be(s){switch(typeof s){case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function ze(s){var a=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function re(s){var a=ze(s)?"checked":"value",d=Object.getOwnPropertyDescriptor(s.constructor.prototype,a),k=""+s[a];if(!s.hasOwnProperty(a)&&typeof d<"u"&&typeof d.get=="function"&&typeof d.set=="function"){var v=d.get,x=d.set;return Object.defineProperty(s,a,{configurable:!0,get:function(){return v.call(this)},set:function(C){k=""+C,x.call(this,C)}}),Object.defineProperty(s,a,{enumerable:d.enumerable}),{getValue:function(){return k},setValue:function(C){k=""+C},stopTracking:function(){s._valueTracker=null,delete s[a]}}}}function he(s){s._valueTracker||(s._valueTracker=re(s))}function pe(s){if(!s)return!1;var a=s._valueTracker;if(!a)return!0;var d=a.getValue(),k="";return s&&(k=ze(s)?s.checked?"true":"false":s.value),s=k,s!==d?(a.setValue(s),!0):!1}function Te(s){if(s=s||(typeof document<"u"?document:void 0),typeof s>"u")return null;try{return s.activeElement||s.body}catch{return s.body}}function Ue(s,a){var d=a.checked;return ie({},a,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:d??s._wrapperState.initialChecked})}function ct(s,a){var d=a.defaultValue==null?"":a.defaultValue,k=a.checked!=null?a.checked:a.defaultChecked;d=be(a.value!=null?a.value:d),s._wrapperState={initialChecked:k,initialValue:d,controlled:a.type==="checkbox"||a.type==="radio"?a.checked!=null:a.value!=null}}function We(s,a){a=a.checked,a!=null&&T(s,"checked",a,!1)}function xn(s,a){We(s,a);var d=be(a.value),k=a.type;if(d!=null)k==="number"?(d===0&&s.value===""||s.value!=d)&&(s.value=""+d):s.value!==""+d&&(s.value=""+d);else if(k==="submit"||k==="reset"){s.removeAttribute("value");return}a.hasOwnProperty("value")?It(s,a.type,d):a.hasOwnProperty("defaultValue")&&It(s,a.type,be(a.defaultValue)),a.checked==null&&a.defaultChecked!=null&&(s.defaultChecked=!!a.defaultChecked)}function Ht(s,a,d){if(a.hasOwnProperty("value")||a.hasOwnProperty("defaultValue")){var k=a.type;if(!(k!=="submit"&&k!=="reset"||a.value!==void 0&&a.value!==null))return;a=""+s._wrapperState.initialValue,d||a===s.value||(s.value=a),s.defaultValue=a}d=s.name,d!==""&&(s.name=""),s.defaultChecked=!!s._wrapperState.initialChecked,d!==""&&(s.name=d)}function It(s,a,d){(a!=="number"||Te(s.ownerDocument)!==s)&&(d==null?s.defaultValue=""+s._wrapperState.initialValue:s.defaultValue!==""+d&&(s.defaultValue=""+d))}var nt=Array.isArray;function Ve(s,a,d,k){if(s=s.options,a){a={};for(var v=0;v<d.length;v++)a["$"+d[v]]=!0;for(d=0;d<s.length;d++)v=a.hasOwnProperty("$"+s[d].value),s[d].selected!==v&&(s[d].selected=v),v&&k&&(s[d].defaultSelected=!0)}else{for(d=""+be(d),a=null,v=0;v<s.length;v++){if(s[v].value===d){s[v].selected=!0,k&&(s[v].defaultSelected=!0);return}a!==null||s[v].disabled||(a=s[v])}a!==null&&(a.selected=!0)}}function mt(s,a){if(a.dangerouslySetInnerHTML!=null)throw Error(n(91));return ie({},a,{value:void 0,defaultValue:void 0,children:""+s._wrapperState.initialValue})}function En(s,a){var d=a.value;if(d==null){if(d=a.children,a=a.defaultValue,d!=null){if(a!=null)throw Error(n(92));if(nt(d)){if(1<d.length)throw Error(n(93));d=d[0]}a=d}a==null&&(a=""),d=a}s._wrapperState={initialValue:be(d)}}function Rt(s,a){var d=be(a.value),k=be(a.defaultValue);d!=null&&(d=""+d,d!==s.value&&(s.value=d),a.defaultValue==null&&s.defaultValue!==d&&(s.defaultValue=d)),k!=null&&(s.defaultValue=""+k)}function V(s){var a=s.textContent;a===s._wrapperState.initialValue&&a!==""&&a!==null&&(s.value=a)}function ge(s){switch(s){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 ft(s,a){return s==null||s==="http://www.w3.org/1999/xhtml"?ge(a):s==="http://www.w3.org/2000/svg"&&a==="foreignObject"?"http://www.w3.org/1999/xhtml":s}var qe,un=(function(s){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(a,d,k,v){MSApp.execUnsafeLocalFunction(function(){return s(a,d,k,v)})}:s})(function(s,a){if(s.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in s)s.innerHTML=a;else{for(qe=qe||document.createElement("div"),qe.innerHTML="<svg>"+a.valueOf().toString()+"</svg>",a=qe.firstChild;s.firstChild;)s.removeChild(s.firstChild);for(;a.firstChild;)s.appendChild(a.firstChild)}});function yn(s,a){if(a){var d=s.firstChild;if(d&&d===s.lastChild&&d.nodeType===3){d.nodeValue=a;return}}s.textContent=a}var Tn={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},gt=["Webkit","ms","Moz","O"];Object.keys(Tn).forEach(function(s){gt.forEach(function(a){a=a+s.charAt(0).toUpperCase()+s.substring(1),Tn[a]=Tn[s]})});function jn(s,a,d){return a==null||typeof a=="boolean"||a===""?"":d||typeof a!="number"||a===0||Tn.hasOwnProperty(s)&&Tn[s]?(""+a).trim():a+"px"}function ye(s,a){s=s.style;for(var d in a)if(a.hasOwnProperty(d)){var k=d.indexOf("--")===0,v=jn(d,a[d],k);d==="float"&&(d="cssFloat"),k?s.setProperty(d,v):s[d]=v}}var Le=ie({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 wn(s,a){if(a){if(Le[s]&&(a.children!=null||a.dangerouslySetInnerHTML!=null))throw Error(n(137,s));if(a.dangerouslySetInnerHTML!=null){if(a.children!=null)throw Error(n(60));if(typeof a.dangerouslySetInnerHTML!="object"||!("__html"in a.dangerouslySetInnerHTML))throw Error(n(61))}if(a.style!=null&&typeof a.style!="object")throw Error(n(62))}}function _n(s,a){if(s.indexOf("-")===-1)return typeof a.is=="string";switch(s){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 Sn=null;function sn(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var In=null,ot=null,Wt=null;function Qt(s){if(s=hl(s)){if(typeof In!="function")throw Error(n(280));var a=s.stateNode;a&&(a=Gc(a),In(s.stateNode,s.type,a))}}function B(s){ot?Wt?Wt.push(s):Wt=[s]:ot=s}function ue(){if(ot){var s=ot,a=Wt;if(Wt=ot=null,Qt(s),a)for(s=0;s<a.length;s++)Qt(a[s])}}function Ie(s,a){return s(a)}function Je(){}var Ot=!1;function $t(s,a,d){if(Ot)return s(a,d);Ot=!0;try{return Ie(s,a,d)}finally{Ot=!1,(ot!==null||Wt!==null)&&(Je(),ue())}}function Oe(s,a){var d=s.stateNode;if(d===null)return null;var k=Gc(d);if(k===null)return null;d=k[a];e:switch(a){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)||(s=s.type,k=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!k;break e;default:s=!1}if(s)return null;if(d&&typeof d!="function")throw Error(n(231,a,typeof d));return d}var Me=!1;if(u)try{var Ye={};Object.defineProperty(Ye,"passive",{get:function(){Me=!0}}),window.addEventListener("test",Ye,Ye),window.removeEventListener("test",Ye,Ye)}catch{Me=!1}function Pt(s,a,d,k,v,x,C,H,G){var le=Array.prototype.slice.call(arguments,3);try{a.apply(d,le)}catch(Ne){this.onError(Ne)}}var X=!1,$e=null,kt=!1,Nt=null,Dt={onError:function(s){X=!0,$e=s}};function an(s,a,d,k,v,x,C,H,G){X=!1,$e=null,Pt.apply(Dt,arguments)}function Mt(s,a,d,k,v,x,C,H,G){if(an.apply(this,arguments),X){if(X){var le=$e;X=!1,$e=null}else throw Error(n(198));kt||(kt=!0,Nt=le)}}function zt(s){var a=s,d=s;if(s.alternate)for(;a.return;)a=a.return;else{s=a;do a=s,(a.flags&4098)!==0&&(d=a.return),s=a.return;while(s)}return a.tag===3?d:null}function Vt(s){if(s.tag===13){var a=s.memoizedState;if(a===null&&(s=s.alternate,s!==null&&(a=s.memoizedState)),a!==null)return a.dehydrated}return null}function Qe(s){if(zt(s)!==s)throw Error(n(188))}function vn(s){var a=s.alternate;if(!a){if(a=zt(s),a===null)throw Error(n(188));return a!==s?null:s}for(var d=s,k=a;;){var v=d.return;if(v===null)break;var x=v.alternate;if(x===null){if(k=v.return,k!==null){d=k;continue}break}if(v.child===x.child){for(x=v.child;x;){if(x===d)return Qe(v),s;if(x===k)return Qe(v),a;x=x.sibling}throw Error(n(188))}if(d.return!==k.return)d=v,k=x;else{for(var C=!1,H=v.child;H;){if(H===d){C=!0,d=v,k=x;break}if(H===k){C=!0,k=v,d=x;break}H=H.sibling}if(!C){for(H=x.child;H;){if(H===d){C=!0,d=x,k=v;break}if(H===k){C=!0,k=x,d=v;break}H=H.sibling}if(!C)throw Error(n(189))}}if(d.alternate!==k)throw Error(n(190))}if(d.tag!==3)throw Error(n(188));return d.stateNode.current===d?s:a}function pn(s){return s=vn(s),s!==null?Rn(s):null}function Rn(s){if(s.tag===5||s.tag===6)return s;for(s=s.child;s!==null;){var a=Rn(s);if(a!==null)return a;s=s.sibling}return null}var dn=t.unstable_scheduleCallback,Bt=t.unstable_cancelCallback,cr=t.unstable_shouldYield,Qr=t.unstable_requestPaint,ln=t.unstable_now,rs=t.unstable_getCurrentPriorityLevel,Xr=t.unstable_ImmediatePriority,Zn=t.unstable_UserBlockingPriority,ur=t.unstable_NormalPriority,je=t.unstable_LowPriority,Fe=t.unstable_IdlePriority,lt=null,Et=null;function cn(s){if(Et&&typeof Et.onCommitFiberRoot=="function")try{Et.onCommitFiberRoot(lt,s,void 0,(s.current.flags&128)===128)}catch{}}var mn=Math.clz32?Math.clz32:De,Z=Math.log,de=Math.LN2;function De(s){return s>>>=0,s===0?32:31-(Z(s)/de|0)|0}var ut=64,wt=4194304;function Xt(s){switch(s&-s){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 s&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return s&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return s}}function Dn(s,a){var d=s.pendingLanes;if(d===0)return 0;var k=0,v=s.suspendedLanes,x=s.pingedLanes,C=d&268435455;if(C!==0){var H=C&~v;H!==0?k=Xt(H):(x&=C,x!==0&&(k=Xt(x)))}else C=d&~v,C!==0?k=Xt(C):x!==0&&(k=Xt(x));if(k===0)return 0;if(a!==0&&a!==k&&(a&v)===0&&(v=k&-k,x=a&-a,v>=x||v===16&&(x&4194240)!==0))return a;if((k&4)!==0&&(k|=d&16),a=s.entangledLanes,a!==0)for(s=s.entanglements,a&=k;0<a;)d=31-mn(a),v=1<<d,k|=s[d],a&=~v;return k}function zn(s,a){switch(s){case 1:case 2:case 4:return a+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 a+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 So(s,a){for(var d=s.suspendedLanes,k=s.pingedLanes,v=s.expirationTimes,x=s.pendingLanes;0<x;){var C=31-mn(x),H=1<<C,G=v[C];G===-1?((H&d)===0||(H&k)!==0)&&(v[C]=zn(H,a)):G<=a&&(s.expiredLanes|=H),x&=~H}}function Pr(s){return s=s.pendingLanes&-1073741825,s!==0?s:s&1073741824?1073741824:0}function Bo(){var s=ut;return ut<<=1,(ut&4194240)===0&&(ut=64),s}function Jr(s){for(var a=[],d=0;31>d;d++)a.push(s);return a}function Dr(s,a,d){s.pendingLanes|=a,a!==536870912&&(s.suspendedLanes=0,s.pingedLanes=0),s=s.eventTimes,a=31-mn(a),s[a]=d}function bt(s,a){var d=s.pendingLanes&~a;s.pendingLanes=a,s.suspendedLanes=0,s.pingedLanes=0,s.expiredLanes&=a,s.mutableReadLanes&=a,s.entangledLanes&=a,a=s.entanglements;var k=s.eventTimes;for(s=s.expirationTimes;0<d;){var v=31-mn(d),x=1<<v;a[v]=0,k[v]=-1,s[v]=-1,d&=~x}}function zr(s,a){var d=s.entangledLanes|=a;for(s=s.entanglements;d;){var k=31-mn(d),v=1<<k;v&a|s[k]&a&&(s[k]|=a),d&=~v}}var Kt=0;function dt(s){return s&=-s,1<s?4<s?(s&268435455)!==0?16:536870912:4:1}var Uo,fn,Gt,gr,qn,Ee=!1,$=[],D=null,J=null,we=null,Ce=new Map,He=new Map,vt=[],Ut="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Xn(s,a){switch(s){case"focusin":case"focusout":D=null;break;case"dragenter":case"dragleave":J=null;break;case"mouseover":case"mouseout":we=null;break;case"pointerover":case"pointerout":Ce.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":He.delete(a.pointerId)}}function Gn(s,a,d,k,v,x){return s===null||s.nativeEvent!==x?(s={blockedOn:a,domEventName:d,eventSystemFlags:k,nativeEvent:x,targetContainers:[v]},a!==null&&(a=hl(a),a!==null&&fn(a)),s):(s.eventSystemFlags|=k,a=s.targetContainers,v!==null&&a.indexOf(v)===-1&&a.push(v),s)}function os(s,a,d,k,v){switch(a){case"focusin":return D=Gn(D,s,a,d,k,v),!0;case"dragenter":return J=Gn(J,s,a,d,k,v),!0;case"mouseover":return we=Gn(we,s,a,d,k,v),!0;case"pointerover":var x=v.pointerId;return Ce.set(x,Gn(Ce.get(x)||null,s,a,d,k,v)),!0;case"gotpointercapture":return x=v.pointerId,He.set(x,Gn(He.get(x)||null,s,a,d,k,v)),!0}return!1}function Vn(s){var a=gi(s.target);if(a!==null){var d=zt(a);if(d!==null){if(a=d.tag,a===13){if(a=Vt(d),a!==null){s.blockedOn=a,qn(s.priority,function(){Gt(d)});return}}else if(a===3&&d.stateNode.current.memoizedState.isDehydrated){s.blockedOn=d.tag===3?d.stateNode.containerInfo:null;return}}}s.blockedOn=null}function Ho(s){if(s.blockedOn!==null)return!1;for(var a=s.targetContainers;0<a.length;){var d=di(s.domEventName,s.eventSystemFlags,a[0],s.nativeEvent);if(d===null){d=s.nativeEvent;var k=new d.constructor(d.type,d);Sn=k,d.target.dispatchEvent(k),Sn=null}else return a=hl(d),a!==null&&fn(a),s.blockedOn=d,!1;a.shift()}return!0}function Zi(s,a,d){Ho(s)&&d.delete(a)}function jc(){Ee=!1,D!==null&&Ho(D)&&(D=null),J!==null&&Ho(J)&&(J=null),we!==null&&Ho(we)&&(we=null),Ce.forEach(Zi),He.forEach(Zi)}function ci(s,a){s.blockedOn===a&&(s.blockedOn=null,Ee||(Ee=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,jc)))}function ss(s){function a(v){return ci(v,s)}if(0<$.length){ci($[0],s);for(var d=1;d<$.length;d++){var k=$[d];k.blockedOn===s&&(k.blockedOn=null)}}for(D!==null&&ci(D,s),J!==null&&ci(J,s),we!==null&&ci(we,s),Ce.forEach(a),He.forEach(a),d=0;d<vt.length;d++)k=vt[d],k.blockedOn===s&&(k.blockedOn=null);for(;0<vt.length&&(d=vt[0],d.blockedOn===null);)Vn(d),d.blockedOn===null&&vt.shift()}var js=O.ReactCurrentBatchConfig,ui=!0;function _f(s,a,d,k){var v=Kt,x=js.transition;js.transition=null;try{Kt=1,Xa(s,a,d,k)}finally{Kt=v,js.transition=x}}function Cc(s,a,d,k){var v=Kt,x=js.transition;js.transition=null;try{Kt=4,Xa(s,a,d,k)}finally{Kt=v,js.transition=x}}function Xa(s,a,d,k){if(ui){var v=di(s,a,d,k);if(v===null)Bf(s,a,k,or,d),Xn(s,k);else if(os(v,s,a,d,k))k.stopPropagation();else if(Xn(s,k),a&4&&-1<Ut.indexOf(s)){for(;v!==null;){var x=hl(v);if(x!==null&&Uo(x),x=di(s,a,d,k),x===null&&Bf(s,a,k,or,d),x===v)break;v=x}v!==null&&k.stopPropagation()}else Bf(s,a,k,null,d)}}var or=null;function di(s,a,d,k){if(or=null,s=sn(k),s=gi(s),s!==null)if(a=zt(s),a===null)s=null;else if(d=a.tag,d===13){if(s=Vt(a),s!==null)return s;s=null}else if(d===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;s=null}else a!==s&&(s=null);return or=s,null}function qi(s){switch(s){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(rs()){case Xr:return 1;case Zn:return 4;case ur:case je:return 16;case Fe:return 536870912;default:return 16}default:return 16}}var eo=null,Yn=null,is=null;function Gi(){if(is)return is;var s,a=Yn,d=a.length,k,v="value"in eo?eo.value:eo.textContent,x=v.length;for(s=0;s<d&&a[s]===v[s];s++);var C=d-s;for(k=1;k<=C&&a[d-k]===v[x-k];k++);return is=v.slice(s,1<k?1-k:void 0)}function as(s){var a=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&a===13&&(s=13)):s=a,s===10&&(s=13),32<=s||s===13?s:0}function ls(){return!0}function cs(){return!1}function vr(s){function a(d,k,v,x,C){this._reactName=d,this._targetInst=v,this.type=k,this.nativeEvent=x,this.target=C,this.currentTarget=null;for(var H in s)s.hasOwnProperty(H)&&(d=s[H],this[H]=d?d(x):x[H]);return this.isDefaultPrevented=(x.defaultPrevented!=null?x.defaultPrevented:x.returnValue===!1)?ls:cs,this.isPropagationStopped=cs,this}return ie(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var d=this.nativeEvent;d&&(d.preventDefault?d.preventDefault():typeof d.returnValue!="unknown"&&(d.returnValue=!1),this.isDefaultPrevented=ls)},stopPropagation:function(){var d=this.nativeEvent;d&&(d.stopPropagation?d.stopPropagation():typeof d.cancelBubble!="unknown"&&(d.cancelBubble=!0),this.isPropagationStopped=ls)},persist:function(){},isPersistent:ls}),a}var Wo={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},fi=vr(Wo),Cs=ie({},Wo,{view:0,detail:0}),Ek=vr(Cs),Vi,As,Is,hi=ie({},Cs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Yi,button:0,buttons:0,relatedTarget:function(s){return s.relatedTarget===void 0?s.fromElement===s.srcElement?s.toElement:s.fromElement:s.relatedTarget},movementX:function(s){return"movementX"in s?s.movementX:(s!==Is&&(Is&&s.type==="mousemove"?(Vi=s.screenX-Is.screenX,As=s.screenY-Is.screenY):As=Vi=0,Is=s),Vi)},movementY:function(s){return"movementY"in s?s.movementY:As}}),Ja=vr(hi),er=ie({},hi,{dataTransfer:0}),Sf=vr(er),el=ie({},Cs,{relatedTarget:0}),pi=vr(el),tl=ie({},Wo,{animationName:0,elapsedTime:0,pseudoElement:0}),Nf=vr(tl),nl=ie({},Wo,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),Tf=vr(nl),Ac=ie({},Wo,{data:0}),rl=vr(Ac),jf={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Cf={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"},Ic={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function mi(s){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(s):(s=Ic[s])?!!a[s]:!1}function Yi(){return mi}var Af=ie({},Cs,{key:function(s){if(s.key){var a=jf[s.key]||s.key;if(a!=="Unidentified")return a}return s.type==="keypress"?(s=as(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?Cf[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Yi,charCode:function(s){return s.type==="keypress"?as(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?as(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),If=vr(Af),Rc=ie({},hi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ol=vr(Rc),$c=ie({},Cs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Yi}),Oc=vr($c),Mc=ie({},Wo,{propertyName:0,elapsedTime:0,pseudoElement:0}),Lc=vr(Mc),Pc=ie({},hi,{deltaX:function(s){return"deltaX"in s?s.deltaX:"wheelDeltaX"in s?-s.wheelDeltaX:0},deltaY:function(s){return"deltaY"in s?s.deltaY:"wheelDeltaY"in s?-s.wheelDeltaY:"wheelDelta"in s?-s.wheelDelta:0},deltaZ:0,deltaMode:0}),Dc=vr(Pc),K=[9,13,27,32],Ge=u&&"CompositionEvent"in window,_t=null;u&&"documentMode"in document&&(_t=document.documentMode);var hn=u&&"TextEvent"in window&&!_t,kr=u&&(!Ge||_t&&8<_t&&11>=_t),br=" ",zc=!1;function Fc(s,a){switch(s){case"keyup":return K.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function _k(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var Qi=!1;function AN(s,a){switch(s){case"compositionend":return _k(a);case"keypress":return a.which!==32?null:(zc=!0,br);case"textInput":return s=a.data,s===br&&zc?null:s;default:return null}}function IN(s,a){if(Qi)return s==="compositionend"||!Ge&&Fc(s,a)?(s=Gi(),is=Yn=eo=null,Qi=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1<a.char.length)return a.char;if(a.which)return String.fromCharCode(a.which)}return null;case"compositionend":return kr&&a.locale!=="ko"?null:a.data;default:return null}}var RN={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 Sk(s){var a=s&&s.nodeName&&s.nodeName.toLowerCase();return a==="input"?!!RN[s.type]:a==="textarea"}function Nk(s,a,d,k){B(k),a=Kc(a,"onChange"),0<a.length&&(d=new fi("onChange","change",null,d,k),s.push({event:d,listeners:a}))}var sl=null,il=null;function $N(s){Wk(s,0)}function Bc(s){var a=na(s);if(pe(a))return s}function ON(s,a){if(s==="change")return a}var Tk=!1;if(u){var Rf;if(u){var $f="oninput"in document;if(!$f){var jk=document.createElement("div");jk.setAttribute("oninput","return;"),$f=typeof jk.oninput=="function"}Rf=$f}else Rf=!1;Tk=Rf&&(!document.documentMode||9<document.documentMode)}function Ck(){sl&&(sl.detachEvent("onpropertychange",Ak),il=sl=null)}function Ak(s){if(s.propertyName==="value"&&Bc(il)){var a=[];Nk(a,il,s,sn(s)),$t($N,a)}}function MN(s,a,d){s==="focusin"?(Ck(),sl=a,il=d,sl.attachEvent("onpropertychange",Ak)):s==="focusout"&&Ck()}function LN(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return Bc(il)}function PN(s,a){if(s==="click")return Bc(a)}function DN(s,a){if(s==="input"||s==="change")return Bc(a)}function zN(s,a){return s===a&&(s!==0||1/s===1/a)||s!==s&&a!==a}var No=typeof Object.is=="function"?Object.is:zN;function al(s,a){if(No(s,a))return!0;if(typeof s!="object"||s===null||typeof a!="object"||a===null)return!1;var d=Object.keys(s),k=Object.keys(a);if(d.length!==k.length)return!1;for(k=0;k<d.length;k++){var v=d[k];if(!c.call(a,v)||!No(s[v],a[v]))return!1}return!0}function Ik(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function Rk(s,a){var d=Ik(s);s=0;for(var k;d;){if(d.nodeType===3){if(k=s+d.textContent.length,s<=a&&k>=a)return{node:d,offset:a-s};s=k}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=Ik(d)}}function $k(s,a){return s&&a?s===a?!0:s&&s.nodeType===3?!1:a&&a.nodeType===3?$k(s,a.parentNode):"contains"in s?s.contains(a):s.compareDocumentPosition?!!(s.compareDocumentPosition(a)&16):!1:!1}function Ok(){for(var s=window,a=Te();a instanceof s.HTMLIFrameElement;){try{var d=typeof a.contentWindow.location.href=="string"}catch{d=!1}if(d)s=a.contentWindow;else break;a=Te(s.document)}return a}function Of(s){var a=s&&s.nodeName&&s.nodeName.toLowerCase();return a&&(a==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||a==="textarea"||s.contentEditable==="true")}function FN(s){var a=Ok(),d=s.focusedElem,k=s.selectionRange;if(a!==d&&d&&d.ownerDocument&&$k(d.ownerDocument.documentElement,d)){if(k!==null&&Of(d)){if(a=k.start,s=k.end,s===void 0&&(s=a),"selectionStart"in d)d.selectionStart=a,d.selectionEnd=Math.min(s,d.value.length);else if(s=(a=d.ownerDocument||document)&&a.defaultView||window,s.getSelection){s=s.getSelection();var v=d.textContent.length,x=Math.min(k.start,v);k=k.end===void 0?x:Math.min(k.end,v),!s.extend&&x>k&&(v=k,k=x,x=v),v=Rk(d,x);var C=Rk(d,k);v&&C&&(s.rangeCount!==1||s.anchorNode!==v.node||s.anchorOffset!==v.offset||s.focusNode!==C.node||s.focusOffset!==C.offset)&&(a=a.createRange(),a.setStart(v.node,v.offset),s.removeAllRanges(),x>k?(s.addRange(a),s.extend(C.node,C.offset)):(a.setEnd(C.node,C.offset),s.addRange(a)))}}for(a=[],s=d;s=s.parentNode;)s.nodeType===1&&a.push({element:s,left:s.scrollLeft,top:s.scrollTop});for(typeof d.focus=="function"&&d.focus(),d=0;d<a.length;d++)s=a[d],s.element.scrollLeft=s.left,s.element.scrollTop=s.top}}var BN=u&&"documentMode"in document&&11>=document.documentMode,Xi=null,Mf=null,ll=null,Lf=!1;function Mk(s,a,d){var k=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;Lf||Xi==null||Xi!==Te(k)||(k=Xi,"selectionStart"in k&&Of(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}),ll&&al(ll,k)||(ll=k,k=Kc(Mf,"onSelect"),0<k.length&&(a=new fi("onSelect","select",null,a,d),s.push({event:a,listeners:k}),a.target=Xi)))}function Uc(s,a){var d={};return d[s.toLowerCase()]=a.toLowerCase(),d["Webkit"+s]="webkit"+a,d["Moz"+s]="moz"+a,d}var Ji={animationend:Uc("Animation","AnimationEnd"),animationiteration:Uc("Animation","AnimationIteration"),animationstart:Uc("Animation","AnimationStart"),transitionend:Uc("Transition","TransitionEnd")},Pf={},Lk={};u&&(Lk=document.createElement("div").style,"AnimationEvent"in window||(delete Ji.animationend.animation,delete Ji.animationiteration.animation,delete Ji.animationstart.animation),"TransitionEvent"in window||delete Ji.transitionend.transition);function Hc(s){if(Pf[s])return Pf[s];if(!Ji[s])return s;var a=Ji[s],d;for(d in a)if(a.hasOwnProperty(d)&&d in Lk)return Pf[s]=a[d];return s}var Pk=Hc("animationend"),Dk=Hc("animationiteration"),zk=Hc("animationstart"),Fk=Hc("transitionend"),Bk=new Map,Uk="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 Rs(s,a){Bk.set(s,a),i(a,[s])}for(var Df=0;Df<Uk.length;Df++){var zf=Uk[Df],UN=zf.toLowerCase(),HN=zf[0].toUpperCase()+zf.slice(1);Rs(UN,"on"+HN)}Rs(Pk,"onAnimationEnd"),Rs(Dk,"onAnimationIteration"),Rs(zk,"onAnimationStart"),Rs("dblclick","onDoubleClick"),Rs("focusin","onFocus"),Rs("focusout","onBlur"),Rs(Fk,"onTransitionEnd"),l("onMouseEnter",["mouseout","mouseover"]),l("onMouseLeave",["mouseout","mouseover"]),l("onPointerEnter",["pointerout","pointerover"]),l("onPointerLeave",["pointerout","pointerover"]),i("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),i("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),i("onBeforeInput",["compositionend","keypress","textInput","paste"]),i("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var cl="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(" "),WN=new Set("cancel close invalid load scroll toggle".split(" ").concat(cl));function Hk(s,a,d){var k=s.type||"unknown-event";s.currentTarget=d,Mt(k,a,void 0,s),s.currentTarget=null}function Wk(s,a){a=(a&4)!==0;for(var d=0;d<s.length;d++){var k=s[d],v=k.event;k=k.listeners;e:{var x=void 0;if(a)for(var C=k.length-1;0<=C;C--){var H=k[C],G=H.instance,le=H.currentTarget;if(H=H.listener,G!==x&&v.isPropagationStopped())break e;Hk(v,H,le),x=G}else for(C=0;C<k.length;C++){if(H=k[C],G=H.instance,le=H.currentTarget,H=H.listener,G!==x&&v.isPropagationStopped())break e;Hk(v,H,le),x=G}}}if(kt)throw s=Nt,kt=!1,Nt=null,s}function Cn(s,a){var d=a[qf];d===void 0&&(d=a[qf]=new Set);var k=s+"__bubble";d.has(k)||(Kk(a,s,2,!1),d.add(k))}function Ff(s,a,d){var k=0;a&&(k|=4),Kk(d,s,k,a)}var Wc="_reactListening"+Math.random().toString(36).slice(2);function ul(s){if(!s[Wc]){s[Wc]=!0,r.forEach(function(d){d!=="selectionchange"&&(WN.has(d)||Ff(d,!1,s),Ff(d,!0,s))});var a=s.nodeType===9?s:s.ownerDocument;a===null||a[Wc]||(a[Wc]=!0,Ff("selectionchange",!1,a))}}function Kk(s,a,d,k){switch(qi(a)){case 1:var v=_f;break;case 4:v=Cc;break;default:v=Xa}d=v.bind(null,a,d,s),v=void 0,!Me||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(v=!0),k?v!==void 0?s.addEventListener(a,d,{capture:!0,passive:v}):s.addEventListener(a,d,!0):v!==void 0?s.addEventListener(a,d,{passive:v}):s.addEventListener(a,d,!1)}function Bf(s,a,d,k,v){var x=k;if((a&1)===0&&(a&2)===0&&k!==null)e:for(;;){if(k===null)return;var C=k.tag;if(C===3||C===4){var H=k.stateNode.containerInfo;if(H===v||H.nodeType===8&&H.parentNode===v)break;if(C===4)for(C=k.return;C!==null;){var G=C.tag;if((G===3||G===4)&&(G=C.stateNode.containerInfo,G===v||G.nodeType===8&&G.parentNode===v))return;C=C.return}for(;H!==null;){if(C=gi(H),C===null)return;if(G=C.tag,G===5||G===6){k=x=C;continue e}H=H.parentNode}}k=k.return}$t(function(){var le=x,Ne=sn(d),Ae=[];e:{var Se=Bk.get(s);if(Se!==void 0){var Ke=fi,et=s;switch(s){case"keypress":if(as(d)===0)break e;case"keydown":case"keyup":Ke=If;break;case"focusin":et="focus",Ke=pi;break;case"focusout":et="blur",Ke=pi;break;case"beforeblur":case"afterblur":Ke=pi;break;case"click":if(d.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ke=Ja;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ke=Sf;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ke=Oc;break;case Pk:case Dk:case zk:Ke=Nf;break;case Fk:Ke=Lc;break;case"scroll":Ke=Ek;break;case"wheel":Ke=Dc;break;case"copy":case"cut":case"paste":Ke=Tf;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ke=ol}var tt=(a&4)!==0,Jn=!tt&&s==="scroll",te=tt?Se!==null?Se+"Capture":null:Se;tt=[];for(var Y=le,oe;Y!==null;){oe=Y;var Re=oe.stateNode;if(oe.tag===5&&Re!==null&&(oe=Re,te!==null&&(Re=Oe(Y,te),Re!=null&&tt.push(dl(Y,Re,oe)))),Jn)break;Y=Y.return}0<tt.length&&(Se=new Ke(Se,et,null,d,Ne),Ae.push({event:Se,listeners:tt}))}}if((a&7)===0){e:{if(Se=s==="mouseover"||s==="pointerover",Ke=s==="mouseout"||s==="pointerout",Se&&d!==Sn&&(et=d.relatedTarget||d.fromElement)&&(gi(et)||et[us]))break e;if((Ke||Se)&&(Se=Ne.window===Ne?Ne:(Se=Ne.ownerDocument)?Se.defaultView||Se.parentWindow:window,Ke?(et=d.relatedTarget||d.toElement,Ke=le,et=et?gi(et):null,et!==null&&(Jn=zt(et),et!==Jn||et.tag!==5&&et.tag!==6)&&(et=null)):(Ke=null,et=le),Ke!==et)){if(tt=Ja,Re="onMouseLeave",te="onMouseEnter",Y="mouse",(s==="pointerout"||s==="pointerover")&&(tt=ol,Re="onPointerLeave",te="onPointerEnter",Y="pointer"),Jn=Ke==null?Se:na(Ke),oe=et==null?Se:na(et),Se=new tt(Re,Y+"leave",Ke,d,Ne),Se.target=Jn,Se.relatedTarget=oe,Re=null,gi(Ne)===le&&(tt=new tt(te,Y+"enter",et,d,Ne),tt.target=oe,tt.relatedTarget=Jn,Re=tt),Jn=Re,Ke&&et)t:{for(tt=Ke,te=et,Y=0,oe=tt;oe;oe=ea(oe))Y++;for(oe=0,Re=te;Re;Re=ea(Re))oe++;for(;0<Y-oe;)tt=ea(tt),Y--;for(;0<oe-Y;)te=ea(te),oe--;for(;Y--;){if(tt===te||te!==null&&tt===te.alternate)break t;tt=ea(tt),te=ea(te)}tt=null}else tt=null;Ke!==null&&Zk(Ae,Se,Ke,tt,!1),et!==null&&Jn!==null&&Zk(Ae,Jn,et,tt,!0)}}e:{if(Se=le?na(le):window,Ke=Se.nodeName&&Se.nodeName.toLowerCase(),Ke==="select"||Ke==="input"&&Se.type==="file")var rt=ON;else if(Sk(Se))if(Tk)rt=DN;else{rt=LN;var ht=MN}else(Ke=Se.nodeName)&&Ke.toLowerCase()==="input"&&(Se.type==="checkbox"||Se.type==="radio")&&(rt=PN);if(rt&&(rt=rt(s,le))){Nk(Ae,rt,d,Ne);break e}ht&&ht(s,Se,le),s==="focusout"&&(ht=Se._wrapperState)&&ht.controlled&&Se.type==="number"&&It(Se,"number",Se.value)}switch(ht=le?na(le):window,s){case"focusin":(Sk(ht)||ht.contentEditable==="true")&&(Xi=ht,Mf=le,ll=null);break;case"focusout":ll=Mf=Xi=null;break;case"mousedown":Lf=!0;break;case"contextmenu":case"mouseup":case"dragend":Lf=!1,Mk(Ae,d,Ne);break;case"selectionchange":if(BN)break;case"keydown":case"keyup":Mk(Ae,d,Ne)}var pt;if(Ge)e:{switch(s){case"compositionstart":var xt="onCompositionStart";break e;case"compositionend":xt="onCompositionEnd";break e;case"compositionupdate":xt="onCompositionUpdate";break e}xt=void 0}else Qi?Fc(s,d)&&(xt="onCompositionEnd"):s==="keydown"&&d.keyCode===229&&(xt="onCompositionStart");xt&&(kr&&d.locale!=="ko"&&(Qi||xt!=="onCompositionStart"?xt==="onCompositionEnd"&&Qi&&(pt=Gi()):(eo=Ne,Yn="value"in eo?eo.value:eo.textContent,Qi=!0)),ht=Kc(le,xt),0<ht.length&&(xt=new rl(xt,s,null,d,Ne),Ae.push({event:xt,listeners:ht}),pt?xt.data=pt:(pt=_k(d),pt!==null&&(xt.data=pt)))),(pt=hn?AN(s,d):IN(s,d))&&(le=Kc(le,"onBeforeInput"),0<le.length&&(Ne=new rl("onBeforeInput","beforeinput",null,d,Ne),Ae.push({event:Ne,listeners:le}),Ne.data=pt))}Wk(Ae,a)})}function dl(s,a,d){return{instance:s,listener:a,currentTarget:d}}function Kc(s,a){for(var d=a+"Capture",k=[];s!==null;){var v=s,x=v.stateNode;v.tag===5&&x!==null&&(v=x,x=Oe(s,d),x!=null&&k.unshift(dl(s,x,v)),x=Oe(s,a),x!=null&&k.push(dl(s,x,v))),s=s.return}return k}function ea(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5);return s||null}function Zk(s,a,d,k,v){for(var x=a._reactName,C=[];d!==null&&d!==k;){var H=d,G=H.alternate,le=H.stateNode;if(G!==null&&G===k)break;H.tag===5&&le!==null&&(H=le,v?(G=Oe(d,x),G!=null&&C.unshift(dl(d,G,H))):v||(G=Oe(d,x),G!=null&&C.push(dl(d,G,H)))),d=d.return}C.length!==0&&s.push({event:a,listeners:C})}var KN=/\r\n?/g,ZN=/\u0000|\uFFFD/g;function qk(s){return(typeof s=="string"?s:""+s).replace(KN,`
|
|
39
|
+
`).replace(ZN,"")}function Zc(s,a,d){if(a=qk(a),qk(s)!==a&&d)throw Error(n(425))}function qc(){}var Uf=null,Hf=null;function Wf(s,a){return s==="textarea"||s==="noscript"||typeof a.children=="string"||typeof a.children=="number"||typeof a.dangerouslySetInnerHTML=="object"&&a.dangerouslySetInnerHTML!==null&&a.dangerouslySetInnerHTML.__html!=null}var Kf=typeof setTimeout=="function"?setTimeout:void 0,qN=typeof clearTimeout=="function"?clearTimeout:void 0,Gk=typeof Promise=="function"?Promise:void 0,GN=typeof queueMicrotask=="function"?queueMicrotask:typeof Gk<"u"?function(s){return Gk.resolve(null).then(s).catch(VN)}:Kf;function VN(s){setTimeout(function(){throw s})}function Zf(s,a){var d=a,k=0;do{var v=d.nextSibling;if(s.removeChild(d),v&&v.nodeType===8)if(d=v.data,d==="/$"){if(k===0){s.removeChild(v),ss(a);return}k--}else d!=="$"&&d!=="$?"&&d!=="$!"||k++;d=v}while(d);ss(a)}function $s(s){for(;s!=null;s=s.nextSibling){var a=s.nodeType;if(a===1||a===3)break;if(a===8){if(a=s.data,a==="$"||a==="$!"||a==="$?")break;if(a==="/$")return null}}return s}function Vk(s){s=s.previousSibling;for(var a=0;s;){if(s.nodeType===8){var d=s.data;if(d==="$"||d==="$!"||d==="$?"){if(a===0)return s;a--}else d==="/$"&&a++}s=s.previousSibling}return null}var ta=Math.random().toString(36).slice(2),Ko="__reactFiber$"+ta,fl="__reactProps$"+ta,us="__reactContainer$"+ta,qf="__reactEvents$"+ta,YN="__reactListeners$"+ta,QN="__reactHandles$"+ta;function gi(s){var a=s[Ko];if(a)return a;for(var d=s.parentNode;d;){if(a=d[us]||d[Ko]){if(d=a.alternate,a.child!==null||d!==null&&d.child!==null)for(s=Vk(s);s!==null;){if(d=s[Ko])return d;s=Vk(s)}return a}s=d,d=s.parentNode}return null}function hl(s){return s=s[Ko]||s[us],!s||s.tag!==5&&s.tag!==6&&s.tag!==13&&s.tag!==3?null:s}function na(s){if(s.tag===5||s.tag===6)return s.stateNode;throw Error(n(33))}function Gc(s){return s[fl]||null}var Gf=[],ra=-1;function Os(s){return{current:s}}function An(s){0>ra||(s.current=Gf[ra],Gf[ra]=null,ra--)}function Nn(s,a){ra++,Gf[ra]=s.current,s.current=a}var Ms={},xr=Os(Ms),Fr=Os(!1),ki=Ms;function oa(s,a){var d=s.type.contextTypes;if(!d)return Ms;var k=s.stateNode;if(k&&k.__reactInternalMemoizedUnmaskedChildContext===a)return k.__reactInternalMemoizedMaskedChildContext;var v={},x;for(x in d)v[x]=a[x];return k&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=a,s.__reactInternalMemoizedMaskedChildContext=v),v}function Br(s){return s=s.childContextTypes,s!=null}function Vc(){An(Fr),An(xr)}function Yk(s,a,d){if(xr.current!==Ms)throw Error(n(168));Nn(xr,a),Nn(Fr,d)}function Qk(s,a,d){var k=s.stateNode;if(a=a.childContextTypes,typeof k.getChildContext!="function")return d;k=k.getChildContext();for(var v in k)if(!(v in a))throw Error(n(108,ae(s)||"Unknown",v));return ie({},d,k)}function Yc(s){return s=(s=s.stateNode)&&s.__reactInternalMemoizedMergedChildContext||Ms,ki=xr.current,Nn(xr,s),Nn(Fr,Fr.current),!0}function Xk(s,a,d){var k=s.stateNode;if(!k)throw Error(n(169));d?(s=Qk(s,a,ki),k.__reactInternalMemoizedMergedChildContext=s,An(Fr),An(xr),Nn(xr,s)):An(Fr),Nn(Fr,d)}var ds=null,Qc=!1,Vf=!1;function Jk(s){ds===null?ds=[s]:ds.push(s)}function XN(s){Qc=!0,Jk(s)}function Ls(){if(!Vf&&ds!==null){Vf=!0;var s=0,a=Kt;try{var d=ds;for(Kt=1;s<d.length;s++){var k=d[s];do k=k(!0);while(k!==null)}ds=null,Qc=!1}catch(v){throw ds!==null&&(ds=ds.slice(s+1)),dn(Xr,Ls),v}finally{Kt=a,Vf=!1}}return null}var sa=[],ia=0,Xc=null,Jc=0,uo=[],fo=0,yi=null,fs=1,hs="";function wi(s,a){sa[ia++]=Jc,sa[ia++]=Xc,Xc=s,Jc=a}function ey(s,a,d){uo[fo++]=fs,uo[fo++]=hs,uo[fo++]=yi,yi=s;var k=fs;s=hs;var v=32-mn(k)-1;k&=~(1<<v),d+=1;var x=32-mn(a)+v;if(30<x){var C=v-v%5;x=(k&(1<<C)-1).toString(32),k>>=C,v-=C,fs=1<<32-mn(a)+v|d<<v|k,hs=x+s}else fs=1<<x|d<<v|k,hs=s}function Yf(s){s.return!==null&&(wi(s,1),ey(s,1,0))}function Qf(s){for(;s===Xc;)Xc=sa[--ia],sa[ia]=null,Jc=sa[--ia],sa[ia]=null;for(;s===yi;)yi=uo[--fo],uo[fo]=null,hs=uo[--fo],uo[fo]=null,fs=uo[--fo],uo[fo]=null}var to=null,no=null,$n=!1,To=null;function ty(s,a){var d=go(5,null,null,0);d.elementType="DELETED",d.stateNode=a,d.return=s,a=s.deletions,a===null?(s.deletions=[d],s.flags|=16):a.push(d)}function ny(s,a){switch(s.tag){case 5:var d=s.type;return a=a.nodeType!==1||d.toLowerCase()!==a.nodeName.toLowerCase()?null:a,a!==null?(s.stateNode=a,to=s,no=$s(a.firstChild),!0):!1;case 6:return a=s.pendingProps===""||a.nodeType!==3?null:a,a!==null?(s.stateNode=a,to=s,no=null,!0):!1;case 13:return a=a.nodeType!==8?null:a,a!==null?(d=yi!==null?{id:fs,overflow:hs}:null,s.memoizedState={dehydrated:a,treeContext:d,retryLane:1073741824},d=go(18,null,null,0),d.stateNode=a,d.return=s,s.child=d,to=s,no=null,!0):!1;default:return!1}}function Xf(s){return(s.mode&1)!==0&&(s.flags&128)===0}function Jf(s){if($n){var a=no;if(a){var d=a;if(!ny(s,a)){if(Xf(s))throw Error(n(418));a=$s(d.nextSibling);var k=to;a&&ny(s,a)?ty(k,d):(s.flags=s.flags&-4097|2,$n=!1,to=s)}}else{if(Xf(s))throw Error(n(418));s.flags=s.flags&-4097|2,$n=!1,to=s}}}function ry(s){for(s=s.return;s!==null&&s.tag!==5&&s.tag!==3&&s.tag!==13;)s=s.return;to=s}function eu(s){if(s!==to)return!1;if(!$n)return ry(s),$n=!0,!1;var a;if((a=s.tag!==3)&&!(a=s.tag!==5)&&(a=s.type,a=a!=="head"&&a!=="body"&&!Wf(s.type,s.memoizedProps)),a&&(a=no)){if(Xf(s))throw oy(),Error(n(418));for(;a;)ty(s,a),a=$s(a.nextSibling)}if(ry(s),s.tag===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(n(317));e:{for(s=s.nextSibling,a=0;s;){if(s.nodeType===8){var d=s.data;if(d==="/$"){if(a===0){no=$s(s.nextSibling);break e}a--}else d!=="$"&&d!=="$!"&&d!=="$?"||a++}s=s.nextSibling}no=null}}else no=to?$s(s.stateNode.nextSibling):null;return!0}function oy(){for(var s=no;s;)s=$s(s.nextSibling)}function aa(){no=to=null,$n=!1}function eh(s){To===null?To=[s]:To.push(s)}var JN=O.ReactCurrentBatchConfig;function pl(s,a,d){if(s=d.ref,s!==null&&typeof s!="function"&&typeof s!="object"){if(d._owner){if(d=d._owner,d){if(d.tag!==1)throw Error(n(309));var k=d.stateNode}if(!k)throw Error(n(147,s));var v=k,x=""+s;return a!==null&&a.ref!==null&&typeof a.ref=="function"&&a.ref._stringRef===x?a.ref:(a=function(C){var H=v.refs;C===null?delete H[x]:H[x]=C},a._stringRef=x,a)}if(typeof s!="string")throw Error(n(284));if(!d._owner)throw Error(n(290,s))}return s}function tu(s,a){throw s=Object.prototype.toString.call(a),Error(n(31,s==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":s))}function sy(s){var a=s._init;return a(s._payload)}function iy(s){function a(te,Y){if(s){var oe=te.deletions;oe===null?(te.deletions=[Y],te.flags|=16):oe.push(Y)}}function d(te,Y){if(!s)return null;for(;Y!==null;)a(te,Y),Y=Y.sibling;return null}function k(te,Y){for(te=new Map;Y!==null;)Y.key!==null?te.set(Y.key,Y):te.set(Y.index,Y),Y=Y.sibling;return te}function v(te,Y){return te=Ws(te,Y),te.index=0,te.sibling=null,te}function x(te,Y,oe){return te.index=oe,s?(oe=te.alternate,oe!==null?(oe=oe.index,oe<Y?(te.flags|=2,Y):oe):(te.flags|=2,Y)):(te.flags|=1048576,Y)}function C(te){return s&&te.alternate===null&&(te.flags|=2),te}function H(te,Y,oe,Re){return Y===null||Y.tag!==6?(Y=Kh(oe,te.mode,Re),Y.return=te,Y):(Y=v(Y,oe),Y.return=te,Y)}function G(te,Y,oe,Re){var rt=oe.type;return rt===R?Ne(te,Y,oe.props.children,Re,oe.key):Y!==null&&(Y.elementType===rt||typeof rt=="object"&&rt!==null&&rt.$$typeof===ke&&sy(rt)===Y.type)?(Re=v(Y,oe.props),Re.ref=pl(te,Y,oe),Re.return=te,Re):(Re=Su(oe.type,oe.key,oe.props,null,te.mode,Re),Re.ref=pl(te,Y,oe),Re.return=te,Re)}function le(te,Y,oe,Re){return Y===null||Y.tag!==4||Y.stateNode.containerInfo!==oe.containerInfo||Y.stateNode.implementation!==oe.implementation?(Y=Zh(oe,te.mode,Re),Y.return=te,Y):(Y=v(Y,oe.children||[]),Y.return=te,Y)}function Ne(te,Y,oe,Re,rt){return Y===null||Y.tag!==7?(Y=Ti(oe,te.mode,Re,rt),Y.return=te,Y):(Y=v(Y,oe),Y.return=te,Y)}function Ae(te,Y,oe){if(typeof Y=="string"&&Y!==""||typeof Y=="number")return Y=Kh(""+Y,te.mode,oe),Y.return=te,Y;if(typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case U:return oe=Su(Y.type,Y.key,Y.props,null,te.mode,oe),oe.ref=pl(te,null,Y),oe.return=te,oe;case Q:return Y=Zh(Y,te.mode,oe),Y.return=te,Y;case ke:var Re=Y._init;return Ae(te,Re(Y._payload),oe)}if(nt(Y)||q(Y))return Y=Ti(Y,te.mode,oe,null),Y.return=te,Y;tu(te,Y)}return null}function Se(te,Y,oe,Re){var rt=Y!==null?Y.key:null;if(typeof oe=="string"&&oe!==""||typeof oe=="number")return rt!==null?null:H(te,Y,""+oe,Re);if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case U:return oe.key===rt?G(te,Y,oe,Re):null;case Q:return oe.key===rt?le(te,Y,oe,Re):null;case ke:return rt=oe._init,Se(te,Y,rt(oe._payload),Re)}if(nt(oe)||q(oe))return rt!==null?null:Ne(te,Y,oe,Re,null);tu(te,oe)}return null}function Ke(te,Y,oe,Re,rt){if(typeof Re=="string"&&Re!==""||typeof Re=="number")return te=te.get(oe)||null,H(Y,te,""+Re,rt);if(typeof Re=="object"&&Re!==null){switch(Re.$$typeof){case U:return te=te.get(Re.key===null?oe:Re.key)||null,G(Y,te,Re,rt);case Q:return te=te.get(Re.key===null?oe:Re.key)||null,le(Y,te,Re,rt);case ke:var ht=Re._init;return Ke(te,Y,oe,ht(Re._payload),rt)}if(nt(Re)||q(Re))return te=te.get(oe)||null,Ne(Y,te,Re,rt,null);tu(Y,Re)}return null}function et(te,Y,oe,Re){for(var rt=null,ht=null,pt=Y,xt=Y=0,hr=null;pt!==null&&xt<oe.length;xt++){pt.index>xt?(hr=pt,pt=null):hr=pt.sibling;var nn=Se(te,pt,oe[xt],Re);if(nn===null){pt===null&&(pt=hr);break}s&&pt&&nn.alternate===null&&a(te,pt),Y=x(nn,Y,xt),ht===null?rt=nn:ht.sibling=nn,ht=nn,pt=hr}if(xt===oe.length)return d(te,pt),$n&&wi(te,xt),rt;if(pt===null){for(;xt<oe.length;xt++)pt=Ae(te,oe[xt],Re),pt!==null&&(Y=x(pt,Y,xt),ht===null?rt=pt:ht.sibling=pt,ht=pt);return $n&&wi(te,xt),rt}for(pt=k(te,pt);xt<oe.length;xt++)hr=Ke(pt,te,xt,oe[xt],Re),hr!==null&&(s&&hr.alternate!==null&&pt.delete(hr.key===null?xt:hr.key),Y=x(hr,Y,xt),ht===null?rt=hr:ht.sibling=hr,ht=hr);return s&&pt.forEach(function(Ks){return a(te,Ks)}),$n&&wi(te,xt),rt}function tt(te,Y,oe,Re){var rt=q(oe);if(typeof rt!="function")throw Error(n(150));if(oe=rt.call(oe),oe==null)throw Error(n(151));for(var ht=rt=null,pt=Y,xt=Y=0,hr=null,nn=oe.next();pt!==null&&!nn.done;xt++,nn=oe.next()){pt.index>xt?(hr=pt,pt=null):hr=pt.sibling;var Ks=Se(te,pt,nn.value,Re);if(Ks===null){pt===null&&(pt=hr);break}s&&pt&&Ks.alternate===null&&a(te,pt),Y=x(Ks,Y,xt),ht===null?rt=Ks:ht.sibling=Ks,ht=Ks,pt=hr}if(nn.done)return d(te,pt),$n&&wi(te,xt),rt;if(pt===null){for(;!nn.done;xt++,nn=oe.next())nn=Ae(te,nn.value,Re),nn!==null&&(Y=x(nn,Y,xt),ht===null?rt=nn:ht.sibling=nn,ht=nn);return $n&&wi(te,xt),rt}for(pt=k(te,pt);!nn.done;xt++,nn=oe.next())nn=Ke(pt,te,xt,nn.value,Re),nn!==null&&(s&&nn.alternate!==null&&pt.delete(nn.key===null?xt:nn.key),Y=x(nn,Y,xt),ht===null?rt=nn:ht.sibling=nn,ht=nn);return s&&pt.forEach(function(RT){return a(te,RT)}),$n&&wi(te,xt),rt}function Jn(te,Y,oe,Re){if(typeof oe=="object"&&oe!==null&&oe.type===R&&oe.key===null&&(oe=oe.props.children),typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case U:e:{for(var rt=oe.key,ht=Y;ht!==null;){if(ht.key===rt){if(rt=oe.type,rt===R){if(ht.tag===7){d(te,ht.sibling),Y=v(ht,oe.props.children),Y.return=te,te=Y;break e}}else if(ht.elementType===rt||typeof rt=="object"&&rt!==null&&rt.$$typeof===ke&&sy(rt)===ht.type){d(te,ht.sibling),Y=v(ht,oe.props),Y.ref=pl(te,ht,oe),Y.return=te,te=Y;break e}d(te,ht);break}else a(te,ht);ht=ht.sibling}oe.type===R?(Y=Ti(oe.props.children,te.mode,Re,oe.key),Y.return=te,te=Y):(Re=Su(oe.type,oe.key,oe.props,null,te.mode,Re),Re.ref=pl(te,Y,oe),Re.return=te,te=Re)}return C(te);case Q:e:{for(ht=oe.key;Y!==null;){if(Y.key===ht)if(Y.tag===4&&Y.stateNode.containerInfo===oe.containerInfo&&Y.stateNode.implementation===oe.implementation){d(te,Y.sibling),Y=v(Y,oe.children||[]),Y.return=te,te=Y;break e}else{d(te,Y);break}else a(te,Y);Y=Y.sibling}Y=Zh(oe,te.mode,Re),Y.return=te,te=Y}return C(te);case ke:return ht=oe._init,Jn(te,Y,ht(oe._payload),Re)}if(nt(oe))return et(te,Y,oe,Re);if(q(oe))return tt(te,Y,oe,Re);tu(te,oe)}return typeof oe=="string"&&oe!==""||typeof oe=="number"?(oe=""+oe,Y!==null&&Y.tag===6?(d(te,Y.sibling),Y=v(Y,oe),Y.return=te,te=Y):(d(te,Y),Y=Kh(oe,te.mode,Re),Y.return=te,te=Y),C(te)):d(te,Y)}return Jn}var la=iy(!0),ay=iy(!1),nu=Os(null),ru=null,ca=null,th=null;function nh(){th=ca=ru=null}function rh(s){var a=nu.current;An(nu),s._currentValue=a}function oh(s,a,d){for(;s!==null;){var k=s.alternate;if((s.childLanes&a)!==a?(s.childLanes|=a,k!==null&&(k.childLanes|=a)):k!==null&&(k.childLanes&a)!==a&&(k.childLanes|=a),s===d)break;s=s.return}}function ua(s,a){ru=s,th=ca=null,s=s.dependencies,s!==null&&s.firstContext!==null&&((s.lanes&a)!==0&&(Ur=!0),s.firstContext=null)}function ho(s){var a=s._currentValue;if(th!==s)if(s={context:s,memoizedValue:a,next:null},ca===null){if(ru===null)throw Error(n(308));ca=s,ru.dependencies={lanes:0,firstContext:s}}else ca=ca.next=s;return a}var vi=null;function sh(s){vi===null?vi=[s]:vi.push(s)}function ly(s,a,d,k){var v=a.interleaved;return v===null?(d.next=d,sh(a)):(d.next=v.next,v.next=d),a.interleaved=d,ps(s,k)}function ps(s,a){s.lanes|=a;var d=s.alternate;for(d!==null&&(d.lanes|=a),d=s,s=s.return;s!==null;)s.childLanes|=a,d=s.alternate,d!==null&&(d.childLanes|=a),d=s,s=s.return;return d.tag===3?d.stateNode:null}var Ps=!1;function ih(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function cy(s,a){s=s.updateQueue,a.updateQueue===s&&(a.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,effects:s.effects})}function ms(s,a){return{eventTime:s,lane:a,tag:0,payload:null,callback:null,next:null}}function Ds(s,a,d){var k=s.updateQueue;if(k===null)return null;if(k=k.shared,(en&2)!==0){var v=k.pending;return v===null?a.next=a:(a.next=v.next,v.next=a),k.pending=a,ps(s,d)}return v=k.interleaved,v===null?(a.next=a,sh(k)):(a.next=v.next,v.next=a),k.interleaved=a,ps(s,d)}function ou(s,a,d){if(a=a.updateQueue,a!==null&&(a=a.shared,(d&4194240)!==0)){var k=a.lanes;k&=s.pendingLanes,d|=k,a.lanes=d,zr(s,d)}}function uy(s,a){var d=s.updateQueue,k=s.alternate;if(k!==null&&(k=k.updateQueue,d===k)){var v=null,x=null;if(d=d.firstBaseUpdate,d!==null){do{var C={eventTime:d.eventTime,lane:d.lane,tag:d.tag,payload:d.payload,callback:d.callback,next:null};x===null?v=x=C:x=x.next=C,d=d.next}while(d!==null);x===null?v=x=a:x=x.next=a}else v=x=a;d={baseState:k.baseState,firstBaseUpdate:v,lastBaseUpdate:x,shared:k.shared,effects:k.effects},s.updateQueue=d;return}s=d.lastBaseUpdate,s===null?d.firstBaseUpdate=a:s.next=a,d.lastBaseUpdate=a}function su(s,a,d,k){var v=s.updateQueue;Ps=!1;var x=v.firstBaseUpdate,C=v.lastBaseUpdate,H=v.shared.pending;if(H!==null){v.shared.pending=null;var G=H,le=G.next;G.next=null,C===null?x=le:C.next=le,C=G;var Ne=s.alternate;Ne!==null&&(Ne=Ne.updateQueue,H=Ne.lastBaseUpdate,H!==C&&(H===null?Ne.firstBaseUpdate=le:H.next=le,Ne.lastBaseUpdate=G))}if(x!==null){var Ae=v.baseState;C=0,Ne=le=G=null,H=x;do{var Se=H.lane,Ke=H.eventTime;if((k&Se)===Se){Ne!==null&&(Ne=Ne.next={eventTime:Ke,lane:0,tag:H.tag,payload:H.payload,callback:H.callback,next:null});e:{var et=s,tt=H;switch(Se=a,Ke=d,tt.tag){case 1:if(et=tt.payload,typeof et=="function"){Ae=et.call(Ke,Ae,Se);break e}Ae=et;break e;case 3:et.flags=et.flags&-65537|128;case 0:if(et=tt.payload,Se=typeof et=="function"?et.call(Ke,Ae,Se):et,Se==null)break e;Ae=ie({},Ae,Se);break e;case 2:Ps=!0}}H.callback!==null&&H.lane!==0&&(s.flags|=64,Se=v.effects,Se===null?v.effects=[H]:Se.push(H))}else Ke={eventTime:Ke,lane:Se,tag:H.tag,payload:H.payload,callback:H.callback,next:null},Ne===null?(le=Ne=Ke,G=Ae):Ne=Ne.next=Ke,C|=Se;if(H=H.next,H===null){if(H=v.shared.pending,H===null)break;Se=H,H=Se.next,Se.next=null,v.lastBaseUpdate=Se,v.shared.pending=null}}while(!0);if(Ne===null&&(G=Ae),v.baseState=G,v.firstBaseUpdate=le,v.lastBaseUpdate=Ne,a=v.shared.interleaved,a!==null){v=a;do C|=v.lane,v=v.next;while(v!==a)}else x===null&&(v.shared.lanes=0);Ei|=C,s.lanes=C,s.memoizedState=Ae}}function dy(s,a,d){if(s=a.effects,a.effects=null,s!==null)for(a=0;a<s.length;a++){var k=s[a],v=k.callback;if(v!==null){if(k.callback=null,k=d,typeof v!="function")throw Error(n(191,v));v.call(k)}}}var ml={},Zo=Os(ml),gl=Os(ml),kl=Os(ml);function bi(s){if(s===ml)throw Error(n(174));return s}function ah(s,a){switch(Nn(kl,a),Nn(gl,s),Nn(Zo,ml),s=a.nodeType,s){case 9:case 11:a=(a=a.documentElement)?a.namespaceURI:ft(null,"");break;default:s=s===8?a.parentNode:a,a=s.namespaceURI||null,s=s.tagName,a=ft(a,s)}An(Zo),Nn(Zo,a)}function da(){An(Zo),An(gl),An(kl)}function fy(s){bi(kl.current);var a=bi(Zo.current),d=ft(a,s.type);a!==d&&(Nn(gl,s),Nn(Zo,d))}function lh(s){gl.current===s&&(An(Zo),An(gl))}var Fn=Os(0);function iu(s){for(var a=s;a!==null;){if(a.tag===13){var d=a.memoizedState;if(d!==null&&(d=d.dehydrated,d===null||d.data==="$?"||d.data==="$!"))return a}else if(a.tag===19&&a.memoizedProps.revealOrder!==void 0){if((a.flags&128)!==0)return a}else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===s)break;for(;a.sibling===null;){if(a.return===null||a.return===s)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var ch=[];function uh(){for(var s=0;s<ch.length;s++)ch[s]._workInProgressVersionPrimary=null;ch.length=0}var au=O.ReactCurrentDispatcher,dh=O.ReactCurrentBatchConfig,xi=0,Bn=null,sr=null,dr=null,lu=!1,yl=!1,wl=0,eT=0;function Er(){throw Error(n(321))}function fh(s,a){if(a===null)return!1;for(var d=0;d<a.length&&d<s.length;d++)if(!No(s[d],a[d]))return!1;return!0}function hh(s,a,d,k,v,x){if(xi=x,Bn=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,au.current=s===null||s.memoizedState===null?oT:sT,s=d(k,v),yl){x=0;do{if(yl=!1,wl=0,25<=x)throw Error(n(301));x+=1,dr=sr=null,a.updateQueue=null,au.current=iT,s=d(k,v)}while(yl)}if(au.current=du,a=sr!==null&&sr.next!==null,xi=0,dr=sr=Bn=null,lu=!1,a)throw Error(n(300));return s}function ph(){var s=wl!==0;return wl=0,s}function qo(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return dr===null?Bn.memoizedState=dr=s:dr=dr.next=s,dr}function po(){if(sr===null){var s=Bn.alternate;s=s!==null?s.memoizedState:null}else s=sr.next;var a=dr===null?Bn.memoizedState:dr.next;if(a!==null)dr=a,sr=s;else{if(s===null)throw Error(n(310));sr=s,s={memoizedState:sr.memoizedState,baseState:sr.baseState,baseQueue:sr.baseQueue,queue:sr.queue,next:null},dr===null?Bn.memoizedState=dr=s:dr=dr.next=s}return dr}function vl(s,a){return typeof a=="function"?a(s):a}function mh(s){var a=po(),d=a.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=s;var k=sr,v=k.baseQueue,x=d.pending;if(x!==null){if(v!==null){var C=v.next;v.next=x.next,x.next=C}k.baseQueue=v=x,d.pending=null}if(v!==null){x=v.next,k=k.baseState;var H=C=null,G=null,le=x;do{var Ne=le.lane;if((xi&Ne)===Ne)G!==null&&(G=G.next={lane:0,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),k=le.hasEagerState?le.eagerState:s(k,le.action);else{var Ae={lane:Ne,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null};G===null?(H=G=Ae,C=k):G=G.next=Ae,Bn.lanes|=Ne,Ei|=Ne}le=le.next}while(le!==null&&le!==x);G===null?C=k:G.next=H,No(k,a.memoizedState)||(Ur=!0),a.memoizedState=k,a.baseState=C,a.baseQueue=G,d.lastRenderedState=k}if(s=d.interleaved,s!==null){v=s;do x=v.lane,Bn.lanes|=x,Ei|=x,v=v.next;while(v!==s)}else v===null&&(d.lanes=0);return[a.memoizedState,d.dispatch]}function gh(s){var a=po(),d=a.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=s;var k=d.dispatch,v=d.pending,x=a.memoizedState;if(v!==null){d.pending=null;var C=v=v.next;do x=s(x,C.action),C=C.next;while(C!==v);No(x,a.memoizedState)||(Ur=!0),a.memoizedState=x,a.baseQueue===null&&(a.baseState=x),d.lastRenderedState=x}return[x,k]}function hy(){}function py(s,a){var d=Bn,k=po(),v=a(),x=!No(k.memoizedState,v);if(x&&(k.memoizedState=v,Ur=!0),k=k.queue,kh(ky.bind(null,d,k,s),[s]),k.getSnapshot!==a||x||dr!==null&&dr.memoizedState.tag&1){if(d.flags|=2048,bl(9,gy.bind(null,d,k,v,a),void 0,null),fr===null)throw Error(n(349));(xi&30)!==0||my(d,a,v)}return v}function my(s,a,d){s.flags|=16384,s={getSnapshot:a,value:d},a=Bn.updateQueue,a===null?(a={lastEffect:null,stores:null},Bn.updateQueue=a,a.stores=[s]):(d=a.stores,d===null?a.stores=[s]:d.push(s))}function gy(s,a,d,k){a.value=d,a.getSnapshot=k,yy(a)&&wy(s)}function ky(s,a,d){return d(function(){yy(a)&&wy(s)})}function yy(s){var a=s.getSnapshot;s=s.value;try{var d=a();return!No(s,d)}catch{return!0}}function wy(s){var a=ps(s,1);a!==null&&Io(a,s,1,-1)}function vy(s){var a=qo();return typeof s=="function"&&(s=s()),a.memoizedState=a.baseState=s,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:vl,lastRenderedState:s},a.queue=s,s=s.dispatch=rT.bind(null,Bn,s),[a.memoizedState,s]}function bl(s,a,d,k){return s={tag:s,create:a,destroy:d,deps:k,next:null},a=Bn.updateQueue,a===null?(a={lastEffect:null,stores:null},Bn.updateQueue=a,a.lastEffect=s.next=s):(d=a.lastEffect,d===null?a.lastEffect=s.next=s:(k=d.next,d.next=s,s.next=k,a.lastEffect=s)),s}function by(){return po().memoizedState}function cu(s,a,d,k){var v=qo();Bn.flags|=s,v.memoizedState=bl(1|a,d,void 0,k===void 0?null:k)}function uu(s,a,d,k){var v=po();k=k===void 0?null:k;var x=void 0;if(sr!==null){var C=sr.memoizedState;if(x=C.destroy,k!==null&&fh(k,C.deps)){v.memoizedState=bl(a,d,x,k);return}}Bn.flags|=s,v.memoizedState=bl(1|a,d,x,k)}function xy(s,a){return cu(8390656,8,s,a)}function kh(s,a){return uu(2048,8,s,a)}function Ey(s,a){return uu(4,2,s,a)}function _y(s,a){return uu(4,4,s,a)}function Sy(s,a){if(typeof a=="function")return s=s(),a(s),function(){a(null)};if(a!=null)return s=s(),a.current=s,function(){a.current=null}}function Ny(s,a,d){return d=d!=null?d.concat([s]):null,uu(4,4,Sy.bind(null,a,s),d)}function yh(){}function Ty(s,a){var d=po();a=a===void 0?null:a;var k=d.memoizedState;return k!==null&&a!==null&&fh(a,k[1])?k[0]:(d.memoizedState=[s,a],s)}function jy(s,a){var d=po();a=a===void 0?null:a;var k=d.memoizedState;return k!==null&&a!==null&&fh(a,k[1])?k[0]:(s=s(),d.memoizedState=[s,a],s)}function Cy(s,a,d){return(xi&21)===0?(s.baseState&&(s.baseState=!1,Ur=!0),s.memoizedState=d):(No(d,a)||(d=Bo(),Bn.lanes|=d,Ei|=d,s.baseState=!0),a)}function tT(s,a){var d=Kt;Kt=d!==0&&4>d?d:4,s(!0);var k=dh.transition;dh.transition={};try{s(!1),a()}finally{Kt=d,dh.transition=k}}function Ay(){return po().memoizedState}function nT(s,a,d){var k=Us(s);if(d={lane:k,action:d,hasEagerState:!1,eagerState:null,next:null},Iy(s))Ry(a,d);else if(d=ly(s,a,d,k),d!==null){var v=$r();Io(d,s,k,v),$y(d,a,k)}}function rT(s,a,d){var k=Us(s),v={lane:k,action:d,hasEagerState:!1,eagerState:null,next:null};if(Iy(s))Ry(a,v);else{var x=s.alternate;if(s.lanes===0&&(x===null||x.lanes===0)&&(x=a.lastRenderedReducer,x!==null))try{var C=a.lastRenderedState,H=x(C,d);if(v.hasEagerState=!0,v.eagerState=H,No(H,C)){var G=a.interleaved;G===null?(v.next=v,sh(a)):(v.next=G.next,G.next=v),a.interleaved=v;return}}catch{}finally{}d=ly(s,a,v,k),d!==null&&(v=$r(),Io(d,s,k,v),$y(d,a,k))}}function Iy(s){var a=s.alternate;return s===Bn||a!==null&&a===Bn}function Ry(s,a){yl=lu=!0;var d=s.pending;d===null?a.next=a:(a.next=d.next,d.next=a),s.pending=a}function $y(s,a,d){if((d&4194240)!==0){var k=a.lanes;k&=s.pendingLanes,d|=k,a.lanes=d,zr(s,d)}}var du={readContext:ho,useCallback:Er,useContext:Er,useEffect:Er,useImperativeHandle:Er,useInsertionEffect:Er,useLayoutEffect:Er,useMemo:Er,useReducer:Er,useRef:Er,useState:Er,useDebugValue:Er,useDeferredValue:Er,useTransition:Er,useMutableSource:Er,useSyncExternalStore:Er,useId:Er,unstable_isNewReconciler:!1},oT={readContext:ho,useCallback:function(s,a){return qo().memoizedState=[s,a===void 0?null:a],s},useContext:ho,useEffect:xy,useImperativeHandle:function(s,a,d){return d=d!=null?d.concat([s]):null,cu(4194308,4,Sy.bind(null,a,s),d)},useLayoutEffect:function(s,a){return cu(4194308,4,s,a)},useInsertionEffect:function(s,a){return cu(4,2,s,a)},useMemo:function(s,a){var d=qo();return a=a===void 0?null:a,s=s(),d.memoizedState=[s,a],s},useReducer:function(s,a,d){var k=qo();return a=d!==void 0?d(a):a,k.memoizedState=k.baseState=a,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:a},k.queue=s,s=s.dispatch=nT.bind(null,Bn,s),[k.memoizedState,s]},useRef:function(s){var a=qo();return s={current:s},a.memoizedState=s},useState:vy,useDebugValue:yh,useDeferredValue:function(s){return qo().memoizedState=s},useTransition:function(){var s=vy(!1),a=s[0];return s=tT.bind(null,s[1]),qo().memoizedState=s,[a,s]},useMutableSource:function(){},useSyncExternalStore:function(s,a,d){var k=Bn,v=qo();if($n){if(d===void 0)throw Error(n(407));d=d()}else{if(d=a(),fr===null)throw Error(n(349));(xi&30)!==0||my(k,a,d)}v.memoizedState=d;var x={value:d,getSnapshot:a};return v.queue=x,xy(ky.bind(null,k,x,s),[s]),k.flags|=2048,bl(9,gy.bind(null,k,x,d,a),void 0,null),d},useId:function(){var s=qo(),a=fr.identifierPrefix;if($n){var d=hs,k=fs;d=(k&~(1<<32-mn(k)-1)).toString(32)+d,a=":"+a+"R"+d,d=wl++,0<d&&(a+="H"+d.toString(32)),a+=":"}else d=eT++,a=":"+a+"r"+d.toString(32)+":";return s.memoizedState=a},unstable_isNewReconciler:!1},sT={readContext:ho,useCallback:Ty,useContext:ho,useEffect:kh,useImperativeHandle:Ny,useInsertionEffect:Ey,useLayoutEffect:_y,useMemo:jy,useReducer:mh,useRef:by,useState:function(){return mh(vl)},useDebugValue:yh,useDeferredValue:function(s){var a=po();return Cy(a,sr.memoizedState,s)},useTransition:function(){var s=mh(vl)[0],a=po().memoizedState;return[s,a]},useMutableSource:hy,useSyncExternalStore:py,useId:Ay,unstable_isNewReconciler:!1},iT={readContext:ho,useCallback:Ty,useContext:ho,useEffect:kh,useImperativeHandle:Ny,useInsertionEffect:Ey,useLayoutEffect:_y,useMemo:jy,useReducer:gh,useRef:by,useState:function(){return gh(vl)},useDebugValue:yh,useDeferredValue:function(s){var a=po();return sr===null?a.memoizedState=s:Cy(a,sr.memoizedState,s)},useTransition:function(){var s=gh(vl)[0],a=po().memoizedState;return[s,a]},useMutableSource:hy,useSyncExternalStore:py,useId:Ay,unstable_isNewReconciler:!1};function jo(s,a){if(s&&s.defaultProps){a=ie({},a),s=s.defaultProps;for(var d in s)a[d]===void 0&&(a[d]=s[d]);return a}return a}function wh(s,a,d,k){a=s.memoizedState,d=d(k,a),d=d==null?a:ie({},a,d),s.memoizedState=d,s.lanes===0&&(s.updateQueue.baseState=d)}var fu={isMounted:function(s){return(s=s._reactInternals)?zt(s)===s:!1},enqueueSetState:function(s,a,d){s=s._reactInternals;var k=$r(),v=Us(s),x=ms(k,v);x.payload=a,d!=null&&(x.callback=d),a=Ds(s,x,v),a!==null&&(Io(a,s,v,k),ou(a,s,v))},enqueueReplaceState:function(s,a,d){s=s._reactInternals;var k=$r(),v=Us(s),x=ms(k,v);x.tag=1,x.payload=a,d!=null&&(x.callback=d),a=Ds(s,x,v),a!==null&&(Io(a,s,v,k),ou(a,s,v))},enqueueForceUpdate:function(s,a){s=s._reactInternals;var d=$r(),k=Us(s),v=ms(d,k);v.tag=2,a!=null&&(v.callback=a),a=Ds(s,v,k),a!==null&&(Io(a,s,k,d),ou(a,s,k))}};function Oy(s,a,d,k,v,x,C){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(k,x,C):a.prototype&&a.prototype.isPureReactComponent?!al(d,k)||!al(v,x):!0}function My(s,a,d){var k=!1,v=Ms,x=a.contextType;return typeof x=="object"&&x!==null?x=ho(x):(v=Br(a)?ki:xr.current,k=a.contextTypes,x=(k=k!=null)?oa(s,v):Ms),a=new a(d,x),s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=fu,s.stateNode=a,a._reactInternals=s,k&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=v,s.__reactInternalMemoizedMaskedChildContext=x),a}function Ly(s,a,d,k){s=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(d,k),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(d,k),a.state!==s&&fu.enqueueReplaceState(a,a.state,null)}function vh(s,a,d,k){var v=s.stateNode;v.props=d,v.state=s.memoizedState,v.refs={},ih(s);var x=a.contextType;typeof x=="object"&&x!==null?v.context=ho(x):(x=Br(a)?ki:xr.current,v.context=oa(s,x)),v.state=s.memoizedState,x=a.getDerivedStateFromProps,typeof x=="function"&&(wh(s,a,x,d),v.state=s.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof v.getSnapshotBeforeUpdate=="function"||typeof v.UNSAFE_componentWillMount!="function"&&typeof v.componentWillMount!="function"||(a=v.state,typeof v.componentWillMount=="function"&&v.componentWillMount(),typeof v.UNSAFE_componentWillMount=="function"&&v.UNSAFE_componentWillMount(),a!==v.state&&fu.enqueueReplaceState(v,v.state,null),su(s,d,v,k),v.state=s.memoizedState),typeof v.componentDidMount=="function"&&(s.flags|=4194308)}function fa(s,a){try{var d="",k=a;do d+=me(k),k=k.return;while(k);var v=d}catch(x){v=`
|
|
40
|
+
Error generating stack: `+x.message+`
|
|
41
|
+
`+x.stack}return{value:s,source:a,stack:v,digest:null}}function bh(s,a,d){return{value:s,source:null,stack:d??null,digest:a??null}}function xh(s,a){try{console.error(a.value)}catch(d){setTimeout(function(){throw d})}}var aT=typeof WeakMap=="function"?WeakMap:Map;function Py(s,a,d){d=ms(-1,d),d.tag=3,d.payload={element:null};var k=a.value;return d.callback=function(){wu||(wu=!0,Ph=k),xh(s,a)},d}function Dy(s,a,d){d=ms(-1,d),d.tag=3;var k=s.type.getDerivedStateFromError;if(typeof k=="function"){var v=a.value;d.payload=function(){return k(v)},d.callback=function(){xh(s,a)}}var x=s.stateNode;return x!==null&&typeof x.componentDidCatch=="function"&&(d.callback=function(){xh(s,a),typeof k!="function"&&(Fs===null?Fs=new Set([this]):Fs.add(this));var C=a.stack;this.componentDidCatch(a.value,{componentStack:C!==null?C:""})}),d}function zy(s,a,d){var k=s.pingCache;if(k===null){k=s.pingCache=new aT;var v=new Set;k.set(a,v)}else v=k.get(a),v===void 0&&(v=new Set,k.set(a,v));v.has(d)||(v.add(d),s=bT.bind(null,s,a,d),a.then(s,s))}function Fy(s){do{var a;if((a=s.tag===13)&&(a=s.memoizedState,a=a!==null?a.dehydrated!==null:!0),a)return s;s=s.return}while(s!==null);return null}function By(s,a,d,k,v){return(s.mode&1)===0?(s===a?s.flags|=65536:(s.flags|=128,d.flags|=131072,d.flags&=-52805,d.tag===1&&(d.alternate===null?d.tag=17:(a=ms(-1,1),a.tag=2,Ds(d,a,1))),d.lanes|=1),s):(s.flags|=65536,s.lanes=v,s)}var lT=O.ReactCurrentOwner,Ur=!1;function Rr(s,a,d,k){a.child=s===null?ay(a,null,d,k):la(a,s.child,d,k)}function Uy(s,a,d,k,v){d=d.render;var x=a.ref;return ua(a,v),k=hh(s,a,d,k,x,v),d=ph(),s!==null&&!Ur?(a.updateQueue=s.updateQueue,a.flags&=-2053,s.lanes&=~v,gs(s,a,v)):($n&&d&&Yf(a),a.flags|=1,Rr(s,a,k,v),a.child)}function Hy(s,a,d,k,v){if(s===null){var x=d.type;return typeof x=="function"&&!Wh(x)&&x.defaultProps===void 0&&d.compare===null&&d.defaultProps===void 0?(a.tag=15,a.type=x,Wy(s,a,x,k,v)):(s=Su(d.type,null,k,a,a.mode,v),s.ref=a.ref,s.return=a,a.child=s)}if(x=s.child,(s.lanes&v)===0){var C=x.memoizedProps;if(d=d.compare,d=d!==null?d:al,d(C,k)&&s.ref===a.ref)return gs(s,a,v)}return a.flags|=1,s=Ws(x,k),s.ref=a.ref,s.return=a,a.child=s}function Wy(s,a,d,k,v){if(s!==null){var x=s.memoizedProps;if(al(x,k)&&s.ref===a.ref)if(Ur=!1,a.pendingProps=k=x,(s.lanes&v)!==0)(s.flags&131072)!==0&&(Ur=!0);else return a.lanes=s.lanes,gs(s,a,v)}return Eh(s,a,d,k,v)}function Ky(s,a,d){var k=a.pendingProps,v=k.children,x=s!==null?s.memoizedState:null;if(k.mode==="hidden")if((a.mode&1)===0)a.memoizedState={baseLanes:0,cachePool:null,transitions:null},Nn(pa,ro),ro|=d;else{if((d&1073741824)===0)return s=x!==null?x.baseLanes|d:d,a.lanes=a.childLanes=1073741824,a.memoizedState={baseLanes:s,cachePool:null,transitions:null},a.updateQueue=null,Nn(pa,ro),ro|=s,null;a.memoizedState={baseLanes:0,cachePool:null,transitions:null},k=x!==null?x.baseLanes:d,Nn(pa,ro),ro|=k}else x!==null?(k=x.baseLanes|d,a.memoizedState=null):k=d,Nn(pa,ro),ro|=k;return Rr(s,a,v,d),a.child}function Zy(s,a){var d=a.ref;(s===null&&d!==null||s!==null&&s.ref!==d)&&(a.flags|=512,a.flags|=2097152)}function Eh(s,a,d,k,v){var x=Br(d)?ki:xr.current;return x=oa(a,x),ua(a,v),d=hh(s,a,d,k,x,v),k=ph(),s!==null&&!Ur?(a.updateQueue=s.updateQueue,a.flags&=-2053,s.lanes&=~v,gs(s,a,v)):($n&&k&&Yf(a),a.flags|=1,Rr(s,a,d,v),a.child)}function qy(s,a,d,k,v){if(Br(d)){var x=!0;Yc(a)}else x=!1;if(ua(a,v),a.stateNode===null)pu(s,a),My(a,d,k),vh(a,d,k,v),k=!0;else if(s===null){var C=a.stateNode,H=a.memoizedProps;C.props=H;var G=C.context,le=d.contextType;typeof le=="object"&&le!==null?le=ho(le):(le=Br(d)?ki:xr.current,le=oa(a,le));var Ne=d.getDerivedStateFromProps,Ae=typeof Ne=="function"||typeof C.getSnapshotBeforeUpdate=="function";Ae||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(H!==k||G!==le)&&Ly(a,C,k,le),Ps=!1;var Se=a.memoizedState;C.state=Se,su(a,k,C,v),G=a.memoizedState,H!==k||Se!==G||Fr.current||Ps?(typeof Ne=="function"&&(wh(a,d,Ne,k),G=a.memoizedState),(H=Ps||Oy(a,d,H,k,Se,G,le))?(Ae||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount()),typeof C.componentDidMount=="function"&&(a.flags|=4194308)):(typeof C.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=k,a.memoizedState=G),C.props=k,C.state=G,C.context=le,k=H):(typeof C.componentDidMount=="function"&&(a.flags|=4194308),k=!1)}else{C=a.stateNode,cy(s,a),H=a.memoizedProps,le=a.type===a.elementType?H:jo(a.type,H),C.props=le,Ae=a.pendingProps,Se=C.context,G=d.contextType,typeof G=="object"&&G!==null?G=ho(G):(G=Br(d)?ki:xr.current,G=oa(a,G));var Ke=d.getDerivedStateFromProps;(Ne=typeof Ke=="function"||typeof C.getSnapshotBeforeUpdate=="function")||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(H!==Ae||Se!==G)&&Ly(a,C,k,G),Ps=!1,Se=a.memoizedState,C.state=Se,su(a,k,C,v);var et=a.memoizedState;H!==Ae||Se!==et||Fr.current||Ps?(typeof Ke=="function"&&(wh(a,d,Ke,k),et=a.memoizedState),(le=Ps||Oy(a,d,le,k,Se,et,G)||!1)?(Ne||typeof C.UNSAFE_componentWillUpdate!="function"&&typeof C.componentWillUpdate!="function"||(typeof C.componentWillUpdate=="function"&&C.componentWillUpdate(k,et,G),typeof C.UNSAFE_componentWillUpdate=="function"&&C.UNSAFE_componentWillUpdate(k,et,G)),typeof C.componentDidUpdate=="function"&&(a.flags|=4),typeof C.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof C.componentDidUpdate!="function"||H===s.memoizedProps&&Se===s.memoizedState||(a.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||H===s.memoizedProps&&Se===s.memoizedState||(a.flags|=1024),a.memoizedProps=k,a.memoizedState=et),C.props=k,C.state=et,C.context=G,k=le):(typeof C.componentDidUpdate!="function"||H===s.memoizedProps&&Se===s.memoizedState||(a.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||H===s.memoizedProps&&Se===s.memoizedState||(a.flags|=1024),k=!1)}return _h(s,a,d,k,x,v)}function _h(s,a,d,k,v,x){Zy(s,a);var C=(a.flags&128)!==0;if(!k&&!C)return v&&Xk(a,d,!1),gs(s,a,x);k=a.stateNode,lT.current=a;var H=C&&typeof d.getDerivedStateFromError!="function"?null:k.render();return a.flags|=1,s!==null&&C?(a.child=la(a,s.child,null,x),a.child=la(a,null,H,x)):Rr(s,a,H,x),a.memoizedState=k.state,v&&Xk(a,d,!0),a.child}function Gy(s){var a=s.stateNode;a.pendingContext?Yk(s,a.pendingContext,a.pendingContext!==a.context):a.context&&Yk(s,a.context,!1),ah(s,a.containerInfo)}function Vy(s,a,d,k,v){return aa(),eh(v),a.flags|=256,Rr(s,a,d,k),a.child}var Sh={dehydrated:null,treeContext:null,retryLane:0};function Nh(s){return{baseLanes:s,cachePool:null,transitions:null}}function Yy(s,a,d){var k=a.pendingProps,v=Fn.current,x=!1,C=(a.flags&128)!==0,H;if((H=C)||(H=s!==null&&s.memoizedState===null?!1:(v&2)!==0),H?(x=!0,a.flags&=-129):(s===null||s.memoizedState!==null)&&(v|=1),Nn(Fn,v&1),s===null)return Jf(a),s=a.memoizedState,s!==null&&(s=s.dehydrated,s!==null)?((a.mode&1)===0?a.lanes=1:s.data==="$!"?a.lanes=8:a.lanes=1073741824,null):(C=k.children,s=k.fallback,x?(k=a.mode,x=a.child,C={mode:"hidden",children:C},(k&1)===0&&x!==null?(x.childLanes=0,x.pendingProps=C):x=Nu(C,k,0,null),s=Ti(s,k,d,null),x.return=a,s.return=a,x.sibling=s,a.child=x,a.child.memoizedState=Nh(d),a.memoizedState=Sh,s):Th(a,C));if(v=s.memoizedState,v!==null&&(H=v.dehydrated,H!==null))return cT(s,a,C,k,H,v,d);if(x){x=k.fallback,C=a.mode,v=s.child,H=v.sibling;var G={mode:"hidden",children:k.children};return(C&1)===0&&a.child!==v?(k=a.child,k.childLanes=0,k.pendingProps=G,a.deletions=null):(k=Ws(v,G),k.subtreeFlags=v.subtreeFlags&14680064),H!==null?x=Ws(H,x):(x=Ti(x,C,d,null),x.flags|=2),x.return=a,k.return=a,k.sibling=x,a.child=k,k=x,x=a.child,C=s.child.memoizedState,C=C===null?Nh(d):{baseLanes:C.baseLanes|d,cachePool:null,transitions:C.transitions},x.memoizedState=C,x.childLanes=s.childLanes&~d,a.memoizedState=Sh,k}return x=s.child,s=x.sibling,k=Ws(x,{mode:"visible",children:k.children}),(a.mode&1)===0&&(k.lanes=d),k.return=a,k.sibling=null,s!==null&&(d=a.deletions,d===null?(a.deletions=[s],a.flags|=16):d.push(s)),a.child=k,a.memoizedState=null,k}function Th(s,a){return a=Nu({mode:"visible",children:a},s.mode,0,null),a.return=s,s.child=a}function hu(s,a,d,k){return k!==null&&eh(k),la(a,s.child,null,d),s=Th(a,a.pendingProps.children),s.flags|=2,a.memoizedState=null,s}function cT(s,a,d,k,v,x,C){if(d)return a.flags&256?(a.flags&=-257,k=bh(Error(n(422))),hu(s,a,C,k)):a.memoizedState!==null?(a.child=s.child,a.flags|=128,null):(x=k.fallback,v=a.mode,k=Nu({mode:"visible",children:k.children},v,0,null),x=Ti(x,v,C,null),x.flags|=2,k.return=a,x.return=a,k.sibling=x,a.child=k,(a.mode&1)!==0&&la(a,s.child,null,C),a.child.memoizedState=Nh(C),a.memoizedState=Sh,x);if((a.mode&1)===0)return hu(s,a,C,null);if(v.data==="$!"){if(k=v.nextSibling&&v.nextSibling.dataset,k)var H=k.dgst;return k=H,x=Error(n(419)),k=bh(x,k,void 0),hu(s,a,C,k)}if(H=(C&s.childLanes)!==0,Ur||H){if(k=fr,k!==null){switch(C&-C){case 4:v=2;break;case 16:v=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:v=32;break;case 536870912:v=268435456;break;default:v=0}v=(v&(k.suspendedLanes|C))!==0?0:v,v!==0&&v!==x.retryLane&&(x.retryLane=v,ps(s,v),Io(k,s,v,-1))}return Hh(),k=bh(Error(n(421))),hu(s,a,C,k)}return v.data==="$?"?(a.flags|=128,a.child=s.child,a=xT.bind(null,s),v._reactRetry=a,null):(s=x.treeContext,no=$s(v.nextSibling),to=a,$n=!0,To=null,s!==null&&(uo[fo++]=fs,uo[fo++]=hs,uo[fo++]=yi,fs=s.id,hs=s.overflow,yi=a),a=Th(a,k.children),a.flags|=4096,a)}function Qy(s,a,d){s.lanes|=a;var k=s.alternate;k!==null&&(k.lanes|=a),oh(s.return,a,d)}function jh(s,a,d,k,v){var x=s.memoizedState;x===null?s.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:k,tail:d,tailMode:v}:(x.isBackwards=a,x.rendering=null,x.renderingStartTime=0,x.last=k,x.tail=d,x.tailMode=v)}function Xy(s,a,d){var k=a.pendingProps,v=k.revealOrder,x=k.tail;if(Rr(s,a,k.children,d),k=Fn.current,(k&2)!==0)k=k&1|2,a.flags|=128;else{if(s!==null&&(s.flags&128)!==0)e:for(s=a.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&Qy(s,d,a);else if(s.tag===19)Qy(s,d,a);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===a)break e;for(;s.sibling===null;){if(s.return===null||s.return===a)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}k&=1}if(Nn(Fn,k),(a.mode&1)===0)a.memoizedState=null;else switch(v){case"forwards":for(d=a.child,v=null;d!==null;)s=d.alternate,s!==null&&iu(s)===null&&(v=d),d=d.sibling;d=v,d===null?(v=a.child,a.child=null):(v=d.sibling,d.sibling=null),jh(a,!1,v,d,x);break;case"backwards":for(d=null,v=a.child,a.child=null;v!==null;){if(s=v.alternate,s!==null&&iu(s)===null){a.child=v;break}s=v.sibling,v.sibling=d,d=v,v=s}jh(a,!0,d,null,x);break;case"together":jh(a,!1,null,null,void 0);break;default:a.memoizedState=null}return a.child}function pu(s,a){(a.mode&1)===0&&s!==null&&(s.alternate=null,a.alternate=null,a.flags|=2)}function gs(s,a,d){if(s!==null&&(a.dependencies=s.dependencies),Ei|=a.lanes,(d&a.childLanes)===0)return null;if(s!==null&&a.child!==s.child)throw Error(n(153));if(a.child!==null){for(s=a.child,d=Ws(s,s.pendingProps),a.child=d,d.return=a;s.sibling!==null;)s=s.sibling,d=d.sibling=Ws(s,s.pendingProps),d.return=a;d.sibling=null}return a.child}function uT(s,a,d){switch(a.tag){case 3:Gy(a),aa();break;case 5:fy(a);break;case 1:Br(a.type)&&Yc(a);break;case 4:ah(a,a.stateNode.containerInfo);break;case 10:var k=a.type._context,v=a.memoizedProps.value;Nn(nu,k._currentValue),k._currentValue=v;break;case 13:if(k=a.memoizedState,k!==null)return k.dehydrated!==null?(Nn(Fn,Fn.current&1),a.flags|=128,null):(d&a.child.childLanes)!==0?Yy(s,a,d):(Nn(Fn,Fn.current&1),s=gs(s,a,d),s!==null?s.sibling:null);Nn(Fn,Fn.current&1);break;case 19:if(k=(d&a.childLanes)!==0,(s.flags&128)!==0){if(k)return Xy(s,a,d);a.flags|=128}if(v=a.memoizedState,v!==null&&(v.rendering=null,v.tail=null,v.lastEffect=null),Nn(Fn,Fn.current),k)break;return null;case 22:case 23:return a.lanes=0,Ky(s,a,d)}return gs(s,a,d)}var Jy,Ch,ew,tw;Jy=function(s,a){for(var d=a.child;d!==null;){if(d.tag===5||d.tag===6)s.appendChild(d.stateNode);else if(d.tag!==4&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===a)break;for(;d.sibling===null;){if(d.return===null||d.return===a)return;d=d.return}d.sibling.return=d.return,d=d.sibling}},Ch=function(){},ew=function(s,a,d,k){var v=s.memoizedProps;if(v!==k){s=a.stateNode,bi(Zo.current);var x=null;switch(d){case"input":v=Ue(s,v),k=Ue(s,k),x=[];break;case"select":v=ie({},v,{value:void 0}),k=ie({},k,{value:void 0}),x=[];break;case"textarea":v=mt(s,v),k=mt(s,k),x=[];break;default:typeof v.onClick!="function"&&typeof k.onClick=="function"&&(s.onclick=qc)}wn(d,k);var C;d=null;for(le in v)if(!k.hasOwnProperty(le)&&v.hasOwnProperty(le)&&v[le]!=null)if(le==="style"){var H=v[le];for(C in H)H.hasOwnProperty(C)&&(d||(d={}),d[C]="")}else le!=="dangerouslySetInnerHTML"&&le!=="children"&&le!=="suppressContentEditableWarning"&&le!=="suppressHydrationWarning"&&le!=="autoFocus"&&(o.hasOwnProperty(le)?x||(x=[]):(x=x||[]).push(le,null));for(le in k){var G=k[le];if(H=v!=null?v[le]:void 0,k.hasOwnProperty(le)&&G!==H&&(G!=null||H!=null))if(le==="style")if(H){for(C in H)!H.hasOwnProperty(C)||G&&G.hasOwnProperty(C)||(d||(d={}),d[C]="");for(C in G)G.hasOwnProperty(C)&&H[C]!==G[C]&&(d||(d={}),d[C]=G[C])}else d||(x||(x=[]),x.push(le,d)),d=G;else le==="dangerouslySetInnerHTML"?(G=G?G.__html:void 0,H=H?H.__html:void 0,G!=null&&H!==G&&(x=x||[]).push(le,G)):le==="children"?typeof G!="string"&&typeof G!="number"||(x=x||[]).push(le,""+G):le!=="suppressContentEditableWarning"&&le!=="suppressHydrationWarning"&&(o.hasOwnProperty(le)?(G!=null&&le==="onScroll"&&Cn("scroll",s),x||H===G||(x=[])):(x=x||[]).push(le,G))}d&&(x=x||[]).push("style",d);var le=x;(a.updateQueue=le)&&(a.flags|=4)}},tw=function(s,a,d,k){d!==k&&(a.flags|=4)};function xl(s,a){if(!$n)switch(s.tailMode){case"hidden":a=s.tail;for(var d=null;a!==null;)a.alternate!==null&&(d=a),a=a.sibling;d===null?s.tail=null:d.sibling=null;break;case"collapsed":d=s.tail;for(var k=null;d!==null;)d.alternate!==null&&(k=d),d=d.sibling;k===null?a||s.tail===null?s.tail=null:s.tail.sibling=null:k.sibling=null}}function _r(s){var a=s.alternate!==null&&s.alternate.child===s.child,d=0,k=0;if(a)for(var v=s.child;v!==null;)d|=v.lanes|v.childLanes,k|=v.subtreeFlags&14680064,k|=v.flags&14680064,v.return=s,v=v.sibling;else for(v=s.child;v!==null;)d|=v.lanes|v.childLanes,k|=v.subtreeFlags,k|=v.flags,v.return=s,v=v.sibling;return s.subtreeFlags|=k,s.childLanes=d,a}function dT(s,a,d){var k=a.pendingProps;switch(Qf(a),a.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return _r(a),null;case 1:return Br(a.type)&&Vc(),_r(a),null;case 3:return k=a.stateNode,da(),An(Fr),An(xr),uh(),k.pendingContext&&(k.context=k.pendingContext,k.pendingContext=null),(s===null||s.child===null)&&(eu(a)?a.flags|=4:s===null||s.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,To!==null&&(Fh(To),To=null))),Ch(s,a),_r(a),null;case 5:lh(a);var v=bi(kl.current);if(d=a.type,s!==null&&a.stateNode!=null)ew(s,a,d,k,v),s.ref!==a.ref&&(a.flags|=512,a.flags|=2097152);else{if(!k){if(a.stateNode===null)throw Error(n(166));return _r(a),null}if(s=bi(Zo.current),eu(a)){k=a.stateNode,d=a.type;var x=a.memoizedProps;switch(k[Ko]=a,k[fl]=x,s=(a.mode&1)!==0,d){case"dialog":Cn("cancel",k),Cn("close",k);break;case"iframe":case"object":case"embed":Cn("load",k);break;case"video":case"audio":for(v=0;v<cl.length;v++)Cn(cl[v],k);break;case"source":Cn("error",k);break;case"img":case"image":case"link":Cn("error",k),Cn("load",k);break;case"details":Cn("toggle",k);break;case"input":ct(k,x),Cn("invalid",k);break;case"select":k._wrapperState={wasMultiple:!!x.multiple},Cn("invalid",k);break;case"textarea":En(k,x),Cn("invalid",k)}wn(d,x),v=null;for(var C in x)if(x.hasOwnProperty(C)){var H=x[C];C==="children"?typeof H=="string"?k.textContent!==H&&(x.suppressHydrationWarning!==!0&&Zc(k.textContent,H,s),v=["children",H]):typeof H=="number"&&k.textContent!==""+H&&(x.suppressHydrationWarning!==!0&&Zc(k.textContent,H,s),v=["children",""+H]):o.hasOwnProperty(C)&&H!=null&&C==="onScroll"&&Cn("scroll",k)}switch(d){case"input":he(k),Ht(k,x,!0);break;case"textarea":he(k),V(k);break;case"select":case"option":break;default:typeof x.onClick=="function"&&(k.onclick=qc)}k=v,a.updateQueue=k,k!==null&&(a.flags|=4)}else{C=v.nodeType===9?v:v.ownerDocument,s==="http://www.w3.org/1999/xhtml"&&(s=ge(d)),s==="http://www.w3.org/1999/xhtml"?d==="script"?(s=C.createElement("div"),s.innerHTML="<script><\/script>",s=s.removeChild(s.firstChild)):typeof k.is=="string"?s=C.createElement(d,{is:k.is}):(s=C.createElement(d),d==="select"&&(C=s,k.multiple?C.multiple=!0:k.size&&(C.size=k.size))):s=C.createElementNS(s,d),s[Ko]=a,s[fl]=k,Jy(s,a,!1,!1),a.stateNode=s;e:{switch(C=_n(d,k),d){case"dialog":Cn("cancel",s),Cn("close",s),v=k;break;case"iframe":case"object":case"embed":Cn("load",s),v=k;break;case"video":case"audio":for(v=0;v<cl.length;v++)Cn(cl[v],s);v=k;break;case"source":Cn("error",s),v=k;break;case"img":case"image":case"link":Cn("error",s),Cn("load",s),v=k;break;case"details":Cn("toggle",s),v=k;break;case"input":ct(s,k),v=Ue(s,k),Cn("invalid",s);break;case"option":v=k;break;case"select":s._wrapperState={wasMultiple:!!k.multiple},v=ie({},k,{value:void 0}),Cn("invalid",s);break;case"textarea":En(s,k),v=mt(s,k),Cn("invalid",s);break;default:v=k}wn(d,v),H=v;for(x in H)if(H.hasOwnProperty(x)){var G=H[x];x==="style"?ye(s,G):x==="dangerouslySetInnerHTML"?(G=G?G.__html:void 0,G!=null&&un(s,G)):x==="children"?typeof G=="string"?(d!=="textarea"||G!=="")&&yn(s,G):typeof G=="number"&&yn(s,""+G):x!=="suppressContentEditableWarning"&&x!=="suppressHydrationWarning"&&x!=="autoFocus"&&(o.hasOwnProperty(x)?G!=null&&x==="onScroll"&&Cn("scroll",s):G!=null&&T(s,x,G,C))}switch(d){case"input":he(s),Ht(s,k,!1);break;case"textarea":he(s),V(s);break;case"option":k.value!=null&&s.setAttribute("value",""+be(k.value));break;case"select":s.multiple=!!k.multiple,x=k.value,x!=null?Ve(s,!!k.multiple,x,!1):k.defaultValue!=null&&Ve(s,!!k.multiple,k.defaultValue,!0);break;default:typeof v.onClick=="function"&&(s.onclick=qc)}switch(d){case"button":case"input":case"select":case"textarea":k=!!k.autoFocus;break e;case"img":k=!0;break e;default:k=!1}}k&&(a.flags|=4)}a.ref!==null&&(a.flags|=512,a.flags|=2097152)}return _r(a),null;case 6:if(s&&a.stateNode!=null)tw(s,a,s.memoizedProps,k);else{if(typeof k!="string"&&a.stateNode===null)throw Error(n(166));if(d=bi(kl.current),bi(Zo.current),eu(a)){if(k=a.stateNode,d=a.memoizedProps,k[Ko]=a,(x=k.nodeValue!==d)&&(s=to,s!==null))switch(s.tag){case 3:Zc(k.nodeValue,d,(s.mode&1)!==0);break;case 5:s.memoizedProps.suppressHydrationWarning!==!0&&Zc(k.nodeValue,d,(s.mode&1)!==0)}x&&(a.flags|=4)}else k=(d.nodeType===9?d:d.ownerDocument).createTextNode(k),k[Ko]=a,a.stateNode=k}return _r(a),null;case 13:if(An(Fn),k=a.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if($n&&no!==null&&(a.mode&1)!==0&&(a.flags&128)===0)oy(),aa(),a.flags|=98560,x=!1;else if(x=eu(a),k!==null&&k.dehydrated!==null){if(s===null){if(!x)throw Error(n(318));if(x=a.memoizedState,x=x!==null?x.dehydrated:null,!x)throw Error(n(317));x[Ko]=a}else aa(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;_r(a),x=!1}else To!==null&&(Fh(To),To=null),x=!0;if(!x)return a.flags&65536?a:null}return(a.flags&128)!==0?(a.lanes=d,a):(k=k!==null,k!==(s!==null&&s.memoizedState!==null)&&k&&(a.child.flags|=8192,(a.mode&1)!==0&&(s===null||(Fn.current&1)!==0?ir===0&&(ir=3):Hh())),a.updateQueue!==null&&(a.flags|=4),_r(a),null);case 4:return da(),Ch(s,a),s===null&&ul(a.stateNode.containerInfo),_r(a),null;case 10:return rh(a.type._context),_r(a),null;case 17:return Br(a.type)&&Vc(),_r(a),null;case 19:if(An(Fn),x=a.memoizedState,x===null)return _r(a),null;if(k=(a.flags&128)!==0,C=x.rendering,C===null)if(k)xl(x,!1);else{if(ir!==0||s!==null&&(s.flags&128)!==0)for(s=a.child;s!==null;){if(C=iu(s),C!==null){for(a.flags|=128,xl(x,!1),k=C.updateQueue,k!==null&&(a.updateQueue=k,a.flags|=4),a.subtreeFlags=0,k=d,d=a.child;d!==null;)x=d,s=k,x.flags&=14680066,C=x.alternate,C===null?(x.childLanes=0,x.lanes=s,x.child=null,x.subtreeFlags=0,x.memoizedProps=null,x.memoizedState=null,x.updateQueue=null,x.dependencies=null,x.stateNode=null):(x.childLanes=C.childLanes,x.lanes=C.lanes,x.child=C.child,x.subtreeFlags=0,x.deletions=null,x.memoizedProps=C.memoizedProps,x.memoizedState=C.memoizedState,x.updateQueue=C.updateQueue,x.type=C.type,s=C.dependencies,x.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),d=d.sibling;return Nn(Fn,Fn.current&1|2),a.child}s=s.sibling}x.tail!==null&&ln()>ma&&(a.flags|=128,k=!0,xl(x,!1),a.lanes=4194304)}else{if(!k)if(s=iu(C),s!==null){if(a.flags|=128,k=!0,d=s.updateQueue,d!==null&&(a.updateQueue=d,a.flags|=4),xl(x,!0),x.tail===null&&x.tailMode==="hidden"&&!C.alternate&&!$n)return _r(a),null}else 2*ln()-x.renderingStartTime>ma&&d!==1073741824&&(a.flags|=128,k=!0,xl(x,!1),a.lanes=4194304);x.isBackwards?(C.sibling=a.child,a.child=C):(d=x.last,d!==null?d.sibling=C:a.child=C,x.last=C)}return x.tail!==null?(a=x.tail,x.rendering=a,x.tail=a.sibling,x.renderingStartTime=ln(),a.sibling=null,d=Fn.current,Nn(Fn,k?d&1|2:d&1),a):(_r(a),null);case 22:case 23:return Uh(),k=a.memoizedState!==null,s!==null&&s.memoizedState!==null!==k&&(a.flags|=8192),k&&(a.mode&1)!==0?(ro&1073741824)!==0&&(_r(a),a.subtreeFlags&6&&(a.flags|=8192)):_r(a),null;case 24:return null;case 25:return null}throw Error(n(156,a.tag))}function fT(s,a){switch(Qf(a),a.tag){case 1:return Br(a.type)&&Vc(),s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 3:return da(),An(Fr),An(xr),uh(),s=a.flags,(s&65536)!==0&&(s&128)===0?(a.flags=s&-65537|128,a):null;case 5:return lh(a),null;case 13:if(An(Fn),s=a.memoizedState,s!==null&&s.dehydrated!==null){if(a.alternate===null)throw Error(n(340));aa()}return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 19:return An(Fn),null;case 4:return da(),null;case 10:return rh(a.type._context),null;case 22:case 23:return Uh(),null;case 24:return null;default:return null}}var mu=!1,Sr=!1,hT=typeof WeakSet=="function"?WeakSet:Set,Xe=null;function ha(s,a){var d=s.ref;if(d!==null)if(typeof d=="function")try{d(null)}catch(k){Qn(s,a,k)}else d.current=null}function Ah(s,a,d){try{d()}catch(k){Qn(s,a,k)}}var nw=!1;function pT(s,a){if(Uf=ui,s=Ok(),Of(s)){if("selectionStart"in s)var d={start:s.selectionStart,end:s.selectionEnd};else e:{d=(d=s.ownerDocument)&&d.defaultView||window;var k=d.getSelection&&d.getSelection();if(k&&k.rangeCount!==0){d=k.anchorNode;var v=k.anchorOffset,x=k.focusNode;k=k.focusOffset;try{d.nodeType,x.nodeType}catch{d=null;break e}var C=0,H=-1,G=-1,le=0,Ne=0,Ae=s,Se=null;t:for(;;){for(var Ke;Ae!==d||v!==0&&Ae.nodeType!==3||(H=C+v),Ae!==x||k!==0&&Ae.nodeType!==3||(G=C+k),Ae.nodeType===3&&(C+=Ae.nodeValue.length),(Ke=Ae.firstChild)!==null;)Se=Ae,Ae=Ke;for(;;){if(Ae===s)break t;if(Se===d&&++le===v&&(H=C),Se===x&&++Ne===k&&(G=C),(Ke=Ae.nextSibling)!==null)break;Ae=Se,Se=Ae.parentNode}Ae=Ke}d=H===-1||G===-1?null:{start:H,end:G}}else d=null}d=d||{start:0,end:0}}else d=null;for(Hf={focusedElem:s,selectionRange:d},ui=!1,Xe=a;Xe!==null;)if(a=Xe,s=a.child,(a.subtreeFlags&1028)!==0&&s!==null)s.return=a,Xe=s;else for(;Xe!==null;){a=Xe;try{var et=a.alternate;if((a.flags&1024)!==0)switch(a.tag){case 0:case 11:case 15:break;case 1:if(et!==null){var tt=et.memoizedProps,Jn=et.memoizedState,te=a.stateNode,Y=te.getSnapshotBeforeUpdate(a.elementType===a.type?tt:jo(a.type,tt),Jn);te.__reactInternalSnapshotBeforeUpdate=Y}break;case 3:var oe=a.stateNode.containerInfo;oe.nodeType===1?oe.textContent="":oe.nodeType===9&&oe.documentElement&&oe.removeChild(oe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Re){Qn(a,a.return,Re)}if(s=a.sibling,s!==null){s.return=a.return,Xe=s;break}Xe=a.return}return et=nw,nw=!1,et}function El(s,a,d){var k=a.updateQueue;if(k=k!==null?k.lastEffect:null,k!==null){var v=k=k.next;do{if((v.tag&s)===s){var x=v.destroy;v.destroy=void 0,x!==void 0&&Ah(a,d,x)}v=v.next}while(v!==k)}}function gu(s,a){if(a=a.updateQueue,a=a!==null?a.lastEffect:null,a!==null){var d=a=a.next;do{if((d.tag&s)===s){var k=d.create;d.destroy=k()}d=d.next}while(d!==a)}}function Ih(s){var a=s.ref;if(a!==null){var d=s.stateNode;switch(s.tag){case 5:s=d;break;default:s=d}typeof a=="function"?a(s):a.current=s}}function rw(s){var a=s.alternate;a!==null&&(s.alternate=null,rw(a)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(a=s.stateNode,a!==null&&(delete a[Ko],delete a[fl],delete a[qf],delete a[YN],delete a[QN])),s.stateNode=null,s.return=null,s.dependencies=null,s.memoizedProps=null,s.memoizedState=null,s.pendingProps=null,s.stateNode=null,s.updateQueue=null}function ow(s){return s.tag===5||s.tag===3||s.tag===4}function sw(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||ow(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function Rh(s,a,d){var k=s.tag;if(k===5||k===6)s=s.stateNode,a?d.nodeType===8?d.parentNode.insertBefore(s,a):d.insertBefore(s,a):(d.nodeType===8?(a=d.parentNode,a.insertBefore(s,d)):(a=d,a.appendChild(s)),d=d._reactRootContainer,d!=null||a.onclick!==null||(a.onclick=qc));else if(k!==4&&(s=s.child,s!==null))for(Rh(s,a,d),s=s.sibling;s!==null;)Rh(s,a,d),s=s.sibling}function $h(s,a,d){var k=s.tag;if(k===5||k===6)s=s.stateNode,a?d.insertBefore(s,a):d.appendChild(s);else if(k!==4&&(s=s.child,s!==null))for($h(s,a,d),s=s.sibling;s!==null;)$h(s,a,d),s=s.sibling}var yr=null,Co=!1;function zs(s,a,d){for(d=d.child;d!==null;)iw(s,a,d),d=d.sibling}function iw(s,a,d){if(Et&&typeof Et.onCommitFiberUnmount=="function")try{Et.onCommitFiberUnmount(lt,d)}catch{}switch(d.tag){case 5:Sr||ha(d,a);case 6:var k=yr,v=Co;yr=null,zs(s,a,d),yr=k,Co=v,yr!==null&&(Co?(s=yr,d=d.stateNode,s.nodeType===8?s.parentNode.removeChild(d):s.removeChild(d)):yr.removeChild(d.stateNode));break;case 18:yr!==null&&(Co?(s=yr,d=d.stateNode,s.nodeType===8?Zf(s.parentNode,d):s.nodeType===1&&Zf(s,d),ss(s)):Zf(yr,d.stateNode));break;case 4:k=yr,v=Co,yr=d.stateNode.containerInfo,Co=!0,zs(s,a,d),yr=k,Co=v;break;case 0:case 11:case 14:case 15:if(!Sr&&(k=d.updateQueue,k!==null&&(k=k.lastEffect,k!==null))){v=k=k.next;do{var x=v,C=x.destroy;x=x.tag,C!==void 0&&((x&2)!==0||(x&4)!==0)&&Ah(d,a,C),v=v.next}while(v!==k)}zs(s,a,d);break;case 1:if(!Sr&&(ha(d,a),k=d.stateNode,typeof k.componentWillUnmount=="function"))try{k.props=d.memoizedProps,k.state=d.memoizedState,k.componentWillUnmount()}catch(H){Qn(d,a,H)}zs(s,a,d);break;case 21:zs(s,a,d);break;case 22:d.mode&1?(Sr=(k=Sr)||d.memoizedState!==null,zs(s,a,d),Sr=k):zs(s,a,d);break;default:zs(s,a,d)}}function aw(s){var a=s.updateQueue;if(a!==null){s.updateQueue=null;var d=s.stateNode;d===null&&(d=s.stateNode=new hT),a.forEach(function(k){var v=ET.bind(null,s,k);d.has(k)||(d.add(k),k.then(v,v))})}}function Ao(s,a){var d=a.deletions;if(d!==null)for(var k=0;k<d.length;k++){var v=d[k];try{var x=s,C=a,H=C;e:for(;H!==null;){switch(H.tag){case 5:yr=H.stateNode,Co=!1;break e;case 3:yr=H.stateNode.containerInfo,Co=!0;break e;case 4:yr=H.stateNode.containerInfo,Co=!0;break e}H=H.return}if(yr===null)throw Error(n(160));iw(x,C,v),yr=null,Co=!1;var G=v.alternate;G!==null&&(G.return=null),v.return=null}catch(le){Qn(v,a,le)}}if(a.subtreeFlags&12854)for(a=a.child;a!==null;)lw(a,s),a=a.sibling}function lw(s,a){var d=s.alternate,k=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:if(Ao(a,s),Go(s),k&4){try{El(3,s,s.return),gu(3,s)}catch(tt){Qn(s,s.return,tt)}try{El(5,s,s.return)}catch(tt){Qn(s,s.return,tt)}}break;case 1:Ao(a,s),Go(s),k&512&&d!==null&&ha(d,d.return);break;case 5:if(Ao(a,s),Go(s),k&512&&d!==null&&ha(d,d.return),s.flags&32){var v=s.stateNode;try{yn(v,"")}catch(tt){Qn(s,s.return,tt)}}if(k&4&&(v=s.stateNode,v!=null)){var x=s.memoizedProps,C=d!==null?d.memoizedProps:x,H=s.type,G=s.updateQueue;if(s.updateQueue=null,G!==null)try{H==="input"&&x.type==="radio"&&x.name!=null&&We(v,x),_n(H,C);var le=_n(H,x);for(C=0;C<G.length;C+=2){var Ne=G[C],Ae=G[C+1];Ne==="style"?ye(v,Ae):Ne==="dangerouslySetInnerHTML"?un(v,Ae):Ne==="children"?yn(v,Ae):T(v,Ne,Ae,le)}switch(H){case"input":xn(v,x);break;case"textarea":Rt(v,x);break;case"select":var Se=v._wrapperState.wasMultiple;v._wrapperState.wasMultiple=!!x.multiple;var Ke=x.value;Ke!=null?Ve(v,!!x.multiple,Ke,!1):Se!==!!x.multiple&&(x.defaultValue!=null?Ve(v,!!x.multiple,x.defaultValue,!0):Ve(v,!!x.multiple,x.multiple?[]:"",!1))}v[fl]=x}catch(tt){Qn(s,s.return,tt)}}break;case 6:if(Ao(a,s),Go(s),k&4){if(s.stateNode===null)throw Error(n(162));v=s.stateNode,x=s.memoizedProps;try{v.nodeValue=x}catch(tt){Qn(s,s.return,tt)}}break;case 3:if(Ao(a,s),Go(s),k&4&&d!==null&&d.memoizedState.isDehydrated)try{ss(a.containerInfo)}catch(tt){Qn(s,s.return,tt)}break;case 4:Ao(a,s),Go(s);break;case 13:Ao(a,s),Go(s),v=s.child,v.flags&8192&&(x=v.memoizedState!==null,v.stateNode.isHidden=x,!x||v.alternate!==null&&v.alternate.memoizedState!==null||(Lh=ln())),k&4&&aw(s);break;case 22:if(Ne=d!==null&&d.memoizedState!==null,s.mode&1?(Sr=(le=Sr)||Ne,Ao(a,s),Sr=le):Ao(a,s),Go(s),k&8192){if(le=s.memoizedState!==null,(s.stateNode.isHidden=le)&&!Ne&&(s.mode&1)!==0)for(Xe=s,Ne=s.child;Ne!==null;){for(Ae=Xe=Ne;Xe!==null;){switch(Se=Xe,Ke=Se.child,Se.tag){case 0:case 11:case 14:case 15:El(4,Se,Se.return);break;case 1:ha(Se,Se.return);var et=Se.stateNode;if(typeof et.componentWillUnmount=="function"){k=Se,d=Se.return;try{a=k,et.props=a.memoizedProps,et.state=a.memoizedState,et.componentWillUnmount()}catch(tt){Qn(k,d,tt)}}break;case 5:ha(Se,Se.return);break;case 22:if(Se.memoizedState!==null){dw(Ae);continue}}Ke!==null?(Ke.return=Se,Xe=Ke):dw(Ae)}Ne=Ne.sibling}e:for(Ne=null,Ae=s;;){if(Ae.tag===5){if(Ne===null){Ne=Ae;try{v=Ae.stateNode,le?(x=v.style,typeof x.setProperty=="function"?x.setProperty("display","none","important"):x.display="none"):(H=Ae.stateNode,G=Ae.memoizedProps.style,C=G!=null&&G.hasOwnProperty("display")?G.display:null,H.style.display=jn("display",C))}catch(tt){Qn(s,s.return,tt)}}}else if(Ae.tag===6){if(Ne===null)try{Ae.stateNode.nodeValue=le?"":Ae.memoizedProps}catch(tt){Qn(s,s.return,tt)}}else if((Ae.tag!==22&&Ae.tag!==23||Ae.memoizedState===null||Ae===s)&&Ae.child!==null){Ae.child.return=Ae,Ae=Ae.child;continue}if(Ae===s)break e;for(;Ae.sibling===null;){if(Ae.return===null||Ae.return===s)break e;Ne===Ae&&(Ne=null),Ae=Ae.return}Ne===Ae&&(Ne=null),Ae.sibling.return=Ae.return,Ae=Ae.sibling}}break;case 19:Ao(a,s),Go(s),k&4&&aw(s);break;case 21:break;default:Ao(a,s),Go(s)}}function Go(s){var a=s.flags;if(a&2){try{e:{for(var d=s.return;d!==null;){if(ow(d)){var k=d;break e}d=d.return}throw Error(n(160))}switch(k.tag){case 5:var v=k.stateNode;k.flags&32&&(yn(v,""),k.flags&=-33);var x=sw(s);$h(s,x,v);break;case 3:case 4:var C=k.stateNode.containerInfo,H=sw(s);Rh(s,H,C);break;default:throw Error(n(161))}}catch(G){Qn(s,s.return,G)}s.flags&=-3}a&4096&&(s.flags&=-4097)}function mT(s,a,d){Xe=s,cw(s)}function cw(s,a,d){for(var k=(s.mode&1)!==0;Xe!==null;){var v=Xe,x=v.child;if(v.tag===22&&k){var C=v.memoizedState!==null||mu;if(!C){var H=v.alternate,G=H!==null&&H.memoizedState!==null||Sr;H=mu;var le=Sr;if(mu=C,(Sr=G)&&!le)for(Xe=v;Xe!==null;)C=Xe,G=C.child,C.tag===22&&C.memoizedState!==null?fw(v):G!==null?(G.return=C,Xe=G):fw(v);for(;x!==null;)Xe=x,cw(x),x=x.sibling;Xe=v,mu=H,Sr=le}uw(s)}else(v.subtreeFlags&8772)!==0&&x!==null?(x.return=v,Xe=x):uw(s)}}function uw(s){for(;Xe!==null;){var a=Xe;if((a.flags&8772)!==0){var d=a.alternate;try{if((a.flags&8772)!==0)switch(a.tag){case 0:case 11:case 15:Sr||gu(5,a);break;case 1:var k=a.stateNode;if(a.flags&4&&!Sr)if(d===null)k.componentDidMount();else{var v=a.elementType===a.type?d.memoizedProps:jo(a.type,d.memoizedProps);k.componentDidUpdate(v,d.memoizedState,k.__reactInternalSnapshotBeforeUpdate)}var x=a.updateQueue;x!==null&&dy(a,x,k);break;case 3:var C=a.updateQueue;if(C!==null){if(d=null,a.child!==null)switch(a.child.tag){case 5:d=a.child.stateNode;break;case 1:d=a.child.stateNode}dy(a,C,d)}break;case 5:var H=a.stateNode;if(d===null&&a.flags&4){d=H;var G=a.memoizedProps;switch(a.type){case"button":case"input":case"select":case"textarea":G.autoFocus&&d.focus();break;case"img":G.src&&(d.src=G.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(a.memoizedState===null){var le=a.alternate;if(le!==null){var Ne=le.memoizedState;if(Ne!==null){var Ae=Ne.dehydrated;Ae!==null&&ss(Ae)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Sr||a.flags&512&&Ih(a)}catch(Se){Qn(a,a.return,Se)}}if(a===s){Xe=null;break}if(d=a.sibling,d!==null){d.return=a.return,Xe=d;break}Xe=a.return}}function dw(s){for(;Xe!==null;){var a=Xe;if(a===s){Xe=null;break}var d=a.sibling;if(d!==null){d.return=a.return,Xe=d;break}Xe=a.return}}function fw(s){for(;Xe!==null;){var a=Xe;try{switch(a.tag){case 0:case 11:case 15:var d=a.return;try{gu(4,a)}catch(G){Qn(a,d,G)}break;case 1:var k=a.stateNode;if(typeof k.componentDidMount=="function"){var v=a.return;try{k.componentDidMount()}catch(G){Qn(a,v,G)}}var x=a.return;try{Ih(a)}catch(G){Qn(a,x,G)}break;case 5:var C=a.return;try{Ih(a)}catch(G){Qn(a,C,G)}}}catch(G){Qn(a,a.return,G)}if(a===s){Xe=null;break}var H=a.sibling;if(H!==null){H.return=a.return,Xe=H;break}Xe=a.return}}var gT=Math.ceil,ku=O.ReactCurrentDispatcher,Oh=O.ReactCurrentOwner,mo=O.ReactCurrentBatchConfig,en=0,fr=null,tr=null,wr=0,ro=0,pa=Os(0),ir=0,_l=null,Ei=0,yu=0,Mh=0,Sl=null,Hr=null,Lh=0,ma=1/0,ks=null,wu=!1,Ph=null,Fs=null,vu=!1,Bs=null,bu=0,Nl=0,Dh=null,xu=-1,Eu=0;function $r(){return(en&6)!==0?ln():xu!==-1?xu:xu=ln()}function Us(s){return(s.mode&1)===0?1:(en&2)!==0&&wr!==0?wr&-wr:JN.transition!==null?(Eu===0&&(Eu=Bo()),Eu):(s=Kt,s!==0||(s=window.event,s=s===void 0?16:qi(s.type)),s)}function Io(s,a,d,k){if(50<Nl)throw Nl=0,Dh=null,Error(n(185));Dr(s,d,k),((en&2)===0||s!==fr)&&(s===fr&&((en&2)===0&&(yu|=d),ir===4&&Hs(s,wr)),Wr(s,k),d===1&&en===0&&(a.mode&1)===0&&(ma=ln()+500,Qc&&Ls()))}function Wr(s,a){var d=s.callbackNode;So(s,a);var k=Dn(s,s===fr?wr:0);if(k===0)d!==null&&Bt(d),s.callbackNode=null,s.callbackPriority=0;else if(a=k&-k,s.callbackPriority!==a){if(d!=null&&Bt(d),a===1)s.tag===0?XN(pw.bind(null,s)):Jk(pw.bind(null,s)),GN(function(){(en&6)===0&&Ls()}),d=null;else{switch(dt(k)){case 1:d=Xr;break;case 4:d=Zn;break;case 16:d=ur;break;case 536870912:d=Fe;break;default:d=ur}d=xw(d,hw.bind(null,s))}s.callbackPriority=a,s.callbackNode=d}}function hw(s,a){if(xu=-1,Eu=0,(en&6)!==0)throw Error(n(327));var d=s.callbackNode;if(ga()&&s.callbackNode!==d)return null;var k=Dn(s,s===fr?wr:0);if(k===0)return null;if((k&30)!==0||(k&s.expiredLanes)!==0||a)a=_u(s,k);else{a=k;var v=en;en|=2;var x=gw();(fr!==s||wr!==a)&&(ks=null,ma=ln()+500,Si(s,a));do try{wT();break}catch(H){mw(s,H)}while(!0);nh(),ku.current=x,en=v,tr!==null?a=0:(fr=null,wr=0,a=ir)}if(a!==0){if(a===2&&(v=Pr(s),v!==0&&(k=v,a=zh(s,v))),a===1)throw d=_l,Si(s,0),Hs(s,k),Wr(s,ln()),d;if(a===6)Hs(s,k);else{if(v=s.current.alternate,(k&30)===0&&!kT(v)&&(a=_u(s,k),a===2&&(x=Pr(s),x!==0&&(k=x,a=zh(s,x))),a===1))throw d=_l,Si(s,0),Hs(s,k),Wr(s,ln()),d;switch(s.finishedWork=v,s.finishedLanes=k,a){case 0:case 1:throw Error(n(345));case 2:Ni(s,Hr,ks);break;case 3:if(Hs(s,k),(k&130023424)===k&&(a=Lh+500-ln(),10<a)){if(Dn(s,0)!==0)break;if(v=s.suspendedLanes,(v&k)!==k){$r(),s.pingedLanes|=s.suspendedLanes&v;break}s.timeoutHandle=Kf(Ni.bind(null,s,Hr,ks),a);break}Ni(s,Hr,ks);break;case 4:if(Hs(s,k),(k&4194240)===k)break;for(a=s.eventTimes,v=-1;0<k;){var C=31-mn(k);x=1<<C,C=a[C],C>v&&(v=C),k&=~x}if(k=v,k=ln()-k,k=(120>k?120:480>k?480:1080>k?1080:1920>k?1920:3e3>k?3e3:4320>k?4320:1960*gT(k/1960))-k,10<k){s.timeoutHandle=Kf(Ni.bind(null,s,Hr,ks),k);break}Ni(s,Hr,ks);break;case 5:Ni(s,Hr,ks);break;default:throw Error(n(329))}}}return Wr(s,ln()),s.callbackNode===d?hw.bind(null,s):null}function zh(s,a){var d=Sl;return s.current.memoizedState.isDehydrated&&(Si(s,a).flags|=256),s=_u(s,a),s!==2&&(a=Hr,Hr=d,a!==null&&Fh(a)),s}function Fh(s){Hr===null?Hr=s:Hr.push.apply(Hr,s)}function kT(s){for(var a=s;;){if(a.flags&16384){var d=a.updateQueue;if(d!==null&&(d=d.stores,d!==null))for(var k=0;k<d.length;k++){var v=d[k],x=v.getSnapshot;v=v.value;try{if(!No(x(),v))return!1}catch{return!1}}}if(d=a.child,a.subtreeFlags&16384&&d!==null)d.return=a,a=d;else{if(a===s)break;for(;a.sibling===null;){if(a.return===null||a.return===s)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function Hs(s,a){for(a&=~Mh,a&=~yu,s.suspendedLanes|=a,s.pingedLanes&=~a,s=s.expirationTimes;0<a;){var d=31-mn(a),k=1<<d;s[d]=-1,a&=~k}}function pw(s){if((en&6)!==0)throw Error(n(327));ga();var a=Dn(s,0);if((a&1)===0)return Wr(s,ln()),null;var d=_u(s,a);if(s.tag!==0&&d===2){var k=Pr(s);k!==0&&(a=k,d=zh(s,k))}if(d===1)throw d=_l,Si(s,0),Hs(s,a),Wr(s,ln()),d;if(d===6)throw Error(n(345));return s.finishedWork=s.current.alternate,s.finishedLanes=a,Ni(s,Hr,ks),Wr(s,ln()),null}function Bh(s,a){var d=en;en|=1;try{return s(a)}finally{en=d,en===0&&(ma=ln()+500,Qc&&Ls())}}function _i(s){Bs!==null&&Bs.tag===0&&(en&6)===0&&ga();var a=en;en|=1;var d=mo.transition,k=Kt;try{if(mo.transition=null,Kt=1,s)return s()}finally{Kt=k,mo.transition=d,en=a,(en&6)===0&&Ls()}}function Uh(){ro=pa.current,An(pa)}function Si(s,a){s.finishedWork=null,s.finishedLanes=0;var d=s.timeoutHandle;if(d!==-1&&(s.timeoutHandle=-1,qN(d)),tr!==null)for(d=tr.return;d!==null;){var k=d;switch(Qf(k),k.tag){case 1:k=k.type.childContextTypes,k!=null&&Vc();break;case 3:da(),An(Fr),An(xr),uh();break;case 5:lh(k);break;case 4:da();break;case 13:An(Fn);break;case 19:An(Fn);break;case 10:rh(k.type._context);break;case 22:case 23:Uh()}d=d.return}if(fr=s,tr=s=Ws(s.current,null),wr=ro=a,ir=0,_l=null,Mh=yu=Ei=0,Hr=Sl=null,vi!==null){for(a=0;a<vi.length;a++)if(d=vi[a],k=d.interleaved,k!==null){d.interleaved=null;var v=k.next,x=d.pending;if(x!==null){var C=x.next;x.next=v,k.next=C}d.pending=k}vi=null}return s}function mw(s,a){do{var d=tr;try{if(nh(),au.current=du,lu){for(var k=Bn.memoizedState;k!==null;){var v=k.queue;v!==null&&(v.pending=null),k=k.next}lu=!1}if(xi=0,dr=sr=Bn=null,yl=!1,wl=0,Oh.current=null,d===null||d.return===null){ir=1,_l=a,tr=null;break}e:{var x=s,C=d.return,H=d,G=a;if(a=wr,H.flags|=32768,G!==null&&typeof G=="object"&&typeof G.then=="function"){var le=G,Ne=H,Ae=Ne.tag;if((Ne.mode&1)===0&&(Ae===0||Ae===11||Ae===15)){var Se=Ne.alternate;Se?(Ne.updateQueue=Se.updateQueue,Ne.memoizedState=Se.memoizedState,Ne.lanes=Se.lanes):(Ne.updateQueue=null,Ne.memoizedState=null)}var Ke=Fy(C);if(Ke!==null){Ke.flags&=-257,By(Ke,C,H,x,a),Ke.mode&1&&zy(x,le,a),a=Ke,G=le;var et=a.updateQueue;if(et===null){var tt=new Set;tt.add(G),a.updateQueue=tt}else et.add(G);break e}else{if((a&1)===0){zy(x,le,a),Hh();break e}G=Error(n(426))}}else if($n&&H.mode&1){var Jn=Fy(C);if(Jn!==null){(Jn.flags&65536)===0&&(Jn.flags|=256),By(Jn,C,H,x,a),eh(fa(G,H));break e}}x=G=fa(G,H),ir!==4&&(ir=2),Sl===null?Sl=[x]:Sl.push(x),x=C;do{switch(x.tag){case 3:x.flags|=65536,a&=-a,x.lanes|=a;var te=Py(x,G,a);uy(x,te);break e;case 1:H=G;var Y=x.type,oe=x.stateNode;if((x.flags&128)===0&&(typeof Y.getDerivedStateFromError=="function"||oe!==null&&typeof oe.componentDidCatch=="function"&&(Fs===null||!Fs.has(oe)))){x.flags|=65536,a&=-a,x.lanes|=a;var Re=Dy(x,H,a);uy(x,Re);break e}}x=x.return}while(x!==null)}yw(d)}catch(rt){a=rt,tr===d&&d!==null&&(tr=d=d.return);continue}break}while(!0)}function gw(){var s=ku.current;return ku.current=du,s===null?du:s}function Hh(){(ir===0||ir===3||ir===2)&&(ir=4),fr===null||(Ei&268435455)===0&&(yu&268435455)===0||Hs(fr,wr)}function _u(s,a){var d=en;en|=2;var k=gw();(fr!==s||wr!==a)&&(ks=null,Si(s,a));do try{yT();break}catch(v){mw(s,v)}while(!0);if(nh(),en=d,ku.current=k,tr!==null)throw Error(n(261));return fr=null,wr=0,ir}function yT(){for(;tr!==null;)kw(tr)}function wT(){for(;tr!==null&&!cr();)kw(tr)}function kw(s){var a=bw(s.alternate,s,ro);s.memoizedProps=s.pendingProps,a===null?yw(s):tr=a,Oh.current=null}function yw(s){var a=s;do{var d=a.alternate;if(s=a.return,(a.flags&32768)===0){if(d=dT(d,a,ro),d!==null){tr=d;return}}else{if(d=fT(d,a),d!==null){d.flags&=32767,tr=d;return}if(s!==null)s.flags|=32768,s.subtreeFlags=0,s.deletions=null;else{ir=6,tr=null;return}}if(a=a.sibling,a!==null){tr=a;return}tr=a=s}while(a!==null);ir===0&&(ir=5)}function Ni(s,a,d){var k=Kt,v=mo.transition;try{mo.transition=null,Kt=1,vT(s,a,d,k)}finally{mo.transition=v,Kt=k}return null}function vT(s,a,d,k){do ga();while(Bs!==null);if((en&6)!==0)throw Error(n(327));d=s.finishedWork;var v=s.finishedLanes;if(d===null)return null;if(s.finishedWork=null,s.finishedLanes=0,d===s.current)throw Error(n(177));s.callbackNode=null,s.callbackPriority=0;var x=d.lanes|d.childLanes;if(bt(s,x),s===fr&&(tr=fr=null,wr=0),(d.subtreeFlags&2064)===0&&(d.flags&2064)===0||vu||(vu=!0,xw(ur,function(){return ga(),null})),x=(d.flags&15990)!==0,(d.subtreeFlags&15990)!==0||x){x=mo.transition,mo.transition=null;var C=Kt;Kt=1;var H=en;en|=4,Oh.current=null,pT(s,d),lw(d,s),FN(Hf),ui=!!Uf,Hf=Uf=null,s.current=d,mT(d),Qr(),en=H,Kt=C,mo.transition=x}else s.current=d;if(vu&&(vu=!1,Bs=s,bu=v),x=s.pendingLanes,x===0&&(Fs=null),cn(d.stateNode),Wr(s,ln()),a!==null)for(k=s.onRecoverableError,d=0;d<a.length;d++)v=a[d],k(v.value,{componentStack:v.stack,digest:v.digest});if(wu)throw wu=!1,s=Ph,Ph=null,s;return(bu&1)!==0&&s.tag!==0&&ga(),x=s.pendingLanes,(x&1)!==0?s===Dh?Nl++:(Nl=0,Dh=s):Nl=0,Ls(),null}function ga(){if(Bs!==null){var s=dt(bu),a=mo.transition,d=Kt;try{if(mo.transition=null,Kt=16>s?16:s,Bs===null)var k=!1;else{if(s=Bs,Bs=null,bu=0,(en&6)!==0)throw Error(n(331));var v=en;for(en|=4,Xe=s.current;Xe!==null;){var x=Xe,C=x.child;if((Xe.flags&16)!==0){var H=x.deletions;if(H!==null){for(var G=0;G<H.length;G++){var le=H[G];for(Xe=le;Xe!==null;){var Ne=Xe;switch(Ne.tag){case 0:case 11:case 15:El(8,Ne,x)}var Ae=Ne.child;if(Ae!==null)Ae.return=Ne,Xe=Ae;else for(;Xe!==null;){Ne=Xe;var Se=Ne.sibling,Ke=Ne.return;if(rw(Ne),Ne===le){Xe=null;break}if(Se!==null){Se.return=Ke,Xe=Se;break}Xe=Ke}}}var et=x.alternate;if(et!==null){var tt=et.child;if(tt!==null){et.child=null;do{var Jn=tt.sibling;tt.sibling=null,tt=Jn}while(tt!==null)}}Xe=x}}if((x.subtreeFlags&2064)!==0&&C!==null)C.return=x,Xe=C;else e:for(;Xe!==null;){if(x=Xe,(x.flags&2048)!==0)switch(x.tag){case 0:case 11:case 15:El(9,x,x.return)}var te=x.sibling;if(te!==null){te.return=x.return,Xe=te;break e}Xe=x.return}}var Y=s.current;for(Xe=Y;Xe!==null;){C=Xe;var oe=C.child;if((C.subtreeFlags&2064)!==0&&oe!==null)oe.return=C,Xe=oe;else e:for(C=Y;Xe!==null;){if(H=Xe,(H.flags&2048)!==0)try{switch(H.tag){case 0:case 11:case 15:gu(9,H)}}catch(rt){Qn(H,H.return,rt)}if(H===C){Xe=null;break e}var Re=H.sibling;if(Re!==null){Re.return=H.return,Xe=Re;break e}Xe=H.return}}if(en=v,Ls(),Et&&typeof Et.onPostCommitFiberRoot=="function")try{Et.onPostCommitFiberRoot(lt,s)}catch{}k=!0}return k}finally{Kt=d,mo.transition=a}}return!1}function ww(s,a,d){a=fa(d,a),a=Py(s,a,1),s=Ds(s,a,1),a=$r(),s!==null&&(Dr(s,1,a),Wr(s,a))}function Qn(s,a,d){if(s.tag===3)ww(s,s,d);else for(;a!==null;){if(a.tag===3){ww(a,s,d);break}else if(a.tag===1){var k=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof k.componentDidCatch=="function"&&(Fs===null||!Fs.has(k))){s=fa(d,s),s=Dy(a,s,1),a=Ds(a,s,1),s=$r(),a!==null&&(Dr(a,1,s),Wr(a,s));break}}a=a.return}}function bT(s,a,d){var k=s.pingCache;k!==null&&k.delete(a),a=$r(),s.pingedLanes|=s.suspendedLanes&d,fr===s&&(wr&d)===d&&(ir===4||ir===3&&(wr&130023424)===wr&&500>ln()-Lh?Si(s,0):Mh|=d),Wr(s,a)}function vw(s,a){a===0&&((s.mode&1)===0?a=1:(a=wt,wt<<=1,(wt&130023424)===0&&(wt=4194304)));var d=$r();s=ps(s,a),s!==null&&(Dr(s,a,d),Wr(s,d))}function xT(s){var a=s.memoizedState,d=0;a!==null&&(d=a.retryLane),vw(s,d)}function ET(s,a){var d=0;switch(s.tag){case 13:var k=s.stateNode,v=s.memoizedState;v!==null&&(d=v.retryLane);break;case 19:k=s.stateNode;break;default:throw Error(n(314))}k!==null&&k.delete(a),vw(s,d)}var bw;bw=function(s,a,d){if(s!==null)if(s.memoizedProps!==a.pendingProps||Fr.current)Ur=!0;else{if((s.lanes&d)===0&&(a.flags&128)===0)return Ur=!1,uT(s,a,d);Ur=(s.flags&131072)!==0}else Ur=!1,$n&&(a.flags&1048576)!==0&&ey(a,Jc,a.index);switch(a.lanes=0,a.tag){case 2:var k=a.type;pu(s,a),s=a.pendingProps;var v=oa(a,xr.current);ua(a,d),v=hh(null,a,k,s,v,d);var x=ph();return a.flags|=1,typeof v=="object"&&v!==null&&typeof v.render=="function"&&v.$$typeof===void 0?(a.tag=1,a.memoizedState=null,a.updateQueue=null,Br(k)?(x=!0,Yc(a)):x=!1,a.memoizedState=v.state!==null&&v.state!==void 0?v.state:null,ih(a),v.updater=fu,a.stateNode=v,v._reactInternals=a,vh(a,k,s,d),a=_h(null,a,k,!0,x,d)):(a.tag=0,$n&&x&&Yf(a),Rr(null,a,v,d),a=a.child),a;case 16:k=a.elementType;e:{switch(pu(s,a),s=a.pendingProps,v=k._init,k=v(k._payload),a.type=k,v=a.tag=ST(k),s=jo(k,s),v){case 0:a=Eh(null,a,k,s,d);break e;case 1:a=qy(null,a,k,s,d);break e;case 11:a=Uy(null,a,k,s,d);break e;case 14:a=Hy(null,a,k,jo(k.type,s),d);break e}throw Error(n(306,k,""))}return a;case 0:return k=a.type,v=a.pendingProps,v=a.elementType===k?v:jo(k,v),Eh(s,a,k,v,d);case 1:return k=a.type,v=a.pendingProps,v=a.elementType===k?v:jo(k,v),qy(s,a,k,v,d);case 3:e:{if(Gy(a),s===null)throw Error(n(387));k=a.pendingProps,x=a.memoizedState,v=x.element,cy(s,a),su(a,k,null,d);var C=a.memoizedState;if(k=C.element,x.isDehydrated)if(x={element:k,isDehydrated:!1,cache:C.cache,pendingSuspenseBoundaries:C.pendingSuspenseBoundaries,transitions:C.transitions},a.updateQueue.baseState=x,a.memoizedState=x,a.flags&256){v=fa(Error(n(423)),a),a=Vy(s,a,k,d,v);break e}else if(k!==v){v=fa(Error(n(424)),a),a=Vy(s,a,k,d,v);break e}else for(no=$s(a.stateNode.containerInfo.firstChild),to=a,$n=!0,To=null,d=ay(a,null,k,d),a.child=d;d;)d.flags=d.flags&-3|4096,d=d.sibling;else{if(aa(),k===v){a=gs(s,a,d);break e}Rr(s,a,k,d)}a=a.child}return a;case 5:return fy(a),s===null&&Jf(a),k=a.type,v=a.pendingProps,x=s!==null?s.memoizedProps:null,C=v.children,Wf(k,v)?C=null:x!==null&&Wf(k,x)&&(a.flags|=32),Zy(s,a),Rr(s,a,C,d),a.child;case 6:return s===null&&Jf(a),null;case 13:return Yy(s,a,d);case 4:return ah(a,a.stateNode.containerInfo),k=a.pendingProps,s===null?a.child=la(a,null,k,d):Rr(s,a,k,d),a.child;case 11:return k=a.type,v=a.pendingProps,v=a.elementType===k?v:jo(k,v),Uy(s,a,k,v,d);case 7:return Rr(s,a,a.pendingProps,d),a.child;case 8:return Rr(s,a,a.pendingProps.children,d),a.child;case 12:return Rr(s,a,a.pendingProps.children,d),a.child;case 10:e:{if(k=a.type._context,v=a.pendingProps,x=a.memoizedProps,C=v.value,Nn(nu,k._currentValue),k._currentValue=C,x!==null)if(No(x.value,C)){if(x.children===v.children&&!Fr.current){a=gs(s,a,d);break e}}else for(x=a.child,x!==null&&(x.return=a);x!==null;){var H=x.dependencies;if(H!==null){C=x.child;for(var G=H.firstContext;G!==null;){if(G.context===k){if(x.tag===1){G=ms(-1,d&-d),G.tag=2;var le=x.updateQueue;if(le!==null){le=le.shared;var Ne=le.pending;Ne===null?G.next=G:(G.next=Ne.next,Ne.next=G),le.pending=G}}x.lanes|=d,G=x.alternate,G!==null&&(G.lanes|=d),oh(x.return,d,a),H.lanes|=d;break}G=G.next}}else if(x.tag===10)C=x.type===a.type?null:x.child;else if(x.tag===18){if(C=x.return,C===null)throw Error(n(341));C.lanes|=d,H=C.alternate,H!==null&&(H.lanes|=d),oh(C,d,a),C=x.sibling}else C=x.child;if(C!==null)C.return=x;else for(C=x;C!==null;){if(C===a){C=null;break}if(x=C.sibling,x!==null){x.return=C.return,C=x;break}C=C.return}x=C}Rr(s,a,v.children,d),a=a.child}return a;case 9:return v=a.type,k=a.pendingProps.children,ua(a,d),v=ho(v),k=k(v),a.flags|=1,Rr(s,a,k,d),a.child;case 14:return k=a.type,v=jo(k,a.pendingProps),v=jo(k.type,v),Hy(s,a,k,v,d);case 15:return Wy(s,a,a.type,a.pendingProps,d);case 17:return k=a.type,v=a.pendingProps,v=a.elementType===k?v:jo(k,v),pu(s,a),a.tag=1,Br(k)?(s=!0,Yc(a)):s=!1,ua(a,d),My(a,k,v),vh(a,k,v,d),_h(null,a,k,!0,s,d);case 19:return Xy(s,a,d);case 22:return Ky(s,a,d)}throw Error(n(156,a.tag))};function xw(s,a){return dn(s,a)}function _T(s,a,d,k){this.tag=s,this.key=d,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=a,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 go(s,a,d,k){return new _T(s,a,d,k)}function Wh(s){return s=s.prototype,!(!s||!s.isReactComponent)}function ST(s){if(typeof s=="function")return Wh(s)?1:0;if(s!=null){if(s=s.$$typeof,s===F)return 11;if(s===fe)return 14}return 2}function Ws(s,a){var d=s.alternate;return d===null?(d=go(s.tag,a,s.key,s.mode),d.elementType=s.elementType,d.type=s.type,d.stateNode=s.stateNode,d.alternate=s,s.alternate=d):(d.pendingProps=a,d.type=s.type,d.flags=0,d.subtreeFlags=0,d.deletions=null),d.flags=s.flags&14680064,d.childLanes=s.childLanes,d.lanes=s.lanes,d.child=s.child,d.memoizedProps=s.memoizedProps,d.memoizedState=s.memoizedState,d.updateQueue=s.updateQueue,a=s.dependencies,d.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},d.sibling=s.sibling,d.index=s.index,d.ref=s.ref,d}function Su(s,a,d,k,v,x){var C=2;if(k=s,typeof s=="function")Wh(s)&&(C=1);else if(typeof s=="string")C=5;else e:switch(s){case R:return Ti(d.children,v,x,a);case I:C=8,v|=8;break;case _:return s=go(12,d,a,v|2),s.elementType=_,s.lanes=x,s;case ee:return s=go(13,d,a,v),s.elementType=ee,s.lanes=x,s;case se:return s=go(19,d,a,v),s.elementType=se,s.lanes=x,s;case ne:return Nu(d,v,x,a);default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case L:C=10;break e;case z:C=9;break e;case F:C=11;break e;case fe:C=14;break e;case ke:C=16,k=null;break e}throw Error(n(130,s==null?s:typeof s,""))}return a=go(C,d,a,v),a.elementType=s,a.type=k,a.lanes=x,a}function Ti(s,a,d,k){return s=go(7,s,k,a),s.lanes=d,s}function Nu(s,a,d,k){return s=go(22,s,k,a),s.elementType=ne,s.lanes=d,s.stateNode={isHidden:!1},s}function Kh(s,a,d){return s=go(6,s,null,a),s.lanes=d,s}function Zh(s,a,d){return a=go(4,s.children!==null?s.children:[],s.key,a),a.lanes=d,a.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},a}function NT(s,a,d,k,v){this.tag=a,this.containerInfo=s,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Jr(0),this.expirationTimes=Jr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Jr(0),this.identifierPrefix=k,this.onRecoverableError=v,this.mutableSourceEagerHydrationData=null}function qh(s,a,d,k,v,x,C,H,G){return s=new NT(s,a,d,H,G),a===1?(a=1,x===!0&&(a|=8)):a=0,x=go(3,null,null,a),s.current=x,x.stateNode=s,x.memoizedState={element:k,isDehydrated:d,cache:null,transitions:null,pendingSuspenseBoundaries:null},ih(x),s}function TT(s,a,d){var k=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Q,key:k==null?null:""+k,children:s,containerInfo:a,implementation:d}}function Ew(s){if(!s)return Ms;s=s._reactInternals;e:{if(zt(s)!==s||s.tag!==1)throw Error(n(170));var a=s;do{switch(a.tag){case 3:a=a.stateNode.context;break e;case 1:if(Br(a.type)){a=a.stateNode.__reactInternalMemoizedMergedChildContext;break e}}a=a.return}while(a!==null);throw Error(n(171))}if(s.tag===1){var d=s.type;if(Br(d))return Qk(s,d,a)}return a}function _w(s,a,d,k,v,x,C,H,G){return s=qh(d,k,!0,s,v,x,C,H,G),s.context=Ew(null),d=s.current,k=$r(),v=Us(d),x=ms(k,v),x.callback=a??null,Ds(d,x,v),s.current.lanes=v,Dr(s,v,k),Wr(s,k),s}function Tu(s,a,d,k){var v=a.current,x=$r(),C=Us(v);return d=Ew(d),a.context===null?a.context=d:a.pendingContext=d,a=ms(x,C),a.payload={element:s},k=k===void 0?null:k,k!==null&&(a.callback=k),s=Ds(v,a,C),s!==null&&(Io(s,v,C,x),ou(s,v,C)),C}function ju(s){if(s=s.current,!s.child)return null;switch(s.child.tag){case 5:return s.child.stateNode;default:return s.child.stateNode}}function Sw(s,a){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var d=s.retryLane;s.retryLane=d!==0&&d<a?d:a}}function Gh(s,a){Sw(s,a),(s=s.alternate)&&Sw(s,a)}function jT(){return null}var Nw=typeof reportError=="function"?reportError:function(s){console.error(s)};function Vh(s){this._internalRoot=s}Cu.prototype.render=Vh.prototype.render=function(s){var a=this._internalRoot;if(a===null)throw Error(n(409));Tu(s,a,null,null)},Cu.prototype.unmount=Vh.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var a=s.containerInfo;_i(function(){Tu(null,s,null,null)}),a[us]=null}};function Cu(s){this._internalRoot=s}Cu.prototype.unstable_scheduleHydration=function(s){if(s){var a=gr();s={blockedOn:null,target:s,priority:a};for(var d=0;d<vt.length&&a!==0&&a<vt[d].priority;d++);vt.splice(d,0,s),d===0&&Vn(s)}};function Yh(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function Au(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11&&(s.nodeType!==8||s.nodeValue!==" react-mount-point-unstable "))}function Tw(){}function CT(s,a,d,k,v){if(v){if(typeof k=="function"){var x=k;k=function(){var le=ju(C);x.call(le)}}var C=_w(a,k,s,0,null,!1,!1,"",Tw);return s._reactRootContainer=C,s[us]=C.current,ul(s.nodeType===8?s.parentNode:s),_i(),C}for(;v=s.lastChild;)s.removeChild(v);if(typeof k=="function"){var H=k;k=function(){var le=ju(G);H.call(le)}}var G=qh(s,0,!1,null,null,!1,!1,"",Tw);return s._reactRootContainer=G,s[us]=G.current,ul(s.nodeType===8?s.parentNode:s),_i(function(){Tu(a,G,d,k)}),G}function Iu(s,a,d,k,v){var x=d._reactRootContainer;if(x){var C=x;if(typeof v=="function"){var H=v;v=function(){var G=ju(C);H.call(G)}}Tu(a,C,s,v)}else C=CT(d,a,s,v,k);return ju(C)}Uo=function(s){switch(s.tag){case 3:var a=s.stateNode;if(a.current.memoizedState.isDehydrated){var d=Xt(a.pendingLanes);d!==0&&(zr(a,d|1),Wr(a,ln()),(en&6)===0&&(ma=ln()+500,Ls()))}break;case 13:_i(function(){var k=ps(s,1);if(k!==null){var v=$r();Io(k,s,1,v)}}),Gh(s,1)}},fn=function(s){if(s.tag===13){var a=ps(s,134217728);if(a!==null){var d=$r();Io(a,s,134217728,d)}Gh(s,134217728)}},Gt=function(s){if(s.tag===13){var a=Us(s),d=ps(s,a);if(d!==null){var k=$r();Io(d,s,a,k)}Gh(s,a)}},gr=function(){return Kt},qn=function(s,a){var d=Kt;try{return Kt=s,a()}finally{Kt=d}},In=function(s,a,d){switch(a){case"input":if(xn(s,d),a=d.name,d.type==="radio"&&a!=null){for(d=s;d.parentNode;)d=d.parentNode;for(d=d.querySelectorAll("input[name="+JSON.stringify(""+a)+'][type="radio"]'),a=0;a<d.length;a++){var k=d[a];if(k!==s&&k.form===s.form){var v=Gc(k);if(!v)throw Error(n(90));pe(k),xn(k,v)}}}break;case"textarea":Rt(s,d);break;case"select":a=d.value,a!=null&&Ve(s,!!d.multiple,a,!1)}},Ie=Bh,Je=_i;var AT={usingClientEntryPoint:!1,Events:[hl,na,Gc,B,ue,Bh]},Tl={findFiberByHostInstance:gi,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},IT={bundleType:Tl.bundleType,version:Tl.version,rendererPackageName:Tl.rendererPackageName,rendererConfig:Tl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:O.ReactCurrentDispatcher,findHostInstanceByFiber:function(s){return s=pn(s),s===null?null:s.stateNode},findFiberByHostInstance:Tl.findFiberByHostInstance||jT,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 Ru=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ru.isDisabled&&Ru.supportsFiber)try{lt=Ru.inject(IT),Et=Ru}catch{}}return Kr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=AT,Kr.createPortal=function(s,a){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Yh(a))throw Error(n(200));return TT(s,a,null,d)},Kr.createRoot=function(s,a){if(!Yh(s))throw Error(n(299));var d=!1,k="",v=Nw;return a!=null&&(a.unstable_strictMode===!0&&(d=!0),a.identifierPrefix!==void 0&&(k=a.identifierPrefix),a.onRecoverableError!==void 0&&(v=a.onRecoverableError)),a=qh(s,1,!1,null,null,d,!1,k,v),s[us]=a.current,ul(s.nodeType===8?s.parentNode:s),new Vh(a)},Kr.findDOMNode=function(s){if(s==null)return null;if(s.nodeType===1)return s;var a=s._reactInternals;if(a===void 0)throw typeof s.render=="function"?Error(n(188)):(s=Object.keys(s).join(","),Error(n(268,s)));return s=pn(a),s=s===null?null:s.stateNode,s},Kr.flushSync=function(s){return _i(s)},Kr.hydrate=function(s,a,d){if(!Au(a))throw Error(n(200));return Iu(null,s,a,!0,d)},Kr.hydrateRoot=function(s,a,d){if(!Yh(s))throw Error(n(405));var k=d!=null&&d.hydratedSources||null,v=!1,x="",C=Nw;if(d!=null&&(d.unstable_strictMode===!0&&(v=!0),d.identifierPrefix!==void 0&&(x=d.identifierPrefix),d.onRecoverableError!==void 0&&(C=d.onRecoverableError)),a=_w(a,null,s,1,d??null,v,!1,x,C),s[us]=a.current,ul(s),k)for(s=0;s<k.length;s++)d=k[s],v=d._getVersion,v=v(d._source),a.mutableSourceEagerHydrationData==null?a.mutableSourceEagerHydrationData=[d,v]:a.mutableSourceEagerHydrationData.push(d,v);return new Cu(a)},Kr.render=function(s,a,d){if(!Au(a))throw Error(n(200));return Iu(null,s,a,!1,d)},Kr.unmountComponentAtNode=function(s){if(!Au(s))throw Error(n(40));return s._reactRootContainer?(_i(function(){Iu(null,null,s,!1,function(){s._reactRootContainer=null,s[us]=null})}),!0):!1},Kr.unstable_batchedUpdates=Bh,Kr.unstable_renderSubtreeIntoContainer=function(s,a,d,k){if(!Au(d))throw Error(n(200));if(s==null||s._reactInternals===void 0)throw Error(n(38));return Iu(s,a,d,!1,k)},Kr.version="18.3.1-next-f1338f8080-20240426",Kr}var Mw;function UT(){if(Mw)return Jh.exports;Mw=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(),Jh.exports=BT(),Jh.exports}var Lw;function HT(){if(Lw)return $u;Lw=1;var e=UT();return $u.createRoot=e.createRoot,$u.hydrateRoot=e.hydrateRoot,$u}var WT=HT();const Wa="shell",Xb="check",KT="ToolSearch",Hm="AskUserQuestion",ZT=new Set(["edit","delete","move","execute"]),qT=new Set(["Edit","Write","MultiEdit","NotebookEdit","Bash"]);function Jb(e){return e.kind?ZT.has(e.kind):qT.has(e.name)}const GT=["read","edit","delete","move","search","execute","fetch"];function Wm(e){return GT.includes(e??"")}function ex(e,t){return(Wm(e.kind)||e.name===Hm)&&Fd(t)}function Fd(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 mc=[{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"}],ld="auto";function VT(e){return e.branch.startsWith("toyon/")}const ko="shell",bs="login";function YT(e,t){return`${e}/${t}`}function QT(e,t,n,r=0){var i;let o=e;for(let l=r;l>0;l--){let u=o.length-1;for(;u>=0&&((i=o[u])==null?void 0:i.proc)!==t;)u--;if(u<0)break;o=o===e?[...o]:o,o.splice(u,1)}return n?[...o,{proc:t,line:n}]:o}const XT=["use","always","off"];function tx(e){return e.find(t=>t.id==="default")}function JT(e){const t=tx(e);if(t!=null&&t.description)return e.find(n=>n!==t&&n.name===t.description)}function On(e){return e.worktree!==void 0}function Di(e){return e.kind==="main"}function gc(e){return e.kind==="spare"}function Ar(e){return gc(e)||Di(e)}function Km(e){return e.kind==="worktree"}function nx(e){return e.kind==="worktree"&&VT(e)}function Ri(e){var t;return e.kind==="worktree"&&((t=e.from)==null?void 0:t.kind)!=="pr"}function Ju(e){return e.kind==="worktree"}function Bd(e){return!!e.branch&&!e.locked&&!(e.worktree&&Ar(e.worktree))}const Jl=e=>{var t;return e.promptedAt??((t=e.lastTurn)==null?void 0:t.at)??e.createdAt},ej=e=>Ar(e)?0:1,tj=e=>e.variant?`group:${e.variant.group}`:`row:${e.id}`;function nj(e){const t=[],n=new Map;for(const r of e){const o=r.worktree,i=tj(o),l=n.get(i);if(l){l.rows.push(r),l.at=Math.max(l.at,Jl(o));continue}const u={tier:ej(o),at:Jl(o),rows:[r]};t.push(u),n.set(i,u)}return t.sort((r,o)=>r.tier-o.tier||o.at-r.at),t.flatMap(r=>r.rows.length>1?r.rows.sort((o,i)=>{var l,u;return(((l=o.worktree.variant)==null?void 0:l.index)??0)-(((u=i.worktree.variant)==null?void 0:u.index)??0)}):r.rows)}const Pw="not opened in ";function rj(e){const t=e.lastIndexOf(Pw);return t<0?{what:e}:{what:e.slice(0,t).replace(/,\s*$/,""),idle:e.slice(t+Pw.length)}}const rx={image:6,paste:4,file:8,pick:8},oj={image:"image",paste:"paste",file:"file",pick:"element"},sj={image:"Image",paste:"Pasted text"},ox=(e,t)=>`${sj[e]} ${t}`,Zm=e=>`at most ${rx[e]} ${oj[e]}s per message`,ij=(e,t)=>e.filter(n=>n.kind===t).length,aj=(e,t)=>Math.max(0,rx[t]-ij(e,t));function sx(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 ix(e,t){const n={...t};return e.map(r=>[r,n[r.kind]++])}function ax(e,t){const n={...e};for(const r of t)n[r.kind]++;return n}function qm(e){return e>=1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}const ed=[{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"}],lj=new Set(["zen","close","back","forward"]);function lx(e,{guest:t=!1}={}){var r,o;if(e.altKey){if(e.metaKey||e.ctrlKey)return null;const i=ed.find(l=>l.alt&&!!l.shift===e.shiftKey&&(l.key===e.key||l.key.length===1&&e.code===`Key${l.key.toUpperCase()}`));return i&&i.id!=="worktree"?{id:i.id}:null}if(!e.metaKey&&!e.ctrlKey){if(e.shiftKey||t)return null;const i=ed.find(l=>l.bareAlias===e.key);return i&&i.id!=="worktree"?{id:i.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 i of ed){if(i.id==="worktree")continue;const l=i.ctrlAlias;if(l&&e.ctrlKey&&l.key===n&&!!l.shift===e.shiftKey&&!(t&&l.hostOnly))return{id:i.id};if(e.metaKey&&e.shiftKey&&((r=i.cmdShiftAlias)!=null&&r.includes(n)))return{id:i.id};if(!i.alt&&!(e.ctrlKey&&!i.ctrl||!!i.shift!==e.shiftKey)&&(i.key===n||(o=i.aliases)!=null&&o.includes(n)))return{id:i.id}}return null}function cj(e){return e.altKey||e.key.toLowerCase()!=="s"?!1:!!e.ctrlKey!==e.metaKey}function cx(e){const t=ed.find(n=>n.id===e);if(!t)throw new Error(`unknown chord ${e}`);return t}function uj(e,t){return e===t-1?"⌘9":e<8?`⌘${e+1}`:void 0}function dj(e,t){return t===0?null:e===9?t-1:e-1<t?e-1:null}function fj(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 hj(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 pj(e,t){const n=cx(e);return!!n.textKeeps&&fj(t)&&!(n.emptyGives&&hj(t))}const mj=["Find","Preview","Panels","Worktrees"],Wl={"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"}},gj={ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Backspace:"⌫",Tab:"Tab"};function kj(e,t={}){var u;const n=cx(e),r=Wl[e],o=r.advertise&&t[r.advertise.when]?r.advertise.key:n.key;if(o===n.bareAlias)return o;const i=o==="1-9"?"1-9":gj[o]??o.toUpperCase(),l=o!==n.key&&o===((u=n.ctrlAlias)==null?void 0:u.key)?n.ctrlAlias:void 0;return l?`⌃${l.shift?"⇧":""}${i}`:`${n.alt?"⌥":n.ctrl?"⌃":"⌘"}${n.shift?"⇧":""}${i}`}function yj(e){return Object.keys(Wl).filter(t=>Wl[t].section===e&&!Wl[t].hidden)}const Dw={m:6e4,h:60*6e4};function wj(e){const[t,n]=vj(e);return`${t}${n.charAt(0)}`}function vj(e){const t=e/Dw.h;if(t>=1&&Number.isInteger(t))return[t,"hour"];const n=e/Dw.m;return n>=1&&Number.isInteger(n)?[n,"minute"]:n>=60?[Math.round(n),"minute"]:[Math.max(1,Math.round(e/1e3)),"second"]}const ec={folder:{shared:".toyon/settings.json",local:".toyon/settings.local.json"},root:{shared:"toyon.json",local:"toyon.local.json"}};function ux(e){return typeof e=="string"?e:e.cmd}function bj(e){return typeof e!="string"&&e.from==="trunk"}function xj(e){return[...e.setup??[],...e.teardown??[],...Object.values(e.run).map(ux),...Object.values(e.profiles??{}).flatMap(n=>Object.values(n.env??{}))].some(n=>n.includes("TOYON_WORKTREE"))}function Ej(e){return e===ec.folder.local||e===ec.root.local}function _j(e){return Ej(e)?"local":"shared"}function Sj(e,t){return(Object.values(ec).find(r=>r.shared===e||r.local===e)??ec.folder)[t]}function Nj(e){var o,i;let t;try{t=new URL(e.trim())}catch{return null}if(t.protocol!=="https:"&&!(t.protocol==="http:"&&Gm(t.hostname)))return null;const n=(o=t.hash.match(/pair=([A-Za-z0-9_-]+)/))==null?void 0:o[1];if(n)return{origin:t.origin,code:n};const r=(i=t.hash.match(/token=([a-f0-9]+)/))==null?void 0:i[1];return r?{origin:t.origin,token:r}:null}const Tj=e=>e.endsWith(".ts.net"),zw=e=>e.length<2?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function jj(e){if(e===null)return{ok:!0,text:"Your phone needs Tailscale on, signed in to the same tailnet."};if(e.length===0)return{ok:!1,text:"No phone has joined your tailnet. Install Tailscale on it and sign in to the same account first."};const t=e.filter(r=>r.online).map(r=>r.name);if(t.length>0)return{ok:!0,text:`${zw(t)} ${t.length>1?"are":"is"} on your tailnet.`};const n=e.map(r=>r.name);return{ok:!1,text:`${zw(n)} ${n.length>1?"are":"is"} not answering on your tailnet. Check Tailscale is on there.`}}const Cj="toyon_grant";function Gm(e){return e==="127.0.0.1"||e==="::1"||e==="[::1]"||e==="localhost"||e.endsWith(".localhost")}function Aj(e,t,n){return e.replace("{id}",t).replace("{port}",String(n))}const Ij=4401,Rj=25e4;function $j(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(i=>({mark:" ",value:i}));return o.push(...Oj(e.slice(n,e.length-r),t.slice(n,t.length-r))),o.push(...e.slice(e.length-r).map(i=>({mark:" ",value:i}))),o}function Oj(e,t){if(e.length===0)return t.map(u=>({mark:"+",value:u}));if(t.length===0)return e.map(u=>({mark:"-",value:u}));if((e.length+1)*(t.length+1)>Rj)return[...e.map(u=>({mark:"-",value:u})),...t.map(u=>({mark:"+",value:u}))];const n=t.length+1,r=new Uint32Array((e.length+1)*n);for(let u=e.length-1;u>=0;u--)for(let c=t.length-1;c>=0;c--)r[u*n+c]=e[u]===t[c]?(r[(u+1)*n+c+1]??0)+1:Math.max(r[(u+1)*n+c]??0,r[u*n+c+1]??0);const o=[];let i=0,l=0;for(;i<e.length&&l<t.length;)e[i]===t[l]?(o.push({mark:" ",value:e[i]}),i++,l++):(r[(i+1)*n+l]??0)>=(r[i*n+l+1]??0)?(o.push({mark:"-",value:e[i]}),i++):(o.push({mark:"+",value:t[l]}),l++);for(;i<e.length;)o.push({mark:"-",value:e[i++]});for(;l<t.length;)o.push({mark:"+",value:t[l++]});return o}const Mj=/[\p{L}\p{N}_$]+|\s+|[^\s\p{L}\p{N}_$]/gu;function Fw(e){return e.match(Mj)??[]}const Lj=.4;function Pj(e,t){if(e===t)return null;const n=$j(Fw(e),Fw(t));let r=0;for(const o of n)o.mark===" "&&(r+=o.value.length);return r<Lj*Math.max(e.length,t.length)?null:{before:Bw(n,"-"),after:Bw(n,"+")}}function Bw(e,t){const n=[];for(const r of e){if(r.mark!==" "&&r.mark!==t)continue;const o=r.mark===t,i=n[n.length-1];i&&i.changed===o?i.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 dx(n)}function Uw(e){const t=[[]];for(const n of e){const r=n.text.split(`
|
|
42
|
+
`);for(const[o,i]of r.entries())o>0&&t.push([]),i&&t[t.length-1].push({text:i,changed:n.changed})}return t.map(dx)}function dx(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 Dj=[{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"}],zj=[{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"}],Fj=[{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)"}],Up="merge",Hp="merge";function Oi(e){var n,r,o;const t=((n=e.land)==null?void 0:n.route)??Up;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 Ud(e){return e.base??e.defaultBranch}function Bj(e){return e.base!==void 0&&e.base!==e.defaultBranch}function cd(e,t="main"){const n={merge:"merge into",squash:"squash onto",rebase:"rebase onto"}[e.merge??Hp];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 open a PR that GitHub merges when its rules allow":"Commit, push the branch and open a PR"}}const Uj="https://toyon.cloud",Hj=e=>`${Uj}/#add=${encodeURIComponent(e)}`;function fx(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 Hw(e,t="|"){return e.map(n=>mx(n)).join(t)}function Wp(e,t){return typeof t=="bigint"?t.toString():t}function Hd(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Wj(e){return e==null}function Vm(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Kj(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 Vr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function oi(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Zj(e){return JSON.stringify(e)}function qj(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const hx="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function tc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Gj=Hd(()=>{var e;if(Fo.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 nc(e){if(tc(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(tc(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function px(e){return nc(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Vj=new Set(["string","number","symbol"]);function Ma(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function si(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 it(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 mx(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Yj(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const Qj={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 Xj(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 i=oi(e._zod.def,{get shape(){const l={};for(const u of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,u))throw new Error(`Unrecognized key: "${String(u)}"`);t[u]&&Vr(l,u,n.shape[u])}return Vr(this,"shape",l),l},checks:[]});return si(e,i)}function Jj(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 i=oi(e._zod.def,{get shape(){const l={...e._zod.def.shape};for(const u of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,u))throw new Error(`Unrecognized key: "${String(u)}"`);t[u]&&delete l[u]}return Vr(this,"shape",l),l},checks:[]});return si(e,i)}function eC(e,t){if(!nc(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const l of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(i,l)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=oi(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Vr(this,"shape",i),i}});return si(e,o)}function tC(e,t){if(!nc(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=oi(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Vr(this,"shape",r),r}});return si(e,n)}function nC(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=oi(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t._zod.def.shape};return Vr(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return si(e,n)}function Ww(e,t,n,r="partial"){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const u=oi(t._zod.def,{get shape(){const c=t._zod.def.shape,h={...c};if(n)for(const p of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(c,p))throw new Error(`Unrecognized key: "${String(p)}"`);n[p]&&(h[p]=e?new e({type:"optional",innerType:c[p]}):c[p])}else for(const p of Reflect.ownKeys(c))h[p]=e?new e({type:"optional",innerType:c[p]}):c[p];return Vr(this,"shape",h),h},checks:[]});return si(t,u)}function rC(e,t,n){const r=oi(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const l of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(i,l))throw new Error(`Unrecognized key: "${String(l)}"`);n[l]&&(i[l]=new e({type:"nonoptional",innerType:o[l]}))}else for(const l of Reflect.ownKeys(o))i[l]=new e({type:"nonoptional",innerType:o[l]});return Vr(this,"shape",i),i}});return si(t,r)}function xa(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 oC(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 Wd(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Cl(e){return typeof e=="string"?e:e==null?void 0:e.message}function Kw(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function Ka(e,t,n){var m,y,w,b,E,N,j,T,O,U;var r;const o=(y=(m=e.inst)==null?void 0:m._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 i=e.schema!==e.inst?(b=(w=e.schema)==null?void 0:w._zod.def)==null?void 0:b.error:void 0,l=e.message?e.message:Cl((j=(N=(E=e.inst)==null?void 0:E._zod.def)==null?void 0:N.error)==null?void 0:j.call(N,e))??Cl(i==null?void 0:i(e))??Cl((T=t==null?void 0:t.error)==null?void 0:T.call(t,e))??Cl((O=n.customError)==null?void 0:O.call(n,e))??Cl((U=n.localeError)==null?void 0:U.call(n,e))??"Invalid input",{inst:u,schema:c,continue:h,input:p,...g}=e;return g.path??(g.path=[]),g.message=l,t!=null&&t.reportInput&&(g.input=p),g}const sC=/[\uD800-\uDBFF]/;function Ym(e){const t=e.length;if(!sC.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 Qm(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function iC(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 rc(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function aC(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):lC(e,n,r.value)}}function La(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function gx(e,t,n){return La(e,t,n,!1)}function lC(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:La(this,t,n.bind(this))},set(r){La(this,t,r)}})}function cC(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let np,Qs=!1;const uC={configurable:!0,get(){Qs=!0}};function kn(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&np!==e._zod){np=void 0;return}np=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,uC);const o=Qs;Qs=!1;try{const i=n(this);return Qs?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),Qs=Qs||o,i}catch(i){throw delete this[t],Qs=Qs||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function dC(e,t,n,r){const o=cC(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){const i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,i),i.value=n(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:i})}})}const fC="~constantCatch";function hC(e){const t=()=>e;return t[fC]=!0,t}var Zw;const rp={value:void 0,enumerable:!1};let qw="captureStackTrace"in Error?Error:null;function pC(e){const t=qw;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return qw=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function ve(e,t,n,r){const o={};function i(m){this.def=m,this.constr=g,this.traits=new Set}i.prototype=o;const l=n,u=l&&new WeakSet;function c(m,y){if(!m._zod){rp.value=new i(y);try{Object.defineProperty(m,"_zod",rp)}finally{rp.value=void 0}}if(m._zod.traits.has(e))return;if(m._zod.traits.add(e),t(m,y),u){const b=Object.getPrototypeOf(m),E=m._zod.constr.prototype;let N=b;for(;N&&N!==E;)N=Object.getPrototypeOf(N);const j=N??b;u.has(j)||(u.add(j),aC(j,l))}const w=g.prototype;for(const b in w)Object.prototype.hasOwnProperty.call(w,b)&&(b in m||(m[b]=w[b].bind(m)))}const h=(r==null?void 0:r.Parent)??Object;class p extends h{}Object.defineProperty(p,"name",{value:e});function g(m){var E;const y=r!=null&&r.Parent?pC(p):this;c(y,m);const w=y._zod.deferred;if(w){for(const N of w)N();y._zod.deferred=void 0}const b=(E=globalThis.__zod_globalConfig)==null?void 0:E.postProcessor;return b&&b(y),y}return Object.defineProperty(g,"init",{value:c}),Object.defineProperty(g,Symbol.hasInstance,{value:m=>{var y,w;return r!=null&&r.Parent&&m instanceof r.Parent?!0:(w=(y=m==null?void 0:m._zod)==null?void 0:y.traits)==null?void 0:w.has(e)}}),Object.defineProperty(g,"name",{value:e}),g}class Ta extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class kx extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Zw=globalThis).__zod_globalConfig??(Zw.__zod_globalConfig={});const Fo=globalThis.__zod_globalConfig;function ii(e){return e&&Object.assign(Fo,e),Fo}function mC(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Wp,2)),e.message}function gC(e){this._zod.message=e}const kC={get:mC,set:gC,enumerable:!0,configurable:!0},op={value:void 0,enumerable:!1},sp={value:void 0,enumerable:!1},Gw=new WeakSet([Object.prototype,Error.prototype]),yx=(e,t)=>{e.name="$ZodError",op.value=e._zod,Object.defineProperty(e,"_zod",op),sp.value=t,Object.defineProperty(e,"issues",sp),op.value=void 0,sp.value=void 0,Object.defineProperty(e,"message",kC);const n=Object.getPrototypeOf(e);Gw.has(n)||(Gw.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})}}))},wx=ve("$ZodError",yx),vx=ve("$ZodError",yx,void 0,{Parent:Error});function yC(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 wC(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?yC(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n}}function vC(e,t=n=>n.message){const n={_errors:[]},r=(o,i=[])=>{for(const l of o.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(u=>r({issues:u},[...i,...l.path]));else if(l.code==="invalid_key")r({issues:l.issues},[...i,...l.path]);else if(l.code==="invalid_element")r({issues:l.issues},[...i,...l.path]);else{const u=[...i,...l.path];if(u.length===0)n._errors.push(t(l));else{let c=n,h=0;for(;h<u.length;){const p=u[h],g=h===u.length-1;if(p==="_errors"){g&&c._errors.push(t(l)),h++;continue}Object.prototype.hasOwnProperty.call(c,p)||Object.defineProperty(c,p,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const m=c[p];g&&m._errors.push(t(l)),c=m,h++}}}};return r(e),n}function Kd(e,t){return{callee:(t==null?void 0:t.callee)??e,Err:t==null?void 0:t.Err}}const Xm=e=>{const t=(n,r,o,i)=>{const l=o?{...o,async:!1}:{async:!1},u=n._zod.run({value:r,issues:[]},l);if(u instanceof Promise)throw new Ta;if(u.issues.length){const c=new((i==null?void 0:i.Err)??e)(u.issues.map(h=>Ka(h,l,ii())));throw hx(c,(i==null?void 0:i.callee)??t),c}return u.value};return t},Jm=e=>{const t=async(n,r,o,i)=>{const l=o?{...o,async:!0}:{async:!0};let u=n._zod.run({value:r,issues:[]},l);if(u instanceof Promise&&(u=await u),u.issues.length){const c=new((i==null?void 0:i.Err)??e)(u.issues.map(h=>Ka(h,l,ii())));throw hx(c,(i==null?void 0:i.callee)??t),c}return u.value};return t},Zd=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new Ta;return i.issues.length?{success:!1,error:new(e??wx)(i.issues.map(l=>Ka(l,o,ii())))}:{success:!0,data:i.value}},bC=Zd(vx),qd=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(l=>Ka(l,o,ii())))}:{success:!0,data:i.value}},xC=qd(vx),EC=e=>{const t=Xm(e),n=(r,o,i,l)=>{const u=i?{...i,direction:"backward"}:{direction:"backward"};return t(r,o,u,Kd(n,l))};return n},_C=e=>{const t=Xm(e),n=(r,o,i,l)=>t(r,o,i,Kd(n,l));return n},SC=e=>{const t=Jm(e),n=async(r,o,i,l)=>{const u=i?{...i,direction:"backward"}:{direction:"backward"};return await t(r,o,u,Kd(n,l))};return n},NC=e=>{const t=Jm(e),n=async(r,o,i,l)=>await t(r,o,i,Kd(n,l));return n},TC=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Zd(e)(t,n,o)},jC=e=>(t,n,r)=>Zd(e)(t,n,r),CC=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return qd(e)(t,n,o)},AC=e=>async(t,n,r)=>qd(e)(t,n,r),IC=/^[cC][0-9a-z]{6,}$/,RC=/^[0-9a-z]+$/,$C=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,OC=/^[0-9a-vA-V]{20}$/,MC=/^[A-Za-z0-9]{27}$/,LC=/^[a-zA-Z0-9_-]{21}$/;function PC(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const DC=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,zC=/^([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})$/,Vw=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)$/,FC=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,BC="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function UC(){return new RegExp(BC,"u")}const HC=/^(?:(?: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])$/,WC=/^(([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}|:))$/,KC=/^((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])$/,ZC=/^(([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])$/,qC=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,bx=/^[A-Za-z0-9_-]*$/,GC=/^https?$/,VC=/^\+[1-9]\d{6,14}$/,xx="(?:(?:\\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 YC(e){return new RegExp(`^${e}$`)}const QC=YC(xx);function Kp(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 XC(e){return new RegExp(`^${Kp(e)}$`)}function JC(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${Kp({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${Kp({precision:e.precision})}`:n;return new RegExp(`^${xx}T(?:${r})$`)}const eA=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}$`)},tA=/^-?\d+$/,nA=/^-?\d+(?:\.\d+)?$/,rA=/^(?:true|false)$/i,oA=/^[^A-Z]*$/,sA=/^[^a-z]*$/,Yr=ve("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),eg=e=>{const t=e.value;return!Wj(t)&&t.length!==void 0},ud={number:"number",bigint:"bigint",object:"date"},Ex=ve("$ZodCheckLessThan",(e,t)=>{Yr.init(e,t);const n=ud[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(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:ud[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})}}),_x=ve("$ZodCheckGreaterThan",(e,t)=>{Yr.init(e,t);const n=ud[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(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:ud[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})}}),iA=ve("$ZodCheckMultipleOf",(e,t)=>{Yr.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):Kj(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})}}),aA=ve("$ZodCheckNumberFormat",(e,t)=>{var l;Yr.init(e,t),t.format=t.format||"float64";const n=(l=t.format)==null?void 0:l.includes("int"),r=n?"int":"number",[o,i]=Qj[t.format];e._zod.onattach.push(u=>{const c=u._zod.bag;c.format=t.format,c.minimum=o,c.maximum=i,n&&(c.pattern=tA)}),e._zod.check=u=>{const c=u.value;if(n){if(!Number.isInteger(c)){u.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?u.issues.push({input:c,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}):u.issues.push({input:c,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}}c<o&&u.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>i&&u.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),lA=ve("$ZodCheckMaxLength",(e,t)=>{var n;Yr.init(e,t),(n=e._zod.def).when??(n.when=eg),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,i=o.length;if((typeof o=="string"&&i>t.maximum?Ym(o):i)<=t.maximum)return;const u=Qm(o);r.issues.push({origin:u,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),cA=ve("$ZodCheckMinLength",(e,t)=>{var n;Yr.init(e,t),(n=e._zod.def).when??(n.when=eg),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,i=o.length;if((typeof o=="string"&&i>=t.minimum&&i<t.minimum*2?Ym(o):i)>=t.minimum)return;const u=Qm(o);r.issues.push({origin:u,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),uA=ve("$ZodCheckLengthEquals",(e,t)=>{var n;Yr.init(e,t),(n=e._zod.def).when??(n.when=eg),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,i=o.length,l=typeof o=="string"&&i>=t.length&&i<=t.length*2?Ym(o):i;if(l===t.length)return;const u=Qm(o),c=l>t.length;r.issues.push({origin:u,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Gd=ve("$ZodCheckStringFormat",(e,t)=>{var n,r;Yr.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.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=()=>{})}),dA=ve("$ZodCheckRegex",(e,t)=>{Gd.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})}}),fA=ve("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=oA),Gd.init(e,t)}),hA=ve("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=sA),Gd.init(e,t)}),pA=ve("$ZodCheckIncludes",(e,t)=>{Yr.init(e,t);const n=Ma(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.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})}}),mA=ve("$ZodCheckStartsWith",(e,t)=>{Yr.init(e,t);const n=new RegExp(`^${Ma(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})}}),gA=ve("$ZodCheckEndsWith",(e,t)=>{Yr.init(e,t);const n=new RegExp(`.*${Ma(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})}}),kA=ve("$ZodCheckOverwrite",(e,t)=>{Yr.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class yA{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(l=>l),o=Math.min(...r.map(l=>l.length-l.trimStart().length)),i=r.map(l=>l.slice(o)).map(l=>" ".repeat(this.indent*2)+l);for(const l of i)this.content.push(l)}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 wA={major:4,minor:5,patch:4},Ln=ve("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=wA;const r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r!=null&&r.length?[...r]:[];for(const l of o)for(const u of l._zod.onattach)u(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),(i=e._zod.deferred)==null||i.push(()=>{e._zod.run=e._zod.parse});else{const l=(c,h,p)=>{if(c.memo)return c;let g=xa(c),m;for(const y of h){if(y._zod.def.when){if(oC(c)||!y._zod.def.when(c))continue}else if(g)continue;const w=c.issues.length,b=y._zod.check(c);if(b instanceof Promise&&(p==null?void 0:p.async)===!1)throw new Ta;if(m||b instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await b,c.issues.length!==w&&(Kw(c.issues,w,e),g||(g=xa(c,w)))});else{if(c.issues.length===w)continue;Kw(c.issues,w,e),g||(g=xa(c,w))}}return m?m.then(()=>c):c},u=(c,h,p)=>{if(xa(c))return c.aborted=!0,c;const g=l(h,o,p);if(g instanceof Promise){if(p.async===!1)throw new Ta;return g.then(m=>e._zod.parse(m,p))}return e._zod.parse(g,p)};e._zod.run=(c,h)=>{if(h.skipChecks)return e._zod.parse(c,h);if(h.direction==="backward"){const g=e._zod.parse({value:c.value,issues:[]},{...h,skipChecks:!0});return g instanceof Promise?g.then(m=>u(m,c,h)):u(g,c,h)}const p=e._zod.parse(c,h);if(p instanceof Promise){if(h.async===!1)throw new Ta;return p.then(g=>l(g,o,h))}return l(p,o,h)}}},{get"~standard"(){return gx(this,"~standard",Sx(this))},set"~standard"(e){La(this,"~standard",e)}}),Yw=e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}};function Sx(e){return{validate:t=>{try{return Yw(bC(e,t))}catch{return xC(e,t).then(Yw)}},vendor:"zod",version:1}}const tg=ve("$ZodString",(e,t)=>{var n;Ln.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??eA(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}}),Pn=ve("$ZodStringFormat",(e,t)=>{Gd.init(e,t),tg.init(e,t)}),vA=ve("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=zC),Pn.init(e,t)}),bA=ve("$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=Vw(r))}else t.pattern??(t.pattern=Vw());Pn.init(e,t)}),xA=ve("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=FC),Pn.init(e,t)}),Nx=1,Tx=2;function EA(e,t){var n;if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===GC.source&&!/^https?:\/\//i.test(e))return Nx;try{return new URL(e)}catch{return Tx}}const _A=/[\t\n\r]/g;function SA(e){return e.replace(_A,"")}function NA(e,t){return t.lastIndex=0,t.test(e.hostname)}function TA(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const jA=ve("$ZodURL",(e,t)=>{Pn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=EA(r,t);if(o===Nx){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===Tx){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!NA(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&&!TA(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:SA(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),CA=ve("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=UC()),Pn.init(e,t)}),AA=ve("$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?LC:PC(t.length)),Pn.init(e,t)}),IA=ve("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=IC),Pn.init(e,t)}),RA=ve("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=RC),Pn.init(e,t)}),$A=ve("$ZodULID",(e,t)=>{t.pattern??(t.pattern=$C),Pn.init(e,t)}),OA=ve("$ZodXID",(e,t)=>{t.pattern??(t.pattern=OC),Pn.init(e,t)}),MA=ve("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=MC),Pn.init(e,t)}),LA=ve("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=JC(t)),Pn.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(n=>{n._zod.bag.laxFormat=!0}))}),PA=ve("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=QC),Pn.init(e,t)}),DA=ve("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=XC(t)),Pn.init(e,t)}),zA=ve("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=DC),Pn.init(e,t)}),FA=ve("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=HC),Pn.init(e,t),e._zod.bag.format="ipv4"}),BA=/^[0-9a-fA-F:.]+$/;function jx(e){if(!BA.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}const UA=ve("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=WC),Pn.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{jx(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),HA=ve("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=KC),Pn.init(e,t)});function WA(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:jx(n)}const KA=ve("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ZC),Pn.init(e,t),e._zod.check=n=>{WA(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Cx(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const ZA=ve("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=qC),Pn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Cx(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function qA(e){if(!bx.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Cx(n)}const GA=ve("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=bx),Pn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{qA(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),VA=ve("$ZodE164",(e,t)=>{t.pattern??(t.pattern=VC),Pn.init(e,t)});function YA(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 QA=ve("$ZodJWT",(e,t)=>{Pn.init(e,t),e._zod.check=n=>{YA(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Ax=ve("$ZodNumber",(e,t)=>{Ln.init(e,t),e._zod.pattern=e._zod.bag.pattern??nA,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 i=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,...i?{received:i}:{}}),n}}),XA=ve("$ZodNumberFormat",(e,t)=>{aA.init(e,t),Ax.init(e,t)}),JA=ve("$ZodBoolean",(e,t)=>{Ln.init(e,t),e._zod.pattern=rA,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}}),eI=ve("$ZodUnknown",(e,t)=>{Ln.init(e,t),e._zod.parse=n=>n}),tI=ve("$ZodNever",(e,t)=>{Ln.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Qw(e,t,n){e.issues.length&&t.issues.push(...Wd(n,e.issues)),t.value[n]=e.value}const nI=ve("$ZodArray",(e,t)=>{Ln.init(e,t);const n=Fo.memoizer;n==null||n.attach(e),e._zod.parse=(r,o)=>{const i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=n?n.alloc(e,r,Array(i.length),o):Array(i.length);const l=[];for(let u=0;u<i.length;u++){const c=i[u],h=t.element._zod.run({value:c,issues:[]},o);h instanceof Promise?l.push(h.then(p=>Qw(p,r,u))):Qw(h,r,u)}return l.length?Promise.all(l).then(()=>r):r}});function dd(e,t,n,r,o,i){const l=n in r,u=i==="optional";if(!(!l&&u&&o==="optional")){if(e.issues.length){if(o!==void 0&&u&&!l)return;t.issues.push(...Wd(n,e.issues))}if(!l&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?l&&(t.value[n]=void 0):t.value[n]=e.value}}const rI=[];function Ix(e){var l,u,c,h;const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:rI,o=r.length?[...t,...r]:t;for(const p of o)if(!((h=(c=(u=(l=e.shape)==null?void 0:l[p])==null?void 0:u._zod)==null?void 0:c.traits)!=null&&h.has("$ZodType")))throw new Error(`Invalid element at key "${String(p)}": expected a Zod schema`);const i=Yj(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function Rx(e,t,n,r,o,i){const l=[],u=o.keySet,c=o.catchall._zod,h=c.def.type,p=c.optin,g=c.optout;for(const m in t){if(u.has(m))continue;if(m==="__proto__"){h==="never"&&l.push(m);continue}if(h==="never"){l.push(m);continue}const y=c.run({value:t[m],issues:[]},r);y instanceof Promise?e.push(y.then(w=>dd(w,n,m,t,p,g))):dd(y,n,m,t,p,g)}return l.length&&n.issues.push({code:"unrecognized_keys",keys:l,input:t,inst:i,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const Zp=new WeakMap,oI=ve("$ZodObject",(e,t)=>{Ln.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const c=t.shape;Zp.set(t,c),Object.defineProperty(t,"shape",{get:()=>{const h={...c};return Object.defineProperty(t,"shape",{value:h}),Zp.set(t,h),h}})}const r=Hd(()=>Ix(t));kn(e,"propValues",c=>{const h=c.def.shape,p={};for(const g in h){const m=h[g]._zod;if(m.values){Object.prototype.hasOwnProperty.call(p,g)||Vr(p,g,new Set);for(const y of m.values)p[g].add(y);m.optin!==void 0&&p[g].add(void 0)}}return p});const o=tc,i=t.catchall;let l;const u=Fo.memoizer;u==null||u.attach(e),e._zod.parse=(c,h)=>{l??(l=r.value);const p=c.value;if(!o(p))return c.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),c;c.value=u?u.alloc(e,c,{},h):{};const g=[],m=l.shape;for(const y of l.allKeys){if(y==="__proto__")continue;const w=m[y],b=w._zod.optin,E=w._zod.optout,N=w._zod.run({value:p[y],issues:[]},h);N instanceof Promise?g.push(N.then(j=>dd(j,c,y,p,b,E))):dd(N,c,y,p,b,E)}return i?Rx(g,p,c,h,r.value,e):g.length?Promise.all(g).then(()=>c):c}}),sI=ve("$ZodObjectJIT",(e,t)=>{oI.init(e,t);const n=e._zod.parse,r=Hd(()=>Ix(t)),o=Fo.memoizer,i=y=>{var U,Q;const w=r.value,b=w.symbolKeys,E=new yA(["payload","ctx"],{shape:y,inst:e,memo:o,syms:b}),N=R=>`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`,j=(R,I)=>`
|
|
47
|
+
for (let i = 0; i < ${R}.issues.length; i++) {
|
|
48
|
+
const iss = ${R}.issues[i];
|
|
49
|
+
iss.path = iss.path ? [${I}, ...iss.path] : [${I}];
|
|
50
|
+
payload.issues.push(iss);
|
|
51
|
+
}`;E.write("const input = payload.value;");const T=Object.create(null);let O=0;for(const R of w.allKeys)T[R]=`key_${O++}`;E.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const R of w.allKeys){if(R==="__proto__")continue;const I=T[R],_=typeof R=="symbol"?`syms[${b.indexOf(R)}]`:Zj(R),L=`${_} in input`,z=y[R],F=(U=z==null?void 0:z._zod)==null?void 0:U.optin,ee=F!==void 0,se=((Q=z==null?void 0:z._zod)==null?void 0:Q.optout)==="optional";if(E.write(`const ${I} = ${N(_)};`),ee&&se){const fe=F==="optional"?`${I}_present`:`${I}.value !== undefined || ${I}_present`;E.write(`
|
|
52
|
+
const ${I}_present = ${L};
|
|
53
|
+
if (!${I}.issues.length || ${I}_present) {
|
|
54
|
+
if (${I}.issues.length) {${j(I,_)}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (${fe}) {
|
|
58
|
+
newResult[${_}] = ${I}.value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
`)}else ee?E.write(`
|
|
63
|
+
if (${I}.issues.length) {${j(I,_)}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (${I}.value === undefined) {
|
|
67
|
+
if (${L}) {
|
|
68
|
+
newResult[${_}] = undefined;
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
newResult[${_}] = ${I}.value;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
`):E.write(`
|
|
75
|
+
const ${I}_present = ${L};
|
|
76
|
+
if (${I}.issues.length) {${j(I,_)}
|
|
77
|
+
}
|
|
78
|
+
if (!${I}_present && !${I}.issues.length) {
|
|
79
|
+
payload.issues.push({
|
|
80
|
+
code: "invalid_type",
|
|
81
|
+
expected: "nonoptional",
|
|
82
|
+
input: undefined,
|
|
83
|
+
path: [${_}]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (${I}_present) {
|
|
88
|
+
newResult[${_}] = ${I}.value;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
`)}return E.write("payload.value = newResult;"),E.write("return payload;"),E.compile()};let l;const u=tc,c=!Fo.jitless,p=c&&Gj.value,g=t.catchall;let m;e._zod.parse=(y,w)=>{m??(m=r.value);const b=y.value;return u(b)?c&&p&&(w==null?void 0:w.async)===!1&&w.jitless!==!0?(l||(l=i(t.shape)),y=l(y,w),g?Rx([],b,y,w,m,e):y):n(y,w):(y.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),y)}});function Xw(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!xa(i));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(i=>i.issues.map(l=>Ka(l,r,ii())))}),t)}const $x=ve("$ZodUnion",(e,t)=>{Ln.init(e,t),kn(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),kn(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),kn(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)))}),kn(e,"pattern",r=>{if(r.def.options.every(o=>o._zod.pattern)){const o=r.def.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>Vm(i.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 i=!1;const l=[];for(const u of t.options){const c=u._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)l.push(c),i=!0;else{if(c.issues.length===0)return c;l.push(c)}}return i?Promise.all(l).then(u=>Xw(u,r,e,o)):Xw(l,r,e,o)}}),iI=ve("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,$x.init(e,t);const n=e._zod.parse;kn(e,"propValues",o=>{const i={};for(const l of o.def.options){const u=l._zod.propValues;if(!u||Object.keys(u).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(l)}"`);for(const[c,h]of Object.entries(u)){Object.prototype.hasOwnProperty.call(i,c)||Vr(i,c,new Set);for(const p of h)i[c].add(p)}}return i}),t.options.forEach((o,i)=>{const l=Zp.get(o._zod.def);if(l&&!Object.prototype.hasOwnProperty.call(l,t.discriminator))throw new Error(`Invalid discriminated union option at index "${i}"`)});const r=Hd(()=>{var l;const o=t.options,i=new Map;for(const u of o){const c=(l=u._zod.propValues)==null?void 0:l[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(u)}"`);for(const h of c){if(i.has(h))throw new Error(`Duplicate discriminator value "${String(h)}"`);i.set(h,u)}}return i});e._zod.parse=(o,i)=>{const l=o.value;if(!tc(l))return o.issues.push({code:"invalid_type",expected:"object",input:l,inst:e}),o;const u=r.value.get(l==null?void 0:l[t.discriminator]);return u?u._zod.run(o,i):t.unionFallback||i.direction==="backward"?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:l,path:[t.discriminator],inst:e}),o)}}),aI=ve("$ZodIntersection",(e,t)=>{Ln.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),l=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||l instanceof Promise?Promise.all([i,l]).then(([c,h])=>Jw(n,c,h)):Jw(n,i,l)}});function qp(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(nc(e)&&nc(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(const i of r){if(i==="__proto__")continue;const l=qp(e[i],t[i]);if(!l.valid)return{valid:!1,mergeErrorPath:[i,...l.mergeErrorPath]};o[i]=l.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],i=t[r],l=qp(o,i);if(!l.valid)return{valid:!1,mergeErrorPath:[r,...l.mergeErrorPath]};n.push(l.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Jw(e,t,n){const r=new Map;let o;const i=new Map,l=(h,p)=>{var m,y;let g;if(h.code==="unrecognized_keys"&&!((m=h.path)!=null&&m.length))o??(o=h),g=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]);i.has(w)||i.set(w,h),g=[w]}else return!1;for(const w of g)r.has(w)||r.set(w,{}),r.get(w)[p]=!0;return!0};for(const h of t.issues)l(h,"l")||e.issues.push(h);for(const h of n.issues)l(h,"r")||e.issues.push(h);const u=[...r].filter(([,h])=>h.l&&h.r).map(([h])=>h);if(u.length){const h=o?u.filter(p=>o.keys.includes(p)):[];h.length&&e.issues.push({...o,keys:h});for(const p of u)!h.includes(p)&&i.has(p)&&e.issues.push(i.get(p))}const c=qp(t.value,n.value);if(!c.valid){if(xa(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const lI=ve("$ZodTuple",(e,t)=>{Ln.init(e,t);const n=t.items,r=Fo.memoizer;r==null||r.attach(e),e._zod.parse=(o,i)=>{const l=o.value;if(!Array.isArray(l))return o.issues.push({input:l,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=r?r.alloc(e,o,[],i):[];const u=[],c=ev(n,"optin"),h=ev(n,"optout");if(!t.rest){if(l.length<c)return o.issues.push({code:"too_small",minimum:c,inclusive:!0,input:l,inst:e,origin:"array"}),o;l.length>n.length&&o.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:l,inst:e,origin:"array"})}const p=new Array(n.length);for(let g=0;g<n.length;g++){const m=n[g]._zod.run({value:l[g],issues:[]},i);m instanceof Promise?u.push(m.then(y=>{p[g]=y})):p[g]=m}if(t.rest){let g=n.length-1;const m=l.slice(n.length);for(const y of m){g++;const w=t.rest._zod.run({value:y,issues:[]},i);w instanceof Promise?u.push(w.then(b=>tv(b,o,g))):tv(w,o,g)}}return u.length?Promise.all(u).then(()=>nv(p,o,n,l,h)):nv(p,o,n,l,h)}});function ev(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 tv(e,t,n){e.issues.length&&t.issues.push(...Wd(n,e.issues)),t.value[n]=e.value}function nv(e,t,n,r,o){for(let i=0;i<n.length;i++){const l=e[i],u=i<r.length;if(!u&&i>=o&&n[i]._zod.optin==="optional"){t.value.length=i;break}if(l.issues.length){if(!u&&i>=o){t.value.length=i;break}t.issues.push(...Wd(i,l.issues))}t.value[i]=l.value}for(let i=t.value.length-1;i>=r.length&&(n[i]._zod.optout==="optional"&&t.value[i]===void 0);i--)t.value.length=i;return t}const cI=ve("$ZodEnum",(e,t)=>{Ln.init(e,t);const n=fx(t.entries),r=new Set(n);e._zod.values=r;const o=n.filter(i=>Vj.has(typeof i));e._zod.pattern=new RegExp(o.length?`^(${o.map(i=>Ma(i.toString())).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(i,l)=>{const u=i.value;return r.has(u)||i.issues.push({code:"invalid_value",values:n,input:u,inst:e}),i}}),uI=ve("$ZodLiteral",(e,t)=>{Ln.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"?Ma(r):r?Ma(r.toString()):String(r)).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),dI=ve("$ZodTransform",(e,t)=>{var n;Ln.init(e,t),e._zod.optin="optional",(n=Fo.memoizer)==null||n.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new kx(e.constructor.name);const i=t.transform(r.value,r);if(o.async)return(i instanceof Promise?i:Promise.resolve(i)).then(u=>(r.value=u,r));if(i instanceof Promise)throw new Ta;return r.value=i,r}});function rv(e,t){return e.value=t.issues.length?void 0:t.value,e}const Ox=ve("$ZodOptional",(e,t)=>{Ln.init(e,t),kn(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",kn(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),kn(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Vm(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(i=>rv(n,i)):rv(n,o)}return t.innerType._zod.run(n,r)}}),fI=ve("$ZodExactOptional",(e,t)=>{Ox.init(e,t),kn(e,"values",n=>n.def.innerType._zod.values),kn(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),hI=ve("$ZodNullable",(e,t)=>{Ln.init(e,t),kn(e,"optin",n=>n.def.innerType._zod.optin),kn(e,"optout",n=>n.def.innerType._zod.optout),kn(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Vm(r.source)}|null)$`):void 0}),kn(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)}),pI=ve("$ZodDefault",(e,t)=>{Ln.init(e,t),e._zod.optin="defaulted",kn(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(i=>ov(i,t)):ov(o,t)}});function ov(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const mI=ve("$ZodPrefault",(e,t)=>{Ln.init(e,t),e._zod.optin="defaulted",kn(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))}),gI=ve("$ZodNonOptional",(e,t)=>{Ln.init(e,t),kn(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(i=>sv(i,e)):sv(o,e)}});function sv(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 iv(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>Ka(o,r,ii()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const kI=ve("$ZodCatch",(e,t)=>{Ln.init(e,t),kn(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),kn(e,"optout",n=>n.def.innerType._zod.optout),kn(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(i=>iv(n,i,t,r)):iv(n,o,t,r)}}),yI=ve("$ZodPipe",(e,t)=>{Ln.init(e,t),kn(e,"values",n=>n.def.in._zod.values),kn(e,"optin",n=>n.def.in._zod.optin),kn(e,"optout",n=>n.def.out._zod.optout),kn(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(l=>Ou(l,t.in,r)):Ou(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>Ou(i,t.out,r)):Ou(o,t.out,r)}});function Ou(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 wI=ve("$ZodReadonly",(e,t)=>{Ln.init(e,t),kn(e,"propValues",n=>n.def.innerType._zod.propValues),kn(e,"values",n=>n.def.innerType._zod.values),kn(e,"optin",n=>{var r,o;return(o=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:o.optin}),kn(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(av):av(o)}});function av(e){return e.memo||(e.value=Object.freeze(e.value)),e}const vI=ve("$ZodCustom",(e,t)=>{Yr.init(e,t),Ln.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(i=>lv(i,n,r,e));lv(o,n,r,e)}});function lv(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(rc(o))}}class bI extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const Gp="~memo",cv=[];function ip(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const uv=new WeakMap;function Mx(e,t){const n=uv.get(e);if(n!==void 0)return n;if(t.has(e))return!0;t.add(e);let r=!1;const o=u=>{!r&&(u!=null&&u._zod)&&Mx(u,t)&&(r=!0)},i=e._zod.def;switch(i.type){case"object":{for(const u of Reflect.ownKeys(i.shape))o(i.shape[u]);o(i.catchall);break}case"array":o(i.element);break;case"tuple":for(const u of i.items)o(u);o(i.rest);break;case"record":case"map":o(i.keyType),o(i.valueType);break;case"set":o(i.valueType);break;case"union":for(const u of i.options)o(u);break;case"intersection":o(i.left),o(i.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(i.innerType);break;case"pipe":o(i.in),o(i.out);break;case"function":o(i.input),o(i.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 u in i){const c=Object.getOwnPropertyDescriptor(i,u);if(!c||c.get)continue;const h=c.value;if(!(!h||typeof h!="object")){if(h._zod)o(h);else if(Array.isArray(h))for(const p of h)o(p)}}}return t.delete(e),uv.set(e,r),r}function xI(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}let Mu;const Lu=[],EI={alloc(e,t,n){const r=Mu;if(!r)return n;Mu=void 0;const o={value:n,issues:null};return r.set(t.value,o),Lu.push(o),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const n=e._zod.parse,r=(o,i)=>{if(i.direction!=="backward"&&SI(i,o.value))throw new bI;return n(o,i)};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 i=e._zod.parse,l=(u,c)=>{if(n===void 0&&(n=Mx(e,new Set),!n))return e._zod.parse=i,e._zod.run===l&&(e._zod.run=i),i(u,c);const h=u.value;if(h===null||typeof h!="object")return i(u,c);let p=c[Gp];p||(p={buckets:new Map,backEdges:void 0},c[Gp]=p);let g;r===c?g=o:(g=xI(p,e),r=c,o=g);const m=g.get(h);if(m)return u.value=m.value,m.issues?m.issues.length&&u.issues.push(...ip(m.issues)):(u.memo=!0,p.backEdges??(p.backEdges=new Set),p.backEdges.add(m.value)),u;Mu=g;const y=Lu.length,w=i(u,c);Mu=void 0;const b=Lu.length>y?Lu.pop():void 0;return w instanceof Promise?w.then(E=>(b&&(b.issues=E.issues.length?ip(E.issues):cv),E)):(b&&(b.issues=w.issues.length?ip(w.issues):cv),w)};e._zod.parse=l,e._zod.run===i&&(e._zod.run=l)})}};function _I(){return EI}function SI(e,t){var r;const n=(r=e[Gp])==null?void 0:r.backEdges;return n!==void 0&&t!==null&&typeof t=="object"&&n.has(t)}const NI=()=>{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(i){return e[i]??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(i,l){return i==="number"&&typeof l=="number"&&!Number.isFinite(l)?String(l):r[i]??i}return i=>{switch(i.code){case"invalid_type":{const l=o(i.expected),u=iC(i.input),c=o(u,i.input);return`Invalid input: expected ${l}, received ${c}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${mx(i.values[0])}`:`Invalid option: expected one of ${Hw(i.values,"|")}`;case"too_big":{const l=i.exact?"exactly ":i.inclusive?"<=":"<",u=t(i.origin);return u?`Too big: expected ${i.origin??"value"} to have ${l}${i.maximum.toString()} ${u.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${l}${i.maximum.toString()}`}case"too_small":{const l=i.exact?"exactly ":i.inclusive?">=":">",u=t(i.origin);return u?`Too small: expected ${i.origin} to have ${l}${i.minimum.toString()} ${u.unit}`:`Too small: expected ${i.origin} to be ${l}${i.minimum.toString()}`}case"invalid_format":{const l=i;return l.format==="starts_with"?`Invalid string: must start with "${l.prefix}"`:l.format==="ends_with"?`Invalid string: must end with "${l.suffix}"`:l.format==="includes"?`Invalid string: must include "${l.includes}"`:l.format==="regex"?`Invalid string: must match pattern ${l.pattern}`:`Invalid ${n[l.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${Hw(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return i.options&&Array.isArray(i.options)&&i.options.length>0?`Invalid discriminator value. Expected ${i.options.map(u=>`'${u}'`).join(" | ")}`:i.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function TI(){return{localeError:NI()}}var dv;class jI{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 CI(){return new jI}(dv=globalThis).__zod_globalRegistry??(dv.__zod_globalRegistry=CI());const Pl=globalThis.__zod_globalRegistry;function AI(e,t){return new e({type:"string",...it(t)})}function II(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...it(t)})}function RI(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...it(t)})}function $I(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...it(t)})}function OI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...it(t)})}function MI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...it(t)})}function LI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...it(t)})}function PI(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...it(t)})}function DI(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...it(t)})}function zI(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...it(t)})}function FI(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...it(t)})}function BI(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...it(t)})}function UI(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...it(t)})}function HI(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...it(t)})}function WI(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...it(t)})}function KI(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...it(t)})}function ZI(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...it(t)})}function qI(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...it(t)})}function GI(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...it(t)})}function VI(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...it(t)})}function YI(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...it(t)})}function QI(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...it(t)})}function XI(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...it(t)})}function JI(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...it(t)})}function eR(e,t){return new e({type:"string",format:"date",check:"string_format",...it(t)})}function tR(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...it(t)})}function nR(e,t){return new e({type:"string",format:"duration",check:"string_format",...it(t)})}function rR(e,t){return new e({type:"number",checks:[],...it(t)})}function oR(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...it(t)})}function sR(e,t){return new e({type:"boolean",...it(t)})}function iR(e){return new e({type:"unknown"})}function aR(e,t){return new e({type:"never",...it(t)})}function fv(e,t){return new Ex({check:"less_than",...it(t),value:e,inclusive:!1})}function ap(e,t){return new Ex({check:"less_than",...it(t),value:e,inclusive:!0})}function hv(e,t){return new _x({check:"greater_than",...it(t),value:e,inclusive:!1})}function lp(e,t){return new _x({check:"greater_than",...it(t),value:e,inclusive:!0})}function pv(e,t){return new iA({check:"multiple_of",...it(t),value:e})}function Lx(e,t){return new lA({check:"max_length",...it(t),maximum:e})}function fd(e,t){return new cA({check:"min_length",...it(t),minimum:e})}function Px(e,t){return new uA({check:"length_equals",...it(t),length:e})}function lR(e,t){return new dA({check:"string_format",format:"regex",...it(t),pattern:e})}function cR(e){return new fA({check:"string_format",format:"lowercase",...it(e)})}function uR(e){return new hA({check:"string_format",format:"uppercase",...it(e)})}function dR(e,t){return new pA({check:"string_format",format:"includes",...it(t),includes:e})}function fR(e,t){return new mA({check:"string_format",format:"starts_with",...it(t),prefix:e})}function hR(e,t){return new gA({check:"string_format",format:"ends_with",...it(t),suffix:e})}function Za(e){return new kA({check:"overwrite",tx:e})}function pR(e){return Za(t=>t.normalize(e))}function mR(){return Za(e=>e.trim())}function gR(){return Za(e=>e.toLowerCase())}function kR(){return Za(e=>e.toUpperCase())}function yR(){return Za(e=>qj(e))}function wR(e,t,n){return new e({type:"array",element:t,...it(n)})}function vR(e,t,n){return new e({type:"custom",check:"custom",fn:t,...it(n)})}function bR(e,t){const n=xR(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(rc(o,r.value,n._zod.def));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(rc(i))}},e(r.value,r)),t);return n}function xR(e,t){const n=new Yr({check:"custom",...it(t)});return n._zod.check=e,n}function Kl(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&Vr(e,r,n[r]);return e}function Dx(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)??Pl,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 ti(e,t,n,r,o){const i=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:o}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw new Error(o);return Object.assign(n,i),!0}function lr(e,t,n={path:[],schemaPath:[]}){var p,g;var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const l={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,l),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const u=(g=(p=e._zod).toJSONSchema)==null?void 0:g.call(p);if(u)l.schema=u;else{const m={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,l.schema,m);else{const w=l.schema,b=t.processors[o.type];if(!b)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);b(e,t,w,m)}const y=e._zod.parent;y&&(l.ref||(l.ref=y),lr(y,t,m),t.seen.get(y).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Kl(l.schema,c),t.io==="input"&&Or(e)&&(delete l.schema.examples,delete l.schema.default),t.io==="input"&&"_prefault"in l.schema&&((r=l.schema).default??(r.default=l.schema._prefault)),delete l.schema._prefault,t.seen.get(e).schema}function mv(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function zx(e,t){var l,u,c,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 p of e.seen.entries()){const g=(l=e.metadataRegistry.get(p[0]))==null?void 0:l.id;if(g){const m=r.get(g);if(m&&m!==p[0])throw new Error(`Duplicate schema id "${g}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(g,p[0])}}const o=p=>{var b;const g=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const E=(b=e.external.registry.get(p[0]))==null?void 0:b.id,N=e.external.uri??(T=>T);if(E)return{ref:N(E)};const j=p[1].defId??p[1].schema.id??`schema${e.counter++}`;return p[1].defId=j,{defId:j,ref:`${N("__shared")}#/${g}/${mv(j)}`}}const m="#",y=`${m}/${g}/`;if(p[1]===n&&!p[1].schema.id)return{ref:m};const w=p[1].schema.id??`__schema${e.counter++}`;return{defId:w,ref:y+mv(w)}},i=p=>{if(p[1].schema.$ref)return;const g=p[1],{ref:m,defId:y}=o(p);g.def={...g.schema},y&&(g.defId=y);const w=g.schema;for(const b in w)delete w[b];w.$ref=m};if(e.cycles==="throw")for(const p of e.seen.entries()){const g=p[1];if(g.cycle)throw new Error(`Cycle detected: #/${(u=g.cycle)==null?void 0:u.join("/")}/<root>
|
|
92
|
+
|
|
93
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const p of e.seen.entries()){const g=p[1];if(t===p[0]){i(p);continue}if(e.external){const y=(c=e.external.registry.get(p[0]))==null?void 0:c.id;if(t!==p[0]&&y){i(p);continue}}if((h=e.metadataRegistry.get(p[0]))==null?void 0:h.id){i(p);continue}if(g.cycle){i(p);continue}if(g.count>1&&e.reused==="ref"){i(p);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Fx(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;Fx(r);const o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;const i=r.type;for(const l of Array.isArray(i)?i:[i]){if(typeof l!="string")return;n.includes(l)||n.push(l)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const Bx=new Set(["type","properties","required","additionalProperties"]),gv=["oneOf","anyOf"];function kv(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Vp(e){var i;const t=[];for(const l of e){if(typeof l!="object"||l.type!=="object")return null;for(const u in l)if(!Bx.has(u))return null;t.push(l)}const n={},r=new Set;for(const l of t){for(const u in l.properties){if(Object.prototype.hasOwnProperty.call(n,u))continue;const c=[];for(const p of t){const g=((i=p.properties)==null?void 0:i[u])??kv(p);g!=null&&(c.some(m=>JSON.stringify(m)===JSON.stringify(g))||c.push(g))}const h=c.length===1?c[0]:Vp(c)??{allOf:c};Vr(n,u,h)}for(const u of l.required??[])r.add(u)}const o={type:"object",properties:n};if(r.size&&(o.required=[...r]),t.every(l=>l.additionalProperties===!1))o.additionalProperties=!1;else{const l=[];for(const u of t){const c=kv(u);c&&!l.some(h=>JSON.stringify(h)===JSON.stringify(c))&&l.push(c)}l.length===1?o.additionalProperties=l[0]:l.length>1&&(o.additionalProperties={allOf:l})}return o}function ER(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const o of Bx)if(o in e)return;const n=t.filter(o=>gv.some(i=>Array.isArray(o[i])));let r=null;if(!n.length)r=Vp(t);else{const o=n[0],i=gv.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;const l=t.filter(c=>c!==o),u=o[i].map(c=>Vp([...l,c]));if(u.some(c=>!c))return;r={[i]:u}}r&&(delete e.allOf,Kl(e,r))}function Ux(e,t){var u,c,h,p;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=g=>{const m=e.seen.get(g);if(m.ref===null)return;const y=m.def??m.schema,w={...y},b=m.ref;if(m.ref=null,b){r(b);const N=e.seen.get(b),j=N.schema;if(j.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(y.allOf=y.allOf??[],y.allOf.push(j)):Kl(y,j),Kl(y,w),g._zod.parent===b)for(const O in y)O==="$ref"||O==="allOf"||O in w||delete y[O];if(j.$ref&&N.def)for(const O in y)O==="$ref"||O==="allOf"||O in N.def&&JSON.stringify(y[O])===JSON.stringify(N.def[O])&&delete y[O]}const E=g._zod.parent;if(E&&E!==b){r(E);const N=e.seen.get(E);if(N!=null&&N.schema.$ref&&(y.$ref=N.schema.$ref,N.def))for(const j in y)j==="$ref"||j==="allOf"||j in N.def&&JSON.stringify(y[j])===JSON.stringify(N.def[j])&&delete y[j]}e.override({zodSchema:g,jsonSchema:y,path:m.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const g of[...e.seen.entries()].reverse())r(g[0]);if(e.target!=="openapi-3.0")for(const g of e.seen.entries())Fx(g[1].def??g[1].schema);for(const g of e.deferred)g();if(e.intersections.length){const g=new Map;for(const m of e.seen.values())for(const y of[m.schema,m.def]){const w=y==null?void 0:y.allOf;if(!Array.isArray(w))continue;const b=g.get(w);b?b.push(y):g.set(w,[y])}for(const m of e.intersections)for(const y of g.get(m)??[])ER(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,(u=e.external)!=null&&u.uri){const g=(c=e.external.registry.get(t))==null?void 0:c.id;if(!g)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(g)}Kl(o,n.defId?n.schema:n.def??n.schema);const i=(h=e.metadataRegistry.get(t))==null?void 0:h.id;i!==void 0&&o.id===i&&delete o.id;const l=((p=e.external)==null?void 0:p.defs)??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const g of e.seen.entries()){const m=g[1];m.def&&m.defId&&(m.def.id===m.defId&&delete m.def.id,Vr(l,m.defId,m.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(l).length>0&&(e.target==="draft-2020-12"?o.$defs=l:o.definitions=l);try{const g=JSON.parse(JSON.stringify(o));return Object.defineProperty(g,"~standard",{value:{...t["~standard"],jsonSchema:{input:hd(t,"input",e.processors),output:hd(t,"output",e.processors)}},enumerable:!1,writable:!1}),g}catch{throw new Error("Error converting schema to JSON.")}}function Or(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 Or(r.element,n);if(r.type==="set")return Or(r.valueType,n);if(r.type==="lazy")return Or(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 Or(r.innerType,n);if(r.type==="intersection")return Or(r.left,n)||Or(r.right,n);if(r.type==="record"||r.type==="map")return Or(r.keyType,n)||Or(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Or(r.in,n)||Or(r.out,n);if(r.type==="object"){for(const o in r.shape)if(Or(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(Or(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(Or(o,n))return!0;return!!(r.rest&&Or(r.rest,n))}return!1}const _R=(e,t={})=>n=>{const r=Dx({...n,processors:t});return lr(e,r),zx(r,e),Ux(r,e)},hd=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},l=Dx({...o??{},target:i,io:t,processors:n});return lr(e,l),zx(l,e),Ux(l,e)},SR={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},NR=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:l,format:u,patterns:c,contentEncoding:h,laxFormat:p}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof l=="number"&&(o.maxLength=l),u&&(o.format=SR[u]??u,o.format===""&&delete o.format,(u==="time"||p)&&delete o.format),h&&(o.contentEncoding=h),c&&c.size>0){const g=[...c];g.length===1?o.pattern=g[0].source:g.length>1&&(o.allOf=[...g.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},TR=(e,t,n,r)=>{const o=n,{minimum:i,maximum:l,format:u,multipleOf:c,exclusiveMaximum:h,exclusiveMinimum:p}=e._zod.bag;typeof u=="string"&&u.includes("int")?o.type="integer":o.type="number";const g=typeof p=="number"&&p>=(i??Number.NEGATIVE_INFINITY),m=typeof h=="number"&&h<=(l??Number.POSITIVE_INFINITY),y=t.target==="draft-04"||t.target==="openapi-3.0";g?y?(o.minimum=p,o.exclusiveMinimum=!0):o.exclusiveMinimum=p:typeof i=="number"&&(o.minimum=i),m?y?(o.maximum=h,o.exclusiveMaximum=!0):o.exclusiveMaximum=h:typeof l=="number"&&(o.maximum=l),typeof c=="number"&&(Number.isFinite(c)&&c!==0?o.multipleOf=Math.abs(c):ti(e,t,o,r,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},jR=(e,t,n,r)=>{n.type="boolean"},CR=(e,t,n,r)=>{n.not={}},AR=(e,t,n,r)=>{},IR=(e,t,n,r)=>{const o=e._zod.def,i=fx(o.entries);if(i.length===0){n.not={};return}i.every(l=>typeof l=="number")&&(n.type="number"),i.every(l=>typeof l=="string")&&(n.type="string"),n.enum=i},RR=(e,t,n,r)=>{const o=e._zod.def;if(o.values.length===0){n.not={};return}const i=[];for(const l of o.values)if(l===void 0){if(ti(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof l=="bigint"){if(ti(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(l))}else i.push(l);if(i.length!==0)if(i.length===1){const l=i[0];n.type=l===null?"null":typeof l,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[l]:n.const=l}else i.every(l=>typeof l=="number")&&(n.type="number"),i.every(l=>typeof l=="string")&&(n.type="string"),i.every(l=>typeof l=="boolean")&&(n.type="boolean"),i.every(l=>l===null)&&(n.type="null"),n.enum=i},$R=(e,t,n,r)=>{ti(e,t,n,r,"Custom types cannot be represented in JSON Schema")},OR=(e,t,n,r)=>{ti(e,t,n,r,"Transforms cannot be represented in JSON Schema")},MR=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:l,maximum:u}=e._zod.bag;typeof l=="number"&&(o.minItems=l),typeof u=="number"&&(o.maxItems=u),o.type="array",o.items=lr(i.element,t,{...r,path:[...r.path,"items"]})};function pd(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?pd(t.out):t.type==="catch"?pd(t.innerType):e._zod.optin}const LR=(e,t,n,r)=>{var p;const o=n,i=e._zod.def,l=i.shape;if(Object.getOwnPropertySymbols(l).length&&ti(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const g in l)Vr(o.properties,g,lr(l[g],t,{...r,path:[...r.path,"properties",g]}));const c=new Set(Object.keys(l)),h=new Set([...c].filter(g=>{const m=i.shape[g];return t.io==="input"?pd(m)===void 0:m._zod.optout===void 0}));h.size>0&&(o.required=Array.from(h)),((p=i.catchall)==null?void 0:p._zod.def.type)==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=lr(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},PR=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,l=o.options.map((u,c)=>lr(u,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=l:n.anyOf=l},DR=(e,t,n,r)=>{const o=e._zod.def,i=lr(o.left,t,{...r,path:[...r.path,"allOf",0]}),l=lr(o.right,t,{...r,path:[...r.path,"allOf",1]}),u=h=>"allOf"in h&&Object.keys(h).length===1,c=[...u(i)?i.allOf:[i],...u(l)?l.allOf:[l]];n.allOf=c,t.intersections.push(c)},zR=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="array";const l=t.target==="draft-2020-12"?"prefixItems":"items",u=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((b,E)=>lr(b,t,{...r,path:[...r.path,l,E]})),h=i.rest?lr(i.rest,t,{...r,path:[...r.path,u,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;let p=i.items.length;for(;p>0;){const b=i.items[p-1];if(!(t.io==="input"?pd(b)!==void 0:b._zod.optout==="optional"))break;p--}const g=i.items.length,m=!i.rest;t.target==="draft-2020-12"?(o.prefixItems=c,m?o.items=!1:h&&(o.items=h),p>0&&(o.minItems=p),m&&(o.maxItems=g)):t.target==="openapi-3.0"?(o.items={anyOf:c},h&&o.items.anyOf.push(h),p>0&&(o.minItems=p),m&&(o.maxItems=g)):(o.items=c,m?o.additionalItems=!1:h&&(o.additionalItems=h),p>0&&(o.minItems=p),m&&(o.maxItems=g));const{minimum:y,maximum:w}=e._zod.bag;typeof y=="number"&&(o.minItems=y),typeof w=="number"&&(o.maxItems=w)},FR=(e,t,n,r)=>{const o=e._zod.def,i=lr(o.innerType,t,r),l=t.seen.get(e);t.target==="openapi-3.0"?(l.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},BR=(e,t,n,r)=>{const o=e._zod.def;lr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},ng=Symbol();function Hx(e,t,n,r,o){let i=!1;const l=JSON.stringify(e,(u,c)=>typeof c!="bigint"?c:(i=!0,null));return i?(ti(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),ng):JSON.parse(l)}const UR=(e,t,n,r)=>{const o=e._zod.def;lr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;const l=Hx(o.defaultValue,e,t,n,r);l!==ng&&(n.default=l)},HR=(e,t,n,r)=>{const o=e._zod.def;lr(o.innerType,t,r);const i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;const l=Hx(o.defaultValue,e,t,n,r);l!==ng&&(n._prefault=l)},WR=(e,t,n,r)=>{const o=e._zod.def;lr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let l;try{l=o.catchValue(void 0)}catch{ti(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=l},KR=(e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),l=t.io==="input"?i?o.out:o.in:o.out;lr(l,t,r);const u=t.seen.get(e);u.ref=l},ZR=(e,t,n,r)=>{const o=e._zod.def;lr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},Wx=(e,t,n,r)=>{const o=e._zod.def;lr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},yv=new WeakSet([Object.prototype,Error.prototype]);function Pu(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 qR=(e,t)=>{wx.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);yv.has(n)||(yv.add(n),Pu(n,"format",r=>o=>vC(r,o)),Pu(n,"flatten",r=>o=>wC(r,o)),Pu(n,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,Wp,2)}),Pu(n,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,Wp,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Eo=ve("ZodError",qR,void 0,{Parent:Error}),GR=Xm(Eo),VR=Jm(Eo),YR=Zd(Eo),QR=qd(Eo),XR=EC(Eo),JR=_C(Eo),e$=SC(Eo),t$=NC(Eo),n$=TC(Eo),r$=jC(Eo),o$=CC(Eo),s$=AC(Eo);function i$(){Fo.localeError||ii(TI())}function Vd(){Fo.memoizer||ii({memoizer:_I()})}const Hn=ve("ZodType",(e,t)=>(i$(),Ln.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(oi(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 si(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(oO(e,t))},superRefine(e,t){return this.check(sO(e,t))},overwrite(e){return this.check(Za(e))},optional(){return bv(this)},exactOptional(){return Z$(this)},nullable(){return xv(this)},nullish(){return bv(xv(this))},nonoptional(e){return X$(this,e)},array(){return Li(this)},or(e){return P$([this,e])},and(e){return B$(this,e)},transform(e){return Ev(this,K$(e))},default(e){return V$(this,e)},prefault(e){return Q$(this,e)},catch(e){return eO(this,e)},pipe(e){return Ev(this,e)},readonly(){return rO(this)},describe(e){const t=this.clone();return Pl.add(t,{description:e}),t},meta(...e){if(e.length===0)return Pl.get(this);const t=this.clone();return Pl.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 gx(this,"~standard",{...Sx(this),jsonSchema:{input:hd(this,"input"),output:hd(this,"output")}})},set"~standard"(e){La(this,"~standard",e)},parse:function e(t,n){return GR(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await VR(this,t,n,{callee:e})},safeParse(e,t){return YR(this,e,t)},async safeParseAsync(e,t){return QR(this,e,t)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(e){La(this,"spa",e)},encode:function e(t,n){return XR(this,t,n,{callee:e})},decode:function e(t,n){return JR(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await e$(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await t$(this,t,n,{callee:e})},safeEncode(e,t){return n$(this,e,t)},safeDecode(e,t){return r$(this,e,t)},async safeEncodeAsync(e,t){return o$(this,e,t)},async safeDecodeAsync(e,t){return s$(this,e,t)},toJSONSchema(e){return _R(this,{})(e)},get description(){var e;return(e=Pl.get(this))==null?void 0:e.description},get _def(){return this._zod.def}}),Kx=ve("_ZodString",(e,t)=>{tg.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>NR(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(lR(...e))},includes(...e){return this.check(dR(...e))},startsWith(...e){return this.check(fR(...e))},endsWith(...e){return this.check(hR(...e))},min(...e){return this.check(fd(...e))},max(...e){return this.check(Lx(...e))},length(...e){return this.check(Px(...e))},nonempty(...e){return this.check(fd(1,...e))},lowercase(e){return this.check(cR(e))},uppercase(e){return this.check(uR(e))},trim(){return this.check(mR())},normalize(...e){return this.check(pR(...e))},toLowerCase(){return this.check(gR())},toUpperCase(){return this.check(kR())},slugify(){return this.check(yR())}}),a$=ve("ZodString",(e,t)=>{tg.init(e,t),Kx.init(e,t)},{email(e){return this.check(II(f$,e))},url(e){return this.check(PI(p$,e))},jwt(e){return this.check(XI(C$,e))},emoji(e){return this.check(DI(m$,e))},guid(e){return this.check(RI(h$,e))},uuid(e){return this.check($I(Du,e))},uuidv4(e){return this.check(OI(Du,e))},uuidv6(e){return this.check(MI(Du,e))},uuidv7(e){return this.check(LI(Du,e))},nanoid(e){return this.check(zI(g$,e))},cuid(e){return this.check(FI(k$,e))},cuid2(e){return this.check(BI(y$,e))},ulid(e){return this.check(UI(w$,e))},base64(e){return this.check(VI(N$,e))},base64url(e){return this.check(YI(T$,e))},xid(e){return this.check(HI(v$,e))},ksuid(e){return this.check(WI(b$,e))},ipv4(e){return this.check(KI(x$,e))},ipv6(e){return this.check(ZI(E$,e))},cidrv4(e){return this.check(qI(_$,e))},cidrv6(e){return this.check(GI(S$,e))},e164(e){return this.check(QI(j$,e))},datetime(e){return this.check(JI(l$,e))},date(e){return this.check(eR(c$,e))},time(e){return this.check(tR(u$,e))},duration(e){return this.check(nR(d$,e))}});function bn(e){return AI(a$,e)}const Wn=ve("ZodStringFormat",(e,t)=>{Pn.init(e,t),Kx.init(e,t)}),l$=ve("ZodISODateTime",(e,t)=>{LA.init(e,t),Wn.init(e,t)}),c$=ve("ZodISODate",(e,t)=>{PA.init(e,t),Wn.init(e,t)}),u$=ve("ZodISOTime",(e,t)=>{DA.init(e,t),Wn.init(e,t)}),d$=ve("ZodISODuration",(e,t)=>{zA.init(e,t),Wn.init(e,t)}),f$=ve("ZodEmail",(e,t)=>{xA.init(e,t),Wn.init(e,t)}),h$=ve("ZodGUID",(e,t)=>{vA.init(e,t),Wn.init(e,t)}),Du=ve("ZodUUID",(e,t)=>{bA.init(e,t),Wn.init(e,t)}),p$=ve("ZodURL",(e,t)=>{jA.init(e,t),Wn.init(e,t)}),m$=ve("ZodEmoji",(e,t)=>{CA.init(e,t),Wn.init(e,t)}),g$=ve("ZodNanoID",(e,t)=>{AA.init(e,t),Wn.init(e,t)}),k$=ve("ZodCUID",(e,t)=>{IA.init(e,t),Wn.init(e,t)}),y$=ve("ZodCUID2",(e,t)=>{RA.init(e,t),Wn.init(e,t)}),w$=ve("ZodULID",(e,t)=>{$A.init(e,t),Wn.init(e,t)}),v$=ve("ZodXID",(e,t)=>{OA.init(e,t),Wn.init(e,t)}),b$=ve("ZodKSUID",(e,t)=>{MA.init(e,t),Wn.init(e,t)}),x$=ve("ZodIPv4",(e,t)=>{FA.init(e,t),Wn.init(e,t)}),E$=ve("ZodIPv6",(e,t)=>{UA.init(e,t),Wn.init(e,t)}),_$=ve("ZodCIDRv4",(e,t)=>{HA.init(e,t),Wn.init(e,t)}),S$=ve("ZodCIDRv6",(e,t)=>{KA.init(e,t),Wn.init(e,t)}),N$=ve("ZodBase64",(e,t)=>{ZA.init(e,t),Wn.init(e,t)}),T$=ve("ZodBase64URL",(e,t)=>{GA.init(e,t),Wn.init(e,t)}),j$=ve("ZodE164",(e,t)=>{VA.init(e,t),Wn.init(e,t)}),C$=ve("ZodJWT",(e,t)=>{QA.init(e,t),Wn.init(e,t)}),Zx=ve("ZodNumber",(e,t)=>{Ax.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>TR(e,r,o,i);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(hv(e,t))},gte(e,t){return this.check(lp(e,t))},min(e,t){return this.check(lp(e,t))},lt(e,t){return this.check(fv(e,t))},lte(e,t){return this.check(ap(e,t))},max(e,t){return this.check(ap(e,t))},int(e){return this.check(wv(e))},safe(e){return this.check(wv(e))},positive(e){return this.check(hv(0,e))},nonnegative(e){return this.check(lp(0,e))},negative(e){return this.check(fv(0,e))},nonpositive(e){return this.check(ap(0,e))},multipleOf(e,t){return this.check(pv(e,t))},step(e,t){return this.check(pv(e,t))},finite(){return this}});function Mi(e){return rR(Zx,e)}const A$=ve("ZodNumberFormat",(e,t)=>{XA.init(e,t),Zx.init(e,t)});function wv(e){return oR(A$,e)}const I$=ve("ZodBoolean",(e,t)=>{JA.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>jR(e,n,r)});function Oo(e){return sR(I$,e)}const R$=ve("ZodUnknown",(e,t)=>{eI.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>AR()});function vv(){return iR(R$)}const $$=ve("ZodNever",(e,t)=>{tI.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>CR(e,n,r)});function O$(e){return aR($$,e)}const M$=ve("ZodArray",(e,t)=>{Vd(),nI.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>MR(e,n,r,o),e.element=t.element},{min(e,t){return this.check(fd(e,t))},nonempty(e){return this.check(fd(1,e))},max(e,t){return this.check(Lx(e,t))},length(e,t){return this.check(Px(e,t))},unwrap(){return this.element}});function Li(e,t){return wR(M$,e,t)}const L$=ve("ZodObject",(e,t)=>{Vd(),sI.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>LR(e,n,r,o),dC(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return md(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:vv()})},loose(){return this.clone({...this._zod.def,catchall:vv()})},strict(){return this.clone({...this._zod.def,catchall:O$()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return eC(this,e)},safeExtend(e){return tC(this,e)},merge(e){return nC(this,e)},pick(e){return Xj(this,e)},omit(e){return Jj(this,e)},partial(...e){return Ww(rg,this,e[0])},exactPartial(...e){return Ww(Vx,this,e[0],"exactPartial")},required(...e){return rC(Yx,this,e[0])}});function Tr(e,t){const n={type:"object",shape:e??{},...it(t)};return new L$(n)}const qx=ve("ZodUnion",(e,t)=>{$x.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>PR(e,n,r,o),e.options=t.options});function P$(e,t){return new qx({type:"union",options:e,...it(t)})}const D$=ve("ZodDiscriminatedUnion",(e,t)=>{qx.init(e,t),iI.init(e,t)});function z$(e,t,n){return new D$({type:"union",options:t,discriminator:e,...it(n)})}const F$=ve("ZodIntersection",(e,t)=>{aI.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>DR(e,n,r,o)});function B$(e,t){return new F$({type:"intersection",left:e,right:t})}const U$=ve("ZodTuple",(e,t)=>{Vd(),lI.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>zR(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 rg({type:"optional",innerType:n}))})}});function Gx(e,t,n){const r=t instanceof Ln,o=r?n:t,i=r?t:null;return new U$({type:"tuple",items:e,rest:i,...it(o)})}const Yp=ve("ZodEnum",(e,t)=>{cI.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>IR(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 i={};for(const l of r)if(n.has(l))i[l]=t.entries[l];else throw new Error(`Key ${l} not found in enum`);return new Yp({...t,checks:[],...it(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const l of r)if(n.has(l))delete i[l];else throw new Error(`Key ${l} not found in enum`);return new Yp({...t,checks:[],...it(o),entries:i})}});function md(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Yp({type:"enum",entries:n,...it(t)})}const H$=ve("ZodLiteral",(e,t)=>{uI.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>RR(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 oo(e,t){return new H$({type:"literal",values:Array.isArray(e)?e:[e],...it(t)})}const W$=ve("ZodTransform",(e,t)=>{Vd(),dI.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>OR(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new kx(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(rc(i,n.value,t));else{const l=i;l.fatal&&(l.continue=!1),l.code??(l.code="custom"),"input"in l||(l.input=n.value),l.inst??(l.inst=e),n.issues.push(rc(l))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function K$(e){return new W$({type:"transform",transform:e})}const rg=ve("ZodOptional",(e,t)=>{Ox.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Wx(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function bv(e){return new rg({type:"optional",innerType:e})}const Vx=ve("ZodExactOptional",(e,t)=>{fI.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Wx(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Z$(e){return new Vx({type:"optional",innerType:e})}const q$=ve("ZodNullable",(e,t)=>{hI.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>FR(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function xv(e){return new q$({type:"nullable",innerType:e})}const G$=ve("ZodDefault",(e,t)=>{pI.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>UR(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function V$(e,t){return new G$({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():px(t)}})}const Y$=ve("ZodPrefault",(e,t)=>{mI.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>HR(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Q$(e,t){return new Y$({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():px(t)}})}const Yx=ve("ZodNonOptional",(e,t)=>{gI.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>BR(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function X$(e,t){return new Yx({type:"nonoptional",innerType:e,...it(t)})}const J$=ve("ZodCatch",(e,t)=>{kI.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>WR(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function eO(e,t){return new J$({type:"catch",innerType:e,catchValue:typeof t=="function"?t:hC(t)})}const tO=ve("ZodPipe",(e,t)=>{yI.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>KR(e,n,r,o),e.in=t.in,e.out=t.out});function Ev(e,t){return new tO({type:"pipe",in:e,out:t})}const nO=ve("ZodReadonly",(e,t)=>{wI.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ZR(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function rO(e){return new nO({type:"readonly",innerType:e})}const Qx=ve("ZodCustom",(e,t)=>{vI.init(e,t),Hn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$R(e,n,r,o)});function oO(e,t={}){return vR(Qx,e,t)}function sO(e,t){return bR(e,t)}function iO(e,t={}){const n=new Qx({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...it(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 aO=["off","tailscale","any"],lO={updates:!0,deploy:!0,remote:"any",agents:null,customAgents:!0,brandedListener:!0,planSignIn:!0};Tr({updates:Oo().optional(),deploy:Oo().optional(),remote:md(aO).optional(),agents:Li(bn()).optional(),customAgents:Oo().optional(),brandedListener:Oo().optional(),planSignIn:Oo().optional()});const cO={...lO,source:null,problem:null};function uO(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 cp=6e3,_v=1500;function dO(e){if(e.length<=cp)return e;const t=e.length-cp;return`${e.slice(0,_v)}
|
|
94
|
+
[${t} characters cut here]
|
|
95
|
+
${e.slice(e.length-(cp-_v))}`}const zu=93,gd=5e6,fO=["image/png","image/jpeg","image/gif","image/webp"],Sv=2576,up=5*1024*1024,hO=1200,pO=10,mO=1e5,Nv=100*1024*1024,gO="pasted-text.txt";function kO(e){return e.t==="term-data"||e.t==="term-snapshot"||e.t==="term-exit"}function yO(e){return e.t==="file-read"||e.t==="file-written"||e.t==="file-blame"}const wO=80;function og(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,wO)}}function Xx(e){return e.length>=hO||e.split(`
|
|
97
|
+
`).length>=pO}function vO({startLine:e,endLine:t}){return e===t?`${e}`:`${e}-${t}`}function bO(e){return`${e.path.slice(e.path.lastIndexOf("/")+1)} (${vO(e)})`}const xO=/\u001B(?:\[[0-?]*[ -/]*[@-~]|\][^\u0007]*(?:\u0007|\u001B\\))/g;function EO(e){return e.replace(xO,"")}const Jx="Projects";function _O(e){for(const t of e){const n=t.codePointAt(0)??0;if(n<32||n===127)return!0}return!1}function oc(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":_O(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 SO=/^(?:https?|ssh|git|file):\/\/\S+$/i,e1=/^[\w.-]+@[\w.-]+:\S+$/;function NO(e){const t=e.trim();if(!SO.test(t)&&!e1.test(t))return null;const n=TO(t);return n&&!oc(n)?{url:t,name:n}:null}function TO(e){var o;const t=((o=e.split(/[?#]/)[0])==null?void 0:o.replace(/\/+$/,""))??"";return((e1.test(t)?t.split(":")[1]??"":t).split("/").pop()??"").replace(/\.git$/i,"")}const jO=Tr({component:bn().nullable(),file:bn().nullable(),line:Mi().nullable(),callFile:bn().nullable().default(null),callLine:Mi().nullable().default(null),tag:bn(),selector:bn()}),CO=Tr({tag:bn().max(40),id:bn().max(200),classes:Li(bn().max(120)).max(16),text:bn().max(200),attrs:Li(Gx([bn().max(40),bn().max(200)])).max(12)}),AO=Gx([Mi(),Mi()]),IO=jO.extend({classes:bn(),text:bn(),html:bn(),route:bn(),element:CO}),RO=z$("type",[Tr({type:oo("loaded"),url:bn(),title:bn()}),Tr({type:oo("navigated"),url:bn(),title:bn().optional()}),Tr({type:oo("title"),title:bn()}),Tr({type:oo("links"),links:Li(Tr({path:bn().max(2048),text:bn().max(120)})).max(200)}),Tr({type:oo("hmr")}),Tr({type:oo("page-error"),message:bn(),source:bn().optional(),line:Mi().optional()}),IO.extend({type:oo("picked"),verb:md(["chat","code"]).default("chat"),site:md(["call","source"]).default("source")}),Tr({type:oo("pick-cancel")}),Tr({type:oo("highlight-miss"),path:bn(),fileMatched:Mi(),withSource:Mi(),ranges:Li(AO).nullable()}),Tr({type:oo("drag-files")}),Tr({type:oo("drop-files"),files:Li(iO(File))}),Tr({type:oo("focus"),gesture:Oo()}),Tr({type:oo("key"),key:bn(),code:bn().optional(),meta:Oo(),ctrl:Oo().optional(),shift:Oo().optional(),alt:Oo().optional(),up:Oo().optional()})]);function $O(e){const t=RO.safeParse(e);return t.success?t.data:null}const OO=/["“”]([^"“”]*)["“”]?|(\S+)/g;function t1(e){const t=new Set;for(const n of e.matchAll(OO)){const r=(n[1]??n[2]??"").replace(/\s+/g," ").trim().toLowerCase();r&&t.add(r)}return[...t]}const MO="now",LO="http://preview.invalid",PO=200;function Tv(e){const t=e==null?void 0:e.replace(/\s+/g," ").trim().slice(0,PO).trim();return t||void 0}function Yd(e){let t;try{t=new URL(e,LO)}catch{return null}if(t.pathname.startsWith("/__toyon"))return null;const n=jv(t.pathname)||"/",r=t.hash.startsWith("#/")?jv(t.hash.split("?")[0]??""):"";return r.length>1?`${n}${r}`:n}const jv=e=>e.replace(/\/+$/,""),DO={static:4,mixed:3.5,param:3,optional:2,"optional-static":2,splat:1},kd=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function n1(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 i=[];let l="",u=0;for(const h of e.matchAll(/\[([^\]=]+)(?:=[^\]]*)?\]|\{\$([\w-]+)\}/g)){const p=e.slice(u,h.index);p&&(i.push({text:p}),l+=kd(p)),i.push({name:h[1]??h[2]??"param"}),l+="[^/]+?",u=(h.index??0)+h[0].length}const c=e.slice(u);if(c&&(i.push({text:c}),l+=kd(c)),i.some(h=>"name"in h))return{kind:"mixed",pattern:l,parts:i}}return{kind:"static",text:e}}function zO(e){const t=e.split("/").filter(Boolean).map(n1);if(t.every(r=>r.kind==="static"))return null;let n="";for(const r of t)r.kind==="static"?n+=`/${kd(r.text)}`:r.kind==="optional-static"?n+=`(?:/${kd(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+DO[o.kind],0),statics:t.filter(r=>r.kind==="static").length}}function FO(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 Qd(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(n1))if(t+="/",o.kind==="static"||o.kind==="optional-static")t+=o.text;else if(o.kind==="mixed")for(const i of o.parts)"name"in i?r(i.name):t+=i.text;else r(o.name);return t||(t="/"),{text:t,params:n,literal:n.length>0?t.slice(0,n[0][0]):t}}const kc={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"}},r1={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"}},BO={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"}},UO={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"}},HO={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"}},WO={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"}},KO={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"}},ZO={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"}},qO={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"}},GO={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"}},VO={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"}},YO={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"}},QO={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"}},XO={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"}},JO={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"}},e2={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"}},t2={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"}},n2={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"}},r2={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"}},o2=[qO,GO,VO,YO,QO,XO,JO,e2,t2,n2,r2],td=[kc,r1,BO,UO,HO,WO,KO,ZO,...o2],s2={mode:"dark",light:r1.id,dark:kc.id},i2=["surface0","surface1","surface2","element0","element1","border0","border1","text0","text1","text2","red","orange","yellow","green","aqua","blue","purple","diffAdd","diffDel"];function a2(e){return`--${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function Cv(e){const t=i1(e);return t>.008856?116*t**(1/3)-16:903.3*t}function o1(e,t){const n=Cv(e)+t,r=zi(e);if(!r)return e;let o=0,i=2;for(let l=0;l<24;l++){const u=(o+i)/2,c=Pa(Math.min(255,r[0]*u),Math.min(255,r[1]*u),Math.min(255,r[2]*u));Cv(c)<n?o=u:i=u}return Pa(Math.min(255,r[0]*o),Math.min(255,r[1]*o),Math.min(255,r[2]*o))}function l2(e){return o1(e.colors.surface1,-4)}function c2(e){return o1(e.colors.surface0,-4)}function Av(e){return y2(e,.55)}function u2(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 d2(e){const t={};for(const n of i2)t[a2(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(u2(e)))t[`--syntax-${n}`]=r;return t["--accent"]=sg(e),t["--fault"]=f2(e),t["--sunken"]=l2(e),t["--sunken-floor"]=c2(e),t["--scrim"]=k2(e.colors.surface0,.7),t["--shadow"]=e.kind==="dark"?"#00000066":"#0000002e",t["--diff-add-word"]=Av(e.colors.diffAdd),t["--diff-del-word"]=Av(e.colors.diffDel),t}function sg(e){return s1(e.accent??"")??e.colors.orange}function f2(e){return sg(e)===s1(e.colors.orange)?e.colors.red:e.colors.orange}function h2(e){return e==="system"||e==="daylight"}function ig(e,t){return e.mode==="system"?t.system?"dark":"light":e.mode==="daylight"?t.daylight?"dark":"light":e.mode}function Xd(e,t,n){const r=ig(e,n);return t.find(o=>o.id===e[r])??td.find(o=>o.kind===r)??kc}function p2(e,t){if(e.pair){const l=t.find(u=>u.id===e.pair);if(l&&l.kind!==e.kind)return l}const n=e.kind==="dark"?"light":"dark",r=l=>l.toLowerCase().replace(/\b(dark|light)\b/g,"*").replace(/\s+/g," ").trim(),o=r(e.name);if(!o.includes("*"))return null;const i=e.id.startsWith("vscode:")?e.id.slice(0,e.id.lastIndexOf(":")+1):null;return t.find(l=>l.kind===n&&l.source===e.source&&(!i||l.id.startsWith(i))&&r(l.name)===o)??null}function m2(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 i=p2(o,e),l={name:r(o)};l[o.kind]=o,n.add(o.id),i&&(l[i.kind]=i,n.add(i.id)),t.push(l)}return t}function g2(e,t){const n={...e};return t.dark&&(n.dark=t.dark.id),t.light&&(n.light=t.light.id),!h2(n.mode)&&!t[n.mode]&&(n.mode=t.dark?"dark":"light"),n}function zi(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 s1(e){const t=zi(e);return t?Pa(t[0],t[1],t[2],t[3]):null}function Pa(e,t,n,r=1){const o=i=>Math.round(Math.max(0,Math.min(255,i))).toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}${r>=1?"":o(r*255)}`}function k2(e,t){const n=zi(e);return n?Pa(n[0],n[1],n[2],t):e}function y2(e,t){const n=zi(e);return n?Pa(n[0],n[1],n[2],Math.min(1,n[3]*t)):e}function h7(e,t){const n=zi(e),r=zi(t);if(!n||!r)return e;const o=n[3];return Pa(n[0]*o+r[0]*(1-o),n[1]*o+r[1]*(1-o),n[2]*o+r[2]*(1-o))}function i1(e){const t=zi(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 w2(e){return i1(e)>.179?"#1d2021":"#fbf1c7"}function Qp(e){if(e===null||e==="")return"the npm registry";try{return new URL(e).host}catch{return e}}function v2(e,t){const n=Iv(e),r=Iv(t);if(!n||!r)return!1;for(let o=0;o<3;o++){const i=n.nums[o]??0,l=r.nums[o]??0;if(i!==l)return i>l}return n.pre===r.pre?!1:n.pre===null?!0:r.pre===null?!1:n.pre>r.pre}function Iv(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 b2=[[/\.(png|jpe?g|gif|webp|avif|bmp|ico)$/i,"image"]];function x2(e){var t;return((t=b2.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const E2=[[/\.(md|markdown)$/i,"markdown"],[/\.html?$/i,"html"]];function Jd(e){var t;return((t=E2.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const Ze={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",designHeight:"toyon-dsh",designFull:"toyon-dsfull",termHeight:"toyon-th",rail:"toyon-rail",railWidth:"toyon-rail-w",chatSide:"toyon-chat-side",clipboardOffer:"toyon-clipboard-offer",layouts:"toyon-layouts",client:"toyon-client",machines:"toyon-machines",profilePrefix:"toyon-profile-",modePrefix:"toyon-mode-",modelPrefix:"toyon-model-",effortPrefix:"toyon-effort-"},_2=[Ze.active,Ze.repo,Ze.lastActive,Ze.discoveredOpen,Ze.archivedOpen,Ze.committedShut,Ze.turnOpen,Ze.treeOpen,Ze.profilePrefix,Ze.modePrefix,Ze.modelPrefix,Ze.effortPrefix,Ze.phoneRow],S2=[Ze.profilePrefix,Ze.modePrefix,Ze.modelPrefix,Ze.effortPrefix],nd=(e,t)=>`${e}@${t}`;function N2(e,t=typeof localStorage>"u"?null:localStorage,n=typeof sessionStorage>"u"?null:sessionStorage){const r=l=>({get(u){try{return(l==null?void 0:l.getItem(nd(u,e)))??null}catch{return null}},set(u,c){try{l==null||l.setItem(nd(u,e),c)}catch{}},remove(u){try{l==null||l.removeItem(nd(u,e))}catch{}}}),o=r(t),i=r(n);return{...o,session:{get:i.get,set:i.set},clear(){for(const l of[t,n])for(const u of a1(l).filter(c=>c.endsWith(`@${e}`)))try{l==null||l.removeItem(u)}catch{}}}}function a1(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 T2="orch-";function j2(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 i of o){const l=Ze[i],u=T2+l.slice(6);Rv(r,u,l)}for(const[r,o]of[[t,_2.filter(i=>i!==Ze.phoneRow)],[n,[Ze.phoneRow]]]){const i=a1(r).filter(l=>!l.includes("@"));for(const l of o){const u=S2.includes(l)?i.filter(c=>c.startsWith(l)):i.filter(c=>c===l);for(const c of u)Rv(r,c,nd(c,e))}}}function Rv(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 l1(){const e=location.hash.match(/token=([a-f0-9]+)/);if(e!=null&&e[1]){try{localStorage.setItem(Ze.token,e[1])}catch{}return e[1]}try{return localStorage.getItem(Ze.token)??sessionStorage.getItem(Ze.token)??""}catch{return""}}function c1(){return l1()!==""}function u1(e,t){const n=new URL(e),r=`token=${t}`,o=i=>`&v=${encodeURIComponent(i??"")}`;return{origin:n.origin,host:n.hostname,token:t,ws:`${n.protocol==="https:"?"wss":"ws"}://${n.host}/ws?${r}`,attachment:(i,l)=>`${n.origin}/attachments/${i}/${l}?${r}`,upload:i=>`${n.origin}/uploads/${i}?${r}`,worktreeFile:(i,l,u)=>`${n.origin}/files/${i}/${l.split("/").map(encodeURIComponent).join("/")}?${r}${o(u)}`,loose:(i,l)=>`${n.origin}/loose/${encodeURIComponent(i)}?${r}${o(l)}`,health:`${n.origin}/health`,restart:i=>`${n.origin}/restart?${r}${i?`&${MO}`:""}`,uploads:i=>`${n.origin}/uploads?kind=${i}`,pair:`${n.origin}/pair`,pairPhones:`${n.origin}/pair/phones`,pairRedeem:`${n.origin}/pair/redeem`,previewGrant:`${n.origin}/preview-grant`}}const ef=e=>({authorization:`Bearer ${e.token}`});async function C2(e,t,n){try{await n.slice(0,1).arrayBuffer()}catch{return"could not be read"}try{const r=await fetch(e.uploads(t),{method:"POST",headers:{...ef(e),"content-type":n.type||"application/octet-stream"},body:n});return r.status>=502&&r.status<=504?null:r.ok?await r.json():await r.text()||"could not be attached"}catch{return null}}async function A2(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 d1(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 I2(e){try{const t=await fetch(e.pairPhones,{headers:ef(e)});return t.ok?await t.json():null}catch{return null}}async function R2(e){try{const t=await fetch(e.pair,{method:"POST",headers:ef(e)});return t.ok?await t.json():await t.text()||"Toyon did not make a code"}catch{return"Toyon is not answering; try again once it is back."}}async function f1(e){try{const t=await fetch(e.previewGrant,{method:"POST",headers:ef(e)});return t.ok?await t.json():null}catch{return null}}async function $2(e,t){try{const n=await fetch(`${e}/pair/redeem`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})});if(n.status===401)return"expired";if(!n.ok)return"not-toyon";const r=await n.json();return typeof r.token=="string"&&r.token?{token:r.token}:"not-toyon"}catch{return"unreachable"}}async function O2(e){try{return await fetch(`${e}/health`,{mode:"no-cors",signal:AbortSignal.timeout(4e3)}),!0}catch{return!1}}async function Xp(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 M2=1e3,L2=3e4,P2=1500,$v=50,D2=e=>e.t==="chat"||e.t==="create-worktree"||e.t==="restore-worktree"||e.t==="batch-worktrees";class z2{constructor(t,n,r){jt(this,"ws",null);jt(this,"queue",[]);jt(this,"closed",!1);jt(this,"attempt",0);jt(this,"timer",null);jt(this,"downAt",null);jt(this,"downCode",0);jt(this,"sayTimer",null);jt(this,"sentDown",new Set);jt(this,"urls");jt(this,"suspended",!1);jt(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.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.urls=u1(t.origin,t.token),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===Ij)return"unauthorized";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+P2-Date.now()))}connect(){if(this.closed||this.suspended)return;const t=new WebSocket(this.urls.ws);this.ws=t;let n=!1;t.onmessage=r=>{if(!n){n=!0,this.attempt=0,this.downAt=null,this.sayTimer&&clearTimeout(this.sayTimer),this.sayTimer=null,this.onStatus(!0);for(const o of this.queue)t.send(o.raw);this.queue=[]}try{this.onMsg(JSON.parse(r.data))}catch{}},t.onclose=r=>{if(this.ws!==t||(this.onStatus(!1),this.closed||this.suspended))return;this.say(r.code);const o=Math.min(L2,M2*2**this.attempt++);this.timer=setTimeout(()=>this.connect(),o/2+Math.random()*(o/2))},t.onerror=()=>t.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)),D2(t)&&t.boxId&&this.sentDown.add(t.boxId),this.queue.push({key:r,raw:n}),this.queue.length>$v&&this.queue.splice(0,this.queue.length-$v)}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 h1(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 p1(e,t,n){const r=h=>e.map((p,g)=>h(p)&&p.id!==t?g:-1).filter(p=>p>=0),i=[()=>r(h=>h.agent==="waiting"),()=>r(h=>!!h.unseen),()=>r(h=>h.agent==="working")].reduce((h,p)=>h.length>0?h:p(),[]),l=e.findIndex(h=>h.id===t),u=n>0?i.find(h=>h>l)??i[0]:i.findLast(h=>h<l)??i[i.length-1],c=u===void 0?void 0:e[u];return c?{activate:c.id}:null}function ag(e,t,n){const r=p1(e,t,n);if(r)return r;const o=e[0];return o&&o.id!==t?{activate:o.id}:null}function m1(e){return e==="cancelled"||e==="expired"}function F2(e){const t=e.findLast(n=>n.kind==="ask"||n.kind==="user");return(t==null?void 0:t.kind)!=="ask"||t.ask.kind!=="question"?null:m1(t.outcome)?t:null}function B2(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 U2(e){return e.map(()=>({selected:[]}))}function Ov(e,t,n,r){return e.map((o,i)=>{if(i!==t)return o;const l=o.selected.includes(n);return r?{...o,selected:l?o.selected.filter(u=>u!==n):[...o.selected,n]}:{...o,selected:[n]}})}function yd(e,t,n){return e.map((r,o)=>{if(o!==t)return r;const{note:i,...l}=r;return n===void 0?l:{...l,note:n}})}function Mv(e,t,n,r){return e.map((o,i)=>i!==t?o:{selected:n&&!r?[]:o.selected,note:o.note??""})}function Jp(e,t){const n=e[t];return n&&n.note!==void 0&&!n.note.trim()?yd(e,t,void 0):e}function H2(e){return e?e.options.length+(e.note?1:0):0}function W2(e,t){return!!(e!=null&&e.note)&&t===e.options.length}function g1(e,t){return!!e&&e.note!==void 0&&(t||e.selected.length===0)}function ja(e){var t;return!!e&&(e.selected.length>0||!!((t=e.note)!=null&&t.trim()))}function Fu(e,t){return e.every((n,r)=>!n.required||ja(t[r]))}function K2(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(i=>{var l;return lg(((l=e.options.find(u=>u.value===i))==null?void 0:l.label)??i)}),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 Z2(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(i=>{var l;return lg(((l=e.options.find(u=>u.value===i))==null?void 0:l.label)??i)}),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 k1(e,t){return e.map((n,r)=>{const o=K2(n,t==null?void 0:t[r]);return e.length>1&&n.header?`${n.header} · ${o}`:o})}function q2(e){return e.outcome!=="answered"||e.ask.kind!=="question"?null:{message:e.ask.message,questions:e.ask.questions,answers:e.answers}}function Ea(e,t){if(!e)return 0;if(g1(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 G2(e,t,n){return Math.max(0,Math.min(n-1,e+t))}function V2(e,t,n){const r=e.length;for(let o=1;o<=r;o++){const i=(n+o)%r;if(!ja(t[i]))return i}return-1}function Zl(e){return e.length>1?e.length:-1}function Y2(e){return e.length+(Zl(e)===-1?0:1)}function Lv(e,t,n){const r=V2(e,t,n);if(r!==-1)return{current:r,cursor:Ea(e[r],t[r]),send:!1};const o=Zl(e);return o!==-1?{current:o,cursor:0,send:!1}:{current:n,cursor:Ea(e[n],t[n]),send:!0}}const y1=/\s*\(recommended\)\s*$/i;function Q2(e){return y1.test(e)}function lg(e){return e.replace(y1,"")}const X2={skipped:"you skipped this",cancelled:"the turn was stopped before you answered",expired:"Toyon restarted before you answered"};function w1(e,t,n,r){return n!==null&&r===n.host?`${Aj(n.previews,e,t)}/`:r.endsWith(".localhost")?`http://w${e}.${r}:${t}/`:Gm(r)?`http://${r==="localhost"?"127.0.0.1":r}:${t}/`:`https://${r}:${t}/`}function Pv(e){return e.ranges.map(([t,n])=>[t+e.offset,n+e.offset])}function Dv(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 Bu(e,t){return!Number.isFinite(e)||e<=0?t:Math.min(Math.max(e,170),Math.floor(window.innerWidth*.5))}function yc(e){return e.agent==="working"||e.agent==="waiting"}function ni(e){var t,n,r;return e.agent==="waiting"?"waiting":e.agent==="working"?"working":e.agent==="error"||((n=(t=e.worktree)==null?void 0:t.lastTurn)==null?void 0:n.end)==="failed"?"failed":(r=e.worktree)!=null&&r.landed?"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 J2={waiting:"Waiting for you",working:"Agent working",failed:"Agent failed",landed:"Landed",crashed:"Crashed",running:"Running",starting:"Starting",asleep:"Asleep",idle:"Idle"};function cg(e,t=!1){const n=ni(e);return n==="idle"&&t?"Not set up":J2[n]}const eM={starting:"Starting",running:"Running",unreachable:"Not answering",crashed:"Crashed",stopped:"Stopped",asleep:"Asleep"};function tM(e){return eM[e]}function v1(e,t){return t&&ni(e)!=="waiting"?t:null}const nM={land:"Landing",commit:"Committing","sync-main":"Syncing with main","pull-main":"Pulling"};function ug(e){return nM[e]}function b1(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 rM(e){const t=e.lastIndexOf("/");return t<0?{name:e,dir:""}:{name:e.slice(t+1),dir:e.slice(0,t)}}const x1=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}).compare;function wd(e){const t=[];for(let n=e.indexOf("/");n!==-1;n=e.indexOf("/",n+1))t.push(e.slice(0,n));return t}function E1(e){const t=new Set;for(const n of e)for(const r of wd(n))t.add(r);return[...t].sort(x1)}function dg(e){return e.includes("A")||e==="??"?"added":e.includes("D")?"deleted":""}function fg(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 oM=/Firefox\//.test(navigator.userAgent);function tf(){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 sM=/Chrome\//.test(navigator.userAgent)&&tf(),Tt=e=>kj(e,{firefox:oM,pwa:sM});function hg(e){return e.component?`<${e.component} />`:`<${e.tag}>`}function em(e,t){return e.worktree&&Ar(e.worktree)&&t?t.defaultBranch:e.name}function pg(e){const t=Math.max(0,e/1e3),n=(l,u)=>`${l} ${u}${l===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 i=o/24;return i<7?n(Math.floor(i),"day"):i<365?n(Math.floor(i/7),"week"):n(Math.floor(i/365),"year")}function ao(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 Ca(e){const t=Math.max(0,Math.floor(e));return t<100?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function iM(e,t,n,r){var l;if(!t)return null;const o=e.filter(On).filter(u=>u.repoId===t&&(u.worktree.agent??r)===n);return((l=o.find(u=>Ar(u.worktree))??o[0])==null?void 0:l.id)??null}const aM=200;function lM(e,t){const n=new Map(e.map(r=>[r.path,r]));for(const r of t){if(n.size>=aM)break;const o=Yd(r.path);o&&!n.has(o)&&n.set(o,{path:o,text:r.text})}return n.size===e.length?e:[...n.values()]}function _1(e){return e!==void 0&&!e.routes.some(t=>!t.endpoint)}const vd=e=>"uploading"in e&&e.uploading===!0;function ql(e){switch(e.kind){case"image":case"file":{const{key:t,local:n,uploading:r,...o}=e;return o}case"paste":{const{key:t,chars:n,lines:r,preview:o,...i}=e;return i}case"pick":{const{key:t,...n}=e;return n}}}const cM=e=>e.filter(t=>!vd(t)).map(ql);let uM=0;function tm(e,t){const n=new Map(t.filter(o=>!vd(o)).map(o=>[JSON.stringify(ql(o)),o]));return[...e.map(o=>{const i=JSON.stringify(o),l=n.get(i);if(l)return n.delete(i),l;const u=`d${++uM}`;return o.kind==="paste"?{...o,key:u,...og(o.text)}:{...o,key:u}}),...t.filter(vd)]}const rd=["files","changes","history"],dM=e=>rd.includes(e),S1=e=>!!(e!=null&&e.carry)&&!e.batch&&e.variants===1,wc=e=>(e==null?void 0:e.worktree.id)??null,qa=Object.freeze({chat:[],log:[],queue:[],page:{errors:[]},turn:{edits:!1,hmr:!1},changedRanges:{},commitFiles:{},search:null,design:null,draft:"",attachments:[],commands:[],termStream:ko}),mg=e=>({...e,phase:"editing",repoId:null,prompt:""}),zv=()=>mg({mode:"create",name:"",parent:`~/${Jx}`}),fM=Object.freeze({changes:!1,changesTab:"files",chat:!0,term:!1,design:!1});function hM(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.changes=="boolean"&&dM(t.changesTab)&&typeof t.chat=="boolean"&&typeof t.term=="boolean"&&typeof t.design=="boolean"}function Zr(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 gg(e,t){return{...e,layout:t,changesAuto:!1}}const Fi=e=>Jd(e)?"preview":"file",pM=(e,t)=>e===t||!!e&&!!t&&e.at===t.at&&(e.at!=="tree"||t.at!=="tree"||e.worktreeId===t.worktreeId&&e.dir===t.dir),Al=(e,t)=>e.worktreeId===t.worktreeId&&e.path===t.path&&e.ref===t.ref&&e.since===t.since;function N1(e,t,n,r){var i;if(!r.fiber)return r;const o=(i=bo(e,t).changedRanges[n])==null?void 0:i.offset;return o===void 0?r:{n:r.n-o}}function mM(e){const t=e.cached??kc,n={connected:!1,connectFailure:null,repos:[],rows:[],activeRepoId:null,visible:[],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,clientId:e.clientId,storedActive:e.storedActive??null,storedRepo:e.storedRepo??null,heard:!1,local:{},editor:null,openUrl:null,reloadReq:null,dragFiles:null,picking:!1,overlay:null,paletteReturn:null,incompatible:!1,layout:fM,focusChanges:0,editCommit:0,focusChat:0,walked:0,railOpen:e.storedRailOpen??!1,chatSide:e.storedChatSide??"left",focusRail:0,railPeek:!1,unreadHold:null,layouts:e.storedLayouts??{},screen:e.storedActive&&e.storedPhoneRow?"chat":"home",frame:e.frame??"desk",touch:e.touch??!1,reading:!1,changesAuto:!0,zen:!1,focusTerm:0,termRun:null,termTall:0,themes:td.some(o=>o.id===t.id)?td:[...td,t],themePrefs:{...s2,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:cO,paired:!1,pairings:0,gitIdentity:!0,self:null,rebuilt:!1,update:null,updateCheck:null,version:"",install:"none",registry:null,choosingFolder:!1,newProject:null,autoSend:null,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?gg(n,r):n}function T1(e){var t;return{system:e.systemDark,daylight:((t=e.daylight)==null?void 0:t.dark)??e.systemDark}}function gM(e){return e.previewTheme??Xd(e.themePrefs,e.themes,T1(e))}function bo(e,t){return t&&e.local[t]||qa}function es(e,t){return t&&e.rows.find(n=>n.id===t)||null}function rn(e,t){const n=es(e,t);return n&&On(n)?n:null}function j1(e){var o;const t=rn(e,e.activeId);if(!t||!Di(t.worktree)||t.agent!=="idle"||!((o=Da(e,t.repoId))!=null&&o.empty))return!1;const n=ai(e,t.repoId),r=e.rows.some(i=>{var l;return i.repoId===t.repoId&&((l=i.worktree)==null?void 0:l.kind)==="worktree"});return!!(n!=null&&n.needsSetup)&&!r&&bo(e,t.id).chat.length===0}function nf(e){return e.newProject!==null||j1(e)}function kM(e){return e.incompatible||nf(e)}function yM(e){return(!e.needsSetup||!!e.assumed)&&Object.keys(e.config.run).length===0}function bd(e){return!!(e!=null&&e.needsSetup)&&!e.assumed}function kg(e){const t=e.archivedPage?null:es(e,e.activeId);return(t==null?void 0:t.repoId)??e.activeRepoId}function wo(e){const t=ai(e,kg(e));return!!t&&yM(t)}function C1(e){return e.layout.chat&&!wo(e)&&!e.archivedPage&&!R1(e)?{a:"toggle-chat"}:{a:"focus-chat"}}function Qo(e){return wo(e)?e:Zr(e,{chat:!0})}function ai(e,t){return t&&e.repos.find(n=>n.id===t)||null}function A1(e,t){if(!t)return null;const n=e.rows.filter(On).filter(r=>r.repoId===t);return n.find(r=>gc(r.worktree))??n.find(r=>Di(r.worktree))??null}function Da(e,t){return t&&e.trunks[t]||null}function Dl(e){return wo(e)||e.archivedPage?null:e.activeId}function yg(e){return e.procs.some(t=>t.status==="running"||t.status==="starting")}function xd(e){if(e.archivedPage)return null;const t=rn(e,e.activeId);return t&&yg(t)?{worktreeId:t.worktree.id,repoId:t.repoId}:null}function wg(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(i=>i.id===r.origin.id);return o&&On(o)&&o.repoId===t?o:null}function rf(e,t,n){return e.repoId===t||wg(e,t,n)!==null}function I1(e,t){return t.length?e.filter(n=>!t.includes(n.id)):e}function wM(e,t,n){const r=I1(e,n).filter(On);return nj(t?r.filter(o=>rf(o,t,r)):r)}function vM(e,t){const n=e.filter(r=>!On(r));return t?n.filter(r=>r.repoId===t):n}function Aa(e,t,n=e.rows){var u;const r=n.filter(On),o=e.archiving.length?r.filter(c=>!e.archiving.includes(c.id)):r,i=t?e.lastActive[t]:void 0;if(i&&o.some(c=>c.id===i))return i;const l=t?o.filter(c=>c.repoId===t):o;return((u=l.find(c=>gc(c.worktree))??l.find(c=>Di(c.worktree))??l[0])==null?void 0:u.id)??null}function Fv(e,t){const n=Object.entries(e),r=n.filter(([o])=>!t(o));return r.length===n.length?e:Object.fromEntries(r)}function Bv(e,t,n){const r={};for(const l of t)l.shipping&&(r[l.id]=l.shipping);for(const l of Object.values(n))l.shipping&&(r[l.id]=l.shipping);for(const[l,u]of Object.entries(e))!u.sent||r[l]||(t.some(c=>c.id===l)||L1({trunks:n},l))&&(r[l]=u);const o=Object.keys(r);return o.length===Object.keys(e).length&&o.every(l=>bM(e[l],r[l]))?e:r}const bM=(e,t)=>!!e&&!!t&&e.op===t.op&&e.step===t.step&&e.sent===t.sent;function _a(e,t){var p;const n=es(e,t),o=!!n&&On(n)&&!!e.activeRepoId&&rf(n,e.activeRepoId,e.rows)?e.activeRepoId:(n==null?void 0:n.repoId)??e.activeRepoId,i=n&&On(n)?{...e.lastActive,[n.repoId]:n.id}:e.lastActive,l=e.activeId!==t?e.activeId:null,u=l?e.local[l]:void 0,c=u&&((p=u.mark)==null?void 0:p.by)==="reveal"?Gl(u,"reveal"):null,h=l&&c?{...e.local,[l]:c}:e.local;return{...e,activeId:t,activeRepoId:o,lastActive:i,editor:null,archivedPage:null,local:h}}function za(e){return xo(e)?"history":e.layout.changesTab}function xM(e,t){const n=za(e);if(xo(e))return n;const r=rd.length;return rd[(rd.indexOf(n)+t+r)%r]??"changes"}function R1(e){if(e.archivedPage)return null;const t=es(e,e.activeId);return t&&!On(t)?t:null}function xo(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 Gl(e,t){var o;if(((o=e.mark)==null?void 0:o.by)!==t)return e;const{mark:n,...r}=e;return r}const $1=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";function sc(e){if(!e.sending)return e;const{sending:t,...n}=e;return n}function EM(e,t){var n;return!t||((n=e.local[t])==null?void 0:n.restoring)===void 0?e:Ct(e,t,({restoring:r,...o})=>o)}function _M(e,t){const n=Object.keys(e.local).filter(o=>{var i;return((i=e.local[o])==null?void 0:i.sending)&&(!t||o===t)});if(n.length===0)return e;const r={...e.local};for(const o of n)r[o]=sc(r[o]);return{...e,local:r}}function SM(e,t,n,r){var l;let o=e;const i=n?(l=o[n])==null?void 0:l.sending:void 0;if(i&&n&&r&&r!==n){const u=o[r]??qa,c=u.chat.some(h=>h.kind==="user")?{}:i;o={...o,[n]:sc(o[n]),[r]:{...u,sending:c}}}for(const u of t){const c=o[u.id];c!=null&&c.sending&&!c.sending.message&&(u.agent==="working"||u.agent==="waiting")&&(o={...o,[u.id]:sc(c)})}return o}function Ct(e,t,n){return{...e,local:{...e.local,[t]:n(e.local[t]??qa)}}}function Uv(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 NM(e,t){const n=t.type==="agent-question"||t.type==="agent-permission"||t.type==="handoff-proposed",r=t.type==="agent-ask-end"||t.type==="handoff"||t.type==="handoff-declined"?t.id:null;if(!n&&!r)return e;const o=t.type==="agent-ask-end"&&m1(t.outcome),{card:i,cardParked:l,askRevived:u,...c}=e;return{...c,...i&&!n&&(i.id!==r||o)?{card:i}:{},...l&&!n&&l!==r?{cardParked:l}:{},...u&&!n?{askRevived:u}:{}}}function TM(e,t,n){return Ct(e,t,r=>({...r,chat:[...r.chat,n],chatAt:Date.now()}))}function O1(e,t,n){return TM(Qo(e),t,{kind:"error",text:n})}function nm(e,t){const n=wc(rn(e,e.activeId));return n?Ct(Qo(e),n,r=>({...r,notice:t})):e}function Hv(e,t,n){return rn(e,t)?O1(e,t,n):nm(e,n)}function jM(e,t){const n=e.paletteReturn;return!t||!n?{overlay:null,paletteReturn:null}:{overlay:{kind:n.mode},paletteReturn:n}}function CM(e){const t=e.activeRepoId;if(!t)return e;const n=e.layouts[t];return n?gg(e,n):e.frame==="desk"?{...e,layouts:{...e.layouts,[t]:e.layout}}:e}function AM(e){return e.a==="server"&&e.msg.t==="git-status"}function IM(e){return{variants:1,batch:!1,agent:e.defaultAgent}}function RM(e){const t=rn(e,e.activeId);return!!t&&Ar(t.worktree)&&!e.archivedPage&&!nf(e)?e.draft?e:{...e,draft:IM(e)}:e.draft?{...e,draft:null}:e}function M1(e){var r;const t=e.archivedPage,n=t!==null&&((r=e.editor)==null?void 0:r.worktreeId)===t&&rn(e,t)===null;return{...e,archivedPage:null,...n?{editor:null}:{}}}function $M(e){const t=e.activeRepoId;if(!t)return e;const n=rn(e,e.activeId);return!n||n.repoId===t||rf(n,t,I1(e.rows,e.archiving))?e:_a(e,Aa(e,t))}function Ia(e,t){let n=RM($M(OM(e,t)));return n.unreadHold!==null&&n.activeId!==n.unreadHold&&(n={...n,unreadHold:null}),n.archivedPage!==null&&(xo(n)===null||rn(n,n.archivedPage)!==null)&&(n=M1(n)),n.activeRepoId!==e.activeRepoId?n=CM(n):n.frame==="desk"&&n.activeRepoId&&!AM(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:{...n,visible:wM(n.rows,n.activeRepoId,n.archiving),visibleDiscovered:vM(n.rows,n.activeRepoId)}}function OM(e,t){var n,r,o,i,l,u;switch(t.a){case"connected":return{...e,connected:t.v,connectFailure:t.v?null:t.failure===void 0?e.connectFailure:t.failure};case"activate":return{..._a(e,t.id),screen:t.id?"chat":"home"};case"open-draft":{if(nf(e))return e;const c=((n=A1(e,e.activeRepoId))==null?void 0:n.id)??null;return c?Qo({..._a(e,c),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-variants":return e.draft?{...e,draft:{...e.draft,variants:t.n}}:e;case"draft-batch":return e.draft?{...e,draft:{...e.draft,batch: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!e.activeRepoId||!((r=e.archived[e.activeRepoId])!=null&&r.some(c=>c.id===t.id))?e:{...e,archivedPage:t.id,editor:null,screen:"chat"};case"close-archived":return e.archivedPage?M1(e):e;case"restoring":return Ct(e,t.id,c=>({...c,restoring:t.text}));case"sending":return Ct(e,t.id,c=>({...c,sending:{message:t.message}}));case"sent-box":return Ct(e,t.id,({notice:c,...h})=>({...Gl(h,"walk"),draft:"",attachments:[],sent:(h.sent??0)+1}));case"answered":return Ct(e,t.id,c=>({...c,sent:(c.sent??0)+1}));case"archive-worktrees":{const c=t.ids.filter(T=>!e.archiving.includes(T)&&rn(e,T));if(c.length===0)return e;const h={...e,archiving:[...e.archiving,...c]};if(!e.activeId||!c.includes(e.activeId))return h;const p=e.visible.filter(T=>T.id===e.activeId||!h.archiving.includes(T.id)),g=p.findIndex(T=>T.id===e.activeId),m=T=>T.id!==e.activeId&&Km(T.worktree)&&!!T.worktree.landed&&T.agent==="idle",y=T=>{var O;return(O=p.find((U,Q)=>Q>g&&T(U))??p.find(T))==null?void 0:O.id},w=y(T=>T.id!==e.activeId&&T.agent==="waiting"),b=y(m),E=(o=p1(p,e.activeId,1))==null?void 0:o.activate,N=(i=p.map((T,O)=>({id:T.id,i:O,far:Math.abs(O-g),up:!Ar(T.worktree)&&ni(T)==="running"})).filter(T=>T.up&&T.far>0).sort((T,O)=>T.far-O.far||O.i-T.i)[0])==null?void 0:i.id,j=_a(h,w??b??E??N??Aa(h,e.activeRepoId));return e.frame==="phone"?{...j,screen:"home"}:j}case"shipping":return e.shipping[t.id]||!(es(e,t.id)||L1(e,t.id))?e:{...e,shipping:{...e.shipping,[t.id]:{op:t.op,sent:!0}}};case"activate-repo":{if(!ai(e,t.id))return e;const c=e.newProject?{...e,newProject:null}:e;if(t.id===e.activeRepoId)return c;const h=Aa(c,t.id);return{..._a(c,h),activeRepoId:t.id,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};case"new-project-set":{if(!e.newProject)return e;const c="name"in t.v||"parent"in t.v||"url"in t.v||"mode"in t.v,{error:h,...p}=e.newProject;return{...e,newProject:{...c?p: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 c=t.v,h=e.editor,p=h&&Al(h,c)?h:null,g=c.line&&N1(e,c.worktreeId,c.path,c.line);return{...e,editor:{worktreeId:c.worktreeId,path:c.path,...c.ref?{ref:c.ref}:{},...c.since?{since:c.since}:{},view:c.view??(p==null?void 0:p.view)??null,seq:c.seq,disk:(p==null?void 0:p.disk)??null,...g?{line:g}:{},focus:c.focus,conflict:(p==null?void 0:p.conflict)??null,blame:(p==null?void 0:p.blame)??null}}}case"open-loose":{const c=t.v,h={before:c.text,after:c.text,version:null,writable:c.source.kind!=="bytes"&&!c.tooLarge&&!c.binary,binary:c.binary,tooLarge:c.tooLarge};return{...e,editor:{worktreeId:c.worktreeId,path:c.name,view:Fi(c.name),seq:c.seq,disk:h,focus:!0,conflict:null,blame:null,loose:{source:c.source}}}}case"editor-read":{const c=e.editor;if(!c||c.loose||!Al(c,t.file))return e;const h=t.disk;if(!h){const m=O1(e,c.worktreeId,t.error??`could not read ${c.path}`);return c.disk?m:{...m,editor:null}}const p=Fi(c.path),g=h.before===""?c.view&&c.view!=="diff"?c.view:p:c.view??(h.before===h.after?p:"diff");return{...e,editor:{...c,view:g,disk:h}}}case"editor-conflict":{const c=e.editor;return c&&!c.loose&&Al(c,t.file)?{...e,editor:{...c,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 c=e.editor;if(!c||!Al(c,t.file))return e;const h=c.loose&&c.disk?{...c.disk,writable:!1}:c.disk;return{...e,editor:{...c,refused:t.message,disk:h}}}case"editor-blame":{const c=e.editor;return c&&!c.loose&&Al(c,t.file)?{...e,editor:{...c,blame:t.blame}}:e}case"notice":return Ct(Qo(e),t.id,c=>({...c,notice:t.text}));case"link-refused":return Ct(e,t.id,({refusedLink:c,...h})=>t.v?{...h,refusedLink:t.v}:h);case"card-draft":return Ct(e,t.id,c=>({...c,card:t.card}));case"card-park":return Ct(e,t.id,c=>({...c,cardParked:t.cardId}));case"card-unpark":return Ct(e,t.id,({cardParked:c,...h})=>h);case"ask-revive":return Ct(e,t.id,({askRevived:c,...h})=>t.askId?{...h,askRevived:t.askId}:h);case"opened-url":return e.openUrl?{...e,openUrl:null}:e;case"set-draft":return Ct(e,t.id,c=>{const{notice:h,...p}=Gl(c,"walk");return{...p,draft:t.text,...h!==void 0&&t.text===""?{notice:h}:{}}});case"walk":return Ct(e,t.id,c=>({...Gl(c,"walk"),draft:t.text,...t.walk?{mark:{by:"walk",at:t.walk.at,from:t.walk.from}}:{}}));case"reveal":return Ct(Qo(e),t.id,c=>{var h;return{...c,mark:{by:"reveal",seq:t.seq,n:((h=c.mark)==null?void 0:h.by)==="reveal"?c.mark.n+1:1}}});case"attach":return Ct(Qo(e),t.id,({notice:c,...h})=>({...h,attachments:[...h.attachments,...t.items]}));case"attached":return(l=e.local[t.id])!=null&&l.attachments.some(c=>c.key===t.key)?Ct(e,t.id,c=>({...c,attachments:c.attachments.map(h=>h.key===t.key?t.item:h)})):e;case"detach":return Ct(e,t.id,({notice:c,...h})=>({...h,attachments:h.attachments.filter(p=>p.key!==t.key)}));case"clear-attachments":return Ct(e,t.id,({notice:c,...h})=>h.attachments.length?{...h,attachments:[]}:h);case"hmr":return Ct(e,t.id,c=>({...c,turn:{...c.turn,hmr:!0}}));case"page":return Ct(e,t.id,c=>({...c,page:{url:t.url??c.page.url,title:t.title??c.page.title,errors:t.fresh?[]:t.error?[...c.page.errors.slice(-2),t.error]:c.page.errors}}));case"links":return Ct(e,t.id,c=>{const h=lM(c.links??[],t.links);return h===c.links?c:{...c,links:h}});case"drag-files":return pM(e.dragFiles,t.v)?e:{...e,dragFiles:t.v};case"set-picking":return{...e,picking:t.v};case"open":return{...e,overlay:t.overlay,previewTheme:null,paletteReturn:$1(t.overlay)?e.paletteReturn:null};case"choosing-folder":return{...e,choosingFolder:t.v};case"close":return{...e,previewTheme:null,...jM(e,t.back)};case"toggle":return((u=e.overlay)==null?void 0:u.kind)===t.overlay.kind?Ia(e,{a:"close"}):Ia(e,{a:"open",overlay:t.overlay});case"palette-return":return{...e,paletteReturn:t.v};case"toggle-changes":return{...Zr(e,{changes:!e.layout.changes}),changesAuto:!1};case"focus-changes":return{...Zr(e,{changes:!0,changesTab:t.tab&&!xo(e)?t.tab:e.layout.changesTab}),changesAuto:!1,focusChanges:e.focusChanges+1};case"changes-tab":return Zr(e,{changesTab:t.v});case"edit-commit":return{...Zr(e,{changes:!0}),changesAuto:!1,editCommit:e.editCommit+1};case"toggle-chat":return wo(e)?e:Zr(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"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"?Zr(e,{changesTab:"changes"}):e,screen:t.to,editor:null};case"frame":{if(e.frame===t.v)return e;const c={...e,frame:t.v};if(t.v!=="desk"||!c.activeRepoId)return c;const h=c.layouts[c.activeRepoId];return h?gg(c,h):c}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"rail-peek":return e.railPeek===t.on?e:{...e,railPeek:t.on};case"toggle-discovered":{const c=e.activeRepoId;return c?{...e,discoveredOpen:{...e.discoveredOpen,[c]:!e.discoveredOpen[c]}}:e}case"toggle-archived":{const c=e.activeRepoId;return c?{...e,archivedOpen:{...e.archivedOpen,[c]:!e.archivedOpen[c]}}:e}case"toggle-committed":{const c=e.activeRepoId;return c?{...e,committedShut:{...e.committedShut,[c]:!e.committedShut[c]}}:e}case"toggle-turn":{const c=e.activeRepoId;return c?{...e,turnOpen:{...e.turnOpen,[c]:!e.turnOpen[c]}}:e}case"tree-folder":{const c=e.treeOpen[t.worktreeId]??[];if(c.includes(t.path)===t.open)return e;const h=t.open?[...c,t.path]:c.filter(g=>g!==t.path),p={...e.treeOpen};return h.length>0?p[t.worktreeId]=h:delete p[t.worktreeId],{...e,treeOpen:p}}case"tree-reveal":{const c=e.treeOpen[t.worktreeId]??[],h=[];for(let m=t.path.indexOf("/");m!==-1;m=t.path.indexOf("/",m+1))h.push(t.path.slice(0,m));h.push(t.path);const p=h.filter(m=>!c.includes(m)),g=p.length?{...e.treeOpen,[t.worktreeId]:[...c,...p]}:e.treeOpen;return{...Zr(e,{changes:!0,changesTab:"files"}),changesAuto:!1,focusChanges:e.focusChanges+1,treeOpen:g,treeReveal:{worktreeId:t.worktreeId,path:t.path}}}case"files-asked":return Ct(e,t.worktreeId,c=>({...c,filesFor:t.key}));case"toggle-zen":return wo(e)?e:{...e,zen:!e.zen};case"toggle-terminal":return Zr(e,{term:!e.layout.term});case"focus-terminal":return{...Zr(e,{term:!0}),focusTerm:e.focusTerm+1};case"toggle-design":return wo(e)?e:Zr(e,{design:!e.layout.design});case"term-stream":return Ct({...Zr(e,{term:!0}),termTall:t.tall?e.termTall+1:e.termTall},t.id,c=>({...c,termStream:t.stream}));case"term-run":return Ct({...Zr(e,{term:!0}),focusTerm:e.focusTerm+1,termRun:{id:t.id,command:t.command}},t.id,c=>({...c,termStream:ko}));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 zM(e,t.msg)}}function Wv(e,t){const n=Object.entries(e),r=n.filter(([o])=>t.some(i=>i.id===o));return r.length===n.length?e:Object.fromEntries(r)}function Kv(e,t,n){const r=new Set(t.map(l=>l.id));n&&r.add(n);const o=([l,u])=>r.has(l)||!!u.draft||u.attachments.length>0,i=Object.entries(e);return i.every(o)?e:Object.fromEntries(i.filter(o))}function MM(e,t,n){var o;let r=e;for(const i of n){if(!((o=i.worktree)!=null&&o.landed)||t.some(u=>{var c;return u.id===i.id&&((c=u.worktree)==null?void 0:c.landed)}))continue;const l=r[i.id];!(l!=null&&l.git)||l.git.files.length===0||(r===e&&(r={...e}),r[i.id]={...l,git:{...l.git,files:[]}})}return r}function LM(e,t){let n=e;for(const[r,o]of Object.entries(t)){const i=n[r];i!=null&&i.draft||(n===e&&(n={...e}),n[r]={...i??qa,draft:o})}return n}function PM(e,t){let n=e;for(const[r,o]of Object.entries(t)){const i=n[r];i!=null&&i.attachments.length||(n===e&&(n={...e}),n[r]={...i??qa,attachments:tm(o,[])})}return n}function DM(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 ji(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 Zv(e){const t=e.newProject;if((t==null?void 0:t.phase)!=="creating"||!t.repoId)return e;const n=A1(e,t.repoId);return n?t.prompt.trim()?{...Ct(e,n.id,o=>({...o,draft:t.prompt})),newProject:null,autoSend:n.id}:{...e,newProject:null}:e}function L1(e,t){return Object.values(e.trunks).some(n=>n.id===t)}function zM(e,t){var n,r,o,i,l,u,c,h,p,g,m;switch(t.t){case"hello":{const y=T=>!!T&&t.rows.some(O=>O.id===T),w=T=>!!T&&t.repos.some(O=>O.id===T),b=w(e.activeRepoId)?e.activeRepoId:w(e.storedRepo)?e.storedRepo:null,E=y(e.activeId)?e.activeId:y(e.storedActive)?e.storedActive:Aa(e,b,t.rows),N=t.rows.find(T=>T.id===E),j=!!b&&!!N&&On(N)&&rf(N,b,t.rows);return{...e,heard:!0,repos:t.repos,rows:t.rows,activeId:E,activeRepoId:j?b:(N==null?void 0:N.repoId)??b??((n=t.repos[0])==null?void 0:n.id)??null,trunks:t.trunks,archiving:e.archiving.length?[]:e.archiving,shipping:Bv({},t.rows,t.trunks),local:Kv(PM(LM(e.local,t.drafts),t.attachments),t.rows,e.archivedPage),lastActive:DM(e.lastActive,t.rows),treeOpen:Wv(e.treeOpen,t.rows),discoveredOpen:ji(e.discoveredOpen,t.repos),archivedOpen:ji(e.archivedOpen,t.repos),committedShut:ji(e.committedShut,t.repos),turnOpen:ji(e.turnOpen,t.repos),refs:ji(e.refs,t.repos),chats:ji(e.chats,t.repos),archived:ji(e.archived,t.repos),themes:t.themes??e.themes,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,paired:t.paired,gitIdentity:t.gitIdentity,newProject:e.newProject??(t.repos.length===0&&t.rows.length===0&&t.pending.length===0?zv():null),pending:t.pending,visits:t.visits,self:t.self,update:t.update,updateCheck:e.updateCheck==="asking"?null:e.updateCheck,version:t.version,install:t.install,registry:t.registry,activeImportId:t.pending.some(T=>T.id===e.activeImportId)?e.activeImportId:null}}case"self":{const y=((r=e.self)==null?void 0:r.building)===!0&&e.self.rebuild&&!((o=t.self)!=null&&o.building);return{...e,self:t.self,rebuilt:e.rebuilt||y&&((i=t.self)==null?void 0:i.buildFailed)===void 0}}case"paired":return{...e,paired:!0,pairings:e.pairings+1};case"update":return{...e,update:t.update};case"update-checked":return{...e,updateCheck:t.check};case"visits":return{...e,visits:{...e.visits,[t.repoId]:t.pages}};case"themes":return{...e,themes:t.themes,themePrefs:t.prefs};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:y,...w}=t;return{...e,agentConfigs:{...e.agentConfigs,[w.agent]:w}}}case"pending-repos":{const y=new Set(e.pending.map(j=>j.id)),w=t.pending.find(j=>!y.has(j.id)),b=w&&e.pendingOpen?w.id:e.activeImportId,E=t.pending.some(j=>j.id===b),N=t.pending.some(j=>j.id===b&&j.error);return{...e,pending:t.pending,activeImportId:E?b:null,pendingOpen:N?!1:e.pendingOpen,newProject:w&&e.pendingOpen&&((l=e.newProject)==null?void 0:l.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:(((u=e.chosenFolder)==null?void 0:u.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}}};case"archived":return{...e,archived:{...e.archived,[t.repoId]:t.items}};case"draft":return t.clientId===e.clientId?e:Ct(e,t.boxId,y=>{var w;return y.draft===t.text||((w=y.mark)==null?void 0:w.by)==="walk"?y:{...y,draft:t.text}});case"attachments":return t.clientId===e.clientId?e:Ct(e,t.boxId,y=>({...y,attachments:tm(t.items,y.attachments)}));case"repos":{const y=new Set(e.repos.map(T=>T.id)),w=t.repos.find(T=>!y.has(T.id));let b=e.activeRepoId,E=e.pendingOpen,N=e.newProject;w&&(E||!b)?(b=w.id,E=!1,N&&N.phase!=="unmaking"&&(N={...N,phase:"creating",repoId:w.id})):t.repos.some(T=>T.id===b)||(b=((c=t.repos[0])==null?void 0:c.id)??null),(N==null?void 0:N.phase)==="unmaking"&&!t.repos.some(T=>T.id===(N==null?void 0:N.repoId))&&(N={...N,phase:"editing",repoId:null}),t.repos.length===0&&!N&&(N=zv());const j=e.gitIdentity||t.repos.some(T=>T.made&&!y.has(T.id));return b===e.activeRepoId?{...e,repos:t.repos,pendingOpen:E,newProject:N,gitIdentity:j}:Zv({...e,repos:t.repos,pendingOpen:E,newProject:N,gitIdentity:j,activeRepoId:b,activeId:Aa(e,b),editor:null})}case"worktrees":{let y=e.activeId;(!y||!t.rows.some(T=>T.id===y))&&(y=Aa(e,e.activeRepoId,t.rows));const w=new Set(e.rows.map(T=>T.id)),b=T=>{var O;return((O=T.worktree)==null?void 0:O.kind)==="worktree"&&T.worktree.createdBy===e.clientId},E=t.rows.find(T=>!w.has(T.id)&&b(T)),N=!!y&&e.rows.some(T=>{var O;return T.id===y&&((O=T.worktree)==null?void 0:O.kind)==="spare"})&&t.rows.some(T=>T.id===y&&b(T));E&&e.rows.length>0&&!N&&(y=E.id);const j=e.archiving.filter(T=>t.rows.some(O=>O.id===T));return Zv({..._a({...e,rows:t.rows,trunks:t.trunks,archiving:j.length===e.archiving.length?e.archiving:j,shipping:Bv(e.shipping,t.rows,t.trunks),local:SM(MM(Kv(e.local,t.rows,e.archivedPage),e.rows,t.rows),t.rows,e.activeId,y===(E==null?void 0:E.id)?E.id:void 0),treeOpen:Wv(e.treeOpen,t.rows)},y),editor:y===e.activeId?e.editor:null,...y===e.activeId?{activeRepoId:e.activeRepoId}:{},archivedPage:E?null:e.archivedPage})}case"proc":{const y=e.rows.map(w=>w.id===t.worktreeId?{...w,procs:FM(w.procs,t.proc)}:w);return{...e,rows:y}}case"log":return Ct(e,t.worktreeId,y=>({...y,log:QT(y.log.slice(-400),t.proc,t.line,t.retract)}));case"agent":{const y=t.event,w=t.worktreeId;let b=Ct(e,w,E=>{const N=Gv(E.chat,y,t.seq),T=y.type==="tool-start"||y.type==="tool-end"||y.type==="turn-end"||y.type==="tool-update"&&y.background?Uv(N,E.running):E.running;let O=E.turn;y.type==="turn-start"?O={edits:!1,hmr:!1}:y.type==="tool-start"&&Jb(y)&&(O={...O,edits:!0});const U=y.type==="session-info"&&y.model?y.model:E.model,Q=y.type==="session-info"&&y.effort?y.effort:E.effort,R=y.type==="usage"?{...qv(y),heard:Date.now()}:E.usage,{restoring:I,..._}=E,L=e.rows.find(fe=>fe.id===w),z=(L==null?void 0:L.agent)==="working"||(L==null?void 0:L.agent)==="waiting",F=_.sending?z?sc(_):{..._,sending:{}}:_,ee=y.type==="turn-end"||y.type==="agent-error",se=NM(y.type==="user-message"?F:ee?sc(E):E,y);return{...y.type==="user-message"?Gl(se,"reveal"):se,chat:N,...N!==E.chat?{chatAt:Date.now()}:{},...T!==E.running?{running:T}:{},turn:O,...U!==E.model?{model:U}:{},...Q!==E.effort?{effort:Q}:{},...R!==E.usage?{usage:R}:{}}});if(y.type==="turn-end"){const E=b.local[w].turn;E.edits&&!E.hmr&&(b={...b,reloadReq:{id:w,n:(((h=b.reloadReq)==null?void 0:h.n)??0)+1}})}return(y.type==="agent-question"||y.type==="agent-permission"||y.type==="handoff-proposed")&&w===e.activeId&&(b=Qo(b)),b}case"backfill":{let y=[],w;for(const{seq:E,event:N}of t.events)y=Gv(y,N,E),N.type==="usage"&&(w=qv(N));const b=E=>!E||t.events.some(({event:N})=>N.type==="user-message"&&N.text===E);return Ct(e,t.worktreeId,({restoring:E,sending:N,...j})=>({...j,...N&&!(N.message&&b(N.message.text))?{sending:N}:{},chat:y,chatAt:Date.now(),running:Uv(y,j.running),log:t.log??j.log,...w?{usage:w}:{},...E!==void 0&&!b(E)?{restoring:E}:{}}))}case"git-status":{let y=e.layout.changes,w=e.changesAuto;e.changesAuto&&t.worktreeId===e.activeId&&!y&&(t.files.length>0||(((p=t.committed)==null?void 0:p.length)??0)>0)&&(y=!0,w=!1);const b=t.worktreeId===e.archivedPage?xo(e):null;b&&(t.files.length>0||(((g=t.committed)==null?void 0:g.length)??0)>0||b.landed)&&(y=!0);const E=Ct(e,t.worktreeId,N=>({...N,git:{files:t.files,committed:t.committed,turn:t.turn,ahead:t.ahead,behind:t.behind,unpushed:t.unpushed,head:t.head},changedRanges:{}}));return{...Zr(E,{changes:y}),changesAuto:w}}case"changed-ranges":{const y=Ct(e,t.worktreeId,b=>({...b,changedRanges:{...b.changedRanges,[t.path]:{ranges:t.ranges,offset:t.lineOffset}}})),w=y.editor;return!((m=w==null?void 0:w.line)!=null&&m.fiber)||w.worktreeId!==t.worktreeId||w.path!==t.path?y:{...y,editor:{...w,line:N1(y,w.worktreeId,w.path,w.line)}}}case"shipped":{const y=t.worktreeId,w={...e,shipping:Fv(e.shipping,b=>{var E;return b===y&&((E=e.shipping[b])==null?void 0:E.sent)===!0}),openUrl:t.ok&&t.url?t.url:e.openUrl};return!t.ok&&!t.asked?y?Hv(w,y,t.message):nm(w,t.message):w}case"files":return Ct(e,t.worktreeId,y=>({...y,files:t.paths,submodules:t.submodules,ignored:t.ignored}));case"search-results":return Ct(e,t.worktreeId,y=>({...y,search:{query:t.query,hits:t.hits,truncated:t.truncated}}));case"element-sources":{if(e.editor&&e.editor.seq>t.seq)return e;const[y]=t.hits;if(!y)return Ct(e,t.worktreeId,b=>({...b,notice:"nothing in the source matches this element"}));if(!t.sure)return Ia(e,{a:"open",overlay:{kind:"element-sources",worktreeId:t.worktreeId,hits:t.hits}});const w=Ia(e,{a:"open-file",v:{worktreeId:t.worktreeId,path:y.path,view:"file",line:{n:y.line},focus:!0,seq:t.seq}});return w.layout.changes?w:Ia(w,{a:"toggle-changes"})}case"design-index":return Ct(e,t.worktreeId,y=>({...y,design:t.index}));case"routes":return Ct(e,t.worktreeId,y=>({...y,pages:{routes:t.routes,unseen:t.unseen}}));case"queue":return Ct(e,t.worktreeId,y=>({...y,queue:t.items}));case"agent-commands":return Ct(e,t.worktreeId,y=>({...y,commands:t.commands}));case"git-log":return Ct(e,t.worktreeId,y=>({...y,commits:t.commits}));case"git-commit":return Ct(e,t.worktreeId,y=>({...y,commitFiles:{...y.commitFiles,[t.sha]:t.files}}));case"error":{const y=t.worktreeId,w=e.newProject,b=(w==null?void 0:w.phase)==="creating"&&!w.repoId,E={..._M(EM(e,y),y),archiving:y?e.archiving.includes(y)?e.archiving.filter(N=>N!==y):e.archiving:e.archiving.length?[]:e.archiving,shipping:Fv(e.shipping,N=>!y||N===y),newProject:b?{...w,phase:"editing",error:t.message}:(w==null?void 0:w.phase)==="unmaking"?null:w,pendingOpen:b?!1:e.pendingOpen,updateCheck:!y&&e.updateCheck==="asking"?null:e.updateCheck};return b?E:y?Hv(E,y,t.message):nm(E,t.message)}case"unsent":return Ct(Qo(e),t.boxId,({restoring:y,sending:w,...b})=>({...b,draft:b.draft||t.text,attachments:[...tm(t.items,[]),...b.attachments],notice:t.message}));default:return e}}function FM(e,t){const n=e.findIndex(o=>o.name===t.name);if(n===-1)return[...e,t];const r=e.slice();return r[n]=t,r}function qv(e){return{used:e.used,size:e.size,...e.cost!==void 0?{cost:e.cost}:{}}}function BM(e,t){const n=t.trim();return n!==""&&(e.trim()===n||e.trim().endsWith(`: ${n}`))}function Gv(e,t,n){var i,l;const r=e[e.length-1],o=n===void 0?{}:{seq:n};switch(t.type){case"fix-asked":return[...e,{kind:"asked",why:t.why,...t.toolId?{toolId:t.toolId}:{}}];case"user-message":return[...e,{kind:"user",text:t.text,...(i=t.attachments)!=null&&i.length?{attachments:t.attachments}:{},...o}];case"text-delta":{const u=t.messageId?{messageId:t.messageId}:{};if((r==null?void 0:r.kind)==="assistant")return[...e.slice(0,-1),{...r,text:r.text+t.text,...u}];const c=t.messageId===void 0?-1:UM(e,t.messageId);if(c!==-1){const h=e.slice(),p=h[c];return h[c]={...p,text:p.text+t.text},h}return[...e,{kind:"assistant",text:t.text,...o,...u}]}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 u=e.findLastIndex(p=>p.kind==="tool"&&p.id===t.toolId);if(u===-1)return e;const c=e.slice(),h=c[u];return c[u]={...h,...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}:{}},c}case"tool-delta":{const u=e.findLastIndex(p=>p.kind==="tool"&&p.id===t.toolId);if(u===-1)return e;const c=e.slice(),h=c[u];return c[u]={...h,output:(h.output??"")+t.text},c}case"tool-end":{const u=e.findLastIndex(p=>p.kind==="tool"&&p.id===t.toolId);if(u===-1)return e;const c=e.slice(),h=c[u];return c[u]={...h,output:t.output,isError:t.isError,...(l=t.images)!=null&&l.length?{images:t.images}:{},...t.detached?{detached:!0}:{},...t.fixable?{fixable:t.fixable}:{},done:!0},c}case"agent-error":return(r==null?void 0:r.kind)==="assistant"&&BM(t.message,r.text)?[...e.slice(0,-1),{kind:"error",text:t.message}]:[...e,{kind:"error",text:t.message}];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"landed":return[...e,{kind:"landed",text:t.message,archiveIds:t.archiveIds,ts:t.ts}];case"handoff-proposed":return[...e,{kind:"handoff",id:t.id,repo:t.repo,message:t.message,...t.title?{title:t.title}:{},by:t.by,mode:t.mode,state:"proposed",ts:t.ts}];case"handoff":{const u=e.findLastIndex(p=>p.kind==="handoff"&&p.id===t.id&&p.state==="proposed");if(u===-1)return[...e,{kind:"handoff",id:t.id,repo:{id:t.repoId,name:t.repoName,path:""},message:"",title:t.title,by:"agent",mode:ld,state:"continued",worktreeId:t.worktreeId,ts:t.ts}];const c=e.slice(),h=c[u];return c[u]={...h,state:"continued",worktreeId:t.worktreeId,title:t.title},c}case"handoff-declined":{const u=e.findLastIndex(p=>p.kind==="handoff"&&p.id===t.id&&p.state==="proposed");if(u===-1)return e;const c=e.slice(),h=c[u];return c[u]={...h,state:"declined",...t.reason?{reason:t.reason}:{}},c}case"handoff-landed":return[...e,{kind:"handoff-landed",worktreeId:t.worktreeId,repoName:t.repoName,title:t.title,...t.url?{url:t.url}:{},ts:t.ts}];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}:{},done:!1}];case"agent-auth-ok":return e.some(u=>u.kind==="auth"&&!u.done)?e.map(u=>u.kind==="auth"&&!u.done?{...u,done:!0}:u):e;case"agent-question":return Vv(e,t.toolId,{kind:"ask",id:t.id,ask:{kind:"question",message:t.message,questions:t.questions}});case"agent-permission":{const u={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}:{},choices:t.choices}},c=e.findLast(h=>h.kind==="tool"&&h.id===t.toolId);return(c==null?void 0:c.kind)!=="tool"||t.plan||c.toolKind==="switch_mode"?Vv(e,t.toolId,u):[...e,{...u,toolId:c.id}]}case"agent-ask-end":{const u=e.findLastIndex(p=>p.kind==="ask"&&p.id===t.id&&!p.outcome);if(u===-1)return e;const c=e[u];if(c.toolId&&HM(c,t.choiceId))return[...e.slice(0,u),...e.slice(u+1)];const h=e.slice();return h[u]={...h[u],outcome:t.outcome,...t.answers?{answers:t.answers}:{},...t.choiceId?{choiceId:t.choiceId}:{}},h}case"turn-end":{const u=c=>c.kind==="tool"&&!c.done&&!c.background;return e.some(u)?e.map(c=>u(c)?{...c,done:!0}:c):e}default:return e}}function UM(e,t){var o;let n=e.length-1;for(;n>=0&&((o=e[n])==null?void 0:o.kind)==="user";)n--;const r=e[n];return(r==null?void 0:r.kind)==="assistant"&&r.messageId===t?n:-1}function HM(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 Vv(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 WM(e){let t=e;const n=new Set;return{getState:()=>t,dispatch(r){const o=Ia(t,r);if(o!==t){t=o;for(const i of n)i()}},subscribe(r){return n.add(r),()=>n.delete(r)}}}const P1=S.createContext(null),vg=S.createContext(null),D1=S.createContext(null);function KM({store:e,sock:t,files:n,children:r}){return f.jsx(P1.Provider,{value:e,children:f.jsx(vg.Provider,{value:t,children:f.jsx(D1.Provider,{value:n,children:r})})})}const z1=S.createContext(null),F1=S.createContext(null);function ZM({machines:e,children:t}){const n=S.useSyncExternalStore(e.subscribe,e.active);return f.jsx(z1.Provider,{value:e,children:f.jsx(F1.Provider,{value:n,children:f.jsx(KM,{store:n.store,sock:n.sock,files:n.files,children:f.jsx(S.Fragment,{children:t},n.origin)})})})}function _o(){const e=S.useContext(z1);if(!e)throw new Error("useMachines outside <MachinesProvider>");return e}function Mr(){const e=S.useContext(F1);if(!e)throw new Error("useMachine outside <MachinesProvider>");return e}function bg(){const e=_o();return S.useSyncExternalStore(e.subscribe,e.list)}function va(e,t){return S.useSyncExternalStore(e.store.subscribe,()=>t(e.store.getState()))}const Yv=(e,t)=>e.length===t.length&&e.every((n,r)=>n===t[r]);function B1(){const e=_o(),t=Mr(),n=bg(),r=S.useMemo(()=>n.filter(u=>u!==t),[n,t]),o=S.useRef(null),i=S.useCallback(u=>{const c=r.map(h=>h.store.subscribe(u));return()=>{for(const h of c)h()}},[r]),l=S.useCallback(()=>{const u=r.map(g=>e.displayName(g.origin)),c=r.map(g=>g.store.getState().repos),h=o.current;if(h&&h.others===r&&Yv(h.names,u)&&Yv(h.repos,c))return h.value;const p=r.map((g,m)=>({origin:g.origin,name:u[m]??g.origin,repos:c[m]??[]}));return o.current={others:r,names:u,repos:c,value:p},p},[r,e]);return S.useSyncExternalStore(i,l)}function p7(){return Mr().terminals}function Kn(){const e=S.useContext(P1);if(!e)throw new Error("useStore outside <StoreProvider>");return e}function M(e){const t=Kn();return S.useSyncExternalStore(t.subscribe,()=>e(t.getState()))}function xg(){const e=M(n=>n.systemDark),t=M(n=>{var r;return(r=n.daylight)==null?void 0:r.dark});return{system:e,daylight:t??e}}function at(){return Kn().dispatch}function st(){return S.useContext(vg)}function Lr(){const e=S.useContext(vg);return(e==null?void 0:e.urls)??u1(location.origin,"")}function U1(){return S.useContext(D1)}function H1(e=!1,t=!0){const n=S.useRef(null);return S.useEffect(()=>{if(!t)return;const r=()=>{const i=n.current;!i||document.activeElement===i||(i.focus(),e&&i instanceof HTMLInputElement&&i.select())};r();const o=requestAnimationFrame(r);return()=>cancelAnimationFrame(o)},[e,t]),n}function yo(e,t,n,r=qM){const o=()=>{try{return n(r.get(e))??t}catch{return t}},[i,l]=S.useState(()=>({key:e,value:o()}));return i.key!==e&&l({key:e,value:o()}),[i.key===e?i.value:o(),h=>{l({key:e,value:h});try{r.set(e,typeof h=="boolean"?h?"1":"0":String(h))}catch{}}]}const qM={get:e=>localStorage.getItem(e),set:(e,t)=>localStorage.setItem(e,t)};function Ra(e,t){return n=>{n.preventDefault(),document.body.classList.add("resizing");const r=n.currentTarget;r.classList.add("active");const o=l=>{const u=e(l,r);u!==null&&t(u)},i=()=>{document.body.classList.remove("resizing"),r.classList.remove("active"),window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",i)};window.addEventListener("pointermove",o),window.addEventListener("pointerup",i)}}function W1(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 Eg(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 _g=1500;function Fa(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 GM(){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 VM(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(),i=n.getBoundingClientRect(),l=i.bottom-o.bottom;if(l<=0)return;const u=parseFloat(getComputedStyle(r).paddingTop)||0;r.scrollTop+=Math.min(l,Math.max(0,i.top-o.top-u))}),n=>{t.current=n}}const dp=40,YM=1200,QM=150,XM=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]);function K1(e,t){const n=S.useRef(!0),r=S.useRef(Number.NEGATIVE_INFINITY),o=S.useRef(!1),[i,l]=S.useState(!1),[u,c]=S.useState(!1),[h,p]=S.useState(!1),[g,m]=S.useState(null),y=S.useCallback(O=>{n.current=O,e.current&&(e.current.style.overflowAnchor=O?"none":"")},[e]),w=S.useRef(null),b=S.useRef(null);yt([t],()=>{n.current||p(!0)});const E=S.useCallback(()=>{const O=e.current;O&&(y(O.scrollHeight-O.scrollTop-O.clientHeight<dp),l(!n.current),c(O.scrollTop>=dp),n.current&&p(!1))},[e,y]),N=S.useCallback(O=>{O!==0&&(m(O<0?"up":"down"),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>m(null),YM))},[]),j=S.useCallback(()=>{const O=e.current;O&&(O.scrollTop=O.scrollHeight,y(!0),l(!1),p(!1))},[e,y]),T=S.useCallback(()=>{const O=e.current;O&&(r.current=performance.now(),O.scrollTop=0)},[e]);return S.useEffect(()=>{const O=e.current;if(!O)return;y(n.current);const U=()=>o.current||performance.now()-r.current<QM,Q=()=>{n.current&&!U()?c(O.scrollTop>=dp):E()};O.addEventListener("scroll",Q,{passive:!0});const R=()=>{r.current=performance.now()},I=ne=>{R(),N(ne.deltaY)},_=ne=>{var A;R(),w.current=((A=ne.touches[0])==null?void 0:A.clientY)??null},L=ne=>{var q;R();const A=(q=ne.touches[0])==null?void 0:q.clientY;A===void 0||w.current===null||(N(w.current-A),w.current=A)},z=()=>{o.current=!0},F=()=>{o.current=!1},ee=ne=>{if(!XM.has(ne.key))return;const A=ne.target;(A===document.body||A instanceof Node&&O.contains(A))&&R()};O.addEventListener("wheel",I,{passive:!0}),O.addEventListener("touchstart",_,{passive:!0}),O.addEventListener("touchmove",L,{passive:!0}),O.addEventListener("pointerdown",z,{passive:!0}),window.addEventListener("pointerup",F,{passive:!0}),window.addEventListener("pointercancel",F,{passive:!0}),document.addEventListener("keydown",ee);const se=()=>{O.scrollTop=O.scrollHeight},fe=new ResizeObserver(()=>{n.current&&se()});fe.observe(O);for(const ne of O.children)fe.observe(ne);const ke=new MutationObserver(ne=>{for(const A of ne){for(const q of A.addedNodes)q instanceof Element&&fe.observe(q);for(const q of A.removedNodes)q instanceof Element&&fe.unobserve(q)}n.current&&se()});return ke.observe(O,{childList:!0}),()=>{O.removeEventListener("scroll",Q),O.removeEventListener("wheel",I),O.removeEventListener("touchstart",_),O.removeEventListener("touchmove",L),O.removeEventListener("pointerdown",z),window.removeEventListener("pointerup",F),window.removeEventListener("pointercancel",F),document.removeEventListener("keydown",ee),ke.disconnect(),fe.disconnect(),b.current&&clearTimeout(b.current)}},[e,E,N,y]),{offEnd:i,offStart:u,away:h,moving:g,pinned:()=>n.current,jump:j,start:T,read:E}}function Qv(e,t,n){const r=document.createRange();return r.selectNodeContents(e),r.setEnd(t,n),r.toString().length}function Xv(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=0,o=null;for(let i=n.nextNode();i;i=n.nextNode()){if(r+i.data.length>=t)return[i,t-r];r+=i.data.length,o=i}return o?[o,o.data.length]:[e,0]}function Z1(e,t){S.useLayoutEffect(()=>{const n=e.current;if(!n)return;const r=window.getSelection(),o=m=>!!m&&n.contains(m),i=r&&r.rangeCount>0&&o(r.anchorNode)?Qv(n,r.anchorNode,r.anchorOffset):null,l=r&&r.rangeCount>0&&o(r.focusNode)?Qv(n,r.focusNode,r.focusOffset):null,u=r&&(i!==null||l!==null)?[r.anchorNode,r.anchorOffset,r.focusNode,r.focusOffset]:null;if(n.innerHTML=t,!r||!u)return;const[c,h]=i===null?[u[0],u[1]]:Xv(n,i),[p,g]=l===null?[u[2],u[3]]:Xv(n,l);c&&p&&r.setBaseAndExtent(c,h,p,g)},[e,t])}function yt(e,t){const n=S.useRef(t);n.current=t,S.useEffect(()=>n.current(),e)}function q1(e){const[t,n]=S.useState({left:0,right:0});return S.useLayoutEffect(()=>{if(!e)return;const r=()=>{const i=e.getBoundingClientRect();let{left:l,right:u}=i;const c=e.closest("[data-pinned]");if(c){const p=c.getBoundingClientRect(),g=c.offsetWidth/p.width;l=c.offsetLeft+(l-p.left)*g,u=c.offsetLeft+(u-p.left)*g}const h={left:Math.round(l),right:Math.round(u)};n(p=>p.left===h.left&&p.right===h.right?p:h)};r();const o=new ResizeObserver(r);return o.observe(e),window.addEventListener("resize",r),()=>{o.disconnect(),window.removeEventListener("resize",r)}},[e]),t}function Jv(){const[e,t]=S.useState(null);return[t,q1(e)]}function m7(e){e.ctrlKey&&e.stopPropagation()}function JM(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 eL(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])}const Ga=()=>M(e=>e.activeId),G1=()=>W1(!M(e=>e.connected),900),Ss=()=>M(e=>rn(e,e.activeId)),Sg=()=>M(e=>es(e,e.activeId)),V1=()=>M(e=>e.rows),Ng=()=>M(e=>e.visible),tL=()=>M(e=>e.visibleDiscovered),nL=()=>M(e=>e.activeRepoId?e.discoveredOpen[e.activeRepoId]??!1:!1),e0=[],rL=()=>M(e=>e.activeRepoId?e.archived[e.activeRepoId]??e0:e0),oL=()=>M(e=>e.activeRepoId?e.archivedOpen[e.activeRepoId]??!1:!1),sL=()=>M(e=>!(e.activeRepoId&&e.committedShut[e.activeRepoId])),iL=()=>M(e=>!!(e.activeRepoId&&e.turnOpen[e.activeRepoId])),Hi=()=>M(xo),Tg=()=>M(R1),aL=()=>M(e=>ai(e,e.activeRepoId)),Va=()=>M(e=>ai(e,kg(e))),Y1=e=>M(t=>bo(t,e)),At=(e,t)=>M(n=>bo(n,e)[t]),lL=()=>M(e=>e.overlay),of=()=>M(gM),Q1=()=>M(j1),vc=()=>M(kM),bc=()=>M(wo),cL=()=>M(e=>e.newProject),Wi=()=>M(e=>e.touch),uL=()=>M(e=>e.draft),jg=()=>M(Dl),dL=()=>M(e=>{const t=es(e,e.activeId),n=t?e.repos.find(r=>r.id===t.repoId):null;return bd(n)?n:null});function fL(e){return e.image?{kind:"image",blob:e.image,sig:`image:${e.image.type}:${e.image.size}`}:e.text&&Xx(e.text)?{kind:"text",text:e.text,sig:`text:${e.text}`}:null}function hL(){try{return localStorage.getItem(Ze.clipboardOffer)==="1"}catch{return!1}}let xs={access:"none",on:typeof localStorage<"u"&&hL(),offer:null},rm="";const om=new Set;function sf(e){xs={...xs,...e};for(const t of om)t()}async function pL(){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 fL({image:e,text:t})}async function af({taken:e=!1,asking:t=!1}={}){if(!xs.on||!(xs.access==="granted"||t&&xs.access==="prompt"))return;let n;try{n=await pL()}catch{return}e&&(rm=(n==null?void 0:n.sig)??""),sf({offer:n&&n.sig!==rm?n:null})}const mL=()=>void af();let t0=!1;function gL(){var e,t;t0||(t0=!0,!(!((e=navigator.clipboard)!=null&&e.read)||!((t=navigator.permissions)!=null&&t.query))&&navigator.permissions.query({name:"clipboard-read"}).then(n=>{const r=()=>{sf({access:n.state,...n.state==="denied"?{offer:null}:{}})};n.onchange=r,r(),window.addEventListener("focus",mL),document.hasFocus()&&af()},()=>{}))}function kL(e){return om.add(e),gL(),()=>{om.delete(e)}}const yL=()=>xs;function wL(e){try{localStorage.setItem(Ze.clipboardOffer,e?"1":"0")}catch{}sf({on:e,offer:null}),e&&af({asking:!0})}function X1(){xs.offer&&(rm=xs.offer.sig),sf({offer:null})}const vL=()=>void af({taken:!0});function bL(){return S.useSyncExternalStore(kL,()=>xs.offer)}const J1="application/x-toyon-source";function g7(e){const t=e.endColumn===1&&e.endLineNumber>e.startLineNumber?e.endLineNumber-1:e.endLineNumber;return{startLine:e.startLineNumber,endLine:t}}function xL(e,t){e.setData(J1,JSON.stringify(t))}const n0=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1;function EL(e,t){const n=e.getData(J1);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:i,ref:l}=r;return!n0(o)||!n0(i)||i<o?null:{path:r.path,startLine:o,endLine:i,...typeof l=="string"?{ref:l}:{}}}const eE=e=>({left:e.x,top:e.y,right:e.x,bottom:e.y});function _L(e,t){return t.matchWidth===void 0?void 0:Math.max(0,e.right-e.left+t.matchWidth)}const SL=new Set(["top","bottom"]),fp={top:"bottom",bottom:"top",left:"right",right:"left"};function hp(e,t,n,r,o){const i=n==="top"||n==="left";return o?i?e.end+r-t:e.start-r:i?e.start-r-t:e.end+r}function r0(e,t,n,r,o){return n==="top"||n==="left"?e>=o:e+t<=r-o}function pp(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 o0(e,t,n,r,o){return n==="start"?e+t<=r-o:e>=o}const s0=(e,t,n,r)=>n||!r?e:t,i0=(e,t,n,r)=>Math.max(r,Math.min(e,n-r-t));function NL(e,t,n,r){const{offset:o=0,alignOffset:i=0,cover:l=!1,flip:u="none",margin:c=8}=r,h=SL.has(r.side),p=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},g=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 m=r.side;if(u==="side"||u==="both"){const E=hp(p.a,p.size,m,o,l),N=hp(p.a,p.size,fp[m],o,l);m=s0(m,fp[m],r0(E,p.size,m,p.limit,c),r0(N,p.size,fp[m],p.limit,c))}let y=r.align??"center";if((u==="align"||u==="both")&&y!=="center"){const E=y==="start"?"end":"start",N=pp(g.a,g.size,y,i),j=pp(g.a,g.size,E,i);y=s0(y,E,o0(N,g.size,y,g.limit,c),o0(j,g.size,E,g.limit,c))}const w=i0(hp(p.a,p.size,m,o,l),p.size,p.limit,c),b=i0(pp(g.a,g.size,y,i),g.size,g.limit,c);return h?{x:b,y:w,side:m,align:y}:{x:w,y:b,side:m,align:y}}function TL(e,t,n){var i,l;const r=e.length;if(r===0)return-1;let o=t<0?n===1?0:r-1:(t+n+r)%r;for(let u=0;u<r&&((i=e[o])!=null&&i.disabled);u++)o=(o+n+r)%r;return(l=e[o])!=null&&l.disabled?-1:o}const tE={sep:!0},Es=e=>!("sep"in e);function lf(e){const t=[];for(const n of e)(Es(n)||t.length>0&&Es(t[t.length-1]))&&t.push(n);for(;t.length>0&&!Es(t[t.length-1]);)t.pop();return t}const Mn=e=>lf(e.flatMap((t,n)=>n?[tE,...t]:t));let ka=null,jL=0;const sm=new Set,a0=()=>{for(const e of sm)e()},Gr={get:()=>ka,subscribe(e){return sm.add(e),()=>{sm.delete(e)}},open(e){const t=lf(e.items);if(t.length===0)return Gr.close();ka={...e,items:t,id:++jL},a0()},close(){ka&&(ka=null,a0())},toggle(e){ka&&ka.target===e.target?Gr.close():Gr.open(e)}};function nE(){return S.useSyncExternalStore(Gr.subscribe,Gr.get)}function rE(e){const t=e.nativeEvent;return t&&"pointerType"in t?t.pointerType==="":e.clientX===0&&e.clientY===0}function CL(e,t){return rE(e)?{anchor:(t.querySelector('[data-state~="cursor"]')??t).getBoundingClientRect()}:{at:{x:e.clientX,y:e.clientY}}}function AL(e){const t=e.anchor;return t?{rect:t,placement:{side:"bottom",align:e.align==="right"?"end":"start",offset:4,margin:4}}:{rect:eE(e.at??{x:0,y:0}),placement:{side:"bottom",align:"start",margin:4}}}function on(e){return S.useMemo(()=>({contextMenu(t,n){return{onContextMenu:r=>{const o=lf(t(rE(r)?"keyboard":"pointer",r.target));if(o.length===0)return;r.preventDefault(),r.stopPropagation();const i=r.currentTarget;Gr.open({items:o,owner:e,key:n,target:i,...CL(r,i)})}}},dropdown(t,n="left"){return{"aria-haspopup":"menu",onClick:r=>{r.stopPropagation();const o=r.currentTarget;Gr.toggle({items:t(),owner:e,target:o,toggles:!0,anchor:o.getBoundingClientRect(),align:n})}}},openUnder(t,n,r){Gr.open({items:n(),owner:e,key:r,target:t,toggles:!0,anchor:t.getBoundingClientRect(),align:"left"})}}),[e])}const oE=e=>({id:"open-out",label:tf()?"open in the browser":"open in a new tab",onClick:()=>window.open(e,"_blank")}),Yt=e=>{var t;return void((t=navigator.clipboard)==null?void 0:t.writeText(e).catch(()=>{}))};function sE(e,t){const n=navigator.clipboard;if(n){if(typeof ClipboardItem>"u"||!n.write){e==="text/plain"&&t.then(r=>r.text()).then(Yt,()=>{});return}n.write([new ClipboardItem({[e]:t})]).catch(()=>{})}}const IL=e=>sE("text/plain",fetch(e).then(t=>t.blob())),RL=e=>sE("image/png",$L(e));async function $L(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,i)=>r.toBlob(l=>l?o(l):i(new Error("could not encode image")),"image/png"))}finally{n.close()}}const OL=[{label:"Zed",scheme:"zed"},{label:"VS Code",scheme:"vscode"},{label:"Cursor",scheme:"cursor"}];function Cg(e){return Gm(e)}function ts(e){return(e==null?void 0:e.urls.host)??(typeof location=="object"?location.hostname:"127.0.0.1")}function Bi(e,t,n){if(!Cg(n))return[];const r=OL.map(o=>({id:`open:${o.scheme}`,label:`open in ${o.label}`,onClick:()=>{window.location.href=`${o.scheme}://file${e}`}}));return r.push(...cf(t,n)),r}function cf(e,t){return!e||!Cg(t)?[]:[{id:"reveal",label:"reveal in Finder",onClick:e}]}function ML(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??""}
|
|
98
|
+
${n.sort().join(`
|
|
99
|
+
`)}`}function uf(e,t,{sock:n,dispatch:r}){var l,u;if(!n)return;const o=t.local[e]??qa,i=ML((l=o.git)==null?void 0:l.head,((u=o.git)==null?void 0:u.files)??[]);o.filesFor!==i&&(r({a:"files-asked",worktreeId:e,key:i}),n.send({t:"list-files",worktreeId:e}))}const LL=["diff","file","preview"],iE=(e,t)=>LL.filter(n=>!(n==="preview"&&!Jd(e))&&!(n==="diff"&&t));let PL=0;const Po=()=>++PL;function nr({dispatch:e},{focus:t=!0,...n}){e({a:"open-file",v:{...n,focus:t,seq:Po()}})}const im=new Map;function aE(e,t,n=""){const{sock:r}=e;if(!r)return Promise.resolve("not connected to the daemon");const o=Po();return new Promise(i=>{im.set(o,l=>{l.ok?(nr(e,{...t,view:Fi(t.path)}),i(null)):i(l.reason==="changed"?"a file is already there":l.message??"the file was not made")}),r.send({t:"write-file",...t,content:n,base:null,seq:o})})}function DL(e){const t=im.get(e.seq);return t?(im.delete(e.seq),t(e),!0):!1}function zL({dispatch:e},t){e({a:"tree-reveal",...t})}function vs(e,t,{discard:n=!1,ref:r,since:o,showing:i,added:l=!1,kept:u=!1,select:c},h){const{sock:p,dispatch:g}=h,m=iE(t,l).filter(j=>j!==i).map(j=>({id:`view:${j}`,label:`view ${j}`,onClick:()=>i?g({a:"editor-view",v:j}):nr(h,{worktreeId:e.id,path:t,view:j,ref:r,since:o})})),y=`${e.dir}/${t}`,w=u?[]:Bi(y,()=>p==null?void 0:p.send({t:"reveal",worktreeId:e.id,path:t}),ts(p));return Mn([m,[{id:"copy-path",label:"copy path",onClick:()=>Yt(y)}],w,c?[{id:"select",label:"select…",onClick:()=>c(t)}]:[],n?[{id:"discard",label:"discard changes…",danger:!0,onClick:()=>{window.confirm(lE([t]))&&(p==null||p.send({t:"discard-files",worktreeId:e.id,paths:[t]}))}}]:[]])}function lE(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(`
|
|
100
|
+
`);return`Discard uncommitted changes to ${e.length} files?
|
|
101
|
+
|
|
102
|
+
${r}`}const co=(e,t,n)=>e.dispatch({a:"notice",id:t,text:n});function df(e,t,n){var o;const r=aj(((o=e.getState().local[t])==null?void 0:o.attachments)??[],n);return r===0&&co(e,t,Zm(n)),r}const FL=1e3,BL=1e4,cE=new WeakMap;function UL(e,t){cE.set(e,t)}async function uE(e,t,n,r){var g;const{local:o,...i}=n;e.dispatch({a:"attach",id:t,items:[{...n,upload:"",uploading:!0}]});const l=()=>{var m;return!!((m=e.getState().local[t])!=null&&m.attachments.some(y=>y.key===n.key))},u=cE.get(e),c=()=>u?C2(u,n.kind,r):Promise.resolve(null);let h=await c();const p=h===null;p&&co(e,t,`${n.name}: Toyon is not answering; it attaches once it is back`);for(let m=FL;h===null&&l();m=Math.min(m*2,BL))await new Promise(y=>setTimeout(y,m)),l()&&(h=await c());if(h!==null)if(typeof h=="string")e.dispatch({a:"detach",id:t,key:n.key}),co(e,t,`${n.name}: ${h}`);else{const m=i.kind==="file"?{...i,...h}:{...i,upload:h.upload,bytes:h.bytes};e.dispatch({a:"attached",id:t,key:n.key,item:m});const y=(g=e.getState().local[t])==null?void 0:g.notice;p&&(y!=null&&y.startsWith(`${n.name}: Toyon is not answering`))&&co(e,t,"")}o&&URL.revokeObjectURL(o)}function Ag(e,t,n){if(!t||n.length===0)return;const r=df(e,t,"file");if(r!==0){for(const o of n.slice(0,r)){const i=o.name||"file";if(o.size>Nv){co(e,t,`${i}: larger than ${qm(Nv)}`);continue}const l={kind:"file",key:crypto.randomUUID(),upload:"",name:i,bytes:o.size,text:!1};uE(e,t,l,o)}n.length>r&&co(e,t,`kept ${r} of ${n.length}: ${Zm("file")}`)}}function Ig(e,t,n,r={}){if(!t)return;const o=EO(r.source?n.replace(/\r?\n$/,""):n);if(o.length>mO)return r.source?co(e,t,"that paste is too large; save it in the worktree and reference it with @path"):Ag(e,t,[new File([o],gO,{type:"text/plain"})]);df(e,t,"paste")!==0&&e.dispatch({a:"attach",id:t,items:[{kind:"paste",key:crypto.randomUUID(),text:o,...r,...og(o)}]})}function dE(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 l0(e,t){var i;const n=e.getState(),r=rn(n,n.activeId),o=wc(r);if(t&&o&&t.worktreeId===(r==null?void 0:r.worktree.id)&&t.text.trim()){const l="source"in t?{source:t.source}:{name:t.name};(((i=n.local[o])==null?void 0:i.attachments)??[]).some(c=>{var y;if(c.kind!=="paste")return!1;if(!("source"in t))return c.name===t.name&&c.text===t.text;const{path:h,startLine:p,endLine:g,ref:m}=t.source;return((y=c.source)==null?void 0:y.path)===h&&c.source.startLine===p&&c.source.endLine===g&&c.source.ref===m})||Ig(e,o,t.text,l)}e.dispatch(t?{a:"focus-chat"}:C1(n))}function ff(e,t){return t!==e.activeId?null:wc(rn(e,t))}const Rg=(e,t)=>`@${e}${t?"/":""}`;function $g(e,t,n){var u;const r=e.getState(),o=ff(r,t);if(!o)return;const i=((u=r.local[o])==null?void 0:u.draft)??"",l=i===""||/\s$/.test(i)?"":" ";e.dispatch({a:"set-draft",id:o,text:`${i}${l}${n}`}),e.dispatch({a:"focus-chat"})}function fE(e,t,n,r){$g(e,t,`${Rg(n,r)} `)}function HL(e,t,n){n.length!==0&&$g(e,t,`${n.map(r=>Rg(r,!1)).join(" ")} `)}function c0(e,t,n){$g(e,t,n)}function WL(e,t){return rn(e,t)?t:null}function KL(e,t){var r;const n=(r=rn(e,t))==null?void 0:r.worktree;return n?[n.path]:[]}function u0(e,t){if(!e)return e;const n=t.find(r=>e.startsWith(`${r}/`));return n?e.slice(n.length+1):e}function ZL(e,t,n){var m;e.dispatch({a:"set-picking",v:!1});const r=e.getState(),o=WL(r,t);if(!o)return;const{classes:i,route:l,element:u,...c}=n,h=KL(r,t),p={...c,file:u0(c.file,h),callFile:u0(c.callFile,h)};!(((m=r.local[o])==null?void 0:m.attachments)??[]).some(y=>y.kind==="pick"&&y.selector===p.selector)&&df(e,o,"pick")>0&&e.dispatch({a:"attach",id:o,items:[{kind:"pick",key:crypto.randomUUID(),...p}]}),e.dispatch({a:"focus-chat"})}function qL(e,t=[],n=[]){const r={path:"",name:"",kind:"folder",children:[],ignored:!1},o=new Map([["",r]]),i=c=>{const h=o.get(c);if(h)return h;const p=c.lastIndexOf("/"),g={path:c,name:c.slice(p+1),kind:"folder",children:[],ignored:!1};return i(p===-1?"":c.slice(0,p)).children.push(g),o.set(c,g),g},l=(c,h,p=!1)=>{const g=c.lastIndexOf("/");i(g===-1?"":c.slice(0,g)).children.push({path:c,name:c.slice(g+1),kind:h,children:[],ignored:p})};for(const c of e)l(c,"file");for(const c of t)l(c,"submodule");for(const c of n)c.endsWith("/")?l(c.slice(0,-1),"ignored",!0):l(c,"file",!0);const u=c=>{const h=p=>p.kind==="file"?1:0;c.children.sort((p,g)=>h(p)-h(g)||x1(p.name,g.name));for(const p of c.children)p.kind==="folder"&&u(p)};return u(r),r.children}function GL(e,t){const n=[],r=(o,i)=>{for(const l of o){const u=l.kind==="folder"&&t(l.path);n.push({path:l.path,name:l.name,depth:i,kind:l.kind,open:u,ignored:l.ignored}),u&&r(l.children,i+1)}};return r(e,0),n}const hE=e=>{const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)};function VL(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 YL(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 i of wd(o))n.add(i)}return{files:t,folders:n}}const pE=new Set(fO),QL=/^image\.[a-z0-9]+$/i,XL=e=>QL.test(e.name),JL=(e,t)=>e===t||e.name===t.name&&e.size===t.size&&e.type===t.type&&e.lastModified===t.lastModified;function eP(e){if(!e)return[];const t=[];for(const i of Array.from(e.items??[])){if(i.kind!=="file"||!i.type.startsWith("image/"))continue;const l=i.getAsFile();l&&t.push(l)}if(t.length===0)for(const i of Array.from(e.files??[]))i.type.startsWith("image/")&&t.push(i);const n=[];for(const i of t)n.some(l=>JL(l,i))||n.push(i);const r=n.filter(i=>!XL(i));if(r.length>0)return r;const o=n.find(i=>pE.has(i.type))??n[0];return o?[o]:[]}function tP(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 nP(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 rP(e){try{return await createImageBitmap(e)}catch{throw new Error(`${e.name||"image"}: not a readable image`)}}function d0(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,i)=>r.toBlob(l=>l?o(l):i(new Error("could not encode image")),n,.9))}async function oP(e){const t=await rP(e);try{const n=Math.max(t.width,t.height);let r=e,o=e.type,i=t.width,l=t.height;if(!pE.has(o)||n>Sv||e.size>up){const u=o==="image/jpeg"?"image/jpeg":"image/png";let c=Math.min(1,Sv/n);for(r=await d0(t,c,u);r.size>up&&c>.1;)c*=.7,r=await d0(t,c,u);if(r.size>up)throw new Error(`${e.name||"image"}: too large even after downscaling`);o=u,i=Math.max(1,Math.round(t.width*c)),l=Math.max(1,Math.round(t.height*c))}return{blob:r,name:e.name||`pasted.${o==="image/jpeg"?"jpg":"png"}`,mimeType:o,width:i,height:l}}finally{t.close()}}const Vl={el:null},sP=80,iP=2e3;let Jo=null,am;const mE=(e,t)=>{clearTimeout(am),am=setTimeout(()=>Mg(e),t)};function Og(e,t){Jo??(Jo={refused:!1}),e.dispatch({a:"drag-files",v:Jo.refused?null:t}),mE(e,iP)}function aP(e){Jo&&mE(e,sP)}function Mg(e){clearTimeout(am),Jo=null,e.dispatch({a:"drag-files",v:null})}function lP(e){Jo&&(Jo.refused=!0,e.dispatch({a:"drag-files",v:null}))}const gE="application/x-toyon-path";let $i=null;function cP(e){$i=e}function kE(e){$i=null,Jo&&Mg(e)}const f0=e=>$i!==null&&Array.from(e.dataTransfer.types).includes(gE);function uP(e){return{onDragOver:t=>{if(!f0(t)||!$i)return;t.preventDefault();const n=ff(e.getState(),$i.worktreeId)!==null;t.dataTransfer.dropEffect=n?"copy":"none",n&&Og(e,{at:"chat"})},onDrop:t=>{if(!f0(t)||!$i)return;t.preventDefault();const{worktreeId:n,path:r,folder:o}=$i;kE(e),fE(e,n,r,o)}}}let dP=0;function fP(e){const{blob:t,...n}=e;return{kind:"image",key:`img${++dP}`,...n,upload:"",bytes:t.size,local:URL.createObjectURL(t)}}async function hf(e,t,n){var l;if(!t||n.length===0)return;const r=df(e,t,"image");if(r===0)return;const o=await Promise.allSettled(n.slice(0,r).map(oP));for(const u of o)u.status==="fulfilled"&&uE(e,t,fP(u.value),u.value.blob);const i=o.find(u=>u.status==="rejected");i?co(e,t,String(((l=i.reason)==null?void 0:l.message)??i.reason)):n.length>r&&co(e,t,`kept ${r} of ${n.length}: ${Zm("image")}`)}function hP(e,t,n){n.kind==="image"?hf(e,t,[new File([n.blob],"image.png",{type:n.blob.type})]):Ig(e,t,n.text),X1()}function yE(e,t,n){const r=o=>o.type.startsWith("image/");hf(e,t,n.filter(r)),Ag(e,t,n.filter(o=>!r(o)))}function pP(e,t,{images:n=!1}={}){const r=document.createElement("input");r.type="file",r.multiple=!0,n&&(r.accept="image/*"),r.onchange=()=>yE(e,t,Array.from(r.files??[])),r.click()}function xc(e){const t=e.getState();return wc(rn(t,t.activeId))}function mP(e,t){const n=xc(e);yE(e,n,t.filter(o=>!o.folder).map(o=>o.file));const r=t.find(o=>o.folder);n&&r&&co(e,n,`${r.file.name}: a folder cannot be attached; drop its files`)}const lm=Promise.resolve(null);function gP(e){var n,r,o;if(!e)return[];const t=[];for(const i of Array.from(e.items)){if(i.kind!=="file")continue;const l=i.getAsFile();if(!l)continue;const u=((n=i.getAsFileSystemHandle)==null?void 0:n.call(i).then(c=>(c==null?void 0:c.kind)==="file"?c:null,()=>null))??lm;t.push({file:l,handle:u,folder:((o=(r=i.webkitGetAsEntry)==null?void 0:r.call(i))==null?void 0:o.isDirectory)===!0})}if(t.length===0)for(const i of Array.from(e.files))t.push({file:i,handle:lm});return t}const kP=e=>e.map(t=>({file:t,handle:lm}));async function wE(e){const t=gd*4;if(e.size>t)return{text:"",tooLarge:!0};const n=await nP(e,t);return n===null?null:n.length>gd?{text:"",tooLarge:!0}:{text:n,tooLarge:!1}}async function yP(e,t){const n=xc(e),r=e.getState().activeId,o=p=>n&&co(e,n,p),i=t.filter(p=>p.file.type.startsWith("image/")).map(p=>p.file);i.length&&hf(e,n,i);const l=t.filter(p=>!p.file.type.startsWith("image/")),u=l[0];if(!u||!r)return;const c=await wE(u.file);if(!c)return void o(`${u.file.name}: not a text file`);const h=await u.handle;e.dispatch({a:"open-loose",v:{worktreeId:r,name:u.file.name,...c,binary:!1,source:h?{kind:"handle",handle:h}:{kind:"bytes"},seq:Po()}}),l.length>1&&o(`opened ${u.file.name}; one file opens at a time`)}async function wP(e,t,n,r){const o=ff(e.getState(),n.worktreeId)??xc(e),i=u=>o&&co(e,o,u),l={sock:t,dispatch:u=>e.dispatch(u)};for(const{file:u}of r){const c=await wE(u);if(!c){i(`${u.name}: not a text file`);continue}if(c.tooLarge){i(`${u.name}: too large to add here`);continue}const h=n.dir?`${n.dir}/${u.name}`:u.name,p=await aE(l,{worktreeId:n.worktreeId,path:h},c.text);p&&i(`${u.name}: ${p}`)}}function vP(e){const t=xc(e);t&&co(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 vE(e,t,n,r){const o=(Jo==null?void 0:Jo.refused)??!1;Mg(e),!(o||r.length===0)&&(n?n.at==="chat"?mP(e,r):n.at==="centre"?yP(e,r):wP(e,t,n,r):vP(e))}const h0=e=>!!e&&Array.from(e.types).includes("Files");function p0(e,t){var i;const n=t instanceof Element?t:t instanceof Node?t.parentElement:null;if(!n)return null;if((i=Vl.el)!=null&&i.contains(n))return xc(e)?{at:"chat"}:null;const r=n.closest(".tree"),o=r==null?void 0:r.dataset.worktree;if(r&&o){const l=n.closest("[data-path]"),u=l==null?void 0:l.dataset.kind;if(u==="submodule")return null;const c=(l==null?void 0:l.dataset.path)??"";return{at:"tree",worktreeId:o,dir:u==="file"?hE(c):c}}return!n.closest(".center-root")||n.closest('[data-pane="terminal"], [data-pane="design"]')?null:e.getState().activeId?{at:"centre"}:null}function bP(){const e=Kn(),t=st();S.useEffect(()=>{const n=l=>{l.defaultPrevented||!h0(l.dataTransfer)||(l.preventDefault(),Og(e,p0(e,l.target)),l.dataTransfer&&(l.dataTransfer.dropEffect=e.getState().dragFiles?"copy":"none"))},r=l=>{l.defaultPrevented||!h0(l.dataTransfer)||(l.preventDefault(),vE(e,t,p0(e,l.target),gP(l.dataTransfer)))},o=()=>aP(e),i=l=>{l.key==="Escape"&&lP(e)};return window.addEventListener("dragover",n),window.addEventListener("drop",r),window.addEventListener("dragleave",o),window.addEventListener("keydown",i,!0),()=>{window.removeEventListener("dragover",n),window.removeEventListener("drop",r),window.removeEventListener("dragleave",o),window.removeEventListener("keydown",i,!0)}},[e,t])}function xP(e,t){const n=Kn(),r=S.useRef(!1);return{onPaste:u=>{vL();const c=eP(u.clipboardData);if(c.length>0)return u.preventDefault(),void hf(n,e,c);const h=tP(u.clipboardData);if(h.length>0)return u.preventDefault(),Ag(n,e,h);if(r.current)return;const p=u.clipboardData.getData("text/plain"),g=p.trim()?EL(u.clipboardData,t):null;!(g&&p.includes(`
|
|
103
|
+
`))&&!Xx(p)||(u.preventDefault(),Ig(n,e,p,g?{source:g}:{}))},onPasteKey:u=>{r.current=(u.metaKey||u.ctrlKey)&&u.shiftKey&&u.key.toLowerCase()==="v"},onPasteKeyUp:()=>{r.current=!1}}}const bE=(e,t)=>`${e}${e.includes("?")?"&":"?"}${Cj}=${encodeURIComponent(t)}`,cm=(e,t)=>!e.serving&&t!==null,EP=3e3;function xE(e,t,n){const[r,o]=S.useState(()=>new Map),i=S.useRef(new Set),l=S.useRef(t);l.current=t;const u=S.useRef(new Map),c=S.useCallback((h,p)=>{i.current.has(h)||(i.current.add(h),f1(e.sock.urls).then(g=>{if(i.current.delete(h),!!l.current.some(y=>y.id===h&&y.url===p)){if(!g){u.current.set(h,setTimeout(()=>{u.current.delete(h),l.current.some(y=>y.id===h&&y.url===p)&&c(h,p)},EP));return}o(y=>new Map(y).set(h,{url:p,src:bE(p,g.code)}))}}))},[e]);return S.useEffect(()=>{const h=u.current;return()=>{for(const p of h.values())clearTimeout(p);h.clear()}},[]),S.useEffect(()=>{var p;if(!n)return;for(const g of t)((p=r.get(g.id))==null?void 0:p.url)!==g.url&&c(g.id,g.url);const h=new Set(t.map(g=>g.id));[...r.keys()].some(g=>!h.has(g))&&o(g=>new Map([...g].filter(([m])=>h.has(m))))},[n,t,r,c]),{urlOf:h=>{var p,g;return n?((p=r.get(h))==null?void 0:p.src)??null:((g=t.find(m=>m.id===h))==null?void 0:g.url)??null},renew:h=>{const p=t.find(g=>g.id===h);!p||!n||(o(g=>{const m=new Map(g);return m.delete(h),m}),c(h,p.url))}}}function _P(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}]),xE(e,r.current,n).urlOf("one")}function SP(e,t,n){if(!n){window.open(t,"_blank");return}const r=window.open("","_blank");f1(e.sock.urls).then(o=>{const i=o?bE(t,o.code):t;r?r.location.href=i:window.open(i,"_blank")})}function Be(...e){return e.filter(Boolean).join(" ")}const NP={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",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",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.5 8h3.3 M5.8 8c2.2 0 2.2-3.6 4.4-3.6h1.5 M5.8 8c2.2 0 2.2 3.6 4.4 3.6h1.5 M12.05 4.4a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M12.05 11.6a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z",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.8 2.95a1.05 1.05 0 1 0 0 2.1 1.05 1.05 0 1 0 0-2.1z M7.4 4h5.4 M3.8 6.95a1.05 1.05 0 1 0 0 2.1 1.05 1.05 0 1 0 0-2.1z M7.4 8h5.4 M3.8 10.95a1.05 1.05 0 1 0 0 2.1 1.05 1.05 0 1 0 0-2.1z 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",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",dot:"M8 4.6a3.4 3.4 0 1 0 0 6.8 3.4 3.4 0 1 0 0-6.8z"};function St({name:e,className:t}){return f.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:f.jsx("path",{d:NP[e]})})}function Ba({size:e="inline",variant:t="ring",className:n}){return f.jsx("span",{className:Be("spinner",e==="dot"&&"spinner-dot",t==="squares"&&"spinner-squares",n),"aria-hidden":"true",children:t==="squares"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{}),f.jsx("span",{}),f.jsx("span",{}),f.jsx("span",{})]})})}const TP='button, a[href], input, textarea, select, summary, label, [role="button"], [role="menuitem"]';function m0(e){var n;const t=e;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,TP))??t??null}function jP(e,t){var r,o,i;if(e.box.contains(t)||(r=e.trigger)!=null&&r.contains(t))return!0;const n=(i=(o=t.closest)==null?void 0:o.call(t,"[aria-controls]"))==null?void 0:i.getAttribute("aria-controls");return!!n&&n===e.box.id}function CP(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 AP(e,t){const n=new Set;for(const r of e)if(jP(r,t))for(let o=r;o;o=o.parent)n.add(o);return e.filter(r=>!n.has(r)&&r.dismiss).reverse()}const IP=e=>{setTimeout(e,0)};function RP({schedule:e=IP}={}){let t=[],n=null,r=!1;const o=new Set,i=()=>{for(const u of[...o])u()},l=u=>{var c;for(const h of[...t].reverse())(c=h.dismiss)==null||c.call(h,u)};return{register(u){const c=u.trigger??(u.from===void 0?n:null),h={box:u.box,trigger:c,parent:CP(t,u.from??c),dismiss:u.dismiss,onKey:u.onKey,back:u.back};return t=[...t,h],i(),h},unregister(u){t=t.filter(c=>c!==u),i()},top:()=>t[t.length-1]??null,open:()=>t,watch(u){return o.add(u),()=>o.delete(u)},shut(u){var c;u.back?u.back():(c=u.dismiss)==null||c.call(u,"outside")},install(u){const c=u.document,h=b=>{var j;const E=b.target,N=E?AP(t,E):[];for(const T of N)(j=T.dismiss)==null||j.call(T,"outside");r=N.length>0&&b.pointerType==="touch",r&&b.preventDefault(),n=m0(b.target)},p=()=>e(()=>n=null),g=()=>{r=!1,p()},m=b=>{if(r){r=!1,b.preventDefault(),b.stopPropagation();return}n||(n=m0(b.target),p())},y=b=>{var N;const E=t[t.length-1];(N=E==null?void 0:E.onKey)==null||N.call(E,b)},w=()=>e(()=>{var b;((b=c.activeElement)==null?void 0:b.tagName)==="IFRAME"&&l("frame")});return c.addEventListener("pointerdown",h,!0),c.addEventListener("pointerup",p,!0),c.addEventListener("pointercancel",g,!0),c.addEventListener("click",m,!0),u.addEventListener("keydown",y,!0),u.addEventListener("blur",w),()=>{c.removeEventListener("pointerdown",h,!0),c.removeEventListener("pointerup",p,!0),c.removeEventListener("pointercancel",g,!0),c.removeEventListener("click",m,!0),u.removeEventListener("keydown",y,!0),u.removeEventListener("blur",w)}}}}const Ed=RP(),mp=typeof HTMLElement<"u"&&"showPopover"in HTMLElement.prototype,g0=e=>(e==null?void 0:e.getBoundingClientRect())??null;function $P(e,t,n,r){const o=e.querySelector(t);if(!o)return null;const i=e.getBoundingClientRect(),l=o.getBoundingClientRect();return{offset:n==="top"?i.bottom-l.bottom:l.top-i.top,alignOffset:r==="end"?i.right-l.right:l.left-i.left}}function Ns({className:e,anchor:t,placement:n,coverBy:r,track:o=t==="parent",raiseKey:i,onDismiss:l,onKey:u,onBack:c,trigger:h,from:p,boxRef:g,handle:m,children:y,...w}){const b=S.useRef(null),E=S.useRef({anchor:t,placement:n,coverBy:r,onDismiss:l,onKey:u,onBack:c,trigger:h,from:p});E.current={anchor:t,placement:n,coverBy:r,onDismiss:l,onKey:u,onBack:c,trigger:h,from:p};const N=S.useCallback(()=>{const T=b.current,{anchor:O,placement:U,coverBy:Q}=E.current;if(!T||!O||!U)return;const R=O==="parent"?g0(T.parentElement):O();if(!R)return;const I=_L(R,U);I!==void 0&&(T.style.width=`${I}px`);for(let _=0;_<2;_++){const L=Q?$P(T,Q,T.dataset.side??"",T.dataset.align??""):null,z=NL(R,{w:T.offsetWidth,h:T.offsetHeight},{w:window.innerWidth,h:window.innerHeight},L?{...U,...L}:U);T.style.left=`${z.x}px`,T.style.top=`${z.y}px`;const F=T.dataset.side!==z.side||T.dataset.align!==z.align;if(T.dataset.side=z.side,T.dataset.align=z.align,!F)break}},[]);S.useImperativeHandle(m,()=>({update:N}),[N]),S.useLayoutEffect(()=>{const T=b.current;if(!T)return;g&&(g.current=T),mp&&(T.popover="manual",T.matches(":popover-open")||T.showPopover());const{onDismiss:O,onKey:U,onBack:Q,trigger:R,from:I}=E.current,_=O||U?Ed.register({box:T,trigger:R,from:I,dismiss:O?L=>{var z,F;return(F=(z=E.current).onDismiss)==null?void 0:F.call(z,L)}:void 0,onKey:U?L=>{var z,F;return(F=(z=E.current).onKey)==null?void 0:F.call(z,L)}:void 0,back:Q?()=>{var L,z;return(z=(L=E.current).onBack)==null?void 0:z.call(L)}:void 0}):null;return()=>{_&&Ed.unregister(_),g&&(g.current=null),mp&&T.isConnected&&T.matches(":popover-open")&&T.hidePopover()}},[g]),S.useLayoutEffect(N),S.useLayoutEffect(()=>{if(!o)return;let T=0,O="";const U=()=>{const Q=b.current,{anchor:R}=E.current,I=Q&&R?R==="parent"?g0(Q.parentElement):R():null;if(Q&&I){const _=`${I.left},${I.top},${I.right},${I.bottom},${Q.offsetWidth},${Q.offsetHeight},${window.innerWidth},${window.innerHeight}`;_!==O&&(O=_,N())}T=requestAnimationFrame(U)};return T=requestAnimationFrame(U),()=>cancelAnimationFrame(T)},[o,N]);const j=S.useRef(!0);return yt([i],()=>{if(j.current){j.current=!1;return}const T=b.current;!mp||!(T!=null&&T.matches(":popover-open"))||(T.hidePopover(),T.showPopover(),N())}),f.jsx("div",{ref:b,className:Be("float",e),...w,children:y})}const OP=/^[⌘⇧⌥⌃]+/;function zo({k:e,chip:t=!1,className:n}){var l;const r=(l=e.match(OP))==null?void 0:l[0],o=r?e.slice(r.length):e,i=["kbd",t?"kbd-chip":"",n??""].filter(Boolean).join(" ");return f.jsxs("kbd",{className:i,children:[r&&f.jsx("span",{className:"kbd-mod",children:r}),o]})}function Ft(e,t,{placement:n,detail:r,card:o,dot:i,name:l,aside:u,also:c}={}){const h=l?`${e}: ${l}`:e,p=(Array.isArray(r)?r:[r]).filter(m=>!!m),g=[h,...p,...u??[]].join(", ");return{"data-tip":e,"data-tip-key":t,"data-tip-placement":n,"data-tip-detail":p.length?p.join(`
|
|
104
|
+
`):void 0,"data-tip-card":o||l||u!=null&&u.length?"":void 0,"data-tip-dot":i,"data-tip-name":l,"data-tip-aside":u!=null&&u.length?u.join(`
|
|
105
|
+
`):void 0,"data-tip-also":c==null?void 0:c.text,"data-tip-also-key":c==null?void 0:c.key,"aria-label":t?`${g} (${t})`:g}}const MP=120,LP=600,PP=150,k0=6,DP=18,gp=8;function y0(e){const t=e.dataset.tipPlacement;return t==="follow"||t==="top"||t==="bottom"||t==="left"||t==="right"?t:"bottom"}function zP(e){return e==="follow"?{side:"bottom",align:"start",offset:DP,alignOffset:-12,flip:"both",margin:gp}:e==="left"||e==="right"?{side:e,align:"start",offset:k0,flip:"both",margin:gp}:{side:e,align:"center",offset:k0,flip:"side",margin:gp}}function FP(e,t){return e.placement==="follow"?eE(t):e.el.getBoundingClientRect()}function EE(){var c;const[e,t]=S.useState(null),n=S.useRef(null),r=S.useRef(null),o=S.useRef({x:0,y:0}),i=Wi();if(S.useEffect(()=>{if(i)return;let h=0,p=0,g=null,m=!1,y=0;const w=()=>{window.clearTimeout(h),window.clearTimeout(p)},b=()=>{w(),m&&(y=Date.now()),m=!1,g=null,t(null)},E=(I,_)=>{var z,F;const L=I.dataset.tip;if(!L)return b();w(),m=!0,t({el:I,text:L,key:I.dataset.tipKey,detail:(z=I.dataset.tipDetail)==null?void 0:z.split(`
|
|
106
|
+
`),card:I.dataset.tipCard!==void 0,dot:I.dataset.tipDot,name:I.dataset.tipName,aside:(F=I.dataset.tipAside)==null?void 0:F.split(`
|
|
107
|
+
`),also:I.dataset.tipAlso&&I.dataset.tipAlsoKey?{text:I.dataset.tipAlso,key:I.dataset.tipAlsoKey}:void 0,placement:_})},N=I=>{const _=I.target;return _ instanceof Element?_.closest("[data-tip]"):null},j=I=>{o.current={x:I.clientX,y:I.clientY};const _=N(I);if(_===g)return;if(w(),g=_,!_){m&&(p=window.setTimeout(b,PP));return}const L=y0(_);if(m||Date.now()-y<LP)return E(_,L);h=window.setTimeout(()=>E(_,L),MP)},T=I=>{I.relatedTarget||b()},O=I=>{const _=N(I);if(_!=null&&_.matches(":focus-visible")){w(),g=_;const L=y0(_);E(_,L==="follow"?"bottom":L)}},U=()=>b(),Q=I=>{I.key!=="Shift"&&I.key!=="Control"&&I.key!=="Alt"&&I.key!=="Meta"&&b()},R=I=>{g&&I.target instanceof Node&&I.target.contains(g)&&b()};return document.addEventListener("mouseover",j),document.addEventListener("mouseout",T),document.addEventListener("mousedown",b),document.addEventListener("keydown",Q),document.addEventListener("scroll",R,!0),document.addEventListener("focusin",O),document.addEventListener("focusout",U),window.addEventListener("blur",b),()=>{w(),document.removeEventListener("mouseover",j),document.removeEventListener("mouseout",T),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",Q),document.removeEventListener("scroll",R,!0),document.removeEventListener("focusin",O),document.removeEventListener("focusout",U),window.removeEventListener("blur",b)}},[i]),S.useLayoutEffect(()=>{e&&!e.el.isConnected&&t(null)},[e]),S.useEffect(()=>{if((e==null?void 0:e.placement)!=="follow")return;const h=p=>{var g;o.current={x:p.clientX,y:p.clientY},(g=r.current)==null||g.update()};return document.addEventListener("mousemove",h),()=>document.removeEventListener("mousemove",h)},[e]),!e)return null;const l=f.jsxs(f.Fragment,{children:[e.dot==="spinner"?f.jsx(Ba,{size:"dot",className:"tooltip-dot"}):e.dot&&f.jsx("span",{className:`dot ${e.dot} tooltip-dot`}),e.text]}),u=f.jsxs(f.Fragment,{children:[l,e.key&&f.jsx(zo,{k:e.key,className:"tooltip-key"})]});return f.jsxs(Ns,{className:Be("tooltip",e.card&&"tooltip-card"),role:"tooltip",boxRef:n,handle:r,anchor:()=>FP(e,o.current),placement:zP(e.placement),track:!1,raiseKey:e,children:[e.also?f.jsxs("div",{className:"tooltip-pair",children:[f.jsx("span",{children:l}),e.key?f.jsx(zo,{k:e.key,className:"tooltip-key"}):f.jsx("span",{}),f.jsx("span",{className:"tooltip-also",children:e.also.text}),f.jsx(zo,{k:e.also.key,className:"tooltip-key"})]}):e.name?f.jsxs("div",{className:"tooltip-head",children:[f.jsx("span",{children:u}),f.jsx("span",{className:"tooltip-name",children:e.name})]}):u,(c=e.detail)==null?void 0:c.map(h=>f.jsx("div",{className:"tooltip-detail",children:h},h)),e.aside&&f.jsx("div",{className:"tooltip-foot",children:e.aside.map(h=>f.jsx("span",{children:h},h))})]})}const BP={sm:"",md:"btn-md",lg:"btn-lg"},UP={ghost:"",outline:"btn-outline",field:"btn-outline btn-field",inline:"btn-inline"},_E={primary:"tone-primary",quiet:"tone-quiet",danger:"tone-danger",strong:"tone-strong",chrome:"tone-chrome"};function Pe({variant:e="ghost",size:t="sm",tone:n,on:r,mono:o,busy:i,className:l,type:u="button",disabled:c,children:h,...p}){const g=Be("btn",UP[e],BP[t],n&&_E[n],r&&"on",o&&"btn-mono",i&&"btn-busy",l);return f.jsxs("button",{className:g,type:u,disabled:i||c,"aria-busy":i||void 0,...p,children:[i&&f.jsx(Ba,{}),h]})}function Lt({icon:e,label:t,hint:n,detail:r,also:o,silent:i,badge:l,tone:u,on:c,className:h,type:p="button",...g}){const m=Be("btn-icon",u&&_E[u],c&&"on",h),y=Ft(t,n,{detail:r,also:o});return f.jsxs("button",{className:m,type:p,...i?{"aria-label":y["aria-label"]}:y,...g,children:[typeof e=="string"?f.jsx(St,{name:e}):e,l]})}function Ec(e,t,n){return n===0?0:(e+t+n)%n}function w0(e,t,n){return e>=0?Ec(e,t,n):n===0?-1:t>0?0:n-1}function SE(e,t,n){var i;const r=e.length,o=n.toLowerCase();for(let l=1;l<=r;l++){const u=(Math.max(t,-1)+l)%r;if((i=e[u])!=null&&i.trim().toLowerCase().startsWith(o))return u}return-1}function kp(e,t){return e&&e.length>t.length&&e.toLowerCase().startsWith(t.toLowerCase())?e.slice(t.length):null}function HP(e,t){if(e==null)return null;if(typeof e=="string"){const o=kp(e,t);return o?{text:o,accept:o,params:[]}:null}const n=kp(e.show,t);if(!n)return null;const r=(e.params??[]).map(([o,i])=>[Math.max(o,t.length)-t.length,i-t.length]).filter(([o,i])=>i>o);return{text:n,accept:kp(e.accept,t),params:r}}function NE(e){const{results:t,keyOf:n,q:r,onPick:o,listRef:i,onActive:l,onSide:u,completionOf:c,narrowTo:h,setQ:p,tabPicks:g,onIdlePick:m}=e,[y,w]=S.useState(()=>{var Q;return e.idle?-1:Math.max(0,((Q=e.initialIndex)==null?void 0:Q.call(e,t))??0)}),b=y>=0&&t[y]?n(t[y]):null,E=S.useRef(l);E.current=l,yt([b],()=>{var Q,R,I;(R=(Q=i.current)==null?void 0:Q.querySelector('.picker-item[data-state~="cursor"]'))==null||R.scrollIntoView({block:"nearest"}),(I=E.current)==null||I.call(E,y>=0?t[y]??null:null)});const N=y<0?-1:Math.min(y,Math.max(0,t.length-1)),j=N>=0?t[N]??null:null,T=j?HP(c==null?void 0:c(j,r),r):null,O=Q=>{const R=h==null?void 0:h(Q,r);if(R==null)return o(Q,r);p==null||p(R),w(0)};return{index:N,active:j,ghost:T,setIndex:w,pick:O,onKeyDown:Q=>{if(Q.key==="ArrowDown")Q.preventDefault(),w(w0(N,1,t.length));else if(Q.key==="ArrowUp")Q.preventDefault(),w(w0(N,-1,t.length));else if((Q.key==="ArrowLeft"||Q.key==="ArrowRight")&&u&&j)Q.preventDefault(),u(j,Q.key==="ArrowLeft"?-1:1);else if(Q.key==="Tab"&&(T!=null&&T.accept))Q.preventDefault(),p==null||p(r+T.accept),w(0);else if(Q.key==="Tab"&&g&&j)Q.preventDefault(),O(j);else if(Q.key==="Enter"&&j)Q.preventDefault(),O(j);else if(Q.key==="Enter"&&N<0&&m)Q.preventDefault(),m(r);else return!1;return!0}}}function pr(e){const t=Object.keys(e).filter(n=>e[n]);return t.length>0?t.join(" "):void 0}const WP=new Set(["Shift","Meta","Control","Alt","CapsLock","Fn"]);function TE(){const e=nE(),t=Kn();return S.useEffect(()=>{if(!e)return;const n=()=>{e.target.isConnected||Gr.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?f.jsx(KP,{spec:e},e.id):null}function KP({spec:e}){const t=e.items,n=t.filter(Es),[r,o]=S.useState(-1),i=S.useRef({idx:r,items:n});i.current={idx:r,items:n};const l=S.useRef(null),u=g=>{var m,y;{const w=()=>Gr.close(),{idx:b,items:E}=i.current;if(WP.has(g.key))return;if(g.key==="ArrowDown"||g.key==="ArrowUp"){g.preventDefault(),g.stopPropagation();const N=g.key==="ArrowDown"?1:-1;o(TL(E,b,N));return}if((g.key==="Enter"||g.key===" ")&&b>=0&&E[b]&&!E[b].disabled){g.preventDefault(),g.stopPropagation(),E[b].onClick(),w();return}if(g.key==="Escape"){g.stopPropagation(),w();return}if(g.key.length===1&&!g.metaKey&&!g.ctrlKey&&!g.altKey){g.preventDefault(),g.stopPropagation();const N=Array.from(((m=l.current)==null?void 0:m.querySelectorAll(".menu-label"))??[],T=>T.textContent??""),j=SE(N,b,g.key);j>=0&&!((y=E[j])!=null&&y.disabled)&&o(j);return}w()}};S.useEffect(()=>{const g=()=>Gr.close();return window.addEventListener("blur",g),window.addEventListener("resize",g),document.addEventListener("scroll",g,!0),()=>{window.removeEventListener("blur",g),window.removeEventListener("resize",g),document.removeEventListener("scroll",g,!0)}},[]);const{rect:c,placement:h}=AL(e),p=n.some(g=>g.checked);return f.jsx(Ns,{className:"menu",role:"menu",boxRef:l,anchor:()=>c,placement:h,track:!1,from:e.target,trigger:e.toggles?e.target:null,onDismiss:()=>Gr.close(),onKey:u,onContextMenu:g=>g.preventDefault(),children:t.map((g,m)=>{if(!Es(g))return f.jsx("hr",{className:"menu-sep"},`sep-${m}`);const y=n.indexOf(g);return f.jsx(ZP,{item:g,gutter:p,cursor:y===r,onEnter:()=>o(y)},g.id)})})}function ZP({item:e,gutter:t,cursor:n,onEnter:r}){const o=e.disabled!==void 0,i=e.detail??e.disabled;return f.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",i!==void 0&&"row-tall",o&&"disabled"),"data-state":pr({cursor:n,checked:e.checked}),onMouseMove:o||n?void 0:r,onClick:()=>{o||(e.onClick(),Gr.close())},children:[t&&f.jsx("span",{className:"menu-check",children:e.checked&&f.jsx(St,{name:"check",className:"icon-inline"})}),f.jsxs("span",{className:"menu-text",children:[f.jsx("span",{className:"menu-label",children:e.label}),i!==void 0&&f.jsx("span",{className:"menu-detail row-dim",children:i})]}),e.key&&f.jsx(zo,{k:e.key,className:"menu-key row-dim"})]})}function pf({items:e,current:t,onPick:n,fill:r,font:o,segmented:i,quiet:l,end:u,label:c,owner:h}){const p=on(h),g=S.useRef(null),m=Math.max(0,e.findIndex(w=>w.id===t)),y=w=>{var N,j;if(w.key!=="ArrowLeft"&&w.key!=="ArrowRight")return;w.preventDefault();const b=e.findIndex(T=>T.id===t),E=e[Ec(b,w.key==="ArrowRight"?1:-1,e.length)];E&&(n(E.id),(j=(N=g.current)==null?void 0:N.querySelectorAll('[role="tab"]')[e.indexOf(E)])==null||j.focus())};return f.jsxs("div",{className:Be("tabs",r&&"tabs-fill",o==="mono"&&"tabs-mono",i&&"tabs-segmented",l&&"tabs-quiet"),children:[f.jsx("div",{className:"tabs-list",role:"tablist","aria-label":c,ref:g,onKeyDown:y,style:i?{"--tabs-at":m,"--tabs-count":e.length}:void 0,children:e.map(w=>{const b=w.id===t;return f.jsxs("div",{className:Be("tab",b&&!!w.trail&&"tab-trailed",w.fit&&"tab-fit",w.far&&"tab-far"),"data-state":pr({current:b}),...w.menu?p.contextMenu(w.menu):{},children:[f.jsxs("button",{type:"button",className:"tab-btn",role:"tab","aria-selected":b,tabIndex:b?0:-1,onClick:()=>n(w.id),...w.tip,...w.ariaLabel?{"aria-label":w.ariaLabel}:{},children:[w.lead,w.label]}),b&&w.trail&&f.jsx("span",{className:"tab-trail",children:w.trail})]},w.id)})}),u&&f.jsx("span",{className:"tabs-end",children:u})]})}function li({anchor:e="top",wide:t,children:n}){return f.jsx("div",{className:Be("view",e==="line"&&"view-anchored",t&&"view-wide"),children:n})}const jE=e=>`Toyon restarts once ${e.join(", ")} ${e.length===1?"finishes":"finish"}`,qP=(e,t)=>[...e,...t.filter(n=>!e.includes(n))];function GP(e,t,n){const r=[...t];return[...e.map(i=>{const l=r.indexOf(i);return l===-1?{name:i,dot:"idle",note:"finished"}:(r.splice(l,1),{name:i,dot:"working",note:null})}),...n.map(i=>({name:i,dot:"waiting",note:"asking you"}))]}function VP(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 YP(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:jE(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 um=!1;function QP(){um=!0}function ic({title:e,body:t,action:n,pane:r,children:o}){return f.jsxs("div",{className:Be("crash",r&&"in-pane"),children:[f.jsx("div",{className:"crash-title",children:e}),t&&f.jsx("div",{className:"crash-body",children:t}),o,n]})}const v0={title:"Toyon was updated",body:"This page is still running the old build. Reload to pick up the new one."};class Lg extends S.Component{constructor(){super(...arguments);jt(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?f.jsx(ic,{pane:this.props.pane,title:um?v0.title:"Toyon hit an error",body:um?v0.body:n.message||String(n),action:f.jsx(Pe,{variant:"outline",onClick:()=>window.location.reload(),children:"reload"})}):this.props.children}}const dm={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.`},XP=1e3,b0={held:[],asking:[],seen:[]};async function x0(e,t,n){for(;;){await new Promise(i=>setTimeout(i,XP));const[r,o]=await Promise.all([Xp(e),d1(e)]);if(r!==null&&r!==t)break;n(o??{waiting:[],asking:[]})}window.location.reload()}function CE({foreign:e}={}){return e?f.jsx(JP,{name:e}):f.jsx(e4,{})}function JP({name:e}){const t=_o(),n=t.list()[0];return f.jsx(ic,{title:`Toyon on ${e} was updated`,body:dm.foreign(e),action:n&&f.jsxs(Pe,{variant:"outline",onClick:()=>t.activate(n.origin),children:["back to ",t.displayName(n.origin)]})})}function e4(){const e=Lr(),[t,n]=S.useState(!0),[r,o]=S.useState(null),[i,l]=S.useState(b0),u=S.useRef(null),c=S.useCallback(m=>l(y=>({held:m.waiting,asking:m.asking,seen:qP(y.seen,m.waiting)})),[]),h=S.useCallback(async m=>{n(!0),o(null);const y=u.current??{pid:await Xp(e)},w=await A2(e,m);if(w){n(u.current!==null),o(w);return}m&&l(b0),!u.current&&(u.current=y,x0(e,y.pid,c))},[c,e]);S.useEffect(()=>{let m=!0;return(async()=>{const[y,w]=await Promise.all([Xp(e),d1(e)]);if(!(!m||u.current)){if(w===null){h(!1);return}u.current={pid:y},c(w),x0(e,y,c)}})(),()=>{m=!1}},[c,h,e]);const p=t&&i.held.length>0,g=p?GP(i.seen,i.held,i.asking):[];return f.jsx(ic,{title:dm.title,body:r??(p?VP(i.held.length,i.seen.length):dm.waiting),action:p?f.jsx(Pe,{variant:"outline",onClick:()=>void h(!0),children:"restart now"}):f.jsx(Pe,{variant:"outline",busy:t,onClick:()=>void h(!1),children:"restart"}),children:g.length>0&&f.jsx("ul",{className:"crash-list",children:g.map((m,y)=>f.jsxs("li",{className:Be("crash-row",m.dot!=="working"&&"row-dim"),children:[f.jsx("span",{className:Be("dot",m.dot)}),f.jsx("span",{className:"crash-row-name",children:m.name}),m.note&&f.jsx("span",{className:"crash-row-note",children:m.note})]},y))})})}const E0={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"},t4={probing:e=>`connecting to ${e}…`,down:e=>`Toyon on ${e} is not answering.
|
|
108
|
+
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.
|
|
109
|
+
a proxy, VPN or browser extension is the usual cause`,unauthorized:e=>`this page's token for ${e} is not the one running there.
|
|
110
|
+
forget ${e} here and pair it again`},n4="no access token for this address.\non a phone, run `toyon pair` on the machine and scan the code: it works once and lasts 2 minutes.\notherwise run `toyon` in your repo, or open the full URL\n(with #token=…) printed in ~/.toyon/daemon.log";function AE(e){return!e.connected&&(!e.heard||e.connectFailure)?e.machine?t4[e.connectFailure??"probing"](e.machine):e.hasToken?E0[e.connectFailure??"probing"]??E0.probing:n4:e.title===null?e.heard?`nothing open yet.
|
|
111
|
+
press ${e.projectChord} to open a project, or type a name there to start a new one`:"":null}function r4(e){const t=AE(e);return t!==null?t:e.needsSetup&&e.busy?`building in ${e.title}; the preview appears once it starts`:e.needsSetup&&e.treeEmpty?`${e.title} is empty so far; say what to build`:e.treeEmpty&&e.landsFrom?`nothing runs on main until ${e.landsFrom} lands`:null}const Jt={post:(e,t)=>{},broadcast:e=>{}};function ac(e,t,n,r){const o=t===r;Jt.post(e,o?{type:"pick-cancel"}:{type:"pick-start",verb:r}),n({a:"set-picking",v:o?!1:r})}function IE(e){return[{id:"copy-sha",label:`copy ${e.short}`,onClick:()=>Yt(e.sha)},{id:"copy-subject",label:"copy subject",onClick:()=>Yt(e.subject)}]}function mf(e,t,n){var o,i;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 l=t-1;l>=0;l--)if((((i=e[l])==null?void 0:i.depth)??0)<r.depth)return{do:"to",at:l};return null}function gf(e){return e!=null&&e.config.profiles?Object.keys(e.config.profiles):[]}function RE(e,t){const n=gf(t);if(n.length!==0)return e.profile&&n.includes(e.profile)?e.profile:t==null?void 0:t.config.defaultProfile}const o4=e=>cd(Oi((e==null?void 0:e.config)??{}),e==null?void 0:e.defaultBranch).toLowerCase();function ei(e,t,n){t({a:"shipping",id:n.worktreeId,op:n.t}),e==null||e.send(n)}const $E=e=>e.dirty===void 0||e.ahead===void 0||e.dirty>0||e.ahead>0;function Pi(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 OE(e,t,n){t({a:"hold-unread",id:n}),e==null||e.send({t:"mark-unread",worktreeId:n})}function Pg(e,t){return{rename(n){if(!nx(n.worktree))return;const r=window.prompt("Rename worktree (its branch follows as a slug):",n.worktree.title);r!=null&&r.trim()&&(e==null||e.send({t:"rename-worktree",worktreeId:n.worktree.id,title:r.trim()}))},pickVariant(n){const r=n.worktree.variant;if(!r)return;const o=r.of-1;window.confirm(`Keep "${n.worktree.title}" and archive ${o} sibling variant(s)? Their directories and branches go; their chats and changes are kept.`)&&(e==null||e.send({t:"pick-variant",worktreeId:n.worktree.id}))},setProfile(n,r){e==null||e.send({t:"set-worktree-profile",worktreeId:n.worktree.id,profile:r})},ownProcs(n){e==null||e.send({t:"own-procs",worktreeId:n.worktree.id})},shareProcs(n){const r=(n.worktree.owns??[]).join(", ");window.confirm(`Stop this worktree's own ${r} and use main's?
|
|
112
|
+
|
|
113
|
+
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:n.worktree.id}))},archive(n){if(!Km(n.worktree))return;if(!$E(n))return Pi(e,t,[n.worktree.id]);window.confirm(`Archive worktree "${n.worktree.title}"?
|
|
114
|
+
|
|
115
|
+
Its directory and branch (${n.worktree.branch}) go. The chat, the commits and any uncommitted changes are kept, and the project menu can restore it.`)&&Pi(e,t,[n.worktree.id])}}}function ME(e,t,n,{sock:r,dispatch:o},i){var Q,R;const l=e.worktree.id,u=Pg(r,o),c=[],h=[],p=[],g=[],m=[],y=[],w=[],b=[];yc(e)&&c.push({id:"stop",label:"stop agent",onClick:()=>r==null?void 0:r.send({t:"stop-agent",worktreeId:l})});const E=!n.shipping[l],N=n.frame==="phone";((e.dirty??0)>0||(e.ahead??0)>0||!N&&!n.layout.changes)&&h.push({id:"changes",label:`view changes${(e.dirty??0)>0?` (${e.dirty})`:""}`,onClick:()=>{o({a:"activate",id:l}),N?o({a:"screen",to:"changes"}):n.layout.changes||o({a:"toggle-changes"})}}),N||h.push({id:"terminal",label:"open terminal",onClick:()=>{o({a:"activate",id:l}),o({a:"focus-terminal"})}}),h.push(...cf(()=>r==null?void 0:r.send({t:"reveal",worktreeId:l}),i.hostname)),N||p.push({id:"copy-path",label:"copy path",onClick:()=>Yt(e.path)}),p.push({id:"copy-branch",label:"copy branch name",onClick:()=>Yt(e.worktree.branch)});const{transcript:j,sessionId:T}=e;!N&&j&&!Ar(e.worktree)&&p.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>Yt(j)}),!N&&T&&p.push({id:"copy-session",label:"copy session id",onClick:()=>Yt(T)});const O=RE(e.worktree,t);for(const I of gc(e.worktree)?[]:gf(t))g.push({id:`profile:${I}`,label:`run with ${I}`,checked:I===O,onClick:()=>u.setProfile(e,I)});if(!Di(e.worktree)&&((Q=e.borrowed)!=null&&Q.length)&&g.push({id:"own-procs",label:`run ${e.borrowed.join(", ")} here`,detail:"on main now",onClick:()=>u.ownProcs(e)}),!Di(e.worktree)&&((R=e.worktree.owns)!=null&&R.length)&&g.push({id:"share-procs",label:`use main's ${e.worktree.owns.join(", ")}…`,detail:"runs here now",danger:!0,onClick:()=>u.shareProcs(e)}),nx(e.worktree)&&m.push({id:"rename",label:"rename…",onClick:()=>u.rename(e)}),e.worktree.variant&&m.push({id:"keep",label:"keep this variant…",onClick:()=>u.pickVariant(e)}),i.graft&&Ju(e.worktree)){const I=i.graft;m.push({id:"graft",label:"graft with…",onClick:()=>I(l)})}m.push({id:"unread",label:"mark as unread",key:Tt("mark-unread"),disabled:e.unseen?"already unread":void 0,onClick:()=>OE(r,o,l)});const U=E?void 0:"waiting on the one in progress";return Bd(e)&&(e.behind??0)>0&&y.push({id:"sync",label:`sync from main (${e.behind} behind)`,disabled:U,onClick:()=>ei(r,o,{t:"sync-main",worktreeId:l})}),Ri(e.worktree)&&y.push({id:"land",label:"land",detail:o4(t),disabled:U,onClick:()=>ei(r,o,{t:"land",worktreeId:l})}),e.worktree.kind==="worktree"&&w.push({id:"handoff",label:"continue in another project…",sub:!0,disabled:n.repos.length<2?"open another project first":void 0,onClick:()=>o({a:"open",overlay:{kind:"handoff",worktreeId:l}})}),Km(e.worktree)&&b.push({id:"archive",label:$E(e)?"archive…":"archive",key:Tt("wt-archive"),danger:!0,onClick:()=>u.archive(e)}),Mn([c,h,p,g,m,y,w,b])}function s4(e,t,{sock:n,dispatch:r},o){const i=[],l=t.frame==="phone",u=[{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 Bd(e)&&(e.behind??0)>0&&i.push({id:"sync",label:`sync from main (${e.behind} behind)`,onClick:()=>n==null?void 0:n.send({t:"sync-main",worktreeId:e.id})}),l||i.push({id:"shell",label:"open a shell here",onClick:()=>{r({a:"activate",id:e.id}),r({a:"focus-terminal"})}}),i.push(...cf(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id}),o)),Mn([u,i,l?[]:[{id:"copy-path",label:"copy path",onClick:()=>Yt(e.path)}]])}const i4={sm:"",md:"field-md",lg:"field-lg"};function LE({size:e="sm",font:t,bare:n,rule:r,className:o}){const i=t??(e==="lg"?"ui":"mono");return Be("field",i4[e],i==="ui"&&"field-ui",i==="lead"&&"field-lead",n&&"field-bare",r&&"field-rule",o)}const vo=S.forwardRef(function({size:t,font:n,bare:r,rule:o,className:i,...l},u){return f.jsx("input",{ref:u,className:LE({size:t,font:n,bare:r,rule:o,className:i}),...l})}),Ua=S.forwardRef(function({size:t,font:n,bare:r,rule:o,className:i,...l},u){return f.jsx("textarea",{ref:u,className:LE({size:t,font:n,bare:r,rule:o,className:i}),...l})});function a4(e,t){const n=t??0;return n===0?null:`${n} behind ${e}`}function PE(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function DE(e,t){if(t.fetchFailed)return`could not reach origin${t.fetchedAt?` since ${PE(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 l4(e){return e.stale!=="diverged"}const ns=e=>/[.!?]$/.test(e)?e:`${e}.`;function ys(e){const t=`PR #${e.number}`;if(e.state==="merged")return`${t} merged.`;if(e.state==="closed")return`${t} was closed without merging.`;if(e.automerge){const n=e.review==="review_required"?"it is approved and checks pass":"checks pass";return`${t} open; GitHub merges it when ${n}.`}return e.mergeable===!1?`${t} open; it conflicts with main.`:e.review==="changes_requested"?`${t} open; changes requested.`:e.checks==="fail"?`${t} open; checks failed.`:e.checks==="pending"?`${t} open; checks running.`:e.review==="review_required"?`${t} open; waiting on review.`:e.review==="approved"?`${t} approved${e.checks==="pass"?", checks pass":""}.`:`${t} open and ready to merge.`}function zE(e){return e.state==="open"&&!e.automerge&&e.mergeable!==!1&&e.review!=="changes_requested"&&e.review!=="review_required"&&e.checks!=="fail"&&e.checks!=="pending"}const FE=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function Dg(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 BE(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, then write":"Write"} the recap and the commit message.`}function c4(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 Uu(e,t=0,n=!0,r){var o,i;if(e.check==="pending")return"Checking the work…";if(e.check==="fail"){const l=(i=(o=e.checkTail)==null?void 0:o.split(`
|
|
116
|
+
`).find(u=>u.trim()))==null?void 0:i.trim();return`Check failed${l?`: ${ns(l)}`:"."}`}return Dg(e,t,n)==="unasked"?c4(r):null}function _0(e,t){const n=u4(e,t);return n?ns(FE(n)):""}function u4(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 UE=e=>/^[A-Z][a-z]+(\s|$)/.test(e)?`${e.charAt(0).toLowerCase()}${e.slice(1)}`:e;function d4(e,t){const n=t??0;return n>0?`${n} behind ${e}; land takes it in first.`:""}function f4(e){return e>0?ns(FE(`${e} ${e===1?"file":"files"} changed`)):""}function h4(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: ${ns(UE(e.why))}`:null}function Hu(e){return ns(e)}const Yo=e=>e==="now"?"just now":`${e} ago`;function p4(e,t,n){switch(e){case"asking":return`Waiting on you${n==="now"?"":` for ${n}`}${t.ask?`: ${ns(t.ask)}`:"."}`;case"failed":return t.auth?`Stopped ${Yo(n)}: not logged in.`:t.error?`Failed ${Yo(n)}: ${ns(t.error)}`:`Failed ${Yo(n)}.`;case"stopped":return t.planBack?`Sent the plan back ${Yo(n)}. Say what to change.`:`Stopped ${Yo(n)}.`;case"done":return t.cut?`Ended early ${Yo(n)} (${t.cut}).`:`Finished ${Yo(n)}.`}}function zg(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?ns(t):p4(e.end,e.facts,ao(e.at))}function m4(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?`Last stop, ${Yo(ao(e.at))}: ${ns(UE(t))}`:void 0}function lc(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 Fg(e){return(e==null?void 0:e.status)==="running"||(e==null?void 0:e.status)==="detached"}function HE(e){const t=e&&e.status!=="terminated"?e.since:void 0,n=Eg(t,_g);return t!==void 0&&n===t?e:void 0}function WE(e,t){const n=e.stage?[e.stage]:[];switch(e.status){case"queued":return[...n,"queued"];case"running":return[...n,`${Ca(t)} of ${wj(e.timeoutMs)}`];case"detached":return[...n,Ca(t),"detached"];case"terminated":return[e.why??"stopped"]}}function fm(e,t,n){return[e,...WE(t,n)].join(" · ")}const KE={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 ZE(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 g4({active:e,ahead:t,behind:n,unpushed:r,dirty:o}){var Ht,It,nt;const i=st(),l=at(),u=on("changes"),c=On(e)?e.worktree:null,h=e.id,p=M(Ve=>{var mt;return(mt=Ve.shipping[h])==null?void 0:mt.op}),g=M(Ve=>{var mt;return(mt=Ve.shipping[h])==null?void 0:mt.step}),m=Eg(g,_g),y=lc(e,"commit"),w=lc(e,"check"),b=p?y:w,E=HE(b),N=Fa(Fg(E)?E==null?void 0:E.since:void 0),[j,T]=S.useState("");yt([h],()=>T(""));const O=S.useRef(null),U=(Ht=c==null?void 0:c.landing)!=null&&Ht.subject?c.landing.body?`${c.landing.subject}
|
|
117
|
+
|
|
118
|
+
${c.landing.body}`:c.landing.subject:null,Q=()=>{j===""&&U&&T(U);const Ve=O.current;Ve&&(Ve.focus(),requestAnimationFrame(()=>Ve.setSelectionRange(Ve.value.length,Ve.value.length)))},R=M(Ve=>Ve.editCommit);yt([R],()=>{R&&Q()});const I=j.trim()||void 0,_=M(Ve=>{var mt;return!!((mt=Ve.agents.find(En=>En.id===((c==null?void 0:c.agent)??Ve.defaultAgent)))!=null&&mt.quick)}),L=c==null?void 0:c.landing,z=I?null:Dg(L,o?1:0,_),F=(L==null?void 0:L.check)==="pending",ee=!!(L!=null&&L.stale),se=()=>{p||i==null||i.send({t:"judge",worktreeId:h})},fe=()=>{p||!I&&!U||(ei(i,l,{t:"commit",worktreeId:h,message:I??U??""}),T(""))},ke=()=>{p||ei(i,l,{t:"land",worktreeId:h,...I?{message:I}:{}})},ne=((It=c==null?void 0:c.landing)==null?void 0:It.check)==="fail",A=c==null?void 0:c.pr,q=(A==null?void 0:A.state)==="open",ie=q&&(o||r>0),P=F||ee||!!z,W=!!c&&Ri(c)&&(o||t>0)&&!ne&&!q&&!P,xe=!!c&&ie&&!ne&&!P,ce=!!c&&Ri(c)&&!F&&(ee||z==="unwritten"||z==="unanswered")&&e.agent!=="working"&&e.agent!=="waiting",me=M(Ve=>Ve.repos.find(mt=>mt.id===e.repoId)??null),_e=cd(Oi((me==null?void 0:me.config)??{}),me==null?void 0:me.defaultBranch),ae=me?Ud(me):"main",be=Bd(e)?a4(ae,n):null,ze=e.agent==="working"||e.agent==="waiting",re=o?c?ze?"the agent is mid-turn: sync when it is done":void 0:"commit or discard the changes here first":void 0,he=q&&!ie&&zE(A),pe=W?"land":xe?"update":he?"merge":(A==null?void 0:A.state)==="merged"?"pull":"land",Ue=p==="commit"?m??"commit":p==="land"?m?`${pe}: ${m}`:pe:null,ct=b?E?WE(E,N).join(" · "):null:F&&!p?"writing the message":null,We=E&&(E.status==="running"||E.status==="detached")?E:null,xn=We&&f.jsx(Lt,{icon:"stop",tone:"danger",label:ZE(We.kind),onClick:()=>i==null?void 0:i.send({t:"run-stop",worktreeId:h,kind:We.kind})});return f.jsxs("div",{className:"composer commit-box",children:[c&&o&&f.jsx("div",{className:"composer-field",children:f.jsx(Ua,{size:"lg",bare:!0,ref:O,value:j,onChange:Ve=>T(Ve.target.value),onKeyDown:Ve=>{Ve.key==="Enter"&&(Ve.metaKey||Ve.ctrlKey)?(Ve.preventDefault(),fe()):Ve.key==="Tab"&&!Ve.shiftKey&&j===""&&U&&(Ve.preventDefault(),Q())},placeholder:U??(z==="unanswered"?"no message yet: the model did not answer. Check again, or write one here":z==="unasked"?"no message yet: write one here to commit or land":"commit message…")})}),f.jsxs("div",{className:"hint composer-knobs",children:[f.jsxs("span",{className:"commit-where",children:[f.jsx(St,{name:"branch",className:"icon-inline"}),f.jsx("span",{className:"branch-name",children:e.branch??"detached"}),t>0&&f.jsxs("span",{className:"badge-ahead","data-tip":`${t} commit(s) ahead of ${ae}`,children:[t," ahead"]}),(c==null?void 0:c.landed)&&f.jsxs("span",{className:"badge-landed","data-tip":`Merged into ${ae}`,children:[f.jsx(St,{name:"check",className:"icon-inline"})," landed"]})]}),f.jsxs("span",{className:"commit-acts",children:[Ue?f.jsx("span",{className:"live-text",children:Ue}):f.jsxs(f.Fragment,{children:[c&&o&&f.jsx(Pe,{disabled:!I&&!U||!!p,onClick:fe,...Ft(U&&!I?"Commit with the suggested message":"git add -A && git commit","⌘⏎"),children:"commit"}),c&&W&&f.jsx(Pe,{tone:"primary",disabled:!!p,"data-tip":_e,onClick:ke,children:"land"}),ce&&f.jsx(Pe,{tone:"primary",disabled:!!p,"data-tip":BE(L,!!((nt=me==null?void 0:me.config.check)!=null&&nt.trim()),z),onClick:se,children:"check"}),F&&f.jsx("span",{className:"live-text",children:"check"}),xe&&A&&f.jsx(Pe,{tone:"primary",disabled:!!p,"data-tip":`Commit, take ${ae} in and push the branch; PR #${A.number} takes the new commits`,onClick:ke,children:"update"}),he&&f.jsx(Pe,{tone:"primary",disabled:!!p,"data-tip":"Merge the PR now, by the method the repo allows",onClick:ke,children:"merge"})]}),A&&f.jsxs(Pe,{"data-tip":`Open PR #${A.number} on GitHub`,onClick:()=>window.open(A.url,"_blank"),...u.contextMenu(()=>[{id:"open-pr",label:"open on GitHub",onClick:()=>window.open(A.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>Yt(A.url)}]),children:["view ",f.jsx(St,{name:"external",className:"icon-inline"})]})]})]}),(be||ct)&&f.jsxs("div",{className:"composer-notes",children:[ct&&f.jsxs("div",{className:"hint composer-note","data-tip":E?KE[E.status]:void 0,children:[f.jsx("span",{children:ct}),xn]}),be&&f.jsxs("div",{className:"hint composer-note",children:[f.jsx("span",{children:be}),p==="sync-main"?f.jsx("span",{className:"live-text",children:m?`sync: ${m}`:"sync"}):f.jsx(Pe,{variant:"outline",disabled:!!p||!!re,"data-tip":re??`Merge ${ae} into this worktree${o?", uncommitted changes kept":""}`,onClick:()=>ei(i,l,{t:"sync-main",worktreeId:h}),children:"sync"})]})]})]})}const k4=S.memo(function({c:t,id:n,selected:r,onToggle:o}){const i=on("changes");return f.jsxs("button",{className:"row row-sm log-row row-edge",id:n,"data-state":pr({current:r,cursor:r}),role:"option","aria-selected":r,tabIndex:-1,onClick:()=>o(t.sha),...i.contextMenu(()=>IE(t)),"data-tip":`${t.subject}
|
|
119
|
+
${t.short} · ${t.author}`,"data-tip-placement":"follow",children:[f.jsx("span",{className:"subject",children:t.subject}),f.jsx("span",{className:"at row-dim",children:ao(t.at)})]})});function y4(e,t){const n=es(e,t);if(!n||!On(n))return"take this worktree over to change files here";if(Di(n.worktree))return"start a worktree to change files"}function qE(e,t,n,r){return{id:"new-file",label:"new file…",disabled:y4(e.getState(),t),onClick:()=>r(n)}}function w4(e,t,n,r){const{worktreeId:o,dir:i,path:l,folder:u,newIn:c}=e,h=ff(t.getState(),o)?void 0:"take this worktree over to talk to an agent here",p=Rg(l,u),g=[...u?[]:[{id:"open",label:"open",onClick:()=>nr(n,{worktreeId:o,path:l,view:Fi(l)})}],{id:"add-to-chat",label:"add to chat",disabled:h,onClick:()=>fE(t,o,l,u)}],m=[qE(t,o,c,r),{id:"ask-rename",label:"ask the agent to rename…",disabled:h,onClick:()=>c0(t,o,`Rename ${p} to `)},{id:"ask-delete",label:"ask the agent to delete…",disabled:h,onClick:()=>c0(t,o,`Delete ${p} and update whatever still uses it`)}],y=[...cf(()=>{var w;return(w=n.sock)==null?void 0:w.send({t:"reveal",worktreeId:o,path:l})},ts(n.sock)),{id:"copy-path",label:"copy path",onClick:()=>Yt(`${i}/${l}`)},{id:"copy-relative-path",label:"copy relative path",onClick:()=>Yt(l)}];return Mn([g,y,m])}function v4(e,t,n,r){return Mn([[qE(t,e.worktreeId,"",r)],Bi(e.dir,()=>{var o;return(o=n.sock)==null?void 0:o.send({t:"reveal",worktreeId:e.worktreeId})},ts(n.sock))])}const Wu=[],b4=[],S0=new Set,N0=e=>`tree-row-${e}`;function x4({worktreeId:e,dir:t,openPath:n,openRef:r,rootRef:o}){const i=Kn(),l=st(),u=at(),c=At(e,"files"),h=At(e,"submodules"),p=At(e,"ignored"),g=At(e,"git"),m=(g==null?void 0:g.files)??b4;yt([e,g,l],()=>uf(e,i.getState(),{sock:l,dispatch:u}));const y=M(re=>{var he;return((he=re.dragFiles)==null?void 0:he.at)==="tree"&&re.dragFiles.worktreeId===e?re.dragFiles.dir:null}),w=M(re=>re.treeOpen[e]??Wu),b=S.useMemo(()=>new Set(w),[w]),[E,N]=S.useState(S0);yt([e,n,r],()=>N(n&&!r?new Set(wd(n).filter(re=>!b.has(re))):S0));const j=S.useCallback(re=>b.has(re)||E.has(re),[b,E]),T=S.useCallback(re=>{const he=b.has(re)||E.has(re);if(he&&E.has(re)){const pe=new Set(E);pe.delete(re),N(pe)}u({a:"tree-folder",worktreeId:e,path:re,open:!he})},[b,E,e,u]),O=S.useMemo(()=>qL(c??Wu,h??Wu,p??Wu),[c,h,p]),U=S.useMemo(()=>GL(O,j),[O,j]),Q=S.useMemo(()=>YL(m),[m]),R=M(re=>re.treeReveal),I=R&&R.worktreeId===e?R:null,[_,L]=S.useState(()=>(I==null?void 0:I.path)??null),[z,F]=S.useState({worktreeId:e,linked:I});(z.worktreeId!==e||z.linked!==I)&&(F({worktreeId:e,linked:I}),L((I==null?void 0:I.path)??null));const[ee,se]=S.useState(!1),fe=S.useMemo(()=>{if(_===null)return-1;const re=U.findIndex(he=>he.path===_);if(re>=0)return re;for(const he of wd(_).reverse()){const pe=U.findIndex(Te=>Te.path===he);if(pe>=0)return pe}return-1},[U,_]);yt([fe,ee],()=>{var re,he;ee&&((he=(re=o.current)==null?void 0:re.querySelector('[data-state~="cursor"]'))==null||he.scrollIntoView({block:"nearest"}))});const ke=S.useCallback((re,he)=>nr({dispatch:u},{worktreeId:e,path:re,view:Fi(re),focus:he}),[e,l,u]),ne=S.useCallback(re=>{L(re.path),re.kind==="folder"?T(re.path):re.kind==="file"&&ke(re.path,!1)},[T,ke]),A=re=>{var Te;if(re.metaKey||re.ctrlKey||re.altKey)return;const he=U[fe],pe=Ue=>{const ct=U[Ue];ct&&(L(ct.path),ct.kind==="file"&&ke(ct.path,!1))};switch(re.key){case"ArrowDown":case"ArrowUp":re.preventDefault(),pe(fe<0?0:Ec(fe,re.key==="ArrowDown"?1:-1,U.length));return;case" ":re.preventDefault(),(he==null?void 0:he.kind)==="file"?ke(he.path,!1):(he==null?void 0:he.kind)==="folder"&&T(he.path);return;case"Enter":re.preventDefault(),(he==null?void 0:he.kind)==="file"?ke(he.path,!0):(he==null?void 0:he.kind)==="folder"&&T(he.path);return;case"ArrowRight":case"ArrowLeft":{re.preventDefault();const Ue=U.map(We=>We.kind==="folder"?{depth:We.depth,open:We.open}:{depth:We.depth}),ct=mf(Ue,fe,re.key);(ct==null?void 0:ct.do)==="to"?pe(ct.at):ct&&he&&T(he.path);return}case"Escape":re.stopPropagation(),n!==null?u({a:"close-editor"}):(Te=document.activeElement)==null||Te.blur();return}if(re.key.length===1){const Ue=SE(U.map(ct=>ct.name),fe,re.key);Ue>=0&&(re.preventDefault(),pe(Ue))}},[q,ie]=S.useState(null),P=S.useRef(0),W=S.useCallback(re=>{re&&!j(re)&&T(re),P.current++,ie({dir:re,error:null,busy:!1})},[j,T]),xe=S.useCallback(()=>{P.current++,ie(null)},[]),ce=S.useCallback(re=>{if(!q||q.busy)return;const he=VL(q.dir,re);if("error"in he){ie({...q,error:he.error});return}const pe=++P.current;ie({...q,error:null,busy:!0}),aE({sock:l,dispatch:u},{worktreeId:e,path:he.path}).then(Te=>{Te===null&&L(he.path),pe===P.current&&ie(Te===null?null:{...q,error:Te,busy:!1})})},[q,e,l,u]),me=on("tree"),_e=S.useCallback(re=>w4({worktreeId:e,dir:t,path:re.path,folder:re.kind!=="file",newIn:re.kind==="folder"||re.kind==="ignored"?re.path:hE(re.path)},i,{sock:l,dispatch:u},W),[e,t,i,l,u,W]),ae=S.useCallback((re,he)=>{re.kind==="file"&&Jt.post(e,he?{type:"highlight-file",path:re.path,ranges:null}:{type:"highlight-clear"})},[e]),be=S.useCallback((re,he)=>{he.dataTransfer.setData(gE,re.path),he.dataTransfer.setData("text/plain",re.path),he.dataTransfer.effectAllowed="copy",cP({worktreeId:e,path:re.path,folder:re.kind!=="file"})},[e]),ze=S.useCallback(()=>kE(i),[i]);return f.jsx("div",{className:Be("tree",y===""&&"drop-over"),role:"tree","aria-label":"files","data-worktree":e,"aria-activedescendant":ee&&fe>=0?N0(fe):void 0,tabIndex:0,ref:o,onKeyDown:A,onFocus:()=>{var re;se(!0),_===null&&L(n&&U.some(he=>he.path===n)?n:((re=U[0])==null?void 0:re.path)??null)},onBlur:re=>!re.currentTarget.contains(re.relatedTarget)&&se(!1),onMouseDown:re=>{if(re.button!==0)return;const he=re.target.closest("[data-path]");(he==null?void 0:he.dataset.path)!==void 0&&L(he.dataset.path)},...me.contextMenu(re=>{const he=U[fe];return re==="keyboard"&&he?_e(he):v4({worktreeId:e,dir:t},i,{sock:l},W)}),children:c===void 0?f.jsx("div",{className:"empty",children:"listing files…"}):U.length===0&&!q?f.jsx("div",{className:"empty",children:"no files"}):E4(U.map((re,he)=>f.jsx(S4,{row:re,id:N0(he),status:Q.files.get(re.path),changedInside:re.kind!=="file"&&Q.folders.has(re.path),current:ee?he===fe:!r&&re.path===n,cursor:ee&&he===fe,dropOver:y===re.path,onPress:ne,menu:_e,onHover:ae,onDragStart:be,onDragEnd:ze},re.path)),q&&(()=>{var he;const re=q.dir===""?-1:U.findIndex(pe=>pe.path===q.dir);return{at:re,node:f.jsx(_4,{depth:re>=0?(((he=U[re])==null?void 0:he.depth)??0)+1:0,error:q.error,onSubmit:ce,onCancel:xe},"new-file")}})())})}function E4(e,t){return t?[...e.slice(0,t.at+1),t.node,...e.slice(t.at+1)]:e}function _4({depth:e,error:t,onSubmit:n,onCancel:r}){const[o,i]=S.useState(""),l={"--tree-depth":e},u=e===0||void 0;return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"row row-sm tree-row row-rails","data-kind":"file","data-root":u,style:l,children:[f.jsx("span",{className:"tree-caret row-dim"}),f.jsx(vo,{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:c=>i(c.target.value),onKeyDown:c=>{c.stopPropagation(),c.key==="Enter"?(c.preventDefault(),n(o)):c.key==="Escape"&&(c.preventDefault(),r())},onBlur:r})]}),t&&f.jsxs("div",{className:"tree-row tree-new-error row-rails","data-root":u,style:l,children:[f.jsx("span",{className:"tree-caret"}),f.jsx("span",{className:"hint",children:t})]})]})}const S4=S.memo(function({row:t,id:n,status:r,changedInside:o,current:i,cursor:l,dropOver:u,onPress:c,menu:h,onHover:p,onDragStart:g,onDragEnd:m}){const y=on("tree"),w=t.kind==="submodule",b=w?"A submodule: its files belong to its own repository":t.kind==="ignored"?"Ignored by git, so what is inside is not listed":null;return f.jsxs("div",{role:"treeitem",id:n,"aria-level":t.depth+1,"aria-expanded":t.kind==="folder"?t.open:void 0,"aria-selected":l,className:Be("row row-sm tree-row row-rails row-edge",u&&"drop-over"),"data-state":pr({current:i,cursor:l}),"data-kind":t.kind,"data-path":t.path,style:{"--tree-depth":t.depth},draggable:!w,onDragStart:E=>g(t,E),onDragEnd:m,onClick:()=>c(t),onMouseEnter:()=>p(t,!0),onMouseLeave:()=>p(t,!1),...y.contextMenu(()=>h(t)),...b?Ft(b):{},children:[f.jsx("span",{className:"tree-caret row-dim",children:t.kind==="folder"&&f.jsx(St,{name:"caret",className:Be("icon-inline disc-caret",!t.open&&"shut")})}),f.jsx("span",{className:Be("tree-name",(w||t.ignored)&&"row-dim"),children:t.name}),r?f.jsx("span",{className:`xy ${dg(r.xy)}`,children:fg(r.xy)}):o&&f.jsx("span",{className:"dot tree-changed"})]})});function GE({f:e}){return e.add===void 0&&e.del===void 0?null:f.jsxs("span",{className:"counts",children:[e.add?f.jsxs("span",{className:"add",children:["+",e.add]}):null,e.del?f.jsxs("span",{className:"del",children:["−",e.del]}):null]})}const Ku=S.memo(function({f:t,id:n,active:r,selected:o,checking:i=!1,checked:l=!1,onOpen:u,onCheck:c,menu:h,onHover:p}){const g=on("changes"),{name:m,dir:y}=rM(t.path);return f.jsxs("button",{className:"row row-sm git-file row-edge",id:n,"data-state":pr({current:r,cursor:o,checked:l}),role:"option","aria-selected":o,tabIndex:-1,onClick:w=>c&&(i||w.shiftKey)?c(t.path):u(t.path),...g.contextMenu(()=>h(t.path)),onMouseEnter:()=>p(t.path,!0),onMouseLeave:()=>p(t.path,!1),children:[i&&f.jsx("input",{type:"checkbox",className:"changes-check",checked:l,readOnly:!0,tabIndex:-1}),f.jsx("span",{className:`xy ${dg(t.xy)}`,children:fg(t.xy)}),f.jsxs("span",{className:"path","data-tip":y?t.path:void 0,children:[f.jsx("span",{className:"name",children:m}),y&&f.jsx("span",{className:"dir row-dim",children:y})]}),f.jsx(GE,{f:t})]})}),N4={added:"A",changed:"M",removed:"D"},T4={added:"added",changed:"",removed:"deleted"},j4=S.memo(function({tests:t,id:n,cursor:r,onPick:o}){return t.map((i,l)=>f.jsxs("button",{className:"row row-sm changes-test row-rails row-edge",id:`${n}-t${l}`,"data-state":pr({current:r===l,cursor:r===l}),"data-sub":!0,role:"option","aria-selected":r===l,tabIndex:-1,onClick:()=>o(l),"data-tip":[...i.group,i.name].join(" · "),"data-tip-placement":"follow",children:[f.jsx("span",{className:`xy ${T4[i.change]}`,children:N4[i.change]}),f.jsx("span",{className:"name",children:i.name})]},l))}),T0=new Set(["test","tests","__tests__","spec","e2e","__snapshots__","__mocks__","fixtures","testdata"]),C4=/([._-]tests?\.[^.]+$)|([._]specs?\.[^.]+$)|(^tests?[._-])|(^conftest\.py$)|(\.snap$)|([a-z0-9](Tests?|Spec)\.[^.]+$)/;function _d(e){const t=(e.endsWith("/")?e.slice(0,-1):e).split("/"),n=t.pop()??"";return e.endsWith("/")&&T0.has(n.toLowerCase())?!0:t.some(r=>T0.has(r.toLowerCase()))||C4.test(n)}function Zu(e){const t=e.filter(n=>!_d(n.path));return t.length===0||t.length===e.length?{files:e,source:t.length}:{files:[...t,...e.filter(n=>_d(n.path))],source:t.length}}const hm="(?<q>[\"'`])(?<name>(?:\\\\.|(?!\\k<q>).)*)\\k<q>",j0={tests:[new RegExp(`^\\s*(?:test|it)(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${hm}`)],groups:[new RegExp(`^\\s*describe(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${hm}`)]},A4={js:j0,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*${hm}`),/^\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*\(/,...j0.tests]}},I4={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"},R4=3,$4=/^\s*(?:[)}\]]|end\b)/,yp=e=>e.length-e.trimStart().length;function C0(e,t){var n,r;for(const o of t??[]){const i=(r=(n=o.exec(e))==null?void 0:n.groups)==null?void 0:r.name;if(i!==void 0)return i.replace(/^(["'`])(.*)\1$/,"$2")}return null}function A0(e,t){const n=t.split(`
|
|
120
|
+
`),r=[],o=[];let i=Number.NEGATIVE_INFINITY;return n.forEach((l,u)=>{var m,y,w;if(l.trim()==="")return;const c=yp(l);for(;o.length>0&&(((m=o.at(-1))==null?void 0:m.indent)??0)>=c;)o.pop();(y=e.mark)!=null&&y.test(l)&&(i=u);const p=!e.mark||u-i<=R4?C0(l,e.tests):null,g=p??C0(l,e.groups);if(g!==null){if(p!==null){i=Number.NEGATIVE_INFINITY;let b=u+1;for(;b<n.length&&(((w=n[b])==null?void 0:w.trim())===""||yp(n[b]??"")>c);)b++;b<n.length&&yp(n[b]??"")===c&&$4.test(n[b]??"")&&b++;const E=n.slice(u,b).map(N=>N.trim()).join(`
|
|
121
|
+
`).trim();r.push({group:o.map(N=>N.name),name:g,line:u,end:b,body:E})}o.push({indent:c,name:g})}}),r}function I0(e){const t=new Map;for(const n of e){const r=[...n.group,n.name].join(`
|
|
122
|
+
`);let o=0;for(;t.has(`${r}
|
|
123
|
+
${o}`);)o++;t.set(`${r}
|
|
124
|
+
${o}`,n)}return t}function O4(e,t,n){const r=A4[I4[e.slice(e.lastIndexOf(".")+1).toLowerCase()]??""];if(!r)return[];const o=I0(A0(r,t)),i=I0(A0(r,n)),l=[];for(const[p,g]of i){const m=o.get(p);(m==null?void 0:m.body)!==g.body&&l.push({name:g.name,group:g.group,change:m?"changed":"added",line:g.line+1})}const u=n.split(`
|
|
125
|
+
`).length;let c=1;for(const[p,g]of o){const m=i.get(p);m?c=Math.min(m.end+1,u):l.push({name:g.name,group:g.group,change:"removed",line:c})}const h=p=>p.change==="removed"?0:1;return l.sort((p,g)=>p.line-g.line||h(p)-h(g))}const qu=[];function M4(e,t,n,r){const o=t?n>0?"no changes of its own":`same as ${e}`:"no changes";if(!r)return o;const i=ao(r.at);return`${o}, last commit ${i==="now"?"just now":`${i} ago`}`}const R0='[role="option"]:not([data-sub])',$0=[];function VE({width:e,placement:t="dock"}){const n=t==="screen",r=st(),o=at(),i=Kn(),l=Ga(),u=Hi(),c=(u==null?void 0:u.id)??l,h=Ss(),p=M(Z=>Z.layout.changes),g=vc(),m=M(Z=>Z.focusChanges),y=At(c,"git"),w=M(Z=>Z.editor&&Z.editor.worktreeId===c?Z.editor.path:null),b=M(Z=>Z.editor&&Z.editor.worktreeId===c?Z.editor.ref??null:null),E=M(Z=>Z.editor&&Z.editor.worktreeId===c?Z.editor.since??null:null),N=(y==null?void 0:y.files)??qu,j=(y==null?void 0:y.committed)??qu,{files:T,source:O}=S.useMemo(()=>Zu(N),[N]),U=j.length>0,Q=sL(),{files:R,source:I}=S.useMemo(()=>Zu(Q?j:qu),[j,Q]),_=y==null?void 0:y.turn,L=_==null?void 0:_.base,z=iL(),{files:F,source:ee}=S.useMemo(()=>Zu(_&&z?_.files:qu),[_,z]),se=T.length,fe=T.length+F.length,ke=M(Z=>Z.editor&&Z.editor.worktreeId===c?Z.editor.disk:null),ne=S.useMemo(()=>w!==null&&ke&&_d(w)?O4(w,ke.before,ke.after):$0,[w,ke]),[A,q]=S.useState(!1);yt([w,b,E],()=>q(!1));const ie=O>0?T.length-O:0,P=I>0?R.length-I:0,W=ee>0?F.length-ee:0,xe=T.length===0,ce=S.useMemo(()=>{if(T.length===0)return;const Z=T.reduce((wt,Xt)=>wt+(Xt.add??0),0),de=T.reduce((wt,Xt)=>wt+(Xt.del??0),0),De=[Z>0&&`+${Z}`,de>0&&`−${de}`].filter(Boolean).join(" "),ut=`${T.length} uncommitted ${T.length===1?"file":"files"}`;return De?`${ut}, ${De}`:ut},[T]),me=!!y&&xe&&!U,_e=M(za),ae=u!==null||_e==="changes",be=u!==null||_e==="history",ze=S.useCallback(Z=>o({a:"changes-tab",v:Z}),[o]),re=S.useRef(_e);re.current=_e;const he=S.useRef(null),pe=Sg(),Te=M(Z=>{const de=ai(Z,pe==null?void 0:pe.repoId);return de?Ud(de):"main"}),Ue=At(c,"commits"),ct=At(c,"commitFiles"),[We,xn]=S.useState(null),Ht=S.useRef(null);Ht.current=We;const It=S.useRef(null),nt=At(c,"changedRanges"),Ve=S.useCallback((Z,de)=>{if(!c||u)return;if(!de){It.current=null,Jt.post(c,{type:"highlight-clear"});return}It.current=Z;const De=nt[Z];De?Jt.post(c,{type:"highlight-file",path:Z,ranges:Pv(De)}):r==null||r.send({t:"changed-ranges",worktreeId:c,path:Z})},[c,u,nt,r]);S.useEffect(()=>{const Z=It.current;if(!Z||!c)return;const de=nt[Z];de&&Jt.post(c,{type:"highlight-file",path:Z,ranges:Pv(de)})},[nt,c]);const mt=u&&T.length>0?(y==null?void 0:y.head)??null:null,En=S.useCallback((Z,de=!1,De)=>c&&nr({dispatch:o},{worktreeId:c,path:Z,focus:de,ref:mt??void 0,since:De}),[c,mt,r,o]),Rt=S.useMemo(()=>u?T:[...T,...F,...R],[u,T,F,R]),V=S.useMemo(()=>{const Z=[];for(const de of Ue??[])if(Z.push({commit:de}),de.sha===We)for(const De of Zu(ct[de.sha]??[]).files)Z.push({commit:de,file:De});return Z},[Ue,We,ct]),ge=S.useMemo(()=>V.filter(Z=>!Z.file&&Z.commit.ahead).length,[V]),ft=S.useMemo(()=>V.findIndex(Z=>!Z.file&&!Z.commit.ahead),[V]),qe=u?Rt.length:0,un=(ae?Rt.length:0)+(be?V.length:0),yn=S.useMemo(()=>{const Z=new Map;if(!u||T.length===0&&V.every(De=>De.commit.landedAt))return Z;let de;return V.forEach((De,ut)=>{const wt=!!De.commit.landedAt;wt!==de&&(de=wt,Z.set(ut,wt?"landed":"not landed"))}),Z},[u,T,V]),Tn=S.useRef(null),[{row:gt,at:jn},ye]=S.useReducer((Z,de)=>typeof de=="number"?{row:de,at:-1}:de,{row:0,at:-1}),[Le,wn]=S.useState(!1),_n=(Z,de)=>Le?Mt(Z):de,Sn=Z=>`changes-row-${Z}`,[sn,In]=S.useState(!1),[ot,Wt]=S.useState([]),Qt=S.useCallback(()=>{In(!1),Wt([])},[]),B=S.useCallback(Z=>{In(!0),Wt(de=>de.includes(Z)?de.filter(De=>De!==Z):[...de,Z])},[]),ue=S.useMemo(()=>T.filter(Z=>ot.includes(Z.path)).map(Z=>Z.path),[T,ot]);yt([T],()=>Wt(Z=>{const de=Z.filter(De=>T.some(ut=>ut.path===De));return de.length===Z.length?Z:de})),yt([sn],()=>{if(!sn)return;const Z=de=>de.key==="Escape"&&Qt();return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)}),yt([c,_e],()=>{ye(0),Qt()});const Ie=y==null?void 0:y.head,Je=S.useRef("");S.useEffect(()=>{if(!(be||me)||!c)return;const Z=`${c}:${Ie??""}`;Je.current!==Z&&(Je.current=Z,r==null||r.send({t:"git-log",worktreeId:c}))},[be,me,c,Ie,r]);const Ot=S.useCallback(Z=>{xn(de=>de===Z?null:Z),c&&!ct[Z]&&(r==null||r.send({t:"git-commit",worktreeId:c,sha:Z}))},[c,ct,r]);yt([gt,jn,Le],()=>{var Z,de;Le&&((de=(Z=Tn.current)==null?void 0:Z.querySelector('[data-state~="cursor"]'))==null||de.scrollIntoView({block:"nearest"}))});const $t=S.useRef(-1),Oe=Z=>Z>=se&&Z<fe?L:void 0,Me=Z=>{var de;return((de=Rt[Z])==null?void 0:de.path)===w&&(E??void 0)===Oe(Z)&&(Z<se?b===mt:!b)};$t.current=ae?Rt.findIndex((Z,de)=>Me(de)):-1,S.useEffect(()=>{if(!m)return;const Z=re.current==="files";$t.current>=0&&ye($t.current);const de=requestAnimationFrame(()=>{var De;return(De=(Z?he:Tn).current)==null?void 0:De.focus()});return()=>cancelAnimationFrame(de)},[m]);const Ye=S.useCallback((Z,de=!1)=>{const De=Rt[Z];De&&(ye(Z),En(De.path,de,Z>=se&&Z<fe?L:void 0),Ve(De.path,!0))},[Rt,En,Ve,se,fe,L]),Pt=S.useCallback((Z,de=!1)=>{const De=Ht.current;c&&De&&nr({dispatch:o},{worktreeId:c,path:Z,ref:De,focus:de})},[c,r,o]),X=S.useCallback(Z=>{const de=V[Z-qe];de&&(ye(Z),de.file&&Pt(de.file.path))},[V,qe,Pt]),$e=S.useCallback(Z=>{const de=V[Z-qe];de&&(ye(Z),de.file?Pt(de.file.path,!0):Ot(de.commit.sha))},[V,qe,Pt,Ot]),kt=Z=>be&&Z>=qe,Nt=Z=>{if(w===null)return!1;if(ae&&Z<Rt.length)return Me(Z);const de=kt(Z)?V[Z-qe]:void 0;return!!(de!=null&&de.file)&&b===de.commit.sha&&de.file.path===w},Dt=Z=>Nt(Z)&&!A?ne:$0,an=jn<Dt(gt).length?jn:-1,Mt=Z=>Le&>===Z&&an<0,zt=()=>{var de,De;const Z=[];for(let ut=0;ut<un;ut++){const wt=kt(ut)?V[ut-qe]:void 0,Xt=wt?(de=wt.file)==null?void 0:de.path:(De=Rt[ut])==null?void 0:De.path,Dn=wt!=null&&wt.file?1:0,zn=Dt(ut);wt&&!wt.file?Z.push({row:ut,at:-1,depth:Dn,open:wt.commit.sha===We}):Xt!==void 0&&_d(Xt)?Z.push({row:ut,at:-1,depth:Dn,open:zn.length>0}):Z.push({row:ut,at:-1,depth:Dn});for(let So=0;So<zn.length;So++)Z.push({row:ut,at:So,depth:Dn+1})}return Z},Vt=(Z,de=!1)=>{const De=ne[Z];!De||!c||w===null||nr({dispatch:o},{worktreeId:c,path:w,ref:b??void 0,since:E??void 0,line:{n:De.line},focus:de})},Qe=Z=>Dt(Z).length>0&&f.jsx(j4,{tests:ne,id:Sn(Z),cursor:Le&>===Z?an:-1,onPick:de=>{ye({row:Z,at:de}),Vt(de)}}),vn=Z=>{var de;if(sn&&Z.key==="Escape")Z.preventDefault(),Z.stopPropagation(),Qt();else if(sn&&Z.key===" "){Z.preventDefault();const De=ae&><T.length?T[gt]:void 0;De&&B(De.path)}else if(Z.key==="ArrowDown"&&an+1<Dt(gt).length)Z.preventDefault(),ye({row:gt,at:an+1}),Vt(an+1);else if(Z.key==="ArrowUp"&&an>=0)Z.preventDefault(),an===0?ye(gt):(ye({row:gt,at:an-1}),Vt(an-1));else if(Z.key==="Enter"&&an>=0)Z.preventDefault(),Vt(an,!0);else if(Z.key==="ArrowDown"||Z.key==="ArrowUp"){Z.preventDefault();const De=Ec(gt,Z.key==="ArrowDown"?1:-1,un);kt(De)?X(De):Ye(De)}else if(Z.key==="Enter")Z.preventDefault(),kt(gt)?$e(gt):Ye(gt,!0);else if(Z.key==="ArrowRight"||Z.key==="ArrowLeft"){Z.preventDefault();const De=zt(),ut=mf(De,De.findIndex(Dn=>Dn.row===gt&&Dn.at===an),Z.key),wt=ut&&De[ut.at];if(!ut||!wt)return;const Xt=kt(wt.row)?V[wt.row-qe]:void 0;ut.do==="to"?wt.at>=0?(ye({row:wt.row,at:wt.at}),Vt(wt.at)):Xt!=null&&Xt.file&&wt.row>gt?X(wt.row):ye(wt.row):Xt&&!Xt.file?Ot(Xt.commit.sha):ut.do==="close"?q(!0):Nt(wt.row)?q(!1):Xt!=null&&Xt.file?X(wt.row):Ye(wt.row)}else Z.key==="Escape"&&(Z.stopPropagation(),w!==null?o({a:"close-editor"}):(de=document.activeElement)==null||de.blur())},pn=u?u.id:h==null?void 0:h.worktree.id,Rn=u?u.path:h?h.worktree.path:"",dn=u!==null,Bt=S.useCallback(Z=>pn?vs({id:pn,dir:Rn},Z,{discard:!dn,kept:dn,ref:mt??void 0,select:dn?void 0:B},{sock:r,dispatch:o}):[],[pn,Rn,dn,mt,B,r,o]),cr=S.useCallback(Z=>pn?vs({id:pn,dir:Rn},Z,{kept:dn},{sock:r,dispatch:o}):[],[pn,Rn,dn,r,o]),Qr=S.useCallback(Z=>pn?vs({id:pn,dir:Rn},Z,{kept:dn,since:L},{sock:r,dispatch:o}):[],[pn,Rn,dn,L,r,o]),ln=S.useCallback(Z=>pn?vs({id:pn,dir:Rn},Z,{ref:Ht.current??void 0,kept:dn},{sock:r,dispatch:o}):[],[pn,Rn,dn,r,o]),rs=on("changes"),Xr=()=>{if(ae&><Rt.length){const de=Rt[gt];return de?(gt<se?Bt:gt<fe?Qr:cr)(de.path):[]}const Z=kt(gt)?V[gt-qe]:void 0;return Z?Z.file?ln(Z.file.path):IE(Z.commit):[]},Zn=(Z,de)=>{const De=Rt.findIndex((ut,wt)=>wt>=Z&&ut.path===de);ye(De),Me(De)&&ne.length>0?q(ut=>!ut):En(de,!1,Oe(De))},ur=S.useRef(Zn);ur.current=Zn;const je=S.useCallback(Z=>ur.current(0,Z),[]),Fe=S.useCallback(Z=>ur.current(se,Z),[se]),lt=S.useCallback(Z=>ur.current(fe,Z),[fe]),Et=S.useCallback(Z=>{ye(qe+V.findIndex(de=>!de.file&&de.commit.sha===Z)),Ot(Z)},[V,qe,Ot]),cn=S.useCallback(Z=>{ye(qe+V.findIndex(de=>{var De;return((De=de.file)==null?void 0:De.path)===Z})),Z===w&&b===Ht.current&&ne.length>0?q(de=>!de):Pt(Z)},[V,qe,Pt,w,b,ne]),mn=S.useCallback(()=>{},[]);return f.jsxs("div",{className:Be("changes-dock",n&&"changes-screen",!n&&(!p||g)&&"collapsed"),style:n?void 0:{width:e},children:[!u&&f.jsx(pf,{fill:!n,quiet:n,owner:"changes-tabs",label:"changes panel",items:[{id:"files",label:f.jsx(St,{name:"folder",className:"icon-inline"}),fit:!0,ariaLabel:"files",tip:Ft("files",Tt("files"))},{id:"changes",label:"changes",tip:Ft("changes",Tt("changes"),{detail:ce})},{id:"history",label:"history"}],current:_e,onPick:ze}),_e==="files"&&c?f.jsx(x4,{worktreeId:c,dir:h?h.worktree.path:(pe==null?void 0:pe.path)??"",openPath:w,openRef:b,rootRef:he}):f.jsxs("div",{className:Be("changes-list",be&&"history"),role:"listbox","aria-label":u?"kept work":be?"commits":"changed files","aria-activedescendant":Le&>>=0&><un?an<0?Sn(gt):`${Sn(gt)}-t${an}`:void 0,tabIndex:0,ref:Tn,onKeyDown:vn,onFocus:()=>wn(!0),onMouseDown:Z=>{var ut;if(Z.button!==0)return;Z.preventDefault();const de=Z.target.closest(R0),De=de?Array.from(Z.currentTarget.querySelectorAll(R0)).indexOf(de):-1;De>=0&&ye(De),(ut=Tn.current)==null||ut.focus()},onBlur:Z=>!Z.currentTarget.contains(Z.relatedTarget)&&wn(!1),...rs.contextMenu(Z=>Z==="keyboard"?Xr():[]),children:[ae&&T.length>0&&f.jsxs(f.Fragment,{children:[(U||u)&&f.jsx("div",{className:"section-title section-row",children:"uncommitted"}),T.map((Z,de)=>f.jsxs(S.Fragment,{children:[ie>0&&de===O&&f.jsx("div",{className:"section-title changes-sub",children:"tests"}),f.jsx(Ku,{f:Z,id:Sn(de),active:_n(de,Nt(de)),selected:Mt(de),checking:sn,checked:ot.includes(Z.path),onOpen:je,onCheck:dn?void 0:B,menu:Bt,onHover:Ve}),Qe(de)]},Z.path))]}),ae&&!u&&_&&f.jsxs(f.Fragment,{children:[f.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":z,"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",f.jsx(St,{name:"caret",className:Be("icon-inline disc-caret",!z&&"shut")})]}),F.map((Z,de)=>f.jsxs(S.Fragment,{children:[W>0&&de===ee&&f.jsx("div",{className:"section-title changes-sub",children:"tests"}),f.jsx(Ku,{f:Z,id:Sn(se+de),active:_n(se+de,Nt(se+de)),selected:Mt(se+de),onOpen:Fe,menu:Qr,onHover:Ve}),Qe(se+de)]},`t-${Z.path}`))]}),ae&&!u&&U&&f.jsxs(f.Fragment,{children:[f.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":Q,"data-tip":`Committed on this branch, not yet on ${Te}`,"data-tip-placement":"follow",onClick:()=>o({a:"toggle-committed"}),onKeyDown:Z=>(Z.key==="Enter"||Z.key===" ")&&Z.stopPropagation(),children:["committed",f.jsx(St,{name:"caret",className:Be("icon-inline disc-caret",!Q&&"shut")})]}),R.map((Z,de)=>f.jsxs(S.Fragment,{children:[P>0&&de===I&&f.jsx("div",{className:"section-title changes-sub",children:"tests"}),f.jsx(Ku,{f:Z,id:Sn(fe+de),active:_n(fe+de,Nt(fe+de)),selected:Mt(fe+de),onOpen:lt,menu:cr,onHover:Ve}),Qe(fe+de)]},`c-${Z.path}`))]}),ae&&!u&&me&&f.jsx("div",{className:"empty",children:M4(Te,!!pe&&Bd(pe),(y==null?void 0:y.behind)??0,Ue==null?void 0:Ue[0])}),be&&V.map((Z,de)=>f.jsxs(S.Fragment,{children:[u&&yn.has(de)&&f.jsx("div",{className:"section-title section-row",children:yn.get(de)}),!u&&ge>0&&de===0&&f.jsx("div",{className:"section-title section-row",children:"on this branch"}),!u&&ge>0&&de===ft&&f.jsx("div",{className:"section-title section-row",children:Te}),Z.file?f.jsxs(f.Fragment,{children:[f.jsx(Ku,{f:Z.file,id:Sn(qe+de),active:_n(qe+de,Nt(qe+de)),selected:Mt(qe+de),onOpen:cn,menu:ln,onHover:mn}),Qe(qe+de)]}):f.jsx(k4,{c:Z.commit,id:Sn(qe+de),selected:Mt(qe+de),onToggle:Et})]},Z.file?`${Z.commit.sha}:${Z.file.path}`:Z.commit.sha)),be&&Ue===void 0&&f.jsx("div",{className:"empty",children:"reading history…"}),be&&(Ue==null?void 0:Ue.length)===0&&T.length===0&&f.jsx("div",{className:"empty",children:"no commits yet"})]}),sn&&f.jsxs("div",{className:"changes-pick",children:[f.jsxs(Pe,{size:"md",tone:"danger",disabled:ue.length===0,"data-tip":"Throw away the uncommitted changes to every checked file",onClick:()=>{!pn||ue.length===0||window.confirm(lE(ue))&&(r==null||r.send({t:"discard-files",worktreeId:pn,paths:ue}),Qt())},children:["discard ",ue.length,"…"]}),f.jsx(Pe,{size:"md",disabled:ue.length===0,"data-tip":"Name every checked file in the chat",onClick:()=>{pn&&HL(i,pn,ue),Qt()},children:"add to chat"}),f.jsx(Lt,{icon:"close",label:"Cancel",hint:"esc",onClick:Qt})]}),pe&&!u&&f.jsx(g4,{active:pe,ahead:(y==null?void 0:y.ahead)??0,behind:(y==null?void 0:y.behind)??0,unpushed:(y==null?void 0:y.unpushed)??pe.unpushed??0,dirty:!xe})]})}function O0(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 _c(e){return e>0&&e<.005?"<$0.01":`$${e.toFixed(2)}`}function M0(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 L4(e){if(!(e<.5))return e<.8?"worth compacting between tasks":"compact before the next task"}const YE=["five_hour","seven_day"],P4={five_hour:"the 5-hour window",seven_day:"the week"},D4={five_hour:"5-hour",seven_day:"this week"};function QE(e,t){return YE.flatMap(n=>{const r=e.windows[n];return r&&r.resetsAt>t?[{key:n,used:r.used,resetsAt:r.resetsAt}]:[]})}function z4(e,t){return Math.min(1,Math.max(0,...QE(e,t).map(n=>n.used)))}const F4=e=>`${Math.round(100*e)}%`;function L0(e,t){const n=QE(e,t).map(r=>`${F4(r.used)} of ${P4[r.key]}`);return n.length?n.join(", "):"plan windows reset"}function B4(e,t,n){const r=new Date(e),o=new Date(t),i=r.toDateString()===o.toDateString();return new Intl.DateTimeFormat(n,{...i?{}:{month:"short",day:"numeric"},hour:"numeric",minute:"2-digit"}).format(r)}function U4(e,t,n=r=>B4(r,t)){return YE.flatMap(r=>{const o=e.windows[r];if(!o)return[];const i=D4[r];if(o.resetsAt<=t)return[{key:r,name:i,used:0,sub:`reset ${n(o.resetsAt)}, read again on the next reply`}];const l=e.binding===r&&e.status==="rejected"?", out until then":e.binding===r&&e.status==="allowed_warning"?", nearly out":"";return[{key:r,name:i,used:o.used,sub:`resets ${n(o.resetsAt)}${l}`}]})}function H4(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 XE(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(_c(e.cost)),t.push(ao(e.archivedAt)),t.filter(Boolean).join(" · ")}function JE({sock:e,dispatch:t},n,r){e==null||e.send({t:"restore-worktree",archiveId:n,clientId:r}),t({a:"restoring",id:n,text:""})}function od(e,t,{sock:n,dispatch:r}){const o=[{id:"restore",label:"restore",disabled:e.restorable?void 0:"its commits were not kept",onClick:()=>{JE({sock:n,dispatch:r},e.id,t.clientId),r({a:"close"})}}],i=[{id:"copy-branch",label:"copy branch name",onClick:()=>Yt(e.branch)}],{sessionId:l}=e;return t.frame!=="phone"&&(i.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>Yt(e.transcript)}),l&&i.push({id:"copy-session",label:"copy session id",onClick:()=>Yt(l)})),Mn([o,i,[{id:"delete",label:"delete for good…",danger:!0,onClick:()=>{window.confirm(`Delete "${e.title}" for good?
|
|
126
|
+
|
|
127
|
+
Its chat, attachments and kept commits are deleted, and it can no longer be restored.`)&&(n==null||n.send({t:"delete-archived",archiveId:e.id}))}}]])}const W4=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function e_(e){const[t,n]=S.useState(()=>Date.now());return S.useEffect(()=>{const r=setInterval(()=>n(Date.now()),6e4);return()=>clearInterval(r)},[]),`${pg(t-e)} ago`}function Do({icon:e,word:t,tone:n,at:r,below:o,children:i,...l}){const u=r!==void 0?{"data-tip":`${t} ${W4.format(r)}`,"data-tip-placement":"follow"}:null;return f.jsxs("div",{...u,...l,className:"daemon-row row-edge","data-tone":n,children:[f.jsxs("div",{className:"daemon-head",children:[f.jsxs("span",{className:"daemon-tag",children:[f.jsx(St,{name:e,className:"icon-inline"}),t]}),i]}),o]})}function K4({item:e}){const t=st(),n=at(),r=M(h=>h.clientId),o=At(e.id,"restoring"),i=e.uncommitted?"its chat, commits and uncommitted changes":"its chat and commits",l=e.cost!==void 0?`; the session cost ${_c(e.cost)}`:"",u=e.restorable?`Toyon kept ${i}${l}. A message sent below restores it first.`:`Its commits were not kept, so there is nothing to restore${l}; its row's menu on the rail can delete it for good.`,c=e_(e.archivedAt);return f.jsxs(Do,{icon:"archive",word:"archived",tone:"quiet",at:e.archivedAt,below:f.jsx("div",{className:"daemon-below row-dim",children:u}),children:[f.jsxs("span",{className:"daemon-text",children:[c,e.landed?", after it was merged into main":""]}),e.restorable&&o===void 0&&f.jsx(Pe,{variant:"inline",tone:"strong",onClick:()=>JE({sock:t,dispatch:n},e.id,r),children:"restore"})]})}function Ha(e,t,n,r,o){const{layout:i}=e.getState();nr({dispatch:e.dispatch},{worktreeId:n,path:r,view:"file",line:{n:o,fiber:!0}}),i.changes||e.dispatch({a:"toggle-changes"})}function Z4(e){let t=0;return e.map(n=>{const r={start:t,len:n};return t+=n,r})}function q4(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 P0(e,t,n){let r=0,o=e.length-1;for(;r<o;){const l=r+o>>1,u=e[l];(n?t>u.start+u.len:t>=u.start+u.len)?r=l+1:o=l}const i=e[r];return{i:r,at:t-i.start}}function G4(e,t){return{from:P0(e,t.start,!1),to:P0(e,t.end,!0)}}function D0(e,t){if(e.length===0)return-1;const n=e.findIndex(r=>r.start>=t);return n===-1?0:n}function V4(e,t,n){return t===0?-1:(e+n+t)%t}function Bg(e){return e.key==="f"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function Y4({label:e,query:t,onQuery:n,seed:r,seq:o,status:i,none:l,onStep:u,onClose:c}){const h=S.useRef(null);return yt([o],()=>{var p,g;r&&n(r),(p=h.current)==null||p.focus(),(g=h.current)==null||g.select()}),f.jsxs("div",{className:"find",children:[f.jsx(vo,{ref:h,autoFocus:!0,value:t,onChange:p=>n(p.target.value),placeholder:"find…","aria-label":e,className:"find-field",spellCheck:!1,onKeyDown:p=>{if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),c();return}if(p.key==="Enter"){p.preventDefault(),u(p.shiftKey?-1:1);return}if(Bg(p)){p.preventDefault(),p.stopPropagation(),p.currentTarget.select();return}p.key.toLowerCase()==="g"&&(p.metaKey||p.ctrlKey)&&!p.altKey&&(p.preventDefault(),p.stopPropagation(),u(p.shiftKey?-1:1))}}),f.jsx("span",{className:"find-count","aria-live":"polite",children:i}),f.jsx(Lt,{icon:"caret",label:"Previous match",hint:"⇧↩",className:"find-prev",disabled:l,onClick:()=>u(-1)}),f.jsx(Lt,{icon:"caret",label:"Next match",hint:"↩",disabled:l,onClick:()=>u(1)}),f.jsx(Lt,{icon:"close",label:"Close",hint:"esc",onClick:c})]})}const t_="find",n_="find-current",r_=typeof CSS<"u"&&"highlights"in CSS;function Q4(e){const t=e.parentElement;return t?typeof t.checkVisibility=="function"?t.checkVisibility():!0:!1}function X4(e){const t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[];for(let r=t.nextNode();r;r=t.nextNode()){const o=r;o.data.length>0&&Q4(o)&&n.push(o)}return n}const pm={matches:[],ranges:[]};function J4(e,t){if(!t)return pm;const n=X4(e),r=q4(n.map(l=>l.data).join(""),t),o=Z4(n.map(l=>l.data.length)),i=r.map(l=>{const{from:u,to:c}=G4(o,l),h=document.createRange();return h.setStart(n[u.i],u.at),h.setEnd(n[c.i],c.at),h});return{matches:r,ranges:i}}function eD(e,t){r_&&(CSS.highlights.set(t_,new Highlight(...e.filter((n,r)=>r!==t))),CSS.highlights.set(n_,new Highlight(...e[t]?[e[t]]:[])))}function tD(){r_&&(CSS.highlights.delete(t_),CSS.highlights.delete(n_))}function nD(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 z0=48;function rD(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect();n.top>=r.top+z0&&n.bottom<=r.bottom-z0||(e.scrollTop+=n.top-r.top-r.height/3)}function o_({root:e,body:t,seed:n,seq:r,onClose:o,onReveal:i}){const[l,u]=S.useState(n),[c,h]=S.useState(pm),[p,g]=S.useState(-1),m=S.useRef({found:pm,at:-1}),y=S.useRef(""),w=S.useRef(!1),[b,E]=S.useState(0);S.useLayoutEffect(()=>{const O=t.current;if(!O)return;let U=0;const Q=new MutationObserver(()=>{U||(U=requestAnimationFrame(()=>{U=0,E(R=>R+1)}))});return Q.observe(O,{childList:!0,characterData:!0,subtree:!0,attributes:!0}),()=>{Q.disconnect(),U&&cancelAnimationFrame(U)}},[t]),S.useLayoutEffect(()=>{const O=t.current;if(!O)return;const U=J4(O,l),Q=l!==y.current;y.current=l,Q&&(w.current=!0);const{found:R,at:I}=m.current;let _;Q?R.matches[I]?_=D0(U.matches,R.matches[I].start):_=e.current?nD(U.ranges,e.current):D0(U.matches,0):_=Math.min(I,U.matches.length-1),m.current={found:U,at:_},h(U),g(_)},[l,b]),S.useLayoutEffect(()=>{eD(c.ranges,p);const O=c.ranges[p];O&&(w.current&&e.current&&(rD(e.current,O),i==null||i()),w.current=!1)},[c,p,e,i]),S.useLayoutEffect(()=>tD,[]);const N=c.matches.length,j=O=>{if(N===0)return;w.current=!0;const U=V4(m.current.at,N,O);m.current={...m.current,at:U},g(U)},T=()=>o(c.ranges[p]??null);return f.jsx(Y4,{label:"find in this document",query:l,onQuery:u,seed:n,seq:r,status:l?N===0?"no matches":`${p+1}/${N}`:"",none:N===0,onStep:j,onClose:T})}function s_(e){return e.key==="a"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function i_(e,t,n,r){S.useEffect(()=>{let o=!1;const i=u=>{o=!!e.current&&u.target instanceof Node&&e.current.contains(u.target)},l=u=>{const c=e.current;if(!c||u.defaultPrevented||!t(u))return;const h=document.activeElement;!(h&&h!==document.body?c.contains(h):o)&&!(r!=null&&r(h))||(u.preventDefault(),n(c,u))};return window.addEventListener("pointerdown",i,!0),window.addEventListener("keydown",l),()=>{window.removeEventListener("pointerdown",i,!0),window.removeEventListener("keydown",l)}},[e,t,n,r])}function oD(e){i_(e,s_,a_)}function mm(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 a_(e){const t=document.createRange();t.selectNodeContents(e);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}const l_=({open:e,remove:t})=>[e?[{id:"open",label:"open full size",onClick:e}]:[],t?[{id:"remove",label:"remove",onClick:t}]:[]];function cc(e,t={}){return Mn([[{id:"copy-image",label:"copy image",onClick:()=>RL(e)}],...l_(t)])}function c_(e,t={}){const{text:n,href:r}=e;return Mn([n!==void 0?[{id:"copy-text",label:"copy text",onClick:()=>Yt(n)}]:r?[{id:"copy-text",label:"copy text",onClick:()=>IL(r)}]:[],...l_(t)])}function sD(e){return[oE(e),{id:"copy-link",label:"copy link",onClick:()=>Yt(e)}]}function gm(e){return e?[{id:"copy-code",label:"copy code",onClick:()=>Yt(e)}]:[]}function Il(e,t,{dispatch:n,sock:r},o={}){const i=o.link,l=(i==null?void 0:i.kind)==="file"&&t?()=>r==null?void 0:r.send({t:"reveal",worktreeId:t,path:i.file.path}):void 0,u=i?i.kind==="file"?Sd(i.file.path,o.dir??null,l,ts(r)):i.kind==="path"||i.kind==="outside"?Sd(i.path,o.dir??null,void 0,ts(r)):[sD(i.href)]:[],c=[{id:"copy",label:"copy message",onClick:()=>Yt(e.text)}],h=[];return e.kind==="user"&&t&&h.push({id:"draft",label:"edit in composer",onClick:()=>{const p=e.seq;if(p===void 0||!r)return n({a:"set-draft",id:t,text:e.text});n({a:"set-draft",id:t,text:""}),r.send({t:"redraft",worktreeId:t,seq:p})}}),Mn([gm(o.code),...u,c,h])}function Sd(e,t,n,r){const o=e.startsWith("/")?e:t?`${t}/${e}`:null;return[o?Bi(o,n,r):[],[{id:"copy-path",label:"copy path",onClick:()=>Yt(e)}]]}function u_(e,t,n,r){return Mn(Sd(e,t,n,r))}function iD(e,t){const n=e.callFile??e.file,r=n?Sd(n,t.dir??null,void 0,t.host):[],o=t.remove?[{id:"remove",label:"remove",onClick:t.remove}]:[];return Mn([...r,o])}const F0=8,aD=.7,lD=100,cD=400,uD=260,dD=80,fD=220;function B0({dx:e,dy:t}){return Math.abs(e)<F0&&Math.abs(t)<F0?null:Math.abs(t)>Math.abs(e)?"away":"other"}function hD(e,t){const n=e.filter(i=>t-i.t<=lD),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 pD=e=>Math.abs(e)>=aD;function mD(e,t){return Math.min(fD,Math.max(dD,e/Math.abs(t)))}function gD(e,t,n){const r=S.useRef(n);r.current=n,S.useEffect(()=>{const o=e.current;if(!o)return;let i=null,l=!1,u=[],c=0;const h=(b,E,N)=>{N!==void 0&&o.style.setProperty("--swipe-ms",`${N}ms`),o.dataset.swipe!==E&&(o.dataset.swipe=E,o.offsetWidth),o.style.setProperty("--swipe-y",`${b}px`),o.style.setProperty("--swipe-fade",`${Math.min(1,Math.abs(b)/(window.innerHeight/2))}`)},p=()=>{o.style.removeProperty("--swipe-y"),o.style.removeProperty("--swipe-fade"),o.style.removeProperty("--swipe-ms"),delete o.dataset.swipe},g=()=>{const b=l;i=null,l=!1,u=[],b&&(h(0,"settle"),c=window.setTimeout(p,uD))},m=b=>{var j;const E=b.touches[0],N=b.target;if(b.touches.length!==1||!E||(((j=window.visualViewport)==null?void 0:j.scale)??1)>1.01)return g();o.dataset.swipe==="leave"||!(N===o||N!=null&&N.closest(t))||(window.clearTimeout(c),i={x:E.clientX,y:E.clientY,at:b.timeStamp},u=[{y:E.clientY,t:b.timeStamp}])},y=b=>{const E=b.touches[0];if(!i||!E)return;const N=E.clientX-i.x,j=E.clientY-i.y;if(!l){const T=B0({dx:N,dy:j});if(T==="other"&&(i=null),T!=="away")return;l=!0}b.preventDefault(),u.push({y:E.clientY,t:b.timeStamp}),u.length>16&&u.shift(),h(j,"drag")},w=b=>{const E=b.changedTouches[0];if(!i||!E)return;const N=E.clientY-i.y,j=b.timeStamp-i.at;if(!l&&j<cD&&b.target!==o&&B0({dx:E.clientX-i.x,dy:N})===null){b.preventDefault(),i=null,r.current();return}const O=hD(u,b.timeStamp);if(!l||!pD(O))return g();i=null,l=!1,u=[];const U=Math.sign(O)*window.innerHeight,Q=mD(Math.abs(U-N),O);h(U,"leave",Q),c=window.setTimeout(()=>r.current(),Q)};return o.addEventListener("touchstart",m,{passive:!0}),o.addEventListener("touchmove",y,{passive:!1}),o.addEventListener("touchend",w),o.addEventListener("touchcancel",g),()=>{window.clearTimeout(c),o.removeEventListener("touchstart",m),o.removeEventListener("touchmove",y),o.removeEventListener("touchend",w),o.removeEventListener("touchcancel",g)}},[e,t])}function Ug({owner:e,onClose:t,menu:n,children:r}){const o=on(e),i=S.useRef(null);return gD(i,"img",t),f.jsxs(Ns,{className:"attach-full scrim",boxRef:i,onDismiss:t,onKey:l=>{l.key==="Escape"&&(l.stopPropagation(),t())},onClick:l=>{l.target===l.currentTarget&&t()},...n&&o.contextMenu(n),children:[r,f.jsx(Lt,{icon:"close",label:"Close",tone:"quiet",onClick:t})]})}function kD({item:e}){if(!e.outcome)return null;const t=X2[e.outcome];if(e.ask.kind==="permission"){const{title:n,choices:r}=e.ask,o=r.find(i=>i.id===e.choiceId);return f.jsxs("div",{className:"ask-closed",children:[!e.toolId&&f.jsx("div",{className:"ask-lead",children:n}),f.jsx("div",{className:"ask-answered",children:o?o.name:t??"closed"})]})}return f.jsxs("div",{className:"ask-closed",children:[f.jsx("div",{className:"ask-lead",children:e.ask.message}),f.jsx("div",{className:"ask-answered",children:t??"closed"})]})}const yD=e=>e.t==="open-path"||e.t==="open-loose",Sa=new Map,wD=16;function vD({sock:e,dispatch:t},n,r){const o=Po();Sa.set(o,{worktreeId:n,href:r.href});for(const i of Sa.keys()){if(Sa.size<=wD)break;Sa.delete(i)}t({a:"link-refused",id:n,v:null}),e==null||e.send({t:"open-by-path",path:r.path,seq:o})}function bD(e,t){const n=Sa.get(t.seq);n&&(Sa.delete(t.seq),e.dispatch({a:"link-refused",id:n.worktreeId,v:{href:n.href,message:t.message}}))}function xD(e,t,n){var i;const r=e.getState();if(n.t==="open-path"){const l={dispatch:c=>e.dispatch(c)};if(es(r,n.worktreeId)){r.activeId!==n.worktreeId&&e.dispatch({a:"activate",id:n.worktreeId}),nr(l,{worktreeId:n.worktreeId,path:n.path});return}const u=Object.keys(r.trunks).find(c=>{var h;return((h=r.trunks[c])==null?void 0:h.id)===n.worktreeId});if(!u)return;if(((i=es(r,r.activeId))==null?void 0:i.repoId)!==u){const c=r.rows.find(h=>h.repoId===u);if(!c)return;e.dispatch({a:"activate",id:c.id})}nr(l,{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:Po()}})}function Hg(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 d_=e=>e.slice(0,Math.max(0,e.lastIndexOf("/")));function f_(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 i=e.replace(/\/+$/,"");if(!i||!n.startsWith(`${i}/`))return null;const l=n.endsWith("/"),u=n.slice(i.length+1).replace(/\/+$/,"");if(!u||u.split("/").some(p=>p===".."))return null;if(l)return{path:u,folder:!0};const c=(r==null?void 0:r[1])??(o==null?void 0:o[1]),h=c?Number.parseInt(c,10):void 0;return h&&h>0?{path:u,line:h}:{path:u}}function h_(e){if(!e.startsWith("/")||e.startsWith("//"))return null;let t;try{t=decodeURIComponent(e)}catch{return null}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 ED(e){return e.length<2||!e.startsWith("/")||e.startsWith("//")||/\s/.test(e)?null:e}function Wg(e,t){const n=e.closest("a, code[data-path]");if(!n)return null;const r=n.getAttribute("data-path");if(r)return{kind:"path",path:r};const o=n.getAttribute("href");if(!o)return null;const i=t?f_(t,o):null;if(i)return{kind:"file",file:i};const l=h_(o);return l?{kind:"outside",href:o,...l}:{kind:"out",href:o}}function Kg(e,t,n,r){const o=Wg(e.target,t);if((o==null?void 0:o.kind)==="outside"&&n){e.preventDefault(),vD(r,n,o);return}if((o==null?void 0:o.kind)!=="file"||!n)return;const i=o.file;if(e.preventDefault(),i.folder){zL(r,{worktreeId:n,path:i.path});return}nr(r,{worktreeId:n,path:i.path,...i.line?{line:{n:i.line}}:{}})}const _D=150,SD=e=>({side:e,align:"center",offset:12,flip:"side",margin:8});function p_({chip:e,className:t,children:n}){const[r,o]=S.useState(!1),i=M(u=>u.chatSide);S.useEffect(()=>{const u=e.current;if(!u)return;let c=0;const h=()=>{window.clearTimeout(c),o(!1)},p=()=>{window.clearTimeout(c),c=window.setTimeout(()=>o(!0),_D)};return u.addEventListener("mouseenter",p),u.addEventListener("mouseleave",h),u.addEventListener("mousedown",h),()=>{window.clearTimeout(c),u.removeEventListener("mouseenter",p),u.removeEventListener("mouseleave",h),u.removeEventListener("mousedown",h)}},[e]);const l=()=>{var p;const u=e.current;if(!u)return null;const c=u.getBoundingClientRect(),h=((p=u.closest(".chat-log"))==null?void 0:p.getBoundingClientRect())??c;return{left:h.left,right:h.right,top:c.top,bottom:c.bottom}};return r?f.jsx(Ns,{className:Be("chip-peek",t),anchor:l,placement:SD(i==="left"?"right":"left"),track:!0,children:n}):null}function Zg({className:e,label:t,tip:n,peek:r,full:o,menu:i,removeLabel:l,onRemove:u}){const c=S.useRef(null),[h,p]=S.useState(!1),g=on("chat"),m=o!==void 0;return f.jsxs("div",{ref:c,className:Be("pick-chip row row-sm",e),"data-tip":m?"Open full size":n,"data-tip-placement":"follow",...g.contextMenu(()=>i({open:m?()=>p(!0):void 0,remove:u})),children:[m?f.jsx("button",{type:"button",className:"chip-link",onClick:()=>p(!0),children:t}):t,u&&f.jsx(Lt,{icon:"close",label:l,tone:"quiet",onClick:u}),m&&r!==void 0&&f.jsx(p_,{chip:c,children:r}),h&&m&&f.jsx(Ug,{owner:"chat",onClose:()=>p(!1),menu:()=>i(),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 U0(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 ND(e){if(Array.isArray(e))return e}function TD(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,i,l,u=[],c=!0,h=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(c=(r=i.call(n)).done)&&(u.push(r.value),u.length!==t);c=!0);}catch(p){h=!0,o=p}finally{try{if(!c&&n.return!=null&&(l=n.return(),Object(l)!==l))return}finally{if(h)throw o}}return u}}function jD(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
128
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function CD(e,t){return ND(e)||TD(e,t)||AD(e,t)||jD()}function AD(e,t){if(e){if(typeof e=="string")return U0(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)?U0(e,t):void 0}}const m_=Object.entries,H0=Object.setPrototypeOf,ID=Object.isFrozen,RD=Object.getPrototypeOf,$D=Object.getOwnPropertyDescriptor;let ar=Object.freeze,mr=Object.seal,ba=Object.create,g_=typeof Reflect<"u"&&Reflect,km=g_.apply,ym=g_.construct;ar||(ar=function(t){return t});mr||(mr=function(t){return t});km||(km=function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];return t.apply(n,o)});ym||(ym=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 Ai=rr(Array.prototype.forEach),OD=rr(Array.prototype.lastIndexOf),W0=rr(Array.prototype.pop),Rl=rr(Array.prototype.push),MD=rr(Array.prototype.splice),$a=Array.isArray,zl=rr(String.prototype.toLowerCase),wp=rr(String.prototype.toString),K0=rr(String.prototype.match),$l=rr(String.prototype.replace),Z0=rr(String.prototype.indexOf),LD=rr(String.prototype.trim),PD=rr(Number.prototype.toString),DD=rr(Boolean.prototype.toString),q0=typeof BigInt>"u"?null:rr(BigInt.prototype.toString),G0=typeof Symbol>"u"?null:rr(Symbol.prototype.toString),qr=rr(Object.prototype.hasOwnProperty),Ol=rr(Object.prototype.toString),Nr=rr(RegExp.prototype.test),Ci=zD(TypeError);function rr(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 km(e,t,r)}}function zD(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return ym(e,n)}}function tn(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:zl;if(H0&&H0(e,null),!$a(t))return e;let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const i=n(o);i!==o&&(ID(t)||(t[r]=i),o=i)}e[o]=!0}return e}function FD(e){for(let t=0;t<e.length;t++)qr(e,t)||(e[t]=null);return e}function io(e){const t=ba(null);for(const r of m_(e)){var n=CD(r,2);const o=n[0],i=n[1];qr(e,o)&&($a(i)?t[o]=FD(i):i&&typeof i=="object"&&i.constructor===Object?t[o]=io(i):t[o]=i)}return t}function BD(e){switch(typeof e){case"string":return e;case"number":return PD(e);case"boolean":return DD(e);case"bigint":return q0?q0(e):"0";case"symbol":return G0?G0(e):"Symbol()";case"undefined":return Ol(e);case"function":case"object":{if(e===null)return Ol(e);const t=e,n=$o(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:Ol(r)}return Ol(e)}default:return Ol(e)}}function $o(e,t){for(;e!==null;){const r=$D(e,t);if(r){if(r.get)return rr(r.get);if(typeof r.value=="function")return rr(r.value)}e=RD(e)}function n(){return null}return n}function UD(e){try{return Nr(e,""),!0}catch{return!1}}const V0=ar(["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"]),vp=ar(["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"]),bp=ar(["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"]),HD=ar(["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"]),xp=ar(["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"]),WD=ar(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Y0=ar(["#text"]),Q0=ar(["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"]),Ep=ar(["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"]),X0=ar(["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"]),Gu=ar(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),KD=mr(/{{[\w\W]*|^[\w\W]*}}/g),ZD=mr(/<%[\w\W]*|^[\w\W]*%>/g),qD=mr(/\${[\w\W]*/g),GD=mr(/^data-[\-\w.\u00B7-\uFFFF]+$/),VD=mr(/^aria-[\-\w]+$/),J0=mr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),YD=mr(/^(?:\w+script|data):/i),QD=mr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),XD=mr(/^html$/i),JD=mr(/^[a-z][.\w]*(-[.\w]+)+$/i),eb=mr(/<[/\w!]/g),tb=mr(/<[/\w]/g),ez=mr(/<\/no(script|embed|frames)/i),tz=mr(/\/>/i),so={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},k_=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],nz=ar(tn({},k_)),rz=(function(){const e={};return Ai(k_,t=>{e[t]=mr(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),ar(e)})(),oz=function(){return typeof window>"u"?null:window},sz=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 i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},nb=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Zs=function(t,n,r,o){return qr(t,n)&&$a(t[n])?tn(o.base?io(o.base):{},t[n],o.transform):r},_p=function(t,n,r){const o=qr(t,n)?t[n]:void 0;return o&&typeof o=="object"?io(o):r()};function y_(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:oz();const t=Ee=>y_(Ee);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==so.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,o=r.currentScript;e.DocumentFragment;const i=e.HTMLTemplateElement,l=e.Node,u=e.Element,c=e.NodeFilter,h=e.NamedNodeMap;h===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const p=e.DOMParser,g=e.trustedTypes,m=u.prototype,y=$o(m,"cloneNode"),w=$o(m,"remove"),b=$o(m,"nextSibling"),E=$o(m,"childNodes"),N=$o(m,"parentNode"),j=$o(m,"shadowRoot"),T=$o(m,"attributes"),O=l&&l.prototype?$o(l.prototype,"nodeType"):null,U=l&&l.prototype?$o(l.prototype,"nodeName"):null,Q=l&&l.prototype?$o(l.prototype,"ownerDocument"):null,R=function($){return O?O($):$.nodeType},I=function($){return U?U($):$.nodeName};if(typeof i=="function"){const Ee=n.createElement("template");Ee.content&&Ee.content.ownerDocument&&(n=Ee.content.ownerDocument)}let _,L="",z,F=!1,ee=0;const se=function(){if(ee>0)throw Ci('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.')},fe=function($){se(),ee++;try{return _.createHTML($)}finally{ee--}},ke=function($){se(),ee++;try{return _.createScriptURL($)}finally{ee--}},ne=function(){return F||(z=sz(g,o),F=!0),z},A=n,q=A.implementation,ie=A.createNodeIterator,P=A.createDocumentFragment,W=A.getElementsByTagName,xe=r.importNode;let ce=nb();t.isSupported=typeof m_=="function"&&typeof N=="function"&&q&&q.createHTMLDocument!==void 0;const me=KD,_e=ZD,ae=qD,be=GD,ze=VD,re=YD,he=QD,pe=JD;let Te=J0,Ue=null;const ct=tn({},[...V0,...vp,...bp,...xp,...Y0]);let We=null;const xn=tn({},[...Q0,...Ep,...X0,...Gu]);let Ht=Object.seal(ba(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}})),It=null,nt=null;const Ve=Object.seal(ba(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let mt=!0,En=!0,Rt=!1,V=!0,ge=!1,ft=!0,qe=!1,un=!1,yn=null,Tn=null,gt=!1,jn=!1,ye=!1,Le=!1,wn=!0,_n=!1;const Sn="user-content-";let sn=!0,In=!1,ot={},Wt=null;const Qt=tn({},["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 B=null;const ue=tn({},["audio","video","img","source","image","track"]);let Ie=null;const Je=tn({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ot="http://www.w3.org/1998/Math/MathML",$t="http://www.w3.org/2000/svg",Oe="http://www.w3.org/1999/xhtml";let Me=Oe,Ye=!1,Pt=null;const X=tn({},[Ot,$t,Oe],wp),$e=ar(["mi","mo","mn","ms","mtext"]);let kt=tn({},$e);const Nt=ar(["annotation-xml"]);let Dt=tn({},Nt);const an=tn({},["title","style","font","a","script"]);let Mt=null;const zt=["application/xhtml+xml","text/html"],Vt="text/html";let Qe=null,vn=null;const pn=n.createElement("form"),Rn=function($){return $ instanceof RegExp||$ instanceof Function},dn=function(){let $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(vn&&vn===$)return;(!$||typeof $!="object")&&($={}),$=io($),Mt=zt.indexOf($.PARSER_MEDIA_TYPE)===-1?Vt:$.PARSER_MEDIA_TYPE,Qe=Mt==="application/xhtml+xml"?wp:zl,Ue=Zs($,"ALLOWED_TAGS",ct,{transform:Qe}),We=Zs($,"ALLOWED_ATTR",xn,{transform:Qe}),Pt=Zs($,"ALLOWED_NAMESPACES",X,{transform:wp}),Ie=Zs($,"ADD_URI_SAFE_ATTR",Je,{transform:Qe,base:Je}),B=Zs($,"ADD_DATA_URI_TAGS",ue,{transform:Qe,base:ue}),Wt=Zs($,"FORBID_CONTENTS",Qt,{transform:Qe}),It=Zs($,"FORBID_TAGS",io({}),{transform:Qe}),nt=Zs($,"FORBID_ATTR",io({}),{transform:Qe}),ot=qr($,"USE_PROFILES")?$.USE_PROFILES&&typeof $.USE_PROFILES=="object"?io($.USE_PROFILES):$.USE_PROFILES:!1,mt=$.ALLOW_ARIA_ATTR!==!1,En=$.ALLOW_DATA_ATTR!==!1,Rt=$.ALLOW_UNKNOWN_PROTOCOLS||!1,V=$.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ge=$.SAFE_FOR_TEMPLATES||!1,ft=$.SAFE_FOR_XML!==!1,qe=$.WHOLE_DOCUMENT||!1,jn=$.RETURN_DOM||!1,ye=$.RETURN_DOM_FRAGMENT||!1,Le=$.RETURN_TRUSTED_TYPE||!1,gt=$.FORCE_BODY||!1,wn=$.SANITIZE_DOM!==!1,_n=$.SANITIZE_NAMED_PROPS||!1,sn=$.KEEP_CONTENT!==!1,In=$.IN_PLACE||!1,Te=UD($.ALLOWED_URI_REGEXP)?$.ALLOWED_URI_REGEXP:J0,Me=typeof $.NAMESPACE=="string"?$.NAMESPACE:Oe,kt=_p($,"MATHML_TEXT_INTEGRATION_POINTS",()=>tn({},$e)),Dt=_p($,"HTML_INTEGRATION_POINTS",()=>tn({},Nt));const D=_p($,"CUSTOM_ELEMENT_HANDLING",()=>ba(null));if(Ht=ba(null),qr(D,"tagNameCheck")&&Rn(D.tagNameCheck)&&(Ht.tagNameCheck=D.tagNameCheck),qr(D,"attributeNameCheck")&&Rn(D.attributeNameCheck)&&(Ht.attributeNameCheck=D.attributeNameCheck),qr(D,"allowCustomizedBuiltInElements")&&typeof D.allowCustomizedBuiltInElements=="boolean"&&(Ht.allowCustomizedBuiltInElements=D.allowCustomizedBuiltInElements),mr(Ht),ge&&(En=!1),ye&&(jn=!0),ot&&(Ue=tn({},Y0),We=ba(null),ot.html===!0&&(tn(Ue,V0),tn(We,Q0)),ot.svg===!0&&(tn(Ue,vp),tn(We,Ep),tn(We,Gu)),ot.svgFilters===!0&&(tn(Ue,bp),tn(We,Ep),tn(We,Gu)),ot.mathMl===!0&&(tn(Ue,xp),tn(We,X0),tn(We,Gu))),Ve.tagCheck=null,Ve.attributeCheck=null,qr($,"ADD_TAGS")&&(typeof $.ADD_TAGS=="function"?Ve.tagCheck=$.ADD_TAGS:$a($.ADD_TAGS)&&(Ue===ct&&(Ue=io(Ue)),tn(Ue,$.ADD_TAGS,Qe))),qr($,"ADD_ATTR")&&(typeof $.ADD_ATTR=="function"?Ve.attributeCheck=$.ADD_ATTR:$a($.ADD_ATTR)&&(We===xn&&(We=io(We)),tn(We,$.ADD_ATTR,Qe))),qr($,"ADD_FORBID_CONTENTS")&&$a($.ADD_FORBID_CONTENTS)&&(Wt===Qt&&(Wt=io(Wt)),tn(Wt,$.ADD_FORBID_CONTENTS,Qe)),sn&&(Ue["#text"]=!0),qe&&tn(Ue,["html","head","body"]),Ue.table&&(tn(Ue,["tbody"]),delete It.tbody),$.TRUSTED_TYPES_POLICY){if(typeof $.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ci('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof $.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ci('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const J=_;_=$.TRUSTED_TYPES_POLICY;try{L=fe("")}catch(we){throw _=J,we}}else $.TRUSTED_TYPES_POLICY===null?(_=void 0,L=""):(_===void 0&&(_=ne()),_&&typeof L=="string"&&(L=fe("")));ar&&ar($),vn=$},Bt=tn({},[...vp,...bp,...HD]),cr=tn({},[...xp,...WD]),Qr=function($,D,J){return D.namespaceURI===Oe?$==="svg":D.namespaceURI===Ot?$==="svg"&&(J==="annotation-xml"||kt[J]):!!Bt[$]},ln=function($,D,J){return D.namespaceURI===Oe?$==="math":D.namespaceURI===$t?$==="math"&&Dt[J]:!!cr[$]},rs=function($,D,J){return D.namespaceURI===$t&&!Dt[J]||D.namespaceURI===Ot&&!kt[J]?!1:!cr[$]&&(an[$]||!Bt[$])},Xr=function($){let D=N($);(!D||!D.tagName)&&(D={namespaceURI:Me,tagName:"template"});const J=zl($.tagName),we=zl(D.tagName);return Pt[$.namespaceURI]?$.namespaceURI===$t?Qr(J,D,we):$.namespaceURI===Ot?ln(J,D,we):$.namespaceURI===Oe?rs(J,D,we):!!(Mt==="application/xhtml+xml"&&Pt[$.namespaceURI]):!1},Zn=function($){Rl(t.removed,{element:$});try{N($).removeChild($)}catch{if(w($),!N($))throw Ci("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},ur=function($,D,J){try{$.removeAttributeNode(D)}catch{try{$.removeAttribute(J)}catch{}}},je=function($){Et($);const D=E($);if(D){const we=[];Ai(D,Ce=>{Rl(we,Ce)}),Ai(we,Ce=>{try{w(Ce)}catch{}})}const J=T($);if(J)for(let we=J.length-1;we>=0;--we){const Ce=J[we],He=Ce&&Ce.name;typeof He=="string"&&ur($,Ce,He)}},Fe=function($,D,J){if(!J)try{J=D.getAttributeNode($)}catch{J=null}Rl(t.removed,{attribute:J||null,from:D});try{J?D.removeAttributeNode(J):D.removeAttribute($)}catch{try{D.removeAttribute($)}catch{}}if($==="is")if(jn||ye)try{Zn(D)}catch{}else try{D.setAttribute($,"")}catch{}},lt=function($){const D=T($);if(D)for(let J=D.length-1;J>=0;--J){const we=D[J],Ce=we&&we.name;typeof Ce!="string"||We[Qe(Ce)]||ur($,we,Ce)}},Et=function($){const D=[$];for(;D.length>0;){const J=D.pop();R(J)===so.element&<(J);const Ce=E(J);if(Ce)for(let He=Ce.length-1;He>=0;--He)D.push(Ce[He])}},cn=function($,D){return ft?$==="patchsrc"?!0:$==="for"&&D!=="label"&&D!=="output":!1},mn=function($){if(!ft)return;const D=[$];for(;D.length>0;){const J=D.pop(),we=R(J);if(we===so.processingInstruction||we===so.comment&&Nr(tb,J.data)){try{w(J)}catch{}continue}if(we===so.element){const He=J,vt=Qe(I(J));try{He.hasAttribute&&He.hasAttribute("patchsrc")&&He.removeAttribute("patchsrc"),He.hasAttribute&&He.hasAttribute("for")&&cn("for",vt)&&He.removeAttribute("for")}catch{}}const Ce=E(J);if(Ce)for(let He=Ce.length-1;He>=0;--He)D.push(Ce[He])}},Z=function($){let D=null,J=null;if(gt)$="<remove></remove>"+$;else{const He=K0($,/^[\r\n\t ]+/);J=He&&He[0]}Mt==="application/xhtml+xml"&&Me===Oe&&($='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+$+"</body></html>");const we=_?fe($):$;if(Me===Oe)try{D=new p().parseFromString(we,Mt)}catch{}if(!D||!D.documentElement){D=q.createDocument(Me,"template",null);try{D.documentElement.innerHTML=Ye?L:we}catch{}}const Ce=D.body||D.documentElement;return $&&J&&Ce.insertBefore(n.createTextNode(J),Ce.childNodes[0]||null),Me===Oe?W.call(D,qe?"html":"body")[0]:qe?D.documentElement:Ce},de=function($){const D=Q?Q($):$.ownerDocument;return ie.call(D||$,$,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},De=function($){return $=$l($,me," "),$=$l($,_e," "),$=$l($,ae," "),$},ut=function($){var D;$.normalize();const J=Q?Q($):$.ownerDocument,we=ie.call(J||$,$,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let Ce=we.nextNode();for(;Ce;)Ce.data=De(Ce.data),Ce=we.nextNode();const He=(D=$.querySelectorAll)===null||D===void 0?void 0:D.call($,"template");He&&Ai(He,vt=>{Xt(vt.content)&&ut(vt.content)})},wt=function($){const D=U?U($):null;return typeof D!="string"||Qe(D)!=="form"?!1:typeof $.nodeName!="string"||typeof $.textContent!="string"||typeof $.removeChild!="function"||$.attributes!==T($)||typeof $.removeAttribute!="function"||typeof $.setAttribute!="function"||typeof $.namespaceURI!="string"||typeof $.insertBefore!="function"||typeof $.hasChildNodes!="function"||$.nodeType!==O($)||$.childNodes!==E($)},Xt=function($){if(!O||typeof $!="object"||$===null)return!1;try{return O($)===so.documentFragment}catch{return!1}},Dn=function($){if(!O||typeof $!="object"||$===null)return!1;try{return typeof O($)=="number"}catch{return!1}};function zn(Ee,$,D){Ee.length!==0&&Ai(Ee,J=>{J.call(t,$,D,vn)})}const So=function($,D){return!!(ft&&$.hasChildNodes()&&!Dn($.firstElementChild)&&Nr(eb,$.textContent)&&Nr(eb,$.innerHTML)||ft&&$.namespaceURI===Oe&&nz[D]&&(Dn($.firstElementChild)||typeof $.textContent=="string"&&Nr(rz[D],$.textContent))||$.nodeType===so.processingInstruction||ft&&$.nodeType===so.comment&&Nr(tb,$.data))},Pr=function($,D){if($ instanceof RegExp)return Nr($,D);if($ instanceof Function){for(var J=arguments.length,we=new Array(J>2?J-2:0),Ce=2;Ce<J;Ce++)we[Ce-2]=arguments[Ce];return!!$(D,...we)}return!1},Bo=function($,D,J){if(!It[D]&&dt(D)&&Pr(Ht.tagNameCheck,D))return!1;if(sn&&!Wt[D]){const we=N($),Ce=E($);if(Ce&&we){const He=Ce.length;for(let vt=He-1;vt>=0;--vt){const Ut=$===J?y(Ce[vt],!0):Ce[vt];we.insertBefore(Ut,b($))}}}return Zn($),!0},Jr=function($,D,J,we){return $.length===0?D:D===J||D===we?io(D):D},Dr=function($,D){return $===D||N($)!==null?!1:(In&&Et($),!0)},bt=function($,D){if(zn(ce.beforeSanitizeElements,$,null),Dr($,D))return!0;if(wt($))return Zn($),!0;const J=Qe(I($));if(Ue=Jr(ce.uponSanitizeElement,Ue,ct,yn),zn(ce.uponSanitizeElement,$,{tagName:J,allowedTags:Ue}),Dr($,D))return!0;if(So($,J))return Zn($),!0;if(It[J]||!(Ve.tagCheck instanceof Function&&Ve.tagCheck(J))&&!Ue[J]){const Ce=Bo($,J,D);return Ce===!1&&zn(ce.afterSanitizeElements,$,null),Ce}if(R($)===so.element&&!Xr($)||(J==="noscript"||J==="noembed"||J==="noframes")&&Nr(ez,$.innerHTML))return Zn($),!0;if(ge&&$.nodeType===so.text){const Ce=De($.textContent);$.textContent!==Ce&&(Rl(t.removed,{element:$.cloneNode()}),$.textContent=Ce)}return zn(ce.afterSanitizeElements,$,null),!1},zr=function($,D,J){if(nt[D]||cn(D,$)||wn&&(D==="id"||D==="name")&&(J in n||J in pn))return!1;const we=We[D]||Ve.attributeCheck instanceof Function&&Ve.attributeCheck(D,$);return En&&Nr(be,D)||mt&&Nr(ze,D)?!0:we?Ie[D]||Nr(Te,$l(J,he,""))||(D==="src"||D==="xlink:href"||D==="href")&&$!=="script"&&Z0(J,"data:")===0&&B[$]||Rt&&!Nr(re,$l(J,he,""))?!0:!J:dt($)&&Pr(Ht.tagNameCheck,$)&&Pr(Ht.attributeNameCheck,D,$)||D==="is"&&Ht.allowCustomizedBuiltInElements&&Pr(Ht.tagNameCheck,J)},Kt=tn({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),dt=function($){return!Kt[zl($)]&&Nr(pe,$)},Uo=function($,D,J,we){if(_&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!J)switch(g.getAttributeType($,D)){case"TrustedHTML":return fe(we);case"TrustedScriptURL":return ke(we)}return we},fn=function($,D,J,we){try{J?$.setAttributeNS(J,D,we):$.setAttribute(D,we),wt($)?Zn($):W0(t.removed)}catch{Fe(D,$)}},Gt=function($){zn(ce.beforeSanitizeAttributes,$,null);const D=$.attributes;if(!D||wt($))return;We=Jr(ce.uponSanitizeAttribute,We,xn,Tn);const J={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:We,forceKeepAttr:void 0};let we=D.length;const Ce=Qe($.nodeName);for(;we--;){const He=D[we],vt=He.name,Ut=He.namespaceURI,Xn=He.value,Gn=Qe(vt),os=Xn;let Vn=vt==="value"?os:LD(os);if(J.attrName=Gn,J.attrValue=Vn,J.keepAttr=!0,J.forceKeepAttr=void 0,zn(ce.uponSanitizeAttribute,$,J),Vn=J.attrValue,_n&&(Gn==="id"||Gn==="name")&&Z0(Vn,Sn)!==0&&(Fe(vt,$,He),Vn=Sn+Vn),ft&&Nr(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Vn)){Fe(vt,$,He);continue}if(Gn==="attributename"&&K0(Vn,"href")){Fe(vt,$,He);continue}if(!J.forceKeepAttr){if(!J.keepAttr){Fe(vt,$,He);continue}if(!V&&Nr(tz,Vn)){Fe(vt,$,He);continue}if(ge&&(Vn=De(Vn)),!zr(Ce,Gn,Vn)){Fe(vt,$,He);continue}Vn=Uo(Ce,Gn,Ut,Vn),Vn!==os&&fn($,vt,Ut,Vn)}}zn(ce.afterSanitizeAttributes,$,null)},gr=function($){let D=null;const J=de($);for(zn(ce.beforeSanitizeShadowDOM,$,null);D=J.nextNode();)if(zn(ce.uponSanitizeShadowNode,D,null),bt(D,$),Gt(D),Xt(D.content)&&gr(D.content),R(D)===so.element){const we=j(D);Xt(we)&&(qn(we),gr(we))}zn(ce.afterSanitizeShadowDOM,$,null)},qn=function($){const D=[{node:$,shadow:null}];for(;D.length>0;){const J=D.pop();if(J.shadow){gr(J.shadow);continue}const we=J.node,He=R(we)===so.element,vt=E(we);if(vt)for(let Ut=vt.length-1;Ut>=0;--Ut)D.push({node:vt[Ut],shadow:null});if(He){const Ut=U?U(we):null;if(typeof Ut=="string"&&Qe(Ut)==="template"){const Xn=we.content;Xt(Xn)&&D.push({node:Xn,shadow:null})}}if(He){const Ut=j(we);Xt(Ut)&&D.push({node:null,shadow:Ut},{node:Ut,shadow:null})}}};return t.sanitize=function(Ee){let $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},D=null,J=null,we=null,Ce=null;if(Ye=!Ee,Ye&&(Ee="<!-->"),typeof Ee!="string"&&!Dn(Ee)&&(Ee=BD(Ee),typeof Ee!="string"))throw Ci("dirty is not a string, aborting");if(!t.isSupported)return Ee;un?(Ue=yn,We=Tn):dn($),(ce.uponSanitizeElement.length>0||ce.uponSanitizeAttribute.length>0)&&(Ue=io(Ue)),ce.uponSanitizeAttribute.length>0&&(We=io(We)),t.removed=[];const He=In&&typeof Ee!="string"&&Dn(Ee);if(He){mn(Ee);const Xn=I(Ee);if(typeof Xn=="string"){const Gn=Qe(Xn);if(!Ue[Gn]||It[Gn])throw je(Ee),Ci("root node is forbidden and cannot be sanitized in-place")}if(wt(Ee))throw je(Ee),Ci("root node is clobbered and cannot be sanitized in-place");try{qn(Ee)}catch(Gn){throw je(Ee),Gn}}else if(Dn(Ee))D=Z("<!---->"),J=D.ownerDocument.importNode(Ee,!0),J.nodeType===so.element&&J.nodeName==="BODY"||J.nodeName==="HTML"?D=J:D.appendChild(J),qn(J);else{if(!jn&&!ge&&!qe&&Ee.indexOf("<")===-1)return _&&Le?fe(Ee):Ee;if(D=Z(Ee),!D)return jn?null:Le?L:""}D&>&&Zn(D.firstChild);const vt=He?Ee:D;try{const Xn=de(vt);for(;we=Xn.nextNode();)bt(we,vt),Gt(we),Xt(we.content)&&gr(we.content)}catch(Xn){throw He&&(je(Ee),Ai(t.removed,Gn=>{Gn.element&&Et(Gn.element)})),Xn}if(He)return Ai(t.removed,Xn=>{Xn.element&&Et(Xn.element)}),ge&&ut(Ee),Ee;if(jn){if(ge&&ut(D),ye)for(Ce=P.call(D.ownerDocument);D.firstChild;)Ce.appendChild(D.firstChild);else Ce=D;return(We.shadowroot||We.shadowrootmode)&&(Ce=xe.call(r,Ce,!0)),Ce}let Ut=qe?D.outerHTML:D.innerHTML;return qe&&Ue["!doctype"]&&D.ownerDocument&&D.ownerDocument.doctype&&D.ownerDocument.doctype.name&&Nr(XD,D.ownerDocument.doctype.name)&&(Ut="<!DOCTYPE "+D.ownerDocument.doctype.name+`>
|
|
129
|
+
`+Ut),ge&&(Ut=De(Ut)),_&&Le?fe(Ut):Ut},t.setConfig=function(){let Ee=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};dn(Ee),un=!0,yn=Ue,Tn=We},t.clearConfig=function(){vn=null,un=!1,yn=null,Tn=null,_=z,L=""},t.isValidAttribute=function(Ee,$,D){vn||dn({});const J=Qe(Ee),we=Qe($);return zr(J,we,D)},t.addHook=function(Ee,$){typeof $=="function"&&qr(ce,Ee)&&Rl(ce[Ee],$)},t.removeHook=function(Ee,$){if(qr(ce,Ee)){if($!==void 0){const D=OD(ce[Ee],$);return D===-1?void 0:MD(ce[Ee],D,1)[0]}return W0(ce[Ee])}},t.removeHooks=function(Ee){qr(ce,Ee)&&(ce[Ee]=[])},t.removeAllHooks=function(){ce=nb()},t}var iz=y_();function qg(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ki=qg();function w_(e){Ki=e}var Ii={exec:()=>null};function ya(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 qt(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(o,i)=>{let l=typeof i=="string"?i:i.source;return l=l.replace(Cr.caret,"$1"),n=n.replace(o,l),r},getRegex:()=>new RegExp(n,t)};return r}var az=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Cr={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:ya(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:ya(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:ya(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:ya(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:ya(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:ya(e=>new RegExp(`^ {0,${e}}>`))},lz=/^(?:[ \t]*(?:\n|$))+/,cz=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,uz=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Sc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,dz=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Gg=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,v_=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,b_=qt(v_).replace(/bull/g,Gg).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(),fz=qt(v_).replace(/bull/g,Gg).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(),Vg=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,hz=/^[^\n]+/,Yg=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,pz=qt(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Yg).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),mz=qt(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Gg).getRegex(),kf="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",Qg=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,gz=qt("^ {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",Qg).replace("tag",kf).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),x_=e=>qt(Vg).replace("hr",Sc).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",kf).getRegex(),kz=x_(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),yz=x_(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),wz=qt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",yz).getRegex(),Xg={blockquote:wz,code:cz,def:pz,fences:uz,heading:dz,hr:Sc,html:gz,lheading:b_,list:mz,newline:lz,paragraph:kz,table:Ii,text:hz},rb=qt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Sc).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",kf).getRegex(),vz={...Xg,lheading:fz,table:rb,paragraph:qt(Vg).replace("hr",Sc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",rb).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",kf).getRegex()},bz={...Xg,html:qt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Qg).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:Ii,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:qt(Vg).replace("hr",Sc).replace("heading",` *#{1,6} *[^
|
|
130
|
+
]`).replace("lheading",b_).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},xz=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ez=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,E_=/^( {2,}|\\)\n(?!\s*$)/,_z=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ts=/[\p{P}\p{S}]/u,Ya=/[\s\p{P}\p{S}]/u,Nc=/[^\s\p{P}\p{S}]/u,Sz=qt(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ya).getRegex(),Nz=/[\p{Pi}\p{Ps}"']/u,__=/(?!~)[\p{P}\p{S}]/u,Tz=/(?!~)[\s\p{P}\p{S}]/u,jz=/(?:[^\s\p{P}\p{S}]|~)/u,Cz=qt(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",az?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),S_=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Az=qt(S_,"u").replace(/punct/g,Ts).getRegex(),Iz=qt(S_,"u").replace(/punct/g,__).getRegex(),Rz=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,$z=qt(Rz,"u").replace(/openQuote/g,Nz).replace(/punct/g,Ts).getRegex(),N_="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Oz=qt(N_,"gu").replace(/notPunctSpace/g,Nc).replace(/punctSpace/g,Ya).replace(/punct/g,Ts).getRegex(),Mz=qt(N_,"gu").replace(/notPunctSpace/g,jz).replace(/punctSpace/g,Tz).replace(/punct/g,__).getRegex(),Lz="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",Pz=qt(Lz,"gu").replace(/notPunctSpace/g,Nc).replace(/punctSpace/g,Ya).replace(/punct/g,Ts).getRegex(),Dz=qt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Nc).replace(/punctSpace/g,Ya).replace(/punct/g,Ts).getRegex(),zz="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",Fz=qt(zz,"gu").replace(/notPunctSpace/g,Nc).replace(/punctSpace/g,Ya).replace(/punct/g,Ts).getRegex(),Bz=qt(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ts).getRegex(),Uz="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Hz=qt(Uz,"gu").replace(/notPunctSpace/g,Nc).replace(/punctSpace/g,Ya).replace(/punct/g,Ts).getRegex(),Wz=qt(/\\(punct)/,"gu").replace(/punct/g,Ts).getRegex(),Kz=qt(/^<(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(),Zz=qt(Qg).replace("(?:-->|$)","-->").getRegex(),qz=qt("^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",Zz).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Nd=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Gz=qt(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Nd).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),T_=qt(/^!?\[(label)\]\[(ref)\]/).replace("label",Nd).replace("ref",Yg).getRegex(),j_=qt(/^!?\[(ref)\](?:\[\])?/).replace("ref",Yg).getRegex(),Vz=qt("reflink|nolink(?!\\()","g").replace("reflink",T_).replace("nolink",j_).getRegex(),ob=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Jg={_backpedal:Ii,anyPunctuation:Wz,autolink:Kz,blockSkip:Cz,br:E_,code:Ez,del:Ii,delLDelim:Ii,delRDelim:Ii,emStrongLDelim:Az,emStrongRDelimAst:Oz,emStrongRDelimUnd:Dz,escape:xz,link:Gz,nolink:j_,punctuation:Sz,reflink:T_,reflinkSearch:Vz,tag:qz,text:_z,url:Ii},Yz={...Jg,emStrongLDelim:$z,emStrongRDelimAst:Pz,emStrongRDelimUnd:Fz,link:qt(/^!?\[(label)\]\((.*?)\)/).replace("label",Nd).getRegex(),reflink:qt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Nd).getRegex()},wm={...Jg,emStrongRDelimAst:Mz,emStrongLDelim:Iz,delLDelim:Bz,delRDelim:Hz,url:qt(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ob).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:qt(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ob).getRegex()},Qz={...wm,br:qt(E_).replace("{2,}","*").getRegex(),text:qt(wm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Vu={normal:Xg,gfm:vz,pedantic:bz},Ml={normal:Jg,gfm:wm,breaks:Qz,pedantic:Yz},Xz={"&":"&","<":"<",">":">",'"':""","'":"'"},sb=e=>Xz[e];function Vo(e,t){if(t){if(Cr.escapeTest.test(e))return e.replace(Cr.escapeReplace,sb)}else if(Cr.escapeTestNoEncode.test(e))return e.replace(Cr.escapeReplaceNoEncode,sb);return e}function ib(e){try{e=encodeURI(e).replace(Cr.percentDecode,"%")}catch{return null}return e}function ab(e,t){var i;let n=e.replace(Cr.findPipe,(l,u,c)=>{let h=!1,p=u;for(;--p>=0&&c[p]==="\\";)h=!h;return h?"|":" |"}),r=n.split(Cr.splitPipe),o=0;if(r[0].trim()||r.shift(),r.length>0&&!((i=r.at(-1))!=null&&i.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(Cr.slashPipe,"|");return r}function qs(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 lb(e){let t=e.split(`
|
|
131
|
+
`),n=t.length-1;for(;n>=0&&Cr.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
132
|
+
`)}function Jz(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 e3(e,t=0){let n=t,r="";for(let o of e)if(o===" "){let i=4-n%4;r+=" ".repeat(i),n+=i}else r+=o,n++;return r}function cb(e,t,n,r,o){let i=t.href,l=t.title||null,u=e[1].replace(o.other.outputLinkReplace,"$1"),c=e[0].charAt(0)==="!";r.state.inLink=!0;let h=r.state.linkEmitted,p=r.state.inRawBlock;r.state.linkEmitted=!1;let g=r.inlineTokens(u),m=r.state.linkEmitted;if(r.state.linkEmitted=h,r.state.inLink=!1,!c){if(m){r.state.inRawBlock=p;return}r.state.linkEmitted=!0}return{type:c?"image":"link",raw:n,href:i,title:l,text:u,tokens:g}}function t3(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let o=r[1];return t.split(`
|
|
133
|
+
`).map(i=>{let l=i.match(n.other.beginningSpace);if(l===null)return i;let[u]=l;return u.length>=o.length?i.slice(o.length):i}).join(`
|
|
134
|
+
`)}var Td=class{constructor(e){jt(this,"options");jt(this,"rules");jt(this,"lexer");this.options=e||Ki}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]:lb(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=t3(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=qs(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:qs(t[0],`
|
|
135
|
+
`),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:qs(t[0],`
|
|
136
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=qs(t[0],`
|
|
137
|
+
`).split(`
|
|
138
|
+
`),r="",o="",i=[];for(;n.length>0;){let l=!1,u=[],c;for(c=0;c<n.length;c++)if(this.rules.other.blockquoteStart.test(n[c]))u.push(n[c]),l=!0;else if(!l)u.push(n[c]);else break;n=n.slice(c);let h=u.join(`
|
|
139
|
+
`),p=h.replace(this.rules.other.blockquoteSetextReplace,`
|
|
140
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
141
|
+
${h}`:h,o=o?`${o}
|
|
142
|
+
${p}`:p;let g=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,i,!0),this.lexer.state.top=g,n.length===0)break;let m=i.at(-1);if((m==null?void 0:m.type)==="code")break;if((m==null?void 0:m.type)==="blockquote"){let y=m,w=n.join(`
|
|
143
|
+
`),b=y.raw+`
|
|
144
|
+
`+w.replace(this.rules.other.blockquoteSetextReplace2,""),E=this.blockquote(b);i[i.length-1]=E,r=`${r}
|
|
145
|
+
${w}`,o=o.substring(0,o.length-y.text.length)+E.text;break}else if((m==null?void 0:m.type)==="list"){let y=m,w=y.raw+`
|
|
146
|
+
`+n.join(`
|
|
147
|
+
`),b=this.list(w);i[i.length-1]=b,r=r.substring(0,r.length-m.raw.length)+b.raw,o=o.substring(0,o.length-y.raw.length)+b.raw,n=w.substring(i.at(-1).raw.length).split(`
|
|
148
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:i,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 i=this.rules.other.listItemRegex(n),l=!1;for(;e;){let c=!1,h="",p="";if(!(t=i.exec(e))||this.rules.block.hr.test(e))break;h=t[0],e=e.substring(h.length);let g=e3(t[2].split(`
|
|
149
|
+
`,1)[0],t[1].length),m=e.split(`
|
|
150
|
+
`,1)[0],y=!g.trim(),w=0;if(this.options.pedantic?(w=2,p=g.trimStart()):y?w=t[1].length+1:(w=g.search(this.rules.other.nonSpaceChar),w=w>4?1:w,p=g.slice(w),w+=t[1].length),y&&this.rules.other.blankLine.test(m)&&(h+=m+`
|
|
151
|
+
`,e=e.substring(m.length+1),c=!0),!c){let b=this.rules.other.nextBulletRegex(w),E=this.rules.other.hrRegex(w),N=this.rules.other.fencesBeginRegex(w),j=this.rules.other.headingBeginRegex(w),T=this.rules.other.htmlBeginRegex(w),O=this.rules.other.blockquoteBeginRegex(w);for(;e;){let U=e.split(`
|
|
152
|
+
`,1)[0],Q;if(m=U,this.options.pedantic?(m=m.replace(this.rules.other.listReplaceNesting," "),Q=m):Q=m.replace(this.rules.other.tabCharGlobal," "),N.test(m)||j.test(m)||T.test(m)||O.test(m)||b.test(m)||E.test(m))break;if(Q.search(this.rules.other.nonSpaceChar)>=w||!m.trim())p+=`
|
|
153
|
+
`+Q.slice(w);else{if(y||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||N.test(g)||j.test(g)||E.test(g))break;p+=`
|
|
154
|
+
`+m}y=!m.trim(),h+=U+`
|
|
155
|
+
`,e=e.substring(U.length+1),g=Q.slice(w)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(l=!0)),o.items.push({type:"list_item",raw:h,task:!!this.options.gfm&&this.rules.other.listIsTask.test(p),loose:!1,text:p,tokens:[]}),o.raw+=h}let u=o.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let c of o.items)if(this.lexer.state.top=!1,c.tokens=this.lexer.blockTokens(c.text,[]),!o.loose){let h=c.tokens.filter(g=>g.type==="space"),p=h.length>0&&h.some(g=>this.rules.other.anyLine.test(g.raw));o.loose=p}for(let c of o.items){let h=c.tokens[0];if(c.task&&((h==null?void 0:h.type)==="text"||(h==null?void 0:h.type)==="paragraph")){c.text=c.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 g=this.lexer.inlineQueue.length-1;g>=0;g--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[g].src)){this.lexer.inlineQueue[g].src=this.lexer.inlineQueue[g].src.replace(this.rules.other.listReplaceTask,"");break}let p=this.rules.other.listTaskCheckbox.exec(c.raw);if(p){let g={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};c.checked=g.checked,o.loose?c.tokens[0]&&["paragraph","text"].includes(c.tokens[0].type)&&"tokens"in c.tokens[0]&&c.tokens[0].tokens?(c.tokens[0].raw=g.raw+c.tokens[0].raw,c.tokens[0].text=g.raw+c.tokens[0].text,c.tokens[0].tokens.unshift(g)):c.tokens.unshift({type:"paragraph",raw:g.raw,text:g.raw,tokens:[g]}):c.tokens.unshift(g)}}else c.task&&(c.task=!1)}if(o.loose)for(let c of o.items){c.loose=!0;for(let h of c.tokens)h.type==="text"&&(h.type="paragraph")}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=lb(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:qs(t[0],`
|
|
156
|
+
`),href:r,title:o}}}table(e){var l;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=ab(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=(l=t[3])!=null&&l.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
157
|
+
`):[],i={type:"table",raw:qs(t[0],`
|
|
158
|
+
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let u of r)this.rules.other.tableAlignRight.test(u)?i.align.push("right"):this.rules.other.tableAlignCenter.test(u)?i.align.push("center"):this.rules.other.tableAlignLeft.test(u)?i.align.push("left"):i.align.push(null);for(let u=0;u<n.length;u++)i.header.push({text:n[u],tokens:this.lexer.inline(n[u]),header:!0,align:i.align[u]});for(let u of o)i.rows.push(ab(u,i.header.length).map((c,h)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:i.align[h]})));return i}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:qs(t[0],`
|
|
159
|
+
`),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)===`
|
|
160
|
+
`?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 i=qs(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=Jz(t[2],"()");if(i===-2)return;if(i>-1){let l=(t[0].indexOf("!")===0?5:4)+t[1].length+i;t[2]=t[2].substring(0,i),t[0]=t[0].substring(0,l).trim(),t[3]=""}}let r=t[2],o="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(r);i&&(r=i[1],o=i[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)),cb(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 i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return cb(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,i,l,u=o,c=0,h=r[0][0],p=n===h,g=h==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(g.lastIndex=0,t=t.slice(-1*e.length+o);(r=g.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(l=[...i].length,r[3]||r[4]){u+=l;continue}else if(r[5]||r[6]){if(o%3&&!((o+l)%3)){c+=l;continue}if(p)break}if(u-=l,u>0)continue;l=Math.min(l,l+u+c);let m=[...r[0]][0].length,y=e.slice(0,o+r.index+m+l);if(Math.min(o,l)%2){let b=y.slice(1,-1);return{type:"em",raw:y,text:b,tokens:this.lexer.inlineTokens(b)}}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,i,l,u=o,c=this.rules.inline.delRDelim;for(c.lastIndex=0,t=t.slice(-1*e.length+o);(r=c.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(l=[...i].length,l!==o))continue;if(r[3]||r[4]){u+=l;continue}if(u-=l,u>0)continue;l=Math.min(l,l+u);let h=[...r[0]][0].length,p=e.slice(0,o+r.index+h+l),g=p.slice(o,-o);return{type:"del",raw:p,text:g,tokens:this.lexer.inlineTokens(g)}}}}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 i;do i=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(i!==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}}}},Mo=class vm{constructor(t){jt(this,"tokens");jt(this,"options");jt(this,"state");jt(this,"inlineQueue");jt(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ki,this.options.tokenizer=this.options.tokenizer||new Td,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:Cr,block:Vu.normal,inline:Ml.normal};this.options.pedantic?(n.block=Vu.pedantic,n.inline=Ml.pedantic):this.options.gfm&&(n.block=Vu.gfm,this.options.breaks?n.inline=Ml.breaks:n.inline=Ml.gfm),this.tokenizer.rules=n}static get rules(){return{block:Vu,inline:Ml}}static lex(t,n){return new vm(n).lex(t)}static lexInline(t,n){return new vm(n).inlineTokens(t)}lex(t){t=t.replace(Cr.carriageReturn,`
|
|
161
|
+
`),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 i,l,u;this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(Cr.tabCharGlobal," ").replace(Cr.spaceLine,""));let o=1/0;for(;t;){if(t.length<o)o=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let c;if((l=(i=this.options.extensions)==null?void 0:i.block)!=null&&l.some(p=>(c=p.call({lexer:this},t,n))?(t=t.substring(c.raw.length),n.push(c),!0):!1))continue;if(c=this.tokenizer.space(t)){t=t.substring(c.raw.length);let p=n.at(-1);c.raw.length===1&&p!==void 0?p.raw+=`
|
|
162
|
+
`:n.push(c);continue}if(c=this.tokenizer.code(t)){t=t.substring(c.raw.length);let p=n.at(-1);(p==null?void 0:p.type)==="paragraph"||(p==null?void 0:p.type)==="text"?(p.raw+=(p.raw.endsWith(`
|
|
163
|
+
`)?"":`
|
|
164
|
+
`)+c.raw,p.text+=`
|
|
165
|
+
`+c.text,this.inlineQueue.at(-1).src=p.text):n.push(c);continue}if(c=this.tokenizer.fences(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.heading(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.hr(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.blockquote(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.list(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.html(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.def(t)){t=t.substring(c.raw.length);let p=n.at(-1);(p==null?void 0:p.type)==="paragraph"||(p==null?void 0:p.type)==="text"?(p.raw+=(p.raw.endsWith(`
|
|
166
|
+
`)?"":`
|
|
167
|
+
`)+c.raw,p.text+=`
|
|
168
|
+
`+c.raw,this.inlineQueue.at(-1).src=p.text):this.tokens.links[c.tag]||(this.tokens.links[c.tag]={href:c.href,title:c.title},n.push(c));continue}if(c=this.tokenizer.table(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.lheading(t)){t=t.substring(c.raw.length),n.push(c);continue}let h=t;if((u=this.options.extensions)!=null&&u.startBlock){let p=1/0,g=t.slice(1),m;this.options.extensions.startBlock.forEach(y=>{m=y.call({lexer:this},g),typeof m=="number"&&m>=0&&(p=Math.min(p,m))}),p<1/0&&p>=0&&(h=t.substring(0,p+1))}if(this.state.top&&(c=this.tokenizer.paragraph(h))){let p=n.at(-1);r&&(p==null?void 0:p.type)==="paragraph"?(p.raw+=(p.raw.endsWith(`
|
|
169
|
+
`)?"":`
|
|
170
|
+
`)+c.raw,p.text+=`
|
|
171
|
+
`+c.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=p.text):n.push(c),r=h.length!==t.length,t=t.substring(c.raw.length);continue}if(c=this.tokenizer.text(t)){t=t.substring(c.raw.length);let p=n.at(-1);(p==null?void 0:p.type)==="text"?(p.raw+=(p.raw.endsWith(`
|
|
172
|
+
`)?"":`
|
|
173
|
+
`)+c.raw,p.text+=`
|
|
174
|
+
`+c.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=p.text):n.push(c);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],i=o.lastIndexOf("[");if(!(o.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,o.slice(i+1,-1)))&&!(i>1&&this.linkInText(o.slice(1,i-1))))return!0}return!1}inlineTokens(t,n=[]){var u,c,h,p,g;this.tokenizer.lexer=this;let r=t;if(this.tokens.links&&t.includes("[")){let m=this.tokenizer.rules.inline.reflinkSearch,y=w=>{let b=w.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,w.slice(b+1,-1)))return w;if(b>1&&w.charAt(0)!=="!"){let E=w.slice(1,b-1);if(this.linkInText(E))return"["+E.replace(m,y)+"]["+"a".repeat(w.length-b-2)+"]"}return"["+"a".repeat(w.length-2)+"]"};r=r.replace(m,y)}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,m=>"+".repeat(m.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(m,y,w)=>{let b=w?w.length:0;return m.slice(0,b)+"["+"a".repeat(m.length-b-2)+"]"}),r=((c=(u=this.options.hooks)==null?void 0:u.emStrongMask)==null?void 0:c.call({lexer:this},r))??r;let o=!1,i="",l=1/0;for(;t;){if(t.length<l)l=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}o||(i=""),o=!1;let m;if((p=(h=this.options.extensions)==null?void 0:h.inline)!=null&&p.some(w=>(m=w.call({lexer:this},t,n))?(t=t.substring(m.raw.length),n.push(m),!0):!1))continue;if(m=this.tokenizer.escape(t)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.tag(t)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.link(t)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(m.raw.length);let w=n.at(-1);m.type==="text"&&(w==null?void 0:w.type)==="text"?(w.raw+=m.raw,w.text+=m.text):n.push(m);continue}if(m=this.tokenizer.emStrong(t,r,i)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.codespan(t)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.br(t)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.del(t,r,i)){t=t.substring(m.raw.length),n.push(m);continue}if(m=this.tokenizer.autolink(t)){t=t.substring(m.raw.length),n.push(m);continue}if(!this.state.inLink&&(m=this.tokenizer.url(t))){t=t.substring(m.raw.length),n.push(m);continue}let y=t;if((g=this.options.extensions)!=null&&g.startInline){let w=1/0,b=t.slice(1),E;this.options.extensions.startInline.forEach(N=>{E=N.call({lexer:this},b),typeof E=="number"&&E>=0&&(w=Math.min(w,E))}),w<1/0&&w>=0&&(y=t.substring(0,w+1))}if(m=this.tokenizer.inlineText(y)){t=t.substring(m.raw.length),m.raw.slice(-1)!=="_"&&(i=m.raw.slice(-1)),o=!0;let w=n.at(-1);(w==null?void 0:w.type)==="text"?(w.raw+=m.raw,w.text+=m.text):n.push(m);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)}},jd=class{constructor(e){jt(this,"options");jt(this,"parser");this.options=e||Ki}space(e){return""}code({text:e,lang:t,escaped:n}){var i;let r=(i=(t||"").match(Cr.notSpaceStart))==null?void 0:i[0],o=e.replace(Cr.endingNewline,"")+`
|
|
175
|
+
`;return r?'<pre><code class="language-'+Vo(r)+'">'+(n?o:Vo(o,!0))+`</code></pre>
|
|
176
|
+
`:"<pre><code>"+(n?o:Vo(o,!0))+`</code></pre>
|
|
177
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
178
|
+
${this.parser.parse(e)}</blockquote>
|
|
179
|
+
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
180
|
+
`}hr(e){return`<hr>
|
|
181
|
+
`}list(e){let t=e.ordered,n=e.start,r="";for(let l=0;l<e.items.length;l++){let u=e.items[l];r+=this.listitem(u)}let o=t?"ol":"ul",i=t&&n!==1?' start="'+n+'"':"";return"<"+o+i+`>
|
|
182
|
+
`+r+"</"+o+`>
|
|
183
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
184
|
+
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
185
|
+
`}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 i=e.rows[o];n="";for(let l=0;l<i.length;l++)n+=this.tablecell(i[l]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
186
|
+
<thead>
|
|
187
|
+
`+t+`</thead>
|
|
188
|
+
`+r+`</table>
|
|
189
|
+
`}tablerow({text:e}){return`<tr>
|
|
190
|
+
${e}</tr>
|
|
191
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
192
|
+
`}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>${Vo(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=ib(e);if(o===null)return r;e=o;let i='<a href="'+e+'"';return t&&(i+=' title="'+Vo(t)+'"'),i+=">"+r+"</a>",i}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let o=ib(e);if(o===null)return Vo(n);e=o;let i=`<img src="${e}" alt="${Vo(n)}"`;return t&&(i+=` title="${Vo(t)}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Vo(e.text)}},ek=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}},Lo=class bm{constructor(t){jt(this,"options");jt(this,"renderer");jt(this,"textRenderer");this.options=t||Ki,this.options.renderer=this.options.renderer||new jd,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ek}static parse(t,n){return new bm(n).parse(t)}static parseInline(t,n){return new bm(n).parseInline(t)}parse(t){var r,o;this.renderer.parser=this;let n="";for(let i=0;i<t.length;i++){let l=t[i];if((o=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&o[l.type]){let c=l,h=this.options.extensions.renderers[c.type].call({parser:this},c);if(h!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(c.type)){n+=h||"";continue}}let u=l;switch(u.type){case"space":{n+=this.renderer.space(u);break}case"hr":{n+=this.renderer.hr(u);break}case"heading":{n+=this.renderer.heading(u);break}case"code":{n+=this.renderer.code(u);break}case"table":{n+=this.renderer.table(u);break}case"blockquote":{n+=this.renderer.blockquote(u);break}case"list":{n+=this.renderer.list(u);break}case"checkbox":{n+=this.renderer.checkbox(u);break}case"html":{n+=this.renderer.html(u);break}case"def":{n+=this.renderer.def(u);break}case"paragraph":{n+=this.renderer.paragraph(u);break}case"text":{n+=this.renderer.text(u);break}default:{let c='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return n}parseInline(t,n=this.renderer){var o,i;this.renderer.parser=this;let r="";for(let l=0;l<t.length;l++){let u=t[l];if((i=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&i[u.type]){let h=this.options.extensions.renderers[u.type].call({parser:this},u);if(h!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(u.type)){r+=h||"";continue}}let c=u;switch(c.type){case"escape":{r+=n.text(c);break}case"html":{r+=n.html(c);break}case"link":{r+=n.link(c);break}case"image":{r+=n.image(c);break}case"checkbox":{r+=n.checkbox(c);break}case"strong":{r+=n.strong(c);break}case"em":{r+=n.em(c);break}case"codespan":{r+=n.codespan(c);break}case"br":{r+=n.br(c);break}case"del":{r+=n.del(c);break}case"text":{r+=n.text(c);break}default:{let h='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(h),"";throw new Error(h)}}}return r}},Xu,Fl=(Xu=class{constructor(e){jt(this,"options");jt(this,"block");this.options=e||Ki}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Mo.lex:Mo.lexInline}provideParser(e=this.block){return e?Lo.parse:Lo.parseInline}},jt(Xu,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),jt(Xu,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Xu),n3=class{constructor(...e){jt(this,"defaults",qg());jt(this,"options",this.setOptions);jt(this,"parse",this.parseMarkdown(!0));jt(this,"parseInline",this.parseMarkdown(!1));jt(this,"Parser",Lo);jt(this,"Renderer",jd);jt(this,"TextRenderer",ek);jt(this,"Lexer",Mo);jt(this,"Tokenizer",Td);jt(this,"Hooks",Fl);this.use(...e)}walkTokens(e,t){var r,o;let n=[];for(let i of e)switch(n=n.concat(t.call(this,i)),i.type){case"table":{let l=i;for(let u of l.header)n=n.concat(this.walkTokens(u.tokens,t));for(let u of l.rows)for(let c of u)n=n.concat(this.walkTokens(c.tokens,t));break}case"list":{let l=i;n=n.concat(this.walkTokens(l.items,t));break}default:{let l=i;(o=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&o[l.type]?this.defaults.extensions.childTokens[l.type].forEach(u=>{let c=l[u].flat(1/0);n=n.concat(this.walkTokens(c,t))}):l.tokens&&(n=n.concat(this.walkTokens(l.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 i=t.renderers[o.name];i?t.renderers[o.name]=function(...l){let u=o.renderer.apply(this,l);return u===!1&&(u=i.apply(this,l)),u}: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 i=t[o.level];i?i.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 jd(this.defaults);for(let i in n.renderer){if(!(i in o))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let l=i,u=n.renderer[l],c=o[l];o[l]=(...h)=>{let p=u.apply(o,h);return p===!1&&(p=c.apply(o,h)),p||""}}r.renderer=o}if(n.tokenizer){let o=this.defaults.tokenizer||new Td(this.defaults);for(let i in n.tokenizer){if(!(i in o))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let l=i,u=n.tokenizer[l],c=o[l];o[l]=(...h)=>{let p=u.apply(o,h);return p===!1&&(p=c.apply(o,h)),p}}r.tokenizer=o}if(n.hooks){let o=this.defaults.hooks||new Fl;for(let i in n.hooks){if(!(i in o))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let l=i,u=n.hooks[l],c=o[l];Fl.passThroughHooks.has(i)?o[l]=h=>{if(this.defaults.async&&Fl.passThroughHooksRespectAsync.has(i))return(async()=>{let g=await u.call(o,h);return c.call(o,g)})();let p=u.call(o,h);return c.call(o,p)}:o[l]=(...h)=>{if(this.defaults.async)return(async()=>{let g=await u.apply(o,h);return g===!1&&(g=await c.apply(o,h)),g})();let p=u.apply(o,h);return p===!1&&(p=c.apply(o,h)),p}}r.hooks=o}if(n.walkTokens){let o=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(l){let u=[];return u.push(i.call(this,l)),o&&(u=u.concat(o.call(this,l))),u}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Mo.lex(e,t??this.defaults)}parser(e,t){return Lo.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},o={...this.defaults,...r},i=this.onError(!!o.silent,!!o.async);if(this.defaults.async===!0&&r.async===!1)return i(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 i(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return i(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 l=o.hooks?await o.hooks.preprocess(t):t,u=await(o.hooks?await o.hooks.provideLexer(e):e?Mo.lex:Mo.lexInline)(l,o),c=o.hooks?await o.hooks.processAllTokens(u):u;o.walkTokens&&await Promise.all(this.walkTokens(c,o.walkTokens));let h=await(o.hooks?await o.hooks.provideParser(e):e?Lo.parse:Lo.parseInline)(c,o);return o.hooks?await o.hooks.postprocess(h):h})().catch(i);try{o.hooks&&(t=o.hooks.preprocess(t));let l=(o.hooks?o.hooks.provideLexer(e):e?Mo.lex:Mo.lexInline)(t,o);o.hooks&&(l=o.hooks.processAllTokens(l)),o.walkTokens&&this.walkTokens(l,o.walkTokens);let u=(o.hooks?o.hooks.provideParser(e):e?Lo.parse:Lo.parseInline)(l,o);return o.hooks&&(u=o.hooks.postprocess(u)),u}catch(l){return i(l)}}}onError(e,t){return n=>{if(n.message+=`
|
|
193
|
+
Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+Vo(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},Ui=new n3;function gn(e,t){return Ui.parse(e,t)}gn.options=gn.setOptions=function(e){return Ui.setOptions(e),gn.defaults=Ui.defaults,w_(gn.defaults),gn};gn.getDefaults=qg;gn.defaults=Ki;function r3(...e){return Ui.use(...e),gn.defaults=Ui.defaults,w_(gn.defaults),gn}gn.use=r3;gn.walkTokens=function(e,t){return Ui.walkTokens(e,t)};gn.parseInline=Ui.parseInline;gn.Parser=Lo;gn.parser=Lo.parse;gn.Renderer=jd;gn.TextRenderer=ek;gn.Lexer=Mo;gn.lexer=Mo.lex;gn.Tokenizer=Td;gn.Hooks=Fl;gn.parse=gn;gn.options;gn.setOptions;gn.walkTokens;gn.parseInline;Lo.parse;Mo.lex;const Cd=100,o3=e=>e.type==="text-delta"||e.type==="thinking-delta"||e.type==="tool-delta";function s3(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 i3={now:()=>performance.now(),after:(e,t)=>void setTimeout(t,e)};function a3(e,t=i3){let n=[],r=!1,o=Number.NEGATIVE_INFINITY;const i=()=>{if(r=!1,n.length===0)return;const l=n;n=[],o=t.now();for(const u of l)e(u)};return l=>{if(l.t==="agent"&&o3(l.event)){const u={...l,event:{...l.event}},c=t.now();if(n.length===0&&c-o>=Cd){o=c,e(u);return}const h=n[n.length-1];h&&s3(h,u)?h.event={...h.event,text:h.event.text+u.event.text}:n.push(u),r||(r=!0,t.after(Math.max(0,o+Cd-c),i));return}i(),e(l)}}const C_="#toyon-link-pending",l3=/!?\[([^[\]\n]*)(?:\]\(([^()\s]*))?$/;function c3(e){const t=e.lastIndexOf(`
|
|
194
|
+
`)+1,n=e.slice(t),r=l3.exec(n);return!r||u3(e.slice(0,t))||d3(n.slice(0,r.index))?e:`${e.slice(0,t)}${n.slice(0,r.index)}[${r[1]}](${C_})`}function u3(e){let t=!1;for(const n of e.split(`
|
|
195
|
+
`))/^\s*(```|~~~)/.test(n)&&(t=!t);return t}function d3(e){let t=0;for(const n of e)n==="`"&&t++;return t%2===1}const Sp="__[a-z][a-z0-9_]*[a-z0-9]__",f3=new RegExp(`^(?:${Sp}\\.)+${Sp}|^${Sp}(?=\\.\\w|\\(|["'])`),h3={name:"dunder",level:"inline",start:e=>e.indexOf("__"),tokenizer(e){const t=f3.exec(e);if(t)return{type:"dunder",raw:t[0],text:t[0]}},renderer:e=>e.text};function p3(e){if(e.header.some(n=>n.text.trim()))return!1;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>
|
|
196
|
+
<tbody>${t}</tbody></table>
|
|
197
|
+
`}function m3(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]},i=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),l={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},u={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,o]};o.contains.push(u);const c={match:/\\"/},h={className:"string",begin:/'/,end:/'/},p={match:/\\'/},g={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},m=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],y=e.SHEBANG({binary:`(${m.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},b=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],E=["true","false"],N={match:/(\/[a-z._-]+)+/},j=["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"],O=["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"],U=["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:b,literal:E,built_in:[...j,...T,"set","shopt",...O,...U]},contains:[y,e.SHEBANG(),w,g,i,l,N,u,c,h,p,n]}}const g3=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_-]*/}}),k3=["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"],y3=["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"],w3=[...k3,...y3],v3=["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(),b3=["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(),x3=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),E3=["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 _3(e){const t=e.regex,n=g3(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},o="and or not only",i=/@-?\w[\w]*(-\w+)*/,l="[a-zA-Z-][a-zA-Z0-9_-]*",u=[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:"\\."+l,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+b3.join("|")+")"},{begin:":(:)?("+x3.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+E3.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,n.UNICODE_RANGE,...u,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...u,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:o,attribute:v3.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...u,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+w3.join("|")+")\\b"}]}}function S3(e){const i={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:i,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:i,illegal:/["']/}]}]}}function N3(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:/\$\{(.*?)\}/}]},i={className:"literal",begin:/\bon|off|true|false|yes|no\b/},l={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},u={begin:/\[/,end:/\]/,contains:[r,i,o,l,n,"self"],relevance:0},c=/[A-Za-z0-9_-]+/,h=/"(\\"|[^"])*"/,p=/'[^']*'/,g=t.either(c,h,p),m=t.concat(g,"(\\s*\\.\\s*",g,")*",t.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:m,className:"attr",starts:{end:/$/,contains:[r,u,i,o,l,n]}}]}}const ub="[A-Za-z$_][0-9A-Za-z$_]*",T3=["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"],j3=["true","false","null","undefined","NaN","Infinity"],A_=["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"],I_=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],R_=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],C3=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],A3=[].concat(R_,A_,I_);function I3(e){const t=e.regex,n=(A,{after:q})=>{const ie="</"+A[0].slice(1);return A.input.indexOf(ie,q)!==-1},r=ub,o={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(A,q)=>{const ie=A[0].length+A.index,P=A.input[ie];if(P==="<"||P===","){q.ignoreMatch();return}P===">"&&(n(A,{after:ie})||q.ignoreMatch());let W;const xe=A.input.substring(ie);if(W=xe.match(/^\s*=/)){q.ignoreMatch();return}if((W=xe.match(/^\s+extends\s+/))&&W.index===0){q.ignoreMatch();return}}},u={$pattern:ub,keyword:T3,literal:j3,built_in:A3,"variable.language":C3},c="[0-9](_?[0-9])*",h=`\\.(${c})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",g={className:"number",variants:[{begin:`(\\b(${p})((${h})|\\.)?|(${h}))[eE][+-]?(${c})\\b`},{begin:`\\b(${p})\\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},m={className:"subst",begin:"\\$\\{",end:"\\}",keywords:u,contains:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,m],subLanguage:"xml"}},w={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,m],subLanguage:"css"}},b={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,m],subLanguage:"graphql"}},E={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,m]},j={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,b,E,{match:/\$\d+/},g];m.contains=T.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(T)});const O=[].concat(j,m.contains),U=O.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(O)}]),Q={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:U},R={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},I={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...A_,...I_]}},_={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},L={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[Q],illegal:/%/},z={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function F(A){return t.concat("(?!",A.join("|"),")")}const ee={match:t.concat(/\b/,F([...R_,"super","import","await"].map(A=>`${A}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},se={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},fe={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},Q]},ke="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",ne={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ke)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[Q]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:U,CLASS_REFERENCE:I},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),_,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,b,E,j,{match:/\$\d+/},g,I,{scope:"attr",match:r+t.lookahead(":"),relevance:0},ne,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[j,e.REGEXP_MODE,{className:"function",begin:ke,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:u,contains:U}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:i},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},L,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[Q,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},se,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[Q]},ee,z,R,fe,{match:/\$[(.]/}]}}const R3="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",$3={scope:"number",match:R3,relevance:0};function O3(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,$3,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function M3(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}]},i={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},l={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},u=/[A-Za-z][A-Za-z0-9+.-]*/,c={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,u,/:\/\/.*?\)/),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}/}]},p={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},g=e.inherit(h,{contains:[]}),m=e.inherit(p,{contains:[]});h.contains.push(m),p.contains.push(g);let y=[n,c];return[h,p,g,m].forEach(N=>{N.contains=N.contains.concat(y)}),y=y.concat(h,p),{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,i,r,h,p,{className:"quote",begin:"^>\\s+",contains:y,end:"$"},o,c,l,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function L3(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"],u={$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"]},c={className:"meta",begin:/^(>>>|\.\.\.) /},h={className:"subst",begin:/\{/,end:/\}/,keywords:u,illegal:/#/},p={begin:/\{\{/,relevance:0},g={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,c,p,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,c,p,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,p,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,p,h]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},m="[0-9](_?[0-9])*",y=`(\\b(${m}))?\\.(${m})|\\b(${m})\\.`,w=`\\b|${r.join("|")}`,b={className:"number",relevance:0,variants:[{begin:`(\\b(${m})|(${y}))[eE][+-]?(${m})[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(${m})[jJ](?=${w})`}]},E={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:u,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},N={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:["self",c,b,g,e.HASH_COMMENT_MODE]}]};return h.contains=[g,b,c],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:u,illegal:/(<\/|\?)|=>/,contains:[c,b,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},g,E,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[N]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[b,N,g]}]}}function P3(e){const t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),o=t.concat(n,e.IDENT_RE),i={scope:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!(?:let|for|while|if|else|match)\b)/,o,t.lookahead(/\s*\(/))},l="([ui](8|16|32|64|128|size)|f(16|32|64|128))?",u=["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"],c=["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!"],p=["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:p,keyword:u,literal:c,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_]+)"+l},{begin:"\\b0o([0-7_]+)"+l},{begin:"\\b0x([A-Fa-f0-9_]+)"+l},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+l}],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:p}},{scope:"punctuation",begin:"->"},i]}}const Ad="[A-Za-z$_][0-9A-Za-z$_]*",$_=["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"],O_=["true","false","null","undefined","NaN","Infinity"],M_=["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"],L_=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],P_=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],D_=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],z_=[].concat(P_,M_,L_);function D3(e){const t=e.regex,n=(A,{after:q})=>{const ie="</"+A[0].slice(1);return A.input.indexOf(ie,q)!==-1},r=Ad,o={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(A,q)=>{const ie=A[0].length+A.index,P=A.input[ie];if(P==="<"||P===","){q.ignoreMatch();return}P===">"&&(n(A,{after:ie})||q.ignoreMatch());let W;const xe=A.input.substring(ie);if(W=xe.match(/^\s*=/)){q.ignoreMatch();return}if((W=xe.match(/^\s+extends\s+/))&&W.index===0){q.ignoreMatch();return}}},u={$pattern:Ad,keyword:$_,literal:O_,built_in:z_,"variable.language":D_},c="[0-9](_?[0-9])*",h=`\\.(${c})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",g={className:"number",variants:[{begin:`(\\b(${p})((${h})|\\.)?|(${h}))[eE][+-]?(${c})\\b`},{begin:`\\b(${p})\\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},m={className:"subst",begin:"\\$\\{",end:"\\}",keywords:u,contains:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,m],subLanguage:"xml"}},w={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,m],subLanguage:"css"}},b={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,m],subLanguage:"graphql"}},E={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,m]},j={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,b,E,{match:/\$\d+/},g];m.contains=T.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(T)});const O=[].concat(j,m.contains),U=O.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(O)}]),Q={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:U},R={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},I={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...M_,...L_]}},_={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},L={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[Q],illegal:/%/},z={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function F(A){return t.concat("(?!",A.join("|"),")")}const ee={match:t.concat(/\b/,F([...P_,"super","import","await"].map(A=>`${A}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},se={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},fe={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},Q]},ke="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",ne={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ke)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[Q]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:U,CLASS_REFERENCE:I},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),_,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,b,E,j,{match:/\$\d+/},g,I,{scope:"attr",match:r+t.lookahead(":"),relevance:0},ne,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[j,e.REGEXP_MODE,{className:"function",begin:ke,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:u,contains:U}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:i},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},L,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[Q,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},se,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[Q]},ee,z,R,fe,{match:/\$[(.]/}]}}function z3(e){const t=e.regex,n=D3(e),r=Ad,o=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},l={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:o},contains:[n.exports.CLASS_REFERENCE]},u={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},c=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],h={$pattern:Ad,keyword:$_.concat(c),literal:O_,built_in:z_.concat(o),"variable.language":D_},p={className:"meta",begin:"@"+r},g=(b,E,N)=>{const j=b.contains.findIndex(T=>T.label===E);if(j===-1)throw new Error("can not find mode to replace");b.contains.splice(j,1,N)};Object.assign(n.keywords,h),n.exports.PARAMS_CONTAINS.push(p);const m=n.contains.find(b=>b.scope==="attr"),y=Object.assign({},m,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,m,y]),n.contains=n.contains.concat([p,i,l,y]),g(n,"shebang",e.SHEBANG()),g(n,"use_strict",u);const w=n.contains.find(b=>b.label==="func.def");return w.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function F3(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]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},l=e.inherit(i,{begin:/\(/,end:/\)/}),u=e.inherit(e.APOS_STRING_MODE,{className:"string"}),c=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:[i,c,u,l,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,l,c,u]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},o,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{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 B3(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:/\}/}]},i={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},l={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,o]},u=e.inherit(l,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),m={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},b={begin:"\\[",end:"\\]",contains:[y],illegal:"\\n",relevance:0},E=[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}},m,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},w,b,i,l],N=[...E];return N.pop(),N.push(u),y.contains=N,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:E}}var Np,db;function U3(){if(db)return Np;db=1;function e(B){return B instanceof Map?B.clear=B.delete=B.set=function(){throw new Error("map is read-only")}:B instanceof Set&&(B.add=B.clear=B.delete=function(){throw new Error("set is read-only")}),Object.freeze(B),Object.getOwnPropertyNames(B).forEach(ue=>{const Ie=B[ue],Je=typeof Ie;(Je==="object"||Je==="function")&&!Object.isFrozen(Ie)&&e(Ie)}),B}class t{constructor(ue){ue.data===void 0&&(ue.data={}),this.data=ue.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(B){return B.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(B,...ue){const Ie=Object.create(null);for(const Je in B)Ie[Je]=B[Je];return ue.forEach(function(Je){for(const Ot in Je)Ie[Ot]=Je[Ot]}),Ie}const o="</span>",i=B=>!!B.scope,l=(B,{prefix:ue})=>{if(B.startsWith("language:"))return B.replace("language:","language-");if(B.includes(".")){const Ie=B.split(".");return[`${ue}${Ie.shift()}`,...Ie.map((Je,Ot)=>`${Je}${"_".repeat(Ot+1)}`)].join(" ")}return`${ue}${B}`};class u{constructor(ue,Ie){this.buffer="",this.classPrefix=Ie.classPrefix,ue.walk(this)}addText(ue){this.buffer+=n(ue)}openNode(ue){if(!i(ue))return;const Ie=l(ue.scope,{prefix:this.classPrefix});this.span(Ie)}closeNode(ue){i(ue)&&(this.buffer+=o)}value(){return this.buffer}span(ue){this.buffer+=`<span class="${ue}">`}}const c=(B={})=>{const ue={children:[]};return Object.assign(ue,B),ue};class h{constructor(){this.rootNode=c(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(ue){this.top.children.push(ue)}openNode(ue){const Ie=c({scope:ue});this.add(Ie),this.stack.push(Ie)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(ue){return this.constructor._walk(ue,this.rootNode)}static _walk(ue,Ie){return typeof Ie=="string"?ue.addText(Ie):Ie.children&&(ue.openNode(Ie),Ie.children.forEach(Je=>this._walk(ue,Je)),ue.closeNode(Ie)),ue}static _collapse(ue){typeof ue!="string"&&ue.children&&(ue.children.every(Ie=>typeof Ie=="string")?ue.children=[ue.children.join("")]:ue.children.forEach(Ie=>{h._collapse(Ie)}))}}class p extends h{constructor(ue){super(),this.options=ue}addText(ue){ue!==""&&this.add(ue)}startScope(ue){this.openNode(ue)}endScope(){this.closeNode()}__addSublanguage(ue,Ie){const Je=ue.root;Ie&&(Je.scope=`language:${Ie}`),this.add(Je)}toHTML(){return new u(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function g(B){return B?typeof B=="string"?B:B.source:null}function m(B){return b("(?=",B,")")}function y(B){return b("(?:",B,")*")}function w(B){return b("(?:",B,")?")}function b(...B){return B.map(Ie=>g(Ie)).join("")}function E(B){const ue=B[B.length-1];return typeof ue=="object"&&ue.constructor===Object?(B.splice(B.length-1,1),ue):{}}function N(...B){return"("+(E(B).capture?"":"?:")+B.map(Je=>g(Je)).join("|")+")"}function j(B){return new RegExp(B.toString()+"|").exec("").length-1}function T(B,ue){const Ie=B&&B.exec(ue);return Ie&&Ie.index===0}const O=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function U(B,{joinWith:ue}){let Ie=0;return B.map(Je=>{Ie+=1;const Ot=Ie;let $t=g(Je),Oe="";for(;$t.length>0;){const Me=O.exec($t);if(!Me){Oe+=$t;break}Oe+=$t.substring(0,Me.index),$t=$t.substring(Me.index+Me[0].length),Me[0][0]==="\\"&&Me[1]?Oe+="\\"+String(Number(Me[1])+Ot):(Oe+=Me[0],Me[0]==="("&&Ie++)}return Oe}).map(Je=>`(${Je})`).join(ue)}const Q=/\b\B/,R="[a-zA-Z]\\w*",I="[a-zA-Z_]\\w*",_="\\b\\d+(\\.\\d+)?",L="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",z="\\b(0b[01]+)",F="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",ee=(B={})=>{const ue=/^#![ ]*\//;return B.binary&&(B.begin=b(ue,/.*\b/,B.binary,/\b.*/)),r({scope:"meta",begin:ue,end:/$/,relevance:0,"on:begin":(Ie,Je)=>{Ie.index!==0&&Je.ignoreMatch()}},B)},se={begin:"\\\\[\\s\\S]",relevance:0},fe={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[se]},ke={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[se]},ne={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/},A=function(B,ue,Ie={}){const Je=r({scope:"comment",begin:B,end:ue,contains:[]},Ie);Je.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 Ot=N("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return Je.contains.push({begin:b(/[ ]+/,"(",Ot,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Je},q=A("//","$"),ie=A("/\\*","\\*/"),P=A("#","$"),W={scope:"number",begin:_,relevance:0},xe={scope:"number",begin:L,relevance:0},ce={scope:"number",begin:z,relevance:0},me={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[se,{begin:/\[/,end:/\]/,relevance:0,contains:[se]}]},_e={scope:"title",begin:R,relevance:0},ae={scope:"title",begin:I,relevance:0},be={begin:"\\.\\s*"+I,relevance:0};var re=Object.freeze({__proto__:null,APOS_STRING_MODE:fe,BACKSLASH_ESCAPE:se,BINARY_NUMBER_MODE:ce,BINARY_NUMBER_RE:z,COMMENT:A,C_BLOCK_COMMENT_MODE:ie,C_LINE_COMMENT_MODE:q,C_NUMBER_MODE:xe,C_NUMBER_RE:L,END_SAME_AS_BEGIN:function(B){return Object.assign(B,{"on:begin":(ue,Ie)=>{Ie.data._beginMatch=ue[1]},"on:end":(ue,Ie)=>{Ie.data._beginMatch!==ue[1]&&Ie.ignoreMatch()}})},HASH_COMMENT_MODE:P,IDENT_RE:R,MATCH_NOTHING_RE:Q,METHOD_GUARD:be,NUMBER_MODE:W,NUMBER_RE:_,PHRASAL_WORDS_MODE:ne,QUOTE_STRING_MODE:ke,REGEXP_MODE:me,RE_STARTERS_RE:F,SHEBANG:ee,TITLE_MODE:_e,UNDERSCORE_IDENT_RE:I,UNDERSCORE_TITLE_MODE:ae});function he(B,ue){B.input[B.index-1]==="."&&ue.ignoreMatch()}function pe(B,ue){B.className!==void 0&&(B.scope=B.className,delete B.className)}function Te(B,ue){ue&&B.beginKeywords&&(B.begin="\\b("+B.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",B.__beforeBegin=he,B.keywords=B.keywords||B.beginKeywords,delete B.beginKeywords,B.relevance===void 0&&(B.relevance=0))}function Ue(B,ue){Array.isArray(B.illegal)&&(B.illegal=N(...B.illegal))}function ct(B,ue){if(B.match){if(B.begin||B.end)throw new Error("begin & end are not supported with match");B.begin=B.match,delete B.match}}function We(B,ue){B.relevance===void 0&&(B.relevance=1)}const xn=(B,ue)=>{if(!B.beforeMatch)return;if(B.starts)throw new Error("beforeMatch cannot be used with starts");const Ie=Object.assign({},B);Object.keys(B).forEach(Je=>{delete B[Je]}),B.keywords=Ie.keywords,B.begin=b(Ie.beforeMatch,m(Ie.begin)),B.starts={relevance:0,contains:[Object.assign(Ie,{endsParent:!0})]},B.relevance=0,delete Ie.beforeMatch},Ht=["of","and","for","in","not","or","if","then","parent","list","value"],It="keyword";function nt(B,ue,Ie=It){const Je=Object.create(null);return typeof B=="string"?Ot(Ie,B.split(" ")):Array.isArray(B)?Ot(Ie,B):Object.keys(B).forEach(function($t){Object.assign(Je,nt(B[$t],ue,$t))}),Je;function Ot($t,Oe){ue&&(Oe=Oe.map(Me=>Me.toLowerCase())),Oe.forEach(function(Me){const Ye=Me.split("|");Je[Ye[0]]=[$t,Ve(Ye[0],Ye[1])]})}}function Ve(B,ue){return ue?Number(ue):mt(B)?0:1}function mt(B){return Ht.includes(B.toLowerCase())}const En={},Rt=B=>{console.error(B)},V=(B,...ue)=>{console.log(`WARN: ${B}`,...ue)},ge=(B,ue)=>{En[`${B}/${ue}`]||(console.log(`Deprecated as of ${B}. ${ue}`),En[`${B}/${ue}`]=!0)},ft=new Error;function qe(B,ue,{key:Ie}){let Je=0;const Ot=B[Ie],$t={},Oe={};for(let Me=1;Me<=ue.length;Me++)Oe[Me+Je]=Ot[Me],$t[Me+Je]=!0,Je+=j(ue[Me-1]);B[Ie]=Oe,B[Ie]._emit=$t,B[Ie]._multi=!0}function un(B){if(Array.isArray(B.begin)){if(B.skip||B.excludeBegin||B.returnBegin)throw Rt("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ft;if(typeof B.beginScope!="object"||B.beginScope===null)throw Rt("beginScope must be object"),ft;qe(B,B.begin,{key:"beginScope"}),B.begin=U(B.begin,{joinWith:""})}}function yn(B){if(Array.isArray(B.end)){if(B.skip||B.excludeEnd||B.returnEnd)throw Rt("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ft;if(typeof B.endScope!="object"||B.endScope===null)throw Rt("endScope must be object"),ft;qe(B,B.end,{key:"endScope"}),B.end=U(B.end,{joinWith:""})}}function Tn(B){B.scope&&typeof B.scope=="object"&&B.scope!==null&&(B.beginScope=B.scope,delete B.scope)}function gt(B){Tn(B),typeof B.beginScope=="string"&&(B.beginScope={_wrap:B.beginScope}),typeof B.endScope=="string"&&(B.endScope={_wrap:B.endScope}),un(B),yn(B)}function jn(B){function ue(Oe,Me){return new RegExp(g(Oe),"m"+(B.case_insensitive?"i":"")+(B.unicodeRegex?"u":"")+(Me?"g":""))}class Ie{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Me,Ye){Ye.position=this.position++,this.matchIndexes[this.matchAt]=Ye,this.regexes.push([Ye,Me]),this.matchAt+=j(Me)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Me=this.regexes.map(Ye=>Ye[1]);this.matcherRe=ue(U(Me,{joinWith:"|"}),!0),this.lastIndex=0}exec(Me){this.matcherRe.lastIndex=this.lastIndex;const Ye=this.matcherRe.exec(Me);if(!Ye)return null;const Pt=Ye.findIndex(($e,kt)=>kt>0&&$e!==void 0),X=this.matchIndexes[Pt];return Ye.splice(0,Pt),Object.assign(Ye,X)}}class Je{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Me){if(this.multiRegexes[Me])return this.multiRegexes[Me];const Ye=new Ie;return this.rules.slice(Me).forEach(([Pt,X])=>Ye.addRule(Pt,X)),Ye.compile(),this.multiRegexes[Me]=Ye,Ye}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Me,Ye){this.rules.push([Me,Ye]),Ye.type==="begin"&&this.count++}exec(Me){const Ye=this.getMatcher(this.regexIndex);Ye.lastIndex=this.lastIndex;let Pt=Ye.exec(Me);if(this.resumingScanAtSamePosition()&&!(Pt&&Pt.index===this.lastIndex)){const X=this.getMatcher(0);X.lastIndex=this.lastIndex+1,Pt=X.exec(Me)}return Pt&&(this.regexIndex+=Pt.position+1,this.regexIndex===this.count&&this.considerAll()),Pt}}function Ot(Oe){const Me=new Je;return Oe.contains.forEach(Ye=>Me.addRule(Ye.begin,{rule:Ye,type:"begin"})),Oe.terminatorEnd&&Me.addRule(Oe.terminatorEnd,{type:"end"}),Oe.illegal&&Me.addRule(Oe.illegal,{type:"illegal"}),Me}function $t(Oe,Me){const Ye=Oe;if(Oe.isCompiled)return Ye;[pe,ct,gt,xn].forEach(X=>X(Oe,Me)),B.compilerExtensions.forEach(X=>X(Oe,Me)),Oe.__beforeBegin=null,[Te,Ue,We].forEach(X=>X(Oe,Me)),Oe.isCompiled=!0;let Pt=null;return typeof Oe.keywords=="object"&&Oe.keywords.$pattern&&(Oe.keywords=Object.assign({},Oe.keywords),Pt=Oe.keywords.$pattern,delete Oe.keywords.$pattern),Pt=Pt||/\w+/,Oe.keywords&&(Oe.keywords=nt(Oe.keywords,B.case_insensitive)),Ye.keywordPatternRe=ue(Pt,!0),Me&&(Oe.begin||(Oe.begin=/\B|\b/),Ye.beginRe=ue(Ye.begin),!Oe.end&&!Oe.endsWithParent&&(Oe.end=/\B|\b/),Oe.end&&(Ye.endRe=ue(Ye.end)),Ye.terminatorEnd=g(Ye.end)||"",Oe.endsWithParent&&Me.terminatorEnd&&(Ye.terminatorEnd+=(Oe.end?"|":"")+Me.terminatorEnd)),Oe.illegal&&(Ye.illegalRe=ue(Oe.illegal)),Oe.contains||(Oe.contains=[]),Oe.contains=[].concat(...Oe.contains.map(function(X){return Le(X==="self"?Oe:X)})),Oe.contains.forEach(function(X){$t(X,Ye)}),Oe.starts&&$t(Oe.starts,Me),Ye.matcher=Ot(Ye),Ye}if(B.compilerExtensions||(B.compilerExtensions=[]),B.contains&&B.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return B.classNameAliases=r(B.classNameAliases||{}),$t(B)}function ye(B){return B?B.endsWithParent||ye(B.starts):!1}function Le(B){return B.variants&&!B.cachedVariants&&(B.cachedVariants=B.variants.map(function(ue){return r(B,{variants:null},ue)})),B.cachedVariants?B.cachedVariants:ye(B)?r(B,{starts:B.starts?r(B.starts):null}):Object.isFrozen(B)?r(B):B}var wn="11.11.2";class _n extends Error{constructor(ue,Ie){super(ue),this.name="HTMLInjectionError",this.html=Ie}}const Sn=n,sn=r,In=Symbol("nomatch"),ot=7,Wt=function(B){const ue=Object.create(null),Ie=Object.create(null),Je=[];let Ot=!0;const $t="Could not find the language '{}', did you forget to load/include a language module?",Oe={disableAutodetect:!0,name:"Plain text",contains:[]};let Me={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:p};function Ye(je){return Me.noHighlightRe.test(je)}function Pt(je){let Fe=je.className+" ";Fe+=je.parentNode?je.parentNode.className:"";const lt=Me.languageDetectRe.exec(Fe);if(lt){const Et=Bt(lt[1]);return Et||(V($t.replace("{}",lt[1])),V("Falling back to no-highlight mode for this block.",je)),Et?lt[1]:"no-highlight"}return Fe.split(/\s+/).find(Et=>Ye(Et)||Bt(Et))}function X(je,Fe,lt){let Et="",cn="";typeof Fe=="object"?(Et=je,lt=Fe.ignoreIllegals,cn=Fe.language):(ge("10.7.0","highlight(lang, code, ...args) has been deprecated."),ge("10.7.0",`Please use highlight(code, options) instead.
|
|
198
|
+
https://github.com/highlightjs/highlight.js/issues/2277`),cn=je,Et=Fe),lt===void 0&&(lt=!0);const mn={code:Et,language:cn};Zn("before:highlight",mn);const Z=mn.result?mn.result:$e(mn.language,mn.code,lt);return Z.code=mn.code,Zn("after:highlight",Z),Z}function $e(je,Fe,lt,Et){const cn=Object.create(null);function mn(D,J){return D.keywords[J]}function Z(){if(!dt.keywords){fn.addText(Gt);return}let D=0;dt.keywordPatternRe.lastIndex=0;let J=dt.keywordPatternRe.exec(Gt),we="";for(;J;){we+=Gt.substring(D,J.index);const Ce=bt.case_insensitive?J[0].toLowerCase():J[0],He=mn(dt,Ce);if(He){const[vt,Ut]=He;if(fn.addText(we),we="",cn[Ce]=(cn[Ce]||0)+1,cn[Ce]<=ot&&(gr+=Ut),vt.startsWith("_"))we+=J[0];else{const Xn=bt.classNameAliases[vt]||vt;ut(J[0],Xn)}}else we+=J[0];D=dt.keywordPatternRe.lastIndex,J=dt.keywordPatternRe.exec(Gt)}we+=Gt.substring(D),fn.addText(we)}function de(){if(Gt==="")return;let D=null;if(typeof dt.subLanguage=="string"){if(!ue[dt.subLanguage]){fn.addText(Gt);return}D=$e(dt.subLanguage,Gt,!0,Uo[dt.subLanguage]),Uo[dt.subLanguage]=D._top}else D=Nt(Gt,dt.subLanguage.length?dt.subLanguage:null);dt.relevance>0&&(gr+=D.relevance),fn.__addSublanguage(D._emitter,D.language)}function De(){dt.subLanguage!=null?de():Z(),Gt=""}function ut(D,J){D!==""&&(fn.startScope(J),fn.addText(D),fn.endScope())}function wt(D,J){let we=1;const Ce=J.length-1;for(;we<=Ce;){if(!D._emit[we]){we++;continue}const He=bt.classNameAliases[D[we]]||D[we],vt=J[we];He?ut(vt,He):(Gt=vt,Z(),Gt=""),we++}}function Xt(D,J){return D.scope&&typeof D.scope=="string"&&fn.openNode(bt.classNameAliases[D.scope]||D.scope),D.beginScope&&(D.beginScope._wrap?(ut(Gt,bt.classNameAliases[D.beginScope._wrap]||D.beginScope._wrap),Gt=""):D.beginScope._multi&&(wt(D.beginScope,J),Gt="")),dt=Object.create(D,{parent:{value:dt}}),dt}function Dn(D,J,we){let Ce=T(D.endRe,we);if(Ce){if(D["on:end"]){const He=new t(D);D["on:end"](J,He),He.isMatchIgnored&&(Ce=!1)}if(Ce){for(;D.endsParent&&D.parent;)D=D.parent;return D}}if(D.endsWithParent)return Dn(D.parent,J,we)}function zn(D){return dt.matcher.regexIndex===0?(Gt+=D[0],1):($=!0,0)}function So(D){const J=D[0],we=D.rule,Ce=new t(we),He=[we.__beforeBegin,we["on:begin"]];for(const vt of He)if(vt&&(vt(D,Ce),Ce.isMatchIgnored))return zn(J);return we.skip?Gt+=J:(we.excludeBegin&&(Gt+=J),De(),!we.returnBegin&&!we.excludeBegin&&(Gt=J)),Xt(we,D),we.returnBegin?0:J.length}function Pr(D){const J=D[0],we=Fe.substring(D.index),Ce=Dn(dt,D,we);if(!Ce)return In;const He=dt;dt.endScope&&dt.endScope._wrap?(De(),ut(J,dt.endScope._wrap)):dt.endScope&&dt.endScope._multi?(De(),wt(dt.endScope,D)):He.skip?Gt+=J:(He.returnEnd||He.excludeEnd||(Gt+=J),De(),He.excludeEnd&&(Gt=J));do dt.scope&&fn.closeNode(),!dt.skip&&!dt.subLanguage&&(gr+=dt.relevance),dt=dt.parent;while(dt!==Ce.parent);return Ce.starts&&Xt(Ce.starts,D),He.returnEnd?0:J.length}function Bo(){const D=[];for(let J=dt;J!==bt;J=J.parent)J.scope&&D.unshift(J.scope);D.forEach(J=>fn.openNode(J))}let Jr={};function Dr(D,J){const we=J&&J[0];if(Gt+=D,we==null)return De(),0;if(Jr.type==="begin"&&J.type==="end"&&Jr.index===J.index&&we===""){if(Gt+=Fe.slice(J.index,J.index+1),!Ot){const Ce=new Error(`0 width match regex (${je})`);throw Ce.languageName=je,Ce.badRule=Jr.rule,Ce}return 1}if(Jr=J,J.type==="begin")return So(J);if(J.type==="illegal"&&!lt){const Ce=new Error('Illegal lexeme "'+we+'" for mode "'+(dt.scope||"<unnamed>")+'"');throw Ce.mode=dt,Ce}else if(J.type==="end"){const Ce=Pr(J);if(Ce!==In)return Ce}if(J.type==="illegal"&&we==="")return J.index===Fe.length||(Gt+=`
|
|
199
|
+
`),1;if(Ee>1e5&&Ee>J.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Gt+=we,we.length}const bt=Bt(je);if(!bt)throw Rt($t.replace("{}",je)),new Error('Unknown language: "'+je+'"');const zr=jn(bt);let Kt="",dt=Et||zr;const Uo={},fn=new Me.__emitter(Me);Bo();let Gt="",gr=0,qn=0,Ee=0,$=!1;try{if(bt.__emitTokens)bt.__emitTokens(Fe,fn);else{for(dt.matcher.considerAll();;){Ee++,$?$=!1:dt.matcher.considerAll(),dt.matcher.lastIndex=qn;const D=dt.matcher.exec(Fe);if(!D)break;const J=Fe.substring(qn,D.index),we=Dr(J,D);qn=D.index+we}Dr(Fe.substring(qn))}return fn.finalize(),Kt=fn.toHTML(),{language:je,value:Kt,relevance:gr,illegal:!1,_emitter:fn,_top:dt}}catch(D){if(D.message&&D.message.includes("Illegal"))return{language:je,value:Sn(Fe),illegal:!0,relevance:0,_illegalBy:{message:D.message,index:qn,context:Fe.slice(qn-100,qn+100),mode:D.mode,resultSoFar:Kt},_emitter:fn};if(Ot)return{language:je,value:Sn(Fe),illegal:!1,relevance:0,errorRaised:D,_emitter:fn,_top:dt};throw D}}function kt(je){const Fe={value:Sn(je),illegal:!1,relevance:0,_top:Oe,_emitter:new Me.__emitter(Me)};return Fe._emitter.addText(je),Fe}function Nt(je,Fe){Fe=Fe||Me.languages||Object.keys(ue);const lt=kt(je),Et=Fe.filter(Bt).filter(Qr).map(De=>$e(De,je,!1));Et.unshift(lt);const cn=Et.sort((De,ut)=>{if(De.relevance!==ut.relevance)return ut.relevance-De.relevance;if(De.language&&ut.language){if(Bt(De.language).supersetOf===ut.language)return 1;if(Bt(ut.language).supersetOf===De.language)return-1}return 0}),[mn,Z]=cn,de=mn;return de.secondBest=Z,de}function Dt(je,Fe,lt){const Et=Fe&&Ie[Fe]||lt;je.classList.add("hljs"),je.classList.add(`language-${Et}`)}function an(je){let Fe=null;const lt=Pt(je);if(Ye(lt))return;if(Zn("before:highlightElement",{el:je,language:lt}),je.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",je);return}if(je.children.length>0&&(Me.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(je)),Me.throwUnescapedHTML))throw new _n("One of your code blocks includes unescaped HTML.",je.innerHTML);Fe=je;const Et=Fe.textContent,cn=lt?X(Et,{language:lt,ignoreIllegals:!0}):Nt(Et);je.innerHTML=cn.value,je.dataset.highlighted="yes",Dt(je,lt,cn.language),je.result={language:cn.language,re:cn.relevance,relevance:cn.relevance},cn.secondBest&&(je.secondBest={language:cn.secondBest.language,relevance:cn.secondBest.relevance}),Zn("after:highlightElement",{el:je,result:cn,text:Et})}function Mt(je){Me=sn(Me,je)}const zt=()=>{vn(),ge("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Vt(){vn(),ge("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Qe=!1;function vn(){function je(){vn()}if(document.readyState==="loading"){Qe||window.addEventListener("DOMContentLoaded",je,!1),Qe=!0;return}document.querySelectorAll(Me.cssSelector).forEach(an)}function pn(je,Fe){let lt=null;try{lt=Fe(B)}catch(Et){if(Rt("Language definition for '{}' could not be registered.".replace("{}",je)),Ot)Rt(Et);else throw Et;lt=Oe}lt.name||(lt.name=je),ue[je]=lt,lt.rawDefinition=Fe.bind(null,B),lt.aliases&&cr(lt.aliases,{languageName:je})}function Rn(je){delete ue[je];for(const Fe of Object.keys(Ie))Ie[Fe]===je&&delete Ie[Fe]}function dn(){return Object.keys(ue)}function Bt(je){return je=(je||"").toLowerCase(),ue[je]||ue[Ie[je]]}function cr(je,{languageName:Fe}){typeof je=="string"&&(je=[je]),je.forEach(lt=>{Ie[lt.toLowerCase()]=Fe})}function Qr(je){const Fe=Bt(je);return Fe&&!Fe.disableAutodetect}function ln(je){je["before:highlightBlock"]&&!je["before:highlightElement"]&&(je["before:highlightElement"]=Fe=>{je["before:highlightBlock"](Object.assign({block:Fe.el},Fe))}),je["after:highlightBlock"]&&!je["after:highlightElement"]&&(je["after:highlightElement"]=Fe=>{je["after:highlightBlock"](Object.assign({block:Fe.el},Fe))})}function rs(je){ln(je),Je.push(je)}function Xr(je){const Fe=Je.indexOf(je);Fe!==-1&&Je.splice(Fe,1)}function Zn(je,Fe){const lt=je;Je.forEach(function(Et){Et[lt]&&Et[lt](Fe)})}function ur(je){return ge("10.7.0","highlightBlock will be removed entirely in v12.0"),ge("10.7.0","Please use highlightElement now."),an(je)}Object.assign(B,{highlight:X,highlightAuto:Nt,highlightAll:vn,highlightElement:an,highlightBlock:ur,configure:Mt,initHighlighting:zt,initHighlightingOnLoad:Vt,registerLanguage:pn,unregisterLanguage:Rn,listLanguages:dn,getLanguage:Bt,registerAliases:cr,autoDetection:Qr,inherit:sn,addPlugin:rs,removePlugin:Xr}),B.debugMode=function(){Ot=!1},B.safeMode=function(){Ot=!0},B.versionString=wn,B.regex={concat:b,lookahead:m,either:N,optional:w,anyNumberOfTimes:y};for(const je in re)typeof re[je]=="object"&&e(re[je]);return Object.assign(B,re),B},Qt=Wt({});return Qt.newInstance=()=>Wt({}),Np=Qt,Qt.HighlightJS=Qt,Qt.default=Qt,Np}var H3=U3();const W3=Qb(H3),fb={},K3="hljs-";function Z3(e){const t=W3.newInstance();return e&&i(e),{highlight:n,highlightAuto:r,listLanguages:o,register:i,registerAlias:l,registered:u};function n(c,h,p){const g=p||fb,m=typeof g.prefix=="string"?g.prefix:K3;if(!t.getLanguage(c))throw new Error("Unknown language: `"+c+"` is not registered");t.configure({__emitter:q3,classPrefix:m});const y=t.highlight(h,{ignoreIllegals:!0,language:c});if(y.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:y.errorRaised});const w=y._emitter.root,b=w.data;return b.language=y.language,b.relevance=y.relevance,w}function r(c,h){const g=(h||fb).subset||o();let m=-1,y=0,w;for(;++m<g.length;){const b=g[m];if(!t.getLanguage(b))continue;const E=n(b,c,h);E.data&&E.data.relevance!==void 0&&E.data.relevance>y&&(y=E.data.relevance,w=E)}return w||{type:"root",children:[],data:{language:void 0,relevance:y}}}function o(){return t.listLanguages()}function i(c,h){if(typeof c=="string")t.registerLanguage(c,h);else{let p;for(p in c)Object.hasOwn(c,p)&&t.registerLanguage(p,c[p])}}function l(c,h){if(typeof c=="string")t.registerAliases(typeof h=="string"?h:[...h],{languageName:c});else{let p;for(p in c)if(Object.hasOwn(c,p)){const g=c[p];t.registerAliases(typeof g=="string"?g:[...g],{languageName:p})}}}function u(c){return!!t.getLanguage(c)}}class q3{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(l,u){return u?l+"_".repeat(u):n.options.classPrefix+l}),o=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:r},children:[]};o.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const F_=Z3({bash:m3,css:_3,go:S3,ini:N3,javascript:I3,json:O3,markdown:M3,python:L3,rust:P3,typescript:z3,xml:F3,yaml:B3}),hb={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 tk(e,t){const n=e&&(hb[e]??(F_.registered(e)?e:null));if(n)return n;const r=t.lastIndexOf("."),o=r<0?"":t.slice(r+1).toLowerCase();return(o?hb[o]:null)??null}const G3=/^(?:diff --git a\/\S+ b\/(\S+)|\+\+\+ (?:b\/)?(\S+))$/gm;function V3(e){const t=new Set;for(const n of e.matchAll(G3)){const r=n[1]??n[2]??"";r&&r!=="/dev/null"&&t.add(r)}return t.size===1?[...t][0]:""}const Y3={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 B_(e,t){const n=[[]],r=(i,l)=>{const u=i.split(`
|
|
200
|
+
`);for(const[c,h]of u.entries()){if(c>0&&n.push([]),!h)continue;const p=n[n.length-1],g=p[p.length-1];g&&g.scope===l?g.text+=h:p.push({text:h,scope:l})}},o=(i,l)=>{for(const u of i)u.type==="text"?r(u.value,l):u.type==="element"&&o(u.children,Q3(u)??l)};try{o(F_.highlight(t,e).children,"")}catch{return e.split(`
|
|
201
|
+
`).map(i=>i?[{text:i,scope:""}]:[])}return n}function Q3(e){var r;const t=((r=e.properties)==null?void 0:r.className)??[];let n=null;for(const o of t){const i=Y3[o.startsWith("hljs-")?o.slice(5):o];i&&(n=i)}return n}const pb=/^\d+\t/;function nk(e,t){if(!t)return[];const n=e.split(`
|
|
202
|
+
`),r=pb.test(n[0]??""),o=r?n.map(l=>{var u;return((u=pb.exec(l))==null?void 0:u[0])??""}):[],i=r?n.map((l,u)=>l.slice(o[u].length)).join(`
|
|
203
|
+
`):e;return B_(i,t).map((l,u)=>{const c=l.map(p=>({text:p.text,changed:!1,scope:p.scope})),h=o[u];return h?[{text:h,changed:!1,scope:""},...c]:c})}function X3(e,t){var r;const n=new Array(e.length);if(t){let o=0;for(let i=0;i<=e.length;i++){const l=(r=e[i])==null?void 0:r.kind;i<e.length&&l!=="hunk"&&l!=="meta"||(J3(e,o,i,t,n),o=i+1)}}return e.map((o,i)=>e5(o.spans,n[i],o.text))}function J3(e,t,n,r,o){var i,l;for(const u of["del","add"]){const c=[];for(let g=t;g<n;g++){const m=(i=e[g])==null?void 0:i.kind;(m===""||m===u)&&c.push(g)}if(c.length===0)continue;const h=c.map(g=>{var m;return((m=e[g])==null?void 0:m.text)??""}).join(`
|
|
204
|
+
`),p=B_(h,r);for(const[g,m]of c.entries())(u==="add"||((l=e[m])==null?void 0:l.kind)==="del")&&(o[m]=p[g])}}function e5(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}],i=t!=null&&t.length?t:[{text:n,scope:""}];let l=0,u=0,c=0,h=0;for(;l<o.length&&u<i.length;){const p=o[l],g=i[u],m=Math.min(p.text.length-c,g.text.length-h);if(m>0){const y={text:p.text.slice(c,c+m),changed:p.changed,scope:g.scope},w=r[r.length-1];w&&w.changed===y.changed&&w.scope===y.scope?w.text+=y.text:r.push(y)}c+=m,h+=m,c>=p.text.length&&(l++,c=0),h>=g.text.length&&(u++,h=0)}return r}gn.use({extensions:[h3],renderer:{code({text:e,lang:t}){const n=tk((t??"").trim().toLowerCase().split(/\s+/)[0]??"","");return n?`<pre><code>${nk(e,n).map(o=>o.map(i=>i.scope?`<span class="sy-${i.scope}">${mb(i.text)}</span>`:mb(i.text)).join("")).join(`
|
|
205
|
+
`)}</code></pre>
|
|
206
|
+
`:!1},table:p3}});const mb=e=>e.replace(/[&<>]/g,t=>t==="&"?"&":t==="<"?"<":">"),U_=iz(window);let ws=null;U_.addHook("afterSanitizeAttributes",e=>{const t=e.tagName==="A"?e.getAttribute("href")??"":"";if(t===C_){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=ws!=null&&ws.fileRoot?f_(ws.fileRoot,t):null,r=n?null:h_(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.path}${r.line?`:${r.line}`:""}`),e.setAttribute("data-tip-placement","follow")),e.tagName==="CODE"&&!e.closest("pre, a")){const i=ED(e.textContent??"");i&&e.setAttribute("data-path",i)}const o=ws==null?void 0:ws.base;if(e.tagName==="IMG"&&o){const i=Hg(o.dir,e.getAttribute("src")??"");i&&e.setAttribute("src",o.urls.worktreeFile(o.worktreeId,i,o.version))}});function Oa(e,t){ws=t??null;const n=t!=null&&t.streaming?c3(e):e;try{return U_.sanitize(gn.parse(n,{async:!1}))}finally{ws=null}}function rk(e,t){var g,m,y,w;const[n,r]=S.useState(()=>Oa(e,t)),o=S.useRef(0),i=(g=t==null?void 0:t.base)==null?void 0:g.worktreeId,l=(m=t==null?void 0:t.base)==null?void 0:m.dir,u=(y=t==null?void 0:t.base)==null?void 0:y.version,c=(w=t==null?void 0:t.base)==null?void 0:w.urls,h=t==null?void 0:t.fileRoot,p=t==null?void 0:t.streaming;return S.useEffect(()=>{const b=i!==void 0&&l!==void 0&&c!==void 0?{worktreeId:i,dir:l,version:u??null,urls:c}:void 0,E=b||h||p?{base:b,fileRoot:h,streaming:p}:void 0,N=performance.now()-o.current;if(N>=Cd){o.current=performance.now(),r(Oa(e,E));return}const j=setTimeout(()=>{o.current=performance.now(),r(Oa(e,E))},Cd-N);return()=>clearTimeout(j)},[e,i,l,u,c,h,p]),n}const t5=/^ {0,3}(`{3,}|~{3,})/,n5=/^#{1,6} \S/,r5=/^\s*(?:[-*+]|\d+[.)]) \S/,o5=/^> ?\S/,s5=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/,i5=/\[[^\]\n]+\]\((?:https?:|\.{0,2}\/|#)[^)\s]*\)/,a5=/\*\*[^\s*][^*\n]*\*\*/;function l5(e){var i,l;const t=e.split(`
|
|
207
|
+
`),n=new Set;let r=null,o=0;for(let u=0;u<t.length;u++){const c=t[u],h=(i=t5.exec(c))==null?void 0:i[1];if(r){h!=null&&h.startsWith(r)&&(r=null,n.add("fence"));continue}if(h){r=h;continue}n5.test(c)&&!((l=t[u+1])!=null&&l.trim())&&n.add("heading"),r5.test(c)&&++o===2&&n.add("list"),o5.test(c)&&n.add("quote"),s5.test(c)&&n.add("table"),i5.test(c)&&n.add("link"),a5.test(c)&&n.add("bold")}return n.size}function c5(e,t){if(t)return Jd(t)==="markdown"?"rendered":"plain";const n=l5(e);return n>=2?"rendered":n===1?"source":"plain"}function ok({n:e,name:t,source:n,lines:r,chars:o,preview:i,text:l,href:u,onRemove:c,className:h=""}){const p=(n==null?void 0:n.path)??t??"",g=p.includes("/")?p.slice(0,p.lastIndexOf("/")):"",m=n?[g,n.ref?`at ${n.ref.slice(0,7)}`:""].filter(Boolean).join(" "):[g,`${r} ${r===1?"line":"lines"}`,`${o.toLocaleString()} chars`,i].filter(Boolean).join(" · "),y=f.jsxs(f.Fragment,{children:[f.jsx(St,{name:"text",className:"icon-inline"}),f.jsxs("span",{className:"pick-target",children:[f.jsx("b",{children:t?t.slice(t.lastIndexOf("/")+1):n?bO(n):ox("paste",e)}),m&&f.jsxs("span",{className:"pick-file row-dim",children:[" · ",m]})]})]}),w=l!==void 0||u!==void 0;return f.jsx(Zg,{className:Be("paste-chip",h),label:y,tip:i||void 0,peek:w?f.jsx(K_,{text:l,href:u}):void 0,full:w?f.jsx(W_,{text:l,href:u,path:p||void 0}):void 0,menu:b=>c_({text:l,href:u},b),removeLabel:"Remove attachment",onRemove:c})}function H_(e,t){const[n,r]=S.useState(e??null),[o,i]=S.useState(!1);return S.useEffect(()=>{if(e!==void 0||!t)return;let l=!0;return fetch(t).then(u=>u.ok?u.text():Promise.reject(new Error(String(u.status)))).then(u=>{l&&r(u)}).catch(()=>{l&&i(!0)}),()=>{l=!1}},[e,t]),{text:e??n,failed:o}}function W_({text:e,href:t,path:n}){const{text:r,failed:o}=H_(e,t),i=S.useMemo(()=>r?c5(r,n):"plain",[r,n]),[l,u]=S.useState(null);if(o)return f.jsx("p",{className:"paste-full hint",children:"Toyon could not read that back."});if(!r||i==="plain")return f.jsx("pre",{className:"paste-full paste-text",children:r});const c=l??i==="rendered";return f.jsxs("div",{className:"paste-full paste-doc",children:[f.jsx("div",{className:"paste-doc-head",children:f.jsxs(Pe,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>u(!c),"data-tip":c?"Text: read it as it was sent":"Preview: read it rendered",children:[f.jsx(St,{name:c?"text":"book",className:"icon-inline"})," ",c?"text":"preview"]})}),c?f.jsx(u5,{text:r}):f.jsx("pre",{className:"paste-doc-body paste-text",children:r})]})}function u5({text:e}){const t=S.useMemo(()=>Oa(e),[e]);return f.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 d5=2e4;function K_({text:e,href:t}){const{text:n}=H_(e,t);return n?f.jsx("pre",{className:"paste-peek paste-text",children:n.slice(0,d5)}):null}function sk({name:e,bytes:t,href:n,uploading:r,onRemove:o,className:i=""}){return f.jsx(Zg,{className:Be("file-chip",i),label:f.jsxs(f.Fragment,{children:[f.jsx(St,{name:"file",className:"icon-inline"}),f.jsxs("span",{className:"pick-target",children:[f.jsx("b",{children:e}),f.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",qm(t),r&&" · uploading"]})]})]}),tip:e,peek:n?f.jsx(K_,{href:n}):void 0,full:n?f.jsx(W_,{href:n,path:e}):void 0,menu:l=>c_({href:n},l),removeLabel:"Remove attachment",onRemove:o})}function Z_(e){return e.replace(/^([\t ]*)\*\*(\S(?:[^\n]*\S)?)\*\*([\t ]*)$/gm,"$1$2$3")}const q_=120,f5=/^\*\*(\S(?:[^\n]*\S)?)\*\*$/;function G_(e){var n,r;const t=[];for(const o of e.split(/\n[\t ]*\n/)){const i=o.trim();if(!i)continue;const l=((r=(n=f5.exec(i))==null?void 0:n[1])==null?void 0:r.replace(/`/g,""))??"";if(!l||l.length>q_)return[];t.push(l)}return t}function V_(e){const t=G_(e);if(t.length)return t.at(-1);const n=Z_(e).trim().replace(/`/g,"");return n&&!n.includes(`
|
|
208
|
+
`)&&n.length<=q_?n:""}const h5={read:"read",edit:"edit",delete:"delete",move:"move",search:"search",execute:"run",think:"think",fetch:"fetch",switch_mode:"mode",other:"tool"},gb={read:"book",edit:"edit",delete:"trash",move:"move",search:"search",execute:"run",think:"bulb",fetch:"globe",switch_mode:"swap",other:"dot"},Y_="Skill",Tp=new Map([[Hm,"chat"],["Monitor","clock"],["TaskOutput","terminal"],[Y_,"layers"]]);function p5(e){if(e.name!==Y_)return"";const t=lo(e,"skill").trim();if(!t)return"";const n=lo(e,"args").trim();return n?`/${t} ${n}`:`/${t}`}const xm={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"},m5=/(^|\s)(-[A-Za-z]*[iI]|--in-place)/,kb=String.raw`(?:"[^"]*"|'[^']*'|[^\s;&|]+)`,yb=new RegExp(String.raw`^\s*(?:(?:cd|echo)\s+${kb}\s*(?:&&|;)|mkdir(?:\s+${kb})+\s*(?:&&|;)|(?:export\s+)?[A-Za-z_]\w*=(?:"[^"]*"|'[^']*'|[^\s;&|()\`]*)\s*(?:&&|;|(?=\s)))\s*`),g5=/^python[\d.]*$/,k5=new RegExp(`open\\([^)]*,\\s*["'][wax]|(?<!std(?:out|err))\\.write\\(|\\.write_text\\(`);function Q_(e){let t=e;for(let n=t.replace(yb,"");n!==t;n=t.replace(yb,""))t=n;return t}const y5=new RegExp("(?<![0-9&])>{1,2}\\s*(?!\\/dev\\/null|&)[^\\s&>]"),X_=/&&|;|\n|\|/;function w5(e){return e.split(X_).some(t=>/^\s*(?:\S*\/)?sed\s/.test(t)&&m5.test(t))}function v5(e){return e.split(/&&|;|\n/).map(t=>Q_(t).trim().split(/\s+/)[0]??"").filter(Boolean).every(t=>xm[t.slice(t.lastIndexOf("/")+1)]==="trash")}function b5(e){const t=Q_(e).trim(),n=t.split(/\s+/)[0]??"",r=n.slice(n.lastIndexOf("/")+1),o=r==="sed"?w5(e)?void 0:"book":xm[r];if(o==="book"||o==="search"){const i=t.split(X_)[0]??"";if(y5.test(i))return r==="cat"&&i.includes("<<")?"edit":void 0}if(!(o==="trash"&&!v5(t)))return o||(g5.test(r)?t.includes("<<")&&k5.test(t)?"edit":void 0:xm[r])}function lo(e,t){const n=e.input,r=n?n[t]:void 0;return typeof r=="string"?r:""}const x5=/^(?:\/(?:usr\/)?bin\/)?(?:ba|z|da)?sh\s+(?:-[a-zA-Z]+\s+)*(?:'([^']*)'|"((?:[^"\\]|\\.)*)")\s*$/;function J_(e){const t=x5.exec(e.trim());return t?t[1]!==void 0?t[1]:(t[2]??"").replace(/\\(["\\$`])/g,"$1"):e}const E5="Guardian Review";function eS(e){return e.toolKind==="think"&&e.title===E5}function _5(e){const t=o=>{var l,u;return((u=(l=[...e.matchAll(new RegExp(`^${o}:[ \\t]*(.+)$`,"gm"))].at(-1))==null?void 0:l[1])==null?void 0:u.trim().toLowerCase())??""},n=t("Status"),r=t("Risk");return!n||n==="in progress"?"reviewing":r?`${n}, ${r} risk`:n}function uc(e,t=[]){const n=J_(lo(e,"command")),o=tS(e)||n||lo(e,"path")||lo(e,"pattern")||p5(e)||(e.title&&e.title!==e.name?e.title:""),i=ik(lo(e,"description")||o,t),l=e.toolKind&&e.toolKind in gb?e.toolKind:"other",u=h5[l],c=e.name===Hm,h=(l!=="other"||Tp.has(e.name))&&e.name!==KT,p=i&&(h||e.name===e.title||e.name===Wa||e.name===Xb)?"":e.name,g=p&&p.toLowerCase()!==u?p:i?"":u,m=(l==="execute"||l==="other")&&n?b5(n):void 0;return{label:c?"ask":u,name:g,icon:Tp.get(e.name)??Tp.get(e.title??"")??m??gb[l],hint:i===g?"":i,command:n&&n!==i?n:""}}const S5=/^Async agent launched/m;function N5(e){if(!e.subagent)return!1;const t=e.input;return!!e.detached||(t==null?void 0:t.run_in_background)===!0||!!e.output&&S5.test(e.output)}const T5={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 j5(e){const t=e.toolKind;return e.subagent?lo(e,"prompt")?"":"writing the brief":!Fd(e.input)||!ex({name:e.name,kind:t},e.input)?"":Wm(t)?T5[t]:"writing the question"}function Em(e,t){const n=nS(t),r=n[0],o=lo(e,"description");return o&&r&&!r.code&&r.text===o?n.slice(1):n}function yf(e){return tS(e)||lo(e,"path")}function C5(e){return lo(e,"description")}function tS(e){return lo(e,"file_path")||lo(e,"filepath")||lo(e,"filePath")||A5(e)}function A5(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 ik(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 I5=/^(`{3,})([\w+#.-]*)\s*$/;function nS(e){var u;const t=[];let n=[],r="",o=!1,i=0;const l=()=>{const c=n.join(`
|
|
209
|
+
`).replace(/^\n+|\n+$/g,"");c.trim()&&t.push({code:o,diff:R5(c,r),lang:o?r:"",text:c}),n=[]};for(const c of e.split(`
|
|
210
|
+
`)){const h=I5.exec(c),p=((u=h==null?void 0:h[1])==null?void 0:u.length)??0;if(!h||o&&(p<i||h[2])){n.push(c);continue}l(),o=!o,i=o?p:0,r=o?(h[2]??"").toLowerCase():""}return l(),t}function R5(e,t){return t==="diff"||t==="patch"||/^diff --git /m.test(e)||/^@@ .*@@/m.test(e)?!0:/^--- /m.test(e)&&/^[+-]/m.test(e)}const $5=/^(diff --git |index [0-9a-f]+\.\.|new file mode |deleted file mode |similarity index |rename (from|to) |Binary files )/;function O5(e){const t=[];for(const n of e.split(`
|
|
211
|
+
`)){const r=L5(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 M5(t),t}function M5(e){var t,n,r,o;for(let i=0;i<e.length;){if(((t=e[i])==null?void 0:t.kind)!=="del"&&((n=e[i])==null?void 0:n.kind)!=="add"){i++;continue}let l=i;for(;((r=e[l])==null?void 0:r.kind)==="del";)l++;let u=l;for(;((o=e[u])==null?void 0:o.kind)==="add";)u++;const c=e.slice(i,l),h=e.slice(l,u),p=c.length>0&&h.length>0?Pj(c.map(g=>g.text).join(`
|
|
212
|
+
`),h.map(g=>g.text).join(`
|
|
213
|
+
`)):null;p&&(wb(c,Uw(p.before)),wb(h,Uw(p.after)));for(const g of[...c,...h])g.spans??(g.spans=[]);i=u}}function wb(e,t){if(t.length===e.length)for(const[n,r]of e.entries())r.spans=t[n]}function L5(e){return e.startsWith("@@")?"hunk":e.startsWith("+++")||e.startsWith("---")||$5.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":""}function P5(e){const t=e.tools.at(-1);return!!t.background&&!t.done&&!t.parentToolId&&t.name!==Wa}const rS=new Set(["read","edit","fetch"]);function oS(e,t){if(e.isError||!e.toolKind||!rS.has(e.toolKind)||Wm(e.toolKind)&&Fd(e.input))return"";const{hint:n}=uc(e,t);return n?`${e.parentToolId??""}
|
|
214
|
+
${e.toolKind}
|
|
215
|
+
${e.name}
|
|
216
|
+
${n}`:""}function vb(e,t,n){if(!t||!("tools"in t)||e.done||e.isError||!e.toolKind||!rS.has(e.toolKind))return!1;const r=t.tools[0];return r.toolKind===e.toolKind&&r.name===e.name&&r.parentToolId===e.parentToolId&&oS(r,n)!==""}function sS(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 D5(e){return e.done&&!e.output&&!e.isError&&ex({name:e.name,kind:e.toolKind},e.input)}function z5(e,t){const n=sS(e),r=[],o=new Map;let i="";for(const[l,u]of e.entries()){if(u.kind!=="tool"){i="",r.push({at:l,item:u});continue}if(D5(u))continue;if(n.has(u.id)){i="";const g={at:l,spawn:u,run:[],end:l};o.set(u.id,{entry:g,key:""}),r.push(g);continue}const c=oS(u,t),h=u.parentToolId?o.get(u.parentToolId):void 0;if(h){const g=h.entry.run,m=g.at(-1);c&&c===h.key&&m?m.tools.push(u):!c&&vb(u,m,t)?m.next=u:g.push({at:l,tools:[u]}),h.key=c,h.entry.end=l;continue}const p=r.at(-1);if(c&&c===i&&p&&"tools"in p){p.tools.push(u);continue}if(!c&&vb(u,p,t)){p.next=u;continue}i=c,r.push({at:l,tools:[u]})}return r}function F5(e){return e.reduce((t,n)=>t+n.tools.length,0)}function B5(e){const t=new Set,n=new Set;let r=!0;for(let i=e.length-1;i>=0;i--){const l=e[i];if(l.kind!=="tool"||!l.parentToolId){r=!1;continue}n.add(l.parentToolId),(r||!l.done)&&t.add(l.parentToolId)}let o=!0;for(let i=e.length-1;i>=0;i--){const l=e[i];l.kind==="user"&&(o=!1),!(l.kind!=="tool"||!l.subagent)&&(l.isError?t.delete(l.id):l.done?N5(l)?o&&!n.has(l.id)&&t.add(l.id):t.delete(l.id):t.add(l.id))}return t}function U5(e,t){const n=[],r=[];let o=-1;for(const i of e)"spawn"in i?t.has(i.spawn.id)?n.push(i):(o=Math.max(o,i.end),r.push({key:o,entry:i})):"tools"in i&&P5(i)?n.push(i):r.push({key:i.at,entry:i});return r.sort((i,l)=>i.key-l.key),{flow:r.map(i=>i.entry),floating:n}}function H5(e){const t=sS(e);return e.some(n=>n.kind==="tool"&&!n.done&&!n.parentToolId&&!n.background&&(!t.has(n.id)||Fd(n.input)))}function W5(e){return e.findIndex(t=>"tools"in t&&!t.tools[0].parentToolId&&!t.tools.at(-1).done&&!t.tools.at(-1).background)}function iS(e,t=!1){const n=new Set;let r=!1,o=!1;return e.forEach((i,l)=>{if(!("tools"in i)||!t&&i.tools[0].parentToolId)return;const u=i.tools.at(-1);if(u.done||u.background||u.name===Wa)return;const c=Jb({name:u.name,kind:u.toolKind});(o||r&&c)&&n.add(l),r=!0,o||(o=c)}),n}function K5(e){return e.findIndex(t=>!t.tools.at(-1).done)}function ak(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function aS(e,t){return!e||!t?e===t:e.length===t.length&&e.every((n,r)=>{var o,i;return n.at===((o=t[r])==null?void 0:o.at)&&n.next===((i=t[r])==null?void 0:i.next)&&ak(n.tools,t[r].tools)})}function Z5(e,t){if(e.length===0)return t;const n=new Map;for(const i of e)n.set(i.at,i);let r=e.length===t.length;const o=t.map((i,l)=>{const u=n.get(i.at),c=u!==void 0&&q5(u,i)?u:i;return c!==e[l]&&(r=!1),c});return r?e:o}function q5(e,t){return"spawn"in e?"spawn"in t&&e.spawn===t.spawn&&e.end===t.end&&aS(e.run,t.run):"tools"in e?"tools"in t&&e.next===t.next&&ak(e.tools,t.tools):"item"in t&&e.item===t.item}function G5(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"&&!eS(r))return t;continue}if(n.item.kind==="thinking"){if(!n.item.text.trim())continue;return V_(n.item.text)?-1:t}if(V5(n.item))return-1}}return-1}function V5(e){return e.kind==="assistant"?!!e.text.trim():e.kind==="ask"?e.ask.kind==="question"||!!e.outcome:!0}function Y5(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 Q5({item:e}){const t=at(),n=M(r=>rn(r,e.worktreeId)!==null);return e.state==="proposed"?null:e.state==="declined"?f.jsx(Do,{icon:"close",word:"not continued",tone:"quiet",at:e.ts,below:e.reason?f.jsx("div",{className:"daemon-below row-dim",children:e.reason}):void 0,children:f.jsxs("span",{className:"daemon-text",children:["in ",e.repo.name]})}):f.jsx(Do,{icon:"spawn",word:"continued",tone:"accent",at:e.ts,children:f.jsxs("span",{className:"daemon-text",children:["in ",e.repo.name,":"," ",f.jsx(Pe,{variant:"inline",tone:"strong",disabled:!n,onClick:()=>e.worktreeId&&t({a:"activate",id:e.worktreeId}),children:e.title??e.repo.name})]})})}function X5({item:e}){return f.jsxs(Do,{icon:"check",word:"landed",tone:"aqua",at:e.ts,children:[f.jsxs("span",{className:"daemon-text",children:[e.title," in ",e.repoName]}),e.url&&f.jsx(Pe,{variant:"inline",tone:"strong",onClick:()=>window.open(e.url,"_blank"),children:"view PR"})]})}function lk({src:e,n:t,name:n,width:r,height:o,bytes:i,uploading:l,onRemove:u,className:c=""}){return f.jsx(Zg,{className:Be("image-chip",c),label:f.jsxs(f.Fragment,{children:[f.jsx("img",{className:"image-thumb",src:e,alt:n,width:40,height:40}),f.jsxs("span",{className:"pick-target",children:[f.jsx("b",{children:ox("image",t)}),f.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",n," · ",r,"×",o," · ",qm(i),l&&" · uploading"]})]})]}),peek:f.jsx("img",{src:e,alt:n,style:{aspectRatio:`${r} / ${o}`}}),full:f.jsx("img",{src:e,alt:n}),menu:h=>cc(e,h),removeLabel:"Remove image",onRemove:u})}function J5({img:e,src:t}){return f.jsx(lk,{className:"in-chat",src:t,...e})}function lS(e,{sock:t,dispatch:n}){var g,m;const r=y=>y?"hide":"show",o=e.repos.some(y=>y.id===e.activeRepoId),i=(g=rn(e,e.activeId))==null?void 0:g.worktree.id,l=[];o&&(l.push({id:"new",label:"new worktree…",key:Tt("new"),onClick:()=>n({a:"open-draft"})}),l.push({id:"refs",label:"open a branch or PR…",key:Tt("refs"),onClick:()=>n({a:"open",overlay:{kind:"refs"}})})),i&&(l.push({id:"jump",label:"jump to file…",key:Tt("quick-open"),onClick:()=>n({a:"open",overlay:{kind:"quick-open"}})}),l.push({id:"search",label:"search in files…",key:Tt("search"),onClick:()=>n({a:"open",overlay:{kind:"search"}})})),xd(e)&&l.push({id:"routes",label:"go to page…",key:Tt("routes"),onClick:()=>n({a:"open",overlay:{kind:"routes"}})}),o&&l.push({id:"chats",label:"search chats…",key:Tt("chats"),onClick:()=>n({a:"open",overlay:{kind:"chats"}})});const u=ag(e.visible,e.activeId,1);u&&l.push({id:"wt-unseen-next",label:"next that needs you",key:Tt("wt-unseen-next"),onClick:()=>n({a:"activate",id:u.activate})}),l.push({id:"project",label:e.repos.length>1?"switch project…":"open project…",key:Tt("project"),onClick:()=>n({a:"open",overlay:{kind:"projects",form:"center"}})});const c=[{id:"changes",label:`${r(e.layout.changes)} changes panel`,key:Tt("changes"),onClick:()=>n({a:"toggle-changes"})},{id:"files",label:`${r(e.layout.changes&&za(e)==="files")} files`,key:Tt("files"),onClick:()=>n(e.layout.changes&&za(e)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"})},{id:"chat",label:`${r(e.layout.chat)} chat panel`,key:Tt("composer"),onClick:()=>n({a:"toggle-chat"})},{id:"terminal",label:`${r(e.layout.term)} terminal`,key:Tt("terminal"),onClick:()=>n({a:"toggle-terminal"})},{id:"rail",label:`${r(e.railOpen)} worktree panel`,key:Tt("rail"),onClick:()=>n({a:"toggle-rail"})},{id:"design",label:`${r(e.layout.design)} design system`,key:Tt("design"),onClick:()=>n({a:"toggle-design"})},{id:"zen",label:"full-bleed preview",key:Tt("zen"),onClick:()=>n({a:"toggle-zen"})}],h=[{id:"commands",label:"command palette",key:Tt("commands"),onClick:()=>n({a:"open",overlay:{kind:"commands"}})},{id:"keys",label:"settings & shortcuts",key:Tt("keys"),onClick:()=>n({a:"open",overlay:{kind:"keys"}})}];if((m=e.self)!=null&&m.restart&&h.push({id:"restart-daemon",label:"restart Toyon",onClick:()=>t==null?void 0:t.send({t:"restart-daemon"})}),h.push({id:"add-machine",label:"add a machine",onClick:()=>n({a:"open",overlay:{kind:"add-machine"}})}),e.remote){e.frame==="desk"&&h.push({id:"pair",label:"open on your phone",onClick:()=>n({a:"open",overlay:{kind:"pair"}})});const y=Hj(`https://${e.remote.host}`);h.push({id:"toyon-cloud",label:"add to toyon.cloud",...e.managed.deploy?{}:{disabled:"managed by your organization"},onClick:()=>window.open(y,"_blank")})}const p=wo(e)?new Set(["chat","design","zen"]):null;return Mn([l,p?c.filter(y=>!p.has(y.id)):c,h])}function ck(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 i=[{id:`forget-machine:${t}`,label:`forget ${r}…`,danger:!0,onClick:()=>{window.confirm(`Forget ${r}?
|
|
217
|
+
|
|
218
|
+
It leaves the list here, and this browser forgets what it had selected there. Toyon on that machine is not touched; pair again to list it.`)&&e.remove(t)}}];return Mn([o,i])}function uk(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 cS(e,{sock:t}){return[{id:"restart:shell",label:"restart shell",onClick:()=>t==null?void 0:t.send({t:"term-restart",worktreeId:e,stream:ko})}]}function e6(e,t,n,r){return Mn([[...e.flatMap(o=>uk(o,t,r)),...cS(t,r)],[{id:"terminal",label:`${n?"hide":"show"} terminal`,onClick:()=>r.dispatch({a:"toggle-terminal"})}]])}function t6(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 wf(e,t,{sock:n,dispatch:r}){const o=[];e.id!==t&&o.push({id:`repo:${e.id}`,label:`switch to ${e.name}`,onClick:()=>r({a:"activate-repo",id:e.id})});const i=[{id:`setup:${e.id}`,label:"project settings…",detail:e.configFile,onClick:()=>r({a:"open",overlay:{kind:"setup",repoId:e.id}})},{id:`archived:${e.id}`,label:"archived worktrees…",onClick:()=>{r({a:"activate-repo",id:e.id}),r({a:"open",overlay:{kind:"chats",names:!0}})}},{id:`forget:${e.id}`,label:"forget project…",danger:!0,onClick:()=>{window.confirm(`Forget ${e.name}?
|
|
219
|
+
|
|
220
|
+
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.`)&&(n==null||n.send({t:"forget-repo",repoId:e.id}))}}];return Mn([o,i])}const Id={dark:"dark",light:"light",system:"follow system",daylight:"follow daylight"},Rd={use:"while in use",always:"always",off:"off"};function n6(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 uS(e,{sock:t,dispatch:n}){var l;const r=e.themePrefs,o=u=>{var c;return((c=e.themes.find(h=>h.id===u))==null?void 0:c.name)??u},i=yL();return Mn([[{id:"theme",label:"theme…",detail:Xd(r,e.themes,T1(e)).name,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"theme"}})},{id:"appearance",topic:"theme",label:"light or dark…",detail:Id[r.mode],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"appearance"}})}],[{id:"agent",label:"default agent…",detail:((l=e.agents.find(u=>u.id===e.defaultAgent))==null?void 0:l.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"})},...i.access==="none"?[]:[{id:"clipboard-offer",label:"offer what is copied",detail:i.access==="denied"?"blocked in site settings":i.on?"on":"off",onClick:()=>wL(!i.on)}]],...e.keepAwake===null?[]:[[{id:"keep-awake",label:"keep awake…",detail:Rd[e.keepAwake],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"keep-awake"}})}]],[{id:"theme-import",topic:"theme",label:"import a VS Code theme…",onClick:()=>n6((u,c)=>t==null?void 0:t.send({t:"import-theme",name:u,source:c}))},{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 r6(e,t,n,r,o,i={machines:[],switchTo:()=>{},forget:()=>{}}){const l=[],u=(m,y,w,b,E)=>l.push({id:m,label:y,hint:b,run:w,sub:E}),c=(m,y)=>{for(const w of m){if(!Es(w)||w.disabled!==void 0||w.checked)continue;const b=w.key??(typeof w.detail=="string"?w.detail:void 0),E=y?`${y.scope}:${w.id}`:w.id,N=w.topic?`${w.topic}: ${w.label}`:w.label;u(E,y?`${N} · ${y.name}`:N,w.onClick,b,w.sub)}},h={sock:n,dispatch:t},p=r,g=p==null?void 0:p.worktree.id;if(c(lS(e,h).filter(m=>!Es(m)||m.id!=="commands")),o&&c(wf(o,o.id,h),{scope:"project",name:o.name}),g&&!wo(e)&&(u("pick",e.picking==="chat"?"cancel element picker":"pick an element for the chat",()=>ac(g,e.picking,t,"chat"),Tt("pick")),u("inspect",e.picking==="code"?"cancel element picker":"pick an element to open its code",()=>ac(g,e.picking,t,"code"),Tt("inspect")),u("reload","reload preview",()=>Jt.post(g,{type:"reload"}))),c(uS(e,h)),p&&g){const m=e.repos.find(y=>y.id===p.worktree.repoId)??null;c(ME(p,m,e,h,{hostname:e.hostname}),{scope:"wt",name:em(p,m)});for(const y of p.procs)c(uk(y,g,h))}e.visible.forEach((m,y)=>{var N;if(m.worktree.id===g)return;const w=m.worktree.variant,E=e.activeRepoId&&wg(m,e.activeRepoId,e.rows)?` in ${((N=e.repos.find(j=>j.id===m.repoId))==null?void 0:N.name)??m.repoId}`:"";u(`go:${m.worktree.id}`,`switch to ${em(m,o)}${w?` (v${w.index}/${w.of})`:""}${E}`,()=>t({a:"activate",id:m.worktree.id}),uj(y,e.visible.length))});for(const m of e.repos)m.id!==(o==null?void 0:o.id)&&u(`repo:${m.id}`,`switch to project ${m.name}`,()=>t({a:"activate-repo",id:m.id}));for(const m of i.machines){for(const y of m.repos)u(`machine:${m.origin}:${y.id}`,`switch to project ${y.name} on ${m.name}`,()=>i.switchTo(m.origin,y.id));u(`forget-machine:${m.origin}`,`forget ${m.name}`,()=>i.forget(m.origin))}return l}function dS(){const e=at(),t=st(),{host:n}=Lr(),r=_o(),o=B1(),i=M(F=>F.picking),l=M(F=>F.layout),u=M(F=>F.chatSide),c=M(F=>F.keepAwake),h=M(F=>F.railOpen),p=M(F=>F.themePrefs),g=M(F=>F.themes),m=M(F=>F.systemDark),y=M(F=>F.daylight),w=M(F=>F.rows),b=M(F=>F.visible),E=M(F=>F.activeId),N=M(F=>F.activeRepoId),j=M(F=>F.repos),T=M(F=>F.agents),O=M(F=>F.defaultAgent),U=M(F=>F.shipping),Q=M(F=>F.remote),R=M(F=>F.managed),I=M(F=>F.frame),_=M(F=>F.self),L=M(F=>F.archivedPage),z=M(F=>F.archived);return S.useMemo(()=>{const F={picking:i,layout:l,chatSide:u,keepAwake:c,railOpen:h,themePrefs:p,themes:g,systemDark:m,daylight:y,rows:w,visible:b,activeId:E,activeRepoId:N,repos:j,agents:T,defaultAgent:O,shipping:U,remote:Q,managed:R,frame:I,self:_,archivedPage:L,archived:z,hostname:n},ee={machines:o,switchTo:(se,fe)=>{var ke;(ke=r.get(se))==null||ke.store.dispatch({a:"activate-repo",id:fe}),r.activate(se)},forget:se=>{const fe=ck(r,se).find(ke=>Es(ke)&&ke.id.startsWith("forget-machine:"));fe&&Es(fe)&&fe.onClick()}};return r6(F,e,t,rn(F,E),ai(F,N),ee)},[i,l,u,c,h,p,g,m,y,w,b,E,N,j,T,O,U,Q,R,I,_,L,z,e,t,n,r,o])}function fS(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=[];for(const o of e){const i=_m(o.label.toLowerCase(),n);i>0&&r.push({c:o,score:i})}return r.sort((o,i)=>i.score-o.score),r.map(o=>o.c)}function _m(e,t){const n=dk(e,t);if(!n)return 0;let r=0,o=0,i=-1;for(const l of n)o=l===i+1?o+1:1,r+=o+(hS(e,l)?3:0),i=l;return r+Math.max(0,40-e.length/4)}const hS=(e,t)=>t===0||/[\s:\-–—·/.(]/.test(e[t-1]);function dk(e,t){const n=e.toLowerCase(),r=[];let o=0;for(const i of t.toLowerCase()){let l=-1;if(n[o]===i)l=o;else if(i===" ")l=n.indexOf(" ",o);else for(let u=n.indexOf(i,o);u!==-1;u=n.indexOf(i,u+1))if(hS(n,u)){l=u;break}if(l===-1)return null;r.push(l),o=l+1}return r}const _s=(e,...t)=>{const n=e.trim().toLowerCase();return!n||t.some(r=>r==null?void 0:r.toLowerCase().includes(n))},o6=/^[^\s]*$/;function bb(e,t){if(e.startsWith("!"))return null;if(e.startsWith("/")){const i=e.indexOf(" "),l=i===-1?e.length:i;if(!(e.indexOf("/",1)!==-1&&e.indexOf("/",1)<l)&&t<=l)return{kind:"command",query:e.slice(1,t),from:0,to:l}}const n=e.lastIndexOf("@",Math.max(0,t-1));if(n===-1||n>=t||n>0&&!/\s/.test(e[n-1]??""))return null;const r=e.slice(n+1,t);if(!o6.test(r))return null;let o=t;for(;o<e.length&&!/\s/.test(e[o]??"");)o++;return{kind:"file",query:r,from:n,to:o}}const s6={files:new Set,folders:new Set},xb=new WeakMap;function i6(e){if(!e)return s6;let t=xb.get(e);return t||(t={files:new Set(e),folders:new Set(E1(e))},xb.set(e,t)),t}const a6=/(^|\s)(@\S+)/g,l6=/[.,;:!?)\]}'"]$/;function Eb(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(/\/+$/,"");return n&&t.folders.has(n)?{kind:"folder",text:`@${e}`,path:n}:null}function c6(e,t){const n=[];let r=0;const o=i=>{if(!i)return;const l=n.at(-1);(l==null?void 0:l.kind)==="text"?l.text+=i:n.push({kind:"text",text:i})};for(const i of e.matchAll(a6)){const l=i.index+(i[1]??"").length;let u=(i[2]??"").slice(1),c=Eb(u,t);for(;!c&&l6.test(u);)u=u.slice(0,-1),c=u?Eb(u,t):null;c&&(o(e.slice(r,l)),n.push(c),r=l+c.text.length)}return o(e.slice(r)),n}function u6(e,t,n){return{text:e.slice(0,t.from)+n+e.slice(t.to),caret:t.from+n.length}}function d6(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=i=>e.map(l=>({c:l,score:i(l)})).filter(l=>l.score>0).sort((l,u)=>u.score-l.score||l.c.name.localeCompare(u.c.name)).map(l=>l.c),o=r(i=>_m(i.name,n));return o.length>0?o:r(i=>_m(i.description,n))}const f6=/(^|\s)@\S/;function pS({text:e,worktreeId:t,root:n,inField:r}){const o=Kn(),i=st(),l=M(p=>{var g;return t?(g=p.local[t])==null?void 0:g.files:void 0}),u=i6(l),c=S.useMemo(()=>c6(e,u),[e,u]),h=l===void 0&&t&&f6.test(e)?t:null;return S.useEffect(()=>{h&&uf(h,o.getState(),{sock:i,dispatch:o.dispatch})},[h,o,i]),f.jsx(f.Fragment,{children:c.map((p,g)=>{if(p.kind==="text")return p.text;if(p.kind==="changes"){const b=Ft("this worktree's uncommitted files",void 0,{placement:"follow"});return f.jsx("span",{className:"chat-mention","data-changes":"",...b,children:p.text},g)}if(!n||!t)return p.text;const m=p.kind==="folder",y=`${n}/${p.path}${m?"/":""}`,w=Ft(m?`${p.path}/`:p.path,void 0,{placement:"follow"});return f.jsx("a",{className:"chat-mention",href:y,tabIndex:r?-1:void 0,...w,children:p.text},g)})})}function mS(e,t,n,r){if(e.target.closest("[data-changes]")){n&&r.dispatch({a:"focus-changes",tab:"changes"});return}Kg(e,t,n,r)}function h6(e){return e.length<2||!e.every(t=>{var n;return t.length===1&&((n=t[0])==null?void 0:n.diff)})?null:m6(e.map(t=>t[0].text))}const p6=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function m6(e,t=3){let n=[];for(const r of e){const o=g6(r);if(!o)return null;const i=k6(n,o);if(!i)return null;n=i}return n.some(r=>r.kind!=="same")?y6(n,t):null}function g6(e){const t=[];let n=null;for(const r of e.split(`
|
|
221
|
+
`)){const o=p6.exec(r);if(o){n={oldStart:Number(o[1]),newStart:Number(o[2]),ops:[]},t.push(n);continue}if(!n)return null;const i=r[0];if(i===" "||i==="-"||i==="+")n.ops.push({mark:i,text:r.slice(1)});else if(r==="")n.ops.push({mark:" ",text:""});else return null}return t.length>0?t:null}function k6(e,t){const n=[];let r=0,o=0,i=0,l=0;const u=p=>{p.kind==="same"?o=p.a-p.c:p.kind==="add"?o-=1:o+=1},c=()=>{for(;r<e.length&&e[r].kind==="del";)n.push(e[r]),u(e[r]),r++},h=p=>{for(let g=p;g<e.length;g++){const m=e[g];if(m.kind!=="del")return m.c}return Number.POSITIVE_INFINITY};for(const p of t){if(p.oldStart<=l)return null;for(;r<e.length;){const y=e[r];if((y.kind==="del"?h(r):y.c)>=p.oldStart)break;n.push(y.kind==="del"?y:{...y,c:y.c+i}),u(y),r++}let g=p.oldStart,m=p.newStart;for(const y of p.ops){if(c(),y.mark==="+"){n.push({kind:"add",c:m,text:y.text}),m++;continue}const w=e[r],b=w&&w.kind!=="del"&&w.c===g?w:void 0;if(b){if(b.text!==y.text)return null;r++,u(b),y.mark===" "?n.push({...b,c:m}):b.kind==="same"&&n.push({kind:"del",a:b.a,text:b.text})}else y.mark===" "?n.push({kind:"same",a:g+o,c:m,text:y.text}):n.push({kind:"del",a:g+o,text:y.text});y.mark===" "&&m++,g++}i=m-g,l=g-1}for(;r<e.length;r++){const p=e[r];n.push(p.kind==="del"?p:{...p,c:p.c+i})}return n}function y6(e,t){const n=[];for(const r of v6(e))for(const[o,i]of b6(r.rows,t)){const l=w6(r.rows.slice(o,i)),u=l.filter(g=>g.kind!=="add").length,c=l.filter(g=>g.kind!=="del").length,h=l.find(g=>g.kind!=="add"),p=l.find(g=>g.kind!=="del");n.push(`@@ -${h?h.a:r.oldAt[o]},${u} +${p?p.c:r.newAt[o]},${c} @@`,...l.map(g=>`${g.kind==="add"?"+":g.kind==="del"?"-":" "}${g.text}`))}return n.join(`
|
|
222
|
+
`)}function w6(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(i=>i.kind==="del"),...o.filter(i=>i.kind==="add")),n=r}return t}function v6(e){const t=[];let n=null,r=1,o=1;for(const i of e){const l=i.kind==="add"?r:i.a,u=i.kind==="del"?o:i.c;(!n||l!==r||u!==o)&&(n={rows:[],oldAt:[],newAt:[]},t.push(n)),n.rows.push(i),n.oldAt.push(l),n.newAt.push(u),r=l+(i.kind==="add"?0:1),o=u+(i.kind==="del"?0:1)}return t}function b6(e,t){const n=[];let r=0;for(;r<e.length;){if(e[r].kind==="same"){r++;continue}let o=r,i=r;for(;i<e.length;){if(e[i].kind!=="same"){o=i,i++;continue}let l=0;for(;i+l<e.length&&e[i+l].kind==="same";)l++;if(l>t*2||i+l>=e.length)break;i+=l}n.push([Math.max(0,r-t),Math.min(e.length,o+t+1)]),r=o+t+1}return n}function Sm({pieces:e}){return f.jsx(f.Fragment,{children:e.map((t,n)=>{const r=`${t.changed?"ch ":""}${t.scope?`sy-${t.scope}`:""}`.trim();return r?f.jsx("span",{className:r,children:t.text},n):f.jsx(S.Fragment,{children:t.text},n)})})}function fk({pick:e,dir:t,worktreeId:n,tipText:r,onHover:o,onOpen:i,onRemove:l,className:u=""}){const c=e.callFile,h=e.file,p=c?{path:c,line:e.callLine}:h?{path:h,line:e.line}:null,g=c&&h?{path:h,line:e.line}:null,m=(j,T)=>`${j}${T?`:${T}`:""}`,y=j=>j.split("/").pop()??j,w=(j,T,O,U)=>i?f.jsx("button",{className:"pick-open","data-tip":U,onClick:()=>i(j,T??1),children:O}):O,b=on("chat"),{host:E}=Lr(),N=S.useRef(null);return f.jsxs("div",{ref:N,className:Be("pick-chip row row-sm",u),"data-tip":r,onMouseEnter:()=>o==null?void 0:o(!0),onMouseLeave:()=>o==null?void 0:o(!1),...b.contextMenu(()=>iD(e,{dir:t,remove:l,host:E})),children:[f.jsxs("span",{className:"pick-target",children:[f.jsx(St,{name:"pick",className:"icon-inline"})," ",hg(e),p&&f.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",w(p.path,p.line,m(y(p.path),p.line),`Open ${m(p.path,p.line)}`)]}),g&&f.jsxs("span",{className:"pick-file row-dim",children:[" ","·"," ",w(g.path,g.line,m(g.path.split("/").pop()??g.path,g.line),`Open the component: ${m(g.path,g.line)}`)]})]}),l&&f.jsx(Lt,{icon:"close",label:"Remove attachment",tone:"quiet",onClick:l}),n&&(p==null?void 0:p.line)&&f.jsx(p_,{chip:N,children:f.jsx(_6,{worktreeId:n,path:p.path,line:p.line})})]})}const x6=6,E6=16;function _6({worktreeId:e,path:t,line:n}){const r=U1(),o=st(),i=M(g=>{var m;return((m=xo(g))==null?void 0:m.id)===e}),l=M(g=>{var m;return i?0:(m=bo(g,e).changedRanges[t])==null?void 0:m.offset}),[u,c]=S.useState(null);S.useEffect(()=>{let g=!0;return i||o==null||o.send({t:"changed-ranges",worktreeId:e,path:t}),r==null||r.look(e,t).then(m=>{g&&c(m)}),()=>{g=!1}},[r,o,e,t,i]);const h=S.useMemo(()=>{if(u===null||l===void 0)return null;const g=u.split(`
|
|
223
|
+
`),m=n-l,y=Math.max(1,m-x6),w=Math.min(g.length,m+E6);if(y>w)return null;const b=g.slice(y-1,w);return{from:y,at:m,slice:b,painted:nk(b.join(`
|
|
224
|
+
`),tk("",t))}},[u,l,n,t]);if(!h)return null;const p=String(h.from+h.slice.length-1).length;return f.jsx("pre",{className:"pick-peek",children:h.slice.map((g,m)=>{const y=h.from+m,w=h.painted[m];return f.jsxs("span",{className:"pick-peek-line","data-state":y===h.at?"current":void 0,children:[f.jsx("span",{className:"pick-peek-n",children:String(y).padStart(p)}),w!=null&&w.length?f.jsx(Sm,{pieces:w}):g||" "]},y)})})}function S6(e){return e.startsWith("!")?e.slice(1).trim():null}function vf(e){if(e.kind!=="tool"||e.name!==Wa&&e.name!==Xb)return null;const t=e.input;return typeof(t==null?void 0:t.command)=="string"?t.command:null}function N6(e){return e.length>0&&e.every(t=>vf(t)!==null&&t.kind==="tool"&&t.done&&!t.isError)}function T6(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(o.kind==="user")break;if(o.kind!=="tool"||!o.done||n.has(o.id))continue;const i=vf(o);if(i===null)continue;const l=nS(o.output??"").map(c=>c.text).join(`
|
|
225
|
+
`),u=dO(l);t.unshift(`$ ${i}${u?`
|
|
226
|
+
${u}`:""}`)}if(t.length!==0)return`Shell commands the user ran since their last message, and what each printed:
|
|
227
|
+
${t.join(`
|
|
228
|
+
`)}`}function j6(e,t,n,r,o){const{sock:i}=r,l=e[0];if(!l)return[];const u=[],c=ik(yf(l),t);if(c&&!c.startsWith("/")&&n){const w=l.toolKind==="edit"?"diff":"file";u.push({id:"open-diff",label:`open ${w}`,onClick:()=>nr(r,{worktreeId:n.id,path:c,view:w})}),u.push(...Bi(`${n.dir}/${c}`,()=>i==null?void 0:i.send({t:"reveal",worktreeId:n.id,path:c}),ts(i)))}else c.startsWith("/")&&u.push(...Bi(c,void 0,ts(i)),{id:"copy-path",label:"copy path",onClick:()=>Yt(c)});const h=[],p=uc(l,t).command,g=C5(l);g&&g!==p&&h.push({id:"copy-description",label:"copy description",onClick:()=>Yt(g)}),p&&h.push({id:"copy-command",label:"copy command",onClick:()=>Yt(p)});const m=e.map(w=>w.output??"").filter(Boolean).join(`
|
|
229
|
+
`);m&&h.push({id:"copy-output",label:"copy output",onClick:()=>Yt(m)});const y=o.leaf?[]:[{id:"fold",label:o.open?"collapse":"expand",onClick:o.toggle}];return Mn([u,h,y])}const gS=e=>e.replace(/\n$/,""),C6=1500,_b=4;function kS(e){return e.closest(".md pre, .card-code pre")}function Nm(e){const t=kS(e);return t?gS(t.textContent??""):null}function A6(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{pre:t,top:r.top-n.top+e.scrollTop+_b,right:n.left+e.clientLeft+e.clientWidth-r.right+_b}}function hk(e){const[t,n]=S.useState(null),[r,o]=S.useState(null);if(S.useEffect(()=>{const h=e.current;if(!h)return;const p=m=>{if(!(m.target instanceof Element)||m.target.closest(".code-copy"))return;const y=kS(m.target);n(y&&h.contains(y)?A6(h,y):null)},g=()=>n(null);return h.addEventListener("pointerover",p),h.addEventListener("pointerleave",g),()=>{h.removeEventListener("pointerover",p),h.removeEventListener("pointerleave",g)}},[e]),S.useEffect(()=>{if(!r)return;const h=setTimeout(()=>o(null),C6);return()=>clearTimeout(h)},[r]),!(t!=null&&t.pre.isConnected))return null;const{pre:i,top:l,right:u}=t,c=r===i;return f.jsx(Lt,{className:"code-copy",style:{top:l,right:u},icon:c?"check":"copy",label:c?"Copied":"Copy code",onClick:()=>{Yt(gS(i.textContent??"")),o(i)}})}function Sb({text:e,menu:t,marked:n,worktreeId:r,fileRoot:o,streaming:i}){const l=rk(e,{fileRoot:o,streaming:i}),u=st(),c=at(),h=on("chat"),p=S.useRef(null);Z1(p,l);const g=M(w=>{var b;return r?(b=w.local[r])==null?void 0:b.refusedLink:void 0});yt([l,g],()=>{var b;const w=p.current;if(w)for(const E of w.querySelectorAll("a.file-link")){const N=g!==void 0&&E.getAttribute("href")===g.href;E.classList.toggle("file-link-refused",N),N?((b=E.dataset).tipWas??(b.tipWas=E.dataset.tip??""),E.dataset.tip=g.message,E.dataset.tipPlacement="bottom",E.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0}))):E.dataset.tipWas!==void 0&&(E.dataset.tip=E.dataset.tipWas,E.dataset.tipPlacement="follow",delete E.dataset.tipWas)}});const m=S.useRef(null),y=hk(m);return f.jsxs("div",{ref:m,className:"msg-assistant md row-edge","data-state":pr({cursor:n}),...h.contextMenu((w,b)=>t(Wg(b,o),Nm(b))),onClick:w=>Kg(w,o,r,{sock:u,dispatch:c}),children:[f.jsx("div",{ref:p}),y]})}const jp=40;function yS(e,t){return e.map(n=>{const r=tk(n.lang,t||(n.diff?V3(n.text):""));if(n.diff){const o=O5(n.text);return{...n,lines:o,painted:X3(o,r)}}return{...n,lines:[],painted:n.code?nk(n.text,r):[]}})}function wS({blocks:e,path:t,worktreeId:n}){st();const r=at();return f.jsx("div",{className:"tool-out",children:e.map((o,i)=>o.diff?f.jsxs("pre",{className:"tool-block diff",children:[o.lines.slice(0,jp).map((l,u)=>{var c;return l.kind==="hunk"?f.jsx("span",{className:"dl hunk",title:l.text},u):f.jsx("span",{className:`dl ${l.kind}`,children:(c=o.painted[u])!=null&&c.length?f.jsx(Sm,{pieces:o.painted[u]}):l.text||" "},u)}),o.lines.length>jp&&f.jsxs("button",{type:"button",className:"dl more",disabled:!t||!n,"data-tip":t&&n?"Open this file's diff":void 0,onClick:()=>n&&nr({dispatch:r},{worktreeId:n,path:t,view:"diff"}),children:[o.lines.length-jp," more lines"]})]},i):o.code?f.jsx("pre",{className:"tool-block",children:o.painted.length?o.painted.map((l,u)=>f.jsxs(S.Fragment,{children:[u>0?`
|
|
230
|
+
`:null,f.jsx(Sm,{pieces:l})]},u)):o.text},i):f.jsx("p",{className:"tool-note",children:o.text},i))})}function I6({image:e,worktreeId:t}){const n=Lr().attachment(t,e.file),[r,o]=S.useState(!1),i=on("chat");return f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",className:"tool-image","data-tip":"Open full size","data-tip-placement":"follow",onClick:()=>o(!0),...i.contextMenu(()=>cc(n,{open:()=>o(!0)})),children:f.jsx("img",{src:n,alt:e.file})}),r&&f.jsx(Ug,{owner:"chat",onClose:()=>o(!1),menu:()=>cc(n),children:f.jsx("img",{src:n,alt:e.file})})]})}const R6=S.memo(function({item:t,roots:n,worktreeId:r}){const o=S.useMemo(()=>yS(Em(t,t.output??""),yf(t)),[t]),i=uc(t,n).command,l=r?t.images??[]:[];return!i&&o.length===0&&l.length===0?null:f.jsxs("div",{className:"tool-part",children:[i&&f.jsx("pre",{className:"tool-block cmd",children:i}),o.length>0&&f.jsx(wS,{blocks:o,path:vS(t,n),worktreeId:r}),l.length>0&&r&&f.jsx("div",{className:"tool-out",children:l.map(u=>f.jsx(I6,{image:u,worktreeId:r},u.file))})]})});function vS(e,t){const n=ik(yf(e),t??[]);return n.startsWith("/")?"":n}const $6=S.memo(function({text:t,item:n,roots:r,worktreeId:o}){const i=yf(n),l=S.useMemo(()=>yS([{code:!0,diff:!0,lang:"diff",text:t}],i),[t,i]);return f.jsx("div",{className:"tool-part",children:f.jsx(wS,{blocks:l,path:vS(n,r),worktreeId:o})})});function Tm({className:e,state:t,auto:n,leaf:r,growing:o,label:i,summary:l,menu:u,children:c}){const[h,p]=S.useState(null),g=S.useRef(null),m=S.useRef(null),y=K1(m),w=VM(".chat-log"),b=!r&&(h??n),E=()=>{r||(b||w(g.current),p(!b))},N=on("chat");return f.jsxs("details",{ref:g,className:Be(e,r&&"leaf"),"data-state":t,open:b,onToggle:j=>{if(!j.currentTarget.open||o)return;const T=m.current;T&&(T.scrollTop=0,y.read())},...N.contextMenu((j,T)=>u({open:b,leaf:!!r,toggle:E},T)),tabIndex:-1,onPointerDown:()=>{var j;return(j=g.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;mf([{depth:0,open:b}],0,j.key)&&E();return}j.key!=="Escape"||!b||(j.stopPropagation(),p(!1))},children:[f.jsx("summary",{"aria-label":i,tabIndex:r?-1:void 0,onClick:j=>{j.preventDefault(),E()},children:l}),f.jsx("div",{className:"tool-body",ref:m,children:c})]})}const O6=S.memo(function({item:t,open:n,streaming:r,worktreeId:o,fileRoot:i}){const l=G_(t.text),u=l.slice(0,-1),c=rk(l.length?u.join(`
|
|
231
|
+
|
|
232
|
+
`):Z_(t.text),i?{fileRoot:i}:void 0),h=st(),p=at(),g=r?"Thinking":"Thought",m=S.useRef(null);Z1(m,c);const y=S.useRef(null),w=hk(y),b=f.jsx("div",{className:"tool-part",children:f.jsxs("div",{ref:y,className:"tool-out thought-out md",onClick:N=>Kg(N,i,o,{sock:h,dispatch:p}),children:[f.jsx("div",{ref:m}),w]})}),E=l.at(-1)??(r?"":V_(t.text));if(E){const N=u.length===0;return f.jsx(Tm,{className:"tool-row",auto:!1,leaf:N,growing:r,label:E,menu:(j,T)=>Mn([gm(Nm(T)),[{id:"copy",label:"copy thought",onClick:()=>Yt(t.text)}],...N?[]:[[{id:"fold",label:j.open?"collapse":"expand",onClick:j.toggle}]]]),summary:f.jsxs(f.Fragment,{children:[f.jsx(St,{name:"bulb",className:"tool-icon"}),f.jsx("span",{className:Be("tool-hint thought-line",r&&"live-text"),children:E})]}),children:N?null:b})}return f.jsx(Tm,{className:"tool-row",auto:!!n,growing:r,label:g,menu:(N,j)=>Mn([gm(Nm(j)),[{id:"copy",label:"copy thought",onClick:()=>Yt(t.text)}],[{id:"fold",label:N.open?"collapse":"expand",onClick:N.toggle}]]),summary:f.jsxs(f.Fragment,{children:[f.jsx(St,{name:"bulb",className:"tool-icon"}),f.jsx("span",{className:Be("tool-name",r&&"live-text"),children:g})]}),children:b})}),Bl=6,M6={land:"the land",commit:"the commit","sync-main":"the sync","pull-main":"the pull"},Cp=S.memo(function e({tools:t,run:n,next:r,live:o,working:i,since:l,queued:u,roots:c,worktreeId:h,marked:p}){const g=t[0],m=S.useMemo(()=>h6(t.map(ce=>Em(ce,ce.output??""))),[t]),y=t.at(-1)??g,w=!y.done,b=w&&!!y.background,N=(w||!!r)&&!u||!!i,j=w&&!!u,T=Fa(w||i?l:void 0),O=n?K5(n):-1,U=S.useMemo(()=>n?iS(n,!0):void 0,[n]),Q=!!o,R=uc(g,c),I=w?j5(g):"",{label:_,icon:L}=R,z=eS(g),F=I?"":z?"Guardian":R.name,ee=I&&g.subagent?R.hint:"",se=ee||I||(z?_5(g.output??""):R.hint),fe=!(n&&n.length>0)&&!m&&t.every(ce=>{var me;return!uc(ce,c).command&&Em(ce,ce.output??"").length===0&&!((me=ce.images)!=null&&me.length)}),ke=n?F5(n):0,ne=N6(t),A=[_,se].filter(Boolean).join(" ")+(b?", in the background":"")+(j?", queued":"")+(ne?", done":""),q=I?"":n?`${ke} ${ke===1?"call":"calls"}`:t.length>1?`×${t.length}`:"",ie=Kn(),P=st(),W=M(ce=>{var me;return h?(me=ce.shipping[h])==null?void 0:me.op:void 0}),xe=w&&g.name===Wa&&h?{worktreeId:h,toolId:y.id}:null;return f.jsxs(Tm,{className:Be("tool-row",t.some(ce=>ce.isError)&&"error",g.parentToolId&&"nested",n&&"spawn",j&&"queued"),state:pr({cursor:p}),auto:Q,leaf:fe,growing:N,label:n&&q?`${A}, ${q}`:t.length>1?`${A}, ${t.length} calls`:A,menu:ce=>{const me=rn(ie.getState(),h),_e=me?{id:me.worktree.id,dir:me.worktree.path}:null;return j6(t,c??[],_e,{sock:P,dispatch:ie.dispatch},ce)},summary:f.jsxs(f.Fragment,{children:[f.jsx(St,{name:n?"spawn":L,className:"tool-icon"}),F&&f.jsx("span",{className:Be("tool-name",N&&!se&&"live-text"),children:F}),I&&!ee?f.jsx("span",{className:"tool-writing","data-tip":se,children:f.jsx(Ba,{variant:"squares"})}):se&&f.jsx("span",{className:Be("tool-hint",N&&"live-text"),children:se}),b&&f.jsx("span",{className:"tool-status",children:"in the background"}),j&&f.jsx("span",{className:"tool-status",children:"queued"}),ne&&f.jsx(St,{name:"check",className:"tool-done"}),T>=Bl&&f.jsx("span",{className:Be("tool-age",O>=0&&"tool-age-folded"),children:Ca(T)}),q&&f.jsx("span",{className:"tool-count",children:q}),ee&&f.jsx("span",{className:"tool-writing","data-tip":I,children:f.jsx(Ba,{variant:"squares"})}),xe&&f.jsx(Lt,{icon:"stop",tone:"danger",className:"tool-stop",label:W?`Stop ${M6[W]}: this step is killed, and what it printed so far stays`:b?"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:ce=>{ce.preventDefault(),ce.stopPropagation(),P==null||P.send({t:"exec-stop",...xe})}})]}),children:[n&&n.length>0&&f.jsx("div",{className:"spawn-run",children:n.map((ce,me)=>f.jsx(e,{tools:ce.tools,next:ce.next,since:me===O?l:void 0,queued:U==null?void 0:U.has(me),roots:c,worktreeId:h},ce.at))}),m?f.jsx($6,{text:m,item:g,roots:c,worktreeId:h}):t.map(ce=>f.jsx(R6,{item:ce,roots:c,worktreeId:h},ce.id))]})},(e,t)=>e.live===t.live&&e.working===t.working&&e.since===t.since&&e.queued===t.queued&&e.next===t.next&&e.roots===t.roots&&e.worktreeId===t.worktreeId&&e.marked===t.marked&&ak(e.tools,t.tools)&&aS(e.run,t.run));function L6({item:e}){const t=st(),n=at(),r=M(w=>w.activeId),o=M(w=>w.layout.term),i=M(w=>{var b;return((b=w.rows.find(E=>E.id===w.activeId))==null?void 0:b.login)??!1}),l=M(w=>w.managed.problem),[u,c]=S.useState(""),[h,p]=S.useState(null),g=S.useRef(!1);if(yt([i],()=>{i&&g.current&&r&&n({a:"term-stream",id:r,stream:bs,tall:!0})}),yt([e.done],()=>{e.done&&g.current&&o&&n({a:"toggle-terminal"}),g.current=!1}),!r)return null;const m=(w,b)=>{t==null||t.send({t:"agent-auth",worktreeId:r,methodId:w,...b?{apiKey:b}:{}})},y=e.methods.find(w=>w.id===h);return f.jsxs("div",{className:`auth-card ${e.done?"done":""}`,children:[f.jsx("div",{className:"auth-title",children:e.done?`${e.agentName} is logged in`:e.rejected?`${e.agentName}'s credentials were refused`:`${e.agentName} is not logged in`}),!e.done&&f.jsxs("div",{className:"auth-methods",children:[e.methods.map(w=>w.needsKey?f.jsx(Pe,{variant:"outline",on:h===w.id,"data-tip":w.description,onClick:()=>p(h===w.id?null:w.id),children:w.name},w.id):f.jsx(Pe,{variant:"outline","data-tip":w.kind==="terminal"?"opens in the terminal pane":w.description,onClick:()=>{m(w.id),w.kind==="terminal"&&(g.current=!0)},children:w.name},w.id)),f.jsx(Pe,{variant:"outline","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&&i&&f.jsx("div",{className:"hint auth-hint",children:"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.withheld&&f.jsx("div",{className:"hint auth-hint",children:l?"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&&y&&f.jsxs("form",{className:"auth-key",onSubmit:w=>{w.preventDefault(),u.trim()&&(m(y.id,u.trim()),c(""),p(null))},children:[f.jsx(vo,{type:"password",autoFocus:!0,placeholder:`${y.name} for ${e.agentName}`,value:u,onChange:w=>c(w.target.value)}),f.jsx(Pe,{type:"submit",children:"use key"})]})]})}const P6=S.memo(function({item:t,worktreeId:n,onPickHover:r,marked:o,streaming:i}){const l=Kn(),u=st(),c=Lr(),h=on("chat"),p={sock:u,dispatch:l.dispatch},g=()=>{const y=rn(l.getState(),n);return y?y.worktree.path:null},m=()=>{var y;return(y=rn(l.getState(),n))==null?void 0:y.worktree.path};switch(t.kind){case"user":{const y=m();return f.jsxs("div",{className:"msg-user row-edge","data-state":pr({cursor:o}),...h.contextMenu((w,b)=>Il(t,n??null,p,{link:Wg(b,y),dir:g()})),onClick:w=>mS(w,y,n,p),children:[t.attachments&&n&&f.jsx("div",{className:"msg-attachments",children:t.attachments.map(w=>w.kind==="image"?f.jsx(J5,{img:w,src:c.attachment(n,w.file)},`${w.kind}-${w.n}`):w.kind==="file"?f.jsx(sk,{className:"in-chat",name:w.name,bytes:w.bytes,href:w.text?c.attachment(n,w.file):void 0},`${w.kind}-${w.n}`):w.kind==="paste"?f.jsx(ok,{className:"in-chat",n:w.n,name:w.name,source:w.source,lines:w.lines,chars:w.chars,preview:w.preview,href:c.attachment(n,w.file)},`${w.kind}-${w.n}`):f.jsx(fk,{pick:w,dir:g(),className:"in-chat",tipText:"Hover to highlight on the page",onHover:b=>r==null?void 0:r(w,b),worktreeId:n,onOpen:(b,E)=>Ha(l,u,n,b,E)},`${w.kind}-${w.n}`))}),f.jsx(pS,{text:t.text,worktreeId:n,root:y})]})}case"assistant":return f.jsx(Sb,{text:t.text,menu:(y,w)=>Il(t,n??null,p,{link:y,code:w,dir:g()}),marked:o,worktreeId:n,fileRoot:m(),streaming:i});case"error":return f.jsx("div",{className:"msg-assistant msg-error",...h.contextMenu(()=>Il(t,n??null,p)),children:t.text});case"auth":return f.jsx(L6,{item:t});case"ask":{const y=q2(t);if(!y)return f.jsx(kD,{item:t});const w=k1(y.questions,y.answers).join(`
|
|
233
|
+
`),b={kind:"assistant",text:w};return f.jsxs(f.Fragment,{children:[f.jsx(Sb,{text:y.message,menu:(E,N)=>Il({kind:"assistant",text:y.message},n??null,p,{link:E,code:N,dir:g()}),worktreeId:n,fileRoot:m()}),f.jsx("div",{className:"msg-user",...h.contextMenu(()=>Il(b,n??null,p)),children:w})]})}case"blocked":return f.jsxs(Do,{icon:"lock",word:"blocked",tone:"red",below:f.jsx("div",{className:"daemon-below row-dim",children:t.reason}),...h.contextMenu(()=>u_(t.path,g(),void 0,ts(p.sock))),children:[f.jsx("span",{className:"tool-name",children:t.tool}),t.path&&f.jsx("span",{className:"tool-hint",children:t.path})]});case"grafted":return f.jsxs(Do,{icon:"layers",word:"grafted",tone:"accent","data-tip":`what follows was said in ${t.title} before it was merged in here`,"data-tip-placement":"follow",children:[f.jsx("span",{className:"tool-name",children:t.title}),f.jsx("span",{className:"tool-hint",children:t.branch})]});case"asked":return f.jsx(Do,{icon:"send",word:"asked",tone:"quiet",children:f.jsx("span",{className:"daemon-text",children:t.why})});case"landed":return f.jsx(z6,{item:t});case"handoff":return f.jsx(Q5,{item:t});case"handoff-landed":return f.jsx(X5,{item:t});case"restored":return f.jsx(D6,{item:t});case"adopted":return f.jsx(Do,{icon:"branch",word:"taken over",tone:"quiet",at:t.ts,children:f.jsxs("span",{className:"daemon-text",children:["on ",t.branch,", its own branch"]})})}});function D6({item:e}){return f.jsx(Do,{icon:"reload",word:"restored",tone:"quiet",at:e.ts,children:f.jsxs("span",{className:"daemon-text",children:["after ",pg(e.ts-e.archivedAt)," in the archive, back on ",e.branch,e.uncommitted?" with its uncommitted changes":""]})})}function z6({item:e}){const t=st(),n=at(),r=M(i=>e.archiveIds.filter(l=>rn(i,l)!==null).length),o=e_(e.ts);return f.jsxs(Do,{icon:"check",word:"landed",tone:"aqua",at:e.ts,children:[f.jsxs("span",{className:"daemon-text",children:[e.text,", ",o]}),r>0&&f.jsx(Pe,{variant:"inline",tone:"strong",onClick:()=>Pi(t,n,e.archiveIds),children:r>1?`archive ${r} worktrees`:"archive the other worktree"})]})}function bS(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 F6(e){return e.kind==="ask"?B2(e):`Continue in ${e.repo.name}?`}function B6(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 U6(e,t,n){const r=e.trim();if(!r)return{pick:!0};if(t.length<2)return{error:"open another project first"};const o=r.search(/\s/),i=o===-1?r:r.slice(0,o),l=o===-1?void 0:r.slice(o).trim()||void 0,u=i.toLowerCase(),c=t.filter(g=>g.name.toLowerCase()===u),h=c.length>0?c:t.filter(g=>g.name.toLowerCase().startsWith(u));if(h.length===0)return{error:`no open project named "${i}"`};if(h.length>1)return{error:`"${i}" names more than one project`};const p=h[0];return p.id===n?{error:`this worktree is already in ${p.name}`}:{repo:p,...l?{text:l}:{}}}const xS=e=>e===""||e==="!";function Nb(e,t){const n=new Set,r=[];for(let o=e.length-1;o>=0;o--){const i=e[o],l=vf(i),u=l!==null?`!${l}`:i.kind==="user"&&!t?i.text:null;u===null||!u.trim()||n.has(u)||(n.add(u),r.push({text:u,at:o}))}return r}function H6(e,t,n,r){if(!t){if(r!=="up"&&r!=="first"||!xS(n))return null;const u=Nb(e,n==="!"),c=r==="up"?u[0]:u.at(-1);return c?{walk:{at:c.at,from:n},text:c.text}:null}if(r==="box")return{walk:null,text:t.from};const o=Nb(e,t.from==="!"),i=r==="first"?o.length-1:o.findIndex(u=>u.at===t.at)+(r==="up"?1:-1);if(i<0)return{walk:null,text:t.from};const l=o[i];return l?{walk:{at:l.at,from:t.from},text:l.text}:{walk:t,text:n}}function W6(e,t,n,r){const o=new Map;return{rows:t.map((l,u)=>{const c=n(l,u),h=e.get(l.at),p=h&&h.row.kind===c.kind&&K6(h.row.props,c.props)?h.el:r(l,c);return o.set(l.at,{row:c,el:p}),p}),cache:o}}function K6(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 i=e[o],l=t[o];if(!Object.is(i,l)&&(!Array.isArray(i)||!Array.isArray(l)||i.length!==l.length||!i.every((u,c)=>Object.is(u,l[c]))))return!1}return!0}const Z6={get current(){return Vl.el}};function Tb({items:e,next:t,worktreeId:n,dir:r,onOpen:o}){const i=Lr();return f.jsx("div",{className:"msg-attachments",children:ix(e,t).map(([l,u])=>l.kind==="image"?f.jsx(lk,{className:"in-chat",src:i.upload(l.upload),n:u,name:l.name,width:l.width,height:l.height,bytes:l.bytes},`image-${u}`):l.kind==="file"?f.jsx(sk,{className:"in-chat",name:l.name,bytes:l.bytes,href:l.text?i.upload(l.upload):void 0},`file-${u}`):l.kind==="paste"?f.jsx(ok,{className:"in-chat",n:u,name:l.name,source:l.source,...og(l.text),text:l.text},`paste-${u}`):f.jsx(fk,{className:"in-chat",pick:l,dir:r,worktreeId:n,onOpen:o},`pick-${u}`))})}const q6=new Set,G6=240;function Ap({active:e,archived:t,found:n,lead:r,tail:o}){const i=st(),l=Kn(),u=at(),c=M(ye=>ye.frame==="phone"),h=(e==null?void 0:e.worktree.id)??(t==null?void 0:t.id)??(n==null?void 0:n.id)??null,p=At(h,"chat"),g=At(h,"queue"),m=At(h,"restoring"),y=At(h,"sending"),w=S.useMemo(()=>sx(p.map(ye=>ye.kind==="user"?ye.attachments:void 0)),[p]),b=S.useMemo(()=>{let ye=w;return g.map(Le=>{const wn=ye;return ye=ax(ye,Le.attachments??[]),wn})},[g,w]),E=y!=null&&y.message?g.findIndex(ye=>{var Le;return ye.text===((Le=y.message)==null?void 0:Le.text)}):-1,N=S.useRef(null);oD(N);const[j,T]=S.useState(null),O=S.useCallback(()=>{const ye=(N.current&&mm(N.current))??"";T(Le=>({seed:ye||(Le==null?void 0:Le.seed)||"",seq:((Le==null?void 0:Le.seq)??0)+1}))},[]),U=S.useCallback(ye=>!(ye!=null&&ye.closest("[data-pane]"))&&!l.getState().overlay,[l]);i_(Z6,Bg,O,U);const Q=ye=>{if(T(null),ye){const Le=window.getSelection();Le==null||Le.removeAllRanges(),Le==null||Le.addRange(ye)}},R=K1(N,p);yt([h],()=>R.jump());const I=R.offStart&&R.moving==="up",_=R.offEnd&&(R.moving==="down"||R.away),L=ye=>ye.preventDefault(),z=(I||_)&&f.jsxs("div",{className:Be("jump",R.away&&"jump-news"),children:[I&&f.jsx("button",{className:"jump-up",onMouseDown:L,onClick:R.start,"data-tip":"Jump to start",children:f.jsx(St,{name:"caret-up",className:"icon-inline"})}),_&&f.jsxs("button",{className:"jump-down",onMouseDown:L,onClick:R.jump,"data-tip":"Jump to latest",children:[f.jsx(St,{name:"caret",className:"icon-inline"}),R.away&&" new messages"]})]});S.useEffect(()=>{const ye=N.current;if(!c||!R.offEnd||!ye){u({a:"reading",on:!1});return}const Le=()=>{ye.scrollHeight-ye.scrollTop-ye.clientHeight<=G6||(u({a:"reading",on:!0}),ye.removeEventListener("scroll",Le))};return Le(),ye.addEventListener("scroll",Le,{passive:!0}),()=>ye.removeEventListener("scroll",Le)},[c,R.offEnd,u]),S.useEffect(()=>()=>u({a:"reading",on:!1}),[u]);const F=At(h,"mark"),ee=(F==null?void 0:F.by)==="walk"?F.at:void 0,se=S.useRef(null),fe=()=>{const ye=N.current,Le=ye==null?void 0:ye.querySelector(':scope > [data-state~="cursor"]');if(!ye||!Le)return;const wn=parseFloat(getComputedStyle(ye).paddingTop)||0;ye.scrollTop+=Le.getBoundingClientRect().top-ye.getBoundingClientRect().top-wn,R.read()};yt([ee],()=>{const ye=N.current;if(ye){if(ee===void 0){const Le=se.current;if(se.current=null,!Le||!xS(bo(l.getState(),h).draft))return;Le.bottom?R.jump():(ye.scrollTop=Le.top,R.read());return}se.current??(se.current={bottom:R.pinned(),top:ye.scrollTop}),fe()}});const ke=At(h,"sent");yt([ke],()=>{ke&&R.jump()});const ne=(F==null?void 0:F.by)==="reveal"?F:void 0,A=S.useMemo(()=>ne?Y5(p,ne.seq):-1,[p,ne]),q=ee??(A>=0?A:void 0);yt([ne==null?void 0:ne.n,A],()=>{A>=0&&fe()});const ie=S.useCallback((ye,Le)=>{h&&(Le?Jt.post(h,{type:"highlight-selector",selector:ye.selector,label:hg(ye)}):Jt.post(h,{type:"highlight-clear"}))},[h]),P=!!e&&yc(e),W=At(h,"cardParked"),xe=S.useMemo(()=>{const ye=bS(p);return!!ye&&W!==ye.id},[p,W]),ce=e==null?void 0:e.worktree,me=(ce==null?void 0:ce.path)??(t==null?void 0:t.path)??(n==null?void 0:n.path),_e=S.useMemo(()=>me?[me]:[],[me]),ae=S.useMemo(()=>z5(p,_e),[p,_e]),be=S.useMemo(()=>P?B5(p):q6,[P,p]),ze=S.useMemo(()=>U5(ae,be),[ae,be]),re=ze.floating,he=S.useRef([]),pe=S.useMemo(()=>(he.current=Z5(he.current,ze.flow),he.current),[ze]),Te=(e==null?void 0:e.agent)==="working",Ue=Te||(e==null?void 0:e.agent)==="waiting",ct=S.useMemo(()=>Ue?G5(pe):-1,[Ue,pe]),We=pe.at(-1),xn=Te&&We&&"item"in We&&(We.item.kind==="thinking"||We.item.kind==="assistant")?pe.length-1:-1,Ht=pe.findLastIndex(ye=>{var Le;return"tools"in ye&&((Le=ye.tools[0])==null?void 0:Le.name)===Wa}),It=At(h,"chatAt"),nt=Fa(P?It:void 0),Ve=At(h,"usage"),mt=(Ve==null?void 0:Ve.heard)!==void 0&&It!==void 0&&Ve.heard>It?Ve.heard:void 0,En=Fa(P?mt:void 0),Rt=H5(p),V=re.length>0,ge=xn>=0||Rt||V,ft=S.useMemo(()=>W5(pe),[pe]),qe=S.useMemo(()=>iS(pe),[pe]),un=At(h,"running"),yn=e==null?void 0:e.worktree.path,Tn=(ye,Le)=>"spawn"in ye?{kind:"tool",props:{tools:[ye.spawn],run:ye.run,roots:_e,worktreeId:h}}:"tools"in ye?{kind:"tool",props:{tools:ye.tools,next:ye.next,live:Le===ct||Le===Ht,since:Le===ft?un==null?void 0:un.at:void 0,queued:qe.has(Le),roots:_e,worktreeId:h,marked:ye.at===q}}:ye.item.kind==="thinking"?{kind:"thought",props:{item:ye.item,open:Le===ct,streaming:Le===xn,worktreeId:h,fileRoot:yn}}:{kind:"item",props:{item:ye.item,worktreeId:h,onPickHover:ie,marked:ye.at===q,streaming:Te&&Le===pe.length-1}},gt=S.useRef(new Map),jn=W6(gt.current,pe,Tn,(ye,Le)=>Le.kind==="tool"?f.jsx(Cp,{...Le.props},ye.at):Le.kind==="thought"?f.jsx(O6,{...Le.props},ye.at):f.jsx(P6,{...Le.props},ye.at));return gt.current=jn.cache,f.jsxs("div",{className:"chat-wrap",children:[f.jsxs("div",{className:"chat-log",ref:N,children:[r,jn.rows,re.map(ye=>"spawn"in ye?f.jsx(Cp,{tools:[ye.spawn],run:ye.run,working:!0,since:It,roots:_e,worktreeId:h},ye.at):f.jsx(Cp,{tools:ye.tools,since:It,roots:_e,worktreeId:h},ye.at)),h&&(y==null?void 0:y.message)&&f.jsxs("div",{className:"msg-user",children:[y.message.attachments&&f.jsx(Tb,{items:y.message.attachments,next:w,worktreeId:h,dir:(e==null?void 0:e.worktree.path)??null,onOpen:(ye,Le)=>Ha(l,i,h,ye,Le)}),y.message.text]}),e&&(y||P&&!(e.agent==="waiting"&&xe)&&!Rt&&!V&&!(ge&&nt<Bl))&&f.jsx("div",{className:"working-row",children:e.agent==="waiting"?"waiting for your answer…":ge?nt>=Bl&&f.jsxs("span",{children:["quiet for",f.jsx("span",{className:"working-num",children:Ca(nt)})]}):f.jsxs("span",{className:"working-mark",children:[f.jsx(Ba,{variant:"squares"}),mt!==void 0?En>=Bl&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"working-word",children:"thinking"}),f.jsx("span",{className:"working-num",children:Ca(En)})]}):nt>=Bl&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"working-word",children:"waiting for the model"}),f.jsx("span",{className:"working-num",children:Ca(nt)})]})]})}),h&&g.map((ye,Le)=>Le===E?null:f.jsxs("div",{className:"msg-user queued-msg",children:[f.jsxs("span",{className:"queued-tag",children:[f.jsx(St,{name:"clock",className:"icon-inline"}),f.jsx("span",{className:"queued-word",children:"queued"})]}),f.jsxs("div",{className:"queued-text",children:[ye.attachments&&f.jsx(Tb,{items:ye.attachments,next:b[Le]??w,worktreeId:h,dir:(e==null?void 0:e.worktree.path)??null,onOpen:(wn,_n)=>Ha(l,i,h,wn,_n)}),ye.text]}),f.jsxs("span",{className:"queued-actions",children:[f.jsx(Lt,{icon:"edit",label:"Edit: removes from queue, puts it back in the input",onClick:()=>dE(l,i,h,Le)}),f.jsx(Lt,{icon:"close",label:"Remove from queue",onClick:()=>i==null?void 0:i.send({t:"unqueue",worktreeId:h,index:Le})})]})]},`q-${Le}`)),o,m!==void 0&&f.jsxs("div",{className:"msg-user queued-msg",children:[f.jsxs("span",{className:"queued-tag",children:[f.jsx(St,{name:"clock",className:"icon-inline"}),f.jsx("span",{className:"queued-word",children:n?"taking over":"restoring"})]}),m&&f.jsx("span",{className:"queued-text",children:m})]})]}),j&&f.jsx(o_,{root:N,body:N,seed:j.seed,seq:j.seq,onClose:Q,onReveal:R.read}),z]})}function ES({hints:e,className:t=""}){return f.jsx("div",{className:`key-hints ${t}`.trim(),children:e.map(([n,r])=>f.jsxs("span",{className:"key-hint",children:[f.jsx(zo,{k:n}),r]},n))})}const V6={side:"top",align:"start",offset:4,alignOffset:-10,matchWidth:-20,flip:"side",margin:8};function Y6({results:e,keyOf:t,row:n,rowClass:r,nav:o,listRef:i,empty:l}){return f.jsxs(Ns,{className:"inline-picker",anchor:"parent",placement:V6,children:[f.jsxs("div",{className:"picker-list",ref:i,children:[e.map((u,c)=>f.jsx("button",{className:Be("picker-item",r==null?void 0:r(u)),"data-state":pr({cursor:c===o.index}),onMouseMove:()=>c!==o.index&&o.setIndex(c),onMouseDown:h=>h.preventDefault(),onClick:()=>o.pick(u),children:n(u,c===o.index)},t(u))),e.length===0&&f.jsx("div",{className:"empty",children:l})]}),f.jsx(ES,{hints:[["↑↓","moves"],["tab","inserts"],["esc","dismisses"]]})]})}const jb=e=>Math.max(0,Math.min(1,Number.isFinite(e)?e:0));function Q6({fraction:e,level:t,className:n}){const o=2*Math.PI*5.5,i=jb(e),l=S.useId(),u=3.5,c=2*u*jb(t);return f.jsxs("svg",{className:Be("ring",n),viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[t!==void 0&&f.jsxs(f.Fragment,{children:[f.jsx("clipPath",{id:l,children:f.jsx("circle",{cx:"7",cy:"7",r:u})}),f.jsx("rect",{className:"ring-level",clipPath:`url(#${l})`,x:"0",y:7+u-c,width:"14",height:c})]}),f.jsx("circle",{className:"ring-track",cx:"7",cy:"7",r:5.5}),f.jsx("circle",{className:"ring-fill",cx:"7",cy:"7",r:5.5,strokeDasharray:`${o*i} ${o}`})]})}function X6(e,t=ec.folder.shared){return`New project: ${e}. The repository is empty apart from a root commit. Pick the mainstream stack for what the message describes, and say which in your first sentence; if the message names a stack, that wins. Scaffold it in this directory, write its .gitignore before installing anything, make it start on $PORT, and write ${t}.`}const Xo="";function J6(e){var h;const t=tF(e.name);if(t){const p=[t.qualifier,e.description||e.name].filter(Boolean).join(" · ");return{label:t.label,version:t.version,description:p}}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(" · "),i=e.name.replace(/\s*\([^)]*\)$/,""),l=r.match(/^(.+?) (\d+(?:\.\d+)*)(?: with (.+))?$/);if(!(l!=null&&l[2])||l[1]!==i)return{label:e.name,...e.description?{description:e.description}:{}};const c=[l[3]??((h=e.name.match(/\(([^)]*)\)$/))==null?void 0:h[1]),...o].filter(Boolean).join(" · ");return{label:i,version:l[2],...c?{description:c}:{}}}const eF=/(?:^|[./])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 tF(e){const t=e.match(eF),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 _S(e,t,n,r){const o=tx(e),i=JT(e),l=w=>i&&w===(o==null?void 0:o.id)?i.id:w,u=l(t||n||(o==null?void 0:o.id)||Xo),c=l(t||(o==null?void 0:o.id)||Xo),h=i?e.filter(w=>w!==o):e,p=h.some(w=>w.id===u),g=h.map(w=>({c:w,words:J6(w)})),m=w=>[w.label,w.version].filter(Boolean).join(" "),y=[...o?[]:[{id:Xo,label:r.label,description:r.description}],...g.map(({c:w,words:b})=>{const E=g.filter(j=>m(j.words)===m(b)).length===1?b:void 0,N=E?E.description:w.description;return{id:w.id,label:E?E.label:w.name,...E!=null&&E.version?{suffix:E.version}:{},...E!=null&&E.version&&g.some(j=>j.c!==w&&j.words.label===E.label)?{chip:m(E)}:{},description:w===i?["recommended",N].filter(Boolean).join(" · "):N}}),...u&&!p?[{id:u,label:u}]:[]];if(u!==c){const w=y.find(N=>N.id===u),b=y.findIndex(N=>N.id===c),E=y[b];if(E){const N=(w==null?void 0:w.chip)??(w==null?void 0:w.label)??u;y[b]={...E,description:[`${N} now`,E.description].filter(Boolean).join(" · ")}}}return{rows:y,shown:u,picked:c}}const Ll=(e,t)=>`${e} ${t}`;function nF(e){const t=e.indexOf(" ");return t<0?{agent:e,model:Xo}:{agent:e.slice(0,t),model:e.slice(t+1)}}function rF(e,t,n){const r=e.length>1;let o=Ll(t,n);return{rows:e.flatMap(l=>{var p;const u=l.short??l.name,c=l.id===t;if(!l.available||!((p=l.models)!=null&&p.length))return c&&(o=Ll(l.id,Xo)),[{id:Ll(l.id,Xo),label:u,description:l.available?"its own default model; the rest are listed once it has run":l.reason??"not installed",disabled:!l.available}];const h=_S(l.models,c?n:Xo,void 0,{label:`${u} default`,description:`whatever ${l.name} runs when nothing is asked for`});return c&&(o=Ll(l.id,h.shown)),h.rows.map(g=>({...g,id:Ll(l.id,g.id),...r&&g.id!==Xo?{prefix:u}:{}}))}),shown:o}}function Tc({anchored:e=!1,...t}){return e?f.jsx(oF,{...t,anchored:e===!0?{}:e}):f.jsx(sF,{...t})}function oF({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,anchored:o,coverBy:i,id:l,children:u}){const{onKey:c,back:h}=SS(t);return f.jsx(Ns,{className:Be(r?"":"overlay-box","anchored",n),id:l,anchor:"parent",placement:{side:"bottom",align:"start",cover:!0,margin:0,...o},coverBy:i,onDismiss:e?()=>e():void 0,onKey:c,onBack:()=>h()||(e==null?void 0:e()),children:u})}function sF({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,id:o,children:i}){const{onKey:l,back:u}=SS(t);return f.jsx(Ns,{className:"overlay scrim",id:o,onDismiss:e?()=>e():void 0,onKey:l,onBack:()=>u()||(e==null?void 0:e()),onClick:c=>{e&&c.target===c.currentTarget&&e()},children:f.jsx("div",{className:Be(r?"":"overlay-box",n),children:i})})}function SS(e){const t=Kn(),n=()=>{if(e)return e(),!0;const o=t.getState();return!o.overlay||o.choosingFolder?!1:(t.dispatch({a:"close",back:$1(o.overlay)}),!0)};return{onKey:o=>{o.key==="Escape"&&n()&&o.stopPropagation()},back:n}}function iF({text:e,params:t}){if(t.length===0)return e;const n=[];let r=0;for(const[o,i]of t)o>r&&n.push(e.slice(r,o)),n.push(f.jsx("span",{className:"picker-ghost-param",children:e.slice(o,i)},o)),r=i;return r<e.length&&n.push(e.slice(r)),n}function Ir({items:e,filter:t,keyOf:n,row:r,rowClass:o,rowTitle:i,onPick:l,onBack:u,onActive:c,onSide:h,onTab:p,onQuery:g,completionOf:m,narrowTo:y,placeholder:w,initialQuery:b="",initialIndex:E,selectOnMount:N=!1,idleWhen:j,onIdlePick:T,anchored:O=!1,onEscape:U,lead:Q,trailing:R,empty:I="no matches",footer:_,keys:L,rowMenu:z,groupOf:F,groupHead:ee,headAlone:se=!1}){const fe=on("picker"),[ke,ne]=S.useState(b),A=S.useMemo(()=>t(e,ke),[e,ke,t]),q=S.useRef(null),ie=Wi(),P=H1(N,!ie);S.useEffect(()=>{if(!g)return;const he=setTimeout(()=>g(ke),150);return()=>clearTimeout(he)},[ke,g]);const W=NE({results:A,keyOf:n,q:ke,onPick:l,listRef:q,onActive:c,onSide:h,completionOf:m,narrowTo:y,setQ:ne,initialIndex:E,idle:(j==null?void 0:j(b))??!1,onIdlePick:T}),{index:xe,ghost:ce}=W,me=typeof L=="function"?L(W.active,ke):L,_e=[];me!=null&&me.nav&&_e.push(["↑↓",me.nav]),me!=null&&me.side&&h&&_e.push(["←→",me.side]),me!=null&&me.complete&&(ce!=null&&ce.accept)&&_e.push(["tab",me.complete]),me!=null&&me.tab&&p&&_e.push(["tab",me.tab]),me!=null&&me.pick&&_e.push(["enter",me.pick]),me!=null&&me.back&&_e.push(["esc",me.back]);const ae=f.jsxs("div",{className:"picker-input",onMouseDown:he=>{var pe;he.target.closest("input")||(he.preventDefault(),(pe=P.current)==null||pe.focus())},children:[Q,f.jsxs("div",{className:"picker-caret",children:[f.jsx(vo,{font:"mono",bare:!0,ref:P,value:ke,onChange:he=>{ne(he.target.value),W.setIndex(j!=null&&j(he.target.value)?-1:0)},onKeyDown:he=>{var pe;if(z&&W.active&&(he.key==="ContextMenu"||he.key==="F10"&&he.shiftKey)){const Te=(pe=q.current)==null?void 0:pe.querySelector('[data-state~="cursor"]');if(Te){he.preventDefault(),he.stopPropagation(),Gr.open({items:z(W.active),owner:"picker",target:Te,anchor:Te.getBoundingClientRect()});return}}W.onKeyDown(he)||!p||he.key!=="Tab"||he.shiftKey||(he.preventDefault(),p())},placeholder:w}),ce&&f.jsxs("div",{className:"picker-ghost","aria-hidden":"true",children:[f.jsx("span",{className:"picker-typed",children:ke}),iF(ce)]})]}),R]}),be=new Map;if(F)for(const he of A)be.set(F(he),(be.get(F(he))??0)+1);const ze=f.jsxs("div",{className:"picker-list",ref:q,children:[A.map((he,pe)=>{const Te=F==null?void 0:F(he),Ue=Te!==void 0&&(se||be.size>1)&&(pe===0||(F==null?void 0:F(A[pe-1]))!==Te)?f.jsx("div",{className:"picker-group",children:(ee==null?void 0:ee(Te,be.get(Te)??0))??Te}):null;return f.jsxs(S.Fragment,{children:[Ue,f.jsx("button",{className:Be("picker-item",o==null?void 0:o(he)),"data-state":pr({cursor:pe===xe}),title:i==null?void 0:i(he),onMouseMove:()=>pe!==xe&&W.setIndex(pe),onClick:()=>{var ct;W.pick(he),(ct=P.current)==null||ct.focus()},...fe.contextMenu(()=>(z==null?void 0:z(he))??[]),children:r(he,pe===xe,ke)})]},n(he))}),A.length===0&&f.jsx("div",{className:"empty",children:typeof I=="function"?I(ke):I}),_==null?void 0:_(ke,A)]}),re=_e.length>0&&f.jsx(ES,{hints:_e});return f.jsxs(Tc,{onClose:u,onEscape:U,boxClass:"picker",anchored:O,coverBy:Q?".picker-input > *:first-child":R?".picker-input > *:last-child":void 0,children:[ae,ze,re]})}function Js({value:e,reads:t,options:n,onChange:r,placeholder:o,hint:i,className:l,onClose:u}){const[c,h]=S.useState(!1),p=()=>{h(!1),u==null||u()},g=t??e,m=n.find(w=>w.id===g),y=(m==null?void 0:m.chip)??(m==null?void 0:m.label)??g;return f.jsxs("span",{className:"chip-picker",children:[f.jsx(Pe,{variant:"ghost",tone:"chrome",mono:!0,on:c,className:Be("chip-picker-btn",l),...Ft(i),onClick:()=>c?p():h(!0),children:y}),c&&f.jsx(Ir,{anchored:{flip:"both",margin:8},onEscape:p,items:n,filter:(w,b)=>{const E=b.trim().toLowerCase().split(/\s+/).filter(Boolean);return w.filter(N=>{const j=`${N.prefix??""} ${N.label??N.id} ${N.suffix??""} ${N.id}`.toLowerCase();return E.every(T=>j.includes(T))})},keyOf:w=>w.id,initialIndex:w=>Math.max(0,w.findIndex(b=>b.id===e)),lead:f.jsx(Pe,{tone:"chrome",mono:!0,on:!0,className:"chip-picker-lead",onClick:p,children:y}),placeholder:o,rowClass:()=>"picker-row",row:w=>f.jsxs(f.Fragment,{children:[w.id===e&&f.jsx("span",{className:"row-current","aria-hidden":"true"}),f.jsxs("span",{className:Be("chip-option",w.disabled&&"chip-option-off"),"aria-disabled":w.disabled,children:[f.jsxs("span",{className:"chip-option-name",children:[w.prefix?`${w.prefix} `:null,w.label??w.id,w.suffix?f.jsx("span",{className:"chip-option-suffix",children:` ${w.suffix}`}):null]}),w.description&&f.jsx("span",{className:"chip-option-desc row-dim",children:w.description})]})]}),onPick:w=>{w.disabled||(r(w.id),p())},onBack:p})]})}function NS({choices:e,value:t,current:n,what:r,defaultLabel:o,defaultDescription:i,placeholder:l,className:u,onChange:c,onClose:h}){const{rows:p,shown:g,picked:m}=S.useMemo(()=>_S(e,t,n,{label:o,description:i}),[e,t,n,o,i]);if(e.length===0)return null;const y=p.find(b=>b.id===g),w=(y==null?void 0:y.chip)??(y==null?void 0:y.label)??g;return f.jsx(Js,{value:m,reads:g,options:p,onChange:c,onClose:h,className:u,hint:t?`asked for ${w}; click to change`:`${w}, the agent's choice; click to pick ${r}`,placeholder:l})}function TS(e){const[t,n]=yo(Ze.effortPrefix+(e??""),Xo,r=>r??"",Mr().storage);return[t,n]}function jm({efforts:e,value:t,current:n,onChange:r,onClose:o}){return f.jsx(NS,{choices:e,value:t,current:n,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:r,onClose:o})}function aF(e){const[t,n]=yo(Ze.modePrefix+((e==null?void 0:e.id)??""),ld,r=>mc.some(o=>o.id===r)?r:ld,Mr().storage);return[t,n]}const lF=e=>{var t;return((t=mc.find(n=>n.id===e))==null?void 0:t.description)??""};function Cb({value:e,onChange:t,onClose:n}){return f.jsx(Js,{value:e,options:mc.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}: ${lF(e)}. Click to change`,placeholder:"what the agent may do without asking"})}function jS(e){const[t,n]=yo(Ze.modelPrefix+(e??""),Xo,r=>r??"",Mr().storage);return[t,n]}function CS(e,t,n){e.set(Ze.modelPrefix+t,n)}function Cm({models:e,value:t,current:n,onChange:r,onClose:o}){return f.jsx(NS,{choices:e,value:t,current:n,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:r,onClose:o})}function AS({agents:e,agent:t,model:n,onChange:r,onClose:o}){const{rows:i,shown:l}=S.useMemo(()=>rF(e,t,n),[e,t,n]);if(i.length===0)return null;const u=i.find(h=>h.id===l),c=u?[u.prefix,u.label,u.suffix].filter(Boolean).join(" "):n;return f.jsx(Js,{value:l,options:i,onChange:h=>{const p=nF(h);r(p.agent,p.model)},onClose:o,className:"model-chip",hint:`${c} works on the new worktree; click to change`,placeholder:"which agent and model work on it"})}function IS(e){const t=gf(e),[n,r]=yo(Ze.profilePrefix+((e==null?void 0:e.id)??""),(e==null?void 0:e.config.defaultProfile)??"",i=>i??void 0,Mr().storage);return[t.length===0?void 0:t.includes(n)?n:e==null?void 0:e.config.defaultProfile,r]}function cF({repo:e,value:t,onChange:n,onClose:r}){const o=gf(e);if(o.length===0||!t)return null;const i=(e==null?void 0:e.config.profiles)??{},l=(e==null?void 0:e.configFile)??"the settings",u=c=>{var g;const h=((g=i[c])==null?void 0:g.run)??[],p=h.length>0?`runs ${h.join(", ")}`:"runs nothing";return c===(e==null?void 0:e.config.defaultProfile)?`${p}; the default in ${l}`:p};return f.jsx(Js,{value:t,options:o.map(c=>({id:c,description:u(c)})),onChange:n,onClose:r,hint:o.length>1?`${t}: ${u(t)}. Click to change`:`the only profile in ${l}`,placeholder:"the profile the worktree runs"})}function dc(e,t,n){if(!t)return e;const r=new Set(t.map(l=>l-n)),o=[];let i="";for(let l=0;l<e.length;l++)r.has(l)?(i&&o.push(i),i="",o.push(f.jsx("b",{className:"hit",children:e[l]},l))):i+=e[l];return i&&o.push(i),o}function uF({c:e,query:t}){const n=t.trim();return f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"picker-name",children:["/",dc(e.name,n?dk(e.name,n):null,0)]}),f.jsx("span",{className:"picker-desc row-dim",children:e.description})]})}function Un({label:e,hint:t,current:n=!1}){return f.jsxs(f.Fragment,{children:[n&&f.jsx("span",{className:"row-current","aria-hidden":"true"}),f.jsx("span",{className:"picker-label",children:e}),t?f.jsx("span",{className:"picker-hint row-dim",children:t}):null]})}function dF(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 fF=/ \| | - | \u2013 | \u2014 | \u00b7 |: /,hF=/^(\d+|[0-9a-f]{8}-[0-9a-f-]{27}|[0-9a-f]{12,})$/i,pF=/^[[:$*{]|\[/;function mF(e){const t=new Map,n=e.filter(i=>!!i.title);if(new Set(n.map(i=>i.path)).size<2)return t;const r=n.map(i=>({path:i.path,parts:i.title.split(fF).map(l=>l.trim()).filter(Boolean)})),o=new Map;for(const{path:i,parts:l}of r)for(const u of l)o.set(u,(o.get(u)??new Set).add(i));for(const{path:i,parts:l}of r){const u=l.filter(c=>{var h;return(((h=o.get(c))==null?void 0:h.size)??0)<2});u.length>0&&t.set(i,u.join(" "))}return t}function pk(e){const t=e.split(/[/#]/).filter(Boolean);for(let n=t.length-1;n>=0;n--){let r=t[n];try{r=decodeURIComponent(r)}catch{}if(hF.test(r)||pF.test(r))continue;const o=r.replace(/[-_.]+/g," ").trim();if(o)return o[0].toUpperCase()+o.slice(1)}return"Home"}const Ip=8,gF=3,kF=50,yF=3;function wF(e,t,n=[]){const r=new Map,o=[],i=new Map;for(const l of(t==null?void 0:t.routes)??[]){if(l.endpoint)continue;const u=l.dynamic?zO(l.path):null;u?(o.push(u),i.set(l.path,l)):r.set(l.path,l)}return{history:e,statics:r,templates:o,templateRoutes:i,unseen:(t==null?void 0:t.unseen)??{},titles:mF(e),links:new Map(n.map(l=>[l.path,l.text]))}}function RS(e){if(!e)return"/";try{const t=new URL(e);return t.pathname+t.search+t.hash}catch{return"/"}}function vF(e){const t=e.trim();return/^[/?#]/.test(t)?t:`/${t}`}function bF(e,t){const n=/^[/?#]/.test(t)?e:e.replace(/^\//,"");return t&&n.toLowerCase().startsWith(t.toLowerCase())?n:null}const $S=e=>/^\[\[?\.\.\.|^\*$|^\$$/.test(e),Ul=e=>$S(e)||/[[:$*{]/.test(e)&&!/^[^[{:$*]+\?$/.test(e),xF=e=>Qd(`/${e}`).text.slice(1),mk=e=>e.split("/").filter(Boolean);function gk(e,t){const n=t.startsWith("/"),r=t.replace(/^\//,"").split("/"),o=mk(e);let i="";const l=[],u=g=>{const m=xF(g);l.push([i.length,i.length+m.length]),i+=m};for(let g=0;g<r.length;g++){const m=r[g],y=o[g];if(y===void 0)return null;if(g<r.length-1){if($S(y))return{show:t,accept:t};if(Ul(y)){if(!m)return null}else if(m.toLowerCase()!==y.toLowerCase())return null;i+=`${Ul(y)?m:y}/`;continue}if(Ul(y))m?i+=m:u(y);else{if(!y.toLowerCase().startsWith(m.toLowerCase()))return null;i+=y}}for(const g of o.slice(r.length))i+="/",Ul(g)?u(g):i+=g;const c=n?1:0,h=(n?"/":"")+i,p=l[0];return{show:h,accept:p?h.slice(0,p[0]+c):h,params:l.map(([g,m])=>[g+c,m+c])}}function EF(e,t){const n=gk(e,t);return n?n.accept.length>t.length?n.accept:t:Qd(e).literal}function OS(e,t){if(e.kind==="go")return null;if(e.template){const n=gk(e.path,t);return n&&n.show.length>t.length?n:null}return bF(e.path,t)}const _F=e=>e.trim().replace(/^\//,"").toLowerCase();function MS(e,t){for(let n=0;n<e.length;n++)if("/-_.#".includes(e[n])&&e.startsWith(t,n+1))return!0;return!1}function SF(e,t,n){const r=e.replace(/^\//,"").toLowerCase(),o=t.toLowerCase();return r===n?100:r.startsWith(n)?80:MS(r,n)?60:o.startsWith(n)?50:o.split(/\s+/).some(i=>i.startsWith(n))?45:r.includes(n)||o.includes(n)?20:0}function NF(e,t){const{text:n,literal:r}=Qd(e);return r.replace(/^\//,"").toLowerCase().startsWith(t)?80:gk(e,t)?70:MS(n.replace(/^\//,"").toLowerCase(),t)?60:0}function TF(e,t){const n=mk(e).findIndex(Ul);return n>=0&&t.split("/").length>n}function Yl(e,t,n){var u;const r=e.statics.get(t),o=r?null:FO(e.templates,t),i=(r==null?void 0:r.file)??(o?(u=e.templateRoutes.get(o.path))==null?void 0:u.file:void 0),l=i?e.unseen[i]:void 0;return{kind:"page",path:t,title:e.titles.get(t)||e.links.get(t)||pk(t),template:!1,visited:n<Number.POSITIVE_INFINITY,...i?{file:i}:{},...l?{badge:l}:{},rank:n,group:(o==null?void 0:o.path)??t,score:0}}function LS(e,t){const n=e.unseen[t.file];return{kind:"page",path:t.path,title:pk(t.path),template:!0,visited:!1,file:t.file,...n?{badge:n}:{},rank:Number.POSITIVE_INFINITY,group:t.path,score:0}}function sd({rank:e,group:t,score:n,...r}){return r}const $d=e=>mk(e).length,Od=e=>e.badge==="new"?0:e.badge==="changed"?1:2;function jF(e,t){const n=new Set,r=[];e.history.forEach((p,g)=>{if(p.path===t)return;const m=Yl(e,p.path,g);n.has(m.group)||(n.add(m.group),r.push(m))});const o=new Set(r.map(p=>p.path)),i=r.filter(p=>p.badge);for(const[p,g]of e.statics)e.unseen[g.file]&&p!==t&&!o.has(p)&&i.push(Yl(e,p,Number.POSITIVE_INFINITY));for(const p of e.templateRoutes.values())e.unseen[p.file]&&!n.has(p.path)&&i.push(LS(e,p));i.sort((p,g)=>Od(p)-Od(g)||p.rank-g.rank);const l=r.filter(p=>!p.badge),u=i.slice(0,Ip-Math.min(gF,l.length));for(const p of l)u.length<Ip&&u.push(p);const c=new Set(u.map(p=>p.path)),h=[...e.statics.keys(),...[...e.links.keys()].filter(p=>!e.statics.has(p))].filter(p=>p!==t&&!c.has(p)&&!o.has(p)).sort((p,g)=>$d(p)-$d(g)||(p<g?-1:p>g?1:0));for(const p of h){if(u.length>=Ip)break;u.push(Yl(e,p,Number.POSITIVE_INFINITY))}return u.map(sd)}function CF(e,t,n){var g;const r=_F(t),o=vF(t),i=new Map;e.history.forEach((m,y)=>{m.path!==n&&i.set(m.path,Yl(e,m.path,y))});for(const m of[...e.statics.keys(),...e.links.keys()])m!==n&&!i.has(m)&&i.set(m,Yl(e,m,Number.POSITIVE_INFINITY));const l=[];for(const m of i.values()){const y=SF(m.path,m.title,r);y>0&&l.push({...m,score:y})}let u=null;for(const m of e.templates){const y=e.templateRoutes.get(m.path);if(!u&&!e.statics.has(o)&&m.re.test(o)){u=y;continue}const w=NF(m.path,r);w>=60&&l.push({...LS(e,y),score:w})}l.sort((m,y)=>y.score-m.score||m.rank-y.rank||Od(m)-Od(y)||$d(m.path)-$d(y.path)||(m.path<y.path?-1:m.path>y.path?1:0));const c=new Map,h=[];for(const m of l){if(!m.template&&m.group!==m.path){const y=c.get(m.group)??0;if(y>=yF&&!TF(m.group,r))continue;c.set(m.group,y+1)}if(h.push(m),h.length>=kF)break}if(h.some(m=>m.score===100))return h.map(sd);const p={kind:"go",path:o,title:pk((u==null?void 0:u.path)??o)};return u||(((g=h[0])==null?void 0:g.score)??0)<80?[p,...h.map(sd)]:[...h.map(sd),p]}function PS(e,{query:t,current:n,here:r}){return t===n||t.trim()===""?jF(e,r):CF(e,t,r)}const AF=[],IF=[];function DS(e,t){const n=M(i=>(t?i.visits[t]:void 0)??AF),r=At(e,"pages"),o=At(e,"links");return yt([e],()=>{_1(r)&&Jt.post(e,{type:"links"})}),S.useMemo(()=>wF(n,r,o),[n,r,o])}function RF({row:e}){if(e.kind!=="page"||!e.template)return f.jsx("span",{className:"bar-route-path row-dim",children:e.path});const{text:t,params:n}=Qd(e.path),r=[];let o=0;for(const[i,l]of n)i>o&&r.push(t.slice(o,i)),r.push(f.jsx("span",{className:"bar-route-param",children:t.slice(i,l)},i)),o=l;return o<t.length&&r.push(t.slice(o)),f.jsx("span",{className:"bar-route-path row-dim",children:r})}function zS({row:e}){return f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"picker-label",children:e.title}),f.jsx(RF,{row:e}),e.kind==="go"?f.jsx("span",{className:"picker-hint row-dim",children:"go"}):e.badge?f.jsx("span",{className:e.badge==="new"?"badge-new":"badge-changed",children:e.badge}):null]})}const FS=e=>e.kind==="page"&&e.file?e.file:e.path,BS=(e,t)=>e.kind==="page"&&e.template?EF(e.path,t):null,US=e=>e.kind==="page"&&e.template?"fills in the parameter":"goes there";function HS(e,t,n){return e.kind!=="page"?[]:lf([...e.file&&t.dir?vs({id:t.worktreeId,dir:t.dir},e.file,{},n):[],tE,...e.visited?dF(t.repoId,e.path,n):[]])}function $F({worktreeId:e,repoId:t,url:n}){const r=at(),o=st(),i=M(m=>{const y=rn(m,e);return y?y.worktree.path:null}),l=DS(e,t),u=RS(n),c=n?Yd(n):null,h=S.useCallback((m,y)=>PS(l,{query:y,current:u,here:c}),[l,u,c]),p=S.useCallback(m=>m===u||m.trim()==="",[u]),g=()=>r({a:"close"});return f.jsx(Ir,{anchored:{matchWidth:0},items:IF,filter:h,initialQuery:u,selectOnMount:!0,idleWhen:p,onIdlePick:()=>{Jt.post(e,{type:"reload"}),g()},keyOf:m=>`${m.kind}:${m.path}`,rowClass:()=>"picker-row",rowTitle:FS,completionOf:(m,y)=>p(y)?null:OS(m,y),narrowTo:BS,onPick:m=>{Jt.post(e,{type:"navigate",path:m.path}),g()},onBack:g,rowMenu:m=>HS(m,{worktreeId:e,repoId:t,dir:i},{sock:o,dispatch:r}),placeholder:"type a path",keys:m=>({complete:"completes the path",pick:m?US(m):"reloads",back:"closes"}),empty:"no pages yet; type a path",row:m=>f.jsx(zS,{row:m})})}function WS(e,t){const n=t.trim();return f.jsx(Un,{label:dc(e.label,n?dk(e.label,n):null,0),hint:e.hint&&f.jsx(zo,{k:e.hint})})}function KS({anchored:e,trailing:t}){const n=at(),r=dS(),o=M(i=>{var l;return((l=i.paletteReturn)==null?void 0:l.mode)==="commands"?i.paletteReturn.q:""});return f.jsx(Ir,{anchored:e,trailing:t,items:r,filter:fS,rowClass:()=>"picker-row",keyOf:i=>i.id,onPick:(i,l)=>{i.sub?n({a:"palette-return",v:{mode:"commands",q:l}}):n({a:"close"}),i.run()},onBack:()=>n({a:"close"}),placeholder:"run a command…",keys:{pick:"runs",back:"closes"},initialQuery:o,empty:"no matching command",row:(i,l,u)=>WS(i,u)})}function ZS(e,t){const n=new Map(t.map(l=>[l.path,l])),r=t.filter(l=>l.xy==="??"&&l.path.endsWith("/")).map(l=>l.path),o=e.map(l=>{const u=n.get(l)??(r.some(c=>l.startsWith(c))?{path:l,xy:"??"}:void 0);return u?{path:l,status:u}:{path:l}}),i=new Set(e);for(const l of t)!i.has(l.path)&&!l.path.endsWith("/")&&o.push({path:l.path,status:l});return o}function Ab(e,t){const n=e.split("/"),r=t.split("/");for(let o=0;;o++){const i=n[o],l=r[o];if(i===void 0||l===void 0)return n.length-r.length;const u=o===n.length-1,c=o===r.length-1;if(u!==c)return u?-1:1;if(i!==l)return i<l?-1:1}}function qS(e,t,n,r=50){const o=ZS(e,t),i=n.trim().toLowerCase();if(!i){const u=new Map(t.map((g,m)=>[g.path,m])),c=g=>{var m;return u.get(((m=g.status)==null?void 0:m.path)??"")??u.get(g.path)??Number.MAX_SAFE_INTEGER},h=o.filter(g=>g.status).sort((g,m)=>c(g)-c(m)||Ab(g.path,m.path)),p=o.filter(g=>!g.status).sort((g,m)=>Ab(g.path,m.path));return{rows:[...h,...p].slice(0,r),changed:Math.min(h.length,r)}}const l=VS(o,i);return l.sort((u,c)=>c.score-u.score||u.row.path.localeCompare(c.row.path)),{rows:l.slice(0,r).map(u=>u.row),changed:0}}function GS(e,t){const n=e.toLowerCase(),r=Ib(n,t);return r<=0?0:Ib(n.slice(n.lastIndexOf("/")+1),t)>0?r+10:r}function VS(e,t){const n=[];for(const r of e){const o=GS(r.path,t);o>0&&n.push({row:r,score:r.status?o+4:o})}return n}function OF(e,t,n,r,o){const i=r.trim().toLowerCase();if(!i)return qS(e,n,r,o).rows.map(c=>({kind:"file",path:c.path,status:c.status}));const l=VS(ZS(e,n),i).map(({row:c,score:h})=>({row:{kind:"file",path:c.path,status:c.status},score:h}));for(const c of t){const h=GS(c,i);h>0&&l.push({row:{kind:"folder",path:c},score:h})}const u=c=>c.kind==="folder"?1:0;return l.sort((c,h)=>h.score-c.score||u(c.row)-u(h.row)||c.row.path.localeCompare(h.row.path)),l.slice(0,o).map(c=>c.row)}function MF(e,t){const n=e.toLowerCase(),r=[];let o=0;for(const i of t.toLowerCase()){const l=n.indexOf(i,o);if(l===-1)return null;r.push(l),o=l+1}return r}function Ib(e,t){let n=0,r=0,o=0;for(const i of t){const l=e.indexOf(i,r);if(l===-1)return 0;o=l===r?o+1:1,n+=o+(l===0||e[l-1]==="/"||e[l-1]==="."?3:0),r=l+1}return n+Math.max(0,40-e.length/4)}function LF(e){const t=e.lastIndexOf("/");return t===-1?[e,""]:[e.slice(t+1),e.slice(0,t+1)]}const Rb=[],PF=[],DF=[];function zF({worktreeId:e}){var b;const t=at(),n=st(),r=Kn();yt([e,n],()=>uf(e,r.getState(),{sock:n,dispatch:t}));const o=Y1(e),i=o.files??PF,l=((b=o.git)==null?void 0:b.files)??DF,u=dS(),c=M(E=>{var N;return((N=E.paletteReturn)==null?void 0:N.mode)==="quick-open"?E.paletteReturn.q:""}),h=M(E=>{var j;const N=(j=rn(E,e))==null?void 0:j.worktree;return N?N.path:null}),p=M(E=>{var N;return((N=rn(E,e))==null?void 0:N.repoId)??null}),g=M(E=>{var N;return((N=xd(E))==null?void 0:N.worktreeId)===e}),m=DS(e,p),y=o.page.url?Yd(o.page.url):null,w=S.useCallback((E,N)=>N.startsWith(">")?fS(u,N.slice(1)).map(j=>({kind:"cmd",c:j})):N.startsWith("/")?g?PS(m,{query:N,current:"/",here:y}).map(j=>({kind:"page",page:j})):Rb:qS(i,l,N).rows.map(j=>({kind:"file",path:j.path,status:j.status})),[u,i,l,g,m,y]);return f.jsx(Ir,{items:Rb,filter:w,keyOf:E=>E.kind==="cmd"?`c:${E.c.id}`:E.kind==="page"?`p:${E.page.kind}:${E.page.path}`:`f:${E.path}`,rowClass:E=>E.kind==="file"?"qo-file":"picker-row",rowTitle:E=>E.kind==="page"?FS(E.page):void 0,completionOf:(E,N)=>E.kind==="page"?OS(E.page,N):null,narrowTo:(E,N)=>E.kind==="page"?BS(E.page,N):null,onPick:(E,N)=>{E.kind==="cmd"?(E.c.sub?t({a:"palette-return",v:{mode:"quick-open",q:N}}):t({a:"close"}),E.c.run()):E.kind==="page"?(Jt.post(e,{type:"navigate",path:E.page.path}),t({a:"close"})):(nr({dispatch:t},{worktreeId:e,path:E.path,view:Fi(E.path)}),t({a:"close"}))},onBack:()=>t({a:"close"}),rowMenu:E=>E.kind==="file"&&h?vs({id:e,dir:h},E.path,{},{sock:n,dispatch:t}):E.kind==="page"&&p?HS(E.page,{worktreeId:e,repoId:p,dir:h},{sock:n,dispatch:t}):[],placeholder:"jump to file · type > for commands, / for pages",keys:(E,N)=>N.startsWith("/")?{complete:"completes the path",pick:(E==null?void 0:E.kind)==="page"?US(E.page):void 0,back:"closes"}:{pick:"opens",back:"closes"},initialQuery:c,empty:E=>E.startsWith(">")?"no matching command":E.startsWith("/")?g?"no pages yet; type a path":"no preview running":"no matches",row:(E,N,j)=>E.kind==="cmd"?WS(E.c,j.slice(1)):E.kind==="page"?f.jsx(zS,{row:E.page}):Am(E.path,E.status,j,{gutter:l.length>0})})}function Am(e,t,n,{folder:r=!1,gutter:o=!0}={}){const[i,l]=LF(e),u=n.trim()?MF(e,n.trim()):null;return f.jsxs(f.Fragment,{children:[o&&f.jsx("span",{className:`xy ${t?dg(t.xy):""}`,children:t?fg(t.xy):""}),f.jsxs("span",{className:"name",children:[dc(i,u,l.length),r&&"/"]}),f.jsx("span",{className:"dir row-dim",children:l&&f.jsxs(f.Fragment,{children:["",dc(l,u,0),""]})}),t&&f.jsx(GE,{f:t})]})}function Rp({icon:e,verb:t,tip:n,onPress:r,onDismiss:o,children:i}){return f.jsxs("div",{className:"composer-offer",children:[f.jsx(St,{name:e,className:"icon-inline"}),f.jsxs("span",{className:"composer-offer-line",children:[f.jsx(Pe,{variant:"inline",tone:"strong","data-tip":n,onClick:r,children:t})," ",i]}),o&&f.jsx(Lt,{icon:"close",tone:"quiet",className:"composer-offer-close",label:"Not this one",onClick:o})]})}function Md({rows:e,cursor:t,onCursor:n,onPick:r,hover:o=!1}){const i=Wi(),l=u=>{var c;u.target instanceof HTMLTextAreaElement||(u.preventDefault(),(c=u.currentTarget.querySelector("textarea"))==null||c.focus())};return f.jsx("div",{className:Be("choices",o&&"choices-hover",i&&"choices-touch"),children:e.map((u,c)=>{const h=!i&&t===c,p=pr({cursor:h,checked:u.checked}),g=u.tone==="deny"&&"choice-deny",m=()=>n&&t!==c&&n(c),y=f.jsxs(f.Fragment,{children:[!i&&f.jsx(zo,{k:String(c+1),className:"choice-num row-dim"}),f.jsx("span",{className:"choice-label",children:u.label}),!i&&u.hint&&f.jsxs("span",{className:Be("choice-hint row-dim",h&&u.hint.on!==!1&&"on"),children:[f.jsx(zo,{k:u.hint.k})," ",u.hint.label]}),u.description&&f.jsx("span",{className:"choice-desc",children:u.description})]});return u.field?f.jsxs("div",{className:Be("picker-item choice row-edge",g),"data-state":p,onMouseMove:m,onMouseDown:l,children:[y,f.jsx(Ua,{ref:u.field.ref,bare:!0,font:"ui",rows:1,className:"choice-field",enterKeyHint:u.field.enterKeyHint,placeholder:u.field.placeholder,value:u.field.value,onChange:w=>{var b;return(b=u.field)==null?void 0:b.onChange(w.target.value)}})]},c):f.jsx("button",{type:"button",className:Be("picker-item choice row-edge",g),"data-state":p,disabled:u.disabled,onMouseMove:m,onClick:()=>r(c),children:y},c)})})}function FF(e){return id(e.key)&&(e.metaKey||e.ctrlKey)&&!e.altKey?!1:e.metaKey||e.ctrlKey||e.altKey}const BF=e=>e.length===1&&e>="1"&&e<="9",id=e=>e==="Enter"||e==="NumpadEnter";function UF(e,t,n){const r=id(e.key)&&(e.metaKey||e.ctrlKey);return t?e.key==="Escape"||e.key==="Tab"&&!e.shiftKey?{kind:"field-leave"}:r?{kind:"submit"}:id(e.key)&&!e.shiftKey?{kind:"field-enter"}:{kind:"typing"}:FF(e)?{kind:"chord"}:e.key==="Escape"?{kind:"escape"}:r?{kind:"submit"}:id(e.key)||e.key===" "&&n.spacePicks?n.cursor===void 0?{kind:"submit"}:{kind:"pick",at:n.cursor,by:"enter"}:e.key==="ArrowUp"||e.key==="ArrowDown"?n.cursor===void 0?null:{kind:"cursor",to:Ec(n.cursor,e.key==="ArrowUp"?-1:1,n.count)}:BF(e.key)&&Number(e.key)<=n.count?{kind:"pick",at:Number(e.key)-1,by:"digit"}:null}function kk(e,t){var o,i,l,u;const n=e.target instanceof HTMLTextAreaElement,r=UF(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?(i=t.onFieldEnter)==null||i.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(),(l=t.onCursor)==null||l.call(t,r.to),!0;case"field-enter":return e.preventDefault(),(u=t.onFieldEnter)==null||u.call(t),!0}}function HF(e){return!e||e===document.body?!1:e.closest(".monaco-editor, .xterm")?!0:(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&!e.closest(".chat-input")}function WF(e,t){yt([t],()=>{const o=requestAnimationFrame(()=>{var i;HF(document.activeElement)||(i=e.current)==null||i.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},i=()=>{n.current=!1,r()};return window.addEventListener("pointerdown",o,!0),window.addEventListener("pointerup",i,!0),window.addEventListener("pointercancel",i,!0),()=>{window.removeEventListener("pointerdown",o,!0),window.removeEventListener("pointerup",i,!0),window.removeEventListener("pointercancel",i,!0)}},[r]),o=>{!o.relatedTarget&&!n.current&&r()}}function yk({root:e,id:t,onKeyDown:n,children:r}){const o=WF(e,t);return f.jsx("div",{ref:e,className:"card",tabIndex:-1,onKeyDown:n,onBlur:o,children:r})}function Ld({children:e,sub:t}){return f.jsxs("div",{className:"card-head",children:[f.jsx("div",{className:"card-text",children:e}),t&&f.jsx("div",{className:"card-sub",children:t})]})}function Pd(e){const t=S.useRef(null),n=hk(t);return"html"in e?f.jsxs("div",{ref:t,className:"card-band md",children:[f.jsx("div",{dangerouslySetInnerHTML:{__html:e.html}}),n]}):f.jsxs("div",{ref:e.still?void 0:t,className:Be("card-band card-code",e.still&&"card-still"),children:[f.jsx("pre",{children:e.code}),!e.still&&n]})}function KF({children:e}){return f.jsx("div",{className:"card-foot",children:e})}const ZF=[{selected:[]}],$p=0,qF=2;function GF({item:e,worktreeId:t,rootRef:n}){var R;const r=st(),o=at(),i=At(t,"card"),l=(i==null?void 0:i.id)===e.id?i.draft:ZF,u=(R=l[0])==null?void 0:R.note,c=u!==void 0,h=I=>o({a:"card-draft",id:t,card:{id:e.id,draft:I,current:0}}),p=S.useRef(null),[g,m]=S.useState($p),[y,w]=S.useState(!1),b=S.useMemo(()=>Oa(e.message),[e.message]),E=I=>{y||!r||(r.send(B6(e,t,I,u)),I&&w(!0),o({a:"answered",id:t}))},N=()=>{c||h(yd(l,0,"")),m($p),requestAnimationFrame(()=>{var I;return(I=p.current)==null?void 0:I.focus()})},j=I=>E(I===$p),T=()=>o({a:"card-park",id:t,cardId:e.id}),O=()=>{var _;const I=Jp(l,0);I!==l&&h(I),(_=n.current)==null||_.focus()},U=I=>{kk(I,{count:qF,cursor:g,onCursor:m,onPick:j,onEscape:T,onFieldEnter:()=>E(!0),onFieldLeave:O})||I.key==="n"&&(I.preventDefault(),N())},Q=[{label:"go",hint:{k:"n",label:"add context",on:!c},checked:c,field:c?{ref:p,value:u??"",placeholder:"a note for the agent there, sent with go",enterKeyHint:"send",onChange:I=>h(yd(l,0,I))}:void 0,description:y?"starting":void 0,disabled:y},{label:"not now",tone:"deny",disabled:y}];return f.jsxs(yk,{root:n,id:e.id,onKeyDown:U,children:[f.jsxs(Ld,{sub:f.jsxs(f.Fragment,{children:["Starts a worktree in ",e.repo.path,", in ",e.mode," mode",e.mode==="auto"?", which runs without asking":"",". Nothing has started yet."," ",e.by==="agent"?"Proposed by this worktree's agent.":"You asked for this."]}),children:["Continue in ",e.repo.name,"?"]}),f.jsx(Pd,{html:b}),f.jsx(Md,{rows:Q,cursor:g,onCursor:m,onPick:j})]})}function VF(e,t){if(t.queued>0||t.sending||t.card)return null;const n=e.at(-1);if((n==null?void 0: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=vf(n);return r===null?null:{verb:"fix",toolId:n.id,command:r}}let Im=new Set;const Rm=new Set;function YF(e){return Rm.add(e),()=>{Rm.delete(e)}}function QF(e){Im=new Set(Im).add(e);for(const t of Rm)t()}function XF(){return S.useSyncExternalStore(YF,()=>Im)}const JF=e=>mc.some(t=>t.id===e);function e8(e){return[...mc.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:"continue this work in another project; Toyon starts a worktree there with your message",hint:"<project> [<message>]"}]}function t8(e,t){const n=new Set(e.map(r=>r.name));return[...e,...t.filter(r=>!n.has(r.name))]}function n8(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 r8({item:e,ask:t,worktreeId:n,rootRef:r}){const o=st(),i=at(),l=M(w=>w.activeId),[u,c]=S.useState(0),h=t.plan,p=S.useMemo(()=>t.detail&&!h?Oa(t.detail):"",[t.detail,h]),g=()=>{h&&l===n&&nr({dispatch:i},{worktreeId:n,path:h,view:"preview",focus:!1})};yt([e.id,h],g);const m=w=>{const b=t.choices[w];b&&(o==null||o.send({t:"agent-decide",worktreeId:n,askId:e.id,choiceId:b.id}),i({a:"answered",id:n}))},y=w=>{kk(w,{count:t.choices.length,cursor:u,onCursor:c,onPick:m,onEscape:()=>i({a:"card-park",id:n,cardId:e.id})})};return f.jsxs(yk,{root:r,id:e.id,onKeyDown:y,children:[f.jsx(Ld,{children:t.title}),t.command&&f.jsx(Pd,{code:J_(t.command)}),p&&f.jsx(Pd,{html:p}),f.jsx(Md,{rows:t.choices.map(w=>({label:w.name,tone:w.kind.startsWith("reject")?"deny":void 0})),cursor:u,onCursor:c,onPick:m})]})}function o8({item:e,ask:t,worktreeId:n,rootRef:r,onAnswer:o}){const i=st(),l=at(),{message:u,questions:c}=t,h=At(n,"card"),p=S.useMemo(()=>(h==null?void 0:h.id)===e.id?h:{id:e.id,draft:U2(c),current:0},[h,e.id,c]),{draft:g,current:m}=p,y=m===Zl(c),w=c[m],b=g[m],E=!!(w!=null&&w.multi),[N,j]=S.useState(()=>Ea(w,b)),T=S.useRef(null);S.useEffect(()=>{const A=window.visualViewport;if(!A)return;const q=()=>{T.current&&T.current===document.activeElement&&T.current.scrollIntoView({block:"nearest"})};return A.addEventListener("resize",q),()=>A.removeEventListener("resize",q)},[]);const O=(A,q)=>l({a:"card-draft",id:n,card:{id:e.id,draft:A,current:q}}),U=A=>{if(o){A&&o(A);return}i==null||i.send({t:"agent-answer",worktreeId:n,askId:e.id,...A?{answers:A}:{}}),l({a:"answered",id:n})},Q=()=>l(o?{a:"ask-revive",id:n}:{a:"card-park",id:n,cardId:e.id}),R=()=>{Fu(c,g)&&U(g)},I=A=>{j(Ea(c[A],g[A])),O(g,A)},_=A=>{w!=null&&w.note&&(O(Mv(g,m,A,E),m),requestAnimationFrame(()=>{var q;return(q=T.current)==null?void 0:q.focus()}))},L=()=>{if(!(w!=null&&w.note))return;const A=w.options[N];if(!A||E)return _(!A);O(Mv(Ov(g,m,A.value,!1),m,!1,!1),m),requestAnimationFrame(()=>{var q;return(q=T.current)==null?void 0:q.focus()})},z=A=>{if(W2(w,A))return j(A),_(!0);const q=w==null?void 0:w.options[A];if(!w||!q)return;const ie=Ov(g,m,q.value,E);if(E){j(A),O(ie,m);return}const P=Lv(c,ie,m);j(P.cursor),O(ie,P.current),P.send&&Fu(c,ie)&&U(ie)},F=()=>{var q;const A=Jp(g,m);A!==g&&(O(A,m),j(Ea(w,A[m]))),(q=r.current)==null||q.focus()},ee=()=>{var ie;const A=Jp(g,m);if((ie=r.current)==null||ie.focus(),!ja(A[m])){A!==g&&(O(A,m),j(Ea(w,A[m])));return}const q=Lv(c,A,m);j(q.cursor),O(A,q.current),q.send&&Fu(c,A)&&U(A)},se=A=>{if(!kk(A,{count:y?c.length:H2(w),cursor:y?void 0:N,spacePicks:E,onCursor:j,onPick:q=>y?I(q):z(q),onSubmit:R,onEscape:Q,onFieldEnter:ee,onFieldLeave:F})){if(A.key==="ArrowLeft"||A.key==="ArrowRight"||A.key==="Tab"){A.preventDefault();const q=A.key==="ArrowLeft"||A.key==="Tab"&&A.shiftKey;return I(G2(m,q?-1:1,Y2(c)))}if(A.key==="n"&&(w!=null&&w.note))return A.preventDefault(),L();if(A.key==="s"&&!o)return A.preventDefault(),U()}},fe=A=>c.length===1&&!A.multi,ke=(A,q)=>f.jsxs(KF,{children:[(!A||!fe(A))&&f.jsx(Pe,{variant:"outline",size:"md",disabled:!Fu(c,g),onClick:R,children:"send"}),(A==null?void 0:A.note)&&q&&q.selected.length>0&&q.note===void 0&&f.jsxs(Pe,{tone:"quiet",size:"md",onClick:()=>_(!1),children:[f.jsx(zo,{k:"n",chip:!0}),"add a note"]}),!o&&f.jsxs(Pe,{tone:"quiet",size:"md",onClick:()=>U(),children:[f.jsx(zo,{k:"s",chip:!0}),"skip"]})]}),ne=(A,q)=>{const ie=q===m,P=g[q],W=g1(P,!!A.multi),xe=ie?A.options[N]:void 0,ce=_e=>({ref:ie?T:void 0,value:(P==null?void 0:P.note)??"",placeholder:_e,enterKeyHint:Zl(c)===-1?"send":"next",onChange:ae=>O(yd(g,q,ae),q)}),me=A.options.map(_e=>{const ae=!!(P!=null&&P.selected.includes(_e.value));return{label:f.jsxs(f.Fragment,{children:[lg(_e.label),Q2(_e.label)&&f.jsx("span",{className:"badge-recommended",children:"recommended"})]}),description:_e.description,hint:A.note&&!A.multi?{k:"n",label:"add a note",on:(P==null?void 0:P.note)===void 0}:void 0,checked:ae,field:ae&&!W&&(P==null?void 0:P.note)!==void 0?ce("a note for the agent, sent with your pick"):void 0}});return A.note&&me.push({label:A.note.label,description:W?void 0:"your own answer",checked:W,field:W?ce("your own answer"):void 0}),f.jsxs("div",{className:Be("card-page",!ie&&"card-page-off"),children:[f.jsx(Ld,{children:A.text||u}),f.jsx(Md,{rows:me,cursor:ie?N:void 0,onCursor:j,onPick:_e=>{var ae;z(_e),(ae=r.current)==null||ae.focus()}}),(xe==null?void 0:xe.preview)&&f.jsx(Pd,{code:xe.preview,still:!0}),ke(A,P)]},A.id)};return f.jsxs(yk,{root:r,id:e.id,onKeyDown:se,children:[c.length>1&&f.jsx("div",{className:"card-tabs",children:f.jsx(pf,{label:"questions",owner:"ask",items:[...c.map((A,q)=>({id:String(q),label:A.header||`question ${q+1}`,lead:f.jsx("span",{className:Be("dot card-step",ja(g[q])&&"answered")})})),{id:String(c.length),label:"send",far:!0}],current:String(m),onPick:A=>{var q;I(Number(A)),(q=r.current)==null||q.focus()}})}),f.jsxs("div",{className:"card-pages",children:[c.map(ne),Zl(c)!==-1&&f.jsxs("div",{className:Be("card-page",!y&&"card-page-off"),children:[f.jsx(Ld,{children:"Send these answers?"}),f.jsx(Md,{hover:!0,rows:c.map((A,q)=>{const ie=ja(g[q])?Z2(A,g[q]):void 0;return{label:f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"row-dim",children:A.header||`question ${q+1}`})," ",f.jsx("span",{className:Be(!ie&&"row-dim"),children:ie?ie.pick:"no answer yet"})]}),description:ie==null?void 0:ie.note}}),onPick:A=>{var q;I(A),(q=r.current)==null||q.focus()}}),ke()]})]})]})}const s8={side:"top",align:"start",offset:6,flip:"both",margin:8},i8=5*6e4;function a8({usage:e,limits:t,now:n,compact:r,onClose:o}){const i=t?U4(t,n):[],l=t&&n-t.at>i8?pg(n-t.at):null,u=(e==null?void 0:e.cost)!==void 0?` · ${_c(e.cost)}`:"";return f.jsxs(Ns,{className:"usage-panel",anchor:"parent",placement:s8,onDismiss:o,onKey:c=>{c.key==="Escape"&&(c.stopPropagation(),o())},children:[e&&f.jsx($b,{name:"context",used:e.used/e.size,sub:`${O0(e.used)} of ${O0(e.size)}${u}`}),i.map(c=>f.jsx($b,{name:c.name,used:c.used,sub:c.sub},c.key)),l&&f.jsxs("div",{className:"usage-stale hint",children:["read ",l," ago"]}),r&&f.jsxs(f.Fragment,{children:[f.jsx("hr",{className:"usage-rule"}),f.jsxs("button",{type:"button",className:"row usage-compact",disabled:!!r.off,onClick:r.run,children:[f.jsx("span",{children:"compact the context"}),f.jsx("span",{className:"usage-detail hint",children:r.off??r.advice})]})]})]})}function $b({name:e,used:t,sub:n}){const r=Math.max(0,Math.min(1,t));return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"usage-row",children:[f.jsx("span",{className:"usage-name",children:e}),f.jsx("span",{className:"meter",children:f.jsx("span",{className:"meter-fill",style:{"--meter":r}})}),f.jsxs("span",{className:"usage-fig",children:[Math.round(100*t),"%"]})]}),f.jsx("div",{className:"usage-sub hint",children:n})]})}const Ob=[],l8=[],c8=new Set(["ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),u8=150,d8=e=>({kind:"cmd",c:e});function f8(e,t,n,r){return e==="command"?r?n===0?"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":"listing files…"}function h8(e){return e.kind==="cmd"?`/${e.c.name} `:e.kind==="folder"?`@${e.path}/ `:e.kind==="changes"?"@changes ":`@${e.path} `}const Op="still uploading what is attached; send again in a moment";function ad({active:e,draft:t,archived:n,found:r,greenfield:o,placement:i="dock"}){var Rc,ol,$c,Oc,Mc,Lc,Pc,Dc;const l=i==="screen",u=at(),c=st(),h=Lr(),{storage:p}=Mr(),g=Kn(),m=!!t,y=(e==null?void 0:e.worktree.id)??null,w=e==null?void 0:e.worktree.repoId,b=n?n.id:r?r.id:wc(e),E=!!n||!!r,N=n?n.restorable:!!r&&!r.locked,j=At(b,"draft"),T=At(b,"attachments"),O=At(b,"notice"),U=((Rc=e==null?void 0:e.worktree.owns)==null?void 0:Rc.join(", "))??"",Q=S.useRef({id:y,owns:U});yt([y,U],()=>{const K=Q.current;Q.current={id:y,owns:U},!(K.id!==y||K.owns===U||!U||!b||n)&&u({a:"notice",id:b,text:`Running its own ${U} here now: this branch changed it.`})});const R=At(b,"mark"),I=(R==null?void 0:R.by)==="walk"?R:void 0,_=At(y,"chat"),L=At(y,"queue"),z=S.useMemo(()=>y&&!m?bS(_):null,[y,m,_]),F=At(y,"cardParked"),ee=At(y,"sending"),se=S.useMemo(()=>y&&!m&&!ee?F2(_):null,[y,m,ee,_]),fe=At(y,"askRevived"),ke=!z&&se&&fe===se.id?se:null,ne=z&&F!==z.id?z:ke,A=z?F===z.id?z:null:se&&!ke?se:null,q=S.useRef(null),ie=Wi(),P=jg(),W=At(P,"page"),xe=bc(),{onPaste:ce,onPasteKey:me,onPasteKeyUp:_e}=xP(b,y),ae=bL(),be=XF(),ze=S.useMemo(()=>y&&!m?VF(_,{queued:L.length,sending:!!ee,card:!!(ne||A),dismissed:be}):null,[y,m,_,L.length,ee,ne,A,be]),re=K=>b&&u({a:"set-draft",id:b,text:K}),he=M(K=>K.clientId),pe=M(K=>K.repos),Te=M(K=>K.repos.find(Ge=>Ge.id===(e==null?void 0:e.worktree.repoId))??null),Ue=M(K=>K.defaultAgent),ct=M(K=>K.agentChosen),We=m||!!o,xn=!We&&!!e&&!e.worktree.agent,Ht=We||xn,It=(t==null?void 0:t.agent)??Ue,nt=M(K=>K.agents.find(Ge=>Ge.id===(Ht?It:e==null?void 0:e.worktree.agent))),Ve=!!(nt!=null&&nt.quick),mt=(nt==null?void 0:nt.models)??Ob,En=(nt==null?void 0:nt.efforts)??Ob,[Rt,V]=jS(It),[ge,ft]=TS(It),qe=M(K=>K.agents),un=(K,Ge)=>{if(K===It){V(Ge);return}CS(p,K,Ge),m?u({a:"draft-agent",id:K}):c==null||c.send({t:"set-default-agent",agent:K})},yn=At(y,"model"),Tn=At(y,"effort"),gt=At(y,"usage")??(e==null?void 0:e.usage),[jn]=IS(Te),ye=(t==null?void 0:t.profile)??jn,[Le,wn]=aF(Te),_n=(e==null?void 0:e.worktree.mode)??ld,Sn=M(K=>K.picking),sn=M(K=>K.layout.term),In=b1((e==null?void 0:e.procs)??[]),ot=on("composer"),Wt=At(y,"files"),Qt=S.useMemo(()=>E1(Wt??l8),[Wt]),B=At(y,"git"),ue=(B==null?void 0:B.files.length)??(e==null?void 0:e.dirty)??0,Ie=(B==null?void 0:B.unpushed)??(e==null?void 0:e.unpushed)??0,Je=M(K=>{var Ge;return y?(Ge=K.shipping[y])==null?void 0:Ge.op:void 0}),Ot=M(K=>{var Ge;return y?(Ge=K.shipping[y])==null?void 0:Ge.step:void 0}),$t=M(K=>Da(K,w)),Oe=M(K=>{var Ge;return $t?(Ge=K.shipping[$t.id])==null?void 0:Ge.op:void 0}),Me=$t&&Te&&We?DE(Te.defaultBranch,$t):null,Ye=M(K=>m?iM(K.rows,w,It,Ue):y),Pt=At(Ye,"commands"),X=Pt.some(K=>K.name==="compact"),$e=(e==null?void 0:e.agent)==="working"||(e==null?void 0:e.agent)==="waiting",kt=$e&&!!y&&!m,Nt=e==null?void 0:e.worktree.lastTurn,Dt=!j.trim()&&T.length===0,an=!m&&!o&&Dt&&!$e?Nt:void 0,Mt=!m&&!o&&e&&Ri(e.worktree)?e.worktree.landing:void 0,zt=!!(Mt!=null&&Mt.ready)&&!Mt.stale&&!Uu(Mt,ue,Ve,nt==null?void 0:nt.name),Vt=Dt&&(!$e||zt)?Mt:void 0,Qe=ue>0&&!!(Vt!=null&&Vt.subject),vn=ue||(((ol=B==null?void 0:B.committed)==null?void 0:ol.length)??0),pn=!m&&!o&&Dt&&!$e&&!!e,Rn=!!(e!=null&&e.worktree.landed)&&ue===0,dn=pn&&Rn,Bt=pn&&!dn?e.worktree.pr:void 0,cr=!Rn&&(($c=e==null?void 0:e.worktree.pr)==null?void 0:$c.state)==="open"?e.worktree.pr:void 0,Qr=!!cr&&(ue>0||Ie>0),ln=((Oc=e==null?void 0:e.worktree.pr)==null?void 0:Oc.state)==="closed",rs=Oi((Te==null?void 0:Te.config)??{}),Xr=S.useMemo(()=>e8(cd(Oi((Te==null?void 0:Te.config)??{}),Te==null?void 0:Te.defaultBranch)),[Te]),Zn=()=>y&&(c==null?void 0:c.send({t:"chat",worktreeId:y,text:"/compact"})),ur=We?"nothing to compact until the first reply":X?$e?"wait for the turn to end":void 0:"this agent offers no compact command",je=X&>?L4(gt.used/gt.size):void 0,Fe=nt==null?void 0:nt.limits,lt=We?void 0:gt,Et=(!!y||We)&&!!(lt||Fe),cn=Date.now(),[mn,Z]=S.useState(!1),[de,De]=S.useState(!1),ut=S.useRef(0),wt=()=>{window.clearTimeout(ut.current),Z(!1),De(!1)};yt([y],wt);const Xt=()=>[{id:"compact",label:"compact the context",detail:ur||!gt?void 0:M0(gt.used/gt.size),disabled:ur,onClick:Zn}],[Dn,zn]=S.useState(0),[So,Pr]=S.useState(null),[Bo,Jr]=S.useState(null),Dr=S.useRef(null),bt=b&&!E?bb(j,Dn):null,zr=bt!==null&&bt.from!==So&&!I,Kt=bt==null?void 0:bt.kind,dt=bt==null?void 0:bt.query,Uo=S.useMemo(()=>{if(dt===void 0)return[];if(Kt==="command")return d6(t8(Xr,Pt),dt).slice(0,8).map(d8);const K=[],Ge=(B==null?void 0:B.files.length)??0;return Ge>0&&"changes".startsWith(dt.toLowerCase())&&K.push({kind:"changes",n:Ge}),K.push(...OF(Wt??[],Qt,(B==null?void 0:B.files)??[],dt,8)),K},[Kt,dt,Wt,Qt,B,Pt,Xr]),fn=S.useRef(null),Gt=S.useRef(null),gr=()=>{var K;return(K=q.current??fn.current)==null?void 0:K.focus()},qn=gr;yt([o?e==null?void 0:e.worktree.id:null],()=>{if(!o)return;const K=requestAnimationFrame(()=>{var _t;const Ge=document.activeElement;(!Ge||Ge===document.body)&&((_t=fn.current)==null||_t.focus())});return()=>cancelAnimationFrame(K)});const Ee=M(K=>K.focusChat),$=S.useRef(Ee),D=!!Q1();yt([Ee],()=>{if(Ee===$.current||($.current=Ee,D!==!!o))return;const K=requestAnimationFrame(gr);return()=>cancelAnimationFrame(K)});const J=ne==null?void 0:ne.id,we=S.useRef({id:y,cardUpId:J});yt([y,J],()=>{const K=we.current;if(we.current={id:y,cardUpId:J},J||!K.cardUpId||K.id!==y||D!==!!o||ie&&!A)return;const Ge=requestAnimationFrame(()=>{var hn;const _t=document.activeElement;(!_t||_t===document.body)&&((hn=fn.current)==null||hn.focus())});return()=>cancelAnimationFrame(Ge)});const Ce=M(K=>K.walked),He=S.useRef(Ce);yt([Ce],()=>{if(Ce===He.current||(He.current=Ce,D!==!!o))return;const K=requestAnimationFrame(()=>{const Ge=document.activeElement;(!Ge||Ge===document.body||Ge.closest(".rail"))&&gr()});return()=>cancelAnimationFrame(K)});const vt=NE({results:Uo,keyOf:K=>K.kind==="cmd"?`c:${K.c.name}`:K.kind==="changes"?"changes":`f:${K.path}`,q:(bt==null?void 0:bt.query)??"",listRef:Dr,tabPicks:!0,onPick:K=>{if(!bt)return;const{text:Ge,caret:_t}=u6(j,bt,h8(K));re(Ge),Pr(bt.from),Jr(K.kind==="cmd"&&K.c.hint?{name:K.c.name,hint:K.c.hint}:null),requestAnimationFrame(()=>{const hn=fn.current;hn&&(hn.focus(),hn.setSelectionRange(_t,_t),zn(_t))})}}),Ut=y||E?S6(j):null,Xn=Bo&&j===`/${Bo.name} `?Bo.hint:null,Gn=Ut===""&&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,os=Xn??Gn,Vn=(e==null?void 0:e.worktree.title)??"untitled",Ho=(Mc=Nt==null?void 0:Nt.recap)==null?void 0:Mc.text,Zi=()=>{y&&ei(c,u,{t:"land",worktreeId:y})},jc=K=>{y&&(c==null||c.send({t:"judge",worktreeId:y,...K?{note:K}:{}}))},ci=!!((Lc=Te==null?void 0:Te.config.check)!=null&&Lc.trim()),ss=Dg(Mt,ue,Ve),js=pn&&!Je&&!We&&Ri(e.worktree)&&!Rn&&!ln&&vn>0&&(!Mt||!!Mt.stale||ss==="unanswered"),ui="Archive this worktree when you are done here; the rail's archived section brings it back with its chat.",_f=Qr?"update":"land",Cc=Te?Ud(Te):"main",Xa=Qr&&cr?`Commit, take ${Cc} in and push the branch; PR #${cr.number} takes the new commits.`:`${cd(rs,Te==null?void 0:Te.defaultBranch)}.`,or=y?dn?{word:"archive",line:((Pc=e==null?void 0:e.worktree.pr)==null?void 0:Pc.state)==="merged"?ys(e.worktree.pr):`landed on ${(Te==null?void 0:Te.defaultBranch)??"main"}.`,tip:ui,run:()=>Pi(c,u,[y])}:(Bt==null?void 0:Bt.state)==="open"&&!Qr?zE(Bt)?{word:"merge",line:Hu(Ho??ys(Bt)),tip:`${ys(Bt)} Merge the PR now, by the method the repo allows.`,run:Zi,ships:!0}:{word:"view",line:Hu(Ho??ys(Bt)),tip:`${ys(Bt)} Open the PR on GitHub.`,run:()=>window.open(Bt.url,"_blank")}:(Bt==null?void 0:Bt.state)==="closed"?{word:"archive",line:ys(Bt),tip:`${ys(Bt)} ${ui}`,run:()=>Pi(c,u,[y])}:js?{word:"check",line:(Mt==null?void 0:Mt.subject)??Hu(Ho??f4(vn)),tip:BE(Mt,ci,ss),run:jc}:Vt!=null&&Vt.ready&&!Uu(Vt,ue,Ve,nt==null?void 0:nt.name)?{word:_f,line:Vt.subject??Hu(Ho??(_0(Vt,vn)||"ready")),tip:[_0(Vt,vn),d4(Cc,e==null?void 0:e.behind),Xa,Vt.subject&&ue>0?"Tab from the word edits the message first.":""].filter(Boolean).join(" "),run:Zi,ships:!0}:null:null,di=((or==null?void 0:or.word)==="land"||(or==null?void 0:or.word)==="update"||(or==null?void 0:or.word)==="check")&&Vt?h4(Vt,ss):null,qi=S.useRef(null);Je!=="land"&&(qi.current=y&&(or!=null&&or.ships)?{id:y,verb:or,under:di}:null);const eo=Je==="land"&&Dt&&((Dc=qi.current)==null?void 0:Dc.id)===y?qi.current:null,Yn=eo?eo.verb:or,is=!!(Yn!=null&&Yn.ships)&&Je==="land",Gi=Eg(Ot,_g),as=lc(e,"commit"),ls=lc(e,"check"),cs=HE(is?as:ls),vr=Fa(Fg(cs)?cs==null?void 0:cs.since:void 0),Wo=Vt?Vt.check==="pending"&&ls&&cs===ls?fm("Checking the work",ls,vr):Uu(Vt,ue,Ve,nt==null?void 0:nt.name):null,fi=Yn&&is?Gi?`${Yn.word}: ${Gi}`:`${Yn.word} ${Yn.line}`:null,Cs=fi&&as&&cs===as?fm(fi,as,vr):fi,Vi=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`:e?Yn?"":Wo||(Bt?ys(Bt):an?zg(an):o?`describe ${Vn}…`:We?"describe a change":l?`message agent on ${Vn}`:`message agent on ${Vn}; / for a command, ! for a shell command`):"no worktree selected",As=j!==""||os||!e?null:is?Gi?null:eo?eo.under:di:Yn?di:Bt||Wo?Ho??(Vt==null?void 0:Vt.subject)??null:null,Is=S.useRef(!1);S.useEffect(()=>{const K=zr&&!Is.current;Is.current=zr,K&&((bt==null?void 0:bt.kind)==="file"&&y?uf(y,g.getState(),{sock:c,dispatch:u}):(bt==null?void 0:bt.kind)==="command"&&Ye&&Pt.length===0&&(c==null||c.send({t:"list-commands",worktreeId:Ye})))},[zr,bt==null?void 0:bt.kind,Pt.length,y,Ye,c,g,u]);const hi=()=>{if(!e)return;const K=[],Ge=W;if(Ge.url)try{const kr=new URL(Ge.url);K.push(`current route: ${kr.pathname}${kr.search}`)}catch{}Ge.title&&K.push(`page title: ${Ge.title}`),Ge.errors.length&&K.push(`recent console errors:
|
|
234
|
+
${Ge.errors.map(kr=>`- ${kr}`).join(`
|
|
235
|
+
`)}`);const _t=[];o&&_t.push(X6(e.worktree.title,Te==null?void 0:Te.configFile)),K.length>0&&_t.push(`What the user is looking at right now:
|
|
236
|
+
${K.join(`
|
|
237
|
+
`)}`);const hn=T6(_);return hn&&_t.push(hn),_t.length>0?_t:void 0},Ja=K=>{We?wn(K):y&&K!==_n&&(c==null||c.send({t:"set-worktree-mode",worktreeId:y,mode:K}))},er=K=>b&&u({a:"notice",id:b,text:K}),Sf=(K,Ge="")=>{if(!e||!y)return;if(K==="handoff"){if(We)return er("a new worktree has nothing to continue yet");const hn=U6(Ge,pe,e.worktree.repoId);"pick"in hn?u({a:"open",overlay:{kind:"handoff",worktreeId:y}}):"error"in hn?er(hn.error):c==null||c.send({t:"handoff-ask",worktreeId:y,repoId:hn.repo.id,...hn.text?{text:hn.text}:{}});return}if(K==="archive"){Rn||ln?Pi(c,u,[y]):er("archive is for a landed worktree; this one has not landed");return}if(K==="check"){We||!Ri(e.worktree)?er("nothing to check from here"):$e?er("wait for the turn to end"):vn===0?er("nothing to check: no changes here"):jc(Ge||void 0);return}const _t=Mt?Uu(Mt,ue,Ve,nt==null?void 0:nt.name):null;We||!Ri(e.worktree)?er("nothing to land from here"):Rn?er(`already landed on ${(Te==null?void 0:Te.defaultBranch)??"main"}`):_t?er(_t):$e&&(!Mt||Mt.stale)?er("wait for the turn to end"):Mt!=null&&Mt.stale?er("the work changed since this was checked; check again first"):Zi()},el=T.some(vd),pi=()=>{b&&(c==null||c.send({t:"set-draft",boxId:b,text:j,clientId:he}))},tl=()=>{if(!b||Dt)return;if(n){if(!n.restorable)return;if(Ut!==null){er("nothing runs here until it is restored");return}if(el){er(Op);return}const br=T.length?T.map(ql):void 0;pi(),c==null||c.send({t:"restore-worktree",archiveId:n.id,clientId:he,message:{text:j.trim(),attachments:br},boxId:b}),u({a:"restoring",id:b,text:j.trim()}),u({a:"sent-box",id:b});return}if(r){if(r.locked)return;if(Ut!==null){er("nothing runs here until Toyon takes it over; its menu on the rail opens a shell");return}if(el){er(Op);return}const br=T.length?T.map(ql):void 0;pi(),c==null||c.send({t:"adopt-worktree",worktreeId:r.id,clientId:he,message:{text:j.trim(),attachments:br},boxId:b}),u({a:"restoring",id:b,text:j.trim()}),u({a:"sent-box",id:b});return}if(!e||!y)return;if(Ut!==null){Ut&&m?u({a:"term-run",id:y,command:Ut}):Ut&&(c==null||c.send({t:"exec",worktreeId:y,command:Ut})),re("");return}const K=n8(j,Xr),Ge=K&&JF(K.name)?K.name:void 0;if(K&&!Ge){Sf(K.name,K.args),re("");return}if(Ge&&!(K!=null&&K.args)){Ja(Ge),re("");return}if(t!=null&&t.batch&&T.length){er("a batch takes no attachments; remove them or turn batch off");return}if(o&&!ct){er("choose an agent above first");return}if(el){er(Op);return}const _t=K?K.args:j.trim(),hn=hi(),kr=T.length?T.map(ql):void 0;if(pi(),Ge&&Ja(Ge),We){const br=gc(e.worktree)?{worktreeId:y}:{},zc={clientId:he,repoId:e.worktree.repoId,context:hn,attachments:kr,agent:It,profile:ye,mode:Ge??Le,...Rt?{model:Rt}:{},...ge?{effort:ge}:{},...S1(t)?{carry:!0}:{}};if(It!==Ue&&(c==null||c.send({t:"set-default-agent",agent:It})),t!=null&&t.batch)c==null||c.send({t:"batch-worktrees",repoId:e.worktree.repoId,prompt:_t,agent:It,...Rt?{model:Rt}:{},...ge?{effort:ge}:{},boxId:b});else{const Fc=t&&t.variants>1?{variants:t.variants}:{};c==null||c.send({t:"create-worktree",...zc,...br,...Fc,prompt:_t,boxId:b}),b&&u({a:"sending",id:b,message:{text:_t,attachments:kr}})}}else xn&&(c==null||c.send({t:"set-worktree-model",worktreeId:y,model:Rt}),c==null||c.send({t:"set-worktree-effort",worktreeId:y,effort:ge})),c==null||c.send({t:"chat",worktreeId:y,clientId:he,text:_t,context:hn,attachments:kr,boxId:b}),$e||u({a:"sending",id:y,message:{text:_t,attachments:kr}});u({a:"sent-box",id:b}),o&&u({a:"show-chat"})},Nf=K=>{if(!y||(ke==null?void 0:ke.ask.kind)!=="question")return;if(!K.some(ja))return u({a:"ask-revive",id:y});const Ge=k1(ke.ask.questions,K).join(`
|
|
238
|
+
`);c==null||c.send({t:"chat",worktreeId:y,clientId:he,text:Ge,context:hi()}),u({a:"sending",id:y,message:{text:Ge}}),u({a:"answered",id:y}),u({a:"ask-revive",id:y})},nl=M(K=>K.autoSend);yt([nl,y],()=>{!nl||nl!==y||!j.trim()||D!==!!o||(u({a:"auto-sent"}),tl())});const Tf=()=>{const K=T[T.length-1];return!b||!K?!1:(u({a:"detach",id:b,key:K.key}),!0)},Ac=K=>{b&&(u({a:"walk",id:b,walk:K.walk,text:K.text}),requestAnimationFrame(()=>{var Ge;(Ge=fn.current)==null||Ge.setSelectionRange(K.text.length,K.text.length),zn(K.text.length)}))},rl=()=>{b&&I&&u({a:"walk",id:b,walk:null,text:j})},jf=We?[]:_.map(K=>K.kind==="user"?K.attachments:void 0),Cf=We?[]:L.flatMap(K=>K.attachments??[]),Ic=e?e.worktree.path:null,mi=e==null?void 0:e.worktree.plan,Yi=kt&&!ne,Af=M(K=>K.reading),If=l&&Af&&Dt&&!ne&&!A&&!ae;return f.jsxs("div",{className:Be("composer chat-input",Yi&&"stopping",If&&"lean"),children:[mi&&e&&f.jsxs("div",{className:"composer-plan",...ot.contextMenu(()=>u_(mi,Ic,()=>c==null?void 0:c.send({t:"reveal",worktreeId:e.worktree.id,path:mi}),ts(c))),children:[f.jsx(St,{name:"text",className:"icon-inline"}),f.jsx(Pe,{variant:"inline",className:"composer-plan-path","data-tip":"Read the plan in the editor pane",onClick:()=>nr({dispatch:u},{worktreeId:e.worktree.id,path:mi,view:"preview"}),children:mi})]}),A&&y&&f.jsx(Rp,{icon:"chat",verb:"answer",tip:"Bring the question back into the box",onPress:()=>{u(A.kind==="ask"&&A.outcome?{a:"ask-revive",id:y,askId:A.id}:{a:"card-unpark",id:y}),u({a:"focus-chat"})},children:F6(A)}),ze&&y&&f.jsxs(Rp,{icon:"run",verb:ze.verb,tip:"Send the agent what it printed and ask for a fix",onPress:()=>c==null?void 0:c.send({t:"fix",worktreeId:y,toolId:ze.toolId}),onDismiss:()=>QF(ze.toolId),children:["what failed in ",f.jsx("code",{children:ze.command})]}),ae&&b&&!ne&&(e||N)&&f.jsx(Rp,{icon:"copy",verb:"attach",tip:"Attach it, as a paste would",onPress:()=>{hP(g,b,ae),gr()},onDismiss:X1,children:ae.kind==="image"?"the image you copied":`the text you copied, ${ae.text.split(`
|
|
239
|
+
`).length} lines`}),b&&ix(T,ax(sx(jf),Cf)).map(([K,Ge])=>{const _t=()=>u({a:"detach",id:b,key:K.key});return K.kind==="image"?f.jsx(lk,{src:K.local??h.upload(K.upload),n:Ge,name:K.name,width:K.width,height:K.height,bytes:K.bytes,uploading:K.uploading,onRemove:_t},K.key):K.kind==="file"?f.jsx(sk,{name:K.name,bytes:K.bytes,href:K.text&&K.upload?h.upload(K.upload):void 0,uploading:K.uploading,onRemove:_t},K.key):K.kind==="paste"?f.jsx(ok,{n:Ge,name:K.name,source:K.source,lines:K.lines,chars:K.chars,preview:K.preview,text:K.text,onRemove:_t},K.key):f.jsx(fk,{pick:K,dir:Ic,tipText:K.html,onHover:hn=>P&&Jt.post(P,hn?{type:"highlight-selector",selector:K.selector,label:hg(K)}:{type:"highlight-clear"}),worktreeId:y,onOpen:(hn,kr)=>y&&Ha(g,c,y,hn,kr),onRemove:_t},K.key)}),zr&&bt&&f.jsx(Y6,{results:Uo,keyOf:K=>K.kind==="cmd"?`c:${K.c.name}`:K.kind==="changes"?"changes":K.kind==="folder"?`d:${K.path}`:`f:${K.path}`,rowClass:K=>K.kind==="file"||K.kind==="folder"?"qo-file":K.kind==="changes"?"picker-row":"picker-row picker-cmd",nav:vt,listRef:Dr,empty:f8(bt.kind,Wt,Pt.length,Ye!==null),row:K=>{const Ge=((B==null?void 0:B.files.length)??0)>0;return K.kind==="file"?Am(K.path,K.status,bt.query,{gutter:Ge}):K.kind==="folder"?Am(K.path,void 0,bt.query,{folder:!0,gutter:Ge}):K.kind==="changes"?f.jsx(Un,{label:"@changes",hint:`${K.n} uncommitted ${K.n===1?"file":"files"}`}):f.jsx(uF,{c:K.c,query:bt.query})}}),ne&&y?ne.kind==="handoff"?f.jsx(GF,{item:ne,worktreeId:y,rootRef:q},ne.id):ne.ask.kind==="question"?f.jsx(o8,{item:ne,ask:ne.ask,worktreeId:y,rootRef:q,onAnswer:ke?Nf:void 0},ne.id):f.jsx(r8,{item:ne,ask:ne.ask,worktreeId:y,rootRef:q},ne.id):f.jsxs("div",{className:Be("composer-field",Ut!==null&&"shell",I&&"recalled"),children:[f.jsx(Ua,{size:"lg",bare:!0,font:Ut!==null?"mono":"ui",ref:fn,value:j,onChange:K=>{var br;const Ge=K.target.value,_t=K.target.selectionStart??Ge.length;re(Ge),zn(_t),vt.setIndex(0);const{inputType:hn}=K.nativeEvent;Pr(hn==="insertFromPaste"||hn==="insertFromDrop"?((br=bb(Ge,_t))==null?void 0:br.from)??null:null)},onKeyUp:K=>{_e(),zn(K.currentTarget.selectionStart??0)},onClick:K=>{zn(K.currentTarget.selectionStart??0),rl()},onPaste:ce,onScroll:K=>{Gt.current&&(Gt.current.scrollTop=K.currentTarget.scrollTop)},onKeyDown:K=>{var Ge;if(me(K),!K.nativeEvent.isComposing){if(zr){if(K.key==="Escape"){K.preventDefault(),K.stopPropagation(),Pr((bt==null?void 0:bt.from)??null);return}if(vt.onKeyDown(K))return}if((K.key==="ArrowUp"||K.key==="ArrowDown")&&!K.altKey&&!K.ctrlKey){const _t=K.key==="ArrowUp",hn=L.at(-1);if(_t&&!K.metaKey&&!I&&j===""&&y&&!m&&hn!==void 0){K.preventDefault(),dE(g,c,y,L.length-1);return}const kr=K.metaKey?_t?"first":"box":_t?"up":"down",br=y?H6(_,I??null,j,kr):null;if(br){K.preventDefault(),(br.walk!==I||br.text!==j)&&Ac(br);return}}if(I&&K.key==="Escape"){K.preventDefault(),K.stopPropagation(),Ac({walk:null,text:I.from});return}if(K.key==="Escape"&&$e&&y&&!m){K.preventDefault(),K.stopPropagation(),c==null||c.send({t:"stop-agent",worktreeId:y});return}if(I&&c8.has(K.key)&&rl(),K.key==="Tab"&&!K.shiftKey&&j===""){const _t=(Ge=K.currentTarget.closest(".composer"))==null?void 0:Ge.querySelector(".composer-verb");if(_t&&!_t.disabled){K.preventDefault(),_t.focus();return}if(Qe){K.preventDefault(),u({a:"edit-commit"});return}}K.key==="Enter"&&(ie?K.metaKey||K.ctrlKey:!K.shiftKey)?(K.preventDefault(),tl()):K.key==="Backspace"&&j===""&&Tf()&&K.preventDefault()}},placeholder:As||Yn?"":Vi,disabled:!e&&!N}),os&&f.jsxs("div",{className:"composer-ghost","aria-hidden":"true",children:[f.jsx("span",{className:"picker-typed",children:j}),os]}),y&&Ut===null&&j.includes("@")&&f.jsx("div",{ref:Gt,className:"composer-ghost composer-marks","aria-hidden":"true",onClick:K=>mS(K,e==null?void 0:e.worktree.path,y,{sock:c,dispatch:u}),children:f.jsx(pS,{text:j,worktreeId:y,root:e==null?void 0:e.worktree.path,inField:!0})}),(As||Yn)&&f.jsxs("div",{className:"composer-ghost","aria-hidden":Yn?void 0:"true",children:[f.jsx("span",{className:Be("composer-placeholder",is&&"live-text"),children:Cs||(Yn?f.jsxs(f.Fragment,{children:[f.jsx(Pe,{variant:"inline",tone:"strong",className:"composer-verb",disabled:!!Yn.ships&&!!Je,...Ft(Yn.tip,void 0,{placement:"top"}),onClick:Yn.run,onKeyDown:K=>{K.key==="Tab"&&!K.shiftKey&&Qe&&(K.preventDefault(),u({a:"edit-commit"}))},children:Yn.word})," ",f.jsx("span",{className:"composer-verb-line",children:Yn.line})]}):Vi)}),As&&f.jsxs(f.Fragment,{children:[`
|
|
240
|
+
`,f.jsx("span",{className:"composer-subline",children:As})]})]}),Yi&&f.jsx(Lt,{icon:"stop",tone:"danger",className:"composer-stop",label:`Stop the agent (context up to here is kept${L.length?"; queued messages go next":""})`,hint:"esc",onClick:()=>y&&(c==null?void 0:c.send({t:"stop-agent",worktreeId:y}))})]}),O&&f.jsx("div",{className:"hint composer-notice",role:"status",children:O}),!ne&&f.jsxs("div",{className:"hint composer-knobs",children:[f.jsxs("span",{className:"spawn-left",children:[Ht?qe.length>1?f.jsx(AS,{agents:qe,agent:It,model:Rt,onChange:un,onClose:qn}):f.jsx(Cm,{models:mt,value:Rt,onChange:V,onClose:qn}):e&&f.jsx(Cm,{models:mt,value:e.worktree.model??"",current:yn,onChange:K=>c==null?void 0:c.send({t:"set-worktree-model",worktreeId:e.worktree.id,model:K}),onClose:qn}),Ht?f.jsx(jm,{efforts:En,value:ge,onChange:ft,onClose:qn}):e&&f.jsx(jm,{efforts:En,value:e.worktree.effort??"",current:Tn,onChange:K=>c==null?void 0:c.send({t:"set-worktree-effort",worktreeId:e.worktree.id,effort:K}),onClose:qn}),We?f.jsx(Cb,{value:Le,onChange:wn,onClose:qn}):e&&f.jsx(Cb,{value:_n,onChange:K=>c==null?void 0:c.send({t:"set-worktree-mode",worktreeId:e.worktree.id,mode:K}),onClose:qn}),Et&&f.jsxs("span",{className:"usage-knob",onMouseEnter:()=>{window.clearTimeout(ut.current),ut.current=window.setTimeout(()=>Z(!0),u8)},onMouseLeave:()=>{window.clearTimeout(ut.current),Z(!1)},children:[f.jsx(Lt,{icon:f.jsx(Q6,{fraction:lt?lt.used/lt.size:0,level:Fe?z4(Fe,cn):void 0}),tone:"chrome",on:de,silent:!0,label:lt?`${Math.round(100*lt.used/lt.size)}% of context`:Fe?L0(Fe,cn):"",detail:[...lt&&Fe?[L0(Fe,cn)]:[],...je?[je]:[]],onClick:()=>De(K=>!K),...ot.contextMenu(Xt)}),(mn||de)&&f.jsx(a8,{usage:lt,limits:Fe,now:cn,compact:de?{off:ur,advice:lt?M0(lt.used/lt.size):void 0,run:()=>{wt(),Zn()}}:void 0,onClose:wt},de?"pinned":"hover")]})]}),f.jsxs("span",{className:"spawn-tools",children:[b&&(e||N)&&f.jsx(Lt,{icon:"attach",tone:"chrome",label:l?"Attach a picture":"Attach a picture or a file",onClick:()=>pP(g,b,{images:l})}),!o&&!E&&!l&&f.jsx(Lt,{icon:"terminal",tone:"chrome",on:sn,className:"composer-term",disabled:!e,label:In?In.tip:"Terminal",hint:Tt("terminal"),badge:In&&f.jsx("span",{className:"composer-term-dot"}),onClick:()=>{u(In&&!sn&&y?{a:"term-stream",id:y,stream:In.stream}:{a:"toggle-terminal"})},...ot.contextMenu(()=>e&&y?e6(e.procs,y,sn,{sock:c,dispatch:g.dispatch}):[])}),!o&&!xe&&!E&&!l&&f.jsx(Lt,{icon:"pick",label:"Pick an element on the page to attach",hint:Tt("pick"),on:Sn==="chat",disabled:!P,onClick:()=>P&&ac(P,Sn,u,"chat")}),ie&&b&&(e||N)&&f.jsx(Lt,{icon:"send",tone:"primary",label:"Send",disabled:Dt,onMouseDown:K=>K.preventDefault(),onClick:tl})]})]}),Me&&$t&&f.jsx("div",{className:"composer-notes",children:f.jsxs("div",{className:"hint composer-note",children:[f.jsx("span",{children:Me}),l4($t)&&f.jsx(Pe,{variant:"outline",busy:Oe==="pull-main",disabled:!!Oe,"data-tip":"Fast-forward main to origin",onClick:()=>ei(c,u,{t:"pull-main",worktreeId:$t.id}),children:"pull"})]})})]})}function YS({children:e,className:t,tip:n,...r}){return f.jsxs("label",{className:Be("check",t),"data-tip":n,children:[f.jsx("input",{type:"checkbox",className:"check-box",...r}),f.jsx("span",{children:e})]})}const p8=[1,2,3];function m8({draft:e,lead:t}){const n=at(),r=M(u=>ai(u,t==null?void 0:t.repoId)),[o]=IS(r),i=M(u=>{var c;return((c=Da(u,t==null?void 0:t.repoId))==null?void 0:c.dirty)??0}),l=!e.batch&&e.variants===1;return f.jsxs("div",{className:"draft-intro",children:[f.jsxs("div",{className:"draft-row hint",children:[f.jsx(Pe,{variant:"ghost",tone:"chrome",on:e.batch,"data-tip":"An agent splits the prompt into a worktree per task",onClick:()=>n({a:"draft-batch",v:!e.batch}),children:"batch"}),f.jsxs("span",{className:"draft-variants",children:[p8.map(u=>f.jsx(Pe,{variant:"ghost",on:e.variants===u,disabled:e.batch,onClick:()=>n({a:"draft-variants",n:u}),children:u},u)),f.jsx("span",{"data-tip":"Run the same prompt in N parallel worktrees, keep the best",children:"variants"})]}),f.jsx("span",{className:"draft-runs",children:f.jsx(cF,{repo:r,value:e.profile??o,onChange:u=>n({a:"draft-profile",profile:u})})})]}),t&&r&&i>0&&f.jsx("div",{className:"draft-notes",children:f.jsxs(YS,{className:"hint draft-note",checked:S1(e),disabled:!l,tip:l?`Move the ${i} uncommitted ${i===1?"file":"files"} into the new worktree, leaving ${r.defaultBranch} clean`:"One set of changes can only go into one worktree",onChange:u=>n({a:"draft-carry",v:u.currentTarget.checked}),children:[f.jsxs("span",{className:"badge-dirty",children:["~",i]})," on ",r.defaultBranch," come along"]})})]})}function g8({row:e}){const t=st(),n=M(l=>l.clientId),r=M(l=>l.home),o=r&&e.path.startsWith(`${r}/`)?`~${e.path.slice(r.length)}`:e.path,i=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 f.jsxs(Do,{icon:e.locked?"lock":"branch",word:e.locked?"held":"discovered",tone:"quiet",below:f.jsx("div",{className:"daemon-below row-dim",children:i}),children:[f.jsxs("span",{className:"daemon-text",children:[e.locked&&`by ${e.lockReason??"another tool"}, at `,f.jsx("span",{className:"tool-hint",children:o})]}),!e.locked&&f.jsx(Pe,{variant:"inline",tone:"strong",onClick:()=>t==null?void 0:t.send({t:"adopt-worktree",worktreeId:e.id,clientId:n}),children:"take over"})]})}function Ql({placement:e,className:t,width:n,archived:r,found:o}){const i=at(),l=Ss(),u=uL(),c=At(l==null?void 0:l.worktree.id,"sending"),h=Va(),p=e==="centre"&&!r&&(h!=null&&h.assumed)?h:null,g=M(w=>{var b;return((b=w.dragFiles)==null?void 0:b.at)==="chat"}),m=Kn(),y=S.useMemo(()=>uP(m),[m]);return f.jsxs("div",{className:Be(e==="dock"?"chat-dock":e==="centre"?"chat-centre":"chat-screen",t,g&&"drop-over"),style:n===void 0?void 0:{width:n},...y,ref:w=>{var b;w?Vl.el=w:(b=Vl.el)!=null&&b.isConnected||(Vl.el=null)},children:[r?f.jsx(Ap,{active:null,archived:r,tail:f.jsx(K4,{item:r})}):o?f.jsx(Ap,{active:null,found:o,tail:f.jsx(g8,{row:o})}):f.jsx(Ap,{active:l,lead:p&&f.jsxs("p",{className:"hint chat-centre-note",children:[p.name," has ",f.jsx("code",{children:p.assumed})," and no dev server, so it is chat only for now."," ",f.jsx(Pe,{variant:"inline",onClick:()=>i({a:"open",overlay:{kind:"setup",repoId:p.id}}),children:"add a dev server"})]})}),!r&&!o&&u&&!c&&f.jsx(m8,{draft:u,lead:l}),r?f.jsx(ad,{active:null,archived:r,placement:e}):o?f.jsx(ad,{active:null,found:o,placement:e}):f.jsx(ad,{active:l,draft:u,placement:e})]})}const k8="modulepreload",y8=function(e){return"/"+e},Mb={},$m=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(p=>Promise.resolve(p).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),c=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));o=l(n.map(h=>{if(h=y8(h),h in Mb)return;Mb[h]=!0;const p=h.endsWith(".css"),g=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${g}`))return;const m=document.createElement("link");if(m.rel=p?"stylesheet":k8,p||(m.as="script"),m.crossOrigin="",m.href=h,c&&m.setAttribute("nonce",c),document.head.appendChild(m),p)return new Promise((y,w)=>{m.addEventListener("load",y),m.addEventListener("error",()=>w(Error(`Unable to preload CSS for ${h}`)))})}))}function i(l){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=l,window.dispatchEvent(u),!u.defaultPrevented)throw l}return o.then(l=>{for(const u of l||[])u.status==="rejected"&&i(u.reason);return t().catch(i)})},wk=800;function w8(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 Ro=e=>`${e.worktreeId}
|
|
241
|
+
${e.ref??""}
|
|
242
|
+
${e.since??""}
|
|
243
|
+
${e.path}`;class v8{constructor(t){jt(this,"files",new Map);jt(this,"looks",new Map);this.d=t}start(){var i,l;let t=this.d.store.getState();const n=this.d.store.subscribe(()=>{const u=this.d.store.getState(),c=t;t=u,this.follow(c,u)}),r=()=>{const u=this.d.store.getState().editor;u&&!u.loose&&this.refresh(Ro(u))};(i=this.d.win)==null||i.addEventListener("focus",r);const o=()=>{for(const[u,c]of this.files)c.timer!==void 0&&this.saveNow(u)};return(l=this.d.win)==null||l.addEventListener("pagehide",o),()=>{var u,c;n(),(u=this.d.win)==null||u.removeEventListener("focus",r),(c=this.d.win)==null||c.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(Ro(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=Po();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=Ro(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(Ro(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(Ro(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 i,l;t.connected&&!n.connected&&this.dropped();const r=(i=n.editor)!=null&&i.loose?null:n.editor,o=(l=t.editor)!=null&&l.loose?null:t.editor;if(o&&(!r||Ro(o)!==Ro(r))&&this.closed(Ro(o)),r&&(!o||o.seq!==r.seq)&&this.opened(r),!t.connected&&n.connected)for(const u of this.files.values())u.reread=!0,this.next(u);else r&&o&&o.seq===r.seq&&bo(t,r.worktreeId).git!==bo(n,r.worktreeId).git&&this.refresh(Ro(r))}opened(t){const n=Ro(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 l;if(t.out||!this.d.store.getState().connected)return;const{worktreeId:n,path:r,ref:o,since:i}=t.file;if(t.reread){t.reread=!1;const u=Po();t.out={seq:u},this.d.send({t:"read-file",worktreeId:n,path:r,ref:o,since:i,seq:u});return}if(t.pending!==null&&t.base&&t.pending===t.base.text&&(t.pending=null),t.pending!==null&&t.writable&&!t.conflict&&!o){const u=t.pending,c=Po();t.pending=null,t.out={seq:c,write:u},this.d.send({t:"write-file",worktreeId:n,path:r,content:u,base:((l=t.base)==null?void 0:l.version)??null,seq:c});return}!t.open&&!t.buffer&&t.pending===null&&!t.conflict&&this.files.delete(Ro(t.file))}read(t,n){var m,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:i,version:l,writable:u,binary:c,tooLarge:h}=n;t.writable=u,t.open&&(this.d.store.dispatch({a:"editor-read",file:r,disk:{before:o,after:i,version:l,writable:u,binary:c,tooLarge:h}}),!c&&!h&&(l!==null||r.ref)&&this.askBlame(t,l));const p={after:t.buffer?t.buffer.normalize(i):i,version:l};if(!t.base){t.base={text:p.after,version:l};return}const g=((m=t.buffer)==null?void 0:m.text())??t.pending??t.base.text;switch(w8(t.base,g,t.pending,p)){case"same":break;case"adopt":t.base={text:p.after,version:l};break;case"apply":(y=t.buffer)==null||y.replace(p.after),t.base={text:p.after,version:l};break;case"gone":t.base={text:"",version:null},t.open&&this.d.store.dispatch({a:"close-editor"});break;case"conflict":this.setConflict(t,p);return}this.setConflict(t,null)}askBlame(t,n){const r=Po();t.blame={seq:r,version:n};const{worktreeId:o,path:i,ref:l}=t.file;this.d.send({t:"blame-file",worktreeId:o,path:i,ref:l,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:i}=n;this.d.store.dispatch({a:"editor-blame",file:t.file,blame:{commits:o,lines:i,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)},wk))}saveNow(t){const n=this.files.get(t);if(!(n!=null&&n.buffer))return;this.cancelTimer(n);const r=n.buffer.text();r.length>gd||(n.pending=r,this.next(n))}cancelTimer(t){t.timer!==void 0&&(this.d.timers.clear(t.timer),t.timer=void 0)}}const QS={attach:()=>{},edited:()=>{},saveNow:()=>{}},b8=e=>({timers:{set:(t,n)=>setTimeout(t,n),clear:t=>clearTimeout(t)},win:typeof window>"u"?null:window,send:e}),Om=new Map;function x8(e){const t=Om.get(e.seq);return t?(Om.delete(e.seq),t(e),!0):!1}function E8(e,t,n,r){if(e.kind==="bytes")return QS;if(e.kind==="grant")return _8(e,t,n,r);const o=e.handle;let i=null,l,u=null,c=Promise.resolve(),h=!1;const p=()=>(u??(u=(async()=>await o.queryPermission({mode:"readwrite"})==="granted"?!0:await o.requestPermission({mode:"readwrite"})==="granted")().catch(()=>!1)),u),g=()=>{l!==void 0&&r.timers.clear(l),l=void 0},m=()=>{h||(h=!0,g(),n(`read-only: the browser would not save ${t}`))},y=async E=>{if(!await p())return m();const N=await o.createWritable();await N.write(E),await N.close()},w=()=>{if(!i||h)return;g();const E=i.text();c=c.then(()=>y(E)).catch(m)},b=()=>{l!==void 0&&w()};return{attach(E){var N,j;if(E){i=E,(N=r.win)==null||N.addEventListener("pagehide",b);return}l!==void 0&&w(),i=null,(j=r.win)==null||j.removeEventListener("pagehide",b)},edited(){!i||h||(p().then(E=>{E||m()}),g(),l=r.timers.set(w,wk))},saveNow:w}}function _8(e,t,n,r){let o=null,i,l=e.version,u=!1,c=null,h=!1;const p=()=>{i!==void 0&&r.timers.clear(i),i=void 0},g=b=>{h||(h=!0,p(),c=null,n(b))},m=b=>{if(!r.send)return;const E=Po();u=!0,Om.set(E,N=>{if(u=!1,N.ok?l=N.version:N.reason==="changed"?g(`read-only: ${t} changed on disk; open it again to edit`):g(N.message??`not saved: ${t}`),c!==null&&!h){const j=c;c=null,m(j)}}),r.send({t:"write-loose",id:e.id,content:b,base:l,seq:E})},y=()=>{if(!o||h)return;p();const b=o.text();b.length>gd||(u?c=b:m(b))},w=()=>{i!==void 0&&y()};return{attach(b){var E,N;if(b){o=b,(E=r.win)==null||E.addEventListener("pagehide",w);return}i!==void 0&&y(),o=null,(N=r.win)==null||N.removeEventListener("pagehide",w)},edited(){!o||h||(p(),i=r.timers.set(y,wk))},saveNow:y}}function vk({kind:e,className:t,height:n,resizable:r=!0,onDragStart:o,title:i,tabs:l,actions:u,menu:c,full:h,onToggleFull:p,onClose:g,closeHint:m="esc",children:y}){const w=on("pane"),b=p&&f.jsxs(Pe,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:p,"data-tip":h?"Split view: show the preview above":"Full height: hide the preview",children:[f.jsx(St,{name:h?"split":"full",className:"icon-inline"})," ",h?"split":"full"]}),E=f.jsx(Lt,{icon:"close",label:"Close",hint:m,onClick:g});return f.jsxs("div",{className:`pane ${t}`,"data-pane":e,tabIndex:-1,style:n===void 0?void 0:{height:n},children:[r&&f.jsx("div",{className:"pane-resize",onPointerDown:o}),f.jsx("div",{className:Be("pane-head",l&&"pane-head-tabs"),...w.contextMenu(()=>(c==null?void 0:c())??[]),children:l?f.jsx(pf,{...l,end:f.jsxs(f.Fragment,{children:[u,b,E]})}):f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"pane-title",children:i}),u,b,E]})}),y]})}function S8({src:e,path:t,full:n,onFull:r}){const o=on("editor");return f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",className:"editor-image",onClick:()=>r(!0),...o.contextMenu(()=>cc(e,{open:()=>r(!0)})),children:f.jsx("img",{src:e,alt:t})}),n&&f.jsx(Ug,{owner:"editor",onClose:()=>r(!1),menu:()=>cc(e),children:f.jsx("img",{src:e,alt:t})})]})}const N8={image:S8};function T8({kind:e,src:t,path:n,openSeq:r,focus:o,full:i,onFull:l}){const u=S.useRef(null);yt([r],()=>{var h;o&&((h=u.current)==null||h.focus())});const c=N8[e];return f.jsx("div",{ref:u,className:"editor-viewer",tabIndex:-1,children:f.jsx(c,{src:t,path:n,full:i,onFull:l})})}const j8="img[src], source[src], video[src], audio[src], video[poster], link[href], object[data]";function C8(e,t){if(!t)return e;const n=new DOMParser().parseFromString(e,"text/html");let r=!1;for(const o of n.querySelectorAll(j8))for(const i of["src","href","poster","data"]){const l=o.getAttribute(i),u=l===null?null:Hg(t.dir,l);u&&(o.setAttribute(i,t.urls.worktreeFile(t.worktreeId,u,t.version)),r=!0)}return r?`${n.doctype?`<!doctype html>
|
|
244
|
+
`:""}${n.documentElement.outerHTML}`:e}function A8({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:i}){const l=S.useRef(null);yt([o],()=>{var p;i&&((p=l.current)==null||p.focus())});const u=Lr(),c=d_(t),h=S.useMemo(()=>C8(e,r===void 0?null:{worktreeId:n,dir:c,version:r,urls:u}),[e,n,c,r,u]);return f.jsx("div",{ref:l,className:"editor-viewer",tabIndex:-1,children:f.jsx("iframe",{className:"editor-frame",title:t,sandbox:"",srcDoc:h})})}function I8(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 R8(e){const t=new Map,n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=I8(n.map(o=>Number(o.tagName[1])));return n.map((o,i)=>{var c;const l=((c=o.textContent)==null?void 0:c.trim())??"",u=t.get(l)??0;return t.set(l,u+1),{id:`${u}
|
|
245
|
+
${l}`,level:Number(o.tagName[1]),depth:r[i],text:l,el:o}})}const $8=48,O8=16;function M8({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:i,onChat:l}){st();const u=Lr(),c=at(),h=d_(t),p=rk(e,r===void 0?void 0:{base:{worktreeId:n,dir:h,version:r,urls:u}}),g=S.useRef(null),m=S.useRef(null),[y,w]=S.useState([]),[b,E]=S.useState(-1),[N,j]=S.useState(null),T=R=>{var I;if(j(null),R){const _=window.getSelection();_==null||_.removeAllRanges(),_==null||_.addRange(R)}(I=g.current)==null||I.focus()};yt([o],()=>{var R;i&&((R=g.current)==null||R.focus())}),yt([p],()=>{g.current&&w(R8(g.current))}),S.useLayoutEffect(()=>{const R=g.current;if(!R)return;let I=0;const _=()=>{if(I=0,R.scrollTop+R.clientHeight>=R.scrollHeight-1){E(y.length-1);return}const z=R.scrollTop+$8;let F=-1;for(let ee=0;ee<y.length;ee++)y[ee].el.offsetTop<=z&&(F=ee);E(F)},L=()=>{I||(I=requestAnimationFrame(_))};return _(),R.addEventListener("scroll",L),()=>{R.removeEventListener("scroll",L),I&&cancelAnimationFrame(I)}},[y]);const O=R=>{var _,L;const I=(_=y[R])==null?void 0:_.el;(L=g.current)==null||L.scrollTo({top:Math.max(0,I?I.offsetTop-O8:0),behavior:"smooth"})},U=R=>{const I=R.target.closest("a"),_=I==null?void 0:I.getAttribute("href");if(!_||(I==null?void 0:I.target)==="_blank")return;R.preventDefault();const L=Hg(h,_);L&&nr({dispatch:c},{worktreeId:n,path:L,view:Fi(L)})},Q=R=>{var I;if(Bg(R)){R.preventDefault(),R.stopPropagation();const _=(m.current&&mm(m.current))??"";j(L=>({seed:_||(L==null?void 0:L.seed)||"",seq:((L==null?void 0:L.seq)??0)+1}));return}if(R.key==="Escape"&&N){R.stopPropagation(),T(null);return}if(s_(R)&&m.current){R.preventDefault(),a_(m.current);return}if(((I=lx(R))==null?void 0:I.id)==="composer"&&m.current){const _=mm(m.current);if(!_)return;R.preventDefault(),R.stopPropagation(),l(_)}};return f.jsxs(f.Fragment,{children:[f.jsx("div",{ref:g,className:"editor-viewer editor-preview",tabIndex:-1,onClick:U,onKeyDown:Q,children:f.jsx("div",{ref:m,className:"md md-preview",dangerouslySetInnerHTML:{__html:p}})}),N&&f.jsx(o_,{root:g,body:m,seed:N.seed,seq:N.seq,onClose:T}),f.jsx(L8,{heads:y,at:b,onJump:O})]})}function L8({heads:e,at:t,onJump:n}){const[r,o]=S.useState(!1),i=S.useRef(null);return e.length<2?null:f.jsxs(f.Fragment,{children:[f.jsx("div",{ref:i,className:"editor-outline","aria-hidden":!0,onPointerEnter:l=>{l.pointerType==="mouse"&&o(!0)},onClick:()=>o(l=>!l),children:e.map((l,u)=>f.jsx("span",{className:"editor-outline-tick","data-level":l.level,"data-state":pr({current:u===t})},l.id))}),r&&f.jsx(Ns,{className:"editor-outline-list",anchor:()=>{var l;return((l=i.current)==null?void 0:l.getBoundingClientRect())??null},placement:{side:"right",align:"center",cover:!0},trigger:i.current,onDismiss:()=>o(!1),onPointerLeave:l=>{l.pointerType==="mouse"&&o(!1)},children:e.map((l,u)=>f.jsx("button",{type:"button",className:"row editor-outline-row","data-level":l.level,"data-state":pr({current:u===t}),onClick:()=>n(u),children:f.jsx("span",{className:"editor-outline-label",style:{"--outline-depth":l.depth},children:l.text})},l.id))})]})}function P8({absPath:e,onReveal:t}){const n=on("editor"),{host:r}=Lr();return Cg(r)?f.jsxs(Pe,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",...n.dropdown(()=>Bi(e,t,r),"right"),children:["open in ",f.jsx(St,{name:"caret",className:"icon-inline"})]}):null}const D8=S.lazy(async()=>{const[e]=await Promise.all([$m(()=>import("./Editor-Cs_OeWSx.js").then(t=>t.E),__vite__mapDeps([0,1,2])),$m(()=>import("./grammar-BSzyJU-q.js"),[]).then(t=>t.grammarsReady)]);return e});function Lb({what:e}){return W1(!0,3e3)?f.jsx("div",{className:"empty",children:f.jsxs("span",{className:"live-text",children:["loading ",e]})}):null}const z8=()=>{},F8={diff:"diff",file:"text",preview:"book"};function B8(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 XS({editor:e,height:t,full:n=!1,onToggleFull:r,onDragStart:o,placement:i="stack"}){const l=i==="screen",u=at(),c=Kn(),h=st(),p=Lr(),g=U1(),m=of(),{worktreeId:y,path:w,ref:b,since:E}=e,N=e.loose,j=M(A=>{var q;return((q=xo(A))==null?void 0:q.id)===y}),T=M(A=>{var ie,P;const q=(ie=rn(A,y))==null?void 0:ie.worktree;return q?q.path:(P=xo(A))==null?void 0:P.path}),O=N?N.source.kind==="grant"?N.source.path:null:T?`${T}/${w}`:w,U=b!==void 0,Q=S.useMemo(()=>N?E8(N.source,w,A=>u({a:"editor-refused",file:{worktreeId:y,path:w},message:A}),b8(h?A=>h.send(A):null)):(g==null?void 0:g.bind({worktreeId:y,path:w,...b?{ref:b}:{},...E?{since:E}:{}}))??QS,[g,y,w,b,E,N,u,h]),R=M(A=>bo(A,y).changedRanges[w]);S.useEffect(()=>{!R&&!U&&!j&&!N&&(h==null||h.send({t:"changed-ranges",worktreeId:y,path:w}))},[y,w,R,U,j,N,h]);const I=(R==null?void 0:R.offset)??0,_=e.disk,L=e.view??"diff",z=(_==null?void 0:_.before)==="",F=iE(w,z).filter(A=>A!==L&&!(N&&A==="diff")),ee=(N==null?void 0:N.source.kind)==="grant"?N.source:null,se=U||j||N&&!ee?null:x2(w),[fe,ke]=S.useState(!1),ne=e.line&&!e.line.fiber?e.line.n:void 0;return f.jsxs(vk,{kind:"editor",className:Be("editor-pane",n&&"full"),height:n||l?void 0:t,resizable:!n&&!l,onDragStart:o??z8,title:U?`${w} at ${b==null?void 0:b.slice(0,7)}`:E?`${w}, last turn`:w,menu:()=>T&&!N?vs({id:y,dir:T},w,{discard:!U&&!j,kept:j,ref:b,showing:e.view??void 0,added:z},{sock:h,dispatch:u}):[],onClose:()=>u({a:"close-editor"}),full:n,onToggleFull:l?void 0:r,actions:f.jsxs(f.Fragment,{children:[!se&&F.map(A=>f.jsxs(Pe,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>u({a:"editor-view",v:A}),"data-tip":B8(A,L),children:[f.jsx(St,{name:F8[A],className:"icon-inline"})," ",A]},A)),se==="image"&&f.jsxs(Pe,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>ke(!0),"data-tip":"Full size: see the picture over the window",children:[f.jsx(St,{name:"zen",className:"icon-inline"})," full size"]}),!j&&O!==null&&f.jsx(P8,{absPath:O,onReveal:N?void 0:()=>h==null?void 0:h.send({t:"reveal",worktreeId:y,path:w})})]}),children:[_&&f.jsx(U8,{editor:e,disk:_,files:g}),f.jsx("div",{className:"editor-body",children:_?se?f.jsx(T8,{kind:se,src:ee?p.loose(ee.id,ee.version):p.worktreeFile(y,w,_.version),path:w,openSeq:e.seq,focus:e.focus,full:fe,onFull:ke}):_.binary?f.jsx("div",{className:"empty",children:"not a text file: open it in another editor"}):_.tooLarge?f.jsx("div",{className:"empty",children:"too large to open here: open it in another editor"}):L==="preview"&&Jd(w)==="html"?f.jsx(A8,{text:_.after,path:w,worktreeId:y,version:U||j||N?void 0:_.version,openSeq:e.seq,focus:e.focus}):L==="preview"?f.jsx(M8,{text:_.after,path:w,worktreeId:y,version:U||j||N?void 0:_.version,openSeq:e.seq,focus:e.focus,onChat:A=>l0(c,{worktreeId:y,text:A,name:w})}):f.jsx(Lg,{pane:!0,children:f.jsx(S.Suspense,{fallback:f.jsx(Lb,{what:L}),children:f.jsx(D8,{file:{worktreeId:y,path:w,...b?{ref:b}:{},...E?{since:E}:{}},disk:_,blame:e.blame,view:L,openSeq:e.seq,line:ne,focus:e.focus,readOnly:U||!_.writable||l,numbers:!l,theme:m,sync:Q,onCopy:N?void 0:(A,q,ie)=>xL(ie,{worktreeId:y,path:A,...q,...b?{ref:b}:{}}),onChat:(A,q)=>l0(c,q&&(N?{worktreeId:y,text:q.text,name:A}:{worktreeId:y,text:q.text,source:{path:A,startLine:q.startLine,endLine:q.endLine,...b?{ref:b}:{}}})),onNew:()=>c.dispatch({a:"open-draft"}),onLineHover:U||N?void 0:A=>{A==null?Jt.post(y,{type:"highlight-clear"}):Jt.post(y,{type:"highlight-file",path:w,ranges:[[A+I,A+I]]})}},`${y}
|
|
246
|
+
${N?"loose":b??E??""}
|
|
247
|
+
${w}`)})}):f.jsx(Lb,{what:w},w)})]})}function U8({editor:e,disk:t,files:n}){const{worktreeId:r,path:o,ref:i,since:l,conflict:u}=e,c={worktreeId:r,path:o,...i?{ref:i}:{},...l?{since:l}:{}};if(u){const h=u.version===null;return f.jsxs("div",{className:"editor-note",children:[f.jsx("span",{className:"editor-note-text",children:h?"deleted on disk; your edits are not saved":"changed on disk; your edits are not saved"}),f.jsx(Pe,{variant:"outline",onClick:()=>n==null?void 0:n.reload(c),"data-tip":h?"Close the file; your edits go with it":"Take the file as it is on disk; undo brings your edits back",children:h?"close":"reload"}),f.jsx(Pe,{variant:"outline",tone:"danger",onClick:()=>n==null?void 0:n.keepMine(c),"data-tip":h?"Save your edits as the file again":"Save your edits over the file on disk",children:"keep mine"})]})}return e.refused?f.jsx("div",{className:"editor-note",children:f.jsx("span",{className:"hint",children:e.refused})}):e.loose&&!t.writable&&!t.tooLarge&&!t.binary?f.jsx("div",{className:"editor-note",children:f.jsxs("span",{className:"hint",children:["read-only: ",o," is not in a project; drop it on a folder in files to add it"]})}):i===void 0&&!t.writable&&!t.binary&&!t.tooLarge?f.jsx("div",{className:"editor-note",children:f.jsx("span",{className:"hint",children:"read-only: Toyon does not run this worktree"})}):null}const Gs={title:"Add a machine",lead:"Point the camera at the code on its screen, or paste the link.",placeholder:"https://",pasteOnly:"Paste the link from the code on its screen.",notALink:"That is not a Toyon link. It starts with https:// and ends in #pair= or #token=.",asking:e=>`Asking ${JS(e)}.`,added:e=>`Added ${e}.`,add:"add"};function JS(e){try{return new URL(e).host}catch{return e}}function Pb(e,t){const n=JS(t);switch(e){case"expired":return"This code has expired; show a new one on the other machine.";case"not-toyon":return`${n} is not a Toyon machine, or has no remote name set up.`;case"unreachable":return`${n} did not answer. Is Tailscale on here, and is Toyon running there?`}}const H8=250;function W8({onRead:e,onUnavailable:t}){const n=S.useRef(null),r=S.useRef(e);r.current=e;const o=S.useRef(t);return o.current=t,S.useEffect(()=>{var y;const i=window.BarcodeDetector,l=n.current;if(!i||!l||!((y=navigator.mediaDevices)!=null&&y.getUserMedia)){o.current();return}let u=!0,c=null,h;const p=new i({formats:["qr_code"]});let g=null;const m=async()=>{var w;if(u){try{const E=(w=(await p.detect(l))[0])==null?void 0:w.rawValue;E&&u&&E!==g&&(g=E,r.current(E))}catch{}h=setTimeout(m,H8)}};return navigator.mediaDevices.getUserMedia({video:{facingMode:"environment"}}).then(w=>{if(!u){for(const b of w.getTracks())b.stop();return}return c=w,l.srcObject=w,l.play().then(m)}).catch(()=>{u&&o.current()}),()=>{if(u=!1,clearTimeout(h),c)for(const w of c.getTracks())w.stop()}},[]),f.jsx("video",{ref:n,className:"add-machine-camera",muted:!0,playsInline:!0})}function K8(){const e=at(),t=_o(),[n,r]=S.useState(""),[o,i]=S.useState({kind:"idle"}),[l,u]=S.useState(!0),c=H1(),h=()=>e({a:"close"}),p=async m=>{if(o.kind==="asking")return;const y=Nj(m);if(!y){i({kind:"failed",line:Gs.notALink});return}if(i({kind:"asking",origin:y.origin}),"token"in y){if(!await O2(y.origin)){i({kind:"failed",line:Pb("unreachable",y.origin)});return}const E=t.add({origin:y.origin,token:y.token});i({kind:"added",name:t.displayName(E.origin)});return}const w=await $2(y.origin,y.code);if(typeof w=="string"){i({kind:"failed",line:Pb(w,y.origin)});return}const b=t.add({origin:y.origin,token:w.token});i({kind:"added",name:t.displayName(b.origin)})},g=o.kind==="asking"?Gs.asking(o.origin):o.kind==="added"?Gs.added(o.name):o.kind==="failed"?o.line:l?Gs.lead:Gs.pasteOnly;return f.jsx(Tc,{bare:!0,boxClass:"add-machine-stack",onClose:h,children:f.jsxs("div",{className:"add-machine-card",children:[f.jsx("div",{className:"add-machine-title",children:Gs.title}),l&&o.kind!=="added"&&f.jsx("div",{className:"add-machine-frame",children:f.jsx(W8,{onRead:m=>void p(m),onUnavailable:()=>u(!1)})}),f.jsx("p",{className:Be("add-machine-line",o.kind==="failed"&&"add-machine-failed"),children:g}),o.kind!=="added"&&f.jsxs("form",{className:"add-machine-form",onSubmit:m=>{m.preventDefault(),p(n)},children:[f.jsx(vo,{ref:c,size:"md",font:"ui",value:n,placeholder:Gs.placeholder,"aria-label":"Link to the other machine",onChange:m=>r(m.target.value),className:"add-machine-field"}),f.jsx(Pe,{type:"submit",variant:"outline",busy:o.kind==="asking",disabled:!n.trim(),children:Gs.add})]}),f.jsx("div",{className:"add-machine-actions",children:f.jsx(Pe,{tone:"quiet",onClick:h,children:o.kind==="added"?"done":"cancel"})})]})})}function bk(e,{sock:t}){var r;const n=[];return e.canLogout&&((r=e.auth)==null?void 0:r.kind)!=="none"&&n.push({id:"logout",label:"log out",danger:!0,onClick:()=>t==null?void 0:t.send({t:"agent-logout",agent:e.id})}),!e.available&&!e.installing&&n.push({id:"install",label:e.onDemand&&e.reason==="not installed"?"install":"install again",onClick:()=>t==null?void 0:t.send({t:"install-agent",agent:e.id})}),n}function eN(e,t,n=!1){var o;const r=((o=t.find(i=>i.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 Z8=(e,t)=>{const n=Qp(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"}},Dd="https://github.com/toyon-dev/toyon",q8=e=>`${Dd}/releases/tag/v${e}`,G8=`${Dd}/releases/latest`,V8=4e3;function Y8(e,t,n,r){if(r==="asking")return{value:`${e} checking`,text:`Asking ${Qp(n)} for the newest version`,act:"check",busy:!0};const o=Qp(r.registry),i={act:"check",busy:!1};if(r.latest===null)return{...i,value:`${e} no answer`,text:`Could not reach ${o}. Press to ask again`,settles:!0};if(v2(r.latest,e)){const l=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{...i,value:`${r.latest} out`,text:`Toyon ${r.latest} is out. ${l}`}}return{...i,value:`${e} up to date`,text:`Toyon ${e} is the newest version ${o} lists. Press to ask again`,settles:!0}}function Q8(e,t,n,r,o,i=!1,l=null,u=null){if(n){if(n.restarting){const h=n.installed??n.running,p=n.restarting.length>0?jE(n.restarting):"Toyon is restarting; this page reloads when it is back";return{value:`${h} restarting`,text:p,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 c=eN(r,o,i);return c?c.busy?{value:`${e} rebuilding`,text:c.text,act:"rebuild",busy:!0}:c.reload?{value:`${e} rebuilt`,text:c.text,act:"reload",busy:!1}:c.build==="try again"?{value:`${e} rebuild stopped`,text:c.text,detail:c.detail,act:"rebuild",busy:!1}:{value:`${e} behind`,text:c.text,act:c.build?"rebuild":"restart",busy:!1}:u?Y8(e,t,l,u):{value:e,text:`Toyon ${e}, ${Z8(t,l)}`,act:"check",busy:!1}}function X8(e,t){const n=r=>()=>window.open(r,"_blank");return Mn([t?[{id:"check-update",label:"check for updates",...t.off?{disabled:t.off}:{},onClick:t.run}]:[],[{id:"release-notes",label:`release notes for ${e}`,onClick:n(q8(e))},{id:"latest-release",label:"latest release",onClick:n(G8)},{id:"repo",label:"Toyon on GitHub",onClick:n(Dd)},{id:"report",label:"report a problem",onClick:n(`${Dd}/issues/new`)}],[{id:"copy-version",label:"copy version",onClick:()=>Yt(e)}]])}const J8=mj.map(e=>({title:e,rows:yj(e).map(t=>[Tt(t),Wl[t].label])}));function e9(){const e=at(),t=st(),n=on("keys"),r=M(g=>g.themePrefs),o=M(g=>g.themes),i=M(g=>g.chatSide),l=M(g=>g.keepAwake),u=xg(),c=M(g=>g.agents),h=Va(),p=g=>{e({a:"palette-return",v:{mode:"keys",q:""}}),e(g)};return f.jsxs(Tc,{bare:!0,boxClass:"keys-stack",id:"keys-help",onClose:()=>e({a:"close"}),children:[f.jsxs("div",{className:"keys-card",children:[f.jsxs("div",{children:[h&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"section-title keys-h",children:h.name}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"processes"}),f.jsx(Pe,{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(()=>wf(h,h.id,{sock:t,dispatch:e})),children:f.jsx("span",{className:"keys-v",children:Object.keys(h.config.run).join(" + ")||"not set up"})})]})]}),f.jsx("div",{className:"section-title keys-h",children:"Agents"}),c.map(g=>f.jsx(r9,{agent:g},g.id))]}),f.jsxs("div",{children:[f.jsx("div",{className:"section-title keys-h",children:"Appearance"}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"mode"}),f.jsx(Pe,{variant:"field",mono:!0,onClick:()=>p({a:"open",overlay:{kind:"appearance"}}),children:Id[r.mode]})]}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"theme"}),f.jsx(Pe,{variant:"field",mono:!0,onClick:()=>p({a:"open",overlay:{kind:"theme",slot:"theme"}}),children:Xd(r,o,u).name})]}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"chat side"}),f.jsx(Pe,{variant:"field",mono:!0,onClick:()=>e({a:"toggle-chat-side"}),children:i})]}),f.jsx("div",{className:"section-title keys-h",children:"Toyon"}),l!==null&&f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"keep awake"}),f.jsx(Pe,{variant:"field",mono:!0,onClick:()=>p({a:"open",overlay:{kind:"keep-awake"}}),children:Rd[l]})]}),f.jsx(t9,{}),f.jsx(n9,{})]})]}),f.jsx("div",{className:"keys-card",children:J8.map(g=>f.jsxs("div",{children:[f.jsx("div",{className:"section-title keys-h",children:g.title}),g.rows.map(([m,y])=>f.jsxs("div",{className:"keys-row",children:[f.jsx(zo,{k:m}),f.jsx("span",{className:"keys-d",children:y})]},m))]},g.title))})]})}function t9(){const e=st(),t=at(),n=on("keys"),r=M(N=>N.version),o=M(N=>N.install),i=M(N=>N.registry),l=M(N=>N.update),u=M(N=>N.self),c=M(N=>N.rebuilt),h=M(N=>N.repos),p=M(N=>N.managed.updates),g=M(N=>N.updateCheck),m=Q8(r,o,l,u,h,c,i,g),y=!p&&(m.act==="update"||m.act==="check"),w=m.settles&&g&&g!=="asking"?g:null;S.useEffect(()=>{if(!w)return;const N=()=>t({a:"update-check-settle",check:w}),j=setTimeout(N,V8);return()=>{clearTimeout(j),N()}},[w,t]);const b=()=>{m.act==="restart"?e==null||e.send({t:"restart-daemon"}):m.act==="reload"?window.location.reload():m.act==="rebuild"&&u?e==null||e.send({t:"run-after-land",repoId:u.repoId}):m.act==="update"?e==null||e.send({t:"update-now"}):m.act==="check"&&e&&(t({a:"update-check"}),e.send({t:"check-update"}))},E=()=>X8(r,m.act==="check"&&!m.busy?{run:b,...y?{off:"managed by your organization"}:{}}:null);return f.jsxs("div",{className:"keys-setting",...n.contextMenu(E),children:[f.jsx("span",{className:"keys-d",children:"version"}),f.jsx(Pe,{variant:"field",mono:!0,busy:m.busy,disabled:y,onClick:b,...Ft(y?"updates are managed by your organization":m.text,void 0,{detail:m.detail}),children:m.value})]})}function n9(){const e=M(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: ${uO(e).join(", ")||"nothing turned off"}`;return f.jsx("div",{className:"hint",children:t})}function tN(e){return e.available?e.auth?e.auth.kind==="none"?"not logged in":e.auth.label:"ready":e.installing?"installing":"not installed"}function nN(e){var n,r;return e.available?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":e.reason??"not installed"}function r9({agent:e}){const t=at(),n=st(),r=on("keys");return f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:e.name}),f.jsx(Pe,{variant:"field",mono:!0,"data-tip":nN(e),...r.contextMenu(()=>bk(e,{sock:n})),onClick:()=>{t({a:"palette-return",v:{mode:"keys",q:""}}),t({a:"open",overlay:{kind:"agent-page",agent:e.id}})},children:tN(e)})]})}function o9({agentId:e}){const t=at(),n=st(),r=Va(),o=M(m=>m.home),i=M(m=>m.agents.find(y=>y.id===e)??null),l=M(m=>m.agentConfigs[e]??null),u=on("keys");if(S.useEffect(()=>{n==null||n.send({t:"agent-config",agent:e,...r?{repoId:r.id}:{}})},[n,e,r]),!i)return null;const c=bk(i,{sock:n}),h=()=>t({a:"close",back:!0}),p=m=>o&&m.startsWith(`${o}/`)?`~${m.slice(o.length)}`:m,g=m=>n==null?void 0:n.send({t:"reveal-agent-file",agent:e,file:m.id,...r?{repoId:r.id}:{}});return f.jsx(Tc,{bare:!0,boxClass:"keys-stack",onClose:h,children:f.jsxs("div",{className:"keys-card keys-settings",children:[f.jsx("div",{className:"agent-page-back",children:f.jsx(Lt,{icon:"back",label:"back to settings",hint:"esc",onClick:h})}),f.jsx("div",{className:"section-title keys-h",children:i.name}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"signed in"}),f.jsx(Pe,{variant:"field",mono:!0,"data-tip":nN(i),disabled:c.length===0,...u.dropdown(()=>c,"right"),children:tN(i)})]}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"commit messages"}),f.jsx("span",{className:"keys-d",children:i.quick?"its quick model writes one after each turn":"none: it has no quick model, so you write them in the changes panel; quickModel in agents.json names one"})]}),f.jsx("div",{className:"section-title keys-h",children:"MCP servers it will load"}),l===null?f.jsx("div",{className:"keys-setting",children:f.jsx("span",{className:"keys-d",children:"reading…"})}):l.servers.length===0?f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"none configured"}),f.jsx("span",{className:"keys-d",children:"add one with the agent's own CLI, or a .mcp.json in the repo"})]}):l.servers.map(m=>f.jsx(s9,{s:m},`${m.scope}:${m.name}`)),l&&l.files.length>0&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"section-title keys-h",children:"the files it reads"}),l.files.map(m=>f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:m.label}),m.exists?f.jsx(Pe,{variant:"field",mono:!0,"data-tip":`reveal ${p(m.path)} in Finder`,onClick:()=>g(m),children:p(m.path)}):f.jsxs("span",{className:"keys-d",children:["not present: ",p(m.path)]})]},m.id))]})]})})}function s9({s:e}){return f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{children:e.name}),f.jsx("span",{className:"keys-d",children:e.detail?`${e.scope} · ${e.detail}`:e.scope})]})}function i9(){const e=at(),t=st(),n=M(o=>o.agents),r=M(o=>o.defaultAgent);return f.jsx(Ir,{items:n,filter:(o,i)=>o.filter(l=>_s(i,l.name,l.id)),rowClass:o=>o.available?"picker-row":"picker-row dim",keyOf:o=>o.id,initialIndex:o=>Math.max(0,o.findIndex(i=>i.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=>bk(o,{sock:t}),placeholder:"default agent for new worktrees",keys:{pick:"sets",back:"closes"},row:o=>f.jsx(Un,{label:o.name,current:o.id===r,hint:o.available?o.sandboxed?void 0:"unsandboxed":o.reason??"not installed"})})}const a9=["dark","light","system","daylight"],l9=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"});function c9(){const e=at(),t=st(),n=M(c=>c.themePrefs),r=M(c=>c.themes),o=xg(),i=M(c=>c.daylight),l=c=>{var h;return((h=r.find(p=>p.id===n[ig({...n,mode:c},o)]))==null?void 0:h.name)??""},u=c=>{if(c==="system")return`${o.system?"dark":"light"} now · ${l(c)}`;if(c!=="daylight")return l(c);const h=i&&i.until>Date.now()?` · ${o.daylight?"light":"dark"} at ${l9.format(i.until)}`:"";return`${o.daylight?"dark":"light"} now${h} · ${l(c)}`};return f.jsx(Ir,{items:a9,filter:(c,h)=>c.filter(p=>_s(h,Id[p])),rowClass:()=>"picker-row",keyOf:c=>c,initialIndex:c=>c.indexOf(n.mode),onActive:c=>e({a:"preview-theme",theme:c?Xd({...n,mode:c},r,o):null}),onPick:c=>{t==null||t.send({t:"set-theme",prefs:{...n,mode:c}}),e({a:"close"})},onBack:()=>e({a:"close",back:!0}),placeholder:"light/dark mode",keys:{nav:"preview",pick:"keeps",back:"reverts"},row:c=>f.jsx(Un,{label:Id[c],current:c===n.mode,hint:u(c)})})}const u9=2,Mm=e=>t1(e).join(" ").length<u9,d9=e=>({kind:"chat",id:e.id,name:e.name,hint:e.branch??"",fields:[e.name,e.branch??""]}),f9=e=>({kind:"chat",id:e.id,name:e.title,hint:XE(e),fields:[e.title,e.branch],prompt:e.prompt,archived:e});function h9(e,t,n){const r=t1(t),o=n==="all"&&!Mm(t);return e.filter(i=>{if(i.kind==="hit")return o;const l=n==="names"&&i.prompt?[...i.fields,i.prompt]:i.fields;return r.every(u=>l.some(c=>c.toLowerCase().includes(u)))})}const p9=e=>e.flatMap(([t,n])=>Array.from({length:n},(r,o)=>t+o));function m9({repoId:e,scope:t}){const n=at(),r=st(),o=M(T=>T.clientId),i=M(T=>T.frame),l=M(T=>T.chats[e]),u=Ng(),c=M(T=>T.archived[e]),[h,p]=S.useState(t),g=S.useCallback(()=>p(T=>T==="all"?"names":"all"),[]);S.useEffect(()=>{r==null||r.send({t:"list-archived",repoId:e})},[r,e]);const m=S.useMemo(()=>[...u.filter(T=>!Ar(T.worktree)).map(d9),...(c??[]).map(f9)],[u,c]),y=S.useMemo(()=>new Map(m.map(T=>[T.id,T])),[m]),w=S.useMemo(()=>[...m,...((l==null?void 0:l.hits)??[]).map(T=>({kind:"hit",hit:T}))],[m,l]),b=S.useCallback((T,O)=>h9(T,O,h),[h]),E=S.useCallback(T=>{h==="all"&&!Mm(T)&&(r==null||r.send({t:"search-chats",repoId:e,query:T.trim()}))},[r,e,h]),N=T=>!l||l.query!==T.trim(),j=T=>h==="all"&&!Mm(T);return f.jsx(Ir,{items:w,filter:b,onQuery:E,onTab:g,trailing:f.jsx(Pe,{tone:"chrome",on:h==="names","aria-pressed":h==="names",onClick:g,children:"names only"}),keyOf:T=>T.kind==="hit"?`h:${T.hit.worktreeId}:${T.hit.seq}`:`w:${T.id}`,rowClass:T=>T.kind==="hit"?"chats-hit":Be("picker-row",T.archived&&!T.archived.restorable&&"dim"),rowTitle:T=>{var O;return T.kind==="hit"?T.hit.text:((O=T.archived)==null?void 0:O.prompt)??T.name},groupOf:T=>T.kind==="hit"?`h:${T.hit.worktreeId}`:T.archived?"archived":"open",groupHead:(T,O)=>{if(!T.startsWith("h:"))return`${T} · ${O}`;const U=y.get(T.slice(2));return f.jsxs("span",{children:[(U==null?void 0:U.name)??"a worktree",(U==null?void 0:U.archived)&&f.jsxs(f.Fragment,{children:[" ",f.jsx("span",{className:"row-dim",children:"archived"})]}),` · ${O}`]})},headAlone:!0,onPick:T=>{const O=T.kind==="hit"?T.hit.worktreeId:T.id,U=T.kind==="hit"?T.hit.archived:!!T.archived;n(U?{a:"open-archived",id:O}:{a:"activate",id:O}),T.kind==="hit"&&n({a:"reveal",id:O,seq:T.hit.seq}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:T=>T.kind==="chat"&&T.archived?od(T.archived,{clientId:o,frame:i},{sock:r,dispatch:n}):[],placeholder:h==="names"?"find a chat by name…":"search in chats…",keys:T=>({nav:"moves",tab:h==="names"?"searches messages too":"searches names only",pick:T?T.kind==="hit"?"opens the chat there":"opens its chat":void 0,back:"closes"}),empty:T=>T.trim()?j(T)?N(T)?"searching…":"no chat says that":"no chat is named that":c?"no chats yet":"looking…",footer:(T,O)=>{const U=O.filter(Q=>Q.kind==="hit").length;return l!=null&&l.truncated&&!N(T)&&U>0?f.jsxs("div",{className:"empty",children:["showing the first ",U,"; narrow the search"]}):null},row:T=>T.kind==="chat"?f.jsx(Un,{label:T.name,hint:T.hint}):f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"chats-text",children:dc(T.hit.text,p9(T.hit.match),0)}),f.jsxs("span",{className:"chats-said row-dim",children:[T.hit.role==="user"?"you":"the agent",T.hit.ts>0?` · ${ao(T.hit.ts)}`:""]})]})})}function g9({worktreeId:e,hits:t}){const n=at(),r=st(),o=M(u=>u.layout.changes),i=M(u=>{var h;const c=(h=rn(u,e))==null?void 0:h.worktree;return c?c.path:null}),l=S.useCallback((u,c)=>{const h=c.trim().toLowerCase();return h?u.filter(p=>`${p.path}:${p.line} ${p.text}`.toLowerCase().includes(h)):u},[]);return f.jsx(Ir,{items:t,filter:l,keyOf:u=>`${u.path}:${u.line}`,rowClass:()=>"search-hit",rowTitle:u=>`${u.path}:${u.line}`,onPick:u=>{nr({dispatch:n},{worktreeId:e,path:u.path,view:"file",line:{n:u.line}}),o||n({a:"toggle-changes"}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:u=>i?vs({id:e,dir:i},u.path,{},{sock:r,dispatch:n}):[],placeholder:"lines that could write this element",keys:{pick:"opens the file",back:"closes"},row:u=>f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"search-loc",children:[u.path,":",u.line]}),f.jsx("span",{className:"search-text",children:u.text})]})})}const bf=e=>/^(~|\/|\.\.?\/)/.test(e.trim());function rN(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 k9(e,t,n){const r=e.map(h=>h.path.slice(0,h.path.lastIndexOf("/"))).filter(Boolean),o=e.find(h=>h.id===t),i=o==null?void 0:o.path.slice(0,o.path.lastIndexOf("/")),l=new Map;for(const h of r)l.set(h,(l.get(h)??0)+1);let u="",c=0;for(const[h,p]of[...l].sort(([g],[m])=>g.localeCompare(m)))(p>c||p===c&&h===i)&&(u=h,c=p);return u?oN(u,n):`~/${Jx}`}function oN(e,t){return t&&(e===t||e.startsWith(`${t}/`))?`~${e.slice(t.length)}`:e}function sN(e,t){return`${e.replace(/\/+$/,"")}/${t.trim()}`}function y9(e){const t=e.query.trim(),n=()=>e.entries.map(l=>({kind:"dir",entry:l}));if(!bf(t)){const l=e.repos.filter(m=>_s(t,m.name,m.path)).map(m=>({kind:"repo",repo:m})),u=e.pending.filter(m=>_s(t,m.name,m.url)).map(m=>({kind:"pending",pending:m})),c=[...l,...u],h=(e.others??[]).flatMap(m=>m.repos.filter(y=>_s(t,y.name,y.path,m.name)).map(y=>({kind:"repo",repo:y,machine:m})));if(!t)return[...c,{kind:"new"},{kind:"disk"},{kind:"add-machine"},...h];const p=NO(t);if(p)return c.length>0?c:[{kind:"clone",url:p.url,name:p.name}];const g=m=>m.toLowerCase()===t.toLowerCase();return e.repos.some(m=>g(m.name))||e.pending.some(m=>g(m.name))?[...c,...h]:oc(t)?[...c,...h]:[...c,{kind:"create",name:t,parent:null},...h]}if(e.answered.trim()!==t||!e.target)return n();const{target:r}=e;if(t.endsWith("/"))return n();if(r.exists)return r.isRepo?[...n(),{kind:"open",path:t}]:n();if(!r.parentExists)return[];const{parent:o,name:i}=rN(t);return oc(i)?n():[...n(),{kind:"create",name:i,parent:o}]}function fc(e,t){return t&&(e==="~"||e.startsWith("~/"))?`${t}${e.slice(1)}`:e}function iN(e,t){const n=fc(e,t).replace(/\/+$/,"");return n.startsWith("/")?oN(n.slice(0,n.lastIndexOf("/"))||"/",t):null}function Lm(e,t){const n=fc(e,t).replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||"/"}function w9(e){const t=e.query.trim(),n=t.lastIndexOf("/"),r=n<0?"":t.slice(0,n)||"/",o=fc(r,e.home);if(!bf(t)||!o.startsWith("/"))return[];const i=t.slice(n+1).toLowerCase(),l=e.answered.trim()===t?e.target:null,u=!l||(i?l.parentExists:l.exists&&l.isDir&&!l.isRepo),c=e.entries.filter(p=>{if(p.isRepo)return!1;const g=fc(p.path,e.home);return(g.slice(0,g.lastIndexOf("/"))||"/")===o&&p.name.toLowerCase().startsWith(i)}),h=iN(r,e.home);return[...u?[{kind:"here",path:r}]:[],...h?[{kind:"up",path:h}]:[],...c.map(p=>({kind:"dir",entry:p}))]}function v9({project:e}){const t=at(),n=st(),r=M(h=>h.paths),o=M(h=>h.home),i=S.useCallback(h=>{bf(h)&&(n==null||n.send({t:"browse-path",path:h}))},[n]),l=S.useCallback((h,p)=>w9({query:p,entries:r.entries,target:r.target,answered:r.query,home:o}),[r,o]),u=oc(e.name)?null:e.name.trim(),c=h=>`${h.replace(/\/+$/,"")}/`;return f.jsx(Ir,{initialQuery:c(e.parent),lead:f.jsx("span",{className:"picker-chip",children:u??"new project"}),items:[],filter:l,keyOf:h=>h.kind==="dir"?`d:${h.entry.path}`:`${h.kind}:${h.path}`,rowClass:()=>"picker-row folder-row",onQuery:i,completionOf:h=>h.kind==="dir"?c(h.entry.path):null,narrowTo:h=>h.kind==="dir"?c(h.entry.path):h.kind==="up"?c(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"?f.jsx(Un,{label:`put ${u??"it"} in ${Lm(h.path,o)}`,hint:f.jsx("bdi",{children:u?sN(h.path,u):h.path})}):h.kind==="up"?f.jsx(Un,{label:`up to ${Lm(h.path,o)}`,hint:f.jsx("bdi",{children:h.path})}):f.jsx(Un,{label:h.entry.name})})}function b9({worktreeId:e}){const t=at(),n=st(),r=M(g=>g.clientId),o=M(g=>rn(g,e)),i=M(g=>g.repos),u=At(e,"draft").trim(),c=S.useMemo(()=>i.filter(g=>g.id!==(o==null?void 0:o.worktree.repoId)),[i,o]),h=()=>t({a:"close"}),p=g=>{if(!o)return h();n==null||n.send({t:"handoff-ask",worktreeId:e,repoId:g.id,...u?{text:u}:{}}),u&&(n==null||n.send({t:"set-draft",boxId:e,text:"",clientId:r}),t({a:"set-draft",id:e,text:""})),h()};return f.jsx(Ir,{lead:f.jsx("span",{className:"picker-chip",children:(o==null?void 0:o.worktree.title)??"worktree"}),items:c,filter:(g,m)=>g.filter(y=>_s(m,y.name,y.path)),keyOf:g=>g.id,row:g=>f.jsx(Un,{label:g.name,hint:g.path}),onPick:p,onBack:()=>t({a:"close",back:!0}),placeholder:"continue in which project?",empty:"no other project is open",keys:{pick:"continues there",back:"closes"},footer:u?()=>f.jsxs("div",{className:"empty",children:["with your message: ",u.split(`
|
|
248
|
+
`)[0]]}):void 0})}const x9={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 E9(){const e=at(),t=st(),n=M(r=>r.keepAwake);return f.jsx(Ir,{items:[...XT],filter:(r,o)=>r.filter(i=>_s(o,Rd[i])),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",keys:{pick:"sets",back:"closes"},row:r=>f.jsx(Un,{label:Rd[r],current:r===n,hint:x9[r]})})}const Qa=function(e,t){let o=e;const i=Hl[t];let l=null,u=0,c=null;const h=[],p={},g=function(R,I){u=o*4+17,l=(function(_){const L=new Array(_);for(let z=0;z<_;z+=1){L[z]=new Array(_);for(let F=0;F<_;F+=1)L[z][F]=null}return L})(u),m(0,0),m(u-7,0),m(0,u-7),b(),w(),N(R,I),o>=7&&E(R),c==null&&(c=O(o,i,h)),j(c,I)},m=function(R,I){for(let _=-1;_<=7;_+=1)if(!(R+_<=-1||u<=R+_))for(let L=-1;L<=7;L+=1)I+L<=-1||u<=I+L||(0<=_&&_<=6&&(L==0||L==6)||0<=L&&L<=6&&(_==0||_==6)||2<=_&&_<=4&&2<=L&&L<=4?l[R+_][I+L]=!0:l[R+_][I+L]=!1)},y=function(){let R=0,I=0;for(let _=0;_<8;_+=1){g(!0,_);const L=Ys.getLostPoint(p);(_==0||R>L)&&(R=L,I=_)}return I},w=function(){for(let R=8;R<u-8;R+=1)l[R][6]==null&&(l[R][6]=R%2==0);for(let R=8;R<u-8;R+=1)l[6][R]==null&&(l[6][R]=R%2==0)},b=function(){const R=Ys.getPatternPosition(o);for(let I=0;I<R.length;I+=1)for(let _=0;_<R.length;_+=1){const L=R[I],z=R[_];if(l[L][z]==null)for(let F=-2;F<=2;F+=1)for(let ee=-2;ee<=2;ee+=1)F==-2||F==2||ee==-2||ee==2||F==0&&ee==0?l[L+F][z+ee]=!0:l[L+F][z+ee]=!1}},E=function(R){const I=Ys.getBCHTypeNumber(o);for(let _=0;_<18;_+=1){const L=!R&&(I>>_&1)==1;l[Math.floor(_/3)][_%3+u-8-3]=L}for(let _=0;_<18;_+=1){const L=!R&&(I>>_&1)==1;l[_%3+u-8-3][Math.floor(_/3)]=L}},N=function(R,I){const _=i<<3|I,L=Ys.getBCHTypeInfo(_);for(let z=0;z<15;z+=1){const F=!R&&(L>>z&1)==1;z<6?l[z][8]=F:z<8?l[z+1][8]=F:l[u-15+z][8]=F}for(let z=0;z<15;z+=1){const F=!R&&(L>>z&1)==1;z<8?l[8][u-z-1]=F:z<9?l[8][15-z-1+1]=F:l[8][15-z-1]=F}l[u-8][8]=!R},j=function(R,I){let _=-1,L=u-1,z=7,F=0;const ee=Ys.getMaskFunction(I);for(let se=u-1;se>0;se-=2)for(se==6&&(se-=1);;){for(let fe=0;fe<2;fe+=1)if(l[L][se-fe]==null){let ke=!1;F<R.length&&(ke=(R[F]>>>z&1)==1),ee(L,se-fe)&&(ke=!ke),l[L][se-fe]=ke,z-=1,z==-1&&(F+=1,z=7)}if(L+=_,L<0||u<=L){L-=_,_=-_;break}}},T=function(R,I){let _=0,L=0,z=0;const F=new Array(I.length),ee=new Array(I.length);for(let ne=0;ne<I.length;ne+=1){const A=I[ne].dataCount,q=I[ne].totalCount-A;L=Math.max(L,A),z=Math.max(z,q),F[ne]=new Array(A);for(let xe=0;xe<F[ne].length;xe+=1)F[ne][xe]=255&R.getBuffer()[xe+_];_+=A;const ie=Ys.getErrorCorrectPolynomial(q),W=hc(F[ne],ie.getLength()-1).mod(ie);ee[ne]=new Array(ie.getLength()-1);for(let xe=0;xe<ee[ne].length;xe+=1){const ce=xe+W.getLength()-ee[ne].length;ee[ne][xe]=ce>=0?W.getAt(ce):0}}let se=0;for(let ne=0;ne<I.length;ne+=1)se+=I[ne].totalCount;const fe=new Array(se);let ke=0;for(let ne=0;ne<L;ne+=1)for(let A=0;A<I.length;A+=1)ne<F[A].length&&(fe[ke]=F[A][ne],ke+=1);for(let ne=0;ne<z;ne+=1)for(let A=0;A<I.length;A+=1)ne<ee[A].length&&(fe[ke]=ee[A][ne],ke+=1);return fe},O=function(R,I,_){const L=Db.getRSBlocks(R,I),z=zb();for(let ee=0;ee<_.length;ee+=1){const se=_[ee];z.put(se.getMode(),4),z.put(se.getLength(),Ys.getLengthInBits(se.getMode(),R)),se.write(z)}let F=0;for(let ee=0;ee<L.length;ee+=1)F+=L[ee].dataCount;if(z.getLengthInBits()>F*8)throw"code length overflow. ("+z.getLengthInBits()+">"+F*8+")";for(z.getLengthInBits()+4<=F*8&&z.put(0,4);z.getLengthInBits()%8!=0;)z.putBit(!1);for(;!(z.getLengthInBits()>=F*8||(z.put(236,8),z.getLengthInBits()>=F*8));)z.put(17,8);return T(z,L)};p.addData=function(R,I){I=I||"Byte";let _=null;switch(I){case"Numeric":_=_9(R);break;case"Alphanumeric":_=S9(R);break;case"Byte":_=N9(R);break;case"Kanji":_=T9(R);break;default:throw"mode:"+I}h.push(_),c=null},p.isDark=function(R,I){if(R<0||u<=R||I<0||u<=I)throw R+","+I;return l[R][I]},p.getModuleCount=function(){return u},p.make=function(){if(o<1){let R=1;for(;R<40;R++){const I=Db.getRSBlocks(R,i),_=zb();for(let z=0;z<h.length;z++){const F=h[z];_.put(F.getMode(),4),_.put(F.getLength(),Ys.getLengthInBits(F.getMode(),R)),F.write(_)}let L=0;for(let z=0;z<I.length;z++)L+=I[z].dataCount;if(_.getLengthInBits()<=L*8)break}o=R}g(!1,y())},p.createTableTag=function(R,I){R=R||2,I=typeof I>"u"?R*4:I;let _="";_+='<table style="',_+=" border-width: 0px; border-style: none;",_+=" border-collapse: collapse;",_+=" padding: 0px; margin: "+I+"px;",_+='">',_+="<tbody>";for(let L=0;L<p.getModuleCount();L+=1){_+="<tr>";for(let z=0;z<p.getModuleCount();z+=1)_+='<td style="',_+=" border-width: 0px; border-style: none;",_+=" border-collapse: collapse;",_+=" padding: 0px; margin: 0px;",_+=" width: "+R+"px;",_+=" height: "+R+"px;",_+=" background-color: ",_+=p.isDark(L,z)?"#000000":"#ffffff",_+=";",_+='"/>';_+="</tr>"}return _+="</tbody>",_+="</table>",_},p.createSvgTag=function(R,I,_,L){let z={};typeof arguments[0]=="object"&&(z=arguments[0],R=z.cellSize,I=z.margin,_=z.alt,L=z.title),R=R||2,I=typeof I>"u"?R*4:I,_=typeof _=="string"?{text:_}:_||{},_.text=_.text||null,_.id=_.text?_.id||"qrcode-description":null,L=typeof L=="string"?{text:L}:L||{},L.text=L.text||null,L.id=L.text?L.id||"qrcode-title":null;const F=p.getModuleCount()*R+I*2;let ee,se,fe,ke,ne="",A;for(A="l"+R+",0 0,"+R+" -"+R+",0 0,-"+R+"z ",ne+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',ne+=z.scalable?"":' width="'+F+'px" height="'+F+'px"',ne+=' viewBox="0 0 '+F+" "+F+'" ',ne+=' preserveAspectRatio="xMinYMin meet"',ne+=L.text||_.text?' role="img" aria-labelledby="'+U([L.id,_.id].join(" ").trim())+'"':"",ne+=">",ne+=L.text?'<title id="'+U(L.id)+'">'+U(L.text)+"</title>":"",ne+=_.text?'<description id="'+U(_.id)+'">'+U(_.text)+"</description>":"",ne+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',ne+='<path d="',fe=0;fe<p.getModuleCount();fe+=1)for(ke=fe*R+I,ee=0;ee<p.getModuleCount();ee+=1)p.isDark(fe,ee)&&(se=ee*R+I,ne+="M"+se+","+ke+A);return ne+='" stroke="transparent" fill="black"/>',ne+="</svg>",ne},p.createDataURL=function(R,I){R=R||2,I=typeof I>"u"?R*4:I;const _=p.getModuleCount()*R+I*2,L=I,z=_-I;return I9(_,_,function(F,ee){if(L<=F&&F<z&&L<=ee&&ee<z){const se=Math.floor((F-L)/R),fe=Math.floor((ee-L)/R);return p.isDark(fe,se)?0:1}else return 1})},p.createImgTag=function(R,I,_){R=R||2,I=typeof I>"u"?R*4:I;const L=p.getModuleCount()*R+I*2;let z="";return z+="<img",z+=' src="',z+=p.createDataURL(R,I),z+='"',z+=' width="',z+=L,z+='"',z+=' height="',z+=L,z+='"',_&&(z+=' alt="',z+=U(_),z+='"'),z+="/>",z};const U=function(R){let I="";for(let _=0;_<R.length;_+=1){const L=R.charAt(_);switch(L){case"<":I+="<";break;case">":I+=">";break;case"&":I+="&";break;case'"':I+=""";break;default:I+=L;break}}return I},Q=function(R){R=typeof R>"u"?2:R;const _=p.getModuleCount()*1+R*2,L=R,z=_-R;let F,ee,se,fe,ke;const ne={"██":"█","█ ":"▀"," █":"▄"," ":" "},A={"██":"▀","█ ":"▀"," █":" "," ":" "};let q="";for(F=0;F<_;F+=2){for(se=Math.floor((F-L)/1),fe=Math.floor((F+1-L)/1),ee=0;ee<_;ee+=1)ke="█",L<=ee&&ee<z&&L<=F&&F<z&&p.isDark(se,Math.floor((ee-L)/1))&&(ke=" "),L<=ee&&ee<z&&L<=F+1&&F+1<z&&p.isDark(fe,Math.floor((ee-L)/1))?ke+=" ":ke+="█",q+=R<1&&F+1>=z?A[ke]:ne[ke];q+=`
|
|
249
|
+
`}return _%2&&R>0?q.substring(0,q.length-_-1)+Array(_+1).join("▀"):q.substring(0,q.length-1)};return p.createASCII=function(R,I){if(R=R||1,R<2)return Q(I);R-=1,I=typeof I>"u"?R*2:I;const _=p.getModuleCount()*R+I*2,L=I,z=_-I;let F,ee,se,fe;const ke=Array(R+1).join("██"),ne=Array(R+1).join(" ");let A="",q="";for(F=0;F<_;F+=1){for(se=Math.floor((F-L)/R),q="",ee=0;ee<_;ee+=1)fe=1,L<=ee&&ee<z&&L<=F&&F<z&&p.isDark(se,Math.floor((ee-L)/R))&&(fe=0),q+=fe?ke:ne;for(se=0;se<R;se+=1)A+=q+`
|
|
250
|
+
`}return A.substring(0,A.length-1)},p.renderTo2dContext=function(R,I){I=I||2;const _=p.getModuleCount();for(let L=0;L<_;L++)for(let z=0;z<_;z++)R.fillStyle=p.isDark(L,z)?"black":"white",R.fillRect(z*I,L*I,I,I)},p};Qa.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};Qa.createStringToBytes=function(e,t){const n=(function(){const o=C9(e),i=function(){const c=o.read();if(c==-1)throw"eof";return c};let l=0;const u={};for(;;){const c=o.read();if(c==-1)break;const h=i(),p=i(),g=i(),m=String.fromCharCode(c<<8|h),y=p<<8|g;u[m]=y,l+=1}if(l!=t)throw l+" != "+t;return u})(),r=63;return function(o){const i=[];for(let l=0;l<o.length;l+=1){const u=o.charCodeAt(l);if(u<128)i.push(u);else{const c=n[o.charAt(l)];typeof c=="number"?(c&255)==c?i.push(c):(i.push(c>>>8),i.push(c&255)):i.push(r)}}return i}};const jr={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},Hl={L:1,M:0,Q:3,H:2},Vs={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},Ys=(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={},i=function(l){let u=0;for(;l!=0;)u+=1,l>>>=1;return u};return o.getBCHTypeInfo=function(l){let u=l<<10;for(;i(u)-i(t)>=0;)u^=t<<i(u)-i(t);return(l<<10|u)^r},o.getBCHTypeNumber=function(l){let u=l<<12;for(;i(u)-i(n)>=0;)u^=n<<i(u)-i(n);return l<<12|u},o.getPatternPosition=function(l){return e[l-1]},o.getMaskFunction=function(l){switch(l){case Vs.PATTERN000:return function(u,c){return(u+c)%2==0};case Vs.PATTERN001:return function(u,c){return u%2==0};case Vs.PATTERN010:return function(u,c){return c%3==0};case Vs.PATTERN011:return function(u,c){return(u+c)%3==0};case Vs.PATTERN100:return function(u,c){return(Math.floor(u/2)+Math.floor(c/3))%2==0};case Vs.PATTERN101:return function(u,c){return u*c%2+u*c%3==0};case Vs.PATTERN110:return function(u,c){return(u*c%2+u*c%3)%2==0};case Vs.PATTERN111:return function(u,c){return(u*c%3+(u+c)%2)%2==0};default:throw"bad maskPattern:"+l}},o.getErrorCorrectPolynomial=function(l){let u=hc([1],0);for(let c=0;c<l;c+=1)u=u.multiply(hc([1,Xs.gexp(c)],0));return u},o.getLengthInBits=function(l,u){if(1<=u&&u<10)switch(l){case jr.MODE_NUMBER:return 10;case jr.MODE_ALPHA_NUM:return 9;case jr.MODE_8BIT_BYTE:return 8;case jr.MODE_KANJI:return 8;default:throw"mode:"+l}else if(u<27)switch(l){case jr.MODE_NUMBER:return 12;case jr.MODE_ALPHA_NUM:return 11;case jr.MODE_8BIT_BYTE:return 16;case jr.MODE_KANJI:return 10;default:throw"mode:"+l}else if(u<41)switch(l){case jr.MODE_NUMBER:return 14;case jr.MODE_ALPHA_NUM:return 13;case jr.MODE_8BIT_BYTE:return 16;case jr.MODE_KANJI:return 12;default:throw"mode:"+l}else throw"type:"+u},o.getLostPoint=function(l){const u=l.getModuleCount();let c=0;for(let g=0;g<u;g+=1)for(let m=0;m<u;m+=1){let y=0;const w=l.isDark(g,m);for(let b=-1;b<=1;b+=1)if(!(g+b<0||u<=g+b))for(let E=-1;E<=1;E+=1)m+E<0||u<=m+E||b==0&&E==0||w==l.isDark(g+b,m+E)&&(y+=1);y>5&&(c+=3+y-5)}for(let g=0;g<u-1;g+=1)for(let m=0;m<u-1;m+=1){let y=0;l.isDark(g,m)&&(y+=1),l.isDark(g+1,m)&&(y+=1),l.isDark(g,m+1)&&(y+=1),l.isDark(g+1,m+1)&&(y+=1),(y==0||y==4)&&(c+=3)}for(let g=0;g<u;g+=1)for(let m=0;m<u-6;m+=1)l.isDark(g,m)&&!l.isDark(g,m+1)&&l.isDark(g,m+2)&&l.isDark(g,m+3)&&l.isDark(g,m+4)&&!l.isDark(g,m+5)&&l.isDark(g,m+6)&&(c+=40);for(let g=0;g<u;g+=1)for(let m=0;m<u-6;m+=1)l.isDark(m,g)&&!l.isDark(m+1,g)&&l.isDark(m+2,g)&&l.isDark(m+3,g)&&l.isDark(m+4,g)&&!l.isDark(m+5,g)&&l.isDark(m+6,g)&&(c+=40);let h=0;for(let g=0;g<u;g+=1)for(let m=0;m<u;m+=1)l.isDark(m,g)&&(h+=1);const p=Math.abs(100*h/u/u-50)/5;return c+=p*10,c},o})(),Xs=(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})(),hc=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 i=new Array(e.length-o+t);for(let l=0;l<e.length-o;l+=1)i[l]=e[l+o];return i})(),r={};return r.getAt=function(o){return n[o]},r.getLength=function(){return n.length},r.multiply=function(o){const i=new Array(r.getLength()+o.getLength()-1);for(let l=0;l<r.getLength();l+=1)for(let u=0;u<o.getLength();u+=1)i[l+u]^=Xs.gexp(Xs.glog(r.getAt(l))+Xs.glog(o.getAt(u)));return hc(i,0)},r.mod=function(o){if(r.getLength()-o.getLength()<0)return r;const i=Xs.glog(r.getAt(0))-Xs.glog(o.getAt(0)),l=new Array(r.getLength());for(let u=0;u<r.getLength();u+=1)l[u]=r.getAt(u);for(let u=0;u<o.getLength();u+=1)l[u]^=Xs.gexp(Xs.glog(o.getAt(u))+i);return hc(l,0).mod(o)},r},Db=(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,i){const l={};return l.totalCount=o,l.dataCount=i,l},n={},r=function(o,i){switch(i){case Hl.L:return e[(o-1)*4+0];case Hl.M:return e[(o-1)*4+1];case Hl.Q:return e[(o-1)*4+2];case Hl.H:return e[(o-1)*4+3];default:return}};return n.getRSBlocks=function(o,i){const l=r(o,i);if(typeof l>"u")throw"bad rs block @ typeNumber:"+o+"/errorCorrectionLevel:"+i;const u=l.length/3,c=[];for(let h=0;h<u;h+=1){const p=l[h*3+0],g=l[h*3+1],m=l[h*3+2];for(let y=0;y<p;y+=1)c.push(t(g,m))}return c},n})(),zb=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 i=0;i<o;i+=1)n.putBit((r>>>o-i-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},_9=function(e){const t=jr.MODE_NUMBER,n=e,r={};r.getMode=function(){return t},r.getLength=function(l){return n.length},r.write=function(l){const u=n;let c=0;for(;c+2<u.length;)l.put(o(u.substring(c,c+3)),10),c+=3;c<u.length&&(u.length-c==1?l.put(o(u.substring(c,c+1)),4):u.length-c==2&&l.put(o(u.substring(c,c+2)),7))};const o=function(l){let u=0;for(let c=0;c<l.length;c+=1)u=u*10+i(l.charAt(c));return u},i=function(l){if("0"<=l&&l<="9")return l.charCodeAt(0)-48;throw"illegal char :"+l};return r},S9=function(e){const t=jr.MODE_ALPHA_NUM,n=e,r={};r.getMode=function(){return t},r.getLength=function(i){return n.length},r.write=function(i){const l=n;let u=0;for(;u+1<l.length;)i.put(o(l.charAt(u))*45+o(l.charAt(u+1)),11),u+=2;u<l.length&&i.put(o(l.charAt(u)),6)};const o=function(i){if("0"<=i&&i<="9")return i.charCodeAt(0)-48;if("A"<=i&&i<="Z")return i.charCodeAt(0)-65+10;switch(i){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 :"+i}};return r},N9=function(e){const t=jr.MODE_8BIT_BYTE,n=Qa.stringToBytes(e),r={};return r.getMode=function(){return t},r.getLength=function(o){return n.length},r.write=function(o){for(let i=0;i<n.length;i+=1)o.put(n[i],8)},r},T9=function(e){const t=jr.MODE_KANJI,n=Qa.stringToBytes;(function(i,l){const u=n(i);if(u.length!=2||(u[0]<<8|u[1])!=l)throw"sjis not supported."})("友",38726);const r=n(e),o={};return o.getMode=function(){return t},o.getLength=function(i){return~~(r.length/2)},o.write=function(i){const l=r;let u=0;for(;u+1<l.length;){let c=(255&l[u])<<8|255&l[u+1];if(33088<=c&&c<=40956)c-=33088;else if(57408<=c&&c<=60351)c-=49472;else throw"illegal char at "+(u+1)+"/"+c;c=(c>>>8&255)*192+(c&255),i.put(c,13),u+=2}if(u<l.length)throw"illegal char at "+(u+1)},o},aN=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 i=0;i<o;i+=1)t.writeByte(n[i+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},j9=function(){let e=0,t=0,n=0,r="";const o={},i=function(u){r+=String.fromCharCode(l(u&63))},l=function(u){if(u<0)throw"n:"+u;if(u<26)return 65+u;if(u<52)return 97+(u-26);if(u<62)return 48+(u-52);if(u==62)return 43;if(u==63)return 47;throw"n:"+u};return o.writeByte=function(u){for(e=e<<8|u&255,t+=8,n+=1;t>=6;)i(e>>>t-6),t-=6},o.flush=function(){if(t>0&&(i(e<<6-t),e=0,t=0),n%3!=0){const u=3-n%3;for(let c=0;c<u;c+=1)r+="="}},o.toString=function(){return r},o},C9=function(e){const t=e;let n=0,r=0,o=0;const i={};i.read=function(){for(;o<8;){if(n>=t.length){if(o==0)return-1;throw"unexpected end of file./"+o}const c=t.charAt(n);if(n+=1,c=="=")return o=0,-1;if(c.match(/^\s$/))continue;r=r<<6|l(c.charCodeAt(0)),o+=6}const u=r>>>o-8&255;return o-=8,u};const l=function(u){if(65<=u&&u<=90)return u-65;if(97<=u&&u<=122)return u-97+26;if(48<=u&&u<=57)return u-48+52;if(u==43)return 62;if(u==47)return 63;throw"c:"+u};return i},A9=function(e,t){const n=e,r=t,o=new Array(e*t),i={};i.setPixel=function(h,p,g){o[p*n+h]=g},i.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 p=2,g=u(p);h.writeByte(p);let m=0;for(;g.length-m>255;)h.writeByte(255),h.writeBytes(g,m,255),m+=255;h.writeByte(g.length-m),h.writeBytes(g,m,g.length-m),h.writeByte(0),h.writeString(";")};const l=function(h){const p=h;let g=0,m=0;const y={};return y.write=function(w,b){if(w>>>b)throw"length over";for(;g+b>=8;)p.writeByte(255&(w<<g|m)),b-=8-g,w>>>=8-g,m=0,g=0;m=w<<g|m,g=g+b},y.flush=function(){g>0&&p.writeByte(m)},y},u=function(h){const p=1<<h,g=(1<<h)+1;let m=h+1;const y=c();for(let j=0;j<p;j+=1)y.add(String.fromCharCode(j));y.add(String.fromCharCode(p)),y.add(String.fromCharCode(g));const w=aN(),b=l(w);b.write(p,m);let E=0,N=String.fromCharCode(o[E]);for(E+=1;E<o.length;){const j=String.fromCharCode(o[E]);E+=1,y.contains(N+j)?N=N+j:(b.write(y.indexOf(N),m),y.size()<4095&&(y.size()==1<<m&&(m+=1),y.add(N+j)),N=j)}return b.write(y.indexOf(N),m),b.write(g,m),b.flush(),w.toByteArray()},c=function(){const h={};let p=0;const g={};return g.add=function(m){if(g.contains(m))throw"dup key:"+m;h[m]=p,p+=1},g.size=function(){return p},g.indexOf=function(m){return h[m]},g.contains=function(m){return typeof h[m]<"u"},g};return i},I9=function(e,t,n){const r=A9(e,t);for(let u=0;u<t;u+=1)for(let c=0;c<e;c+=1)r.setPixel(c,u,n(c,u));const o=aN();r.write(o);const i=j9(),l=o.toByteArray();for(let u=0;u<l.length;u+=1)i.writeByte(l[u]);return i.flush(),"data:image/gif;base64,"+i};Qa.stringToBytes;function R9(e){const t=Qa(0,"M");t.addData(e,"Byte"),t.make();const n=t.getModuleCount();return Array.from({length:n},(r,o)=>Array.from({length:n},(i,l)=>t.isDark(o,l)))}const Mp=4;function $9({text:e,spent:t}){const{size:n,d:r}=S.useMemo(()=>{const o=R9(e);let i="";return o.forEach((l,u)=>{l.forEach((c,h)=>{c&&(i+=`M${h+Mp} ${u+Mp}h1v1h-1z`)})}),{size:o.length+Mp*2,d:i}},[e]);return f.jsx("svg",{className:Be("pair-qr",t&&"pair-qr-spent"),viewBox:`0 0 ${n} ${n}`,shapeRendering:"crispEdges",role:"img","aria-label":"Pairing code",children:f.jsx("path",{d:r})})}function O9(e){const[t,n]=S.useState(0);return S.useEffect(()=>{if(!e)return;const r=performance.now()+e.ms,o=()=>n(Math.max(0,Math.ceil((r-performance.now())/1e3)));o();const i=setInterval(o,250);return()=>clearInterval(i)},[e]),t}const M9=3e3;function L9(e,t,n){const[r,o]=S.useState(),i=t!==null&&Tj(t);return S.useEffect(()=>{if(!i||!n)return;let l=!0,u;const c=()=>void I2(e).then(h=>{l&&(o(h),u=setTimeout(c,M9))});return c(),()=>{l=!1,clearTimeout(u)}},[i,n,e]),i?r:void 0}function P9(){const e=at(),t=Lr(),n=M(N=>{var j;return((j=N.remote)==null?void 0:j.host)??null}),r=M(N=>N.pairings),[o,i]=S.useState(null),[l,u]=S.useState(null),[c,h]=S.useState(0),p=S.useRef(r),g=O9(o);yt([c],()=>{let N=!0;return i(null),u(null),R2(t).then(j=>{N&&(p.current=r,typeof j=="string"?u(j):i(j))}),()=>{N=!1}});const m=o!==null&&r>p.current,y=o!==null&&g===0,w=()=>e({a:"close"}),b=L9(t,n,!m&&!l),E=b===void 0?null:jj(b);return f.jsx(Tc,{bare:!0,boxClass:"pair-stack",onClose:w,children:f.jsxs("div",{className:"pair-card",children:[f.jsx("div",{className:"pair-title",children:"Open on your phone"}),m?f.jsx("p",{className:"pair-line",children:"Paired. Your phone lists this machine on toyon.cloud now."}):l?f.jsx("p",{className:"pair-line",children:l}):f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"pair-frame",children:o&&f.jsx($9,{text:o.url,spent:y})}),n&&f.jsx("div",{className:"hint pair-host",children:n}),f.jsx("p",{className:"pair-line",children:o?y?"This code has expired.":f.jsxs(f.Fragment,{children:["Scan from Toyon on your phone to add this machine there, or with your phone's camera to install it as a new app. The code works once; ",f.jsx("span",{className:"pair-left",children:g})," seconds left."]}):"Making a code."}),E&&f.jsx("p",{className:Be("pair-note",E.ok&&"hint"),children:E.text})]}),f.jsxs("div",{className:"pair-actions",children:[(y||l)&&!m&&f.jsx(Pe,{variant:"outline",onClick:()=>h(N=>N+1),children:"new code"}),f.jsx(Pe,{tone:"quiet",onClick:w,children:"done"})]})]})})}function xk({form:e}){var I;const t=at(),n=st(),r=_o(),o=Mr(),i=r.displayName(o.origin),l=B1(),u=M(_=>_.repos),c=M(_=>_.newProject?null:_.activeRepoId),h=M(_=>_.rows),p=M(_=>_.paths),g=M(_=>_.home),m=M(_=>_.pending),y=S.useCallback(_=>{bf(_)&&(n==null||n.send({t:"browse-path",path:_}))},[n]),w=S.useCallback((_,L)=>y9({query:L,repos:u,pending:m,entries:[...p.entries].sort((z,F)=>Number(F.isRepo)-Number(z.isRepo)),target:p.target,answered:p.query,others:l}),[u,p,m,l]),b=_=>lN(h,_),E=()=>t({a:"close"}),N=()=>t({a:"close",back:!0}),j=_=>{t({a:"open-repo"}),n==null||n.send({t:"register-repo",path:_})},T=(_,L)=>{t({a:"open-repo"}),n==null||n.send({t:"create-repo",mode:"create",parent:_,name:L})},O=(_,L,z)=>t({a:"new-project",v:mg({mode:_,name:L,parent:k9(u,c,g),...z?{url:z}:{}})}),U=()=>t({a:"open",overlay:{kind:"projects",form:"disk"}}),Q=()=>t({a:"open",overlay:{kind:"add-machine"}}),R=(_,L)=>{const z=r.get(_);z&&(z.store.dispatch({a:"activate-repo",id:L}),r.activate(_))};return f.jsx(Ir,{anchored:e==="pill",initialQuery:e==="disk"?"~/":"",lead:e==="disk"?void 0:f.jsx("span",{className:"picker-chip",children:((I=u.find(_=>_.id===c))==null?void 0:I.name)??"no project"}),trailing:e==="disk"?void 0:f.jsx(Lt,{icon:"folder",label:"Find a project on disk",onClick:U}),items:[],filter:w,initialIndex:_=>_.findIndex(L=>L.kind==="repo"&&!L.machine&&L.repo.id===c),groupOf:_=>_.kind==="repo"&&_.machine?_.machine.name:i,keyOf:_=>_.kind==="repo"?_.machine?`${_.machine.origin}:${_.repo.id}`:_.repo.id:_.kind==="dir"?`d:${_.entry.path}`:_.kind==="open"?`open:${_.path}`:_.kind==="pending"?`p:${_.pending.id}`:_.kind==="clone"?`clone:${_.url}`:_.kind==="new"?"new-project":_.kind==="disk"?"open-folder":_.kind==="add-machine"?"add-machine":`new:${_.parent??""}/${_.name}`,rowClass:_=>Be("picker-row",(_.kind==="new"||_.kind==="disk"||_.kind==="add-machine")&&"new-project-row"),onQuery:y,completionOf:_=>_.kind==="dir"?_.entry.isRepo?_.entry.path:`${_.entry.path}/`:null,narrowTo:_=>_.kind==="dir"&&!_.entry.isRepo?`${_.entry.path}/`:null,onPick:_=>{if(_.kind==="clone")return O("clone",_.name,_.url);if(_.kind==="create"&&!_.parent)return O("create",_.name);if(_.kind==="new")return O("create","");if(_.kind==="disk")return U();if(_.kind==="add-machine")return Q();_.kind==="pending"?t({a:"watch-import",id:_.pending.id}):_.kind==="repo"&&_.machine?R(_.machine.origin,_.repo.id):_.kind==="repo"?t({a:"activate-repo",id:_.repo.id}):_.kind==="open"?j(_.path):_.kind==="dir"?j(_.entry.path):_.parent&&T(_.parent,_.name),E()},onBack:N,rowMenu:_=>_.kind==="repo"&&_.machine?ck(r,_.machine.origin):_.kind==="repo"?wf(_.repo,c,{sock:n,dispatch:t}):_.kind==="pending"?t6(_.pending,{sock:n,dispatch:t}):[],placeholder:u.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)==="add-machine"?"adds one":(_==null?void 0:_.kind)==="repo"&&_.machine?"switches machine":"opens",back:"closes"}),empty:"nothing here; keep typing a path (~/… or /…)",row:_=>_.kind==="repo"&&_.machine?f.jsx(Un,{label:_.repo.name,hint:f.jsx(D9,{origin:_.machine.origin,repo:_.repo})}):_.kind==="repo"?f.jsx(Un,{label:_.repo.name,current:_.repo.id===c,hint:b(_.repo)}):_.kind==="pending"?f.jsx(Un,{label:_.pending.name,hint:_.pending.error?"import failed":"importing…"}):_.kind==="dir"?f.jsx(Un,{label:_.entry.name,hint:_.entry.isRepo?"git repo":void 0}):_.kind==="open"?f.jsx(Un,{label:`open ${_.path}`,hint:"register with this daemon"}):_.kind==="clone"?f.jsx(Un,{label:`clone ${_.name}`,hint:z9(_.url)}):_.kind==="new"?f.jsx(Un,{label:f.jsxs(f.Fragment,{children:[f.jsx(St,{name:"plus",className:"icon-inline"}),"new project"]})}):_.kind==="disk"?f.jsx(Un,{label:f.jsxs(f.Fragment,{children:[f.jsx(St,{name:"folder",className:"icon-inline"}),"open folder"]})}):_.kind==="add-machine"?f.jsx(Un,{label:f.jsxs(f.Fragment,{children:[f.jsx(St,{name:"globe",className:"icon-inline"}),"add a machine"]})}):f.jsx(Un,{label:`create ${_.name}`,hint:_.parent?`in ${_.parent}`:"new project"})})}function lN(e,t){const n=e.filter(c=>c.repoId===t.id),r=n.filter(On).filter(c=>c.worktree.kind!=="spare"),o=r.filter(yc).length,i=r.length-1,l=n.length-n.filter(On).length;return[i>0?`${i} worktree${i===1?"":"s"}`:null,o>0?`${o} working`:null,l>0?`${l} discovered`:null].filter(Boolean).join(" · ")||void 0}function D9({origin:e,repo:t}){const n=_o(),r=n.get(e),o=va(r??n.active(),i=>i.rows);return f.jsx(f.Fragment,{children:r?lN(o,t):null})}function z9(e){const t=e.match(/^[a-z+]+:\/\/(?:[^@/]*@)?([^/:]+)/i)??e.match(/^[^@]+@([^:]+):/);return(t==null?void 0:t[1])??"git remote"}function F9(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:()=>Yt(r)})}const n=[{id:"copy-ref",label:e.kind==="pr"?"copy PR number":"copy branch name",onClick:()=>Yt(e.ref)}];return Mn([t,n])}const B9=[],U9={branch:"branch",remote:"globe",pr:"pr"},Fb={pr:0,branch:1,remote:2},H9={pr:"pull requests",branch:"branches",remote:"remote branches"};function W9({repoId:e}){const t=at(),n=st(),r=M(g=>g.clientId),o=M(g=>g.refs[e]),i=M(g=>g.rows),l=g=>{var m;return((m=i.find(y=>y.id===g))==null?void 0:m.name)??"a worktree"},u=S.useCallback(g=>[...g].sort((m,y)=>Fb[m.kind]-Fb[y.kind]),[]),c=S.useCallback(g=>n==null?void 0:n.send({t:"search-refs",repoId:e,query:g.trim()}),[n,e]),h=g=>!o||o.query!==g.trim(),p=g=>g.openIn?`open in ${l(g.openIn)}`:g.merged?"merged":g.pr?`${g.pr.author}${g.pr.draft?" · draft":""}${g.pr.fork?" · fork":""}`:g.subject??"";return f.jsx(Ir,{items:(o==null?void 0:o.refs)??B9,filter:u,onQuery:c,keyOf:g=>`${g.kind}:${g.ref}`,rowClass:()=>"picker-row ref-row",onPick:g=>{g.openIn?t({a:"activate",id:g.openIn}):n==null||n.send({t:"open-ref",repoId:e,kind:g.kind,ref:g.ref,clientId:r,...g.pr?{pr:{title:g.pr.title,url:g.pr.url}}:{}}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:F9,groupOf:g=>g.kind,groupHead:(g,m)=>`${H9[g]} · ${m}`,placeholder:"open a branch or PR…",keys:g=>({nav:"moves",pick:g!=null&&g.openIn?"switches to it":"opens it as a worktree",back:"closes"}),empty:g=>h(g)?"looking…":g.trim()?"no branch or PR matches":"no unmerged branches or open PRs",row:g=>f.jsx(Un,{label:f.jsxs(f.Fragment,{children:[f.jsx(St,{name:U9[g.kind],className:"icon-inline"}),f.jsx("span",{className:"ref-name",children:g.name})]}),hint:p(g)})})}const Bb=[],Lp=2;function K9({worktreeId:e}){const t=at(),n=st(),r=Y1(e).search,o=M(h=>h.layout.changes),i=M(h=>{var g;const p=(g=rn(h,e))==null?void 0:g.worktree;return p?p.path:null}),l=S.useCallback((h,p)=>p.trim().length>=Lp?h:Bb,[]),u=S.useCallback(h=>{const p=h.trim();p.length>=Lp&&(n==null||n.send({t:"search",worktreeId:e,query:p}))},[n,e]),c=h=>!r||r.query.trim()!==h.trim();return f.jsx(Ir,{items:(r==null?void 0:r.hits)??Bb,filter:l,onQuery:u,keyOf:h=>`${h.path}:${h.line}`,rowClass:()=>"search-hit",rowTitle:h=>`${h.path}:${h.line}`,onPick:h=>{nr({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=>i?vs({id:e,dir:i},h.path,{},{sock:n,dispatch:t}):[],placeholder:"search in files…",keys:{pick:"opens the file",back:"closes"},empty:h=>h.trim().length<Lp?"type at least two characters":c(h)?"searching…":"no matches",footer:(h,p)=>r!=null&&r.truncated&&!c(h)&&p.length>0?f.jsxs("div",{className:"empty",children:["showing the first ",p.length,"; narrow the search"]}):null,row:h=>f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"search-loc",children:[h.path,":",h.line]}),f.jsx("span",{className:"search-text",children:h.text})]})})}const Ub=e=>e.source==="file"?"~/.toyon/themes":e.source==="vscode"?"VS Code":"";function Z9({slot:e}){const t=at(),n=st(),r=M(j=>j.themePrefs),o=M(j=>j.themes),i=xg(),l=ig(r,i),u=r[e==="theme"?l:e],c=()=>t({a:"close"}),h=()=>t({a:"close",back:!0}),p=j=>t({a:"preview-theme",theme:j}),[g,m]=S.useState(null),[y,w]=S.useState(null),b=(j,T)=>j[T??l]??j.dark??j.light??null,E=S.useMemo(()=>m2(o),[o]),N=S.useMemo(()=>o.filter(j=>j.kind===e),[o,e]);return yt([g,y],()=>{e==="theme"&&p(g?b(g,y):null)}),e!=="theme"?f.jsx(Ir,{items:N,filter:(j,T)=>j.filter(O=>_s(T,O.name,O.id)),rowClass:()=>"picker-row",keyOf:j=>j.id,initialIndex:j=>j.findIndex(T=>T.id===u),onActive:p,onPick:j=>{n==null||n.send({t:"set-theme",prefs:{...r,[e]:j.id}}),c()},onBack:h,placeholder:`${e} slot override`,keys:{nav:"preview",pick:"keeps",back:"reverts"},empty:"no matching theme",row:j=>f.jsx(Un,{label:j.name,current:j.id===u,hint:Ub(j)})}):f.jsx(Ir,{items:E,filter:(j,T)=>j.filter(O=>{var U,Q;return _s(T,O.name,(U=O.dark)==null?void 0:U.name,(Q=O.light)==null?void 0:Q.name)}),rowClass:()=>"picker-row",keyOf:j=>{var T,O;return j.name+(((T=j.dark)==null?void 0:T.id)??((O=j.light)==null?void 0:O.id))},initialIndex:j=>j.findIndex(T=>{var O,U;return((O=T.dark)==null?void 0:O.id)===u||((U=T.light)==null?void 0:U.id)===u}),onActive:m,onSide:j=>{var T;j.dark&&j.light&&w((((T=b(j,y))==null?void 0:T.kind)??l)==="dark"?"light":"dark")},onPick:j=>{n==null||n.send({t:"set-theme",prefs:g2(r,j)}),c()},onBack:h,placeholder:"theme",keys:{nav:"preview",side:"dark/light",pick:"keeps",back:"reverts"},empty:"no matching theme",row:(j,T)=>{var R,I;const O=b(j,T?y:null),U=Ub(j.dark??j.light),Q=((R=j.dark)==null?void 0:R.id)===u||((I=j.light)==null?void 0:I.id)===u;return f.jsx(Un,{label:j.name,current:Q,hint:f.jsxs("span",{className:"theme-kinds",children:[U&&f.jsx("span",{children:U}),f.jsx("span",{className:"kind","data-state":pr({current:T&&(O==null?void 0:O.kind)==="dark"}),children:j.dark?"dark":""}),f.jsx("span",{className:"kind","data-state":pr({current:T&&(O==null?void 0:O.kind)==="light"}),children:j.light?"light":""})]})})}})}function cN(){const e=lL(),t=M(i=>i.frame==="phone"),n=Ga(),r=M(i=>i.activeRepoId),o=M(i=>i.newProject);return f.jsxs(f.Fragment,{children:[(e==null?void 0:e.kind)==="quick-open"&&n&&f.jsx(zF,{worktreeId:n}),(e==null?void 0:e.kind)==="search"&&n&&f.jsx(K9,{worktreeId:n}),(e==null?void 0:e.kind)==="element-sources"&&f.jsx(g9,{worktreeId:e.worktreeId,hits:e.hits}),(e==null?void 0:e.kind)==="refs"&&r&&f.jsx(W9,{repoId:r}),(e==null?void 0:e.kind)==="chats"&&r&&f.jsx(m9,{repoId:r,scope:e.names?"names":"all"}),(e==null?void 0:e.kind)==="keys"&&f.jsx(e9,{}),(e==null?void 0:e.kind)==="pair"&&f.jsx(P9,{}),(e==null?void 0:e.kind)==="add-machine"&&f.jsx(K8,{}),(e==null?void 0:e.kind)==="theme"&&f.jsx(Z9,{slot:e.slot}),(e==null?void 0:e.kind)==="appearance"&&f.jsx(c9,{}),(e==null?void 0:e.kind)==="keep-awake"&&f.jsx(E9,{}),(e==null?void 0:e.kind)==="agent"&&f.jsx(i9,{}),(e==null?void 0:e.kind)==="agent-page"&&f.jsx(o9,{agentId:e.agent}),(e==null?void 0:e.kind)==="handoff"&&f.jsx(b9,{worktreeId:e.worktreeId}),(e==null?void 0:e.kind)==="commands"&&!t&&f.jsx(KS,{}),(e==null?void 0:e.kind)==="projects"&&e.form!=="pill"&&f.jsx(xk,{form:e.form},e.form),(e==null?void 0:e.kind)==="choose-folder"&&o&&f.jsx(v9,{project:o})]})}const Xl="Lost the daemon; retrying",q9="Not run by Toyon",uN="new worktree",G9=(e,t)=>`in ${e}, started from ${t}`,V9=new Set(["waiting","working","starting","failed","crashed"]);function Pm(e,t){if(t.offline)return Xl;if(!On(e))return e.locked?`Held by ${e.lockReason??"another tool"}`:t.path;if(t.op)return ug(t.op);if(Ar(e.worktree))return uN;const n=cg(e,t.needsSetup),r=e.worktree.lastTurn;return!V9.has(ni(e))&&r?zg(r):t.at&&t.at!=="now"?`${n} · ${t.at}`:n}function Y9(e,t){if(!On(e)||t)return!1;const n=ni(e);return(n==="idle"||n==="asleep")&&!e.unseen}function Q9(e){const t=e.worktree.lastTurn,n=t?(yc(e)?m4:zg)(t):void 0,r=e.worktree.pr&&!e.worktree.landed?ys(e.worktree.pr):void 0;return[n,r].filter(o=>!!o)}function X9(e,t,n,r){var h,p;let o;const i=(g,m)=>{m&&(!o||m>o.at)&&(o={title:g,at:m})};for(const g of e){const m=(h=g.worktree)==null?void 0:h.lands;g.worktree&&(m!=null&&m.length)&&i(g.worktree.title,(p=m[m.length-1])==null?void 0:p.at)}for(const g of t)i(g.title,g.landedAt);const l=o?`Landed ${o.title} ${Yo(ao(o.at))}.`:void 0,u=n?DE(r,n):null,c=u?ns(`${u.charAt(0).toUpperCase()}${u.slice(1)}`):n!=null&&n.fetchedAt?`Level with origin, fetched ${Yo(ao(n.fetchedAt))}.`:void 0;return[l,c].filter(g=>!!g)}const Hb=160;function J9(e){var r;const t=(r=e.prompt)==null?void 0:r.replace(/\s+/g," ").trim();if(!t)return[];if(t.length<=Hb)return[t];const n=t.slice(0,Hb);return[`${n.slice(0,Math.max(n.lastIndexOf(" "),1)).trimEnd()}…`]}function eB(e){const n=[e.auto&&tB(e.auto,!!e.landed),e.cost!==void 0?_c(e.cost):void 0].filter(r=>!!r);return n.length?n:void 0}function tB(e,t){const{what:n,idle:r}=rj(e);return r?`${t?"":`${n}, `}${r} idle`:n}const Wb=25;function nB(e,t){if(e.length<=Wb+1)return{shown:e,rest:0};const n=e.slice(0,Wb),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}}const rB=.5;function oB(e){const t=e.usage,n=t&&t.size>0?t.used/t.size:0,r=[n>=rB?`${Math.round(100*n)}% of context`:void 0,e.queued?`${e.queued} queued`:void 0,(t==null?void 0:t.cost)!==void 0?_c(t.cost):void 0].filter(o=>!!o);return r.length?r:void 0}const Yu=e=>e>999?"1k+":String(e);function dN({width:e,placement:t="strip"}){const n=t==="screen",r=Wi(),o=M(V=>V.chatSide)==="left"?"right":"left",i=at(),l=st(),{host:u}=Lr(),c=Ng(),h=c[0]&&Ar(c[0].worktree)?c[0]:null,p=h?c.slice(1):c,g=M(V=>Da(V,V.activeRepoId)),m=V=>h&&V.id===h.id&&g?{behind:g.behind,dirty:g.dirty}:V,[,y]=S.useState(0);S.useEffect(()=>{const V=setInterval(()=>y(ge=>ge+1),6e4);return()=>clearInterval(V)},[]);const w=tL(),b=nL(),E=rL(),N=oL(),j=(V,ge,ft)=>{V.key!=="ArrowLeft"&&V.key!=="ArrowRight"||V.shiftKey||V.altKey||V.metaKey||V.ctrlKey||(V.preventDefault(),mf([{depth:0,open:ge}],0,V.key)&&i({a:ft}))},T=Hi(),O=M(V=>V.clientId),U=M(V=>V.frame),Q=M(V=>V.activeRepoId),R=M(V=>V.connected);S.useEffect(()=>{l&&R&&Q&&l.send({t:"list-archived",repoId:Q})},[l,R,Q]);const I=Ga(),_=G1(),L=M(V=>V.layout),z=M(V=>V.railOpen),F=M(V=>V.railPeek),ee=S.useRef(null),[se,fe]=S.useState(!1);yt([F],()=>{var V;F&&!n&&!r&&!((V=ee.current)!=null&&V.matches(":hover"))&&fe(!0)}),S.useEffect(()=>{if(!se)return;let V=null;const ge=ft=>{if(!V){V={x:ft.clientX,y:ft.clientY};return}Math.abs(ft.clientX-V.x)+Math.abs(ft.clientY-V.y)<3||fe(!1)};return window.addEventListener("pointermove",ge),()=>window.removeEventListener("pointermove",ge)},[se]);const ke=M(V=>V.focusRail),ne=S.useRef(ke),A=S.useRef(null);yt([ke],()=>{if(ke===ne.current)return;ne.current=ke;const V=requestAnimationFrame(()=>{var ge,ft;return(ft=(ge=A.current)==null?void 0:ge.querySelector('[data-state~="current"]'))==null?void 0:ft.focus()});return()=>cancelAnimationFrame(V)});const q=M(V=>V.repos),ie=M(V=>V.shipping),P=M(V=>V.rows),W=V=>q.find(ge=>ge.id===V.repoId)??null,xe=V=>Q?wg(V,Q,P):null,ce=on("rail"),me=nE(),_e=M(V=>V.home),ae=V=>{const ge=V.worktree?V.worktree.path:V.path;return _e&&ge.startsWith(`${_e}/`)?`~${ge.slice(_e.length)}`:ge},[be,ze]=S.useState(!1),[re,he]=S.useState([]),pe=V=>{!Ju(V.worktree)||xe(V)||(ze(!0),he(ge=>ge.includes(V.worktree.id)?ge.filter(ft=>ft!==V.worktree.id):[...ge,V.worktree.id]))},Te=()=>{ze(!1),he([])};yt([be],()=>{const V=ge=>ge.key==="Escape"&&Te();return be&&window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)});const Ue=Pg(l,i),ct={sock:l,dispatch:i},We=V=>{ze(!0),he(ge=>V===I||ge.includes(V)?ge:[...ge,V])},xn=V=>On(V)?ME(V,W(V),{layout:L,shipping:ie,frame:U,repos:q},ct,{...xe(V)?{}:{graft:We},hostname:u}):s4(V,{clientId:O,frame:U},ct,u),Ht=nB(E,(T==null?void 0:T.id)??null),It=Ht.shown.some(V=>(V.dirty??0)>0),nt=V=>f.jsxs("button",{type:"button",className:Be("row row-edge row-quiet rail-disc-item rail-arch-item",(me==null?void 0:me.owner)==="rail"&&me.key===V.id&&"menu-open"),"data-state":pr({current:!n&&(T==null?void 0:T.id)===V.id}),...Ft(H4(V),void 0,{placement:o,card:!0,detail:J9(V),aside:eB(V)}),onClick:()=>i({a:"open-archived",id:V.id}),...ce.contextMenu(()=>od(V,{clientId:O,frame:U},ct),V.id),children:[f.jsxs("span",{className:"rail-gut",onClick:r?ge=>{ge.stopPropagation(),ce.openUnder(ge.currentTarget,()=>od(V,{clientId:O,frame:U},ct),V.id)}:void 0,children:[f.jsx("span",{className:"rail-at row-dim",children:ao(V.archivedAt)}),f.jsx("span",{className:"rail-more",...Ft("Actions"),onClick:ge=>{ge.stopPropagation(),ce.openUnder(ge.currentTarget,()=>od(V,{clientId:O,frame:U},ct),V.id)},children:f.jsx(St,{name:"more"})})]}),f.jsx("span",{className:"branch",children:V.title}),It&&f.jsx("span",{className:"rail-counts",children:f.jsx("span",{className:"rail-count row-dim","data-tip":V.dirty?`${V.dirty} uncommitted, kept`:void 0,children:V.dirty?`~${Yu(V.dirty)}`:""})}),V.auto?f.jsx("span",{className:"rail-glyph rail-auto row-dim",children:f.jsx(St,{name:"clock",className:"icon-inline"})}):f.jsx("span",{className:"dot"}),n&&f.jsx("span",{className:"rail-at rail-at-end row-dim",children:ao(V.archivedAt)})]},V.id),Ve=[...c,...w].map(m),mt=["ahead","dirty","behind"].filter(V=>Ve.some(ge=>(ge[V]??0)>0)),En=V=>{const ge=mt.findIndex(ft=>(V[ft]??0)>0);return new Set(ge<0?[]:mt.slice(ge))},Rt=V=>{var In;const ge=On(V)?V:null,ft=!!ge&&Ar(ge.worktree),qe=m(V),un=q.find(ot=>ot.id===V.repoId)??null,yn=un?Ud(un):"main",Tn=un&&Bj(un)&&(g!=null&&g.fetchedAt)?` as of ${PE(g.fetchedAt)}`:"",gt=En(qe),jn=!!qe.ahead&&!qe.dirty,ye=V.id,Le=(me==null?void 0:me.owner)==="rail"&&me.key===ye,wn=ge?xe(ge):null,_n=wn&&ge?W(ge):null,Sn=ge&&!wn&&be&&Ju(ge.worktree)&&ye!==I,sn=v1(V,(In=ie[ye])==null?void 0:In.op);return f.jsxs("button",{type:"button",className:Be("row row-edge",ge?"rail-item":"row-quiet rail-disc-item",n&&Y9(V,sn)&&"row-quiet",Le&&"menu-open"),"data-state":pr({current:!n&&ye===I&&!T,checked:re.includes(ye)}),...ge?Ft(_?Xl:sn?ug(sn):cg(V,bd(W(ge))),void 0,{placement:o,card:!0,aside:oB(V),detail:Ar(ge.worktree)?X9(c,E,g,yn):[...wn&&_n?[G9(_n.name,wn.worktree.title)]:[],...Q9(ge)],dot:_?void 0:sn?"spinner":ni(V)}):Ft(_?Xl:V.locked?`Held by ${V.lockReason??"another tool"}`:q9,void 0,{placement:o,card:!0,detail:ae(V),dot:_||V.locked?void 0:"discovered"}),"data-wt":ye,onKeyDown:ot=>{var ue,Ie;if(!ge||be||ot.key!=="ArrowUp"&&ot.key!=="ArrowDown"||ot.altKey||ot.ctrlKey||ot.metaKey)return;ot.preventDefault();const Wt=ot.key==="ArrowDown",Qt=c.findIndex(Je=>Je.id===ye),B=c[Qt+(Wt?1:-1)];B&&(i({a:"activate",id:B.id}),(Ie=(ue=ot.currentTarget.parentElement)==null?void 0:ue.querySelector(`[data-wt="${B.id}"]`))==null||Ie.focus())},onClick:ot=>{ge&&!wn&&(be||ot.shiftKey)?ye===I?ze(!0):pe(ge):ft&&!n?i({a:"open-draft"}):(i({a:"activate",id:ye}),ge&&!r&&i({a:"walked"}))},...ce.contextMenu(()=>xn(V),ye),children:[f.jsx("span",{className:"rail-gut",onClick:r&&!be?ot=>{ot.stopPropagation(),ce.openUnder(ot.currentTarget,()=>xn(V),ye)}:void 0,children:Sn?f.jsx("input",{type:"checkbox",className:"rail-graft-check",checked:re.includes(ye),readOnly:!0,tabIndex:-1}):!be&&f.jsxs(f.Fragment,{children:[ge&&!ft&&f.jsx("span",{className:"rail-at row-dim",children:ao(Jl(ge.worktree))}),f.jsx("span",{className:"rail-more",...Ft("Actions"),onClick:ot=>{ot.stopPropagation(),ce.openUnder(ot.currentTarget,()=>xn(V),ye)},children:f.jsx(St,{name:"more"})})]})}),ft?f.jsxs("span",{className:"branch rail-main-label",children:[f.jsx(St,{name:"plus",className:"icon-inline"}),"new worktree"]}):f.jsx("span",{className:Be("branch",(ge==null?void 0:ge.worktree.unnamed)&&"row-dim"),children:em(V,ge?W(ge):null)}),(ge==null?void 0:ge.worktree.mode)&&ge.worktree.mode!=="auto"&&f.jsx("span",{className:"rail-badge badge-mode","data-tip":`${ge.worktree.mode} mode: the agent waits for you`,children:ge.worktree.mode}),ge&&(()=>{const ot=W(ge),Wt=RE(ge.worktree,ot);return Wt&&Wt!==(ot==null?void 0:ot.config.defaultProfile)?f.jsx("span",{className:"rail-badge badge-profile","data-tip":`runs the ${Wt} profile`,children:Wt}):null})(),(ge==null?void 0:ge.worktree.variant)&&f.jsxs("span",{className:"rail-badge badge-variant clickable","data-tip":"Keep this variant, archive the others",onClick:ot=>{ot.stopPropagation(),Ue.pickVariant(ge)},children:[f.jsxs("span",{className:"num",children:["v",ge.worktree.variant.index,"/",ge.worktree.variant.of]}),f.jsx("span",{className:"act",children:"pick"})]}),_n&&f.jsx("span",{className:"rail-guest row-dim",children:_n.name}),f.jsxs("span",{className:"rail-counts",children:[gt.has("ahead")&&f.jsx("span",{className:"rail-count badge-ahead","data-tip":qe.ahead?`${qe.ahead} ahead of ${yn}`:void 0,children:qe.ahead?`+${Yu(qe.ahead)}`:""}),gt.has("dirty")&&!jn&&f.jsx("span",{className:"rail-count badge-dirty","data-tip":qe.dirty?`${qe.dirty} uncommitted${ft?" on main":""}`:void 0,children:qe.dirty?`~${Yu(qe.dirty)}`:""}),gt.has("behind")&&f.jsx("span",{className:"rail-count rail-behind row-dim","data-tip":qe.behind?`${qe.behind} behind ${ft?"origin":yn}${ft?"":Tn}`:void 0,children:qe.behind?Yu(qe.behind):""}),n&&ge&&f.jsx("span",{className:"rail-at row-dim",children:ft?"":ao(Jl(ge.worktree))})]}),(()=>{if(sn)return f.jsx(Ba,{size:"dot"});if(V.locked)return f.jsx("span",{className:"rail-glyph rail-lock row-dim",children:f.jsx(St,{name:"lock",className:"icon-inline"})});if(!ge)return f.jsx("span",{className:"dot discovered"});const ot=be||_?null:b1(V.procs),Wt=V.unseen?" unseen":"",Qt=ni(V);return ft&&!ot&&Qt!=="crashed"&&!_?f.jsxs(f.Fragment,{children:[f.jsx("span",{className:`dot ${Qt} rail-main-dot`}),f.jsx("span",{className:"rail-glyph rail-main-strip",children:f.jsx(St,{name:"plus"})})]}):!ot||Qt!=="crashed"?f.jsx("span",{className:`dot ${Qt}${Wt}`}):f.jsx("span",{className:`dot crashed clickable${Wt}`,...Ft(ot.tip),onClick:B=>{B.stopPropagation(),i({a:"activate",id:ye}),i({a:"term-stream",id:ye,stream:ot.stream})}})})(),n&&f.jsx("span",{className:"rail-say row-dim",children:Pm(V,{offline:_,needsSetup:bd(ge?W(ge):null),path:ae(V),op:sn})})]},ye)};return f.jsx("div",{ref:ee,className:Be("rail",n&&"rail-screen",!n&&(be||(me==null?void 0:me.owner)==="rail"||F)&&"hold",se&&"quiet",(n||z)&&"pinned",_&&"offline"),style:e!==void 0&&!n?{"--rail-width":`${e}px`}:void 0,onClick:r&&!n&&!z?V=>{V.target instanceof Element&&V.target.closest("button, .rail-gut")||i({a:"toggle-rail"})}:void 0,children:f.jsxs("div",{className:"rail-panel","data-tip":_?Xl:void 0,"data-tip-placement":"follow",children:[f.jsxs("div",{className:"rail-list",ref:A,children:[h&&!n&&Rt(h),p.map(Rt),be&&f.jsxs("div",{className:"rail-graft",children:[(()=>{const V=c.find(qe=>qe.worktree.id===I&&Ju(qe.worktree)&&!xe(qe)),ge=re.filter(qe=>qe!==(V==null?void 0:V.worktree.id)),ft=ge.map(qe=>{var un;return((un=c.find(yn=>yn.worktree.id===qe))==null?void 0:un.worktree.title)??qe}).join(", ");return f.jsxs(Pe,{size:"md",tone:"primary",disabled:!V||ge.length===0,"data-tip":V?`Merge the checked worktrees into ${V.worktree.title} and remove them`:"Select a worktree to graft onto",onClick:()=>{V&&window.confirm(`Graft ${ft} onto ${V.worktree.title}?
|
|
251
|
+
|
|
252
|
+
Their branches are merged in, then their directories and branches are removed.`)&&(l==null||l.send({t:"graft",targetId:V.worktree.id,sourceIds:ge}),Te())},children:["graft ",ge.length]})})(),f.jsxs(Pe,{size:"md",disabled:!re.some(V=>{var ge;return(((ge=c.find(ft=>ft.worktree.id===V))==null?void 0:ge.behind)??0)>0}),"data-tip":"Pull main into every selected worktree that's behind",onClick:()=>{for(const V of re){const ge=c.find(ft=>ft.worktree.id===V);((ge==null?void 0:ge.behind)??0)>0&&ei(l,i,{t:"sync-main",worktreeId:V})}Te()},children:[f.jsx(St,{name:"pull",className:"icon-inline"})," sync"]}),f.jsx(Pe,{size:"md",tone:"danger",disabled:re.length===0,"data-tip":"Archive all selected worktrees; their chats and work are kept",onClick:()=>{window.confirm(`Archive ${re.length} worktree(s)?
|
|
253
|
+
|
|
254
|
+
Their directories and branches go. The chats, commits and any uncommitted changes are kept, and each can be restored.`)&&(Pi(l,i,re),Te())},children:"archive…"}),f.jsx(Lt,{icon:"close",label:"Cancel",hint:"esc",onClick:Te})]}),!be&&w.length>0&&f.jsxs(f.Fragment,{children:[f.jsxs("button",{className:"section-title section-row section-fold rail-disc-head","aria-expanded":b,...Ft(`${w.length} worktree${w.length===1?"":"s"} here that Toyon did not make`,void 0,{placement:o}),onClick:()=>i({a:"toggle-discovered"}),onKeyDown:V=>j(V,b,"toggle-discovered"),children:[f.jsx("span",{className:"rail-gut",children:f.jsx(St,{name:"caret",className:Be("icon-inline disc-caret",!b&&"shut")})}),f.jsx("span",{className:"rail-label",children:"discovered"})]}),b&&w.map(Rt)]}),!be&&E.length>0&&f.jsxs(f.Fragment,{children:[f.jsxs("button",{type:"button",className:"section-title section-row section-fold rail-disc-head","aria-expanded":N,...Ft(`${E.length} archived worktree${E.length===1?"":"s"}, kept with ${E.length===1?"its chat":"their chats"}`,void 0,{placement:o}),onClick:()=>i({a:"toggle-archived"}),onKeyDown:V=>j(V,N,"toggle-archived"),children:[f.jsx("span",{className:"rail-gut",children:f.jsx(St,{name:"caret",className:Be("icon-inline disc-caret",!N&&"shut")})}),f.jsx("span",{className:"rail-label",children:"archived"})]}),N&&Ht.shown.map(nt),N&&Ht.rest>0&&Q&&f.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:()=>i({a:"open",overlay:{kind:"chats",names:!0}}),children:[f.jsx("span",{className:"rail-gut"}),f.jsxs("span",{className:"branch row-dim",children:[Ht.rest," more"]}),f.jsx("span",{className:"dot"})]})]})]}),!n&&f.jsx("div",{className:"rail-foot",children:f.jsx(Lt,{icon:"worktrees",label:"Worktree panel",hint:Tt("rail"),tone:"chrome",on:z,onClick:()=>i({a:"toggle-rail"})})})]})})}function sB(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=h1(t.rows,null);return n?`${n.n} ${n.tier==="waiting"?"waiting":"unread"}`:"all quiet"}function iB({machine:e}){const t=_o(),n=on("machines"),r=va(e,g=>g.rows),o=va(e,g=>g.connected),i=va(e,g=>g.connectFailure),l=va(e,g=>g.incompatible),u=va(e,g=>{var m;return(m=g.remote)==null?void 0:m.front}),c=t.displayName(e.origin),h=sB(c,{rows:r.filter(On),connected:o,connectFailure:i,incompatible:l,suspended:u==="edge"&&!o}),p=/^\d+ /.test(h);return f.jsxs("button",{type:"button",className:"row machine-row",onClick:()=>t.activate(e.origin),...n.contextMenu(()=>ck(t,e.origin)),children:[f.jsx("span",{className:"machine-name",children:c}),f.jsx("span",{className:Be("machine-line",p?"machine-owed":"row-dim"),children:h})]})}function aB(){const e=_o(),t=Mr(),n=bg();return n.length<2?null:f.jsxs("div",{className:"machine-rows",children:[f.jsx("div",{className:"section-title section-row machine-head",children:e.displayName(t.origin)}),n.filter(r=>r!==t).map(r=>f.jsx(iB,{machine:r},r.origin))]})}function lB({screen:e,tabs:t,fold:n}){const r=at(),o=_o(),i=Mr(),l=M(se=>se.reading),u=aL(),c=Va(),h=M(se=>se.repos),p=Ss(),g=Ga(),m=Hi(),y=Tg(),w=Ng(),b=G1(),E=h1(w,g),N=w.find(se=>Ar(se.worktree)),j=e==="home",T=!j&&!m&&!!p&&Ar(p.worktree),O=M(se=>{var fe;return T&&p?v1(p,(fe=se.shipping[p.id])==null?void 0:fe.op):null}),U=j?(u==null?void 0:u.name)??o.displayName(i.origin):T?uN:(m==null?void 0:m.title)??(p==null?void 0:p.worktree.title)??(y==null?void 0:y.name)??null,Q=w.filter(se=>!Ar(se.worktree)).length,R=j?Q===0?"no worktrees yet":`${Q} ${Q===1?"worktree":"worktrees"}`:m?XE(m):T?b?Xl:O?ug(O):(u==null?void 0:u.name)??null:p?Pm(p,{offline:b,needsSetup:bd(c),path:p.worktree.path,at:ao(Jl(p.worktree))}):y?Pm(y,{offline:b,needsSetup:!1,path:y.path}):null,I=!j&&!m&&!!p&&ni(p)==="waiting",_=M(se=>{var fe;return((fe=se.overlay)==null?void 0:fe.kind)==="projects"&&se.overlay.form==="pill"}),L=bg().length,z=M(se=>{var fe;return((fe=se.overlay)==null?void 0:fe.kind)==="commands"}),F=f.jsxs("div",{className:"phone-title",children:[j&&(h.length>1||L>1)?f.jsxs("span",{className:"phone-drop phone-switch",children:[f.jsxs(Pe,{tone:"chrome",on:_,onClick:()=>r({a:"toggle",overlay:{kind:"projects",form:"pill"}}),children:[f.jsx("span",{className:"phone-name",children:U}),f.jsx(St,{name:"caret",className:"icon-inline"})]}),_&&f.jsx(xk,{form:"pill"})]}):f.jsx("span",{className:"phone-name",children:U}),R&&f.jsx("span",{className:Be("phone-sub",I&&"phone-sub-asks"),children:R})]}),ee=E&&f.jsxs(Pe,{size:"md",tone:"primary",onClick:()=>{const se=ag(w,g,1);se&&r({a:"activate",id:se.activate})},children:[E.n," ",E.tier]});return f.jsxs("div",{className:"phone-bar",children:[f.jsxs("div",{className:"phone-bar-row",children:[!j&&f.jsx(Lt,{icon:"back",label:"Worktrees",tone:"chrome",onClick:()=>r({a:"screen",to:"home"})}),t?f.jsx("div",{className:"phone-tabs",children:t}):F,!t&&ee,j&&N&&f.jsx(Lt,{icon:"plus",label:"New worktree",tone:"chrome",onClick:()=>r({a:"activate",id:N.id})}),f.jsxs("span",{className:"phone-drop",children:[f.jsx(Lt,{icon:"more",label:"Menu",tone:"chrome",on:z,onClick:()=>r({a:"toggle",overlay:{kind:"commands"}})}),z&&f.jsx(KS,{anchored:{flip:"align",margin:6},trailing:f.jsx(Lt,{icon:"close",label:"Close",tone:"chrome",onClick:()=>r({a:"close"})})})]})]}),t&&!n&&f.jsx("div",{className:"phone-title-seat","data-away":l||void 0,children:f.jsxs("div",{className:"phone-title-strip",children:[F,ee]})})]})}function cB({gated:e,active:t,url:n,hidden:r}){const o=yg(t),i=_P(Mr(),o?n:null,e);return f.jsx("div",{className:"phone-preview",hidden:r,children:o&&i?f.jsx("iframe",{className:"phone-preview-frame",src:i,title:t.worktree.title}):f.jsx(li,{wide:!0,children:f.jsx("p",{className:"status-line",children:cg(t)})})})}const uB=c1();function dB(){const e=S.useRef(null);JM(e);const t=at(),n=M(R=>R.screen),r=Ss(),o=Hi(),i=Tg(),l=M(R=>R.editor),u=M(R=>R.remote),c=bc(),h=M(R=>R.connected),p=M(R=>R.heard),g=M(R=>R.connectFailure),m=Wi(),y=Mr(),w=_o(),b=M(R=>R.incompatible),E=AE({connected:h,heard:p,connectFailure:g,hasToken:y.serving?uB:!0,projectChord:Tt("project"),title:(r==null?void 0:r.worktree.title)??null,machine:y.serving?null:w.displayName(y.origin)}),N=n!=="home"&&(r!==null||o!==null||i!==null),j=N&&!c&&!o?r:null,{host:T}=Lr(),O=j?w1(j.worktree.id,j.worktree.proxyPort,u,T):null,U=n==="preview"&&!j?"chat":n,Q=[{id:"chat",label:"chat"},...j&&O?[{id:"preview",label:"preview",trail:f.jsx(Lt,{icon:"external",label:"Open in browser",tone:"chrome",onClick:()=>SP(y,O,cm(y,u))})}]:[],{id:"changes",label:"code"}];return f.jsxs("div",{ref:e,className:"app phone","data-chat-side":"left","data-touch":m||void 0,"data-hover":!m||void 0,children:[f.jsx(EE,{}),f.jsx(TE,{}),f.jsx(lB,{screen:N?"chat":"home",fold:U!=="chat"||l!==null,tabs:N&&E===null&&f.jsx(pf,{fill:!0,segmented:!0,owner:"phone-tabs",label:"worktree",items:Q,current:U,onPick:R=>t({a:"screen",to:R})})}),f.jsx("div",{className:"phone-screen",children:f.jsxs("div",{className:"center-root",children:[b&&!y.serving?f.jsx(CE,{foreign:w.displayName(y.origin)}):E!==null?f.jsx(li,{wide:!0,children:f.jsx("p",{className:"status-line",children:E})}):N?l?f.jsx(XS,{editor:l,placement:"screen"}):U==="chat"?f.jsx(Ql,{placement:"screen",archived:o,found:i}):U==="changes"?f.jsx(VE,{placement:"screen"}):null:f.jsxs("div",{className:"phone-home",children:[f.jsx(aB,{}),f.jsx(dN,{placement:"screen"})]}),j&&O&&f.jsx(cB,{gated:cm(y,u),active:j,url:O,hidden:U!=="preview"||l!==null},j.worktree.id),f.jsx(cN,{})]})})]})}const fB=640,hB=1e3,fN=`(max-width: ${fB}px), ((hover: none) and (max-width: ${hB}px))`,hN="(hover: none)",pN=()=>{var e;return(e=window.matchMedia)!=null&&e.call(window,fN).matches?"phone":"desk"},pB=()=>{var e;return((e=window.matchMedia)==null?void 0:e.call(window,hN).matches)??!1};function mB(e){const t=(o,i)=>{var c;const l=(c=window.matchMedia)==null?void 0:c.call(window,o);if(!l)return()=>{};const u=h=>i(h.matches);return l.addEventListener("change",u),()=>l.removeEventListener("change",u)},n=t(fN,o=>e.dispatch({a:"frame",v:o?"phone":"desk"})),r=t(hN,o=>e.dispatch({a:"touch",v:o}));return()=>{n(),r()}}function gB(){try{const e=localStorage.getItem(Ze.theme);if(e){const t=JSON.parse(e);if(t!=null&&t.colors&&typeof t.colors.surface0=="string")return t}}catch{}return kc}function mN(e,t={}){var o;const n=document.documentElement;for(const[i,l]of Object.entries(d2(e)))n.style.setProperty(i,l);n.style.colorScheme=e.kind,n.dataset.theme=e.kind;const r=pN()==="phone"?e.colors.surface0:e.colors.surface1;if((o=document.querySelector('meta[name="theme-color"]'))==null||o.setAttribute("content",r),t.remember!==!1)try{localStorage.setItem(Ze.theme,JSON.stringify(e))}catch{}}function gN(e){const t=sg(e);return{type:"theme",accent:t,accentFg:w2(t)}}function kB(){var e;return((e=window.matchMedia)==null?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)??!0}const yB=12*36e5;function wB(){try{const e=localStorage.getItem(Ze.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<yB?{dark:!t.dark,until:0}:null}catch{return null}}function vB(e){try{localStorage.setItem(Ze.daylight,JSON.stringify(e))}catch{}}function bB(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 Dm(e,t){return[{id:"copy-name",label:"copy name",detail:e,onClick:()=>Yt(e)},{id:"copy-value",label:"copy value",detail:t,onClick:()=>Yt(t)}]}function zm(e){return[{id:"copy-value",label:"copy value",detail:e,onClick:()=>Yt(e)}]}function xB(e,t,{sock:n},r){return t?Mn([[{id:"source",label:"open source",onClick:r}],Bi(`${e.dir}/${t}`,()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id,path:t}),ts(n)),[{id:"copy-path",label:"copy path",onClick:()=>Yt(t)}]]):[]}function pc(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(i=>i+i).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 EB(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());return t?t[1].length===4||t[1].length===8:!1}function Kb([e,t,n]){const r=o=>{const i=o/255;return i<=.03928?i/12.92:((i+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function kN(e,t){if(EB(e))return null;const n=pc(e);if(!n)return null;const r=pc(t);if(!r)return null;const[o,i]=[Kb(n),Kb(r)];return`${((Math.max(o,i)+.05)/(Math.min(o,i)+.05)).toFixed(2)}:1`}function _B({worktreeId:e,height:t,full:n,onToggleFull:r,onDragStart:o}){const i=at(),l=st(),u=M(h=>bo(h,e).design);S.useEffect(()=>{u||l==null||l.send({t:"design-scan",worktreeId:e})},[u,e,l]),S.useEffect(()=>()=>Jt.post(e,{type:"highlight-clear"}),[e]);const c={outline:h=>Jt.post(e,h),clear:()=>Jt.post(e,{type:"highlight-clear"}),open:h=>nr({dispatch:i},{worktreeId:e,path:h})};return f.jsx(vk,{kind:"design",className:Be("design-pane",n&&"full"),height:n?void 0:t,resizable:!n,onDragStart:o,title:u?f.jsx("span",{children:jB(u)}):void 0,onClose:()=>i({a:"toggle-design"}),closeHint:Tt("design"),full:n,onToggleFull:r,actions:f.jsxs(Pe,{variant:"outline",onClick:()=>l==null?void 0:l.send({t:"design-scan",worktreeId:e}),"data-tip":"Scan this worktree again",children:[f.jsx(St,{name:"reload",className:"icon-inline"})," rescan"]}),children:u?f.jsxs("div",{className:"design-body",style:TB,onMouseLeave:c.clear,children:[u.tokens.length===0&&u.literals.length>0?f.jsx(OB,{literals:u.literals,outline:c.outline,clear:c.clear}):f.jsx(RB,{tokens:u.tokens,coverage:u.coverage,outline:c.outline,clear:c.clear}),f.jsx(HB,{index:u,outline:c.outline,clear:c.clear,onOpen:c.open}),f.jsx(WB,{index:u,outline:c.outline,clear:c.clear,onOpen:c.open})]}):f.jsx("div",{className:"empty",children:"reading the design system…"})})}const SB=720,NB=132,TB={"--design-column":`${SB}px`,"--design-cell":`${NB}px`};function jB(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 Na=e=>`${e} use${e===1?"":"s"}`;function xf({title:e,note:t,children:n}){return f.jsxs("section",{className:"design-section",children:[f.jsxs("h2",{className:"design-h",children:[e,t&&f.jsx("span",{className:"design-note",children:t})]}),n]})}function zd({children:e}){return f.jsx("p",{className:"design-gap",children:e})}const CB=[{kind:"font",label:"type"},{kind:"color",label:"color"},{kind:"length",label:"size & radius"},{kind:"shadow",label:"shadow"},{kind:"other",label:"computed"}];function AB(e){return e.find(t=>t.kind==="color"&&pc(t.resolved??t.value)!==null)}function IB(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 RB({tokens:e,coverage:t,outline:n,clear:r}){const o=AB(e),i=o&&(o.resolved??o.value),l=new Map;for(const c of e){const h=(c.resolved??c.value).trim().toLowerCase();l.set(h,[...l.get(h)??[],c.name])}const u=c=>(l.get((c.resolved??c.value).trim().toLowerCase())??[]).filter(h=>h!==c.name);return f.jsx(xf,{title:"Tokens",children:e.length===0?f.jsx(zd,{children:IB(t)}):CB.map(({kind:c,label:h})=>{const p=e.filter(m=>m.kind===c);if(p.length===0)return null;const g=wN(p.map(m=>m.value));return f.jsxs("div",{className:"design-group",children:[c!=="font"&&f.jsx("span",{className:"design-group-name",children:h}),c==="font"?f.jsx(vN,{groups:zB(p),outline:n,clear:r}):f.jsx("div",{className:"design-breakout",style:yN(p.length),children:f.jsx("div",{className:"design-grid",children:p.map(m=>{const y=m.resolved??m.value,w=m.kind==="color"&&i?kN(y,i):null;return f.jsx(bN,{kind:m.kind,name:m.name,lines:m.resolved?[m.value,m.resolved]:[m.value],actual:y,ratio:w,largest:g,tipText:BB(m,w,o,u(m)),menu:()=>Dm(m.name,y),outline:n,clear:r},m.name)})})})]},c)})})}const $B=[{role:"color",kind:"color",label:"color"},{role:"radius",kind:"length",label:"radius"},{role:"shadow",kind:"shadow",label:"shadow"}];function OB({literals:e,outline:t,clear:n}){const r=e.find(i=>i.ground&&pc(i.value)!==null),o=FB(e);return f.jsxs(xf,{title:"Values",note:"written out in the rules; no custom properties",children:[o.length>0&&f.jsx("div",{className:"design-group",children:f.jsx(vN,{groups:o,outline:t,clear:n})}),$B.map(({role:i,kind:l,label:u})=>{const c=e.filter(p=>p.role===i);if(c.length===0)return null;const h=wN(c.map(p=>p.value));return f.jsxs("div",{className:"design-group",children:[f.jsx("span",{className:"design-group-name",children:u}),f.jsx("div",{className:"design-breakout",style:yN(c.length),children:f.jsx("div",{className:"design-grid",children:c.map(p=>{const g=l==="color"&&r?kN(p.value,r.value):null;return f.jsx(bN,{kind:l,name:p.value,lines:[Na(p.uses)],actual:p.value,ratio:g,largest:h,tipText:UB(p,g,r),menu:()=>zm(p.value),outline:t,clear:n},p.value)})})})]},i)})]})}function yN(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 wN(e){return e.reduce((t,n)=>Math.max(t,Math.abs(Number.parseFloat(n))||0),0)}const MB=["color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color","outline-color"];function LB(e,t){if(!e)return[];const n=getComputedStyle(e);return t.map(r=>[r,n.getPropertyValue(r)])}const Fm=e=>(e.split(",")[0]??e).replace(/["']/g,"").trim();function PB(e){const t=/^[1-9]00\s+([\d.]+)px(?:\s*\/\s*([\d.]+)(px)?)?\s+(.+)$/.exec(e.trim());if(!t)return{family:Fm(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:Fm(t[4]??""),size:n,lead:o}}function Pp(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 DB(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 zB(e){const t=e.map(n=>({token:n,actual:n.resolved??n.value,...PB(n.resolved??n.value)}));return[...new Set(t.map(n=>n.family))].map(n=>{const r=t.filter(i=>i.family===n),o=r.find(i=>i.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}
|
|
255
|
+
${o.actual}`:void 0,menu:()=>o?Dm(o.token.name,o.actual):[],rows:r.filter(i=>i.size!==null).sort((i,l)=>(l.size??0)-(i.size??0)).map(i=>({key:i.token.name,sample:`${i.family} ${i.size}${i.lead===null?"":`/${i.lead}`}`,style:{font:i.actual},name:i.token.name,label:i.token.name,tipText:`${i.token.name}
|
|
256
|
+
${i.actual}`,menu:()=>Dm(i.token.name,i.actual)}))}})}function FB(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 i=t.find(u=>u.value===o),l=o==="initial"?"default face":Fm(o);return{family:l,stack:o,name:i?Na(i.uses):void 0,label:l,tipText:i?`${i.value}
|
|
257
|
+
${Na(i.uses)}: ${i.selectors.join(", ")}`:void 0,menu:()=>i?zm(i.value):[],rows:n.filter(u=>(u.family??"initial")===o).sort((u,c)=>Pp(c.value)-Pp(u.value)).map(u=>{const c=Pp(u.value),h=DB(u.lead,c),p=u.value.endsWith("px")?`${c}`:u.value;return{key:`${u.value}/${u.lead??""}`,sample:`${l} ${p}${h===null?"":`/${h}`}`,style:{fontFamily:o,fontSize:u.value,lineHeight:u.lead},name:Na(u.uses),label:u.value,tipText:`${u.value}${u.lead?` / ${u.lead}`:""}
|
|
258
|
+
${Na(u.uses)}: ${u.selectors.join(", ")}`,menu:()=>zm(u.value)}})}})}function vN({groups:e,outline:t,clear:n}){const r=(i,l,u)=>t({type:"highlight-computed",props:LB(i.currentTarget.querySelector(".design-face-sample"),l?["font-family","font-size","line-height"]:["font-family"]),match:"all",label:u}),o=on("design");return f.jsx("div",{className:"design-faces",children:e.map(i=>f.jsxs("div",{className:"design-face-group",children:[f.jsxs("div",{className:"design-face-head row-edge",onMouseEnter:l=>r(l,!1,i.label),onMouseLeave:n,...o.contextMenu(i.menu),...i.tipText?Ft(i.tipText,void 0,{placement:"follow"}):{},children:[f.jsx("span",{className:"design-face-sample design-face-family",style:{fontFamily:i.stack},children:i.family}),i.name&&f.jsx("span",{className:"design-face-name row-dim",children:i.name})]}),i.rows.map(l=>f.jsxs("div",{className:"design-face row-edge",onMouseEnter:u=>r(u,!0,l.label),onMouseLeave:n,...o.contextMenu(l.menu),...Ft(l.tipText,void 0,{placement:"follow"}),children:[f.jsx("span",{className:"design-face-sample",style:l.style,children:l.sample}),f.jsx("span",{className:"design-face-name row-dim",children:l.name})]},l.key))]},i.stack))})}function bN({kind:e,name:t,lines:n,actual:r,ratio:o,largest:i,tipText:l,menu:u,outline:c,clear:h}){const p=e==="color"&&pc(r)!==null,g=e==="length"?Number.parseFloat(r):Number.NaN,m=on("design");return f.jsxs("div",{className:"design-cell","data-kind":e,...m.contextMenu(u),onMouseEnter:p?y=>{const w=y.currentTarget.querySelector(".design-fill"),b=w?getComputedStyle(w).backgroundColor:"";c({type:"highlight-computed",props:MB.map(E=>[E,b]),match:"any",label:t})}:void 0,onMouseLeave:p?h:void 0,...Ft(l),children:[e==="color"&&f.jsx("div",{className:"design-sample",children:p&&f.jsx("span",{className:"design-fill",style:{background:r}})}),f.jsxs("div",{className:"design-plate",children:[f.jsx("span",{className:"design-cell-name",children:t}),n.map((y,w)=>f.jsxs("span",{className:"design-cell-line",children:[f.jsx("span",{className:"design-cell-value",children:y}),w===0&&o&&f.jsx("span",{className:"design-cell-note",children:o})]},y)),Number.isFinite(g)&&i>0&&f.jsx("span",{className:"design-scale",style:{width:`${Math.max(2,Math.abs(g)/i*100)}%`}})]})]})}function BB(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 i=e.name===n.name;o.push(i?"the ground these ratios are measured against":`${t} against ${n.name}`)}return o.join(`
|
|
259
|
+
`)}function UB(e,t,n){const r=[e.value,`${Na(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(`
|
|
260
|
+
`)}function xN({shared:e,rest:t}){return e.length===0?f.jsx("ul",{className:"design-rows",children:t}):f.jsxs(f.Fragment,{children:[f.jsx("ul",{className:"design-rows",children:e}),t.length>0&&f.jsxs("details",{className:"design-tail",children:[f.jsxs("summary",{className:"row-edge",children:[f.jsx("span",{className:"design-count row-dim",children:t.length}),"used once or never"]}),f.jsx("ul",{className:"design-rows",children:t})]})]})}function HB({index:e,outline:t,clear:n,onOpen:r}){const{components:o,typed:i}=e;if(o.length===0)return null;const l=o.filter(h=>h.imports>=2),u=o.filter(h=>h.imports<2),c=h=>f.jsx(EN,{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&&f.jsx("span",{className:"design-variants",children:h.variants.map(p=>f.jsxs("span",{className:"design-variant",children:[p.prop,": ",p.values.join(" · ")]},p.prop))})},`${h.path}:${h.name}`);return f.jsxs(xf,{title:"Components",note:`${l.length} reused of ${o.length}`,children:[!i&&f.jsx(zd,{children:"No TypeScript in this project, so the values each prop allows are not listed."}),f.jsx(xN,{shared:l.map(c),rest:u.map(c)})]})}function WB({index:e,outline:t,clear:n,onOpen:r}){const{classes:o,coverage:i}=e,l=o.filter(m=>m.uses>0),u=o.filter(m=>m.uses>=2),c=o.filter(m=>m.uses<2),h=u.filter(m=>m.unwrapped).length,p=o.length?`${u.length} reused of ${o.length}`+(h?`, ${h} with no component of their name`:""):void 0,g=m=>f.jsx(KB,{cls:m,outline:t,clear:n,onOpen:r},m.name);return f.jsx(xf,{title:"Classes",note:p,children:o.length===0?f.jsx(zd,{children:"No stylesheet in this project defines a class. Utility-first CSS generates its own."}):l.length===0?f.jsx(zd,{children:i.classAttrs>0?`${i.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."}):f.jsx(xN,{shared:u.map(g),rest:c.map(g)})})}function KB({cls:e,outline:t,clear:n,onOpen:r}){return f.jsx(EN,{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&&f.jsx("span",{className:"design-tag",children:"no component"})})}function EN({count:e,name:t,path:n,onEnter:r,onLeave:o,onOpen:i,children:l}){const u=Ss(),c=st();at();const h=on("design");return f.jsx("li",{children:f.jsxs("button",{type:"button",className:"design-row row-edge",onMouseEnter:r,onFocus:r,onMouseLeave:o,onBlur:o,onClick:i,disabled:!n,...h.contextMenu(()=>u?xB({id:u.worktree.id,dir:u.worktree.path},n,{sock:c},i):[]),children:[f.jsx("span",{className:"design-count row-dim",children:e}),f.jsx("span",{className:"design-name",children:t}),f.jsx("span",{className:"design-path row-dim",children:n}),l]})})}function ZB({worktreeId:e,procs:t,borrowed:n,login:r,current:o,onRestart:i}){const l=st();at();const u={sock:l},c=(p,g)=>f.jsx(Lt,{icon:"reload",label:g,onClick:()=>i(p)}),h={id:bs,label:"login",tip:Ft("The agent's login; it closes once you are in",void 0,{placement:"top"}),trail:c(bs,"Run the login again")};return r&&o===bs?[h]:[{id:ko,label:"shell",tip:Ft("A shell in this worktree",void 0,{placement:"top"}),menu:()=>cS(e,u),trail:c(ko,"Restart the shell")},...r?[h]:[],...t.map(p=>({id:p.name,label:p.name,lead:f.jsx("span",{className:`dot ${p.status}`}),tip:Ft(tM(p.status),void 0,{placement:"top",dot:p.status,name:p.name,detail:p.command,aside:[`:${p.port}`]}),menu:()=>uk(p,e,u),trail:c(p.name,`Restart ${p.name}`)})),...n.map(p=>({id:p,label:p,lead:f.jsx("span",{className:"dot borrowed"}),tip:Ft(`${p} runs on main for every worktree; this one reaches it at its usual address`,void 0,{placement:"top"})}))]}const qB=S.lazy(()=>$m(()=>import("./XTerm-Dc6Bk52B.js"),__vite__mapDeps([3,4]))),GB=[];function VB({worktreeId:e,opened:t,height:n,onDragStart:r}){const o=at(),i=st(),l=of(),u=M(z=>z.connected),c=M(z=>z.focusTerm),h=Ss(),p=(h==null?void 0:h.procs)??[],g=(h==null?void 0:h.borrowed)??GB,m=(h==null?void 0:h.login)??!1,y=At(e,"termStream"),w=M(z=>{var F;return((F=z.termRun)==null?void 0:F.id)===e&&y===ko?z.termRun.command:null}),[b,E]=S.useState(null),N=g.includes(y);S.useEffect(()=>{y===ko||(y===bs?m:p.some(F=>F.name===y)||g.includes(y))||o({a:"term-stream",id:e,stream:ko})},[p,g,m,y,e,o]);const j=z=>{z!==y&&(E(null),o({a:"term-stream",id:e,stream:z}))},T=S.useRef(!1),[O,U]=S.useState(0),Q=z=>{z===ko&&z===y&&(T.current=!0),i==null||i.send({t:"term-restart",worktreeId:e,stream:z}),z===bs&&z===y&&(E(null),U(F=>F+1))},R=(z,F)=>{if(z)return E(null);if(T.current){T.current=!1,U(ee=>ee+1);return}E({code:F})},I=ZB({worktreeId:e,procs:p,borrowed:g,login:m,current:y,onRestart:Q}),_=S.useRef(!t),L=!_.current;return S.useEffect(()=>{_.current=!1},[]),f.jsxs(vk,{kind:"terminal",className:"term-pane",height:n,onDragStart:r,tabs:{items:I,current:y,onPick:j,font:"mono",owner:"terminal",label:"terminal streams"},onClose:()=>o({a:"toggle-terminal"}),closeHint:Tt("terminal"),children:[f.jsxs("div",{className:"term-body",children:[N&&f.jsx(ic,{pane:!0,title:`${y} runs on main`,body:"Every worktree reaches main's copy until its own changes touch it, or until asked.",action:f.jsx(Pe,{variant:"outline",onClick:()=>i==null?void 0:i.send({t:"own-procs",worktreeId:e,names:[y]}),children:"run it here"})}),f.jsx(Lg,{pane:!0,children:f.jsx(S.Suspense,{fallback:f.jsx("div",{className:"empty",children:"loading terminal…"}),children:f.jsx(qB,{worktreeId:e,stream:y,theme:l,sock:i,connected:u,focusOnMount:L,focusReq:c,onAlive:R,run:w,onRan:()=>o({a:"term-ran"}),onEscape:()=>o({a:"toggle-terminal"})},`${y}:${O}`)})})]}),b!==null&&!N&&f.jsx(ic,{pane:!0,title:y===ko?"the shell exited":y===bs?"the login did not finish":`${y} exited`,body:b.code===void 0?void 0:`exit code ${b.code}`,action:f.jsx(Pe,{variant:"outline",onClick:()=>Q(y),children:"restart"})})]})}function YB(e){return e==="reserved"?"checking out a fresh worktree…":e==="warming"?"copying dependencies and running setup…":"starting dev servers…"}const QB="preview off; it starts when the agent writes a file";function XB({worktree:e,log:t}){const n=st(),r=at(),o=e.procs,i=b=>n==null?void 0:n.send({t:"term-restart",worktreeId:e.id,stream:b.name}),l=o.some(b=>b.status==="crashed"||b.status==="unreachable"),u=M(b=>b.clientId),c=lc(e,"setup"),h=c&&c.status!=="terminated"?c:null,p=Fa(Fg(h??void 0)?h==null?void 0:h.since:void 0),g=!!e.worktree.parked&&o.length===0,m=()=>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:u});return f.jsxs(li,{wide:!0,children:[o.length===0?f.jsx("div",{className:"status-line",children:h?f.jsx("span",{className:"live-text","data-tip":KE[h.status],children:fm("setup",h,p)}):g?QB:YB(e.worktree.phase)}):f.jsx("ul",{className:"boot-procs",children:o.map(b=>f.jsxs("li",{className:Be("boot-proc",(b.status==="crashed"||b.status==="unreachable")&&"boot-bad"),children:[f.jsx("span",{className:"boot-name",children:b.name}),f.jsx("span",{className:"boot-status",children:JB(b)}),(b.status==="crashed"||b.status==="unreachable")&&f.jsx(Pe,{variant:"outline",onClick:()=>i(b),children:"restart"}),b.detail&&b.status!=="asleep"&&f.jsx("div",{className:"boot-detail",children:b.detail})]},b.name))}),g&&f.jsx("div",{className:"status-actions",children:f.jsx(Pe,{variant:"outline",size:"lg",onClick:m,children:"start preview"})}),y&&f.jsx("div",{className:"status-actions",children:f.jsx(Pe,{variant:"outline","data-tip":ZE("setup"),onClick:()=>n==null?void 0:n.send({t:"run-stop",worktreeId:e.id,kind:"setup"}),children:"stop setup"})}),l&&f.jsxs("div",{className:"status-actions",children:[e.agent==="idle"&&f.jsx(Pe,{variant:"outline",size:"lg",onClick:w,children:"ask the agent to fix it"}),f.jsx(Pe,{onClick:()=>r({a:"open",overlay:{kind:"setup",repoId:e.repoId}}),children:"edit setup"})]}),t.length>0&&f.jsx("pre",{className:"status-tail",children:t.slice(-30).map(b=>`[${b.proc}] ${b.line}`).join(`
|
|
261
|
+
`)})]})}function JB(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 eU(e,t,n){return!e||!t||e===t?null:n(e)===n(t)?e:null}function tU(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 nU(e){return e.available?e.sandboxed?`${e.name} works on it`:`${e.name} works on it, with no sandbox around its commands`:e.installing?`${e.name} is installing; it works on it once that lands`:e.onDemand&&e.reason==="not installed"?`${e.name} is a large download; press to fetch it`:`${e.reason??"not installed"}; press to install again`}function _N(){const e=st(),t=M(c=>c.agents),n=M(c=>c.agentChosen),[r,o]=S.useState(null),i=r?t.find(c=>c.id===r):void 0,l=c=>e==null?void 0:e.send({t:"set-default-agent",agent:c});if(yt([i==null?void 0:i.available,r],()=>{!r||!(i!=null&&i.available)||(l(r),o(null))}),n)return null;const u=c=>{if(c.available){l(c.id);return}o(c.id),c.installing||e==null||e.send({t:"install-agent",agent:c.id})};return f.jsxs("div",{className:"hint agent-ask",children:[f.jsx("span",{children:"which agent works on it?"}),t.map(c=>f.jsx(Pe,{variant:"outline",size:"md",busy:c.installing||r===c.id,onClick:()=>u(c),...Ft(nU(c)),children:c.name},c.id))]})}function rU({active:e}){const t=at(),n=st(),r=Kn(),o=Va(),i=M(c=>c.home),l=e.worktree.title,u=()=>{o!=null&&o.made&&(t({a:"new-project",v:{...mg({mode:o.made==="git"?"init":"create",name:o.name,parent:iN(o.path,i)??o.path}),phase:"unmaking",repoId:o.id,prompt:bo(r.getState(),e.worktree.id).draft}}),n==null||n.send({t:"unmake-repo",repoId:o.id}))};return f.jsxs(li,{anchor:"line",children:[f.jsx("p",{className:"form-title",children:o!=null&&o.made?f.jsx(Pe,{variant:"inline",onClick:u,...Ft("Rename or move this project"),children:l}):l}),f.jsx(_N,{}),f.jsx("div",{className:"form-body form-body-lg",children:f.jsx(ad,{active:e,greenfield:!0})})]})}function oU({pending:e}){const t=at(),n=st(),r=!!e.error,o=()=>{n==null||n.send({t:"cancel-import",id:e.id}),t({a:"watch-import",id:null})},i=S.useRef(null);return S.useEffect(()=>{var l;return(l=i.current)==null?void 0:l.scrollTo({top:i.current.scrollHeight})},[e.lines.length]),f.jsxs(li,{wide:!0,children:[f.jsxs("p",{className:"status-line",children:[r?"could not import":"importing"," ",e.name]}),f.jsxs("p",{children:["from ",f.jsx("code",{children:e.url})," into ",f.jsx("code",{children:e.parent})]}),r?f.jsx("p",{className:"import-error",children:e.error}):f.jsx("p",{className:"hint",children:"the whole history is cloned, so worktrees, land and graft all work on it straight away."}),f.jsx("div",{className:"status-tail",ref:i,children:e.lines.length===0&&!r?f.jsx("span",{className:"import-idle",children:"starting git…"}):e.lines.map((l,u)=>f.jsx("div",{children:l},u))}),f.jsx("div",{className:"status-actions",children:f.jsx(Pe,{variant:"outline",size:"lg",onClick:o,children:r?"dismiss":"stop"})})]})}const sU=150,iU=/^[^\s@]+@[^\s@]+$/,aU=14,Zb=[];function lU({project:e}){var he;const t=at(),n=st(),{storage:r}=Mr(),o=M(pe=>pe.repos),i=M(pe=>pe.home),l=M(pe=>pe.folderDialog),u=M(pe=>pe.gitIdentity),c=M(pe=>pe.choosingFolder),h=M(pe=>pe.chosenFolder),p=M(pe=>pe.paths),g=M(pe=>pe.agents),m=M(pe=>pe.defaultAgent),y=M(pe=>pe.agentChosen),[w,b]=S.useState({name:"",email:""}),[E,N]=S.useState(null),[j,T]=S.useState(null),O=S.useRef(null),U=S.useRef(null),{mode:Q,name:R,parent:I,prompt:_}=e,L=Q==="clone",z=Q==="init",F=e.phase==="editing",ee=R.trim(),se=z||!ee?null:oc(R),fe=!z&&ee&&!se?sN(I,ee):null,ke=Lm(I,i),ne=fe!==null&&p.query===fe&&((he=p.target)==null?void 0:he.exists)===!0,A=!u&&!L,q=!A||w.name.trim()!==""&&iU.test(w.email.trim()),ie=F&&!E&&(z||ee!==""&&!se&&!ne)&&q&&y,P=g.find(pe=>pe.id===m),[W,xe]=jS(m),[ce,me]=TS(m),_e=(pe,Te)=>{if(pe===m){xe(Te);return}CS(r,pe,Te),n==null||n.send({t:"set-default-agent",agent:pe})};S.useEffect(()=>{if(!fe)return;const pe=setTimeout(()=>n==null?void 0:n.send({t:"browse-path",path:fe}),sU);return()=>clearTimeout(pe)},[fe,n]),yt([e.phase],()=>{var pe;e.phase==="editing"&&((pe=O.current)==null||pe.focus())}),yt([Q,R,I],()=>T(null));const ae=()=>{ie&&(t({a:"open-repo"}),t({a:"new-project-set",v:{phase:"creating"}}),n==null||n.send({t:"create-repo",mode:Q,parent:I.trim(),name:ee,...L&&e.url?{url:e.url}:{},...A?{identity:{name:w.name.trim(),email:w.email.trim()}}:{}}))},be=pe=>{const Te=o.find(Ue=>Ue.path===fc(pe,i));if(Te){t({a:"activate-repo",id:Te.id});return}t({a:"open-repo"}),n==null||n.send({t:"register-repo",path:pe})},ze=pe=>{T(null),l?(t({a:"choosing-folder",v:pe}),n==null||n.send({t:"choose-folder",start:I,purpose:pe})):t(pe==="location"?{a:"open",overlay:{kind:"choose-folder"}}:{a:"open",overlay:{kind:"projects",form:"disk"}})};yt([h==null?void 0:h.seq],()=>{var Te,Ue;if(!c||!h)return;t({a:"choosing-folder",v:!1});const pe=h.folder;if(!pe){(Te=O.current)==null||Te.focus();return}if(c==="open"&&pe.kind==="project"){be(pe.path);return}if(c==="open"&&pe.kind==="folder"){T("that folder has files but is not a project yet; choose a project, or an empty folder to start one");return}if(N(pe.kind==="project"?pe.path:null),pe.kind!=="project"){if(pe.kind==="empty"&&!L){const ct=rN(pe.path);t({a:"new-project-set",v:{mode:"init",parent:ct.parent,name:ct.name}});return}t({a:"new-project-set",v:{mode:L?"clone":"create",parent:pe.path}}),(Ue=O.current)==null||Ue.focus()}});const re=j??(z?"the empty folder you chose becomes the project":E?"the folder you chose is already a project: open it, or choose another":ne?`${ke} already has a folder called ${ee}`:se);return f.jsxs(li,{anchor:"line",children:[L&&f.jsx("p",{className:"new-project-url",children:e.url}),f.jsxs("div",{className:"form-head",children:[z?f.jsx("p",{className:"form-title",children:R}):f.jsx(vo,{ref:O,bare:!0,font:"lead",className:"new-project-field",autoFocus:!0,spellCheck:!1,autoComplete:"off",value:R,placeholder:"Project name",disabled:!F,style:{width:`${Math.max(R.length+1,aU)}ch`},onChange:pe=>t({a:"new-project-set",v:{name:pe.target.value}}),onKeyDown:pe=>{var Te;pe.key==="Enter"&&(pe.preventDefault(),(Te=U.current)==null||Te.focus())}}),f.jsxs("span",{className:"new-project-where",children:[f.jsx("span",{className:"hint",children:"in"}),f.jsx("span",{className:"new-project-parent",...Ft(I),children:ke}),f.jsx(Lt,{icon:"folder",label:l?"Choose in Finder":"Choose a folder",className:"new-project-folder",on:c==="location",disabled:!F,onClick:()=>ze("location")})]})]}),re&&f.jsx("p",{className:"hint",children:re}),f.jsx(_N,{}),f.jsx("div",{className:"form-body",children:f.jsx(Ua,{ref:U,bare:!0,font:"ui",value:_,placeholder:`describe ${ee||"the app"}…`,disabled:!F,onChange:pe=>t({a:"new-project-set",v:{prompt:pe.target.value}}),onKeyDown:pe=>{pe.key!=="Enter"||pe.shiftKey||(pe.preventDefault(),ae())}})}),f.jsxs("div",{className:"hint form-knobs",children:[g.length>1?f.jsx(AS,{agents:g,agent:m,model:W,onChange:_e}):f.jsx(Cm,{models:(P==null?void 0:P.models)??Zb,value:W,onChange:xe}),f.jsx(jm,{efforts:(P==null?void 0:P.efforts)??Zb,value:ce,onChange:me}),E?f.jsx(Pe,{variant:"outline",size:"lg",className:"form-go",autoFocus:!0,onClick:()=>be(E),children:"open it"}):f.jsx(Pe,{variant:"outline",size:"lg",className:"form-go",busy:e.phase==="creating",disabled:!ie,onClick:ae,...Ft(y?L?"Clone the project":_.trim()?"Make it and start on this":"Make the project":"Choose an agent first","⏎"),children:L?"clone":"create"})]}),e.error&&f.jsx("p",{className:"hint",role:"status",children:e.error}),A&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"new-project-identity",children:[f.jsx(vo,{size:"md",font:"ui",rule:!0,value:w.name,placeholder:"Your name",autoComplete:"name",disabled:!F,onChange:pe=>b({...w,name:pe.target.value})}),f.jsx(vo,{size:"md",font:"ui",rule:!0,type:"email",value:w.email,placeholder:"Email",autoComplete:"email",disabled:!F,onChange:pe=>b({...w,email:pe.target.value})})]}),f.jsx("p",{className:"hint",children:"git labels the work you save with these, and asks only once"})]}),!L&&F&&f.jsx(Pe,{tone:"quiet",className:"new-project-open",onClick:()=>ze("open"),children:"or open a folder you already have"})]})}function wa({label:e,hint:t,children:n}){return f.jsxs("label",{className:"form-row",children:[f.jsx("span",{className:"form-label",children:e}),f.jsxs("div",{className:"form-control",children:[n,t&&f.jsx("span",{className:"hint",children:t})]})]})}function cU(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(`
|
|
262
|
+
`)}function uU(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(`
|
|
263
|
+
`)}let dU=1;const Dp=(e,t,n=!1)=>({id:dU++,name:e,cmd:t,shared:n}),fU=[{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 hU({repo:e,onClose:t}){const n=st(),r=Kn(),o=M(ae=>ae.clientId),i=M(ae=>ae.rows.find(be=>{var ze;return On(be)&&be.id===((ze=Da(ae,e.id))==null?void 0:ze.id)})??null),l=M(ae=>{var be;return((be=Da(ae,e.id))==null?void 0:be.id)??null});S.useEffect(()=>{if(!t)return;const ae=be=>be.key==="Escape"&&t();return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[t]);const[u]=S.useState(()=>Object.keys(e.config.run).length>0),[c,h]=S.useState(()=>{const ae=Object.entries(e.config.run).map(([be,ze])=>Dp(be,ux(ze),bj(ze)));return ae.length>0?ae:[Dp("web","")]}),[p,g]=S.useState(()=>(e.config.setup??[]).join(`
|
|
264
|
+
`)),[m,y]=S.useState(()=>(e.config.teardown??[]).join(`
|
|
265
|
+
`)),[w,b]=S.useState(()=>e.config.check??""),[E,N]=S.useState(()=>Oi(e.config).land),[j,T]=S.useState(()=>Oi(e.config).automerge),[O,U]=S.useState(()=>Oi(e.config).merge??"default"),[Q,R]=S.useState(()=>_j(e.configFile)),I=Sj(e.configFile,Q),_=!!e.remote&&E==="pr",L=c.length>1,z=c.some(ae=>ae.name.trim()&&ae.cmd.trim()),ee=!!i&&!t&&!u&&!z,se=(ae,be)=>h(c.map((ze,re)=>re===ae?{...ze,...be}:ze)),fe=ae=>ae.split(`
|
|
266
|
+
`).map(be=>be.trim()).filter(Boolean),ke=()=>fe(p),ne=()=>fe(m),A=()=>{const{check:ae,land:be,teardown:ze,...re}=e.config,he=e.remote?E:Up,pe=O==="default"||he!=="pr"&&O===Hp?void 0:O,Te={...he!==Up?{route:he}:{},...he==="pr"&&j?{automerge:!0}:{},...pe?{method:pe}:{}};return{...re,setup:ke(),...ne().length>0?{teardown:ne()}:{},...w.trim()?{check:w.trim()}:{},...Object.keys(Te).length>0?{land:Te}:{}}},q=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...A(),run:Object.fromEntries(c.filter(ae=>ae.name.trim()&&ae.cmd.trim()).map((ae,be)=>[ae.name.trim(),ae.shared&&be>0?{cmd:ae.cmd.trim(),from:"trunk"}:ae.cmd.trim()]))},kind:Q}),t==null||t()},ie=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...A(),run:{}},kind:Q}),t==null||t()},P=()=>n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:uU(e,I)}),W=e.services,xe=[p,m,...c.map(ae=>ae.cmd)].some(ae=>ae.includes("TOYON_WORKTREE"))||xj(e.config),ce=W?[W.envUrl?`the database at ${W.envUrl.name} in ${W.envUrl.file}`:null,W.compose?`the stack in ${W.compose}`:null].filter(Boolean).join(" and "):"",me=()=>W&&(n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:cU(e,I,W)})),_e=(ae,be)=>f.jsxs("div",{className:"setup-proc",children:[L&&f.jsx(vo,{size:"md",rule:!0,className:"setup-name",value:ae.name,placeholder:"name",...Ft("Process name, shown in the status bar"),onChange:ze=>se(be,{name:ze.target.value})}),f.jsx(vo,{size:"md",rule:!0,className:"setup-cmd",value:ae.cmd,placeholder:"npm run dev",onChange:ze=>se(be,{cmd:ze.target.value})}),L&&f.jsx(Lt,{icon:"close",label:"Remove",onClick:()=>h(c.filter((ze,re)=>re!==be))}),L&&be>0&&f.jsx(YS,{className:"setup-shared",checked:ae.shared,onChange:ze=>se(be,{shared:ze.target.checked}),tip:"Main runs it once for every worktree; a worktree whose changes touch it runs its own",children:"shared from main"})]},ae.id);return f.jsxs(li,{children:[f.jsxs("p",{className:"form-title",children:["how does ",e.name," start?"]}),W&&!xe&&f.jsxs("p",{className:"hint setup-shared-note",children:["Worktrees will share ",ce,", migrations included."," ",f.jsx(Pe,{tone:"quiet",disabled:!i,onClick:me,children:"ask the agent to keep them apart"})]}),f.jsx(wa,{label:"install",hint:"once per new worktree; one command per line",children:f.jsx(Ua,{size:"md",rule:!0,rows:Math.max(1,p.split(`
|
|
267
|
+
`).length),value:p,placeholder:"bun install",onChange:ae=>g(ae.target.value)})}),f.jsx(wa,{label:"remove",hint:"once when a worktree goes, before its directory does; one command per line",children:f.jsx(Ua,{size:"md",rule:!0,rows:Math.max(1,m.split(`
|
|
268
|
+
`).length),value:m,placeholder:'dropdb --if-exists "app_$TOYON_WORKTREE"',onChange:ae=>y(ae.target.value)})}),f.jsx(wa,{label:"check",hint:"runs after each of the agent's turns; the work lands only when it passes",children:f.jsx(vo,{size:"md",rule:!0,value:w,placeholder:"bun run check",onChange:ae=>b(ae.target.value)})}),e.remote&&f.jsx(wa,{label:"land",hint:"where a worktree's finished work goes; one way per repo",children:f.jsxs("div",{className:"setup-land",children:[f.jsx(Js,{value:E,options:Dj.map(ae=>({id:ae.id,label:ae.name,description:ae.description})),onChange:N,hint:"where the work goes",placeholder:"where work lands"}),_&&f.jsx(Js,{value:j?"github":"you",options:Fj.map(ae=>({id:ae.id,label:ae.name,description:ae.description})),onChange:ae=>T(ae==="github"),hint:"who merges the pull request",placeholder:"who merges it"})]})}),f.jsx(wa,{label:"merge",hint:_?"how GitHub merges the pull request; only what the repo allows":"how the commits arrive on main",children:f.jsx(Js,{value:O==="default"&&!_?Hp:O,options:[..._?[{id:"default",label:"what the repo allows",description:"the repo's allowed methods on GitHub: squash, else a merge commit, else rebase"}]:[],...zj.map(ae=>({id:ae.id,label:ae.name,description:ae.description}))],onChange:U,hint:"how the commits arrive on main",placeholder:"how the commits arrive"})}),f.jsx(wa,{label:"start",hint:f.jsxs(f.Fragment,{children:["must listen on ",f.jsx("code",{...Ft("Toyon sets a different port for each worktree"),children:"$PORT"}),e.guess&&l&&f.jsxs(f.Fragment,{children:[" · from ",f.jsx(Pe,{mono:!0,tone:"quiet",...Ft(`open ${e.guess} in the editor pane`),onClick:()=>Ha(r,n,l,e.guess??"",1),children:e.guess})]})]}),children:c[0]&&_e(c[0],0)}),c.slice(1).map((ae,be)=>f.jsxs("div",{className:"form-row",children:[f.jsx("span",{className:"form-label"}),f.jsx("div",{className:"form-control",children:_e(ae,be+1)})]},ae.id)),f.jsxs("div",{className:"form-row",children:[f.jsx("span",{className:"form-label"}),f.jsxs(Pe,{tone:"quiet",onClick:()=>h([...c,Dp("","")]),children:[f.jsx(St,{name:"plus",className:"icon-inline"})," another process"]})]}),f.jsxs("div",{className:"form-knobs",children:[f.jsx(Js,{value:Q,options:fU,onChange:R,hint:"whether the settings file is committed with the repo or kept out of git",placeholder:"committed or kept local"}),f.jsx("span",{className:"form-sign",children:I}),t&&f.jsx(Pe,{onClick:t,children:"cancel"}),(!u||t)&&f.jsx(Pe,{...Ft("This project has no dev server: chat, changes and the terminal work, the preview stays empty"),onClick:ie,children:"no dev server"}),ee&&i?f.jsx(Pe,{variant:"outline",size:"lg",disabled:i.agent!=="idle",...Ft("The agent reads the repo and writes the settings file; the daemon picks it up as soon as it lands"),onClick:P,children:"let the agent work it out"}):f.jsxs(Pe,{variant:"outline",size:"lg",disabled:!z,...t?Ft("Restarts every worktree of this repo. Profiles and other keys in the file are kept."):{},onClick:q,children:[t?"save + restart":"start"," ",f.jsx(St,{name:"forward",className:"icon-inline"})]})]})]})}const pU=1500,mU={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};class gU{constructor(t,n,r=mU){jt(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=Tv(r));const i=Yd(n);if(!i){o.sent=null;return}if(i===o.sent){this.renamed(t,o);return}o.pending=i,o.timer=this.timers.set(()=>{o.timer=null,o.pending=null,o.sent=i,o.sentTitle=o.title,this.send(t,i,o.title)},pU)}title(t,n){const r=this.frame(t);r.title=Tv(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 kU=c1(),yU=2*6e4;function qb(e){e==null||e.setAttribute("src",e.src)}const wU=8e3;function vU({onRoot:e}){const t=S.useRef(null),n=S.useCallback(X=>{t.current=X,e(X)},[e]),r=at(),o=Kn(),i=st(),l=S.useRef(i);l.current=i;const[u]=S.useState(()=>new gU((X,$e,kt)=>{var Nt,Dt;(Nt=l.current)==null||Nt.send({t:"visit",worktreeId:X,path:$e,title:kt}),_1((Dt=o.getState().local[X])==null?void 0:Dt.pages)&&Jt.post(X,{type:"links"})},(X,$e,kt)=>{var Nt;return(Nt=l.current)==null?void 0:Nt.send({t:"page-title",worktreeId:X,path:$e,title:kt})}));S.useEffect(()=>()=>u.dispose(),[u]);const c=V1(),h=Ga(),p=Ss(),g=M(X=>X.connected),m=M(X=>X.heard),y=M(X=>X.connectFailure),w=M(X=>X.remote),{host:b}=Lr(),E=Mr(),N=_o(),j=M(X=>X.editor),T=Q1(),O=cL(),U=vc(),Q=M(X=>X.layout.term)&&!U,R=M(X=>X.focusTerm),I=S.useRef(!1),_=S.useRef(R),L=!I.current||R!==_.current;S.useEffect(()=>{I.current=Q&&!!h,_.current=R});const z=bc(),F=M(X=>X.layout.design)&&!U&&!z,ee=M(X=>X.reloadReq),se=of(),fe=S.useRef(se);fe.current=se;const ke=M(X=>X.zen),ne=M(X=>{var $e;return(($e=X.dragFiles)==null?void 0:$e.at)==="centre"}),A=S.useRef(ke);A.current=ke;const q=At(h,"log"),ie=M(X=>X.incompatible),P=dL(),W=M(X=>{var $e;return(($e=X.overlay)==null?void 0:$e.kind)==="setup"?X.repos.find(kt=>kt.id===X.overlay.repoId)??null:null}),xe=(p==null?void 0:p.worktree.empty)===!0,ce=!!p&&yc(p),me=P&&!xe&&!ce?P:null,_e=me??W,ae=M(X=>X.pending.find($e=>$e.id===X.activeImportId)??null),[be,ze]=S.useState([]),re=S.useRef(new Map),he=S.useRef(new Map),[pe,Te]=S.useState([]),Ue=S.useRef(new Set),ct=S.useRef(new Set),We=S.useRef(X=>qb(re.current.get(X)));S.useEffect(()=>{Jt.post=(X,$e)=>{var kt,Nt;if($e.type==="reload"&&Ue.current.has(X))return We.current(X);(Nt=(kt=re.current.get(X))==null?void 0:kt.contentWindow)==null||Nt.postMessage({__toyon:!0,...$e},he.current.get(X)??"*")},Jt.broadcast=X=>{var $e;for(const[kt,Nt]of re.current)($e=Nt.contentWindow)==null||$e.postMessage({__toyon:!0,...X},he.current.get(kt)??"*")}},[]),S.useEffect(()=>{let X=null;const $e=Dt=>{Dt.target instanceof HTMLElement&&Dt.target.tagName!=="IFRAME"&&(X=Dt.target)},kt=Dt=>{Dt.relatedTarget===null&&setTimeout(()=>{document.activeElement===document.body&&(X=null)},0)},Nt=Dt=>{var an,Mt;if((an=Dt.data)!=null&&an.__toyon)for(const[zt,Vt]of re.current){if(Vt.contentWindow!==Dt.source)continue;if(Dt.origin!==he.current.get(zt))return;const Qe=$O(Dt.data);if(!Qe)return;switch(Qe.type){case"key":window.dispatchEvent(new KeyboardEvent(Qe.up?"keyup":"keydown",{key:Qe.key,code:Qe.code,metaKey:Qe.meta,ctrlKey:!!Qe.ctrl,shiftKey:!!Qe.shift,altKey:!!Qe.alt}));break;case"hmr":r({a:"hmr",id:zt});break;case"loaded":Ue.current.delete(zt),ct.current.add(zt),Te(vn=>vn.includes(zt)?vn:[...vn,zt]),Jt.post(zt,gN(fe.current)),Jt.post(zt,{type:"zen",on:A.current}),r({a:"hmr",id:zt}),r({a:"page",id:zt,url:Qe.url,title:Qe.title,fresh:!0}),u.note(zt,Qe.url,Qe.title);break;case"navigated":r({a:"page",id:zt,url:Qe.url,...Qe.title!==void 0?{title:Qe.title}:{}}),u.note(zt,Qe.url,Qe.title);break;case"title":r({a:"page",id:zt,title:Qe.title}),u.title(zt,Qe.title);break;case"links":r({a:"links",id:zt,links:Qe.links});break;case"page-error":{const vn=Qe.source?` (${Dv(Qe.source)}:${Qe.line??"?"})`:"";r({a:"page",id:zt,error:`${Qe.message}${vn}`});break}case"picked":{const{type:vn,verb:pn,site:Rn,...dn}=Qe,Bt=Rn==="call"?{file:dn.callFile,line:dn.callLine}:{file:dn.file,line:dn.line};if(pn==="code"){r({a:"set-picking",v:!1});const cr=(Mt=rn(o.getState(),zt))==null?void 0:Mt.worktree;Bt.file?Ha(o,i,zt,Dv(Bt.file,cr==null?void 0:cr.path),Bt.line??1):i==null||i.send({t:"find-element",worktreeId:zt,seq:Po(),element:dn.element})}else ZL(o,zt,dn);break}case"pick-cancel":r({a:"set-picking",v:!1});break;case"drag-files":Og(o,o.getState().activeId?{at:"centre"}:null);break;case"drop-files":vE(o,i,o.getState().activeId?{at:"centre"}:null,kP(Qe.files));break;case"focus":Qe.gesture?X=null:document.activeElement===Vt&&(X!=null&&X.isConnected)&&X!==document.body&&X.focus();break;case"highlight-miss":console.warn(`[toyon] highlight miss on ${Qe.path}: ${Qe.fileMatched} elements from this file, ${Qe.withSource} elements with source info on page, ranges=${JSON.stringify(Qe.ranges)}`);break}return}};return window.addEventListener("message",Nt),document.addEventListener("focusin",$e),document.addEventListener("focusout",kt),()=>{window.removeEventListener("message",Nt),document.removeEventListener("focusin",$e),document.removeEventListener("focusout",kt)}},[r,o,i,u]),S.useEffect(()=>{Jt.broadcast({type:"zen",on:ke})},[ke]);const xn=S.useRef(new Map);yt([ee==null?void 0:ee.id,ee==null?void 0:ee.n],()=>{if(!ee)return;const{id:X}=ee;clearTimeout(xn.current.get(X)),xn.current.set(X,setTimeout(()=>{xn.current.delete(X),Jt.post(X,{type:"reload"})},1200))});const Ht=Sg(),It=Ht&&!On(Ht)?Ht:null,nt=Hi(),Ve=!!p&&p.procs.some(X=>X.status==="running"),mt=jg(),En=mt!==null&&mt===h&&Ve;S.useEffect(()=>{mt&&En&&!be.includes(mt)&&ze(X=>[...X,mt])},[mt,En,be]);const Rt=c.filter(X=>On(X)&&X.procs.some($e=>$e.status==="asleep")).map(X=>X.id).join(" ");S.useEffect(()=>{const X=new Set(Rt.split(" ").filter(Boolean));be.some($e=>X.has($e))&&ze($e=>$e.filter(kt=>!X.has(kt)))},[Rt,be]),S.useEffect(()=>{const X=be.filter($e=>$e!==mt).map($e=>setTimeout(()=>ze(kt=>kt.filter(Nt=>Nt!==$e)),yU));return()=>{for(const $e of X)clearTimeout($e)}},[be,mt]),S.useEffect(()=>{Te(X=>X.every($e=>be.includes($e))?X:X.filter($e=>be.includes($e)))},[be]);const V=S.useMemo(()=>c.filter(On).filter(X=>be.includes(X.id)).map(X=>({id:X.worktree.id,port:X.worktree.proxyPort,title:X.worktree.title,url:w1(X.worktree.id,X.worktree.proxyPort,w,b)})),[c,be,w,b]),ge=cm(E,w),ft=xE(E,V,ge);We.current=X=>ge?ft.renew(X):qb(re.current.get(X));const qe=V.filter(X=>{var $e;return($e=c.find(kt=>kt.id===X.id))==null?void 0:$e.procs.some(kt=>kt.status==="running")}).map(X=>X.id).join(" ");yt([qe],()=>{for(const X of qe.split(" "))Ue.current.has(X)&&We.current(X)});const[un,yn]=S.useState(null),[Tn,gt]=S.useState(mt),jn=S.useRef(null);Tn!==mt&&(gt(mt),yn(eU(jn.current,mt,X=>{var $e;return(($e=c.find(kt=>kt.id===X))==null?void 0:$e.repoId)??null}))),S.useEffect(()=>{if(!un)return;const X=setTimeout(()=>yn(null),wU);return()=>clearTimeout(X)},[un]);const ye=mt!==null&&pe.includes(mt),Le=tU({previewId:mt,painted:ye,ready:En,carry:un,mounted:be}),wn=Le!==null&&Le!==mt;S.useEffect(()=>{jn.current=Le});const[_n,Sn]=yo(Ze.editorHeight,0,X=>{const $e=Number(X);return Number.isFinite($e)&&$e>=120?$e:0}),[sn,In]=yo(Ze.designHeight,0,X=>{const $e=Number(X);return Number.isFinite($e)&&$e>0?$e:0}),[ot,Wt]=yo(Ze.designFull,!1,X=>X===null?void 0:X==="1"),[Qt,B]=yo(Ze.editorFull,!1,X=>X===null?void 0:X==="1"),[ue,Ie]=yo(Ze.termHeight,240,X=>{const $e=Number(X);return Number.isFinite($e)&&$e>=140?$e:void 0}),Je=M(X=>X.termTall);yt([Je],()=>{const X=t.current;Je&&X&&Ie(Math.max(ue,Math.round(X.clientHeight/2)))});const Ot=X=>($e,kt)=>{const Nt=kt.parentElement,Dt=t.current;if(!Nt||!Dt)return null;let an=0;for(const zt of Array.from(Dt.querySelectorAll(":scope > .pane")))zt!==Nt&&!zt.classList.contains("full")&&(an+=zt.offsetHeight);const Mt=Math.max(Dt.clientHeight-an-80,X);return Math.min(Math.max(Nt.getBoundingClientRect().bottom-$e.clientY,X),Mt)},$t=Ra(Ot(120),X=>Sn(Math.round(X))),Oe=Ra(Ot(160),X=>In(Math.round(X))),Me=Ra(Ot(140),X=>Ie(Math.round(X))),Ye=M(X=>{var $e,kt;return p&&Ar(p.worktree)?((kt=($e=X.rows.find(Nt=>{var Dt;return Nt.repoId===p.worktree.repoId&&((Dt=Nt.worktree)==null?void 0:Dt.kind)==="worktree"}))==null?void 0:$e.worktree)==null?void 0:kt.title)??null:null}),Pt=r4({connected:g,heard:m,connectFailure:y,hasToken:E.serving?kU:!0,projectChord:Tt("project"),title:(p==null?void 0:p.worktree.title)??null,machine:E.serving?null:N.displayName(E.origin),needsSetup:!!P,busy:ce,treeEmpty:xe,landsFrom:Ye});return f.jsxs("div",{className:"center-root",ref:n,children:[f.jsx("div",{className:Be("center-area",ne&&"drop-over"),style:{display:!(ke&&!z)&&(j&&Qt||F&&ot)?"none":void 0},children:f.jsxs("div",{className:"frames-wrap",children:[V.map(X=>f.jsx("iframe",{ref:$e=>{$e?(re.current.set(X.id,$e),he.current.set(X.id,new URL(X.url).origin)):(re.current.delete(X.id),he.current.delete(X.id),Ue.current.delete(X.id),ct.current.delete(X.id))},onLoad:()=>{ct.current.delete(X.id)?Ue.current.delete(X.id):Ue.current.add(X.id)},src:ft.urlOf(X.id)??void 0,title:X.title,style:{display:X.id===Le&&!_e&&!ae&&!U&&!z?"block":"none"}},X.id)),O?f.jsx(lU,{project:O}):f.jsxs(f.Fragment,{children:[ae&&f.jsx(oU,{pending:ae},ae.id),T&&p&&!ae&&f.jsx(rU,{active:p},p.worktree.id),_e&&!ae&&!T&&f.jsx(hU,{repo:_e,onClose:me?void 0:()=>r({a:"close"})},`${_e.id}:${JSON.stringify(_e.config)}`),It&&!_e&&!ae&&!nt&&f.jsx(Ql,{placement:"centre",found:It},It.id),nt&&!_e&&!ae&&f.jsx(Ql,{placement:"centre",archived:nt},nt.id),!Ve&&!It&&!nt&&!_e&&!ae&&!T&&ie&&f.jsx(CE,{foreign:E.serving?void 0:N.displayName(E.origin)}),!Ve&&!It&&!nt&&!_e&&!ae&&!T&&!ie&&(Pt!==null?f.jsx(li,{wide:!0,children:f.jsx("p",{className:"status-line",children:Pt})}):z?f.jsx(Ql,{placement:"centre"}):wn?null:p&&f.jsx(XB,{worktree:p,log:q}))]})]})}),j&&f.jsx(XS,{editor:j,height:Qt?"100%":_n>0?_n:"45%",full:Qt,onToggleFull:()=>B(!Qt),onDragStart:$t}),F&&h&&!nt&&f.jsx(_B,{worktreeId:h,height:ot?"100%":sn>0?sn:"55%",full:ot,onToggleFull:()=>Wt(!ot),onDragStart:Oe},`design:${h}`),Q&&h&&!nt&&f.jsx(VB,{worktreeId:h,opened:L,height:ue,onDragStart:Me},`term:${h}`),f.jsx(cN,{})]})}function bU({width:e}){const t=M(r=>r.layout.chat),n=vc();return f.jsx(Ql,{placement:"dock",className:!t||n?"collapsed":void 0,width:e})}function xU(e,t){const n=[];return e&&(n.push(oE(e)),n.push({id:"copy-url",label:"copy URL",onClick:()=>Yt(e)})),Mn([n,[{id:"reload",label:"reload preview",key:Tt("reload"),onClick:t.reload}]])}const EU=520,zp=8;function _U({winW:e,centre:t,leadRight:n,toolsLeft:r}){const o=t.right-t.left,i=Math.max(0,Math.min(EU,Math.floor(e*.4),o-2*zp)),l=t.left+(o-i)/2,u=n+zp,c=r-zp-i,h=Math.max(Math.min(l,c),u);return{left:Math.round(h),width:i}}function SU({center:e}){const t=GM(),n=q1(e),r=S.useRef(null);eL(r);const[o,i]=Jv(),[l,u]=Jv(),c=_U({winW:t,centre:n,leadRight:i.right,toolsLeft:u.left}),h=at(),p=st(),g=Kn(),m=on("bar"),y=Ss(),w=bc(),b=M(F=>F.zen)&&!w,E=M(F=>F.layout.changes),N=M(F=>F.layout.chat),j=vc(),T=M(F=>F.layout.design),O=M(F=>{var ee;return((ee=F.overlay)==null?void 0:ee.kind)==="keys"}),U=IU(),Q=(y==null?void 0:y.worktree.id)??null,R=M(F=>F.archivedPage!==null),I=!!y&&yg(y)&&!R,_=M(F=>F.chatSide)==="left",L=!j&&f.jsx(Lt,{icon:"branch",label:"Changes panel",hint:Tt("changes"),tone:"chrome",on:E,onClick:()=>h({a:"toggle-changes"})}),z=!j&&!w&&f.jsx(Lt,{icon:"chat",label:"Chat panel",hint:Tt("composer"),tone:"chrome",on:N,onClick:()=>h({a:"toggle-chat"})});return f.jsxs("div",{className:"top-bar",ref:r,children:[b&&f.jsx("span",{className:"bar-zen-title",children:(y==null?void 0:y.worktree.title)??"Toyon"}),f.jsxs("span",{className:"bar-lead",ref:o,children:[_?z:L,f.jsx(NU,{}),U&&f.jsx(Ef,{icon:"download","data-tip":"Install Toyon as an app (own window, dock icon)",onClick:()=>void U.prompt(),children:"install app"}),f.jsx(jU,{}),f.jsx(CU,{})]}),!w&&f.jsx(TU,{worktreeId:Q,repoId:(y==null?void 0:y.repoId)??null,ready:I,left:c.left,width:c.width}),f.jsx("span",{className:"bar-grow"}),f.jsxs("span",{className:"bar-tools",ref:l,children:[f.jsx(AU,{}),f.jsx(Lt,{icon:"settings",label:"Settings & shortcuts",hint:Tt("keys"),tone:"chrome",on:O,"aria-controls":"keys-help","aria-expanded":O,onClick:()=>h({a:"toggle",overlay:{kind:"keys"}}),...m.contextMenu(()=>uS(g.getState(),{sock:p,dispatch:h}))}),!j&&!w&&f.jsx(Lt,{icon:"palette",label:"Design system",hint:Tt("design"),tone:"chrome",on:T,onClick:()=>h({a:"toggle-design"})}),_?L:z,!w&&f.jsx(Lt,{icon:"zen",className:"bar-zen",label:"Full-bleed preview",hint:Tt("zen"),tone:"chrome",on:b,onClick:()=>h({a:"toggle-zen"})})]})]})}function NU(){const e=at(),t=st(),n=Va(),r=M(p=>p.activeRepoId),o=M(p=>p.repos),i=on("bar"),l=()=>Mn([[{id:"project",label:o.length>1?"switch project…":"open project…",key:Tt("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?wf(n,r,{sock:t,dispatch:e}):[]]),u=M(p=>{var g;return((g=p.overlay)==null?void 0:g.kind)==="projects"&&p.overlay.form==="pill"}),c=M(p=>p.heard),h=M(p=>p.newProject!==null);return f.jsxs("span",{className:"bar-project",children:[f.jsx(Pe,{tone:"chrome",className:"bar-pill",on:u,...Ft(o.length>1?"Switch project":"Open a project",Tt("project")),onClick:()=>e({a:"toggle",overlay:{kind:"projects",form:"pill"}}),...i.contextMenu(l),children:f.jsx("span",{className:"bar-project-name",children:h?"new project":(n==null?void 0:n.name)??(c?"open project":"")})}),u&&f.jsx(xk,{form:"pill"})]})}function TU({worktreeId:e,repoId:t,ready:n,left:r,width:o}){const i=At(e,"page").url,l=RS(i),u=at(),c=M(w=>{var b;return((b=w.overlay)==null?void 0:b.kind)==="routes"}),h=()=>{n&&e&&t&&!c&&u({a:"open",overlay:{kind:"routes"}})};yt([e,n],()=>{c&&u({a:"close"})});const g=on("bar").contextMenu(()=>n?xU(i,{reload:()=>e&&Jt.post(e,{type:"reload"})}):[]),m=M(w=>w.picking),y=jg();return f.jsxs("div",{className:"bar-center",style:{left:r,width:o},children:[f.jsx(Lt,{icon:"back",label:"Back",hint:Tt("back"),disabled:!n,onClick:()=>e&&Jt.post(e,{type:"back"}),...g}),f.jsx(Lt,{icon:"forward",label:"Forward",hint:Tt("forward"),disabled:!n,onClick:()=>e&&Jt.post(e,{type:"forward"}),...g}),f.jsx(Lt,{icon:"reload",label:"Reload preview",hint:Tt("reload"),disabled:!n,onClick:()=>e&&Jt.post(e,{type:"reload"}),...g}),f.jsxs("span",{className:"bar-route",children:[f.jsx(vo,{className:"bar-path",value:n?l:"",readOnly:!0,disabled:!n,placeholder:n?"/":"",onMouseDown:w=>{w.button===0&&w.preventDefault()},onClick:h,onFocus:h,spellCheck:!1,...Ft("Go to a page",Tt("routes"))}),c&&n&&e&&t&&f.jsx($F,{worktreeId:e,repoId:t,url:i},e)]}),f.jsx(Lt,{icon:"inspect",label:"Pick an element to open its code",hint:Tt("inspect"),also:{text:"Add an element to chat",key:Tt("pick")},on:m==="code",disabled:!n||!y,onClick:()=>y&&ac(y,m,u,"code")})]})}function Ef({icon:e,busy:t,children:n,...r}){return f.jsxs(Pe,{disabled:t,...r,children:[!t&&f.jsx(St,{name:e,className:"icon-inline"}),f.jsx("span",{className:Be(t&&"live-text"),children:n})]})}function jU(){const e=M(c=>c.self),t=M(c=>c.rebuilt),n=M(c=>c.repos),r=st(),o=M(c=>{var h;return((h=c.update)==null?void 0:h.restarting)!=null}),i=eN(e,n,t);if(!i||o)return null;const l=i.busy?"rebuilding":i.reload?"reload Toyon":i.build==="rebuild"?"rebuild Toyon":i.build??"restart Toyon",u=()=>{i.reload?window.location.reload():e&&(r==null||r.send(i.build?{t:"run-after-land",repoId:e.repoId}:{t:"restart-daemon"}))};return f.jsx(Ef,{icon:"reload",busy:i.busy,onClick:u,...Ft(i.text,void 0,{detail:i.detail}),children:l})}function CU(){const e=M(o=>o.update),t=M(o=>o.managed.updates),n=st(),r=YP(e);return!r||!t?null:f.jsx(Ef,{icon:"reload",busy:r.busy,onClick:()=>{r.retry&&(n==null||n.send({t:"update-now"}))},...Ft(r.text),children:r.word})}function AU(){const e=at(),t=M(i=>i.remote!==null&&i.frame==="desk"),n=M(i=>i.paired),r=M(i=>{var l;return((l=i.overlay)==null?void 0:l.kind)==="pair"});if(!t)return null;const o=()=>e({a:"toggle",overlay:{kind:"pair"}});return n?f.jsx(Lt,{icon:"phone",label:"Open on your phone",tone:"chrome",on:r,"aria-expanded":r,onClick:o}):f.jsx(Ef,{icon:"phone","aria-expanded":r,onClick:o,...Ft("Scan a code with your phone to open this machine there, signed in"),children:"open on phone"})}function IU(){const[e,t]=S.useState(null);return S.useEffect(()=>{if(tf())return;const n=o=>{o.preventDefault(),t(o)},r=()=>t(null);return window.addEventListener("beforeinstallprompt",n),window.addEventListener("appinstalled",r),()=>{window.removeEventListener("beforeinstallprompt",n),window.removeEventListener("appinstalled",r)}},[]),e}function RU(e,t,n){return t==="left"?n-e.left:e.right-n}const $U="input, textarea, [contenteditable], .monaco-editor, .xterm, iframe";function OU(){const e=Kn(),t=at(),n=st(),r=vc(),o=Wi(),i=bc(),l=M(A=>A.zen)&&!i,u=Hi(),c=!!Tg()||!!u,h=M(A=>A.layout.changes)&&!r,p=M(A=>A.layout.chat)&&!r&&!i&&!c,g=M(A=>A.chatSide),m=M(A=>A.railOpen),[y,w]=yo(Ze.changesWidth,220,A=>A?Bu(Number(A),220):void 0),[b,E]=yo(Ze.chatWidth,380,A=>A?Bu(Number(A),380):void 0),[N,j]=yo(Ze.railWidth,280,A=>A?Bu(Number(A),280):void 0),T=(A,q,ie)=>{const P=q.classList.contains("left")?"left":"right",W=P==="left"?q.previousElementSibling:q.nextElementSibling;return W?Bu(RU(W.getBoundingClientRect(),P,A.clientX),ie):null},O=Ra((A,q)=>T(A,q,220),w),U=Ra((A,q)=>T(A,q,380),E),Q=Ra((A,q)=>T(A,q,280),j),[R,I]=S.useState(null),L=on("app").contextMenu(()=>lS(e.getState(),{sock:n,dispatch:t})),z=f.jsx(VE,{width:y}),F=!i&&!c&&f.jsx(bU,{width:b}),ee=!r&&f.jsx(dN,{width:N}),se=A=>!r&&m&&f.jsx("div",{className:`dock-resize ${A}`,onPointerDown:Q}),fe=g==="left",ke=fe?{dock:F,open:p,drag:U}:{dock:z,open:h,drag:O},ne=fe?{dock:z,open:h,drag:O}:{dock:F,open:p,drag:U};return f.jsxs("div",{className:Be("app",l&&"zen"),"data-chat-side":g,"data-touch":o||void 0,"data-hover":!o||void 0,onContextMenu:A=>{A.defaultPrevented||A.target instanceof Element&&A.target.closest($U)||L.onContextMenu(A)},children:[f.jsx(EE,{}),f.jsx(TE,{}),f.jsx(SU,{center:R}),f.jsxs("div",{className:"docks",children:[fe&&ee,fe&&se("left"),ke.dock,ke.open&&f.jsx("div",{className:"dock-resize left",onPointerDown:ke.drag}),f.jsx(vU,{onRoot:I}),ne.open&&f.jsx("div",{className:"dock-resize right",onPointerDown:ne.drag}),ne.dock,!fe&&se("right"),!fe&&ee]})]})}function MU(e){return e.altKey?"Alt":e.ctrlKey?"Control":e.metaKey?"Meta":null}function LU(e,t){return t==="Alt"?e.altKey:t==="Control"?e.ctrlKey:e.metaKey}const PU=200,DU={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};function zU(e,t=DU){let n=null,r=!1,o=null;const i=()=>{r||(r=!0,e(!0))},l=()=>{o!==null&&(t.clear(o),o=null)},u=()=>{l(),n=null,r&&(r=!1,e(!1))};return{press(c){const h=n!==null;n=MU(c),l(),n&&(h?i():o=t.set(()=>{o=null,i()},PU))},keyup(c){n&&c===n&&u()},mods(c){n&&!LU(c,n)&&u()},end:u}}function FU(e,t,n,r){if(!n)return null;const o=e.findIndex(c=>c.id===n);if(o>=0){const c=e[(o+r+e.length)%e.length];return c&&c.id!==n?{activate:c.id}:null}const i=t.findIndex(c=>c.id===n);if(i<0)return null;const l=t[i+r];if(l)return{activate:l.id};const u=e[e.length-1];return r<0&&u?{activate:u.id}:null}const BU=new Set(["design","chats"]),UU=new Set(["reload","back","forward"]),HU=new Set(["project","commands","keys","zen"]);function WU(){const e=Kn(),t=st();S.useEffect(()=>{const n=zU(p=>e.dispatch({a:"rail-peek",on:p})),r=n.end,o=p=>{e.getState().railOpen||n.press(p)},i=p=>n.keyup(p.key),l=p=>n.mods(p),u=()=>{var y,w;const p=e.getState(),m=((w=(y=document.activeElement)==null?void 0:y.closest("[data-pane]"))==null?void 0:w.dataset.pane)??(p.layout.term?"terminal":p.editor?"editor":p.layout.design?"design":null);m==="terminal"?e.dispatch({a:"toggle-terminal"}):m==="editor"?e.dispatch({a:"close-editor"}):m==="design"&&e.dispatch({a:"toggle-design"})},c=p=>{p.key!=="Escape"||!e.getState().choosingFolder||(p.stopImmediatePropagation(),t==null||t.send({t:"cancel-folder"}),e.dispatch({a:"choosing-folder",v:!1}))},h=p=>{var E,N,j,T;l(p),cj(p)&&!p.defaultPrevented&&p.preventDefault();const g=e.getState(),{dispatch:m}=e,y=O=>{const U=document.activeElement,Q=!U||U===document.body||!!U.closest(".rail, .chat-input");m({a:"activate",id:O}),Q&&m({a:"walked"})},w=lx(p,{guest:!!((E=document.activeElement)!=null&&E.closest(".xterm"))});if(!(g.zen&&!wo(g)&&!g.overlay&&!g.picking&&!(w&&lj.has(w.id))||(w==null?void 0:w.id)==="close"&&!tf()||(N=document.activeElement)!=null&&N.closest(".monaco-editor")&&w&&BU.has(w.id))&&!(w&&pj(w.id,document.activeElement))&&!(w&&UU.has(w.id)&&!(Dl(g)&&xd(g)))){if(w){const O=p.defaultPrevented;if(p.preventDefault(),g.newProject&&!HU.has(w.id))return;switch(w.id){case"worktree":{const U=dj(w.digit,g.visible.length),Q=U===null?void 0:g.visible[U];Q&&y(Q.id);break}case"wt-prev":case"wt-next":{const U=FU(g.visible,g.visibleDiscovered,g.activeId,w.id==="wt-next"?1:-1);U&&y(U.activate),o(p);break}case"wt-unseen-prev":case"wt-unseen-next":{const U=ag(g.visible,g.activeId,w.id==="wt-unseen-next"?1:-1);U&&y(U.activate),o(p);break}case"mark-unread":g.activeId&&!g.draft&&g.visible.some(U=>U.id===g.activeId)&&OE(t,m,g.activeId);break;case"wt-archive":{if(p.repeat||O)break;const U=g.draft||g.archivedPage?void 0:g.visible.find(Q=>Q.id===g.activeId);U&&Pg(t,m).archive(U);break}case"new":m({a:"open-draft"});break;case"project":m({a:"toggle",overlay:{kind:"projects",form:"center"}});break;case"quick-open":((j=g.overlay)==null?void 0:j.kind)==="quick-open"?m({a:"close"}):g.activeId&&m({a:"open",overlay:{kind:"quick-open"}});break;case"routes":((T=g.overlay)==null?void 0:T.kind)==="routes"?m({a:"close"}):xd(g)&&m({a:"open",overlay:{kind:"routes"}});break;case"reload":case"back":case"forward":{const U=Dl(g);U&&Jt.post(U,{type:w.id});break}case"pick":case"inspect":{const U=Dl(g);U&&ac(U,g.picking,m,w.id==="pick"?"chat":"code");break}case"search":g.activeId&&m({a:"toggle",overlay:{kind:"search"}});break;case"refs":g.activeRepoId&&m({a:"toggle",overlay:{kind:"refs"}});break;case"chats":g.activeRepoId&&m({a:"toggle",overlay:{kind:"chats"}});break;case"commands":m({a:"toggle",overlay:{kind:"commands"}});break;case"zen":m({a:"toggle-zen"});break;case"close":!(g.zen&&!wo(g))&&!g.overlay&&u();break;case"changes":m(g.layout.changes&&(za(g)==="changes"||xo(g)!==null)?{a:"toggle-changes"}:{a:"focus-changes",tab:"changes"});break;case"files":m(g.layout.changes&&za(g)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"});break;case"panel-tab-prev":case"panel-tab-next":if(nf(g))break;m(g.layout.changes?{a:"focus-changes",tab:xM(g,w.id==="panel-tab-next"?1:-1)}:{a:"focus-changes"});break;case"composer":m(C1(g));break;case"rail":m(g.railOpen?{a:"toggle-rail"}:{a:"focus-rail"});break;case"keys":m({a:"toggle",overlay:{kind:"keys"}});break;case"terminal":m(g.layout.term?{a:"toggle-terminal"}:{a:"focus-terminal"});break;case"design":m({a:"toggle-design"});break;case"term-tab":{const U=g.rows.find(_=>_.id===g.activeId);if(!U)break;const Q=bo(g,g.activeId).termStream;if(U.login&&Q===bs)break;const R=[ko,...U.login?[bs]:[],...U.procs.map(_=>_.name)],I=R.indexOf(Q);m({a:"term-stream",id:U.id,stream:R[(I+1)%R.length]??ko});break}}}else if(p.key==="Escape")if(g.newProject)g.newProject.phase==="editing"&&m({a:"close-new-project"});else if(g.picking){const O=Dl(g);O&&Jt.post(O,{type:"pick-cancel"}),m({a:"set-picking",v:!1})}else g.archivedPage?m({a:"close-archived"}):g.activeImportId?m({a:"watch-import",id:null}):u()}};return window.addEventListener("keydown",c,!0),window.addEventListener("keydown",h),window.addEventListener("keyup",i),window.addEventListener("pointermove",l),window.addEventListener("pointerdown",l),window.addEventListener("blur",r),()=>{window.removeEventListener("keydown",c,!0),window.removeEventListener("keydown",h),window.removeEventListener("keyup",i),window.removeEventListener("pointermove",l),window.removeEventListener("pointerdown",l),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&&Jt.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 KU=3,ZU=2e3,qU=200,GU=5e3;function VU(){const e=Kn(),t=at(),n=st(),{storage:r}=Mr(),o=Ga(),i=M(W=>W.activeRepoId),l=Ss(),u=Sg(),c=M(W=>W.connected),h=M(W=>W.daylight),p=M(W=>{var xe;return((xe=W.daylight)==null?void 0:xe.until)??0}),g=Hi(),m=M(W=>W.railOpen),y=M(W=>W.chatSide),w=M(W=>W.layouts),b=M(W=>W.lastActive),E=M(W=>W.discoveredOpen),N=M(W=>W.archivedOpen),j=M(W=>W.committedShut),T=M(W=>W.turnOpen),O=M(W=>W.treeOpen),U=of(),Q=M(W=>W.previewTheme!==null),R=M(W=>W.openUrl),I=V1();S.useEffect(()=>Ed.install(window),[]);const _=S.useRef([]);S.useEffect(()=>{if(!n||!c||!o)return;const W=[o,..._.current.filter(xe=>xe!==o)];for(const xe of W.splice(KU))n.send({t:"unsubscribe",worktreeId:xe});_.current.includes(o)||n.send({t:"subscribe",worktreeId:o}),_.current=W},[o,c,n]),S.useEffect(()=>{if(!(!n||!c))for(const W of _.current)n.send({t:"subscribe",worktreeId:W})},[c,n]);const L=S.useRef(void 0);S.useEffect(()=>{if(!n||!c)return;let W;const xe=()=>{const _e=document.visibilityState==="visible"?o:null;n.send({t:"view",worktreeId:_e}),L.current=_e},ce=()=>{clearTimeout(W),W=setTimeout(xe,qU)};L.current===void 0||L.current===o||document.visibilityState!=="visible"?xe():ce();const me=()=>document.visibilityState==="visible"?ce():xe();return document.addEventListener("visibilitychange",me),()=>{clearTimeout(W),document.removeEventListener("visibilitychange",me)}},[o,c,n]);const z=(g==null?void 0:g.id)??null;S.useEffect(()=>{if(!(!n||!c||!z))return n.send({t:"subscribe",worktreeId:z}),()=>n.send({t:"unsubscribe",worktreeId:z})},[z,c,n]),S.useEffect(()=>{const W=new Set(I.map(ce=>ce.id)),xe=_.current.filter(ce=>!W.has(ce));if(xe.length!==0&&(_.current=_.current.filter(ce=>W.has(ce)),!(!n||!c)))for(const ce of xe)n.send({t:"unsubscribe",worktreeId:ce})},[I,c,n]);const F=(g==null?void 0:g.title)??(u==null?void 0:u.name)??null;S.useEffect(()=>{document.title=F?`${F} · Toyon`:"Toyon"},[F]);const ee=!!(l!=null&&l.unseen),se=M(W=>W.unreadHold!==null&&W.unreadHold===W.activeId);S.useEffect(()=>{if(!n||!o||!ee||se)return;let W;const xe=()=>document.visibilityState==="visible"&&document.hasFocus(),ce=()=>{clearTimeout(W),xe()&&(W=setTimeout(()=>{xe()&&n.send({t:"seen",worktreeId:o})},ZU))},me=()=>clearTimeout(W);return ce(),window.addEventListener("focus",ce),window.addEventListener("blur",me),()=>{me(),window.removeEventListener("focus",ce),window.removeEventListener("blur",me)}},[n,o,ee,se]);const fe=S.useRef(0),ke=M(W=>kg(W));S.useEffect(()=>{if(!n||!c||!i)return;const W=()=>{Date.now()-fe.current<GU||(fe.current=Date.now(),n.send({t:"refresh-git",repoId:i}),ke&&ke!==i&&n.send({t:"refresh-git",repoId:ke}))};return window.addEventListener("focus",W),()=>window.removeEventListener("focus",W)},[n,c,i,ke]),S.useEffect(()=>{mN(U,{remember:!Q}),Jt.broadcast(gN(U))},[U,Q]);const ne=S.useCallback(()=>{n==null||n.send({t:"zone",tz:Intl.DateTimeFormat().resolvedOptions().timeZone})},[n]);S.useEffect(()=>{if(!c)return;ne();const W=()=>{document.visibilityState==="visible"&&ne()};return document.addEventListener("visibilitychange",W),()=>document.removeEventListener("visibilitychange",W)},[c,ne]),S.useEffect(()=>{if(!c||p<=Date.now())return;const W=setTimeout(ne,p-Date.now()+1e3);return()=>clearTimeout(W)},[c,p,ne]),S.useEffect(()=>{h&&h.until>0&&vB(h)},[h]),S.useEffect(()=>{o&&r.set(Ze.active,o)},[o,r]);const A=M(W=>W.frame==="phone"?W.screen!=="home":null);S.useEffect(()=>{A!==null&&r.session.set(Ze.phoneRow,A?"1":"0")},[A,r]),S.useEffect(()=>{i&&r.set(Ze.repo,i)},[i,r]),S.useEffect(()=>{try{localStorage.setItem(Ze.rail,m?"1":"0")}catch{}},[m]),S.useEffect(()=>{try{localStorage.setItem(Ze.chatSide,y)}catch{}},[y]),S.useEffect(()=>{try{localStorage.setItem(Ze.layouts,JSON.stringify(w))}catch{}},[w]),S.useEffect(()=>{r.set(Ze.lastActive,JSON.stringify(b))},[b,r]),S.useEffect(()=>{r.set(Ze.discoveredOpen,JSON.stringify(E))},[E,r]),S.useEffect(()=>{r.set(Ze.archivedOpen,JSON.stringify(N))},[N,r]),S.useEffect(()=>{r.set(Ze.committedShut,JSON.stringify(j))},[j,r]),S.useEffect(()=>{r.set(Ze.turnOpen,JSON.stringify(T))},[T,r]),S.useEffect(()=>{r.set(Ze.treeOpen,JSON.stringify(O))},[O,r]),WU(),bP();const q=S.useRef(null);S.useEffect(()=>{!R||q.current===R||(q.current=R,window.open(R,"_blank"),t({a:"opened-url"}))},[R,t]);const ie=S.useRef(null);return yt([o],()=>{var ze,re,he,pe;const W=ie.current;if(ie.current=o,!W||!o||W===o)return;const xe=e.getState(),ce=I.find(Te=>Te.id===W),me=I.find(Te=>Te.id===o),_e=(re=(ze=ce==null?void 0:ce.worktree)==null?void 0:ze.variant)==null?void 0:re.group;if(!_e||((pe=(he=me==null?void 0:me.worktree)==null?void 0:he.variant)==null?void 0:pe.group)!==_e)return;const ae=Te=>{var Ue;try{const ct=(Ue=xe.local[Te])==null?void 0:Ue.page.url;return ct?new URL(ct).pathname+new URL(ct).search:"/"}catch{return"/"}},be=ae(W);be!==ae(o)&&Jt.post(o,{type:"navigate",path:be})}),M(W=>W.frame)==="phone"?f.jsx(dB,{}):f.jsx(OU,{})}const Bm="toyonDepth",SN="toyonOver";function Gb(e){if(e.frame!=="phone"||!e.heard)return null;if(!(e.screen!=="home"&&(rn(e,e.activeId)!==null||xo(e)!==null)))return 0;const n=rn(e,e.activeId)!==null&&!wo(e)&&xo(e)===null;return 1+(e.screen==="changes"||e.screen==="preview"&&n?1:0)+(e.editor?1:0)}const Fp=e=>{const t=e&&typeof e=="object"?e[Bm]:void 0;return typeof t=="number"?t:null},YU=e=>!!e&&typeof e=="object"&&e[SN]===!0;function NN(e,t=window,n=Ed){const r=t.history;let o=Fp(r.state)??0;Fp(r.state)===null&&r.replaceState({[Bm]:0},"");let i=null;const l=()=>{const w=n.open();i&&!w.includes(i)&&(i=null);for(let b=w.length-1;b>=0;b--){const E=w[b];if(E!=null&&E.dismiss&&E!==i)return E}return null};let u=0;const c=()=>{const w=Gb(e.getState());if(w===null)return;const b=w+(l()?1:0);if(b!==o){if(b>o)for(let E=o+1;E<=b;E++)r.pushState({[Bm]:E,[SN]:E>w},"");else r.go(b-o),u++;o=b}};let h=!1;const p=()=>{h||(h=!0,queueMicrotask(()=>{h=!1,c()}))},g=w=>{const b=u>0;b&&u--,o=Fp(w.state)??0;const E=e.getState(),N=Gb(E);if(N===null)return;const j=l(),T=N+(j?1:0);if(T!==o){if(T>o&&j){i=j,n.shut(j);return}if(T>o){const O=o===0?"home":E.editor&&o===N-1?E.screen:"chat";e.dispatch({a:"screen",to:O})}else{if(b&&u>0)return;!b&&T===0&&E.activeId&&!YU(w.state)&&e.dispatch({a:"screen",to:"chat"})}c()}};t.addEventListener("popstate",g);const m=e.subscribe(c),y=n.watch(p);return c(),()=>{t.removeEventListener("popstate",g),m(),y()}}function QU(){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(YT(t.worktreeId,t.stream))??[])n(t)}}}function XU(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 JU(e){const t={};try{const n=JSON.parse(e??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))hM(o)&&(t[r]=o)}catch{}return t}function e7(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 Qu(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 t7(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(i=>typeof i=="string")&&o.length>0&&(t[r]=o)}catch{}return t}const n7=400,r7=2e3;function TN(){const e=new Map;return{another(t,n=0){return(e.get(t)??0)===n?!1:(e.set(t,n),!0)}}}function o7(e,t){const n=new Map,r=new Map,o=TN(),i=c=>{var p,g;clearTimeout((p=r.get(c))==null?void 0:p.timer),r.delete(c);const h=e.getState().local[c];!h||((g=h.mark)==null?void 0:g.by)==="walk"||(n.get(c)??"")!==h.draft&&(n.set(c,h.draft),t.send({t:"set-draft",boxId:c,text:h.draft,clientId:e.getState().clientId}))},l=()=>{for(const c of[...r.keys()])i(c)},u=e.subscribe(()=>{var c,h;for(const[p,g]of Object.entries(e.getState().local)){if(o.another(p,g.sent)&&(clearTimeout((c=r.get(p))==null?void 0:c.timer),r.delete(p),n.set(p,"")),((h=g.mark)==null?void 0:h.by)==="walk"||(n.get(p)??"")===g.draft)continue;if(!g.draft){i(p);continue}const m=r.get(p);if((m==null?void 0:m.text)===g.draft)continue;clearTimeout(m==null?void 0:m.timer);const y=(m==null?void 0:m.since)??Date.now(),w=Math.max(0,Math.min(n7,y+r7-Date.now()));r.set(p,{text:g.draft,timer:setTimeout(i,w,p),since:y})}});return window.addEventListener("focusout",l),window.addEventListener("pagehide",l),{hello(c){n.clear();for(const[h,p]of Object.entries(c))n.set(h,p)},heard(c,h){return r.has(c)?!1:(n.set(c,h),!0)},dispose(){u();for(const c of r.values())clearTimeout(c.timer);r.clear(),window.removeEventListener("focusout",l),window.removeEventListener("pagehide",l)}}}function s7(e,t){const n=new Map,r=new Map,o=TN(),i=e.subscribe(()=>{for(const[l,u]of Object.entries(e.getState().local)){if(o.another(l,u.sent)&&r.set(l,"[]"),n.get(l)===u.attachments)continue;n.set(l,u.attachments);const c=cM(u.attachments),h=JSON.stringify(c);(r.get(l)??"[]")!==h&&(r.set(l,h),t.send({t:"set-attachments",boxId:l,items:c,clientId:e.getState().clientId}))}});return{hello(l){r.clear(),n.clear();for(const[u,c]of Object.entries(l))r.set(u,JSON.stringify(c))},heard(l,u){r.set(l,JSON.stringify(u))},dispose:i}}function i7(e,t){const n=(t.storage??N2)(e.origin),r=WM(mM({cached:t.cached,systemDark:t.systemDark,daylight:t.daylight,storedActive:n.get(Ze.active),storedPhoneRow:n.session.get(Ze.phoneRow)==="1",storedRepo:n.get(Ze.repo),storedRailOpen:Bp(Ze.rail)==="1",storedChatSide:Bp(Ze.chatSide)==="right"?"right":"left",storedLayouts:JU(Bp(Ze.layouts)),storedLastActive:e7(n.get(Ze.lastActive)),storedDiscoveredOpen:Qu(n.get(Ze.discoveredOpen)),storedArchivedOpen:Qu(n.get(Ze.archivedOpen)),storedCommittedShut:Qu(n.get(Ze.committedShut)),storedTurnOpen:Qu(n.get(Ze.turnOpen)),storedTreeOpen:t7(n.get(Ze.treeOpen)),clientId:t.clientId,frame:t.frame,touch:t.touch})),o=QU(),i={version:null,protocol:null},l=a3(m=>r.dispatch({a:"server",msg:m}));let u,c,h;const p=new z2(e,m=>{if(m.t==="hello"){if(i.protocol=m.protocol,e.serving){const{rebuilt:w,update:b}=r.getState(),E=w&&(b==null?void 0:b.restarting)!=null;if(i.version!==null&&(E||m.version!==i.version||m.protocol!==zu)){p.dispose(),t.reload();return}if(m.protocol!==zu){r.dispatch({a:"incompatible"}),p.dispose();return}}else if(m.protocol!==zu){r.dispatch({a:"incompatible"}),p.suspend();return}else r.getState().incompatible&&r.dispatch({a:"incompatible",v:!1});i.version=m.version;const y=new Set(p.sentWhileDown());if(y.size){const w=b=>Object.fromEntries(Object.entries(b).filter(([E])=>!y.has(E)));m.drafts=w(m.drafts),m.attachments=w(m.attachments)}u.hello(m.drafts),c.hello(m.attachments)}if(m.t==="attachments"&&m.clientId!==r.getState().clientId&&c.heard(m.boxId,m.items),!(m.t==="draft"&&m.clientId!==r.getState().clientId&&!u.heard(m.boxId,m.text))){if(kO(m)){o.deliver(m);return}if(yO(m)){if(m.t==="file-written"&&DL(m))return;h.receive(m);return}if(m.t==="loose-written"){x8(m);return}if(yD(m)){xD(r,p,m);return}if(m.t==="open-refused"){bD(r,m);return}l(m)}},(m,y)=>r.dispatch({a:"connected",v:m,failure:y}));UL(r,p.urls),h=new v8({store:r,send:m=>p.send(m),timers:{set:(m,y)=>setTimeout(m,y),clear:m=>clearTimeout(m)},win:window});const g=h.start();return u=o7(r,p),c=s7(r,p),{origin:e.origin,serving:e.serving,token:e.token,get name(){return r.getState().machine??XU(e.origin)},store:r,sock:p,files:h,terminals:o,storage:n,heard:i,boot(m){m.t!=="hello"||m.protocol!==zu||(i.version??(i.version=m.version),c.hello(m.attachments),r.dispatch({a:"server",msg:m}))},dispose(){p.dispose(),g(),u.dispose(),c.dispose()}}}function Bp(e){try{return localStorage.getItem(e)}catch{return null}}function a7(e){const t=new Set,n=e.build({...e.serving,serving:!0}),r=[];let o=n,i=[n];const l=()=>{i=[n,...r];for(const m of t)m()},u=new Map,c=m=>{var w;if(m.serving)return;((w=m.store.getState().remote)==null?void 0:w.front)==="edge"&&m!==o?m.sock.suspend():m.sock.resume()},h=m=>{var w;let y=(w=m.store.getState().remote)==null?void 0:w.front;u.set(m.origin,m.store.subscribe(()=>{var E;const b=(E=m.store.getState().remote)==null?void 0:E.front;b!==y&&(y=b,c(m))}))},p=()=>{var m;return(m=e.persist)==null?void 0:m.call(e,r.map(y=>({origin:y.origin,token:y.token})))};for(const m of e.saved){if(m.origin===n.origin||r.some(w=>w.origin===m.origin))continue;const y=e.build({...m,serving:!1});r.push(y),h(y)}i=[n,...r];const g=()=>i;return{list:g,active:()=>o,get:m=>g().find(y=>y.origin===m)??null,displayName(m){const y=g().find(b=>b.origin===m);return y?g().filter(b=>b.name===y.name).length>1?`${y.name} (${new URL(y.origin).host})`:y.name:m},activate(m){const y=g().find(b=>b.origin===m);if(!y||y===o)return;const w=o;o=y,c(w),c(y),l()},add(m){var b;const y=r.find(E=>E.origin===m.origin);if(m.origin===n.origin)return n;if(y){if(y.token===m.token)return y;(b=u.get(y.origin))==null||b(),y.dispose(),r.splice(r.indexOf(y),1),o===y&&(o=n)}const w=e.build({...m,serving:!1});return r.push(w),h(w),p(),l(),w},remove(m){var w;const y=r.find(b=>b.origin===m);y&&((w=u.get(m))==null||w(),u.delete(m),y.dispose(),y.storage.clear(),r.splice(r.indexOf(y),1),o===y&&(o=n),p(),l())},broadcast(m){for(const y of g())y.store.dispatch(m)},subscribe(m){return t.add(m),()=>t.delete(m)}}}function l7(e){try{const t=JSON.parse(e??"[]");return Array.isArray(t)?t.filter(n=>!!n&&typeof n=="object"&&typeof n.origin=="string"&&/^https?:\/\//.test(n.origin)&&typeof n.token=="string"&&n.token!==""):[]}catch{return[]}}window.__toyonShell=!0;window.top!==window&&(document.documentElement.dataset.framed="");j2(location.origin);const jN=gB();mN(jN);function CN(e,t){try{return e.getItem(t)}catch{return null}}function c7(){const e=CN(sessionStorage,Ze.client);if(e)return e;const t=Math.random().toString(36).slice(2,10);try{sessionStorage.setItem(Ze.client,t)}catch{}return t}const u7={cached:jN,systemDark:kB(),daylight:wB(),clientId:c7(),frame:pN(),touch:pB(),reload:()=>window.location.reload()},ri=a7({serving:{origin:location.origin,token:l1()},saved:l7(CN(localStorage,Ze.machines)),build:e=>i7(e,u7),persist:e=>{try{localStorage.setItem(Ze.machines,JSON.stringify(e))}catch{}}});mB({dispatch:e=>ri.broadcast(e)});bB(e=>ri.broadcast({a:"system-dark",v:e}));let Vb=NN(ri.active().store),Yb=ri.active();ri.subscribe(()=>{const e=ri.active();e!==Yb&&(Yb=e,Vb(),e.store.getState().frame==="phone"&&e.store.dispatch({a:"screen",to:"home"}),Vb=NN(e.store))});window.addEventListener("vite:preloadError",QP);const d7=(window.toyonBoot??Promise.resolve(null)).then(e=>{const t=e;t&&typeof t=="object"&&t.t==="hello"&&ri.active().boot(t)});d7.then(()=>WT.createRoot(document.getElementById("root")).render(f.jsx(DT.StrictMode,{children:f.jsx(Lg,{children:f.jsx(ZM,{machines:ri,children:f.jsx(VU,{})})})})));"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{});export{Ns as F,$m as _,ao as a,sg as b,g7 as c,p7 as d,cx as e,YT as f,Y4 as g,k2 as h,Bg as i,f as j,h7 as k,lx as m,m7 as p,S as r,u2 as s,kc as t,yt as u,Av as w};
|