toyon 0.11.0 → 0.12.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/cli.js +468 -2110
- package/dist/daemon.js +2091 -703
- package/dist/helper-stub +0 -0
- package/dist/shell/assets/{Editor-Cs_OeWSx.js → Editor-ofBOHWJt.js} +3 -3
- package/dist/shell/assets/{XTerm-Dc6Bk52B.js → XTerm-C_Gv5uo2.js} +1 -1
- package/dist/shell/assets/{cssMode-D8uDYrHJ.js → cssMode-LqxC-sXw.js} +1 -1
- package/dist/shell/assets/{freemarker2-DlU9uDzS.js → freemarker2-DUqPZFAL.js} +1 -1
- package/dist/shell/assets/{grammar-BSzyJU-q.js → grammar-CFa79rtH.js} +1 -1
- package/dist/shell/assets/{handlebars-B66kGi_7.js → handlebars-CF9us5mA.js} +1 -1
- package/dist/shell/assets/{html-D6juOeyd.js → html-SO575qLW.js} +1 -1
- package/dist/shell/assets/{htmlMode-CbTT-4ZV.js → htmlMode-XUsZRqmU.js} +1 -1
- package/dist/shell/assets/index-BYJYiHrs.css +1 -0
- package/dist/shell/assets/index-Brx-QOIQ.js +266 -0
- package/dist/shell/assets/{javascript-CHwG4FvH.js → javascript-4ER2NhcO.js} +1 -1
- package/dist/shell/assets/{jsonMode-DzTEiaKX.js → jsonMode-D-UOjsYN.js} +1 -1
- package/dist/shell/assets/{liquid-wddZX4zw.js → liquid-CMXc0SdF.js} +1 -1
- package/dist/shell/assets/{lspLanguageFeatures-BlqDZ6dO.js → lspLanguageFeatures-D4Z0LyWk.js} +1 -1
- package/dist/shell/assets/{mdx-Dlz2LIv9.js → mdx-Dc4E4gPJ.js} +1 -1
- package/dist/shell/assets/{python-DvkArqZY.js → python-DhCnlsga.js} +1 -1
- package/dist/shell/assets/{razor-bDLQ0jQf.js → razor-CGRu_Zyc.js} +1 -1
- package/dist/shell/assets/{tsMode-B_NomV_y.js → tsMode-BoDg-EAl.js} +1 -1
- package/dist/shell/assets/{xml-CBYJrQiV.js → xml-Dl50xhA0.js} +1 -1
- package/dist/shell/assets/{yaml-DnmVK8S2.js → yaml-CoqiVhBi.js} +1 -1
- package/dist/shell/index.html +5 -29
- package/dist/shell/offline.html +219 -0
- package/dist/shell/sw.js +32 -3
- package/package.json +1 -1
- package/dist/shell/assets/index-B4KJ--q9.css +0 -1
- package/dist/shell/assets/index-Cj-6Xixu.js +0 -268
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Editor-ofBOHWJt.js","assets/grammar-CFa79rtH.js","assets/Editor-CB2SckMT.css","assets/XTerm-C_Gv5uo2.js","assets/XTerm-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
var QT=Object.defineProperty;var JT=(e,t,n)=>t in e?QT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Rt=(e,t,n)=>JT(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 Ex(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var dp={exports:{}},Pl={},fp={exports:{}},Bt={};/**
|
|
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 Xy;function ej(){if(Xy)return Bt;Xy=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.iterator;function g(K){return K===null||typeof K!="object"?null:(K=m&&K[m]||K["@@iterator"],typeof K=="function"?K:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,x={};function b(K,B,xe){this.props=K,this.context=B,this.refs=x,this.updater=xe||w}b.prototype.isReactComponent={},b.prototype.setState=function(K,B){if(typeof K!="object"&&typeof K!="function"&&K!=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,K,B,"setState")},b.prototype.forceUpdate=function(K){this.updater.enqueueForceUpdate(this,K,"forceUpdate")};function j(){}j.prototype=b.prototype;function N(K,B,xe){this.props=K,this.context=B,this.refs=x,this.updater=xe||w}var T=N.prototype=new j;T.constructor=N,y(T,b.prototype),T.isPureReactComponent=!0;var R=Array.isArray,$=Object.prototype.hasOwnProperty,W={current:null},A={key:!0,ref:!0,__self:!0,__source:!0};function I(K,B,xe){var de,we={},ee=null,J=null;if(B!=null)for(de in B.ref!==void 0&&(J=B.ref),B.key!==void 0&&(ee=""+B.key),B)$.call(B,de)&&!A.hasOwnProperty(de)&&(we[de]=B[de]);var pe=arguments.length-2;if(pe===1)we.children=xe;else if(1<pe){for(var $e=Array(pe),le=0;le<pe;le++)$e[le]=arguments[le+2];we.children=$e}if(K&&K.defaultProps)for(de in pe=K.defaultProps,pe)we[de]===void 0&&(we[de]=pe[de]);return{$$typeof:e,type:K,key:ee,ref:J,props:we,_owner:W.current}}function _(K,B){return{$$typeof:e,type:K.type,key:B,ref:K.ref,props:K.props,_owner:K._owner}}function P(K){return typeof K=="object"&&K!==null&&K.$$typeof===e}function z(K){var B={"=":"=0",":":"=2"};return"$"+K.replace(/[=:]/g,function(xe){return B[xe]})}var q=/\/+/g;function se(K,B){return typeof K=="object"&&K!==null&&K.key!=null?z(""+K.key):B.toString(36)}function Y(K,B,xe,de,we){var ee=typeof K;(ee==="undefined"||ee==="boolean")&&(K=null);var J=!1;if(K===null)J=!0;else switch(ee){case"string":case"number":J=!0;break;case"object":switch(K.$$typeof){case e:case t:J=!0}}if(J)return J=K,we=we(J),K=de===""?"."+se(J,0):de,R(we)?(xe="",K!=null&&(xe=K.replace(q,"$&/")+"/"),Y(we,B,xe,"",function(le){return le})):we!=null&&(P(we)&&(we=_(we,xe+(!we.key||J&&J.key===we.key?"":(""+we.key).replace(q,"$&/")+"/")+K)),B.push(we)),1;if(J=0,de=de===""?".":de+":",R(K))for(var pe=0;pe<K.length;pe++){ee=K[pe];var $e=de+se(ee,pe);J+=Y(ee,B,xe,$e,we)}else if($e=g(K),typeof $e=="function")for(K=$e.call(K),pe=0;!(ee=K.next()).done;)ee=ee.value,$e=de+se(ee,pe++),J+=Y(ee,B,xe,$e,we);else if(ee==="object")throw B=String(K),Error("Objects are not valid as a React child (found: "+(B==="[object Object]"?"object with keys {"+Object.keys(K).join(", ")+"}":B)+"). If you meant to render a collection of children, use an array instead.");return J}function ge(K,B,xe){if(K==null)return K;var de=[],we=0;return Y(K,de,"","",function(ee){return B.call(xe,ee,we++)}),de}function ke(K){if(K._status===-1){var B=K._result;B=B(),B.then(function(xe){(K._status===0||K._status===-1)&&(K._status=1,K._result=xe)},function(xe){(K._status===0||K._status===-1)&&(K._status=2,K._result=xe)}),K._status===-1&&(K._status=0,K._result=B)}if(K._status===1)return K._result.default;throw K._result}var oe={current:null},L={transition:null},re={ReactCurrentDispatcher:oe,ReactCurrentBatchConfig:L,ReactCurrentOwner:W};function te(){throw Error("act(...) is not supported in production builds of React.")}return Bt.Children={map:ge,forEach:function(K,B,xe){ge(K,function(){B.apply(this,arguments)},xe)},count:function(K){var B=0;return ge(K,function(){B++}),B},toArray:function(K){return ge(K,function(B){return B})||[]},only:function(K){if(!P(K))throw Error("React.Children.only expected to receive a single React element child.");return K}},Bt.Component=b,Bt.Fragment=n,Bt.Profiler=o,Bt.PureComponent=N,Bt.StrictMode=r,Bt.Suspense=c,Bt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=re,Bt.act=te,Bt.cloneElement=function(K,B,xe){if(K==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+K+".");var de=y({},K.props),we=K.key,ee=K.ref,J=K._owner;if(B!=null){if(B.ref!==void 0&&(ee=B.ref,J=W.current),B.key!==void 0&&(we=""+B.key),K.type&&K.type.defaultProps)var pe=K.type.defaultProps;for($e in B)$.call(B,$e)&&!A.hasOwnProperty($e)&&(de[$e]=B[$e]===void 0&&pe!==void 0?pe[$e]:B[$e])}var $e=arguments.length-2;if($e===1)de.children=xe;else if(1<$e){pe=Array($e);for(var le=0;le<$e;le++)pe[le]=arguments[le+2];de.children=pe}return{$$typeof:e,type:K.type,key:we,ref:ee,props:de,_owner:J}},Bt.createContext=function(K){return K={$$typeof:l,_currentValue:K,_currentValue2:K,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},K.Provider={$$typeof:i,_context:K},K.Consumer=K},Bt.createElement=I,Bt.createFactory=function(K){var B=I.bind(null,K);return B.type=K,B},Bt.createRef=function(){return{current:null}},Bt.forwardRef=function(K){return{$$typeof:u,render:K}},Bt.isValidElement=P,Bt.lazy=function(K){return{$$typeof:p,_payload:{_status:-1,_result:K},_init:ke}},Bt.memo=function(K,B){return{$$typeof:f,type:K,compare:B===void 0?null:B}},Bt.startTransition=function(K){var B=L.transition;L.transition={};try{K()}finally{L.transition=B}},Bt.unstable_act=te,Bt.useCallback=function(K,B){return oe.current.useCallback(K,B)},Bt.useContext=function(K){return oe.current.useContext(K)},Bt.useDebugValue=function(){},Bt.useDeferredValue=function(K){return oe.current.useDeferredValue(K)},Bt.useEffect=function(K,B){return oe.current.useEffect(K,B)},Bt.useId=function(){return oe.current.useId()},Bt.useImperativeHandle=function(K,B,xe){return oe.current.useImperativeHandle(K,B,xe)},Bt.useInsertionEffect=function(K,B){return oe.current.useInsertionEffect(K,B)},Bt.useLayoutEffect=function(K,B){return oe.current.useLayoutEffect(K,B)},Bt.useMemo=function(K,B){return oe.current.useMemo(K,B)},Bt.useReducer=function(K,B,xe){return oe.current.useReducer(K,B,xe)},Bt.useRef=function(K){return oe.current.useRef(K)},Bt.useState=function(K){return oe.current.useState(K)},Bt.useSyncExternalStore=function(K,B,xe){return oe.current.useSyncExternalStore(K,B,xe)},Bt.useTransition=function(){return oe.current.useTransition()},Bt.version="18.3.1",Bt}var Qy;function ng(){return Qy||(Qy=1,fp.exports=ej()),fp.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 Jy;function tj(){if(Jy)return Pl;Jy=1;var e=ng(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function l(u,c,f){var p,m={},g=null,w=null;f!==void 0&&(g=""+f),c.key!==void 0&&(g=""+c.key),c.ref!==void 0&&(w=c.ref);for(p in c)r.call(c,p)&&!i.hasOwnProperty(p)&&(m[p]=c[p]);if(u&&u.defaultProps)for(p in c=u.defaultProps,c)m[p]===void 0&&(m[p]=c[p]);return{$$typeof:t,type:u,key:g,ref:w,props:m,_owner:o.current}}return Pl.Fragment=n,Pl.jsx=l,Pl.jsxs=l,Pl}var ev;function nj(){return ev||(ev=1,dp.exports=tj()),dp.exports}var h=nj(),S=ng();const rj=Ex(S);var Wu={},hp={exports:{}},Vr={},pp={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 tv;function oj(){return tv||(tv=1,(function(e){function t(L,re){var te=L.length;L.push(re);e:for(;0<te;){var K=te-1>>>1,B=L[K];if(0<o(B,re))L[K]=re,L[te]=B,te=K;else break e}}function n(L){return L.length===0?null:L[0]}function r(L){if(L.length===0)return null;var re=L[0],te=L.pop();if(te!==re){L[0]=te;e:for(var K=0,B=L.length,xe=B>>>1;K<xe;){var de=2*(K+1)-1,we=L[de],ee=de+1,J=L[ee];if(0>o(we,te))ee<B&&0>o(J,we)?(L[K]=J,L[ee]=te,K=ee):(L[K]=we,L[de]=te,K=de);else if(ee<B&&0>o(J,te))L[K]=J,L[ee]=te,K=ee;else break e}}return re}function o(L,re){var te=L.sortIndex-re.sortIndex;return te!==0?te:L.id-re.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,u=l.now();e.unstable_now=function(){return l.now()-u}}var c=[],f=[],p=1,m=null,g=3,w=!1,y=!1,x=!1,b=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function T(L){for(var re=n(f);re!==null;){if(re.callback===null)r(f);else if(re.startTime<=L)r(f),re.sortIndex=re.expirationTime,t(c,re);else break;re=n(f)}}function R(L){if(x=!1,T(L),!y)if(n(c)!==null)y=!0,ke($);else{var re=n(f);re!==null&&oe(R,re.startTime-L)}}function $(L,re){y=!1,x&&(x=!1,j(I),I=-1),w=!0;var te=g;try{for(T(re),m=n(c);m!==null&&(!(m.expirationTime>re)||L&&!z());){var K=m.callback;if(typeof K=="function"){m.callback=null,g=m.priorityLevel;var B=K(m.expirationTime<=re);re=e.unstable_now(),typeof B=="function"?m.callback=B:m===n(c)&&r(c),T(re)}else r(c);m=n(c)}if(m!==null)var xe=!0;else{var de=n(f);de!==null&&oe(R,de.startTime-re),xe=!1}return xe}finally{m=null,g=te,w=!1}}var W=!1,A=null,I=-1,_=5,P=-1;function z(){return!(e.unstable_now()-P<_)}function q(){if(A!==null){var L=e.unstable_now();P=L;var re=!0;try{re=A(!0,L)}finally{re?se():(W=!1,A=null)}}else W=!1}var se;if(typeof N=="function")se=function(){N(q)};else if(typeof MessageChannel<"u"){var Y=new MessageChannel,ge=Y.port2;Y.port1.onmessage=q,se=function(){ge.postMessage(null)}}else se=function(){b(q,0)};function ke(L){A=L,W||(W=!0,se())}function oe(L,re){I=b(function(){L(e.unstable_now())},re)}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(L){L.callback=null},e.unstable_continueExecution=function(){y||w||(y=!0,ke($))},e.unstable_forceFrameRate=function(L){0>L||125<L?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):_=0<L?Math.floor(1e3/L):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(L){switch(g){case 1:case 2:case 3:var re=3;break;default:re=g}var te=g;g=re;try{return L()}finally{g=te}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(L,re){switch(L){case 1:case 2:case 3:case 4:case 5:break;default:L=3}var te=g;g=L;try{return re()}finally{g=te}},e.unstable_scheduleCallback=function(L,re,te){var K=e.unstable_now();switch(typeof te=="object"&&te!==null?(te=te.delay,te=typeof te=="number"&&0<te?K+te:K):te=K,L){case 1:var B=-1;break;case 2:B=250;break;case 5:B=1073741823;break;case 4:B=1e4;break;default:B=5e3}return B=te+B,L={id:p++,callback:re,priorityLevel:L,startTime:te,expirationTime:B,sortIndex:-1},te>K?(L.sortIndex=te,t(f,L),n(c)===null&&L===n(f)&&(x?(j(I),I=-1):x=!0,oe(R,te-K))):(L.sortIndex=B,t(c,L),y||w||(y=!0,ke($))),L},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(L){var re=g;return function(){var te=g;g=re;try{return L.apply(this,arguments)}finally{g=te}}}})(mp)),mp}var nv;function sj(){return nv||(nv=1,pp.exports=oj()),pp.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 rv;function ij(){if(rv)return Vr;rv=1;var e=ng(),t=sj();function n(s){for(var a="https://reactjs.org/docs/error-decoder.html?invariant="+s,d=1;d<arguments.length;d++)a+="&args[]="+encodeURIComponent(arguments[d]);return"Minified React error #"+s+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function i(s,a){l(s,a),l(s+"Capture",a)}function l(s,a){for(o[s]=a,s=0;s<a.length;s++)r.add(a[s])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),c=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function g(s){return c.call(m,s)?!0:c.call(p,s)?!1:f.test(s)?m[s]=!0:(p[s]=!0,!1)}function w(s,a,d,k){if(d!==null&&d.type===0)return!1;switch(typeof a){case"function":case"symbol":return!0;case"boolean":return k?!1:d!==null?!d.acceptsBooleans:(s=s.toLowerCase().slice(0,5),s!=="data-"&&s!=="aria-");default:return!1}}function y(s,a,d,k){if(a===null||typeof a>"u"||w(s,a,d,k))return!0;if(k)return!1;if(d!==null)switch(d.type){case 3:return!a;case 4:return a===!1;case 5:return isNaN(a);case 6:return isNaN(a)||1>a}return!1}function x(s,a,d,k,v,E,C){this.acceptsBooleans=a===2||a===3||a===4,this.attributeName=k,this.attributeNamespace=v,this.mustUseProperty=d,this.propertyName=s,this.type=a,this.sanitizeURL=E,this.removeEmptyString=C}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(s){b[s]=new x(s,0,!1,s,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(s){var a=s[0];b[a]=new x(a,1,!1,s[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(s){b[s]=new x(s,2,!1,s.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(s){b[s]=new x(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){b[s]=new x(s,3,!1,s.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(s){b[s]=new x(s,3,!0,s,null,!1,!1)}),["capture","download"].forEach(function(s){b[s]=new x(s,4,!1,s,null,!1,!1)}),["cols","rows","size","span"].forEach(function(s){b[s]=new x(s,6,!1,s,null,!1,!1)}),["rowSpan","start"].forEach(function(s){b[s]=new x(s,5,!1,s.toLowerCase(),null,!1,!1)});var j=/[\-:]([a-z])/g;function N(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(j,N);b[a]=new x(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(j,N);b[a]=new x(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(j,N);b[a]=new x(a,1,!1,s,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(s){b[s]=new x(s,1,!1,s.toLowerCase(),null,!1,!1)}),b.xlinkHref=new x("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(s){b[s]=new x(s,1,!1,s.toLowerCase(),null,!0,!0)});function T(s,a,d,k){var v=b.hasOwnProperty(a)?b[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,d,v,k)&&(d=null),k||v===null?g(a)&&(d===null?s.removeAttribute(a):s.setAttribute(a,""+d)):v.mustUseProperty?s[v.propertyName]=d===null?v.type===3?!1:"":d:(a=v.attributeName,k=v.attributeNamespace,d===null?s.removeAttribute(a):(v=v.type,d=v===3||v===4&&d===!0?"":""+d,k?s.setAttributeNS(k,a,d):s.setAttribute(a,d))))}var R=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,$=Symbol.for("react.element"),W=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),P=Symbol.for("react.provider"),z=Symbol.for("react.context"),q=Symbol.for("react.forward_ref"),se=Symbol.for("react.suspense"),Y=Symbol.for("react.suspense_list"),ge=Symbol.for("react.memo"),ke=Symbol.for("react.lazy"),oe=Symbol.for("react.offscreen"),L=Symbol.iterator;function re(s){return s===null||typeof s!="object"?null:(s=L&&s[L]||s["@@iterator"],typeof s=="function"?s:null)}var te=Object.assign,K;function B(s){if(K===void 0)try{throw Error()}catch(d){var a=d.stack.trim().match(/\n( *(at )?)/);K=a&&a[1]||""}return`
|
|
35
|
+
`+K+s}var xe=!1;function de(s,a){if(!s||xe)return"";xe=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(a)if(a=function(){throw Error()},Object.defineProperty(a.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(a,[])}catch(ue){var k=ue}Reflect.construct(s,[],a)}else{try{a.call()}catch(ue){k=ue}s.call(a.prototype)}else{try{throw Error()}catch(ue){k=ue}s()}}catch(ue){if(ue&&k&&typeof ue.stack=="string"){for(var v=ue.stack.split(`
|
|
36
|
+
`),E=k.stack.split(`
|
|
37
|
+
`),C=v.length-1,F=E.length-1;1<=C&&0<=F&&v[C]!==E[F];)F--;for(;1<=C&&0<=F;C--,F--)if(v[C]!==E[F]){if(C!==1||F!==1)do if(C--,F--,0>F||v[C]!==E[F]){var V=`
|
|
38
|
+
`+v[C].replace(" at new "," at ");return s.displayName&&V.includes("<anonymous>")&&(V=V.replace("<anonymous>",s.displayName)),V}while(1<=C&&0<=F);break}}}finally{xe=!1,Error.prepareStackTrace=d}return(s=s?s.displayName||s.name:"")?B(s):""}function we(s){switch(s.tag){case 5:return B(s.type);case 16:return B("Lazy");case 13:return B("Suspense");case 19:return B("SuspenseList");case 0:case 2:case 15:return s=de(s.type,!1),s;case 11:return s=de(s.type.render,!1),s;case 1:return s=de(s.type,!0),s;default:return""}}function ee(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 A:return"Fragment";case W:return"Portal";case _:return"Profiler";case I:return"StrictMode";case se:return"Suspense";case Y:return"SuspenseList"}if(typeof s=="object")switch(s.$$typeof){case z:return(s.displayName||"Context")+".Consumer";case P: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 ge:return a=s.displayName||null,a!==null?a:ee(s.type)||"Memo";case ke:a=s._payload,s=s._init;try{return ee(s(a))}catch{}}return null}function J(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 ee(a);case 8:return a===I?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a}return null}function pe(s){switch(typeof s){case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function $e(s){var a=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function le(s){var a=$e(s)?"checked":"value",d=Object.getOwnPropertyDescriptor(s.constructor.prototype,a),k=""+s[a];if(!s.hasOwnProperty(a)&&typeof d<"u"&&typeof d.get=="function"&&typeof d.set=="function"){var v=d.get,E=d.set;return Object.defineProperty(s,a,{configurable:!0,get:function(){return v.call(this)},set:function(C){k=""+C,E.call(this,C)}}),Object.defineProperty(s,a,{enumerable:d.enumerable}),{getValue:function(){return k},setValue:function(C){k=""+C},stopTracking:function(){s._valueTracker=null,delete s[a]}}}}function ae(s){s._valueTracker||(s._valueTracker=le(s))}function Fe(s){if(!s)return!1;var a=s._valueTracker;if(!a)return!0;var d=a.getValue(),k="";return s&&(k=$e(s)?s.checked?"true":"false":s.value),s=k,s!==d?(a.setValue(s),!0):!1}function Qe(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 ze(s,a){var d=a.checked;return te({},a,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:d??s._wrapperState.initialChecked})}function Re(s,a){var d=a.defaultValue==null?"":a.defaultValue,k=a.checked!=null?a.checked:a.defaultChecked;d=pe(a.value!=null?a.value:d),s._wrapperState={initialChecked:k,initialValue:d,controlled:a.type==="checkbox"||a.type==="radio"?a.checked!=null:a.value!=null}}function ct(s,a){a=a.checked,a!=null&&T(s,"checked",a,!1)}function _n(s,a){ct(s,a);var d=pe(a.value),k=a.type;if(d!=null)k==="number"?(d===0&&s.value===""||s.value!=d)&&(s.value=""+d):s.value!==""+d&&(s.value=""+d);else if(k==="submit"||k==="reset"){s.removeAttribute("value");return}a.hasOwnProperty("value")?tn(s,a.type,d):a.hasOwnProperty("defaultValue")&&tn(s,a.type,pe(a.defaultValue)),a.checked==null&&a.defaultChecked!=null&&(s.defaultChecked=!!a.defaultChecked)}function ht(s,a,d){if(a.hasOwnProperty("value")||a.hasOwnProperty("defaultValue")){var k=a.type;if(!(k!=="submit"&&k!=="reset"||a.value!==void 0&&a.value!==null))return;a=""+s._wrapperState.initialValue,d||a===s.value||(s.value=a),s.defaultValue=a}d=s.name,d!==""&&(s.name=""),s.defaultChecked=!!s._wrapperState.initialChecked,d!==""&&(s.name=d)}function tn(s,a,d){(a!=="number"||Qe(s.ownerDocument)!==s)&&(d==null?s.defaultValue=""+s._wrapperState.initialValue:s.defaultValue!==""+d&&(s.defaultValue=""+d))}var Vt=Array.isArray;function He(s,a,d,k){if(s=s.options,a){a={};for(var v=0;v<d.length;v++)a["$"+d[v]]=!0;for(d=0;d<s.length;d++)v=a.hasOwnProperty("$"+s[d].value),s[d].selected!==v&&(s[d].selected=v),v&&k&&(s[d].defaultSelected=!0)}else{for(d=""+pe(d),a=null,v=0;v<s.length;v++){if(s[v].value===d){s[v].selected=!0,k&&(s[v].defaultSelected=!0);return}a!==null||s[v].disabled||(a=s[v])}a!==null&&(a.selected=!0)}}function nt(s,a){if(a.dangerouslySetInnerHTML!=null)throw Error(n(91));return te({},a,{value:void 0,defaultValue:void 0,children:""+s._wrapperState.initialValue})}function an(s,a){var d=a.value;if(d==null){if(d=a.children,a=a.defaultValue,d!=null){if(a!=null)throw Error(n(92));if(Vt(d)){if(1<d.length)throw Error(n(93));d=d[0]}a=d}a==null&&(a=""),d=a}s._wrapperState={initialValue:pe(d)}}function It(s,a){var d=pe(a.value),k=pe(a.defaultValue);d!=null&&(d=""+d,d!==s.value&&(s.value=d),a.defaultValue==null&&s.defaultValue!==d&&(s.defaultValue=d)),k!=null&&(s.defaultValue=""+k)}function X(s){var a=s.textContent;a===s._wrapperState.initialValue&&a!==""&&a!==null&&(s.value=a)}function fe(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 dt(s,a){return s==null||s==="http://www.w3.org/1999/xhtml"?fe(a):s==="http://www.w3.org/2000/svg"&&a==="foreignObject"?"http://www.w3.org/1999/xhtml":s}var Ke,pn=(function(s){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(a,d,k,v){MSApp.execUnsafeLocalFunction(function(){return s(a,d,k,v)})}:s})(function(s,a){if(s.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in s)s.innerHTML=a;else{for(Ke=Ke||document.createElement("div"),Ke.innerHTML="<svg>"+a.valueOf().toString()+"</svg>",a=Ke.firstChild;s.firstChild;)s.removeChild(s.firstChild);for(;a.firstChild;)s.appendChild(a.firstChild)}});function mn(s,a){if(a){var d=s.firstChild;if(d&&d===s.lastChild&&d.nodeType===3){d.nodeValue=a;return}}s.textContent=a}var Sn={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},Ct=["Webkit","ms","Moz","O"];Object.keys(Sn).forEach(function(s){Ct.forEach(function(a){a=a+s.charAt(0).toUpperCase()+s.substring(1),Sn[a]=Sn[s]})});function Nn(s,a,d){return a==null||typeof a=="boolean"||a===""?"":d||typeof a!="number"||a===0||Sn.hasOwnProperty(s)&&Sn[s]?(""+a).trim():a+"px"}function ut(s,a){s=s.style;for(var d in a)if(a.hasOwnProperty(d)){var k=d.indexOf("--")===0,v=Nn(d,a[d],k);d==="float"&&(d="cssFloat"),k?s.setProperty(d,v):s[d]=v}}var Ee=te({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 De(s,a){if(a){if(Ee[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 gn(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 bn=null;function wn(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var qn=null,ft=null,Mt=null;function nn(s){if(s=xl(s)){if(typeof qn!="function")throw Error(n(280));var a=s.stateNode;a&&(a=iu(a),qn(s.stateNode,s.type,a))}}function H(s){ft?Mt?Mt.push(s):Mt=[s]:ft=s}function me(){if(ft){var s=ft,a=Mt;if(Mt=ft=null,nn(s),a)for(s=0;s<a.length;s++)nn(a[s])}}function _e(s,a){return s(a)}function Ge(){}var Lt=!1;function Pt(s,a,d){if(Lt)return s(a,d);Lt=!0;try{return _e(s,a,d)}finally{Lt=!1,(ft!==null||Mt!==null)&&(Ge(),me())}}function Pe(s,a){var d=s.stateNode;if(d===null)return null;var k=iu(d);if(k===null)return null;d=k[a];e:switch(a){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(k=!k.disabled)||(s=s.type,k=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!k;break e;default:s=!1}if(s)return null;if(d&&typeof d!="function")throw Error(n(231,a,typeof d));return d}var Oe=!1;if(u)try{var Ve={};Object.defineProperty(Ve,"passive",{get:function(){Oe=!0}}),window.addEventListener("test",Ve,Ve),window.removeEventListener("test",Ve,Ve)}catch{Oe=!1}function Zt(s,a,d,k,v,E,C,F,V){var ue=Array.prototype.slice.call(arguments,3);try{a.apply(d,ue)}catch(Ce){this.onError(Ce)}}var $t=!1,Tn=null,In=!1,kn=null,kr={onError:function(s){$t=!0,Tn=s}};function hn(s,a,d,k,v,E,C,F,V){$t=!1,Tn=null,Zt.apply(kr,arguments)}function En(s,a,d,k,v,E,C,F,V){if(hn.apply(this,arguments),$t){if($t){var ue=Tn;$t=!1,Tn=null}else throw Error(n(198));In||(In=!0,kn=ue)}}function cr(s){var a=s,d=s;if(s.alternate)for(;a.return;)a=a.return;else{s=a;do a=s,(a.flags&4098)!==0&&(d=a.return),s=a.return;while(s)}return a.tag===3?d:null}function Yt(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 qt(s){if(cr(s)!==s)throw Error(n(188))}function zt(s){var a=s.alternate;if(!a){if(a=cr(s),a===null)throw Error(n(188));return a!==s?null:s}for(var d=s,k=a;;){var v=d.return;if(v===null)break;var E=v.alternate;if(E===null){if(k=v.return,k!==null){d=k;continue}break}if(v.child===E.child){for(E=v.child;E;){if(E===d)return qt(v),s;if(E===k)return qt(v),a;E=E.sibling}throw Error(n(188))}if(d.return!==k.return)d=v,k=E;else{for(var C=!1,F=v.child;F;){if(F===d){C=!0,d=v,k=E;break}if(F===k){C=!0,k=v,d=E;break}F=F.sibling}if(!C){for(F=E.child;F;){if(F===d){C=!0,d=E,k=v;break}if(F===k){C=!0,k=E,d=v;break}F=F.sibling}if(!C)throw Error(n(189))}}if(d.alternate!==k)throw Error(n(190))}if(d.tag!==3)throw Error(n(188));return d.stateNode.current===d?s:a}function G(s){return s=zt(s),s!==null?be(s):null}function be(s){if(s.tag===5||s.tag===6)return s;for(s=s.child;s!==null;){var a=be(s);if(a!==null)return a;s=s.sibling}return null}var Ze=t.unstable_scheduleCallback,pt=t.unstable_cancelCallback,Jt=t.unstable_shouldYield,rn=t.unstable_requestPaint,Ut=t.unstable_now,ur=t.unstable_getCurrentPriorityLevel,Or=t.unstable_ImmediatePriority,On=t.unstable_UserBlockingPriority,St=t.unstable_NormalPriority,je=t.unstable_LowPriority,Se=t.unstable_IdlePriority,kt=null,st=null;function Ft(s){if(st&&typeof st.onCommitFiberRoot=="function")try{st.onCommitFiberRoot(kt,s,void 0,(s.current.flags&128)===128)}catch{}}var Gt=Math.clz32?Math.clz32:Be,U=Math.log,he=Math.LN2;function Be(s){return s>>>=0,s===0?32:31-(U(s)/he|0)|0}var mt=64,bt=4194304;function Ht(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 Mn(s,a){var d=s.pendingLanes;if(d===0)return 0;var k=0,v=s.suspendedLanes,E=s.pingedLanes,C=d&268435455;if(C!==0){var F=C&~v;F!==0?k=Ht(F):(E&=C,E!==0&&(k=Ht(E)))}else C=d&~v,C!==0?k=Ht(C):E!==0&&(k=Ht(E));if(k===0)return 0;if(a!==0&&a!==k&&(a&v)===0&&(v=k&-k,E=a&-a,v>=E||v===16&&(E&4194240)!==0))return a;if((k&4)!==0&&(k|=d&16),a=s.entangledLanes,a!==0)for(s=s.entanglements,a&=k;0<a;)d=31-Gt(a),v=1<<d,k|=s[d],a&=~v;return k}function tr(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 jo(s,a){for(var d=s.suspendedLanes,k=s.pingedLanes,v=s.expirationTimes,E=s.pendingLanes;0<E;){var C=31-Gt(E),F=1<<C,V=v[C];V===-1?((F&d)===0||(F&k)!==0)&&(v[C]=tr(F,a)):V<=a&&(s.expiredLanes|=F),E&=~F}}function xr(s){return s=s.pendingLanes&-1073741825,s!==0?s:s&1073741824?1073741824:0}function js(){var s=mt;return mt<<=1,(mt&4194240)===0&&(mt=64),s}function Mr(s){for(var a=[],d=0;31>d;d++)a.push(s);return a}function Lr(s,a,d){s.pendingLanes|=a,a!==536870912&&(s.suspendedLanes=0,s.pingedLanes=0),s=s.eventTimes,a=31-Gt(a),s[a]=d}function wr(s,a){var d=s.pendingLanes&~a;s.pendingLanes=a,s.suspendedLanes=0,s.pingedLanes=0,s.expiredLanes&=a,s.mutableReadLanes&=a,s.entangledLanes&=a,a=s.entanglements;var k=s.eventTimes;for(s=s.expirationTimes;0<d;){var v=31-Gt(d),E=1<<v;a[v]=0,k[v]=-1,s[v]=-1,d&=~E}}function Co(s,a){var d=s.entangledLanes|=a;for(s=s.entanglements;d;){var k=31-Gt(d),v=1<<k;v&a|s[k]&a&&(s[k]|=a),d&=~v}}var Xe=0;function gt(s){return s&=-s,1<s?4<s?(s&268435455)!==0?16:536870912:4:1}var Ao,ln,Xt,Pr,Xn,Ne=!1,O=[],D=null,ne=null,ye=null,Ae=new Map,We=new Map,xt=[],cn="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 Gn(s,a){switch(s){case"focusin":case"focusout":D=null;break;case"dragenter":case"dragleave":ne=null;break;case"mouseover":case"mouseout":ye=null;break;case"pointerover":case"pointerout":Ae.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":We.delete(a.pointerId)}}function Ln(s,a,d,k,v,E){return s===null||s.nativeEvent!==E?(s={blockedOn:a,domEventName:d,eventSystemFlags:k,nativeEvent:E,targetContainers:[v]},a!==null&&(a=xl(a),a!==null&&ln(a)),s):(s.eventSystemFlags|=k,a=s.targetContainers,v!==null&&a.indexOf(v)===-1&&a.push(v),s)}function yr(s,a,d,k,v){switch(a){case"focusin":return D=Ln(D,s,a,d,k,v),!0;case"dragenter":return ne=Ln(ne,s,a,d,k,v),!0;case"mouseover":return ye=Ln(ye,s,a,d,k,v),!0;case"pointerover":var E=v.pointerId;return Ae.set(E,Ln(Ae.get(E)||null,s,a,d,k,v)),!0;case"gotpointercapture":return E=v.pointerId,We.set(E,Ln(We.get(E)||null,s,a,d,k,v)),!0}return!1}function nr(s){var a=hi(s.target);if(a!==null){var d=cr(a);if(d!==null){if(a=d.tag,a===13){if(a=Yt(d),a!==null){s.blockedOn=a,Xn(s.priority,function(){Xt(d)});return}}else if(a===3&&d.stateNode.current.memoizedState.isDehydrated){s.blockedOn=d.tag===3?d.stateNode.containerInfo:null;return}}}s.blockedOn=null}function Zi(s){if(s.blockedOn!==null)return!1;for(var a=s.targetContainers;0<a.length;){var d=Xi(s.domEventName,s.eventSystemFlags,a[0],s.nativeEvent);if(d===null){d=s.nativeEvent;var k=new d.constructor(d.type,d);bn=k,d.target.dispatchEvent(k),bn=null}else return a=xl(d),a!==null&&ln(a),s.blockedOn=d,!1;a.shift()}return!0}function qi(s,a,d){Zi(s)&&d.delete(a)}function cl(){Ne=!1,D!==null&&Zi(D)&&(D=null),ne!==null&&Zi(ne)&&(ne=null),ye!==null&&Zi(ye)&&(ye=null),Ae.forEach(qi),We.forEach(qi)}function Io(s,a){s.blockedOn===a&&(s.blockedOn=null,Ne||(Ne=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,cl)))}function ss(s){function a(v){return Io(v,s)}if(0<O.length){Io(O[0],s);for(var d=1;d<O.length;d++){var k=O[d];k.blockedOn===s&&(k.blockedOn=null)}}for(D!==null&&Io(D,s),ne!==null&&Io(ne,s),ye!==null&&Io(ye,s),Ae.forEach(a),We.forEach(a),d=0;d<xt.length;d++)k=xt[d],k.blockedOn===s&&(k.blockedOn=null);for(;0<xt.length&&(d=xt[0],d.blockedOn===null);)nr(d),d.blockedOn===null&&xt.shift()}var is=R.ReactCurrentBatchConfig,Gi=!0;function ul(s,a,d,k){var v=Xe,E=is.transition;is.transition=null;try{Xe=1,Vi(s,a,d,k)}finally{Xe=v,is.transition=E}}function Df(s,a,d,k){var v=Xe,E=is.transition;is.transition=null;try{Xe=4,Vi(s,a,d,k)}finally{Xe=v,is.transition=E}}function Vi(s,a,d,k){if(Gi){var v=Xi(s,a,d,k);if(v===null)th(s,a,k,Yi,d),Gn(s,k);else if(yr(v,s,a,d,k))k.stopPropagation();else if(Gn(s,k),a&4&&-1<cn.indexOf(s)){for(;v!==null;){var E=xl(v);if(E!==null&&Ao(E),E=Xi(s,a,d,k),E===null&&th(s,a,k,Yi,d),E===v)break;v=E}v!==null&&k.stopPropagation()}else th(s,a,k,null,d)}}var Yi=null;function Xi(s,a,d,k){if(Yi=null,s=wn(k),s=hi(s),s!==null)if(a=cr(s),a===null)s=null;else if(d=a.tag,d===13){if(s=Yt(a),s!==null)return s;s=null}else if(d===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;s=null}else a!==s&&(s=null);return Yi=s,null}function Dc(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(ur()){case Or:return 1;case On:return 4;case St:case je:return 16;case Se:return 536870912;default:return 16}default:return 16}}var jn=null,Qi=null,ui=null;function Ji(){if(ui)return ui;var s,a=Qi,d=a.length,k,v="value"in jn?jn.value:jn.textContent,E=v.length;for(s=0;s<d&&a[s]===v[s];s++);var C=d-s;for(k=1;k<=C&&a[d-k]===v[E-k];k++);return ui=v.slice(s,1<k?1-k:void 0)}function Cs(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 as(){return!0}function Qn(){return!1}function dr(s){function a(d,k,v,E,C){this._reactName=d,this._targetInst=v,this.type=k,this.nativeEvent=E,this.target=C,this.currentTarget=null;for(var F in s)s.hasOwnProperty(F)&&(d=s[F],this[F]=d?d(E):E[F]);return this.isDefaultPrevented=(E.defaultPrevented!=null?E.defaultPrevented:E.returnValue===!1)?as:Qn,this.isPropagationStopped=Qn,this}return te(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var d=this.nativeEvent;d&&(d.preventDefault?d.preventDefault():typeof d.returnValue!="unknown"&&(d.returnValue=!1),this.isDefaultPrevented=as)},stopPropagation:function(){var d=this.nativeEvent;d&&(d.stopPropagation?d.stopPropagation():typeof d.cancelBubble!="unknown"&&(d.cancelBubble=!0),this.isPropagationStopped=as)},persist:function(){},isPersistent:as}),a}var qo={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},As=dr(qo),Go=te({},qo,{view:0,detail:0}),Is=dr(Go),ea,di,ls,fi=te({},Go,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ia,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!==ls&&(ls&&s.type==="mousemove"?(ea=s.screenX-ls.screenX,di=s.screenY-ls.screenY):di=ea=0,ls=s),ea)},movementY:function(s){return"movementY"in s?s.movementY:di}}),zf=dr(fi),zc=te({},fi,{dataTransfer:0}),ta=dr(zc),Fc=te({},Go,{relatedTarget:0}),na=dr(Fc),Bc=te({},qo,{animationName:0,elapsedTime:0,pseudoElement:0}),Vn=dr(Bc),Ff=te({},qo,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),ra=dr(Ff),oa=te({},qo,{data:0}),sa=dr(oa),Bf={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},dl={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"},Uf={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Uc(s){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(s):(s=Uf[s])?!!a[s]:!1}function ia(){return Uc}var Hc=te({},Go,{key:function(s){if(s.key){var a=Bf[s.key]||s.key;if(a!=="Unidentified")return a}return s.type==="keypress"?(s=Cs(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?dl[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ia,charCode:function(s){return s.type==="keypress"?Cs(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?Cs(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),Kc=dr(Hc),Wc=te({},fi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Rs=dr(Wc),Zc=te({},Go,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ia}),Hf=dr(Zc),Kf=te({},qo,{propertyName:0,elapsedTime:0,pseudoElement:0}),qc=dr(Kf),Gc=te({},fi,{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}),Vc=dr(Gc),Yc=[9,13,27,32],aa=u&&"CompositionEvent"in window,$s=null;u&&"documentMode"in document&&($s=document.documentMode);var Xc=u&&"TextEvent"in window&&!$s,fl=u&&(!aa||$s&&8<$s&&11>=$s),hl=" ",Z=!1;function et(s,a){switch(s){case"keyup":return Yc.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Nt(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var Kt=!1;function Hr(s,a){switch(s){case"compositionend":return Nt(a);case"keypress":return a.which!==32?null:(Z=!0,hl);case"textInput":return s=a.data,s===hl&&Z?null:s;default:return null}}function Dr(s,a){if(Kt)return s==="compositionend"||!aa&&et(s,a)?(s=Ji(),ui=Qi=jn=null,Kt=!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 fl&&a.locale!=="ko"?null:a.data;default:return null}}var Wf={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 Qc(s){var a=s&&s.nodeName&&s.nodeName.toLowerCase();return a==="input"?!!Wf[s.type]:a==="textarea"}function Vk(s,a,d,k){H(k),a=ru(a,"onChange"),0<a.length&&(d=new As("onChange","change",null,d,k),s.push({event:d,listeners:a}))}var pl=null,ml=null;function QN(s){hw(s,0)}function Jc(s){var a=fa(s);if(Fe(a))return s}function JN(s,a){if(s==="change")return a}var Yk=!1;if(u){var Zf;if(u){var qf="oninput"in document;if(!qf){var Xk=document.createElement("div");Xk.setAttribute("oninput","return;"),qf=typeof Xk.oninput=="function"}Zf=qf}else Zf=!1;Yk=Zf&&(!document.documentMode||9<document.documentMode)}function Qk(){pl&&(pl.detachEvent("onpropertychange",Jk),ml=pl=null)}function Jk(s){if(s.propertyName==="value"&&Jc(ml)){var a=[];Vk(a,ml,s,wn(s)),Pt(QN,a)}}function eT(s,a,d){s==="focusin"?(Qk(),pl=a,ml=d,pl.attachEvent("onpropertychange",Jk)):s==="focusout"&&Qk()}function tT(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return Jc(ml)}function nT(s,a){if(s==="click")return Jc(a)}function rT(s,a){if(s==="input"||s==="change")return Jc(a)}function oT(s,a){return s===a&&(s!==0||1/s===1/a)||s!==s&&a!==a}var Ro=typeof Object.is=="function"?Object.is:oT;function gl(s,a){if(Ro(s,a))return!0;if(typeof s!="object"||s===null||typeof a!="object"||a===null)return!1;var d=Object.keys(s),k=Object.keys(a);if(d.length!==k.length)return!1;for(k=0;k<d.length;k++){var v=d[k];if(!c.call(a,v)||!Ro(s[v],a[v]))return!1}return!0}function ew(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function tw(s,a){var d=ew(s);s=0;for(var k;d;){if(d.nodeType===3){if(k=s+d.textContent.length,s<=a&&k>=a)return{node:d,offset:a-s};s=k}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=ew(d)}}function nw(s,a){return s&&a?s===a?!0:s&&s.nodeType===3?!1:a&&a.nodeType===3?nw(s,a.parentNode):"contains"in s?s.contains(a):s.compareDocumentPosition?!!(s.compareDocumentPosition(a)&16):!1:!1}function rw(){for(var s=window,a=Qe();a instanceof s.HTMLIFrameElement;){try{var d=typeof a.contentWindow.location.href=="string"}catch{d=!1}if(d)s=a.contentWindow;else break;a=Qe(s.document)}return a}function Gf(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 sT(s){var a=rw(),d=s.focusedElem,k=s.selectionRange;if(a!==d&&d&&d.ownerDocument&&nw(d.ownerDocument.documentElement,d)){if(k!==null&&Gf(d)){if(a=k.start,s=k.end,s===void 0&&(s=a),"selectionStart"in d)d.selectionStart=a,d.selectionEnd=Math.min(s,d.value.length);else if(s=(a=d.ownerDocument||document)&&a.defaultView||window,s.getSelection){s=s.getSelection();var v=d.textContent.length,E=Math.min(k.start,v);k=k.end===void 0?E:Math.min(k.end,v),!s.extend&&E>k&&(v=k,k=E,E=v),v=tw(d,E);var C=tw(d,k);v&&C&&(s.rangeCount!==1||s.anchorNode!==v.node||s.anchorOffset!==v.offset||s.focusNode!==C.node||s.focusOffset!==C.offset)&&(a=a.createRange(),a.setStart(v.node,v.offset),s.removeAllRanges(),E>k?(s.addRange(a),s.extend(C.node,C.offset)):(a.setEnd(C.node,C.offset),s.addRange(a)))}}for(a=[],s=d;s=s.parentNode;)s.nodeType===1&&a.push({element:s,left:s.scrollLeft,top:s.scrollTop});for(typeof d.focus=="function"&&d.focus(),d=0;d<a.length;d++)s=a[d],s.element.scrollLeft=s.left,s.element.scrollTop=s.top}}var iT=u&&"documentMode"in document&&11>=document.documentMode,la=null,Vf=null,kl=null,Yf=!1;function ow(s,a,d){var k=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;Yf||la==null||la!==Qe(k)||(k=la,"selectionStart"in k&&Gf(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}),kl&&gl(kl,k)||(kl=k,k=ru(Vf,"onSelect"),0<k.length&&(a=new As("onSelect","select",null,a,d),s.push({event:a,listeners:k}),a.target=la)))}function eu(s,a){var d={};return d[s.toLowerCase()]=a.toLowerCase(),d["Webkit"+s]="webkit"+a,d["Moz"+s]="moz"+a,d}var ca={animationend:eu("Animation","AnimationEnd"),animationiteration:eu("Animation","AnimationIteration"),animationstart:eu("Animation","AnimationStart"),transitionend:eu("Transition","TransitionEnd")},Xf={},sw={};u&&(sw=document.createElement("div").style,"AnimationEvent"in window||(delete ca.animationend.animation,delete ca.animationiteration.animation,delete ca.animationstart.animation),"TransitionEvent"in window||delete ca.transitionend.transition);function tu(s){if(Xf[s])return Xf[s];if(!ca[s])return s;var a=ca[s],d;for(d in a)if(a.hasOwnProperty(d)&&d in sw)return Xf[s]=a[d];return s}var iw=tu("animationend"),aw=tu("animationiteration"),lw=tu("animationstart"),cw=tu("transitionend"),uw=new Map,dw="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 Os(s,a){uw.set(s,a),i(a,[s])}for(var Qf=0;Qf<dw.length;Qf++){var Jf=dw[Qf],aT=Jf.toLowerCase(),lT=Jf[0].toUpperCase()+Jf.slice(1);Os(aT,"on"+lT)}Os(iw,"onAnimationEnd"),Os(aw,"onAnimationIteration"),Os(lw,"onAnimationStart"),Os("dblclick","onDoubleClick"),Os("focusin","onFocus"),Os("focusout","onBlur"),Os(cw,"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 wl="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(" "),cT=new Set("cancel close invalid load scroll toggle".split(" ").concat(wl));function fw(s,a,d){var k=s.type||"unknown-event";s.currentTarget=d,En(k,a,void 0,s),s.currentTarget=null}function hw(s,a){a=(a&4)!==0;for(var d=0;d<s.length;d++){var k=s[d],v=k.event;k=k.listeners;e:{var E=void 0;if(a)for(var C=k.length-1;0<=C;C--){var F=k[C],V=F.instance,ue=F.currentTarget;if(F=F.listener,V!==E&&v.isPropagationStopped())break e;fw(v,F,ue),E=V}else for(C=0;C<k.length;C++){if(F=k[C],V=F.instance,ue=F.currentTarget,F=F.listener,V!==E&&v.isPropagationStopped())break e;fw(v,F,ue),E=V}}}if(In)throw s=kn,In=!1,kn=null,s}function Rn(s,a){var d=a[ah];d===void 0&&(d=a[ah]=new Set);var k=s+"__bubble";d.has(k)||(pw(a,s,2,!1),d.add(k))}function eh(s,a,d){var k=0;a&&(k|=4),pw(d,s,k,a)}var nu="_reactListening"+Math.random().toString(36).slice(2);function yl(s){if(!s[nu]){s[nu]=!0,r.forEach(function(d){d!=="selectionchange"&&(cT.has(d)||eh(d,!1,s),eh(d,!0,s))});var a=s.nodeType===9?s:s.ownerDocument;a===null||a[nu]||(a[nu]=!0,eh("selectionchange",!1,a))}}function pw(s,a,d,k){switch(Dc(a)){case 1:var v=ul;break;case 4:v=Df;break;default:v=Vi}d=v.bind(null,a,d,s),v=void 0,!Oe||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(v=!0),k?v!==void 0?s.addEventListener(a,d,{capture:!0,passive:v}):s.addEventListener(a,d,!0):v!==void 0?s.addEventListener(a,d,{passive:v}):s.addEventListener(a,d,!1)}function th(s,a,d,k,v){var E=k;if((a&1)===0&&(a&2)===0&&k!==null)e:for(;;){if(k===null)return;var C=k.tag;if(C===3||C===4){var F=k.stateNode.containerInfo;if(F===v||F.nodeType===8&&F.parentNode===v)break;if(C===4)for(C=k.return;C!==null;){var V=C.tag;if((V===3||V===4)&&(V=C.stateNode.containerInfo,V===v||V.nodeType===8&&V.parentNode===v))return;C=C.return}for(;F!==null;){if(C=hi(F),C===null)return;if(V=C.tag,V===5||V===6){k=E=C;continue e}F=F.parentNode}}k=k.return}Pt(function(){var ue=E,Ce=wn(d),Ie=[];e:{var Te=uw.get(s);if(Te!==void 0){var qe=As,tt=s;switch(s){case"keypress":if(Cs(d)===0)break e;case"keydown":case"keyup":qe=Kc;break;case"focusin":tt="focus",qe=na;break;case"focusout":tt="blur",qe=na;break;case"beforeblur":case"afterblur":qe=na;break;case"click":if(d.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":qe=zf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":qe=ta;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":qe=Hf;break;case iw:case aw:case lw:qe=Vn;break;case cw:qe=qc;break;case"scroll":qe=Is;break;case"wheel":qe=Vc;break;case"copy":case"cut":case"paste":qe=ra;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":qe=Rs}var rt=(a&4)!==0,Jn=!rt&&s==="scroll",ie=rt?Te!==null?Te+"Capture":null:Te;rt=[];for(var Q=ue,ce;Q!==null;){ce=Q;var Me=ce.stateNode;if(ce.tag===5&&Me!==null&&(ce=Me,ie!==null&&(Me=Pe(Q,ie),Me!=null&&rt.push(vl(Q,Me,ce)))),Jn)break;Q=Q.return}0<rt.length&&(Te=new qe(Te,tt,null,d,Ce),Ie.push({event:Te,listeners:rt}))}}if((a&7)===0){e:{if(Te=s==="mouseover"||s==="pointerover",qe=s==="mouseout"||s==="pointerout",Te&&d!==bn&&(tt=d.relatedTarget||d.fromElement)&&(hi(tt)||tt[cs]))break e;if((qe||Te)&&(Te=Ce.window===Ce?Ce:(Te=Ce.ownerDocument)?Te.defaultView||Te.parentWindow:window,qe?(tt=d.relatedTarget||d.toElement,qe=ue,tt=tt?hi(tt):null,tt!==null&&(Jn=cr(tt),tt!==Jn||tt.tag!==5&&tt.tag!==6)&&(tt=null)):(qe=null,tt=ue),qe!==tt)){if(rt=zf,Me="onMouseLeave",ie="onMouseEnter",Q="mouse",(s==="pointerout"||s==="pointerover")&&(rt=Rs,Me="onPointerLeave",ie="onPointerEnter",Q="pointer"),Jn=qe==null?Te:fa(qe),ce=tt==null?Te:fa(tt),Te=new rt(Me,Q+"leave",qe,d,Ce),Te.target=Jn,Te.relatedTarget=ce,Me=null,hi(Ce)===ue&&(rt=new rt(ie,Q+"enter",tt,d,Ce),rt.target=ce,rt.relatedTarget=Jn,Me=rt),Jn=Me,qe&&tt)t:{for(rt=qe,ie=tt,Q=0,ce=rt;ce;ce=ua(ce))Q++;for(ce=0,Me=ie;Me;Me=ua(Me))ce++;for(;0<Q-ce;)rt=ua(rt),Q--;for(;0<ce-Q;)ie=ua(ie),ce--;for(;Q--;){if(rt===ie||ie!==null&&rt===ie.alternate)break t;rt=ua(rt),ie=ua(ie)}rt=null}else rt=null;qe!==null&&mw(Ie,Te,qe,rt,!1),tt!==null&&Jn!==null&&mw(Ie,Jn,tt,rt,!0)}}e:{if(Te=ue?fa(ue):window,qe=Te.nodeName&&Te.nodeName.toLowerCase(),qe==="select"||qe==="input"&&Te.type==="file")var ot=JN;else if(Qc(Te))if(Yk)ot=rT;else{ot=tT;var wt=eT}else(qe=Te.nodeName)&&qe.toLowerCase()==="input"&&(Te.type==="checkbox"||Te.type==="radio")&&(ot=nT);if(ot&&(ot=ot(s,ue))){Vk(Ie,ot,d,Ce);break e}wt&&wt(s,Te,ue),s==="focusout"&&(wt=Te._wrapperState)&&wt.controlled&&Te.type==="number"&&tn(Te,"number",Te.value)}switch(wt=ue?fa(ue):window,s){case"focusin":(Qc(wt)||wt.contentEditable==="true")&&(la=wt,Vf=ue,kl=null);break;case"focusout":kl=Vf=la=null;break;case"mousedown":Yf=!0;break;case"contextmenu":case"mouseup":case"dragend":Yf=!1,ow(Ie,d,Ce);break;case"selectionchange":if(iT)break;case"keydown":case"keyup":ow(Ie,d,Ce)}var yt;if(aa)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 Kt?et(s,d)&&(_t="onCompositionEnd"):s==="keydown"&&d.keyCode===229&&(_t="onCompositionStart");_t&&(fl&&d.locale!=="ko"&&(Kt||_t!=="onCompositionStart"?_t==="onCompositionEnd"&&Kt&&(yt=Ji()):(jn=Ce,Qi="value"in jn?jn.value:jn.textContent,Kt=!0)),wt=ru(ue,_t),0<wt.length&&(_t=new sa(_t,s,null,d,Ce),Ie.push({event:_t,listeners:wt}),yt?_t.data=yt:(yt=Nt(d),yt!==null&&(_t.data=yt)))),(yt=Xc?Hr(s,d):Dr(s,d))&&(ue=ru(ue,"onBeforeInput"),0<ue.length&&(Ce=new sa("onBeforeInput","beforeinput",null,d,Ce),Ie.push({event:Ce,listeners:ue}),Ce.data=yt))}hw(Ie,a)})}function vl(s,a,d){return{instance:s,listener:a,currentTarget:d}}function ru(s,a){for(var d=a+"Capture",k=[];s!==null;){var v=s,E=v.stateNode;v.tag===5&&E!==null&&(v=E,E=Pe(s,d),E!=null&&k.unshift(vl(s,E,v)),E=Pe(s,a),E!=null&&k.push(vl(s,E,v))),s=s.return}return k}function ua(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5);return s||null}function mw(s,a,d,k,v){for(var E=a._reactName,C=[];d!==null&&d!==k;){var F=d,V=F.alternate,ue=F.stateNode;if(V!==null&&V===k)break;F.tag===5&&ue!==null&&(F=ue,v?(V=Pe(d,E),V!=null&&C.unshift(vl(d,V,F))):v||(V=Pe(d,E),V!=null&&C.push(vl(d,V,F)))),d=d.return}C.length!==0&&s.push({event:a,listeners:C})}var uT=/\r\n?/g,dT=/\u0000|\uFFFD/g;function gw(s){return(typeof s=="string"?s:""+s).replace(uT,`
|
|
39
|
+
`).replace(dT,"")}function ou(s,a,d){if(a=gw(a),gw(s)!==a&&d)throw Error(n(425))}function su(){}var nh=null,rh=null;function oh(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 sh=typeof setTimeout=="function"?setTimeout:void 0,fT=typeof clearTimeout=="function"?clearTimeout:void 0,kw=typeof Promise=="function"?Promise:void 0,hT=typeof queueMicrotask=="function"?queueMicrotask:typeof kw<"u"?function(s){return kw.resolve(null).then(s).catch(pT)}:sh;function pT(s){setTimeout(function(){throw s})}function ih(s,a){var d=a,k=0;do{var v=d.nextSibling;if(s.removeChild(d),v&&v.nodeType===8)if(d=v.data,d==="/$"){if(k===0){s.removeChild(v),ss(a);return}k--}else d!=="$"&&d!=="$?"&&d!=="$!"||k++;d=v}while(d);ss(a)}function Ms(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 ww(s){s=s.previousSibling;for(var a=0;s;){if(s.nodeType===8){var d=s.data;if(d==="$"||d==="$!"||d==="$?"){if(a===0)return s;a--}else d==="/$"&&a++}s=s.previousSibling}return null}var da=Math.random().toString(36).slice(2),Vo="__reactFiber$"+da,bl="__reactProps$"+da,cs="__reactContainer$"+da,ah="__reactEvents$"+da,mT="__reactListeners$"+da,gT="__reactHandles$"+da;function hi(s){var a=s[Vo];if(a)return a;for(var d=s.parentNode;d;){if(a=d[cs]||d[Vo]){if(d=a.alternate,a.child!==null||d!==null&&d.child!==null)for(s=ww(s);s!==null;){if(d=s[Vo])return d;s=ww(s)}return a}s=d,d=s.parentNode}return null}function xl(s){return s=s[Vo]||s[cs],!s||s.tag!==5&&s.tag!==6&&s.tag!==13&&s.tag!==3?null:s}function fa(s){if(s.tag===5||s.tag===6)return s.stateNode;throw Error(n(33))}function iu(s){return s[bl]||null}var lh=[],ha=-1;function Ls(s){return{current:s}}function $n(s){0>ha||(s.current=lh[ha],lh[ha]=null,ha--)}function Cn(s,a){ha++,lh[ha]=s.current,s.current=a}var Ps={},Er=Ls(Ps),Kr=Ls(!1),pi=Ps;function pa(s,a){var d=s.type.contextTypes;if(!d)return Ps;var k=s.stateNode;if(k&&k.__reactInternalMemoizedUnmaskedChildContext===a)return k.__reactInternalMemoizedMaskedChildContext;var v={},E;for(E in d)v[E]=a[E];return k&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=a,s.__reactInternalMemoizedMaskedChildContext=v),v}function Wr(s){return s=s.childContextTypes,s!=null}function au(){$n(Kr),$n(Er)}function yw(s,a,d){if(Er.current!==Ps)throw Error(n(168));Cn(Er,a),Cn(Kr,d)}function vw(s,a,d){var k=s.stateNode;if(a=a.childContextTypes,typeof k.getChildContext!="function")return d;k=k.getChildContext();for(var v in k)if(!(v in a))throw Error(n(108,J(s)||"Unknown",v));return te({},d,k)}function lu(s){return s=(s=s.stateNode)&&s.__reactInternalMemoizedMergedChildContext||Ps,pi=Er.current,Cn(Er,s),Cn(Kr,Kr.current),!0}function bw(s,a,d){var k=s.stateNode;if(!k)throw Error(n(169));d?(s=vw(s,a,pi),k.__reactInternalMemoizedMergedChildContext=s,$n(Kr),$n(Er),Cn(Er,s)):$n(Kr),Cn(Kr,d)}var us=null,cu=!1,ch=!1;function xw(s){us===null?us=[s]:us.push(s)}function kT(s){cu=!0,xw(s)}function Ds(){if(!ch&&us!==null){ch=!0;var s=0,a=Xe;try{var d=us;for(Xe=1;s<d.length;s++){var k=d[s];do k=k(!0);while(k!==null)}us=null,cu=!1}catch(v){throw us!==null&&(us=us.slice(s+1)),Ze(Or,Ds),v}finally{Xe=a,ch=!1}}return null}var ma=[],ga=0,uu=null,du=0,po=[],mo=0,mi=null,ds=1,fs="";function gi(s,a){ma[ga++]=du,ma[ga++]=uu,uu=s,du=a}function Ew(s,a,d){po[mo++]=ds,po[mo++]=fs,po[mo++]=mi,mi=s;var k=ds;s=fs;var v=32-Gt(k)-1;k&=~(1<<v),d+=1;var E=32-Gt(a)+v;if(30<E){var C=v-v%5;E=(k&(1<<C)-1).toString(32),k>>=C,v-=C,ds=1<<32-Gt(a)+v|d<<v|k,fs=E+s}else ds=1<<E|d<<v|k,fs=s}function uh(s){s.return!==null&&(gi(s,1),Ew(s,1,0))}function dh(s){for(;s===uu;)uu=ma[--ga],ma[ga]=null,du=ma[--ga],ma[ga]=null;for(;s===mi;)mi=po[--mo],po[mo]=null,fs=po[--mo],po[mo]=null,ds=po[--mo],po[mo]=null}var so=null,io=null,Pn=!1,$o=null;function _w(s,a){var d=yo(5,null,null,0);d.elementType="DELETED",d.stateNode=a,d.return=s,a=s.deletions,a===null?(s.deletions=[d],s.flags|=16):a.push(d)}function Sw(s,a){switch(s.tag){case 5:var d=s.type;return a=a.nodeType!==1||d.toLowerCase()!==a.nodeName.toLowerCase()?null:a,a!==null?(s.stateNode=a,so=s,io=Ms(a.firstChild),!0):!1;case 6:return a=s.pendingProps===""||a.nodeType!==3?null:a,a!==null?(s.stateNode=a,so=s,io=null,!0):!1;case 13:return a=a.nodeType!==8?null:a,a!==null?(d=mi!==null?{id:ds,overflow:fs}:null,s.memoizedState={dehydrated:a,treeContext:d,retryLane:1073741824},d=yo(18,null,null,0),d.stateNode=a,d.return=s,s.child=d,so=s,io=null,!0):!1;default:return!1}}function fh(s){return(s.mode&1)!==0&&(s.flags&128)===0}function hh(s){if(Pn){var a=io;if(a){var d=a;if(!Sw(s,a)){if(fh(s))throw Error(n(418));a=Ms(d.nextSibling);var k=so;a&&Sw(s,a)?_w(k,d):(s.flags=s.flags&-4097|2,Pn=!1,so=s)}}else{if(fh(s))throw Error(n(418));s.flags=s.flags&-4097|2,Pn=!1,so=s}}}function Nw(s){for(s=s.return;s!==null&&s.tag!==5&&s.tag!==3&&s.tag!==13;)s=s.return;so=s}function fu(s){if(s!==so)return!1;if(!Pn)return Nw(s),Pn=!0,!1;var a;if((a=s.tag!==3)&&!(a=s.tag!==5)&&(a=s.type,a=a!=="head"&&a!=="body"&&!oh(s.type,s.memoizedProps)),a&&(a=io)){if(fh(s))throw Tw(),Error(n(418));for(;a;)_w(s,a),a=Ms(a.nextSibling)}if(Nw(s),s.tag===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(n(317));e:{for(s=s.nextSibling,a=0;s;){if(s.nodeType===8){var d=s.data;if(d==="/$"){if(a===0){io=Ms(s.nextSibling);break e}a--}else d!=="$"&&d!=="$!"&&d!=="$?"||a++}s=s.nextSibling}io=null}}else io=so?Ms(s.stateNode.nextSibling):null;return!0}function Tw(){for(var s=io;s;)s=Ms(s.nextSibling)}function ka(){io=so=null,Pn=!1}function ph(s){$o===null?$o=[s]:$o.push(s)}var wT=R.ReactCurrentBatchConfig;function El(s,a,d){if(s=d.ref,s!==null&&typeof s!="function"&&typeof s!="object"){if(d._owner){if(d=d._owner,d){if(d.tag!==1)throw Error(n(309));var k=d.stateNode}if(!k)throw Error(n(147,s));var v=k,E=""+s;return a!==null&&a.ref!==null&&typeof a.ref=="function"&&a.ref._stringRef===E?a.ref:(a=function(C){var F=v.refs;C===null?delete F[E]:F[E]=C},a._stringRef=E,a)}if(typeof s!="string")throw Error(n(284));if(!d._owner)throw Error(n(290,s))}return s}function hu(s,a){throw s=Object.prototype.toString.call(a),Error(n(31,s==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":s))}function jw(s){var a=s._init;return a(s._payload)}function Cw(s){function a(ie,Q){if(s){var ce=ie.deletions;ce===null?(ie.deletions=[Q],ie.flags|=16):ce.push(Q)}}function d(ie,Q){if(!s)return null;for(;Q!==null;)a(ie,Q),Q=Q.sibling;return null}function k(ie,Q){for(ie=new Map;Q!==null;)Q.key!==null?ie.set(Q.key,Q):ie.set(Q.index,Q),Q=Q.sibling;return ie}function v(ie,Q){return ie=Zs(ie,Q),ie.index=0,ie.sibling=null,ie}function E(ie,Q,ce){return ie.index=ce,s?(ce=ie.alternate,ce!==null?(ce=ce.index,ce<Q?(ie.flags|=2,Q):ce):(ie.flags|=2,Q)):(ie.flags|=1048576,Q)}function C(ie){return s&&ie.alternate===null&&(ie.flags|=2),ie}function F(ie,Q,ce,Me){return Q===null||Q.tag!==6?(Q=sp(ce,ie.mode,Me),Q.return=ie,Q):(Q=v(Q,ce),Q.return=ie,Q)}function V(ie,Q,ce,Me){var ot=ce.type;return ot===A?Ce(ie,Q,ce.props.children,Me,ce.key):Q!==null&&(Q.elementType===ot||typeof ot=="object"&&ot!==null&&ot.$$typeof===ke&&jw(ot)===Q.type)?(Me=v(Q,ce.props),Me.ref=El(ie,Q,ce),Me.return=ie,Me):(Me=Pu(ce.type,ce.key,ce.props,null,ie.mode,Me),Me.ref=El(ie,Q,ce),Me.return=ie,Me)}function ue(ie,Q,ce,Me){return Q===null||Q.tag!==4||Q.stateNode.containerInfo!==ce.containerInfo||Q.stateNode.implementation!==ce.implementation?(Q=ip(ce,ie.mode,Me),Q.return=ie,Q):(Q=v(Q,ce.children||[]),Q.return=ie,Q)}function Ce(ie,Q,ce,Me,ot){return Q===null||Q.tag!==7?(Q=_i(ce,ie.mode,Me,ot),Q.return=ie,Q):(Q=v(Q,ce),Q.return=ie,Q)}function Ie(ie,Q,ce){if(typeof Q=="string"&&Q!==""||typeof Q=="number")return Q=sp(""+Q,ie.mode,ce),Q.return=ie,Q;if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case $:return ce=Pu(Q.type,Q.key,Q.props,null,ie.mode,ce),ce.ref=El(ie,null,Q),ce.return=ie,ce;case W:return Q=ip(Q,ie.mode,ce),Q.return=ie,Q;case ke:var Me=Q._init;return Ie(ie,Me(Q._payload),ce)}if(Vt(Q)||re(Q))return Q=_i(Q,ie.mode,ce,null),Q.return=ie,Q;hu(ie,Q)}return null}function Te(ie,Q,ce,Me){var ot=Q!==null?Q.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number")return ot!==null?null:F(ie,Q,""+ce,Me);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case $:return ce.key===ot?V(ie,Q,ce,Me):null;case W:return ce.key===ot?ue(ie,Q,ce,Me):null;case ke:return ot=ce._init,Te(ie,Q,ot(ce._payload),Me)}if(Vt(ce)||re(ce))return ot!==null?null:Ce(ie,Q,ce,Me,null);hu(ie,ce)}return null}function qe(ie,Q,ce,Me,ot){if(typeof Me=="string"&&Me!==""||typeof Me=="number")return ie=ie.get(ce)||null,F(Q,ie,""+Me,ot);if(typeof Me=="object"&&Me!==null){switch(Me.$$typeof){case $:return ie=ie.get(Me.key===null?ce:Me.key)||null,V(Q,ie,Me,ot);case W:return ie=ie.get(Me.key===null?ce:Me.key)||null,ue(Q,ie,Me,ot);case ke:var wt=Me._init;return qe(ie,Q,ce,wt(Me._payload),ot)}if(Vt(Me)||re(Me))return ie=ie.get(ce)||null,Ce(Q,ie,Me,ot,null);hu(Q,Me)}return null}function tt(ie,Q,ce,Me){for(var ot=null,wt=null,yt=Q,_t=Q=0,pr=null;yt!==null&&_t<ce.length;_t++){yt.index>_t?(pr=yt,yt=null):pr=yt.sibling;var un=Te(ie,yt,ce[_t],Me);if(un===null){yt===null&&(yt=pr);break}s&&yt&&un.alternate===null&&a(ie,yt),Q=E(un,Q,_t),wt===null?ot=un:wt.sibling=un,wt=un,yt=pr}if(_t===ce.length)return d(ie,yt),Pn&&gi(ie,_t),ot;if(yt===null){for(;_t<ce.length;_t++)yt=Ie(ie,ce[_t],Me),yt!==null&&(Q=E(yt,Q,_t),wt===null?ot=yt:wt.sibling=yt,wt=yt);return Pn&&gi(ie,_t),ot}for(yt=k(ie,yt);_t<ce.length;_t++)pr=qe(yt,ie,_t,ce[_t],Me),pr!==null&&(s&&pr.alternate!==null&&yt.delete(pr.key===null?_t:pr.key),Q=E(pr,Q,_t),wt===null?ot=pr:wt.sibling=pr,wt=pr);return s&&yt.forEach(function(qs){return a(ie,qs)}),Pn&&gi(ie,_t),ot}function rt(ie,Q,ce,Me){var ot=re(ce);if(typeof ot!="function")throw Error(n(150));if(ce=ot.call(ce),ce==null)throw Error(n(151));for(var wt=ot=null,yt=Q,_t=Q=0,pr=null,un=ce.next();yt!==null&&!un.done;_t++,un=ce.next()){yt.index>_t?(pr=yt,yt=null):pr=yt.sibling;var qs=Te(ie,yt,un.value,Me);if(qs===null){yt===null&&(yt=pr);break}s&&yt&&qs.alternate===null&&a(ie,yt),Q=E(qs,Q,_t),wt===null?ot=qs:wt.sibling=qs,wt=qs,yt=pr}if(un.done)return d(ie,yt),Pn&&gi(ie,_t),ot;if(yt===null){for(;!un.done;_t++,un=ce.next())un=Ie(ie,un.value,Me),un!==null&&(Q=E(un,Q,_t),wt===null?ot=un:wt.sibling=un,wt=un);return Pn&&gi(ie,_t),ot}for(yt=k(ie,yt);!un.done;_t++,un=ce.next())un=qe(yt,ie,_t,un.value,Me),un!==null&&(s&&un.alternate!==null&&yt.delete(un.key===null?_t:un.key),Q=E(un,Q,_t),wt===null?ot=un:wt.sibling=un,wt=un);return s&&yt.forEach(function(XT){return a(ie,XT)}),Pn&&gi(ie,_t),ot}function Jn(ie,Q,ce,Me){if(typeof ce=="object"&&ce!==null&&ce.type===A&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case $:e:{for(var ot=ce.key,wt=Q;wt!==null;){if(wt.key===ot){if(ot=ce.type,ot===A){if(wt.tag===7){d(ie,wt.sibling),Q=v(wt,ce.props.children),Q.return=ie,ie=Q;break e}}else if(wt.elementType===ot||typeof ot=="object"&&ot!==null&&ot.$$typeof===ke&&jw(ot)===wt.type){d(ie,wt.sibling),Q=v(wt,ce.props),Q.ref=El(ie,wt,ce),Q.return=ie,ie=Q;break e}d(ie,wt);break}else a(ie,wt);wt=wt.sibling}ce.type===A?(Q=_i(ce.props.children,ie.mode,Me,ce.key),Q.return=ie,ie=Q):(Me=Pu(ce.type,ce.key,ce.props,null,ie.mode,Me),Me.ref=El(ie,Q,ce),Me.return=ie,ie=Me)}return C(ie);case W:e:{for(wt=ce.key;Q!==null;){if(Q.key===wt)if(Q.tag===4&&Q.stateNode.containerInfo===ce.containerInfo&&Q.stateNode.implementation===ce.implementation){d(ie,Q.sibling),Q=v(Q,ce.children||[]),Q.return=ie,ie=Q;break e}else{d(ie,Q);break}else a(ie,Q);Q=Q.sibling}Q=ip(ce,ie.mode,Me),Q.return=ie,ie=Q}return C(ie);case ke:return wt=ce._init,Jn(ie,Q,wt(ce._payload),Me)}if(Vt(ce))return tt(ie,Q,ce,Me);if(re(ce))return rt(ie,Q,ce,Me);hu(ie,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"?(ce=""+ce,Q!==null&&Q.tag===6?(d(ie,Q.sibling),Q=v(Q,ce),Q.return=ie,ie=Q):(d(ie,Q),Q=sp(ce,ie.mode,Me),Q.return=ie,ie=Q),C(ie)):d(ie,Q)}return Jn}var wa=Cw(!0),Aw=Cw(!1),pu=Ls(null),mu=null,ya=null,mh=null;function gh(){mh=ya=mu=null}function kh(s){var a=pu.current;$n(pu),s._currentValue=a}function wh(s,a,d){for(;s!==null;){var k=s.alternate;if((s.childLanes&a)!==a?(s.childLanes|=a,k!==null&&(k.childLanes|=a)):k!==null&&(k.childLanes&a)!==a&&(k.childLanes|=a),s===d)break;s=s.return}}function va(s,a){mu=s,mh=ya=null,s=s.dependencies,s!==null&&s.firstContext!==null&&((s.lanes&a)!==0&&(Zr=!0),s.firstContext=null)}function go(s){var a=s._currentValue;if(mh!==s)if(s={context:s,memoizedValue:a,next:null},ya===null){if(mu===null)throw Error(n(308));ya=s,mu.dependencies={lanes:0,firstContext:s}}else ya=ya.next=s;return a}var ki=null;function yh(s){ki===null?ki=[s]:ki.push(s)}function Iw(s,a,d,k){var v=a.interleaved;return v===null?(d.next=d,yh(a)):(d.next=v.next,v.next=d),a.interleaved=d,hs(s,k)}function hs(s,a){s.lanes|=a;var d=s.alternate;for(d!==null&&(d.lanes|=a),d=s,s=s.return;s!==null;)s.childLanes|=a,d=s.alternate,d!==null&&(d.childLanes|=a),d=s,s=s.return;return d.tag===3?d.stateNode:null}var zs=!1;function vh(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Rw(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 ps(s,a){return{eventTime:s,lane:a,tag:0,payload:null,callback:null,next:null}}function Fs(s,a,d){var k=s.updateQueue;if(k===null)return null;if(k=k.shared,(on&2)!==0){var v=k.pending;return v===null?a.next=a:(a.next=v.next,v.next=a),k.pending=a,hs(s,d)}return v=k.interleaved,v===null?(a.next=a,yh(k)):(a.next=v.next,v.next=a),k.interleaved=a,hs(s,d)}function gu(s,a,d){if(a=a.updateQueue,a!==null&&(a=a.shared,(d&4194240)!==0)){var k=a.lanes;k&=s.pendingLanes,d|=k,a.lanes=d,Co(s,d)}}function $w(s,a){var d=s.updateQueue,k=s.alternate;if(k!==null&&(k=k.updateQueue,d===k)){var v=null,E=null;if(d=d.firstBaseUpdate,d!==null){do{var C={eventTime:d.eventTime,lane:d.lane,tag:d.tag,payload:d.payload,callback:d.callback,next:null};E===null?v=E=C:E=E.next=C,d=d.next}while(d!==null);E===null?v=E=a:E=E.next=a}else v=E=a;d={baseState:k.baseState,firstBaseUpdate:v,lastBaseUpdate:E,shared:k.shared,effects:k.effects},s.updateQueue=d;return}s=d.lastBaseUpdate,s===null?d.firstBaseUpdate=a:s.next=a,d.lastBaseUpdate=a}function ku(s,a,d,k){var v=s.updateQueue;zs=!1;var E=v.firstBaseUpdate,C=v.lastBaseUpdate,F=v.shared.pending;if(F!==null){v.shared.pending=null;var V=F,ue=V.next;V.next=null,C===null?E=ue:C.next=ue,C=V;var Ce=s.alternate;Ce!==null&&(Ce=Ce.updateQueue,F=Ce.lastBaseUpdate,F!==C&&(F===null?Ce.firstBaseUpdate=ue:F.next=ue,Ce.lastBaseUpdate=V))}if(E!==null){var Ie=v.baseState;C=0,Ce=ue=V=null,F=E;do{var Te=F.lane,qe=F.eventTime;if((k&Te)===Te){Ce!==null&&(Ce=Ce.next={eventTime:qe,lane:0,tag:F.tag,payload:F.payload,callback:F.callback,next:null});e:{var tt=s,rt=F;switch(Te=a,qe=d,rt.tag){case 1:if(tt=rt.payload,typeof tt=="function"){Ie=tt.call(qe,Ie,Te);break e}Ie=tt;break e;case 3:tt.flags=tt.flags&-65537|128;case 0:if(tt=rt.payload,Te=typeof tt=="function"?tt.call(qe,Ie,Te):tt,Te==null)break e;Ie=te({},Ie,Te);break e;case 2:zs=!0}}F.callback!==null&&F.lane!==0&&(s.flags|=64,Te=v.effects,Te===null?v.effects=[F]:Te.push(F))}else qe={eventTime:qe,lane:Te,tag:F.tag,payload:F.payload,callback:F.callback,next:null},Ce===null?(ue=Ce=qe,V=Ie):Ce=Ce.next=qe,C|=Te;if(F=F.next,F===null){if(F=v.shared.pending,F===null)break;Te=F,F=Te.next,Te.next=null,v.lastBaseUpdate=Te,v.shared.pending=null}}while(!0);if(Ce===null&&(V=Ie),v.baseState=V,v.firstBaseUpdate=ue,v.lastBaseUpdate=Ce,a=v.shared.interleaved,a!==null){v=a;do C|=v.lane,v=v.next;while(v!==a)}else E===null&&(v.shared.lanes=0);vi|=C,s.lanes=C,s.memoizedState=Ie}}function Ow(s,a,d){if(s=a.effects,a.effects=null,s!==null)for(a=0;a<s.length;a++){var k=s[a],v=k.callback;if(v!==null){if(k.callback=null,k=d,typeof v!="function")throw Error(n(191,v));v.call(k)}}}var _l={},Yo=Ls(_l),Sl=Ls(_l),Nl=Ls(_l);function wi(s){if(s===_l)throw Error(n(174));return s}function bh(s,a){switch(Cn(Nl,a),Cn(Sl,s),Cn(Yo,_l),s=a.nodeType,s){case 9:case 11:a=(a=a.documentElement)?a.namespaceURI:dt(null,"");break;default:s=s===8?a.parentNode:a,a=s.namespaceURI||null,s=s.tagName,a=dt(a,s)}$n(Yo),Cn(Yo,a)}function ba(){$n(Yo),$n(Sl),$n(Nl)}function Mw(s){wi(Nl.current);var a=wi(Yo.current),d=dt(a,s.type);a!==d&&(Cn(Sl,s),Cn(Yo,d))}function xh(s){Sl.current===s&&($n(Yo),$n(Sl))}var Bn=Ls(0);function wu(s){for(var a=s;a!==null;){if(a.tag===13){var d=a.memoizedState;if(d!==null&&(d=d.dehydrated,d===null||d.data==="$?"||d.data==="$!"))return a}else if(a.tag===19&&a.memoizedProps.revealOrder!==void 0){if((a.flags&128)!==0)return a}else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===s)break;for(;a.sibling===null;){if(a.return===null||a.return===s)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var Eh=[];function _h(){for(var s=0;s<Eh.length;s++)Eh[s]._workInProgressVersionPrimary=null;Eh.length=0}var yu=R.ReactCurrentDispatcher,Sh=R.ReactCurrentBatchConfig,yi=0,Un=null,sr=null,fr=null,vu=!1,Tl=!1,jl=0,yT=0;function _r(){throw Error(n(321))}function Nh(s,a){if(a===null)return!1;for(var d=0;d<a.length&&d<s.length;d++)if(!Ro(s[d],a[d]))return!1;return!0}function Th(s,a,d,k,v,E){if(yi=E,Un=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,yu.current=s===null||s.memoizedState===null?ET:_T,s=d(k,v),Tl){E=0;do{if(Tl=!1,jl=0,25<=E)throw Error(n(301));E+=1,fr=sr=null,a.updateQueue=null,yu.current=ST,s=d(k,v)}while(Tl)}if(yu.current=Eu,a=sr!==null&&sr.next!==null,yi=0,fr=sr=Un=null,vu=!1,a)throw Error(n(300));return s}function jh(){var s=jl!==0;return jl=0,s}function Xo(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return fr===null?Un.memoizedState=fr=s:fr=fr.next=s,fr}function ko(){if(sr===null){var s=Un.alternate;s=s!==null?s.memoizedState:null}else s=sr.next;var a=fr===null?Un.memoizedState:fr.next;if(a!==null)fr=a,sr=s;else{if(s===null)throw Error(n(310));sr=s,s={memoizedState:sr.memoizedState,baseState:sr.baseState,baseQueue:sr.baseQueue,queue:sr.queue,next:null},fr===null?Un.memoizedState=fr=s:fr=fr.next=s}return fr}function Cl(s,a){return typeof a=="function"?a(s):a}function Ch(s){var a=ko(),d=a.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=s;var k=sr,v=k.baseQueue,E=d.pending;if(E!==null){if(v!==null){var C=v.next;v.next=E.next,E.next=C}k.baseQueue=v=E,d.pending=null}if(v!==null){E=v.next,k=k.baseState;var F=C=null,V=null,ue=E;do{var Ce=ue.lane;if((yi&Ce)===Ce)V!==null&&(V=V.next={lane:0,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null}),k=ue.hasEagerState?ue.eagerState:s(k,ue.action);else{var Ie={lane:Ce,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null};V===null?(F=V=Ie,C=k):V=V.next=Ie,Un.lanes|=Ce,vi|=Ce}ue=ue.next}while(ue!==null&&ue!==E);V===null?C=k:V.next=F,Ro(k,a.memoizedState)||(Zr=!0),a.memoizedState=k,a.baseState=C,a.baseQueue=V,d.lastRenderedState=k}if(s=d.interleaved,s!==null){v=s;do E=v.lane,Un.lanes|=E,vi|=E,v=v.next;while(v!==s)}else v===null&&(d.lanes=0);return[a.memoizedState,d.dispatch]}function Ah(s){var a=ko(),d=a.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=s;var k=d.dispatch,v=d.pending,E=a.memoizedState;if(v!==null){d.pending=null;var C=v=v.next;do E=s(E,C.action),C=C.next;while(C!==v);Ro(E,a.memoizedState)||(Zr=!0),a.memoizedState=E,a.baseQueue===null&&(a.baseState=E),d.lastRenderedState=E}return[E,k]}function Lw(){}function Pw(s,a){var d=Un,k=ko(),v=a(),E=!Ro(k.memoizedState,v);if(E&&(k.memoizedState=v,Zr=!0),k=k.queue,Ih(Fw.bind(null,d,k,s),[s]),k.getSnapshot!==a||E||fr!==null&&fr.memoizedState.tag&1){if(d.flags|=2048,Al(9,zw.bind(null,d,k,v,a),void 0,null),hr===null)throw Error(n(349));(yi&30)!==0||Dw(d,a,v)}return v}function Dw(s,a,d){s.flags|=16384,s={getSnapshot:a,value:d},a=Un.updateQueue,a===null?(a={lastEffect:null,stores:null},Un.updateQueue=a,a.stores=[s]):(d=a.stores,d===null?a.stores=[s]:d.push(s))}function zw(s,a,d,k){a.value=d,a.getSnapshot=k,Bw(a)&&Uw(s)}function Fw(s,a,d){return d(function(){Bw(a)&&Uw(s)})}function Bw(s){var a=s.getSnapshot;s=s.value;try{var d=a();return!Ro(s,d)}catch{return!0}}function Uw(s){var a=hs(s,1);a!==null&&Po(a,s,1,-1)}function Hw(s){var a=Xo();return typeof s=="function"&&(s=s()),a.memoizedState=a.baseState=s,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Cl,lastRenderedState:s},a.queue=s,s=s.dispatch=xT.bind(null,Un,s),[a.memoizedState,s]}function Al(s,a,d,k){return s={tag:s,create:a,destroy:d,deps:k,next:null},a=Un.updateQueue,a===null?(a={lastEffect:null,stores:null},Un.updateQueue=a,a.lastEffect=s.next=s):(d=a.lastEffect,d===null?a.lastEffect=s.next=s:(k=d.next,d.next=s,s.next=k,a.lastEffect=s)),s}function Kw(){return ko().memoizedState}function bu(s,a,d,k){var v=Xo();Un.flags|=s,v.memoizedState=Al(1|a,d,void 0,k===void 0?null:k)}function xu(s,a,d,k){var v=ko();k=k===void 0?null:k;var E=void 0;if(sr!==null){var C=sr.memoizedState;if(E=C.destroy,k!==null&&Nh(k,C.deps)){v.memoizedState=Al(a,d,E,k);return}}Un.flags|=s,v.memoizedState=Al(1|a,d,E,k)}function Ww(s,a){return bu(8390656,8,s,a)}function Ih(s,a){return xu(2048,8,s,a)}function Zw(s,a){return xu(4,2,s,a)}function qw(s,a){return xu(4,4,s,a)}function Gw(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 Vw(s,a,d){return d=d!=null?d.concat([s]):null,xu(4,4,Gw.bind(null,a,s),d)}function Rh(){}function Yw(s,a){var d=ko();a=a===void 0?null:a;var k=d.memoizedState;return k!==null&&a!==null&&Nh(a,k[1])?k[0]:(d.memoizedState=[s,a],s)}function Xw(s,a){var d=ko();a=a===void 0?null:a;var k=d.memoizedState;return k!==null&&a!==null&&Nh(a,k[1])?k[0]:(s=s(),d.memoizedState=[s,a],s)}function Qw(s,a,d){return(yi&21)===0?(s.baseState&&(s.baseState=!1,Zr=!0),s.memoizedState=d):(Ro(d,a)||(d=js(),Un.lanes|=d,vi|=d,s.baseState=!0),a)}function vT(s,a){var d=Xe;Xe=d!==0&&4>d?d:4,s(!0);var k=Sh.transition;Sh.transition={};try{s(!1),a()}finally{Xe=d,Sh.transition=k}}function Jw(){return ko().memoizedState}function bT(s,a,d){var k=Ks(s);if(d={lane:k,action:d,hasEagerState:!1,eagerState:null,next:null},ey(s))ty(a,d);else if(d=Iw(s,a,d,k),d!==null){var v=Fr();Po(d,s,k,v),ny(d,a,k)}}function xT(s,a,d){var k=Ks(s),v={lane:k,action:d,hasEagerState:!1,eagerState:null,next:null};if(ey(s))ty(a,v);else{var E=s.alternate;if(s.lanes===0&&(E===null||E.lanes===0)&&(E=a.lastRenderedReducer,E!==null))try{var C=a.lastRenderedState,F=E(C,d);if(v.hasEagerState=!0,v.eagerState=F,Ro(F,C)){var V=a.interleaved;V===null?(v.next=v,yh(a)):(v.next=V.next,V.next=v),a.interleaved=v;return}}catch{}finally{}d=Iw(s,a,v,k),d!==null&&(v=Fr(),Po(d,s,k,v),ny(d,a,k))}}function ey(s){var a=s.alternate;return s===Un||a!==null&&a===Un}function ty(s,a){Tl=vu=!0;var d=s.pending;d===null?a.next=a:(a.next=d.next,d.next=a),s.pending=a}function ny(s,a,d){if((d&4194240)!==0){var k=a.lanes;k&=s.pendingLanes,d|=k,a.lanes=d,Co(s,d)}}var Eu={readContext:go,useCallback:_r,useContext:_r,useEffect:_r,useImperativeHandle:_r,useInsertionEffect:_r,useLayoutEffect:_r,useMemo:_r,useReducer:_r,useRef:_r,useState:_r,useDebugValue:_r,useDeferredValue:_r,useTransition:_r,useMutableSource:_r,useSyncExternalStore:_r,useId:_r,unstable_isNewReconciler:!1},ET={readContext:go,useCallback:function(s,a){return Xo().memoizedState=[s,a===void 0?null:a],s},useContext:go,useEffect:Ww,useImperativeHandle:function(s,a,d){return d=d!=null?d.concat([s]):null,bu(4194308,4,Gw.bind(null,a,s),d)},useLayoutEffect:function(s,a){return bu(4194308,4,s,a)},useInsertionEffect:function(s,a){return bu(4,2,s,a)},useMemo:function(s,a){var d=Xo();return a=a===void 0?null:a,s=s(),d.memoizedState=[s,a],s},useReducer:function(s,a,d){var k=Xo();return a=d!==void 0?d(a):a,k.memoizedState=k.baseState=a,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:a},k.queue=s,s=s.dispatch=bT.bind(null,Un,s),[k.memoizedState,s]},useRef:function(s){var a=Xo();return s={current:s},a.memoizedState=s},useState:Hw,useDebugValue:Rh,useDeferredValue:function(s){return Xo().memoizedState=s},useTransition:function(){var s=Hw(!1),a=s[0];return s=vT.bind(null,s[1]),Xo().memoizedState=s,[a,s]},useMutableSource:function(){},useSyncExternalStore:function(s,a,d){var k=Un,v=Xo();if(Pn){if(d===void 0)throw Error(n(407));d=d()}else{if(d=a(),hr===null)throw Error(n(349));(yi&30)!==0||Dw(k,a,d)}v.memoizedState=d;var E={value:d,getSnapshot:a};return v.queue=E,Ww(Fw.bind(null,k,E,s),[s]),k.flags|=2048,Al(9,zw.bind(null,k,E,d,a),void 0,null),d},useId:function(){var s=Xo(),a=hr.identifierPrefix;if(Pn){var d=fs,k=ds;d=(k&~(1<<32-Gt(k)-1)).toString(32)+d,a=":"+a+"R"+d,d=jl++,0<d&&(a+="H"+d.toString(32)),a+=":"}else d=yT++,a=":"+a+"r"+d.toString(32)+":";return s.memoizedState=a},unstable_isNewReconciler:!1},_T={readContext:go,useCallback:Yw,useContext:go,useEffect:Ih,useImperativeHandle:Vw,useInsertionEffect:Zw,useLayoutEffect:qw,useMemo:Xw,useReducer:Ch,useRef:Kw,useState:function(){return Ch(Cl)},useDebugValue:Rh,useDeferredValue:function(s){var a=ko();return Qw(a,sr.memoizedState,s)},useTransition:function(){var s=Ch(Cl)[0],a=ko().memoizedState;return[s,a]},useMutableSource:Lw,useSyncExternalStore:Pw,useId:Jw,unstable_isNewReconciler:!1},ST={readContext:go,useCallback:Yw,useContext:go,useEffect:Ih,useImperativeHandle:Vw,useInsertionEffect:Zw,useLayoutEffect:qw,useMemo:Xw,useReducer:Ah,useRef:Kw,useState:function(){return Ah(Cl)},useDebugValue:Rh,useDeferredValue:function(s){var a=ko();return sr===null?a.memoizedState=s:Qw(a,sr.memoizedState,s)},useTransition:function(){var s=Ah(Cl)[0],a=ko().memoizedState;return[s,a]},useMutableSource:Lw,useSyncExternalStore:Pw,useId:Jw,unstable_isNewReconciler:!1};function Oo(s,a){if(s&&s.defaultProps){a=te({},a),s=s.defaultProps;for(var d in s)a[d]===void 0&&(a[d]=s[d]);return a}return a}function $h(s,a,d,k){a=s.memoizedState,d=d(k,a),d=d==null?a:te({},a,d),s.memoizedState=d,s.lanes===0&&(s.updateQueue.baseState=d)}var _u={isMounted:function(s){return(s=s._reactInternals)?cr(s)===s:!1},enqueueSetState:function(s,a,d){s=s._reactInternals;var k=Fr(),v=Ks(s),E=ps(k,v);E.payload=a,d!=null&&(E.callback=d),a=Fs(s,E,v),a!==null&&(Po(a,s,v,k),gu(a,s,v))},enqueueReplaceState:function(s,a,d){s=s._reactInternals;var k=Fr(),v=Ks(s),E=ps(k,v);E.tag=1,E.payload=a,d!=null&&(E.callback=d),a=Fs(s,E,v),a!==null&&(Po(a,s,v,k),gu(a,s,v))},enqueueForceUpdate:function(s,a){s=s._reactInternals;var d=Fr(),k=Ks(s),v=ps(d,k);v.tag=2,a!=null&&(v.callback=a),a=Fs(s,v,k),a!==null&&(Po(a,s,k,d),gu(a,s,k))}};function ry(s,a,d,k,v,E,C){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(k,E,C):a.prototype&&a.prototype.isPureReactComponent?!gl(d,k)||!gl(v,E):!0}function oy(s,a,d){var k=!1,v=Ps,E=a.contextType;return typeof E=="object"&&E!==null?E=go(E):(v=Wr(a)?pi:Er.current,k=a.contextTypes,E=(k=k!=null)?pa(s,v):Ps),a=new a(d,E),s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=_u,s.stateNode=a,a._reactInternals=s,k&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=v,s.__reactInternalMemoizedMaskedChildContext=E),a}function sy(s,a,d,k){s=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(d,k),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(d,k),a.state!==s&&_u.enqueueReplaceState(a,a.state,null)}function Oh(s,a,d,k){var v=s.stateNode;v.props=d,v.state=s.memoizedState,v.refs={},vh(s);var E=a.contextType;typeof E=="object"&&E!==null?v.context=go(E):(E=Wr(a)?pi:Er.current,v.context=pa(s,E)),v.state=s.memoizedState,E=a.getDerivedStateFromProps,typeof E=="function"&&($h(s,a,E,d),v.state=s.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof v.getSnapshotBeforeUpdate=="function"||typeof v.UNSAFE_componentWillMount!="function"&&typeof v.componentWillMount!="function"||(a=v.state,typeof v.componentWillMount=="function"&&v.componentWillMount(),typeof v.UNSAFE_componentWillMount=="function"&&v.UNSAFE_componentWillMount(),a!==v.state&&_u.enqueueReplaceState(v,v.state,null),ku(s,d,v,k),v.state=s.memoizedState),typeof v.componentDidMount=="function"&&(s.flags|=4194308)}function xa(s,a){try{var d="",k=a;do d+=we(k),k=k.return;while(k);var v=d}catch(E){v=`
|
|
40
|
+
Error generating stack: `+E.message+`
|
|
41
|
+
`+E.stack}return{value:s,source:a,stack:v,digest:null}}function Mh(s,a,d){return{value:s,source:null,stack:d??null,digest:a??null}}function Lh(s,a){try{console.error(a.value)}catch(d){setTimeout(function(){throw d})}}var NT=typeof WeakMap=="function"?WeakMap:Map;function iy(s,a,d){d=ps(-1,d),d.tag=3,d.payload={element:null};var k=a.value;return d.callback=function(){Iu||(Iu=!0,Xh=k),Lh(s,a)},d}function ay(s,a,d){d=ps(-1,d),d.tag=3;var k=s.type.getDerivedStateFromError;if(typeof k=="function"){var v=a.value;d.payload=function(){return k(v)},d.callback=function(){Lh(s,a)}}var E=s.stateNode;return E!==null&&typeof E.componentDidCatch=="function"&&(d.callback=function(){Lh(s,a),typeof k!="function"&&(Us===null?Us=new Set([this]):Us.add(this));var C=a.stack;this.componentDidCatch(a.value,{componentStack:C!==null?C:""})}),d}function ly(s,a,d){var k=s.pingCache;if(k===null){k=s.pingCache=new NT;var v=new Set;k.set(a,v)}else v=k.get(a),v===void 0&&(v=new Set,k.set(a,v));v.has(d)||(v.add(d),s=FT.bind(null,s,a,d),a.then(s,s))}function cy(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 uy(s,a,d,k,v){return(s.mode&1)===0?(s===a?s.flags|=65536:(s.flags|=128,d.flags|=131072,d.flags&=-52805,d.tag===1&&(d.alternate===null?d.tag=17:(a=ps(-1,1),a.tag=2,Fs(d,a,1))),d.lanes|=1),s):(s.flags|=65536,s.lanes=v,s)}var TT=R.ReactCurrentOwner,Zr=!1;function zr(s,a,d,k){a.child=s===null?Aw(a,null,d,k):wa(a,s.child,d,k)}function dy(s,a,d,k,v){d=d.render;var E=a.ref;return va(a,v),k=Th(s,a,d,k,E,v),d=jh(),s!==null&&!Zr?(a.updateQueue=s.updateQueue,a.flags&=-2053,s.lanes&=~v,ms(s,a,v)):(Pn&&d&&uh(a),a.flags|=1,zr(s,a,k,v),a.child)}function fy(s,a,d,k,v){if(s===null){var E=d.type;return typeof E=="function"&&!op(E)&&E.defaultProps===void 0&&d.compare===null&&d.defaultProps===void 0?(a.tag=15,a.type=E,hy(s,a,E,k,v)):(s=Pu(d.type,null,k,a,a.mode,v),s.ref=a.ref,s.return=a,a.child=s)}if(E=s.child,(s.lanes&v)===0){var C=E.memoizedProps;if(d=d.compare,d=d!==null?d:gl,d(C,k)&&s.ref===a.ref)return ms(s,a,v)}return a.flags|=1,s=Zs(E,k),s.ref=a.ref,s.return=a,a.child=s}function hy(s,a,d,k,v){if(s!==null){var E=s.memoizedProps;if(gl(E,k)&&s.ref===a.ref)if(Zr=!1,a.pendingProps=k=E,(s.lanes&v)!==0)(s.flags&131072)!==0&&(Zr=!0);else return a.lanes=s.lanes,ms(s,a,v)}return Ph(s,a,d,k,v)}function py(s,a,d){var k=a.pendingProps,v=k.children,E=s!==null?s.memoizedState:null;if(k.mode==="hidden")if((a.mode&1)===0)a.memoizedState={baseLanes:0,cachePool:null,transitions:null},Cn(_a,ao),ao|=d;else{if((d&1073741824)===0)return s=E!==null?E.baseLanes|d:d,a.lanes=a.childLanes=1073741824,a.memoizedState={baseLanes:s,cachePool:null,transitions:null},a.updateQueue=null,Cn(_a,ao),ao|=s,null;a.memoizedState={baseLanes:0,cachePool:null,transitions:null},k=E!==null?E.baseLanes:d,Cn(_a,ao),ao|=k}else E!==null?(k=E.baseLanes|d,a.memoizedState=null):k=d,Cn(_a,ao),ao|=k;return zr(s,a,v,d),a.child}function my(s,a){var d=a.ref;(s===null&&d!==null||s!==null&&s.ref!==d)&&(a.flags|=512,a.flags|=2097152)}function Ph(s,a,d,k,v){var E=Wr(d)?pi:Er.current;return E=pa(a,E),va(a,v),d=Th(s,a,d,k,E,v),k=jh(),s!==null&&!Zr?(a.updateQueue=s.updateQueue,a.flags&=-2053,s.lanes&=~v,ms(s,a,v)):(Pn&&k&&uh(a),a.flags|=1,zr(s,a,d,v),a.child)}function gy(s,a,d,k,v){if(Wr(d)){var E=!0;lu(a)}else E=!1;if(va(a,v),a.stateNode===null)Nu(s,a),oy(a,d,k),Oh(a,d,k,v),k=!0;else if(s===null){var C=a.stateNode,F=a.memoizedProps;C.props=F;var V=C.context,ue=d.contextType;typeof ue=="object"&&ue!==null?ue=go(ue):(ue=Wr(d)?pi:Er.current,ue=pa(a,ue));var Ce=d.getDerivedStateFromProps,Ie=typeof Ce=="function"||typeof C.getSnapshotBeforeUpdate=="function";Ie||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(F!==k||V!==ue)&&sy(a,C,k,ue),zs=!1;var Te=a.memoizedState;C.state=Te,ku(a,k,C,v),V=a.memoizedState,F!==k||Te!==V||Kr.current||zs?(typeof Ce=="function"&&($h(a,d,Ce,k),V=a.memoizedState),(F=zs||ry(a,d,F,k,Te,V,ue))?(Ie||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount()),typeof C.componentDidMount=="function"&&(a.flags|=4194308)):(typeof C.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=k,a.memoizedState=V),C.props=k,C.state=V,C.context=ue,k=F):(typeof C.componentDidMount=="function"&&(a.flags|=4194308),k=!1)}else{C=a.stateNode,Rw(s,a),F=a.memoizedProps,ue=a.type===a.elementType?F:Oo(a.type,F),C.props=ue,Ie=a.pendingProps,Te=C.context,V=d.contextType,typeof V=="object"&&V!==null?V=go(V):(V=Wr(d)?pi:Er.current,V=pa(a,V));var qe=d.getDerivedStateFromProps;(Ce=typeof qe=="function"||typeof C.getSnapshotBeforeUpdate=="function")||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(F!==Ie||Te!==V)&&sy(a,C,k,V),zs=!1,Te=a.memoizedState,C.state=Te,ku(a,k,C,v);var tt=a.memoizedState;F!==Ie||Te!==tt||Kr.current||zs?(typeof qe=="function"&&($h(a,d,qe,k),tt=a.memoizedState),(ue=zs||ry(a,d,ue,k,Te,tt,V)||!1)?(Ce||typeof C.UNSAFE_componentWillUpdate!="function"&&typeof C.componentWillUpdate!="function"||(typeof C.componentWillUpdate=="function"&&C.componentWillUpdate(k,tt,V),typeof C.UNSAFE_componentWillUpdate=="function"&&C.UNSAFE_componentWillUpdate(k,tt,V)),typeof C.componentDidUpdate=="function"&&(a.flags|=4),typeof C.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof C.componentDidUpdate!="function"||F===s.memoizedProps&&Te===s.memoizedState||(a.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||F===s.memoizedProps&&Te===s.memoizedState||(a.flags|=1024),a.memoizedProps=k,a.memoizedState=tt),C.props=k,C.state=tt,C.context=V,k=ue):(typeof C.componentDidUpdate!="function"||F===s.memoizedProps&&Te===s.memoizedState||(a.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||F===s.memoizedProps&&Te===s.memoizedState||(a.flags|=1024),k=!1)}return Dh(s,a,d,k,E,v)}function Dh(s,a,d,k,v,E){my(s,a);var C=(a.flags&128)!==0;if(!k&&!C)return v&&bw(a,d,!1),ms(s,a,E);k=a.stateNode,TT.current=a;var F=C&&typeof d.getDerivedStateFromError!="function"?null:k.render();return a.flags|=1,s!==null&&C?(a.child=wa(a,s.child,null,E),a.child=wa(a,null,F,E)):zr(s,a,F,E),a.memoizedState=k.state,v&&bw(a,d,!0),a.child}function ky(s){var a=s.stateNode;a.pendingContext?yw(s,a.pendingContext,a.pendingContext!==a.context):a.context&&yw(s,a.context,!1),bh(s,a.containerInfo)}function wy(s,a,d,k,v){return ka(),ph(v),a.flags|=256,zr(s,a,d,k),a.child}var zh={dehydrated:null,treeContext:null,retryLane:0};function Fh(s){return{baseLanes:s,cachePool:null,transitions:null}}function yy(s,a,d){var k=a.pendingProps,v=Bn.current,E=!1,C=(a.flags&128)!==0,F;if((F=C)||(F=s!==null&&s.memoizedState===null?!1:(v&2)!==0),F?(E=!0,a.flags&=-129):(s===null||s.memoizedState!==null)&&(v|=1),Cn(Bn,v&1),s===null)return hh(a),s=a.memoizedState,s!==null&&(s=s.dehydrated,s!==null)?((a.mode&1)===0?a.lanes=1:s.data==="$!"?a.lanes=8:a.lanes=1073741824,null):(C=k.children,s=k.fallback,E?(k=a.mode,E=a.child,C={mode:"hidden",children:C},(k&1)===0&&E!==null?(E.childLanes=0,E.pendingProps=C):E=Du(C,k,0,null),s=_i(s,k,d,null),E.return=a,s.return=a,E.sibling=s,a.child=E,a.child.memoizedState=Fh(d),a.memoizedState=zh,s):Bh(a,C));if(v=s.memoizedState,v!==null&&(F=v.dehydrated,F!==null))return jT(s,a,C,k,F,v,d);if(E){E=k.fallback,C=a.mode,v=s.child,F=v.sibling;var V={mode:"hidden",children:k.children};return(C&1)===0&&a.child!==v?(k=a.child,k.childLanes=0,k.pendingProps=V,a.deletions=null):(k=Zs(v,V),k.subtreeFlags=v.subtreeFlags&14680064),F!==null?E=Zs(F,E):(E=_i(E,C,d,null),E.flags|=2),E.return=a,k.return=a,k.sibling=E,a.child=k,k=E,E=a.child,C=s.child.memoizedState,C=C===null?Fh(d):{baseLanes:C.baseLanes|d,cachePool:null,transitions:C.transitions},E.memoizedState=C,E.childLanes=s.childLanes&~d,a.memoizedState=zh,k}return E=s.child,s=E.sibling,k=Zs(E,{mode:"visible",children:k.children}),(a.mode&1)===0&&(k.lanes=d),k.return=a,k.sibling=null,s!==null&&(d=a.deletions,d===null?(a.deletions=[s],a.flags|=16):d.push(s)),a.child=k,a.memoizedState=null,k}function Bh(s,a){return a=Du({mode:"visible",children:a},s.mode,0,null),a.return=s,s.child=a}function Su(s,a,d,k){return k!==null&&ph(k),wa(a,s.child,null,d),s=Bh(a,a.pendingProps.children),s.flags|=2,a.memoizedState=null,s}function jT(s,a,d,k,v,E,C){if(d)return a.flags&256?(a.flags&=-257,k=Mh(Error(n(422))),Su(s,a,C,k)):a.memoizedState!==null?(a.child=s.child,a.flags|=128,null):(E=k.fallback,v=a.mode,k=Du({mode:"visible",children:k.children},v,0,null),E=_i(E,v,C,null),E.flags|=2,k.return=a,E.return=a,k.sibling=E,a.child=k,(a.mode&1)!==0&&wa(a,s.child,null,C),a.child.memoizedState=Fh(C),a.memoizedState=zh,E);if((a.mode&1)===0)return Su(s,a,C,null);if(v.data==="$!"){if(k=v.nextSibling&&v.nextSibling.dataset,k)var F=k.dgst;return k=F,E=Error(n(419)),k=Mh(E,k,void 0),Su(s,a,C,k)}if(F=(C&s.childLanes)!==0,Zr||F){if(k=hr,k!==null){switch(C&-C){case 4:v=2;break;case 16:v=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:v=32;break;case 536870912:v=268435456;break;default:v=0}v=(v&(k.suspendedLanes|C))!==0?0:v,v!==0&&v!==E.retryLane&&(E.retryLane=v,hs(s,v),Po(k,s,v,-1))}return rp(),k=Mh(Error(n(421))),Su(s,a,C,k)}return v.data==="$?"?(a.flags|=128,a.child=s.child,a=BT.bind(null,s),v._reactRetry=a,null):(s=E.treeContext,io=Ms(v.nextSibling),so=a,Pn=!0,$o=null,s!==null&&(po[mo++]=ds,po[mo++]=fs,po[mo++]=mi,ds=s.id,fs=s.overflow,mi=a),a=Bh(a,k.children),a.flags|=4096,a)}function vy(s,a,d){s.lanes|=a;var k=s.alternate;k!==null&&(k.lanes|=a),wh(s.return,a,d)}function Uh(s,a,d,k,v){var E=s.memoizedState;E===null?s.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:k,tail:d,tailMode:v}:(E.isBackwards=a,E.rendering=null,E.renderingStartTime=0,E.last=k,E.tail=d,E.tailMode=v)}function by(s,a,d){var k=a.pendingProps,v=k.revealOrder,E=k.tail;if(zr(s,a,k.children,d),k=Bn.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&&vy(s,d,a);else if(s.tag===19)vy(s,d,a);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===a)break e;for(;s.sibling===null;){if(s.return===null||s.return===a)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}k&=1}if(Cn(Bn,k),(a.mode&1)===0)a.memoizedState=null;else switch(v){case"forwards":for(d=a.child,v=null;d!==null;)s=d.alternate,s!==null&&wu(s)===null&&(v=d),d=d.sibling;d=v,d===null?(v=a.child,a.child=null):(v=d.sibling,d.sibling=null),Uh(a,!1,v,d,E);break;case"backwards":for(d=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=d,d=v,v=s}Uh(a,!0,d,null,E);break;case"together":Uh(a,!1,null,null,void 0);break;default:a.memoizedState=null}return a.child}function Nu(s,a){(a.mode&1)===0&&s!==null&&(s.alternate=null,a.alternate=null,a.flags|=2)}function ms(s,a,d){if(s!==null&&(a.dependencies=s.dependencies),vi|=a.lanes,(d&a.childLanes)===0)return null;if(s!==null&&a.child!==s.child)throw Error(n(153));if(a.child!==null){for(s=a.child,d=Zs(s,s.pendingProps),a.child=d,d.return=a;s.sibling!==null;)s=s.sibling,d=d.sibling=Zs(s,s.pendingProps),d.return=a;d.sibling=null}return a.child}function CT(s,a,d){switch(a.tag){case 3:ky(a),ka();break;case 5:Mw(a);break;case 1:Wr(a.type)&&lu(a);break;case 4:bh(a,a.stateNode.containerInfo);break;case 10:var k=a.type._context,v=a.memoizedProps.value;Cn(pu,k._currentValue),k._currentValue=v;break;case 13:if(k=a.memoizedState,k!==null)return k.dehydrated!==null?(Cn(Bn,Bn.current&1),a.flags|=128,null):(d&a.child.childLanes)!==0?yy(s,a,d):(Cn(Bn,Bn.current&1),s=ms(s,a,d),s!==null?s.sibling:null);Cn(Bn,Bn.current&1);break;case 19:if(k=(d&a.childLanes)!==0,(s.flags&128)!==0){if(k)return by(s,a,d);a.flags|=128}if(v=a.memoizedState,v!==null&&(v.rendering=null,v.tail=null,v.lastEffect=null),Cn(Bn,Bn.current),k)break;return null;case 22:case 23:return a.lanes=0,py(s,a,d)}return ms(s,a,d)}var xy,Hh,Ey,_y;xy=function(s,a){for(var d=a.child;d!==null;){if(d.tag===5||d.tag===6)s.appendChild(d.stateNode);else if(d.tag!==4&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===a)break;for(;d.sibling===null;){if(d.return===null||d.return===a)return;d=d.return}d.sibling.return=d.return,d=d.sibling}},Hh=function(){},Ey=function(s,a,d,k){var v=s.memoizedProps;if(v!==k){s=a.stateNode,wi(Yo.current);var E=null;switch(d){case"input":v=ze(s,v),k=ze(s,k),E=[];break;case"select":v=te({},v,{value:void 0}),k=te({},k,{value:void 0}),E=[];break;case"textarea":v=nt(s,v),k=nt(s,k),E=[];break;default:typeof v.onClick!="function"&&typeof k.onClick=="function"&&(s.onclick=su)}De(d,k);var C;d=null;for(ue in v)if(!k.hasOwnProperty(ue)&&v.hasOwnProperty(ue)&&v[ue]!=null)if(ue==="style"){var F=v[ue];for(C in F)F.hasOwnProperty(C)&&(d||(d={}),d[C]="")}else ue!=="dangerouslySetInnerHTML"&&ue!=="children"&&ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&ue!=="autoFocus"&&(o.hasOwnProperty(ue)?E||(E=[]):(E=E||[]).push(ue,null));for(ue in k){var V=k[ue];if(F=v!=null?v[ue]:void 0,k.hasOwnProperty(ue)&&V!==F&&(V!=null||F!=null))if(ue==="style")if(F){for(C in F)!F.hasOwnProperty(C)||V&&V.hasOwnProperty(C)||(d||(d={}),d[C]="");for(C in V)V.hasOwnProperty(C)&&F[C]!==V[C]&&(d||(d={}),d[C]=V[C])}else d||(E||(E=[]),E.push(ue,d)),d=V;else ue==="dangerouslySetInnerHTML"?(V=V?V.__html:void 0,F=F?F.__html:void 0,V!=null&&F!==V&&(E=E||[]).push(ue,V)):ue==="children"?typeof V!="string"&&typeof V!="number"||(E=E||[]).push(ue,""+V):ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&(o.hasOwnProperty(ue)?(V!=null&&ue==="onScroll"&&Rn("scroll",s),E||F===V||(E=[])):(E=E||[]).push(ue,V))}d&&(E=E||[]).push("style",d);var ue=E;(a.updateQueue=ue)&&(a.flags|=4)}},_y=function(s,a,d,k){d!==k&&(a.flags|=4)};function Il(s,a){if(!Pn)switch(s.tailMode){case"hidden":a=s.tail;for(var d=null;a!==null;)a.alternate!==null&&(d=a),a=a.sibling;d===null?s.tail=null:d.sibling=null;break;case"collapsed":d=s.tail;for(var k=null;d!==null;)d.alternate!==null&&(k=d),d=d.sibling;k===null?a||s.tail===null?s.tail=null:s.tail.sibling=null:k.sibling=null}}function Sr(s){var a=s.alternate!==null&&s.alternate.child===s.child,d=0,k=0;if(a)for(var v=s.child;v!==null;)d|=v.lanes|v.childLanes,k|=v.subtreeFlags&14680064,k|=v.flags&14680064,v.return=s,v=v.sibling;else for(v=s.child;v!==null;)d|=v.lanes|v.childLanes,k|=v.subtreeFlags,k|=v.flags,v.return=s,v=v.sibling;return s.subtreeFlags|=k,s.childLanes=d,a}function AT(s,a,d){var k=a.pendingProps;switch(dh(a),a.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Sr(a),null;case 1:return Wr(a.type)&&au(),Sr(a),null;case 3:return k=a.stateNode,ba(),$n(Kr),$n(Er),_h(),k.pendingContext&&(k.context=k.pendingContext,k.pendingContext=null),(s===null||s.child===null)&&(fu(a)?a.flags|=4:s===null||s.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,$o!==null&&(ep($o),$o=null))),Hh(s,a),Sr(a),null;case 5:xh(a);var v=wi(Nl.current);if(d=a.type,s!==null&&a.stateNode!=null)Ey(s,a,d,k,v),s.ref!==a.ref&&(a.flags|=512,a.flags|=2097152);else{if(!k){if(a.stateNode===null)throw Error(n(166));return Sr(a),null}if(s=wi(Yo.current),fu(a)){k=a.stateNode,d=a.type;var E=a.memoizedProps;switch(k[Vo]=a,k[bl]=E,s=(a.mode&1)!==0,d){case"dialog":Rn("cancel",k),Rn("close",k);break;case"iframe":case"object":case"embed":Rn("load",k);break;case"video":case"audio":for(v=0;v<wl.length;v++)Rn(wl[v],k);break;case"source":Rn("error",k);break;case"img":case"image":case"link":Rn("error",k),Rn("load",k);break;case"details":Rn("toggle",k);break;case"input":Re(k,E),Rn("invalid",k);break;case"select":k._wrapperState={wasMultiple:!!E.multiple},Rn("invalid",k);break;case"textarea":an(k,E),Rn("invalid",k)}De(d,E),v=null;for(var C in E)if(E.hasOwnProperty(C)){var F=E[C];C==="children"?typeof F=="string"?k.textContent!==F&&(E.suppressHydrationWarning!==!0&&ou(k.textContent,F,s),v=["children",F]):typeof F=="number"&&k.textContent!==""+F&&(E.suppressHydrationWarning!==!0&&ou(k.textContent,F,s),v=["children",""+F]):o.hasOwnProperty(C)&&F!=null&&C==="onScroll"&&Rn("scroll",k)}switch(d){case"input":ae(k),ht(k,E,!0);break;case"textarea":ae(k),X(k);break;case"select":case"option":break;default:typeof E.onClick=="function"&&(k.onclick=su)}k=v,a.updateQueue=k,k!==null&&(a.flags|=4)}else{C=v.nodeType===9?v:v.ownerDocument,s==="http://www.w3.org/1999/xhtml"&&(s=fe(d)),s==="http://www.w3.org/1999/xhtml"?d==="script"?(s=C.createElement("div"),s.innerHTML="<script><\/script>",s=s.removeChild(s.firstChild)):typeof k.is=="string"?s=C.createElement(d,{is:k.is}):(s=C.createElement(d),d==="select"&&(C=s,k.multiple?C.multiple=!0:k.size&&(C.size=k.size))):s=C.createElementNS(s,d),s[Vo]=a,s[bl]=k,xy(s,a,!1,!1),a.stateNode=s;e:{switch(C=gn(d,k),d){case"dialog":Rn("cancel",s),Rn("close",s),v=k;break;case"iframe":case"object":case"embed":Rn("load",s),v=k;break;case"video":case"audio":for(v=0;v<wl.length;v++)Rn(wl[v],s);v=k;break;case"source":Rn("error",s),v=k;break;case"img":case"image":case"link":Rn("error",s),Rn("load",s),v=k;break;case"details":Rn("toggle",s),v=k;break;case"input":Re(s,k),v=ze(s,k),Rn("invalid",s);break;case"option":v=k;break;case"select":s._wrapperState={wasMultiple:!!k.multiple},v=te({},k,{value:void 0}),Rn("invalid",s);break;case"textarea":an(s,k),v=nt(s,k),Rn("invalid",s);break;default:v=k}De(d,v),F=v;for(E in F)if(F.hasOwnProperty(E)){var V=F[E];E==="style"?ut(s,V):E==="dangerouslySetInnerHTML"?(V=V?V.__html:void 0,V!=null&&pn(s,V)):E==="children"?typeof V=="string"?(d!=="textarea"||V!=="")&&mn(s,V):typeof V=="number"&&mn(s,""+V):E!=="suppressContentEditableWarning"&&E!=="suppressHydrationWarning"&&E!=="autoFocus"&&(o.hasOwnProperty(E)?V!=null&&E==="onScroll"&&Rn("scroll",s):V!=null&&T(s,E,V,C))}switch(d){case"input":ae(s),ht(s,k,!1);break;case"textarea":ae(s),X(s);break;case"option":k.value!=null&&s.setAttribute("value",""+pe(k.value));break;case"select":s.multiple=!!k.multiple,E=k.value,E!=null?He(s,!!k.multiple,E,!1):k.defaultValue!=null&&He(s,!!k.multiple,k.defaultValue,!0);break;default:typeof v.onClick=="function"&&(s.onclick=su)}switch(d){case"button":case"input":case"select":case"textarea":k=!!k.autoFocus;break e;case"img":k=!0;break e;default:k=!1}}k&&(a.flags|=4)}a.ref!==null&&(a.flags|=512,a.flags|=2097152)}return Sr(a),null;case 6:if(s&&a.stateNode!=null)_y(s,a,s.memoizedProps,k);else{if(typeof k!="string"&&a.stateNode===null)throw Error(n(166));if(d=wi(Nl.current),wi(Yo.current),fu(a)){if(k=a.stateNode,d=a.memoizedProps,k[Vo]=a,(E=k.nodeValue!==d)&&(s=so,s!==null))switch(s.tag){case 3:ou(k.nodeValue,d,(s.mode&1)!==0);break;case 5:s.memoizedProps.suppressHydrationWarning!==!0&&ou(k.nodeValue,d,(s.mode&1)!==0)}E&&(a.flags|=4)}else k=(d.nodeType===9?d:d.ownerDocument).createTextNode(k),k[Vo]=a,a.stateNode=k}return Sr(a),null;case 13:if($n(Bn),k=a.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(Pn&&io!==null&&(a.mode&1)!==0&&(a.flags&128)===0)Tw(),ka(),a.flags|=98560,E=!1;else if(E=fu(a),k!==null&&k.dehydrated!==null){if(s===null){if(!E)throw Error(n(318));if(E=a.memoizedState,E=E!==null?E.dehydrated:null,!E)throw Error(n(317));E[Vo]=a}else ka(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Sr(a),E=!1}else $o!==null&&(ep($o),$o=null),E=!0;if(!E)return a.flags&65536?a:null}return(a.flags&128)!==0?(a.lanes=d,a):(k=k!==null,k!==(s!==null&&s.memoizedState!==null)&&k&&(a.child.flags|=8192,(a.mode&1)!==0&&(s===null||(Bn.current&1)!==0?ir===0&&(ir=3):rp())),a.updateQueue!==null&&(a.flags|=4),Sr(a),null);case 4:return ba(),Hh(s,a),s===null&&yl(a.stateNode.containerInfo),Sr(a),null;case 10:return kh(a.type._context),Sr(a),null;case 17:return Wr(a.type)&&au(),Sr(a),null;case 19:if($n(Bn),E=a.memoizedState,E===null)return Sr(a),null;if(k=(a.flags&128)!==0,C=E.rendering,C===null)if(k)Il(E,!1);else{if(ir!==0||s!==null&&(s.flags&128)!==0)for(s=a.child;s!==null;){if(C=wu(s),C!==null){for(a.flags|=128,Il(E,!1),k=C.updateQueue,k!==null&&(a.updateQueue=k,a.flags|=4),a.subtreeFlags=0,k=d,d=a.child;d!==null;)E=d,s=k,E.flags&=14680066,C=E.alternate,C===null?(E.childLanes=0,E.lanes=s,E.child=null,E.subtreeFlags=0,E.memoizedProps=null,E.memoizedState=null,E.updateQueue=null,E.dependencies=null,E.stateNode=null):(E.childLanes=C.childLanes,E.lanes=C.lanes,E.child=C.child,E.subtreeFlags=0,E.deletions=null,E.memoizedProps=C.memoizedProps,E.memoizedState=C.memoizedState,E.updateQueue=C.updateQueue,E.type=C.type,s=C.dependencies,E.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),d=d.sibling;return Cn(Bn,Bn.current&1|2),a.child}s=s.sibling}E.tail!==null&&Ut()>Sa&&(a.flags|=128,k=!0,Il(E,!1),a.lanes=4194304)}else{if(!k)if(s=wu(C),s!==null){if(a.flags|=128,k=!0,d=s.updateQueue,d!==null&&(a.updateQueue=d,a.flags|=4),Il(E,!0),E.tail===null&&E.tailMode==="hidden"&&!C.alternate&&!Pn)return Sr(a),null}else 2*Ut()-E.renderingStartTime>Sa&&d!==1073741824&&(a.flags|=128,k=!0,Il(E,!1),a.lanes=4194304);E.isBackwards?(C.sibling=a.child,a.child=C):(d=E.last,d!==null?d.sibling=C:a.child=C,E.last=C)}return E.tail!==null?(a=E.tail,E.rendering=a,E.tail=a.sibling,E.renderingStartTime=Ut(),a.sibling=null,d=Bn.current,Cn(Bn,k?d&1|2:d&1),a):(Sr(a),null);case 22:case 23:return np(),k=a.memoizedState!==null,s!==null&&s.memoizedState!==null!==k&&(a.flags|=8192),k&&(a.mode&1)!==0?(ao&1073741824)!==0&&(Sr(a),a.subtreeFlags&6&&(a.flags|=8192)):Sr(a),null;case 24:return null;case 25:return null}throw Error(n(156,a.tag))}function IT(s,a){switch(dh(a),a.tag){case 1:return Wr(a.type)&&au(),s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 3:return ba(),$n(Kr),$n(Er),_h(),s=a.flags,(s&65536)!==0&&(s&128)===0?(a.flags=s&-65537|128,a):null;case 5:return xh(a),null;case 13:if($n(Bn),s=a.memoizedState,s!==null&&s.dehydrated!==null){if(a.alternate===null)throw Error(n(340));ka()}return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 19:return $n(Bn),null;case 4:return ba(),null;case 10:return kh(a.type._context),null;case 22:case 23:return np(),null;case 24:return null;default:return null}}var Tu=!1,Nr=!1,RT=typeof WeakSet=="function"?WeakSet:Set,Je=null;function Ea(s,a){var d=s.ref;if(d!==null)if(typeof d=="function")try{d(null)}catch(k){Yn(s,a,k)}else d.current=null}function Kh(s,a,d){try{d()}catch(k){Yn(s,a,k)}}var Sy=!1;function $T(s,a){if(nh=Gi,s=rw(),Gf(s)){if("selectionStart"in s)var d={start:s.selectionStart,end:s.selectionEnd};else e:{d=(d=s.ownerDocument)&&d.defaultView||window;var k=d.getSelection&&d.getSelection();if(k&&k.rangeCount!==0){d=k.anchorNode;var v=k.anchorOffset,E=k.focusNode;k=k.focusOffset;try{d.nodeType,E.nodeType}catch{d=null;break e}var C=0,F=-1,V=-1,ue=0,Ce=0,Ie=s,Te=null;t:for(;;){for(var qe;Ie!==d||v!==0&&Ie.nodeType!==3||(F=C+v),Ie!==E||k!==0&&Ie.nodeType!==3||(V=C+k),Ie.nodeType===3&&(C+=Ie.nodeValue.length),(qe=Ie.firstChild)!==null;)Te=Ie,Ie=qe;for(;;){if(Ie===s)break t;if(Te===d&&++ue===v&&(F=C),Te===E&&++Ce===k&&(V=C),(qe=Ie.nextSibling)!==null)break;Ie=Te,Te=Ie.parentNode}Ie=qe}d=F===-1||V===-1?null:{start:F,end:V}}else d=null}d=d||{start:0,end:0}}else d=null;for(rh={focusedElem:s,selectionRange:d},Gi=!1,Je=a;Je!==null;)if(a=Je,s=a.child,(a.subtreeFlags&1028)!==0&&s!==null)s.return=a,Je=s;else for(;Je!==null;){a=Je;try{var tt=a.alternate;if((a.flags&1024)!==0)switch(a.tag){case 0:case 11:case 15:break;case 1:if(tt!==null){var rt=tt.memoizedProps,Jn=tt.memoizedState,ie=a.stateNode,Q=ie.getSnapshotBeforeUpdate(a.elementType===a.type?rt:Oo(a.type,rt),Jn);ie.__reactInternalSnapshotBeforeUpdate=Q}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(Me){Yn(a,a.return,Me)}if(s=a.sibling,s!==null){s.return=a.return,Je=s;break}Je=a.return}return tt=Sy,Sy=!1,tt}function Rl(s,a,d){var k=a.updateQueue;if(k=k!==null?k.lastEffect:null,k!==null){var v=k=k.next;do{if((v.tag&s)===s){var E=v.destroy;v.destroy=void 0,E!==void 0&&Kh(a,d,E)}v=v.next}while(v!==k)}}function ju(s,a){if(a=a.updateQueue,a=a!==null?a.lastEffect:null,a!==null){var d=a=a.next;do{if((d.tag&s)===s){var k=d.create;d.destroy=k()}d=d.next}while(d!==a)}}function Wh(s){var a=s.ref;if(a!==null){var d=s.stateNode;switch(s.tag){case 5:s=d;break;default:s=d}typeof a=="function"?a(s):a.current=s}}function Ny(s){var a=s.alternate;a!==null&&(s.alternate=null,Ny(a)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(a=s.stateNode,a!==null&&(delete a[Vo],delete a[bl],delete a[ah],delete a[mT],delete a[gT])),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 Ty(s){return s.tag===5||s.tag===3||s.tag===4}function jy(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||Ty(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 Zh(s,a,d){var k=s.tag;if(k===5||k===6)s=s.stateNode,a?d.nodeType===8?d.parentNode.insertBefore(s,a):d.insertBefore(s,a):(d.nodeType===8?(a=d.parentNode,a.insertBefore(s,d)):(a=d,a.appendChild(s)),d=d._reactRootContainer,d!=null||a.onclick!==null||(a.onclick=su));else if(k!==4&&(s=s.child,s!==null))for(Zh(s,a,d),s=s.sibling;s!==null;)Zh(s,a,d),s=s.sibling}function qh(s,a,d){var k=s.tag;if(k===5||k===6)s=s.stateNode,a?d.insertBefore(s,a):d.appendChild(s);else if(k!==4&&(s=s.child,s!==null))for(qh(s,a,d),s=s.sibling;s!==null;)qh(s,a,d),s=s.sibling}var vr=null,Mo=!1;function Bs(s,a,d){for(d=d.child;d!==null;)Cy(s,a,d),d=d.sibling}function Cy(s,a,d){if(st&&typeof st.onCommitFiberUnmount=="function")try{st.onCommitFiberUnmount(kt,d)}catch{}switch(d.tag){case 5:Nr||Ea(d,a);case 6:var k=vr,v=Mo;vr=null,Bs(s,a,d),vr=k,Mo=v,vr!==null&&(Mo?(s=vr,d=d.stateNode,s.nodeType===8?s.parentNode.removeChild(d):s.removeChild(d)):vr.removeChild(d.stateNode));break;case 18:vr!==null&&(Mo?(s=vr,d=d.stateNode,s.nodeType===8?ih(s.parentNode,d):s.nodeType===1&&ih(s,d),ss(s)):ih(vr,d.stateNode));break;case 4:k=vr,v=Mo,vr=d.stateNode.containerInfo,Mo=!0,Bs(s,a,d),vr=k,Mo=v;break;case 0:case 11:case 14:case 15:if(!Nr&&(k=d.updateQueue,k!==null&&(k=k.lastEffect,k!==null))){v=k=k.next;do{var E=v,C=E.destroy;E=E.tag,C!==void 0&&((E&2)!==0||(E&4)!==0)&&Kh(d,a,C),v=v.next}while(v!==k)}Bs(s,a,d);break;case 1:if(!Nr&&(Ea(d,a),k=d.stateNode,typeof k.componentWillUnmount=="function"))try{k.props=d.memoizedProps,k.state=d.memoizedState,k.componentWillUnmount()}catch(F){Yn(d,a,F)}Bs(s,a,d);break;case 21:Bs(s,a,d);break;case 22:d.mode&1?(Nr=(k=Nr)||d.memoizedState!==null,Bs(s,a,d),Nr=k):Bs(s,a,d);break;default:Bs(s,a,d)}}function Ay(s){var a=s.updateQueue;if(a!==null){s.updateQueue=null;var d=s.stateNode;d===null&&(d=s.stateNode=new RT),a.forEach(function(k){var v=UT.bind(null,s,k);d.has(k)||(d.add(k),k.then(v,v))})}}function Lo(s,a){var d=a.deletions;if(d!==null)for(var k=0;k<d.length;k++){var v=d[k];try{var E=s,C=a,F=C;e:for(;F!==null;){switch(F.tag){case 5:vr=F.stateNode,Mo=!1;break e;case 3:vr=F.stateNode.containerInfo,Mo=!0;break e;case 4:vr=F.stateNode.containerInfo,Mo=!0;break e}F=F.return}if(vr===null)throw Error(n(160));Cy(E,C,v),vr=null,Mo=!1;var V=v.alternate;V!==null&&(V.return=null),v.return=null}catch(ue){Yn(v,a,ue)}}if(a.subtreeFlags&12854)for(a=a.child;a!==null;)Iy(a,s),a=a.sibling}function Iy(s,a){var d=s.alternate,k=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:if(Lo(a,s),Qo(s),k&4){try{Rl(3,s,s.return),ju(3,s)}catch(rt){Yn(s,s.return,rt)}try{Rl(5,s,s.return)}catch(rt){Yn(s,s.return,rt)}}break;case 1:Lo(a,s),Qo(s),k&512&&d!==null&&Ea(d,d.return);break;case 5:if(Lo(a,s),Qo(s),k&512&&d!==null&&Ea(d,d.return),s.flags&32){var v=s.stateNode;try{mn(v,"")}catch(rt){Yn(s,s.return,rt)}}if(k&4&&(v=s.stateNode,v!=null)){var E=s.memoizedProps,C=d!==null?d.memoizedProps:E,F=s.type,V=s.updateQueue;if(s.updateQueue=null,V!==null)try{F==="input"&&E.type==="radio"&&E.name!=null&&ct(v,E),gn(F,C);var ue=gn(F,E);for(C=0;C<V.length;C+=2){var Ce=V[C],Ie=V[C+1];Ce==="style"?ut(v,Ie):Ce==="dangerouslySetInnerHTML"?pn(v,Ie):Ce==="children"?mn(v,Ie):T(v,Ce,Ie,ue)}switch(F){case"input":_n(v,E);break;case"textarea":It(v,E);break;case"select":var Te=v._wrapperState.wasMultiple;v._wrapperState.wasMultiple=!!E.multiple;var qe=E.value;qe!=null?He(v,!!E.multiple,qe,!1):Te!==!!E.multiple&&(E.defaultValue!=null?He(v,!!E.multiple,E.defaultValue,!0):He(v,!!E.multiple,E.multiple?[]:"",!1))}v[bl]=E}catch(rt){Yn(s,s.return,rt)}}break;case 6:if(Lo(a,s),Qo(s),k&4){if(s.stateNode===null)throw Error(n(162));v=s.stateNode,E=s.memoizedProps;try{v.nodeValue=E}catch(rt){Yn(s,s.return,rt)}}break;case 3:if(Lo(a,s),Qo(s),k&4&&d!==null&&d.memoizedState.isDehydrated)try{ss(a.containerInfo)}catch(rt){Yn(s,s.return,rt)}break;case 4:Lo(a,s),Qo(s);break;case 13:Lo(a,s),Qo(s),v=s.child,v.flags&8192&&(E=v.memoizedState!==null,v.stateNode.isHidden=E,!E||v.alternate!==null&&v.alternate.memoizedState!==null||(Yh=Ut())),k&4&&Ay(s);break;case 22:if(Ce=d!==null&&d.memoizedState!==null,s.mode&1?(Nr=(ue=Nr)||Ce,Lo(a,s),Nr=ue):Lo(a,s),Qo(s),k&8192){if(ue=s.memoizedState!==null,(s.stateNode.isHidden=ue)&&!Ce&&(s.mode&1)!==0)for(Je=s,Ce=s.child;Ce!==null;){for(Ie=Je=Ce;Je!==null;){switch(Te=Je,qe=Te.child,Te.tag){case 0:case 11:case 14:case 15:Rl(4,Te,Te.return);break;case 1:Ea(Te,Te.return);var tt=Te.stateNode;if(typeof tt.componentWillUnmount=="function"){k=Te,d=Te.return;try{a=k,tt.props=a.memoizedProps,tt.state=a.memoizedState,tt.componentWillUnmount()}catch(rt){Yn(k,d,rt)}}break;case 5:Ea(Te,Te.return);break;case 22:if(Te.memoizedState!==null){Oy(Ie);continue}}qe!==null?(qe.return=Te,Je=qe):Oy(Ie)}Ce=Ce.sibling}e:for(Ce=null,Ie=s;;){if(Ie.tag===5){if(Ce===null){Ce=Ie;try{v=Ie.stateNode,ue?(E=v.style,typeof E.setProperty=="function"?E.setProperty("display","none","important"):E.display="none"):(F=Ie.stateNode,V=Ie.memoizedProps.style,C=V!=null&&V.hasOwnProperty("display")?V.display:null,F.style.display=Nn("display",C))}catch(rt){Yn(s,s.return,rt)}}}else if(Ie.tag===6){if(Ce===null)try{Ie.stateNode.nodeValue=ue?"":Ie.memoizedProps}catch(rt){Yn(s,s.return,rt)}}else if((Ie.tag!==22&&Ie.tag!==23||Ie.memoizedState===null||Ie===s)&&Ie.child!==null){Ie.child.return=Ie,Ie=Ie.child;continue}if(Ie===s)break e;for(;Ie.sibling===null;){if(Ie.return===null||Ie.return===s)break e;Ce===Ie&&(Ce=null),Ie=Ie.return}Ce===Ie&&(Ce=null),Ie.sibling.return=Ie.return,Ie=Ie.sibling}}break;case 19:Lo(a,s),Qo(s),k&4&&Ay(s);break;case 21:break;default:Lo(a,s),Qo(s)}}function Qo(s){var a=s.flags;if(a&2){try{e:{for(var d=s.return;d!==null;){if(Ty(d)){var k=d;break e}d=d.return}throw Error(n(160))}switch(k.tag){case 5:var v=k.stateNode;k.flags&32&&(mn(v,""),k.flags&=-33);var E=jy(s);qh(s,E,v);break;case 3:case 4:var C=k.stateNode.containerInfo,F=jy(s);Zh(s,F,C);break;default:throw Error(n(161))}}catch(V){Yn(s,s.return,V)}s.flags&=-3}a&4096&&(s.flags&=-4097)}function OT(s,a,d){Je=s,Ry(s)}function Ry(s,a,d){for(var k=(s.mode&1)!==0;Je!==null;){var v=Je,E=v.child;if(v.tag===22&&k){var C=v.memoizedState!==null||Tu;if(!C){var F=v.alternate,V=F!==null&&F.memoizedState!==null||Nr;F=Tu;var ue=Nr;if(Tu=C,(Nr=V)&&!ue)for(Je=v;Je!==null;)C=Je,V=C.child,C.tag===22&&C.memoizedState!==null?My(v):V!==null?(V.return=C,Je=V):My(v);for(;E!==null;)Je=E,Ry(E),E=E.sibling;Je=v,Tu=F,Nr=ue}$y(s)}else(v.subtreeFlags&8772)!==0&&E!==null?(E.return=v,Je=E):$y(s)}}function $y(s){for(;Je!==null;){var a=Je;if((a.flags&8772)!==0){var d=a.alternate;try{if((a.flags&8772)!==0)switch(a.tag){case 0:case 11:case 15:Nr||ju(5,a);break;case 1:var k=a.stateNode;if(a.flags&4&&!Nr)if(d===null)k.componentDidMount();else{var v=a.elementType===a.type?d.memoizedProps:Oo(a.type,d.memoizedProps);k.componentDidUpdate(v,d.memoizedState,k.__reactInternalSnapshotBeforeUpdate)}var E=a.updateQueue;E!==null&&Ow(a,E,k);break;case 3:var C=a.updateQueue;if(C!==null){if(d=null,a.child!==null)switch(a.child.tag){case 5:d=a.child.stateNode;break;case 1:d=a.child.stateNode}Ow(a,C,d)}break;case 5:var F=a.stateNode;if(d===null&&a.flags&4){d=F;var V=a.memoizedProps;switch(a.type){case"button":case"input":case"select":case"textarea":V.autoFocus&&d.focus();break;case"img":V.src&&(d.src=V.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(a.memoizedState===null){var ue=a.alternate;if(ue!==null){var Ce=ue.memoizedState;if(Ce!==null){var Ie=Ce.dehydrated;Ie!==null&&ss(Ie)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Nr||a.flags&512&&Wh(a)}catch(Te){Yn(a,a.return,Te)}}if(a===s){Je=null;break}if(d=a.sibling,d!==null){d.return=a.return,Je=d;break}Je=a.return}}function Oy(s){for(;Je!==null;){var a=Je;if(a===s){Je=null;break}var d=a.sibling;if(d!==null){d.return=a.return,Je=d;break}Je=a.return}}function My(s){for(;Je!==null;){var a=Je;try{switch(a.tag){case 0:case 11:case 15:var d=a.return;try{ju(4,a)}catch(V){Yn(a,d,V)}break;case 1:var k=a.stateNode;if(typeof k.componentDidMount=="function"){var v=a.return;try{k.componentDidMount()}catch(V){Yn(a,v,V)}}var E=a.return;try{Wh(a)}catch(V){Yn(a,E,V)}break;case 5:var C=a.return;try{Wh(a)}catch(V){Yn(a,C,V)}}}catch(V){Yn(a,a.return,V)}if(a===s){Je=null;break}var F=a.sibling;if(F!==null){F.return=a.return,Je=F;break}Je=a.return}}var MT=Math.ceil,Cu=R.ReactCurrentDispatcher,Gh=R.ReactCurrentOwner,wo=R.ReactCurrentBatchConfig,on=0,hr=null,rr=null,br=0,ao=0,_a=Ls(0),ir=0,$l=null,vi=0,Au=0,Vh=0,Ol=null,qr=null,Yh=0,Sa=1/0,gs=null,Iu=!1,Xh=null,Us=null,Ru=!1,Hs=null,$u=0,Ml=0,Qh=null,Ou=-1,Mu=0;function Fr(){return(on&6)!==0?Ut():Ou!==-1?Ou:Ou=Ut()}function Ks(s){return(s.mode&1)===0?1:(on&2)!==0&&br!==0?br&-br:wT.transition!==null?(Mu===0&&(Mu=js()),Mu):(s=Xe,s!==0||(s=window.event,s=s===void 0?16:Dc(s.type)),s)}function Po(s,a,d,k){if(50<Ml)throw Ml=0,Qh=null,Error(n(185));Lr(s,d,k),((on&2)===0||s!==hr)&&(s===hr&&((on&2)===0&&(Au|=d),ir===4&&Ws(s,br)),Gr(s,k),d===1&&on===0&&(a.mode&1)===0&&(Sa=Ut()+500,cu&&Ds()))}function Gr(s,a){var d=s.callbackNode;jo(s,a);var k=Mn(s,s===hr?br:0);if(k===0)d!==null&&pt(d),s.callbackNode=null,s.callbackPriority=0;else if(a=k&-k,s.callbackPriority!==a){if(d!=null&&pt(d),a===1)s.tag===0?kT(Py.bind(null,s)):xw(Py.bind(null,s)),hT(function(){(on&6)===0&&Ds()}),d=null;else{switch(gt(k)){case 1:d=Or;break;case 4:d=On;break;case 16:d=St;break;case 536870912:d=Se;break;default:d=St}d=Wy(d,Ly.bind(null,s))}s.callbackPriority=a,s.callbackNode=d}}function Ly(s,a){if(Ou=-1,Mu=0,(on&6)!==0)throw Error(n(327));var d=s.callbackNode;if(Na()&&s.callbackNode!==d)return null;var k=Mn(s,s===hr?br:0);if(k===0)return null;if((k&30)!==0||(k&s.expiredLanes)!==0||a)a=Lu(s,k);else{a=k;var v=on;on|=2;var E=zy();(hr!==s||br!==a)&&(gs=null,Sa=Ut()+500,xi(s,a));do try{DT();break}catch(F){Dy(s,F)}while(!0);gh(),Cu.current=E,on=v,rr!==null?a=0:(hr=null,br=0,a=ir)}if(a!==0){if(a===2&&(v=xr(s),v!==0&&(k=v,a=Jh(s,v))),a===1)throw d=$l,xi(s,0),Ws(s,k),Gr(s,Ut()),d;if(a===6)Ws(s,k);else{if(v=s.current.alternate,(k&30)===0&&!LT(v)&&(a=Lu(s,k),a===2&&(E=xr(s),E!==0&&(k=E,a=Jh(s,E))),a===1))throw d=$l,xi(s,0),Ws(s,k),Gr(s,Ut()),d;switch(s.finishedWork=v,s.finishedLanes=k,a){case 0:case 1:throw Error(n(345));case 2:Ei(s,qr,gs);break;case 3:if(Ws(s,k),(k&130023424)===k&&(a=Yh+500-Ut(),10<a)){if(Mn(s,0)!==0)break;if(v=s.suspendedLanes,(v&k)!==k){Fr(),s.pingedLanes|=s.suspendedLanes&v;break}s.timeoutHandle=sh(Ei.bind(null,s,qr,gs),a);break}Ei(s,qr,gs);break;case 4:if(Ws(s,k),(k&4194240)===k)break;for(a=s.eventTimes,v=-1;0<k;){var C=31-Gt(k);E=1<<C,C=a[C],C>v&&(v=C),k&=~E}if(k=v,k=Ut()-k,k=(120>k?120:480>k?480:1080>k?1080:1920>k?1920:3e3>k?3e3:4320>k?4320:1960*MT(k/1960))-k,10<k){s.timeoutHandle=sh(Ei.bind(null,s,qr,gs),k);break}Ei(s,qr,gs);break;case 5:Ei(s,qr,gs);break;default:throw Error(n(329))}}}return Gr(s,Ut()),s.callbackNode===d?Ly.bind(null,s):null}function Jh(s,a){var d=Ol;return s.current.memoizedState.isDehydrated&&(xi(s,a).flags|=256),s=Lu(s,a),s!==2&&(a=qr,qr=d,a!==null&&ep(a)),s}function ep(s){qr===null?qr=s:qr.push.apply(qr,s)}function LT(s){for(var a=s;;){if(a.flags&16384){var d=a.updateQueue;if(d!==null&&(d=d.stores,d!==null))for(var k=0;k<d.length;k++){var v=d[k],E=v.getSnapshot;v=v.value;try{if(!Ro(E(),v))return!1}catch{return!1}}}if(d=a.child,a.subtreeFlags&16384&&d!==null)d.return=a,a=d;else{if(a===s)break;for(;a.sibling===null;){if(a.return===null||a.return===s)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function Ws(s,a){for(a&=~Vh,a&=~Au,s.suspendedLanes|=a,s.pingedLanes&=~a,s=s.expirationTimes;0<a;){var d=31-Gt(a),k=1<<d;s[d]=-1,a&=~k}}function Py(s){if((on&6)!==0)throw Error(n(327));Na();var a=Mn(s,0);if((a&1)===0)return Gr(s,Ut()),null;var d=Lu(s,a);if(s.tag!==0&&d===2){var k=xr(s);k!==0&&(a=k,d=Jh(s,k))}if(d===1)throw d=$l,xi(s,0),Ws(s,a),Gr(s,Ut()),d;if(d===6)throw Error(n(345));return s.finishedWork=s.current.alternate,s.finishedLanes=a,Ei(s,qr,gs),Gr(s,Ut()),null}function tp(s,a){var d=on;on|=1;try{return s(a)}finally{on=d,on===0&&(Sa=Ut()+500,cu&&Ds())}}function bi(s){Hs!==null&&Hs.tag===0&&(on&6)===0&&Na();var a=on;on|=1;var d=wo.transition,k=Xe;try{if(wo.transition=null,Xe=1,s)return s()}finally{Xe=k,wo.transition=d,on=a,(on&6)===0&&Ds()}}function np(){ao=_a.current,$n(_a)}function xi(s,a){s.finishedWork=null,s.finishedLanes=0;var d=s.timeoutHandle;if(d!==-1&&(s.timeoutHandle=-1,fT(d)),rr!==null)for(d=rr.return;d!==null;){var k=d;switch(dh(k),k.tag){case 1:k=k.type.childContextTypes,k!=null&&au();break;case 3:ba(),$n(Kr),$n(Er),_h();break;case 5:xh(k);break;case 4:ba();break;case 13:$n(Bn);break;case 19:$n(Bn);break;case 10:kh(k.type._context);break;case 22:case 23:np()}d=d.return}if(hr=s,rr=s=Zs(s.current,null),br=ao=a,ir=0,$l=null,Vh=Au=vi=0,qr=Ol=null,ki!==null){for(a=0;a<ki.length;a++)if(d=ki[a],k=d.interleaved,k!==null){d.interleaved=null;var v=k.next,E=d.pending;if(E!==null){var C=E.next;E.next=v,k.next=C}d.pending=k}ki=null}return s}function Dy(s,a){do{var d=rr;try{if(gh(),yu.current=Eu,vu){for(var k=Un.memoizedState;k!==null;){var v=k.queue;v!==null&&(v.pending=null),k=k.next}vu=!1}if(yi=0,fr=sr=Un=null,Tl=!1,jl=0,Gh.current=null,d===null||d.return===null){ir=1,$l=a,rr=null;break}e:{var E=s,C=d.return,F=d,V=a;if(a=br,F.flags|=32768,V!==null&&typeof V=="object"&&typeof V.then=="function"){var ue=V,Ce=F,Ie=Ce.tag;if((Ce.mode&1)===0&&(Ie===0||Ie===11||Ie===15)){var Te=Ce.alternate;Te?(Ce.updateQueue=Te.updateQueue,Ce.memoizedState=Te.memoizedState,Ce.lanes=Te.lanes):(Ce.updateQueue=null,Ce.memoizedState=null)}var qe=cy(C);if(qe!==null){qe.flags&=-257,uy(qe,C,F,E,a),qe.mode&1&&ly(E,ue,a),a=qe,V=ue;var tt=a.updateQueue;if(tt===null){var rt=new Set;rt.add(V),a.updateQueue=rt}else tt.add(V);break e}else{if((a&1)===0){ly(E,ue,a),rp();break e}V=Error(n(426))}}else if(Pn&&F.mode&1){var Jn=cy(C);if(Jn!==null){(Jn.flags&65536)===0&&(Jn.flags|=256),uy(Jn,C,F,E,a),ph(xa(V,F));break e}}E=V=xa(V,F),ir!==4&&(ir=2),Ol===null?Ol=[E]:Ol.push(E),E=C;do{switch(E.tag){case 3:E.flags|=65536,a&=-a,E.lanes|=a;var ie=iy(E,V,a);$w(E,ie);break e;case 1:F=V;var Q=E.type,ce=E.stateNode;if((E.flags&128)===0&&(typeof Q.getDerivedStateFromError=="function"||ce!==null&&typeof ce.componentDidCatch=="function"&&(Us===null||!Us.has(ce)))){E.flags|=65536,a&=-a,E.lanes|=a;var Me=ay(E,F,a);$w(E,Me);break e}}E=E.return}while(E!==null)}By(d)}catch(ot){a=ot,rr===d&&d!==null&&(rr=d=d.return);continue}break}while(!0)}function zy(){var s=Cu.current;return Cu.current=Eu,s===null?Eu:s}function rp(){(ir===0||ir===3||ir===2)&&(ir=4),hr===null||(vi&268435455)===0&&(Au&268435455)===0||Ws(hr,br)}function Lu(s,a){var d=on;on|=2;var k=zy();(hr!==s||br!==a)&&(gs=null,xi(s,a));do try{PT();break}catch(v){Dy(s,v)}while(!0);if(gh(),on=d,Cu.current=k,rr!==null)throw Error(n(261));return hr=null,br=0,ir}function PT(){for(;rr!==null;)Fy(rr)}function DT(){for(;rr!==null&&!Jt();)Fy(rr)}function Fy(s){var a=Ky(s.alternate,s,ao);s.memoizedProps=s.pendingProps,a===null?By(s):rr=a,Gh.current=null}function By(s){var a=s;do{var d=a.alternate;if(s=a.return,(a.flags&32768)===0){if(d=AT(d,a,ao),d!==null){rr=d;return}}else{if(d=IT(d,a),d!==null){d.flags&=32767,rr=d;return}if(s!==null)s.flags|=32768,s.subtreeFlags=0,s.deletions=null;else{ir=6,rr=null;return}}if(a=a.sibling,a!==null){rr=a;return}rr=a=s}while(a!==null);ir===0&&(ir=5)}function Ei(s,a,d){var k=Xe,v=wo.transition;try{wo.transition=null,Xe=1,zT(s,a,d,k)}finally{wo.transition=v,Xe=k}return null}function zT(s,a,d,k){do Na();while(Hs!==null);if((on&6)!==0)throw Error(n(327));d=s.finishedWork;var v=s.finishedLanes;if(d===null)return null;if(s.finishedWork=null,s.finishedLanes=0,d===s.current)throw Error(n(177));s.callbackNode=null,s.callbackPriority=0;var E=d.lanes|d.childLanes;if(wr(s,E),s===hr&&(rr=hr=null,br=0),(d.subtreeFlags&2064)===0&&(d.flags&2064)===0||Ru||(Ru=!0,Wy(St,function(){return Na(),null})),E=(d.flags&15990)!==0,(d.subtreeFlags&15990)!==0||E){E=wo.transition,wo.transition=null;var C=Xe;Xe=1;var F=on;on|=4,Gh.current=null,$T(s,d),Iy(d,s),sT(rh),Gi=!!nh,rh=nh=null,s.current=d,OT(d),rn(),on=F,Xe=C,wo.transition=E}else s.current=d;if(Ru&&(Ru=!1,Hs=s,$u=v),E=s.pendingLanes,E===0&&(Us=null),Ft(d.stateNode),Gr(s,Ut()),a!==null)for(k=s.onRecoverableError,d=0;d<a.length;d++)v=a[d],k(v.value,{componentStack:v.stack,digest:v.digest});if(Iu)throw Iu=!1,s=Xh,Xh=null,s;return($u&1)!==0&&s.tag!==0&&Na(),E=s.pendingLanes,(E&1)!==0?s===Qh?Ml++:(Ml=0,Qh=s):Ml=0,Ds(),null}function Na(){if(Hs!==null){var s=gt($u),a=wo.transition,d=Xe;try{if(wo.transition=null,Xe=16>s?16:s,Hs===null)var k=!1;else{if(s=Hs,Hs=null,$u=0,(on&6)!==0)throw Error(n(331));var v=on;for(on|=4,Je=s.current;Je!==null;){var E=Je,C=E.child;if((Je.flags&16)!==0){var F=E.deletions;if(F!==null){for(var V=0;V<F.length;V++){var ue=F[V];for(Je=ue;Je!==null;){var Ce=Je;switch(Ce.tag){case 0:case 11:case 15:Rl(8,Ce,E)}var Ie=Ce.child;if(Ie!==null)Ie.return=Ce,Je=Ie;else for(;Je!==null;){Ce=Je;var Te=Ce.sibling,qe=Ce.return;if(Ny(Ce),Ce===ue){Je=null;break}if(Te!==null){Te.return=qe,Je=Te;break}Je=qe}}}var tt=E.alternate;if(tt!==null){var rt=tt.child;if(rt!==null){tt.child=null;do{var Jn=rt.sibling;rt.sibling=null,rt=Jn}while(rt!==null)}}Je=E}}if((E.subtreeFlags&2064)!==0&&C!==null)C.return=E,Je=C;else e:for(;Je!==null;){if(E=Je,(E.flags&2048)!==0)switch(E.tag){case 0:case 11:case 15:Rl(9,E,E.return)}var ie=E.sibling;if(ie!==null){ie.return=E.return,Je=ie;break e}Je=E.return}}var Q=s.current;for(Je=Q;Je!==null;){C=Je;var ce=C.child;if((C.subtreeFlags&2064)!==0&&ce!==null)ce.return=C,Je=ce;else e:for(C=Q;Je!==null;){if(F=Je,(F.flags&2048)!==0)try{switch(F.tag){case 0:case 11:case 15:ju(9,F)}}catch(ot){Yn(F,F.return,ot)}if(F===C){Je=null;break e}var Me=F.sibling;if(Me!==null){Me.return=F.return,Je=Me;break e}Je=F.return}}if(on=v,Ds(),st&&typeof st.onPostCommitFiberRoot=="function")try{st.onPostCommitFiberRoot(kt,s)}catch{}k=!0}return k}finally{Xe=d,wo.transition=a}}return!1}function Uy(s,a,d){a=xa(d,a),a=iy(s,a,1),s=Fs(s,a,1),a=Fr(),s!==null&&(Lr(s,1,a),Gr(s,a))}function Yn(s,a,d){if(s.tag===3)Uy(s,s,d);else for(;a!==null;){if(a.tag===3){Uy(a,s,d);break}else if(a.tag===1){var k=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof k.componentDidCatch=="function"&&(Us===null||!Us.has(k))){s=xa(d,s),s=ay(a,s,1),a=Fs(a,s,1),s=Fr(),a!==null&&(Lr(a,1,s),Gr(a,s));break}}a=a.return}}function FT(s,a,d){var k=s.pingCache;k!==null&&k.delete(a),a=Fr(),s.pingedLanes|=s.suspendedLanes&d,hr===s&&(br&d)===d&&(ir===4||ir===3&&(br&130023424)===br&&500>Ut()-Yh?xi(s,0):Vh|=d),Gr(s,a)}function Hy(s,a){a===0&&((s.mode&1)===0?a=1:(a=bt,bt<<=1,(bt&130023424)===0&&(bt=4194304)));var d=Fr();s=hs(s,a),s!==null&&(Lr(s,a,d),Gr(s,d))}function BT(s){var a=s.memoizedState,d=0;a!==null&&(d=a.retryLane),Hy(s,d)}function UT(s,a){var d=0;switch(s.tag){case 13:var k=s.stateNode,v=s.memoizedState;v!==null&&(d=v.retryLane);break;case 19:k=s.stateNode;break;default:throw Error(n(314))}k!==null&&k.delete(a),Hy(s,d)}var Ky;Ky=function(s,a,d){if(s!==null)if(s.memoizedProps!==a.pendingProps||Kr.current)Zr=!0;else{if((s.lanes&d)===0&&(a.flags&128)===0)return Zr=!1,CT(s,a,d);Zr=(s.flags&131072)!==0}else Zr=!1,Pn&&(a.flags&1048576)!==0&&Ew(a,du,a.index);switch(a.lanes=0,a.tag){case 2:var k=a.type;Nu(s,a),s=a.pendingProps;var v=pa(a,Er.current);va(a,d),v=Th(null,a,k,s,v,d);var E=jh();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,Wr(k)?(E=!0,lu(a)):E=!1,a.memoizedState=v.state!==null&&v.state!==void 0?v.state:null,vh(a),v.updater=_u,a.stateNode=v,v._reactInternals=a,Oh(a,k,s,d),a=Dh(null,a,k,!0,E,d)):(a.tag=0,Pn&&E&&uh(a),zr(null,a,v,d),a=a.child),a;case 16:k=a.elementType;e:{switch(Nu(s,a),s=a.pendingProps,v=k._init,k=v(k._payload),a.type=k,v=a.tag=KT(k),s=Oo(k,s),v){case 0:a=Ph(null,a,k,s,d);break e;case 1:a=gy(null,a,k,s,d);break e;case 11:a=dy(null,a,k,s,d);break e;case 14:a=fy(null,a,k,Oo(k.type,s),d);break e}throw Error(n(306,k,""))}return a;case 0:return k=a.type,v=a.pendingProps,v=a.elementType===k?v:Oo(k,v),Ph(s,a,k,v,d);case 1:return k=a.type,v=a.pendingProps,v=a.elementType===k?v:Oo(k,v),gy(s,a,k,v,d);case 3:e:{if(ky(a),s===null)throw Error(n(387));k=a.pendingProps,E=a.memoizedState,v=E.element,Rw(s,a),ku(a,k,null,d);var C=a.memoizedState;if(k=C.element,E.isDehydrated)if(E={element:k,isDehydrated:!1,cache:C.cache,pendingSuspenseBoundaries:C.pendingSuspenseBoundaries,transitions:C.transitions},a.updateQueue.baseState=E,a.memoizedState=E,a.flags&256){v=xa(Error(n(423)),a),a=wy(s,a,k,d,v);break e}else if(k!==v){v=xa(Error(n(424)),a),a=wy(s,a,k,d,v);break e}else for(io=Ms(a.stateNode.containerInfo.firstChild),so=a,Pn=!0,$o=null,d=Aw(a,null,k,d),a.child=d;d;)d.flags=d.flags&-3|4096,d=d.sibling;else{if(ka(),k===v){a=ms(s,a,d);break e}zr(s,a,k,d)}a=a.child}return a;case 5:return Mw(a),s===null&&hh(a),k=a.type,v=a.pendingProps,E=s!==null?s.memoizedProps:null,C=v.children,oh(k,v)?C=null:E!==null&&oh(k,E)&&(a.flags|=32),my(s,a),zr(s,a,C,d),a.child;case 6:return s===null&&hh(a),null;case 13:return yy(s,a,d);case 4:return bh(a,a.stateNode.containerInfo),k=a.pendingProps,s===null?a.child=wa(a,null,k,d):zr(s,a,k,d),a.child;case 11:return k=a.type,v=a.pendingProps,v=a.elementType===k?v:Oo(k,v),dy(s,a,k,v,d);case 7:return zr(s,a,a.pendingProps,d),a.child;case 8:return zr(s,a,a.pendingProps.children,d),a.child;case 12:return zr(s,a,a.pendingProps.children,d),a.child;case 10:e:{if(k=a.type._context,v=a.pendingProps,E=a.memoizedProps,C=v.value,Cn(pu,k._currentValue),k._currentValue=C,E!==null)if(Ro(E.value,C)){if(E.children===v.children&&!Kr.current){a=ms(s,a,d);break e}}else for(E=a.child,E!==null&&(E.return=a);E!==null;){var F=E.dependencies;if(F!==null){C=E.child;for(var V=F.firstContext;V!==null;){if(V.context===k){if(E.tag===1){V=ps(-1,d&-d),V.tag=2;var ue=E.updateQueue;if(ue!==null){ue=ue.shared;var Ce=ue.pending;Ce===null?V.next=V:(V.next=Ce.next,Ce.next=V),ue.pending=V}}E.lanes|=d,V=E.alternate,V!==null&&(V.lanes|=d),wh(E.return,d,a),F.lanes|=d;break}V=V.next}}else if(E.tag===10)C=E.type===a.type?null:E.child;else if(E.tag===18){if(C=E.return,C===null)throw Error(n(341));C.lanes|=d,F=C.alternate,F!==null&&(F.lanes|=d),wh(C,d,a),C=E.sibling}else C=E.child;if(C!==null)C.return=E;else for(C=E;C!==null;){if(C===a){C=null;break}if(E=C.sibling,E!==null){E.return=C.return,C=E;break}C=C.return}E=C}zr(s,a,v.children,d),a=a.child}return a;case 9:return v=a.type,k=a.pendingProps.children,va(a,d),v=go(v),k=k(v),a.flags|=1,zr(s,a,k,d),a.child;case 14:return k=a.type,v=Oo(k,a.pendingProps),v=Oo(k.type,v),fy(s,a,k,v,d);case 15:return hy(s,a,a.type,a.pendingProps,d);case 17:return k=a.type,v=a.pendingProps,v=a.elementType===k?v:Oo(k,v),Nu(s,a),a.tag=1,Wr(k)?(s=!0,lu(a)):s=!1,va(a,d),oy(a,k,v),Oh(a,k,v,d),Dh(null,a,k,!0,s,d);case 19:return by(s,a,d);case 22:return py(s,a,d)}throw Error(n(156,a.tag))};function Wy(s,a){return Ze(s,a)}function HT(s,a,d,k){this.tag=s,this.key=d,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=a,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=k,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function yo(s,a,d,k){return new HT(s,a,d,k)}function op(s){return s=s.prototype,!(!s||!s.isReactComponent)}function KT(s){if(typeof s=="function")return op(s)?1:0;if(s!=null){if(s=s.$$typeof,s===q)return 11;if(s===ge)return 14}return 2}function Zs(s,a){var d=s.alternate;return d===null?(d=yo(s.tag,a,s.key,s.mode),d.elementType=s.elementType,d.type=s.type,d.stateNode=s.stateNode,d.alternate=s,s.alternate=d):(d.pendingProps=a,d.type=s.type,d.flags=0,d.subtreeFlags=0,d.deletions=null),d.flags=s.flags&14680064,d.childLanes=s.childLanes,d.lanes=s.lanes,d.child=s.child,d.memoizedProps=s.memoizedProps,d.memoizedState=s.memoizedState,d.updateQueue=s.updateQueue,a=s.dependencies,d.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},d.sibling=s.sibling,d.index=s.index,d.ref=s.ref,d}function Pu(s,a,d,k,v,E){var C=2;if(k=s,typeof s=="function")op(s)&&(C=1);else if(typeof s=="string")C=5;else e:switch(s){case A:return _i(d.children,v,E,a);case I:C=8,v|=8;break;case _:return s=yo(12,d,a,v|2),s.elementType=_,s.lanes=E,s;case se:return s=yo(13,d,a,v),s.elementType=se,s.lanes=E,s;case Y:return s=yo(19,d,a,v),s.elementType=Y,s.lanes=E,s;case oe:return Du(d,v,E,a);default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case P:C=10;break e;case z:C=9;break e;case q:C=11;break e;case ge:C=14;break e;case ke:C=16,k=null;break e}throw Error(n(130,s==null?s:typeof s,""))}return a=yo(C,d,a,v),a.elementType=s,a.type=k,a.lanes=E,a}function _i(s,a,d,k){return s=yo(7,s,k,a),s.lanes=d,s}function Du(s,a,d,k){return s=yo(22,s,k,a),s.elementType=oe,s.lanes=d,s.stateNode={isHidden:!1},s}function sp(s,a,d){return s=yo(6,s,null,a),s.lanes=d,s}function ip(s,a,d){return a=yo(4,s.children!==null?s.children:[],s.key,a),a.lanes=d,a.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},a}function WT(s,a,d,k,v){this.tag=a,this.containerInfo=s,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Mr(0),this.expirationTimes=Mr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Mr(0),this.identifierPrefix=k,this.onRecoverableError=v,this.mutableSourceEagerHydrationData=null}function ap(s,a,d,k,v,E,C,F,V){return s=new WT(s,a,d,F,V),a===1?(a=1,E===!0&&(a|=8)):a=0,E=yo(3,null,null,a),s.current=E,E.stateNode=s,E.memoizedState={element:k,isDehydrated:d,cache:null,transitions:null,pendingSuspenseBoundaries:null},vh(E),s}function ZT(s,a,d){var k=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:W,key:k==null?null:""+k,children:s,containerInfo:a,implementation:d}}function Zy(s){if(!s)return Ps;s=s._reactInternals;e:{if(cr(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(Wr(a.type)){a=a.stateNode.__reactInternalMemoizedMergedChildContext;break e}}a=a.return}while(a!==null);throw Error(n(171))}if(s.tag===1){var d=s.type;if(Wr(d))return vw(s,d,a)}return a}function qy(s,a,d,k,v,E,C,F,V){return s=ap(d,k,!0,s,v,E,C,F,V),s.context=Zy(null),d=s.current,k=Fr(),v=Ks(d),E=ps(k,v),E.callback=a??null,Fs(d,E,v),s.current.lanes=v,Lr(s,v,k),Gr(s,k),s}function zu(s,a,d,k){var v=a.current,E=Fr(),C=Ks(v);return d=Zy(d),a.context===null?a.context=d:a.pendingContext=d,a=ps(E,C),a.payload={element:s},k=k===void 0?null:k,k!==null&&(a.callback=k),s=Fs(v,a,C),s!==null&&(Po(s,v,C,E),gu(s,v,C)),C}function Fu(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 Gy(s,a){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var d=s.retryLane;s.retryLane=d!==0&&d<a?d:a}}function lp(s,a){Gy(s,a),(s=s.alternate)&&Gy(s,a)}function qT(){return null}var Vy=typeof reportError=="function"?reportError:function(s){console.error(s)};function cp(s){this._internalRoot=s}Bu.prototype.render=cp.prototype.render=function(s){var a=this._internalRoot;if(a===null)throw Error(n(409));zu(s,a,null,null)},Bu.prototype.unmount=cp.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var a=s.containerInfo;bi(function(){zu(null,s,null,null)}),a[cs]=null}};function Bu(s){this._internalRoot=s}Bu.prototype.unstable_scheduleHydration=function(s){if(s){var a=Pr();s={blockedOn:null,target:s,priority:a};for(var d=0;d<xt.length&&a!==0&&a<xt[d].priority;d++);xt.splice(d,0,s),d===0&&nr(s)}};function up(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function Uu(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11&&(s.nodeType!==8||s.nodeValue!==" react-mount-point-unstable "))}function Yy(){}function GT(s,a,d,k,v){if(v){if(typeof k=="function"){var E=k;k=function(){var ue=Fu(C);E.call(ue)}}var C=qy(a,k,s,0,null,!1,!1,"",Yy);return s._reactRootContainer=C,s[cs]=C.current,yl(s.nodeType===8?s.parentNode:s),bi(),C}for(;v=s.lastChild;)s.removeChild(v);if(typeof k=="function"){var F=k;k=function(){var ue=Fu(V);F.call(ue)}}var V=ap(s,0,!1,null,null,!1,!1,"",Yy);return s._reactRootContainer=V,s[cs]=V.current,yl(s.nodeType===8?s.parentNode:s),bi(function(){zu(a,V,d,k)}),V}function Hu(s,a,d,k,v){var E=d._reactRootContainer;if(E){var C=E;if(typeof v=="function"){var F=v;v=function(){var V=Fu(C);F.call(V)}}zu(a,C,s,v)}else C=GT(d,a,s,v,k);return Fu(C)}Ao=function(s){switch(s.tag){case 3:var a=s.stateNode;if(a.current.memoizedState.isDehydrated){var d=Ht(a.pendingLanes);d!==0&&(Co(a,d|1),Gr(a,Ut()),(on&6)===0&&(Sa=Ut()+500,Ds()))}break;case 13:bi(function(){var k=hs(s,1);if(k!==null){var v=Fr();Po(k,s,1,v)}}),lp(s,1)}},ln=function(s){if(s.tag===13){var a=hs(s,134217728);if(a!==null){var d=Fr();Po(a,s,134217728,d)}lp(s,134217728)}},Xt=function(s){if(s.tag===13){var a=Ks(s),d=hs(s,a);if(d!==null){var k=Fr();Po(d,s,a,k)}lp(s,a)}},Pr=function(){return Xe},Xn=function(s,a){var d=Xe;try{return Xe=s,a()}finally{Xe=d}},qn=function(s,a,d){switch(a){case"input":if(_n(s,d),a=d.name,d.type==="radio"&&a!=null){for(d=s;d.parentNode;)d=d.parentNode;for(d=d.querySelectorAll("input[name="+JSON.stringify(""+a)+'][type="radio"]'),a=0;a<d.length;a++){var k=d[a];if(k!==s&&k.form===s.form){var v=iu(k);if(!v)throw Error(n(90));Fe(k),_n(k,v)}}}break;case"textarea":It(s,d);break;case"select":a=d.value,a!=null&&He(s,!!d.multiple,a,!1)}},_e=tp,Ge=bi;var VT={usingClientEntryPoint:!1,Events:[xl,fa,iu,H,me,tp]},Ll={findFiberByHostInstance:hi,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},YT={bundleType:Ll.bundleType,version:Ll.version,rendererPackageName:Ll.rendererPackageName,rendererConfig:Ll.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:R.ReactCurrentDispatcher,findHostInstanceByFiber:function(s){return s=G(s),s===null?null:s.stateNode},findFiberByHostInstance:Ll.findFiberByHostInstance||qT,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 Ku=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ku.isDisabled&&Ku.supportsFiber)try{kt=Ku.inject(YT),st=Ku}catch{}}return Vr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=VT,Vr.createPortal=function(s,a){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!up(a))throw Error(n(200));return ZT(s,a,null,d)},Vr.createRoot=function(s,a){if(!up(s))throw Error(n(299));var d=!1,k="",v=Vy;return a!=null&&(a.unstable_strictMode===!0&&(d=!0),a.identifierPrefix!==void 0&&(k=a.identifierPrefix),a.onRecoverableError!==void 0&&(v=a.onRecoverableError)),a=ap(s,1,!1,null,null,d,!1,k,v),s[cs]=a.current,yl(s.nodeType===8?s.parentNode:s),new cp(a)},Vr.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=G(a),s=s===null?null:s.stateNode,s},Vr.flushSync=function(s){return bi(s)},Vr.hydrate=function(s,a,d){if(!Uu(a))throw Error(n(200));return Hu(null,s,a,!0,d)},Vr.hydrateRoot=function(s,a,d){if(!up(s))throw Error(n(405));var k=d!=null&&d.hydratedSources||null,v=!1,E="",C=Vy;if(d!=null&&(d.unstable_strictMode===!0&&(v=!0),d.identifierPrefix!==void 0&&(E=d.identifierPrefix),d.onRecoverableError!==void 0&&(C=d.onRecoverableError)),a=qy(a,null,s,1,d??null,v,!1,E,C),s[cs]=a.current,yl(s),k)for(s=0;s<k.length;s++)d=k[s],v=d._getVersion,v=v(d._source),a.mutableSourceEagerHydrationData==null?a.mutableSourceEagerHydrationData=[d,v]:a.mutableSourceEagerHydrationData.push(d,v);return new Bu(a)},Vr.render=function(s,a,d){if(!Uu(a))throw Error(n(200));return Hu(null,s,a,!1,d)},Vr.unmountComponentAtNode=function(s){if(!Uu(s))throw Error(n(40));return s._reactRootContainer?(bi(function(){Hu(null,null,s,!1,function(){s._reactRootContainer=null,s[cs]=null})}),!0):!1},Vr.unstable_batchedUpdates=tp,Vr.unstable_renderSubtreeIntoContainer=function(s,a,d,k){if(!Uu(d))throw Error(n(200));if(s==null||s._reactInternals===void 0)throw Error(n(38));return Hu(s,a,d,!1,k)},Vr.version="18.3.1-next-f1338f8080-20240426",Vr}var ov;function aj(){if(ov)return hp.exports;ov=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(),hp.exports=ij(),hp.exports}var sv;function lj(){if(sv)return Wu;sv=1;var e=aj();return Wu.createRoot=e.createRoot,Wu.hydrateRoot=e.hydrateRoot,Wu}var cj=lj();const ni="shell",_x="check",uj="ToolSearch",rg="AskUserQuestion",Sx="preview",dj=new Set(["edit","delete","move","execute"]),fj=new Set(["Edit","Write","MultiEdit","NotebookEdit","Bash"]);function og(e){return e.kind?dj.has(e.kind):fj.has(e.name)}const hj=["read","edit","delete","move","search","execute","fetch"];function sg(e){return hj.includes(e??"")}function Nx(e,t){return(sg(e.kind)||e.name===rg)&&ef(t)}function ef(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 Sc=[{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"}],xd="auto";function pj(e){return e.branch.startsWith("toyon/")}const vo="shell",vs="login";function mj(e,t){return`${e}/${t}`}function gj(e,t,n,r=0){var i;let o=e;for(let l=r;l>0;l--){let u=o.length-1;for(;u>=0&&((i=o[u])==null?void 0:i.proc)!==t;)u--;if(u<0)break;o=o===e?[...o]:o,o.splice(u,1)}return n?[...o,{proc:t,line:n}]:o}const kj=["use","always","off"];function Tx(e){return e.find(t=>t.id==="default")}function wj(e){const t=Tx(e);if(t!=null&&t.description)return e.find(n=>n!==t&&n.name===t.description)}function An(e){return e.worktree!==void 0}function Di(e){return e.kind==="main"}function Nc(e){return e.kind==="spare"}function Ir(e){return Nc(e)||Di(e)}function ig(e){return e.kind==="worktree"}function jx(e){return e.kind==="worktree"&&pj(e)}function Ai(e){var t;return e.kind==="worktree"&&((t=e.from)==null?void 0:t.kind)!=="pr"}function hd(e){return e.kind==="worktree"}function tf(e){return!!e.branch&&!e.locked&&!(e.worktree&&Ir(e.worktree))}const lc=e=>{var t;return e.promptedAt??((t=e.lastTurn)==null?void 0:t.at)??e.createdAt},yj=e=>Ir(e)?0:1,vj=e=>e.variant?`group:${e.variant.group}`:`row:${e.id}`;function bj(e){const t=[],n=new Map;for(const r of e){const o=r.worktree,i=vj(o),l=n.get(i);if(l){l.rows.push(r),l.at=Math.max(l.at,lc(o));continue}const u={tier:yj(o),at:lc(o),rows:[r]};t.push(u),n.set(i,u)}return t.sort((r,o)=>r.tier-o.tier||o.at-r.at),t.flatMap(r=>r.rows.length>1?r.rows.sort((o,i)=>{var l,u;return(((l=o.worktree.variant)==null?void 0:l.index)??0)-(((u=i.worktree.variant)==null?void 0:u.index)??0)}):r.rows)}const iv="not opened in ";function xj(e){const t=e.lastIndexOf(iv);return t<0?{what:e}:{what:e.slice(0,t).replace(/,\s*$/,""),idle:e.slice(t+iv.length)}}const Cx={image:6,paste:4,file:8,pick:8},Ej={image:"image",paste:"paste",file:"file",pick:"element"},_j={image:"Image",paste:"Pasted text"},Ax=(e,t)=>`${_j[e]} ${t}`,ag=e=>`at most ${Cx[e]} ${Ej[e]}s per message`,Sj=(e,t)=>e.filter(n=>n.kind===t).length,Nj=(e,t)=>Math.max(0,Cx[t]-Sj(e,t));function nm(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 lg(e,t){const n={...t};return e.map(r=>[r,n[r.kind]++])}function rm(e,t){const n={...e};for(const r of t)n[r.kind]++;return n}function cg(e){return e>=1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}const Da=e=>`card:${e}`,pd=[{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"}],Tj=new Set(["zen","close","back","forward"]);function Ix(e,{guest:t=!1}={}){var r,o;if(e.altKey){if(e.metaKey||e.ctrlKey)return null;const i=pd.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=pd.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 pd){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 jj(e){return e.altKey||e.key.toLowerCase()!=="s"?!1:!!e.ctrlKey!==e.metaKey}function Rx(e){const t=pd.find(n=>n.id===e);if(!t)throw new Error(`unknown chord ${e}`);return t}function Cj(e,t){return e===t-1?"⌘9":e<8?`⌘${e+1}`:void 0}function Aj(e,t){return t===0?null:e===9?t-1:e-1<t?e-1:null}function Ij(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 Rj(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 $j(e,t){const n=Rx(e);return!!n.textKeeps&&Ij(t)&&!(n.emptyGives&&Rj(t))}const Oj=["Find","Preview","Panels","Worktrees"],Jl={"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"}},Mj={ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Backspace:"⌫",Tab:"Tab"};function Lj(e,t={}){var u;const n=Rx(e),r=Jl[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":Mj[o]??o.toUpperCase(),l=o!==n.key&&o===((u=n.ctrlAlias)==null?void 0:u.key)?n.ctrlAlias:void 0;return l?`⌃${l.shift?"⇧":""}${i}`:`${n.alt?"⌥":n.ctrl?"⌃":"⌘"}${n.shift?"⇧":""}${i}`}function Pj(e){return Object.keys(Jl).filter(t=>Jl[t].section===e&&!Jl[t].hidden)}const av={m:6e4,h:60*6e4};function Dj(e){const[t,n]=zj(e);return`${t}${n.charAt(0)}`}function zj(e){const t=e/av.h;if(t>=1&&Number.isInteger(t))return[t,"hour"];const n=e/av.m;return n>=1&&Number.isInteger(n)?[n,"minute"]:n>=60?[Math.round(n),"minute"]:[Math.max(1,Math.round(e/1e3)),"second"]}const cc={folder:{shared:".toyon/settings.json",local:".toyon/settings.local.json"},root:{shared:"toyon.json",local:"toyon.local.json"}};function $x(e){return typeof e=="string"?e:e.cmd}function Fj(e){return typeof e!="string"&&e.from==="trunk"}function Bj(e){return[...e.setup??[],...e.teardown??[],...Object.values(e.run).map($x),...Object.values(e.profiles??{}).flatMap(n=>Object.values(n.env??{}))].some(n=>n.includes("TOYON_WORKTREE"))}function Uj(e){return e===cc.folder.local||e===cc.root.local}function Hj(e){return Uj(e)?"local":"shared"}function Kj(e,t){return(Object.values(cc).find(r=>r.shared===e||r.local===e)??cc.folder)[t]}const Wj=e=>`https://${e}/`;function Zj(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 Vj(n.origin)?n.origin:null}const qj=e=>e.endsWith(".ts.net"),lv=e=>e.length<2?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function Gj(e){if(e===null)return{ok:!0,text:"Your phone needs Tailscale on, signed in to the same tailnet."};if(e.length===0)return{ok:!1,text:"No phone has joined your tailnet. Install Tailscale on it and sign in to the same account first."};const t=e.filter(r=>r.online).map(r=>r.name);if(t.length>0)return{ok:!0,text:`${lv(t)} ${t.length>1?"are":"is"} on your tailnet.`};const n=e.map(r=>r.name);return{ok:!1,text:`${lv(n)} ${n.length>1?"are":"is"} not answering on your tailnet. Check Tailscale is on there.`}}function Vj(e){let t;try{t=new URL(e)}catch{return!1}return t.origin!==e?!1:t.protocol==="https:"||t.protocol==="http:"&&ug(t.hostname)}const Yj="toyon_grant";function ug(e){return e==="127.0.0.1"||e==="::1"||e==="[::1]"||e==="localhost"||e.endsWith(".localhost")}function Xj(e,t,n){return e.replace("{id}",t).replace("{port}",String(n))}const Qj=4401,Jj=25e4;function eC(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(...tC(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 tC(e,t){if(e.length===0)return t.map(u=>({mark:"+",value:u}));if(t.length===0)return e.map(u=>({mark:"-",value:u}));if((e.length+1)*(t.length+1)>Jj)return[...e.map(u=>({mark:"-",value:u})),...t.map(u=>({mark:"+",value:u}))];const n=t.length+1,r=new Uint32Array((e.length+1)*n);for(let u=e.length-1;u>=0;u--)for(let c=t.length-1;c>=0;c--)r[u*n+c]=e[u]===t[c]?(r[(u+1)*n+c+1]??0)+1:Math.max(r[(u+1)*n+c]??0,r[u*n+c+1]??0);const o=[];let i=0,l=0;for(;i<e.length&&l<t.length;)e[i]===t[l]?(o.push({mark:" ",value:e[i]}),i++,l++):(r[(i+1)*n+l]??0)>=(r[i*n+l+1]??0)?(o.push({mark:"-",value:e[i]}),i++):(o.push({mark:"+",value:t[l]}),l++);for(;i<e.length;)o.push({mark:"-",value:e[i++]});for(;l<t.length;)o.push({mark:"+",value:t[l++]});return o}const nC=/[\p{L}\p{N}_$]+|\s+|[^\s\p{L}\p{N}_$]/gu;function cv(e){return e.match(nC)??[]}const rC=.4;function oC(e,t){if(e===t)return null;const n=eC(cv(e),cv(t));let r=0;for(const o of n)o.mark===" "&&(r+=o.value.length);return r<rC*Math.max(e.length,t.length)?null:{before:uv(n,"-"),after:uv(n,"+")}}function uv(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 Ox(n)}function dv(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(Ox)}function Ox(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 sC=[{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"}],iC=[{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"}],aC=[{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)"}],om="merge",sm="merge";function $i(e){var n,r,o;const t=((n=e.land)==null?void 0:n.route)??om;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 nf(e){return e.base??e.defaultBranch}function lC(e){return e.base!==void 0&&e.base!==e.defaultBranch}function Ed(e,t="main"){const n={merge:"merge into",squash:"squash onto",rebase:"rebase onto"}[e.merge??sm];switch(e.land){case"merge":return`Commit and ${n} ${t} here`;case"push":return`Commit, ${n} ${t} on origin and push it`;case"pr":return e.automerge?"Commit, push the branch and open a PR that GitHub merges when its rules allow":"Commit, push the branch and open a PR"}}function Mx(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=>Dx(n)).join(t)}function im(e,t){return typeof t=="bigint"?t.toString():t}function rf(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function cC(e){return e==null}function dg(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function uC(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 no(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ii(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function dC(e){return JSON.stringify(e)}function fC(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Lx="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function uc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const hC=rf(()=>{var e;if(Zo.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 dc(e){if(uc(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(uc(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Px(e){return dc(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const pC=new Set(["string","number","symbol"]);function Za(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ai(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function it(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Dx(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function mC(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const gC={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 kC(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=ii(e._zod.def,{get shape(){const l={};for(const u of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,u))throw new Error(`Unrecognized key: "${String(u)}"`);t[u]&&no(l,u,n.shape[u])}return no(this,"shape",l),l},checks:[]});return ai(e,i)}function wC(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=ii(e._zod.def,{get shape(){const l={...e._zod.def.shape};for(const u of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,u))throw new Error(`Unrecognized key: "${String(u)}"`);t[u]&&delete l[u]}return no(this,"shape",l),l},checks:[]});return ai(e,i)}function yC(e,t){if(!dc(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=ii(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return no(this,"shape",i),i}});return ai(e,o)}function vC(e,t){if(!dc(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=ii(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return no(this,"shape",r),r}});return ai(e,n)}function bC(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=ii(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t._zod.def.shape};return no(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ai(e,n)}function hv(e,t,n,r="partial"){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const u=ii(t._zod.def,{get shape(){const c=t._zod.def.shape,f={...c};if(n)for(const p of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(c,p))throw new Error(`Unrecognized key: "${String(p)}"`);n[p]&&(f[p]=e?new e({type:"optional",innerType:c[p]}):c[p])}else for(const p of Reflect.ownKeys(c))f[p]=e?new e({type:"optional",innerType:c[p]}):c[p];return no(this,"shape",f),f},checks:[]});return ai(t,u)}function xC(e,t,n){const r=ii(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 no(this,"shape",i),i}});return ai(t,r)}function $a(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 EC(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 of(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Dl(e){return typeof e=="string"?e:e==null?void 0:e.message}function pv(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function nl(e,t,n){var g,w,y,x,b,j,N,T,R,$;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?(x=(y=e.schema)==null?void 0:y._zod.def)==null?void 0:x.error:void 0,l=e.message?e.message:Dl((N=(j=(b=e.inst)==null?void 0:b._zod.def)==null?void 0:j.error)==null?void 0:N.call(j,e))??Dl(i==null?void 0:i(e))??Dl((T=t==null?void 0:t.error)==null?void 0:T.call(t,e))??Dl((R=n.customError)==null?void 0:R.call(n,e))??Dl(($=n.localeError)==null?void 0:$.call(n,e))??"Invalid input",{inst:u,schema:c,continue:f,input:p,...m}=e;return m.path??(m.path=[]),m.message=l,t!=null&&t.reportInput&&(m.input=p),m}const _C=/[\uD800-\uDBFF]/;function fg(e){const t=e.length;if(!_C.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 hg(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function SC(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 fc(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function NC(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):TC(e,n,r.value)}}function qa(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function zx(e,t,n){return qa(e,t,n,!1)}function TC(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:qa(this,t,n.bind(this))},set(r){qa(this,t,r)}})}function jC(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let gp,Qs=!1;const CC={configurable:!0,get(){Qs=!0}};function vn(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&gp!==e._zod){gp=void 0;return}gp=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,CC);const o=Qs;Qs=!1;try{const i=n(this);return Qs?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),Qs=Qs||o,i}catch(i){throw delete this[t],Qs=Qs||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function AC(e,t,n,r){const o=jC(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 IC="~constantCatch";function RC(e){const t=()=>e;return t[IC]=!0,t}var mv;const kp={value:void 0,enumerable:!1};let gv="captureStackTrace"in Error?Error:null;function $C(e){const t=gv;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return gv=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function ve(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,u=l&&new WeakSet;function c(g,w){if(!g._zod){kp.value=new i(w);try{Object.defineProperty(g,"_zod",kp)}finally{kp.value=void 0}}if(g._zod.traits.has(e))return;if(g._zod.traits.add(e),t(g,w),u){const x=Object.getPrototypeOf(g),b=g._zod.constr.prototype;let j=x;for(;j&&j!==b;)j=Object.getPrototypeOf(j);const N=j??x;u.has(N)||(u.add(N),NC(N,l))}const y=m.prototype;for(const x in y)Object.prototype.hasOwnProperty.call(y,x)&&(x in g||(g[x]=y[x].bind(g)))}const f=(r==null?void 0:r.Parent)??Object;class p extends f{}Object.defineProperty(p,"name",{value:e});function m(g){var b;const w=r!=null&&r.Parent?$C(p):this;c(w,g);const y=w._zod.deferred;if(y){for(const j of y)j();w._zod.deferred=void 0}const x=(b=globalThis.__zod_globalConfig)==null?void 0:b.postProcessor;return x&&x(w),w}return Object.defineProperty(m,"init",{value:c}),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 za extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Fx extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(mv=globalThis).__zod_globalConfig??(mv.__zod_globalConfig={});const Zo=globalThis.__zod_globalConfig;function li(e){return e&&Object.assign(Zo,e),Zo}function OC(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,im,2)),e.message}function MC(e){this._zod.message=e}const LC={get:OC,set:MC,enumerable:!0,configurable:!0},wp={value:void 0,enumerable:!1},yp={value:void 0,enumerable:!1},kv=new WeakSet([Object.prototype,Error.prototype]),Bx=(e,t)=>{e.name="$ZodError",wp.value=e._zod,Object.defineProperty(e,"_zod",wp),yp.value=t,Object.defineProperty(e,"issues",yp),wp.value=void 0,yp.value=void 0,Object.defineProperty(e,"message",LC);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})}}))},Ux=ve("$ZodError",Bx),Hx=ve("$ZodError",Bx,void 0,{Parent:Error});function PC(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 DC(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?PC(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n}}function zC(e,t=n=>n.message){const n={_errors:[]},r=(o,i=[])=>{for(const l of o.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(u=>r({issues:u},[...i,...l.path]));else if(l.code==="invalid_key")r({issues:l.issues},[...i,...l.path]);else if(l.code==="invalid_element")r({issues:l.issues},[...i,...l.path]);else{const u=[...i,...l.path];if(u.length===0)n._errors.push(t(l));else{let c=n,f=0;for(;f<u.length;){const p=u[f],m=f===u.length-1;if(p==="_errors"){m&&c._errors.push(t(l)),f++;continue}Object.prototype.hasOwnProperty.call(c,p)||Object.defineProperty(c,p,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const g=c[p];m&&g._errors.push(t(l)),c=g,f++}}}};return r(e),n}function sf(e,t){return{callee:(t==null?void 0:t.callee)??e,Err:t==null?void 0:t.Err}}const pg=e=>{const t=(n,r,o,i)=>{const l=o?{...o,async:!1}:{async:!1},u=n._zod.run({value:r,issues:[]},l);if(u instanceof Promise)throw new za;if(u.issues.length){const c=new((i==null?void 0:i.Err)??e)(u.issues.map(f=>nl(f,l,li())));throw Lx(c,(i==null?void 0:i.callee)??t),c}return u.value};return t},mg=e=>{const t=async(n,r,o,i)=>{const l=o?{...o,async:!0}:{async:!0};let u=n._zod.run({value:r,issues:[]},l);if(u instanceof Promise&&(u=await u),u.issues.length){const c=new((i==null?void 0:i.Err)??e)(u.issues.map(f=>nl(f,l,li())));throw Lx(c,(i==null?void 0:i.callee)??t),c}return u.value};return t},af=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 za;return i.issues.length?{success:!1,error:new(e??Ux)(i.issues.map(l=>nl(l,o,li())))}:{success:!0,data:i.value}},FC=af(Hx),lf=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=>nl(l,o,li())))}:{success:!0,data:i.value}},BC=lf(Hx),UC=e=>{const t=pg(e),n=(r,o,i,l)=>{const u=i?{...i,direction:"backward"}:{direction:"backward"};return t(r,o,u,sf(n,l))};return n},HC=e=>{const t=pg(e),n=(r,o,i,l)=>t(r,o,i,sf(n,l));return n},KC=e=>{const t=mg(e),n=async(r,o,i,l)=>{const u=i?{...i,direction:"backward"}:{direction:"backward"};return await t(r,o,u,sf(n,l))};return n},WC=e=>{const t=mg(e),n=async(r,o,i,l)=>await t(r,o,i,sf(n,l));return n},ZC=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return af(e)(t,n,o)},qC=e=>(t,n,r)=>af(e)(t,n,r),GC=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return lf(e)(t,n,o)},VC=e=>async(t,n,r)=>lf(e)(t,n,r),YC=/^[cC][0-9a-z]{6,}$/,XC=/^[0-9a-z]+$/,QC=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,JC=/^[0-9a-vA-V]{20}$/,eA=/^[A-Za-z0-9]{27}$/,tA=/^[a-zA-Z0-9_-]{21}$/;function nA(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const rA=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,oA=/^([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})$/,wv=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)$/,sA=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,iA="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function aA(){return new RegExp(iA,"u")}const lA=/^(?:(?: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])$/,cA=/^(([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}|:))$/,uA=/^((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])$/,dA=/^(([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])$/,fA=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Kx=/^[A-Za-z0-9_-]*$/,hA=/^https?$/,pA=/^\+[1-9]\d{6,14}$/,Wx="(?:(?:\\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 mA(e){return new RegExp(`^${e}$`)}const gA=mA(Wx);function am(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 kA(e){return new RegExp(`^${am(e)}$`)}function wA(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${am({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${am({precision:e.precision})}`:n;return new RegExp(`^${Wx}T(?:${r})$`)}const yA=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}$`)},vA=/^-?\d+$/,bA=/^-?\d+(?:\.\d+)?$/,xA=/^(?:true|false)$/i,EA=/^[^A-Z]*$/,_A=/^[^a-z]*$/,ro=ve("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),gg=e=>{const t=e.value;return!cC(t)&&t.length!==void 0},_d={number:"number",bigint:"bigint",object:"date"},Zx=ve("$ZodCheckLessThan",(e,t)=>{ro.init(e,t);const n=_d[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:_d[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})}}),qx=ve("$ZodCheckGreaterThan",(e,t)=>{ro.init(e,t);const n=_d[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:_d[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})}}),SA=ve("$ZodCheckMultipleOf",(e,t)=>{ro.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):uC(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})}}),NA=ve("$ZodCheckNumberFormat",(e,t)=>{var l;ro.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]=gC[t.format];e._zod.onattach.push(u=>{const c=u._zod.bag;c.format=t.format,c.minimum=o,c.maximum=i,n&&(c.pattern=vA)}),e._zod.check=u=>{const c=u.value;if(n){if(!Number.isInteger(c)){u.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?u.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):u.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}c<o&&u.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>i&&u.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),TA=ve("$ZodCheckMaxLength",(e,t)=>{var n;ro.init(e,t),(n=e._zod.def).when??(n.when=gg),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?fg(o):i)<=t.maximum)return;const u=hg(o);r.issues.push({origin:u,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),jA=ve("$ZodCheckMinLength",(e,t)=>{var n;ro.init(e,t),(n=e._zod.def).when??(n.when=gg),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?fg(o):i)>=t.minimum)return;const u=hg(o);r.issues.push({origin:u,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),CA=ve("$ZodCheckLengthEquals",(e,t)=>{var n;ro.init(e,t),(n=e._zod.def).when??(n.when=gg),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?fg(o):i;if(l===t.length)return;const u=hg(o),c=l>t.length;r.issues.push({origin:u,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),cf=ve("$ZodCheckStringFormat",(e,t)=>{var n,r;ro.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=()=>{})}),AA=ve("$ZodCheckRegex",(e,t)=>{cf.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})}}),IA=ve("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=EA),cf.init(e,t)}),RA=ve("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=_A),cf.init(e,t)}),$A=ve("$ZodCheckIncludes",(e,t)=>{ro.init(e,t);const n=Za(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})}}),OA=ve("$ZodCheckStartsWith",(e,t)=>{ro.init(e,t);const n=new RegExp(`^${Za(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})}}),MA=ve("$ZodCheckEndsWith",(e,t)=>{ro.init(e,t);const n=new RegExp(`.*${Za(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})}}),LA=ve("$ZodCheckOverwrite",(e,t)=>{ro.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class PA{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 DA={major:4,minor:5,patch:4},zn=ve("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=DA;const r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r!=null&&r.length?[...r]:[];for(const l of o)for(const u of l._zod.onattach)u(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),(i=e._zod.deferred)==null||i.push(()=>{e._zod.run=e._zod.parse});else{const l=(c,f,p)=>{if(c.memo)return c;let m=$a(c),g;for(const w of f){if(w._zod.def.when){if(EC(c)||!w._zod.def.when(c))continue}else if(m)continue;const y=c.issues.length,x=w._zod.check(c);if(x instanceof Promise&&(p==null?void 0:p.async)===!1)throw new za;if(g||x instanceof Promise)g=(g??Promise.resolve()).then(async()=>{await x,c.issues.length!==y&&(pv(c.issues,y,e),m||(m=$a(c,y)))});else{if(c.issues.length===y)continue;pv(c.issues,y,e),m||(m=$a(c,y))}}return g?g.then(()=>c):c},u=(c,f,p)=>{if($a(c))return c.aborted=!0,c;const m=l(f,o,p);if(m instanceof Promise){if(p.async===!1)throw new za;return m.then(g=>e._zod.parse(g,p))}return e._zod.parse(m,p)};e._zod.run=(c,f)=>{if(f.skipChecks)return e._zod.parse(c,f);if(f.direction==="backward"){const m=e._zod.parse({value:c.value,issues:[]},{...f,skipChecks:!0});return m instanceof Promise?m.then(g=>u(g,c,f)):u(m,c,f)}const p=e._zod.parse(c,f);if(p instanceof Promise){if(f.async===!1)throw new za;return p.then(m=>l(m,o,f))}return l(p,o,f)}}},{get"~standard"(){return zx(this,"~standard",Gx(this))},set"~standard"(e){qa(this,"~standard",e)}}),yv=e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}};function Gx(e){return{validate:t=>{try{return yv(FC(e,t))}catch{return BC(e,t).then(yv)}},vendor:"zod",version:1}}const kg=ve("$ZodString",(e,t)=>{var n;zn.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??yA(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}}),Fn=ve("$ZodStringFormat",(e,t)=>{cf.init(e,t),kg.init(e,t)}),zA=ve("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=oA),Fn.init(e,t)}),FA=ve("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=wv(r))}else t.pattern??(t.pattern=wv());Fn.init(e,t)}),BA=ve("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=sA),Fn.init(e,t)}),Vx=1,Yx=2;function UA(e,t){var n;if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===hA.source&&!/^https?:\/\//i.test(e))return Vx;try{return new URL(e)}catch{return Yx}}const HA=/[\t\n\r]/g;function KA(e){return e.replace(HA,"")}function WA(e,t){return t.lastIndex=0,t.test(e.hostname)}function ZA(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const qA=ve("$ZodURL",(e,t)=>{Fn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=UA(r,t);if(o===Vx){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===Yx){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!WA(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&&!ZA(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:KA(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),GA=ve("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=aA()),Fn.init(e,t)}),VA=ve("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?tA:nA(t.length)),Fn.init(e,t)}),YA=ve("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=YC),Fn.init(e,t)}),XA=ve("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=XC),Fn.init(e,t)}),QA=ve("$ZodULID",(e,t)=>{t.pattern??(t.pattern=QC),Fn.init(e,t)}),JA=ve("$ZodXID",(e,t)=>{t.pattern??(t.pattern=JC),Fn.init(e,t)}),eI=ve("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=eA),Fn.init(e,t)}),tI=ve("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=wA(t)),Fn.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(n=>{n._zod.bag.laxFormat=!0}))}),nI=ve("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=gA),Fn.init(e,t)}),rI=ve("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=kA(t)),Fn.init(e,t)}),oI=ve("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=rA),Fn.init(e,t)}),sI=ve("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=lA),Fn.init(e,t),e._zod.bag.format="ipv4"}),iI=/^[0-9a-fA-F:.]+$/;function Xx(e){if(!iI.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}const aI=ve("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=cA),Fn.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{Xx(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),lI=ve("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=uA),Fn.init(e,t)});function cI(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:Xx(n)}const uI=ve("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=dA),Fn.init(e,t),e._zod.check=n=>{cI(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Qx(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const dI=ve("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=fA),Fn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Qx(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function fI(e){if(!Kx.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Qx(n)}const hI=ve("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Kx),Fn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{fI(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),pI=ve("$ZodE164",(e,t)=>{t.pattern??(t.pattern=pA),Fn.init(e,t)});function mI(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 gI=ve("$ZodJWT",(e,t)=>{Fn.init(e,t),e._zod.check=n=>{mI(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Jx=ve("$ZodNumber",(e,t)=>{zn.init(e,t),e._zod.pattern=e._zod.bag.pattern??bA,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}}),kI=ve("$ZodNumberFormat",(e,t)=>{NA.init(e,t),Jx.init(e,t)}),wI=ve("$ZodBoolean",(e,t)=>{zn.init(e,t),e._zod.pattern=xA,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}}),yI=ve("$ZodUnknown",(e,t)=>{zn.init(e,t),e._zod.parse=n=>n}),vI=ve("$ZodNever",(e,t)=>{zn.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function vv(e,t,n){e.issues.length&&t.issues.push(...of(n,e.issues)),t.value[n]=e.value}const bI=ve("$ZodArray",(e,t)=>{zn.init(e,t);const n=Zo.memoizer;n==null||n.attach(e),e._zod.parse=(r,o)=>{const i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=n?n.alloc(e,r,Array(i.length),o):Array(i.length);const l=[];for(let u=0;u<i.length;u++){const c=i[u],f=t.element._zod.run({value:c,issues:[]},o);f instanceof Promise?l.push(f.then(p=>vv(p,r,u))):vv(f,r,u)}return l.length?Promise.all(l).then(()=>r):r}});function Sd(e,t,n,r,o,i){const l=n in r,u=i==="optional";if(!(!l&&u&&o==="optional")){if(e.issues.length){if(o!==void 0&&u&&!l)return;t.issues.push(...of(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 xI=[];function e1(e){var l,u,c,f;const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:xI,o=r.length?[...t,...r]:t;for(const p of o)if(!((f=(c=(u=(l=e.shape)==null?void 0:l[p])==null?void 0:u._zod)==null?void 0:c.traits)!=null&&f.has("$ZodType")))throw new Error(`Invalid element at key "${String(p)}": expected a Zod schema`);const i=mC(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function t1(e,t,n,r,o,i){const l=[],u=o.keySet,c=o.catchall._zod,f=c.def.type,p=c.optin,m=c.optout;for(const g in t){if(u.has(g))continue;if(g==="__proto__"){f==="never"&&l.push(g);continue}if(f==="never"){l.push(g);continue}const w=c.run({value:t[g],issues:[]},r);w instanceof Promise?e.push(w.then(y=>Sd(y,n,g,t,p,m))):Sd(w,n,g,t,p,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 lm=new WeakMap,EI=ve("$ZodObject",(e,t)=>{zn.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const c=t.shape;lm.set(t,c),Object.defineProperty(t,"shape",{get:()=>{const f={...c};return Object.defineProperty(t,"shape",{value:f}),lm.set(t,f),f}})}const r=rf(()=>e1(t));vn(e,"propValues",c=>{const f=c.def.shape,p={};for(const m in f){const g=f[m]._zod;if(g.values){Object.prototype.hasOwnProperty.call(p,m)||no(p,m,new Set);for(const w of g.values)p[m].add(w);g.optin!==void 0&&p[m].add(void 0)}}return p});const o=uc,i=t.catchall;let l;const u=Zo.memoizer;u==null||u.attach(e),e._zod.parse=(c,f)=>{l??(l=r.value);const p=c.value;if(!o(p))return c.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),c;c.value=u?u.alloc(e,c,{},f):{};const m=[],g=l.shape;for(const w of l.allKeys){if(w==="__proto__")continue;const y=g[w],x=y._zod.optin,b=y._zod.optout,j=y._zod.run({value:p[w],issues:[]},f);j instanceof Promise?m.push(j.then(N=>Sd(N,c,w,p,x,b))):Sd(j,c,w,p,x,b)}return i?t1(m,p,c,f,r.value,e):m.length?Promise.all(m).then(()=>c):c}}),_I=ve("$ZodObjectJIT",(e,t)=>{EI.init(e,t);const n=e._zod.parse,r=rf(()=>e1(t)),o=Zo.memoizer,i=w=>{var $,W;const y=r.value,x=y.symbolKeys,b=new PA(["payload","ctx"],{shape:w,inst:e,memo:o,syms:x}),j=A=>`shape[${A}]._zod.run({ value: input[${A}], issues: [] }, ctx)`,N=(A,I)=>`
|
|
47
|
+
for (let i = 0; i < ${A}.issues.length; i++) {
|
|
48
|
+
const iss = ${A}.issues[i];
|
|
49
|
+
iss.path = iss.path ? [${I}, ...iss.path] : [${I}];
|
|
50
|
+
payload.issues.push(iss);
|
|
51
|
+
}`;b.write("const input = payload.value;");const T=Object.create(null);let R=0;for(const A of y.allKeys)T[A]=`key_${R++}`;b.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const A of y.allKeys){if(A==="__proto__")continue;const I=T[A],_=typeof A=="symbol"?`syms[${x.indexOf(A)}]`:dC(A),P=`${_} in input`,z=w[A],q=($=z==null?void 0:z._zod)==null?void 0:$.optin,se=q!==void 0,Y=((W=z==null?void 0:z._zod)==null?void 0:W.optout)==="optional";if(b.write(`const ${I} = ${j(_)};`),se&&Y){const ge=q==="optional"?`${I}_present`:`${I}.value !== undefined || ${I}_present`;b.write(`
|
|
52
|
+
const ${I}_present = ${P};
|
|
53
|
+
if (!${I}.issues.length || ${I}_present) {
|
|
54
|
+
if (${I}.issues.length) {${N(I,_)}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (${ge}) {
|
|
58
|
+
newResult[${_}] = ${I}.value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
`)}else se?b.write(`
|
|
63
|
+
if (${I}.issues.length) {${N(I,_)}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (${I}.value === undefined) {
|
|
67
|
+
if (${P}) {
|
|
68
|
+
newResult[${_}] = undefined;
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
newResult[${_}] = ${I}.value;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
`):b.write(`
|
|
75
|
+
const ${I}_present = ${P};
|
|
76
|
+
if (${I}.issues.length) {${N(I,_)}
|
|
77
|
+
}
|
|
78
|
+
if (!${I}_present && !${I}.issues.length) {
|
|
79
|
+
payload.issues.push({
|
|
80
|
+
code: "invalid_type",
|
|
81
|
+
expected: "nonoptional",
|
|
82
|
+
input: undefined,
|
|
83
|
+
path: [${_}]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (${I}_present) {
|
|
88
|
+
newResult[${_}] = ${I}.value;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
`)}return b.write("payload.value = newResult;"),b.write("return payload;"),b.compile()};let l;const u=uc,c=!Zo.jitless,p=c&&hC.value,m=t.catchall;let g;e._zod.parse=(w,y)=>{g??(g=r.value);const x=w.value;return u(x)?c&&p&&(y==null?void 0:y.async)===!1&&y.jitless!==!0?(l||(l=i(t.shape)),w=l(w,y),m?t1([],x,w,y,g,e):w):n(w,y):(w.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),w)}});function bv(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=>!$a(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=>nl(l,r,li())))}),t)}const n1=ve("$ZodUnion",(e,t)=>{zn.init(e,t),vn(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),vn(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),vn(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)))}),vn(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=>dg(i.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const l=[];for(const u of t.options){const c=u._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)l.push(c),i=!0;else{if(c.issues.length===0)return c;l.push(c)}}return i?Promise.all(l).then(u=>bv(u,r,e,o)):bv(l,r,e,o)}}),SI=ve("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,n1.init(e,t);const n=e._zod.parse;vn(e,"propValues",o=>{const i={};for(const l of o.def.options){const u=l._zod.propValues;if(!u||Object.keys(u).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(l)}"`);for(const[c,f]of Object.entries(u)){Object.prototype.hasOwnProperty.call(i,c)||no(i,c,new Set);for(const p of f)i[c].add(p)}}return i}),t.options.forEach((o,i)=>{const l=lm.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=rf(()=>{var l;const o=t.options,i=new Map;for(const u of o){const c=(l=u._zod.propValues)==null?void 0:l[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(u)}"`);for(const f of c){if(i.has(f))throw new Error(`Duplicate discriminator value "${String(f)}"`);i.set(f,u)}}return i});e._zod.parse=(o,i)=>{const l=o.value;if(!uc(l))return o.issues.push({code:"invalid_type",expected:"object",input:l,inst:e}),o;const u=r.value.get(l==null?void 0:l[t.discriminator]);return u?u._zod.run(o,i):t.unionFallback||i.direction==="backward"?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:l,path:[t.discriminator],inst:e}),o)}}),NI=ve("$ZodIntersection",(e,t)=>{zn.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),l=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||l instanceof Promise?Promise.all([i,l]).then(([c,f])=>xv(n,c,f)):xv(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(dc(e)&&dc(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 xv(e,t,n){const r=new Map;let o;const i=new Map,l=(f,p)=>{var g,w;let m;if(f.code==="unrecognized_keys"&&!((g=f.path)!=null&&g.length))o??(o=f),m=f.keys;else if(f.code==="invalid_key"&&f.origin==="record"&&((w=f.path)==null?void 0:w.length)===1){const y=String(f.path[0]);i.has(y)||i.set(y,f),m=[y]}else return!1;for(const y of m)r.has(y)||r.set(y,{}),r.get(y)[p]=!0;return!0};for(const f of t.issues)l(f,"l")||e.issues.push(f);for(const f of n.issues)l(f,"r")||e.issues.push(f);const u=[...r].filter(([,f])=>f.l&&f.r).map(([f])=>f);if(u.length){const f=o?u.filter(p=>o.keys.includes(p)):[];f.length&&e.issues.push({...o,keys:f});for(const p of u)!f.includes(p)&&i.has(p)&&e.issues.push(i.get(p))}const c=cm(t.value,n.value);if(!c.valid){if($a(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const TI=ve("$ZodTuple",(e,t)=>{zn.init(e,t);const n=t.items,r=Zo.memoizer;r==null||r.attach(e),e._zod.parse=(o,i)=>{const l=o.value;if(!Array.isArray(l))return o.issues.push({input:l,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=r?r.alloc(e,o,[],i):[];const u=[],c=Ev(n,"optin"),f=Ev(n,"optout");if(!t.rest){if(l.length<c)return o.issues.push({code:"too_small",minimum:c,inclusive:!0,input:l,inst:e,origin:"array"}),o;l.length>n.length&&o.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:l,inst:e,origin:"array"})}const p=new Array(n.length);for(let m=0;m<n.length;m++){const g=n[m]._zod.run({value:l[m],issues:[]},i);g instanceof Promise?u.push(g.then(w=>{p[m]=w})):p[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?u.push(y.then(x=>_v(x,o,m))):_v(y,o,m)}}return u.length?Promise.all(u).then(()=>Sv(p,o,n,l,f)):Sv(p,o,n,l,f)}});function Ev(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function _v(e,t,n){e.issues.length&&t.issues.push(...of(n,e.issues)),t.value[n]=e.value}function Sv(e,t,n,r,o){for(let i=0;i<n.length;i++){const l=e[i],u=i<r.length;if(!u&&i>=o&&n[i]._zod.optin==="optional"){t.value.length=i;break}if(l.issues.length){if(!u&&i>=o){t.value.length=i;break}t.issues.push(...of(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 jI=ve("$ZodEnum",(e,t)=>{zn.init(e,t);const n=Mx(t.entries),r=new Set(n);e._zod.values=r;const o=n.filter(i=>pC.has(typeof i));e._zod.pattern=new RegExp(o.length?`^(${o.map(i=>Za(i.toString())).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(i,l)=>{const u=i.value;return r.has(u)||i.issues.push({code:"invalid_value",values:n,input:u,inst:e}),i}}),CI=ve("$ZodLiteral",(e,t)=>{zn.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"?Za(r):r?Za(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}}),AI=ve("$ZodTransform",(e,t)=>{var n;zn.init(e,t),e._zod.optin="optional",(n=Zo.memoizer)==null||n.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new Fx(e.constructor.name);const i=t.transform(r.value,r);if(o.async)return(i instanceof Promise?i:Promise.resolve(i)).then(u=>(r.value=u,r));if(i instanceof Promise)throw new za;return r.value=i,r}});function Nv(e,t){return e.value=t.issues.length?void 0:t.value,e}const r1=ve("$ZodOptional",(e,t)=>{zn.init(e,t),vn(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",vn(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),vn(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${dg(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=>Nv(n,i)):Nv(n,o)}return t.innerType._zod.run(n,r)}}),II=ve("$ZodExactOptional",(e,t)=>{r1.init(e,t),vn(e,"values",n=>n.def.innerType._zod.values),vn(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),RI=ve("$ZodNullable",(e,t)=>{zn.init(e,t),vn(e,"optin",n=>n.def.innerType._zod.optin),vn(e,"optout",n=>n.def.innerType._zod.optout),vn(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${dg(r.source)}|null)$`):void 0}),vn(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)}),$I=ve("$ZodDefault",(e,t)=>{zn.init(e,t),e._zod.optin="defaulted",vn(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=>Tv(i,t)):Tv(o,t)}});function Tv(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const OI=ve("$ZodPrefault",(e,t)=>{zn.init(e,t),e._zod.optin="defaulted",vn(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))}),MI=ve("$ZodNonOptional",(e,t)=>{zn.init(e,t),vn(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=>jv(i,e)):jv(o,e)}});function jv(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 Cv(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>nl(o,r,li()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const LI=ve("$ZodCatch",(e,t)=>{zn.init(e,t),vn(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),vn(e,"optout",n=>n.def.innerType._zod.optout),vn(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=>Cv(n,i,t,r)):Cv(n,o,t,r)}}),PI=ve("$ZodPipe",(e,t)=>{zn.init(e,t),vn(e,"values",n=>n.def.in._zod.values),vn(e,"optin",n=>n.def.in._zod.optin),vn(e,"optout",n=>n.def.out._zod.optout),vn(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=>Zu(l,t.in,r)):Zu(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>Zu(i,t.out,r)):Zu(o,t.out,r)}});function Zu(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 DI=ve("$ZodReadonly",(e,t)=>{zn.init(e,t),vn(e,"propValues",n=>n.def.innerType._zod.propValues),vn(e,"values",n=>n.def.innerType._zod.values),vn(e,"optin",n=>{var r,o;return(o=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:o.optin}),vn(e,"optout",n=>{var r,o;return(o=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:o.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Av):Av(o)}});function Av(e){return e.memo||(e.value=Object.freeze(e.value)),e}const zI=ve("$ZodCustom",(e,t)=>{ro.init(e,t),zn.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=>Iv(i,n,r,e));Iv(o,n,r,e)}});function Iv(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(fc(o))}}class FI extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const um="~memo",Rv=[];function vp(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const $v=new WeakMap;function o1(e,t){const n=$v.get(e);if(n!==void 0)return n;if(t.has(e))return!0;t.add(e);let r=!1;const o=u=>{!r&&(u!=null&&u._zod)&&o1(u,t)&&(r=!0)},i=e._zod.def;switch(i.type){case"object":{for(const u of Reflect.ownKeys(i.shape))o(i.shape[u]);o(i.catchall);break}case"array":o(i.element);break;case"tuple":for(const u of i.items)o(u);o(i.rest);break;case"record":case"map":o(i.keyType),o(i.valueType);break;case"set":o(i.valueType);break;case"union":for(const u of i.options)o(u);break;case"intersection":o(i.left),o(i.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(i.innerType);break;case"pipe":o(i.in),o(i.out);break;case"function":o(i.input),o(i.output);break;case"lazy":o(e._zod.innerType);break;case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const u in i){const c=Object.getOwnPropertyDescriptor(i,u);if(!c||c.get)continue;const f=c.value;if(!(!f||typeof f!="object")){if(f._zod)o(f);else if(Array.isArray(f))for(const p of f)o(p)}}}return t.delete(e),$v.set(e,r),r}function BI(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}let qu;const Gu=[],UI={alloc(e,t,n){const r=qu;if(!r)return n;qu=void 0;const o={value:n,issues:null};return r.set(t.value,o),Gu.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"&&KI(i,o.value))throw new FI;return n(o,i)};e._zod.parse=r,e._zod.run===n&&(e._zod.run=r)})},attach(e){var t;let n,r,o;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const i=e._zod.parse,l=(u,c)=>{if(n===void 0&&(n=o1(e,new Set),!n))return e._zod.parse=i,e._zod.run===l&&(e._zod.run=i),i(u,c);const f=u.value;if(f===null||typeof f!="object")return i(u,c);let p=c[um];p||(p={buckets:new Map,backEdges:void 0},c[um]=p);let m;r===c?m=o:(m=BI(p,e),r=c,o=m);const g=m.get(f);if(g)return u.value=g.value,g.issues?g.issues.length&&u.issues.push(...vp(g.issues)):(u.memo=!0,p.backEdges??(p.backEdges=new Set),p.backEdges.add(g.value)),u;qu=m;const w=Gu.length,y=i(u,c);qu=void 0;const x=Gu.length>w?Gu.pop():void 0;return y instanceof Promise?y.then(b=>(x&&(x.issues=b.issues.length?vp(b.issues):Rv),b)):(x&&(x.issues=y.issues.length?vp(y.issues):Rv),y)};e._zod.parse=l,e._zod.run===i&&(e._zod.run=l)})}};function HI(){return UI}function KI(e,t){var r;const n=(r=e[um])==null?void 0:r.backEdges;return n!==void 0&&t!==null&&typeof t=="object"&&n.has(t)}const WI=()=>{const e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(i){return e[i]??null}const n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",credit_card:"credit card number",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(i,l){return i==="number"&&typeof l=="number"&&!Number.isFinite(l)?String(l):r[i]??i}return i=>{switch(i.code){case"invalid_type":{const l=o(i.expected),u=SC(i.input),c=o(u,i.input);return`Invalid input: expected ${l}, received ${c}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${Dx(i.values[0])}`:`Invalid option: expected one of ${fv(i.values,"|")}`;case"too_big":{const l=i.exact?"exactly ":i.inclusive?"<=":"<",u=t(i.origin);return u?`Too big: expected ${i.origin??"value"} to have ${l}${i.maximum.toString()} ${u.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${l}${i.maximum.toString()}`}case"too_small":{const l=i.exact?"exactly ":i.inclusive?">=":">",u=t(i.origin);return u?`Too small: expected ${i.origin} to have ${l}${i.minimum.toString()} ${u.unit}`:`Too small: expected ${i.origin} to be ${l}${i.minimum.toString()}`}case"invalid_format":{const l=i;return l.format==="starts_with"?`Invalid string: must start with "${l.prefix}"`:l.format==="ends_with"?`Invalid string: must end with "${l.suffix}"`:l.format==="includes"?`Invalid string: must include "${l.includes}"`:l.format==="regex"?`Invalid string: must match pattern ${l.pattern}`:`Invalid ${n[l.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${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(u=>`'${u}'`).join(" | ")}`:i.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function ZI(){return{localeError:WI()}}var Ov;class qI{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 GI(){return new qI}(Ov=globalThis).__zod_globalRegistry??(Ov.__zod_globalRegistry=GI());const Zl=globalThis.__zod_globalRegistry;function VI(e,t){return new e({type:"string",...it(t)})}function YI(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...it(t)})}function XI(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...it(t)})}function QI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...it(t)})}function JI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...it(t)})}function eR(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...it(t)})}function tR(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...it(t)})}function nR(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...it(t)})}function rR(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...it(t)})}function oR(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...it(t)})}function sR(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...it(t)})}function iR(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...it(t)})}function aR(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...it(t)})}function lR(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...it(t)})}function cR(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...it(t)})}function uR(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...it(t)})}function dR(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...it(t)})}function fR(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...it(t)})}function hR(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...it(t)})}function pR(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...it(t)})}function mR(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...it(t)})}function gR(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...it(t)})}function kR(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...it(t)})}function wR(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...it(t)})}function yR(e,t){return new e({type:"string",format:"date",check:"string_format",...it(t)})}function vR(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...it(t)})}function bR(e,t){return new e({type:"string",format:"duration",check:"string_format",...it(t)})}function xR(e,t){return new e({type:"number",checks:[],...it(t)})}function ER(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...it(t)})}function _R(e,t){return new e({type:"boolean",...it(t)})}function SR(e){return new e({type:"unknown"})}function NR(e,t){return new e({type:"never",...it(t)})}function Mv(e,t){return new Zx({check:"less_than",...it(t),value:e,inclusive:!1})}function bp(e,t){return new Zx({check:"less_than",...it(t),value:e,inclusive:!0})}function Lv(e,t){return new qx({check:"greater_than",...it(t),value:e,inclusive:!1})}function xp(e,t){return new qx({check:"greater_than",...it(t),value:e,inclusive:!0})}function Pv(e,t){return new SA({check:"multiple_of",...it(t),value:e})}function s1(e,t){return new TA({check:"max_length",...it(t),maximum:e})}function Nd(e,t){return new jA({check:"min_length",...it(t),minimum:e})}function i1(e,t){return new CA({check:"length_equals",...it(t),length:e})}function TR(e,t){return new AA({check:"string_format",format:"regex",...it(t),pattern:e})}function jR(e){return new IA({check:"string_format",format:"lowercase",...it(e)})}function CR(e){return new RA({check:"string_format",format:"uppercase",...it(e)})}function AR(e,t){return new $A({check:"string_format",format:"includes",...it(t),includes:e})}function IR(e,t){return new OA({check:"string_format",format:"starts_with",...it(t),prefix:e})}function RR(e,t){return new MA({check:"string_format",format:"ends_with",...it(t),suffix:e})}function rl(e){return new LA({check:"overwrite",tx:e})}function $R(e){return rl(t=>t.normalize(e))}function OR(){return rl(e=>e.trim())}function MR(){return rl(e=>e.toLowerCase())}function LR(){return rl(e=>e.toUpperCase())}function PR(){return rl(e=>fC(e))}function DR(e,t,n){return new e({type:"array",element:t,...it(n)})}function zR(e,t,n){return new e({type:"custom",check:"custom",fn:t,...it(n)})}function FR(e,t){const n=BR(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(fc(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(fc(i))}},e(r.value,r)),t);return n}function BR(e,t){const n=new ro({check:"custom",...it(t)});return n._zod.check=e,n}function ec(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&no(e,r,n[r]);return e}function a1(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)??Zl,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 ri(e,t,n,r,o){const i=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:o}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw new Error(o);return Object.assign(n,i),!0}function lr(e,t,n={path:[],schemaPath:[]}){var p,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 u=(m=(p=e._zod).toJSONSchema)==null?void 0:m.call(p);if(u)l.schema=u;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,x=t.processors[o.type];if(!x)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);x(e,t,y,g)}const w=e._zod.parent;w&&(l.ref||(l.ref=w),lr(w,t,g),t.seen.get(w).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&ec(l.schema,c),t.io==="input"&&Br(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 Dv(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function l1(e,t){var l,u,c,f;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const r=new Map;for(const p of e.seen.entries()){const m=(l=e.metadataRegistry.get(p[0]))==null?void 0:l.id;if(m){const g=r.get(m);if(g&&g!==p[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,p[0])}}const o=p=>{var x;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const b=(x=e.external.registry.get(p[0]))==null?void 0:x.id,j=e.external.uri??(T=>T);if(b)return{ref:j(b)};const N=p[1].defId??p[1].schema.id??`schema${e.counter++}`;return p[1].defId=N,{defId:N,ref:`${j("__shared")}#/${m}/${Dv(N)}`}}const g="#",w=`${g}/${m}/`;if(p[1]===n&&!p[1].schema.id)return{ref:g};const y=p[1].schema.id??`__schema${e.counter++}`;return{defId:y,ref:w+Dv(y)}},i=p=>{if(p[1].schema.$ref)return;const m=p[1],{ref:g,defId:w}=o(p);m.def={...m.schema},w&&(m.defId=w);const y=m.schema;for(const x in y)delete y[x];y.$ref=g};if(e.cycles==="throw")for(const p of e.seen.entries()){const m=p[1];if(m.cycle)throw new Error(`Cycle detected: #/${(u=m.cycle)==null?void 0:u.join("/")}/<root>
|
|
92
|
+
|
|
93
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const p of e.seen.entries()){const m=p[1];if(t===p[0]){i(p);continue}if(e.external){const w=(c=e.external.registry.get(p[0]))==null?void 0:c.id;if(t!==p[0]&&w){i(p);continue}}if((f=e.metadataRegistry.get(p[0]))==null?void 0:f.id){i(p);continue}if(m.cycle){i(p);continue}if(m.count>1&&e.reused==="ref"){i(p);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function c1(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;c1(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 u1=new Set(["type","properties","required","additionalProperties"]),zv=["oneOf","anyOf"];function Fv(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function dm(e){var i;const t=[];for(const l of e){if(typeof l!="object"||l.type!=="object")return null;for(const u in l)if(!u1.has(u))return null;t.push(l)}const n={},r=new Set;for(const l of t){for(const u in l.properties){if(Object.prototype.hasOwnProperty.call(n,u))continue;const c=[];for(const p of t){const m=((i=p.properties)==null?void 0:i[u])??Fv(p);m!=null&&(c.some(g=>JSON.stringify(g)===JSON.stringify(m))||c.push(m))}const f=c.length===1?c[0]:dm(c)??{allOf:c};no(n,u,f)}for(const u of l.required??[])r.add(u)}const o={type:"object",properties:n};if(r.size&&(o.required=[...r]),t.every(l=>l.additionalProperties===!1))o.additionalProperties=!1;else{const l=[];for(const u of t){const c=Fv(u);c&&!l.some(f=>JSON.stringify(f)===JSON.stringify(c))&&l.push(c)}l.length===1?o.additionalProperties=l[0]:l.length>1&&(o.additionalProperties={allOf:l})}return o}function UR(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const o of u1)if(o in e)return;const n=t.filter(o=>zv.some(i=>Array.isArray(o[i])));let r=null;if(!n.length)r=dm(t);else{const o=n[0],i=zv.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;const l=t.filter(c=>c!==o),u=o[i].map(c=>dm([...l,c]));if(u.some(c=>!c))return;r={[i]:u}}r&&(delete e.allOf,ec(e,r))}function d1(e,t){var u,c,f,p;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},x=g.ref;if(g.ref=null,x){r(x);const j=e.seen.get(x),N=j.schema;if(N.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(w.allOf=w.allOf??[],w.allOf.push(N)):ec(w,N),ec(w,y),m._zod.parent===x)for(const R in w)R==="$ref"||R==="allOf"||R in y||delete w[R];if(N.$ref&&j.def)for(const R in w)R==="$ref"||R==="allOf"||R in j.def&&JSON.stringify(w[R])===JSON.stringify(j.def[R])&&delete w[R]}const b=m._zod.parent;if(b&&b!==x){r(b);const j=e.seen.get(b);if(j!=null&&j.schema.$ref&&(w.$ref=j.schema.$ref,j.def))for(const N in w)N==="$ref"||N==="allOf"||N in j.def&&JSON.stringify(w[N])===JSON.stringify(j.def[N])&&delete w[N]}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())c1(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 x=m.get(y);x?x.push(w):m.set(y,[w])}for(const g of e.intersections)for(const w of m.get(g)??[])UR(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,(u=e.external)!=null&&u.uri){const m=(c=e.external.registry.get(t))==null?void 0:c.id;if(!m)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(m)}ec(o,n.defId?n.schema:n.def??n.schema);const i=(f=e.metadataRegistry.get(t))==null?void 0:f.id;i!==void 0&&o.id===i&&delete o.id;const l=((p=e.external)==null?void 0:p.defs)??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const m of e.seen.entries()){const g=m[1];g.def&&g.defId&&(g.def.id===g.defId&&delete g.def.id,no(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:Td(t,"input",e.processors),output:Td(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function Br(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 Br(r.element,n);if(r.type==="set")return Br(r.valueType,n);if(r.type==="lazy")return Br(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 Br(r.innerType,n);if(r.type==="intersection")return Br(r.left,n)||Br(r.right,n);if(r.type==="record"||r.type==="map")return Br(r.keyType,n)||Br(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Br(r.in,n)||Br(r.out,n);if(r.type==="object"){for(const o in r.shape)if(Br(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(Br(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(Br(o,n))return!0;return!!(r.rest&&Br(r.rest,n))}return!1}const HR=(e,t={})=>n=>{const r=a1({...n,processors:t});return lr(e,r),l1(r,e),d1(r,e)},Td=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},l=a1({...o??{},target:i,io:t,processors:n});return lr(e,l),l1(l,e),d1(l,e)},KR={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},WR=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:l,format:u,patterns:c,contentEncoding:f,laxFormat:p}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof l=="number"&&(o.maxLength=l),u&&(o.format=KR[u]??u,o.format===""&&delete o.format,(u==="time"||p)&&delete o.format),f&&(o.contentEncoding=f),c&&c.size>0){const m=[...c];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}))])}},ZR=(e,t,n,r)=>{const o=n,{minimum:i,maximum:l,format:u,multipleOf:c,exclusiveMaximum:f,exclusiveMinimum:p}=e._zod.bag;typeof u=="string"&&u.includes("int")?o.type="integer":o.type="number";const m=typeof p=="number"&&p>=(i??Number.NEGATIVE_INFINITY),g=typeof f=="number"&&f<=(l??Number.POSITIVE_INFINITY),w=t.target==="draft-04"||t.target==="openapi-3.0";m?w?(o.minimum=p,o.exclusiveMinimum=!0):o.exclusiveMinimum=p:typeof i=="number"&&(o.minimum=i),g?w?(o.maximum=f,o.exclusiveMaximum=!0):o.exclusiveMaximum=f:typeof l=="number"&&(o.maximum=l),typeof c=="number"&&(Number.isFinite(c)&&c!==0?o.multipleOf=Math.abs(c):ri(e,t,o,r,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},qR=(e,t,n,r)=>{n.type="boolean"},GR=(e,t,n,r)=>{n.not={}},VR=(e,t,n,r)=>{},YR=(e,t,n,r)=>{const o=e._zod.def,i=Mx(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},XR=(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(ri(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof l=="bigint"){if(ri(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},QR=(e,t,n,r)=>{ri(e,t,n,r,"Custom types cannot be represented in JSON Schema")},JR=(e,t,n,r)=>{ri(e,t,n,r,"Transforms cannot be represented in JSON Schema")},e$=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:l,maximum:u}=e._zod.bag;typeof l=="number"&&(o.minItems=l),typeof u=="number"&&(o.maxItems=u),o.type="array",o.items=lr(i.element,t,{...r,path:[...r.path,"items"]})};function jd(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?jd(t.out):t.type==="catch"?jd(t.innerType):e._zod.optin}const t$=(e,t,n,r)=>{var p;const o=n,i=e._zod.def,l=i.shape;if(Object.getOwnPropertySymbols(l).length&&ri(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const m in l)no(o.properties,m,lr(l[m],t,{...r,path:[...r.path,"properties",m]}));const c=new Set(Object.keys(l)),f=new Set([...c].filter(m=>{const g=i.shape[m];return t.io==="input"?jd(g)===void 0:g._zod.optout===void 0}));f.size>0&&(o.required=Array.from(f)),((p=i.catchall)==null?void 0:p._zod.def.type)==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=lr(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},n$=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,l=o.options.map((u,c)=>lr(u,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=l:n.anyOf=l},r$=(e,t,n,r)=>{const o=e._zod.def,i=lr(o.left,t,{...r,path:[...r.path,"allOf",0]}),l=lr(o.right,t,{...r,path:[...r.path,"allOf",1]}),u=f=>"allOf"in f&&Object.keys(f).length===1,c=[...u(i)?i.allOf:[i],...u(l)?l.allOf:[l]];n.allOf=c,t.intersections.push(c)},o$=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="array";const l=t.target==="draft-2020-12"?"prefixItems":"items",u=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((x,b)=>lr(x,t,{...r,path:[...r.path,l,b]})),f=i.rest?lr(i.rest,t,{...r,path:[...r.path,u,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;let p=i.items.length;for(;p>0;){const x=i.items[p-1];if(!(t.io==="input"?jd(x)!==void 0:x._zod.optout==="optional"))break;p--}const m=i.items.length,g=!i.rest;t.target==="draft-2020-12"?(o.prefixItems=c,g?o.items=!1:f&&(o.items=f),p>0&&(o.minItems=p),g&&(o.maxItems=m)):t.target==="openapi-3.0"?(o.items={anyOf:c},f&&o.items.anyOf.push(f),p>0&&(o.minItems=p),g&&(o.maxItems=m)):(o.items=c,g?o.additionalItems=!1:f&&(o.additionalItems=f),p>0&&(o.minItems=p),g&&(o.maxItems=m));const{minimum:w,maximum:y}=e._zod.bag;typeof w=="number"&&(o.minItems=w),typeof y=="number"&&(o.maxItems=y)},s$=(e,t,n,r)=>{const o=e._zod.def,i=lr(o.innerType,t,r),l=t.seen.get(e);t.target==="openapi-3.0"?(l.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},i$=(e,t,n,r)=>{const o=e._zod.def;lr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},wg=Symbol();function f1(e,t,n,r,o){let i=!1;const l=JSON.stringify(e,(u,c)=>typeof c!="bigint"?c:(i=!0,null));return i?(ri(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),wg):JSON.parse(l)}const a$=(e,t,n,r)=>{const o=e._zod.def;lr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;const l=f1(o.defaultValue,e,t,n,r);l!==wg&&(n.default=l)},l$=(e,t,n,r)=>{const o=e._zod.def;lr(o.innerType,t,r);const i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;const l=f1(o.defaultValue,e,t,n,r);l!==wg&&(n._prefault=l)},c$=(e,t,n,r)=>{const o=e._zod.def;lr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let l;try{l=o.catchValue(void 0)}catch{ri(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=l},u$=(e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),l=t.io==="input"?i?o.out:o.in:o.out;lr(l,t,r);const u=t.seen.get(e);u.ref=l},d$=(e,t,n,r)=>{const o=e._zod.def;lr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},h1=(e,t,n,r)=>{const o=e._zod.def;lr(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Bv=new WeakSet([Object.prototype,Error.prototype]);function Vu(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 f$=(e,t)=>{Ux.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);Bv.has(n)||(Bv.add(n),Vu(n,"format",r=>o=>zC(r,o)),Vu(n,"flatten",r=>o=>DC(r,o)),Vu(n,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,im,2)}),Vu(n,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,im,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},No=ve("ZodError",f$,void 0,{Parent:Error}),h$=pg(No),p$=mg(No),m$=af(No),g$=lf(No),k$=UC(No),w$=HC(No),y$=KC(No),v$=WC(No),b$=ZC(No),x$=qC(No),E$=GC(No),_$=VC(No);function S$(){Zo.localeError||li(ZI())}function uf(){Zo.memoizer||li({memoizer:HI()})}const Kn=ve("ZodType",(e,t)=>(S$(),zn.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(ii(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 ai(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(EO(e,t))},superRefine(e,t){return this.check(_O(e,t))},overwrite(e){return this.check(rl(e))},optional(){return Kv(this)},exactOptional(){return dO(this)},nullable(){return Wv(this)},nullish(){return Kv(Wv(this))},nonoptional(e){return kO(this,e)},array(){return Mi(this)},or(e){return nO([this,e])},and(e){return iO(this,e)},transform(e){return Zv(this,uO(e))},default(e){return pO(this,e)},prefault(e){return gO(this,e)},catch(e){return yO(this,e)},pipe(e){return Zv(this,e)},readonly(){return xO(this)},describe(e){const t=this.clone();return Zl.add(t,{description:e}),t},meta(...e){if(e.length===0)return Zl.get(this);const t=this.clone();return Zl.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 zx(this,"~standard",{...Gx(this),jsonSchema:{input:Td(this,"input"),output:Td(this,"output")}})},set"~standard"(e){qa(this,"~standard",e)},parse:function e(t,n){return h$(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await p$(this,t,n,{callee:e})},safeParse(e,t){return m$(this,e,t)},async safeParseAsync(e,t){return g$(this,e,t)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(e){qa(this,"spa",e)},encode:function e(t,n){return k$(this,t,n,{callee:e})},decode:function e(t,n){return w$(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await y$(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await v$(this,t,n,{callee:e})},safeEncode(e,t){return b$(this,e,t)},safeDecode(e,t){return x$(this,e,t)},async safeEncodeAsync(e,t){return E$(this,e,t)},async safeDecodeAsync(e,t){return _$(this,e,t)},toJSONSchema(e){return HR(this,{})(e)},get description(){var e;return(e=Zl.get(this))==null?void 0:e.description},get _def(){return this._zod.def}}),p1=ve("_ZodString",(e,t)=>{kg.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>WR(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(TR(...e))},includes(...e){return this.check(AR(...e))},startsWith(...e){return this.check(IR(...e))},endsWith(...e){return this.check(RR(...e))},min(...e){return this.check(Nd(...e))},max(...e){return this.check(s1(...e))},length(...e){return this.check(i1(...e))},nonempty(...e){return this.check(Nd(1,...e))},lowercase(e){return this.check(jR(e))},uppercase(e){return this.check(CR(e))},trim(){return this.check(OR())},normalize(...e){return this.check($R(...e))},toLowerCase(){return this.check(MR())},toUpperCase(){return this.check(LR())},slugify(){return this.check(PR())}}),N$=ve("ZodString",(e,t)=>{kg.init(e,t),p1.init(e,t)},{email(e){return this.check(YI(I$,e))},url(e){return this.check(nR($$,e))},jwt(e){return this.check(kR(G$,e))},emoji(e){return this.check(rR(O$,e))},guid(e){return this.check(XI(R$,e))},uuid(e){return this.check(QI(Yu,e))},uuidv4(e){return this.check(JI(Yu,e))},uuidv6(e){return this.check(eR(Yu,e))},uuidv7(e){return this.check(tR(Yu,e))},nanoid(e){return this.check(oR(M$,e))},cuid(e){return this.check(sR(L$,e))},cuid2(e){return this.check(iR(P$,e))},ulid(e){return this.check(aR(D$,e))},base64(e){return this.check(pR(W$,e))},base64url(e){return this.check(mR(Z$,e))},xid(e){return this.check(lR(z$,e))},ksuid(e){return this.check(cR(F$,e))},ipv4(e){return this.check(uR(B$,e))},ipv6(e){return this.check(dR(U$,e))},cidrv4(e){return this.check(fR(H$,e))},cidrv6(e){return this.check(hR(K$,e))},e164(e){return this.check(gR(q$,e))},datetime(e){return this.check(wR(T$,e))},date(e){return this.check(yR(j$,e))},time(e){return this.check(vR(C$,e))},duration(e){return this.check(bR(A$,e))}});function xn(e){return VI(N$,e)}const Wn=ve("ZodStringFormat",(e,t)=>{Fn.init(e,t),p1.init(e,t)}),T$=ve("ZodISODateTime",(e,t)=>{tI.init(e,t),Wn.init(e,t)}),j$=ve("ZodISODate",(e,t)=>{nI.init(e,t),Wn.init(e,t)}),C$=ve("ZodISOTime",(e,t)=>{rI.init(e,t),Wn.init(e,t)}),A$=ve("ZodISODuration",(e,t)=>{oI.init(e,t),Wn.init(e,t)}),I$=ve("ZodEmail",(e,t)=>{BA.init(e,t),Wn.init(e,t)}),R$=ve("ZodGUID",(e,t)=>{zA.init(e,t),Wn.init(e,t)}),Yu=ve("ZodUUID",(e,t)=>{FA.init(e,t),Wn.init(e,t)}),$$=ve("ZodURL",(e,t)=>{qA.init(e,t),Wn.init(e,t)}),O$=ve("ZodEmoji",(e,t)=>{GA.init(e,t),Wn.init(e,t)}),M$=ve("ZodNanoID",(e,t)=>{VA.init(e,t),Wn.init(e,t)}),L$=ve("ZodCUID",(e,t)=>{YA.init(e,t),Wn.init(e,t)}),P$=ve("ZodCUID2",(e,t)=>{XA.init(e,t),Wn.init(e,t)}),D$=ve("ZodULID",(e,t)=>{QA.init(e,t),Wn.init(e,t)}),z$=ve("ZodXID",(e,t)=>{JA.init(e,t),Wn.init(e,t)}),F$=ve("ZodKSUID",(e,t)=>{eI.init(e,t),Wn.init(e,t)}),B$=ve("ZodIPv4",(e,t)=>{sI.init(e,t),Wn.init(e,t)}),U$=ve("ZodIPv6",(e,t)=>{aI.init(e,t),Wn.init(e,t)}),H$=ve("ZodCIDRv4",(e,t)=>{lI.init(e,t),Wn.init(e,t)}),K$=ve("ZodCIDRv6",(e,t)=>{uI.init(e,t),Wn.init(e,t)}),W$=ve("ZodBase64",(e,t)=>{dI.init(e,t),Wn.init(e,t)}),Z$=ve("ZodBase64URL",(e,t)=>{hI.init(e,t),Wn.init(e,t)}),q$=ve("ZodE164",(e,t)=>{pI.init(e,t),Wn.init(e,t)}),G$=ve("ZodJWT",(e,t)=>{gI.init(e,t),Wn.init(e,t)}),m1=ve("ZodNumber",(e,t)=>{Jx.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>ZR(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(Lv(e,t))},gte(e,t){return this.check(xp(e,t))},min(e,t){return this.check(xp(e,t))},lt(e,t){return this.check(Mv(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(Uv(e))},safe(e){return this.check(Uv(e))},positive(e){return this.check(Lv(0,e))},nonnegative(e){return this.check(xp(0,e))},negative(e){return this.check(Mv(0,e))},nonpositive(e){return this.check(bp(0,e))},multipleOf(e,t){return this.check(Pv(e,t))},step(e,t){return this.check(Pv(e,t))},finite(){return this}});function Oi(e){return xR(m1,e)}const V$=ve("ZodNumberFormat",(e,t)=>{kI.init(e,t),m1.init(e,t)});function Uv(e){return ER(V$,e)}const Y$=ve("ZodBoolean",(e,t)=>{wI.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>qR(e,n,r)});function Bo(e){return _R(Y$,e)}const X$=ve("ZodUnknown",(e,t)=>{yI.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>VR()});function Hv(){return SR(X$)}const Q$=ve("ZodNever",(e,t)=>{vI.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>GR(e,n,r)});function J$(e){return NR(Q$,e)}const eO=ve("ZodArray",(e,t)=>{uf(),bI.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>e$(e,n,r,o),e.element=t.element},{min(e,t){return this.check(Nd(e,t))},nonempty(e){return this.check(Nd(1,e))},max(e,t){return this.check(s1(e,t))},length(e,t){return this.check(i1(e,t))},unwrap(){return this.element}});function Mi(e,t){return DR(eO,e,t)}const tO=ve("ZodObject",(e,t)=>{uf(),_I.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>t$(e,n,r,o),AC(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return Cd(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Hv()})},loose(){return this.clone({...this._zod.def,catchall:Hv()})},strict(){return this.clone({...this._zod.def,catchall:J$()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return yC(this,e)},safeExtend(e){return vC(this,e)},merge(e){return bC(this,e)},pick(e){return kC(this,e)},omit(e){return wC(this,e)},partial(...e){return hv(yg,this,e[0])},exactPartial(...e){return hv(w1,this,e[0],"exactPartial")},required(...e){return xC(y1,this,e[0])}});function jr(e,t){const n={type:"object",shape:e??{},...it(t)};return new tO(n)}const g1=ve("ZodUnion",(e,t)=>{n1.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>n$(e,n,r,o),e.options=t.options});function nO(e,t){return new g1({type:"union",options:e,...it(t)})}const rO=ve("ZodDiscriminatedUnion",(e,t)=>{g1.init(e,t),SI.init(e,t)});function oO(e,t,n){return new rO({type:"union",options:t,discriminator:e,...it(n)})}const sO=ve("ZodIntersection",(e,t)=>{NI.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>r$(e,n,r,o)});function iO(e,t){return new sO({type:"intersection",left:e,right:t})}const aO=ve("ZodTuple",(e,t)=>{uf(),TI.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>o$(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 yg({type:"optional",innerType:n}))})}});function k1(e,t,n){const r=t instanceof zn,o=r?n:t,i=r?t:null;return new aO({type:"tuple",items:e,rest:i,...it(o)})}const fm=ve("ZodEnum",(e,t)=>{jI.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>YR(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 fm({...t,checks:[],...it(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const l of r)if(n.has(l))delete i[l];else throw new Error(`Key ${l} not found in enum`);return new fm({...t,checks:[],...it(o),entries:i})}});function Cd(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new fm({type:"enum",entries:n,...it(t)})}const lO=ve("ZodLiteral",(e,t)=>{CI.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>XR(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 lo(e,t){return new lO({type:"literal",values:Array.isArray(e)?e:[e],...it(t)})}const cO=ve("ZodTransform",(e,t)=>{uf(),AI.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>JR(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Fx(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(fc(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(fc(l))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function uO(e){return new cO({type:"transform",transform:e})}const yg=ve("ZodOptional",(e,t)=>{r1.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>h1(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Kv(e){return new yg({type:"optional",innerType:e})}const w1=ve("ZodExactOptional",(e,t)=>{II.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>h1(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function dO(e){return new w1({type:"optional",innerType:e})}const fO=ve("ZodNullable",(e,t)=>{RI.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>s$(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Wv(e){return new fO({type:"nullable",innerType:e})}const hO=ve("ZodDefault",(e,t)=>{$I.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>a$(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function pO(e,t){return new hO({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Px(t)}})}const mO=ve("ZodPrefault",(e,t)=>{OI.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>l$(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function gO(e,t){return new mO({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Px(t)}})}const y1=ve("ZodNonOptional",(e,t)=>{MI.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>i$(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function kO(e,t){return new y1({type:"nonoptional",innerType:e,...it(t)})}const wO=ve("ZodCatch",(e,t)=>{LI.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>c$(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function yO(e,t){return new wO({type:"catch",innerType:e,catchValue:typeof t=="function"?t:RC(t)})}const vO=ve("ZodPipe",(e,t)=>{PI.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>u$(e,n,r,o),e.in=t.in,e.out=t.out});function Zv(e,t){return new vO({type:"pipe",in:e,out:t})}const bO=ve("ZodReadonly",(e,t)=>{DI.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>d$(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function xO(e){return new bO({type:"readonly",innerType:e})}const v1=ve("ZodCustom",(e,t)=>{zI.init(e,t),Kn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>QR(e,n,r,o)});function EO(e,t={}){return zR(v1,e,t)}function _O(e,t){return FR(e,t)}function SO(e,t={}){const n=new v1({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...it(t)});return n._zod.bag.Class=e,n._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}const NO=["off","tailscale","any"],TO={updates:!0,deploy:!0,remote:"any",agents:null,customAgents:!0,brandedListener:!0,planSignIn:!0};jr({updates:Bo().optional(),deploy:Bo().optional(),remote:Cd(NO).optional(),agents:Mi(xn()).optional(),customAgents:Bo().optional(),brandedListener:Bo().optional(),planSignIn:Bo().optional()});const jO={...TO,source:null,problem:null};function CO(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 Ep=6e3,qv=1500;function AO(e){if(e.length<=Ep)return e;const t=e.length-Ep;return`${e.slice(0,qv)}
|
|
94
|
+
[${t} characters cut here]
|
|
95
|
+
${e.slice(e.length-(Ep-qv))}`}const Xu=100,Gv=2e3,IO=1e3,RO=10,$O=2048,Ad=5e6,OO=["image/png","image/jpeg","image/gif","image/webp"],Vv=2576,_p=5*1024*1024,MO=1200,LO=10,PO=1e5,Yv=100*1024*1024,DO="pasted-text.txt";function zO(e){return e.t==="term-data"||e.t==="term-snapshot"||e.t==="term-exit"}function FO(e){return e.t==="file-read"||e.t==="file-written"||e.t==="file-blame"}const BO=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,BO)}}function b1(e){return e.length>=MO||e.split(`
|
|
97
|
+
`).length>=LO}function UO({startLine:e,endLine:t}){return e===t?`${e}`:`${e}-${t}`}function HO(e){return`${e.path.slice(e.path.lastIndexOf("/")+1)} (${UO(e)})`}const KO=/\u001B(?:\[[0-?]*[ -/]*[@-~]|\][^\u0007]*(?:\u0007|\u001B\\))/g;function WO(e){return e.replace(KO,"")}const x1="Projects";function ZO(e){for(const t of e){const n=t.codePointAt(0)??0;if(n<32||n===127)return!0}return!1}function hc(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":ZO(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 qO=/^(?:https?|ssh|git|file):\/\/\S+$/i,E1=/^[\w.-]+@[\w.-]+:\S+$/;function GO(e){const t=e.trim();if(!qO.test(t)&&!E1.test(t))return null;const n=VO(t);return n&&!hc(n)?{url:t,name:n}:null}function VO(e){var o;const t=((o=e.split(/[?#]/)[0])==null?void 0:o.replace(/\/+$/,""))??"";return((E1.test(t)?t.split(":")[1]??"":t).split("/").pop()??"").replace(/\.git$/i,"")}const YO=jr({component:xn().nullable(),file:xn().nullable(),line:Oi().nullable(),callFile:xn().nullable().default(null),callLine:Oi().nullable().default(null),tag:xn(),selector:xn()}),XO=jr({tag:xn().max(40),id:xn().max(200),classes:Mi(xn().max(120)).max(16),text:xn().max(200),attrs:Mi(k1([xn().max(40),xn().max(200)])).max(12)}),QO=k1([Oi(),Oi()]),JO=YO.extend({classes:xn(),text:xn(),html:xn(),route:xn(),element:XO}),e2=oO("type",[jr({type:lo("loaded"),url:xn(),title:xn()}),jr({type:lo("navigated"),url:xn(),title:xn().optional()}),jr({type:lo("title"),title:xn()}),jr({type:lo("links"),links:Mi(jr({path:xn().max(2048),text:xn().max(120)})).max(200)}),jr({type:lo("hmr")}),jr({type:lo("page-error"),message:xn(),source:xn().optional(),line:Oi().optional()}),JO.extend({type:lo("picked"),verb:Cd(["chat","code"]).default("chat"),site:Cd(["call","source"]).default("source")}),jr({type:lo("pick-cancel")}),jr({type:lo("highlight-miss"),path:xn(),fileMatched:Oi(),withSource:Oi(),ranges:Mi(QO).nullable()}),jr({type:lo("drag-files")}),jr({type:lo("drop-files"),files:Mi(SO(File))}),jr({type:lo("focus"),gesture:Bo()}),jr({type:lo("key"),key:xn(),code:xn().optional(),meta:Bo(),ctrl:Bo().optional(),shift:Bo().optional(),alt:Bo().optional(),up:Bo().optional()})]);function t2(e){const t=e2.safeParse(e);return t.success?t.data:null}const n2=/["“”]([^"“”]*)["“”]?|(\S+)/g;function _1(e){const t=new Set;for(const n of e.matchAll(n2)){const r=(n[1]??n[2]??"").replace(/\s+/g," ").trim().toLowerCase();r&&t.add(r)}return[...t]}const r2="now",o2="http://preview.invalid",s2=200;function Xv(e){const t=e==null?void 0:e.replace(/\s+/g," ").trim().slice(0,s2).trim();return t||void 0}function df(e){let t;try{t=new URL(e,o2)}catch{return null}if(t.pathname.startsWith("/__toyon"))return null;const n=Qv(t.pathname)||"/",r=t.hash.startsWith("#/")?Qv(t.hash.split("?")[0]??""):"";return r.length>1?`${n}${r}`:n}const Qv=e=>e.replace(/\/+$/,""),i2={static:4,mixed:3.5,param:3,optional:2,"optional-static":2,splat:1},Id=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function S1(e){const t=/^\[\[\.\.\.([^\]]*)\]\]$/.exec(e);if(t)return{kind:"splat",name:t[1]||"path",min:0};const n=/^\[\.\.\.([^\]]*)\]$/.exec(e);if(n)return{kind:"splat",name:n[1]||"path",min:1};const r=/^\[\[([^\]]+)\]\]$/.exec(e)??/^:([\w-]+)\?$/.exec(e)??/^\{-\$([\w-]+)\}$/.exec(e);if(r)return{kind:"optional",name:r[1]};const o=/^\[([^\]=]+)(?:=[^\]]*)?\]$/.exec(e)??/^:([\w-]+)$/.exec(e)??/^\$([\w-]+)$/.exec(e);if(o)return{kind:"param",name:o[1]};if(e==="*"||e==="$")return{kind:"splat",name:"path",min:0};if(/^[^[{:$*?]+\?$/.test(e))return{kind:"optional-static",text:e.slice(0,-1)};if(/[[{]/.test(e)){const i=[];let l="",u=0;for(const f of e.matchAll(/\[([^\]=]+)(?:=[^\]]*)?\]|\{\$([\w-]+)\}/g)){const p=e.slice(u,f.index);p&&(i.push({text:p}),l+=Id(p)),i.push({name:f[1]??f[2]??"param"}),l+="[^/]+?",u=(f.index??0)+f[0].length}const c=e.slice(u);if(c&&(i.push({text:c}),l+=Id(c)),i.some(f=>"name"in f))return{kind:"mixed",pattern:l,parts:i}}return{kind:"static",text:e}}function a2(e){const t=e.split("/").filter(Boolean).map(S1);if(t.every(r=>r.kind==="static"))return null;let n="";for(const r of t)r.kind==="static"?n+=`/${Id(r.text)}`:r.kind==="optional-static"?n+=`(?:/${Id(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+i2[o.kind],0),statics:t.filter(r=>r.kind==="static").length}}function l2(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 ff(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(S1))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 Tc={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"}},N1={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"}},c2={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"}},u2={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"}},d2={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"}},f2={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"}},h2={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"}},p2={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"}},m2={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"}},g2={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"}},k2={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"}},w2={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"}},y2={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"}},v2={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"}},b2={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"}},x2={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"}},E2={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"}},_2={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"}},S2={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"}},N2=[m2,g2,k2,w2,y2,v2,b2,x2,E2,_2,S2],md=[Tc,N1,c2,u2,d2,f2,h2,p2,...N2],T2={mode:"dark",light:N1.id,dark:Tc.id},j2=["surface0","surface1","surface2","element0","element1","border0","border1","text0","text1","text2","red","orange","yellow","green","aqua","blue","purple","diffAdd","diffDel"];function C2(e){return`--${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function Jv(e){const t=C1(e);return t>.008856?116*t**(1/3)-16:903.3*t}function T1(e,t){const n=Jv(e)+t,r=zi(e);if(!r)return e;let o=0,i=2;for(let l=0;l<24;l++){const u=(o+i)/2,c=Ga(Math.min(255,r[0]*u),Math.min(255,r[1]*u),Math.min(255,r[2]*u));Jv(c)<n?o=u:i=u}return Ga(Math.min(255,r[0]*o),Math.min(255,r[1]*o),Math.min(255,r[2]*o))}function A2(e){return T1(e.colors.surface1,-4)}function I2(e){return T1(e.colors.surface0,-4)}function e0(e){return F2(e,.55)}function R2(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 $2(e){const t={};for(const n of j2)t[C2(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(R2(e)))t[`--syntax-${n}`]=r;return t["--accent"]=bg(e),t["--fault"]=O2(e),t["--sunken"]=A2(e),t["--sunken-floor"]=I2(e),t["--scrim"]=z2(e.colors.surface0,.7),t["--shadow"]=e.kind==="dark"?"#00000066":"#0000002e",t["--diff-add-word"]=e0(e.colors.diffAdd),t["--diff-del-word"]=e0(e.colors.diffDel),t}function bg(e){return j1(e.accent??"")??e.colors.orange}function O2(e){return bg(e)===j1(e.colors.orange)?e.colors.red:e.colors.orange}function M2(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 hf(e,t,n){const r=xg(e,n);return t.find(o=>o.id===e[r])??md.find(o=>o.kind===r)??Tc}function L2(e,t){if(e.pair){const l=t.find(u=>u.id===e.pair);if(l&&l.kind!==e.kind)return l}const n=e.kind==="dark"?"light":"dark",r=l=>l.toLowerCase().replace(/\b(dark|light)\b/g,"*").replace(/\s+/g," ").trim(),o=r(e.name);if(!o.includes("*"))return null;const i=e.id.startsWith("vscode:")?e.id.slice(0,e.id.lastIndexOf(":")+1):null;return t.find(l=>l.kind===n&&l.source===e.source&&(!i||l.id.startsWith(i))&&r(l.name)===o)??null}function P2(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=L2(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 D2(e,t){const n={...e};return t.dark&&(n.dark=t.dark.id),t.light&&(n.light=t.light.id),!M2(n.mode)&&!t[n.mode]&&(n.mode=t.dark?"dark":"light"),n}function zi(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());if(!t)return null;let n=t[1];if((n.length===3||n.length===4)&&(n=[...n].map(o=>o+o).join("")),n.length!==6&&n.length!==8)return null;const r=o=>parseInt(n.slice(o,o+2),16);return[r(0),r(2),r(4),n.length===8?r(6)/255:1]}function j1(e){const t=zi(e);return t?Ga(t[0],t[1],t[2],t[3]):null}function Ga(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 z2(e,t){const n=zi(e);return n?Ga(n[0],n[1],n[2],t):e}function F2(e,t){const n=zi(e);return n?Ga(n[0],n[1],n[2],Math.min(1,n[3]*t)):e}function Y7(e,t){const n=zi(e),r=zi(t);if(!n||!r)return e;const o=n[3];return Ga(n[0]*o+r[0]*(1-o),n[1]*o+r[1]*(1-o),n[2]*o+r[2]*(1-o))}function C1(e){const t=zi(e);if(!t)return 0;const n=r=>{const o=r/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4};return .2126*n(t[0])+.7152*n(t[1])+.0722*n(t[2])}function B2(e){return C1(e)>.179?"#1d2021":"#fbf1c7"}function hm(e){if(e===null||e==="")return"the npm registry";try{return new URL(e).host}catch{return e}}function U2(e,t){const n=t0(e),r=t0(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 t0(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 H2=[[/\.(png|jpe?g|gif|webp|avif|bmp|ico)$/i,"image"]];function K2(e){var t;return((t=H2.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const W2=[[/\.(md|markdown)$/i,"markdown"],[/\.html?$/i,"html"]];function pf(e){var t;return((t=W2.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const Ye={active:"toyon-active",phoneRow:"toyon-phone-row",repo:"toyon-repo",lastActive:"toyon-last",discoveredOpen:"toyon-disc",archivedOpen:"toyon-arch",committedShut:"toyon-committed-shut",turnOpen:"toyon-turn-open",treeOpen:"toyon-tree",token:"toyon-token",theme:"toyon-theme",daylight:"toyon-sun",changesWidth:"toyon-changes-w",chatWidth:"toyon-chat-w",editorHeight:"toyon-dh",editorFull:"toyon-dfull",designHeight:"toyon-dsh",designFull:"toyon-dsfull",termHeight:"toyon-th",rail:"toyon-rail",railWidth:"toyon-rail-w",chatSide:"toyon-chat-side",clipboardOffer:"toyon-clipboard-offer",layouts:"toyon-layouts",client:"toyon-client",profilePrefix:"toyon-profile-",modePrefix:"toyon-mode-",modelPrefix:"toyon-model-",effortPrefix:"toyon-effort-"},Z2=[Ye.active,Ye.repo,Ye.lastActive,Ye.discoveredOpen,Ye.archivedOpen,Ye.committedShut,Ye.turnOpen,Ye.treeOpen,Ye.profilePrefix,Ye.modePrefix,Ye.modelPrefix,Ye.effortPrefix,Ye.phoneRow],q2=[Ye.profilePrefix,Ye.modePrefix,Ye.modelPrefix,Ye.effortPrefix],gd=(e,t)=>`${e}@${t}`;function G2(e,t=typeof localStorage>"u"?null:localStorage,n=typeof sessionStorage>"u"?null:sessionStorage){const r=l=>({get(u){try{return(l==null?void 0:l.getItem(gd(u,e)))??null}catch{return null}},set(u,c){try{l==null||l.setItem(gd(u,e),c)}catch{}},remove(u){try{l==null||l.removeItem(gd(u,e))}catch{}}}),o=r(t),i=r(n);return{...o,session:{get:i.get,set:i.set},clear(){for(const l of[t,n])for(const u of A1(l).filter(c=>c.endsWith(`@${e}`)))try{l==null||l.removeItem(u)}catch{}}}}function A1(e){const t=[];try{for(let n=0;n<((e==null?void 0:e.length)??0);n++){const r=e==null?void 0:e.key(n);r!=null&&t.push(r)}}catch{}return t}const V2="orch-";function Y2(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=Ye[i],u=V2+l.slice(6);n0(r,u,l)}for(const[r,o]of[[t,Z2.filter(i=>i!==Ye.phoneRow)],[n,[Ye.phoneRow]]]){const i=A1(r).filter(l=>!l.includes("@"));for(const l of o){const u=q2.includes(l)?i.filter(c=>c.startsWith(l)):i.filter(c=>c===l);for(const c of u)n0(r,c,gd(c,e))}}}function n0(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 I1(){const e=location.hash.match(/token=([a-f0-9]+)/);if(e!=null&&e[1])return R1(e[1]),e[1];try{return localStorage.getItem(Ye.token)??sessionStorage.getItem(Ye.token)??""}catch{return""}}function R1(e){try{localStorage.setItem(Ye.token,e)}catch{}}function Eg(){return I1()!==""}function _g(e,t){const n=new URL(e),r=`token=${t}`,o=i=>`&v=${encodeURIComponent(i??"")}`;return{origin:n.origin,host:n.hostname,token:t,ws:`${n.protocol==="https:"?"wss":"ws"}://${n.host}/ws?${r}`,attachment:(i,l)=>`${n.origin}/attachments/${i}/${l}?${r}`,upload:i=>`${n.origin}/uploads/${i}?${r}`,worktreeFile:(i,l,u)=>`${n.origin}/files/${i}/${l.split("/").map(encodeURIComponent).join("/")}?${r}${o(u)}`,loose:(i,l)=>`${n.origin}/loose/${encodeURIComponent(i)}?${r}${o(l)}`,health:`${n.origin}/health`,restart:i=>`${n.origin}/restart?${r}${i?`&${r2}`:""}`,uploads:i=>`${n.origin}/uploads?kind=${i}`,phones:`${n.origin}/phones`,tailnet:`${n.origin}/tailnet`,remote:`${n.origin}/remote`,machines:`${n.origin}/machines`,knockAnswer:i=>`${n.origin}/knock/${i}/answer`,previewGrant:`${n.origin}/preview-grant`}}const mf=e=>({authorization:`Bearer ${e.token}`});async function X2(e,t,n){try{await n.slice(0,1).arrayBuffer()}catch{return"could not be read"}try{const r=await fetch(e.uploads(t),{method:"POST",headers:{...mf(e),"content-type":n.type||"application/octet-stream"},body:n});return r.status>=502&&r.status<=504?null:r.ok?await r.json():await r.text()||"could not be attached"}catch{return null}}async function Q2(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 $1(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 O1(e,t){try{const n=await fetch(t,{headers:mf(e)});return n.ok?await n.json():null}catch{return null}}async function Sg(e,t,n,r){try{const o=await fetch(t,{method:"POST",headers:{...mf(e),"content-type":"application/json"},body:JSON.stringify(n)});return o.ok?null:await o.text()||`refused (${o.status})`}catch{return r}}const J2=e=>O1(e,e.phones),eM=e=>O1(e,e.tailnet),tM=e=>Sg(e,e.remote,{tailscale:!0},"Toyon is not answering; try again once it is back."),nM=(e,t,n)=>Sg(e,e.machines,{origin:t,token:n},"Toyon here is not answering; the machine is not listed yet."),rM=(e,t,n)=>Sg(e,e.knockAnswer(t),{letIn:n},"Toyon is not answering");async function M1(e){try{const t=await fetch(e.previewGrant,{method:"POST",headers:mf(e)});return t.ok?await t.json():null}catch{return null}}const oM=2e3;async function L1(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,oM))}return"gone"}async function pm(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 sM=1e3,iM=3e4,aM=1500,r0=50,lM=e=>e.t==="chat"||e.t==="create-worktree"||e.t==="restore-worktree"||e.t==="batch-worktrees";class cM{constructor(t,n,r){Rt(this,"ws",null);Rt(this,"queue",[]);Rt(this,"closed",!1);Rt(this,"attempt",0);Rt(this,"timer",null);Rt(this,"downAt",null);Rt(this,"downCode",0);Rt(this,"sayTimer",null);Rt(this,"sentDown",new Set);Rt(this,"urls");Rt(this,"suspended",!1);Rt(this,"wake",()=>{var n;if(this.closed||this.suspended||document.visibilityState!=="visible"||((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN)return;this.timer&&clearTimeout(this.timer),this.timer=null,this.attempt=0,this.downAt!==null&&(this.downAt=Date.now(),this.onStatus(!1,null),this.armSay());const t=this.ws;this.connect(),t==null||t.close()});this.onMsg=n,this.onStatus=r,this.urls=_g(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===Qj)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+aM-Date.now()))}connect(){if(this.closed||this.suspended)return;const t=new WebSocket(this.urls.ws);this.ws=t;let n=!1;t.onmessage=r=>{if(!n){n=!0,this.attempt=0,this.downAt=null,this.sayTimer&&clearTimeout(this.sayTimer),this.sayTimer=null,this.onStatus(!0);for(const o of this.queue)t.send(o.raw);this.queue=[]}try{this.onMsg(JSON.parse(r.data))}catch{}},t.onclose=r=>{if(this.ws!==t||(this.onStatus(!1),this.closed||this.suspended))return;this.say(r.code);const o=Math.min(iM,sM*2**this.attempt++);this.timer=setTimeout(()=>this.connect(),o/2+Math.random()*(o/2))},t.onerror=()=>t.close()}send(t){const n=JSON.stringify(t);if(this.ws&&this.ws.readyState===WebSocket.OPEN){this.ws.send(n);return}if(t.t.startsWith("term-"))return;const r=t.t==="subscribe"||t.t==="unsubscribe"?`sub:${t.worktreeId}`:t.t==="view"?"view":null;r&&(this.queue=this.queue.filter(o=>o.key!==r)),lM(t)&&t.boxId&&this.sentDown.add(t.boxId),this.queue.push({key:r,raw:n}),this.queue.length>r0&&this.queue.splice(0,this.queue.length-r0)}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 P1(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 D1(e,t,n){const r=f=>e.map((p,m)=>f(p)&&p.id!==t?m:-1).filter(p=>p>=0),i=[()=>r(f=>f.agent==="waiting"),()=>r(f=>!!f.unseen),()=>r(f=>f.agent==="working")].reduce((f,p)=>f.length>0?f:p(),[]),l=e.findIndex(f=>f.id===t),u=n>0?i.find(f=>f>l)??i[0]:i.findLast(f=>f<l)??i[i.length-1],c=u===void 0?void 0:e[u];return c?{activate:c.id}:null}function Ng(e,t,n){const r=D1(e,t,n);if(r)return r;const o=e[0];return o&&o.id!==t?{activate:o.id}:null}function Tg(e){return e==="cancelled"||e==="expired"}function z1(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:Tg(t.outcome)?t:null}function uM(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 dM(e){return e.map(()=>({selected:[]}))}function o0(e,t,n,r){return e.map((o,i)=>{if(i!==t)return o;const l=o.selected.includes(n);return r?{...o,selected:l?o.selected.filter(u=>u!==n):[...o.selected,n]}:{...o,selected:[n]}})}function Rd(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 s0(e,t,n,r){return e.map((o,i)=>i!==t?o:{selected:n&&!r?[]:o.selected,note:o.note??""})}function mm(e,t){const n=e[t];return n&&n.note!==void 0&&!n.note.trim()?Rd(e,t,void 0):e}function fM(e){return e?e.options.length+(e.note?1:0):0}function hM(e,t){return!!(e!=null&&e.note)&&t===e.options.length}function F1(e,t){return!!e&&e.note!==void 0&&(t||e.selected.length===0)}function Fa(e){var t;return!!e&&(e.selected.length>0||!!((t=e.note)!=null&&t.trim()))}function Qu(e,t){return e.every((n,r)=>!n.required||Fa(t[r]))}function pM(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(i=>{var l;return jg(((l=e.options.find(u=>u.value===i))==null?void 0:l.label)??i)}),r=(o=t==null?void 0:t.note)==null?void 0:o.trim();return n.length===0?r||"skipped":r?`${n.join(", ")}: ${r}`:n.join(", ")}function mM(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(i=>{var l;return jg(((l=e.options.find(u=>u.value===i))==null?void 0:l.label)??i)}),r=((o=t==null?void 0:t.note)==null?void 0:o.trim())||void 0;return n.length>0?r?{pick:n.join(", "),note:r}:{pick:n.join(", ")}:r&&e.note?{pick:e.note.label,note:r}:{pick:r??"skipped"}}function B1(e,t){return e.map((n,r)=>{const o=pM(n,t==null?void 0:t[r]);return e.length>1&&n.header?`${n.header} · ${o}`:o})}function gM(e){return e.outcome!=="answered"||e.ask.kind!=="question"?null:{message:e.ask.message,questions:e.ask.questions,answers:e.answers}}function kM(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 Oa(e,t){if(!e)return 0;if(F1(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 wM(e,t,n){return Math.max(0,Math.min(n-1,e+t))}function yM(e,t,n){const r=e.length;for(let o=1;o<=r;o++){const i=(n+o)%r;if(!Fa(t[i]))return i}return-1}function tc(e){return e.length>1?e.length:-1}function vM(e){return e.length+(tc(e)===-1?0:1)}function i0(e,t,n){const r=yM(e,t,n);if(r!==-1)return{current:r,cursor:Oa(e[r],t[r]),send:!1};const o=tc(e);return o!==-1?{current:o,cursor:0,send:!1}:{current:n,cursor:Oa(e[n],t[n]),send:!0}}const U1=/\s*\(recommended\)\s*$/i;function bM(e){return U1.test(e)}function jg(e){return e.replace(U1,"")}const xM={skipped:"you skipped this",cancelled:"the turn was stopped before you answered",expired:"Toyon restarted before you answered"};function kd(e,t,n,r){return n!==null&&r===n.host?`${Xj(n.previews,e,t)}/`:r.endsWith(".localhost")?`http://w${e}.${r}:${t}/`:ug(r)?`http://${r==="localhost"?"127.0.0.1":r}:${t}/`:`https://${r}:${t}/`}function a0(e){return e.ranges.map(([t,n])=>[t+e.offset,n+e.offset])}function Sp(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 Ju(e,t){return!Number.isFinite(e)||e<=0?t:Math.min(Math.max(e,170),Math.floor(window.innerWidth*.5))}function jc(e){return e.agent==="working"||e.agent==="waiting"}function oi(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 EM={waiting:"Waiting for you",working:"Agent working",failed:"Agent failed",landed:"Landed",crashed:"Crashed",running:"Running",starting:"Starting",asleep:"Asleep",idle:"Idle"};function Cg(e,t=!1){const n=oi(e);return n==="idle"&&t?"Not set up":EM[n]}const _M={starting:"Starting",running:"Running",unreachable:"Not answering",crashed:"Crashed",stopped:"Stopped",asleep:"Asleep"};function SM(e){return _M[e]}function H1(e,t){return t&&oi(e)!=="waiting"?t:null}const NM={land:"Landing",commit:"Committing","sync-main":"Syncing with main","pull-main":"Pulling"};function Ag(e){return NM[e]}function K1(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 TM(e){const t=e.lastIndexOf("/");return t<0?{name:e,dir:""}:{name:e.slice(t+1),dir:e.slice(0,t)}}const W1=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}).compare;function $d(e){const t=[];for(let n=e.indexOf("/");n!==-1;n=e.indexOf("/",n+1))t.push(e.slice(0,n));return t}function Z1(e){const t=new Set;for(const n of e)for(const r of $d(n))t.add(r);return[...t].sort(W1)}function Ig(e){return e.includes("A")||e==="??"?"added":e.includes("D")?"deleted":""}function Rg(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 jM=/Firefox\//.test(navigator.userAgent);function gf(){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 CM=/Chrome\//.test(navigator.userAgent)&&gf(),At=e=>Lj(e,{firefox:jM,pwa:CM});function $g(e){return e.component?`<${e.component} />`:`<${e.tag}>`}function gm(e,t){return e.worktree&&Ir(e.worktree)&&t?t.defaultBranch:e.name}function Og(e){const t=Math.max(0,e/1e3),n=(l,u)=>`${l} ${u}${l===1?"":"s"}`;if(t<60)return"a moment";const r=t/60;if(r<60)return n(Math.floor(r),"minute");const o=r/60;if(o<24)return n(Math.floor(o),"hour");const i=o/24;return i<7?n(Math.floor(i),"day"):i<365?n(Math.floor(i/7),"week"):n(Math.floor(i/365),"year")}function eo(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 Ba(e){const t=Math.max(0,Math.floor(e));return t<100?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function AM(e,t,n,r){var l;if(!t)return null;const o=e.filter(An).filter(u=>u.repoId===t&&(u.worktree.agent??r)===n);return((l=o.find(u=>Ir(u.worktree))??o[0])==null?void 0:l.id)??null}const IM=200;function RM(e,t){const n=new Map(e.map(r=>[r.path,r]));for(const r of t){if(n.size>=IM)break;const o=df(r.path);o&&!n.has(o)&&n.set(o,{path:o,text:r.text})}return n.size===e.length?e:[...n.values()]}function q1(e){return e!==void 0&&!e.routes.some(t=>!t.endpoint)}const Va=e=>"uploading"in e&&e.uploading===!0;function Ii(e){switch(e.kind){case"image":case"file":{const{key:t,local:n,uploading:r,...o}=e;return o}case"paste":{const{key:t,chars:n,lines:r,preview:o,...i}=e;return i}case"pick":{const{key:t,...n}=e;return n}}}const $M=e=>e.filter(t=>!Va(t)).map(Ii);let OM=0;function km(e,t){const n=new Map(t.filter(o=>!Va(o)).map(o=>[JSON.stringify(Ii(o)),o]));return[...e.map(o=>{const i=JSON.stringify(o),l=n.get(i);if(l)return n.delete(i),l;const u=`d${++OM}`;return o.kind==="paste"?{...o,key:u,...vg(o.text)}:{...o,key:u}}),...t.filter(Va)]}const wd=["files","changes","history"],MM=e=>wd.includes(e),G1=e=>!!(e!=null&&e.carry)&&!e.batch&&e.variants===1,Cc=e=>(e==null?void 0:e.worktree.id)??null,Ya="new-project",ol=Object.freeze({chat:[],log:[],queue:[],page:{},turn:{edits:!1,hmr:!1},changedRanges:{},commitFiles:{},search:null,design:null,draft:"",attachments:[],commands:[],termStream:vo}),Mg=e=>({...e,phase:"editing",repoId:null}),l0=()=>Mg({mode:"create",name:"",parent:`~/${x1}`}),LM=Object.freeze({changes:!1,changesTab:"files",chat:!0,term:!1,design:!1});function PM(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.changes=="boolean"&&MM(t.changesTab)&&typeof t.chat=="boolean"&&typeof t.term=="boolean"&&typeof t.design=="boolean"}function Xr(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 Lg(e,t){return{...e,layout:t,changesAuto:!1}}const Fi=e=>pf(e)?"preview":"file",DM=(e,t)=>e===t||!!e&&!!t&&e.at===t.at&&(e.at!=="tree"||t.at!=="tree"||e.worktreeId===t.worktreeId&&e.dir===t.dir),zl=(e,t)=>e.worktreeId===t.worktreeId&&e.path===t.path&&e.ref===t.ref&&e.since===t.since;function V1(e,t,n,r){var i;if(!r.fiber)return r;const o=(i=_o(e,t).changedRanges[n])==null?void 0:i.offset;return o===void 0?r:{n:r.n-o}}function zM(e){const t=e.cached??Tc,n={connected:!1,connectFailure:null,repos:[],rows:[],activeRepoId:null,visible:[],archiving:[],shipping:{},visibleDiscovered:[],discoveredOpen:e.storedDiscoveredOpen??{},archivedOpen:e.storedArchivedOpen??{},committedShut:e.storedCommittedShut??{},turnOpen:e.storedTurnOpen??{},treeOpen:e.storedTreeOpen??{},treeReveal:null,refs:{},chats:{},archived:{},archivedPage:null,lastActive:e.storedLastActive??{},pendingOpen:!1,activeId:null,carryTo:null,clientId:e.clientId,storedActive:e.storedActive??null,storedRepo:e.storedRepo??null,heard:!1,local:{},editor:null,openUrl:null,reloadReq:null,renders:[],dragFiles:null,picking:!1,overlay:null,paletteReturn:null,incompatible:!1,layout:LM,focusChanges:0,editCommit:0,focusChat:0,walked:0,railOpen:e.storedRailOpen??!1,chatSide:e.storedChatSide??"left",focusRail:0,railPeek:!1,unreadHold:null,layouts:e.storedLayouts??{},screen:e.storedActive&&e.storedPhoneRow?"chat":"home",frame:e.frame??"desk",touch:e.touch??!1,reading:!1,changesAuto:!0,zen:!1,focusTerm:0,termRun:null,termTall:0,themes:md.some(o=>o.id===t.id)?md:[...md,t],themePrefs:{...T2,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:jO,letIn:!1,knocks:[],tailscale:null,handed:[],gitIdentity:!0,self:null,rebuilt:!1,update:null,updateCheck:null,version:"",install:"none",registry:null,choosingFolder:!1,newProject:null,autoSend:null,chosenFolder:null,pending:[],activeImportId:null,agents:[],defaultAgent:"claude",agentChosen:!1,agentConfigs:{},draft:null,trunks:{},visits:{}},r=e.storedRepo?n.layouts[e.storedRepo]:void 0;return r?Lg(n,r):n}function Y1(e){var t;return{system:e.systemDark,daylight:((t=e.daylight)==null?void 0:t.dark)??e.systemDark}}function FM(e){return e.previewTheme??hf(e.themePrefs,e.themes,Y1(e))}function _o(e,t){return t&&e.local[t]||ol}function rs(e,t){return t&&e.rows.find(n=>n.id===t)||null}function dn(e,t){const n=rs(e,t);return n&&An(n)?n:null}function X1(e){var o;const t=dn(e,e.activeId);if(!t||!Di(t.worktree)||t.agent!=="idle"||!((o=Xa(e,t.repoId))!=null&&o.empty))return!1;const n=ci(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&&_o(e,t.id).chat.length===0}function kf(e){return e.newProject!==null||X1(e)}function BM(e){return e.incompatible||kf(e)}function UM(e){return(!e.needsSetup||!!e.assumed)&&Object.keys(e.config.run).length===0}function Od(e){return!!(e!=null&&e.needsSetup)&&!e.assumed}function Pg(e){const t=e.archivedPage?null:rs(e,e.activeId);return(t==null?void 0:t.repoId)??e.activeRepoId}function xo(e){const t=ci(e,Pg(e));return!!t&&UM(t)}function Q1(e){return e.layout.chat&&!xo(e)&&!e.archivedPage&&!tE(e)?{a:"toggle-chat"}:{a:"focus-chat"}}function es(e){return xo(e)?e:Xr(e,{chat:!0})}function ci(e,t){return t&&e.repos.find(n=>n.id===t)||null}function J1(e,t){if(!t)return null;const n=e.rows.filter(An).filter(r=>r.repoId===t);return n.find(r=>Nc(r.worktree))??n.find(r=>Di(r.worktree))??null}function Xa(e,t){return t&&e.trunks[t]||null}function ql(e){return xo(e)||e.archivedPage?null:e.activeId}function Dg(e){return e.procs.some(t=>t.status==="running"||t.status==="starting")}function Md(e){if(e.archivedPage)return null;const t=dn(e,e.activeId);return t&&Dg(t)?{worktreeId:t.worktree.id,repoId:t.repoId}:null}function zg(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&&An(o)&&o.repoId===t?o:null}function wf(e,t,n){return e.repoId===t||zg(e,t,n)!==null}function eE(e,t){return t.length?e.filter(n=>!t.includes(n.id)):e}function HM(e,t,n){const r=eE(e,n).filter(An);return bj(t?r.filter(o=>wf(o,t,r)):r)}function KM(e,t){const n=e.filter(r=>!An(r));return t?n.filter(r=>r.repoId===t):n}function Ua(e,t,n=e.rows){var u;const r=n.filter(An),o=e.archiving.length?r.filter(c=>!e.archiving.includes(c.id)):r,i=t?e.lastActive[t]:void 0;if(i&&o.some(c=>c.id===i))return i;const l=t?o.filter(c=>c.repoId===t):o;return((u=l.find(c=>Nc(c.worktree))??l.find(c=>Di(c.worktree))??l[0])==null?void 0:u.id)??null}function c0(e,t){const n=Object.entries(e),r=n.filter(([o])=>!t(o));return r.length===n.length?e:Object.fromEntries(r)}function u0(e,t,n){const r={};for(const l of t)l.shipping&&(r[l.id]=l.shipping);for(const l of Object.values(n))l.shipping&&(r[l.id]=l.shipping);for(const[l,u]of Object.entries(e))!u.sent||r[l]||(t.some(c=>c.id===l)||aE({trunks:n},l))&&(r[l]=u);const o=Object.keys(r);return o.length===Object.keys(e).length&&o.every(l=>WM(e[l],r[l]))?e:r}const WM=(e,t)=>!!e&&!!t&&e.op===t.op&&e.step===t.step&&e.sent===t.sent;function Ma(e,t){var p;const n=rs(e,t),o=!!n&&An(n)&&!!e.activeRepoId&&wf(n,e.activeRepoId,e.rows)?e.activeRepoId:(n==null?void 0:n.repoId)??e.activeRepoId,i=n&&An(n)?{...e.lastActive,[n.repoId]:n.id}:e.lastActive,l=e.activeId!==t?e.activeId:null,u=l?e.local[l]:void 0,c=u&&((p=u.mark)==null?void 0:p.by)==="reveal"?nc(u,"reveal"):null,f=l&&c?{...e.local,[l]:c}:e.local;return{...e,activeId:t,activeRepoId:o,lastActive:i,editor:null,archivedPage:null,local:f}}function Qa(e){return So(e)?"history":e.layout.changesTab}function ZM(e,t){const n=Qa(e);if(So(e))return n;const r=wd.length;return wd[(wd.indexOf(n)+t+r)%r]??"changes"}function tE(e){if(e.archivedPage)return null;const t=rs(e,e.activeId);return t&&!An(t)?t:null}function So(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 nc(e,t){var o;if(((o=e.mark)==null?void 0:o.by)!==t)return e;const{mark:n,...r}=e;return r}const nE=e=>e.kind==="theme"||e.kind==="appearance"||e.kind==="keep-awake"||e.kind==="agent"||e.kind==="agent-page"||e.kind==="choose-folder"||e.kind==="handoff";function pc(e){if(!e.sending)return e;const{sending:t,...n}=e;return n}function qM(e,t){var n;return!t||((n=e.local[t])==null?void 0:n.restoring)===void 0?e:Et(e,t,({restoring:r,...o})=>o)}function GM(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]=pc(r[o]);return{...e,local:r}}function VM(e,t,n,r){var l;let o=e;const i=n?(l=o[n])==null?void 0:l.sending:void 0;if(i&&n&&r&&r!==n){const u=o[r]??ol,c=u.chat.some(f=>f.kind==="user")?{}:i;o={...o,[n]:pc(o[n]),[r]:{...u,sending:c}}}for(const u of t){const c=o[u.id];c!=null&&c.sending&&!c.sending.message&&(u.agent==="working"||u.agent==="waiting")&&(o={...o,[u.id]:pc(c)})}return o}function Et(e,t,n){return{...e,local:{...e.local,[t]:n(e.local[t]??ol)}}}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 YM(e,t){const n=t.type==="agent-question"||t.type==="agent-permission"||t.type==="handoff-proposed",r=t.type==="agent-ask-end"||t.type==="handoff"||t.type==="handoff-declined"?t.id:null;if(!n&&!r)return e;const o=t.type==="agent-ask-end"&&Tg(t.outcome),{card:i,cardParked:l,askRevived:u,...c}=e;return{...c,...i&&!n&&(i.id!==r||o)?{card:i}:{},...l&&!n&&l!==r?{cardParked:l}:{},...u&&!n?{askRevived:u}:{}}}function XM(e,t,n){return Et(e,t,r=>({...r,chat:[...r.chat,n],chatAt:Date.now()}))}function rE(e,t,n){return XM(es(e),t,{kind:"error",text:n})}function wm(e,t){const n=Cc(dn(e,e.activeId));return n?Et(es(e),n,r=>({...r,notice:t})):e}function f0(e,t,n){return dn(e,t)?rE(e,t,n):wm(e,n)}function QM(e,t){const n=e.paletteReturn;return!t||!n?{overlay:null,paletteReturn:null}:{overlay:{kind:n.mode},paletteReturn:n}}function JM(e){const t=e.activeRepoId;if(!t)return e;const n=e.layouts[t];return n?Lg(e,n):e.frame==="desk"?{...e,layouts:{...e.layouts,[t]:e.layout}}:e}function eL(e){return e.a==="server"&&e.msg.t==="git-status"}function tL(e){return{variants:1,batch:!1,agent:e.defaultAgent}}function nL(e){const t=dn(e,e.activeId);return!!t&&Ir(t.worktree)&&!e.archivedPage&&!kf(e)?e.draft?e:{...e,draft:tL(e)}:e.draft?{...e,draft:null}:e}function oE(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 rL(e){const t=e.activeRepoId;if(!t)return e;const n=dn(e,e.activeId);return!n||n.repoId===t||wf(n,t,eE(e.rows,e.archiving))?e:Ma(e,Ua(e,t))}function h0(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?Li(o,{a:"open",overlay:{kind:"pair"}}):o}const sE=e=>{var t;return e.frame==="desk"&&(e.remote!==null||((t=e.tailscale)==null?void 0:t.state)==="ready")};function Li(e,t){let n=nL(rL(oL(e,t)));return n.unreadHold!==null&&n.activeId!==n.unreadHold&&(n={...n,unreadHold:null}),n.archivedPage!==null&&(So(n)===null||dn(n,n.archivedPage)!==null)&&(n=oE(n)),n.activeRepoId!==e.activeRepoId?n=JM(n):n.frame==="desk"&&n.activeRepoId&&!eL(t)&&n.layout!==e.layout&&(n={...n,layouts:{...n.layouts,[n.activeRepoId]:n.layout}}),n.rows===e.rows&&n.activeRepoId===e.activeRepoId&&n.archiving===e.archiving?n:{...n,visible:HM(n.rows,n.activeRepoId,n.archiving),visibleDiscovered:KM(n.rows,n.activeRepoId)}}function oL(e,t){var n,r,o,i,l,u;switch(t.a){case"connected":return{...e,connected:t.v,connectFailure:t.v?null:t.failure===void 0?e.connectFailure:t.failure};case"activate":return{...Ma(e,t.id),carryTo:null,screen:t.id?"chat":"home"};case"open-draft":{if(kf(e))return e;const c=((n=J1(e,e.activeRepoId))==null?void 0:n.id)??null;return c?es({...Ma(e,c),carryTo:c,overlay:null,paletteReturn:null,focusChat:e.focusChat+1,screen:"chat"}):e}case"draft-carry":return e.draft?{...e,draft:{...e.draft,carry:t.v}}:e;case"draft-variants":return e.draft?{...e,draft:{...e.draft,variants:t.n}}:e;case"draft-batch":return e.draft?{...e,draft:{...e.draft,batch:t.v}}:e;case"draft-agent":return e.draft?{...e,draft:{...e.draft,agent:t.id}}:e;case"draft-profile":return e.draft?{...e,draft:{...e.draft,profile:t.profile}}:e;case"open-archived":return!e.activeRepoId||!((r=e.archived[e.activeRepoId])!=null&&r.some(c=>c.id===t.id))?e:{...e,archivedPage:t.id,editor:null,screen:"chat"};case"close-archived":return e.archivedPage?oE(e):e;case"restoring":return Et(e,t.id,c=>({...c,restoring:t.text}));case"sending":return Et(e,t.id,c=>({...c,sending:{message:t.message}}));case"sent-box":return Et(e,t.id,({notice:c,...f})=>({...nc(f,"walk"),draft:"",attachments:[],sent:(f.sent??0)+1}));case"answered":return Et(e,t.id,c=>({...c,sent:(c.sent??0)+1}));case"archive-worktrees":{const c=t.ids.filter(T=>!e.archiving.includes(T)&&dn(e,T));if(c.length===0)return e;const f={...e,archiving:[...e.archiving,...c]};if(!e.activeId||!c.includes(e.activeId))return f;const p=e.visible.filter(T=>T.id===e.activeId||!f.archiving.includes(T.id)),m=p.findIndex(T=>T.id===e.activeId),g=T=>T.id!==e.activeId&&ig(T.worktree)&&!!T.worktree.landed&&T.agent==="idle",w=T=>{var R;return(R=p.find(($,W)=>W>m&&T($))??p.find(T))==null?void 0:R.id},y=w(T=>T.id!==e.activeId&&T.agent==="waiting"),x=w(g),b=(o=D1(p,e.activeId,1))==null?void 0:o.activate,j=(i=p.map((T,R)=>({id:T.id,i:R,far:Math.abs(R-m),up:!Ir(T.worktree)&&oi(T)==="running"})).filter(T=>T.up&&T.far>0).sort((T,R)=>T.far-R.far||R.i-T.i)[0])==null?void 0:i.id,N=Ma(f,y??x??b??j??Ua(f,e.activeRepoId));return e.frame==="phone"?{...N,screen:"home"}:N}case"shipping":return e.shipping[t.id]||!(rs(e,t.id)||aE(e,t.id))?e:{...e,shipping:{...e.shipping,[t.id]:{op:t.op,sent:!0}}};case"activate-repo":{if(!ci(e,t.id))return e;const c=e.newProject?{...e,newProject:null}:e;if(t.id===e.activeRepoId)return c;const f=Ua(c,t.id);return{...Ma(c,f),carryTo:null,activeRepoId:t.id,pendingOpen:!1}}case"open-repo":return{...e,pendingOpen:!0};case"new-project":return{...e,newProject:t.v,overlay:null,paletteReturn:null,previewTheme:null,editor:null};case"new-project-set":{if(!e.newProject)return e;const c="name"in t.v||"parent"in t.v||"url"in t.v||"mode"in t.v,{error:f,...p}=e.newProject;return{...e,newProject:{...c?p:e.newProject,...t.v}}}case"close-new-project":return e.newProject&&e.repos.length>0?{...e,newProject:null,choosingFolder:!1}:e;case"auto-sent":return e.autoSend?{...e,autoSend:null}:e;case"watch-import":return{...e,activeImportId:t.id};case"close-editor":return{...e,editor:null};case"open-file":{const c=t.v,f=e.editor,p=f&&zl(f,c)?f:null,m=c.line&&V1(e,c.worktreeId,c.path,c.line);return{...e,editor:{worktreeId:c.worktreeId,path:c.path,...c.ref?{ref:c.ref}:{},...c.since?{since:c.since}:{},view:c.view??(p==null?void 0:p.view)??null,seq:c.seq,disk:(p==null?void 0:p.disk)??null,...m?{line:m}:{},focus:c.focus,conflict:(p==null?void 0:p.conflict)??null,blame:(p==null?void 0:p.blame)??null}}}case"open-loose":{const c=t.v,f={before:c.text,after:c.text,version:null,writable:c.source.kind!=="bytes"&&!c.tooLarge&&!c.binary,binary:c.binary,tooLarge:c.tooLarge};return{...e,editor:{worktreeId:c.worktreeId,path:c.name,view:Fi(c.name),seq:c.seq,disk:f,focus:!0,conflict:null,blame:null,loose:{source:c.source}}}}case"editor-read":{const c=e.editor;if(!c||c.loose||!zl(c,t.file))return e;const f=t.disk;if(!f){const g=rE(e,c.worktreeId,t.error??`could not read ${c.path}`);return c.disk?g:{...g,editor:null}}const p=Fi(c.path),m=f.before===""?c.view&&c.view!=="diff"?c.view:p:c.view??(f.before===f.after?p:"diff");return{...e,editor:{...c,view:m,disk:f}}}case"editor-conflict":{const c=e.editor;return c&&!c.loose&&zl(c,t.file)?{...e,editor:{...c,conflict:t.theirs}}:e}case"editor-view":return e.editor?{...e,editor:{...e.editor,view:t.v,line:void 0}}:e;case"editor-refused":{const c=e.editor;if(!c||!zl(c,t.file))return e;const f=c.loose&&c.disk?{...c.disk,writable:!1}:c.disk;return{...e,editor:{...c,refused:t.message,disk:f}}}case"editor-blame":{const c=e.editor;return c&&!c.loose&&zl(c,t.file)?{...e,editor:{...c,blame:t.blame}}:e}case"notice":return Et(es(e),t.id,c=>({...c,notice:t.text}));case"link-refused":return Et(e,t.id,({refusedLink:c,...f})=>t.v?{...f,refusedLink:t.v}:f);case"card-draft":return Et(e,t.id,c=>({...c,card:t.card}));case"card-park":return Et(e,t.id,c=>({...c,cardParked:t.cardId}));case"card-unpark":return Et(e,t.id,({cardParked:c,...f})=>f);case"ask-revive":return Et(e,t.id,({askRevived:c,...f})=>t.askId?{...f,askRevived:t.askId}:f);case"opened-url":return e.openUrl?{...e,openUrl:null}:e;case"set-draft":return Et(e,t.id,c=>{const{notice:f,...p}=nc(c,"walk");return{...p,draft:t.text,...f!==void 0&&t.text===""?{notice:f}:{}}});case"move-box":return iE(e,t.from,t.to);case"walk":return Et(e,t.id,c=>({...nc(c,"walk"),draft:t.text,...t.walk?{mark:{by:"walk",at:t.walk.at,from:t.walk.from}}:{}}));case"reveal":return Et(es(e),t.id,c=>{var f;return{...c,mark:{by:"reveal",seq:t.seq,n:((f=c.mark)==null?void 0:f.by)==="reveal"?c.mark.n+1:1}}});case"attach":return Et(es(e),t.id,({notice:c,...f})=>({...f,attachments:[...f.attachments,...t.items]}));case"attached":return(l=e.local[t.id])!=null&&l.attachments.some(c=>c.key===t.key)?Et(e,t.id,c=>({...c,attachments:c.attachments.map(f=>f.key===t.key?t.item:f)})):e;case"detach":return Et(e,t.id,({notice:c,...f})=>({...f,attachments:f.attachments.filter(p=>p.key!==t.key)}));case"clear-attachments":return Et(e,t.id,({notice:c,...f})=>f.attachments.length?{...f,attachments:[]}:f);case"hmr":return Et(e,t.id,c=>({...c,turn:{...c.turn,hmr:!0}}));case"page":return Et(e,t.id,c=>({...c,page:{url:t.url??c.page.url,title:t.title??c.page.title}}));case"render-done":return e.renders.some(c=>c.id===t.id)?{...e,renders:e.renders.filter(c=>c.id!==t.id)}:e;case"links":return Et(e,t.id,c=>{const f=RM(c.links??[],t.links);return f===c.links?c:{...c,links:f}});case"drag-files":return DM(e.dragFiles,t.v)?e:{...e,dragFiles:t.v};case"set-picking":return{...e,picking:t.v};case"open":return{...e,overlay:t.overlay,previewTheme:null,paletteReturn:nE(t.overlay)?e.paletteReturn:null};case"choosing-folder":return{...e,choosingFolder:t.v};case"close":return{...e,previewTheme:null,...QM(e,t.back)};case"toggle":return((u=e.overlay)==null?void 0:u.kind)===t.overlay.kind?Li(e,{a:"close"}):Li(e,{a:"open",overlay:t.overlay});case"palette-return":return{...e,paletteReturn:t.v};case"toggle-changes":return{...Xr(e,{changes:!e.layout.changes}),changesAuto:!1};case"focus-changes":return{...Xr(e,{changes:!0,changesTab:t.tab&&!So(e)?t.tab:e.layout.changesTab}),changesAuto:!1,focusChanges:e.focusChanges+1};case"changes-tab":return Xr(e,{changesTab:t.v});case"edit-commit":return{...Xr(e,{changes:!0}),changesAuto:!1,editCommit:e.editCommit+1};case"toggle-chat":return xo(e)?e:Xr(e,{chat:!e.layout.chat});case"focus-chat":return{...es(e),focusChat:e.focusChat+1};case"walked":return{...e,walked:e.walked+1};case"show-chat":return es(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"?Xr(e,{changesTab:"changes"}):e,screen:t.to,editor:null};case"frame":{if(e.frame===t.v)return e;const c={...e,frame:t.v};if(t.v!=="desk"||!c.activeRepoId)return c;const f=c.layouts[c.activeRepoId];return f?Lg(c,f):c}case"touch":return e.touch===t.v?e:{...e,touch:t.v};case"reading":return e.reading===t.on?e:{...e,reading:t.on};case"rail-peek":return e.railPeek===t.on?e:{...e,railPeek:t.on};case"toggle-discovered":{const c=e.activeRepoId;return c?{...e,discoveredOpen:{...e.discoveredOpen,[c]:!e.discoveredOpen[c]}}:e}case"toggle-archived":{const c=e.activeRepoId;return c?{...e,archivedOpen:{...e.archivedOpen,[c]:!e.archivedOpen[c]}}:e}case"toggle-committed":{const c=e.activeRepoId;return c?{...e,committedShut:{...e.committedShut,[c]:!e.committedShut[c]}}:e}case"toggle-turn":{const c=e.activeRepoId;return c?{...e,turnOpen:{...e.turnOpen,[c]:!e.turnOpen[c]}}:e}case"tree-folder":{const c=e.treeOpen[t.worktreeId]??[];if(c.includes(t.path)===t.open)return e;const f=t.open?[...c,t.path]:c.filter(m=>m!==t.path),p={...e.treeOpen};return f.length>0?p[t.worktreeId]=f:delete p[t.worktreeId],{...e,treeOpen:p}}case"tree-reveal":{const c=e.treeOpen[t.worktreeId]??[],f=[];for(let g=t.path.indexOf("/");g!==-1;g=t.path.indexOf("/",g+1))f.push(t.path.slice(0,g));f.push(t.path);const p=f.filter(g=>!c.includes(g)),m=p.length?{...e.treeOpen,[t.worktreeId]:[...c,...p]}:e.treeOpen;return{...Xr(e,{changes:!0,changesTab:"files"}),changesAuto:!1,focusChanges:e.focusChanges+1,treeOpen:m,treeReveal:{worktreeId:t.worktreeId,path:t.path}}}case"files-asked":return Et(e,t.worktreeId,c=>({...c,filesFor:t.key}));case"toggle-zen":return xo(e)?e:{...e,zen:!e.zen};case"toggle-terminal":return Xr(e,{term:!e.layout.term});case"focus-terminal":return{...Xr(e,{term:!0}),focusTerm:e.focusTerm+1};case"toggle-design":return xo(e)?e:Xr(e,{design:!e.layout.design});case"term-stream":return Et({...Xr(e,{term:!0}),termTall:t.tall?e.termTall+1:e.termTall},t.id,c=>({...c,termStream:t.stream}));case"term-run":return Et({...Xr(e,{term:!0}),focusTerm:e.focusTerm+1,termRun:{id:t.id,command:t.command}},t.id,c=>({...c,termStream:vo}));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 cL(e,t.msg)}}function p0(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 m0(e,t,n){const r=new Set(t.map(l=>l.id));n&&r.add(n);const o=([l,u])=>r.has(l)||!!u.draft||u.attachments.length>0,i=Object.entries(e);return i.every(o)?e:Object.fromEntries(i.filter(o))}function sL(e,t,n){var o;let r=e;for(const i of n){if(!((o=i.worktree)!=null&&o.landed)||t.some(u=>{var c;return u.id===i.id&&((c=u.worktree)==null?void 0:c.landed)}))continue;const l=r[i.id];!(l!=null&&l.git)||l.git.files.length===0||(r===e&&(r={...e}),r[i.id]={...l,git:{...l.git,files:[]}})}return r}function iL(e,t){let n=e;for(const[r,o]of Object.entries(t)){const i=n[r];i!=null&&i.draft||(n===e&&(n={...e}),n[r]={...i??ol,draft:o})}return n}function aL(e,t){let n=e;for(const[r,o]of Object.entries(t)){const i=n[r];i!=null&&i.attachments.length||(n===e&&(n={...e}),n[r]={...i??ol,attachments:km(o,[])})}return n}function lL(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 Si(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 g0(e){const t=e.newProject;if((t==null?void 0:t.phase)!=="creating"||!t.repoId)return e;const n=J1(e,t.repoId);if(!n)return e;const r=_o(e,Ya);return!r.draft.trim()&&r.attachments.length===0?{...e,newProject:null}:{...iE(e,Ya,n.id),newProject:null,autoSend:n.id}}function iE(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 aE(e,t){return Object.values(e.trunks).some(n=>n.id===t)}function cL(e,t){var n,r,o,i,l,u,c,f,p,m,g,w,y,x;switch(t.t){case"hello":{const b=A=>!!A&&t.rows.some(I=>I.id===A),j=A=>!!A&&t.repos.some(I=>I.id===A),N=j(e.activeRepoId)?e.activeRepoId:j(e.storedRepo)?e.storedRepo:null,T=b(e.activeId)?e.activeId:b(e.storedActive)?e.storedActive:Ua(e,N,t.rows),R=t.rows.find(A=>A.id===T),$=!!N&&!!R&&An(R)&&wf(R,N,t.rows),W={...e,heard:!0,repos:t.repos,rows:t.rows,activeId:T,activeRepoId:$?N:(R==null?void 0:R.repoId)??N??((n=t.repos[0])==null?void 0:n.id)??null,trunks:t.trunks,archiving:e.archiving.length?[]:e.archiving,shipping:u0({},t.rows,t.trunks),local:m0(aL(iL(e.local,t.drafts),t.attachments),t.rows,e.archivedPage),lastActive:lL(e.lastActive,t.rows),treeOpen:p0(e.treeOpen,t.rows),discoveredOpen:Si(e.discoveredOpen,t.repos),archivedOpen:Si(e.archivedOpen,t.repos),committedShut:Si(e.committedShut,t.repos),turnOpen:Si(e.turnOpen,t.repos),refs:Si(e.refs,t.repos),chats:Si(e.chats,t.repos),archived:Si(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?l0():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(A=>A.id===e.activeImportId)?e.activeImportId:null};return h0(W,t.knocks,t.letIn)}case"self":{const b=((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||b&&((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 h0(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"render":return{...e,renders:[...e.renders,{worktreeId:t.worktreeId,id:t.id,path:t.path}]};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:b,...j}=t;return{...e,agentConfigs:{...e.agentConfigs,[j.agent]:j}}}case"pending-repos":{const b=new Set(e.pending.map($=>$.id)),j=t.pending.find($=>!b.has($.id)),N=j&&e.pendingOpen?j.id:e.activeImportId,T=t.pending.some($=>$.id===N),R=t.pending.some($=>$.id===N&&$.error);return{...e,pending:t.pending,activeImportId:T?N:null,pendingOpen:R?!1:e.pendingOpen,newProject:j&&e.pendingOpen&&((l=e.newProject)==null?void 0:l.phase)==="creating"?null:e.newProject}}case"path-entries":return{...e,paths:{query:t.query,entries:t.entries,target:t.target}};case"folder-chosen":return{...e,chosenFolder:{seq:(((u=e.chosenFolder)==null?void 0:u.seq)??0)+1,folder:t.folder}};case"refs":return{...e,refs:{...e.refs,[t.repoId]:{query:t.query,refs:t.refs}}};case"chat-hits":return{...e,chats:{...e.chats,[t.repoId]:{query:t.query,hits:t.hits,truncated:t.truncated}}};case"archived":return{...e,archived:{...e.archived,[t.repoId]:t.items}};case"draft":return t.clientId===e.clientId?e:Et(e,t.boxId,b=>{var j;return b.draft===t.text||((j=b.mark)==null?void 0:j.by)==="walk"?b:{...b,draft:t.text}});case"attachments":return t.clientId===e.clientId?e:Et(e,t.boxId,b=>({...b,attachments:km(t.items,b.attachments)}));case"repos":{const b=new Set(e.repos.map(W=>W.id)),j=t.repos.find(W=>!b.has(W.id));let N=e.activeRepoId,T=e.pendingOpen,R=e.newProject;j&&(T||!N)?(N=j.id,T=!1,R&&R.phase!=="unmaking"&&(R={...R,phase:"creating",repoId:j.id})):t.repos.some(W=>W.id===N)||(N=((c=t.repos[0])==null?void 0:c.id)??null),(R==null?void 0:R.phase)==="unmaking"&&!t.repos.some(W=>W.id===(R==null?void 0:R.repoId))&&(R={...R,phase:"editing",repoId:null}),t.repos.length===0&&!R&&(R=l0());const $=e.gitIdentity||t.repos.some(W=>W.made&&!b.has(W.id));return N===e.activeRepoId?{...e,repos:t.repos,pendingOpen:T,newProject:R,gitIdentity:$}:g0({...e,repos:t.repos,pendingOpen:T,newProject:R,gitIdentity:$,activeRepoId:N,activeId:Ua(e,N),editor:null})}case"worktrees":{let b=e.activeId;(!b||!t.rows.some(W=>W.id===b))&&(b=Ua(e,e.activeRepoId,t.rows));const j=new Set(e.rows.map(W=>W.id)),N=W=>{var A;return((A=W.worktree)==null?void 0:A.kind)==="worktree"&&W.worktree.createdBy===e.clientId},T=t.rows.find(W=>!j.has(W.id)&&N(W)),R=!!b&&e.rows.some(W=>{var A;return W.id===b&&((A=W.worktree)==null?void 0:A.kind)==="spare"})&&t.rows.some(W=>W.id===b&&N(W));T&&e.rows.length>0&&!R&&(b=T.id);const $=e.archiving.filter(W=>t.rows.some(A=>A.id===W));return g0({...Ma({...e,rows:t.rows,trunks:t.trunks,archiving:$.length===e.archiving.length?e.archiving:$,shipping:u0(e.shipping,t.rows,t.trunks),local:VM(sL(m0(e.local,t.rows,e.archivedPage),e.rows,t.rows),t.rows,e.activeId,b===(T==null?void 0:T.id)?T.id:void 0),treeOpen:p0(e.treeOpen,t.rows)},b),editor:b===e.activeId?e.editor:null,...T&&b===T.id?{carryTo:T.id}:{},...b===e.activeId?{activeRepoId:e.activeRepoId}:{},archivedPage:T?null:e.archivedPage})}case"proc":{const b=e.rows.map(j=>j.id===t.worktreeId?{...j,procs:uL(j.procs,t.proc)}:j);return{...e,rows:b}}case"log":return Et(e,t.worktreeId,b=>({...b,log:gj(b.log.slice(-400),t.proc,t.line,t.retract)}));case"agent":{const b=t.event,j=t.worktreeId;let N=Et(e,j,T=>{const R=w0(T.chat,b,t.seq),W=b.type==="tool-start"||b.type==="tool-end"||b.type==="turn-end"||b.type==="agent-error"||b.type==="tool-update"&&b.background?d0(R,T.running):T.running;let A=T.turn;b.type==="turn-start"?A={edits:!1,hmr:!1}:b.type==="tool-start"&&og(b)&&(A={...A,edits:!0});const I=b.type==="session-info"&&b.model?b.model:T.model,_=b.type==="session-info"&&b.effort?b.effort:T.effort,P=b.type==="usage"?{...k0(b),heard:Date.now()}:T.usage,{restoring:z,...q}=T,se=e.rows.find(L=>L.id===j),Y=(se==null?void 0:se.agent)==="working"||(se==null?void 0:se.agent)==="waiting",ge=q.sending?Y?pc(q):{...q,sending:{}}:q,ke=b.type==="turn-end"||b.type==="agent-error",oe=YM(b.type==="user-message"?ge:ke?pc(T):T,b);return{...b.type==="user-message"?nc(oe,"reveal"):oe,chat:R,...R!==T.chat?{chatAt:Date.now()}:{},...W!==T.running?{running:W}:{},turn:A,...I!==T.model?{model:I}:{},..._!==T.effort?{effort:_}:{},...P!==T.usage?{usage:P}:{}}});if(b.type==="agent-ask-end"&&!Tg(b.outcome)&&((f=N.local[Da(b.id)])!=null&&f.attachments.length)&&(N=Et(N,Da(b.id),T=>({...T,attachments:[]}))),b.type==="user-message"){const T=z1(((p=e.local[j])==null?void 0:p.chat)??[]),R=T?Da(T.id):null,$=R?((m=N.local[R])==null?void 0:m.attachments)??[]:[];R&&$.length&&(N=Et(N,R,W=>({...W,attachments:[]})),N=Et(N,j,W=>({...W,attachments:[...W.attachments,...$]})))}if(b.type==="turn-end"){const T=N.local[j].turn;T.edits&&!T.hmr&&(N={...N,reloadReq:{id:j,n:(((g=N.reloadReq)==null?void 0:g.n)??0)+1}})}return(b.type==="agent-question"||b.type==="agent-permission"||b.type==="handoff-proposed")&&j===e.activeId&&(N=es(N)),N}case"backfill":{let b=[],j;for(const{seq:T,event:R}of t.events)b=w0(b,R,T),R.type==="usage"&&(j=k0(R));const N=T=>!T||t.events.some(({event:R})=>R.type==="user-message"&&R.text===T);return Et(e,t.worktreeId,({restoring:T,sending:R,...$})=>({...$,...R&&!(R.message&&N(R.message.text))?{sending:R}:{},chat:b,chatAt:Date.now(),running:d0(b,$.running),log:t.log??$.log,...j?{usage:j}:{},...T!==void 0&&!N(T)?{restoring:T}:{}}))}case"git-status":{let b=e.layout.changes,j=e.changesAuto;e.changesAuto&&t.worktreeId===e.activeId&&!b&&(t.files.length>0||(((w=t.committed)==null?void 0:w.length)??0)>0)&&(b=!0,j=!1);const N=t.worktreeId===e.archivedPage?So(e):null;N&&(t.files.length>0||(((y=t.committed)==null?void 0:y.length)??0)>0||N.landed)&&(b=!0);const T=Et(e,t.worktreeId,R=>({...R,git:{files:t.files,committed:t.committed,turn:t.turn,ahead:t.ahead,behind:t.behind,unpushed:t.unpushed,head:t.head},changedRanges:{}}));return{...Xr(T,{changes:b}),changesAuto:j}}case"changed-ranges":{const b=Et(e,t.worktreeId,N=>({...N,changedRanges:{...N.changedRanges,[t.path]:{ranges:t.ranges,offset:t.lineOffset}}})),j=b.editor;return!((x=j==null?void 0:j.line)!=null&&x.fiber)||j.worktreeId!==t.worktreeId||j.path!==t.path?b:{...b,editor:{...j,line:V1(b,j.worktreeId,j.path,j.line)}}}case"shipped":{const b=t.worktreeId,j={...e,shipping:c0(e.shipping,N=>{var T;return N===b&&((T=e.shipping[N])==null?void 0:T.sent)===!0}),openUrl:t.ok&&t.url?t.url:e.openUrl};return!t.ok&&!t.asked?b?f0(j,b,t.message):wm(j,t.message):j}case"files":return Et(e,t.worktreeId,b=>({...b,files:t.paths,submodules:t.submodules,ignored:t.ignored}));case"search-results":return Et(e,t.worktreeId,b=>({...b,search:{query:t.query,hits:t.hits,truncated:t.truncated}}));case"element-sources":{if(e.editor&&e.editor.seq>t.seq)return e;const[b]=t.hits;if(!b)return Et(e,t.worktreeId,N=>({...N,notice:"nothing in the source matches this element"}));if(!t.sure)return Li(e,{a:"open",overlay:{kind:"element-sources",worktreeId:t.worktreeId,hits:t.hits}});const j=Li(e,{a:"open-file",v:{worktreeId:t.worktreeId,path:b.path,view:"file",line:{n:b.line},focus:!0,seq:t.seq}});return j.layout.changes?j:Li(j,{a:"toggle-changes"})}case"design-index":return Et(e,t.worktreeId,b=>({...b,design:t.index}));case"routes":return Et(e,t.worktreeId,b=>({...b,pages:{routes:t.routes,unseen:t.unseen}}));case"queue":return Et(e,t.worktreeId,b=>({...b,queue:t.items}));case"agent-commands":return Et(e,t.worktreeId,b=>({...b,commands:t.commands}));case"git-log":return Et(e,t.worktreeId,b=>({...b,commits:t.commits}));case"git-commit":return Et(e,t.worktreeId,b=>({...b,commitFiles:{...b.commitFiles,[t.sha]:t.files}}));case"error":{const b=t.worktreeId,j=e.newProject,N=(j==null?void 0:j.phase)==="creating"&&!j.repoId,T={...GM(qM(e,b),b),archiving:b?e.archiving.includes(b)?e.archiving.filter(R=>R!==b):e.archiving:e.archiving.length?[]:e.archiving,shipping:c0(e.shipping,R=>!b||R===b),newProject:N?{...j,phase:"editing",error:t.message}:(j==null?void 0:j.phase)==="unmaking"?null:j,pendingOpen:N?!1:e.pendingOpen,updateCheck:!b&&e.updateCheck==="asking"?null:e.updateCheck};return N?T:b?f0(T,b,t.message):wm(T,t.message)}case"unsent":return Et(es(e),t.boxId,({restoring:b,sending:j,...N})=>({...N,draft:N.draft||t.text,attachments:[...km(t.items,[]),...N.attachments],notice:t.message}));default:return e}}function uL(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 k0(e){return{used:e.used,size:e.size,...e.cost!==void 0?{cost:e.cost}:{}}}function dL(e,t){const n=t.trim();return n!==""&&(e.trim()===n||e.trim().endsWith(`: ${n}`))}function w0(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 u=t.messageId?{messageId:t.messageId}:{};if((r==null?void 0:r.kind)==="assistant")return[...e.slice(0,-1),{...r,text:r.text+t.text,...u}];const c=t.messageId===void 0?-1:fL(e,t.messageId);if(c!==-1){const f=e.slice(),p=f[c];return f[c]={...p,text:p.text+t.text},f}return[...e,{kind:"assistant",text:t.text,...o,...u}]}case"thinking-delta":return(r==null?void 0:r.kind)==="thinking"?[...e.slice(0,-1),{...r,text:r.text+t.text}]:[...e,{kind:"thinking",text:t.text}];case"tool-start":return[...e,{kind:"tool",id:t.toolId,name:t.name,input:t.input,done:!1,...t.kind?{toolKind:t.kind}:{},...t.title?{title:t.title}:{},...t.parentToolId?{parentToolId:t.parentToolId}:{},...t.subagent?{subagent:!0}:{}}];case"tool-update":{const u=e.findLastIndex(p=>p.kind==="tool"&&p.id===t.toolId);if(u===-1)return e;const c=e.slice(),f=c[u];return c[u]={...f,...t.name?{name:t.name}:{},...t.title?{title:t.title}:{},...t.input!==void 0?{input:t.input}:{},...t.kind?{toolKind:t.kind}:{},...t.background?{background:!0}:{}},c}case"tool-delta":{const u=e.findLastIndex(p=>p.kind==="tool"&&p.id===t.toolId);if(u===-1)return e;const c=e.slice(),f=c[u];return c[u]={...f,output:(f.output??"")+t.text},c}case"tool-end":{const u=e.findLastIndex(p=>p.kind==="tool"&&p.id===t.toolId);if(u===-1)return e;const c=e.slice(),f=c[u];return c[u]={...f,output:t.output,isError:t.isError,...(l=t.images)!=null&&l.length?{images:t.images}:{},...t.detached?{detached:!0}:{},...t.fixable?{fixable:t.fixable}:{},done:!0},c}case"agent-error":{const u=y0(e);return(r==null?void 0:r.kind)==="assistant"&&dL(t.message,r.text)?[...u.slice(0,-1),{kind:"error",text:t.message,...o}]:[...u,{kind:"error",text:t.message,...o}]}case"page-error":return[...e,{kind:"page-error",message: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":{const u=e.findLastIndex(p=>p.kind==="handoff"&&p.id===t.id&&p.state==="proposed");if(u===-1)return[...e,{kind:"handoff",id:t.id,repo:{id:t.repoId,name:t.repoName,path:""},message:"",title:t.title,by:"agent",mode:xd,state:"continued",worktreeId:t.worktreeId,ts:t.ts}];const c=e.slice(),f=c[u];return c[u]={...f,state:"continued",worktreeId:t.worktreeId,title:t.title},c}case"handoff-declined":{const u=e.findLastIndex(p=>p.kind==="handoff"&&p.id===t.id&&p.state==="proposed");if(u===-1)return e;const c=e.slice(),f=c[u];return c[u]={...f,state:"declined",...t.reason?{reason:t.reason}:{}},c}case"handoff-landed":return[...e,{kind:"handoff-landed",worktreeId:t.worktreeId,repoName:t.repoName,title:t.title,...t.url?{url:t.url}:{},ts:t.ts}];case"restored":return[...e,{kind:"restored",archivedAt:t.archivedAt,branch:t.branch,uncommitted:t.uncommitted,ts:t.ts}];case"adopted":return[...e,{kind:"adopted",branch:t.branch,ts:t.ts}];case"agent-auth-required":return[...e,{kind:"auth",agent:t.agent,agentName:t.agentName,methods:t.methods,...t.rejected?{rejected:!0}:{},...t.withheld?{withheld:!0}:{},done:!1}];case"agent-auth-ok":return e.some(u=>u.kind==="auth"&&!u.done)?e.map(u=>u.kind==="auth"&&!u.done?{...u,done:!0}:u):e;case"agent-question":return v0(e,t.toolId,{kind:"ask",id:t.id,ask:{kind:"question",message:t.message,questions:t.questions}});case"agent-permission":{const u={kind:"ask",id:t.id,ask:{kind:"permission",title:t.title,...t.command?{command:t.command}:{},...t.detail?{detail:t.detail}:{},...t.plan?{plan:t.plan}:{},choices:t.choices}},c=e.findLast(f=>f.kind==="tool"&&f.id===t.toolId);return(c==null?void 0:c.kind)!=="tool"||t.plan||c.toolKind==="switch_mode"?v0(e,t.toolId,u):[...e,{...u,toolId:c.id}]}case"agent-ask-end":{const u=e.findLastIndex(p=>p.kind==="ask"&&p.id===t.id&&!p.outcome);if(u===-1)return e;const c=e[u];if(c.toolId&&hL(c,t.choiceId))return[...e.slice(0,u),...e.slice(u+1)];const f=e.slice();return f[u]={...f[u],outcome:t.outcome,...t.answers?{answers:t.answers}:{},...t.choiceId?{choiceId:t.choiceId}:{}},f}case"turn-end":{const u=y0(e);return t.stopReason==="interrupted"?[...u,{kind:"stopped",...o}]:u}default:return e}}function y0(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 fL(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 hL(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 v0(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 pL(e){let t=e;const n=new Set;return{getState:()=>t,dispatch(r){const o=Li(t,r);if(o!==t){t=o;for(const i of n)i()}},subscribe(r){return n.add(r),()=>n.delete(r)}}}const lE=S.createContext(null),Fg=S.createContext(null),cE=S.createContext(null);function mL({store:e,sock:t,files:n,children:r}){return h.jsx(lE.Provider,{value:e,children:h.jsx(Fg.Provider,{value:t,children:h.jsx(cE.Provider,{value:n,children:r})})})}const uE=S.createContext(null),dE=S.createContext(null);function gL({machines:e,children:t}){const n=S.useSyncExternalStore(e.subscribe,e.active);return h.jsx(uE.Provider,{value:e,children:h.jsx(dE.Provider,{value:n,children:h.jsx(mL,{store:n.store,sock:n.sock,files:n.files,children:h.jsx(S.Fragment,{children:t},n.origin)})})})}function To(){const e=S.useContext(uE);if(!e)throw new Error("useMachines outside <MachinesProvider>");return e}function oo(){const e=S.useContext(dE);if(!e)throw new Error("useMachine outside <MachinesProvider>");return e}function Bg(){const e=To();return S.useSyncExternalStore(e.subscribe,e.list)}function Aa(e,t){return S.useSyncExternalStore(e.store.subscribe,()=>t(e.store.getState()))}const b0=(e,t)=>e.length===t.length&&e.every((n,r)=>n===t[r]);function fE(){const e=To(),t=oo(),n=Bg(),r=S.useMemo(()=>n.filter(u=>u!==t),[n,t]),o=S.useRef(null),i=S.useCallback(u=>{const c=r.map(f=>f.store.subscribe(u));return()=>{for(const f of c)f()}},[r]),l=S.useCallback(()=>{const u=r.map(m=>e.displayName(m.origin)),c=r.map(m=>m.store.getState().repos),f=o.current;if(f&&f.others===r&&b0(f.names,u)&&b0(f.repos,c))return f.value;const p=r.map((m,g)=>({origin:m.origin,name:u[g]??m.origin,repos:c[g]??[]}));return o.current={others:r,names:u,repos:c,value:p},p},[r,e]);return S.useSyncExternalStore(i,l)}function X7(){return oo().terminals}function Zn(){const e=S.useContext(lE);if(!e)throw new Error("useStore outside <StoreProvider>");return e}function M(e){const t=Zn();return S.useSyncExternalStore(t.subscribe,()=>e(t.getState()))}function Ug(){const e=M(n=>n.systemDark),t=M(n=>{var r;return(r=n.daylight)==null?void 0:r.dark});return{system:e,daylight:t??e}}function at(){return Zn().dispatch}function lt(){return S.useContext(Fg)}function $r(){const e=S.useContext(Fg);return(e==null?void 0:e.urls)??_g(location.origin,"")}function hE(){return S.useContext(cE)}function pE(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 bo(e,t,n,r=kL){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(),f=>{l({key:e,value:f});try{r.set(e,typeof f=="boolean"?f?"1":"0":String(f))}catch{}}]}const kL={get:e=>localStorage.getItem(e),set:(e,t)=>localStorage.setItem(e,t)};function Ha(e,t){return n=>{n.preventDefault(),document.body.classList.add("resizing");const r=n.currentTarget;r.classList.add("active");const o=l=>{const u=e(l,r);u!==null&&t(u)},i=()=>{document.body.classList.remove("resizing"),r.classList.remove("active"),window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",i)};window.addEventListener("pointermove",o),window.addEventListener("pointerup",i)}}function mE(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 Hg(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 Kg=1500;function Ja(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 wL(){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 yL(e){const t=S.useRef(null);return S.useLayoutEffect(()=>{const n=t.current;if(!n)return;t.current=null;const r=n.closest(e);if(!r)return;const o=r.getBoundingClientRect(),i=n.getBoundingClientRect(),l=i.bottom-o.bottom;if(l<=0)return;const u=parseFloat(getComputedStyle(r).paddingTop)||0;r.scrollTop+=Math.min(l,Math.max(0,i.top-o.top-u))}),n=>{t.current=n}}const Np=40,vL=1200,bL=150,xL=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]);function gE(e,t){const n=S.useRef(!0),r=S.useRef(Number.NEGATIVE_INFINITY),o=S.useRef(!1),[i,l]=S.useState(!1),[u,c]=S.useState(!1),[f,p]=S.useState(!1),[m,g]=S.useState(null),w=S.useCallback(R=>{n.current=R,e.current&&(e.current.style.overflowAnchor=R?"none":"")},[e]),y=S.useRef(null),x=S.useRef(null);vt([t],()=>{n.current||p(!0)});const b=S.useCallback(()=>{const R=e.current;R&&(w(R.scrollHeight-R.scrollTop-R.clientHeight<Np),l(!n.current),c(R.scrollTop>=Np),n.current&&p(!1))},[e,w]),j=S.useCallback(R=>{R!==0&&(g(R<0?"up":"down"),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>g(null),vL))},[]),N=S.useCallback(()=>{const R=e.current;R&&(R.scrollTop=R.scrollHeight,w(!0),l(!1),p(!1))},[e,w]),T=S.useCallback(()=>{const R=e.current;R&&(r.current=performance.now(),R.scrollTop=0)},[e]);return S.useEffect(()=>{const R=e.current;if(!R)return;w(n.current);const $=()=>o.current||performance.now()-r.current<bL,W=()=>{n.current&&!$()?c(R.scrollTop>=Np):b()};R.addEventListener("scroll",W,{passive:!0});const A=()=>{r.current=performance.now()},I=oe=>{A(),j(oe.deltaY)},_=oe=>{var L;A(),y.current=((L=oe.touches[0])==null?void 0:L.clientY)??null},P=oe=>{var re;A();const L=(re=oe.touches[0])==null?void 0:re.clientY;L===void 0||y.current===null||(j(y.current-L),y.current=L)},z=()=>{o.current=!0},q=()=>{o.current=!1},se=oe=>{if(!xL.has(oe.key))return;const L=oe.target;(L===document.body||L instanceof Node&&R.contains(L))&&A()};R.addEventListener("wheel",I,{passive:!0}),R.addEventListener("touchstart",_,{passive:!0}),R.addEventListener("touchmove",P,{passive:!0}),R.addEventListener("pointerdown",z,{passive:!0}),window.addEventListener("pointerup",q,{passive:!0}),window.addEventListener("pointercancel",q,{passive:!0}),document.addEventListener("keydown",se);const Y=()=>{R.scrollTop=R.scrollHeight},ge=new ResizeObserver(()=>{n.current&&Y()});ge.observe(R);for(const oe of R.children)ge.observe(oe);const ke=new MutationObserver(oe=>{for(const L of oe){for(const re of L.addedNodes)re instanceof Element&&ge.observe(re);for(const re of L.removedNodes)re instanceof Element&&ge.unobserve(re)}n.current&&Y()});return ke.observe(R,{childList:!0}),()=>{R.removeEventListener("scroll",W),R.removeEventListener("wheel",I),R.removeEventListener("touchstart",_),R.removeEventListener("touchmove",P),R.removeEventListener("pointerdown",z),window.removeEventListener("pointerup",q),window.removeEventListener("pointercancel",q),document.removeEventListener("keydown",se),ke.disconnect(),ge.disconnect(),x.current&&clearTimeout(x.current)}},[e,b,j,w]),{offEnd:i,offStart:u,away:f,moving:m,pinned:()=>n.current,jump:N,start:T,read:b}}function x0(e,t,n){const r=document.createRange();return r.selectNodeContents(e),r.setEnd(t,n),r.toString().length}function E0(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 kE(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)?x0(n,r.anchorNode,r.anchorOffset):null,l=r&&r.rangeCount>0&&o(r.focusNode)?x0(n,r.focusNode,r.focusOffset):null,u=r&&(i!==null||l!==null)?[r.anchorNode,r.anchorOffset,r.focusNode,r.focusOffset]:null;if(n.innerHTML=t,!r||!u)return;const[c,f]=i===null?[u[0],u[1]]:E0(n,i),[p,m]=l===null?[u[2],u[3]]:E0(n,l);c&&p&&r.setBaseAndExtent(c,f,p,m)},[e,t])}function vt(e,t){const n=S.useRef(t);n.current=t,S.useEffect(()=>n.current(),e)}function wE(e){const[t,n]=S.useState({left:0,right:0});return S.useLayoutEffect(()=>{if(!e)return;const r=()=>{const i=e.getBoundingClientRect();let{left:l,right:u}=i;const c=e.closest("[data-pinned]");if(c){const p=c.getBoundingClientRect(),m=c.offsetWidth/p.width;l=c.offsetLeft+(l-p.left)*m,u=c.offsetLeft+(u-p.left)*m}const f={left:Math.round(l),right:Math.round(u)};n(p=>p.left===f.left&&p.right===f.right?p:f)};r();const o=new ResizeObserver(r);return o.observe(e),window.addEventListener("resize",r),()=>{o.disconnect(),window.removeEventListener("resize",r)}},[e]),t}function _0(){const[e,t]=S.useState(null);return[t,wE(e)]}function Q7(e){e.ctrlKey&&e.stopPropagation()}function EL(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 _L(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 yE(e,t,n){const[r,o]=S.useState(),i=S.useRef(e);return i.current=e,S.useEffect(()=>{if(!n)return;let l=!0,u;const c=()=>void i.current().then(f=>{l&&(o(f),u=setTimeout(c,t))});return c(),()=>{l=!1,clearTimeout(u)}},[t,n]),r}const sl=()=>M(e=>e.activeId),vE=()=>mE(!M(e=>e.connected),900),_s=()=>M(e=>dn(e,e.activeId)),Wg=()=>M(e=>rs(e,e.activeId)),bE=()=>M(e=>e.rows),Zg=()=>M(e=>e.visible),SL=()=>M(e=>e.visibleDiscovered),NL=()=>M(e=>e.activeRepoId?e.discoveredOpen[e.activeRepoId]??!1:!1),S0=[],TL=()=>M(e=>e.activeRepoId?e.archived[e.activeRepoId]??S0:S0),jL=()=>M(e=>e.activeRepoId?e.archivedOpen[e.activeRepoId]??!1:!1),CL=()=>M(e=>!(e.activeRepoId&&e.committedShut[e.activeRepoId])),AL=()=>M(e=>!!(e.activeRepoId&&e.turnOpen[e.activeRepoId])),Hi=()=>M(So),qg=()=>M(tE),IL=()=>M(e=>ci(e,e.activeRepoId)),il=()=>M(e=>ci(e,Pg(e))),xE=e=>M(t=>_o(t,e)),Tt=(e,t)=>M(n=>_o(n,e)[t]),RL=()=>M(e=>e.overlay),yf=()=>M(FM),EE=()=>M(X1),Ac=()=>M(BM),Ic=()=>M(xo),$L=()=>M(e=>e.newProject),Ki=()=>M(e=>e.touch),OL=()=>M(e=>e.draft),Gg=()=>M(ql),ML=()=>M(e=>{const t=rs(e,e.activeId),n=t?e.repos.find(r=>r.id===t.repoId):null;return Od(n)?n:null});function LL(e){return e.image?{kind:"image",blob:e.image,sig:`image:${e.image.type}:${e.image.size}`}:e.text&&b1(e.text)?{kind:"text",text:e.text,sig:`text:${e.text}`}:null}function PL(){try{return localStorage.getItem(Ye.clipboardOffer)==="1"}catch{return!1}}let bs={access:"none",on:typeof localStorage<"u"&&PL(),offer:null},ym="";const vm=new Set;function vf(e){bs={...bs,...e};for(const t of vm)t()}async function DL(){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 LL({image:e,text:t})}async function bf({taken:e=!1,asking:t=!1}={}){if(!bs.on||!(bs.access==="granted"||t&&bs.access==="prompt"))return;let n;try{n=await DL()}catch{return}e&&(ym=(n==null?void 0:n.sig)??""),vf({offer:n&&n.sig!==ym?n:null})}const zL=()=>void bf();let N0=!1;function FL(){var e,t;N0||(N0=!0,!(!((e=navigator.clipboard)!=null&&e.read)||!((t=navigator.permissions)!=null&&t.query))&&navigator.permissions.query({name:"clipboard-read"}).then(n=>{const r=()=>{vf({access:n.state,...n.state==="denied"?{offer:null}:{}})};n.onchange=r,r(),window.addEventListener("focus",zL),document.hasFocus()&&bf()},()=>{}))}function BL(e){return vm.add(e),FL(),()=>{vm.delete(e)}}const UL=()=>bs;function HL(e){try{localStorage.setItem(Ye.clipboardOffer,e?"1":"0")}catch{}vf({on:e,offer:null}),e&&bf({asking:!0})}function _E(){bs.offer&&(ym=bs.offer.sig),vf({offer:null})}const KL=()=>void bf({taken:!0});function WL(){return S.useSyncExternalStore(BL,()=>bs.offer)}const SE="application/x-toyon-source";function J7(e){const t=e.endColumn===1&&e.endLineNumber>e.startLineNumber?e.endLineNumber-1:e.endLineNumber;return{startLine:e.startLineNumber,endLine:t}}function ZL(e,t){e.setData(SE,JSON.stringify(t))}const T0=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1;function qL(e,t){const n=e.getData(SE);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!T0(o)||!T0(i)||i<o?null:{path:r.path,startLine:o,endLine:i,...typeof l=="string"?{ref:l}:{}}}const NE=e=>({left:e.x,top:e.y,right:e.x,bottom:e.y});function GL(e,t){return t.matchWidth===void 0?void 0:Math.max(0,e.right-e.left+t.matchWidth)}const VL=new Set(["top","bottom"]),Tp={top:"bottom",bottom:"top",left:"right",right:"left"};function jp(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 j0(e,t,n,r,o){return n==="top"||n==="left"?e>=o:e+t<=r-o}function Cp(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 C0(e,t,n,r,o){return n==="start"?e+t<=r-o:e>=o}const A0=(e,t,n,r)=>n||!r?e:t,I0=(e,t,n,r)=>Math.max(r,Math.min(e,n-r-t));function YL(e,t,n,r){const{offset:o=0,alignOffset:i=0,cover:l=!1,flip:u="none",margin:c=8}=r,f=VL.has(r.side),p=f?{a:{start:e.top,end:e.bottom},size:t.h,limit:n.h}:{a:{start:e.left,end:e.right},size:t.w,limit:n.w},m=f?{a:{start:e.left,end:e.right},size:t.w,limit:n.w}:{a:{start:e.top,end:e.bottom},size:t.h,limit:n.h};let g=r.side;if(u==="side"||u==="both"){const b=jp(p.a,p.size,g,o,l),j=jp(p.a,p.size,Tp[g],o,l);g=A0(g,Tp[g],j0(b,p.size,g,p.limit,c),j0(j,p.size,Tp[g],p.limit,c))}let w=r.align??"center";if((u==="align"||u==="both")&&w!=="center"){const b=w==="start"?"end":"start",j=Cp(m.a,m.size,w,i),N=Cp(m.a,m.size,b,i);w=A0(w,b,C0(j,m.size,w,m.limit,c),C0(N,m.size,b,m.limit,c))}const y=I0(jp(p.a,p.size,g,o,l),p.size,p.limit,c),x=I0(Cp(m.a,m.size,w,i),m.size,m.limit,c);return f?{x,y,side:g,align:w}:{x:y,y:x,side:g,align:w}}function XL(e,t,n){var i,l;const r=e.length;if(r===0)return-1;let o=t<0?n===1?0:r-1:(t+n+r)%r;for(let u=0;u<r&&((i=e[o])!=null&&i.disabled);u++)o=(o+n+r)%r;return(l=e[o])!=null&&l.disabled?-1:o}const TE={sep:!0},xs=e=>!("sep"in e);function xf(e){const t=[];for(const n of e)(xs(n)||t.length>0&&xs(t[t.length-1]))&&t.push(n);for(;t.length>0&&!xs(t[t.length-1]);)t.pop();return t}const Dn=e=>xf(e.flatMap((t,n)=>n?[TE,...t]:t));let Ta=null,QL=0;const bm=new Set,R0=()=>{for(const e of bm)e()},to={get:()=>Ta,subscribe(e){return bm.add(e),()=>{bm.delete(e)}},open(e){const t=xf(e.items);if(t.length===0)return to.close();Ta={...e,items:t,id:++QL},R0()},close(){Ta&&(Ta=null,R0())},toggle(e){Ta&&Ta.target===e.target?to.close():to.open(e)}};function Vg(){return S.useSyncExternalStore(to.subscribe,to.get)}function jE(e){const t=e.nativeEvent;return t&&"pointerType"in t?t.pointerType==="":e.clientX===0&&e.clientY===0}function JL(e,t){return jE(e)?{anchor:(t.querySelector('[data-state~="cursor"]')??t).getBoundingClientRect()}:{at:{x:e.clientX,y:e.clientY}}}function eP(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:NE(e.at??{x:0,y:0}),placement:{side:"bottom",align:"start",margin:4}}}function fn(e){return S.useMemo(()=>({contextMenu(t,n){return{onContextMenu:r=>{const o=xf(t(jE(r)?"keyboard":"pointer",r.target));if(o.length===0)return;r.preventDefault(),r.stopPropagation();const i=r.currentTarget;to.open({items:o,owner:e,key:n,target:i,...JL(r,i)})}}},dropdown(t,n="left",r){return{"aria-haspopup":"menu",onClick:o=>{o.stopPropagation();const i=o.currentTarget;to.toggle({items:t(),owner:e,key:r,target:i,toggles:!0,anchor:i.getBoundingClientRect(),align:n})}}},openUnder(t,n,r){to.open({items:n(),owner:e,key:r,target:t,toggles:!0,anchor:t.getBoundingClientRect(),align:"left"})}}),[e])}const CE=e=>({id:"open-out",label:gf()?"open in the browser":"open in a new tab",onClick:()=>window.open(e,"_blank")}),Qt=e=>{var t;return void((t=navigator.clipboard)==null?void 0:t.writeText(e).catch(()=>{}))};function AE(e,t){const n=navigator.clipboard;if(n){if(typeof ClipboardItem>"u"||!n.write){e==="text/plain"&&t.then(r=>r.text()).then(Qt,()=>{});return}n.write([new ClipboardItem({[e]:t})]).catch(()=>{})}}const tP=e=>AE("text/plain",fetch(e).then(t=>t.blob())),nP=e=>AE("image/png",rP(e));async function rP(e){const t=await(await fetch(e)).blob();if(t.type==="image/png")return t;const n=await createImageBitmap(t);try{const r=document.createElement("canvas");return r.width=n.width,r.height=n.height,r.getContext("2d").drawImage(n,0,0),await new Promise((o,i)=>r.toBlob(l=>l?o(l):i(new Error("could not encode image")),"image/png"))}finally{n.close()}}const oP=[{label:"Zed",scheme:"zed"},{label:"VS Code",scheme:"vscode"},{label:"Cursor",scheme:"cursor"}];function Yg(e){return ug(e)}function os(e){return(e==null?void 0:e.urls.host)??(typeof location=="object"?location.hostname:"127.0.0.1")}function Bi(e,t,n){if(!Yg(n))return[];const r=oP.map(o=>({id:`open:${o.scheme}`,label:`open in ${o.label}`,onClick:()=>{window.location.href=`${o.scheme}://file${e}`}}));return r.push(...Ef(t,n)),r}function Ef(e,t){return!e||!Yg(t)?[]:[{id:"reveal",label:"reveal in Finder",onClick:e}]}function sP(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 _f(e,t,{sock:n,dispatch:r}){var l,u;if(!n)return;const o=t.local[e]??ol,i=sP((l=o.git)==null?void 0:l.head,((u=o.git)==null?void 0:u.files)??[]);o.filesFor!==i&&(r({a:"files-asked",worktreeId:e,key:i}),n.send({t:"list-files",worktreeId:e}))}const iP=["diff","file","preview"],IE=(e,t)=>iP.filter(n=>!(n==="preview"&&!pf(e))&&!(n==="diff"&&t));let aP=0;const Ko=()=>++aP;function er({dispatch:e},{focus:t=!0,...n}){e({a:"open-file",v:{...n,focus:t,seq:Ko()}})}const xm=new Map;function RE(e,t,n=""){const{sock:r}=e;if(!r)return Promise.resolve("not connected to the daemon");const o=Ko();return new Promise(i=>{xm.set(o,l=>{l.ok?(er(e,{...t,view:Fi(t.path)}),i(null)):i(l.reason==="changed"?"a file is already there":l.message??"the file was not made")}),r.send({t:"write-file",...t,content:n,base:null,seq:o})})}function lP(e){const t=xm.get(e.seq);return t?(xm.delete(e.seq),t(e),!0):!1}function cP({dispatch:e},t){e({a:"tree-reveal",...t})}function ys(e,t,{discard:n=!1,ref:r,since:o,showing:i,added:l=!1,kept:u=!1,select:c},f){const{sock:p,dispatch:m}=f,g=IE(t,l).filter(N=>N!==i).map(N=>({id:`view:${N}`,label:`view ${N}`,onClick:()=>i?m({a:"editor-view",v:N}):er(f,{worktreeId:e.id,path:t,view:N,ref:r,since:o})})),w=`${e.dir}/${t}`,y=u?[]:Bi(w,()=>p==null?void 0:p.send({t:"reveal",worktreeId:e.id,path:t}),os(p));return Dn([g,[{id:"copy-path",label:"copy path",onClick:()=>Qt(w)}],y,c?[{id:"select",label:"select…",onClick:()=>c(t)}]:[],n?[{id:"discard",label:"discard changes…",danger:!0,onClick:()=>{window.confirm($E([t]))&&(p==null||p.send({t:"discard-files",worktreeId:e.id,paths:[t]}))}}]:[]])}function $E(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 ho=(e,t,n)=>e.dispatch({a:"notice",id:t,text:n});function Sf(e,t,n){var o;const r=Nj(((o=e.getState().local[t])==null?void 0:o.attachments)??[],n);return r===0&&ho(e,t,ag(n)),r}const uP=1e3,dP=1e4,OE=new WeakMap;function fP(e,t){OE.set(e,t)}async function ME(e,t,n,r){var m;const{local:o,...i}=n;e.dispatch({a:"attach",id:t,items:[{...n,upload:"",uploading:!0}]});const l=()=>{var g;return!!((g=e.getState().local[t])!=null&&g.attachments.some(w=>w.key===n.key))},u=OE.get(e),c=()=>u?X2(u,n.kind,r):Promise.resolve(null);let f=await c();const p=f===null;p&&ho(e,t,`${n.name}: Toyon is not answering; it attaches once it is back`);for(let g=uP;f===null&&l();g=Math.min(g*2,dP))await new Promise(w=>setTimeout(w,g)),l()&&(f=await c());if(f!==null)if(typeof f=="string")e.dispatch({a:"detach",id:t,key:n.key}),ho(e,t,`${n.name}: ${f}`);else{const g=i.kind==="file"?{...i,...f}:{...i,upload:f.upload,bytes:f.bytes};e.dispatch({a:"attached",id:t,key:n.key,item:g});const w=(m=e.getState().local[t])==null?void 0:m.notice;p&&(w!=null&&w.startsWith(`${n.name}: Toyon is not answering`))&&ho(e,t,"")}o&&URL.revokeObjectURL(o)}function Xg(e,t,n){if(!t||n.length===0)return;const r=Sf(e,t,"file");if(r!==0){for(const o of n.slice(0,r)){const i=o.name||"file";if(o.size>Yv){ho(e,t,`${i}: larger than ${cg(Yv)}`);continue}const l={kind:"file",key:crypto.randomUUID(),upload:"",name:i,bytes:o.size,text:!1};ME(e,t,l,o)}n.length>r&&ho(e,t,`kept ${r} of ${n.length}: ${ag("file")}`)}}function Qg(e,t,n,r={}){if(!t)return;const o=WO(r.source?n.replace(/\r?\n$/,""):n);if(o.length>PO)return r.source?ho(e,t,"that paste is too large; save it in the worktree and reference it with @path"):Xg(e,t,[new File([o],DO,{type:"text/plain"})]);Sf(e,t,"paste")!==0&&e.dispatch({a:"attach",id:t,items:[{kind:"paste",key:crypto.randomUUID(),text:o,...r,...vg(o)}]})}function LE(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 $0(e,t){var i;const n=e.getState(),r=dn(n,n.activeId),o=Cc(r);if(t&&o&&t.worktreeId===(r==null?void 0:r.worktree.id)&&t.text.trim()){const l="source"in t?{source:t.source}:{name:t.name};(((i=n.local[o])==null?void 0:i.attachments)??[]).some(c=>{var w;if(c.kind!=="paste")return!1;if(!("source"in t))return c.name===t.name&&c.text===t.text;const{path:f,startLine:p,endLine:m,ref:g}=t.source;return((w=c.source)==null?void 0:w.path)===f&&c.source.startLine===p&&c.source.endLine===m&&c.source.ref===g})||Qg(e,o,t.text,l)}e.dispatch(t?{a:"focus-chat"}:Q1(n))}function Nf(e,t){return t!==e.activeId?null:Cc(dn(e,t))}const Jg=(e,t)=>`@${e}${t?"/":""}`;function ek(e,t,n){var u;const r=e.getState(),o=Nf(r,t);if(!o)return;const i=((u=r.local[o])==null?void 0:u.draft)??"",l=i===""||/\s$/.test(i)?"":" ";e.dispatch({a:"set-draft",id:o,text:`${i}${l}${n}`}),e.dispatch({a:"focus-chat"})}function PE(e,t,n,r){ek(e,t,`${Jg(n,r)} `)}function hP(e,t,n){n.length!==0&&ek(e,t,`${n.map(r=>Jg(r,!1)).join(" ")} `)}function O0(e,t,n){ek(e,t,n)}function pP(e,t){return dn(e,t)?t:null}function mP(e,t){var r;const n=(r=dn(e,t))==null?void 0:r.worktree;return n?[n.path]:[]}function M0(e,t){if(!e)return e;const n=t.find(r=>e.startsWith(`${r}/`));return n?e.slice(n.length+1):e}function gP(e,t,n){var g;e.dispatch({a:"set-picking",v:!1});const r=e.getState(),o=pP(r,t);if(!o)return;const{classes:i,route:l,element:u,...c}=n,f=mP(r,t),p={...c,file:M0(c.file,f),callFile:M0(c.callFile,f)};!(((g=r.local[o])==null?void 0:g.attachments)??[]).some(w=>w.kind==="pick"&&w.selector===p.selector)&&Sf(e,o,"pick")>0&&e.dispatch({a:"attach",id:o,items:[{kind:"pick",key:crypto.randomUUID(),...p}]}),e.dispatch({a:"focus-chat"})}function kP(e,t=[],n=[]){const r={path:"",name:"",kind:"folder",children:[],ignored:!1},o=new Map([["",r]]),i=c=>{const f=o.get(c);if(f)return f;const p=c.lastIndexOf("/"),m={path:c,name:c.slice(p+1),kind:"folder",children:[],ignored:!1};return i(p===-1?"":c.slice(0,p)).children.push(m),o.set(c,m),m},l=(c,f,p=!1)=>{const m=c.lastIndexOf("/");i(m===-1?"":c.slice(0,m)).children.push({path:c,name:c.slice(m+1),kind:f,children:[],ignored:p})};for(const c of e)l(c,"file");for(const c of t)l(c,"submodule");for(const c of n)c.endsWith("/")?l(c.slice(0,-1),"ignored",!0):l(c,"file",!0);const u=c=>{const f=p=>p.kind==="file"?1:0;c.children.sort((p,m)=>f(p)-f(m)||W1(p.name,m.name));for(const p of c.children)p.kind==="folder"&&u(p)};return u(r),r.children}function wP(e,t){const n=[],r=(o,i)=>{for(const l of o){const u=l.kind==="folder"&&t(l.path);n.push({path:l.path,name:l.name,depth:i,kind:l.kind,open:u,ignored:l.ignored}),u&&r(l.children,i+1)}};return r(e,0),n}const DE=e=>{const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)};function yP(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 vP(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 $d(o))n.add(i)}return{files:t,folders:n}}function tk(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 bP(e){const t=e?tk(e.chat):null;return(t==null?void 0:t.kind)!=="ask"||t.ask.kind!=="question"||(e==null?void 0:e.cardParked)===t.id?null:Da(t.id)}function xP(e){return e.kind==="ask"?uM(e):`Continue in ${e.repo.name}?`}function EP(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 _P(e,t,n){const r=e.trim();if(!r)return{pick:!0};if(t.length<2)return{error:"open another project first"};const o=r.search(/\s/),i=o===-1?r:r.slice(0,o),l=o===-1?void 0:r.slice(o).trim()||void 0,u=i.toLowerCase(),c=t.filter(m=>m.name.toLowerCase()===u),f=c.length>0?c:t.filter(m=>m.name.toLowerCase().startsWith(u));if(f.length===0)return{error:`no open project named "${i}"`};if(f.length>1)return{error:`"${i}" names more than one project`};const p=f[0];return p.id===n?{error:`this worktree is already in ${p.name}`}:{repo:p,...l?{text:l}:{}}}const zE=new Set(OO),SP=/^image\.[a-z0-9]+$/i,NP=e=>SP.test(e.name),TP=(e,t)=>e===t||e.name===t.name&&e.size===t.size&&e.type===t.type&&e.lastModified===t.lastModified;function jP(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=>TP(l,i))||n.push(i);const r=n.filter(i=>!NP(i));if(r.length>0)return r;const o=n.find(i=>zE.has(i.type))??n[0];return o?[o]:[]}function CP(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 AP(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 IP(e){try{return await createImageBitmap(e)}catch{throw new Error(`${e.name||"image"}: not a readable image`)}}function L0(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 RP(e){const t=await IP(e);try{const n=Math.max(t.width,t.height);let r=e,o=e.type,i=t.width,l=t.height;if(!zE.has(o)||n>Vv||e.size>_p){const u=o==="image/jpeg"?"image/jpeg":"image/png";let c=Math.min(1,Vv/n);for(r=await L0(t,c,u);r.size>_p&&c>.1;)c*=.7,r=await L0(t,c,u);if(r.size>_p)throw new Error(`${e.name||"image"}: too large even after downscaling`);o=u,i=Math.max(1,Math.round(t.width*c)),l=Math.max(1,Math.round(t.height*c))}return{blob:r,name:e.name||`pasted.${o==="image/jpeg"?"jpg":"png"}`,mimeType:o,width:i,height:l}}finally{t.close()}}const rc={el:null},$P=80,OP=2e3;let ns=null,Em;const FE=(e,t)=>{clearTimeout(Em),Em=setTimeout(()=>rk(e),t)};function nk(e,t){ns??(ns={refused:!1}),e.dispatch({a:"drag-files",v:ns.refused?null:t}),FE(e,OP)}function MP(e){ns&&FE(e,$P)}function rk(e){clearTimeout(Em),ns=null,e.dispatch({a:"drag-files",v:null})}function LP(e){ns&&(ns.refused=!0,e.dispatch({a:"drag-files",v:null}))}const BE="application/x-toyon-path";let Ri=null;function PP(e){Ri=e}function UE(e){Ri=null,ns&&rk(e)}const P0=e=>Ri!==null&&Array.from(e.dataTransfer.types).includes(BE);function DP(e){return{onDragOver:t=>{if(!P0(t)||!Ri)return;t.preventDefault();const n=Nf(e.getState(),Ri.worktreeId)!==null;t.dataTransfer.dropEffect=n?"copy":"none",n&&nk(e,{at:"chat"})},onDrop:t=>{if(!P0(t)||!Ri)return;t.preventDefault();const{worktreeId:n,path:r,folder:o}=Ri;UE(e),PE(e,n,r,o)}}}let zP=0;function FP(e){const{blob:t,...n}=e;return{kind:"image",key:`img${++zP}`,...n,upload:"",bytes:t.size,local:URL.createObjectURL(t)}}async function Tf(e,t,n){var l;if(!t||n.length===0)return;const r=Sf(e,t,"image");if(r===0)return;const o=await Promise.allSettled(n.slice(0,r).map(RP));for(const u of o)u.status==="fulfilled"&&ME(e,t,FP(u.value),u.value.blob);const i=o.find(u=>u.status==="rejected");i?ho(e,t,String(((l=i.reason)==null?void 0:l.message)??i.reason)):n.length>r&&ho(e,t,`kept ${r} of ${n.length}: ${ag("image")}`)}function BP(e,t,n){n.kind==="image"?Tf(e,t,[new File([n.blob],"image.png",{type:n.blob.type})]):Qg(e,t,n.text),_E()}function HE(e,t,n){const r=o=>o.type.startsWith("image/");Tf(e,t,n.filter(r)),Xg(e,t,n.filter(o=>!r(o)))}function KE(e,t,{images:n=!1}={}){const r=document.createElement("input");r.type="file",r.multiple=!0,n&&(r.accept="image/*"),r.onchange=()=>HE(e,t,Array.from(r.files??[])),r.click()}const Ia="still uploading what is attached; send again in a moment";function Rc(e){const t=e.getState();if(t.newProject)return Ya;const n=dn(t,t.activeId);return bP(n?t.local[n.worktree.id]:void 0)??Cc(n)}function UP(e,t){const n=Rc(e);HE(e,n,t.filter(o=>!o.folder).map(o=>o.file));const r=t.find(o=>o.folder);n&&r&&ho(e,n,`${r.file.name}: a folder cannot be attached; drop its files`)}const _m=Promise.resolve(null);function HP(e){var n,r,o;if(!e)return[];const t=[];for(const i of Array.from(e.items)){if(i.kind!=="file")continue;const l=i.getAsFile();if(!l)continue;const u=((n=i.getAsFileSystemHandle)==null?void 0:n.call(i).then(c=>(c==null?void 0:c.kind)==="file"?c:null,()=>null))??_m;t.push({file:l,handle:u,folder:((o=(r=i.webkitGetAsEntry)==null?void 0:r.call(i))==null?void 0:o.isDirectory)===!0})}if(t.length===0)for(const i of Array.from(e.files))t.push({file:i,handle:_m});return t}const KP=e=>e.map(t=>({file:t,handle:_m}));async function WE(e){const t=Ad*4;if(e.size>t)return{text:"",tooLarge:!0};const n=await AP(e,t);return n===null?null:n.length>Ad?{text:"",tooLarge:!0}:{text:n,tooLarge:!1}}async function WP(e,t){const n=Rc(e),r=e.getState().activeId,o=p=>n&&ho(e,n,p),i=t.filter(p=>p.file.type.startsWith("image/")).map(p=>p.file);i.length&&Tf(e,n,i);const l=t.filter(p=>!p.file.type.startsWith("image/")),u=l[0];if(!u||!r)return;const c=await WE(u.file);if(!c)return void o(`${u.file.name}: not a text file`);const f=await u.handle;e.dispatch({a:"open-loose",v:{worktreeId:r,name:u.file.name,...c,binary:!1,source:f?{kind:"handle",handle:f}:{kind:"bytes"},seq:Ko()}}),l.length>1&&o(`opened ${u.file.name}; one file opens at a time`)}async function ZP(e,t,n,r){const o=Nf(e.getState(),n.worktreeId)??Rc(e),i=u=>o&&ho(e,o,u),l={sock:t,dispatch:u=>e.dispatch(u)};for(const{file:u}of r){const c=await WE(u);if(!c){i(`${u.name}: not a text file`);continue}if(c.tooLarge){i(`${u.name}: too large to add here`);continue}const f=n.dir?`${n.dir}/${u.name}`:u.name,p=await RE(l,{worktreeId:n.worktreeId,path:f},c.text);p&&i(`${u.name}: ${p}`)}}function qP(e){const t=Rc(e);t&&ho(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 ZE(e,t,n,r){const o=(ns==null?void 0:ns.refused)??!1;rk(e),!(o||r.length===0)&&(n?n.at==="chat"||n.at==="centre"&&e.getState().newProject?UP(e,r):n.at==="centre"?WP(e,r):ZP(e,t,n,r):qP(e))}const D0=e=>!!e&&Array.from(e.types).includes("Files");function z0(e,t){var l;const n=t instanceof Element?t:t instanceof Node?t.parentElement:null;if(!n)return null;if((l=rc.el)!=null&&l.contains(n))return Rc(e)?{at:"chat"}:null;const r=n.closest(".tree"),o=r==null?void 0:r.dataset.worktree;if(r&&o){const u=n.closest("[data-path]"),c=u==null?void 0:u.dataset.kind;if(c==="submodule")return null;const f=(u==null?void 0:u.dataset.path)??"";return{at:"tree",worktreeId:o,dir:c==="file"?DE(f):f}}if(!n.closest(".center-root")||n.closest('[data-pane="terminal"], [data-pane="design"]'))return null;const i=e.getState();return i.activeId||i.newProject?{at:"centre"}:null}function GP(){const e=Zn(),t=lt();S.useEffect(()=>{const n=l=>{l.defaultPrevented||!D0(l.dataTransfer)||(l.preventDefault(),nk(e,z0(e,l.target)),l.dataTransfer&&(l.dataTransfer.dropEffect=e.getState().dragFiles?"copy":"none"))},r=l=>{l.defaultPrevented||!D0(l.dataTransfer)||(l.preventDefault(),ZE(e,t,z0(e,l.target),HP(l.dataTransfer)))},o=()=>MP(e),i=l=>{l.key==="Escape"&&LP(e)};return window.addEventListener("dragover",n),window.addEventListener("drop",r),window.addEventListener("dragleave",o),window.addEventListener("keydown",i,!0),()=>{window.removeEventListener("dragover",n),window.removeEventListener("drop",r),window.removeEventListener("dragleave",o),window.removeEventListener("keydown",i,!0)}},[e,t])}function qE(e,t){const n=Zn(),r=S.useRef(!1);return{onPaste:u=>{KL();const c=jP(u.clipboardData);if(c.length>0)return u.preventDefault(),void Tf(n,e,c);const f=CP(u.clipboardData);if(f.length>0)return u.preventDefault(),Xg(n,e,f);if(r.current)return;const p=u.clipboardData.getData("text/plain"),m=p.trim()?qL(u.clipboardData,t):null;!(m&&p.includes(`
|
|
103
|
+
`))&&!b1(p)||(u.preventDefault(),Qg(n,e,p,m?{source:m}:{}))},onPasteKey:u=>{r.current=(u.metaKey||u.ctrlKey)&&u.shiftKey&&u.key.toLowerCase()==="v"},onPasteKeyUp:()=>{r.current=!1}}}const GE=(e,t)=>`${e}${e.includes("?")?"&":"?"}${Yj}=${encodeURIComponent(t)}`,Sm=(e,t)=>!e.serving&&t!==null,VP=3e3;function VE(e,t,n){const[r,o]=S.useState(()=>new Map),i=S.useRef(new Set),l=S.useRef(t);l.current=t;const u=S.useRef(new Map),c=S.useCallback((f,p)=>{i.current.has(f)||(i.current.add(f),M1(e.sock.urls).then(m=>{if(i.current.delete(f),!!l.current.some(w=>w.id===f&&w.url===p)){if(!m){u.current.set(f,setTimeout(()=>{u.current.delete(f),l.current.some(w=>w.id===f&&w.url===p)&&c(f,p)},VP));return}o(w=>new Map(w).set(f,{url:p,src:GE(p,m.code)}))}}))},[e]);return S.useEffect(()=>{const f=u.current;return()=>{for(const p of f.values())clearTimeout(p);f.clear()}},[]),S.useEffect(()=>{var p;if(!n)return;for(const m of t)((p=r.get(m.id))==null?void 0:p.url)!==m.url&&c(m.id,m.url);const f=new Set(t.map(m=>m.id));[...r.keys()].some(m=>!f.has(m))&&o(m=>new Map([...m].filter(([g])=>f.has(g))))},[n,t,r,c]),{urlOf:f=>{var p,m;return n?((p=r.get(f))==null?void 0:p.src)??null:((m=t.find(g=>g.id===f))==null?void 0:m.url)??null},renew:f=>{const p=t.find(m=>m.id===f);!p||!n||(o(m=>{const g=new Map(m);return g.delete(f),g}),c(f,p.url))}}}function YP(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}]),VE(e,r.current,n).urlOf("one")}function XP(e,t,n){if(!n){window.open(t,"_blank");return}const r=window.open("","_blank");M1(e.sock.urls).then(o=>{const i=o?GE(t,o.code):t;r?r.location.href=i:window.open(i,"_blank")})}function Ue(...e){return e.filter(Boolean).join(" ")}const QP={branch:"M4.5 5.1v5.8 M11.5 6.6c0 2.6-7 1.6-7 4.3 M4.5 1.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M4.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 3.4a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z",chat:"M2.5 3.5a1.5 1.5 0 0 1 1.5-1.5h8a1.5 1.5 0 0 1 1.5 1.5v6a1.5 1.5 0 0 1-1.5 1.5H7l-3.2 2.6V11H4a1.5 1.5 0 0 1-1.5-1.5z",settings:"M12.38 6.99 14.05 7.26 14.05 8.74 12.38 9.01 11.82 10.38 12.81 11.76 11.76 12.81 10.38 11.82 9.01 12.38 8.74 14.05 7.26 14.05 6.99 12.38 5.62 11.82 4.24 12.81 3.19 11.76 4.18 10.38 3.62 9.01 1.95 8.74 1.95 7.26 3.62 6.99 4.18 5.62 3.19 4.24 4.24 3.19 5.62 4.18 6.99 3.62 7.26 1.95 8.74 1.95 9.01 3.62 10.38 4.18 11.76 3.19 12.81 4.24 11.82 5.62z M8 6.4a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z",zen:"M2 6V3a1 1 0 0 1 1-1h3 M10 2h3a1 1 0 0 1 1 1v3 M14 10v3a1 1 0 0 1-1 1h-3 M6 14H3a1 1 0 0 1-1-1v-3",back:"M9.5 3.5 5 8l4.5 4.5",forward:"M6.5 3.5 11 8l-4.5 4.5",reload:"M13.5 2.5v3.5H10 M12.4 9.2a4.8 4.8 0 1 1-1-4.9l2.1 1.7",pick:"M8 4.2a3.8 3.8 0 1 0 0 7.6 3.8 3.8 0 1 0 0-7.6z M8 1.5v2.7 M8 11.8v2.7 M1.5 8h2.7 M11.8 8h2.7",inspect:"M6.5 13.5h-3a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1h9a1 1 0 0 1 1 1v3 M8.2 8.2l5.3 2-2.3.9-.9 2.3z",terminal:"M2 3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1z M4.8 5.6 7.4 8l-2.6 2.4 M8.6 10.6h2.8",close:"M4.2 4.2 11.8 11.8 M11.8 4.2 4.2 11.8",edit:"M10.6 2.6 13.4 5.4 5.8 13H3v-2.8z M9.2 4l2.8 2.8 M3 10.2l2.8 2.8",check:"M3.4 8.4 6.4 11.4 12.6 4.6",split:"M2.5 2.5h11v11h-11z M2.5 8h11",full:"M2.5 2.5h11v11h-11z",more:"M3.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M7.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M11.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z",caret:"M4.5 6.5 8 10l3.5-3.5","caret-up":"M4.5 9.5 8 6l3.5 3.5",stop:"M4.5 4.5h7v7h-7z",send:"M8 13V3.2 M4 7.2 8 3.2l4 4",external:"M9 3h4v4 M13 3 8 8 M11.5 9.5V13H3V4.5h3.5",plus:"M8 3.5v9 M3.5 8h9",download:"M8 2.5v7.4 M4.9 6.8 8 9.9l3.1-3.1 M3 13h10",copy:"M5.5 5.5h8v8h-8z M10.5 5.5v-3h-8v8h3",pull:"M8 3.2v7.4 M4.9 7.4 8 10.6l3.1-3.2",layers:"M6 2.5h7.5V10 M2.5 6h8v7.5h-8z",text:"M3.5 3.5h9 M3.5 6.5h9 M3.5 9.5h9 M3.5 12.5h5",file:"M4.5 2.5h4.5l2.5 2.5v8.5h-7z M9 2.5V5h2.5",diff:"M8 2.8v5 M5.5 5.3h5 M5.5 11.2h5",folder:"M2.2 3.9a1 1 0 0 1 1-1h2.9l1.5 1.7h5.2a1 1 0 0 1 1 1v5.9a1 1 0 0 1-1 1H3.2a1 1 0 0 1-1-1z",book:"M8 4.6c-1.2-1-2.7-1.4-4.4-1.3v7.6c1.7-.1 3.2.3 4.4 1.3 1.2-1 2.7-1.4 4.4-1.3V3.3c-1.7-.1-3.2.3-4.4 1.3z M8 4.6v8.6",trash:"M3.6 4.6h8.8 M6.4 4.6V3.2a.7.7 0 0 1 .7-.7h1.8a.7.7 0 0 1 .7.7v1.4 M5 4.6l.55 8.1a.9.9 0 0 0 .9.84h3.1a.9.9 0 0 0 .9-.84L11 4.6",move:"M2.8 8h9.2 M8.9 4.9 12 8l-3.1 3.1",search:"M7.2 2.6a4.6 4.6 0 1 0 0 9.2 4.6 4.6 0 1 0 0-9.2z M10.5 10.5 13.5 13.5",run:"M3.4 4.2 7.6 8l-4.2 3.8 M9 11.8h4",bulb:"M4.8 8.8a4 4 0 1 1 6.4 0L9.5 10.6v1.4H6.5v-1.4z M6.7 13.8h2.6",spawn:"M2.5 8h3.3 M5.8 8c2.2 0 2.2-3.6 4.4-3.6h1.5 M5.8 8c2.2 0 2.2 3.6 4.4 3.6h1.5 M12.05 4.4a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M12.05 11.6a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z",globe:"M8 2.2a5.8 5.8 0 1 0 0 11.6 5.8 5.8 0 1 0 0-11.6z M2.2 8h11.6 M8 2.2c-3 3.4-3 8.2 0 11.6 3-3.4 3-8.2 0-11.6z",worktrees:"M3.8 2.95a1.05 1.05 0 1 0 0 2.1 1.05 1.05 0 1 0 0-2.1z M7.4 4h5.4 M3.8 6.95a1.05 1.05 0 1 0 0 2.1 1.05 1.05 0 1 0 0-2.1z M7.4 8h5.4 M3.8 10.95a1.05 1.05 0 1 0 0 2.1 1.05 1.05 0 1 0 0-2.1z M7.4 12h5.4",swap:"M3 6.2h9.2 M9.7 3.7 12.2 6.2 9.7 8.7 M13 10.2H3.8 M6.3 7.7 3.8 10.2l2.5 2.5",palette:"M2.3 8.4C2.3 4.7 5 2.2 8.5 2.2c3.4 0 5.2 2.2 5.2 4.6 0 1.9-1.4 2.6-2.7 2.8-.9.15-1.3.7-1.1 1.4.2.9-.5 2.2-2.1 2.2-3.2 0-5.5-2-5.5-4.8z M5 6.2a.5.5 0 1 0 0 1 .5.5 0 1 0 0-1z M7.8 4.9a.5.5 0 1 0 0 1 .5.5 0 1 0 0-1z M11 5.8a.5.5 0 1 0 0 1 .5.5 0 1 0 0-1z",lock:"M4.4 7.3h7.2v6.1H4.4z M6.2 7.3V5.5a1.8 1.8 0 0 1 3.6 0v1.8",phone:"M5.4 2.2h5.2a1.2 1.2 0 0 1 1.2 1.2v9.2a1.2 1.2 0 0 1-1.2 1.2H5.4a1.2 1.2 0 0 1-1.2-1.2V3.4a1.2 1.2 0 0 1 1.2-1.2z M7.1 11.6h1.8",pr:"M4.5 5.1v5.8 M4.5 1.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M4.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 10.9V6.6a2 2 0 0 0-2-2H8 M9.6 2.9 7.9 4.6l1.7 1.7",clock:"M8 2.2a5.8 5.8 0 1 0 0 11.6 5.8 5.8 0 1 0 0-11.6z M8 4.8V8l2.2 1.4",archive:"M2.4 3.2h11.2v2.8H2.4z M3.4 6v6.1a.9.9 0 0 0 .9.9h7.4a.9.9 0 0 0 .9-.9V6 M6.6 8.6h2.8",attach:"M13.7 7.4 8.2 12.9a3.6 3.6 0 0 1-5.1-5.1l5.5-5.5a2.4 2.4 0 0 1 3.4 3.4l-5.5 5.5a1.2 1.2 0 0 1-1.7-1.7l5.1-5.1",dot:"M8 4.6a3.4 3.4 0 1 0 0 6.8 3.4 3.4 0 1 0 0-6.8z"};function jt({name:e,className:t}){return h.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:h.jsx("path",{d:QP[e]})})}function el({size:e="inline",variant:t="ring",className:n}){return h.jsx("span",{className:Ue("spinner",e==="dot"&&"spinner-dot",t==="squares"&&"spinner-squares",n),"aria-hidden":"true",children:t==="squares"&&h.jsxs(h.Fragment,{children:[h.jsx("span",{}),h.jsx("span",{}),h.jsx("span",{}),h.jsx("span",{})]})})}const JP='button, a[href], input, textarea, select, summary, label, [role="button"], [role="menuitem"]';function F0(e){var n;const t=e;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,JP))??t??null}function e4(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 t4(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 n4(e,t){const n=new Set;for(const r of e)if(e4(r,t))for(let o=r;o;o=o.parent)n.add(o);return e.filter(r=>!n.has(r)&&r.dismiss).reverse()}const r4=e=>{setTimeout(e,0)};function o4({schedule:e=r4}={}){let t=[],n=null,r=!1;const o=new Set,i=()=>{for(const u of[...o])u()},l=u=>{var c;for(const f of[...t].reverse())(c=f.dismiss)==null||c.call(f,u)};return{register(u){const c=u.trigger??(u.from===void 0?n:null),f={box:u.box,trigger:c,parent:t4(t,u.from??c),dismiss:u.dismiss,onKey:u.onKey,back:u.back};return t=[...t,f],i(),f},unregister(u){t=t.filter(c=>c!==u),i()},top:()=>t[t.length-1]??null,open:()=>t,watch(u){return o.add(u),()=>o.delete(u)},shut(u){var c;u.back?u.back():(c=u.dismiss)==null||c.call(u,"outside")},install(u){const c=u.document,f=x=>{var N;const b=x.target,j=b?n4(t,b):[];for(const T of j)(N=T.dismiss)==null||N.call(T,"outside");r=j.length>0&&x.pointerType==="touch",r&&x.preventDefault(),n=F0(x.target)},p=()=>e(()=>n=null),m=()=>{r=!1,p()},g=x=>{if(r){r=!1,x.preventDefault(),x.stopPropagation();return}n||(n=F0(x.target),p())},w=x=>{var j;const b=t[t.length-1];(j=b==null?void 0:b.onKey)==null||j.call(b,x)},y=()=>e(()=>{var x;((x=c.activeElement)==null?void 0:x.tagName)==="IFRAME"&&l("frame")});return c.addEventListener("pointerdown",f,!0),c.addEventListener("pointerup",p,!0),c.addEventListener("pointercancel",m,!0),c.addEventListener("click",g,!0),u.addEventListener("keydown",w,!0),u.addEventListener("blur",y),()=>{c.removeEventListener("pointerdown",f,!0),c.removeEventListener("pointerup",p,!0),c.removeEventListener("pointercancel",m,!0),c.removeEventListener("click",g,!0),u.removeEventListener("keydown",w,!0),u.removeEventListener("blur",y)}}}}const Ld=o4(),Ap=typeof HTMLElement<"u"&&"showPopover"in HTMLElement.prototype,B0=e=>(e==null?void 0:e.getBoundingClientRect())??null;function s4(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 Ss({className:e,anchor:t,placement:n,coverBy:r,track:o=t==="parent",raiseKey:i,onDismiss:l,onKey:u,onBack:c,trigger:f,from:p,boxRef:m,handle:g,children:w,...y}){const x=S.useRef(null),b=S.useRef({anchor:t,placement:n,coverBy:r,onDismiss:l,onKey:u,onBack:c,trigger:f,from:p});b.current={anchor:t,placement:n,coverBy:r,onDismiss:l,onKey:u,onBack:c,trigger:f,from:p};const j=S.useCallback(()=>{const T=x.current,{anchor:R,placement:$,coverBy:W}=b.current;if(!T||!R||!$)return;const A=R==="parent"?B0(T.parentElement):R();if(!A)return;const I=GL(A,$);I!==void 0&&(T.style.width=`${I}px`);for(let _=0;_<2;_++){const P=W?s4(T,W,T.dataset.side??"",T.dataset.align??""):null,z=YL(A,{w:T.offsetWidth,h:T.offsetHeight},{w:window.innerWidth,h:window.innerHeight},P?{...$,...P}:$);T.style.left=`${z.x}px`,T.style.top=`${z.y}px`;const q=T.dataset.side!==z.side||T.dataset.align!==z.align;if(T.dataset.side=z.side,T.dataset.align=z.align,!q)break}},[]);S.useImperativeHandle(g,()=>({update:j}),[j]),S.useLayoutEffect(()=>{const T=x.current;if(!T)return;m&&(m.current=T),Ap&&(T.popover="manual",T.matches(":popover-open")||T.showPopover());const{onDismiss:R,onKey:$,onBack:W,trigger:A,from:I}=b.current,_=R||$?Ld.register({box:T,trigger:A,from:I,dismiss:R?P=>{var z,q;return(q=(z=b.current).onDismiss)==null?void 0:q.call(z,P)}:void 0,onKey:$?P=>{var z,q;return(q=(z=b.current).onKey)==null?void 0:q.call(z,P)}:void 0,back:W?()=>{var P,z;return(z=(P=b.current).onBack)==null?void 0:z.call(P)}:void 0}):null;return()=>{_&&Ld.unregister(_),m&&(m.current=null),Ap&&T.isConnected&&T.matches(":popover-open")&&T.hidePopover()}},[m]),S.useLayoutEffect(j),S.useLayoutEffect(()=>{if(!o)return;let T=0,R="";const $=()=>{const W=x.current,{anchor:A}=b.current,I=W&&A?A==="parent"?B0(W.parentElement):A():null;if(W&&I){const _=`${I.left},${I.top},${I.right},${I.bottom},${W.offsetWidth},${W.offsetHeight},${window.innerWidth},${window.innerHeight}`;_!==R&&(R=_,j())}T=requestAnimationFrame($)};return T=requestAnimationFrame($),()=>cancelAnimationFrame(T)},[o,j]);const N=S.useRef(!0);return vt([i],()=>{if(N.current){N.current=!1;return}const T=x.current;!Ap||!(T!=null&&T.matches(":popover-open"))||(T.hidePopover(),T.showPopover(),j())}),h.jsx("div",{ref:x,className:Ue("float",e),...y,children:w})}const i4=/^[⌘⇧⌥⌃]+/;function Wo({k:e,chip:t=!1,className:n}){var l;const r=(l=e.match(i4))==null?void 0:l[0],o=r?e.slice(r.length):e,i=["kbd",t?"kbd-chip":"",n??""].filter(Boolean).join(" ");return h.jsxs("kbd",{className:i,children:[r&&h.jsx("span",{className:"kbd-mod",children:r}),o]})}function Dt(e,t,{placement:n,detail:r,card:o,dot:i,name:l,aside:u,also:c}={}){const f=l?`${e}: ${l}`:e,p=(Array.isArray(r)?r:[r]).filter(g=>!!g),m=[f,...p,...u??[]].join(", ");return{"data-tip":e,"data-tip-key":t,"data-tip-placement":n,"data-tip-detail":p.length?p.join(`
|
|
104
|
+
`):void 0,"data-tip-card":o||l||u!=null&&u.length?"":void 0,"data-tip-dot":i,"data-tip-name":l,"data-tip-aside":u!=null&&u.length?u.join(`
|
|
105
|
+
`):void 0,"data-tip-also":c==null?void 0:c.text,"data-tip-also-key":c==null?void 0:c.key,"aria-label":t?`${m} (${t})`:m}}const a4=120,l4=600,c4=150,U0=6,u4=18,Ip=8;function H0(e){const t=e.dataset.tipPlacement;return t==="follow"||t==="top"||t==="bottom"||t==="left"||t==="right"?t:"bottom"}function d4(e){return e==="follow"?{side:"bottom",align:"start",offset:u4,alignOffset:-12,flip:"both",margin:Ip}:e==="left"||e==="right"?{side:e,align:"start",offset:U0,flip:"both",margin:Ip}:{side:e,align:"center",offset:U0,flip:"side",margin:Ip}}function f4(e,t){return e.placement==="follow"?NE(t):e.el.getBoundingClientRect()}function YE(){var c;const[e,t]=S.useState(null),n=S.useRef(null),r=S.useRef(null),o=S.useRef({x:0,y:0}),i=Ki();if(S.useEffect(()=>{if(i)return;let f=0,p=0,m=null,g=!1,w=0;const y=()=>{window.clearTimeout(f),window.clearTimeout(p)},x=()=>{y(),g&&(w=Date.now()),g=!1,m=null,t(null)},b=(I,_)=>{var z,q;const P=I.dataset.tip;if(!P)return x();y(),g=!0,t({el:I,text:P,key:I.dataset.tipKey,detail:(z=I.dataset.tipDetail)==null?void 0:z.split(`
|
|
106
|
+
`),card:I.dataset.tipCard!==void 0,dot:I.dataset.tipDot,name:I.dataset.tipName,aside:(q=I.dataset.tipAside)==null?void 0:q.split(`
|
|
107
|
+
`),also:I.dataset.tipAlso&&I.dataset.tipAlsoKey?{text:I.dataset.tipAlso,key:I.dataset.tipAlsoKey}:void 0,placement:_})},j=I=>{const _=I.target;return _ instanceof Element?_.closest("[data-tip]"):null},N=I=>{o.current={x:I.clientX,y:I.clientY};const _=j(I);if(_===m)return;if(y(),m=_,!_){g&&(p=window.setTimeout(x,c4));return}const P=H0(_);if(g||Date.now()-w<l4)return b(_,P);f=window.setTimeout(()=>b(_,P),a4)},T=I=>{I.relatedTarget||x()},R=I=>{const _=j(I);if(_!=null&&_.matches(":focus-visible")){y(),m=_;const P=H0(_);b(_,P==="follow"?"bottom":P)}},$=()=>x(),W=I=>{I.key!=="Shift"&&I.key!=="Control"&&I.key!=="Alt"&&I.key!=="Meta"&&x()},A=I=>{m&&I.target instanceof Node&&I.target.contains(m)&&x()};return document.addEventListener("mouseover",N),document.addEventListener("mouseout",T),document.addEventListener("mousedown",x),document.addEventListener("keydown",W),document.addEventListener("scroll",A,!0),document.addEventListener("focusin",R),document.addEventListener("focusout",$),window.addEventListener("blur",x),()=>{y(),document.removeEventListener("mouseover",N),document.removeEventListener("mouseout",T),document.removeEventListener("mousedown",x),document.removeEventListener("keydown",W),document.removeEventListener("scroll",A,!0),document.removeEventListener("focusin",R),document.removeEventListener("focusout",$),window.removeEventListener("blur",x)}},[i]),S.useLayoutEffect(()=>{e&&!e.el.isConnected&&t(null)},[e]),S.useEffect(()=>{if((e==null?void 0:e.placement)!=="follow")return;const f=p=>{var m;o.current={x:p.clientX,y:p.clientY},(m=r.current)==null||m.update()};return document.addEventListener("mousemove",f),()=>document.removeEventListener("mousemove",f)},[e]),!e)return null;const l=h.jsxs(h.Fragment,{children:[e.dot==="spinner"?h.jsx(el,{size:"dot",className:"tooltip-dot"}):e.dot&&h.jsx("span",{className:`dot ${e.dot} tooltip-dot`}),e.text]}),u=h.jsxs(h.Fragment,{children:[l,e.key&&h.jsx(Wo,{k:e.key,className:"tooltip-key"})]});return h.jsxs(Ss,{className:Ue("tooltip",e.card&&"tooltip-card"),role:"tooltip",boxRef:n,handle:r,anchor:()=>f4(e,o.current),placement:d4(e.placement),track:!1,raiseKey:e,children:[e.also?h.jsxs("div",{className:"tooltip-pair",children:[h.jsx("span",{children:l}),e.key?h.jsx(Wo,{k:e.key,className:"tooltip-key"}):h.jsx("span",{}),h.jsx("span",{className:"tooltip-also",children:e.also.text}),h.jsx(Wo,{k:e.also.key,className:"tooltip-key"})]}):e.name?h.jsxs("div",{className:"tooltip-head",children:[h.jsx("span",{children:u}),h.jsx("span",{className:"tooltip-name",children:e.name})]}):u,(c=e.detail)==null?void 0:c.map((f,p)=>h.jsx("div",{className:"tooltip-detail",children:f},p)),e.aside&&h.jsx("div",{className:"tooltip-foot",children:e.aside.map(f=>h.jsx("span",{children:f},f))})]})}const h4={sm:"",md:"btn-md",lg:"btn-lg"},p4={ghost:"",outline:"btn-outline",field:"btn-outline btn-field",inline:"btn-inline"},XE={primary:"tone-primary",quiet:"tone-quiet",danger:"tone-danger",strong:"tone-strong",chrome:"tone-chrome"};function Le({variant:e="ghost",size:t="sm",tone:n,on:r,mono:o,busy:i,className:l,type:u="button",disabled:c,children:f,...p}){const m=Ue("btn",p4[e],h4[t],n&&XE[n],r&&"on",o&&"btn-mono",i&&"btn-busy",l);return h.jsxs("button",{className:m,type:u,disabled:i||c,"aria-busy":i||void 0,...p,children:[i&&h.jsx(el,{}),f]})}function Ot({icon:e,label:t,hint:n,detail:r,also:o,silent:i,badge:l,tone:u,on:c,className:f,type:p="button",...m}){const g=Ue("btn-icon",u&&XE[u],c&&"on",f),w=Dt(t,n,{detail:r,also:o});return h.jsxs("button",{className:g,type:p,...i?{"aria-label":w["aria-label"]}:w,...m,children:[typeof e=="string"?h.jsx(jt,{name:e}):e,l]})}function $c(e,t,n){return n===0?0:(e+t+n)%n}function K0(e,t,n){return e>=0?$c(e,t,n):n===0?-1:t>0?0:n-1}function QE(e,t,n){var i;const r=e.length,o=n.toLowerCase();for(let l=1;l<=r;l++){const u=(Math.max(t,-1)+l)%r;if((i=e[u])!=null&&i.trim().toLowerCase().startsWith(o))return u}return-1}function Rp(e,t){return e&&e.length>t.length&&e.toLowerCase().startsWith(t.toLowerCase())?e.slice(t.length):null}function m4(e,t){if(e==null)return null;if(typeof e=="string"){const o=Rp(e,t);return o?{text:o,accept:o,params:[]}:null}const n=Rp(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:Rp(e.accept,t),params:r}}function JE(e){const{results:t,keyOf:n,q:r,onPick:o,listRef:i,onActive:l,onSide:u,completionOf:c,narrowTo:f,setQ:p,tabPicks:m,onIdlePick:g}=e,[w,y]=S.useState(()=>{var W;return e.idle?-1:Math.max(0,((W=e.initialIndex)==null?void 0:W.call(e,t))??0)}),x=w>=0&&t[w]?n(t[w]):null,b=S.useRef(l);b.current=l,vt([x],()=>{var W,A,I;(A=(W=i.current)==null?void 0:W.querySelector('.picker-item[data-state~="cursor"]'))==null||A.scrollIntoView({block:"nearest"}),(I=b.current)==null||I.call(b,w>=0?t[w]??null:null)});const j=w<0?-1:Math.min(w,Math.max(0,t.length-1)),N=j>=0?t[j]??null:null,T=N?m4(c==null?void 0:c(N,r),r):null,R=W=>{const A=f==null?void 0:f(W,r);if(A==null)return o(W,r);p==null||p(A),y(0)};return{index:j,active:N,ghost:T,setIndex:y,pick:R,onKeyDown:W=>{if(W.key==="ArrowDown")W.preventDefault(),y(K0(j,1,t.length));else if(W.key==="ArrowUp")W.preventDefault(),y(K0(j,-1,t.length));else if((W.key==="ArrowLeft"||W.key==="ArrowRight")&&u&&N)W.preventDefault(),u(N,W.key==="ArrowLeft"?-1:1);else if(W.key==="Tab"&&(T!=null&&T.accept))W.preventDefault(),p==null||p(r+T.accept),y(0);else if(W.key==="Tab"&&m&&N)W.preventDefault(),R(N);else if(W.key==="Enter"&&N)W.preventDefault(),R(N);else if(W.key==="Enter"&&j<0&&g)W.preventDefault(),g(r);else return!1;return!0}}}function mr(e){const t=Object.keys(e).filter(n=>e[n]);return t.length>0?t.join(" "):void 0}const g4=new Set(["Shift","Meta","Control","Alt","CapsLock","Fn"]);function e_(){const e=Vg(),t=Zn();return S.useEffect(()=>{if(!e)return;const n=()=>{e.target.isConnected||to.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?h.jsx(k4,{spec:e},e.id):null}function k4({spec:e}){const t=e.items,n=t.filter(xs),[r,o]=S.useState(-1),i=S.useRef({idx:r,items:n});i.current={idx:r,items:n};const l=S.useRef(null),u=m=>{var g,w;{const y=()=>to.close(),{idx:x,items:b}=i.current;if(g4.has(m.key))return;if(m.key==="ArrowDown"||m.key==="ArrowUp"){m.preventDefault(),m.stopPropagation();const j=m.key==="ArrowDown"?1:-1;o(XL(b,x,j));return}if((m.key==="Enter"||m.key===" ")&&x>=0&&b[x]&&!b[x].disabled){m.preventDefault(),m.stopPropagation(),b[x].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 j=Array.from(((g=l.current)==null?void 0:g.querySelectorAll(".menu-label"))??[],T=>T.textContent??""),N=QE(j,x,m.key);N>=0&&!((w=b[N])!=null&&w.disabled)&&o(N);return}y()}};S.useEffect(()=>{const m=()=>to.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:c,placement:f}=eP(e),p=n.some(m=>m.checked);return h.jsx(Ss,{className:"menu",role:"menu",boxRef:l,anchor:()=>c,placement:f,track:!1,from:e.target,trigger:e.toggles?e.target:null,onDismiss:()=>to.close(),onKey:u,onContextMenu:m=>m.preventDefault(),children:t.map((m,g)=>{if(!xs(m))return h.jsx("hr",{className:"menu-sep"},`sep-${g}`);const w=n.indexOf(m);return h.jsx(w4,{item:m,gutter:p,cursor:w===r,onEnter:()=>o(w)},m.id)})})}function w4({item:e,gutter:t,cursor:n,onEnter:r}){const o=e.disabled!==void 0,i=e.detail??e.disabled;return h.jsxs("button",{...e.checked===void 0?{role:"menuitem"}:{role:"menuitemcheckbox","aria-checked":e.checked},"aria-disabled":o||void 0,className:Ue("row row-keyed",e.danger&&"danger",i!==void 0&&"row-tall",o&&"disabled"),"data-state":mr({cursor:n,checked:e.checked}),onMouseMove:o||n?void 0:r,onClick:()=>{o||(e.onClick(),to.close())},children:[t&&h.jsx("span",{className:"menu-check",children:e.checked&&h.jsx(jt,{name:"check",className:"icon-inline"})}),h.jsxs("span",{className:"menu-text",children:[h.jsx("span",{className:"menu-label",children:e.label}),i!==void 0&&h.jsx("span",{className:"menu-detail row-dim",children:i})]}),e.key&&h.jsx(Wo,{k:e.key,className:"menu-key row-dim"})]})}function jf({items:e,current:t,onPick:n,fill:r,font:o,segmented:i,quiet:l,end:u,label:c,owner:f}){const p=fn(f),m=S.useRef(null),g=Math.max(0,e.findIndex(y=>y.id===t)),w=y=>{var j,N;if(y.key!=="ArrowLeft"&&y.key!=="ArrowRight")return;y.preventDefault();const x=e.findIndex(T=>T.id===t),b=e[$c(x,y.key==="ArrowRight"?1:-1,e.length)];b&&(n(b.id),(N=(j=m.current)==null?void 0:j.querySelectorAll('[role="tab"]')[e.indexOf(b)])==null||N.focus())};return h.jsxs("div",{className:Ue("tabs",r&&"tabs-fill",o==="mono"&&"tabs-mono",i&&"tabs-segmented",l&&"tabs-quiet"),children:[h.jsx("div",{className:"tabs-list",role:"tablist","aria-label":c,ref:m,onKeyDown:w,style:i?{"--tabs-at":g,"--tabs-count":e.length}:void 0,children:e.map(y=>{const x=y.id===t;return h.jsxs("div",{className:Ue("tab",x&&!!y.trail&&"tab-trailed",y.fit&&"tab-fit",y.far&&"tab-far"),"data-state":mr({current:x}),...y.menu?p.contextMenu(y.menu):{},children:[h.jsxs("button",{type:"button",className:"tab-btn",role:"tab","aria-selected":x,tabIndex:x?0:-1,onClick:()=>n(y.id),...y.tip,...y.ariaLabel?{"aria-label":y.ariaLabel}:{},children:[y.lead,y.label]}),x&&y.trail&&h.jsx("span",{className:"tab-trail",children:y.trail})]},y.id)})}),u&&h.jsx("span",{className:"tabs-end",children:u})]})}function Ns({anchor:e="top",wide:t,foot:n,children:r}){const o=h.jsx("div",{className:Ue("view",e==="line"&&"view-anchored",t&&"view-wide"),children:r});return n?h.jsxs("div",{className:"view-stack",children:[o,n]}):o}const t_=e=>`Toyon restarts once ${e.join(", ")} ${e.length===1?"finishes":"finish"}`,y4=(e,t)=>[...e,...t.filter(n=>!e.includes(n))];function v4(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 b4(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 x4(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:t_(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 Nm=!1;function E4(){Nm=!0}function mc({title:e,body:t,action:n,pane:r,children:o}){return h.jsxs("div",{className:Ue("crash",r&&"in-pane"),children:[h.jsx("div",{className:"crash-title",children:e}),t&&h.jsx("div",{className:"crash-body",children:t}),o,n]})}const W0={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);Rt(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?h.jsx(mc,{pane:this.props.pane,title:Nm?W0.title:"Toyon hit an error",body:Nm?W0.body:n.message||String(n),action:h.jsx(Le,{variant:"outline",onClick:()=>window.location.reload(),children:"reload"})}):this.props.children}}const Tm={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.`},_4=1e3,Z0={held:[],asking:[],seen:[]};async function q0(e,t,n){for(;;){await new Promise(i=>setTimeout(i,_4));const[r,o]=await Promise.all([pm(e),$1(e)]);if(r!==null&&r!==t)break;n(o??{waiting:[],asking:[]})}window.location.reload()}function n_({foreign:e}={}){return e?h.jsx(S4,{name:e}):h.jsx(N4,{})}function S4({name:e}){const t=To(),n=t.list()[0];return h.jsx(mc,{title:`Toyon on ${e} was updated`,body:Tm.foreign(e),action:n&&h.jsxs(Le,{variant:"outline",onClick:()=>t.activate(n.origin),children:["back to ",t.displayName(n.origin)]})})}function N4(){const e=$r(),[t,n]=S.useState(!0),[r,o]=S.useState(null),[i,l]=S.useState(Z0),u=S.useRef(null),c=S.useCallback(g=>l(w=>({held:g.waiting,asking:g.asking,seen:y4(w.seen,g.waiting)})),[]),f=S.useCallback(async g=>{n(!0),o(null);const w=u.current??{pid:await pm(e)},y=await Q2(e,g);if(y){n(u.current!==null),o(y);return}g&&l(Z0),!u.current&&(u.current=w,q0(e,w.pid,c))},[c,e]);S.useEffect(()=>{let g=!0;return(async()=>{const[w,y]=await Promise.all([pm(e),$1(e)]);if(!(!g||u.current)){if(y===null){f(!1);return}u.current={pid:w},c(y),q0(e,w,c)}})(),()=>{g=!1}},[c,f,e]);const p=t&&i.held.length>0,m=p?v4(i.seen,i.held,i.asking):[];return h.jsx(mc,{title:Tm.title,body:r??(p?b4(i.held.length,i.seen.length):Tm.waiting),action:p?h.jsx(Le,{variant:"outline",onClick:()=>void f(!0),children:"restart now"}):h.jsx(Le,{variant:"outline",busy:t,onClick:()=>void f(!1),children:"restart"}),children:m.length>0&&h.jsx("ul",{className:"crash-list",children:m.map((g,w)=>h.jsxs("li",{className:Ue("crash-row",g.dot!=="working"&&"row-dim"),children:[h.jsx("span",{className:Ue("dot",g.dot)}),h.jsx("span",{className:"crash-row-name",children:g.name}),g.note&&h.jsx("span",{className:"crash-row-note",children:g.note})]},w))})})}const G0={probing:"connecting to daemon…",down:"the daemon is not running.\nrun `toyon` in your repo to start it; `toyon doctor` says what it can see",blocked:"the daemon is up, but this page's websocket never connected.\na proxy, VPN or browser extension is the usual cause; `toyon doctor` checks from the terminal",unauthorized:"this page's token is not the running daemon's.\nrun `toyon` again and open the link it prints"},T4={probing:e=>`connecting to ${e}…`,down:e=>`Toyon on ${e} is not answering.
|
|
108
|
+
is Tailscale on here, and is Toyon running there?`,blocked:e=>`Toyon on ${e} is up, but this page's websocket to it never connected.
|
|
109
|
+
a proxy, VPN or browser extension is the usual cause`,unauthorized:e=>`this page's token for ${e} is not the one running there.
|
|
110
|
+
forget ${e} here and pair it again`},j4="no access token for this address.\nrun `toyon` in your repo, or open the full URL\n(with #token=…) printed in ~/.toyon/daemon.log";function r_(e){return!e.connected&&(!e.heard||e.connectFailure)?e.machine?T4[e.connectFailure??"probing"](e.machine):e.hasToken?G0[e.connectFailure??"probing"]??G0.probing:j4:e.title===null?e.heard?`nothing open yet.
|
|
111
|
+
press ${e.projectChord} to open a project, or type a name there to start a new one`:"":null}function C4(e){const t=r_(e);return t!==null?t:e.needsSetup&&e.busy?`building in ${e.title}; the preview appears once it starts`:e.needsSetup&&e.treeEmpty?`${e.title} is empty so far; say what to build`:e.treeEmpty&&e.landsFrom?`nothing runs on main until ${e.landsFrom} lands`:null}const en={post:(e,t)=>{},broadcast:e=>{}};function gc(e,t,n,r){const o=t===r;en.post(e,o?{type:"pick-cancel"}:{type:"pick-start",verb:r}),n({a:"set-picking",v:o?!1:r})}function o_(e){return[{id:"copy-sha",label:`copy ${e.short}`,onClick:()=>Qt(e.sha)},{id:"copy-subject",label:"copy subject",onClick:()=>Qt(e.subject)}]}function Cf(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 Af(e){return e!=null&&e.config.profiles?Object.keys(e.config.profiles):[]}function s_(e,t){const n=Af(t);if(n.length!==0)return e.profile&&n.includes(e.profile)?e.profile:t==null?void 0:t.config.defaultProfile}const A4=e=>Ed($i((e==null?void 0:e.config)??{}),e==null?void 0:e.defaultBranch).toLowerCase();function ti(e,t,n){t({a:"shipping",id:n.worktreeId,op:n.t}),e==null||e.send(n)}const i_=e=>e.dirty===void 0||e.ahead===void 0||e.dirty>0||e.ahead>0;function Pi(e,t,n){if(n.length!==0){t({a:"archive-worktrees",ids:n});for(const r of n)e==null||e.send({t:"archive-worktree",worktreeId:r})}}function a_(e,t,n){t({a:"hold-unread",id:n}),e==null||e.send({t:"mark-unread",worktreeId:n})}function sk(e,t){return{rename(n){if(!jx(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(!ig(n.worktree))return;if(!i_(n))return Pi(e,t,[n.worktree.id]);window.confirm(`Archive worktree "${n.worktree.title}"?
|
|
114
|
+
|
|
115
|
+
Its directory and branch (${n.worktree.branch}) go. The chat, the commits and any uncommitted changes are kept, and the project menu can restore it.`)&&Pi(e,t,[n.worktree.id])}}}function l_(e,t,n,{sock:r,dispatch:o},i){var W,A;const l=e.worktree.id,u=sk(r,o),c=[],f=[],p=[],m=[],g=[],w=[],y=[],x=[];jc(e)&&c.push({id:"stop",label:"stop agent",onClick:()=>r==null?void 0:r.send({t:"stop-agent",worktreeId:l})});const b=!n.shipping[l],j=n.frame==="phone";((e.dirty??0)>0||(e.ahead??0)>0||!j&&!n.layout.changes)&&f.push({id:"changes",label:`view changes${(e.dirty??0)>0?` (${e.dirty})`:""}`,onClick:()=>{o({a:"activate",id:l}),j?o({a:"screen",to:"changes"}):n.layout.changes||o({a:"toggle-changes"})}}),j||f.push({id:"terminal",label:"open terminal",onClick:()=>{o({a:"activate",id:l}),o({a:"focus-terminal"})}}),f.push(...Ef(()=>r==null?void 0:r.send({t:"reveal",worktreeId:l}),i.hostname)),j||p.push({id:"copy-path",label:"copy path",onClick:()=>Qt(e.path)}),p.push({id:"copy-branch",label:"copy branch name",onClick:()=>Qt(e.worktree.branch)});const{transcript:N,sessionId:T}=e;!j&&N&&!Ir(e.worktree)&&p.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>Qt(N)}),!j&&T&&p.push({id:"copy-session",label:"copy session id",onClick:()=>Qt(T)});const R=s_(e.worktree,t);for(const I of Nc(e.worktree)?[]:Af(t))m.push({id:`profile:${I}`,label:`run with ${I}`,checked:I===R,onClick:()=>u.setProfile(e,I)});if(!Di(e.worktree)&&((W=e.borrowed)!=null&&W.length)&&m.push({id:"own-procs",label:`run ${e.borrowed.join(", ")} here`,detail:"on main now",onClick:()=>u.ownProcs(e)}),!Di(e.worktree)&&((A=e.worktree.owns)!=null&&A.length)&&m.push({id:"share-procs",label:`use main's ${e.worktree.owns.join(", ")}…`,detail:"runs here now",danger:!0,onClick:()=>u.shareProcs(e)}),jx(e.worktree)&&g.push({id:"rename",label:"rename…",onClick:()=>u.rename(e)}),e.worktree.variant&&g.push({id:"keep",label:"keep this variant…",onClick:()=>u.pickVariant(e)}),i.graft&&hd(e.worktree)){const I=i.graft;g.push({id:"graft",label:"graft with…",onClick:()=>I(l)})}g.push({id:"unread",label:"mark as unread",key:At("mark-unread"),disabled:e.unseen?"already unread":void 0,onClick:()=>a_(r,o,l)});const $=b?void 0:"waiting on the one in progress";return tf(e)&&(e.behind??0)>0&&w.push({id:"sync",label:`sync from main (${e.behind} behind)`,disabled:$,onClick:()=>ti(r,o,{t:"sync-main",worktreeId:l})}),Ai(e.worktree)&&w.push({id:"land",label:"land",detail:A4(t),disabled:$,onClick:()=>ti(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}})}),ig(e.worktree)&&x.push({id:"archive",label:i_(e)?"archive…":"archive",key:At("wt-archive"),danger:!0,onClick:()=>u.archive(e)}),Dn([c,f,p,m,g,w,y,x])}function I4(e,t,{sock:n,dispatch:r},o){const i=[],l=t.frame==="phone",u=[{id:"adopt",label:"take over",disabled:e.locked?`held by ${e.lockReason??"another tool"}`:void 0,onClick:()=>n==null?void 0:n.send({t:"adopt-worktree",worktreeId:e.id,clientId:t.clientId})}];return tf(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(...Ef(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id}),o)),Dn([u,i,l?[]:[{id:"copy-path",label:"copy path",onClick:()=>Qt(e.path)}]])}const R4={sm:"",md:"field-md",lg:"field-lg"};function c_({size:e="sm",font:t,bare:n,rule:r,className:o}){const i=t??(e==="lg"?"ui":"mono");return Ue("field",R4[e],i==="ui"&&"field-ui",i==="lead"&&"field-lead",n&&"field-bare",r&&"field-rule",o)}const Eo=S.forwardRef(function({size:t,font:n,bare:r,rule:o,className:i,...l},u){return h.jsx("input",{ref:u,className:c_({size:t,font:n,bare:r,rule:o,className:i}),...l})}),kc=S.forwardRef(function({size:t,font:n,bare:r,rule:o,className:i,...l},u){return h.jsx("textarea",{ref:u,className:c_({size:t,font:n,bare:r,rule:o,className:i}),...l})});function $4(e,t){const n=t??0;return n===0?null:`${n} behind ${e}`}function u_(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function d_(e,t){if(t.fetchFailed)return`could not reach origin${t.fetchedAt?` since ${u_(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 O4(e){return e.stale!=="diverged"}const Ur=e=>/[.!?…]$/.test(e)?e:`${e}.`,V0=160;function ik(e){const t=e.replace(/\s+/g," ").trim();if(t.length<=V0)return t;const n=t.slice(0,V0);return`${n.slice(0,Math.max(n.lastIndexOf(" "),1)).trimEnd()}…`}function f_(e){return e.subjects.length?ik(e.subjects.join("; ")):void 0}function ak(e){const t=f_(e);if(t)return e.pr===void 0?t:ik(`PR #${e.pr}: ${t}`)}function lk(e,t=3){const n=[];for(const l of e??[]){const u=ak(l);u&&n.push({at:l.at,line:u})}if(n.length===0)return[];const r=n.slice(-t),o=n.length-r.length,i=r.map(({at:l,line:u})=>n.length===1?Ur(u):`${ck(Fo(eo(l)))}: ${Ur(u)}`);return o>0?[`${o} earlier landing${o===1?"":"s"}.`,...i]:i}function ks(e){const t=`PR #${e.number}`;if(e.state==="merged")return`${t} merged.`;if(e.state==="closed")return`${t} was closed without merging.`;if(e.automerge){const n=e.review==="review_required"?"it is approved and checks pass":"checks pass";return`${t} open; GitHub merges it when ${n}.`}return e.mergeable===!1?`${t} open; it conflicts with main.`:e.review==="changes_requested"?`${t} open; changes requested.`:e.checks==="fail"?`${t} open; checks failed.`:e.checks==="pending"?`${t} open; checks running.`:e.review==="review_required"?`${t} open; waiting on review.`:e.review==="approved"?`${t} approved${e.checks==="pass"?", checks pass":""}.`:`${t} open and ready to merge.`}function h_(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 ck=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function uk(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 p_(e,t,n=null){return e!=null&&e.stale?`The work changed since this was written. ${t?"Run the check again and refresh":"Refresh"} the message.`:n==="unanswered"?`The model did not answer with a message. ${t?"Run the check again and ask":"Ask"} for it again.`:`${t?"Run the repo's check here, then write":"Write"} the recap and the commit message.`}function M4(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 ed(e,t=0,n=!0,r){var o,i;if(e.check==="pending")return"Checking the work…";if(e.check==="fail"){const l=(i=(o=e.checkTail)==null?void 0:o.split(`
|
|
116
|
+
`).find(u=>u.trim()))==null?void 0:i.trim();return`Check failed${l?`: ${Ur(l)}`:"."}`}return uk(e,t,n)==="unasked"?M4(r):null}function Y0(e,t){const n=L4(e,t);return n?Ur(ck(n)):""}function L4(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 m_=e=>/^[A-Z][a-z]+(\s|$)/.test(e)?`${e.charAt(0).toLowerCase()}${e.slice(1)}`:e;function P4(e,t){const n=t??0;return n>0?`${n} behind ${e}; land takes it in first.`:""}function D4(e){return e>0?Ur(ck(`${e} ${e===1?"file":"files"} changed`)):""}function z4(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: ${Ur(m_(e.why))}`:null}function td(e){return Ur(e)}const Fo=e=>e==="now"?"just now":`${e} ago`;function F4(e,t,n){switch(e){case"asking":return`Waiting on you${n==="now"?"":` for ${n}`}${t.ask?`: ${Ur(t.ask)}`:"."}`;case"failed":return t.auth?`Stopped ${Fo(n)}: not logged in.`:t.error?`Failed ${Fo(n)}: ${Ur(t.error)}`:`Failed ${Fo(n)}.`;case"stopped":return t.planBack?`Sent the plan back ${Fo(n)}. Say what to change.`:`Stopped ${Fo(n)}.`;case"done":return t.cut?`Ended early ${Fo(n)} (${t.cut}).`:`Finished ${Fo(n)}.`}}function dk(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?Ur(t):F4(e.end,e.facts,eo(e.at))}function B4(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?`Last stop, ${Fo(eo(e.at))}: ${Ur(m_(t))}`:void 0}function wc(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 fk(e){return(e==null?void 0:e.status)==="running"||(e==null?void 0:e.status)==="detached"}function g_(e){const t=e&&e.status!=="terminated"?e.since:void 0,n=Hg(t,Kg);return t!==void 0&&n===t?e:void 0}function k_(e,t){const n=e.stage?[e.stage]:[];switch(e.status){case"queued":return[...n,"queued"];case"running":return[...n,`${Ba(t)} of ${Dj(e.timeoutMs)}`];case"detached":return[...n,Ba(t),"detached"];case"terminated":return[e.why??"stopped"]}}function jm(e,t,n){return[e,...k_(t,n)].join(" · ")}const w_={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 y_(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 U4({active:e,ahead:t,behind:n,unpushed:r,dirty:o}){var ht,tn,Vt;const i=lt(),l=at(),u=fn("changes"),c=An(e)?e.worktree:null,f=e.id,p=M(He=>{var nt;return(nt=He.shipping[f])==null?void 0:nt.op}),m=M(He=>{var nt;return(nt=He.shipping[f])==null?void 0:nt.step}),g=Hg(m,Kg),w=wc(e,"commit"),y=wc(e,"check"),x=p?w:y,b=g_(x),j=Ja(fk(b)?b==null?void 0:b.since:void 0),[N,T]=S.useState("");vt([f],()=>T(""));const R=S.useRef(null),$=(ht=c==null?void 0:c.landing)!=null&&ht.subject?c.landing.body?`${c.landing.subject}
|
|
117
|
+
|
|
118
|
+
${c.landing.body}`:c.landing.subject:null,W=()=>{N===""&&$&&T($);const He=R.current;He&&(He.focus(),requestAnimationFrame(()=>He.setSelectionRange(He.value.length,He.value.length)))},A=M(He=>He.editCommit);vt([A],()=>{A&&W()});const I=N.trim()||void 0,_=M(He=>{var nt;return!!((nt=He.agents.find(an=>an.id===((c==null?void 0:c.agent)??He.defaultAgent)))!=null&&nt.quick)}),P=c==null?void 0:c.landing,z=I?null:uk(P,o?1:0,_),q=(P==null?void 0:P.check)==="pending",se=!!(P!=null&&P.stale),Y=()=>{p||i==null||i.send({t:"judge",worktreeId:f})},ge=()=>{p||!I&&!$||(ti(i,l,{t:"commit",worktreeId:f,message:I??$??""}),T(""))},ke=()=>{p||ti(i,l,{t:"land",worktreeId:f,...I?{message:I}:{}})},oe=((tn=c==null?void 0:c.landing)==null?void 0:tn.check)==="fail",L=c==null?void 0:c.pr,re=(L==null?void 0:L.state)==="open",te=re&&(o||r>0),K=q||se||!!z,B=!!c&&Ai(c)&&(o||t>0)&&!oe&&!re&&!K,xe=!!c&&te&&!oe&&!K,de=!!c&&Ai(c)&&!q&&(se||z==="unwritten"||z==="unanswered")&&e.agent!=="working"&&e.agent!=="waiting",we=M(He=>He.repos.find(nt=>nt.id===e.repoId)??null),ee=Ed($i((we==null?void 0:we.config)??{}),we==null?void 0:we.defaultBranch),J=we?nf(we):"main",pe=tf(e)?$4(J,n):null,$e=e.agent==="working"||e.agent==="waiting",le=o?c?$e?"the agent is mid-turn: sync when it is done":void 0:"commit or discard the changes here first":void 0,ae=re&&!te&&h_(L),Fe=B?"land":xe?"update":ae?"merge":(L==null?void 0:L.state)==="merged"?"pull":"land",ze=p==="commit"?g??"commit":p==="land"?g?`${Fe}: ${g}`:Fe:null,Re=x?b?k_(b,j).join(" · "):null:q&&!p?"writing the message":null,ct=b&&(b.status==="running"||b.status==="detached")?b:null,_n=ct&&h.jsx(Ot,{icon:"stop",tone:"danger",label:y_(ct.kind),onClick:()=>i==null?void 0:i.send({t:"run-stop",worktreeId:f,kind:ct.kind})});return h.jsxs("div",{className:"composer commit-box",children:[c&&o&&h.jsx("div",{className:"composer-field",children:h.jsx(kc,{size:"lg",bare:!0,ref:R,value:N,onChange:He=>T(He.target.value),onKeyDown:He=>{He.key==="Enter"&&(He.metaKey||He.ctrlKey)?(He.preventDefault(),ge()):He.key==="Tab"&&!He.shiftKey&&N===""&&$&&(He.preventDefault(),W())},placeholder:$??(z==="unanswered"?"no message yet: the model did not answer. Check again, or write one here":z==="unasked"?"no message yet: write one here to commit or land":"commit message…")})}),h.jsxs("div",{className:"hint composer-knobs",children:[h.jsxs("span",{className:"commit-where",children:[h.jsx(jt,{name:"branch",className:"icon-inline"}),h.jsx("span",{className:"branch-name",children:e.branch??"detached"}),t>0&&h.jsxs("span",{className:"badge-ahead","data-tip":`${t} commit(s) ahead of ${J}`,children:[t," ahead"]}),(c==null?void 0:c.landed)&&h.jsxs("span",{className:"badge-landed","data-tip":`Merged into ${J}`,children:[h.jsx(jt,{name:"check",className:"icon-inline"})," landed"]})]}),h.jsxs("span",{className:"commit-acts",children:[ze?h.jsx("span",{className:"live-text",children:ze}):h.jsxs(h.Fragment,{children:[c&&o&&h.jsx(Le,{disabled:!I&&!$||!!p,onClick:ge,...Dt($&&!I?"Commit with the suggested message":"git add -A && git commit","⌘⏎"),children:"commit"}),c&&B&&h.jsx(Le,{tone:"primary",disabled:!!p,"data-tip":ee,onClick:ke,children:"land"}),de&&h.jsx(Le,{tone:"primary",disabled:!!p,"data-tip":p_(P,!!((Vt=we==null?void 0:we.config.check)!=null&&Vt.trim()),z),onClick:Y,children:"check"}),q&&h.jsx("span",{className:"live-text",children:"check"}),xe&&L&&h.jsx(Le,{tone:"primary",disabled:!!p,"data-tip":`Commit, take ${J} in and push the branch; PR #${L.number} takes the new commits`,onClick:ke,children:"update"}),ae&&h.jsx(Le,{tone:"primary",disabled:!!p,"data-tip":"Merge the PR now, by the method the repo allows",onClick:ke,children:"merge"})]}),L&&h.jsxs(Le,{"data-tip":`Open PR #${L.number} on GitHub`,onClick:()=>window.open(L.url,"_blank"),...u.contextMenu(()=>[{id:"open-pr",label:"open on GitHub",onClick:()=>window.open(L.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>Qt(L.url)}]),children:["view ",h.jsx(jt,{name:"external",className:"icon-inline"})]})]})]}),(pe||Re)&&h.jsxs("div",{className:"composer-notes",children:[Re&&h.jsxs("div",{className:"hint composer-note","data-tip":b?w_[b.status]:void 0,children:[h.jsx("span",{children:Re}),_n]}),pe&&h.jsxs("div",{className:"hint composer-note",children:[h.jsx("span",{children:pe}),p==="sync-main"?h.jsx("span",{className:"live-text",children:g?`sync: ${g}`:"sync"}):h.jsx(Le,{variant:"outline",disabled:!!p||!!le,"data-tip":le??`Merge ${J} into this worktree${o?", uncommitted changes kept":""}`,onClick:()=>ti(i,l,{t:"sync-main",worktreeId:f}),children:"sync"})]})]})]})}const H4=S.memo(function({c:t,id:n,selected:r,onToggle:o}){const i=fn("changes");return h.jsxs("button",{className:"row row-sm log-row row-edge",id:n,"data-state":mr({current:r,cursor:r}),role:"option","aria-selected":r,tabIndex:-1,onClick:()=>o(t.sha),...i.contextMenu(()=>o_(t)),"data-tip":`${t.subject}
|
|
119
|
+
${t.short} · ${t.author}`,"data-tip-placement":"follow",children:[h.jsx("span",{className:"subject",children:t.subject}),h.jsx("span",{className:"at row-dim",children:eo(t.at)})]})});function K4(e,t){const n=rs(e,t);if(!n||!An(n))return"take this worktree over to change files here";if(Di(n.worktree))return"start a worktree to change files"}function v_(e,t,n,r){return{id:"new-file",label:"new file…",disabled:K4(e.getState(),t),onClick:()=>r(n)}}function W4(e,t,n,r){const{worktreeId:o,dir:i,path:l,folder:u,newIn:c}=e,f=Nf(t.getState(),o)?void 0:"take this worktree over to talk to an agent here",p=Jg(l,u),m=[...u?[]:[{id:"open",label:"open",onClick:()=>er(n,{worktreeId:o,path:l,view:Fi(l)})}],{id:"add-to-chat",label:"add to chat",disabled:f,onClick:()=>PE(t,o,l,u)}],g=[v_(t,o,c,r),{id:"ask-rename",label:"ask the agent to rename…",disabled:f,onClick:()=>O0(t,o,`Rename ${p} to `)},{id:"ask-delete",label:"ask the agent to delete…",disabled:f,onClick:()=>O0(t,o,`Delete ${p} and update whatever still uses it`)}],w=[...Ef(()=>{var y;return(y=n.sock)==null?void 0:y.send({t:"reveal",worktreeId:o,path:l})},os(n.sock)),{id:"copy-path",label:"copy path",onClick:()=>Qt(`${i}/${l}`)},{id:"copy-relative-path",label:"copy relative path",onClick:()=>Qt(l)}];return Dn([m,w,g])}function Z4(e,t,n,r){return Dn([[v_(t,e.worktreeId,"",r)],Bi(e.dir,()=>{var o;return(o=n.sock)==null?void 0:o.send({t:"reveal",worktreeId:e.worktreeId})},os(n.sock))])}const nd=[],q4=[],X0=new Set,Q0=e=>`tree-row-${e}`;function G4({worktreeId:e,dir:t,openPath:n,openRef:r,rootRef:o}){const i=Zn(),l=lt(),u=at(),c=Tt(e,"files"),f=Tt(e,"submodules"),p=Tt(e,"ignored"),m=Tt(e,"git"),g=(m==null?void 0:m.files)??q4;vt([e,m,l],()=>_f(e,i.getState(),{sock:l,dispatch:u}));const w=M(le=>{var ae;return((ae=le.dragFiles)==null?void 0:ae.at)==="tree"&&le.dragFiles.worktreeId===e?le.dragFiles.dir:null}),y=M(le=>le.treeOpen[e]??nd),x=S.useMemo(()=>new Set(y),[y]),[b,j]=S.useState(X0);vt([e,n,r],()=>j(n&&!r?new Set($d(n).filter(le=>!x.has(le))):X0));const N=S.useCallback(le=>x.has(le)||b.has(le),[x,b]),T=S.useCallback(le=>{const ae=x.has(le)||b.has(le);if(ae&&b.has(le)){const Fe=new Set(b);Fe.delete(le),j(Fe)}u({a:"tree-folder",worktreeId:e,path:le,open:!ae})},[x,b,e,u]),R=S.useMemo(()=>kP(c??nd,f??nd,p??nd),[c,f,p]),$=S.useMemo(()=>wP(R,N),[R,N]),W=S.useMemo(()=>vP(g),[g]),A=M(le=>le.treeReveal),I=A&&A.worktreeId===e?A:null,[_,P]=S.useState(()=>(I==null?void 0:I.path)??null),[z,q]=S.useState({worktreeId:e,linked:I});(z.worktreeId!==e||z.linked!==I)&&(q({worktreeId:e,linked:I}),P((I==null?void 0:I.path)??null));const[se,Y]=S.useState(!1),ge=S.useMemo(()=>{if(_===null)return-1;const le=$.findIndex(ae=>ae.path===_);if(le>=0)return le;for(const ae of $d(_).reverse()){const Fe=$.findIndex(Qe=>Qe.path===ae);if(Fe>=0)return Fe}return-1},[$,_]);vt([ge,se],()=>{var le,ae;se&&((ae=(le=o.current)==null?void 0:le.querySelector('[data-state~="cursor"]'))==null||ae.scrollIntoView({block:"nearest"}))});const ke=S.useCallback((le,ae)=>er({dispatch:u},{worktreeId:e,path:le,view:Fi(le),focus:ae}),[e,l,u]),oe=S.useCallback(le=>{P(le.path),le.kind==="folder"?T(le.path):le.kind==="file"&&ke(le.path,!1)},[T,ke]),L=le=>{var Qe;if(le.metaKey||le.ctrlKey||le.altKey)return;const ae=$[ge],Fe=ze=>{const Re=$[ze];Re&&(P(Re.path),Re.kind==="file"&&ke(Re.path,!1))};switch(le.key){case"ArrowDown":case"ArrowUp":le.preventDefault(),Fe(ge<0?0:$c(ge,le.key==="ArrowDown"?1:-1,$.length));return;case" ":le.preventDefault(),(ae==null?void 0:ae.kind)==="file"?ke(ae.path,!1):(ae==null?void 0:ae.kind)==="folder"&&T(ae.path);return;case"Enter":le.preventDefault(),(ae==null?void 0:ae.kind)==="file"?ke(ae.path,!0):(ae==null?void 0:ae.kind)==="folder"&&T(ae.path);return;case"ArrowRight":case"ArrowLeft":{le.preventDefault();const ze=$.map(ct=>ct.kind==="folder"?{depth:ct.depth,open:ct.open}:{depth:ct.depth}),Re=Cf(ze,ge,le.key);(Re==null?void 0:Re.do)==="to"?Fe(Re.at):Re&&ae&&T(ae.path);return}case"Escape":le.stopPropagation(),n!==null?u({a:"close-editor"}):(Qe=document.activeElement)==null||Qe.blur();return}if(le.key.length===1){const ze=QE($.map(Re=>Re.name),ge,le.key);ze>=0&&(le.preventDefault(),Fe(ze))}},[re,te]=S.useState(null),K=S.useRef(0),B=S.useCallback(le=>{le&&!N(le)&&T(le),K.current++,te({dir:le,error:null,busy:!1})},[N,T]),xe=S.useCallback(()=>{K.current++,te(null)},[]),de=S.useCallback(le=>{if(!re||re.busy)return;const ae=yP(re.dir,le);if("error"in ae){te({...re,error:ae.error});return}const Fe=++K.current;te({...re,error:null,busy:!0}),RE({sock:l,dispatch:u},{worktreeId:e,path:ae.path}).then(Qe=>{Qe===null&&P(ae.path),Fe===K.current&&te(Qe===null?null:{...re,error:Qe,busy:!1})})},[re,e,l,u]),we=fn("tree"),ee=S.useCallback(le=>W4({worktreeId:e,dir:t,path:le.path,folder:le.kind!=="file",newIn:le.kind==="folder"||le.kind==="ignored"?le.path:DE(le.path)},i,{sock:l,dispatch:u},B),[e,t,i,l,u,B]),J=S.useCallback((le,ae)=>{le.kind==="file"&&en.post(e,ae?{type:"highlight-file",path:le.path,ranges:null}:{type:"highlight-clear"})},[e]),pe=S.useCallback((le,ae)=>{ae.dataTransfer.setData(BE,le.path),ae.dataTransfer.setData("text/plain",le.path),ae.dataTransfer.effectAllowed="copy",PP({worktreeId:e,path:le.path,folder:le.kind!=="file"})},[e]),$e=S.useCallback(()=>UE(i),[i]);return h.jsx("div",{className:Ue("tree",w===""&&"drop-over"),role:"tree","aria-label":"files","data-worktree":e,"aria-activedescendant":se&&ge>=0?Q0(ge):void 0,tabIndex:0,ref:o,onKeyDown:L,onFocus:()=>{var le;Y(!0),_===null&&P(n&&$.some(ae=>ae.path===n)?n:((le=$[0])==null?void 0:le.path)??null)},onBlur:le=>!le.currentTarget.contains(le.relatedTarget)&&Y(!1),onMouseDown:le=>{if(le.button!==0)return;const ae=le.target.closest("[data-path]");(ae==null?void 0:ae.dataset.path)!==void 0&&P(ae.dataset.path)},...we.contextMenu(le=>{const ae=$[ge];return le==="keyboard"&&ae?ee(ae):Z4({worktreeId:e,dir:t},i,{sock:l},B)}),children:c===void 0?h.jsx("div",{className:"empty",children:"listing files…"}):$.length===0&&!re?h.jsx("div",{className:"empty",children:"no files"}):V4($.map((le,ae)=>h.jsx(X4,{row:le,id:Q0(ae),status:W.files.get(le.path),changedInside:le.kind!=="file"&&W.folders.has(le.path),current:se?ae===ge:!r&&le.path===n,cursor:se&&ae===ge,dropOver:w===le.path,onPress:oe,menu:ee,onHover:J,onDragStart:pe,onDragEnd:$e},le.path)),re&&(()=>{var ae;const le=re.dir===""?-1:$.findIndex(Fe=>Fe.path===re.dir);return{at:le,node:h.jsx(Y4,{depth:le>=0?(((ae=$[le])==null?void 0:ae.depth)??0)+1:0,error:re.error,onSubmit:de,onCancel:xe},"new-file")}})())})}function V4(e,t){return t?[...e.slice(0,t.at+1),t.node,...e.slice(t.at+1)]:e}function Y4({depth:e,error:t,onSubmit:n,onCancel:r}){const[o,i]=S.useState(""),l={"--tree-depth":e},u=e===0||void 0;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"row row-sm tree-row row-rails","data-kind":"file","data-root":u,style:l,children:[h.jsx("span",{className:"tree-caret row-dim"}),h.jsx(Eo,{bare:!0,font:"mono",autoFocus:!0,className:"tree-new-name","aria-label":"new file name","aria-invalid":t!==null||void 0,placeholder:"name",value:o,onChange:c=>i(c.target.value),onKeyDown:c=>{c.stopPropagation(),c.key==="Enter"?(c.preventDefault(),n(o)):c.key==="Escape"&&(c.preventDefault(),r())},onBlur:r})]}),t&&h.jsxs("div",{className:"tree-row tree-new-error row-rails","data-root":u,style:l,children:[h.jsx("span",{className:"tree-caret"}),h.jsx("span",{className:"hint",children:t})]})]})}const X4=S.memo(function({row:t,id:n,status:r,changedInside:o,current:i,cursor:l,dropOver:u,onPress:c,menu:f,onHover:p,onDragStart:m,onDragEnd:g}){const w=fn("tree"),y=t.kind==="submodule",x=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 h.jsxs("div",{role:"treeitem",id:n,"aria-level":t.depth+1,"aria-expanded":t.kind==="folder"?t.open:void 0,"aria-selected":l,className:Ue("row row-sm tree-row row-rails row-edge",u&&"drop-over"),"data-state":mr({current:i,cursor:l}),"data-kind":t.kind,"data-path":t.path,style:{"--tree-depth":t.depth},draggable:!y,onDragStart:b=>m(t,b),onDragEnd:g,onClick:()=>c(t),onMouseEnter:()=>p(t,!0),onMouseLeave:()=>p(t,!1),...w.contextMenu(()=>f(t)),...x?Dt(x):{},children:[h.jsx("span",{className:"tree-caret row-dim",children:t.kind==="folder"&&h.jsx(jt,{name:"caret",className:Ue("icon-inline disc-caret",!t.open&&"shut")})}),h.jsx("span",{className:Ue("tree-name",(y||t.ignored)&&"row-dim"),children:t.name}),r?h.jsx("span",{className:`xy ${Ig(r.xy)}`,children:Rg(r.xy)}):o&&h.jsx("span",{className:"dot tree-changed"})]})});function b_({f:e}){return e.add===void 0&&e.del===void 0?null:h.jsxs("span",{className:"counts",children:[e.add?h.jsxs("span",{className:"add",children:["+",e.add]}):null,e.del?h.jsxs("span",{className:"del",children:["−",e.del]}):null]})}const rd=S.memo(function({f:t,id:n,active:r,selected:o,checking:i=!1,checked:l=!1,onOpen:u,onCheck:c,menu:f,onHover:p}){const m=fn("changes"),{name:g,dir:w}=TM(t.path);return h.jsxs("button",{className:"row row-sm git-file row-edge",id:n,"data-state":mr({current:r,cursor:o,checked:l}),role:"option","aria-selected":o,tabIndex:-1,onClick:y=>c&&(i||y.shiftKey)?c(t.path):u(t.path),...m.contextMenu(()=>f(t.path)),onMouseEnter:()=>p(t.path,!0),onMouseLeave:()=>p(t.path,!1),children:[i&&h.jsx("input",{type:"checkbox",className:"changes-check",checked:l,readOnly:!0,tabIndex:-1}),h.jsx("span",{className:`xy ${Ig(t.xy)}`,children:Rg(t.xy)}),h.jsxs("span",{className:"path","data-tip":w?t.path:void 0,children:[h.jsx("span",{className:"name",children:g}),w&&h.jsx("span",{className:"dir row-dim",children:w})]}),h.jsx(b_,{f:t})]})}),Q4={added:"A",changed:"M",removed:"D"},J4={added:"added",changed:"",removed:"deleted"},eD=S.memo(function({tests:t,id:n,cursor:r,onPick:o}){return t.map((i,l)=>h.jsxs("button",{className:"row row-sm changes-test row-rails row-edge",id:`${n}-t${l}`,"data-state":mr({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:[h.jsx("span",{className:`xy ${J4[i.change]}`,children:Q4[i.change]}),h.jsx("span",{className:"name",children:i.name})]},l))}),J0=new Set(["test","tests","__tests__","spec","e2e","__snapshots__","__mocks__","fixtures","testdata"]),tD=/([._-]tests?\.[^.]+$)|([._]specs?\.[^.]+$)|(^tests?[._-])|(^conftest\.py$)|(\.snap$)|([a-z0-9](Tests?|Spec)\.[^.]+$)/;function Pd(e){const t=(e.endsWith("/")?e.slice(0,-1):e).split("/"),n=t.pop()??"";return e.endsWith("/")&&J0.has(n.toLowerCase())?!0:t.some(r=>J0.has(r.toLowerCase()))||tD.test(n)}function od(e){const t=e.filter(n=>!Pd(n.path));return t.length===0||t.length===e.length?{files:e,source:t.length}:{files:[...t,...e.filter(n=>Pd(n.path))],source:t.length}}const Cm="(?<q>[\"'`])(?<name>(?:\\\\.|(?!\\k<q>).)*)\\k<q>",eb={tests:[new RegExp(`^\\s*(?:test|it)(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Cm}`)],groups:[new RegExp(`^\\s*describe(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Cm}`)]},nD={js:eb,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*${Cm}`),/^\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*\(/,...eb.tests]}},rD={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"},oD=3,sD=/^\s*(?:[)}\]]|end\b)/,$p=e=>e.length-e.trimStart().length;function tb(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 nb(e,t){const n=t.split(`
|
|
120
|
+
`),r=[],o=[];let i=Number.NEGATIVE_INFINITY;return n.forEach((l,u)=>{var g,w,y;if(l.trim()==="")return;const c=$p(l);for(;o.length>0&&(((g=o.at(-1))==null?void 0:g.indent)??0)>=c;)o.pop();(w=e.mark)!=null&&w.test(l)&&(i=u);const p=!e.mark||u-i<=oD?tb(l,e.tests):null,m=p??tb(l,e.groups);if(m!==null){if(p!==null){i=Number.NEGATIVE_INFINITY;let x=u+1;for(;x<n.length&&(((y=n[x])==null?void 0:y.trim())===""||$p(n[x]??"")>c);)x++;x<n.length&&$p(n[x]??"")===c&&sD.test(n[x]??"")&&x++;const b=n.slice(u,x).map(j=>j.trim()).join(`
|
|
121
|
+
`).trim();r.push({group:o.map(j=>j.name),name:m,line:u,end:x,body:b})}o.push({indent:c,name:m})}}),r}function rb(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 iD(e,t,n){const r=nD[rD[e.slice(e.lastIndexOf(".")+1).toLowerCase()]??""];if(!r)return[];const o=rb(nb(r,t)),i=rb(nb(r,n)),l=[];for(const[p,m]of i){const g=o.get(p);(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 u=n.split(`
|
|
125
|
+
`).length;let c=1;for(const[p,m]of o){const g=i.get(p);g?c=Math.min(g.end+1,u):l.push({name:m.name,group:m.group,change:"removed",line:c})}const f=p=>p.change==="removed"?0:1;return l.sort((p,m)=>p.line-m.line||f(p)-f(m))}const sd=[];function aD(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=eo(r.at);return`${o}, last commit ${i==="now"?"just now":`${i} ago`}`}const ob='[role="option"]:not([data-sub])',sb=[];function x_({width:e,placement:t="dock"}){const n=t==="screen",r=lt(),o=at(),i=Zn(),l=sl(),u=Hi(),c=(u==null?void 0:u.id)??l,f=_s(),p=M(U=>U.layout.changes),m=Ac(),g=M(U=>U.focusChanges),w=Tt(c,"git"),y=M(U=>U.editor&&U.editor.worktreeId===c?U.editor.path:null),x=M(U=>U.editor&&U.editor.worktreeId===c?U.editor.ref??null:null),b=M(U=>U.editor&&U.editor.worktreeId===c?U.editor.since??null:null),j=(w==null?void 0:w.files)??sd,N=(w==null?void 0:w.committed)??sd,{files:T,source:R}=S.useMemo(()=>od(j),[j]),$=N.length>0,W=CL(),{files:A,source:I}=S.useMemo(()=>od(W?N:sd),[N,W]),_=w==null?void 0:w.turn,P=_==null?void 0:_.base,z=AL(),{files:q,source:se}=S.useMemo(()=>od(_&&z?_.files:sd),[_,z]),Y=T.length,ge=T.length+q.length,ke=M(U=>U.editor&&U.editor.worktreeId===c?U.editor.disk:null),oe=S.useMemo(()=>y!==null&&ke&&Pd(y)?iD(y,ke.before,ke.after):sb,[y,ke]),[L,re]=S.useState(!1);vt([y,x,b],()=>re(!1));const te=R>0?T.length-R:0,K=I>0?A.length-I:0,B=se>0?q.length-se:0,xe=T.length===0,de=S.useMemo(()=>{if(T.length===0)return;const U=T.reduce((bt,Ht)=>bt+(Ht.add??0),0),he=T.reduce((bt,Ht)=>bt+(Ht.del??0),0),Be=[U>0&&`+${U}`,he>0&&`−${he}`].filter(Boolean).join(" "),mt=`${T.length} uncommitted ${T.length===1?"file":"files"}`;return Be?`${mt}, ${Be}`:mt},[T]),we=!!w&&xe&&!$,ee=M(Qa),J=u!==null||ee==="changes",pe=u!==null||ee==="history",$e=S.useCallback(U=>o({a:"changes-tab",v:U}),[o]),le=S.useRef(ee);le.current=ee;const ae=S.useRef(null),Fe=Wg(),Qe=M(U=>{const he=ci(U,Fe==null?void 0:Fe.repoId);return he?nf(he):"main"}),ze=Tt(c,"commits"),Re=Tt(c,"commitFiles"),[ct,_n]=S.useState(null),ht=S.useRef(null);ht.current=ct;const tn=S.useRef(null),Vt=Tt(c,"changedRanges"),He=S.useCallback((U,he)=>{if(!c||u)return;if(!he){tn.current=null,en.post(c,{type:"highlight-clear"});return}tn.current=U;const Be=Vt[U];Be?en.post(c,{type:"highlight-file",path:U,ranges:a0(Be)}):r==null||r.send({t:"changed-ranges",worktreeId:c,path:U})},[c,u,Vt,r]);S.useEffect(()=>{const U=tn.current;if(!U||!c)return;const he=Vt[U];he&&en.post(c,{type:"highlight-file",path:U,ranges:a0(he)})},[Vt,c]);const nt=u&&T.length>0?(w==null?void 0:w.head)??null:null,an=S.useCallback((U,he=!1,Be)=>c&&er({dispatch:o},{worktreeId:c,path:U,focus:he,ref:nt??void 0,since:Be}),[c,nt,r,o]),It=S.useMemo(()=>u?T:[...T,...q,...A],[u,T,q,A]),X=S.useMemo(()=>{const U=[];for(const he of ze??[])if(U.push({commit:he}),he.sha===ct)for(const Be of od(Re[he.sha]??[]).files)U.push({commit:he,file:Be});return U},[ze,ct,Re]),fe=S.useMemo(()=>X.filter(U=>!U.file&&U.commit.ahead).length,[X]),dt=S.useMemo(()=>X.findIndex(U=>!U.file&&!U.commit.ahead),[X]),Ke=u?It.length:0,pn=(J?It.length:0)+(pe?X.length:0),mn=S.useMemo(()=>{const U=new Map;if(!u||T.length===0&&X.every(Be=>Be.commit.landedAt))return U;let he;return X.forEach((Be,mt)=>{const bt=!!Be.commit.landedAt;bt!==he&&(he=bt,U.set(mt,bt?"landed":"not landed"))}),U},[u,T,X]),Sn=S.useRef(null),[{row:Ct,at:Nn},ut]=S.useReducer((U,he)=>typeof he=="number"?{row:he,at:-1}:he,{row:0,at:-1}),[Ee,De]=S.useState(!1),gn=(U,he)=>Ee?En(U):he,bn=U=>`changes-row-${U}`,[wn,qn]=S.useState(!1),[ft,Mt]=S.useState([]),nn=S.useCallback(()=>{qn(!1),Mt([])},[]),H=S.useCallback(U=>{qn(!0),Mt(he=>he.includes(U)?he.filter(Be=>Be!==U):[...he,U])},[]),me=S.useMemo(()=>T.filter(U=>ft.includes(U.path)).map(U=>U.path),[T,ft]);vt([T],()=>Mt(U=>{const he=U.filter(Be=>T.some(mt=>mt.path===Be));return he.length===U.length?U:he})),vt([wn],()=>{if(!wn)return;const U=he=>he.key==="Escape"&&nn();return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)}),vt([c,ee],()=>{ut(0),nn()});const _e=w==null?void 0:w.head,Ge=S.useRef("");S.useEffect(()=>{if(!(pe||we)||!c)return;const U=`${c}:${_e??""}`;Ge.current!==U&&(Ge.current=U,r==null||r.send({t:"git-log",worktreeId:c}))},[pe,we,c,_e,r]);const Lt=S.useCallback(U=>{_n(he=>he===U?null:U),c&&!Re[U]&&(r==null||r.send({t:"git-commit",worktreeId:c,sha:U}))},[c,Re,r]);vt([Ct,Nn,Ee],()=>{var U,he;Ee&&((he=(U=Sn.current)==null?void 0:U.querySelector('[data-state~="cursor"]'))==null||he.scrollIntoView({block:"nearest"}))});const Pt=S.useRef(-1),Pe=U=>U>=Y&&U<ge?P:void 0,Oe=U=>{var he;return((he=It[U])==null?void 0:he.path)===y&&(b??void 0)===Pe(U)&&(U<Y?x===nt:!x)};Pt.current=J?It.findIndex((U,he)=>Oe(he)):-1,S.useEffect(()=>{if(!g)return;const U=le.current==="files";Pt.current>=0&&ut(Pt.current);const he=requestAnimationFrame(()=>{var Be;return(Be=(U?ae:Sn).current)==null?void 0:Be.focus()});return()=>cancelAnimationFrame(he)},[g]);const Ve=S.useCallback((U,he=!1)=>{const Be=It[U];Be&&(ut(U),an(Be.path,he,U>=Y&&U<ge?P:void 0),He(Be.path,!0))},[It,an,He,Y,ge,P]),Zt=S.useCallback((U,he=!1)=>{const Be=ht.current;c&&Be&&er({dispatch:o},{worktreeId:c,path:U,ref:Be,focus:he})},[c,r,o]),$t=S.useCallback(U=>{const he=X[U-Ke];he&&(ut(U),he.file&&Zt(he.file.path))},[X,Ke,Zt]),Tn=S.useCallback(U=>{const he=X[U-Ke];he&&(ut(U),he.file?Zt(he.file.path,!0):Lt(he.commit.sha))},[X,Ke,Zt,Lt]),In=U=>pe&&U>=Ke,kn=U=>{if(y===null)return!1;if(J&&U<It.length)return Oe(U);const he=In(U)?X[U-Ke]:void 0;return!!(he!=null&&he.file)&&x===he.commit.sha&&he.file.path===y},kr=U=>kn(U)&&!L?oe:sb,hn=Nn<kr(Ct).length?Nn:-1,En=U=>Ee&&Ct===U&&hn<0,cr=()=>{var he,Be;const U=[];for(let mt=0;mt<pn;mt++){const bt=In(mt)?X[mt-Ke]:void 0,Ht=bt?(he=bt.file)==null?void 0:he.path:(Be=It[mt])==null?void 0:Be.path,Mn=bt!=null&&bt.file?1:0,tr=kr(mt);bt&&!bt.file?U.push({row:mt,at:-1,depth:Mn,open:bt.commit.sha===ct}):Ht!==void 0&&Pd(Ht)?U.push({row:mt,at:-1,depth:Mn,open:tr.length>0}):U.push({row:mt,at:-1,depth:Mn});for(let jo=0;jo<tr.length;jo++)U.push({row:mt,at:jo,depth:Mn+1})}return U},Yt=(U,he=!1)=>{const Be=oe[U];!Be||!c||y===null||er({dispatch:o},{worktreeId:c,path:y,ref:x??void 0,since:b??void 0,line:{n:Be.line},focus:he})},qt=U=>kr(U).length>0&&h.jsx(eD,{tests:oe,id:bn(U),cursor:Ee&&Ct===U?hn:-1,onPick:he=>{ut({row:U,at:he}),Yt(he)}}),zt=U=>{var he;if(wn&&U.key==="Escape")U.preventDefault(),U.stopPropagation(),nn();else if(wn&&U.key===" "){U.preventDefault();const Be=J&&Ct<T.length?T[Ct]:void 0;Be&&H(Be.path)}else if(U.key==="ArrowDown"&&hn+1<kr(Ct).length)U.preventDefault(),ut({row:Ct,at:hn+1}),Yt(hn+1);else if(U.key==="ArrowUp"&&hn>=0)U.preventDefault(),hn===0?ut(Ct):(ut({row:Ct,at:hn-1}),Yt(hn-1));else if(U.key==="Enter"&&hn>=0)U.preventDefault(),Yt(hn,!0);else if(U.key==="ArrowDown"||U.key==="ArrowUp"){U.preventDefault();const Be=$c(Ct,U.key==="ArrowDown"?1:-1,pn);In(Be)?$t(Be):Ve(Be)}else if(U.key==="Enter")U.preventDefault(),In(Ct)?Tn(Ct):Ve(Ct,!0);else if(U.key==="ArrowRight"||U.key==="ArrowLeft"){U.preventDefault();const Be=cr(),mt=Cf(Be,Be.findIndex(Mn=>Mn.row===Ct&&Mn.at===hn),U.key),bt=mt&&Be[mt.at];if(!mt||!bt)return;const Ht=In(bt.row)?X[bt.row-Ke]:void 0;mt.do==="to"?bt.at>=0?(ut({row:bt.row,at:bt.at}),Yt(bt.at)):Ht!=null&&Ht.file&&bt.row>Ct?$t(bt.row):ut(bt.row):Ht&&!Ht.file?Lt(Ht.commit.sha):mt.do==="close"?re(!0):kn(bt.row)?re(!1):Ht!=null&&Ht.file?$t(bt.row):Ve(bt.row)}else U.key==="Escape"&&(U.stopPropagation(),y!==null?o({a:"close-editor"}):(he=document.activeElement)==null||he.blur())},G=u?u.id:f==null?void 0:f.worktree.id,be=u?u.path:f?f.worktree.path:"",Ze=u!==null,pt=S.useCallback(U=>G?ys({id:G,dir:be},U,{discard:!Ze,kept:Ze,ref:nt??void 0,select:Ze?void 0:H},{sock:r,dispatch:o}):[],[G,be,Ze,nt,H,r,o]),Jt=S.useCallback(U=>G?ys({id:G,dir:be},U,{kept:Ze},{sock:r,dispatch:o}):[],[G,be,Ze,r,o]),rn=S.useCallback(U=>G?ys({id:G,dir:be},U,{kept:Ze,since:P},{sock:r,dispatch:o}):[],[G,be,Ze,P,r,o]),Ut=S.useCallback(U=>G?ys({id:G,dir:be},U,{ref:ht.current??void 0,kept:Ze},{sock:r,dispatch:o}):[],[G,be,Ze,r,o]),ur=fn("changes"),Or=()=>{if(J&&Ct<It.length){const he=It[Ct];return he?(Ct<Y?pt:Ct<ge?rn:Jt)(he.path):[]}const U=In(Ct)?X[Ct-Ke]:void 0;return U?U.file?Ut(U.file.path):o_(U.commit):[]},On=(U,he)=>{const Be=It.findIndex((mt,bt)=>bt>=U&&mt.path===he);ut(Be),Oe(Be)&&oe.length>0?re(mt=>!mt):an(he,!1,Pe(Be))},St=S.useRef(On);St.current=On;const je=S.useCallback(U=>St.current(0,U),[]),Se=S.useCallback(U=>St.current(Y,U),[Y]),kt=S.useCallback(U=>St.current(ge,U),[ge]),st=S.useCallback(U=>{ut(Ke+X.findIndex(he=>!he.file&&he.commit.sha===U)),Lt(U)},[X,Ke,Lt]),Ft=S.useCallback(U=>{ut(Ke+X.findIndex(he=>{var Be;return((Be=he.file)==null?void 0:Be.path)===U})),U===y&&x===ht.current&&oe.length>0?re(he=>!he):Zt(U)},[X,Ke,Zt,y,x,oe]),Gt=S.useCallback(()=>{},[]);return h.jsxs("div",{className:Ue("changes-dock",n&&"changes-screen",!n&&(!p||m)&&"collapsed"),style:n?void 0:{width:e},children:[!u&&h.jsx(jf,{fill:!n,quiet:n,owner:"changes-tabs",label:"changes panel",items:[{id:"files",label:h.jsx(jt,{name:"folder",className:"icon-inline"}),fit:!0,ariaLabel:"files",tip:Dt("files",At("files"))},{id:"changes",label:"changes",tip:Dt("changes",At("changes"),{detail:de})},{id:"history",label:"history"}],current:ee,onPick:$e}),ee==="files"&&c?h.jsx(G4,{worktreeId:c,dir:f?f.worktree.path:(Fe==null?void 0:Fe.path)??"",openPath:y,openRef:x,rootRef:ae}):h.jsxs("div",{className:Ue("changes-list",pe&&"history"),role:"listbox","aria-label":u?"kept work":pe?"commits":"changed files","aria-activedescendant":Ee&&Ct>=0&&Ct<pn?hn<0?bn(Ct):`${bn(Ct)}-t${hn}`:void 0,tabIndex:0,ref:Sn,onKeyDown:zt,onFocus:()=>De(!0),onMouseDown:U=>{var mt;if(U.button!==0)return;U.preventDefault();const he=U.target.closest(ob),Be=he?Array.from(U.currentTarget.querySelectorAll(ob)).indexOf(he):-1;Be>=0&&ut(Be),(mt=Sn.current)==null||mt.focus()},onBlur:U=>!U.currentTarget.contains(U.relatedTarget)&&De(!1),...ur.contextMenu(U=>U==="keyboard"?Or():[]),children:[J&&T.length>0&&h.jsxs(h.Fragment,{children:[($||u)&&h.jsx("div",{className:"section-title section-row",children:"uncommitted"}),T.map((U,he)=>h.jsxs(S.Fragment,{children:[te>0&&he===R&&h.jsx("div",{className:"section-title changes-sub",children:"tests"}),h.jsx(rd,{f:U,id:bn(he),active:gn(he,kn(he)),selected:En(he),checking:wn,checked:ft.includes(U.path),onOpen:je,onCheck:Ze?void 0:H,menu:pt,onHover:He}),qt(he)]},`${U.xy}:${U.path}`))]}),J&&!u&&_&&h.jsxs(h.Fragment,{children:[h.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":z,"data-tip":"What changed since your last message","data-tip-placement":"follow",onClick:()=>o({a:"toggle-turn"}),onKeyDown:U=>(U.key==="Enter"||U.key===" ")&&U.stopPropagation(),children:["last turn",h.jsx(jt,{name:"caret",className:Ue("icon-inline disc-caret",!z&&"shut")})]}),q.map((U,he)=>h.jsxs(S.Fragment,{children:[B>0&&he===se&&h.jsx("div",{className:"section-title changes-sub",children:"tests"}),h.jsx(rd,{f:U,id:bn(Y+he),active:gn(Y+he,kn(Y+he)),selected:En(Y+he),onOpen:Se,menu:rn,onHover:He}),qt(Y+he)]},`t-${U.path}`))]}),J&&!u&&$&&h.jsxs(h.Fragment,{children:[h.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":W,"data-tip":`Committed on this branch, not yet on ${Qe}`,"data-tip-placement":"follow",onClick:()=>o({a:"toggle-committed"}),onKeyDown:U=>(U.key==="Enter"||U.key===" ")&&U.stopPropagation(),children:["committed",h.jsx(jt,{name:"caret",className:Ue("icon-inline disc-caret",!W&&"shut")})]}),A.map((U,he)=>h.jsxs(S.Fragment,{children:[K>0&&he===I&&h.jsx("div",{className:"section-title changes-sub",children:"tests"}),h.jsx(rd,{f:U,id:bn(ge+he),active:gn(ge+he,kn(ge+he)),selected:En(ge+he),onOpen:kt,menu:Jt,onHover:He}),qt(ge+he)]},`c-${U.path}`))]}),J&&!u&&we&&h.jsx("div",{className:"empty",children:aD(Qe,!!Fe&&tf(Fe),(w==null?void 0:w.behind)??0,ze==null?void 0:ze[0])}),pe&&X.map((U,he)=>h.jsxs(S.Fragment,{children:[u&&mn.has(he)&&h.jsx("div",{className:"section-title section-row",children:mn.get(he)}),!u&&fe>0&&he===0&&h.jsx("div",{className:"section-title section-row",children:"on this branch"}),!u&&fe>0&&he===dt&&h.jsx("div",{className:"section-title section-row",children:Qe}),U.file?h.jsxs(h.Fragment,{children:[h.jsx(rd,{f:U.file,id:bn(Ke+he),active:gn(Ke+he,kn(Ke+he)),selected:En(Ke+he),onOpen:Ft,menu:Ut,onHover:Gt}),qt(Ke+he)]}):h.jsx(H4,{c:U.commit,id:bn(Ke+he),selected:En(Ke+he),onToggle:st})]},U.file?`${U.commit.sha}:${U.file.path}`:U.commit.sha)),pe&&ze===void 0&&h.jsx("div",{className:"empty",children:"reading history…"}),pe&&(ze==null?void 0:ze.length)===0&&T.length===0&&h.jsx("div",{className:"empty",children:"no commits yet"})]}),wn&&h.jsxs("div",{className:"changes-pick",children:[h.jsxs(Le,{size:"md",tone:"danger",disabled:me.length===0,"data-tip":"Throw away the uncommitted changes to every checked file",onClick:()=>{!G||me.length===0||window.confirm($E(me))&&(r==null||r.send({t:"discard-files",worktreeId:G,paths:me}),nn())},children:["discard ",me.length,"…"]}),h.jsx(Le,{size:"md",disabled:me.length===0,"data-tip":"Name every checked file in the chat",onClick:()=>{G&&hP(i,G,me),nn()},children:"add to chat"}),h.jsx(Ot,{icon:"close",label:"Cancel",hint:"esc",onClick:nn})]}),Fe&&!u&&h.jsx(U4,{active:Fe,ahead:(w==null?void 0:w.ahead)??0,behind:(w==null?void 0:w.behind)??0,unpushed:(w==null?void 0:w.unpushed)??Fe.unpushed??0,dirty:!xe})]})}function lD(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 Oc(e){return e>0&&e<.005?"<$0.01":`$${e.toFixed(2)}`}function cD(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 uD(e){if(!(e<.5))return e<.8?"worth compacting between tasks":"compact before the next task"}const E_=["five_hour","seven_day"],dD={five_hour:"the 5-hour window",seven_day:"the week"},fD={five_hour:"5-hour",seven_day:"this week"};function __(e,t){return E_.flatMap(n=>{const r=e.windows[n];return r&&r.resetsAt>t?[{key:n,used:r.used,resetsAt:r.resetsAt}]:[]})}function hD(e,t){return Math.min(1,Math.max(0,...__(e,t).map(n=>n.used)))}const pD=e=>`${Math.round(100*e)}%`;function ab(e,t){const n=__(e,t).map(r=>`${pD(r.used)} of ${dD[r.key]}`);return n.length?n.join(", "):"plan windows reset"}function mD(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 gD(e,t,n=r=>mD(r,t)){return E_.flatMap(r=>{const o=e.windows[r];if(!o)return[];const i=fD[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 kD(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 S_(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(Oc(e.cost)),t.push(eo(e.archivedAt)),t.filter(Boolean).join(" · ")}function N_({sock:e,dispatch:t},n,r){e==null||e.send({t:"restore-worktree",archiveId:n,clientId:r}),t({a:"restoring",id:n,text:""})}function yd(e,t,{sock:n,dispatch:r}){const o=[{id:"restore",label:"restore",disabled:e.restorable?void 0:"its commits were not kept",onClick:()=>{N_({sock:n,dispatch:r},e.id,t.clientId),r({a:"close"})}}],i=[{id:"copy-branch",label:"copy branch name",onClick:()=>Qt(e.branch)}],{sessionId:l}=e;return t.frame!=="phone"&&(i.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>Qt(e.transcript)}),l&&i.push({id:"copy-session",label:"copy session id",onClick:()=>Qt(l)})),Dn([o,i,[{id:"delete",label:"delete for good…",danger:!0,onClick:()=>{window.confirm(`Delete "${e.title}" for good?
|
|
126
|
+
|
|
127
|
+
Its chat, attachments and kept commits are deleted, and it can no longer be restored.`)&&(n==null||n.send({t:"delete-archived",archiveId:e.id}))}}]])}const wD=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function T_(e){const[t,n]=S.useState(()=>Date.now());return S.useEffect(()=>{const r=setInterval(()=>n(Date.now()),6e4);return()=>clearInterval(r)},[]),`${Og(t-e)} ago`}function Jr({icon:e,word:t,tone:n,at:r,below:o,children:i,...l}){const u=r!==void 0?{"data-tip":`${t} ${wD.format(r)}`,"data-tip-placement":"follow"}:null;return h.jsxs("div",{...u,...l,className:"daemon-row row-edge","data-tone":n,children:[h.jsxs("div",{className:"daemon-head",children:[h.jsxs("span",{className:"daemon-tag",children:[h.jsx(jt,{name:e,className:"icon-inline"}),t]}),i]}),o]})}function yD({item:e}){const t=lt(),n=at(),r=M(p=>p.clientId),o=Tt(e.id,"restoring"),i=e.uncommitted?"its chat, commits and uncommitted changes":"its chat and commits",l=e.cost!==void 0?`; the session cost ${Oc(e.cost)}`:"",u=e.restorable?`Toyon kept ${i}${l}. A message sent below restores it first.`:`Its commits were not kept, so there is nothing to restore${l}; its row's menu on the rail can delete it for good.`,c=T_(e.archivedAt),f=lk(e.lands);return h.jsxs(Jr,{icon:"archive",word:"archived",tone:"quiet",at:e.archivedAt,below:h.jsxs(h.Fragment,{children:[f.map((p,m)=>h.jsx("div",{className:"daemon-below row-dim",children:p},m)),h.jsx("div",{className:"daemon-below row-dim",children:u})]}),children:[h.jsxs("span",{className:"daemon-text",children:[c,e.landed?", after it was merged into main":""]}),e.restorable&&o===void 0&&h.jsx(Le,{variant:"inline",tone:"strong",onClick:()=>N_({sock:t,dispatch:n},e.id,r),children:"restore"})]})}function tl(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 vD(e){let t=0;return e.map(n=>{const r={start:t,len:n};return t+=n,r})}function bD(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 lb(e,t,n){let r=0,o=e.length-1;for(;r<o;){const l=r+o>>1,u=e[l];(n?t>u.start+u.len:t>=u.start+u.len)?r=l+1:o=l}const i=e[r];return{i:r,at:t-i.start}}function xD(e,t){return{from:lb(e,t.start,!1),to:lb(e,t.end,!0)}}function cb(e,t){if(e.length===0)return-1;const n=e.findIndex(r=>r.start>=t);return n===-1?0:n}function ED(e,t,n){return t===0?-1:(e+n+t)%t}function hk(e){return e.key==="f"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function _D({label:e,query:t,onQuery:n,seed:r,seq:o,status:i,none:l,onStep:u,onClose:c}){const f=S.useRef(null);return vt([o],()=>{var p,m;r&&n(r),(p=f.current)==null||p.focus(),(m=f.current)==null||m.select()}),h.jsxs("div",{className:"find",children:[h.jsx(Eo,{ref:f,autoFocus:!0,value:t,onChange:p=>n(p.target.value),placeholder:"find…","aria-label":e,className:"find-field",spellCheck:!1,onKeyDown:p=>{if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),c();return}if(p.key==="Enter"){p.preventDefault(),u(p.shiftKey?-1:1);return}if(hk(p)){p.preventDefault(),p.stopPropagation(),p.currentTarget.select();return}p.key.toLowerCase()==="g"&&(p.metaKey||p.ctrlKey)&&!p.altKey&&(p.preventDefault(),p.stopPropagation(),u(p.shiftKey?-1:1))}}),h.jsx("span",{className:"find-count","aria-live":"polite",children:i}),h.jsx(Ot,{icon:"caret",label:"Previous match",hint:"⇧↩",className:"find-prev",disabled:l,onClick:()=>u(-1)}),h.jsx(Ot,{icon:"caret",label:"Next match",hint:"↩",disabled:l,onClick:()=>u(1)}),h.jsx(Ot,{icon:"close",label:"Close",hint:"esc",onClick:c})]})}const j_="find",C_="find-current",A_=typeof CSS<"u"&&"highlights"in CSS;function SD(e){const t=e.parentElement;return t?typeof t.checkVisibility=="function"?t.checkVisibility():!0:!1}function ND(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&&SD(o)&&n.push(o)}return n}const Am={matches:[],ranges:[]};function TD(e,t){if(!t)return Am;const n=ND(e),r=bD(n.map(l=>l.data).join(""),t),o=vD(n.map(l=>l.data.length)),i=r.map(l=>{const{from:u,to:c}=xD(o,l),f=document.createRange();return f.setStart(n[u.i],u.at),f.setEnd(n[c.i],c.at),f});return{matches:r,ranges:i}}function jD(e,t){A_&&(CSS.highlights.set(j_,new Highlight(...e.filter((n,r)=>r!==t))),CSS.highlights.set(C_,new Highlight(...e[t]?[e[t]]:[])))}function CD(){A_&&(CSS.highlights.delete(j_),CSS.highlights.delete(C_))}function AD(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 ub=48;function ID(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect();n.top>=r.top+ub&&n.bottom<=r.bottom-ub||(e.scrollTop+=n.top-r.top-r.height/3)}function I_({root:e,body:t,seed:n,seq:r,onClose:o,onReveal:i}){const[l,u]=S.useState(n),[c,f]=S.useState(Am),[p,m]=S.useState(-1),g=S.useRef({found:Am,at:-1}),w=S.useRef(""),y=S.useRef(!1),[x,b]=S.useState(0);S.useLayoutEffect(()=>{const R=t.current;if(!R)return;let $=0;const W=new MutationObserver(()=>{$||($=requestAnimationFrame(()=>{$=0,b(A=>A+1)}))});return W.observe(R,{childList:!0,characterData:!0,subtree:!0,attributes:!0}),()=>{W.disconnect(),$&&cancelAnimationFrame($)}},[t]),S.useLayoutEffect(()=>{const R=t.current;if(!R)return;const $=TD(R,l),W=l!==w.current;w.current=l,W&&(y.current=!0);const{found:A,at:I}=g.current;let _;W?A.matches[I]?_=cb($.matches,A.matches[I].start):_=e.current?AD($.ranges,e.current):cb($.matches,0):_=Math.min(I,$.matches.length-1),g.current={found:$,at:_},f($),m(_)},[l,x]),S.useLayoutEffect(()=>{jD(c.ranges,p);const R=c.ranges[p];R&&(y.current&&e.current&&(ID(e.current,R),i==null||i()),y.current=!1)},[c,p,e,i]),S.useLayoutEffect(()=>CD,[]);const j=c.matches.length,N=R=>{if(j===0)return;y.current=!0;const $=ED(g.current.at,j,R);g.current={...g.current,at:$},m($)},T=()=>o(c.ranges[p]??null);return h.jsx(_D,{label:"find in this document",query:l,onQuery:u,seed:n,seq:r,status:l?j===0?"no matches":`${p+1}/${j}`:"",none:j===0,onStep:N,onClose:T})}function R_(e){return e.key==="a"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function $_(e,t,n,r){S.useEffect(()=>{let o=!1;const i=u=>{o=!!e.current&&u.target instanceof Node&&e.current.contains(u.target)},l=u=>{const c=e.current;if(!c||u.defaultPrevented||!t(u))return;const f=document.activeElement;!(f&&f!==document.body?c.contains(f):o)&&!(r!=null&&r(f))||(u.preventDefault(),n(c,u))};return window.addEventListener("pointerdown",i,!0),window.addEventListener("keydown",l),()=>{window.removeEventListener("pointerdown",i,!0),window.removeEventListener("keydown",l)}},[e,t,n,r])}function RD(e){$_(e,R_,O_)}function Im(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 O_(e){const t=document.createRange();t.selectNodeContents(e);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}const M_=({open:e,remove:t})=>[e?[{id:"open",label:"open full size",onClick:e}]:[],t?[{id:"remove",label:"remove",onClick:t}]:[]];function yc(e,t={}){return Dn([[{id:"copy-image",label:"copy image",onClick:()=>nP(e)}],...M_(t)])}function L_(e,t={}){const{text:n,href:r}=e;return Dn([n!==void 0?[{id:"copy-text",label:"copy text",onClick:()=>Qt(n)}]:r?[{id:"copy-text",label:"copy text",onClick:()=>tP(r)}]:[],...M_(t)])}function $D(e){return[CE(e),{id:"copy-link",label:"copy link",onClick:()=>Qt(e)}]}function Rm(e){return e?[{id:"copy-code",label:"copy code",onClick:()=>Qt(e)}]:[]}function Ni(e,t,{dispatch:n,sock:r},o={}){const i=o.link,l=(i==null?void 0:i.kind)==="file"&&t?()=>r==null?void 0:r.send({t:"reveal",worktreeId:t,path:i.file.path}):void 0,u=i?i.kind==="file"?Dd(i.file.path,o.dir??null,l,os(r)):i.kind==="path"||i.kind==="outside"?Dd(i.path,o.dir??null,void 0,os(r)):[$D(i.href)]:[],c=[{id:"copy",label:"copy message",onClick:()=>Qt(e.text)}],f=[];return e.kind==="user"&&t&&f.push({id:"draft",label:"edit in composer",onClick:()=>{const p=e.seq;if(p===void 0||!r)return n({a:"set-draft",id:t,text:e.text});n({a:"set-draft",id:t,text:""}),r.send({t:"redraft",worktreeId:t,seq:p})}}),Dn([Rm(o.code),...u,c,f])}function Dd(e,t,n,r){const o=e.startsWith("/")?e:t?`${t}/${e}`:null;return[o?Bi(o,n,r):[],[{id:"copy-path",label:"copy path",onClick:()=>Qt(e)}]]}function P_(e,t,n,r){return Dn(Dd(e,t,n,r))}function OD(e,t){const n=e.callFile??e.file,r=n?Dd(n,t.dir??null,void 0,t.host):[],o=t.remove?[{id:"remove",label:"remove",onClick:t.remove}]:[];return Dn([...r,o])}const db=8,MD=.7,LD=100,PD=400,DD=260,zD=80,FD=220;function fb({dx:e,dy:t}){return Math.abs(e)<db&&Math.abs(t)<db?null:Math.abs(t)>Math.abs(e)?"away":"other"}function BD(e,t){const n=e.filter(i=>t-i.t<=LD),r=n[0],o=n[n.length-1];return!r||!o||o.t===r.t?0:(o.y-r.y)/(o.t-r.t)}const UD=e=>Math.abs(e)>=MD;function HD(e,t){return Math.min(FD,Math.max(zD,e/Math.abs(t)))}function KD(e,t,n){const r=S.useRef(n);r.current=n,S.useEffect(()=>{const o=e.current;if(!o)return;let i=null,l=!1,u=[],c=0;const f=(x,b,j)=>{j!==void 0&&o.style.setProperty("--swipe-ms",`${j}ms`),o.dataset.swipe!==b&&(o.dataset.swipe=b,o.offsetWidth),o.style.setProperty("--swipe-y",`${x}px`),o.style.setProperty("--swipe-fade",`${Math.min(1,Math.abs(x)/(window.innerHeight/2))}`)},p=()=>{o.style.removeProperty("--swipe-y"),o.style.removeProperty("--swipe-fade"),o.style.removeProperty("--swipe-ms"),delete o.dataset.swipe},m=()=>{const x=l;i=null,l=!1,u=[],x&&(f(0,"settle"),c=window.setTimeout(p,DD))},g=x=>{var N;const b=x.touches[0],j=x.target;if(x.touches.length!==1||!b||(((N=window.visualViewport)==null?void 0:N.scale)??1)>1.01)return m();o.dataset.swipe==="leave"||!(j===o||j!=null&&j.closest(t))||(window.clearTimeout(c),i={x:b.clientX,y:b.clientY,at:x.timeStamp},u=[{y:b.clientY,t:x.timeStamp}])},w=x=>{const b=x.touches[0];if(!i||!b)return;const j=b.clientX-i.x,N=b.clientY-i.y;if(!l){const T=fb({dx:j,dy:N});if(T==="other"&&(i=null),T!=="away")return;l=!0}x.preventDefault(),u.push({y:b.clientY,t:x.timeStamp}),u.length>16&&u.shift(),f(N,"drag")},y=x=>{const b=x.changedTouches[0];if(!i||!b)return;const j=b.clientY-i.y,N=x.timeStamp-i.at;if(!l&&N<PD&&x.target!==o&&fb({dx:b.clientX-i.x,dy:j})===null){x.preventDefault(),i=null,r.current();return}const R=BD(u,x.timeStamp);if(!l||!UD(R))return m();i=null,l=!1,u=[];const $=Math.sign(R)*window.innerHeight,W=HD(Math.abs($-j),R);f($,"leave",W),c=window.setTimeout(()=>r.current(),W)};return o.addEventListener("touchstart",g,{passive:!0}),o.addEventListener("touchmove",w,{passive:!1}),o.addEventListener("touchend",y),o.addEventListener("touchcancel",m),()=>{window.clearTimeout(c),o.removeEventListener("touchstart",g),o.removeEventListener("touchmove",w),o.removeEventListener("touchend",y),o.removeEventListener("touchcancel",m)}},[e,t])}function pk({owner:e,onClose:t,menu:n,children:r}){const o=fn(e),i=S.useRef(null);return KD(i,"img",t),h.jsxs(Ss,{className:"attach-full scrim",boxRef:i,onDismiss:t,onKey:l=>{l.key==="Escape"&&(l.stopPropagation(),t())},onClick:l=>{l.target===l.currentTarget&&t()},...n&&o.contextMenu(n),children:[r,h.jsx(Ot,{icon:"close",label:"Close",tone:"quiet",onClick:t})]})}function WD({item:e}){if(!e.outcome)return null;const t=xM[e.outcome];if(e.ask.kind==="permission"){const{title:n,choices:r}=e.ask,o=r.find(i=>i.id===e.choiceId);return h.jsxs("div",{className:"ask-closed",children:[!e.toolId&&h.jsx("div",{className:"ask-lead",children:n}),h.jsx("div",{className:"ask-answered",children:o?o.name:t??"closed"})]})}return h.jsxs("div",{className:"ask-closed",children:[h.jsx("div",{className:"ask-lead",children:e.ask.message}),h.jsx("div",{className:"ask-answered",children:t??"closed"})]})}const ZD=e=>e.t==="open-path"||e.t==="open-loose",La=new Map,qD=16;function GD({sock:e,dispatch:t},n,r){const o=Ko();La.set(o,{worktreeId:n,href:r.href});for(const i of La.keys()){if(La.size<=qD)break;La.delete(i)}t({a:"link-refused",id:n,v:null}),e==null||e.send({t:"open-by-path",path:r.path,seq:o})}function VD(e,t){const n=La.get(t.seq);n&&(La.delete(t.seq),e.dispatch({a:"link-refused",id:n.worktreeId,v:{href:n.href,message:t.message}}))}function YD(e,t,n){var i;const r=e.getState();if(n.t==="open-path"){const l={dispatch:c=>e.dispatch(c)};if(rs(r,n.worktreeId)){r.activeId!==n.worktreeId&&e.dispatch({a:"activate",id:n.worktreeId}),er(l,{worktreeId:n.worktreeId,path:n.path});return}const u=Object.keys(r.trunks).find(c=>{var f;return((f=r.trunks[c])==null?void 0:f.id)===n.worktreeId});if(!u)return;if(((i=rs(r,r.activeId))==null?void 0:i.repoId)!==u){const c=r.rows.find(f=>f.repoId===u);if(!c)return;e.dispatch({a:"activate",id:c.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:Ko()}})}function mk(e,t){if(!t||t.startsWith("#")||t.startsWith("/")||/^[a-z][a-z\d+.-]*:/i.test(t))return null;const n=t.split(/[?#]/)[0]??"";if(!n)return null;const r=e?e.split("/"):[];for(const o of n.split("/"))if(!(o===""||o==="."))if(o===".."){if(!r.length)return null;r.pop()}else r.push(decodeURIComponent(o));return r.length?r.join("/"):null}const D_=e=>e.slice(0,Math.max(0,e.lastIndexOf("/")));function z_(e,t){let n;try{n=decodeURIComponent(t)}catch{return null}const r=n.match(/#L(\d+)(?:-L?\d+)?$/i);r?n=n.slice(0,r.index):n=n.split(/[?#]/)[0]??"";const o=n.match(/:(\d+)(?::\d+)?$/);o&&(n=n.slice(0,o.index));const i=e.replace(/\/+$/,"");if(!i||!n.startsWith(`${i}/`))return null;const l=n.endsWith("/"),u=n.slice(i.length+1).replace(/\/+$/,"");if(!u||u.split("/").some(p=>p===".."))return null;if(l)return{path:u,folder:!0};const c=(r==null?void 0:r[1])??(o==null?void 0:o[1]),f=c?Number.parseInt(c,10):void 0;return f&&f>0?{path:u,line:f}:{path:u}}function F_(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 XD(e){return e.length<2||!e.startsWith("/")||e.startsWith("//")||/\s/.test(e)?null:e}function gk(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?z_(t,o):null;if(i)return{kind:"file",file:i};const l=F_(o);return l?{kind:"outside",href:o,...l}:{kind:"out",href:o}}function kk(e,t,n,r){const o=gk(e.target,t);if((o==null?void 0:o.kind)==="outside"&&n){e.preventDefault(),GD(r,n,o);return}if((o==null?void 0:o.kind)!=="file"||!n)return;const i=o.file;if(e.preventDefault(),i.folder){cP(r,{worktreeId:n,path:i.path});return}er(r,{worktreeId:n,path:i.path,...i.line?{line:{n:i.line}}:{}})}const QD=150,JD=e=>({side:e,align:"center",offset:12,flip:"side",margin:8});function B_({chip:e,className:t,children:n}){const[r,o]=S.useState(!1),i=M(u=>u.chatSide);S.useEffect(()=>{const u=e.current;if(!u)return;let c=0;const f=()=>{window.clearTimeout(c),o(!1)},p=()=>{window.clearTimeout(c),c=window.setTimeout(()=>o(!0),QD)};return u.addEventListener("mouseenter",p),u.addEventListener("mouseleave",f),u.addEventListener("mousedown",f),()=>{window.clearTimeout(c),u.removeEventListener("mouseenter",p),u.removeEventListener("mouseleave",f),u.removeEventListener("mousedown",f)}},[e]);const l=()=>{var p;const u=e.current;if(!u)return null;const c=u.getBoundingClientRect(),f=((p=u.closest(".chat-log"))==null?void 0:p.getBoundingClientRect())??c;return{left:f.left,right:f.right,top:c.top,bottom:c.bottom}};return r?h.jsx(Ss,{className:Ue("chip-peek",t),anchor:l,placement:JD(i==="left"?"right":"left"),track:!0,children:n}):null}function wk({className:e,label:t,tip:n,peek:r,full:o,menu:i,removeLabel:l,onRemove:u}){const c=S.useRef(null),[f,p]=S.useState(!1),m=fn("chat"),g=o!==void 0;return h.jsxs("div",{ref:c,className:Ue("pick-chip row row-sm",e),"data-tip":g?"Open full size":n,"data-tip-placement":"follow",...m.contextMenu(()=>i({open:g?()=>p(!0):void 0,remove:u})),children:[g?h.jsx("button",{type:"button",className:"chip-link",onClick:()=>p(!0),children:t}):t,u&&h.jsx(Ot,{icon:"close",label:l,tone:"quiet",onClick:u}),g&&r!==void 0&&h.jsx(B_,{chip:c,children:r}),f&&g&&h.jsx(pk,{owner:"chat",onClose:()=>p(!1),menu:()=>i(),children:o})]})}/*! @license DOMPurify 3.4.14 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.14/LICENSE */function hb(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 ez(e){if(Array.isArray(e))return e}function tz(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,i,l,u=[],c=!0,f=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(c=(r=i.call(n)).done)&&(u.push(r.value),u.length!==t);c=!0);}catch(p){f=!0,o=p}finally{try{if(!c&&n.return!=null&&(l=n.return(),Object(l)!==l))return}finally{if(f)throw o}}return u}}function nz(){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 rz(e,t){return ez(e)||tz(e,t)||oz(e,t)||nz()}function oz(e,t){if(e){if(typeof e=="string")return hb(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)?hb(e,t):void 0}}const U_=Object.entries,pb=Object.setPrototypeOf,sz=Object.isFrozen,iz=Object.getPrototypeOf,az=Object.getOwnPropertyDescriptor;let ar=Object.freeze,gr=Object.seal,Ra=Object.create,H_=typeof Reflect<"u"&&Reflect,$m=H_.apply,Om=H_.construct;ar||(ar=function(t){return t});gr||(gr=function(t){return t});$m||($m=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)});Om||(Om=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 ji=or(Array.prototype.forEach),lz=or(Array.prototype.lastIndexOf),mb=or(Array.prototype.pop),Fl=or(Array.prototype.push),cz=or(Array.prototype.splice),Ka=Array.isArray,Gl=or(String.prototype.toLowerCase),Op=or(String.prototype.toString),gb=or(String.prototype.match),Bl=or(String.prototype.replace),kb=or(String.prototype.indexOf),uz=or(String.prototype.trim),dz=or(Number.prototype.toString),fz=or(Boolean.prototype.toString),wb=typeof BigInt>"u"?null:or(BigInt.prototype.toString),yb=typeof Symbol>"u"?null:or(Symbol.prototype.toString),Qr=or(Object.prototype.hasOwnProperty),Ul=or(Object.prototype.toString),Tr=or(RegExp.prototype.test),Ti=hz(TypeError);function or(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 $m(e,t,r)}}function hz(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Om(e,n)}}function sn(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Gl;if(pb&&pb(e,null),!Ka(t))return e;let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const i=n(o);i!==o&&(sz(t)||(t[r]=i),o=i)}e[o]=!0}return e}function pz(e){for(let t=0;t<e.length;t++)Qr(e,t)||(e[t]=null);return e}function uo(e){const t=Ra(null);for(const r of U_(e)){var n=rz(r,2);const o=n[0],i=n[1];Qr(e,o)&&(Ka(i)?t[o]=pz(i):i&&typeof i=="object"&&i.constructor===Object?t[o]=uo(i):t[o]=i)}return t}function mz(e){switch(typeof e){case"string":return e;case"number":return dz(e);case"boolean":return fz(e);case"bigint":return wb?wb(e):"0";case"symbol":return yb?yb(e):"Symbol()";case"undefined":return Ul(e);case"function":case"object":{if(e===null)return Ul(e);const t=e,n=zo(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:Ul(r)}return Ul(e)}default:return Ul(e)}}function zo(e,t){for(;e!==null;){const r=az(e,t);if(r){if(r.get)return or(r.get);if(typeof r.value=="function")return or(r.value)}e=iz(e)}function n(){return null}return n}function gz(e){try{return Tr(e,""),!0}catch{return!1}}const vb=ar(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Mp=ar(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Lp=ar(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),kz=ar(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Pp=ar(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),wz=ar(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),bb=ar(["#text"]),xb=ar(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Dp=ar(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Eb=ar(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),id=ar(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),yz=gr(/{{[\w\W]*|^[\w\W]*}}/g),vz=gr(/<%[\w\W]*|^[\w\W]*%>/g),bz=gr(/\${[\w\W]*/g),xz=gr(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ez=gr(/^aria-[\-\w]+$/),_b=gr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),_z=gr(/^(?:\w+script|data):/i),Sz=gr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Nz=gr(/^html$/i),Tz=gr(/^[a-z][.\w]*(-[.\w]+)+$/i),Sb=gr(/<[/\w!]/g),Nb=gr(/<[/\w]/g),jz=gr(/<\/no(script|embed|frames)/i),Cz=gr(/\/>/i),co={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},K_=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],Az=ar(sn({},K_)),Iz=(function(){const e={};return ji(K_,t=>{e[t]=gr(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),ar(e)})(),Rz=function(){return typeof window>"u"?null:window},$z=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}},Tb=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Gs=function(t,n,r,o){return Qr(t,n)&&Ka(t[n])?sn(o.base?uo(o.base):{},t[n],o.transform):r},zp=function(t,n,r){const o=Qr(t,n)?t[n]:void 0;return o&&typeof o=="object"?uo(o):r()};function W_(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Rz();const t=Ne=>W_(Ne);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==co.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,o=r.currentScript;e.DocumentFragment;const i=e.HTMLTemplateElement,l=e.Node,u=e.Element,c=e.NodeFilter,f=e.NamedNodeMap;f===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const p=e.DOMParser,m=e.trustedTypes,g=u.prototype,w=zo(g,"cloneNode"),y=zo(g,"remove"),x=zo(g,"nextSibling"),b=zo(g,"childNodes"),j=zo(g,"parentNode"),N=zo(g,"shadowRoot"),T=zo(g,"attributes"),R=l&&l.prototype?zo(l.prototype,"nodeType"):null,$=l&&l.prototype?zo(l.prototype,"nodeName"):null,W=l&&l.prototype?zo(l.prototype,"ownerDocument"):null,A=function(O){return R?R(O):O.nodeType},I=function(O){return $?$(O):O.nodeName};if(typeof i=="function"){const Ne=n.createElement("template");Ne.content&&Ne.content.ownerDocument&&(n=Ne.content.ownerDocument)}let _,P="",z,q=!1,se=0;const Y=function(){if(se>0)throw Ti('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.')},ge=function(O){Y(),se++;try{return _.createHTML(O)}finally{se--}},ke=function(O){Y(),se++;try{return _.createScriptURL(O)}finally{se--}},oe=function(){return q||(z=$z(m,o),q=!0),z},L=n,re=L.implementation,te=L.createNodeIterator,K=L.createDocumentFragment,B=L.getElementsByTagName,xe=r.importNode;let de=Tb();t.isSupported=typeof U_=="function"&&typeof j=="function"&&re&&re.createHTMLDocument!==void 0;const we=yz,ee=vz,J=bz,pe=xz,$e=Ez,le=_z,ae=Sz,Fe=Tz;let Qe=_b,ze=null;const Re=sn({},[...vb,...Mp,...Lp,...Pp,...bb]);let ct=null;const _n=sn({},[...xb,...Dp,...Eb,...id]);let ht=Object.seal(Ra(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}})),tn=null,Vt=null;const He=Object.seal(Ra(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let nt=!0,an=!0,It=!1,X=!0,fe=!1,dt=!0,Ke=!1,pn=!1,mn=null,Sn=null,Ct=!1,Nn=!1,ut=!1,Ee=!1,De=!0,gn=!1;const bn="user-content-";let wn=!0,qn=!1,ft={},Mt=null;const nn=sn({},["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 H=null;const me=sn({},["audio","video","img","source","image","track"]);let _e=null;const Ge=sn({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Lt="http://www.w3.org/1998/Math/MathML",Pt="http://www.w3.org/2000/svg",Pe="http://www.w3.org/1999/xhtml";let Oe=Pe,Ve=!1,Zt=null;const $t=sn({},[Lt,Pt,Pe],Op),Tn=ar(["mi","mo","mn","ms","mtext"]);let In=sn({},Tn);const kn=ar(["annotation-xml"]);let kr=sn({},kn);const hn=sn({},["title","style","font","a","script"]);let En=null;const cr=["application/xhtml+xml","text/html"],Yt="text/html";let qt=null,zt=null;const G=n.createElement("form"),be=function(O){return O instanceof RegExp||O instanceof Function},Ze=function(){let O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(zt&&zt===O)return;(!O||typeof O!="object")&&(O={}),O=uo(O),En=cr.indexOf(O.PARSER_MEDIA_TYPE)===-1?Yt:O.PARSER_MEDIA_TYPE,qt=En==="application/xhtml+xml"?Op:Gl,ze=Gs(O,"ALLOWED_TAGS",Re,{transform:qt}),ct=Gs(O,"ALLOWED_ATTR",_n,{transform:qt}),Zt=Gs(O,"ALLOWED_NAMESPACES",$t,{transform:Op}),_e=Gs(O,"ADD_URI_SAFE_ATTR",Ge,{transform:qt,base:Ge}),H=Gs(O,"ADD_DATA_URI_TAGS",me,{transform:qt,base:me}),Mt=Gs(O,"FORBID_CONTENTS",nn,{transform:qt}),tn=Gs(O,"FORBID_TAGS",uo({}),{transform:qt}),Vt=Gs(O,"FORBID_ATTR",uo({}),{transform:qt}),ft=Qr(O,"USE_PROFILES")?O.USE_PROFILES&&typeof O.USE_PROFILES=="object"?uo(O.USE_PROFILES):O.USE_PROFILES:!1,nt=O.ALLOW_ARIA_ATTR!==!1,an=O.ALLOW_DATA_ATTR!==!1,It=O.ALLOW_UNKNOWN_PROTOCOLS||!1,X=O.ALLOW_SELF_CLOSE_IN_ATTR!==!1,fe=O.SAFE_FOR_TEMPLATES||!1,dt=O.SAFE_FOR_XML!==!1,Ke=O.WHOLE_DOCUMENT||!1,Nn=O.RETURN_DOM||!1,ut=O.RETURN_DOM_FRAGMENT||!1,Ee=O.RETURN_TRUSTED_TYPE||!1,Ct=O.FORCE_BODY||!1,De=O.SANITIZE_DOM!==!1,gn=O.SANITIZE_NAMED_PROPS||!1,wn=O.KEEP_CONTENT!==!1,qn=O.IN_PLACE||!1,Qe=gz(O.ALLOWED_URI_REGEXP)?O.ALLOWED_URI_REGEXP:_b,Oe=typeof O.NAMESPACE=="string"?O.NAMESPACE:Pe,In=zp(O,"MATHML_TEXT_INTEGRATION_POINTS",()=>sn({},Tn)),kr=zp(O,"HTML_INTEGRATION_POINTS",()=>sn({},kn));const D=zp(O,"CUSTOM_ELEMENT_HANDLING",()=>Ra(null));if(ht=Ra(null),Qr(D,"tagNameCheck")&&be(D.tagNameCheck)&&(ht.tagNameCheck=D.tagNameCheck),Qr(D,"attributeNameCheck")&&be(D.attributeNameCheck)&&(ht.attributeNameCheck=D.attributeNameCheck),Qr(D,"allowCustomizedBuiltInElements")&&typeof D.allowCustomizedBuiltInElements=="boolean"&&(ht.allowCustomizedBuiltInElements=D.allowCustomizedBuiltInElements),gr(ht),fe&&(an=!1),ut&&(Nn=!0),ft&&(ze=sn({},bb),ct=Ra(null),ft.html===!0&&(sn(ze,vb),sn(ct,xb)),ft.svg===!0&&(sn(ze,Mp),sn(ct,Dp),sn(ct,id)),ft.svgFilters===!0&&(sn(ze,Lp),sn(ct,Dp),sn(ct,id)),ft.mathMl===!0&&(sn(ze,Pp),sn(ct,Eb),sn(ct,id))),He.tagCheck=null,He.attributeCheck=null,Qr(O,"ADD_TAGS")&&(typeof O.ADD_TAGS=="function"?He.tagCheck=O.ADD_TAGS:Ka(O.ADD_TAGS)&&(ze===Re&&(ze=uo(ze)),sn(ze,O.ADD_TAGS,qt))),Qr(O,"ADD_ATTR")&&(typeof O.ADD_ATTR=="function"?He.attributeCheck=O.ADD_ATTR:Ka(O.ADD_ATTR)&&(ct===_n&&(ct=uo(ct)),sn(ct,O.ADD_ATTR,qt))),Qr(O,"ADD_FORBID_CONTENTS")&&Ka(O.ADD_FORBID_CONTENTS)&&(Mt===nn&&(Mt=uo(Mt)),sn(Mt,O.ADD_FORBID_CONTENTS,qt)),wn&&(ze["#text"]=!0),Ke&&sn(ze,["html","head","body"]),ze.table&&(sn(ze,["tbody"]),delete tn.tbody),O.TRUSTED_TYPES_POLICY){if(typeof O.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ti('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof O.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ti('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const ne=_;_=O.TRUSTED_TYPES_POLICY;try{P=ge("")}catch(ye){throw _=ne,ye}}else O.TRUSTED_TYPES_POLICY===null?(_=void 0,P=""):(_===void 0&&(_=oe()),_&&typeof P=="string"&&(P=ge("")));ar&&ar(O),zt=O},pt=sn({},[...Mp,...Lp,...kz]),Jt=sn({},[...Pp,...wz]),rn=function(O,D,ne){return D.namespaceURI===Pe?O==="svg":D.namespaceURI===Lt?O==="svg"&&(ne==="annotation-xml"||In[ne]):!!pt[O]},Ut=function(O,D,ne){return D.namespaceURI===Pe?O==="math":D.namespaceURI===Pt?O==="math"&&kr[ne]:!!Jt[O]},ur=function(O,D,ne){return D.namespaceURI===Pt&&!kr[ne]||D.namespaceURI===Lt&&!In[ne]?!1:!Jt[O]&&(hn[O]||!pt[O])},Or=function(O){let D=j(O);(!D||!D.tagName)&&(D={namespaceURI:Oe,tagName:"template"});const ne=Gl(O.tagName),ye=Gl(D.tagName);return Zt[O.namespaceURI]?O.namespaceURI===Pt?rn(ne,D,ye):O.namespaceURI===Lt?Ut(ne,D,ye):O.namespaceURI===Pe?ur(ne,D,ye):!!(En==="application/xhtml+xml"&&Zt[O.namespaceURI]):!1},On=function(O){Fl(t.removed,{element:O});try{j(O).removeChild(O)}catch{if(y(O),!j(O))throw Ti("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},St=function(O,D,ne){try{O.removeAttributeNode(D)}catch{try{O.removeAttribute(ne)}catch{}}},je=function(O){st(O);const D=b(O);if(D){const ye=[];ji(D,Ae=>{Fl(ye,Ae)}),ji(ye,Ae=>{try{y(Ae)}catch{}})}const ne=T(O);if(ne)for(let ye=ne.length-1;ye>=0;--ye){const Ae=ne[ye],We=Ae&&Ae.name;typeof We=="string"&&St(O,Ae,We)}},Se=function(O,D,ne){if(!ne)try{ne=D.getAttributeNode(O)}catch{ne=null}Fl(t.removed,{attribute:ne||null,from:D});try{ne?D.removeAttributeNode(ne):D.removeAttribute(O)}catch{try{D.removeAttribute(O)}catch{}}if(O==="is")if(Nn||ut)try{On(D)}catch{}else try{D.setAttribute(O,"")}catch{}},kt=function(O){const D=T(O);if(D)for(let ne=D.length-1;ne>=0;--ne){const ye=D[ne],Ae=ye&&ye.name;typeof Ae!="string"||ct[qt(Ae)]||St(O,ye,Ae)}},st=function(O){const D=[O];for(;D.length>0;){const ne=D.pop();A(ne)===co.element&&kt(ne);const Ae=b(ne);if(Ae)for(let We=Ae.length-1;We>=0;--We)D.push(Ae[We])}},Ft=function(O,D){return dt?O==="patchsrc"?!0:O==="for"&&D!=="label"&&D!=="output":!1},Gt=function(O){if(!dt)return;const D=[O];for(;D.length>0;){const ne=D.pop(),ye=A(ne);if(ye===co.processingInstruction||ye===co.comment&&Tr(Nb,ne.data)){try{y(ne)}catch{}continue}if(ye===co.element){const We=ne,xt=qt(I(ne));try{We.hasAttribute&&We.hasAttribute("patchsrc")&&We.removeAttribute("patchsrc"),We.hasAttribute&&We.hasAttribute("for")&&Ft("for",xt)&&We.removeAttribute("for")}catch{}}const Ae=b(ne);if(Ae)for(let We=Ae.length-1;We>=0;--We)D.push(Ae[We])}},U=function(O){let D=null,ne=null;if(Ct)O="<remove></remove>"+O;else{const We=gb(O,/^[\r\n\t ]+/);ne=We&&We[0]}En==="application/xhtml+xml"&&Oe===Pe&&(O='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+O+"</body></html>");const ye=_?ge(O):O;if(Oe===Pe)try{D=new p().parseFromString(ye,En)}catch{}if(!D||!D.documentElement){D=re.createDocument(Oe,"template",null);try{D.documentElement.innerHTML=Ve?P:ye}catch{}}const Ae=D.body||D.documentElement;return O&&ne&&Ae.insertBefore(n.createTextNode(ne),Ae.childNodes[0]||null),Oe===Pe?B.call(D,Ke?"html":"body")[0]:Ke?D.documentElement:Ae},he=function(O){const D=W?W(O):O.ownerDocument;return te.call(D||O,O,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Be=function(O){return O=Bl(O,we," "),O=Bl(O,ee," "),O=Bl(O,J," "),O},mt=function(O){var D;O.normalize();const ne=W?W(O):O.ownerDocument,ye=te.call(ne||O,O,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let Ae=ye.nextNode();for(;Ae;)Ae.data=Be(Ae.data),Ae=ye.nextNode();const We=(D=O.querySelectorAll)===null||D===void 0?void 0:D.call(O,"template");We&&ji(We,xt=>{Ht(xt.content)&&mt(xt.content)})},bt=function(O){const D=$?$(O):null;return typeof D!="string"||qt(D)!=="form"?!1:typeof O.nodeName!="string"||typeof O.textContent!="string"||typeof O.removeChild!="function"||O.attributes!==T(O)||typeof O.removeAttribute!="function"||typeof O.setAttribute!="function"||typeof O.namespaceURI!="string"||typeof O.insertBefore!="function"||typeof O.hasChildNodes!="function"||O.nodeType!==R(O)||O.childNodes!==b(O)},Ht=function(O){if(!R||typeof O!="object"||O===null)return!1;try{return R(O)===co.documentFragment}catch{return!1}},Mn=function(O){if(!R||typeof O!="object"||O===null)return!1;try{return typeof R(O)=="number"}catch{return!1}};function tr(Ne,O,D){Ne.length!==0&&ji(Ne,ne=>{ne.call(t,O,D,zt)})}const jo=function(O,D){return!!(dt&&O.hasChildNodes()&&!Mn(O.firstElementChild)&&Tr(Sb,O.textContent)&&Tr(Sb,O.innerHTML)||dt&&O.namespaceURI===Pe&&Az[D]&&(Mn(O.firstElementChild)||typeof O.textContent=="string"&&Tr(Iz[D],O.textContent))||O.nodeType===co.processingInstruction||dt&&O.nodeType===co.comment&&Tr(Nb,O.data))},xr=function(O,D){if(O instanceof RegExp)return Tr(O,D);if(O instanceof Function){for(var ne=arguments.length,ye=new Array(ne>2?ne-2:0),Ae=2;Ae<ne;Ae++)ye[Ae-2]=arguments[Ae];return!!O(D,...ye)}return!1},js=function(O,D,ne){if(!tn[D]&>(D)&&xr(ht.tagNameCheck,D))return!1;if(wn&&!Mt[D]){const ye=j(O),Ae=b(O);if(Ae&&ye){const We=Ae.length;for(let xt=We-1;xt>=0;--xt){const cn=O===ne?w(Ae[xt],!0):Ae[xt];ye.insertBefore(cn,x(O))}}}return On(O),!0},Mr=function(O,D,ne,ye){return O.length===0?D:D===ne||D===ye?uo(D):D},Lr=function(O,D){return O===D||j(O)!==null?!1:(qn&&st(O),!0)},wr=function(O,D){if(tr(de.beforeSanitizeElements,O,null),Lr(O,D))return!0;if(bt(O))return On(O),!0;const ne=qt(I(O));if(ze=Mr(de.uponSanitizeElement,ze,Re,mn),tr(de.uponSanitizeElement,O,{tagName:ne,allowedTags:ze}),Lr(O,D))return!0;if(jo(O,ne))return On(O),!0;if(tn[ne]||!(He.tagCheck instanceof Function&&He.tagCheck(ne))&&!ze[ne]){const Ae=js(O,ne,D);return Ae===!1&&tr(de.afterSanitizeElements,O,null),Ae}if(A(O)===co.element&&!Or(O)||(ne==="noscript"||ne==="noembed"||ne==="noframes")&&Tr(jz,O.innerHTML))return On(O),!0;if(fe&&O.nodeType===co.text){const Ae=Be(O.textContent);O.textContent!==Ae&&(Fl(t.removed,{element:O.cloneNode()}),O.textContent=Ae)}return tr(de.afterSanitizeElements,O,null),!1},Co=function(O,D,ne){if(Vt[D]||Ft(D,O)||De&&(D==="id"||D==="name")&&(ne in n||ne in G))return!1;const ye=ct[D]||He.attributeCheck instanceof Function&&He.attributeCheck(D,O);return an&&Tr(pe,D)||nt&&Tr($e,D)?!0:ye?_e[D]||Tr(Qe,Bl(ne,ae,""))||(D==="src"||D==="xlink:href"||D==="href")&&O!=="script"&&kb(ne,"data:")===0&&H[O]||It&&!Tr(le,Bl(ne,ae,""))?!0:!ne:gt(O)&&xr(ht.tagNameCheck,O)&&xr(ht.attributeNameCheck,D,O)||D==="is"&&ht.allowCustomizedBuiltInElements&&xr(ht.tagNameCheck,ne)},Xe=sn({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),gt=function(O){return!Xe[Gl(O)]&&Tr(Fe,O)},Ao=function(O,D,ne,ye){if(_&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!ne)switch(m.getAttributeType(O,D)){case"TrustedHTML":return ge(ye);case"TrustedScriptURL":return ke(ye)}return ye},ln=function(O,D,ne,ye){try{ne?O.setAttributeNS(ne,D,ye):O.setAttribute(D,ye),bt(O)?On(O):mb(t.removed)}catch{Se(D,O)}},Xt=function(O){tr(de.beforeSanitizeAttributes,O,null);const D=O.attributes;if(!D||bt(O))return;ct=Mr(de.uponSanitizeAttribute,ct,_n,Sn);const ne={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ct,forceKeepAttr:void 0};let ye=D.length;const Ae=qt(O.nodeName);for(;ye--;){const We=D[ye],xt=We.name,cn=We.namespaceURI,Gn=We.value,Ln=qt(xt),yr=Gn;let nr=xt==="value"?yr:uz(yr);if(ne.attrName=Ln,ne.attrValue=nr,ne.keepAttr=!0,ne.forceKeepAttr=void 0,tr(de.uponSanitizeAttribute,O,ne),nr=ne.attrValue,gn&&(Ln==="id"||Ln==="name")&&kb(nr,bn)!==0&&(Se(xt,O,We),nr=bn+nr),dt&&Tr(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,nr)){Se(xt,O,We);continue}if(Ln==="attributename"&&gb(nr,"href")){Se(xt,O,We);continue}if(!ne.forceKeepAttr){if(!ne.keepAttr){Se(xt,O,We);continue}if(!X&&Tr(Cz,nr)){Se(xt,O,We);continue}if(fe&&(nr=Be(nr)),!Co(Ae,Ln,nr)){Se(xt,O,We);continue}nr=Ao(Ae,Ln,cn,nr),nr!==yr&&ln(O,xt,cn,nr)}}tr(de.afterSanitizeAttributes,O,null)},Pr=function(O){let D=null;const ne=he(O);for(tr(de.beforeSanitizeShadowDOM,O,null);D=ne.nextNode();)if(tr(de.uponSanitizeShadowNode,D,null),wr(D,O),Xt(D),Ht(D.content)&&Pr(D.content),A(D)===co.element){const ye=N(D);Ht(ye)&&(Xn(ye),Pr(ye))}tr(de.afterSanitizeShadowDOM,O,null)},Xn=function(O){const D=[{node:O,shadow:null}];for(;D.length>0;){const ne=D.pop();if(ne.shadow){Pr(ne.shadow);continue}const ye=ne.node,We=A(ye)===co.element,xt=b(ye);if(xt)for(let cn=xt.length-1;cn>=0;--cn)D.push({node:xt[cn],shadow:null});if(We){const cn=$?$(ye):null;if(typeof cn=="string"&&qt(cn)==="template"){const Gn=ye.content;Ht(Gn)&&D.push({node:Gn,shadow:null})}}if(We){const cn=N(ye);Ht(cn)&&D.push({node:null,shadow:cn},{node:cn,shadow:null})}}};return t.sanitize=function(Ne){let O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},D=null,ne=null,ye=null,Ae=null;if(Ve=!Ne,Ve&&(Ne="<!-->"),typeof Ne!="string"&&!Mn(Ne)&&(Ne=mz(Ne),typeof Ne!="string"))throw Ti("dirty is not a string, aborting");if(!t.isSupported)return Ne;pn?(ze=mn,ct=Sn):Ze(O),(de.uponSanitizeElement.length>0||de.uponSanitizeAttribute.length>0)&&(ze=uo(ze)),de.uponSanitizeAttribute.length>0&&(ct=uo(ct)),t.removed=[];const We=qn&&typeof Ne!="string"&&Mn(Ne);if(We){Gt(Ne);const Gn=I(Ne);if(typeof Gn=="string"){const Ln=qt(Gn);if(!ze[Ln]||tn[Ln])throw je(Ne),Ti("root node is forbidden and cannot be sanitized in-place")}if(bt(Ne))throw je(Ne),Ti("root node is clobbered and cannot be sanitized in-place");try{Xn(Ne)}catch(Ln){throw je(Ne),Ln}}else if(Mn(Ne))D=U("<!---->"),ne=D.ownerDocument.importNode(Ne,!0),ne.nodeType===co.element&&ne.nodeName==="BODY"||ne.nodeName==="HTML"?D=ne:D.appendChild(ne),Xn(ne);else{if(!Nn&&!fe&&!Ke&&Ne.indexOf("<")===-1)return _&&Ee?ge(Ne):Ne;if(D=U(Ne),!D)return Nn?null:Ee?P:""}D&&Ct&&On(D.firstChild);const xt=We?Ne:D;try{const Gn=he(xt);for(;ye=Gn.nextNode();)wr(ye,xt),Xt(ye),Ht(ye.content)&&Pr(ye.content)}catch(Gn){throw We&&(je(Ne),ji(t.removed,Ln=>{Ln.element&&st(Ln.element)})),Gn}if(We)return ji(t.removed,Gn=>{Gn.element&&st(Gn.element)}),fe&&mt(Ne),Ne;if(Nn){if(fe&&mt(D),ut)for(Ae=K.call(D.ownerDocument);D.firstChild;)Ae.appendChild(D.firstChild);else Ae=D;return(ct.shadowroot||ct.shadowrootmode)&&(Ae=xe.call(r,Ae,!0)),Ae}let cn=Ke?D.outerHTML:D.innerHTML;return Ke&&ze["!doctype"]&&D.ownerDocument&&D.ownerDocument.doctype&&D.ownerDocument.doctype.name&&Tr(Nz,D.ownerDocument.doctype.name)&&(cn="<!DOCTYPE "+D.ownerDocument.doctype.name+`>
|
|
129
|
+
`+cn),fe&&(cn=Be(cn)),_&&Ee?ge(cn):cn},t.setConfig=function(){let Ne=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ze(Ne),pn=!0,mn=ze,Sn=ct},t.clearConfig=function(){zt=null,pn=!1,mn=null,Sn=null,_=z,P=""},t.isValidAttribute=function(Ne,O,D){zt||Ze({});const ne=qt(Ne),ye=qt(O);return Co(ne,ye,D)},t.addHook=function(Ne,O){typeof O=="function"&&Qr(de,Ne)&&Fl(de[Ne],O)},t.removeHook=function(Ne,O){if(Qr(de,Ne)){if(O!==void 0){const D=lz(de[Ne],O);return D===-1?void 0:cz(de[Ne],D,1)[0]}return mb(de[Ne])}},t.removeHooks=function(Ne){Qr(de,Ne)&&(de[Ne]=[])},t.removeAllHooks=function(){de=Tb()},t}var Oz=W_();function yk(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Wi=yk();function Z_(e){Wi=e}var Ci={exec:()=>null};function ja(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 Wt(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(Ar.caret,"$1"),n=n.replace(o,l),r},getRegex:()=>new RegExp(n,t)};return r}var Mz=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Ar={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:ja(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:ja(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:ja(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:ja(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:ja(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:ja(e=>new RegExp(`^ {0,${e}}>`))},Lz=/^(?:[ \t]*(?:\n|$))+/,Pz=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Dz=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Mc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,zz=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,vk=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,q_=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,G_=Wt(q_).replace(/bull/g,vk).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Fz=Wt(q_).replace(/bull/g,vk).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(),bk=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Bz=/^[^\n]+/,xk=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Uz=Wt(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",xk).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Hz=Wt(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,vk).getRegex(),If="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",Ek=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Kz=Wt("^ {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",Ek).replace("tag",If).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),V_=e=>Wt(bk).replace("hr",Mc).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",If).getRegex(),Wz=V_(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Zz=V_(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),qz=Wt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Zz).getRegex(),_k={blockquote:qz,code:Pz,def:Uz,fences:Dz,heading:zz,hr:Mc,html:Kz,lheading:G_,list:Hz,newline:Lz,paragraph:Wz,table:Ci,text:Bz},jb=Wt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Mc).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",If).getRegex(),Gz={..._k,lheading:Fz,table:jb,paragraph:Wt(bk).replace("hr",Mc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",jb).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",If).getRegex()},Vz={..._k,html:Wt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ek).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:Ci,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Wt(bk).replace("hr",Mc).replace("heading",` *#{1,6} *[^
|
|
130
|
+
]`).replace("lheading",G_).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Yz=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Xz=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Y_=/^( {2,}|\\)\n(?!\s*$)/,Qz=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ts=/[\p{P}\p{S}]/u,al=/[\s\p{P}\p{S}]/u,Lc=/[^\s\p{P}\p{S}]/u,Jz=Wt(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,al).getRegex(),e3=/[\p{Pi}\p{Ps}"']/u,X_=/(?!~)[\p{P}\p{S}]/u,t3=/(?!~)[\s\p{P}\p{S}]/u,n3=/(?:[^\s\p{P}\p{S}]|~)/u,r3=Wt(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Mz?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Q_=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,o3=Wt(Q_,"u").replace(/punct/g,Ts).getRegex(),s3=Wt(Q_,"u").replace(/punct/g,X_).getRegex(),i3=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,a3=Wt(i3,"u").replace(/openQuote/g,e3).replace(/punct/g,Ts).getRegex(),J_="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",l3=Wt(J_,"gu").replace(/notPunctSpace/g,Lc).replace(/punctSpace/g,al).replace(/punct/g,Ts).getRegex(),c3=Wt(J_,"gu").replace(/notPunctSpace/g,n3).replace(/punctSpace/g,t3).replace(/punct/g,X_).getRegex(),u3="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",d3=Wt(u3,"gu").replace(/notPunctSpace/g,Lc).replace(/punctSpace/g,al).replace(/punct/g,Ts).getRegex(),f3=Wt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Lc).replace(/punctSpace/g,al).replace(/punct/g,Ts).getRegex(),h3="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",p3=Wt(h3,"gu").replace(/notPunctSpace/g,Lc).replace(/punctSpace/g,al).replace(/punct/g,Ts).getRegex(),m3=Wt(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ts).getRegex(),g3="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",k3=Wt(g3,"gu").replace(/notPunctSpace/g,Lc).replace(/punctSpace/g,al).replace(/punct/g,Ts).getRegex(),w3=Wt(/\\(punct)/,"gu").replace(/punct/g,Ts).getRegex(),y3=Wt(/^<(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(),v3=Wt(Ek).replace("(?:-->|$)","-->").getRegex(),b3=Wt("^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",v3).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),zd=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,x3=Wt(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",zd).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),eS=Wt(/^!?\[(label)\]\[(ref)\]/).replace("label",zd).replace("ref",xk).getRegex(),tS=Wt(/^!?\[(ref)\](?:\[\])?/).replace("ref",xk).getRegex(),E3=Wt("reflink|nolink(?!\\()","g").replace("reflink",eS).replace("nolink",tS).getRegex(),Cb=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Sk={_backpedal:Ci,anyPunctuation:w3,autolink:y3,blockSkip:r3,br:Y_,code:Xz,del:Ci,delLDelim:Ci,delRDelim:Ci,emStrongLDelim:o3,emStrongRDelimAst:l3,emStrongRDelimUnd:f3,escape:Yz,link:x3,nolink:tS,punctuation:Jz,reflink:eS,reflinkSearch:E3,tag:b3,text:Qz,url:Ci},_3={...Sk,emStrongLDelim:a3,emStrongRDelimAst:d3,emStrongRDelimUnd:p3,link:Wt(/^!?\[(label)\]\((.*?)\)/).replace("label",zd).getRegex(),reflink:Wt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",zd).getRegex()},Mm={...Sk,emStrongRDelimAst:c3,emStrongLDelim:s3,delLDelim:m3,delRDelim:k3,url:Wt(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Cb).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:Wt(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Cb).getRegex()},S3={...Mm,br:Wt(Y_).replace("{2,}","*").getRegex(),text:Wt(Mm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ad={normal:_k,gfm:Gz,pedantic:Vz},Hl={normal:Sk,gfm:Mm,breaks:S3,pedantic:_3},N3={"&":"&","<":"<",">":">",'"':""","'":"'"},Ab=e=>N3[e];function Jo(e,t){if(t){if(Ar.escapeTest.test(e))return e.replace(Ar.escapeReplace,Ab)}else if(Ar.escapeTestNoEncode.test(e))return e.replace(Ar.escapeReplaceNoEncode,Ab);return e}function Ib(e){try{e=encodeURI(e).replace(Ar.percentDecode,"%")}catch{return null}return e}function Rb(e,t){var i;let n=e.replace(Ar.findPipe,(l,u,c)=>{let f=!1,p=u;for(;--p>=0&&c[p]==="\\";)f=!f;return f?"|":" |"}),r=n.split(Ar.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(Ar.slashPipe,"|");return r}function Vs(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 $b(e){let t=e.split(`
|
|
131
|
+
`),n=t.length-1;for(;n>=0&&Ar.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
132
|
+
`)}function T3(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 j3(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 Ob(e,t,n,r,o){let i=t.href,l=t.title||null,u=e[1].replace(o.other.outputLinkReplace,"$1"),c=e[0].charAt(0)==="!";r.state.inLink=!0;let f=r.state.linkEmitted,p=r.state.inRawBlock;r.state.linkEmitted=!1;let m=r.inlineTokens(u),g=r.state.linkEmitted;if(r.state.linkEmitted=f,r.state.inLink=!1,!c){if(g){r.state.inRawBlock=p;return}r.state.linkEmitted=!0}return{type:c?"image":"link",raw:n,href:i,title:l,text:u,tokens:m}}function C3(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let o=r[1];return t.split(`
|
|
133
|
+
`).map(i=>{let l=i.match(n.other.beginningSpace);if(l===null)return i;let[u]=l;return u.length>=o.length?i.slice(o.length):i}).join(`
|
|
134
|
+
`)}var Fd=class{constructor(e){Rt(this,"options");Rt(this,"rules");Rt(this,"lexer");this.options=e||Wi}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]:$b(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=C3(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=Vs(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:Vs(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:Vs(t[0],`
|
|
136
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Vs(t[0],`
|
|
137
|
+
`).split(`
|
|
138
|
+
`),r="",o="",i=[];for(;n.length>0;){let l=!1,u=[],c;for(c=0;c<n.length;c++)if(this.rules.other.blockquoteStart.test(n[c]))u.push(n[c]),l=!0;else if(!l)u.push(n[c]);else break;n=n.slice(c);let f=u.join(`
|
|
139
|
+
`),p=f.replace(this.rules.other.blockquoteSetextReplace,`
|
|
140
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
141
|
+
${f}`:f,o=o?`${o}
|
|
142
|
+
${p}`:p;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,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
|
+
`),x=w.raw+`
|
|
144
|
+
`+y.replace(this.rules.other.blockquoteSetextReplace2,""),b=this.blockquote(x);i[i.length-1]=b,r=`${r}
|
|
145
|
+
${y}`,o=o.substring(0,o.length-w.text.length)+b.text;break}else if((g==null?void 0:g.type)==="list"){let w=g,y=w.raw+`
|
|
146
|
+
`+n.join(`
|
|
147
|
+
`),x=this.list(y);i[i.length-1]=x,r=r.substring(0,r.length-g.raw.length)+x.raw,o=o.substring(0,o.length-w.raw.length)+x.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 c=!1,f="",p="";if(!(t=i.exec(e))||this.rules.block.hr.test(e))break;f=t[0],e=e.substring(f.length);let m=j3(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,p=m.trimStart()):w?y=t[1].length+1:(y=m.search(this.rules.other.nonSpaceChar),y=y>4?1:y,p=m.slice(y),y+=t[1].length),w&&this.rules.other.blankLine.test(g)&&(f+=g+`
|
|
151
|
+
`,e=e.substring(g.length+1),c=!0),!c){let x=this.rules.other.nextBulletRegex(y),b=this.rules.other.hrRegex(y),j=this.rules.other.fencesBeginRegex(y),N=this.rules.other.headingBeginRegex(y),T=this.rules.other.htmlBeginRegex(y),R=this.rules.other.blockquoteBeginRegex(y);for(;e;){let $=e.split(`
|
|
152
|
+
`,1)[0],W;if(g=$,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),W=g):W=g.replace(this.rules.other.tabCharGlobal," "),j.test(g)||N.test(g)||T.test(g)||R.test(g)||x.test(g)||b.test(g))break;if(W.search(this.rules.other.nonSpaceChar)>=y||!g.trim())p+=`
|
|
153
|
+
`+W.slice(y);else{if(w||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||j.test(m)||N.test(m)||b.test(m))break;p+=`
|
|
154
|
+
`+g}w=!g.trim(),f+=$+`
|
|
155
|
+
`,e=e.substring($.length+1),m=W.slice(y)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(f)&&(l=!0)),o.items.push({type:"list_item",raw:f,task:!!this.options.gfm&&this.rules.other.listIsTask.test(p),loose:!1,text:p,tokens:[]}),o.raw+=f}let u=o.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let c of o.items)if(this.lexer.state.top=!1,c.tokens=this.lexer.blockTokens(c.text,[]),!o.loose){let f=c.tokens.filter(m=>m.type==="space"),p=f.length>0&&f.some(m=>this.rules.other.anyLine.test(m.raw));o.loose=p}for(let c of o.items){let f=c.tokens[0];if(c.task&&((f==null?void 0:f.type)==="text"||(f==null?void 0:f.type)==="paragraph")){c.text=c.text.replace(this.rules.other.listReplaceTask,""),f.raw=f.raw.replace(this.rules.other.listReplaceTask,""),f.text=f.text.replace(this.rules.other.listReplaceTask,"");for(let 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 p=this.rules.other.listTaskCheckbox.exec(c.raw);if(p){let m={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};c.checked=m.checked,o.loose?c.tokens[0]&&["paragraph","text"].includes(c.tokens[0].type)&&"tokens"in c.tokens[0]&&c.tokens[0].tokens?(c.tokens[0].raw=m.raw+c.tokens[0].raw,c.tokens[0].text=m.raw+c.tokens[0].text,c.tokens[0].tokens.unshift(m)):c.tokens.unshift({type:"paragraph",raw:m.raw,text:m.raw,tokens:[m]}):c.tokens.unshift(m)}}else c.task&&(c.task=!1)}if(o.loose)for(let c of o.items){c.loose=!0;for(let f of c.tokens)f.type==="text"&&(f.type="paragraph")}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=$b(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:Vs(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=Rb(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:Vs(t[0],`
|
|
158
|
+
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let u of r)this.rules.other.tableAlignRight.test(u)?i.align.push("right"):this.rules.other.tableAlignCenter.test(u)?i.align.push("center"):this.rules.other.tableAlignLeft.test(u)?i.align.push("left"):i.align.push(null);for(let u=0;u<n.length;u++)i.header.push({text:n[u],tokens:this.lexer.inline(n[u]),header:!0,align:i.align[u]});for(let u of o)i.rows.push(Rb(u,i.header.length).map((c,f)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:i.align[f]})));return i}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:Vs(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=Vs(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=T3(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)),Ob(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 Ob(n,o,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,i,l,u=o,c=0,f=r[0][0],p=n===f,m=f==="*"?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]){u+=l;continue}else if(r[5]||r[6]){if(o%3&&!((o+l)%3)){c+=l;continue}if(p)break}if(u-=l,u>0)continue;l=Math.min(l,l+u+c);let g=[...r[0]][0].length,w=e.slice(0,o+r.index+g+l);if(Math.min(o,l)%2){let x=w.slice(1,-1);return{type:"em",raw:w,text:x,tokens:this.lexer.inlineTokens(x)}}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,u=o,c=this.rules.inline.delRDelim;for(c.lastIndex=0,t=t.slice(-1*e.length+o);(r=c.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(l=[...i].length,l!==o))continue;if(r[3]||r[4]){u+=l;continue}if(u-=l,u>0)continue;l=Math.min(l,l+u);let f=[...r[0]][0].length,p=e.slice(0,o+r.index+f+l),m=p.slice(o,-o);return{type:"del",raw:p,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}}}},Uo=class Lm{constructor(t){Rt(this,"tokens");Rt(this,"options");Rt(this,"state");Rt(this,"inlineQueue");Rt(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Wi,this.options.tokenizer=this.options.tokenizer||new Fd,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:Ar,block:ad.normal,inline:Hl.normal};this.options.pedantic?(n.block=ad.pedantic,n.inline=Hl.pedantic):this.options.gfm&&(n.block=ad.gfm,this.options.breaks?n.inline=Hl.breaks:n.inline=Hl.gfm),this.tokenizer.rules=n}static get rules(){return{block:ad,inline:Hl}}static lex(t,n){return new Lm(n).lex(t)}static lexInline(t,n){return new Lm(n).inlineTokens(t)}lex(t){t=t.replace(Ar.carriageReturn,`
|
|
161
|
+
`),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],r=!1){var i,l,u;this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(Ar.tabCharGlobal," ").replace(Ar.spaceLine,""));let o=1/0;for(;t;){if(t.length<o)o=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let c;if((l=(i=this.options.extensions)==null?void 0:i.block)!=null&&l.some(p=>(c=p.call({lexer:this},t,n))?(t=t.substring(c.raw.length),n.push(c),!0):!1))continue;if(c=this.tokenizer.space(t)){t=t.substring(c.raw.length);let p=n.at(-1);c.raw.length===1&&p!==void 0?p.raw+=`
|
|
162
|
+
`:n.push(c);continue}if(c=this.tokenizer.code(t)){t=t.substring(c.raw.length);let p=n.at(-1);(p==null?void 0:p.type)==="paragraph"||(p==null?void 0:p.type)==="text"?(p.raw+=(p.raw.endsWith(`
|
|
163
|
+
`)?"":`
|
|
164
|
+
`)+c.raw,p.text+=`
|
|
165
|
+
`+c.text,this.inlineQueue.at(-1).src=p.text):n.push(c);continue}if(c=this.tokenizer.fences(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.heading(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.hr(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.blockquote(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.list(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.html(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.def(t)){t=t.substring(c.raw.length);let p=n.at(-1);(p==null?void 0:p.type)==="paragraph"||(p==null?void 0:p.type)==="text"?(p.raw+=(p.raw.endsWith(`
|
|
166
|
+
`)?"":`
|
|
167
|
+
`)+c.raw,p.text+=`
|
|
168
|
+
`+c.raw,this.inlineQueue.at(-1).src=p.text):this.tokens.links[c.tag]||(this.tokens.links[c.tag]={href:c.href,title:c.title},n.push(c));continue}if(c=this.tokenizer.table(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.lheading(t)){t=t.substring(c.raw.length),n.push(c);continue}let f=t;if((u=this.options.extensions)!=null&&u.startBlock){let p=1/0,m=t.slice(1),g;this.options.extensions.startBlock.forEach(w=>{g=w.call({lexer:this},m),typeof g=="number"&&g>=0&&(p=Math.min(p,g))}),p<1/0&&p>=0&&(f=t.substring(0,p+1))}if(this.state.top&&(c=this.tokenizer.paragraph(f))){let p=n.at(-1);r&&(p==null?void 0:p.type)==="paragraph"?(p.raw+=(p.raw.endsWith(`
|
|
169
|
+
`)?"":`
|
|
170
|
+
`)+c.raw,p.text+=`
|
|
171
|
+
`+c.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=p.text):n.push(c),r=f.length!==t.length,t=t.substring(c.raw.length);continue}if(c=this.tokenizer.text(t)){t=t.substring(c.raw.length);let p=n.at(-1);(p==null?void 0:p.type)==="text"?(p.raw+=(p.raw.endsWith(`
|
|
172
|
+
`)?"":`
|
|
173
|
+
`)+c.raw,p.text+=`
|
|
174
|
+
`+c.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=p.text):n.push(c);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}linkInText(t){if(!t.includes("["))return!1;let n=this.tokenizer.rules.inline.link;for(let r of t.matchAll(this.tokenizer.rules.inline.blockSkip))if(n.test(r[0])&&t.charAt(r.index-1)!=="!")return!0;for(let r of t.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let o=r[0],i=o.lastIndexOf("[");if(!(o.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,o.slice(i+1,-1)))&&!(i>1&&this.linkInText(o.slice(1,i-1))))return!0}return!1}inlineTokens(t,n=[]){var u,c,f,p,m;this.tokenizer.lexer=this;let r=t;if(this.tokens.links&&t.includes("[")){let g=this.tokenizer.rules.inline.reflinkSearch,w=y=>{let x=y.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,y.slice(x+1,-1)))return y;if(x>1&&y.charAt(0)!=="!"){let b=y.slice(1,x-1);if(this.linkInText(b))return"["+b.replace(g,w)+"]["+"a".repeat(y.length-x-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 x=y?y.length:0;return g.slice(0,x)+"["+"a".repeat(g.length-x-2)+"]"}),r=((c=(u=this.options.hooks)==null?void 0:u.emStrongMask)==null?void 0:c.call({lexer:this},r))??r;let o=!1,i="",l=1/0;for(;t;){if(t.length<l)l=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}o||(i=""),o=!1;let g;if((p=(f=this.options.extensions)==null?void 0:f.inline)!=null&&p.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,x=t.slice(1),b;this.options.extensions.startInline.forEach(j=>{b=j.call({lexer:this},x),typeof b=="number"&&b>=0&&(y=Math.min(y,b))}),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)}},Bd=class{constructor(e){Rt(this,"options");Rt(this,"parser");this.options=e||Wi}space(e){return""}code({text:e,lang:t,escaped:n}){var i;let r=(i=(t||"").match(Ar.notSpaceStart))==null?void 0:i[0],o=e.replace(Ar.endingNewline,"")+`
|
|
175
|
+
`;return r?'<pre><code class="language-'+Jo(r)+'">'+(n?o:Jo(o,!0))+`</code></pre>
|
|
176
|
+
`:"<pre><code>"+(n?o:Jo(o,!0))+`</code></pre>
|
|
177
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
178
|
+
${this.parser.parse(e)}</blockquote>
|
|
179
|
+
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
180
|
+
`}hr(e){return`<hr>
|
|
181
|
+
`}list(e){let t=e.ordered,n=e.start,r="";for(let l=0;l<e.items.length;l++){let u=e.items[l];r+=this.listitem(u)}let o=t?"ol":"ul",i=t&&n!==1?' start="'+n+'"':"";return"<"+o+i+`>
|
|
182
|
+
`+r+"</"+o+`>
|
|
183
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
184
|
+
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
185
|
+
`}table(e){let t="",n="";for(let o=0;o<e.header.length;o++)n+=this.tablecell(e.header[o]);t+=this.tablerow({text:n});let r="";for(let o=0;o<e.rows.length;o++){let i=e.rows[o];n="";for(let l=0;l<i.length;l++)n+=this.tablecell(i[l]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
186
|
+
<thead>
|
|
187
|
+
`+t+`</thead>
|
|
188
|
+
`+r+`</table>
|
|
189
|
+
`}tablerow({text:e}){return`<tr>
|
|
190
|
+
${e}</tr>
|
|
191
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
192
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Jo(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),o=Ib(e);if(o===null)return r;e=o;let i='<a href="'+e+'"';return t&&(i+=' title="'+Jo(t)+'"'),i+=">"+r+"</a>",i}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let o=Ib(e);if(o===null)return Jo(n);e=o;let i=`<img src="${e}" alt="${Jo(n)}"`;return t&&(i+=` title="${Jo(t)}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Jo(e.text)}},Nk=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}},Ho=class Pm{constructor(t){Rt(this,"options");Rt(this,"renderer");Rt(this,"textRenderer");this.options=t||Wi,this.options.renderer=this.options.renderer||new Bd,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Nk}static parse(t,n){return new Pm(n).parse(t)}static parseInline(t,n){return new Pm(n).parseInline(t)}parse(t){var r,o;this.renderer.parser=this;let n="";for(let i=0;i<t.length;i++){let l=t[i];if((o=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&o[l.type]){let c=l,f=this.options.extensions.renderers[c.type].call({parser:this},c);if(f!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(c.type)){n+=f||"";continue}}let u=l;switch(u.type){case"space":{n+=this.renderer.space(u);break}case"hr":{n+=this.renderer.hr(u);break}case"heading":{n+=this.renderer.heading(u);break}case"code":{n+=this.renderer.code(u);break}case"table":{n+=this.renderer.table(u);break}case"blockquote":{n+=this.renderer.blockquote(u);break}case"list":{n+=this.renderer.list(u);break}case"checkbox":{n+=this.renderer.checkbox(u);break}case"html":{n+=this.renderer.html(u);break}case"def":{n+=this.renderer.def(u);break}case"paragraph":{n+=this.renderer.paragraph(u);break}case"text":{n+=this.renderer.text(u);break}default:{let c='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return n}parseInline(t,n=this.renderer){var o,i;this.renderer.parser=this;let r="";for(let l=0;l<t.length;l++){let u=t[l];if((i=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&i[u.type]){let f=this.options.extensions.renderers[u.type].call({parser:this},u);if(f!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(u.type)){r+=f||"";continue}}let c=u;switch(c.type){case"escape":{r+=n.text(c);break}case"html":{r+=n.html(c);break}case"link":{r+=n.link(c);break}case"image":{r+=n.image(c);break}case"checkbox":{r+=n.checkbox(c);break}case"strong":{r+=n.strong(c);break}case"em":{r+=n.em(c);break}case"codespan":{r+=n.codespan(c);break}case"br":{r+=n.br(c);break}case"del":{r+=n.del(c);break}case"text":{r+=n.text(c);break}default:{let f='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(f),"";throw new Error(f)}}}return r}},fd,Vl=(fd=class{constructor(e){Rt(this,"options");Rt(this,"block");this.options=e||Wi}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Uo.lex:Uo.lexInline}provideParser(e=this.block){return e?Ho.parse:Ho.parseInline}},Rt(fd,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),Rt(fd,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),fd),A3=class{constructor(...e){Rt(this,"defaults",yk());Rt(this,"options",this.setOptions);Rt(this,"parse",this.parseMarkdown(!0));Rt(this,"parseInline",this.parseMarkdown(!1));Rt(this,"Parser",Ho);Rt(this,"Renderer",Bd);Rt(this,"TextRenderer",Nk);Rt(this,"Lexer",Uo);Rt(this,"Tokenizer",Fd);Rt(this,"Hooks",Vl);this.use(...e)}walkTokens(e,t){var r,o;let n=[];for(let i of e)switch(n=n.concat(t.call(this,i)),i.type){case"table":{let l=i;for(let u of l.header)n=n.concat(this.walkTokens(u.tokens,t));for(let u of l.rows)for(let c of u)n=n.concat(this.walkTokens(c.tokens,t));break}case"list":{let l=i;n=n.concat(this.walkTokens(l.items,t));break}default:{let l=i;(o=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&o[l.type]?this.defaults.extensions.childTokens[l.type].forEach(u=>{let c=l[u].flat(1/0);n=n.concat(this.walkTokens(c,t))}):l.tokens&&(n=n.concat(this.walkTokens(l.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if("renderer"in o){let i=t.renderers[o.name];i?t.renderers[o.name]=function(...l){let u=o.renderer.apply(this,l);return u===!1&&(u=i.apply(this,l)),u}:t.renderers[o.name]=o.renderer}if("tokenizer"in o){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=t[o.level];i?i.unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}"childTokens"in o&&o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){let o=this.defaults.renderer||new Bd(this.defaults);for(let i in n.renderer){if(!(i in o))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let l=i,u=n.renderer[l],c=o[l];o[l]=(...f)=>{let p=u.apply(o,f);return p===!1&&(p=c.apply(o,f)),p||""}}r.renderer=o}if(n.tokenizer){let o=this.defaults.tokenizer||new Fd(this.defaults);for(let i in n.tokenizer){if(!(i in o))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let l=i,u=n.tokenizer[l],c=o[l];o[l]=(...f)=>{let p=u.apply(o,f);return p===!1&&(p=c.apply(o,f)),p}}r.tokenizer=o}if(n.hooks){let o=this.defaults.hooks||new Vl;for(let i in n.hooks){if(!(i in o))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let l=i,u=n.hooks[l],c=o[l];Vl.passThroughHooks.has(i)?o[l]=f=>{if(this.defaults.async&&Vl.passThroughHooksRespectAsync.has(i))return(async()=>{let m=await u.call(o,f);return c.call(o,m)})();let p=u.call(o,f);return c.call(o,p)}:o[l]=(...f)=>{if(this.defaults.async)return(async()=>{let m=await u.apply(o,f);return m===!1&&(m=await c.apply(o,f)),m})();let p=u.apply(o,f);return p===!1&&(p=c.apply(o,f)),p}}r.hooks=o}if(n.walkTokens){let o=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(l){let u=[];return u.push(i.call(this,l)),o&&(u=u.concat(o.call(this,l))),u}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Uo.lex(e,t??this.defaults)}parser(e,t){return Ho.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},o={...this.defaults,...r},i=this.onError(!!o.silent,!!o.async);if(this.defaults.async===!0&&r.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(o.hooks&&(o.hooks.options=o,o.hooks.block=e),o.async)return(async()=>{let l=o.hooks?await o.hooks.preprocess(t):t,u=await(o.hooks?await o.hooks.provideLexer(e):e?Uo.lex:Uo.lexInline)(l,o),c=o.hooks?await o.hooks.processAllTokens(u):u;o.walkTokens&&await Promise.all(this.walkTokens(c,o.walkTokens));let f=await(o.hooks?await o.hooks.provideParser(e):e?Ho.parse:Ho.parseInline)(c,o);return o.hooks?await o.hooks.postprocess(f):f})().catch(i);try{o.hooks&&(t=o.hooks.preprocess(t));let l=(o.hooks?o.hooks.provideLexer(e):e?Uo.lex:Uo.lexInline)(t,o);o.hooks&&(l=o.hooks.processAllTokens(l)),o.walkTokens&&this.walkTokens(l,o.walkTokens);let u=(o.hooks?o.hooks.provideParser(e):e?Ho.parse:Ho.parseInline)(l,o);return o.hooks&&(u=o.hooks.postprocess(u)),u}catch(l){return i(l)}}}onError(e,t){return n=>{if(n.message+=`
|
|
193
|
+
Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+Jo(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},Ui=new A3;function yn(e,t){return Ui.parse(e,t)}yn.options=yn.setOptions=function(e){return Ui.setOptions(e),yn.defaults=Ui.defaults,Z_(yn.defaults),yn};yn.getDefaults=yk;yn.defaults=Wi;function I3(...e){return Ui.use(...e),yn.defaults=Ui.defaults,Z_(yn.defaults),yn}yn.use=I3;yn.walkTokens=function(e,t){return Ui.walkTokens(e,t)};yn.parseInline=Ui.parseInline;yn.Parser=Ho;yn.parser=Ho.parse;yn.Renderer=Bd;yn.TextRenderer=Nk;yn.Lexer=Uo;yn.lexer=Uo.lex;yn.Tokenizer=Fd;yn.Hooks=Vl;yn.parse=yn;yn.options;yn.setOptions;yn.walkTokens;yn.parseInline;Ho.parse;Uo.lex;const Ud=100,R3=e=>e.type==="text-delta"||e.type==="thinking-delta"||e.type==="tool-delta";function $3(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 O3={now:()=>performance.now(),after:(e,t)=>void setTimeout(t,e)};function M3(e,t=O3){let n=[],r=!1,o=Number.NEGATIVE_INFINITY;const i=()=>{if(r=!1,n.length===0)return;const l=n;n=[],o=t.now();for(const u of l)e(u)};return l=>{if(l.t==="agent"&&R3(l.event)){const u={...l,event:{...l.event}},c=t.now();if(n.length===0&&c-o>=Ud){o=c,e(u);return}const f=n[n.length-1];f&&$3(f,u)?f.event={...f.event,text:f.event.text+u.event.text}:n.push(u),r||(r=!0,t.after(Math.max(0,o+Ud-c),i));return}i(),e(l)}}const nS="#toyon-link-pending",L3=/!?\[([^[\]\n]*)(?:\]\(([^()\s]*))?$/;function P3(e){const t=e.lastIndexOf(`
|
|
194
|
+
`)+1,n=e.slice(t),r=L3.exec(n);return!r||D3(e.slice(0,t))||z3(n.slice(0,r.index))?e:`${e.slice(0,t)}${n.slice(0,r.index)}[${r[1]}](${nS})`}function D3(e){let t=!1;for(const n of e.split(`
|
|
195
|
+
`))/^\s*(```|~~~)/.test(n)&&(t=!t);return t}function z3(e){let t=0;for(const n of e)n==="`"&&t++;return t%2===1}const Fp="__[a-z][a-z0-9_]*[a-z0-9]__",F3=new RegExp(`^(?:${Fp}\\.)+${Fp}|^${Fp}(?=\\.\\w|\\(|["'])`),B3={name:"dunder",level:"inline",start:e=>e.indexOf("__"),tokenizer(e){const t=F3.exec(e);if(t)return{type:"dunder",raw:t[0],text:t[0]}},renderer:e=>e.text};function U3(e){if(e.header.some(n=>n.text.trim()))return!1;let t="";for(const n of e.rows){let r="";for(const o of n)r+=this.tablecell(o);t+=this.tablerow({text:r})}return`<table>
|
|
196
|
+
<tbody>${t}</tbody></table>
|
|
197
|
+
`}function H3(e){const t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const o={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},i=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),l={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},u={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,o]};o.contains.push(u);const c={match:/\\"/},f={className:"string",begin:/'/,end:/'/},p={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},x=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],b=["true","false"],j={match:/(\/[a-z._-]+)+/},N=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],T=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],R=["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:x,literal:b,built_in:[...N,...T,"set","shopt",...R,...$]},contains:[w,e.SHEBANG(),y,m,i,l,j,u,c,f,p,n]}}const K3=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_-]*/}}),W3=["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"],Z3=["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"],q3=[...W3,...Z3],G3=["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(),V3=["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(),Y3=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),X3=["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 Q3(e){const t=e.regex,n=K3(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},o="and or not only",i=/@-?\w[\w]*(-\w+)*/,l="[a-zA-Z-][a-zA-Z0-9_-]*",u=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+l,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+V3.join("|")+")"},{begin:":(:)?("+Y3.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+X3.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,n.UNICODE_RANGE,...u,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...u,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:o,attribute:G3.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...u,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+q3.join("|")+")\\b"}]}}function J3(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 e5(e){const t=e.regex,n={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:e.NUMBER_RE}]},r=e.COMMENT();r.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];const o={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},i={className:"literal",begin:/\bon|off|true|false|yes|no\b/},l={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},u={begin:/\[/,end:/\]/,contains:[r,i,o,l,n,"self"],relevance:0},c=/[A-Za-z0-9_-]+/,f=/"(\\"|[^"])*"/,p=/'[^']*'/,m=t.either(c,f,p),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,u,i,o,l,n]}}]}}const Mb="[A-Za-z$_][0-9A-Za-z$_]*",t5=["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"],n5=["true","false","null","undefined","NaN","Infinity"],rS=["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"],oS=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],sS=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],r5=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],o5=[].concat(sS,rS,oS);function s5(e){const t=e.regex,n=(L,{after:re})=>{const te="</"+L[0].slice(1);return L.input.indexOf(te,re)!==-1},r=Mb,o={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(L,re)=>{const te=L[0].length+L.index,K=L.input[te];if(K==="<"||K===","){re.ignoreMatch();return}K===">"&&(n(L,{after:te})||re.ignoreMatch());let B;const xe=L.input.substring(te);if(B=xe.match(/^\s*=/)){re.ignoreMatch();return}if((B=xe.match(/^\s+extends\s+/))&&B.index===0){re.ignoreMatch();return}}},u={$pattern:Mb,keyword:t5,literal:n5,built_in:o5,"variable.language":r5},c="[0-9](_?[0-9])*",f=`\\.(${c})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${p})((${f})|\\.)?|(${f}))[eE][+-]?(${c})\\b`},{begin:`\\b(${p})\\b((${f})\\b|\\.)?|(${f})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:u,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"}},x={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},b={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},N={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},T=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,y,x,b,{match:/\$\d+/},m];g.contains=T.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(T)});const R=[].concat(N,g.contains),$=R.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(R)}]),W={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:$},A={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},I={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...rS,...oS]}},_={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},P={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[W],illegal:/%/},z={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function q(L){return t.concat("(?!",L.join("|"),")")}const se={match:t.concat(/\b/,q([...sS,"super","import","await"].map(L=>`${L}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},Y={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},ge={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},W]},ke="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",oe={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ke)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[W]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:$,CLASS_REFERENCE:I},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),_,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,y,x,b,N,{match:/\$\d+/},m,I,{scope:"attr",match:r+t.lookahead(":"),relevance:0},oe,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[N,e.REGEXP_MODE,{className:"function",begin:ke,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:$}]}]},{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"]}]}]},P,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[W,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},Y,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[W]},se,z,A,ge,{match:/\$[(.]/}]}}const i5="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",a5={scope:"number",match:i5,relevance:0};function l5(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,a5,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function c5(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={match:/^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/},o={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},i={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},l={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},u=/[A-Za-z][A-Za-z0-9+.-]*/,c={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,u,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},f={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},p={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},m=e.inherit(f,{contains:[]}),g=e.inherit(p,{contains:[]});f.contains.push(g),p.contains.push(m);let w=[n,c];return[f,p,m,g].forEach(j=>{j.contains=j.contains.concat(w)}),w=w.concat(f,p),{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,f,p,{className:"quote",begin:"^>\\s+",contains:w,end:"$"},o,c,l,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function u5(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","lazy","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],u={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","aiter","all","anext","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozendict","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","sentinel","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},c={className:"meta",begin:/^(>>>|\.\.\.) /},f={className:"subst",begin:/\{/,end:/\}/,keywords:u,illegal:/#/},p={begin:/\{\{/,relevance:0},m={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,c,p,f]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,c,p,f]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,p,f]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,p,f]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},g="[0-9](_?[0-9])*",w=`(\\b(${g}))?\\.(${g})|\\b(${g})\\.`,y=`\\b|${r.join("|")}`,x={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})`}]},b={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:u,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},j={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:["self",c,x,m,e.HASH_COMMENT_MODE]}]};return f.contains=[m,x,c],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:u,illegal:/(<\/|\?)|=>/,contains:[c,x,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},m,b,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[j]},{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:[x,j,m]}]}}function d5(e){const t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),o=t.concat(n,e.IDENT_RE),i={scope:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!(?:let|for|while|if|else|match)\b)/,o,t.lookahead(/\s*\(/))},l="([ui](8|16|32|64|128|size)|f(16|32|64|128))?",u=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","raw","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],c=["true","false","Some","None","Ok","Err"],f=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],p=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f16","f32","f64","f128","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:p,keyword:u,literal:c,built_in:f},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{scope:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|"|\\|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{scope:"number",variants:[{begin:"\\b0b([01_]+)"+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:f,type:p}},{scope:"punctuation",begin:"->"},i]}}const Hd="[A-Za-z$_][0-9A-Za-z$_]*",iS=["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"],aS=["true","false","null","undefined","NaN","Infinity"],lS=["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"],cS=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],uS=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],dS=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],fS=[].concat(uS,lS,cS);function f5(e){const t=e.regex,n=(L,{after:re})=>{const te="</"+L[0].slice(1);return L.input.indexOf(te,re)!==-1},r=Hd,o={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(L,re)=>{const te=L[0].length+L.index,K=L.input[te];if(K==="<"||K===","){re.ignoreMatch();return}K===">"&&(n(L,{after:te})||re.ignoreMatch());let B;const xe=L.input.substring(te);if(B=xe.match(/^\s*=/)){re.ignoreMatch();return}if((B=xe.match(/^\s+extends\s+/))&&B.index===0){re.ignoreMatch();return}}},u={$pattern:Hd,keyword:iS,literal:aS,built_in:fS,"variable.language":dS},c="[0-9](_?[0-9])*",f=`\\.(${c})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${p})((${f})|\\.)?|(${f}))[eE][+-]?(${c})\\b`},{begin:`\\b(${p})\\b((${f})\\b|\\.)?|(${f})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:u,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"}},x={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},b={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},N={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},T=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,y,x,b,{match:/\$\d+/},m];g.contains=T.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(T)});const R=[].concat(N,g.contains),$=R.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(R)}]),W={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:$},A={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},I={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...lS,...cS]}},_={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},P={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[W],illegal:/%/},z={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function q(L){return t.concat("(?!",L.join("|"),")")}const se={match:t.concat(/\b/,q([...uS,"super","import","await"].map(L=>`${L}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},Y={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},ge={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},W]},ke="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",oe={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ke)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[W]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:$,CLASS_REFERENCE:I},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),_,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,y,x,b,N,{match:/\$\d+/},m,I,{scope:"attr",match:r+t.lookahead(":"),relevance:0},oe,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[N,e.REGEXP_MODE,{className:"function",begin:ke,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:$}]}]},{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"]}]}]},P,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[W,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},Y,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[W]},se,z,A,ge,{match:/\$[(.]/}]}}function h5(e){const t=e.regex,n=f5(e),r=Hd,o=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},l={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:o},contains:[n.exports.CLASS_REFERENCE]},u={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},c=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],f={$pattern:Hd,keyword:iS.concat(c),literal:aS,built_in:fS.concat(o),"variable.language":dS},p={className:"meta",begin:"@"+r},m=(x,b,j)=>{const N=x.contains.findIndex(T=>T.label===b);if(N===-1)throw new Error("can not find mode to replace");x.contains.splice(N,1,j)};Object.assign(n.keywords,f),n.exports.PARAMS_CONTAINS.push(p);const g=n.contains.find(x=>x.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([p,i,l,w]),m(n,"shebang",e.SHEBANG()),m(n,"use_strict",u);const y=n.contains.find(x=>x.label==="func.def");return y.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function p5(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,o={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},l=e.inherit(i,{begin:/\(/,end:/\)/}),u=e.inherit(e.APOS_STRING_MODE,{className:"string"}),c=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),f={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[o]},{begin:/'/,end:/'/,contains:[o]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[i,c,u,l,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,l,c,u]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},o,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[f],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:"css"}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[f],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:"javascript"}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:f}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function m5(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},o={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},i={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},l={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,o]},u=e.inherit(l,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),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},x={begin:"\\[",end:"\\]",contains:[w],illegal:"\\n",relevance:0},b=[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,x,i,l],j=[...b];return j.pop(),j.push(u),w.contains=j,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:b}}var Bp,Lb;function g5(){if(Lb)return Bp;Lb=1;function e(H){return H instanceof Map?H.clear=H.delete=H.set=function(){throw new Error("map is read-only")}:H instanceof Set&&(H.add=H.clear=H.delete=function(){throw new Error("set is read-only")}),Object.freeze(H),Object.getOwnPropertyNames(H).forEach(me=>{const _e=H[me],Ge=typeof _e;(Ge==="object"||Ge==="function")&&!Object.isFrozen(_e)&&e(_e)}),H}class t{constructor(me){me.data===void 0&&(me.data={}),this.data=me.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(H){return H.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(H,...me){const _e=Object.create(null);for(const Ge in H)_e[Ge]=H[Ge];return me.forEach(function(Ge){for(const Lt in Ge)_e[Lt]=Ge[Lt]}),_e}const o="</span>",i=H=>!!H.scope,l=(H,{prefix:me})=>{if(H.startsWith("language:"))return H.replace("language:","language-");if(H.includes(".")){const _e=H.split(".");return[`${me}${_e.shift()}`,..._e.map((Ge,Lt)=>`${Ge}${"_".repeat(Lt+1)}`)].join(" ")}return`${me}${H}`};class u{constructor(me,_e){this.buffer="",this.classPrefix=_e.classPrefix,me.walk(this)}addText(me){this.buffer+=n(me)}openNode(me){if(!i(me))return;const _e=l(me.scope,{prefix:this.classPrefix});this.span(_e)}closeNode(me){i(me)&&(this.buffer+=o)}value(){return this.buffer}span(me){this.buffer+=`<span class="${me}">`}}const c=(H={})=>{const me={children:[]};return Object.assign(me,H),me};class f{constructor(){this.rootNode=c(),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 _e=c({scope:me});this.add(_e),this.stack.push(_e)}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,_e){return typeof _e=="string"?me.addText(_e):_e.children&&(me.openNode(_e),_e.children.forEach(Ge=>this._walk(me,Ge)),me.closeNode(_e)),me}static _collapse(me){typeof me!="string"&&me.children&&(me.children.every(_e=>typeof _e=="string")?me.children=[me.children.join("")]:me.children.forEach(_e=>{f._collapse(_e)}))}}class p extends f{constructor(me){super(),this.options=me}addText(me){me!==""&&this.add(me)}startScope(me){this.openNode(me)}endScope(){this.closeNode()}__addSublanguage(me,_e){const Ge=me.root;_e&&(Ge.scope=`language:${_e}`),this.add(Ge)}toHTML(){return new u(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function m(H){return H?typeof H=="string"?H:H.source:null}function g(H){return x("(?=",H,")")}function w(H){return x("(?:",H,")*")}function y(H){return x("(?:",H,")?")}function x(...H){return H.map(_e=>m(_e)).join("")}function b(H){const me=H[H.length-1];return typeof me=="object"&&me.constructor===Object?(H.splice(H.length-1,1),me):{}}function j(...H){return"("+(b(H).capture?"":"?:")+H.map(Ge=>m(Ge)).join("|")+")"}function N(H){return new RegExp(H.toString()+"|").exec("").length-1}function T(H,me){const _e=H&&H.exec(me);return _e&&_e.index===0}const R=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function $(H,{joinWith:me}){let _e=0;return H.map(Ge=>{_e+=1;const Lt=_e;let Pt=m(Ge),Pe="";for(;Pt.length>0;){const Oe=R.exec(Pt);if(!Oe){Pe+=Pt;break}Pe+=Pt.substring(0,Oe.index),Pt=Pt.substring(Oe.index+Oe[0].length),Oe[0][0]==="\\"&&Oe[1]?Pe+="\\"+String(Number(Oe[1])+Lt):(Pe+=Oe[0],Oe[0]==="("&&_e++)}return Pe}).map(Ge=>`(${Ge})`).join(me)}const W=/\b\B/,A="[a-zA-Z]\\w*",I="[a-zA-Z_]\\w*",_="\\b\\d+(\\.\\d+)?",P="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",z="\\b(0b[01]+)",q="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",se=(H={})=>{const me=/^#![ ]*\//;return H.binary&&(H.begin=x(me,/.*\b/,H.binary,/\b.*/)),r({scope:"meta",begin:me,end:/$/,relevance:0,"on:begin":(_e,Ge)=>{_e.index!==0&&Ge.ignoreMatch()}},H)},Y={begin:"\\\\[\\s\\S]",relevance:0},ge={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[Y]},ke={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[Y]},oe={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/},L=function(H,me,_e={}){const Ge=r({scope:"comment",begin:H,end:me,contains:[]},_e);Ge.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const Lt=j("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return Ge.contains.push({begin:x(/[ ]+/,"(",Lt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Ge},re=L("//","$"),te=L("/\\*","\\*/"),K=L("#","$"),B={scope:"number",begin:_,relevance:0},xe={scope:"number",begin:P,relevance:0},de={scope:"number",begin:z,relevance:0},we={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[Y,{begin:/\[/,end:/\]/,relevance:0,contains:[Y]}]},ee={scope:"title",begin:A,relevance:0},J={scope:"title",begin:I,relevance:0},pe={begin:"\\.\\s*"+I,relevance:0};var le=Object.freeze({__proto__:null,APOS_STRING_MODE:ge,BACKSLASH_ESCAPE:Y,BINARY_NUMBER_MODE:de,BINARY_NUMBER_RE:z,COMMENT:L,C_BLOCK_COMMENT_MODE:te,C_LINE_COMMENT_MODE:re,C_NUMBER_MODE:xe,C_NUMBER_RE:P,END_SAME_AS_BEGIN:function(H){return Object.assign(H,{"on:begin":(me,_e)=>{_e.data._beginMatch=me[1]},"on:end":(me,_e)=>{_e.data._beginMatch!==me[1]&&_e.ignoreMatch()}})},HASH_COMMENT_MODE:K,IDENT_RE:A,MATCH_NOTHING_RE:W,METHOD_GUARD:pe,NUMBER_MODE:B,NUMBER_RE:_,PHRASAL_WORDS_MODE:oe,QUOTE_STRING_MODE:ke,REGEXP_MODE:we,RE_STARTERS_RE:q,SHEBANG:se,TITLE_MODE:ee,UNDERSCORE_IDENT_RE:I,UNDERSCORE_TITLE_MODE:J});function ae(H,me){H.input[H.index-1]==="."&&me.ignoreMatch()}function Fe(H,me){H.className!==void 0&&(H.scope=H.className,delete H.className)}function Qe(H,me){me&&H.beginKeywords&&(H.begin="\\b("+H.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",H.__beforeBegin=ae,H.keywords=H.keywords||H.beginKeywords,delete H.beginKeywords,H.relevance===void 0&&(H.relevance=0))}function ze(H,me){Array.isArray(H.illegal)&&(H.illegal=j(...H.illegal))}function Re(H,me){if(H.match){if(H.begin||H.end)throw new Error("begin & end are not supported with match");H.begin=H.match,delete H.match}}function ct(H,me){H.relevance===void 0&&(H.relevance=1)}const _n=(H,me)=>{if(!H.beforeMatch)return;if(H.starts)throw new Error("beforeMatch cannot be used with starts");const _e=Object.assign({},H);Object.keys(H).forEach(Ge=>{delete H[Ge]}),H.keywords=_e.keywords,H.begin=x(_e.beforeMatch,g(_e.begin)),H.starts={relevance:0,contains:[Object.assign(_e,{endsParent:!0})]},H.relevance=0,delete _e.beforeMatch},ht=["of","and","for","in","not","or","if","then","parent","list","value"],tn="keyword";function Vt(H,me,_e=tn){const Ge=Object.create(null);return typeof H=="string"?Lt(_e,H.split(" ")):Array.isArray(H)?Lt(_e,H):Object.keys(H).forEach(function(Pt){Object.assign(Ge,Vt(H[Pt],me,Pt))}),Ge;function Lt(Pt,Pe){me&&(Pe=Pe.map(Oe=>Oe.toLowerCase())),Pe.forEach(function(Oe){const Ve=Oe.split("|");Ge[Ve[0]]=[Pt,He(Ve[0],Ve[1])]})}}function He(H,me){return me?Number(me):nt(H)?0:1}function nt(H){return ht.includes(H.toLowerCase())}const an={},It=H=>{console.error(H)},X=(H,...me)=>{console.log(`WARN: ${H}`,...me)},fe=(H,me)=>{an[`${H}/${me}`]||(console.log(`Deprecated as of ${H}. ${me}`),an[`${H}/${me}`]=!0)},dt=new Error;function Ke(H,me,{key:_e}){let Ge=0;const Lt=H[_e],Pt={},Pe={};for(let Oe=1;Oe<=me.length;Oe++)Pe[Oe+Ge]=Lt[Oe],Pt[Oe+Ge]=!0,Ge+=N(me[Oe-1]);H[_e]=Pe,H[_e]._emit=Pt,H[_e]._multi=!0}function pn(H){if(Array.isArray(H.begin)){if(H.skip||H.excludeBegin||H.returnBegin)throw It("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),dt;if(typeof H.beginScope!="object"||H.beginScope===null)throw It("beginScope must be object"),dt;Ke(H,H.begin,{key:"beginScope"}),H.begin=$(H.begin,{joinWith:""})}}function mn(H){if(Array.isArray(H.end)){if(H.skip||H.excludeEnd||H.returnEnd)throw It("skip, excludeEnd, returnEnd not compatible with endScope: {}"),dt;if(typeof H.endScope!="object"||H.endScope===null)throw It("endScope must be object"),dt;Ke(H,H.end,{key:"endScope"}),H.end=$(H.end,{joinWith:""})}}function Sn(H){H.scope&&typeof H.scope=="object"&&H.scope!==null&&(H.beginScope=H.scope,delete H.scope)}function Ct(H){Sn(H),typeof H.beginScope=="string"&&(H.beginScope={_wrap:H.beginScope}),typeof H.endScope=="string"&&(H.endScope={_wrap:H.endScope}),pn(H),mn(H)}function Nn(H){function me(Pe,Oe){return new RegExp(m(Pe),"m"+(H.case_insensitive?"i":"")+(H.unicodeRegex?"u":"")+(Oe?"g":""))}class _e{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Oe,Ve){Ve.position=this.position++,this.matchIndexes[this.matchAt]=Ve,this.regexes.push([Ve,Oe]),this.matchAt+=N(Oe)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Oe=this.regexes.map(Ve=>Ve[1]);this.matcherRe=me($(Oe,{joinWith:"|"}),!0),this.lastIndex=0}exec(Oe){this.matcherRe.lastIndex=this.lastIndex;const Ve=this.matcherRe.exec(Oe);if(!Ve)return null;const Zt=Ve.findIndex((Tn,In)=>In>0&&Tn!==void 0),$t=this.matchIndexes[Zt];return Ve.splice(0,Zt),Object.assign(Ve,$t)}}class Ge{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Oe){if(this.multiRegexes[Oe])return this.multiRegexes[Oe];const Ve=new _e;return this.rules.slice(Oe).forEach(([Zt,$t])=>Ve.addRule(Zt,$t)),Ve.compile(),this.multiRegexes[Oe]=Ve,Ve}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Oe,Ve){this.rules.push([Oe,Ve]),Ve.type==="begin"&&this.count++}exec(Oe){const Ve=this.getMatcher(this.regexIndex);Ve.lastIndex=this.lastIndex;let Zt=Ve.exec(Oe);if(this.resumingScanAtSamePosition()&&!(Zt&&Zt.index===this.lastIndex)){const $t=this.getMatcher(0);$t.lastIndex=this.lastIndex+1,Zt=$t.exec(Oe)}return Zt&&(this.regexIndex+=Zt.position+1,this.regexIndex===this.count&&this.considerAll()),Zt}}function Lt(Pe){const Oe=new Ge;return Pe.contains.forEach(Ve=>Oe.addRule(Ve.begin,{rule:Ve,type:"begin"})),Pe.terminatorEnd&&Oe.addRule(Pe.terminatorEnd,{type:"end"}),Pe.illegal&&Oe.addRule(Pe.illegal,{type:"illegal"}),Oe}function Pt(Pe,Oe){const Ve=Pe;if(Pe.isCompiled)return Ve;[Fe,Re,Ct,_n].forEach($t=>$t(Pe,Oe)),H.compilerExtensions.forEach($t=>$t(Pe,Oe)),Pe.__beforeBegin=null,[Qe,ze,ct].forEach($t=>$t(Pe,Oe)),Pe.isCompiled=!0;let Zt=null;return typeof Pe.keywords=="object"&&Pe.keywords.$pattern&&(Pe.keywords=Object.assign({},Pe.keywords),Zt=Pe.keywords.$pattern,delete Pe.keywords.$pattern),Zt=Zt||/\w+/,Pe.keywords&&(Pe.keywords=Vt(Pe.keywords,H.case_insensitive)),Ve.keywordPatternRe=me(Zt,!0),Oe&&(Pe.begin||(Pe.begin=/\B|\b/),Ve.beginRe=me(Ve.begin),!Pe.end&&!Pe.endsWithParent&&(Pe.end=/\B|\b/),Pe.end&&(Ve.endRe=me(Ve.end)),Ve.terminatorEnd=m(Ve.end)||"",Pe.endsWithParent&&Oe.terminatorEnd&&(Ve.terminatorEnd+=(Pe.end?"|":"")+Oe.terminatorEnd)),Pe.illegal&&(Ve.illegalRe=me(Pe.illegal)),Pe.contains||(Pe.contains=[]),Pe.contains=[].concat(...Pe.contains.map(function($t){return Ee($t==="self"?Pe:$t)})),Pe.contains.forEach(function($t){Pt($t,Ve)}),Pe.starts&&Pt(Pe.starts,Oe),Ve.matcher=Lt(Ve),Ve}if(H.compilerExtensions||(H.compilerExtensions=[]),H.contains&&H.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return H.classNameAliases=r(H.classNameAliases||{}),Pt(H)}function ut(H){return H?H.endsWithParent||ut(H.starts):!1}function Ee(H){return H.variants&&!H.cachedVariants&&(H.cachedVariants=H.variants.map(function(me){return r(H,{variants:null},me)})),H.cachedVariants?H.cachedVariants:ut(H)?r(H,{starts:H.starts?r(H.starts):null}):Object.isFrozen(H)?r(H):H}var De="11.11.2";class gn extends Error{constructor(me,_e){super(me),this.name="HTMLInjectionError",this.html=_e}}const bn=n,wn=r,qn=Symbol("nomatch"),ft=7,Mt=function(H){const me=Object.create(null),_e=Object.create(null),Ge=[];let Lt=!0;const Pt="Could not find the language '{}', did you forget to load/include a language module?",Pe={disableAutodetect:!0,name:"Plain text",contains:[]};let Oe={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:p};function Ve(je){return Oe.noHighlightRe.test(je)}function Zt(je){let Se=je.className+" ";Se+=je.parentNode?je.parentNode.className:"";const kt=Oe.languageDetectRe.exec(Se);if(kt){const st=pt(kt[1]);return st||(X(Pt.replace("{}",kt[1])),X("Falling back to no-highlight mode for this block.",je)),st?kt[1]:"no-highlight"}return Se.split(/\s+/).find(st=>Ve(st)||pt(st))}function $t(je,Se,kt){let st="",Ft="";typeof Se=="object"?(st=je,kt=Se.ignoreIllegals,Ft=Se.language):(fe("10.7.0","highlight(lang, code, ...args) has been deprecated."),fe("10.7.0",`Please use highlight(code, options) instead.
|
|
198
|
+
https://github.com/highlightjs/highlight.js/issues/2277`),Ft=je,st=Se),kt===void 0&&(kt=!0);const Gt={code:st,language:Ft};On("before:highlight",Gt);const U=Gt.result?Gt.result:Tn(Gt.language,Gt.code,kt);return U.code=Gt.code,On("after:highlight",U),U}function Tn(je,Se,kt,st){const Ft=Object.create(null);function Gt(D,ne){return D.keywords[ne]}function U(){if(!gt.keywords){ln.addText(Xt);return}let D=0;gt.keywordPatternRe.lastIndex=0;let ne=gt.keywordPatternRe.exec(Xt),ye="";for(;ne;){ye+=Xt.substring(D,ne.index);const Ae=wr.case_insensitive?ne[0].toLowerCase():ne[0],We=Gt(gt,Ae);if(We){const[xt,cn]=We;if(ln.addText(ye),ye="",Ft[Ae]=(Ft[Ae]||0)+1,Ft[Ae]<=ft&&(Pr+=cn),xt.startsWith("_"))ye+=ne[0];else{const Gn=wr.classNameAliases[xt]||xt;mt(ne[0],Gn)}}else ye+=ne[0];D=gt.keywordPatternRe.lastIndex,ne=gt.keywordPatternRe.exec(Xt)}ye+=Xt.substring(D),ln.addText(ye)}function he(){if(Xt==="")return;let D=null;if(typeof gt.subLanguage=="string"){if(!me[gt.subLanguage]){ln.addText(Xt);return}D=Tn(gt.subLanguage,Xt,!0,Ao[gt.subLanguage]),Ao[gt.subLanguage]=D._top}else D=kn(Xt,gt.subLanguage.length?gt.subLanguage:null);gt.relevance>0&&(Pr+=D.relevance),ln.__addSublanguage(D._emitter,D.language)}function Be(){gt.subLanguage!=null?he():U(),Xt=""}function mt(D,ne){D!==""&&(ln.startScope(ne),ln.addText(D),ln.endScope())}function bt(D,ne){let ye=1;const Ae=ne.length-1;for(;ye<=Ae;){if(!D._emit[ye]){ye++;continue}const We=wr.classNameAliases[D[ye]]||D[ye],xt=ne[ye];We?mt(xt,We):(Xt=xt,U(),Xt=""),ye++}}function Ht(D,ne){return D.scope&&typeof D.scope=="string"&&ln.openNode(wr.classNameAliases[D.scope]||D.scope),D.beginScope&&(D.beginScope._wrap?(mt(Xt,wr.classNameAliases[D.beginScope._wrap]||D.beginScope._wrap),Xt=""):D.beginScope._multi&&(bt(D.beginScope,ne),Xt="")),gt=Object.create(D,{parent:{value:gt}}),gt}function Mn(D,ne,ye){let Ae=T(D.endRe,ye);if(Ae){if(D["on:end"]){const We=new t(D);D["on:end"](ne,We),We.isMatchIgnored&&(Ae=!1)}if(Ae){for(;D.endsParent&&D.parent;)D=D.parent;return D}}if(D.endsWithParent)return Mn(D.parent,ne,ye)}function tr(D){return gt.matcher.regexIndex===0?(Xt+=D[0],1):(O=!0,0)}function jo(D){const ne=D[0],ye=D.rule,Ae=new t(ye),We=[ye.__beforeBegin,ye["on:begin"]];for(const xt of We)if(xt&&(xt(D,Ae),Ae.isMatchIgnored))return tr(ne);return ye.skip?Xt+=ne:(ye.excludeBegin&&(Xt+=ne),Be(),!ye.returnBegin&&!ye.excludeBegin&&(Xt=ne)),Ht(ye,D),ye.returnBegin?0:ne.length}function xr(D){const ne=D[0],ye=Se.substring(D.index),Ae=Mn(gt,D,ye);if(!Ae)return qn;const We=gt;gt.endScope&>.endScope._wrap?(Be(),mt(ne,gt.endScope._wrap)):gt.endScope&>.endScope._multi?(Be(),bt(gt.endScope,D)):We.skip?Xt+=ne:(We.returnEnd||We.excludeEnd||(Xt+=ne),Be(),We.excludeEnd&&(Xt=ne));do gt.scope&&ln.closeNode(),!gt.skip&&!gt.subLanguage&&(Pr+=gt.relevance),gt=gt.parent;while(gt!==Ae.parent);return Ae.starts&&Ht(Ae.starts,D),We.returnEnd?0:ne.length}function js(){const D=[];for(let ne=gt;ne!==wr;ne=ne.parent)ne.scope&&D.unshift(ne.scope);D.forEach(ne=>ln.openNode(ne))}let Mr={};function Lr(D,ne){const ye=ne&&ne[0];if(Xt+=D,ye==null)return Be(),0;if(Mr.type==="begin"&&ne.type==="end"&&Mr.index===ne.index&&ye===""){if(Xt+=Se.slice(ne.index,ne.index+1),!Lt){const Ae=new Error(`0 width match regex (${je})`);throw Ae.languageName=je,Ae.badRule=Mr.rule,Ae}return 1}if(Mr=ne,ne.type==="begin")return jo(ne);if(ne.type==="illegal"&&!kt){const Ae=new Error('Illegal lexeme "'+ye+'" for mode "'+(gt.scope||"<unnamed>")+'"');throw Ae.mode=gt,Ae}else if(ne.type==="end"){const Ae=xr(ne);if(Ae!==qn)return Ae}if(ne.type==="illegal"&&ye==="")return ne.index===Se.length||(Xt+=`
|
|
199
|
+
`),1;if(Ne>1e5&&Ne>ne.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Xt+=ye,ye.length}const wr=pt(je);if(!wr)throw It(Pt.replace("{}",je)),new Error('Unknown language: "'+je+'"');const Co=Nn(wr);let Xe="",gt=st||Co;const Ao={},ln=new Oe.__emitter(Oe);js();let Xt="",Pr=0,Xn=0,Ne=0,O=!1;try{if(wr.__emitTokens)wr.__emitTokens(Se,ln);else{for(gt.matcher.considerAll();;){Ne++,O?O=!1:gt.matcher.considerAll(),gt.matcher.lastIndex=Xn;const D=gt.matcher.exec(Se);if(!D)break;const ne=Se.substring(Xn,D.index),ye=Lr(ne,D);Xn=D.index+ye}Lr(Se.substring(Xn))}return ln.finalize(),Xe=ln.toHTML(),{language:je,value:Xe,relevance:Pr,illegal:!1,_emitter:ln,_top:gt}}catch(D){if(D.message&&D.message.includes("Illegal"))return{language:je,value:bn(Se),illegal:!0,relevance:0,_illegalBy:{message:D.message,index:Xn,context:Se.slice(Xn-100,Xn+100),mode:D.mode,resultSoFar:Xe},_emitter:ln};if(Lt)return{language:je,value:bn(Se),illegal:!1,relevance:0,errorRaised:D,_emitter:ln,_top:gt};throw D}}function In(je){const Se={value:bn(je),illegal:!1,relevance:0,_top:Pe,_emitter:new Oe.__emitter(Oe)};return Se._emitter.addText(je),Se}function kn(je,Se){Se=Se||Oe.languages||Object.keys(me);const kt=In(je),st=Se.filter(pt).filter(rn).map(Be=>Tn(Be,je,!1));st.unshift(kt);const Ft=st.sort((Be,mt)=>{if(Be.relevance!==mt.relevance)return mt.relevance-Be.relevance;if(Be.language&&mt.language){if(pt(Be.language).supersetOf===mt.language)return 1;if(pt(mt.language).supersetOf===Be.language)return-1}return 0}),[Gt,U]=Ft,he=Gt;return he.secondBest=U,he}function kr(je,Se,kt){const st=Se&&_e[Se]||kt;je.classList.add("hljs"),je.classList.add(`language-${st}`)}function hn(je){let Se=null;const kt=Zt(je);if(Ve(kt))return;if(On("before:highlightElement",{el:je,language:kt}),je.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",je);return}if(je.children.length>0&&(Oe.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(je)),Oe.throwUnescapedHTML))throw new gn("One of your code blocks includes unescaped HTML.",je.innerHTML);Se=je;const st=Se.textContent,Ft=kt?$t(st,{language:kt,ignoreIllegals:!0}):kn(st);je.innerHTML=Ft.value,je.dataset.highlighted="yes",kr(je,kt,Ft.language),je.result={language:Ft.language,re:Ft.relevance,relevance:Ft.relevance},Ft.secondBest&&(je.secondBest={language:Ft.secondBest.language,relevance:Ft.secondBest.relevance}),On("after:highlightElement",{el:je,result:Ft,text:st})}function En(je){Oe=wn(Oe,je)}const cr=()=>{zt(),fe("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Yt(){zt(),fe("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let qt=!1;function zt(){function je(){zt()}if(document.readyState==="loading"){qt||window.addEventListener("DOMContentLoaded",je,!1),qt=!0;return}document.querySelectorAll(Oe.cssSelector).forEach(hn)}function G(je,Se){let kt=null;try{kt=Se(H)}catch(st){if(It("Language definition for '{}' could not be registered.".replace("{}",je)),Lt)It(st);else throw st;kt=Pe}kt.name||(kt.name=je),me[je]=kt,kt.rawDefinition=Se.bind(null,H),kt.aliases&&Jt(kt.aliases,{languageName:je})}function be(je){delete me[je];for(const Se of Object.keys(_e))_e[Se]===je&&delete _e[Se]}function Ze(){return Object.keys(me)}function pt(je){return je=(je||"").toLowerCase(),me[je]||me[_e[je]]}function Jt(je,{languageName:Se}){typeof je=="string"&&(je=[je]),je.forEach(kt=>{_e[kt.toLowerCase()]=Se})}function rn(je){const Se=pt(je);return Se&&!Se.disableAutodetect}function Ut(je){je["before:highlightBlock"]&&!je["before:highlightElement"]&&(je["before:highlightElement"]=Se=>{je["before:highlightBlock"](Object.assign({block:Se.el},Se))}),je["after:highlightBlock"]&&!je["after:highlightElement"]&&(je["after:highlightElement"]=Se=>{je["after:highlightBlock"](Object.assign({block:Se.el},Se))})}function ur(je){Ut(je),Ge.push(je)}function Or(je){const Se=Ge.indexOf(je);Se!==-1&&Ge.splice(Se,1)}function On(je,Se){const kt=je;Ge.forEach(function(st){st[kt]&&st[kt](Se)})}function St(je){return fe("10.7.0","highlightBlock will be removed entirely in v12.0"),fe("10.7.0","Please use highlightElement now."),hn(je)}Object.assign(H,{highlight:$t,highlightAuto:kn,highlightAll:zt,highlightElement:hn,highlightBlock:St,configure:En,initHighlighting:cr,initHighlightingOnLoad:Yt,registerLanguage:G,unregisterLanguage:be,listLanguages:Ze,getLanguage:pt,registerAliases:Jt,autoDetection:rn,inherit:wn,addPlugin:ur,removePlugin:Or}),H.debugMode=function(){Lt=!1},H.safeMode=function(){Lt=!0},H.versionString=De,H.regex={concat:x,lookahead:g,either:j,optional:y,anyNumberOfTimes:w};for(const je in le)typeof le[je]=="object"&&e(le[je]);return Object.assign(H,le),H},nn=Mt({});return nn.newInstance=()=>Mt({}),Bp=nn,nn.HighlightJS=nn,nn.default=nn,Bp}var k5=g5();const w5=Ex(k5),Pb={},y5="hljs-";function v5(e){const t=w5.newInstance();return e&&i(e),{highlight:n,highlightAuto:r,listLanguages:o,register:i,registerAlias:l,registered:u};function n(c,f,p){const m=p||Pb,g=typeof m.prefix=="string"?m.prefix:y5;if(!t.getLanguage(c))throw new Error("Unknown language: `"+c+"` is not registered");t.configure({__emitter:b5,classPrefix:g});const w=t.highlight(f,{ignoreIllegals:!0,language:c});if(w.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:w.errorRaised});const y=w._emitter.root,x=y.data;return x.language=w.language,x.relevance=w.relevance,y}function r(c,f){const m=(f||Pb).subset||o();let g=-1,w=0,y;for(;++g<m.length;){const x=m[g];if(!t.getLanguage(x))continue;const b=n(x,c,f);b.data&&b.data.relevance!==void 0&&b.data.relevance>w&&(w=b.data.relevance,y=b)}return y||{type:"root",children:[],data:{language:void 0,relevance:w}}}function o(){return t.listLanguages()}function i(c,f){if(typeof c=="string")t.registerLanguage(c,f);else{let p;for(p in c)Object.hasOwn(c,p)&&t.registerLanguage(p,c[p])}}function l(c,f){if(typeof c=="string")t.registerAliases(typeof f=="string"?f:[...f],{languageName:c});else{let p;for(p in c)if(Object.hasOwn(c,p)){const m=c[p];t.registerAliases(typeof m=="string"?m:[...m],{languageName:p})}}}function u(c){return!!t.getLanguage(c)}}class b5{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const r=this.stack[this.stack.length-1],o=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:o}):r.children.push(...o)}openNode(t){const n=this,r=t.split(".").map(function(l,u){return u?l+"_".repeat(u):n.options.classPrefix+l}),o=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:r},children:[]};o.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const hS=v5({bash:H3,css:Q3,go:J3,ini:e5,javascript:s5,json:l5,markdown:c5,python:u5,rust:d5,typescript:h5,xml:p5,yaml:m5}),Db={ts:"typescript",tsx:"typescript",mts:"typescript",cts:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",json:"json",jsonc:"json",css:"css",scss:"css",less:"css",html:"xml",htm:"xml",xml:"xml",svg:"xml",vue:"xml",md:"markdown",mdx:"markdown",markdown:"markdown",py:"python",pyi:"python",rs:"rust",go:"go",java:"javascript",kt:"javascript",c:"javascript",h:"javascript",cc:"javascript",cpp:"javascript",hpp:"javascript",cs:"javascript",swift:"javascript",yml:"yaml",yaml:"yaml",toml:"ini",ini:"ini",env:"ini",sh:"bash",bash:"bash",zsh:"bash",fish:"bash"};function Tk(e,t){const n=e&&(Db[e]??(hS.registered(e)?e:null));if(n)return n;const r=t.lastIndexOf("."),o=r<0?"":t.slice(r+1).toLowerCase();return(o?Db[o]:null)??null}const x5=/^(?:diff --git a\/\S+ b\/(\S+)|\+\+\+ (?:b\/)?(\S+))$/gm;function E5(e){const t=new Set;for(const n of e.matchAll(x5)){const r=n[1]??n[2]??"";r&&r!=="/dev/null"&&t.add(r)}return t.size===1?[...t][0]:""}const _5={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 pS(e,t){const n=[[]],r=(i,l)=>{const u=i.split(`
|
|
200
|
+
`);for(const[c,f]of u.entries()){if(c>0&&n.push([]),!f)continue;const p=n[n.length-1],m=p[p.length-1];m&&m.scope===l?m.text+=f:p.push({text:f,scope:l})}},o=(i,l)=>{for(const u of i)u.type==="text"?r(u.value,l):u.type==="element"&&o(u.children,S5(u)??l)};try{o(hS.highlight(t,e).children,"")}catch{return e.split(`
|
|
201
|
+
`).map(i=>i?[{text:i,scope:""}]:[])}return n}function S5(e){var r;const t=((r=e.properties)==null?void 0:r.className)??[];let n=null;for(const o of t){const i=_5[o.startsWith("hljs-")?o.slice(5):o];i&&(n=i)}return n}const zb=/^\d+\t/;function jk(e,t){if(!t)return[];const n=e.split(`
|
|
202
|
+
`),r=zb.test(n[0]??""),o=r?n.map(l=>{var u;return((u=zb.exec(l))==null?void 0:u[0])??""}):[],i=r?n.map((l,u)=>l.slice(o[u].length)).join(`
|
|
203
|
+
`):e;return pS(i,t).map((l,u)=>{const c=l.map(p=>({text:p.text,changed:!1,scope:p.scope})),f=o[u];return f?[{text:f,changed:!1,scope:""},...c]:c})}function N5(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"||(T5(e,o,i,t,n),o=i+1)}}return e.map((o,i)=>j5(o.spans,n[i],o.text))}function T5(e,t,n,r,o){var i,l;for(const u of["del","add"]){const c=[];for(let m=t;m<n;m++){const g=(i=e[m])==null?void 0:i.kind;(g===""||g===u)&&c.push(m)}if(c.length===0)continue;const f=c.map(m=>{var g;return((g=e[m])==null?void 0:g.text)??""}).join(`
|
|
204
|
+
`),p=pS(f,r);for(const[m,g]of c.entries())(u==="add"||((l=e[g])==null?void 0:l.kind)==="del")&&(o[g]=p[m])}}function j5(e,t,n){if(!(e!=null&&e.length)&&!(t!=null&&t.length))return n?[{text:n,changed:!1,scope:""}]:[];const r=[],o=e!=null&&e.length?e:[{text:n,changed:!1}],i=t!=null&&t.length?t:[{text:n,scope:""}];let l=0,u=0,c=0,f=0;for(;l<o.length&&u<i.length;){const p=o[l],m=i[u],g=Math.min(p.text.length-c,m.text.length-f);if(g>0){const w={text:p.text.slice(c,c+g),changed:p.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)}c+=g,f+=g,c>=p.text.length&&(l++,c=0),f>=m.text.length&&(u++,f=0)}return r}yn.use({extensions:[B3],renderer:{code({text:e,lang:t}){const n=Tk((t??"").trim().toLowerCase().split(/\s+/)[0]??"","");return n?`<pre><code>${jk(e,n).map(o=>o.map(i=>i.scope?`<span class="sy-${i.scope}">${Fb(i.text)}</span>`:Fb(i.text)).join("")).join(`
|
|
205
|
+
`)}</code></pre>
|
|
206
|
+
`:!1},table:U3}});const Fb=e=>e.replace(/[&<>]/g,t=>t==="&"?"&":t==="<"?"<":">"),mS=Oz(window);let ws=null;mS.addHook("afterSanitizeAttributes",e=>{const t=e.tagName==="A"?e.getAttribute("href")??"":"";if(t===nS){e.removeAttribute("href"),e.classList.add("link-pending","live-text");return}/^https?:/i.test(t)&&(e.setAttribute("target","_blank"),e.setAttribute("rel","noreferrer"));const n=ws!=null&&ws.fileRoot?z_(ws.fileRoot,t):null,r=n?null:F_(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=XD(e.textContent??"");i&&e.setAttribute("data-path",i)}const o=ws==null?void 0:ws.base;if(e.tagName==="IMG"&&o){const i=mk(o.dir,e.getAttribute("src")??"");i&&e.setAttribute("src",o.urls.worktreeFile(o.worktreeId,i,o.version))}});function Wa(e,t){ws=t??null;const n=t!=null&&t.streaming?P3(e):e;try{return mS.sanitize(yn.parse(n,{async:!1}))}finally{ws=null}}function Ck(e,t){var m,g,w,y;const[n,r]=S.useState(()=>Wa(e,t)),o=S.useRef(0),i=(m=t==null?void 0:t.base)==null?void 0:m.worktreeId,l=(g=t==null?void 0:t.base)==null?void 0:g.dir,u=(w=t==null?void 0:t.base)==null?void 0:w.version,c=(y=t==null?void 0:t.base)==null?void 0:y.urls,f=t==null?void 0:t.fileRoot,p=t==null?void 0:t.streaming;return S.useEffect(()=>{const x=i!==void 0&&l!==void 0&&c!==void 0?{worktreeId:i,dir:l,version:u??null,urls:c}:void 0,b=x||f||p?{base:x,fileRoot:f,streaming:p}:void 0,j=performance.now()-o.current;if(j>=Ud){o.current=performance.now(),r(Wa(e,b));return}const N=setTimeout(()=>{o.current=performance.now(),r(Wa(e,b))},Ud-j);return()=>clearTimeout(N)},[e,i,l,u,c,f,p]),n}const C5=/^ {0,3}(`{3,}|~{3,})/,A5=/^#{1,6} \S/,I5=/^\s*(?:[-*+]|\d+[.)]) \S/,R5=/^> ?\S/,$5=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/,O5=/\[[^\]\n]+\]\((?:https?:|\.{0,2}\/|#)[^)\s]*\)/,M5=/\*\*[^\s*][^*\n]*\*\*/;function L5(e){var i,l;const t=e.split(`
|
|
207
|
+
`),n=new Set;let r=null,o=0;for(let u=0;u<t.length;u++){const c=t[u],f=(i=C5.exec(c))==null?void 0:i[1];if(r){f!=null&&f.startsWith(r)&&(r=null,n.add("fence"));continue}if(f){r=f;continue}A5.test(c)&&!((l=t[u+1])!=null&&l.trim())&&n.add("heading"),I5.test(c)&&++o===2&&n.add("list"),R5.test(c)&&n.add("quote"),$5.test(c)&&n.add("table"),O5.test(c)&&n.add("link"),M5.test(c)&&n.add("bold")}return n.size}function P5(e,t){if(t)return pf(t)==="markdown"?"rendered":"plain";const n=L5(e);return n>=2?"rendered":n===1?"source":"plain"}function Ak({n:e,name:t,source:n,lines:r,chars:o,preview:i,text:l,href:u,onRemove:c,className:f=""}){const p=(n==null?void 0:n.path)??t??"",m=p.includes("/")?p.slice(0,p.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=h.jsxs(h.Fragment,{children:[h.jsx(jt,{name:"text",className:"icon-inline"}),h.jsxs("span",{className:"pick-target",children:[h.jsx("b",{children:t?t.slice(t.lastIndexOf("/")+1):n?HO(n):Ax("paste",e)}),g&&h.jsxs("span",{className:"pick-file row-dim",children:[" · ",g]})]})]}),y=l!==void 0||u!==void 0;return h.jsx(wk,{className:Ue("paste-chip",f),label:w,tip:i||void 0,peek:y?h.jsx(wS,{text:l,href:u}):void 0,full:y?h.jsx(kS,{text:l,href:u,path:p||void 0}):void 0,menu:x=>L_({text:l,href:u},x),removeLabel:"Remove attachment",onRemove:c})}function gS(e,t){const[n,r]=S.useState(e??null),[o,i]=S.useState(!1);return S.useEffect(()=>{if(e!==void 0||!t)return;let l=!0;return fetch(t).then(u=>u.ok?u.text():Promise.reject(new Error(String(u.status)))).then(u=>{l&&r(u)}).catch(()=>{l&&i(!0)}),()=>{l=!1}},[e,t]),{text:e??n,failed:o}}function kS({text:e,href:t,path:n}){const{text:r,failed:o}=gS(e,t),i=S.useMemo(()=>r?P5(r,n):"plain",[r,n]),[l,u]=S.useState(null);if(o)return h.jsx("p",{className:"paste-full hint",children:"Toyon could not read that back."});if(!r||i==="plain")return h.jsx("pre",{className:"paste-full paste-text",children:r});const c=l??i==="rendered";return h.jsxs("div",{className:"paste-full paste-doc",children:[h.jsx("div",{className:"paste-doc-head",children:h.jsxs(Le,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>u(!c),"data-tip":c?"Text: read it as it was sent":"Preview: read it rendered",children:[h.jsx(jt,{name:c?"text":"book",className:"icon-inline"})," ",c?"text":"preview"]})}),c?h.jsx(D5,{text:r}):h.jsx("pre",{className:"paste-doc-body paste-text",children:r})]})}function D5({text:e}){const t=S.useMemo(()=>Wa(e),[e]);return h.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 z5=2e4;function wS({text:e,href:t}){const{text:n}=gS(e,t);return n?h.jsx("pre",{className:"paste-peek paste-text",children:n.slice(0,z5)}):null}function Ik({name:e,bytes:t,href:n,uploading:r,onRemove:o,className:i=""}){return h.jsx(wk,{className:Ue("file-chip",i),label:h.jsxs(h.Fragment,{children:[h.jsx(jt,{name:"file",className:"icon-inline"}),h.jsxs("span",{className:"pick-target",children:[h.jsx("b",{children:e}),h.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",cg(t),r&&" · uploading"]})]})]}),tip:e,peek:n?h.jsx(wS,{href:n}):void 0,full:n?h.jsx(kS,{href:n,path:e}):void 0,menu:l=>L_({href:n},l),removeLabel:"Remove attachment",onRemove:o})}function yS(e){return e.replace(/^([\t ]*)\*\*(\S(?:[^\n]*\S)?)\*\*([\t ]*)$/gm,"$1$2$3")}const vS=120,F5=/^\*\*(\S(?:[^\n]*\S)?)\*\*$/;function bS(e){var n,r;const t=[];for(const o of e.split(/\n[\t ]*\n/)){const i=o.trim();if(!i)continue;const l=((r=(n=F5.exec(i))==null?void 0:n[1])==null?void 0:r.replace(/`/g,""))??"";if(!l||l.length>vS)return[];t.push(l)}return t}function xS(e){const t=bS(e);if(t.length)return t.at(-1);const n=yS(e).trim().replace(/`/g,"");return n&&!n.includes(`
|
|
208
|
+
`)&&n.length<=vS?n:""}const B5={read:"read",edit:"edit",delete:"delete",move:"move",search:"search",execute:"run",think:"think",fetch:"fetch",switch_mode:"mode",other:"tool"},Bb={read:"book",edit:"edit",delete:"trash",move:"move",search:"search",execute:"run",think:"bulb",fetch:"globe",switch_mode:"swap",other:"dot"},ES="Skill",Up=new Map([[rg,"chat"],["Monitor","clock"],["TaskOutput","terminal"],[ES,"layers"],[Sx,"globe"]]);function U5(e){if(e.name!==ES)return"";const t=fo(e,"skill").trim();if(!t)return"";const n=fo(e,"args").trim();return n?`/${t} ${n}`:`/${t}`}const Dm={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"},H5=/(^|\s)(-[A-Za-z]*[iI]|--in-place)/,Ub=String.raw`(?:"[^"]*"|'[^']*'|[^\s;&|]+)`,Hb=new RegExp(String.raw`^\s*(?:(?:cd|echo)\s+${Ub}\s*(?:&&|;)|mkdir(?:\s+${Ub})+\s*(?:&&|;)|(?:export\s+)?[A-Za-z_]\w*=(?:"[^"]*"|'[^']*'|[^\s;&|()\`]*)\s*(?:&&|;|(?=\s)))\s*`),K5=/^python[\d.]*$/,W5=new RegExp(`open\\([^)]*,\\s*["'][wax]|(?<!std(?:out|err))\\.write\\(|\\.write_text\\(`);function _S(e){let t=e;for(let n=t.replace(Hb,"");n!==t;n=t.replace(Hb,""))t=n;return t}const Z5=new RegExp("(?<![0-9&])>{1,2}\\s*(?!\\/dev\\/null|&)[^\\s&>]"),SS=/&&|;|\n|\|/;function q5(e){return e.split(SS).some(t=>/^\s*(?:\S*\/)?sed\s/.test(t)&&H5.test(t))}function G5(e){return e.split(/&&|;|\n/).map(t=>_S(t).trim().split(/\s+/)[0]??"").filter(Boolean).every(t=>Dm[t.slice(t.lastIndexOf("/")+1)]==="trash")}function V5(e){const t=_S(e).trim(),n=t.split(/\s+/)[0]??"",r=n.slice(n.lastIndexOf("/")+1),o=r==="sed"?q5(e)?void 0:"book":Dm[r];if(o==="book"||o==="search"){const i=t.split(SS)[0]??"";if(Z5.test(i))return r==="cat"&&i.includes("<<")?"edit":void 0}if(!(o==="trash"&&!G5(t)))return o||(K5.test(r)?t.includes("<<")&&W5.test(t)?"edit":void 0:Dm[r])}function fo(e,t){const n=e.input,r=n?n[t]:void 0;return typeof r=="string"?r:""}const Y5=/^(?:\/(?:usr\/)?bin\/)?(?:ba|z|da)?sh\s+(?:-[a-zA-Z]+\s+)*(?:'([^']*)'|"((?:[^"\\]|\\.)*)")\s*$/;function NS(e){const t=Y5.exec(e.trim());return t?t[1]!==void 0?t[1]:(t[2]??"").replace(/\\(["\\$`])/g,"$1"):e}const X5="Guardian Review";function TS(e){return e.toolKind==="think"&&e.title===X5}function Q5(e){const t=o=>{var l,u;return((u=(l=[...e.matchAll(new RegExp(`^${o}:[ \\t]*(.+)$`,"gm"))].at(-1))==null?void 0:l[1])==null?void 0:u.trim().toLowerCase())??""},n=t("Status"),r=t("Risk");return!n||n==="in progress"?"reviewing":r?`${n}, ${r} risk`:n}function vc(e,t=[]){const n=NS(fo(e,"command")),o=jS(e)||n||fo(e,"path")||fo(e,"pattern")||U5(e)||(e.title&&e.title!==e.name?e.title:""),i=Rk(fo(e,"description")||o,t),l=e.toolKind&&e.toolKind in Bb?e.toolKind:"other",u=B5[l],c=e.name===rg,f=(l!=="other"||Up.has(e.name))&&e.name!==uj,p=i&&(f||e.name===e.title||e.name===ni||e.name===_x)&&e.name!==Sx?"":e.name,m=p&&p.toLowerCase()!==u?p:i?"":u,g=(l==="execute"||l==="other")&&n?V5(n):void 0;return{label:c?"ask":u,name:m,icon:Up.get(e.name)??Up.get(e.title??"")??g??Bb[l],hint:i===m?"":i,command:n&&n!==i?n:""}}const J5=/^Async agent launched/m;function e6(e){if(!e.subagent)return!1;const t=e.input;return!!e.detached||(t==null?void 0:t.run_in_background)===!0||!!e.output&&J5.test(e.output)}const t6={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 n6(e){const t=e.toolKind;return e.subagent?fo(e,"prompt")?"":"writing the brief":!ef(e.input)||!Nx({name:e.name,kind:t},e.input)?"":sg(t)?t6[t]:"writing the question"}function zm(e,t){const n=CS(t),r=n[0],o=fo(e,"description");return o&&r&&!r.code&&r.text===o?n.slice(1):n}function Rf(e){return jS(e)||fo(e,"path")}function r6(e){return fo(e,"description")}function jS(e){return fo(e,"file_path")||fo(e,"filepath")||fo(e,"filePath")||o6(e)}function o6(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 Rk(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 s6=/^(`{3,})([\w+#.-]*)\s*$/;function CS(e){var u;const t=[];let n=[],r="",o=!1,i=0;const l=()=>{const c=n.join(`
|
|
209
|
+
`).replace(/^\n+|\n+$/g,"");c.trim()&&t.push({code:o,diff:i6(c,r),lang:o?r:"",text:c}),n=[]};for(const c of e.split(`
|
|
210
|
+
`)){const f=s6.exec(c),p=((u=f==null?void 0:f[1])==null?void 0:u.length)??0;if(!f||o&&(p<i||f[2])){n.push(c);continue}l(),o=!o,i=o?p:0,r=o?(f[2]??"").toLowerCase():""}return l(),t}function i6(e,t){return t==="diff"||t==="patch"||/^diff --git /m.test(e)||/^@@ .*@@/m.test(e)?!0:/^--- /m.test(e)&&/^[+-]/m.test(e)}const a6=/^(diff --git |index [0-9a-f]+\.\.|new file mode |deleted file mode |similarity index |rename (from|to) |Binary files )/;function l6(e){const t=[];for(const n of e.split(`
|
|
211
|
+
`)){const r=u6(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 c6(t),t}function c6(e){var t,n,r,o;for(let i=0;i<e.length;){if(((t=e[i])==null?void 0:t.kind)!=="del"&&((n=e[i])==null?void 0:n.kind)!=="add"){i++;continue}let l=i;for(;((r=e[l])==null?void 0:r.kind)==="del";)l++;let u=l;for(;((o=e[u])==null?void 0:o.kind)==="add";)u++;const c=e.slice(i,l),f=e.slice(l,u),p=c.length>0&&f.length>0?oC(c.map(m=>m.text).join(`
|
|
212
|
+
`),f.map(m=>m.text).join(`
|
|
213
|
+
`)):null;p&&(Kb(c,dv(p.before)),Kb(f,dv(p.after)));for(const m of[...c,...f])m.spans??(m.spans=[]);i=u}}function Kb(e,t){if(t.length===e.length)for(const[n,r]of e.entries())r.spans=t[n]}function u6(e){return e.startsWith("@@")?"hunk":e.startsWith("+++")||e.startsWith("---")||a6.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":""}function d6(e){const t=e.tools.at(-1);return t.done||t.parentToolId?!1:t.name===ni?!t.background:!!t.background}const AS=new Set(["read","edit","fetch"]);function IS(e,t){if(e.isError||!e.toolKind||!AS.has(e.toolKind)||sg(e.toolKind)&&ef(e.input))return"";const{hint:n}=vc(e,t);return n?`${e.parentToolId??""}
|
|
214
|
+
${e.toolKind}
|
|
215
|
+
${e.name}
|
|
216
|
+
${n}`:""}function Wb(e,t,n){if(!t||!("tools"in t)||e.done||e.isError||!e.toolKind||!AS.has(e.toolKind))return!1;const r=t.tools[0];return r.toolKind===e.toolKind&&r.name===e.name&&r.parentToolId===e.parentToolId&&IS(r,n)!==""}function RS(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 f6(e){return e.done&&!e.output&&!e.isError&&Nx({name:e.name,kind:e.toolKind},e.input)}function h6(e,t){const n=RS(e),r=[],o=new Map;let i="";for(const[l,u]of e.entries()){if(u.kind!=="tool"){i="",r.push({at:l,item:u});continue}if(f6(u))continue;if(n.has(u.id)){i="";const m={at:l,spawn:u,run:[],end:l};o.set(u.id,{entry:m,key:""}),r.push(m);continue}const c=IS(u,t),f=u.parentToolId?o.get(u.parentToolId):void 0;if(f){const m=f.entry.run,g=m.at(-1);c&&c===f.key&&g?g.tools.push(u):!c&&Wb(u,g,t)?g.next=u:m.push({at:l,tools:[u]}),f.key=c,f.entry.end=l;continue}const p=r.at(-1);if(c&&c===i&&p&&"tools"in p){p.tools.push(u);continue}if(!c&&Wb(u,p,t)){p.next=u;continue}i=c,r.push({at:l,tools:[u]})}return r}function p6(e){return e.reduce((t,n)=>t+n.tools.length,0)}function m6(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?e6(l)?o&&!n.has(l.id)&&t.add(l.id):t.delete(l.id):t.add(l.id))}return t}function g6(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&&d6(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 k6(e){const t=RS(e);return e.some(n=>n.kind==="tool"&&!n.done&&!n.parentToolId&&!n.background&&(!t.has(n.id)||ef(n.input)))}function $S(e,t=!1){const n=new Set;let r=!1,o=!1;return e.forEach((i,l)=>{if(!("tools"in i)||!t&&i.tools[0].parentToolId)return;const u=i.tools.at(-1);if(u.done||u.background||u.name===ni)return;const c=og({name:u.name,kind:u.toolKind});(o||r&&c)&&n.add(l),r=!0,o||(o=c)}),n}function w6(e){return e.findIndex(t=>!t.tools.at(-1).done)}function $k(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function OS(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)&&$k(n.tools,t[r].tools)})}function y6(e,t){if(e.length===0)return t;const n=new Map;for(const i of e)n.set(i.at,i);let r=e.length===t.length;const o=t.map((i,l)=>{const u=n.get(i.at),c=u!==void 0&&v6(u,i)?u:i;return c!==e[l]&&(r=!1),c});return r?e:o}function v6(e,t){return"spawn"in e?"spawn"in t&&e.spawn===t.spawn&&e.end===t.end&&OS(e.run,t.run):"tools"in e?"tools"in t&&e.next===t.next&&$k(e.tools,t.tools):"item"in t&&e.item===t.item}function b6(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"&&!TS(r))return t;continue}if(n.item.kind==="thinking"){if(!n.item.text.trim())continue;return xS(n.item.text)?-1:t}if(x6(n.item))return-1}}return-1}function x6(e){return e.kind==="assistant"?!!e.text.trim():e.kind==="ask"?e.ask.kind==="question"||!!e.outcome:!0}function E6(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 _6({item:e}){const t=at(),n=M(r=>dn(r,e.worktreeId)!==null);return e.state==="proposed"?null:e.state==="declined"?h.jsx(Jr,{icon:"close",word:"not continued",tone:"quiet",at:e.ts,below:e.reason?h.jsx("div",{className:"daemon-below row-dim",children:e.reason}):void 0,children:h.jsxs("span",{className:"daemon-text",children:["in ",e.repo.name]})}):h.jsx(Jr,{icon:"spawn",word:"continued",tone:"accent",at:e.ts,children:h.jsxs("span",{className:"daemon-text",children:["in ",e.repo.name,":"," ",h.jsx(Le,{variant:"inline",tone:"strong",disabled:!n,onClick:()=>e.worktreeId&&t({a:"activate",id:e.worktreeId}),children:e.title??e.repo.name})]})})}function S6({item:e}){return h.jsxs(Jr,{icon:"check",word:"landed",tone:"aqua",at:e.ts,children:[h.jsxs("span",{className:"daemon-text",children:[e.title," in ",e.repoName]}),e.url&&h.jsx(Le,{variant:"inline",tone:"strong",onClick:()=>window.open(e.url,"_blank"),children:"view PR"})]})}function Ok({src:e,n:t,name:n,width:r,height:o,bytes:i,uploading:l,onRemove:u,className:c=""}){return h.jsx(wk,{className:Ue("image-chip",c),label:h.jsxs(h.Fragment,{children:[h.jsx("img",{className:"image-thumb",src:e,alt:n,width:40,height:40}),h.jsxs("span",{className:"pick-target",children:[h.jsx("b",{children:Ax("image",t)}),h.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",n," · ",r,"×",o," · ",cg(i),l&&" · uploading"]})]})]}),peek:h.jsx("img",{src:e,alt:n,style:{aspectRatio:`${r} / ${o}`}}),full:h.jsx("img",{src:e,alt:n}),menu:f=>yc(e,f),removeLabel:"Remove image",onRemove:u})}function N6({img:e,src:t}){return h.jsx(Ok,{className:"in-chat",src:t,...e})}function MS(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:At("new"),onClick:()=>n({a:"open-draft"})}),l.push({id:"refs",label:"open a branch or PR…",key:At("refs"),onClick:()=>n({a:"open",overlay:{kind:"refs"}})})),i&&(l.push({id:"jump",label:"jump to file…",key:At("quick-open"),onClick:()=>n({a:"open",overlay:{kind:"quick-open"}})}),l.push({id:"search",label:"search in files…",key:At("search"),onClick:()=>n({a:"open",overlay:{kind:"search"}})})),Md(e)&&l.push({id:"routes",label:"go to page…",key:At("routes"),onClick:()=>n({a:"open",overlay:{kind:"routes"}})}),o&&l.push({id:"chats",label:"search chats…",key:At("chats"),onClick:()=>n({a:"open",overlay:{kind:"chats"}})});const u=Ng(e.visible,e.activeId,1);u&&l.push({id:"wt-unseen-next",label:"next that needs you",key:At("wt-unseen-next"),onClick:()=>n({a:"activate",id:u.activate})}),l.push({id:"project",label:e.repos.length>1?"switch project…":"open project…",key:At("project"),onClick:()=>n({a:"open",overlay:{kind:"projects",form:"center"}})});const c=[{id:"changes",label:`${r(e.layout.changes)} changes panel`,key:At("changes"),onClick:()=>n({a:"toggle-changes"})},{id:"files",label:`${r(e.layout.changes&&Qa(e)==="files")} files`,key:At("files"),onClick:()=>n(e.layout.changes&&Qa(e)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"})},{id:"chat",label:`${r(e.layout.chat)} chat panel`,key:At("composer"),onClick:()=>n({a:"toggle-chat"})},{id:"terminal",label:`${r(e.layout.term)} terminal`,key:At("terminal"),onClick:()=>n({a:"toggle-terminal"})},{id:"rail",label:`${r(e.railOpen)} worktree panel`,key:At("rail"),onClick:()=>n({a:"toggle-rail"})},{id:"design",label:`${r(e.layout.design)} design system`,key:At("design"),onClick:()=>n({a:"toggle-design"})},{id:"zen",label:"full-bleed preview",key:At("zen"),onClick:()=>n({a:"toggle-zen"})}],f=[{id:"commands",label:"command palette",key:At("commands"),onClick:()=>n({a:"open",overlay:{kind:"commands"}})},{id:"keys",label:"settings & shortcuts",key:At("keys"),onClick:()=>n({a:"open",overlay:{kind:"keys"}})}];(g=e.self)!=null&&g.restart&&f.push({id:"restart-daemon",label:"restart Toyon",onClick:()=>t==null?void 0:t.send({t:"restart-daemon"})}),f.push({id:"add-machine",label:"add a machine",onClick:()=>n({a:"open",overlay:{kind:"add-machine"}})}),e.knocks.length>0?f.push({id:"pair",label:`let a device in (${e.knocks.length})`,onClick:()=>n({a:"open",overlay:{kind:"pair"}})}):sE(e)&&f.push({id:"pair",label:"open on your phone",onClick:()=>n({a:"open",overlay:{kind:"pair"}})});const p=xo(e)?new Set(["chat","design","zen"]):null;return Dn([l,p?c.filter(w=>!p.has(w.id)):c,f])}function Mk(e,t){const n=e.get(t);if(!n||n.serving)return[];const r=e.displayName(t),o=[];e.active().origin!==t&&o.push({id:`machine:${t}`,label:`switch to ${r}`,onClick:()=>e.activate(t)});const i=[{id:`forget-machine:${t}`,label:`forget ${r}…`,danger:!0,onClick:()=>{window.confirm(`Forget ${r}?
|
|
217
|
+
|
|
218
|
+
It leaves 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 Dn([o,i])}function Lk(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 LS(e,{sock:t}){return[{id:"restart:shell",label:"restart shell",onClick:()=>t==null?void 0:t.send({t:"term-restart",worktreeId:e,stream:vo})}]}function T6(e,t,n,r){return Dn([[...e.flatMap(o=>Lk(o,t,r)),...LS(t,r)],[{id:"terminal",label:`${n?"hide":"show"} terminal`,onClick:()=>r.dispatch({a:"toggle-terminal"})}]])}function j6(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 $f(e,t,{sock:n,dispatch:r}){const o=[];e.id!==t&&o.push({id:`repo:${e.id}`,label:`switch to ${e.name}`,onClick:()=>r({a:"activate-repo",id:e.id})});const i=[{id:`setup:${e.id}`,label:"project settings…",detail:e.configFile,onClick:()=>r({a:"open",overlay:{kind:"setup",repoId:e.id}})},{id:`archived:${e.id}`,label:"archived worktrees…",onClick:()=>{r({a:"activate-repo",id:e.id}),r({a:"open",overlay:{kind:"chats",names:!0}})}},{id:`forget:${e.id}`,label:"forget project…",danger:!0,onClick:()=>{window.confirm(`Forget ${e.name}?
|
|
219
|
+
|
|
220
|
+
Its procs stop, it leaves the project list, and the chat on main is deleted. The checkout is not touched, and archived worktrees come back when you open it again.`)&&(n==null||n.send({t:"forget-repo",repoId:e.id}))}}];return Dn([o,i])}const Kd={dark:"dark",light:"light",system:"follow system",daylight:"follow daylight"},Wd={use:"while in use",always:"always",off:"off"};function C6(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 PS(e,{sock:t,dispatch:n}){var l;const r=e.themePrefs,o=u=>{var c;return((c=e.themes.find(f=>f.id===u))==null?void 0:c.name)??u},i=UL();return Dn([[{id:"theme",label:"theme…",detail:hf(r,e.themes,Y1(e)).name,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"theme"}})},{id:"appearance",topic:"theme",label:"light or dark…",detail:Kd[r.mode],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"appearance"}})}],[{id:"agent",label:"default agent…",detail:((l=e.agents.find(u=>u.id===e.defaultAgent))==null?void 0:l.name)??e.defaultAgent,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"agent"}})}],[{id:"chat-side",label:"chat side",detail:e.chatSide,onClick:()=>n({a:"toggle-chat-side"})},...i.access==="none"?[]:[{id:"clipboard-offer",label:"offer what is copied",detail:i.access==="denied"?"blocked in site settings":i.on?"on":"off",onClick:()=>HL(!i.on)}]],...e.keepAwake===null?[]:[[{id:"keep-awake",label:"keep awake…",detail:Wd[e.keepAwake],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"keep-awake"}})}]],[{id:"theme-import",topic:"theme",label:"import a VS Code theme…",onClick:()=>C6((u,c)=>t==null?void 0:t.send({t:"import-theme",name:u,source:c}))},{id:"theme-rescan",topic:"theme",label:"rescan editor themes",onClick:()=>t==null?void 0:t.send({t:"rescan-themes"})}],[{id:"theme-dark",topic:"theme",label:"dark slot override…",detail:o(r.dark),sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"dark"}})},{id:"theme-light",topic:"theme",label:"light slot override…",detail:o(r.light),sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"light"}})}]])}function A6(e,t,n,r,o,i={machines:[],switchTo:()=>{},forget:()=>{}}){const l=[],u=(g,w,y,x,b)=>l.push({id:g,label:w,hint:x,run:y,sub:b}),c=(g,w)=>{for(const y of g){if(!xs(y)||y.disabled!==void 0||y.checked)continue;const x=y.key??(typeof y.detail=="string"?y.detail:void 0),b=w?`${w.scope}:${y.id}`:y.id,j=y.topic?`${y.topic}: ${y.label}`:y.label;u(b,w?`${j} · ${w.name}`:j,y.onClick,x,y.sub)}},f={sock:n,dispatch:t},p=r,m=p==null?void 0:p.worktree.id;if(c(MS(e,f).filter(g=>!xs(g)||g.id!=="commands")),o&&c($f(o,o.id,f),{scope:"project",name:o.name}),m&&!xo(e)&&(u("pick",e.picking==="chat"?"cancel element picker":"pick an element for the chat",()=>gc(m,e.picking,t,"chat"),At("pick")),u("inspect",e.picking==="code"?"cancel element picker":"pick an element to open its code",()=>gc(m,e.picking,t,"code"),At("inspect")),u("reload","reload preview",()=>en.post(m,{type:"reload"}))),c(PS(e,f)),p&&m){const g=e.repos.find(w=>w.id===p.worktree.repoId)??null;c(l_(p,g,e,f,{hostname:e.hostname}),{scope:"wt",name:gm(p,g)});for(const w of p.procs)c(Lk(w,m,f))}e.visible.forEach((g,w)=>{var j;if(g.worktree.id===m)return;const y=g.worktree.variant,b=e.activeRepoId&&zg(g,e.activeRepoId,e.rows)?` in ${((j=e.repos.find(N=>N.id===g.repoId))==null?void 0:j.name)??g.repoId}`:"";u(`go:${g.worktree.id}`,`switch to ${gm(g,o)}${y?` (v${y.index}/${y.of})`:""}${b}`,()=>t({a:"activate",id:g.worktree.id}),Cj(w,e.visible.length))});for(const g of e.repos)g.id!==(o==null?void 0:o.id)&&u(`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)u(`machine:${g.origin}:${w.id}`,`switch to project ${w.name} on ${g.name}`,()=>i.switchTo(g.origin,w.id));u(`forget-machine:${g.origin}`,`forget ${g.name}`,()=>i.forget(g.origin))}return l}function DS(){const e=at(),t=lt(),{host:n}=$r(),r=To(),o=fE(),i=M(Y=>Y.picking),l=M(Y=>Y.layout),u=M(Y=>Y.chatSide),c=M(Y=>Y.keepAwake),f=M(Y=>Y.railOpen),p=M(Y=>Y.themePrefs),m=M(Y=>Y.themes),g=M(Y=>Y.systemDark),w=M(Y=>Y.daylight),y=M(Y=>Y.rows),x=M(Y=>Y.visible),b=M(Y=>Y.activeId),j=M(Y=>Y.activeRepoId),N=M(Y=>Y.repos),T=M(Y=>Y.agents),R=M(Y=>Y.defaultAgent),$=M(Y=>Y.shipping),W=M(Y=>Y.remote),A=M(Y=>Y.managed),I=M(Y=>Y.frame),_=M(Y=>Y.self),P=M(Y=>Y.archivedPage),z=M(Y=>Y.archived),q=M(Y=>Y.knocks),se=M(Y=>Y.tailscale);return S.useMemo(()=>{const Y={picking:i,layout:l,chatSide:u,keepAwake:c,railOpen:f,themePrefs:p,themes:m,systemDark:g,daylight:w,rows:y,visible:x,activeId:b,activeRepoId:j,repos:N,agents:T,defaultAgent:R,shipping:$,remote:W,frame:I,self:_,archivedPage:P,archived:z,knocks:q,tailscale:se,hostname:n},ge={machines:o,switchTo:(ke,oe)=>{var L;(L=r.get(ke))==null||L.store.dispatch({a:"activate-repo",id:oe}),r.activate(ke)},forget:ke=>{const oe=Mk(r,ke).find(L=>xs(L)&&L.id.startsWith("forget-machine:"));oe&&xs(oe)&&oe.onClick()}};return A6(Y,e,t,dn(Y,b),ci(Y,j),ge)},[i,l,u,c,f,p,m,g,w,y,x,b,j,N,T,R,$,W,A,I,_,P,z,q,se,e,t,n,r,o])}function zS(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=[];for(const o of e){const i=Fm(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 Fm(e,t){const n=Pk(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+(FS(e,l)?3:0),i=l;return r+Math.max(0,40-e.length/4)}const FS=(e,t)=>t===0||/[\s:\-–—·/.(]/.test(e[t-1]);function Pk(e,t){const n=e.toLowerCase(),r=[];let o=0;for(const i of t.toLowerCase()){let l=-1;if(n[o]===i)l=o;else if(i===" ")l=n.indexOf(" ",o);else for(let u=n.indexOf(i,o);u!==-1;u=n.indexOf(i,u+1))if(FS(n,u)){l=u;break}if(l===-1)return null;r.push(l),o=l+1}return r}const Es=(e,...t)=>{const n=e.trim().toLowerCase();return!n||t.some(r=>r==null?void 0:r.toLowerCase().includes(n))},I6=/^[^\s]*$/;function Zb(e,t){if(e.startsWith("!"))return null;if(e.startsWith("/")){const i=e.indexOf(" "),l=i===-1?e.length:i;if(!(e.indexOf("/",1)!==-1&&e.indexOf("/",1)<l)&&t<=l)return{kind:"command",query:e.slice(1,t),from:0,to:l}}const n=e.lastIndexOf("@",Math.max(0,t-1));if(n===-1||n>=t||n>0&&!/\s/.test(e[n-1]??""))return null;const r=e.slice(n+1,t);if(!I6.test(r))return null;let o=t;for(;o<e.length&&!/\s/.test(e[o]??"");)o++;return{kind:"file",query:r,from:n,to:o}}const R6={files:new Set,folders:new Set},qb=new WeakMap;function $6(e){if(!e)return R6;let t=qb.get(e);return t||(t={files:new Set(e),folders:new Set(Z1(e))},qb.set(e,t)),t}const O6=/(^|\s)(@\S+)/g,M6=/[.,;:!?)\]}'"]$/;function Gb(e,t){if(e==="changes")return{kind:"changes",text:"@changes"};if(t.files.has(e))return{kind:"file",text:`@${e}`,path:e};const n=e.replace(/\/+$/,"");return n&&t.folders.has(n)?{kind:"folder",text:`@${e}`,path:n}:null}function L6(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(O6)){const l=i.index+(i[1]??"").length;let u=(i[2]??"").slice(1),c=Gb(u,t);for(;!c&&M6.test(u);)u=u.slice(0,-1),c=u?Gb(u,t):null;c&&(o(e.slice(r,l)),n.push(c),r=l+c.text.length)}return o(e.slice(r)),n}function P6(e,t,n){return{text:e.slice(0,t.from)+n+e.slice(t.to),caret:t.from+n.length}}function D6(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=i=>e.map((l,u)=>({c:l,i:u,score:i(l)})).filter(l=>l.score>0).sort((l,u)=>u.score-l.score||l.i-u.i).map(l=>l.c),o=r(i=>Fm(i.name,n));return o.length>0?o:r(i=>Fm(i.description,n))}const z6=/(^|\s)@\S/;function BS({text:e,worktreeId:t,root:n,inField:r}){const o=Zn(),i=lt(),l=M(p=>{var m;return t?(m=p.local[t])==null?void 0:m.files:void 0}),u=$6(l),c=S.useMemo(()=>L6(e,u),[e,u]),f=l===void 0&&t&&z6.test(e)?t:null;return S.useEffect(()=>{f&&_f(f,o.getState(),{sock:i,dispatch:o.dispatch})},[f,o,i]),h.jsx(h.Fragment,{children:c.map((p,m)=>{if(p.kind==="text")return p.text;if(p.kind==="changes"){const x=Dt("this worktree's uncommitted files",void 0,{placement:"follow"});return h.jsx("span",{className:"chat-mention","data-changes":"",...x,children:p.text},m)}if(!n||!t)return p.text;const g=p.kind==="folder",w=`${n}/${p.path}${g?"/":""}`,y=Dt(g?`${p.path}/`:p.path,void 0,{placement:"follow"});return h.jsx("a",{className:"chat-mention",href:w,tabIndex:r?-1:void 0,...y,children:p.text},m)})})}function US(e,t,n,r){if(e.target.closest("[data-changes]")){n&&r.dispatch({a:"focus-changes",tab:"changes"});return}kk(e,t,n,r)}function F6(e){return e.length<2||!e.every(t=>{var n;return t.length===1&&((n=t[0])==null?void 0:n.diff)})?null:U6(e.map(t=>t[0].text))}const B6=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function U6(e,t=3){let n=[];for(const r of e){const o=H6(r);if(!o)return null;const i=K6(n,o);if(!i)return null;n=i}return n.some(r=>r.kind!=="same")?W6(n,t):null}function H6(e){const t=[];let n=null;for(const r of e.split(`
|
|
221
|
+
`)){const o=B6.exec(r);if(o){n={oldStart:Number(o[1]),newStart:Number(o[2]),ops:[]},t.push(n);continue}if(!n)return null;const i=r[0];if(i===" "||i==="-"||i==="+")n.ops.push({mark:i,text:r.slice(1)});else if(r==="")n.ops.push({mark:" ",text:""});else return null}return t.length>0?t:null}function K6(e,t){const n=[];let r=0,o=0,i=0,l=0;const u=p=>{p.kind==="same"?o=p.a-p.c:p.kind==="add"?o-=1:o+=1},c=()=>{for(;r<e.length&&e[r].kind==="del";)n.push(e[r]),u(e[r]),r++},f=p=>{for(let m=p;m<e.length;m++){const g=e[m];if(g.kind!=="del")return g.c}return Number.POSITIVE_INFINITY};for(const p of t){if(p.oldStart<=l)return null;for(;r<e.length;){const w=e[r];if((w.kind==="del"?f(r):w.c)>=p.oldStart)break;n.push(w.kind==="del"?w:{...w,c:w.c+i}),u(w),r++}let m=p.oldStart,g=p.newStart;for(const w of p.ops){if(c(),w.mark==="+"){n.push({kind:"add",c:g,text:w.text}),g++;continue}const y=e[r],x=y&&y.kind!=="del"&&y.c===m?y:void 0;if(x){if(x.text!==w.text)return null;r++,u(x),w.mark===" "?n.push({...x,c:g}):x.kind==="same"&&n.push({kind:"del",a:x.a,text:x.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 p=e[r];n.push(p.kind==="del"?p:{...p,c:p.c+i})}return n}function W6(e,t){const n=[];for(const r of q6(e))for(const[o,i]of G6(r.rows,t)){const l=Z6(r.rows.slice(o,i)),u=l.filter(m=>m.kind!=="add").length,c=l.filter(m=>m.kind!=="del").length,f=l.find(m=>m.kind!=="add"),p=l.find(m=>m.kind!=="del");n.push(`@@ -${f?f.a:r.oldAt[o]},${u} +${p?p.c:r.newAt[o]},${c} @@`,...l.map(m=>`${m.kind==="add"?"+":m.kind==="del"?"-":" "}${m.text}`))}return n.join(`
|
|
222
|
+
`)}function Z6(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 q6(e){const t=[];let n=null,r=1,o=1;for(const i of e){const l=i.kind==="add"?r:i.a,u=i.kind==="del"?o:i.c;(!n||l!==r||u!==o)&&(n={rows:[],oldAt:[],newAt:[]},t.push(n)),n.rows.push(i),n.oldAt.push(l),n.newAt.push(u),r=l+(i.kind==="add"?0:1),o=u+(i.kind==="del"?0:1)}return t}function G6(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 Bm({pieces:e}){return h.jsx(h.Fragment,{children:e.map((t,n)=>{const r=`${t.changed?"ch ":""}${t.scope?`sy-${t.scope}`:""}`.trim();return r?h.jsx("span",{className:r,children:t.text},n):h.jsx(S.Fragment,{children:t.text},n)})})}function Dk({pick:e,dir:t,worktreeId:n,tipText:r,onHover:o,onOpen:i,onRemove:l,className:u=""}){const c=e.callFile,f=e.file,p=c?{path:c,line:e.callLine}:f?{path:f,line:e.line}:null,m=c&&f?{path:f,line:e.line}:null,g=(T,R)=>`${T}${R?`:${R}`:""}`,w=T=>T.split("/").pop()??T,y=(T,R,$,W)=>i?h.jsx("button",{className:"pick-open","data-tip":W,onClick:()=>i(T,R??1),children:$}):$,x=fn("chat"),{host:b}=$r(),j=S.useRef(null),N=l?()=>{o==null||o(!1),l()}:void 0;return h.jsxs("div",{ref:j,className:Ue("pick-chip row row-sm",u),"data-tip":r,onMouseEnter:()=>o==null?void 0:o(!0),onMouseLeave:()=>o==null?void 0:o(!1),...x.contextMenu(()=>OD(e,{dir:t,remove:N,host:b})),children:[h.jsxs("span",{className:"pick-target",children:[h.jsx(jt,{name:"pick",className:"icon-inline"})," ",$g(e),p&&h.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",y(p.path,p.line,g(w(p.path),p.line),`Open ${g(p.path,p.line)}`)]}),m&&h.jsxs("span",{className:"pick-file row-dim",children:[" ","·"," ",y(m.path,m.line,g(m.path.split("/").pop()??m.path,m.line),`Open the component: ${g(m.path,m.line)}`)]})]}),N&&h.jsx(Ot,{icon:"close",label:"Remove attachment",tone:"quiet",onClick:N}),n&&(p==null?void 0:p.line)&&h.jsx(B_,{chip:j,children:h.jsx(X6,{worktreeId:n,path:p.path,line:p.line})})]})}const V6=6,Y6=16;function X6({worktreeId:e,path:t,line:n}){const r=hE(),o=lt(),i=M(m=>{var g;return((g=So(m))==null?void 0:g.id)===e}),l=M(m=>{var g;return i?0:(g=_o(m,e).changedRanges[t])==null?void 0:g.offset}),[u,c]=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&&c(g)}),()=>{m=!1}},[r,o,e,t,i]);const f=S.useMemo(()=>{if(u===null||l===void 0)return null;const m=u.split(`
|
|
223
|
+
`),g=n-l,w=Math.max(1,g-V6),y=Math.min(m.length,g+Y6);if(w>y)return null;const x=m.slice(w-1,y);return{from:w,at:g,slice:x,painted:jk(x.join(`
|
|
224
|
+
`),Tk("",t))}},[u,l,n,t]);if(!f)return null;const p=String(f.from+f.slice.length-1).length;return h.jsx("pre",{className:"pick-peek",children:f.slice.map((m,g)=>{const w=f.from+g,y=f.painted[g];return h.jsxs("span",{className:"pick-peek-line","data-state":w===f.at?"current":void 0,children:[h.jsx("span",{className:"pick-peek-n",children:String(w).padStart(p)}),y!=null&&y.length?h.jsx(Bm,{pieces:y}):m||" "]},w)})})}function Q6(e){return e.startsWith("!")?e.slice(1).trim():null}function Of(e){if(e.kind!=="tool"||e.name!==ni&&e.name!==_x)return null;const t=e.input;return typeof(t==null?void 0:t.command)=="string"?t.command:null}function J6(e){return e.length>0&&e.every(t=>t.kind==="tool"&&t.name===ni&&Of(t)!==null&&!t.input.landing&&t.done&&!t.isError)}function eF(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=Of(o);if(i===null)continue;const l=CS(o.output??"").map(c=>c.text).join(`
|
|
225
|
+
`),u=AO(l);t.unshift(`$ ${i}${u?`
|
|
226
|
+
${u}`:""}`)}if(t.length!==0)return`Shell commands the user ran since their last message, and what each printed:
|
|
227
|
+
${t.join(`
|
|
228
|
+
`)}`}function tF(e,t,n,r,o){const{sock:i}=r,l=e[0];if(!l)return[];const u=[],c=Rk(Rf(l),t);if(c&&!c.startsWith("/")&&n){const y=l.toolKind==="edit"?"diff":"file";u.push({id:"open-diff",label:`open ${y}`,onClick:()=>er(r,{worktreeId:n.id,path:c,view:y})}),u.push(...Bi(`${n.dir}/${c}`,()=>i==null?void 0:i.send({t:"reveal",worktreeId:n.id,path:c}),os(i)))}else c.startsWith("/")&&u.push(...Bi(c,void 0,os(i)),{id:"copy-path",label:"copy path",onClick:()=>Qt(c)});const f=[],p=vc(l,t).command,m=r6(l);m&&m!==p&&f.push({id:"copy-description",label:"copy description",onClick:()=>Qt(m)}),p&&f.push({id:"copy-command",label:"copy command",onClick:()=>Qt(p)});const g=e.map(y=>y.output??"").filter(Boolean).join(`
|
|
229
|
+
`);g&&f.push({id:"copy-output",label:"copy output",onClick:()=>Qt(g)});const w=o.leaf?[]:[{id:"fold",label:o.open?"collapse":"expand",onClick:o.toggle}];return Dn([u,f,w])}const HS=e=>e.replace(/\n$/,""),nF=1500,Vb=4;function KS(e){return e.closest(".md pre, .card-code pre")}function Um(e){const t=KS(e);return t?HS(t.textContent??""):null}function rF(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{pre:t,top:r.top-n.top+e.scrollTop+Vb,right:n.left+e.clientLeft+e.clientWidth-r.right+Vb}}function zk(e){const[t,n]=S.useState(null),[r,o]=S.useState(null);if(S.useEffect(()=>{const f=e.current;if(!f)return;const p=g=>{if(!(g.target instanceof Element)||g.target.closest(".code-copy"))return;const w=KS(g.target);n(w&&f.contains(w)?rF(f,w):null)},m=()=>n(null);return f.addEventListener("pointerover",p),f.addEventListener("pointerleave",m),()=>{f.removeEventListener("pointerover",p),f.removeEventListener("pointerleave",m)}},[e]),S.useEffect(()=>{if(!r)return;const f=setTimeout(()=>o(null),nF);return()=>clearTimeout(f)},[r]),!(t!=null&&t.pre.isConnected))return null;const{pre:i,top:l,right:u}=t,c=r===i;return h.jsx(Ot,{className:"code-copy",style:{top:l,right:u},icon:c?"check":"copy",label:c?"Copied":"Copy code",onClick:()=>{Qt(HS(i.textContent??"")),o(i)}})}function Hp({text:e,menu:t,marked:n,worktreeId:r,fileRoot:o,streaming:i}){const l=Ck(e,{fileRoot:o,streaming:i}),u=lt(),c=at(),f=fn("chat"),p=S.useRef(null);kE(p,l);const m=M(y=>{var x;return r?(x=y.local[r])==null?void 0:x.refusedLink:void 0});vt([l,m],()=>{var x;const y=p.current;if(y)for(const b of y.querySelectorAll("a.file-link")){const j=m!==void 0&&b.getAttribute("href")===m.href;b.classList.toggle("file-link-refused",j),j?((x=b.dataset).tipWas??(x.tipWas=b.dataset.tip??""),b.dataset.tip=m.message,b.dataset.tipPlacement="bottom",b.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0}))):b.dataset.tipWas!==void 0&&(b.dataset.tip=b.dataset.tipWas,b.dataset.tipPlacement="follow",delete b.dataset.tipWas)}});const g=S.useRef(null),w=zk(g);return h.jsxs("div",{ref:g,className:"msg-assistant md row-edge","data-state":mr({cursor:n}),...f.contextMenu((y,x)=>t(gk(x,o),Um(x))),onClick:y=>kk(y,o,r,{sock:u,dispatch:c}),children:[h.jsx("div",{ref:p}),w]})}const Kp=40;function WS(e,t){return e.map(n=>{const r=Tk(n.lang,t||(n.diff?E5(n.text):""));if(n.diff){const o=l6(n.text);return{...n,lines:o,painted:N5(o,r)}}return{...n,lines:[],painted:n.code?jk(n.text,r):[]}})}function ZS({blocks:e,path:t,worktreeId:n}){lt();const r=at();return h.jsx("div",{className:"tool-out",children:e.map((o,i)=>o.diff?h.jsxs("pre",{className:"tool-block diff",children:[o.lines.slice(0,Kp).map((l,u)=>{var c;return l.kind==="hunk"?h.jsx("span",{className:"dl hunk",title:l.text},u):h.jsx("span",{className:`dl ${l.kind}`,children:(c=o.painted[u])!=null&&c.length?h.jsx(Bm,{pieces:o.painted[u]}):l.text||" "},u)}),o.lines.length>Kp&&h.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-Kp," more lines"]})]},i):o.code?h.jsx("pre",{className:"tool-block",children:o.painted.length?o.painted.map((l,u)=>h.jsxs(S.Fragment,{children:[u>0?`
|
|
230
|
+
`:null,h.jsx(Bm,{pieces:l})]},u)):o.text},i):h.jsx("p",{className:"tool-note",children:o.text},i))})}function oF({image:e,worktreeId:t}){const n=$r().attachment(t,e.file),[r,o]=S.useState(!1),i=fn("chat");return h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button",className:"tool-image","data-tip":"Open full size","data-tip-placement":"follow",onClick:()=>o(!0),...i.contextMenu(()=>yc(n,{open:()=>o(!0)})),children:h.jsx("img",{src:n,alt:e.file})}),r&&h.jsx(pk,{owner:"chat",onClose:()=>o(!1),menu:()=>yc(n),children:h.jsx("img",{src:n,alt:e.file})})]})}const sF=S.memo(function({item:t,roots:n,worktreeId:r}){const o=S.useMemo(()=>WS(zm(t,t.output??""),Rf(t)),[t]),i=vc(t,n).command,l=r?t.images??[]:[];return!i&&o.length===0&&l.length===0?null:h.jsxs("div",{className:"tool-part",children:[i&&h.jsx("pre",{className:"tool-block cmd",children:i}),o.length>0&&h.jsx(ZS,{blocks:o,path:qS(t,n),worktreeId:r}),l.length>0&&r&&h.jsx("div",{className:"tool-out",children:l.map(u=>h.jsx(oF,{image:u,worktreeId:r},u.file))})]})});function qS(e,t){const n=Rk(Rf(e),t??[]);return n.startsWith("/")?"":n}const iF=S.memo(function({text:t,item:n,roots:r,worktreeId:o}){const i=Rf(n),l=S.useMemo(()=>WS([{code:!0,diff:!0,lang:"diff",text:t}],i),[t,i]);return h.jsx("div",{className:"tool-part",children:h.jsx(ZS,{blocks:l,path:qS(n,r),worktreeId:o})})});function Hm({className:e,state:t,auto:n,leaf:r,growing:o,label:i,summary:l,menu:u,children:c}){const[f,p]=S.useState(null),m=S.useRef(null),g=S.useRef(null),w=gE(g),y=yL(".chat-log"),x=!r&&(f??n),b=()=>{r||(x||y(m.current),p(!x))},j=fn("chat");return h.jsxs("details",{ref:m,className:Ue(e,r&&"leaf"),"data-state":t,open:x,onToggle:N=>{if(!N.currentTarget.open||o)return;const T=g.current;T&&(T.scrollTop=0,w.read())},...j.contextMenu((N,T)=>u({open:x,leaf:!!r,toggle:b},T)),tabIndex:-1,onPointerDown:()=>{var N;return(N=m.current)==null?void 0:N.focus({preventScroll:!0})},onKeyDown:N=>{if((N.key==="ArrowLeft"||N.key==="ArrowRight")&&!r){if(N.shiftKey||N.altKey||N.metaKey||N.ctrlKey)return;Cf([{depth:0,open:x}],0,N.key)&&b();return}N.key!=="Escape"||!x||(N.stopPropagation(),p(!1))},children:[h.jsx("summary",{"aria-label":i,tabIndex:r?-1:void 0,onClick:N=>{N.preventDefault(),b()},children:l}),h.jsx("div",{className:"tool-body",ref:g,children:c})]})}const aF=S.memo(function({item:t,open:n,streaming:r,worktreeId:o,fileRoot:i}){const l=bS(t.text),u=l.slice(0,-1),c=Ck(l.length?u.join(`
|
|
231
|
+
|
|
232
|
+
`):yS(t.text),i?{fileRoot:i}:void 0),f=lt(),p=at(),m=r?"Thinking":"Thought",g=S.useRef(null);kE(g,c);const w=S.useRef(null),y=zk(w),x=h.jsx("div",{className:"tool-part",children:h.jsxs("div",{ref:w,className:"tool-out thought-out md",onClick:j=>kk(j,i,o,{sock:f,dispatch:p}),children:[h.jsx("div",{ref:g}),y]})}),b=l.at(-1)??(r?"":xS(t.text));if(b){const j=u.length===0;return h.jsx(Hm,{className:"tool-row",auto:!1,leaf:j,growing:r,label:b,menu:(N,T)=>Dn([Rm(Um(T)),[{id:"copy",label:"copy thought",onClick:()=>Qt(t.text)}],...j?[]:[[{id:"fold",label:N.open?"collapse":"expand",onClick:N.toggle}]]]),summary:h.jsxs(h.Fragment,{children:[h.jsx(jt,{name:"bulb",className:"tool-icon"}),h.jsx("span",{className:Ue("tool-hint thought-line",r&&"live-text"),children:b})]}),children:j?null:x})}return h.jsx(Hm,{className:"tool-row",auto:!!n,growing:r,label:m,menu:(j,N)=>Dn([Rm(Um(N)),[{id:"copy",label:"copy thought",onClick:()=>Qt(t.text)}],[{id:"fold",label:j.open?"collapse":"expand",onClick:j.toggle}]]),summary:h.jsxs(h.Fragment,{children:[h.jsx(jt,{name:"bulb",className:"tool-icon"}),h.jsx("span",{className:Ue("tool-name",r&&"live-text"),children:m})]}),children:x})}),Yl=6,lF={land:"the land",commit:"the commit","sync-main":"the sync","pull-main":"the pull"},ld=S.memo(function e({tools:t,run:n,next:r,live:o,working:i,since:l,queued:u,roots:c,worktreeId:f,marked:p}){const m=t[0],g=S.useMemo(()=>F6(t.map(de=>zm(de,de.output??""))),[t]),w=t.at(-1)??m,y=!w.done,x=y&&!!w.background,j=(y||!!r)&&!u||!!i,N=y&&!!u,T=Ja(y||i?l:void 0),R=n?w6(n):-1,$=S.useMemo(()=>n?$S(n,!0):void 0,[n]),W=!!o,A=vc(m,c),I=y?n6(m):"",{label:_,icon:P}=A,z=TS(m),q=I?"":z?"Guardian":A.name,se=I&&m.subagent?A.hint:"",Y=se||I||(z?Q5(m.output??""):A.hint),ge=!(n&&n.length>0)&&!g&&t.every(de=>{var we;return!vc(de,c).command&&zm(de,de.output??"").length===0&&!((we=de.images)!=null&&we.length)}),ke=n?p6(n):0,oe=J6(t),L=[_,Y].filter(Boolean).join(" ")+(x?", in the background":"")+(N?", queued":"")+(oe?", done":""),re=I?"":n?`${ke} ${ke===1?"call":"calls"}`:t.length>1?`×${t.length}`:"",te=Zn(),K=lt(),B=M(de=>{var we;return f?(we=de.shipping[f])==null?void 0:we.op:void 0}),xe=y&&m.name===ni&&f?{worktreeId:f,toolId:w.id}:null;return h.jsxs(Hm,{className:Ue("tool-row",t.some(de=>de.isError)&&"error",m.parentToolId&&"nested",n&&"spawn",N&&"queued"),state:mr({cursor:p}),auto:W,leaf:ge,growing:j,label:n&&re?`${L}, ${re}`:t.length>1?`${L}, ${t.length} calls`:L,menu:de=>{const we=dn(te.getState(),f),ee=we?{id:we.worktree.id,dir:we.worktree.path}:null;return tF(t,c??[],ee,{sock:K,dispatch:te.dispatch},de)},summary:h.jsxs(h.Fragment,{children:[h.jsx(jt,{name:n?"spawn":P,className:"tool-icon"}),q&&h.jsx("span",{className:Ue("tool-name",j&&!Y&&"live-text"),children:q}),I&&!se?h.jsx("span",{className:"tool-writing","data-tip":Y,children:h.jsx(el,{variant:"squares"})}):Y&&h.jsx("span",{className:Ue("tool-hint",j&&"live-text"),children:Y}),x&&h.jsx("span",{className:"tool-status",children:"in the background"}),N&&h.jsx("span",{className:"tool-status",children:"queued"}),oe&&h.jsx(jt,{name:"check",className:"tool-done"}),T>=Yl&&h.jsx("span",{className:Ue("tool-age",R>=0&&"tool-age-folded"),children:Ba(T)}),re&&h.jsx("span",{className:"tool-count",children:re}),se&&h.jsx("span",{className:"tool-writing","data-tip":I,children:h.jsx(el,{variant:"squares"})}),xe&&h.jsx(Ot,{icon:"stop",className:"tool-stop",label:B?`Stop ${lF[B]}: this step is killed, and what it printed so far stays`:x?"Kill what the command left running; what it printed so far stays":"Kill the command and everything it started; what it printed so far stays",onClick:de=>{de.preventDefault(),de.stopPropagation(),K==null||K.send({t:"exec-stop",...xe})}})]}),children:[n&&n.length>0&&h.jsx("div",{className:"spawn-run",children:n.map((de,we)=>h.jsx(e,{tools:de.tools,next:de.next,since:we===R?l:void 0,queued:$==null?void 0:$.has(we),roots:c,worktreeId:f},de.at))}),g?h.jsx(iF,{text:g,item:m,roots:c,worktreeId:f}):t.map(de=>h.jsx(sF,{item:de,roots:c,worktreeId:f},de.id))]})},(e,t)=>e.live===t.live&&e.working===t.working&&e.since===t.since&&e.queued===t.queued&&e.next===t.next&&e.roots===t.roots&&e.worktreeId===t.worktreeId&&e.marked===t.marked&&$k(e.tools,t.tools)&&OS(e.run,t.run));function cF({item:e}){const t=lt(),n=at(),r=M(y=>y.activeId),o=M(y=>y.layout.term),i=M(y=>{var x;return((x=y.rows.find(b=>b.id===y.activeId))==null?void 0:x.login)??!1}),l=M(y=>y.managed.problem),[u,c]=S.useState(""),[f,p]=S.useState(null),m=S.useRef(!1);if(vt([i],()=>{i&&m.current&&r&&n({a:"term-stream",id:r,stream:vs,tall:!0})}),vt([e.done],()=>{e.done&&m.current&&o&&n({a:"toggle-terminal"}),m.current=!1}),!r)return null;const g=(y,x)=>{t==null||t.send({t:"agent-auth",worktreeId:r,methodId:y,...x?{apiKey:x}:{}})},w=e.methods.find(y=>y.id===f);return h.jsxs("div",{className:`auth-card ${e.done?"done":""}`,children:[h.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&&h.jsxs("div",{className:"auth-methods",children:[e.methods.map(y=>y.needsKey?h.jsx(Le,{variant:"outline",on:f===y.id,"data-tip":y.description,onClick:()=>p(f===y.id?null:y.id),children:y.name},y.id):h.jsx(Le,{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)),h.jsx(Le,{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&&h.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&&h.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&&h.jsxs("form",{className:"auth-key",onSubmit:y=>{y.preventDefault(),u.trim()&&(g(w.id,u.trim()),c(""),p(null))},children:[h.jsx(Eo,{type:"password",autoFocus:!0,placeholder:`${w.name} for ${e.agentName}`,value:u,onChange:y=>c(y.target.value)}),h.jsx(Le,{type:"submit",children:"use key"})]})]})}const uF=S.memo(function({item:t,worktreeId:n,onPickHover:r,marked:o,streaming:i}){const l=Zn(),u=lt(),c=$r(),f=fn("chat"),p={sock:u,dispatch:l.dispatch},m=()=>{const w=dn(l.getState(),n);return w?w.worktree.path:null},g=()=>{var w;return(w=dn(l.getState(),n))==null?void 0:w.worktree.path};switch(t.kind){case"user":{const w=g();return h.jsxs("div",{className:"msg-user row-edge","data-state":mr({cursor:o}),...f.contextMenu((y,x)=>Ni(t,n??null,p,{link:gk(x,w),dir:m()})),onClick:y=>US(y,w,n,p),children:[t.attachments&&n&&h.jsx("div",{className:"msg-attachments",children:t.attachments.map(y=>y.kind==="image"?h.jsx(N6,{img:y,src:c.attachment(n,y.file)},`${y.kind}-${y.n}`):y.kind==="file"?h.jsx(Ik,{className:"in-chat",name:y.name,bytes:y.bytes,href:y.text?c.attachment(n,y.file):void 0},`${y.kind}-${y.n}`):y.kind==="paste"?h.jsx(Ak,{className:"in-chat",n:y.n,name:y.name,source:y.source,lines:y.lines,chars:y.chars,preview:y.preview,href:c.attachment(n,y.file)},`${y.kind}-${y.n}`):h.jsx(Dk,{pick:y,dir:m(),className:"in-chat",tipText:"Hover to highlight on the page",onHover:x=>r==null?void 0:r(y,x),worktreeId:n,onOpen:(x,b)=>tl(l,u,n,x,b)},`${y.kind}-${y.n}`))}),h.jsx(BS,{text:t.text,worktreeId:n,root:w})]})}case"assistant":return h.jsx(Hp,{text:t.text,menu:(w,y)=>Ni(t,n??null,p,{link:w,code:y,dir:m()}),marked:o,worktreeId:n,fileRoot:g(),streaming:i});case"error":return h.jsx("div",{className:"msg-assistant msg-error",...f.contextMenu(()=>Ni(t,n??null,p)),children:t.text});case"auth":return h.jsx(cF,{item:t});case"ask":{const w=gM(t);if(w){const j=B1(w.questions,w.answers).join(`
|
|
233
|
+
`),N={kind:"assistant",text:j};return h.jsxs(h.Fragment,{children:[h.jsx(Hp,{text:w.message,menu:(T,R)=>Ni({kind:"assistant",text:w.message},n??null,p,{link:T,code:R,dir:m()}),worktreeId:n,fileRoot:g()}),h.jsx("div",{className:"msg-user",...f.contextMenu(()=>Ni(N,n??null,p)),children:j})]})}const y=kM(t);if(!y)return h.jsx(WD,{item:t});const x=y.file,b={kind:"assistant",text:y.choice};return h.jsxs(h.Fragment,{children:[x?h.jsx(Jr,{icon:"file",word:"plan",tone:"quiet",children:h.jsx("span",{className:"daemon-text",children:h.jsx(Le,{variant:"inline",tone:"strong",mono:!0,onClick:()=>n&&er(p,{worktreeId:n,path:x,view:"preview"}),children:x})})}):y.text&&h.jsx(Hp,{text:y.text,menu:(j,N)=>Ni({kind:"assistant",text:y.text},n??null,p,{link:j,code:N,dir:m()}),worktreeId:n,fileRoot:g()}),h.jsx("div",{className:"msg-user",...f.contextMenu(()=>Ni(b,n??null,p)),children:y.choice})]})}case"blocked":return h.jsxs(Jr,{icon:"lock",word:"blocked",tone:"red",below:h.jsx("div",{className:"daemon-below row-dim",children:t.reason}),...f.contextMenu(()=>P_(t.path,m(),void 0,os(p.sock))),children:[h.jsx("span",{className:"tool-name",children:t.tool}),t.path&&h.jsx("span",{className:"tool-hint",children:t.path})]});case"grafted":return h.jsxs(Jr,{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:[h.jsx("span",{className:"tool-name",children:t.title}),h.jsx("span",{className:"tool-hint",children:t.branch})]});case"asked":return h.jsx(Jr,{icon:"send",word:"asked",tone:"quiet",children:h.jsx("span",{className:"daemon-text",children:t.why})});case"stopped":return h.jsx(Jr,{icon:"stop",word:"stopped",tone:"quiet"});case"page-error":return h.jsx(Jr,{icon:"globe",word:"preview threw",tone:"quiet",below:h.jsx("code",{className:"daemon-text",children:t.message})});case"landed":return h.jsx(fF,{item:t});case"handoff":return h.jsx(_6,{item:t});case"handoff-landed":return h.jsx(S6,{item:t});case"restored":return h.jsx(dF,{item:t});case"adopted":return h.jsx(Jr,{icon:"branch",word:"taken over",tone:"quiet",at:t.ts,children:h.jsxs("span",{className:"daemon-text",children:["on ",t.branch,", its own branch"]})})}});function dF({item:e}){return h.jsx(Jr,{icon:"reload",word:"restored",tone:"quiet",at:e.ts,children:h.jsxs("span",{className:"daemon-text",children:["after ",Og(e.ts-e.archivedAt)," in the archive, back on ",e.branch,e.uncommitted?" with its uncommitted changes":""]})})}function fF({item:e}){const t=lt(),n=at(),r=M(l=>e.archiveIds.filter(u=>dn(l,u)!==null).length),o=T_(e.ts),i=e.mark&&ak(e.mark);return h.jsxs(Jr,{icon:"check",word:"landed",tone:"aqua",at:e.ts,below:i?h.jsx("div",{className:"daemon-below row-dim",children:Ur(i)}):void 0,children:[h.jsxs("span",{className:"daemon-text",children:[e.text,", ",o]}),r>0&&h.jsx(Le,{variant:"inline",tone:"strong",onClick:()=>Pi(t,n,e.archiveIds),children:r>1?`archive ${r} worktrees`:"archive the other worktree"})]})}const GS=e=>e===""||e==="!";function Yb(e,t){const n=new Set,r=[];for(let o=e.length-1;o>=0;o--){const i=e[o],l=Of(i),u=l!==null?`!${l}`:i.kind==="user"&&!t?i.text:null;u===null||!u.trim()||n.has(u)||(n.add(u),r.push({text:u,at:o}))}return r}function hF(e,t,n,r){if(!t){if(r!=="up"&&r!=="first"||!GS(n))return null;const u=Yb(e,n==="!"),c=r==="up"?u[0]:u.at(-1);return c?{walk:{at:c.at,from:n},text:c.text}:null}if(r==="box")return{walk:null,text:t.from};const o=Yb(e,t.from==="!"),i=r==="first"?o.length-1:o.findIndex(u=>u.at===t.at)+(r==="up"?1:-1);if(i<0)return{walk:null,text:t.from};const l=o[i];return l?{walk:{at:l.at,from:t.from},text:l.text}:{walk:t,text:n}}function pF(e,t,n,r){const o=new Map;return{rows:t.map((l,u)=>{const c=n(l,u),f=e.get(l.at),p=f&&f.row.kind===c.kind&&mF(f.row.props,c.props)?f.el:r(l,c);return o.set(l.at,{row:c,el:p}),p}),cache:o}}function mF(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){if(!(o in t))return!1;const i=e[o],l=t[o];if(!Object.is(i,l)&&(!Array.isArray(i)||!Array.isArray(l)||i.length!==l.length||!i.every((u,c)=>Object.is(u,l[c]))))return!1}return!0}const gF={get current(){return rc.el}};function Xb({items:e,next:t,worktreeId:n,dir:r,onOpen:o}){const i=$r();return h.jsx("div",{className:"msg-attachments",children:lg(e,t).map(([l,u])=>l.kind==="image"?h.jsx(Ok,{className:"in-chat",src:i.upload(l.upload),n:u,name:l.name,width:l.width,height:l.height,bytes:l.bytes},`image-${u}`):l.kind==="file"?h.jsx(Ik,{className:"in-chat",name:l.name,bytes:l.bytes,href:l.text?i.upload(l.upload):void 0},`file-${u}`):l.kind==="paste"?h.jsx(Ak,{className:"in-chat",n:u,name:l.name,source:l.source,...vg(l.text),text:l.text},`paste-${u}`):h.jsx(Dk,{className:"in-chat",pick:l,dir:r,worktreeId:n,onOpen:o},`pick-${u}`))})}const kF=new Set,wF=240;function Wp({active:e,archived:t,found:n,lead:r,tail:o}){var ut;const i=lt(),l=Zn(),u=at(),c=M(Ee=>Ee.frame==="phone"),f=(e==null?void 0:e.worktree.id)??(t==null?void 0:t.id)??(n==null?void 0:n.id)??null,p=Tt(f,"chat"),m=Tt(f,"queue"),g=Tt(f,"restoring"),w=Tt(f,"sending"),y=S.useMemo(()=>nm(p.map(Ee=>Ee.kind==="user"?Ee.attachments:void 0)),[p]),x=S.useMemo(()=>{let Ee=y;return m.map(De=>{const gn=Ee;return Ee=rm(Ee,De.attachments??[]),gn})},[m,y]),b=w!=null&&w.message?m.findIndex(Ee=>{var De;return Ee.text===((De=w.message)==null?void 0:De.text)}):-1,j=S.useRef(null);RD(j);const[N,T]=S.useState(null),R=S.useCallback(()=>{const Ee=(j.current&&Im(j.current))??"";T(De=>({seed:Ee||(De==null?void 0:De.seed)||"",seq:((De==null?void 0:De.seq)??0)+1}))},[]),$=S.useCallback(Ee=>!(Ee!=null&&Ee.closest("[data-pane]"))&&!l.getState().overlay,[l]);$_(gF,hk,R,$);const W=Ee=>{if(T(null),Ee){const De=window.getSelection();De==null||De.removeAllRanges(),De==null||De.addRange(Ee)}},A=gE(j,p);vt([f],()=>A.jump());const I=A.offStart&&A.moving==="up",_=A.offEnd&&(A.moving==="down"||A.away),P=Ee=>Ee.preventDefault(),z=(I||_)&&h.jsxs("div",{className:Ue("jump",A.away&&"jump-news"),children:[I&&h.jsx("button",{className:"jump-up",onMouseDown:P,onClick:A.start,"data-tip":"Jump to start",children:h.jsx(jt,{name:"caret-up",className:"icon-inline"})}),_&&h.jsxs("button",{className:"jump-down",onMouseDown:P,onClick:A.jump,"data-tip":"Jump to latest",children:[h.jsx(jt,{name:"caret",className:"icon-inline"}),A.away&&" new messages"]})]});S.useEffect(()=>{const Ee=j.current;if(!c||!A.offEnd||!Ee){u({a:"reading",on:!1});return}const De=()=>{Ee.scrollHeight-Ee.scrollTop-Ee.clientHeight<=wF||(u({a:"reading",on:!0}),Ee.removeEventListener("scroll",De))};return De(),Ee.addEventListener("scroll",De,{passive:!0}),()=>Ee.removeEventListener("scroll",De)},[c,A.offEnd,u]),S.useEffect(()=>()=>u({a:"reading",on:!1}),[u]);const q=Tt(f,"mark"),se=(q==null?void 0:q.by)==="walk"?q.at:void 0,Y=S.useRef(null),ge=()=>{const Ee=j.current,De=Ee==null?void 0:Ee.querySelector(':scope > [data-state~="cursor"]');if(!Ee||!De)return;const gn=parseFloat(getComputedStyle(Ee).paddingTop)||0;Ee.scrollTop+=De.getBoundingClientRect().top-Ee.getBoundingClientRect().top-gn,A.read()};vt([se],()=>{const Ee=j.current;if(Ee){if(se===void 0){const De=Y.current;if(Y.current=null,!De||!GS(_o(l.getState(),f).draft))return;De.bottom?A.jump():(Ee.scrollTop=De.top,A.read());return}Y.current??(Y.current={bottom:A.pinned(),top:Ee.scrollTop}),ge()}});const ke=Tt(f,"sent");vt([ke],()=>{ke&&A.jump()});const oe=(q==null?void 0:q.by)==="reveal"?q:void 0,L=S.useMemo(()=>oe?E6(p,oe.seq):-1,[p,oe]),re=se??(L>=0?L:void 0);vt([oe==null?void 0:oe.n,L],()=>{L>=0&&ge()});const te=S.useCallback((Ee,De)=>{f&&(De?en.post(f,{type:"highlight-selector",selector:Ee.selector,label:$g(Ee)}):en.post(f,{type:"highlight-clear"}))},[f]),K=!!e&&jc(e),B=Tt(f,"cardParked"),xe=S.useMemo(()=>{const Ee=tk(p);return!!Ee&&B!==Ee.id},[p,B]),de=e==null?void 0:e.worktree,we=(de==null?void 0:de.path)??(t==null?void 0:t.path)??(n==null?void 0:n.path),ee=S.useMemo(()=>we?[we]:[],[we]),J=S.useMemo(()=>h6(p,ee),[p,ee]),pe=S.useMemo(()=>K?m6(p):kF,[K,p]),$e=S.useMemo(()=>g6(J,pe),[J,pe]),le=$e.floating,ae=S.useRef([]),Fe=S.useMemo(()=>(ae.current=y6(ae.current,$e.flow),ae.current),[$e]),Qe=(e==null?void 0:e.agent)==="working",ze=Qe||(e==null?void 0:e.agent)==="waiting",Re=S.useMemo(()=>ze?b6(Fe):-1,[ze,Fe]),ct=Fe.at(-1),_n=Qe&&ct&&"item"in ct&&(ct.item.kind==="thinking"||ct.item.kind==="assistant")?Fe.length-1:-1,ht=(ut=J.findLast(Ee=>{var De;return"tools"in Ee&&((De=Ee.tools[0])==null?void 0:De.name)===ni}))==null?void 0:ut.at,tn=Tt(f,"chatAt"),Vt=Ja(K?tn:void 0),He=Tt(f,"usage"),nt=(He==null?void 0:He.heard)!==void 0&&tn!==void 0&&He.heard>tn?He.heard:void 0,an=Ja(K?nt:void 0),It=k6(p),X=le.length>0,fe=_n>=0||It||X,dt=S.useMemo(()=>$S(Fe),[Fe]),Ke=Tt(f,"running"),pn=Ee=>Ke&&Ee.tools.some(De=>De.id===Ke.id)?Ke.at:void 0,mn=e==null?void 0:e.worktree.path,Sn=(Ee,De)=>"spawn"in Ee?{kind:"tool",props:{tools:[Ee.spawn],run:Ee.run,roots:ee,worktreeId:f}}:"tools"in Ee?{kind:"tool",props:{tools:Ee.tools,next:Ee.next,live:De===Re||Ee.at===ht,since:pn(Ee),queued:dt.has(De),roots:ee,worktreeId:f,marked:Ee.at===re}}:Ee.item.kind==="thinking"?{kind:"thought",props:{item:Ee.item,open:De===Re,streaming:De===_n,worktreeId:f,fileRoot:mn}}:{kind:"item",props:{item:Ee.item,worktreeId:f,onPickHover:te,marked:Ee.at===re,streaming:Qe&&De===Fe.length-1}},Ct=S.useRef(new Map),Nn=pF(Ct.current,Fe,Sn,(Ee,De)=>De.kind==="tool"?h.jsx(ld,{...De.props},Ee.at):De.kind==="thought"?h.jsx(aF,{...De.props},Ee.at):h.jsx(uF,{...De.props},Ee.at));return Ct.current=Nn.cache,h.jsxs("div",{className:"chat-wrap",children:[h.jsxs("div",{className:"chat-log",ref:j,children:[r,Nn.rows,le.map(Ee=>{var De;return"spawn"in Ee?h.jsx(ld,{tools:[Ee.spawn],run:Ee.run,working:!0,since:tn,roots:ee,worktreeId:f},Ee.at):((De=Ee.tools[0])==null?void 0:De.name)===ni?h.jsx(ld,{tools:Ee.tools,live:Ee.at===ht,since:pn(Ee),roots:ee,worktreeId:f,marked:Ee.at===re},Ee.at):h.jsx(ld,{tools:Ee.tools,since:tn,roots:ee,worktreeId:f},Ee.at)}),f&&(w==null?void 0:w.message)&&h.jsxs("div",{className:"msg-user",children:[w.message.attachments&&h.jsx(Xb,{items:w.message.attachments,next:y,worktreeId:f,dir:(e==null?void 0:e.worktree.path)??null,onOpen:(Ee,De)=>tl(l,i,f,Ee,De)}),w.message.text]}),e&&(w||K&&!(e.agent==="waiting"&&xe)&&!It&&!X&&!(fe&&Vt<Yl))&&h.jsx("div",{className:"working-row",children:e.agent==="waiting"?"waiting for your answer…":fe?Vt>=Yl&&h.jsxs("span",{children:["quiet for",h.jsx("span",{className:"working-num",children:Ba(Vt)})]}):h.jsxs("span",{className:"working-mark",children:[h.jsx(el,{variant:"squares"}),nt!==void 0?an>=Yl&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"working-word",children:"thinking"}),h.jsx("span",{className:"working-num",children:Ba(an)})]}):Vt>=Yl&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"working-word",children:"waiting for the model"}),h.jsx("span",{className:"working-num",children:Ba(Vt)})]})]})}),f&&m.map((Ee,De)=>De===b?null:h.jsxs("div",{className:"msg-user queued-msg",children:[h.jsxs("span",{className:"queued-tag",children:[h.jsx(jt,{name:"clock",className:"icon-inline"}),h.jsx("span",{className:"queued-word",children:"queued"})]}),h.jsxs("div",{className:"queued-text",children:[Ee.attachments&&h.jsx(Xb,{items:Ee.attachments,next:x[De]??y,worktreeId:f,dir:(e==null?void 0:e.worktree.path)??null,onOpen:(gn,bn)=>tl(l,i,f,gn,bn)}),Ee.text]}),h.jsxs("span",{className:"queued-actions",children:[h.jsx(Ot,{icon:"edit",label:"Edit: removes from queue, puts it back in the input",onClick:()=>LE(l,i,f,De)}),h.jsx(Ot,{icon:"close",label:"Remove from queue",onClick:()=>i==null?void 0:i.send({t:"unqueue",worktreeId:f,index:De})})]})]},`q-${De}`)),o,g!==void 0&&h.jsxs("div",{className:"msg-user queued-msg",children:[h.jsxs("span",{className:"queued-tag",children:[h.jsx(jt,{name:"clock",className:"icon-inline"}),h.jsx("span",{className:"queued-word",children:n?"taking over":"restoring"})]}),g&&h.jsx("span",{className:"queued-text",children:g})]})]}),N&&h.jsx(I_,{root:j,body:j,seed:N.seed,seq:N.seq,onClose:W,onReveal:A.read}),z]})}function VS({hints:e,note:t,className:n=""}){return h.jsxs("div",{className:`key-hints ${n}`.trim(),children:[e.map(([r,o])=>h.jsxs("span",{className:"key-hint",children:[h.jsx(Wo,{k:r}),o]},r)),t&&h.jsx("span",{className:"key-note",children:t})]})}const yF={side:"top",align:"start",offset:4,alignOffset:-10,matchWidth:-20,flip:"side",margin:8};function vF({results:e,keyOf:t,row:n,rowClass:r,nav:o,listRef:i,empty:l,note:u}){return h.jsxs(Ss,{className:"inline-picker",anchor:"parent",placement:yF,children:[h.jsxs("div",{className:"picker-list",ref:i,children:[e.map((c,f)=>h.jsx("button",{className:Ue("picker-item",r==null?void 0:r(c)),"data-state":mr({cursor:f===o.index}),onMouseMove:()=>f!==o.index&&o.setIndex(f),onMouseDown:p=>p.preventDefault(),onClick:()=>o.pick(c),children:n(c,f===o.index)},t(c))),e.length===0&&h.jsx("div",{className:"empty",children:l})]}),h.jsx(VS,{hints:[["↑↓","moves"],["tab","inserts"],["esc","dismisses"]],note:u})]})}const Qb=e=>Math.max(0,Math.min(1,Number.isFinite(e)?e:0));function bF({fraction:e,level:t,className:n}){const o=2*Math.PI*5.5,i=Qb(e),l=S.useId(),u=3.5,c=2*u*Qb(t);return h.jsxs("svg",{className:Ue("ring",n),viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[t!==void 0&&h.jsxs(h.Fragment,{children:[h.jsx("clipPath",{id:l,children:h.jsx("circle",{cx:"7",cy:"7",r:u})}),h.jsx("rect",{className:"ring-level",clipPath:`url(#${l})`,x:"0",y:7+u-c,width:"14",height:c})]}),h.jsx("circle",{className:"ring-track",cx:"7",cy:"7",r:5.5}),h.jsx("circle",{className:"ring-fill",cx:"7",cy:"7",r:5.5,strokeDasharray:`${o*i} ${o}`})]})}function xF(e,t=cc.folder.shared){return`New project: ${e}. The repository is empty apart from a root commit. Pick the mainstream stack for what the message describes, and say which in your first sentence; if the message names a stack, that wins. Scaffold it in this directory, write its .gitignore before installing anything, make it start on $PORT, and write ${t}.`}const ts="";function EF(e){var f;const t=SF(e.name);if(t){const p=[t.qualifier,e.description||e.name].filter(Boolean).join(" · ");return{label:t.label,version:t.version,description:p}}const n=e.name.match(/^([A-Za-z]+)-(\d+(?:\.\d+)*)(?:-([A-Z][a-z]+))?$/);if(n!=null&&n[1]&&n[2])return{label:n[3]??n[1],version:n[2],...e.description?{description:e.description}:{}};const[r="",...o]=(e.description??"").split(" · "),i=e.name.replace(/\s*\([^)]*\)$/,""),l=r.match(/^(.+?) (\d+(?:\.\d+)*)(?: with (.+))?$/);if(!(l!=null&&l[2])||l[1]!==i)return{label:e.name,...e.description?{description:e.description}:{}};const c=[l[3]??((f=e.name.match(/\(([^)]*)\)$/))==null?void 0:f[1]),...o].filter(Boolean).join(" · ");return{label:i,version:l[2],...c?{description:c}:{}}}const _F=/(?:^|[./])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 SF(e){const t=e.match(_F),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 YS(e,t,n,r){const o=Tx(e),i=wj(e),l=y=>i&&y===(o==null?void 0:o.id)?i.id:y,u=l(t||n||(o==null?void 0:o.id)||ts),c=l(t||(o==null?void 0:o.id)||ts),f=i?e.filter(y=>y!==o):e,p=f.some(y=>y.id===u),m=f.map(y=>({c:y,words:EF(y)})),g=y=>[y.label,y.version].filter(Boolean).join(" "),w=[...o?[]:[{id:ts,label:r.label,description:r.description}],...m.map(({c:y,words:x})=>{const b=m.filter(N=>g(N.words)===g(x)).length===1?x:void 0,j=b?b.description:y.description;return{id:y.id,label:b?b.label:y.name,...b!=null&&b.version?{suffix:b.version}:{},...b!=null&&b.version&&m.some(N=>N.c!==y&&N.words.label===b.label)?{chip:g(b)}:{},description:y===i?["recommended",j].filter(Boolean).join(" · "):j}}),...u&&!p?[{id:u,label:u}]:[]];if(u!==c){const y=w.find(j=>j.id===u),x=w.findIndex(j=>j.id===c),b=w[x];if(b){const j=(y==null?void 0:y.chip)??(y==null?void 0:y.label)??u;w[x]={...b,description:[`${j} now`,b.description].filter(Boolean).join(" · ")}}}return{rows:w,shown:u,picked:c}}const Kl=(e,t)=>`${e} ${t}`;function NF(e){const t=e.indexOf(" ");return t<0?{agent:e,model:ts}:{agent:e.slice(0,t),model:e.slice(t+1)}}function TF(e,t,n){const r=e.length>1;let o=Kl(t,n);return{rows:e.flatMap(l=>{var p;const u=l.short??l.name,c=l.id===t;if(!l.available||!((p=l.models)!=null&&p.length))return c&&(o=Kl(l.id,ts)),[{id:Kl(l.id,ts),label:u,description:l.available?"its own default model; the rest are listed once it has run":l.reason??"not installed",disabled:!l.available}];const f=YS(l.models,c?n:ts,void 0,{label:`${u} default`,description:`whatever ${l.name} runs when nothing is asked for`});return c&&(o=Kl(l.id,f.shown)),f.rows.map(m=>({...m,id:Kl(l.id,m.id),...r&&m.id!==ts?{prefix:u}:{}}))}),shown:o}}function Pc({anchored:e=!1,...t}){return e?h.jsx(jF,{...t,anchored:e===!0?{}:e}):h.jsx(CF,{...t})}function jF({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,anchored:o,coverBy:i,id:l,children:u}){const{onKey:c,back:f}=XS(t);return h.jsx(Ss,{className:Ue(r?"":"overlay-box","anchored",n),id:l,anchor:"parent",placement:{side:"bottom",align:"start",cover:!0,margin:0,...o},coverBy:i,onDismiss:e?()=>e():void 0,onKey:c,onBack:()=>f()||(e==null?void 0:e()),children:u})}function CF({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,id:o,children:i}){const{onKey:l,back:u}=XS(t);return h.jsx(Ss,{className:"overlay scrim",id:o,onDismiss:e?()=>e():void 0,onKey:l,onBack:()=>u()||(e==null?void 0:e()),onClick:c=>{e&&c.target===c.currentTarget&&e()},children:h.jsx("div",{className:Ue(r?"":"overlay-box",n),children:i})})}function XS(e){const t=Zn(),n=()=>{if(e)return e(),!0;const o=t.getState();return!o.overlay||o.choosingFolder?!1:(t.dispatch({a:"close",back:nE(o.overlay)}),!0)};return{onKey:o=>{o.key==="Escape"&&n()&&o.stopPropagation()},back:n}}function AF({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(h.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 Rr({items:e,filter:t,keyOf:n,row:r,rowClass:o,rowTitle:i,onPick:l,onBack:u,onActive:c,onSide:f,onTab:p,onQuery:m,completionOf:g,narrowTo:w,placeholder:y,initialQuery:x="",initialIndex:b,selectOnMount:j=!1,idleWhen:N,onIdlePick:T,anchored:R=!1,onEscape:$,lead:W,trailing:A,empty:I="no matches",footer:_,keys:P,rowMenu:z,groupOf:q,groupHead:se,headAlone:Y=!1}){const ge=fn("picker"),[ke,oe]=S.useState(x),L=S.useMemo(()=>t(e,ke),[e,ke,t]),re=S.useRef(null),te=Ki(),K=pE(j,!te);S.useEffect(()=>{if(!m)return;const ae=setTimeout(()=>m(ke),150);return()=>clearTimeout(ae)},[ke,m]);const B=JE({results:L,keyOf:n,q:ke,onPick:l,listRef:re,onActive:c,onSide:f,completionOf:g,narrowTo:w,setQ:oe,initialIndex:b,idle:(N==null?void 0:N(x))??!1,onIdlePick:T}),{index:xe,ghost:de}=B,we=typeof P=="function"?P(B.active,ke):P,ee=[];we!=null&&we.nav&&ee.push(["↑↓",we.nav]),we!=null&&we.side&&f&&ee.push(["←→",we.side]),we!=null&&we.complete&&(de!=null&&de.accept)&&ee.push(["tab",we.complete]),we!=null&&we.tab&&p&&ee.push(["tab",we.tab]),we!=null&&we.pick&&ee.push(["enter",we.pick]),we!=null&&we.back&&ee.push(["esc",we.back]);const J=h.jsxs("div",{className:"picker-input",onMouseDown:ae=>{var Fe;ae.target.closest("input")||(ae.preventDefault(),(Fe=K.current)==null||Fe.focus())},children:[W,h.jsxs("div",{className:"picker-caret",children:[h.jsx(Eo,{font:"mono",bare:!0,ref:K,value:ke,onChange:ae=>{oe(ae.target.value),B.setIndex(N!=null&&N(ae.target.value)?-1:0)},onKeyDown:ae=>{var Fe;if(z&&B.active&&(ae.key==="ContextMenu"||ae.key==="F10"&&ae.shiftKey)){const Qe=(Fe=re.current)==null?void 0:Fe.querySelector('[data-state~="cursor"]');if(Qe){ae.preventDefault(),ae.stopPropagation(),to.open({items:z(B.active),owner:"picker",target:Qe,anchor:Qe.getBoundingClientRect()});return}}B.onKeyDown(ae)||!p||ae.key!=="Tab"||ae.shiftKey||(ae.preventDefault(),p())},placeholder:y}),de&&h.jsxs("div",{className:"picker-ghost","aria-hidden":"true",children:[h.jsx("span",{className:"picker-typed",children:ke}),AF(de)]})]}),A]}),pe=new Map;if(q)for(const ae of L)pe.set(q(ae),(pe.get(q(ae))??0)+1);const $e=h.jsxs("div",{className:"picker-list",ref:re,children:[L.map((ae,Fe)=>{const Qe=q==null?void 0:q(ae),ze=Qe!==void 0&&(Y||pe.size>1)&&(Fe===0||(q==null?void 0:q(L[Fe-1]))!==Qe)?h.jsx("div",{className:"picker-group",children:(se==null?void 0:se(Qe,pe.get(Qe)??0))??Qe}):null;return h.jsxs(S.Fragment,{children:[ze,h.jsx("button",{className:Ue("picker-item",o==null?void 0:o(ae)),"data-state":mr({cursor:Fe===xe}),title:i==null?void 0:i(ae),onMouseMove:()=>Fe!==xe&&B.setIndex(Fe),onClick:()=>{var Re;B.pick(ae),(Re=K.current)==null||Re.focus()},...ge.contextMenu(()=>(z==null?void 0:z(ae))??[]),children:r(ae,Fe===xe,ke)})]},n(ae))}),L.length===0&&h.jsx("div",{className:"empty",children:typeof I=="function"?I(ke):I}),_==null?void 0:_(ke,L)]}),le=ee.length>0&&h.jsx(VS,{hints:ee});return h.jsxs(Pc,{onClose:u,onEscape:$,boxClass:"picker",anchored:R,coverBy:W?".picker-input > *:first-child":A?".picker-input > *:last-child":void 0,children:[J,$e,le]})}function ei({value:e,reads:t,options:n,onChange:r,placeholder:o,hint:i,className:l,onClose:u}){const[c,f]=S.useState(!1),p=()=>{f(!1),u==null||u()},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 h.jsxs("span",{className:"chip-picker",children:[h.jsx(Le,{variant:"ghost",tone:"chrome",mono:!0,on:c,className:Ue("chip-picker-btn",l),...Dt(i),onClick:()=>c?p():f(!0),children:w}),c&&h.jsx(Rr,{anchored:{flip:"both",margin:8},onEscape:p,items:n,filter:(y,x)=>{const b=x.trim().toLowerCase().split(/\s+/).filter(Boolean);return y.filter(j=>{const N=`${j.prefix??""} ${j.label??j.id} ${j.suffix??""} ${j.id}`.toLowerCase();return b.every(T=>N.includes(T))})},keyOf:y=>y.id,initialIndex:y=>Math.max(0,y.findIndex(x=>x.id===e)),lead:h.jsx(Le,{tone:"chrome",mono:!0,on:!0,className:"chip-picker-lead",onClick:p,children:w}),placeholder:o,rowClass:()=>"picker-row",row:y=>h.jsxs(h.Fragment,{children:[y.id===e&&h.jsx("span",{className:"row-current","aria-hidden":"true"}),h.jsxs("span",{className:Ue("chip-option",y.disabled&&"chip-option-off"),"aria-disabled":y.disabled,children:[h.jsxs("span",{className:"chip-option-name",children:[y.prefix?`${y.prefix} `:null,y.label??y.id,y.suffix?h.jsx("span",{className:"chip-option-suffix",children:` ${y.suffix}`}):null]}),y.description&&h.jsx("span",{className:"chip-option-desc row-dim",children:y.description})]})]}),onPick:y=>{y.disabled||(r(y.id),p())},onBack:p})]})}function QS({choices:e,value:t,current:n,what:r,defaultLabel:o,defaultDescription:i,placeholder:l,className:u,onChange:c,onClose:f}){const{rows:p,shown:m,picked:g}=S.useMemo(()=>YS(e,t,n,{label:o,description:i}),[e,t,n,o,i]);if(e.length===0)return null;const w=p.find(x=>x.id===m),y=(w==null?void 0:w.chip)??(w==null?void 0:w.label)??m;return h.jsx(ei,{value:g,reads:m,options:p,onChange:c,onClose:f,className:u,hint:t?`asked for ${y}; click to change`:`${y}, the agent's choice; click to pick ${r}`,placeholder:l})}function IF(e){const[t,n]=bo(Ye.effortPrefix+(e??""),ts,r=>r??"",oo().storage);return[t,n]}function Jb({efforts:e,value:t,current:n,onChange:r,onClose:o}){return h.jsx(QS,{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 RF(e){const[t,n]=bo(Ye.modePrefix+((e==null?void 0:e.id)??""),xd,r=>Sc.some(o=>o.id===r)?r:xd,oo().storage);return[t,n]}const $F=e=>{var t;return((t=Sc.find(n=>n.id===e))==null?void 0:t.description)??""};function ex({value:e,onChange:t,onClose:n}){return h.jsx(ei,{value:e,options:Sc.map(r=>({id:r.id,label:r.name,description:r.description})),onChange:t,onClose:n,className:Ue("mode-chip",e!=="auto"&&"mode-held"),hint:`${e}: ${$F(e)}. Click to change`,placeholder:"what the agent may do without asking"})}function OF(e){const[t,n]=bo(Ye.modelPrefix+(e??""),ts,r=>r??"",oo().storage);return[t,n]}function MF(e,t,n){e.set(Ye.modelPrefix+t,n)}function tx({models:e,value:t,current:n,onChange:r,onClose:o}){return h.jsx(QS,{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 LF({agents:e,agent:t,model:n,onChange:r,onClose:o}){const{rows:i,shown:l}=S.useMemo(()=>TF(e,t,n),[e,t,n]);if(i.length===0)return null;const u=i.find(f=>f.id===l),c=u?[u.prefix,u.label,u.suffix].filter(Boolean).join(" "):n;return h.jsx(ei,{value:l,options:i,onChange:f=>{const p=NF(f);r(p.agent,p.model)},onClose:o,className:"model-chip",hint:`${c} works on the new worktree; click to change`,placeholder:"which agent and model work on it"})}function JS(e){const t=Af(e),[n,r]=bo(Ye.profilePrefix+((e==null?void 0:e.id)??""),(e==null?void 0:e.config.defaultProfile)??"",i=>i??void 0,oo().storage);return[t.length===0?void 0:t.includes(n)?n:e==null?void 0:e.config.defaultProfile,r]}function PF({repo:e,value:t,onChange:n,onClose:r}){const o=Af(e);if(o.length===0||!t)return null;const i=(e==null?void 0:e.config.profiles)??{},l=(e==null?void 0:e.configFile)??"the settings",u=c=>{var m;const f=((m=i[c])==null?void 0:m.run)??[],p=f.length>0?`runs ${f.join(", ")}`:"runs nothing";return c===(e==null?void 0:e.config.defaultProfile)?`${p}; the default in ${l}`:p};return h.jsx(ei,{value:t,options:o.map(c=>({id:c,description:u(c)})),onChange:n,onClose:r,hint:o.length>1?`${t}: ${u(t)}. Click to change`:`the only profile in ${l}`,placeholder:"the profile the worktree runs"})}function bc(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(h.jsx("b",{className:"hit",children:e[l]},l))):i+=e[l];return i&&o.push(i),o}function DF({c:e,query:t}){const n=t.trim();return h.jsxs(h.Fragment,{children:[h.jsxs("span",{className:"picker-name",children:["/",bc(e.name,n?Pk(e.name,n):null,0)]}),h.jsx("span",{className:"picker-desc row-dim",children:e.description})]})}function Hn({label:e,hint:t,current:n=!1}){return h.jsxs(h.Fragment,{children:[n&&h.jsx("span",{className:"row-current","aria-hidden":"true"}),h.jsx("span",{className:"picker-label",children:e}),t?h.jsx("span",{className:"picker-hint row-dim",children:t}):null]})}function zF(e,t,{sock:n}){return[{id:`forget-visit:${t}`,label:"remove from this list",onClick:()=>n==null?void 0:n.send({t:"forget-visit",repoId:e,path:t})}]}const FF=/ \| | - | \u2013 | \u2014 | \u00b7 |: /,BF=/^(\d+|[0-9a-f]{8}-[0-9a-f-]{27}|[0-9a-f]{12,})$/i,UF=/^[[:$*{]|\[/;function HF(e){const t=new Map,n=e.filter(i=>!!i.title);if(new Set(n.map(i=>i.path)).size<2)return t;const r=n.map(i=>({path:i.path,parts:i.title.split(FF).map(l=>l.trim()).filter(Boolean)})),o=new Map;for(const{path:i,parts:l}of r)for(const u of l)o.set(u,(o.get(u)??new Set).add(i));for(const{path:i,parts:l}of r){const u=l.filter(c=>{var f;return(((f=o.get(c))==null?void 0:f.size)??0)<2});u.length>0&&t.set(i,u.join(" "))}return t}function Fk(e){const t=e.split(/[/#]/).filter(Boolean);for(let n=t.length-1;n>=0;n--){let r=t[n];try{r=decodeURIComponent(r)}catch{}if(BF.test(r)||UF.test(r))continue;const o=r.replace(/[-_.]+/g," ").trim();if(o)return o[0].toUpperCase()+o.slice(1)}return"Home"}const Zp=8,KF=3,WF=50,ZF=3;function qF(e,t,n=[]){const r=new Map,o=[],i=new Map;for(const l of(t==null?void 0:t.routes)??[]){if(l.endpoint)continue;const u=l.dynamic?a2(l.path):null;u?(o.push(u),i.set(l.path,l)):r.set(l.path,l)}return{history:e,statics:r,templates:o,templateRoutes:i,unseen:(t==null?void 0:t.unseen)??{},titles:HF(e),links:new Map(n.map(l=>[l.path,l.text]))}}function eN(e){if(!e)return"/";try{const t=new URL(e);return t.pathname+t.search+t.hash}catch{return"/"}}function GF(e){const t=e.trim();return/^[/?#]/.test(t)?t:`/${t}`}function VF(e,t){const n=/^[/?#]/.test(t)?e:e.replace(/^\//,"");return t&&n.toLowerCase().startsWith(t.toLowerCase())?n:null}const tN=e=>/^\[\[?\.\.\.|^\*$|^\$$/.test(e),Xl=e=>tN(e)||/[[:$*{]/.test(e)&&!/^[^[{:$*]+\?$/.test(e),YF=e=>ff(`/${e}`).text.slice(1),Bk=e=>e.split("/").filter(Boolean);function Uk(e,t){const n=t.startsWith("/"),r=t.replace(/^\//,"").split("/"),o=Bk(e);let i="";const l=[],u=m=>{const g=YF(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(tN(w))return{show:t,accept:t};if(Xl(w)){if(!g)return null}else if(g.toLowerCase()!==w.toLowerCase())return null;i+=`${Xl(w)?g:w}/`;continue}if(Xl(w))g?i+=g:u(w);else{if(!w.toLowerCase().startsWith(g.toLowerCase()))return null;i+=w}}for(const m of o.slice(r.length))i+="/",Xl(m)?u(m):i+=m;const c=n?1:0,f=(n?"/":"")+i,p=l[0];return{show:f,accept:p?f.slice(0,p[0]+c):f,params:l.map(([m,g])=>[m+c,g+c])}}function XF(e,t){const n=Uk(e,t);return n?n.accept.length>t.length?n.accept:t:ff(e).literal}function nN(e,t){if(e.kind==="go")return null;if(e.template){const n=Uk(e.path,t);return n&&n.show.length>t.length?n:null}return VF(e.path,t)}const QF=e=>e.trim().replace(/^\//,"").toLowerCase();function rN(e,t){for(let n=0;n<e.length;n++)if("/-_.#".includes(e[n])&&e.startsWith(t,n+1))return!0;return!1}function JF(e,t,n){const r=e.replace(/^\//,"").toLowerCase(),o=t.toLowerCase();return r===n?100:r.startsWith(n)?80:rN(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 e8(e,t){const{text:n,literal:r}=ff(e);return r.replace(/^\//,"").toLowerCase().startsWith(t)?80:Uk(e,t)?70:rN(n.replace(/^\//,"").toLowerCase(),t)?60:0}function t8(e,t){const n=Bk(e).findIndex(Xl);return n>=0&&t.split("/").length>n}function oc(e,t,n){var u;const r=e.statics.get(t),o=r?null:l2(e.templates,t),i=(r==null?void 0:r.file)??(o?(u=e.templateRoutes.get(o.path))==null?void 0:u.file:void 0),l=i?e.unseen[i]:void 0;return{kind:"page",path:t,title:e.titles.get(t)||e.links.get(t)||Fk(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 oN(e,t){const n=e.unseen[t.file];return{kind:"page",path:t.path,title:Fk(t.path),template:!0,visited:!1,file:t.file,...n?{badge:n}:{},rank:Number.POSITIVE_INFINITY,group:t.path,score:0}}function vd({rank:e,group:t,score:n,...r}){return r}const Zd=e=>Bk(e).length,qd=e=>e.badge==="new"?0:e.badge==="changed"?1:2;function n8(e,t){const n=new Set,r=[];e.history.forEach((p,m)=>{if(p.path===t)return;const g=oc(e,p.path,m);n.has(g.group)||(n.add(g.group),r.push(g))});const o=new Set(r.map(p=>p.path)),i=r.filter(p=>p.badge);for(const[p,m]of e.statics)e.unseen[m.file]&&p!==t&&!o.has(p)&&i.push(oc(e,p,Number.POSITIVE_INFINITY));for(const p of e.templateRoutes.values())e.unseen[p.file]&&!n.has(p.path)&&i.push(oN(e,p));i.sort((p,m)=>qd(p)-qd(m)||p.rank-m.rank);const l=r.filter(p=>!p.badge),u=i.slice(0,Zp-Math.min(KF,l.length));for(const p of l)u.length<Zp&&u.push(p);const c=new Set(u.map(p=>p.path)),f=[...e.statics.keys(),...[...e.links.keys()].filter(p=>!e.statics.has(p))].filter(p=>p!==t&&!c.has(p)&&!o.has(p)).sort((p,m)=>Zd(p)-Zd(m)||(p<m?-1:p>m?1:0));for(const p of f){if(u.length>=Zp)break;u.push(oc(e,p,Number.POSITIVE_INFINITY))}return u.map(vd)}function r8(e,t,n){const r=QF(t),o=GF(t),i=new Map;e.history.forEach((w,y)=>{w.path!==n&&i.set(w.path,oc(e,w.path,y))});for(const w of[...e.statics.keys(),...e.links.keys()])w!==n&&!i.has(w)&&i.set(w,oc(e,w,Number.POSITIVE_INFINITY));const l=[];for(const w of i.values()){const y=JF(w.path,w.title,r);y>0&&l.push({...w,score:y})}let u=null;for(const w of e.templates){const y=e.templateRoutes.get(w.path);if(!u&&!e.statics.has(o)&&w.re.test(o)){u=y;continue}const x=e8(w.path,r);x>=60&&l.push({...oN(e,y),score:x})}l.sort((w,y)=>y.score-w.score||w.rank-y.rank||qd(w)-qd(y)||Zd(w.path)-Zd(y.path)||(w.path<y.path?-1:w.path>y.path?1:0));const c=new Map,f=[];for(const w of l){if(!w.template&&w.group!==w.path){const y=c.get(w.group)??0;if(y>=ZF&&!t8(w.group,r))continue;c.set(w.group,y+1)}if(f.push(w),f.length>=WF)break}if(f.some(w=>w.score===100))return f.map(vd);const p={kind:"go",path:o,title:Fk((u==null?void 0:u.path)??o)},m=f[0];return!u&&m!==void 0&&m.score>=80&&o8(m.path,r)?[...f.map(vd),p]:[p,...f.map(vd)]}function o8(e,t){const n=e.replace(/^\//,"").toLowerCase().slice(t.length);return!t.endsWith("/")&&n.length>0&&!/^[/?#]/.test(n)}function sN(e,{query:t,current:n,here:r}){return t===n||t.trim()===""?n8(e,r):r8(e,t,r)}const s8=[],i8=[];function iN(e,t){const n=M(i=>(t?i.visits[t]:void 0)??s8),r=Tt(e,"pages"),o=Tt(e,"links");return vt([e],()=>{q1(r)&&en.post(e,{type:"links"})}),S.useMemo(()=>qF(n,r,o),[n,r,o])}function a8({row:e}){if(e.kind!=="page"||!e.template)return h.jsx("span",{className:"bar-route-path row-dim",children:e.path});const{text:t,params:n}=ff(e.path),r=[];let o=0;for(const[i,l]of n)i>o&&r.push(t.slice(o,i)),r.push(h.jsx("span",{className:"bar-route-param",children:t.slice(i,l)},i)),o=l;return o<t.length&&r.push(t.slice(o)),h.jsx("span",{className:"bar-route-path row-dim",children:r})}function aN({row:e}){return h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"picker-label",children:e.title}),h.jsx(a8,{row:e}),e.kind==="go"?h.jsx("span",{className:"picker-hint row-dim",children:"as typed"}):e.badge?h.jsx("span",{className:e.badge==="new"?"badge-new":"badge-changed",children:e.badge}):null]})}const lN=e=>e.kind==="page"&&e.file?e.file:e.path,cN=(e,t)=>e.kind==="page"&&e.template?XF(e.path,t):null,uN=e=>e.kind==="page"&&e.template?"fills in the parameter":"goes there";function dN(e,t,n){return e.kind!=="page"?[]:xf([...e.file&&t.dir?ys({id:t.worktreeId,dir:t.dir},e.file,{},n):[],TE,...e.visited?zF(t.repoId,e.path,n):[]])}function l8({worktreeId:e,repoId:t,url:n}){const r=at(),o=lt(),i=M(g=>{const w=dn(g,e);return w?w.worktree.path:null}),l=iN(e,t),u=eN(n),c=n?df(n):null,f=S.useCallback((g,w)=>sN(l,{query:w,current:u,here:c}),[l,u,c]),p=S.useCallback(g=>g===u||g.trim()==="",[u]),m=()=>r({a:"close"});return h.jsx(Rr,{anchored:{matchWidth:0},items:i8,filter:f,initialQuery:u,selectOnMount:!0,idleWhen:p,onIdlePick:()=>{en.post(e,{type:"reload"}),m()},keyOf:g=>`${g.kind}:${g.path}`,rowClass:()=>"picker-row",rowTitle:lN,completionOf:(g,w)=>p(w)?null:nN(g,w),narrowTo:cN,onPick:g=>{en.post(e,{type:"navigate",path:g.path}),m()},onBack:m,rowMenu:g=>dN(g,{worktreeId:e,repoId:t,dir:i},{sock:o,dispatch:r}),placeholder:"type a path",keys:g=>({complete:"completes the path",pick:g?uN(g):"reloads",back:"closes"}),empty:"no pages yet; type a path",row:g=>h.jsx(aN,{row:g})})}function fN(e,t){const n=t.trim();return h.jsx(Hn,{label:bc(e.label,n?Pk(e.label,n):null,0),hint:e.hint&&h.jsx(Wo,{k:e.hint})})}function hN({anchored:e,trailing:t}){const n=at(),r=DS(),o=M(i=>{var l;return((l=i.paletteReturn)==null?void 0:l.mode)==="commands"?i.paletteReturn.q:""});return h.jsx(Rr,{anchored:e,trailing:t,items:r,filter:zS,rowClass:()=>"picker-row",keyOf:i=>i.id,onPick:(i,l)=>{i.sub?n({a:"palette-return",v:{mode:"commands",q:l}}):n({a:"close"}),i.run()},onBack:()=>n({a:"close"}),placeholder:"run a command…",keys:{pick:"runs",back:"closes"},initialQuery:o,empty:"no matching command",row:(i,l,u)=>fN(i,u)})}function pN(e,t){const n=new Map(t.map(l=>[l.path,l])),r=t.filter(l=>l.xy==="??"&&l.path.endsWith("/")).map(l=>l.path),o=e.map(l=>{const u=n.get(l)??(r.some(c=>l.startsWith(c))?{path:l,xy:"??"}:void 0);return u?{path:l,status:u}:{path:l}}),i=new Set(e);for(const l of t)!i.has(l.path)&&!l.path.endsWith("/")&&o.push({path:l.path,status:l});return o}function nx(e,t){const n=e.split("/"),r=t.split("/");for(let o=0;;o++){const i=n[o],l=r[o];if(i===void 0||l===void 0)return n.length-r.length;const u=o===n.length-1,c=o===r.length-1;if(u!==c)return u?-1:1;if(i!==l)return i<l?-1:1}}function mN(e,t,n,r=50){const o=pN(e,t),i=n.trim().toLowerCase();if(!i){const u=new Map(t.map((m,g)=>[m.path,g])),c=m=>{var g;return u.get(((g=m.status)==null?void 0:g.path)??"")??u.get(m.path)??Number.MAX_SAFE_INTEGER},f=o.filter(m=>m.status).sort((m,g)=>c(m)-c(g)||nx(m.path,g.path)),p=o.filter(m=>!m.status).sort((m,g)=>nx(m.path,g.path));return{rows:[...f,...p].slice(0,r),changed:Math.min(f.length,r)}}const l=kN(o,i);return l.sort((u,c)=>c.score-u.score||u.row.path.localeCompare(c.row.path)),{rows:l.slice(0,r).map(u=>u.row),changed:0}}function gN(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 kN(e,t){const n=[];for(const r of e){const o=gN(r.path,t);o>0&&n.push({row:r,score:r.status?o+4:o})}return n}function c8(e,t,n,r,o){const i=r.trim().toLowerCase();if(!i)return mN(e,n,r,o).rows.map(c=>({kind:"file",path:c.path,status:c.status}));const l=kN(pN(e,n),i).map(({row:c,score:f})=>({row:{kind:"file",path:c.path,status:c.status},score:f}));for(const c of t){const f=gN(c,i);f>0&&l.push({row:{kind:"folder",path:c},score:f})}const u=c=>c.kind==="folder"?1:0;return l.sort((c,f)=>f.score-c.score||u(c.row)-u(f.row)||c.row.path.localeCompare(f.row.path)),l.slice(0,o).map(c=>c.row)}function u8(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 d8(e){const t=e.lastIndexOf("/");return t===-1?[e,""]:[e.slice(t+1),e.slice(0,t+1)]}const ox=[],f8=[],h8=[];function p8({worktreeId:e}){var x;const t=at(),n=lt(),r=Zn();vt([e,n],()=>_f(e,r.getState(),{sock:n,dispatch:t}));const o=xE(e),i=o.files??f8,l=((x=o.git)==null?void 0:x.files)??h8,u=DS(),c=M(b=>{var j;return((j=b.paletteReturn)==null?void 0:j.mode)==="quick-open"?b.paletteReturn.q:""}),f=M(b=>{var N;const j=(N=dn(b,e))==null?void 0:N.worktree;return j?j.path:null}),p=M(b=>{var j;return((j=dn(b,e))==null?void 0:j.repoId)??null}),m=M(b=>{var j;return((j=Md(b))==null?void 0:j.worktreeId)===e}),g=iN(e,p),w=o.page.url?df(o.page.url):null,y=S.useCallback((b,j)=>j.startsWith(">")?zS(u,j.slice(1)).map(N=>({kind:"cmd",c:N})):j.startsWith("/")?m?sN(g,{query:j,current:"/",here:w}).map(N=>({kind:"page",page:N})):ox:mN(i,l,j).rows.map(N=>({kind:"file",path:N.path,status:N.status})),[u,i,l,m,g,w]);return h.jsx(Rr,{items:ox,filter:y,keyOf:b=>b.kind==="cmd"?`c:${b.c.id}`:b.kind==="page"?`p:${b.page.kind}:${b.page.path}`:`f:${b.path}`,rowClass:b=>b.kind==="file"?"qo-file":"picker-row",rowTitle:b=>b.kind==="page"?lN(b.page):void 0,completionOf:(b,j)=>b.kind==="page"?nN(b.page,j):null,narrowTo:(b,j)=>b.kind==="page"?cN(b.page,j):null,onPick:(b,j)=>{b.kind==="cmd"?(b.c.sub?t({a:"palette-return",v:{mode:"quick-open",q:j}}):t({a:"close"}),b.c.run()):b.kind==="page"?(en.post(e,{type:"navigate",path:b.page.path}),t({a:"close"})):(er({dispatch:t},{worktreeId:e,path:b.path,view:Fi(b.path)}),t({a:"close"}))},onBack:()=>t({a:"close"}),rowMenu:b=>b.kind==="file"&&f?ys({id:e,dir:f},b.path,{},{sock:n,dispatch:t}):b.kind==="page"&&p?dN(b.page,{worktreeId:e,repoId:p,dir:f},{sock:n,dispatch:t}):[],placeholder:"jump to file · type > for commands, / for pages",keys:(b,j)=>j.startsWith("/")?{complete:"completes the path",pick:(b==null?void 0:b.kind)==="page"?uN(b.page):void 0,back:"closes"}:{pick:"opens",back:"closes"},initialQuery:c,empty:b=>b.startsWith(">")?"no matching command":b.startsWith("/")?m?"no pages yet; type a path":"no preview running":"no matches",row:(b,j,N)=>b.kind==="cmd"?fN(b.c,N.slice(1)):b.kind==="page"?h.jsx(aN,{row:b.page}):Km(b.path,b.status,N,{gutter:l.length>0})})}function Km(e,t,n,{folder:r=!1,gutter:o=!0}={}){const[i,l]=d8(e),u=n.trim()?u8(e,n.trim()):null;return h.jsxs(h.Fragment,{children:[o&&h.jsx("span",{className:`xy ${t?Ig(t.xy):""}`,children:t?Rg(t.xy):""}),h.jsxs("span",{className:"name",children:[bc(i,u,l.length),r&&"/"]}),h.jsx("span",{className:"dir row-dim",children:l&&h.jsxs(h.Fragment,{children:["",bc(l,u,0),""]})}),t&&h.jsx(b_,{f:t})]})}function Wl({icon:e,verb:t,tip:n,onPress:r,onDismiss:o,children:i}){return h.jsxs("div",{className:"composer-offer",children:[h.jsx(jt,{name:e,className:"icon-inline"}),h.jsxs("span",{className:"composer-offer-line",children:[h.jsx(Le,{variant:"inline",tone:"strong","data-tip":n,onClick:r,children:t})," ",i]}),o&&h.jsx(Ot,{icon:"close",tone:"quiet",className:"composer-offer-close",label:"Not this one",onClick:o})]})}function wN({item:e,n:t,onRemove:n}){const r=$r();return e.kind==="image"?h.jsx(Ok,{src:e.local??r.upload(e.upload),n:t,name:e.name,width:e.width,height:e.height,bytes:e.bytes,uploading:e.uploading,onRemove:n}):e.kind==="file"?h.jsx(Ik,{name:e.name,bytes:e.bytes,href:e.text&&e.upload?r.upload(e.upload):void 0,uploading:e.uploading,onRemove:n}):h.jsx(Ak,{n:t,name:e.name,source:e.source,lines:e.lines,chars:e.chars,preview:e.preview,text:e.text,onRemove:n})}function Gd({rows:e,cursor:t,onCursor:n,onPick:r,hover:o=!1}){const i=Ki(),l=u=>{var c;u.target instanceof HTMLTextAreaElement||(u.preventDefault(),(c=u.currentTarget.querySelector("textarea"))==null||c.focus())};return h.jsx("div",{className:Ue("choices",o&&"choices-hover",i&&"choices-touch"),children:e.map((u,c)=>{const f=!i&&t===c,p=mr({cursor:f,checked:u.checked}),m=u.tone==="deny"&&"choice-deny",g=()=>n&&t!==c&&n(c),w=h.jsxs(h.Fragment,{children:[!i&&h.jsx(Wo,{k:String(c+1),className:"choice-num row-dim"}),h.jsx("span",{className:"choice-label",children:u.label}),!i&&u.hint&&h.jsxs("span",{className:Ue("choice-hint row-dim",f&&u.hint.on!==!1&&"on"),children:[h.jsx(Wo,{k:u.hint.k})," ",u.hint.label]}),u.description&&h.jsx("span",{className:"choice-desc",children:u.description})]});return u.field?h.jsxs("div",{className:Ue("picker-item choice row-edge",m),"data-state":p,onMouseMove:g,onMouseDown:l,children:[w,h.jsx(kc,{ref:u.field.ref,bare:!0,font:"ui",rows:1,className:"choice-field",enterKeyHint:u.field.enterKeyHint,placeholder:u.field.placeholder,value:u.field.value,onChange:y=>{var x;return(x=u.field)==null?void 0:x.onChange(y.target.value)}})]},c):h.jsx("button",{type:"button",className:Ue("picker-item choice row-edge",m),"data-state":p,disabled:u.disabled,onMouseMove:g,onClick:()=>r(c),children:w},c)})})}function m8(e){return bd(e.key)&&(e.metaKey||e.ctrlKey)&&!e.altKey?!1:e.metaKey||e.ctrlKey||e.altKey}const g8=e=>e.length===1&&e>="1"&&e<="9",bd=e=>e==="Enter"||e==="NumpadEnter";function k8(e,t,n){const r=bd(e.key)&&(e.metaKey||e.ctrlKey);return t?e.key==="Escape"||e.key==="Tab"&&!e.shiftKey?{kind:"field-leave"}:r?{kind:"submit"}:bd(e.key)&&!e.shiftKey?{kind:"field-enter"}:{kind:"typing"}:m8(e)?{kind:"chord"}:e.key==="Escape"?{kind:"escape"}:r?{kind:"submit"}:bd(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:$c(n.cursor,e.key==="ArrowUp"?-1:1,n.count)}:g8(e.key)&&Number(e.key)<=n.count?{kind:"pick",at:Number(e.key)-1,by:"digit"}:null}function Hk(e,t){var o,i,l,u;const n=e.target instanceof HTMLTextAreaElement,r=k8(e,n,t);if(!r)return!1;switch(r.kind){case"chord":case"typing":return!0;case"escape":case"field-leave":return e.preventDefault(),e.stopPropagation(),(o=r.kind==="escape"?t.onEscape:t.onFieldLeave)==null||o(),!0;case"submit":return e.preventDefault(),t.onSubmit?t.onSubmit():n?(i=t.onFieldEnter)==null||i.call(t):t.cursor!==void 0&&t.onPick(t.cursor,"enter"),!0;case"pick":return e.preventDefault(),t.onPick(r.at,r.by),!0;case"cursor":return e.preventDefault(),(l=t.onCursor)==null||l.call(t,r.to),!0;case"field-enter":return e.preventDefault(),(u=t.onFieldEnter)==null||u.call(t),!0}}function w8(e){return!e||e===document.body?!1:e.closest(".monaco-editor, .xterm")?!0:(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&!e.closest(".chat-input")}function y8(e,t){vt([t],()=>{const o=requestAnimationFrame(()=>{var i;w8(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 Kk({root:e,id:t,onKeyDown:n,onKeyUp:r,onPaste:o,children:i}){const l=y8(e,t);return h.jsx("div",{ref:e,className:"card",tabIndex:-1,onKeyDown:n,onKeyUp:r,onPaste:o,onBlur:l,children:i})}function Vd({children:e,sub:t}){return h.jsxs("div",{className:"card-head",children:[h.jsx("div",{className:"card-text",children:e}),t&&h.jsx("div",{className:"card-sub",children:t})]})}function Yd(e){const t=S.useRef(null),n=zk(t);return"html"in e?h.jsxs("div",{ref:t,className:"card-band md",children:[h.jsx("div",{dangerouslySetInnerHTML:{__html:e.html}}),n]}):h.jsxs("div",{ref:e.still?void 0:t,className:Ue("card-band card-code",e.still&&"card-still"),children:[h.jsx("pre",{children:e.code}),!e.still&&n]})}function v8({children:e}){return h.jsx("div",{className:"card-foot",children:e})}const b8=[{selected:[]}],qp=0,x8=2;function E8({item:e,worktreeId:t,rootRef:n}){var A;const r=lt(),o=at(),i=Tt(t,"card"),l=(i==null?void 0:i.id)===e.id?i.draft:b8,u=(A=l[0])==null?void 0:A.note,c=u!==void 0,f=I=>o({a:"card-draft",id:t,card:{id:e.id,draft:I,current:0}}),p=S.useRef(null),[m,g]=S.useState(qp),[w,y]=S.useState(!1),x=S.useMemo(()=>Wa(e.message),[e.message]),b=I=>{w||!r||(r.send(EP(e,t,I,u)),I&&y(!0),o({a:"answered",id:t}))},j=()=>{c||f(Rd(l,0,"")),g(qp),requestAnimationFrame(()=>{var I;return(I=p.current)==null?void 0:I.focus()})},N=I=>b(I===qp),T=()=>o({a:"card-park",id:t,cardId:e.id}),R=()=>{var _;const I=mm(l,0);I!==l&&f(I),(_=n.current)==null||_.focus()},$=I=>{Hk(I,{count:x8,cursor:m,onCursor:g,onPick:N,onEscape:T,onFieldEnter:()=>b(!0),onFieldLeave:R})||I.key==="n"&&(I.preventDefault(),j())},W=[{label:"go",hint:{k:"n",label:"add context",on:!c},checked:c,field:c?{ref:p,value:u??"",placeholder:"a note for the agent there, sent with go",enterKeyHint:"send",onChange:I=>f(Rd(l,0,I))}:void 0,description:w?"starting":void 0,disabled:w},{label:"not now",tone:"deny",disabled:w}];return h.jsxs(Kk,{root:n,id:e.id,onKeyDown:$,children:[h.jsxs(Vd,{sub:h.jsxs(h.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,"?"]}),h.jsx(Yd,{html:x}),h.jsx(Gd,{rows:W,cursor:m,onCursor:g,onPick:N})]})}function _8(e,t){if(t.queued>0||t.sending||t.card)return null;const n=e.at(-1);if(!n)return null;const r=e.filter(u=>u.kind!=="page-error"),o=r.at(-1);if(o&&(o.kind==="stopped"||o.kind==="error")){if(o.seq===void 0)return null;const u=`${o.kind}:${o.seq}`;return t.dismissed.has(u)?null:o.kind==="stopped"?{verb:"continue",key:u,after:"stop"}:{verb:"continue",key:u,after:"error",...N8(r)?{again:!0}:{}}}const i=S8(e,t.dismissed);if(i!==void 0)return i;if(n.kind!=="tool"||!n.done||!n.fixable||t.dismissed.has(n.id)||e.some(u=>u.kind==="asked"&&u.toolId===n.id))return null;const l=Of(n);return l===null?null:{verb:"fix",key:n.id,toolId:n.id,command:l}}function S8(e,t){let n=0,r;for(let i=e.length-1;i>=0;i--){const l=e[i];if(l.kind==="page-error")r??(r=l.seq),n++;else{if(l.kind==="user"||l.kind==="asked")break;if(l.kind==="tool"&&og({name:l.name,kind:l.toolKind}))break}}if(n===0)return;if(r===void 0)return null;const o=`page:${r}`;return t.has(o)?null:{verb:"fix",key:o,page:{errors:n}}}function N8(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 Wm=new Set;const Zm=new Set;function T8(e){return Zm.add(e),()=>{Zm.delete(e)}}function Gp(e){Wm=new Set(Wm).add(e);for(const t of Zm)t()}function j8(){return S.useSyncExternalStore(T8,()=>Wm)}const C8=e=>Sc.some(t=>t.id===e);function A8(e){return[...Sc.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 yN(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 I8(e,t){const n=yN(e,t);return[...n.yours,...n.own,...n.rest]}function sx(e,t){const n=yN(e,t);return{rows:[...n.yours,...n.own],more:n.rest.length}}function R8(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 $8({item:e,ask:t,worktreeId:n,rootRef:r}){const o=lt(),i=at(),l=M(y=>y.activeId),[u,c]=S.useState(0),f=t.plan,p=S.useMemo(()=>t.detail&&!f?Wa(t.detail):"",[t.detail,f]),m=()=>{f&&l===n&&er({dispatch:i},{worktreeId:n,path:f,view:"preview",focus:!1})};vt([e.id,f],m);const g=y=>{const x=t.choices[y];x&&(o==null||o.send({t:"agent-decide",worktreeId:n,askId:e.id,choiceId:x.id}),i({a:"answered",id:n}))},w=y=>{Hk(y,{count:t.choices.length,cursor:u,onCursor:c,onPick:g,onEscape:()=>i({a:"card-park",id:n,cardId:e.id})})};return h.jsxs(Kk,{root:r,id:e.id,onKeyDown:w,children:[h.jsx(Vd,{children:t.title}),t.command&&h.jsx(Yd,{code:NS(t.command)}),p&&h.jsx(Yd,{html:p}),h.jsx(Gd,{rows:t.choices.map(y=>({label:y.name,tone:y.kind.startsWith("reject")?"deny":void 0})),cursor:u,onCursor:c,onPick:g})]})}function O8({item:e,ask:t,worktreeId:n,rootRef:r,numbers:o,onScreen:i,onAnswer:l}){const u=lt(),c=at(),f=Zn(),p=M(ee=>ee.clientId),{message:m,questions:g}=t,w=Da(e.id),y=Tt(w,"attachments"),x=qE(w,n),b=Tt(n,"card"),j=S.useMemo(()=>(b==null?void 0:b.id)===e.id?b:{id:e.id,draft:dM(g),current:0},[b,e.id,g]),{draft:N,current:T}=j,R=T===tc(g),$=g[T],W=N[T],A=!!($!=null&&$.multi),[I,_]=S.useState(()=>Oa($,W)),P=S.useRef(null);S.useEffect(()=>{const ee=window.visualViewport;if(!ee)return;const J=()=>{P.current&&P.current===document.activeElement&&P.current.scrollIntoView({block:"nearest"})};return ee.addEventListener("resize",J),()=>ee.removeEventListener("resize",J)},[]);const z=(ee,J)=>c({a:"card-draft",id:n,card:{id:e.id,draft:ee,current:J}}),q=ee=>{if(l){ee&&l(ee);return}const J=ee?y:[];if(J.some(Va))return c({a:"notice",id:n,text:Ia});u==null||u.send({t:"agent-answer",worktreeId:n,askId:e.id,...ee?{answers:ee}:{},...J.length?{attachments:J.map(Ii),boxId:w,clientId:p}:{}}),J.length&&c({a:"clear-attachments",id:w}),c({a:"answered",id:n})},se=()=>c(l?{a:"ask-revive",id:n}:{a:"card-park",id:n,cardId:e.id}),Y=()=>{Qu(g,N)&&q(N)},ge=ee=>{_(Oa(g[ee],N[ee])),z(N,ee)},ke=ee=>{$!=null&&$.note&&(z(s0(N,T,ee,A),T),requestAnimationFrame(()=>{var J;return(J=P.current)==null?void 0:J.focus()}))},oe=()=>{if(!($!=null&&$.note))return;const ee=$.options[I];if(!ee||A)return ke(!ee);z(s0(o0(N,T,ee.value,!1),T,!1,!1),T),requestAnimationFrame(()=>{var J;return(J=P.current)==null?void 0:J.focus()})},L=ee=>{if(hM($,ee))return _(ee),ke(!0);const J=$==null?void 0:$.options[ee];if(!$||!J)return;const pe=o0(N,T,J.value,A);if(A){_(ee),z(pe,T);return}const $e=i0(g,pe,T);_($e.cursor),z(pe,$e.current),$e.send&&Qu(g,pe)&&q(pe)},re=()=>{var J;const ee=mm(N,T);ee!==N&&(z(ee,T),_(Oa($,ee[T]))),(J=r.current)==null||J.focus()},te=()=>{var pe;const ee=mm(N,T);if((pe=r.current)==null||pe.focus(),!Fa(ee[T])){ee!==N&&(z(ee,T),_(Oa($,ee[T])));return}const J=i0(g,ee,T);_(J.cursor),z(ee,J.current),J.send&&Qu(g,ee)&&q(ee)},K=ee=>{if(x.onPasteKey(ee),!Hk(ee,{count:R?g.length:fM($),cursor:R?void 0:I,spacePicks:A,onCursor:_,onPick:J=>R?ge(J):L(J),onSubmit:Y,onEscape:se,onFieldEnter:te,onFieldLeave:re})){if(ee.key==="ArrowLeft"||ee.key==="ArrowRight"||ee.key==="Tab"){ee.preventDefault();const J=ee.key==="ArrowLeft"||ee.key==="Tab"&&ee.shiftKey;return ge(wM(T,J?-1:1,vM(g)))}if(ee.key==="n"&&($!=null&&$.note))return ee.preventDefault(),oe();if(ee.key==="s"&&!l)return ee.preventDefault(),q()}},B=ee=>g.length===1&&!ee.multi,xe=(ee,J)=>h.jsxs(v8,{children:[(!ee||!B(ee))&&h.jsx(Le,{variant:"outline",size:"md",disabled:!Qu(g,N),onClick:Y,children:"send"}),(ee==null?void 0:ee.note)&&J&&J.selected.length>0&&J.note===void 0&&h.jsxs(Le,{tone:"quiet",size:"md",onClick:()=>ke(!1),children:[h.jsx(Wo,{k:"n",chip:!0}),"add a note"]}),!l&&h.jsxs(Le,{tone:"quiet",size:"md",onClick:()=>q(),children:[h.jsx(Wo,{k:"s",chip:!0}),"skip"]}),h.jsx(Ot,{className:"card-attach",icon:"attach",tone:"chrome",label:i?"Attach a picture":"Attach a picture or a file",onClick:()=>KE(f,w,{images:i})})]}),de=y.length>0&&h.jsx("div",{className:"card-chips",children:lg(y,o).map(([ee,J])=>{const pe=()=>c({a:"detach",id:w,key:ee.key});return ee.kind==="pick"?null:h.jsx(wN,{item:ee,n:J,onRemove:pe},ee.key)})}),we=(ee,J)=>{const pe=J===T,$e=N[J],le=F1($e,!!ee.multi),ae=pe?ee.options[I]:void 0,Fe=ze=>({ref:pe?P:void 0,value:($e==null?void 0:$e.note)??"",placeholder:ze,enterKeyHint:tc(g)===-1?"send":"next",onChange:Re=>z(Rd(N,J,Re),J)}),Qe=ee.options.map(ze=>{const Re=!!($e!=null&&$e.selected.includes(ze.value));return{label:h.jsxs(h.Fragment,{children:[jg(ze.label),bM(ze.label)&&h.jsx("span",{className:"badge-recommended",children:"recommended"})]}),description:ze.description,hint:ee.note&&!ee.multi?{k:"n",label:"add a note",on:($e==null?void 0:$e.note)===void 0}:void 0,checked:Re,field:Re&&!le&&($e==null?void 0:$e.note)!==void 0?Fe("a note for the agent, sent with your pick"):void 0}});return ee.note&&Qe.push({label:ee.note.label,description:le?void 0:"your own answer",checked:le,field:le?Fe("your own answer"):void 0}),h.jsxs("div",{className:Ue("card-page",!pe&&"card-page-off"),children:[h.jsx(Vd,{children:ee.text||m}),pe&&de,h.jsx(Gd,{rows:Qe,cursor:pe?I:void 0,onCursor:_,onPick:ze=>{var Re;L(ze),(Re=r.current)==null||Re.focus()}}),(ae==null?void 0:ae.preview)&&h.jsx(Yd,{code:ae.preview,still:!0}),xe(ee,$e)]},ee.id)};return h.jsxs(Kk,{root:r,id:e.id,onKeyDown:K,onKeyUp:x.onPasteKeyUp,onPaste:x.onPaste,children:[g.length>1&&h.jsx("div",{className:"card-tabs",children:h.jsx(jf,{label:"questions",owner:"ask",items:[...g.map((ee,J)=>({id:String(J),label:ee.header||`question ${J+1}`,lead:h.jsx("span",{className:Ue("dot card-step",Fa(N[J])&&"answered")})})),{id:String(g.length),label:"send",far:!0}],current:String(T),onPick:ee=>{var J;ge(Number(ee)),(J=r.current)==null||J.focus()}})}),h.jsxs("div",{className:"card-pages",children:[g.map(we),tc(g)!==-1&&h.jsxs("div",{className:Ue("card-page",!R&&"card-page-off"),children:[h.jsx(Vd,{children:"Send these answers?"}),R&&de,h.jsx(Gd,{hover:!0,rows:g.map((ee,J)=>{const pe=Fa(N[J])?mM(ee,N[J]):void 0;return{label:h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"row-dim",children:ee.header||`question ${J+1}`})," ",h.jsx("span",{className:Ue(!pe&&"row-dim"),children:pe?pe.pick:"no answer yet"})]}),description:pe==null?void 0:pe.note}}),onPick:ee=>{var J;ge(ee),(J=r.current)==null||J.focus()}}),xe()]})]})]})}const M8={side:"top",align:"start",offset:6,flip:"both",margin:8},L8=5*6e4;function P8({usage:e,limits:t,auth:n,now:r,onClose:o}){const i=t?gD(t,r):[],l=i.length?lD(n):void 0,u=t&&r-t.at>L8?Og(r-t.at):null,c=(e==null?void 0:e.cost)!==void 0?` · ${Oc(e.cost)}`:"";return h.jsxs(Ss,{className:"usage-panel",anchor:"parent",placement:M8,onDismiss:o,onKey:f=>{f.key==="Escape"&&(f.stopPropagation(),o())},children:[e&&h.jsx(ix,{name:"context",used:e.used/e.size,sub:`${ib(e.used)} of ${ib(e.size)}${c}`}),l&&h.jsx("div",{className:"usage-who section-title",children:l}),i.map(f=>h.jsx(ix,{name:f.name,used:f.used,sub:f.sub},f.key)),u&&h.jsxs("div",{className:"usage-stale hint",children:["read ",u," ago"]})]})}function ix({name:e,used:t,sub:n}){const r=Math.max(0,Math.min(1,t));return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"usage-row",children:[h.jsx("span",{className:"usage-name",children:e}),h.jsx("span",{className:"meter",children:h.jsx("span",{className:"meter-fill",style:{"--meter":r}})}),h.jsxs("span",{className:"usage-fig",children:[Math.round(100*t),"%"]})]}),h.jsx("div",{className:"usage-sub hint",children:n})]})}const ax=[],D8=[],z8=new Set(["ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),F8=150,lx=e=>({kind:"cmd",c:e});function B8(e,t,n,r){return e==="command"?r?n===0?"starting the agent to see what it offers…":"no matching command":"no session has run this agent yet, so it has offered no commands":t?"no matches":"listing files…"}function U8(e){return e.kind==="cmd"?`/${e.c.name} `:e.kind==="folder"?`@${e.path}/ `:e.kind==="changes"?"@changes ":`@${e.path} `}function sc({active:e,draft:t,archived:n,found:r,project:o,greenfield:i,placement:l="dock"}){var qc,Gc,Vc,Yc,aa,$s,Xc,fl,hl;const u=l==="screen",c=at(),f=lt(),{storage:p}=oo(),m=Zn(),g=!!t,w=(e==null?void 0:e.worktree.id)??null,y=e==null?void 0:e.worktree.repoId,x=o?Ya:n?n.id:r?r.id:Cc(e),b=!!n||!!r,j=n?n.restorable:!!r&&!r.locked,N=Tt(x,"draft"),T=Tt(x,"attachments"),R=Tt(x,"notice"),$=((qc=e==null?void 0:e.worktree.owns)==null?void 0:qc.join(", "))??"",W=S.useRef({id:w,owns:$});vt([w,$],()=>{const Z=W.current;W.current={id:w,owns:$},!(Z.id!==w||Z.owns===$||!$||!x||n)&&c({a:"notice",id:x,text:`Running its own ${$} here now: this branch changed it.`})});const A=Tt(x,"mark"),I=(A==null?void 0:A.by)==="walk"?A:void 0,_=Tt(w,"chat"),P=Tt(w,"queue"),z=S.useMemo(()=>w&&!g?tk(_):null,[w,g,_]),q=Tt(w,"cardParked"),se=Tt(w,"sending"),Y=S.useMemo(()=>w&&!g&&!se?z1(_):null,[w,g,se,_]),ge=Tt(w,"askRevived"),ke=!z&&Y&&ge===Y.id?Y:null,oe=z&&q!==z.id?z:ke,L=ke?Da(ke.id):null,re=Tt(L,"attachments"),te=z?q===z.id?z:null:Y&&!ke?Y:null,K=S.useRef(null),B=Ki(),xe=Gg(),de=Tt(xe,"page"),we=Ic(),{onPaste:ee,onPasteKey:J,onPasteKeyUp:pe}=qE(x,w),$e=WL(),le=j8(),ae=S.useMemo(()=>w&&!g?_8(_,{queued:P.length,sending:!!se,card:!!(oe||te),dismissed:le}):null,[w,g,_,P.length,se,oe,te,le]),Fe=Z=>x&&c({a:"set-draft",id:x,text:Z}),Qe=M(Z=>Z.clientId),ze=M(Z=>Z.repos),Re=M(Z=>Z.repos.find(et=>et.id===(e==null?void 0:e.worktree.repoId))??null),ct=M(Z=>Z.defaultAgent),_n=M(Z=>Z.agentChosen),ht=g||!!i||!!o,tn=!ht&&!!e&&!e.worktree.agent,Vt=ht||tn,He=(t==null?void 0:t.agent)??ct,nt=M(Z=>Z.agents.find(et=>et.id===(Vt?He:e==null?void 0:e.worktree.agent))),an=!!(nt!=null&&nt.quick),It=(nt==null?void 0:nt.models)??ax,X=(nt==null?void 0:nt.efforts)??ax,[fe,dt]=OF(He),[Ke,pn]=IF(He),mn=M(Z=>Z.agents),Sn=(Z,et)=>{if(Z===He){dt(et);return}MF(p,Z,et),g?c({a:"draft-agent",id:Z}):f==null||f.send({t:"set-default-agent",agent:Z})},Ct=Tt(w,"model"),Nn=Tt(w,"effort"),ut=Tt(w,"usage")??(e==null?void 0:e.usage),[Ee]=JS(Re),De=(t==null?void 0:t.profile)??Ee,[gn,bn]=RF(Re),wn=(e==null?void 0:e.worktree.mode)??xd,qn=M(Z=>Z.picking),ft=M(Z=>Z.layout.term),Mt=K1((e==null?void 0:e.procs)??[]),nn=fn("composer"),H=Tt(w,"files"),me=S.useMemo(()=>Z1(H??D8),[H]),_e=Tt(w,"git"),Ge=(_e==null?void 0:_e.files.length)??(e==null?void 0:e.dirty)??0,Lt=(_e==null?void 0:_e.unpushed)??(e==null?void 0:e.unpushed)??0,Pt=M(Z=>{var et;return w?(et=Z.shipping[w])==null?void 0:et.op:void 0}),Pe=M(Z=>{var et;return w?(et=Z.shipping[w])==null?void 0:et.step:void 0}),Oe=M(Z=>Xa(Z,y)),Ve=M(Z=>{var et;return Oe?(et=Z.shipping[Oe.id])==null?void 0:et.op:void 0}),Zt=Oe&&Re&&ht?d_(Re.defaultBranch,Oe):null,$t=M(Z=>g?AM(Z.rows,y,He,ct):w),Tn=Tt($t,"commands"),In=Tn.some(Z=>Z.name==="compact"),kn=(e==null?void 0:e.agent)==="working"||(e==null?void 0:e.agent)==="waiting",kr=kn&&!!w&&!g,hn=e==null?void 0:e.worktree.lastTurn,En=!N.trim()&&T.length===0,cr=!g&&!i&&En&&!kn?hn:void 0,Yt=!g&&!i&&e&&Ai(e.worktree)?e.worktree.landing:void 0,qt=!!(Yt!=null&&Yt.ready)&&!Yt.stale&&!ed(Yt,Ge,an,nt==null?void 0:nt.name),zt=En&&(!kn||qt)?Yt:void 0,G=Ge>0&&!!(zt!=null&&zt.subject),be=Ge||(((Gc=_e==null?void 0:_e.committed)==null?void 0:Gc.length)??0),Ze=!g&&!i&&En&&!kn&&!!e,pt=!!(e!=null&&e.worktree.landed)&&Ge===0,Jt=Ze&&pt,rn=Ze&&!Jt?e.worktree.pr:void 0,Ut=!pt&&((Vc=e==null?void 0:e.worktree.pr)==null?void 0:Vc.state)==="open"?e.worktree.pr:void 0,ur=!!Ut&&(Ge>0||Lt>0),Or=((Yc=e==null?void 0:e.worktree.pr)==null?void 0:Yc.state)==="closed",On=$i((Re==null?void 0:Re.config)??{}),St=S.useMemo(()=>A8(Ed($i((Re==null?void 0:Re.config)??{}),Re==null?void 0:Re.defaultBranch)),[Re]),je=()=>w&&(f==null?void 0:f.send({t:"chat",worktreeId:w,text:"/compact"})),Se=ht?"nothing to compact until the first reply":In?kn?"wait for the turn to end":void 0:"this agent offers no compact command",kt=In&&ut?uD(ut.used/ut.size):void 0,st=nt==null?void 0:nt.limits,Ft=ht?void 0:ut,Gt=(!!w||ht)&&!!(Ft||st),U=Date.now(),[he,Be]=S.useState(!1),mt=S.useRef(0),bt=()=>{window.clearTimeout(mt.current),Be(!1)};vt([w],bt);const Ht=Vg(),Mn=(Ht==null?void 0:Ht.owner)==="composer"&&Ht.key==="usage",tr=()=>[{id:"compact",label:"compact the context",detail:Se||!ut?void 0:cD(ut.used/ut.size),disabled:Se,onClick:je}],[jo,xr]=S.useState(0),[js,Mr]=S.useState(null),[Lr,wr]=S.useState(null),Co=S.useRef(null),Xe=x&&!b&&!o?Zb(N,jo):null,gt=Xe!==null&&Xe.from!==js&&!I,Ao=Xe==null?void 0:Xe.kind,ln=Xe==null?void 0:Xe.query,Xt=S.useMemo(()=>{if(ln===void 0)return[];if(Ao==="command")return ln.trim()?D6(I8(St,Tn),ln).slice(0,8).map(lx):sx(St,Tn).rows.map(lx);const Z=[],et=(_e==null?void 0:_e.files.length)??0;return et>0&&"changes".startsWith(ln.toLowerCase())&&Z.push({kind:"changes",n:et}),Z.push(...c8(H??[],me,(_e==null?void 0:_e.files)??[],ln,8)),Z},[Ao,ln,H,me,_e,Tn,St]),Pr=Ao==="command"&&ln!==void 0&&!ln.trim()?sx(St,Tn).more:0,Xn=S.useRef(null),Ne=S.useRef(null),O=()=>{var Z;return(Z=K.current??Xn.current)==null?void 0:Z.focus()},D=O;vt([i?e==null?void 0:e.worktree.id:null],()=>{if(!i)return;const Z=requestAnimationFrame(()=>{var Nt;const et=document.activeElement;(!et||et===document.body)&&((Nt=Xn.current)==null||Nt.focus())});return()=>cancelAnimationFrame(Z)});const ne=M(Z=>Z.focusChat),ye=S.useRef(ne),Ae=!!EE();vt([ne],()=>{if(ne===ye.current||(ye.current=ne,Ae!==!!i))return;const Z=requestAnimationFrame(O);return()=>cancelAnimationFrame(Z)});const We=oe==null?void 0:oe.id,xt=S.useRef({id:w,cardUpId:We});vt([w,We],()=>{const Z=xt.current;if(xt.current={id:w,cardUpId:We},We||!Z.cardUpId||Z.id!==w||Ae!==!!i||B&&!te)return;const et=requestAnimationFrame(()=>{var Kt;const Nt=document.activeElement;(!Nt||Nt===document.body)&&((Kt=Xn.current)==null||Kt.focus())});return()=>cancelAnimationFrame(et)});const cn=M(Z=>Z.walked),Gn=S.useRef(cn);vt([cn],()=>{if(cn===Gn.current||(Gn.current=cn,Ae!==!!i))return;const Z=requestAnimationFrame(()=>{const et=document.activeElement;(!et||et===document.body||et.closest(".rail"))&&O()});return()=>cancelAnimationFrame(Z)});const Ln=JE({results:Xt,keyOf:Z=>Z.kind==="cmd"?`c:${Z.c.name}`:Z.kind==="changes"?"changes":`f:${Z.path}`,q:(Xe==null?void 0:Xe.query)??"",listRef:Co,tabPicks:!0,onPick:Z=>{if(!Xe)return;const{text:et,caret:Nt}=P6(N,Xe,U8(Z));Fe(et),Mr(Xe.from),wr(Z.kind==="cmd"&&Z.c.hint?{name:Z.c.name,hint:Z.c.hint}:null),requestAnimationFrame(()=>{const Kt=Xn.current;Kt&&(Kt.focus(),Kt.setSelectionRange(Nt,Nt),xr(Nt))})}}),yr=w||b?Q6(N):null,nr=Lr&&N===`/${Lr.name} `?Lr.hint:null,Zi=yr===""&&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,qi=nr??Zi,cl=(e==null?void 0:e.worktree.title)??"untitled",Io=(aa=hn==null?void 0:hn.recap)==null?void 0:aa.text,ss=()=>{w&&ti(f,c,{t:"land",worktreeId:w})},is=Z=>{w&&(f==null||f.send({t:"judge",worktreeId:w,...Z?{note:Z}:{}}))},Gi=!!(($s=Re==null?void 0:Re.config.check)!=null&&$s.trim()),ul=uk(Yt,Ge,an),Df=Ze&&!Pt&&!ht&&Ai(e.worktree)&&!pt&&!Or&&be>0&&(!Yt||!!Yt.stale||ul==="unanswered"),Vi="Archive this worktree when you are done here; the rail's archived section brings it back with its chat.",Yi=ur?"update":"land",Xi=Re?nf(Re):"main",Dc=ur&&Ut?`Commit, take ${Xi} in and push the branch; PR #${Ut.number} takes the new commits.`:`${Ed(On,Re==null?void 0:Re.defaultBranch)}.`,jn=w?Jt?{word:"archive",line:((Xc=e==null?void 0:e.worktree.pr)==null?void 0:Xc.state)==="merged"?ks(e.worktree.pr):`landed on ${(Re==null?void 0:Re.defaultBranch)??"main"}.`,tip:Vi,run:()=>Pi(f,c,[w])}:(rn==null?void 0:rn.state)==="open"&&!ur?h_(rn)?{word:"merge",line:td(Io??ks(rn)),tip:`${ks(rn)} Merge the PR now, by the method the repo allows.`,run:ss,ships:!0}:{word:"view",line:td(Io??ks(rn)),tip:`${ks(rn)} Open the PR on GitHub.`,run:()=>window.open(rn.url,"_blank")}:(rn==null?void 0:rn.state)==="closed"?{word:"archive",line:ks(rn),tip:`${ks(rn)} ${Vi}`,run:()=>Pi(f,c,[w])}:Df?{word:"check",line:(Yt==null?void 0:Yt.subject)??td(Io??D4(be)),tip:p_(Yt,Gi,ul),run:is}:zt!=null&&zt.ready&&!ed(zt,Ge,an,nt==null?void 0:nt.name)?{word:Yi,line:zt.subject??td(Io??(Y0(zt,be)||"ready")),tip:[Y0(zt,be),P4(Xi,e==null?void 0:e.behind),Dc,zt.subject&&Ge>0?"Tab from the word edits the message first.":""].filter(Boolean).join(" "),run:ss,ships:!0}:null:null,Qi=(fl=e==null?void 0:e.worktree.lands)==null?void 0:fl.at(-1),ui=Qi&&f_(Qi),Ji=((jn==null?void 0:jn.word)==="land"||(jn==null?void 0:jn.word)==="update"||(jn==null?void 0:jn.word)==="check")&&zt?z4(zt,ul):(jn==null?void 0:jn.word)==="archive"&&ui?Ur(ui):null,Cs=S.useRef(null);Pt!=="land"&&(Cs.current=w&&(jn!=null&&jn.ships)?{id:w,verb:jn,under:Ji}:null);const as=Pt==="land"&&En&&((hl=Cs.current)==null?void 0:hl.id)===w?Cs.current:null,Qn=as?as.verb:jn,dr=!!(Qn!=null&&Qn.ships)&&Pt==="land",qo=Hg(Pe,Kg),As=wc(e,"commit"),Go=wc(e,"check"),Is=g_(dr?As:Go),ea=Ja(fk(Is)?Is==null?void 0:Is.since:void 0),di=zt?zt.check==="pending"&&Go&&Is===Go?jm("Checking the work",Go,ea):ed(zt,Ge,an,nt==null?void 0:nt.name):null,ls=Qn&&dr?qo?`${Qn.word}: ${qo}`:`${Qn.word} ${Qn.line}`:null,fi=ls&&As&&Is===As?jm(ls,As,ea):ls,zc=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?Qn?"":di||(rn?ks(rn):cr?dk(cr):i?`describe ${cl}…`:ht?"describe a change":u?`message agent on ${cl}`:`message agent on ${cl}; / for a command, ! for a shell command`):"no worktree selected",ta=N!==""||qi||!e?null:dr?qo?null:as?as.under:Ji:Qn?Ji:rn||di?Io??(zt==null?void 0:zt.subject)??null:null,Fc=S.useRef(!1);S.useEffect(()=>{const Z=gt&&!Fc.current;Fc.current=gt,Z&&((Xe==null?void 0:Xe.kind)==="file"&&w?_f(w,m.getState(),{sock:f,dispatch:c}):(Xe==null?void 0:Xe.kind)==="command"&&$t&&Tn.length===0&&(f==null||f.send({t:"list-commands",worktreeId:$t})))},[gt,Xe==null?void 0:Xe.kind,Tn.length,w,$t,f,m,c]);const na=()=>{if(!e)return;const Z=[],et=de;if(et.url)try{const Hr=new URL(et.url);Z.push(`current route: ${Hr.pathname}${Hr.search}`)}catch{}et.title&&Z.push(`page title: ${et.title}`);const Nt=[];i&&Nt.push(xF(e.worktree.title,Re==null?void 0:Re.configFile)),Z.length>0&&Nt.push(`What the user is looking at right now:
|
|
234
|
+
${Z.join(`
|
|
235
|
+
`)}`);const Kt=eF(_);return Kt&&Nt.push(Kt),Nt.length>0?Nt:void 0},Bc=Z=>{ht?bn(Z):w&&Z!==wn&&(f==null||f.send({t:"set-worktree-mode",worktreeId:w,mode:Z}))},Vn=Z=>x&&c({a:"notice",id:x,text:Z}),Ff=(Z,et="")=>{if(!e||!w)return;if(Z==="handoff"){if(ht)return Vn("a new worktree has nothing to continue yet");const Kt=_P(et,ze,e.worktree.repoId);"pick"in Kt?c({a:"open",overlay:{kind:"handoff",worktreeId:w}}):"error"in Kt?Vn(Kt.error):f==null||f.send({t:"handoff-ask",worktreeId:w,repoId:Kt.repo.id,...Kt.text?{text:Kt.text}:{}});return}if(Z==="archive"){pt||Or?Pi(f,c,[w]):Vn("archive is for a landed worktree; this one has not landed");return}if(Z==="check"){ht||!Ai(e.worktree)?Vn("nothing to check from here"):kn?Vn("wait for the turn to end"):be===0?Vn("nothing to check: no changes here"):is(et||void 0);return}const Nt=Yt?ed(Yt,Ge,an,nt==null?void 0:nt.name):null;ht||!Ai(e.worktree)?Vn("nothing to land from here"):pt?Vn(`already landed on ${(Re==null?void 0:Re.defaultBranch)??"main"}`):Nt?Vn(Nt):kn&&(!Yt||Yt.stale)?Vn("wait for the turn to end"):Yt!=null&&Yt.stale?Vn("the work changed since this was checked; check again first"):ss()},ra=T.some(Va),oa=()=>{x&&(f==null||f.send({t:"set-draft",boxId:x,text:N,clientId:Qe}))},sa=()=>{if(!x)return;if(o){if(o.busy)return;if(o.why)return Vn(o.why);if(ra)return Vn(Ia);(He!==ct||!_n)&&(f==null||f.send({t:"set-default-agent",agent:He})),oa(),o.create();return}if(En)return;if(n){if(!n.restorable)return;if(yr!==null){Vn("nothing runs here until it is restored");return}if(ra){Vn(Ia);return}const Dr=T.length?T.map(Ii):void 0;oa(),f==null||f.send({t:"restore-worktree",archiveId:n.id,clientId:Qe,message:{text:N.trim(),attachments:Dr},boxId:x}),c({a:"restoring",id:x,text:N.trim()}),c({a:"sent-box",id:x});return}if(r){if(r.locked)return;if(yr!==null){Vn("nothing runs here until Toyon takes it over; its menu on the rail opens a shell");return}if(ra){Vn(Ia);return}const Dr=T.length?T.map(Ii):void 0;oa(),f==null||f.send({t:"adopt-worktree",worktreeId:r.id,clientId:Qe,message:{text:N.trim(),attachments:Dr},boxId:x}),c({a:"restoring",id:x,text:N.trim()}),c({a:"sent-box",id:x});return}if(!e||!w)return;if(yr!==null){yr&&g?c({a:"term-run",id:w,command:yr}):yr&&(f==null||f.send({t:"exec",worktreeId:w,command:yr})),Fe("");return}const Z=R8(N,St),et=Z&&C8(Z.name)?Z.name:void 0;if(Z&&!et){Ff(Z.name,Z.args),Fe("");return}if(et&&!(Z!=null&&Z.args)){Bc(et),Fe("");return}if(t!=null&&t.batch&&T.length){Vn("a batch takes no attachments; remove them or turn batch off");return}if(ra){Vn(Ia);return}const Nt=Z?Z.args:N.trim(),Kt=na(),Hr=T.length?T.map(Ii):void 0;if(oa(),et&&Bc(et),ht){const Dr=Nc(e.worktree)?{worktreeId:w}:{},Wf={clientId:Qe,repoId:e.worktree.repoId,context:Kt,attachments:Hr,agent:He,profile:De,mode:et??gn,...fe?{model:fe}:{},...Ke?{effort:Ke}:{},...G1(t)?{carry:!0}:{}};if((He!==ct||!_n)&&(f==null||f.send({t:"set-default-agent",agent:He})),t!=null&&t.batch)f==null||f.send({t:"batch-worktrees",repoId:e.worktree.repoId,prompt:Nt,agent:He,...fe?{model:fe}:{},...Ke?{effort:Ke}:{},boxId:x});else{const Qc=t&&t.variants>1?{variants:t.variants}:{};f==null||f.send({t:"create-worktree",...Wf,...Dr,...Qc,prompt:Nt,boxId:x}),x&&c({a:"sending",id:x,message:{text:Nt,attachments:Hr}})}}else tn&&(f==null||f.send({t:"set-worktree-model",worktreeId:w,model:fe}),f==null||f.send({t:"set-worktree-effort",worktreeId:w,effort:Ke})),f==null||f.send({t:"chat",worktreeId:w,clientId:Qe,text:Nt,context:Kt,attachments:Hr,boxId:x}),kn||c({a:"sending",id:w,message:{text:Nt,attachments:Hr}});c({a:"sent-box",id:x}),i&&c({a:"show-chat"})},Bf=Z=>{if(!w||(ke==null?void 0:ke.ask.kind)!=="question")return;if(!Z.some(Fa))return c({a:"ask-revive",id:w});if(re.some(Va))return Vn(Ia);const et=B1(ke.ask.questions,Z).join(`
|
|
236
|
+
`),Nt=re.length?re.map(Ii):void 0,Kt=Nt&&L?{attachments:Nt,boxId:L}:{};f==null||f.send({t:"chat",worktreeId:w,clientId:Qe,text:et,context:na(),...Kt}),Nt&&L&&c({a:"clear-attachments",id:L}),c({a:"sending",id:w,message:{text:et,attachments:Nt}}),c({a:"answered",id:w}),c({a:"ask-revive",id:w})},dl=M(Z=>Z.autoSend);vt([dl,w],()=>{!dl||dl!==w||En||Ae!==!!i||(c({a:"auto-sent"}),sa())});const Uf=()=>{const Z=T[T.length-1];return!x||!Z?!1:(c({a:"detach",id:x,key:Z.key}),!0)},Uc=Z=>{x&&(c({a:"walk",id:x,walk:Z.walk,text:Z.text}),requestAnimationFrame(()=>{var et;(et=Xn.current)==null||et.setSelectionRange(Z.text.length,Z.text.length),xr(Z.text.length)}))},ia=()=>{x&&I&&c({a:"walk",id:x,walk:null,text:N})},Hc=ht?[]:_.map(Z=>Z.kind==="user"?Z.attachments:void 0),Kc=ht?[]:P.flatMap(Z=>Z.attachments??[]),Wc=e?e.worktree.path:null,Rs=e==null?void 0:e.worktree.plan,Zc=kr&&!oe,Hf=M(Z=>Z.reading),Kf=u&&Hf&&En&&!oe&&!te&&!$e;return h.jsxs("div",{className:Ue("composer chat-input",Zc&&"stopping",Kf&&"lean"),children:[Rs&&e&&h.jsxs("div",{className:"composer-plan",...nn.contextMenu(()=>P_(Rs,Wc,()=>f==null?void 0:f.send({t:"reveal",worktreeId:e.worktree.id,path:Rs}),os(f))),children:[h.jsx(jt,{name:"text",className:"icon-inline"}),h.jsx(Le,{variant:"inline",className:"composer-plan-path","data-tip":"Read the plan in the editor pane",onClick:()=>er({dispatch:c},{worktreeId:e.worktree.id,path:Rs,view:"preview"}),children:Rs})]}),te&&w&&h.jsx(Wl,{icon:"chat",verb:"answer",tip:"Bring the question back into the box",onPress:()=>{c(te.kind==="ask"&&te.outcome?{a:"ask-revive",id:w,askId:te.id}:{a:"card-unpark",id:w}),c({a:"focus-chat"})},children:xP(te)}),(ae==null?void 0:ae.verb)==="fix"&&"toolId"in ae&&w&&h.jsxs(Wl,{icon:"run",verb:ae.verb,tip:"Send the agent what it printed and ask for a fix",onPress:()=>f==null?void 0:f.send({t:"fix",worktreeId:w,toolId:ae.toolId}),onDismiss:()=>Gp(ae.key),children:["what failed in ",h.jsx("code",{children:ae.command})]}),(ae==null?void 0:ae.verb)==="fix"&&"page"in ae&&w&&h.jsx(Wl,{icon:"run",verb:ae.verb,tip:"Send the agent what the preview threw and ask for a fix",onPress:()=>f==null?void 0:f.send({t:"fix-page",worktreeId:w}),onDismiss:()=>Gp(ae.key),children:"what the preview threw"}),(ae==null?void 0:ae.verb)==="continue"&&w&&h.jsx(Wl,{icon:"send",verb:ae.verb,tip:ae.after==="stop"?"Send the agent on from where its turn stopped":ae.again?"The last press ended in this same error. Send the agent on once more, or wait it out.":"Send the agent on from where its turn failed",onPress:()=>f==null?void 0:f.send({t:"continue",worktreeId:w}),onDismiss:()=>Gp(ae.key),children:ae.after==="stop"?"where it stopped":ae.again?"after the same error again":"after the error"}),$e&&x&&!oe&&(e||j||o)&&h.jsx(Wl,{icon:"copy",verb:"attach",tip:"Attach it, as a paste would",onPress:()=>{BP(m,x,$e),O()},onDismiss:_E,children:$e.kind==="image"?"the image you copied":`the text you copied, ${$e.text.split(`
|
|
237
|
+
`).length} lines`}),x&&!oe&&lg(T,rm(nm(Hc),Kc)).map(([Z,et])=>{const Nt=()=>c({a:"detach",id:x,key:Z.key});return Z.kind!=="pick"?h.jsx(wN,{item:Z,n:et,onRemove:Nt},Z.key):h.jsx(Dk,{pick:Z,dir:Wc,tipText:Z.html,onHover:Kt=>xe&&en.post(xe,Kt?{type:"highlight-selector",selector:Z.selector,label:$g(Z)}:{type:"highlight-clear"}),worktreeId:w,onOpen:(Kt,Hr)=>w&&tl(m,f,w,Kt,Hr),onRemove:Nt},Z.key)}),gt&&Xe&&h.jsx(vF,{results:Xt,keyOf:Z=>Z.kind==="cmd"?`c:${Z.c.name}`:Z.kind==="changes"?"changes":Z.kind==="folder"?`d:${Z.path}`:`f:${Z.path}`,rowClass:Z=>Z.kind==="file"||Z.kind==="folder"?"qo-file":Z.kind==="changes"?"picker-row":"picker-row picker-cmd",nav:Ln,listRef:Co,empty:B8(Xe.kind,H,Tn.length,$t!==null),note:Pr>0?`type to find ${Pr} more`:void 0,row:Z=>{const et=((_e==null?void 0:_e.files.length)??0)>0;return Z.kind==="file"?Km(Z.path,Z.status,Xe.query,{gutter:et}):Z.kind==="folder"?Km(Z.path,void 0,Xe.query,{folder:!0,gutter:et}):Z.kind==="changes"?h.jsx(Hn,{label:"@changes",hint:`${Z.n} uncommitted ${Z.n===1?"file":"files"}`}):h.jsx(DF,{c:Z.c,query:Xe.query})}}),oe&&w?oe.kind==="handoff"?h.jsx(E8,{item:oe,worktreeId:w,rootRef:K},oe.id):oe.ask.kind==="question"?h.jsx(O8,{item:oe,ask:oe.ask,worktreeId:w,rootRef:K,numbers:rm(nm(Hc),Kc),onScreen:u,onAnswer:ke?Bf:void 0},oe.id):h.jsx($8,{item:oe,ask:oe.ask,worktreeId:w,rootRef:K},oe.id):h.jsxs("div",{className:Ue("composer-field",yr!==null&&"shell",I&&"recalled"),children:[h.jsx(kc,{size:"lg",bare:!0,font:yr!==null?"mono":"ui",ref:Xn,value:N,onChange:Z=>{var Dr;const et=Z.target.value,Nt=Z.target.selectionStart??et.length;Fe(et),xr(Nt),Ln.setIndex(0);const{inputType:Kt}=Z.nativeEvent;Mr(Kt==="insertFromPaste"||Kt==="insertFromDrop"?((Dr=Zb(et,Nt))==null?void 0:Dr.from)??null:null)},onKeyUp:Z=>{pe(),xr(Z.currentTarget.selectionStart??0)},onClick:Z=>{xr(Z.currentTarget.selectionStart??0),ia()},onPaste:ee,onScroll:Z=>{Ne.current&&(Ne.current.scrollTop=Z.currentTarget.scrollTop)},onKeyDown:Z=>{var et;if(J(Z),!Z.nativeEvent.isComposing){if(gt){if(Z.key==="Escape"){Z.preventDefault(),Z.stopPropagation(),Mr((Xe==null?void 0:Xe.from)??null);return}if(Ln.onKeyDown(Z))return}if((Z.key==="ArrowUp"||Z.key==="ArrowDown")&&!Z.altKey&&!Z.ctrlKey){const Nt=Z.key==="ArrowUp",Kt=P.at(-1);if(Nt&&!Z.metaKey&&!I&&N===""&&w&&!g&&Kt!==void 0){Z.preventDefault(),LE(m,f,w,P.length-1);return}const Hr=Z.metaKey?Nt?"first":"box":Nt?"up":"down",Dr=w?hF(_,I??null,N,Hr):null;if(Dr){Z.preventDefault(),(Dr.walk!==I||Dr.text!==N)&&Uc(Dr);return}}if(I&&Z.key==="Escape"){Z.preventDefault(),Z.stopPropagation(),Uc({walk:null,text:I.from});return}if(Z.key==="Escape"&&kn&&w&&!g){Z.preventDefault(),Z.stopPropagation(),f==null||f.send({t:"stop-agent",worktreeId:w});return}if(I&&z8.has(Z.key)&&ia(),Z.key==="Tab"&&!Z.shiftKey&&N===""){const Nt=(et=Z.currentTarget.closest(".composer"))==null?void 0:et.querySelector(".composer-verb");if(Nt&&!Nt.disabled){Z.preventDefault(),Nt.focus();return}if(G){Z.preventDefault(),c({a:"edit-commit"});return}}Z.key==="Enter"&&(B?Z.metaKey||Z.ctrlKey:!Z.shiftKey)?(Z.preventDefault(),sa()):Z.key==="Backspace"&&N===""&&Uf()&&Z.preventDefault()}},placeholder:ta||Qn?"":zc,disabled:o?o.busy:!e&&!j}),qi&&h.jsxs("div",{className:"composer-ghost","aria-hidden":"true",children:[h.jsx("span",{className:"picker-typed",children:N}),qi]}),w&&yr===null&&N.includes("@")&&h.jsx("div",{ref:Ne,className:"composer-ghost composer-marks","aria-hidden":"true",onClick:Z=>US(Z,e==null?void 0:e.worktree.path,w,{sock:f,dispatch:c}),children:h.jsx(BS,{text:N,worktreeId:w,root:e==null?void 0:e.worktree.path,inField:!0})}),(ta||Qn)&&h.jsxs("div",{className:"composer-ghost","aria-hidden":Qn?void 0:"true",children:[h.jsx("span",{className:Ue("composer-placeholder",dr&&"live-text"),children:fi||(Qn?h.jsxs(h.Fragment,{children:[h.jsx(Le,{variant:"inline",tone:"strong",className:"composer-verb",disabled:!!Qn.ships&&!!Pt,...Dt(Qn.tip,void 0,{placement:"top"}),onClick:Qn.run,onKeyDown:Z=>{Z.key==="Tab"&&!Z.shiftKey&&G&&(Z.preventDefault(),c({a:"edit-commit"}))},children:Qn.word})," ",h.jsx("span",{className:"composer-verb-line",children:Qn.line})]}):zc)}),ta&&h.jsxs(h.Fragment,{children:[`
|
|
238
|
+
`,h.jsx("span",{className:"composer-subline",children:ta})]})]}),Zc&&h.jsx(Ot,{icon:"stop",tone:"danger",className:"composer-stop",label:`Stop the agent (context up to here is kept${P.length?"; queued messages go next":""})`,hint:"esc",onClick:()=>w&&(f==null?void 0:f.send({t:"stop-agent",worktreeId:w}))})]}),R&&h.jsx("div",{className:"hint composer-notice",role:"status",children:R}),!oe&&h.jsxs("div",{className:"hint composer-knobs",children:[h.jsxs("span",{className:"spawn-left",children:[Vt?mn.length>1?h.jsx(LF,{agents:mn,agent:He,model:fe,onChange:Sn,onClose:D}):h.jsx(tx,{models:It,value:fe,onChange:dt,onClose:D}):e&&h.jsx(tx,{models:It,value:e.worktree.model??"",current:Ct,onChange:Z=>f==null?void 0:f.send({t:"set-worktree-model",worktreeId:e.worktree.id,model:Z}),onClose:D}),Vt?h.jsx(Jb,{efforts:X,value:Ke,onChange:pn,onClose:D}):e&&h.jsx(Jb,{efforts:X,value:e.worktree.effort??"",current:Nn,onChange:Z=>f==null?void 0:f.send({t:"set-worktree-effort",worktreeId:e.worktree.id,effort:Z}),onClose:D}),ht?!o&&h.jsx(ex,{value:gn,onChange:bn,onClose:D}):e&&h.jsx(ex,{value:wn,onChange:Z=>f==null?void 0:f.send({t:"set-worktree-mode",worktreeId:e.worktree.id,mode:Z}),onClose:D}),Gt&&h.jsxs("span",{className:"usage-knob",onMouseEnter:()=>{Mn||(window.clearTimeout(mt.current),mt.current=window.setTimeout(()=>Be(!0),F8))},onMouseLeave:()=>{window.clearTimeout(mt.current),Be(!1)},children:[h.jsx(Ot,{icon:h.jsx(bF,{fraction:Ft?Ft.used/Ft.size:0,level:st?hD(st,U):void 0}),tone:"chrome",on:Mn,silent:!0,label:Ft?`${Math.round(100*Ft.used/Ft.size)}% of context`:st?ab(st,U):"",detail:[...Ft&&st?[ab(st,U)]:[],...kt?[kt]:[]],...nn.dropdown(tr,"left","usage"),...nn.contextMenu(tr,"usage")}),he&&h.jsx(P8,{usage:Ft,limits:st,auth:nt==null?void 0:nt.auth,now:U,onClose:bt})]})]}),h.jsxs("span",{className:"spawn-tools",children:[x&&(e||j||o)&&h.jsx(Ot,{icon:"attach",tone:"chrome",label:u?"Attach a picture":"Attach a picture or a file, or drop one here",onClick:()=>KE(m,x,{images:u})}),!i&&!b&&!u&&!o&&h.jsx(Ot,{icon:"terminal",tone:"chrome",on:ft,className:"composer-term",disabled:!e,label:Mt?Mt.tip:"Terminal",hint:At("terminal"),badge:Mt&&h.jsx("span",{className:"composer-term-dot"}),onClick:()=>{c(Mt&&!ft&&w?{a:"term-stream",id:w,stream:Mt.stream}:{a:"toggle-terminal"})},...nn.contextMenu(()=>e&&w?T6(e.procs,w,ft,{sock:f,dispatch:m.dispatch}):[])}),!i&&!we&&!b&&!u&&!o&&h.jsx(Ot,{icon:"pick",label:"Pick an element on the page to attach",hint:At("pick"),on:qn==="chat",disabled:!xe,onClick:()=>xe&&gc(xe,qn,c,"chat")}),B&&x&&(e||j||o)&&h.jsx(Ot,{icon:"send",tone:"primary",label:o?"Create the project":"Send",disabled:o?o.busy:En,onMouseDown:Z=>Z.preventDefault(),onClick:sa})]})]}),Zt&&Oe&&h.jsx("div",{className:"composer-notes",children:h.jsxs("div",{className:"hint composer-note",children:[h.jsx("span",{children:Zt}),O4(Oe)&&h.jsx(Le,{variant:"outline",busy:Ve==="pull-main",disabled:!!Ve,"data-tip":"Fast-forward main to origin",onClick:()=>ti(f,c,{t:"pull-main",worktreeId:Oe.id}),children:"pull"})]})})]})}function vN({children:e,className:t,tip:n,...r}){return h.jsxs("label",{className:Ue("check",t),"data-tip":n,children:[h.jsx("input",{type:"checkbox",className:"check-box",...r}),h.jsx("span",{children:e})]})}const H8=[1,2,3];function K8({draft:e,lead:t}){const n=at(),r=M(u=>ci(u,t==null?void 0:t.repoId)),[o]=JS(r),i=M(u=>{var c;return((c=Xa(u,t==null?void 0:t.repoId))==null?void 0:c.dirty)??0}),l=!e.batch&&e.variants===1;return h.jsxs("div",{className:"draft-intro",children:[h.jsxs("div",{className:"draft-row hint",children:[h.jsx(Le,{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"}),h.jsxs("span",{className:"draft-variants",children:[H8.map(u=>h.jsx(Le,{variant:"ghost",on:e.variants===u,disabled:e.batch,onClick:()=>n({a:"draft-variants",n:u}),children:u},u)),h.jsx("span",{"data-tip":"Run the same prompt in N parallel worktrees, keep the best",children:"variants"})]}),h.jsx("span",{className:"draft-runs",children:h.jsx(PF,{repo:r,value:e.profile??o,onChange:u=>n({a:"draft-profile",profile:u})})})]}),t&&r&&i>0&&h.jsx("div",{className:"draft-notes",children:h.jsxs(vN,{className:"hint draft-note",checked:G1(e),disabled:!l,tip:l?`Move the ${i} uncommitted ${i===1?"file":"files"} into the new worktree, leaving ${r.defaultBranch} clean`:"One set of changes can only go into one worktree",onChange:u=>n({a:"draft-carry",v:u.currentTarget.checked}),children:[h.jsxs("span",{className:"badge-dirty",children:["~",i]})," on ",r.defaultBranch," come along"]})})]})}function W8({row:e}){const t=lt(),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 h.jsxs(Jr,{icon:e.locked?"lock":"branch",word:e.locked?"held":"discovered",tone:"quiet",below:h.jsx("div",{className:"daemon-below row-dim",children:i}),children:[h.jsxs("span",{className:"daemon-text",children:[e.locked&&`by ${e.lockReason??"another tool"}, at `,h.jsx("span",{className:"tool-hint",children:o})]}),!e.locked&&h.jsx(Le,{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=at(),l=_s(),u=OL(),c=Tt(l==null?void 0:l.worktree.id,"sending"),f=il(),p=e==="centre"&&!r&&(f!=null&&f.assumed)?f:null,m=M(y=>{var x;return((x=y.dragFiles)==null?void 0:x.at)==="chat"}),g=Zn(),w=S.useMemo(()=>DP(g),[g]);return h.jsxs("div",{className:Ue(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 x;y?rc.el=y:(x=rc.el)!=null&&x.isConnected||(rc.el=null)},children:[r?h.jsx(Wp,{active:null,archived:r,tail:h.jsx(yD,{item:r})}):o?h.jsx(Wp,{active:null,found:o,tail:h.jsx(W8,{row:o})}):h.jsx(Wp,{active:l,lead:p&&h.jsxs("p",{className:"hint chat-centre-note",children:[p.name," has ",h.jsx("code",{children:p.assumed})," and no dev server, so it is chat only for now."," ",h.jsx(Le,{variant:"inline",onClick:()=>i({a:"open",overlay:{kind:"setup",repoId:p.id}}),children:"add a dev server"})]})}),!r&&!o&&u&&!c&&h.jsx(K8,{draft:u,lead:l}),r?h.jsx(sc,{active:null,archived:r,placement:e}):o?h.jsx(sc,{active:null,found:o,placement:e}):h.jsx(sc,{active:l,draft:u,placement:e})]})}const Z8="modulepreload",q8=function(e){return"/"+e},cx={},qm=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let l=function(f){return Promise.all(f.map(p=>Promise.resolve(p).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),c=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));o=l(n.map(f=>{if(f=q8(f),f in cx)return;cx[f]=!0;const p=f.endsWith(".css"),m=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${m}`))return;const g=document.createElement("link");if(g.rel=p?"stylesheet":Z8,p||(g.as="script"),g.crossOrigin="",g.href=f,c&&g.setAttribute("nonce",c),document.head.appendChild(g),p)return new Promise((w,y)=>{g.addEventListener("load",w),g.addEventListener("error",()=>y(Error(`Unable to preload CSS for ${f}`)))})}))}function i(l){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=l,window.dispatchEvent(u),!u.defaultPrevented)throw l}return o.then(l=>{for(const u of l||[])u.status==="rejected"&&i(u.reason);return t().catch(i)})},Wk=800;function G8(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 Do=e=>`${e.worktreeId}
|
|
239
|
+
${e.ref??""}
|
|
240
|
+
${e.since??""}
|
|
241
|
+
${e.path}`;class V8{constructor(t){Rt(this,"files",new Map);Rt(this,"looks",new Map);this.d=t}start(){var i,l;let t=this.d.store.getState();const n=this.d.store.subscribe(()=>{const u=this.d.store.getState(),c=t;t=u,this.follow(c,u)}),r=()=>{const u=this.d.store.getState().editor;u&&!u.loose&&this.refresh(Do(u))};(i=this.d.win)==null||i.addEventListener("focus",r);const o=()=>{for(const[u,c]of this.files)c.timer!==void 0&&this.saveNow(u)};return(l=this.d.win)==null||l.addEventListener("pagehide",o),()=>{var u,c;n(),(u=this.d.win)==null||u.removeEventListener("focus",r),(c=this.d.win)==null||c.removeEventListener("pagehide",o)}}receive(t){const n=t.t==="file-read"?this.looks.get(t.seq):void 0;if(n&&t.t==="file-read"){this.looks.delete(t.seq),n(t.error||t.binary||t.tooLarge||t.version===null?null:t.after);return}const r=this.files.get(Do(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=Ko();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=Do(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(Do(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(Do(t)),r=n==null?void 0:n.conflict;!(n!=null&&n.buffer)||!r||(n.base={text:r.after,version:r.version},this.setConflict(n,null),n.pending=n.buffer.text(),this.next(n))}follow(t,n){var i,l;t.connected&&!n.connected&&this.dropped();const r=(i=n.editor)!=null&&i.loose?null:n.editor,o=(l=t.editor)!=null&&l.loose?null:t.editor;if(o&&(!r||Do(o)!==Do(r))&&this.closed(Do(o)),r&&(!o||o.seq!==r.seq)&&this.opened(r),!t.connected&&n.connected)for(const u of this.files.values())u.reread=!0,this.next(u);else r&&o&&o.seq===r.seq&&_o(t,r.worktreeId).git!==_o(n,r.worktreeId).git&&this.refresh(Do(r))}opened(t){const n=Do(t);let r=this.files.get(n);r||(r={file:{worktreeId:t.worktreeId,path:t.path,...t.ref?{ref:t.ref}:{},...t.since?{since:t.since}:{}},open:!0,base:null,out:null,pending:null,reread:!1,writable:!1,conflict:null,buffer:null,timer:void 0,blame:null},this.files.set(n,r)),r.open=!0,r.reread=!0,r.conflict&&this.d.store.dispatch({a:"editor-conflict",file:r.file,theirs:r.conflict}),this.next(r)}closed(t){const n=this.files.get(t);n&&(n.open=!1,this.next(n))}refresh(t){const n=this.files.get(t);!n||n.file.ref||(n.reread=!0,this.next(n))}dropped(){for(const t of this.looks.values())t(null);this.looks.clear();for(const t of this.files.values())t.out&&(t.out.write!==void 0&&(t.pending??(t.pending=t.out.write)),t.out=null,t.reread=!0)}next(t){var l;if(t.out||!this.d.store.getState().connected)return;const{worktreeId:n,path:r,ref:o,since:i}=t.file;if(t.reread){t.reread=!1;const u=Ko();t.out={seq:u},this.d.send({t:"read-file",worktreeId:n,path:r,ref:o,since:i,seq:u});return}if(t.pending!==null&&t.base&&t.pending===t.base.text&&(t.pending=null),t.pending!==null&&t.writable&&!t.conflict&&!o){const u=t.pending,c=Ko();t.pending=null,t.out={seq:c,write:u},this.d.send({t:"write-file",worktreeId:n,path:r,content:u,base:((l=t.base)==null?void 0:l.version)??null,seq:c});return}!t.open&&!t.buffer&&t.pending===null&&!t.conflict&&this.files.delete(Do(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:u,binary:c,tooLarge:f}=n;t.writable=u,t.open&&(this.d.store.dispatch({a:"editor-read",file:r,disk:{before:o,after:i,version:l,writable:u,binary:c,tooLarge:f}}),!c&&!f&&(l!==null||r.ref)&&this.askBlame(t,l));const p={after:t.buffer?t.buffer.normalize(i):i,version:l};if(!t.base){t.base={text:p.after,version:l};return}const m=((g=t.buffer)==null?void 0:g.text())??t.pending??t.base.text;switch(G8(t.base,m,t.pending,p)){case"same":break;case"adopt":t.base={text:p.after,version:l};break;case"apply":(w=t.buffer)==null||w.replace(p.after),t.base={text:p.after,version:l};break;case"gone":t.base={text:"",version:null},t.open&&this.d.store.dispatch({a:"close-editor"});break;case"conflict":this.setConflict(t,p);return}this.setConflict(t,null)}askBlame(t,n){const r=Ko();t.blame={seq:r,version:n};const{worktreeId:o,path:i,ref:l}=t.file;this.d.send({t:"blame-file",worktreeId:o,path:i,ref:l,seq:r})}blamed(t,n){const r=t.blame;if(!r||r.seq!==n.seq||(t.blame=null,!t.open))return;const{commits:o,lines:i}=n;this.d.store.dispatch({a:"editor-blame",file:t.file,blame:{commits:o,lines:i,version:r.version}})}written(t,n,r){if(r.ok){t.base={text:n,version:r.version};return}if(r.reason==="changed"){t.pending??(t.pending=n),t.reread=!0;return}t.writable=!1,t.pending=null,this.d.store.dispatch({a:"editor-refused",file:t.file,message:r.message??`not saved: ${t.file.path}`})}setConflict(t,n){t.conflict===n||t.conflict&&n&&t.conflict.version===n.version||(t.conflict=n,t.open&&this.d.store.dispatch({a:"editor-conflict",file:t.file,theirs:n}))}attach(t,n){const r=this.files.get(t);if(r){if(n){r.buffer=n,r.base&&(r.base={...r.base,text:n.normalize(r.base.text)}),r.conflict&&r.pending!==null&&n.replace(r.pending);return}r.buffer&&((r.timer!==void 0||r.conflict)&&(r.pending=r.buffer.text()),this.cancelTimer(r),r.buffer=null,this.next(r))}}edited(t){const n=this.files.get(t);!(n!=null&&n.buffer)||!n.writable||n.file.ref||(this.cancelTimer(n),n.timer=this.d.timers.set(()=>{n.timer=void 0,this.saveNow(t)},Wk))}saveNow(t){const n=this.files.get(t);if(!(n!=null&&n.buffer))return;this.cancelTimer(n);const r=n.buffer.text();r.length>Ad||(n.pending=r,this.next(n))}cancelTimer(t){t.timer!==void 0&&(this.d.timers.clear(t.timer),t.timer=void 0)}}const bN={attach:()=>{},edited:()=>{},saveNow:()=>{}},Y8=e=>({timers:{set:(t,n)=>setTimeout(t,n),clear:t=>clearTimeout(t)},win:typeof window>"u"?null:window,send:e}),Gm=new Map;function X8(e){const t=Gm.get(e.seq);return t?(Gm.delete(e.seq),t(e),!0):!1}function Q8(e,t,n,r){if(e.kind==="bytes")return bN;if(e.kind==="grant")return J8(e,t,n,r);const o=e.handle;let i=null,l,u=null,c=Promise.resolve(),f=!1;const p=()=>(u??(u=(async()=>await o.queryPermission({mode:"readwrite"})==="granted"?!0:await o.requestPermission({mode:"readwrite"})==="granted")().catch(()=>!1)),u),m=()=>{l!==void 0&&r.timers.clear(l),l=void 0},g=()=>{f||(f=!0,m(),n(`read-only: the browser would not save ${t}`))},w=async b=>{if(!await p())return g();const j=await o.createWritable();await j.write(b),await j.close()},y=()=>{if(!i||f)return;m();const b=i.text();c=c.then(()=>w(b)).catch(g)},x=()=>{l!==void 0&&y()};return{attach(b){var j,N;if(b){i=b,(j=r.win)==null||j.addEventListener("pagehide",x);return}l!==void 0&&y(),i=null,(N=r.win)==null||N.removeEventListener("pagehide",x)},edited(){!i||f||(p().then(b=>{b||g()}),m(),l=r.timers.set(y,Wk))},saveNow:y}}function J8(e,t,n,r){let o=null,i,l=e.version,u=!1,c=null,f=!1;const p=()=>{i!==void 0&&r.timers.clear(i),i=void 0},m=x=>{f||(f=!0,p(),c=null,n(x))},g=x=>{if(!r.send)return;const b=Ko();u=!0,Gm.set(b,j=>{if(u=!1,j.ok?l=j.version:j.reason==="changed"?m(`read-only: ${t} changed on disk; open it again to edit`):m(j.message??`not saved: ${t}`),c!==null&&!f){const N=c;c=null,g(N)}}),r.send({t:"write-loose",id:e.id,content:x,base:l,seq:b})},w=()=>{if(!o||f)return;p();const x=o.text();x.length>Ad||(u?c=x:g(x))},y=()=>{i!==void 0&&w()};return{attach(x){var b,j;if(x){o=x,(b=r.win)==null||b.addEventListener("pagehide",y);return}i!==void 0&&w(),o=null,(j=r.win)==null||j.removeEventListener("pagehide",y)},edited(){!o||f||(p(),i=r.timers.set(w,Wk))},saveNow:w}}function Zk({kind:e,className:t,height:n,resizable:r=!0,onDragStart:o,title:i,tabs:l,actions:u,menu:c,full:f,onToggleFull:p,onClose:m,closeHint:g="esc",children:w}){const y=fn("pane"),x=p&&h.jsxs(Le,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:p,"data-tip":f?"Split view: show the preview above":"Full height: hide the preview",children:[h.jsx(jt,{name:f?"split":"full",className:"icon-inline"})," ",f?"split":"full"]}),b=h.jsx(Ot,{icon:"close",label:"Close",hint:g,onClick:m});return h.jsxs("div",{className:`pane ${t}`,"data-pane":e,tabIndex:-1,style:n===void 0?void 0:{height:n},children:[r&&h.jsx("div",{className:"pane-resize",onPointerDown:o}),h.jsx("div",{className:Ue("pane-head",l&&"pane-head-tabs"),...y.contextMenu(()=>(c==null?void 0:c())??[]),children:l?h.jsx(jf,{...l,end:h.jsxs(h.Fragment,{children:[u,x,b]})}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"pane-title",children:i}),u,x,b]})}),w]})}function e9({src:e,path:t,full:n,onFull:r}){const o=fn("editor");return h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button",className:"editor-image",onClick:()=>r(!0),...o.contextMenu(()=>yc(e,{open:()=>r(!0)})),children:h.jsx("img",{src:e,alt:t})}),n&&h.jsx(pk,{owner:"editor",onClose:()=>r(!1),menu:()=>yc(e),children:h.jsx("img",{src:e,alt:t})})]})}const t9={image:e9};function n9({kind:e,src:t,path:n,openSeq:r,focus:o,full:i,onFull:l}){const u=S.useRef(null);vt([r],()=>{var f;o&&((f=u.current)==null||f.focus())});const c=t9[e];return h.jsx("div",{ref:u,className:"editor-viewer",tabIndex:-1,children:h.jsx(c,{src:t,path:n,full:i,onFull:l})})}const r9="img[src], source[src], video[src], audio[src], video[poster], link[href], object[data]";function o9(e,t){if(!t)return e;const n=new DOMParser().parseFromString(e,"text/html");let r=!1;for(const o of n.querySelectorAll(r9))for(const i of["src","href","poster","data"]){const l=o.getAttribute(i),u=l===null?null:mk(t.dir,l);u&&(o.setAttribute(i,t.urls.worktreeFile(t.worktreeId,u,t.version)),r=!0)}return r?`${n.doctype?`<!doctype html>
|
|
242
|
+
`:""}${n.documentElement.outerHTML}`:e}function s9({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:i}){const l=S.useRef(null);vt([o],()=>{var p;i&&((p=l.current)==null||p.focus())});const u=$r(),c=D_(t),f=S.useMemo(()=>o9(e,r===void 0?null:{worktreeId:n,dir:c,version:r,urls:u}),[e,n,c,r,u]);return h.jsx("div",{ref:l,className:"editor-viewer",tabIndex:-1,children:h.jsx("iframe",{className:"editor-frame",title:t,sandbox:"",srcDoc:f})})}function i9(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 a9(e){const t=new Map,n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=i9(n.map(o=>Number(o.tagName[1])));return n.map((o,i)=>{var c;const l=((c=o.textContent)==null?void 0:c.trim())??"",u=t.get(l)??0;return t.set(l,u+1),{id:`${u}
|
|
243
|
+
${l}`,level:Number(o.tagName[1]),depth:r[i],text:l,el:o}})}const l9=48,c9=16;function u9({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:i,onChat:l}){lt();const u=$r(),c=at(),f=D_(t),p=Ck(e,r===void 0?void 0:{base:{worktreeId:n,dir:f,version:r,urls:u}}),m=S.useRef(null),g=S.useRef(null),[w,y]=S.useState([]),[x,b]=S.useState(-1),[j,N]=S.useState(null),T=A=>{var I;if(N(null),A){const _=window.getSelection();_==null||_.removeAllRanges(),_==null||_.addRange(A)}(I=m.current)==null||I.focus()};vt([o],()=>{var A;i&&((A=m.current)==null||A.focus())}),vt([p],()=>{m.current&&y(a9(m.current))}),S.useLayoutEffect(()=>{const A=m.current;if(!A)return;let I=0;const _=()=>{if(I=0,A.scrollTop+A.clientHeight>=A.scrollHeight-1){b(w.length-1);return}const z=A.scrollTop+l9;let q=-1;for(let se=0;se<w.length;se++)w[se].el.offsetTop<=z&&(q=se);b(q)},P=()=>{I||(I=requestAnimationFrame(_))};return _(),A.addEventListener("scroll",P),()=>{A.removeEventListener("scroll",P),I&&cancelAnimationFrame(I)}},[w]);const R=A=>{var _,P;const I=(_=w[A])==null?void 0:_.el;(P=m.current)==null||P.scrollTo({top:Math.max(0,I?I.offsetTop-c9:0),behavior:"smooth"})},$=A=>{const I=A.target.closest("a"),_=I==null?void 0:I.getAttribute("href");if(!_||(I==null?void 0:I.target)==="_blank")return;A.preventDefault();const P=mk(f,_);P&&er({dispatch:c},{worktreeId:n,path:P,view:Fi(P)})},W=A=>{var I;if(hk(A)){A.preventDefault(),A.stopPropagation();const _=(g.current&&Im(g.current))??"";N(P=>({seed:_||(P==null?void 0:P.seed)||"",seq:((P==null?void 0:P.seq)??0)+1}));return}if(A.key==="Escape"&&j){A.stopPropagation(),T(null);return}if(R_(A)&&g.current){A.preventDefault(),O_(g.current);return}if(((I=Ix(A))==null?void 0:I.id)==="composer"&&g.current){const _=Im(g.current);if(!_)return;A.preventDefault(),A.stopPropagation(),l(_)}};return h.jsxs(h.Fragment,{children:[h.jsx("div",{ref:m,className:"editor-viewer editor-preview",tabIndex:-1,onClick:$,onKeyDown:W,children:h.jsx("div",{ref:g,className:"md md-preview",dangerouslySetInnerHTML:{__html:p}})}),j&&h.jsx(I_,{root:m,body:g,seed:j.seed,seq:j.seq,onClose:T}),h.jsx(d9,{heads:w,at:x,onJump:R})]})}function d9({heads:e,at:t,onJump:n}){const[r,o]=S.useState(!1),i=S.useRef(null);return e.length<2?null:h.jsxs(h.Fragment,{children:[h.jsx("div",{ref:i,className:"editor-outline","aria-hidden":!0,onPointerEnter:l=>{l.pointerType==="mouse"&&o(!0)},onClick:()=>o(l=>!l),children:e.map((l,u)=>h.jsx("span",{className:"editor-outline-tick","data-level":l.level,"data-state":mr({current:u===t})},l.id))}),r&&h.jsx(Ss,{className:"editor-outline-list",anchor:()=>{var l;return((l=i.current)==null?void 0:l.getBoundingClientRect())??null},placement:{side:"right",align:"center",cover:!0},trigger:i.current,onDismiss:()=>o(!1),onPointerLeave:l=>{l.pointerType==="mouse"&&o(!1)},children:e.map((l,u)=>h.jsx("button",{type:"button",className:"row editor-outline-row","data-level":l.level,"data-state":mr({current:u===t}),onClick:()=>n(u),children:h.jsx("span",{className:"editor-outline-label",style:{"--outline-depth":l.depth},children:l.text})},l.id))})]})}function f9({absPath:e,onReveal:t}){const n=fn("editor"),{host:r}=$r();return Yg(r)?h.jsxs(Le,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",...n.dropdown(()=>Bi(e,t,r),"right"),children:["open in ",h.jsx(jt,{name:"caret",className:"icon-inline"})]}):null}const h9=S.lazy(async()=>{const[e]=await Promise.all([qm(()=>import("./Editor-ofBOHWJt.js").then(t=>t.E),__vite__mapDeps([0,1,2])),qm(()=>import("./grammar-CFa79rtH.js"),[]).then(t=>t.grammarsReady)]);return e});function ux({what:e}){return mE(!0,3e3)?h.jsx("div",{className:"empty",children:h.jsxs("span",{className:"live-text",children:["loading ",e]})}):null}const p9=()=>{},m9={diff:"diff",file:"text",preview:"book"};function g9(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 xN({editor:e,height:t,full:n=!1,onToggleFull:r,onDragStart:o,placement:i="stack"}){const l=i==="screen",u=at(),c=Zn(),f=lt(),p=$r(),m=hE(),g=yf(),{worktreeId:w,path:y,ref:x,since:b}=e,j=e.loose,N=M(L=>{var re;return((re=So(L))==null?void 0:re.id)===w}),T=M(L=>{var te,K;const re=(te=dn(L,w))==null?void 0:te.worktree;return re?re.path:(K=So(L))==null?void 0:K.path}),R=j?j.source.kind==="grant"?j.source.path:null:T?`${T}/${y}`:y,$=x!==void 0,W=S.useMemo(()=>j?Q8(j.source,y,L=>u({a:"editor-refused",file:{worktreeId:w,path:y},message:L}),Y8(f?L=>f.send(L):null)):(m==null?void 0:m.bind({worktreeId:w,path:y,...x?{ref:x}:{},...b?{since:b}:{}}))??bN,[m,w,y,x,b,j,u,f]),A=M(L=>_o(L,w).changedRanges[y]);S.useEffect(()=>{!A&&!$&&!N&&!j&&(f==null||f.send({t:"changed-ranges",worktreeId:w,path:y}))},[w,y,A,$,N,j,f]);const I=(A==null?void 0:A.offset)??0,_=e.disk,P=e.view??"diff",z=(_==null?void 0:_.before)==="",q=IE(y,z).filter(L=>L!==P&&!(j&&L==="diff")),se=(j==null?void 0:j.source.kind)==="grant"?j.source:null,Y=$||N||j&&!se?null:K2(y),[ge,ke]=S.useState(!1),oe=e.line&&!e.line.fiber?e.line.n:void 0;return h.jsxs(Zk,{kind:"editor",className:Ue("editor-pane",n&&"full"),height:n||l?void 0:t,resizable:!n&&!l,onDragStart:o??p9,title:$?`${y} at ${x==null?void 0:x.slice(0,7)}`:b?`${y}, last turn`:y,menu:()=>T&&!j?ys({id:w,dir:T},y,{discard:!$&&!N,kept:N,ref:x,showing:e.view??void 0,added:z},{sock:f,dispatch:u}):[],onClose:()=>u({a:"close-editor"}),full:n,onToggleFull:l?void 0:r,actions:h.jsxs(h.Fragment,{children:[!Y&&q.map(L=>h.jsxs(Le,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>u({a:"editor-view",v:L}),"data-tip":g9(L,P),children:[h.jsx(jt,{name:m9[L],className:"icon-inline"})," ",L]},L)),Y==="image"&&h.jsxs(Le,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>ke(!0),"data-tip":"Full size: see the picture over the window",children:[h.jsx(jt,{name:"zen",className:"icon-inline"})," full size"]}),!N&&R!==null&&h.jsx(f9,{absPath:R,onReveal:j?void 0:()=>f==null?void 0:f.send({t:"reveal",worktreeId:w,path:y})})]}),children:[_&&h.jsx(k9,{editor:e,disk:_,files:m}),h.jsx("div",{className:"editor-body",children:_?Y?h.jsx(n9,{kind:Y,src:se?p.loose(se.id,se.version):p.worktreeFile(w,y,_.version),path:y,openSeq:e.seq,focus:e.focus,full:ge,onFull:ke}):_.binary?h.jsx("div",{className:"empty",children:"not a text file: open it in another editor"}):_.tooLarge?h.jsx("div",{className:"empty",children:"too large to open here: open it in another editor"}):P==="preview"&&pf(y)==="html"?h.jsx(s9,{text:_.after,path:y,worktreeId:w,version:$||N||j?void 0:_.version,openSeq:e.seq,focus:e.focus}):P==="preview"?h.jsx(u9,{text:_.after,path:y,worktreeId:w,version:$||N||j?void 0:_.version,openSeq:e.seq,focus:e.focus,onChat:L=>$0(c,{worktreeId:w,text:L,name:y})}):h.jsx(ok,{pane:!0,children:h.jsx(S.Suspense,{fallback:h.jsx(ux,{what:P}),children:h.jsx(h9,{file:{worktreeId:w,path:y,...x?{ref:x}:{},...b?{since:b}:{}},disk:_,blame:e.blame,view:P,openSeq:e.seq,line:oe,focus:e.focus,readOnly:$||!_.writable||l,numbers:!l,theme:g,sync:W,onCopy:j?void 0:(L,re,te)=>ZL(te,{worktreeId:w,path:L,...re,...x?{ref:x}:{}}),onChat:(L,re)=>$0(c,re&&(j?{worktreeId:w,text:re.text,name:L}:{worktreeId:w,text:re.text,source:{path:L,startLine:re.startLine,endLine:re.endLine,...x?{ref:x}:{}}})),onNew:()=>c.dispatch({a:"open-draft"}),onLineHover:$||j?void 0:L=>{L==null?en.post(w,{type:"highlight-clear"}):en.post(w,{type:"highlight-file",path:y,ranges:[[L+I,L+I]]})}},`${w}
|
|
244
|
+
${j?"loose":x??b??""}
|
|
245
|
+
${y}`)})}):h.jsx(ux,{what:y},y)})]})}function k9({editor:e,disk:t,files:n}){const{worktreeId:r,path:o,ref:i,since:l,conflict:u}=e,c={worktreeId:r,path:o,...i?{ref:i}:{},...l?{since:l}:{}};if(u){const f=u.version===null;return h.jsxs("div",{className:"editor-note",children:[h.jsx("span",{className:"editor-note-text",children:f?"deleted on disk; your edits are not saved":"changed on disk; your edits are not saved"}),h.jsx(Le,{variant:"outline",onClick:()=>n==null?void 0:n.reload(c),"data-tip":f?"Close the file; your edits go with it":"Take the file as it is on disk; undo brings your edits back",children:f?"close":"reload"}),h.jsx(Le,{variant:"outline",tone:"danger",onClick:()=>n==null?void 0:n.keepMine(c),"data-tip":f?"Save your edits as the file again":"Save your edits over the file on disk",children:"keep mine"})]})}return e.refused?h.jsx("div",{className:"editor-note",children:h.jsx("span",{className:"hint",children:e.refused})}):e.loose&&!t.writable&&!t.tooLarge&&!t.binary?h.jsx("div",{className:"editor-note",children:h.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?h.jsx("div",{className:"editor-note",children:h.jsx("span",{className:"hint",children:"read-only: Toyon does not run this worktree"})}):null}const Yr={title:"Add a machine",lead:"Pick a machine on your tailnet, or type an address.",leadTyped:"Type the address from the screen of the other machine.",noneOnTailnet:"No other machine on your tailnet answers as a Toyon yet.",missing:"A machine missing here needs the phone button pressed on it, or `toyon remote --tailscale`.",listed:"listed",request:"request access",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 ${Xd(e)}.`,waiting:(e,t)=>`Toyon on ${Xd(e)} is asking whether to let ${t} in.`,added:e=>`Added ${e}.`,notKept:e=>`Let in, but not listed: ${e}`,add:"add"};function Xd(e){try{return new URL(e).host}catch{return e}}function EN(e,t,n){const r=Xd(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?`}}const w9=1e4;function y9(){const e=at(),t=To(),n=$r(),[r,o]=S.useState(""),[i,l]=S.useState({kind:"idle"}),u=pE(),c=()=>e({a:"close"}),f=i.kind==="asking"||i.kind==="waiting",p=!f&&i.kind!=="added",m=yE(()=>eM(n),w9,p),g=S.useRef(new AbortController);S.useEffect(()=>{const N=g.current;return()=>N.abort()},[]);const w=async N=>{if(f)return;l({kind:"asking",origin:N});const T=await L1(N,g.current.signal,W=>l({kind:"waiting",origin:N,word:W}));if(g.current.signal.aborted)return;if(typeof T=="string"){l({kind:"failed",line:EN(T,N,"this page")});return}const R=t.serving(),$=await nM(_g(R.origin,R.token),N,T.token);l($?{kind:"failed",line:Yr.notKept($)}:{kind:"added",name:t.displayName(N)})},y=()=>{const N=Zj(r);N?w(N):l({kind:"failed",line:Yr.notAnAddress})},x=(m??[]).filter(N=>N.toyon!==null),b=(m??[]).filter(N=>N.toyon===null),j=(()=>{switch(i.kind){case"asking":return Yr.asking(i.origin);case"waiting":return Yr.waiting(i.origin,i.word);case"added":return Yr.added(i.name);case"failed":return i.line;case"idle":return m===null?Yr.leadTyped:Yr.lead}})();return h.jsxs(Pc,{boxClass:"add-machine-card",onClose:c,children:[h.jsx("div",{className:"add-machine-title",children:Yr.title}),i.kind==="waiting"&&h.jsx("div",{className:"knock-word add-machine-word",children:i.word}),h.jsx("p",{className:Ue("add-machine-line",i.kind==="failed"&&"add-machine-failed"),children:j}),p&&m&&h.jsxs("div",{className:"add-machine-list",children:[x.map(N=>{var $;const T=`https://${N.host}`,R=t.get(T)!==null;return h.jsxs("div",{className:"add-machine-row",children:[h.jsxs("div",{className:"add-machine-machine",children:[h.jsx("span",{className:"add-machine-name",children:(($=N.toyon)==null?void 0:$.machine)??N.name}),h.jsx("span",{className:"hint",children:N.host})]}),R?h.jsx("span",{className:"hint",children:Yr.listed}):h.jsx(Le,{variant:"outline",size:"sm",onClick:()=>void w(T),children:Yr.request})]},N.host)}),x.length===0&&h.jsx("p",{className:"add-machine-line",children:Yr.noneOnTailnet}),b.length>0&&h.jsx("p",{className:"hint add-machine-note",children:Yr.missing})]}),p&&h.jsxs("form",{className:"add-machine-form",onSubmit:N=>{N.preventDefault(),y()},children:[h.jsx(Eo,{ref:u,size:"md",font:"ui",value:r,placeholder:Yr.placeholder,"aria-label":"Address of the other machine",onChange:N=>o(N.target.value),className:"add-machine-field"}),h.jsx(Le,{type:"submit",variant:"outline",disabled:!r.trim(),children:Yr.add})]}),h.jsx("div",{className:"add-machine-actions",children:h.jsx(Le,{tone:"quiet",onClick:c,children:i.kind==="added"?"done":"cancel"})})]})}function qk(e,{sock:t}){var r;const n=[];return e.canLogout&&((r=e.auth)==null?void 0:r.kind)!=="none"&&n.push({id:"logout",label:"log out",danger:!0,onClick:()=>t==null?void 0:t.send({t:"agent-logout",agent:e.id})}),!e.available&&!e.installing&&n.push({id:"install",label:e.onDemand&&e.reason==="not installed"?"install":"install again",onClick:()=>t==null?void 0:t.send({t:"install-agent",agent:e.id})}),n}function _N(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 v9=(e,t)=>{const n=hm(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"}},Qd="https://github.com/toyon-dev/toyon",b9=e=>`${Qd}/releases/tag/v${e}`,x9=`${Qd}/releases/latest`,E9=4e3;function _9(e,t,n,r){if(r==="asking")return{value:`${e} checking`,text:`Asking ${hm(n)} for the newest version`,act:"check",busy:!0};const o=hm(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(U2(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 S9(e,t,n,r,o,i=!1,l=null,u=null){if(n){if(n.restarting){const f=n.installed??n.running,p=n.restarting.length>0?t_(n.restarting):"Toyon is restarting; this page reloads when it is back";return{value:`${f} restarting`,text:p,act:"restart",busy:!0}}if(n.installing){const f=n.latest??n.installed??n.running;return{value:`${f} installing`,text:`Installing Toyon ${f}`,act:"update",busy:!0}}if(n.failed){const f=n.failed.line.replace(/\.$/,"");return{value:`${n.running} update failed`,text:`Installing Toyon ${n.failed.version} stopped: ${f}. Press to try again, or run ${n.failed.command}`,act:"update",busy:!1}}if(n.installed)return{value:`${n.installed} ready`,text:`Toyon ${n.installed} is installed and ${n.running} is still running. It restarts onto the new one when nothing is busy; press to restart now`,act:"restart",busy:!1};if(n.latest)return{value:`${n.latest} out`,text:n.method==="npx"?`Toyon ${n.latest} is out. This copy runs with npx, so run npx toyon@${n.latest} to use it`:`Toyon ${n.latest} is out and installs when nothing is busy; press to install now`,act:"update",busy:!1}}const c=_N(r,o,i);return c?c.busy?{value:`${e} rebuilding`,text:c.text,act:"rebuild",busy:!0}:c.reload?{value:`${e} rebuilt`,text:c.text,act:"reload",busy:!1}:c.build==="try again"?{value:`${e} rebuild stopped`,text:c.text,detail:c.detail,act:"rebuild",busy:!1}:{value:`${e} behind`,text:c.text,act:c.build?"rebuild":"restart",busy:!1}:u?_9(e,t,l,u):{value:e,text:`Toyon ${e}, ${v9(t,l)}`,act:"check",busy:!1}}function N9(e,t){const n=r=>()=>window.open(r,"_blank");return Dn([t?[{id:"check-update",label:"check for updates",...t.off?{disabled:t.off}:{},onClick:t.run}]:[],[{id:"release-notes",label:`release notes for ${e}`,onClick:n(b9(e))},{id:"latest-release",label:"latest release",onClick:n(x9)},{id:"repo",label:"Toyon on GitHub",onClick:n(Qd)},{id:"report",label:"report a problem",onClick:n(`${Qd}/issues/new`)}],[{id:"copy-version",label:"copy version",onClick:()=>Qt(e)}]])}const T9=Oj.map(e=>({title:e,rows:Pj(e).map(t=>[At(t),Jl[t].label])}));function j9(){const e=at(),t=lt(),n=fn("keys"),r=M(m=>m.themePrefs),o=M(m=>m.themes),i=M(m=>m.chatSide),l=M(m=>m.keepAwake),u=Ug(),c=M(m=>m.agents),f=il(),p=m=>{e({a:"palette-return",v:{mode:"keys",q:""}}),e(m)};return h.jsxs(Pc,{bare:!0,boxClass:"keys-stack",id:"keys-help",onClose:()=>e({a:"close"}),children:[h.jsxs("div",{className:"keys-card",children:[h.jsxs("div",{children:[f&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"section-title keys-h",children:f.name}),h.jsxs("div",{className:"keys-setting",children:[h.jsx("span",{className:"keys-d",children:"processes"}),h.jsx(Le,{variant:"field",mono:!0,className:"keys-chip","data-tip":`edit the install + start commands in ${f.configFile}`,onClick:()=>e({a:"open",overlay:{kind:"setup",repoId:f.id}}),...n.contextMenu(()=>$f(f,f.id,{sock:t,dispatch:e})),children:h.jsx("span",{className:"keys-v",children:Object.keys(f.config.run).join(" + ")||"not set up"})})]})]}),h.jsx("div",{className:"section-title keys-h",children:"Agents"}),c.map(m=>h.jsx(I9,{agent:m},m.id))]}),h.jsxs("div",{children:[h.jsx("div",{className:"section-title keys-h",children:"Appearance"}),h.jsxs("div",{className:"keys-setting",children:[h.jsx("span",{className:"keys-d",children:"mode"}),h.jsx(Le,{variant:"field",mono:!0,onClick:()=>p({a:"open",overlay:{kind:"appearance"}}),children:Kd[r.mode]})]}),h.jsxs("div",{className:"keys-setting",children:[h.jsx("span",{className:"keys-d",children:"theme"}),h.jsx(Le,{variant:"field",mono:!0,onClick:()=>p({a:"open",overlay:{kind:"theme",slot:"theme"}}),children:hf(r,o,u).name})]}),h.jsxs("div",{className:"keys-setting",children:[h.jsx("span",{className:"keys-d",children:"chat side"}),h.jsx(Le,{variant:"field",mono:!0,onClick:()=>e({a:"toggle-chat-side"}),children:i})]}),h.jsx("div",{className:"section-title keys-h",children:"Toyon"}),l!==null&&h.jsxs("div",{className:"keys-setting",children:[h.jsx("span",{className:"keys-d",children:"keep awake"}),h.jsx(Le,{variant:"field",mono:!0,onClick:()=>p({a:"open",overlay:{kind:"keep-awake"}}),children:Wd[l]})]}),h.jsx(C9,{}),h.jsx(A9,{})]})]}),h.jsx("div",{className:"keys-card",children:T9.map(m=>h.jsxs("div",{children:[h.jsx("div",{className:"section-title keys-h",children:m.title}),m.rows.map(([g,w])=>h.jsxs("div",{className:"keys-row",children:[h.jsx(Wo,{k:g}),h.jsx("span",{className:"keys-d",children:w})]},g))]},m.title))})]})}function C9(){const e=lt(),t=at(),n=fn("keys"),r=M(j=>j.version),o=M(j=>j.install),i=M(j=>j.registry),l=M(j=>j.update),u=M(j=>j.self),c=M(j=>j.rebuilt),f=M(j=>j.repos),p=M(j=>j.managed.updates),m=M(j=>j.updateCheck),g=S9(r,o,l,u,f,c,i,m),w=!p&&(g.act==="update"||g.act==="check"),y=g.settles&&m&&m!=="asking"?m:null;S.useEffect(()=>{if(!y)return;const j=()=>t({a:"update-check-settle",check:y}),N=setTimeout(j,E9);return()=>{clearTimeout(N),j()}},[y,t]);const x=()=>{g.act==="restart"?e==null||e.send({t:"restart-daemon"}):g.act==="reload"?window.location.reload():g.act==="rebuild"&&u?e==null||e.send({t:"run-after-land",repoId:u.repoId}):g.act==="update"?e==null||e.send({t:"update-now"}):g.act==="check"&&e&&(t({a:"update-check"}),e.send({t:"check-update"}))},b=()=>N9(r,g.act==="check"&&!g.busy?{run:x,...w?{off:"managed by your organization"}:{}}:null);return h.jsxs("div",{className:"keys-setting",...n.contextMenu(b),children:[h.jsx("span",{className:"keys-d",children:"version"}),h.jsx(Le,{variant:"field",mono:!0,busy:g.busy,disabled:w,onClick:x,...Dt(w?"updates are managed by your organization":g.text,void 0,{detail:g.detail}),children:g.value})]})}function A9(){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: ${CO(e).join(", ")||"nothing turned off"}`;return h.jsx("div",{className:"hint",children:t})}function SN(e){return e.available?e.auth?e.auth.kind==="none"?"not logged in":e.auth.label:"ready":e.installing?"installing":"not installed"}function NN(e){var n,r;return e.available?e.auth?[e.auth.detail,(n=e.auth.account)==null?void 0:n.email,(r=e.auth.account)==null?void 0:r.organization].filter(Boolean).join(" · ")||e.auth.label:"installed; it names the account it runs on the first time it runs":e.reason??"not installed"}function I9({agent:e}){const t=at(),n=lt(),r=fn("keys");return h.jsxs("div",{className:"keys-setting",children:[h.jsx("span",{className:"keys-d",children:e.name}),h.jsx(Le,{variant:"field",mono:!0,"data-tip":NN(e),...r.contextMenu(()=>qk(e,{sock:n})),onClick:()=>{t({a:"palette-return",v:{mode:"keys",q:""}}),t({a:"open",overlay:{kind:"agent-page",agent:e.id}})},children:SN(e)})]})}function R9({agentId:e}){const t=at(),n=lt(),r=il(),o=M(g=>g.home),i=M(g=>g.agents.find(w=>w.id===e)??null),l=M(g=>g.agentConfigs[e]??null),u=fn("keys");if(S.useEffect(()=>{n==null||n.send({t:"agent-config",agent:e,...r?{repoId:r.id}:{}})},[n,e,r]),!i)return null;const c=qk(i,{sock:n}),f=()=>t({a:"close",back:!0}),p=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 h.jsx(Pc,{bare:!0,boxClass:"keys-stack",onClose:f,children:h.jsxs("div",{className:"keys-card keys-settings",children:[h.jsx("div",{className:"agent-page-back",children:h.jsx(Ot,{icon:"back",label:"back to settings",hint:"esc",onClick:f})}),h.jsx("div",{className:"section-title keys-h",children:i.name}),h.jsxs("div",{className:"keys-setting",children:[h.jsx("span",{className:"keys-d",children:"signed in"}),h.jsx(Le,{variant:"field",mono:!0,"data-tip":NN(i),disabled:c.length===0,...u.dropdown(()=>c,"right"),children:SN(i)})]}),h.jsxs("div",{className:"keys-setting",children:[h.jsx("span",{className:"keys-d",children:"commit messages"}),h.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"})]}),h.jsx("div",{className:"section-title keys-h",children:"MCP servers it will load"}),l===null?h.jsx("div",{className:"keys-setting",children:h.jsx("span",{className:"keys-d",children:"reading…"})}):l.servers.length===0?h.jsxs("div",{className:"keys-setting",children:[h.jsx("span",{className:"keys-d",children:"none configured"}),h.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=>h.jsx($9,{s:g},`${g.scope}:${g.name}`)),l&&l.files.length>0&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"section-title keys-h",children:"the files it reads"}),l.files.map(g=>h.jsxs("div",{className:"keys-setting",children:[h.jsx("span",{className:"keys-d",children:g.label}),g.exists?h.jsx(Le,{variant:"field",mono:!0,"data-tip":`reveal ${p(g.path)} in Finder`,onClick:()=>m(g),children:p(g.path)}):h.jsxs("span",{className:"keys-d",children:["not present: ",p(g.path)]})]},g.id))]})]})})}function $9({s:e}){return h.jsxs("div",{className:"keys-setting",children:[h.jsx("span",{children:e.name}),h.jsx("span",{className:"keys-d",children:e.detail?`${e.scope} · ${e.detail}`:e.scope})]})}function O9(){const e=at(),t=lt(),n=M(o=>o.agents),r=M(o=>o.defaultAgent);return h.jsx(Rr,{items:n,filter:(o,i)=>o.filter(l=>Es(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=>qk(o,{sock:t}),placeholder:"default agent for new worktrees",keys:{pick:"sets",back:"closes"},row:o=>h.jsx(Hn,{label:o.name,current:o.id===r,hint:o.available?o.sandboxed?void 0:"unsandboxed":o.reason??"not installed"})})}const M9=["dark","light","system","daylight"],L9=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"});function P9(){const e=at(),t=lt(),n=M(c=>c.themePrefs),r=M(c=>c.themes),o=Ug(),i=M(c=>c.daylight),l=c=>{var f;return((f=r.find(p=>p.id===n[xg({...n,mode:c},o)]))==null?void 0:f.name)??""},u=c=>{if(c==="system")return`${o.system?"dark":"light"} now · ${l(c)}`;if(c!=="daylight")return l(c);const f=i&&i.until>Date.now()?` · ${o.daylight?"light":"dark"} at ${L9.format(i.until)}`:"";return`${o.daylight?"dark":"light"} now${f} · ${l(c)}`};return h.jsx(Rr,{items:M9,filter:(c,f)=>c.filter(p=>Es(f,Kd[p])),rowClass:()=>"picker-row",keyOf:c=>c,initialIndex:c=>c.indexOf(n.mode),onActive:c=>e({a:"preview-theme",theme:c?hf({...n,mode:c},r,o):null}),onPick:c=>{t==null||t.send({t:"set-theme",prefs:{...n,mode:c}}),e({a:"close"})},onBack:()=>e({a:"close",back:!0}),placeholder:"light/dark mode",keys:{nav:"preview",pick:"keeps",back:"reverts"},row:c=>h.jsx(Hn,{label:Kd[c],current:c===n.mode,hint:u(c)})})}const D9=2,Vm=e=>_1(e).join(" ").length<D9,z9=e=>({kind:"chat",id:e.id,name:e.name,hint:e.branch??"",fields:[e.name,e.branch??""]}),F9=e=>({kind:"chat",id:e.id,name:e.title,hint:S_(e),fields:[e.title,e.branch],prompt:e.prompt,archived:e});function B9(e,t,n){const r=_1(t),o=n==="all"&&!Vm(t);return e.filter(i=>{if(i.kind==="hit")return o;const l=n==="names"&&i.prompt?[...i.fields,i.prompt]:i.fields;return r.every(u=>l.some(c=>c.toLowerCase().includes(u)))})}const U9=e=>e.flatMap(([t,n])=>Array.from({length:n},(r,o)=>t+o));function H9({repoId:e,scope:t}){const n=at(),r=lt(),o=M(T=>T.clientId),i=M(T=>T.frame),l=M(T=>T.chats[e]),u=Zg(),c=M(T=>T.archived[e]),[f,p]=S.useState(t),m=S.useCallback(()=>p(T=>T==="all"?"names":"all"),[]);S.useEffect(()=>{r==null||r.send({t:"list-archived",repoId:e})},[r,e]);const g=S.useMemo(()=>[...u.filter(T=>!Ir(T.worktree)).map(z9),...(c??[]).map(F9)],[u,c]),w=S.useMemo(()=>new Map(g.map(T=>[T.id,T])),[g]),y=S.useMemo(()=>[...g,...((l==null?void 0:l.hits)??[]).map(T=>({kind:"hit",hit:T}))],[g,l]),x=S.useCallback((T,R)=>B9(T,R,f),[f]),b=S.useCallback(T=>{f==="all"&&!Vm(T)&&(r==null||r.send({t:"search-chats",repoId:e,query:T.trim()}))},[r,e,f]),j=T=>!l||l.query!==T.trim(),N=T=>f==="all"&&!Vm(T);return h.jsx(Rr,{items:y,filter:x,onQuery:b,onTab:m,trailing:h.jsx(Le,{tone:"chrome",on:f==="names","aria-pressed":f==="names",onClick:m,children:"names only"}),keyOf:T=>T.kind==="hit"?`h:${T.hit.worktreeId}:${T.hit.seq}`:`w:${T.id}`,rowClass:T=>T.kind==="hit"?"chats-hit":Ue("picker-row",T.archived&&!T.archived.restorable&&"dim"),rowTitle:T=>{var R;return T.kind==="hit"?T.hit.text:((R=T.archived)==null?void 0:R.prompt)??T.name},groupOf:T=>T.kind==="hit"?`h:${T.hit.worktreeId}`:T.archived?"archived":"open",groupHead:(T,R)=>{if(!T.startsWith("h:"))return`${T} · ${R}`;const $=w.get(T.slice(2));return h.jsxs("span",{children:[($==null?void 0:$.name)??"a worktree",($==null?void 0:$.archived)&&h.jsxs(h.Fragment,{children:[" ",h.jsx("span",{className:"row-dim",children:"archived"})]}),` · ${R}`]})},headAlone:!0,onPick:T=>{const R=T.kind==="hit"?T.hit.worktreeId:T.id,$=T.kind==="hit"?T.hit.archived:!!T.archived;n($?{a:"open-archived",id:R}:{a:"activate",id:R}),T.kind==="hit"&&n({a:"reveal",id:R,seq:T.hit.seq}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:T=>T.kind==="chat"&&T.archived?yd(T.archived,{clientId:o,frame:i},{sock:r,dispatch:n}):[],placeholder:f==="names"?"find a chat by name…":"search in chats…",keys:T=>({nav:"moves",tab:f==="names"?"searches messages too":"searches names only",pick:T?T.kind==="hit"?"opens the chat there":"opens its chat":void 0,back:"closes"}),empty:T=>T.trim()?N(T)?j(T)?"searching…":"no chat says that":"no chat is named that":c?"no chats yet":"looking…",footer:(T,R)=>{const $=R.filter(W=>W.kind==="hit").length;return l!=null&&l.truncated&&!j(T)&&$>0?h.jsxs("div",{className:"empty",children:["showing the first ",$,"; narrow the search"]}):null},row:T=>T.kind==="chat"?h.jsx(Hn,{label:T.name,hint:T.hint}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"chats-text",children:bc(T.hit.text,U9(T.hit.match),0)}),h.jsxs("span",{className:"chats-said row-dim",children:[T.hit.role==="user"?"you":"the agent",T.hit.ts>0?` · ${eo(T.hit.ts)}`:""]})]})})}function K9({worktreeId:e,hits:t}){const n=at(),r=lt(),o=M(u=>u.layout.changes),i=M(u=>{var f;const c=(f=dn(u,e))==null?void 0:f.worktree;return c?c.path:null}),l=S.useCallback((u,c)=>{const f=c.trim().toLowerCase();return f?u.filter(p=>`${p.path}:${p.line} ${p.text}`.toLowerCase().includes(f)):u},[]);return h.jsx(Rr,{items:t,filter:l,keyOf:u=>`${u.path}:${u.line}`,rowClass:()=>"search-hit",rowTitle:u=>`${u.path}:${u.line}`,onPick:u=>{er({dispatch:n},{worktreeId:e,path:u.path,view:"file",line:{n:u.line}}),o||n({a:"toggle-changes"}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:u=>i?ys({id:e,dir:i},u.path,{},{sock:r,dispatch:n}):[],placeholder:"lines that could write this element",keys:{pick:"opens the file",back:"closes"},row:u=>h.jsxs(h.Fragment,{children:[h.jsxs("span",{className:"search-loc",children:[u.path,":",u.line]}),h.jsx("span",{className:"search-text",children:u.text})]})})}const Mf=e=>/^(~|\/|\.\.?\/)/.test(e.trim());function TN(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 W9(e,t,n){const r=e.map(f=>f.path.slice(0,f.path.lastIndexOf("/"))).filter(Boolean),o=e.find(f=>f.id===t),i=o==null?void 0:o.path.slice(0,o.path.lastIndexOf("/")),l=new Map;for(const f of r)l.set(f,(l.get(f)??0)+1);let u="",c=0;for(const[f,p]of[...l].sort(([m],[g])=>m.localeCompare(g)))(p>c||p===c&&f===i)&&(u=f,c=p);return u?jN(u,n):`~/${x1}`}function jN(e,t){return t&&(e===t||e.startsWith(`${t}/`))?`~${e.slice(t.length)}`:e}function CN(e,t){return`${e.replace(/\/+$/,"")}/${t.trim()}`}function Z9(e){const t=e.query.trim(),n=()=>e.entries.map(l=>({kind:"dir",entry:l}));if(!Mf(t)){const l=e.repos.filter(g=>Es(t,g.name,g.path)).map(g=>({kind:"repo",repo:g})),u=e.pending.filter(g=>Es(t,g.name,g.url)).map(g=>({kind:"pending",pending:g})),c=[...l,...u],f=(e.others??[]).flatMap(g=>g.repos.filter(w=>Es(t,w.name,w.path,g.name)).map(w=>({kind:"repo",repo:w,machine:g})));if(!t)return[...c,{kind:"new"},{kind:"disk"},{kind:"add-machine"},...f];const p=GO(t);if(p)return c.length>0?c:[{kind:"clone",url:p.url,name:p.name}];const m=g=>g.toLowerCase()===t.toLowerCase();return e.repos.some(g=>m(g.name))||e.pending.some(g=>m(g.name))?[...c,...f]:hc(t)?[...c,...f]:[...c,{kind:"create",name:t,parent:null},...f]}if(e.answered.trim()!==t||!e.target)return n();const{target:r}=e;if(t.endsWith("/"))return n();if(r.exists)return r.isRepo?[...n(),{kind:"open",path:t}]:n();if(!r.parentExists)return[];const{parent:o,name:i}=TN(t);return hc(i)?n():[...n(),{kind:"create",name:i,parent:o}]}function xc(e,t){return t&&(e==="~"||e.startsWith("~/"))?`${t}${e.slice(1)}`:e}function AN(e,t){const n=xc(e,t).replace(/\/+$/,"");return n.startsWith("/")?jN(n.slice(0,n.lastIndexOf("/"))||"/",t):null}function Ym(e,t){const n=xc(e,t).replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||"/"}function q9(e){const t=e.query.trim(),n=t.lastIndexOf("/"),r=n<0?"":t.slice(0,n)||"/",o=xc(r,e.home);if(!Mf(t)||!o.startsWith("/"))return[];const i=t.slice(n+1).toLowerCase(),l=e.answered.trim()===t?e.target:null,u=!l||(i?l.parentExists:l.exists&&l.isDir&&!l.isRepo),c=e.entries.filter(p=>{if(p.isRepo)return!1;const m=xc(p.path,e.home);return(m.slice(0,m.lastIndexOf("/"))||"/")===o&&p.name.toLowerCase().startsWith(i)}),f=AN(r,e.home);return[...u?[{kind:"here",path:r}]:[],...f?[{kind:"up",path:f}]:[],...c.map(p=>({kind:"dir",entry:p}))]}function G9({project:e}){const t=at(),n=lt(),r=M(f=>f.paths),o=M(f=>f.home),i=S.useCallback(f=>{Mf(f)&&(n==null||n.send({t:"browse-path",path:f}))},[n]),l=S.useCallback((f,p)=>q9({query:p,entries:r.entries,target:r.target,answered:r.query,home:o}),[r,o]),u=hc(e.name)?null:e.name.trim(),c=f=>`${f.replace(/\/+$/,"")}/`;return h.jsx(Rr,{initialQuery:c(e.parent),lead:h.jsx("span",{className:"picker-chip",children:u??"new project"}),items:[],filter:l,keyOf:f=>f.kind==="dir"?`d:${f.entry.path}`:`${f.kind}:${f.path}`,rowClass:()=>"picker-row folder-row",onQuery:i,completionOf:f=>f.kind==="dir"?c(f.entry.path):null,narrowTo:f=>f.kind==="dir"?c(f.entry.path):f.kind==="up"?c(f.path):null,onPick:f=>{f.kind==="here"&&(t({a:"new-project-set",v:{mode:e.mode==="init"?"create":e.mode,parent:f.path}}),t({a:"close"}))},onBack:()=>t({a:"close"}),placeholder:"type a folder path",keys:f=>({complete:"completes the path",pick:(f==null?void 0:f.kind)==="here"?"chooses it":(f==null?void 0:f.kind)==="up"?"goes up":"opens it",back:"goes back"}),empty:"no such folder",row:f=>f.kind==="here"?h.jsx(Hn,{label:`put ${u??"it"} in ${Ym(f.path,o)}`,hint:h.jsx("bdi",{children:u?CN(f.path,u):f.path})}):f.kind==="up"?h.jsx(Hn,{label:`up to ${Ym(f.path,o)}`,hint:h.jsx("bdi",{children:f.path})}):h.jsx(Hn,{label:f.entry.name})})}function V9({worktreeId:e}){const t=at(),n=lt(),r=M(m=>m.clientId),o=M(m=>dn(m,e)),i=M(m=>m.repos),u=Tt(e,"draft").trim(),c=S.useMemo(()=>i.filter(m=>m.id!==(o==null?void 0:o.worktree.repoId)),[i,o]),f=()=>t({a:"close"}),p=m=>{if(!o)return f();n==null||n.send({t:"handoff-ask",worktreeId:e,repoId:m.id,...u?{text:u}:{}}),u&&(n==null||n.send({t:"set-draft",boxId:e,text:"",clientId:r}),t({a:"set-draft",id:e,text:""})),f()};return h.jsx(Rr,{lead:h.jsx("span",{className:"picker-chip",children:(o==null?void 0:o.worktree.title)??"worktree"}),items:c,filter:(m,g)=>m.filter(w=>Es(g,w.name,w.path)),keyOf:m=>m.id,row:m=>h.jsx(Hn,{label:m.name,hint:m.path}),onPick:p,onBack:()=>t({a:"close",back:!0}),placeholder:"continue in which project?",empty:"no other project is open",keys:{pick:"continues there",back:"closes"},footer:u?()=>h.jsxs("div",{className:"empty",children:["with your message: ",u.split(`
|
|
246
|
+
`)[0]]}):void 0})}const Y9={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 X9(){const e=at(),t=lt(),n=M(r=>r.keepAwake);return h.jsx(Rr,{items:[...kj],filter:(r,o)=>r.filter(i=>Es(o,Wd[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=>h.jsx(Hn,{label:Wd[r],current:r===n,hint:Y9[r]})})}const ll=function(e,t){let o=e;const i=Ql[t];let l=null,u=0,c=null;const f=[],p={},m=function(A,I){u=o*4+17,l=(function(_){const P=new Array(_);for(let z=0;z<_;z+=1){P[z]=new Array(_);for(let q=0;q<_;q+=1)P[z][q]=null}return P})(u),g(0,0),g(u-7,0),g(0,u-7),x(),y(),j(A,I),o>=7&&b(A),c==null&&(c=R(o,i,f)),N(c,I)},g=function(A,I){for(let _=-1;_<=7;_+=1)if(!(A+_<=-1||u<=A+_))for(let P=-1;P<=7;P+=1)I+P<=-1||u<=I+P||(0<=_&&_<=6&&(P==0||P==6)||0<=P&&P<=6&&(_==0||_==6)||2<=_&&_<=4&&2<=P&&P<=4?l[A+_][I+P]=!0:l[A+_][I+P]=!1)},w=function(){let A=0,I=0;for(let _=0;_<8;_+=1){m(!0,_);const P=Xs.getLostPoint(p);(_==0||A>P)&&(A=P,I=_)}return I},y=function(){for(let A=8;A<u-8;A+=1)l[A][6]==null&&(l[A][6]=A%2==0);for(let A=8;A<u-8;A+=1)l[6][A]==null&&(l[6][A]=A%2==0)},x=function(){const A=Xs.getPatternPosition(o);for(let I=0;I<A.length;I+=1)for(let _=0;_<A.length;_+=1){const P=A[I],z=A[_];if(l[P][z]==null)for(let q=-2;q<=2;q+=1)for(let se=-2;se<=2;se+=1)q==-2||q==2||se==-2||se==2||q==0&&se==0?l[P+q][z+se]=!0:l[P+q][z+se]=!1}},b=function(A){const I=Xs.getBCHTypeNumber(o);for(let _=0;_<18;_+=1){const P=!A&&(I>>_&1)==1;l[Math.floor(_/3)][_%3+u-8-3]=P}for(let _=0;_<18;_+=1){const P=!A&&(I>>_&1)==1;l[_%3+u-8-3][Math.floor(_/3)]=P}},j=function(A,I){const _=i<<3|I,P=Xs.getBCHTypeInfo(_);for(let z=0;z<15;z+=1){const q=!A&&(P>>z&1)==1;z<6?l[z][8]=q:z<8?l[z+1][8]=q:l[u-15+z][8]=q}for(let z=0;z<15;z+=1){const q=!A&&(P>>z&1)==1;z<8?l[8][u-z-1]=q:z<9?l[8][15-z-1+1]=q:l[8][15-z-1]=q}l[u-8][8]=!A},N=function(A,I){let _=-1,P=u-1,z=7,q=0;const se=Xs.getMaskFunction(I);for(let Y=u-1;Y>0;Y-=2)for(Y==6&&(Y-=1);;){for(let ge=0;ge<2;ge+=1)if(l[P][Y-ge]==null){let ke=!1;q<A.length&&(ke=(A[q]>>>z&1)==1),se(P,Y-ge)&&(ke=!ke),l[P][Y-ge]=ke,z-=1,z==-1&&(q+=1,z=7)}if(P+=_,P<0||u<=P){P-=_,_=-_;break}}},T=function(A,I){let _=0,P=0,z=0;const q=new Array(I.length),se=new Array(I.length);for(let oe=0;oe<I.length;oe+=1){const L=I[oe].dataCount,re=I[oe].totalCount-L;P=Math.max(P,L),z=Math.max(z,re),q[oe]=new Array(L);for(let xe=0;xe<q[oe].length;xe+=1)q[oe][xe]=255&A.getBuffer()[xe+_];_+=L;const te=Xs.getErrorCorrectPolynomial(re),B=Ec(q[oe],te.getLength()-1).mod(te);se[oe]=new Array(te.getLength()-1);for(let xe=0;xe<se[oe].length;xe+=1){const de=xe+B.getLength()-se[oe].length;se[oe][xe]=de>=0?B.getAt(de):0}}let Y=0;for(let oe=0;oe<I.length;oe+=1)Y+=I[oe].totalCount;const ge=new Array(Y);let ke=0;for(let oe=0;oe<P;oe+=1)for(let L=0;L<I.length;L+=1)oe<q[L].length&&(ge[ke]=q[L][oe],ke+=1);for(let oe=0;oe<z;oe+=1)for(let L=0;L<I.length;L+=1)oe<se[L].length&&(ge[ke]=se[L][oe],ke+=1);return ge},R=function(A,I,_){const P=dx.getRSBlocks(A,I),z=fx();for(let se=0;se<_.length;se+=1){const Y=_[se];z.put(Y.getMode(),4),z.put(Y.getLength(),Xs.getLengthInBits(Y.getMode(),A)),Y.write(z)}let q=0;for(let se=0;se<P.length;se+=1)q+=P[se].dataCount;if(z.getLengthInBits()>q*8)throw"code length overflow. ("+z.getLengthInBits()+">"+q*8+")";for(z.getLengthInBits()+4<=q*8&&z.put(0,4);z.getLengthInBits()%8!=0;)z.putBit(!1);for(;!(z.getLengthInBits()>=q*8||(z.put(236,8),z.getLengthInBits()>=q*8));)z.put(17,8);return T(z,P)};p.addData=function(A,I){I=I||"Byte";let _=null;switch(I){case"Numeric":_=Q9(A);break;case"Alphanumeric":_=J9(A);break;case"Byte":_=eB(A);break;case"Kanji":_=tB(A);break;default:throw"mode:"+I}f.push(_),c=null},p.isDark=function(A,I){if(A<0||u<=A||I<0||u<=I)throw A+","+I;return l[A][I]},p.getModuleCount=function(){return u},p.make=function(){if(o<1){let A=1;for(;A<40;A++){const I=dx.getRSBlocks(A,i),_=fx();for(let z=0;z<f.length;z++){const q=f[z];_.put(q.getMode(),4),_.put(q.getLength(),Xs.getLengthInBits(q.getMode(),A)),q.write(_)}let P=0;for(let z=0;z<I.length;z++)P+=I[z].dataCount;if(_.getLengthInBits()<=P*8)break}o=A}m(!1,w())},p.createTableTag=function(A,I){A=A||2,I=typeof I>"u"?A*4:I;let _="";_+='<table style="',_+=" border-width: 0px; border-style: none;",_+=" border-collapse: collapse;",_+=" padding: 0px; margin: "+I+"px;",_+='">',_+="<tbody>";for(let P=0;P<p.getModuleCount();P+=1){_+="<tr>";for(let z=0;z<p.getModuleCount();z+=1)_+='<td style="',_+=" border-width: 0px; border-style: none;",_+=" border-collapse: collapse;",_+=" padding: 0px; margin: 0px;",_+=" width: "+A+"px;",_+=" height: "+A+"px;",_+=" background-color: ",_+=p.isDark(P,z)?"#000000":"#ffffff",_+=";",_+='"/>';_+="</tr>"}return _+="</tbody>",_+="</table>",_},p.createSvgTag=function(A,I,_,P){let z={};typeof arguments[0]=="object"&&(z=arguments[0],A=z.cellSize,I=z.margin,_=z.alt,P=z.title),A=A||2,I=typeof I>"u"?A*4:I,_=typeof _=="string"?{text:_}:_||{},_.text=_.text||null,_.id=_.text?_.id||"qrcode-description":null,P=typeof P=="string"?{text:P}:P||{},P.text=P.text||null,P.id=P.text?P.id||"qrcode-title":null;const q=p.getModuleCount()*A+I*2;let se,Y,ge,ke,oe="",L;for(L="l"+A+",0 0,"+A+" -"+A+",0 0,-"+A+"z ",oe+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',oe+=z.scalable?"":' width="'+q+'px" height="'+q+'px"',oe+=' viewBox="0 0 '+q+" "+q+'" ',oe+=' preserveAspectRatio="xMinYMin meet"',oe+=P.text||_.text?' role="img" aria-labelledby="'+$([P.id,_.id].join(" ").trim())+'"':"",oe+=">",oe+=P.text?'<title id="'+$(P.id)+'">'+$(P.text)+"</title>":"",oe+=_.text?'<description id="'+$(_.id)+'">'+$(_.text)+"</description>":"",oe+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',oe+='<path d="',ge=0;ge<p.getModuleCount();ge+=1)for(ke=ge*A+I,se=0;se<p.getModuleCount();se+=1)p.isDark(ge,se)&&(Y=se*A+I,oe+="M"+Y+","+ke+L);return oe+='" stroke="transparent" fill="black"/>',oe+="</svg>",oe},p.createDataURL=function(A,I){A=A||2,I=typeof I>"u"?A*4:I;const _=p.getModuleCount()*A+I*2,P=I,z=_-I;return sB(_,_,function(q,se){if(P<=q&&q<z&&P<=se&&se<z){const Y=Math.floor((q-P)/A),ge=Math.floor((se-P)/A);return p.isDark(ge,Y)?0:1}else return 1})},p.createImgTag=function(A,I,_){A=A||2,I=typeof I>"u"?A*4:I;const P=p.getModuleCount()*A+I*2;let z="";return z+="<img",z+=' src="',z+=p.createDataURL(A,I),z+='"',z+=' width="',z+=P,z+='"',z+=' height="',z+=P,z+='"',_&&(z+=' alt="',z+=$(_),z+='"'),z+="/>",z};const $=function(A){let I="";for(let _=0;_<A.length;_+=1){const P=A.charAt(_);switch(P){case"<":I+="<";break;case">":I+=">";break;case"&":I+="&";break;case'"':I+=""";break;default:I+=P;break}}return I},W=function(A){A=typeof A>"u"?2:A;const _=p.getModuleCount()*1+A*2,P=A,z=_-A;let q,se,Y,ge,ke;const oe={"██":"█","█ ":"▀"," █":"▄"," ":" "},L={"██":"▀","█ ":"▀"," █":" "," ":" "};let re="";for(q=0;q<_;q+=2){for(Y=Math.floor((q-P)/1),ge=Math.floor((q+1-P)/1),se=0;se<_;se+=1)ke="█",P<=se&&se<z&&P<=q&&q<z&&p.isDark(Y,Math.floor((se-P)/1))&&(ke=" "),P<=se&&se<z&&P<=q+1&&q+1<z&&p.isDark(ge,Math.floor((se-P)/1))?ke+=" ":ke+="█",re+=A<1&&q+1>=z?L[ke]:oe[ke];re+=`
|
|
247
|
+
`}return _%2&&A>0?re.substring(0,re.length-_-1)+Array(_+1).join("▀"):re.substring(0,re.length-1)};return p.createASCII=function(A,I){if(A=A||1,A<2)return W(I);A-=1,I=typeof I>"u"?A*2:I;const _=p.getModuleCount()*A+I*2,P=I,z=_-I;let q,se,Y,ge;const ke=Array(A+1).join("██"),oe=Array(A+1).join(" ");let L="",re="";for(q=0;q<_;q+=1){for(Y=Math.floor((q-P)/A),re="",se=0;se<_;se+=1)ge=1,P<=se&&se<z&&P<=q&&q<z&&p.isDark(Y,Math.floor((se-P)/A))&&(ge=0),re+=ge?ke:oe;for(Y=0;Y<A;Y+=1)L+=re+`
|
|
248
|
+
`}return L.substring(0,L.length-1)},p.renderTo2dContext=function(A,I){I=I||2;const _=p.getModuleCount();for(let P=0;P<_;P++)for(let z=0;z<_;z++)A.fillStyle=p.isDark(P,z)?"black":"white",A.fillRect(z*I,P*I,I,I)},p};ll.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};ll.createStringToBytes=function(e,t){const n=(function(){const o=rB(e),i=function(){const c=o.read();if(c==-1)throw"eof";return c};let l=0;const u={};for(;;){const c=o.read();if(c==-1)break;const f=i(),p=i(),m=i(),g=String.fromCharCode(c<<8|f),w=p<<8|m;u[g]=w,l+=1}if(l!=t)throw l+" != "+t;return u})(),r=63;return function(o){const i=[];for(let l=0;l<o.length;l+=1){const u=o.charCodeAt(l);if(u<128)i.push(u);else{const c=n[o.charAt(l)];typeof c=="number"?(c&255)==c?i.push(c):(i.push(c>>>8),i.push(c&255)):i.push(r)}}return i}};const Cr={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},Ql={L:1,M:0,Q:3,H:2},Ys={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},Xs=(function(){const e=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],t=1335,n=7973,r=21522,o={},i=function(l){let u=0;for(;l!=0;)u+=1,l>>>=1;return u};return o.getBCHTypeInfo=function(l){let u=l<<10;for(;i(u)-i(t)>=0;)u^=t<<i(u)-i(t);return(l<<10|u)^r},o.getBCHTypeNumber=function(l){let u=l<<12;for(;i(u)-i(n)>=0;)u^=n<<i(u)-i(n);return l<<12|u},o.getPatternPosition=function(l){return e[l-1]},o.getMaskFunction=function(l){switch(l){case Ys.PATTERN000:return function(u,c){return(u+c)%2==0};case Ys.PATTERN001:return function(u,c){return u%2==0};case Ys.PATTERN010:return function(u,c){return c%3==0};case Ys.PATTERN011:return function(u,c){return(u+c)%3==0};case Ys.PATTERN100:return function(u,c){return(Math.floor(u/2)+Math.floor(c/3))%2==0};case Ys.PATTERN101:return function(u,c){return u*c%2+u*c%3==0};case Ys.PATTERN110:return function(u,c){return(u*c%2+u*c%3)%2==0};case Ys.PATTERN111:return function(u,c){return(u*c%3+(u+c)%2)%2==0};default:throw"bad maskPattern:"+l}},o.getErrorCorrectPolynomial=function(l){let u=Ec([1],0);for(let c=0;c<l;c+=1)u=u.multiply(Ec([1,Js.gexp(c)],0));return u},o.getLengthInBits=function(l,u){if(1<=u&&u<10)switch(l){case Cr.MODE_NUMBER:return 10;case Cr.MODE_ALPHA_NUM:return 9;case Cr.MODE_8BIT_BYTE:return 8;case Cr.MODE_KANJI:return 8;default:throw"mode:"+l}else if(u<27)switch(l){case Cr.MODE_NUMBER:return 12;case Cr.MODE_ALPHA_NUM:return 11;case Cr.MODE_8BIT_BYTE:return 16;case Cr.MODE_KANJI:return 10;default:throw"mode:"+l}else if(u<41)switch(l){case Cr.MODE_NUMBER:return 14;case Cr.MODE_ALPHA_NUM:return 13;case Cr.MODE_8BIT_BYTE:return 16;case Cr.MODE_KANJI:return 12;default:throw"mode:"+l}else throw"type:"+u},o.getLostPoint=function(l){const u=l.getModuleCount();let c=0;for(let m=0;m<u;m+=1)for(let g=0;g<u;g+=1){let w=0;const y=l.isDark(m,g);for(let x=-1;x<=1;x+=1)if(!(m+x<0||u<=m+x))for(let b=-1;b<=1;b+=1)g+b<0||u<=g+b||x==0&&b==0||y==l.isDark(m+x,g+b)&&(w+=1);w>5&&(c+=3+w-5)}for(let m=0;m<u-1;m+=1)for(let g=0;g<u-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)&&(c+=3)}for(let m=0;m<u;m+=1)for(let g=0;g<u-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)&&(c+=40);for(let m=0;m<u;m+=1)for(let g=0;g<u-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)&&(c+=40);let f=0;for(let m=0;m<u;m+=1)for(let g=0;g<u;g+=1)l.isDark(g,m)&&(f+=1);const p=Math.abs(100*f/u/u-50)/5;return c+=p*10,c},o})(),Js=(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})(),Ec=function(e,t){if(typeof e.length>"u")throw e.length+"/"+t;const n=(function(){let o=0;for(;o<e.length&&e[o]==0;)o+=1;const i=new Array(e.length-o+t);for(let l=0;l<e.length-o;l+=1)i[l]=e[l+o];return i})(),r={};return r.getAt=function(o){return n[o]},r.getLength=function(){return n.length},r.multiply=function(o){const i=new Array(r.getLength()+o.getLength()-1);for(let l=0;l<r.getLength();l+=1)for(let u=0;u<o.getLength();u+=1)i[l+u]^=Js.gexp(Js.glog(r.getAt(l))+Js.glog(o.getAt(u)));return Ec(i,0)},r.mod=function(o){if(r.getLength()-o.getLength()<0)return r;const i=Js.glog(r.getAt(0))-Js.glog(o.getAt(0)),l=new Array(r.getLength());for(let u=0;u<r.getLength();u+=1)l[u]=r.getAt(u);for(let u=0;u<o.getLength();u+=1)l[u]^=Js.gexp(Js.glog(o.getAt(u))+i);return Ec(l,0).mod(o)},r},dx=(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 Ql.L:return e[(o-1)*4+0];case Ql.M:return e[(o-1)*4+1];case Ql.Q:return e[(o-1)*4+2];case Ql.H:return e[(o-1)*4+3];default:return}};return n.getRSBlocks=function(o,i){const l=r(o,i);if(typeof l>"u")throw"bad rs block @ typeNumber:"+o+"/errorCorrectionLevel:"+i;const u=l.length/3,c=[];for(let f=0;f<u;f+=1){const p=l[f*3+0],m=l[f*3+1],g=l[f*3+2];for(let w=0;w<p;w+=1)c.push(t(m,g))}return c},n})(),fx=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},Q9=function(e){const t=Cr.MODE_NUMBER,n=e,r={};r.getMode=function(){return t},r.getLength=function(l){return n.length},r.write=function(l){const u=n;let c=0;for(;c+2<u.length;)l.put(o(u.substring(c,c+3)),10),c+=3;c<u.length&&(u.length-c==1?l.put(o(u.substring(c,c+1)),4):u.length-c==2&&l.put(o(u.substring(c,c+2)),7))};const o=function(l){let u=0;for(let c=0;c<l.length;c+=1)u=u*10+i(l.charAt(c));return u},i=function(l){if("0"<=l&&l<="9")return l.charCodeAt(0)-48;throw"illegal char :"+l};return r},J9=function(e){const t=Cr.MODE_ALPHA_NUM,n=e,r={};r.getMode=function(){return t},r.getLength=function(i){return n.length},r.write=function(i){const l=n;let u=0;for(;u+1<l.length;)i.put(o(l.charAt(u))*45+o(l.charAt(u+1)),11),u+=2;u<l.length&&i.put(o(l.charAt(u)),6)};const o=function(i){if("0"<=i&&i<="9")return i.charCodeAt(0)-48;if("A"<=i&&i<="Z")return i.charCodeAt(0)-65+10;switch(i){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+i}};return r},eB=function(e){const t=Cr.MODE_8BIT_BYTE,n=ll.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},tB=function(e){const t=Cr.MODE_KANJI,n=ll.stringToBytes;(function(i,l){const u=n(i);if(u.length!=2||(u[0]<<8|u[1])!=l)throw"sjis not supported."})("友",38726);const r=n(e),o={};return o.getMode=function(){return t},o.getLength=function(i){return~~(r.length/2)},o.write=function(i){const l=r;let u=0;for(;u+1<l.length;){let c=(255&l[u])<<8|255&l[u+1];if(33088<=c&&c<=40956)c-=33088;else if(57408<=c&&c<=60351)c-=49472;else throw"illegal char at "+(u+1)+"/"+c;c=(c>>>8&255)*192+(c&255),i.put(c,13),u+=2}if(u<l.length)throw"illegal char at "+(u+1)},o},IN=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},nB=function(){let e=0,t=0,n=0,r="";const o={},i=function(u){r+=String.fromCharCode(l(u&63))},l=function(u){if(u<0)throw"n:"+u;if(u<26)return 65+u;if(u<52)return 97+(u-26);if(u<62)return 48+(u-52);if(u==62)return 43;if(u==63)return 47;throw"n:"+u};return o.writeByte=function(u){for(e=e<<8|u&255,t+=8,n+=1;t>=6;)i(e>>>t-6),t-=6},o.flush=function(){if(t>0&&(i(e<<6-t),e=0,t=0),n%3!=0){const u=3-n%3;for(let c=0;c<u;c+=1)r+="="}},o.toString=function(){return r},o},rB=function(e){const t=e;let n=0,r=0,o=0;const i={};i.read=function(){for(;o<8;){if(n>=t.length){if(o==0)return-1;throw"unexpected end of file./"+o}const c=t.charAt(n);if(n+=1,c=="=")return o=0,-1;if(c.match(/^\s$/))continue;r=r<<6|l(c.charCodeAt(0)),o+=6}const u=r>>>o-8&255;return o-=8,u};const l=function(u){if(65<=u&&u<=90)return u-65;if(97<=u&&u<=122)return u-97+26;if(48<=u&&u<=57)return u-48+52;if(u==43)return 62;if(u==47)return 63;throw"c:"+u};return i},oB=function(e,t){const n=e,r=t,o=new Array(e*t),i={};i.setPixel=function(f,p,m){o[p*n+f]=m},i.write=function(f){f.writeString("GIF87a"),f.writeShort(n),f.writeShort(r),f.writeByte(128),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(255),f.writeByte(255),f.writeByte(255),f.writeString(","),f.writeShort(0),f.writeShort(0),f.writeShort(n),f.writeShort(r),f.writeByte(0);const p=2,m=u(p);f.writeByte(p);let g=0;for(;m.length-g>255;)f.writeByte(255),f.writeBytes(m,g,255),g+=255;f.writeByte(m.length-g),f.writeBytes(m,g,m.length-g),f.writeByte(0),f.writeString(";")};const l=function(f){const p=f;let m=0,g=0;const w={};return w.write=function(y,x){if(y>>>x)throw"length over";for(;m+x>=8;)p.writeByte(255&(y<<m|g)),x-=8-m,y>>>=8-m,g=0,m=0;g=y<<m|g,m=m+x},w.flush=function(){m>0&&p.writeByte(g)},w},u=function(f){const p=1<<f,m=(1<<f)+1;let g=f+1;const w=c();for(let N=0;N<p;N+=1)w.add(String.fromCharCode(N));w.add(String.fromCharCode(p)),w.add(String.fromCharCode(m));const y=IN(),x=l(y);x.write(p,g);let b=0,j=String.fromCharCode(o[b]);for(b+=1;b<o.length;){const N=String.fromCharCode(o[b]);b+=1,w.contains(j+N)?j=j+N:(x.write(w.indexOf(j),g),w.size()<4095&&(w.size()==1<<g&&(g+=1),w.add(j+N)),j=N)}return x.write(w.indexOf(j),g),x.write(m,g),x.flush(),y.toByteArray()},c=function(){const f={};let p=0;const m={};return m.add=function(g){if(m.contains(g))throw"dup key:"+g;f[g]=p,p+=1},m.size=function(){return p},m.indexOf=function(g){return f[g]},m.contains=function(g){return typeof f[g]<"u"},m};return i},sB=function(e,t,n){const r=oB(e,t);for(let u=0;u<t;u+=1)for(let c=0;c<e;c+=1)r.setPixel(c,u,n(c,u));const o=IN();r.write(o);const i=nB(),l=o.toByteArray();for(let u=0;u<l.length;u+=1)i.writeByte(l[u]);return i.flush(),"data:image/gif;base64,"+i};ll.stringToBytes;function iB(e){const t=ll(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 Vp=4;function aB({text:e}){const{size:t,d:n}=S.useMemo(()=>{const r=iB(e);let o="";return r.forEach((i,l)=>{i.forEach((u,c)=>{u&&(o+=`M${c+Vp} ${l+Vp}h1v1h-1z`)})}),{size:r.length+Vp*2,d:o}},[e]);return h.jsx("svg",{className:"pair-qr",viewBox:`0 0 ${t} ${t}`,shapeRendering:"crispEdges",role:"img","aria-label":"This machine's address",children:h.jsx("path",{d:n})})}const lB=3e3;function cB(e){return e.from===null?"A device that opened this address":`A Toyon page at ${Xd(e.from)}`}function uB({knock:e,letIn:t,onAnswer:n}){return h.jsxs("div",{className:Ue("pair-knock",t!==null&&"pair-knock-done"),children:[h.jsxs("div",{className:"pair-knock-line",children:[h.jsx("span",{className:"knock-word",children:e.word}),h.jsx("span",{className:"pair-from",children:t===null?`${cB(e)} wants in.`:t?"is in.":"was turned away."})]}),t===null&&h.jsxs("div",{className:"pair-knock-actions",children:[h.jsx(Le,{tone:"primary",onClick:()=>n(!0),children:"let in"}),h.jsx(Le,{variant:"outline",onClick:()=>n(!1),children:"not now"})]})]})}function dB({urls:e,waitingOnPhone:t}){const n=M(g=>{var w;return((w=g.remote)==null?void 0:w.host)??null}),r=M(g=>g.tailscale),[o,i]=S.useState(!1),[l,u]=S.useState(null),c=n!==null&&qj(n),f=yE(()=>J2(e),lB,c&&t),p=c&&f!==void 0?Gj(f):null,m=async()=>{i(!0),u(null);const g=await tM(e);i(!1),g&&u(g)};return n!==null?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"pair-frame",children:h.jsx(aB,{text:Wj(n)})}),h.jsx("div",{className:"hint pair-host",children:n}),h.jsx("p",{className:"pair-line",children:`Scan it with your phone's camera. The phone asks to be let in, and the ask shows here. Another machine finds this one under "add a machine".`}),p&&h.jsx("p",{className:Ue("pair-note",p.ok&&"hint"),children:p.text})]}):h.jsxs(h.Fragment,{children:[h.jsx("p",{className:"pair-line",children:"Your phone opens this machine at its tailnet name. Anyone on your tailnet you let in gets a shell here."}),r===null?h.jsx("p",{className:"pair-note",children:"Asking Tailscale."}):r.state==="ready"?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"pair-knock-actions",children:h.jsx(Le,{tone:"primary",busy:o,onClick:()=>void m(),children:"turn on"})}),l&&h.jsx("p",{className:"pair-note",children:l})]}):h.jsx("p",{className:"pair-note",children:r.line})]})}function fB(){const e=at(),t=$r(),n=M(p=>p.frame==="desk"),r=M(p=>p.knocks),[o,i]=S.useState([]),l=()=>e({a:"close"}),u=(p,m)=>{i(g=>g.some(w=>w.knock.id===p.id)?g:[...g,{knock:p,letIn:m}]),rM(t,p.id,m)},c=r.filter(p=>!o.some(m=>m.knock.id===p.id)),f=[...o,...c.map(p=>({knock:p,letIn:null}))];return h.jsxs(Pc,{boxClass:"pair-card",onClose:l,children:[h.jsx("div",{className:"pair-title",children:n?"Open on your phone":"Pair a device"}),n&&h.jsx(dB,{urls:t,waitingOnPhone:c.length===0}),f.length===0&&!n&&h.jsx("p",{className:"pair-line",children:"Nothing is asking to be let in right now."}),c.length>0&&h.jsx("p",{className:"pair-line",children:"Let in the one whose words match the other screen."}),f.map(p=>h.jsx(uB,{knock:p.knock,letIn:p.letIn,onAnswer:m=>u(p.knock,m)},p.knock.id)),h.jsx("div",{className:"pair-actions",children:h.jsx(Le,{tone:"quiet",onClick:l,children:"done"})})]})}function Gk({form:e}){var I;const t=at(),n=lt(),r=To(),o=oo(),i=r.displayName(o.origin),l=fE(),u=M(_=>_.repos),c=M(_=>_.newProject?null:_.activeRepoId),f=M(_=>_.rows),p=M(_=>_.paths),m=M(_=>_.home),g=M(_=>_.pending),w=S.useCallback(_=>{Mf(_)&&(n==null||n.send({t:"browse-path",path:_}))},[n]),y=S.useCallback((_,P)=>Z9({query:P,repos:u,pending:g,entries:[...p.entries].sort((z,q)=>Number(q.isRepo)-Number(z.isRepo)),target:p.target,answered:p.query,others:l}),[u,p,g,l]),x=_=>RN(f,_),b=()=>t({a:"close"}),j=()=>t({a:"close",back:!0}),N=_=>{t({a:"open-repo"}),n==null||n.send({t:"register-repo",path:_})},T=(_,P)=>{t({a:"open-repo"}),n==null||n.send({t:"create-repo",mode:"create",parent:_,name:P})},R=(_,P,z)=>t({a:"new-project",v:Mg({mode:_,name:P,parent:W9(u,c,m),...z?{url:z}:{}})}),$=()=>t({a:"open",overlay:{kind:"projects",form:"disk"}}),W=()=>t({a:"open",overlay:{kind:"add-machine"}}),A=(_,P)=>{const z=r.get(_);z&&(z.store.dispatch({a:"activate-repo",id:P}),r.activate(_))};return h.jsx(Rr,{anchored:e==="pill",initialQuery:e==="disk"?"~/":"",lead:e==="disk"?void 0:h.jsx("span",{className:"picker-chip",children:((I=u.find(_=>_.id===c))==null?void 0:I.name)??"no project"}),trailing:e==="disk"?void 0:h.jsx(Ot,{icon:"folder",label:"Find a project on disk",onClick:$}),items:[],filter:y,initialIndex:_=>_.findIndex(P=>P.kind==="repo"&&!P.machine&&P.repo.id===c),groupOf:_=>_.kind==="repo"&&_.machine?_.machine.name:i,keyOf:_=>_.kind==="repo"?_.machine?`${_.machine.origin}:${_.repo.id}`:_.repo.id:_.kind==="dir"?`d:${_.entry.path}`:_.kind==="open"?`open:${_.path}`:_.kind==="pending"?`p:${_.pending.id}`:_.kind==="clone"?`clone:${_.url}`:_.kind==="new"?"new-project":_.kind==="disk"?"open-folder":_.kind==="add-machine"?"add-machine":`new:${_.parent??""}/${_.name}`,rowClass:_=>Ue("picker-row",(_.kind==="new"||_.kind==="disk"||_.kind==="add-machine")&&"new-project-row"),onQuery:w,completionOf:_=>_.kind==="dir"?_.entry.isRepo?_.entry.path:`${_.entry.path}/`:null,narrowTo:_=>_.kind==="dir"&&!_.entry.isRepo?`${_.entry.path}/`:null,onPick:_=>{if(_.kind==="clone")return R("clone",_.name,_.url);if(_.kind==="create"&&!_.parent)return R("create",_.name);if(_.kind==="new")return R("create","");if(_.kind==="disk")return $();if(_.kind==="add-machine")return W();_.kind==="pending"?t({a:"watch-import",id:_.pending.id}):_.kind==="repo"&&_.machine?A(_.machine.origin,_.repo.id):_.kind==="repo"?t({a:"activate-repo",id:_.repo.id}):_.kind==="open"?N(_.path):_.kind==="dir"?N(_.entry.path):_.parent&&T(_.parent,_.name),b()},onBack:j,rowMenu:_=>_.kind==="repo"&&_.machine?Mk(r,_.machine.origin):_.kind==="repo"?$f(_.repo,c,{sock:n,dispatch:t}):_.kind==="pending"?j6(_.pending,{sock:n,dispatch:t}):[],placeholder:u.length>1?"switch project, or type a name or path":"type a name or a path to start",keys:_=>({complete:"completes the path",pick:(_==null?void 0:_.kind)==="dir"&&!_.entry.isRepo?"descends":(_==null?void 0:_.kind)==="pending"?"watches it":(_==null?void 0:_.kind)==="create"?_.parent?"creates it":"names it":(_==null?void 0:_.kind)==="clone"?"clones it":(_==null?void 0:_.kind)==="new"?"starts one":(_==null?void 0:_.kind)==="disk"?"browses":(_==null?void 0:_.kind)==="add-machine"?"adds one":(_==null?void 0:_.kind)==="repo"&&_.machine?"switches machine":"opens",back:"closes"}),empty:"nothing here; keep typing a path (~/… or /…)",row:_=>_.kind==="repo"&&_.machine?h.jsx(Hn,{label:_.repo.name,hint:h.jsx(hB,{origin:_.machine.origin,repo:_.repo})}):_.kind==="repo"?h.jsx(Hn,{label:_.repo.name,current:_.repo.id===c,hint:x(_.repo)}):_.kind==="pending"?h.jsx(Hn,{label:_.pending.name,hint:_.pending.error?"import failed":"importing…"}):_.kind==="dir"?h.jsx(Hn,{label:_.entry.name,hint:_.entry.isRepo?"git repo":void 0}):_.kind==="open"?h.jsx(Hn,{label:`open ${_.path}`,hint:"register with this daemon"}):_.kind==="clone"?h.jsx(Hn,{label:`clone ${_.name}`,hint:pB(_.url)}):_.kind==="new"?h.jsx(Hn,{label:h.jsxs(h.Fragment,{children:[h.jsx(jt,{name:"plus",className:"icon-inline"}),"new project"]})}):_.kind==="disk"?h.jsx(Hn,{label:h.jsxs(h.Fragment,{children:[h.jsx(jt,{name:"folder",className:"icon-inline"}),"open folder"]})}):_.kind==="add-machine"?h.jsx(Hn,{label:h.jsxs(h.Fragment,{children:[h.jsx(jt,{name:"globe",className:"icon-inline"}),"add a machine"]})}):h.jsx(Hn,{label:`create ${_.name}`,hint:_.parent?`in ${_.parent}`:"new project"})})}function RN(e,t){const n=e.filter(c=>c.repoId===t.id),r=n.filter(An).filter(c=>c.worktree.kind!=="spare"),o=r.filter(jc).length,i=r.length-1,l=n.length-n.filter(An).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 hB({origin:e,repo:t}){const n=To(),r=n.get(e),o=Aa(r??n.active(),i=>i.rows);return h.jsx(h.Fragment,{children:r?RN(o,t):null})}function pB(e){const t=e.match(/^[a-z+]+:\/\/(?:[^@/]*@)?([^/:]+)/i)??e.match(/^[^@]+@([^:]+):/);return(t==null?void 0:t[1])??"git remote"}function mB(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:()=>Qt(r)})}const n=[{id:"copy-ref",label:e.kind==="pr"?"copy PR number":"copy branch name",onClick:()=>Qt(e.ref)}];return Dn([t,n])}const gB=[],kB={branch:"branch",remote:"globe",pr:"pr"},hx={pr:0,branch:1,remote:2},wB={pr:"pull requests",branch:"branches",remote:"remote branches"};function yB({repoId:e}){const t=at(),n=lt(),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"},u=S.useCallback(m=>[...m].sort((g,w)=>hx[g.kind]-hx[w.kind]),[]),c=S.useCallback(m=>n==null?void 0:n.send({t:"search-refs",repoId:e,query:m.trim()}),[n,e]),f=m=>!o||o.query!==m.trim(),p=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 h.jsx(Rr,{items:(o==null?void 0:o.refs)??gB,filter:u,onQuery:c,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:mB,groupOf:m=>m.kind,groupHead:(m,g)=>`${wB[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=>f(m)?"looking…":m.trim()?"no branch or PR matches":"no unmerged branches or open PRs",row:m=>h.jsx(Hn,{label:h.jsxs(h.Fragment,{children:[h.jsx(jt,{name:kB[m.kind],className:"icon-inline"}),h.jsx("span",{className:"ref-name",children:m.name})]}),hint:p(m)})})}const px=[],Yp=2;function vB({worktreeId:e}){const t=at(),n=lt(),r=xE(e).search,o=M(f=>f.layout.changes),i=M(f=>{var m;const p=(m=dn(f,e))==null?void 0:m.worktree;return p?p.path:null}),l=S.useCallback((f,p)=>p.trim().length>=Yp?f:px,[]),u=S.useCallback(f=>{const p=f.trim();p.length>=Yp&&(n==null||n.send({t:"search",worktreeId:e,query:p}))},[n,e]),c=f=>!r||r.query.trim()!==f.trim();return h.jsx(Rr,{items:(r==null?void 0:r.hits)??px,filter:l,onQuery:u,keyOf:f=>`${f.path}:${f.line}`,rowClass:()=>"search-hit",rowTitle:f=>`${f.path}:${f.line}`,onPick:f=>{er({dispatch:t},{worktreeId:e,path:f.path,view:"file",line:{n:f.line}}),o||t({a:"toggle-changes"}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:f=>i?ys({id:e,dir:i},f.path,{},{sock:n,dispatch:t}):[],placeholder:"search in files…",keys:{pick:"opens the file",back:"closes"},empty:f=>f.trim().length<Yp?"type at least two characters":c(f)?"searching…":"no matches",footer:(f,p)=>r!=null&&r.truncated&&!c(f)&&p.length>0?h.jsxs("div",{className:"empty",children:["showing the first ",p.length,"; narrow the search"]}):null,row:f=>h.jsxs(h.Fragment,{children:[h.jsxs("span",{className:"search-loc",children:[f.path,":",f.line]}),h.jsx("span",{className:"search-text",children:f.text})]})})}const mx=e=>e.source==="file"?"~/.toyon/themes":e.source==="vscode"?"VS Code":"";function bB({slot:e}){const t=at(),n=lt(),r=M(N=>N.themePrefs),o=M(N=>N.themes),i=Ug(),l=xg(r,i),u=r[e==="theme"?l:e],c=()=>t({a:"close"}),f=()=>t({a:"close",back:!0}),p=N=>t({a:"preview-theme",theme:N}),[m,g]=S.useState(null),[w,y]=S.useState(null),x=(N,T)=>N[T??l]??N.dark??N.light??null,b=S.useMemo(()=>P2(o),[o]),j=S.useMemo(()=>o.filter(N=>N.kind===e),[o,e]);return vt([m,w],()=>{e==="theme"&&p(m?x(m,w):null)}),e!=="theme"?h.jsx(Rr,{items:j,filter:(N,T)=>N.filter(R=>Es(T,R.name,R.id)),rowClass:()=>"picker-row",keyOf:N=>N.id,initialIndex:N=>N.findIndex(T=>T.id===u),onActive:p,onPick:N=>{n==null||n.send({t:"set-theme",prefs:{...r,[e]:N.id}}),c()},onBack:f,placeholder:`${e} slot override`,keys:{nav:"preview",pick:"keeps",back:"reverts"},empty:"no matching theme",row:N=>h.jsx(Hn,{label:N.name,current:N.id===u,hint:mx(N)})}):h.jsx(Rr,{items:b,filter:(N,T)=>N.filter(R=>{var $,W;return Es(T,R.name,($=R.dark)==null?void 0:$.name,(W=R.light)==null?void 0:W.name)}),rowClass:()=>"picker-row",keyOf:N=>{var T,R;return N.name+(((T=N.dark)==null?void 0:T.id)??((R=N.light)==null?void 0:R.id))},initialIndex:N=>N.findIndex(T=>{var R,$;return((R=T.dark)==null?void 0:R.id)===u||(($=T.light)==null?void 0:$.id)===u}),onActive:g,onSide:N=>{var T;N.dark&&N.light&&y((((T=x(N,w))==null?void 0:T.kind)??l)==="dark"?"light":"dark")},onPick:N=>{n==null||n.send({t:"set-theme",prefs:D2(r,N)}),c()},onBack:f,placeholder:"theme",keys:{nav:"preview",side:"dark/light",pick:"keeps",back:"reverts"},empty:"no matching theme",row:(N,T)=>{var A,I;const R=x(N,T?w:null),$=mx(N.dark??N.light),W=((A=N.dark)==null?void 0:A.id)===u||((I=N.light)==null?void 0:I.id)===u;return h.jsx(Hn,{label:N.name,current:W,hint:h.jsxs("span",{className:"theme-kinds",children:[$&&h.jsx("span",{children:$}),h.jsx("span",{className:"kind","data-state":mr({current:T&&(R==null?void 0:R.kind)==="dark"}),children:N.dark?"dark":""}),h.jsx("span",{className:"kind","data-state":mr({current:T&&(R==null?void 0:R.kind)==="light"}),children:N.light?"light":""})]})})}})}function $N(){const e=RL(),t=M(i=>i.frame==="phone"),n=sl(),r=M(i=>i.activeRepoId),o=M(i=>i.newProject);return h.jsxs(h.Fragment,{children:[(e==null?void 0:e.kind)==="quick-open"&&n&&h.jsx(p8,{worktreeId:n}),(e==null?void 0:e.kind)==="search"&&n&&h.jsx(vB,{worktreeId:n}),(e==null?void 0:e.kind)==="element-sources"&&h.jsx(K9,{worktreeId:e.worktreeId,hits:e.hits}),(e==null?void 0:e.kind)==="refs"&&r&&h.jsx(yB,{repoId:r}),(e==null?void 0:e.kind)==="chats"&&r&&h.jsx(H9,{repoId:r,scope:e.names?"names":"all"}),(e==null?void 0:e.kind)==="keys"&&h.jsx(j9,{}),(e==null?void 0:e.kind)==="pair"&&h.jsx(fB,{}),(e==null?void 0:e.kind)==="add-machine"&&h.jsx(y9,{}),(e==null?void 0:e.kind)==="theme"&&h.jsx(bB,{slot:e.slot}),(e==null?void 0:e.kind)==="appearance"&&h.jsx(P9,{}),(e==null?void 0:e.kind)==="keep-awake"&&h.jsx(X9,{}),(e==null?void 0:e.kind)==="agent"&&h.jsx(O9,{}),(e==null?void 0:e.kind)==="agent-page"&&h.jsx(R9,{agentId:e.agent}),(e==null?void 0:e.kind)==="handoff"&&h.jsx(V9,{worktreeId:e.worktreeId}),(e==null?void 0:e.kind)==="commands"&&!t&&h.jsx(hN,{}),(e==null?void 0:e.kind)==="projects"&&e.form!=="pill"&&h.jsx(Gk,{form:e.form},e.form),(e==null?void 0:e.kind)==="choose-folder"&&o&&h.jsx(G9,{project:o})]})}const ac="Lost the daemon; retrying",xB="Not run by Toyon",ON="new worktree",EB=(e,t)=>`in ${e}, started from ${t}`,_B=new Set(["waiting","working","starting","failed","crashed"]);function Xm(e,t){if(t.offline)return ac;if(!An(e))return e.locked?`Held by ${e.lockReason??"another tool"}`:t.path;if(t.op)return Ag(t.op);if(Ir(e.worktree))return ON;const n=Cg(e,t.needsSetup),r=e.worktree.lastTurn;return!_B.has(oi(e))&&r?dk(r):t.at&&t.at!=="now"?`${n} · ${t.at}`:n}function SB(e,t){if(!An(e)||t)return!1;const n=oi(e);return(n==="idle"||n==="asleep")&&!e.unseen}function NB(e){const t=e.worktree.lastTurn,n=e.worktree.landed?lk(e.worktree.lands):[],r=t?(jc(e)?B4:dk)(t):void 0,o=e.worktree.pr&&!e.worktree.landed?ks(e.worktree.pr):void 0;return[...n,r,o].filter(i=>!!i)}function TB(e,t,n,r){let o;const i=(p,m)=>{const g=m==null?void 0:m[m.length-1];g&&(!o||g.at>o.mark.at)&&(o={title:p,mark:g})};for(const p of e)p.worktree&&i(p.worktree.title,p.worktree.lands);for(const p of t)i(p.title,p.lands);const l=o&&ak(o.mark),u=o?`Landed ${o.title} ${Fo(eo(o.mark.at))}${l?`: ${Ur(l)}`:"."}`:void 0,c=n?d_(r,n):null,f=c?Ur(`${c.charAt(0).toUpperCase()}${c.slice(1)}`):n!=null&&n.fetchedAt?`Level with origin, fetched ${Fo(eo(n.fetchedAt))}.`:void 0;return[u,f].filter(p=>!!p)}function jB(e){const t=e.prompt?ik(e.prompt):"";return[...t?[t]:[],...lk(e.lands)]}function CB(e){const n=[e.auto&&AB(e.auto,!!e.landed),e.cost!==void 0?Oc(e.cost):void 0].filter(r=>!!r);return n.length?n:void 0}function AB(e,t){const{what:n,idle:r}=xj(e);return r?`${t?"":`${n}, `}${r} idle`:n}const gx=25;function IB(e,t){if(e.length<=gx+1)return{shown:e,rest:0};const n=e.slice(0,gx),r=t?e.find(o=>o.id===t):void 0;return r&&!n.includes(r)&&n.push(r),{shown:n,rest:e.length-n.length}}const RB=.5;function $B(e){const t=e.usage,n=t&&t.size>0?t.used/t.size:0,r=[n>=RB?`${Math.round(100*n)}% of context`:void 0,e.queued?`${e.queued} queued`:void 0,(t==null?void 0:t.cost)!==void 0?Oc(t.cost):void 0].filter(o=>!!o);return r.length?r:void 0}const cd=e=>e>999?"1k+":String(e);function MN({width:e,placement:t="strip"}){const n=t==="screen",r=Ki(),o=M(X=>X.chatSide)==="left"?"right":"left",i=at(),l=lt(),{host:u}=$r(),c=Zg(),f=c[0]&&Ir(c[0].worktree)?c[0]:null,p=f?c.slice(1):c,m=M(X=>Xa(X,X.activeRepoId)),g=X=>f&&X.id===f.id&&m?{behind:m.behind,dirty:m.dirty}:X,[,w]=S.useState(0);S.useEffect(()=>{const X=setInterval(()=>w(fe=>fe+1),6e4);return()=>clearInterval(X)},[]);const y=SL(),x=NL(),b=TL(),j=jL(),N=(X,fe,dt)=>{X.key!=="ArrowLeft"&&X.key!=="ArrowRight"||X.shiftKey||X.altKey||X.metaKey||X.ctrlKey||(X.preventDefault(),Cf([{depth:0,open:fe}],0,X.key)&&i({a:dt}))},T=Hi(),R=M(X=>X.clientId),$=M(X=>X.frame),W=M(X=>X.activeRepoId),A=M(X=>X.connected);S.useEffect(()=>{l&&A&&W&&l.send({t:"list-archived",repoId:W})},[l,A,W]);const I=sl(),_=vE(),P=M(X=>X.layout),z=M(X=>X.railOpen),q=M(X=>X.railPeek),se=S.useRef(null),[Y,ge]=S.useState(!1);vt([q],()=>{var X;q&&!n&&!r&&!((X=se.current)!=null&&X.matches(":hover"))&&ge(!0)}),S.useEffect(()=>{if(!Y)return;let X=null;const fe=dt=>{if(!X){X={x:dt.clientX,y:dt.clientY};return}Math.abs(dt.clientX-X.x)+Math.abs(dt.clientY-X.y)<3||ge(!1)};return window.addEventListener("pointermove",fe),()=>window.removeEventListener("pointermove",fe)},[Y]);const ke=M(X=>X.focusRail),oe=S.useRef(ke),L=S.useRef(null);vt([ke],()=>{if(ke===oe.current)return;oe.current=ke;const X=requestAnimationFrame(()=>{var fe,dt;return(dt=(fe=L.current)==null?void 0:fe.querySelector('[data-state~="current"]'))==null?void 0:dt.focus()});return()=>cancelAnimationFrame(X)});const re=M(X=>X.repos),te=M(X=>X.shipping),K=M(X=>X.rows),B=X=>re.find(fe=>fe.id===X.repoId)??null,xe=X=>W?zg(X,W,K):null,de=fn("rail"),we=Vg(),ee=M(X=>X.home),J=X=>{const fe=X.worktree?X.worktree.path:X.path;return ee&&fe.startsWith(`${ee}/`)?`~${fe.slice(ee.length)}`:fe},[pe,$e]=S.useState(!1),[le,ae]=S.useState([]),Fe=X=>{!hd(X.worktree)||xe(X)||($e(!0),ae(fe=>fe.includes(X.worktree.id)?fe.filter(dt=>dt!==X.worktree.id):[...fe,X.worktree.id]))},Qe=()=>{$e(!1),ae([])};vt([pe],()=>{const X=fe=>fe.key==="Escape"&&Qe();return pe&&window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)});const ze=sk(l,i),Re={sock:l,dispatch:i},ct=X=>{$e(!0),ae(fe=>X===I||fe.includes(X)?fe:[...fe,X])},_n=X=>An(X)?l_(X,B(X),{layout:P,shipping:te,frame:$,repos:re},Re,{...xe(X)?{}:{graft:ct},hostname:u}):I4(X,{clientId:R,frame:$},Re,u),ht=IB(b,(T==null?void 0:T.id)??null),tn=ht.shown.some(X=>(X.dirty??0)>0),Vt=X=>h.jsxs("button",{type:"button",className:Ue("row row-edge row-quiet rail-disc-item rail-arch-item",(we==null?void 0:we.owner)==="rail"&&we.key===X.id&&"menu-open"),"data-state":mr({current:!n&&(T==null?void 0:T.id)===X.id}),...Dt(kD(X),void 0,{placement:o,card:!0,detail:jB(X),aside:CB(X)}),onClick:()=>i({a:"open-archived",id:X.id}),...de.contextMenu(()=>yd(X,{clientId:R,frame:$},Re),X.id),children:[h.jsxs("span",{className:"rail-gut",onClick:r?fe=>{fe.stopPropagation(),de.openUnder(fe.currentTarget,()=>yd(X,{clientId:R,frame:$},Re),X.id)}:void 0,children:[h.jsx("span",{className:"rail-at row-dim",children:eo(X.archivedAt)}),h.jsx("span",{className:"rail-more",...Dt("Actions"),onClick:fe=>{fe.stopPropagation(),de.openUnder(fe.currentTarget,()=>yd(X,{clientId:R,frame:$},Re),X.id)},children:h.jsx(jt,{name:"more"})})]}),h.jsx("span",{className:"branch",children:X.title}),tn&&h.jsx("span",{className:"rail-counts",children:h.jsx("span",{className:"rail-count row-dim","data-tip":X.dirty?`${X.dirty} uncommitted, kept`:void 0,children:X.dirty?`~${cd(X.dirty)}`:""})}),X.auto?h.jsx("span",{className:"rail-glyph rail-auto row-dim",children:h.jsx(jt,{name:"clock",className:"icon-inline"})}):h.jsx("span",{className:"dot"}),n&&h.jsx("span",{className:"rail-at rail-at-end row-dim",children:eo(X.archivedAt)})]},X.id),He=[...c,...y].map(g),nt=["ahead","dirty","behind"].filter(X=>He.some(fe=>(fe[X]??0)>0)),an=X=>{const fe=nt.findIndex(dt=>(X[dt]??0)>0);return new Set(fe<0?[]:nt.slice(fe))},It=X=>{var qn;const fe=An(X)?X:null,dt=!!fe&&Ir(fe.worktree),Ke=g(X),pn=re.find(ft=>ft.id===X.repoId)??null,mn=pn?nf(pn):"main",Sn=pn&&lC(pn)&&(m!=null&&m.fetchedAt)?` as of ${u_(m.fetchedAt)}`:"",Ct=an(Ke),Nn=!!Ke.ahead&&!Ke.dirty,ut=X.id,Ee=(we==null?void 0:we.owner)==="rail"&&we.key===ut,De=fe?xe(fe):null,gn=De&&fe?B(fe):null,bn=fe&&!De&&pe&&hd(fe.worktree)&&ut!==I,wn=H1(X,(qn=te[ut])==null?void 0:qn.op);return h.jsxs("button",{type:"button",className:Ue("row row-edge",fe?"rail-item":"row-quiet rail-disc-item",n&&SB(X,wn)&&"row-quiet",Ee&&"menu-open"),"data-state":mr({current:!n&&ut===I&&!T,checked:le.includes(ut)}),...fe?Dt(_?ac:wn?Ag(wn):Cg(X,Od(B(fe))),void 0,{placement:o,card:!0,aside:$B(X),detail:Ir(fe.worktree)?TB(c,b,m,mn):[...De&&gn?[EB(gn.name,De.worktree.title)]:[],...NB(fe)],dot:_?void 0:wn?"spinner":oi(X)}):Dt(_?ac:X.locked?`Held by ${X.lockReason??"another tool"}`:xB,void 0,{placement:o,card:!0,detail:J(X),dot:_||X.locked?void 0:"discovered"}),"data-wt":ut,onKeyDown:ft=>{var me,_e;if(!fe||pe||ft.key!=="ArrowUp"&&ft.key!=="ArrowDown"||ft.altKey||ft.ctrlKey||ft.metaKey)return;ft.preventDefault();const Mt=ft.key==="ArrowDown",nn=c.findIndex(Ge=>Ge.id===ut),H=c[nn+(Mt?1:-1)];H&&(i({a:"activate",id:H.id}),(_e=(me=ft.currentTarget.parentElement)==null?void 0:me.querySelector(`[data-wt="${H.id}"]`))==null||_e.focus())},onClick:ft=>{fe&&!De&&(pe||ft.shiftKey)?ut===I?$e(!0):Fe(fe):dt&&!n?i({a:"open-draft"}):(i({a:"activate",id:ut}),fe&&!r&&i({a:"walked"}))},...de.contextMenu(()=>_n(X),ut),children:[h.jsx("span",{className:"rail-gut",onClick:r&&!pe?ft=>{ft.stopPropagation(),de.openUnder(ft.currentTarget,()=>_n(X),ut)}:void 0,children:bn?h.jsx("input",{type:"checkbox",className:"rail-graft-check",checked:le.includes(ut),readOnly:!0,tabIndex:-1}):!pe&&h.jsxs(h.Fragment,{children:[fe&&!dt&&h.jsx("span",{className:"rail-at row-dim",children:eo(lc(fe.worktree))}),h.jsx("span",{className:"rail-more",...Dt("Actions"),onClick:ft=>{ft.stopPropagation(),de.openUnder(ft.currentTarget,()=>_n(X),ut)},children:h.jsx(jt,{name:"more"})})]})}),dt?h.jsxs("span",{className:"branch rail-main-label",children:[h.jsx(jt,{name:"plus",className:"icon-inline"}),"new worktree"]}):h.jsx("span",{className:Ue("branch",(fe==null?void 0:fe.worktree.unnamed)&&"row-dim"),children:gm(X,fe?B(fe):null)}),(fe==null?void 0:fe.worktree.mode)&&fe.worktree.mode!=="auto"&&h.jsx("span",{className:"rail-badge badge-mode","data-tip":`${fe.worktree.mode} mode: the agent waits for you`,children:fe.worktree.mode}),fe&&(()=>{const ft=B(fe),Mt=s_(fe.worktree,ft);return Mt&&Mt!==(ft==null?void 0:ft.config.defaultProfile)?h.jsx("span",{className:"rail-badge badge-profile","data-tip":`runs the ${Mt} profile`,children:Mt}):null})(),(fe==null?void 0:fe.worktree.variant)&&h.jsxs("span",{className:"rail-badge badge-variant clickable","data-tip":"Keep this variant, archive the others",onClick:ft=>{ft.stopPropagation(),ze.pickVariant(fe)},children:[h.jsxs("span",{className:"num",children:["v",fe.worktree.variant.index,"/",fe.worktree.variant.of]}),h.jsx("span",{className:"act",children:"pick"})]}),gn&&h.jsx("span",{className:"rail-guest row-dim",children:gn.name}),h.jsxs("span",{className:"rail-counts",children:[Ct.has("ahead")&&h.jsx("span",{className:"rail-count badge-ahead","data-tip":Ke.ahead?`${Ke.ahead} ahead of ${mn}`:void 0,children:Ke.ahead?`+${cd(Ke.ahead)}`:""}),Ct.has("dirty")&&!Nn&&h.jsx("span",{className:"rail-count badge-dirty","data-tip":Ke.dirty?`${Ke.dirty} uncommitted${dt?" on main":""}`:void 0,children:Ke.dirty?`~${cd(Ke.dirty)}`:""}),Ct.has("behind")&&h.jsx("span",{className:"rail-count rail-behind row-dim","data-tip":Ke.behind?`${Ke.behind} behind ${dt?"origin":mn}${dt?"":Sn}`:void 0,children:Ke.behind?cd(Ke.behind):""}),n&&fe&&h.jsx("span",{className:"rail-at row-dim",children:dt?"":eo(lc(fe.worktree))})]}),(()=>{if(wn)return h.jsx(el,{size:"dot"});if(X.locked)return h.jsx("span",{className:"rail-glyph rail-lock row-dim",children:h.jsx(jt,{name:"lock",className:"icon-inline"})});if(!fe)return h.jsx("span",{className:"dot discovered"});const ft=pe||_?null:K1(X.procs),Mt=X.unseen?" unseen":"",nn=oi(X);return dt&&!ft&&nn!=="crashed"&&!_?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:`dot ${nn} rail-main-dot`}),h.jsx("span",{className:"rail-glyph rail-main-strip",children:h.jsx(jt,{name:"plus"})})]}):!ft||nn!=="crashed"?h.jsx("span",{className:`dot ${nn}${Mt}`}):h.jsx("span",{className:`dot crashed clickable${Mt}`,...Dt(ft.tip),onClick:H=>{H.stopPropagation(),i({a:"activate",id:ut}),i({a:"term-stream",id:ut,stream:ft.stream})}})})(),n&&h.jsx("span",{className:"rail-say row-dim",children:Xm(X,{offline:_,needsSetup:Od(fe?B(fe):null),path:J(X),op:wn})})]},ut)};return h.jsx("div",{ref:se,className:Ue("rail",n&&"rail-screen",!n&&(pe||(we==null?void 0:we.owner)==="rail"||q)&&"hold",Y&&"quiet",(n||z)&&"pinned",_&&"offline"),style:e!==void 0&&!n?{"--rail-width":`${e}px`}:void 0,onClick:r&&!n&&!z?X=>{X.target instanceof Element&&X.target.closest("button, .rail-gut")||i({a:"toggle-rail"})}:void 0,children:h.jsxs("div",{className:"rail-panel","data-tip":_?ac:void 0,"data-tip-placement":"follow",children:[h.jsxs("div",{className:"rail-list",ref:L,children:[f&&!n&&It(f),p.map(It),pe&&h.jsxs("div",{className:"rail-graft",children:[(()=>{const X=c.find(Ke=>Ke.worktree.id===I&&hd(Ke.worktree)&&!xe(Ke)),fe=le.filter(Ke=>Ke!==(X==null?void 0:X.worktree.id)),dt=fe.map(Ke=>{var pn;return((pn=c.find(mn=>mn.worktree.id===Ke))==null?void 0:pn.worktree.title)??Ke}).join(", ");return h.jsxs(Le,{size:"md",tone:"primary",disabled:!X||fe.length===0,"data-tip":X?`Merge the checked worktrees into ${X.worktree.title} and remove them`:"Select a worktree to graft onto",onClick:()=>{X&&window.confirm(`Graft ${dt} onto ${X.worktree.title}?
|
|
249
|
+
|
|
250
|
+
Their branches are merged in, then their directories and branches are removed.`)&&(l==null||l.send({t:"graft",targetId:X.worktree.id,sourceIds:fe}),Qe())},children:["graft ",fe.length]})})(),h.jsxs(Le,{size:"md",disabled:!le.some(X=>{var fe;return(((fe=c.find(dt=>dt.worktree.id===X))==null?void 0:fe.behind)??0)>0}),"data-tip":"Pull main into every selected worktree that's behind",onClick:()=>{for(const X of le){const fe=c.find(dt=>dt.worktree.id===X);((fe==null?void 0:fe.behind)??0)>0&&ti(l,i,{t:"sync-main",worktreeId:X})}Qe()},children:[h.jsx(jt,{name:"pull",className:"icon-inline"})," sync"]}),h.jsx(Le,{size:"md",tone:"danger",disabled:le.length===0,"data-tip":"Archive all selected worktrees; their chats and work are kept",onClick:()=>{window.confirm(`Archive ${le.length} worktree(s)?
|
|
251
|
+
|
|
252
|
+
Their directories and branches go. The chats, commits and any uncommitted changes are kept, and each can be restored.`)&&(Pi(l,i,le),Qe())},children:"archive…"}),h.jsx(Ot,{icon:"close",label:"Cancel",hint:"esc",onClick:Qe})]}),!pe&&y.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("button",{className:"section-title section-row section-fold rail-disc-head","aria-expanded":x,...Dt(`${y.length} worktree${y.length===1?"":"s"} here that Toyon did not make`,void 0,{placement:o}),onClick:()=>i({a:"toggle-discovered"}),onKeyDown:X=>N(X,x,"toggle-discovered"),children:[h.jsx("span",{className:"rail-gut",children:h.jsx(jt,{name:"caret",className:Ue("icon-inline disc-caret",!x&&"shut")})}),h.jsx("span",{className:"rail-label",children:"discovered"})]}),x&&y.map(It)]}),!pe&&b.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("button",{type:"button",className:"section-title section-row section-fold rail-disc-head","aria-expanded":j,...Dt(`${b.length} archived worktree${b.length===1?"":"s"}, kept with ${b.length===1?"its chat":"their chats"}`,void 0,{placement:o}),onClick:()=>i({a:"toggle-archived"}),onKeyDown:X=>N(X,j,"toggle-archived"),children:[h.jsx("span",{className:"rail-gut",children:h.jsx(jt,{name:"caret",className:Ue("icon-inline disc-caret",!j&&"shut")})}),h.jsx("span",{className:"rail-label",children:"archived"})]}),j&&ht.shown.map(Vt),j&&ht.rest>0&&W&&h.jsxs("button",{type:"button",className:"row row-quiet rail-disc-item rail-arch-item",...Dt("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:[h.jsx("span",{className:"rail-gut"}),h.jsxs("span",{className:"branch row-dim",children:[ht.rest," more"]}),h.jsx("span",{className:"dot"})]})]})]}),!n&&h.jsx("div",{className:"rail-foot",children:h.jsx(Ot,{icon:"worktrees",label:"Worktree panel",hint:At("rail"),tone:"chrome",on:z,onClick:()=>i({a:"toggle-rail"})})})]})})}function OB(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=P1(t.rows,null);return n?`${n.n} ${n.tier==="waiting"?"waiting":"unread"}`:"all quiet"}function MB({machine:e}){const t=To(),n=fn("machines"),r=Aa(e,m=>m.rows),o=Aa(e,m=>m.connected),i=Aa(e,m=>m.connectFailure),l=Aa(e,m=>m.incompatible),u=Aa(e,m=>{var g;return(g=m.remote)==null?void 0:g.front}),c=t.displayName(e.origin),f=OB(c,{rows:r.filter(An),connected:o,connectFailure:i,incompatible:l,suspended:u==="edge"&&!o}),p=/^\d+ /.test(f);return h.jsxs("button",{type:"button",className:"row machine-row",onClick:()=>t.activate(e.origin),...n.contextMenu(()=>Mk(t,e.origin)),children:[h.jsx("span",{className:"machine-name",children:c}),h.jsx("span",{className:Ue("machine-line",p?"machine-owed":"row-dim"),children:f})]})}function LB(){const e=To(),t=oo(),n=Bg();return n.length<2?null:h.jsxs("div",{className:"machine-rows",children:[h.jsx("div",{className:"section-title section-row machine-head",children:e.displayName(t.origin)}),n.filter(r=>r!==t).map(r=>h.jsx(MB,{machine:r},r.origin))]})}function PB({screen:e,tabs:t,fold:n}){const r=at(),o=To(),i=oo(),l=M(Y=>Y.reading),u=IL(),c=il(),f=M(Y=>Y.repos),p=_s(),m=sl(),g=Hi(),w=qg(),y=Zg(),x=vE(),b=P1(y,m),j=y.find(Y=>Ir(Y.worktree)),N=e==="home",T=!N&&!g&&!!p&&Ir(p.worktree),R=M(Y=>{var ge;return T&&p?H1(p,(ge=Y.shipping[p.id])==null?void 0:ge.op):null}),$=N?(u==null?void 0:u.name)??o.displayName(i.origin):T?ON:(g==null?void 0:g.title)??(p==null?void 0:p.worktree.title)??(w==null?void 0:w.name)??null,W=y.filter(Y=>!Ir(Y.worktree)).length,A=N?W===0?"no worktrees yet":`${W} ${W===1?"worktree":"worktrees"}`:g?S_(g):T?x?ac:R?Ag(R):(u==null?void 0:u.name)??null:p?Xm(p,{offline:x,needsSetup:Od(c),path:p.worktree.path,at:eo(lc(p.worktree))}):w?Xm(w,{offline:x,needsSetup:!1,path:w.path}):null,I=!N&&!g&&!!p&&oi(p)==="waiting",_=M(Y=>{var ge;return((ge=Y.overlay)==null?void 0:ge.kind)==="projects"&&Y.overlay.form==="pill"}),P=Bg().length,z=M(Y=>{var ge;return((ge=Y.overlay)==null?void 0:ge.kind)==="commands"}),q=h.jsxs("div",{className:"phone-title",children:[N&&(f.length>1||P>1)?h.jsxs("span",{className:"phone-drop phone-switch",children:[h.jsxs(Le,{tone:"chrome",on:_,onClick:()=>r({a:"toggle",overlay:{kind:"projects",form:"pill"}}),children:[h.jsx("span",{className:"phone-name",children:$}),h.jsx(jt,{name:"caret",className:"icon-inline"})]}),_&&h.jsx(Gk,{form:"pill"})]}):h.jsx("span",{className:"phone-name",children:$}),A&&h.jsx("span",{className:Ue("phone-sub",I&&"phone-sub-asks"),children:A})]}),se=b&&h.jsxs(Le,{size:"md",tone:"primary",onClick:()=>{const Y=Ng(y,m,1);Y&&r({a:"activate",id:Y.activate})},children:[b.n," ",b.tier]});return h.jsxs("div",{className:"phone-bar",children:[h.jsxs("div",{className:"phone-bar-row",children:[!N&&h.jsx(Ot,{icon:"back",label:"Worktrees",tone:"chrome",onClick:()=>r({a:"screen",to:"home"})}),t?h.jsx("div",{className:"phone-tabs",children:t}):q,!t&&se,N&&j&&h.jsx(Ot,{icon:"plus",label:"New worktree",tone:"chrome",onClick:()=>r({a:"activate",id:j.id})}),h.jsxs("span",{className:"phone-drop",children:[h.jsx(Ot,{icon:"more",label:"Menu",tone:"chrome",on:z,onClick:()=>r({a:"toggle",overlay:{kind:"commands"}})}),z&&h.jsx(hN,{anchored:{flip:"align",margin:6},trailing:h.jsx(Ot,{icon:"close",label:"Close",tone:"chrome",onClick:()=>r({a:"close"})})})]})]}),t&&!n&&h.jsx("div",{className:"phone-title-seat","data-away":l||void 0,children:h.jsxs("div",{className:"phone-title-strip",children:[q,se]})})]})}function DB({gated:e,active:t,url:n,hidden:r}){const o=Dg(t),i=YP(oo(),o?n:null,e);return h.jsx("div",{className:"phone-preview",hidden:r,children:o&&i?h.jsx("iframe",{className:"phone-preview-frame",src:i,title:t.worktree.title}):h.jsx(Ns,{wide:!0,children:h.jsx("p",{className:"status-line",children:Cg(t)})})})}const zB=Eg();function FB(){const e=S.useRef(null);EL(e);const t=at(),n=M(A=>A.screen),r=_s(),o=Hi(),i=qg(),l=M(A=>A.editor),u=M(A=>A.remote),c=Ic(),f=M(A=>A.connected),p=M(A=>A.heard),m=M(A=>A.connectFailure),g=Ki(),w=oo(),y=To(),x=M(A=>A.incompatible),b=r_({connected:f,heard:p,connectFailure:m,hasToken:w.serving?zB:!0,projectChord:At("project"),title:(r==null?void 0:r.worktree.title)??null,machine:w.serving?null:y.displayName(w.origin)}),j=n!=="home"&&(r!==null||o!==null||i!==null),N=j&&!c&&!o?r:null,{host:T}=$r(),R=N?kd(N.worktree.id,N.worktree.proxyPort,u,T):null,$=n==="preview"&&!N?"chat":n,W=[{id:"chat",label:"chat"},...N&&R?[{id:"preview",label:"preview",trail:h.jsx(Ot,{icon:"external",label:"Open in browser",tone:"chrome",onClick:()=>XP(w,R,Sm(w,u))})}]:[],{id:"changes",label:"code"}];return h.jsxs("div",{ref:e,className:"app phone","data-chat-side":"left","data-touch":g||void 0,"data-hover":!g||void 0,children:[h.jsx(YE,{}),h.jsx(e_,{}),h.jsx(PB,{screen:j?"chat":"home",fold:$!=="chat"||l!==null,tabs:j&&b===null&&h.jsx(jf,{fill:!0,segmented:!0,owner:"phone-tabs",label:"worktree",items:W,current:$,onPick:A=>t({a:"screen",to:A})})}),h.jsx("div",{className:"phone-screen",children:h.jsxs("div",{className:"center-root",children:[x&&!w.serving?h.jsx(n_,{foreign:y.displayName(w.origin)}):b!==null?h.jsx(Ns,{wide:!0,children:h.jsx("p",{className:"status-line",children:b})}):j?l?h.jsx(xN,{editor:l,placement:"screen"}):$==="chat"?h.jsx(ic,{placement:"screen",archived:o,found:i}):$==="changes"?h.jsx(x_,{placement:"screen"}):null:h.jsxs("div",{className:"phone-home",children:[h.jsx(LB,{}),h.jsx(MN,{placement:"screen"})]}),N&&R&&h.jsx(DB,{gated:Sm(w,u),active:N,url:R,hidden:$!=="preview"||l!==null},N.worktree.id),h.jsx($N,{})]})})]})}const BB=640,UB=1e3,LN=`(max-width: ${BB}px), ((hover: none) and (max-width: ${UB}px))`,PN="(hover: none)",DN=()=>{var e;return(e=window.matchMedia)!=null&&e.call(window,LN).matches?"phone":"desk"},HB=()=>{var e;return((e=window.matchMedia)==null?void 0:e.call(window,PN).matches)??!1};function KB(e){const t=(o,i)=>{var c;const l=(c=window.matchMedia)==null?void 0:c.call(window,o);if(!l)return()=>{};const u=f=>i(f.matches);return l.addEventListener("change",u),()=>l.removeEventListener("change",u)},n=t(LN,o=>e.dispatch({a:"frame",v:o?"phone":"desk"})),r=t(PN,o=>e.dispatch({a:"touch",v:o}));return()=>{n(),r()}}function WB(){try{const e=localStorage.getItem(Ye.theme);if(e){const t=JSON.parse(e);if(t!=null&&t.colors&&typeof t.colors.surface0=="string")return t}}catch{}return Tc}function zN(e,t={}){var o;const n=document.documentElement;for(const[i,l]of Object.entries($2(e)))n.style.setProperty(i,l);n.style.colorScheme=e.kind,n.dataset.theme=e.kind;const r=DN()==="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(Ye.theme,JSON.stringify(e))}catch{}}function FN(e){const t=bg(e);return{type:"theme",accent:t,accentFg:B2(t)}}function ZB(){var e;return((e=window.matchMedia)==null?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)??!0}const qB=12*36e5;function GB(){try{const e=localStorage.getItem(Ye.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<qB?{dark:!t.dark,until:0}:null}catch{return null}}function VB(e){try{localStorage.setItem(Ye.daylight,JSON.stringify(e))}catch{}}function YB(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 Qm(e,t){return[{id:"copy-name",label:"copy name",detail:e,onClick:()=>Qt(e)},{id:"copy-value",label:"copy value",detail:t,onClick:()=>Qt(t)}]}function Jm(e){return[{id:"copy-value",label:"copy value",detail:e,onClick:()=>Qt(e)}]}function XB(e,t,{sock:n},r){return t?Dn([[{id:"source",label:"open source",onClick:r}],Bi(`${e.dir}/${t}`,()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id,path:t}),os(n)),[{id:"copy-path",label:"copy path",onClick:()=>Qt(t)}]]):[]}function _c(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 QB(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());return t?t[1].length===4||t[1].length===8:!1}function kx([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 BN(e,t){if(QB(e))return null;const n=_c(e);if(!n)return null;const r=_c(t);if(!r)return null;const[o,i]=[kx(n),kx(r)];return`${((Math.max(o,i)+.05)/(Math.min(o,i)+.05)).toFixed(2)}:1`}function JB({worktreeId:e,height:t,full:n,onToggleFull:r,onDragStart:o}){const i=at(),l=lt(),u=M(f=>_o(f,e).design);S.useEffect(()=>{u||l==null||l.send({t:"design-scan",worktreeId:e})},[u,e,l]),S.useEffect(()=>()=>en.post(e,{type:"highlight-clear"}),[e]);const c={outline:f=>en.post(e,f),clear:()=>en.post(e,{type:"highlight-clear"}),open:f=>er({dispatch:i},{worktreeId:e,path:f})};return h.jsx(Zk,{kind:"design",className:Ue("design-pane",n&&"full"),height:n?void 0:t,resizable:!n,onDragStart:o,title:u?h.jsx("span",{children:rU(u)}):void 0,onClose:()=>i({a:"toggle-design"}),closeHint:At("design"),full:n,onToggleFull:r,actions:h.jsxs(Le,{variant:"outline",onClick:()=>l==null?void 0:l.send({t:"design-scan",worktreeId:e}),"data-tip":"Scan this worktree again",children:[h.jsx(jt,{name:"reload",className:"icon-inline"})," rescan"]}),children:u?h.jsxs("div",{className:"design-body",style:nU,onMouseLeave:c.clear,children:[u.tokens.length===0&&u.literals.length>0?h.jsx(cU,{literals:u.literals,outline:c.outline,clear:c.clear}):h.jsx(aU,{tokens:u.tokens,coverage:u.coverage,outline:c.outline,clear:c.clear}),h.jsx(wU,{index:u,outline:c.outline,clear:c.clear,onOpen:c.open}),h.jsx(yU,{index:u,outline:c.outline,clear:c.clear,onOpen:c.open})]}):h.jsx("div",{className:"empty",children:"reading the design system…"})})}const eU=720,tU=132,nU={"--design-column":`${eU}px`,"--design-cell":`${tU}px`};function rU(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 Pa=e=>`${e} use${e===1?"":"s"}`;function Lf({title:e,note:t,children:n}){return h.jsxs("section",{className:"design-section",children:[h.jsxs("h2",{className:"design-h",children:[e,t&&h.jsx("span",{className:"design-note",children:t})]}),n]})}function Jd({children:e}){return h.jsx("p",{className:"design-gap",children:e})}const oU=[{kind:"font",label:"type"},{kind:"color",label:"color"},{kind:"length",label:"size & radius"},{kind:"shadow",label:"shadow"},{kind:"other",label:"computed"}];function sU(e){return e.find(t=>t.kind==="color"&&_c(t.resolved??t.value)!==null)}function iU(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 aU({tokens:e,coverage:t,outline:n,clear:r}){const o=sU(e),i=o&&(o.resolved??o.value),l=new Map;for(const c of e){const f=(c.resolved??c.value).trim().toLowerCase();l.set(f,[...l.get(f)??[],c.name])}const u=c=>(l.get((c.resolved??c.value).trim().toLowerCase())??[]).filter(f=>f!==c.name);return h.jsx(Lf,{title:"Tokens",children:e.length===0?h.jsx(Jd,{children:iU(t)}):oU.map(({kind:c,label:f})=>{const p=e.filter(g=>g.kind===c);if(p.length===0)return null;const m=HN(p.map(g=>g.value));return h.jsxs("div",{className:"design-group",children:[c!=="font"&&h.jsx("span",{className:"design-group-name",children:f}),c==="font"?h.jsx(KN,{groups:pU(p),outline:n,clear:r}):h.jsx("div",{className:"design-breakout",style:UN(p.length),children:h.jsx("div",{className:"design-grid",children:p.map(g=>{const w=g.resolved??g.value,y=g.kind==="color"&&i?BN(w,i):null;return h.jsx(WN,{kind:g.kind,name:g.name,lines:g.resolved?[g.value,g.resolved]:[g.value],actual:w,ratio:y,largest:m,tipText:gU(g,y,o,u(g)),menu:()=>Qm(g.name,w),outline:n,clear:r},g.name)})})})]},c)})})}const lU=[{role:"color",kind:"color",label:"color"},{role:"radius",kind:"length",label:"radius"},{role:"shadow",kind:"shadow",label:"shadow"}];function cU({literals:e,outline:t,clear:n}){const r=e.find(i=>i.ground&&_c(i.value)!==null),o=mU(e);return h.jsxs(Lf,{title:"Values",note:"written out in the rules; no custom properties",children:[o.length>0&&h.jsx("div",{className:"design-group",children:h.jsx(KN,{groups:o,outline:t,clear:n})}),lU.map(({role:i,kind:l,label:u})=>{const c=e.filter(p=>p.role===i);if(c.length===0)return null;const f=HN(c.map(p=>p.value));return h.jsxs("div",{className:"design-group",children:[h.jsx("span",{className:"design-group-name",children:u}),h.jsx("div",{className:"design-breakout",style:UN(c.length),children:h.jsx("div",{className:"design-grid",children:c.map(p=>{const m=l==="color"&&r?BN(p.value,r.value):null;return h.jsx(WN,{kind:l,name:p.value,lines:[Pa(p.uses)],actual:p.value,ratio:m,largest:f,tipText:kU(p,m,r),menu:()=>Jm(p.value),outline:t,clear:n},p.value)})})})]},i)})]})}function UN(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 HN(e){return e.reduce((t,n)=>Math.max(t,Math.abs(Number.parseFloat(n))||0),0)}const uU=["color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color","outline-color"];function dU(e,t){if(!e)return[];const n=getComputedStyle(e);return t.map(r=>[r,n.getPropertyValue(r)])}const eg=e=>(e.split(",")[0]??e).replace(/["']/g,"").trim();function fU(e){const t=/^[1-9]00\s+([\d.]+)px(?:\s*\/\s*([\d.]+)(px)?)?\s+(.+)$/.exec(e.trim());if(!t)return{family:eg(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:eg(t[4]??""),size:n,lead:o}}function Xp(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 hU(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 pU(e){const t=e.map(n=>({token:n,actual:n.resolved??n.value,...fU(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}
|
|
253
|
+
${o.actual}`:void 0,menu:()=>o?Qm(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}
|
|
254
|
+
${i.actual}`,menu:()=>Qm(i.token.name,i.actual)}))}})}function mU(e){const t=e.filter(o=>o.role==="family"),n=e.filter(o=>o.role==="size");return[...new Set([...t.map(o=>o.value),...n.map(o=>o.family??"initial")])].map(o=>{const i=t.find(u=>u.value===o),l=o==="initial"?"default face":eg(o);return{family:l,stack:o,name:i?Pa(i.uses):void 0,label:l,tipText:i?`${i.value}
|
|
255
|
+
${Pa(i.uses)}: ${i.selectors.join(", ")}`:void 0,menu:()=>i?Jm(i.value):[],rows:n.filter(u=>(u.family??"initial")===o).sort((u,c)=>Xp(c.value)-Xp(u.value)).map(u=>{const c=Xp(u.value),f=hU(u.lead,c),p=u.value.endsWith("px")?`${c}`:u.value;return{key:`${u.value}/${u.lead??""}`,sample:`${l} ${p}${f===null?"":`/${f}`}`,style:{fontFamily:o,fontSize:u.value,lineHeight:u.lead},name:Pa(u.uses),label:u.value,tipText:`${u.value}${u.lead?` / ${u.lead}`:""}
|
|
256
|
+
${Pa(u.uses)}: ${u.selectors.join(", ")}`,menu:()=>Jm(u.value)}})}})}function KN({groups:e,outline:t,clear:n}){const r=(i,l,u)=>t({type:"highlight-computed",props:dU(i.currentTarget.querySelector(".design-face-sample"),l?["font-family","font-size","line-height"]:["font-family"]),match:"all",label:u}),o=fn("design");return h.jsx("div",{className:"design-faces",children:e.map(i=>h.jsxs("div",{className:"design-face-group",children:[h.jsxs("div",{className:"design-face-head row-edge",onMouseEnter:l=>r(l,!1,i.label),onMouseLeave:n,...o.contextMenu(i.menu),...i.tipText?Dt(i.tipText,void 0,{placement:"follow"}):{},children:[h.jsx("span",{className:"design-face-sample design-face-family",style:{fontFamily:i.stack},children:i.family}),i.name&&h.jsx("span",{className:"design-face-name row-dim",children:i.name})]}),i.rows.map(l=>h.jsxs("div",{className:"design-face row-edge",onMouseEnter:u=>r(u,!0,l.label),onMouseLeave:n,...o.contextMenu(l.menu),...Dt(l.tipText,void 0,{placement:"follow"}),children:[h.jsx("span",{className:"design-face-sample",style:l.style,children:l.sample}),h.jsx("span",{className:"design-face-name row-dim",children:l.name})]},l.key))]},i.stack))})}function WN({kind:e,name:t,lines:n,actual:r,ratio:o,largest:i,tipText:l,menu:u,outline:c,clear:f}){const p=e==="color"&&_c(r)!==null,m=e==="length"?Number.parseFloat(r):Number.NaN,g=fn("design");return h.jsxs("div",{className:"design-cell","data-kind":e,...g.contextMenu(u),onMouseEnter:p?w=>{const y=w.currentTarget.querySelector(".design-fill"),x=y?getComputedStyle(y).backgroundColor:"";c({type:"highlight-computed",props:uU.map(b=>[b,x]),match:"any",label:t})}:void 0,onMouseLeave:p?f:void 0,...Dt(l),children:[e==="color"&&h.jsx("div",{className:"design-sample",children:p&&h.jsx("span",{className:"design-fill",style:{background:r}})}),h.jsxs("div",{className:"design-plate",children:[h.jsx("span",{className:"design-cell-name",children:t}),n.map((w,y)=>h.jsxs("span",{className:"design-cell-line",children:[h.jsx("span",{className:"design-cell-value",children:w}),y===0&&o&&h.jsx("span",{className:"design-cell-note",children:o})]},w)),Number.isFinite(m)&&i>0&&h.jsx("span",{className:"design-scale",style:{width:`${Math.max(2,Math.abs(m)/i*100)}%`}})]})]})}function gU(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(`
|
|
257
|
+
`)}function kU(e,t,n){const r=[e.value,`${Pa(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(`
|
|
258
|
+
`)}function ZN({shared:e,rest:t}){return e.length===0?h.jsx("ul",{className:"design-rows",children:t}):h.jsxs(h.Fragment,{children:[h.jsx("ul",{className:"design-rows",children:e}),t.length>0&&h.jsxs("details",{className:"design-tail",children:[h.jsxs("summary",{className:"row-edge",children:[h.jsx("span",{className:"design-count row-dim",children:t.length}),"used once or never"]}),h.jsx("ul",{className:"design-rows",children:t})]})]})}function wU({index:e,outline:t,clear:n,onOpen:r}){const{components:o,typed:i}=e;if(o.length===0)return null;const l=o.filter(f=>f.imports>=2),u=o.filter(f=>f.imports<2),c=f=>h.jsx(qN,{count:f.imports,name:f.name,path:f.path,onEnter:()=>t({type:"highlight-file",path:f.path,ranges:null}),onLeave:n,onOpen:()=>r(f.path),children:f.variants.length>0&&h.jsx("span",{className:"design-variants",children:f.variants.map(p=>h.jsxs("span",{className:"design-variant",children:[p.prop,": ",p.values.join(" · ")]},p.prop))})},`${f.path}:${f.name}`);return h.jsxs(Lf,{title:"Components",note:`${l.length} reused of ${o.length}`,children:[!i&&h.jsx(Jd,{children:"No TypeScript in this project, so the values each prop allows are not listed."}),h.jsx(ZN,{shared:l.map(c),rest:u.map(c)})]})}function yU({index:e,outline:t,clear:n,onOpen:r}){const{classes:o,coverage:i}=e,l=o.filter(g=>g.uses>0),u=o.filter(g=>g.uses>=2),c=o.filter(g=>g.uses<2),f=u.filter(g=>g.unwrapped).length,p=o.length?`${u.length} reused of ${o.length}`+(f?`, ${f} with no component of their name`:""):void 0,m=g=>h.jsx(vU,{cls:g,outline:t,clear:n,onOpen:r},g.name);return h.jsx(Lf,{title:"Classes",note:p,children:o.length===0?h.jsx(Jd,{children:"No stylesheet in this project defines a class. Utility-first CSS generates its own."}):l.length===0?h.jsx(Jd,{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."}):h.jsx(ZN,{shared:u.map(m),rest:c.map(m)})})}function vU({cls:e,outline:t,clear:n,onOpen:r}){return h.jsx(qN,{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&&h.jsx("span",{className:"design-tag",children:"no component"})})}function qN({count:e,name:t,path:n,onEnter:r,onLeave:o,onOpen:i,children:l}){const u=_s(),c=lt();at();const f=fn("design");return h.jsx("li",{children:h.jsxs("button",{type:"button",className:"design-row row-edge",onMouseEnter:r,onFocus:r,onMouseLeave:o,onBlur:o,onClick:i,disabled:!n,...f.contextMenu(()=>u?XB({id:u.worktree.id,dir:u.worktree.path},n,{sock:c},i):[]),children:[h.jsx("span",{className:"design-count row-dim",children:e}),h.jsx("span",{className:"design-name",children:t}),h.jsx("span",{className:"design-path row-dim",children:n}),l]})})}function bU({worktreeId:e,procs:t,borrowed:n,login:r,current:o,onRestart:i}){const l=lt();at();const u={sock:l},c=(p,m)=>h.jsx(Ot,{icon:"reload",label:m,onClick:()=>i(p)}),f={id:vs,label:"login",tip:Dt("The agent's login; it closes once you are in",void 0,{placement:"top"}),trail:c(vs,"Run the login again")};return r&&o===vs?[f]:[{id:vo,label:"shell",tip:Dt("A shell in this worktree",void 0,{placement:"top"}),menu:()=>LS(e,u),trail:c(vo,"Restart the shell")},...r?[f]:[],...t.map(p=>({id:p.name,label:p.name,lead:h.jsx("span",{className:`dot ${p.status}`}),tip:Dt(SM(p.status),void 0,{placement:"top",dot:p.status,name:p.name,detail:p.command,aside:[`:${p.port}`]}),menu:()=>Lk(p,e,u),trail:c(p.name,`Restart ${p.name}`)})),...n.map(p=>({id:p,label:p,lead:h.jsx("span",{className:"dot borrowed"}),tip:Dt(`${p} runs on main for every worktree; this one reaches it at its usual address`,void 0,{placement:"top"})}))]}const xU=S.lazy(()=>qm(()=>import("./XTerm-C_Gv5uo2.js"),__vite__mapDeps([3,4]))),EU=[];function _U({worktreeId:e,opened:t,height:n,onDragStart:r}){const o=at(),i=lt(),l=yf(),u=M(z=>z.connected),c=M(z=>z.focusTerm),f=_s(),p=(f==null?void 0:f.procs)??[],m=(f==null?void 0:f.borrowed)??EU,g=(f==null?void 0:f.login)??!1,w=Tt(e,"termStream"),y=M(z=>{var q;return((q=z.termRun)==null?void 0:q.id)===e&&w===vo?z.termRun.command:null}),[x,b]=S.useState(null),j=m.includes(w);S.useEffect(()=>{w===vo||(w===vs?g:p.some(q=>q.name===w)||m.includes(w))||o({a:"term-stream",id:e,stream:vo})},[p,m,g,w,e,o]);const N=z=>{z!==w&&(b(null),o({a:"term-stream",id:e,stream:z}))},T=S.useRef(!1),[R,$]=S.useState(0),W=z=>{z===vo&&z===w&&(T.current=!0),i==null||i.send({t:"term-restart",worktreeId:e,stream:z}),z===vs&&z===w&&(b(null),$(q=>q+1))},A=(z,q)=>{if(z)return b(null);if(T.current){T.current=!1,$(se=>se+1);return}b({code:q})},I=bU({worktreeId:e,procs:p,borrowed:m,login:g,current:w,onRestart:W}),_=S.useRef(!t),P=!_.current;return S.useEffect(()=>{_.current=!1},[]),h.jsxs(Zk,{kind:"terminal",className:"term-pane",height:n,onDragStart:r,tabs:{items:I,current:w,onPick:N,font:"mono",owner:"terminal",label:"terminal streams"},onClose:()=>o({a:"toggle-terminal"}),closeHint:At("terminal"),children:[h.jsxs("div",{className:"term-body",children:[j&&h.jsx(mc,{pane:!0,title:`${w} runs on main`,body:"Every worktree reaches main's copy until its own changes touch it, or until asked.",action:h.jsx(Le,{variant:"outline",onClick:()=>i==null?void 0:i.send({t:"own-procs",worktreeId:e,names:[w]}),children:"run it here"})}),h.jsx(ok,{pane:!0,children:h.jsx(S.Suspense,{fallback:h.jsx("div",{className:"empty",children:"loading terminal…"}),children:h.jsx(xU,{worktreeId:e,stream:w,theme:l,sock:i,connected:u,focusOnMount:P,focusReq:c,onAlive:A,run:y,onRan:()=>o({a:"term-ran"}),onEscape:()=>o({a:"toggle-terminal"})},`${w}:${R}`)})})]}),x!==null&&!j&&h.jsx(mc,{pane:!0,title:w===vo?"the shell exited":w===vs?"the login did not finish":`${w} exited`,body:x.code===void 0?void 0:`exit code ${x.code}`,action:h.jsx(Le,{variant:"outline",onClick:()=>W(w),children:"restart"})})]})}function SU(e){return e==="reserved"?"checking out a fresh worktree…":e==="warming"?"copying dependencies and running setup…":"starting dev servers…"}const NU="preview off; it starts when the agent writes a file";function TU({worktree:e,log:t}){const n=lt(),r=at(),o=e.procs,i=x=>n==null?void 0:n.send({t:"term-restart",worktreeId:e.id,stream:x.name}),l=o.some(x=>x.status==="crashed"||x.status==="unreachable"),u=M(x=>x.clientId),c=wc(e,"setup"),f=c&&c.status!=="terminated"?c:null,p=Ja(fk(f??void 0)?f==null?void 0:f.since:void 0),m=!!e.worktree.parked&&o.length===0,g=()=>n==null?void 0:n.send({t:"preview-start",worktreeId:e.id}),w=f&&(f.status==="running"||f.status==="detached"),y=()=>n==null?void 0:n.send({t:"fix-preview",worktreeId:e.id,clientId:u});return h.jsxs(Ns,{wide:!0,children:[o.length===0?h.jsx("div",{className:"status-line",children:f?h.jsx("span",{className:"live-text","data-tip":w_[f.status],children:jm("setup",f,p)}):m?NU:SU(e.worktree.phase)}):h.jsx("ul",{className:"boot-procs",children:o.map(x=>h.jsxs("li",{className:Ue("boot-proc",(x.status==="crashed"||x.status==="unreachable")&&"boot-bad"),children:[h.jsx("span",{className:"boot-name",children:x.name}),h.jsx("span",{className:"boot-status",children:jU(x)}),(x.status==="crashed"||x.status==="unreachable")&&h.jsx(Le,{variant:"outline",onClick:()=>i(x),children:"restart"}),x.detail&&x.status!=="asleep"&&h.jsx("div",{className:"boot-detail",children:x.detail})]},x.name))}),m&&h.jsx("div",{className:"status-actions",children:h.jsx(Le,{variant:"outline",size:"lg",onClick:g,children:"start preview"})}),w&&h.jsx("div",{className:"status-actions",children:h.jsx(Le,{variant:"outline","data-tip":y_("setup"),onClick:()=>n==null?void 0:n.send({t:"run-stop",worktreeId:e.id,kind:"setup"}),children:"stop setup"})}),l&&h.jsxs("div",{className:"status-actions",children:[e.agent==="idle"&&h.jsx(Le,{variant:"outline",size:"lg",onClick:y,children:"ask the agent to fix it"}),h.jsx(Le,{onClick:()=>r({a:"open",overlay:{kind:"setup",repoId:e.repoId}}),children:"edit setup"})]}),t.length>0&&h.jsx("pre",{className:"status-tail",children:t.slice(-30).map(x=>`[${x.proc}] ${x.line}`).join(`
|
|
259
|
+
`)})]})}function jU(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 CU(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 AU(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 IU({active:e}){const t=at(),n=lt(),r=il(),o=M(u=>u.home),i=e.worktree.title,l=()=>{r!=null&&r.made&&(t({a:"new-project",v:{...Mg({mode:r.made==="git"?"init":"create",name:r.name,parent:AN(r.path,o)??r.path}),phase:"unmaking",repoId:r.id}}),t({a:"move-box",from:e.worktree.id,to:Ya}),n==null||n.send({t:"unmake-repo",repoId:r.id}))};return h.jsx(Ns,{anchor:"line",foot:h.jsx("div",{className:"composer view-foot",children:h.jsx(sc,{active:e,greenfield:!0})}),children:h.jsx("p",{className:"form-title",children:r!=null&&r.made?h.jsx(Le,{variant:"inline",onClick:l,...Dt("Rename or move this project"),children:i}):i})})}function RU({pending:e}){const t=at(),n=lt(),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]),h.jsxs(Ns,{wide:!0,children:[h.jsxs("p",{className:"status-line",children:[r?"could not import":"importing"," ",e.name]}),h.jsxs("p",{children:["from ",h.jsx("code",{children:e.url})," into ",h.jsx("code",{children:e.parent})]}),r?h.jsx("p",{className:"import-error",children:e.error}):h.jsx("p",{className:"hint",children:"the whole history is cloned, so worktrees, land and graft all work on it straight away."}),h.jsx("div",{className:"status-tail",ref:i,children:e.lines.length===0&&!r?h.jsx("span",{className:"import-idle",children:"starting git…"}):e.lines.map((l,u)=>h.jsx("div",{children:l},u))}),h.jsx("div",{className:"status-actions",children:h.jsx(Le,{variant:"outline",size:"lg",onClick:o,children:r?"dismiss":"stop"})})]})}const $U=150,OU=/^[^\s@]+@[^\s@]+$/,MU=14;function LU({project:e}){var re;const t=at(),n=lt(),r=M(te=>te.repos),o=M(te=>te.home),i=M(te=>te.folderDialog),l=M(te=>te.gitIdentity),u=M(te=>te.choosingFolder),c=M(te=>te.chosenFolder),f=M(te=>te.paths),[p,m]=S.useState({name:"",email:""}),[g,w]=S.useState(null),[y,x]=S.useState(null),b=S.useRef(null),{mode:j,name:N,parent:T}=e,R=j==="clone",$=j==="init",W=e.phase==="editing",A=N.trim(),I=$||!A?null:hc(N),_=!$&&A&&!I?CN(T,A):null,P=Ym(T,o),z=_!==null&&f.query===_&&((re=f.target)==null?void 0:re.exists)===!0,q=!l&&!R,se=!q||p.name.trim()!==""&&OU.test(p.email.trim()),Y=W?g?"the folder you chose is already a project: open it, or choose another":!$&&!A?"name the project first":I??(z?`${P} already has a folder called ${A}`:se?null:"git needs your name and email first"):null;S.useEffect(()=>{if(!_)return;const te=setTimeout(()=>n==null?void 0:n.send({t:"browse-path",path:_}),$U);return()=>clearTimeout(te)},[_,n]),vt([e.phase],()=>{var te;e.phase==="editing"&&((te=b.current)==null||te.focus())}),vt([j,N,T],()=>x(null)),vt([e.error],()=>{e.error&&t({a:"notice",id:Ya,text:e.error})});const ge=()=>{Y||!W||(t({a:"open-repo"}),t({a:"new-project-set",v:{phase:"creating"}}),n==null||n.send({t:"create-repo",mode:j,parent:T.trim(),name:A,...R&&e.url?{url:e.url}:{},...q?{identity:{name:p.name.trim(),email:p.email.trim()}}:{}}))},ke=te=>{const K=r.find(B=>B.path===xc(te,o));if(K){t({a:"activate-repo",id:K.id});return}t({a:"open-repo"}),n==null||n.send({t:"register-repo",path:te})},oe=te=>{x(null),i?(t({a:"choosing-folder",v:te}),n==null||n.send({t:"choose-folder",start:T,purpose:te})):t(te==="location"?{a:"open",overlay:{kind:"choose-folder"}}:{a:"open",overlay:{kind:"projects",form:"disk"}})};vt([c==null?void 0:c.seq],()=>{var K,B;if(!u||!c)return;t({a:"choosing-folder",v:!1});const te=c.folder;if(!te){(K=b.current)==null||K.focus();return}if(u==="open"&&te.kind==="project"){ke(te.path);return}if(u==="open"&&te.kind==="folder"){x("that folder has files but is not a project yet; choose a project, or an empty folder to start one");return}if(w(te.kind==="project"?te.path:null),te.kind!=="project"){if(te.kind==="empty"&&!R){const xe=TN(te.path);t({a:"new-project-set",v:{mode:"init",parent:xe.parent,name:xe.name}});return}t({a:"new-project-set",v:{mode:R?"clone":"create",parent:te.path}}),(B=b.current)==null||B.focus()}});const L=y??($?"the empty folder you chose becomes the project":g?null:z?`${P} already has a folder called ${A}`:I);return h.jsxs(Ns,{anchor:"line",foot:h.jsx("div",{className:"composer view-foot",children:h.jsx(sc,{active:null,project:{name:A,why:Y,busy:!W,create:ge}})}),children:[R&&h.jsx("p",{className:"new-project-url",children:e.url}),h.jsxs("div",{className:"form-head",children:[$?h.jsx("p",{className:"form-title",children:N}):h.jsx(Eo,{ref:b,bare:!0,font:"lead",className:"new-project-field",autoFocus:!0,spellCheck:!1,autoComplete:"off",value:N,placeholder:"Project name",disabled:!W,style:{width:`${Math.max(N.length+1,MU)}ch`},onChange:te=>t({a:"new-project-set",v:{name:te.target.value}}),onKeyDown:te=>{te.key==="Enter"&&(te.preventDefault(),t({a:"focus-chat"}))}}),h.jsxs("span",{className:"new-project-where",children:[h.jsx("span",{className:"hint",children:"in"}),h.jsx("span",{className:"new-project-parent",...Dt(T),children:P}),h.jsx(Ot,{icon:"folder",label:i?"Choose in Finder":"Choose a folder",className:"new-project-folder",on:u==="location",disabled:!W,onClick:()=>oe("location")})]})]}),L&&h.jsx("p",{className:"hint",children:L}),g&&!y&&h.jsxs("p",{className:"hint",children:["the folder you chose is already a project:"," ",h.jsx(Le,{variant:"inline",autoFocus:!0,onClick:()=>ke(g),children:"open it"}),", or choose another"]}),q&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"new-project-identity",children:[h.jsx(Eo,{size:"md",font:"ui",rule:!0,value:p.name,placeholder:"Your name",autoComplete:"name",disabled:!W,onChange:te=>m({...p,name:te.target.value})}),h.jsx(Eo,{size:"md",font:"ui",rule:!0,type:"email",value:p.email,placeholder:"Email",autoComplete:"email",disabled:!W,onChange:te=>m({...p,email:te.target.value})})]}),h.jsx("p",{className:"hint",children:"git labels the work you save with these, and asks only once"})]}),!R&&W&&h.jsx(Le,{tone:"quiet",className:"new-project-open",onClick:()=>oe("open"),children:"or open a folder you already have"})]})}function Ca({label:e,hint:t,children:n}){return h.jsxs("label",{className:"form-row",children:[h.jsx("span",{className:"form-label",children:e}),h.jsxs("div",{className:"form-control",children:[n,t&&h.jsx("span",{className:"hint",children:t})]})]})}function PU(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(`
|
|
260
|
+
`)}function DU(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(`
|
|
261
|
+
`)}let zU=1;const Qp=(e,t,n=!1)=>({id:zU++,name:e,cmd:t,shared:n}),FU=[{id:"shared",label:"committed",description:"in the repo; everyone who opens it gets these settings"},{id:"local",label:"kept local",description:"in a file git never sees; for when only you use Toyon here"}];function BU({repo:e,onClose:t}){const n=lt(),r=Zn(),o=M(J=>J.clientId),i=M(J=>J.rows.find(pe=>{var $e;return An(pe)&&pe.id===(($e=Xa(J,e.id))==null?void 0:$e.id)})??null),l=M(J=>{var pe;return((pe=Xa(J,e.id))==null?void 0:pe.id)??null});S.useEffect(()=>{if(!t)return;const J=pe=>pe.key==="Escape"&&t();return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[t]);const[u]=S.useState(()=>Object.keys(e.config.run).length>0),[c,f]=S.useState(()=>{const J=Object.entries(e.config.run).map(([pe,$e])=>Qp(pe,$x($e),Fj($e)));return J.length>0?J:[Qp("web","")]}),[p,m]=S.useState(()=>(e.config.setup??[]).join(`
|
|
262
|
+
`)),[g,w]=S.useState(()=>(e.config.teardown??[]).join(`
|
|
263
|
+
`)),[y,x]=S.useState(()=>e.config.check??""),[b,j]=S.useState(()=>$i(e.config).land),[N,T]=S.useState(()=>$i(e.config).automerge),[R,$]=S.useState(()=>$i(e.config).merge??"default"),[W,A]=S.useState(()=>Hj(e.configFile)),I=Kj(e.configFile,W),_=!!e.remote&&b==="pr",P=c.length>1,z=c.some(J=>J.name.trim()&&J.cmd.trim()),se=!!i&&!t&&!u&&!z,Y=(J,pe)=>f(c.map(($e,le)=>le===J?{...$e,...pe}:$e)),ge=J=>J.split(`
|
|
264
|
+
`).map(pe=>pe.trim()).filter(Boolean),ke=()=>ge(p),oe=()=>ge(g),L=()=>{const{check:J,land:pe,teardown:$e,...le}=e.config,ae=e.remote?b:om,Fe=R==="default"||ae!=="pr"&&R===sm?void 0:R,Qe={...ae!==om?{route:ae}:{},...ae==="pr"&&N?{automerge:!0}:{},...Fe?{method:Fe}:{}};return{...le,setup:ke(),...oe().length>0?{teardown:oe()}:{},...y.trim()?{check:y.trim()}:{},...Object.keys(Qe).length>0?{land:Qe}:{}}},re=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...L(),run:Object.fromEntries(c.filter(J=>J.name.trim()&&J.cmd.trim()).map((J,pe)=>[J.name.trim(),J.shared&&pe>0?{cmd:J.cmd.trim(),from:"trunk"}:J.cmd.trim()]))},kind:W}),t==null||t()},te=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...L(),run:{}},kind:W}),t==null||t()},K=()=>n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:DU(e,I)}),B=e.services,xe=[p,g,...c.map(J=>J.cmd)].some(J=>J.includes("TOYON_WORKTREE"))||Bj(e.config),de=B?[B.envUrl?`the database at ${B.envUrl.name} in ${B.envUrl.file}`:null,B.compose?`the stack in ${B.compose}`:null].filter(Boolean).join(" and "):"",we=()=>B&&(n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:PU(e,I,B)})),ee=(J,pe)=>h.jsxs("div",{className:"setup-proc",children:[P&&h.jsx(Eo,{size:"md",rule:!0,className:"setup-name",value:J.name,placeholder:"name",...Dt("Process name, shown in the status bar"),onChange:$e=>Y(pe,{name:$e.target.value})}),h.jsx(Eo,{size:"md",rule:!0,className:"setup-cmd",value:J.cmd,placeholder:"npm run dev",onChange:$e=>Y(pe,{cmd:$e.target.value})}),P&&h.jsx(Ot,{icon:"close",label:"Remove",onClick:()=>f(c.filter(($e,le)=>le!==pe))}),P&&pe>0&&h.jsx(vN,{className:"setup-shared",checked:J.shared,onChange:$e=>Y(pe,{shared:$e.target.checked}),tip:"Main runs it once for every worktree; a worktree whose changes touch it runs its own",children:"shared from main"})]},J.id);return h.jsxs(Ns,{children:[h.jsxs("p",{className:"form-title",children:["how does ",e.name," start?"]}),B&&!xe&&h.jsxs("p",{className:"hint setup-shared-note",children:["Worktrees will share ",de,", migrations included."," ",h.jsx(Le,{tone:"quiet",disabled:!i,onClick:we,children:"ask the agent to keep them apart"})]}),h.jsx(Ca,{label:"install",hint:"once per new worktree; one command per line",children:h.jsx(kc,{size:"md",rule:!0,rows:Math.max(1,p.split(`
|
|
265
|
+
`).length),value:p,placeholder:"bun install",onChange:J=>m(J.target.value)})}),h.jsx(Ca,{label:"remove",hint:"once when a worktree goes, before its directory does; one command per line",children:h.jsx(kc,{size:"md",rule:!0,rows:Math.max(1,g.split(`
|
|
266
|
+
`).length),value:g,placeholder:'dropdb --if-exists "app_$TOYON_WORKTREE"',onChange:J=>w(J.target.value)})}),h.jsx(Ca,{label:"check",hint:"runs after each of the agent's turns; the work lands only when it passes",children:h.jsx(Eo,{size:"md",rule:!0,value:y,placeholder:"bun run check",onChange:J=>x(J.target.value)})}),e.remote&&h.jsx(Ca,{label:"land",hint:"where a worktree's finished work goes; one way per repo",children:h.jsxs("div",{className:"setup-land",children:[h.jsx(ei,{value:b,options:sC.map(J=>({id:J.id,label:J.name,description:J.description})),onChange:j,hint:"where the work goes",placeholder:"where work lands"}),_&&h.jsx(ei,{value:N?"github":"you",options:aC.map(J=>({id:J.id,label:J.name,description:J.description})),onChange:J=>T(J==="github"),hint:"who merges the pull request",placeholder:"who merges it"})]})}),h.jsx(Ca,{label:"merge",hint:_?"how GitHub merges the pull request; only what the repo allows":"how the commits arrive on main",children:h.jsx(ei,{value:R==="default"&&!_?sm:R,options:[..._?[{id:"default",label:"what the repo allows",description:"the repo's allowed methods on GitHub: squash, else a merge commit, else rebase"}]:[],...iC.map(J=>({id:J.id,label:J.name,description:J.description}))],onChange:$,hint:"how the commits arrive on main",placeholder:"how the commits arrive"})}),h.jsx(Ca,{label:"start",hint:h.jsxs(h.Fragment,{children:["must listen on ",h.jsx("code",{...Dt("Toyon sets a different port for each worktree"),children:"$PORT"}),e.guess&&l&&h.jsxs(h.Fragment,{children:[" · from ",h.jsx(Le,{mono:!0,tone:"quiet",...Dt(`open ${e.guess} in the editor pane`),onClick:()=>tl(r,n,l,e.guess??"",1),children:e.guess})]})]}),children:c[0]&&ee(c[0],0)}),c.slice(1).map((J,pe)=>h.jsxs("div",{className:"form-row",children:[h.jsx("span",{className:"form-label"}),h.jsx("div",{className:"form-control",children:ee(J,pe+1)})]},J.id)),h.jsxs("div",{className:"form-row",children:[h.jsx("span",{className:"form-label"}),h.jsxs(Le,{tone:"quiet",onClick:()=>f([...c,Qp("","")]),children:[h.jsx(jt,{name:"plus",className:"icon-inline"})," another process"]})]}),h.jsxs("div",{className:"form-knobs",children:[h.jsx(ei,{value:W,options:FU,onChange:A,hint:"whether the settings file is committed with the repo or kept out of git",placeholder:"committed or kept local"}),h.jsx("span",{className:"form-sign",children:I}),t&&h.jsx(Le,{onClick:t,children:"cancel"}),(!u||t)&&h.jsx(Le,{...Dt("This project has no dev server: chat, changes and the terminal work, the preview stays empty"),onClick:te,children:"no dev server"}),se&&i?h.jsx(Le,{variant:"outline",size:"lg",disabled:i.agent!=="idle",...Dt("The agent reads the repo and writes the settings file; the daemon picks it up as soon as it lands"),onClick:K,children:"let the agent work it out"}):h.jsxs(Le,{variant:"outline",size:"lg",disabled:!z,...t?Dt("Restarts every worktree of this repo. Profiles and other keys in the file are kept."):{},onClick:re,children:[t?"save + restart":"start"," ",h.jsx(jt,{name:"forward",className:"icon-inline"})]})]})]})}const UU=900;function HU(e){return`${Math.round(e.w)} × ${Math.round(e.h)}`}function KU(e,t){return!e||t.w<=0||t.h<=0?!1:Math.round(e.w)!==Math.round(t.w)||Math.round(e.h)!==Math.round(t.h)}function WU(e,t){const[n,r]=S.useState(null);return S.useEffect(()=>{if(!e||!t){r(null);return}let o=null,i=null;const l=new ResizeObserver(u=>{var p;const c=(p=u[u.length-1])==null?void 0:p.contentRect;if(!c)return;const f={w:c.width,h:c.height};KU(o,f)&&(r(HU(f)),i&&clearTimeout(i),i=setTimeout(()=>r(null),UU)),f.w>0&&f.h>0&&(o=f)});return l.observe(e),()=>{l.disconnect(),i&&clearTimeout(i),r(null)}},[e,t]),n}const ZU=1500,qU={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};class GU{constructor(t,n,r=qU){Rt(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=Xv(r));const i=df(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)},ZU)}title(t,n){const r=this.frame(t);r.title=Xv(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 VU=Eg(),YU=2*6e4;function wx(e){e==null||e.setAttribute("src",e.src)}const XU=8e3,ud="render:",QU=6e3,JU=1500;function yx(e,t){try{const n=new URL(e,t);return n.origin===new URL(t).origin?n.href:null}catch{return null}}function e7({onRoot:e}){const t=S.useRef(null),n=S.useCallback(G=>{t.current=G,e(G)},[e]),r=at(),o=Zn(),i=lt(),l=S.useRef(i);l.current=i;const[u]=S.useState(()=>new GU((G,be,Ze)=>{var pt,Jt;(pt=l.current)==null||pt.send({t:"visit",worktreeId:G,path:be,title:Ze}),q1((Jt=o.getState().local[G])==null?void 0:Jt.pages)&&en.post(G,{type:"links"})},(G,be,Ze)=>{var pt;return(pt=l.current)==null?void 0:pt.send({t:"page-title",worktreeId:G,path:be,title:Ze})}));S.useEffect(()=>()=>u.dispose(),[u]);const c=bE(),f=sl(),p=_s(),m=M(G=>G.connected),g=M(G=>G.heard),w=M(G=>G.connectFailure),y=M(G=>G.remote),{host:x}=$r(),b=oo(),j=To(),N=M(G=>G.editor),T=EE(),R=$L(),$=Ac(),W=M(G=>G.layout.term)&&!$,A=M(G=>G.focusTerm),I=S.useRef(!1),_=S.useRef(A),P=!I.current||A!==_.current;S.useEffect(()=>{I.current=W&&!!f,_.current=A});const z=Ic(),q=M(G=>G.layout.design)&&!$&&!z,se=M(G=>G.reloadReq),Y=yf(),ge=S.useRef(Y);ge.current=Y;const ke=M(G=>G.zen),oe=M(G=>{var be;return((be=G.dragFiles)==null?void 0:be.at)==="centre"}),L=S.useRef(ke);L.current=ke;const re=Tt(f,"log"),te=M(G=>G.incompatible),K=ML(),B=M(G=>{var be;return((be=G.overlay)==null?void 0:be.kind)==="setup"?G.repos.find(Ze=>Ze.id===G.overlay.repoId)??null:null}),xe=(p==null?void 0:p.worktree.empty)===!0,de=!!p&&jc(p),we=K&&!xe&&!de?K:null,ee=we??B,J=M(G=>G.pending.find(be=>be.id===G.activeImportId)??null),[pe,$e]=S.useState([]),le=M(G=>G.renders),ae=S.useRef(new Map),Fe=S.useCallback((G,be,Ze)=>{var pt;clearTimeout(be.timer),ae.current.delete(G),(pt=l.current)==null||pt.send({t:"rendered",worktreeId:be.worktreeId,id:G,errors:be.errors.slice(0,RO),...be.url?{url:be.url.slice(0,$O)}:{},...be.title?{title:be.title.slice(0,IO)}:{},...Ze}),r({a:"render-done",id:G})},[r]),Qe=S.useRef((G,be)=>{});Qe.current=(G,be)=>{const Ze=ae.current.get(G);if(Ze)switch(be.type){case"frame-load":clearTimeout(Ze.timer),Ze.timer=setTimeout(()=>Fe(G,Ze,{ok:!0}),JU);break;case"loaded":Ze.url=be.url,Ze.title=be.title;break;case"navigated":Ze.url=be.url,be.title!==void 0&&(Ze.title=be.title);break;case"title":Ze.title=be.title;break;case"page-error":{const pt=be.source?` (${Sp(be.source)}:${be.line??"?"})`:"";Ze.errors.push(`${be.message}${pt}`.slice(0,Gv));break}}},S.useEffect(()=>{for(const G of le){if(ae.current.has(G.id))continue;const be={worktreeId:G.worktreeId,errors:[]};ae.current.set(G.id,be);const Ze=c.find(pt=>pt.id===G.worktreeId);if(!Ze||!An(Ze)){Fe(G.id,be,{ok:!1,reason:"this tab has no preview for that worktree"});continue}if(!yx(G.path,kd(Ze.worktree.id,Ze.worktree.proxyPort,y,x))){Fe(G.id,be,{ok:!1,reason:"not a route of the preview"});continue}be.timer=setTimeout(()=>Fe(G.id,be,{ok:!1,reason:"the page did not load"}),QU)}},[le,c,y,x,Fe]),S.useEffect(()=>()=>{for(const G of ae.current.values())clearTimeout(G.timer)},[]);const ze=S.useRef(new Map),Re=S.useRef(new Map),[ct,_n]=S.useState([]),ht=S.useRef(new Set),tn=S.useRef(new Set),Vt=S.useRef(G=>wx(ze.current.get(G)));S.useEffect(()=>{en.post=(G,be)=>{var Ze,pt;if(be.type==="reload"&&ht.current.has(G))return Vt.current(G);(pt=(Ze=ze.current.get(G))==null?void 0:Ze.contentWindow)==null||pt.postMessage({__toyon:!0,...be},Re.current.get(G)??"*")},en.broadcast=G=>{var be;for(const[Ze,pt]of ze.current)(be=pt.contentWindow)==null||be.postMessage({__toyon:!0,...G},Re.current.get(Ze)??"*")}},[]),S.useEffect(()=>{let G=null;const be=Jt=>{Jt.target instanceof HTMLElement&&Jt.target.tagName!=="IFRAME"&&(G=Jt.target)},Ze=Jt=>{Jt.relatedTarget===null&&setTimeout(()=>{document.activeElement===document.body&&(G=null)},0)},pt=Jt=>{var rn,Ut,ur,Or,On;if((rn=Jt.data)!=null&&rn.__toyon)for(const[St,je]of ze.current){if(je.contentWindow!==Jt.source)continue;if(Jt.origin!==Re.current.get(St))return;const Se=t2(Jt.data);if(!Se)return;if(St.startsWith(ud)){Qe.current(St.slice(ud.length),Se);return}switch(Se.type){case"key":window.dispatchEvent(new KeyboardEvent(Se.up?"keyup":"keydown",{key:Se.key,code:Se.code,metaKey:Se.meta,ctrlKey:!!Se.ctrl,shiftKey:!!Se.shift,altKey:!!Se.alt}));break;case"hmr":r({a:"hmr",id:St}),(Ut=l.current)==null||Ut.send({t:"page-loaded",worktreeId:St});break;case"loaded":ht.current.delete(St),tn.current.add(St),_n(kt=>kt.includes(St)?kt:[...kt,St]),en.post(St,FN(ge.current)),en.post(St,{type:"zen",on:L.current}),r({a:"hmr",id:St}),r({a:"page",id:St,url:Se.url,title:Se.title}),(ur=l.current)==null||ur.send({t:"page-loaded",worktreeId:St}),u.note(St,Se.url,Se.title);break;case"navigated":r({a:"page",id:St,url:Se.url,...Se.title!==void 0?{title:Se.title}:{}}),u.note(St,Se.url,Se.title);break;case"title":r({a:"page",id:St,title:Se.title}),u.title(St,Se.title);break;case"links":r({a:"links",id:St,links:Se.links});break;case"page-error":{const kt=Se.source?` (${Sp(Se.source)}:${Se.line??"?"})`:"",st=`${Se.message}${kt}`.slice(0,Gv);st&&((Or=l.current)==null||Or.send({t:"page-error",worktreeId:St,message:st}));break}case"picked":{const{type:kt,verb:st,site:Ft,...Gt}=Se,U=Ft==="call"?{file:Gt.callFile,line:Gt.callLine}:{file:Gt.file,line:Gt.line};if(st==="code"){r({a:"set-picking",v:!1});const he=(On=dn(o.getState(),St))==null?void 0:On.worktree;U.file?tl(o,i,St,Sp(U.file,he==null?void 0:he.path),U.line??1):i==null||i.send({t:"find-element",worktreeId:St,seq:Ko(),element:Gt.element})}else gP(o,St,Gt);break}case"pick-cancel":r({a:"set-picking",v:!1});break;case"drag-files":nk(o,o.getState().activeId?{at:"centre"}:null);break;case"drop-files":ZE(o,i,o.getState().activeId?{at:"centre"}:null,KP(Se.files));break;case"focus":Se.gesture?G=null:document.activeElement===je&&(G!=null&&G.isConnected)&&G!==document.body&&G.focus();break;case"highlight-miss":console.warn(`[toyon] highlight miss on ${Se.path}: ${Se.fileMatched} elements from this file, ${Se.withSource} elements with source info on page, ranges=${JSON.stringify(Se.ranges)}`);break}return}};return window.addEventListener("message",pt),document.addEventListener("focusin",be),document.addEventListener("focusout",Ze),()=>{window.removeEventListener("message",pt),document.removeEventListener("focusin",be),document.removeEventListener("focusout",Ze)}},[r,o,i,u]),S.useEffect(()=>{en.broadcast({type:"zen",on:ke})},[ke]);const He=S.useRef(new Map);vt([se==null?void 0:se.id,se==null?void 0:se.n],()=>{if(!se)return;const{id:G}=se;clearTimeout(He.current.get(G)),He.current.set(G,setTimeout(()=>{He.current.delete(G),en.post(G,{type:"reload"})},1200))});const nt=Wg(),an=nt&&!An(nt)?nt:null,It=Hi(),X=!!p&&p.procs.some(G=>G.status==="running"),fe=Gg(),dt=fe!==null&&fe===f&&X;S.useEffect(()=>{fe&&dt&&!pe.includes(fe)&&$e(G=>[...G,fe])},[fe,dt,pe]);const Ke=c.filter(G=>An(G)&&G.procs.some(be=>be.status==="asleep")).map(G=>G.id).join(" ");S.useEffect(()=>{const G=new Set(Ke.split(" ").filter(Boolean));pe.some(be=>G.has(be))&&$e(be=>be.filter(Ze=>!G.has(Ze)))},[Ke,pe]),S.useEffect(()=>{const G=pe.filter(be=>be!==fe).map(be=>setTimeout(()=>$e(Ze=>Ze.filter(pt=>pt!==be)),YU));return()=>{for(const be of G)clearTimeout(be)}},[pe,fe]),S.useEffect(()=>{_n(G=>G.every(be=>pe.includes(be))?G:G.filter(be=>pe.includes(be)))},[pe]);const pn=S.useMemo(()=>c.filter(An).filter(G=>pe.includes(G.id)).map(G=>({id:G.worktree.id,port:G.worktree.proxyPort,title:G.worktree.title,url:kd(G.worktree.id,G.worktree.proxyPort,y,x)})),[c,pe,y,x]),mn=S.useMemo(()=>le.flatMap(G=>{const be=c.find(pt=>pt.id===G.worktreeId);if(!be||!An(be))return[];const Ze=yx(G.path,kd(be.worktree.id,be.worktree.proxyPort,y,x));return Ze?[{id:`${ud}${G.id}`,path:G.path,url:Ze}]:[]}),[le,c,y,x]),Sn=Sm(b,y),Ct=S.useMemo(()=>[...pn,...mn],[pn,mn]),Nn=VE(b,Ct,Sn);Vt.current=G=>Sn?Nn.renew(G):wx(ze.current.get(G));const ut=pn.filter(G=>{var be;return(be=c.find(Ze=>Ze.id===G.id))==null?void 0:be.procs.some(Ze=>Ze.status==="running")}).map(G=>G.id).join(" ");vt([ut],()=>{for(const G of ut.split(" "))ht.current.has(G)&&Vt.current(G)});const Ee=M(G=>G.carryTo),[De,gn]=S.useState(null),[bn,wn]=S.useState(fe),qn=S.useRef(null);bn!==fe&&(wn(fe),gn(CU({leaving:qn.current,arriving:fe,carryTo:Ee,repoOf:G=>{var be;return((be=c.find(Ze=>Ze.id===G))==null?void 0:be.repoId)??null}}))),S.useEffect(()=>{if(!De)return;const G=setTimeout(()=>gn(null),XU);return()=>clearTimeout(G)},[De]);const ft=fe!==null&&ct.includes(fe),Mt=AU({previewId:fe,painted:ft,ready:dt,carry:De,mounted:pe}),nn=Mt!==null&&Mt!==fe;S.useEffect(()=>{qn.current=Mt});const H=Mt!==null&&!ee&&!J&&!$&&!z,[me,_e]=S.useState(null),Ge=WU(me,H),[Lt,Pt]=bo(Ye.editorHeight,0,G=>{const be=Number(G);return Number.isFinite(be)&&be>=120?be:0}),[Pe,Oe]=bo(Ye.designHeight,0,G=>{const be=Number(G);return Number.isFinite(be)&&be>0?be:0}),[Ve,Zt]=bo(Ye.designFull,!1,G=>G===null?void 0:G==="1"),[$t,Tn]=bo(Ye.editorFull,!1,G=>G===null?void 0:G==="1"),[In,kn]=bo(Ye.termHeight,240,G=>{const be=Number(G);return Number.isFinite(be)&&be>=140?be:void 0}),kr=M(G=>G.termTall);vt([kr],()=>{const G=t.current;kr&&G&&kn(Math.max(In,Math.round(G.clientHeight/2)))});const hn=G=>(be,Ze)=>{const pt=Ze.parentElement,Jt=t.current;if(!pt||!Jt)return null;let rn=0;for(const ur of Array.from(Jt.querySelectorAll(":scope > .pane")))ur!==pt&&!ur.classList.contains("full")&&(rn+=ur.offsetHeight);const Ut=Math.max(Jt.clientHeight-rn-80,G);return Math.min(Math.max(pt.getBoundingClientRect().bottom-be.clientY,G),Ut)},En=Ha(hn(120),G=>Pt(Math.round(G))),cr=Ha(hn(160),G=>Oe(Math.round(G))),Yt=Ha(hn(140),G=>kn(Math.round(G))),qt=M(G=>{var be,Ze;return p&&Ir(p.worktree)?((Ze=(be=G.rows.find(pt=>{var Jt;return pt.repoId===p.worktree.repoId&&((Jt=pt.worktree)==null?void 0:Jt.kind)==="worktree"}))==null?void 0:be.worktree)==null?void 0:Ze.title)??null:null}),zt=C4({connected:m,heard:g,connectFailure:w,hasToken:b.serving?VU:!0,projectChord:At("project"),title:(p==null?void 0:p.worktree.title)??null,machine:b.serving?null:j.displayName(b.origin),needsSetup:!!K,busy:de,treeEmpty:xe,landsFrom:qt});return h.jsxs("div",{className:"center-root",ref:n,children:[h.jsx("div",{className:Ue("center-area",oe&&"drop-over"),style:{display:!(ke&&!z)&&(N&&$t||q&&Ve)?"none":void 0},children:h.jsxs("div",{className:"frames-wrap",ref:_e,children:[pn.map(G=>h.jsx("iframe",{ref:be=>{be?(ze.current.set(G.id,be),Re.current.set(G.id,new URL(G.url).origin)):(ze.current.delete(G.id),Re.current.delete(G.id),ht.current.delete(G.id),tn.current.delete(G.id))},onLoad:()=>{tn.current.delete(G.id)?ht.current.delete(G.id):ht.current.add(G.id)},src:Nn.urlOf(G.id)??void 0,title:G.title,style:{display:H&&G.id===Mt?"block":"none"}},G.id)),mn.map(G=>h.jsx("iframe",{ref:be=>{be?(ze.current.set(G.id,be),Re.current.set(G.id,new URL(G.url).origin)):(ze.current.delete(G.id),Re.current.delete(G.id))},onLoad:()=>Qe.current(G.id.slice(ud.length),{type:"frame-load"}),src:Nn.urlOf(G.id)??void 0,title:`checking ${G.path}`,style:{display:"none"}},G.id)),Ge&&h.jsx("span",{className:"center-size",children:Ge}),R?h.jsx(LU,{project:R}):h.jsxs(h.Fragment,{children:[J&&h.jsx(RU,{pending:J},J.id),T&&p&&!J&&h.jsx(IU,{active:p},p.worktree.id),ee&&!J&&!T&&h.jsx(BU,{repo:ee,onClose:we?void 0:()=>r({a:"close"})},`${ee.id}:${JSON.stringify(ee.config)}`),an&&!ee&&!J&&!It&&h.jsx(ic,{placement:"centre",found:an},an.id),It&&!ee&&!J&&h.jsx(ic,{placement:"centre",archived:It},It.id),!X&&!an&&!It&&!ee&&!J&&!T&&te&&h.jsx(n_,{foreign:b.serving?void 0:j.displayName(b.origin)}),!X&&!an&&!It&&!ee&&!J&&!T&&!te&&(zt!==null?h.jsx(Ns,{wide:!0,children:h.jsx("p",{className:"status-line",children:zt})}):z?h.jsx(ic,{placement:"centre"}):nn?null:p&&h.jsx(TU,{worktree:p,log:re}))]})]})}),N&&h.jsx(xN,{editor:N,height:$t?"100%":Lt>0?Lt:"45%",full:$t,onToggleFull:()=>Tn(!$t),onDragStart:En}),q&&f&&!It&&h.jsx(JB,{worktreeId:f,height:Ve?"100%":Pe>0?Pe:"55%",full:Ve,onToggleFull:()=>Zt(!Ve),onDragStart:cr},`design:${f}`),W&&f&&!It&&h.jsx(_U,{worktreeId:f,opened:P,height:In,onDragStart:Yt},`term:${f}`),h.jsx($N,{})]})}function t7({width:e}){const t=M(r=>r.layout.chat),n=Ac();return h.jsx(ic,{placement:"dock",className:!t||n?"collapsed":void 0,width:e})}function n7(e,t){const n=[];return e&&(n.push(CE(e)),n.push({id:"copy-url",label:"copy URL",onClick:()=>Qt(e)})),Dn([n,[{id:"reload",label:"reload preview",key:At("reload"),onClick:t.reload}]])}const r7=520,Jp=8;function o7({winW:e,centre:t,leadRight:n,toolsLeft:r}){const o=t.right-t.left,i=Math.max(0,Math.min(r7,Math.floor(e*.4),o-2*Jp)),l=t.left+(o-i)/2,u=n+Jp,c=r-Jp-i,f=Math.max(Math.min(l,c),u);return{left:Math.round(f),width:i}}function s7({center:e}){const t=wL(),n=wE(e),r=S.useRef(null);_L(r);const[o,i]=_0(),[l,u]=_0(),c=o7({winW:t,centre:n,leadRight:i.right,toolsLeft:u.left}),f=at(),p=lt(),m=Zn(),g=fn("bar"),w=_s(),y=Ic(),x=M(q=>q.zen)&&!y,b=M(q=>q.layout.changes),j=M(q=>q.layout.chat),N=Ac(),T=M(q=>q.layout.design),R=M(q=>{var se;return((se=q.overlay)==null?void 0:se.kind)==="keys"}),$=d7(),W=(w==null?void 0:w.worktree.id)??null,A=M(q=>q.archivedPage!==null),I=!!w&&Dg(w)&&!A,_=M(q=>q.chatSide)==="left",P=!N&&h.jsx(Ot,{icon:"branch",label:"Changes panel",hint:At("changes"),tone:"chrome",on:b,onClick:()=>f({a:"toggle-changes"})}),z=!N&&!y&&h.jsx(Ot,{icon:"chat",label:"Chat panel",hint:At("composer"),tone:"chrome",on:j,onClick:()=>f({a:"toggle-chat"})});return h.jsxs("div",{className:"top-bar",ref:r,children:[x&&h.jsx("span",{className:"bar-zen-title",children:(w==null?void 0:w.worktree.title)??"Toyon"}),h.jsxs("span",{className:"bar-lead",ref:o,children:[_?z:P,h.jsx(i7,{}),$&&h.jsx(Pf,{icon:"download","data-tip":"Install Toyon as an app (own window, dock icon)",onClick:()=>void $.prompt(),children:"install app"}),h.jsx(l7,{}),h.jsx(c7,{})]}),!y&&h.jsx(a7,{worktreeId:W,repoId:(w==null?void 0:w.repoId)??null,ready:I,left:c.left,width:c.width}),h.jsx("span",{className:"bar-grow"}),h.jsxs("span",{className:"bar-tools",ref:l,children:[h.jsx(u7,{}),h.jsx(Ot,{icon:"settings",label:"Settings & shortcuts",hint:At("keys"),tone:"chrome",on:R,"aria-controls":"keys-help","aria-expanded":R,onClick:()=>f({a:"toggle",overlay:{kind:"keys"}}),...g.contextMenu(()=>PS(m.getState(),{sock:p,dispatch:f}))}),!N&&!y&&h.jsx(Ot,{icon:"palette",label:"Design system",hint:At("design"),tone:"chrome",on:T,onClick:()=>f({a:"toggle-design"})}),_?P:z,!y&&h.jsx(Ot,{icon:"zen",className:"bar-zen",label:"Full-bleed preview",hint:At("zen"),tone:"chrome",on:x,onClick:()=>f({a:"toggle-zen"})})]})]})}function i7(){const e=at(),t=lt(),n=il(),r=M(p=>p.activeRepoId),o=M(p=>p.repos),i=fn("bar"),l=()=>Dn([[{id:"project",label:o.length>1?"switch project…":"open project…",key:At("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?$f(n,r,{sock:t,dispatch:e}):[]]),u=M(p=>{var m;return((m=p.overlay)==null?void 0:m.kind)==="projects"&&p.overlay.form==="pill"}),c=M(p=>p.heard),f=M(p=>p.newProject!==null);return h.jsxs("span",{className:"bar-project",children:[h.jsx(Le,{tone:"chrome",className:"bar-pill",on:u,...Dt(o.length>1?"Switch project":"Open a project",At("project")),onClick:()=>e({a:"toggle",overlay:{kind:"projects",form:"pill"}}),...i.contextMenu(l),children:h.jsx("span",{className:"bar-project-name",children:f?"new project":(n==null?void 0:n.name)??(c?"open project":"")})}),u&&h.jsx(Gk,{form:"pill"})]})}function a7({worktreeId:e,repoId:t,ready:n,left:r,width:o}){const i=Tt(e,"page").url,l=eN(i),u=at(),c=M(y=>{var x;return((x=y.overlay)==null?void 0:x.kind)==="routes"}),f=()=>{n&&e&&t&&!c&&u({a:"open",overlay:{kind:"routes"}})};vt([e,n],()=>{c&&u({a:"close"})});const m=fn("bar").contextMenu(()=>n?n7(i,{reload:()=>e&&en.post(e,{type:"reload"})}):[]),g=M(y=>y.picking),w=Gg();return h.jsxs("div",{className:"bar-center",style:{left:r,width:o},children:[h.jsx(Ot,{icon:"back",label:"Back",hint:At("back"),disabled:!n,onClick:()=>e&&en.post(e,{type:"back"}),...m}),h.jsx(Ot,{icon:"forward",label:"Forward",hint:At("forward"),disabled:!n,onClick:()=>e&&en.post(e,{type:"forward"}),...m}),h.jsx(Ot,{icon:"reload",label:"Reload preview",hint:At("reload"),disabled:!n,onClick:()=>e&&en.post(e,{type:"reload"}),...m}),h.jsxs("span",{className:"bar-route",children:[h.jsx(Eo,{className:"bar-path",value:n?l:"",readOnly:!0,disabled:!n,placeholder:n?"/":"",onMouseDown:y=>{y.button===0&&y.preventDefault()},onClick:f,onFocus:f,spellCheck:!1,...Dt("Go to a page",At("routes"))}),c&&n&&e&&t&&h.jsx(l8,{worktreeId:e,repoId:t,url:i},e)]}),h.jsx(Ot,{icon:"inspect",label:"Pick an element to open its code",hint:At("inspect"),also:{text:"Add an element to chat",key:At("pick")},on:g==="code",disabled:!n||!w,onClick:()=>w&&gc(w,g,u,"code")})]})}function Pf({icon:e,busy:t,children:n,...r}){return h.jsxs(Le,{disabled:t,...r,children:[!t&&h.jsx(jt,{name:e,className:"icon-inline"}),h.jsx("span",{className:Ue(t&&"live-text"),children:n})]})}function l7(){const e=M(c=>c.self),t=M(c=>c.rebuilt),n=M(c=>c.repos),r=lt(),o=M(c=>{var f;return((f=c.update)==null?void 0:f.restarting)!=null}),i=_N(e,n,t);if(!i||o)return null;const l=i.busy?"rebuilding":i.reload?"reload Toyon":i.build==="rebuild"?"rebuild Toyon":i.build??"restart Toyon",u=()=>{i.reload?window.location.reload():e&&(r==null||r.send(i.build?{t:"run-after-land",repoId:e.repoId}:{t:"restart-daemon"}))};return h.jsx(Pf,{icon:"reload",busy:i.busy,onClick:u,...Dt(i.text,void 0,{detail:i.detail}),children:l})}function c7(){const e=M(o=>o.update),t=M(o=>o.managed.updates),n=lt(),r=x4(e);return!r||!t?null:h.jsx(Pf,{icon:"reload",busy:r.busy,onClick:()=>{r.retry&&(n==null||n.send({t:"update-now"}))},...Dt(r.text),children:r.word})}function u7(){const e=at(),t=M(sE),n=M(i=>i.letIn),r=M(i=>{var l;return((l=i.overlay)==null?void 0:l.kind)==="pair"});if(!t)return null;const o=()=>e({a:"toggle",overlay:{kind:"pair"}});return n?h.jsx(Ot,{icon:"phone",label:"Open on your phone",tone:"chrome",on:r,"aria-expanded":r,onClick:o}):h.jsx(Pf,{icon:"phone","aria-expanded":r,onClick:o,...Dt("Open this machine on your phone, and let it in"),children:"open on phone"})}function d7(){const[e,t]=S.useState(null);return S.useEffect(()=>{if(gf())return;const n=o=>{o.preventDefault(),t(o)},r=()=>t(null);return window.addEventListener("beforeinstallprompt",n),window.addEventListener("appinstalled",r),()=>{window.removeEventListener("beforeinstallprompt",n),window.removeEventListener("appinstalled",r)}},[]),e}function f7(e,t,n){return t==="left"?n-e.left:e.right-n}const h7="input, textarea, [contenteditable], .monaco-editor, .xterm, iframe";function p7(){const e=Zn(),t=at(),n=lt(),r=Ac(),o=Ki(),i=Ic(),l=M(L=>L.zen)&&!i,u=Hi(),c=!!qg()||!!u,f=M(L=>L.layout.changes)&&!r,p=M(L=>L.layout.chat)&&!r&&!i&&!c,m=M(L=>L.chatSide),g=M(L=>L.railOpen),[w,y]=bo(Ye.changesWidth,220,L=>L?Ju(Number(L),220):void 0),[x,b]=bo(Ye.chatWidth,380,L=>L?Ju(Number(L),380):void 0),[j,N]=bo(Ye.railWidth,280,L=>L?Ju(Number(L),280):void 0),T=(L,re,te)=>{const K=re.classList.contains("left")?"left":"right",B=K==="left"?re.previousElementSibling:re.nextElementSibling;return B?Ju(f7(B.getBoundingClientRect(),K,L.clientX),te):null},R=Ha((L,re)=>T(L,re,220),y),$=Ha((L,re)=>T(L,re,380),b),W=Ha((L,re)=>T(L,re,280),N),[A,I]=S.useState(null),P=fn("app").contextMenu(()=>MS(e.getState(),{sock:n,dispatch:t})),z=h.jsx(x_,{width:w}),q=!i&&!c&&h.jsx(t7,{width:x}),se=!r&&h.jsx(MN,{width:j}),Y=L=>!r&&g&&h.jsx("div",{className:`dock-resize ${L}`,onPointerDown:W}),ge=m==="left",ke=ge?{dock:q,open:p,drag:$}:{dock:z,open:f,drag:R},oe=ge?{dock:z,open:f,drag:R}:{dock:q,open:p,drag:$};return h.jsxs("div",{className:Ue("app",l&&"zen"),"data-chat-side":m,"data-touch":o||void 0,"data-hover":!o||void 0,onContextMenu:L=>{L.defaultPrevented||L.target instanceof Element&&L.target.closest(h7)||P.onContextMenu(L)},children:[h.jsx(YE,{}),h.jsx(e_,{}),h.jsx(s7,{center:A}),h.jsxs("div",{className:"docks",children:[ge&&se,ge&&Y("left"),ke.dock,ke.open&&h.jsx("div",{className:"dock-resize left",onPointerDown:ke.drag}),h.jsx(e7,{onRoot:I}),oe.open&&h.jsx("div",{className:"dock-resize right",onPointerDown:oe.drag}),oe.dock,!ge&&Y("right"),!ge&&se]})]})}function m7(e){return e.altKey?"Alt":e.ctrlKey?"Control":e.metaKey?"Meta":null}function g7(e,t){return t==="Alt"?e.altKey:t==="Control"?e.ctrlKey:e.metaKey}const k7=200,w7={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};function y7(e,t=w7){let n=null,r=!1,o=null;const i=()=>{r||(r=!0,e(!0))},l=()=>{o!==null&&(t.clear(o),o=null)},u=()=>{l(),n=null,r&&(r=!1,e(!1))};return{press(c){const f=n!==null;n=m7(c),l(),n&&(f?i():o=t.set(()=>{o=null,i()},k7))},keyup(c){n&&c===n&&u()},mods(c){n&&!g7(c,n)&&u()},end:u}}function v7(e,t,n,r){if(!n)return null;const o=e.findIndex(c=>c.id===n);if(o>=0){const c=e[(o+r+e.length)%e.length];return c&&c.id!==n?{activate:c.id}:null}const i=t.findIndex(c=>c.id===n);if(i<0)return null;const l=t[i+r];if(l)return{activate:l.id};const u=e[e.length-1];return r<0&&u?{activate:u.id}:null}const b7=new Set(["design","chats"]),x7=new Set(["reload","back","forward"]),E7=new Set(["project","commands","keys","zen"]);function _7(){const e=Zn(),t=lt();S.useEffect(()=>{const n=y7(p=>e.dispatch({a:"rail-peek",on:p})),r=n.end,o=p=>{e.getState().railOpen||n.press(p)},i=p=>n.keyup(p.key),l=p=>n.mods(p),u=()=>{var w,y;const p=e.getState(),g=((y=(w=document.activeElement)==null?void 0:w.closest("[data-pane]"))==null?void 0:y.dataset.pane)??(p.layout.term?"terminal":p.editor?"editor":p.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"})},c=p=>{p.key!=="Escape"||!e.getState().choosingFolder||(p.stopImmediatePropagation(),t==null||t.send({t:"cancel-folder"}),e.dispatch({a:"choosing-folder",v:!1}))},f=p=>{var b,j,N,T;l(p),jj(p)&&!p.defaultPrevented&&p.preventDefault();const m=e.getState(),{dispatch:g}=e,w=R=>{const $=document.activeElement,W=!$||$===document.body||!!$.closest(".rail, .chat-input");g({a:"activate",id:R}),W&&g({a:"walked"})},y=Ix(p,{guest:!!((b=document.activeElement)!=null&&b.closest(".xterm"))});if(!(m.zen&&!xo(m)&&!m.overlay&&!m.picking&&!(y&&Tj.has(y.id))||(y==null?void 0:y.id)==="close"&&!gf()||(j=document.activeElement)!=null&&j.closest(".monaco-editor")&&y&&b7.has(y.id))&&!(y&&$j(y.id,document.activeElement))&&!(y&&x7.has(y.id)&&!(ql(m)&&Md(m)))){if(y){const R=p.defaultPrevented;if(p.preventDefault(),m.newProject&&!E7.has(y.id))return;switch(y.id){case"worktree":{const $=Aj(y.digit,m.visible.length),W=$===null?void 0:m.visible[$];W&&w(W.id);break}case"wt-prev":case"wt-next":{const $=v7(m.visible,m.visibleDiscovered,m.activeId,y.id==="wt-next"?1:-1);$&&w($.activate),o(p);break}case"wt-unseen-prev":case"wt-unseen-next":{const $=Ng(m.visible,m.activeId,y.id==="wt-unseen-next"?1:-1);$&&w($.activate),o(p);break}case"mark-unread":m.activeId&&!m.draft&&m.visible.some($=>$.id===m.activeId)&&a_(t,g,m.activeId);break;case"wt-archive":{if(p.repeat||R)break;const $=m.draft||m.archivedPage?void 0:m.visible.find(W=>W.id===m.activeId);$&&sk(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":((N=m.overlay)==null?void 0:N.kind)==="quick-open"?g({a:"close"}):m.activeId&&g({a:"open",overlay:{kind:"quick-open"}});break;case"routes":((T=m.overlay)==null?void 0:T.kind)==="routes"?g({a:"close"}):Md(m)&&g({a:"open",overlay:{kind:"routes"}});break;case"reload":case"back":case"forward":{const $=ql(m);$&&en.post($,{type:y.id});break}case"pick":case"inspect":{const $=ql(m);$&&gc($,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&&!xo(m))&&!m.overlay&&u();break;case"changes":g(m.layout.changes&&(Qa(m)==="changes"||So(m)!==null)?{a:"toggle-changes"}:{a:"focus-changes",tab:"changes"});break;case"files":g(m.layout.changes&&Qa(m)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"});break;case"panel-tab-prev":case"panel-tab-next":if(kf(m))break;g(m.layout.changes?{a:"focus-changes",tab:ZM(m,y.id==="panel-tab-next"?1:-1)}:{a:"focus-changes"});break;case"composer":g(Q1(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(_=>_.id===m.activeId);if(!$)break;const W=_o(m,m.activeId).termStream;if($.login&&W===vs)break;const A=[vo,...$.login?[vs]:[],...$.procs.map(_=>_.name)],I=A.indexOf(W);g({a:"term-stream",id:$.id,stream:A[(I+1)%A.length]??vo});break}}}else if(p.key==="Escape")if(m.newProject)m.newProject.phase==="editing"&&g({a:"close-new-project"});else if(m.picking){const R=ql(m);R&&en.post(R,{type:"pick-cancel"}),g({a:"set-picking",v:!1})}else m.archivedPage?g({a:"close-archived"}):m.activeImportId?g({a:"watch-import",id:null}):u()}};return window.addEventListener("keydown",c,!0),window.addEventListener("keydown",f),window.addEventListener("keyup",i),window.addEventListener("pointermove",l),window.addEventListener("pointerdown",l),window.addEventListener("blur",r),()=>{window.removeEventListener("keydown",c,!0),window.removeEventListener("keydown",f),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&&en.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 S7=3,N7=2e3,T7=200,j7=5e3;function C7(){const e=Zn(),t=at(),n=lt(),{storage:r}=oo(),o=sl(),i=M(B=>B.activeRepoId),l=_s(),u=Wg(),c=M(B=>B.connected),f=M(B=>B.daylight),p=M(B=>{var xe;return((xe=B.daylight)==null?void 0:xe.until)??0}),m=Hi(),g=M(B=>B.railOpen),w=M(B=>B.chatSide),y=M(B=>B.layouts),x=M(B=>B.lastActive),b=M(B=>B.discoveredOpen),j=M(B=>B.archivedOpen),N=M(B=>B.committedShut),T=M(B=>B.turnOpen),R=M(B=>B.treeOpen),$=yf(),W=M(B=>B.previewTheme!==null),A=M(B=>B.openUrl),I=bE();S.useEffect(()=>Ld.install(window),[]);const _=S.useRef([]);S.useEffect(()=>{if(!n||!c||!o)return;const B=[o,..._.current.filter(xe=>xe!==o)];for(const xe of B.splice(S7))n.send({t:"unsubscribe",worktreeId:xe});_.current.includes(o)||n.send({t:"subscribe",worktreeId:o}),_.current=B},[o,c,n]),S.useEffect(()=>{if(!(!n||!c))for(const B of _.current)n.send({t:"subscribe",worktreeId:B})},[c,n]);const P=S.useRef(void 0);S.useEffect(()=>{if(!n||!c)return;let B;const xe=()=>{const ee=document.visibilityState==="visible"?o:null;n.send({t:"view",worktreeId:ee}),P.current=ee},de=()=>{clearTimeout(B),B=setTimeout(xe,T7)};P.current===void 0||P.current===o||document.visibilityState!=="visible"?xe():de();const we=()=>document.visibilityState==="visible"?de():xe();return document.addEventListener("visibilitychange",we),()=>{clearTimeout(B),document.removeEventListener("visibilitychange",we)}},[o,c,n]);const z=(m==null?void 0:m.id)??null;S.useEffect(()=>{if(!(!n||!c||!z))return n.send({t:"subscribe",worktreeId:z}),()=>n.send({t:"unsubscribe",worktreeId:z})},[z,c,n]),S.useEffect(()=>{const B=new Set(I.map(de=>de.id)),xe=_.current.filter(de=>!B.has(de));if(xe.length!==0&&(_.current=_.current.filter(de=>B.has(de)),!(!n||!c)))for(const de of xe)n.send({t:"unsubscribe",worktreeId:de})},[I,c,n]);const q=(m==null?void 0:m.title)??(u==null?void 0:u.name)??null;S.useEffect(()=>{document.title=q?`${q} · Toyon`:"Toyon"},[q]);const se=!!(l!=null&&l.unseen),Y=M(B=>B.unreadHold!==null&&B.unreadHold===B.activeId);S.useEffect(()=>{if(!n||!o||!se||Y)return;let B;const xe=()=>document.visibilityState==="visible"&&document.hasFocus(),de=()=>{clearTimeout(B),xe()&&(B=setTimeout(()=>{xe()&&n.send({t:"seen",worktreeId:o})},N7))},we=()=>clearTimeout(B);return de(),window.addEventListener("focus",de),window.addEventListener("blur",we),()=>{we(),window.removeEventListener("focus",de),window.removeEventListener("blur",we)}},[n,o,se,Y]);const ge=S.useRef(0),ke=M(B=>Pg(B));S.useEffect(()=>{if(!n||!c||!i)return;const B=()=>{Date.now()-ge.current<j7||(ge.current=Date.now(),n.send({t:"refresh-git",repoId:i}),ke&&ke!==i&&n.send({t:"refresh-git",repoId:ke}))};return window.addEventListener("focus",B),()=>window.removeEventListener("focus",B)},[n,c,i,ke]),S.useEffect(()=>{zN($,{remember:!W}),en.broadcast(FN($))},[$,W]);const oe=S.useCallback(()=>{n==null||n.send({t:"zone",tz:Intl.DateTimeFormat().resolvedOptions().timeZone})},[n]);S.useEffect(()=>{if(!c)return;oe();const B=()=>{document.visibilityState==="visible"&&oe()};return document.addEventListener("visibilitychange",B),()=>document.removeEventListener("visibilitychange",B)},[c,oe]),S.useEffect(()=>{if(!c||p<=Date.now())return;const B=setTimeout(oe,p-Date.now()+1e3);return()=>clearTimeout(B)},[c,p,oe]),S.useEffect(()=>{f&&f.until>0&&VB(f)},[f]),S.useEffect(()=>{o&&r.set(Ye.active,o)},[o,r]);const L=M(B=>B.frame==="phone"?B.screen!=="home":null);S.useEffect(()=>{L!==null&&r.session.set(Ye.phoneRow,L?"1":"0")},[L,r]),S.useEffect(()=>{i&&r.set(Ye.repo,i)},[i,r]),S.useEffect(()=>{try{localStorage.setItem(Ye.rail,g?"1":"0")}catch{}},[g]),S.useEffect(()=>{try{localStorage.setItem(Ye.chatSide,w)}catch{}},[w]),S.useEffect(()=>{try{localStorage.setItem(Ye.layouts,JSON.stringify(y))}catch{}},[y]),S.useEffect(()=>{r.set(Ye.lastActive,JSON.stringify(x))},[x,r]),S.useEffect(()=>{r.set(Ye.discoveredOpen,JSON.stringify(b))},[b,r]),S.useEffect(()=>{r.set(Ye.archivedOpen,JSON.stringify(j))},[j,r]),S.useEffect(()=>{r.set(Ye.committedShut,JSON.stringify(N))},[N,r]),S.useEffect(()=>{r.set(Ye.turnOpen,JSON.stringify(T))},[T,r]),S.useEffect(()=>{r.set(Ye.treeOpen,JSON.stringify(R))},[R,r]),_7(),GP();const re=S.useRef(null);S.useEffect(()=>{!A||re.current===A||(re.current=A,window.open(A,"_blank"),t({a:"opened-url"}))},[A,t]);const te=S.useRef(null);return vt([o],()=>{var $e,le,ae,Fe;const B=te.current;if(te.current=o,!B||!o||B===o)return;const xe=e.getState(),de=I.find(Qe=>Qe.id===B),we=I.find(Qe=>Qe.id===o),ee=(le=($e=de==null?void 0:de.worktree)==null?void 0:$e.variant)==null?void 0:le.group;if(!ee||((Fe=(ae=we==null?void 0:we.worktree)==null?void 0:ae.variant)==null?void 0:Fe.group)!==ee)return;const J=Qe=>{var ze;try{const Re=(ze=xe.local[Qe])==null?void 0:ze.page.url;return Re?new URL(Re).pathname+new URL(Re).search:"/"}catch{return"/"}},pe=J(B);pe!==J(o)&&en.post(o,{type:"navigate",path:pe})}),M(B=>B.frame)==="phone"?h.jsx(FB,{}):h.jsx(p7,{})}function A7({origin:e,machine:t,onToken:n}){const[r,o]=S.useState({kind:"asking"}),[i,l]=S.useState(0);return vt([i],()=>{const u=new AbortController;return o({kind:"asking"}),L1(e,u.signal,c=>o({kind:"waiting",word:c})).then(c=>{if(!u.signal.aborted){if(typeof c=="string"){o({kind:"failed",failure:c});return}o({kind:"in"}),n(c.token)}}),()=>u.abort()}),h.jsxs(Ns,{children:[r.kind==="waiting"&&h.jsx("div",{className:"knock-word",children:r.word}),h.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.":EN(r.failure,e,"this device")}),r.kind==="failed"&&h.jsx("div",{className:"status-actions",children:h.jsx(Le,{variant:"outline",onClick:()=>l(u=>u+1),children:"ask again"})})]})}const tg="toyonDepth",GN="toyonOver";function vx(e){if(e.frame!=="phone"||!e.heard)return null;if(!(e.screen!=="home"&&(dn(e,e.activeId)!==null||So(e)!==null)))return 0;const n=dn(e,e.activeId)!==null&&!xo(e)&&So(e)===null;return 1+(e.screen==="changes"||e.screen==="preview"&&n?1:0)+(e.editor?1:0)}const em=e=>{const t=e&&typeof e=="object"?e[tg]:void 0;return typeof t=="number"?t:null},I7=e=>!!e&&typeof e=="object"&&e[GN]===!0;function VN(e,t=window,n=Ld){const r=t.history;let o=em(r.state)??0;em(r.state)===null&&r.replaceState({[tg]:0},"");let i=null;const l=()=>{const y=n.open();i&&!y.includes(i)&&(i=null);for(let x=y.length-1;x>=0;x--){const b=y[x];if(b!=null&&b.dismiss&&b!==i)return b}return null};let u=0;const c=()=>{const y=vx(e.getState());if(y===null)return;const x=y+(l()?1:0);if(x!==o){if(x>o)for(let b=o+1;b<=x;b++)r.pushState({[tg]:b,[GN]:b>y},"");else r.go(x-o),u++;o=x}};let f=!1;const p=()=>{f||(f=!0,queueMicrotask(()=>{f=!1,c()}))},m=y=>{const x=u>0;x&&u--,o=em(y.state)??0;const b=e.getState(),j=vx(b);if(j===null)return;const N=l(),T=j+(N?1:0);if(T!==o){if(T>o&&N){i=N,n.shut(N);return}if(T>o){const R=o===0?"home":b.editor&&o===j-1?b.screen:"chat";e.dispatch({a:"screen",to:R})}else{if(x&&u>0)return;!x&&T===0&&b.activeId&&!I7(y.state)&&e.dispatch({a:"screen",to:"chat"})}c()}};t.addEventListener("popstate",m);const g=e.subscribe(c),w=n.watch(p);return c(),()=>{t.removeEventListener("popstate",m),g(),w()}}function R7(){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(mj(t.worktreeId,t.stream))??[])n(t)}}}function $7(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 O7(e){const t={};try{const n=JSON.parse(e??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))PM(o)&&(t[r]=o)}catch{}return t}function M7(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 dd(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 L7(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 P7=400,D7=2e3;function YN(){const e=new Map;return{another(t,n=0){return(e.get(t)??0)===n?!1:(e.set(t,n),!0)}}}function z7(e,t){const n=new Map,r=new Map,o=YN(),i=c=>{var p,m;clearTimeout((p=r.get(c))==null?void 0:p.timer),r.delete(c);const f=e.getState().local[c];!f||((m=f.mark)==null?void 0:m.by)==="walk"||(n.get(c)??"")!==f.draft&&(n.set(c,f.draft),t.send({t:"set-draft",boxId:c,text:f.draft,clientId:e.getState().clientId}))},l=()=>{for(const c of[...r.keys()])i(c)},u=e.subscribe(()=>{var c,f;for(const[p,m]of Object.entries(e.getState().local)){if(o.another(p,m.sent)&&(clearTimeout((c=r.get(p))==null?void 0:c.timer),r.delete(p),n.set(p,"")),((f=m.mark)==null?void 0:f.by)==="walk"||(n.get(p)??"")===m.draft)continue;if(!m.draft){i(p);continue}const g=r.get(p);if((g==null?void 0:g.text)===m.draft)continue;clearTimeout(g==null?void 0:g.timer);const w=(g==null?void 0:g.since)??Date.now(),y=Math.max(0,Math.min(P7,w+D7-Date.now()));r.set(p,{text:m.draft,timer:setTimeout(i,y,p),since:w})}});return window.addEventListener("focusout",l),window.addEventListener("pagehide",l),{hello(c){n.clear();for(const[f,p]of Object.entries(c))n.set(f,p)},heard(c,f){return r.has(c)?!1:(n.set(c,f),!0)},dispose(){u();for(const c of r.values())clearTimeout(c.timer);r.clear(),window.removeEventListener("focusout",l),window.removeEventListener("pagehide",l)}}}function F7(e,t){const n=new Map,r=new Map,o=YN(),i=e.subscribe(()=>{for(const[l,u]of Object.entries(e.getState().local)){if(o.another(l,u.sent)&&r.set(l,"[]"),n.get(l)===u.attachments)continue;n.set(l,u.attachments);const c=$M(u.attachments),f=JSON.stringify(c);(r.get(l)??"[]")!==f&&(r.set(l,f),t.send({t:"set-attachments",boxId:l,items:c,clientId:e.getState().clientId}))}});return{hello(l){r.clear(),n.clear();for(const[u,c]of Object.entries(l))r.set(u,JSON.stringify(c))},heard(l,u){r.set(l,JSON.stringify(u))},dispose:i}}function B7(e,t){const n=(t.storage??G2)(e.origin),r=pL(zM({cached:t.cached,systemDark:t.systemDark,daylight:t.daylight,storedActive:n.get(Ye.active),storedPhoneRow:n.session.get(Ye.phoneRow)==="1",storedRepo:n.get(Ye.repo),storedRailOpen:tm(Ye.rail)==="1",storedChatSide:tm(Ye.chatSide)==="right"?"right":"left",storedLayouts:O7(tm(Ye.layouts)),storedLastActive:M7(n.get(Ye.lastActive)),storedDiscoveredOpen:dd(n.get(Ye.discoveredOpen)),storedArchivedOpen:dd(n.get(Ye.archivedOpen)),storedCommittedShut:dd(n.get(Ye.committedShut)),storedTurnOpen:dd(n.get(Ye.turnOpen)),storedTreeOpen:L7(n.get(Ye.treeOpen)),clientId:t.clientId,frame:t.frame,touch:t.touch})),o=R7(),i={version:null,protocol:null},l=M3(g=>r.dispatch({a:"server",msg:g}));let u,c,f;const p=new cM(e,g=>{if(g.t==="hello"){if(i.protocol=g.protocol,e.serving){const{rebuilt:y,update:x}=r.getState(),b=y&&(x==null?void 0:x.restarting)!=null;if(i.version!==null&&(b||g.version!==i.version||g.protocol!==Xu)){p.dispose(),t.reload();return}if(g.protocol!==Xu){r.dispatch({a:"incompatible"}),p.dispose();return}}else if(g.protocol!==Xu){r.dispatch({a:"incompatible"}),p.suspend();return}else r.getState().incompatible&&r.dispatch({a:"incompatible",v:!1});i.version=g.version;const w=new Set(p.sentWhileDown());if(w.size){const y=x=>Object.fromEntries(Object.entries(x).filter(([b])=>!w.has(b)));g.drafts=y(g.drafts),g.attachments=y(g.attachments)}u.hello(g.drafts),c.hello(g.attachments)}if(g.t==="attachments"&&g.clientId!==r.getState().clientId&&c.heard(g.boxId,g.items),!(g.t==="draft"&&g.clientId!==r.getState().clientId&&!u.heard(g.boxId,g.text))){if(zO(g)){o.deliver(g);return}if(FO(g)){if(g.t==="file-written"&&lP(g))return;f.receive(g);return}if(g.t==="loose-written"){X8(g);return}if(ZD(g)){YD(r,p,g);return}if(g.t==="open-refused"){VD(r,g);return}l(g)}},(g,w)=>r.dispatch({a:"connected",v:g,failure:w}));fP(r,p.urls),f=new V8({store:r,send:g=>p.send(g),timers:{set:(g,w)=>setTimeout(g,w),clear:g=>clearTimeout(g)},win:window});const m=f.start();return u=z7(r,p),c=F7(r,p),{origin:e.origin,serving:e.serving,token:e.token,get name(){return r.getState().machine??$7(e.origin)},store:r,sock:p,files:f,terminals:o,storage:n,heard:i,boot(g){g.t!=="hello"||g.protocol!==Xu||(i.version??(i.version=g.version),c.hello(g.attachments),r.dispatch({a:"server",msg:g}))},dispose(){p.dispose(),m(),u.dispose(),c.dispose()}}}function tm(e){try{return localStorage.getItem(e)}catch{return null}}function U7(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()},u=new Map,c=y=>{var b;if(y.serving)return;((b=y.store.getState().remote)==null?void 0:b.front)==="edge"&&y!==o?y.sock.suspend():y.sock.resume()},f=y=>{var b;let x=(b=y.store.getState().remote)==null?void 0:b.front;u.set(y.origin,y.store.subscribe(()=>{var N;const j=(N=y.store.getState().remote)==null?void 0:N.front;j!==x&&(x=j,c(y))}))},p=()=>i,m={list:p,active:()=>o,serving:()=>n,get:y=>p().find(x=>x.origin===y)??null,displayName(y){const x=p().find(j=>j.origin===y);return x?p().filter(j=>j.name===x.name).length>1?`${x.name} (${new URL(x.origin).host})`:x.name:y},activate(y){const x=p().find(j=>j.origin===y);if(!x||x===o)return;const b=o;o=x,c(b),c(x),l()},add(y){var j;const x=r.find(N=>N.origin===y.origin);if(y.origin===n.origin)return n;if(x){if(x.token===y.token)return x;(j=u.get(x.origin))==null||j(),x.dispose(),r.splice(r.indexOf(x),1),o===x&&(o=n)}const b=e.build({...y,serving:!1});return r.push(b),f(b),l(),b},remove(y){var b;const x=r.find(j=>j.origin===y);x&&((b=u.get(y))==null||b(),u.delete(y),x.dispose(),x.storage.clear(),r.splice(r.indexOf(x),1),o===x&&(o=n),l())},broadcast(y){for(const x of p())x.store.dispatch(y)},subscribe(y){return t.add(y),()=>t.delete(y)}},g=y=>{for(const x of y)m.add(x);for(const x of[...r])y.some(b=>b.origin===x.origin)||m.remove(x.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}window.__toyonShell=!0;window.top!==window&&(document.documentElement.dataset.framed="");Y2(location.origin);const XN=WB();zN(XN);function H7(e,t){try{return e.getItem(t)}catch{return null}}function K7(){const e=H7(sessionStorage,Ye.client);if(e)return e;const t=Math.random().toString(36).slice(2,10);try{sessionStorage.setItem(Ye.client,t)}catch{}return t}const W7={cached:XN,systemDark:ZB(),daylight:GB(),clientId:K7(),frame:DN(),touch:HB(),reload:()=>window.location.reload()},si=U7({serving:{origin:location.origin,token:I1()},build:e=>B7(e,W7)});KB({dispatch:e=>si.broadcast(e)});YB(e=>si.broadcast({a:"system-dark",v:e}));let bx=VN(si.active().store),xx=si.active();si.subscribe(()=>{const e=si.active();e!==xx&&(xx=e,bx(),e.store.getState().frame==="phone"&&e.store.dispatch({a:"screen",to:"home"}),bx=VN(e.store))});window.addEventListener("vite:preloadError",E4);const Z7=(window.toyonBoot??Promise.resolve(null)).then(e=>{const t=e;t&&typeof t=="object"&&t.t==="hello"&&si.active().boot(t)});function q7(e){R1(e),window.location.reload()}const G7=cj.createRoot(document.getElementById("root"));Z7.then(()=>G7.render(h.jsx(rj.StrictMode,{children:h.jsx(ok,{children:Eg()?h.jsx(gL,{machines:si,children:h.jsx(C7,{})}):h.jsx(A7,{origin:location.origin,machine:location.host,onToken:q7})})})));"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{});export{Ss as F,qm as _,eo as a,bg as b,J7 as c,X7 as d,Rx as e,mj as f,_D as g,z2 as h,hk as i,h as j,Y7 as k,Ix as m,Q7 as p,S as r,R2 as s,Tc as t,vt as u,e0 as w};
|