toyon 0.16.0 → 0.17.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/README.md +1 -1
- package/dist/CHANGELOG.md +35 -0
- package/dist/cli.js +114 -47
- package/dist/daemon.js +1350 -502
- package/dist/shell/assets/{Editor-BATywBIx.js → Editor-BMBnZV2V.js} +175 -175
- package/dist/shell/assets/{XTerm-So8-Vafj.js → XTerm-xxm4nCyN.js} +1 -1
- package/dist/shell/assets/{cssMode-DlHcrkXj.js → cssMode-DRRmIKjD.js} +1 -1
- package/dist/shell/assets/{freemarker2-D3xOnVxc.js → freemarker2-BWXbPnFF.js} +1 -1
- package/dist/shell/assets/{grammar-RZJ5oG33.js → grammar-BlgE3B1J.js} +1 -1
- package/dist/shell/assets/{handlebars-UbIG7080.js → handlebars-swdzvdWB.js} +1 -1
- package/dist/shell/assets/{html-D92eLK6U.js → html-GPVhANjL.js} +1 -1
- package/dist/shell/assets/{htmlMode-DsZIJzoj.js → htmlMode-BTtuR8kD.js} +1 -1
- package/dist/shell/assets/index-9aG0ri4Y.css +1 -0
- package/dist/shell/assets/index-miqqiN7Z.js +269 -0
- package/dist/shell/assets/{javascript-DUkgFtV2.js → javascript-CFXn2iKE.js} +1 -1
- package/dist/shell/assets/{jsonMode-BiIooPg9.js → jsonMode-wmrRCrSu.js} +1 -1
- package/dist/shell/assets/{liquid-DFFjZ5TH.js → liquid-Bz7Svg4V.js} +1 -1
- package/dist/shell/assets/{lspLanguageFeatures-C7Ug4qkg.js → lspLanguageFeatures-BDP4BowE.js} +1 -1
- package/dist/shell/assets/{mdx-DdjSgAuG.js → mdx-CzERTPdi.js} +1 -1
- package/dist/shell/assets/{python-DPUF4OK9.js → python-3OsSAVmo.js} +1 -1
- package/dist/shell/assets/{razor-IRYJ0pOA.js → razor-BKY4SJuy.js} +1 -1
- package/dist/shell/assets/{tsMode-CljE7MPO.js → tsMode-BESW693Z.js} +1 -1
- package/dist/shell/assets/{xml-D8Zv3Gd0.js → xml-SaTEQQ9V.js} +1 -1
- package/dist/shell/assets/{yaml-Dxx9PL0B.js → yaml-gHi84-nk.js} +1 -1
- package/dist/shell/index.html +2 -2
- package/package.json +1 -1
- package/dist/shell/assets/index-BvYzBRq_.css +0 -1
- package/dist/shell/assets/index-CHQwm2uN.js +0 -268
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Editor-BMBnZV2V.js","assets/grammar-BlgE3B1J.js","assets/Editor-CB2SckMT.css","assets/XTerm-xxm4nCyN.js","assets/XTerm-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
var rC=Object.defineProperty;var oC=(e,t,n)=>t in e?rC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Bt=(e,t,n)=>oC(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 i1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ip={exports:{}},ac={},$p={exports:{}},tn={};/**
|
|
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 _v;function sC(){if(_v)return tn;_v=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"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.iterator;function g(z){return z===null||typeof z!="object"?null:(z=m&&z[m]||z["@@iterator"],typeof z=="function"?z:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,b={};function _(z,te,Ee){this.props=z,this.context=te,this.refs=b,this.updater=Ee||w}_.prototype.isReactComponent={},_.prototype.setState=function(z,te){if(typeof z!="object"&&typeof z!="function"&&z!=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,z,te,"setState")},_.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function T(){}T.prototype=_.prototype;function E(z,te,Ee){this.props=z,this.context=te,this.refs=b,this.updater=Ee||w}var N=E.prototype=new T;N.constructor=E,y(N,_.prototype),N.isPureReactComponent=!0;var j=Array.isArray,$=Object.prototype.hasOwnProperty,P={current:null},R={key:!0,ref:!0,__self:!0,__source:!0};function A(z,te,Ee){var Ne,de={},we=null,ae=null;if(te!=null)for(Ne in te.ref!==void 0&&(ae=te.ref),te.key!==void 0&&(we=""+te.key),te)$.call(te,Ne)&&!R.hasOwnProperty(Ne)&&(de[Ne]=te[Ne]);var G=arguments.length-2;if(G===1)de.children=Ee;else if(1<G){for(var ue=Array(G),Le=0;Le<G;Le++)ue[Le]=arguments[Le+2];de.children=ue}if(z&&z.defaultProps)for(Ne in G=z.defaultProps,G)de[Ne]===void 0&&(de[Ne]=G[Ne]);return{$$typeof:e,type:z,key:we,ref:ae,props:de,_owner:P.current}}function O(z,te){return{$$typeof:e,type:z.type,key:te,ref:z.ref,props:z.props,_owner:z._owner}}function B(z){return typeof z=="object"&&z!==null&&z.$$typeof===e}function H(z){var te={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(Ee){return te[Ee]})}var Q=/\/+/g;function re(z,te){return typeof z=="object"&&z!==null&&z.key!=null?H(""+z.key):te.toString(36)}function J(z,te,Ee,Ne,de){var we=typeof z;(we==="undefined"||we==="boolean")&&(z=null);var ae=!1;if(z===null)ae=!0;else switch(we){case"string":case"number":ae=!0;break;case"object":switch(z.$$typeof){case e:case t:ae=!0}}if(ae)return ae=z,de=de(ae),z=Ne===""?"."+re(ae,0):Ne,j(de)?(Ee="",z!=null&&(Ee=z.replace(Q,"$&/")+"/"),J(de,te,Ee,"",function(Le){return Le})):de!=null&&(B(de)&&(de=O(de,Ee+(!de.key||ae&&ae.key===de.key?"":(""+de.key).replace(Q,"$&/")+"/")+z)),te.push(de)),1;if(ae=0,Ne=Ne===""?".":Ne+":",j(z))for(var G=0;G<z.length;G++){we=z[G];var ue=Ne+re(we,G);ae+=J(we,te,Ee,ue,de)}else if(ue=g(z),typeof ue=="function")for(z=ue.call(z),G=0;!(we=z.next()).done;)we=we.value,ue=Ne+re(we,G++),ae+=J(we,te,Ee,ue,de);else if(we==="object")throw te=String(z),Error("Objects are not valid as a React child (found: "+(te==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":te)+"). If you meant to render a collection of children, use an array instead.");return ae}function ie(z,te,Ee){if(z==null)return z;var Ne=[],de=0;return J(z,Ne,"","",function(we){return te.call(Ee,we,de++)}),Ne}function ve(z){if(z._status===-1){var te=z._result;te=te(),te.then(function(Ee){(z._status===0||z._status===-1)&&(z._status=1,z._result=Ee)},function(Ee){(z._status===0||z._status===-1)&&(z._status=2,z._result=Ee)}),z._status===-1&&(z._status=0,z._result=te)}if(z._status===1)return z._result.default;throw z._result}var C={current:null},Z={transition:null},Y={ReactCurrentDispatcher:C,ReactCurrentBatchConfig:Z,ReactCurrentOwner:P};function q(){throw Error("act(...) is not supported in production builds of React.")}return tn.Children={map:ie,forEach:function(z,te,Ee){ie(z,function(){te.apply(this,arguments)},Ee)},count:function(z){var te=0;return ie(z,function(){te++}),te},toArray:function(z){return ie(z,function(te){return te})||[]},only:function(z){if(!B(z))throw Error("React.Children.only expected to receive a single React element child.");return z}},tn.Component=_,tn.Fragment=n,tn.Profiler=o,tn.PureComponent=E,tn.StrictMode=r,tn.Suspense=u,tn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Y,tn.act=q,tn.cloneElement=function(z,te,Ee){if(z==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+z+".");var Ne=y({},z.props),de=z.key,we=z.ref,ae=z._owner;if(te!=null){if(te.ref!==void 0&&(we=te.ref,ae=P.current),te.key!==void 0&&(de=""+te.key),z.type&&z.type.defaultProps)var G=z.type.defaultProps;for(ue in te)$.call(te,ue)&&!R.hasOwnProperty(ue)&&(Ne[ue]=te[ue]===void 0&&G!==void 0?G[ue]:te[ue])}var ue=arguments.length-2;if(ue===1)Ne.children=Ee;else if(1<ue){G=Array(ue);for(var Le=0;Le<ue;Le++)G[Le]=arguments[Le+2];Ne.children=G}return{$$typeof:e,type:z.type,key:de,ref:we,props:Ne,_owner:ae}},tn.createContext=function(z){return z={$$typeof:l,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},z.Provider={$$typeof:i,_context:z},z.Consumer=z},tn.createElement=A,tn.createFactory=function(z){var te=A.bind(null,z);return te.type=z,te},tn.createRef=function(){return{current:null}},tn.forwardRef=function(z){return{$$typeof:c,render:z}},tn.isValidElement=B,tn.lazy=function(z){return{$$typeof:h,_payload:{_status:-1,_result:z},_init:ve}},tn.memo=function(z,te){return{$$typeof:p,type:z,compare:te===void 0?null:te}},tn.startTransition=function(z){var te=Z.transition;Z.transition={};try{z()}finally{Z.transition=te}},tn.unstable_act=q,tn.useCallback=function(z,te){return C.current.useCallback(z,te)},tn.useContext=function(z){return C.current.useContext(z)},tn.useDebugValue=function(){},tn.useDeferredValue=function(z){return C.current.useDeferredValue(z)},tn.useEffect=function(z,te){return C.current.useEffect(z,te)},tn.useId=function(){return C.current.useId()},tn.useImperativeHandle=function(z,te,Ee){return C.current.useImperativeHandle(z,te,Ee)},tn.useInsertionEffect=function(z,te){return C.current.useInsertionEffect(z,te)},tn.useLayoutEffect=function(z,te){return C.current.useLayoutEffect(z,te)},tn.useMemo=function(z,te){return C.current.useMemo(z,te)},tn.useReducer=function(z,te,Ee){return C.current.useReducer(z,te,Ee)},tn.useRef=function(z){return C.current.useRef(z)},tn.useState=function(z){return C.current.useState(z)},tn.useSyncExternalStore=function(z,te,Ee){return C.current.useSyncExternalStore(z,te,Ee)},tn.useTransition=function(){return C.current.useTransition()},tn.version="18.3.1",tn}var Nv;function Ig(){return Nv||(Nv=1,$p.exports=sC()),$p.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 Tv;function iC(){if(Tv)return ac;Tv=1;var e=Ig(),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(c,u,p){var h,m={},g=null,w=null;p!==void 0&&(g=""+p),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(w=u.ref);for(h in u)r.call(u,h)&&!i.hasOwnProperty(h)&&(m[h]=u[h]);if(c&&c.defaultProps)for(h in u=c.defaultProps,u)m[h]===void 0&&(m[h]=u[h]);return{$$typeof:t,type:c,key:g,ref:w,props:m,_owner:o.current}}return ac.Fragment=n,ac.jsx=l,ac.jsxs=l,ac}var jv;function aC(){return jv||(jv=1,Ip.exports=iC()),Ip.exports}var d=aC(),S=Ig();const lC=i1(S);var Rp={exports:{}},Xr={},Op={exports:{}},Mp={};/**
|
|
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 Cv;function cC(){return Cv||(Cv=1,(function(e){function t(Z,Y){var q=Z.length;Z.push(Y);e:for(;0<q;){var z=q-1>>>1,te=Z[z];if(0<o(te,Y))Z[z]=Y,Z[q]=te,q=z;else break e}}function n(Z){return Z.length===0?null:Z[0]}function r(Z){if(Z.length===0)return null;var Y=Z[0],q=Z.pop();if(q!==Y){Z[0]=q;e:for(var z=0,te=Z.length,Ee=te>>>1;z<Ee;){var Ne=2*(z+1)-1,de=Z[Ne],we=Ne+1,ae=Z[we];if(0>o(de,q))we<te&&0>o(ae,de)?(Z[z]=ae,Z[we]=q,z=we):(Z[z]=de,Z[Ne]=q,z=Ne);else if(we<te&&0>o(ae,q))Z[z]=ae,Z[we]=q,z=we;else break e}}return Y}function o(Z,Y){var q=Z.sortIndex-Y.sortIndex;return q!==0?q:Z.id-Y.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,c=l.now();e.unstable_now=function(){return l.now()-c}}var u=[],p=[],h=1,m=null,g=3,w=!1,y=!1,b=!1,_=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function N(Z){for(var Y=n(p);Y!==null;){if(Y.callback===null)r(p);else if(Y.startTime<=Z)r(p),Y.sortIndex=Y.expirationTime,t(u,Y);else break;Y=n(p)}}function j(Z){if(b=!1,N(Z),!y)if(n(u)!==null)y=!0,ve($);else{var Y=n(p);Y!==null&&C(j,Y.startTime-Z)}}function $(Z,Y){y=!1,b&&(b=!1,T(A),A=-1),w=!0;var q=g;try{for(N(Y),m=n(u);m!==null&&(!(m.expirationTime>Y)||Z&&!H());){var z=m.callback;if(typeof z=="function"){m.callback=null,g=m.priorityLevel;var te=z(m.expirationTime<=Y);Y=e.unstable_now(),typeof te=="function"?m.callback=te:m===n(u)&&r(u),N(Y)}else r(u);m=n(u)}if(m!==null)var Ee=!0;else{var Ne=n(p);Ne!==null&&C(j,Ne.startTime-Y),Ee=!1}return Ee}finally{m=null,g=q,w=!1}}var P=!1,R=null,A=-1,O=5,B=-1;function H(){return!(e.unstable_now()-B<O)}function Q(){if(R!==null){var Z=e.unstable_now();B=Z;var Y=!0;try{Y=R(!0,Z)}finally{Y?re():(P=!1,R=null)}}else P=!1}var re;if(typeof E=="function")re=function(){E(Q)};else if(typeof MessageChannel<"u"){var J=new MessageChannel,ie=J.port2;J.port1.onmessage=Q,re=function(){ie.postMessage(null)}}else re=function(){_(Q,0)};function ve(Z){R=Z,P||(P=!0,re())}function C(Z,Y){A=_(function(){Z(e.unstable_now())},Y)}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(Z){Z.callback=null},e.unstable_continueExecution=function(){y||w||(y=!0,ve($))},e.unstable_forceFrameRate=function(Z){0>Z||125<Z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<Z?Math.floor(1e3/Z):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(Z){switch(g){case 1:case 2:case 3:var Y=3;break;default:Y=g}var q=g;g=Y;try{return Z()}finally{g=q}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(Z,Y){switch(Z){case 1:case 2:case 3:case 4:case 5:break;default:Z=3}var q=g;g=Z;try{return Y()}finally{g=q}},e.unstable_scheduleCallback=function(Z,Y,q){var z=e.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?z+q:z):q=z,Z){case 1:var te=-1;break;case 2:te=250;break;case 5:te=1073741823;break;case 4:te=1e4;break;default:te=5e3}return te=q+te,Z={id:h++,callback:Y,priorityLevel:Z,startTime:q,expirationTime:te,sortIndex:-1},q>z?(Z.sortIndex=q,t(p,Z),n(u)===null&&Z===n(p)&&(b?(T(A),A=-1):b=!0,C(j,q-z))):(Z.sortIndex=te,t(u,Z),y||w||(y=!0,ve($))),Z},e.unstable_shouldYield=H,e.unstable_wrapCallback=function(Z){var Y=g;return function(){var q=g;g=Y;try{return Z.apply(this,arguments)}finally{g=q}}}})(Mp)),Mp}var Av;function uC(){return Av||(Av=1,Op.exports=cC()),Op.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 Iv;function dC(){if(Iv)return Xr;Iv=1;var e=Ig(),t=uC();function n(s){for(var a="https://reactjs.org/docs/error-decoder.html?invariant="+s,f=1;f<arguments.length;f++)a+="&args[]="+encodeURIComponent(arguments[f]);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 c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,p=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,h={},m={};function g(s){return u.call(m,s)?!0:u.call(h,s)?!1:p.test(s)?m[s]=!0:(h[s]=!0,!1)}function w(s,a,f,k){if(f!==null&&f.type===0)return!1;switch(typeof a){case"function":case"symbol":return!0;case"boolean":return k?!1:f!==null?!f.acceptsBooleans:(s=s.toLowerCase().slice(0,5),s!=="data-"&&s!=="aria-");default:return!1}}function y(s,a,f,k){if(a===null||typeof a>"u"||w(s,a,f,k))return!0;if(k)return!1;if(f!==null)switch(f.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,f,k,v,x,I){this.acceptsBooleans=a===2||a===3||a===4,this.attributeName=k,this.attributeNamespace=v,this.mustUseProperty=f,this.propertyName=s,this.type=a,this.sanitizeURL=x,this.removeEmptyString=I}var _={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(s){_[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];_[a]=new b(a,1,!1,s[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(s){_[s]=new b(s,2,!1,s.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(s){_[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){_[s]=new b(s,3,!1,s.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(s){_[s]=new b(s,3,!0,s,null,!1,!1)}),["capture","download"].forEach(function(s){_[s]=new b(s,4,!1,s,null,!1,!1)}),["cols","rows","size","span"].forEach(function(s){_[s]=new b(s,6,!1,s,null,!1,!1)}),["rowSpan","start"].forEach(function(s){_[s]=new b(s,5,!1,s.toLowerCase(),null,!1,!1)});var T=/[\-:]([a-z])/g;function E(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(T,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(T,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(T,E);_[a]=new b(a,1,!1,s,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(s){_[s]=new b(s,1,!1,s.toLowerCase(),null,!1,!1)}),_.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(s){_[s]=new b(s,1,!1,s.toLowerCase(),null,!0,!0)});function N(s,a,f,k){var v=_.hasOwnProperty(a)?_[a]:null;(v!==null?v.type!==0:k||!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(y(a,f,v,k)&&(f=null),k||v===null?g(a)&&(f===null?s.removeAttribute(a):s.setAttribute(a,""+f)):v.mustUseProperty?s[v.propertyName]=f===null?v.type===3?!1:"":f:(a=v.attributeName,k=v.attributeNamespace,f===null?s.removeAttribute(a):(v=v.type,f=v===3||v===4&&f===!0?"":""+f,k?s.setAttributeNS(k,a,f):s.setAttribute(a,f))))}var j=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,$=Symbol.for("react.element"),P=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),O=Symbol.for("react.profiler"),B=Symbol.for("react.provider"),H=Symbol.for("react.context"),Q=Symbol.for("react.forward_ref"),re=Symbol.for("react.suspense"),J=Symbol.for("react.suspense_list"),ie=Symbol.for("react.memo"),ve=Symbol.for("react.lazy"),C=Symbol.for("react.offscreen"),Z=Symbol.iterator;function Y(s){return s===null||typeof s!="object"?null:(s=Z&&s[Z]||s["@@iterator"],typeof s=="function"?s:null)}var q=Object.assign,z;function te(s){if(z===void 0)try{throw Error()}catch(f){var a=f.stack.trim().match(/\n( *(at )?)/);z=a&&a[1]||""}return`
|
|
35
|
+
`+z+s}var Ee=!1;function Ne(s,a){if(!s||Ee)return"";Ee=!0;var f=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(he){var k=he}Reflect.construct(s,[],a)}else{try{a.call()}catch(he){k=he}s.call(a.prototype)}else{try{throw Error()}catch(he){k=he}s()}}catch(he){if(he&&k&&typeof he.stack=="string"){for(var v=he.stack.split(`
|
|
36
|
+
`),x=k.stack.split(`
|
|
37
|
+
`),I=v.length-1,W=x.length-1;1<=I&&0<=W&&v[I]!==x[W];)W--;for(;1<=I&&0<=W;I--,W--)if(v[I]!==x[W]){if(I!==1||W!==1)do if(I--,W--,0>W||v[I]!==x[W]){var X=`
|
|
38
|
+
`+v[I].replace(" at new "," at ");return s.displayName&&X.includes("<anonymous>")&&(X=X.replace("<anonymous>",s.displayName)),X}while(1<=I&&0<=W);break}}}finally{Ee=!1,Error.prepareStackTrace=f}return(s=s?s.displayName||s.name:"")?te(s):""}function de(s){switch(s.tag){case 5:return te(s.type);case 16:return te("Lazy");case 13:return te("Suspense");case 19:return te("SuspenseList");case 0:case 2:case 15:return s=Ne(s.type,!1),s;case 11:return s=Ne(s.type.render,!1),s;case 1:return s=Ne(s.type,!0),s;default:return""}}function we(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 P:return"Portal";case O:return"Profiler";case A:return"StrictMode";case re:return"Suspense";case J:return"SuspenseList"}if(typeof s=="object")switch(s.$$typeof){case H:return(s.displayName||"Context")+".Consumer";case B:return(s._context.displayName||"Context")+".Provider";case Q:var a=s.render;return s=s.displayName,s||(s=a.displayName||a.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case ie:return a=s.displayName||null,a!==null?a:we(s.type)||"Memo";case ve:a=s._payload,s=s._init;try{return we(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 we(a);case 8:return a===A?"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 G(s){switch(typeof s){case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function ue(s){var a=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function Le(s){var a=ue(s)?"checked":"value",f=Object.getOwnPropertyDescriptor(s.constructor.prototype,a),k=""+s[a];if(!s.hasOwnProperty(a)&&typeof f<"u"&&typeof f.get=="function"&&typeof f.set=="function"){var v=f.get,x=f.set;return Object.defineProperty(s,a,{configurable:!0,get:function(){return v.call(this)},set:function(I){k=""+I,x.call(this,I)}}),Object.defineProperty(s,a,{enumerable:f.enumerable}),{getValue:function(){return k},setValue:function(I){k=""+I},stopTracking:function(){s._valueTracker=null,delete s[a]}}}}function ke(s){s._valueTracker||(s._valueTracker=Le(s))}function ne(s){if(!s)return!1;var a=s._valueTracker;if(!a)return!0;var f=a.getValue(),k="";return s&&(k=ue(s)?s.checked?"true":"false":s.value),s=k,s!==f?(a.setValue(s),!0):!1}function ge(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 je(s,a){var f=a.checked;return q({},a,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:f??s._wrapperState.initialChecked})}function Ce(s,a){var f=a.defaultValue==null?"":a.defaultValue,k=a.checked!=null?a.checked:a.defaultChecked;f=G(a.value!=null?a.value:f),s._wrapperState={initialChecked:k,initialValue:f,controlled:a.type==="checkbox"||a.type==="radio"?a.checked!=null:a.value!=null}}function Se(s,a){a=a.checked,a!=null&&N(s,"checked",a,!1)}function Me(s,a){Se(s,a);var f=G(a.value),k=a.type;if(f!=null)k==="number"?(f===0&&s.value===""||s.value!=f)&&(s.value=""+f):s.value!==""+f&&(s.value=""+f);else if(k==="submit"||k==="reset"){s.removeAttribute("value");return}a.hasOwnProperty("value")?on(s,a.type,f):a.hasOwnProperty("defaultValue")&&on(s,a.type,G(a.defaultValue)),a.checked==null&&a.defaultChecked!=null&&(s.defaultChecked=!!a.defaultChecked)}function wt(s,a,f){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,f||a===s.value||(s.value=a),s.defaultValue=a}f=s.name,f!==""&&(s.name=""),s.defaultChecked=!!s._wrapperState.initialChecked,f!==""&&(s.name=f)}function on(s,a,f){(a!=="number"||ge(s.ownerDocument)!==s)&&(f==null?s.defaultValue=""+s._wrapperState.initialValue:s.defaultValue!==""+f&&(s.defaultValue=""+f))}var St=Array.isArray;function Yt(s,a,f,k){if(s=s.options,a){a={};for(var v=0;v<f.length;v++)a["$"+f[v]]=!0;for(f=0;f<s.length;f++)v=a.hasOwnProperty("$"+s[f].value),s[f].selected!==v&&(s[f].selected=v),v&&k&&(s[f].defaultSelected=!0)}else{for(f=""+G(f),a=null,v=0;v<s.length;v++){if(s[v].value===f){s[v].selected=!0,k&&(s[v].defaultSelected=!0);return}a!==null||s[v].disabled||(a=s[v])}a!==null&&(a.selected=!0)}}function zt(s,a){if(a.dangerouslySetInnerHTML!=null)throw Error(n(91));return q({},a,{value:void 0,defaultValue:void 0,children:""+s._wrapperState.initialValue})}function Ht(s,a){var f=a.value;if(f==null){if(f=a.children,a=a.defaultValue,f!=null){if(a!=null)throw Error(n(92));if(St(f)){if(1<f.length)throw Error(n(93));f=f[0]}a=f}a==null&&(a=""),f=a}s._wrapperState={initialValue:G(f)}}function De(s,a){var f=G(a.value),k=G(a.defaultValue);f!=null&&(f=""+f,f!==s.value&&(s.value=f),a.defaultValue==null&&s.defaultValue!==f&&(s.defaultValue=f)),k!=null&&(s.defaultValue=""+k)}function _t(s){var a=s.textContent;a===s._wrapperState.initialValue&&a!==""&&a!==null&&(s.value=a)}function sn(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 ln(s,a){return s==null||s==="http://www.w3.org/1999/xhtml"?sn(a):s==="http://www.w3.org/2000/svg"&&a==="foreignObject"?"http://www.w3.org/1999/xhtml":s}var lt,jt=(function(s){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(a,f,k,v){MSApp.execUnsafeLocalFunction(function(){return s(a,f,k,v)})}:s})(function(s,a){if(s.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in s)s.innerHTML=a;else{for(lt=lt||document.createElement("div"),lt.innerHTML="<svg>"+a.valueOf().toString()+"</svg>",a=lt.firstChild;s.firstChild;)s.removeChild(s.firstChild);for(;a.firstChild;)s.appendChild(a.firstChild)}});function Kt(s,a){if(a){var f=s.firstChild;if(f&&f===s.lastChild&&f.nodeType===3){f.nodeValue=a;return}}s.textContent=a}var xn={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},Pt=["Webkit","ms","Moz","O"];Object.keys(xn).forEach(function(s){Pt.forEach(function(a){a=a+s.charAt(0).toUpperCase()+s.substring(1),xn[a]=xn[s]})});function jn(s,a,f){return a==null||typeof a=="boolean"||a===""?"":f||typeof a!="number"||a===0||xn.hasOwnProperty(s)&&xn[s]?(""+a).trim():a+"px"}function Qt(s,a){s=s.style;for(var f in a)if(a.hasOwnProperty(f)){var k=f.indexOf("--")===0,v=jn(f,a[f],k);f==="float"&&(f="cssFloat"),k?s.setProperty(f,v):s[f]=v}}var V=q({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 pe(s,a){if(a){if(V[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 Ye(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 nt=null;function yt(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var Jt=null,ye=null,Ie=null;function Xt(s){if(s=Zl(s)){if(typeof Jt!="function")throw Error(n(280));var a=s.stateNode;a&&(a=$u(a),Jt(s.stateNode,s.type,a))}}function U(s){ye?Ie?Ie.push(s):Ie=[s]:ye=s}function me(){if(ye){var s=ye,a=Ie;if(Ie=ye=null,Xt(s),a)for(s=0;s<a.length;s++)Xt(a[s])}}function ze(s,a){return s(a)}function Xe(){}var Mt=!1;function Nt(s,a,f){if(Mt)return s(a,f);Mt=!0;try{return ze(s,a,f)}finally{Mt=!1,(ye!==null||Ie!==null)&&(Xe(),me())}}function He(s,a){var f=s.stateNode;if(f===null)return null;var k=$u(f);if(k===null)return null;f=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(f&&typeof f!="function")throw Error(n(231,a,typeof f));return f}var Fe=!1;if(c)try{var Ke={};Object.defineProperty(Ke,"passive",{get:function(){Fe=!0}}),window.addEventListener("test",Ke,Ke),window.removeEventListener("test",Ke,Ke)}catch{Fe=!1}function ht(s,a,f,k,v,x,I,W,X){var he=Array.prototype.slice.call(arguments,3);try{a.apply(f,he)}catch(Oe){this.onError(Oe)}}var Ct=!1,Ft=null,Zt=!1,bn=null,On={onError:function(s){Ct=!0,Ft=s}};function Cn(s,a,f,k,v,x,I,W,X){Ct=!1,Ft=null,ht.apply(On,arguments)}function Xn(s,a,f,k,v,x,I,W,X){if(Cn.apply(this,arguments),Ct){if(Ct){var he=Ft;Ct=!1,Ft=null}else throw Error(n(198));Zt||(Zt=!0,bn=he)}}function Hn(s){var a=s,f=s;if(s.alternate)for(;a.return;)a=a.return;else{s=a;do a=s,(a.flags&4098)!==0&&(f=a.return),s=a.return;while(s)}return a.tag===3?f:null}function se(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 _e(s){if(Hn(s)!==s)throw Error(n(188))}function at(s){var a=s.alternate;if(!a){if(a=Hn(s),a===null)throw Error(n(188));return a!==s?null:s}for(var f=s,k=a;;){var v=f.return;if(v===null)break;var x=v.alternate;if(x===null){if(k=v.return,k!==null){f=k;continue}break}if(v.child===x.child){for(x=v.child;x;){if(x===f)return _e(v),s;if(x===k)return _e(v),a;x=x.sibling}throw Error(n(188))}if(f.return!==k.return)f=v,k=x;else{for(var I=!1,W=v.child;W;){if(W===f){I=!0,f=v,k=x;break}if(W===k){I=!0,k=v,f=x;break}W=W.sibling}if(!I){for(W=x.child;W;){if(W===f){I=!0,f=x,k=v;break}if(W===k){I=!0,k=x,f=v;break}W=W.sibling}if(!I)throw Error(n(189))}}if(f.alternate!==k)throw Error(n(190))}if(f.tag!==3)throw Error(n(188));return f.stateNode.current===f?s:a}function mt(s){return s=at(s),s!==null?Wt(s):null}function Wt(s){if(s.tag===5||s.tag===6)return s;for(s=s.child;s!==null;){var a=Wt(s);if(a!==null)return a;s=s.sibling}return null}var kn=t.unstable_scheduleCallback,wn=t.unstable_cancelCallback,tr=t.unstable_shouldYield,fn=t.unstable_requestPaint,hn=t.unstable_now,Tt=t.unstable_getCurrentPriorityLevel,zr=t.unstable_ImmediatePriority,pt=t.unstable_UserBlockingPriority,In=t.unstable_NormalPriority,Te=t.unstable_LowPriority,Ge=t.unstable_IdlePriority,rt=null,et=null;function cn(s){if(et&&typeof et.onCommitFiberRoot=="function")try{et.onCommitFiberRoot(rt,s,void 0,(s.current.flags&128)===128)}catch{}}var yn=Math.clz32?Math.clz32:K,ar=Math.log,Fr=Math.LN2;function K(s){return s>>>=0,s===0?32:31-(ar(s)/Fr|0)|0}var fe=64,Qe=4194304;function At(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 gt(s,a){var f=s.pendingLanes;if(f===0)return 0;var k=0,v=s.suspendedLanes,x=s.pingedLanes,I=f&268435455;if(I!==0){var W=I&~v;W!==0?k=At(W):(x&=I,x!==0&&(k=At(x)))}else I=f&~v,I!==0?k=At(I):x!==0&&(k=At(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|=f&16),a=s.entangledLanes,a!==0)for(s=s.entanglements,a&=k;0<a;)f=31-yn(a),v=1<<f,k|=s[f],a&=~v;return k}function qt(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 Br(s,a){for(var f=s.suspendedLanes,k=s.pingedLanes,v=s.expirationTimes,x=s.pendingLanes;0<x;){var I=31-yn(x),W=1<<I,X=v[I];X===-1?((W&f)===0||(W&k)!==0)&&(v[I]=qt(W,a)):X<=a&&(s.expiredLanes|=W),x&=~W}}function hr(s){return s=s.pendingLanes&-1073741825,s!==0?s:s&1073741824?1073741824:0}function vo(){var s=fe;return fe<<=1,(fe&4194240)===0&&(fe=64),s}function Nr(s){for(var a=[],f=0;31>f;f++)a.push(s);return a}function xr(s,a,f){s.pendingLanes|=a,a!==536870912&&(s.suspendedLanes=0,s.pingedLanes=0),s=s.eventTimes,a=31-yn(a),s[a]=f}function nr(s,a){var f=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<f;){var v=31-yn(f),x=1<<v;a[v]=0,k[v]=-1,s[v]=-1,f&=~x}}function ao(s,a){var f=s.entangledLanes|=a;for(s=s.entanglements;f;){var k=31-yn(f),v=1<<k;v&a|s[k]&a&&(s[k]|=a),f&=~v}}var Gt=0;function vt(s){return s&=-s,1<s?4<s?(s&268435455)!==0?16:536870912:4:1}var fs,En,un,Tr,pr,Re=!1,L=[],D=null,oe=null,be=null,Ae=new Map,Ve=new Map,It=[],rn="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 Wn(s,a){switch(s){case"focusin":case"focusout":D=null;break;case"dragenter":case"dragleave":oe=null;break;case"mouseover":case"mouseout":be=null;break;case"pointerover":case"pointerout":Ae.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ve.delete(a.pointerId)}}function Mn(s,a,f,k,v,x){return s===null||s.nativeEvent!==x?(s={blockedOn:a,domEventName:f,eventSystemFlags:k,nativeEvent:x,targetContainers:[v]},a!==null&&(a=Zl(a),a!==null&&En(a)),s):(s.eventSystemFlags|=k,a=s.targetContainers,v!==null&&a.indexOf(v)===-1&&a.push(v),s)}function lo(s,a,f,k,v){switch(a){case"focusin":return D=Mn(D,s,a,f,k,v),!0;case"dragenter":return oe=Mn(oe,s,a,f,k,v),!0;case"mouseover":return be=Mn(be,s,a,f,k,v),!0;case"pointerover":var x=v.pointerId;return Ae.set(x,Mn(Ae.get(x)||null,s,a,f,k,v)),!0;case"gotpointercapture":return x=v.pointerId,Ve.set(x,Mn(Ve.get(x)||null,s,a,f,k,v)),!0}return!1}function Kn(s){var a=$i(s.target);if(a!==null){var f=Hn(a);if(f!==null){if(a=f.tag,a===13){if(a=se(f),a!==null){s.blockedOn=a,pr(s.priority,function(){un(f)});return}}else if(a===3&&f.stateNode.current.memoizedState.isDehydrated){s.blockedOn=f.tag===3?f.stateNode.containerInfo:null;return}}}s.blockedOn=null}function _i(s){if(s.blockedOn!==null)return!1;for(var a=s.targetContainers;0<a.length;){var f=Ti(s.domEventName,s.eventSystemFlags,a[0],s.nativeEvent);if(f===null){f=s.nativeEvent;var k=new f.constructor(f.type,f);nt=k,f.target.dispatchEvent(k),nt=null}else return a=Zl(f),a!==null&&En(a),s.blockedOn=f,!1;a.shift()}return!0}function Ni(s,a,f){_i(s)&&f.delete(a)}function pa(){Re=!1,D!==null&&_i(D)&&(D=null),oe!==null&&_i(oe)&&(oe=null),be!==null&&_i(be)&&(be=null),Ae.forEach(Ni),Ve.forEach(Ni)}function Ms(s,a){s.blockedOn===a&&(s.blockedOn=null,Re||(Re=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,pa)))}function es(s){function a(v){return Ms(v,s)}if(0<L.length){Ms(L[0],s);for(var f=1;f<L.length;f++){var k=L[f];k.blockedOn===s&&(k.blockedOn=null)}}for(D!==null&&Ms(D,s),oe!==null&&Ms(oe,s),be!==null&&Ms(be,s),Ae.forEach(a),Ve.forEach(a),f=0;f<It.length;f++)k=It[f],k.blockedOn===s&&(k.blockedOn=null);for(;0<It.length&&(f=It[0],f.blockedOn===null);)Kn(f),f.blockedOn===null&&It.shift()}var hs=j.ReactCurrentBatchConfig,Ps=!0;function jr(s,a,f,k){var v=Gt,x=hs.transition;hs.transition=null;try{Gt=1,Cl(s,a,f,k)}finally{Gt=v,hs.transition=x}}function lh(s,a,f,k){var v=Gt,x=hs.transition;hs.transition=null;try{Gt=4,Cl(s,a,f,k)}finally{Gt=v,hs.transition=x}}function Cl(s,a,f,k){if(Ps){var v=Ti(s,a,f,k);if(v===null)bh(s,a,k,Ls,f),Wn(s,k);else if(lo(v,s,a,f,k))k.stopPropagation();else if(Wn(s,k),a&4&&-1<rn.indexOf(s)){for(;v!==null;){var x=Zl(v);if(x!==null&&fs(x),x=Ti(s,a,f,k),x===null&&bh(s,a,k,Ls,f),x===v)break;v=x}v!==null&&k.stopPropagation()}else bh(s,a,k,null,f)}}var Ls=null;function Ti(s,a,f,k){if(Ls=null,s=yt(k),s=$i(s),s!==null)if(a=Hn(s),a===null)s=null;else if(f=a.tag,f===13){if(s=se(a),s!==null)return s;s=null}else if(f===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;s=null}else a!==s&&(s=null);return Ls=s,null}function ps(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(Tt()){case zr:return 1;case pt:return 4;case In:case Te:return 16;case Ge:return 536870912;default:return 16}default:return 16}}var bo=null,ma=null,ga=null;function ka(){if(ga)return ga;var s,a=ma,f=a.length,k,v="value"in bo?bo.value:bo.textContent,x=v.length;for(s=0;s<f&&a[s]===v[s];s++);var I=f-s;for(k=1;k<=I&&a[f-k]===v[x-k];k++);return ga=v.slice(s,1<k?1-k:void 0)}function wa(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 ji(){return!0}function uu(){return!1}function Cr(s){function a(f,k,v,x,I){this._reactName=f,this._targetInst=v,this.type=k,this.nativeEvent=x,this.target=I,this.currentTarget=null;for(var W in s)s.hasOwnProperty(W)&&(f=s[W],this[W]=f?f(x):x[W]);return this.isDefaultPrevented=(x.defaultPrevented!=null?x.defaultPrevented:x.returnValue===!1)?ji:uu,this.isPropagationStopped=uu,this}return q(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var f=this.nativeEvent;f&&(f.preventDefault?f.preventDefault():typeof f.returnValue!="unknown"&&(f.returnValue=!1),this.isDefaultPrevented=ji)},stopPropagation:function(){var f=this.nativeEvent;f&&(f.stopPropagation?f.stopPropagation():typeof f.cancelBubble!="unknown"&&(f.cancelBubble=!0),this.isPropagationStopped=ji)},persist:function(){},isPersistent:ji}),a}var Ds={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ya=Cr(Ds),rr=q({},Ds,{view:0,detail:0}),du=Cr(rr),va,Ci,ms,gs=q({},rr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Sa,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!==ms&&(ms&&s.type==="mousemove"?(va=s.screenX-ms.screenX,Ci=s.screenY-ms.screenY):Ci=va=0,ms=s),va)},movementY:function(s){return"movementY"in s?s.movementY:Ci}}),$n=Cr(gs),fu=q({},gs,{dataTransfer:0}),ba=Cr(fu),Al=q({},rr,{relatedTarget:0}),zs=Cr(Al),xa=q({},Ds,{animationName:0,elapsedTime:0,pseudoElement:0}),Fs=Cr(xa),hu=q({},Ds,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),Il=Cr(hu),$l=q({},Ds,{data:0}),Rl=Cr($l),Tw={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},pu={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"},Ea={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function mu(s){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(s):(s=Ea[s])?!!a[s]:!1}function Sa(){return mu}var gu=q({},rr,{key:function(s){if(s.key){var a=Tw[s.key]||s.key;if(a!=="Unidentified")return a}return s.type==="keypress"?(s=wa(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?pu[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Sa,charCode:function(s){return s.type==="keypress"?wa(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?wa(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),lr=Cr(gu),ch=q({},gs,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ai=Cr(ch),Bs=q({},rr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Sa}),Ii=Cr(Bs),Ol=q({},Ds,{propertyName:0,elapsedTime:0,pseudoElement:0}),uh=Cr(Ol),Ml=q({},gs,{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}),dh=Cr(Ml),ku=[9,13,27,32],_a=c&&"CompositionEvent"in window,Us=null;c&&"documentMode"in document&&(Us=document.documentMode);var wu=c&&"TextEvent"in window&&!Us,ks=c&&(!_a||Us&&8<Us&&11>=Us),yu=" ",Pl=!1;function vu(s,a){switch(s){case"keyup":return ku.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function bu(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var ws=!1;function Na(s,a){switch(s){case"compositionend":return bu(a);case"keypress":return a.which!==32?null:(Pl=!0,yu);case"textInput":return s=a.data,s===yu&&Pl?null:s;default:return null}}function xu(s,a){if(ws)return s==="compositionend"||!_a&&vu(s,a)?(s=ka(),ga=ma=bo=null,ws=!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 ks&&a.locale!=="ko"?null:a.data;default:return null}}var Eu={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 Ll(s){var a=s&&s.nodeName&&s.nodeName.toLowerCase();return a==="input"?!!Eu[s.type]:a==="textarea"}function Dl(s,a,f,k){U(k),a=Cu(a,"onChange"),0<a.length&&(f=new ya("onChange","change",null,f,k),s.push({event:f,listeners:a}))}var Hs=null,Ws=null;function Su(s){Bw(s,0)}function F(s){var a=Ia(s);if(ne(a))return s}function Ze(s,a){if(s==="change")return a}var Lt=!1;if(c){var Vt;if(c){var Pn="oninput"in document;if(!Pn){var co=document.createElement("div");co.setAttribute("oninput","return;"),Pn=typeof co.oninput=="function"}Vt=Pn}else Vt=!1;Lt=Vt&&(!document.documentMode||9<document.documentMode)}function zl(){Hs&&(Hs.detachEvent("onpropertychange",uo),Ws=Hs=null)}function uo(s){if(s.propertyName==="value"&&F(Ws)){var a=[];Dl(a,Ws,s,yt(s)),Nt(Su,a)}}function fh(s,a,f){s==="focusin"?(zl(),Hs=a,Ws=f,Hs.attachEvent("onpropertychange",uo)):s==="focusout"&&zl()}function hh(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return F(Ws)}function _u(s,a){if(s==="click")return F(a)}function lj(s,a){if(s==="input"||s==="change")return F(a)}function cj(s,a){return s===a&&(s!==0||1/s===1/a)||s!==s&&a!==a}var Po=typeof Object.is=="function"?Object.is:cj;function Fl(s,a){if(Po(s,a))return!0;if(typeof s!="object"||s===null||typeof a!="object"||a===null)return!1;var f=Object.keys(s),k=Object.keys(a);if(f.length!==k.length)return!1;for(k=0;k<f.length;k++){var v=f[k];if(!u.call(a,v)||!Po(s[v],a[v]))return!1}return!0}function jw(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function Cw(s,a){var f=jw(s);s=0;for(var k;f;){if(f.nodeType===3){if(k=s+f.textContent.length,s<=a&&k>=a)return{node:f,offset:a-s};s=k}e:{for(;f;){if(f.nextSibling){f=f.nextSibling;break e}f=f.parentNode}f=void 0}f=jw(f)}}function Aw(s,a){return s&&a?s===a?!0:s&&s.nodeType===3?!1:a&&a.nodeType===3?Aw(s,a.parentNode):"contains"in s?s.contains(a):s.compareDocumentPosition?!!(s.compareDocumentPosition(a)&16):!1:!1}function Iw(){for(var s=window,a=ge();a instanceof s.HTMLIFrameElement;){try{var f=typeof a.contentWindow.location.href=="string"}catch{f=!1}if(f)s=a.contentWindow;else break;a=ge(s.document)}return a}function ph(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 uj(s){var a=Iw(),f=s.focusedElem,k=s.selectionRange;if(a!==f&&f&&f.ownerDocument&&Aw(f.ownerDocument.documentElement,f)){if(k!==null&&ph(f)){if(a=k.start,s=k.end,s===void 0&&(s=a),"selectionStart"in f)f.selectionStart=a,f.selectionEnd=Math.min(s,f.value.length);else if(s=(a=f.ownerDocument||document)&&a.defaultView||window,s.getSelection){s=s.getSelection();var v=f.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=Cw(f,x);var I=Cw(f,k);v&&I&&(s.rangeCount!==1||s.anchorNode!==v.node||s.anchorOffset!==v.offset||s.focusNode!==I.node||s.focusOffset!==I.offset)&&(a=a.createRange(),a.setStart(v.node,v.offset),s.removeAllRanges(),x>k?(s.addRange(a),s.extend(I.node,I.offset)):(a.setEnd(I.node,I.offset),s.addRange(a)))}}for(a=[],s=f;s=s.parentNode;)s.nodeType===1&&a.push({element:s,left:s.scrollLeft,top:s.scrollTop});for(typeof f.focus=="function"&&f.focus(),f=0;f<a.length;f++)s=a[f],s.element.scrollLeft=s.left,s.element.scrollTop=s.top}}var dj=c&&"documentMode"in document&&11>=document.documentMode,Ta=null,mh=null,Bl=null,gh=!1;function $w(s,a,f){var k=f.window===f?f.document:f.nodeType===9?f:f.ownerDocument;gh||Ta==null||Ta!==ge(k)||(k=Ta,"selectionStart"in k&&ph(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}),Bl&&Fl(Bl,k)||(Bl=k,k=Cu(mh,"onSelect"),0<k.length&&(a=new ya("onSelect","select",null,a,f),s.push({event:a,listeners:k}),a.target=Ta)))}function Nu(s,a){var f={};return f[s.toLowerCase()]=a.toLowerCase(),f["Webkit"+s]="webkit"+a,f["Moz"+s]="moz"+a,f}var ja={animationend:Nu("Animation","AnimationEnd"),animationiteration:Nu("Animation","AnimationIteration"),animationstart:Nu("Animation","AnimationStart"),transitionend:Nu("Transition","TransitionEnd")},kh={},Rw={};c&&(Rw=document.createElement("div").style,"AnimationEvent"in window||(delete ja.animationend.animation,delete ja.animationiteration.animation,delete ja.animationstart.animation),"TransitionEvent"in window||delete ja.transitionend.transition);function Tu(s){if(kh[s])return kh[s];if(!ja[s])return s;var a=ja[s],f;for(f in a)if(a.hasOwnProperty(f)&&f in Rw)return kh[s]=a[f];return s}var Ow=Tu("animationend"),Mw=Tu("animationiteration"),Pw=Tu("animationstart"),Lw=Tu("transitionend"),Dw=new Map,zw="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 Ks(s,a){Dw.set(s,a),i(a,[s])}for(var wh=0;wh<zw.length;wh++){var yh=zw[wh],fj=yh.toLowerCase(),hj=yh[0].toUpperCase()+yh.slice(1);Ks(fj,"on"+hj)}Ks(Ow,"onAnimationEnd"),Ks(Mw,"onAnimationIteration"),Ks(Pw,"onAnimationStart"),Ks("dblclick","onDoubleClick"),Ks("focusin","onFocus"),Ks("focusout","onBlur"),Ks(Lw,"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 Ul="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(" "),pj=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ul));function Fw(s,a,f){var k=s.type||"unknown-event";s.currentTarget=f,Xn(k,a,void 0,s),s.currentTarget=null}function Bw(s,a){a=(a&4)!==0;for(var f=0;f<s.length;f++){var k=s[f],v=k.event;k=k.listeners;e:{var x=void 0;if(a)for(var I=k.length-1;0<=I;I--){var W=k[I],X=W.instance,he=W.currentTarget;if(W=W.listener,X!==x&&v.isPropagationStopped())break e;Fw(v,W,he),x=X}else for(I=0;I<k.length;I++){if(W=k[I],X=W.instance,he=W.currentTarget,W=W.listener,X!==x&&v.isPropagationStopped())break e;Fw(v,W,he),x=X}}}if(Zt)throw s=bn,Zt=!1,bn=null,s}function Ln(s,a){var f=a[Th];f===void 0&&(f=a[Th]=new Set);var k=s+"__bubble";f.has(k)||(Uw(a,s,2,!1),f.add(k))}function vh(s,a,f){var k=0;a&&(k|=4),Uw(f,s,k,a)}var ju="_reactListening"+Math.random().toString(36).slice(2);function Hl(s){if(!s[ju]){s[ju]=!0,r.forEach(function(f){f!=="selectionchange"&&(pj.has(f)||vh(f,!1,s),vh(f,!0,s))});var a=s.nodeType===9?s:s.ownerDocument;a===null||a[ju]||(a[ju]=!0,vh("selectionchange",!1,a))}}function Uw(s,a,f,k){switch(ps(a)){case 1:var v=jr;break;case 4:v=lh;break;default:v=Cl}f=v.bind(null,a,f,s),v=void 0,!Fe||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(v=!0),k?v!==void 0?s.addEventListener(a,f,{capture:!0,passive:v}):s.addEventListener(a,f,!0):v!==void 0?s.addEventListener(a,f,{passive:v}):s.addEventListener(a,f,!1)}function bh(s,a,f,k,v){var x=k;if((a&1)===0&&(a&2)===0&&k!==null)e:for(;;){if(k===null)return;var I=k.tag;if(I===3||I===4){var W=k.stateNode.containerInfo;if(W===v||W.nodeType===8&&W.parentNode===v)break;if(I===4)for(I=k.return;I!==null;){var X=I.tag;if((X===3||X===4)&&(X=I.stateNode.containerInfo,X===v||X.nodeType===8&&X.parentNode===v))return;I=I.return}for(;W!==null;){if(I=$i(W),I===null)return;if(X=I.tag,X===5||X===6){k=x=I;continue e}W=W.parentNode}}k=k.return}Nt(function(){var he=x,Oe=yt(f),Pe=[];e:{var $e=Dw.get(s);if($e!==void 0){var Je=ya,ot=s;switch(s){case"keypress":if(wa(f)===0)break e;case"keydown":case"keyup":Je=lr;break;case"focusin":ot="focus",Je=zs;break;case"focusout":ot="blur",Je=zs;break;case"beforeblur":case"afterblur":Je=zs;break;case"click":if(f.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Je=$n;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Je=ba;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Je=Ii;break;case Ow:case Mw:case Pw:Je=Fs;break;case Lw:Je=uh;break;case"scroll":Je=du;break;case"wheel":Je=dh;break;case"copy":case"cut":case"paste":Je=Il;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Je=Ai}var st=(a&4)!==0,Jn=!st&&s==="scroll",le=st?$e!==null?$e+"Capture":null:$e;st=[];for(var ee=he,ce;ee!==null;){ce=ee;var Ue=ce.stateNode;if(ce.tag===5&&Ue!==null&&(ce=Ue,le!==null&&(Ue=He(ee,le),Ue!=null&&st.push(Wl(ee,Ue,ce)))),Jn)break;ee=ee.return}0<st.length&&($e=new Je($e,ot,null,f,Oe),Pe.push({event:$e,listeners:st}))}}if((a&7)===0){e:{if($e=s==="mouseover"||s==="pointerover",Je=s==="mouseout"||s==="pointerout",$e&&f!==nt&&(ot=f.relatedTarget||f.fromElement)&&($i(ot)||ot[ys]))break e;if((Je||$e)&&($e=Oe.window===Oe?Oe:($e=Oe.ownerDocument)?$e.defaultView||$e.parentWindow:window,Je?(ot=f.relatedTarget||f.toElement,Je=he,ot=ot?$i(ot):null,ot!==null&&(Jn=Hn(ot),ot!==Jn||ot.tag!==5&&ot.tag!==6)&&(ot=null)):(Je=null,ot=he),Je!==ot)){if(st=$n,Ue="onMouseLeave",le="onMouseEnter",ee="mouse",(s==="pointerout"||s==="pointerover")&&(st=Ai,Ue="onPointerLeave",le="onPointerEnter",ee="pointer"),Jn=Je==null?$e:Ia(Je),ce=ot==null?$e:Ia(ot),$e=new st(Ue,ee+"leave",Je,f,Oe),$e.target=Jn,$e.relatedTarget=ce,Ue=null,$i(Oe)===he&&(st=new st(le,ee+"enter",ot,f,Oe),st.target=ce,st.relatedTarget=Jn,Ue=st),Jn=Ue,Je&&ot)t:{for(st=Je,le=ot,ee=0,ce=st;ce;ce=Ca(ce))ee++;for(ce=0,Ue=le;Ue;Ue=Ca(Ue))ce++;for(;0<ee-ce;)st=Ca(st),ee--;for(;0<ce-ee;)le=Ca(le),ce--;for(;ee--;){if(st===le||le!==null&&st===le.alternate)break t;st=Ca(st),le=Ca(le)}st=null}else st=null;Je!==null&&Hw(Pe,$e,Je,st,!1),ot!==null&&Jn!==null&&Hw(Pe,Jn,ot,st,!0)}}e:{if($e=he?Ia(he):window,Je=$e.nodeName&&$e.nodeName.toLowerCase(),Je==="select"||Je==="input"&&$e.type==="file")var ct=Ze;else if(Ll($e))if(Lt)ct=lj;else{ct=hh;var bt=fh}else(Je=$e.nodeName)&&Je.toLowerCase()==="input"&&($e.type==="checkbox"||$e.type==="radio")&&(ct=_u);if(ct&&(ct=ct(s,he))){Dl(Pe,ct,f,Oe);break e}bt&&bt(s,$e,he),s==="focusout"&&(bt=$e._wrapperState)&&bt.controlled&&$e.type==="number"&&on($e,"number",$e.value)}switch(bt=he?Ia(he):window,s){case"focusin":(Ll(bt)||bt.contentEditable==="true")&&(Ta=bt,mh=he,Bl=null);break;case"focusout":Bl=mh=Ta=null;break;case"mousedown":gh=!0;break;case"contextmenu":case"mouseup":case"dragend":gh=!1,$w(Pe,f,Oe);break;case"selectionchange":if(dj)break;case"keydown":case"keyup":$w(Pe,f,Oe)}var xt;if(_a)e:{switch(s){case"compositionstart":var $t="onCompositionStart";break e;case"compositionend":$t="onCompositionEnd";break e;case"compositionupdate":$t="onCompositionUpdate";break e}$t=void 0}else ws?vu(s,f)&&($t="onCompositionEnd"):s==="keydown"&&f.keyCode===229&&($t="onCompositionStart");$t&&(ks&&f.locale!=="ko"&&(ws||$t!=="onCompositionStart"?$t==="onCompositionEnd"&&ws&&(xt=ka()):(bo=Oe,ma="value"in bo?bo.value:bo.textContent,ws=!0)),bt=Cu(he,$t),0<bt.length&&($t=new Rl($t,s,null,f,Oe),Pe.push({event:$t,listeners:bt}),xt?$t.data=xt:(xt=bu(f),xt!==null&&($t.data=xt)))),(xt=wu?Na(s,f):xu(s,f))&&(he=Cu(he,"onBeforeInput"),0<he.length&&(Oe=new Rl("onBeforeInput","beforeinput",null,f,Oe),Pe.push({event:Oe,listeners:he}),Oe.data=xt))}Bw(Pe,a)})}function Wl(s,a,f){return{instance:s,listener:a,currentTarget:f}}function Cu(s,a){for(var f=a+"Capture",k=[];s!==null;){var v=s,x=v.stateNode;v.tag===5&&x!==null&&(v=x,x=He(s,f),x!=null&&k.unshift(Wl(s,x,v)),x=He(s,a),x!=null&&k.push(Wl(s,x,v))),s=s.return}return k}function Ca(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5);return s||null}function Hw(s,a,f,k,v){for(var x=a._reactName,I=[];f!==null&&f!==k;){var W=f,X=W.alternate,he=W.stateNode;if(X!==null&&X===k)break;W.tag===5&&he!==null&&(W=he,v?(X=He(f,x),X!=null&&I.unshift(Wl(f,X,W))):v||(X=He(f,x),X!=null&&I.push(Wl(f,X,W)))),f=f.return}I.length!==0&&s.push({event:a,listeners:I})}var mj=/\r\n?/g,gj=/\u0000|\uFFFD/g;function Ww(s){return(typeof s=="string"?s:""+s).replace(mj,`
|
|
39
|
+
`).replace(gj,"")}function Au(s,a,f){if(a=Ww(a),Ww(s)!==a&&f)throw Error(n(425))}function Iu(){}var xh=null,Eh=null;function Sh(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 _h=typeof setTimeout=="function"?setTimeout:void 0,kj=typeof clearTimeout=="function"?clearTimeout:void 0,Kw=typeof Promise=="function"?Promise:void 0,wj=typeof queueMicrotask=="function"?queueMicrotask:typeof Kw<"u"?function(s){return Kw.resolve(null).then(s).catch(yj)}:_h;function yj(s){setTimeout(function(){throw s})}function Nh(s,a){var f=a,k=0;do{var v=f.nextSibling;if(s.removeChild(f),v&&v.nodeType===8)if(f=v.data,f==="/$"){if(k===0){s.removeChild(v),es(a);return}k--}else f!=="$"&&f!=="$?"&&f!=="$!"||k++;f=v}while(f);es(a)}function Zs(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 Zw(s){s=s.previousSibling;for(var a=0;s;){if(s.nodeType===8){var f=s.data;if(f==="$"||f==="$!"||f==="$?"){if(a===0)return s;a--}else f==="/$"&&a++}s=s.previousSibling}return null}var Aa=Math.random().toString(36).slice(2),ts="__reactFiber$"+Aa,Kl="__reactProps$"+Aa,ys="__reactContainer$"+Aa,Th="__reactEvents$"+Aa,vj="__reactListeners$"+Aa,bj="__reactHandles$"+Aa;function $i(s){var a=s[ts];if(a)return a;for(var f=s.parentNode;f;){if(a=f[ys]||f[ts]){if(f=a.alternate,a.child!==null||f!==null&&f.child!==null)for(s=Zw(s);s!==null;){if(f=s[ts])return f;s=Zw(s)}return a}s=f,f=s.parentNode}return null}function Zl(s){return s=s[ts]||s[ys],!s||s.tag!==5&&s.tag!==6&&s.tag!==13&&s.tag!==3?null:s}function Ia(s){if(s.tag===5||s.tag===6)return s.stateNode;throw Error(n(33))}function $u(s){return s[Kl]||null}var jh=[],$a=-1;function qs(s){return{current:s}}function Dn(s){0>$a||(s.current=jh[$a],jh[$a]=null,$a--)}function Rn(s,a){$a++,jh[$a]=s.current,s.current=a}var Gs={},Ar=qs(Gs),Zr=qs(!1),Ri=Gs;function Ra(s,a){var f=s.type.contextTypes;if(!f)return Gs;var k=s.stateNode;if(k&&k.__reactInternalMemoizedUnmaskedChildContext===a)return k.__reactInternalMemoizedMaskedChildContext;var v={},x;for(x in f)v[x]=a[x];return k&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=a,s.__reactInternalMemoizedMaskedChildContext=v),v}function qr(s){return s=s.childContextTypes,s!=null}function Ru(){Dn(Zr),Dn(Ar)}function qw(s,a,f){if(Ar.current!==Gs)throw Error(n(168));Rn(Ar,a),Rn(Zr,f)}function Gw(s,a,f){var k=s.stateNode;if(a=a.childContextTypes,typeof k.getChildContext!="function")return f;k=k.getChildContext();for(var v in k)if(!(v in a))throw Error(n(108,ae(s)||"Unknown",v));return q({},f,k)}function Ou(s){return s=(s=s.stateNode)&&s.__reactInternalMemoizedMergedChildContext||Gs,Ri=Ar.current,Rn(Ar,s),Rn(Zr,Zr.current),!0}function Vw(s,a,f){var k=s.stateNode;if(!k)throw Error(n(169));f?(s=Gw(s,a,Ri),k.__reactInternalMemoizedMergedChildContext=s,Dn(Zr),Dn(Ar),Rn(Ar,s)):Dn(Zr),Rn(Zr,f)}var vs=null,Mu=!1,Ch=!1;function Yw(s){vs===null?vs=[s]:vs.push(s)}function xj(s){Mu=!0,Yw(s)}function Vs(){if(!Ch&&vs!==null){Ch=!0;var s=0,a=Gt;try{var f=vs;for(Gt=1;s<f.length;s++){var k=f[s];do k=k(!0);while(k!==null)}vs=null,Mu=!1}catch(v){throw vs!==null&&(vs=vs.slice(s+1)),kn(zr,Vs),v}finally{Gt=a,Ch=!1}}return null}var Oa=[],Ma=0,Pu=null,Lu=0,xo=[],Eo=0,Oi=null,bs=1,xs="";function Mi(s,a){Oa[Ma++]=Lu,Oa[Ma++]=Pu,Pu=s,Lu=a}function Xw(s,a,f){xo[Eo++]=bs,xo[Eo++]=xs,xo[Eo++]=Oi,Oi=s;var k=bs;s=xs;var v=32-yn(k)-1;k&=~(1<<v),f+=1;var x=32-yn(a)+v;if(30<x){var I=v-v%5;x=(k&(1<<I)-1).toString(32),k>>=I,v-=I,bs=1<<32-yn(a)+v|f<<v|k,xs=x+s}else bs=1<<x|f<<v|k,xs=s}function Ah(s){s.return!==null&&(Mi(s,1),Xw(s,1,0))}function Ih(s){for(;s===Pu;)Pu=Oa[--Ma],Oa[Ma]=null,Lu=Oa[--Ma],Oa[Ma]=null;for(;s===Oi;)Oi=xo[--Eo],xo[Eo]=null,xs=xo[--Eo],xo[Eo]=null,bs=xo[--Eo],xo[Eo]=null}var fo=null,ho=null,Fn=!1,Lo=null;function Qw(s,a){var f=To(5,null,null,0);f.elementType="DELETED",f.stateNode=a,f.return=s,a=s.deletions,a===null?(s.deletions=[f],s.flags|=16):a.push(f)}function Jw(s,a){switch(s.tag){case 5:var f=s.type;return a=a.nodeType!==1||f.toLowerCase()!==a.nodeName.toLowerCase()?null:a,a!==null?(s.stateNode=a,fo=s,ho=Zs(a.firstChild),!0):!1;case 6:return a=s.pendingProps===""||a.nodeType!==3?null:a,a!==null?(s.stateNode=a,fo=s,ho=null,!0):!1;case 13:return a=a.nodeType!==8?null:a,a!==null?(f=Oi!==null?{id:bs,overflow:xs}:null,s.memoizedState={dehydrated:a,treeContext:f,retryLane:1073741824},f=To(18,null,null,0),f.stateNode=a,f.return=s,s.child=f,fo=s,ho=null,!0):!1;default:return!1}}function $h(s){return(s.mode&1)!==0&&(s.flags&128)===0}function Rh(s){if(Fn){var a=ho;if(a){var f=a;if(!Jw(s,a)){if($h(s))throw Error(n(418));a=Zs(f.nextSibling);var k=fo;a&&Jw(s,a)?Qw(k,f):(s.flags=s.flags&-4097|2,Fn=!1,fo=s)}}else{if($h(s))throw Error(n(418));s.flags=s.flags&-4097|2,Fn=!1,fo=s}}}function ey(s){for(s=s.return;s!==null&&s.tag!==5&&s.tag!==3&&s.tag!==13;)s=s.return;fo=s}function Du(s){if(s!==fo)return!1;if(!Fn)return ey(s),Fn=!0,!1;var a;if((a=s.tag!==3)&&!(a=s.tag!==5)&&(a=s.type,a=a!=="head"&&a!=="body"&&!Sh(s.type,s.memoizedProps)),a&&(a=ho)){if($h(s))throw ty(),Error(n(418));for(;a;)Qw(s,a),a=Zs(a.nextSibling)}if(ey(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 f=s.data;if(f==="/$"){if(a===0){ho=Zs(s.nextSibling);break e}a--}else f!=="$"&&f!=="$!"&&f!=="$?"||a++}s=s.nextSibling}ho=null}}else ho=fo?Zs(s.stateNode.nextSibling):null;return!0}function ty(){for(var s=ho;s;)s=Zs(s.nextSibling)}function Pa(){ho=fo=null,Fn=!1}function Oh(s){Lo===null?Lo=[s]:Lo.push(s)}var Ej=j.ReactCurrentBatchConfig;function ql(s,a,f){if(s=f.ref,s!==null&&typeof s!="function"&&typeof s!="object"){if(f._owner){if(f=f._owner,f){if(f.tag!==1)throw Error(n(309));var k=f.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(I){var W=v.refs;I===null?delete W[x]:W[x]=I},a._stringRef=x,a)}if(typeof s!="string")throw Error(n(284));if(!f._owner)throw Error(n(290,s))}return s}function zu(s,a){throw s=Object.prototype.toString.call(a),Error(n(31,s==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":s))}function ny(s){var a=s._init;return a(s._payload)}function ry(s){function a(le,ee){if(s){var ce=le.deletions;ce===null?(le.deletions=[ee],le.flags|=16):ce.push(ee)}}function f(le,ee){if(!s)return null;for(;ee!==null;)a(le,ee),ee=ee.sibling;return null}function k(le,ee){for(le=new Map;ee!==null;)ee.key!==null?le.set(ee.key,ee):le.set(ee.index,ee),ee=ee.sibling;return le}function v(le,ee){return le=ri(le,ee),le.index=0,le.sibling=null,le}function x(le,ee,ce){return le.index=ce,s?(ce=le.alternate,ce!==null?(ce=ce.index,ce<ee?(le.flags|=2,ee):ce):(le.flags|=2,ee)):(le.flags|=1048576,ee)}function I(le){return s&&le.alternate===null&&(le.flags|=2),le}function W(le,ee,ce,Ue){return ee===null||ee.tag!==6?(ee=_p(ce,le.mode,Ue),ee.return=le,ee):(ee=v(ee,ce),ee.return=le,ee)}function X(le,ee,ce,Ue){var ct=ce.type;return ct===R?Oe(le,ee,ce.props.children,Ue,ce.key):ee!==null&&(ee.elementType===ct||typeof ct=="object"&&ct!==null&&ct.$$typeof===ve&&ny(ct)===ee.type)?(Ue=v(ee,ce.props),Ue.ref=ql(le,ee,ce),Ue.return=le,Ue):(Ue=cd(ce.type,ce.key,ce.props,null,le.mode,Ue),Ue.ref=ql(le,ee,ce),Ue.return=le,Ue)}function he(le,ee,ce,Ue){return ee===null||ee.tag!==4||ee.stateNode.containerInfo!==ce.containerInfo||ee.stateNode.implementation!==ce.implementation?(ee=Np(ce,le.mode,Ue),ee.return=le,ee):(ee=v(ee,ce.children||[]),ee.return=le,ee)}function Oe(le,ee,ce,Ue,ct){return ee===null||ee.tag!==7?(ee=Hi(ce,le.mode,Ue,ct),ee.return=le,ee):(ee=v(ee,ce),ee.return=le,ee)}function Pe(le,ee,ce){if(typeof ee=="string"&&ee!==""||typeof ee=="number")return ee=_p(""+ee,le.mode,ce),ee.return=le,ee;if(typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case $:return ce=cd(ee.type,ee.key,ee.props,null,le.mode,ce),ce.ref=ql(le,null,ee),ce.return=le,ce;case P:return ee=Np(ee,le.mode,ce),ee.return=le,ee;case ve:var Ue=ee._init;return Pe(le,Ue(ee._payload),ce)}if(St(ee)||Y(ee))return ee=Hi(ee,le.mode,ce,null),ee.return=le,ee;zu(le,ee)}return null}function $e(le,ee,ce,Ue){var ct=ee!==null?ee.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number")return ct!==null?null:W(le,ee,""+ce,Ue);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case $:return ce.key===ct?X(le,ee,ce,Ue):null;case P:return ce.key===ct?he(le,ee,ce,Ue):null;case ve:return ct=ce._init,$e(le,ee,ct(ce._payload),Ue)}if(St(ce)||Y(ce))return ct!==null?null:Oe(le,ee,ce,Ue,null);zu(le,ce)}return null}function Je(le,ee,ce,Ue,ct){if(typeof Ue=="string"&&Ue!==""||typeof Ue=="number")return le=le.get(ce)||null,W(ee,le,""+Ue,ct);if(typeof Ue=="object"&&Ue!==null){switch(Ue.$$typeof){case $:return le=le.get(Ue.key===null?ce:Ue.key)||null,X(ee,le,Ue,ct);case P:return le=le.get(Ue.key===null?ce:Ue.key)||null,he(ee,le,Ue,ct);case ve:var bt=Ue._init;return Je(le,ee,ce,bt(Ue._payload),ct)}if(St(Ue)||Y(Ue))return le=le.get(ce)||null,Oe(ee,le,Ue,ct,null);zu(ee,Ue)}return null}function ot(le,ee,ce,Ue){for(var ct=null,bt=null,xt=ee,$t=ee=0,kr=null;xt!==null&&$t<ce.length;$t++){xt.index>$t?(kr=xt,xt=null):kr=xt.sibling;var gn=$e(le,xt,ce[$t],Ue);if(gn===null){xt===null&&(xt=kr);break}s&&xt&&gn.alternate===null&&a(le,xt),ee=x(gn,ee,$t),bt===null?ct=gn:bt.sibling=gn,bt=gn,xt=kr}if($t===ce.length)return f(le,xt),Fn&&Mi(le,$t),ct;if(xt===null){for(;$t<ce.length;$t++)xt=Pe(le,ce[$t],Ue),xt!==null&&(ee=x(xt,ee,$t),bt===null?ct=xt:bt.sibling=xt,bt=xt);return Fn&&Mi(le,$t),ct}for(xt=k(le,xt);$t<ce.length;$t++)kr=Je(xt,le,$t,ce[$t],Ue),kr!==null&&(s&&kr.alternate!==null&&xt.delete(kr.key===null?$t:kr.key),ee=x(kr,ee,$t),bt===null?ct=kr:bt.sibling=kr,bt=kr);return s&&xt.forEach(function(oi){return a(le,oi)}),Fn&&Mi(le,$t),ct}function st(le,ee,ce,Ue){var ct=Y(ce);if(typeof ct!="function")throw Error(n(150));if(ce=ct.call(ce),ce==null)throw Error(n(151));for(var bt=ct=null,xt=ee,$t=ee=0,kr=null,gn=ce.next();xt!==null&&!gn.done;$t++,gn=ce.next()){xt.index>$t?(kr=xt,xt=null):kr=xt.sibling;var oi=$e(le,xt,gn.value,Ue);if(oi===null){xt===null&&(xt=kr);break}s&&xt&&oi.alternate===null&&a(le,xt),ee=x(oi,ee,$t),bt===null?ct=oi:bt.sibling=oi,bt=oi,xt=kr}if(gn.done)return f(le,xt),Fn&&Mi(le,$t),ct;if(xt===null){for(;!gn.done;$t++,gn=ce.next())gn=Pe(le,gn.value,Ue),gn!==null&&(ee=x(gn,ee,$t),bt===null?ct=gn:bt.sibling=gn,bt=gn);return Fn&&Mi(le,$t),ct}for(xt=k(le,xt);!gn.done;$t++,gn=ce.next())gn=Je(xt,le,$t,gn.value,Ue),gn!==null&&(s&&gn.alternate!==null&&xt.delete(gn.key===null?$t:gn.key),ee=x(gn,ee,$t),bt===null?ct=gn:bt.sibling=gn,bt=gn);return s&&xt.forEach(function(nC){return a(le,nC)}),Fn&&Mi(le,$t),ct}function Jn(le,ee,ce,Ue){if(typeof ce=="object"&&ce!==null&&ce.type===R&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case $:e:{for(var ct=ce.key,bt=ee;bt!==null;){if(bt.key===ct){if(ct=ce.type,ct===R){if(bt.tag===7){f(le,bt.sibling),ee=v(bt,ce.props.children),ee.return=le,le=ee;break e}}else if(bt.elementType===ct||typeof ct=="object"&&ct!==null&&ct.$$typeof===ve&&ny(ct)===bt.type){f(le,bt.sibling),ee=v(bt,ce.props),ee.ref=ql(le,bt,ce),ee.return=le,le=ee;break e}f(le,bt);break}else a(le,bt);bt=bt.sibling}ce.type===R?(ee=Hi(ce.props.children,le.mode,Ue,ce.key),ee.return=le,le=ee):(Ue=cd(ce.type,ce.key,ce.props,null,le.mode,Ue),Ue.ref=ql(le,ee,ce),Ue.return=le,le=Ue)}return I(le);case P:e:{for(bt=ce.key;ee!==null;){if(ee.key===bt)if(ee.tag===4&&ee.stateNode.containerInfo===ce.containerInfo&&ee.stateNode.implementation===ce.implementation){f(le,ee.sibling),ee=v(ee,ce.children||[]),ee.return=le,le=ee;break e}else{f(le,ee);break}else a(le,ee);ee=ee.sibling}ee=Np(ce,le.mode,Ue),ee.return=le,le=ee}return I(le);case ve:return bt=ce._init,Jn(le,ee,bt(ce._payload),Ue)}if(St(ce))return ot(le,ee,ce,Ue);if(Y(ce))return st(le,ee,ce,Ue);zu(le,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"?(ce=""+ce,ee!==null&&ee.tag===6?(f(le,ee.sibling),ee=v(ee,ce),ee.return=le,le=ee):(f(le,ee),ee=_p(ce,le.mode,Ue),ee.return=le,le=ee),I(le)):f(le,ee)}return Jn}var La=ry(!0),oy=ry(!1),Fu=qs(null),Bu=null,Da=null,Mh=null;function Ph(){Mh=Da=Bu=null}function Lh(s){var a=Fu.current;Dn(Fu),s._currentValue=a}function Dh(s,a,f){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===f)break;s=s.return}}function za(s,a){Bu=s,Mh=Da=null,s=s.dependencies,s!==null&&s.firstContext!==null&&((s.lanes&a)!==0&&(Gr=!0),s.firstContext=null)}function So(s){var a=s._currentValue;if(Mh!==s)if(s={context:s,memoizedValue:a,next:null},Da===null){if(Bu===null)throw Error(n(308));Da=s,Bu.dependencies={lanes:0,firstContext:s}}else Da=Da.next=s;return a}var Pi=null;function zh(s){Pi===null?Pi=[s]:Pi.push(s)}function sy(s,a,f,k){var v=a.interleaved;return v===null?(f.next=f,zh(a)):(f.next=v.next,v.next=f),a.interleaved=f,Es(s,k)}function Es(s,a){s.lanes|=a;var f=s.alternate;for(f!==null&&(f.lanes|=a),f=s,s=s.return;s!==null;)s.childLanes|=a,f=s.alternate,f!==null&&(f.childLanes|=a),f=s,s=s.return;return f.tag===3?f.stateNode:null}var Ys=!1;function Fh(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function iy(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 Ss(s,a){return{eventTime:s,lane:a,tag:0,payload:null,callback:null,next:null}}function Xs(s,a,f){var k=s.updateQueue;if(k===null)return null;if(k=k.shared,(pn&2)!==0){var v=k.pending;return v===null?a.next=a:(a.next=v.next,v.next=a),k.pending=a,Es(s,f)}return v=k.interleaved,v===null?(a.next=a,zh(k)):(a.next=v.next,v.next=a),k.interleaved=a,Es(s,f)}function Uu(s,a,f){if(a=a.updateQueue,a!==null&&(a=a.shared,(f&4194240)!==0)){var k=a.lanes;k&=s.pendingLanes,f|=k,a.lanes=f,ao(s,f)}}function ay(s,a){var f=s.updateQueue,k=s.alternate;if(k!==null&&(k=k.updateQueue,f===k)){var v=null,x=null;if(f=f.firstBaseUpdate,f!==null){do{var I={eventTime:f.eventTime,lane:f.lane,tag:f.tag,payload:f.payload,callback:f.callback,next:null};x===null?v=x=I:x=x.next=I,f=f.next}while(f!==null);x===null?v=x=a:x=x.next=a}else v=x=a;f={baseState:k.baseState,firstBaseUpdate:v,lastBaseUpdate:x,shared:k.shared,effects:k.effects},s.updateQueue=f;return}s=f.lastBaseUpdate,s===null?f.firstBaseUpdate=a:s.next=a,f.lastBaseUpdate=a}function Hu(s,a,f,k){var v=s.updateQueue;Ys=!1;var x=v.firstBaseUpdate,I=v.lastBaseUpdate,W=v.shared.pending;if(W!==null){v.shared.pending=null;var X=W,he=X.next;X.next=null,I===null?x=he:I.next=he,I=X;var Oe=s.alternate;Oe!==null&&(Oe=Oe.updateQueue,W=Oe.lastBaseUpdate,W!==I&&(W===null?Oe.firstBaseUpdate=he:W.next=he,Oe.lastBaseUpdate=X))}if(x!==null){var Pe=v.baseState;I=0,Oe=he=X=null,W=x;do{var $e=W.lane,Je=W.eventTime;if((k&$e)===$e){Oe!==null&&(Oe=Oe.next={eventTime:Je,lane:0,tag:W.tag,payload:W.payload,callback:W.callback,next:null});e:{var ot=s,st=W;switch($e=a,Je=f,st.tag){case 1:if(ot=st.payload,typeof ot=="function"){Pe=ot.call(Je,Pe,$e);break e}Pe=ot;break e;case 3:ot.flags=ot.flags&-65537|128;case 0:if(ot=st.payload,$e=typeof ot=="function"?ot.call(Je,Pe,$e):ot,$e==null)break e;Pe=q({},Pe,$e);break e;case 2:Ys=!0}}W.callback!==null&&W.lane!==0&&(s.flags|=64,$e=v.effects,$e===null?v.effects=[W]:$e.push(W))}else Je={eventTime:Je,lane:$e,tag:W.tag,payload:W.payload,callback:W.callback,next:null},Oe===null?(he=Oe=Je,X=Pe):Oe=Oe.next=Je,I|=$e;if(W=W.next,W===null){if(W=v.shared.pending,W===null)break;$e=W,W=$e.next,$e.next=null,v.lastBaseUpdate=$e,v.shared.pending=null}}while(!0);if(Oe===null&&(X=Pe),v.baseState=X,v.firstBaseUpdate=he,v.lastBaseUpdate=Oe,a=v.shared.interleaved,a!==null){v=a;do I|=v.lane,v=v.next;while(v!==a)}else x===null&&(v.shared.lanes=0);zi|=I,s.lanes=I,s.memoizedState=Pe}}function ly(s,a,f){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=f,typeof v!="function")throw Error(n(191,v));v.call(k)}}}var Gl={},ns=qs(Gl),Vl=qs(Gl),Yl=qs(Gl);function Li(s){if(s===Gl)throw Error(n(174));return s}function Bh(s,a){switch(Rn(Yl,a),Rn(Vl,s),Rn(ns,Gl),s=a.nodeType,s){case 9:case 11:a=(a=a.documentElement)?a.namespaceURI:ln(null,"");break;default:s=s===8?a.parentNode:a,a=s.namespaceURI||null,s=s.tagName,a=ln(a,s)}Dn(ns),Rn(ns,a)}function Fa(){Dn(ns),Dn(Vl),Dn(Yl)}function cy(s){Li(Yl.current);var a=Li(ns.current),f=ln(a,s.type);a!==f&&(Rn(Vl,s),Rn(ns,f))}function Uh(s){Vl.current===s&&(Dn(ns),Dn(Vl))}var Zn=qs(0);function Wu(s){for(var a=s;a!==null;){if(a.tag===13){var f=a.memoizedState;if(f!==null&&(f=f.dehydrated,f===null||f.data==="$?"||f.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 Hh=[];function Wh(){for(var s=0;s<Hh.length;s++)Hh[s]._workInProgressVersionPrimary=null;Hh.length=0}var Ku=j.ReactCurrentDispatcher,Kh=j.ReactCurrentBatchConfig,Di=0,qn=null,cr=null,mr=null,Zu=!1,Xl=!1,Ql=0,Sj=0;function Ir(){throw Error(n(321))}function Zh(s,a){if(a===null)return!1;for(var f=0;f<a.length&&f<s.length;f++)if(!Po(s[f],a[f]))return!1;return!0}function qh(s,a,f,k,v,x){if(Di=x,qn=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,Ku.current=s===null||s.memoizedState===null?jj:Cj,s=f(k,v),Xl){x=0;do{if(Xl=!1,Ql=0,25<=x)throw Error(n(301));x+=1,mr=cr=null,a.updateQueue=null,Ku.current=Aj,s=f(k,v)}while(Xl)}if(Ku.current=Vu,a=cr!==null&&cr.next!==null,Di=0,mr=cr=qn=null,Zu=!1,a)throw Error(n(300));return s}function Gh(){var s=Ql!==0;return Ql=0,s}function rs(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return mr===null?qn.memoizedState=mr=s:mr=mr.next=s,mr}function _o(){if(cr===null){var s=qn.alternate;s=s!==null?s.memoizedState:null}else s=cr.next;var a=mr===null?qn.memoizedState:mr.next;if(a!==null)mr=a,cr=s;else{if(s===null)throw Error(n(310));cr=s,s={memoizedState:cr.memoizedState,baseState:cr.baseState,baseQueue:cr.baseQueue,queue:cr.queue,next:null},mr===null?qn.memoizedState=mr=s:mr=mr.next=s}return mr}function Jl(s,a){return typeof a=="function"?a(s):a}function Vh(s){var a=_o(),f=a.queue;if(f===null)throw Error(n(311));f.lastRenderedReducer=s;var k=cr,v=k.baseQueue,x=f.pending;if(x!==null){if(v!==null){var I=v.next;v.next=x.next,x.next=I}k.baseQueue=v=x,f.pending=null}if(v!==null){x=v.next,k=k.baseState;var W=I=null,X=null,he=x;do{var Oe=he.lane;if((Di&Oe)===Oe)X!==null&&(X=X.next={lane:0,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null}),k=he.hasEagerState?he.eagerState:s(k,he.action);else{var Pe={lane:Oe,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null};X===null?(W=X=Pe,I=k):X=X.next=Pe,qn.lanes|=Oe,zi|=Oe}he=he.next}while(he!==null&&he!==x);X===null?I=k:X.next=W,Po(k,a.memoizedState)||(Gr=!0),a.memoizedState=k,a.baseState=I,a.baseQueue=X,f.lastRenderedState=k}if(s=f.interleaved,s!==null){v=s;do x=v.lane,qn.lanes|=x,zi|=x,v=v.next;while(v!==s)}else v===null&&(f.lanes=0);return[a.memoizedState,f.dispatch]}function Yh(s){var a=_o(),f=a.queue;if(f===null)throw Error(n(311));f.lastRenderedReducer=s;var k=f.dispatch,v=f.pending,x=a.memoizedState;if(v!==null){f.pending=null;var I=v=v.next;do x=s(x,I.action),I=I.next;while(I!==v);Po(x,a.memoizedState)||(Gr=!0),a.memoizedState=x,a.baseQueue===null&&(a.baseState=x),f.lastRenderedState=x}return[x,k]}function uy(){}function dy(s,a){var f=qn,k=_o(),v=a(),x=!Po(k.memoizedState,v);if(x&&(k.memoizedState=v,Gr=!0),k=k.queue,Xh(py.bind(null,f,k,s),[s]),k.getSnapshot!==a||x||mr!==null&&mr.memoizedState.tag&1){if(f.flags|=2048,ec(9,hy.bind(null,f,k,v,a),void 0,null),gr===null)throw Error(n(349));(Di&30)!==0||fy(f,a,v)}return v}function fy(s,a,f){s.flags|=16384,s={getSnapshot:a,value:f},a=qn.updateQueue,a===null?(a={lastEffect:null,stores:null},qn.updateQueue=a,a.stores=[s]):(f=a.stores,f===null?a.stores=[s]:f.push(s))}function hy(s,a,f,k){a.value=f,a.getSnapshot=k,my(a)&&gy(s)}function py(s,a,f){return f(function(){my(a)&&gy(s)})}function my(s){var a=s.getSnapshot;s=s.value;try{var f=a();return!Po(s,f)}catch{return!0}}function gy(s){var a=Es(s,1);a!==null&&Bo(a,s,1,-1)}function ky(s){var a=rs();return typeof s=="function"&&(s=s()),a.memoizedState=a.baseState=s,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Jl,lastRenderedState:s},a.queue=s,s=s.dispatch=Tj.bind(null,qn,s),[a.memoizedState,s]}function ec(s,a,f,k){return s={tag:s,create:a,destroy:f,deps:k,next:null},a=qn.updateQueue,a===null?(a={lastEffect:null,stores:null},qn.updateQueue=a,a.lastEffect=s.next=s):(f=a.lastEffect,f===null?a.lastEffect=s.next=s:(k=f.next,f.next=s,s.next=k,a.lastEffect=s)),s}function wy(){return _o().memoizedState}function qu(s,a,f,k){var v=rs();qn.flags|=s,v.memoizedState=ec(1|a,f,void 0,k===void 0?null:k)}function Gu(s,a,f,k){var v=_o();k=k===void 0?null:k;var x=void 0;if(cr!==null){var I=cr.memoizedState;if(x=I.destroy,k!==null&&Zh(k,I.deps)){v.memoizedState=ec(a,f,x,k);return}}qn.flags|=s,v.memoizedState=ec(1|a,f,x,k)}function yy(s,a){return qu(8390656,8,s,a)}function Xh(s,a){return Gu(2048,8,s,a)}function vy(s,a){return Gu(4,2,s,a)}function by(s,a){return Gu(4,4,s,a)}function xy(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 Ey(s,a,f){return f=f!=null?f.concat([s]):null,Gu(4,4,xy.bind(null,a,s),f)}function Qh(){}function Sy(s,a){var f=_o();a=a===void 0?null:a;var k=f.memoizedState;return k!==null&&a!==null&&Zh(a,k[1])?k[0]:(f.memoizedState=[s,a],s)}function _y(s,a){var f=_o();a=a===void 0?null:a;var k=f.memoizedState;return k!==null&&a!==null&&Zh(a,k[1])?k[0]:(s=s(),f.memoizedState=[s,a],s)}function Ny(s,a,f){return(Di&21)===0?(s.baseState&&(s.baseState=!1,Gr=!0),s.memoizedState=f):(Po(f,a)||(f=vo(),qn.lanes|=f,zi|=f,s.baseState=!0),a)}function _j(s,a){var f=Gt;Gt=f!==0&&4>f?f:4,s(!0);var k=Kh.transition;Kh.transition={};try{s(!1),a()}finally{Gt=f,Kh.transition=k}}function Ty(){return _o().memoizedState}function Nj(s,a,f){var k=ti(s);if(f={lane:k,action:f,hasEagerState:!1,eagerState:null,next:null},jy(s))Cy(a,f);else if(f=sy(s,a,f,k),f!==null){var v=Hr();Bo(f,s,k,v),Ay(f,a,k)}}function Tj(s,a,f){var k=ti(s),v={lane:k,action:f,hasEagerState:!1,eagerState:null,next:null};if(jy(s))Cy(a,v);else{var x=s.alternate;if(s.lanes===0&&(x===null||x.lanes===0)&&(x=a.lastRenderedReducer,x!==null))try{var I=a.lastRenderedState,W=x(I,f);if(v.hasEagerState=!0,v.eagerState=W,Po(W,I)){var X=a.interleaved;X===null?(v.next=v,zh(a)):(v.next=X.next,X.next=v),a.interleaved=v;return}}catch{}finally{}f=sy(s,a,v,k),f!==null&&(v=Hr(),Bo(f,s,k,v),Ay(f,a,k))}}function jy(s){var a=s.alternate;return s===qn||a!==null&&a===qn}function Cy(s,a){Xl=Zu=!0;var f=s.pending;f===null?a.next=a:(a.next=f.next,f.next=a),s.pending=a}function Ay(s,a,f){if((f&4194240)!==0){var k=a.lanes;k&=s.pendingLanes,f|=k,a.lanes=f,ao(s,f)}}var Vu={readContext:So,useCallback:Ir,useContext:Ir,useEffect:Ir,useImperativeHandle:Ir,useInsertionEffect:Ir,useLayoutEffect:Ir,useMemo:Ir,useReducer:Ir,useRef:Ir,useState:Ir,useDebugValue:Ir,useDeferredValue:Ir,useTransition:Ir,useMutableSource:Ir,useSyncExternalStore:Ir,useId:Ir,unstable_isNewReconciler:!1},jj={readContext:So,useCallback:function(s,a){return rs().memoizedState=[s,a===void 0?null:a],s},useContext:So,useEffect:yy,useImperativeHandle:function(s,a,f){return f=f!=null?f.concat([s]):null,qu(4194308,4,xy.bind(null,a,s),f)},useLayoutEffect:function(s,a){return qu(4194308,4,s,a)},useInsertionEffect:function(s,a){return qu(4,2,s,a)},useMemo:function(s,a){var f=rs();return a=a===void 0?null:a,s=s(),f.memoizedState=[s,a],s},useReducer:function(s,a,f){var k=rs();return a=f!==void 0?f(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=Nj.bind(null,qn,s),[k.memoizedState,s]},useRef:function(s){var a=rs();return s={current:s},a.memoizedState=s},useState:ky,useDebugValue:Qh,useDeferredValue:function(s){return rs().memoizedState=s},useTransition:function(){var s=ky(!1),a=s[0];return s=_j.bind(null,s[1]),rs().memoizedState=s,[a,s]},useMutableSource:function(){},useSyncExternalStore:function(s,a,f){var k=qn,v=rs();if(Fn){if(f===void 0)throw Error(n(407));f=f()}else{if(f=a(),gr===null)throw Error(n(349));(Di&30)!==0||fy(k,a,f)}v.memoizedState=f;var x={value:f,getSnapshot:a};return v.queue=x,yy(py.bind(null,k,x,s),[s]),k.flags|=2048,ec(9,hy.bind(null,k,x,f,a),void 0,null),f},useId:function(){var s=rs(),a=gr.identifierPrefix;if(Fn){var f=xs,k=bs;f=(k&~(1<<32-yn(k)-1)).toString(32)+f,a=":"+a+"R"+f,f=Ql++,0<f&&(a+="H"+f.toString(32)),a+=":"}else f=Sj++,a=":"+a+"r"+f.toString(32)+":";return s.memoizedState=a},unstable_isNewReconciler:!1},Cj={readContext:So,useCallback:Sy,useContext:So,useEffect:Xh,useImperativeHandle:Ey,useInsertionEffect:vy,useLayoutEffect:by,useMemo:_y,useReducer:Vh,useRef:wy,useState:function(){return Vh(Jl)},useDebugValue:Qh,useDeferredValue:function(s){var a=_o();return Ny(a,cr.memoizedState,s)},useTransition:function(){var s=Vh(Jl)[0],a=_o().memoizedState;return[s,a]},useMutableSource:uy,useSyncExternalStore:dy,useId:Ty,unstable_isNewReconciler:!1},Aj={readContext:So,useCallback:Sy,useContext:So,useEffect:Xh,useImperativeHandle:Ey,useInsertionEffect:vy,useLayoutEffect:by,useMemo:_y,useReducer:Yh,useRef:wy,useState:function(){return Yh(Jl)},useDebugValue:Qh,useDeferredValue:function(s){var a=_o();return cr===null?a.memoizedState=s:Ny(a,cr.memoizedState,s)},useTransition:function(){var s=Yh(Jl)[0],a=_o().memoizedState;return[s,a]},useMutableSource:uy,useSyncExternalStore:dy,useId:Ty,unstable_isNewReconciler:!1};function Do(s,a){if(s&&s.defaultProps){a=q({},a),s=s.defaultProps;for(var f in s)a[f]===void 0&&(a[f]=s[f]);return a}return a}function Jh(s,a,f,k){a=s.memoizedState,f=f(k,a),f=f==null?a:q({},a,f),s.memoizedState=f,s.lanes===0&&(s.updateQueue.baseState=f)}var Yu={isMounted:function(s){return(s=s._reactInternals)?Hn(s)===s:!1},enqueueSetState:function(s,a,f){s=s._reactInternals;var k=Hr(),v=ti(s),x=Ss(k,v);x.payload=a,f!=null&&(x.callback=f),a=Xs(s,x,v),a!==null&&(Bo(a,s,v,k),Uu(a,s,v))},enqueueReplaceState:function(s,a,f){s=s._reactInternals;var k=Hr(),v=ti(s),x=Ss(k,v);x.tag=1,x.payload=a,f!=null&&(x.callback=f),a=Xs(s,x,v),a!==null&&(Bo(a,s,v,k),Uu(a,s,v))},enqueueForceUpdate:function(s,a){s=s._reactInternals;var f=Hr(),k=ti(s),v=Ss(f,k);v.tag=2,a!=null&&(v.callback=a),a=Xs(s,v,k),a!==null&&(Bo(a,s,k,f),Uu(a,s,k))}};function Iy(s,a,f,k,v,x,I){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(k,x,I):a.prototype&&a.prototype.isPureReactComponent?!Fl(f,k)||!Fl(v,x):!0}function $y(s,a,f){var k=!1,v=Gs,x=a.contextType;return typeof x=="object"&&x!==null?x=So(x):(v=qr(a)?Ri:Ar.current,k=a.contextTypes,x=(k=k!=null)?Ra(s,v):Gs),a=new a(f,x),s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Yu,s.stateNode=a,a._reactInternals=s,k&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=v,s.__reactInternalMemoizedMaskedChildContext=x),a}function Ry(s,a,f,k){s=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(f,k),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(f,k),a.state!==s&&Yu.enqueueReplaceState(a,a.state,null)}function ep(s,a,f,k){var v=s.stateNode;v.props=f,v.state=s.memoizedState,v.refs={},Fh(s);var x=a.contextType;typeof x=="object"&&x!==null?v.context=So(x):(x=qr(a)?Ri:Ar.current,v.context=Ra(s,x)),v.state=s.memoizedState,x=a.getDerivedStateFromProps,typeof x=="function"&&(Jh(s,a,x,f),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&&Yu.enqueueReplaceState(v,v.state,null),Hu(s,f,v,k),v.state=s.memoizedState),typeof v.componentDidMount=="function"&&(s.flags|=4194308)}function Ba(s,a){try{var f="",k=a;do f+=de(k),k=k.return;while(k);var v=f}catch(x){v=`
|
|
40
|
+
Error generating stack: `+x.message+`
|
|
41
|
+
`+x.stack}return{value:s,source:a,stack:v,digest:null}}function tp(s,a,f){return{value:s,source:null,stack:f??null,digest:a??null}}function np(s,a){try{console.error(a.value)}catch(f){setTimeout(function(){throw f})}}var Ij=typeof WeakMap=="function"?WeakMap:Map;function Oy(s,a,f){f=Ss(-1,f),f.tag=3,f.payload={element:null};var k=a.value;return f.callback=function(){rd||(rd=!0,kp=k),np(s,a)},f}function My(s,a,f){f=Ss(-1,f),f.tag=3;var k=s.type.getDerivedStateFromError;if(typeof k=="function"){var v=a.value;f.payload=function(){return k(v)},f.callback=function(){np(s,a)}}var x=s.stateNode;return x!==null&&typeof x.componentDidCatch=="function"&&(f.callback=function(){np(s,a),typeof k!="function"&&(Js===null?Js=new Set([this]):Js.add(this));var I=a.stack;this.componentDidCatch(a.value,{componentStack:I!==null?I:""})}),f}function Py(s,a,f){var k=s.pingCache;if(k===null){k=s.pingCache=new Ij;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(f)||(v.add(f),s=Kj.bind(null,s,a,f),a.then(s,s))}function Ly(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 Dy(s,a,f,k,v){return(s.mode&1)===0?(s===a?s.flags|=65536:(s.flags|=128,f.flags|=131072,f.flags&=-52805,f.tag===1&&(f.alternate===null?f.tag=17:(a=Ss(-1,1),a.tag=2,Xs(f,a,1))),f.lanes|=1),s):(s.flags|=65536,s.lanes=v,s)}var $j=j.ReactCurrentOwner,Gr=!1;function Ur(s,a,f,k){a.child=s===null?oy(a,null,f,k):La(a,s.child,f,k)}function zy(s,a,f,k,v){f=f.render;var x=a.ref;return za(a,v),k=qh(s,a,f,k,x,v),f=Gh(),s!==null&&!Gr?(a.updateQueue=s.updateQueue,a.flags&=-2053,s.lanes&=~v,_s(s,a,v)):(Fn&&f&&Ah(a),a.flags|=1,Ur(s,a,k,v),a.child)}function Fy(s,a,f,k,v){if(s===null){var x=f.type;return typeof x=="function"&&!Sp(x)&&x.defaultProps===void 0&&f.compare===null&&f.defaultProps===void 0?(a.tag=15,a.type=x,By(s,a,x,k,v)):(s=cd(f.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 I=x.memoizedProps;if(f=f.compare,f=f!==null?f:Fl,f(I,k)&&s.ref===a.ref)return _s(s,a,v)}return a.flags|=1,s=ri(x,k),s.ref=a.ref,s.return=a,a.child=s}function By(s,a,f,k,v){if(s!==null){var x=s.memoizedProps;if(Fl(x,k)&&s.ref===a.ref)if(Gr=!1,a.pendingProps=k=x,(s.lanes&v)!==0)(s.flags&131072)!==0&&(Gr=!0);else return a.lanes=s.lanes,_s(s,a,v)}return rp(s,a,f,k,v)}function Uy(s,a,f){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},Rn(Ha,po),po|=f;else{if((f&1073741824)===0)return s=x!==null?x.baseLanes|f:f,a.lanes=a.childLanes=1073741824,a.memoizedState={baseLanes:s,cachePool:null,transitions:null},a.updateQueue=null,Rn(Ha,po),po|=s,null;a.memoizedState={baseLanes:0,cachePool:null,transitions:null},k=x!==null?x.baseLanes:f,Rn(Ha,po),po|=k}else x!==null?(k=x.baseLanes|f,a.memoizedState=null):k=f,Rn(Ha,po),po|=k;return Ur(s,a,v,f),a.child}function Hy(s,a){var f=a.ref;(s===null&&f!==null||s!==null&&s.ref!==f)&&(a.flags|=512,a.flags|=2097152)}function rp(s,a,f,k,v){var x=qr(f)?Ri:Ar.current;return x=Ra(a,x),za(a,v),f=qh(s,a,f,k,x,v),k=Gh(),s!==null&&!Gr?(a.updateQueue=s.updateQueue,a.flags&=-2053,s.lanes&=~v,_s(s,a,v)):(Fn&&k&&Ah(a),a.flags|=1,Ur(s,a,f,v),a.child)}function Wy(s,a,f,k,v){if(qr(f)){var x=!0;Ou(a)}else x=!1;if(za(a,v),a.stateNode===null)Qu(s,a),$y(a,f,k),ep(a,f,k,v),k=!0;else if(s===null){var I=a.stateNode,W=a.memoizedProps;I.props=W;var X=I.context,he=f.contextType;typeof he=="object"&&he!==null?he=So(he):(he=qr(f)?Ri:Ar.current,he=Ra(a,he));var Oe=f.getDerivedStateFromProps,Pe=typeof Oe=="function"||typeof I.getSnapshotBeforeUpdate=="function";Pe||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(W!==k||X!==he)&&Ry(a,I,k,he),Ys=!1;var $e=a.memoizedState;I.state=$e,Hu(a,k,I,v),X=a.memoizedState,W!==k||$e!==X||Zr.current||Ys?(typeof Oe=="function"&&(Jh(a,f,Oe,k),X=a.memoizedState),(W=Ys||Iy(a,f,W,k,$e,X,he))?(Pe||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount()),typeof I.componentDidMount=="function"&&(a.flags|=4194308)):(typeof I.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=k,a.memoizedState=X),I.props=k,I.state=X,I.context=he,k=W):(typeof I.componentDidMount=="function"&&(a.flags|=4194308),k=!1)}else{I=a.stateNode,iy(s,a),W=a.memoizedProps,he=a.type===a.elementType?W:Do(a.type,W),I.props=he,Pe=a.pendingProps,$e=I.context,X=f.contextType,typeof X=="object"&&X!==null?X=So(X):(X=qr(f)?Ri:Ar.current,X=Ra(a,X));var Je=f.getDerivedStateFromProps;(Oe=typeof Je=="function"||typeof I.getSnapshotBeforeUpdate=="function")||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(W!==Pe||$e!==X)&&Ry(a,I,k,X),Ys=!1,$e=a.memoizedState,I.state=$e,Hu(a,k,I,v);var ot=a.memoizedState;W!==Pe||$e!==ot||Zr.current||Ys?(typeof Je=="function"&&(Jh(a,f,Je,k),ot=a.memoizedState),(he=Ys||Iy(a,f,he,k,$e,ot,X)||!1)?(Oe||typeof I.UNSAFE_componentWillUpdate!="function"&&typeof I.componentWillUpdate!="function"||(typeof I.componentWillUpdate=="function"&&I.componentWillUpdate(k,ot,X),typeof I.UNSAFE_componentWillUpdate=="function"&&I.UNSAFE_componentWillUpdate(k,ot,X)),typeof I.componentDidUpdate=="function"&&(a.flags|=4),typeof I.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof I.componentDidUpdate!="function"||W===s.memoizedProps&&$e===s.memoizedState||(a.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||W===s.memoizedProps&&$e===s.memoizedState||(a.flags|=1024),a.memoizedProps=k,a.memoizedState=ot),I.props=k,I.state=ot,I.context=X,k=he):(typeof I.componentDidUpdate!="function"||W===s.memoizedProps&&$e===s.memoizedState||(a.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||W===s.memoizedProps&&$e===s.memoizedState||(a.flags|=1024),k=!1)}return op(s,a,f,k,x,v)}function op(s,a,f,k,v,x){Hy(s,a);var I=(a.flags&128)!==0;if(!k&&!I)return v&&Vw(a,f,!1),_s(s,a,x);k=a.stateNode,$j.current=a;var W=I&&typeof f.getDerivedStateFromError!="function"?null:k.render();return a.flags|=1,s!==null&&I?(a.child=La(a,s.child,null,x),a.child=La(a,null,W,x)):Ur(s,a,W,x),a.memoizedState=k.state,v&&Vw(a,f,!0),a.child}function Ky(s){var a=s.stateNode;a.pendingContext?qw(s,a.pendingContext,a.pendingContext!==a.context):a.context&&qw(s,a.context,!1),Bh(s,a.containerInfo)}function Zy(s,a,f,k,v){return Pa(),Oh(v),a.flags|=256,Ur(s,a,f,k),a.child}var sp={dehydrated:null,treeContext:null,retryLane:0};function ip(s){return{baseLanes:s,cachePool:null,transitions:null}}function qy(s,a,f){var k=a.pendingProps,v=Zn.current,x=!1,I=(a.flags&128)!==0,W;if((W=I)||(W=s!==null&&s.memoizedState===null?!1:(v&2)!==0),W?(x=!0,a.flags&=-129):(s===null||s.memoizedState!==null)&&(v|=1),Rn(Zn,v&1),s===null)return Rh(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):(I=k.children,s=k.fallback,x?(k=a.mode,x=a.child,I={mode:"hidden",children:I},(k&1)===0&&x!==null?(x.childLanes=0,x.pendingProps=I):x=ud(I,k,0,null),s=Hi(s,k,f,null),x.return=a,s.return=a,x.sibling=s,a.child=x,a.child.memoizedState=ip(f),a.memoizedState=sp,s):ap(a,I));if(v=s.memoizedState,v!==null&&(W=v.dehydrated,W!==null))return Rj(s,a,I,k,W,v,f);if(x){x=k.fallback,I=a.mode,v=s.child,W=v.sibling;var X={mode:"hidden",children:k.children};return(I&1)===0&&a.child!==v?(k=a.child,k.childLanes=0,k.pendingProps=X,a.deletions=null):(k=ri(v,X),k.subtreeFlags=v.subtreeFlags&14680064),W!==null?x=ri(W,x):(x=Hi(x,I,f,null),x.flags|=2),x.return=a,k.return=a,k.sibling=x,a.child=k,k=x,x=a.child,I=s.child.memoizedState,I=I===null?ip(f):{baseLanes:I.baseLanes|f,cachePool:null,transitions:I.transitions},x.memoizedState=I,x.childLanes=s.childLanes&~f,a.memoizedState=sp,k}return x=s.child,s=x.sibling,k=ri(x,{mode:"visible",children:k.children}),(a.mode&1)===0&&(k.lanes=f),k.return=a,k.sibling=null,s!==null&&(f=a.deletions,f===null?(a.deletions=[s],a.flags|=16):f.push(s)),a.child=k,a.memoizedState=null,k}function ap(s,a){return a=ud({mode:"visible",children:a},s.mode,0,null),a.return=s,s.child=a}function Xu(s,a,f,k){return k!==null&&Oh(k),La(a,s.child,null,f),s=ap(a,a.pendingProps.children),s.flags|=2,a.memoizedState=null,s}function Rj(s,a,f,k,v,x,I){if(f)return a.flags&256?(a.flags&=-257,k=tp(Error(n(422))),Xu(s,a,I,k)):a.memoizedState!==null?(a.child=s.child,a.flags|=128,null):(x=k.fallback,v=a.mode,k=ud({mode:"visible",children:k.children},v,0,null),x=Hi(x,v,I,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,I),a.child.memoizedState=ip(I),a.memoizedState=sp,x);if((a.mode&1)===0)return Xu(s,a,I,null);if(v.data==="$!"){if(k=v.nextSibling&&v.nextSibling.dataset,k)var W=k.dgst;return k=W,x=Error(n(419)),k=tp(x,k,void 0),Xu(s,a,I,k)}if(W=(I&s.childLanes)!==0,Gr||W){if(k=gr,k!==null){switch(I&-I){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|I))!==0?0:v,v!==0&&v!==x.retryLane&&(x.retryLane=v,Es(s,v),Bo(k,s,v,-1))}return Ep(),k=tp(Error(n(421))),Xu(s,a,I,k)}return v.data==="$?"?(a.flags|=128,a.child=s.child,a=Zj.bind(null,s),v._reactRetry=a,null):(s=x.treeContext,ho=Zs(v.nextSibling),fo=a,Fn=!0,Lo=null,s!==null&&(xo[Eo++]=bs,xo[Eo++]=xs,xo[Eo++]=Oi,bs=s.id,xs=s.overflow,Oi=a),a=ap(a,k.children),a.flags|=4096,a)}function Gy(s,a,f){s.lanes|=a;var k=s.alternate;k!==null&&(k.lanes|=a),Dh(s.return,a,f)}function lp(s,a,f,k,v){var x=s.memoizedState;x===null?s.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:k,tail:f,tailMode:v}:(x.isBackwards=a,x.rendering=null,x.renderingStartTime=0,x.last=k,x.tail=f,x.tailMode=v)}function Vy(s,a,f){var k=a.pendingProps,v=k.revealOrder,x=k.tail;if(Ur(s,a,k.children,f),k=Zn.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&&Gy(s,f,a);else if(s.tag===19)Gy(s,f,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(Rn(Zn,k),(a.mode&1)===0)a.memoizedState=null;else switch(v){case"forwards":for(f=a.child,v=null;f!==null;)s=f.alternate,s!==null&&Wu(s)===null&&(v=f),f=f.sibling;f=v,f===null?(v=a.child,a.child=null):(v=f.sibling,f.sibling=null),lp(a,!1,v,f,x);break;case"backwards":for(f=null,v=a.child,a.child=null;v!==null;){if(s=v.alternate,s!==null&&Wu(s)===null){a.child=v;break}s=v.sibling,v.sibling=f,f=v,v=s}lp(a,!0,f,null,x);break;case"together":lp(a,!1,null,null,void 0);break;default:a.memoizedState=null}return a.child}function Qu(s,a){(a.mode&1)===0&&s!==null&&(s.alternate=null,a.alternate=null,a.flags|=2)}function _s(s,a,f){if(s!==null&&(a.dependencies=s.dependencies),zi|=a.lanes,(f&a.childLanes)===0)return null;if(s!==null&&a.child!==s.child)throw Error(n(153));if(a.child!==null){for(s=a.child,f=ri(s,s.pendingProps),a.child=f,f.return=a;s.sibling!==null;)s=s.sibling,f=f.sibling=ri(s,s.pendingProps),f.return=a;f.sibling=null}return a.child}function Oj(s,a,f){switch(a.tag){case 3:Ky(a),Pa();break;case 5:cy(a);break;case 1:qr(a.type)&&Ou(a);break;case 4:Bh(a,a.stateNode.containerInfo);break;case 10:var k=a.type._context,v=a.memoizedProps.value;Rn(Fu,k._currentValue),k._currentValue=v;break;case 13:if(k=a.memoizedState,k!==null)return k.dehydrated!==null?(Rn(Zn,Zn.current&1),a.flags|=128,null):(f&a.child.childLanes)!==0?qy(s,a,f):(Rn(Zn,Zn.current&1),s=_s(s,a,f),s!==null?s.sibling:null);Rn(Zn,Zn.current&1);break;case 19:if(k=(f&a.childLanes)!==0,(s.flags&128)!==0){if(k)return Vy(s,a,f);a.flags|=128}if(v=a.memoizedState,v!==null&&(v.rendering=null,v.tail=null,v.lastEffect=null),Rn(Zn,Zn.current),k)break;return null;case 22:case 23:return a.lanes=0,Uy(s,a,f)}return _s(s,a,f)}var Yy,cp,Xy,Qy;Yy=function(s,a){for(var f=a.child;f!==null;){if(f.tag===5||f.tag===6)s.appendChild(f.stateNode);else if(f.tag!==4&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===a)break;for(;f.sibling===null;){if(f.return===null||f.return===a)return;f=f.return}f.sibling.return=f.return,f=f.sibling}},cp=function(){},Xy=function(s,a,f,k){var v=s.memoizedProps;if(v!==k){s=a.stateNode,Li(ns.current);var x=null;switch(f){case"input":v=je(s,v),k=je(s,k),x=[];break;case"select":v=q({},v,{value:void 0}),k=q({},k,{value:void 0}),x=[];break;case"textarea":v=zt(s,v),k=zt(s,k),x=[];break;default:typeof v.onClick!="function"&&typeof k.onClick=="function"&&(s.onclick=Iu)}pe(f,k);var I;f=null;for(he in v)if(!k.hasOwnProperty(he)&&v.hasOwnProperty(he)&&v[he]!=null)if(he==="style"){var W=v[he];for(I in W)W.hasOwnProperty(I)&&(f||(f={}),f[I]="")}else he!=="dangerouslySetInnerHTML"&&he!=="children"&&he!=="suppressContentEditableWarning"&&he!=="suppressHydrationWarning"&&he!=="autoFocus"&&(o.hasOwnProperty(he)?x||(x=[]):(x=x||[]).push(he,null));for(he in k){var X=k[he];if(W=v!=null?v[he]:void 0,k.hasOwnProperty(he)&&X!==W&&(X!=null||W!=null))if(he==="style")if(W){for(I in W)!W.hasOwnProperty(I)||X&&X.hasOwnProperty(I)||(f||(f={}),f[I]="");for(I in X)X.hasOwnProperty(I)&&W[I]!==X[I]&&(f||(f={}),f[I]=X[I])}else f||(x||(x=[]),x.push(he,f)),f=X;else he==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,W=W?W.__html:void 0,X!=null&&W!==X&&(x=x||[]).push(he,X)):he==="children"?typeof X!="string"&&typeof X!="number"||(x=x||[]).push(he,""+X):he!=="suppressContentEditableWarning"&&he!=="suppressHydrationWarning"&&(o.hasOwnProperty(he)?(X!=null&&he==="onScroll"&&Ln("scroll",s),x||W===X||(x=[])):(x=x||[]).push(he,X))}f&&(x=x||[]).push("style",f);var he=x;(a.updateQueue=he)&&(a.flags|=4)}},Qy=function(s,a,f,k){f!==k&&(a.flags|=4)};function tc(s,a){if(!Fn)switch(s.tailMode){case"hidden":a=s.tail;for(var f=null;a!==null;)a.alternate!==null&&(f=a),a=a.sibling;f===null?s.tail=null:f.sibling=null;break;case"collapsed":f=s.tail;for(var k=null;f!==null;)f.alternate!==null&&(k=f),f=f.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,f=0,k=0;if(a)for(var v=s.child;v!==null;)f|=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;)f|=v.lanes|v.childLanes,k|=v.subtreeFlags,k|=v.flags,v.return=s,v=v.sibling;return s.subtreeFlags|=k,s.childLanes=f,a}function Mj(s,a,f){var k=a.pendingProps;switch(Ih(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 qr(a.type)&&Ru(),$r(a),null;case 3:return k=a.stateNode,Fa(),Dn(Zr),Dn(Ar),Wh(),k.pendingContext&&(k.context=k.pendingContext,k.pendingContext=null),(s===null||s.child===null)&&(Du(a)?a.flags|=4:s===null||s.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,Lo!==null&&(vp(Lo),Lo=null))),cp(s,a),$r(a),null;case 5:Uh(a);var v=Li(Yl.current);if(f=a.type,s!==null&&a.stateNode!=null)Xy(s,a,f,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=Li(ns.current),Du(a)){k=a.stateNode,f=a.type;var x=a.memoizedProps;switch(k[ts]=a,k[Kl]=x,s=(a.mode&1)!==0,f){case"dialog":Ln("cancel",k),Ln("close",k);break;case"iframe":case"object":case"embed":Ln("load",k);break;case"video":case"audio":for(v=0;v<Ul.length;v++)Ln(Ul[v],k);break;case"source":Ln("error",k);break;case"img":case"image":case"link":Ln("error",k),Ln("load",k);break;case"details":Ln("toggle",k);break;case"input":Ce(k,x),Ln("invalid",k);break;case"select":k._wrapperState={wasMultiple:!!x.multiple},Ln("invalid",k);break;case"textarea":Ht(k,x),Ln("invalid",k)}pe(f,x),v=null;for(var I in x)if(x.hasOwnProperty(I)){var W=x[I];I==="children"?typeof W=="string"?k.textContent!==W&&(x.suppressHydrationWarning!==!0&&Au(k.textContent,W,s),v=["children",W]):typeof W=="number"&&k.textContent!==""+W&&(x.suppressHydrationWarning!==!0&&Au(k.textContent,W,s),v=["children",""+W]):o.hasOwnProperty(I)&&W!=null&&I==="onScroll"&&Ln("scroll",k)}switch(f){case"input":ke(k),wt(k,x,!0);break;case"textarea":ke(k),_t(k);break;case"select":case"option":break;default:typeof x.onClick=="function"&&(k.onclick=Iu)}k=v,a.updateQueue=k,k!==null&&(a.flags|=4)}else{I=v.nodeType===9?v:v.ownerDocument,s==="http://www.w3.org/1999/xhtml"&&(s=sn(f)),s==="http://www.w3.org/1999/xhtml"?f==="script"?(s=I.createElement("div"),s.innerHTML="<script><\/script>",s=s.removeChild(s.firstChild)):typeof k.is=="string"?s=I.createElement(f,{is:k.is}):(s=I.createElement(f),f==="select"&&(I=s,k.multiple?I.multiple=!0:k.size&&(I.size=k.size))):s=I.createElementNS(s,f),s[ts]=a,s[Kl]=k,Yy(s,a,!1,!1),a.stateNode=s;e:{switch(I=Ye(f,k),f){case"dialog":Ln("cancel",s),Ln("close",s),v=k;break;case"iframe":case"object":case"embed":Ln("load",s),v=k;break;case"video":case"audio":for(v=0;v<Ul.length;v++)Ln(Ul[v],s);v=k;break;case"source":Ln("error",s),v=k;break;case"img":case"image":case"link":Ln("error",s),Ln("load",s),v=k;break;case"details":Ln("toggle",s),v=k;break;case"input":Ce(s,k),v=je(s,k),Ln("invalid",s);break;case"option":v=k;break;case"select":s._wrapperState={wasMultiple:!!k.multiple},v=q({},k,{value:void 0}),Ln("invalid",s);break;case"textarea":Ht(s,k),v=zt(s,k),Ln("invalid",s);break;default:v=k}pe(f,v),W=v;for(x in W)if(W.hasOwnProperty(x)){var X=W[x];x==="style"?Qt(s,X):x==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,X!=null&&jt(s,X)):x==="children"?typeof X=="string"?(f!=="textarea"||X!=="")&&Kt(s,X):typeof X=="number"&&Kt(s,""+X):x!=="suppressContentEditableWarning"&&x!=="suppressHydrationWarning"&&x!=="autoFocus"&&(o.hasOwnProperty(x)?X!=null&&x==="onScroll"&&Ln("scroll",s):X!=null&&N(s,x,X,I))}switch(f){case"input":ke(s),wt(s,k,!1);break;case"textarea":ke(s),_t(s);break;case"option":k.value!=null&&s.setAttribute("value",""+G(k.value));break;case"select":s.multiple=!!k.multiple,x=k.value,x!=null?Yt(s,!!k.multiple,x,!1):k.defaultValue!=null&&Yt(s,!!k.multiple,k.defaultValue,!0);break;default:typeof v.onClick=="function"&&(s.onclick=Iu)}switch(f){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)Qy(s,a,s.memoizedProps,k);else{if(typeof k!="string"&&a.stateNode===null)throw Error(n(166));if(f=Li(Yl.current),Li(ns.current),Du(a)){if(k=a.stateNode,f=a.memoizedProps,k[ts]=a,(x=k.nodeValue!==f)&&(s=fo,s!==null))switch(s.tag){case 3:Au(k.nodeValue,f,(s.mode&1)!==0);break;case 5:s.memoizedProps.suppressHydrationWarning!==!0&&Au(k.nodeValue,f,(s.mode&1)!==0)}x&&(a.flags|=4)}else k=(f.nodeType===9?f:f.ownerDocument).createTextNode(k),k[ts]=a,a.stateNode=k}return $r(a),null;case 13:if(Dn(Zn),k=a.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(Fn&&ho!==null&&(a.mode&1)!==0&&(a.flags&128)===0)ty(),Pa(),a.flags|=98560,x=!1;else if(x=Du(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[ts]=a}else Pa(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;$r(a),x=!1}else Lo!==null&&(vp(Lo),Lo=null),x=!0;if(!x)return a.flags&65536?a:null}return(a.flags&128)!==0?(a.lanes=f,a):(k=k!==null,k!==(s!==null&&s.memoizedState!==null)&&k&&(a.child.flags|=8192,(a.mode&1)!==0&&(s===null||(Zn.current&1)!==0?ur===0&&(ur=3):Ep())),a.updateQueue!==null&&(a.flags|=4),$r(a),null);case 4:return Fa(),cp(s,a),s===null&&Hl(a.stateNode.containerInfo),$r(a),null;case 10:return Lh(a.type._context),$r(a),null;case 17:return qr(a.type)&&Ru(),$r(a),null;case 19:if(Dn(Zn),x=a.memoizedState,x===null)return $r(a),null;if(k=(a.flags&128)!==0,I=x.rendering,I===null)if(k)tc(x,!1);else{if(ur!==0||s!==null&&(s.flags&128)!==0)for(s=a.child;s!==null;){if(I=Wu(s),I!==null){for(a.flags|=128,tc(x,!1),k=I.updateQueue,k!==null&&(a.updateQueue=k,a.flags|=4),a.subtreeFlags=0,k=f,f=a.child;f!==null;)x=f,s=k,x.flags&=14680066,I=x.alternate,I===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=I.childLanes,x.lanes=I.lanes,x.child=I.child,x.subtreeFlags=0,x.deletions=null,x.memoizedProps=I.memoizedProps,x.memoizedState=I.memoizedState,x.updateQueue=I.updateQueue,x.type=I.type,s=I.dependencies,x.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),f=f.sibling;return Rn(Zn,Zn.current&1|2),a.child}s=s.sibling}x.tail!==null&&hn()>Wa&&(a.flags|=128,k=!0,tc(x,!1),a.lanes=4194304)}else{if(!k)if(s=Wu(I),s!==null){if(a.flags|=128,k=!0,f=s.updateQueue,f!==null&&(a.updateQueue=f,a.flags|=4),tc(x,!0),x.tail===null&&x.tailMode==="hidden"&&!I.alternate&&!Fn)return $r(a),null}else 2*hn()-x.renderingStartTime>Wa&&f!==1073741824&&(a.flags|=128,k=!0,tc(x,!1),a.lanes=4194304);x.isBackwards?(I.sibling=a.child,a.child=I):(f=x.last,f!==null?f.sibling=I:a.child=I,x.last=I)}return x.tail!==null?(a=x.tail,x.rendering=a,x.tail=a.sibling,x.renderingStartTime=hn(),a.sibling=null,f=Zn.current,Rn(Zn,k?f&1|2:f&1),a):($r(a),null);case 22:case 23:return xp(),k=a.memoizedState!==null,s!==null&&s.memoizedState!==null!==k&&(a.flags|=8192),k&&(a.mode&1)!==0?(po&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 Pj(s,a){switch(Ih(a),a.tag){case 1:return qr(a.type)&&Ru(),s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 3:return Fa(),Dn(Zr),Dn(Ar),Wh(),s=a.flags,(s&65536)!==0&&(s&128)===0?(a.flags=s&-65537|128,a):null;case 5:return Uh(a),null;case 13:if(Dn(Zn),s=a.memoizedState,s!==null&&s.dehydrated!==null){if(a.alternate===null)throw Error(n(340));Pa()}return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 19:return Dn(Zn),null;case 4:return Fa(),null;case 10:return Lh(a.type._context),null;case 22:case 23:return xp(),null;case 24:return null;default:return null}}var Ju=!1,Rr=!1,Lj=typeof WeakSet=="function"?WeakSet:Set,tt=null;function Ua(s,a){var f=s.ref;if(f!==null)if(typeof f=="function")try{f(null)}catch(k){Qn(s,a,k)}else f.current=null}function up(s,a,f){try{f()}catch(k){Qn(s,a,k)}}var Jy=!1;function Dj(s,a){if(xh=Ps,s=Iw(),ph(s)){if("selectionStart"in s)var f={start:s.selectionStart,end:s.selectionEnd};else e:{f=(f=s.ownerDocument)&&f.defaultView||window;var k=f.getSelection&&f.getSelection();if(k&&k.rangeCount!==0){f=k.anchorNode;var v=k.anchorOffset,x=k.focusNode;k=k.focusOffset;try{f.nodeType,x.nodeType}catch{f=null;break e}var I=0,W=-1,X=-1,he=0,Oe=0,Pe=s,$e=null;t:for(;;){for(var Je;Pe!==f||v!==0&&Pe.nodeType!==3||(W=I+v),Pe!==x||k!==0&&Pe.nodeType!==3||(X=I+k),Pe.nodeType===3&&(I+=Pe.nodeValue.length),(Je=Pe.firstChild)!==null;)$e=Pe,Pe=Je;for(;;){if(Pe===s)break t;if($e===f&&++he===v&&(W=I),$e===x&&++Oe===k&&(X=I),(Je=Pe.nextSibling)!==null)break;Pe=$e,$e=Pe.parentNode}Pe=Je}f=W===-1||X===-1?null:{start:W,end:X}}else f=null}f=f||{start:0,end:0}}else f=null;for(Eh={focusedElem:s,selectionRange:f},Ps=!1,tt=a;tt!==null;)if(a=tt,s=a.child,(a.subtreeFlags&1028)!==0&&s!==null)s.return=a,tt=s;else for(;tt!==null;){a=tt;try{var ot=a.alternate;if((a.flags&1024)!==0)switch(a.tag){case 0:case 11:case 15:break;case 1:if(ot!==null){var st=ot.memoizedProps,Jn=ot.memoizedState,le=a.stateNode,ee=le.getSnapshotBeforeUpdate(a.elementType===a.type?st:Do(a.type,st),Jn);le.__reactInternalSnapshotBeforeUpdate=ee}break;case 3:var ce=a.stateNode.containerInfo;ce.nodeType===1?ce.textContent="":ce.nodeType===9&&ce.documentElement&&ce.removeChild(ce.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Ue){Qn(a,a.return,Ue)}if(s=a.sibling,s!==null){s.return=a.return,tt=s;break}tt=a.return}return ot=Jy,Jy=!1,ot}function nc(s,a,f){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&&up(a,f,x)}v=v.next}while(v!==k)}}function ed(s,a){if(a=a.updateQueue,a=a!==null?a.lastEffect:null,a!==null){var f=a=a.next;do{if((f.tag&s)===s){var k=f.create;f.destroy=k()}f=f.next}while(f!==a)}}function dp(s){var a=s.ref;if(a!==null){var f=s.stateNode;switch(s.tag){case 5:s=f;break;default:s=f}typeof a=="function"?a(s):a.current=s}}function ev(s){var a=s.alternate;a!==null&&(s.alternate=null,ev(a)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(a=s.stateNode,a!==null&&(delete a[ts],delete a[Kl],delete a[Th],delete a[vj],delete a[bj])),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 tv(s){return s.tag===5||s.tag===3||s.tag===4}function nv(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||tv(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 fp(s,a,f){var k=s.tag;if(k===5||k===6)s=s.stateNode,a?f.nodeType===8?f.parentNode.insertBefore(s,a):f.insertBefore(s,a):(f.nodeType===8?(a=f.parentNode,a.insertBefore(s,f)):(a=f,a.appendChild(s)),f=f._reactRootContainer,f!=null||a.onclick!==null||(a.onclick=Iu));else if(k!==4&&(s=s.child,s!==null))for(fp(s,a,f),s=s.sibling;s!==null;)fp(s,a,f),s=s.sibling}function hp(s,a,f){var k=s.tag;if(k===5||k===6)s=s.stateNode,a?f.insertBefore(s,a):f.appendChild(s);else if(k!==4&&(s=s.child,s!==null))for(hp(s,a,f),s=s.sibling;s!==null;)hp(s,a,f),s=s.sibling}var Er=null,zo=!1;function Qs(s,a,f){for(f=f.child;f!==null;)rv(s,a,f),f=f.sibling}function rv(s,a,f){if(et&&typeof et.onCommitFiberUnmount=="function")try{et.onCommitFiberUnmount(rt,f)}catch{}switch(f.tag){case 5:Rr||Ua(f,a);case 6:var k=Er,v=zo;Er=null,Qs(s,a,f),Er=k,zo=v,Er!==null&&(zo?(s=Er,f=f.stateNode,s.nodeType===8?s.parentNode.removeChild(f):s.removeChild(f)):Er.removeChild(f.stateNode));break;case 18:Er!==null&&(zo?(s=Er,f=f.stateNode,s.nodeType===8?Nh(s.parentNode,f):s.nodeType===1&&Nh(s,f),es(s)):Nh(Er,f.stateNode));break;case 4:k=Er,v=zo,Er=f.stateNode.containerInfo,zo=!0,Qs(s,a,f),Er=k,zo=v;break;case 0:case 11:case 14:case 15:if(!Rr&&(k=f.updateQueue,k!==null&&(k=k.lastEffect,k!==null))){v=k=k.next;do{var x=v,I=x.destroy;x=x.tag,I!==void 0&&((x&2)!==0||(x&4)!==0)&&up(f,a,I),v=v.next}while(v!==k)}Qs(s,a,f);break;case 1:if(!Rr&&(Ua(f,a),k=f.stateNode,typeof k.componentWillUnmount=="function"))try{k.props=f.memoizedProps,k.state=f.memoizedState,k.componentWillUnmount()}catch(W){Qn(f,a,W)}Qs(s,a,f);break;case 21:Qs(s,a,f);break;case 22:f.mode&1?(Rr=(k=Rr)||f.memoizedState!==null,Qs(s,a,f),Rr=k):Qs(s,a,f);break;default:Qs(s,a,f)}}function ov(s){var a=s.updateQueue;if(a!==null){s.updateQueue=null;var f=s.stateNode;f===null&&(f=s.stateNode=new Lj),a.forEach(function(k){var v=qj.bind(null,s,k);f.has(k)||(f.add(k),k.then(v,v))})}}function Fo(s,a){var f=a.deletions;if(f!==null)for(var k=0;k<f.length;k++){var v=f[k];try{var x=s,I=a,W=I;e:for(;W!==null;){switch(W.tag){case 5:Er=W.stateNode,zo=!1;break e;case 3:Er=W.stateNode.containerInfo,zo=!0;break e;case 4:Er=W.stateNode.containerInfo,zo=!0;break e}W=W.return}if(Er===null)throw Error(n(160));rv(x,I,v),Er=null,zo=!1;var X=v.alternate;X!==null&&(X.return=null),v.return=null}catch(he){Qn(v,a,he)}}if(a.subtreeFlags&12854)for(a=a.child;a!==null;)sv(a,s),a=a.sibling}function sv(s,a){var f=s.alternate,k=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:if(Fo(a,s),os(s),k&4){try{nc(3,s,s.return),ed(3,s)}catch(st){Qn(s,s.return,st)}try{nc(5,s,s.return)}catch(st){Qn(s,s.return,st)}}break;case 1:Fo(a,s),os(s),k&512&&f!==null&&Ua(f,f.return);break;case 5:if(Fo(a,s),os(s),k&512&&f!==null&&Ua(f,f.return),s.flags&32){var v=s.stateNode;try{Kt(v,"")}catch(st){Qn(s,s.return,st)}}if(k&4&&(v=s.stateNode,v!=null)){var x=s.memoizedProps,I=f!==null?f.memoizedProps:x,W=s.type,X=s.updateQueue;if(s.updateQueue=null,X!==null)try{W==="input"&&x.type==="radio"&&x.name!=null&&Se(v,x),Ye(W,I);var he=Ye(W,x);for(I=0;I<X.length;I+=2){var Oe=X[I],Pe=X[I+1];Oe==="style"?Qt(v,Pe):Oe==="dangerouslySetInnerHTML"?jt(v,Pe):Oe==="children"?Kt(v,Pe):N(v,Oe,Pe,he)}switch(W){case"input":Me(v,x);break;case"textarea":De(v,x);break;case"select":var $e=v._wrapperState.wasMultiple;v._wrapperState.wasMultiple=!!x.multiple;var Je=x.value;Je!=null?Yt(v,!!x.multiple,Je,!1):$e!==!!x.multiple&&(x.defaultValue!=null?Yt(v,!!x.multiple,x.defaultValue,!0):Yt(v,!!x.multiple,x.multiple?[]:"",!1))}v[Kl]=x}catch(st){Qn(s,s.return,st)}}break;case 6:if(Fo(a,s),os(s),k&4){if(s.stateNode===null)throw Error(n(162));v=s.stateNode,x=s.memoizedProps;try{v.nodeValue=x}catch(st){Qn(s,s.return,st)}}break;case 3:if(Fo(a,s),os(s),k&4&&f!==null&&f.memoizedState.isDehydrated)try{es(a.containerInfo)}catch(st){Qn(s,s.return,st)}break;case 4:Fo(a,s),os(s);break;case 13:Fo(a,s),os(s),v=s.child,v.flags&8192&&(x=v.memoizedState!==null,v.stateNode.isHidden=x,!x||v.alternate!==null&&v.alternate.memoizedState!==null||(gp=hn())),k&4&&ov(s);break;case 22:if(Oe=f!==null&&f.memoizedState!==null,s.mode&1?(Rr=(he=Rr)||Oe,Fo(a,s),Rr=he):Fo(a,s),os(s),k&8192){if(he=s.memoizedState!==null,(s.stateNode.isHidden=he)&&!Oe&&(s.mode&1)!==0)for(tt=s,Oe=s.child;Oe!==null;){for(Pe=tt=Oe;tt!==null;){switch($e=tt,Je=$e.child,$e.tag){case 0:case 11:case 14:case 15:nc(4,$e,$e.return);break;case 1:Ua($e,$e.return);var ot=$e.stateNode;if(typeof ot.componentWillUnmount=="function"){k=$e,f=$e.return;try{a=k,ot.props=a.memoizedProps,ot.state=a.memoizedState,ot.componentWillUnmount()}catch(st){Qn(k,f,st)}}break;case 5:Ua($e,$e.return);break;case 22:if($e.memoizedState!==null){lv(Pe);continue}}Je!==null?(Je.return=$e,tt=Je):lv(Pe)}Oe=Oe.sibling}e:for(Oe=null,Pe=s;;){if(Pe.tag===5){if(Oe===null){Oe=Pe;try{v=Pe.stateNode,he?(x=v.style,typeof x.setProperty=="function"?x.setProperty("display","none","important"):x.display="none"):(W=Pe.stateNode,X=Pe.memoizedProps.style,I=X!=null&&X.hasOwnProperty("display")?X.display:null,W.style.display=jn("display",I))}catch(st){Qn(s,s.return,st)}}}else if(Pe.tag===6){if(Oe===null)try{Pe.stateNode.nodeValue=he?"":Pe.memoizedProps}catch(st){Qn(s,s.return,st)}}else if((Pe.tag!==22&&Pe.tag!==23||Pe.memoizedState===null||Pe===s)&&Pe.child!==null){Pe.child.return=Pe,Pe=Pe.child;continue}if(Pe===s)break e;for(;Pe.sibling===null;){if(Pe.return===null||Pe.return===s)break e;Oe===Pe&&(Oe=null),Pe=Pe.return}Oe===Pe&&(Oe=null),Pe.sibling.return=Pe.return,Pe=Pe.sibling}}break;case 19:Fo(a,s),os(s),k&4&&ov(s);break;case 21:break;default:Fo(a,s),os(s)}}function os(s){var a=s.flags;if(a&2){try{e:{for(var f=s.return;f!==null;){if(tv(f)){var k=f;break e}f=f.return}throw Error(n(160))}switch(k.tag){case 5:var v=k.stateNode;k.flags&32&&(Kt(v,""),k.flags&=-33);var x=nv(s);hp(s,x,v);break;case 3:case 4:var I=k.stateNode.containerInfo,W=nv(s);fp(s,W,I);break;default:throw Error(n(161))}}catch(X){Qn(s,s.return,X)}s.flags&=-3}a&4096&&(s.flags&=-4097)}function zj(s,a,f){tt=s,iv(s)}function iv(s,a,f){for(var k=(s.mode&1)!==0;tt!==null;){var v=tt,x=v.child;if(v.tag===22&&k){var I=v.memoizedState!==null||Ju;if(!I){var W=v.alternate,X=W!==null&&W.memoizedState!==null||Rr;W=Ju;var he=Rr;if(Ju=I,(Rr=X)&&!he)for(tt=v;tt!==null;)I=tt,X=I.child,I.tag===22&&I.memoizedState!==null?cv(v):X!==null?(X.return=I,tt=X):cv(v);for(;x!==null;)tt=x,iv(x),x=x.sibling;tt=v,Ju=W,Rr=he}av(s)}else(v.subtreeFlags&8772)!==0&&x!==null?(x.return=v,tt=x):av(s)}}function av(s){for(;tt!==null;){var a=tt;if((a.flags&8772)!==0){var f=a.alternate;try{if((a.flags&8772)!==0)switch(a.tag){case 0:case 11:case 15:Rr||ed(5,a);break;case 1:var k=a.stateNode;if(a.flags&4&&!Rr)if(f===null)k.componentDidMount();else{var v=a.elementType===a.type?f.memoizedProps:Do(a.type,f.memoizedProps);k.componentDidUpdate(v,f.memoizedState,k.__reactInternalSnapshotBeforeUpdate)}var x=a.updateQueue;x!==null&&ly(a,x,k);break;case 3:var I=a.updateQueue;if(I!==null){if(f=null,a.child!==null)switch(a.child.tag){case 5:f=a.child.stateNode;break;case 1:f=a.child.stateNode}ly(a,I,f)}break;case 5:var W=a.stateNode;if(f===null&&a.flags&4){f=W;var X=a.memoizedProps;switch(a.type){case"button":case"input":case"select":case"textarea":X.autoFocus&&f.focus();break;case"img":X.src&&(f.src=X.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(a.memoizedState===null){var he=a.alternate;if(he!==null){var Oe=he.memoizedState;if(Oe!==null){var Pe=Oe.dehydrated;Pe!==null&&es(Pe)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Rr||a.flags&512&&dp(a)}catch($e){Qn(a,a.return,$e)}}if(a===s){tt=null;break}if(f=a.sibling,f!==null){f.return=a.return,tt=f;break}tt=a.return}}function lv(s){for(;tt!==null;){var a=tt;if(a===s){tt=null;break}var f=a.sibling;if(f!==null){f.return=a.return,tt=f;break}tt=a.return}}function cv(s){for(;tt!==null;){var a=tt;try{switch(a.tag){case 0:case 11:case 15:var f=a.return;try{ed(4,a)}catch(X){Qn(a,f,X)}break;case 1:var k=a.stateNode;if(typeof k.componentDidMount=="function"){var v=a.return;try{k.componentDidMount()}catch(X){Qn(a,v,X)}}var x=a.return;try{dp(a)}catch(X){Qn(a,x,X)}break;case 5:var I=a.return;try{dp(a)}catch(X){Qn(a,I,X)}}}catch(X){Qn(a,a.return,X)}if(a===s){tt=null;break}var W=a.sibling;if(W!==null){W.return=a.return,tt=W;break}tt=a.return}}var Fj=Math.ceil,td=j.ReactCurrentDispatcher,pp=j.ReactCurrentOwner,No=j.ReactCurrentBatchConfig,pn=0,gr=null,or=null,Sr=0,po=0,Ha=qs(0),ur=0,rc=null,zi=0,nd=0,mp=0,oc=null,Vr=null,gp=0,Wa=1/0,Ns=null,rd=!1,kp=null,Js=null,od=!1,ei=null,sd=0,sc=0,wp=null,id=-1,ad=0;function Hr(){return(pn&6)!==0?hn():id!==-1?id:id=hn()}function ti(s){return(s.mode&1)===0?1:(pn&2)!==0&&Sr!==0?Sr&-Sr:Ej.transition!==null?(ad===0&&(ad=vo()),ad):(s=Gt,s!==0||(s=window.event,s=s===void 0?16:ps(s.type)),s)}function Bo(s,a,f,k){if(50<sc)throw sc=0,wp=null,Error(n(185));xr(s,f,k),((pn&2)===0||s!==gr)&&(s===gr&&((pn&2)===0&&(nd|=f),ur===4&&ni(s,Sr)),Yr(s,k),f===1&&pn===0&&(a.mode&1)===0&&(Wa=hn()+500,Mu&&Vs()))}function Yr(s,a){var f=s.callbackNode;Br(s,a);var k=gt(s,s===gr?Sr:0);if(k===0)f!==null&&wn(f),s.callbackNode=null,s.callbackPriority=0;else if(a=k&-k,s.callbackPriority!==a){if(f!=null&&wn(f),a===1)s.tag===0?xj(dv.bind(null,s)):Yw(dv.bind(null,s)),wj(function(){(pn&6)===0&&Vs()}),f=null;else{switch(vt(k)){case 1:f=zr;break;case 4:f=pt;break;case 16:f=In;break;case 536870912:f=Ge;break;default:f=In}f=yv(f,uv.bind(null,s))}s.callbackPriority=a,s.callbackNode=f}}function uv(s,a){if(id=-1,ad=0,(pn&6)!==0)throw Error(n(327));var f=s.callbackNode;if(Ka()&&s.callbackNode!==f)return null;var k=gt(s,s===gr?Sr:0);if(k===0)return null;if((k&30)!==0||(k&s.expiredLanes)!==0||a)a=ld(s,k);else{a=k;var v=pn;pn|=2;var x=hv();(gr!==s||Sr!==a)&&(Ns=null,Wa=hn()+500,Bi(s,a));do try{Hj();break}catch(W){fv(s,W)}while(!0);Ph(),td.current=x,pn=v,or!==null?a=0:(gr=null,Sr=0,a=ur)}if(a!==0){if(a===2&&(v=hr(s),v!==0&&(k=v,a=yp(s,v))),a===1)throw f=rc,Bi(s,0),ni(s,k),Yr(s,hn()),f;if(a===6)ni(s,k);else{if(v=s.current.alternate,(k&30)===0&&!Bj(v)&&(a=ld(s,k),a===2&&(x=hr(s),x!==0&&(k=x,a=yp(s,x))),a===1))throw f=rc,Bi(s,0),ni(s,k),Yr(s,hn()),f;switch(s.finishedWork=v,s.finishedLanes=k,a){case 0:case 1:throw Error(n(345));case 2:Ui(s,Vr,Ns);break;case 3:if(ni(s,k),(k&130023424)===k&&(a=gp+500-hn(),10<a)){if(gt(s,0)!==0)break;if(v=s.suspendedLanes,(v&k)!==k){Hr(),s.pingedLanes|=s.suspendedLanes&v;break}s.timeoutHandle=_h(Ui.bind(null,s,Vr,Ns),a);break}Ui(s,Vr,Ns);break;case 4:if(ni(s,k),(k&4194240)===k)break;for(a=s.eventTimes,v=-1;0<k;){var I=31-yn(k);x=1<<I,I=a[I],I>v&&(v=I),k&=~x}if(k=v,k=hn()-k,k=(120>k?120:480>k?480:1080>k?1080:1920>k?1920:3e3>k?3e3:4320>k?4320:1960*Fj(k/1960))-k,10<k){s.timeoutHandle=_h(Ui.bind(null,s,Vr,Ns),k);break}Ui(s,Vr,Ns);break;case 5:Ui(s,Vr,Ns);break;default:throw Error(n(329))}}}return Yr(s,hn()),s.callbackNode===f?uv.bind(null,s):null}function yp(s,a){var f=oc;return s.current.memoizedState.isDehydrated&&(Bi(s,a).flags|=256),s=ld(s,a),s!==2&&(a=Vr,Vr=f,a!==null&&vp(a)),s}function vp(s){Vr===null?Vr=s:Vr.push.apply(Vr,s)}function Bj(s){for(var a=s;;){if(a.flags&16384){var f=a.updateQueue;if(f!==null&&(f=f.stores,f!==null))for(var k=0;k<f.length;k++){var v=f[k],x=v.getSnapshot;v=v.value;try{if(!Po(x(),v))return!1}catch{return!1}}}if(f=a.child,a.subtreeFlags&16384&&f!==null)f.return=a,a=f;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 ni(s,a){for(a&=~mp,a&=~nd,s.suspendedLanes|=a,s.pingedLanes&=~a,s=s.expirationTimes;0<a;){var f=31-yn(a),k=1<<f;s[f]=-1,a&=~k}}function dv(s){if((pn&6)!==0)throw Error(n(327));Ka();var a=gt(s,0);if((a&1)===0)return Yr(s,hn()),null;var f=ld(s,a);if(s.tag!==0&&f===2){var k=hr(s);k!==0&&(a=k,f=yp(s,k))}if(f===1)throw f=rc,Bi(s,0),ni(s,a),Yr(s,hn()),f;if(f===6)throw Error(n(345));return s.finishedWork=s.current.alternate,s.finishedLanes=a,Ui(s,Vr,Ns),Yr(s,hn()),null}function bp(s,a){var f=pn;pn|=1;try{return s(a)}finally{pn=f,pn===0&&(Wa=hn()+500,Mu&&Vs())}}function Fi(s){ei!==null&&ei.tag===0&&(pn&6)===0&&Ka();var a=pn;pn|=1;var f=No.transition,k=Gt;try{if(No.transition=null,Gt=1,s)return s()}finally{Gt=k,No.transition=f,pn=a,(pn&6)===0&&Vs()}}function xp(){po=Ha.current,Dn(Ha)}function Bi(s,a){s.finishedWork=null,s.finishedLanes=0;var f=s.timeoutHandle;if(f!==-1&&(s.timeoutHandle=-1,kj(f)),or!==null)for(f=or.return;f!==null;){var k=f;switch(Ih(k),k.tag){case 1:k=k.type.childContextTypes,k!=null&&Ru();break;case 3:Fa(),Dn(Zr),Dn(Ar),Wh();break;case 5:Uh(k);break;case 4:Fa();break;case 13:Dn(Zn);break;case 19:Dn(Zn);break;case 10:Lh(k.type._context);break;case 22:case 23:xp()}f=f.return}if(gr=s,or=s=ri(s.current,null),Sr=po=a,ur=0,rc=null,mp=nd=zi=0,Vr=oc=null,Pi!==null){for(a=0;a<Pi.length;a++)if(f=Pi[a],k=f.interleaved,k!==null){f.interleaved=null;var v=k.next,x=f.pending;if(x!==null){var I=x.next;x.next=v,k.next=I}f.pending=k}Pi=null}return s}function fv(s,a){do{var f=or;try{if(Ph(),Ku.current=Vu,Zu){for(var k=qn.memoizedState;k!==null;){var v=k.queue;v!==null&&(v.pending=null),k=k.next}Zu=!1}if(Di=0,mr=cr=qn=null,Xl=!1,Ql=0,pp.current=null,f===null||f.return===null){ur=1,rc=a,or=null;break}e:{var x=s,I=f.return,W=f,X=a;if(a=Sr,W.flags|=32768,X!==null&&typeof X=="object"&&typeof X.then=="function"){var he=X,Oe=W,Pe=Oe.tag;if((Oe.mode&1)===0&&(Pe===0||Pe===11||Pe===15)){var $e=Oe.alternate;$e?(Oe.updateQueue=$e.updateQueue,Oe.memoizedState=$e.memoizedState,Oe.lanes=$e.lanes):(Oe.updateQueue=null,Oe.memoizedState=null)}var Je=Ly(I);if(Je!==null){Je.flags&=-257,Dy(Je,I,W,x,a),Je.mode&1&&Py(x,he,a),a=Je,X=he;var ot=a.updateQueue;if(ot===null){var st=new Set;st.add(X),a.updateQueue=st}else ot.add(X);break e}else{if((a&1)===0){Py(x,he,a),Ep();break e}X=Error(n(426))}}else if(Fn&&W.mode&1){var Jn=Ly(I);if(Jn!==null){(Jn.flags&65536)===0&&(Jn.flags|=256),Dy(Jn,I,W,x,a),Oh(Ba(X,W));break e}}x=X=Ba(X,W),ur!==4&&(ur=2),oc===null?oc=[x]:oc.push(x),x=I;do{switch(x.tag){case 3:x.flags|=65536,a&=-a,x.lanes|=a;var le=Oy(x,X,a);ay(x,le);break e;case 1:W=X;var ee=x.type,ce=x.stateNode;if((x.flags&128)===0&&(typeof ee.getDerivedStateFromError=="function"||ce!==null&&typeof ce.componentDidCatch=="function"&&(Js===null||!Js.has(ce)))){x.flags|=65536,a&=-a,x.lanes|=a;var Ue=My(x,W,a);ay(x,Ue);break e}}x=x.return}while(x!==null)}mv(f)}catch(ct){a=ct,or===f&&f!==null&&(or=f=f.return);continue}break}while(!0)}function hv(){var s=td.current;return td.current=Vu,s===null?Vu:s}function Ep(){(ur===0||ur===3||ur===2)&&(ur=4),gr===null||(zi&268435455)===0&&(nd&268435455)===0||ni(gr,Sr)}function ld(s,a){var f=pn;pn|=2;var k=hv();(gr!==s||Sr!==a)&&(Ns=null,Bi(s,a));do try{Uj();break}catch(v){fv(s,v)}while(!0);if(Ph(),pn=f,td.current=k,or!==null)throw Error(n(261));return gr=null,Sr=0,ur}function Uj(){for(;or!==null;)pv(or)}function Hj(){for(;or!==null&&!tr();)pv(or)}function pv(s){var a=wv(s.alternate,s,po);s.memoizedProps=s.pendingProps,a===null?mv(s):or=a,pp.current=null}function mv(s){var a=s;do{var f=a.alternate;if(s=a.return,(a.flags&32768)===0){if(f=Mj(f,a,po),f!==null){or=f;return}}else{if(f=Pj(f,a),f!==null){f.flags&=32767,or=f;return}if(s!==null)s.flags|=32768,s.subtreeFlags=0,s.deletions=null;else{ur=6,or=null;return}}if(a=a.sibling,a!==null){or=a;return}or=a=s}while(a!==null);ur===0&&(ur=5)}function Ui(s,a,f){var k=Gt,v=No.transition;try{No.transition=null,Gt=1,Wj(s,a,f,k)}finally{No.transition=v,Gt=k}return null}function Wj(s,a,f,k){do Ka();while(ei!==null);if((pn&6)!==0)throw Error(n(327));f=s.finishedWork;var v=s.finishedLanes;if(f===null)return null;if(s.finishedWork=null,s.finishedLanes=0,f===s.current)throw Error(n(177));s.callbackNode=null,s.callbackPriority=0;var x=f.lanes|f.childLanes;if(nr(s,x),s===gr&&(or=gr=null,Sr=0),(f.subtreeFlags&2064)===0&&(f.flags&2064)===0||od||(od=!0,yv(In,function(){return Ka(),null})),x=(f.flags&15990)!==0,(f.subtreeFlags&15990)!==0||x){x=No.transition,No.transition=null;var I=Gt;Gt=1;var W=pn;pn|=4,pp.current=null,Dj(s,f),sv(f,s),uj(Eh),Ps=!!xh,Eh=xh=null,s.current=f,zj(f),fn(),pn=W,Gt=I,No.transition=x}else s.current=f;if(od&&(od=!1,ei=s,sd=v),x=s.pendingLanes,x===0&&(Js=null),cn(f.stateNode),Yr(s,hn()),a!==null)for(k=s.onRecoverableError,f=0;f<a.length;f++)v=a[f],k(v.value,{componentStack:v.stack,digest:v.digest});if(rd)throw rd=!1,s=kp,kp=null,s;return(sd&1)!==0&&s.tag!==0&&Ka(),x=s.pendingLanes,(x&1)!==0?s===wp?sc++:(sc=0,wp=s):sc=0,Vs(),null}function Ka(){if(ei!==null){var s=vt(sd),a=No.transition,f=Gt;try{if(No.transition=null,Gt=16>s?16:s,ei===null)var k=!1;else{if(s=ei,ei=null,sd=0,(pn&6)!==0)throw Error(n(331));var v=pn;for(pn|=4,tt=s.current;tt!==null;){var x=tt,I=x.child;if((tt.flags&16)!==0){var W=x.deletions;if(W!==null){for(var X=0;X<W.length;X++){var he=W[X];for(tt=he;tt!==null;){var Oe=tt;switch(Oe.tag){case 0:case 11:case 15:nc(8,Oe,x)}var Pe=Oe.child;if(Pe!==null)Pe.return=Oe,tt=Pe;else for(;tt!==null;){Oe=tt;var $e=Oe.sibling,Je=Oe.return;if(ev(Oe),Oe===he){tt=null;break}if($e!==null){$e.return=Je,tt=$e;break}tt=Je}}}var ot=x.alternate;if(ot!==null){var st=ot.child;if(st!==null){ot.child=null;do{var Jn=st.sibling;st.sibling=null,st=Jn}while(st!==null)}}tt=x}}if((x.subtreeFlags&2064)!==0&&I!==null)I.return=x,tt=I;else e:for(;tt!==null;){if(x=tt,(x.flags&2048)!==0)switch(x.tag){case 0:case 11:case 15:nc(9,x,x.return)}var le=x.sibling;if(le!==null){le.return=x.return,tt=le;break e}tt=x.return}}var ee=s.current;for(tt=ee;tt!==null;){I=tt;var ce=I.child;if((I.subtreeFlags&2064)!==0&&ce!==null)ce.return=I,tt=ce;else e:for(I=ee;tt!==null;){if(W=tt,(W.flags&2048)!==0)try{switch(W.tag){case 0:case 11:case 15:ed(9,W)}}catch(ct){Qn(W,W.return,ct)}if(W===I){tt=null;break e}var Ue=W.sibling;if(Ue!==null){Ue.return=W.return,tt=Ue;break e}tt=W.return}}if(pn=v,Vs(),et&&typeof et.onPostCommitFiberRoot=="function")try{et.onPostCommitFiberRoot(rt,s)}catch{}k=!0}return k}finally{Gt=f,No.transition=a}}return!1}function gv(s,a,f){a=Ba(f,a),a=Oy(s,a,1),s=Xs(s,a,1),a=Hr(),s!==null&&(xr(s,1,a),Yr(s,a))}function Qn(s,a,f){if(s.tag===3)gv(s,s,f);else for(;a!==null;){if(a.tag===3){gv(a,s,f);break}else if(a.tag===1){var k=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof k.componentDidCatch=="function"&&(Js===null||!Js.has(k))){s=Ba(f,s),s=My(a,s,1),a=Xs(a,s,1),s=Hr(),a!==null&&(xr(a,1,s),Yr(a,s));break}}a=a.return}}function Kj(s,a,f){var k=s.pingCache;k!==null&&k.delete(a),a=Hr(),s.pingedLanes|=s.suspendedLanes&f,gr===s&&(Sr&f)===f&&(ur===4||ur===3&&(Sr&130023424)===Sr&&500>hn()-gp?Bi(s,0):mp|=f),Yr(s,a)}function kv(s,a){a===0&&((s.mode&1)===0?a=1:(a=Qe,Qe<<=1,(Qe&130023424)===0&&(Qe=4194304)));var f=Hr();s=Es(s,a),s!==null&&(xr(s,a,f),Yr(s,f))}function Zj(s){var a=s.memoizedState,f=0;a!==null&&(f=a.retryLane),kv(s,f)}function qj(s,a){var f=0;switch(s.tag){case 13:var k=s.stateNode,v=s.memoizedState;v!==null&&(f=v.retryLane);break;case 19:k=s.stateNode;break;default:throw Error(n(314))}k!==null&&k.delete(a),kv(s,f)}var wv;wv=function(s,a,f){if(s!==null)if(s.memoizedProps!==a.pendingProps||Zr.current)Gr=!0;else{if((s.lanes&f)===0&&(a.flags&128)===0)return Gr=!1,Oj(s,a,f);Gr=(s.flags&131072)!==0}else Gr=!1,Fn&&(a.flags&1048576)!==0&&Xw(a,Lu,a.index);switch(a.lanes=0,a.tag){case 2:var k=a.type;Qu(s,a),s=a.pendingProps;var v=Ra(a,Ar.current);za(a,f),v=qh(null,a,k,s,v,f);var x=Gh();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,qr(k)?(x=!0,Ou(a)):x=!1,a.memoizedState=v.state!==null&&v.state!==void 0?v.state:null,Fh(a),v.updater=Yu,a.stateNode=v,v._reactInternals=a,ep(a,k,s,f),a=op(null,a,k,!0,x,f)):(a.tag=0,Fn&&x&&Ah(a),Ur(null,a,v,f),a=a.child),a;case 16:k=a.elementType;e:{switch(Qu(s,a),s=a.pendingProps,v=k._init,k=v(k._payload),a.type=k,v=a.tag=Vj(k),s=Do(k,s),v){case 0:a=rp(null,a,k,s,f);break e;case 1:a=Wy(null,a,k,s,f);break e;case 11:a=zy(null,a,k,s,f);break e;case 14:a=Fy(null,a,k,Do(k.type,s),f);break e}throw Error(n(306,k,""))}return a;case 0:return k=a.type,v=a.pendingProps,v=a.elementType===k?v:Do(k,v),rp(s,a,k,v,f);case 1:return k=a.type,v=a.pendingProps,v=a.elementType===k?v:Do(k,v),Wy(s,a,k,v,f);case 3:e:{if(Ky(a),s===null)throw Error(n(387));k=a.pendingProps,x=a.memoizedState,v=x.element,iy(s,a),Hu(a,k,null,f);var I=a.memoizedState;if(k=I.element,x.isDehydrated)if(x={element:k,isDehydrated:!1,cache:I.cache,pendingSuspenseBoundaries:I.pendingSuspenseBoundaries,transitions:I.transitions},a.updateQueue.baseState=x,a.memoizedState=x,a.flags&256){v=Ba(Error(n(423)),a),a=Zy(s,a,k,f,v);break e}else if(k!==v){v=Ba(Error(n(424)),a),a=Zy(s,a,k,f,v);break e}else for(ho=Zs(a.stateNode.containerInfo.firstChild),fo=a,Fn=!0,Lo=null,f=oy(a,null,k,f),a.child=f;f;)f.flags=f.flags&-3|4096,f=f.sibling;else{if(Pa(),k===v){a=_s(s,a,f);break e}Ur(s,a,k,f)}a=a.child}return a;case 5:return cy(a),s===null&&Rh(a),k=a.type,v=a.pendingProps,x=s!==null?s.memoizedProps:null,I=v.children,Sh(k,v)?I=null:x!==null&&Sh(k,x)&&(a.flags|=32),Hy(s,a),Ur(s,a,I,f),a.child;case 6:return s===null&&Rh(a),null;case 13:return qy(s,a,f);case 4:return Bh(a,a.stateNode.containerInfo),k=a.pendingProps,s===null?a.child=La(a,null,k,f):Ur(s,a,k,f),a.child;case 11:return k=a.type,v=a.pendingProps,v=a.elementType===k?v:Do(k,v),zy(s,a,k,v,f);case 7:return Ur(s,a,a.pendingProps,f),a.child;case 8:return Ur(s,a,a.pendingProps.children,f),a.child;case 12:return Ur(s,a,a.pendingProps.children,f),a.child;case 10:e:{if(k=a.type._context,v=a.pendingProps,x=a.memoizedProps,I=v.value,Rn(Fu,k._currentValue),k._currentValue=I,x!==null)if(Po(x.value,I)){if(x.children===v.children&&!Zr.current){a=_s(s,a,f);break e}}else for(x=a.child,x!==null&&(x.return=a);x!==null;){var W=x.dependencies;if(W!==null){I=x.child;for(var X=W.firstContext;X!==null;){if(X.context===k){if(x.tag===1){X=Ss(-1,f&-f),X.tag=2;var he=x.updateQueue;if(he!==null){he=he.shared;var Oe=he.pending;Oe===null?X.next=X:(X.next=Oe.next,Oe.next=X),he.pending=X}}x.lanes|=f,X=x.alternate,X!==null&&(X.lanes|=f),Dh(x.return,f,a),W.lanes|=f;break}X=X.next}}else if(x.tag===10)I=x.type===a.type?null:x.child;else if(x.tag===18){if(I=x.return,I===null)throw Error(n(341));I.lanes|=f,W=I.alternate,W!==null&&(W.lanes|=f),Dh(I,f,a),I=x.sibling}else I=x.child;if(I!==null)I.return=x;else for(I=x;I!==null;){if(I===a){I=null;break}if(x=I.sibling,x!==null){x.return=I.return,I=x;break}I=I.return}x=I}Ur(s,a,v.children,f),a=a.child}return a;case 9:return v=a.type,k=a.pendingProps.children,za(a,f),v=So(v),k=k(v),a.flags|=1,Ur(s,a,k,f),a.child;case 14:return k=a.type,v=Do(k,a.pendingProps),v=Do(k.type,v),Fy(s,a,k,v,f);case 15:return By(s,a,a.type,a.pendingProps,f);case 17:return k=a.type,v=a.pendingProps,v=a.elementType===k?v:Do(k,v),Qu(s,a),a.tag=1,qr(k)?(s=!0,Ou(a)):s=!1,za(a,f),$y(a,k,v),ep(a,k,v,f),op(null,a,k,!0,s,f);case 19:return Vy(s,a,f);case 22:return Uy(s,a,f)}throw Error(n(156,a.tag))};function yv(s,a){return kn(s,a)}function Gj(s,a,f,k){this.tag=s,this.key=f,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 To(s,a,f,k){return new Gj(s,a,f,k)}function Sp(s){return s=s.prototype,!(!s||!s.isReactComponent)}function Vj(s){if(typeof s=="function")return Sp(s)?1:0;if(s!=null){if(s=s.$$typeof,s===Q)return 11;if(s===ie)return 14}return 2}function ri(s,a){var f=s.alternate;return f===null?(f=To(s.tag,a,s.key,s.mode),f.elementType=s.elementType,f.type=s.type,f.stateNode=s.stateNode,f.alternate=s,s.alternate=f):(f.pendingProps=a,f.type=s.type,f.flags=0,f.subtreeFlags=0,f.deletions=null),f.flags=s.flags&14680064,f.childLanes=s.childLanes,f.lanes=s.lanes,f.child=s.child,f.memoizedProps=s.memoizedProps,f.memoizedState=s.memoizedState,f.updateQueue=s.updateQueue,a=s.dependencies,f.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},f.sibling=s.sibling,f.index=s.index,f.ref=s.ref,f}function cd(s,a,f,k,v,x){var I=2;if(k=s,typeof s=="function")Sp(s)&&(I=1);else if(typeof s=="string")I=5;else e:switch(s){case R:return Hi(f.children,v,x,a);case A:I=8,v|=8;break;case O:return s=To(12,f,a,v|2),s.elementType=O,s.lanes=x,s;case re:return s=To(13,f,a,v),s.elementType=re,s.lanes=x,s;case J:return s=To(19,f,a,v),s.elementType=J,s.lanes=x,s;case C:return ud(f,v,x,a);default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case B:I=10;break e;case H:I=9;break e;case Q:I=11;break e;case ie:I=14;break e;case ve:I=16,k=null;break e}throw Error(n(130,s==null?s:typeof s,""))}return a=To(I,f,a,v),a.elementType=s,a.type=k,a.lanes=x,a}function Hi(s,a,f,k){return s=To(7,s,k,a),s.lanes=f,s}function ud(s,a,f,k){return s=To(22,s,k,a),s.elementType=C,s.lanes=f,s.stateNode={isHidden:!1},s}function _p(s,a,f){return s=To(6,s,null,a),s.lanes=f,s}function Np(s,a,f){return a=To(4,s.children!==null?s.children:[],s.key,a),a.lanes=f,a.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},a}function Yj(s,a,f,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=Nr(0),this.expirationTimes=Nr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Nr(0),this.identifierPrefix=k,this.onRecoverableError=v,this.mutableSourceEagerHydrationData=null}function Tp(s,a,f,k,v,x,I,W,X){return s=new Yj(s,a,f,W,X),a===1?(a=1,x===!0&&(a|=8)):a=0,x=To(3,null,null,a),s.current=x,x.stateNode=s,x.memoizedState={element:k,isDehydrated:f,cache:null,transitions:null,pendingSuspenseBoundaries:null},Fh(x),s}function Xj(s,a,f){var k=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:P,key:k==null?null:""+k,children:s,containerInfo:a,implementation:f}}function vv(s){if(!s)return Gs;s=s._reactInternals;e:{if(Hn(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(qr(a.type)){a=a.stateNode.__reactInternalMemoizedMergedChildContext;break e}}a=a.return}while(a!==null);throw Error(n(171))}if(s.tag===1){var f=s.type;if(qr(f))return Gw(s,f,a)}return a}function bv(s,a,f,k,v,x,I,W,X){return s=Tp(f,k,!0,s,v,x,I,W,X),s.context=vv(null),f=s.current,k=Hr(),v=ti(f),x=Ss(k,v),x.callback=a??null,Xs(f,x,v),s.current.lanes=v,xr(s,v,k),Yr(s,k),s}function dd(s,a,f,k){var v=a.current,x=Hr(),I=ti(v);return f=vv(f),a.context===null?a.context=f:a.pendingContext=f,a=Ss(x,I),a.payload={element:s},k=k===void 0?null:k,k!==null&&(a.callback=k),s=Xs(v,a,I),s!==null&&(Bo(s,v,I,x),Uu(s,v,I)),I}function fd(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 xv(s,a){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var f=s.retryLane;s.retryLane=f!==0&&f<a?f:a}}function jp(s,a){xv(s,a),(s=s.alternate)&&xv(s,a)}function Qj(){return null}var Ev=typeof reportError=="function"?reportError:function(s){console.error(s)};function Cp(s){this._internalRoot=s}hd.prototype.render=Cp.prototype.render=function(s){var a=this._internalRoot;if(a===null)throw Error(n(409));dd(s,a,null,null)},hd.prototype.unmount=Cp.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var a=s.containerInfo;Fi(function(){dd(null,s,null,null)}),a[ys]=null}};function hd(s){this._internalRoot=s}hd.prototype.unstable_scheduleHydration=function(s){if(s){var a=Tr();s={blockedOn:null,target:s,priority:a};for(var f=0;f<It.length&&a!==0&&a<It[f].priority;f++);It.splice(f,0,s),f===0&&Kn(s)}};function Ap(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function pd(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11&&(s.nodeType!==8||s.nodeValue!==" react-mount-point-unstable "))}function Sv(){}function Jj(s,a,f,k,v){if(v){if(typeof k=="function"){var x=k;k=function(){var he=fd(I);x.call(he)}}var I=bv(a,k,s,0,null,!1,!1,"",Sv);return s._reactRootContainer=I,s[ys]=I.current,Hl(s.nodeType===8?s.parentNode:s),Fi(),I}for(;v=s.lastChild;)s.removeChild(v);if(typeof k=="function"){var W=k;k=function(){var he=fd(X);W.call(he)}}var X=Tp(s,0,!1,null,null,!1,!1,"",Sv);return s._reactRootContainer=X,s[ys]=X.current,Hl(s.nodeType===8?s.parentNode:s),Fi(function(){dd(a,X,f,k)}),X}function md(s,a,f,k,v){var x=f._reactRootContainer;if(x){var I=x;if(typeof v=="function"){var W=v;v=function(){var X=fd(I);W.call(X)}}dd(a,I,s,v)}else I=Jj(f,a,s,v,k);return fd(I)}fs=function(s){switch(s.tag){case 3:var a=s.stateNode;if(a.current.memoizedState.isDehydrated){var f=At(a.pendingLanes);f!==0&&(ao(a,f|1),Yr(a,hn()),(pn&6)===0&&(Wa=hn()+500,Vs()))}break;case 13:Fi(function(){var k=Es(s,1);if(k!==null){var v=Hr();Bo(k,s,1,v)}}),jp(s,1)}},En=function(s){if(s.tag===13){var a=Es(s,134217728);if(a!==null){var f=Hr();Bo(a,s,134217728,f)}jp(s,134217728)}},un=function(s){if(s.tag===13){var a=ti(s),f=Es(s,a);if(f!==null){var k=Hr();Bo(f,s,a,k)}jp(s,a)}},Tr=function(){return Gt},pr=function(s,a){var f=Gt;try{return Gt=s,a()}finally{Gt=f}},Jt=function(s,a,f){switch(a){case"input":if(Me(s,f),a=f.name,f.type==="radio"&&a!=null){for(f=s;f.parentNode;)f=f.parentNode;for(f=f.querySelectorAll("input[name="+JSON.stringify(""+a)+'][type="radio"]'),a=0;a<f.length;a++){var k=f[a];if(k!==s&&k.form===s.form){var v=$u(k);if(!v)throw Error(n(90));ne(k),Me(k,v)}}}break;case"textarea":De(s,f);break;case"select":a=f.value,a!=null&&Yt(s,!!f.multiple,a,!1)}},ze=bp,Xe=Fi;var eC={usingClientEntryPoint:!1,Events:[Zl,Ia,$u,U,me,bp]},ic={findFiberByHostInstance:$i,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},tC={bundleType:ic.bundleType,version:ic.version,rendererPackageName:ic.rendererPackageName,rendererConfig:ic.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:j.ReactCurrentDispatcher,findHostInstanceByFiber:function(s){return s=mt(s),s===null?null:s.stateNode},findFiberByHostInstance:ic.findFiberByHostInstance||Qj,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 gd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!gd.isDisabled&&gd.supportsFiber)try{rt=gd.inject(tC),et=gd}catch{}}return Xr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=eC,Xr.createPortal=function(s,a){var f=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ap(a))throw Error(n(200));return Xj(s,a,null,f)},Xr.createRoot=function(s,a){if(!Ap(s))throw Error(n(299));var f=!1,k="",v=Ev;return a!=null&&(a.unstable_strictMode===!0&&(f=!0),a.identifierPrefix!==void 0&&(k=a.identifierPrefix),a.onRecoverableError!==void 0&&(v=a.onRecoverableError)),a=Tp(s,1,!1,null,null,f,!1,k,v),s[ys]=a.current,Hl(s.nodeType===8?s.parentNode:s),new Cp(a)},Xr.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=mt(a),s=s===null?null:s.stateNode,s},Xr.flushSync=function(s){return Fi(s)},Xr.hydrate=function(s,a,f){if(!pd(a))throw Error(n(200));return md(null,s,a,!0,f)},Xr.hydrateRoot=function(s,a,f){if(!Ap(s))throw Error(n(405));var k=f!=null&&f.hydratedSources||null,v=!1,x="",I=Ev;if(f!=null&&(f.unstable_strictMode===!0&&(v=!0),f.identifierPrefix!==void 0&&(x=f.identifierPrefix),f.onRecoverableError!==void 0&&(I=f.onRecoverableError)),a=bv(a,null,s,1,f??null,v,!1,x,I),s[ys]=a.current,Hl(s),k)for(s=0;s<k.length;s++)f=k[s],v=f._getVersion,v=v(f._source),a.mutableSourceEagerHydrationData==null?a.mutableSourceEagerHydrationData=[f,v]:a.mutableSourceEagerHydrationData.push(f,v);return new hd(a)},Xr.render=function(s,a,f){if(!pd(a))throw Error(n(200));return md(null,s,a,!1,f)},Xr.unmountComponentAtNode=function(s){if(!pd(s))throw Error(n(40));return s._reactRootContainer?(Fi(function(){md(null,null,s,!1,function(){s._reactRootContainer=null,s[ys]=null})}),!0):!1},Xr.unstable_batchedUpdates=bp,Xr.unstable_renderSubtreeIntoContainer=function(s,a,f,k){if(!pd(f))throw Error(n(200));if(s==null||s._reactInternals===void 0)throw Error(n(38));return md(s,a,f,!1,k)},Xr.version="18.3.1-next-f1338f8080-20240426",Xr}var $v;function a1(){if($v)return Rp.exports;$v=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(),Rp.exports=dC(),Rp.exports}var fC=a1(),kd={},Rv;function hC(){if(Rv)return kd;Rv=1;var e=a1();return kd.createRoot=e.createRoot,kd.hydrateRoot=e.hydrateRoot,kd}var pC=hC();const mi="shell",l1="check",xm="ToolSearch",$g="AskUserQuestion",mC=new Set(["edit","delete","move","execute"]),gC=new Set(["Edit","Write","MultiEdit","NotebookEdit","Bash"]);function c1(e){return e.kind?mC.has(e.kind):gC.has(e.name)}const kC=["read","edit","delete","move","search","execute","fetch"];function Rg(e){return kC.includes(e??"")}function u1(e,t){return(Rg(e.kind)||e.name===$g||e.name===xm)&&_f(t)}function _f(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 Qc=[{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"}],Vd="auto";function wC(e){return e.branch.startsWith("toyon/")}const Ao="shell",Cs="login";function yC(e,t){return`${e}/${t}`}function vC(e,t,n,r=0){var i;let o=e;for(let l=r;l>0;l--){let c=o.length-1;for(;c>=0&&((i=o[c])==null?void 0:i.proc)!==t;)c--;if(c<0)break;o=o===e?[...o]:o,o.splice(c,1)}return n?[...o,{proc:t,line:n}]:o}const bC=["use","always","off"];function d1(e){return e.find(t=>t.id==="default")}function xC(e){const t=d1(e);if(t!=null&&t.description)return e.find(n=>n!==t&&n.name===t.description)}function _n(e){return e.worktree!==void 0}function ia(e){return e.kind==="main"}function Jc(e){return e.kind==="spare"}function wr(e){return Jc(e)||ia(e)}function Og(e){return e.kind==="worktree"}function f1(e){return e.kind==="worktree"&&wC(e)}function Yi(e){var t;return e.kind==="worktree"&&((t=e.from)==null?void 0:t.kind)!=="pr"}function Dd(e){return e.kind==="worktree"}function Nf(e){return!!e.branch&&!e.locked&&!(e.worktree&&wr(e.worktree))}const aa=e=>{var t;return e.promptedAt??((t=e.lastTurn)==null?void 0:t.at)??e.createdAt},EC=e=>wr(e)?0:1,SC=e=>e.variant?`group:${e.variant.group}`:`row:${e.id}`;function _C(e){const t=[],n=new Map;for(const r of e){const o=r.worktree,i=SC(o),l=n.get(i);if(l){l.rows.push(r),l.at=Math.max(l.at,aa(o));continue}const c={tier:EC(o),at:aa(o),rows:[r]};t.push(c),n.set(i,c)}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,c;return(((l=o.worktree.variant)==null?void 0:l.index)??0)-(((c=i.worktree.variant)==null?void 0:c.index)??0)}):r.rows)}function Ov(e,t){const n=new Map;for(const r of e)n.set(r.id,r.promptedAt??0);for(const r of t){if(!_n(r)||r.worktree.kind==="spare")continue;const o=r.worktree.repoId;n.set(o,Math.max(n.get(o)??0,aa(r.worktree)))}return[...e].sort((r,o)=>(n.get(o.id)??0)-(n.get(r.id)??0))}const Mv="not opened in ";function NC(e){const t=e.lastIndexOf(Mv);return t<0?{what:e}:{what:e.slice(0,t).replace(/,\s*$/,""),idle:e.slice(t+Mv.length)}}const h1={image:6,paste:4,file:8,pick:8},TC={image:"image",paste:"paste",file:"file",pick:"element"},jC={image:"Image",paste:"Pasted text"},p1=(e,t)=>`${jC[e]} ${t}`,Mg=e=>`at most ${h1[e]} ${TC[e]}s per message`,CC=(e,t)=>e.filter(n=>n.kind===t).length,AC=(e,t)=>Math.max(0,h1[t]-CC(e,t));function Em(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 Pg(e,t){const n={...t};return e.map(r=>[r,n[r.kind]++])}function Ec(e,t){const n={...e};for(const r of t)n[r.kind]++;return n}function Lg(e){return e>=1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}const rl=e=>`card:${e}`,zd=[{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"}],IC=new Set(["zen","close","back","forward"]);function m1(e,{guest:t=!1}={}){var r,o;if(e.altKey){if(e.metaKey||e.ctrlKey)return null;const i=zd.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=zd.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 zd){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 $C(e){return e.altKey||e.key.toLowerCase()!=="s"?!1:!!e.ctrlKey!==e.metaKey}function g1(e){const t=zd.find(n=>n.id===e);if(!t)throw new Error(`unknown chord ${e}`);return t}function RC(e,t){return e===t-1?"⌘9":e<8?`⌘${e+1}`:void 0}function OC(e,t){return t===0?null:e===9?t-1:e-1<t?e-1:null}function MC(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 PC(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 LC(e,t){const n=g1(e);return!!n.textKeeps&&MC(t)&&!(n.emptyGives&&PC(t))}const DC=["Find","Preview","Panels","Worktrees"],Sc={"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"}},zC={ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Backspace:"⌫",Tab:"Tab"};function FC(e,t={}){var c;const n=g1(e),r=Sc[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":zC[o]??o.toUpperCase(),l=o!==n.key&&o===((c=n.ctrlAlias)==null?void 0:c.key)?n.ctrlAlias:void 0;return l?`⌃${l.shift?"⇧":""}${i}`:`${n.alt?"⌥":n.ctrl?"⌃":"⌘"}${n.shift?"⇧":""}${i}`}function BC(e){return Object.keys(Sc).filter(t=>Sc[t].section===e&&!Sc[t].hidden)}const Pv={m:6e4,h:60*6e4};function UC(e){const[t,n]=HC(e);return`${t}${n.charAt(0)}`}function HC(e){const t=e/Pv.h;if(t>=1&&Number.isInteger(t))return[t,"hour"];const n=e/Pv.m;return n>=1&&Number.isInteger(n)?[n,"minute"]:n>=60?[Math.round(n),"minute"]:[Math.max(1,Math.round(e/1e3)),"second"]}const Rc={folder:{shared:".toyon/settings.json",local:".toyon/settings.local.json"},root:{shared:"toyon.json",local:"toyon.local.json"}};function k1(e){return typeof e=="string"?e:e.cmd}function WC(e){return typeof e!="string"&&e.from==="trunk"}function KC(e){return[...e.setup??[],...e.teardown??[],...Object.values(e.run).map(k1),...Object.values(e.profiles??{}).flatMap(n=>Object.values(n.env??{}))].some(n=>n.includes("TOYON_WORKTREE"))}function ZC(e){return e===Rc.folder.local||e===Rc.root.local}function qC(e){return ZC(e)?"local":"shared"}function GC(e,t){return(Object.values(Rc).find(r=>r.shared===e||r.local===e)??Rc.folder)[t]}const VC=e=>`https://${e}/`;function YC(e){let t=e.trim();if(t==="")return null;/^[a-z]+:\/\//i.test(t)||(t=`https://${t}`);let n;try{n=new URL(t)}catch{return null}return QC(n.origin)?n.origin:null}function XC(e){return e.toLowerCase().endsWith(".fly.dev")}function QC(e){let t;try{t=new URL(e)}catch{return!1}return t.origin!==e?!1:t.protocol==="https:"||t.protocol==="http:"&&Dg(t.hostname)}const JC="toyon_grant";function Dg(e){return e==="127.0.0.1"||e==="::1"||e==="[::1]"||e==="localhost"||e.endsWith(".localhost")}function eA(e,t,n){return e.replace("{id}",t).replace("{port}",String(n))}const tA=4401,nA=25e4;function rA(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(...oA(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 oA(e,t){if(e.length===0)return t.map(c=>({mark:"+",value:c}));if(t.length===0)return e.map(c=>({mark:"-",value:c}));if((e.length+1)*(t.length+1)>nA)return[...e.map(c=>({mark:"-",value:c})),...t.map(c=>({mark:"+",value:c}))];const n=t.length+1,r=new Uint32Array((e.length+1)*n);for(let c=e.length-1;c>=0;c--)for(let u=t.length-1;u>=0;u--)r[c*n+u]=e[c]===t[u]?(r[(c+1)*n+u+1]??0)+1:Math.max(r[(c+1)*n+u]??0,r[c*n+u+1]??0);const o=[];let 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 sA=/[\p{L}\p{N}_$]+|\s+|[^\s\p{L}\p{N}_$]/gu;function Lv(e){return e.match(sA)??[]}const iA=.4;function aA(e,t){if(e===t)return null;const n=rA(Lv(e),Lv(t));let r=0;for(const o of n)o.mark===" "&&(r+=o.value.length);return r<iA*Math.max(e.length,t.length)?null:{before:Dv(n,"-"),after:Dv(n,"+")}}function Dv(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 w1(n)}function zv(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(w1)}function w1(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 lA=[{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"}],cA=[{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"}],uA=[{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)"}],Sm="merge",_m="merge";function fi(e){var n,r,o;const t=((n=e.land)==null?void 0:n.route)??Sm;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 Tf(e){return e.base??e.defaultBranch}function dA(e){return e.base!==void 0&&e.base!==e.defaultBranch}function fA(e){return!!e.pr&&(e.lands??[]).some(t=>{var n;return t.pr===((n=e.pr)==null?void 0:n.number)})}function hA(e){return{land:"a land",commit:"a commit","sync-main":"a sync","pull-main":"a pull"}[e]}function jf(e){return fA(e)&&!e.landed?void 0:e.pr}function zg(e,t){const n=jf(t);return e.land==="pr"&&(!n||n.state==="closed")?"create pr":"land"}function Yd(e,t="main"){const n={merge:"merge into",squash:"squash onto",rebase:"rebase onto"}[e.merge??_m];switch(e.land){case"merge":return`Commit and ${n} ${t} here`;case"push":return`Commit, ${n} ${t} on origin and push it`;case"pr":return e.automerge?"Commit, push the branch and create a PR that GitHub merges when its rules allow":"Commit, push the branch and create a PR"}}function y1(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 Fv(e,t="|"){return e.map(n=>x1(n)).join(t)}function Nm(e,t){return typeof t=="bigint"?t.toString():t}function Cf(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function pA(e){return e==null}function Fg(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function mA(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 oo(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function vi(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function gA(e){return JSON.stringify(e)}function kA(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const v1="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Oc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const wA=Cf(()=>{var e;if(Yo.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 Mc(e){if(Oc(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Oc(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function b1(e){return Mc(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const yA=new Set(["string","number","symbol"]);function dl(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function bi(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function dt(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function x1(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function vA(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const bA={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 xA(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=vi(e._zod.def,{get shape(){const l={};for(const c of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,c))throw new Error(`Unrecognized key: "${String(c)}"`);t[c]&&oo(l,c,n.shape[c])}return oo(this,"shape",l),l},checks:[]});return bi(e,i)}function EA(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=vi(e._zod.def,{get shape(){const l={...e._zod.def.shape};for(const c of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,c))throw new Error(`Unrecognized key: "${String(c)}"`);t[c]&&delete l[c]}return oo(this,"shape",l),l},checks:[]});return bi(e,i)}function SA(e,t){if(!Mc(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=vi(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return oo(this,"shape",i),i}});return bi(e,o)}function _A(e,t){if(!Mc(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=vi(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return oo(this,"shape",r),r}});return bi(e,n)}function NA(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=vi(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t._zod.def.shape};return oo(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return bi(e,n)}function Bv(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 c=vi(t._zod.def,{get shape(){const u=t._zod.def.shape,p={...u};if(n)for(const h of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(u,h))throw new Error(`Unrecognized key: "${String(h)}"`);n[h]&&(p[h]=e?new e({type:"optional",innerType:u[h]}):u[h])}else for(const h of Reflect.ownKeys(u))p[h]=e?new e({type:"optional",innerType:u[h]}):u[h];return oo(this,"shape",p),p},checks:[]});return bi(t,c)}function TA(e,t,n){const r=vi(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 oo(this,"shape",i),i}});return bi(t,r)}function Qa(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 jA(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 Af(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function lc(e){return typeof e=="string"?e:e==null?void 0:e.message}function Uv(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function bl(e,t,n){var g,w,y,b,_,T,E,N,j,$;var r;const o=(w=(g=e.inst)==null?void 0:g._zod)==null?void 0:w.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=(y=e.schema)==null?void 0:y._zod.def)==null?void 0:b.error:void 0,l=e.message?e.message:lc((E=(T=(_=e.inst)==null?void 0:_._zod.def)==null?void 0:T.error)==null?void 0:E.call(T,e))??lc(i==null?void 0:i(e))??lc((N=t==null?void 0:t.error)==null?void 0:N.call(t,e))??lc((j=n.customError)==null?void 0:j.call(n,e))??lc(($=n.localeError)==null?void 0:$.call(n,e))??"Invalid input",{inst:c,schema:u,continue:p,input:h,...m}=e;return m.path??(m.path=[]),m.message=l,t!=null&&t.reportInput&&(m.input=h),m}const CA=/[\uD800-\uDBFF]/;function Bg(e){const t=e.length;if(!CA.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 Ug(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function AA(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 Pc(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function IA(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):$A(e,n,r.value)}}function fl(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function E1(e,t,n){return fl(e,t,n,!1)}function $A(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:fl(this,t,n.bind(this))},set(r){fl(this,t,r)}})}function RA(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let Pp,ci=!1;const OA={configurable:!0,get(){ci=!0}};function Nn(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&Pp!==e._zod){Pp=void 0;return}Pp=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,OA);const o=ci;ci=!1;try{const i=n(this);return ci?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),ci=ci||o,i}catch(i){throw delete this[t],ci=ci||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function MA(e,t,n,r){const o=RA(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 PA="~constantCatch";function LA(e){const t=()=>e;return t[PA]=!0,t}var Hv;const Lp={value:void 0,enumerable:!1};let Wv="captureStackTrace"in Error?Error:null;function DA(e){const t=Wv;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return Wv=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function xe(e,t,n,r){const o={};function i(g){this.def=g,this.constr=m,this.traits=new Set}i.prototype=o;const l=n,c=l&&new WeakSet;function u(g,w){if(!g._zod){Lp.value=new i(w);try{Object.defineProperty(g,"_zod",Lp)}finally{Lp.value=void 0}}if(g._zod.traits.has(e))return;if(g._zod.traits.add(e),t(g,w),c){const b=Object.getPrototypeOf(g),_=g._zod.constr.prototype;let T=b;for(;T&&T!==_;)T=Object.getPrototypeOf(T);const E=T??b;c.has(E)||(c.add(E),IA(E,l))}const y=m.prototype;for(const b in y)Object.prototype.hasOwnProperty.call(y,b)&&(b in g||(g[b]=y[b].bind(g)))}const p=(r==null?void 0:r.Parent)??Object;class h extends p{}Object.defineProperty(h,"name",{value:e});function m(g){var _;const w=r!=null&&r.Parent?DA(h):this;u(w,g);const y=w._zod.deferred;if(y){for(const T of y)T();w._zod.deferred=void 0}const b=(_=globalThis.__zod_globalConfig)==null?void 0:_.postProcessor;return b&&b(w),w}return Object.defineProperty(m,"init",{value:u}),Object.defineProperty(m,Symbol.hasInstance,{value:g=>{var w,y;return r!=null&&r.Parent&&g instanceof r.Parent?!0:(y=(w=g==null?void 0:g._zod)==null?void 0:w.traits)==null?void 0:y.has(e)}}),Object.defineProperty(m,"name",{value:e}),m}class ol extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class S1 extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Hv=globalThis).__zod_globalConfig??(Hv.__zod_globalConfig={});const Yo=globalThis.__zod_globalConfig;function xi(e){return e&&Object.assign(Yo,e),Yo}function zA(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Nm,2)),e.message}function FA(e){this._zod.message=e}const BA={get:zA,set:FA,enumerable:!0,configurable:!0},Dp={value:void 0,enumerable:!1},zp={value:void 0,enumerable:!1},Kv=new WeakSet([Object.prototype,Error.prototype]),_1=(e,t)=>{e.name="$ZodError",Dp.value=e._zod,Object.defineProperty(e,"_zod",Dp),zp.value=t,Object.defineProperty(e,"issues",zp),Dp.value=void 0,zp.value=void 0,Object.defineProperty(e,"message",BA);const n=Object.getPrototypeOf(e);Kv.has(n)||(Kv.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})}}))},N1=xe("$ZodError",_1),T1=xe("$ZodError",_1,void 0,{Parent:Error});function UA(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 HA(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?UA(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n}}function WA(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(c=>r({issues:c},[...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 c=[...i,...l.path];if(c.length===0)n._errors.push(t(l));else{let u=n,p=0;for(;p<c.length;){const h=c[p],m=p===c.length-1;if(h==="_errors"){m&&u._errors.push(t(l)),p++;continue}Object.prototype.hasOwnProperty.call(u,h)||Object.defineProperty(u,h,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const g=u[h];m&&g._errors.push(t(l)),u=g,p++}}}};return r(e),n}function If(e,t){return{callee:(t==null?void 0:t.callee)??e,Err:t==null?void 0:t.Err}}const Hg=e=>{const t=(n,r,o,i)=>{const l=o?{...o,async:!1}:{async:!1},c=n._zod.run({value:r,issues:[]},l);if(c instanceof Promise)throw new ol;if(c.issues.length){const u=new((i==null?void 0:i.Err)??e)(c.issues.map(p=>bl(p,l,xi())));throw v1(u,(i==null?void 0:i.callee)??t),u}return c.value};return t},Wg=e=>{const t=async(n,r,o,i)=>{const l=o?{...o,async:!0}:{async:!0};let c=n._zod.run({value:r,issues:[]},l);if(c instanceof Promise&&(c=await c),c.issues.length){const u=new((i==null?void 0:i.Err)??e)(c.issues.map(p=>bl(p,l,xi())));throw v1(u,(i==null?void 0:i.callee)??t),u}return c.value};return t},$f=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 ol;return i.issues.length?{success:!1,error:new(e??N1)(i.issues.map(l=>bl(l,o,xi())))}:{success:!0,data:i.value}},KA=$f(T1),Rf=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=>bl(l,o,xi())))}:{success:!0,data:i.value}},ZA=Rf(T1),qA=e=>{const t=Hg(e),n=(r,o,i,l)=>{const c=i?{...i,direction:"backward"}:{direction:"backward"};return t(r,o,c,If(n,l))};return n},GA=e=>{const t=Hg(e),n=(r,o,i,l)=>t(r,o,i,If(n,l));return n},VA=e=>{const t=Wg(e),n=async(r,o,i,l)=>{const c=i?{...i,direction:"backward"}:{direction:"backward"};return await t(r,o,c,If(n,l))};return n},YA=e=>{const t=Wg(e),n=async(r,o,i,l)=>await t(r,o,i,If(n,l));return n},XA=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return $f(e)(t,n,o)},QA=e=>(t,n,r)=>$f(e)(t,n,r),JA=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Rf(e)(t,n,o)},eI=e=>async(t,n,r)=>Rf(e)(t,n,r),tI=/^[cC][0-9a-z]{6,}$/,nI=/^[0-9a-z]+$/,rI=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,oI=/^[0-9a-vA-V]{20}$/,sI=/^[A-Za-z0-9]{27}$/,iI=/^[a-zA-Z0-9_-]{21}$/;function aI(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const lI=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,cI=/^([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})$/,Zv=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)$/,uI=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,dI="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function fI(){return new RegExp(dI,"u")}const hI=/^(?:(?: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])$/,pI=/^(([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}|:))$/,mI=/^((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])$/,gI=/^(([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])$/,kI=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,j1=/^[A-Za-z0-9_-]*$/,wI=/^https?$/,yI=/^\+[1-9]\d{6,14}$/,C1="(?:(?:\\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 vI(e){return new RegExp(`^${e}$`)}const bI=vI(C1);function Tm(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 xI(e){return new RegExp(`^${Tm(e)}$`)}function EI(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${Tm({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${Tm({precision:e.precision})}`:n;return new RegExp(`^${C1}T(?:${r})$`)}const SI=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}$`)},_I=/^-?\d+$/,NI=/^-?\d+(?:\.\d+)?$/,TI=/^(?:true|false)$/i,jI=/^[^A-Z]*$/,CI=/^[^a-z]*$/,so=xe("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Kg=e=>{const t=e.value;return!pA(t)&&t.length!==void 0},Xd={number:"number",bigint:"bigint",object:"date"},A1=xe("$ZodCheckLessThan",(e,t)=>{so.init(e,t);const n=Xd[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:Xd[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})}}),I1=xe("$ZodCheckGreaterThan",(e,t)=>{so.init(e,t);const n=Xd[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:Xd[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})}}),AI=xe("$ZodCheckMultipleOf",(e,t)=>{so.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):mA(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})}}),II=xe("$ZodCheckNumberFormat",(e,t)=>{var l;so.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]=bA[t.format];e._zod.onattach.push(c=>{const u=c._zod.bag;u.format=t.format,u.minimum=o,u.maximum=i,n&&(u.pattern=_I)}),e._zod.check=c=>{const u=c.value;if(n){if(!Number.isInteger(u)){c.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:u,inst:e});return}if(!Number.isSafeInteger(u)){u>0?c.issues.push({input:u,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):c.issues.push({input:u,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}u<o&&c.issues.push({origin:"number",input:u,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),u>i&&c.issues.push({origin:"number",input:u,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),$I=xe("$ZodCheckMaxLength",(e,t)=>{var n;so.init(e,t),(n=e._zod.def).when??(n.when=Kg),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?Bg(o):i)<=t.maximum)return;const c=Ug(o);r.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),RI=xe("$ZodCheckMinLength",(e,t)=>{var n;so.init(e,t),(n=e._zod.def).when??(n.when=Kg),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?Bg(o):i)>=t.minimum)return;const c=Ug(o);r.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),OI=xe("$ZodCheckLengthEquals",(e,t)=>{var n;so.init(e,t),(n=e._zod.def).when??(n.when=Kg),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?Bg(o):i;if(l===t.length)return;const c=Ug(o),u=l>t.length;r.issues.push({origin:c,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Of=xe("$ZodCheckStringFormat",(e,t)=>{var n,r;so.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=()=>{})}),MI=xe("$ZodCheckRegex",(e,t)=>{Of.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})}}),PI=xe("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=jI),Of.init(e,t)}),LI=xe("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=CI),Of.init(e,t)}),DI=xe("$ZodCheckIncludes",(e,t)=>{so.init(e,t);const n=dl(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})}}),zI=xe("$ZodCheckStartsWith",(e,t)=>{so.init(e,t);const n=new RegExp(`^${dl(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})}}),FI=xe("$ZodCheckEndsWith",(e,t)=>{so.init(e,t);const n=new RegExp(`.*${dl(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})}}),BI=xe("$ZodCheckOverwrite",(e,t)=>{so.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class UI{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 HI={major:4,minor:5,patch:4},Bn=xe("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=HI;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 c of l._zod.onattach)c(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=(u,p,h)=>{if(u.memo)return u;let m=Qa(u),g;for(const w of p){if(w._zod.def.when){if(jA(u)||!w._zod.def.when(u))continue}else if(m)continue;const y=u.issues.length,b=w._zod.check(u);if(b instanceof Promise&&(h==null?void 0:h.async)===!1)throw new ol;if(g||b instanceof Promise)g=(g??Promise.resolve()).then(async()=>{await b,u.issues.length!==y&&(Uv(u.issues,y,e),m||(m=Qa(u,y)))});else{if(u.issues.length===y)continue;Uv(u.issues,y,e),m||(m=Qa(u,y))}}return g?g.then(()=>u):u},c=(u,p,h)=>{if(Qa(u))return u.aborted=!0,u;const m=l(p,o,h);if(m instanceof Promise){if(h.async===!1)throw new ol;return m.then(g=>e._zod.parse(g,h))}return e._zod.parse(m,h)};e._zod.run=(u,p)=>{if(p.skipChecks)return e._zod.parse(u,p);if(p.direction==="backward"){const m=e._zod.parse({value:u.value,issues:[]},{...p,skipChecks:!0});return m instanceof Promise?m.then(g=>c(g,u,p)):c(m,u,p)}const h=e._zod.parse(u,p);if(h instanceof Promise){if(p.async===!1)throw new ol;return h.then(m=>l(m,o,p))}return l(h,o,p)}}},{get"~standard"(){return E1(this,"~standard",$1(this))},set"~standard"(e){fl(this,"~standard",e)}}),qv=e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}};function $1(e){return{validate:t=>{try{return qv(KA(e,t))}catch{return ZA(e,t).then(qv)}},vendor:"zod",version:1}}const Zg=xe("$ZodString",(e,t)=>{var n;Bn.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??SI(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}}),Un=xe("$ZodStringFormat",(e,t)=>{Of.init(e,t),Zg.init(e,t)}),WI=xe("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=cI),Un.init(e,t)}),KI=xe("$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=Zv(r))}else t.pattern??(t.pattern=Zv());Un.init(e,t)}),ZI=xe("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=uI),Un.init(e,t)}),R1=1,O1=2;function qI(e,t){var n;if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===wI.source&&!/^https?:\/\//i.test(e))return R1;try{return new URL(e)}catch{return O1}}const GI=/[\t\n\r]/g;function VI(e){return e.replace(GI,"")}function YI(e,t){return t.lastIndex=0,t.test(e.hostname)}function XI(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const QI=xe("$ZodURL",(e,t)=>{Un.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=qI(r,t);if(o===R1){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===O1){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!YI(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&&!XI(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:VI(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),JI=xe("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=fI()),Un.init(e,t)}),e$=xe("$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?iI:aI(t.length)),Un.init(e,t)}),t$=xe("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=tI),Un.init(e,t)}),n$=xe("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=nI),Un.init(e,t)}),r$=xe("$ZodULID",(e,t)=>{t.pattern??(t.pattern=rI),Un.init(e,t)}),o$=xe("$ZodXID",(e,t)=>{t.pattern??(t.pattern=oI),Un.init(e,t)}),s$=xe("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=sI),Un.init(e,t)}),i$=xe("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=EI(t)),Un.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(n=>{n._zod.bag.laxFormat=!0}))}),a$=xe("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=bI),Un.init(e,t)}),l$=xe("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=xI(t)),Un.init(e,t)}),c$=xe("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=lI),Un.init(e,t)}),u$=xe("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=hI),Un.init(e,t),e._zod.bag.format="ipv4"}),d$=/^[0-9a-fA-F:.]+$/;function M1(e){if(!d$.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}const f$=xe("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=pI),Un.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{M1(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),h$=xe("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=mI),Un.init(e,t)});function p$(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:M1(n)}const m$=xe("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=gI),Un.init(e,t),e._zod.check=n=>{p$(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function P1(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const g$=xe("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=kI),Un.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{P1(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function k$(e){if(!j1.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return P1(n)}const w$=xe("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=j1),Un.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{k$(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),y$=xe("$ZodE164",(e,t)=>{t.pattern??(t.pattern=yI),Un.init(e,t)});function v$(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 b$=xe("$ZodJWT",(e,t)=>{Un.init(e,t),e._zod.check=n=>{v$(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),L1=xe("$ZodNumber",(e,t)=>{Bn.init(e,t),e._zod.pattern=e._zod.bag.pattern??NI,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}}),x$=xe("$ZodNumberFormat",(e,t)=>{II.init(e,t),L1.init(e,t)}),E$=xe("$ZodBoolean",(e,t)=>{Bn.init(e,t),e._zod.pattern=TI,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}}),S$=xe("$ZodUnknown",(e,t)=>{Bn.init(e,t),e._zod.parse=n=>n}),_$=xe("$ZodNever",(e,t)=>{Bn.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Gv(e,t,n){e.issues.length&&t.issues.push(...Af(n,e.issues)),t.value[n]=e.value}const N$=xe("$ZodArray",(e,t)=>{Bn.init(e,t);const n=Yo.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 c=0;c<i.length;c++){const u=i[c],p=t.element._zod.run({value:u,issues:[]},o);p instanceof Promise?l.push(p.then(h=>Gv(h,r,c))):Gv(p,r,c)}return l.length?Promise.all(l).then(()=>r):r}});function Qd(e,t,n,r,o,i){const l=n in r,c=i==="optional";if(!(!l&&c&&o==="optional")){if(e.issues.length){if(o!==void 0&&c&&!l)return;t.issues.push(...Af(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 T$=[];function D1(e){var l,c,u,p;const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:T$,o=r.length?[...t,...r]:t;for(const h of o)if(!((p=(u=(c=(l=e.shape)==null?void 0:l[h])==null?void 0:c._zod)==null?void 0:u.traits)!=null&&p.has("$ZodType")))throw new Error(`Invalid element at key "${String(h)}": expected a Zod schema`);const i=vA(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function z1(e,t,n,r,o,i){const l=[],c=o.keySet,u=o.catchall._zod,p=u.def.type,h=u.optin,m=u.optout;for(const g in t){if(c.has(g))continue;if(g==="__proto__"){p==="never"&&l.push(g);continue}if(p==="never"){l.push(g);continue}const w=u.run({value:t[g],issues:[]},r);w instanceof Promise?e.push(w.then(y=>Qd(y,n,g,t,h,m))):Qd(w,n,g,t,h,m)}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 jm=new WeakMap,j$=xe("$ZodObject",(e,t)=>{Bn.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const u=t.shape;jm.set(t,u),Object.defineProperty(t,"shape",{get:()=>{const p={...u};return Object.defineProperty(t,"shape",{value:p}),jm.set(t,p),p}})}const r=Cf(()=>D1(t));Nn(e,"propValues",u=>{const p=u.def.shape,h={};for(const m in p){const g=p[m]._zod;if(g.values){Object.prototype.hasOwnProperty.call(h,m)||oo(h,m,new Set);for(const w of g.values)h[m].add(w);g.optin!==void 0&&h[m].add(void 0)}}return h});const o=Oc,i=t.catchall;let l;const c=Yo.memoizer;c==null||c.attach(e),e._zod.parse=(u,p)=>{l??(l=r.value);const h=u.value;if(!o(h))return u.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),u;u.value=c?c.alloc(e,u,{},p):{};const m=[],g=l.shape;for(const w of l.allKeys){if(w==="__proto__")continue;const y=g[w],b=y._zod.optin,_=y._zod.optout,T=y._zod.run({value:h[w],issues:[]},p);T instanceof Promise?m.push(T.then(E=>Qd(E,u,w,h,b,_))):Qd(T,u,w,h,b,_)}return i?z1(m,h,u,p,r.value,e):m.length?Promise.all(m).then(()=>u):u}}),C$=xe("$ZodObjectJIT",(e,t)=>{j$.init(e,t);const n=e._zod.parse,r=Cf(()=>D1(t)),o=Yo.memoizer,i=w=>{var $,P;const y=r.value,b=y.symbolKeys,_=new UI(["payload","ctx"],{shape:w,inst:e,memo:o,syms:b}),T=R=>`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`,E=(R,A)=>`
|
|
47
|
+
for (let i = 0; i < ${R}.issues.length; i++) {
|
|
48
|
+
const iss = ${R}.issues[i];
|
|
49
|
+
iss.path = iss.path ? [${A}, ...iss.path] : [${A}];
|
|
50
|
+
payload.issues.push(iss);
|
|
51
|
+
}`;_.write("const input = payload.value;");const N=Object.create(null);let j=0;for(const R of y.allKeys)N[R]=`key_${j++}`;_.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const R of y.allKeys){if(R==="__proto__")continue;const A=N[R],O=typeof R=="symbol"?`syms[${b.indexOf(R)}]`:gA(R),B=`${O} in input`,H=w[R],Q=($=H==null?void 0:H._zod)==null?void 0:$.optin,re=Q!==void 0,J=((P=H==null?void 0:H._zod)==null?void 0:P.optout)==="optional";if(_.write(`const ${A} = ${T(O)};`),re&&J){const ie=Q==="optional"?`${A}_present`:`${A}.value !== undefined || ${A}_present`;_.write(`
|
|
52
|
+
const ${A}_present = ${B};
|
|
53
|
+
if (!${A}.issues.length || ${A}_present) {
|
|
54
|
+
if (${A}.issues.length) {${E(A,O)}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (${ie}) {
|
|
58
|
+
newResult[${O}] = ${A}.value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
`)}else re?_.write(`
|
|
63
|
+
if (${A}.issues.length) {${E(A,O)}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (${A}.value === undefined) {
|
|
67
|
+
if (${B}) {
|
|
68
|
+
newResult[${O}] = undefined;
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
newResult[${O}] = ${A}.value;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
`):_.write(`
|
|
75
|
+
const ${A}_present = ${B};
|
|
76
|
+
if (${A}.issues.length) {${E(A,O)}
|
|
77
|
+
}
|
|
78
|
+
if (!${A}_present && !${A}.issues.length) {
|
|
79
|
+
payload.issues.push({
|
|
80
|
+
code: "invalid_type",
|
|
81
|
+
expected: "nonoptional",
|
|
82
|
+
input: undefined,
|
|
83
|
+
path: [${O}]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (${A}_present) {
|
|
88
|
+
newResult[${O}] = ${A}.value;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
`)}return _.write("payload.value = newResult;"),_.write("return payload;"),_.compile()};let l;const c=Oc,u=!Yo.jitless,h=u&&wA.value,m=t.catchall;let g;e._zod.parse=(w,y)=>{g??(g=r.value);const b=w.value;return c(b)?u&&h&&(y==null?void 0:y.async)===!1&&y.jitless!==!0?(l||(l=i(t.shape)),w=l(w,y),m?z1([],b,w,y,g,e):w):n(w,y):(w.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),w)}});function Vv(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=>!Qa(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=>bl(l,r,xi())))}),t)}const F1=xe("$ZodUnion",(e,t)=>{Bn.init(e,t),Nn(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),Nn(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),Nn(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)))}),Nn(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=>Fg(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 c of t.options){const u=c._zod.run({value:r.value,issues:[]},o);if(u instanceof Promise)l.push(u),i=!0;else{if(u.issues.length===0)return u;l.push(u)}}return i?Promise.all(l).then(c=>Vv(c,r,e,o)):Vv(l,r,e,o)}}),A$=xe("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,F1.init(e,t);const n=e._zod.parse;Nn(e,"propValues",o=>{const i={};for(const l of o.def.options){const c=l._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(l)}"`);for(const[u,p]of Object.entries(c)){Object.prototype.hasOwnProperty.call(i,u)||oo(i,u,new Set);for(const h of p)i[u].add(h)}}return i}),t.options.forEach((o,i)=>{const l=jm.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=Cf(()=>{var l;const o=t.options,i=new Map;for(const c of o){const u=(l=c._zod.propValues)==null?void 0:l[t.discriminator];if(!u||u.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(c)}"`);for(const p of u){if(i.has(p))throw new Error(`Duplicate discriminator value "${String(p)}"`);i.set(p,c)}}return i});e._zod.parse=(o,i)=>{const l=o.value;if(!Oc(l))return o.issues.push({code:"invalid_type",expected:"object",input:l,inst:e}),o;const c=r.value.get(l==null?void 0:l[t.discriminator]);return c?c._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)}}),I$=xe("$ZodIntersection",(e,t)=>{Bn.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(([u,p])=>Yv(n,u,p)):Yv(n,i,l)}});function Cm(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(Mc(e)&&Mc(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=Cm(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=Cm(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 Yv(e,t,n){const r=new Map;let o;const i=new Map,l=(p,h)=>{var g,w;let m;if(p.code==="unrecognized_keys"&&!((g=p.path)!=null&&g.length))o??(o=p),m=p.keys;else if(p.code==="invalid_key"&&p.origin==="record"&&((w=p.path)==null?void 0:w.length)===1){const y=String(p.path[0]);i.has(y)||i.set(y,p),m=[y]}else return!1;for(const y of m)r.has(y)||r.set(y,{}),r.get(y)[h]=!0;return!0};for(const p of t.issues)l(p,"l")||e.issues.push(p);for(const p of n.issues)l(p,"r")||e.issues.push(p);const c=[...r].filter(([,p])=>p.l&&p.r).map(([p])=>p);if(c.length){const p=o?c.filter(h=>o.keys.includes(h)):[];p.length&&e.issues.push({...o,keys:p});for(const h of c)!p.includes(h)&&i.has(h)&&e.issues.push(i.get(h))}const u=Cm(t.value,n.value);if(!u.valid){if(Qa(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}const $$=xe("$ZodTuple",(e,t)=>{Bn.init(e,t);const n=t.items,r=Yo.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 c=[],u=Xv(n,"optin"),p=Xv(n,"optout");if(!t.rest){if(l.length<u)return o.issues.push({code:"too_small",minimum:u,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 h=new Array(n.length);for(let m=0;m<n.length;m++){const g=n[m]._zod.run({value:l[m],issues:[]},i);g instanceof Promise?c.push(g.then(w=>{h[m]=w})):h[m]=g}if(t.rest){let m=n.length-1;const g=l.slice(n.length);for(const w of g){m++;const y=t.rest._zod.run({value:w,issues:[]},i);y instanceof Promise?c.push(y.then(b=>Qv(b,o,m))):Qv(y,o,m)}}return c.length?Promise.all(c).then(()=>Jv(h,o,n,l,p)):Jv(h,o,n,l,p)}});function Xv(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 Qv(e,t,n){e.issues.length&&t.issues.push(...Af(n,e.issues)),t.value[n]=e.value}function Jv(e,t,n,r,o){for(let i=0;i<n.length;i++){const l=e[i],c=i<r.length;if(!c&&i>=o&&n[i]._zod.optin==="optional"){t.value.length=i;break}if(l.issues.length){if(!c&&i>=o){t.value.length=i;break}t.issues.push(...Af(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 R$=xe("$ZodEnum",(e,t)=>{Bn.init(e,t);const n=y1(t.entries),r=new Set(n);e._zod.values=r;const o=n.filter(i=>yA.has(typeof i));e._zod.pattern=new RegExp(o.length?`^(${o.map(i=>dl(i.toString())).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(i,l)=>{const c=i.value;return r.has(c)||i.issues.push({code:"invalid_value",values:n,input:c,inst:e}),i}}),O$=xe("$ZodLiteral",(e,t)=>{Bn.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"?dl(r):r?dl(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}}),M$=xe("$ZodTransform",(e,t)=>{var n;Bn.init(e,t),e._zod.optin="optional",(n=Yo.memoizer)==null||n.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new S1(e.constructor.name);const i=t.transform(r.value,r);if(o.async)return(i instanceof Promise?i:Promise.resolve(i)).then(c=>(r.value=c,r));if(i instanceof Promise)throw new ol;return r.value=i,r}});function e0(e,t){return e.value=t.issues.length?void 0:t.value,e}const B1=xe("$ZodOptional",(e,t)=>{Bn.init(e,t),Nn(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",Nn(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),Nn(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Fg(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=>e0(n,i)):e0(n,o)}return t.innerType._zod.run(n,r)}}),P$=xe("$ZodExactOptional",(e,t)=>{B1.init(e,t),Nn(e,"values",n=>n.def.innerType._zod.values),Nn(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),L$=xe("$ZodNullable",(e,t)=>{Bn.init(e,t),Nn(e,"optin",n=>n.def.innerType._zod.optin),Nn(e,"optout",n=>n.def.innerType._zod.optout),Nn(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Fg(r.source)}|null)$`):void 0}),Nn(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)}),D$=xe("$ZodDefault",(e,t)=>{Bn.init(e,t),e._zod.optin="defaulted",Nn(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=>t0(i,t)):t0(o,t)}});function t0(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const z$=xe("$ZodPrefault",(e,t)=>{Bn.init(e,t),e._zod.optin="defaulted",Nn(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))}),F$=xe("$ZodNonOptional",(e,t)=>{Bn.init(e,t),Nn(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=>n0(i,e)):n0(o,e)}});function n0(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 r0(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>bl(o,r,xi()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const B$=xe("$ZodCatch",(e,t)=>{Bn.init(e,t),Nn(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),Nn(e,"optout",n=>n.def.innerType._zod.optout),Nn(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=>r0(n,i,t,r)):r0(n,o,t,r)}}),U$=xe("$ZodPipe",(e,t)=>{Bn.init(e,t),Nn(e,"values",n=>n.def.in._zod.values),Nn(e,"optin",n=>n.def.in._zod.optin),Nn(e,"optout",n=>n.def.out._zod.optout),Nn(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=>wd(l,t.in,r)):wd(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>wd(i,t.out,r)):wd(o,t.out,r)}});function wd(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 H$=xe("$ZodReadonly",(e,t)=>{Bn.init(e,t),Nn(e,"propValues",n=>n.def.innerType._zod.propValues),Nn(e,"values",n=>n.def.innerType._zod.values),Nn(e,"optin",n=>{var r,o;return(o=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:o.optin}),Nn(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(o0):o0(o)}});function o0(e){return e.memo||(e.value=Object.freeze(e.value)),e}const W$=xe("$ZodCustom",(e,t)=>{so.init(e,t),Bn.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=>s0(i,n,r,e));s0(o,n,r,e)}});function s0(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(Pc(o))}}class K$ extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const Am="~memo",i0=[];function Fp(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const a0=new WeakMap;function U1(e,t){const n=a0.get(e);if(n!==void 0)return n;if(t.has(e))return!0;t.add(e);let r=!1;const o=c=>{!r&&(c!=null&&c._zod)&&U1(c,t)&&(r=!0)},i=e._zod.def;switch(i.type){case"object":{for(const c of Reflect.ownKeys(i.shape))o(i.shape[c]);o(i.catchall);break}case"array":o(i.element);break;case"tuple":for(const c of i.items)o(c);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 c of i.options)o(c);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 c in i){const u=Object.getOwnPropertyDescriptor(i,c);if(!u||u.get)continue;const p=u.value;if(!(!p||typeof p!="object")){if(p._zod)o(p);else if(Array.isArray(p))for(const h of p)o(h)}}}return t.delete(e),a0.set(e,r),r}function Z$(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}let yd;const vd=[],q$={alloc(e,t,n){const r=yd;if(!r)return n;yd=void 0;const o={value:n,issues:null};return r.set(t.value,o),vd.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"&&V$(i,o.value))throw new K$;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=(c,u)=>{if(n===void 0&&(n=U1(e,new Set),!n))return e._zod.parse=i,e._zod.run===l&&(e._zod.run=i),i(c,u);const p=c.value;if(p===null||typeof p!="object")return i(c,u);let h=u[Am];h||(h={buckets:new Map,backEdges:void 0},u[Am]=h);let m;r===u?m=o:(m=Z$(h,e),r=u,o=m);const g=m.get(p);if(g)return c.value=g.value,g.issues?g.issues.length&&c.issues.push(...Fp(g.issues)):(c.memo=!0,h.backEdges??(h.backEdges=new Set),h.backEdges.add(g.value)),c;yd=m;const w=vd.length,y=i(c,u);yd=void 0;const b=vd.length>w?vd.pop():void 0;return y instanceof Promise?y.then(_=>(b&&(b.issues=_.issues.length?Fp(_.issues):i0),_)):(b&&(b.issues=y.issues.length?Fp(y.issues):i0),y)};e._zod.parse=l,e._zod.run===i&&(e._zod.run=l)})}};function G$(){return q$}function V$(e,t){var r;const n=(r=e[Am])==null?void 0:r.backEdges;return n!==void 0&&t!==null&&typeof t=="object"&&n.has(t)}const Y$=()=>{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),c=AA(i.input),u=o(c,i.input);return`Invalid input: expected ${l}, received ${u}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${x1(i.values[0])}`:`Invalid option: expected one of ${Fv(i.values,"|")}`;case"too_big":{const l=i.exact?"exactly ":i.inclusive?"<=":"<",c=t(i.origin);return c?`Too big: expected ${i.origin??"value"} to have ${l}${i.maximum.toString()} ${c.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${l}${i.maximum.toString()}`}case"too_small":{const l=i.exact?"exactly ":i.inclusive?">=":">",c=t(i.origin);return c?`Too small: expected ${i.origin} to have ${l}${i.minimum.toString()} ${c.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":""}: ${Fv(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(c=>`'${c}'`).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 X$(){return{localeError:Y$()}}var l0;class Q${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 J$(){return new Q$}(l0=globalThis).__zod_globalRegistry??(l0.__zod_globalRegistry=J$());const mc=globalThis.__zod_globalRegistry;function eR(e,t){return new e({type:"string",...dt(t)})}function tR(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...dt(t)})}function nR(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...dt(t)})}function rR(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...dt(t)})}function oR(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...dt(t)})}function sR(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...dt(t)})}function iR(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...dt(t)})}function aR(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...dt(t)})}function lR(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...dt(t)})}function cR(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...dt(t)})}function uR(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...dt(t)})}function dR(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...dt(t)})}function fR(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...dt(t)})}function hR(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...dt(t)})}function pR(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...dt(t)})}function mR(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...dt(t)})}function gR(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...dt(t)})}function kR(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...dt(t)})}function wR(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...dt(t)})}function yR(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...dt(t)})}function vR(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...dt(t)})}function bR(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...dt(t)})}function xR(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...dt(t)})}function ER(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...dt(t)})}function SR(e,t){return new e({type:"string",format:"date",check:"string_format",...dt(t)})}function _R(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...dt(t)})}function NR(e,t){return new e({type:"string",format:"duration",check:"string_format",...dt(t)})}function TR(e,t){return new e({type:"number",checks:[],...dt(t)})}function jR(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...dt(t)})}function CR(e,t){return new e({type:"boolean",...dt(t)})}function AR(e){return new e({type:"unknown"})}function IR(e,t){return new e({type:"never",...dt(t)})}function c0(e,t){return new A1({check:"less_than",...dt(t),value:e,inclusive:!1})}function Bp(e,t){return new A1({check:"less_than",...dt(t),value:e,inclusive:!0})}function u0(e,t){return new I1({check:"greater_than",...dt(t),value:e,inclusive:!1})}function Up(e,t){return new I1({check:"greater_than",...dt(t),value:e,inclusive:!0})}function d0(e,t){return new AI({check:"multiple_of",...dt(t),value:e})}function H1(e,t){return new $I({check:"max_length",...dt(t),maximum:e})}function Jd(e,t){return new RI({check:"min_length",...dt(t),minimum:e})}function W1(e,t){return new OI({check:"length_equals",...dt(t),length:e})}function $R(e,t){return new MI({check:"string_format",format:"regex",...dt(t),pattern:e})}function RR(e){return new PI({check:"string_format",format:"lowercase",...dt(e)})}function OR(e){return new LI({check:"string_format",format:"uppercase",...dt(e)})}function MR(e,t){return new DI({check:"string_format",format:"includes",...dt(t),includes:e})}function PR(e,t){return new zI({check:"string_format",format:"starts_with",...dt(t),prefix:e})}function LR(e,t){return new FI({check:"string_format",format:"ends_with",...dt(t),suffix:e})}function xl(e){return new BI({check:"overwrite",tx:e})}function DR(e){return xl(t=>t.normalize(e))}function zR(){return xl(e=>e.trim())}function FR(){return xl(e=>e.toLowerCase())}function BR(){return xl(e=>e.toUpperCase())}function UR(){return xl(e=>kA(e))}function HR(e,t,n){return new e({type:"array",element:t,...dt(n)})}function WR(e,t,n){return new e({type:"custom",check:"custom",fn:t,...dt(n)})}function KR(e,t){const n=ZR(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(Pc(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(Pc(i))}},e(r.value,r)),t);return n}function ZR(e,t){const n=new so({check:"custom",...dt(t)});return n._zod.check=e,n}function _c(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&oo(e,r,n[r]);return e}function K1(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)??mc,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 gi(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 fr(e,t,n={path:[],schemaPath:[]}){var h,m;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 c=(m=(h=e._zod).toJSONSchema)==null?void 0:m.call(h);if(c)l.schema=c;else{const g={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,l.schema,g);else{const y=l.schema,b=t.processors[o.type];if(!b)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);b(e,t,y,g)}const w=e._zod.parent;w&&(l.ref||(l.ref=w),fr(w,t,g),t.seen.get(w).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&_c(l.schema,u),t.io==="input"&&Wr(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 f0(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Z1(e,t){var l,c,u,p;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const r=new Map;for(const h of e.seen.entries()){const m=(l=e.metadataRegistry.get(h[0]))==null?void 0:l.id;if(m){const g=r.get(m);if(g&&g!==h[0])throw new Error(`Duplicate schema id "${m}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(m,h[0])}}const o=h=>{var b;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const _=(b=e.external.registry.get(h[0]))==null?void 0:b.id,T=e.external.uri??(N=>N);if(_)return{ref:T(_)};const E=h[1].defId??h[1].schema.id??`schema${e.counter++}`;return h[1].defId=E,{defId:E,ref:`${T("__shared")}#/${m}/${f0(E)}`}}const g="#",w=`${g}/${m}/`;if(h[1]===n&&!h[1].schema.id)return{ref:g};const y=h[1].schema.id??`__schema${e.counter++}`;return{defId:y,ref:w+f0(y)}},i=h=>{if(h[1].schema.$ref)return;const m=h[1],{ref:g,defId:w}=o(h);m.def={...m.schema},w&&(m.defId=w);const y=m.schema;for(const b in y)delete y[b];y.$ref=g};if(e.cycles==="throw")for(const h of e.seen.entries()){const m=h[1];if(m.cycle)throw new Error(`Cycle detected: #/${(c=m.cycle)==null?void 0:c.join("/")}/<root>
|
|
92
|
+
|
|
93
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const h of e.seen.entries()){const m=h[1];if(t===h[0]){i(h);continue}if(e.external){const w=(u=e.external.registry.get(h[0]))==null?void 0:u.id;if(t!==h[0]&&w){i(h);continue}}if((p=e.metadataRegistry.get(h[0]))==null?void 0:p.id){i(h);continue}if(m.cycle){i(h);continue}if(m.count>1&&e.reused==="ref"){i(h);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function q1(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;q1(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 G1=new Set(["type","properties","required","additionalProperties"]),h0=["oneOf","anyOf"];function p0(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Im(e){var i;const t=[];for(const l of e){if(typeof l!="object"||l.type!=="object")return null;for(const c in l)if(!G1.has(c))return null;t.push(l)}const n={},r=new Set;for(const l of t){for(const c in l.properties){if(Object.prototype.hasOwnProperty.call(n,c))continue;const u=[];for(const h of t){const m=((i=h.properties)==null?void 0:i[c])??p0(h);m!=null&&(u.some(g=>JSON.stringify(g)===JSON.stringify(m))||u.push(m))}const p=u.length===1?u[0]:Im(u)??{allOf:u};oo(n,c,p)}for(const c of l.required??[])r.add(c)}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 c of t){const u=p0(c);u&&!l.some(p=>JSON.stringify(p)===JSON.stringify(u))&&l.push(u)}l.length===1?o.additionalProperties=l[0]:l.length>1&&(o.additionalProperties={allOf:l})}return o}function qR(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const o of G1)if(o in e)return;const n=t.filter(o=>h0.some(i=>Array.isArray(o[i])));let r=null;if(!n.length)r=Im(t);else{const o=n[0],i=h0.find(u=>Array.isArray(o[u]));if(Object.keys(o).length!==1)return;const l=t.filter(u=>u!==o),c=o[i].map(u=>Im([...l,u]));if(c.some(u=>!u))return;r={[i]:c}}r&&(delete e.allOf,_c(e,r))}function V1(e,t){var c,u,p,h;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=m=>{const g=e.seen.get(m);if(g.ref===null)return;const w=g.def??g.schema,y={...w},b=g.ref;if(g.ref=null,b){r(b);const T=e.seen.get(b),E=T.schema;if(E.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(w.allOf=w.allOf??[],w.allOf.push(E)):_c(w,E),_c(w,y),m._zod.parent===b)for(const j in w)j==="$ref"||j==="allOf"||j in y||delete w[j];if(E.$ref&&T.def)for(const j in w)j==="$ref"||j==="allOf"||j in T.def&&JSON.stringify(w[j])===JSON.stringify(T.def[j])&&delete w[j]}const _=m._zod.parent;if(_&&_!==b){r(_);const T=e.seen.get(_);if(T!=null&&T.schema.$ref&&(w.$ref=T.schema.$ref,T.def))for(const E in w)E==="$ref"||E==="allOf"||E in T.def&&JSON.stringify(w[E])===JSON.stringify(T.def[E])&&delete w[E]}e.override({zodSchema:m,jsonSchema:w,path:g.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const m of[...e.seen.entries()].reverse())r(m[0]);if(e.target!=="openapi-3.0")for(const m of e.seen.entries())q1(m[1].def??m[1].schema);for(const m of e.deferred)m();if(e.intersections.length){const m=new Map;for(const g of e.seen.values())for(const w of[g.schema,g.def]){const y=w==null?void 0:w.allOf;if(!Array.isArray(y))continue;const b=m.get(y);b?b.push(w):m.set(y,[w])}for(const g of e.intersections)for(const w of m.get(g)??[])qR(w)}}const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,(c=e.external)!=null&&c.uri){const m=(u=e.external.registry.get(t))==null?void 0:u.id;if(!m)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(m)}_c(o,n.defId?n.schema:n.def??n.schema);const i=(p=e.metadataRegistry.get(t))==null?void 0:p.id;i!==void 0&&o.id===i&&delete o.id;const l=((h=e.external)==null?void 0:h.defs)??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const m of e.seen.entries()){const g=m[1];g.def&&g.defId&&(g.def.id===g.defId&&delete g.def.id,oo(l,g.defId,g.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 m=JSON.parse(JSON.stringify(o));return Object.defineProperty(m,"~standard",{value:{...t["~standard"],jsonSchema:{input:ef(t,"input",e.processors),output:ef(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function Wr(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 Wr(r.element,n);if(r.type==="set")return Wr(r.valueType,n);if(r.type==="lazy")return Wr(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 Wr(r.innerType,n);if(r.type==="intersection")return Wr(r.left,n)||Wr(r.right,n);if(r.type==="record"||r.type==="map")return Wr(r.keyType,n)||Wr(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Wr(r.in,n)||Wr(r.out,n);if(r.type==="object"){for(const o in r.shape)if(Wr(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(Wr(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(Wr(o,n))return!0;return!!(r.rest&&Wr(r.rest,n))}return!1}const GR=(e,t={})=>n=>{const r=K1({...n,processors:t});return fr(e,r),Z1(r,e),V1(r,e)},ef=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},l=K1({...o??{},target:i,io:t,processors:n});return fr(e,l),Z1(l,e),V1(l,e)},VR={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},YR=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:l,format:c,patterns:u,contentEncoding:p,laxFormat:h}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof l=="number"&&(o.maxLength=l),c&&(o.format=VR[c]??c,o.format===""&&delete o.format,(c==="time"||h)&&delete o.format),p&&(o.contentEncoding=p),u&&u.size>0){const m=[...u];m.length===1?o.pattern=m[0].source:m.length>1&&(o.allOf=[...m.map(g=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},XR=(e,t,n,r)=>{const o=n,{minimum:i,maximum:l,format:c,multipleOf:u,exclusiveMaximum:p,exclusiveMinimum:h}=e._zod.bag;typeof c=="string"&&c.includes("int")?o.type="integer":o.type="number";const m=typeof h=="number"&&h>=(i??Number.NEGATIVE_INFINITY),g=typeof p=="number"&&p<=(l??Number.POSITIVE_INFINITY),w=t.target==="draft-04"||t.target==="openapi-3.0";m?w?(o.minimum=h,o.exclusiveMinimum=!0):o.exclusiveMinimum=h:typeof i=="number"&&(o.minimum=i),g?w?(o.maximum=p,o.exclusiveMaximum=!0):o.exclusiveMaximum=p:typeof l=="number"&&(o.maximum=l),typeof u=="number"&&(Number.isFinite(u)&&u!==0?o.multipleOf=Math.abs(u):gi(e,t,o,r,`A multipleOf divisor of ${u} cannot be represented in JSON Schema`))},QR=(e,t,n,r)=>{n.type="boolean"},JR=(e,t,n,r)=>{n.not={}},eO=(e,t,n,r)=>{},tO=(e,t,n,r)=>{const o=e._zod.def,i=y1(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},nO=(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(gi(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof l=="bigint"){if(gi(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},rO=(e,t,n,r)=>{gi(e,t,n,r,"Custom types cannot be represented in JSON Schema")},oO=(e,t,n,r)=>{gi(e,t,n,r,"Transforms cannot be represented in JSON Schema")},sO=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:l,maximum:c}=e._zod.bag;typeof l=="number"&&(o.minItems=l),typeof c=="number"&&(o.maxItems=c),o.type="array",o.items=fr(i.element,t,{...r,path:[...r.path,"items"]})};function tf(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?tf(t.out):t.type==="catch"?tf(t.innerType):e._zod.optin}const iO=(e,t,n,r)=>{var h;const o=n,i=e._zod.def,l=i.shape;if(Object.getOwnPropertySymbols(l).length&&gi(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const m in l)oo(o.properties,m,fr(l[m],t,{...r,path:[...r.path,"properties",m]}));const u=new Set(Object.keys(l)),p=new Set([...u].filter(m=>{const g=i.shape[m];return t.io==="input"?tf(g)===void 0:g._zod.optout===void 0}));p.size>0&&(o.required=Array.from(p)),((h=i.catchall)==null?void 0:h._zod.def.type)==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=fr(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},aO=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,l=o.options.map((c,u)=>fr(c,t,{...r,path:[...r.path,i?"oneOf":"anyOf",u]}));i?n.oneOf=l:n.anyOf=l},lO=(e,t,n,r)=>{const o=e._zod.def,i=fr(o.left,t,{...r,path:[...r.path,"allOf",0]}),l=fr(o.right,t,{...r,path:[...r.path,"allOf",1]}),c=p=>"allOf"in p&&Object.keys(p).length===1,u=[...c(i)?i.allOf:[i],...c(l)?l.allOf:[l]];n.allOf=u,t.intersections.push(u)},cO=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="array";const l=t.target==="draft-2020-12"?"prefixItems":"items",c=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",u=i.items.map((b,_)=>fr(b,t,{...r,path:[...r.path,l,_]})),p=i.rest?fr(i.rest,t,{...r,path:[...r.path,c,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;let h=i.items.length;for(;h>0;){const b=i.items[h-1];if(!(t.io==="input"?tf(b)!==void 0:b._zod.optout==="optional"))break;h--}const m=i.items.length,g=!i.rest;t.target==="draft-2020-12"?(o.prefixItems=u,g?o.items=!1:p&&(o.items=p),h>0&&(o.minItems=h),g&&(o.maxItems=m)):t.target==="openapi-3.0"?(o.items={anyOf:u},p&&o.items.anyOf.push(p),h>0&&(o.minItems=h),g&&(o.maxItems=m)):(o.items=u,g?o.additionalItems=!1:p&&(o.additionalItems=p),h>0&&(o.minItems=h),g&&(o.maxItems=m));const{minimum:w,maximum:y}=e._zod.bag;typeof w=="number"&&(o.minItems=w),typeof y=="number"&&(o.maxItems=y)},uO=(e,t,n,r)=>{const o=e._zod.def,i=fr(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"}]},dO=(e,t,n,r)=>{const o=e._zod.def;fr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},qg=Symbol();function Y1(e,t,n,r,o){let i=!1;const l=JSON.stringify(e,(c,u)=>typeof u!="bigint"?u:(i=!0,null));return i?(gi(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),qg):JSON.parse(l)}const fO=(e,t,n,r)=>{const o=e._zod.def;fr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;const l=Y1(o.defaultValue,e,t,n,r);l!==qg&&(n.default=l)},hO=(e,t,n,r)=>{const o=e._zod.def;fr(o.innerType,t,r);const i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;const l=Y1(o.defaultValue,e,t,n,r);l!==qg&&(n._prefault=l)},pO=(e,t,n,r)=>{const o=e._zod.def;fr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let l;try{l=o.catchValue(void 0)}catch{gi(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=l},mO=(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;fr(l,t,r);const c=t.seen.get(e);c.ref=l},gO=(e,t,n,r)=>{const o=e._zod.def;fr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},X1=(e,t,n,r)=>{const o=e._zod.def;fr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},m0=new WeakSet([Object.prototype,Error.prototype]);function bd(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 kO=(e,t)=>{N1.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);m0.has(n)||(m0.add(n),bd(n,"format",r=>o=>WA(r,o)),bd(n,"flatten",r=>o=>HA(r,o)),bd(n,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,Nm,2)}),bd(n,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,Nm,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Mo=xe("ZodError",kO,void 0,{Parent:Error}),wO=Hg(Mo),yO=Wg(Mo),vO=$f(Mo),bO=Rf(Mo),xO=qA(Mo),EO=GA(Mo),SO=VA(Mo),_O=YA(Mo),NO=XA(Mo),TO=QA(Mo),jO=JA(Mo),CO=eI(Mo);function AO(){Yo.localeError||xi(X$())}function Mf(){Yo.memoizer||xi({memoizer:G$()})}const Gn=xe("ZodType",(e,t)=>(AO(),Bn.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(vi(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 bi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(j2(e,t))},superRefine(e,t){return this.check(C2(e,t))},overwrite(e){return this.check(xl(e))},optional(){return w0(this)},exactOptional(){return g2(this)},nullable(){return y0(this)},nullish(){return w0(y0(this))},nonoptional(e){return x2(this,e)},array(){return na(this)},or(e){return a2([this,e])},and(e){return d2(this,e)},transform(e){return v0(this,m2(e))},default(e){return y2(this,e)},prefault(e){return b2(this,e)},catch(e){return S2(this,e)},pipe(e){return v0(this,e)},readonly(){return T2(this)},describe(e){const t=this.clone();return mc.add(t,{description:e}),t},meta(...e){if(e.length===0)return mc.get(this);const t=this.clone();return mc.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 E1(this,"~standard",{...$1(this),jsonSchema:{input:ef(this,"input"),output:ef(this,"output")}})},set"~standard"(e){fl(this,"~standard",e)},parse:function e(t,n){return wO(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await yO(this,t,n,{callee:e})},safeParse(e,t){return vO(this,e,t)},async safeParseAsync(e,t){return bO(this,e,t)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(e){fl(this,"spa",e)},encode:function e(t,n){return xO(this,t,n,{callee:e})},decode:function e(t,n){return EO(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await SO(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await _O(this,t,n,{callee:e})},safeEncode(e,t){return NO(this,e,t)},safeDecode(e,t){return TO(this,e,t)},async safeEncodeAsync(e,t){return jO(this,e,t)},async safeDecodeAsync(e,t){return CO(this,e,t)},toJSONSchema(e){return GR(this,{})(e)},get description(){var e;return(e=mc.get(this))==null?void 0:e.description},get _def(){return this._zod.def}}),Q1=xe("_ZodString",(e,t)=>{Zg.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>YR(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($R(...e))},includes(...e){return this.check(MR(...e))},startsWith(...e){return this.check(PR(...e))},endsWith(...e){return this.check(LR(...e))},min(...e){return this.check(Jd(...e))},max(...e){return this.check(H1(...e))},length(...e){return this.check(W1(...e))},nonempty(...e){return this.check(Jd(1,...e))},lowercase(e){return this.check(RR(e))},uppercase(e){return this.check(OR(e))},trim(){return this.check(zR())},normalize(...e){return this.check(DR(...e))},toLowerCase(){return this.check(FR())},toUpperCase(){return this.check(BR())},slugify(){return this.check(UR())}}),IO=xe("ZodString",(e,t)=>{Zg.init(e,t),Q1.init(e,t)},{email(e){return this.check(tR(PO,e))},url(e){return this.check(aR(DO,e))},jwt(e){return this.check(xR(JO,e))},emoji(e){return this.check(lR(zO,e))},guid(e){return this.check(nR(LO,e))},uuid(e){return this.check(rR(xd,e))},uuidv4(e){return this.check(oR(xd,e))},uuidv6(e){return this.check(sR(xd,e))},uuidv7(e){return this.check(iR(xd,e))},nanoid(e){return this.check(cR(FO,e))},cuid(e){return this.check(uR(BO,e))},cuid2(e){return this.check(dR(UO,e))},ulid(e){return this.check(fR(HO,e))},base64(e){return this.check(yR(YO,e))},base64url(e){return this.check(vR(XO,e))},xid(e){return this.check(hR(WO,e))},ksuid(e){return this.check(pR(KO,e))},ipv4(e){return this.check(mR(ZO,e))},ipv6(e){return this.check(gR(qO,e))},cidrv4(e){return this.check(kR(GO,e))},cidrv6(e){return this.check(wR(VO,e))},e164(e){return this.check(bR(QO,e))},datetime(e){return this.check(ER($O,e))},date(e){return this.check(SR(RO,e))},time(e){return this.check(_R(OO,e))},duration(e){return this.check(NR(MO,e))}});function Tn(e){return eR(IO,e)}const Vn=xe("ZodStringFormat",(e,t)=>{Un.init(e,t),Q1.init(e,t)}),$O=xe("ZodISODateTime",(e,t)=>{i$.init(e,t),Vn.init(e,t)}),RO=xe("ZodISODate",(e,t)=>{a$.init(e,t),Vn.init(e,t)}),OO=xe("ZodISOTime",(e,t)=>{l$.init(e,t),Vn.init(e,t)}),MO=xe("ZodISODuration",(e,t)=>{c$.init(e,t),Vn.init(e,t)}),PO=xe("ZodEmail",(e,t)=>{ZI.init(e,t),Vn.init(e,t)}),LO=xe("ZodGUID",(e,t)=>{WI.init(e,t),Vn.init(e,t)}),xd=xe("ZodUUID",(e,t)=>{KI.init(e,t),Vn.init(e,t)}),DO=xe("ZodURL",(e,t)=>{QI.init(e,t),Vn.init(e,t)}),zO=xe("ZodEmoji",(e,t)=>{JI.init(e,t),Vn.init(e,t)}),FO=xe("ZodNanoID",(e,t)=>{e$.init(e,t),Vn.init(e,t)}),BO=xe("ZodCUID",(e,t)=>{t$.init(e,t),Vn.init(e,t)}),UO=xe("ZodCUID2",(e,t)=>{n$.init(e,t),Vn.init(e,t)}),HO=xe("ZodULID",(e,t)=>{r$.init(e,t),Vn.init(e,t)}),WO=xe("ZodXID",(e,t)=>{o$.init(e,t),Vn.init(e,t)}),KO=xe("ZodKSUID",(e,t)=>{s$.init(e,t),Vn.init(e,t)}),ZO=xe("ZodIPv4",(e,t)=>{u$.init(e,t),Vn.init(e,t)}),qO=xe("ZodIPv6",(e,t)=>{f$.init(e,t),Vn.init(e,t)}),GO=xe("ZodCIDRv4",(e,t)=>{h$.init(e,t),Vn.init(e,t)}),VO=xe("ZodCIDRv6",(e,t)=>{m$.init(e,t),Vn.init(e,t)}),YO=xe("ZodBase64",(e,t)=>{g$.init(e,t),Vn.init(e,t)}),XO=xe("ZodBase64URL",(e,t)=>{w$.init(e,t),Vn.init(e,t)}),QO=xe("ZodE164",(e,t)=>{y$.init(e,t),Vn.init(e,t)}),JO=xe("ZodJWT",(e,t)=>{b$.init(e,t),Vn.init(e,t)}),J1=xe("ZodNumber",(e,t)=>{L1.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>XR(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(u0(e,t))},gte(e,t){return this.check(Up(e,t))},min(e,t){return this.check(Up(e,t))},lt(e,t){return this.check(c0(e,t))},lte(e,t){return this.check(Bp(e,t))},max(e,t){return this.check(Bp(e,t))},int(e){return this.check(g0(e))},safe(e){return this.check(g0(e))},positive(e){return this.check(u0(0,e))},nonnegative(e){return this.check(Up(0,e))},negative(e){return this.check(c0(0,e))},nonpositive(e){return this.check(Bp(0,e))},multipleOf(e,t){return this.check(d0(e,t))},step(e,t){return this.check(d0(e,t))},finite(){return this}});function ta(e){return TR(J1,e)}const e2=xe("ZodNumberFormat",(e,t)=>{x$.init(e,t),J1.init(e,t)});function g0(e){return jR(e2,e)}const t2=xe("ZodBoolean",(e,t)=>{E$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>QR(e,n,r)});function jo(e){return CR(t2,e)}const n2=xe("ZodUnknown",(e,t)=>{S$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>eO()});function k0(){return AR(n2)}const r2=xe("ZodNever",(e,t)=>{_$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>JR(e,n,r)});function o2(e){return IR(r2,e)}const s2=xe("ZodArray",(e,t)=>{Mf(),N$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>sO(e,n,r,o),e.element=t.element},{min(e,t){return this.check(Jd(e,t))},nonempty(e){return this.check(Jd(1,e))},max(e,t){return this.check(H1(e,t))},length(e,t){return this.check(W1(e,t))},unwrap(){return this.element}});function na(e,t){return HR(s2,e,t)}const i2=xe("ZodObject",(e,t)=>{Mf(),C$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>iO(e,n,r,o),MA(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return Nc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:k0()})},loose(){return this.clone({...this._zod.def,catchall:k0()})},strict(){return this.clone({...this._zod.def,catchall:o2()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return SA(this,e)},safeExtend(e){return _A(this,e)},merge(e){return NA(this,e)},pick(e){return xA(this,e)},omit(e){return EA(this,e)},partial(...e){return Bv(Gg,this,e[0])},exactPartial(...e){return Bv(nE,this,e[0],"exactPartial")},required(...e){return TA(rE,this,e[0])}});function _r(e,t){const n={type:"object",shape:e??{},...dt(t)};return new i2(n)}const eE=xe("ZodUnion",(e,t)=>{F1.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>aO(e,n,r,o),e.options=t.options});function a2(e,t){return new eE({type:"union",options:e,...dt(t)})}const l2=xe("ZodDiscriminatedUnion",(e,t)=>{eE.init(e,t),A$.init(e,t)});function c2(e,t,n){return new l2({type:"union",options:t,discriminator:e,...dt(n)})}const u2=xe("ZodIntersection",(e,t)=>{I$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>lO(e,n,r,o)});function d2(e,t){return new u2({type:"intersection",left:e,right:t})}const f2=xe("ZodTuple",(e,t)=>{Mf(),$$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>cO(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 Gg({type:"optional",innerType:n}))})}});function tE(e,t,n){const r=t instanceof Bn,o=r?n:t,i=r?t:null;return new f2({type:"tuple",items:e,rest:i,...dt(o)})}const $m=xe("ZodEnum",(e,t)=>{R$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>tO(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 $m({...t,checks:[],...dt(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 $m({...t,checks:[],...dt(o),entries:i})}});function Nc(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new $m({type:"enum",entries:n,...dt(t)})}const h2=xe("ZodLiteral",(e,t)=>{O$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>nO(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 Qr(e,t){return new h2({type:"literal",values:Array.isArray(e)?e:[e],...dt(t)})}const p2=xe("ZodTransform",(e,t)=>{Mf(),M$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>oO(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new S1(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Pc(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(Pc(l))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function m2(e){return new p2({type:"transform",transform:e})}const Gg=xe("ZodOptional",(e,t)=>{B1.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>X1(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function w0(e){return new Gg({type:"optional",innerType:e})}const nE=xe("ZodExactOptional",(e,t)=>{P$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>X1(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function g2(e){return new nE({type:"optional",innerType:e})}const k2=xe("ZodNullable",(e,t)=>{L$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>uO(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function y0(e){return new k2({type:"nullable",innerType:e})}const w2=xe("ZodDefault",(e,t)=>{D$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>fO(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function y2(e,t){return new w2({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():b1(t)}})}const v2=xe("ZodPrefault",(e,t)=>{z$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>hO(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function b2(e,t){return new v2({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():b1(t)}})}const rE=xe("ZodNonOptional",(e,t)=>{F$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>dO(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function x2(e,t){return new rE({type:"nonoptional",innerType:e,...dt(t)})}const E2=xe("ZodCatch",(e,t)=>{B$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>pO(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function S2(e,t){return new E2({type:"catch",innerType:e,catchValue:typeof t=="function"?t:LA(t)})}const _2=xe("ZodPipe",(e,t)=>{U$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>mO(e,n,r,o),e.in=t.in,e.out=t.out});function v0(e,t){return new _2({type:"pipe",in:e,out:t})}const N2=xe("ZodReadonly",(e,t)=>{H$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>gO(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function T2(e){return new N2({type:"readonly",innerType:e})}const oE=xe("ZodCustom",(e,t)=>{W$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>rO(e,n,r,o)});function j2(e,t={}){return WR(oE,e,t)}function C2(e,t){return KR(e,t)}function A2(e,t={}){const n=new oE({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...dt(t)});return n._zod.bag.Class=e,n._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}const I2=["off","tailscale","any"],$2={updates:!0,deploy:!0,remote:"any",agents:null,customAgents:!0,brandedListener:!0,planSignIn:!0};_r({updates:jo().optional(),deploy:jo().optional(),remote:Nc(I2).optional(),agents:na(Tn()).optional(),customAgents:jo().optional(),brandedListener:jo().optional(),planSignIn:jo().optional()});const R2={...$2,source:null,problem:null};function O2(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 Hp=6e3,b0=1500;function M2(e){if(e.length<=Hp)return e;const t=e.length-Hp;return`${e.slice(0,b0)}
|
|
94
|
+
[${t} characters cut here]
|
|
95
|
+
${e.slice(e.length-(Hp-b0))}`}const Ed=115,P2=2e3,nf=5e6,L2=["image/png","image/jpeg","image/gif","image/webp"],x0=2576,Wp=5*1024*1024,D2=1200,z2=10,F2=1e5,E0=100*1024*1024,B2="pasted-text.txt";function U2(e){return e.t==="term-data"||e.t==="term-snapshot"||e.t==="term-exit"}function H2(e){return e.t==="file-read"||e.t==="file-written"||e.t==="file-blame"}const W2=80;function Vg(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,W2)}}function sE(e){return e.length>=D2||e.split(`
|
|
97
|
+
`).length>=z2}function K2({startLine:e,endLine:t}){return e===t?`${e}`:`${e}-${t}`}function Z2(e){return`${e.path.slice(e.path.lastIndexOf("/")+1)} (${K2(e)})`}const q2=/\u001B(?:\[[0-?]*[ -/]*[@-~]|\][^\u0007]*(?:\u0007|\u001B\\))/g;function G2(e){return e.replace(q2,"")}const iE="Projects";function V2(e){for(const t of e){const n=t.codePointAt(0)??0;if(n<32||n===127)return!0}return!1}function Lc(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":V2(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 Y2=/^(?:https?|ssh|git|file):\/\/\S+$/i,aE=/^[\w.-]+@[\w.-]+:\S+$/;function X2(e){const t=e.trim();if(!Y2.test(t)&&!aE.test(t))return null;const n=Q2(t);return n&&!Lc(n)?{url:t,name:n}:null}function Q2(e){var o;const t=((o=e.split(/[?#]/)[0])==null?void 0:o.replace(/\/+$/,""))??"";return((aE.test(t)?t.split(":")[1]??"":t).split("/").pop()??"").replace(/\.git$/i,"")}const J2=_r({component:Tn().nullable(),file:Tn().nullable(),line:ta().nullable(),callFile:Tn().nullable().default(null),callLine:ta().nullable().default(null),tag:Tn(),selector:Tn()}),eM=_r({tag:Tn().max(40),id:Tn().max(200),classes:na(Tn().max(120)).max(16),text:Tn().max(200),attrs:na(tE([Tn().max(40),Tn().max(200)])).max(12)}),tM=tE([ta(),ta()]),nM=J2.extend({classes:Tn(),text:Tn(),html:Tn(),route:Tn(),element:eM}),rM=c2("type",[_r({type:Qr("loaded"),url:Tn(),title:Tn()}),_r({type:Qr("navigated"),url:Tn(),title:Tn().optional()}),_r({type:Qr("traversed"),dir:Nc(["back","forward"]).optional()}),_r({type:Qr("title"),title:Tn()}),_r({type:Qr("links"),links:na(_r({path:Tn().max(2048),text:Tn().max(120)})).max(200)}),_r({type:Qr("hmr")}),_r({type:Qr("page-error"),message:Tn(),source:Tn().optional(),line:ta().optional()}),nM.extend({type:Qr("picked"),verb:Nc(["chat","code"]).default("chat"),site:Nc(["call","source"]).default("source")}),_r({type:Qr("pick-cancel")}),_r({type:Qr("highlight-miss"),path:Tn(),fileMatched:ta(),withSource:ta(),ranges:na(tM).nullable()}),_r({type:Qr("drag-files"),over:jo().default(!0)}),_r({type:Qr("drop-files"),files:na(A2(File))}),_r({type:Qr("focus"),gesture:jo()}),_r({type:Qr("key"),key:Tn(),code:Tn().optional(),meta:jo(),ctrl:jo().optional(),shift:jo().optional(),alt:jo().optional(),up:jo().optional()})]);function lE(e){const t=rM.safeParse(e);return t.success?t.data:null}const oM=/["“”]([^"“”]*)["“”]?|(\S+)/g;function cE(e){const t=new Set;for(const n of e.matchAll(oM)){const r=(n[1]??n[2]??"").replace(/\s+/g," ").trim().toLowerCase();r&&t.add(r)}return[...t]}const sM="now",iM="http://preview.invalid",aM=200;function S0(e){const t=e==null?void 0:e.replace(/\s+/g," ").trim().slice(0,aM).trim();return t||void 0}function Pf(e){let t;try{t=new URL(e,iM)}catch{return null}if(t.pathname.startsWith("/__toyon"))return null;const n=_0(t.pathname)||"/",r=t.hash.startsWith("#/")?_0(t.hash.split("?")[0]??""):"";return r.length>1?`${n}${r}`:n}const _0=e=>e.replace(/\/+$/,""),lM={static:4,mixed:3.5,param:3,optional:2,"optional-static":2,splat:1},rf=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function uE(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="",c=0;for(const p of e.matchAll(/\[([^\]=]+)(?:=[^\]]*)?\]|\{\$([\w-]+)\}/g)){const h=e.slice(c,p.index);h&&(i.push({text:h}),l+=rf(h)),i.push({name:p[1]??p[2]??"param"}),l+="[^/]+?",c=(p.index??0)+p[0].length}const u=e.slice(c);if(u&&(i.push({text:u}),l+=rf(u)),i.some(p=>"name"in p))return{kind:"mixed",pattern:l,parts:i}}return{kind:"static",text:e}}function cM(e){const t=e.split("/").filter(Boolean).map(uE);if(t.every(r=>r.kind==="static"))return null;let n="";for(const r of t)r.kind==="static"?n+=`/${rf(r.text)}`:r.kind==="optional-static"?n+=`(?:/${rf(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+lM[o.kind],0),statics:t.filter(r=>r.kind==="static").length}}function uM(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 Lf(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(uE))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 eu={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"}},dE={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"}},dM={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"}},fM={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"}},hM={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"}},pM={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"}},mM={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"}},gM={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"}},kM={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"}},wM={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"}},yM={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"}},vM={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"}},bM={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"}},xM={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"}},EM={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"}},SM={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"}},_M={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"}},NM={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"}},TM={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"}},jM=[kM,wM,yM,vM,bM,xM,EM,SM,_M,NM,TM],Fd=[eu,dE,dM,fM,hM,pM,mM,gM,...jM],CM={mode:"dark",light:dE.id,dark:eu.id},AM=["surface0","surface1","surface2","element0","element1","border0","border1","text0","text1","text2","red","orange","yellow","green","aqua","blue","purple","diffAdd","diffDel"];function IM(e){return`--${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function N0(e){const t=pE(e);return t>.008856?116*t**(1/3)-16:903.3*t}function fE(e,t){const n=N0(e)+t,r=la(e);if(!r)return e;let o=0,i=2;for(let l=0;l<24;l++){const c=(o+i)/2,u=hl(Math.min(255,r[0]*c),Math.min(255,r[1]*c),Math.min(255,r[2]*c));N0(u)<n?o=c:i=c}return hl(Math.min(255,r[0]*o),Math.min(255,r[1]*o),Math.min(255,r[2]*o))}function $M(e){return fE(e.colors.surface1,-4)}function RM(e){return fE(e.colors.surface0,-4)}function T0(e){return UM(e,.55)}function OM(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 MM(e){const t={};for(const n of AM)t[IM(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(OM(e)))t[`--syntax-${n}`]=r;return t["--accent"]=Yg(e),t["--fault"]=PM(e),t["--sunken"]=$M(e),t["--sunken-floor"]=RM(e),t["--scrim"]=BM(e.colors.surface0,.7),t["--shadow"]=e.kind==="dark"?"#00000066":"#0000002e",t["--diff-add-word"]=T0(e.colors.diffAdd),t["--diff-del-word"]=T0(e.colors.diffDel),t}function Yg(e){return hE(e.accent??"")??e.colors.orange}function PM(e){return Yg(e)===hE(e.colors.orange)?e.colors.red:e.colors.orange}function LM(e){return e==="system"||e==="daylight"}function Xg(e,t){return e.mode==="system"?t.system?"dark":"light":e.mode==="daylight"?t.daylight?"dark":"light":e.mode}function Df(e,t,n){const r=Xg(e,n);return t.find(o=>o.id===e[r])??Fd.find(o=>o.kind===r)??eu}function DM(e,t){if(e.pair){const l=t.find(c=>c.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 zM(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=DM(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 FM(e,t){const n={...e};return t.dark&&(n.dark=t.dark.id),t.light&&(n.light=t.light.id),!LM(n.mode)&&!t[n.mode]&&(n.mode=t.dark?"dark":"light"),n}function la(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 hE(e){const t=la(e);return t?hl(t[0],t[1],t[2],t[3]):null}function hl(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 BM(e,t){const n=la(e);return n?hl(n[0],n[1],n[2],t):e}function UM(e,t){const n=la(e);return n?hl(n[0],n[1],n[2],Math.min(1,n[3]*t)):e}function nK(e,t){const n=la(e),r=la(t);if(!n||!r)return e;const o=n[3];return hl(n[0]*o+r[0]*(1-o),n[1]*o+r[1]*(1-o),n[2]*o+r[2]*(1-o))}function pE(e){const t=la(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 HM(e){return pE(e)>.179?"#1d2021":"#fbf1c7"}function Rm(e){if(e===null||e==="")return"the npm registry";try{return new URL(e).host}catch{return e}}function mE(e,t){const n=j0(e),r=j0(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 j0(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 WM=[[/\.(png|jpe?g|gif|webp|avif|bmp|ico)$/i,"image"]];function KM(e){var t;return((t=WM.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const ZM=[[/\.(md|markdown)$/i,"markdown"],[/\.html?$/i,"html"]];function zf(e){var t;return((t=ZM.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const qe={active:"toyon-active",phoneRow:"toyon-phone-row",repo:"toyon-repo",lastActive:"toyon-last",discoveredOpen:"toyon-disc",archivedOpen:"toyon-arch",committedShut:"toyon-committed-shut",turnOpen:"toyon-turn-open",treeOpen:"toyon-tree",token:"toyon-token",theme:"toyon-theme",daylight:"toyon-sun",changesWidth:"toyon-changes-w",chatWidth:"toyon-chat-w",editorHeight:"toyon-dh",editorFull:"toyon-dfull",editorWrap:"toyon-dwrap",designHeight:"toyon-dsh",designFull:"toyon-dsfull",termHeight:"toyon-th",rail:"toyon-rail",railWidth:"toyon-rail-w",chatSide:"toyon-chat-side",clipboardOffer:"toyon-clipboard-offer",installOffered:"toyon-install-offered",layouts:"toyon-layouts",client:"toyon-client",ground:"toyon-ground",profilePrefix:"toyon-profile-",modePrefix:"toyon-mode-",modelPrefix:"toyon-model-",effortPrefix:"toyon-effort-",version:"toyon-version"},qM=[qe.active,qe.repo,qe.lastActive,qe.discoveredOpen,qe.archivedOpen,qe.committedShut,qe.turnOpen,qe.treeOpen,qe.profilePrefix,qe.modePrefix,qe.modelPrefix,qe.effortPrefix,qe.phoneRow,qe.version],GM=[qe.profilePrefix,qe.modePrefix,qe.modelPrefix,qe.effortPrefix],Bd=(e,t)=>`${e}@${t}`;function VM(e,t=typeof localStorage>"u"?null:localStorage,n=typeof sessionStorage>"u"?null:sessionStorage){const r=l=>({get(c){try{return(l==null?void 0:l.getItem(Bd(c,e)))??null}catch{return null}},set(c,u){try{l==null||l.setItem(Bd(c,e),u)}catch{}},remove(c){try{l==null||l.removeItem(Bd(c,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 c of gE(l).filter(u=>u.endsWith(`@${e}`)))try{l==null||l.removeItem(c)}catch{}}}}function gE(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 YM="orch-";function XM(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=qe[i],c=YM+l.slice(6);C0(r,c,l)}for(const[r,o]of[[t,qM.filter(i=>i!==qe.phoneRow)],[n,[qe.phoneRow]]]){const i=gE(r).filter(l=>!l.includes("@"));for(const l of o){const c=GM.includes(l)?i.filter(u=>u.startsWith(l)):i.filter(u=>u===l);for(const u of c)C0(r,u,Bd(u,e))}}}function C0(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 kE(){const e=location.hash.match(/token=([a-f0-9]+)/);if(e!=null&&e[1])return wE(e[1]),e[1];try{return localStorage.getItem(qe.token)??sessionStorage.getItem(qe.token)??""}catch{return""}}function wE(e){try{localStorage.setItem(qe.token,e)}catch{}}function Qg(){return kE()!==""}function Jg(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}`,attachmentWhere:(i,l)=>`${n.origin}/attachments/${i}/${l}?${r}&where`,upload:i=>`${n.origin}/uploads/${i}?${r}`,worktreeFile:(i,l,c)=>`${n.origin}/files/${i}/${l.split("/").map(encodeURIComponent).join("/")}?${r}${o(c)}`,loose:(i,l)=>`${n.origin}/loose/${encodeURIComponent(i)}?${r}${o(l)}`,health:`${n.origin}/health`,restart:i=>`${n.origin}/restart?${r}${i?`&${sM}`:""}`,uploads:i=>`${n.origin}/uploads?kind=${i}`,tailnet:`${n.origin}/tailnet`,remote:`${n.origin}/remote`,tailscale:`${n.origin}/tailscale`,machines:`${n.origin}/machines`,knockAnswer:i=>`${n.origin}/knock/${i}/answer`,previewGrant:`${n.origin}/preview-grant`,changelog:`${n.origin}/changelog`}}const El=e=>({authorization:`Bearer ${e.token}`});async function QM(e,t,n,r){try{await n.slice(0,1).arrayBuffer()}catch{return"could not be read"}return new Promise(o=>{const i=new XMLHttpRequest;i.open("POST",e.uploads(t)),i.setRequestHeader("authorization",El(e).authorization),i.setRequestHeader("content-type",n.type||"application/octet-stream"),r&&(i.upload.onprogress=l=>l.lengthComputable&&r(l.loaded/l.total)),i.onload=()=>{if(i.status>=502&&i.status<=504)return o(null);if(i.status<200||i.status>=300)return o(i.responseText||"could not be attached");try{o(JSON.parse(i.responseText))}catch{o("could not be attached")}},i.onerror=()=>o(null),i.onabort=()=>o(null),i.send(n)})}async function JM(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 yE(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 eP(e){var t;try{const n=await fetch(e.changelog,{headers:El(e)});return!n.ok||!((t=n.headers.get("content-type"))!=null&&t.startsWith("text/markdown"))?null:await n.text()}catch{return null}}async function tP(e,t){try{const n=await fetch(t,{headers:El(e)});return n.ok?await n.json():null}catch{return null}}async function Ff(e,t,n,r){try{const o=await fetch(t,{method:"POST",headers:{...El(e),"content-type":"application/json"},body:JSON.stringify(n)});return o.ok?null:await o.text()||`refused (${o.status})`}catch{return r}}const nP=e=>tP(e,e.tailnet),rP=e=>Ff(e,e.remote,{tailscale:!0},"Toyon is not answering; try again once it is back."),oP=e=>Ff(e,e.remote,{off:!0},"Toyon is not answering; try again once it is back.");async function vE(e,t,n){try{const r=await fetch(t,{method:"POST",headers:{...El(e),"content-type":"application/json"},body:JSON.stringify(n)});return r.ok?await r.json():null}catch{return null}}const bE="Toyon is not answering; try again once it is back.",sP=async e=>{const t=await vE(e,e.tailscale,{up:!0});return t===null?bE:t.refused},iP=async e=>await vE(e,e.tailscale,{login:!0})??{why:bE},aP=(e,t,n)=>Ff(e,e.machines,{origin:t,token:n},"Toyon here is not answering; the machine is not listed yet."),lP=(e,t,n)=>Ff(e,e.knockAnswer(t),{letIn:n},"Toyon is not answering");async function xE(e){try{const t=await fetch(e.previewGrant,{method:"POST",headers:El(e)});return t.ok?await t.json():null}catch{return null}}const cP=2e3;async function EE(e,t,n){let r;try{const o=await fetch(`${e}/knock`,{method:"POST",signal:t});if(o.status===429)return"full";if(!o.ok)return"not-toyon";r=await o.json()}catch{return t.aborted?"gone":"unreachable"}if(typeof r.id!="string"||typeof r.word!="string")return"not-toyon";for(n(r.word);!t.aborted;){try{const o=await fetch(`${e}/knock/${r.id}`,{cache:"no-store",signal:t});if(o.status===404)return"gone";if(o.ok){const i=await o.json();if(i.state==="let-in"&&typeof i.token=="string"&&i.token)return{token:i.token};if(i.state==="refused")return"refused"}}catch{}await new Promise(o=>setTimeout(o,cP))}return"gone"}async function Om(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 uP=1e3,dP=3e4,fP=1500,hP=5e3,A0=50,pP=e=>e.t==="chat"||e.t==="create-worktree"||e.t==="restore-worktree"||e.t==="batch-worktrees";class mP{constructor(t,n,r,o=hP){Bt(this,"ws",null);Bt(this,"queue",[]);Bt(this,"closed",!1);Bt(this,"attempt",0);Bt(this,"timer",null);Bt(this,"downAt",null);Bt(this,"downCode",0);Bt(this,"sayTimer",null);Bt(this,"sentDown",new Set);Bt(this,"urls");Bt(this,"suspended",!1);Bt(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.connectDeadline=o,this.urls=Jg(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===tA)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+fP-Date.now()))}connect(){if(this.closed||this.suspended)return;const t=new WebSocket(this.urls.ws);this.ws=t;let n=!1;const r=setTimeout(()=>{t.readyState===WebSocket.CONNECTING&&t.close()},this.connectDeadline);t.onmessage=o=>{if(!n){n=!0,clearTimeout(r),this.attempt=0,this.downAt=null,this.sayTimer&&clearTimeout(this.sayTimer),this.sayTimer=null,this.onStatus(!0);for(const i of this.queue)t.send(i.raw);this.queue=[]}try{this.onMsg(JSON.parse(o.data))}catch{}},t.onclose=o=>{if(clearTimeout(r),this.ws!==t||(this.onStatus(!1),this.closed||this.suspended))return;this.say(o.code);const i=Math.min(dP,uP*2**this.attempt++);this.timer=setTimeout(()=>this.connect(),i/2+Math.random()*(i/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)),pP(t)&&t.boxId&&this.sentDown.add(t.boxId),this.queue.push({key:r,raw:n}),this.queue.length>A0&&this.queue.splice(0,this.queue.length-A0)}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 ek(e){return e==="cancelled"||e==="expired"}function SE(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:ek(t.outcome)?t:null}function gP(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 kP(e){return e.map(()=>({selected:[]}))}function I0(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(c=>c!==n):[...o.selected,n]}:{...o,selected:[n]}})}function of(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 $0(e,t,n,r){return e.map((o,i)=>i!==t?o:{selected:n&&!r?[]:o.selected,note:o.note??""})}function Ud(e,t){const n=e[t];return n&&n.note!==void 0&&!n.note.trim()?of(e,t,void 0):e}function wP(e){return e?e.options.length+(e.note?1:0):0}function yP(e,t){return!!(e!=null&&e.note)&&t===e.options.length}function _E(e,t){return!!e&&e.note!==void 0&&(t||e.selected.length===0)}function sl(e){var t;return!!e&&(e.selected.length>0||!!((t=e.note)!=null&&t.trim()))}function Sd(e,t){return e.every((n,r)=>!n.required||sl(t[r]))}function vP(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(i=>{var l;return nk(((l=e.options.find(c=>c.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 bP(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(i=>{var l;return nk(((l=e.options.find(c=>c.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 tk(e,t){return e.map((n,r)=>{const o=vP(n,t==null?void 0:t[r]);return e.length>1&&n.header?`${n.header} · ${o}`:o})}function xP(e){return e.outcome!=="answered"||e.ask.kind!=="question"?null:{message:e.ask.message,questions:e.ask.questions,answers:e.answers}}function EP(e){if(e.outcome!=="answered"||e.ask.kind!=="permission"||e.toolId)return null;const t=e.ask.choices.find(r=>r.id===e.choiceId);if(!t)return null;const n=e.ask.plan??null;return{file:n,text:n?"":e.ask.detail??"",choice:t.name}}function Ja(e,t){if(!e)return 0;if(_E(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 SP(e,t,n){return Math.max(0,Math.min(n-1,e+t))}function _P(e,t,n){const r=e.length;for(let o=1;o<=r;o++){const i=(n+o)%r;if(!sl(t[i]))return i}return-1}function Tc(e){return e.length>1?e.length:-1}function NP(e){return e.length+(Tc(e)===-1?0:1)}function R0(e,t,n){const r=_P(e,t,n);if(r!==-1)return{current:r,cursor:Ja(e[r],t[r]),send:!1};const o=Tc(e);return o!==-1?{current:o,cursor:0,send:!1}:{current:n,cursor:Ja(e[n],t[n]),send:!0}}const NE=/\s*\(recommended\)\s*$/i;function TP(e){return NE.test(e)}function nk(e){return e.replace(NE,"")}const jP={skipped:"you skipped this",cancelled:"the turn was stopped before you answered",expired:"Toyon restarted before you answered"};function TE(e,t,n,r){return n!==null&&r===n.host?`${eA(n.previews,e,t)}/`:r.endsWith(".localhost")?`http://w${e}.${r}:${t}/`:Dg(r)?`http://${r==="localhost"?"127.0.0.1":r}:${t}/`:`https://${r}:${t}/`}function O0(e){return e.ranges.map(([t,n])=>[t+e.offset,n+e.offset])}function jE(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 CP(e){var r;const t=(r=e.source)==null?void 0:r.replace(/[?#].*$/,""),n=t?` (${jE(t)}:${e.line??"?"})`:"";return`${e.message}${n}`.slice(0,P2)}function _d(e,t){return!Number.isFinite(e)||e<=0?t:Math.min(Math.max(e,170),Math.floor(window.innerWidth*.5))}function tu(e){return e.agent==="working"||e.agent==="waiting"}function Is(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 AP={waiting:"Waiting for you",working:"Agent working",failed:"Agent failed",landed:"Landed",crashed:"Crashed",running:"Running",starting:"Starting",asleep:"Asleep",idle:"Idle"};function rk(e,t=!1){const n=Is(e);return n==="idle"&&t?"Not set up":AP[n]}const IP={starting:"Starting",running:"Running",unreachable:"Not answering",crashed:"Crashed",stopped:"Stopped",asleep:"Asleep"};function $P(e){return IP[e]}function CE(e,t){return t&&Is(e)!=="waiting"?t:null}const RP={land:"Landing",commit:"Committing","sync-main":"Syncing with main","pull-main":"Pulling"};function ok(e){return RP[e]}function AE(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 OP(e){const t=e.lastIndexOf("/");return t<0?{name:e,dir:""}:{name:e.slice(t+1),dir:e.slice(0,t)}}const IE=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}).compare;function sf(e){const t=[];for(let n=e.indexOf("/");n!==-1;n=e.indexOf("/",n+1))t.push(e.slice(0,n));return t}function $E(e){const t=new Set;for(const n of e)for(const r of sf(n))t.add(r);return[...t].sort(IE)}function sk(e){return e.includes("A")||e==="??"?"added":e.includes("D")?"deleted":""}function ik(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 MP=/Firefox\//.test(navigator.userAgent);function ak(){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 PP=/Chrome\//.test(navigator.userAgent)&&ak(),Dt=e=>FC(e,{firefox:MP,pwa:PP});function lk(e){return e.component?`<${e.component} />`:`<${e.tag}>`}function Mm(e,t){return e.worktree&&wr(e.worktree)&&t?t.defaultBranch:e.name}function ck(e){const t=Math.max(0,e/1e3),n=(l,c)=>`${l} ${c}${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 yr(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 Xi(e){const t=Math.max(0,Math.floor(e));return t<100?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function LP(e,t,n,r){var l;if(!t)return null;const o=e.filter(_n).filter(c=>c.repoId===t&&(c.worktree.agent??r)===n);return((l=o.find(c=>wr(c.worktree))??o[0])==null?void 0:l.id)??null}const DP=200;function zP(e,t){const n=new Map(e.map(r=>[r.path,r]));for(const r of t){if(n.size>=DP)break;const o=Pf(r.path);o&&!n.has(o)&&n.set(o,{path:o,text:r.text})}return n.size===e.length?e:[...n.values()]}function RE(e){return e!==void 0&&!e.routes.some(t=>!t.endpoint)}const ki=e=>"uploading"in e&&e.uploading===!0;function il(e){switch(e.kind){case"image":case"file":{const{key:t,local:n,uploading:r,progress:o,...i}=e;return i}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 uk=e=>e.filter(t=>!ki(t)).map(il);let FP=0;function Pm(e,t){const n=new Map(t.filter(o=>!ki(o)).map(o=>[JSON.stringify(il(o)),o]));return[...e.map(o=>{const i=JSON.stringify(o),l=n.get(i);if(l)return n.delete(i),l;const c=`d${++FP}`;return o.kind==="paste"?{...o,key:c,...Vg(o.text)}:{...o,key:c}}),...t.filter(ki)]}const Lm="out:",BP=(e,t,n)=>`${Lm}${e}:${t}:${n}`;function ls(e){if(!e.startsWith(Lm))return null;const t=e.slice(Lm.length),n=t.indexOf(":"),r=t.indexOf(":",n+1);return n<0||r<0?null:{clientId:t.slice(0,n),source:t.slice(r+1)}}function gc(e,t,n,r){const o=r.length?uk(r):void 0;switch(e.t){case"chat":return{...e,text:n,attachments:o,boxId:t};case"create-worktree":return{...e,prompt:n,attachments:o,boxId:t};case"restore-worktree":case"adopt-worktree":return{...e,message:{text:n,attachments:o},boxId:t};case"agent-answer":return{...e,attachments:o,boxId:t}}}function UP(e,t){const n=new Set,r=[];for(const o of e){if(n.has(o.log))continue;const i=t[o.id];if(!i||i.attachments.some(ki)){n.add(o.log);continue}r.push(o.id)}return r}const OE=e=>e.flatMap(t=>"upload"in t&&t.upload?[t.upload]:[]);function HP(e){const t=n=>OE(n.items).some(r=>!n.before.includes(r));return[...e.filter(t),...e.filter(n=>!t(n))]}const Hd=["files","changes","history"],WP=e=>Hd.includes(e),ME=e=>!!(e!=null&&e.carry)&&!e.batch&&e.variants===1,Sl=e=>(e==null?void 0:e.worktree.id)??null,pl="new-project",da=Object.freeze({chat:[],log:[],queue:[],page:{},turn:{edits:!1,hmr:!1},changedRanges:{},commitFiles:{},search:null,design:null,draft:"",attachments:[],commands:[],termStream:Ao}),dk=e=>({...e,phase:"editing",repoId:null}),M0=()=>dk({mode:"create",name:"",parent:`~/${iE}`}),KP=Object.freeze({changes:!1,changesTab:"files",chat:!0,term:!1,design:!1});function ZP(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.changes=="boolean"&&WP(t.changesTab)&&typeof t.chat=="boolean"&&typeof t.term=="boolean"&&typeof t.design=="boolean"}function Jr(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 fk(e,t){return{...e,layout:t,changesAuto:!1}}const wi=e=>zf(e)?"preview":"file",qP=(e,t)=>e===t||!!e&&!!t&&e.at===t.at&&(e.at!=="tree"||t.at!=="tree"||e.worktreeId===t.worktreeId&&e.dir===t.dir)&&(e.at!=="rail"||t.at!=="rail"||e.worktreeId===t.worktreeId),cc=(e,t)=>e.worktreeId===t.worktreeId&&e.path===t.path&&e.ref===t.ref&&e.since===t.since;function PE(e,t,n,r){var i;if(!r.fiber)return r;const o=(i=Ro(e,t).changedRanges[n])==null?void 0:i.offset;return o===void 0?r:{n:r.n-o}}function GP(e){const t=e.cached??eu,n={connected:!1,connectFailure:null,repos:[],rows:[],activeRepoId:null,visible:[],lent:null,archiving:[],shipping:{},visibleDiscovered:[],discoveredOpen:e.storedDiscoveredOpen??{},archivedOpen:e.storedArchivedOpen??{},committedShut:e.storedCommittedShut??{},turnOpen:e.storedTurnOpen??{},treeOpen:e.storedTreeOpen??{},treeReveal:null,refs:{},chats:{},archived:{},archivedPage:null,lastActive:e.storedLastActive??{},pendingOpen:!1,activeId:null,carryTo:null,clientId:e.clientId,storedActive:e.storedActive??null,storedRepo:e.storedRepo??null,heard:!1,local:{},editor:null,openUrl:null,reloadReq:null,dragFiles:null,picking:!1,overlay:null,paletteReturn:null,incompatible:!1,layout:KP,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,previewSize:null,themes:Fd.some(o=>o.id===t.id)?Fd:[...Fd,t],themePrefs:{...CM,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:R2,letIn:!1,knocks:[],tailscale:null,handed:[],gitIdentity:!0,self:null,rebuilt:!1,update:null,updateCheck:null,version:"",install:"none",registry:null,ranBefore:e.storedVersion??null,notesPage:!1,notesSeen:!1,choosingFolder:!1,newProject:null,autoSend:null,outbox:[],chosenFolder:null,pending:[],activeImportId:null,agents:[],defaultAgent:"claude",agentChosen:!1,agentConfigs:{},draft:null,trunks:{},visits:{}},r=e.storedRepo?n.layouts[e.storedRepo]:void 0;return r?fk(n,r):n}function LE(e){var t;return{system:e.systemDark,daylight:((t=e.daylight)==null?void 0:t.dark)??e.systemDark}}function VP(e){return e.previewTheme??Df(e.themePrefs,e.themes,LE(e))}function Ro(e,t){return t&&e.local[t]||da}function yo(e,t){return t&&e.rows.find(n=>n.id===t)||null}function DE(e,t){const n=yo(e,t);return n?n.agent==="working"||n.agent==="waiting"||!!e.shipping[n.id]||(n.queued??0)>0:!1}function dn(e,t){const n=yo(e,t);return n&&_n(n)?n:null}function zE(e){var o;const t=dn(e,e.activeId);if(!t||!ia(t.worktree)||t.agent!=="idle"||!((o=ml(e,t.repoId))!=null&&o.empty))return!1;const n=Ei(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&&Ro(e,t.id).chat.length===0}function Bf(e){return e.newProject!==null||zE(e)}function YP(e){return e.incompatible||Bf(e)}function XP(e){return(!e.needsSetup||!!e.assumed)&&Object.keys(e.config.run).length===0}function af(e){return!!(e!=null&&e.needsSetup)&&!e.assumed}function hk(e){const t=e.archivedPage?null:yo(e,e.activeId);return(t==null?void 0:t.repoId)??e.activeRepoId}function Io(e){const t=Ei(e,hk(e));return!!t&&XP(t)}function FE(e){return e.layout.chat&&!Io(e)&&!e.archivedPage&&!ZE(e)?{a:"toggle-chat"}:{a:"focus-chat"}}function BE(e,t){var n;return!e.activeRepoId||!((n=e.archived[e.activeRepoId])!=null&&n.some(r=>r.id===t))?e:{...e,archivedPage:t,notesPage:!1,editor:null,screen:"chat"}}function Wo(e){return Io(e)?e:Jr(e,{chat:!0})}function Ei(e,t){return t&&e.repos.find(n=>n.id===t)||null}function UE(e,t){if(!t)return null;const n=e.rows.filter(_n).filter(r=>r.repoId===t);return n.find(r=>Jc(r.worktree))??n.find(r=>ia(r.worktree))??null}function ml(e,t){return t&&e.trunks[t]||null}function kc(e){return Io(e)||e.archivedPage||e.notesPage?null:e.activeId}function pk(e){return e.procs.some(t=>t.status==="running"||t.status==="starting")}function lf(e){if(e.archivedPage||e.notesPage)return null;const t=dn(e,e.activeId);return t&&pk(t)?{worktreeId:t.worktree.id,repoId:t.repoId}:null}function mk(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&&_n(o)&&o.repoId===t?o:null}function HE(e,t){return e.repoId!==t&&(e.agent==="waiting"||!!e.unseen)}function Uf(e,t,n,r){return e.repoId===t||mk(e,t,n)!==null||HE(e,t)||e.id===r}function WE(e,t,n){return!e||!t||!_n(e)||e.repoId===t||mk(e,t,n)?null:HE(e,t)?e.id:null}function KE(e,t){return t.length?e.filter(n=>!t.includes(n.id)):e}function QP(e,t,n,r){const o=KE(e,n).filter(_n);return _C(t?o.filter(i=>Uf(i,t,o,r)):o)}function JP(e,t){const n=e.filter(r=>!_n(r));return t?n.filter(r=>r.repoId===t):n}function al(e,t,n=e.rows){var c;const r=n.filter(_n),o=e.archiving.length?r.filter(u=>!e.archiving.includes(u.id)):r,i=t?e.lastActive[t]:void 0;if(i&&o.some(u=>u.id===i))return i;const l=t?o.filter(u=>u.repoId===t):o;return((c=l.find(u=>Jc(u.worktree))??l.find(u=>ia(u.worktree))??l[0])==null?void 0:c.id)??null}function P0(e,t){const n=Object.entries(e),r=n.filter(([o])=>!t(o));return r.length===n.length?e:Object.fromEntries(r)}function L0(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,c]of Object.entries(e))!c.sent||r[l]||(t.some(u=>u.id===l)||XE({trunks:n},l))&&(r[l]=c);const o=Object.keys(r);return o.length===Object.keys(e).length&&o.every(l=>eL(e[l],r[l]))?e:r}const eL=(e,t)=>!!e&&!!t&&e.op===t.op&&e.step===t.step&&e.sent===t.sent;function el(e,t){var m;const n=yo(e,t),r=!!n&&_n(n)&&!!e.activeRepoId&&Uf(n,e.activeRepoId,e.rows,e.lent),o=r&&e.lent!==t?WE(n,e.activeRepoId,e.rows):r?e.lent:null,i=r?e.activeRepoId:(n==null?void 0:n.repoId)??e.activeRepoId,l=n&&_n(n)?{...e.lastActive,[n.repoId]:n.id}:e.lastActive,c=e.activeId!==t?e.activeId:null,u=c?e.local[c]:void 0,p=u&&((m=u.mark)==null?void 0:m.by)==="reveal"?tl(u,"reveal"):null,h=c&&p?{...e.local,[c]:p}:e.local;return{...e,activeId:t,activeRepoId:i,lent:o,lastActive:l,editor:null,archivedPage:null,notesPage:!1,local:h}}function gl(e){return Oo(e)?"history":e.layout.changesTab}function tL(e,t){const n=gl(e);if(Oo(e))return n;const r=Hd.length;return Hd[(Hd.indexOf(n)+t+r)%r]??"changes"}function ZE(e){if(e.archivedPage)return null;const t=yo(e,e.activeId);return t&&!_n(t)?t:null}function nL(e){return e.notesSeen||e.ranBefore===null||!mE(e.version,e.ranBefore)?null:e.version}function Oo(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 tl(e,t){var o;if(((o=e.mark)==null?void 0:o.by)!==t)return e;const{mark:n,...r}=e;return r}const qE=e=>e.kind==="theme"||e.kind==="appearance"||e.kind==="keep-awake"||e.kind==="agent"||e.kind==="agent-page"||e.kind==="choose-folder"||e.kind==="handoff";let rL=0;function Dc(e){if(!e.sending)return e;const{sending:t,...n}=e;return n}function oL(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]=Dc(r[o]);return{...e,local:r}}function sL(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 c=o[r]??da,u=c.chat.some(p=>p.kind==="user")?{at:i.at}:i;o={...o,[n]:Dc(o[n]),[r]:{...c,sending:u}}}for(const c of t){const u=o[c.id];u!=null&&u.sending&&!u.sending.message&&(c.agent==="working"||c.agent==="waiting")&&(o={...o,[c.id]:Dc(u)})}return o}function Et(e,t,n){return{...e,local:{...e.local,[t]:n(e.local[t]??da)}}}function D0(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 iL(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-go"||t.type==="handoff-declined"?t.id:null;if(!n&&!r)return e;const o=t.type==="agent-ask-end"&&ek(t.outcome),i=t.type==="agent-ask-end"&&t.outcome==="expired"?t.id:null,{card:l,cardParked:c,askRevived:u,...p}=e;return{...p,...l&&!n&&(l.id!==r||o)?{card:l}:{},...c&&!n&&c!==r?{cardParked:c}:{},...i?{askRevived:i}:u&&!n?{askRevived:u}:{}}}function aL(e,t,n){return Et(e,t,r=>({...r,chat:[...r.chat,n],chatAt:Date.now()}))}function GE(e,t,n){return aL(Wo(e),t,{kind:"error",text:n})}function Dm(e,t){const n=Sl(dn(e,e.activeId));return n?Et(Wo(e),n,r=>({...r,notice:t})):e}function z0(e,t,n){return dn(e,t)?GE(e,t,n):Dm(e,n)}function lL(e,t){const n=e.paletteReturn;return!t||!n?{overlay:null,paletteReturn:null}:{overlay:{kind:n.mode},paletteReturn:n}}function cL(e){const t=e.activeRepoId;if(!t)return e;const n=e.layouts[t];return n?fk(e,n):e.frame==="desk"?{...e,layouts:{...e.layouts,[t]:e.layout}}:e}function uL(e){return e.a==="server"&&e.msg.t==="git-status"}function dL(e){return{variants:1,batch:!1,agent:e.defaultAgent}}function fL(e){const t=dn(e,e.activeId);return!!t&&wr(t.worktree)&&!e.archivedPage&&!Bf(e)?e.draft?e:{...e,draft:dL(e)}:e.draft?{...e,draft:null}:e}function VE(e){var r;const t=e.archivedPage,n=t!==null&&((r=e.editor)==null?void 0:r.worktreeId)===t&&dn(e,t)===null;return{...e,archivedPage:null,...n?{editor:null}:{}}}function hL(e){const t=e.activeRepoId;if(!t)return e;const n=dn(e,e.activeId);return!n||n.repoId===t||Uf(n,t,KE(e.rows,e.archiving),e.lent)?e:el(e,al(e,t))}function F0(e,t,n){const r=t.some(i=>!e.knocks.some(l=>l.id===i.id)),o={...e,knocks:t,letIn:n};return r&&o.overlay===null?hi(o,{a:"open",overlay:{kind:"devices"}}):o}const pL=e=>{var t;return e.frame==="desk"&&(e.remote!==null||((t=e.tailscale)==null?void 0:t.state)==="ready")};function hi(e,t){let n=fL(hL(mL(e,t)));return n.unreadHold!==null&&n.activeId!==n.unreadHold&&(n={...n,unreadHold:null}),n.archivedPage!==null&&(Oo(n)===null||dn(n,n.archivedPage)!==null)&&(n=VE(n)),n.activeRepoId!==e.activeRepoId?n=cL(n):n.frame==="desk"&&n.activeRepoId&&!uL(t)&&n.layout!==e.layout&&(n={...n,layouts:{...n.layouts,[n.activeRepoId]:n.layout}}),n.rows===e.rows&&n.activeRepoId===e.activeRepoId&&n.archiving===e.archiving&&n.lent===e.lent?n:{...n,visible:QP(n.rows,n.activeRepoId,n.archiving,n.lent),visibleDiscovered:JP(n.rows,n.activeRepoId)}}function mL(e,t){var n,r,o,i,l,c,u,p;switch(t.a){case"connected":return{...e,connected:t.v,connectFailure:t.v?null:t.failure===void 0?e.connectFailure:t.failure,local:t.v?e.local:vL(e.local)};case"activate":return{...el(e,t.id),carryTo:null,screen:t.id?"chat":"home"};case"open-draft":{if(Bf(e))return e;const h=((n=UE(e,e.activeRepoId))==null?void 0:n.id)??null;return h?Wo({...el(e,h),carryTo:h,overlay:null,paletteReturn:null,focusChat:e.focusChat+1,screen:"chat"}):e}case"draft-carry":return e.draft?{...e,draft:{...e.draft,carry:t.v}}:e;case"draft-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 BE(e,t.id);case"close-archived":return e.archivedPage?VE(e):e;case"open-release-notes":return e.newProject?e:{...e,notesPage:!0,notesSeen:!0,overlay:null,paletteReturn:null,editor:null};case"close-release-notes":return e.notesPage?{...e,notesPage:!1}:e;case"sending":return Et(e,t.id,h=>({...h,sending:{message:t.message,at:Date.now()}}));case"sent-box":return Et(e,t.id,({notice:h,...m})=>({...tl(m,"walk"),draft:"",attachments:[],sent:(m.sent??0)+1}));case"answered":return Et(e,t.id,h=>({...h,sent:(h.sent??0)+1}));case"hold-send":{const h=e.local[t.id];if(!h)return e;const m=BP(e.clientId,++rL,t.id),g={...da,draft:t.text,attachments:h.attachments,outgoing:{frame:t.frame,log:t.log}},w=Et(e,t.id,({notice:y,...b})=>({...tl(b,"walk"),draft:"",attachments:[]}));return{...w,local:{...w.local,[m]:g},outbox:[...e.outbox,{id:m,log:t.log,kinds:h.attachments.map(y=>y.kind)}]}}case"sent-out":{const h=e.local[t.id],m=h==null?void 0:h.outgoing;if(!h||!m)return e;const{[t.id]:g,...w}=e.local,y={...e,local:w,outbox:e.outbox.filter(N=>N.id!==t.id)},b=h.draft,_=h.attachments.length?uk(h.attachments):void 0,T=N=>({...N,sent:(N.sent??0)+1});if(m.frame.t==="restore-worktree"||m.frame.t==="adopt-worktree")return Et(y,m.log,N=>({...T(N),sending:{message:{text:b,attachments:_},at:Date.now()}}));if(m.frame.t==="agent-answer")return Et(y,m.log,T);const E=m.frame.t==="chat"&&DE(e,m.log);return Et(y,m.log,N=>E?T(N):{...T(N),sending:{message:{text:b,attachments:_},at:Date.now()}})}case"unsend":{const h=e.local[t.id],m=(r=ls(t.id))==null?void 0:r.source;if(!(h!=null&&h.outgoing)||!m)return e;const{[t.id]:g,...w}=e.local,y={...e,local:w,outbox:e.outbox.filter(b=>b.id!==t.id)};return Et(Wo(y),m,b=>({...b,draft:b.draft||h.draft,attachments:[...h.attachments,...b.attachments],...t.notice?{notice:t.notice}:{}}))}case"drop-out":{if(!((o=e.local[t.id])!=null&&o.outgoing))return e;const{[t.id]:h,...m}=e.local;return{...e,local:m,outbox:e.outbox.filter(g=>g.id!==t.id)}}case"archive-worktrees":{const h=t.ids.filter(N=>!e.archiving.includes(N)&&dn(e,N));if(h.length===0)return e;const m={...e,archiving:[...e.archiving,...h]};if(!e.activeId||!h.includes(e.activeId))return m;const g=e.visible.filter(N=>N.id===e.activeId||!m.archiving.includes(N.id)),w=g.findIndex(N=>N.id===e.activeId),y=[N=>N.agent==="waiting",N=>Og(N.worktree)&&!!N.worktree.landed&&N.agent==="idle",N=>!!N.unseen,N=>N.agent==="working",N=>!wr(N.worktree)&&Is(N)==="running"],b=N=>{for(const j of y){const $=N(j);if($)return $.id}},_=b(N=>g.findLast((j,$)=>$<w&&N(j))),E=el(m,_??b(N=>g.find((j,$)=>$>w&&N(j)))??al(m,e.activeRepoId));return e.frame==="phone"?{...E,screen:"home"}:E}case"shipping":return e.shipping[t.id]||!(yo(e,t.id)||XE(e,t.id))?e:{...e,shipping:{...e.shipping,[t.id]:{op:t.op,sent:!0}}};case"activate-repo":{if(!Ei(e,t.id))return e;const h=e.newProject?{...e,newProject:null}:e;if(t.id===e.activeRepoId)return h;const m=al(h,t.id);return{...el(h,m),carryTo:null,activeRepoId:t.id,lent:null,pendingOpen:!1}}case"open-repo":return{...e,pendingOpen:!0};case"new-project":return{...e,newProject:t.v,overlay:null,paletteReturn:null,previewTheme:null,editor:null,notesPage:!1};case"new-project-set":{if(!e.newProject)return e;const h="name"in t.v||"parent"in t.v||"url"in t.v||"mode"in t.v,{error:m,...g}=e.newProject;return{...e,newProject:{...h?g:e.newProject,...t.v}}}case"close-new-project":return e.newProject&&e.repos.length>0?{...e,newProject:null,choosingFolder:!1}:e;case"auto-sent":return e.autoSend?{...e,autoSend:null}:e;case"watch-import":return{...e,activeImportId:t.id};case"close-editor":return{...e,editor:null};case"open-file":{const h=t.v,m=e.editor,g=m&&cc(m,h)?m:null,w=h.line&&PE(e,h.worktreeId,h.path,h.line);return{...e,editor:{worktreeId:h.worktreeId,path:h.path,...h.ref?{ref:h.ref}:{},...h.since?{since:h.since}:{},view:h.view??(g==null?void 0:g.view)??null,seq:h.seq,disk:(g==null?void 0:g.disk)??null,...w?{line:w}:{},focus:h.focus,conflict:(g==null?void 0:g.conflict)??null,blame:(g==null?void 0:g.blame)??null}}}case"open-loose":{const h=t.v,m={before:h.text,after:h.text,version:null,writable:h.source.kind!=="bytes"&&!h.tooLarge&&!h.binary,binary:h.binary,tooLarge:h.tooLarge};return{...e,editor:{worktreeId:h.worktreeId,path:h.name,view:wi(h.name),seq:h.seq,disk:m,focus:!0,conflict:null,blame:null,loose:{source:h.source}}}}case"editor-read":{const h=e.editor;if(!h||h.loose||!cc(h,t.file))return e;const m=t.disk;if(!m){const y=GE(e,h.worktreeId,t.error??`could not read ${h.path}`);return h.disk?y:{...y,editor:null}}const g=wi(h.path),w=m.before===""?h.view&&h.view!=="diff"?h.view:g:h.view??(m.before===m.after?g:"diff");return{...e,editor:{...h,view:w,disk:m}}}case"editor-conflict":{const h=e.editor;return h&&!h.loose&&cc(h,t.file)?{...e,editor:{...h,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 h=e.editor;if(!h||!cc(h,t.file))return e;const m=h.loose&&h.disk?{...h.disk,writable:!1}:h.disk;return{...e,editor:{...h,refused:t.message,disk:m}}}case"editor-blame":{const h=e.editor;return h&&!h.loose&&cc(h,t.file)?{...e,editor:{...h,blame:t.blame}}:e}case"notice":return Et(Wo(e),((i=ls(t.id))==null?void 0:i.source)??t.id,h=>({...h,notice:t.text}));case"link-refused":return Et(e,t.id,({refusedLink:h,...m})=>t.v?{...m,refusedLink:t.v}:m);case"card-draft":return Et(e,t.id,h=>({...h,card:t.card}));case"card-park":return Et(e,t.id,h=>({...h,cardParked:t.cardId}));case"card-unpark":return Et(e,t.id,({cardParked:h,...m})=>m);case"ask-revive":return Et(e,t.id,({askRevived:h,...m})=>t.askId?{...m,askRevived:t.askId}:m);case"opened-url":return e.openUrl?{...e,openUrl:null}:e;case"set-draft":return Et(e,t.id,h=>{const{notice:m,...g}=tl(h,"walk");return{...g,draft:t.text,...m!==void 0&&t.text===""?{notice:m}:{}}});case"move-box":return YE(e,t.from,t.to);case"walk":return Et(e,t.id,h=>({...tl(h,"walk"),draft:t.text,...t.walk?{mark:{by:"walk",at:t.walk.at,from:t.walk.from}}:{}}));case"reveal":return Et(Wo(e),t.id,h=>{var m;return{...h,mark:{by:"reveal",seq:t.seq,n:((m=h.mark)==null?void 0:m.by)==="reveal"?h.mark.n+1:1}}});case"attach":return Et(Wo(e),t.id,({notice:h,...m})=>({...m,attachments:[...m.attachments,...t.items]}));case"upload-progress":return(l=e.local[t.id])!=null&&l.attachments.some(h=>h.key===t.key&&ki(h))?Et(e,t.id,h=>({...h,attachments:h.attachments.map(m=>m.key===t.key?{...m,progress:t.progress}:m)})):e;case"attached":return(c=e.local[t.id])!=null&&c.attachments.some(h=>h.key===t.key)?Et(e,t.id,h=>({...h,attachments:h.attachments.map(m=>m.key===t.key?t.item:m)})):e;case"detach":{const h=Et(e,t.id,({notice:m,...g})=>({...g,attachments:g.attachments.filter(w=>w.key!==t.key)}));return(u=e.local[t.id])!=null&&u.outgoing?hi(h,{a:"unsend",id:t.id}):h}case"clear-attachments":return Et(e,t.id,({notice:h,...m})=>m.attachments.length?{...m,attachments:[]}:m);case"hmr":return Et(e,t.id,h=>({...h,turn:{...h.turn,hmr:!0}}));case"page":return Et(e,t.id,h=>({...h,page:{url:t.url??h.page.url,title:t.title??h.page.title}}));case"links":return Et(e,t.id,h=>{const m=zP(h.links??[],t.links);return m===h.links?h:{...h,links:m}});case"drag-files":return qP(e.dragFiles,t.v)?e:{...e,dragFiles:t.v};case"set-picking":return{...e,picking:t.v};case"preview-size":return e.previewSize===t.text?e:{...e,previewSize:t.text};case"open":return{...e,overlay:t.overlay,previewTheme:null,paletteReturn:qE(t.overlay)?e.paletteReturn:null};case"choosing-folder":return{...e,choosingFolder:t.v};case"close":return{...e,previewTheme:null,...lL(e,t.back)};case"toggle":return((p=e.overlay)==null?void 0:p.kind)===t.overlay.kind?hi(e,{a:"close"}):hi(e,{a:"open",overlay:t.overlay});case"palette-return":return{...e,paletteReturn:t.v};case"toggle-changes":return{...Jr(e,{changes:!e.layout.changes}),changesAuto:!1};case"focus-changes":return{...Jr(e,{changes:!0,changesTab:t.tab&&!Oo(e)?t.tab:e.layout.changesTab}),changesAuto:!1,focusChanges:e.focusChanges+1};case"changes-tab":return Jr(e,{changesTab:t.v});case"edit-commit":return{...Jr(e,{changes:!0}),changesAuto:!1,editCommit:e.editCommit+1};case"toggle-chat":return Io(e)?e:Jr(e,{chat:!e.layout.chat});case"focus-chat":return{...Wo(e),focusChat:e.focusChat+1};case"walked":return{...e,walked:e.walked+1};case"show-chat":return Wo(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"?Jr(e,{changesTab:"changes"}):e,screen:t.to,editor:null};case"frame":{if(e.frame===t.v)return e;const h={...e,frame:t.v};if(t.v!=="desk"||!h.activeRepoId)return h;const m=h.layouts[h.activeRepoId];return m?fk(h,m):h}case"touch":return e.touch===t.v?e:{...e,touch:t.v};case"reading":return e.reading===t.on?e:{...e,reading:t.on};case"rail-peek":return e.railPeek===t.on?e:{...e,railPeek:t.on};case"toggle-discovered":{const h=e.activeRepoId;return h?{...e,discoveredOpen:{...e.discoveredOpen,[h]:!e.discoveredOpen[h]}}:e}case"toggle-archived":{const h=e.activeRepoId;return h?{...e,archivedOpen:{...e.archivedOpen,[h]:!e.archivedOpen[h]}}:e}case"toggle-committed":{const h=e.activeRepoId;return h?{...e,committedShut:{...e.committedShut,[h]:!e.committedShut[h]}}:e}case"toggle-turn":{const h=e.activeRepoId;return h?{...e,turnOpen:{...e.turnOpen,[h]:!e.turnOpen[h]}}:e}case"tree-folder":{const h=e.treeOpen[t.worktreeId]??[];if(h.includes(t.path)===t.open)return e;const m=t.open?[...h,t.path]:h.filter(w=>w!==t.path),g={...e.treeOpen};return m.length>0?g[t.worktreeId]=m:delete g[t.worktreeId],{...e,treeOpen:g}}case"tree-reveal":{const h=e.treeOpen[t.worktreeId]??[],m=[];for(let y=t.path.indexOf("/");y!==-1;y=t.path.indexOf("/",y+1))m.push(t.path.slice(0,y));m.push(t.path);const g=m.filter(y=>!h.includes(y)),w=g.length?{...e.treeOpen,[t.worktreeId]:[...h,...g]}:e.treeOpen;return{...Jr(e,{changes:!0,changesTab:"files"}),changesAuto:!1,focusChanges:e.focusChanges+1,treeOpen:w,treeReveal:{worktreeId:t.worktreeId,path:t.path}}}case"files-asked":return Et(e,t.worktreeId,h=>({...h,filesFor:t.key}));case"toggle-zen":return Io(e)?e:{...e,zen:!e.zen};case"toggle-terminal":return Jr(e,{term:!e.layout.term});case"focus-terminal":return{...Jr(e,{term:!0}),focusTerm:e.focusTerm+1};case"toggle-design":return Io(e)?e:Jr(e,{design:!e.layout.design});case"term-stream":return Et({...Jr(e,{term:!0}),termTall:t.tall?e.termTall+1:e.termTall},t.id,h=>({...h,termStream:t.stream}));case"term-run":return Et({...Jr(e,{term:!0}),focusTerm:e.focusTerm+1,termRun:{id:t.id,command:t.command}},t.id,h=>({...h,termStream:Ao}));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 SL(e,t.msg)}}function B0(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 U0(e,t,n){const r=new Set(t.map(l=>l.id));n&&r.add(n);const o=([l,c])=>r.has(l)||!!c.draft||c.attachments.length>0,i=Object.entries(e);return i.every(o)?e:Object.fromEntries(i.filter(o))}function gL(e,t,n){var o;let r=e;for(const i of n){if(!((o=i.worktree)!=null&&o.landed)||t.some(p=>{var h;return p.id===i.id&&((h=p.worktree)==null?void 0:h.landed)}))continue;const l=r[i.id];if(!(l!=null&&l.git)||l.git.files.length===0)continue;r===e&&(r={...e});const{extras:c,...u}=l.git;r[i.id]={...l,git:{...u,files:[]}}}return r}function kL(e,t){const{version:n,files:r,ahead:o,behind:i,unpushed:l,head:c}=t,u={version:n,files:r,...o===void 0?{}:{ahead:o},...i===void 0?{}:{behind:i},...l===void 0?{}:{unpushed:l},...c===void 0?{}:{head:c}};if(t.extras)return{...u,extras:t.extras};const p=new Map(e==null?void 0:e.files.map(w=>[w.path,w])),h=r.map(w=>{const y=p.get(w.path);return y&&y.xy===w.xy&&y.add!==void 0?{...w,add:y.add,del:y.del}:w}),m=e!=null&&e.extras&&e.head===c?e.extras:void 0,g=m&&r.length===0&&m.turn?{committed:m.committed}:m;return{...u,files:h,...g?{extras:g}:{}}}function wL(e,t,n){if(!e||e.head!==t.head)return{};if(e.version===t.version)return n;const r=new Set([...e.files,...t.files].map(i=>i.path));let o=n;for(const i of Object.keys(n))r.has(i)&&(o===n&&(o={...n}),delete o[i]);return o}function yL(e){let t=e;for(const[n,r]of Object.entries(e))!r.git||r.git.version===0||(t===e&&(t={...e}),t[n]={...r,git:{...r.git,version:0}});return t}function vL(e){let t=e;for(const[n,r]of Object.entries(e)){if(r.filesFor===void 0)continue;t===e&&(t={...e});const{filesFor:o,...i}=r;t[n]=i}return t}function bL(e,t){let n=e;for(const[r,o]of Object.entries(t)){const i=n[r];i!=null&&i.draft||ls(r)||(n===e&&(n={...e}),n[r]={...i??da,draft:o})}return n}function xL(e,t){let n=e;for(const[r,o]of Object.entries(t)){const i=n[r];i!=null&&i.attachments.length||ls(r)||(n===e&&(n={...e}),n[r]={...i??da,attachments:Pm(o,[])})}return n}function EL(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 Wi(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 H0(e){const t=e.newProject;if((t==null?void 0:t.phase)!=="creating"||!t.repoId)return e;const n=UE(e,t.repoId);if(!n)return e;const r=Ro(e,pl);return!r.draft.trim()&&r.attachments.length===0?{...e,newProject:null}:{...YE(e,pl,n.id),newProject:null,autoSend:n.id}}function YE(e,t,n){const r=e.local[t];if(!r)return e;const o=Et(e,n,i=>({...i,draft:r.draft,attachments:r.attachments}));return Et(o,t,i=>({...i,draft:"",attachments:[]}))}function XE(e,t){return Object.values(e.trunks).some(n=>n.id===t)}function SL(e,t){var n,r,o,i,l,c,u,p,h,m,g,w,y,b,_,T;switch(t.t){case"hello":{const E=O=>!!O&&t.rows.some(B=>B.id===O),N=O=>!!O&&t.repos.some(B=>B.id===O),j=N(e.activeRepoId)?e.activeRepoId:N(e.storedRepo)?e.storedRepo:null,$=E(e.activeId)?e.activeId:E(e.storedActive)?e.storedActive:al(e,j,t.rows),P=t.rows.find(O=>O.id===$),R=!!j&&!!P&&_n(P)&&Uf(P,j,t.rows,e.lent),A={...e,heard:!0,repos:t.repos,rows:t.rows,activeId:$,lent:R?e.lent===$?e.lent:WE(P??null,j,t.rows):null,activeRepoId:R?j:(P==null?void 0:P.repoId)??j??((n=t.repos[0])==null?void 0:n.id)??null,trunks:t.trunks,archiving:e.archiving.length?[]:e.archiving,shipping:L0({},t.rows,t.trunks),local:yL(U0(xL(bL(e.local,t.drafts),t.attachments),t.rows,e.archivedPage)),lastActive:EL(e.lastActive,t.rows),treeOpen:B0(e.treeOpen,t.rows),discoveredOpen:Wi(e.discoveredOpen,t.repos),archivedOpen:Wi(e.archivedOpen,t.repos),committedShut:Wi(e.committedShut,t.repos),turnOpen:Wi(e.turnOpen,t.repos),refs:Wi(e.refs,t.repos),chats:Wi(e.chats,t.repos),archived:Wi(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,tailscale:t.tailscale,handed:t.machines,gitIdentity:t.gitIdentity,newProject:e.newProject??(t.repos.length===0&&t.rows.length===0&&t.pending.length===0?M0():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(O=>O.id===e.activeImportId)?e.activeImportId:null};return F0(A,t.knocks,t.letIn)}case"self":{const E=((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||E&&((i=t.self)==null?void 0:i.buildFailed)===void 0}}case"remote":return{...e,remote:t.remote,machine:t.machine};case"machines":return{...e,handed:t.machines};case"tailscale":return{...e,tailscale:t.tailscale};case"knocks":return F0(e,t.knocks,t.letIn);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:E,...N}=t;return{...e,agentConfigs:{...e.agentConfigs,[N.agent]:N}}}case"pending-repos":{const E=new Set(e.pending.map(R=>R.id)),N=t.pending.find(R=>!E.has(R.id)),j=N&&e.pendingOpen?N.id:e.activeImportId,$=t.pending.some(R=>R.id===j),P=t.pending.some(R=>R.id===j&&R.error);return{...e,pending:t.pending,activeImportId:$?j:null,pendingOpen:P?!1:e.pendingOpen,newProject:N&&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:(((c=e.chosenFolder)==null?void 0:c.seq)??0)+1,folder:t.folder}};case"refs":return{...e,refs:{...e.refs,[t.repoId]:{query:t.query,refs:t.refs}}};case"chat-hits":return{...e,chats:{...e.chats,[t.repoId]:{query:t.query,hits:t.hits,truncated:t.truncated,asks:t.asks}}};case"archived":return{...e,archived:{...e.archived,[t.repoId]:t.items}};case"draft":return t.clientId===e.clientId||ls(t.boxId)?e:Et(e,t.boxId,E=>{var N;return E.draft===t.text||((N=E.mark)==null?void 0:N.by)==="walk"?E:{...E,draft:t.text}});case"attachments":return t.clientId===e.clientId||ls(t.boxId)?e:Et(e,t.boxId,E=>({...E,attachments:Pm(t.items,E.attachments)}));case"repos":{const E=new Set(e.repos.map(A=>A.id)),N=t.repos.find(A=>!E.has(A.id));let j=e.activeRepoId,$=e.pendingOpen,P=e.newProject;N&&($||!j)?(j=N.id,$=!1,P&&P.phase!=="unmaking"&&(P={...P,phase:"creating",repoId:N.id})):t.repos.some(A=>A.id===j)||(j=((u=t.repos[0])==null?void 0:u.id)??null),(P==null?void 0:P.phase)==="unmaking"&&!t.repos.some(A=>A.id===(P==null?void 0:P.repoId))&&(P={...P,phase:"editing",repoId:null}),t.repos.length===0&&!P&&(P=M0());const R=e.gitIdentity||t.repos.some(A=>A.made&&!E.has(A.id));return j===e.activeRepoId?{...e,repos:t.repos,pendingOpen:$,newProject:P,gitIdentity:R}:H0({...e,repos:t.repos,pendingOpen:$,newProject:P,gitIdentity:R,activeRepoId:j,activeId:al(e,j),editor:null})}case"worktrees":{let E=e.activeId;(!E||!t.rows.some(A=>A.id===E))&&(E=al(e,e.activeRepoId,t.rows));const N=new Set(e.rows.map(A=>A.id)),j=A=>{var O;return((O=A.worktree)==null?void 0:O.kind)==="worktree"&&A.worktree.createdBy===e.clientId},$=t.rows.find(A=>!N.has(A.id)&&j(A)),P=!!E&&e.rows.some(A=>{var O;return A.id===E&&((O=A.worktree)==null?void 0:O.kind)==="spare"})&&t.rows.some(A=>A.id===E&&j(A));$&&e.rows.length>0&&!P&&(E=$.id);const R=e.archiving.filter(A=>t.rows.some(O=>O.id===A));return H0({...el({...e,rows:t.rows,trunks:t.trunks,archiving:R.length===e.archiving.length?e.archiving:R,shipping:L0(e.shipping,t.rows,t.trunks),local:U0(sL(gL(e.local,e.rows,t.rows),t.rows,e.activeId,E===($==null?void 0:$.id)?$.id:void 0),t.rows,e.archivedPage),treeOpen:B0(e.treeOpen,t.rows)},E),editor:E===e.activeId?e.editor:null,...$&&E===$.id?{carryTo:$.id}:{},...E===e.activeId?{activeRepoId:e.activeRepoId}:{},archivedPage:$?null:e.archivedPage,notesPage:$?!1:e.notesPage})}case"proc":{const E=e.rows.map(N=>N.id===t.worktreeId?{...N,procs:_L(N.procs,t.proc)}:N);return{...e,rows:E}}case"log":return Et(e,t.worktreeId,E=>({...E,log:vC(E.log.slice(-400),t.proc,t.line,t.retract)}));case"agent":{const E=t.event,N=t.worktreeId;let j=Et(e,N,$=>{const P=K0($.chat,E,t.seq),A=E.type==="tool-start"||E.type==="tool-end"||E.type==="turn-end"||E.type==="agent-error"||E.type==="tool-update"&&E.background?D0(P,$.running):$.running;let O=$.turn;E.type==="turn-start"?O={edits:!1,hmr:!1}:E.type==="tool-start"&&c1(E)&&(O={...O,edits:!0});const B=E.type==="session-info"&&E.model?E.model:$.model,H=E.type==="session-info"&&E.effort?E.effort:$.effort,Q=E.type==="usage"?{...W0(E),heard:Date.now()}:$.usage,re=e.rows.find(Z=>Z.id===N),J=(re==null?void 0:re.agent)==="working"||(re==null?void 0:re.agent)==="waiting",ie=$.sending?J?Dc($):{...$,sending:{at:$.sending.at}}:$,ve=E.type==="turn-end"||E.type==="agent-error",C=iL(E.type==="user-message"?ie:ve?Dc($):$,E);return{...E.type==="user-message"?tl(C,"reveal"):C,chat:P,...P!==$.chat?{chatAt:Date.now()}:{},...A!==$.running?{running:A}:{},turn:O,...B!==$.model?{model:B}:{},...H!==$.effort?{effort:H}:{},...Q!==$.usage?{usage:Q}:{}}});if(E.type==="agent-ask-end"&&!ek(E.outcome)&&((p=j.local[rl(E.id)])!=null&&p.attachments.length)&&(j=Et(j,rl(E.id),$=>({...$,attachments:[]}))),E.type==="user-message"){const $=SE(((h=e.local[N])==null?void 0:h.chat)??[]),P=$?rl($.id):null,R=P?((m=j.local[P])==null?void 0:m.attachments)??[]:[];P&&R.length&&(j=Et(j,P,A=>({...A,attachments:[]})),j=Et(j,N,A=>({...A,attachments:[...A.attachments,...R]})))}if(E.type==="turn-end"){const $=j.local[N].turn;$.edits&&!$.hmr&&(j={...j,reloadReq:{id:N,n:(((g=j.reloadReq)==null?void 0:g.n)??0)+1}})}return(E.type==="agent-question"||E.type==="agent-permission"||E.type==="handoff-proposed")&&N===e.activeId&&(j=Wo(j)),j}case"backfill":{let E=[],N;for(const{seq:$,event:P}of t.events)E=K0(E,P,$),P.type==="usage"&&(N=W0(P));const j=$=>t.events.some(({event:P})=>P.type==="user-message"&&P.text===$);return Et(e,t.worktreeId,({sending:$,...P})=>({...P,...$&&!($.message&&j($.message.text))?{sending:$}:{},chat:E,chatAt:Date.now(),running:D0(E,P.running),log:t.log??P.log,...N?{usage:N}:{}}))}case"git-status":{const E=(w=e.local[t.worktreeId])==null?void 0:w.git;if(t.version>0&&E&&t.version<E.version||t.version>0&&E&&t.version===E.version&&!t.extras)return e;let N=e.layout.changes,j=e.changesAuto;const $=((y=t.extras)==null?void 0:y.committed.length)??0;e.changesAuto&&t.worktreeId===e.activeId&&!N&&(t.files.length>0||$>0)&&(N=!0,j=!1);const P=t.worktreeId===e.archivedPage?Oo(e):null;P&&(t.files.length>0||$>0||P.landed)&&(N=!0);const R=Et(e,t.worktreeId,A=>{const O=kL(A.git,t);return{...A,git:O,changedRanges:wL(A.git,O,A.changedRanges)}});return{...Jr(R,{changes:N}),changesAuto:j}}case"changed-ranges":{const E=Et(e,t.worktreeId,j=>({...j,changedRanges:{...j.changedRanges,[t.path]:{ranges:t.ranges,offset:t.lineOffset}}})),N=E.editor;return!((b=N==null?void 0:N.line)!=null&&b.fiber)||N.worktreeId!==t.worktreeId||N.path!==t.path?E:{...E,editor:{...N,line:PE(E,N.worktreeId,N.path,N.line)}}}case"shipped":{const E=t.worktreeId,N={...e,shipping:P0(e.shipping,j=>{var $;return j===E&&(($=e.shipping[j])==null?void 0:$.sent)===!0}),openUrl:t.ok&&t.url?t.url:e.openUrl};return!t.ok&&!t.asked?E?z0(N,E,t.message):Dm(N,t.message):N}case"files":return Et(e,t.worktreeId,E=>({...E,files:t.paths,submodules:t.submodules,ignored:t.ignored}));case"search-results":return Et(e,t.worktreeId,E=>({...E,search:{query:t.query,hits:t.hits,truncated:t.truncated}}));case"element-sources":{if(e.editor&&e.editor.seq>t.seq)return e;const[E]=t.hits;if(!E)return Et(e,t.worktreeId,j=>({...j,notice:"nothing in the source matches this element"}));if(!t.sure)return hi(e,{a:"open",overlay:{kind:"element-sources",worktreeId:t.worktreeId,hits:t.hits}});const N=hi(e,{a:"open-file",v:{worktreeId:t.worktreeId,path:E.path,view:"file",line:{n:E.line},focus:!0,seq:t.seq}});return N.layout.changes?N:hi(N,{a:"toggle-changes"})}case"design-index":return Et(e,t.worktreeId,E=>({...E,design:t.index}));case"routes":return Et(e,t.worktreeId,E=>({...E,pages:{routes:t.routes,unseen:t.unseen}}));case"queue":return Et(e,t.worktreeId,E=>({...E,queue:t.items}));case"agent-commands":return Et(e,t.worktreeId,E=>({...E,commands:t.commands}));case"git-log":return Et(e,t.worktreeId,E=>({...E,commits:t.commits}));case"git-commit":return Et(e,t.worktreeId,E=>({...E,commitFiles:{...E.commitFiles,[t.sha]:t.files}}));case"error":{const E=t.worktreeId,N=e.newProject,j=(N==null?void 0:N.phase)==="creating"&&!N.repoId,$={...oL(e,E),archiving:E?e.archiving.includes(E)?e.archiving.filter(P=>P!==E):e.archiving:e.archiving.length?[]:e.archiving,shipping:P0(e.shipping,P=>!E||P===E),newProject:j?{...N,phase:"editing",error:t.message}:(N==null?void 0:N.phase)==="unmaking"?null:N,pendingOpen:j?!1:e.pendingOpen,updateCheck:!E&&e.updateCheck==="asking"?null:e.updateCheck};return j?$:E?z0($,E,t.message):Dm($,t.message)}case"unsent":{const E=((_=ls(t.boxId))==null?void 0:_.source)??t.boxId,N=!yo(e,E)&&!!e.activeRepoId&&((T=e.archived[e.activeRepoId])==null?void 0:T.some(j=>j.id===E));return Et(Wo(N?BE(e,E):e),E,({sending:j,...$})=>({...$,draft:$.draft||t.text,attachments:[...Pm(t.items,[]),...$.attachments],notice:t.message}))}default:return e}}function _L(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 W0(e){return{used:e.used,size:e.size,...e.cost!==void 0?{cost:e.cost}:{}}}function NL(e,t){const n=t.trim();return n!==""&&(e.trim()===n||e.trim().endsWith(`: ${n}`))}function K0(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",about:t.kind,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 c=t.messageId?{messageId:t.messageId}:{};if((r==null?void 0:r.kind)==="assistant")return[...e.slice(0,-1),{...r,text:r.text+t.text,...c}];const u=t.messageId===void 0?-1:TL(e,t.messageId);if(u!==-1){const p=e.slice(),h=p[u];return p[u]={...h,text:h.text+t.text},p}return[...e,{kind:"assistant",text:t.text,...o,...c}]}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 c=e.findLastIndex(h=>h.kind==="tool"&&h.id===t.toolId);if(c===-1)return e;const u=e.slice(),p=u[c];return u[c]={...p,...t.name?{name:t.name}:{},...t.title?{title:t.title}:{},...t.input!==void 0?{input:t.input}:{},...t.kind?{toolKind:t.kind}:{},...t.background?{background:!0}:{}},u}case"tool-delta":{const c=e.findLastIndex(h=>h.kind==="tool"&&h.id===t.toolId);if(c===-1)return e;const u=e.slice(),p=u[c];return u[c]={...p,output:(p.output??"")+t.text},u}case"tool-end":{const c=e.findLastIndex(h=>h.kind==="tool"&&h.id===t.toolId);if(c===-1)return e;const u=e.slice(),p=u[c];return u[c]={...p,output:t.output,isError:t.isError,...(l=t.images)!=null&&l.length?{images:t.images}:{},...t.detached?{detached:!0}:{},...t.fixable?{fixable:t.fixable}:{},done:!0},u}case"agent-error":{const c=Z0(e);return(r==null?void 0:r.kind)==="assistant"&&NL(t.message,r.text)?[...c.slice(0,-1),{kind:"error",text:t.message,...o}]:[...c,{kind:"error",text:t.message,...o}]}case"agent-blocked":return[...e,{kind:"blocked",tool:t.tool,path:t.path,reason:t.reason}];case"grafted":return[...e,{kind:"grafted",title:t.title,branch:t.branch}];case"landed":return[...e,{kind:"landed",text:t.message,archiveIds:t.archiveIds,...t.mark?{mark:t.mark}:{},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-go":{const c=Kp(e,t.id);if(c===-1)return e;const u=e.slice(),p=u[c];return u[c]={...p,state:"starting"},u}case"handoff":{const c=Kp(e,t.id);if(c===-1)return[...e,{kind:"handoff",id:t.id,repo:{id:t.repoId,name:t.repoName,path:""},message:"",title:t.title,by:"agent",mode:Vd,state:"continued",worktreeId:t.worktreeId,ts:t.ts}];const u=e.slice(),p=u[c];return u[c]={...p,state:"continued",worktreeId:t.worktreeId,title:t.title},u}case"handoff-declined":{const c=Kp(e,t.id);if(c===-1)return e;const u=e.slice(),p=u[c];return u[c]={...p,state:"declined",...t.reason?{reason:t.reason}:{}},u}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(c=>c.kind==="auth"&&!c.done)?e.map(c=>c.kind==="auth"&&!c.done?{...c,done:!0}:c):e;case"agent-question":return q0(e,t.toolId,{kind:"ask",id:t.id,ask:{kind:"question",message:t.message,questions:t.questions}});case"agent-permission":{const c={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}},u=e.findLast(p=>p.kind==="tool"&&p.id===t.toolId);return(u==null?void 0:u.kind)!=="tool"||t.plan||u.toolKind==="switch_mode"?q0(e,t.toolId,c):[...e,{...c,toolId:u.id}]}case"agent-ask-end":{const c=e.findLastIndex(h=>h.kind==="ask"&&h.id===t.id&&!h.outcome);if(c===-1)return e;const u=e[c];if(u.toolId&&jL(u,t.choiceId))return[...e.slice(0,c),...e.slice(c+1)];const p=e.slice();return p[c]={...p[c],outcome:t.outcome,...t.answers?{answers:t.answers}:{},...t.choiceId?{choiceId:t.choiceId}:{}},p}case"turn-end":{const c=Z0(e);return t.stopReason==="interrupted"?[...c,{kind:"stopped",...o}]:c}default:return e}}function Z0(e){const t=n=>n.kind==="tool"&&!n.done&&!n.background;return e.some(t)?e.map(n=>t(n)?{...n,done:!0}:n):e}function TL(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 Kp(e,t){return e.findLastIndex(n=>n.kind==="handoff"&&n.id===t&&(n.state==="proposed"||n.state==="starting"))}function jL(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 q0(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 CL(e){let t=e;const n=new Set;return{getState:()=>t,dispatch(r){const o=hi(t,r);if(o!==t){t=o;for(const i of n)i()}},subscribe(r){return n.add(r),()=>n.delete(r)}}}const QE=S.createContext(null),gk=S.createContext(null),JE=S.createContext(null);function AL({store:e,sock:t,files:n,children:r}){return d.jsx(QE.Provider,{value:e,children:d.jsx(gk.Provider,{value:t,children:d.jsx(JE.Provider,{value:n,children:r})})})}const eS=S.createContext(null),tS=S.createContext(null);function IL({machines:e,children:t}){const n=S.useSyncExternalStore(e.subscribe,e.active);return d.jsx(eS.Provider,{value:e,children:d.jsx(tS.Provider,{value:n,children:d.jsx(AL,{store:n.store,sock:n.sock,files:n.files,children:d.jsx(S.Fragment,{children:t},n.origin)})})})}function Jo(){const e=S.useContext(eS);if(!e)throw new Error("useMachines outside <MachinesProvider>");return e}function io(){const e=S.useContext(tS);if(!e)throw new Error("useMachine outside <MachinesProvider>");return e}function kk(){const e=Jo();return S.useSyncExternalStore(e.subscribe,e.list)}function Ya(e,t){return S.useSyncExternalStore(e.store.subscribe,()=>t(e.store.getState()))}const zm=(e,t)=>e.length===t.length&&e.every((n,r)=>n===t[r]);function nS(){const e=Jo(),t=io(),n=kk(),r=S.useMemo(()=>n.filter(c=>c!==t),[n,t]),o=S.useRef(null),i=S.useCallback(c=>{const u=r.map(p=>p.store.subscribe(c));return()=>{for(const p of u)p()}},[r]),l=S.useCallback(()=>{const c=r.map(m=>e.displayName(m.origin)),u=r.map(m=>m.store.getState().repos),p=o.current;if(p&&p.others===r&&zm(p.names,c)&&zm(p.repos,u))return p.value;const h=r.map((m,g)=>({origin:m.origin,name:c[g]??m.origin,repos:u[g]??[]}));return o.current={others:r,names:c,repos:u,value:h},h},[r,e]);return S.useSyncExternalStore(i,l)}function rS(){const e=io(),t=kk(),n=S.useMemo(()=>t.filter(l=>l!==e),[t,e]),r=S.useRef(null),o=S.useCallback(l=>{const c=n.map(u=>u.store.subscribe(l));return()=>{for(const u of c)u()}},[n]),i=S.useCallback(()=>{const l=n.map(p=>{const h=p.store.getState();return h.connected&&!h.incompatible?h.rows:G0}),c=r.current;if(c&&c.others===n&&zm(c.rows,l))return c.value;const u=n.map((p,h)=>({origin:p.origin,rows:(l[h]??G0).filter(_n)}));return r.current={others:n,rows:l,value:u},u},[n]);return S.useSyncExternalStore(o,i)}const G0=[];function rK(){return io().terminals}function Yn(){const e=S.useContext(QE);if(!e)throw new Error("useStore outside <StoreProvider>");return e}function M(e){const t=Yn();return S.useSyncExternalStore(t.subscribe,()=>e(t.getState()))}function wk(){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 ut(){return Yn().dispatch}function it(){return S.useContext(gk)}function Dr(){const e=S.useContext(gk);return(e==null?void 0:e.urls)??Jg(location.origin,"")}function yk(){return S.useContext(JE)}function $L(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 ko(e,t,n,r=RL){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(),p=>{l({key:e,value:p});try{r.set(e,typeof p=="boolean"?p?"1":"0":String(p))}catch{}}]}const RL={get:e=>localStorage.getItem(e),set:(e,t)=>localStorage.setItem(e,t)};function ll(e,t){return n=>{n.preventDefault(),document.body.classList.add("resizing");const r=n.currentTarget;r.classList.add("active");const o=l=>{const c=e(l,r);c!==null&&t(c)},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 oS(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 vk(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 bk=1500;function ra(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 OL(){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 ML(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 c=parseFloat(getComputedStyle(r).paddingTop)||0;r.scrollTop+=Math.min(l,Math.max(0,i.top-o.top-c))}),n=>{t.current=n}}const Wd=40,PL=1200,LL=150,DL=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]);function sS(e,t){const n=S.useRef(!0),r=S.useRef(Number.NEGATIVE_INFINITY),o=S.useRef(!1),[i,l]=S.useState(!1),[c,u]=S.useState(!1),[p,h]=S.useState(!1),[m,g]=S.useState(null),w=S.useCallback(j=>{n.current=j,e.current&&(e.current.style.overflowAnchor=j?"none":"")},[e]),y=S.useRef(null),b=S.useRef(null);ft([t],()=>{n.current||h(!0)});const _=S.useCallback(()=>{const j=e.current;j&&(w(j.scrollHeight-j.scrollTop-j.clientHeight<Wd),l(!n.current),u(j.scrollTop>=Wd),n.current&&h(!1))},[e,w]),T=S.useCallback(j=>{j!==0&&(g(j<0?"up":"down"),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>g(null),PL))},[]),E=S.useCallback(()=>{const j=e.current;j&&(j.scrollTop=j.scrollHeight,w(!0),l(!1),h(!1))},[e,w]),N=S.useCallback(()=>{const j=e.current;j&&(r.current=performance.now(),j.scrollTop=0)},[e]);return S.useEffect(()=>{const j=e.current;if(!j)return;w(n.current);const $=()=>o.current||performance.now()-r.current<LL,P=()=>{n.current&&!$()?u(j.scrollTop>=Wd):_()};j.addEventListener("scroll",P,{passive:!0});const R=()=>{r.current=performance.now()},A=C=>{R(),T(C.deltaY)},O=C=>{var Z;R(),y.current=((Z=C.touches[0])==null?void 0:Z.clientY)??null},B=C=>{var Y;R();const Z=(Y=C.touches[0])==null?void 0:Y.clientY;Z===void 0||y.current===null||(T(y.current-Z),y.current=Z)},H=()=>{o.current=!0},Q=()=>{o.current=!1},re=C=>{if(!DL.has(C.key))return;const Z=C.target;(Z===document.body||Z instanceof Node&&j.contains(Z))&&R()};j.addEventListener("wheel",A,{passive:!0}),j.addEventListener("touchstart",O,{passive:!0}),j.addEventListener("touchmove",B,{passive:!0}),j.addEventListener("pointerdown",H,{passive:!0}),window.addEventListener("pointerup",Q,{passive:!0}),window.addEventListener("pointercancel",Q,{passive:!0}),document.addEventListener("keydown",re);const J=()=>{j.scrollTop=j.scrollHeight},ie=new ResizeObserver(()=>{n.current&&J()});ie.observe(j);for(const C of j.children)ie.observe(C);const ve=new MutationObserver(C=>{for(const Z of C){for(const Y of Z.addedNodes)Y instanceof Element&&ie.observe(Y);for(const Y of Z.removedNodes)Y instanceof Element&&ie.unobserve(Y)}n.current&&J()});return ve.observe(j,{childList:!0}),()=>{j.removeEventListener("scroll",P),j.removeEventListener("wheel",A),j.removeEventListener("touchstart",O),j.removeEventListener("touchmove",B),j.removeEventListener("pointerdown",H),window.removeEventListener("pointerup",Q),window.removeEventListener("pointercancel",Q),document.removeEventListener("keydown",re),ve.disconnect(),ie.disconnect(),b.current&&clearTimeout(b.current)}},[e,_,T,w]),{offEnd:i,offStart:c,away:p,moving:m,pinned:()=>n.current,jump:E,start:N,read:_}}function V0(e,t,n){const r=document.createRange();return r.selectNodeContents(e),r.setEnd(t,n),r.toString().length}function Y0(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 iS(e,t){S.useLayoutEffect(()=>{const n=e.current;if(!n)return;const r=window.getSelection(),o=g=>!!g&&n.contains(g),i=r&&r.rangeCount>0&&o(r.anchorNode)?V0(n,r.anchorNode,r.anchorOffset):null,l=r&&r.rangeCount>0&&o(r.focusNode)?V0(n,r.focusNode,r.focusOffset):null,c=r&&(i!==null||l!==null)?[r.anchorNode,r.anchorOffset,r.focusNode,r.focusOffset]:null;if(n.innerHTML=t,!r||!c)return;const[u,p]=i===null?[c[0],c[1]]:Y0(n,i),[h,m]=l===null?[c[2],c[3]]:Y0(n,l);u&&h&&r.setBaseAndExtent(u,p,h,m)},[e,t])}function ft(e,t){const n=S.useRef(t);n.current=t,S.useEffect(()=>n.current(),e)}function aS(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:c}=i;const u=e.closest("[data-pinned]");if(u){const h=u.getBoundingClientRect(),m=u.offsetWidth/h.width;l=u.offsetLeft+(l-h.left)*m,c=u.offsetLeft+(c-h.left)*m}const p={left:Math.round(l),right:Math.round(c)};n(h=>h.left===p.left&&h.right===p.right?h:p)};r();const o=new ResizeObserver(r);return o.observe(e),window.addEventListener("resize",r),()=>{o.disconnect(),window.removeEventListener("resize",r)}},[e]),t}function X0(){const[e,t]=S.useState(null);return[t,aS(e)]}function oK(e){e.ctrlKey&&e.stopPropagation()}function zL(e,t){return e.defaultPrevented||e.ctrlKey?!1:t<1.01}function sK(e){S.useEffect(()=>{const t=e.current;if(!t)return;const n=r=>{var o;zL(r,((o=window.visualViewport)==null?void 0:o.scale)??1)&&r.preventDefault()};return t.addEventListener("wheel",n,{passive:!1}),()=>t.removeEventListener("wheel",n)},[e])}function FL(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 BL(e){S.useEffect(()=>{const t=window.visualViewport;if(!t)return;const n=()=>{var r;(r=e.current)==null||r.style.setProperty("--visible-height",`${Math.round(t.height)}px`)};return n(),t.addEventListener("resize",n),()=>t.removeEventListener("resize",n)},[e])}function UL(e){S.useEffect(()=>{const t=window.visualViewport;if(!t)return;const n=()=>{const r=e.current;if(r){if(t.scale<1.01){delete r.dataset.pinned;return}r.dataset.pinned="",r.style.setProperty("--pin-x",`${t.offsetLeft}px`),r.style.setProperty("--pin-y",`${t.offsetTop}px`),r.style.setProperty("--pin-scale",String(1/t.scale))}};return n(),t.addEventListener("resize",n),t.addEventListener("scroll",n),()=>{t.removeEventListener("resize",n),t.removeEventListener("scroll",n)}},[e])}function HL(e,t,n){const[r,o]=S.useState(),i=S.useRef(e);return i.current=e,S.useEffect(()=>{if(!n)return;let l=!0,c;const u=()=>void i.current().then(p=>{l&&(o(p),c=setTimeout(u,t))});return u(),()=>{l=!1,clearTimeout(c)}},[t,n]),r}const _l=()=>M(e=>e.activeId),lS=()=>oS(!M(e=>e.connected),900),$s=()=>M(e=>dn(e,e.activeId)),xk=()=>M(e=>yo(e,e.activeId)),cS=()=>M(e=>e.rows),Ek=()=>M(e=>e.visible),WL=()=>M(e=>e.visibleDiscovered),KL=()=>M(e=>e.activeRepoId?e.discoveredOpen[e.activeRepoId]??!1:!1),Q0=[],ZL=()=>M(e=>e.activeRepoId?e.archived[e.activeRepoId]??Q0:Q0),qL=()=>M(e=>e.activeRepoId?e.archivedOpen[e.activeRepoId]??!1:!1),GL=()=>M(e=>!(e.activeRepoId&&e.committedShut[e.activeRepoId])),VL=()=>M(e=>!!(e.activeRepoId&&e.turnOpen[e.activeRepoId])),fa=()=>M(Oo),Sk=()=>M(ZE),YL=()=>M(e=>Ei(e,e.activeRepoId)),Nl=()=>M(e=>Ei(e,hk(e))),uS=e=>M(t=>Ro(t,e)),Rt=(e,t)=>M(n=>Ro(n,e)[t]),XL=()=>M(e=>e.overlay),Hf=()=>M(VP),dS=()=>M(zE),nu=()=>M(YP),ru=()=>M(Io),QL=()=>M(e=>e.newProject),Si=()=>M(e=>e.touch),JL=()=>M(e=>e.draft),_k=()=>M(kc),e4=()=>M(e=>{const t=yo(e,e.activeId),n=t?e.repos.find(r=>r.id===t.repoId):null;return af(n)?n:null});function t4(e){return e.image?{kind:"image",blob:e.image,sig:`image:${e.image.type}:${e.image.size}`}:e.text&&sE(e.text)?{kind:"text",text:e.text,sig:`text:${e.text}`}:null}function n4(){try{return localStorage.getItem(qe.clipboardOffer)==="1"}catch{return!1}}let As={access:"none",on:typeof localStorage<"u"&&n4(),offer:null},Fm="";const Bm=new Set;function Wf(e){As={...As,...e};for(const t of Bm)t()}async function r4(){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 t4({image:e,text:t})}async function Kf({taken:e=!1,asking:t=!1}={}){if(!As.on||!(As.access==="granted"||t&&As.access==="prompt"))return;let n;try{n=await r4()}catch{return}e&&(Fm=(n==null?void 0:n.sig)??""),Wf({offer:n&&n.sig!==Fm?n:null})}const o4=()=>void Kf();let J0=!1;function s4(){var e,t;J0||(J0=!0,!(!((e=navigator.clipboard)!=null&&e.read)||!((t=navigator.permissions)!=null&&t.query))&&navigator.permissions.query({name:"clipboard-read"}).then(n=>{const r=()=>{Wf({access:n.state,...n.state==="denied"?{offer:null}:{}})};n.onchange=r,r(),window.addEventListener("focus",o4),document.hasFocus()&&Kf()},()=>{}))}function i4(e){return Bm.add(e),s4(),()=>{Bm.delete(e)}}const a4=()=>As;function l4(e){try{localStorage.setItem(qe.clipboardOffer,e?"1":"0")}catch{}Wf({on:e,offer:null}),e&&Kf({asking:!0})}function fS(){As.offer&&(Fm=As.offer.sig),Wf({offer:null})}const c4=()=>void Kf({taken:!0});function u4(){return S.useSyncExternalStore(i4,()=>As.offer)}const hS="application/x-toyon-source";function iK(e){const t=e.endColumn===1&&e.endLineNumber>e.startLineNumber?e.endLineNumber-1:e.endLineNumber;return{startLine:e.startLineNumber,endLine:t}}function d4(e,t){e.setData(hS,JSON.stringify(t))}const eb=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1;function f4(e,t){const n=e.getData(hS);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!eb(o)||!eb(i)||i<o?null:{path:r.path,startLine:o,endLine:i,...typeof l=="string"?{ref:l}:{}}}const pS=e=>({left:e.x,top:e.y,right:e.x,bottom:e.y});function h4(e,t){return t.matchWidth===void 0?void 0:Math.max(0,e.right-e.left+t.matchWidth)}const p4=new Set(["top","bottom"]),Zp={top:"bottom",bottom:"top",left:"right",right:"left"};function qp(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 tb(e,t,n,r,o){return n==="top"||n==="left"?e>=o:e+t<=r-o}function Gp(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 nb(e,t,n,r,o){return n==="start"?e+t<=r-o:e>=o}const rb=(e,t,n,r)=>n||!r?e:t,ob=(e,t,n,r)=>Math.max(r,Math.min(e,n-r-t));function m4(e,t,n,r){const{offset:o=0,alignOffset:i=0,cover:l=!1,flip:c="none",margin:u=8}=r,p=p4.has(r.side),h=p?{a:{start:e.top,end:e.bottom},size:t.h,limit:n.h}:{a:{start:e.left,end:e.right},size:t.w,limit:n.w},m=p?{a:{start:e.left,end:e.right},size:t.w,limit:n.w}:{a:{start:e.top,end:e.bottom},size:t.h,limit:n.h};let g=r.side;if(c==="side"||c==="both"){const _=qp(h.a,h.size,g,o,l),T=qp(h.a,h.size,Zp[g],o,l);g=rb(g,Zp[g],tb(_,h.size,g,h.limit,u),tb(T,h.size,Zp[g],h.limit,u))}let w=r.align??"center";if((c==="align"||c==="both")&&w!=="center"){const _=w==="start"?"end":"start",T=Gp(m.a,m.size,w,i),E=Gp(m.a,m.size,_,i);w=rb(w,_,nb(T,m.size,w,m.limit,u),nb(E,m.size,_,m.limit,u))}const y=ob(qp(h.a,h.size,g,o,l),h.size,h.limit,u),b=ob(Gp(m.a,m.size,w,i),m.size,m.limit,u);return p?{x:b,y,side:g,align:w}:{x:y,y:b,side:g,align:w}}function g4(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 c=0;c<r&&((i=e[o])!=null&&i.disabled);c++)o=(o+n+r)%r;return(l=e[o])!=null&&l.disabled?-1:o}const mS={sep:!0},cs=e=>!("sep"in e);function Zf(e){const t=[];for(const n of e)(cs(n)||t.length>0&&cs(t[t.length-1]))&&t.push(n);for(;t.length>0&&!cs(t[t.length-1]);)t.pop();return t}const zn=e=>Zf(e.flatMap((t,n)=>n?[mS,...t]:t));let Za=null,k4=0;const Um=new Set,sb=()=>{for(const e of Um)e()},ro={get:()=>Za,subscribe(e){return Um.add(e),()=>{Um.delete(e)}},open(e){const t=Zf(e.items);if(t.length===0)return ro.close();Za={...e,items:t,id:++k4},sb()},close(){Za&&(Za=null,sb())},toggle(e){Za&&Za.target===e.target?ro.close():ro.open(e)}};function Nk(){return S.useSyncExternalStore(ro.subscribe,ro.get)}function gS(e){const t=e.nativeEvent;return t&&"pointerType"in t?t.pointerType==="":e.clientX===0&&e.clientY===0}function w4(e,t){return gS(e)?{anchor:(t.querySelector('[data-state~="cursor"]')??t).getBoundingClientRect()}:{at:{x:e.clientX,y:e.clientY}}}function y4(e){const t=e.anchor;return t?{rect:t,placement:{side:"bottom",align:e.align==="right"?"end":"start",offset:4,margin:4,...e.toggles?{flip:"side"}:{}}}:{rect:pS(e.at??{x:0,y:0}),placement:{side:"bottom",align:"start",margin:4}}}function vn(e){return S.useMemo(()=>({contextMenu(t,n){return{onContextMenu:r=>{const o=Zf(t(gS(r)?"keyboard":"pointer",r.target));if(o.length===0)return;r.preventDefault(),r.stopPropagation();const i=r.currentTarget;ro.open({items:o,owner:e,key:n,target:i,...w4(r,i)})}}},dropdown(t,n="left",r){return{"aria-haspopup":"menu",onClick:o=>{o.stopPropagation();const i=o.currentTarget;ro.toggle({items:t(),owner:e,key:r,target:i,toggles:!0,anchor:i.getBoundingClientRect(),align:n})}}},openUnder(t,n,r){ro.open({items:n(),owner:e,key:r,target:t,toggles:!0,anchor:t.getBoundingClientRect(),align:"left"})}}),[e])}const kS=e=>({id:"open-out",label:ak()?"open in the browser":"open in a new tab",onClick:()=>window.open(e,"_blank")}),en=e=>{var t;return void((t=navigator.clipboard)==null?void 0:t.writeText(e).catch(()=>{}))};function wS(e,t){const n=navigator.clipboard;if(n){if(typeof ClipboardItem>"u"||!n.write){e==="text/plain"&&t.then(r=>r.text()).then(en,()=>{});return}n.write([new ClipboardItem({[e]:t})]).catch(()=>{})}}const yS=e=>wS("text/plain",fetch(e).then(t=>t.blob())),v4=e=>wS("image/png",b4(e));async function b4(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()}}function vS(e){return Dg(e)}function Xo(e){return(e==null?void 0:e.urls.host)??(typeof location=="object"?location.hostname:"127.0.0.1")}function Qo(e,t,n="reveal in Finder"){return!e||!vS(t)?[]:[{id:"reveal",label:n,onClick:e}]}function x4(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 qf(e,t,{sock:n,dispatch:r}){var l,c;if(!n)return;const o=t.local[e]??da,i=x4((l=o.git)==null?void 0:l.head,((c=o.git)==null?void 0:c.files)??[]);o.filesFor!==i&&(r({a:"files-asked",worktreeId:e,key:i}),n.send({t:"list-files",worktreeId:e}))}const E4=["diff","file","preview"],bS=(e,t)=>E4.filter(n=>!(n==="preview"&&!zf(e))&&!(n==="diff"&&t));let S4=0;const Go=()=>++S4;function er({dispatch:e},{focus:t=!0,...n}){e({a:"open-file",v:{...n,focus:t,seq:Go()}})}const Hm=new Map;function xS(e,t,n=""){const{sock:r}=e;if(!r)return Promise.resolve("not connected to the daemon");const o=Go();return new Promise(i=>{Hm.set(o,l=>{l.ok?(er(e,{...t,view:wi(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 _4(e){const t=Hm.get(e.seq);return t?(Hm.delete(e.seq),t(e),!0):!1}function N4({dispatch:e},t){e({a:"tree-reveal",...t})}function js(e,t,{discard:n=!1,ref:r,since:o,showing:i,noDiff:l=!1,kept:c=!1,select:u},p){const{sock:h,dispatch:m}=p,g=bS(t,l).filter(E=>E!==i).map(E=>({id:`view:${E}`,label:`view ${E}`,onClick:()=>i?m({a:"editor-view",v:E}):er(p,{worktreeId:e.id,path:t,view:E,ref:r,since:o})})),w=`${e.dir}/${t}`,y=c?[]:Qo(()=>h==null?void 0:h.send({t:"reveal",worktreeId:e.id,path:t}),Xo(h));return zn([g,[{id:"copy-path",label:"copy path",onClick:()=>en(w)}],y,u?[{id:"select",label:"select…",onClick:()=>u(t)}]:[],n?[{id:"discard",label:"discard changes…",danger:!0,onClick:()=>{window.confirm(ES([t]))&&(h==null||h.send({t:"discard-files",worktreeId:e.id,paths:[t]}))}}]:[]])}function ES(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 wo=(e,t,n)=>e.dispatch({a:"notice",id:t,text:n});function Gf(e,t,n){var o;const r=AC(((o=e.getState().local[t])==null?void 0:o.attachments)??[],n);return r===0&&wo(e,t,Mg(n)),r}const T4=1e3,j4=1e4,SS=new WeakMap;function C4(e,t){SS.set(e,t)}async function _S(e,t,n,r){var y,b;const{local:o,...i}=n;e.dispatch({a:"attach",id:t,items:[{...n,upload:"",uploading:!0}]});const l=()=>{var _;return(_=Object.entries(e.getState().local).find(([,T])=>T.attachments.some(E=>E.key===n.key)))==null?void 0:_[0]},c=SS.get(e);let u=-1;const p=_=>{const T=Math.min(99,Math.floor(_*100)),E=l();T===u||E===void 0||(u=T,e.dispatch({a:"upload-progress",id:E,key:n.key,progress:T}))},h=()=>(u=-1,c?QM(c,n.kind,r,p):Promise.resolve(null));let m=await h();const g=m===null;g&&wo(e,l()??t,`${n.name}: Toyon is not answering; it attaches once it is back`);for(let _=T4;m===null&&l()!==void 0;_=Math.min(_*2,j4))await new Promise(T=>setTimeout(T,_)),l()!==void 0&&(m=await h());const w=l();if(!(m===null||w===void 0))if(typeof m=="string")e.dispatch({a:"detach",id:w,key:n.key}),wo(e,w,`${n.name}: ${m}`);else{const _=i.kind==="file"?{...i,...m}:{...i,upload:m.upload,bytes:m.bytes};e.dispatch({a:"attached",id:w,key:n.key,item:_});const T=(b=e.getState().local[((y=ls(w))==null?void 0:y.source)??w])==null?void 0:b.notice;g&&(T!=null&&T.startsWith(`${n.name}: Toyon is not answering`))&&wo(e,w,"")}o&&URL.revokeObjectURL(o)}function Tk(e,t,n){if(!t||n.length===0)return;const r=Gf(e,t,"file");if(r!==0){for(const o of n.slice(0,r)){const i=o.name||"file";if(o.size>E0){wo(e,t,`${i}: larger than ${Lg(E0)}`);continue}const l={kind:"file",key:crypto.randomUUID(),upload:"",name:i,bytes:o.size,text:!1};_S(e,t,l,o)}n.length>r&&wo(e,t,`kept ${r} of ${n.length}: ${Mg("file")}`)}}function jk(e,t,n,r={}){if(!t)return;const o=G2(r.source?n.replace(/\r?\n$/,""):n);if(o.length>F2)return r.source?wo(e,t,"that paste is too large; save it in the worktree and reference it with @path"):Tk(e,t,[new File([o],B2,{type:"text/plain"})]);Gf(e,t,"paste")!==0&&e.dispatch({a:"attach",id:t,items:[{kind:"paste",key:crypto.randomUUID(),text:o,...r,...Vg(o)}]})}function NS(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 ib(e,t){var i;const n=e.getState(),r=dn(n,n.activeId),o=Sl(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(u=>{var w;if(u.kind!=="paste")return!1;if(!("source"in t))return u.name===t.name&&u.text===t.text;const{path:p,startLine:h,endLine:m,ref:g}=t.source;return((w=u.source)==null?void 0:w.path)===p&&u.source.startLine===h&&u.source.endLine===m&&u.source.ref===g})||jk(e,o,t.text,l)}e.dispatch(t?{a:"focus-chat"}:FE(n))}function Vf(e,t){return t!==e.activeId?null:Sl(dn(e,t))}const Ck=(e,t)=>`@${e}${t?"/":""}`;function Ak(e,t,n){var c;const r=e.getState(),o=Vf(r,t);if(!o)return;const i=((c=r.local[o])==null?void 0:c.draft)??"",l=i===""||/\s$/.test(i)?"":" ";e.dispatch({a:"set-draft",id:o,text:`${i}${l}${n}`}),e.dispatch({a:"focus-chat"})}function TS(e,t,n,r){Ak(e,t,`${Ck(n,r)} `)}function A4(e,t,n){n.length!==0&&Ak(e,t,`${n.map(r=>Ck(r,!1)).join(" ")} `)}function ab(e,t,n){Ak(e,t,n)}function I4(e,t){return dn(e,t)?t:null}function $4(e,t){var r;const n=(r=dn(e,t))==null?void 0:r.worktree;return n?[n.path]:[]}function lb(e,t){if(!e)return e;const n=t.find(r=>e.startsWith(`${r}/`));return n?e.slice(n.length+1):e}function R4(e,t,n){var g;e.dispatch({a:"set-picking",v:!1});const r=e.getState(),o=I4(r,t);if(!o)return;const{classes:i,route:l,element:c,...u}=n,p=$4(r,t),h={...u,file:lb(u.file,p),callFile:lb(u.callFile,p)};!(((g=r.local[o])==null?void 0:g.attachments)??[]).some(w=>w.kind==="pick"&&w.selector===h.selector)&&Gf(e,o,"pick")>0&&e.dispatch({a:"attach",id:o,items:[{kind:"pick",key:crypto.randomUUID(),...h}]}),e.dispatch({a:"focus-chat"})}function O4(e,t=[],n=[]){const r={path:"",name:"",kind:"folder",children:[],ignored:!1},o=new Map([["",r]]),i=u=>{const p=o.get(u);if(p)return p;const h=u.lastIndexOf("/"),m={path:u,name:u.slice(h+1),kind:"folder",children:[],ignored:!1};return i(h===-1?"":u.slice(0,h)).children.push(m),o.set(u,m),m},l=(u,p,h=!1)=>{const m=u.lastIndexOf("/");i(m===-1?"":u.slice(0,m)).children.push({path:u,name:u.slice(m+1),kind:p,children:[],ignored:h})};for(const u of e)l(u,"file");for(const u of t)l(u,"submodule");for(const u of n)u.endsWith("/")?l(u.slice(0,-1),"ignored",!0):l(u,"file",!0);const c=u=>{const p=h=>h.kind==="file"?1:0;u.children.sort((h,m)=>p(h)-p(m)||IE(h.name,m.name));for(const h of u.children)h.kind==="folder"&&c(h)};return c(r),r.children}function M4(e,t){const n=[],r=(o,i)=>{for(const l of o){const c=l.kind==="folder"&&t(l.path);n.push({path:l.path,name:l.name,depth:i,kind:l.kind,open:c,ignored:l.ignored}),c&&r(l.children,i+1)}};return r(e,0),n}const jS=e=>{const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)};function P4(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 L4(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 sf(o))n.add(i)}return{files:t,folders:n}}function Ik(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 D4(e){const t=e?Ik(e.chat):null;return(t==null?void 0:t.kind)!=="ask"||t.ask.kind!=="question"||(e==null?void 0:e.cardParked)===t.id?null:rl(t.id)}function cb(e){return e.kind==="ask"?gP(e):`Continue in ${e.repo.name}?`}function z4(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 F4(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,c=i.toLowerCase(),u=t.filter(m=>m.name.toLowerCase()===c),p=u.length>0?u:t.filter(m=>m.name.toLowerCase().startsWith(c));if(p.length===0)return{error:`no open project named "${i}"`};if(p.length>1)return{error:`"${i}" names more than one project`};const h=p[0];return h.id===n?{error:`this worktree is already in ${h.name}`}:{repo:h,...l?{text:l}:{}}}const CS=new Set(L2),B4=/^image\.[a-z0-9]+$/i,U4=e=>B4.test(e.name),H4=(e,t)=>e===t||e.name===t.name&&e.size===t.size&&e.type===t.type&&e.lastModified===t.lastModified;function W4(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=>H4(l,i))||n.push(i);const r=n.filter(i=>!U4(i));if(r.length>0)return r;const o=n.find(i=>CS.has(i.type))??n[0];return o?[o]:[]}function K4(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 Z4(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 q4(e){try{return await createImageBitmap(e)}catch{throw new Error(`${e.name||"image"}: not a readable image`)}}function ub(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 G4(e){const t=await q4(e);try{const n=Math.max(t.width,t.height);let r=e,o=e.type,i=t.width,l=t.height;if(!CS.has(o)||n>x0||e.size>Wp){const c=o==="image/jpeg"?"image/jpeg":"image/png";let u=Math.min(1,x0/n);for(r=await ub(t,u,c);r.size>Wp&&u>.1;)u*=.7,r=await ub(t,u,c);if(r.size>Wp)throw new Error(`${e.name||"image"}: too large even after downscaling`);o=c,i=Math.max(1,Math.round(t.width*u)),l=Math.max(1,Math.round(t.height*u))}return{blob:r,name:e.name||`pasted.${o==="image/jpeg"?"jpg":"png"}`,mimeType:o,width:i,height:l}}finally{t.close()}}const jc={el:null},V4=80,Y4=2e3;let us=null,Wm;const AS=(e,t)=>{clearTimeout(Wm),Wm=setTimeout(()=>Rk(e),t)};function $k(e,t){us??(us={refused:!1}),e.dispatch({a:"drag-files",v:us.refused?null:t}),AS(e,Y4)}function IS(e){us&&AS(e,V4)}function Rk(e){clearTimeout(Wm),us=null,e.dispatch({a:"drag-files",v:null})}function X4(e){us&&(us.refused=!0,e.dispatch({a:"drag-files",v:null}))}const $S="application/x-toyon-path";let Qi=null;function Q4(e){Qi=e}function RS(e){Qi=null,us&&Rk(e)}const db=e=>Qi!==null&&Array.from(e.dataTransfer.types).includes($S);function J4(e){return{onDragOver:t=>{if(!db(t)||!Qi)return;t.preventDefault();const n=Vf(e.getState(),Qi.worktreeId)!==null;t.dataTransfer.dropEffect=n?"copy":"none",n&&$k(e,{at:"chat"})},onDrop:t=>{if(!db(t)||!Qi)return;t.preventDefault();const{worktreeId:n,path:r,folder:o}=Qi;RS(e),TS(e,n,r,o)}}}let eD=0;function tD(e){const{blob:t,...n}=e;return{kind:"image",key:`img${++eD}`,...n,upload:"",bytes:t.size,local:URL.createObjectURL(t)}}async function Yf(e,t,n){var l;if(!t||n.length===0)return;const r=Gf(e,t,"image");if(r===0)return;const o=await Promise.allSettled(n.slice(0,r).map(G4));for(const c of o)c.status==="fulfilled"&&_S(e,t,tD(c.value),c.value.blob);const i=o.find(c=>c.status==="rejected");i?wo(e,t,String(((l=i.reason)==null?void 0:l.message)??i.reason)):n.length>r&&wo(e,t,`kept ${r} of ${n.length}: ${Mg("image")}`)}function nD(e,t,n){n.kind==="image"?Yf(e,t,[new File([n.blob],"image.png",{type:n.blob.type})]):jk(e,t,n.text),fS()}function OS(e,t,n){const r=o=>o.type.startsWith("image/");Yf(e,t,n.filter(r)),Tk(e,t,n.filter(o=>!r(o)))}function MS(e,t,{images:n=!1}={}){const r=document.createElement("input");r.type="file",r.multiple=!0,n&&(r.accept="image/*"),r.onchange=()=>OS(e,t,Array.from(r.files??[])),r.click()}function ou(e){const t=e.getState();if(t.newProject)return pl;const n=dn(t,t.activeId);return D4(n?t.local[n.worktree.id]:void 0)??Sl(n)}function PS(e,t,n=ou(e)){OS(e,n,t.filter(o=>!o.folder).map(o=>o.file));const r=t.find(o=>o.folder);n&&r&&wo(e,n,`${r.file.name}: a folder cannot be attached; drop its files`)}const Km=Promise.resolve(null);function rD(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 c=((n=i.getAsFileSystemHandle)==null?void 0:n.call(i).then(u=>(u==null?void 0:u.kind)==="file"?u:null,()=>null))??Km;t.push({file:l,handle:c,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:Km});return t}const oD=e=>e.map(t=>({file:t,handle:Km}));async function LS(e){const t=nf*4;if(e.size>t)return{text:"",tooLarge:!0};const n=await Z4(e,t);return n===null?null:n.length>nf?{text:"",tooLarge:!0}:{text:n,tooLarge:!1}}async function sD(e,t){const n=ou(e),r=e.getState().activeId,o=h=>n&&wo(e,n,h),i=t.filter(h=>h.file.type.startsWith("image/")).map(h=>h.file);i.length&&Yf(e,n,i);const l=t.filter(h=>!h.file.type.startsWith("image/")),c=l[0];if(!c||!r)return;const u=await LS(c.file);if(!u)return void o(`${c.file.name}: not a text file`);const p=await c.handle;e.dispatch({a:"open-loose",v:{worktreeId:r,name:c.file.name,...u,binary:!1,source:p?{kind:"handle",handle:p}:{kind:"bytes"},seq:Go()}}),l.length>1&&o(`opened ${c.file.name}; one file opens at a time`)}async function iD(e,t,n,r){const o=Vf(e.getState(),n.worktreeId)??ou(e),i=c=>o&&wo(e,o,c),l={sock:t,dispatch:c=>e.dispatch(c)};for(const{file:c}of r){const u=await LS(c);if(!u){i(`${c.name}: not a text file`);continue}if(u.tooLarge){i(`${c.name}: too large to add here`);continue}const p=n.dir?`${n.dir}/${c.name}`:c.name,h=await xS(l,{worktreeId:n.worktreeId,path:p},u.text);h&&i(`${c.name}: ${h}`)}}function aD(e){const t=ou(e);t&&wo(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 DS(e,t,n,r){const o=(us==null?void 0:us.refused)??!1;Rk(e),!(o||r.length===0)&&(n?n.at==="chat"||n.at==="centre"&&e.getState().newProject?PS(e,r):n.at==="centre"?sD(e,r):n.at==="rail"?lD(e,n,r):iD(e,t,n,r):aD(e))}function lD(e,t,n){const r=dn(e.getState(),t.worktreeId);r&&(e.dispatch(wr(r.worktree)?{a:"open-draft"}:{a:"activate",id:r.worktree.id}),PS(e,n,Sl(r)))}const Zm=e=>!!e&&Array.from(e.types).includes("Files");function fb(e,t){var c,u;const n=t instanceof Element?t:t instanceof Node?t.parentElement:null;if(!n)return null;if((c=jc.el)!=null&&c.contains(n))return ou(e)?{at:"chat"}:null;const r=(u=n.closest(".rail [data-wt]"))==null?void 0:u.dataset.wt;if(r)return dn(e.getState(),r)?{at:"rail",worktreeId:r}:null;const o=n.closest(".tree"),i=o==null?void 0:o.dataset.worktree;if(o&&i){const p=n.closest("[data-path]"),h=p==null?void 0:p.dataset.kind;if(h==="submodule")return null;const m=(p==null?void 0:p.dataset.path)??"";return{at:"tree",worktreeId:i,dir:h==="file"?jS(m):m}}if(!n.closest(".center-root")||n.closest('[data-pane="terminal"], [data-pane="design"]'))return null;const l=e.getState();return l.activeId||l.newProject?{at:"centre"}:null}function cD(){const e=Yn(),t=it();S.useEffect(()=>{const n=l=>{l.defaultPrevented||!Zm(l.dataTransfer)||(l.preventDefault(),$k(e,fb(e,l.target)),l.dataTransfer&&(l.dataTransfer.dropEffect=e.getState().dragFiles?"copy":"none"))},r=l=>{l.defaultPrevented||!Zm(l.dataTransfer)||(l.preventDefault(),DS(e,t,fb(e,l.target),rD(l.dataTransfer)))},o=()=>IS(e),i=l=>{l.key==="Escape"&&X4(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 zS(e,t){const n=Yn(),r=S.useRef(!1);return{onPaste:c=>{c4();const u=W4(c.clipboardData);if(u.length>0)return c.preventDefault(),void Yf(n,e,u);const p=K4(c.clipboardData);if(p.length>0)return c.preventDefault(),Tk(n,e,p);if(r.current)return;const h=c.clipboardData.getData("text/plain"),m=h.trim()?f4(c.clipboardData,t):null;!(m&&h.includes(`
|
|
103
|
+
`))&&!sE(h)||(c.preventDefault(),jk(n,e,h,m?{source:m}:{}))},onPasteKey:c=>{r.current=(c.metaKey||c.ctrlKey)&&c.shiftKey&&c.key.toLowerCase()==="v"},onPasteKeyUp:()=>{r.current=!1}}}const FS=(e,t)=>{const n=e.indexOf("#"),[r,o]=n===-1?[e,""]:[e.slice(0,n),e.slice(n)];return`${r}${r.includes("?")?"&":"?"}${JC}=${encodeURIComponent(t)}${o}`},qm=(e,t)=>!e.serving&&t!==null,uD=3e3;function BS(e,t,n){const[r,o]=S.useState(()=>new Map),i=S.useRef(new Set),l=S.useRef(t);l.current=t;const c=S.useRef(new Map),u=S.useCallback((p,h)=>{i.current.has(p)||(i.current.add(p),xE(e.sock.urls).then(m=>{if(i.current.delete(p),!!l.current.some(w=>w.id===p&&w.url===h)){if(!m){c.current.set(p,setTimeout(()=>{c.current.delete(p),l.current.some(w=>w.id===p&&w.url===h)&&u(p,h)},uD));return}o(w=>new Map(w).set(p,{url:h,src:FS(h,m.code)}))}}))},[e]);return S.useEffect(()=>{const p=c.current;return()=>{for(const h of p.values())clearTimeout(h);p.clear()}},[]),S.useEffect(()=>{var h;if(!n)return;for(const m of t)((h=r.get(m.id))==null?void 0:h.url)!==m.url&&u(m.id,m.url);const p=new Set(t.map(m=>m.id));[...r.keys()].some(m=>!p.has(m))&&o(m=>new Map([...m].filter(([g])=>p.has(g))))},[n,t,r,u]),{urlOf:p=>{var h,m;return n?((h=r.get(p))==null?void 0:h.src)??null:((m=t.find(g=>g.id===p))==null?void 0:m.url)??null},renew:p=>{const h=t.find(m=>m.id===p);!h||!n||(o(m=>{const g=new Map(m);return g.delete(p),g}),u(p,h.url))}}}function dD(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}]),BS(e,r.current,n).urlOf("one")}function fD(e,t,n){if(!n){window.open(t,"_blank");return}const r=window.open("","_blank");xE(e.sock.urls).then(o=>{const i=o?FS(t,o.code):t;r?r.location.href=i:window.open(i,"_blank")})}function We(...e){return e.filter(Boolean).join(" ")}const hD={branch:"M4.5 5.1v5.8 M11.5 6.6c0 2.6-7 1.6-7 4.3 M4.5 1.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M4.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 3.4a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z",chat:"M2.5 3.5a1.5 1.5 0 0 1 1.5-1.5h8a1.5 1.5 0 0 1 1.5 1.5v6a1.5 1.5 0 0 1-1.5 1.5H7l-3.2 2.6V11H4a1.5 1.5 0 0 1-1.5-1.5z",settings:"M12.38 6.99 14.05 7.26 14.05 8.74 12.38 9.01 11.82 10.38 12.81 11.76 11.76 12.81 10.38 11.82 9.01 12.38 8.74 14.05 7.26 14.05 6.99 12.38 5.62 11.82 4.24 12.81 3.19 11.76 4.18 10.38 3.62 9.01 1.95 8.74 1.95 7.26 3.62 6.99 4.18 5.62 3.19 4.24 4.24 3.19 5.62 4.18 6.99 3.62 7.26 1.95 8.74 1.95 9.01 3.62 10.38 4.18 11.76 3.19 12.81 4.24 11.82 5.62z M8 6.4a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z",zen:"M2 6V3a1 1 0 0 1 1-1h3 M10 2h3a1 1 0 0 1 1 1v3 M14 10v3a1 1 0 0 1-1 1h-3 M6 14H3a1 1 0 0 1-1-1v-3",back:"M9.5 3.5 5 8l4.5 4.5",forward:"M6.5 3.5 11 8l-4.5 4.5",reload:"M13.5 2.5v3.5H10 M12.4 9.2a4.8 4.8 0 1 1-1-4.9l2.1 1.7",pick:"M8 4.2a3.8 3.8 0 1 0 0 7.6 3.8 3.8 0 1 0 0-7.6z M8 1.5v2.7 M8 11.8v2.7 M1.5 8h2.7 M11.8 8h2.7",inspect:"M6.5 13.5h-3a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1h9a1 1 0 0 1 1 1v3 M8.2 8.2l5.3 2-2.3.9-.9 2.3z",terminal:"M2 3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1z M4.8 5.6 7.4 8l-2.6 2.4 M8.6 10.6h2.8",close:"M4.2 4.2 11.8 11.8 M11.8 4.2 4.2 11.8",edit:"M10.6 2.6 13.4 5.4 5.8 13H3v-2.8z M9.2 4l2.8 2.8 M3 10.2l2.8 2.8",check:"M3.4 8.4 6.4 11.4 12.6 4.6",split:"M2.5 2.5h11v11h-11z M2.5 8h11",full:"M2.5 2.5h11v11h-11z",more:"M3.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M7.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M11.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z",caret:"M4.5 6.5 8 10l3.5-3.5","caret-up":"M4.5 9.5 8 6l3.5 3.5",stop:"M4.5 4.5h7v7h-7z",send:"M8 13V3.2 M4 7.2 8 3.2l4 4",external:"M9 3h4v4 M13 3 8 8 M11.5 9.5V13H3V4.5h3.5",plus:"M8 3.5v9 M3.5 8h9",download:"M8 2.5v7.4 M4.9 6.8 8 9.9l3.1-3.1 M3 13h10",copy:"M5.5 5.5h8v8h-8z M10.5 5.5v-3h-8v8h3",pull:"M8 3.2v7.4 M4.9 7.4 8 10.6l3.1-3.2",layers:"M6 2.5h7.5V10 M2.5 6h8v7.5h-8z",text:"M3.5 3.5h9 M3.5 6.5h9 M3.5 9.5h9 M3.5 12.5h5",wrap:"M3.5 4h9 M3.5 8h7a2 2 0 0 1 0 4H8 M9.5 10.5 8 12l1.5 1.5 M3.5 12h2.5",file:"M4.5 2.5h4.5l2.5 2.5v8.5h-7z M9 2.5V5h2.5",diff:"M8 2.8v5 M5.5 5.3h5 M5.5 11.2h5",folder:"M2.2 3.9a1 1 0 0 1 1-1h2.9l1.5 1.7h5.2a1 1 0 0 1 1 1v5.9a1 1 0 0 1-1 1H3.2a1 1 0 0 1-1-1z",book:"M8 4.6c-1.2-1-2.7-1.4-4.4-1.3v7.6c1.7-.1 3.2.3 4.4 1.3 1.2-1 2.7-1.4 4.4-1.3V3.3c-1.7-.1-3.2.3-4.4 1.3z M8 4.6v8.6",eye:"M2 8c1.6-2.9 3.6-4.3 6-4.3s4.4 1.4 6 4.3c-1.6 2.9-3.6 4.3-6 4.3S3.6 10.9 2 8z M8 6.1a1.9 1.9 0 1 0 0 3.8 1.9 1.9 0 1 0 0-3.8z",trash:"M3.6 4.6h8.8 M6.4 4.6V3.2a.7.7 0 0 1 .7-.7h1.8a.7.7 0 0 1 .7.7v1.4 M5 4.6l.55 8.1a.9.9 0 0 0 .9.84h3.1a.9.9 0 0 0 .9-.84L11 4.6",move:"M2.8 8h9.2 M8.9 4.9 12 8l-3.1 3.1",search:"M7.2 2.6a4.6 4.6 0 1 0 0 9.2 4.6 4.6 0 1 0 0-9.2z M10.5 10.5 13.5 13.5",run:"M3.4 4.2 7.6 8l-4.2 3.8 M9 11.8h4",bulb:"M4.8 8.8a4 4 0 1 1 6.4 0L9.5 10.6v1.4H6.5v-1.4z M6.7 13.8h2.6",spawn:"M2.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",laptop:"M3.4 3.4h9.2a1 1 0 0 1 1 1v6.2H2.4V4.4a1 1 0 0 1 1-1z M1.5 12.6h13",devices:"M8.8 11.2H3.2a1 1 0 0 1-1-1V4.2a1 1 0 0 1 1-1h8.8a1 1 0 0 1 1 1v1.3 M4.6 13.6h4.2 M10.6 6.9h3a.9.9 0 0 1 .9.9v5a.9.9 0 0 1-.9.9h-3a.9.9 0 0 1-.9-.9v-5a.9.9 0 0 1 .9-.9z M11.6 12.1h1",pr:"M4.5 5.1v5.8 M4.5 1.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M4.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 10.9V6.6a2 2 0 0 0-2-2H8 M9.6 2.9 7.9 4.6l1.7 1.7",clock:"M8 2.2a5.8 5.8 0 1 0 0 11.6 5.8 5.8 0 1 0 0-11.6z M8 4.8V8l2.2 1.4",archive:"M2.4 3.2h11.2v2.8H2.4z M3.4 6v6.1a.9.9 0 0 0 .9.9h7.4a.9.9 0 0 0 .9-.9V6 M6.6 8.6h2.8",land:"M8 2.1a1.3 1.3 0 1 0 0 2.6 1.3 1.3 0 1 0 0-2.6z M8 4.7v5.4 M5.4 7.6 8 10.2l2.6-2.6 M3 13h10",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 kt({name:e,className:t}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:hD[e]})})}function kl({size:e="inline",variant:t="ring",className:n}){return d.jsx("span",{className:We("spinner",e==="dot"&&"spinner-dot",t==="squares"&&"spinner-squares",n),"aria-hidden":"true",children:t==="squares"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{})]})})}const pD='button, a[href], input, textarea, select, summary, label, [role="button"], [role="menuitem"]';function hb(e){var n;const t=e;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,pD))??t??null}function mD(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 gD(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 kD(e,t){const n=new Set;for(const r of e)if(mD(r,t))for(let o=r;o;o=o.parent)n.add(o);return e.filter(r=>!n.has(r)&&r.dismiss).reverse()}const wD=e=>{setTimeout(e,0)};function yD({schedule:e=wD}={}){let t=[],n=null,r=!1;const o=new Set,i=()=>{for(const c of[...o])c()},l=c=>{var u;for(const p of[...t].reverse())(u=p.dismiss)==null||u.call(p,c)};return{register(c){const u=c.trigger??(c.from===void 0?n:null),p={box:c.box,trigger:u,parent:gD(t,c.from??u),dismiss:c.dismiss,onKey:c.onKey,back:c.back};return t=[...t,p],i(),p},unregister(c){t=t.filter(u=>u!==c),i()},top:()=>t[t.length-1]??null,open:()=>t,watch(c){return o.add(c),()=>o.delete(c)},shut(c){var u;c.back?c.back():(u=c.dismiss)==null||u.call(c,"outside")},install(c){const u=c.document,p=b=>{var E;const _=b.target,T=_?kD(t,_):[];for(const N of T)(E=N.dismiss)==null||E.call(N,"outside");r=T.length>0&&b.pointerType==="touch",r&&b.preventDefault(),n=hb(b.target)},h=()=>e(()=>n=null),m=()=>{r=!1,h()},g=b=>{if(r){r=!1,b.preventDefault(),b.stopPropagation();return}n||(n=hb(b.target),h())},w=b=>{var T;const _=t[t.length-1];(T=_==null?void 0:_.onKey)==null||T.call(_,b)},y=()=>e(()=>{var b;((b=u.activeElement)==null?void 0:b.tagName)==="IFRAME"&&l("frame")});return u.addEventListener("pointerdown",p,!0),u.addEventListener("pointerup",h,!0),u.addEventListener("pointercancel",m,!0),u.addEventListener("click",g,!0),c.addEventListener("keydown",w,!0),c.addEventListener("blur",y),()=>{u.removeEventListener("pointerdown",p,!0),u.removeEventListener("pointerup",h,!0),u.removeEventListener("pointercancel",m,!0),u.removeEventListener("click",g,!0),c.removeEventListener("keydown",w,!0),c.removeEventListener("blur",y)}}}}const wl=yD(),vD=()=>wl.open().some(e=>!!e.dismiss);function bD(){return S.useSyncExternalStore(wl.watch,vD,()=>!1)}const Vp=typeof HTMLElement<"u"&&"showPopover"in HTMLElement.prototype,pb=e=>(e==null?void 0:e.getBoundingClientRect())??null;function xD(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 Rs({className:e,anchor:t,placement:n,coverBy:r,track:o=t==="parent",raiseKey:i,onDismiss:l,onKey:c,onBack:u,trigger:p,from:h,boxRef:m,handle:g,children:w,...y}){const b=S.useRef(null),_=S.useRef({anchor:t,placement:n,coverBy:r,onDismiss:l,onKey:c,onBack:u,trigger:p,from:h});_.current={anchor:t,placement:n,coverBy:r,onDismiss:l,onKey:c,onBack:u,trigger:p,from:h};const T=S.useCallback(()=>{const N=b.current,{anchor:j,placement:$,coverBy:P}=_.current;if(!N||!j||!$)return;const R=j==="parent"?pb(N.parentElement):j();if(!R)return;const A=h4(R,$);A!==void 0&&(N.style.width=`${A}px`);for(let O=0;O<2;O++){const B=P?xD(N,P,N.dataset.side??"",N.dataset.align??""):null,H=m4(R,{w:N.offsetWidth,h:N.offsetHeight},{w:window.innerWidth,h:window.innerHeight},B?{...$,...B}:$);N.style.left=`${H.x}px`,N.style.top=`${H.y}px`;const Q=N.dataset.side!==H.side||N.dataset.align!==H.align;if(N.dataset.side=H.side,N.dataset.align=H.align,!Q)break}},[]);S.useImperativeHandle(g,()=>({update:T}),[T]),S.useLayoutEffect(()=>{const N=b.current;if(!N)return;m&&(m.current=N),Vp&&(N.popover="manual",N.matches(":popover-open")||N.showPopover());const{onDismiss:j,onKey:$,onBack:P,trigger:R,from:A}=_.current,O=j||$?wl.register({box:N,trigger:R,from:A,dismiss:j?B=>{var H,Q;return(Q=(H=_.current).onDismiss)==null?void 0:Q.call(H,B)}:void 0,onKey:$?B=>{var H,Q;return(Q=(H=_.current).onKey)==null?void 0:Q.call(H,B)}:void 0,back:P?()=>{var B,H;return(H=(B=_.current).onBack)==null?void 0:H.call(B)}:void 0}):null;return()=>{O&&wl.unregister(O),m&&(m.current=null),Vp&&N.isConnected&&N.matches(":popover-open")&&N.hidePopover()}},[m]),S.useLayoutEffect(T),S.useLayoutEffect(()=>{if(!o)return;let N=0,j="";const $=()=>{const P=b.current,{anchor:R}=_.current,A=P&&R?R==="parent"?pb(P.parentElement):R():null;if(P&&A){const O=`${A.left},${A.top},${A.right},${A.bottom},${P.offsetWidth},${P.offsetHeight},${window.innerWidth},${window.innerHeight}`;O!==j&&(j=O,T())}N=requestAnimationFrame($)};return N=requestAnimationFrame($),()=>cancelAnimationFrame(N)},[o,T]);const E=S.useRef(!0);return ft([i],()=>{if(E.current){E.current=!1;return}const N=b.current;!Vp||!(N!=null&&N.matches(":popover-open"))||(N.hidePopover(),N.showPopover(),T())}),d.jsx("div",{ref:b,className:We("float",e),...y,children:w})}const ED=/^[⌘⇧⌥⌃]+/;function Vo({k:e,chip:t=!1,className:n}){var l;const r=(l=e.match(ED))==null?void 0:l[0],o=r?e.slice(r.length):e,i=["kbd",t?"kbd-chip":"",n??""].filter(Boolean).join(" ");return d.jsxs("kbd",{className:i,children:[r&&d.jsx("span",{className:"kbd-mod",children:r}),o]})}function Ut(e,t,{placement:n,detail:r,card:o,dot:i,name:l,aside:c,also:u}={}){const p=l?`${e}: ${l}`:e,h=(Array.isArray(r)?r:[r]).filter(g=>!!g),m=[p,...h,...c??[]].join(", ");return{"data-tip":e,"data-tip-key":t,"data-tip-placement":n,"data-tip-detail":h.length?h.join(`
|
|
104
|
+
`):void 0,"data-tip-card":o||l||c!=null&&c.length?"":void 0,"data-tip-dot":i,"data-tip-name":l,"data-tip-aside":c!=null&&c.length?c.join(`
|
|
105
|
+
`):void 0,"data-tip-also":u==null?void 0:u.text,"data-tip-also-key":u==null?void 0:u.key,"aria-label":t?`${m} (${t})`:m}}const SD=120,_D=600,ND=150,mb=6,TD=18,Yp=8;function gb(e){const t=e.dataset.tipPlacement;return t==="follow"||t==="top"||t==="bottom"||t==="left"||t==="right"?t:"bottom"}function US(e){return e==="follow"?{side:"bottom",align:"start",offset:TD,alignOffset:-12,flip:"both",margin:Yp}:e==="left"||e==="right"?{side:e,align:"start",offset:mb,flip:"both",margin:Yp}:{side:e,align:"center",offset:mb,flip:"side",margin:Yp}}function jD(e,t){return e.placement==="follow"?pS(t):e.el.getBoundingClientRect()}function HS(){var u;const[e,t]=S.useState(null),n=S.useRef(null),r=S.useRef(null),o=S.useRef({x:0,y:0}),i=Si();if(S.useEffect(()=>{if(i)return;let p=0,h=0,m=null,g=!1,w=0;const y=()=>{window.clearTimeout(p),window.clearTimeout(h)},b=()=>{y(),g&&(w=Date.now()),g=!1,m=null,t(null)},_=(A,O)=>{var H,Q;const B=A.dataset.tip;if(!B)return b();y(),g=!0,t({el:A,text:B,key:A.dataset.tipKey,detail:(H=A.dataset.tipDetail)==null?void 0:H.split(`
|
|
106
|
+
`),card:A.dataset.tipCard!==void 0,dot:A.dataset.tipDot,name:A.dataset.tipName,aside:(Q=A.dataset.tipAside)==null?void 0:Q.split(`
|
|
107
|
+
`),also:A.dataset.tipAlso&&A.dataset.tipAlsoKey?{text:A.dataset.tipAlso,key:A.dataset.tipAlsoKey}:void 0,placement:O})},T=A=>{const O=A.target;if(!(O instanceof Element))return null;const B=O.closest("[data-tip], .float");return(B==null?void 0:B.dataset.tip)!==void 0?B:null},E=A=>{o.current={x:A.clientX,y:A.clientY};const O=T(A);if(O===m)return;if(y(),m=O,!O){g&&(h=window.setTimeout(b,ND));return}const B=gb(O);if(g||Date.now()-w<_D)return _(O,B);p=window.setTimeout(()=>_(O,B),SD)},N=A=>{A.relatedTarget||b()},j=A=>{const O=T(A);if(O!=null&&O.matches(":focus-visible")){y(),m=O;const B=gb(O);_(O,B==="follow"?"bottom":B)}},$=()=>b(),P=A=>{A.key!=="Shift"&&A.key!=="Control"&&A.key!=="Alt"&&A.key!=="Meta"&&b()},R=A=>{m&&A.target instanceof Node&&A.target.contains(m)&&b()};return document.addEventListener("mouseover",E),document.addEventListener("mouseout",N),document.addEventListener("mousedown",b),document.addEventListener("keydown",P),document.addEventListener("scroll",R,!0),document.addEventListener("focusin",j),document.addEventListener("focusout",$),window.addEventListener("blur",b),()=>{y(),document.removeEventListener("mouseover",E),document.removeEventListener("mouseout",N),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",P),document.removeEventListener("scroll",R,!0),document.removeEventListener("focusin",j),document.removeEventListener("focusout",$),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 p=h=>{var m;o.current={x:h.clientX,y:h.clientY},(m=r.current)==null||m.update()};return document.addEventListener("mousemove",p),()=>document.removeEventListener("mousemove",p)},[e]),!e)return null;const l=d.jsxs(d.Fragment,{children:[e.dot==="spinner"?d.jsx(kl,{size:"dot",className:"tooltip-dot"}):e.dot&&d.jsx("span",{className:`dot ${e.dot} tooltip-dot`}),e.text]}),c=d.jsxs(d.Fragment,{children:[l,e.key&&d.jsx(Vo,{k:e.key,className:"tooltip-key"})]});return d.jsxs(Rs,{className:We("tooltip",e.card&&"tooltip-card"),role:"tooltip",boxRef:n,handle:r,anchor:()=>jD(e,o.current),placement:US(e.placement),track:!1,raiseKey:e,children:[e.also?d.jsxs("div",{className:"tooltip-pair",children:[d.jsx("span",{children:l}),e.key?d.jsx(Vo,{k:e.key,className:"tooltip-key"}):d.jsx("span",{}),d.jsx("span",{className:"tooltip-also",children:e.also.text}),d.jsx(Vo,{k:e.also.key,className:"tooltip-key"})]}):e.name?d.jsxs("div",{className:"tooltip-head",children:[d.jsx("span",{children:c}),d.jsx("span",{className:"tooltip-name",children:e.name})]}):c,(u=e.detail)==null?void 0:u.map((p,h)=>d.jsx("div",{className:"tooltip-detail",children:p},h)),e.aside&&d.jsx("div",{className:"tooltip-foot",children:e.aside.map(p=>d.jsx("span",{children:p},p))})]})}const CD={sm:"",md:"btn-md",lg:"btn-lg"},AD={ghost:"",outline:"btn-outline",field:"btn-outline btn-field",inline:"btn-inline"},WS={primary:"tone-primary",quiet:"tone-quiet",danger:"tone-danger",strong:"tone-strong",chrome:"tone-chrome"};function Be({variant:e="ghost",size:t="sm",tone:n,on:r,mono:o,busy:i,className:l,type:c="button",disabled:u,children:p,...h}){const m=We("btn",AD[e],CD[t],n&&WS[n],r&&"on",o&&"btn-mono",i&&"btn-busy",l);return d.jsxs("button",{className:m,type:c,disabled:i||u,"aria-busy":i||void 0,...h,children:[i&&d.jsx(kl,{}),p]})}function Ot({icon:e,label:t,hint:n,detail:r,also:o,silent:i,badge:l,tone:c,on:u,className:p,type:h="button",...m}){const g=We("btn-icon",c&&WS[c],u&&"on",p),w=Ut(t,n,{detail:r,also:o});return d.jsxs("button",{className:g,type:h,...i?{"aria-label":w["aria-label"]}:w,...m,children:[typeof e=="string"?d.jsx(kt,{name:e}):e,l]})}function su(e,t,n){return n===0?0:(e+t+n)%n}function kb(e,t,n){return e>=0?su(e,t,n):n===0?-1:t>0?0:n-1}function KS(e,t,n){var i;const r=e.length,o=n.toLowerCase();for(let l=1;l<=r;l++){const c=(Math.max(t,-1)+l)%r;if((i=e[c])!=null&&i.trim().toLowerCase().startsWith(o))return c}return-1}function Xp(e,t){return e&&e.length>t.length&&e.toLowerCase().startsWith(t.toLowerCase())?e.slice(t.length):null}function ID(e,t){if(e==null)return null;if(typeof e=="string"){const o=Xp(e,t);return o?{text:o,accept:o,params:[]}:null}const n=Xp(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:Xp(e.accept,t),params:r}}function ZS(e){const{results:t,keyOf:n,q:r,onPick:o,listRef:i,onActive:l,onSide:c,completionOf:u,narrowTo:p,setQ:h,tabPicks:m,onIdlePick:g}=e,[w,y]=S.useState(()=>{var P;return e.idle?-1:Math.max(0,((P=e.initialIndex)==null?void 0:P.call(e,t))??0)}),b=w>=0&&t[w]?n(t[w]):null,_=S.useRef(l);_.current=l,ft([b],()=>{var P,R,A;(R=(P=i.current)==null?void 0:P.querySelector('.picker-item[data-state~="cursor"]'))==null||R.scrollIntoView({block:"nearest"}),(A=_.current)==null||A.call(_,w>=0?t[w]??null:null)});const T=w<0?-1:Math.min(w,Math.max(0,t.length-1)),E=T>=0?t[T]??null:null,N=E?ID(u==null?void 0:u(E,r),r):null,j=P=>{const R=p==null?void 0:p(P,r);if(R==null)return o(P,r);h==null||h(R),y(0)};return{index:T,active:E,ghost:N,setIndex:y,pick:j,onKeyDown:P=>{if(P.key==="ArrowDown")P.preventDefault(),y(kb(T,1,t.length));else if(P.key==="ArrowUp")P.preventDefault(),y(kb(T,-1,t.length));else if((P.key==="ArrowLeft"||P.key==="ArrowRight")&&c&&E)P.preventDefault(),c(E,P.key==="ArrowLeft"?-1:1);else if(P.key==="Tab"&&(N!=null&&N.accept))P.preventDefault(),h==null||h(r+N.accept),y(0);else if(P.key==="Tab"&&m&&E)P.preventDefault(),j(E);else if(P.key==="Enter"&&E)P.preventDefault(),j(E);else if(P.key==="Enter"&&T<0&&g)P.preventDefault(),g(r);else return!1;return!0}}}function vr(e){const t=Object.keys(e).filter(n=>e[n]);return t.length>0?t.join(" "):void 0}const $D=new Set(["Shift","Meta","Control","Alt","CapsLock","Fn"]);function qS(){const e=Nk(),t=Yn();return S.useEffect(()=>{if(!e)return;const n=()=>{e.target.isConnected||ro.close()},r=new MutationObserver(n);r.observe(document.body,{childList:!0,subtree:!0});const o=t.subscribe(n);return()=>{r.disconnect(),o()}},[e,t]),e?d.jsx(RD,{spec:e},e.id):null}function RD({spec:e}){const t=e.items,n=t.filter(cs),[r,o]=S.useState(-1),i=S.useRef({idx:r,items:n});i.current={idx:r,items:n};const l=S.useRef(null),c=m=>{var g,w;{const y=()=>ro.close(),{idx:b,items:_}=i.current;if($D.has(m.key))return;if(m.key==="ArrowDown"||m.key==="ArrowUp"){m.preventDefault(),m.stopPropagation();const T=m.key==="ArrowDown"?1:-1;o(g4(_,b,T));return}if((m.key==="Enter"||m.key===" ")&&b>=0&&_[b]&&!_[b].disabled){m.preventDefault(),m.stopPropagation(),_[b].onClick(),y();return}if(m.key==="Escape"){m.stopPropagation(),y();return}if(m.key.length===1&&!m.metaKey&&!m.ctrlKey&&!m.altKey){m.preventDefault(),m.stopPropagation();const T=Array.from(((g=l.current)==null?void 0:g.querySelectorAll(".menu-label"))??[],N=>N.textContent??""),E=KS(T,b,m.key);E>=0&&!((w=_[E])!=null&&w.disabled)&&o(E);return}y()}};S.useEffect(()=>{const m=()=>ro.close();return window.addEventListener("blur",m),window.addEventListener("resize",m),document.addEventListener("scroll",m,!0),()=>{window.removeEventListener("blur",m),window.removeEventListener("resize",m),document.removeEventListener("scroll",m,!0)}},[]);const{rect:u,placement:p}=y4(e),h=n.some(m=>m.checked);return d.jsx(Rs,{className:"menu",role:"menu",boxRef:l,anchor:()=>u,placement:p,track:!1,from:e.target,trigger:e.toggles?e.target:null,onDismiss:()=>ro.close(),onKey:c,onContextMenu:m=>m.preventDefault(),children:t.map((m,g)=>{if(!cs(m))return d.jsx("hr",{className:"menu-sep"},`sep-${g}`);const w=n.indexOf(m);return d.jsx(OD,{item:m,gutter:h,cursor:w===r,onEnter:()=>o(w)},m.id)})})}function OD({item:e,gutter:t,cursor:n,onEnter:r}){const o=e.disabled!==void 0,i=e.detail??e.disabled;return d.jsxs("button",{...e.checked===void 0?{role:"menuitem"}:{role:"menuitemcheckbox","aria-checked":e.checked},"aria-disabled":o||void 0,className:We("row row-keyed",e.danger&&"danger",i!==void 0&&"row-tall",o&&"disabled"),"data-state":vr({cursor:n,checked:e.checked}),onMouseMove:o||n?void 0:r,onClick:()=>{o||(e.onClick(),ro.close())},children:[t&&d.jsx("span",{className:"menu-check",children:e.checked&&d.jsx(kt,{name:"check",className:"icon-inline"})}),d.jsxs("span",{className:"menu-text",children:[d.jsx("span",{className:"menu-label",children:e.label}),i!==void 0&&d.jsx("span",{className:"menu-detail row-dim",children:i})]}),e.key&&d.jsx(Vo,{k:e.key,className:"menu-key row-dim"})]})}function Xf({items:e,current:t,onPick:n,fill:r,font:o,segmented:i,quiet:l,end:c,label:u,owner:p}){const h=vn(p),m=S.useRef(null),g=Math.max(0,e.findIndex(y=>y.id===t)),w=y=>{var T,E;if(y.key!=="ArrowLeft"&&y.key!=="ArrowRight")return;y.preventDefault();const b=e.findIndex(N=>N.id===t),_=e[su(b,y.key==="ArrowRight"?1:-1,e.length)];_&&(n(_.id),(E=(T=m.current)==null?void 0:T.querySelectorAll('[role="tab"]')[e.indexOf(_)])==null||E.focus())};return d.jsxs("div",{className:We("tabs",r&&"tabs-fill",o==="mono"&&"tabs-mono",i&&"tabs-segmented",l&&"tabs-quiet"),children:[d.jsx("div",{className:"tabs-list",role:"tablist","aria-label":u,ref:m,onKeyDown:w,style:i?{"--tabs-at":g,"--tabs-count":e.length}:void 0,children:e.map(y=>{const b=y.id===t;return d.jsxs("div",{className:We("tab",b&&!!y.trail&&"tab-trailed",y.fit&&"tab-fit",y.far&&"tab-far"),"data-state":vr({current:b}),...y.menu?h.contextMenu(y.menu):{},children:[d.jsxs("button",{type:"button",className:"tab-btn",role:"tab","aria-selected":b,tabIndex:b?0:-1,onClick:()=>n(y.id),...y.tip,...y.ariaLabel?{"aria-label":y.ariaLabel}:{},children:[y.lead,y.label]}),b&&y.trail&&d.jsx("span",{className:"tab-trail",children:y.trail})]},y.id)})}),c&&d.jsx("span",{className:"tabs-end",children:c})]})}function ds({anchor:e="top",wide:t,foot:n,children:r}){const o=d.jsx("div",{className:We("view",e==="line"&&"view-anchored",t&&"view-wide"),children:r});return n?d.jsxs("div",{className:"view-stack",children:[o,n]}):o}const GS=e=>`Toyon restarts once ${e.join(", ")} ${e.length===1?"finishes":"finish"}`,MD=(e,t)=>[...e,...t.filter(n=>!e.includes(n))];function PD(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 LD(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 DD(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:GS(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 Gm=!1;function zD(){Gm=!0}function zc({title:e,body:t,action:n,pane:r,children:o}){return d.jsxs("div",{className:We("crash",r&&"in-pane"),children:[d.jsx("div",{className:"crash-title",children:e}),t&&d.jsx("div",{className:"crash-body",children:t}),o,n]})}const wb={title:"Toyon was updated",body:"This page is still running the old build. Reload to pick up the new one."};class Ok extends S.Component{constructor(){super(...arguments);Bt(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,r){console.error("[toyon] render error",n,r.componentStack)}render(){const{error:n}=this.state;return n?d.jsx(zc,{pane:this.props.pane,title:Gm?wb.title:"Toyon hit an error",body:Gm?wb.body:n.message||String(n),action:d.jsx(Be,{variant:"outline",onClick:()=>window.location.reload(),children:"reload"})}):this.props.children}}const Vm={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.`},FD=1e3,yb={held:[],asking:[],seen:[]};async function vb(e,t,n){for(;;){await new Promise(i=>setTimeout(i,FD));const[r,o]=await Promise.all([Om(e),yE(e)]);if(r!==null&&r!==t)break;n(o??{waiting:[],asking:[]})}window.location.reload()}function VS({foreign:e}={}){return e?d.jsx(BD,{name:e}):d.jsx(UD,{})}function BD({name:e}){const t=Jo(),n=t.list()[0];return d.jsx(zc,{title:`Toyon on ${e} was updated`,body:Vm.foreign(e),action:n&&d.jsxs(Be,{variant:"outline",onClick:()=>t.activate(n.origin),children:["back to ",t.displayName(n.origin)]})})}function UD(){const e=Dr(),[t,n]=S.useState(!0),[r,o]=S.useState(null),[i,l]=S.useState(yb),c=S.useRef(null),u=S.useCallback(g=>l(w=>({held:g.waiting,asking:g.asking,seen:MD(w.seen,g.waiting)})),[]),p=S.useCallback(async g=>{n(!0),o(null);const w=c.current??{pid:await Om(e)},y=await JM(e,g);if(y){n(c.current!==null),o(y);return}g&&l(yb),!c.current&&(c.current=w,vb(e,w.pid,u))},[u,e]);S.useEffect(()=>{let g=!0;return(async()=>{const[w,y]=await Promise.all([Om(e),yE(e)]);if(!(!g||c.current)){if(y===null){p(!1);return}c.current={pid:w},u(y),vb(e,w,u)}})(),()=>{g=!1}},[u,p,e]);const h=t&&i.held.length>0,m=h?PD(i.seen,i.held,i.asking):[];return d.jsx(zc,{title:Vm.title,body:r??(h?LD(i.held.length,i.seen.length):Vm.waiting),action:h?d.jsx(Be,{variant:"outline",onClick:()=>void p(!0),children:"restart now"}):d.jsx(Be,{variant:"outline",busy:t,onClick:()=>void p(!1),children:"restart"}),children:m.length>0&&d.jsx("ul",{className:"crash-list",children:m.map((g,w)=>d.jsxs("li",{className:We("crash-row",g.dot!=="working"&&"row-dim"),children:[d.jsx("span",{className:We("dot",g.dot)}),d.jsx("span",{className:"crash-row-name",children:g.name}),g.note&&d.jsx("span",{className:"crash-row-note",children:g.note})]},w))})})}const Ji=(e,t=!1)=>({text:e,live:t}),HD={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"},WD={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`},KD="no access token for this address.\nrun `toyon` or `toyon open` in your repo to get a signed-in page";function YS(e){if(!e.connected&&(!e.heard||e.connectFailure)){const t=e.connectFailure===null;return e.machine?Ji(WD[e.connectFailure??"probing"](e.machine),t):e.hasToken?Ji(HD[e.connectFailure??"probing"],t):Ji(KD)}return e.title===null?Ji(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 ZD(e){const t=YS(e);return t!==null?t:e.needsSetup&&e.busy?Ji(`building in ${e.title}; the preview appears once it starts`,!0):e.needsSetup&&e.treeEmpty?Ji(`${e.title} is empty so far; say what to build`):e.treeEmpty&&e.landsFrom?Ji(`nothing runs on main until ${e.landsFrom} lands`):null}const an={post:(e,t)=>{},broadcast:e=>{}};function Fc(e,t,n,r){const o=t===r;an.post(e,o?{type:"pick-cancel"}:{type:"pick-start",verb:r}),n({a:"set-picking",v:o?!1:r})}function XS(e){return[{id:"copy-sha",label:`copy ${e.short}`,onClick:()=>en(e.sha)},{id:"copy-subject",label:"copy subject",onClick:()=>en(e.subject)}]}function Qf(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 Jf(e){return e!=null&&e.config.profiles?Object.keys(e.config.profiles):[]}function QS(e,t){const n=Jf(t);if(n.length!==0)return e.profile&&n.includes(e.profile)?e.profile:t==null?void 0:t.config.defaultProfile}const qD=e=>Yd(fi((e==null?void 0:e.config)??{}),e==null?void 0:e.defaultBranch).toLowerCase();function pi(e,t,n){t({a:"shipping",id:n.worktreeId,op:n.t}),e==null||e.send(n)}const JS=e=>e.dirty===void 0||e.ahead===void 0||e.dirty>0||e.ahead>0;function oa(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 e_(e,t,n){t({a:"hold-unread",id:n}),e==null||e.send({t:"mark-unread",worktreeId:n})}function Mk(e,t){return{rename(n){if(!f1(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(!Og(n.worktree))return;if(!JS(n))return oa(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.`)&&oa(e,t,[n.worktree.id])}}}function t_(e,t,n,{sock:r,dispatch:o},i){var P,R;const l=e.worktree.id,c=Mk(r,o),u=[],p=[],h=[],m=[],g=[],w=[],y=[],b=[];tu(e)&&u.push({id:"stop",label:"stop agent",onClick:()=>r==null?void 0:r.send({t:"stop-agent",worktreeId:l})});const _=!n.shipping[l],T=n.frame==="phone";((e.dirty??0)>0||(e.ahead??0)>0||!T&&!n.layout.changes)&&p.push({id:"changes",label:`view changes${(e.dirty??0)>0?` (${e.dirty})`:""}`,onClick:()=>{o({a:"activate",id:l}),T?o({a:"screen",to:"changes"}):n.layout.changes||o({a:"toggle-changes"})}}),T||p.push({id:"terminal",label:"open terminal",onClick:()=>{o({a:"activate",id:l}),o({a:"focus-terminal"})}}),p.push(...Qo(()=>r==null?void 0:r.send({t:"reveal",worktreeId:l}),i.hostname)),T||h.push({id:"copy-path",label:"copy path",onClick:()=>en(e.path)}),h.push({id:"copy-branch",label:"copy branch name",onClick:()=>en(e.worktree.branch)});const{transcript:E,sessionId:N}=e;!T&&E&&!wr(e.worktree)&&h.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>en(E)}),!T&&N&&h.push({id:"copy-session",label:"copy session id",onClick:()=>en(N)});const j=QS(e.worktree,t);for(const A of Jc(e.worktree)?[]:Jf(t))m.push({id:`profile:${A}`,label:`run with ${A}`,checked:A===j,onClick:()=>c.setProfile(e,A)});if(!ia(e.worktree)&&((P=e.borrowed)!=null&&P.length)&&m.push({id:"own-procs",label:`run ${e.borrowed.join(", ")} here`,detail:"on main now",onClick:()=>c.ownProcs(e)}),!ia(e.worktree)&&((R=e.worktree.owns)!=null&&R.length)&&m.push({id:"share-procs",label:`use main's ${e.worktree.owns.join(", ")}…`,detail:"runs here now",danger:!0,onClick:()=>c.shareProcs(e)}),f1(e.worktree)&&g.push({id:"rename",label:"rename…",onClick:()=>c.rename(e)}),e.worktree.variant&&g.push({id:"keep",label:"keep this variant…",onClick:()=>c.pickVariant(e)}),i.graft&&Dd(e.worktree)){const A=i.graft;g.push({id:"graft",label:"graft with…",onClick:()=>A(l)})}g.push({id:"unread",label:"mark as unread",key:Dt("mark-unread"),disabled:e.unseen?"already unread":void 0,onClick:()=>e_(r,o,l)});const $=_?void 0:"waiting on the one in progress";if(e.syncQueued)w.push({id:"sync",label:"call off the sync from main",onClick:()=>r==null?void 0:r.send({t:"unqueue-sync",worktreeId:l})});else if(Nf(e)&&(e.behind??0)>0){const A=(e.agent==="working"||e.agent==="waiting")&&(e.dirty??0)>0;w.push({id:"sync",label:`sync from main${A?" after the turn":""} (${e.behind} behind)`,disabled:$,onClick:()=>pi(r,o,{t:"sync-main",worktreeId:l})})}return Yi(e.worktree)&&!(e.worktree.landed&&e.dirty===0)&&w.push({id:"land",label:zg(fi((t==null?void 0:t.config)??{}),e.worktree),detail:qD(t),disabled:$,onClick:()=>pi(r,o,{t:"land",worktreeId:l})}),e.worktree.kind==="worktree"&&y.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}})}),Og(e.worktree)&&b.push({id:"archive",label:JS(e)?"archive…":"archive",key:Dt("wt-archive"),danger:!0,onClick:()=>c.archive(e)}),zn([u,p,h,m,g,w,y,b])}function GD(e,t,{sock:n,dispatch:r},o){const i=[],l=t.frame==="phone",c=[{id:"adopt",label:"take over",disabled:e.locked?`held by ${e.lockReason??"another tool"}`:void 0,onClick:()=>n==null?void 0:n.send({t:"adopt-worktree",worktreeId:e.id,clientId:t.clientId})}];return Nf(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(...Qo(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id}),o)),zn([c,i,l?[]:[{id:"copy-path",label:"copy path",onClick:()=>en(e.path)}]])}const VD={sm:"",md:"field-md",lg:"field-lg"};function n_({size:e="sm",font:t,bare:n,rule:r,className:o}){const i=t??(e==="lg"?"ui":"mono");return We("field",VD[e],i==="ui"&&"field-ui",i==="lead"&&"field-lead",n&&"field-bare",r&&"field-rule",o)}const $o=S.forwardRef(function({size:t,font:n,bare:r,rule:o,className:i,...l},c){return d.jsx("input",{ref:c,className:n_({size:t,font:n,bare:r,rule:o,className:i}),...l})}),Bc=S.forwardRef(function({size:t,font:n,bare:r,rule:o,className:i,...l},c){return d.jsx("textarea",{ref:c,className:n_({size:t,font:n,bare:r,rule:o,className:i}),...l})});function YD(e,t){const n=t??0;return n===0?null:`${n} behind ${e}`}function r_(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function o_(e,t){if(t.fetchFailed)return`could not reach origin${t.fetchedAt?` since ${r_(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 XD(e){return e.stale!=="diverged"}const Kr=e=>/[.!?…]$/.test(e)?e:`${e}.`,s_=160;function eh(e,t=s_){const n=e.replace(/\s+/g," ").trim();if(n.length<=t)return n;const r=n.slice(0,t);return`${r.slice(0,Math.max(r.lastIndexOf(" "),1)).trimEnd()}…`}function i_(e){return e.subjects.length?eh(e.subjects.join("; ")):void 0}function Pk(e){const t=i_(e);if(t)return e.pr===void 0?t:eh(`PR #${e.pr}: ${t}`)}function Lk(e,t=3){const n=[];for(const l of e??[]){const c=Pk(l);c&&n.push({at:l.at,line:c})}if(n.length===0)return[];const r=n.slice(-t),o=n.length-r.length,i=r.map(({at:l,line:c})=>n.length===1?Kr(c):`${Dk(Ko(yr(l)))}: ${Kr(c)}`);return o>0?[`${o} earlier landing${o===1?"":"s"}.`,...i]:i}const QD="checks running",JD="checks failed",a_="preview up";function ez(e){if(e.state!=="open")return[];const t=[];return(e.checks==="pending"||e.checks==="fail")&&t.push({text:e.checks==="fail"?JD:QD,url:`${e.url}/checks`,tip:"Open the checks on GitHub",open:"open the checks"}),e.preview&&t.push({text:a_,url:e.preview,tip:`Open the branch on ${new URL(e.preview).hostname}`,open:"open the preview"}),t}function tz(e,t){const n=[];let r=e;for(const o of t){const i=new RegExp(`(^|; |, )${o.text.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?=;|\\.|$)`).exec(r);if(!i)continue;const l=i.index+(i[1]??"").length;l>0&&n.push(r.slice(0,l)),n.push(o),r=r.slice(l+o.text.length)}return r&&n.push(r),n}function Ts(e){const t=`PR #${e.number}`;if(e.state==="merged")return`${t} merged.`;if(e.state==="closed")return`${t} was closed without merging.`;const n=e.preview?`; ${a_}.`:".";if(e.automerge){const r=e.review==="review_required"?"it is approved and checks pass":"checks pass";return`${t} open; GitHub merges it when ${r}${n}`}return e.mergeable===!1?`${t} open; it conflicts with main${n}`:e.review==="changes_requested"?`${t} open; changes requested${n}`:e.checks==="fail"?`${t} open; checks failed${n}`:e.checks==="pending"?`${t} open; checks running${n}`:e.review==="review_required"?`${t} open; waiting on review${n}`:e.review==="approved"?`${t} approved${e.checks==="pass"?", checks pass":""}${n}`:`${t} open and ready to merge${n}`}function l_(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 Dk=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function zk(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 c_(e,t,n=null){return e!=null&&e.stale?`The work changed since this was written. ${t?"Run the check again and refresh":"Refresh"} the message.`:n==="unanswered"?`The model did not answer with a message. ${t?"Run the check again and ask":"Ask"} for it again.`:`${t?"Run the repo's check here and write":"Write"} the recap and the commit message.`}function nz(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 Nd(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(c=>c.trim()))==null?void 0:i.trim();return`Check failed${l?`: ${Kr(l)}`:"."}`}return zk(e,t,n)==="unasked"?nz(r):null}function bb(e,t){const n=rz(e,t);return n?Kr(Dk(n)):""}function rz(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 u_=e=>/^[A-Z][a-z]+(\s|$)/.test(e)?`${e.charAt(0).toLowerCase()}${e.slice(1)}`:e;function oz(e,t){const n=t??0;return n>0?`${n} behind ${e}; land takes it in first.`:""}function sz(e){return e>0?Kr(Dk(`${e} ${e===1?"file":"files"} changed`)):""}function iz(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: ${Kr(u_(e.why))}`:null}function Td(e){return Kr(e)}const Ko=e=>e==="now"?"just now":`${e} ago`;function az(e,t,n){switch(e){case"asking":return`Waiting on you${n==="now"?"":` for ${n}`}${t.ask?`: ${Kr(t.ask)}`:"."}`;case"failed":return t.auth?`Stopped ${Ko(n)}: not logged in.`:t.error?`Failed ${Ko(n)}: ${Kr(t.error)}`:`Failed ${Ko(n)}.`;case"stopped":return t.planBack?`Sent the plan back ${Ko(n)}. Say what to change.`:`Stopped ${Ko(n)}.`;case"done":return t.cut?`Ended early ${Ko(n)} (${t.cut}).`:`Finished ${Ko(n)}.`}}function Fk(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?Kr(t):az(e.end,e.facts,yr(e.at))}function lz(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?`Last stop, ${Ko(yr(e.at))}: ${Kr(u_(t))}`:void 0}function Uc(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 Bk(e){return(e==null?void 0:e.status)==="running"||(e==null?void 0:e.status)==="detached"}function d_(e){const t=e&&e.status!=="terminated"?e.since:void 0,n=vk(t,bk);return t!==void 0&&n===t?e:void 0}function f_(e,t){const n=e.stage?[e.stage]:[];switch(e.status){case"queued":return[...n,"queued"];case"running":return[...n,`${Xi(t)} of ${UC(e.timeoutMs)}`];case"detached":return[...n,Xi(t),"detached"];case"terminated":return[e.why??"stopped"]}}function cf(e,t,n){return[e,...f_(t,n)].join(" · ")}const Ym={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 h_(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 cz({active:e,ahead:t,behind:n,unpushed:r,dirty:o}){var sn,ln,lt;const i=it(),l=ut(),c=vn("changes"),u=_n(e)?e.worktree:null,p=e.id,h=M(jt=>{var Kt;return(Kt=jt.shipping[p])==null?void 0:Kt.op}),m=M(jt=>{var Kt;return(Kt=jt.shipping[p])==null?void 0:Kt.step}),g=vk(m,bk),w=Uc(e,"commit"),y=Uc(e,"check"),b=h?w:y,_=d_(b),T=ra(Bk(_)?_==null?void 0:_.since:void 0),[E,N]=S.useState("");ft([p],()=>N("")),ft([o],()=>{o||N("")});const j=S.useRef(null),$=(sn=u==null?void 0:u.landing)!=null&&sn.subject?u.landing.body?`${u.landing.subject}
|
|
117
|
+
|
|
118
|
+
${u.landing.body}`:u.landing.subject:null,P=()=>{E===""&&$&&N($);const jt=j.current;jt&&(jt.focus(),requestAnimationFrame(()=>jt.setSelectionRange(jt.value.length,jt.value.length)))},R=M(jt=>jt.editCommit);ft([R],()=>{R&&P()});const A=E.trim()||void 0,O=M(jt=>{var Kt;return!!((Kt=jt.agents.find(xn=>xn.id===((u==null?void 0:u.agent)??jt.defaultAgent)))!=null&&Kt.quick)}),B=u==null?void 0:u.landing,H=A?null:zk(B,o?1:0,O),Q=(B==null?void 0:B.check)==="pending",re=!!(B!=null&&B.stale),J=()=>{h||i==null||i.send({t:"judge",worktreeId:p})},ie=()=>{h||!A&&!$||pi(i,l,{t:"commit",worktreeId:p,message:A??$??""})},ve=()=>{h||pi(i,l,{t:"land",worktreeId:p,...A?{message:A}:{}})},C=((ln=u==null?void 0:u.landing)==null?void 0:ln.check)==="fail",Z=!!(u!=null&&u.landed)&&!o,Y=u?jf({...u,landed:Z}):void 0,q=(Y==null?void 0:Y.state)==="open",z=q&&(o||r>0),te=Q||re||!!H,Ee=!!u&&Yi(u)&&!Z&&(o||t>0)&&!C&&!q&&!te,Ne=!!u&&z&&!C&&!te,de=!!u&&Yi(u)&&!Q&&(re||H==="unwritten"||H==="unanswered")&&e.agent!=="working"&&e.agent!=="waiting",we=M(jt=>jt.repos.find(Kt=>Kt.id===e.repoId)??null),ae=fi((we==null?void 0:we.config)??{}),G=Yd(ae,we==null?void 0:we.defaultBranch),ue=zg(ae,u??{}),Le=we?Tf(we):"main",ke=Nf(e)?YD(Le,n):null,ne=e.agent==="working"||e.agent==="waiting",ge=o&&!u?"commit or discard the changes here first":void 0,je=!!e.syncQueued,Ce=o&&ne?`Merge ${Le} into this worktree once the turn ends, uncommitted changes kept`:`Merge ${Le} into this worktree${o?", uncommitted changes kept":""}`,Se=q&&!z&&l_(Y),Me=Ee?ue:Ne?"update":Se?"land":(Y==null?void 0:Y.state)==="merged"?"pull":"land",wt=h==="commit"?g??"commit":h==="land"?g?`${Me}: ${g}`:Me:null,on=wt&&_?cf(wt,_,T):wt,St=S.useRef(!1);on?o&&(St.current=!0):St.current=!1;const Yt=!!u&&(o||St.current),zt=Yt&&!!on,Ht=h?null:b?_?f_(_,T).join(" · "):null:Q?"writing the message":null,De=_&&(_.status==="running"||_.status==="detached")?_:null,_t=De&&d.jsx(Ot,{icon:"stop",tone:"danger",label:h_(De.kind),onClick:()=>i==null?void 0:i.send({t:"run-stop",worktreeId:p,kind:De.kind})});return d.jsxs("div",{className:"composer commit-box",children:[Yt&&d.jsx("div",{className:"composer-field",children:zt?d.jsx("div",{className:"commit-running live-text","data-tip":_?Ym[_.status]:void 0,children:on}):d.jsx(Bc,{size:"lg",bare:!0,ref:j,value:E,onChange:jt=>N(jt.target.value),onKeyDown:jt=>{jt.key==="Enter"&&(jt.metaKey||jt.ctrlKey)?(jt.preventDefault(),ie()):jt.key==="Tab"&&!jt.shiftKey&&E===""&&$&&(jt.preventDefault(),P())},placeholder:$??(H==="unanswered"?"no message yet: the model did not answer. Check again, or write one here":H==="unasked"?"no message yet: write one here to commit or land":"commit message…")})}),d.jsxs("div",{className:"hint composer-knobs",children:[d.jsxs("span",{className:"commit-where",children:[d.jsx(kt,{name:"branch",className:"icon-inline"}),d.jsx("span",{className:"branch-name",children:e.branch??"detached"}),t>0&&d.jsxs("span",{className:"badge-ahead","data-tip":`${t} commit(s) ahead of ${Le}`,children:[t," ahead"]}),(u==null?void 0:u.landed)&&d.jsxs("span",{className:"badge-landed","data-tip":`Merged into ${Le}`,children:[d.jsx(kt,{name:"check",className:"icon-inline"})," landed"]})]}),d.jsxs("span",{className:"commit-acts",children:[on?d.jsxs(d.Fragment,{children:[!zt&&d.jsx("span",{className:"live-text",children:on}),_t]}):d.jsxs(d.Fragment,{children:[u&&o&&d.jsx(Be,{disabled:!A&&!$||!!h,onClick:ie,...Ut($&&!A?"Commit with the suggested message":"git add -A && git commit","⌘⏎"),children:"commit"}),u&&Ee&&d.jsx(Be,{tone:"primary",disabled:!!h,"data-tip":G,onClick:ve,children:ue}),de&&d.jsx(Be,{tone:"primary",disabled:!!h,"data-tip":c_(B,!!((lt=we==null?void 0:we.config.check)!=null&<.trim()),H),onClick:J,children:"check"}),Q&&d.jsx("span",{className:"live-text",children:"check"}),Ne&&Y&&d.jsx(Be,{tone:"primary",disabled:!!h,"data-tip":`Commit, take ${Le} in and push the branch; PR #${Y.number} takes the new commits`,onClick:ve,children:"update"}),Se&&d.jsx(Be,{tone:"primary",disabled:!!h,"data-tip":"Merge the PR now, by the method the repo allows",onClick:ve,children:"land"})]}),Y&&d.jsxs(Be,{"data-tip":`Open PR #${Y.number} on GitHub`,onClick:()=>window.open(Y.url,"_blank"),...c.contextMenu(()=>[{id:"open-pr",label:"open on GitHub",onClick:()=>window.open(Y.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>en(Y.url)}]),children:["view ",d.jsx(kt,{name:"external",className:"icon-inline"})]}),(Y==null?void 0:Y.preview)&&d.jsxs(Be,{"data-tip":`Open the branch on ${new URL(Y.preview).hostname}`,onClick:()=>window.open(Y.preview,"_blank"),...c.contextMenu(()=>[{id:"open-preview",label:"open the preview",onClick:()=>window.open(Y.preview,"_blank")},{id:"copy-preview",label:"copy link",onClick:()=>en(Y.preview??"")}]),children:["preview ",d.jsx(kt,{name:"external",className:"icon-inline"})]})]})]}),(ke||Ht)&&d.jsxs("div",{className:"composer-notes",children:[Ht&&d.jsxs("div",{className:"hint composer-note","data-tip":_?Ym[_.status]:void 0,children:[d.jsx("span",{children:Ht}),_t]}),ke&&d.jsxs("div",{className:"hint composer-note",children:[d.jsx("span",{children:ke}),h==="sync-main"?d.jsx("span",{className:"live-text",children:g?`sync: ${g}`:"sync"}):je?d.jsx("span",{className:"live-text","data-tip":"Runs once the turn ends, the uncommitted changes kept. The row's menu calls it off",children:"syncing after next turn"}):d.jsx(Be,{variant:"outline",disabled:!!h||!!ge,"data-tip":ge??Ce,onClick:()=>pi(i,l,{t:"sync-main",worktreeId:p}),children:"sync"})]})]})]})}const uz=S.memo(function({c:t,id:n,selected:r,onToggle:o}){const i=vn("changes");return d.jsxs("button",{className:"row row-sm log-row row-edge",id:n,"data-state":vr({current:r,cursor:r}),role:"option","aria-selected":r,tabIndex:-1,onClick:()=>o(t.sha),...i.contextMenu(()=>XS(t)),"data-tip":`${t.subject}
|
|
119
|
+
${t.short} · ${t.author}`,"data-tip-placement":"follow",children:[d.jsx("span",{className:"subject",children:t.subject}),d.jsx("span",{className:"at row-dim",children:yr(t.at)})]})});function dz(e,t){const n=yo(e,t);if(!n||!_n(n))return"take this worktree over to change files here";if(ia(n.worktree))return"start a worktree to change files"}function p_(e,t,n,r){return{id:"new-file",label:"new file…",disabled:dz(e.getState(),t),onClick:()=>r(n)}}function fz(e,t,n,r){const{worktreeId:o,dir:i,path:l,folder:c,newIn:u}=e,p=Vf(t.getState(),o)?void 0:"take this worktree over to talk to an agent here",h=Ck(l,c),m=[...c?[]:[{id:"open",label:"open",onClick:()=>er(n,{worktreeId:o,path:l,view:wi(l)})}],{id:"add-to-chat",label:"add to chat",disabled:p,onClick:()=>TS(t,o,l,c)}],g=[p_(t,o,u,r),{id:"ask-rename",label:"ask the agent to rename…",disabled:p,onClick:()=>ab(t,o,`Rename ${h} to `)},{id:"ask-delete",label:"ask the agent to delete…",disabled:p,onClick:()=>ab(t,o,`Delete ${h} and update whatever still uses it`)}],w=[...Qo(()=>{var y;return(y=n.sock)==null?void 0:y.send({t:"reveal",worktreeId:o,path:l})},Xo(n.sock)),{id:"copy-path",label:"copy path",onClick:()=>en(`${i}/${l}`)},{id:"copy-relative-path",label:"copy relative path",onClick:()=>en(l)}];return zn([m,w,g])}function hz(e,t,n,r){return zn([[p_(t,e.worktreeId,"",r)],Qo(()=>{var o;return(o=n.sock)==null?void 0:o.send({t:"reveal",worktreeId:e.worktreeId})},Xo(n.sock))])}const jd=[],pz=[],xb=new Set,Eb=e=>`tree-row-${e}`;function mz({worktreeId:e,dir:t,openPath:n,openRef:r,rootRef:o}){const i=Yn(),l=it(),c=ut(),u=Rt(e,"files"),p=Rt(e,"submodules"),h=Rt(e,"ignored"),m=Rt(e,"git"),g=(m==null?void 0:m.files)??pz,w=m==null?void 0:m.version,y=M(ne=>ne.connected);ft([e,w,y,l],()=>qf(e,i.getState(),{sock:l,dispatch:c}));const b=M(ne=>{var ge;return((ge=ne.dragFiles)==null?void 0:ge.at)==="tree"&&ne.dragFiles.worktreeId===e?ne.dragFiles.dir:null}),_=M(ne=>ne.treeOpen[e]??jd),T=S.useMemo(()=>new Set(_),[_]),[E,N]=S.useState(xb);ft([e,n,r],()=>N(n&&!r?new Set(sf(n).filter(ne=>!T.has(ne))):xb));const j=S.useCallback(ne=>T.has(ne)||E.has(ne),[T,E]),$=S.useCallback(ne=>{const ge=T.has(ne)||E.has(ne);if(ge&&E.has(ne)){const je=new Set(E);je.delete(ne),N(je)}c({a:"tree-folder",worktreeId:e,path:ne,open:!ge})},[T,E,e,c]),P=S.useMemo(()=>O4(u??jd,p??jd,h??jd),[u,p,h]),R=S.useMemo(()=>M4(P,j),[P,j]),A=S.useMemo(()=>L4(g),[g]),O=M(ne=>ne.treeReveal),B=O&&O.worktreeId===e?O:null,[H,Q]=S.useState(()=>(B==null?void 0:B.path)??null),[re,J]=S.useState({worktreeId:e,linked:B});(re.worktreeId!==e||re.linked!==B)&&(J({worktreeId:e,linked:B}),Q((B==null?void 0:B.path)??null));const[ie,ve]=S.useState(!1),C=S.useMemo(()=>{if(H===null)return-1;const ne=R.findIndex(ge=>ge.path===H);if(ne>=0)return ne;for(const ge of sf(H).reverse()){const je=R.findIndex(Ce=>Ce.path===ge);if(je>=0)return je}return-1},[R,H]);ft([C,ie],()=>{var ne,ge;ie&&((ge=(ne=o.current)==null?void 0:ne.querySelector('[data-state~="cursor"]'))==null||ge.scrollIntoView({block:"nearest"}))});const Z=S.useCallback((ne,ge)=>er({dispatch:c},{worktreeId:e,path:ne,view:wi(ne),focus:ge}),[e,l,c]),Y=S.useCallback(ne=>{Q(ne.path),ne.kind==="folder"?$(ne.path):ne.kind==="file"&&Z(ne.path,!1)},[$,Z]),q=ne=>{var Ce;if(ne.metaKey||ne.ctrlKey||ne.altKey)return;const ge=R[C],je=Se=>{const Me=R[Se];Me&&(Q(Me.path),Me.kind==="file"&&Z(Me.path,!1))};switch(ne.key){case"ArrowDown":case"ArrowUp":ne.preventDefault(),je(C<0?0:su(C,ne.key==="ArrowDown"?1:-1,R.length));return;case" ":ne.preventDefault(),(ge==null?void 0:ge.kind)==="file"?Z(ge.path,!1):(ge==null?void 0:ge.kind)==="folder"&&$(ge.path);return;case"Enter":ne.preventDefault(),(ge==null?void 0:ge.kind)==="file"?Z(ge.path,!0):(ge==null?void 0:ge.kind)==="folder"&&$(ge.path);return;case"ArrowRight":case"ArrowLeft":{ne.preventDefault();const Se=R.map(wt=>wt.kind==="folder"?{depth:wt.depth,open:wt.open}:{depth:wt.depth}),Me=Qf(Se,C,ne.key);(Me==null?void 0:Me.do)==="to"?je(Me.at):Me&&ge&&$(ge.path);return}case"Escape":ne.stopPropagation(),n!==null?c({a:"close-editor"}):(Ce=document.activeElement)==null||Ce.blur();return}if(ne.key.length===1){const Se=KS(R.map(Me=>Me.name),C,ne.key);Se>=0&&(ne.preventDefault(),je(Se))}},[z,te]=S.useState(null),Ee=S.useRef(0),Ne=S.useCallback(ne=>{ne&&!j(ne)&&$(ne),Ee.current++,te({dir:ne,error:null,busy:!1})},[j,$]),de=S.useCallback(()=>{Ee.current++,te(null)},[]),we=S.useCallback(ne=>{if(!z||z.busy)return;const ge=P4(z.dir,ne);if("error"in ge){te({...z,error:ge.error});return}const je=++Ee.current;te({...z,error:null,busy:!0}),xS({sock:l,dispatch:c},{worktreeId:e,path:ge.path}).then(Ce=>{Ce===null&&Q(ge.path),je===Ee.current&&te(Ce===null?null:{...z,error:Ce,busy:!1})})},[z,e,l,c]),ae=vn("tree"),G=S.useCallback(ne=>fz({worktreeId:e,dir:t,path:ne.path,folder:ne.kind!=="file",newIn:ne.kind==="folder"||ne.kind==="ignored"?ne.path:jS(ne.path)},i,{sock:l,dispatch:c},Ne),[e,t,i,l,c,Ne]),ue=S.useCallback((ne,ge)=>{ne.kind==="file"&&an.post(e,ge?{type:"highlight-file",path:ne.path,ranges:null}:{type:"highlight-clear"})},[e]),Le=S.useCallback((ne,ge)=>{ge.dataTransfer.setData($S,ne.path),ge.dataTransfer.setData("text/plain",ne.path),ge.dataTransfer.effectAllowed="copy",Q4({worktreeId:e,path:ne.path,folder:ne.kind!=="file"})},[e]),ke=S.useCallback(()=>RS(i),[i]);return d.jsx("div",{className:We("tree",b===""&&"drop-over"),role:"tree","aria-label":"files","data-worktree":e,"aria-activedescendant":ie&&C>=0?Eb(C):void 0,tabIndex:0,ref:o,onKeyDown:q,onFocus:()=>{var ne;ve(!0),H===null&&Q(n&&R.some(ge=>ge.path===n)?n:((ne=R[0])==null?void 0:ne.path)??null)},onBlur:ne=>!ne.currentTarget.contains(ne.relatedTarget)&&ve(!1),onMouseDown:ne=>{if(ne.button!==0)return;const ge=ne.target.closest("[data-path]");(ge==null?void 0:ge.dataset.path)!==void 0&&Q(ge.dataset.path)},...ae.contextMenu(ne=>{const ge=R[C];return ne==="keyboard"&&ge?G(ge):hz({worktreeId:e},i,{sock:l},Ne)}),children:u===void 0?d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"listing files"})}):R.length===0&&!z?d.jsx("div",{className:"empty",children:"no files"}):gz(R.map((ne,ge)=>d.jsx(wz,{row:ne,id:Eb(ge),status:A.files.get(ne.path),changedInside:ne.kind!=="file"&&A.folders.has(ne.path),current:ie?ge===C:!r&&ne.path===n,cursor:ie&&ge===C,dropOver:b===ne.path,onPress:Y,menu:G,onHover:ue,onDragStart:Le,onDragEnd:ke},ne.path)),z&&(()=>{var ge;const ne=z.dir===""?-1:R.findIndex(je=>je.path===z.dir);return{at:ne,node:d.jsx(kz,{depth:ne>=0?(((ge=R[ne])==null?void 0:ge.depth)??0)+1:0,error:z.error,onSubmit:we,onCancel:de},"new-file")}})())})}function gz(e,t){return t?[...e.slice(0,t.at+1),t.node,...e.slice(t.at+1)]:e}function kz({depth:e,error:t,onSubmit:n,onCancel:r}){const[o,i]=S.useState(""),l={"--tree-depth":e},c=e===0||void 0;return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"row row-sm tree-row row-rails","data-kind":"file","data-root":c,style:l,children:[d.jsx("span",{className:"tree-caret row-dim"}),d.jsx($o,{bare:!0,font:"mono",autoFocus:!0,className:"tree-new-name","aria-label":"new file name","aria-invalid":t!==null||void 0,placeholder:"name",value:o,onChange:u=>i(u.target.value),onKeyDown:u=>{u.stopPropagation(),u.key==="Enter"?(u.preventDefault(),n(o)):u.key==="Escape"&&(u.preventDefault(),r())},onBlur:r})]}),t&&d.jsxs("div",{className:"tree-row tree-new-error row-rails","data-root":c,style:l,children:[d.jsx("span",{className:"tree-caret"}),d.jsx("span",{className:"hint",children:t})]})]})}const wz=S.memo(function({row:t,id:n,status:r,changedInside:o,current:i,cursor:l,dropOver:c,onPress:u,menu:p,onHover:h,onDragStart:m,onDragEnd:g}){const w=vn("tree"),y=t.kind==="submodule",b=y?"A submodule: its files belong to its own repository":t.kind==="ignored"?"Ignored by git, so what is inside is not listed":null;return d.jsxs("div",{role:"treeitem",id:n,"aria-level":t.depth+1,"aria-expanded":t.kind==="folder"?t.open:void 0,"aria-selected":l,className:We("row row-sm tree-row row-rails row-edge",c&&"drop-over"),"data-state":vr({current:i,cursor:l}),"data-kind":t.kind,"data-path":t.path,style:{"--tree-depth":t.depth},draggable:!y,onDragStart:_=>m(t,_),onDragEnd:g,onClick:()=>u(t),onMouseEnter:()=>h(t,!0),onMouseLeave:()=>h(t,!1),...w.contextMenu(()=>p(t)),...b?Ut(b):{},children:[d.jsx("span",{className:"tree-caret row-dim",children:t.kind==="folder"&&d.jsx(kt,{name:"caret",className:We("icon-inline disc-caret",!t.open&&"shut")})}),d.jsx("span",{className:We("tree-name",(y||t.ignored)&&"row-dim"),children:t.name}),r?d.jsx("span",{className:`xy ${sk(r.xy)}`,children:ik(r.xy)}):o&&d.jsx("span",{className:"dot tree-changed"})]})});function m_({f:e}){return e.add===void 0&&e.del===void 0?null:d.jsxs("span",{className:"counts",children:[e.add?d.jsxs("span",{className:"add",children:["+",e.add]}):null,e.del?d.jsxs("span",{className:"del",children:["−",e.del]}):null]})}const Cd=S.memo(function({f:t,id:n,active:r,selected:o,checking:i=!1,checked:l=!1,onOpen:c,onCheck:u,menu:p,onHover:h}){const m=vn("changes"),{name:g,dir:w}=OP(t.path);return d.jsxs("button",{className:"row row-sm git-file row-edge",id:n,"data-state":vr({current:r,cursor:o,checked:l}),role:"option","aria-selected":o,tabIndex:-1,onClick:y=>u&&(i||y.shiftKey)?u(t.path):c(t.path),...m.contextMenu(()=>p(t.path)),onMouseEnter:()=>h(t.path,!0),onMouseLeave:()=>h(t.path,!1),children:[i&&d.jsx("input",{type:"checkbox",className:"changes-check",checked:l,readOnly:!0,tabIndex:-1}),d.jsx("span",{className:`xy ${sk(t.xy)}`,children:ik(t.xy)}),d.jsxs("span",{className:"path","data-tip":w?t.path:void 0,children:[d.jsx("span",{className:"name",children:g}),w&&d.jsx("span",{className:"dir row-dim",children:w})]}),d.jsx(m_,{f:t})]})}),yz={added:"A",changed:"M",removed:"D"},vz={added:"added",changed:"",removed:"deleted"},bz=S.memo(function({tests:t,id:n,cursor:r,onPick:o}){return t.map((i,l)=>d.jsxs("button",{className:"row row-sm changes-test row-rails row-edge",id:`${n}-t${l}`,"data-state":vr({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:[d.jsx("span",{className:`xy ${vz[i.change]}`,children:yz[i.change]}),d.jsx("span",{className:"name",children:i.name})]},l))}),Sb=new Set(["test","tests","__tests__","spec","e2e","__snapshots__","__mocks__","fixtures","testdata"]),xz=/([._-]tests?\.[^.]+$)|([._]specs?\.[^.]+$)|(^tests?[._-])|(^conftest\.py$)|(\.snap$)|([a-z0-9](Tests?|Spec)\.[^.]+$)/;function uf(e){const t=(e.endsWith("/")?e.slice(0,-1):e).split("/"),n=t.pop()??"";return e.endsWith("/")&&Sb.has(n.toLowerCase())?!0:t.some(r=>Sb.has(r.toLowerCase()))||xz.test(n)}function Ad(e){const t=e.filter(n=>!uf(n.path));return t.length===0||t.length===e.length?{files:e,source:t.length}:{files:[...t,...e.filter(n=>uf(n.path))],source:t.length}}const Xm="(?<q>[\"'`])(?<name>(?:\\\\.|(?!\\k<q>).)*)\\k<q>",_b={tests:[new RegExp(`^\\s*(?:test|it)(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Xm}`)],groups:[new RegExp(`^\\s*describe(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Xm}`)]},Ez={js:_b,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*${Xm}`),/^\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*\(/,..._b.tests]}},Sz={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"},_z=3,Nz=/^\s*(?:[)}\]]|end\b)/,Qp=e=>e.length-e.trimStart().length;function Nb(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 Tb(e,t){const n=t.split(`
|
|
120
|
+
`),r=[],o=[];let i=Number.NEGATIVE_INFINITY;return n.forEach((l,c)=>{var g,w,y;if(l.trim()==="")return;const u=Qp(l);for(;o.length>0&&(((g=o.at(-1))==null?void 0:g.indent)??0)>=u;)o.pop();(w=e.mark)!=null&&w.test(l)&&(i=c);const h=!e.mark||c-i<=_z?Nb(l,e.tests):null,m=h??Nb(l,e.groups);if(m!==null){if(h!==null){i=Number.NEGATIVE_INFINITY;let b=c+1;for(;b<n.length&&(((y=n[b])==null?void 0:y.trim())===""||Qp(n[b]??"")>u);)b++;b<n.length&&Qp(n[b]??"")===u&&Nz.test(n[b]??"")&&b++;const _=n.slice(c,b).map(T=>T.trim()).join(`
|
|
121
|
+
`).trim();r.push({group:o.map(T=>T.name),name:m,line:c,end:b,body:_})}o.push({indent:u,name:m})}}),r}function jb(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 Tz(e,t,n){const r=Ez[Sz[e.slice(e.lastIndexOf(".")+1).toLowerCase()]??""];if(!r)return[];const o=jb(Tb(r,t)),i=jb(Tb(r,n)),l=[];for(const[h,m]of i){const g=o.get(h);(g==null?void 0:g.body)!==m.body&&l.push({name:m.name,group:m.group,change:g?"changed":"added",line:m.line+1})}const c=n.split(`
|
|
125
|
+
`).length;let u=1;for(const[h,m]of o){const g=i.get(h);g?u=Math.min(g.end+1,c):l.push({name:m.name,group:m.group,change:"removed",line:u})}const p=h=>h.change==="removed"?0:1;return l.sort((h,m)=>h.line-m.line||p(h)-p(m))}const Id=[];function jz(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=yr(r.at);return`${o}, last commit ${i==="now"?"just now":`${i} ago`}`}const Cb='[role="option"]:not([data-sub])',Ab=[];function g_({width:e,placement:t="dock"}){var ar,Fr;const n=t==="screen",r=it(),o=ut(),i=Yn(),l=_l(),c=fa(),u=(c==null?void 0:c.id)??l,p=$s(),h=M(K=>K.layout.changes),m=nu(),g=M(K=>K.focusChanges),w=Rt(u,"git"),y=M(K=>K.editor&&K.editor.worktreeId===u?K.editor.path:null),b=M(K=>K.editor&&K.editor.worktreeId===u?K.editor.ref??null:null),_=M(K=>K.editor&&K.editor.worktreeId===u?K.editor.since??null:null),T=(w==null?void 0:w.files)??Id,E=((ar=w==null?void 0:w.extras)==null?void 0:ar.committed)??Id,{files:N,source:j}=S.useMemo(()=>Ad(T),[T]),$=E.length>0,P=GL(),{files:R,source:A}=S.useMemo(()=>Ad(P?E:Id),[E,P]),O=(Fr=w==null?void 0:w.extras)==null?void 0:Fr.turn,B=O==null?void 0:O.base,H=VL(),{files:Q,source:re}=S.useMemo(()=>Ad(O&&H?O.files:Id),[O,H]),J=N.length,ie=N.length+Q.length,ve=M(K=>K.editor&&K.editor.worktreeId===u?K.editor.disk:null),C=S.useMemo(()=>y!==null&&ve&&uf(y)?Tz(y,ve.before,ve.after):Ab,[y,ve]),[Z,Y]=S.useState(!1);ft([y,b,_],()=>Y(!1));const q=j>0?N.length-j:0,z=A>0?R.length-A:0,te=re>0?Q.length-re:0,Ee=N.length===0,Ne=S.useMemo(()=>{if(N.length===0)return;const K=N.reduce((gt,qt)=>gt+(qt.add??0),0),fe=N.reduce((gt,qt)=>gt+(qt.del??0),0),Qe=[K>0&&`+${K}`,fe>0&&`−${fe}`].filter(Boolean).join(" "),At=`${N.length} uncommitted ${N.length===1?"file":"files"}`;return Qe?`${At}, ${Qe}`:At},[N]),de=!!w&&Ee&&(w.ahead??0)===0,we=M(gl),ae=c!==null||we==="changes",G=c!==null||we==="history",ue=S.useCallback(K=>o({a:"changes-tab",v:K}),[o]),Le=S.useRef(we);Le.current=we;const ke=S.useRef(null),ne=xk(),ge=M(K=>{const fe=Ei(K,ne==null?void 0:ne.repoId);return fe?Tf(fe):"main"}),je=Rt(u,"commits"),Ce=Rt(u,"commitFiles"),[Se,Me]=S.useState(null),wt=S.useRef(null);wt.current=Se;const on=S.useRef(null),St=Rt(u,"changedRanges"),Yt=S.useCallback((K,fe)=>{if(!u||c)return;if(!fe){on.current=null,an.post(u,{type:"highlight-clear"});return}on.current=K;const Qe=St[K];Qe?an.post(u,{type:"highlight-file",path:K,ranges:O0(Qe)}):r==null||r.send({t:"changed-ranges",worktreeId:u,path:K})},[u,c,St,r]);S.useEffect(()=>{const K=on.current;if(!K||!u)return;const fe=St[K];fe&&an.post(u,{type:"highlight-file",path:K,ranges:O0(fe)})},[St,u]);const zt=c&&N.length>0?(w==null?void 0:w.head)??null:null,Ht=S.useCallback((K,fe=!1,Qe)=>u&&er({dispatch:o},{worktreeId:u,path:K,focus:fe,ref:zt??void 0,since:Qe}),[u,zt,r,o]),De=S.useMemo(()=>c?N:[...N,...Q,...R],[c,N,Q,R]),_t=S.useMemo(()=>{const K=[];for(const fe of je??[])if(K.push({commit:fe}),fe.sha===Se)for(const Qe of Ad(Ce[fe.sha]??[]).files)K.push({commit:fe,file:Qe});return K},[je,Se,Ce]),sn=S.useMemo(()=>_t.filter(K=>!K.file&&K.commit.ahead).length,[_t]),ln=S.useMemo(()=>_t.findIndex(K=>!K.file&&!K.commit.ahead),[_t]),lt=c?De.length:0,jt=(ae?De.length:0)+(G?_t.length:0),Kt=S.useMemo(()=>{const K=new Map;if(!c||N.length===0&&_t.every(Qe=>Qe.commit.landedAt))return K;let fe;return _t.forEach((Qe,At)=>{const gt=!!Qe.commit.landedAt;gt!==fe&&(fe=gt,K.set(At,gt?"landed":"not landed"))}),K},[c,N,_t]),xn=S.useRef(null),[{row:Pt,at:jn},Qt]=S.useReducer((K,fe)=>typeof fe=="number"?{row:fe,at:-1}:fe,{row:0,at:-1}),[V,pe]=S.useState(!1),Ye=(K,fe)=>V?Xn(K):fe,nt=K=>`changes-row-${K}`,[yt,Jt]=S.useState(!1),[ye,Ie]=S.useState([]),Xt=S.useCallback(()=>{Jt(!1),Ie([])},[]),U=S.useCallback(K=>{Jt(!0),Ie(fe=>fe.includes(K)?fe.filter(Qe=>Qe!==K):[...fe,K])},[]),me=S.useMemo(()=>N.filter(K=>ye.includes(K.path)).map(K=>K.path),[N,ye]);ft([N],()=>Ie(K=>{const fe=K.filter(Qe=>N.some(At=>At.path===Qe));return fe.length===K.length?K:fe})),ft([yt],()=>{if(!yt)return;const K=fe=>fe.key==="Escape"&&Xt();return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)}),ft([u,we],()=>{Qt(0),Xt()});const ze=w==null?void 0:w.head,Xe=S.useRef("");S.useEffect(()=>{if(!(G||de)||!u)return;const K=`${u}:${ze??""}`;Xe.current!==K&&(Xe.current=K,r==null||r.send({t:"git-log",worktreeId:u}))},[G,de,u,ze,r]);const Mt=S.useCallback(K=>{Me(fe=>fe===K?null:K),u&&!Ce[K]&&(r==null||r.send({t:"git-commit",worktreeId:u,sha:K}))},[u,Ce,r]);ft([Pt,jn,V],()=>{var K,fe;V&&((fe=(K=xn.current)==null?void 0:K.querySelector('[data-state~="cursor"]'))==null||fe.scrollIntoView({block:"nearest"}))});const Nt=S.useRef(-1),He=K=>K>=J&&K<ie?B:void 0,Fe=K=>{var fe;return((fe=De[K])==null?void 0:fe.path)===y&&(_??void 0)===He(K)&&(K<J?b===zt:!b)};Nt.current=ae?De.findIndex((K,fe)=>Fe(fe)):-1,S.useEffect(()=>{if(!g)return;const K=Le.current==="files";Nt.current>=0&&Qt(Nt.current);const fe=requestAnimationFrame(()=>{var Qe;return(Qe=(K?ke:xn).current)==null?void 0:Qe.focus()});return()=>cancelAnimationFrame(fe)},[g]);const Ke=S.useCallback((K,fe=!1)=>{const Qe=De[K];Qe&&(Qt(K),Ht(Qe.path,fe,K>=J&&K<ie?B:void 0),Yt(Qe.path,!0))},[De,Ht,Yt,J,ie,B]),ht=S.useCallback((K,fe=!1)=>{const Qe=wt.current;u&&Qe&&er({dispatch:o},{worktreeId:u,path:K,ref:Qe,focus:fe})},[u,r,o]),Ct=S.useCallback(K=>{const fe=_t[K-lt];fe&&(Qt(K),fe.file&&ht(fe.file.path))},[_t,lt,ht]),Ft=S.useCallback(K=>{const fe=_t[K-lt];fe&&(Qt(K),fe.file?ht(fe.file.path,!0):Mt(fe.commit.sha))},[_t,lt,ht,Mt]),Zt=K=>G&&K>=lt,bn=K=>{if(y===null)return!1;if(ae&&K<De.length)return Fe(K);const fe=Zt(K)?_t[K-lt]:void 0;return!!(fe!=null&&fe.file)&&b===fe.commit.sha&&fe.file.path===y},On=K=>bn(K)&&!Z?C:Ab,Cn=jn<On(Pt).length?jn:-1,Xn=K=>V&&Pt===K&&Cn<0,Hn=()=>{var fe,Qe;const K=[];for(let At=0;At<jt;At++){const gt=Zt(At)?_t[At-lt]:void 0,qt=gt?(fe=gt.file)==null?void 0:fe.path:(Qe=De[At])==null?void 0:Qe.path,Br=gt!=null&>.file?1:0,hr=On(At);gt&&!gt.file?K.push({row:At,at:-1,depth:Br,open:gt.commit.sha===Se}):qt!==void 0&&uf(qt)?K.push({row:At,at:-1,depth:Br,open:hr.length>0}):K.push({row:At,at:-1,depth:Br});for(let vo=0;vo<hr.length;vo++)K.push({row:At,at:vo,depth:Br+1})}return K},se=(K,fe=!1)=>{const Qe=C[K];!Qe||!u||y===null||er({dispatch:o},{worktreeId:u,path:y,ref:b??void 0,since:_??void 0,line:{n:Qe.line},focus:fe})},_e=K=>On(K).length>0&&d.jsx(bz,{tests:C,id:nt(K),cursor:V&&Pt===K?Cn:-1,onPick:fe=>{Qt({row:K,at:fe}),se(fe)}}),at=K=>{var fe;if(yt&&K.key==="Escape")K.preventDefault(),K.stopPropagation(),Xt();else if(yt&&K.key===" "){K.preventDefault();const Qe=ae&&Pt<N.length?N[Pt]:void 0;Qe&&U(Qe.path)}else if(K.key==="ArrowDown"&&Cn+1<On(Pt).length)K.preventDefault(),Qt({row:Pt,at:Cn+1}),se(Cn+1);else if(K.key==="ArrowUp"&&Cn>=0)K.preventDefault(),Cn===0?Qt(Pt):(Qt({row:Pt,at:Cn-1}),se(Cn-1));else if(K.key==="Enter"&&Cn>=0)K.preventDefault(),se(Cn,!0);else if(K.key==="ArrowDown"||K.key==="ArrowUp"){K.preventDefault();const Qe=su(Pt,K.key==="ArrowDown"?1:-1,jt);Zt(Qe)?Ct(Qe):Ke(Qe)}else if(K.key==="Enter")K.preventDefault(),Zt(Pt)?Ft(Pt):Ke(Pt,!0);else if(K.key==="ArrowRight"||K.key==="ArrowLeft"){K.preventDefault();const Qe=Hn(),At=Qf(Qe,Qe.findIndex(Br=>Br.row===Pt&&Br.at===Cn),K.key),gt=At&&Qe[At.at];if(!At||!gt)return;const qt=Zt(gt.row)?_t[gt.row-lt]:void 0;At.do==="to"?gt.at>=0?(Qt({row:gt.row,at:gt.at}),se(gt.at)):qt!=null&&qt.file&>.row>Pt?Ct(gt.row):Qt(gt.row):qt&&!qt.file?Mt(qt.commit.sha):At.do==="close"?Y(!0):bn(gt.row)?Y(!1):qt!=null&&qt.file?Ct(gt.row):Ke(gt.row)}else K.key==="Escape"&&(K.stopPropagation(),y!==null?o({a:"close-editor"}):(fe=document.activeElement)==null||fe.blur())},mt=c?c.id:p==null?void 0:p.worktree.id,Wt=c?c.path:p?p.worktree.path:"",kn=c!==null,wn=S.useCallback(K=>mt?js({id:mt,dir:Wt},K,{discard:!kn,kept:kn,ref:zt??void 0,select:kn?void 0:U},{sock:r,dispatch:o}):[],[mt,Wt,kn,zt,U,r,o]),tr=S.useCallback(K=>mt?js({id:mt,dir:Wt},K,{kept:kn},{sock:r,dispatch:o}):[],[mt,Wt,kn,r,o]),fn=S.useCallback(K=>mt?js({id:mt,dir:Wt},K,{kept:kn,since:B},{sock:r,dispatch:o}):[],[mt,Wt,kn,B,r,o]),hn=S.useCallback(K=>mt?js({id:mt,dir:Wt},K,{ref:wt.current??void 0,kept:kn},{sock:r,dispatch:o}):[],[mt,Wt,kn,r,o]),Tt=vn("changes"),zr=()=>{if(ae&&Pt<De.length){const fe=De[Pt];return fe?(Pt<J?wn:Pt<ie?fn:tr)(fe.path):[]}const K=Zt(Pt)?_t[Pt-lt]:void 0;return K?K.file?hn(K.file.path):XS(K.commit):[]},pt=(K,fe)=>{const Qe=De.findIndex((At,gt)=>gt>=K&&At.path===fe);Qt(Qe),Fe(Qe)&&C.length>0?Y(At=>!At):Ht(fe,!1,He(Qe))},In=S.useRef(pt);In.current=pt;const Te=S.useCallback(K=>In.current(0,K),[]),Ge=S.useCallback(K=>In.current(J,K),[J]),rt=S.useCallback(K=>In.current(ie,K),[ie]),et=S.useCallback(K=>{Qt(lt+_t.findIndex(fe=>!fe.file&&fe.commit.sha===K)),Mt(K)},[_t,lt,Mt]),cn=S.useCallback(K=>{Qt(lt+_t.findIndex(fe=>{var Qe;return((Qe=fe.file)==null?void 0:Qe.path)===K})),K===y&&b===wt.current&&C.length>0?Y(fe=>!fe):ht(K)},[_t,lt,ht,y,b,C]),yn=S.useCallback(()=>{},[]);return d.jsxs("div",{className:We("changes-dock",n&&"changes-screen",!n&&(!h||m)&&"collapsed"),style:n?void 0:{width:e},children:[!c&&d.jsx(Xf,{fill:!n,quiet:n,owner:"changes-tabs",label:"changes panel",items:[{id:"files",label:d.jsx(kt,{name:"folder",className:"icon-inline"}),fit:!0,ariaLabel:"files",tip:Ut("files",Dt("files"))},{id:"changes",label:"changes",tip:Ut("changes",Dt("changes"),{detail:Ne})},{id:"history",label:"history"}],current:we,onPick:ue}),we==="files"&&u?d.jsx(mz,{worktreeId:u,dir:p?p.worktree.path:(ne==null?void 0:ne.path)??"",openPath:y,openRef:b,rootRef:ke}):d.jsxs("div",{className:We("changes-list",G&&"history"),role:"listbox","aria-label":c?"kept work":G?"commits":"changed files","aria-activedescendant":V&&Pt>=0&&Pt<jt?Cn<0?nt(Pt):`${nt(Pt)}-t${Cn}`:void 0,tabIndex:0,ref:xn,onKeyDown:at,onFocus:()=>pe(!0),onMouseDown:K=>{var At;if(K.button!==0)return;K.preventDefault();const fe=K.target.closest(Cb),Qe=fe?Array.from(K.currentTarget.querySelectorAll(Cb)).indexOf(fe):-1;Qe>=0&&Qt(Qe),(At=xn.current)==null||At.focus()},onBlur:K=>!K.currentTarget.contains(K.relatedTarget)&&pe(!1),...Tt.contextMenu(K=>K==="keyboard"?zr():[]),children:[ae&&N.length>0&&d.jsxs(d.Fragment,{children:[($||((w==null?void 0:w.ahead)??0)>0||c)&&d.jsx("div",{className:"section-title section-row",children:"uncommitted"}),N.map((K,fe)=>d.jsxs(S.Fragment,{children:[q>0&&fe===j&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(Cd,{f:K,id:nt(fe),active:Ye(fe,bn(fe)),selected:Xn(fe),checking:yt,checked:ye.includes(K.path),onOpen:Te,onCheck:kn?void 0:U,menu:wn,onHover:Yt}),_e(fe)]},`${K.xy}:${K.path}`))]}),ae&&!c&&O&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":H,"data-tip":"What changed since your last message","data-tip-placement":"follow",onClick:()=>o({a:"toggle-turn"}),onKeyDown:K=>(K.key==="Enter"||K.key===" ")&&K.stopPropagation(),children:["last turn",d.jsx(kt,{name:"caret",className:We("icon-inline disc-caret",!H&&"shut")})]}),Q.map((K,fe)=>d.jsxs(S.Fragment,{children:[te>0&&fe===re&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(Cd,{f:K,id:nt(J+fe),active:Ye(J+fe,bn(J+fe)),selected:Xn(J+fe),onOpen:Ge,menu:fn,onHover:Yt}),_e(J+fe)]},`t-${K.path}`))]}),ae&&!c&&$&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":P,"data-tip":`Committed on this branch, not yet on ${ge}`,"data-tip-placement":"follow",onClick:()=>o({a:"toggle-committed"}),onKeyDown:K=>(K.key==="Enter"||K.key===" ")&&K.stopPropagation(),children:["committed",d.jsx(kt,{name:"caret",className:We("icon-inline disc-caret",!P&&"shut")})]}),R.map((K,fe)=>d.jsxs(S.Fragment,{children:[z>0&&fe===A&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx(Cd,{f:K,id:nt(ie+fe),active:Ye(ie+fe,bn(ie+fe)),selected:Xn(ie+fe),onOpen:rt,menu:tr,onHover:Yt}),_e(ie+fe)]},`c-${K.path}`))]}),ae&&!c&&de&&d.jsx("div",{className:"empty",children:jz(ge,!!ne&&Nf(ne),(w==null?void 0:w.behind)??0,je==null?void 0:je[0])}),G&&_t.map((K,fe)=>d.jsxs(S.Fragment,{children:[c&&Kt.has(fe)&&d.jsx("div",{className:"section-title section-row",children:Kt.get(fe)}),!c&&sn>0&&fe===0&&d.jsx("div",{className:"section-title section-row",children:"on this branch"}),!c&&sn>0&&fe===ln&&d.jsx("div",{className:"section-title section-row",children:ge}),K.file?d.jsxs(d.Fragment,{children:[d.jsx(Cd,{f:K.file,id:nt(lt+fe),active:Ye(lt+fe,bn(lt+fe)),selected:Xn(lt+fe),onOpen:cn,menu:hn,onHover:yn}),_e(lt+fe)]}):d.jsx(uz,{c:K.commit,id:nt(lt+fe),selected:Xn(lt+fe),onToggle:et})]},K.file?`${K.commit.sha}:${K.file.path}`:K.commit.sha)),G&&je===void 0&&d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"reading history"})}),G&&(je==null?void 0:je.length)===0&&N.length===0&&d.jsx("div",{className:"empty",children:"no commits yet"})]}),yt&&d.jsxs("div",{className:"changes-pick",children:[d.jsxs(Be,{size:"md",tone:"danger",disabled:me.length===0,"data-tip":"Throw away the uncommitted changes to every checked file",onClick:()=>{!mt||me.length===0||window.confirm(ES(me))&&(r==null||r.send({t:"discard-files",worktreeId:mt,paths:me}),Xt())},children:["discard ",me.length,"…"]}),d.jsx(Be,{size:"md",disabled:me.length===0,"data-tip":"Name every checked file in the chat",onClick:()=>{mt&&A4(i,mt,me),Xt()},children:"add to chat"}),d.jsx(Ot,{icon:"close",label:"Cancel",hint:"esc",onClick:Xt})]}),ne&&!c&&d.jsx(cz,{active:ne,ahead:(w==null?void 0:w.ahead)??ne.ahead??0,behind:(w==null?void 0:w.behind)??ne.behind??0,unpushed:(w==null?void 0:w.unpushed)??ne.unpushed??0,dirty:!Ee})]})}function Cz(e){var t;if((e==null?void 0:e.kind)==="account")return[(t=e.account)==null?void 0:t.email,e.label].filter(Boolean).join(" · ")}function Ib(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 iu(e){return e>0&&e<.005?"<$0.01":`$${e.toFixed(2)}`}function Az(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 Iz(e){if(!(e<.5))return e<.8?"worth compacting between tasks":"compact before the next task"}const k_=["five_hour","seven_day"],$z={five_hour:"the 5-hour window",seven_day:"the week"},Rz={five_hour:"5-hour",seven_day:"this week"};function w_(e,t){return k_.flatMap(n=>{const r=e.windows[n];return r&&r.resetsAt>t?[{key:n,used:r.used,resetsAt:r.resetsAt}]:[]})}function Oz(e,t){return Math.min(1,Math.max(0,...w_(e,t).map(n=>n.used)))}const Mz=e=>`${Math.round(100*e)}%`;function $b(e,t){const n=w_(e,t).map(r=>`${Mz(r.used)} of ${$z[r.key]}`);return n.length?n.join(", "):"plan windows reset"}function Pz(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 Lz(e,t,n=r=>Pz(r,t)){return k_.flatMap(r=>{const o=e.windows[r];if(!o)return[];const i=Rz[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 Dz(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 y_(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(iu(e.cost)),t.push(yr(e.archivedAt)),t.filter(Boolean).join(" · ")}function v_({sock:e},t,n){e==null||e.send({t:"restore-worktree",archiveId:t,clientId:n})}function Kd(e,t,{sock:n,dispatch:r}){const o=[{id:"restore",label:"restore",disabled:e.restorable?void 0:"its commits were not kept",onClick:()=>{v_({sock:n},e.id,t.clientId),r({a:"close"})}}],i=[{id:"copy-branch",label:"copy branch name",onClick:()=>en(e.branch)}],{sessionId:l}=e;return t.frame!=="phone"&&(i.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>en(e.transcript)}),l&&i.push({id:"copy-session",label:"copy session id",onClick:()=>en(l)})),zn([o,i,[{id:"delete",label:"delete…",danger:!0,onClick:()=>{window.confirm(`Delete "${e.title}"?
|
|
126
|
+
|
|
127
|
+
Its chat, attachments and kept commits go with it, and it cannot be restored.`)&&(n==null||n.send({t:"delete-archived",archiveId:e.id}))}}]])}const zz=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function b_(e){const[t,n]=S.useState(()=>Date.now());return S.useEffect(()=>{const r=setInterval(()=>n(Date.now()),6e4);return()=>clearInterval(r)},[]),`${ck(t-e)} ago`}function to({icon:e,word:t,tone:n,at:r,below:o,children:i,...l}){const c=r!==void 0?{"data-tip":`${t} ${zz.format(r)}`,"data-tip-placement":"top"}:null;return d.jsxs("div",{...l,className:"daemon-row row-edge","data-tone":n,children:[d.jsxs("div",{className:"daemon-head",children:[d.jsxs("span",{...c,className:"daemon-tag",children:[d.jsx(kt,{name:e,className:"icon-inline"}),t]}),i]}),o]})}function Fz({item:e}){const t=it(),n=M(u=>u.clientId),r=e.uncommitted?"its chat, commits and uncommitted changes":"its chat and commits",o=e.cost!==void 0?`; the session cost ${iu(e.cost)}`:"",i=e.restorable?`Toyon kept ${r}${o}. A message sent below restores it first.`:`Its commits were not kept, so there is nothing to restore${o}; its row's menu on the rail can delete it.`,l=b_(e.archivedAt),c=Lk(e.lands);return d.jsxs(to,{icon:"archive",word:"archived",tone:"quiet",at:e.archivedAt,below:d.jsxs(d.Fragment,{children:[c.map((u,p)=>d.jsx("div",{className:"daemon-below row-dim",children:u},p)),d.jsx("div",{className:"daemon-below row-dim",children:i})]}),children:[d.jsxs("span",{className:"daemon-text",children:[l,e.landed?", after it was merged into main":""]}),e.restorable&&d.jsx(Be,{variant:"inline",tone:"strong",onClick:()=>v_({sock:t},e.id,n),children:"restore"})]})}function sa(e,t,n,r,o){const{layout:i}=e.getState();er({dispatch:e.dispatch},{worktreeId:n,path:r,view:"file",line:{n:o,fiber:!0}}),i.changes||e.dispatch({a:"toggle-changes"})}function Bz(e){let t=0;return e.map(n=>{const r={start:t,len:n};return t+=n,r})}function Uz(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 Rb(e,t,n){let r=0,o=e.length-1;for(;r<o;){const l=r+o>>1,c=e[l];(n?t>c.start+c.len:t>=c.start+c.len)?r=l+1:o=l}const i=e[r];return{i:r,at:t-i.start}}function Hz(e,t){return{from:Rb(e,t.start,!1),to:Rb(e,t.end,!0)}}function Ob(e,t){if(e.length===0)return-1;const n=e.findIndex(r=>r.start>=t);return n===-1?0:n}function Wz(e,t,n){return t===0?-1:(e+n+t)%t}function Uk(e){return e.key==="f"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function Kz({label:e,query:t,onQuery:n,seed:r,seq:o,status:i,none:l,onStep:c,onClose:u}){const p=S.useRef(null);return ft([o],()=>{var h,m;r&&n(r),(h=p.current)==null||h.focus(),(m=p.current)==null||m.select()}),d.jsxs("div",{className:"find",children:[d.jsx($o,{ref:p,autoFocus:!0,value:t,onChange:h=>n(h.target.value),placeholder:"find…","aria-label":e,className:"find-field",spellCheck:!1,onKeyDown:h=>{if(h.key==="Escape"){h.preventDefault(),h.stopPropagation(),u();return}if(h.key==="Enter"){h.preventDefault(),c(h.shiftKey?-1:1);return}if(Uk(h)){h.preventDefault(),h.stopPropagation(),h.currentTarget.select();return}h.key.toLowerCase()==="g"&&(h.metaKey||h.ctrlKey)&&!h.altKey&&(h.preventDefault(),h.stopPropagation(),c(h.shiftKey?-1:1))}}),d.jsx("span",{className:"find-count","aria-live":"polite",children:i}),d.jsx(Ot,{icon:"caret",label:"Previous match",hint:"⇧↩",className:"find-prev",disabled:l,onClick:()=>c(-1)}),d.jsx(Ot,{icon:"caret",label:"Next match",hint:"↩",disabled:l,onClick:()=>c(1)}),d.jsx(Ot,{icon:"close",label:"Close",hint:"esc",onClick:u})]})}const x_="find",E_="find-current",S_=typeof CSS<"u"&&"highlights"in CSS;function Zz(e){const t=e.parentElement;return t?typeof t.checkVisibility=="function"?t.checkVisibility():!0:!1}function qz(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&&Zz(o)&&n.push(o)}return n}const Qm={matches:[],ranges:[]};function Gz(e,t){if(!t)return Qm;const n=qz(e),r=Uz(n.map(l=>l.data).join(""),t),o=Bz(n.map(l=>l.data.length)),i=r.map(l=>{const{from:c,to:u}=Hz(o,l),p=document.createRange();return p.setStart(n[c.i],c.at),p.setEnd(n[u.i],u.at),p});return{matches:r,ranges:i}}function Vz(e,t){S_&&(CSS.highlights.set(x_,new Highlight(...e.filter((n,r)=>r!==t))),CSS.highlights.set(E_,new Highlight(...e[t]?[e[t]]:[])))}function Yz(){S_&&(CSS.highlights.delete(x_),CSS.highlights.delete(E_))}function Xz(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 Mb=48;function Qz(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect();n.top>=r.top+Mb&&n.bottom<=r.bottom-Mb||(e.scrollTop+=n.top-r.top-r.height/3)}function __({root:e,body:t,seed:n,seq:r,onClose:o,onReveal:i}){const[l,c]=S.useState(n),[u,p]=S.useState(Qm),[h,m]=S.useState(-1),g=S.useRef({found:Qm,at:-1}),w=S.useRef(""),y=S.useRef(!1),[b,_]=S.useState(0);S.useLayoutEffect(()=>{const j=t.current;if(!j)return;let $=0;const P=new MutationObserver(()=>{$||($=requestAnimationFrame(()=>{$=0,_(R=>R+1)}))});return P.observe(j,{childList:!0,characterData:!0,subtree:!0,attributes:!0}),()=>{P.disconnect(),$&&cancelAnimationFrame($)}},[t]),S.useLayoutEffect(()=>{const j=t.current;if(!j)return;const $=Gz(j,l),P=l!==w.current;w.current=l,P&&(y.current=!0);const{found:R,at:A}=g.current;let O;P?R.matches[A]?O=Ob($.matches,R.matches[A].start):O=e.current?Xz($.ranges,e.current):Ob($.matches,0):O=Math.min(A,$.matches.length-1),g.current={found:$,at:O},p($),m(O)},[l,b]),S.useLayoutEffect(()=>{Vz(u.ranges,h);const j=u.ranges[h];j&&(y.current&&e.current&&(Qz(e.current,j),i==null||i()),y.current=!1)},[u,h,e,i]),S.useLayoutEffect(()=>Yz,[]);const T=u.matches.length,E=j=>{if(T===0)return;y.current=!0;const $=Wz(g.current.at,T,j);g.current={...g.current,at:$},m($)},N=()=>o(u.ranges[h]??null);return d.jsx(Kz,{label:"find in this document",query:l,onQuery:c,seed:n,seq:r,status:l?T===0?"no matches":`${h+1}/${T}`:"",none:T===0,onStep:E,onClose:N})}function N_(e){return e.key==="a"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function T_(e,t,n,r){S.useEffect(()=>{let o=!1;const i=c=>{o=!!e.current&&c.target instanceof Node&&e.current.contains(c.target)},l=c=>{const u=e.current;if(!u||c.defaultPrevented||!t(c))return;const p=document.activeElement;!(p&&p!==document.body?u.contains(p):o)&&!(r!=null&&r(p))||(c.preventDefault(),n(u,c))};return window.addEventListener("pointerdown",i,!0),window.addEventListener("keydown",l),()=>{window.removeEventListener("pointerdown",i,!0),window.removeEventListener("keydown",l)}},[e,t,n,r])}function Jz(e){T_(e,N_,j_)}function Jm(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 j_(e){const t=document.createRange();t.selectNodeContents(e);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}function e3(e){return e.shiftKey||e.altKey||e.metaKey||e.ctrlKey?null:e.key==="ArrowLeft"?-1:e.key==="ArrowRight"?1:null}function t3(e,t,n){const r=e+n;return r<0||r>=t?null:r}const C_=S.createContext(null),n3="input, textarea, [contenteditable]";function Pb(e){return[...e.values()].filter(t=>{var n;return(n=t.el())==null?void 0:n.isConnected}).sort((t,n)=>{const r=t.el(),o=n.el();return!r||!o||r===o?0:r.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1})}function th({children:e}){const t=S.useRef(new Map),[n,r]=S.useState(null),o=S.useRef(n);o.current=n;const i=S.useMemo(()=>{const c=u=>{const p=Pb(t.current),h=p.findIndex(m=>m.id===u);r(h<0?null:{id:u,at:h,of:p.length})};return{register(u){return t.current.set(u.id,u),()=>{var p;t.current.delete(u.id),((p=o.current)==null?void 0:p.id)===u.id&&r(null)}},open:c,step(u){const p=o.current;if(!p)return;const h=Pb(t.current),m=h.findIndex(y=>y.id===p.id),g=m<0?null:t3(m,h.length,u),w=g===null?void 0:h[g];w&&c(w.id)},close(){var h,m,g;const u=o.current;if(r(null),!u)return;const p=document.activeElement;p!=null&&p.matches(n3)||(g=(m=(h=t.current.get(u.id))==null?void 0:h.el())==null?void 0:m.querySelector(".chip-link"))==null||g.focus({preventScroll:!0})}}},[]),l=S.useMemo(()=>({api:i,shown:n}),[i,n]);return d.jsx(C_.Provider,{value:l,children:e})}function r3(e,t){const n=S.useContext(C_),r=S.useId(),[o,i]=S.useState(!1),l=n==null?void 0:n.api;if(S.useLayoutEffect(()=>{if(!(!l||!t))return l.register({id:r,el:()=>e.current})},[l,r,t,e]),!l)return{open:o,show:()=>i(!0),close:()=>i(!1),nav:void 0};const c=(n==null?void 0:n.shown)??null,u=(c==null?void 0:c.id)===r;return{open:u,show:()=>l.open(r),close:l.close,nav:u&&c?{at:c.at,of:c.of,step:l.step}:void 0}}const o3=e=>e.t==="open-path"||e.t==="open-loose",ea=new Map,s3=16;function eg({sock:e,dispatch:t},n,r){const o=A_({worktreeId:n,href:r.href});t({a:"link-refused",id:n,v:null}),e==null||e.send({t:"open-by-path",path:r.path,seq:o})}function i3(e,t){e==null||e.send({t:"open-by-path",path:t,seq:A_(null)})}function A_(e){const t=Go();ea.set(t,e);for(const n of ea.keys()){if(ea.size<=s3)break;ea.delete(n)}return t}function a3(e,t){if(!ea.has(t.seq))return;const n=ea.get(t.seq);ea.delete(t.seq),n?e.dispatch({a:"link-refused",id:n.worktreeId,v:{href:n.href,message:t.message}}):e.dispatch({a:"server",msg:{t:"error",message:t.message}})}function l3(e,t,n){var i;const r=e.getState();if(n.t==="open-path"){const l={dispatch:u=>e.dispatch(u)};if(yo(r,n.worktreeId)){r.activeId!==n.worktreeId&&e.dispatch({a:"activate",id:n.worktreeId}),er(l,{worktreeId:n.worktreeId,path:n.path});return}const c=Object.keys(r.trunks).find(u=>{var p;return((p=r.trunks[u])==null?void 0:p.id)===n.worktreeId});if(!c)return;if(((i=yo(r,r.activeId))==null?void 0:i.repoId)!==c){const u=r.rows.find(p=>p.repoId===c);if(!u)return;e.dispatch({a:"activate",id:u.id})}er(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:Go()}})}function Hk({open:e,remove:t},n){const r=n==null?void 0:n.sock,o=n&&r?()=>r.send({t:"reveal-attachment",worktreeId:n.worktreeId,file:n.file}):void 0,i=n&&r?r.urls.attachmentWhere(n.worktreeId,n.file):void 0;return[[...e?[{id:"open",label:"open full size",onClick:e}]:[],...Qo(o,Xo(r),"reveal the copy")],i?[{id:"copy-path",label:"copy path",onClick:()=>yS(i)}]:[],t?[{id:"remove",label:"remove",onClick:t}]:[]]}function Hc(e,t={},n){return zn([[{id:"copy-image",label:"copy image",onClick:()=>v4(e)}],...Hk(t,n)])}function I_({text:e,href:t}){return e!==void 0?[{id:"copy-text",label:"copy text",onClick:()=>en(e)}]:t?[{id:"copy-text",label:"copy text",onClick:()=>yS(t)}]:[]}function c3(e,t={}){return zn([I_(e),...Hk(t)])}function u3(e,t={},n){return zn([I_(e),...Hk(t,n)])}function d3(e){return[kS(e),{id:"copy-link",label:"copy link",onClick:()=>en(e)}]}function $_(e,t,n){if(!t)return null;if(e.kind==="outside")return()=>eg(n,t,e);if(e.kind==="path")return()=>eg(n,t,{href:e.path,path:e.path});if(e.kind!=="file")return null;const r=e.file;return r.folder?()=>N4(n,{worktreeId:t,path:r.path}):()=>er(n,{worktreeId:t,path:r.path,...r.line?{line:{n:r.line}}:{}})}function f3(e,t,n){const r=$_(e,t,n),{sock:o}=n,i=e.kind==="file"?t?()=>o==null?void 0:o.send({t:"reveal",worktreeId:t,path:e.file.path}):void 0:()=>o==null?void 0:o.send({t:"reveal-path",path:e.path}),l=e.kind==="file"?e.file.path:e.path;return[[...r?[{id:"open",label:"open",onClick:r}]:[],...Qo(i,Xo(o))],[{id:"copy-path",label:"copy path",onClick:()=>en(l)}]]}function tg(e){return e?[{id:"copy-code",label:"copy code",onClick:()=>en(e)}]:[]}function Ki(e,t,n,r={}){const{dispatch:o,sock:i}=n,l=r.link,c=l?l.kind==="out"?[d3(l.href)]:f3(l,t,n):[],u=[{id:"copy",label:"copy message",onClick:()=>en(e.text)}],p=[];return e.kind==="user"&&t&&p.push({id:"draft",label:"edit in composer",onClick:()=>{const h=e.seq;if(h===void 0||!i)return o({a:"set-draft",id:t,text:e.text});o({a:"set-draft",id:t,text:""}),i.send({t:"redraft",worktreeId:t,seq:h})}}),zn([tg(r.code),...c,u,p])}function R_(e,t,n){return[Qo(t,n),[{id:"copy-path",label:"copy path",onClick:()=>en(e)}]]}function Wk(e,t,n){return zn(R_(e,t,n))}function h3(e,t){const n=e.callFile??e.file,r=n?R_(n,void 0,t.host):[],o=t.remove?[{id:"remove",label:"remove",onClick:t.remove}]:[];return zn([...r,o])}const Lb=8,p3=.7,m3=100,g3=400,k3=260,w3=80,y3=220;function Db({dx:e,dy:t}){return Math.abs(e)<Lb&&Math.abs(t)<Lb?null:Math.abs(t)>Math.abs(e)?"away":"other"}function v3(e,t){const n=e.filter(i=>t-i.t<=m3),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 b3=e=>Math.abs(e)>=p3;function x3(e,t){return Math.min(y3,Math.max(w3,e/Math.abs(t)))}function E3(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,c=[],u=0;const p=(b,_,T)=>{T!==void 0&&o.style.setProperty("--swipe-ms",`${T}ms`),o.dataset.swipe!==_&&(o.dataset.swipe=_,o.offsetWidth),o.style.setProperty("--swipe-y",`${b}px`),o.style.setProperty("--swipe-fade",`${Math.min(1,Math.abs(b)/(window.innerHeight/2))}`)},h=()=>{o.style.removeProperty("--swipe-y"),o.style.removeProperty("--swipe-fade"),o.style.removeProperty("--swipe-ms"),delete o.dataset.swipe},m=()=>{const b=l;i=null,l=!1,c=[],b&&(p(0,"settle"),u=window.setTimeout(h,k3))},g=b=>{var E;const _=b.touches[0],T=b.target;if(b.touches.length!==1||!_||(((E=window.visualViewport)==null?void 0:E.scale)??1)>1.01)return m();o.dataset.swipe==="leave"||!(T===o||T!=null&&T.closest(t))||(window.clearTimeout(u),i={x:_.clientX,y:_.clientY,at:b.timeStamp},c=[{y:_.clientY,t:b.timeStamp}])},w=b=>{const _=b.touches[0];if(!i||!_)return;const T=_.clientX-i.x,E=_.clientY-i.y;if(!l){const N=Db({dx:T,dy:E});if(N==="other"&&(i=null),N!=="away")return;l=!0}b.preventDefault(),c.push({y:_.clientY,t:b.timeStamp}),c.length>16&&c.shift(),p(E,"drag")},y=b=>{const _=b.changedTouches[0];if(!i||!_)return;const T=_.clientY-i.y,E=b.timeStamp-i.at;if(!l&&E<g3&&b.target!==o&&Db({dx:_.clientX-i.x,dy:T})===null){b.preventDefault(),i=null,r.current();return}const j=v3(c,b.timeStamp);if(!l||!b3(j))return m();i=null,l=!1,c=[];const $=Math.sign(j)*window.innerHeight,P=x3(Math.abs($-T),j);p($,"leave",P),u=window.setTimeout(()=>r.current(),P)};return o.addEventListener("touchstart",g,{passive:!0}),o.addEventListener("touchmove",w,{passive:!1}),o.addEventListener("touchend",y),o.addEventListener("touchcancel",m),()=>{window.clearTimeout(u),o.removeEventListener("touchstart",g),o.removeEventListener("touchmove",w),o.removeEventListener("touchend",y),o.removeEventListener("touchcancel",m)}},[e,t])}function Kk({owner:e,onClose:t,menu:n,nav:r,children:o}){const i=vn(e),l=S.useRef(null);return E3(l,"img",t),d.jsxs(Rs,{className:"attach-full scrim",boxRef:l,onDismiss:t,onKey:c=>{if(c.key==="Escape"){c.stopPropagation(),t();return}const u=r&&e3(c);u&&(c.preventDefault(),c.stopPropagation(),r.step(u))},onClick:c=>{c.target===c.currentTarget&&t()},...n&&i.contextMenu(n),children:[o,d.jsxs("div",{className:"attach-head",children:[r&&r.of>1&&d.jsxs("span",{className:"attach-count",children:[r.at+1," of ",r.of]}),d.jsx(Ot,{icon:"close",label:"Close",tone:"quiet",onClick:t})]})]})}function S3({item:e}){if(!e.outcome)return null;const t=jP[e.outcome];if(e.ask.kind==="permission"){const{title:n,choices:r}=e.ask,o=r.find(i=>i.id===e.choiceId);return d.jsxs("div",{className:"ask-closed",children:[!e.toolId&&d.jsx("div",{className:"ask-lead",children:n}),d.jsx("div",{className:"ask-answered",children:o?o.name:t??"closed"})]})}return d.jsxs("div",{className:"ask-closed",children:[d.jsx("div",{className:"ask-lead",children:e.ask.message}),d.jsx("div",{className:"ask-answered",children:t??"closed"})]})}function Zk(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 O_=e=>e.slice(0,Math.max(0,e.lastIndexOf("/")));function M_(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("/"),c=n.slice(i.length+1).replace(/\/+$/,"");if(!c||c.split("/").some(h=>h===".."))return null;if(l)return{path:c,folder:!0};const u=(r==null?void 0:r[1])??(o==null?void 0:o[1]),p=u?Number.parseInt(u,10):void 0;return p&&p>0?{path:c,line:p}:{path:c}}function P_(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 _3(e){return e.length<2||!e.startsWith("/")||e.startsWith("//")||/\s/.test(e)?null:e}function qk(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?M_(t,o):null;if(i)return{kind:"file",file:i};const l=P_(o);return l?{kind:"outside",href:o,...l}:{kind:"out",href:o}}function Gk(e,t,n,r){const o=qk(e.target,t),i=o&&o.kind!=="path"?$_(o,n,r):null;i&&(e.preventDefault(),i())}const N3=150,T3=e=>({side:e,align:"center",offset:12,flip:"side",margin:8});function L_({chip:e,className:t,children:n}){const[r,o]=S.useState(!1),i=M(c=>c.chatSide);S.useEffect(()=>{const c=e.current;if(!c)return;let u=0;const p=()=>{window.clearTimeout(u),o(!1)},h=()=>{window.clearTimeout(u),u=window.setTimeout(()=>o(!0),N3)};return c.addEventListener("mouseenter",h),c.addEventListener("mouseleave",p),c.addEventListener("mousedown",p),()=>{window.clearTimeout(u),c.removeEventListener("mouseenter",h),c.removeEventListener("mouseleave",p),c.removeEventListener("mousedown",p)}},[e]);const l=()=>{var h;const c=e.current;if(!c)return null;const u=c.getBoundingClientRect(),p=((h=c.closest(".chat-log"))==null?void 0:h.getBoundingClientRect())??u;return{left:p.left,right:p.right,top:u.top,bottom:u.bottom}};return r?d.jsx(Rs,{className:We("chip-peek",t),anchor:l,placement:T3(i==="left"?"right":"left"),track:!0,children:n}):null}function Vk({className:e,label:t,tip:n,peek:r,full:o,menu:i,removeLabel:l,onRemove:c}){const u=S.useRef(null),p=vn("chat"),h=o!==void 0,m=r3(u,h);return d.jsxs("div",{ref:u,className:We("pick-chip row row-sm",e),"data-tip":h?"Open full size":n,"data-tip-placement":"follow",...p.contextMenu(()=>i({open:h?m.show:void 0,remove:c})),children:[h?d.jsx("button",{type:"button",className:"chip-link",onClick:m.show,children:t}):t,c&&d.jsx(Ot,{icon:"close",label:l,tone:"quiet",onClick:c}),h&&r!==void 0&&d.jsx(L_,{chip:u,children:r}),m.open&&h&&d.jsx(Kk,{owner:"chat",onClose:m.close,menu:()=>i(),nav:m.nav,children:o})]})}/*! @license DOMPurify 3.4.14 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.14/LICENSE */function zb(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 j3(e){if(Array.isArray(e))return e}function C3(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,i,l,c=[],u=!0,p=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(u=(r=i.call(n)).done)&&(c.push(r.value),c.length!==t);u=!0);}catch(h){p=!0,o=h}finally{try{if(!u&&n.return!=null&&(l=n.return(),Object(l)!==l))return}finally{if(p)throw o}}return c}}function A3(){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 I3(e,t){return j3(e)||C3(e,t)||$3(e,t)||A3()}function $3(e,t){if(e){if(typeof e=="string")return zb(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)?zb(e,t):void 0}}const D_=Object.entries,Fb=Object.setPrototypeOf,R3=Object.isFrozen,O3=Object.getPrototypeOf,M3=Object.getOwnPropertyDescriptor;let dr=Object.freeze,br=Object.seal,Xa=Object.create,z_=typeof Reflect<"u"&&Reflect,ng=z_.apply,rg=z_.construct;dr||(dr=function(t){return t});br||(br=function(t){return t});ng||(ng=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)});rg||(rg=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 qi=ir(Array.prototype.forEach),P3=ir(Array.prototype.lastIndexOf),Bb=ir(Array.prototype.pop),uc=ir(Array.prototype.push),L3=ir(Array.prototype.splice),cl=Array.isArray,wc=ir(String.prototype.toLowerCase),Jp=ir(String.prototype.toString),Ub=ir(String.prototype.match),dc=ir(String.prototype.replace),Hb=ir(String.prototype.indexOf),D3=ir(String.prototype.trim),z3=ir(Number.prototype.toString),F3=ir(Boolean.prototype.toString),Wb=typeof BigInt>"u"?null:ir(BigInt.prototype.toString),Kb=typeof Symbol>"u"?null:ir(Symbol.prototype.toString),eo=ir(Object.prototype.hasOwnProperty),fc=ir(Object.prototype.toString),Or=ir(RegExp.prototype.test),Zi=B3(TypeError);function ir(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 ng(e,t,r)}}function B3(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return rg(e,n)}}function mn(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:wc;if(Fb&&Fb(e,null),!cl(t))return e;let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const i=n(o);i!==o&&(R3(t)||(t[r]=i),o=i)}e[o]=!0}return e}function U3(e){for(let t=0;t<e.length;t++)eo(e,t)||(e[t]=null);return e}function go(e){const t=Xa(null);for(const r of D_(e)){var n=I3(r,2);const o=n[0],i=n[1];eo(e,o)&&(cl(i)?t[o]=U3(i):i&&typeof i=="object"&&i.constructor===Object?t[o]=go(i):t[o]=i)}return t}function H3(e){switch(typeof e){case"string":return e;case"number":return z3(e);case"boolean":return F3(e);case"bigint":return Wb?Wb(e):"0";case"symbol":return Kb?Kb(e):"Symbol()";case"undefined":return fc(e);case"function":case"object":{if(e===null)return fc(e);const t=e,n=Ho(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:fc(r)}return fc(e)}default:return fc(e)}}function Ho(e,t){for(;e!==null;){const r=M3(e,t);if(r){if(r.get)return ir(r.get);if(typeof r.value=="function")return ir(r.value)}e=O3(e)}function n(){return null}return n}function W3(e){try{return Or(e,""),!0}catch{return!1}}const Zb=dr(["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"]),em=dr(["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"]),tm=dr(["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"]),K3=dr(["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"]),nm=dr(["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"]),Z3=dr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),qb=dr(["#text"]),Gb=dr(["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"]),rm=dr(["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"]),Vb=dr(["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"]),$d=dr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),q3=br(/{{[\w\W]*|^[\w\W]*}}/g),G3=br(/<%[\w\W]*|^[\w\W]*%>/g),V3=br(/\${[\w\W]*/g),Y3=br(/^data-[\-\w.\u00B7-\uFFFF]+$/),X3=br(/^aria-[\-\w]+$/),Yb=br(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Q3=br(/^(?:\w+script|data):/i),J3=br(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),e5=br(/^html$/i),t5=br(/^[a-z][.\w]*(-[.\w]+)+$/i),Xb=br(/<[/\w!]/g),Qb=br(/<[/\w]/g),n5=br(/<\/no(script|embed|frames)/i),r5=br(/\/>/i),mo={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},F_=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],o5=dr(mn({},F_)),s5=(function(){const e={};return qi(F_,t=>{e[t]=br(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),dr(e)})(),i5=function(){return typeof window>"u"?null:window},a5=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}},Jb=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},si=function(t,n,r,o){return eo(t,n)&&cl(t[n])?mn(o.base?go(o.base):{},t[n],o.transform):r},om=function(t,n,r){const o=eo(t,n)?t[n]:void 0;return o&&typeof o=="object"?go(o):r()};function B_(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:i5();const t=Re=>B_(Re);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==mo.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,c=e.Element,u=e.NodeFilter,p=e.NamedNodeMap;p===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const h=e.DOMParser,m=e.trustedTypes,g=c.prototype,w=Ho(g,"cloneNode"),y=Ho(g,"remove"),b=Ho(g,"nextSibling"),_=Ho(g,"childNodes"),T=Ho(g,"parentNode"),E=Ho(g,"shadowRoot"),N=Ho(g,"attributes"),j=l&&l.prototype?Ho(l.prototype,"nodeType"):null,$=l&&l.prototype?Ho(l.prototype,"nodeName"):null,P=l&&l.prototype?Ho(l.prototype,"ownerDocument"):null,R=function(L){return j?j(L):L.nodeType},A=function(L){return $?$(L):L.nodeName};if(typeof i=="function"){const Re=n.createElement("template");Re.content&&Re.content.ownerDocument&&(n=Re.content.ownerDocument)}let O,B="",H,Q=!1,re=0;const J=function(){if(re>0)throw Zi('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.')},ie=function(L){J(),re++;try{return O.createHTML(L)}finally{re--}},ve=function(L){J(),re++;try{return O.createScriptURL(L)}finally{re--}},C=function(){return Q||(H=a5(m,o),Q=!0),H},Z=n,Y=Z.implementation,q=Z.createNodeIterator,z=Z.createDocumentFragment,te=Z.getElementsByTagName,Ee=r.importNode;let Ne=Jb();t.isSupported=typeof D_=="function"&&typeof T=="function"&&Y&&Y.createHTMLDocument!==void 0;const de=q3,we=G3,ae=V3,G=Y3,ue=X3,Le=Q3,ke=J3,ne=t5;let ge=Yb,je=null;const Ce=mn({},[...Zb,...em,...tm,...nm,...qb]);let Se=null;const Me=mn({},[...Gb,...rm,...Vb,...$d]);let wt=Object.seal(Xa(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}})),on=null,St=null;const Yt=Object.seal(Xa(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let zt=!0,Ht=!0,De=!1,_t=!0,sn=!1,ln=!0,lt=!1,jt=!1,Kt=null,xn=null,Pt=!1,jn=!1,Qt=!1,V=!1,pe=!0,Ye=!1;const nt="user-content-";let yt=!0,Jt=!1,ye={},Ie=null;const Xt=mn({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let U=null;const me=mn({},["audio","video","img","source","image","track"]);let ze=null;const Xe=mn({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Mt="http://www.w3.org/1998/Math/MathML",Nt="http://www.w3.org/2000/svg",He="http://www.w3.org/1999/xhtml";let Fe=He,Ke=!1,ht=null;const Ct=mn({},[Mt,Nt,He],Jp),Ft=dr(["mi","mo","mn","ms","mtext"]);let Zt=mn({},Ft);const bn=dr(["annotation-xml"]);let On=mn({},bn);const Cn=mn({},["title","style","font","a","script"]);let Xn=null;const Hn=["application/xhtml+xml","text/html"],se="text/html";let _e=null,at=null;const mt=n.createElement("form"),Wt=function(L){return L instanceof RegExp||L instanceof Function},kn=function(){let L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(at&&at===L)return;(!L||typeof L!="object")&&(L={}),L=go(L),Xn=Hn.indexOf(L.PARSER_MEDIA_TYPE)===-1?se:L.PARSER_MEDIA_TYPE,_e=Xn==="application/xhtml+xml"?Jp:wc,je=si(L,"ALLOWED_TAGS",Ce,{transform:_e}),Se=si(L,"ALLOWED_ATTR",Me,{transform:_e}),ht=si(L,"ALLOWED_NAMESPACES",Ct,{transform:Jp}),ze=si(L,"ADD_URI_SAFE_ATTR",Xe,{transform:_e,base:Xe}),U=si(L,"ADD_DATA_URI_TAGS",me,{transform:_e,base:me}),Ie=si(L,"FORBID_CONTENTS",Xt,{transform:_e}),on=si(L,"FORBID_TAGS",go({}),{transform:_e}),St=si(L,"FORBID_ATTR",go({}),{transform:_e}),ye=eo(L,"USE_PROFILES")?L.USE_PROFILES&&typeof L.USE_PROFILES=="object"?go(L.USE_PROFILES):L.USE_PROFILES:!1,zt=L.ALLOW_ARIA_ATTR!==!1,Ht=L.ALLOW_DATA_ATTR!==!1,De=L.ALLOW_UNKNOWN_PROTOCOLS||!1,_t=L.ALLOW_SELF_CLOSE_IN_ATTR!==!1,sn=L.SAFE_FOR_TEMPLATES||!1,ln=L.SAFE_FOR_XML!==!1,lt=L.WHOLE_DOCUMENT||!1,jn=L.RETURN_DOM||!1,Qt=L.RETURN_DOM_FRAGMENT||!1,V=L.RETURN_TRUSTED_TYPE||!1,Pt=L.FORCE_BODY||!1,pe=L.SANITIZE_DOM!==!1,Ye=L.SANITIZE_NAMED_PROPS||!1,yt=L.KEEP_CONTENT!==!1,Jt=L.IN_PLACE||!1,ge=W3(L.ALLOWED_URI_REGEXP)?L.ALLOWED_URI_REGEXP:Yb,Fe=typeof L.NAMESPACE=="string"?L.NAMESPACE:He,Zt=om(L,"MATHML_TEXT_INTEGRATION_POINTS",()=>mn({},Ft)),On=om(L,"HTML_INTEGRATION_POINTS",()=>mn({},bn));const D=om(L,"CUSTOM_ELEMENT_HANDLING",()=>Xa(null));if(wt=Xa(null),eo(D,"tagNameCheck")&&Wt(D.tagNameCheck)&&(wt.tagNameCheck=D.tagNameCheck),eo(D,"attributeNameCheck")&&Wt(D.attributeNameCheck)&&(wt.attributeNameCheck=D.attributeNameCheck),eo(D,"allowCustomizedBuiltInElements")&&typeof D.allowCustomizedBuiltInElements=="boolean"&&(wt.allowCustomizedBuiltInElements=D.allowCustomizedBuiltInElements),br(wt),sn&&(Ht=!1),Qt&&(jn=!0),ye&&(je=mn({},qb),Se=Xa(null),ye.html===!0&&(mn(je,Zb),mn(Se,Gb)),ye.svg===!0&&(mn(je,em),mn(Se,rm),mn(Se,$d)),ye.svgFilters===!0&&(mn(je,tm),mn(Se,rm),mn(Se,$d)),ye.mathMl===!0&&(mn(je,nm),mn(Se,Vb),mn(Se,$d))),Yt.tagCheck=null,Yt.attributeCheck=null,eo(L,"ADD_TAGS")&&(typeof L.ADD_TAGS=="function"?Yt.tagCheck=L.ADD_TAGS:cl(L.ADD_TAGS)&&(je===Ce&&(je=go(je)),mn(je,L.ADD_TAGS,_e))),eo(L,"ADD_ATTR")&&(typeof L.ADD_ATTR=="function"?Yt.attributeCheck=L.ADD_ATTR:cl(L.ADD_ATTR)&&(Se===Me&&(Se=go(Se)),mn(Se,L.ADD_ATTR,_e))),eo(L,"ADD_FORBID_CONTENTS")&&cl(L.ADD_FORBID_CONTENTS)&&(Ie===Xt&&(Ie=go(Ie)),mn(Ie,L.ADD_FORBID_CONTENTS,_e)),yt&&(je["#text"]=!0),lt&&mn(je,["html","head","body"]),je.table&&(mn(je,["tbody"]),delete on.tbody),L.TRUSTED_TYPES_POLICY){if(typeof L.TRUSTED_TYPES_POLICY.createHTML!="function")throw Zi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof L.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Zi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const oe=O;O=L.TRUSTED_TYPES_POLICY;try{B=ie("")}catch(be){throw O=oe,be}}else L.TRUSTED_TYPES_POLICY===null?(O=void 0,B=""):(O===void 0&&(O=C()),O&&typeof B=="string"&&(B=ie("")));dr&&dr(L),at=L},wn=mn({},[...em,...tm,...K3]),tr=mn({},[...nm,...Z3]),fn=function(L,D,oe){return D.namespaceURI===He?L==="svg":D.namespaceURI===Mt?L==="svg"&&(oe==="annotation-xml"||Zt[oe]):!!wn[L]},hn=function(L,D,oe){return D.namespaceURI===He?L==="math":D.namespaceURI===Nt?L==="math"&&On[oe]:!!tr[L]},Tt=function(L,D,oe){return D.namespaceURI===Nt&&!On[oe]||D.namespaceURI===Mt&&!Zt[oe]?!1:!tr[L]&&(Cn[L]||!wn[L])},zr=function(L){let D=T(L);(!D||!D.tagName)&&(D={namespaceURI:Fe,tagName:"template"});const oe=wc(L.tagName),be=wc(D.tagName);return ht[L.namespaceURI]?L.namespaceURI===Nt?fn(oe,D,be):L.namespaceURI===Mt?hn(oe,D,be):L.namespaceURI===He?Tt(oe,D,be):!!(Xn==="application/xhtml+xml"&&ht[L.namespaceURI]):!1},pt=function(L){uc(t.removed,{element:L});try{T(L).removeChild(L)}catch{if(y(L),!T(L))throw Zi("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},In=function(L,D,oe){try{L.removeAttributeNode(D)}catch{try{L.removeAttribute(oe)}catch{}}},Te=function(L){et(L);const D=_(L);if(D){const be=[];qi(D,Ae=>{uc(be,Ae)}),qi(be,Ae=>{try{y(Ae)}catch{}})}const oe=N(L);if(oe)for(let be=oe.length-1;be>=0;--be){const Ae=oe[be],Ve=Ae&&Ae.name;typeof Ve=="string"&&In(L,Ae,Ve)}},Ge=function(L,D,oe){if(!oe)try{oe=D.getAttributeNode(L)}catch{oe=null}uc(t.removed,{attribute:oe||null,from:D});try{oe?D.removeAttributeNode(oe):D.removeAttribute(L)}catch{try{D.removeAttribute(L)}catch{}}if(L==="is")if(jn||Qt)try{pt(D)}catch{}else try{D.setAttribute(L,"")}catch{}},rt=function(L){const D=N(L);if(D)for(let oe=D.length-1;oe>=0;--oe){const be=D[oe],Ae=be&&be.name;typeof Ae!="string"||Se[_e(Ae)]||In(L,be,Ae)}},et=function(L){const D=[L];for(;D.length>0;){const oe=D.pop();R(oe)===mo.element&&rt(oe);const Ae=_(oe);if(Ae)for(let Ve=Ae.length-1;Ve>=0;--Ve)D.push(Ae[Ve])}},cn=function(L,D){return ln?L==="patchsrc"?!0:L==="for"&&D!=="label"&&D!=="output":!1},yn=function(L){if(!ln)return;const D=[L];for(;D.length>0;){const oe=D.pop(),be=R(oe);if(be===mo.processingInstruction||be===mo.comment&&Or(Qb,oe.data)){try{y(oe)}catch{}continue}if(be===mo.element){const Ve=oe,It=_e(A(oe));try{Ve.hasAttribute&&Ve.hasAttribute("patchsrc")&&Ve.removeAttribute("patchsrc"),Ve.hasAttribute&&Ve.hasAttribute("for")&&cn("for",It)&&Ve.removeAttribute("for")}catch{}}const Ae=_(oe);if(Ae)for(let Ve=Ae.length-1;Ve>=0;--Ve)D.push(Ae[Ve])}},ar=function(L){let D=null,oe=null;if(Pt)L="<remove></remove>"+L;else{const Ve=Ub(L,/^[\r\n\t ]+/);oe=Ve&&Ve[0]}Xn==="application/xhtml+xml"&&Fe===He&&(L='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+L+"</body></html>");const be=O?ie(L):L;if(Fe===He)try{D=new h().parseFromString(be,Xn)}catch{}if(!D||!D.documentElement){D=Y.createDocument(Fe,"template",null);try{D.documentElement.innerHTML=Ke?B:be}catch{}}const Ae=D.body||D.documentElement;return L&&oe&&Ae.insertBefore(n.createTextNode(oe),Ae.childNodes[0]||null),Fe===He?te.call(D,lt?"html":"body")[0]:lt?D.documentElement:Ae},Fr=function(L){const D=P?P(L):L.ownerDocument;return q.call(D||L,L,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},K=function(L){return L=dc(L,de," "),L=dc(L,we," "),L=dc(L,ae," "),L},fe=function(L){var D;L.normalize();const oe=P?P(L):L.ownerDocument,be=q.call(oe||L,L,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let Ae=be.nextNode();for(;Ae;)Ae.data=K(Ae.data),Ae=be.nextNode();const Ve=(D=L.querySelectorAll)===null||D===void 0?void 0:D.call(L,"template");Ve&&qi(Ve,It=>{At(It.content)&&fe(It.content)})},Qe=function(L){const D=$?$(L):null;return typeof D!="string"||_e(D)!=="form"?!1:typeof L.nodeName!="string"||typeof L.textContent!="string"||typeof L.removeChild!="function"||L.attributes!==N(L)||typeof L.removeAttribute!="function"||typeof L.setAttribute!="function"||typeof L.namespaceURI!="string"||typeof L.insertBefore!="function"||typeof L.hasChildNodes!="function"||L.nodeType!==j(L)||L.childNodes!==_(L)},At=function(L){if(!j||typeof L!="object"||L===null)return!1;try{return j(L)===mo.documentFragment}catch{return!1}},gt=function(L){if(!j||typeof L!="object"||L===null)return!1;try{return typeof j(L)=="number"}catch{return!1}};function qt(Re,L,D){Re.length!==0&&qi(Re,oe=>{oe.call(t,L,D,at)})}const Br=function(L,D){return!!(ln&&L.hasChildNodes()&&!gt(L.firstElementChild)&&Or(Xb,L.textContent)&&Or(Xb,L.innerHTML)||ln&&L.namespaceURI===He&&o5[D]&&(gt(L.firstElementChild)||typeof L.textContent=="string"&&Or(s5[D],L.textContent))||L.nodeType===mo.processingInstruction||ln&&L.nodeType===mo.comment&&Or(Qb,L.data))},hr=function(L,D){if(L instanceof RegExp)return Or(L,D);if(L instanceof Function){for(var oe=arguments.length,be=new Array(oe>2?oe-2:0),Ae=2;Ae<oe;Ae++)be[Ae-2]=arguments[Ae];return!!L(D,...be)}return!1},vo=function(L,D,oe){if(!on[D]&&vt(D)&&hr(wt.tagNameCheck,D))return!1;if(yt&&!Ie[D]){const be=T(L),Ae=_(L);if(Ae&&be){const Ve=Ae.length;for(let It=Ve-1;It>=0;--It){const rn=L===oe?w(Ae[It],!0):Ae[It];be.insertBefore(rn,b(L))}}}return pt(L),!0},Nr=function(L,D,oe,be){return L.length===0?D:D===oe||D===be?go(D):D},xr=function(L,D){return L===D||T(L)!==null?!1:(Jt&&et(L),!0)},nr=function(L,D){if(qt(Ne.beforeSanitizeElements,L,null),xr(L,D))return!0;if(Qe(L))return pt(L),!0;const oe=_e(A(L));if(je=Nr(Ne.uponSanitizeElement,je,Ce,Kt),qt(Ne.uponSanitizeElement,L,{tagName:oe,allowedTags:je}),xr(L,D))return!0;if(Br(L,oe))return pt(L),!0;if(on[oe]||!(Yt.tagCheck instanceof Function&&Yt.tagCheck(oe))&&!je[oe]){const Ae=vo(L,oe,D);return Ae===!1&&qt(Ne.afterSanitizeElements,L,null),Ae}if(R(L)===mo.element&&!zr(L)||(oe==="noscript"||oe==="noembed"||oe==="noframes")&&Or(n5,L.innerHTML))return pt(L),!0;if(sn&&L.nodeType===mo.text){const Ae=K(L.textContent);L.textContent!==Ae&&(uc(t.removed,{element:L.cloneNode()}),L.textContent=Ae)}return qt(Ne.afterSanitizeElements,L,null),!1},ao=function(L,D,oe){if(St[D]||cn(D,L)||pe&&(D==="id"||D==="name")&&(oe in n||oe in mt))return!1;const be=Se[D]||Yt.attributeCheck instanceof Function&&Yt.attributeCheck(D,L);return Ht&&Or(G,D)||zt&&Or(ue,D)?!0:be?ze[D]||Or(ge,dc(oe,ke,""))||(D==="src"||D==="xlink:href"||D==="href")&&L!=="script"&&Hb(oe,"data:")===0&&U[L]||De&&!Or(Le,dc(oe,ke,""))?!0:!oe:vt(L)&&hr(wt.tagNameCheck,L)&&hr(wt.attributeNameCheck,D,L)||D==="is"&&wt.allowCustomizedBuiltInElements&&hr(wt.tagNameCheck,oe)},Gt=mn({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),vt=function(L){return!Gt[wc(L)]&&Or(ne,L)},fs=function(L,D,oe,be){if(O&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!oe)switch(m.getAttributeType(L,D)){case"TrustedHTML":return ie(be);case"TrustedScriptURL":return ve(be)}return be},En=function(L,D,oe,be){try{oe?L.setAttributeNS(oe,D,be):L.setAttribute(D,be),Qe(L)?pt(L):Bb(t.removed)}catch{Ge(D,L)}},un=function(L){qt(Ne.beforeSanitizeAttributes,L,null);const D=L.attributes;if(!D||Qe(L))return;Se=Nr(Ne.uponSanitizeAttribute,Se,Me,xn);const oe={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Se,forceKeepAttr:void 0};let be=D.length;const Ae=_e(L.nodeName);for(;be--;){const Ve=D[be],It=Ve.name,rn=Ve.namespaceURI,Wn=Ve.value,Mn=_e(It),lo=Wn;let Kn=It==="value"?lo:D3(lo);if(oe.attrName=Mn,oe.attrValue=Kn,oe.keepAttr=!0,oe.forceKeepAttr=void 0,qt(Ne.uponSanitizeAttribute,L,oe),Kn=oe.attrValue,Ye&&(Mn==="id"||Mn==="name")&&Hb(Kn,nt)!==0&&(Ge(It,L,Ve),Kn=nt+Kn),ln&&Or(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Kn)){Ge(It,L,Ve);continue}if(Mn==="attributename"&&Ub(Kn,"href")){Ge(It,L,Ve);continue}if(!oe.forceKeepAttr){if(!oe.keepAttr){Ge(It,L,Ve);continue}if(!_t&&Or(r5,Kn)){Ge(It,L,Ve);continue}if(sn&&(Kn=K(Kn)),!ao(Ae,Mn,Kn)){Ge(It,L,Ve);continue}Kn=fs(Ae,Mn,rn,Kn),Kn!==lo&&En(L,It,rn,Kn)}}qt(Ne.afterSanitizeAttributes,L,null)},Tr=function(L){let D=null;const oe=Fr(L);for(qt(Ne.beforeSanitizeShadowDOM,L,null);D=oe.nextNode();)if(qt(Ne.uponSanitizeShadowNode,D,null),nr(D,L),un(D),At(D.content)&&Tr(D.content),R(D)===mo.element){const be=E(D);At(be)&&(pr(be),Tr(be))}qt(Ne.afterSanitizeShadowDOM,L,null)},pr=function(L){const D=[{node:L,shadow:null}];for(;D.length>0;){const oe=D.pop();if(oe.shadow){Tr(oe.shadow);continue}const be=oe.node,Ve=R(be)===mo.element,It=_(be);if(It)for(let rn=It.length-1;rn>=0;--rn)D.push({node:It[rn],shadow:null});if(Ve){const rn=$?$(be):null;if(typeof rn=="string"&&_e(rn)==="template"){const Wn=be.content;At(Wn)&&D.push({node:Wn,shadow:null})}}if(Ve){const rn=E(be);At(rn)&&D.push({node:null,shadow:rn},{node:rn,shadow:null})}}};return t.sanitize=function(Re){let L=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},D=null,oe=null,be=null,Ae=null;if(Ke=!Re,Ke&&(Re="<!-->"),typeof Re!="string"&&!gt(Re)&&(Re=H3(Re),typeof Re!="string"))throw Zi("dirty is not a string, aborting");if(!t.isSupported)return Re;jt?(je=Kt,Se=xn):kn(L),(Ne.uponSanitizeElement.length>0||Ne.uponSanitizeAttribute.length>0)&&(je=go(je)),Ne.uponSanitizeAttribute.length>0&&(Se=go(Se)),t.removed=[];const Ve=Jt&&typeof Re!="string"&>(Re);if(Ve){yn(Re);const Wn=A(Re);if(typeof Wn=="string"){const Mn=_e(Wn);if(!je[Mn]||on[Mn])throw Te(Re),Zi("root node is forbidden and cannot be sanitized in-place")}if(Qe(Re))throw Te(Re),Zi("root node is clobbered and cannot be sanitized in-place");try{pr(Re)}catch(Mn){throw Te(Re),Mn}}else if(gt(Re))D=ar("<!---->"),oe=D.ownerDocument.importNode(Re,!0),oe.nodeType===mo.element&&oe.nodeName==="BODY"||oe.nodeName==="HTML"?D=oe:D.appendChild(oe),pr(oe);else{if(!jn&&!sn&&!lt&&Re.indexOf("<")===-1)return O&&V?ie(Re):Re;if(D=ar(Re),!D)return jn?null:V?B:""}D&&Pt&&pt(D.firstChild);const It=Ve?Re:D;try{const Wn=Fr(It);for(;be=Wn.nextNode();)nr(be,It),un(be),At(be.content)&&Tr(be.content)}catch(Wn){throw Ve&&(Te(Re),qi(t.removed,Mn=>{Mn.element&&et(Mn.element)})),Wn}if(Ve)return qi(t.removed,Wn=>{Wn.element&&et(Wn.element)}),sn&&fe(Re),Re;if(jn){if(sn&&fe(D),Qt)for(Ae=z.call(D.ownerDocument);D.firstChild;)Ae.appendChild(D.firstChild);else Ae=D;return(Se.shadowroot||Se.shadowrootmode)&&(Ae=Ee.call(r,Ae,!0)),Ae}let rn=lt?D.outerHTML:D.innerHTML;return lt&&je["!doctype"]&&D.ownerDocument&&D.ownerDocument.doctype&&D.ownerDocument.doctype.name&&Or(e5,D.ownerDocument.doctype.name)&&(rn="<!DOCTYPE "+D.ownerDocument.doctype.name+`>
|
|
129
|
+
`+rn),sn&&(rn=K(rn)),O&&V?ie(rn):rn},t.setConfig=function(){let Re=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};kn(Re),jt=!0,Kt=je,xn=Se},t.clearConfig=function(){at=null,jt=!1,Kt=null,xn=null,O=H,B=""},t.isValidAttribute=function(Re,L,D){at||kn({});const oe=_e(Re),be=_e(L);return ao(oe,be,D)},t.addHook=function(Re,L){typeof L=="function"&&eo(Ne,Re)&&uc(Ne[Re],L)},t.removeHook=function(Re,L){if(eo(Ne,Re)){if(L!==void 0){const D=P3(Ne[Re],L);return D===-1?void 0:L3(Ne[Re],D,1)[0]}return Bb(Ne[Re])}},t.removeHooks=function(Re){eo(Ne,Re)&&(Ne[Re]=[])},t.removeAllHooks=function(){Ne=Jb()},t}var l5=B_();function Yk(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ha=Yk();function U_(e){ha=e}var Vi={exec:()=>null};function qa(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 nn(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(Pr.caret,"$1"),n=n.replace(o,l),r},getRegex:()=>new RegExp(n,t)};return r}var c5=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Pr={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:qa(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:qa(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:qa(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:qa(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:qa(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:qa(e=>new RegExp(`^ {0,${e}}>`))},u5=/^(?:[ \t]*(?:\n|$))+/,d5=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,f5=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,au=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,h5=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Xk=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,H_=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,W_=nn(H_).replace(/bull/g,Xk).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(),p5=nn(H_).replace(/bull/g,Xk).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(),Qk=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,m5=/^[^\n]+/,Jk=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,g5=nn(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Jk).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),k5=nn(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Xk).getRegex(),nh="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",ew=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,w5=nn("^ {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",ew).replace("tag",nh).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),K_=e=>nn(Qk).replace("hr",au).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",nh).getRegex(),y5=K_(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),v5=K_(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),b5=nn(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",v5).getRegex(),tw={blockquote:b5,code:d5,def:g5,fences:f5,heading:h5,hr:au,html:w5,lheading:W_,list:k5,newline:u5,paragraph:y5,table:Vi,text:m5},ex=nn("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",au).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",nh).getRegex(),x5={...tw,lheading:p5,table:ex,paragraph:nn(Qk).replace("hr",au).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ex).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",nh).getRegex()},E5={...tw,html:nn(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ew).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:Vi,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:nn(Qk).replace("hr",au).replace("heading",` *#{1,6} *[^
|
|
130
|
+
]`).replace("lheading",W_).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},S5=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,_5=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Z_=/^( {2,}|\\)\n(?!\s*$)/,N5=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Os=/[\p{P}\p{S}]/u,Tl=/[\s\p{P}\p{S}]/u,lu=/[^\s\p{P}\p{S}]/u,T5=nn(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Tl).getRegex(),j5=/[\p{Pi}\p{Ps}"']/u,q_=/(?!~)[\p{P}\p{S}]/u,C5=/(?!~)[\s\p{P}\p{S}]/u,A5=/(?:[^\s\p{P}\p{S}]|~)/u,I5=nn(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",c5?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),G_=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,$5=nn(G_,"u").replace(/punct/g,Os).getRegex(),R5=nn(G_,"u").replace(/punct/g,q_).getRegex(),O5=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,M5=nn(O5,"u").replace(/openQuote/g,j5).replace(/punct/g,Os).getRegex(),V_="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",P5=nn(V_,"gu").replace(/notPunctSpace/g,lu).replace(/punctSpace/g,Tl).replace(/punct/g,Os).getRegex(),L5=nn(V_,"gu").replace(/notPunctSpace/g,A5).replace(/punctSpace/g,C5).replace(/punct/g,q_).getRegex(),D5="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",z5=nn(D5,"gu").replace(/notPunctSpace/g,lu).replace(/punctSpace/g,Tl).replace(/punct/g,Os).getRegex(),F5=nn("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,lu).replace(/punctSpace/g,Tl).replace(/punct/g,Os).getRegex(),B5="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",U5=nn(B5,"gu").replace(/notPunctSpace/g,lu).replace(/punctSpace/g,Tl).replace(/punct/g,Os).getRegex(),H5=nn(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Os).getRegex(),W5="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",K5=nn(W5,"gu").replace(/notPunctSpace/g,lu).replace(/punctSpace/g,Tl).replace(/punct/g,Os).getRegex(),Z5=nn(/\\(punct)/,"gu").replace(/punct/g,Os).getRegex(),q5=nn(/^<(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(),G5=nn(ew).replace("(?:-->|$)","-->").getRegex(),V5=nn("^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",G5).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),df=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Y5=nn(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",df).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Y_=nn(/^!?\[(label)\]\[(ref)\]/).replace("label",df).replace("ref",Jk).getRegex(),X_=nn(/^!?\[(ref)\](?:\[\])?/).replace("ref",Jk).getRegex(),X5=nn("reflink|nolink(?!\\()","g").replace("reflink",Y_).replace("nolink",X_).getRegex(),tx=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,nw={_backpedal:Vi,anyPunctuation:Z5,autolink:q5,blockSkip:I5,br:Z_,code:_5,del:Vi,delLDelim:Vi,delRDelim:Vi,emStrongLDelim:$5,emStrongRDelimAst:P5,emStrongRDelimUnd:F5,escape:S5,link:Y5,nolink:X_,punctuation:T5,reflink:Y_,reflinkSearch:X5,tag:V5,text:N5,url:Vi},Q5={...nw,emStrongLDelim:M5,emStrongRDelimAst:z5,emStrongRDelimUnd:U5,link:nn(/^!?\[(label)\]\((.*?)\)/).replace("label",df).getRegex(),reflink:nn(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",df).getRegex()},og={...nw,emStrongRDelimAst:L5,emStrongLDelim:R5,delLDelim:H5,delRDelim:K5,url:nn(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",tx).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:nn(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",tx).getRegex()},J5={...og,br:nn(Z_).replace("{2,}","*").getRegex(),text:nn(og.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Rd={normal:tw,gfm:x5,pedantic:E5},hc={normal:nw,gfm:og,breaks:J5,pedantic:Q5},e6={"&":"&","<":"<",">":">",'"':""","'":"'"},nx=e=>e6[e];function ss(e,t){if(t){if(Pr.escapeTest.test(e))return e.replace(Pr.escapeReplace,nx)}else if(Pr.escapeTestNoEncode.test(e))return e.replace(Pr.escapeReplaceNoEncode,nx);return e}function rx(e){try{e=encodeURI(e).replace(Pr.percentDecode,"%")}catch{return null}return e}function ox(e,t){var i;let n=e.replace(Pr.findPipe,(l,c,u)=>{let p=!1,h=c;for(;--h>=0&&u[h]==="\\";)p=!p;return p?"|":" |"}),r=n.split(Pr.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(Pr.slashPipe,"|");return r}function ii(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 sx(e){let t=e.split(`
|
|
131
|
+
`),n=t.length-1;for(;n>=0&&Pr.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
132
|
+
`)}function t6(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 n6(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 ix(e,t,n,r,o){let i=t.href,l=t.title||null,c=e[1].replace(o.other.outputLinkReplace,"$1"),u=e[0].charAt(0)==="!";r.state.inLink=!0;let p=r.state.linkEmitted,h=r.state.inRawBlock;r.state.linkEmitted=!1;let m=r.inlineTokens(c),g=r.state.linkEmitted;if(r.state.linkEmitted=p,r.state.inLink=!1,!u){if(g){r.state.inRawBlock=h;return}r.state.linkEmitted=!0}return{type:u?"image":"link",raw:n,href:i,title:l,text:c,tokens:m}}function r6(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[c]=l;return c.length>=o.length?i.slice(o.length):i}).join(`
|
|
134
|
+
`)}var ff=class{constructor(e){Bt(this,"options");Bt(this,"rules");Bt(this,"lexer");this.options=e||ha}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]:sx(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=r6(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=ii(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:ii(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:ii(t[0],`
|
|
136
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=ii(t[0],`
|
|
137
|
+
`).split(`
|
|
138
|
+
`),r="",o="",i=[];for(;n.length>0;){let l=!1,c=[],u;for(u=0;u<n.length;u++)if(this.rules.other.blockquoteStart.test(n[u]))c.push(n[u]),l=!0;else if(!l)c.push(n[u]);else break;n=n.slice(u);let p=c.join(`
|
|
139
|
+
`),h=p.replace(this.rules.other.blockquoteSetextReplace,`
|
|
140
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
141
|
+
${p}`:p,o=o?`${o}
|
|
142
|
+
${h}`:h;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,i,!0),this.lexer.state.top=m,n.length===0)break;let g=i.at(-1);if((g==null?void 0:g.type)==="code")break;if((g==null?void 0:g.type)==="blockquote"){let w=g,y=n.join(`
|
|
143
|
+
`),b=w.raw+`
|
|
144
|
+
`+y.replace(this.rules.other.blockquoteSetextReplace2,""),_=this.blockquote(b);i[i.length-1]=_,r=`${r}
|
|
145
|
+
${y}`,o=o.substring(0,o.length-w.text.length)+_.text;break}else if((g==null?void 0:g.type)==="list"){let w=g,y=w.raw+`
|
|
146
|
+
`+n.join(`
|
|
147
|
+
`),b=this.list(y);i[i.length-1]=b,r=r.substring(0,r.length-g.raw.length)+b.raw,o=o.substring(0,o.length-w.raw.length)+b.raw,n=y.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 u=!1,p="",h="";if(!(t=i.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let m=n6(t[2].split(`
|
|
149
|
+
`,1)[0],t[1].length),g=e.split(`
|
|
150
|
+
`,1)[0],w=!m.trim(),y=0;if(this.options.pedantic?(y=2,h=m.trimStart()):w?y=t[1].length+1:(y=m.search(this.rules.other.nonSpaceChar),y=y>4?1:y,h=m.slice(y),y+=t[1].length),w&&this.rules.other.blankLine.test(g)&&(p+=g+`
|
|
151
|
+
`,e=e.substring(g.length+1),u=!0),!u){let b=this.rules.other.nextBulletRegex(y),_=this.rules.other.hrRegex(y),T=this.rules.other.fencesBeginRegex(y),E=this.rules.other.headingBeginRegex(y),N=this.rules.other.htmlBeginRegex(y),j=this.rules.other.blockquoteBeginRegex(y);for(;e;){let $=e.split(`
|
|
152
|
+
`,1)[0],P;if(g=$,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),P=g):P=g.replace(this.rules.other.tabCharGlobal," "),T.test(g)||E.test(g)||N.test(g)||j.test(g)||b.test(g)||_.test(g))break;if(P.search(this.rules.other.nonSpaceChar)>=y||!g.trim())h+=`
|
|
153
|
+
`+P.slice(y);else{if(w||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||T.test(m)||E.test(m)||_.test(m))break;h+=`
|
|
154
|
+
`+g}w=!g.trim(),p+=$+`
|
|
155
|
+
`,e=e.substring($.length+1),m=P.slice(y)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(l=!0)),o.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(h),loose:!1,text:h,tokens:[]}),o.raw+=p}let c=o.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let u of o.items)if(this.lexer.state.top=!1,u.tokens=this.lexer.blockTokens(u.text,[]),!o.loose){let p=u.tokens.filter(m=>m.type==="space"),h=p.length>0&&p.some(m=>this.rules.other.anyLine.test(m.raw));o.loose=h}for(let u of o.items){let p=u.tokens[0];if(u.task&&((p==null?void 0:p.type)==="text"||(p==null?void 0:p.type)==="paragraph")){u.text=u.text.replace(this.rules.other.listReplaceTask,""),p.raw=p.raw.replace(this.rules.other.listReplaceTask,""),p.text=p.text.replace(this.rules.other.listReplaceTask,"");for(let m=this.lexer.inlineQueue.length-1;m>=0;m--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[m].src)){this.lexer.inlineQueue[m].src=this.lexer.inlineQueue[m].src.replace(this.rules.other.listReplaceTask,"");break}let h=this.rules.other.listTaskCheckbox.exec(u.raw);if(h){let m={type:"checkbox",raw:h[0]+" ",checked:h[0]!=="[ ]"};u.checked=m.checked,o.loose?u.tokens[0]&&["paragraph","text"].includes(u.tokens[0].type)&&"tokens"in u.tokens[0]&&u.tokens[0].tokens?(u.tokens[0].raw=m.raw+u.tokens[0].raw,u.tokens[0].text=m.raw+u.tokens[0].text,u.tokens[0].tokens.unshift(m)):u.tokens.unshift({type:"paragraph",raw:m.raw,text:m.raw,tokens:[m]}):u.tokens.unshift(m)}}else u.task&&(u.task=!1)}if(o.loose)for(let u of o.items){u.loose=!0;for(let p of u.tokens)p.type==="text"&&(p.type="paragraph")}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=sx(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:ii(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=ox(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:ii(t[0],`
|
|
158
|
+
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let c of r)this.rules.other.tableAlignRight.test(c)?i.align.push("right"):this.rules.other.tableAlignCenter.test(c)?i.align.push("center"):this.rules.other.tableAlignLeft.test(c)?i.align.push("left"):i.align.push(null);for(let c=0;c<n.length;c++)i.header.push({text:n[c],tokens:this.lexer.inline(n[c]),header:!0,align:i.align[c]});for(let c of o)i.rows.push(ox(c,i.header.length).map((u,p)=>({text:u,tokens:this.lexer.inline(u),header:!1,align:i.align[p]})));return i}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:ii(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=ii(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=t6(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)),ix(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 ix(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,c=o,u=0,p=r[0][0],h=n===p,m=p==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(m.lastIndex=0,t=t.slice(-1*e.length+o);(r=m.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(l=[...i].length,r[3]||r[4]){c+=l;continue}else if(r[5]||r[6]){if(o%3&&!((o+l)%3)){u+=l;continue}if(h)break}if(c-=l,c>0)continue;l=Math.min(l,l+c+u);let g=[...r[0]][0].length,w=e.slice(0,o+r.index+g+l);if(Math.min(o,l)%2){let b=w.slice(1,-1);return{type:"em",raw:w,text:b,tokens:this.lexer.inlineTokens(b)}}let y=w.slice(2,-2);return{type:"strong",raw:w,text:y,tokens:this.lexer.inlineTokens(y)}}}}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,c=o,u=this.rules.inline.delRDelim;for(u.lastIndex=0,t=t.slice(-1*e.length+o);(r=u.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]){c+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c);let p=[...r[0]][0].length,h=e.slice(0,o+r.index+p+l),m=h.slice(o,-o);return{type:"del",raw:h,text:m,tokens:this.lexer.inlineTokens(m)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let r,o;if(t[2]==="@")r=t[0],o="mailto:"+r;else{let 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}}}},Zo=class sg{constructor(t){Bt(this,"tokens");Bt(this,"options");Bt(this,"state");Bt(this,"inlineQueue");Bt(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||ha,this.options.tokenizer=this.options.tokenizer||new ff,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:Pr,block:Rd.normal,inline:hc.normal};this.options.pedantic?(n.block=Rd.pedantic,n.inline=hc.pedantic):this.options.gfm&&(n.block=Rd.gfm,this.options.breaks?n.inline=hc.breaks:n.inline=hc.gfm),this.tokenizer.rules=n}static get rules(){return{block:Rd,inline:hc}}static lex(t,n){return new sg(n).lex(t)}static lexInline(t,n){return new sg(n).inlineTokens(t)}lex(t){t=t.replace(Pr.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,c;this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(Pr.tabCharGlobal," ").replace(Pr.spaceLine,""));let o=1/0;for(;t;){if(t.length<o)o=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let u;if((l=(i=this.options.extensions)==null?void 0:i.block)!=null&&l.some(h=>(u=h.call({lexer:this},t,n))?(t=t.substring(u.raw.length),n.push(u),!0):!1))continue;if(u=this.tokenizer.space(t)){t=t.substring(u.raw.length);let h=n.at(-1);u.raw.length===1&&h!==void 0?h.raw+=`
|
|
162
|
+
`:n.push(u);continue}if(u=this.tokenizer.code(t)){t=t.substring(u.raw.length);let h=n.at(-1);(h==null?void 0:h.type)==="paragraph"||(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
|
|
163
|
+
`)?"":`
|
|
164
|
+
`)+u.raw,h.text+=`
|
|
165
|
+
`+u.text,this.inlineQueue.at(-1).src=h.text):n.push(u);continue}if(u=this.tokenizer.fences(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.heading(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.hr(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.blockquote(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.list(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.html(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.def(t)){t=t.substring(u.raw.length);let h=n.at(-1);(h==null?void 0:h.type)==="paragraph"||(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
|
|
166
|
+
`)?"":`
|
|
167
|
+
`)+u.raw,h.text+=`
|
|
168
|
+
`+u.raw,this.inlineQueue.at(-1).src=h.text):this.tokens.links[u.tag]||(this.tokens.links[u.tag]={href:u.href,title:u.title},n.push(u));continue}if(u=this.tokenizer.table(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.lheading(t)){t=t.substring(u.raw.length),n.push(u);continue}let p=t;if((c=this.options.extensions)!=null&&c.startBlock){let h=1/0,m=t.slice(1),g;this.options.extensions.startBlock.forEach(w=>{g=w.call({lexer:this},m),typeof g=="number"&&g>=0&&(h=Math.min(h,g))}),h<1/0&&h>=0&&(p=t.substring(0,h+1))}if(this.state.top&&(u=this.tokenizer.paragraph(p))){let h=n.at(-1);r&&(h==null?void 0:h.type)==="paragraph"?(h.raw+=(h.raw.endsWith(`
|
|
169
|
+
`)?"":`
|
|
170
|
+
`)+u.raw,h.text+=`
|
|
171
|
+
`+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=h.text):n.push(u),r=p.length!==t.length,t=t.substring(u.raw.length);continue}if(u=this.tokenizer.text(t)){t=t.substring(u.raw.length);let h=n.at(-1);(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
|
|
172
|
+
`)?"":`
|
|
173
|
+
`)+u.raw,h.text+=`
|
|
174
|
+
`+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=h.text):n.push(u);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}linkInText(t){if(!t.includes("["))return!1;let n=this.tokenizer.rules.inline.link;for(let r of t.matchAll(this.tokenizer.rules.inline.blockSkip))if(n.test(r[0])&&t.charAt(r.index-1)!=="!")return!0;for(let r of t.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let o=r[0],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 c,u,p,h,m;this.tokenizer.lexer=this;let r=t;if(this.tokens.links&&t.includes("[")){let g=this.tokenizer.rules.inline.reflinkSearch,w=y=>{let b=y.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,y.slice(b+1,-1)))return y;if(b>1&&y.charAt(0)!=="!"){let _=y.slice(1,b-1);if(this.linkInText(_))return"["+_.replace(g,w)+"]["+"a".repeat(y.length-b-2)+"]"}return"["+"a".repeat(y.length-2)+"]"};r=r.replace(g,w)}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,g=>"+".repeat(g.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(g,w,y)=>{let b=y?y.length:0;return g.slice(0,b)+"["+"a".repeat(g.length-b-2)+"]"}),r=((u=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:u.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 g;if((h=(p=this.options.extensions)==null?void 0:p.inline)!=null&&h.some(y=>(g=y.call({lexer:this},t,n))?(t=t.substring(g.raw.length),n.push(g),!0):!1))continue;if(g=this.tokenizer.escape(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.tag(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.link(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(g.raw.length);let y=n.at(-1);g.type==="text"&&(y==null?void 0:y.type)==="text"?(y.raw+=g.raw,y.text+=g.text):n.push(g);continue}if(g=this.tokenizer.emStrong(t,r,i)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.codespan(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.br(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.del(t,r,i)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.autolink(t)){t=t.substring(g.raw.length),n.push(g);continue}if(!this.state.inLink&&(g=this.tokenizer.url(t))){t=t.substring(g.raw.length),n.push(g);continue}let w=t;if((m=this.options.extensions)!=null&&m.startInline){let y=1/0,b=t.slice(1),_;this.options.extensions.startInline.forEach(T=>{_=T.call({lexer:this},b),typeof _=="number"&&_>=0&&(y=Math.min(y,_))}),y<1/0&&y>=0&&(w=t.substring(0,y+1))}if(g=this.tokenizer.inlineText(w)){t=t.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(i=g.raw.slice(-1)),o=!0;let y=n.at(-1);(y==null?void 0:y.type)==="text"?(y.raw+=g.raw,y.text+=g.text):n.push(g);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return n}infiniteLoopError(t){let n="Infinite loop on byte: "+t;if(this.options.silent)console.error(n);else throw new Error(n)}},Wc=class{constructor(e){Bt(this,"options");Bt(this,"parser");this.options=e||ha}space(e){return""}code({text:e,lang:t,escaped:n}){var i;let r=(i=(t||"").match(Pr.notSpaceStart))==null?void 0:i[0],o=e.replace(Pr.endingNewline,"")+`
|
|
175
|
+
`;return r?'<pre><code class="language-'+ss(r)+'">'+(n?o:ss(o,!0))+`</code></pre>
|
|
176
|
+
`:"<pre><code>"+(n?o:ss(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 c=e.items[l];r+=this.listitem(c)}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>${ss(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=rx(e);if(o===null)return r;e=o;let i='<a href="'+e+'"';return t&&(i+=' title="'+ss(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=rx(e);if(o===null)return ss(n);e=o;let i=`<img src="${e}" alt="${ss(n)}"`;return t&&(i+=` title="${ss(t)}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:ss(e.text)}},rw=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}},qo=class ig{constructor(t){Bt(this,"options");Bt(this,"renderer");Bt(this,"textRenderer");this.options=t||ha,this.options.renderer=this.options.renderer||new Wc,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new rw}static parse(t,n){return new ig(n).parse(t)}static parseInline(t,n){return new ig(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 u=l,p=this.options.extensions.renderers[u.type].call({parser:this},u);if(p!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(u.type)){n+=p||"";continue}}let c=l;switch(c.type){case"space":{n+=this.renderer.space(c);break}case"hr":{n+=this.renderer.hr(c);break}case"heading":{n+=this.renderer.heading(c);break}case"code":{n+=this.renderer.code(c);break}case"table":{n+=this.renderer.table(c);break}case"blockquote":{n+=this.renderer.blockquote(c);break}case"list":{n+=this.renderer.list(c);break}case"checkbox":{n+=this.renderer.checkbox(c);break}case"html":{n+=this.renderer.html(c);break}case"def":{n+=this.renderer.def(c);break}case"paragraph":{n+=this.renderer.paragraph(c);break}case"text":{n+=this.renderer.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return n}parseInline(t,n=this.renderer){var o,i;this.renderer.parser=this;let r="";for(let l=0;l<t.length;l++){let c=t[l];if((i=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&i[c.type]){let p=this.options.extensions.renderers[c.type].call({parser:this},c);if(p!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(c.type)){r+=p||"";continue}}let u=c;switch(u.type){case"escape":{r+=n.text(u);break}case"html":{r+=n.html(u);break}case"link":{r+=n.link(u);break}case"image":{r+=n.image(u);break}case"checkbox":{r+=n.checkbox(u);break}case"strong":{r+=n.strong(u);break}case"em":{r+=n.em(u);break}case"codespan":{r+=n.codespan(u);break}case"br":{r+=n.br(u);break}case"del":{r+=n.del(u);break}case"text":{r+=n.text(u);break}default:{let p='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(p),"";throw new Error(p)}}}return r}},Ld,yc=(Ld=class{constructor(e){Bt(this,"options");Bt(this,"block");this.options=e||ha}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Zo.lex:Zo.lexInline}provideParser(e=this.block){return e?qo.parse:qo.parseInline}},Bt(Ld,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),Bt(Ld,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Ld),o6=class{constructor(...e){Bt(this,"defaults",Yk());Bt(this,"options",this.setOptions);Bt(this,"parse",this.parseMarkdown(!0));Bt(this,"parseInline",this.parseMarkdown(!1));Bt(this,"Parser",qo);Bt(this,"Renderer",Wc);Bt(this,"TextRenderer",rw);Bt(this,"Lexer",Zo);Bt(this,"Tokenizer",ff);Bt(this,"Hooks",yc);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 c of l.header)n=n.concat(this.walkTokens(c.tokens,t));for(let c of l.rows)for(let u of c)n=n.concat(this.walkTokens(u.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(c=>{let u=l[c].flat(1/0);n=n.concat(this.walkTokens(u,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 c=o.renderer.apply(this,l);return c===!1&&(c=i.apply(this,l)),c}:t.renderers[o.name]=o.renderer}if("tokenizer"in o){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let 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 Wc(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,c=n.renderer[l],u=o[l];o[l]=(...p)=>{let h=c.apply(o,p);return h===!1&&(h=u.apply(o,p)),h||""}}r.renderer=o}if(n.tokenizer){let o=this.defaults.tokenizer||new ff(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,c=n.tokenizer[l],u=o[l];o[l]=(...p)=>{let h=c.apply(o,p);return h===!1&&(h=u.apply(o,p)),h}}r.tokenizer=o}if(n.hooks){let o=this.defaults.hooks||new yc;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,c=n.hooks[l],u=o[l];yc.passThroughHooks.has(i)?o[l]=p=>{if(this.defaults.async&&yc.passThroughHooksRespectAsync.has(i))return(async()=>{let m=await c.call(o,p);return u.call(o,m)})();let h=c.call(o,p);return u.call(o,h)}:o[l]=(...p)=>{if(this.defaults.async)return(async()=>{let m=await c.apply(o,p);return m===!1&&(m=await u.apply(o,p)),m})();let h=c.apply(o,p);return h===!1&&(h=u.apply(o,p)),h}}r.hooks=o}if(n.walkTokens){let o=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(l){let c=[];return c.push(i.call(this,l)),o&&(c=c.concat(o.call(this,l))),c}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Zo.lex(e,t??this.defaults)}parser(e,t){return qo.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,c=await(o.hooks?await o.hooks.provideLexer(e):e?Zo.lex:Zo.lexInline)(l,o),u=o.hooks?await o.hooks.processAllTokens(c):c;o.walkTokens&&await Promise.all(this.walkTokens(u,o.walkTokens));let p=await(o.hooks?await o.hooks.provideParser(e):e?qo.parse:qo.parseInline)(u,o);return o.hooks?await o.hooks.postprocess(p):p})().catch(i);try{o.hooks&&(t=o.hooks.preprocess(t));let l=(o.hooks?o.hooks.provideLexer(e):e?Zo.lex:Zo.lexInline)(t,o);o.hooks&&(l=o.hooks.processAllTokens(l)),o.walkTokens&&this.walkTokens(l,o.walkTokens);let c=(o.hooks?o.hooks.provideParser(e):e?qo.parse:qo.parseInline)(l,o);return o.hooks&&(c=o.hooks.postprocess(c)),c}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>"+ss(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},ca=new o6;function Sn(e,t){return ca.parse(e,t)}Sn.options=Sn.setOptions=function(e){return ca.setOptions(e),Sn.defaults=ca.defaults,U_(Sn.defaults),Sn};Sn.getDefaults=Yk;Sn.defaults=ha;function s6(...e){return ca.use(...e),Sn.defaults=ca.defaults,U_(Sn.defaults),Sn}Sn.use=s6;Sn.walkTokens=function(e,t){return ca.walkTokens(e,t)};Sn.parseInline=ca.parseInline;Sn.Parser=qo;Sn.parser=qo.parse;Sn.Renderer=Wc;Sn.TextRenderer=rw;Sn.Lexer=Zo;Sn.lexer=Zo.lex;Sn.Tokenizer=ff;Sn.Hooks=yc;Sn.parse=Sn;Sn.options;Sn.setOptions;Sn.walkTokens;Sn.parseInline;qo.parse;Zo.lex;const ua=100,i6=e=>e.type==="text-delta"||e.type==="thinking-delta"||e.type==="tool-delta";function a6(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 l6={now:()=>performance.now(),after:(e,t)=>void setTimeout(t,e)};function c6(e,t=l6){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 c of l)e(c)};return l=>{if(l.t==="agent"&&i6(l.event)){const c={...l,event:{...l.event}},u=t.now();if(n.length===0&&u-o>=ua){o=u,e(c);return}const p=n[n.length-1];p&&a6(p,c)?p.event={...p.event,text:p.event.text+c.event.text}:n.push(c),r||(r=!0,t.after(Math.max(0,o+ua-u),i));return}i(),e(l)}}const Q_="#toyon-link-pending",u6=/!?\[([^[\]\n]*)(?:\]\(([^()\s]*))?$/;function d6(e){const t=e.lastIndexOf(`
|
|
194
|
+
`)+1,n=e.slice(t),r=u6.exec(n);return!r||f6(e.slice(0,t))||h6(n.slice(0,r.index))?e:`${e.slice(0,t)}${n.slice(0,r.index)}[${r[1]}](${Q_})`}function f6(e){let t=!1;for(const n of e.split(`
|
|
195
|
+
`))/^\s*(```|~~~)/.test(n)&&(t=!t);return t}function h6(e){let t=0;for(const n of e)n==="`"&&t++;return t%2===1}const sm="__[a-z][a-z0-9_]*[a-z0-9]__",p6=new RegExp(`^(?:${sm}\\.)+${sm}|^${sm}(?=\\.\\w|\\(|["'])`),m6={name:"dunder",level:"inline",start:e=>e.indexOf("__"),tokenizer(e){const t=p6.exec(e);if(t)return{type:"dunder",raw:t[0],text:t[0]}},renderer:e=>e.text},ag=e=>e.replace(/[&<>]/g,t=>t==="&"?"&":t==="<"?"<":">");function g6({text:e}){return ag(e)}function k6(e){return`<div class="md-table">${w6.call(this,e)}</div>
|
|
196
|
+
`}function w6(e){if(e.header.some(n=>n.text.trim()))return Wc.prototype.table.call(this,e);let t="";for(const n of e.rows){let r="";for(const o of n)r+=this.tablecell(o);t+=this.tablerow({text:r})}return`<table>
|
|
197
|
+
<tbody>${t}</tbody></table>
|
|
198
|
+
`}const y6=4*ua;function v6(e,t,n){if(!e)return{from:t,to:t,at:n,span:ua};const r=Math.min(J_(e,n),t),o=Math.min(Math.max(n-e.at,ua),y6);return{from:r,to:t,at:n,span:o}}function J_(e,t){const n=t-e.at;return n>=e.span?e.to:e.from+Math.floor((e.to-e.from)*Math.max(0,n)/e.span)}function b6(e,t){if(t>=e.length)return e;const n=e.charCodeAt(t);return e.slice(0,n>=56320&&n<=57343?t+1:t)}function x6(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"})]}},c={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,o]};o.contains.push(c);const u={match:/\\"/},p={className:"string",begin:/'/,end:/'/},h={match:/\\'/},m={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},g=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],w=e.SHEBANG({binary:`(${g.join("|")})`,relevance:10}),y={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"],_=["true","false"],T={match:/(\/[a-z._-]+)+/},E=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],N=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],j=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],$=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:b,literal:_,built_in:[...E,...N,"set","shopt",...j,...$]},contains:[w,e.SHEBANG(),y,m,i,l,T,c,u,p,h,n]}}const E6=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_-]*/}}),S6=["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"],_6=["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"],N6=[...S6,..._6],T6=["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(),j6=["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(),C6=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),A6=["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 I6(e){const t=e.regex,n=E6(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_-]*",c=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+l,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+j6.join("|")+")"},{begin:":(:)?("+C6.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+A6.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,n.UNICODE_RANGE,...c,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...c,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:o,attribute:T6.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...c,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+N6.join("|")+")\\b"}]}}function $6(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 R6(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:"'"}]},c={begin:/\[/,end:/\]/,contains:[r,i,o,l,n,"self"],relevance:0},u=/[A-Za-z0-9_-]+/,p=/"(\\"|[^"])*"/,h=/'[^']*'/,m=t.either(u,p,h),g=t.concat(m,"(\\s*\\.\\s*",m,")*",t.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:g,className:"attr",starts:{end:/$/,contains:[r,c,i,o,l,n]}}]}}const ax="[A-Za-z$_][0-9A-Za-z$_]*",O6=["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"],M6=["true","false","null","undefined","NaN","Infinity"],eN=["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"],tN=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],nN=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],P6=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],L6=[].concat(nN,eN,tN);function D6(e){const t=e.regex,n=(Z,{after:Y})=>{const q="</"+Z[0].slice(1);return Z.input.indexOf(q,Y)!==-1},r=ax,o={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(Z,Y)=>{const q=Z[0].length+Z.index,z=Z.input[q];if(z==="<"||z===","){Y.ignoreMatch();return}z===">"&&(n(Z,{after:q})||Y.ignoreMatch());let te;const Ee=Z.input.substring(q);if(te=Ee.match(/^\s*=/)){Y.ignoreMatch();return}if((te=Ee.match(/^\s+extends\s+/))&&te.index===0){Y.ignoreMatch();return}}},c={$pattern:ax,keyword:O6,literal:M6,built_in:L6,"variable.language":P6},u="[0-9](_?[0-9])*",p=`\\.(${u})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${h})((${p})|\\.)?|(${p}))[eE][+-]?(${u})\\b`},{begin:`\\b(${h})\\b((${p})\\b|\\.)?|(${p})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},w={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},b={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},_={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},E={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]},N=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,y,b,_,{match:/\$\d+/},m];g.contains=N.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(N)});const j=[].concat(E,g.contains),$=j.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(j)}]),P={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:$},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"}}]},A={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:{_:[...eN,...tN]}},O={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},B={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[P],illegal:/%/},H={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function Q(Z){return t.concat("(?!",Z.join("|"),")")}const re={match:t.concat(/\b/,Q([...nN,"super","import","await"].map(Z=>`${Z}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},J={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},ie={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},P]},ve="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",C={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ve)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[P]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:$,CLASS_REFERENCE:A},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),O,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,y,b,_,E,{match:/\$\d+/},m,A,{scope:"attr",match:r+t.lookahead(":"),relevance:0},C,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[E,e.REGEXP_MODE,{className:"function",begin:ve,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:$}]}]},{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"]}]}]},B,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[P,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},J,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[P]},re,H,R,ie,{match:/\$[(.]/}]}}const z6="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",F6={scope:"number",match:z6,relevance:0};function B6(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,F6,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function U6(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}]},c=/[A-Za-z][A-Za-z0-9+.-]*/,u={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,c,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},p={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},h={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},m=e.inherit(p,{contains:[]}),g=e.inherit(h,{contains:[]});p.contains.push(g),h.contains.push(m);let w=[n,u];return[p,h,m,g].forEach(T=>{T.contains=T.contains.concat(w)}),w=w.concat(p,h),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:w},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:w}]}]},n,i,r,p,h,{className:"quote",begin:"^>\\s+",contains:w,end:"$"},o,u,l,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function H6(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","lazy","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],c={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","aiter","all","anext","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozendict","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","sentinel","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},u={className:"meta",begin:/^(>>>|\.\.\.) /},p={className:"subst",begin:/\{/,end:/\}/,keywords:c,illegal:/#/},h={begin:/\{\{/,relevance:0},m={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,u,h,p]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u,h,p]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,h,p]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,h,p]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},g="[0-9](_?[0-9])*",w=`(\\b(${g}))?\\.(${g})|\\b(${g})\\.`,y=`\\b|${r.join("|")}`,b={className:"number",relevance:0,variants:[{begin:`(\\b(${g})|(${w}))[eE][+-]?(${g})[jJ]?(?=${y})`},{begin:`(${w})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${y})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${y})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${y})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${y})`},{begin:`\\b(${g})[jJ](?=${y})`}]},_={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:c,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},T={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:["self",u,b,m,e.HASH_COMMENT_MODE]}]};return p.contains=[m,b,u],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:c,illegal:/(<\/|\?)|=>/,contains:[u,b,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},m,_,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[T]},{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,T,m]}]}}function W6(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))?",c=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","raw","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],u=["true","false","Some","None","Ok","Err"],p=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],h=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f16","f32","f64","f128","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:h,keyword:c,literal:u,built_in:p},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:p,type:h}},{scope:"punctuation",begin:"->"},i]}}const hf="[A-Za-z$_][0-9A-Za-z$_]*",rN=["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"],oN=["true","false","null","undefined","NaN","Infinity"],sN=["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"],iN=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],aN=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],lN=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],cN=[].concat(aN,sN,iN);function K6(e){const t=e.regex,n=(Z,{after:Y})=>{const q="</"+Z[0].slice(1);return Z.input.indexOf(q,Y)!==-1},r=hf,o={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(Z,Y)=>{const q=Z[0].length+Z.index,z=Z.input[q];if(z==="<"||z===","){Y.ignoreMatch();return}z===">"&&(n(Z,{after:q})||Y.ignoreMatch());let te;const Ee=Z.input.substring(q);if(te=Ee.match(/^\s*=/)){Y.ignoreMatch();return}if((te=Ee.match(/^\s+extends\s+/))&&te.index===0){Y.ignoreMatch();return}}},c={$pattern:hf,keyword:rN,literal:oN,built_in:cN,"variable.language":lN},u="[0-9](_?[0-9])*",p=`\\.(${u})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${h})((${p})|\\.)?|(${p}))[eE][+-]?(${u})\\b`},{begin:`\\b(${h})\\b((${p})\\b|\\.)?|(${p})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},w={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},b={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},_={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},E={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]},N=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,y,b,_,{match:/\$\d+/},m];g.contains=N.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(N)});const j=[].concat(E,g.contains),$=j.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(j)}]),P={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:$},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"}}]},A={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:{_:[...sN,...iN]}},O={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},B={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[P],illegal:/%/},H={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function Q(Z){return t.concat("(?!",Z.join("|"),")")}const re={match:t.concat(/\b/,Q([...aN,"super","import","await"].map(Z=>`${Z}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},J={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},ie={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},P]},ve="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",C={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ve)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[P]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:$,CLASS_REFERENCE:A},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),O,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,y,b,_,E,{match:/\$\d+/},m,A,{scope:"attr",match:r+t.lookahead(":"),relevance:0},C,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[E,e.REGEXP_MODE,{className:"function",begin:ve,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:$}]}]},{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"]}]}]},B,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[P,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},J,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[P]},re,H,R,ie,{match:/\$[(.]/}]}}function Z6(e){const t=e.regex,n=K6(e),r=hf,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]},c={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},u=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],p={$pattern:hf,keyword:rN.concat(u),literal:oN,built_in:cN.concat(o),"variable.language":lN},h={className:"meta",begin:"@"+r},m=(b,_,T)=>{const E=b.contains.findIndex(N=>N.label===_);if(E===-1)throw new Error("can not find mode to replace");b.contains.splice(E,1,T)};Object.assign(n.keywords,p),n.exports.PARAMS_CONTAINS.push(h);const g=n.contains.find(b=>b.scope==="attr"),w=Object.assign({},g,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,g,w]),n.contains=n.contains.concat([h,i,l,w]),m(n,"shebang",e.SHEBANG()),m(n,"use_strict",c);const y=n.contains.find(b=>b.label==="func.def");return y.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function q6(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:/\)/}),c=e.inherit(e.APOS_STRING_MODE,{className:"string"}),u=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),p={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,u,c,l,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,l,u,c]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},o,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[u]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[p],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:"css"}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[p],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:p}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function G6(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]},c=e.inherit(l,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),g={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},w={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},y={begin:/\{/,end:/\}/,contains:[w],illegal:"\\n",relevance:0},b={begin:"\\[",end:"\\]",contains:[w],illegal:"\\n",relevance:0},_=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},g,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},y,b,i,l],T=[..._];return T.pop(),T.push(c),w.contains=T,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:_}}var im,lx;function V6(){if(lx)return im;lx=1;function e(U){return U instanceof Map?U.clear=U.delete=U.set=function(){throw new Error("map is read-only")}:U instanceof Set&&(U.add=U.clear=U.delete=function(){throw new Error("set is read-only")}),Object.freeze(U),Object.getOwnPropertyNames(U).forEach(me=>{const ze=U[me],Xe=typeof ze;(Xe==="object"||Xe==="function")&&!Object.isFrozen(ze)&&e(ze)}),U}class t{constructor(me){me.data===void 0&&(me.data={}),this.data=me.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(U){return U.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(U,...me){const ze=Object.create(null);for(const Xe in U)ze[Xe]=U[Xe];return me.forEach(function(Xe){for(const Mt in Xe)ze[Mt]=Xe[Mt]}),ze}const o="</span>",i=U=>!!U.scope,l=(U,{prefix:me})=>{if(U.startsWith("language:"))return U.replace("language:","language-");if(U.includes(".")){const ze=U.split(".");return[`${me}${ze.shift()}`,...ze.map((Xe,Mt)=>`${Xe}${"_".repeat(Mt+1)}`)].join(" ")}return`${me}${U}`};class c{constructor(me,ze){this.buffer="",this.classPrefix=ze.classPrefix,me.walk(this)}addText(me){this.buffer+=n(me)}openNode(me){if(!i(me))return;const ze=l(me.scope,{prefix:this.classPrefix});this.span(ze)}closeNode(me){i(me)&&(this.buffer+=o)}value(){return this.buffer}span(me){this.buffer+=`<span class="${me}">`}}const u=(U={})=>{const me={children:[]};return Object.assign(me,U),me};class p{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(me){this.top.children.push(me)}openNode(me){const ze=u({scope:me});this.add(ze),this.stack.push(ze)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(me){return this.constructor._walk(me,this.rootNode)}static _walk(me,ze){return typeof ze=="string"?me.addText(ze):ze.children&&(me.openNode(ze),ze.children.forEach(Xe=>this._walk(me,Xe)),me.closeNode(ze)),me}static _collapse(me){typeof me!="string"&&me.children&&(me.children.every(ze=>typeof ze=="string")?me.children=[me.children.join("")]:me.children.forEach(ze=>{p._collapse(ze)}))}}class h extends p{constructor(me){super(),this.options=me}addText(me){me!==""&&this.add(me)}startScope(me){this.openNode(me)}endScope(){this.closeNode()}__addSublanguage(me,ze){const Xe=me.root;ze&&(Xe.scope=`language:${ze}`),this.add(Xe)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function m(U){return U?typeof U=="string"?U:U.source:null}function g(U){return b("(?=",U,")")}function w(U){return b("(?:",U,")*")}function y(U){return b("(?:",U,")?")}function b(...U){return U.map(ze=>m(ze)).join("")}function _(U){const me=U[U.length-1];return typeof me=="object"&&me.constructor===Object?(U.splice(U.length-1,1),me):{}}function T(...U){return"("+(_(U).capture?"":"?:")+U.map(Xe=>m(Xe)).join("|")+")"}function E(U){return new RegExp(U.toString()+"|").exec("").length-1}function N(U,me){const ze=U&&U.exec(me);return ze&&ze.index===0}const j=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function $(U,{joinWith:me}){let ze=0;return U.map(Xe=>{ze+=1;const Mt=ze;let Nt=m(Xe),He="";for(;Nt.length>0;){const Fe=j.exec(Nt);if(!Fe){He+=Nt;break}He+=Nt.substring(0,Fe.index),Nt=Nt.substring(Fe.index+Fe[0].length),Fe[0][0]==="\\"&&Fe[1]?He+="\\"+String(Number(Fe[1])+Mt):(He+=Fe[0],Fe[0]==="("&&ze++)}return He}).map(Xe=>`(${Xe})`).join(me)}const P=/\b\B/,R="[a-zA-Z]\\w*",A="[a-zA-Z_]\\w*",O="\\b\\d+(\\.\\d+)?",B="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",H="\\b(0b[01]+)",Q="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",re=(U={})=>{const me=/^#![ ]*\//;return U.binary&&(U.begin=b(me,/.*\b/,U.binary,/\b.*/)),r({scope:"meta",begin:me,end:/$/,relevance:0,"on:begin":(ze,Xe)=>{ze.index!==0&&Xe.ignoreMatch()}},U)},J={begin:"\\\\[\\s\\S]",relevance:0},ie={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[J]},ve={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[J]},C={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/},Z=function(U,me,ze={}){const Xe=r({scope:"comment",begin:U,end:me,contains:[]},ze);Xe.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 Mt=T("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 Xe.contains.push({begin:b(/[ ]+/,"(",Mt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Xe},Y=Z("//","$"),q=Z("/\\*","\\*/"),z=Z("#","$"),te={scope:"number",begin:O,relevance:0},Ee={scope:"number",begin:B,relevance:0},Ne={scope:"number",begin:H,relevance:0},de={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[J,{begin:/\[/,end:/\]/,relevance:0,contains:[J]}]},we={scope:"title",begin:R,relevance:0},ae={scope:"title",begin:A,relevance:0},G={begin:"\\.\\s*"+A,relevance:0};var Le=Object.freeze({__proto__:null,APOS_STRING_MODE:ie,BACKSLASH_ESCAPE:J,BINARY_NUMBER_MODE:Ne,BINARY_NUMBER_RE:H,COMMENT:Z,C_BLOCK_COMMENT_MODE:q,C_LINE_COMMENT_MODE:Y,C_NUMBER_MODE:Ee,C_NUMBER_RE:B,END_SAME_AS_BEGIN:function(U){return Object.assign(U,{"on:begin":(me,ze)=>{ze.data._beginMatch=me[1]},"on:end":(me,ze)=>{ze.data._beginMatch!==me[1]&&ze.ignoreMatch()}})},HASH_COMMENT_MODE:z,IDENT_RE:R,MATCH_NOTHING_RE:P,METHOD_GUARD:G,NUMBER_MODE:te,NUMBER_RE:O,PHRASAL_WORDS_MODE:C,QUOTE_STRING_MODE:ve,REGEXP_MODE:de,RE_STARTERS_RE:Q,SHEBANG:re,TITLE_MODE:we,UNDERSCORE_IDENT_RE:A,UNDERSCORE_TITLE_MODE:ae});function ke(U,me){U.input[U.index-1]==="."&&me.ignoreMatch()}function ne(U,me){U.className!==void 0&&(U.scope=U.className,delete U.className)}function ge(U,me){me&&U.beginKeywords&&(U.begin="\\b("+U.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",U.__beforeBegin=ke,U.keywords=U.keywords||U.beginKeywords,delete U.beginKeywords,U.relevance===void 0&&(U.relevance=0))}function je(U,me){Array.isArray(U.illegal)&&(U.illegal=T(...U.illegal))}function Ce(U,me){if(U.match){if(U.begin||U.end)throw new Error("begin & end are not supported with match");U.begin=U.match,delete U.match}}function Se(U,me){U.relevance===void 0&&(U.relevance=1)}const Me=(U,me)=>{if(!U.beforeMatch)return;if(U.starts)throw new Error("beforeMatch cannot be used with starts");const ze=Object.assign({},U);Object.keys(U).forEach(Xe=>{delete U[Xe]}),U.keywords=ze.keywords,U.begin=b(ze.beforeMatch,g(ze.begin)),U.starts={relevance:0,contains:[Object.assign(ze,{endsParent:!0})]},U.relevance=0,delete ze.beforeMatch},wt=["of","and","for","in","not","or","if","then","parent","list","value"],on="keyword";function St(U,me,ze=on){const Xe=Object.create(null);return typeof U=="string"?Mt(ze,U.split(" ")):Array.isArray(U)?Mt(ze,U):Object.keys(U).forEach(function(Nt){Object.assign(Xe,St(U[Nt],me,Nt))}),Xe;function Mt(Nt,He){me&&(He=He.map(Fe=>Fe.toLowerCase())),He.forEach(function(Fe){const Ke=Fe.split("|");Xe[Ke[0]]=[Nt,Yt(Ke[0],Ke[1])]})}}function Yt(U,me){return me?Number(me):zt(U)?0:1}function zt(U){return wt.includes(U.toLowerCase())}const Ht={},De=U=>{console.error(U)},_t=(U,...me)=>{console.log(`WARN: ${U}`,...me)},sn=(U,me)=>{Ht[`${U}/${me}`]||(console.log(`Deprecated as of ${U}. ${me}`),Ht[`${U}/${me}`]=!0)},ln=new Error;function lt(U,me,{key:ze}){let Xe=0;const Mt=U[ze],Nt={},He={};for(let Fe=1;Fe<=me.length;Fe++)He[Fe+Xe]=Mt[Fe],Nt[Fe+Xe]=!0,Xe+=E(me[Fe-1]);U[ze]=He,U[ze]._emit=Nt,U[ze]._multi=!0}function jt(U){if(Array.isArray(U.begin)){if(U.skip||U.excludeBegin||U.returnBegin)throw De("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ln;if(typeof U.beginScope!="object"||U.beginScope===null)throw De("beginScope must be object"),ln;lt(U,U.begin,{key:"beginScope"}),U.begin=$(U.begin,{joinWith:""})}}function Kt(U){if(Array.isArray(U.end)){if(U.skip||U.excludeEnd||U.returnEnd)throw De("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ln;if(typeof U.endScope!="object"||U.endScope===null)throw De("endScope must be object"),ln;lt(U,U.end,{key:"endScope"}),U.end=$(U.end,{joinWith:""})}}function xn(U){U.scope&&typeof U.scope=="object"&&U.scope!==null&&(U.beginScope=U.scope,delete U.scope)}function Pt(U){xn(U),typeof U.beginScope=="string"&&(U.beginScope={_wrap:U.beginScope}),typeof U.endScope=="string"&&(U.endScope={_wrap:U.endScope}),jt(U),Kt(U)}function jn(U){function me(He,Fe){return new RegExp(m(He),"m"+(U.case_insensitive?"i":"")+(U.unicodeRegex?"u":"")+(Fe?"g":""))}class ze{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Fe,Ke){Ke.position=this.position++,this.matchIndexes[this.matchAt]=Ke,this.regexes.push([Ke,Fe]),this.matchAt+=E(Fe)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Fe=this.regexes.map(Ke=>Ke[1]);this.matcherRe=me($(Fe,{joinWith:"|"}),!0),this.lastIndex=0}exec(Fe){this.matcherRe.lastIndex=this.lastIndex;const Ke=this.matcherRe.exec(Fe);if(!Ke)return null;const ht=Ke.findIndex((Ft,Zt)=>Zt>0&&Ft!==void 0),Ct=this.matchIndexes[ht];return Ke.splice(0,ht),Object.assign(Ke,Ct)}}class Xe{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Fe){if(this.multiRegexes[Fe])return this.multiRegexes[Fe];const Ke=new ze;return this.rules.slice(Fe).forEach(([ht,Ct])=>Ke.addRule(ht,Ct)),Ke.compile(),this.multiRegexes[Fe]=Ke,Ke}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Fe,Ke){this.rules.push([Fe,Ke]),Ke.type==="begin"&&this.count++}exec(Fe){const Ke=this.getMatcher(this.regexIndex);Ke.lastIndex=this.lastIndex;let ht=Ke.exec(Fe);if(this.resumingScanAtSamePosition()&&!(ht&&ht.index===this.lastIndex)){const Ct=this.getMatcher(0);Ct.lastIndex=this.lastIndex+1,ht=Ct.exec(Fe)}return ht&&(this.regexIndex+=ht.position+1,this.regexIndex===this.count&&this.considerAll()),ht}}function Mt(He){const Fe=new Xe;return He.contains.forEach(Ke=>Fe.addRule(Ke.begin,{rule:Ke,type:"begin"})),He.terminatorEnd&&Fe.addRule(He.terminatorEnd,{type:"end"}),He.illegal&&Fe.addRule(He.illegal,{type:"illegal"}),Fe}function Nt(He,Fe){const Ke=He;if(He.isCompiled)return Ke;[ne,Ce,Pt,Me].forEach(Ct=>Ct(He,Fe)),U.compilerExtensions.forEach(Ct=>Ct(He,Fe)),He.__beforeBegin=null,[ge,je,Se].forEach(Ct=>Ct(He,Fe)),He.isCompiled=!0;let ht=null;return typeof He.keywords=="object"&&He.keywords.$pattern&&(He.keywords=Object.assign({},He.keywords),ht=He.keywords.$pattern,delete He.keywords.$pattern),ht=ht||/\w+/,He.keywords&&(He.keywords=St(He.keywords,U.case_insensitive)),Ke.keywordPatternRe=me(ht,!0),Fe&&(He.begin||(He.begin=/\B|\b/),Ke.beginRe=me(Ke.begin),!He.end&&!He.endsWithParent&&(He.end=/\B|\b/),He.end&&(Ke.endRe=me(Ke.end)),Ke.terminatorEnd=m(Ke.end)||"",He.endsWithParent&&Fe.terminatorEnd&&(Ke.terminatorEnd+=(He.end?"|":"")+Fe.terminatorEnd)),He.illegal&&(Ke.illegalRe=me(He.illegal)),He.contains||(He.contains=[]),He.contains=[].concat(...He.contains.map(function(Ct){return V(Ct==="self"?He:Ct)})),He.contains.forEach(function(Ct){Nt(Ct,Ke)}),He.starts&&Nt(He.starts,Fe),Ke.matcher=Mt(Ke),Ke}if(U.compilerExtensions||(U.compilerExtensions=[]),U.contains&&U.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return U.classNameAliases=r(U.classNameAliases||{}),Nt(U)}function Qt(U){return U?U.endsWithParent||Qt(U.starts):!1}function V(U){return U.variants&&!U.cachedVariants&&(U.cachedVariants=U.variants.map(function(me){return r(U,{variants:null},me)})),U.cachedVariants?U.cachedVariants:Qt(U)?r(U,{starts:U.starts?r(U.starts):null}):Object.isFrozen(U)?r(U):U}var pe="11.11.2";class Ye extends Error{constructor(me,ze){super(me),this.name="HTMLInjectionError",this.html=ze}}const nt=n,yt=r,Jt=Symbol("nomatch"),ye=7,Ie=function(U){const me=Object.create(null),ze=Object.create(null),Xe=[];let Mt=!0;const Nt="Could not find the language '{}', did you forget to load/include a language module?",He={disableAutodetect:!0,name:"Plain text",contains:[]};let Fe={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:h};function Ke(Te){return Fe.noHighlightRe.test(Te)}function ht(Te){let Ge=Te.className+" ";Ge+=Te.parentNode?Te.parentNode.className:"";const rt=Fe.languageDetectRe.exec(Ge);if(rt){const et=wn(rt[1]);return et||(_t(Nt.replace("{}",rt[1])),_t("Falling back to no-highlight mode for this block.",Te)),et?rt[1]:"no-highlight"}return Ge.split(/\s+/).find(et=>Ke(et)||wn(et))}function Ct(Te,Ge,rt){let et="",cn="";typeof Ge=="object"?(et=Te,rt=Ge.ignoreIllegals,cn=Ge.language):(sn("10.7.0","highlight(lang, code, ...args) has been deprecated."),sn("10.7.0",`Please use highlight(code, options) instead.
|
|
199
|
+
https://github.com/highlightjs/highlight.js/issues/2277`),cn=Te,et=Ge),rt===void 0&&(rt=!0);const yn={code:et,language:cn};pt("before:highlight",yn);const ar=yn.result?yn.result:Ft(yn.language,yn.code,rt);return ar.code=yn.code,pt("after:highlight",ar),ar}function Ft(Te,Ge,rt,et){const cn=Object.create(null);function yn(D,oe){return D.keywords[oe]}function ar(){if(!vt.keywords){En.addText(un);return}let D=0;vt.keywordPatternRe.lastIndex=0;let oe=vt.keywordPatternRe.exec(un),be="";for(;oe;){be+=un.substring(D,oe.index);const Ae=nr.case_insensitive?oe[0].toLowerCase():oe[0],Ve=yn(vt,Ae);if(Ve){const[It,rn]=Ve;if(En.addText(be),be="",cn[Ae]=(cn[Ae]||0)+1,cn[Ae]<=ye&&(Tr+=rn),It.startsWith("_"))be+=oe[0];else{const Wn=nr.classNameAliases[It]||It;fe(oe[0],Wn)}}else be+=oe[0];D=vt.keywordPatternRe.lastIndex,oe=vt.keywordPatternRe.exec(un)}be+=un.substring(D),En.addText(be)}function Fr(){if(un==="")return;let D=null;if(typeof vt.subLanguage=="string"){if(!me[vt.subLanguage]){En.addText(un);return}D=Ft(vt.subLanguage,un,!0,fs[vt.subLanguage]),fs[vt.subLanguage]=D._top}else D=bn(un,vt.subLanguage.length?vt.subLanguage:null);vt.relevance>0&&(Tr+=D.relevance),En.__addSublanguage(D._emitter,D.language)}function K(){vt.subLanguage!=null?Fr():ar(),un=""}function fe(D,oe){D!==""&&(En.startScope(oe),En.addText(D),En.endScope())}function Qe(D,oe){let be=1;const Ae=oe.length-1;for(;be<=Ae;){if(!D._emit[be]){be++;continue}const Ve=nr.classNameAliases[D[be]]||D[be],It=oe[be];Ve?fe(It,Ve):(un=It,ar(),un=""),be++}}function At(D,oe){return D.scope&&typeof D.scope=="string"&&En.openNode(nr.classNameAliases[D.scope]||D.scope),D.beginScope&&(D.beginScope._wrap?(fe(un,nr.classNameAliases[D.beginScope._wrap]||D.beginScope._wrap),un=""):D.beginScope._multi&&(Qe(D.beginScope,oe),un="")),vt=Object.create(D,{parent:{value:vt}}),vt}function gt(D,oe,be){let Ae=N(D.endRe,be);if(Ae){if(D["on:end"]){const Ve=new t(D);D["on:end"](oe,Ve),Ve.isMatchIgnored&&(Ae=!1)}if(Ae){for(;D.endsParent&&D.parent;)D=D.parent;return D}}if(D.endsWithParent)return gt(D.parent,oe,be)}function qt(D){return vt.matcher.regexIndex===0?(un+=D[0],1):(L=!0,0)}function Br(D){const oe=D[0],be=D.rule,Ae=new t(be),Ve=[be.__beforeBegin,be["on:begin"]];for(const It of Ve)if(It&&(It(D,Ae),Ae.isMatchIgnored))return qt(oe);return be.skip?un+=oe:(be.excludeBegin&&(un+=oe),K(),!be.returnBegin&&!be.excludeBegin&&(un=oe)),At(be,D),be.returnBegin?0:oe.length}function hr(D){const oe=D[0],be=Ge.substring(D.index),Ae=gt(vt,D,be);if(!Ae)return Jt;const Ve=vt;vt.endScope&&vt.endScope._wrap?(K(),fe(oe,vt.endScope._wrap)):vt.endScope&&vt.endScope._multi?(K(),Qe(vt.endScope,D)):Ve.skip?un+=oe:(Ve.returnEnd||Ve.excludeEnd||(un+=oe),K(),Ve.excludeEnd&&(un=oe));do vt.scope&&En.closeNode(),!vt.skip&&!vt.subLanguage&&(Tr+=vt.relevance),vt=vt.parent;while(vt!==Ae.parent);return Ae.starts&&At(Ae.starts,D),Ve.returnEnd?0:oe.length}function vo(){const D=[];for(let oe=vt;oe!==nr;oe=oe.parent)oe.scope&&D.unshift(oe.scope);D.forEach(oe=>En.openNode(oe))}let Nr={};function xr(D,oe){const be=oe&&oe[0];if(un+=D,be==null)return K(),0;if(Nr.type==="begin"&&oe.type==="end"&&Nr.index===oe.index&&be===""){if(un+=Ge.slice(oe.index,oe.index+1),!Mt){const Ae=new Error(`0 width match regex (${Te})`);throw Ae.languageName=Te,Ae.badRule=Nr.rule,Ae}return 1}if(Nr=oe,oe.type==="begin")return Br(oe);if(oe.type==="illegal"&&!rt){const Ae=new Error('Illegal lexeme "'+be+'" for mode "'+(vt.scope||"<unnamed>")+'"');throw Ae.mode=vt,Ae}else if(oe.type==="end"){const Ae=hr(oe);if(Ae!==Jt)return Ae}if(oe.type==="illegal"&&be==="")return oe.index===Ge.length||(un+=`
|
|
200
|
+
`),1;if(Re>1e5&&Re>oe.index*3)throw new Error("potential infinite loop, way more iterations than matches");return un+=be,be.length}const nr=wn(Te);if(!nr)throw De(Nt.replace("{}",Te)),new Error('Unknown language: "'+Te+'"');const ao=jn(nr);let Gt="",vt=et||ao;const fs={},En=new Fe.__emitter(Fe);vo();let un="",Tr=0,pr=0,Re=0,L=!1;try{if(nr.__emitTokens)nr.__emitTokens(Ge,En);else{for(vt.matcher.considerAll();;){Re++,L?L=!1:vt.matcher.considerAll(),vt.matcher.lastIndex=pr;const D=vt.matcher.exec(Ge);if(!D)break;const oe=Ge.substring(pr,D.index),be=xr(oe,D);pr=D.index+be}xr(Ge.substring(pr))}return En.finalize(),Gt=En.toHTML(),{language:Te,value:Gt,relevance:Tr,illegal:!1,_emitter:En,_top:vt}}catch(D){if(D.message&&D.message.includes("Illegal"))return{language:Te,value:nt(Ge),illegal:!0,relevance:0,_illegalBy:{message:D.message,index:pr,context:Ge.slice(pr-100,pr+100),mode:D.mode,resultSoFar:Gt},_emitter:En};if(Mt)return{language:Te,value:nt(Ge),illegal:!1,relevance:0,errorRaised:D,_emitter:En,_top:vt};throw D}}function Zt(Te){const Ge={value:nt(Te),illegal:!1,relevance:0,_top:He,_emitter:new Fe.__emitter(Fe)};return Ge._emitter.addText(Te),Ge}function bn(Te,Ge){Ge=Ge||Fe.languages||Object.keys(me);const rt=Zt(Te),et=Ge.filter(wn).filter(fn).map(K=>Ft(K,Te,!1));et.unshift(rt);const cn=et.sort((K,fe)=>{if(K.relevance!==fe.relevance)return fe.relevance-K.relevance;if(K.language&&fe.language){if(wn(K.language).supersetOf===fe.language)return 1;if(wn(fe.language).supersetOf===K.language)return-1}return 0}),[yn,ar]=cn,Fr=yn;return Fr.secondBest=ar,Fr}function On(Te,Ge,rt){const et=Ge&&ze[Ge]||rt;Te.classList.add("hljs"),Te.classList.add(`language-${et}`)}function Cn(Te){let Ge=null;const rt=ht(Te);if(Ke(rt))return;if(pt("before:highlightElement",{el:Te,language:rt}),Te.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Te);return}if(Te.children.length>0&&(Fe.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(Te)),Fe.throwUnescapedHTML))throw new Ye("One of your code blocks includes unescaped HTML.",Te.innerHTML);Ge=Te;const et=Ge.textContent,cn=rt?Ct(et,{language:rt,ignoreIllegals:!0}):bn(et);Te.innerHTML=cn.value,Te.dataset.highlighted="yes",On(Te,rt,cn.language),Te.result={language:cn.language,re:cn.relevance,relevance:cn.relevance},cn.secondBest&&(Te.secondBest={language:cn.secondBest.language,relevance:cn.secondBest.relevance}),pt("after:highlightElement",{el:Te,result:cn,text:et})}function Xn(Te){Fe=yt(Fe,Te)}const Hn=()=>{at(),sn("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function se(){at(),sn("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let _e=!1;function at(){function Te(){at()}if(document.readyState==="loading"){_e||window.addEventListener("DOMContentLoaded",Te,!1),_e=!0;return}document.querySelectorAll(Fe.cssSelector).forEach(Cn)}function mt(Te,Ge){let rt=null;try{rt=Ge(U)}catch(et){if(De("Language definition for '{}' could not be registered.".replace("{}",Te)),Mt)De(et);else throw et;rt=He}rt.name||(rt.name=Te),me[Te]=rt,rt.rawDefinition=Ge.bind(null,U),rt.aliases&&tr(rt.aliases,{languageName:Te})}function Wt(Te){delete me[Te];for(const Ge of Object.keys(ze))ze[Ge]===Te&&delete ze[Ge]}function kn(){return Object.keys(me)}function wn(Te){return Te=(Te||"").toLowerCase(),me[Te]||me[ze[Te]]}function tr(Te,{languageName:Ge}){typeof Te=="string"&&(Te=[Te]),Te.forEach(rt=>{ze[rt.toLowerCase()]=Ge})}function fn(Te){const Ge=wn(Te);return Ge&&!Ge.disableAutodetect}function hn(Te){Te["before:highlightBlock"]&&!Te["before:highlightElement"]&&(Te["before:highlightElement"]=Ge=>{Te["before:highlightBlock"](Object.assign({block:Ge.el},Ge))}),Te["after:highlightBlock"]&&!Te["after:highlightElement"]&&(Te["after:highlightElement"]=Ge=>{Te["after:highlightBlock"](Object.assign({block:Ge.el},Ge))})}function Tt(Te){hn(Te),Xe.push(Te)}function zr(Te){const Ge=Xe.indexOf(Te);Ge!==-1&&Xe.splice(Ge,1)}function pt(Te,Ge){const rt=Te;Xe.forEach(function(et){et[rt]&&et[rt](Ge)})}function In(Te){return sn("10.7.0","highlightBlock will be removed entirely in v12.0"),sn("10.7.0","Please use highlightElement now."),Cn(Te)}Object.assign(U,{highlight:Ct,highlightAuto:bn,highlightAll:at,highlightElement:Cn,highlightBlock:In,configure:Xn,initHighlighting:Hn,initHighlightingOnLoad:se,registerLanguage:mt,unregisterLanguage:Wt,listLanguages:kn,getLanguage:wn,registerAliases:tr,autoDetection:fn,inherit:yt,addPlugin:Tt,removePlugin:zr}),U.debugMode=function(){Mt=!1},U.safeMode=function(){Mt=!0},U.versionString=pe,U.regex={concat:b,lookahead:g,either:T,optional:y,anyNumberOfTimes:w};for(const Te in Le)typeof Le[Te]=="object"&&e(Le[Te]);return Object.assign(U,Le),U},Xt=Ie({});return Xt.newInstance=()=>Ie({}),im=Xt,Xt.HighlightJS=Xt,Xt.default=Xt,im}var Y6=V6();const X6=i1(Y6),cx={},Q6="hljs-";function J6(e){const t=X6.newInstance();return e&&i(e),{highlight:n,highlightAuto:r,listLanguages:o,register:i,registerAlias:l,registered:c};function n(u,p,h){const m=h||cx,g=typeof m.prefix=="string"?m.prefix:Q6;if(!t.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");t.configure({__emitter:eF,classPrefix:g});const w=t.highlight(p,{ignoreIllegals:!0,language:u});if(w.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:w.errorRaised});const y=w._emitter.root,b=y.data;return b.language=w.language,b.relevance=w.relevance,y}function r(u,p){const m=(p||cx).subset||o();let g=-1,w=0,y;for(;++g<m.length;){const b=m[g];if(!t.getLanguage(b))continue;const _=n(b,u,p);_.data&&_.data.relevance!==void 0&&_.data.relevance>w&&(w=_.data.relevance,y=_)}return y||{type:"root",children:[],data:{language:void 0,relevance:w}}}function o(){return t.listLanguages()}function i(u,p){if(typeof u=="string")t.registerLanguage(u,p);else{let h;for(h in u)Object.hasOwn(u,h)&&t.registerLanguage(h,u[h])}}function l(u,p){if(typeof u=="string")t.registerAliases(typeof p=="string"?p:[...p],{languageName:u});else{let h;for(h in u)if(Object.hasOwn(u,h)){const m=u[h];t.registerAliases(typeof m=="string"?m:[...m],{languageName:h})}}}function c(u){return!!t.getLanguage(u)}}class eF{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,c){return c?l+"_".repeat(c):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 uN=J6({bash:x6,css:I6,go:$6,ini:R6,javascript:D6,json:B6,markdown:U6,python:H6,rust:W6,typescript:Z6,xml:q6,yaml:G6}),ux={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 ow(e,t){const n=e&&(ux[e]??(uN.registered(e)?e:null));if(n)return n;const r=t.lastIndexOf("."),o=r<0?"":t.slice(r+1).toLowerCase();return(o?ux[o]:null)??null}const tF=/^(?:diff --git a\/\S+ b\/(\S+)|\+\+\+ (?:b\/)?(\S+))$/gm;function nF(e){const t=new Set;for(const n of e.matchAll(tF)){const r=n[1]??n[2]??"";r&&r!=="/dev/null"&&t.add(r)}return t.size===1?[...t][0]:""}const rF={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 dN(e,t){const n=[[]],r=(i,l)=>{const c=i.split(`
|
|
201
|
+
`);for(const[u,p]of c.entries()){if(u>0&&n.push([]),!p)continue;const h=n[n.length-1],m=h[h.length-1];m&&m.scope===l?m.text+=p:h.push({text:p,scope:l})}},o=(i,l)=>{for(const c of i)c.type==="text"?r(c.value,l):c.type==="element"&&o(c.children,oF(c)??l)};try{o(uN.highlight(t,e).children,"")}catch{return e.split(`
|
|
202
|
+
`).map(i=>i?[{text:i,scope:""}]:[])}return n}function oF(e){var r;const t=((r=e.properties)==null?void 0:r.className)??[];let n=null;for(const o of t){const i=rF[o.startsWith("hljs-")?o.slice(5):o];i&&(n=i)}return n}const dx=/^\d+\t/;function sw(e,t){if(!t)return[];const n=e.split(`
|
|
203
|
+
`),r=dx.test(n[0]??""),o=r?n.map(l=>{var c;return((c=dx.exec(l))==null?void 0:c[0])??""}):[],i=r?n.map((l,c)=>l.slice(o[c].length)).join(`
|
|
204
|
+
`):e;return dN(i,t).map((l,c)=>{const u=l.map(h=>({text:h.text,changed:!1,scope:h.scope})),p=o[c];return p?[{text:p,changed:!1,scope:""},...u]:u})}function sF(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"||(iF(e,o,i,t,n),o=i+1)}}return e.map((o,i)=>aF(o.spans,n[i],o.text))}function iF(e,t,n,r,o){var i,l;for(const c of["del","add"]){const u=[];for(let m=t;m<n;m++){const g=(i=e[m])==null?void 0:i.kind;(g===""||g===c)&&u.push(m)}if(u.length===0)continue;const p=u.map(m=>{var g;return((g=e[m])==null?void 0:g.text)??""}).join(`
|
|
205
|
+
`),h=dN(p,r);for(const[m,g]of u.entries())(c==="add"||((l=e[g])==null?void 0:l.kind)==="del")&&(o[g]=h[m])}}function aF(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,c=0,u=0,p=0;for(;l<o.length&&c<i.length;){const h=o[l],m=i[c],g=Math.min(h.text.length-u,m.text.length-p);if(g>0){const w={text:h.text.slice(u,u+g),changed:h.changed,scope:m.scope},y=r[r.length-1];y&&y.changed===w.changed&&y.scope===w.scope?y.text+=w.text:r.push(w)}u+=g,p+=g,u>=h.text.length&&(l++,u=0),p>=m.text.length&&(c++,p=0)}return r}Sn.use({extensions:[m6],renderer:{code({text:e,lang:t}){const n=ow((t??"").trim().toLowerCase().split(/\s+/)[0]??"","");return n?`<pre><code>${sw(e,n).map(o=>o.map(i=>i.scope?`<span class="sy-${i.scope}">${ag(i.text)}</span>`:ag(i.text)).join("")).join(`
|
|
206
|
+
`)}</code></pre>
|
|
207
|
+
`:!1},html(e){return Co!=null&&Co.keepHtml?!1:g6(e)},table:k6}});const fN=l5(window);let Co=null;fN.addHook("afterSanitizeAttributes",e=>{const t=e.tagName==="A"?e.getAttribute("href")??"":"";if(t===Q_){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=Co!=null&&Co.fileRoot?M_(Co.fileRoot,t):null,r=n?null:P_(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=_3(e.textContent??"");i&&e.setAttribute("data-path",i)}const o=Co==null?void 0:Co.base;if(e.tagName==="IMG"&&o){const i=Zk(o.dir,e.getAttribute("src")??"");i&&e.setAttribute("src",o.urls.worktreeFile(o.worktreeId,i,o.version))}});function ul(e,t){Co=t??null;const n=t!=null&&t.streaming?d6(e):e;try{return fN.sanitize(Sn.parse(n,{async:!1}))}finally{Co=null}}function lF(e,t){const[n,r]=S.useState(e),o=S.useRef(null);return S.useEffect(()=>{if(!t){o.current=null;return}o.current=v6(o.current,e.length,performance.now());let i=0;const l=()=>{const c=o.current;if(!c)return;const u=J_(c,performance.now());r(b6(e,u)),u<c.to&&(i=requestAnimationFrame(l))};return l(),()=>cancelAnimationFrame(i)},[e,t]),t?n:e}function rh(e,t){var w,y,b,_;const[n,r]=S.useState(()=>ul(e,t)),o=S.useRef(0),i=(w=t==null?void 0:t.base)==null?void 0:w.worktreeId,l=(y=t==null?void 0:t.base)==null?void 0:y.dir,c=(b=t==null?void 0:t.base)==null?void 0:b.version,u=(_=t==null?void 0:t.base)==null?void 0:_.urls,p=t==null?void 0:t.fileRoot,h=!!(t!=null&&t.keepHtml),m=!!(t!=null&&t.streaming),g=lF(e,m);return S.useEffect(()=>{const T=i!==void 0&&l!==void 0&&u!==void 0?{worktreeId:i,dir:l,version:c??null,urls:u}:void 0,E=T||p||h||m?{base:T,fileRoot:p,keepHtml:h,streaming:m}:void 0,N=performance.now()-o.current;if(m||N>=ua){o.current=performance.now(),r(ul(g,E));return}const j=setTimeout(()=>{o.current=performance.now(),r(ul(g,E))},ua-N);return()=>clearTimeout(j)},[g,i,l,c,u,p,h,m]),n}const cF=/^ {0,3}(`{3,}|~{3,})/,uF=/^#{1,6} \S/,dF=/^\s*(?:[-*+]|\d+[.)]) \S/,fF=/^> ?\S/,hF=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/,pF=/\[[^\]\n]+\]\((?:https?:|\.{0,2}\/|#)[^)\s]*\)/,mF=/\*\*[^\s*][^*\n]*\*\*/;function gF(e){var i,l;const t=e.split(`
|
|
208
|
+
`),n=new Set;let r=null,o=0;for(let c=0;c<t.length;c++){const u=t[c],p=(i=cF.exec(u))==null?void 0:i[1];if(r){p!=null&&p.startsWith(r)&&(r=null,n.add("fence"));continue}if(p){r=p;continue}uF.test(u)&&!((l=t[c+1])!=null&&l.trim())&&n.add("heading"),dF.test(u)&&++o===2&&n.add("list"),fF.test(u)&&n.add("quote"),hF.test(u)&&n.add("table"),pF.test(u)&&n.add("link"),mF.test(u)&&n.add("bold")}return n.size}function kF(e,t){if(t)return zf(t)==="markdown"?"rendered":"plain";const n=gF(e);return n>=2?"rendered":n===1?"source":"plain"}function iw({n:e,name:t,source:n,lines:r,chars:o,preview:i,text:l,href:c,onRemove:u,className:p=""}){const h=(n==null?void 0:n.path)??t??"",m=h.includes("/")?h.slice(0,h.lastIndexOf("/")):"",g=n?[m,n.ref?`at ${n.ref.slice(0,7)}`:""].filter(Boolean).join(" "):[m,`${r} ${r===1?"line":"lines"}`,`${o.toLocaleString()} chars`,i].filter(Boolean).join(" · "),w=d.jsxs(d.Fragment,{children:[d.jsx(kt,{name:"text",className:"icon-inline"}),d.jsxs("span",{className:"pick-target",children:[d.jsx("b",{children:t?t.slice(t.lastIndexOf("/")+1):n?Z2(n):p1("paste",e)}),g&&d.jsxs("span",{className:"pick-file row-dim",children:[" · ",g]})]})]}),y=l!==void 0||c!==void 0;return d.jsx(Vk,{className:We("paste-chip",p),label:w,tip:i||void 0,peek:y?d.jsx(mN,{text:l,href:c}):void 0,full:y?d.jsx(pN,{text:l,href:c,path:h||void 0}):void 0,menu:b=>c3({text:l,href:c},b),removeLabel:"Remove attachment",onRemove:u})}function hN(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(c=>c.ok?c.text():Promise.reject(new Error(String(c.status)))).then(c=>{l&&r(c)}).catch(()=>{l&&i(!0)}),()=>{l=!1}},[e,t]),{text:e??n,failed:o}}function pN({text:e,href:t,path:n}){const{text:r,failed:o}=hN(e,t),i=S.useMemo(()=>r?kF(r,n):"plain",[r,n]),[l,c]=S.useState(null);if(o)return d.jsx("p",{className:"paste-full hint",children:"Toyon could not read that back."});if(!r||i==="plain")return d.jsx("pre",{className:"paste-full paste-text",children:r});const u=l??i==="rendered";return d.jsxs("div",{className:"paste-full paste-doc",children:[d.jsx("div",{className:"paste-doc-head",children:d.jsxs(Be,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>c(!u),"data-tip":u?"Text: read it as it was sent":"Preview: read it rendered",children:[d.jsx(kt,{name:u?"text":"book",className:"icon-inline"})," ",u?"text":"preview"]})}),u?d.jsx(wF,{text:r}):d.jsx("pre",{className:"paste-doc-body paste-text",children:r})]})}function wF({text:e}){const t=S.useMemo(()=>ul(e),[e]);return d.jsx("div",{className:"paste-doc-body md md-preview",onClick:n=>{const r=n.target.closest("a");r&&r.target!=="_blank"&&n.preventDefault()},dangerouslySetInnerHTML:{__html:t}})}const yF=2e4;function mN({text:e,href:t}){const{text:n}=hN(e,t);return n?d.jsx("pre",{className:"paste-peek paste-text",children:n.slice(0,yF)}):null}function aw({name:e,bytes:t,href:n,kept:r,uploading:o,progress:i,onRemove:l,className:c=""}){const u=it();return d.jsx(Vk,{className:We("file-chip",c),label:d.jsxs(d.Fragment,{children:[d.jsx(kt,{name:"file",className:"icon-inline"}),d.jsxs("span",{className:"pick-target",children:[d.jsx("b",{children:e}),d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",Lg(t),i!==void 0?d.jsxs(d.Fragment,{children:[" ","· ",d.jsxs("span",{className:"pick-progress",children:[i,"%"]})]}):o&&" · uploading"]})]})]}),tip:e,peek:n?d.jsx(mN,{href:n}):void 0,full:n?d.jsx(pN,{href:n,path:e}):void 0,menu:p=>u3({href:n},p,r&&{...r,sock:u}),removeLabel:"Remove attachment",onRemove:l})}function gN(e){return e.replace(/^([\t ]*)\*\*(\S(?:[^\n]*\S)?)\*\*([\t ]*)$/gm,"$1$2$3")}const kN=120,vF=/^\*\*(\S(?:[^\n]*\S)?)\*\*$/;function wN(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=vF.exec(i))==null?void 0:n[1])==null?void 0:r.replace(/`/g,""))??"";if(!l||l.length>kN)return[];t.push(l)}return t}function yN(e){const t=wN(e);if(t.length)return t.at(-1);const n=gN(e).trim().replace(/`/g,"");return n&&!n.includes(`
|
|
209
|
+
`)&&n.length<=kN?n:""}const bF={read:"read",edit:"edit",delete:"delete",move:"move",search:"search",execute:"run",think:"think",fetch:"fetch",switch_mode:"mode",other:"tool"},fx={read:"book",edit:"edit",delete:"trash",move:"move",search:"search",execute:"run",think:"bulb",fetch:"globe",switch_mode:"swap",other:"dot"},vN="Skill",am=new Map([[$g,"chat"],["Monitor","clock"],["TaskOutput","terminal"],[vN,"layers"]]);function xF(e){if(e.name!==vN)return"";const t=no(e,"skill").trim();if(!t)return"";const n=no(e,"args").trim();return n?`/${t} ${n}`:`/${t}`}const lg={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"},EF=/(^|\s)(-[A-Za-z]*[iI]|--in-place)/,hx=String.raw`(?:"[^"]*"|'[^']*'|[^\s;&|]+)`,px=new RegExp(String.raw`^\s*(?:(?:cd|echo)\s+${hx}\s*(?:&&|;)|mkdir(?:\s+${hx})+\s*(?:&&|;)|(?:export\s+)?[A-Za-z_]\w*=(?:"[^"]*"|'[^']*'|[^\s;&|()\`]*)\s*(?:&&|;|(?=\s)))\s*`),SF=/^python[\d.]*$/,_F=new RegExp(`open\\([^)]*,\\s*["'][wax]|(?<!std(?:out|err))\\.write\\(|\\.write_text\\(`);function bN(e){let t=e;for(let n=t.replace(px,"");n!==t;n=t.replace(px,""))t=n;return t}const NF=new RegExp("(?<![0-9&])>{1,2}\\s*(?!\\/dev\\/null|&)[^\\s&>]"),xN=/&&|;|\n|\|/;function TF(e){return e.split(xN).some(t=>/^\s*(?:\S*\/)?sed\s/.test(t)&&EF.test(t))}function jF(e){return e.split(/&&|;|\n/).map(t=>bN(t).trim().split(/\s+/)[0]??"").filter(Boolean).every(t=>lg[t.slice(t.lastIndexOf("/")+1)]==="trash")}function CF(e){const t=bN(e).trim(),n=t.split(/\s+/)[0]??"",r=n.slice(n.lastIndexOf("/")+1),o=r==="sed"?TF(e)?void 0:"book":lg[r];if(o==="book"||o==="search"){const i=t.split(xN)[0]??"";if(NF.test(i))return r==="cat"&&i.includes("<<")?"edit":void 0}if(!(o==="trash"&&!jF(t)))return o||(SF.test(r)?t.includes("<<")&&_F.test(t)?"edit":void 0:lg[r])}function no(e,t){const n=e.input,r=n?n[t]:void 0;return typeof r=="string"?r:""}const AF=/^(?:\/(?:usr\/)?bin\/)?(?:ba|z|da)?sh\s+(?:-[a-zA-Z]+\s+)*(?:'([^']*)'|"((?:[^"\\]|\\.)*)")\s*$/;function EN(e){const t=AF.exec(e.trim());return t?t[1]!==void 0?t[1]:(t[2]??"").replace(/\\(["\\$`])/g,"$1"):e}const IF="Guardian Review";function SN(e){return e.toolKind==="think"&&e.title===IF}function $F(e){const t=o=>{var l,c;return((c=(l=[...e.matchAll(new RegExp(`^${o}:[ \\t]*(.+)$`,"gm"))].at(-1))==null?void 0:l[1])==null?void 0:c.trim().toLowerCase())??""},n=t("Status"),r=t("Risk");return!n||n==="in progress"?"reviewing":r?`${n}, ${r} risk`:n}function Kc(e,t=[]){const n=EN(no(e,"command")),r=e.name===xm?"":no(e,"query"),i=_N(e)||n||no(e,"path")||no(e,"pattern")||r||xF(e)||(e.title&&e.title!==e.name?e.title:""),l=oh(no(e,"description")||i,t),c=e.toolKind&&e.toolKind in fx?e.toolKind:"other",u=bF[c],p=e.name===$g,h=c!=="other"||am.has(e.name),m=e.name===e.title||e.name===mi||e.name===l1,g=l&&(h||m||e.name===xm)?"":e.name,w=g&&g.toLowerCase()!==u?g:l?"":u,y=(c==="execute"||c==="other")&&n?CF(n):void 0;return{label:p?"ask":u,name:w,icon:am.get(e.name)??am.get(e.title??"")??y??fx[c],hint:l===w?"":l,command:n&&n!==l?n:""}}const RF=/^Async agent launched/m;function OF(e){if(!e.subagent)return!1;const t=e.input;return!!e.detached||(t==null?void 0:t.run_in_background)===!0||!!e.output&&RF.test(e.output)}const MF={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 PF(e){const t=e.toolKind;return e.subagent?no(e,"prompt")?"":"writing the brief":!_f(e.input)||!u1({name:e.name,kind:t},e.input)?"":Rg(t)?MF[t]:"writing the question"}function cg(e,t){const n=NN(t),r=n[0],o=no(e,"description");return o&&r&&!r.code&&r.text===o?n.slice(1):n}function yl(e){return _N(e)||no(e,"path")}function LF(e){return no(e,"description")}function _N(e){return no(e,"file_path")||no(e,"filepath")||no(e,"filePath")||DF(e)}function DF(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 oh(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 zF=/^(`{3,})([\w+#.-]*)\s*$/;function NN(e){var c;const t=[];let n=[],r="",o=!1,i=0;const l=()=>{const u=n.join(`
|
|
210
|
+
`).replace(/^\n+|\n+$/g,"");u.trim()&&t.push({code:o,diff:FF(u,r),lang:o?r:"",text:u}),n=[]};for(const u of e.split(`
|
|
211
|
+
`)){const p=zF.exec(u),h=((c=p==null?void 0:p[1])==null?void 0:c.length)??0;if(!p||o&&(h<i||p[2])){n.push(u);continue}l(),o=!o,i=o?h:0,r=o?(p[2]??"").toLowerCase():""}return l(),t}function FF(e,t){return t==="diff"||t==="patch"||/^diff --git /m.test(e)||/^@@ .*@@/m.test(e)?!0:/^--- /m.test(e)&&/^[+-]/m.test(e)}const BF=/^(diff --git |index [0-9a-f]+\.\.|new file mode |deleted file mode |similarity index |rename (from|to) |Binary files )/;function UF(e){const t=[];for(const n of e.split(`
|
|
212
|
+
`)){const r=WF(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 HF(t),t}function HF(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 c=l;for(;((o=e[c])==null?void 0:o.kind)==="add";)c++;const u=e.slice(i,l),p=e.slice(l,c),h=u.length>0&&p.length>0?aA(u.map(m=>m.text).join(`
|
|
213
|
+
`),p.map(m=>m.text).join(`
|
|
214
|
+
`)):null;h&&(mx(u,zv(h.before)),mx(p,zv(h.after)));for(const m of[...u,...p])m.spans??(m.spans=[]);i=c}}function mx(e,t){if(t.length===e.length)for(const[n,r]of e.entries())r.spans=t[n]}function WF(e){return e.startsWith("@@")?"hunk":e.startsWith("+++")||e.startsWith("---")||BF.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":""}function KF(e){const t=e.tools.at(-1);return t.done||t.parentToolId?!1:t.name===mi?!t.background:!!t.background}const TN=new Set(["read","edit","fetch"]);function lw(e,t){if(e.isError||!e.toolKind||!TN.has(e.toolKind)||Rg(e.toolKind)&&_f(e.input))return"";const{hint:n}=Kc(e,t);return n?`${e.parentToolId??""}
|
|
215
|
+
${e.toolKind}
|
|
216
|
+
${e.name}
|
|
217
|
+
${n}`:""}function gx(e,t,n){if(!t||!("tools"in t)||e.done||e.isError||!e.toolKind||!TN.has(e.toolKind))return!1;const r=t.tools[0];return r.toolKind===e.toolKind&&r.name===e.name&&r.parentToolId===e.parentToolId&&lw(r,n)!==""}function ZF(e,t){const n=e.length-1,r=e[n];if(!r||!("tools"in r)||r.next)return-1;const o=r.tools[0],i=r.tools.at(-1);return o.toolKind!=="edit"||o.parentToolId||!i.done||i.isError?-1:lw(o,t)?n:-1}function jN(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 qF(e){return e.done&&!e.output&&!e.isError&&u1({name:e.name,kind:e.toolKind},e.input)}function GF(e,t){const n=jN(e),r=[],o=new Map;let i="";for(const[l,c]of e.entries()){if(c.kind!=="tool"){i="",r.push({at:l,item:c});continue}if(qF(c))continue;if(n.has(c.id)){i="";const m={at:l,spawn:c,run:[],end:l};o.set(c.id,{entry:m,key:""}),r.push(m);continue}const u=lw(c,t),p=c.parentToolId?o.get(c.parentToolId):void 0;if(p){const m=p.entry.run,g=m.at(-1);u&&u===p.key&&g?g.tools.push(c):!u&&gx(c,g,t)?g.next=c:m.push({at:l,tools:[c]}),p.key=u,p.entry.end=l;continue}const h=r.at(-1);if(u&&u===i&&h&&"tools"in h){h.tools.push(c);continue}if(!u&&gx(c,h,t)){h.next=c;continue}i=u,r.push({at:l,tools:[c]})}return r}function VF(e){return e.reduce((t,n)=>t+n.tools.length,0)}function YF(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?OF(l)?o&&!n.has(l.id)&&t.add(l.id):t.delete(l.id):t.add(l.id))}return t}function XF(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&&KF(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 QF(e){const t=jN(e);return e.some(n=>n.kind==="tool"&&!n.done&&!n.parentToolId&&!n.background&&(!t.has(n.id)||_f(n.input)))}function CN(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 c=i.tools.at(-1);if(c.done||c.background||c.name===mi)return;const u=c1({name:c.name,kind:c.toolKind});(o||r&&u)&&n.add(l),r=!0,o||(o=u)}),n}function JF(e){return e.findIndex(t=>!t.tools.at(-1).done)}function cw(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function AN(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)&&cw(n.tools,t[r].tools)})}function e8(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 c=n.get(i.at),u=c!==void 0&&t8(c,i)?c:i;return u!==e[l]&&(r=!1),u});return r?e:o}function t8(e,t){return"spawn"in e?"spawn"in t&&e.spawn===t.spawn&&e.end===t.end&&AN(e.run,t.run):"tools"in e?"tools"in t&&e.next===t.next&&cw(e.tools,t.tools):"item"in t&&e.item===t.item}function n8(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"&&!SN(r))return t;continue}if(n.item.kind==="thinking"){if(!n.item.text.trim())continue;return yN(n.item.text)?-1:t}if(r8(n.item))return-1}}return-1}function r8(e){return e.kind==="assistant"?!!e.text.trim():e.kind==="ask"?e.ask.kind==="question"||!!e.outcome:!0}function o8(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 s8({item:e}){const t=ut(),n=M(r=>dn(r,e.worktreeId)!==null);return e.state==="proposed"?null:e.state==="starting"?d.jsx(to,{icon:"spawn",word:"continuing",tone:"accent",at:e.ts,children:d.jsxs("span",{className:"daemon-text live-text",children:["in ",e.repo.name,", starting the worktree"]})}):e.state==="declined"?d.jsx(to,{icon:"close",word:"not continued",tone:"quiet",at:e.ts,below:e.reason?d.jsx("div",{className:"daemon-below row-dim",children:e.reason}):void 0,children:d.jsxs("span",{className:"daemon-text",children:["in ",e.repo.name]})}):d.jsx(to,{icon:"spawn",word:"continued",tone:"accent",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:["in ",e.repo.name,":"," ",d.jsx(Be,{variant:"inline",tone:"strong",disabled:!n,onClick:()=>e.worktreeId&&t({a:"activate",id:e.worktreeId}),children:e.title??e.repo.name})]})})}function i8({item:e}){return d.jsxs(to,{icon:"check",word:"landed",tone:"aqua",at:e.ts,children:[d.jsxs("span",{className:"daemon-text",children:[e.title," in ",e.repoName]}),e.url&&d.jsx(Be,{variant:"inline",tone:"strong",onClick:()=>window.open(e.url,"_blank"),children:"view PR"})]})}function uw({src:e,n:t,name:n,width:r,height:o,bytes:i,kept:l,uploading:c,progress:u,onRemove:p,className:h=""}){const m=it();return d.jsx(Vk,{className:We("image-chip",h),label:d.jsxs(d.Fragment,{children:[d.jsx("img",{className:"image-thumb",src:e,alt:n,width:40,height:40}),d.jsxs("span",{className:"pick-target",children:[d.jsx("b",{children:p1("image",t)}),d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",n," · ",r,"×",o," · ",Lg(i),u!==void 0?d.jsxs(d.Fragment,{children:[" ","· ",d.jsxs("span",{className:"pick-progress",children:[u,"%"]})]}):c&&" · uploading"]})]})]}),peek:d.jsx("img",{src:e,alt:n,style:{aspectRatio:`${r} / ${o}`}}),full:d.jsx("img",{src:e,alt:n}),menu:g=>Hc(e,g,l&&{...l,sock:m}),removeLabel:"Remove image",onRemove:p})}function a8({img:e,worktreeId:t,src:n}){return d.jsx(uw,{className:"in-chat",src:n,...e,kept:{worktreeId:t,file:e.file}})}function ug(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 IN(e,t,n){const r=p=>e.map((h,m)=>p(h)&&h.id!==t?m:-1).filter(h=>h>=0),i=[()=>r(p=>p.agent==="waiting"),()=>r(p=>!!p.unseen),()=>r(p=>p.agent==="working")].reduce((p,h)=>p.length>0?p:h(),[]),l=e.findIndex(p=>p.id===t),c=n>0?i.find(p=>p>l)??i[0]:i.findLast(p=>p<l)??i[i.length-1],u=c===void 0?void 0:e[c];return u?{activate:u.id}:null}function dw(e,t,n){const r=IN(e,t,n);if(r)return r;const o=e[0];return o&&o.id!==t?{activate:o.id}:null}function l8(e,t,n){const r=[ug(e,t),...n.map(o=>ug(o.rows,null))].filter(o=>o!==null);return r.length===0?null:{n:r.reduce((o,i)=>o+i.n,0),tier:r.some(o=>o.tier==="waiting")?"waiting":"unseen"}}function c8(e,t,n){const r=[i=>i.agent==="waiting",i=>!!i.unseen];for(const i of r){if(e.some(l=>i(l)&&l.id!==t)){const l=IN(e,t,1);return l&&{origin:null,activate:l.activate}}for(const l of n){const c=l.rows.find(i);if(c)return{origin:l.origin,activate:c.id}}}const o=dw(e,t,1);return o&&{origin:null,activate:o.activate}}function $N(e,{sock:t,dispatch:n}){var m,g;const r=w=>w?"hide":"show",o=e.repos.some(w=>w.id===e.activeRepoId),i=(m=dn(e,e.activeId))==null?void 0:m.worktree.id,l=[];o&&(l.push({id:"new",label:"new worktree…",key:Dt("new"),onClick:()=>n({a:"open-draft"})}),l.push({id:"refs",label:"open a branch or PR…",key:Dt("refs"),onClick:()=>n({a:"open",overlay:{kind:"refs"}})})),i&&(l.push({id:"jump",label:"jump to file…",key:Dt("quick-open"),onClick:()=>n({a:"open",overlay:{kind:"quick-open"}})}),l.push({id:"search",label:"search in files…",key:Dt("search"),onClick:()=>n({a:"open",overlay:{kind:"search"}})})),lf(e)&&l.push({id:"routes",label:"go to page…",key:Dt("routes"),onClick:()=>n({a:"open",overlay:{kind:"routes"}})}),o&&l.push({id:"chats",label:"search chats…",key:Dt("chats"),onClick:()=>n({a:"open",overlay:{kind:"chats"}})});const c=dw(e.visible,e.activeId,1);c&&l.push({id:"wt-unseen-next",label:"next that needs you",key:Dt("wt-unseen-next"),onClick:()=>n({a:"activate",id:c.activate})}),l.push({id:"project",label:e.repos.length>1?"switch project…":"open project…",key:Dt("project"),onClick:()=>n({a:"open",overlay:{kind:"projects",form:"center"}})});const u=[{id:"changes",label:`${r(e.layout.changes)} changes panel`,key:Dt("changes"),onClick:()=>n({a:"toggle-changes"})},{id:"files",label:`${r(e.layout.changes&&gl(e)==="files")} files`,key:Dt("files"),onClick:()=>n(e.layout.changes&&gl(e)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"})},{id:"chat",label:`${r(e.layout.chat)} chat panel`,key:Dt("composer"),onClick:()=>n({a:"toggle-chat"})},{id:"terminal",label:`${r(e.layout.term)} terminal`,key:Dt("terminal"),onClick:()=>n({a:"toggle-terminal"})},{id:"rail",label:`${r(e.railOpen)} worktree panel`,key:Dt("rail"),onClick:()=>n({a:"toggle-rail"})},{id:"design",label:`${r(e.layout.design)} design system`,key:Dt("design"),onClick:()=>n({a:"toggle-design"})},{id:"zen",label:"full-bleed preview",key:Dt("zen"),onClick:()=>n({a:"toggle-zen"})}],p=[{id:"commands",label:"command palette",key:Dt("commands"),onClick:()=>n({a:"open",overlay:{kind:"commands"}})},{id:"keys",label:"settings & shortcuts",key:Dt("keys"),onClick:()=>n({a:"open",overlay:{kind:"keys"}})}];(g=e.self)!=null&&g.restart&&p.push({id:"restart-daemon",label:"restart Toyon",onClick:()=>t==null?void 0:t.send({t:"restart-daemon"})}),p.push({id:"devices",label:e.knocks.length>0?`let a device in (${e.knocks.length})`:"your devices",onClick:()=>n({a:"open",overlay:{kind:"devices"}})});const h=Io(e)?new Set(["chat","design","zen"]):null;return zn([l,h?u.filter(w=>!h.has(w.id)):u,p])}function dg(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}?
|
|
218
|
+
|
|
219
|
+
It leaves your list, here and in every browser Toyon on this machine serves, and this browser forgets what it had selected there. Toyon on that machine is not touched; pair again to list it.`)&&e.serving().sock.send({t:"forget-machine",origin:t})}}];return zn([o,i])}function fw(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 RN(e,{sock:t}){return[{id:"restart:shell",label:"restart shell",onClick:()=>t==null?void 0:t.send({t:"term-restart",worktreeId:e,stream:Ao})}]}function u8(e,t,n,r){return zn([[...e.flatMap(o=>fw(o,t,r)),...RN(t,r)],[{id:"terminal",label:`${n?"hide":"show"} terminal`,onClick:()=>r.dispatch({a:"toggle-terminal"})}]])}const Zc=e=>/^(~|\/|\.\.?\/)/.test(e.trim());function hw(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 d8(e,t,n){const r=e.map(p=>p.path.slice(0,p.path.lastIndexOf("/"))).filter(Boolean),o=e.find(p=>p.id===t),i=o==null?void 0:o.path.slice(0,o.path.lastIndexOf("/")),l=new Map;for(const p of r)l.set(p,(l.get(p)??0)+1);let c="",u=0;for(const[p,h]of[...l].sort(([m],[g])=>m.localeCompare(g)))(h>u||h===u&&p===i)&&(c=p,u=h);return c?ON(c,n):`~/${iE}`}function ON(e,t){return t&&(e===t||e.startsWith(`${t}/`))?`~${e.slice(t.length)}`:e}function MN(e,t){return`${e.replace(/\/+$/,"")}/${t.trim()}`}function f8(e){const t=e.query.trim(),n=()=>e.entries.map(l=>({kind:l.isFile?"file":"dir",entry:l}));if(!Zc(t)){const l=e.repos.filter(g=>is(t,g.name,g.path)).map(g=>({kind:"repo",repo:g})),c=e.pending.filter(g=>is(t,g.name,g.url)).map(g=>({kind:"pending",pending:g})),u=[...l,...c],p=(e.others??[]).flatMap(g=>g.repos.length===0?is(t,g.name)?[{kind:"machine",machine:g}]:[]:g.repos.filter(w=>is(t,w.name,w.path,g.name)).map(w=>({kind:"repo",repo:w,machine:g})));if(!t){const g=l.find(y=>y.kind==="repo"&&y.repo.id===e.current);return[...g?[g,...l.filter(y=>y!==g)]:l,...c,{kind:"new"},{kind:"disk"},{kind:"add-machine"},...p]}const h=X2(t);if(h)return u.length>0?u:[{kind:"clone",url:h.url,name:h.name}];const m=g=>g.toLowerCase()===t.toLowerCase();return e.repos.some(g=>m(g.name))||e.pending.some(g=>m(g.name))?[...u,...p]:Lc(t)?[...u,...p]:[...u,{kind:"create",name:t,parent:null},...p]}if(e.answered.trim()!==t||!e.target)return n();const{target:r}=e;if(r.exists){const l=t.replace(/\/+$/,"")||"/";if(r.isRepo)return[...n(),{kind:"open",path:l}];if(!r.isDir)return n();const c=vl(l,e.home);return c==="/"||c===e.home||e.repos.some(p=>p.path.startsWith(`${c}/`))?n():[...n(),{kind:"init",path:l}]}if(t.endsWith("/"))return n();if(!r.parentExists)return[];const{parent:o,name:i}=hw(t);return Lc(i)?n():[...n(),{kind:"create",name:i,parent:o}]}function vl(e,t){return t&&(e==="~"||e.startsWith("~/"))?`${t}${e.slice(1)}`:e}function PN(e,t){const n=vl(e,t).replace(/\/+$/,"");return n.startsWith("/")?ON(n.slice(0,n.lastIndexOf("/"))||"/",t):null}function fg(e,t){const n=vl(e,t).replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||"/"}function h8(e){const t=e.query.trim(),n=t.lastIndexOf("/"),r=n<0?"":t.slice(0,n)||"/",o=vl(r,e.home);if(!Zc(t)||!o.startsWith("/"))return[];const i=t.slice(n+1).toLowerCase(),l=e.answered.trim()===t?e.target:null,c=!l||(i?l.parentExists:l.exists&&l.isDir&&!l.isRepo),u=e.entries.filter(h=>{if(h.isRepo||h.isFile)return!1;const m=vl(h.path,e.home);return(m.slice(0,m.lastIndexOf("/"))||"/")===o&&h.name.toLowerCase().startsWith(i)}),p=PN(r,e.home);return[...c?[{kind:"here",path:r}]:[],...p?[{kind:"up",path:p}]:[],...u.map(h=>({kind:"dir",entry:h}))]}function qc({sock:e,dispatch:t},n){t({a:"open-repo"}),e==null||e.send(n)}function LN(e,t){const{parent:n,name:r}=hw(t);qc(e,{t:"create-repo",mode:"init",parent:n,name:r})}function p8(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 sh(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}?
|
|
220
|
+
|
|
221
|
+
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 zn([o,i])}const pf={dark:"dark",light:"light",system:"follow system",daylight:"follow daylight"},mf={use:"while in use",always:"always",off:"off"};function m8(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 DN(e,{sock:t,dispatch:n}){var l;const r=e.themePrefs,o=c=>{var u;return((u=e.themes.find(p=>p.id===c))==null?void 0:u.name)??c},i=a4();return zn([[{id:"theme",label:"theme…",detail:Df(r,e.themes,LE(e)).name,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"theme"}})},{id:"appearance",topic:"theme",label:"light or dark…",detail:pf[r.mode],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"appearance"}})}],[{id:"agent",label:"default agent…",detail:((l=e.agents.find(c=>c.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:()=>l4(!i.on)}]],...e.keepAwake===null?[]:[[{id:"keep-awake",label:"keep awake…",detail:mf[e.keepAwake],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"keep-awake"}})}]],[{id:"theme-import",topic:"theme",label:"import a VS Code theme…",onClick:()=>m8((c,u)=>t==null?void 0:t.send({t:"import-theme",name:c,source:u}))},{id:"theme-rescan",topic:"theme",label:"rescan editor themes",onClick:()=>t==null?void 0:t.send({t:"rescan-themes"})}],[{id:"theme-dark",topic:"theme",label:"dark slot override…",detail:o(r.dark),sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"dark"}})},{id:"theme-light",topic:"theme",label:"light slot override…",detail:o(r.light),sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"light"}})}]])}function g8(e,t,n,r,o,i={machines:[],switchTo:()=>{},forget:()=>{}}){const l=[],c=(g,w,y,b,_)=>l.push({id:g,label:w,hint:b,run:y,sub:_}),u=(g,w)=>{for(const y of g){if(!cs(y)||y.disabled!==void 0||y.checked)continue;const b=y.key??(typeof y.detail=="string"?y.detail:void 0),_=w?`${w.scope}:${y.id}`:y.id,T=y.topic?`${y.topic}: ${y.label}`:y.label;c(_,w?`${T} · ${w.name}`:T,y.onClick,b,y.sub)}},p={sock:n,dispatch:t},h=r,m=h==null?void 0:h.worktree.id;if(u($N(e,p).filter(g=>!cs(g)||g.id!=="commands")),o&&u(sh(o,o.id,p),{scope:"project",name:o.name}),m&&!Io(e)&&(c("pick",e.picking==="chat"?"cancel element picker":"pick an element for the chat",()=>Fc(m,e.picking,t,"chat"),Dt("pick")),c("inspect",e.picking==="code"?"cancel element picker":"pick an element to open its code",()=>Fc(m,e.picking,t,"code"),Dt("inspect")),c("reload","reload preview",()=>an.post(m,{type:"reload"}))),u(DN(e,p)),h&&m){const g=e.repos.find(w=>w.id===h.worktree.repoId)??null;u(t_(h,g,e,p,{hostname:e.hostname}),{scope:"wt",name:Mm(h,g)});for(const w of h.procs)u(fw(w,m,p))}e.visible.forEach((g,w)=>{var T;if(g.worktree.id===m)return;const y=g.worktree.variant,_=!!e.activeRepoId&&g.repoId!==e.activeRepoId?` in ${((T=e.repos.find(E=>E.id===g.repoId))==null?void 0:T.name)??g.repoId}`:"";c(`go:${g.worktree.id}`,`switch to ${Mm(g,o)}${y?` (v${y.index}/${y.of})`:""}${_}`,()=>t({a:"activate",id:g.worktree.id}),RC(w,e.visible.length))});for(const g of e.repos)g.id!==(o==null?void 0:o.id)&&c(`repo:${g.id}`,`switch to project ${g.name}`,()=>t({a:"activate-repo",id:g.id}));for(const g of i.machines){for(const w of g.repos)c(`machine:${g.origin}:${w.id}`,`switch to project ${w.name} on ${g.name}`,()=>i.switchTo(g.origin,w.id));c(`forget-machine:${g.origin}`,`forget ${g.name}`,()=>i.forget(g.origin))}return l}function zN(){const e=ut(),t=it(),{host:n}=Dr(),r=Jo(),o=nS(),i=M(J=>J.picking),l=M(J=>J.layout),c=M(J=>J.chatSide),u=M(J=>J.keepAwake),p=M(J=>J.railOpen),h=M(J=>J.themePrefs),m=M(J=>J.themes),g=M(J=>J.systemDark),w=M(J=>J.daylight),y=M(J=>J.rows),b=M(J=>J.visible),_=M(J=>J.activeId),T=M(J=>J.activeRepoId),E=M(J=>J.repos),N=M(J=>J.agents),j=M(J=>J.defaultAgent),$=M(J=>J.shipping),P=M(J=>J.remote),R=M(J=>J.managed),A=M(J=>J.frame),O=M(J=>J.self),B=M(J=>J.archivedPage),H=M(J=>J.archived),Q=M(J=>J.knocks),re=M(J=>J.tailscale);return S.useMemo(()=>{const J={picking:i,layout:l,chatSide:c,keepAwake:u,railOpen:p,themePrefs:h,themes:m,systemDark:g,daylight:w,rows:y,visible:b,activeId:_,activeRepoId:T,repos:E,agents:N,defaultAgent:j,shipping:$,frame:A,self:O,archivedPage:B,archived:H,knocks:Q,hostname:n},ie={machines:o,switchTo:(ve,C)=>{var Z;(Z=r.get(ve))==null||Z.store.dispatch({a:"activate-repo",id:C}),r.activate(ve)},forget:ve=>{const C=dg(r,ve).find(Z=>cs(Z)&&Z.id.startsWith("forget-machine:"));C&&cs(C)&&C.onClick()}};return g8(J,e,t,dn(J,_),Ei(J,T),ie)},[i,l,c,u,p,h,m,g,w,y,b,_,T,E,N,j,$,P,R,A,O,B,H,Q,re,e,t,n,r,o])}function FN(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=[];for(const o of e){const i=hg(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 hg(e,t){const n=pw(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+(BN(e,l)?3:0),i=l;return r+Math.max(0,40-e.length/4)}const BN=(e,t)=>t===0||/[\s:\-–—·/.(]/.test(e[t-1]);function pw(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 c=n.indexOf(i,o);c!==-1;c=n.indexOf(i,c+1))if(BN(n,c)){l=c;break}if(l===-1)return null;r.push(l),o=l+1}return r}const is=(e,...t)=>{const n=e.trim().toLowerCase();return!n||t.some(r=>r==null?void 0:r.toLowerCase().includes(n))},k8=/^[^\s]*$/;function kx(e,t,n){if(e.startsWith("!"))return null;if(e.startsWith("/")){const l=e.indexOf(" "),c=l===-1?e.length:l;if(!(e.indexOf("/",1)!==-1&&e.indexOf("/",1)<c)&&t<=c)return{kind:"command",query:e.slice(1,t),from:0,to:c}}const r=e.lastIndexOf("@",Math.max(0,t-1));if(r===-1||r>=t||r>0&&!/\s/.test(e[r-1]??""))return null;const o=e.slice(r+1,t);if(!k8.test(o)&&!(n!=null&&n(o)))return null;let i=t;for(;i<e.length&&!/\s/.test(e[i]??"");)i++;return{kind:"file",query:o,from:r,to:i}}const vc=new Map,wx={files:new Set,folders:new Set,worktrees:vc},yx=new WeakMap;function w8(e,t=vc){if(!e)return t===vc?wx:{...wx,worktrees:t};let n=yx.get(e);return n||(n={files:new Set(e),folders:new Set($E(e)),worktrees:vc},yx.set(e,n)),t===vc?n:{...n,worktrees:t}}const y8=/(^|\s)(@\S+)/g,v8=/[.,;:!?)\]}'"]$/;function vx(e,t){if(e==="changes")return{kind:"changes",text:"@changes"};if(t.files.has(e))return{kind:"file",text:`@${e}`,path:e};const n=e.replace(/\/+$/,"");if(n&&t.folders.has(n))return{kind:"folder",text:`@${e}`,path:n};const r=t.worktrees.get(e);return r?{kind:"worktree",text:`@${e}`,id:r.id,title:r.title}:null}function b8(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(y8)){const l=i.index+(i[1]??"").length;let c=(i[2]??"").slice(1),u=vx(c,t);for(;!u&&v8.test(c);)c=c.slice(0,-1),u=c?vx(c,t):null;u&&(o(e.slice(r,l)),n.push(u),r=l+u.text.length)}return o(e.slice(r)),n}function x8(e,t,n){return{text:e.slice(0,t.from)+n+e.slice(t.to),caret:t.from+n.length}}function E8(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=i=>e.map((l,c)=>({c:l,i:c,score:i(l)})).filter(l=>l.score>0).sort((l,c)=>c.score-l.score||l.i-c.i).map(l=>l.c),o=r(i=>hg(i.name,n));return o.length>0?o:r(i=>hg(i.description,n))}function UN(e,t,n){if(!t)return[];const r=[];for(const o of e){const i=o.worktree;i.repoId!==t||i.id===n||i.kind!=="worktree"||r.push({id:i.id,title:i.title,branch:i.branch,dir:i.path.slice(i.path.lastIndexOf("/")+1),dot:Is(o),at:aa(i)})}return r}const bx=e=>e.toLowerCase().replace(/[^a-z0-9]/g,"");function xx(e,t){const n=bx(e);return n?[t.title,t.branch,t.id,t.dir].some(r=>bx(r).includes(n)):!0}const S8=/(^|\s)@\S/;function HN({text:e,worktreeId:t,root:n,inField:r}){const o=Yn(),i=it(),l=M(w=>{var y;return t?(y=w.local[t])==null?void 0:y.files:void 0}),c=M(w=>w.visible),u=M(w=>{var y;return(y=dn(w,t))==null?void 0:y.worktree.repoId}),p=S.useMemo(()=>{const w=new Map;for(const y of UN(c,u,t))w.set(y.branch,{id:y.id,title:y.title});return w},[c,u,t]),h=S.useMemo(()=>w8(l,p),[l,p]),m=S.useMemo(()=>b8(e,h),[e,h]),g=l===void 0&&t&&S8.test(e)?t:null;return S.useEffect(()=>{g&&qf(g,o.getState(),{sock:i,dispatch:o.dispatch})},[g,o,i]),d.jsx(d.Fragment,{children:m.map((w,y)=>{if(w.kind==="text")return w.text;if(w.kind==="changes"){const E=Ut("this worktree's uncommitted files",void 0,{placement:"follow"});return d.jsx("span",{className:"chat-mention","data-changes":"",...E,children:w.text},y)}if(w.kind==="worktree"){const E=Ut(`the chat of "${w.title}"`,void 0,{placement:"follow"});return d.jsx("span",{className:"chat-mention","data-worktree":w.id,...E,children:w.text},y)}if(!n||!t)return w.text;const b=w.kind==="folder",_=`${n}/${w.path}${b?"/":""}`,T=Ut(b?`${w.path}/`:w.path,void 0,{placement:"follow"});return d.jsx("a",{className:"chat-mention",href:_,tabIndex:r?-1:void 0,...T,children:w.text},y)})})}function WN(e,t,n,r){var l;const o=e.target;if(o.closest("[data-changes]")){n&&r.dispatch({a:"focus-changes",tab:"changes"});return}const i=(l=o.closest("[data-worktree]"))==null?void 0:l.getAttribute("data-worktree");if(i){r.dispatch({a:"activate",id:i});return}Gk(e,t,n,r)}function _8(e){return e.length<2||!e.every(t=>{var n;return t.length===1&&((n=t[0])==null?void 0:n.diff)})?null:T8(e.map(t=>t[0].text))}const N8=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function T8(e,t=3){let n=[];for(const r of e){const o=j8(r);if(!o)return null;const i=C8(n,o);if(!i)return null;n=i}return n.some(r=>r.kind!=="same")?A8(n,t):null}function j8(e){const t=[];let n=null;for(const r of e.split(`
|
|
222
|
+
`)){const o=N8.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 C8(e,t){const n=[];let r=0,o=0,i=0,l=0;const c=h=>{h.kind==="same"?o=h.a-h.c:h.kind==="add"?o-=1:o+=1},u=()=>{for(;r<e.length&&e[r].kind==="del";)n.push(e[r]),c(e[r]),r++},p=h=>{for(let m=h;m<e.length;m++){const g=e[m];if(g.kind!=="del")return g.c}return Number.POSITIVE_INFINITY};for(const h of t){if(h.oldStart<=l)return null;for(;r<e.length;){const w=e[r];if((w.kind==="del"?p(r):w.c)>=h.oldStart)break;n.push(w.kind==="del"?w:{...w,c:w.c+i}),c(w),r++}let m=h.oldStart,g=h.newStart;for(const w of h.ops){if(u(),w.mark==="+"){n.push({kind:"add",c:g,text:w.text}),g++;continue}const y=e[r],b=y&&y.kind!=="del"&&y.c===m?y:void 0;if(b){if(b.text!==w.text)return null;r++,c(b),w.mark===" "?n.push({...b,c:g}):b.kind==="same"&&n.push({kind:"del",a:b.a,text:b.text})}else w.mark===" "?n.push({kind:"same",a:m+o,c:g,text:w.text}):n.push({kind:"del",a:m+o,text:w.text});w.mark===" "&&g++,m++}i=g-m,l=m-1}for(;r<e.length;r++){const h=e[r];n.push(h.kind==="del"?h:{...h,c:h.c+i})}return n}function A8(e,t){const n=[];for(const r of $8(e))for(const[o,i]of R8(r.rows,t)){const l=I8(r.rows.slice(o,i)),c=l.filter(m=>m.kind!=="add").length,u=l.filter(m=>m.kind!=="del").length,p=l.find(m=>m.kind!=="add"),h=l.find(m=>m.kind!=="del");n.push(`@@ -${p?p.a:r.oldAt[o]},${c} +${h?h.c:r.newAt[o]},${u} @@`,...l.map(m=>`${m.kind==="add"?"+":m.kind==="del"?"-":" "}${m.text}`))}return n.join(`
|
|
223
|
+
`)}function I8(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 $8(e){const t=[];let n=null,r=1,o=1;for(const i of e){const l=i.kind==="add"?r:i.a,c=i.kind==="del"?o:i.c;(!n||l!==r||c!==o)&&(n={rows:[],oldAt:[],newAt:[]},t.push(n)),n.rows.push(i),n.oldAt.push(l),n.newAt.push(c),r=l+(i.kind==="add"?0:1),o=c+(i.kind==="del"?0:1)}return t}function R8(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 pg({pieces:e}){return d.jsx(d.Fragment,{children:e.map((t,n)=>{const r=`${t.changed?"ch ":""}${t.scope?`sy-${t.scope}`:""}`.trim();return r?d.jsx("span",{className:r,children:t.text},n):d.jsx(S.Fragment,{children:t.text},n)})})}function mw({pick:e,worktreeId:t,tipText:n,onHover:r,onOpen:o,onRemove:i,className:l=""}){const c=e.callFile,u=e.file,p=c?{path:c,line:e.callLine}:u?{path:u,line:e.line}:null,h=c&&u?{path:u,line:e.line}:null,m=(E,N)=>`${E}${N?`:${N}`:""}`,g=E=>E.split("/").pop()??E,w=(E,N,j,$)=>o?d.jsx("button",{className:"pick-open","data-tip":$,onClick:()=>o(E,N??1),children:j}):j,y=vn("chat"),{host:b}=Dr(),_=S.useRef(null),T=i?()=>{r==null||r(!1),i()}:void 0;return d.jsxs("div",{ref:_,className:We("pick-chip row row-sm",l),"data-tip":n,onMouseEnter:()=>r==null?void 0:r(!0),onMouseLeave:()=>r==null?void 0:r(!1),...y.contextMenu(()=>h3(e,{remove:T,host:b})),children:[d.jsxs("span",{className:"pick-target",children:[d.jsx(kt,{name:"pick",className:"icon-inline"})," ",lk(e),p&&d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",w(p.path,p.line,m(g(p.path),p.line),`Open ${m(p.path,p.line)}`)]}),h&&d.jsxs("span",{className:"pick-file row-dim",children:[" ","·"," ",w(h.path,h.line,m(h.path.split("/").pop()??h.path,h.line),`Open the component: ${m(h.path,h.line)}`)]})]}),T&&d.jsx(Ot,{icon:"close",label:"Remove attachment",tone:"quiet",onClick:T}),t&&(p==null?void 0:p.line)&&d.jsx(L_,{chip:_,children:d.jsx(P8,{worktreeId:t,path:p.path,line:p.line})})]})}const O8=6,M8=16;function P8({worktreeId:e,path:t,line:n}){const r=yk(),o=it(),i=M(m=>{var g;return((g=Oo(m))==null?void 0:g.id)===e}),l=M(m=>{var g;return i?0:(g=Ro(m,e).changedRanges[t])==null?void 0:g.offset}),[c,u]=S.useState(null);S.useEffect(()=>{let m=!0;return i||o==null||o.send({t:"changed-ranges",worktreeId:e,path:t}),r==null||r.look(e,t).then(g=>{m&&u(g)}),()=>{m=!1}},[r,o,e,t,i]);const p=S.useMemo(()=>{if(c===null||l===void 0)return null;const m=c.split(`
|
|
224
|
+
`),g=n-l,w=Math.max(1,g-O8),y=Math.min(m.length,g+M8);if(w>y)return null;const b=m.slice(w-1,y);return{from:w,at:g,slice:b,painted:sw(b.join(`
|
|
225
|
+
`),ow("",t))}},[c,l,n,t]);if(!p)return null;const h=String(p.from+p.slice.length-1).length;return d.jsx("pre",{className:"pick-peek",children:p.slice.map((m,g)=>{const w=p.from+g,y=p.painted[g];return d.jsxs("span",{className:"pick-peek-line","data-state":w===p.at?"current":void 0,children:[d.jsx("span",{className:"pick-peek-n",children:String(w).padStart(h)}),y!=null&&y.length?d.jsx(pg,{pieces:y}):m||" "]},w)})})}function L8(e){return e.startsWith("!")?e.slice(1).trim():null}function gw(e){if(e.kind!=="tool"||e.name!==mi&&e.name!==l1)return null;const t=e.input;return typeof(t==null?void 0:t.command)=="string"?t.command:null}function KN(e){var t;return e.kind!=="tool"||e.name!==mi||(t=e.input)!=null&&t.landing?null:gw(e)}function D8(e){return e.length>0&&e.every(t=>t.kind==="tool"&&KN(t)!==null&&t.done&&!t.isError)}function z8(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=gw(o);if(i===null)continue;const l=NN(o.output??"").map(u=>u.text).join(`
|
|
226
|
+
`),c=M2(l);t.unshift(`$ ${i}${c?`
|
|
227
|
+
${c}`:""}`)}if(t.length!==0)return`Shell commands the user ran since their last message, and what each printed:
|
|
228
|
+
${t.join(`
|
|
229
|
+
`)}`}const Ex={diff:"Open this file's diff in the editor pane",file:"Open this file in the editor pane",preview:"Read this file rendered in the editor pane"};function ZN(e,t,n,r){const o=e[0];if(!o||!n)return[];const i=oh(yl(o),t);return i?i.startsWith("/")?[{label:"open",tip:Ex.file,open:()=>eg(r,n.id,{href:i,path:i})}]:[...wi(i)==="preview"?["preview"]:[],...o.toolKind==="edit"?["diff"]:[],"file"].map(c=>({label:`open ${c}`,tip:Ex[c],open:()=>er(r,{worktreeId:n.id,path:i,view:c})})):[]}const F8=(...e)=>ZN(...e)[0]??null;function B8(e,t,n,r,o){const{sock:i}=r,l=e[0];if(!l)return[];const c=[],u=oh(yl(l),t),p=ZN(e,t,n,r).map(_=>({id:_.label.replace(" ","-"),label:_.label,onClick:_.open}));u&&!u.startsWith("/")&&n?c.push(...p,...Qo(()=>i==null?void 0:i.send({t:"reveal",worktreeId:n.id,path:u}),Xo(i))):u.startsWith("/")&&c.push(...p,...Qo(()=>i==null?void 0:i.send({t:"reveal-path",path:u}),Xo(i)));const h=[],m=yl(l);u&&m&&h.push({id:"copy-path",label:"copy path",onClick:()=>en(m)});const g=Kc(l,t).command,w=LF(l);w&&w!==g&&h.push({id:"copy-description",label:"copy description",onClick:()=>en(w)}),g&&h.push({id:"copy-command",label:"copy command",onClick:()=>en(g)});const y=e.map(_=>_.output??"").filter(Boolean).join(`
|
|
230
|
+
`);y&&h.push({id:"copy-output",label:"copy output",onClick:()=>en(y)});const b=o.leaf?[]:[{id:"fold",label:o.open?"collapse":"expand",onClick:o.toggle}];return zn([c,h,b])}const qN=e=>e.replace(/\n$/,""),U8=1500,Sx=4;function GN(e){return e.closest(".md pre, .card-code pre")}function mg(e){const t=GN(e);return t?qN(t.textContent??""):null}function H8(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{pre:t,top:r.top-n.top+e.scrollTop+Sx,right:n.left+e.clientLeft+e.clientWidth-r.right+Sx}}function kw(e){const[t,n]=S.useState(null),[r,o]=S.useState(null);if(S.useEffect(()=>{const p=e.current;if(!p)return;const h=g=>{if(!(g.target instanceof Element)||g.target.closest(".code-copy"))return;const w=GN(g.target);n(w&&p.contains(w)?H8(p,w):null)},m=()=>n(null);return p.addEventListener("pointerover",h),p.addEventListener("pointerleave",m),()=>{p.removeEventListener("pointerover",h),p.removeEventListener("pointerleave",m)}},[e]),S.useEffect(()=>{if(!r)return;const p=setTimeout(()=>o(null),U8);return()=>clearTimeout(p)},[r]),!(t!=null&&t.pre.isConnected))return null;const{pre:i,top:l,right:c}=t,u=r===i;return d.jsx(Ot,{className:"code-copy",style:{top:l,right:c},icon:u?"check":"copy",label:u?"Copied":"Copy code",onClick:()=>{en(qN(i.textContent??"")),o(i)}})}function W8(e){for(const t of e.split(`
|
|
231
|
+
`)){const n=/^#{1,6}\s+(.+?)\s*#*\s*$/.exec(t);if(n)return n[1];if(t.trim()&&!t.startsWith("<!--"))return null}return null}function K8(e){return e.slice(e.lastIndexOf("/")+1).replace(/\.md$/,"")}function VN(e,t){var c;const n=yk(),r=(c=Rt(e,"git"))==null?void 0:c.version,[o,i]=S.useState(null);return ft([n,e,t,r],()=>{if(!n||!e||!t)return;let u=!0;return n.look(e,t).then(p=>{u&&i({plan:t,title:p?W8(p):null})}),()=>{u=!1}}),(o&&o.plan===t?o.title:null)??(t?K8(t):"")}function lm({text:e,menu:t,marked:n,worktreeId:r,fileRoot:o,streaming:i}){const l=rh(e,{fileRoot:o,streaming:i}),c=it(),u=ut(),p=vn("chat"),h=S.useRef(null);iS(h,l);const m=M(y=>{var b;return r?(b=y.local[r])==null?void 0:b.refusedLink:void 0});ft([l,m],()=>{var b;const y=h.current;if(y)for(const _ of y.querySelectorAll("a.file-link, code[data-path]")){const T=_.getAttribute("href")??_.dataset.path,E=m!==void 0&&T===m.href;_.classList.toggle("file-link-refused",E),E?((b=_.dataset).tipWas??(b.tipWas=_.dataset.tip??""),_.dataset.tip=m.message,_.dataset.tipPlacement="bottom",_.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0}))):_.dataset.tipWas!==void 0&&(_.dataset.tipWas?(_.dataset.tip=_.dataset.tipWas,_.dataset.tipPlacement="follow"):(delete _.dataset.tip,delete _.dataset.tipPlacement),delete _.dataset.tipWas)}});const g=S.useRef(null),w=kw(g);return d.jsxs("div",{ref:g,className:"msg-assistant md row-edge","data-state":vr({cursor:n}),...p.contextMenu((y,b)=>t(qk(b,o),mg(b))),onClick:y=>Gk(y,o,r,{sock:c,dispatch:u}),children:[d.jsx("div",{ref:h}),w]})}const cm=40;function YN(e,t){return e.map(n=>{const r=ow(n.lang,t||(n.diff?nF(n.text):""));if(n.diff){const o=UF(n.text);return{...n,lines:o,painted:sF(o,r)}}return{...n,lines:[],painted:n.code?sw(n.text,r):[]}})}function XN({blocks:e,path:t,worktreeId:n}){it();const r=ut();return d.jsx("div",{className:"tool-out",children:e.map((o,i)=>o.diff?d.jsxs("pre",{className:"tool-block diff",children:[o.lines.slice(0,cm).map((l,c)=>{var u;return l.kind==="hunk"?d.jsx("span",{className:"dl hunk",title:l.text},c):d.jsx("span",{className:`dl ${l.kind}`,children:(u=o.painted[c])!=null&&u.length?d.jsx(pg,{pieces:o.painted[c]}):l.text||" "},c)}),o.lines.length>cm&&d.jsxs("button",{type:"button",className:"dl more",disabled:!t||!n,"data-tip":t&&n?"Open this file's diff":void 0,onClick:()=>n&&er({dispatch:r},{worktreeId:n,path:t,view:"diff"}),children:[o.lines.length-cm," more lines"]})]},i):o.code?d.jsx("pre",{className:"tool-block",children:o.painted.length?o.painted.map((l,c)=>d.jsxs(S.Fragment,{children:[c>0?`
|
|
232
|
+
`:null,d.jsx(pg,{pieces:l})]},c)):o.text},i):d.jsx("p",{className:"tool-note",children:o.text},i))})}function Z8({image:e,worktreeId:t}){const n=Dr().attachment(t,e.file),r={worktreeId:t,file:e.file,sock:it()},[o,i]=S.useState(!1),l=vn("chat");return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"tool-image","data-tip":"Open full size","data-tip-placement":"follow",onClick:()=>i(!0),...l.contextMenu(()=>Hc(n,{open:()=>i(!0)},r)),children:d.jsx("img",{src:n,alt:e.file})}),o&&d.jsx(Kk,{owner:"chat",onClose:()=>i(!1),menu:()=>Hc(n,{},r),children:d.jsx("img",{src:n,alt:e.file})})]})}const q8=S.memo(function({item:t,roots:n,worktreeId:r}){const o=S.useMemo(()=>YN(cg(t,t.output??""),yl(t)),[t]),i=Kc(t,n).command,l=r?t.images??[]:[];return!i&&o.length===0&&l.length===0?null:d.jsxs("div",{className:"tool-part",children:[i&&d.jsx("pre",{className:"tool-block cmd",children:i}),o.length>0&&d.jsx(XN,{blocks:o,path:QN(t,n),worktreeId:r}),l.length>0&&r&&d.jsx("div",{className:"tool-out",children:l.map(c=>d.jsx(Z8,{image:c,worktreeId:r},c.file))})]})});function QN(e,t){const n=oh(yl(e),t??[]);return n.startsWith("/")?"":n}const G8=S.memo(function({text:t,item:n,roots:r,worktreeId:o}){const i=yl(n),l=S.useMemo(()=>YN([{code:!0,diff:!0,lang:"diff",text:t}],i),[t,i]);return d.jsx("div",{className:"tool-part",children:d.jsx(XN,{blocks:l,path:QN(n,r),worktreeId:o})})});function gg({className:e,state:t,auto:n,leaf:r,growing:o,label:i,summary:l,menu:c,children:u}){const[p,h]=S.useState(null),m=S.useRef(null),g=S.useRef(null),w=sS(g),y=ML(".chat-log"),b=!r&&(p??n),_=()=>{r||(b||y(m.current),h(!b))},T=vn("chat");return d.jsxs("details",{ref:m,className:We(e,r&&"leaf"),"data-state":t,open:b,onToggle:E=>{if(!E.currentTarget.open||o)return;const N=g.current;N&&(N.scrollTop=0,w.read())},...T.contextMenu((E,N)=>c({open:b,leaf:!!r,toggle:_},N)),tabIndex:-1,onPointerDown:()=>{var E;return(E=m.current)==null?void 0:E.focus({preventScroll:!0})},onKeyDown:E=>{if((E.key==="ArrowLeft"||E.key==="ArrowRight")&&!r){if(E.shiftKey||E.altKey||E.metaKey||E.ctrlKey)return;Qf([{depth:0,open:b}],0,E.key)&&_();return}E.key!=="Escape"||!b||(E.stopPropagation(),h(!1))},children:[d.jsx("summary",{"aria-label":i,tabIndex:r?-1:void 0,onClick:E=>{E.preventDefault(),_()},children:l}),d.jsx("div",{className:"tool-body",ref:g,children:u})]})}const V8=S.memo(function({item:t,open:n,streaming:r,worktreeId:o,fileRoot:i}){const l=wN(t.text),c=l.slice(0,-1),u=rh(l.length?c.join(`
|
|
233
|
+
|
|
234
|
+
`):gN(t.text),i||r?{fileRoot:i,streaming:r}:void 0),p=it(),h=ut(),m=r?"Thinking":"Thought",g=S.useRef(null);iS(g,u);const w=S.useRef(null),y=kw(w),b=d.jsx("div",{className:"tool-part",children:d.jsxs("div",{ref:w,className:"tool-out thought-out md",onClick:T=>Gk(T,i,o,{sock:p,dispatch:h}),children:[d.jsx("div",{ref:g}),y]})}),_=l.at(-1)??(r?"":yN(t.text));if(_){const T=c.length===0;return d.jsx(gg,{className:"tool-row",auto:!1,leaf:T,growing:r,label:_,menu:(E,N)=>zn([tg(mg(N)),[{id:"copy",label:"copy thought",onClick:()=>en(t.text)}],...T?[]:[[{id:"fold",label:E.open?"collapse":"expand",onClick:E.toggle}]]]),summary:d.jsxs(d.Fragment,{children:[d.jsx(kt,{name:"bulb",className:"tool-icon"}),d.jsx("span",{className:We("tool-hint thought-line",r&&"live-text"),children:_})]}),children:T?null:b})}return d.jsx(gg,{className:"tool-row",auto:!!n,growing:r,label:m,menu:(T,E)=>zn([tg(mg(E)),[{id:"copy",label:"copy thought",onClick:()=>en(t.text)}],[{id:"fold",label:T.open?"collapse":"expand",onClick:T.toggle}]]),summary:d.jsxs(d.Fragment,{children:[d.jsx(kt,{name:"bulb",className:"tool-icon"}),d.jsx("span",{className:We("tool-name",r&&"live-text"),children:m})]}),children:b})}),Gi=6,Y8={land:"the land",commit:"the commit","sync-main":"the sync","pull-main":"the pull"},Od=S.memo(function e({tools:t,run:n,next:r,live:o,working:i,held:l,since:c,queued:u,roots:p,worktreeId:h,marked:m}){const g=t[0],w=S.useMemo(()=>_8(t.map(we=>cg(we,we.output??""))),[t]),y=t.at(-1)??g,b=!y.done,_=b&&!!y.background,E=(b||!!r||!!l)&&!u||!!i,N=b&&!!u,j=ra(b||i?c:void 0),$=n?JF(n):-1,P=S.useMemo(()=>n?CN(n,!0):void 0,[n]),R=!!o,A=Kc(g,p),O=b?PF(g):"",{label:B,icon:H}=A,Q=SN(g),re=O?"":Q?"Guardian":A.name,J=O&&g.subagent?A.hint:"",ie=J||O||(Q?$F(g.output??""):A.hint),ve=!(n&&n.length>0)&&!w&&t.every(we=>{var ae;return!Kc(we,p).command&&cg(we,we.output??"").length===0&&!((ae=we.images)!=null&&ae.length)}),C=n?VF(n):0,Z=D8(t),Y=[B,ie].filter(Boolean).join(" ")+(_?", in the background":"")+(N?", queued":"")+(Z?", done":""),q=O?"":n?`${C} ${C===1?"call":"calls"}`:t.length>1?`×${t.length}`:"",z=Yn(),te=it(),Ee=M(we=>{var ae;return h?(ae=we.shipping[h])==null?void 0:ae.op:void 0}),Ne=b&&g.name===mi&&h?{worktreeId:h,toolId:y.id}:null,de=b?null:(()=>{const we=dn(z.getState(),h);return F8(t,p??[],we?{id:we.worktree.id}:null,{sock:te,dispatch:z.dispatch})})();return d.jsxs(gg,{className:We("tool-row",t.some(we=>we.isError)&&"error",g.parentToolId&&"nested",n&&"spawn",N&&"queued"),state:vr({cursor:m}),auto:R,leaf:ve,growing:E,label:n&&q?`${Y}, ${q}`:t.length>1?`${Y}, ${t.length} calls`:Y,menu:we=>{const ae=dn(z.getState(),h),G=ae?{id:ae.worktree.id}:null;return B8(t,p??[],G,{sock:te,dispatch:z.dispatch},we)},summary:d.jsxs(d.Fragment,{children:[d.jsx(kt,{name:n?"spawn":H,className:"tool-icon"}),re&&d.jsx("span",{className:We("tool-name",E&&!ie&&"live-text"),children:re}),O&&!J?d.jsx("span",{className:"tool-writing","data-tip":ie,children:d.jsx(kl,{variant:"squares"})}):ie&&d.jsx("span",{className:We("tool-hint",E&&"live-text"),children:ie}),_&&d.jsx("span",{className:"tool-status",children:"in the background"}),N&&d.jsx("span",{className:"tool-status",children:"queued"}),Z&&d.jsx(kt,{name:"check",className:"tool-done"}),j>=Gi&&d.jsx("span",{className:We("tool-age",$>=0&&"tool-age-folded"),children:Xi(j)}),q&&d.jsx("span",{className:"tool-count",children:q}),J&&d.jsx("span",{className:"tool-writing","data-tip":O,children:d.jsx(kl,{variant:"squares"})}),Ne&&d.jsx(Ot,{icon:"stop",className:"tool-stop",label:Ee?`Stop ${Y8[Ee]}: this step is killed, and what it printed so far stays`:_?"Kill what the command left running; what it printed so far stays":"Kill the command and everything it started; what it printed so far stays",onClick:we=>{we.preventDefault(),we.stopPropagation(),te==null||te.send({t:"exec-stop",...Ne})}}),de&&d.jsx(Ot,{icon:"eye",className:"tool-open",label:de.tip,onClick:we=>{we.preventDefault(),we.stopPropagation(),de.open()}})]}),children:[n&&n.length>0&&d.jsx("div",{className:"spawn-run",children:n.map((we,ae)=>d.jsx(e,{tools:we.tools,next:we.next,since:ae===$?c:void 0,queued:P==null?void 0:P.has(ae),roots:p,worktreeId:h},we.at))}),w?d.jsx(G8,{text:w,item:g,roots:p,worktreeId:h}):t.map(we=>d.jsx(q8,{item:we,roots:p,worktreeId:h},we.id))]})},(e,t)=>e.live===t.live&&e.working===t.working&&e.held===t.held&&e.since===t.since&&e.queued===t.queued&&e.next===t.next&&e.roots===t.roots&&e.worktreeId===t.worktreeId&&e.marked===t.marked&&cw(e.tools,t.tools)&&AN(e.run,t.run));function X8({item:e}){const t=it(),n=ut(),r=M(y=>y.activeId),o=M(y=>y.layout.term),i=M(y=>{var b;return((b=y.rows.find(_=>_.id===y.activeId))==null?void 0:b.login)??!1}),l=M(y=>y.managed.problem),[c,u]=S.useState(""),[p,h]=S.useState(null),m=S.useRef(!1);if(ft([i],()=>{i&&m.current&&r&&n({a:"term-stream",id:r,stream:Cs,tall:!0})}),ft([e.done],()=>{e.done&&m.current&&o&&n({a:"toggle-terminal"}),m.current=!1}),!r)return null;const g=(y,b)=>{t==null||t.send({t:"agent-auth",worktreeId:r,methodId:y,...b?{apiKey:b}:{}})},w=e.methods.find(y=>y.id===p);return d.jsxs("div",{className:`auth-card ${e.done?"done":""}`,children:[d.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&&d.jsxs("div",{className:"auth-methods",children:[e.methods.map(y=>y.needsKey?d.jsx(Be,{variant:"outline",on:p===y.id,"data-tip":y.description,onClick:()=>h(p===y.id?null:y.id),children:y.name},y.id):d.jsx(Be,{variant:"outline","data-tip":y.kind==="terminal"?"opens in the terminal pane":y.description,onClick:()=>{g(y.id),y.kind==="terminal"&&(m.current=!0)},children:y.name},y.id)),d.jsx(Be,{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&&d.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&&d.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&&w&&d.jsxs("form",{className:"auth-key",onSubmit:y=>{y.preventDefault(),c.trim()&&(g(w.id,c.trim()),u(""),h(null))},children:[d.jsx($o,{type:"password",autoFocus:!0,placeholder:`${w.name} for ${e.agentName}`,value:c,onChange:y=>u(y.target.value)}),d.jsx(Be,{type:"submit",children:"use key"})]})]})}const Q8=S.memo(function({item:t,worktreeId:n,onPickHover:r,marked:o,streaming:i}){const l=Yn(),c=it(),u=Dr(),p=vn("chat"),h={sock:c,dispatch:l.dispatch},m=()=>{var g;return(g=dn(l.getState(),n))==null?void 0:g.worktree.path};switch(t.kind){case"user":{const g=m();return d.jsxs("div",{className:"msg-user row-edge","data-state":vr({cursor:o}),...p.contextMenu((w,y)=>Ki(t,n??null,h,{link:qk(y,g)})),onClick:w=>WN(w,g,n,h),children:[t.attachments&&n&&d.jsx(th,{children:d.jsx("div",{className:"msg-attachments",children:t.attachments.map(w=>w.kind==="image"?d.jsx(a8,{img:w,worktreeId:n,src:u.attachment(n,w.file)},`${w.kind}-${w.n}`):w.kind==="file"?d.jsx(aw,{className:"in-chat",name:w.name,bytes:w.bytes,href:w.text?u.attachment(n,w.file):void 0,kept:{worktreeId:n,file:w.file}},`${w.kind}-${w.n}`):w.kind==="paste"?d.jsx(iw,{className:"in-chat",n:w.n,name:w.name,source:w.source,lines:w.lines,chars:w.chars,preview:w.preview,href:u.attachment(n,w.file)},`${w.kind}-${w.n}`):d.jsx(mw,{pick:w,className:"in-chat",tipText:"Hover to highlight on the page",onHover:y=>r==null?void 0:r(w,y),worktreeId:n,onOpen:(y,b)=>sa(l,c,n,y,b)},`${w.kind}-${w.n}`))})}),d.jsx(HN,{text:t.text,worktreeId:n,root:g})]})}case"assistant":return d.jsx(lm,{text:t.text,menu:(g,w)=>Ki(t,n??null,h,{link:g,code:w}),marked:o,worktreeId:n,fileRoot:m(),streaming:i});case"error":return d.jsx("div",{className:"msg-assistant msg-error",...p.contextMenu(()=>Ki(t,n??null,h)),children:t.text});case"auth":return d.jsx(X8,{item:t});case"ask":{const g=xP(t);if(g){const _=tk(g.questions,g.answers).join(`
|
|
235
|
+
`),T={kind:"assistant",text:_};return d.jsxs(d.Fragment,{children:[d.jsx(lm,{text:g.message,menu:(E,N)=>Ki({kind:"assistant",text:g.message},n??null,h,{link:E,code:N}),worktreeId:n,fileRoot:m()}),d.jsx("div",{className:"msg-user",...p.contextMenu(()=>Ki(T,n??null,h)),children:_})]})}const w=EP(t);if(!w)return d.jsx(S3,{item:t});const y=w.file,b={kind:"assistant",text:w.choice};return d.jsxs(d.Fragment,{children:[y?d.jsx(J8,{file:y,worktreeId:n}):w.text&&d.jsx(lm,{text:w.text,menu:(_,T)=>Ki({kind:"assistant",text:w.text},n??null,h,{link:_,code:T}),worktreeId:n,fileRoot:m()}),d.jsx("div",{className:"msg-user",...p.contextMenu(()=>Ki(b,n??null,h)),children:w.choice})]})}case"blocked":return d.jsxs(to,{icon:"lock",word:"blocked",tone:"red",below:d.jsx("div",{className:"daemon-below row-dim",children:t.reason}),...p.contextMenu(()=>Wk(t.path,void 0,Xo(h.sock))),children:[d.jsx("span",{className:"tool-name",children:t.tool}),t.path&&d.jsx("span",{className:"tool-hint",children:t.path})]});case"grafted":return d.jsxs(to,{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:[d.jsx("span",{className:"tool-name",children:t.title}),d.jsx("span",{className:"tool-hint",children:t.branch})]});case"asked":return d.jsx(to,{icon:"send",word:"asked",tone:"quiet",children:d.jsx("span",{className:"daemon-text",children:t.why})});case"stopped":return d.jsx(to,{icon:"stop",word:"stopped",tone:"quiet"});case"landed":return d.jsx(t9,{item:t});case"handoff":return d.jsx(s8,{item:t});case"handoff-landed":return d.jsx(i8,{item:t});case"restored":return d.jsx(e9,{item:t});case"adopted":return d.jsx(to,{icon:"branch",word:"taken over",tone:"quiet",at:t.ts,children:d.jsxs("span",{className:"daemon-text",children:["on ",t.branch,", its own branch"]})})}});function J8({file:e,worktreeId:t}){const n=it(),r=ut(),o=vn("chat"),i=VN(t??void 0,e);return d.jsx(to,{icon:"file",word:"plan",tone:"quiet",...o.contextMenu(()=>Wk(e,t?()=>n==null?void 0:n.send({t:"reveal",worktreeId:t,path:e}):void 0,Xo(n))),children:d.jsx("span",{className:"daemon-text",children:d.jsx(Be,{variant:"inline",tone:"strong","data-tip":e,onClick:()=>t&&er({dispatch:r},{worktreeId:t,path:e,view:"preview"}),children:i})})})}function e9({item:e}){return d.jsx(to,{icon:"reload",word:"restored",tone:"quiet",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:["after ",ck(e.ts-e.archivedAt)," in the archive, back on ",e.branch,e.uncommitted?" with its uncommitted changes":""]})})}function t9({item:e}){const t=it(),n=ut(),r=M(l=>e.archiveIds.filter(c=>dn(l,c)!==null).length),o=b_(e.ts),i=e.mark&&Pk(e.mark);return d.jsxs(to,{icon:"check",word:"landed",tone:"aqua",at:e.ts,below:i?d.jsx("div",{className:"daemon-below row-dim",children:Kr(i)}):void 0,children:[d.jsxs("span",{className:"daemon-text",children:[e.text,", ",o]}),r>0&&d.jsx(Be,{variant:"inline",tone:"strong",onClick:()=>oa(t,n,e.archiveIds),children:r>1?`archive ${r} worktrees`:"archive the other worktree"})]})}const JN=e=>e===""||e==="!";function _x(e,t){const n=new Set,r=[];for(let o=e.length-1;o>=0;o--){const i=e[o],l=KN(i),c=l!==null?`!${l}`:i.kind==="user"&&!t?i.text:null;c===null||!c.trim()||n.has(c)||(n.add(c),r.push({text:c,at:o}))}return r}function n9(e,t,n,r){if(!t){if(r!=="up"&&r!=="first"||!JN(n))return null;const c=_x(e,n==="!"),u=r==="up"?c[0]:c.at(-1);return u?{walk:{at:u.at,from:n},text:u.text}:null}if(r==="box")return{walk:null,text:t.from};const o=_x(e,t.from==="!"),i=r==="first"?o.length-1:o.findIndex(c=>c.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 r9(e,t,n,r){const o=new Map;return{rows:t.map((l,c)=>{const u=n(l,c),p=e.get(l.at),h=p&&p.row.kind===u.kind&&o9(p.row.props,u.props)?p.el:r(l,u);return o.set(l.at,{row:u,el:h}),h}),cache:o}}function o9(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((c,u)=>Object.is(c,l[u]))))return!1}return!0}const Nx={get current(){return jc.el}};function kg({items:e,next:t,worktreeId:n,onOpen:r}){const o=Dr();return d.jsx(th,{children:d.jsx("div",{className:"msg-attachments",children:Pg(e,t).map(([i,l])=>i.kind==="image"?d.jsx(uw,{className:"in-chat",src:"local"in i&&i.local||o.upload(i.upload),n:l,name:i.name,width:i.width,height:i.height,bytes:i.bytes,progress:"progress"in i?i.progress:void 0},`image-${l}`):i.kind==="file"?d.jsx(aw,{className:"in-chat",name:i.name,bytes:i.bytes,href:i.text&&i.upload?o.upload(i.upload):void 0,progress:"progress"in i?i.progress:void 0},`file-${l}`):i.kind==="paste"?d.jsx(iw,{className:"in-chat",n:l,name:i.name,source:i.source,...Vg(i.text),text:i.text},`paste-${l}`):d.jsx(mw,{className:"in-chat",pick:i,worktreeId:n,onOpen:r},`pick-${l}`))})})}function s9({entry:e,next:t,worktreeId:n,onOpen:r}){const o=ut(),i=Rt(e.id,"draft"),l=Rt(e.id,"attachments");return d.jsxs("div",{className:"msg-user queued-msg",children:[d.jsxs("span",{className:"queued-tag",children:[d.jsx(kt,{name:"clock",className:"icon-inline"}),d.jsx("span",{className:"queued-word",children:"uploading"})]}),d.jsxs("div",{className:"queued-text",children:[l.length>0&&d.jsx(kg,{items:l,next:t,worktreeId:n,onOpen:r}),i]}),d.jsxs("span",{className:"queued-actions",children:[d.jsx(Ot,{icon:"edit",label:"Edit: puts it back in the input",onClick:()=>o({a:"unsend",id:e.id})}),d.jsx(Ot,{icon:"close",label:"Remove: it is not sent",onClick:()=>o({a:"drop-out",id:e.id})})]})]})}const i9=new Set,a9=90;function um({active:e,archived:t,found:n,lead:r,tail:o}){var Jt;const i=it(),l=Yn(),c=ut(),u=M(ye=>ye.frame==="phone"),p=(e==null?void 0:e.worktree.id)??(t==null?void 0:t.id)??(n==null?void 0:n.id)??null,h=Rt(p,"chat"),m=Rt(p,"queue"),g=Rt(p,"sending"),w=S.useMemo(()=>Em(h.map(ye=>ye.kind==="user"?ye.attachments:void 0)),[h]),y=S.useMemo(()=>{let ye=w;return m.map(Ie=>{const Xt=ye;return ye=Ec(ye,Ie.attachments??[]),Xt})},[m,w]),b=M(ye=>ye.outbox),_=S.useMemo(()=>{let ye=m.reduce((Ie,Xt)=>Ec(Ie,Xt.attachments??[]),w);return b.filter(Ie=>Ie.log===p).map(Ie=>{const Xt=ye;return ye=Ec(ye,Ie.kinds.map(U=>({kind:U}))),{entry:Ie,next:Xt}})},[b,p,m,w]),T=g!=null&&g.message?m.findIndex(ye=>{var Ie;return ye.text===((Ie=g.message)==null?void 0:Ie.text)}):-1,E=S.useRef(null);Jz(E);const[N,j]=S.useState(null),$=S.useCallback(()=>{const ye=(E.current&&Jm(E.current))??"";j(Ie=>({seed:ye||(Ie==null?void 0:Ie.seed)||"",seq:((Ie==null?void 0:Ie.seq)??0)+1}))},[]),P=S.useCallback(ye=>!(ye!=null&&ye.closest("[data-pane]"))&&!l.getState().overlay,[l]);T_(Nx,Uk,$,P);const R=ye=>{if(j(null),ye){const Ie=window.getSelection();Ie==null||Ie.removeAllRanges(),Ie==null||Ie.addRange(ye)}},A=sS(E,h);ft([p],()=>A.jump());const O=A.offStart&&A.moving==="up",B=A.offEnd&&(A.moving==="down"||A.away),H=ye=>ye.preventDefault(),Q=(O||B)&&d.jsxs("div",{className:We("jump",A.away&&"jump-news"),children:[O&&d.jsx("button",{className:"jump-up",onMouseDown:H,onClick:A.start,"data-tip":"Jump to start",children:d.jsx(kt,{name:"caret-up",className:"icon-inline"})}),B&&d.jsxs("button",{className:"jump-down",onMouseDown:H,onClick:A.jump,"data-tip":"Jump to latest",children:[d.jsx(kt,{name:"caret",className:"icon-inline"}),A.away&&" new messages"]})]});S.useEffect(()=>{const ye=E.current;if(!u||!A.offEnd||!ye){c({a:"reading",on:!1});return}const Ie=()=>{var U,me;const Xt=((me=(U=Nx.current)==null?void 0:U.querySelector(":scope > .chat-input"))==null?void 0:me.offsetHeight)??0;ye.scrollHeight-ye.scrollTop-ye.clientHeight<=Xt+Wd+a9||(c({a:"reading",on:!0}),ye.removeEventListener("scroll",Ie))};return Ie(),ye.addEventListener("scroll",Ie,{passive:!0}),()=>ye.removeEventListener("scroll",Ie)},[u,A.offEnd,c]),S.useEffect(()=>()=>c({a:"reading",on:!1}),[c]);const re=Rt(p,"mark"),J=(re==null?void 0:re.by)==="walk"?re.at:void 0,ie=S.useRef(null),ve=()=>{const ye=E.current,Ie=ye==null?void 0:ye.querySelector(':scope > [data-state~="cursor"]');if(!ye||!Ie)return;const Xt=parseFloat(getComputedStyle(ye).paddingTop)||0;ye.scrollTop+=Ie.getBoundingClientRect().top-ye.getBoundingClientRect().top-Xt,A.read()};ft([J],()=>{const ye=E.current;if(ye){if(J===void 0){const Ie=ie.current;if(ie.current=null,!Ie||!JN(Ro(l.getState(),p).draft))return;Ie.bottom?A.jump():(ye.scrollTop=Ie.top,A.read());return}ie.current??(ie.current={bottom:A.pinned(),top:ye.scrollTop}),ve()}});const C=Rt(p,"sent");ft([C],()=>{C&&A.jump()});const Z=_.length,Y=S.useRef(Z);ft([Z],()=>{Z>Y.current&&A.jump(),Y.current=Z});const q=(re==null?void 0:re.by)==="reveal"?re:void 0,z=S.useMemo(()=>q?o8(h,q.seq):-1,[h,q]),te=J??(z>=0?z:void 0);ft([q==null?void 0:q.n,z],()=>{z>=0&&ve()});const Ee=S.useCallback((ye,Ie)=>{p&&(Ie?an.post(p,{type:"highlight-selector",selector:ye.selector,label:lk(ye)}):an.post(p,{type:"highlight-clear"}))},[p]),Ne=!!e&&tu(e),de=Rt(p,"cardParked"),we=S.useMemo(()=>{const ye=Ik(h);return!!ye&&de!==ye.id},[h,de]),ae=e==null?void 0:e.worktree,G=(ae==null?void 0:ae.path)??(t==null?void 0:t.path)??(n==null?void 0:n.path),ue=S.useMemo(()=>G?[G]:[],[G]),Le=S.useMemo(()=>GF(h,ue),[h,ue]),ke=S.useMemo(()=>Ne?YF(h):i9,[Ne,h]),ne=S.useMemo(()=>XF(Le,ke),[Le,ke]),ge=ne.floating,je=S.useRef([]),Ce=S.useMemo(()=>(je.current=e8(je.current,ne.flow),je.current),[ne]),Se=(e==null?void 0:e.agent)==="working",Me=Se||(e==null?void 0:e.agent)==="waiting",wt=S.useMemo(()=>Me?n8(Ce):-1,[Me,Ce]),on=Ce.at(-1),St=Se&&on&&"item"in on&&(on.item.kind==="thinking"||on.item.kind==="assistant")?Ce.length-1:-1,Yt=(Jt=Le.findLast(ye=>{var Ie;return"tools"in ye&&((Ie=ye.tools[0])==null?void 0:Ie.name)===mi}))==null?void 0:Jt.at,zt=Rt(p,"chatAt"),Ht=ra(Ne?zt:void 0),De=Rt(p,"usage"),_t=(De==null?void 0:De.heard)!==void 0&&zt!==void 0&&De.heard>zt?De.heard:void 0,sn=ra(Ne?_t:void 0),ln=ra(g&&!Ne?g.at:void 0),lt=QF(h),jt=ge.length>0,Kt=St>=0||lt||jt,xn=Se&&!Kt&&Ht<Gi?ZF(Ce,ue):-1,Pt=S.useMemo(()=>CN(Ce),[Ce]),jn=Rt(p,"running"),Qt=ye=>jn&&ye.tools.some(Ie=>Ie.id===jn.id)?jn.at:void 0,V=e==null?void 0:e.worktree.path,pe=ye=>`${p??""}:${ye}`,Ye=(ye,Ie)=>"spawn"in ye?{kind:"tool",props:{tools:[ye.spawn],run:ye.run,roots:ue,worktreeId:p}}:"tools"in ye?{kind:"tool",props:{tools:ye.tools,next:ye.next,live:Ie===wt||ye.at===Yt,held:Ie===xn,since:Qt(ye),queued:Pt.has(Ie),roots:ue,worktreeId:p,marked:ye.at===te}}:ye.item.kind==="thinking"?{kind:"thought",props:{item:ye.item,open:Ie===wt,streaming:Ie===St,worktreeId:p,fileRoot:V}}:{kind:"item",props:{item:ye.item,worktreeId:p,onPickHover:Ee,marked:ye.at===te,streaming:Se&&Ie===Ce.length-1}},nt=S.useRef(new Map),yt=r9(nt.current,Ce,Ye,(ye,Ie)=>Ie.kind==="tool"?d.jsx(Od,{...Ie.props},pe(ye.at)):Ie.kind==="thought"?d.jsx(V8,{...Ie.props},pe(ye.at)):d.jsx(Q8,{...Ie.props},pe(ye.at)));return nt.current=yt.cache,d.jsxs("div",{className:"chat-wrap",children:[d.jsxs("div",{className:"chat-log",ref:E,children:[r,yt.rows,ge.map(ye=>{var Ie;return"spawn"in ye?d.jsx(Od,{tools:[ye.spawn],run:ye.run,working:!0,since:zt,roots:ue,worktreeId:p},pe(ye.at)):((Ie=ye.tools[0])==null?void 0:Ie.name)===mi?d.jsx(Od,{tools:ye.tools,live:ye.at===Yt,since:Qt(ye),roots:ue,worktreeId:p,marked:ye.at===te},pe(ye.at)):d.jsx(Od,{tools:ye.tools,since:zt,roots:ue,worktreeId:p},pe(ye.at))}),p&&(g==null?void 0:g.message)&&d.jsxs("div",{className:"msg-user",children:[g.message.attachments&&d.jsx(kg,{items:g.message.attachments,next:w,worktreeId:p,onOpen:(ye,Ie)=>sa(l,i,p,ye,Ie)}),g.message.text]}),e&&(g||Ne&&!(e.agent==="waiting"&&we)&&!lt&&!jt&&xn<0&&!(Kt&&Ht<Gi))&&d.jsx("div",{className:"working-row",children:e.agent==="waiting"?"waiting for your answer…":Kt?Ht>=Gi&&d.jsxs("span",{children:["quiet for",d.jsx("span",{className:"working-num",children:Xi(Ht)})]}):d.jsxs("span",{className:"working-mark",children:[d.jsx(kl,{variant:"squares"}),!Ne&&g?ln>=Gi&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"waiting for the agent"}),d.jsx("span",{className:"working-num",children:Xi(ln)})]}):_t!==void 0?sn>=Gi&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"thinking"}),d.jsx("span",{className:"working-num",children:Xi(sn)})]}):Ht>=Gi&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"waiting for the model"}),d.jsx("span",{className:"working-num",children:Xi(Ht)})]})]})}),p&&m.map((ye,Ie)=>Ie===T?null:d.jsxs("div",{className:"msg-user queued-msg",children:[d.jsxs("span",{className:"queued-tag",children:[d.jsx(kt,{name:"clock",className:"icon-inline"}),d.jsx("span",{className:"queued-word",children:"queued"})]}),d.jsxs("div",{className:"queued-text",children:[ye.attachments&&d.jsx(kg,{items:ye.attachments,next:y[Ie]??w,worktreeId:p,onOpen:(Xt,U)=>sa(l,i,p,Xt,U)}),ye.text]}),d.jsxs("span",{className:"queued-actions",children:[d.jsx(Ot,{icon:"edit",label:"Edit: removes from queue, puts it back in the input",onClick:()=>NS(l,i,p,Ie)}),d.jsx(Ot,{icon:"close",label:"Remove from queue",onClick:()=>i==null?void 0:i.send({t:"unqueue",worktreeId:p,index:Ie})})]})]},`q-${Ie}`)),p&&_.map(({entry:ye,next:Ie})=>d.jsx(s9,{entry:ye,next:Ie,worktreeId:p,onOpen:(Xt,U)=>sa(l,i,p,Xt,U)},ye.id)),o]}),N&&d.jsx(__,{root:E,body:E,seed:N.seed,seq:N.seq,onClose:R,onReveal:A.read}),Q]})}function l9(){try{return localStorage.getItem(qe.installOffered)==="1"}catch{return!1}}let gf={prompt:null,offered:typeof localStorage<"u"&&l9()};const wg=new Set;function yg(e){gf={...gf,...e};for(const t of wg)t()}typeof window<"u"&&(window.addEventListener("beforeinstallprompt",e=>{e.preventDefault(),yg({prompt:e})}),window.addEventListener("appinstalled",()=>yg({prompt:null})));function eT(e){return wg.add(e),()=>{wg.delete(e)}}function tT(){return S.useSyncExternalStore(eT,()=>gf.prompt)}function c9(){return S.useSyncExternalStore(eT,()=>gf.offered)}function Tx(){try{localStorage.setItem(qe.installOffered,"1")}catch{}yg({offered:!0})}function u9(e){return!e.prompt||e.offered||e.agent!=="idle"?!1:e.chat.some(t=>t.kind==="assistant")}function nT({hints:e,note:t,className:n=""}){return d.jsxs("div",{className:`key-hints ${n}`.trim(),children:[e.map(([r,o])=>d.jsxs("span",{className:"key-hint",children:[d.jsx(Vo,{k:r}),o]},r)),t&&d.jsx("span",{className:"key-note",children:t})]})}const d9={side:"top",align:"start",offset:4,alignOffset:-10,matchWidth:-20,flip:"side",margin:8};function f9({results:e,keyOf:t,row:n,rowClass:r,nav:o,listRef:i,empty:l,note:c,groupOf:u,groupHead:p}){const h=new Set(u?e.map(u):[]);return d.jsxs(Rs,{className:"inline-picker",anchor:"parent",placement:d9,children:[d.jsxs("div",{className:"picker-list",ref:i,children:[e.map((m,g)=>{const w=u==null?void 0:u(m),y=w!==void 0&&h.size>1&&(g===0||(u==null?void 0:u(e[g-1]))!==w)?d.jsx("div",{className:"picker-group",children:(p==null?void 0:p(w))??w}):null;return d.jsxs(S.Fragment,{children:[y,d.jsx("button",{className:We("picker-item",r==null?void 0:r(m)),"data-state":vr({cursor:g===o.index}),onMouseMove:()=>g!==o.index&&o.setIndex(g),onMouseDown:b=>b.preventDefault(),onClick:()=>o.pick(m),children:n(m,g===o.index)})]},t(m))}),e.length===0&&d.jsx("div",{className:"empty",children:l})]}),d.jsx(nT,{hints:[["↑↓","moves"],["tab","inserts"],["esc","dismisses"]],note:c})]})}const jx=e=>Math.max(0,Math.min(1,Number.isFinite(e)?e:0));function h9({fraction:e,level:t,className:n}){const o=2*Math.PI*5.5,i=jx(e),l=S.useId(),c=3.5,u=2*c*jx(t);return d.jsxs("svg",{className:We("ring",n),viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[t!==void 0&&d.jsxs(d.Fragment,{children:[d.jsx("clipPath",{id:l,children:d.jsx("circle",{cx:"7",cy:"7",r:c})}),d.jsx("rect",{className:"ring-level",clipPath:`url(#${l})`,x:"0",y:7+c-u,width:"14",height:u})]}),d.jsx("circle",{className:"ring-track",cx:"7",cy:"7",r:5.5}),d.jsx("circle",{className:"ring-fill",cx:"7",cy:"7",r:5.5,strokeDasharray:`${o*i} ${o}`})]})}function p9(e,t=Rc.folder.shared){return`New project: ${e}. The repository is empty apart from a root commit. Pick the mainstream stack for what the message describes, and say which in your first sentence; if the message names a stack, that wins. Scaffold it in this directory, write its .gitignore before installing anything, make it start on $PORT, and write ${t}.`}function ww(e,{sock:t}){var o;const n=[];e.canLogout&&((o=e.auth)==null?void 0:o.kind)!=="none"&&n.push({id:"logout",label:"log out",danger:!0,onClick:()=>t==null?void 0:t.send({t:"agent-logout",agent:e.id})});const r=rT(e);return r&&n.push({id:"install",label:r,onClick:()=>t==null?void 0:t.send({t:"install-agent",agent:e.id})}),n}function rT(e){return e.install?e.install==="missing"?"install":"install again":null}const ih=e=>e.reason??"not installed",as="";function m9(e){var p;const t=k9(e.name);if(t){const h=[t.qualifier,e.description||e.name].filter(Boolean).join(" · ");return{label:t.label,version:t.version,description:h}}const n=e.name.match(/^([A-Za-z]+)-(\d+(?:\.\d+)*)(?:-([A-Z][a-z]+))?$/);if(n!=null&&n[1]&&n[2])return{label:n[3]??n[1],version:n[2],...e.description?{description:e.description}:{}};const[r="",...o]=(e.description??"").split(" · "),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 u=[l[3]??((p=e.name.match(/\(([^)]*)\)$/))==null?void 0:p[1]),...o].filter(Boolean).join(" · ");return{label:i,version:l[2],...u?{description:u}:{}}}const g9=/(?:^|[./])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 k9(e){const t=e.match(g9),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 oT(e,t,n,r){const o=d1(e),i=xC(e),l=y=>i&&y===(o==null?void 0:o.id)?i.id:y,c=l(t||n||(o==null?void 0:o.id)||as),u=l(t||(o==null?void 0:o.id)||as),p=i?e.filter(y=>y!==o):e,h=p.some(y=>y.id===c),m=p.map(y=>({c:y,words:m9(y)})),g=y=>[y.label,y.version].filter(Boolean).join(" "),w=[...o?[]:[{id:as,label:r.label,description:r.description}],...m.map(({c:y,words:b})=>{const _=m.filter(E=>g(E.words)===g(b)).length===1?b:void 0,T=_?_.description:y.description;return{id:y.id,label:_?_.label:y.name,..._!=null&&_.version?{suffix:_.version}:{},..._!=null&&_.version&&m.some(E=>E.c!==y&&E.words.label===_.label)?{chip:g(_)}:{},description:y===i?["recommended",T].filter(Boolean).join(" · "):T}}),...c&&!h?[{id:c,label:c}]:[]];if(c!==u){const y=w.find(T=>T.id===c),b=w.findIndex(T=>T.id===u),_=w[b];if(_){const T=(y==null?void 0:y.chip)??(y==null?void 0:y.label)??c;w[b]={..._,description:[`${T} now`,_.description].filter(Boolean).join(" · ")}}}return{rows:w,shown:c,picked:u}}const pc=(e,t)=>`${e} ${t}`;function w9(e){const t=e.indexOf(" ");return t<0?{agent:e,model:as}:{agent:e.slice(0,t),model:e.slice(t+1)}}function y9(e,t,n){const r=e.length>1;let o=pc(t,n);return{rows:e.flatMap(l=>{var h;const c=l.short??l.name,u=l.id===t;if(!l.available||!((h=l.models)!=null&&h.length))return u&&(o=pc(l.id,as)),[{id:pc(l.id,as),label:c,description:l.available?l.checkFailed??"its own default model; the rest are listed once it has run":ih(l),disabled:!l.available}];const p=oT(l.models,u?n:as,void 0,{label:`${c} default`,description:`whatever ${l.name} runs when nothing is asked for`});return u&&(o=pc(l.id,p.shown)),p.rows.map(m=>({...m,id:pc(l.id,m.id),...r&&m.id!==as?{prefix:c}:{}}))}),shown:o}}function Gc({anchored:e=!1,...t}){return e?d.jsx(v9,{...t,anchored:e===!0?{}:e}):d.jsx(b9,{...t})}function v9({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,anchored:o,coverBy:i,id:l,children:c}){const{onKey:u,back:p}=sT(t);return d.jsx(Rs,{className:We(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:u,onBack:()=>p()||(e==null?void 0:e()),children:c})}function b9({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,id:o,children:i}){const{onKey:l,back:c}=sT(t);return d.jsx(Rs,{className:"overlay scrim",id:o,onDismiss:e?()=>e():void 0,onKey:l,onBack:()=>c()||(e==null?void 0:e()),onClick:u=>{e&&u.target===u.currentTarget&&e()},children:d.jsx("div",{className:We(r?"":"overlay-box",n),children:i})})}function sT(e){const t=Yn(),n=()=>{if(e)return e(),!0;const o=t.getState();return!o.overlay||o.choosingFolder?!1:(t.dispatch({a:"close",back:qE(o.overlay)}),!0)};return{onKey:o=>{o.key==="Escape"&&n()&&o.stopPropagation()},back:n}}function x9(e){const t=e.value.length;e.setSelectionRange(t,t)}function E9({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(d.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 Lr({items:e,filter:t,keyOf:n,row:r,rowClass:o,rowTitle:i,onPick:l,onBack:c,onActive:u,onSide:p,onTab:h,onQuery:m,completionOf:g,narrowTo:w,placeholder:y,initialQuery:b="",initialIndex:_,selectOnMount:T=!1,idleWhen:E,onIdlePick:N,anchored:j=!1,onEscape:$,lead:P,trailing:R,empty:A="no matches",footer:O,keys:B,rowMenu:H,groupOf:Q,groupHead:re,headAlone:J=!1,field:ie}){const ve=vn("picker"),[C,Z]=S.useState(b),Y=S.useMemo(()=>t(e,C),[e,C,t]),q=S.useRef(null),z=Si(),te=$L(T,!z&&!ie);S.useEffect(()=>{if(!m)return;const je=setTimeout(()=>m(C),150);return()=>clearTimeout(je)},[C,m]);const Ee=ZS({results:Y,keyOf:n,q:C,onPick:l,listRef:q,onActive:u,onSide:p,completionOf:g,narrowTo:w,setQ:Z,initialIndex:_,idle:(E==null?void 0:E(b))??!1,onIdlePick:N}),{index:Ne,ghost:de}=Ee,we=ie?ie.open:!0;ft([we,b],()=>{!ie||we||(Z(b),Ee.setIndex(E!=null&&E(b)?-1:0))}),ft([we],()=>{if(!ie||!we||z)return;const je=()=>{const Se=te.current;!Se||document.activeElement===Se||(Se.focus(),T&&Se.select())};je();const Ce=requestAnimationFrame(je);return()=>cancelAnimationFrame(Ce)});const ae=S.useRef(!1),G=typeof B=="function"?B(Ee.active,C):B,ue=[];G!=null&&G.nav&&ue.push(["↑↓",G.nav]),G!=null&&G.side&&p&&ue.push(["←→",G.side]),G!=null&&G.complete&&(de!=null&&de.accept)&&ue.push(["tab",G.complete]),G!=null&&G.tab&&h&&ue.push(["tab",G.tab]),G!=null&&G.pick&&ue.push(["enter",G.pick]),G!=null&&G.back&&ue.push(["esc",G.back]);const Le=je=>d.jsxs("div",{...ie==null?void 0:ie.attrs,className:We("picker-input",ie&&"picker-field",ie==null?void 0:ie.className),"data-open":(ie==null?void 0:ie.open)||void 0,onMouseDown:Ce=>{var Se;Ce.target.closest("input, .float")||(Ce.preventDefault(),(Se=te.current)==null||Se.focus())},children:[P,d.jsxs("div",{className:"picker-caret",children:[d.jsx($o,{font:"mono",bare:!0,ref:te,value:C,spellCheck:!1,"aria-controls":ie==null?void 0:ie.id,"aria-expanded":ie?ie.open:void 0,onFocus:()=>{ie&&!ie.open&&ie.onOpen()},onBlur:Ce=>{const Se=Ce.relatedTarget;ie!=null&&ie.open&&Se instanceof Element&&!Se.closest(".float")&&c()},onMouseDown:Ce=>{const Se=document.activeElement!==Ce.currentTarget;if(ae.current=Se,ie&&Se){const Me=document.getSelection();Me&&(!Me.isCollapsed||Me.toString()!=="")&&Me.removeAllRanges()}},onClick:Ce=>{if(!ie||!ae.current)return;ae.current=!1;const Se=Ce.currentTarget;setTimeout(()=>{document.activeElement===Se&&Se.selectionStart===Se.selectionEnd&&Se.select()},0)},onChange:Ce=>{Z(Ce.target.value),Ee.setIndex(E!=null&&E(Ce.target.value)?-1:0),ie&&!ie.open&&ie.onOpen()},onKeyDown:Ce=>{var Se;if(ie&&!ie.open){if(Ce.key==="ArrowDown"||Ce.key==="ArrowUp")ie.onOpen();else if(Ce.key==="Escape"){x9(Ce.currentTarget),Ce.currentTarget.blur();return}}if(H&&Ee.active&&(Ce.key==="ContextMenu"||Ce.key==="F10"&&Ce.shiftKey)){const Me=(Se=q.current)==null?void 0:Se.querySelector('[data-state~="cursor"]');if(Me){Ce.preventDefault(),Ce.stopPropagation(),ro.open({items:H(Ee.active),owner:"picker",target:Me,anchor:Me.getBoundingClientRect()});return}}Ee.onKeyDown(Ce)||!h||Ce.key!=="Tab"||Ce.shiftKey||(Ce.preventDefault(),h())},placeholder:y}),de&&d.jsxs("div",{className:"picker-ghost","aria-hidden":"true",children:[d.jsx("span",{className:"picker-typed",children:C}),E9(de)]})]}),R,je]}),ke=new Map;if(Q)for(const je of Y)ke.set(Q(je),(ke.get(Q(je))??0)+1);const ne=d.jsxs("div",{className:"picker-list",ref:q,onMouseDown:je=>{ie&&je.target!==je.currentTarget&&je.preventDefault()},children:[Y.map((je,Ce)=>{const Se=Q==null?void 0:Q(je),Me=Se!==void 0&&(J||ke.size>1)&&(Ce===0||(Q==null?void 0:Q(Y[Ce-1]))!==Se)?d.jsx("div",{className:"picker-group",children:(re==null?void 0:re(Se,ke.get(Se)??0))??Se}):null;return d.jsxs(S.Fragment,{children:[Me,d.jsx("button",{className:We("picker-item",o==null?void 0:o(je)),"data-state":vr({cursor:Ce===Ne}),title:i==null?void 0:i(je),onMouseMove:()=>Ce!==Ne&&Ee.setIndex(Ce),onClick:()=>{var wt;Ee.pick(je),(wt=te.current)==null||wt.focus()},...ve.contextMenu(()=>(H==null?void 0:H(je))??[]),children:r(je,Ce===Ne,C)})]},n(je))}),Y.length===0&&d.jsx("div",{className:"empty",children:typeof A=="function"?A(C):A}),O==null?void 0:O(C,Y)]}),ge=ue.length>0&&d.jsx(nT,{hints:ue});return ie?Le(ie.open&&d.jsxs(Gc,{onClose:c,onEscape:$,boxClass:"picker",anchored:j,id:ie.id,children:[ne,ge]})):d.jsxs(Gc,{onClose:c,onEscape:$,boxClass:"picker",anchored:j,coverBy:P?".picker-input > *:first-child":R?".picker-input > *:last-child":void 0,children:[Le(),ne,ge]})}function di({value:e,reads:t,options:n,onChange:r,placeholder:o,hint:i,className:l,onClose:c}){const[u,p]=S.useState(!1),h=()=>{p(!1),c==null||c()},m=t??e,g=n.find(y=>y.id===m),w=(g==null?void 0:g.chip)??(g==null?void 0:g.label)??m;return d.jsxs("span",{className:"chip-picker",children:[d.jsx(Be,{variant:"ghost",tone:"chrome",mono:!0,on:u,className:We("chip-picker-btn",l),...Ut(i),onClick:()=>u?h():p(!0),children:w}),u&&d.jsx(Lr,{anchored:{flip:"both",margin:0},onEscape:h,items:n,filter:(y,b)=>{const _=b.trim().toLowerCase().split(/\s+/).filter(Boolean);return y.filter(T=>{const E=`${T.prefix??""} ${T.label??T.id} ${T.suffix??""} ${T.id}`.toLowerCase();return _.every(N=>E.includes(N))})},keyOf:y=>y.id,initialIndex:y=>Math.max(0,y.findIndex(b=>b.id===e)),lead:d.jsx(Be,{tone:"chrome",mono:!0,on:!0,className:"chip-picker-lead",onClick:h,children:w}),placeholder:o,rowClass:()=>"picker-row",row:y=>d.jsxs(d.Fragment,{children:[y.id===e&&d.jsx("span",{className:"row-current","aria-hidden":"true"}),d.jsxs("span",{className:We("chip-option",y.disabled&&"chip-option-off"),"aria-disabled":y.disabled,children:[d.jsxs("span",{className:"chip-option-name",children:[y.prefix?`${y.prefix} `:null,y.label??y.id,y.suffix?d.jsx("span",{className:"chip-option-suffix",children:` ${y.suffix}`}):null]}),y.description&&d.jsx("span",{className:"chip-option-desc row-dim",children:y.description})]})]}),onPick:y=>{y.disabled||(r(y.id),h())},onBack:h})]})}function iT({choices:e,value:t,current:n,what:r,defaultLabel:o,defaultDescription:i,placeholder:l,className:c,onChange:u,onClose:p}){const{rows:h,shown:m,picked:g}=S.useMemo(()=>oT(e,t,n,{label:o,description:i}),[e,t,n,o,i]);if(e.length===0)return null;const w=h.find(b=>b.id===m),y=(w==null?void 0:w.chip)??(w==null?void 0:w.label)??m;return d.jsx(di,{value:g,reads:m,options:h,onChange:u,onClose:p,className:c,hint:t?`asked for ${y}; click to change`:`${y}, the agent's choice; click to pick ${r}`,placeholder:l})}function S9(e){const[t,n]=ko(qe.effortPrefix+(e??""),as,r=>r??"",io().storage);return[t,n]}function Cx({efforts:e,value:t,current:n,onChange:r,onClose:o}){return d.jsx(iT,{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 _9(e){const[t,n]=ko(qe.modePrefix+((e==null?void 0:e.id)??""),Vd,r=>Qc.some(o=>o.id===r)?r:Vd,io().storage);return[t,n]}const N9=e=>{var t;return((t=Qc.find(n=>n.id===e))==null?void 0:t.description)??""};function Ax({value:e,onChange:t,onClose:n}){return d.jsx(di,{value:e,options:Qc.map(r=>({id:r.id,label:r.name,description:r.description})),onChange:t,onClose:n,className:We("mode-chip",e!=="auto"&&"mode-held"),hint:`${e}: ${N9(e)}. Click to change`,placeholder:"what the agent may do without asking"})}function T9(e){const[t,n]=ko(qe.modelPrefix+(e??""),as,r=>r??"",io().storage);return[t,n]}function j9(e,t,n){e.set(qe.modelPrefix+t,n)}function Ix({models:e,value:t,current:n,onChange:r,onClose:o}){return d.jsx(iT,{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 C9({agents:e,agent:t,model:n,onChange:r,onClose:o}){const{rows:i,shown:l}=S.useMemo(()=>y9(e,t,n),[e,t,n]);if(i.length===0)return null;const c=i.find(p=>p.id===l),u=c?[c.prefix,c.label,c.suffix].filter(Boolean).join(" "):n;return d.jsx(di,{value:l,options:i,onChange:p=>{const h=w9(p);r(h.agent,h.model)},onClose:o,className:"model-chip",hint:`${u} works on the new worktree; click to change`,placeholder:"which agent and model work on it"})}function aT(e){const t=Jf(e),[n,r]=ko(qe.profilePrefix+((e==null?void 0:e.id)??""),(e==null?void 0:e.config.defaultProfile)??"",i=>i??void 0,io().storage);return[t.length===0?void 0:t.includes(n)?n:e==null?void 0:e.config.defaultProfile,r]}function A9({repo:e,value:t,onChange:n,onClose:r}){const o=Jf(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",c=u=>{var m;const p=((m=i[u])==null?void 0:m.run)??[],h=p.length>0?`runs ${p.join(", ")}`:"runs nothing";return u===(e==null?void 0:e.config.defaultProfile)?`${h}; the default in ${l}`:h};return d.jsx(di,{value:t,options:o.map(u=>({id:u,description:c(u)})),onChange:n,onClose:r,hint:o.length>1?`${t}: ${c(t)}. Click to change`:`the only profile in ${l}`,placeholder:"the profile the worktree runs"})}function Vc(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(d.jsx("b",{className:"hit",children:e[l]},l))):i+=e[l];return i&&o.push(i),o}function I9({c:e,query:t}){const n=t.trim();return d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"picker-name",children:["/",Vc(e.name,n?pw(e.name,n):null,0)]}),d.jsx("span",{className:"picker-desc row-dim",children:e.description})]})}function An({label:e,hint:t,current:n=!1}){return d.jsxs(d.Fragment,{children:[n&&d.jsx("span",{className:"row-current","aria-hidden":"true"}),d.jsx("span",{className:"picker-label",children:e}),t?d.jsx("span",{className:"picker-hint row-dim",children:t}):null]})}function $9(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 R9=/ \| | - | \u2013 | \u2014 | \u00b7 |: /,O9=/^(\d+|[0-9a-f]{8}-[0-9a-f-]{27}|[0-9a-f]{12,})$/i,M9=/^[[:$*{]|\[/;function P9(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(R9).map(l=>l.trim()).filter(Boolean)})),o=new Map;for(const{path:i,parts:l}of r)for(const c of l)o.set(c,(o.get(c)??new Set).add(i));for(const{path:i,parts:l}of r){const c=l.filter(u=>{var p;return(((p=o.get(u))==null?void 0:p.size)??0)<2});c.length>0&&t.set(i,c.join(" "))}return t}function yw(e){const t=e.replace(/\?[^#]*/,"").split(/[/#]/).filter(Boolean);for(let n=t.length-1;n>=0;n--){let r=t[n];try{r=decodeURIComponent(r)}catch{}if(O9.test(r)||M9.test(r))continue;const o=r.replace(/[-_.]+/g," ").trim();if(o)return o[0].toUpperCase()+o.slice(1)}return"Home"}const dm=8,L9=3,D9=50,z9=3;function F9(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 c=l.dynamic?cM(l.path):null;c?(o.push(c),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:P9(e),links:new Map(n.map(l=>[l.path,l.text]))}}function B9(e){if(!e)return"/";try{const t=new URL(e);return t.pathname+t.search+t.hash}catch{return"/"}}function U9(e){const t=e.trim();return/^[/?#]/.test(t)?t:`/${t}`}function H9(e,t){const n=/^[/?#]/.test(t)?e:e.replace(/^\//,"");return t&&n.toLowerCase().startsWith(t.toLowerCase())?n:null}const lT=e=>/^\[\[?\.\.\.|^\*$|^\$$/.test(e),bc=e=>lT(e)||/[[:$*{]/.test(e)&&!/^[^[{:$*]+\?$/.test(e),W9=e=>Lf(`/${e}`).text.slice(1),vw=e=>e.split("/").filter(Boolean);function bw(e,t){const n=t.startsWith("/"),r=t.replace(/^\//,"").split("/"),o=vw(e);let i="";const l=[],c=m=>{const g=W9(m);l.push([i.length,i.length+g.length]),i+=g};for(let m=0;m<r.length;m++){const g=r[m],w=o[m];if(w===void 0)return null;if(m<r.length-1){if(lT(w))return{show:t,accept:t};if(bc(w)){if(!g)return null}else if(g.toLowerCase()!==w.toLowerCase())return null;i+=`${bc(w)?g:w}/`;continue}if(bc(w))g?i+=g:c(w);else{if(!w.toLowerCase().startsWith(g.toLowerCase()))return null;i+=w}}for(const m of o.slice(r.length))i+="/",bc(m)?c(m):i+=m;const u=n?1:0,p=(n?"/":"")+i,h=l[0];return{show:p,accept:h?p.slice(0,h[0]+u):p,params:l.map(([m,g])=>[m+u,g+u])}}function K9(e,t){const n=bw(e,t);return n?n.accept.length>t.length?n.accept:t:Lf(e).literal}function cT(e,t){if(e.kind==="go")return null;if(e.template){const n=bw(e.path,t);return n&&n.show.length>t.length?n:null}return H9(e.path,t)}const Z9=e=>e.trim().replace(/^\//,"").toLowerCase();function uT(e,t){for(let n=0;n<e.length;n++)if("/-_.#".includes(e[n])&&e.startsWith(t,n+1))return!0;return!1}function q9(e,t,n){const r=e.replace(/^\//,"").toLowerCase(),o=t.toLowerCase();return r===n?100:r.startsWith(n)?80:uT(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 G9(e,t){const{text:n,literal:r}=Lf(e);return r.replace(/^\//,"").toLowerCase().startsWith(t)?80:bw(e,t)?70:uT(n.replace(/^\//,"").toLowerCase(),t)?60:0}function V9(e,t){const n=vw(e).findIndex(bc);return n>=0&&t.split("/").length>n}function Cc(e,t,n){var c;const r=e.statics.get(t),o=r?null:uM(e.templates,t),i=(r==null?void 0:r.file)??(o?(c=e.templateRoutes.get(o.path))==null?void 0:c.file:void 0),l=i?e.unseen[i]:void 0;return{kind:"page",path:t,title:e.titles.get(t)||e.links.get(t)||yw(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 dT(e,t){const n=e.unseen[t.file];return{kind:"page",path:t.path,title:yw(t.path),template:!0,visited:!1,file:t.file,...n?{badge:n}:{},rank:Number.POSITIVE_INFINITY,group:t.path,score:0}}function Zd({rank:e,group:t,score:n,...r}){return r}const kf=e=>vw(e).length,wf=e=>e.badge==="new"?0:e.badge==="changed"?1:2;function Y9(e,t){const n=new Set,r=[];e.history.forEach((h,m)=>{if(h.path===t)return;const g=Cc(e,h.path,m);n.has(g.group)||(n.add(g.group),r.push(g))});const o=new Set(r.map(h=>h.path)),i=r.filter(h=>h.badge);for(const[h,m]of e.statics)e.unseen[m.file]&&h!==t&&!o.has(h)&&i.push(Cc(e,h,Number.POSITIVE_INFINITY));for(const h of e.templateRoutes.values())e.unseen[h.file]&&!n.has(h.path)&&i.push(dT(e,h));i.sort((h,m)=>wf(h)-wf(m)||h.rank-m.rank);const l=r.filter(h=>!h.badge),c=i.slice(0,dm-Math.min(L9,l.length));for(const h of l)c.length<dm&&c.push(h);const u=new Set(c.map(h=>h.path)),p=[...e.statics.keys(),...[...e.links.keys()].filter(h=>!e.statics.has(h))].filter(h=>h!==t&&!u.has(h)&&!o.has(h)).sort((h,m)=>kf(h)-kf(m)||(h<m?-1:h>m?1:0));for(const h of p){if(c.length>=dm)break;c.push(Cc(e,h,Number.POSITIVE_INFINITY))}return c.map(Zd)}function X9(e,t,n){const r=Z9(t),o=U9(t),i=new Map;e.history.forEach((w,y)=>{w.path!==n&&i.set(w.path,Cc(e,w.path,y))});for(const w of[...e.statics.keys(),...e.links.keys()])w!==n&&!i.has(w)&&i.set(w,Cc(e,w,Number.POSITIVE_INFINITY));const l=[];for(const w of i.values()){const y=q9(w.path,w.title,r);y>0&&l.push({...w,score:y})}let c=null;for(const w of e.templates){const y=e.templateRoutes.get(w.path);if(!c&&!e.statics.has(o)&&w.re.test(o)){c=y;continue}const b=G9(w.path,r);b>=60&&l.push({...dT(e,y),score:b})}l.sort((w,y)=>y.score-w.score||w.rank-y.rank||wf(w)-wf(y)||kf(w.path)-kf(y.path)||(w.path<y.path?-1:w.path>y.path?1:0));const u=new Map,p=[];for(const w of l){if(!w.template&&w.group!==w.path){const y=u.get(w.group)??0;if(y>=z9&&!V9(w.group,r))continue;u.set(w.group,y+1)}if(p.push(w),p.length>=D9)break}if(p.some(w=>w.score===100))return p.map(Zd);const h={kind:"go",path:o,...c?{title:yw(c.path)}:{}},m=p[0];return!c&&m!==void 0&&m.score>=80&&Q9(m.path,r)?[...p.map(Zd),h]:[h,...p.map(Zd)]}function Q9(e,t){const n=e.replace(/^\//,"").toLowerCase().slice(t.length);return!t.endsWith("/")&&n.length>0&&!/^[/?#]/.test(n)}function fT(e,{query:t,current:n,here:r}){return t===n||t.trim()===""?Y9(e,r):X9(e,t,r)}const J9=[],eB=[];function hT(e,t){const n=M(i=>(t?i.visits[t]:void 0)??J9),r=Rt(e,"pages"),o=Rt(e,"links");return ft([e],()=>{RE(r)&&an.post(e,{type:"links"})}),S.useMemo(()=>F9(n,r,o),[n,r,o])}function tB({row:e}){if(e.kind!=="page"||!e.template)return d.jsx("span",{className:"bar-route-path row-dim",children:e.path});const{text:t,params:n}=Lf(e.path),r=[];let o=0;for(const[i,l]of n)i>o&&r.push(t.slice(o,i)),r.push(d.jsx("span",{className:"bar-route-param",children:t.slice(i,l)},i)),o=l;return o<t.length&&r.push(t.slice(o)),d.jsx("span",{className:"bar-route-path row-dim",children:r})}function pT({row:e}){return e.kind==="go"?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"picker-label",children:e.path}),e.title?d.jsx("span",{className:"bar-route-path row-dim",children:e.title}):null,d.jsx("span",{className:"picker-hint row-dim",children:"as typed"})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"picker-label",children:e.title}),d.jsx(tB,{row:e}),e.badge?d.jsx("span",{className:e.badge==="new"?"badge-new":"badge-changed",children:e.badge}):null]})}const mT=e=>e.kind==="page"&&e.file?e.file:e.path,gT=(e,t)=>e.kind==="page"&&e.template?K9(e.path,t):null,kT=e=>e.kind==="page"&&e.template?"fills in the parameter":"goes there";function wT(e,t,n){return e.kind!=="page"?[]:Zf([...e.file&&t.dir?js({id:t.worktreeId,dir:t.dir},e.file,{},n):[],mS,...e.visited?$9(t.repoId,e.path,n):[]])}function nB({worktreeId:e,repoId:t,url:n,open:r}){const o=ut(),i=it(),l=M(y=>{const b=dn(y,e);return b?b.worktree.path:null}),c=hT(e,t),u=B9(n),p=n?Pf(n):null,h=S.useCallback((y,b)=>fT(c,{query:b,current:u,here:p}),[c,u,p]),m=S.useCallback(y=>y===u||y.trim()==="",[u]),g=()=>o({a:"close"}),w=S.useMemo(()=>({open:r,onOpen:()=>o({a:"open",overlay:{kind:"routes"}}),id:"routes",className:"bar-path",attrs:Ut("Go to a page",Dt("routes"))}),[r,o]);return d.jsx(Lr,{anchored:{matchWidth:0,cover:!1,offset:-1},field:w,items:eB,filter:h,initialQuery:u,selectOnMount:!0,idleWhen:m,onIdlePick:y=>{y.trim()===""?an.post(e,{type:"navigate",path:"/"}):an.post(e,{type:"reload"}),g()},keyOf:y=>`${y.kind}:${y.path}`,rowClass:()=>"picker-row",rowTitle:mT,completionOf:(y,b)=>m(b)?null:cT(y,b),narrowTo:gT,onPick:y=>{an.post(e,{type:"navigate",path:y.path}),g()},onBack:g,rowMenu:y=>wT(y,{worktreeId:e,repoId:t,dir:l},{sock:i,dispatch:o}),placeholder:"type a path",keys:(y,b)=>({complete:"completes the path",pick:y?kT(y):b.trim()===""?"goes to the root":"reloads",back:"closes"}),empty:"no pages yet; type a path",row:y=>d.jsx(pT,{row:y})})}function yT(e,t){const n=t.trim();return d.jsx(An,{label:Vc(e.label,n?pw(e.label,n):null,0),hint:e.hint&&d.jsx(Vo,{k:e.hint})})}function vT({anchored:e,trailing:t}){const n=ut(),r=zN(),o=M(i=>{var l;return((l=i.paletteReturn)==null?void 0:l.mode)==="commands"?i.paletteReturn.q:""});return d.jsx(Lr,{anchored:e,trailing:t,items:r,filter:FN,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,c)=>yT(i,c)})}function bT(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 c=n.get(l)??(r.some(u=>l.startsWith(u))?{path:l,xy:"??"}:void 0);return c?{path:l,status:c}:{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 $x(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 c=o===n.length-1,u=o===r.length-1;if(c!==u)return c?-1:1;if(i!==l)return i<l?-1:1}}function xT(e,t,n,r=50){const o=bT(e,t),i=n.trim().toLowerCase();if(!i){const c=new Map(t.map((m,g)=>[m.path,g])),u=m=>{var g;return c.get(((g=m.status)==null?void 0:g.path)??"")??c.get(m.path)??Number.MAX_SAFE_INTEGER},p=o.filter(m=>m.status).sort((m,g)=>u(m)-u(g)||$x(m.path,g.path)),h=o.filter(m=>!m.status).sort((m,g)=>$x(m.path,g.path));return{rows:[...p,...h].slice(0,r),changed:Math.min(p.length,r)}}const l=ST(o,i);return l.sort((c,u)=>u.score-c.score||c.row.path.localeCompare(u.row.path)),{rows:l.slice(0,r).map(c=>c.row),changed:0}}function ET(e,t){const n=e.toLowerCase(),r=Rx(n,t);return r<=0?0:Rx(n.slice(n.lastIndexOf("/")+1),t)>0?r+10:r}function ST(e,t){const n=[];for(const r of e){const o=ET(r.path,t);o>0&&n.push({row:r,score:r.status?o+4:o})}return n}function rB(e,t,n,r,o){const i=r.trim().toLowerCase();if(!i)return xT(e,n,r,o).rows.map(u=>({kind:"file",path:u.path,status:u.status}));const l=ST(bT(e,n),i).map(({row:u,score:p})=>({row:{kind:"file",path:u.path,status:u.status},score:p}));for(const u of t){const p=ET(u,i);p>0&&l.push({row:{kind:"folder",path:u},score:p})}const c=u=>u.kind==="folder"?1:0;return l.sort((u,p)=>p.score-u.score||c(u.row)-c(p.row)||u.row.path.localeCompare(p.row.path)),l.slice(0,o).map(u=>u.row)}function oB(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 Rx(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 sB(e){const t=e.lastIndexOf("/");return t===-1?[e,""]:[e.slice(t+1),e.slice(0,t+1)]}const Ox=[],iB=[],aB=[];function lB({worktreeId:e}){var _;const t=ut(),n=it(),r=Yn(),o=M(T=>T.connected);ft([e,o,n],()=>qf(e,r.getState(),{sock:n,dispatch:t}));const i=uS(e),l=i.files??iB,c=((_=i.git)==null?void 0:_.files)??aB,u=zN(),p=M(T=>{var E;return((E=T.paletteReturn)==null?void 0:E.mode)==="quick-open"?T.paletteReturn.q:""}),h=M(T=>{var N;const E=(N=dn(T,e))==null?void 0:N.worktree;return E?E.path:null}),m=M(T=>{var E;return((E=dn(T,e))==null?void 0:E.repoId)??null}),g=M(T=>{var E;return((E=lf(T))==null?void 0:E.worktreeId)===e}),w=hT(e,m),y=i.page.url?Pf(i.page.url):null,b=S.useCallback((T,E)=>E.startsWith(">")?FN(u,E.slice(1)).map(N=>({kind:"cmd",c:N})):E.startsWith("/")?g?fT(w,{query:E,current:"/",here:y}).map(N=>({kind:"page",page:N})):Ox:xT(l,c,E).rows.map(N=>({kind:"file",path:N.path,status:N.status})),[u,l,c,g,w,y]);return d.jsx(Lr,{items:Ox,filter:b,keyOf:T=>T.kind==="cmd"?`c:${T.c.id}`:T.kind==="page"?`p:${T.page.kind}:${T.page.path}`:`f:${T.path}`,rowClass:T=>T.kind==="file"?"qo-file":"picker-row",rowTitle:T=>T.kind==="page"?mT(T.page):void 0,completionOf:(T,E)=>T.kind==="page"?cT(T.page,E):null,narrowTo:(T,E)=>T.kind==="page"?gT(T.page,E):null,onPick:(T,E)=>{T.kind==="cmd"?(T.c.sub?t({a:"palette-return",v:{mode:"quick-open",q:E}}):t({a:"close"}),T.c.run()):T.kind==="page"?(an.post(e,{type:"navigate",path:T.page.path}),t({a:"close"})):(er({dispatch:t},{worktreeId:e,path:T.path,view:wi(T.path)}),t({a:"close"}))},onBack:()=>t({a:"close"}),rowMenu:T=>T.kind==="file"&&h?js({id:e,dir:h},T.path,{},{sock:n,dispatch:t}):T.kind==="page"&&m?wT(T.page,{worktreeId:e,repoId:m,dir:h},{sock:n,dispatch:t}):[],placeholder:"jump to file · type > for commands, / for pages",keys:(T,E)=>E.startsWith("/")?{complete:"completes the path",pick:(T==null?void 0:T.kind)==="page"?kT(T.page):void 0,back:"closes"}:{pick:"opens",back:"closes"},initialQuery:p,empty:T=>T.startsWith(">")?"no matching command":T.startsWith("/")?g?"no pages yet; type a path":"no preview running":"no matches",row:(T,E,N)=>T.kind==="cmd"?yT(T.c,N.slice(1)):T.kind==="page"?d.jsx(pT,{row:T.page}):vg(T.path,T.status,N,{gutter:c.length>0})})}function vg(e,t,n,{folder:r=!1,gutter:o=!0}={}){const[i,l]=sB(e),c=n.trim()?oB(e,n.trim()):null;return d.jsxs(d.Fragment,{children:[o&&d.jsx("span",{className:`xy ${t?sk(t.xy):""}`,children:t?ik(t.xy):""}),d.jsxs("span",{className:"name",children:[Vc(i,c,l.length),r&&"/"]}),d.jsx("span",{className:"dir row-dim",children:l&&d.jsxs(d.Fragment,{children:["",Vc(l,c,0),""]})}),t&&d.jsx(m_,{f:t})]})}function cB(e,t,n){var l;if(!e)return null;if(e.available)return e.checkFailed?{kind:"unready",text:e.checkFailed,retry:null}:((l=e.auth)==null?void 0:l.kind)==="none"?{kind:"unready",text:e.loginHint??`${e.name} is not logged in`,retry:null}:null;const r=n?t.find(c=>c.available&&c.id!==e.id):void 0,o=r?{other:r}:{};return e.installing?{kind:"installing",text:`${e.name} is installing`,retry:null,...o}:{kind:"failed",text:typeof e.install=="object"?`${e.name} did not install: ${e.install.failed}`:`${e.name} is not ready: ${ih(e)}`,retry:rT(e),...o}}function Ga({icon:e,verb:t,tip:n,onPress:r,onDismiss:o,children:i}){return d.jsxs("div",{className:"composer-offer",children:[d.jsx(kt,{name:e,className:"icon-inline"}),d.jsxs("span",{className:"composer-offer-line",children:[d.jsx(Be,{variant:"inline",tone:"strong","data-tip":n,onClick:r,children:t})," ",i]}),o&&d.jsx(Ot,{icon:"close",tone:"quiet",className:"composer-offer-close",label:"Not this one",onClick:o})]})}function _T({item:e,n:t,onRemove:n}){const r=Dr();return e.kind==="image"?d.jsx(uw,{src:e.local??r.upload(e.upload),n:t,name:e.name,width:e.width,height:e.height,bytes:e.bytes,uploading:e.uploading,progress:e.progress,onRemove:n}):e.kind==="file"?d.jsx(aw,{name:e.name,bytes:e.bytes,href:e.text&&e.upload?r.upload(e.upload):void 0,uploading:e.uploading,progress:e.progress,onRemove:n}):d.jsx(iw,{n:t,name:e.name,source:e.source,lines:e.lines,chars:e.chars,preview:e.preview,text:e.text,onRemove:n})}const Mx=8,uB=104,dB=.25,NT=220;function fB({dx:e,dy:t}){return Math.abs(e)<Mx&&Math.abs(t)<Mx?null:Math.abs(e)>Math.abs(t)&&e<0?"slide":"other"}function hB(e,t,n=uB){const r=Math.max(0,-e),o=t*n,i=Math.min(t,Math.floor(r/n)),l=r<=o?r:o+(r-o)*dB;return{step:i,x:-l}}function TT(e,t){const n=S.useRef(t);n.current=t,S.useEffect(()=>{const r=e.current;if(!r)return;let o=null,i=null,l=!1,c=0,u=0,p=0;const h=(E,N,j)=>{E.el.dataset.slide!==j&&(E.el.dataset.slide=j,E.el.offsetWidth),E.el.style.setProperty("--slide-x",`${N}px`)},m=E=>{E.el.style.removeProperty("--slide-x"),delete E.el.dataset.slide},g=()=>{const E=o,N=l,j=c;o=null,i=null,l=!1,c=0,!(!E||!N)&&(h(E,0,"settle"),j>0&&n.current.onPick(E.key,j),u=window.setTimeout(()=>{m(E),n.current.onSlide(null)},NT))};let w=null;const y=E=>{if(!E.isPrimary||E.pointerType==="mouse"&&E.button!==0)return g();const N=E.target instanceof Element?n.current.rowOf(E.target):null;!N||N.el.dataset.slide||(window.clearTimeout(u),o=N,w=E.pointerId,i={x:E.clientX,y:E.clientY})},b=E=>{var R;const N=o;if(!N||!i||E.pointerId!==w)return;const j=E.clientX-i.x,$=E.clientY-i.y;if(!l){const A=fB({dx:j,dy:$});if(A==="other"&&(o=null,i=null,w=null),A!=="slide")return;l=!0;try{N.el.setPointerCapture(E.pointerId)}catch{}n.current.onSlide({key:N.key,step:0})}const P=hB(j,N.rungs,N.rung);h(N,P.x,"drag"),P.step!==c&&(c=P.step,n.current.onSlide({key:N.key,step:c}),c>0&&((R=navigator.vibrate)==null||R.call(navigator,8)))},_=E=>{E.pointerId===w&&(l&&(p=E.timeStamp+400),w=null,g())},T=E=>{E.timeStamp>=p||(E.preventDefault(),E.stopPropagation())};return r.addEventListener("pointerdown",y),r.addEventListener("pointermove",b),r.addEventListener("pointerup",_),r.addEventListener("pointercancel",_),r.addEventListener("click",T,!0),()=>{window.clearTimeout(u),r.removeEventListener("pointerdown",y),r.removeEventListener("pointermove",b),r.removeEventListener("pointerup",_),r.removeEventListener("pointercancel",_),r.removeEventListener("click",T,!0)}},[e])}function yf({rows:e,cursor:t,onCursor:n,onPick:r,onHint:o,hover:i=!1}){const l=Si(),c=S.useRef(null),[u,p]=S.useState(null),h=l&&!!o;TT(c,{rowOf:g=>{if(!h||g.closest("textarea"))return null;const w=g.closest(".slide"),y=w==null?void 0:w.dataset.row,b=y===void 0?void 0:e[Number(y)];return w&&y!==void 0&&(b!=null&&b.hint)&&!b.field?{el:w,key:y,rungs:1,rung:120}:null},onSlide:p,onPick:g=>o==null?void 0:o(Number(g))});const m=g=>{var w;g.target instanceof HTMLTextAreaElement||(g.preventDefault(),(w=g.currentTarget.querySelector("textarea"))==null||w.focus())};return d.jsx("div",{className:We("choices",i&&"choices-hover",l&&"choices-touch"),ref:c,children:e.map((g,w)=>{const y=!l&&t===w,b=vr({cursor:y,checked:g.checked}),_=g.tone==="deny"&&"choice-deny",T=()=>n&&t!==w&&n(w),E=j=>{var R;if(!h)return j;const $=(u==null?void 0:u.key)===String(w)?u.step:null,P=$!==null&&$>0&&((R=g.hint)==null?void 0:R.on)!==!1;return d.jsxs("div",{className:"slide","data-row":w,children:[j,$!==null&&g.hint&&d.jsxs("span",{className:"slide-verb","data-rung":P?"hint":void 0,"aria-hidden":"true",children:[d.jsx("span",{className:"slide-word",children:g.hint.label}),d.jsx(kt,{name:g.hint.icon})]})]},w)},N=d.jsxs(d.Fragment,{children:[!l&&d.jsx(Vo,{k:String(w+1),className:"choice-num row-dim"}),d.jsx("span",{className:"choice-label",children:g.label}),!l&&g.hint&&d.jsxs("span",{className:We("choice-hint row-dim",y&&g.hint.on!==!1&&"on"),children:[d.jsx(Vo,{k:g.hint.k})," ",g.hint.label]}),g.description&&d.jsx("span",{className:"choice-desc",children:g.description})]});return g.field?E(d.jsxs("div",{className:We("picker-item choice row-edge",_),"data-state":b,onMouseMove:T,onMouseDown:m,children:[N,d.jsx(Bc,{ref:g.field.ref,bare:!0,font:"ui",rows:1,className:"choice-field",enterKeyHint:g.field.enterKeyHint,placeholder:g.field.placeholder,value:g.field.value,onChange:j=>{var $;return($=g.field)==null?void 0:$.onChange(j.target.value)}})]},w)):E(d.jsx("button",{type:"button",className:We("picker-item choice row-edge",_),"data-state":b,disabled:g.disabled,onMouseMove:T,onClick:()=>r(w),children:N},w))})})}function pB(e){return qd(e.key)&&(e.metaKey||e.ctrlKey)&&!e.altKey?!1:e.metaKey||e.ctrlKey||e.altKey}const mB=e=>e.length===1&&e>="1"&&e<="9",qd=e=>e==="Enter"||e==="NumpadEnter";function gB(e,t,n){const r=qd(e.key)&&(e.metaKey||e.ctrlKey);return t?e.key==="Escape"||e.key==="Tab"&&!e.shiftKey?{kind:"field-leave"}:r?{kind:"submit"}:qd(e.key)&&!e.shiftKey?{kind:"field-enter"}:{kind:"typing"}:pB(e)?{kind:"chord"}:e.key==="Escape"?{kind:"escape"}:r?{kind:"submit"}:qd(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:su(n.cursor,e.key==="ArrowUp"?-1:1,n.count)}:mB(e.key)&&Number(e.key)<=n.count?{kind:"pick",at:Number(e.key)-1,by:"digit"}:null}function xw(e,t){var o,i,l,c;const n=e.target instanceof HTMLTextAreaElement,r=gB(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(),(c=t.onFieldEnter)==null||c.call(t),!0}}function kB(e){return!e||e===document.body?!1:e.closest(".monaco-editor, .xterm")?!0:(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&!e.closest(".chat-input")}function wB(e,t){ft([t],()=>{const o=requestAnimationFrame(()=>{var i;kB(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 Ew({root:e,id:t,onKeyDown:n,onKeyUp:r,onPaste:o,children:i}){const l=wB(e,t);return d.jsx("div",{ref:e,className:"card",tabIndex:-1,onKeyDown:n,onKeyUp:r,onPaste:o,onBlur:l,children:i})}function vf({children:e,sub:t}){return d.jsxs("div",{className:"card-head",children:[d.jsx("div",{className:"card-text",children:e}),t&&d.jsx("div",{className:"card-sub",children:t})]})}function bf(e){const t=S.useRef(null),n=kw(t);return"html"in e?d.jsxs("div",{ref:t,className:"card-band md",children:[d.jsx("div",{dangerouslySetInnerHTML:{__html:e.html}}),n]}):d.jsxs("div",{ref:e.still?void 0:t,className:We("card-band card-code",e.still&&"card-still"),children:[d.jsx("pre",{children:e.code}),!e.still&&n]})}function yB({children:e}){return d.jsx("div",{className:"card-foot",children:e})}const vB=[{selected:[]}],fm=0,bB=2;function xB({item:e,worktreeId:t,rootRef:n}){var R;const r=it(),o=ut(),i=Rt(t,"card"),l=(i==null?void 0:i.id)===e.id?i.draft:vB,c=(R=l[0])==null?void 0:R.note,u=c!==void 0,p=A=>o({a:"card-draft",id:t,card:{id:e.id,draft:A,current:0}}),h=S.useRef(null),[m,g]=S.useState(fm),[w,y]=S.useState(!1),b=S.useMemo(()=>ul(e.message),[e.message]),_=A=>{w||!r||(r.send(z4(e,t,A,c)),A&&y(!0),o({a:"answered",id:t}))},T=()=>{u||p(of(l,0,"")),g(fm),requestAnimationFrame(()=>{var A;return(A=h.current)==null?void 0:A.focus()})},E=A=>_(A===fm),N=()=>o({a:"card-park",id:t,cardId:e.id}),j=()=>{var O;const A=Ud(l,0);A!==l&&p(A),(O=n.current)==null||O.focus()},$=A=>{xw(A,{count:bB,cursor:m,onCursor:g,onPick:E,onEscape:N,onFieldEnter:()=>_(!0),onFieldLeave:j})||A.key==="n"&&(A.preventDefault(),T())},P=[{label:"go",hint:{k:"n",label:"add context",icon:"edit",on:!u},checked:u,field:u?{ref:h,value:c??"",placeholder:"a note for the agent there, sent with go",enterKeyHint:"send",onChange:A=>p(of(l,0,A))}:void 0,description:w?"starting":void 0,disabled:w},{label:"not now",tone:"deny",disabled:w}];return d.jsxs(Ew,{root:n,id:e.id,onKeyDown:$,children:[d.jsxs(vf,{sub:d.jsxs(d.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,"?"]}),d.jsx(bf,{html:b}),d.jsx(yf,{rows:P,cursor:m,onCursor:g,onPick:E})]})}function EB(e,t){if(t.queued>0||t.sending||t.card)return null;const n=e.at(-1);if(!n)return null;if(n.kind==="stopped"||n.kind==="error"){if(n.seq===void 0)return null;const o=`${n.kind}:${n.seq}`;return t.dismissed.has(o)?null:n.kind==="stopped"?{verb:"continue",key:o,after:"stop"}:{verb:"continue",key:o,after:"error",...SB(e)?{again:!0}:{}}}if(n.kind!=="tool"||!n.done||!n.fixable||t.dismissed.has(n.id)||e.some(o=>o.kind==="asked"&&o.toolId===n.id))return null;const r=gw(n);return r===null?null:{verb:"fix",key:n.id,toolId:n.id,command:r}}function SB(e){const[t,n,r]=e.slice(-3);return(r==null?void 0:r.kind)==="error"&&(n==null?void 0:n.kind)==="asked"&&n.about==="failed"&&(t==null?void 0:t.kind)==="error"&&t.text===r.text}let bg=new Set;const xg=new Set;function _B(e){return xg.add(e),()=>{xg.delete(e)}}function Px(e){bg=new Set(bg).add(e);for(const t of xg)t()}function NB(){return S.useSyncExternalStore(_B,()=>bg)}const TB=e=>Qc.some(t=>t.id===e);function jB(e){return[...Qc.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 jT(e,t){const n=new Set(e.map(o=>o.name)),r=t.filter(o=>!n.has(o.name));return{yours:r.filter(o=>o.origin),own:e,rest:r.filter(o=>!o.origin)}}function CB(e,t){const n=jT(e,t);return[...n.yours,...n.own,...n.rest]}function Lx(e,t){const n=jT(e,t);return{rows:[...n.yours,...n.own],more:n.rest.length}}function AB(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 IB({item:e,ask:t,worktreeId:n,rootRef:r}){const o=it(),i=ut(),l=M(y=>y.activeId),[c,u]=S.useState(0),p=t.plan,h=S.useMemo(()=>t.detail&&!p?ul(t.detail):"",[t.detail,p]),m=()=>{p&&l===n&&er({dispatch:i},{worktreeId:n,path:p,view:"preview",focus:!1})};ft([e.id,p],m);const g=y=>{const b=t.choices[y];b&&(o==null||o.send({t:"agent-decide",worktreeId:n,askId:e.id,choiceId:b.id}),i({a:"answered",id:n}))},w=y=>{xw(y,{count:t.choices.length,cursor:c,onCursor:u,onPick:g,onEscape:()=>i({a:"card-park",id:n,cardId:e.id})})};return d.jsxs(Ew,{root:r,id:e.id,onKeyDown:w,children:[d.jsx(vf,{children:t.title}),t.command&&d.jsx(bf,{code:EN(t.command)}),h&&d.jsx(bf,{html:h}),d.jsx(yf,{rows:t.choices.map(y=>({label:y.name,tone:y.kind.startsWith("reject")?"deny":void 0})),cursor:c,onCursor:u,onPick:g})]})}function $B({item:e,ask:t,worktreeId:n,rootRef:r,numbers:o,onScreen:i,onAnswer:l}){const c=it(),u=ut(),p=Yn(),h=M(G=>G.clientId),m=Si(),{message:g,questions:w}=t,y=rl(e.id),b=Rt(y,"attachments"),_=zS(y,n),T=Rt(n,"card"),E=S.useMemo(()=>(T==null?void 0:T.id)===e.id?T:{id:e.id,draft:kP(w),current:0},[T,e.id,w]),{draft:N,current:j}=E,$=j===Tc(w),P=w[j],R=N[j],A=!!(P!=null&&P.multi),[O,B]=S.useState(()=>Ja(P,R)),H=S.useRef(null);S.useEffect(()=>{const G=window.visualViewport;if(!G)return;const ue=()=>{H.current&&H.current===document.activeElement&&H.current.scrollIntoView({block:"nearest"})};return G.addEventListener("resize",ue),()=>G.removeEventListener("resize",ue)},[]);const Q=(G,ue)=>u({a:"card-draft",id:n,card:{id:e.id,draft:G,current:ue}}),re=G=>{if(l){G&&l(G);return}const ue=G?b:[],Le={t:"agent-answer",worktreeId:n,askId:e.id,...G?{answers:G}:{}};ue.some(ki)?u({a:"hold-send",id:y,log:n,text:tk(w,G).join(`
|
|
236
|
+
`),frame:Le}):(c==null||c.send({...Le,...ue.length?{attachments:ue.map(il),boxId:y,clientId:h}:{}}),ue.length&&u({a:"clear-attachments",id:y})),u({a:"answered",id:n})},J=()=>u(l?{a:"ask-revive",id:n}:{a:"card-park",id:n,cardId:e.id}),ie=()=>{Sd(w,N)&&re(N)},ve=G=>{B(Ja(w[G],N[G])),Q(N,G)},C=G=>{P!=null&&P.note&&(Q($0(N,j,G,A),j),requestAnimationFrame(()=>{var ue;return(ue=H.current)==null?void 0:ue.focus()}))},Z=G=>{if(!(P!=null&&P.note))return;const ue=P.options[G];if(B(G),!ue||A)return C(!ue);Q($0(I0(N,j,ue.value,!1),j,!1,!1),j),requestAnimationFrame(()=>{var Le;return(Le=H.current)==null?void 0:Le.focus()})},Y=()=>Z(O),q=G=>{if(yP(P,G))return B(G),C(!0);const ue=P==null?void 0:P.options[G];if(!P||!ue)return;const Le=I0(Ud(N,j),j,ue.value,A);if(A){B(G),Q(Le,j);return}const ke=R0(w,Le,j);B(ke.cursor),Q(Le,ke.current),ke.send&&Sd(w,Le)&&re(Le)},z=()=>{var ue;const G=Ud(N,j);G!==N&&(Q(G,j),B(Ja(P,G[j]))),(ue=r.current)==null||ue.focus()},te=()=>{var Le;const G=Ud(N,j);if((Le=r.current)==null||Le.focus(),!sl(G[j])){G!==N&&(Q(G,j),B(Ja(P,G[j])));return}const ue=R0(w,G,j);B(ue.cursor),Q(G,ue.current),ue.send&&Sd(w,G)&&re(G)},Ee=G=>{if(_.onPasteKey(G),!xw(G,{count:$?w.length:wP(P),cursor:$?void 0:O,spacePicks:A,onCursor:B,onPick:ue=>$?ve(ue):q(ue),onSubmit:ie,onEscape:J,onFieldEnter:te,onFieldLeave:z})){if(G.key==="ArrowLeft"||G.key==="ArrowRight"||G.key==="Tab"){G.preventDefault();const ue=G.key==="ArrowLeft"||G.key==="Tab"&&G.shiftKey;return ve(SP(j,ue?-1:1,NP(w)))}if(G.key==="n"&&(P!=null&&P.note))return G.preventDefault(),Y();if(G.key==="s"&&!l)return G.preventDefault(),re()}},Ne=G=>w.length===1&&!G.multi,de=(G,ue)=>d.jsxs(yB,{children:[(!G||!Ne(G)||m&&(ue==null?void 0:ue.note)!==void 0)&&d.jsx(Be,{variant:"outline",size:"md",disabled:!Sd(w,N),onClick:ie,children:"send"}),(G==null?void 0:G.note)&&ue&&ue.selected.length>0&&ue.note===void 0&&d.jsxs(Be,{tone:"quiet",size:"md",onClick:()=>C(!1),children:[d.jsx(Vo,{k:"n",chip:!0}),"add a note"]}),!l&&d.jsxs(Be,{tone:"quiet",size:"md",onClick:()=>re(),children:[d.jsx(Vo,{k:"s",chip:!0}),"skip"]}),d.jsx(Ot,{className:"card-attach",icon:"attach",tone:"chrome",label:i?"Attach a picture":"Attach a picture or a file",onClick:()=>MS(p,y,{images:i})})]}),we=b.length>0&&d.jsx(th,{children:d.jsx("div",{className:"card-chips",children:Pg(b,o).map(([G,ue])=>{const Le=()=>u({a:"detach",id:y,key:G.key});return G.kind==="pick"?null:d.jsx(_T,{item:G,n:ue,onRemove:Le},G.key)})})}),ae=(G,ue)=>{const Le=ue===j,ke=N[ue],ne=_E(ke,!!G.multi),ge=Le?G.options[O]:void 0,je=Se=>({ref:Le?H:void 0,value:(ke==null?void 0:ke.note)??"",placeholder:Se,enterKeyHint:Tc(w)===-1?"send":"next",onChange:Me=>Q(of(N,ue,Me),ue)}),Ce=G.options.map(Se=>{const Me=!!(ke!=null&&ke.selected.includes(Se.value));return{label:d.jsxs(d.Fragment,{children:[nk(Se.label),TP(Se.label)&&d.jsx("span",{className:"badge-recommended",children:"recommended"})]}),description:Se.description,hint:G.note&&!G.multi?{k:"n",label:"add a note",icon:"edit",on:(ke==null?void 0:ke.note)===void 0}:void 0,checked:Me,field:Me&&!ne&&(ke==null?void 0:ke.note)!==void 0?je("a note for the agent, sent with your pick"):void 0}});return G.note&&Ce.push({label:G.note.label,description:ne?void 0:"your own answer",checked:ne,field:ne?je("your own answer"):void 0}),d.jsxs("div",{className:We("card-page",!Le&&"card-page-off"),children:[d.jsx(vf,{children:G.text||g}),Le&&we,d.jsx(yf,{rows:Ce,cursor:Le?O:void 0,onCursor:B,onPick:Se=>{var Me;q(Se),(Me=r.current)==null||Me.focus()},onHint:Z}),(ge==null?void 0:ge.preview)&&d.jsx(bf,{code:ge.preview,still:!0}),de(G,ke)]},G.id)};return d.jsxs(Ew,{root:r,id:e.id,onKeyDown:Ee,onKeyUp:_.onPasteKeyUp,onPaste:_.onPaste,children:[w.length>1&&d.jsx("div",{className:"card-tabs",children:d.jsx(Xf,{label:"questions",owner:"ask",items:[...w.map((G,ue)=>({id:String(ue),label:G.header||`question ${ue+1}`,lead:d.jsx("span",{className:We("dot card-step",sl(N[ue])&&"answered")})})),{id:String(w.length),label:"send",far:!0}],current:String(j),onPick:G=>{var ue;ve(Number(G)),(ue=r.current)==null||ue.focus()}})}),d.jsxs("div",{className:"card-pages",children:[w.map(ae),Tc(w)!==-1&&d.jsxs("div",{className:We("card-page",!$&&"card-page-off"),children:[d.jsx(vf,{children:"Send these answers?"}),$&&we,d.jsx(yf,{hover:!0,rows:w.map((G,ue)=>{const Le=sl(N[ue])?bP(G,N[ue]):void 0;return{label:d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"row-dim",children:G.header||`question ${ue+1}`})," ",d.jsx("span",{className:We(!Le&&"row-dim"),children:Le?Le.pick:"no answer yet"})]}),description:Le==null?void 0:Le.note}}),onPick:G=>{var ue;ve(G),(ue=r.current)==null||ue.focus()}}),de()]})]})]})}const RB=US("top"),OB=5*6e4;function MB({usage:e,limits:t,auth:n,now:r,onClose:o}){const i=t?Lz(t,r):[],l=i.length?Cz(n):void 0,c=t&&r-t.at>OB?ck(r-t.at):null,u=(e==null?void 0:e.cost)!==void 0?` · ${iu(e.cost)}`:"";return d.jsxs(Rs,{className:"usage-panel",anchor:"parent",placement:RB,onDismiss:o,onKey:p=>{p.key==="Escape"&&(p.stopPropagation(),o())},children:[e&&d.jsx(Dx,{name:"context",used:e.used/e.size,sub:`${Ib(e.used)} of ${Ib(e.size)}${u}`}),l&&d.jsx("div",{className:"usage-who section-title",children:l}),i.map(p=>d.jsx(Dx,{name:p.name,used:p.used,sub:p.sub},p.key)),c&&d.jsxs("div",{className:"usage-stale hint",children:["read ",c," ago"]})]})}function Dx({name:e,used:t,sub:n}){const r=Math.max(0,Math.min(1,t));return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"usage-row",children:[d.jsx("span",{className:"usage-name",children:e}),d.jsx("span",{className:"meter",children:d.jsx("span",{className:"meter-fill",style:{"--meter":r}})}),d.jsxs("span",{className:"usage-fig",children:[Math.round(100*t),"%"]})]}),d.jsx("div",{className:"usage-sub hint",children:n})]})}function CT(e,t,n){const r=S.useRef(n);r.current=n,ft([e,t,n==null?void 0:n.id],()=>{if(!e||!t)return;const o=()=>{const i=r.current;i!=null&&i.available&&e.send({t:"agent-check",agent:i.id})};return o(),window.addEventListener("focus",o),()=>window.removeEventListener("focus",o)})}const zx=[],PB=[],LB=new Set(["ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),DB=150,zB=3,Fx=e=>({kind:"cmd",c:e});function FB(e,t,n,r){return e==="command"?r?n===0?d.jsx("span",{className:"live-text",children:"starting the agent to see what it offers"}):"no matching command":"no session has run this agent yet, so it has offered no commands":t?"no matches":d.jsx("span",{className:"live-text",children:"listing files"})}function BB(e){return e.kind==="cmd"?`/${e.c.name} `:e.kind==="folder"?`@${e.path}/ `:e.kind==="worktree"?`@${e.branch} `:e.kind==="changes"?"@changes ":`@${e.path} `}function Ac({active:e,draft:t,archived:n,found:r,project:o,greenfield:i,placement:l="dock"}){var xu,Eu,Ll,Dl,Hs,Ws,Su;const c=l==="screen",u=ut(),p=it(),{storage:h}=io(),m=Yn(),g=!!t,w=(e==null?void 0:e.worktree.id)??null,y=e==null?void 0:e.worktree.repoId,b=o?pl:n?n.id:r?r.id:Sl(e),_=!!n||!!r,T=n?n.restorable:!!r&&!r.locked,E=Rt(b,"draft"),N=Rt(b,"attachments"),j=Rt(b,"notice"),$=((xu=e==null?void 0:e.worktree.owns)==null?void 0:xu.join(", "))??"",P=S.useRef({id:w,owns:$});ft([w,$],()=>{const F=P.current;P.current={id:w,owns:$},!(F.id!==w||F.owns===$||!$||!b||n)&&u({a:"notice",id:b,text:`Running its own ${$} here now: this branch changed it.`})});const R=Rt(b,"mark"),A=(R==null?void 0:R.by)==="walk"?R:void 0,O=Rt(w,"chat"),B=Rt(w,"queue"),H=S.useMemo(()=>w&&!g?Ik(O):null,[w,g,O]),Q=Rt(w,"cardParked"),re=Rt(w,"sending"),J=S.useMemo(()=>w&&!g&&!re?SE(O):null,[w,g,re,O]),ie=Rt(w,"askRevived"),ve=!H&&J&&ie===J.id?J:null,C=H&&Q!==H.id?H:ve,Z=ve?rl(ve.id):null,Y=Rt(Z,"attachments"),q=H?Q===H.id?H:null:J&&!ve?J:null,z=S.useRef(null),te=Si(),Ee=_k(),Ne=Rt(Ee,"page"),de=ru(),{onPaste:we,onPasteKey:ae,onPasteKeyUp:G}=zS(b,w),ue=u4(),Le=tT(),ke=c9(),ne=NB(),ge=S.useMemo(()=>w&&!g?EB(O,{queued:B.length,sending:!!re,card:!!(C||q),dismissed:ne}):null,[w,g,O,B.length,re,C,q,ne]),je=F=>b&&u({a:"set-draft",id:b,text:F}),Ce=M(F=>F.clientId),Se=M(F=>F.repos),Me=M(F=>F.repos.find(Ze=>Ze.id===(e==null?void 0:e.worktree.repoId))??null),wt=M(F=>F.defaultAgent),on=M(F=>F.agentChosen),St=g||!!i||!!o,Yt=!St&&!!e&&!e.worktree.agent,zt=St||Yt,Ht=(t==null?void 0:t.agent)??wt,De=M(F=>F.agents.find(Ze=>Ze.id===(zt?Ht:e==null?void 0:e.worktree.agent)));CT(p,w??(St?"new":null),De);const _t=!!(De!=null&&De.quick),sn=(De==null?void 0:De.models)??zx,ln=(De==null?void 0:De.efforts)??zx,[lt,jt]=T9(Ht),[Kt,xn]=S9(Ht),Pt=M(F=>F.agents),jn=(F,Ze)=>{if(F===Ht){jt(Ze);return}j9(h,F,Ze),Qt(F)},Qt=F=>{g?u({a:"draft-agent",id:F}):p==null||p.send({t:"set-default-agent",agent:F})},V=cB(De,Pt,zt),pe=V==null?void 0:V.other,Ye=Rt(w,"model"),nt=Rt(w,"effort"),yt=Rt(w,"usage")??(e==null?void 0:e.usage),[Jt]=aT(Me),ye=(t==null?void 0:t.profile)??Jt,[Ie,Xt]=_9(Me),U=(e==null?void 0:e.worktree.mode)??Vd,me=M(F=>F.picking),ze=M(F=>F.layout.term),Xe=AE((e==null?void 0:e.procs)??[]),Mt=vn("composer"),Nt=Rt(w,"files"),He=S.useMemo(()=>$E(Nt??PB),[Nt]),Fe=M(F=>F.visible),Ke=S.useMemo(()=>UN(Fe,y,w),[Fe,y,w]),ht=Rt(w,"git"),Ct=(ht==null?void 0:ht.files.length)??(e==null?void 0:e.dirty)??0,Ft=(ht==null?void 0:ht.unpushed)??(e==null?void 0:e.unpushed)??0,Zt=M(F=>{var Ze;return w?(Ze=F.shipping[w])==null?void 0:Ze.op:void 0}),bn=M(F=>{var Ze;return w?(Ze=F.shipping[w])==null?void 0:Ze.step:void 0}),On=M(F=>ml(F,y)),Cn=M(F=>{var Ze;return On?(Ze=F.shipping[On.id])==null?void 0:Ze.op:void 0}),Xn=On&&Me&&St?o_(Me.defaultBranch,On):null,Hn=M(F=>g?LP(F.rows,y,Ht,wt):w),se=Rt(Hn,"commands"),_e=se.some(F=>F.name==="compact"),at=(e==null?void 0:e.agent)==="working"||(e==null?void 0:e.agent)==="waiting",mt=M(F=>DE(F,w)),Wt=at&&!!w&&!g,kn=e==null?void 0:e.worktree.lastTurn,wn=!E.trim()&&N.length===0,tr=!g&&!i&&wn&&!at?kn:void 0,fn=!g&&!i&&e&&Yi(e.worktree)?e.worktree.landing:void 0,hn=!!(fn!=null&&fn.ready)&&!fn.stale&&!Nd(fn,Ct,_t,De==null?void 0:De.name),Tt=wn&&(!at||hn)?fn:void 0,zr=Ct>0&&!!(Tt!=null&&Tt.subject),pt=Ct||(((Eu=ht==null?void 0:ht.extras)==null?void 0:Eu.committed.length)??0),In=!g&&!i&&wn&&!at&&!!e,Te=!!(e!=null&&e.worktree.landed)&&Ct===0,Ge=In&&Te,rt=e?jf({...e.worktree,landed:Te}):void 0,et=In&&!Ge?rt:void 0,cn=!Te&&(rt==null?void 0:rt.state)==="open"?rt:void 0,yn=!!cn&&(Ct>0||Ft>0),ar=(rt==null?void 0:rt.state)==="closed",Fr=fi((Me==null?void 0:Me.config)??{}),K=S.useMemo(()=>jB(Yd(fi((Me==null?void 0:Me.config)??{}),Me==null?void 0:Me.defaultBranch)),[Me]),fe=()=>w&&(p==null?void 0:p.send({t:"chat",worktreeId:w,text:"/compact"})),Qe=St?"nothing to compact until the first reply":_e?at?"wait for the turn to end":void 0:"this agent offers no compact command",At=_e&&yt?Iz(yt.used/yt.size):void 0,gt=De==null?void 0:De.limits,qt=St?void 0:yt,Br=(!!w||St)&&!!(qt||gt),hr=Date.now(),[vo,Nr]=S.useState(!1),xr=S.useRef(0),nr=()=>{window.clearTimeout(xr.current),Nr(!1)};ft([w],nr);const ao=Nk(),Gt=(ao==null?void 0:ao.owner)==="composer"&&ao.key==="usage";ft([Gt],()=>{Gt&&nr()});const vt=()=>[{id:"compact",label:"compact the context",detail:Qe||!yt?void 0:Az(yt.used/yt.size),disabled:Qe,onClick:fe}],[fs,En]=S.useState(0),[un,Tr]=S.useState(null),[pr,Re]=S.useState(null),L=S.useRef(null),D=b&&!_&&!o?kx(E,fs,F=>Ke.some(Ze=>xx(F,Ze))):null,oe=D!==null&&D.from!==un&&!A,be=D==null?void 0:D.kind,Ae=D==null?void 0:D.query,Ve=S.useMemo(()=>{if(Ae===void 0)return[];if(be==="command")return Ae.trim()?E8(CB(K,se),Ae).slice(0,8).map(Fx):Lx(K,se).rows.map(Fx);const F=[],Ze=(ht==null?void 0:ht.files.length)??0;Ze>0&&"changes".startsWith(Ae.toLowerCase())&&F.push({kind:"changes",n:Ze});const Lt=Ae.trim(),Vt=Lt?Ke.filter(Pn=>xx(Lt,Pn)):Ke.slice(0,zB);return F.push(...Vt.map(Pn=>({kind:"worktree",...Pn}))),F.push(...rB(Nt??[],He,(ht==null?void 0:ht.files)??[],Ae,8)),F},[be,Ae,Nt,He,ht,se,K,Ke]),It=be==="command"&&Ae!==void 0&&!Ae.trim()?Lx(K,se).more:0,rn=S.useRef(null),Wn=S.useRef(null),Mn=()=>{var F;return(F=z.current??rn.current)==null?void 0:F.focus()},lo=Mn;ft([i?e==null?void 0:e.worktree.id:null],()=>{if(!i)return;const F=requestAnimationFrame(()=>{var Lt;const Ze=document.activeElement;(!Ze||Ze===document.body)&&((Lt=rn.current)==null||Lt.focus())});return()=>cancelAnimationFrame(F)});const Kn=M(F=>F.focusChat),_i=S.useRef(Kn),Ni=!!dS();ft([Kn],()=>{if(Kn===_i.current||(_i.current=Kn,Ni!==!!i))return;const F=requestAnimationFrame(Mn);return()=>cancelAnimationFrame(F)});const pa=C==null?void 0:C.id,Ms=S.useRef({id:w,cardUpId:pa});ft([w,pa],()=>{const F=Ms.current;if(Ms.current={id:w,cardUpId:pa},pa||!F.cardUpId||F.id!==w||Ni!==!!i||te&&!q)return;const Ze=requestAnimationFrame(()=>{var Vt;const Lt=document.activeElement;(!Lt||Lt===document.body)&&((Vt=rn.current)==null||Vt.focus())});return()=>cancelAnimationFrame(Ze)});const es=M(F=>F.walked),hs=S.useRef(es);ft([es],()=>{if(es===hs.current||(hs.current=es,Ni!==!!i))return;const F=requestAnimationFrame(()=>{const Ze=document.activeElement;(!Ze||Ze===document.body||Ze.closest(".rail"))&&Mn()});return()=>cancelAnimationFrame(F)});const Ps=ZS({results:Ve,keyOf:F=>F.kind==="cmd"?`c:${F.c.name}`:F.kind==="changes"?"changes":F.kind==="worktree"?`w:${F.id}`:`f:${F.path}`,q:(D==null?void 0:D.query)??"",listRef:L,tabPicks:!0,onPick:F=>{if(!D)return;const{text:Ze,caret:Lt}=x8(E,D,BB(F));je(Ze),Tr(D.from),Re(F.kind==="cmd"&&F.c.hint?{name:F.c.name,hint:F.c.hint}:null),requestAnimationFrame(()=>{const Vt=rn.current;Vt&&(Vt.focus(),Vt.setSelectionRange(Lt,Lt),En(Lt))})}}),jr=w||_?L8(E):null,lh=pr&&E===`/${pr.name} `?pr.hint:null,Cl=jr===""&&e?g?" 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,Ls=lh??Cl,Ti=(e==null?void 0:e.worktree.title)??"untitled",ps=(Ll=kn==null?void 0:kn.recap)==null?void 0:Ll.text,bo=()=>{w&&pi(p,u,{t:"land",worktreeId:w})},ma=F=>{w&&(p==null||p.send({t:"judge",worktreeId:w,...F?{note:F}:{}}))},ga=!!((Dl=Me==null?void 0:Me.config.check)!=null&&Dl.trim()),ka=zk(fn,Ct,_t),wa=In&&!Zt&&!St&&Yi(e.worktree)&&!Te&&!ar&&pt>0&&(!fn||!!fn.stale||ka==="unanswered"),ji="Archive this worktree when you are done here; the rail's archived section brings it back with its chat.",uu=yn?"update":zg(Fr,(e==null?void 0:e.worktree)??{}),Cr=Me?Tf(Me):"main",Ds=yn&&cn?`Commit, take ${Cr} in and push the branch; PR #${cn.number} takes the new commits.`:`${Yd(Fr,Me==null?void 0:Me.defaultBranch)}.`,ya=et&&!ps?{links:ez(et)}:{},rr=w?Ge?{word:"archive",kind:"archive",line:(rt==null?void 0:rt.state)==="merged"?Ts(rt):`landed on ${(Me==null?void 0:Me.defaultBranch)??"main"}.`,tip:ji,run:()=>oa(p,u,[w])}:(et==null?void 0:et.state)==="open"&&!yn?l_(et)?{word:"land",kind:"merge",line:Td(ps??Ts(et)),tip:`${Ts(et)} Merge the PR now, by the method the repo allows.`,...ya,run:bo,ships:!0}:{word:"view",kind:"view",line:Td(ps??Ts(et)),tip:`${Ts(et)} Open the PR on GitHub.`,...ya,run:()=>window.open(et.url,"_blank")}:(et==null?void 0:et.state)==="closed"?{word:"archive",kind:"archive",line:Ts(et),tip:`${Ts(et)} ${ji}`,run:()=>oa(p,u,[w])}:wa?{word:"check",kind:"check",line:(fn==null?void 0:fn.subject)??Td(ps??sz(pt)),tip:c_(fn,ga,ka),run:ma}:Tt!=null&&Tt.ready&&!Nd(Tt,Ct,_t,De==null?void 0:De.name)?{word:uu,kind:"ship",line:Tt.subject??Td(ps??(bb(Tt,pt)||"ready")),tip:[bb(Tt,pt),oz(Cr,e==null?void 0:e.behind),Ds,Tt.subject&&Ct>0?"Tab from the word edits the message first.":""].filter(Boolean).join(" "),run:bo,ships:!0}:null:null,du=(Hs=e==null?void 0:e.worktree.lands)==null?void 0:Hs.at(-1),va=du&&i_(du),Ci=((rr==null?void 0:rr.kind)==="ship"||(rr==null?void 0:rr.kind)==="check")&&Tt?iz(Tt,ka):(rr==null?void 0:rr.word)==="archive"&&va?Kr(va):null,ms=S.useRef(null);Zt!=="land"&&(ms.current=w&&(rr!=null&&rr.ships)?{id:w,verb:rr,under:Ci}:null);const gs=Zt==="land"&&wn&&((Ws=ms.current)==null?void 0:Ws.id)===w?ms.current:null,$n=gs?gs.verb:rr,fu=(Su=$n==null?void 0:$n.links)!=null&&Su.length?tz($n.line,$n.links):null,ba=!!($n!=null&&$n.ships)&&Zt==="land",Al=vk(bn,bk),zs=Uc(e,"commit"),xa=Uc(e,"check"),Fs=d_(ba?zs:xa),hu=ra(Bk(Fs)?Fs==null?void 0:Fs.since:void 0),Il=Tt?Tt.check==="pending"&&xa&&Fs===xa?cf("Checking the work",xa,hu):Nd(Tt,Ct,_t,De==null?void 0:De.name):null,$l=$n&&ba?Al?`${$n.word}: ${Al}`:`${$n.word} ${$n.line}`:null,Rl=$l&&zs&&Fs===zs?cf($l,zs,hu):$l,pu=n?n.restorable?`message agent on ${n.title}; sending restores it first`:"its commits were not kept, so it cannot come back":r?r.locked?`held by ${r.lockReason??"another tool"}; Toyon takes it over once the lock goes`:`message agent on ${r.name}; sending takes it over first`:o?`describe ${o.name||"the app"}; return makes it`:e?$n?"":Il||(et?Ts(et):tr?Fk(tr):i?`describe ${Ti}…`:St?"describe a change":c?`message agent on ${Ti}`:`message agent on ${Ti}; / for a command, ! for a shell command`):"no worktree selected",Ea=E!==""||Ls||!e?null:ba?Al?null:gs?gs.under:Ci:$n?Ci:et||Il?ps??(Tt==null?void 0:Tt.subject)??null:null,mu=S.useRef(!1);S.useEffect(()=>{const F=oe&&!mu.current;mu.current=oe,F&&((D==null?void 0:D.kind)==="file"&&w?qf(w,m.getState(),{sock:p,dispatch:u}):(D==null?void 0:D.kind)==="command"&&Hn&&se.length===0&&(p==null||p.send({t:"list-commands",worktreeId:Hn})))},[oe,D==null?void 0:D.kind,se.length,w,Hn,p,m,u]);const Sa=()=>{if(!e)return;const F=[],Ze=Ne;if(Ze.url)try{const Pn=new URL(Ze.url);F.push(`current route: ${Pn.pathname}${Pn.search}`)}catch{}Ze.title&&F.push(`page title: ${Ze.title}`);const Lt=[];i&&Lt.push(p9(e.worktree.title,Me==null?void 0:Me.configFile)),F.length>0&&Lt.push(`What the user is looking at right now:
|
|
237
|
+
${F.join(`
|
|
238
|
+
`)}`);const Vt=z8(O);return Vt&&Lt.push(Vt),Lt.length>0?Lt:void 0},gu=F=>{St?Xt(F):w&&F!==U&&(p==null||p.send({t:"set-worktree-mode",worktreeId:w,mode:F}))},lr=F=>b&&u({a:"notice",id:b,text:F}),ch=(F,Ze="")=>{if(!e||!w)return;if(F==="handoff"){if(St)return lr("a new worktree has nothing to continue yet");const Vt=F4(Ze,Se,e.worktree.repoId);"pick"in Vt?u({a:"open",overlay:{kind:"handoff",worktreeId:w}}):"error"in Vt?lr(Vt.error):p==null||p.send({t:"handoff-ask",worktreeId:w,repoId:Vt.repo.id,...Vt.text?{text:Vt.text}:{}});return}if(F==="archive"){Te||ar?oa(p,u,[w]):lr("archive is for a landed worktree; this one has not landed");return}if(F==="check"){St||!Yi(e.worktree)?lr("nothing to check from here"):at?lr("wait for the turn to end"):pt===0?lr("nothing to check: no changes here"):ma(Ze||void 0);return}const Lt=fn?Nd(fn,Ct,_t,De==null?void 0:De.name):null;St||!Yi(e.worktree)?lr("nothing to land from here"):Te?lr(`already landed on ${(Me==null?void 0:Me.defaultBranch)??"main"}`):Lt?lr(Lt):at&&(!fn||fn.stale)?lr("wait for the turn to end"):fn!=null&&fn.stale?lr("the work changed since this was checked; check again first"):bo()},Ai=N.some(ki),Bs=()=>{b&&(p==null||p.send({t:"set-draft",boxId:b,text:E,clientId:Ce}))},Ii=(F,Ze,Lt,Vt)=>u({a:"hold-send",id:F,log:Ze,text:Lt,frame:Vt}),Ol=()=>{if(!b)return;const F=AB(E,K),Ze=F&&TB(F.name)?F.name:void 0;if(o){if(o.busy)return;if(o.why)return lr(o.why);(Ht!==wt||!on)&&(p==null||p.send({t:"set-default-agent",agent:Ht})),Bs(),o.create();return}if(wn)return;const Lt=jr===null&&(!F||!!Ze&&!!F.args);if(V&&V.kind!=="unready"&&De&&Lt){lr(V.kind==="installing"?`${De.name} is still installing`:V.retry?`nothing runs here until ${De.name} is installed`:V.text);return}const Vt=()=>({text:E.trim(),attachments:N.length?N.map(il):void 0});if(n){if(!n.restorable)return;if(jr!==null){lr("nothing runs here until it is restored");return}const uo={t:"restore-worktree",archiveId:n.id,clientId:Ce};if(Ai)return Ii(b,b,E.trim(),uo);Bs(),p==null||p.send(gc(uo,b,E.trim(),N)),u({a:"sending",id:b,message:Vt()}),u({a:"sent-box",id:b});return}if(r){if(r.locked)return;if(jr!==null){lr("nothing runs here until Toyon takes it over; its menu on the rail opens a shell");return}const uo={t:"adopt-worktree",worktreeId:r.id,clientId:Ce};if(Ai)return Ii(b,b,E.trim(),uo);Bs(),p==null||p.send(gc(uo,b,E.trim(),N)),u({a:"sending",id:b,message:Vt()}),u({a:"sent-box",id:b});return}if(!e||!w)return;if(jr!==null){if(jr&&Zt&&!g){lr(`${hA(Zt)} is running here; run the command once it is done`);return}jr&&g?u({a:"term-run",id:w,command:jr}):jr&&(p==null||p.send({t:"exec",worktreeId:w,command:jr})),je("");return}if(F&&!Ze){ch(F.name,F.args),je("");return}if(Ze&&!(F!=null&&F.args)){gu(Ze),je("");return}if(t!=null&&t.batch&&N.length){lr("a batch takes no attachments; remove them or turn batch off");return}const Pn=F?F.args:E.trim(),co=Sa(),zl=N.length?N.map(il):void 0;if(Ze&&gu(Ze),St){const uo=Jc(e.worktree)?{worktreeId:w}:{},fh={clientId:Ce,repoId:e.worktree.repoId,context:co,agent:Ht,profile:ye,mode:Ze??Ie,...lt?{model:lt}:{},...Kt?{effort:Kt}:{},...ME(t)?{carry:!0}:{}};if((Ht!==wt||!on)&&(p==null||p.send({t:"set-default-agent",agent:Ht})),t!=null&&t.batch)Bs(),p==null||p.send({t:"batch-worktrees",repoId:e.worktree.repoId,prompt:Pn,agent:Ht,...lt?{model:lt}:{},...Kt?{effort:Kt}:{},boxId:b}),u({a:"sent-box",id:b});else{const hh=t&&t.variants>1?{variants:t.variants}:{},_u={t:"create-worktree",...fh,...uo,...hh};Ai?Ii(b,b,Pn,_u):(Bs(),p==null||p.send(gc(_u,b,Pn,N)),u({a:"sending",id:b,message:{text:Pn,attachments:zl}}),u({a:"sent-box",id:b}))}}else{Yt&&(p==null||p.send({t:"set-worktree-model",worktreeId:w,model:lt}),p==null||p.send({t:"set-worktree-effort",worktreeId:w,effort:Kt}));const uo={t:"chat",worktreeId:w,clientId:Ce,context:co};Ai?Ii(b,w,Pn,uo):(Bs(),p==null||p.send(gc(uo,b,Pn,N)),mt||u({a:"sending",id:w,message:{text:Pn,attachments:zl}}),u({a:"sent-box",id:b}))}i&&u({a:"show-chat"})},uh=F=>{if(!w||(ve==null?void 0:ve.ask.kind)!=="question")return;if(!F.some(sl))return u({a:"ask-revive",id:w});const Ze=tk(ve.ask.questions,F).join(`
|
|
239
|
+
`),Lt={t:"chat",worktreeId:w,clientId:Ce,context:Sa()};if(Z&&Y.some(ki))Ii(Z,w,Ze,Lt);else{const Vt=Y.length?Y.map(il):void 0,Pn=Vt&&Z?{attachments:Vt,boxId:Z}:{};p==null||p.send({...Lt,text:Ze,...Pn}),Vt&&Z&&u({a:"clear-attachments",id:Z}),u({a:"sending",id:w,message:{text:Ze,attachments:Vt}})}u({a:"answered",id:w}),u({a:"ask-revive",id:w})},Ml=M(F=>F.autoSend);ft([Ml,w],()=>{!Ml||Ml!==w||wn||Ni!==!!i||(u({a:"auto-sent"}),Ol())});const dh=()=>{const F=N[N.length-1];return!b||!F?!1:(u({a:"detach",id:b,key:F.key}),!0)},ku=F=>{b&&(u({a:"walk",id:b,walk:F.walk,text:F.text}),requestAnimationFrame(()=>{var Ze;(Ze=rn.current)==null||Ze.setSelectionRange(F.text.length,F.text.length),En(F.text.length)}))},_a=()=>{b&&A&&u({a:"walk",id:b,walk:null,text:E})},Us=St?[]:O.map(F=>F.kind==="user"?F.attachments:void 0),wu=St?[]:B.flatMap(F=>F.attachments??[]),ks=e==null?void 0:e.worktree.plan,yu=VN(e==null?void 0:e.worktree.id,ks),Pl=Wt&&!C,vu=M(F=>F.reading),[bu,ws]=S.useState(!1),Na=c&&vu&&!q&&(C?!bu:wn&&!ue);return ft([Na],()=>{if(Na||!C)return;const F=requestAnimationFrame(()=>{var Ze;document.activeElement===document.body&&((Ze=z.current)==null||Ze.focus())});return()=>cancelAnimationFrame(F)}),d.jsxs("div",{className:We("composer chat-input",Pl&&"stopping",Na&&"lean"),onFocus:F=>ws(F.target instanceof HTMLTextAreaElement),onBlur:()=>ws(!1),children:[ks&&e&&d.jsxs("div",{className:"composer-plan",...Mt.contextMenu(()=>Wk(ks,()=>p==null?void 0:p.send({t:"reveal",worktreeId:e.worktree.id,path:ks}),Xo(p))),children:[d.jsx(kt,{name:"text",className:"icon-inline"}),d.jsx(Be,{variant:"inline",className:"composer-plan-path","data-tip":ks,onClick:()=>er({dispatch:u},{worktreeId:e.worktree.id,path:ks,view:"preview"}),children:yu})]}),q&&w&&d.jsx(Ga,{icon:"chat",verb:"answer",tip:"Bring the question back into the box",onPress:()=>{u(q.kind==="ask"&&q.outcome?{a:"ask-revive",id:w,askId:q.id}:{a:"card-unpark",id:w}),u({a:"focus-chat"})},children:cb(q)}),(ge==null?void 0:ge.verb)==="fix"&&"toolId"in ge&&w&&d.jsxs(Ga,{icon:"run",verb:ge.verb,tip:"Send the agent what it printed and ask for a fix",onPress:()=>p==null?void 0:p.send({t:"fix",worktreeId:w,toolId:ge.toolId}),onDismiss:()=>Px(ge.key),children:["what failed in ",d.jsx("code",{children:ge.command})]}),(ge==null?void 0:ge.verb)==="continue"&&w&&d.jsx(Ga,{icon:"send",verb:ge.verb,tip:ge.after==="stop"?"Send the agent on from where its turn stopped":ge.again?"The last press ended in this same error. Send the agent on once more, or wait it out.":"Send the agent on from where its turn failed",onPress:()=>p==null?void 0:p.send({t:"continue",worktreeId:w}),onDismiss:()=>Px(ge.key),children:ge.after==="stop"?"where it stopped":ge.again?"after the same error again":"after the error"}),ue&&b&&!C&&(e||T||o)&&d.jsx(Ga,{icon:"copy",verb:"attach",tip:"Attach it, as a paste would",onPress:()=>{nD(m,b,ue),Mn()},onDismiss:fS,children:ue.kind==="image"?"the image you copied":`the text you copied, ${ue.text.split(`
|
|
240
|
+
`).length} lines`}),Le&&w&&!g&&!C&&u9({prompt:Le,offered:ke,agent:e==null?void 0:e.agent,chat:O})&&d.jsx(Ga,{icon:"download",verb:"install",tip:"Install Toyon as an app: a window of its own, with a Dock icon and no browser bar",onPress:()=>{Tx(),Le.prompt()},onDismiss:Tx,children:"Toyon as a window of its own, with a Dock icon and no browser bar"}),b&&!C&&jr===null&&d.jsx(th,{children:Pg(N,Ec(Em(Us),wu)).map(([F,Ze])=>{const Lt=()=>u({a:"detach",id:b,key:F.key});return F.kind!=="pick"?d.jsx(_T,{item:F,n:Ze,onRemove:Lt},F.key):d.jsx(mw,{pick:F,tipText:F.html,onHover:Vt=>Ee&&an.post(Ee,Vt?{type:"highlight-selector",selector:F.selector,label:lk(F)}:{type:"highlight-clear"}),worktreeId:w,onOpen:(Vt,Pn)=>w&&sa(m,p,w,Vt,Pn),onRemove:Lt},F.key)})}),oe&&D&&d.jsx(f9,{results:Ve,keyOf:F=>F.kind==="cmd"?`c:${F.c.name}`:F.kind==="changes"?"changes":F.kind==="worktree"?`w:${F.id}`:F.kind==="folder"?`d:${F.path}`:`f:${F.path}`,rowClass:F=>F.kind==="file"||F.kind==="folder"?"qo-file":F.kind==="changes"||F.kind==="worktree"?"picker-row":"picker-row picker-cmd",nav:Ps,listRef:L,empty:FB(D.kind,Nt,se.length,Hn!==null),note:It>0?`type to find ${It} more`:void 0,groupOf:F=>F.kind==="worktree"?"worktrees":F.kind==="cmd"?"commands":"files",row:F=>{const Ze=((ht==null?void 0:ht.files.length)??0)>0;return F.kind==="file"?vg(F.path,F.status,D.query,{gutter:Ze}):F.kind==="folder"?vg(F.path,void 0,D.query,{folder:!0,gutter:Ze}):F.kind==="changes"?d.jsx(An,{label:"@changes",hint:`${F.n} uncommitted ${F.n===1?"file":"files"}`}):F.kind==="worktree"?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:`dot ${F.dot}`}),d.jsx(An,{label:F.title,hint:yr(F.at)})]}):d.jsx(I9,{c:F.c,query:D.query})}}),C&&Na&&w&&d.jsx(Ga,{icon:"chat",verb:"answer",tip:"Back to the question",onPress:()=>u({a:"answered",id:w}),children:cb(C)}),C&&w?C.kind==="handoff"?d.jsx(xB,{item:C,worktreeId:w,rootRef:z},C.id):C.ask.kind==="question"?d.jsx($B,{item:C,ask:C.ask,worktreeId:w,rootRef:z,numbers:Ec(Em(Us),wu),onScreen:c,onAnswer:ve?uh:void 0},C.id):d.jsx(IB,{item:C,ask:C.ask,worktreeId:w,rootRef:z},C.id):d.jsxs("div",{className:We("composer-field",jr!==null&&"shell",A&&"recalled"),children:[d.jsx(Bc,{size:"lg",bare:!0,font:jr!==null?"mono":"ui",ref:rn,value:E,onChange:F=>{var co;const Ze=F.target.value,Lt=F.target.selectionStart??Ze.length;je(Ze),En(Lt),Ps.setIndex(0);const{inputType:Vt}=F.nativeEvent;Tr(Vt==="insertFromPaste"||Vt==="insertFromDrop"?((co=kx(Ze,Lt))==null?void 0:co.from)??null:null)},onKeyUp:F=>{G(),En(F.currentTarget.selectionStart??0)},onClick:F=>{En(F.currentTarget.selectionStart??0),_a()},onPaste:we,onScroll:F=>{Wn.current&&(Wn.current.scrollTop=F.currentTarget.scrollTop)},onKeyDown:F=>{var Ze;if(ae(F),!F.nativeEvent.isComposing){if(oe){if(F.key==="Escape"){F.preventDefault(),F.stopPropagation(),Tr((D==null?void 0:D.from)??null);return}if(Ps.onKeyDown(F))return}if((F.key==="ArrowUp"||F.key==="ArrowDown")&&!F.altKey&&!F.ctrlKey){const Lt=F.key==="ArrowUp",Vt=B.at(-1);if(Lt&&!F.metaKey&&!A&&E===""&&w&&!g&&Vt!==void 0){F.preventDefault(),NS(m,p,w,B.length-1);return}const Pn=F.metaKey?Lt?"first":"box":Lt?"up":"down",co=w?n9(O,A??null,E,Pn):null;if(co){F.preventDefault(),(co.walk!==A||co.text!==E)&&ku(co);return}}if(A&&F.key==="Escape"){F.preventDefault(),F.stopPropagation(),ku({walk:null,text:A.from});return}if(F.key==="Escape"&&at&&w&&!g){F.preventDefault(),F.stopPropagation(),p==null||p.send({t:"stop-agent",worktreeId:w});return}if(A&&LB.has(F.key)&&_a(),F.key==="Tab"&&!F.shiftKey&&E===""){const Lt=(Ze=F.currentTarget.closest(".composer"))==null?void 0:Ze.querySelector(".composer-verb");if(Lt&&!Lt.disabled){F.preventDefault(),Lt.focus();return}if(zr){F.preventDefault(),u({a:"edit-commit"});return}}F.key==="Enter"&&(te?F.metaKey||F.ctrlKey:!F.shiftKey)?(F.preventDefault(),Ol()):F.key==="Backspace"&&E===""&&dh()&&F.preventDefault()}},placeholder:Ea||$n?"":pu,disabled:o?o.busy:!e&&!T}),Ls&&d.jsxs("div",{className:"composer-ghost","aria-hidden":"true",children:[d.jsx("span",{className:"picker-typed",children:E}),Ls]}),w&&jr===null&&E.includes("@")&&d.jsx("div",{ref:Wn,className:"composer-ghost composer-marks","aria-hidden":"true",onClick:F=>WN(F,e==null?void 0:e.worktree.path,w,{sock:p,dispatch:u}),children:d.jsx(HN,{text:E,worktreeId:w,root:e==null?void 0:e.worktree.path,inField:!0})}),(Ea||$n)&&d.jsxs("div",{className:"composer-ghost composer-standing","aria-hidden":$n?void 0:"true",children:[d.jsx("span",{className:We("composer-placeholder",ba&&"live-text"),children:Rl||($n?d.jsxs(d.Fragment,{children:[d.jsx(Be,{variant:"inline",tone:"strong",className:"composer-verb",disabled:!!$n.ships&&!!Zt,...Ut($n.tip,void 0,{placement:"top"}),onClick:()=>{var F;$n.run(),te||(F=rn.current)==null||F.focus()},onKeyDown:F=>{F.key==="Tab"&&!F.shiftKey&&zr&&(F.preventDefault(),u({a:"edit-commit"}))},children:$n.word})," ",d.jsx("span",{className:"composer-verb-line",children:fu?fu.map(F=>typeof F=="string"?F:d.jsxs(Be,{variant:"inline",className:"composer-verb-tail",...Ut(F.tip,void 0,{placement:"top"}),onClick:()=>{var Ze;window.open(F.url,"_blank"),te||(Ze=rn.current)==null||Ze.focus()},...Mt.contextMenu(()=>[{id:"open-link",label:F.open,onClick:()=>window.open(F.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>en(F.url)}]),children:[F.text," ",d.jsx(kt,{name:"external",className:"icon-inline"})]},F.text)):$n.line})]}):pu)}),Ea&&d.jsxs(d.Fragment,{children:[`
|
|
241
|
+
`,d.jsx("span",{className:"composer-subline",children:Ea})]})]}),Pl&&d.jsx(Ot,{icon:"stop",tone:"danger",className:"composer-stop",label:`Stop the agent (context up to here is kept${B.length?"; queued messages go next":""})`,hint:"esc",onClick:()=>w&&(p==null?void 0:p.send({t:"stop-agent",worktreeId:w}))})]}),j&&d.jsx("div",{className:"hint composer-notice",role:"status",children:j}),!C&&d.jsxs("div",{className:"hint composer-knobs",children:[d.jsxs("span",{className:"spawn-left",children:[zt?Pt.length>1?d.jsx(C9,{agents:Pt,agent:Ht,model:lt,onChange:jn,onClose:lo}):d.jsx(Ix,{models:sn,value:lt,onChange:jt,onClose:lo}):e&&d.jsx(Ix,{models:sn,value:e.worktree.model??"",current:Ye,onChange:F=>p==null?void 0:p.send({t:"set-worktree-model",worktreeId:e.worktree.id,model:F}),onClose:lo}),zt?d.jsx(Cx,{efforts:ln,value:Kt,onChange:xn,onClose:lo}):e&&d.jsx(Cx,{efforts:ln,value:e.worktree.effort??"",current:nt,onChange:F=>p==null?void 0:p.send({t:"set-worktree-effort",worktreeId:e.worktree.id,effort:F}),onClose:lo}),St?!o&&d.jsx(Ax,{value:Ie,onChange:Xt,onClose:lo}):e&&d.jsx(Ax,{value:U,onChange:F=>p==null?void 0:p.send({t:"set-worktree-mode",worktreeId:e.worktree.id,mode:F}),onClose:lo}),Br&&d.jsxs("span",{className:"usage-knob",onMouseEnter:()=>{Gt||(window.clearTimeout(xr.current),xr.current=window.setTimeout(()=>Nr(!0),DB))},onMouseLeave:()=>{window.clearTimeout(xr.current),Nr(!1)},onFocus:F=>{Gt||!F.target.matches(":focus-visible")||(window.clearTimeout(xr.current),Nr(!0))},onBlur:nr,children:[d.jsx(Ot,{icon:d.jsx(h9,{fraction:qt?qt.used/qt.size:0,level:gt?Oz(gt,hr):void 0}),tone:"chrome",on:Gt,silent:!0,label:qt?`${Math.round(100*qt.used/qt.size)}% of context`:gt?$b(gt,hr):"",detail:[...qt&>?[$b(gt,hr)]:[],...At?[At]:[]],...Mt.dropdown(vt,"left","usage"),...Mt.contextMenu(vt,"usage")}),vo&&d.jsx(MB,{usage:qt,limits:gt,auth:De==null?void 0:De.auth,now:hr,onClose:nr})]})]}),d.jsxs("span",{className:"spawn-tools",children:[b&&(e||T||o)&&d.jsx(Ot,{icon:"attach",tone:"chrome",label:c?"Attach a picture":"Attach a picture or a file, or drop one here",onClick:()=>MS(m,b,{images:c})}),!i&&!_&&!c&&!o&&d.jsx(Ot,{icon:"terminal",tone:"chrome",on:ze,className:"composer-term",disabled:!e,label:Xe?Xe.tip:"Terminal",hint:Dt("terminal"),badge:Xe&&d.jsx("span",{className:"composer-term-dot"}),onClick:()=>{u(Xe&&!ze&&w?{a:"term-stream",id:w,stream:Xe.stream}:{a:"toggle-terminal"})},...Mt.contextMenu(()=>e&&w?u8(e.procs,w,ze,{sock:p,dispatch:m.dispatch}):[])}),!i&&!de&&!_&&!c&&!o&&d.jsx(Ot,{icon:"pick",label:"Pick an element on the page to attach",hint:Dt("pick"),on:me==="chat",disabled:!Ee,onClick:()=>Ee&&Fc(Ee,me,u,"chat")}),te&&b&&(e||T||o)&&d.jsx(Ot,{icon:"send",tone:"primary",label:o?"Create the project":"Send",disabled:o?o.busy:wn,onMouseDown:F=>F.preventDefault(),onClick:Ol})]})]}),(V||Xn&&On)&&d.jsxs("div",{className:"composer-notes",children:[V&&De&&d.jsxs("div",{className:"hint composer-note",role:"status",children:[d.jsx("span",{children:V.text}),(V.retry||pe)&&d.jsxs("span",{className:"composer-note-actions",children:[V.retry&&d.jsx(Be,{variant:"outline",onClick:()=>p==null?void 0:p.send({t:"install-agent",agent:De.id}),children:V.retry}),pe&&d.jsxs(Be,{variant:"outline","data-tip":`${pe.name} is installed and takes this message instead`,onClick:()=>Qt(pe.id),children:["use ",pe.name]})]})]}),Xn&&On&&d.jsxs("div",{className:"hint composer-note",children:[d.jsx("span",{children:Xn}),XD(On)&&d.jsx(Be,{variant:"outline",busy:Cn==="pull-main",disabled:!!Cn,"data-tip":"Fast-forward main to origin",onClick:()=>pi(p,u,{t:"pull-main",worktreeId:On.id}),children:"pull"})]})]})]})}function AT({children:e,className:t,tip:n,...r}){return d.jsxs("label",{className:We("check",t),"data-tip":n,children:[d.jsx("input",{type:"checkbox",className:"check-box",...r}),d.jsx("span",{children:e})]})}const UB=[1,2,3];function HB({draft:e,lead:t}){const n=ut(),r=M(c=>Ei(c,t==null?void 0:t.repoId)),[o]=aT(r),i=M(c=>{var u;return((u=ml(c,t==null?void 0:t.repoId))==null?void 0:u.dirty)??0}),l=!e.batch&&e.variants===1;return d.jsxs("div",{className:"draft-intro",children:[d.jsxs("div",{className:"draft-row hint",children:[d.jsx(Be,{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"}),d.jsxs("span",{className:"draft-variants",children:[UB.map(c=>d.jsx(Be,{variant:"ghost",on:e.variants===c,disabled:e.batch,onClick:()=>n({a:"draft-variants",n:c}),children:c},c)),d.jsx("span",{"data-tip":"Run the same prompt in N parallel worktrees, keep the best",children:"variants"})]}),d.jsx("span",{className:"draft-runs",children:d.jsx(A9,{repo:r,value:e.profile??o,onChange:c=>n({a:"draft-profile",profile:c})})})]}),t&&r&&i>0&&d.jsx("div",{className:"draft-notes",children:d.jsxs(AT,{className:"hint draft-note",checked:ME(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:c=>n({a:"draft-carry",v:c.currentTarget.checked}),children:[d.jsxs("span",{className:"badge-dirty",children:["~",i]})," on ",r.defaultBranch," come along"]})})]})}function WB({row:e}){const t=it(),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 d.jsxs(to,{icon:e.locked?"lock":"branch",word:e.locked?"held":"discovered",tone:"quiet",below:d.jsx("div",{className:"daemon-below row-dim",children:i}),children:[d.jsxs("span",{className:"daemon-text",children:[e.locked&&`by ${e.lockReason??"another tool"}, at `,d.jsx("span",{className:"tool-hint",children:o})]}),!e.locked&&d.jsx(Be,{variant:"inline",tone:"strong",onClick:()=>t==null?void 0:t.send({t:"adopt-worktree",worktreeId:e.id,clientId:n}),children:"take over"})]})}function Ic({placement:e,className:t,width:n,archived:r,found:o}){const i=ut(),l=$s(),c=JL(),u=Rt(l==null?void 0:l.worktree.id,"sending"),p=Nl(),h=e==="centre"&&!r&&(p!=null&&p.assumed)?p:null,m=M(y=>{var b;return((b=y.dragFiles)==null?void 0:b.at)==="chat"}),g=Yn(),w=S.useMemo(()=>J4(g),[g]);return d.jsxs("div",{className:We(e==="dock"?"chat-dock":e==="centre"?"chat-centre":"chat-screen",t,m&&"drop-over"),style:n===void 0?void 0:{width:n},...w,ref:y=>{var b;y?jc.el=y:(b=jc.el)!=null&&b.isConnected||(jc.el=null)},children:[r?d.jsx(um,{active:null,archived:r,tail:d.jsx(Fz,{item:r})}):o?d.jsx(um,{active:null,found:o,tail:d.jsx(WB,{row:o})}):d.jsx(um,{active:l,lead:h&&d.jsxs("p",{className:"hint chat-centre-note",children:[h.name," has ",d.jsx("code",{children:h.assumed})," and no dev server, so it is chat only for now."," ",d.jsx(Be,{variant:"inline",onClick:()=>i({a:"open",overlay:{kind:"setup",repoId:h.id}}),children:"add a dev server"})]})}),!r&&!o&&c&&!u&&d.jsx(HB,{draft:c,lead:l}),r?d.jsx(Ac,{active:null,archived:r,placement:e}):o?d.jsx(Ac,{active:null,found:o,placement:e}):d.jsx(Ac,{active:l,draft:c,placement:e})]})}const KB="modulepreload",ZB=function(e){return"/"+e},Bx={},Eg=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let l=function(p){return Promise.all(p.map(h=>Promise.resolve(h).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),u=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));o=l(n.map(p=>{if(p=ZB(p),p in Bx)return;Bx[p]=!0;const h=p.endsWith(".css"),m=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${m}`))return;const g=document.createElement("link");if(g.rel=h?"stylesheet":KB,h||(g.as="script"),g.crossOrigin="",g.href=p,u&&g.setAttribute("nonce",u),document.head.appendChild(g),h)return new Promise((w,y)=>{g.addEventListener("load",w),g.addEventListener("error",()=>y(Error(`Unable to preload CSS for ${p}`)))})}))}function i(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return o.then(l=>{for(const c of l||[])c.status==="rejected"&&i(c.reason);return t().catch(i)})},Sw=800;function qB(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 Uo=e=>`${e.worktreeId}
|
|
242
|
+
${e.ref??""}
|
|
243
|
+
${e.since??""}
|
|
244
|
+
${e.path}`;class GB{constructor(t){Bt(this,"files",new Map);Bt(this,"looks",new Map);this.d=t}start(){var i,l;let t=this.d.store.getState();const n=this.d.store.subscribe(()=>{const c=this.d.store.getState(),u=t;t=c,this.follow(u,c)}),r=()=>{const c=this.d.store.getState().editor;c&&!c.loose&&this.refresh(Uo(c))};(i=this.d.win)==null||i.addEventListener("focus",r);const o=()=>{for(const[c,u]of this.files)u.timer!==void 0&&this.saveNow(c)};return(l=this.d.win)==null||l.addEventListener("pagehide",o),()=>{var c,u;n(),(c=this.d.win)==null||c.removeEventListener("focus",r),(u=this.d.win)==null||u.removeEventListener("pagehide",o)}}receive(t){const n=t.t==="file-read"?this.looks.get(t.seq):void 0;if(n&&t.t==="file-read"){this.looks.delete(t.seq),n(t.error||t.binary||t.tooLarge||t.version===null?null:t.after);return}const r=this.files.get(Uo(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=Go();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=Uo(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(Uo(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(Uo(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,c,u;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||Uo(o)!==Uo(r))&&this.closed(Uo(o)),r&&(!o||o.seq!==r.seq)&&this.opened(r),!t.connected&&n.connected)for(const p of this.files.values())p.reread=!0,this.next(p);else r&&o&&o.seq===r.seq&&((c=Ro(t,r.worktreeId).git)==null?void 0:c.version)!==((u=Ro(n,r.worktreeId).git)==null?void 0:u.version)&&this.refresh(Uo(r))}opened(t){const n=Uo(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 c=Go();t.out={seq:c},this.d.send({t:"read-file",worktreeId:n,path:r,ref:o,since:i,seq:c});return}if(t.pending!==null&&t.base&&t.pending===t.base.text&&(t.pending=null),t.pending!==null&&t.writable&&!t.conflict&&!o){const c=t.pending,u=Go();t.pending=null,t.out={seq:u,write:c},this.d.send({t:"write-file",worktreeId:n,path:r,content:c,base:((l=t.base)==null?void 0:l.version)??null,seq:u});return}!t.open&&!t.buffer&&t.pending===null&&!t.conflict&&this.files.delete(Uo(t.file))}read(t,n){var g,w;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:c,binary:u,tooLarge:p}=n;t.writable=c,t.open&&(this.d.store.dispatch({a:"editor-read",file:r,disk:{before:o,after:i,version:l,writable:c,binary:u,tooLarge:p}}),!u&&!p&&(l!==null||r.ref)&&this.askBlame(t,l));const h={after:t.buffer?t.buffer.normalize(i):i,version:l};if(!t.base){t.base={text:h.after,version:l};return}const m=((g=t.buffer)==null?void 0:g.text())??t.pending??t.base.text;switch(qB(t.base,m,t.pending,h)){case"same":break;case"adopt":t.base={text:h.after,version:l};break;case"apply":(w=t.buffer)==null||w.replace(h.after),t.base={text:h.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,h);return}this.setConflict(t,null)}askBlame(t,n){const r=Go();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)},Sw))}saveNow(t){const n=this.files.get(t);if(!(n!=null&&n.buffer))return;this.cancelTimer(n);const r=n.buffer.text();r.length>nf||(n.pending=r,this.next(n))}cancelTimer(t){t.timer!==void 0&&(this.d.timers.clear(t.timer),t.timer=void 0)}}const IT={attach:()=>{},edited:()=>{},saveNow:()=>{}},VB=e=>({timers:{set:(t,n)=>setTimeout(t,n),clear:t=>clearTimeout(t)},win:typeof window>"u"?null:window,send:e}),Sg=new Map;function YB(e){const t=Sg.get(e.seq);return t?(Sg.delete(e.seq),t(e),!0):!1}function XB(e,t,n,r){if(e.kind==="bytes")return IT;if(e.kind==="grant")return QB(e,t,n,r);const o=e.handle;let i=null,l,c=null,u=Promise.resolve(),p=!1;const h=()=>(c??(c=(async()=>await o.queryPermission({mode:"readwrite"})==="granted"?!0:await o.requestPermission({mode:"readwrite"})==="granted")().catch(()=>!1)),c),m=()=>{l!==void 0&&r.timers.clear(l),l=void 0},g=()=>{p||(p=!0,m(),n(`read-only: the browser would not save ${t}`))},w=async _=>{if(!await h())return g();const T=await o.createWritable();await T.write(_),await T.close()},y=()=>{if(!i||p)return;m();const _=i.text();u=u.then(()=>w(_)).catch(g)},b=()=>{l!==void 0&&y()};return{attach(_){var T,E;if(_){i=_,(T=r.win)==null||T.addEventListener("pagehide",b);return}l!==void 0&&y(),i=null,(E=r.win)==null||E.removeEventListener("pagehide",b)},edited(){!i||p||(h().then(_=>{_||g()}),m(),l=r.timers.set(y,Sw))},saveNow:y}}function QB(e,t,n,r){let o=null,i,l=e.version,c=!1,u=null,p=!1;const h=()=>{i!==void 0&&r.timers.clear(i),i=void 0},m=b=>{p||(p=!0,h(),u=null,n(b))},g=b=>{if(!r.send)return;const _=Go();c=!0,Sg.set(_,T=>{if(c=!1,T.ok?l=T.version:T.reason==="changed"?m(`read-only: ${t} changed on disk; open it again to edit`):m(T.message??`not saved: ${t}`),u!==null&&!p){const E=u;u=null,g(E)}}),r.send({t:"write-loose",id:e.id,content:b,base:l,seq:_})},w=()=>{if(!o||p)return;h();const b=o.text();b.length>nf||(c?u=b:g(b))},y=()=>{i!==void 0&&w()};return{attach(b){var _,T;if(b){o=b,(_=r.win)==null||_.addEventListener("pagehide",y);return}i!==void 0&&w(),o=null,(T=r.win)==null||T.removeEventListener("pagehide",y)},edited(){!o||p||(h(),i=r.timers.set(w,Sw))},saveNow:w}}function _w({kind:e,className:t,height:n,resizable:r=!0,onDragStart:o,title:i,tabs:l,actions:c,menu:u,full:p,onToggleFull:h,onClose:m,closeHint:g="esc",children:w}){const y=vn("pane"),b=h&&d.jsxs(Be,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:h,"data-tip":p?"Split view: show the preview above":"Full height: hide the preview",children:[d.jsx(kt,{name:p?"split":"full",className:"icon-inline"})," ",p?"split":"full"]}),_=d.jsx(Ot,{icon:"close",label:"Close",hint:g,onClick:m});return d.jsxs("div",{className:`pane ${t}`,"data-pane":e,tabIndex:-1,style:n===void 0?void 0:{height:n},children:[r&&d.jsx("div",{className:"pane-resize",onPointerDown:o}),d.jsx("div",{className:We("pane-head",l&&"pane-head-tabs"),...y.contextMenu(()=>(u==null?void 0:u())??[]),children:l?d.jsx(Xf,{...l,end:d.jsxs(d.Fragment,{children:[c,b,_]})}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"pane-title",children:i}),c,b,_]})}),w]})}const JB=1500;function eU({path:e}){const[t,n]=S.useState(!1);return S.useEffect(()=>{if(!t)return;const r=setTimeout(()=>n(!1),JB);return()=>clearTimeout(r)},[t]),d.jsxs(Be,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>{en(e),n(!0)},"data-tip":"Copy path: the file's full path on disk",children:[d.jsx(kt,{name:t?"check":"copy",className:"icon-inline"})," ",t?"copied":"copy"]})}function tU({src:e,path:t,full:n,onFull:r}){const o=vn("editor");return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"editor-image",onClick:()=>r(!0),...o.contextMenu(()=>Hc(e,{open:()=>r(!0)})),children:d.jsx("img",{src:e,alt:t})}),n&&d.jsx(Kk,{owner:"editor",onClose:()=>r(!1),menu:()=>Hc(e),children:d.jsx("img",{src:e,alt:t})})]})}const nU={image:tU};function rU({kind:e,src:t,path:n,openSeq:r,focus:o,full:i,onFull:l}){const c=S.useRef(null);ft([r],()=>{var p;o&&((p=c.current)==null||p.focus())});const u=nU[e];return d.jsx("div",{ref:c,className:"editor-viewer",tabIndex:-1,children:d.jsx(u,{src:t,path:n,full:i,onFull:l})})}const oU="img[src], source[src], video[src], audio[src], video[poster], link[href], object[data]";function sU(e,t){if(!t)return e;const n=new DOMParser().parseFromString(e,"text/html");let r=!1;for(const o of n.querySelectorAll(oU))for(const i of["src","href","poster","data"]){const l=o.getAttribute(i),c=l===null?null:Zk(t.dir,l);c&&(o.setAttribute(i,t.urls.worktreeFile(t.worktreeId,c,t.version)),r=!0)}return r?`${n.doctype?`<!doctype html>
|
|
245
|
+
`:""}${n.documentElement.outerHTML}`:e}function iU({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:i}){const l=S.useRef(null);ft([o],()=>{var h;i&&((h=l.current)==null||h.focus())});const c=Dr(),u=O_(t),p=S.useMemo(()=>sU(e,r===void 0?null:{worktreeId:n,dir:u,version:r,urls:c}),[e,n,u,r,c]);return d.jsx("div",{ref:l,className:"editor-viewer",tabIndex:-1,children:d.jsx("iframe",{className:"editor-frame",title:t,sandbox:"",srcDoc:p})})}function aU(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 lU(e){const t=new Map,n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=aU(n.map(o=>Number(o.tagName[1])));return n.map((o,i)=>{var u;const l=((u=o.textContent)==null?void 0:u.trim())??"",c=t.get(l)??0;return t.set(l,c+1),{id:`${c}
|
|
246
|
+
${l}`,level:Number(o.tagName[1]),depth:r[i],text:l,el:o}})}const cU=48,uU=16;function $T({html:e,openSeq:t=0,focus:n=!0,onLink:r,onChat:o}){const i=S.useRef(null),l=S.useRef(null),[c,u]=S.useState([]),[p,h]=S.useState(-1),[m,g]=S.useState(null),w=T=>{var E;if(g(null),T){const N=window.getSelection();N==null||N.removeAllRanges(),N==null||N.addRange(T)}(E=i.current)==null||E.focus()};ft([t],()=>{var T;n&&((T=i.current)==null||T.focus())}),ft([e],()=>{i.current&&u(lU(i.current))}),S.useLayoutEffect(()=>{const T=i.current;if(!T)return;let E=0;const N=()=>{if(E=0,T.scrollTop+T.clientHeight>=T.scrollHeight-1){h(c.length-1);return}const $=T.scrollTop+cU;let P=-1;for(let R=0;R<c.length;R++)c[R].el.offsetTop<=$&&(P=R);h(P)},j=()=>{E||(E=requestAnimationFrame(N))};return N(),T.addEventListener("scroll",j),()=>{T.removeEventListener("scroll",j),E&&cancelAnimationFrame(E)}},[c]);const y=T=>{var N,j;const E=(N=c[T])==null?void 0:N.el;(j=i.current)==null||j.scrollTo({top:Math.max(0,E?E.offsetTop-uU:0),behavior:"smooth"})},b=T=>{const E=T.target.closest("a"),N=E==null?void 0:E.getAttribute("href");!N||(E==null?void 0:E.target)==="_blank"||(T.preventDefault(),r==null||r(N))},_=T=>{var E;if(Uk(T)){T.preventDefault(),T.stopPropagation();const N=(l.current&&Jm(l.current))??"";g(j=>({seed:N||(j==null?void 0:j.seed)||"",seq:((j==null?void 0:j.seq)??0)+1}));return}if(T.key==="Escape"&&m){T.stopPropagation(),w(null);return}if(N_(T)&&l.current){T.preventDefault(),j_(l.current);return}if(o&&((E=m1(T))==null?void 0:E.id)==="composer"&&l.current){const N=Jm(l.current);if(!N)return;T.preventDefault(),T.stopPropagation(),o(N)}};return d.jsxs(d.Fragment,{children:[d.jsx("div",{ref:i,className:"document",tabIndex:-1,onClick:b,onKeyDown:_,children:d.jsx("div",{ref:l,className:"md md-preview",dangerouslySetInnerHTML:{__html:e}})}),m&&d.jsx(__,{root:i,body:l,seed:m.seed,seq:m.seq,onClose:w}),d.jsx(dU,{heads:c,at:p,onJump:y})]})}function dU({heads:e,at:t,onJump:n}){const[r,o]=S.useState(!1),i=S.useRef(null);return e.length<2?null:d.jsxs(d.Fragment,{children:[d.jsx("div",{ref:i,className:"document-outline","aria-hidden":!0,onPointerEnter:l=>{l.pointerType==="mouse"&&o(!0)},onClick:()=>o(l=>!l),children:e.map((l,c)=>d.jsx("span",{className:"document-outline-tick","data-level":l.level,"data-state":vr({current:c===t})},l.id))}),r&&d.jsx(Rs,{className:"document-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,c)=>d.jsx("button",{type:"button",className:"row document-outline-row","data-level":l.level,"data-state":vr({current:c===t}),onClick:()=>n(c),children:d.jsx("span",{className:"document-outline-label",style:{"--outline-depth":l.depth},children:l.text})},l.id))})]})}function fU({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:i,onChat:l}){it();const c=Dr(),u=ut(),p=O_(t),h=rh(e,{keepHtml:!0,base:r===void 0?void 0:{worktreeId:n,dir:p,version:r,urls:c}}),m=g=>{const w=Zk(p,g);w&&er({dispatch:u},{worktreeId:n,path:w,view:wi(w)})};return d.jsx($T,{html:h,openSeq:o,focus:i,onLink:m,onChat:l})}function hU({onReveal:e}){const{host:t}=Dr();return vS(t)?d.jsxs(Be,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:e,"data-tip":"Reveal in Finder: show the file where it sits on disk",children:[d.jsx(kt,{name:"folder",className:"icon-inline"})," reveal"]}):null}const pU=S.lazy(async()=>{const[e]=await Promise.all([Eg(()=>import("./Editor-BMBnZV2V.js").then(t=>t.E),__vite__mapDeps([0,1,2])),Eg(()=>import("./grammar-BlgE3B1J.js"),[]).then(t=>t.grammarsReady)]);return e});function Ux({what:e}){return oS(!0,3e3)?d.jsx("div",{className:"empty",children:d.jsxs("span",{className:"live-text",children:["loading ",e]})}):null}const mU=()=>{},gU={diff:"diff",file:"text",preview:"book"};function kU(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 RT({editor:e,height:t,full:n=!1,onToggleFull:r,onDragStart:o,placement:i="stack"}){const l=i==="screen",c=ut(),u=Yn(),p=it(),h=Dr(),m=yk(),g=Hf(),{worktreeId:w,path:y,ref:b,since:_}=e,T=e.loose,E=M(q=>{var z;return((z=Oo(q))==null?void 0:z.id)===w}),N=M(q=>{var te,Ee;const z=(te=dn(q,w))==null?void 0:te.worktree;return z?z.path:(Ee=Oo(q))==null?void 0:Ee.path}),j=b!==void 0,$=S.useMemo(()=>T?XB(T.source,y,q=>c({a:"editor-refused",file:{worktreeId:w,path:y},message:q}),VB(p?q=>p.send(q):null)):(m==null?void 0:m.bind({worktreeId:w,path:y,...b?{ref:b}:{},..._?{since:_}:{}}))??IT,[m,w,y,b,_,T,c,p]),P=M(q=>Ro(q,w).changedRanges[y]);S.useEffect(()=>{!P&&!j&&!E&&!T&&(p==null||p.send({t:"changed-ranges",worktreeId:w,path:y}))},[w,y,P,j,E,T,p]);const R=(P==null?void 0:P.offset)??0,A=e.disk,O=e.view??"diff",B=!!A&&(A.before===""||A.before===A.after),H=bS(y,B).filter(q=>q!==O&&!(T&&q==="diff")),Q=(T==null?void 0:T.source.kind)==="grant"?T.source:null,re=j||E||T&&!Q?null:KM(y),[J,ie]=S.useState(!1),[ve,C]=ko(qe.editorWrap,!1,q=>q===null?void 0:q==="1"),Z=!!A&&!re&&!A.binary&&!A.tooLarge&&O!=="preview",Y=e.line&&!e.line.fiber?e.line.n:void 0;return d.jsxs(_w,{kind:"editor",className:We("editor-pane",n&&"full"),height:n||l?void 0:t,resizable:!n&&!l,onDragStart:o??mU,title:j?`${y} at ${b==null?void 0:b.slice(0,7)}`:_?`${y}, last turn`:y,menu:()=>N&&!T?js({id:w,dir:N},y,{discard:!j&&!E,kept:E,ref:b,showing:e.view??void 0,noDiff:B},{sock:p,dispatch:c}):[],onClose:()=>c({a:"close-editor"}),full:n,onToggleFull:l?void 0:r,actions:d.jsxs(d.Fragment,{children:[!re&&H.map(q=>d.jsxs(Be,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>c({a:"editor-view",v:q}),"data-tip":kU(q,O),children:[d.jsx(kt,{name:gU[q],className:"icon-inline"})," ",q]},q)),re==="image"&&d.jsxs(Be,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>ie(!0),"data-tip":"Full size: see the picture over the window",children:[d.jsx(kt,{name:"zen",className:"icon-inline"})," full size"]}),Z&&d.jsxs(Be,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>C(!ve),"data-tip":ve?"Unwrap lines: one line per row, scroll sideways for the rest":"Wrap lines: fold a long line at the pane's edge",children:[d.jsx(kt,{name:"wrap",className:"icon-inline"})," ",ve?"unwrap":"wrap"]}),N&&!T&&d.jsx(eU,{path:`${N}/${y}`}),!E&&!T&&d.jsx(hU,{onReveal:()=>p==null?void 0:p.send({t:"reveal",worktreeId:w,path:y})})]}),children:[A&&d.jsx(wU,{editor:e,disk:A,files:m}),d.jsx("div",{className:"editor-body",children:A?re?d.jsx(rU,{kind:re,src:Q?h.loose(Q.id,Q.version):h.worktreeFile(w,y,A.version),path:y,openSeq:e.seq,focus:e.focus,full:J,onFull:ie}):A.binary?d.jsx("div",{className:"empty",children:"not a text file: open it in another editor"}):A.tooLarge?d.jsx("div",{className:"empty",children:"too large to open here: open it in another editor"}):O==="preview"&&zf(y)==="html"?d.jsx(iU,{text:A.after,path:y,worktreeId:w,version:j||E||T?void 0:A.version,openSeq:e.seq,focus:e.focus}):O==="preview"?d.jsx(fU,{text:A.after,path:y,worktreeId:w,version:j||E||T?void 0:A.version,openSeq:e.seq,focus:e.focus,onChat:q=>ib(u,{worktreeId:w,text:q,name:y})}):d.jsx(Ok,{pane:!0,children:d.jsx(S.Suspense,{fallback:d.jsx(Ux,{what:O}),children:d.jsx(pU,{file:{worktreeId:w,path:y,...b?{ref:b}:{},..._?{since:_}:{}},disk:A,blame:e.blame,view:O,openSeq:e.seq,line:Y,focus:e.focus,readOnly:j||!A.writable||l,numbers:!l,wrap:ve,theme:g,sync:$,onCopy:T?void 0:(q,z,te)=>d4(te,{worktreeId:w,path:q,...z,...b?{ref:b}:{}}),onChat:(q,z)=>ib(u,z&&(T?{worktreeId:w,text:z.text,name:q}:{worktreeId:w,text:z.text,source:{path:q,startLine:z.startLine,endLine:z.endLine,...b?{ref:b}:{}}})),onNew:()=>u.dispatch({a:"open-draft"}),onLineHover:j||T?void 0:q=>{q==null?an.post(w,{type:"highlight-clear"}):an.post(w,{type:"highlight-file",path:y,ranges:[[q+R,q+R]]})}},`${w}
|
|
247
|
+
${T?"loose":b??_??""}
|
|
248
|
+
${y}`)})}):d.jsx(Ux,{what:y},y)})]})}function wU({editor:e,disk:t,files:n}){const{worktreeId:r,path:o,ref:i,since:l,conflict:c}=e,u={worktreeId:r,path:o,...i?{ref:i}:{},...l?{since:l}:{}};if(c){const p=c.version===null;return d.jsxs("div",{className:"editor-note",children:[d.jsx("span",{className:"editor-note-text",children:p?"deleted on disk; your edits are not saved":"changed on disk; your edits are not saved"}),d.jsx(Be,{variant:"outline",onClick:()=>n==null?void 0:n.reload(u),"data-tip":p?"Close the file; your edits go with it":"Take the file as it is on disk; undo brings your edits back",children:p?"close":"reload"}),d.jsx(Be,{variant:"outline",tone:"danger",onClick:()=>n==null?void 0:n.keepMine(u),"data-tip":p?"Save your edits as the file again":"Save your edits over the file on disk",children:"keep mine"})]})}return e.refused?d.jsx("div",{className:"editor-note",children:d.jsx("span",{className:"hint",children:e.refused})}):e.loose&&!t.writable&&!t.tooLarge&&!t.binary?d.jsx("div",{className:"editor-note",children:d.jsxs("span",{className:"hint",children:["read-only: ",o," is not in a project; drop it on a folder in files to add it"]})}):i===void 0&&!t.writable&&!t.binary&&!t.tooLarge?d.jsx("div",{className:"editor-note",children:d.jsx("span",{className:"hint",children:"read-only: Toyon does not run this worktree"})}):null}function OT(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 yU=(e,t)=>{const n=Rm(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"}},xf="https://github.com/toyon-dev/toyon",vU=e=>`${xf}/releases/tag/v${e}`,bU=`${xf}/releases/latest`,xU=4e3;function EU(e,t,n,r){if(r==="asking")return{value:`${e} checking`,text:`Asking ${Rm(n)} for the newest version`,act:"check",busy:!0};const o=Rm(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(mE(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 SU(e,t,n,r,o,i=!1,l=null,c=null){if(n){if(n.restarting){const p=n.installed??n.running,h=n.restarting.length>0?GS(n.restarting):"Toyon is restarting; this page reloads when it is back";return{value:`${p} restarting`,text:h,act:"restart",busy:!0}}if(n.installing){const p=n.latest??n.installed??n.running;return{value:`${p} installing`,text:`Installing Toyon ${p}`,act:"update",busy:!0}}if(n.failed){const p=n.failed.line.replace(/\.$/,"");return{value:`${n.running} update failed`,text:`Installing Toyon ${n.failed.version} stopped: ${p}. Press to try again, or run ${n.failed.command}`,act:"update",busy:!1}}if(n.installed)return{value:`${n.installed} ready`,text:`Toyon ${n.installed} is installed and ${n.running} is still running. It restarts onto the new one when nothing is busy; press to restart now`,act:"restart",busy:!1};if(n.latest)return{value:`${n.latest} out`,text:n.method==="npx"?`Toyon ${n.latest} is out. This copy runs with npx, so run npx toyon@${n.latest} to use it`:`Toyon ${n.latest} is out and installs when nothing is busy; press to install now`,act:"update",busy:!1}}const u=OT(r,o,i);return u?u.busy?{value:`${e} rebuilding`,text:u.text,act:"rebuild",busy:!0}:u.reload?{value:`${e} rebuilt`,text:u.text,act:"reload",busy:!1}:u.build==="try again"?{value:`${e} rebuild stopped`,text:u.text,detail:u.detail,act:"rebuild",busy:!1}:{value:`${e} behind`,text:u.text,act:u.build?"rebuild":"restart",busy:!1}:c?EU(e,t,l,c):{value:e,text:`Toyon ${e}, ${yU(t,l)}`,act:"check",busy:!1}}function _U(e,t,n){const r=o=>()=>window.open(o,"_blank");return zn([t?[{id:"check-update",label:"check for updates",...t.off?{disabled:t.off}:{},onClick:t.run}]:[],[n?{id:"release-notes",label:"release notes",onClick:n}:{id:"release-notes",label:`release notes for ${e}`,onClick:r(vU(e))},{id:"latest-release",label:"latest release",onClick:r(bU)},{id:"repo",label:"Toyon on GitHub",onClick:r(xf)},{id:"report",label:"report a problem",onClick:r(`${xf}/issues/new`)}],[{id:"copy-version",label:"copy version",onClick:()=>en(e)}]])}const NU=DC.map(e=>({title:e,rows:BC(e).map(t=>[Dt(t),Sc[t].label])}));function TU(){const e=ut(),t=it(),n=vn("keys"),r=M(m=>m.themePrefs),o=M(m=>m.themes),i=M(m=>m.chatSide),l=M(m=>m.keepAwake),c=wk(),u=M(m=>m.agents),p=Nl(),h=m=>{e({a:"palette-return",v:{mode:"keys",q:""}}),e(m)};return d.jsxs(Gc,{bare:!0,boxClass:"keys-stack",id:"keys-help",onClose:()=>e({a:"close"}),children:[d.jsxs("div",{className:"keys-card",children:[d.jsxs("div",{children:[p&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"section-title keys-h",children:p.name}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"processes"}),d.jsx(Be,{variant:"field",mono:!0,className:"keys-chip","data-tip":`edit the install + start commands in ${p.configFile}`,onClick:()=>e({a:"open",overlay:{kind:"setup",repoId:p.id}}),...n.contextMenu(()=>sh(p,p.id,{sock:t,dispatch:e})),children:d.jsx("span",{className:"keys-v",children:Object.keys(p.config.run).join(" + ")||"not set up"})})]})]}),d.jsx("div",{className:"section-title keys-h",children:"Agents"}),u.map(m=>d.jsx(AU,{agent:m},m.id))]}),d.jsxs("div",{children:[d.jsx("div",{className:"section-title keys-h",children:"Appearance"}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"mode"}),d.jsx(Be,{variant:"field",mono:!0,onClick:()=>h({a:"open",overlay:{kind:"appearance"}}),children:pf[r.mode]})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"theme"}),d.jsx(Be,{variant:"field",mono:!0,onClick:()=>h({a:"open",overlay:{kind:"theme",slot:"theme"}}),children:Df(r,o,c).name})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"chat side"}),d.jsx(Be,{variant:"field",mono:!0,onClick:()=>e({a:"toggle-chat-side"}),children:i})]}),d.jsx("div",{className:"section-title keys-h",children:"Toyon"}),l!==null&&d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"keep awake"}),d.jsx(Be,{variant:"field",mono:!0,onClick:()=>h({a:"open",overlay:{kind:"keep-awake"}}),children:mf[l]})]}),d.jsx(jU,{}),d.jsx(CU,{})]})]}),d.jsx("div",{className:"keys-card",children:NU.map(m=>d.jsxs("div",{children:[d.jsx("div",{className:"section-title keys-h",children:m.title}),m.rows.map(([g,w])=>d.jsxs("div",{className:"keys-row",children:[d.jsx(Vo,{k:g}),d.jsx("span",{className:"keys-d",children:w})]},g))]},m.title))})]})}function jU(){const e=it(),t=ut(),n=vn("keys"),r=M(N=>N.version),o=M(N=>N.install),i=M(N=>N.registry),l=M(N=>N.update),c=M(N=>N.self),u=M(N=>N.rebuilt),p=M(N=>N.repos),h=M(N=>N.managed.updates),m=M(N=>N.updateCheck),g=M(N=>N.frame),w=M(N=>N.newProject!==null),y=SU(r,o,l,c,p,u,i,m),b=!h&&(y.act==="update"||y.act==="check"),_=y.settles&&m&&m!=="asking"?m:null;S.useEffect(()=>{if(!_)return;const N=()=>t({a:"update-check-settle",check:_}),j=setTimeout(N,xU);return()=>{clearTimeout(j),N()}},[_,t]);const T=()=>{y.act==="restart"?e==null||e.send({t:"restart-daemon"}):y.act==="reload"?window.location.reload():y.act==="rebuild"&&c?e==null||e.send({t:"run-after-land",repoId:c.repoId}):y.act==="update"?e==null||e.send({t:"update-now"}):y.act==="check"&&e&&(t({a:"update-check"}),e.send({t:"check-update"}))},E=()=>_U(r,y.act==="check"&&!y.busy?{run:T,...b?{off:"managed by your organization"}:{}}:null,g==="phone"||w?void 0:()=>t({a:"open-release-notes"}));return d.jsxs("div",{className:"keys-setting",...n.contextMenu(E),children:[d.jsx("span",{className:"keys-d",children:"version"}),d.jsx(Be,{variant:"field",mono:!0,busy:y.busy,disabled:b,onClick:T,...Ut(b?"updates are managed by your organization":y.text,void 0,{detail:y.detail}),children:y.value})]})}function CU(){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: ${O2(e).join(", ")||"nothing turned off"}`;return d.jsx("div",{className:"hint",children:t})}function MT(e){return e.available?e.auth?e.auth.kind==="none"?"not logged in":e.auth.label:e.checkFailed?"not ready":"ready":e.installing?"installing":"not installed"}function PT(e){var n,r;return e.available?e.checkFailed?e.checkFailed:e.auth?[e.auth.detail,(n=e.auth.account)==null?void 0:n.email,(r=e.auth.account)==null?void 0:r.organization].filter(Boolean).join(" · ")||e.auth.label:"installed; it names the account it runs on the first time it runs":ih(e)}function AU({agent:e}){const t=ut(),n=it(),r=vn("keys");return d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:e.name}),d.jsx(Be,{variant:"field",mono:!0,"data-tip":PT(e),...r.contextMenu(()=>ww(e,{sock:n})),onClick:()=>{t({a:"palette-return",v:{mode:"keys",q:""}}),t({a:"open",overlay:{kind:"agent-page",agent:e.id}})},children:MT(e)})]})}function IU({agentId:e}){const t=ut(),n=it(),r=Nl(),o=M(g=>g.home),i=M(g=>g.agents.find(w=>w.id===e)??null),l=M(g=>g.agentConfigs[e]??null),c=vn("keys");if(S.useEffect(()=>{n==null||n.send({t:"agent-config",agent:e,...r?{repoId:r.id}:{}})},[n,e,r]),CT(n,e,i??void 0),!i)return null;const u=ww(i,{sock:n}),p=()=>t({a:"close",back:!0}),h=g=>o&&g.startsWith(`${o}/`)?`~${g.slice(o.length)}`:g,m=g=>n==null?void 0:n.send({t:"reveal-agent-file",agent:e,file:g.id,...r?{repoId:r.id}:{}});return d.jsx(Gc,{bare:!0,boxClass:"keys-stack",onClose:p,children:d.jsxs("div",{className:"keys-card keys-settings",children:[d.jsx("div",{className:"agent-page-back",children:d.jsx(Ot,{icon:"back",label:"back to settings",hint:"esc",onClick:p})}),d.jsx("div",{className:"section-title keys-h",children:i.name}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"signed in"}),d.jsx(Be,{variant:"field",mono:!0,"data-tip":PT(i),disabled:u.length===0,...c.dropdown(()=>u,"right"),children:MT(i)})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"commit messages"}),d.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"})]}),d.jsx("div",{className:"section-title keys-h",children:"MCP servers it will load"}),l===null?d.jsx("div",{className:"keys-setting",children:d.jsx("span",{className:"keys-d live-text",children:"reading"})}):l.servers.length===0?d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"none configured"}),d.jsx("span",{className:"keys-d",children:"add one with the agent's own CLI, or a .mcp.json in the repo"})]}):l.servers.map(g=>d.jsx($U,{s:g},`${g.scope}:${g.name}`)),l&&l.files.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"section-title keys-h",children:"the files it reads"}),l.files.map(g=>d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:g.label}),g.exists?d.jsx(Be,{variant:"field",mono:!0,"data-tip":`reveal ${h(g.path)} in Finder`,onClick:()=>m(g),children:h(g.path)}):d.jsxs("span",{className:"keys-d",children:["not present: ",h(g.path)]})]},g.id))]})]})})}function $U({s:e}){return d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{children:e.name}),d.jsx("span",{className:"keys-d",children:e.detail?`${e.scope} · ${e.detail}`:e.scope})]})}function RU(){const e=ut(),t=it(),n=M(o=>o.agents),r=M(o=>o.defaultAgent);return d.jsx(Lr,{items:n,filter:(o,i)=>o.filter(l=>is(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=>ww(o,{sock:t}),placeholder:"default agent for new worktrees",keys:{pick:"sets",back:"closes"},row:o=>d.jsx(An,{label:o.name,current:o.id===r,hint:o.available?o.checkFailed??(o.sandboxed?void 0:"unsandboxed"):ih(o)})})}const OU=["dark","light","system","daylight"],MU=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"});function PU(){const e=ut(),t=it(),n=M(u=>u.themePrefs),r=M(u=>u.themes),o=wk(),i=M(u=>u.daylight),l=u=>{var p;return((p=r.find(h=>h.id===n[Xg({...n,mode:u},o)]))==null?void 0:p.name)??""},c=u=>{if(u==="system")return`${o.system?"dark":"light"} now · ${l(u)}`;if(u!=="daylight")return l(u);const p=i&&i.until>Date.now()?` · ${o.daylight?"light":"dark"} at ${MU.format(i.until)}`:"";return`${o.daylight?"dark":"light"} now${p} · ${l(u)}`};return d.jsx(Lr,{items:OU,filter:(u,p)=>u.filter(h=>is(p,pf[h])),rowClass:()=>"picker-row",keyOf:u=>u,initialIndex:u=>u.indexOf(n.mode),onActive:u=>e({a:"preview-theme",theme:u?Df({...n,mode:u},r,o):null}),onPick:u=>{t==null||t.send({t:"set-theme",prefs:{...n,mode:u}}),e({a:"close"})},onBack:()=>e({a:"close",back:!0}),placeholder:"light/dark mode",keys:{nav:"preview",pick:"keeps",back:"reverts"},row:u=>d.jsx(An,{label:pf[u],current:u===n.mode,hint:c(u)})})}const LU=2,_g=e=>cE(e).join(" ").length<LU,DU=e=>({kind:"chat",id:e.id,name:e.name,hint:e.branch??"",fields:[e.name,e.branch??""]}),zU=e=>({kind:"chat",id:e.id,name:e.title,hint:y_(e),fields:[e.title,e.branch],prompt:e.prompt,archived:e});function FU(e,t,n){const r=cE(t),o=n==="all"&&!_g(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(c=>l.some(u=>u.toLowerCase().includes(c)))})}const BU=e=>e.flatMap(([t,n])=>Array.from({length:n},(r,o)=>t+o));function UU({repoId:e,scope:t}){const n=ut(),r=it(),o=M(j=>j.clientId),i=M(j=>j.frame),l=M(j=>j.chats[e]),c=Ek(),u=M(j=>j.archived[e]),[p,h]=S.useState(t),m=S.useCallback(()=>h(j=>j==="all"?"names":"all"),[]);S.useEffect(()=>{r==null||r.send({t:"list-archived",repoId:e})},[r,e]);const g=S.useMemo(()=>[...c.filter(j=>!wr(j.worktree)).map(DU),...(u??[]).map(zU)],[c,u]),w=S.useMemo(()=>new Map(g.map(j=>[j.id,j])),[g]),y=S.useMemo(()=>[...g,...((l==null?void 0:l.hits)??[]).map(j=>({kind:"hit",hit:j}))],[g,l]),b=S.useMemo(()=>{const j=new Map;for(const $ of(l==null?void 0:l.hits)??[])j.set($.worktreeId,Math.max(j.get($.worktreeId)??0,$.ts));return j},[l]),_=S.useCallback((j,$)=>FU(j,$,p),[p]),T=S.useCallback(j=>{p==="all"&&!_g(j)&&(r==null||r.send({t:"search-chats",repoId:e,query:j.trim()}))},[r,e,p]),E=j=>!l||l.query!==j.trim(),N=j=>p==="all"&&!_g(j);return d.jsx(Lr,{items:y,filter:_,onQuery:T,onTab:m,trailing:d.jsx(Be,{tone:"chrome",on:p==="names","aria-pressed":p==="names",onClick:m,children:"names only"}),keyOf:j=>j.kind==="hit"?`h:${j.hit.worktreeId}:${j.hit.seq}`:`w:${j.id}`,rowClass:j=>j.kind==="hit"?"chats-hit":We("picker-row",j.archived&&!j.archived.restorable&&"dim"),rowTitle:j=>{var $;return j.kind==="hit"?j.hit.text:(($=j.archived)==null?void 0:$.prompt)??j.name},groupOf:j=>j.kind==="hit"?`h:${j.hit.worktreeId}`:j.archived?"archived":"open",groupHead:(j,$)=>{if(!j.startsWith("h:"))return`${j} · ${$}`;const P=j.slice(2),R=w.get(P),A=l==null?void 0:l.asks[P],O=b.get(P)??0;return d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"chats-name",children:[(R==null?void 0:R.name)??"a worktree",(R==null?void 0:R.archived)&&d.jsxs(d.Fragment,{children:[" ",d.jsx("span",{className:"row-dim",children:"archived"})]})]}),O>0&&d.jsx("span",{className:"picker-group-tail",children:yr(O)}),A&&d.jsx("span",{className:"picker-group-line",children:eh(A,s_*2)})]})},headAlone:!0,onPick:j=>{const $=j.kind==="hit"?j.hit.worktreeId:j.id,P=j.kind==="hit"?j.hit.archived:!!j.archived;n(P?{a:"open-archived",id:$}:{a:"activate",id:$}),j.kind==="hit"&&n({a:"reveal",id:$,seq:j.hit.seq}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:j=>j.kind==="chat"&&j.archived?Kd(j.archived,{clientId:o,frame:i},{sock:r,dispatch:n}):[],placeholder:p==="names"?"find a chat by name…":"search in chats…",keys:j=>({nav:"moves",tab:p==="names"?"searches messages too":"searches names only",pick:j?j.kind==="hit"?"opens the chat there":"opens its chat":void 0,back:"closes"}),empty:j=>j.trim()?N(j)?E(j)?d.jsx("span",{className:"live-text",children:"searching"}):"no chat says that":"no chat is named that":u?"no chats yet":d.jsx("span",{className:"live-text",children:"looking"}),footer:(j,$)=>{const P=$.filter(R=>R.kind==="hit").length;return l!=null&&l.truncated&&!E(j)&&P>0?d.jsxs("div",{className:"empty",children:["showing the first ",P,"; narrow the search"]}):null},row:j=>j.kind==="chat"?d.jsx(An,{label:j.name,hint:j.hint}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"chats-text",children:Vc(j.hit.text,BU(j.hit.match),0)}),d.jsxs("span",{className:"chats-said row-dim",children:[j.hit.role==="user"?"you":"the agent",j.hit.ts>0&&yr(j.hit.ts)!==yr(b.get(j.hit.worktreeId)??0)?` · ${yr(j.hit.ts)}`:""]})]})})}const jl=function(e,t){let o=e;const i=xc[t];let l=null,c=0,u=null;const p=[],h={},m=function(R,A){c=o*4+17,l=(function(O){const B=new Array(O);for(let H=0;H<O;H+=1){B[H]=new Array(O);for(let Q=0;Q<O;Q+=1)B[H][Q]=null}return B})(c),g(0,0),g(c-7,0),g(0,c-7),b(),y(),T(R,A),o>=7&&_(R),u==null&&(u=j(o,i,p)),E(u,A)},g=function(R,A){for(let O=-1;O<=7;O+=1)if(!(R+O<=-1||c<=R+O))for(let B=-1;B<=7;B+=1)A+B<=-1||c<=A+B||(0<=O&&O<=6&&(B==0||B==6)||0<=B&&B<=6&&(O==0||O==6)||2<=O&&O<=4&&2<=B&&B<=4?l[R+O][A+B]=!0:l[R+O][A+B]=!1)},w=function(){let R=0,A=0;for(let O=0;O<8;O+=1){m(!0,O);const B=li.getLostPoint(h);(O==0||R>B)&&(R=B,A=O)}return A},y=function(){for(let R=8;R<c-8;R+=1)l[R][6]==null&&(l[R][6]=R%2==0);for(let R=8;R<c-8;R+=1)l[6][R]==null&&(l[6][R]=R%2==0)},b=function(){const R=li.getPatternPosition(o);for(let A=0;A<R.length;A+=1)for(let O=0;O<R.length;O+=1){const B=R[A],H=R[O];if(l[B][H]==null)for(let Q=-2;Q<=2;Q+=1)for(let re=-2;re<=2;re+=1)Q==-2||Q==2||re==-2||re==2||Q==0&&re==0?l[B+Q][H+re]=!0:l[B+Q][H+re]=!1}},_=function(R){const A=li.getBCHTypeNumber(o);for(let O=0;O<18;O+=1){const B=!R&&(A>>O&1)==1;l[Math.floor(O/3)][O%3+c-8-3]=B}for(let O=0;O<18;O+=1){const B=!R&&(A>>O&1)==1;l[O%3+c-8-3][Math.floor(O/3)]=B}},T=function(R,A){const O=i<<3|A,B=li.getBCHTypeInfo(O);for(let H=0;H<15;H+=1){const Q=!R&&(B>>H&1)==1;H<6?l[H][8]=Q:H<8?l[H+1][8]=Q:l[c-15+H][8]=Q}for(let H=0;H<15;H+=1){const Q=!R&&(B>>H&1)==1;H<8?l[8][c-H-1]=Q:H<9?l[8][15-H-1+1]=Q:l[8][15-H-1]=Q}l[c-8][8]=!R},E=function(R,A){let O=-1,B=c-1,H=7,Q=0;const re=li.getMaskFunction(A);for(let J=c-1;J>0;J-=2)for(J==6&&(J-=1);;){for(let ie=0;ie<2;ie+=1)if(l[B][J-ie]==null){let ve=!1;Q<R.length&&(ve=(R[Q]>>>H&1)==1),re(B,J-ie)&&(ve=!ve),l[B][J-ie]=ve,H-=1,H==-1&&(Q+=1,H=7)}if(B+=O,B<0||c<=B){B-=O,O=-O;break}}},N=function(R,A){let O=0,B=0,H=0;const Q=new Array(A.length),re=new Array(A.length);for(let C=0;C<A.length;C+=1){const Z=A[C].dataCount,Y=A[C].totalCount-Z;B=Math.max(B,Z),H=Math.max(H,Y),Q[C]=new Array(Z);for(let Ee=0;Ee<Q[C].length;Ee+=1)Q[C][Ee]=255&R.getBuffer()[Ee+O];O+=Z;const q=li.getErrorCorrectPolynomial(Y),te=Yc(Q[C],q.getLength()-1).mod(q);re[C]=new Array(q.getLength()-1);for(let Ee=0;Ee<re[C].length;Ee+=1){const Ne=Ee+te.getLength()-re[C].length;re[C][Ee]=Ne>=0?te.getAt(Ne):0}}let J=0;for(let C=0;C<A.length;C+=1)J+=A[C].totalCount;const ie=new Array(J);let ve=0;for(let C=0;C<B;C+=1)for(let Z=0;Z<A.length;Z+=1)C<Q[Z].length&&(ie[ve]=Q[Z][C],ve+=1);for(let C=0;C<H;C+=1)for(let Z=0;Z<A.length;Z+=1)C<re[Z].length&&(ie[ve]=re[Z][C],ve+=1);return ie},j=function(R,A,O){const B=Hx.getRSBlocks(R,A),H=Wx();for(let re=0;re<O.length;re+=1){const J=O[re];H.put(J.getMode(),4),H.put(J.getLength(),li.getLengthInBits(J.getMode(),R)),J.write(H)}let Q=0;for(let re=0;re<B.length;re+=1)Q+=B[re].dataCount;if(H.getLengthInBits()>Q*8)throw"code length overflow. ("+H.getLengthInBits()+">"+Q*8+")";for(H.getLengthInBits()+4<=Q*8&&H.put(0,4);H.getLengthInBits()%8!=0;)H.putBit(!1);for(;!(H.getLengthInBits()>=Q*8||(H.put(236,8),H.getLengthInBits()>=Q*8));)H.put(17,8);return N(H,B)};h.addData=function(R,A){A=A||"Byte";let O=null;switch(A){case"Numeric":O=HU(R);break;case"Alphanumeric":O=WU(R);break;case"Byte":O=KU(R);break;case"Kanji":O=ZU(R);break;default:throw"mode:"+A}p.push(O),u=null},h.isDark=function(R,A){if(R<0||c<=R||A<0||c<=A)throw R+","+A;return l[R][A]},h.getModuleCount=function(){return c},h.make=function(){if(o<1){let R=1;for(;R<40;R++){const A=Hx.getRSBlocks(R,i),O=Wx();for(let H=0;H<p.length;H++){const Q=p[H];O.put(Q.getMode(),4),O.put(Q.getLength(),li.getLengthInBits(Q.getMode(),R)),Q.write(O)}let B=0;for(let H=0;H<A.length;H++)B+=A[H].dataCount;if(O.getLengthInBits()<=B*8)break}o=R}m(!1,w())},h.createTableTag=function(R,A){R=R||2,A=typeof A>"u"?R*4:A;let O="";O+='<table style="',O+=" border-width: 0px; border-style: none;",O+=" border-collapse: collapse;",O+=" padding: 0px; margin: "+A+"px;",O+='">',O+="<tbody>";for(let B=0;B<h.getModuleCount();B+=1){O+="<tr>";for(let H=0;H<h.getModuleCount();H+=1)O+='<td style="',O+=" border-width: 0px; border-style: none;",O+=" border-collapse: collapse;",O+=" padding: 0px; margin: 0px;",O+=" width: "+R+"px;",O+=" height: "+R+"px;",O+=" background-color: ",O+=h.isDark(B,H)?"#000000":"#ffffff",O+=";",O+='"/>';O+="</tr>"}return O+="</tbody>",O+="</table>",O},h.createSvgTag=function(R,A,O,B){let H={};typeof arguments[0]=="object"&&(H=arguments[0],R=H.cellSize,A=H.margin,O=H.alt,B=H.title),R=R||2,A=typeof A>"u"?R*4:A,O=typeof O=="string"?{text:O}:O||{},O.text=O.text||null,O.id=O.text?O.id||"qrcode-description":null,B=typeof B=="string"?{text:B}:B||{},B.text=B.text||null,B.id=B.text?B.id||"qrcode-title":null;const Q=h.getModuleCount()*R+A*2;let re,J,ie,ve,C="",Z;for(Z="l"+R+",0 0,"+R+" -"+R+",0 0,-"+R+"z ",C+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',C+=H.scalable?"":' width="'+Q+'px" height="'+Q+'px"',C+=' viewBox="0 0 '+Q+" "+Q+'" ',C+=' preserveAspectRatio="xMinYMin meet"',C+=B.text||O.text?' role="img" aria-labelledby="'+$([B.id,O.id].join(" ").trim())+'"':"",C+=">",C+=B.text?'<title id="'+$(B.id)+'">'+$(B.text)+"</title>":"",C+=O.text?'<description id="'+$(O.id)+'">'+$(O.text)+"</description>":"",C+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',C+='<path d="',ie=0;ie<h.getModuleCount();ie+=1)for(ve=ie*R+A,re=0;re<h.getModuleCount();re+=1)h.isDark(ie,re)&&(J=re*R+A,C+="M"+J+","+ve+Z);return C+='" stroke="transparent" fill="black"/>',C+="</svg>",C},h.createDataURL=function(R,A){R=R||2,A=typeof A>"u"?R*4:A;const O=h.getModuleCount()*R+A*2,B=A,H=O-A;return YU(O,O,function(Q,re){if(B<=Q&&Q<H&&B<=re&&re<H){const J=Math.floor((Q-B)/R),ie=Math.floor((re-B)/R);return h.isDark(ie,J)?0:1}else return 1})},h.createImgTag=function(R,A,O){R=R||2,A=typeof A>"u"?R*4:A;const B=h.getModuleCount()*R+A*2;let H="";return H+="<img",H+=' src="',H+=h.createDataURL(R,A),H+='"',H+=' width="',H+=B,H+='"',H+=' height="',H+=B,H+='"',O&&(H+=' alt="',H+=$(O),H+='"'),H+="/>",H};const $=function(R){let A="";for(let O=0;O<R.length;O+=1){const B=R.charAt(O);switch(B){case"<":A+="<";break;case">":A+=">";break;case"&":A+="&";break;case'"':A+=""";break;default:A+=B;break}}return A},P=function(R){R=typeof R>"u"?2:R;const O=h.getModuleCount()*1+R*2,B=R,H=O-R;let Q,re,J,ie,ve;const C={"██":"█","█ ":"▀"," █":"▄"," ":" "},Z={"██":"▀","█ ":"▀"," █":" "," ":" "};let Y="";for(Q=0;Q<O;Q+=2){for(J=Math.floor((Q-B)/1),ie=Math.floor((Q+1-B)/1),re=0;re<O;re+=1)ve="█",B<=re&&re<H&&B<=Q&&Q<H&&h.isDark(J,Math.floor((re-B)/1))&&(ve=" "),B<=re&&re<H&&B<=Q+1&&Q+1<H&&h.isDark(ie,Math.floor((re-B)/1))?ve+=" ":ve+="█",Y+=R<1&&Q+1>=H?Z[ve]:C[ve];Y+=`
|
|
249
|
+
`}return O%2&&R>0?Y.substring(0,Y.length-O-1)+Array(O+1).join("▀"):Y.substring(0,Y.length-1)};return h.createASCII=function(R,A){if(R=R||1,R<2)return P(A);R-=1,A=typeof A>"u"?R*2:A;const O=h.getModuleCount()*R+A*2,B=A,H=O-A;let Q,re,J,ie;const ve=Array(R+1).join("██"),C=Array(R+1).join(" ");let Z="",Y="";for(Q=0;Q<O;Q+=1){for(J=Math.floor((Q-B)/R),Y="",re=0;re<O;re+=1)ie=1,B<=re&&re<H&&B<=Q&&Q<H&&h.isDark(J,Math.floor((re-B)/R))&&(ie=0),Y+=ie?ve:C;for(J=0;J<R;J+=1)Z+=Y+`
|
|
250
|
+
`}return Z.substring(0,Z.length-1)},h.renderTo2dContext=function(R,A){A=A||2;const O=h.getModuleCount();for(let B=0;B<O;B++)for(let H=0;H<O;H++)R.fillStyle=h.isDark(B,H)?"black":"white",R.fillRect(H*A,B*A,A,A)},h};jl.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};jl.createStringToBytes=function(e,t){const n=(function(){const o=GU(e),i=function(){const u=o.read();if(u==-1)throw"eof";return u};let l=0;const c={};for(;;){const u=o.read();if(u==-1)break;const p=i(),h=i(),m=i(),g=String.fromCharCode(u<<8|p),w=h<<8|m;c[g]=w,l+=1}if(l!=t)throw l+" != "+t;return c})(),r=63;return function(o){const i=[];for(let l=0;l<o.length;l+=1){const c=o.charCodeAt(l);if(c<128)i.push(c);else{const u=n[o.charAt(l)];typeof u=="number"?(u&255)==u?i.push(u):(i.push(u>>>8),i.push(u&255)):i.push(r)}}return i}};const Mr={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},xc={L:1,M:0,Q:3,H:2},ai={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},li=(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 c=0;for(;l!=0;)c+=1,l>>>=1;return c};return o.getBCHTypeInfo=function(l){let c=l<<10;for(;i(c)-i(t)>=0;)c^=t<<i(c)-i(t);return(l<<10|c)^r},o.getBCHTypeNumber=function(l){let c=l<<12;for(;i(c)-i(n)>=0;)c^=n<<i(c)-i(n);return l<<12|c},o.getPatternPosition=function(l){return e[l-1]},o.getMaskFunction=function(l){switch(l){case ai.PATTERN000:return function(c,u){return(c+u)%2==0};case ai.PATTERN001:return function(c,u){return c%2==0};case ai.PATTERN010:return function(c,u){return u%3==0};case ai.PATTERN011:return function(c,u){return(c+u)%3==0};case ai.PATTERN100:return function(c,u){return(Math.floor(c/2)+Math.floor(u/3))%2==0};case ai.PATTERN101:return function(c,u){return c*u%2+c*u%3==0};case ai.PATTERN110:return function(c,u){return(c*u%2+c*u%3)%2==0};case ai.PATTERN111:return function(c,u){return(c*u%3+(c+u)%2)%2==0};default:throw"bad maskPattern:"+l}},o.getErrorCorrectPolynomial=function(l){let c=Yc([1],0);for(let u=0;u<l;u+=1)c=c.multiply(Yc([1,ui.gexp(u)],0));return c},o.getLengthInBits=function(l,c){if(1<=c&&c<10)switch(l){case Mr.MODE_NUMBER:return 10;case Mr.MODE_ALPHA_NUM:return 9;case Mr.MODE_8BIT_BYTE:return 8;case Mr.MODE_KANJI:return 8;default:throw"mode:"+l}else if(c<27)switch(l){case Mr.MODE_NUMBER:return 12;case Mr.MODE_ALPHA_NUM:return 11;case Mr.MODE_8BIT_BYTE:return 16;case Mr.MODE_KANJI:return 10;default:throw"mode:"+l}else if(c<41)switch(l){case Mr.MODE_NUMBER:return 14;case Mr.MODE_ALPHA_NUM:return 13;case Mr.MODE_8BIT_BYTE:return 16;case Mr.MODE_KANJI:return 12;default:throw"mode:"+l}else throw"type:"+c},o.getLostPoint=function(l){const c=l.getModuleCount();let u=0;for(let m=0;m<c;m+=1)for(let g=0;g<c;g+=1){let w=0;const y=l.isDark(m,g);for(let b=-1;b<=1;b+=1)if(!(m+b<0||c<=m+b))for(let _=-1;_<=1;_+=1)g+_<0||c<=g+_||b==0&&_==0||y==l.isDark(m+b,g+_)&&(w+=1);w>5&&(u+=3+w-5)}for(let m=0;m<c-1;m+=1)for(let g=0;g<c-1;g+=1){let w=0;l.isDark(m,g)&&(w+=1),l.isDark(m+1,g)&&(w+=1),l.isDark(m,g+1)&&(w+=1),l.isDark(m+1,g+1)&&(w+=1),(w==0||w==4)&&(u+=3)}for(let m=0;m<c;m+=1)for(let g=0;g<c-6;g+=1)l.isDark(m,g)&&!l.isDark(m,g+1)&&l.isDark(m,g+2)&&l.isDark(m,g+3)&&l.isDark(m,g+4)&&!l.isDark(m,g+5)&&l.isDark(m,g+6)&&(u+=40);for(let m=0;m<c;m+=1)for(let g=0;g<c-6;g+=1)l.isDark(g,m)&&!l.isDark(g+1,m)&&l.isDark(g+2,m)&&l.isDark(g+3,m)&&l.isDark(g+4,m)&&!l.isDark(g+5,m)&&l.isDark(g+6,m)&&(u+=40);let p=0;for(let m=0;m<c;m+=1)for(let g=0;g<c;g+=1)l.isDark(g,m)&&(p+=1);const h=Math.abs(100*p/c/c-50)/5;return u+=h*10,u},o})(),ui=(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})(),Yc=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 c=0;c<o.getLength();c+=1)i[l+c]^=ui.gexp(ui.glog(r.getAt(l))+ui.glog(o.getAt(c)));return Yc(i,0)},r.mod=function(o){if(r.getLength()-o.getLength()<0)return r;const i=ui.glog(r.getAt(0))-ui.glog(o.getAt(0)),l=new Array(r.getLength());for(let c=0;c<r.getLength();c+=1)l[c]=r.getAt(c);for(let c=0;c<o.getLength();c+=1)l[c]^=ui.gexp(ui.glog(o.getAt(c))+i);return Yc(l,0).mod(o)},r},Hx=(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 xc.L:return e[(o-1)*4+0];case xc.M:return e[(o-1)*4+1];case xc.Q:return e[(o-1)*4+2];case xc.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 c=l.length/3,u=[];for(let p=0;p<c;p+=1){const h=l[p*3+0],m=l[p*3+1],g=l[p*3+2];for(let w=0;w<h;w+=1)u.push(t(m,g))}return u},n})(),Wx=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},HU=function(e){const t=Mr.MODE_NUMBER,n=e,r={};r.getMode=function(){return t},r.getLength=function(l){return n.length},r.write=function(l){const c=n;let u=0;for(;u+2<c.length;)l.put(o(c.substring(u,u+3)),10),u+=3;u<c.length&&(c.length-u==1?l.put(o(c.substring(u,u+1)),4):c.length-u==2&&l.put(o(c.substring(u,u+2)),7))};const o=function(l){let c=0;for(let u=0;u<l.length;u+=1)c=c*10+i(l.charAt(u));return c},i=function(l){if("0"<=l&&l<="9")return l.charCodeAt(0)-48;throw"illegal char :"+l};return r},WU=function(e){const t=Mr.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 c=0;for(;c+1<l.length;)i.put(o(l.charAt(c))*45+o(l.charAt(c+1)),11),c+=2;c<l.length&&i.put(o(l.charAt(c)),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},KU=function(e){const t=Mr.MODE_8BIT_BYTE,n=jl.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},ZU=function(e){const t=Mr.MODE_KANJI,n=jl.stringToBytes;(function(i,l){const c=n(i);if(c.length!=2||(c[0]<<8|c[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 c=0;for(;c+1<l.length;){let u=(255&l[c])<<8|255&l[c+1];if(33088<=u&&u<=40956)u-=33088;else if(57408<=u&&u<=60351)u-=49472;else throw"illegal char at "+(c+1)+"/"+u;u=(u>>>8&255)*192+(u&255),i.put(u,13),c+=2}if(c<l.length)throw"illegal char at "+(c+1)},o},LT=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},qU=function(){let e=0,t=0,n=0,r="";const o={},i=function(c){r+=String.fromCharCode(l(c&63))},l=function(c){if(c<0)throw"n:"+c;if(c<26)return 65+c;if(c<52)return 97+(c-26);if(c<62)return 48+(c-52);if(c==62)return 43;if(c==63)return 47;throw"n:"+c};return o.writeByte=function(c){for(e=e<<8|c&255,t+=8,n+=1;t>=6;)i(e>>>t-6),t-=6},o.flush=function(){if(t>0&&(i(e<<6-t),e=0,t=0),n%3!=0){const c=3-n%3;for(let u=0;u<c;u+=1)r+="="}},o.toString=function(){return r},o},GU=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 u=t.charAt(n);if(n+=1,u=="=")return o=0,-1;if(u.match(/^\s$/))continue;r=r<<6|l(u.charCodeAt(0)),o+=6}const c=r>>>o-8&255;return o-=8,c};const l=function(c){if(65<=c&&c<=90)return c-65;if(97<=c&&c<=122)return c-97+26;if(48<=c&&c<=57)return c-48+52;if(c==43)return 62;if(c==47)return 63;throw"c:"+c};return i},VU=function(e,t){const n=e,r=t,o=new Array(e*t),i={};i.setPixel=function(p,h,m){o[h*n+p]=m},i.write=function(p){p.writeString("GIF87a"),p.writeShort(n),p.writeShort(r),p.writeByte(128),p.writeByte(0),p.writeByte(0),p.writeByte(0),p.writeByte(0),p.writeByte(0),p.writeByte(255),p.writeByte(255),p.writeByte(255),p.writeString(","),p.writeShort(0),p.writeShort(0),p.writeShort(n),p.writeShort(r),p.writeByte(0);const h=2,m=c(h);p.writeByte(h);let g=0;for(;m.length-g>255;)p.writeByte(255),p.writeBytes(m,g,255),g+=255;p.writeByte(m.length-g),p.writeBytes(m,g,m.length-g),p.writeByte(0),p.writeString(";")};const l=function(p){const h=p;let m=0,g=0;const w={};return w.write=function(y,b){if(y>>>b)throw"length over";for(;m+b>=8;)h.writeByte(255&(y<<m|g)),b-=8-m,y>>>=8-m,g=0,m=0;g=y<<m|g,m=m+b},w.flush=function(){m>0&&h.writeByte(g)},w},c=function(p){const h=1<<p,m=(1<<p)+1;let g=p+1;const w=u();for(let E=0;E<h;E+=1)w.add(String.fromCharCode(E));w.add(String.fromCharCode(h)),w.add(String.fromCharCode(m));const y=LT(),b=l(y);b.write(h,g);let _=0,T=String.fromCharCode(o[_]);for(_+=1;_<o.length;){const E=String.fromCharCode(o[_]);_+=1,w.contains(T+E)?T=T+E:(b.write(w.indexOf(T),g),w.size()<4095&&(w.size()==1<<g&&(g+=1),w.add(T+E)),T=E)}return b.write(w.indexOf(T),g),b.write(m,g),b.flush(),y.toByteArray()},u=function(){const p={};let h=0;const m={};return m.add=function(g){if(m.contains(g))throw"dup key:"+g;p[g]=h,h+=1},m.size=function(){return h},m.indexOf=function(g){return p[g]},m.contains=function(g){return typeof p[g]<"u"},m};return i},YU=function(e,t,n){const r=VU(e,t);for(let c=0;c<t;c+=1)for(let u=0;u<e;u+=1)r.setPixel(u,c,n(u,c));const o=LT();r.write(o);const i=qU(),l=o.toByteArray();for(let c=0;c<l.length;c+=1)i.writeByte(l[c]);return i.flush(),"data:image/gif;base64,"+i};jl.stringToBytes;function XU(e){const t=jl(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 sr={title:"Your devices",scan:"Scan with your phone's camera to open this machine there, then let the phone in here.",turnOn:"Turn on, and your phone opens this machine at its tailnet name. Anyone on your tailnet you let in gets a shell here.",hereOff:"Tailscale on this machine is not connected, so nothing on your tailnet can reach it.",noneOnTailnet:"No other device is on your tailnet yet.",noPhone:"No phone has joined your tailnet. Install Tailscale on it and sign in to the same account.",knocking:"Let in the one whose words match the other screen.",missing:"A machine with no Toyon needs the phone button pressed on it, or `toyon remote --tailscale`.",listed:"listed",request:"request access",notAnswering:"not answering right now",offline:"offline",noToyon:"no Toyon",placeholder:"https://",notAnAddress:"That is not a Toyon address. It is https:// and the machine's name, as its screen shows it.",asking:e=>`Asking ${Ef(e)}.`,waiting:(e,t)=>`Toyon on ${Ef(e)} is asking whether to let ${t} in.`,added:e=>`Added ${e}.`,notKept:e=>`Let in, but not listed: ${e}`,add:"add"};function QU(e,t){return e.reached?e.toyon&&!e.toyon.answering?sr.notAnswering:t?sr.listed:e.toyon?null:sr.noToyon:sr.offline}function Kx(e){var t;return(t=e.toyon)!=null&&t.answering?0:e.toyon?1:e.reached?2:3}function Ef(e){try{return new URL(e).host}catch{return e}}function DT(e,t,n){const r=Ef(t);switch(e){case"refused":return`${r} did not let ${n} in.`;case"gone":return`${r} stopped waiting. Ask again, and answer there within five minutes.`;case"full":return`${r} has too many devices waiting already. Answer or turn those away there first.`;case"not-toyon":return`${r} is not a Toyon machine, or has no remote name set up.`;case"unreachable":return`${r} did not answer. Is Tailscale on here, and is Toyon running there?`}}function JU(e,t,n){const r=(o,i)=>({word:o,note:i,offer:null});switch(t==null?void 0:t.state){case"not-installed":return r("no Tailscale","Tailscale is not installed on this machine, so nothing on your tailnet can reach it.");case"not-running":return r("Tailscale not running","Tailscale is not running on this machine, so nothing on your tailnet can reach it.");case"disconnected":return{word:null,note:"Tailscale on this machine is switched off, so nothing on your tailnet can reach it.",offer:"connect"};case"signed-out":return{word:null,note:"Tailscale on this machine is signed out, so nothing on your tailnet can reach it.",offer:"sign-in"};case"needs-approval":return r("not approved",t.line)}if(e===null)return r("not asked","Toyon could not ask Tailscale here just now.");if(e!==void 0&&!e.here)return r("not connected",sr.hereOff);if(n===null&&t!==null&&t.state!=="ready")switch(t.state){case"magicdns-off":return r("MagicDNS off",t.line);case"https-off":return r("HTTPS off",t.line);default:return r(null,t.line)}return r(null,null)}const e7=e=>e==="phone"?"phone":"laptop";function Zx({rows:e}){return d.jsx("div",{className:"tailnet-list",children:e.map(t=>d.jsxs("div",{className:"tailnet-row",children:[d.jsxs("div",{className:"tailnet-peer",children:[d.jsx("span",{className:We("dot tailnet-dot",t.reached===null?"tailnet-asking":t.reached?"tailnet-reached":"tailnet-unreached"),role:"img","aria-label":t.reached===null?"asking":t.reached?"connected":"not connected"}),d.jsx(kt,{name:t.icon,className:"tailnet-kind"}),d.jsx("span",{className:"tailnet-name",children:t.name}),t.host&&d.jsx("span",{className:"hint tailnet-host",children:t.host})]}),t.right!==void 0&&t.right!==null&&d.jsx("span",{className:We("tailnet-right",typeof t.right=="string"&&"hint"),children:t.right})]},t.key))})}const qx=(e,t)=>{var n;return{key:e.host||e.name,name:((n=e.toyon)==null?void 0:n.machine)??e.name,host:e.kind==="machine"&&e.host?e.host:void 0,reached:e.reached,icon:e7(e.kind),right:t}},hm=4;function t7({text:e}){const{size:t,d:n}=S.useMemo(()=>{const r=XU(e);let o="";return r.forEach((i,l)=>{i.forEach((c,u)=>{c&&(o+=`M${u+hm} ${l+hm}h1v1h-1z`)})}),{size:r.length+hm*2,d:o}},[e]);return d.jsx("svg",{className:"devices-qr",viewBox:`0 0 ${t} ${t}`,shapeRendering:"crispEdges",role:"img","aria-label":"This machine's address",children:d.jsx("path",{d:n})})}const n7=5e3;function r7(e){return e.from===null?"A device that opened this address":`A Toyon page at ${Ef(e.from)}`}function o7({knock:e,letIn:t,onAnswer:n}){return d.jsxs("div",{className:We("devices-knock",t!==null&&"devices-knock-done"),children:[d.jsxs("div",{className:"devices-knock-line",children:[d.jsx("span",{className:"knock-word",children:e.word}),d.jsx("span",{className:"devices-from",children:t===null?`${r7(e)} wants in.`:t?"is in.":"was turned away."})]}),t===null&&d.jsxs("div",{className:"devices-actions",children:[d.jsx(Be,{tone:"primary",onClick:()=>n(!0),children:"let in"}),d.jsx(Be,{variant:"outline",onClick:()=>n(!1),children:"not now"})]})]})}function s7({host:e,noPhone:t}){return d.jsxs("div",{className:"devices-address",children:[d.jsx("div",{className:"devices-frame",children:d.jsx(t7,{text:VC(e)})}),d.jsxs("div",{className:"devices-about",children:[d.jsx("p",{className:"devices-line",children:sr.scan}),t&&d.jsx("p",{className:"devices-note",children:sr.noPhone})]})]})}function i7(e){const t=e.devices.filter(r=>r.kind==="phone"),n=e.devices.map((r,o)=>({d:r,i:o})).filter(({d:r})=>r.kind==="machine").sort((r,o)=>Kx(r.d)-Kx(o.d)||r.i-o.i).map(({d:r})=>r);return[...t,...n]}function a7(){const e=ut(),t=Jo(),n=Dr(),r=M(ke=>ke.frame==="desk"),o=M(ke=>{var ne;return((ne=ke.remote)==null?void 0:ne.host)??null}),i=M(ke=>ke.machine),l=M(ke=>ke.tailscale),c=M(ke=>ke.knocks),[u,p]=S.useState(""),[h,m]=S.useState({kind:"idle"}),[g,w]=S.useState([]),y=()=>e({a:"close"}),b=h.kind==="asking"||h.kind==="waiting",_=HL(()=>nP(n),n7,!b),T=S.useRef(new AbortController);S.useEffect(()=>()=>T.current.abort(),[]);const E=async ke=>{if(b)return;const ne=T.current.signal;m({kind:"asking",origin:ke});const ge=await EE(ke,ne,Se=>m({kind:"waiting",origin:ke,word:Se}));if(ne.aborted)return;if(typeof ge=="string"){m({kind:"failed",line:DT(ge,ke,"this page")});return}const je=t.serving(),Ce=await aP(Jg(je.origin,je.token),ke,ge.token);m(Ce?{kind:"failed",line:sr.notKept(Ce)}:{kind:"added",name:t.displayName(ke)})},N=()=>{const ke=YC(u);ke?E(ke):m({kind:"failed",line:sr.notAnAddress})},j=()=>{T.current.abort(),T.current=new AbortController,m({kind:"idle"})},$=(ke,ne)=>{w(ge=>ge.some(je=>je.knock.id===ke.id)?ge:[...ge,{knock:ke,letIn:ne}]),lP(n,ke.id,ne)},P=c.filter(ke=>!g.some(ne=>ne.knock.id===ke.id)),R=[...g,...P.map(ke=>({knock:ke,letIn:null}))],[A,O]=S.useState(!1),[B,H]=S.useState(null),Q=async ke=>{O(!0),H(null);const ne=await(ke?rP(n):oP(n));O(!1),ne&&H(ne)},re=(_==null?void 0:_.here)===!0,J=JU(_,l,o),ie=o!==null,ve=r&&(re||_===void 0)?d.jsx(Be,{variant:"outline",size:"sm",on:ie,"aria-pressed":ie,busy:A,disabled:!ie&&(l==null?void 0:l.state)!=="ready",onClick:()=>void Q(!ie),...Ut(ie?"Take this machine's name off your tailnet":"Give this machine a name on your tailnet"),children:ie?"on":"off"}):null,[C,Z]=S.useState(!1),[Y,q]=S.useState(null),z=ke=>{window.open(ke,"_blank","noopener")===null?q(ke):q(null)},te=async ke=>{if(Z(!0),H(null),ke==="connect"){const ne=await sP(n);ne&&H(ne)}else{const ne=await iP(n);"url"in ne?z(ne.url):H(ne.why)}Z(!1)},Ee=r&&J.offer!==null?Y!==null?d.jsx(Be,{variant:"outline",size:"sm",onClick:()=>z(Y),children:"open the sign-in page"}):d.jsx(Be,{variant:"outline",size:"sm",busy:C,onClick:()=>void te(J.offer??"connect"),...J.note?Ut(J.note):{},children:J.offer==="connect"?"connect":"sign in"}):null,Ne=J.word===null&&ve===null&&Ee===null?"this machine":d.jsxs(d.Fragment,{children:[J.word&&d.jsx("span",{className:"hint",children:J.word}),ve??Ee]}),de=[{key:"self",name:i??"This machine",host:o??void 0,reached:_===void 0?null:re,icon:"laptop",right:Ne}],we=_?i7(_).map(ke=>{if(ke.kind==="phone"||ke.host==="")return qx(ke,ke.reached?void 0:"not answering");const ne=`https://${ke.host}`,ge=QU(ke,t.get(ne)!==null);return qx(ke,ge??d.jsx(Be,{variant:"outline",size:"sm",disabled:b,onClick:()=>void E(ne),children:sr.request}))}):[],ae=r&&o!==null&&_!==null&&(_===void 0||_.here),G=_==null?void 0:_.devices.some(ke=>ke.kind==="machine"&&ke.host!==""&&ke.reached&&ke.toyon===null),ue=ae&&_!==void 0&&!_.devices.some(ke=>ke.kind==="phone"),Le=(()=>{switch(h.kind){case"asking":return sr.asking(h.origin);case"waiting":return sr.waiting(h.origin,h.word);case"added":return sr.added(h.name);case"failed":return h.line;case"idle":return null}})();return d.jsxs(Gc,{boxClass:"devices-card",onClose:y,children:[d.jsx("div",{className:"devices-title",children:sr.title}),d.jsx(Zx,{rows:de}),J.note&&J.offer===null&&d.jsx("p",{className:"devices-note",children:J.note}),B&&d.jsx("p",{className:"devices-note",children:B}),r&&!ie&&(l==null?void 0:l.state)==="ready"&&d.jsx("p",{className:"devices-note",children:sr.turnOn}),ae&&o!==null&&d.jsx(s7,{host:o,noPhone:ue}),h.kind==="waiting"&&d.jsx("div",{className:"knock-word devices-word",children:h.word}),Le&&d.jsx("p",{className:We("devices-line",h.kind==="failed"&&"devices-failed"),children:Le}),_!==void 0&&d.jsxs(d.Fragment,{children:[we.length>0&&d.jsx("div",{className:"devices-others",children:d.jsx(Zx,{rows:we})}),(_==null?void 0:_.devices.length)===0&&d.jsx("p",{className:"devices-note",children:sr.noneOnTailnet}),G&&d.jsx("p",{className:"devices-note",children:sr.missing})]}),!b&&d.jsxs("form",{className:"devices-form",onSubmit:ke=>{ke.preventDefault(),N()},children:[d.jsx($o,{size:"md",font:"ui",value:u,placeholder:sr.placeholder,"aria-label":"Address of the other machine",onChange:ke=>p(ke.target.value),className:"devices-field"}),d.jsx(Be,{type:"submit",variant:"outline",disabled:!u.trim(),children:sr.add})]}),b&&d.jsx("div",{className:"devices-actions",children:d.jsx(Be,{tone:"quiet",onClick:j,children:"cancel"})}),P.length>0&&d.jsx("p",{className:"devices-line devices-centred",children:sr.knocking}),R.map(ke=>d.jsx(o7,{knock:ke.knock,letIn:ke.letIn,onAnswer:ne=>$(ke.knock,ne)},ke.knock.id))]})}function l7({worktreeId:e,hits:t}){const n=ut(),r=it(),o=M(c=>c.layout.changes),i=M(c=>{var p;const u=(p=dn(c,e))==null?void 0:p.worktree;return u?u.path:null}),l=S.useCallback((c,u)=>{const p=u.trim().toLowerCase();return p?c.filter(h=>`${h.path}:${h.line} ${h.text}`.toLowerCase().includes(p)):c},[]);return d.jsx(Lr,{items:t,filter:l,keyOf:c=>`${c.path}:${c.line}`,rowClass:()=>"search-hit",rowTitle:c=>`${c.path}:${c.line}`,onPick:c=>{er({dispatch:n},{worktreeId:e,path:c.path,view:"file",line:{n:c.line}}),o||n({a:"toggle-changes"}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:c=>i?js({id:e,dir:i},c.path,{},{sock:r,dispatch:n}):[],placeholder:"lines that could write this element",keys:{pick:"opens the file",back:"closes"},row:c=>d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"search-loc",children:[c.path,":",c.line]}),d.jsx("span",{className:"search-text",children:c.text})]})})}function c7({project:e}){const t=ut(),n=it(),r=M(p=>p.paths),o=M(p=>p.home),i=S.useCallback(p=>{Zc(p)&&(n==null||n.send({t:"browse-path",path:p}))},[n]),l=S.useCallback((p,h)=>h8({query:h,entries:r.entries,target:r.target,answered:r.query,home:o}),[r,o]),c=Lc(e.name)?null:e.name.trim(),u=p=>`${p.replace(/\/+$/,"")}/`;return d.jsx(Lr,{initialQuery:u(e.parent),lead:d.jsx("span",{className:"picker-chip",children:c??"new project"}),items:[],filter:l,keyOf:p=>p.kind==="dir"?`d:${p.entry.path}`:`${p.kind}:${p.path}`,rowClass:()=>"picker-row folder-row",onQuery:i,completionOf:p=>p.kind==="dir"?u(p.entry.path):null,narrowTo:p=>p.kind==="dir"?u(p.entry.path):p.kind==="up"?u(p.path):null,onPick:p=>{p.kind==="here"&&(t({a:"new-project-set",v:{mode:e.mode==="init"?"create":e.mode,parent:p.path}}),t({a:"close"}))},onBack:()=>t({a:"close"}),placeholder:"type a folder path",keys:p=>({complete:"completes the path",pick:(p==null?void 0:p.kind)==="here"?"chooses it":(p==null?void 0:p.kind)==="up"?"goes up":"opens it",back:"goes back"}),empty:"no such folder",row:p=>p.kind==="here"?d.jsx(An,{label:`put ${c??"it"} in ${fg(p.path,o)}`,hint:d.jsx("bdi",{children:c?MN(p.path,c):p.path})}):p.kind==="up"?d.jsx(An,{label:`up to ${fg(p.path,o)}`,hint:d.jsx("bdi",{children:p.path})}):d.jsx(An,{label:p.entry.name})})}function u7({worktreeId:e}){const t=ut(),n=it(),r=M(m=>m.clientId),o=M(m=>dn(m,e)),i=M(m=>m.repos),c=Rt(e,"draft").trim(),u=S.useMemo(()=>i.filter(m=>m.id!==(o==null?void 0:o.worktree.repoId)),[i,o]),p=()=>t({a:"close"}),h=m=>{if(!o)return p();n==null||n.send({t:"handoff-ask",worktreeId:e,repoId:m.id,...c?{text:c}:{}}),c&&(n==null||n.send({t:"set-draft",boxId:e,text:"",clientId:r}),t({a:"set-draft",id:e,text:""})),p()};return d.jsx(Lr,{lead:d.jsx("span",{className:"picker-chip",children:(o==null?void 0:o.worktree.title)??"worktree"}),items:u,filter:(m,g)=>m.filter(w=>is(g,w.name,w.path)),keyOf:m=>m.id,row:m=>d.jsx(An,{label:m.name,hint:m.path}),onPick:h,onBack:()=>t({a:"close",back:!0}),placeholder:"continue in which project?",empty:"no other project is open",keys:{pick:"continues there",back:"closes"},footer:c?()=>d.jsxs("div",{className:"empty",children:["with your message: ",c.split(`
|
|
251
|
+
`)[0]]}):void 0})}const d7={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 f7(){const e=ut(),t=it(),n=M(r=>r.keepAwake);return d.jsx(Lr,{items:[...bC],filter:(r,o)=>r.filter(i=>is(o,mf[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=>d.jsx(An,{label:mf[r],current:r===n,hint:d7[r]})})}function h7(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=ug(t.rows,null);return n?`${n.n} ${n.tier==="waiting"?"waiting":"unread"}`:"all quiet"}function Ng(e){try{return XC(new URL(e).hostname)}catch{return!1}}function p7(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 y of t)y()},c=new Map,u=y=>{var _;if(y.serving)return;(((_=y.store.getState().remote)==null?void 0:_.front)==="edge"||Ng(y.origin))&&y!==o?y.sock.suspend():y.sock.resume()},p=y=>{var _;let b=(_=y.store.getState().remote)==null?void 0:_.front;c.set(y.origin,y.store.subscribe(()=>{var E;const T=(E=y.store.getState().remote)==null?void 0:E.front;T!==b&&(b=T,u(y))}))},h=()=>i,m={list:h,active:()=>o,serving:()=>n,get:y=>h().find(b=>b.origin===y)??null,displayName(y){const b=h().find(T=>T.origin===y);return b?h().filter(T=>T.name===b.name).length>1?`${b.name} (${new URL(b.origin).host})`:b.name:y},activate(y){const b=h().find(T=>T.origin===y);if(!b||b===o)return;const _=o;o=b,u(_),u(b),l()},add(y){var T;const b=r.find(E=>E.origin===y.origin);if(y.origin===n.origin)return n;if(b){if(b.token===y.token)return b;(T=c.get(b.origin))==null||T(),b.dispose(),r.splice(r.indexOf(b),1),o===b&&(o=n)}const _=e.build({...y,serving:!1});return r.push(_),p(_),Ng(_.origin)&&_.sock.suspend(),l(),_},remove(y){var _;const b=r.find(T=>T.origin===y);b&&((_=c.get(y))==null||_(),c.delete(y),b.dispose(),b.storage.clear(),r.splice(r.indexOf(b),1),o===b&&(o=n),l())},broadcast(y){for(const b of h())b.store.dispatch(y)},subscribe(y){return t.add(y),()=>t.delete(y)}},g=y=>{for(const b of y)m.add(b);for(const b of[...r])y.some(_=>_.origin===b.origin)||m.remove(b.origin)};let w=n.store.getState().handed;return n.store.subscribe(()=>{const y=n.store.getState().handed;y!==w&&(w=y,g(w))}),g(w),m}function Nw({form:e,anchored:t}){var ve;const n=ut(),r=it(),o=Jo(),i=io(),l=o.displayName(i.origin),c=M(C=>C.repos),u=M(C=>C.newProject?null:C.activeRepoId),p=M(C=>C.rows),h=M(C=>C.paths),m=M(C=>C.home),g=M(C=>C.pending),w=M(C=>C.folderDialog),y=S.useRef(""),b=S.useMemo(()=>Ov(c,p),[c,p]),_=nS(),T=rS(),E=S.useMemo(()=>_.map(C=>{var Z;return{...C,repos:Ov(C.repos,((Z=T.find(Y=>Y.origin===C.origin))==null?void 0:Z.rows)??[])}}),[_,T]),N=S.useCallback(C=>{y.current=C,Zc(C)&&(r==null||r.send({t:"browse-path",path:C}))},[r]),j=S.useCallback((C,Z)=>f8({query:Z,repos:b,pending:g,entries:[...h.entries].sort((Y,q)=>Number(q.isRepo)-Number(Y.isRepo)),target:h.target,answered:h.query,home:m,others:E,current:u}),[b,h,g,m,E,u]),$=C=>zT(p,C),P=()=>n({a:"close"}),R=()=>n({a:"close",back:!0}),A={sock:r,dispatch:n},O=C=>qc(A,{t:"register-repo",path:C}),B=(C,Z)=>qc(A,{t:"create-repo",mode:"create",parent:C,name:Z}),H=(C,Z,Y)=>n({a:"new-project",v:dk({mode:C,name:Z,parent:d8(c,u,m),...Y?{url:Y}:{}})}),Q=()=>n({a:"open",overlay:{kind:"projects",form:"disk"}}),re=()=>{const C=y.current.trim(),Z=C.lastIndexOf("/"),Y=Zc(C)&&Z>=0?C.slice(0,Z)||"/":"~";r==null||r.send({t:"choose-file",start:Y}),P()},J=()=>n({a:"open",overlay:{kind:"devices"}}),ie=(C,Z)=>{const Y=o.get(C);Y&&(Y.store.dispatch({a:"activate-repo",id:Z}),o.activate(C))};return d.jsx(Lr,{anchored:e==="pill"&&(t??!0),initialQuery:e==="disk"?"~/":"",lead:e==="disk"?void 0:d.jsx("span",{className:"picker-chip",children:((ve=c.find(C=>C.id===u))==null?void 0:ve.name)??"no project"}),trailing:e==="disk"?w?d.jsx(Ot,{icon:"file",label:"Open a file from Finder",onClick:re}):void 0:d.jsx(Ot,{icon:"folder",label:"Find a project or file on disk",onClick:Q}),items:[],filter:j,initialIndex:C=>C.findIndex(Z=>Z.kind==="repo"&&!Z.machine&&Z.repo.id===u),groupOf:C=>C.kind==="machine"||C.kind==="repo"&&C.machine?C.machine.origin:i.origin,groupHead:C=>C===i.origin?l:d.jsx(m7,{origin:C}),keyOf:C=>C.kind==="repo"?C.machine?`${C.machine.origin}:${C.repo.id}`:C.repo.id:C.kind==="dir"?`d:${C.entry.path}`:C.kind==="file"?`f:${C.entry.path}`:C.kind==="open"?`open:${C.path}`:C.kind==="init"?`init:${C.path}`:C.kind==="pending"?`p:${C.pending.id}`:C.kind==="clone"?`clone:${C.url}`:C.kind==="new"?"new-project":C.kind==="disk"?"open-folder":C.kind==="add-machine"?"add-machine":C.kind==="machine"?`machine:${C.machine.origin}`:`new:${C.parent??""}/${C.name}`,rowClass:C=>We("picker-row",(C.kind==="new"||C.kind==="disk"||C.kind==="add-machine")&&"new-project-row"),onQuery:N,completionOf:C=>C.kind==="dir"?C.entry.isRepo?C.entry.path:`${C.entry.path}/`:C.kind==="file"?C.entry.path:null,narrowTo:C=>C.kind==="dir"&&!C.entry.isRepo?`${C.entry.path}/`:null,onPick:C=>{if(C.kind==="clone")return H("clone",C.name,C.url);if(C.kind==="create"&&!C.parent)return H("create",C.name);if(C.kind==="new")return H("create","");if(C.kind==="disk")return Q();if(C.kind==="add-machine")return J();C.kind==="machine"?o.activate(C.machine.origin):C.kind==="pending"?n({a:"watch-import",id:C.pending.id}):C.kind==="repo"&&C.machine?ie(C.machine.origin,C.repo.id):C.kind==="repo"?n({a:"activate-repo",id:C.repo.id}):C.kind==="open"?O(C.path):C.kind==="file"?i3(r,C.entry.path):C.kind==="init"?LN(A,C.path):C.kind==="dir"?O(C.entry.path):C.parent&&B(C.parent,C.name),P()},onBack:R,rowMenu:C=>C.kind==="machine"||C.kind==="repo"&&C.machine?dg(o,C.machine.origin):C.kind==="repo"?sh(C.repo,u,A):C.kind==="pending"?p8(C.pending,A):[],placeholder:c.length>1?"switch project, or type a name or path":"type a name or a path to start",keys:C=>({complete:"completes the path",pick:(C==null?void 0:C.kind)==="dir"&&!C.entry.isRepo?"descends":(C==null?void 0:C.kind)==="pending"?"watches it":(C==null?void 0:C.kind)==="create"?C.parent?"creates it":"names it":(C==null?void 0:C.kind)==="clone"?"clones it":(C==null?void 0:C.kind)==="new"?"starts one":(C==null?void 0:C.kind)==="disk"?"browses":(C==null?void 0:C.kind)==="add-machine"?"adds one":(C==null?void 0:C.kind)==="machine"||(C==null?void 0:C.kind)==="repo"&&C.machine?"switches machine":"opens",back:"closes"}),empty:"nothing here; keep typing a path (~/… or /…)",row:C=>C.kind==="repo"&&C.machine?d.jsx(An,{label:C.repo.name,hint:d.jsx(g7,{origin:C.machine.origin,repo:C.repo})}):C.kind==="repo"?d.jsx(An,{label:C.repo.name,current:C.repo.id===u,hint:$(C.repo)}):C.kind==="pending"?d.jsx(An,{label:C.pending.name,hint:C.pending.error?"import failed":d.jsx("span",{className:"live-text",children:"importing"})}):C.kind==="dir"?d.jsx(An,{label:C.entry.name,hint:C.entry.isRepo?"git repo":void 0}):C.kind==="file"?d.jsx(An,{label:C.entry.name,hint:"file"}):C.kind==="open"?d.jsx(An,{label:`open ${C.path}`,hint:"register with this daemon"}):C.kind==="init"?d.jsx(An,{label:`open ${C.path}`,hint:"no git yet; starts it here with the files in it"}):C.kind==="clone"?d.jsx(An,{label:`clone ${C.name}`,hint:k7(C.url)}):C.kind==="new"?d.jsx(An,{label:d.jsxs(d.Fragment,{children:[d.jsx(kt,{name:"plus",className:"icon-inline"}),"new project"]})}):C.kind==="disk"?d.jsx(An,{label:d.jsxs(d.Fragment,{children:[d.jsx(kt,{name:"folder",className:"icon-inline"}),"open folder or file"]})}):C.kind==="add-machine"?d.jsx(An,{label:d.jsxs(d.Fragment,{children:[d.jsx(kt,{name:"devices",className:"icon-inline"}),"add a machine"]})}):C.kind==="machine"?d.jsx(An,{label:`switch to ${o.displayName(C.machine.origin)}`}):d.jsx(An,{label:`create ${C.name}`,hint:C.parent?`in ${C.parent}`:"new project"})})}function zT(e,t){const n=e.filter(u=>u.repoId===t.id),r=n.filter(_n).filter(u=>u.worktree.kind!=="spare"),o=r.filter(tu).length,i=r.length-1,l=n.length-n.filter(_n).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 m7({origin:e}){const t=Jo(),n=t.get(e)??t.active(),r=Ya(n,m=>m.rows),o=Ya(n,m=>m.connected),i=Ya(n,m=>m.connectFailure),l=Ya(n,m=>m.incompatible),c=Ya(n,m=>{var g;return(g=m.remote)==null?void 0:g.front}),u=t.displayName(e),p=h7(u,{rows:r.filter(_n),connected:o,connectFailure:i,incompatible:l,suspended:(c==="edge"||Ng(e))&&!o}),h=/^\d+ /.test(p);return d.jsxs(d.Fragment,{children:[u,d.jsx("span",{className:We("picker-group-tail",h&&"picker-group-owed"),children:p})]})}function g7({origin:e,repo:t}){const n=Jo(),r=n.get(e),o=Ya(r??n.active(),i=>i.rows);return d.jsx(d.Fragment,{children:r?zT(o,t):null})}function k7(e){const t=e.match(/^[a-z+]+:\/\/(?:[^@/]*@)?([^/:]+)/i)??e.match(/^[^@]+@([^:]+):/);return(t==null?void 0:t[1])??"git remote"}function w7(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:()=>en(r)})}const n=[{id:"copy-ref",label:e.kind==="pr"?"copy PR number":"copy branch name",onClick:()=>en(e.ref)}];return zn([t,n])}const y7=[],v7={branch:"branch",remote:"globe",pr:"pr"},Gx={pr:0,branch:1,remote:2},b7={pr:"pull requests",branch:"branches",remote:"remote branches"};function x7({repoId:e}){const t=ut(),n=it(),r=M(m=>m.clientId),o=M(m=>m.refs[e]),i=M(m=>m.rows),l=m=>{var g;return((g=i.find(w=>w.id===m))==null?void 0:g.name)??"a worktree"},c=S.useCallback(m=>[...m].sort((g,w)=>Gx[g.kind]-Gx[w.kind]),[]),u=S.useCallback(m=>n==null?void 0:n.send({t:"search-refs",repoId:e,query:m.trim()}),[n,e]),p=m=>!o||o.query!==m.trim(),h=m=>m.openIn?`open in ${l(m.openIn)}`:m.merged?"merged":m.pr?`${m.pr.author}${m.pr.draft?" · draft":""}${m.pr.fork?" · fork":""}`:m.subject??"";return d.jsx(Lr,{items:(o==null?void 0:o.refs)??y7,filter:c,onQuery:u,keyOf:m=>`${m.kind}:${m.ref}`,rowClass:()=>"picker-row ref-row",onPick:m=>{m.openIn?t({a:"activate",id:m.openIn}):n==null||n.send({t:"open-ref",repoId:e,kind:m.kind,ref:m.ref,clientId:r,...m.pr?{pr:{title:m.pr.title,url:m.pr.url}}:{}}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:w7,groupOf:m=>m.kind,groupHead:(m,g)=>`${b7[m]} · ${g}`,placeholder:"open a branch or PR…",keys:m=>({nav:"moves",pick:m!=null&&m.openIn?"switches to it":"opens it as a worktree",back:"closes"}),empty:m=>p(m)?d.jsx("span",{className:"live-text",children:"looking"}):m.trim()?"no branch or PR matches":"no unmerged branches or open PRs",row:m=>d.jsx(An,{label:d.jsxs(d.Fragment,{children:[d.jsx(kt,{name:v7[m.kind],className:"icon-inline"}),d.jsx("span",{className:"ref-name",children:m.name})]}),hint:h(m)})})}const Vx=[],pm=2;function E7({worktreeId:e}){const t=ut(),n=it(),r=uS(e).search,o=M(p=>p.layout.changes),i=M(p=>{var m;const h=(m=dn(p,e))==null?void 0:m.worktree;return h?h.path:null}),l=S.useCallback((p,h)=>h.trim().length>=pm?p:Vx,[]),c=S.useCallback(p=>{const h=p.trim();h.length>=pm&&(n==null||n.send({t:"search",worktreeId:e,query:h}))},[n,e]),u=p=>!r||r.query.trim()!==p.trim();return S.useEffect(()=>()=>n==null?void 0:n.send({t:"search-stop"}),[n]),d.jsx(Lr,{items:(r==null?void 0:r.hits)??Vx,filter:l,onQuery:c,keyOf:p=>`${p.path}:${p.line}`,rowClass:()=>"search-hit",rowTitle:p=>`${p.path}:${p.line}`,onPick:p=>{er({dispatch:t},{worktreeId:e,path:p.path,view:"file",line:{n:p.line}}),o||t({a:"toggle-changes"}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:p=>i?js({id:e,dir:i},p.path,{},{sock:n,dispatch:t}):[],placeholder:"search in files…",keys:{pick:"opens the file",back:"closes"},empty:p=>p.trim().length<pm?"type at least two characters":u(p)?d.jsx("span",{className:"live-text",children:"searching"}):"no matches",footer:(p,h)=>r!=null&&r.truncated&&!u(p)&&h.length>0?d.jsx("div",{className:"empty",children:"not every match is shown; narrow the search"}):null,row:p=>d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"search-loc",children:[p.path,":",p.line]}),d.jsx("span",{className:"search-text",children:p.text})]})})}const Yx=e=>e.source==="file"?"~/.toyon/themes":e.source==="vscode"?"VS Code":"";function S7({slot:e}){const t=ut(),n=it(),r=M(E=>E.themePrefs),o=M(E=>E.themes),i=wk(),l=Xg(r,i),c=r[e==="theme"?l:e],u=()=>t({a:"close"}),p=()=>t({a:"close",back:!0}),h=E=>t({a:"preview-theme",theme:E}),[m,g]=S.useState(null),[w,y]=S.useState(null),b=(E,N)=>E[N??l]??E.dark??E.light??null,_=S.useMemo(()=>zM(o),[o]),T=S.useMemo(()=>o.filter(E=>E.kind===e),[o,e]);return ft([m,w],()=>{e==="theme"&&h(m?b(m,w):null)}),e!=="theme"?d.jsx(Lr,{items:T,filter:(E,N)=>E.filter(j=>is(N,j.name,j.id)),rowClass:()=>"picker-row",keyOf:E=>E.id,initialIndex:E=>E.findIndex(N=>N.id===c),onActive:h,onPick:E=>{n==null||n.send({t:"set-theme",prefs:{...r,[e]:E.id}}),u()},onBack:p,placeholder:`${e} slot override`,keys:{nav:"preview",pick:"keeps",back:"reverts"},empty:"no matching theme",row:E=>d.jsx(An,{label:E.name,current:E.id===c,hint:Yx(E)})}):d.jsx(Lr,{items:_,filter:(E,N)=>E.filter(j=>{var $,P;return is(N,j.name,($=j.dark)==null?void 0:$.name,(P=j.light)==null?void 0:P.name)}),rowClass:()=>"picker-row",keyOf:E=>{var N,j;return E.name+(((N=E.dark)==null?void 0:N.id)??((j=E.light)==null?void 0:j.id))},initialIndex:E=>E.findIndex(N=>{var j,$;return((j=N.dark)==null?void 0:j.id)===c||(($=N.light)==null?void 0:$.id)===c}),onActive:g,onSide:E=>{var N;E.dark&&E.light&&y((((N=b(E,w))==null?void 0:N.kind)??l)==="dark"?"light":"dark")},onPick:E=>{n==null||n.send({t:"set-theme",prefs:FM(r,E)}),u()},onBack:p,placeholder:"theme",keys:{nav:"preview",side:"dark/light",pick:"keeps",back:"reverts"},empty:"no matching theme",row:(E,N)=>{var R,A;const j=b(E,N?w:null),$=Yx(E.dark??E.light),P=((R=E.dark)==null?void 0:R.id)===c||((A=E.light)==null?void 0:A.id)===c;return d.jsx(An,{label:E.name,current:P,hint:d.jsxs("span",{className:"theme-kinds",children:[$&&d.jsx("span",{children:$}),d.jsx("span",{className:"kind","data-state":vr({current:N&&(j==null?void 0:j.kind)==="dark"}),children:E.dark?"dark":""}),d.jsx("span",{className:"kind","data-state":vr({current:N&&(j==null?void 0:j.kind)==="light"}),children:E.light?"light":""})]})})}})}function FT(){const e=XL(),t=M(i=>i.frame==="phone"),n=_l(),r=M(i=>i.activeRepoId),o=M(i=>i.newProject);return d.jsxs(d.Fragment,{children:[(e==null?void 0:e.kind)==="quick-open"&&n&&d.jsx(lB,{worktreeId:n}),(e==null?void 0:e.kind)==="search"&&n&&d.jsx(E7,{worktreeId:n}),(e==null?void 0:e.kind)==="element-sources"&&d.jsx(l7,{worktreeId:e.worktreeId,hits:e.hits}),(e==null?void 0:e.kind)==="refs"&&r&&d.jsx(x7,{repoId:r}),(e==null?void 0:e.kind)==="chats"&&r&&d.jsx(UU,{repoId:r,scope:e.names?"names":"all"}),(e==null?void 0:e.kind)==="keys"&&d.jsx(TU,{}),(e==null?void 0:e.kind)==="devices"&&d.jsx(a7,{}),(e==null?void 0:e.kind)==="theme"&&d.jsx(S7,{slot:e.slot}),(e==null?void 0:e.kind)==="appearance"&&d.jsx(PU,{}),(e==null?void 0:e.kind)==="keep-awake"&&d.jsx(f7,{}),(e==null?void 0:e.kind)==="agent"&&d.jsx(RU,{}),(e==null?void 0:e.kind)==="agent-page"&&d.jsx(IU,{agentId:e.agent}),(e==null?void 0:e.kind)==="handoff"&&d.jsx(u7,{worktreeId:e.worktreeId}),(e==null?void 0:e.kind)==="commands"&&!t&&d.jsx(vT,{}),(e==null?void 0:e.kind)==="projects"&&e.form!=="pill"&&d.jsx(Nw,{form:e.form},e.form),(e==null?void 0:e.kind)==="choose-folder"&&o&&d.jsx(c7,{project:o})]})}const $c="Lost the daemon; retrying",_7="Not run by Toyon",BT="new worktree",N7=(e,t)=>`in ${e}, started from ${t}`,T7=e=>`in ${e}, here while it needs you`,j7=new Set(["waiting","working","starting","failed","crashed"]);function Tg(e,t){if(t.offline)return $c;if(!_n(e))return e.locked?`Held by ${e.lockReason??"another tool"}`:t.path;if(t.op)return ok(t.op);if(wr(e.worktree))return BT;const n=rk(e,t.needsSetup),r=e.worktree.lastTurn;return!j7.has(Is(e))&&r?Fk(r):t.at&&t.at!=="now"?`${n} · ${t.at}`:n}function C7(e,t){if(!_n(e)||t)return!1;const n=Is(e);return(n==="idle"||n==="asleep")&&!e.unseen}function A7(e){const t=e.worktree.lastTurn,n=e.worktree.landed?Lk(e.worktree.lands):[],r=t?(tu(e)?lz:Fk)(t):void 0,o=jf(e.worktree),i=o&&!e.worktree.landed?Ts(o):void 0;return[...n,r,i].filter(l=>!!l)}function I7(e,t,n,r){let o;const i=(h,m)=>{const g=m==null?void 0:m[m.length-1];g&&(!o||g.at>o.mark.at)&&(o={title:h,mark:g})};for(const h of e)h.worktree&&i(h.worktree.title,h.worktree.lands);for(const h of t)i(h.title,h.lands);const l=o&&Pk(o.mark),c=o?`Landed ${o.title} ${Ko(yr(o.mark.at))}${l?`: ${Kr(l)}`:"."}`:void 0,u=n?o_(r,n):null,p=u?Kr(`${u.charAt(0).toUpperCase()}${u.slice(1)}`):n!=null&&n.fetchedAt?`Level with origin, fetched ${Ko(yr(n.fetchedAt))}.`:void 0;return[c,p].filter(h=>!!h)}function $7(e){const t=e.prompt?eh(e.prompt):"";return[...t?[t]:[],...Lk(e.lands)]}function R7(e){const n=[e.auto&&O7(e.auto,!!e.landed),e.cost!==void 0?iu(e.cost):void 0].filter(r=>!!r);return n.length?n:void 0}function O7(e,t){const{what:n,idle:r}=NC(e);return r?`${t?"":`${n}, `}${r} idle`:n}const Xx=25;function M7(e,t){if(e.length<=Xx+1)return{shown:e,rest:0};const n=e.slice(0,Xx),r=t?e.find(o=>o.id===t):void 0;return r&&!n.includes(r)&&n.push(r),{shown:n,rest:e.length-n.length}}function P7(e,t,n){const r=e.indexOf(t);return r<0?null:e[r+(n?1:-1)]??null}const L7=.5;function D7(e){const t=e.usage,n=t&&t.size>0?t.used/t.size:0,r=[n>=L7?`${Math.round(100*n)}% of context`:void 0,e.queued?`${e.queued} queued`:void 0,(t==null?void 0:t.cost)!==void 0?iu(t.cost):void 0].filter(o=>!!o);return r.length?r:void 0}function z7(e){const t=o=>e.filter(cs).find(i=>i.id===o)??null,n=t("archive"),r=t("land");return[{id:"archive",label:(n==null?void 0:n.label)??"archive",icon:"archive",item:n},{id:"land",label:(r==null?void 0:r.label)??"land",icon:"land",item:r},{id:"more",label:"more",icon:"more",item:null}]}function F7(e){return e.altKey?"Alt":e.ctrlKey?"Control":e.metaKey?"Meta":null}function B7(e,t){return t==="Alt"?e.altKey:t==="Control"?e.ctrlKey:e.metaKey}const U7=200,UT={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};function H7(e,t=UT){let n=null,r=!1,o=null;const i=()=>{r||(r=!0,e(!0))},l=()=>{o!==null&&(t.clear(o),o=null)},c=()=>{l(),n=null,r&&(r=!1,e(!1))};return{press(u){const p=n!==null;n=F7(u),l(),n&&(p?i():o=t.set(()=>{o=null,i()},U7))},keyup(u){n&&u===n&&c()},mods(u){n&&!B7(u,n)&&c()},end:c}}const W7=350,K7=80,Z7=2e3;function q7(e,t=UT){let n=!1,r=null,o=null,i=null,l=null;const c=()=>{r&&(t.clear(r.pending),r=null)},u=()=>{i!==null&&t.clear(i),l!==null&&t.clear(l),i=null,l=null},p=()=>{c(),u(),o=null,n&&(n=!1,e(!1))};return{over(h){u(),l=t.set(p,Z7),n||(n=!0,e(!0)),(r==null?void 0:r.id)!==(h==null?void 0:h.id)&&(c(),!(!h||h.id===o)&&(o=null,r={id:h.id,pending:t.set(()=>{r=null,o=h.id,h.land()},W7)}))},leave(){n&&(i!==null&&t.clear(i),i=t.set(p,K7))},end:p}}const Md=e=>e>999?"1k+":String(e);function HT({width:e,placement:t="strip"}){const n=t==="screen",r=Si(),o=M(V=>V.chatSide)==="left"?"right":"left",i=ut(),l=it(),{host:c}=Dr(),u=Ek(),p=u[0]&&wr(u[0].worktree)?u[0]:null,h=p?u.slice(1):u,m=M(V=>ml(V,V.activeRepoId)),g=V=>p&&V.id===p.id&&m?{behind:m.behind,dirty:m.dirty}:V,[,w]=S.useState(0);S.useEffect(()=>{const V=setInterval(()=>w(pe=>pe+1),6e4);return()=>clearInterval(V)},[]);const y=WL(),b=KL(),_=ZL(),T=qL(),E=(V,pe,Ye)=>{V.key!=="ArrowLeft"&&V.key!=="ArrowRight"||V.shiftKey||V.altKey||V.metaKey||V.ctrlKey||(V.preventDefault(),Qf([{depth:0,open:pe}],0,V.key)&&i({a:Ye}))},N=fa(),j=M(V=>V.notesPage),$=M(V=>V.clientId),P=M(V=>V.frame),R=M(V=>V.activeRepoId),A=M(V=>V.connected);S.useEffect(()=>{l&&A&&R&&l.send({t:"list-archived",repoId:R})},[l,A,R]);const O=_l(),B=lS(),H=M(V=>V.layout),Q=M(V=>V.railOpen),re=M(V=>V.railPeek),J=S.useRef(null),[ie,ve]=S.useState(!1);ft([re],()=>{var V;re&&!n&&!r&&!((V=J.current)!=null&&V.matches(":hover"))&&ve(!0)}),S.useEffect(()=>{if(!ie)return;let V=null;const pe=Ye=>{if(!V){V={x:Ye.clientX,y:Ye.clientY};return}Math.abs(Ye.clientX-V.x)+Math.abs(Ye.clientY-V.y)<3||ve(!1)};return window.addEventListener("pointermove",pe),()=>window.removeEventListener("pointermove",pe)},[ie]);const[C,Z]=S.useState(!1),Y=S.useMemo(()=>q7(Z),[]);S.useEffect(()=>()=>Y.end(),[Y]);const q=M(V=>{var pe;return((pe=V.dragFiles)==null?void 0:pe.at)==="rail"?V.dragFiles.worktreeId:null}),z=M(V=>V.focusRail),te=S.useRef(z),Ee=S.useRef(null);ft([z],()=>{if(z===te.current)return;te.current=z;const V=requestAnimationFrame(()=>{var pe,Ye;return(Ye=(pe=Ee.current)==null?void 0:pe.querySelector('[data-state~="current"]'))==null?void 0:Ye.focus()});return()=>cancelAnimationFrame(V)});const Ne=(V,pe,Ye,nt,yt)=>{var ye,Ie;if(V.key!=="ArrowUp"&&V.key!=="ArrowDown"||V.altKey||V.ctrlKey||V.metaKey)return;V.preventDefault();const Jt=P7(pe,Ye,V.key==="ArrowDown");Jt!==null&&(yt(Jt),(Ie=(ye=Ee.current)==null?void 0:ye.querySelector(`[${nt}="${Jt}"]`))==null||Ie.focus())},de=M(V=>V.repos),we=M(V=>V.shipping),ae=M(V=>V.rows),G=V=>de.find(pe=>pe.id===V.repoId)??null,ue=V=>R?mk(V,R,ae):null,Le=V=>R&&V.repoId!==R?G(V):null,ke=vn("rail"),ne=Nk(),ge=M(V=>V.home),je=V=>{const pe=V.worktree?V.worktree.path:V.path;return ge&&pe.startsWith(`${ge}/`)?`~${pe.slice(ge.length)}`:pe},[Ce,Se]=S.useState(!1),[Me,wt]=S.useState([]),on=V=>{!Dd(V.worktree)||Le(V)||(Se(!0),wt(pe=>pe.includes(V.worktree.id)?pe.filter(Ye=>Ye!==V.worktree.id):[...pe,V.worktree.id]))},St=()=>{Se(!1),wt([])};ft([Ce],()=>{const V=pe=>pe.key==="Escape"&&St();return Ce&&window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)});const Yt=Mk(l,i),zt={sock:l,dispatch:i},Ht=V=>{Se(!0),wt(pe=>V===O||pe.includes(V)?pe:[...pe,V])},De=V=>_n(V)?t_(V,G(V),{layout:H,shipping:we,frame:P,repos:de},zt,{...Le(V)?{}:{graft:Ht},hostname:c}):GD(V,{clientId:$,frame:P},zt,c),[_t,sn]=S.useState(null),ln=V=>_n(V)?z7(De(V)):[];TT(Ee,{rowOf:V=>{if(!n||Ce)return null;const pe=V.closest(".slide"),Ye=pe==null?void 0:pe.dataset.row,nt=Ye?u.find(yt=>yt.id===Ye):void 0;return pe&&Ye&&nt?{el:pe,key:Ye,rungs:ln(nt).length}:null},onSlide:sn,onPick:(V,pe)=>{var yt;const Ye=u.find(Jt=>Jt.id===V),nt=Ye?ln(Ye)[pe-1]:void 0;if(!(!Ye||!nt)){if(nt.id==="more"){const Jt=(yt=Ee.current)==null?void 0:yt.querySelector(`.slide[data-row="${V}"]`);Jt&&ke.openUnder(Jt,()=>De(Ye),V)}else if(nt.item&&!nt.item.disabled){const Jt=nt.item.onClick;window.setTimeout(Jt,NT)}}}});const lt=M7(_,(N==null?void 0:N.id)??null),jt=lt.shown.some(V=>(V.dirty??0)>0),Kt=V=>d.jsxs("button",{type:"button",className:We("row row-edge row-quiet rail-disc-item rail-arch-item",(ne==null?void 0:ne.owner)==="rail"&&ne.key===V.id&&"menu-open"),"data-state":vr({current:!n&&(N==null?void 0:N.id)===V.id}),"data-arch":V.id,...Ut(Dz(V),void 0,{placement:o,card:!0,detail:$7(V),aside:R7(V)}),onClick:()=>i({a:"open-archived",id:V.id}),onKeyDown:pe=>Ne(pe,lt.shown.map(Ye=>Ye.id),V.id,"data-arch",Ye=>i({a:"open-archived",id:Ye})),...ke.contextMenu(()=>Kd(V,{clientId:$,frame:P},zt),V.id),children:[d.jsxs("span",{className:"rail-gut",onClick:r?pe=>{pe.stopPropagation(),ke.openUnder(pe.currentTarget,()=>Kd(V,{clientId:$,frame:P},zt),V.id)}:void 0,children:[d.jsx("span",{className:"rail-at row-dim",children:yr(V.archivedAt)}),d.jsx("span",{className:"rail-more",...Ut("Actions"),onClick:pe=>{pe.stopPropagation(),ke.openUnder(pe.currentTarget,()=>Kd(V,{clientId:$,frame:P},zt),V.id)},children:d.jsx(kt,{name:"more"})})]}),d.jsx("span",{className:"branch",children:V.title}),jt&&d.jsx("span",{className:"rail-counts",children:d.jsx("span",{className:"rail-count row-dim","data-tip":V.dirty?`${V.dirty} uncommitted, kept`:void 0,children:V.dirty?`~${Md(V.dirty)}`:""})}),V.auto?d.jsx("span",{className:"rail-glyph rail-auto row-dim",children:d.jsx(kt,{name:"clock",className:"icon-inline"})}):d.jsx("span",{className:"dot"}),n&&d.jsx("span",{className:"rail-at rail-at-end row-dim",children:yr(V.archivedAt)})]},V.id),xn=[...u,...y].map(g),Pt=["ahead","dirty","behind"].filter(V=>xn.some(pe=>(pe[V]??0)>0)),jn=V=>{const pe=Pt.findIndex(Ye=>(V[Ye]??0)>0);return new Set(pe<0?[]:Pt.slice(pe))},Qt=V=>{var Ct;const pe=_n(V)?V:null,Ye=!!pe&&wr(pe.worktree),nt=g(V),yt=de.find(Ft=>Ft.id===V.repoId)??null,Jt=yt?Tf(yt):"main",ye=yt&&dA(yt)&&(m!=null&&m.fetchedAt)?` as of ${r_(m.fetchedAt)}`:"",Ie=jn(nt),Xt=!!nt.ahead&&!nt.dirty,U=V.id,me=(ne==null?void 0:ne.owner)==="rail"&&ne.key===U,ze=pe?ue(pe):null,Xe=pe?Le(pe):null,Mt=pe&&!Xe&&Ce&&Dd(pe.worktree)&&U!==O,Nt=CE(V,(Ct=we[U])==null?void 0:Ct.op),He=d.jsxs("button",{type:"button",className:We("row row-edge",pe?"rail-item":"row-quiet rail-disc-item",n&&C7(V,Nt)&&"row-quiet",me&&"menu-open",q===U&&"drop-over"),"data-state":vr({current:!n&&U===O&&!N&&!j,checked:Me.includes(U)}),...pe?Ut(B?$c:Nt?ok(Nt):rk(V,af(G(pe))),void 0,{placement:o,card:!0,aside:D7(V),detail:wr(pe.worktree)?I7(u,_,m,Jt):[...Xe?[ze?N7(Xe.name,ze.worktree.title):T7(Xe.name)]:[],...A7(pe)],dot:B?void 0:Nt?"spinner":Is(V)}):Ut(B?$c:V.locked?`Held by ${V.lockReason??"another tool"}`:_7,void 0,{placement:o,card:!0,detail:je(V),dot:B||V.locked?void 0:"discovered"}),"data-wt":U,onKeyDown:Ft=>{if(Ce)return;const Zt=(pe?u:y).map(bn=>bn.id);Ne(Ft,Zt,U,"data-wt",bn=>i({a:"activate",id:bn}))},onClick:Ft=>{pe&&!Xe&&(Ce||Ft.shiftKey)?U===O?Se(!0):on(pe):Ye&&!n?i({a:"open-draft"}):(i({a:"activate",id:U}),pe&&!r&&i({a:"walked"}))},...ke.contextMenu(()=>De(V),U),children:[d.jsx("span",{className:"rail-gut",onClick:r&&!Ce?Ft=>{Ft.stopPropagation(),ke.openUnder(Ft.currentTarget,()=>De(V),U)}:void 0,children:Mt?d.jsx("input",{type:"checkbox",className:"rail-graft-check",checked:Me.includes(U),readOnly:!0,tabIndex:-1}):!Ce&&d.jsxs(d.Fragment,{children:[pe&&!Ye&&d.jsx("span",{className:"rail-at row-dim",children:yr(aa(pe.worktree))}),d.jsx("span",{className:"rail-more",...Ut("Actions"),onClick:Ft=>{Ft.stopPropagation(),ke.openUnder(Ft.currentTarget,()=>De(V),U)},children:d.jsx(kt,{name:"more"})})]})}),Ye?d.jsxs("span",{className:"branch rail-main-label",children:[d.jsx(kt,{name:"plus",className:"icon-inline"}),"new worktree"]}):d.jsx("span",{className:We("branch",(pe==null?void 0:pe.worktree.unnamed)&&"row-dim"),children:Mm(V,pe?G(pe):null)}),(pe==null?void 0:pe.worktree.mode)&&pe.worktree.mode!=="auto"&&d.jsx("span",{className:"rail-badge badge-mode","data-tip":`${pe.worktree.mode} mode: the agent waits for you`,children:pe.worktree.mode}),pe&&(()=>{const Ft=G(pe),Zt=QS(pe.worktree,Ft);return Zt&&Zt!==(Ft==null?void 0:Ft.config.defaultProfile)?d.jsx("span",{className:"rail-badge badge-profile","data-tip":`runs the ${Zt} profile`,children:Zt}):null})(),(pe==null?void 0:pe.worktree.variant)&&d.jsxs("span",{className:"rail-badge badge-variant clickable","data-tip":"Keep this variant, archive the others",onClick:Ft=>{Ft.stopPropagation(),Yt.pickVariant(pe)},children:[d.jsxs("span",{className:"num",children:["v",pe.worktree.variant.index,"/",pe.worktree.variant.of]}),d.jsx("span",{className:"act",children:"pick"})]}),Xe&&d.jsx("span",{className:"rail-guest row-dim",children:Xe.name}),d.jsxs("span",{className:"rail-counts",children:[Ie.has("ahead")&&d.jsx("span",{className:"rail-count badge-ahead","data-tip":nt.ahead?`${nt.ahead} ahead of ${Jt}`:void 0,children:nt.ahead?`+${Md(nt.ahead)}`:""}),Ie.has("dirty")&&!Xt&&d.jsx("span",{className:"rail-count badge-dirty","data-tip":nt.dirty?`${nt.dirty} uncommitted${Ye?" on main":""}`:void 0,children:nt.dirty?`~${Md(nt.dirty)}`:""}),Ie.has("behind")&&d.jsx("span",{className:"rail-count rail-behind row-dim","data-tip":nt.behind?`${nt.behind} behind ${Ye?"origin":Jt}${Ye?"":ye}`:void 0,children:nt.behind?Md(nt.behind):""}),n&&pe&&d.jsx("span",{className:"rail-at row-dim",children:Ye?"":yr(aa(pe.worktree))})]}),(()=>{if(Nt)return d.jsx(kl,{size:"dot"});if(V.locked)return d.jsx("span",{className:"rail-glyph rail-lock row-dim",children:d.jsx(kt,{name:"lock",className:"icon-inline"})});if(!pe)return d.jsx("span",{className:"dot discovered"});const Ft=Ce||B?null:AE(V.procs),Zt=V.unseen?" unseen":"",bn=Is(V);return Ye&&!Ft&&bn!=="crashed"&&!B?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:`dot ${bn} rail-main-dot`}),d.jsx("span",{className:"rail-glyph rail-main-strip",children:d.jsx(kt,{name:"plus"})})]}):!Ft||bn!=="crashed"?d.jsx("span",{className:`dot ${bn}${Zt}`}):d.jsx("span",{className:`dot crashed clickable${Zt}`,...Ut(Ft.tip),onClick:On=>{On.stopPropagation(),i({a:"activate",id:U}),i({a:"term-stream",id:U,stream:Ft.stream})}})})(),n&&d.jsx("span",{className:"rail-say row-dim",children:Tg(V,{offline:B,needsSetup:af(pe?G(pe):null),path:je(V),op:Nt})})]},U);if(!n||!pe)return He;const Fe=(_t==null?void 0:_t.key)===U?_t.step:null,Ke=Fe===null?null:ln(V)[Math.max(0,Fe-1)],ht=!!Ke&&Fe!==null&&Fe>0&&(Ke.id==="more"||!!Ke.item&&!Ke.item.disabled);return d.jsxs("div",{className:"slide","data-row":U,children:[He,Ke&&d.jsxs("span",{className:"slide-verb","data-rung":ht?Ke.id:void 0,"aria-hidden":"true",children:[d.jsx("span",{className:"slide-word",children:Ke.label}),d.jsx(kt,{name:Ke.icon})]})]},U)};return d.jsx("div",{ref:J,className:We("rail",n&&"rail-screen",!n&&(Ce||(ne==null?void 0:ne.owner)==="rail"||re||C)&&"hold",ie&&"quiet",(n||Q)&&"pinned",B&&"offline"),style:e!==void 0&&!n?{"--rail-width":`${e}px`}:void 0,onClick:r&&!n&&!Q?V=>{V.target instanceof Element&&V.target.closest("button, .rail-gut")||i({a:"toggle-rail"})}:void 0,onDragOver:V=>{var yt;if(!Zm(V.dataTransfer))return;const pe=V.target instanceof Element?(yt=V.target.closest("[data-wt]"))==null?void 0:yt.dataset.wt:void 0,Ye=pe?[...u,...y].find(Jt=>Jt.id===pe):void 0;if(!Ye||Ce||Ye.id===O)return Y.over(null);const nt=!n&&_n(Ye)&&wr(Ye.worktree);Y.over({id:Ye.id,land:()=>i(nt?{a:"open-draft"}:{a:"activate",id:Ye.id})})},onDragLeave:Y.leave,onDrop:Y.end,children:d.jsxs("div",{className:"rail-panel","data-tip":B?$c:void 0,"data-tip-placement":"follow",children:[d.jsxs("div",{className:"rail-list",ref:Ee,children:[p&&!n&&Qt(p),h.map(Qt),Ce&&d.jsxs("div",{className:"rail-graft",children:[(()=>{const V=u.find(nt=>nt.worktree.id===O&&Dd(nt.worktree)&&!Le(nt)),pe=Me.filter(nt=>nt!==(V==null?void 0:V.worktree.id)),Ye=pe.map(nt=>{var yt;return((yt=u.find(Jt=>Jt.worktree.id===nt))==null?void 0:yt.worktree.title)??nt}).join(", ");return d.jsxs(Be,{size:"md",tone:"primary",disabled:!V||pe.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 ${Ye} onto ${V.worktree.title}?
|
|
252
|
+
|
|
253
|
+
Their branches are merged in, then their directories and branches are removed.`)&&(l==null||l.send({t:"graft",targetId:V.worktree.id,sourceIds:pe}),St())},children:["graft ",pe.length]})})(),d.jsxs(Be,{size:"md",disabled:!Me.some(V=>{var pe;return(((pe=u.find(Ye=>Ye.worktree.id===V))==null?void 0:pe.behind)??0)>0}),"data-tip":"Pull main into every selected worktree that's behind",onClick:()=>{for(const V of Me){const pe=u.find(Ye=>Ye.worktree.id===V);((pe==null?void 0:pe.behind)??0)>0&&pi(l,i,{t:"sync-main",worktreeId:V})}St()},children:[d.jsx(kt,{name:"pull",className:"icon-inline"})," sync"]}),d.jsx(Be,{size:"md",tone:"danger",disabled:Me.length===0,"data-tip":"Archive all selected worktrees; their chats and work are kept",onClick:()=>{window.confirm(`Archive ${Me.length} worktree(s)?
|
|
254
|
+
|
|
255
|
+
Their directories and branches go. The chats, commits and any uncommitted changes are kept, and each can be restored.`)&&(oa(l,i,Me),St())},children:"archive…"}),d.jsx(Ot,{icon:"close",label:"Cancel",hint:"esc",onClick:St})]}),!Ce&&y.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{className:"section-title section-row section-fold rail-disc-head","aria-expanded":b,...Ut(`${y.length} worktree${y.length===1?"":"s"} here that Toyon did not make`,void 0,{placement:o}),onClick:()=>i({a:"toggle-discovered"}),onKeyDown:V=>E(V,b,"toggle-discovered"),children:[d.jsx("span",{className:"rail-gut",children:d.jsx(kt,{name:"caret",className:We("icon-inline disc-caret",!b&&"shut")})}),d.jsx("span",{className:"rail-label",children:"discovered"})]}),b&&y.map(Qt)]}),!Ce&&_.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold rail-disc-head","aria-expanded":T,...Ut(`${_.length} archived worktree${_.length===1?"":"s"}, kept with ${_.length===1?"its chat":"their chats"}`,void 0,{placement:o}),onClick:()=>i({a:"toggle-archived"}),onKeyDown:V=>E(V,T,"toggle-archived"),children:[d.jsx("span",{className:"rail-gut",children:d.jsx(kt,{name:"caret",className:We("icon-inline disc-caret",!T&&"shut")})}),d.jsx("span",{className:"rail-label",children:"archived"})]}),T&<.shown.map(Kt),T&<.rest>0&&R&&d.jsxs("button",{type:"button",className:"row row-quiet rail-disc-item rail-arch-item",...Ut("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:[d.jsx("span",{className:"rail-gut"}),d.jsxs("span",{className:"branch row-dim",children:[lt.rest," more"]}),d.jsx("span",{className:"dot"})]})]})]}),!n&&d.jsx("div",{className:"rail-foot",children:d.jsx(Ot,{icon:"worktrees",label:"Worktree panel",hint:Dt("rail"),tone:"chrome",on:Q,onClick:()=>i({a:"toggle-rail"})})})]})})}function G7({screen:e,tabs:t,fold:n}){const r=ut(),o=Jo(),i=io(),l=M(C=>C.reading),c=YL(),u=Nl(),p=M(C=>C.repos),h=$s(),m=_l(),g=fa(),w=Sk(),y=Ek(),b=lS(),_=rS(),T=l8(y,m,_),E=y.find(C=>wr(C.worktree)),N=e==="home",j=!N&&!g&&!!h&&wr(h.worktree),$=M(C=>{var Z;return j&&h?CE(h,(Z=C.shipping[h.id])==null?void 0:Z.op):null}),P=kk().length,R=o.displayName(i.origin),A=N?(c==null?void 0:c.name)??R:j?BT:(g==null?void 0:g.title)??(h==null?void 0:h.worktree.title)??(w==null?void 0:w.name)??null,O=y.filter(C=>!wr(C.worktree)).length,B=O===0?"no worktrees yet":`${O} ${O===1?"worktree":"worktrees"}`,H=N?c&&P>1?`${R} · ${B}`:B:g?y_(g):j?b?$c:$?ok($):(c==null?void 0:c.name)??null:h?Tg(h,{offline:b,needsSetup:af(u),path:h.worktree.path,at:yr(aa(h.worktree))}):w?Tg(w,{offline:b,needsSetup:!1,path:w.path}):null,Q=!N&&!g&&!!h&&Is(h)==="waiting",re=M(C=>{var Z;return((Z=C.overlay)==null?void 0:Z.kind)==="projects"&&C.overlay.form==="pill"}),J=M(C=>{var Z;return((Z=C.overlay)==null?void 0:Z.kind)==="commands"}),ie=d.jsxs("div",{className:"phone-title",children:[N&&(p.length>1||P>1)?d.jsxs("span",{className:"phone-drop phone-switch",children:[d.jsxs(Be,{tone:"chrome",on:re,onClick:()=>r({a:"toggle",overlay:{kind:"projects",form:"pill"}}),children:[d.jsx("span",{className:"phone-name",children:A}),d.jsx(kt,{name:"caret",className:"icon-inline"})]}),re&&d.jsx(Nw,{form:"pill",anchored:{margin:6}})]}):d.jsx("span",{className:"phone-name",children:A}),H&&d.jsx("span",{className:We("phone-sub",Q&&"phone-sub-asks"),children:H})]}),ve=T&&d.jsxs(Be,{size:"md",tone:"primary",onClick:()=>{const C=c8(y,m,_);if(!C)return;if(C.origin===null)return r({a:"activate",id:C.activate});const Z=o.get(C.origin);Z&&(Z.store.dispatch({a:"activate",id:C.activate}),o.activate(C.origin))},children:[T.n," ",T.tier]});return d.jsxs("div",{className:"phone-bar",children:[d.jsxs("div",{className:"phone-bar-row",children:[!N&&d.jsx(Ot,{icon:"back",label:"Worktrees",tone:"chrome",onClick:()=>r({a:"screen",to:"home"})}),t?d.jsx("div",{className:"phone-tabs",children:t}):ie,!t&&ve,N&&E&&d.jsx(Ot,{icon:"plus",label:"New worktree",tone:"chrome",onClick:()=>r({a:"activate",id:E.id})}),d.jsxs("span",{className:"phone-drop",children:[d.jsx(Ot,{icon:"more",label:"Menu",tone:"chrome",on:J,onClick:()=>r({a:"toggle",overlay:{kind:"commands"}})}),J&&d.jsx(vT,{anchored:{flip:"align",margin:6},trailing:d.jsx(Ot,{icon:"close",label:"Close",tone:"chrome",onClick:()=>r({a:"close"})})})]})]}),t&&!n&&d.jsx("div",{className:"phone-title-seat","data-away":l||void 0,children:d.jsxs("div",{className:"phone-title-strip",children:[ie,ve]})})]})}const Gd="toyonDepth",WT="toyonOver",mm=-1;function gm(e){if(e.frame!=="phone"||!e.heard)return null;if(!(e.screen!=="home"&&(yo(e,e.activeId)!==null||Oo(e)!==null)))return 0;const n=dn(e,e.activeId)!==null&&!Io(e)&&Oo(e)===null;return 1+(e.screen==="changes"||e.screen==="preview"&&n?1:0)+(e.editor?1:0)}const KT=(()=>{const e=new Set;return{watch(t){return e.add(t),()=>e.delete(t)},tell(t){for(const n of e)n(t)}}})(),km=e=>{const t=e&&typeof e=="object"?e[Gd]:void 0;return typeof t=="number"?t:null},V7=e=>!!e&&typeof e=="object"&&e[WT]===!0;function ZT(e,t=window,n=wl,r=KT){const o=t.history;let i=km(o.state)??mm,l=km(o.state)!==null,c=null;const u=()=>{const N=n.open();c&&!N.includes(c)&&(c=null);for(let j=N.length-1;j>=0;j--){const $=N[j];if($!=null&&$.dismiss&&$!==c)return $}return null};let p=!1;const h=()=>{const N=gm(e.getState());if(N===null||p)return;l||(o.replaceState({[Gd]:mm},""),l=!0);const j=N+(u()?1:0);if(j!==i)if(j>i){for(let $=i+1;$<=j;$++)o.pushState({[Gd]:$,[WT]:$>N},"");i=j}else o.go(-1),p=!0};let m=!1;const g=()=>{m||(m=!0,queueMicrotask(()=>{m=!1,h()}))},w=(N,j,$)=>{const P=u();if(P){c=P,n.shut(P);return}const R=$===0?"home":N.editor&&$===j-1?N.screen:"chat";e.dispatch({a:"screen",to:R})},y=N=>{const j=p;p=!1,i=km(N.state)??mm;const $=e.getState(),P=gm($);if(P===null)return;if(i<0){o.pushState({[Gd]:0},""),i=0,h();return}if(j){h();return}const R=P+(u()?1:0);R!==i&&(R>i?w($,P,i):R===0&&$.activeId&&!V7(N.state)&&e.dispatch({a:"screen",to:"chat"}),h())},b=N=>{if(p){p=!1,h();return}const j=e.getState(),$=gm(j);$===null||$===0||j.screen==="preview"&&!j.editor&&$===2||N.dir==="forward"||w(j,$,$+(u()?1:0)-1)};t.addEventListener("popstate",y);const _=e.subscribe(h),T=n.watch(g),E=r.watch(b);return h(),()=>{t.removeEventListener("popstate",y),_(),T(),E()}}function Y7({gated:e,active:t,url:n,hidden:r}){const o=pk(t),i=dD(io(),o?n:null,e),l=S.useRef(null);return S.useEffect(()=>{if(!i)return;const c=new URL(i,location.href).origin,u=p=>{var m,g;if(p.source!==((m=l.current)==null?void 0:m.contentWindow)||p.origin!==c||!((g=p.data)!=null&&g.__toyon))return;const h=lE(p.data);(h==null?void 0:h.type)==="traversed"&&KT.tell({dir:h.dir??null})};return window.addEventListener("message",u),()=>window.removeEventListener("message",u)},[i]),d.jsx("div",{className:"phone-preview",hidden:r,children:o&&i?d.jsx("iframe",{ref:l,className:"phone-preview-frame",src:i,title:t.worktree.title}):d.jsx(ds,{wide:!0,children:d.jsx("p",{className:"status-line",children:rk(t)})})})}const X7=Qg();function Q7(){const e=S.useRef(null);FL(e),BL(e);const t=ut(),n=M(R=>R.screen),r=$s(),o=fa(),i=Sk(),l=M(R=>R.editor),c=M(R=>R.remote),u=ru(),p=M(R=>R.connected),h=M(R=>R.heard),m=M(R=>R.connectFailure),g=Si(),w=io(),y=Jo(),b=M(R=>R.incompatible),_=YS({connected:p,heard:h,connectFailure:m,hasToken:w.serving?X7:!0,projectChord:Dt("project"),title:(r==null?void 0:r.worktree.title)??null,machine:w.serving?null:y.displayName(w.origin)}),T=n!=="home"&&(r!==null||o!==null||i!==null),E=T&&!u&&!o?r:null,{host:N}=Dr(),j=E?TE(E.worktree.id,E.worktree.proxyPort,c,N):null,$=n==="preview"&&!E?"chat":n,P=[{id:"chat",label:"chat"},...E&&j?[{id:"preview",label:"preview",trail:d.jsx(Ot,{icon:"external",label:"Open in browser",tone:"chrome",onClick:()=>fD(w,j,qm(w,c))})}]:[],{id:"changes",label:"code"}];return d.jsxs("div",{ref:e,className:"app phone","data-chat-side":"left","data-touch":g||void 0,"data-hover":!g||void 0,children:[d.jsx(HS,{}),d.jsx(qS,{}),d.jsx(G7,{screen:T?"chat":"home",fold:$!=="chat"||l!==null,tabs:T&&_===null&&d.jsx(Xf,{fill:!0,segmented:!0,owner:"phone-tabs",label:"worktree",items:P,current:$,onPick:R=>t({a:"screen",to:R})})}),d.jsx("div",{className:"phone-screen",children:d.jsxs("div",{className:"center-root",children:[b&&!w.serving?d.jsx(VS,{foreign:y.displayName(w.origin)}):_!==null?d.jsx(ds,{wide:!0,children:d.jsx("p",{className:We("status-line",_.live&&"live-text"),children:_.text})}):T?l?d.jsx(RT,{editor:l,placement:"screen"}):$==="chat"?d.jsx(Ic,{placement:"screen",archived:o,found:i}):$==="changes"?d.jsx(g_,{placement:"screen"}):null:d.jsx(HT,{placement:"screen"}),E&&j&&d.jsx(Y7,{gated:qm(w,c),active:E,url:j,hidden:$!=="preview"||l!==null},E.worktree.id),d.jsx(FT,{})]})})]})}const J7=640,eH=1e3,qT=`(max-width: ${J7}px), ((hover: none) and (max-width: ${eH}px))`,GT="(hover: none)",VT=()=>{var e;return(e=window.matchMedia)!=null&&e.call(window,qT).matches?"phone":"desk"},tH=()=>{var e;return((e=window.matchMedia)==null?void 0:e.call(window,GT).matches)??!1};function nH(e){const t=(o,i)=>{var u;const l=(u=window.matchMedia)==null?void 0:u.call(window,o);if(!l)return()=>{};const c=p=>i(p.matches);return l.addEventListener("change",c),()=>l.removeEventListener("change",c)},n=t(qT,o=>e.dispatch({a:"frame",v:o?"phone":"desk"})),r=t(GT,o=>e.dispatch({a:"touch",v:o}));return()=>{n(),r()}}function rH(){try{const e=localStorage.getItem(qe.theme);if(e){const t=JSON.parse(e);if(t!=null&&t.colors&&typeof t.colors.surface0=="string")return t}}catch{}return eu}function YT(e,t={}){var o;const n=document.documentElement;for(const[i,l]of Object.entries(MM(e)))n.style.setProperty(i,l);n.style.colorScheme=e.kind,n.dataset.theme=e.kind;const r=VT()==="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(qe.theme,JSON.stringify(e))}catch{}}function XT(e){const t=Yg(e);return{type:"theme",accent:t,accentFg:HM(t)}}function oH(){var e;return((e=window.matchMedia)==null?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)??!0}const sH=12*36e5;function iH(){try{const e=localStorage.getItem(qe.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<sH?{dark:!t.dark,until:0}:null}catch{return null}}function aH(e){try{localStorage.setItem(qe.daylight,JSON.stringify(e))}catch{}}function lH(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 cH(e,t){return{word:`what's new in ${t}`,text:`Toyon updated from ${e} to ${t} since you last opened it here. Press to read what changed`}}function Qx(e,t){return t==="reading"?"Reading the release notes":`No release notes could be read from Toyon ${e}.`}function uH(){const e=Dr(),t=M(i=>i.version),[n,r]=S.useState(void 0);S.useEffect(()=>{let i=!0;return eP(e).then(l=>{i&&r(l)}),()=>{i=!1}},[e]);const o=rh(n??"",{keepHtml:!0});return n?d.jsx("div",{className:"notes-page",children:d.jsx($T,{html:o})}):d.jsx(ds,{wide:!0,children:d.jsx("p",{className:"status-line",children:n===void 0?d.jsx("span",{className:"live-text",children:Qx(t,"reading")}):Qx(t,"missing")})})}function jg(e,t){return[{id:"copy-name",label:"copy name",detail:e,onClick:()=>en(e)},{id:"copy-value",label:"copy value",detail:t,onClick:()=>en(t)}]}function Cg(e){return[{id:"copy-value",label:"copy value",detail:e,onClick:()=>en(e)}]}function dH(e,t,{sock:n},r){return t?zn([[{id:"source",label:"open source",onClick:r}],Qo(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id,path:t}),Xo(n)),[{id:"copy-path",label:"copy path",onClick:()=>en(t)}]]):[]}function Xc(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 fH(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());return t?t[1].length===4||t[1].length===8:!1}function Jx([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 QT(e,t){if(fH(e))return null;const n=Xc(e);if(!n)return null;const r=Xc(t);if(!r)return null;const[o,i]=[Jx(n),Jx(r)];return`${((Math.max(o,i)+.05)/(Math.min(o,i)+.05)).toFixed(2)}:1`}function hH({worktreeId:e,height:t,full:n,onToggleFull:r,onDragStart:o}){const i=ut(),l=it(),c=M(p=>Ro(p,e).design);S.useEffect(()=>{c||l==null||l.send({t:"design-scan",worktreeId:e})},[c,e,l]),S.useEffect(()=>()=>an.post(e,{type:"highlight-clear"}),[e]);const u={outline:p=>an.post(e,p),clear:()=>an.post(e,{type:"highlight-clear"}),open:p=>er({dispatch:i},{worktreeId:e,path:p})};return d.jsx(_w,{kind:"design",className:We("design-pane",n&&"full"),height:n?void 0:t,resizable:!n,onDragStart:o,title:c?d.jsx("span",{children:kH(c)}):void 0,onClose:()=>i({a:"toggle-design"}),closeHint:Dt("design"),full:n,onToggleFull:r,actions:d.jsxs(Be,{variant:"outline",onClick:()=>l==null?void 0:l.send({t:"design-scan",worktreeId:e}),"data-tip":"Scan this worktree again",children:[d.jsx(kt,{name:"reload",className:"icon-inline"})," rescan"]}),children:c?d.jsxs("div",{className:"design-body",style:gH,onMouseLeave:u.clear,children:[c.tokens.length===0&&c.literals.length>0?d.jsx(EH,{literals:c.literals,outline:u.outline,clear:u.clear}):d.jsx(bH,{tokens:c.tokens,coverage:c.coverage,outline:u.outline,clear:u.clear}),d.jsx($H,{index:c,outline:u.outline,clear:u.clear,onOpen:u.open}),d.jsx(RH,{index:c,outline:u.outline,clear:u.clear,onOpen:u.open})]}):d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"reading the design system"})})})}const pH=720,mH=132,gH={"--design-column":`${pH}px`,"--design-cell":`${mH}px`};function kH(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 nl=e=>`${e} use${e===1?"":"s"}`;function ah({title:e,note:t,children:n}){return d.jsxs("section",{className:"design-section",children:[d.jsxs("h2",{className:"design-h",children:[e,t&&d.jsx("span",{className:"design-note",children:t})]}),n]})}function Sf({children:e}){return d.jsx("p",{className:"design-gap",children:e})}const wH=[{kind:"font",label:"type"},{kind:"color",label:"color"},{kind:"length",label:"size & radius"},{kind:"shadow",label:"shadow"},{kind:"other",label:"computed"}];function yH(e){return e.find(t=>t.kind==="color"&&Xc(t.resolved??t.value)!==null)}function vH(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 bH({tokens:e,coverage:t,outline:n,clear:r}){const o=yH(e),i=o&&(o.resolved??o.value),l=new Map;for(const u of e){const p=(u.resolved??u.value).trim().toLowerCase();l.set(p,[...l.get(p)??[],u.name])}const c=u=>(l.get((u.resolved??u.value).trim().toLowerCase())??[]).filter(p=>p!==u.name);return d.jsx(ah,{title:"Tokens",children:e.length===0?d.jsx(Sf,{children:vH(t)}):wH.map(({kind:u,label:p})=>{const h=e.filter(g=>g.kind===u);if(h.length===0)return null;const m=ej(h.map(g=>g.value));return d.jsxs("div",{className:"design-group",children:[u!=="font"&&d.jsx("span",{className:"design-group-name",children:p}),u==="font"?d.jsx(tj,{groups:jH(h),outline:n,clear:r}):d.jsx("div",{className:"design-breakout",style:JT(h.length),children:d.jsx("div",{className:"design-grid",children:h.map(g=>{const w=g.resolved??g.value,y=g.kind==="color"&&i?QT(w,i):null;return d.jsx(nj,{kind:g.kind,name:g.name,lines:g.resolved?[g.value,g.resolved]:[g.value],actual:w,ratio:y,largest:m,tipText:AH(g,y,o,c(g)),menu:()=>jg(g.name,w),outline:n,clear:r},g.name)})})})]},u)})})}const xH=[{role:"color",kind:"color",label:"color"},{role:"radius",kind:"length",label:"radius"},{role:"shadow",kind:"shadow",label:"shadow"}];function EH({literals:e,outline:t,clear:n}){const r=e.find(i=>i.ground&&Xc(i.value)!==null),o=CH(e);return d.jsxs(ah,{title:"Values",note:"written out in the rules; no custom properties",children:[o.length>0&&d.jsx("div",{className:"design-group",children:d.jsx(tj,{groups:o,outline:t,clear:n})}),xH.map(({role:i,kind:l,label:c})=>{const u=e.filter(h=>h.role===i);if(u.length===0)return null;const p=ej(u.map(h=>h.value));return d.jsxs("div",{className:"design-group",children:[d.jsx("span",{className:"design-group-name",children:c}),d.jsx("div",{className:"design-breakout",style:JT(u.length),children:d.jsx("div",{className:"design-grid",children:u.map(h=>{const m=l==="color"&&r?QT(h.value,r.value):null;return d.jsx(nj,{kind:l,name:h.value,lines:[nl(h.uses)],actual:h.value,ratio:m,largest:p,tipText:IH(h,m,r),menu:()=>Cg(h.value),outline:t,clear:n},h.value)})})})]},i)})]})}function JT(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 ej(e){return e.reduce((t,n)=>Math.max(t,Math.abs(Number.parseFloat(n))||0),0)}const SH=["color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color","outline-color"];function _H(e,t){if(!e)return[];const n=getComputedStyle(e);return t.map(r=>[r,n.getPropertyValue(r)])}const Ag=e=>(e.split(",")[0]??e).replace(/["']/g,"").trim();function NH(e){const t=/^[1-9]00\s+([\d.]+)px(?:\s*\/\s*([\d.]+)(px)?)?\s+(.+)$/.exec(e.trim());if(!t)return{family:Ag(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:Ag(t[4]??""),size:n,lead:o}}function wm(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 TH(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 jH(e){const t=e.map(n=>({token:n,actual:n.resolved??n.value,...NH(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}
|
|
256
|
+
${o.actual}`:void 0,menu:()=>o?jg(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}
|
|
257
|
+
${i.actual}`,menu:()=>jg(i.token.name,i.actual)}))}})}function CH(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(c=>c.value===o),l=o==="initial"?"default face":Ag(o);return{family:l,stack:o,name:i?nl(i.uses):void 0,label:l,tipText:i?`${i.value}
|
|
258
|
+
${nl(i.uses)}: ${i.selectors.join(", ")}`:void 0,menu:()=>i?Cg(i.value):[],rows:n.filter(c=>(c.family??"initial")===o).sort((c,u)=>wm(u.value)-wm(c.value)).map(c=>{const u=wm(c.value),p=TH(c.lead,u),h=c.value.endsWith("px")?`${u}`:c.value;return{key:`${c.value}/${c.lead??""}`,sample:`${l} ${h}${p===null?"":`/${p}`}`,style:{fontFamily:o,fontSize:c.value,lineHeight:c.lead},name:nl(c.uses),label:c.value,tipText:`${c.value}${c.lead?` / ${c.lead}`:""}
|
|
259
|
+
${nl(c.uses)}: ${c.selectors.join(", ")}`,menu:()=>Cg(c.value)}})}})}function tj({groups:e,outline:t,clear:n}){const r=(i,l,c)=>t({type:"highlight-computed",props:_H(i.currentTarget.querySelector(".design-face-sample"),l?["font-family","font-size","line-height"]:["font-family"]),match:"all",label:c}),o=vn("design");return d.jsx("div",{className:"design-faces",children:e.map(i=>d.jsxs("div",{className:"design-face-group",children:[d.jsxs("div",{className:"design-face-head row-edge",onMouseEnter:l=>r(l,!1,i.label),onMouseLeave:n,...o.contextMenu(i.menu),...i.tipText?Ut(i.tipText,void 0,{placement:"follow"}):{},children:[d.jsx("span",{className:"design-face-sample design-face-family",style:{fontFamily:i.stack},children:i.family}),i.name&&d.jsx("span",{className:"design-face-name row-dim",children:i.name})]}),i.rows.map(l=>d.jsxs("div",{className:"design-face row-edge",onMouseEnter:c=>r(c,!0,l.label),onMouseLeave:n,...o.contextMenu(l.menu),...Ut(l.tipText,void 0,{placement:"follow"}),children:[d.jsx("span",{className:"design-face-sample",style:l.style,children:l.sample}),d.jsx("span",{className:"design-face-name row-dim",children:l.name})]},l.key))]},i.stack))})}function nj({kind:e,name:t,lines:n,actual:r,ratio:o,largest:i,tipText:l,menu:c,outline:u,clear:p}){const h=e==="color"&&Xc(r)!==null,m=e==="length"?Number.parseFloat(r):Number.NaN,g=vn("design");return d.jsxs("div",{className:"design-cell","data-kind":e,...g.contextMenu(c),onMouseEnter:h?w=>{const y=w.currentTarget.querySelector(".design-fill"),b=y?getComputedStyle(y).backgroundColor:"";u({type:"highlight-computed",props:SH.map(_=>[_,b]),match:"any",label:t})}:void 0,onMouseLeave:h?p:void 0,...Ut(l),children:[e==="color"&&d.jsx("div",{className:"design-sample",children:h&&d.jsx("span",{className:"design-fill",style:{background:r}})}),d.jsxs("div",{className:"design-plate",children:[d.jsx("span",{className:"design-cell-name",children:t}),n.map((w,y)=>d.jsxs("span",{className:"design-cell-line",children:[d.jsx("span",{className:"design-cell-value",children:w}),y===0&&o&&d.jsx("span",{className:"design-cell-note",children:o})]},w)),Number.isFinite(m)&&i>0&&d.jsx("span",{className:"design-scale",style:{width:`${Math.max(2,Math.abs(m)/i*100)}%`}})]})]})}function AH(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(`
|
|
260
|
+
`)}function IH(e,t,n){const r=[e.value,`${nl(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(`
|
|
261
|
+
`)}function rj({shared:e,rest:t}){return e.length===0?d.jsx("ul",{className:"design-rows",children:t}):d.jsxs(d.Fragment,{children:[d.jsx("ul",{className:"design-rows",children:e}),t.length>0&&d.jsxs("details",{className:"design-tail",children:[d.jsxs("summary",{className:"row-edge",children:[d.jsx("span",{className:"design-count row-dim",children:t.length}),"used once or never"]}),d.jsx("ul",{className:"design-rows",children:t})]})]})}function $H({index:e,outline:t,clear:n,onOpen:r}){const{components:o,typed:i}=e;if(o.length===0)return null;const l=o.filter(p=>p.imports>=2),c=o.filter(p=>p.imports<2),u=p=>d.jsx(oj,{count:p.imports,name:p.name,path:p.path,onEnter:()=>t({type:"highlight-file",path:p.path,ranges:null}),onLeave:n,onOpen:()=>r(p.path),children:p.variants.length>0&&d.jsx("span",{className:"design-variants",children:p.variants.map(h=>d.jsxs("span",{className:"design-variant",children:[h.prop,": ",h.values.join(" · ")]},h.prop))})},`${p.path}:${p.name}`);return d.jsxs(ah,{title:"Components",note:`${l.length} reused of ${o.length}`,children:[!i&&d.jsx(Sf,{children:"No TypeScript in this project, so the values each prop allows are not listed."}),d.jsx(rj,{shared:l.map(u),rest:c.map(u)})]})}function RH({index:e,outline:t,clear:n,onOpen:r}){const{classes:o,coverage:i}=e,l=o.filter(g=>g.uses>0),c=o.filter(g=>g.uses>=2),u=o.filter(g=>g.uses<2),p=c.filter(g=>g.unwrapped).length,h=o.length?`${c.length} reused of ${o.length}`+(p?`, ${p} with no component of their name`:""):void 0,m=g=>d.jsx(OH,{cls:g,outline:t,clear:n,onOpen:r},g.name);return d.jsx(ah,{title:"Classes",note:h,children:o.length===0?d.jsx(Sf,{children:"No stylesheet in this project defines a class. Utility-first CSS generates its own."}):l.length===0?d.jsx(Sf,{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."}):d.jsx(rj,{shared:c.map(m),rest:u.map(m)})})}function OH({cls:e,outline:t,clear:n,onOpen:r}){return d.jsx(oj,{count:e.uses,name:`.${e.name}`,path:e.path,onEnter:()=>t({type:"highlight-selector",selector:`.${e.name}`,label:`.${e.name}`}),onLeave:n,onOpen:()=>e.path&&r(e.path),children:e.unwrapped&&d.jsx("span",{className:"design-tag",children:"no component"})})}function oj({count:e,name:t,path:n,onEnter:r,onLeave:o,onOpen:i,children:l}){const c=$s(),u=it();ut();const p=vn("design");return d.jsx("li",{children:d.jsxs("button",{type:"button",className:"design-row row-edge",onMouseEnter:r,onFocus:r,onMouseLeave:o,onBlur:o,onClick:i,disabled:!n,...p.contextMenu(()=>c?dH({id:c.worktree.id},n,{sock:u},i):[]),children:[d.jsx("span",{className:"design-count row-dim",children:e}),d.jsx("span",{className:"design-name",children:t}),d.jsx("span",{className:"design-path row-dim",children:n}),l]})})}function MH({worktreeId:e,procs:t,borrowed:n,login:r,current:o,onRestart:i}){const l=it();ut();const c={sock:l},u=(h,m)=>d.jsx(Ot,{icon:"reload",label:m,onClick:()=>i(h)}),p={id:Cs,label:"login",tip:Ut("The agent's login; it closes once you are in",void 0,{placement:"top"}),trail:u(Cs,"Run the login again")};return r&&o===Cs?[p]:[{id:Ao,label:"shell",tip:Ut("A shell in this worktree",void 0,{placement:"top"}),menu:()=>RN(e,c),trail:u(Ao,"Restart the shell")},...r?[p]:[],...t.map(h=>({id:h.name,label:h.name,lead:d.jsx("span",{className:`dot ${h.status}`}),tip:Ut($P(h.status),void 0,{placement:"top",dot:h.status,name:h.name,detail:h.command,aside:[`:${h.port}`]}),menu:()=>fw(h,e,c),trail:u(h.name,`Restart ${h.name}`)})),...n.map(h=>({id:h,label:h,lead:d.jsx("span",{className:"dot borrowed"}),tip:Ut(`${h} runs on main for every worktree; this one reaches it at its usual address`,void 0,{placement:"top"})}))]}const PH=S.lazy(()=>Eg(()=>import("./XTerm-xxm4nCyN.js"),__vite__mapDeps([3,4]))),LH=[];function DH({worktreeId:e,opened:t,height:n,onDragStart:r}){const o=ut(),i=it(),l=Hf(),c=M(H=>H.connected),u=M(H=>H.focusTerm),p=$s(),h=(p==null?void 0:p.procs)??[],m=(p==null?void 0:p.borrowed)??LH,g=(p==null?void 0:p.login)??!1,w=Rt(e,"termStream"),y=M(H=>{var Q;return((Q=H.termRun)==null?void 0:Q.id)===e&&w===Ao?H.termRun.command:null}),[b,_]=S.useState(null),T=m.includes(w);S.useEffect(()=>{w===Ao||(w===Cs?g:h.some(Q=>Q.name===w)||m.includes(w))||o({a:"term-stream",id:e,stream:Ao})},[h,m,g,w,e,o]);const E=H=>{H!==w&&(_(null),o({a:"term-stream",id:e,stream:H}))},N=S.useRef(!1),[j,$]=S.useState(0),P=H=>{H===Ao&&H===w&&(N.current=!0),i==null||i.send({t:"term-restart",worktreeId:e,stream:H}),H===Cs&&H===w&&(_(null),$(Q=>Q+1))},R=(H,Q)=>{if(H)return _(null);if(N.current){N.current=!1,$(re=>re+1);return}_({code:Q})},A=MH({worktreeId:e,procs:h,borrowed:m,login:g,current:w,onRestart:P}),O=S.useRef(!t),B=!O.current;return S.useEffect(()=>{O.current=!1},[]),d.jsxs(_w,{kind:"terminal",className:"term-pane",height:n,onDragStart:r,tabs:{items:A,current:w,onPick:E,font:"mono",owner:"terminal",label:"terminal streams"},onClose:()=>o({a:"toggle-terminal"}),closeHint:Dt("terminal"),children:[d.jsxs("div",{className:"term-body",children:[T&&d.jsx(zc,{pane:!0,title:`${w} runs on main`,body:"Every worktree reaches main's copy until its own changes touch it, or until asked.",action:d.jsx(Be,{variant:"outline",onClick:()=>i==null?void 0:i.send({t:"own-procs",worktreeId:e,names:[w]}),children:"run it here"})}),d.jsx(Ok,{pane:!0,children:d.jsx(S.Suspense,{fallback:d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"loading terminal"})}),children:d.jsx(PH,{worktreeId:e,stream:w,theme:l,sock:i,connected:c,focusOnMount:B,focusReq:u,onAlive:R,run:y,onRan:()=>o({a:"term-ran"}),onEscape:()=>o({a:"toggle-terminal"})},`${w}:${j}`)})})]}),b!==null&&!T&&d.jsx(zc,{pane:!0,title:w===Ao?"the shell exited":w===Cs?"the login did not finish":`${w} exited`,body:b.code===void 0?void 0:`exit code ${b.code}`,action:d.jsx(Be,{variant:"outline",onClick:()=>P(w),children:"restart"})})]})}function zH(e){return e==="reserved"?"checking out a fresh worktree":e==="warming"?"copying dependencies and running setup":"starting dev servers"}const FH="preview off; it starts when the agent writes a file";function BH({worktree:e,log:t}){const n=it(),r=ut(),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"),c=M(b=>b.clientId),u=Uc(e,"setup"),p=u&&u.status!=="terminated"?u:null,h=ra(Bk(p??void 0)?p==null?void 0:p.since:void 0),m=!!e.worktree.parked&&o.length===0,g=()=>n==null?void 0:n.send({t:"preview-start",worktreeId:e.id}),w=p&&(p.status==="running"||p.status==="detached"),y=()=>n==null?void 0:n.send({t:"fix-preview",worktreeId:e.id,clientId:c});return d.jsxs(ds,{wide:!0,children:[o.length===0?d.jsx("div",{className:"status-line",children:p?d.jsx("span",{className:"live-text","data-tip":Ym[p.status],children:cf("setup",p,h)}):m?FH:d.jsx("span",{className:"live-text",children:zH(e.worktree.phase)})}):d.jsx("ul",{className:"boot-procs",children:o.map(b=>d.jsxs("li",{className:We("boot-proc",(b.status==="crashed"||b.status==="unreachable")&&"boot-bad"),children:[d.jsx("span",{className:"boot-name",children:b.name}),d.jsx("span",{className:"boot-status",children:UH(b)}),(b.status==="crashed"||b.status==="unreachable")&&d.jsx(Be,{variant:"outline",onClick:()=>i(b),children:"restart"}),b.detail&&b.status!=="asleep"&&d.jsx("div",{className:"boot-detail",children:b.detail})]},b.name))}),m&&d.jsx("div",{className:"status-actions",children:d.jsx(Be,{variant:"outline",size:"lg",onClick:g,children:"start preview"})}),w&&d.jsx("div",{className:"status-actions",children:d.jsx(Be,{variant:"outline","data-tip":h_("setup"),onClick:()=>n==null?void 0:n.send({t:"run-stop",worktreeId:e.id,kind:"setup"}),children:"stop setup"})}),l&&d.jsxs("div",{className:"status-actions",children:[e.agent==="idle"&&d.jsx(Be,{variant:"outline",size:"lg",onClick:y,children:"ask the agent to fix it"}),d.jsx(Be,{onClick:()=>r({a:"open",overlay:{kind:"setup",repoId:e.repoId}}),children:"edit setup"})]}),t.length>0&&d.jsx("pre",{className:"status-tail",children:t.slice(-30).map(b=>`[${b.proc}] ${b.line}`).join(`
|
|
262
|
+
`)})]})}function UH(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 HH(e){const{leaving:t,arriving:n}=e;return!t||!n||t===n||n!==e.carryTo?null:e.repoOf(t)===e.repoOf(n)?t:null}function e1(e){if(!e)return"/";try{const t=new URL(e);return`${t.pathname}${t.search}${t.hash}`}catch{return"/"}}function WH(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 KH({active:e}){const t=ut(),n=it(),r=Nl(),o=M(c=>c.home),i=e.worktree.title,l=()=>{r!=null&&r.made&&(t({a:"new-project",v:{...dk({mode:r.made==="git"?"init":"create",name:r.name,parent:PN(r.path,o)??r.path}),phase:"unmaking",repoId:r.id}}),t({a:"move-box",from:e.worktree.id,to:pl}),n==null||n.send({t:"unmake-repo",repoId:r.id}))};return d.jsx(ds,{anchor:"line",foot:d.jsx("div",{className:"composer view-foot",children:d.jsx(Ac,{active:e,greenfield:!0})}),children:d.jsx("p",{className:"form-title",children:r!=null&&r.made?d.jsx(Be,{variant:"inline",onClick:l,...Ut("Rename or move this project"),children:i}):i})})}function ZH({pending:e}){const t=ut(),n=it(),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]),d.jsxs(ds,{wide:!0,children:[d.jsxs("p",{className:"status-line",children:[r?"could not import":"importing"," ",e.name]}),d.jsxs("p",{children:["from ",d.jsx("code",{children:e.url})," into ",d.jsx("code",{children:e.parent})]}),r?d.jsx("p",{className:"import-error",children:e.error}):d.jsx("p",{className:"hint",children:"the whole history is cloned, so worktrees, land and graft all work on it straight away."}),d.jsx("div",{className:"status-tail",ref:i,children:e.lines.length===0&&!r?d.jsx("span",{className:"live-text",children:"starting git"}):e.lines.map((l,c)=>d.jsx("div",{children:l},c))}),d.jsx("div",{className:"status-actions",children:d.jsx(Be,{variant:"outline",size:"lg",onClick:o,children:r?"dismiss":"stop"})})]})}const qH=150,GH=/^[^\s@]+@[^\s@]+$/,VH=14;function YH({project:e}){var Y;const t=ut(),n=it(),r=M(q=>q.repos),o=M(q=>q.home),i=M(q=>q.folderDialog),l=M(q=>q.gitIdentity),c=M(q=>q.choosingFolder),u=M(q=>q.chosenFolder),p=M(q=>q.paths),[h,m]=S.useState({name:"",email:""}),[g,w]=S.useState(null),y=S.useRef(null),{mode:b,name:_,parent:T}=e,E=b==="clone",N=b==="init",j=e.phase==="editing",$=_.trim(),P=N||!$?null:Lc(_),R=!N&&$&&!P?MN(T,$):null,A=fg(T,o),O=R!==null&&p.query===R&&((Y=p.target)==null?void 0:Y.exists)===!0,B=!l&&!E,H=!B||h.name.trim()!==""&&GH.test(h.email.trim()),Q=j?g?"the folder you chose is already a project: open it, or choose another":!N&&!$?"name the project first":P??(O?`${A} already has a folder called ${$}`:H?null:"git needs your name and email first"):null;S.useEffect(()=>{if(!R)return;const q=setTimeout(()=>n==null?void 0:n.send({t:"browse-path",path:R}),qH);return()=>clearTimeout(q)},[R,n]),ft([e.phase],()=>{var q;e.phase==="editing"&&((q=y.current)==null||q.focus())}),ft([e.error],()=>{e.error&&t({a:"notice",id:pl,text:e.error})});const re={sock:n,dispatch:t},J=()=>{Q||!j||(t({a:"new-project-set",v:{phase:"creating"}}),qc(re,{t:"create-repo",mode:b,parent:T.trim(),name:$,...E&&e.url?{url:e.url}:{},...B?{identity:{name:h.name.trim(),email:h.email.trim()}}:{}}))},ie=q=>{const z=r.find(te=>te.path===vl(q,o));z?t({a:"activate-repo",id:z.id}):qc(re,{t:"register-repo",path:q})},ve=q=>{const z=hw(q);t({a:"new-project-set",v:{mode:"init",parent:z.parent,name:z.name}})},C=q=>{i?(t({a:"choosing-folder",v:q}),n==null||n.send({t:"choose-folder",start:T,purpose:q})):t(q==="location"?{a:"open",overlay:{kind:"choose-folder"}}:{a:"open",overlay:{kind:"projects",form:"disk"}})};ft([u==null?void 0:u.seq],()=>{var z,te;if(!c||!u)return;t({a:"choosing-folder",v:!1});const q=u.folder;if(!q){(z=y.current)==null||z.focus();return}if(c==="open"){q.kind==="project"?ie(q.path):B?ve(q.path):LN(re,q.path);return}if(w(q.kind==="project"?q.path:null),q.kind!=="project"){if(q.kind==="empty"&&!E){ve(q.path);return}t({a:"new-project-set",v:{mode:E?"clone":"create",parent:q.path}}),(te=y.current)==null||te.focus()}});const Z=N?"the folder you chose becomes the project":g?null:O?`${A} already has a folder called ${$}`:P;return d.jsxs(ds,{anchor:"line",foot:d.jsx("div",{className:"composer view-foot",children:d.jsx(Ac,{active:null,project:{name:$,why:Q,busy:!j,create:J}})}),children:[E&&d.jsx("p",{className:"new-project-url",children:e.url}),d.jsxs("div",{className:"form-head",children:[N?d.jsx("p",{className:"form-title",children:_}):d.jsx($o,{ref:y,bare:!0,font:"lead",className:"new-project-field",autoFocus:!0,spellCheck:!1,autoComplete:"off",value:_,placeholder:"Project name",disabled:!j,style:{width:`${Math.max(_.length+1,VH)}ch`},onChange:q=>t({a:"new-project-set",v:{name:q.target.value}}),onKeyDown:q=>{q.key==="Enter"&&(q.preventDefault(),t({a:"focus-chat"}))}}),d.jsxs("span",{className:"new-project-where",children:[d.jsx("span",{className:"hint",children:"in"}),d.jsx("span",{className:"new-project-parent",...Ut(T),children:A}),d.jsx(Ot,{icon:"folder",label:i?"Choose in Finder":"Choose a folder",className:"new-project-folder",on:c==="location",disabled:!j,onClick:()=>C("location")})]})]}),Z&&d.jsx("p",{className:"hint",children:Z}),g&&d.jsxs("p",{className:"hint",children:["the folder you chose is already a project:"," ",d.jsx(Be,{variant:"inline",autoFocus:!0,onClick:()=>ie(g),children:"open it"}),", or choose another"]}),B&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"new-project-identity",children:[d.jsx($o,{size:"md",font:"ui",rule:!0,value:h.name,placeholder:"Your name",autoComplete:"name",disabled:!j,onChange:q=>m({...h,name:q.target.value})}),d.jsx($o,{size:"md",font:"ui",rule:!0,type:"email",value:h.email,placeholder:"Email",autoComplete:"email",disabled:!j,onChange:q=>m({...h,email:q.target.value})})]}),d.jsx("p",{className:"hint",children:"git labels the work you save with these, and asks only once"})]}),!E&&j&&d.jsx(Be,{tone:"quiet",className:"new-project-open",onClick:()=>C("open"),children:"or open a folder you already have"})]})}function Va({label:e,hint:t,children:n}){return d.jsxs("label",{className:"form-row",children:[d.jsx("span",{className:"form-label",children:e}),d.jsxs("div",{className:"form-control",children:[n,t&&d.jsx("span",{className:"hint",children:t})]})]})}function XH(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(`
|
|
263
|
+
`)}function QH(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(`
|
|
264
|
+
`)}let JH=1;const ym=(e,t,n=!1)=>({id:JH++,name:e,cmd:t,shared:n}),eW=[{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 tW({repo:e,onClose:t}){const n=it(),r=Yn(),o=M(ae=>ae.clientId),i=M(ae=>ae.rows.find(G=>{var ue;return _n(G)&&G.id===((ue=ml(ae,e.id))==null?void 0:ue.id)})??null),l=M(ae=>{var G;return((G=ml(ae,e.id))==null?void 0:G.id)??null});S.useEffect(()=>{if(!t)return;const ae=G=>G.key==="Escape"&&t();return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[t]);const[c]=S.useState(()=>Object.keys(e.config.run).length>0),[u,p]=S.useState(()=>{const ae=Object.entries(e.config.run).map(([G,ue])=>ym(G,k1(ue),WC(ue)));return ae.length>0?ae:[ym("web","")]}),[h,m]=S.useState(()=>(e.config.setup??[]).join(`
|
|
265
|
+
`)),[g,w]=S.useState(()=>(e.config.teardown??[]).join(`
|
|
266
|
+
`)),[y,b]=S.useState(()=>e.config.check??""),[_,T]=S.useState(()=>fi(e.config).land),[E,N]=S.useState(()=>fi(e.config).automerge),[j,$]=S.useState(()=>fi(e.config).merge??"default"),[P,R]=S.useState(()=>qC(e.configFile)),A=GC(e.configFile,P),O=!!e.remote&&_==="pr",B=u.length>1,H=u.some(ae=>ae.name.trim()&&ae.cmd.trim()),re=!!i&&!t&&!c&&!H,J=(ae,G)=>p(u.map((ue,Le)=>Le===ae?{...ue,...G}:ue)),ie=ae=>ae.split(`
|
|
267
|
+
`).map(G=>G.trim()).filter(Boolean),ve=()=>ie(h),C=()=>ie(g),Z=()=>{const{check:ae,land:G,teardown:ue,...Le}=e.config,ke=e.remote?_:Sm,ne=j==="default"||ke!=="pr"&&j===_m?void 0:j,ge={...ke!==Sm?{route:ke}:{},...ke==="pr"&&E?{automerge:!0}:{},...ne?{method:ne}:{}};return{...Le,setup:ve(),...C().length>0?{teardown:C()}:{},...y.trim()?{check:y.trim()}:{},...Object.keys(ge).length>0?{land:ge}:{}}},Y=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...Z(),run:Object.fromEntries(u.filter(ae=>ae.name.trim()&&ae.cmd.trim()).map((ae,G)=>[ae.name.trim(),ae.shared&&G>0?{cmd:ae.cmd.trim(),from:"trunk"}:ae.cmd.trim()]))},kind:P}),t==null||t()},q=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...Z(),run:{}},kind:P}),t==null||t()},z=()=>n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:QH(e,A)}),te=e.services,Ee=[h,g,...u.map(ae=>ae.cmd)].some(ae=>ae.includes("TOYON_WORKTREE"))||KC(e.config),Ne=te?[te.envUrl?`the database at ${te.envUrl.name} in ${te.envUrl.file}`:null,te.compose?`the stack in ${te.compose}`:null].filter(Boolean).join(" and "):"",de=()=>te&&(n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:XH(e,A,te)})),we=(ae,G)=>d.jsxs("div",{className:"setup-proc",children:[B&&d.jsx($o,{size:"md",rule:!0,className:"setup-name",value:ae.name,placeholder:"name",...Ut("Process name, shown in the status bar"),onChange:ue=>J(G,{name:ue.target.value})}),d.jsx($o,{size:"md",rule:!0,className:"setup-cmd",value:ae.cmd,placeholder:"npm run dev",onChange:ue=>J(G,{cmd:ue.target.value})}),B&&d.jsx(Ot,{icon:"close",label:"Remove",onClick:()=>p(u.filter((ue,Le)=>Le!==G))}),B&&G>0&&d.jsx(AT,{className:"setup-shared",checked:ae.shared,onChange:ue=>J(G,{shared:ue.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 d.jsxs(ds,{children:[d.jsxs("p",{className:"form-title",children:["how does ",e.name," start?"]}),te&&!Ee&&d.jsxs("p",{className:"hint setup-shared-note",children:["Worktrees will share ",Ne,", migrations included."," ",d.jsx(Be,{tone:"quiet",disabled:!i,onClick:de,children:"ask the agent to keep them apart"})]}),d.jsx(Va,{label:"install",hint:"once per new worktree; one command per line",children:d.jsx(Bc,{size:"md",rule:!0,rows:Math.max(1,h.split(`
|
|
268
|
+
`).length),value:h,placeholder:"bun install",onChange:ae=>m(ae.target.value)})}),d.jsx(Va,{label:"remove",hint:"once when a worktree goes, before its directory does; one command per line",children:d.jsx(Bc,{size:"md",rule:!0,rows:Math.max(1,g.split(`
|
|
269
|
+
`).length),value:g,placeholder:'dropdb --if-exists "app_$TOYON_WORKTREE"',onChange:ae=>w(ae.target.value)})}),d.jsx(Va,{label:"check",hint:"runs after each of the agent's turns; the work lands only when it passes",children:d.jsx($o,{size:"md",rule:!0,value:y,placeholder:"bun run check",onChange:ae=>b(ae.target.value)})}),e.remote&&d.jsx(Va,{label:"land",hint:"where a worktree's finished work goes; one way per repo",children:d.jsxs("div",{className:"setup-land",children:[d.jsx(di,{value:_,options:lA.map(ae=>({id:ae.id,label:ae.name,description:ae.description})),onChange:T,hint:"where the work goes",placeholder:"where work lands"}),O&&d.jsx(di,{value:E?"github":"you",options:uA.map(ae=>({id:ae.id,label:ae.name,description:ae.description})),onChange:ae=>N(ae==="github"),hint:"who merges the pull request",placeholder:"who merges it"})]})}),d.jsx(Va,{label:"merge",hint:O?"how GitHub merges the pull request; only what the repo allows":"how the commits arrive on main",children:d.jsx(di,{value:j==="default"&&!O?_m:j,options:[...O?[{id:"default",label:"what the repo allows",description:"the repo's allowed methods on GitHub: squash, else a merge commit, else rebase"}]:[],...cA.map(ae=>({id:ae.id,label:ae.name,description:ae.description}))],onChange:$,hint:"how the commits arrive on main",placeholder:"how the commits arrive"})}),d.jsx(Va,{label:"start",hint:d.jsxs(d.Fragment,{children:["must listen on ",d.jsx("code",{...Ut("Toyon sets a different port for each worktree"),children:"$PORT"}),e.guess&&l&&d.jsxs(d.Fragment,{children:[" · from ",d.jsx(Be,{mono:!0,tone:"quiet",...Ut(`open ${e.guess} in the editor pane`),onClick:()=>sa(r,n,l,e.guess??"",1),children:e.guess})]})]}),children:u[0]&&we(u[0],0)}),u.slice(1).map((ae,G)=>d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsx("div",{className:"form-control",children:we(ae,G+1)})]},ae.id)),d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsxs(Be,{tone:"quiet",onClick:()=>p([...u,ym("","")]),children:[d.jsx(kt,{name:"plus",className:"icon-inline"})," another process"]})]}),d.jsxs("div",{className:"form-knobs",children:[d.jsx(di,{value:P,options:eW,onChange:R,hint:"whether the settings file is committed with the repo or kept out of git",placeholder:"committed or kept local"}),d.jsx("span",{className:"form-sign",children:A}),t&&d.jsx(Be,{onClick:t,children:"cancel"}),(!c||t)&&d.jsx(Be,{...Ut("This project has no dev server: chat, changes and the terminal work, the preview stays empty"),onClick:q,children:"no dev server"}),re&&i?d.jsx(Be,{variant:"outline",size:"lg",disabled:i.agent!=="idle",...Ut("The agent reads the repo and writes the settings file; the daemon picks it up as soon as it lands"),onClick:z,children:"let the agent work it out"}):d.jsxs(Be,{variant:"outline",size:"lg",disabled:!H,...t?Ut("Restarts every worktree of this repo. Profiles and other keys in the file are kept."):{},onClick:Y,children:[t?"save + restart":"start"," ",d.jsx(kt,{name:"forward",className:"icon-inline"})]})]})]})}function nW(e){return`${Math.round(e.w)} × ${Math.round(e.h)}`}function rW(e){return e.w>0&&e.h>0}function oW(e,t,n){S.useEffect(()=>{if(!e||!t){n(null);return}const r=new ResizeObserver(o=>{var c;const i=(c=o[o.length-1])==null?void 0:c.contentRect;if(!i)return;const l={w:i.width,h:i.height};n(rW(l)?nW(l):null)});return r.observe(e),()=>{r.disconnect(),n(null)}},[e,t,n])}const sW=1500,iW={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};class aW{constructor(t,n,r=iW){Bt(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=S0(r));const i=Pf(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)},sW)}title(t,n){const r=this.frame(t);r.title=S0(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 lW=Qg(),cW=2*6e4;function t1(e){e==null||e.setAttribute("src",e.src)}const uW=8e3;function dW(e,t){try{const n=new URL(e,t);return n.origin===new URL(t).origin?n.href:null}catch{return null}}function fW({onRoot:e}){const t=S.useRef(null),n=S.useCallback(se=>{t.current=se,e(se)},[e]),r=ut(),o=Yn(),i=it(),l=S.useRef(i);l.current=i;const[c]=S.useState(()=>new aW((se,_e,at)=>{var mt,Wt;(mt=l.current)==null||mt.send({t:"visit",worktreeId:se,path:_e,title:at}),RE((Wt=o.getState().local[se])==null?void 0:Wt.pages)&&an.post(se,{type:"links"})},(se,_e,at)=>{var mt;return(mt=l.current)==null?void 0:mt.send({t:"page-title",worktreeId:se,path:_e,title:at})}));S.useEffect(()=>()=>c.dispose(),[c]);const u=cS(),p=_l(),h=$s(),m=M(se=>se.connected),g=M(se=>se.heard),w=M(se=>se.connectFailure),y=M(se=>se.remote),{host:b}=Dr(),_=io(),T=Jo(),E=M(se=>se.editor),N=dS(),j=QL(),$=M(se=>se.notesPage),P=nu(),R=M(se=>se.layout.term)&&!P,A=M(se=>se.focusTerm),O=S.useRef(!1),B=S.useRef(A),H=!O.current||A!==B.current;S.useEffect(()=>{O.current=R&&!!p,B.current=A});const Q=ru(),re=M(se=>se.layout.design)&&!P&&!Q,J=M(se=>se.reloadReq),ie=Hf(),ve=S.useRef(ie);ve.current=ie;const C=M(se=>se.zen),Z=M(se=>{var _e;return((_e=se.dragFiles)==null?void 0:_e.at)==="centre"}),Y=S.useRef(C);Y.current=C;const q=Rt(p,"log"),z=M(se=>se.incompatible),te=e4(),Ee=M(se=>{var _e;return((_e=se.overlay)==null?void 0:_e.kind)==="setup"?se.repos.find(at=>at.id===se.overlay.repoId)??null:null}),Ne=(h==null?void 0:h.worktree.empty)===!0,de=!!h&&tu(h),we=te&&!Ne&&!de?te:null,ae=we??Ee,G=M(se=>se.pending.find(_e=>_e.id===se.activeImportId)??null),[ue,Le]=S.useState([]),ke=S.useMemo(()=>ue.map(se=>se.id),[ue]),ne=S.useRef(new Map),ge=S.useRef(new Map),[je,Ce]=S.useState([]),Se=S.useRef(new Set),Me=S.useRef(new Set),wt=S.useRef(se=>t1(ne.current.get(se)));S.useEffect(()=>{an.post=(se,_e)=>{var at,mt;if(_e.type==="reload"&&Se.current.has(se))return wt.current(se);(mt=(at=ne.current.get(se))==null?void 0:at.contentWindow)==null||mt.postMessage({__toyon:!0,..._e},ge.current.get(se)??"*")},an.broadcast=se=>{var _e;for(const[at,mt]of ne.current)(_e=mt.contentWindow)==null||_e.postMessage({__toyon:!0,...se},ge.current.get(at)??"*")}},[]),S.useEffect(()=>{let se=null;const _e=Wt=>{Wt.target instanceof HTMLElement&&Wt.target.tagName!=="IFRAME"&&(se=Wt.target)},at=Wt=>{Wt.relatedTarget===null&&setTimeout(()=>{document.activeElement===document.body&&(se=null)},0)},mt=Wt=>{var kn,wn,tr,fn,hn;if((kn=Wt.data)!=null&&kn.__toyon)for(const[Tt,zr]of ne.current){if(zr.contentWindow!==Wt.source)continue;if(Wt.origin!==ge.current.get(Tt))return;const pt=lE(Wt.data);if(!pt)return;switch(pt.type){case"key":window.dispatchEvent(new KeyboardEvent(pt.up?"keyup":"keydown",{key:pt.key,code:pt.code,metaKey:pt.meta,ctrlKey:!!pt.ctrl,shiftKey:!!pt.shift,altKey:!!pt.alt}));break;case"hmr":r({a:"hmr",id:Tt}),(wn=l.current)==null||wn.send({t:"page-loaded",worktreeId:Tt});break;case"loaded":Se.current.delete(Tt),Me.current.add(Tt),Ce(In=>In.includes(Tt)?In:[...In,Tt]),an.post(Tt,XT(ve.current)),an.post(Tt,{type:"zen",on:Y.current}),r({a:"hmr",id:Tt}),r({a:"page",id:Tt,url:pt.url,title:pt.title}),(tr=l.current)==null||tr.send({t:"page-loaded",worktreeId:Tt}),c.note(Tt,pt.url,pt.title);break;case"navigated":r({a:"page",id:Tt,url:pt.url,...pt.title!==void 0?{title:pt.title}:{}}),c.note(Tt,pt.url,pt.title);break;case"title":r({a:"page",id:Tt,title:pt.title}),c.title(Tt,pt.title);break;case"links":r({a:"links",id:Tt,links:pt.links});break;case"page-error":{const In=CP(pt);In&&((fn=l.current)==null||fn.send({t:"page-error",worktreeId:Tt,message:In}));break}case"picked":{const{type:In,verb:Te,site:Ge,...rt}=pt,et=Ge==="call"?{file:rt.callFile,line:rt.callLine}:{file:rt.file,line:rt.line};if(Te==="code"){r({a:"set-picking",v:!1});const cn=(hn=dn(o.getState(),Tt))==null?void 0:hn.worktree;et.file?sa(o,i,Tt,jE(et.file,cn==null?void 0:cn.path),et.line??1):i==null||i.send({t:"find-element",worktreeId:Tt,seq:Go(),element:rt.element})}else R4(o,Tt,rt);break}case"pick-cancel":r({a:"set-picking",v:!1});break;case"drag-files":pt.over?$k(o,o.getState().activeId?{at:"centre"}:null):IS(o);break;case"drop-files":DS(o,i,o.getState().activeId?{at:"centre"}:null,oD(pt.files));break;case"focus":pt.gesture?se=null:document.activeElement===zr&&(se!=null&&se.isConnected)&&se!==document.body&&se.focus();break;case"highlight-miss":console.warn(`[toyon] highlight miss on ${pt.path}: ${pt.fileMatched} elements from this file, ${pt.withSource} elements with source info on page, ranges=${JSON.stringify(pt.ranges)}`);break}return}};return window.addEventListener("message",mt),document.addEventListener("focusin",_e),document.addEventListener("focusout",at),()=>{window.removeEventListener("message",mt),document.removeEventListener("focusin",_e),document.removeEventListener("focusout",at)}},[r,o,i,c]),S.useEffect(()=>{an.broadcast({type:"zen",on:C})},[C]);const on=S.useRef(new Map);ft([J==null?void 0:J.id,J==null?void 0:J.n],()=>{if(!J)return;const{id:se}=J;clearTimeout(on.current.get(se)),on.current.set(se,setTimeout(()=>{on.current.delete(se),an.post(se,{type:"reload"})},1200))});const St=xk(),Yt=St&&!_n(St)?St:null,zt=fa(),Ht=!!h&&h.procs.some(se=>se.status==="running"),De=_k(),_t=De!==null&&De===p&&Ht;S.useEffect(()=>{var se;if(De&&_t&&!ke.includes(De)){const _e=e1((se=o.getState().local[De])==null?void 0:se.page.url);Le(at=>[...at,{id:De,path:_e}])}},[De,_t,ke,o]);const sn=u.filter(se=>_n(se)&&se.procs.some(_e=>_e.status==="asleep")).map(se=>se.id).join(" ");S.useEffect(()=>{const se=new Set(sn.split(" ").filter(Boolean));ke.some(_e=>se.has(_e))&&Le(_e=>_e.filter(at=>!se.has(at.id)))},[sn,ke]);const ln=ke.join(" ");S.useEffect(()=>{const se=ln.split(" ").filter(_e=>_e&&_e!==De).map(_e=>setTimeout(()=>Le(at=>at.filter(mt=>mt.id!==_e)),cW));return()=>{for(const _e of se)clearTimeout(_e)}},[ln,De]),S.useEffect(()=>{Ce(se=>se.every(_e=>ke.includes(_e))?se:se.filter(_e=>ke.includes(_e)))},[ke]);const lt=S.useMemo(()=>u.filter(_n).flatMap(se=>{const _e=ue.find(mt=>mt.id===se.id);if(!_e)return[];const at=TE(se.worktree.id,se.worktree.proxyPort,y,b);return[{id:se.worktree.id,port:se.worktree.proxyPort,title:se.worktree.title,url:dW(_e.path,at)??at}]}),[u,ue,y,b]),jt=qm(_,y),Kt=BS(_,lt,jt);wt.current=se=>{var at;const _e=e1((at=o.getState().local[se])==null?void 0:at.page.url);if(ue.some(mt=>mt.id===se&&mt.path!==_e)){Le(mt=>mt.map(Wt=>Wt.id===se?{...Wt,path:_e}:Wt));return}jt?Kt.renew(se):t1(ne.current.get(se))};const xn=lt.filter(se=>{var _e;return(_e=u.find(at=>at.id===se.id))==null?void 0:_e.procs.some(at=>at.status==="running")}).map(se=>se.id).join(" ");ft([xn],()=>{for(const se of xn.split(" "))Se.current.has(se)&&wt.current(se)});const Pt=M(se=>se.carryTo),[jn,Qt]=S.useState(null),[V,pe]=S.useState(De),Ye=S.useRef(null);V!==De&&(pe(De),Qt(HH({leaving:Ye.current,arriving:De,carryTo:Pt,repoOf:se=>{var _e;return((_e=u.find(at=>at.id===se))==null?void 0:_e.repoId)??null}}))),S.useEffect(()=>{if(!jn)return;const se=setTimeout(()=>Qt(null),uW);return()=>clearTimeout(se)},[jn]);const nt=De!==null&&je.includes(De),yt=WH({previewId:De,painted:nt,ready:_t,carry:jn,mounted:ke}),Jt=yt!==null&&yt!==De;S.useEffect(()=>{Ye.current=yt});const ye=yt!==null&&!ae&&!G&&!$&&!P&&!Q,[Ie,Xt]=S.useState(null),U=S.useCallback(se=>r({a:"preview-size",text:se}),[r]);oW(Ie,ye,U);const[me,ze]=ko(qe.editorHeight,0,se=>{const _e=Number(se);return Number.isFinite(_e)&&_e>=120?_e:0}),[Xe,Mt]=ko(qe.designHeight,0,se=>{const _e=Number(se);return Number.isFinite(_e)&&_e>0?_e:0}),[Nt,He]=ko(qe.designFull,!1,se=>se===null?void 0:se==="1"),[Fe,Ke]=ko(qe.editorFull,!1,se=>se===null?void 0:se==="1"),[ht,Ct]=ko(qe.termHeight,240,se=>{const _e=Number(se);return Number.isFinite(_e)&&_e>=140?_e:void 0}),Ft=M(se=>se.termTall);ft([Ft],()=>{const se=t.current;Ft&&se&&Ct(Math.max(ht,Math.round(se.clientHeight/2)))});const Zt=se=>(_e,at)=>{const mt=at.parentElement,Wt=t.current;if(!mt||!Wt)return null;let kn=0;for(const tr of Array.from(Wt.querySelectorAll(":scope > .pane")))tr!==mt&&!tr.classList.contains("full")&&(kn+=tr.offsetHeight);const wn=Math.max(Wt.clientHeight-kn-80,se);return Math.min(Math.max(mt.getBoundingClientRect().bottom-_e.clientY,se),wn)},bn=ll(Zt(120),se=>ze(Math.round(se))),On=ll(Zt(160),se=>Mt(Math.round(se))),Cn=ll(Zt(140),se=>Ct(Math.round(se))),Xn=M(se=>{var _e,at;return h&&wr(h.worktree)?((at=(_e=se.rows.find(mt=>{var Wt;return mt.repoId===h.worktree.repoId&&((Wt=mt.worktree)==null?void 0:Wt.kind)==="worktree"}))==null?void 0:_e.worktree)==null?void 0:at.title)??null:null}),Hn=ZD({connected:m,heard:g,connectFailure:w,hasToken:_.serving?lW:!0,projectChord:Dt("project"),title:(h==null?void 0:h.worktree.title)??null,machine:_.serving?null:T.displayName(_.origin),needsSetup:!!te,busy:de,treeEmpty:Ne,landsFrom:Xn});return d.jsxs("div",{className:"center-root",ref:n,children:[d.jsx("div",{className:We("center-area",Z&&"drop-over"),style:{display:!(C&&!Q)&&!zt&&!$&&(E&&Fe||re&&Nt)?"none":void 0},children:d.jsxs("div",{className:"frames-wrap",ref:Xt,children:[lt.map(se=>d.jsx("iframe",{ref:_e=>{_e?(ne.current.set(se.id,_e),ge.current.set(se.id,new URL(se.url).origin)):(ne.current.delete(se.id),ge.current.delete(se.id),Se.current.delete(se.id),Me.current.delete(se.id))},onLoad:()=>{Me.current.delete(se.id)?Se.current.delete(se.id):Se.current.add(se.id)},src:Kt.urlOf(se.id)??void 0,title:se.title,style:{display:ye&&se.id===yt?"block":"none"}},se.id)),j?d.jsx(YH,{project:j}):$?d.jsx(uH,{}):d.jsxs(d.Fragment,{children:[G&&d.jsx(ZH,{pending:G},G.id),N&&h&&!G&&d.jsx(KH,{active:h},h.worktree.id),ae&&!G&&!N&&d.jsx(tW,{repo:ae,onClose:we?void 0:()=>r({a:"close"})},`${ae.id}:${JSON.stringify(ae.config)}`),Yt&&!ae&&!G&&!zt&&d.jsx(Ic,{placement:"centre",found:Yt},Yt.id),zt&&!ae&&!G&&d.jsx(Ic,{placement:"centre",archived:zt},zt.id),!Ht&&!Yt&&!zt&&!ae&&!G&&!N&&z&&d.jsx(VS,{foreign:_.serving?void 0:T.displayName(_.origin)}),!Ht&&!Yt&&!zt&&!ae&&!G&&!N&&!z&&(Hn!==null?d.jsx(ds,{wide:!0,children:d.jsx("p",{className:We("status-line",Hn.live&&"live-text"),children:Hn.text})}):Q?d.jsx(Ic,{placement:"centre"}):Jt?null:h&&d.jsx(BH,{worktree:h,log:q}))]})]})}),E&&d.jsx(RT,{editor:E,height:Fe?"100%":me>0?me:"45%",full:Fe,onToggleFull:()=>Ke(!Fe),onDragStart:bn}),re&&p&&!zt&&!$&&d.jsx(hH,{worktreeId:p,height:Nt?"100%":Xe>0?Xe:"55%",full:Nt,onToggleFull:()=>He(!Nt),onDragStart:On},`design:${p}`),R&&p&&!zt&&!$&&d.jsx(DH,{worktreeId:p,opened:H,height:ht,onDragStart:Cn},`term:${p}`),d.jsx(FT,{})]})}function hW({width:e}){const t=M(r=>r.layout.chat),n=nu();return d.jsx(Ic,{placement:"dock",className:!t||n?"collapsed":void 0,width:e})}function pW(e,t){const n=[];return e&&(n.push(kS(e)),n.push({id:"copy-url",label:"copy URL",onClick:()=>en(e)})),zn([n,[{id:"reload",label:"reload preview",key:Dt("reload"),onClick:t.reload}]])}const mW=520,vm=8;function gW({winW:e,centre:t,leadRight:n,toolsLeft:r}){const o=t.right-t.left,i=Math.max(0,Math.min(mW,Math.floor(e*.4),o-2*vm)),l=t.left+(o-i)/2,c=n+vm,u=r-vm-i,p=Math.max(Math.min(l,u),c);return{left:Math.round(p),width:i}}function kW({center:e}){const t=OL(),n=aS(e),r=S.useRef(null);UL(r);const o=bD(),[i,l]=X0(),[c,u]=X0(),p=gW({winW:t,centre:n,leadRight:l.right,toolsLeft:u.left}),h=ut(),m=it(),g=Yn(),w=vn("bar"),y=$s(),b=ru(),_=M(re=>re.zen)&&!b,T=M(re=>re.layout.changes),E=M(re=>re.layout.chat),N=nu(),j=M(re=>re.layout.design),$=M(re=>{var J;return((J=re.overlay)==null?void 0:J.kind)==="keys"}),P=tT(),R=(y==null?void 0:y.worktree.id)??null,A=M(re=>re.archivedPage!==null||re.notesPage),O=!!y&&pk(y)&&!A,B=M(re=>re.chatSide)==="left",H=!N&&d.jsx(Ot,{icon:"branch",label:"Changes panel",hint:Dt("changes"),tone:"chrome",on:T,onClick:()=>h({a:"toggle-changes"})}),Q=!N&&!b&&d.jsx(Ot,{icon:"chat",label:"Chat panel",hint:Dt("composer"),tone:"chrome",on:E,onClick:()=>h({a:"toggle-chat"})});return d.jsxs("div",{className:"top-bar",ref:r,"data-float-up":o||void 0,children:[_&&d.jsx("span",{className:"bar-zen-title",children:(y==null?void 0:y.worktree.title)??"Toyon"}),d.jsxs("span",{className:"bar-lead",ref:i,children:[B?Q:H,d.jsx(wW,{}),P&&d.jsx(cu,{icon:"download","data-tip":"Install Toyon as an app (own window, dock icon)",onClick:()=>void P.prompt(),children:"install app"}),d.jsx(vW,{}),d.jsx(bW,{}),d.jsx(xW,{})]}),!b&&d.jsx(yW,{worktreeId:R,repoId:(y==null?void 0:y.repoId)??null,ready:O,left:p.left,width:p.width}),d.jsx("span",{className:"bar-grow"}),d.jsxs("span",{className:"bar-tools",ref:c,children:[d.jsx(EW,{}),d.jsx(Ot,{icon:"settings",label:"Settings & shortcuts",hint:Dt("keys"),tone:"chrome",on:$,"aria-controls":"keys-help","aria-expanded":$,onClick:()=>h({a:"toggle",overlay:{kind:"keys"}}),...w.contextMenu(()=>DN(g.getState(),{sock:m,dispatch:h}))}),!N&&!b&&d.jsx(Ot,{icon:"palette",label:"Design system",hint:Dt("design"),tone:"chrome",on:j,onClick:()=>h({a:"toggle-design"})}),B?H:Q,!b&&d.jsx(Ot,{icon:"zen",className:"bar-zen",label:"Full-bleed preview",hint:Dt("zen"),tone:"chrome",on:_,onClick:()=>h({a:"toggle-zen"})})]})]})}function wW(){const e=ut(),t=it(),n=Nl(),r=M(h=>h.activeRepoId),o=M(h=>h.repos),i=vn("bar"),l=()=>zn([[{id:"project",label:o.length>1?"switch project…":"open project…",key:Dt("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?sh(n,r,{sock:t,dispatch:e}):[]]),c=M(h=>{var m;return((m=h.overlay)==null?void 0:m.kind)==="projects"&&h.overlay.form==="pill"}),u=M(h=>h.heard),p=M(h=>h.newProject!==null);return d.jsxs("span",{className:"bar-project",children:[d.jsx(Be,{tone:"chrome",className:"bar-pill",on:c,...Ut(o.length>1?"Switch project":"Open a project",Dt("project")),onClick:()=>e({a:"toggle",overlay:{kind:"projects",form:"pill"}}),...i.contextMenu(l),children:d.jsx("span",{className:"bar-project-name",children:p?"new project":(n==null?void 0:n.name)??(u?"open project":"")})}),c&&d.jsx(Nw,{form:"pill"})]})}function yW({worktreeId:e,repoId:t,ready:n,left:r,width:o}){const i=Rt(e,"page").url,l=ut(),c=M(w=>{var y;return((y=w.overlay)==null?void 0:y.kind)==="routes"}),u=M(w=>w.previewSize);ft([e,n],()=>{c&&l({a:"close"})});const h=vn("bar").contextMenu(()=>n?pW(i,{reload:()=>e&&an.post(e,{type:"reload"})}):[]),m=M(w=>w.picking),g=_k();return d.jsxs("div",{className:"bar-center",style:{left:r,width:o},children:[d.jsx(Ot,{icon:"back",label:"Back",hint:Dt("back"),disabled:!n,onClick:()=>e&&an.post(e,{type:"back"}),...h}),d.jsx(Ot,{icon:"forward",label:"Forward",hint:Dt("forward"),disabled:!n,onClick:()=>e&&an.post(e,{type:"forward"}),...h}),d.jsx(Ot,{icon:"reload",label:"Reload preview",hint:Dt("reload"),disabled:!n,onClick:()=>e&&an.post(e,{type:"reload"}),...h}),d.jsxs("span",{className:"bar-route",children:[n&&e&&t?d.jsx(nB,{worktreeId:e,repoId:t,url:i,open:c},e):d.jsx($o,{className:"bar-path",value:"",readOnly:!0,disabled:!0}),u&&d.jsx("span",{className:"bar-size",children:u})]}),d.jsx(Ot,{icon:"inspect",label:"Pick an element to open its code",hint:Dt("inspect"),also:{text:"Add an element to chat",key:Dt("pick")},on:m==="code",disabled:!n||!g,onClick:()=>g&&Fc(g,m,l,"code")})]})}function cu({icon:e,busy:t,children:n,...r}){return d.jsxs(Be,{disabled:t,...r,children:[!t&&d.jsx(kt,{name:e,className:"icon-inline"}),d.jsx("span",{className:We(t&&"live-text"),children:n})]})}function vW(){const e=M(u=>u.self),t=M(u=>u.rebuilt),n=M(u=>u.repos),r=it(),o=M(u=>{var p;return((p=u.update)==null?void 0:p.restarting)!=null}),i=OT(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",c=()=>{i.reload?window.location.reload():e&&(r==null||r.send(i.build?{t:"run-after-land",repoId:e.repoId}:{t:"restart-daemon"}))};return d.jsx(cu,{icon:"reload",busy:i.busy,onClick:c,...Ut(i.text,void 0,{detail:i.detail}),children:l})}function bW(){const e=M(o=>o.update),t=M(o=>o.managed.updates),n=it(),r=DD(e);return!r||!t?null:d.jsx(cu,{icon:"reload",busy:r.busy,onClick:()=>{r.retry&&(n==null||n.send({t:"update-now"}))},...Ut(r.text),children:r.word})}function xW(){const e=ut(),t=M(nL),n=M(l=>l.ranBefore),r=M(l=>l.newProject!==null);if(!t||!n||r)return null;const{word:o,text:i}=cH(n,t);return d.jsx(cu,{icon:"book",onClick:()=>e({a:"open-release-notes"}),...Ut(i),children:o})}function EW(){const e=ut(),t=M(pL),n=M(i=>i.letIn),r=M(i=>{var l;return((l=i.overlay)==null?void 0:l.kind)==="devices"});if(!t)return null;const o=()=>e({a:"toggle",overlay:{kind:"devices"}});return n?d.jsx(Ot,{icon:"devices",label:"Your devices",tone:"chrome",on:r,"aria-expanded":r,onClick:o}):d.jsx(cu,{icon:"devices","aria-expanded":r,onClick:o,...Ut("Open this machine on your phone, and let it in"),children:"open on phone"})}function SW(e,t,n){return t==="left"?n-e.left:e.right-n}const _W="input, textarea, [contenteditable], .monaco-editor, .xterm, iframe";function NW(){const e=Yn(),t=ut(),n=it(),r=nu(),o=Si(),i=ru(),l=M(Y=>Y.zen)&&!i,c=fa(),u=M(Y=>Y.notesPage),p=!!Sk()||!!c||u,h=M(Y=>Y.layout.changes)&&!r,m=M(Y=>Y.layout.chat)&&!r&&!i&&!p,g=M(Y=>Y.chatSide),w=M(Y=>Y.railOpen),[y,b]=ko(qe.changesWidth,220,Y=>Y?_d(Number(Y),220):void 0),[_,T]=ko(qe.chatWidth,380,Y=>Y?_d(Number(Y),380):void 0),[E,N]=ko(qe.railWidth,280,Y=>Y?_d(Number(Y),280):void 0),j=(Y,q,z)=>{const te=q.classList.contains("left")?"left":"right",Ee=te==="left"?q.previousElementSibling:q.nextElementSibling;return Ee?_d(SW(Ee.getBoundingClientRect(),te,Y.clientX),z):null},$=ll((Y,q)=>j(Y,q,220),b),P=ll((Y,q)=>j(Y,q,380),T),R=ll((Y,q)=>j(Y,q,280),N),[A,O]=S.useState(null),H=vn("app").contextMenu(()=>$N(e.getState(),{sock:n,dispatch:t})),Q=d.jsx(g_,{width:y}),re=!i&&!p&&d.jsx(hW,{width:_}),J=!r&&d.jsx(HT,{width:E}),ie=Y=>!r&&w&&d.jsx("div",{className:`dock-resize ${Y}`,onPointerDown:R}),ve=g==="left",C=ve?{dock:re,open:m,drag:P}:{dock:Q,open:h,drag:$},Z=ve?{dock:Q,open:h,drag:$}:{dock:re,open:m,drag:P};return d.jsxs("div",{className:We("app",l&&"zen"),"data-chat-side":g,"data-touch":o||void 0,"data-hover":!o||void 0,onContextMenu:Y=>{Y.defaultPrevented||Y.target instanceof Element&&Y.target.closest(_W)||H.onContextMenu(Y)},children:[d.jsx(HS,{}),d.jsx(qS,{}),d.jsx(kW,{center:A}),d.jsxs("div",{className:"docks",children:[ve&&J,ve&&ie("left"),C.dock,C.open&&d.jsx("div",{className:"dock-resize left",onPointerDown:C.drag}),d.jsx(fW,{onRoot:O}),Z.open&&d.jsx("div",{className:"dock-resize right",onPointerDown:Z.drag}),Z.dock,!ve&&ie("right"),!ve&&J]})]})}function TW(e,t,n,r){if(!n)return null;const o=e.findIndex(u=>u.id===n);if(o>=0){const u=e[(o+r+e.length)%e.length];return u&&u.id!==n?{activate:u.id}:null}const i=t.findIndex(u=>u.id===n);if(i<0)return null;const l=t[i+r];if(l)return{activate:l.id};const c=e[e.length-1];return r<0&&c?{activate:c.id}:null}const jW=new Set(["design","chats"]),CW=new Set(["reload","back","forward"]),AW=new Set(["project","commands","keys","zen"]);function IW(){const e=Yn(),t=it();S.useEffect(()=>{const n=H7(h=>e.dispatch({a:"rail-peek",on:h})),r=n.end,o=h=>{e.getState().railOpen||n.press(h)},i=h=>n.keyup(h.key),l=h=>n.mods(h),c=()=>{var w,y;const h=e.getState(),g=((y=(w=document.activeElement)==null?void 0:w.closest("[data-pane]"))==null?void 0:y.dataset.pane)??(h.layout.term?"terminal":h.editor?"editor":h.layout.design?"design":null);g==="terminal"?e.dispatch({a:"toggle-terminal"}):g==="editor"?e.dispatch({a:"close-editor"}):g==="design"&&e.dispatch({a:"toggle-design"})},u=h=>{h.key!=="Escape"||!e.getState().choosingFolder||(h.stopImmediatePropagation(),t==null||t.send({t:"cancel-folder"}),e.dispatch({a:"choosing-folder",v:!1}))},p=h=>{var _,T,E,N;l(h),$C(h)&&!h.defaultPrevented&&h.preventDefault();const m=e.getState(),{dispatch:g}=e,w=j=>{const $=document.activeElement,P=!$||$===document.body||!!$.closest(".rail, .chat-input");g({a:"activate",id:j}),P&&g({a:"walked"})},y=m1(h,{guest:!!((_=document.activeElement)!=null&&_.closest(".xterm"))});if(!(m.zen&&!Io(m)&&!m.overlay&&!m.picking&&!(y&&IC.has(y.id))||(y==null?void 0:y.id)==="close"&&!ak()||(T=document.activeElement)!=null&&T.closest(".monaco-editor")&&y&&jW.has(y.id))&&!(y&&LC(y.id,document.activeElement))&&!(y&&CW.has(y.id)&&!(kc(m)&&lf(m)))){if(y){const j=h.defaultPrevented;if(h.preventDefault(),m.newProject&&!AW.has(y.id))return;switch(y.id){case"worktree":{const $=OC(y.digit,m.visible.length),P=$===null?void 0:m.visible[$];P&&w(P.id);break}case"wt-prev":case"wt-next":{const $=TW(m.visible,m.visibleDiscovered,m.activeId,y.id==="wt-next"?1:-1);$&&w($.activate),o(h);break}case"wt-unseen-prev":case"wt-unseen-next":{const $=dw(m.visible,m.activeId,y.id==="wt-unseen-next"?1:-1);$&&w($.activate),o(h);break}case"mark-unread":m.activeId&&!m.draft&&m.visible.some($=>$.id===m.activeId)&&e_(t,g,m.activeId);break;case"wt-archive":{if(h.repeat||j)break;const $=m.draft||m.archivedPage?void 0:m.visible.find(P=>P.id===m.activeId);$&&Mk(t,g).archive($);break}case"new":g({a:"open-draft"});break;case"project":g({a:"toggle",overlay:{kind:"projects",form:"center"}});break;case"quick-open":((E=m.overlay)==null?void 0:E.kind)==="quick-open"?g({a:"close"}):m.activeId&&g({a:"open",overlay:{kind:"quick-open"}});break;case"routes":((N=m.overlay)==null?void 0:N.kind)==="routes"?g({a:"close"}):lf(m)&&g({a:"open",overlay:{kind:"routes"}});break;case"reload":case"back":case"forward":{const $=kc(m);$&&an.post($,{type:y.id});break}case"pick":case"inspect":{const $=kc(m);$&&Fc($,m.picking,g,y.id==="pick"?"chat":"code");break}case"search":m.activeId&&g({a:"toggle",overlay:{kind:"search"}});break;case"refs":m.activeRepoId&&g({a:"toggle",overlay:{kind:"refs"}});break;case"chats":m.activeRepoId&&g({a:"toggle",overlay:{kind:"chats"}});break;case"commands":g({a:"toggle",overlay:{kind:"commands"}});break;case"zen":g({a:"toggle-zen"});break;case"close":!(m.zen&&!Io(m))&&!m.overlay&&c();break;case"changes":g(m.layout.changes&&(gl(m)==="changes"||Oo(m)!==null)?{a:"toggle-changes"}:{a:"focus-changes",tab:"changes"});break;case"files":g(m.layout.changes&&gl(m)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"});break;case"panel-tab-prev":case"panel-tab-next":if(Bf(m))break;g(m.layout.changes?{a:"focus-changes",tab:tL(m,y.id==="panel-tab-next"?1:-1)}:{a:"focus-changes"});break;case"composer":g(FE(m));break;case"rail":g(m.railOpen?{a:"toggle-rail"}:{a:"focus-rail"});break;case"keys":g({a:"toggle",overlay:{kind:"keys"}});break;case"terminal":g(m.layout.term?{a:"toggle-terminal"}:{a:"focus-terminal"});break;case"design":g({a:"toggle-design"});break;case"term-tab":{const $=m.rows.find(O=>O.id===m.activeId);if(!$)break;const P=Ro(m,m.activeId).termStream;if($.login&&P===Cs)break;const R=[Ao,...$.login?[Cs]:[],...$.procs.map(O=>O.name)],A=R.indexOf(P);g({a:"term-stream",id:$.id,stream:R[(A+1)%R.length]??Ao});break}}}else if(h.key==="Escape")if(m.newProject)m.newProject.phase==="editing"&&g({a:"close-new-project"});else if(m.picking){const j=kc(m);j&&an.post(j,{type:"pick-cancel"}),g({a:"set-picking",v:!1})}else m.notesPage?g({a:"close-release-notes"}):m.archivedPage?g({a:"close-archived"}):m.activeImportId?g({a:"watch-import",id:null}):c()}};return window.addEventListener("keydown",u,!0),window.addEventListener("keydown",p),window.addEventListener("keyup",i),window.addEventListener("pointermove",l),window.addEventListener("pointerdown",l),window.addEventListener("blur",r),()=>{window.removeEventListener("keydown",u,!0),window.removeEventListener("keydown",p),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&&an.post(o.activeId,{type:"pick-mods",alt:r.altKey,shift:r.shiftKey})};return window.addEventListener("keydown",n),window.addEventListener("keyup",n),()=>{window.removeEventListener("keydown",n),window.removeEventListener("keyup",n)}},[e])}const $W=3,RW=2e3,OW=200,MW=5e3;function PW(){const e=Yn(),t=ut(),n=it(),{storage:r}=io(),o=_l(),i=M(de=>de.activeRepoId),l=$s(),c=xk(),u=M(de=>de.connected),p=M(de=>de.daylight),h=M(de=>{var we;return((we=de.daylight)==null?void 0:we.until)??0}),m=fa(),g=M(de=>de.notesPage),w=M(de=>de.version),y=M(de=>de.railOpen),b=M(de=>de.chatSide),_=M(de=>de.layouts),T=M(de=>de.lastActive),E=M(de=>de.discoveredOpen),N=M(de=>de.archivedOpen),j=M(de=>de.committedShut),$=M(de=>de.turnOpen),P=M(de=>de.treeOpen),R=Hf(),A=M(de=>de.previewTheme!==null),O=M(de=>de.openUrl),B=cS();S.useEffect(()=>wl.install(window),[]);const H=S.useRef([]);S.useEffect(()=>{if(!n||!u||!o)return;const de=[o,...H.current.filter(we=>we!==o)];for(const we of de.splice($W))n.send({t:"unsubscribe",worktreeId:we});H.current.includes(o)||n.send({t:"subscribe",worktreeId:o}),H.current=de},[o,u,n]),S.useEffect(()=>{if(!(!n||!u))for(const de of H.current)n.send({t:"subscribe",worktreeId:de})},[u,n]);const Q=S.useRef(void 0);S.useEffect(()=>{if(!n||!u)return;let de;const we=()=>{const ue=document.visibilityState==="visible"?o:null;n.send({t:"view",worktreeId:ue}),Q.current=ue},ae=()=>{clearTimeout(de),de=setTimeout(we,OW)};Q.current===void 0||Q.current===o||document.visibilityState!=="visible"?we():ae();const G=()=>document.visibilityState==="visible"?ae():we();return document.addEventListener("visibilitychange",G),()=>{clearTimeout(de),document.removeEventListener("visibilitychange",G)}},[o,u,n]);const re=(m==null?void 0:m.id)??null;S.useEffect(()=>{if(!(!n||!u||!re))return n.send({t:"subscribe",worktreeId:re}),()=>n.send({t:"unsubscribe",worktreeId:re})},[re,u,n]),S.useEffect(()=>{const de=new Set(B.map(ae=>ae.id)),we=H.current.filter(ae=>!de.has(ae));if(we.length!==0&&(H.current=H.current.filter(ae=>de.has(ae)),!(!n||!u)))for(const ae of we)n.send({t:"unsubscribe",worktreeId:ae})},[B,u,n]);const J=g?"Release notes":(m==null?void 0:m.title)??(c==null?void 0:c.name)??null;S.useEffect(()=>{document.title=J?`${J} · Toyon`:"Toyon"},[J]);const ie=!!(l!=null&&l.unseen),ve=M(de=>de.unreadHold!==null&&de.unreadHold===de.activeId);S.useEffect(()=>{if(!n||!o||!ie||ve)return;let de;const we=()=>document.visibilityState==="visible"&&document.hasFocus(),ae=()=>{clearTimeout(de),we()&&(de=setTimeout(()=>{we()&&n.send({t:"seen",worktreeId:o})},RW))},G=()=>clearTimeout(de);return ae(),window.addEventListener("focus",ae),window.addEventListener("blur",G),()=>{G(),window.removeEventListener("focus",ae),window.removeEventListener("blur",G)}},[n,o,ie,ve]);const C=S.useRef(0),Z=M(de=>hk(de));S.useEffect(()=>{if(!n||!u||!i)return;const de=()=>{Date.now()-C.current<MW||(C.current=Date.now(),n.send({t:"refresh-git",repoId:i}),Z&&Z!==i&&n.send({t:"refresh-git",repoId:Z}))};return window.addEventListener("focus",de),()=>window.removeEventListener("focus",de)},[n,u,i,Z]),S.useEffect(()=>{YT(R,{remember:!A}),an.broadcast(XT(R))},[R,A]);const Y=S.useCallback(()=>{n==null||n.send({t:"zone",tz:Intl.DateTimeFormat().resolvedOptions().timeZone})},[n]);S.useEffect(()=>{if(!u)return;Y();const de=()=>{document.visibilityState==="visible"&&Y()};return document.addEventListener("visibilitychange",de),()=>document.removeEventListener("visibilitychange",de)},[u,Y]),S.useEffect(()=>{if(!u||h<=Date.now())return;const de=setTimeout(Y,h-Date.now()+1e3);return()=>clearTimeout(de)},[u,h,Y]),S.useEffect(()=>{p&&p.until>0&&aH(p)},[p]),S.useEffect(()=>{o&&r.set(qe.active,o)},[o,r]),S.useEffect(()=>{w&&r.set(qe.version,w)},[w,r]);const q=M(de=>de.frame==="phone"?de.screen!=="home":null);S.useEffect(()=>{q!==null&&r.session.set(qe.phoneRow,q?"1":"0")},[q,r]);const z=M(de=>de.frame==="phone"&&de.screen==="home"?"surface1":"surface0");S.useEffect(()=>{try{sessionStorage.setItem(qe.ground,z)}catch{}},[z]),S.useEffect(()=>{i&&r.set(qe.repo,i)},[i,r]),S.useEffect(()=>{try{localStorage.setItem(qe.rail,y?"1":"0")}catch{}},[y]),S.useEffect(()=>{try{localStorage.setItem(qe.chatSide,b)}catch{}},[b]),S.useEffect(()=>{try{localStorage.setItem(qe.layouts,JSON.stringify(_))}catch{}},[_]),S.useEffect(()=>{r.set(qe.lastActive,JSON.stringify(T))},[T,r]),S.useEffect(()=>{r.set(qe.discoveredOpen,JSON.stringify(E))},[E,r]),S.useEffect(()=>{r.set(qe.archivedOpen,JSON.stringify(N))},[N,r]),S.useEffect(()=>{r.set(qe.committedShut,JSON.stringify(j))},[j,r]),S.useEffect(()=>{r.set(qe.turnOpen,JSON.stringify($))},[$,r]),S.useEffect(()=>{r.set(qe.treeOpen,JSON.stringify(P))},[P,r]),IW(),cD();const te=S.useRef(null);S.useEffect(()=>{!O||te.current===O||(te.current=O,window.open(O,"_blank"),t({a:"opened-url"}))},[O,t]);const Ee=S.useRef(null);return ft([o],()=>{var ne,ge,je,Ce;const de=Ee.current;if(Ee.current=o,!de||!o||de===o)return;const we=e.getState(),ae=B.find(Se=>Se.id===de),G=B.find(Se=>Se.id===o),ue=(ge=(ne=ae==null?void 0:ae.worktree)==null?void 0:ne.variant)==null?void 0:ge.group;if(!ue||((Ce=(je=G==null?void 0:G.worktree)==null?void 0:je.variant)==null?void 0:Ce.group)!==ue)return;const Le=Se=>{var Me;try{const wt=(Me=we.local[Se])==null?void 0:Me.page.url;return wt?new URL(wt).pathname+new URL(wt).search:"/"}catch{return"/"}},ke=Le(de);ke!==Le(o)&&an.post(o,{type:"navigate",path:ke})}),M(de=>de.frame)==="phone"?d.jsx(Q7,{}):d.jsx(NW,{})}function LW({origin:e,machine:t,onToken:n}){const[r,o]=S.useState({kind:"asking"}),[i,l]=S.useState(0);return ft([i],()=>{const c=new AbortController;return o({kind:"asking"}),EE(e,c.signal,u=>o({kind:"waiting",word:u})).then(u=>{if(!c.signal.aborted){if(typeof u=="string"){o({kind:"failed",failure:u});return}o({kind:"in"}),n(u.token)}}),()=>c.abort()}),d.jsxs(ds,{children:[r.kind==="waiting"&&d.jsx("div",{className:"knock-word",children:r.word}),d.jsx("p",{className:"status-line",children:r.kind==="asking"?`Asking Toyon on ${t} to let this device in.`:r.kind==="waiting"?`Toyon on ${t} is asking whether to let these two words in. Say yes there.`:r.kind==="in"?"Let in. Opening.":DT(r.failure,e,"this device")}),r.kind==="failed"&&d.jsx("div",{className:"status-actions",children:d.jsx(Be,{variant:"outline",onClick:()=>l(c=>c+1),children:"ask again"})})]})}function DW(){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(yC(t.worktreeId,t.stream))??[])n(t)}}}function zW(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 FW(e){const t={};try{const n=JSON.parse(e??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))ZP(o)&&(t[r]=o)}catch{}return t}function BW(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 Pd(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 UW(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 HW=400,WW=2e3;function sj(){const e=new Map;return{another(t,n=0){return(e.get(t)??0)===n?!1:(e.set(t,n),!0)}}}function ij(e,t,n){const r=e.getState(),o=[];for(const[i,l]of t){if(l===n||r.local[i])continue;const c=ls(i);c&&c.clientId!==r.clientId||o.push(i)}return o}function KW(e,t){const n=new Map,r=new Map,o=sj(),i=u=>{var h,m;clearTimeout((h=r.get(u))==null?void 0:h.timer),r.delete(u);const p=e.getState().local[u];!p||((m=p.mark)==null?void 0:m.by)==="walk"||(n.get(u)??"")!==p.draft&&(n.set(u,p.draft),t.send({t:"set-draft",boxId:u,text:p.draft,clientId:e.getState().clientId}))},l=()=>{for(const u of[...r.keys()])i(u)},c=e.subscribe(()=>{var u,p,h;for(const[m,g]of Object.entries(e.getState().local)){if(o.another(m,g.sent)&&(clearTimeout((u=r.get(m))==null?void 0:u.timer),r.delete(m),n.set(m,"")),((p=g.mark)==null?void 0:p.by)==="walk"||(n.get(m)??"")===g.draft)continue;if(!g.draft){i(m);continue}const w=r.get(m);if((w==null?void 0:w.text)===g.draft)continue;clearTimeout(w==null?void 0:w.timer);const y=(w==null?void 0:w.since)??Date.now(),b=Math.max(0,Math.min(HW,y+WW-Date.now()));r.set(m,{text:g.draft,timer:setTimeout(i,b,m),since:y})}for(const m of ij(e,n,""))clearTimeout((h=r.get(m))==null?void 0:h.timer),r.delete(m),n.set(m,""),t.send({t:"set-draft",boxId:m,text:"",clientId:e.getState().clientId})});return window.addEventListener("focusout",l),window.addEventListener("pagehide",l),{hello(u){n.clear();for(const[p,h]of Object.entries(u))n.set(p,h)},heard(u,p){return r.has(u)?!1:(n.set(u,p),!0)},dispose(){c();for(const u of r.values())clearTimeout(u.timer);r.clear(),window.removeEventListener("focusout",l),window.removeEventListener("pagehide",l)}}}function ZW(e,t){const n=new Map,r=new Map,o=sj(),i=e.subscribe(()=>{const l=[];for(const[c,u]of Object.entries(e.getState().local)){if(o.another(c,u.sent)&&r.set(c,"[]"),n.get(c)===u.attachments)continue;n.set(c,u.attachments);const p=uk(u.attachments),h=JSON.stringify(p),m=r.get(c)??"[]";m!==h&&(r.set(c,h),l.push({id:c,items:p,before:OE(JSON.parse(m))}))}for(const c of ij(e,r,"[]"))r.set(c,"[]"),l.push({id:c,items:[],before:[]});for(const c of HP(l))t.send({t:"set-attachments",boxId:c.id,items:c.items,clientId:e.getState().clientId})});return{hello(l){r.clear(),n.clear();for(const[c,u]of Object.entries(l))r.set(c,JSON.stringify(u))},heard(l,c){r.set(l,JSON.stringify(c))},dispose:i}}function qW(e,t){return e.subscribe(()=>{for(const n of UP(e.getState().outbox,e.getState().local)){const r=e.getState(),o=r.local[n];o!=null&&o.outgoing&&(t.send({t:"set-draft",boxId:n,text:o.draft,clientId:r.clientId}),t.send(gc(o.outgoing.frame,n,o.draft,o.attachments)),e.dispatch({a:"sent-out",id:n}))}})}const n1="not sent: the page reloaded while an upload was on its way; attach it again and send";function r1(e,t,n){var l;const r=e.getState(),o=new Set([...Object.keys(n.drafts),...Object.keys(n.attachments)]),i=[];for(const c of o){const u=ls(c);if((u==null?void 0:u.clientId)!==r.clientId||(l=r.local[c])!=null&&l.outgoing)continue;const p=n.drafts[c]??"",h=n.attachments[c]??[],m=n.drafts[u.source]??"",g=[...h,...n.attachments[u.source]??[]],w=m||p,y=r.clientId;g.length&&t.send({t:"set-attachments",boxId:u.source,items:g,clientId:y}),w!==m&&t.send({t:"set-draft",boxId:u.source,text:w,clientId:y}),t.send({t:"set-attachments",boxId:c,items:[],clientId:y}),t.send({t:"set-draft",boxId:c,text:"",clientId:y}),delete n.drafts[c],delete n.attachments[c],w&&(n.drafts[u.source]=w),g.length&&(n.attachments[u.source]=g),i.push(u.source)}return i}function GW(e,t){const n=(t.storage??VM)(e.origin),r=CL(GP({cached:t.cached,systemDark:t.systemDark,daylight:t.daylight,storedActive:n.get(qe.active),storedPhoneRow:n.session.get(qe.phoneRow)==="1",storedRepo:n.get(qe.repo),storedVersion:n.get(qe.version),storedRailOpen:bm(qe.rail)==="1",storedChatSide:bm(qe.chatSide)==="right"?"right":"left",storedLayouts:FW(bm(qe.layouts)),storedLastActive:BW(n.get(qe.lastActive)),storedDiscoveredOpen:Pd(n.get(qe.discoveredOpen)),storedArchivedOpen:Pd(n.get(qe.archivedOpen)),storedCommittedShut:Pd(n.get(qe.committedShut)),storedTurnOpen:Pd(n.get(qe.turnOpen)),storedTreeOpen:UW(n.get(qe.treeOpen)),clientId:t.clientId,frame:t.frame,touch:t.touch})),o=DW(),i={version:null,protocol:null},l=c6(y=>r.dispatch({a:"server",msg:y}));let c,u,p,h=[];const m=new mP(e,y=>{if(y.t==="hello"){if(i.protocol=y.protocol,e.serving){const{rebuilt:_,update:T}=r.getState(),E=_&&(T==null?void 0:T.restarting)!=null;if(i.version!==null&&(E||y.version!==i.version||y.protocol!==Ed)){m.dispose(),t.reload();return}if(y.protocol!==Ed){r.dispatch({a:"incompatible"}),m.dispose();return}}else if(y.protocol!==Ed){r.dispatch({a:"incompatible"}),m.suspend();return}else r.getState().incompatible&&r.dispatch({a:"incompatible",v:!1});i.version=y.version;const b=new Set(m.sentWhileDown());if(b.size){const _=T=>Object.fromEntries(Object.entries(T).filter(([E])=>!b.has(E)));y.drafts=_(y.drafts),y.attachments=_(y.attachments)}h=r1(r,m,y),c.hello(y.drafts),u.hello(y.attachments)}if(y.t==="attachments"&&y.clientId!==r.getState().clientId&&u.heard(y.boxId,y.items),!(y.t==="draft"&&y.clientId!==r.getState().clientId&&!c.heard(y.boxId,y.text))){if(U2(y)){o.deliver(y);return}if(H2(y)){if(y.t==="file-written"&&_4(y))return;p.receive(y);return}if(y.t==="loose-written"){YB(y);return}if(o3(y)){l3(r,m,y);return}if(y.t==="open-refused"){a3(r,y);return}l(y);for(const b of h.splice(0))r.dispatch({a:"notice",id:b,text:n1})}},(y,b)=>r.dispatch({a:"connected",v:y,failure:b}));C4(r,m.urls),p=new GB({store:r,send:y=>m.send(y),timers:{set:(y,b)=>setTimeout(y,b),clear:y=>clearTimeout(y)},win:window});const g=p.start();c=KW(r,m),u=ZW(r,m);const w=qW(r,m);return{origin:e.origin,serving:e.serving,token:e.token,get name(){return r.getState().machine??zW(e.origin)},store:r,sock:m,files:p,terminals:o,storage:n,heard:i,boot(y){if(y.t!=="hello"||y.protocol!==Ed)return;i.version??(i.version=y.version);const b=r1(r,m,y);u.hello(y.attachments),r.dispatch({a:"server",msg:y});for(const _ of b)r.dispatch({a:"notice",id:_,text:n1})},dispose(){m.dispose(),g(),c.dispose(),u.dispose(),w()}}}function bm(e){try{return localStorage.getItem(e)}catch{return null}}window.__toyonShell=!0;window.top!==window&&(document.documentElement.dataset.framed="");XM(location.origin);const aj=rH();YT(aj);function VW(e,t){try{return e.getItem(t)}catch{return null}}function YW(){const e=VW(sessionStorage,qe.client);if(e)return e;const t=Math.random().toString(36).slice(2,10);try{sessionStorage.setItem(qe.client,t)}catch{}return t}const XW={cached:aj,systemDark:oH(),daylight:iH(),clientId:YW(),frame:VT(),touch:tH(),reload:()=>window.location.reload()},yi=p7({serving:{origin:location.origin,token:kE()},build:e=>GW(e,XW)});nH({dispatch:e=>yi.broadcast(e)});lH(e=>yi.broadcast({a:"system-dark",v:e}));let o1=ZT(yi.active().store),s1=yi.active();yi.subscribe(()=>{const e=yi.active();e!==s1&&(s1=e,o1(),e.store.getState().frame==="phone"&&e.store.dispatch({a:"screen",to:"home"}),o1=ZT(e.store))});window.addEventListener("vite:preloadError",zD);const QW=(window.toyonBoot??Promise.resolve(null)).then(e=>{const t=e;t&&typeof t=="object"&&t.t==="hello"&&yi.active().boot(t)});function JW(e){wE(e),window.location.reload()}const eK=pC.createRoot(document.getElementById("root"));QW.then(()=>{fC.flushSync(()=>eK.render(d.jsx(lC.StrictMode,{children:d.jsx(Ok,{children:Qg()?d.jsx(IL,{machines:yi,children:d.jsx(PW,{})}):d.jsx(LW,{origin:location.origin,machine:location.host,onToken:JW})})}))),document.documentElement.style.removeProperty("background")});"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{});export{Rs as F,Eg as _,yr as a,Yg as b,ft as c,iK as d,rK as e,g1 as f,yC as g,BM as h,Kz as i,d as j,Uk as k,nK as l,m1 as m,oK as p,S as r,OM as s,eu as t,sK as u,T0 as w};
|