toyon 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge.js +1 -1
- package/dist/cli.js +19 -1
- package/dist/daemon.js +1323 -426
- package/dist/shell/assets/{Editor-CFH2QbSg.js → Editor-DAJni9OF.js} +137 -137
- package/dist/shell/assets/{XTerm-C3aMkE_w.js → XTerm-dug6M6yd.js} +16 -16
- package/dist/shell/assets/{cssMode-dc6AdHsZ.js → cssMode-B5iiwdXn.js} +1 -1
- package/dist/shell/assets/{freemarker2-CxtmNsLB.js → freemarker2-CdVcBNE9.js} +1 -1
- package/dist/shell/assets/{grammar-B-X0FPRk.js → grammar-Cfxx1yRn.js} +5 -5
- package/dist/shell/assets/{handlebars-DVzmQ0KM.js → handlebars-CW5EFZC2.js} +1 -1
- package/dist/shell/assets/{html-CqqXL9ke.js → html-B8gP1xu-.js} +1 -1
- package/dist/shell/assets/{htmlMode-Bg-Em0rL.js → htmlMode-C6I99y8u.js} +1 -1
- package/dist/shell/assets/index-BRSL9cyD.css +1 -0
- package/dist/shell/assets/index-D_PsyNmp.js +266 -0
- package/dist/shell/assets/{javascript-W-C4G7BB.js → javascript-C_3_LFln.js} +1 -1
- package/dist/shell/assets/{jsonMode-De4ajMpV.js → jsonMode-CD5xJEUk.js} +1 -1
- package/dist/shell/assets/{liquid-BSUg_7LQ.js → liquid-CJw93Zxn.js} +1 -1
- package/dist/shell/assets/{lspLanguageFeatures-BImXYajo.js → lspLanguageFeatures-wMR368iN.js} +1 -1
- package/dist/shell/assets/{mdx-B9A7RorP.js → mdx-BJ6yMgc3.js} +1 -1
- package/dist/shell/assets/{python-BD9sq3DF.js → python-BWGkxFUr.js} +1 -1
- package/dist/shell/assets/{razor-DGQVRh5-.js → razor-BV9pdU1A.js} +1 -1
- package/dist/shell/assets/{tsMode-DudQlgN_.js → tsMode-CN8OfYAX.js} +1 -1
- package/dist/shell/assets/{xml-BI6-GyBn.js → xml-DBGLqvw7.js} +1 -1
- package/dist/shell/assets/{yaml-BEUvyYtP.js → yaml-dH0C6Dth.js} +1 -1
- package/dist/shell/index.html +21 -2
- package/package.json +1 -1
- package/dist/shell/assets/index-BskWflhx.css +0 -1
- package/dist/shell/assets/index-C8QP4sgP.js +0 -255
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Editor-DAJni9OF.js","assets/grammar-Cfxx1yRn.js","assets/Editor-CB2SckMT.css","assets/XTerm-dug6M6yd.js","assets/XTerm-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
var vN=Object.defineProperty;var bN=(e,t,n)=>t in e?vN(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ct=(e,t,n)=>bN(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();function W0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var kp={exports:{}},dl={},yp={exports:{}},Pt={};/**
|
|
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 Cy;function xN(){if(Cy)return Pt;Cy=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),g=Symbol.iterator;function k($){return $===null||typeof $!="object"?null:($=g&&$[g]||$["@@iterator"],typeof $=="function"?$:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,_={};function E($,q,ke){this.props=$,this.context=q,this.refs=_,this.updater=ke||y}E.prototype.isReactComponent={},E.prototype.setState=function($,q){if(typeof $!="object"&&typeof $!="function"&&$!=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,$,q,"setState")},E.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function C(){}C.prototype=E.prototype;function x($,q,ke){this.props=$,this.context=q,this.refs=_,this.updater=ke||y}var N=x.prototype=new C;N.constructor=x,v(N,E.prototype),N.isPureReactComponent=!0;var M=Array.isArray,J=Object.prototype.hasOwnProperty,W={current:null},R={key:!0,ref:!0,__self:!0,__source:!0};function j($,q,ke){var se,ve={},Re=null,le=null;if(q!=null)for(se in q.ref!==void 0&&(le=q.ref),q.key!==void 0&&(Re=""+q.key),q)J.call(q,se)&&!R.hasOwnProperty(se)&&(ve[se]=q[se]);var xe=arguments.length-2;if(xe===1)ve.children=ke;else if(1<xe){for(var Le=Array(xe),oe=0;oe<xe;oe++)Le[oe]=arguments[oe+2];ve.children=Le}if($&&$.defaultProps)for(se in xe=$.defaultProps,xe)ve[se]===void 0&&(ve[se]=xe[se]);return{$$typeof:e,type:$,key:Re,ref:le,props:ve,_owner:W.current}}function A($,q){return{$$typeof:e,type:$.type,key:q,ref:$.ref,props:$.props,_owner:$._owner}}function D($){return typeof $=="object"&&$!==null&&$.$$typeof===e}function H($){var q={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(ke){return q[ke]})}var Y=/\/+/g;function ae($,q){return typeof $=="object"&&$!==null&&$.key!=null?H(""+$.key):q.toString(36)}function me($,q,ke,se,ve){var Re=typeof $;(Re==="undefined"||Re==="boolean")&&($=null);var le=!1;if($===null)le=!0;else switch(Re){case"string":case"number":le=!0;break;case"object":switch($.$$typeof){case e:case t:le=!0}}if(le)return le=$,ve=ve(le),$=se===""?"."+ae(le,0):se,M(ve)?(ke="",$!=null&&(ke=$.replace(Y,"$&/")+"/"),me(ve,q,ke,"",function(oe){return oe})):ve!=null&&(D(ve)&&(ve=A(ve,ke+(!ve.key||le&&le.key===ve.key?"":(""+ve.key).replace(Y,"$&/")+"/")+$)),q.push(ve)),1;if(le=0,se=se===""?".":se+":",M($))for(var xe=0;xe<$.length;xe++){Re=$[xe];var Le=se+ae(Re,xe);le+=me(Re,q,ke,Le,ve)}else if(Le=k($),typeof Le=="function")for($=Le.call($),xe=0;!(Re=$.next()).done;)Re=Re.value,Le=se+ae(Re,xe++),le+=me(Re,q,ke,Le,ve);else if(Re==="object")throw q=String($),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.");return le}function ye($,q,ke){if($==null)return $;var se=[],ve=0;return me($,se,"","",function(Re){return q.call(ke,Re,ve++)}),se}function _e($){if($._status===-1){var q=$._result;q=q(),q.then(function(ke){($._status===0||$._status===-1)&&($._status=1,$._result=ke)},function(ke){($._status===0||$._status===-1)&&($._status=2,$._result=ke)}),$._status===-1&&($._status=0,$._result=q)}if($._status===1)return $._result.default;throw $._result}var V={current:null},O={transition:null},F={ReactCurrentDispatcher:V,ReactCurrentBatchConfig:O,ReactCurrentOwner:W};function ne(){throw Error("act(...) is not supported in production builds of React.")}return Pt.Children={map:ye,forEach:function($,q,ke){ye($,function(){q.apply(this,arguments)},ke)},count:function($){var q=0;return ye($,function(){q++}),q},toArray:function($){return ye($,function(q){return q})||[]},only:function($){if(!D($))throw Error("React.Children.only expected to receive a single React element child.");return $}},Pt.Component=E,Pt.Fragment=n,Pt.Profiler=s,Pt.PureComponent=x,Pt.StrictMode=r,Pt.Suspense=u,Pt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=F,Pt.act=ne,Pt.cloneElement=function($,q,ke){if($==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+$+".");var se=v({},$.props),ve=$.key,Re=$.ref,le=$._owner;if(q!=null){if(q.ref!==void 0&&(Re=q.ref,le=W.current),q.key!==void 0&&(ve=""+q.key),$.type&&$.type.defaultProps)var xe=$.type.defaultProps;for(Le in q)J.call(q,Le)&&!R.hasOwnProperty(Le)&&(se[Le]=q[Le]===void 0&&xe!==void 0?xe[Le]:q[Le])}var Le=arguments.length-2;if(Le===1)se.children=ke;else if(1<Le){xe=Array(Le);for(var oe=0;oe<Le;oe++)xe[oe]=arguments[oe+2];se.children=xe}return{$$typeof:e,type:$.type,key:ve,ref:Re,props:se,_owner:le}},Pt.createContext=function($){return $={$$typeof:l,_currentValue:$,_currentValue2:$,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},$.Provider={$$typeof:a,_context:$},$.Consumer=$},Pt.createElement=j,Pt.createFactory=function($){var q=j.bind(null,$);return q.type=$,q},Pt.createRef=function(){return{current:null}},Pt.forwardRef=function($){return{$$typeof:c,render:$}},Pt.isValidElement=D,Pt.lazy=function($){return{$$typeof:p,_payload:{_status:-1,_result:$},_init:_e}},Pt.memo=function($,q){return{$$typeof:h,type:$,compare:q===void 0?null:q}},Pt.startTransition=function($){var q=O.transition;O.transition={};try{$()}finally{O.transition=q}},Pt.unstable_act=ne,Pt.useCallback=function($,q){return V.current.useCallback($,q)},Pt.useContext=function($){return V.current.useContext($)},Pt.useDebugValue=function(){},Pt.useDeferredValue=function($){return V.current.useDeferredValue($)},Pt.useEffect=function($,q){return V.current.useEffect($,q)},Pt.useId=function(){return V.current.useId()},Pt.useImperativeHandle=function($,q,ke){return V.current.useImperativeHandle($,q,ke)},Pt.useInsertionEffect=function($,q){return V.current.useInsertionEffect($,q)},Pt.useLayoutEffect=function($,q){return V.current.useLayoutEffect($,q)},Pt.useMemo=function($,q){return V.current.useMemo($,q)},Pt.useReducer=function($,q,ke){return V.current.useReducer($,q,ke)},Pt.useRef=function($){return V.current.useRef($)},Pt.useState=function($){return V.current.useState($)},Pt.useSyncExternalStore=function($,q,ke){return V.current.useSyncExternalStore($,q,ke)},Pt.useTransition=function(){return V.current.useTransition()},Pt.version="18.3.1",Pt}var Ay;function Xh(){return Ay||(Ay=1,yp.exports=xN()),yp.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 Iy;function _N(){if(Iy)return dl;Iy=1;var e=Xh(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,s=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function l(c,u,h){var p,g={},k=null,y=null;h!==void 0&&(k=""+h),u.key!==void 0&&(k=""+u.key),u.ref!==void 0&&(y=u.ref);for(p in u)r.call(u,p)&&!a.hasOwnProperty(p)&&(g[p]=u[p]);if(c&&c.defaultProps)for(p in u=c.defaultProps,u)g[p]===void 0&&(g[p]=u[p]);return{$$typeof:t,type:c,key:k,ref:y,props:g,_owner:s.current}}return dl.Fragment=n,dl.jsx=l,dl.jsxs=l,dl}var Ry;function EN(){return Ry||(Ry=1,kp.exports=_N()),kp.exports}var f=EN();const SN=new Set(["edit","delete","move","execute"]),NN=new Set(["Edit","Write","MultiEdit","NotebookEdit","Bash"]);function K0(e){return e.kind?SN.has(e.kind):NN.has(e.name)}const TN=["read","edit","delete","move","search","execute","fetch"];function Jh(e){return TN.includes(e??"")}function gd(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 Xl=[{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"}],th="auto";function jN(e){return e.branch.startsWith("toyon/")}const po="shell",ls="login";function CN(e,t){return`${e}/${t}`}function AN(e,t,n,r=0){var a;let s=e;for(let l=r;l>0;l--){let c=s.length-1;for(;c>=0&&((a=s[c])==null?void 0:a.proc)!==t;)c--;if(c<0)break;s=s===e?[...s]:s,s.splice(c,1)}return n?[...s,{proc:t,line:n}]:s}function Z0(e){return e.find(t=>t.id==="default")}function IN(e){const t=Z0(e);if(t!=null&&t.description)return e.find(n=>n!==t&&n.name===t.description)}function ir(e){return e.worktree!==void 0}function Ei(e){return e.kind==="main"}function Ta(e){return e.kind==="spare"}function hr(e){return Ta(e)||Ei(e)}function em(e){return e.kind==="worktree"}function q0(e){return e.kind==="worktree"&&jN(e)}function ki(e){var t;return e.kind==="worktree"&&((t=e.from)==null?void 0:t.kind)!=="pr"}function Ru(e){return e.kind==="worktree"}function kd(e){return!!e.branch&&!e.locked&&!(e.worktree&&hr(e.worktree))}const Ll=e=>{var t;return e.promptedAt??((t=e.lastTurn)==null?void 0:t.at)??e.createdAt},RN=e=>hr(e)?0:1,ON=e=>e.variant?`group:${e.variant.group}`:`row:${e.id}`;function $N(e){const t=[],n=new Map;for(const r of e){const s=r.worktree,a=ON(s),l=n.get(a);if(l){l.rows.push(r),l.at=Math.max(l.at,Ll(s));continue}const c={tier:RN(s),at:Ll(s),rows:[r]};t.push(c),n.set(a,c)}return t.sort((r,s)=>r.tier-s.tier||s.at-r.at),t.flatMap(r=>r.rows.length>1?r.rows.sort((s,a)=>{var l,c;return(((l=s.worktree.variant)==null?void 0:l.index)??0)-(((c=a.worktree.variant)==null?void 0:c.index)??0)}):r.rows)}const MN="not opened in ";function LN(e){const t=e.lastIndexOf(MN);return t<0?e:e.slice(t)}const G0={image:6,paste:4,file:8,pick:8},PN={image:"image",paste:"paste",file:"file",pick:"element"},DN={image:"Image",paste:"Pasted text"},V0=(e,t)=>`${DN[e]} ${t}`,tm=e=>`at most ${G0[e]} ${PN[e]}s per message`,zN=(e,t)=>e.filter(n=>n.kind===t).length,FN=(e,t)=>Math.max(0,G0[t]-zN(e,t));function Y0(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 Q0(e,t){const n={...t};return e.map(r=>[r,n[r.kind]++])}function X0(e,t){const n={...e};for(const r of t)n[r.kind]++;return n}function nm(e){return e>=1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}const Ou=[{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"}],BN=new Set(["zen","close","back","forward"]);function J0(e,{guest:t=!1}={}){var r,s;if(e.altKey){if(e.metaKey||e.ctrlKey)return null;const a=Ou.find(l=>l.alt&&!!l.shift===e.shiftKey&&(l.key===e.key||l.key.length===1&&e.code===`Key${l.key.toUpperCase()}`));return a&&a.id!=="worktree"?{id:a.id}:null}if(!e.metaKey&&!e.ctrlKey){if(e.shiftKey||t)return null;const a=Ou.find(l=>l.bareAlias===e.key);return a&&a.id!=="worktree"?{id:a.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 a of Ou){if(a.id==="worktree")continue;const l=a.ctrlAlias;if(l&&e.ctrlKey&&l.key===n&&!!l.shift===e.shiftKey&&!(t&&l.hostOnly))return{id:a.id};if(e.metaKey&&e.shiftKey&&((r=a.cmdShiftAlias)!=null&&r.includes(n)))return{id:a.id};if(!a.alt&&!(e.ctrlKey&&!a.ctrl||!!a.shift!==e.shiftKey)&&(a.key===n||(s=a.aliases)!=null&&s.includes(n)))return{id:a.id}}return null}function UN(e){return e.altKey||e.key.toLowerCase()!=="s"?!1:!!e.ctrlKey!==e.metaKey}function eb(e){const t=Ou.find(n=>n.id===e);if(!t)throw new Error(`unknown chord ${e}`);return t}function HN(e,t){return e===t-1?"⌘9":e<8?`⌘${e+1}`:void 0}function WN(e,t){return t===0?null:e===9?t-1:e-1<t?e-1:null}function KN(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 ZN(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 qN(e,t){const n=eb(e);return!!n.textKeeps&&KN(t)&&!(n.emptyGives&&ZN(t))}const GN=["Find","Preview","Panels","Worktrees"],Cl={"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"},changes:{label:"changes panel",section:"Panels"},files:{label:"files panel",section:"Panels"},"panel-tab-prev":{label:"previous panel tab",section:"Panels",hidden:!0},"panel-tab-next":{label:"next panel tab",section:"Panels"},composer:{label:"chat panel, with the editor's selection",section:"Panels"},rail:{label:"worktree panel",section:"Panels"},keys:{label:"settings & shortcuts",section:"Panels"},terminal:{label:"terminal",section:"Panels"},design:{label:"design system",section:"Panels"},"term-tab":{label:"next terminal tab",section:"Panels"},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},close:{label:"close the pane",section:"Panels",hidden:!0},pick:{label:"element to chat",section:"Preview"},inspect:{label:"element to code",section:"Preview"},zen:{label:"full-bleed preview",section:"Preview"},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"}},VN={ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Backspace:"⌫",Tab:"Tab"};function YN(e,t={}){var c;const n=eb(e),r=Cl[e],s=r.advertise&&t[r.advertise.when]?r.advertise.key:n.key;if(s===n.bareAlias)return s;const a=s==="1-9"?"1-9":VN[s]??s.toUpperCase(),l=s!==n.key&&s===((c=n.ctrlAlias)==null?void 0:c.key)?n.ctrlAlias:void 0;return l?`⌃${l.shift?"⇧":""}${a}`:`${n.alt?"⌥":n.ctrl?"⌃":"⌘"}${n.shift?"⇧":""}${a}`}function QN(e){return Object.keys(Cl).filter(t=>Cl[t].section===e&&!Cl[t].hidden)}const Oy={m:6e4,h:60*6e4};function XN(e){const[t,n]=JN(e);return`${t}${n.charAt(0)}`}function JN(e){const t=e/Oy.h;if(t>=1&&Number.isInteger(t))return[t,"hour"];const n=e/Oy.m;return n>=1&&Number.isInteger(n)?[n,"minute"]:n>=60?[Math.round(n),"minute"]:[Math.max(1,Math.round(e/1e3)),"second"]}const Pl={folder:{shared:".toyon/settings.json",local:".toyon/settings.local.json"},root:{shared:"toyon.json",local:"toyon.local.json"}};function tb(e){return typeof e=="string"?e:e.cmd}function eT(e){return typeof e!="string"&&e.from==="trunk"}function tT(e){return[...e.setup??[],...e.teardown??[],...Object.values(e.run).map(tb),...Object.values(e.profiles??{}).flatMap(n=>Object.values(n.env??{}))].some(n=>n.includes("TOYON_WORKTREE"))}function nT(e){return e===Pl.folder.local||e===Pl.root.local}function rT(e){return nT(e)?"local":"shared"}function oT(e,t){return(Object.values(Pl).find(r=>r.shared===e||r.local===e)??Pl.folder)[t]}function sT(e,t,n){return e.replace("{id}",t).replace("{port}",String(n))}const iT=4401,aT=25e4;function lT(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 s=e.slice(0,n).map(a=>({mark:" ",value:a}));return s.push(...cT(e.slice(n,e.length-r),t.slice(n,t.length-r))),s.push(...e.slice(e.length-r).map(a=>({mark:" ",value:a}))),s}function cT(e,t){if(e.length===0)return t.map(c=>({mark:"+",value:c}));if(t.length===0)return e.map(c=>({mark:"-",value:c}));if((e.length+1)*(t.length+1)>aT)return[...e.map(c=>({mark:"-",value:c})),...t.map(c=>({mark:"+",value:c}))];const n=t.length+1,r=new Uint32Array((e.length+1)*n);for(let c=e.length-1;c>=0;c--)for(let u=t.length-1;u>=0;u--)r[c*n+u]=e[c]===t[u]?(r[(c+1)*n+u+1]??0)+1:Math.max(r[(c+1)*n+u]??0,r[c*n+u+1]??0);const s=[];let a=0,l=0;for(;a<e.length&&l<t.length;)e[a]===t[l]?(s.push({mark:" ",value:e[a]}),a++,l++):(r[(a+1)*n+l]??0)>=(r[a*n+l+1]??0)?(s.push({mark:"-",value:e[a]}),a++):(s.push({mark:"+",value:t[l]}),l++);for(;a<e.length;)s.push({mark:"-",value:e[a++]});for(;l<t.length;)s.push({mark:"+",value:t[l++]});return s}const uT=/[\p{L}\p{N}_$]+|\s+|[^\s\p{L}\p{N}_$]/gu;function $y(e){return e.match(uT)??[]}const dT=.4;function fT(e,t){if(e===t)return null;const n=lT($y(e),$y(t));let r=0;for(const s of n)s.mark===" "&&(r+=s.value.length);return r<dT*Math.max(e.length,t.length)?null:{before:My(n,"-"),after:My(n,"+")}}function My(e,t){const n=[];for(const r of e){if(r.mark!==" "&&r.mark!==t)continue;const s=r.mark===t,a=n[n.length-1];a&&a.changed===s?a.text+=r.value:n.push({text:r.value,changed:s})}for(let r=1;r<n.length-1;r++){const s=n[r];s&&(s.changed?s.changed=s.text.trim()!=="":s.changed=s.text.length<=2)}return nb(n)}function Ly(e){const t=[[]];for(const n of e){const r=n.text.split(`
|
|
19
|
+
`);for(const[s,a]of r.entries())s>0&&t.push([]),a&&t[t.length-1].push({text:a,changed:n.changed})}return t.map(nb)}function nb(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 pT=[{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"}],hT=[{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"}],mT=[{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)"}],nh="merge",rh="merge";function wi(e){var n,r,s;const t=((n=e.land)==null?void 0:n.route)??nh;return{land:t,automerge:t==="pr"&&((r=e.land)==null?void 0:r.automerge)===!0,...(s=e.land)!=null&&s.method?{merge:e.land.method}:{}}}function yd(e){return e.base??e.defaultBranch}function gT(e){return e.base!==void 0&&e.base!==e.defaultBranch}function Bu(e,t="main"){const n={merge:"merge into",squash:"squash onto",rebase:"rebase onto"}[e.merge??rh];switch(e.land){case"merge":return`Commit and ${n} ${t} here`;case"push":return`Commit, ${n} ${t} on origin and push it`;case"pr":return e.automerge?"Commit, push the branch and open a PR that GitHub merges when its rules allow":"Commit, push the branch and open a PR"}}const kT="https://toyon.cloud",yT=e=>`${kT}/#add=${encodeURIComponent(e)}`;function rb(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,s])=>t.indexOf(+r)===-1).map(([r,s])=>s)}function Py(e,t="|"){return e.map(n=>ib(n)).join(t)}function oh(e,t){return typeof t=="bigint"?t.toString():t}function wd(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function wT(e){return e==null}function rm(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function vT(e,t){const n=e/t,r=Math.round(n),s=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<s?0:n-r}function Wr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ks(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function bT(e){return JSON.stringify(e)}function xT(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const ob="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Dl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const _T=wd(()=>{var e;if(Oo.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 zl(e){if(Dl(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Dl(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function sb(e){return zl(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const ET=new Set(["string","number","symbol"]);function ya(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Zs(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 nt(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 ib(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function ST(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const NT={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 TT(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 a=Ks(e._zod.def,{get shape(){const l={};for(const c of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,c))throw new Error(`Unrecognized key: "${String(c)}"`);t[c]&&Wr(l,c,n.shape[c])}return Wr(this,"shape",l),l},checks:[]});return Zs(e,a)}function jT(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 a=Ks(e._zod.def,{get shape(){const l={...e._zod.def.shape};for(const c of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,c))throw new Error(`Unrecognized key: "${String(c)}"`);t[c]&&delete l[c]}return Wr(this,"shape",l),l},checks:[]});return Zs(e,a)}function CT(e,t){if(!zl(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const a=e._zod.def.shape;for(const l of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(a,l)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const s=Ks(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return Wr(this,"shape",a),a}});return Zs(e,s)}function AT(e,t){if(!zl(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Ks(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Wr(this,"shape",r),r}});return Zs(e,n)}function IT(e,t){var r,s;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((s=e._zod.def.checks)!=null&&s.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=Ks(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Wr(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Zs(e,n)}function Dy(e,t,n,r="partial"){const a=t._zod.def.checks;if(a&&a.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const c=Ks(t._zod.def,{get shape(){const u=t._zod.def.shape,h={...u};if(n)for(const p of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(u,p))throw new Error(`Unrecognized key: "${String(p)}"`);n[p]&&(h[p]=e?new e({type:"optional",innerType:u[p]}):u[p])}else for(const p of Reflect.ownKeys(u))h[p]=e?new e({type:"optional",innerType:u[p]}):u[p];return Wr(this,"shape",h),h},checks:[]});return Zs(t,c)}function RT(e,t,n){const r=Ks(t._zod.def,{get shape(){const s=t._zod.def.shape,a={...s};if(n)for(const l of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(a,l))throw new Error(`Unrecognized key: "${String(l)}"`);n[l]&&(a[l]=new e({type:"nonoptional",innerType:s[l]}))}else for(const l of Reflect.ownKeys(s))a[l]=new e({type:"nonoptional",innerType:s[l]});return Wr(this,"shape",a),a}});return Zs(t,r)}function la(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 OT(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 vd(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function fl(e){return typeof e=="string"?e:e==null?void 0:e.message}function zy(e,t,n){var r;for(let s=t;s<e.length;s++)(r=e[s]).schema??(r.schema=n)}function ja(e,t,n){var k,y,v,_,E,C,x,N,M,J;var r;const s=(y=(k=e.inst)==null?void 0:k._zod)==null?void 0:y.traits;s!=null&&s.has("$ZodType")&&(s.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const a=e.schema!==e.inst?(_=(v=e.schema)==null?void 0:v._zod.def)==null?void 0:_.error:void 0,l=e.message?e.message:fl((x=(C=(E=e.inst)==null?void 0:E._zod.def)==null?void 0:C.error)==null?void 0:x.call(C,e))??fl(a==null?void 0:a(e))??fl((N=t==null?void 0:t.error)==null?void 0:N.call(t,e))??fl((M=n.customError)==null?void 0:M.call(n,e))??fl((J=n.localeError)==null?void 0:J.call(n,e))??"Invalid input",{inst:c,schema:u,continue:h,input:p,...g}=e;return g.path??(g.path=[]),g.message=l,t!=null&&t.reportInput&&(g.input=p),g}const $T=/[\uD800-\uDBFF]/;function om(e){const t=e.length;if(!$T.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 sm(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function MT(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 Fl(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function LT(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):PT(e,n,r.value)}}function wa(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function ab(e,t,n){return wa(e,t,n,!1)}function PT(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:wa(this,t,n.bind(this))},set(r){wa(this,t,r)}})}function DT(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let wp,zs=!1;const zT={configurable:!0,get(){zs=!0}};function sn(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&wp!==e._zod){wp=void 0;return}wp=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,zT);const s=zs;zs=!1;try{const a=n(this);return zs?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:a}),zs=zs||s,a}catch(a){throw delete this[t],zs=zs||s,a}},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s})}})}function FT(e,t,n,r){const s=DT(e,t);s&&Object.defineProperty(s,t,{configurable:!0,get(){const a={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,a),a.value=n(this),Object.defineProperty(this,t,a),a.value},set(a){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:a})}})}const BT="~constantCatch";function UT(e){const t=()=>e;return t[BT]=!0,t}var Fy;const vp={value:void 0,enumerable:!1};let By="captureStackTrace"in Error?Error:null;function HT(e){const t=By;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return By=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function ge(e,t,n,r){const s={};function a(k){this.def=k,this.constr=g,this.traits=new Set}a.prototype=s;const l=n,c=l&&new WeakSet;function u(k,y){if(!k._zod){vp.value=new a(y);try{Object.defineProperty(k,"_zod",vp)}finally{vp.value=void 0}}if(k._zod.traits.has(e))return;if(k._zod.traits.add(e),t(k,y),c){const _=Object.getPrototypeOf(k),E=k._zod.constr.prototype;let C=_;for(;C&&C!==E;)C=Object.getPrototypeOf(C);const x=C??_;c.has(x)||(c.add(x),LT(x,l))}const v=g.prototype;for(const _ in v)Object.prototype.hasOwnProperty.call(v,_)&&(_ in k||(k[_]=v[_].bind(k)))}const h=(r==null?void 0:r.Parent)??Object;class p extends h{}Object.defineProperty(p,"name",{value:e});function g(k){var E;const y=r!=null&&r.Parent?HT(p):this;u(y,k);const v=y._zod.deferred;if(v){for(const C of v)C();y._zod.deferred=void 0}const _=(E=globalThis.__zod_globalConfig)==null?void 0:E.postProcessor;return _&&_(y),y}return Object.defineProperty(g,"init",{value:u}),Object.defineProperty(g,Symbol.hasInstance,{value:k=>{var y,v;return r!=null&&r.Parent&&k instanceof r.Parent?!0:(v=(y=k==null?void 0:k._zod)==null?void 0:y.traits)==null?void 0:v.has(e)}}),Object.defineProperty(g,"name",{value:e}),g}class fa extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class lb extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Fy=globalThis).__zod_globalConfig??(Fy.__zod_globalConfig={});const Oo=globalThis.__zod_globalConfig;function qs(e){return e&&Object.assign(Oo,e),Oo}function WT(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,oh,2)),e.message}function KT(e){this._zod.message=e}const ZT={get:WT,set:KT,enumerable:!0,configurable:!0},bp={value:void 0,enumerable:!1},xp={value:void 0,enumerable:!1},Uy=new WeakSet([Object.prototype,Error.prototype]),cb=(e,t)=>{e.name="$ZodError",bp.value=e._zod,Object.defineProperty(e,"_zod",bp),xp.value=t,Object.defineProperty(e,"issues",xp),bp.value=void 0,xp.value=void 0,Object.defineProperty(e,"message",ZT);const n=Object.getPrototypeOf(e);Uy.has(n)||(Uy.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})}}))},ub=ge("$ZodError",cb),db=ge("$ZodError",cb,void 0,{Parent:Error});function qT(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 GT(e,t=n=>n.message){const n={},r=[];for(const s of e.issues)s.path.length>0?qT(n,s.path[0],()=>[]).push(t(s)):r.push(t(s));return{formErrors:r,fieldErrors:n}}function VT(e,t=n=>n.message){const n={_errors:[]},r=(s,a=[])=>{for(const l of s.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(c=>r({issues:c},[...a,...l.path]));else if(l.code==="invalid_key")r({issues:l.issues},[...a,...l.path]);else if(l.code==="invalid_element")r({issues:l.issues},[...a,...l.path]);else{const c=[...a,...l.path];if(c.length===0)n._errors.push(t(l));else{let u=n,h=0;for(;h<c.length;){const p=c[h],g=h===c.length-1;if(p==="_errors"){g&&u._errors.push(t(l)),h++;continue}Object.prototype.hasOwnProperty.call(u,p)||Object.defineProperty(u,p,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const k=u[p];g&&k._errors.push(t(l)),u=k,h++}}}};return r(e),n}function bd(e,t){return{callee:(t==null?void 0:t.callee)??e,Err:t==null?void 0:t.Err}}const im=e=>{const t=(n,r,s,a)=>{const l=s?{...s,async:!1}:{async:!1},c=n._zod.run({value:r,issues:[]},l);if(c instanceof Promise)throw new fa;if(c.issues.length){const u=new((a==null?void 0:a.Err)??e)(c.issues.map(h=>ja(h,l,qs())));throw ob(u,(a==null?void 0:a.callee)??t),u}return c.value};return t},am=e=>{const t=async(n,r,s,a)=>{const l=s?{...s,async:!0}:{async:!0};let c=n._zod.run({value:r,issues:[]},l);if(c instanceof Promise&&(c=await c),c.issues.length){const u=new((a==null?void 0:a.Err)??e)(c.issues.map(h=>ja(h,l,qs())));throw ob(u,(a==null?void 0:a.callee)??t),u}return c.value};return t},xd=e=>(t,n,r)=>{const s=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise)throw new fa;return a.issues.length?{success:!1,error:new(e??ub)(a.issues.map(l=>ja(l,s,qs())))}:{success:!0,data:a.value}},YT=xd(db),_d=e=>async(t,n,r)=>{const s=r?{...r,async:!0}:{async:!0};let a=t._zod.run({value:n,issues:[]},s);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(l=>ja(l,s,qs())))}:{success:!0,data:a.value}},QT=_d(db),XT=e=>{const t=im(e),n=(r,s,a,l)=>{const c=a?{...a,direction:"backward"}:{direction:"backward"};return t(r,s,c,bd(n,l))};return n},JT=e=>{const t=im(e),n=(r,s,a,l)=>t(r,s,a,bd(n,l));return n},ej=e=>{const t=am(e),n=async(r,s,a,l)=>{const c=a?{...a,direction:"backward"}:{direction:"backward"};return await t(r,s,c,bd(n,l))};return n},tj=e=>{const t=am(e),n=async(r,s,a,l)=>await t(r,s,a,bd(n,l));return n},nj=e=>(t,n,r)=>{const s=r?{...r,direction:"backward"}:{direction:"backward"};return xd(e)(t,n,s)},rj=e=>(t,n,r)=>xd(e)(t,n,r),oj=e=>async(t,n,r)=>{const s=r?{...r,direction:"backward"}:{direction:"backward"};return _d(e)(t,n,s)},sj=e=>async(t,n,r)=>_d(e)(t,n,r),ij=/^[cC][0-9a-z]{6,}$/,aj=/^[0-9a-z]+$/,lj=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,cj=/^[0-9a-vA-V]{20}$/,uj=/^[A-Za-z0-9]{27}$/,dj=/^[a-zA-Z0-9_-]{21}$/;function fj(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const pj=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,hj=/^([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})$/,Hy=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)$/,mj=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,gj="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function kj(){return new RegExp(gj,"u")}const yj=/^(?:(?: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])$/,wj=/^(([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}|:))$/,vj=/^((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])$/,bj=/^(([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])$/,xj=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,fb=/^[A-Za-z0-9_-]*$/,_j=/^https?$/,Ej=/^\+[1-9]\d{6,14}$/,pb="(?:(?:\\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 Sj(e){return new RegExp(`^${e}$`)}const Nj=Sj(pb);function sh(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 Tj(e){return new RegExp(`^${sh(e)}$`)}function jj(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${sh({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${sh({precision:e.precision})}`:n;return new RegExp(`^${pb}T(?:${r})$`)}const Cj=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}$`)},Aj=/^-?\d+$/,Ij=/^-?\d+(?:\.\d+)?$/,Rj=/^(?:true|false)$/i,Oj=/^[^A-Z]*$/,$j=/^[^a-z]*$/,Zr=ge("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),lm=e=>{const t=e.value;return!wT(t)&&t.length!==void 0},Uu={number:"number",bigint:"bigint",object:"date"},hb=ge("$ZodCheckLessThan",(e,t)=>{Zr.init(e,t);const n=Uu[typeof t.value];e._zod.onattach.push(r=>{const s=r._zod.bag,a=(t.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<a&&(t.inclusive?s.maximum=t.value:s.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Uu[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})}}),mb=ge("$ZodCheckGreaterThan",(e,t)=>{Zr.init(e,t);const n=Uu[typeof t.value];e._zod.onattach.push(r=>{const s=r._zod.bag,a=(t.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>a&&(t.inclusive?s.minimum=t.value:s.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Uu[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})}}),Mj=ge("$ZodCheckMultipleOf",(e,t)=>{Zr.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):vT(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})}}),Lj=ge("$ZodCheckNumberFormat",(e,t)=>{var l;Zr.init(e,t),t.format=t.format||"float64";const n=(l=t.format)==null?void 0:l.includes("int"),r=n?"int":"number",[s,a]=NT[t.format];e._zod.onattach.push(c=>{const u=c._zod.bag;u.format=t.format,u.minimum=s,u.maximum=a,n&&(u.pattern=Aj)}),e._zod.check=c=>{const u=c.value;if(n){if(!Number.isInteger(u)){c.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:u,inst:e});return}if(!Number.isSafeInteger(u)){u>0?c.issues.push({input:u,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):c.issues.push({input:u,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}u<s&&c.issues.push({origin:"number",input:u,code:"too_small",minimum:s,inclusive:!0,inst:e,continue:!t.abort}),u>a&&c.issues.push({origin:"number",input:u,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Pj=ge("$ZodCheckMaxLength",(e,t)=>{var n;Zr.init(e,t),(n=e._zod.def).when??(n.when=lm),e._zod.onattach.push(r=>{const s=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<s&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const s=r.value,a=s.length;if((typeof s=="string"&&a>t.maximum?om(s):a)<=t.maximum)return;const c=sm(s);r.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Dj=ge("$ZodCheckMinLength",(e,t)=>{var n;Zr.init(e,t),(n=e._zod.def).when??(n.when=lm),e._zod.onattach.push(r=>{const s=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>s&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const s=r.value,a=s.length;if((typeof s=="string"&&a>=t.minimum&&a<t.minimum*2?om(s):a)>=t.minimum)return;const c=sm(s);r.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),zj=ge("$ZodCheckLengthEquals",(e,t)=>{var n;Zr.init(e,t),(n=e._zod.def).when??(n.when=lm),e._zod.onattach.push(r=>{const s=r._zod.bag;s.minimum=t.length,s.maximum=t.length,s.length=t.length}),e._zod.check=r=>{const s=r.value,a=s.length,l=typeof s=="string"&&a>=t.length&&a<=t.length*2?om(s):a;if(l===t.length)return;const c=sm(s),u=l>t.length;r.issues.push({origin:c,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Ed=ge("$ZodCheckStringFormat",(e,t)=>{var n,r;Zr.init(e,t),e._zod.onattach.push(s=>{const a=s._zod.bag;a.format=t.format,t.pattern&&(a.patterns??(a.patterns=new Set),a.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=s=>{t.pattern.lastIndex=0,!t.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Fj=ge("$ZodCheckRegex",(e,t)=>{Ed.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})}}),Bj=ge("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Oj),Ed.init(e,t)}),Uj=ge("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=$j),Ed.init(e,t)}),Hj=ge("$ZodCheckIncludes",(e,t)=>{Zr.init(e,t);const n=ya(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.onattach.push(s=>{const a=s._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=s=>{s.value.includes(t.includes,t.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:s.value,inst:e,continue:!t.abort})}}),Wj=ge("$ZodCheckStartsWith",(e,t)=>{Zr.init(e,t);const n=new RegExp(`^${ya(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.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})}}),Kj=ge("$ZodCheckEndsWith",(e,t)=>{Zr.init(e,t);const n=new RegExp(`.*${ya(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.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})}}),Zj=ge("$ZodCheckOverwrite",(e,t)=>{Zr.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class qj{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(`
|
|
20
|
+
`).filter(l=>l),s=Math.min(...r.map(l=>l.length-l.trimStart().length)),a=r.map(l=>l.slice(s)).map(l=>" ".repeat(this.indent*2)+l);for(const l of a)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(", ")}) {
|
|
21
|
+
${n.join(`
|
|
22
|
+
`)}
|
|
23
|
+
};`)(...Object.values(this.closed))}}const Gj={major:4,minor:5,patch:4},jn=ge("$ZodType",(e,t)=>{var a;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Gj;const r=e._zod.def.checks,s=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r!=null&&r.length?[...r]:[];for(const l of s)for(const c of l._zod.onattach)c(e);if(s.length===0)(n=e._zod).deferred??(n.deferred=[]),(a=e._zod.deferred)==null||a.push(()=>{e._zod.run=e._zod.parse});else{const l=(u,h,p)=>{if(u.memo)return u;let g=la(u),k;for(const y of h){if(y._zod.def.when){if(OT(u)||!y._zod.def.when(u))continue}else if(g)continue;const v=u.issues.length,_=y._zod.check(u);if(_ instanceof Promise&&(p==null?void 0:p.async)===!1)throw new fa;if(k||_ instanceof Promise)k=(k??Promise.resolve()).then(async()=>{await _,u.issues.length!==v&&(zy(u.issues,v,e),g||(g=la(u,v)))});else{if(u.issues.length===v)continue;zy(u.issues,v,e),g||(g=la(u,v))}}return k?k.then(()=>u):u},c=(u,h,p)=>{if(la(u))return u.aborted=!0,u;const g=l(h,s,p);if(g instanceof Promise){if(p.async===!1)throw new fa;return g.then(k=>e._zod.parse(k,p))}return e._zod.parse(g,p)};e._zod.run=(u,h)=>{if(h.skipChecks)return e._zod.parse(u,h);if(h.direction==="backward"){const g=e._zod.parse({value:u.value,issues:[]},{...h,skipChecks:!0});return g instanceof Promise?g.then(k=>c(k,u,h)):c(g,u,h)}const p=e._zod.parse(u,h);if(p instanceof Promise){if(h.async===!1)throw new fa;return p.then(g=>l(g,s,h))}return l(p,s,h)}}},{get"~standard"(){return ab(this,"~standard",gb(this))},set"~standard"(e){wa(this,"~standard",e)}}),Wy=e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}};function gb(e){return{validate:t=>{try{return Wy(YT(e,t))}catch{return QT(e,t).then(Wy)}},vendor:"zod",version:1}}const cm=ge("$ZodString",(e,t)=>{var n;jn.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??Cj(e._zod.bag),e._zod.parse=(r,s)=>{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}}),Cn=ge("$ZodStringFormat",(e,t)=>{Ed.init(e,t),cm.init(e,t)}),Vj=ge("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=hj),Cn.init(e,t)}),Yj=ge("$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=Hy(r))}else t.pattern??(t.pattern=Hy());Cn.init(e,t)}),Qj=ge("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=mj),Cn.init(e,t)}),kb=1,yb=2;function Xj(e,t){var n;if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===_j.source&&!/^https?:\/\//i.test(e))return kb;try{return new URL(e)}catch{return yb}}const Jj=/[\t\n\r]/g;function eC(e){return e.replace(Jj,"")}function tC(e,t){return t.lastIndex=0,t.test(e.hostname)}function nC(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const rC=ge("$ZodURL",(e,t)=>{Cn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),s=Xj(r,t);if(s===kb){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(s===yb){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!tC(s,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&&!nC(s,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?s.href:eC(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),oC=ge("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=kj()),Cn.init(e,t)}),sC=ge("$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?dj:fj(t.length)),Cn.init(e,t)}),iC=ge("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ij),Cn.init(e,t)}),aC=ge("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=aj),Cn.init(e,t)}),lC=ge("$ZodULID",(e,t)=>{t.pattern??(t.pattern=lj),Cn.init(e,t)}),cC=ge("$ZodXID",(e,t)=>{t.pattern??(t.pattern=cj),Cn.init(e,t)}),uC=ge("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=uj),Cn.init(e,t)}),dC=ge("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=jj(t)),Cn.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(n=>{n._zod.bag.laxFormat=!0}))}),fC=ge("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Nj),Cn.init(e,t)}),pC=ge("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Tj(t)),Cn.init(e,t)}),hC=ge("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=pj),Cn.init(e,t)}),mC=ge("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=yj),Cn.init(e,t),e._zod.bag.format="ipv4"}),gC=/^[0-9a-fA-F:.]+$/;function wb(e){if(!gC.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}const kC=ge("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=wj),Cn.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{wb(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),yC=ge("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=vj),Cn.init(e,t)});function wC(e){const t=e.split("/");if(t.length!==2)return!1;const[n,r]=t;if(!r)return!1;const s=Number(r);return`${s}`!==r||s<0||s>128?!1:wb(n)}const vC=ge("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=bj),Cn.init(e,t),e._zod.check=n=>{wC(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function vb(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const bC=ge("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=xj),Cn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{vb(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function xC(e){if(!fb.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return vb(n)}const _C=ge("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=fb),Cn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{xC(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),EC=ge("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ej),Cn.init(e,t)});function SC(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const s=JSON.parse(atob(r));return!("typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||t&&(!("alg"in s)||s.alg!==t))}catch{return!1}}const NC=ge("$ZodJWT",(e,t)=>{Cn.init(e,t),e._zod.check=n=>{SC(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),bb=ge("$ZodNumber",(e,t)=>{jn.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ij,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const s=n.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return n;const a=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:String(s):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:s,inst:e,...a?{received:a}:{}}),n}}),TC=ge("$ZodNumberFormat",(e,t)=>{Lj.init(e,t),bb.init(e,t)}),jC=ge("$ZodBoolean",(e,t)=>{jn.init(e,t),e._zod.pattern=Rj,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const s=n.value;return typeof s=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:e}),n}}),CC=ge("$ZodUnknown",(e,t)=>{jn.init(e,t),e._zod.parse=n=>n}),AC=ge("$ZodNever",(e,t)=>{jn.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Ky(e,t,n){e.issues.length&&t.issues.push(...vd(n,e.issues)),t.value[n]=e.value}const IC=ge("$ZodArray",(e,t)=>{jn.init(e,t);const n=Oo.memoizer;n==null||n.attach(e),e._zod.parse=(r,s)=>{const a=r.value;if(!Array.isArray(a))return r.issues.push({expected:"array",code:"invalid_type",input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),s):Array(a.length);const l=[];for(let c=0;c<a.length;c++){const u=a[c],h=t.element._zod.run({value:u,issues:[]},s);h instanceof Promise?l.push(h.then(p=>Ky(p,r,c))):Ky(h,r,c)}return l.length?Promise.all(l).then(()=>r):r}});function Hu(e,t,n,r,s,a){const l=n in r,c=a==="optional";if(!(!l&&c&&s==="optional")){if(e.issues.length){if(s!==void 0&&c&&!l)return;t.issues.push(...vd(n,e.issues))}if(!l&&s===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 RC=[];function xb(e){var l,c,u,h;const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:RC,s=r.length?[...t,...r]:t;for(const p of s)if(!((h=(u=(c=(l=e.shape)==null?void 0:l[p])==null?void 0:c._zod)==null?void 0:u.traits)!=null&&h.has("$ZodType")))throw new Error(`Invalid element at key "${String(p)}": expected a Zod schema`);const a=ST(e.shape);return{...e,allKeys:s,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function _b(e,t,n,r,s,a){const l=[],c=s.keySet,u=s.catchall._zod,h=u.def.type,p=u.optin,g=u.optout;for(const k in t){if(c.has(k))continue;if(k==="__proto__"){h==="never"&&l.push(k);continue}if(h==="never"){l.push(k);continue}const y=u.run({value:t[k],issues:[]},r);y instanceof Promise?e.push(y.then(v=>Hu(v,n,k,t,p,g))):Hu(y,n,k,t,p,g)}return l.length&&n.issues.push({code:"unrecognized_keys",keys:l,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const ih=new WeakMap,OC=ge("$ZodObject",(e,t)=>{jn.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const u=t.shape;ih.set(t,u),Object.defineProperty(t,"shape",{get:()=>{const h={...u};return Object.defineProperty(t,"shape",{value:h}),ih.set(t,h),h}})}const r=wd(()=>xb(t));sn(e,"propValues",u=>{const h=u.def.shape,p={};for(const g in h){const k=h[g]._zod;if(k.values){Object.prototype.hasOwnProperty.call(p,g)||Wr(p,g,new Set);for(const y of k.values)p[g].add(y);k.optin!==void 0&&p[g].add(void 0)}}return p});const s=Dl,a=t.catchall;let l;const c=Oo.memoizer;c==null||c.attach(e),e._zod.parse=(u,h)=>{l??(l=r.value);const p=u.value;if(!s(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u;u.value=c?c.alloc(e,u,{},h):{};const g=[],k=l.shape;for(const y of l.allKeys){if(y==="__proto__")continue;const v=k[y],_=v._zod.optin,E=v._zod.optout,C=v._zod.run({value:p[y],issues:[]},h);C instanceof Promise?g.push(C.then(x=>Hu(x,u,y,p,_,E))):Hu(C,u,y,p,_,E)}return a?_b(g,p,u,h,r.value,e):g.length?Promise.all(g).then(()=>u):u}}),$C=ge("$ZodObjectJIT",(e,t)=>{OC.init(e,t);const n=e._zod.parse,r=wd(()=>xb(t)),s=Oo.memoizer,a=y=>{var J,W;const v=r.value,_=v.symbolKeys,E=new qj(["payload","ctx"],{shape:y,inst:e,memo:s,syms:_}),C=R=>`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`,x=(R,j)=>`
|
|
24
|
+
for (let i = 0; i < ${R}.issues.length; i++) {
|
|
25
|
+
const iss = ${R}.issues[i];
|
|
26
|
+
iss.path = iss.path ? [${j}, ...iss.path] : [${j}];
|
|
27
|
+
payload.issues.push(iss);
|
|
28
|
+
}`;E.write("const input = payload.value;");const N=Object.create(null);let M=0;for(const R of v.allKeys)N[R]=`key_${M++}`;E.write(s?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const R of v.allKeys){if(R==="__proto__")continue;const j=N[R],A=typeof R=="symbol"?`syms[${_.indexOf(R)}]`:bT(R),D=`${A} in input`,H=y[R],Y=(J=H==null?void 0:H._zod)==null?void 0:J.optin,ae=Y!==void 0,me=((W=H==null?void 0:H._zod)==null?void 0:W.optout)==="optional";if(E.write(`const ${j} = ${C(A)};`),ae&&me){const ye=Y==="optional"?`${j}_present`:`${j}.value !== undefined || ${j}_present`;E.write(`
|
|
29
|
+
const ${j}_present = ${D};
|
|
30
|
+
if (!${j}.issues.length || ${j}_present) {
|
|
31
|
+
if (${j}.issues.length) {${x(j,A)}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (${ye}) {
|
|
35
|
+
newResult[${A}] = ${j}.value;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
`)}else ae?E.write(`
|
|
40
|
+
if (${j}.issues.length) {${x(j,A)}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (${j}.value === undefined) {
|
|
44
|
+
if (${D}) {
|
|
45
|
+
newResult[${A}] = undefined;
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
newResult[${A}] = ${j}.value;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
`):E.write(`
|
|
52
|
+
const ${j}_present = ${D};
|
|
53
|
+
if (${j}.issues.length) {${x(j,A)}
|
|
54
|
+
}
|
|
55
|
+
if (!${j}_present && !${j}.issues.length) {
|
|
56
|
+
payload.issues.push({
|
|
57
|
+
code: "invalid_type",
|
|
58
|
+
expected: "nonoptional",
|
|
59
|
+
input: undefined,
|
|
60
|
+
path: [${A}]
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (${j}_present) {
|
|
65
|
+
newResult[${A}] = ${j}.value;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
`)}return E.write("payload.value = newResult;"),E.write("return payload;"),E.compile()};let l;const c=Dl,u=!Oo.jitless,p=u&&_T.value,g=t.catchall;let k;e._zod.parse=(y,v)=>{k??(k=r.value);const _=y.value;return c(_)?u&&p&&(v==null?void 0:v.async)===!1&&v.jitless!==!0?(l||(l=a(t.shape)),y=l(y,v),g?_b([],_,y,v,k,e):y):n(y,v):(y.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),y)}});function Zy(e,t,n,r){for(const a of e)if(a.issues.length===0)return t.value=a.value,t;const s=e.filter(a=>!la(a));return s.length===1?(t.value=s[0].value,s[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(a=>a.issues.map(l=>ja(l,r,qs())))}),t)}const Eb=ge("$ZodUnion",(e,t)=>{jn.init(e,t),sn(e,"optin",r=>r.def.options.some(s=>s._zod.optin==="defaulted")?"defaulted":r.def.options.some(s=>s._zod.optin!==void 0)?"optional":void 0),sn(e,"optout",r=>r.def.options.some(s=>s._zod.optout==="optional")?"optional":void 0),sn(e,"values",r=>{if(r.def.options.every(s=>s._zod.values))return new Set(r.def.options.flatMap(s=>Array.from(s._zod.values)))}),sn(e,"pattern",r=>{if(r.def.options.every(s=>s._zod.pattern)){const s=r.def.options.map(a=>a._zod.pattern);return new RegExp(`^(${s.map(a=>rm(a.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,s)=>{if(n)return n(r,s);let a=!1;const l=[];for(const c of t.options){const u=c._zod.run({value:r.value,issues:[]},s);if(u instanceof Promise)l.push(u),a=!0;else{if(u.issues.length===0)return u;l.push(u)}}return a?Promise.all(l).then(c=>Zy(c,r,e,s)):Zy(l,r,e,s)}}),MC=ge("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Eb.init(e,t);const n=e._zod.parse;sn(e,"propValues",s=>{const a={};for(const l of s.def.options){const c=l._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${s.def.options.indexOf(l)}"`);for(const[u,h]of Object.entries(c)){Object.prototype.hasOwnProperty.call(a,u)||Wr(a,u,new Set);for(const p of h)a[u].add(p)}}return a}),t.options.forEach((s,a)=>{const l=ih.get(s._zod.def);if(l&&!Object.prototype.hasOwnProperty.call(l,t.discriminator))throw new Error(`Invalid discriminated union option at index "${a}"`)});const r=wd(()=>{var l;const s=t.options,a=new Map;for(const c of s){const u=(l=c._zod.propValues)==null?void 0:l[t.discriminator];if(!u||u.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(c)}"`);for(const h of u){if(a.has(h))throw new Error(`Duplicate discriminator value "${String(h)}"`);a.set(h,c)}}return a});e._zod.parse=(s,a)=>{const l=s.value;if(!Dl(l))return s.issues.push({code:"invalid_type",expected:"object",input:l,inst:e}),s;const c=r.value.get(l==null?void 0:l[t.discriminator]);return c?c._zod.run(s,a):t.unionFallback||a.direction==="backward"?n(s,a):(s.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}),s)}}),LC=ge("$ZodIntersection",(e,t)=>{jn.init(e,t),e._zod.parse=(n,r)=>{const s=n.value,a=t.left._zod.run({value:s,issues:[]},r),l=t.right._zod.run({value:s,issues:[]},r);return a instanceof Promise||l instanceof Promise?Promise.all([a,l]).then(([u,h])=>qy(n,u,h)):qy(n,a,l)}});function ah(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(zl(e)&&zl(t)){const n=Object.keys(t),r=Object.keys(e).filter(a=>n.indexOf(a)!==-1),s={...e,...t};Object.prototype.hasOwnProperty.call(s,"__proto__")&&delete s.__proto__;for(const a of r){if(a==="__proto__")continue;const l=ah(e[a],t[a]);if(!l.valid)return{valid:!1,mergeErrorPath:[a,...l.mergeErrorPath]};s[a]=l.data}return{valid:!0,data:s}}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 s=e[r],a=t[r],l=ah(s,a);if(!l.valid)return{valid:!1,mergeErrorPath:[r,...l.mergeErrorPath]};n.push(l.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function qy(e,t,n){const r=new Map;let s;const a=new Map,l=(h,p)=>{var k,y;let g;if(h.code==="unrecognized_keys"&&!((k=h.path)!=null&&k.length))s??(s=h),g=h.keys;else if(h.code==="invalid_key"&&h.origin==="record"&&((y=h.path)==null?void 0:y.length)===1){const v=String(h.path[0]);a.has(v)||a.set(v,h),g=[v]}else return!1;for(const v of g)r.has(v)||r.set(v,{}),r.get(v)[p]=!0;return!0};for(const h of t.issues)l(h,"l")||e.issues.push(h);for(const h of n.issues)l(h,"r")||e.issues.push(h);const c=[...r].filter(([,h])=>h.l&&h.r).map(([h])=>h);if(c.length){const h=s?c.filter(p=>s.keys.includes(p)):[];h.length&&e.issues.push({...s,keys:h});for(const p of c)!h.includes(p)&&a.has(p)&&e.issues.push(a.get(p))}const u=ah(t.value,n.value);if(!u.valid){if(la(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}const PC=ge("$ZodTuple",(e,t)=>{jn.init(e,t);const n=t.items,r=Oo.memoizer;r==null||r.attach(e),e._zod.parse=(s,a)=>{const l=s.value;if(!Array.isArray(l))return s.issues.push({input:l,inst:e,expected:"tuple",code:"invalid_type"}),s;s.value=r?r.alloc(e,s,[],a):[];const c=[],u=Gy(n,"optin"),h=Gy(n,"optout");if(!t.rest){if(l.length<u)return s.issues.push({code:"too_small",minimum:u,inclusive:!0,input:l,inst:e,origin:"array"}),s;l.length>n.length&&s.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:l,inst:e,origin:"array"})}const p=new Array(n.length);for(let g=0;g<n.length;g++){const k=n[g]._zod.run({value:l[g],issues:[]},a);k instanceof Promise?c.push(k.then(y=>{p[g]=y})):p[g]=k}if(t.rest){let g=n.length-1;const k=l.slice(n.length);for(const y of k){g++;const v=t.rest._zod.run({value:y,issues:[]},a);v instanceof Promise?c.push(v.then(_=>Vy(_,s,g))):Vy(v,s,g)}}return c.length?Promise.all(c).then(()=>Yy(p,s,n,l,h)):Yy(p,s,n,l,h)}});function Gy(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 Vy(e,t,n){e.issues.length&&t.issues.push(...vd(n,e.issues)),t.value[n]=e.value}function Yy(e,t,n,r,s){for(let a=0;a<n.length;a++){const l=e[a],c=a<r.length;if(!c&&a>=s&&n[a]._zod.optin==="optional"){t.value.length=a;break}if(l.issues.length){if(!c&&a>=s){t.value.length=a;break}t.issues.push(...vd(a,l.issues))}t.value[a]=l.value}for(let a=t.value.length-1;a>=r.length&&(n[a]._zod.optout==="optional"&&t.value[a]===void 0);a--)t.value.length=a;return t}const DC=ge("$ZodEnum",(e,t)=>{jn.init(e,t);const n=rb(t.entries),r=new Set(n);e._zod.values=r;const s=n.filter(a=>ET.has(typeof a));e._zod.pattern=new RegExp(s.length?`^(${s.map(a=>ya(a.toString())).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(a,l)=>{const c=a.value;return r.has(c)||a.issues.push({code:"invalid_value",values:n,input:c,inst:e}),a}}),zC=ge("$ZodLiteral",(e,t)=>{jn.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"?ya(r):r?ya(r.toString()):String(r)).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(r,s)=>{const a=r.value;return n.has(a)||r.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),r}}),FC=ge("$ZodTransform",(e,t)=>{var n;jn.init(e,t),e._zod.optin="optional",(n=Oo.memoizer)==null||n.guard(e),e._zod.parse=(r,s)=>{if(s.direction==="backward")throw new lb(e.constructor.name);const a=t.transform(r.value,r);if(s.async)return(a instanceof Promise?a:Promise.resolve(a)).then(c=>(r.value=c,r));if(a instanceof Promise)throw new fa;return r.value=a,r}});function Qy(e,t){return e.value=t.issues.length?void 0:t.value,e}const Sb=ge("$ZodOptional",(e,t)=>{jn.init(e,t),sn(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",sn(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),sn(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${rm(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;const s=t.innerType._zod.run({value:n.value,issues:[]},r);return s instanceof Promise?s.then(a=>Qy(n,a)):Qy(n,s)}return t.innerType._zod.run(n,r)}}),BC=ge("$ZodExactOptional",(e,t)=>{Sb.init(e,t),sn(e,"values",n=>n.def.innerType._zod.values),sn(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),UC=ge("$ZodNullable",(e,t)=>{jn.init(e,t),sn(e,"optin",n=>n.def.innerType._zod.optin),sn(e,"optout",n=>n.def.innerType._zod.optout),sn(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${rm(r.source)}|null)$`):void 0}),sn(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)}),HC=ge("$ZodDefault",(e,t)=>{jn.init(e,t),e._zod.optin="defaulted",sn(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 s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(a=>Xy(a,t)):Xy(s,t)}});function Xy(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const WC=ge("$ZodPrefault",(e,t)=>{jn.init(e,t),e._zod.optin="defaulted",sn(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))}),KC=ge("$ZodNonOptional",(e,t)=>{jn.init(e,t),sn(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r].filter(s=>s!==void 0)):void 0}),e._zod.parse=(n,r)=>{const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(a=>Jy(a,e)):Jy(s,e)}});function Jy(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 ew(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(s=>ja(s,r,qs()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const ZC=ge("$ZodCatch",(e,t)=>{jn.init(e,t),sn(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),sn(e,"optout",n=>n.def.innerType._zod.optout),sn(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 s=t.innerType._zod.run({value:n.value,issues:[]},r);return s instanceof Promise?s.then(a=>ew(n,a,t,r)):ew(n,s,t,r)}}),qC=ge("$ZodPipe",(e,t)=>{jn.init(e,t),sn(e,"values",n=>n.def.in._zod.values),sn(e,"optin",n=>n.def.in._zod.optin),sn(e,"optout",n=>n.def.out._zod.optout),sn(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const a=t.out._zod.run(n,r);return a instanceof Promise?a.then(l=>uu(l,t.in,r)):uu(a,t.in,r)}const s=t.in._zod.run(n,r);return s instanceof Promise?s.then(a=>uu(a,t.out,r)):uu(s,t.out,r)}});function uu(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 GC=ge("$ZodReadonly",(e,t)=>{jn.init(e,t),sn(e,"propValues",n=>n.def.innerType._zod.propValues),sn(e,"values",n=>n.def.innerType._zod.values),sn(e,"optin",n=>{var r,s;return(s=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:s.optin}),sn(e,"optout",n=>{var r,s;return(s=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:s.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(tw):tw(s)}});function tw(e){return e.memo||(e.value=Object.freeze(e.value)),e}const VC=ge("$ZodCustom",(e,t)=>{Zr.init(e,t),jn.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,s=t.fn(r);if(s instanceof Promise)return s.then(a=>nw(a,n,r,e));nw(s,n,r,e)}});function nw(e,t,n,r){if(!e){const s={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(s.params=r._zod.def.params),t.issues.push(Fl(s))}}class YC extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const lh="~memo",rw=[];function _p(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const ow=new WeakMap;function Nb(e,t){const n=ow.get(e);if(n!==void 0)return n;if(t.has(e))return!0;t.add(e);let r=!1;const s=c=>{!r&&(c!=null&&c._zod)&&Nb(c,t)&&(r=!0)},a=e._zod.def;switch(a.type){case"object":{for(const c of Reflect.ownKeys(a.shape))s(a.shape[c]);s(a.catchall);break}case"array":s(a.element);break;case"tuple":for(const c of a.items)s(c);s(a.rest);break;case"record":case"map":s(a.keyType),s(a.valueType);break;case"set":s(a.valueType);break;case"union":for(const c of a.options)s(c);break;case"intersection":s(a.left),s(a.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(a.innerType);break;case"pipe":s(a.in),s(a.out);break;case"function":s(a.input),s(a.output);break;case"lazy":s(e._zod.innerType);break;case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const c in a){const u=Object.getOwnPropertyDescriptor(a,c);if(!u||u.get)continue;const h=u.value;if(!(!h||typeof h!="object")){if(h._zod)s(h);else if(Array.isArray(h))for(const p of h)s(p)}}}return t.delete(e),ow.set(e,r),r}function QC(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}let du;const fu=[],XC={alloc(e,t,n){const r=du;if(!r)return n;du=void 0;const s={value:n,issues:null};return r.set(t.value,s),fu.push(s),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const n=e._zod.parse,r=(s,a)=>{if(a.direction!=="backward"&&eA(a,s.value))throw new YC;return n(s,a)};e._zod.parse=r,e._zod.run===n&&(e._zod.run=r)})},attach(e){var t;let n,r,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const a=e._zod.parse,l=(c,u)=>{if(n===void 0&&(n=Nb(e,new Set),!n))return e._zod.parse=a,e._zod.run===l&&(e._zod.run=a),a(c,u);const h=c.value;if(h===null||typeof h!="object")return a(c,u);let p=u[lh];p||(p={buckets:new Map,backEdges:void 0},u[lh]=p);let g;r===u?g=s:(g=QC(p,e),r=u,s=g);const k=g.get(h);if(k)return c.value=k.value,k.issues?k.issues.length&&c.issues.push(..._p(k.issues)):(c.memo=!0,p.backEdges??(p.backEdges=new Set),p.backEdges.add(k.value)),c;du=g;const y=fu.length,v=a(c,u);du=void 0;const _=fu.length>y?fu.pop():void 0;return v instanceof Promise?v.then(E=>(_&&(_.issues=E.issues.length?_p(E.issues):rw),E)):(_&&(_.issues=v.issues.length?_p(v.issues):rw),v)};e._zod.parse=l,e._zod.run===a&&(e._zod.run=l)})}};function JC(){return XC}function eA(e,t){var r;const n=(r=e[lh])==null?void 0:r.backEdges;return n!==void 0&&t!==null&&typeof t=="object"&&n.has(t)}const tA=()=>{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(a){return e[a]??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 s(a,l){return a==="number"&&typeof l=="number"&&!Number.isFinite(l)?String(l):r[a]??a}return a=>{switch(a.code){case"invalid_type":{const l=s(a.expected),c=MT(a.input),u=s(c,a.input);return`Invalid input: expected ${l}, received ${u}`}case"invalid_value":return a.values.length===1?`Invalid input: expected ${ib(a.values[0])}`:`Invalid option: expected one of ${Py(a.values,"|")}`;case"too_big":{const l=a.exact?"exactly ":a.inclusive?"<=":"<",c=t(a.origin);return c?`Too big: expected ${a.origin??"value"} to have ${l}${a.maximum.toString()} ${c.unit??"elements"}`:`Too big: expected ${a.origin??"value"} to be ${l}${a.maximum.toString()}`}case"too_small":{const l=a.exact?"exactly ":a.inclusive?">=":">",c=t(a.origin);return c?`Too small: expected ${a.origin} to have ${l}${a.minimum.toString()} ${c.unit}`:`Too small: expected ${a.origin} to be ${l}${a.minimum.toString()}`}case"invalid_format":{const l=a;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]??a.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${a.divisor}`;case"unrecognized_keys":return`Unrecognized key${a.keys.length>1?"s":""}: ${Py(a.keys,", ")}`;case"invalid_key":return`Invalid key in ${a.origin}`;case"invalid_union":return a.options&&Array.isArray(a.options)&&a.options.length>0?`Invalid discriminator value. Expected ${a.options.map(c=>`'${c}'`).join(" | ")}`:a.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${a.origin}`;default:return"Invalid input"}}};function nA(){return{localeError:tA()}}var sw;class rA{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 s={...r,...this._map.get(t)};return Object.keys(s).length?s:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function oA(){return new rA}(sw=globalThis).__zod_globalRegistry??(sw.__zod_globalRegistry=oA());const vl=globalThis.__zod_globalRegistry;function sA(e,t){return new e({type:"string",...nt(t)})}function iA(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...nt(t)})}function aA(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...nt(t)})}function lA(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...nt(t)})}function cA(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...nt(t)})}function uA(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...nt(t)})}function dA(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...nt(t)})}function fA(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...nt(t)})}function pA(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...nt(t)})}function hA(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...nt(t)})}function mA(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...nt(t)})}function gA(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...nt(t)})}function kA(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...nt(t)})}function yA(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...nt(t)})}function wA(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...nt(t)})}function vA(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...nt(t)})}function bA(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...nt(t)})}function xA(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...nt(t)})}function _A(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...nt(t)})}function EA(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...nt(t)})}function SA(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...nt(t)})}function NA(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...nt(t)})}function TA(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...nt(t)})}function jA(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...nt(t)})}function CA(e,t){return new e({type:"string",format:"date",check:"string_format",...nt(t)})}function AA(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...nt(t)})}function IA(e,t){return new e({type:"string",format:"duration",check:"string_format",...nt(t)})}function RA(e,t){return new e({type:"number",checks:[],...nt(t)})}function OA(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...nt(t)})}function $A(e,t){return new e({type:"boolean",...nt(t)})}function MA(e){return new e({type:"unknown"})}function LA(e,t){return new e({type:"never",...nt(t)})}function iw(e,t){return new hb({check:"less_than",...nt(t),value:e,inclusive:!1})}function Ep(e,t){return new hb({check:"less_than",...nt(t),value:e,inclusive:!0})}function aw(e,t){return new mb({check:"greater_than",...nt(t),value:e,inclusive:!1})}function Sp(e,t){return new mb({check:"greater_than",...nt(t),value:e,inclusive:!0})}function lw(e,t){return new Mj({check:"multiple_of",...nt(t),value:e})}function Tb(e,t){return new Pj({check:"max_length",...nt(t),maximum:e})}function Wu(e,t){return new Dj({check:"min_length",...nt(t),minimum:e})}function jb(e,t){return new zj({check:"length_equals",...nt(t),length:e})}function PA(e,t){return new Fj({check:"string_format",format:"regex",...nt(t),pattern:e})}function DA(e){return new Bj({check:"string_format",format:"lowercase",...nt(e)})}function zA(e){return new Uj({check:"string_format",format:"uppercase",...nt(e)})}function FA(e,t){return new Hj({check:"string_format",format:"includes",...nt(t),includes:e})}function BA(e,t){return new Wj({check:"string_format",format:"starts_with",...nt(t),prefix:e})}function UA(e,t){return new Kj({check:"string_format",format:"ends_with",...nt(t),suffix:e})}function Ca(e){return new Zj({check:"overwrite",tx:e})}function HA(e){return Ca(t=>t.normalize(e))}function WA(){return Ca(e=>e.trim())}function KA(){return Ca(e=>e.toLowerCase())}function ZA(){return Ca(e=>e.toUpperCase())}function qA(){return Ca(e=>xT(e))}function GA(e,t,n){return new e({type:"array",element:t,...nt(n)})}function VA(e,t,n){return new e({type:"custom",check:"custom",fn:t,...nt(n)})}function YA(e,t){const n=QA(r=>(r.addIssue=s=>{if(typeof s=="string")r.issues.push(Fl(s,r.value,n._zod.def));else{const a=s;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=r.value),a.inst??(a.inst=n),a.continue??(a.continue=!n._zod.def.abort),r.issues.push(Fl(a))}},e(r.value,r)),t);return n}function QA(e,t){const n=new Zr({check:"custom",...nt(t)});return n._zod.check=e,n}function Al(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&Wr(e,r,n[r]);return e}function Cb(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)??vl,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 Ws(e,t,n,r,s){const a=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:s}):t.unrepresentable;if(a==="any")return!1;if(a===void 0||a==="throw")throw new Error(s);return Object.assign(n,a),!0}function ar(e,t,n={path:[],schemaPath:[]}){var p,g;var r;const s=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;const l={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,l),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const c=(g=(p=e._zod).toJSONSchema)==null?void 0:g.call(p);if(c)l.schema=c;else{const k={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,l.schema,k);else{const v=l.schema,_=t.processors[s.type];if(!_)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);_(e,t,v,k)}const y=e._zod.parent;y&&(l.ref||(l.ref=y),ar(y,t,k),t.seen.get(y).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&Al(l.schema,u),t.io==="input"&&Rr(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 cw(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Ab(e,t){var l,c,u,h;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const r=new Map;for(const p of e.seen.entries()){const g=(l=e.metadataRegistry.get(p[0]))==null?void 0:l.id;if(g){const k=r.get(g);if(k&&k!==p[0])throw new Error(`Duplicate schema id "${g}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(g,p[0])}}const s=p=>{var _;const g=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const E=(_=e.external.registry.get(p[0]))==null?void 0:_.id,C=e.external.uri??(N=>N);if(E)return{ref:C(E)};const x=p[1].defId??p[1].schema.id??`schema${e.counter++}`;return p[1].defId=x,{defId:x,ref:`${C("__shared")}#/${g}/${cw(x)}`}}const k="#",y=`${k}/${g}/`;if(p[1]===n&&!p[1].schema.id)return{ref:k};const v=p[1].schema.id??`__schema${e.counter++}`;return{defId:v,ref:y+cw(v)}},a=p=>{if(p[1].schema.$ref)return;const g=p[1],{ref:k,defId:y}=s(p);g.def={...g.schema},y&&(g.defId=y);const v=g.schema;for(const _ in v)delete v[_];v.$ref=k};if(e.cycles==="throw")for(const p of e.seen.entries()){const g=p[1];if(g.cycle)throw new Error(`Cycle detected: #/${(c=g.cycle)==null?void 0:c.join("/")}/<root>
|
|
69
|
+
|
|
70
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const p of e.seen.entries()){const g=p[1];if(t===p[0]){a(p);continue}if(e.external){const y=(u=e.external.registry.get(p[0]))==null?void 0:u.id;if(t!==p[0]&&y){a(p);continue}}if((h=e.metadataRegistry.get(p[0]))==null?void 0:h.id){a(p);continue}if(g.cycle){a(p);continue}if(g.count>1&&e.reused==="ref"){a(p);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Ib(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;Ib(r);const s=Object.keys(r);if(s.length!==1||s[0]!=="type")return;const a=r.type;for(const l of Array.isArray(a)?a:[a]){if(typeof l!="string")return;n.includes(l)||n.push(l)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const Rb=new Set(["type","properties","required","additionalProperties"]),uw=["oneOf","anyOf"];function dw(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function ch(e){var a;const t=[];for(const l of e){if(typeof l!="object"||l.type!=="object")return null;for(const c in l)if(!Rb.has(c))return null;t.push(l)}const n={},r=new Set;for(const l of t){for(const c in l.properties){if(Object.prototype.hasOwnProperty.call(n,c))continue;const u=[];for(const p of t){const g=((a=p.properties)==null?void 0:a[c])??dw(p);g!=null&&(u.some(k=>JSON.stringify(k)===JSON.stringify(g))||u.push(g))}const h=u.length===1?u[0]:ch(u)??{allOf:u};Wr(n,c,h)}for(const c of l.required??[])r.add(c)}const s={type:"object",properties:n};if(r.size&&(s.required=[...r]),t.every(l=>l.additionalProperties===!1))s.additionalProperties=!1;else{const l=[];for(const c of t){const u=dw(c);u&&!l.some(h=>JSON.stringify(h)===JSON.stringify(u))&&l.push(u)}l.length===1?s.additionalProperties=l[0]:l.length>1&&(s.additionalProperties={allOf:l})}return s}function XA(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const s of Rb)if(s in e)return;const n=t.filter(s=>uw.some(a=>Array.isArray(s[a])));let r=null;if(!n.length)r=ch(t);else{const s=n[0],a=uw.find(u=>Array.isArray(s[u]));if(Object.keys(s).length!==1)return;const l=t.filter(u=>u!==s),c=s[a].map(u=>ch([...l,u]));if(c.some(u=>!u))return;r={[a]:c}}r&&(delete e.allOf,Al(e,r))}function Ob(e,t){var c,u,h,p;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=g=>{const k=e.seen.get(g);if(k.ref===null)return;const y=k.def??k.schema,v={...y},_=k.ref;if(k.ref=null,_){r(_);const C=e.seen.get(_),x=C.schema;if(x.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(y.allOf=y.allOf??[],y.allOf.push(x)):Al(y,x),Al(y,v),g._zod.parent===_)for(const M in y)M==="$ref"||M==="allOf"||M in v||delete y[M];if(x.$ref&&C.def)for(const M in y)M==="$ref"||M==="allOf"||M in C.def&&JSON.stringify(y[M])===JSON.stringify(C.def[M])&&delete y[M]}const E=g._zod.parent;if(E&&E!==_){r(E);const C=e.seen.get(E);if(C!=null&&C.schema.$ref&&(y.$ref=C.schema.$ref,C.def))for(const x in y)x==="$ref"||x==="allOf"||x in C.def&&JSON.stringify(y[x])===JSON.stringify(C.def[x])&&delete y[x]}e.override({zodSchema:g,jsonSchema:y,path:k.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const g of[...e.seen.entries()].reverse())r(g[0]);if(e.target!=="openapi-3.0")for(const g of e.seen.entries())Ib(g[1].def??g[1].schema);for(const g of e.deferred)g();if(e.intersections.length){const g=new Map;for(const k of e.seen.values())for(const y of[k.schema,k.def]){const v=y==null?void 0:y.allOf;if(!Array.isArray(v))continue;const _=g.get(v);_?_.push(y):g.set(v,[y])}for(const k of e.intersections)for(const y of g.get(k)??[])XA(y)}}const s={};if(e.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":e.target,(c=e.external)!=null&&c.uri){const g=(u=e.external.registry.get(t))==null?void 0:u.id;if(!g)throw new Error("Schema is missing an `id` property");s.$id=e.external.uri(g)}Al(s,n.defId?n.schema:n.def??n.schema);const a=(h=e.metadataRegistry.get(t))==null?void 0:h.id;a!==void 0&&s.id===a&&delete s.id;const l=((p=e.external)==null?void 0:p.defs)??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const g of e.seen.entries()){const k=g[1];k.def&&k.defId&&(k.def.id===k.defId&&delete k.def.id,Wr(l,k.defId,k.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(l).length>0&&(e.target==="draft-2020-12"?s.$defs=l:s.definitions=l);try{const g=JSON.parse(JSON.stringify(s));return Object.defineProperty(g,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ku(t,"input",e.processors),output:Ku(t,"output",e.processors)}},enumerable:!1,writable:!1}),g}catch{throw new Error("Error converting schema to JSON.")}}function Rr(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 Rr(r.element,n);if(r.type==="set")return Rr(r.valueType,n);if(r.type==="lazy")return Rr(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 Rr(r.innerType,n);if(r.type==="intersection")return Rr(r.left,n)||Rr(r.right,n);if(r.type==="record"||r.type==="map")return Rr(r.keyType,n)||Rr(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Rr(r.in,n)||Rr(r.out,n);if(r.type==="object"){for(const s in r.shape)if(Rr(r.shape[s],n))return!0;return!1}if(r.type==="union"){for(const s of r.options)if(Rr(s,n))return!0;return!1}if(r.type==="tuple"){for(const s of r.items)if(Rr(s,n))return!0;return!!(r.rest&&Rr(r.rest,n))}return!1}const JA=(e,t={})=>n=>{const r=Cb({...n,processors:t});return ar(e,r),Ab(r,e),Ob(r,e)},Ku=(e,t,n={})=>r=>{const{libraryOptions:s,target:a}=r??{},l=Cb({...s??{},target:a,io:t,processors:n});return ar(e,l),Ab(l,e),Ob(l,e)},eI={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},tI=(e,t,n,r)=>{const s=n;s.type="string";const{minimum:a,maximum:l,format:c,patterns:u,contentEncoding:h,laxFormat:p}=e._zod.bag;if(typeof a=="number"&&(s.minLength=a),typeof l=="number"&&(s.maxLength=l),c&&(s.format=eI[c]??c,s.format===""&&delete s.format,(c==="time"||p)&&delete s.format),h&&(s.contentEncoding=h),u&&u.size>0){const g=[...u];g.length===1?s.pattern=g[0].source:g.length>1&&(s.allOf=[...g.map(k=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:k.source}))])}},nI=(e,t,n,r)=>{const s=n,{minimum:a,maximum:l,format:c,multipleOf:u,exclusiveMaximum:h,exclusiveMinimum:p}=e._zod.bag;typeof c=="string"&&c.includes("int")?s.type="integer":s.type="number";const g=typeof p=="number"&&p>=(a??Number.NEGATIVE_INFINITY),k=typeof h=="number"&&h<=(l??Number.POSITIVE_INFINITY),y=t.target==="draft-04"||t.target==="openapi-3.0";g?y?(s.minimum=p,s.exclusiveMinimum=!0):s.exclusiveMinimum=p:typeof a=="number"&&(s.minimum=a),k?y?(s.maximum=h,s.exclusiveMaximum=!0):s.exclusiveMaximum=h:typeof l=="number"&&(s.maximum=l),typeof u=="number"&&(Number.isFinite(u)&&u!==0?s.multipleOf=Math.abs(u):Ws(e,t,s,r,`A multipleOf divisor of ${u} cannot be represented in JSON Schema`))},rI=(e,t,n,r)=>{n.type="boolean"},oI=(e,t,n,r)=>{n.not={}},sI=(e,t,n,r)=>{},iI=(e,t,n,r)=>{const s=e._zod.def,a=rb(s.entries);if(a.length===0){n.not={};return}a.every(l=>typeof l=="number")&&(n.type="number"),a.every(l=>typeof l=="string")&&(n.type="string"),n.enum=a},aI=(e,t,n,r)=>{const s=e._zod.def;if(s.values.length===0){n.not={};return}const a=[];for(const l of s.values)if(l===void 0){if(Ws(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof l=="bigint"){if(Ws(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;a.push(Number(l))}else a.push(l);if(a.length!==0)if(a.length===1){const l=a[0];n.type=l===null?"null":typeof l,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[l]:n.const=l}else a.every(l=>typeof l=="number")&&(n.type="number"),a.every(l=>typeof l=="string")&&(n.type="string"),a.every(l=>typeof l=="boolean")&&(n.type="boolean"),a.every(l=>l===null)&&(n.type="null"),n.enum=a},lI=(e,t,n,r)=>{Ws(e,t,n,r,"Custom types cannot be represented in JSON Schema")},cI=(e,t,n,r)=>{Ws(e,t,n,r,"Transforms cannot be represented in JSON Schema")},uI=(e,t,n,r)=>{const s=n,a=e._zod.def,{minimum:l,maximum:c}=e._zod.bag;typeof l=="number"&&(s.minItems=l),typeof c=="number"&&(s.maxItems=c),s.type="array",s.items=ar(a.element,t,{...r,path:[...r.path,"items"]})};function Zu(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Zu(t.out):t.type==="catch"?Zu(t.innerType):e._zod.optin}const dI=(e,t,n,r)=>{var p;const s=n,a=e._zod.def,l=a.shape;if(Object.getOwnPropertySymbols(l).length&&Ws(e,t,s,r,"Symbol keys cannot be represented in JSON Schema"))return;s.type="object",s.properties={};for(const g in l)Wr(s.properties,g,ar(l[g],t,{...r,path:[...r.path,"properties",g]}));const u=new Set(Object.keys(l)),h=new Set([...u].filter(g=>{const k=a.shape[g];return t.io==="input"?Zu(k)===void 0:k._zod.optout===void 0}));h.size>0&&(s.required=Array.from(h)),((p=a.catchall)==null?void 0:p._zod.def.type)==="never"?s.additionalProperties=!1:a.catchall?a.catchall&&(s.additionalProperties=ar(a.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(s.additionalProperties=!1)},fI=(e,t,n,r)=>{const s=e._zod.def,a=s.inclusive===!1,l=s.options.map((c,u)=>ar(c,t,{...r,path:[...r.path,a?"oneOf":"anyOf",u]}));a?n.oneOf=l:n.anyOf=l},pI=(e,t,n,r)=>{const s=e._zod.def,a=ar(s.left,t,{...r,path:[...r.path,"allOf",0]}),l=ar(s.right,t,{...r,path:[...r.path,"allOf",1]}),c=h=>"allOf"in h&&Object.keys(h).length===1,u=[...c(a)?a.allOf:[a],...c(l)?l.allOf:[l]];n.allOf=u,t.intersections.push(u)},hI=(e,t,n,r)=>{const s=n,a=e._zod.def;s.type="array";const l=t.target==="draft-2020-12"?"prefixItems":"items",c=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",u=a.items.map((_,E)=>ar(_,t,{...r,path:[...r.path,l,E]})),h=a.rest?ar(a.rest,t,{...r,path:[...r.path,c,...t.target==="openapi-3.0"?[a.items.length]:[]]}):null;let p=a.items.length;for(;p>0;){const _=a.items[p-1];if(!(t.io==="input"?Zu(_)!==void 0:_._zod.optout==="optional"))break;p--}const g=a.items.length,k=!a.rest;t.target==="draft-2020-12"?(s.prefixItems=u,k?s.items=!1:h&&(s.items=h),p>0&&(s.minItems=p),k&&(s.maxItems=g)):t.target==="openapi-3.0"?(s.items={anyOf:u},h&&s.items.anyOf.push(h),p>0&&(s.minItems=p),k&&(s.maxItems=g)):(s.items=u,k?s.additionalItems=!1:h&&(s.additionalItems=h),p>0&&(s.minItems=p),k&&(s.maxItems=g));const{minimum:y,maximum:v}=e._zod.bag;typeof y=="number"&&(s.minItems=y),typeof v=="number"&&(s.maxItems=v)},mI=(e,t,n,r)=>{const s=e._zod.def,a=ar(s.innerType,t,r),l=t.seen.get(e);t.target==="openapi-3.0"?(l.ref=s.innerType,n.nullable=!0):n.anyOf=[a,{type:"null"}]},gI=(e,t,n,r)=>{const s=e._zod.def;ar(s.innerType,t,r);const a=t.seen.get(e);a.ref=s.innerType},um=Symbol();function $b(e,t,n,r,s){let a=!1;const l=JSON.stringify(e,(c,u)=>typeof u!="bigint"?u:(a=!0,null));return a?(Ws(t,n,r,s,"BigInt defaults cannot be represented in JSON Schema"),um):JSON.parse(l)}const kI=(e,t,n,r)=>{const s=e._zod.def;ar(s.innerType,t,r);const a=t.seen.get(e);a.ref=s.innerType;const l=$b(s.defaultValue,e,t,n,r);l!==um&&(n.default=l)},yI=(e,t,n,r)=>{const s=e._zod.def;ar(s.innerType,t,r);const a=t.seen.get(e);if(a.ref=s.innerType,t.io!=="input")return;const l=$b(s.defaultValue,e,t,n,r);l!==um&&(n._prefault=l)},wI=(e,t,n,r)=>{const s=e._zod.def;ar(s.innerType,t,r);const a=t.seen.get(e);a.ref=s.innerType;let l;try{l=s.catchValue(void 0)}catch{Ws(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=l},vI=(e,t,n,r)=>{const s=e._zod.def,a=s.in._zod.traits.has("$ZodTransform"),l=t.io==="input"?a?s.out:s.in:s.out;ar(l,t,r);const c=t.seen.get(e);c.ref=l},bI=(e,t,n,r)=>{const s=e._zod.def;ar(s.innerType,t,r);const a=t.seen.get(e);a.ref=s.innerType,n.readOnly=!0},Mb=(e,t,n,r)=>{const s=e._zod.def;ar(s.innerType,t,r);const a=t.seen.get(e);a.ref=s.innerType},fw=new WeakSet([Object.prototype,Error.prototype]);function pu(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){const r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}const xI=(e,t)=>{ub.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);fw.has(n)||(fw.add(n),pu(n,"format",r=>s=>VT(r,s)),pu(n,"flatten",r=>s=>GT(r,s)),pu(n,"addIssue",r=>s=>{r.issues.push(s),r.message=JSON.stringify(r.issues,oh,2)}),pu(n,"addIssues",r=>s=>{r.issues.push(...s),r.message=JSON.stringify(r.issues,oh,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},ko=ge("ZodError",xI,void 0,{Parent:Error}),_I=im(ko),EI=am(ko),SI=xd(ko),NI=_d(ko),TI=XT(ko),jI=JT(ko),CI=ej(ko),AI=tj(ko),II=nj(ko),RI=rj(ko),OI=oj(ko),$I=sj(ko);function MI(){Oo.localeError||qs(nA())}function Sd(){Oo.memoizer||qs({memoizer:JC()})}const Ln=ge("ZodType",(e,t)=>(MI(),jn.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(Ks(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 Zs(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(OR(e,t))},superRefine(e,t){return this.check($R(e,t))},overwrite(e){return this.check(Ca(e))},optional(){return mw(this)},exactOptional(){return bR(this)},nullable(){return gw(this)},nullish(){return mw(gw(this))},nonoptional(e){return TR(this,e)},array(){return bi(this)},or(e){return fR([this,e])},and(e){return gR(this,e)},transform(e){return kw(this,vR(e))},default(e){return ER(this,e)},prefault(e){return NR(this,e)},catch(e){return CR(this,e)},pipe(e){return kw(this,e)},readonly(){return RR(this)},describe(e){const t=this.clone();return vl.add(t,{description:e}),t},meta(...e){if(e.length===0)return vl.get(this);const t=this.clone();return vl.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 ab(this,"~standard",{...gb(this),jsonSchema:{input:Ku(this,"input"),output:Ku(this,"output")}})},set"~standard"(e){wa(this,"~standard",e)},parse:function e(t,n){return _I(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await EI(this,t,n,{callee:e})},safeParse(e,t){return SI(this,e,t)},async safeParseAsync(e,t){return NI(this,e,t)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(e){wa(this,"spa",e)},encode:function e(t,n){return TI(this,t,n,{callee:e})},decode:function e(t,n){return jI(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await CI(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await AI(this,t,n,{callee:e})},safeEncode(e,t){return II(this,e,t)},safeDecode(e,t){return RI(this,e,t)},async safeEncodeAsync(e,t){return OI(this,e,t)},async safeDecodeAsync(e,t){return $I(this,e,t)},toJSONSchema(e){return JA(this,{})(e)},get description(){var e;return(e=vl.get(this))==null?void 0:e.description},get _def(){return this._zod.def}}),Lb=ge("_ZodString",(e,t)=>{cm.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(r,s,a)=>tI(e,r,s);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(PA(...e))},includes(...e){return this.check(FA(...e))},startsWith(...e){return this.check(BA(...e))},endsWith(...e){return this.check(UA(...e))},min(...e){return this.check(Wu(...e))},max(...e){return this.check(Tb(...e))},length(...e){return this.check(jb(...e))},nonempty(...e){return this.check(Wu(1,...e))},lowercase(e){return this.check(DA(e))},uppercase(e){return this.check(zA(e))},trim(){return this.check(WA())},normalize(...e){return this.check(HA(...e))},toLowerCase(){return this.check(KA())},toUpperCase(){return this.check(ZA())},slugify(){return this.check(qA())}}),LI=ge("ZodString",(e,t)=>{cm.init(e,t),Lb.init(e,t)},{email(e){return this.check(iA(BI,e))},url(e){return this.check(fA(HI,e))},jwt(e){return this.check(TA(oR,e))},emoji(e){return this.check(pA(WI,e))},guid(e){return this.check(aA(UI,e))},uuid(e){return this.check(lA(hu,e))},uuidv4(e){return this.check(cA(hu,e))},uuidv6(e){return this.check(uA(hu,e))},uuidv7(e){return this.check(dA(hu,e))},nanoid(e){return this.check(hA(KI,e))},cuid(e){return this.check(mA(ZI,e))},cuid2(e){return this.check(gA(qI,e))},ulid(e){return this.check(kA(GI,e))},base64(e){return this.check(EA(tR,e))},base64url(e){return this.check(SA(nR,e))},xid(e){return this.check(yA(VI,e))},ksuid(e){return this.check(wA(YI,e))},ipv4(e){return this.check(vA(QI,e))},ipv6(e){return this.check(bA(XI,e))},cidrv4(e){return this.check(xA(JI,e))},cidrv6(e){return this.check(_A(eR,e))},e164(e){return this.check(NA(rR,e))},datetime(e){return this.check(jA(PI,e))},date(e){return this.check(CA(DI,e))},time(e){return this.check(AA(zI,e))},duration(e){return this.check(IA(FI,e))}});function dn(e){return sA(LI,e)}const Pn=ge("ZodStringFormat",(e,t)=>{Cn.init(e,t),Lb.init(e,t)}),PI=ge("ZodISODateTime",(e,t)=>{dC.init(e,t),Pn.init(e,t)}),DI=ge("ZodISODate",(e,t)=>{fC.init(e,t),Pn.init(e,t)}),zI=ge("ZodISOTime",(e,t)=>{pC.init(e,t),Pn.init(e,t)}),FI=ge("ZodISODuration",(e,t)=>{hC.init(e,t),Pn.init(e,t)}),BI=ge("ZodEmail",(e,t)=>{Qj.init(e,t),Pn.init(e,t)}),UI=ge("ZodGUID",(e,t)=>{Vj.init(e,t),Pn.init(e,t)}),hu=ge("ZodUUID",(e,t)=>{Yj.init(e,t),Pn.init(e,t)}),HI=ge("ZodURL",(e,t)=>{rC.init(e,t),Pn.init(e,t)}),WI=ge("ZodEmoji",(e,t)=>{oC.init(e,t),Pn.init(e,t)}),KI=ge("ZodNanoID",(e,t)=>{sC.init(e,t),Pn.init(e,t)}),ZI=ge("ZodCUID",(e,t)=>{iC.init(e,t),Pn.init(e,t)}),qI=ge("ZodCUID2",(e,t)=>{aC.init(e,t),Pn.init(e,t)}),GI=ge("ZodULID",(e,t)=>{lC.init(e,t),Pn.init(e,t)}),VI=ge("ZodXID",(e,t)=>{cC.init(e,t),Pn.init(e,t)}),YI=ge("ZodKSUID",(e,t)=>{uC.init(e,t),Pn.init(e,t)}),QI=ge("ZodIPv4",(e,t)=>{mC.init(e,t),Pn.init(e,t)}),XI=ge("ZodIPv6",(e,t)=>{kC.init(e,t),Pn.init(e,t)}),JI=ge("ZodCIDRv4",(e,t)=>{yC.init(e,t),Pn.init(e,t)}),eR=ge("ZodCIDRv6",(e,t)=>{vC.init(e,t),Pn.init(e,t)}),tR=ge("ZodBase64",(e,t)=>{bC.init(e,t),Pn.init(e,t)}),nR=ge("ZodBase64URL",(e,t)=>{_C.init(e,t),Pn.init(e,t)}),rR=ge("ZodE164",(e,t)=>{EC.init(e,t),Pn.init(e,t)}),oR=ge("ZodJWT",(e,t)=>{NC.init(e,t),Pn.init(e,t)}),Pb=ge("ZodNumber",(e,t)=>{bb.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(r,s,a)=>nI(e,r,s,a);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(aw(e,t))},gte(e,t){return this.check(Sp(e,t))},min(e,t){return this.check(Sp(e,t))},lt(e,t){return this.check(iw(e,t))},lte(e,t){return this.check(Ep(e,t))},max(e,t){return this.check(Ep(e,t))},int(e){return this.check(pw(e))},safe(e){return this.check(pw(e))},positive(e){return this.check(aw(0,e))},nonnegative(e){return this.check(Sp(0,e))},negative(e){return this.check(iw(0,e))},nonpositive(e){return this.check(Ep(0,e))},multipleOf(e,t){return this.check(lw(e,t))},step(e,t){return this.check(lw(e,t))},finite(){return this}});function vi(e){return RA(Pb,e)}const sR=ge("ZodNumberFormat",(e,t)=>{TC.init(e,t),Pb.init(e,t)});function pw(e){return OA(sR,e)}const iR=ge("ZodBoolean",(e,t)=>{jC.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(n,r,s)=>rI(e,n,r)});function jo(e){return $A(iR,e)}const aR=ge("ZodUnknown",(e,t)=>{CC.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(n,r,s)=>sI()});function hw(){return MA(aR)}const lR=ge("ZodNever",(e,t)=>{AC.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(n,r,s)=>oI(e,n,r)});function cR(e){return LA(lR,e)}const uR=ge("ZodArray",(e,t)=>{Sd(),IC.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(n,r,s)=>uI(e,n,r,s),e.element=t.element},{min(e,t){return this.check(Wu(e,t))},nonempty(e){return this.check(Wu(1,e))},max(e,t){return this.check(Tb(e,t))},length(e,t){return this.check(jb(e,t))},unwrap(){return this.element}});function bi(e,t){return GA(uR,e,t)}const dR=ge("ZodObject",(e,t)=>{Sd(),$C.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(n,r,s)=>dI(e,n,r,s),FT(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return qu(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:hw()})},loose(){return this.clone({...this._zod.def,catchall:hw()})},strict(){return this.clone({...this._zod.def,catchall:cR()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return CT(this,e)},safeExtend(e){return AT(this,e)},merge(e){return IT(this,e)},pick(e){return TT(this,e)},omit(e){return jT(this,e)},partial(...e){return Dy(dm,this,e[0])},exactPartial(...e){return Dy(Fb,this,e[0],"exactPartial")},required(...e){return RT(Bb,this,e[0])}});function Er(e,t){const n={type:"object",shape:e??{},...nt(t)};return new dR(n)}const Db=ge("ZodUnion",(e,t)=>{Eb.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(n,r,s)=>fI(e,n,r,s),e.options=t.options});function fR(e,t){return new Db({type:"union",options:e,...nt(t)})}const pR=ge("ZodDiscriminatedUnion",(e,t)=>{Db.init(e,t),MC.init(e,t)});function hR(e,t,n){return new pR({type:"union",options:t,discriminator:e,...nt(n)})}const mR=ge("ZodIntersection",(e,t)=>{LC.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(n,r,s)=>pI(e,n,r,s)});function gR(e,t){return new mR({type:"intersection",left:e,right:t})}const kR=ge("ZodTuple",(e,t)=>{Sd(),PC.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(n,r,s)=>hI(e,n,r,s)},{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 dm({type:"optional",innerType:n}))})}});function zb(e,t,n){const r=t instanceof jn,s=r?n:t,a=r?t:null;return new kR({type:"tuple",items:e,rest:a,...nt(s)})}const uh=ge("ZodEnum",(e,t)=>{DC.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(r,s,a)=>iI(e,r,s),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,s)=>{const a={};for(const l of r)if(n.has(l))a[l]=t.entries[l];else throw new Error(`Key ${l} not found in enum`);return new uh({...t,checks:[],...nt(s),entries:a})},e.exclude=(r,s)=>{const a={...t.entries};for(const l of r)if(n.has(l))delete a[l];else throw new Error(`Key ${l} not found in enum`);return new uh({...t,checks:[],...nt(s),entries:a})}});function qu(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new uh({type:"enum",entries:n,...nt(t)})}const yR=ge("ZodLiteral",(e,t)=>{zC.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(n,r,s)=>aI(e,n,r,s),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Jr(e,t){return new yR({type:"literal",values:Array.isArray(e)?e:[e],...nt(t)})}const wR=ge("ZodTransform",(e,t)=>{Sd(),FC.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(n,r,s)=>cI(e,n,r,s),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new lb(e.constructor.name);n.addIssue=a=>{if(typeof a=="string")n.issues.push(Fl(a,n.value,t));else{const l=a;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(Fl(l))}};const s=t.transform(n.value,n);return s instanceof Promise?s.then(a=>(n.value=a,n)):(n.value=s,n)}});function vR(e){return new wR({type:"transform",transform:e})}const dm=ge("ZodOptional",(e,t)=>{Sb.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(n,r,s)=>Mb(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function mw(e){return new dm({type:"optional",innerType:e})}const Fb=ge("ZodExactOptional",(e,t)=>{BC.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(n,r,s)=>Mb(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function bR(e){return new Fb({type:"optional",innerType:e})}const xR=ge("ZodNullable",(e,t)=>{UC.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(n,r,s)=>mI(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function gw(e){return new xR({type:"nullable",innerType:e})}const _R=ge("ZodDefault",(e,t)=>{HC.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(n,r,s)=>kI(e,n,r,s),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ER(e,t){return new _R({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():sb(t)}})}const SR=ge("ZodPrefault",(e,t)=>{WC.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(n,r,s)=>yI(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function NR(e,t){return new SR({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():sb(t)}})}const Bb=ge("ZodNonOptional",(e,t)=>{KC.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(n,r,s)=>gI(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function TR(e,t){return new Bb({type:"nonoptional",innerType:e,...nt(t)})}const jR=ge("ZodCatch",(e,t)=>{ZC.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(n,r,s)=>wI(e,n,r,s),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function CR(e,t){return new jR({type:"catch",innerType:e,catchValue:typeof t=="function"?t:UT(t)})}const AR=ge("ZodPipe",(e,t)=>{qC.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(n,r,s)=>vI(e,n,r,s),e.in=t.in,e.out=t.out});function kw(e,t){return new AR({type:"pipe",in:e,out:t})}const IR=ge("ZodReadonly",(e,t)=>{GC.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(n,r,s)=>bI(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function RR(e){return new IR({type:"readonly",innerType:e})}const Ub=ge("ZodCustom",(e,t)=>{VC.init(e,t),Ln.init(e,t),e._zod.processJSONSchema=(n,r,s)=>lI(e,n,r,s)});function OR(e,t={}){return VA(Ub,e,t)}function $R(e,t){return YA(e,t)}function MR(e,t={}){const n=new Ub({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...nt(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 LR=["off","tailscale","any"],PR={updates:!0,deploy:!0,remote:"any",agents:null,customAgents:!0,brandedListener:!0,planSignIn:!0};Er({updates:jo().optional(),deploy:jo().optional(),remote:qu(LR).optional(),agents:bi(dn()).optional(),customAgents:jo().optional(),brandedListener:jo().optional(),planSignIn:jo().optional()});const DR={...PR,source:null,problem:null};function zR(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 dh=85,Gu=5e6,FR=["image/png","image/jpeg","image/gif","image/webp"],yw=2576,Np=5*1024*1024,BR=1200,UR=10,HR=1e5,ww=100*1024*1024,WR="pasted-text.txt";function KR(e){return e.t==="term-data"||e.t==="term-snapshot"||e.t==="term-exit"}function ZR(e){return e.t==="file-read"||e.t==="file-written"||e.t==="file-blame"}const qR=80;function fm(e){var r;const t=e.split(`
|
|
71
|
+
`),n=((r=t.find(s=>s.trim().length>0))==null?void 0:r.trim())??"";return{chars:e.length,lines:t.length,preview:n.slice(0,qR)}}function GR(e){return e.length>=BR||e.split(`
|
|
72
|
+
`).length>=UR}function VR({startLine:e,endLine:t}){return e===t?`${e}`:`${e}-${t}`}function YR(e){return`${e.path.slice(e.path.lastIndexOf("/")+1)} (${VR(e)})`}const QR=/\u001B(?:\[[0-?]*[ -/]*[@-~]|\][^\u0007]*(?:\u0007|\u001B\\))/g;function XR(e){return e.replace(QR,"")}const Hb="Projects";function JR(e){for(const t of e){const n=t.codePointAt(0)??0;if(n<32||n===127)return!0}return!1}function Bl(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":JR(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 eO=/^(?:https?|ssh|git|file):\/\/\S+$/i,Wb=/^[\w.-]+@[\w.-]+:\S+$/;function tO(e){const t=e.trim();if(!eO.test(t)&&!Wb.test(t))return null;const n=nO(t);return n&&!Bl(n)?{url:t,name:n}:null}function nO(e){var s;const t=((s=e.split(/[?#]/)[0])==null?void 0:s.replace(/\/+$/,""))??"";return((Wb.test(t)?t.split(":")[1]??"":t).split("/").pop()??"").replace(/\.git$/i,"")}const rO=Er({component:dn().nullable(),file:dn().nullable(),line:vi().nullable(),callFile:dn().nullable().default(null),callLine:vi().nullable().default(null),tag:dn(),selector:dn()}),oO=Er({tag:dn().max(40),id:dn().max(200),classes:bi(dn().max(120)).max(16),text:dn().max(200),attrs:bi(zb([dn().max(40),dn().max(200)])).max(12)}),sO=zb([vi(),vi()]),iO=rO.extend({classes:dn(),text:dn(),html:dn(),route:dn(),element:oO}),aO=hR("type",[Er({type:Jr("loaded"),url:dn(),title:dn()}),Er({type:Jr("navigated"),url:dn(),title:dn().optional()}),Er({type:Jr("title"),title:dn()}),Er({type:Jr("links"),links:bi(Er({path:dn().max(2048),text:dn().max(120)})).max(200)}),Er({type:Jr("hmr")}),Er({type:Jr("page-error"),message:dn(),source:dn().optional(),line:vi().optional()}),iO.extend({type:Jr("picked"),verb:qu(["chat","code"]).default("chat"),site:qu(["call","source"]).default("source")}),Er({type:Jr("pick-cancel")}),Er({type:Jr("highlight-miss"),path:dn(),fileMatched:vi(),withSource:vi(),ranges:bi(sO).nullable()}),Er({type:Jr("drag-files")}),Er({type:Jr("drop-files"),files:bi(MR(File))}),Er({type:Jr("focus"),gesture:jo()}),Er({type:Jr("key"),key:dn(),code:dn().optional(),meta:jo(),ctrl:jo().optional(),shift:jo().optional(),alt:jo().optional(),up:jo().optional()})]);function lO(e){const t=aO.safeParse(e);return t.success?t.data:null}const Aa="shell",Kb="check",cO="ToolSearch",pm="AskUserQuestion",uO=/["“”]([^"“”]*)["“”]?|(\S+)/g;function Zb(e){const t=new Set;for(const n of e.matchAll(uO)){const r=(n[1]??n[2]??"").replace(/\s+/g," ").trim().toLowerCase();r&&t.add(r)}return[...t]}const dO="now",fO="http://preview.invalid",pO=200;function vw(e){const t=e==null?void 0:e.replace(/\s+/g," ").trim().slice(0,pO).trim();return t||void 0}function Nd(e){let t;try{t=new URL(e,fO)}catch{return null}if(t.pathname.startsWith("/__toyon"))return null;const n=bw(t.pathname)||"/",r=t.hash.startsWith("#/")?bw(t.hash.split("?")[0]??""):"";return r.length>1?`${n}${r}`:n}const bw=e=>e.replace(/\/+$/,""),hO={static:4,mixed:3.5,param:3,optional:2,"optional-static":2,splat:1},Vu=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function qb(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 s=/^\[([^\]=]+)(?:=[^\]]*)?\]$/.exec(e)??/^:([\w-]+)$/.exec(e)??/^\$([\w-]+)$/.exec(e);if(s)return{kind:"param",name:s[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 a=[];let l="",c=0;for(const h of e.matchAll(/\[([^\]=]+)(?:=[^\]]*)?\]|\{\$([\w-]+)\}/g)){const p=e.slice(c,h.index);p&&(a.push({text:p}),l+=Vu(p)),a.push({name:h[1]??h[2]??"param"}),l+="[^/]+?",c=(h.index??0)+h[0].length}const u=e.slice(c);if(u&&(a.push({text:u}),l+=Vu(u)),a.some(h=>"name"in h))return{kind:"mixed",pattern:l,parts:a}}return{kind:"static",text:e}}function mO(e){const t=e.split("/").filter(Boolean).map(qb);if(t.every(r=>r.kind==="static"))return null;let n="";for(const r of t)r.kind==="static"?n+=`/${Vu(r.text)}`:r.kind==="optional-static"?n+=`(?:/${Vu(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,s)=>r+hO[s.kind],0),statics:t.filter(r=>r.kind==="static").length}}function gO(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 Td(e){let t="";const n=[],r=s=>{n.push([t.length,t.length+s.length]),t+=s};for(const s of e.split("/").filter(Boolean).map(qb))if(t+="/",s.kind==="static"||s.kind==="optional-static")t+=s.text;else if(s.kind==="mixed")for(const a of s.parts)"name"in a?r(a.name):t+=a.text;else r(s.name);return t||(t="/"),{text:t,params:n,literal:n.length>0?t.slice(0,n[0][0]):t}}const Jl={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"}},Gb={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"}},kO={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"}},yO={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"}},wO={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"}},vO={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"}},bO={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"}},xO={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"}},_O={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"}},EO={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"}},SO={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"}},NO={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"}},TO={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"}},jO={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"}},CO={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"}},AO={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"}},IO={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"}},RO={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"}},OO={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"}},$O=[_O,EO,SO,NO,TO,jO,CO,AO,IO,RO,OO],$u=[Jl,Gb,kO,yO,wO,vO,bO,xO,...$O],MO={mode:"dark",light:Gb.id,dark:Jl.id},LO=["surface0","surface1","surface2","element0","element1","border0","border1","text0","text1","text2","red","orange","yellow","green","aqua","blue","purple","diffAdd","diffDel"];function PO(e){return`--${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function xw(e){const t=Qb(e);return t>.008856?116*t**(1/3)-16:903.3*t}function Vb(e,t){const n=xw(e)+t,r=Si(e);if(!r)return e;let s=0,a=2;for(let l=0;l<24;l++){const c=(s+a)/2,u=va(Math.min(255,r[0]*c),Math.min(255,r[1]*c),Math.min(255,r[2]*c));xw(u)<n?s=c:a=c}return va(Math.min(255,r[0]*s),Math.min(255,r[1]*s),Math.min(255,r[2]*s))}function DO(e){return Vb(e.colors.surface1,-4)}function zO(e){return Vb(e.colors.surface0,-4)}function _w(e){return GO(e,.55)}function FO(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 BO(e){const t={};for(const n of LO)t[PO(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(FO(e)))t[`--syntax-${n}`]=r;return t["--accent"]=hm(e),t["--fault"]=UO(e),t["--sunken"]=DO(e),t["--sunken-floor"]=zO(e),t["--scrim"]=qO(e.colors.surface0,.7),t["--shadow"]=e.kind==="dark"?"#00000066":"#0000002e",t["--diff-add-word"]=_w(e.colors.diffAdd),t["--diff-del-word"]=_w(e.colors.diffDel),t}function hm(e){return Yb(e.accent??"")??e.colors.orange}function UO(e){return hm(e)===Yb(e.colors.orange)?e.colors.red:e.colors.orange}function HO(e){return e==="system"||e==="daylight"}function mm(e,t){return e.mode==="system"?t.system?"dark":"light":e.mode==="daylight"?t.daylight?"dark":"light":e.mode}function jd(e,t,n){const r=mm(e,n);return t.find(s=>s.id===e[r])??$u.find(s=>s.kind===r)??Jl}function WO(e,t){if(e.pair){const l=t.find(c=>c.id===e.pair);if(l&&l.kind!==e.kind)return l}const n=e.kind==="dark"?"light":"dark",r=l=>l.toLowerCase().replace(/\b(dark|light)\b/g,"*").replace(/\s+/g," ").trim(),s=r(e.name);if(!s.includes("*"))return null;const a=e.id.startsWith("vscode:")?e.id.slice(0,e.id.lastIndexOf(":")+1):null;return t.find(l=>l.kind===n&&l.source===e.source&&(!a||l.id.startsWith(a))&&r(l.name)===s)??null}function KO(e){const t=[],n=new Set,r=s=>s.family??(s.name.replace(/\b(dark|light)\b/gi,"").replace(/\s+/g," ").trim()||s.name);for(const s of e){if(n.has(s.id))continue;const a=WO(s,e),l={name:r(s)};l[s.kind]=s,n.add(s.id),a&&(l[a.kind]=a,n.add(a.id)),t.push(l)}return t}function ZO(e,t){const n={...e};return t.dark&&(n.dark=t.dark.id),t.light&&(n.light=t.light.id),!HO(n.mode)&&!t[n.mode]&&(n.mode=t.dark?"dark":"light"),n}function Si(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(s=>s+s).join("")),n.length!==6&&n.length!==8)return null;const r=s=>parseInt(n.slice(s,s+2),16);return[r(0),r(2),r(4),n.length===8?r(6)/255:1]}function Yb(e){const t=Si(e);return t?va(t[0],t[1],t[2],t[3]):null}function va(e,t,n,r=1){const s=a=>Math.round(Math.max(0,Math.min(255,a))).toString(16).padStart(2,"0");return`#${s(e)}${s(t)}${s(n)}${r>=1?"":s(r*255)}`}function qO(e,t){const n=Si(e);return n?va(n[0],n[1],n[2],t):e}function GO(e,t){const n=Si(e);return n?va(n[0],n[1],n[2],Math.min(1,n[3]*t)):e}function m9(e,t){const n=Si(e),r=Si(t);if(!n||!r)return e;const s=n[3];return va(n[0]*s+r[0]*(1-s),n[1]*s+r[1]*(1-s),n[2]*s+r[2]*(1-s))}function Qb(e){const t=Si(e);if(!t)return 0;const n=r=>{const s=r/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4};return .2126*n(t[0])+.7152*n(t[1])+.0722*n(t[2])}function VO(e){return Qb(e)>.179?"#1d2021":"#fbf1c7"}function fh(e){if(e===null||e==="")return"the npm registry";try{return new URL(e).host}catch{return e}}function YO(e,t){const n=Ew(e),r=Ew(t);if(!n||!r)return!1;for(let s=0;s<3;s++){const a=n.nums[s]??0,l=r.nums[s]??0;if(a!==l)return a>l}return n.pre===r.pre?!1:n.pre===null?!0:r.pre===null?!1:n.pre>r.pre}function Ew(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 QO=[[/\.(png|jpe?g|gif|webp|avif|bmp|ico)$/i,"image"]];function XO(e){var t;return((t=QO.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const JO=[[/\.(md|markdown)$/i,"markdown"],[/\.html?$/i,"html"]];function Cd(e){var t;return((t=JO.find(([n])=>n.test(e)))==null?void 0:t[1])??null}var S=Xh();const e$=W0(S);var mu={},Tp={exports:{}},Fr={},jp={exports:{}},Cp={};/**
|
|
73
|
+
* @license React
|
|
74
|
+
* scheduler.production.min.js
|
|
75
|
+
*
|
|
76
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
77
|
+
*
|
|
78
|
+
* This source code is licensed under the MIT license found in the
|
|
79
|
+
* LICENSE file in the root directory of this source tree.
|
|
80
|
+
*/var Sw;function t$(){return Sw||(Sw=1,(function(e){function t(O,F){var ne=O.length;O.push(F);e:for(;0<ne;){var $=ne-1>>>1,q=O[$];if(0<s(q,F))O[$]=F,O[ne]=q,ne=$;else break e}}function n(O){return O.length===0?null:O[0]}function r(O){if(O.length===0)return null;var F=O[0],ne=O.pop();if(ne!==F){O[0]=ne;e:for(var $=0,q=O.length,ke=q>>>1;$<ke;){var se=2*($+1)-1,ve=O[se],Re=se+1,le=O[Re];if(0>s(ve,ne))Re<q&&0>s(le,ve)?(O[$]=le,O[Re]=ne,$=Re):(O[$]=ve,O[se]=ne,$=se);else if(Re<q&&0>s(le,ne))O[$]=le,O[Re]=ne,$=Re;else break e}}return F}function s(O,F){var ne=O.sortIndex-F.sortIndex;return ne!==0?ne:O.id-F.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var l=Date,c=l.now();e.unstable_now=function(){return l.now()-c}}var u=[],h=[],p=1,g=null,k=3,y=!1,v=!1,_=!1,E=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function N(O){for(var F=n(h);F!==null;){if(F.callback===null)r(h);else if(F.startTime<=O)r(h),F.sortIndex=F.expirationTime,t(u,F);else break;F=n(h)}}function M(O){if(_=!1,N(O),!v)if(n(u)!==null)v=!0,_e(J);else{var F=n(h);F!==null&&V(M,F.startTime-O)}}function J(O,F){v=!1,_&&(_=!1,C(j),j=-1),y=!0;var ne=k;try{for(N(F),g=n(u);g!==null&&(!(g.expirationTime>F)||O&&!H());){var $=g.callback;if(typeof $=="function"){g.callback=null,k=g.priorityLevel;var q=$(g.expirationTime<=F);F=e.unstable_now(),typeof q=="function"?g.callback=q:g===n(u)&&r(u),N(F)}else r(u);g=n(u)}if(g!==null)var ke=!0;else{var se=n(h);se!==null&&V(M,se.startTime-F),ke=!1}return ke}finally{g=null,k=ne,y=!1}}var W=!1,R=null,j=-1,A=5,D=-1;function H(){return!(e.unstable_now()-D<A)}function Y(){if(R!==null){var O=e.unstable_now();D=O;var F=!0;try{F=R(!0,O)}finally{F?ae():(W=!1,R=null)}}else W=!1}var ae;if(typeof x=="function")ae=function(){x(Y)};else if(typeof MessageChannel<"u"){var me=new MessageChannel,ye=me.port2;me.port1.onmessage=Y,ae=function(){ye.postMessage(null)}}else ae=function(){E(Y,0)};function _e(O){R=O,W||(W=!0,ae())}function V(O,F){j=E(function(){O(e.unstable_now())},F)}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(O){O.callback=null},e.unstable_continueExecution=function(){v||y||(v=!0,_e(J))},e.unstable_forceFrameRate=function(O){0>O||125<O?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):A=0<O?Math.floor(1e3/O):5},e.unstable_getCurrentPriorityLevel=function(){return k},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(O){switch(k){case 1:case 2:case 3:var F=3;break;default:F=k}var ne=k;k=F;try{return O()}finally{k=ne}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(O,F){switch(O){case 1:case 2:case 3:case 4:case 5:break;default:O=3}var ne=k;k=O;try{return F()}finally{k=ne}},e.unstable_scheduleCallback=function(O,F,ne){var $=e.unstable_now();switch(typeof ne=="object"&&ne!==null?(ne=ne.delay,ne=typeof ne=="number"&&0<ne?$+ne:$):ne=$,O){case 1:var q=-1;break;case 2:q=250;break;case 5:q=1073741823;break;case 4:q=1e4;break;default:q=5e3}return q=ne+q,O={id:p++,callback:F,priorityLevel:O,startTime:ne,expirationTime:q,sortIndex:-1},ne>$?(O.sortIndex=ne,t(h,O),n(u)===null&&O===n(h)&&(_?(C(j),j=-1):_=!0,V(M,ne-$))):(O.sortIndex=q,t(u,O),v||y||(v=!0,_e(J))),O},e.unstable_shouldYield=H,e.unstable_wrapCallback=function(O){var F=k;return function(){var ne=k;k=F;try{return O.apply(this,arguments)}finally{k=ne}}}})(Cp)),Cp}var Nw;function n$(){return Nw||(Nw=1,jp.exports=t$()),jp.exports}/**
|
|
81
|
+
* @license React
|
|
82
|
+
* react-dom.production.min.js
|
|
83
|
+
*
|
|
84
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
85
|
+
*
|
|
86
|
+
* This source code is licensed under the MIT license found in the
|
|
87
|
+
* LICENSE file in the root directory of this source tree.
|
|
88
|
+
*/var Tw;function r$(){if(Tw)return Fr;Tw=1;var e=Xh(),t=n$();function n(o){for(var i="https://reactjs.org/docs/error-decoder.html?invariant="+o,d=1;d<arguments.length;d++)i+="&args[]="+encodeURIComponent(arguments[d]);return"Minified React error #"+o+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,s={};function a(o,i){l(o,i),l(o+"Capture",i)}function l(o,i){for(s[o]=i,o=0;o<i.length;o++)r.add(i[o])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},g={};function k(o){return u.call(g,o)?!0:u.call(p,o)?!1:h.test(o)?g[o]=!0:(p[o]=!0,!1)}function y(o,i,d,m){if(d!==null&&d.type===0)return!1;switch(typeof i){case"function":case"symbol":return!0;case"boolean":return m?!1:d!==null?!d.acceptsBooleans:(o=o.toLowerCase().slice(0,5),o!=="data-"&&o!=="aria-");default:return!1}}function v(o,i,d,m){if(i===null||typeof i>"u"||y(o,i,d,m))return!0;if(m)return!1;if(d!==null)switch(d.type){case 3:return!i;case 4:return i===!1;case 5:return isNaN(i);case 6:return isNaN(i)||1>i}return!1}function _(o,i,d,m,w,b,T){this.acceptsBooleans=i===2||i===3||i===4,this.attributeName=m,this.attributeNamespace=w,this.mustUseProperty=d,this.propertyName=o,this.type=i,this.sanitizeURL=b,this.removeEmptyString=T}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(o){E[o]=new _(o,0,!1,o,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(o){var i=o[0];E[i]=new _(i,1,!1,o[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(o){E[o]=new _(o,2,!1,o.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(o){E[o]=new _(o,2,!1,o,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(o){E[o]=new _(o,3,!1,o.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(o){E[o]=new _(o,3,!0,o,null,!1,!1)}),["capture","download"].forEach(function(o){E[o]=new _(o,4,!1,o,null,!1,!1)}),["cols","rows","size","span"].forEach(function(o){E[o]=new _(o,6,!1,o,null,!1,!1)}),["rowSpan","start"].forEach(function(o){E[o]=new _(o,5,!1,o.toLowerCase(),null,!1,!1)});var C=/[\-:]([a-z])/g;function x(o){return o[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(o){var i=o.replace(C,x);E[i]=new _(i,1,!1,o,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(o){var i=o.replace(C,x);E[i]=new _(i,1,!1,o,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(o){var i=o.replace(C,x);E[i]=new _(i,1,!1,o,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(o){E[o]=new _(o,1,!1,o.toLowerCase(),null,!1,!1)}),E.xlinkHref=new _("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(o){E[o]=new _(o,1,!1,o.toLowerCase(),null,!0,!0)});function N(o,i,d,m){var w=E.hasOwnProperty(i)?E[i]:null;(w!==null?w.type!==0:m||!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=="N")&&(v(i,d,w,m)&&(d=null),m||w===null?k(i)&&(d===null?o.removeAttribute(i):o.setAttribute(i,""+d)):w.mustUseProperty?o[w.propertyName]=d===null?w.type===3?!1:"":d:(i=w.attributeName,m=w.attributeNamespace,d===null?o.removeAttribute(i):(w=w.type,d=w===3||w===4&&d===!0?"":""+d,m?o.setAttributeNS(m,i,d):o.setAttribute(i,d))))}var M=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,J=Symbol.for("react.element"),W=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),j=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),D=Symbol.for("react.provider"),H=Symbol.for("react.context"),Y=Symbol.for("react.forward_ref"),ae=Symbol.for("react.suspense"),me=Symbol.for("react.suspense_list"),ye=Symbol.for("react.memo"),_e=Symbol.for("react.lazy"),V=Symbol.for("react.offscreen"),O=Symbol.iterator;function F(o){return o===null||typeof o!="object"?null:(o=O&&o[O]||o["@@iterator"],typeof o=="function"?o:null)}var ne=Object.assign,$;function q(o){if($===void 0)try{throw Error()}catch(d){var i=d.stack.trim().match(/\n( *(at )?)/);$=i&&i[1]||""}return`
|
|
89
|
+
`+$+o}var ke=!1;function se(o,i){if(!o||ke)return"";ke=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(i)if(i=function(){throw Error()},Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(ce){var m=ce}Reflect.construct(o,[],i)}else{try{i.call()}catch(ce){m=ce}o.call(i.prototype)}else{try{throw Error()}catch(ce){m=ce}o()}}catch(ce){if(ce&&m&&typeof ce.stack=="string"){for(var w=ce.stack.split(`
|
|
90
|
+
`),b=m.stack.split(`
|
|
91
|
+
`),T=w.length-1,z=b.length-1;1<=T&&0<=z&&w[T]!==b[z];)z--;for(;1<=T&&0<=z;T--,z--)if(w[T]!==b[z]){if(T!==1||z!==1)do if(T--,z--,0>z||w[T]!==b[z]){var G=`
|
|
92
|
+
`+w[T].replace(" at new "," at ");return o.displayName&&G.includes("<anonymous>")&&(G=G.replace("<anonymous>",o.displayName)),G}while(1<=T&&0<=z);break}}}finally{ke=!1,Error.prepareStackTrace=d}return(o=o?o.displayName||o.name:"")?q(o):""}function ve(o){switch(o.tag){case 5:return q(o.type);case 16:return q("Lazy");case 13:return q("Suspense");case 19:return q("SuspenseList");case 0:case 2:case 15:return o=se(o.type,!1),o;case 11:return o=se(o.type.render,!1),o;case 1:return o=se(o.type,!0),o;default:return""}}function Re(o){if(o==null)return null;if(typeof o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case R:return"Fragment";case W:return"Portal";case A:return"Profiler";case j:return"StrictMode";case ae:return"Suspense";case me:return"SuspenseList"}if(typeof o=="object")switch(o.$$typeof){case H:return(o.displayName||"Context")+".Consumer";case D:return(o._context.displayName||"Context")+".Provider";case Y:var i=o.render;return o=o.displayName,o||(o=i.displayName||i.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case ye:return i=o.displayName||null,i!==null?i:Re(o.type)||"Memo";case _e:i=o._payload,o=o._init;try{return Re(o(i))}catch{}}return null}function le(o){var i=o.type;switch(o.tag){case 24:return"Cache";case 9:return(i.displayName||"Context")+".Consumer";case 10:return(i._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return o=i.render,o=o.displayName||o.name||"",i.displayName||(o!==""?"ForwardRef("+o+")":"ForwardRef");case 7:return"Fragment";case 5:return i;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Re(i);case 8:return i===j?"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 i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i}return null}function xe(o){switch(typeof o){case"boolean":case"number":case"string":case"undefined":return o;case"object":return o;default:return""}}function Le(o){var i=o.type;return(o=o.nodeName)&&o.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function oe(o){var i=Le(o)?"checked":"value",d=Object.getOwnPropertyDescriptor(o.constructor.prototype,i),m=""+o[i];if(!o.hasOwnProperty(i)&&typeof d<"u"&&typeof d.get=="function"&&typeof d.set=="function"){var w=d.get,b=d.set;return Object.defineProperty(o,i,{configurable:!0,get:function(){return w.call(this)},set:function(T){m=""+T,b.call(this,T)}}),Object.defineProperty(o,i,{enumerable:d.enumerable}),{getValue:function(){return m},setValue:function(T){m=""+T},stopTracking:function(){o._valueTracker=null,delete o[i]}}}}function Z(o){o._valueTracker||(o._valueTracker=oe(o))}function De(o){if(!o)return!1;var i=o._valueTracker;if(!i)return!0;var d=i.getValue(),m="";return o&&(m=Le(o)?o.checked?"true":"false":o.value),o=m,o!==d?(i.setValue(o),!0):!1}function Ve(o){if(o=o||(typeof document<"u"?document:void 0),typeof o>"u")return null;try{return o.activeElement||o.body}catch{return o.body}}function ze(o,i){var d=i.checked;return ne({},i,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:d??o._wrapperState.initialChecked})}function it(o,i){var d=i.defaultValue==null?"":i.defaultValue,m=i.checked!=null?i.checked:i.defaultChecked;d=xe(i.value!=null?i.value:d),o._wrapperState={initialChecked:m,initialValue:d,controlled:i.type==="checkbox"||i.type==="radio"?i.checked!=null:i.value!=null}}function Je(o,i){i=i.checked,i!=null&&N(o,"checked",i,!1)}function en(o,i){Je(o,i);var d=xe(i.value),m=i.type;if(d!=null)m==="number"?(d===0&&o.value===""||o.value!=d)&&(o.value=""+d):o.value!==""+d&&(o.value=""+d);else if(m==="submit"||m==="reset"){o.removeAttribute("value");return}i.hasOwnProperty("value")?tn(o,i.type,d):i.hasOwnProperty("defaultValue")&&tn(o,i.type,xe(i.defaultValue)),i.checked==null&&i.defaultChecked!=null&&(o.defaultChecked=!!i.defaultChecked)}function kt(o,i,d){if(i.hasOwnProperty("value")||i.hasOwnProperty("defaultValue")){var m=i.type;if(!(m!=="submit"&&m!=="reset"||i.value!==void 0&&i.value!==null))return;i=""+o._wrapperState.initialValue,d||i===o.value||(o.value=i),o.defaultValue=i}d=o.name,d!==""&&(o.name=""),o.defaultChecked=!!o._wrapperState.initialChecked,d!==""&&(o.name=d)}function tn(o,i,d){(i!=="number"||Ve(o.ownerDocument)!==o)&&(d==null?o.defaultValue=""+o._wrapperState.initialValue:o.defaultValue!==""+d&&(o.defaultValue=""+d))}var st=Array.isArray;function X(o,i,d,m){if(o=o.options,i){i={};for(var w=0;w<d.length;w++)i["$"+d[w]]=!0;for(d=0;d<o.length;d++)w=i.hasOwnProperty("$"+o[d].value),o[d].selected!==w&&(o[d].selected=w),w&&m&&(o[d].defaultSelected=!0)}else{for(d=""+xe(d),i=null,w=0;w<o.length;w++){if(o[w].value===d){o[w].selected=!0,m&&(o[w].defaultSelected=!0);return}i!==null||o[w].disabled||(i=o[w])}i!==null&&(i.selected=!0)}}function we(o,i){if(i.dangerouslySetInnerHTML!=null)throw Error(n(91));return ne({},i,{value:void 0,defaultValue:void 0,children:""+o._wrapperState.initialValue})}function Qe(o,i){var d=i.value;if(d==null){if(d=i.children,i=i.defaultValue,d!=null){if(i!=null)throw Error(n(92));if(st(d)){if(1<d.length)throw Error(n(93));d=d[0]}i=d}i==null&&(i=""),d=i}o._wrapperState={initialValue:xe(d)}}function he(o,i){var d=xe(i.value),m=xe(i.defaultValue);d!=null&&(d=""+d,d!==o.value&&(o.value=d),i.defaultValue==null&&o.defaultValue!==d&&(o.defaultValue=d)),m!=null&&(o.defaultValue=""+m)}function Oe(o){var i=o.textContent;i===o._wrapperState.initialValue&&i!==""&&i!==null&&(o.value=i)}function Mt(o){switch(o){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 an(o,i){return o==null||o==="http://www.w3.org/1999/xhtml"?Mt(i):o==="http://www.w3.org/2000/svg"&&i==="foreignObject"?"http://www.w3.org/1999/xhtml":o}var vt,Dn=(function(o){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(i,d,m,w){MSApp.execUnsafeLocalFunction(function(){return o(i,d,m,w)})}:o})(function(o,i){if(o.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in o)o.innerHTML=i;else{for(vt=vt||document.createElement("div"),vt.innerHTML="<svg>"+i.valueOf().toString()+"</svg>",i=vt.firstChild;o.firstChild;)o.removeChild(o.firstChild);for(;i.firstChild;)o.appendChild(i.firstChild)}});function Lt(o,i){if(i){var d=o.firstChild;if(d&&d===o.lastChild&&d.nodeType===3){d.nodeValue=i;return}}o.textContent=i}var ln={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},Tt=["Webkit","ms","Moz","O"];Object.keys(ln).forEach(function(o){Tt.forEach(function(i){i=i+o.charAt(0).toUpperCase()+o.substring(1),ln[i]=ln[o]})});function nn(o,i,d){return i==null||typeof i=="boolean"||i===""?"":d||typeof i!="number"||i===0||ln.hasOwnProperty(o)&&ln[o]?(""+i).trim():i+"px"}function Ut(o,i){o=o.style;for(var d in i)if(i.hasOwnProperty(d)){var m=d.indexOf("--")===0,w=nn(d,i[d],m);d==="float"&&(d="cssFloat"),m?o.setProperty(d,w):o[d]=w}}var We=ne({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 Gt(o,i){if(i){if(We[o]&&(i.children!=null||i.dangerouslySetInnerHTML!=null))throw Error(n(137,o));if(i.dangerouslySetInnerHTML!=null){if(i.children!=null)throw Error(n(60));if(typeof i.dangerouslySetInnerHTML!="object"||!("__html"in i.dangerouslySetInnerHTML))throw Error(n(61))}if(i.style!=null&&typeof i.style!="object")throw Error(n(62))}}function pn(o,i){if(o.indexOf("-")===-1)return typeof i.is=="string";switch(o){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 Kt=null;function xn(o){return o=o.target||o.srcElement||window,o.correspondingUseElement&&(o=o.correspondingUseElement),o.nodeType===3?o.parentNode:o}var hn=null,mn=null,gn=null;function kn(o){if(o=Ya(o)){if(typeof hn!="function")throw Error(n(280));var i=o.stateNode;i&&(i=Sc(i),hn(o.stateNode,o.type,i))}}function U(o){mn?gn?gn.push(o):gn=[o]:mn=o}function de(){if(mn){var o=mn,i=gn;if(gn=mn=null,kn(o),i)for(o=0;o<i.length;o++)kn(i[o])}}function Ae(o,i){return o(i)}function et(){}var ee=!1;function Se(o,i,d){if(ee)return o(i,d);ee=!0;try{return Ae(o,i,d)}finally{ee=!1,(mn!==null||gn!==null)&&(et(),de())}}function be(o,i){var d=o.stateNode;if(d===null)return null;var m=Sc(d);if(m===null)return null;d=m[i];e:switch(i){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(m=!m.disabled)||(o=o.type,m=!(o==="button"||o==="input"||o==="select"||o==="textarea")),o=!m;break e;default:o=!1}if(o)return null;if(d&&typeof d!="function")throw Error(n(231,i,typeof d));return d}var fe=!1;if(c)try{var Pe={};Object.defineProperty(Pe,"passive",{get:function(){fe=!0}}),window.addEventListener("test",Pe,Pe),window.removeEventListener("test",Pe,Pe)}catch{fe=!1}function rt(o,i,d,m,w,b,T,z,G){var ce=Array.prototype.slice.call(arguments,3);try{i.apply(d,ce)}catch(Te){this.onError(Te)}}var St=!1,bt=null,cn=!1,at=null,Dt={onError:function(o){St=!0,bt=o}};function un(o,i,d,m,w,b,T,z,G){St=!1,bt=null,rt.apply(Dt,arguments)}function zn(o,i,d,m,w,b,T,z,G){if(un.apply(this,arguments),St){if(St){var ce=bt;St=!1,bt=null}else throw Error(n(198));cn||(cn=!0,at=ce)}}function An(o){var i=o,d=o;if(o.alternate)for(;i.return;)i=i.return;else{o=i;do i=o,(i.flags&4098)!==0&&(d=i.return),o=i.return;while(o)}return i.tag===3?d:null}function lr(o){if(o.tag===13){var i=o.memoizedState;if(i===null&&(o=o.alternate,o!==null&&(i=o.memoizedState)),i!==null)return i.dehydrated}return null}function Rt(o){if(An(o)!==o)throw Error(n(188))}function cr(o){var i=o.alternate;if(!i){if(i=An(o),i===null)throw Error(n(188));return i!==o?null:o}for(var d=o,m=i;;){var w=d.return;if(w===null)break;var b=w.alternate;if(b===null){if(m=w.return,m!==null){d=m;continue}break}if(w.child===b.child){for(b=w.child;b;){if(b===d)return Rt(w),o;if(b===m)return Rt(w),i;b=b.sibling}throw Error(n(188))}if(d.return!==m.return)d=w,m=b;else{for(var T=!1,z=w.child;z;){if(z===d){T=!0,d=w,m=b;break}if(z===m){T=!0,m=w,d=b;break}z=z.sibling}if(!T){for(z=b.child;z;){if(z===d){T=!0,d=b,m=w;break}if(z===m){T=!0,m=b,d=w;break}z=z.sibling}if(!T)throw Error(n(189))}}if(d.alternate!==m)throw Error(n(190))}if(d.tag!==3)throw Error(n(188));return d.stateNode.current===d?o:i}function wn(o){return o=cr(o),o!==null?Xn(o):null}function Xn(o){if(o.tag===5||o.tag===6)return o;for(o=o.child;o!==null;){var i=Xn(o);if(i!==null)return i;o=o.sibling}return null}var Fn=t.unstable_scheduleCallback,In=t.unstable_cancelCallback,oo=t.unstable_shouldYield,qr=t.unstable_requestPaint,Vt=t.unstable_now,Go=t.unstable_getCurrentPriorityLevel,so=t.unstable_ImmediatePriority,dt=t.unstable_UserBlockingPriority,Zn=t.unstable_NormalPriority,je=t.unstable_LowPriority,Ue=t.unstable_IdlePriority,yt=null,ft=null;function rn(o){if(ft&&typeof ft.onCommitFiberRoot=="function")try{ft.onCommitFiberRoot(yt,o,void 0,(o.current.flags&128)===128)}catch{}}var Qt=Math.clz32?Math.clz32:Fe,B=Math.log,ue=Math.LN2;function Fe(o){return o>>>=0,o===0?32:31-(B(o)/ue|0)|0}var tt=64,pt=4194304;function jt(o){switch(o&-o){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 o&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return o&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return o}}function vn(o,i){var d=o.pendingLanes;if(d===0)return 0;var m=0,w=o.suspendedLanes,b=o.pingedLanes,T=d&268435455;if(T!==0){var z=T&~w;z!==0?m=jt(z):(b&=T,b!==0&&(m=jt(b)))}else T=d&~w,T!==0?m=jt(T):b!==0&&(m=jt(b));if(m===0)return 0;if(i!==0&&i!==m&&(i&w)===0&&(w=m&-m,b=i&-i,w>=b||w===16&&(b&4194240)!==0))return i;if((m&4)!==0&&(m|=d&16),i=o.entangledLanes,i!==0)for(o=o.entanglements,i&=m;0<i;)d=31-Qt(i),w=1<<d,m|=o[d],i&=~w;return m}function qn(o,i){switch(o){case 1:case 2:case 4:return i+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 i+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Gr(o,i){for(var d=o.suspendedLanes,m=o.pingedLanes,w=o.expirationTimes,b=o.pendingLanes;0<b;){var T=31-Qt(b),z=1<<T,G=w[T];G===-1?((z&d)===0||(z&m)!==0)&&(w[T]=qn(z,i)):G<=i&&(o.expiredLanes|=z),b&=~z}}function Hn(o){return o=o.pendingLanes&-1073741825,o!==0?o:o&1073741824?1073741824:0}function ps(){var o=tt;return tt<<=1,(tt&4194240)===0&&(tt=64),o}function Vr(o){for(var i=[],d=0;31>d;d++)i.push(o);return i}function Tr(o,i,d){o.pendingLanes|=i,i!==536870912&&(o.suspendedLanes=0,o.pingedLanes=0),o=o.eventTimes,i=31-Qt(i),o[i]=d}function Jn(o,i){var d=o.pendingLanes&~i;o.pendingLanes=i,o.suspendedLanes=0,o.pingedLanes=0,o.expiredLanes&=i,o.mutableReadLanes&=i,o.entangledLanes&=i,i=o.entanglements;var m=o.eventTimes;for(o=o.expirationTimes;0<d;){var w=31-Qt(d),b=1<<w;i[w]=0,m[w]=-1,o[w]=-1,d&=~b}}function $r(o,i){var d=o.entangledLanes|=i;for(o=o.entanglements;d;){var m=31-Qt(d),w=1<<m;w&i|o[m]&i&&(o[m]|=i),d&=~w}}var Ot=0;function lt(o){return o&=-o,1<o?4<o?(o&268435455)!==0?16:536870912:4:1}var Vo,yn,Ht,jr,yr,Ne=!1,I=[],L=null,te=null,pe=null,Ce=new Map,$e=new Map,mt=[],Xt="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 Nn(o,i){switch(o){case"focusin":case"focusout":L=null;break;case"dragenter":case"dragleave":te=null;break;case"mouseover":case"mouseout":pe=null;break;case"pointerover":case"pointerout":Ce.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":$e.delete(i.pointerId)}}function _n(o,i,d,m,w,b){return o===null||o.nativeEvent!==b?(o={blockedOn:i,domEventName:d,eventSystemFlags:m,nativeEvent:b,targetContainers:[w]},i!==null&&(i=Ya(i),i!==null&&yn(i)),o):(o.eventSystemFlags|=m,i=o.targetContainers,w!==null&&i.indexOf(w)===-1&&i.push(w),o)}function Mo(o,i,d,m,w){switch(i){case"focusin":return L=_n(L,o,i,d,m,w),!0;case"dragenter":return te=_n(te,o,i,d,m,w),!0;case"mouseover":return pe=_n(pe,o,i,d,m,w),!0;case"pointerover":var b=w.pointerId;return Ce.set(b,_n(Ce.get(b)||null,o,i,d,m,w)),!0;case"gotpointercapture":return b=w.pointerId,$e.set(b,_n($e.get(b)||null,o,i,d,m,w)),!0}return!1}function Wn(o){var i=ti(o.target);if(i!==null){var d=An(i);if(d!==null){if(i=d.tag,i===13){if(i=lr(d),i!==null){o.blockedOn=i,yr(o.priority,function(){Ht(d)});return}}else if(i===3&&d.stateNode.current.memoizedState.isDehydrated){o.blockedOn=d.tag===3?d.stateNode.containerInfo:null;return}}}o.blockedOn=null}function hs(o){if(o.blockedOn!==null)return!1;for(var i=o.targetContainers;0<i.length;){var d=Mi(o.domEventName,o.eventSystemFlags,i[0],o.nativeEvent);if(d===null){d=o.nativeEvent;var m=new d.constructor(d.type,d);Kt=m,d.target.dispatchEvent(m),Kt=null}else return i=Ya(d),i!==null&&yn(i),o.blockedOn=d,!1;i.shift()}return!0}function Ri(o,i,d){hs(o)&&d.delete(i)}function cc(){Ne=!1,L!==null&&hs(L)&&(L=null),te!==null&&hs(te)&&(te=null),pe!==null&&hs(pe)&&(pe=null),Ce.forEach(Ri),$e.forEach(Ri)}function Oi(o,i){o.blockedOn===i&&(o.blockedOn=null,Ne||(Ne=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,cc)))}function ms(o){function i(w){return Oi(w,o)}if(0<I.length){Oi(I[0],o);for(var d=1;d<I.length;d++){var m=I[d];m.blockedOn===o&&(m.blockedOn=null)}}for(L!==null&&Oi(L,o),te!==null&&Oi(te,o),pe!==null&&Oi(pe,o),Ce.forEach(i),$e.forEach(i),d=0;d<mt.length;d++)m=mt[d],m.blockedOn===o&&(m.blockedOn=null);for(;0<mt.length&&(d=mt[0],d.blockedOn===null);)Wn(d),d.blockedOn===null&&mt.shift()}var yo=M.ReactCurrentBatchConfig,Ys=!0;function uc(o,i,d,m){var w=Ot,b=yo.transition;yo.transition=null;try{Ot=1,ur(o,i,d,m)}finally{Ot=w,yo.transition=b}}function dc(o,i,d,m){var w=Ot,b=yo.transition;yo.transition=null;try{Ot=4,ur(o,i,d,m)}finally{Ot=w,yo.transition=b}}function ur(o,i,d,m){if(Ys){var w=Mi(o,i,d,m);if(w===null)af(o,i,m,$i,d),Nn(o,m);else if(Mo(w,o,i,d,m))m.stopPropagation();else if(Nn(o,m),i&4&&-1<Xt.indexOf(o)){for(;w!==null;){var b=Ya(w);if(b!==null&&Vo(b),b=Mi(o,i,d,m),b===null&&af(o,i,m,$i,d),b===w)break;w=b}w!==null&&m.stopPropagation()}else af(o,i,m,null,d)}}var $i=null;function Mi(o,i,d,m){if($i=null,o=xn(m),o=ti(o),o!==null)if(i=An(o),i===null)o=null;else if(d=i.tag,d===13){if(o=lr(i),o!==null)return o;o=null}else if(d===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;o=null}else i!==o&&(o=null);return $i=o,null}function Da(o){switch(o){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(Go()){case so:return 1;case dt:return 4;case Zn:case je:return 16;case Ue:return 536870912;default:return 16}default:return 16}}var wo=null,za=null,gs=null;function fc(){if(gs)return gs;var o,i=za,d=i.length,m,w="value"in wo?wo.value:wo.textContent,b=w.length;for(o=0;o<d&&i[o]===w[o];o++);var T=d-o;for(m=1;m<=T&&i[d-m]===w[b-m];m++);return gs=w.slice(o,1<m?1-m:void 0)}function Qs(o){var i=o.keyCode;return"charCode"in o?(o=o.charCode,o===0&&i===13&&(o=13)):o=i,o===10&&(o=13),32<=o||o===13?o:0}function Xs(){return!0}function pc(){return!1}function Cr(o){function i(d,m,w,b,T){this._reactName=d,this._targetInst=w,this.type=m,this.nativeEvent=b,this.target=T,this.currentTarget=null;for(var z in o)o.hasOwnProperty(z)&&(d=o[z],this[z]=d?d(b):b[z]);return this.isDefaultPrevented=(b.defaultPrevented!=null?b.defaultPrevented:b.returnValue===!1)?Xs:pc,this.isPropagationStopped=pc,this}return ne(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var d=this.nativeEvent;d&&(d.preventDefault?d.preventDefault():typeof d.returnValue!="unknown"&&(d.returnValue=!1),this.isDefaultPrevented=Xs)},stopPropagation:function(){var d=this.nativeEvent;d&&(d.stopPropagation?d.stopPropagation():typeof d.cancelBubble!="unknown"&&(d.cancelBubble=!0),this.isPropagationStopped=Xs)},persist:function(){},isPersistent:Xs}),i}var ks={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(o){return o.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Js=Cr(ks),ys=ne({},ks,{view:0,detail:0}),hc=Cr(ys),Li,Pi,ws,ei=ne({},ys,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Vd,button:0,buttons:0,relatedTarget:function(o){return o.relatedTarget===void 0?o.fromElement===o.srcElement?o.toElement:o.fromElement:o.relatedTarget},movementX:function(o){return"movementX"in o?o.movementX:(o!==ws&&(ws&&o.type==="mousemove"?(Li=o.screenX-ws.screenX,Pi=o.screenY-ws.screenY):Pi=Li=0,ws=o),Li)},movementY:function(o){return"movementY"in o?o.movementY:Pi}}),Fa=Cr(ei),mc=ne({},ei,{dataTransfer:0}),gc=Cr(mc),K=ne({},ys,{relatedTarget:0}),He=Cr(K),Ft=ne({},ks,{animationName:0,elapsedTime:0,pseudoElement:0}),Rn=Cr(Ft),er=ne({},ks,{clipboardData:function(o){return"clipboardData"in o?o.clipboardData:window.clipboardData}}),vs=Cr(er),Gd=ne({},ks,{data:0}),kc=Cr(Gd),nS={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},rS={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"},oS={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function sS(o){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(o):(o=oS[o])?!!i[o]:!1}function Vd(){return sS}var iS=ne({},ys,{key:function(o){if(o.key){var i=nS[o.key]||o.key;if(i!=="Unidentified")return i}return o.type==="keypress"?(o=Qs(o),o===13?"Enter":String.fromCharCode(o)):o.type==="keydown"||o.type==="keyup"?rS[o.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Vd,charCode:function(o){return o.type==="keypress"?Qs(o):0},keyCode:function(o){return o.type==="keydown"||o.type==="keyup"?o.keyCode:0},which:function(o){return o.type==="keypress"?Qs(o):o.type==="keydown"||o.type==="keyup"?o.keyCode:0}}),aS=Cr(iS),lS=ne({},ei,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),vg=Cr(lS),cS=ne({},ys,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Vd}),uS=Cr(cS),dS=ne({},ks,{propertyName:0,elapsedTime:0,pseudoElement:0}),fS=Cr(dS),pS=ne({},ei,{deltaX:function(o){return"deltaX"in o?o.deltaX:"wheelDeltaX"in o?-o.wheelDeltaX:0},deltaY:function(o){return"deltaY"in o?o.deltaY:"wheelDeltaY"in o?-o.wheelDeltaY:"wheelDelta"in o?-o.wheelDelta:0},deltaZ:0,deltaMode:0}),hS=Cr(pS),mS=[9,13,27,32],Yd=c&&"CompositionEvent"in window,Ba=null;c&&"documentMode"in document&&(Ba=document.documentMode);var gS=c&&"TextEvent"in window&&!Ba,bg=c&&(!Yd||Ba&&8<Ba&&11>=Ba),xg=" ",_g=!1;function Eg(o,i){switch(o){case"keyup":return mS.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Sg(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var Di=!1;function kS(o,i){switch(o){case"compositionend":return Sg(i);case"keypress":return i.which!==32?null:(_g=!0,xg);case"textInput":return o=i.data,o===xg&&_g?null:o;default:return null}}function yS(o,i){if(Di)return o==="compositionend"||!Yd&&Eg(o,i)?(o=fc(),gs=za=wo=null,Di=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1<i.char.length)return i.char;if(i.which)return String.fromCharCode(i.which)}return null;case"compositionend":return bg&&i.locale!=="ko"?null:i.data;default:return null}}var wS={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 Ng(o){var i=o&&o.nodeName&&o.nodeName.toLowerCase();return i==="input"?!!wS[o.type]:i==="textarea"}function Tg(o,i,d,m){U(m),i=xc(i,"onChange"),0<i.length&&(d=new Js("onChange","change",null,d,m),o.push({event:d,listeners:i}))}var Ua=null,Ha=null;function vS(o){Kg(o,0)}function yc(o){var i=Hi(o);if(De(i))return o}function bS(o,i){if(o==="change")return i}var jg=!1;if(c){var Qd;if(c){var Xd="oninput"in document;if(!Xd){var Cg=document.createElement("div");Cg.setAttribute("oninput","return;"),Xd=typeof Cg.oninput=="function"}Qd=Xd}else Qd=!1;jg=Qd&&(!document.documentMode||9<document.documentMode)}function Ag(){Ua&&(Ua.detachEvent("onpropertychange",Ig),Ha=Ua=null)}function Ig(o){if(o.propertyName==="value"&&yc(Ha)){var i=[];Tg(i,Ha,o,xn(o)),Se(vS,i)}}function xS(o,i,d){o==="focusin"?(Ag(),Ua=i,Ha=d,Ua.attachEvent("onpropertychange",Ig)):o==="focusout"&&Ag()}function _S(o){if(o==="selectionchange"||o==="keyup"||o==="keydown")return yc(Ha)}function ES(o,i){if(o==="click")return yc(i)}function SS(o,i){if(o==="input"||o==="change")return yc(i)}function NS(o,i){return o===i&&(o!==0||1/o===1/i)||o!==o&&i!==i}var vo=typeof Object.is=="function"?Object.is:NS;function Wa(o,i){if(vo(o,i))return!0;if(typeof o!="object"||o===null||typeof i!="object"||i===null)return!1;var d=Object.keys(o),m=Object.keys(i);if(d.length!==m.length)return!1;for(m=0;m<d.length;m++){var w=d[m];if(!u.call(i,w)||!vo(o[w],i[w]))return!1}return!0}function Rg(o){for(;o&&o.firstChild;)o=o.firstChild;return o}function Og(o,i){var d=Rg(o);o=0;for(var m;d;){if(d.nodeType===3){if(m=o+d.textContent.length,o<=i&&m>=i)return{node:d,offset:i-o};o=m}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=Rg(d)}}function $g(o,i){return o&&i?o===i?!0:o&&o.nodeType===3?!1:i&&i.nodeType===3?$g(o,i.parentNode):"contains"in o?o.contains(i):o.compareDocumentPosition?!!(o.compareDocumentPosition(i)&16):!1:!1}function Mg(){for(var o=window,i=Ve();i instanceof o.HTMLIFrameElement;){try{var d=typeof i.contentWindow.location.href=="string"}catch{d=!1}if(d)o=i.contentWindow;else break;i=Ve(o.document)}return i}function Jd(o){var i=o&&o.nodeName&&o.nodeName.toLowerCase();return i&&(i==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||i==="textarea"||o.contentEditable==="true")}function TS(o){var i=Mg(),d=o.focusedElem,m=o.selectionRange;if(i!==d&&d&&d.ownerDocument&&$g(d.ownerDocument.documentElement,d)){if(m!==null&&Jd(d)){if(i=m.start,o=m.end,o===void 0&&(o=i),"selectionStart"in d)d.selectionStart=i,d.selectionEnd=Math.min(o,d.value.length);else if(o=(i=d.ownerDocument||document)&&i.defaultView||window,o.getSelection){o=o.getSelection();var w=d.textContent.length,b=Math.min(m.start,w);m=m.end===void 0?b:Math.min(m.end,w),!o.extend&&b>m&&(w=m,m=b,b=w),w=Og(d,b);var T=Og(d,m);w&&T&&(o.rangeCount!==1||o.anchorNode!==w.node||o.anchorOffset!==w.offset||o.focusNode!==T.node||o.focusOffset!==T.offset)&&(i=i.createRange(),i.setStart(w.node,w.offset),o.removeAllRanges(),b>m?(o.addRange(i),o.extend(T.node,T.offset)):(i.setEnd(T.node,T.offset),o.addRange(i)))}}for(i=[],o=d;o=o.parentNode;)o.nodeType===1&&i.push({element:o,left:o.scrollLeft,top:o.scrollTop});for(typeof d.focus=="function"&&d.focus(),d=0;d<i.length;d++)o=i[d],o.element.scrollLeft=o.left,o.element.scrollTop=o.top}}var jS=c&&"documentMode"in document&&11>=document.documentMode,zi=null,ef=null,Ka=null,tf=!1;function Lg(o,i,d){var m=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;tf||zi==null||zi!==Ve(m)||(m=zi,"selectionStart"in m&&Jd(m)?m={start:m.selectionStart,end:m.selectionEnd}:(m=(m.ownerDocument&&m.ownerDocument.defaultView||window).getSelection(),m={anchorNode:m.anchorNode,anchorOffset:m.anchorOffset,focusNode:m.focusNode,focusOffset:m.focusOffset}),Ka&&Wa(Ka,m)||(Ka=m,m=xc(ef,"onSelect"),0<m.length&&(i=new Js("onSelect","select",null,i,d),o.push({event:i,listeners:m}),i.target=zi)))}function wc(o,i){var d={};return d[o.toLowerCase()]=i.toLowerCase(),d["Webkit"+o]="webkit"+i,d["Moz"+o]="moz"+i,d}var Fi={animationend:wc("Animation","AnimationEnd"),animationiteration:wc("Animation","AnimationIteration"),animationstart:wc("Animation","AnimationStart"),transitionend:wc("Transition","TransitionEnd")},nf={},Pg={};c&&(Pg=document.createElement("div").style,"AnimationEvent"in window||(delete Fi.animationend.animation,delete Fi.animationiteration.animation,delete Fi.animationstart.animation),"TransitionEvent"in window||delete Fi.transitionend.transition);function vc(o){if(nf[o])return nf[o];if(!Fi[o])return o;var i=Fi[o],d;for(d in i)if(i.hasOwnProperty(d)&&d in Pg)return nf[o]=i[d];return o}var Dg=vc("animationend"),zg=vc("animationiteration"),Fg=vc("animationstart"),Bg=vc("transitionend"),Ug=new Map,Hg="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 bs(o,i){Ug.set(o,i),a(i,[o])}for(var rf=0;rf<Hg.length;rf++){var of=Hg[rf],CS=of.toLowerCase(),AS=of[0].toUpperCase()+of.slice(1);bs(CS,"on"+AS)}bs(Dg,"onAnimationEnd"),bs(zg,"onAnimationIteration"),bs(Fg,"onAnimationStart"),bs("dblclick","onDoubleClick"),bs("focusin","onFocus"),bs("focusout","onBlur"),bs(Bg,"onTransitionEnd"),l("onMouseEnter",["mouseout","mouseover"]),l("onMouseLeave",["mouseout","mouseover"]),l("onPointerEnter",["pointerout","pointerover"]),l("onPointerLeave",["pointerout","pointerover"]),a("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),a("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),a("onBeforeInput",["compositionend","keypress","textInput","paste"]),a("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Za="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(" "),IS=new Set("cancel close invalid load scroll toggle".split(" ").concat(Za));function Wg(o,i,d){var m=o.type||"unknown-event";o.currentTarget=d,zn(m,i,void 0,o),o.currentTarget=null}function Kg(o,i){i=(i&4)!==0;for(var d=0;d<o.length;d++){var m=o[d],w=m.event;m=m.listeners;e:{var b=void 0;if(i)for(var T=m.length-1;0<=T;T--){var z=m[T],G=z.instance,ce=z.currentTarget;if(z=z.listener,G!==b&&w.isPropagationStopped())break e;Wg(w,z,ce),b=G}else for(T=0;T<m.length;T++){if(z=m[T],G=z.instance,ce=z.currentTarget,z=z.listener,G!==b&&w.isPropagationStopped())break e;Wg(w,z,ce),b=G}}}if(cn)throw o=at,cn=!1,at=null,o}function En(o,i){var d=i[pf];d===void 0&&(d=i[pf]=new Set);var m=o+"__bubble";d.has(m)||(Zg(i,o,2,!1),d.add(m))}function sf(o,i,d){var m=0;i&&(m|=4),Zg(d,o,m,i)}var bc="_reactListening"+Math.random().toString(36).slice(2);function qa(o){if(!o[bc]){o[bc]=!0,r.forEach(function(d){d!=="selectionchange"&&(IS.has(d)||sf(d,!1,o),sf(d,!0,o))});var i=o.nodeType===9?o:o.ownerDocument;i===null||i[bc]||(i[bc]=!0,sf("selectionchange",!1,i))}}function Zg(o,i,d,m){switch(Da(i)){case 1:var w=uc;break;case 4:w=dc;break;default:w=ur}d=w.bind(null,i,d,o),w=void 0,!fe||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(w=!0),m?w!==void 0?o.addEventListener(i,d,{capture:!0,passive:w}):o.addEventListener(i,d,!0):w!==void 0?o.addEventListener(i,d,{passive:w}):o.addEventListener(i,d,!1)}function af(o,i,d,m,w){var b=m;if((i&1)===0&&(i&2)===0&&m!==null)e:for(;;){if(m===null)return;var T=m.tag;if(T===3||T===4){var z=m.stateNode.containerInfo;if(z===w||z.nodeType===8&&z.parentNode===w)break;if(T===4)for(T=m.return;T!==null;){var G=T.tag;if((G===3||G===4)&&(G=T.stateNode.containerInfo,G===w||G.nodeType===8&&G.parentNode===w))return;T=T.return}for(;z!==null;){if(T=ti(z),T===null)return;if(G=T.tag,G===5||G===6){m=b=T;continue e}z=z.parentNode}}m=m.return}Se(function(){var ce=b,Te=xn(d),Ie=[];e:{var Ee=Ug.get(o);if(Ee!==void 0){var Ze=Js,Ge=o;switch(o){case"keypress":if(Qs(d)===0)break e;case"keydown":case"keyup":Ze=aS;break;case"focusin":Ge="focus",Ze=He;break;case"focusout":Ge="blur",Ze=He;break;case"beforeblur":case"afterblur":Ze=He;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":Ze=Fa;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ze=gc;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ze=uS;break;case Dg:case zg:case Fg:Ze=Rn;break;case Bg:Ze=fS;break;case"scroll":Ze=hc;break;case"wheel":Ze=hS;break;case"copy":case"cut":case"paste":Ze=vs;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ze=vg}var Ye=(i&4)!==0,Kn=!Ye&&o==="scroll",re=Ye?Ee!==null?Ee+"Capture":null:Ee;Ye=[];for(var Q=ce,ie;Q!==null;){ie=Q;var Me=ie.stateNode;if(ie.tag===5&&Me!==null&&(ie=Me,re!==null&&(Me=be(Q,re),Me!=null&&Ye.push(Ga(Q,Me,ie)))),Kn)break;Q=Q.return}0<Ye.length&&(Ee=new Ze(Ee,Ge,null,d,Te),Ie.push({event:Ee,listeners:Ye}))}}if((i&7)===0){e:{if(Ee=o==="mouseover"||o==="pointerover",Ze=o==="mouseout"||o==="pointerout",Ee&&d!==Kt&&(Ge=d.relatedTarget||d.fromElement)&&(ti(Ge)||Ge[Yo]))break e;if((Ze||Ee)&&(Ee=Te.window===Te?Te:(Ee=Te.ownerDocument)?Ee.defaultView||Ee.parentWindow:window,Ze?(Ge=d.relatedTarget||d.toElement,Ze=ce,Ge=Ge?ti(Ge):null,Ge!==null&&(Kn=An(Ge),Ge!==Kn||Ge.tag!==5&&Ge.tag!==6)&&(Ge=null)):(Ze=null,Ge=ce),Ze!==Ge)){if(Ye=Fa,Me="onMouseLeave",re="onMouseEnter",Q="mouse",(o==="pointerout"||o==="pointerover")&&(Ye=vg,Me="onPointerLeave",re="onPointerEnter",Q="pointer"),Kn=Ze==null?Ee:Hi(Ze),ie=Ge==null?Ee:Hi(Ge),Ee=new Ye(Me,Q+"leave",Ze,d,Te),Ee.target=Kn,Ee.relatedTarget=ie,Me=null,ti(Te)===ce&&(Ye=new Ye(re,Q+"enter",Ge,d,Te),Ye.target=ie,Ye.relatedTarget=Kn,Me=Ye),Kn=Me,Ze&&Ge)t:{for(Ye=Ze,re=Ge,Q=0,ie=Ye;ie;ie=Bi(ie))Q++;for(ie=0,Me=re;Me;Me=Bi(Me))ie++;for(;0<Q-ie;)Ye=Bi(Ye),Q--;for(;0<ie-Q;)re=Bi(re),ie--;for(;Q--;){if(Ye===re||re!==null&&Ye===re.alternate)break t;Ye=Bi(Ye),re=Bi(re)}Ye=null}else Ye=null;Ze!==null&&qg(Ie,Ee,Ze,Ye,!1),Ge!==null&&Kn!==null&&qg(Ie,Kn,Ge,Ye,!0)}}e:{if(Ee=ce?Hi(ce):window,Ze=Ee.nodeName&&Ee.nodeName.toLowerCase(),Ze==="select"||Ze==="input"&&Ee.type==="file")var Xe=bS;else if(Ng(Ee))if(jg)Xe=SS;else{Xe=_S;var ct=xS}else(Ze=Ee.nodeName)&&Ze.toLowerCase()==="input"&&(Ee.type==="checkbox"||Ee.type==="radio")&&(Xe=ES);if(Xe&&(Xe=Xe(o,ce))){Tg(Ie,Xe,d,Te);break e}ct&&ct(o,Ee,ce),o==="focusout"&&(ct=Ee._wrapperState)&&ct.controlled&&Ee.type==="number"&&tn(Ee,"number",Ee.value)}switch(ct=ce?Hi(ce):window,o){case"focusin":(Ng(ct)||ct.contentEditable==="true")&&(zi=ct,ef=ce,Ka=null);break;case"focusout":Ka=ef=zi=null;break;case"mousedown":tf=!0;break;case"contextmenu":case"mouseup":case"dragend":tf=!1,Lg(Ie,d,Te);break;case"selectionchange":if(jS)break;case"keydown":case"keyup":Lg(Ie,d,Te)}var ut;if(Yd)e:{switch(o){case"compositionstart":var wt="onCompositionStart";break e;case"compositionend":wt="onCompositionEnd";break e;case"compositionupdate":wt="onCompositionUpdate";break e}wt=void 0}else Di?Eg(o,d)&&(wt="onCompositionEnd"):o==="keydown"&&d.keyCode===229&&(wt="onCompositionStart");wt&&(bg&&d.locale!=="ko"&&(Di||wt!=="onCompositionStart"?wt==="onCompositionEnd"&&Di&&(ut=fc()):(wo=Te,za="value"in wo?wo.value:wo.textContent,Di=!0)),ct=xc(ce,wt),0<ct.length&&(wt=new kc(wt,o,null,d,Te),Ie.push({event:wt,listeners:ct}),ut?wt.data=ut:(ut=Sg(d),ut!==null&&(wt.data=ut)))),(ut=gS?kS(o,d):yS(o,d))&&(ce=xc(ce,"onBeforeInput"),0<ce.length&&(Te=new kc("onBeforeInput","beforeinput",null,d,Te),Ie.push({event:Te,listeners:ce}),Te.data=ut))}Kg(Ie,i)})}function Ga(o,i,d){return{instance:o,listener:i,currentTarget:d}}function xc(o,i){for(var d=i+"Capture",m=[];o!==null;){var w=o,b=w.stateNode;w.tag===5&&b!==null&&(w=b,b=be(o,d),b!=null&&m.unshift(Ga(o,b,w)),b=be(o,i),b!=null&&m.push(Ga(o,b,w))),o=o.return}return m}function Bi(o){if(o===null)return null;do o=o.return;while(o&&o.tag!==5);return o||null}function qg(o,i,d,m,w){for(var b=i._reactName,T=[];d!==null&&d!==m;){var z=d,G=z.alternate,ce=z.stateNode;if(G!==null&&G===m)break;z.tag===5&&ce!==null&&(z=ce,w?(G=be(d,b),G!=null&&T.unshift(Ga(d,G,z))):w||(G=be(d,b),G!=null&&T.push(Ga(d,G,z)))),d=d.return}T.length!==0&&o.push({event:i,listeners:T})}var RS=/\r\n?/g,OS=/\u0000|\uFFFD/g;function Gg(o){return(typeof o=="string"?o:""+o).replace(RS,`
|
|
93
|
+
`).replace(OS,"")}function _c(o,i,d){if(i=Gg(i),Gg(o)!==i&&d)throw Error(n(425))}function Ec(){}var lf=null,cf=null;function uf(o,i){return o==="textarea"||o==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var df=typeof setTimeout=="function"?setTimeout:void 0,$S=typeof clearTimeout=="function"?clearTimeout:void 0,Vg=typeof Promise=="function"?Promise:void 0,MS=typeof queueMicrotask=="function"?queueMicrotask:typeof Vg<"u"?function(o){return Vg.resolve(null).then(o).catch(LS)}:df;function LS(o){setTimeout(function(){throw o})}function ff(o,i){var d=i,m=0;do{var w=d.nextSibling;if(o.removeChild(d),w&&w.nodeType===8)if(d=w.data,d==="/$"){if(m===0){o.removeChild(w),ms(i);return}m--}else d!=="$"&&d!=="$?"&&d!=="$!"||m++;d=w}while(d);ms(i)}function xs(o){for(;o!=null;o=o.nextSibling){var i=o.nodeType;if(i===1||i===3)break;if(i===8){if(i=o.data,i==="$"||i==="$!"||i==="$?")break;if(i==="/$")return null}}return o}function Yg(o){o=o.previousSibling;for(var i=0;o;){if(o.nodeType===8){var d=o.data;if(d==="$"||d==="$!"||d==="$?"){if(i===0)return o;i--}else d==="/$"&&i++}o=o.previousSibling}return null}var Ui=Math.random().toString(36).slice(2),Lo="__reactFiber$"+Ui,Va="__reactProps$"+Ui,Yo="__reactContainer$"+Ui,pf="__reactEvents$"+Ui,PS="__reactListeners$"+Ui,DS="__reactHandles$"+Ui;function ti(o){var i=o[Lo];if(i)return i;for(var d=o.parentNode;d;){if(i=d[Yo]||d[Lo]){if(d=i.alternate,i.child!==null||d!==null&&d.child!==null)for(o=Yg(o);o!==null;){if(d=o[Lo])return d;o=Yg(o)}return i}o=d,d=o.parentNode}return null}function Ya(o){return o=o[Lo]||o[Yo],!o||o.tag!==5&&o.tag!==6&&o.tag!==13&&o.tag!==3?null:o}function Hi(o){if(o.tag===5||o.tag===6)return o.stateNode;throw Error(n(33))}function Sc(o){return o[Va]||null}var hf=[],Wi=-1;function _s(o){return{current:o}}function Sn(o){0>Wi||(o.current=hf[Wi],hf[Wi]=null,Wi--)}function bn(o,i){Wi++,hf[Wi]=o.current,o.current=i}var Es={},wr=_s(Es),Mr=_s(!1),ni=Es;function Ki(o,i){var d=o.type.contextTypes;if(!d)return Es;var m=o.stateNode;if(m&&m.__reactInternalMemoizedUnmaskedChildContext===i)return m.__reactInternalMemoizedMaskedChildContext;var w={},b;for(b in d)w[b]=i[b];return m&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=i,o.__reactInternalMemoizedMaskedChildContext=w),w}function Lr(o){return o=o.childContextTypes,o!=null}function Nc(){Sn(Mr),Sn(wr)}function Qg(o,i,d){if(wr.current!==Es)throw Error(n(168));bn(wr,i),bn(Mr,d)}function Xg(o,i,d){var m=o.stateNode;if(i=i.childContextTypes,typeof m.getChildContext!="function")return d;m=m.getChildContext();for(var w in m)if(!(w in i))throw Error(n(108,le(o)||"Unknown",w));return ne({},d,m)}function Tc(o){return o=(o=o.stateNode)&&o.__reactInternalMemoizedMergedChildContext||Es,ni=wr.current,bn(wr,o),bn(Mr,Mr.current),!0}function Jg(o,i,d){var m=o.stateNode;if(!m)throw Error(n(169));d?(o=Xg(o,i,ni),m.__reactInternalMemoizedMergedChildContext=o,Sn(Mr),Sn(wr),bn(wr,o)):Sn(Mr),bn(Mr,d)}var Qo=null,jc=!1,mf=!1;function ek(o){Qo===null?Qo=[o]:Qo.push(o)}function zS(o){jc=!0,ek(o)}function Ss(){if(!mf&&Qo!==null){mf=!0;var o=0,i=Ot;try{var d=Qo;for(Ot=1;o<d.length;o++){var m=d[o];do m=m(!0);while(m!==null)}Qo=null,jc=!1}catch(w){throw Qo!==null&&(Qo=Qo.slice(o+1)),Fn(so,Ss),w}finally{Ot=i,mf=!1}}return null}var Zi=[],qi=0,Cc=null,Ac=0,io=[],ao=0,ri=null,Xo=1,Jo="";function oi(o,i){Zi[qi++]=Ac,Zi[qi++]=Cc,Cc=o,Ac=i}function tk(o,i,d){io[ao++]=Xo,io[ao++]=Jo,io[ao++]=ri,ri=o;var m=Xo;o=Jo;var w=32-Qt(m)-1;m&=~(1<<w),d+=1;var b=32-Qt(i)+w;if(30<b){var T=w-w%5;b=(m&(1<<T)-1).toString(32),m>>=T,w-=T,Xo=1<<32-Qt(i)+w|d<<w|m,Jo=b+o}else Xo=1<<b|d<<w|m,Jo=o}function gf(o){o.return!==null&&(oi(o,1),tk(o,1,0))}function kf(o){for(;o===Cc;)Cc=Zi[--qi],Zi[qi]=null,Ac=Zi[--qi],Zi[qi]=null;for(;o===ri;)ri=io[--ao],io[ao]=null,Jo=io[--ao],io[ao]=null,Xo=io[--ao],io[ao]=null}var Yr=null,Qr=null,Tn=!1,bo=null;function nk(o,i){var d=fo(5,null,null,0);d.elementType="DELETED",d.stateNode=i,d.return=o,i=o.deletions,i===null?(o.deletions=[d],o.flags|=16):i.push(d)}function rk(o,i){switch(o.tag){case 5:var d=o.type;return i=i.nodeType!==1||d.toLowerCase()!==i.nodeName.toLowerCase()?null:i,i!==null?(o.stateNode=i,Yr=o,Qr=xs(i.firstChild),!0):!1;case 6:return i=o.pendingProps===""||i.nodeType!==3?null:i,i!==null?(o.stateNode=i,Yr=o,Qr=null,!0):!1;case 13:return i=i.nodeType!==8?null:i,i!==null?(d=ri!==null?{id:Xo,overflow:Jo}:null,o.memoizedState={dehydrated:i,treeContext:d,retryLane:1073741824},d=fo(18,null,null,0),d.stateNode=i,d.return=o,o.child=d,Yr=o,Qr=null,!0):!1;default:return!1}}function yf(o){return(o.mode&1)!==0&&(o.flags&128)===0}function wf(o){if(Tn){var i=Qr;if(i){var d=i;if(!rk(o,i)){if(yf(o))throw Error(n(418));i=xs(d.nextSibling);var m=Yr;i&&rk(o,i)?nk(m,d):(o.flags=o.flags&-4097|2,Tn=!1,Yr=o)}}else{if(yf(o))throw Error(n(418));o.flags=o.flags&-4097|2,Tn=!1,Yr=o}}}function ok(o){for(o=o.return;o!==null&&o.tag!==5&&o.tag!==3&&o.tag!==13;)o=o.return;Yr=o}function Ic(o){if(o!==Yr)return!1;if(!Tn)return ok(o),Tn=!0,!1;var i;if((i=o.tag!==3)&&!(i=o.tag!==5)&&(i=o.type,i=i!=="head"&&i!=="body"&&!uf(o.type,o.memoizedProps)),i&&(i=Qr)){if(yf(o))throw sk(),Error(n(418));for(;i;)nk(o,i),i=xs(i.nextSibling)}if(ok(o),o.tag===13){if(o=o.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(n(317));e:{for(o=o.nextSibling,i=0;o;){if(o.nodeType===8){var d=o.data;if(d==="/$"){if(i===0){Qr=xs(o.nextSibling);break e}i--}else d!=="$"&&d!=="$!"&&d!=="$?"||i++}o=o.nextSibling}Qr=null}}else Qr=Yr?xs(o.stateNode.nextSibling):null;return!0}function sk(){for(var o=Qr;o;)o=xs(o.nextSibling)}function Gi(){Qr=Yr=null,Tn=!1}function vf(o){bo===null?bo=[o]:bo.push(o)}var FS=M.ReactCurrentBatchConfig;function Qa(o,i,d){if(o=d.ref,o!==null&&typeof o!="function"&&typeof o!="object"){if(d._owner){if(d=d._owner,d){if(d.tag!==1)throw Error(n(309));var m=d.stateNode}if(!m)throw Error(n(147,o));var w=m,b=""+o;return i!==null&&i.ref!==null&&typeof i.ref=="function"&&i.ref._stringRef===b?i.ref:(i=function(T){var z=w.refs;T===null?delete z[b]:z[b]=T},i._stringRef=b,i)}if(typeof o!="string")throw Error(n(284));if(!d._owner)throw Error(n(290,o))}return o}function Rc(o,i){throw o=Object.prototype.toString.call(i),Error(n(31,o==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":o))}function ik(o){var i=o._init;return i(o._payload)}function ak(o){function i(re,Q){if(o){var ie=re.deletions;ie===null?(re.deletions=[Q],re.flags|=16):ie.push(Q)}}function d(re,Q){if(!o)return null;for(;Q!==null;)i(re,Q),Q=Q.sibling;return null}function m(re,Q){for(re=new Map;Q!==null;)Q.key!==null?re.set(Q.key,Q):re.set(Q.index,Q),Q=Q.sibling;return re}function w(re,Q){return re=Os(re,Q),re.index=0,re.sibling=null,re}function b(re,Q,ie){return re.index=ie,o?(ie=re.alternate,ie!==null?(ie=ie.index,ie<Q?(re.flags|=2,Q):ie):(re.flags|=2,Q)):(re.flags|=1048576,Q)}function T(re){return o&&re.alternate===null&&(re.flags|=2),re}function z(re,Q,ie,Me){return Q===null||Q.tag!==6?(Q=dp(ie,re.mode,Me),Q.return=re,Q):(Q=w(Q,ie),Q.return=re,Q)}function G(re,Q,ie,Me){var Xe=ie.type;return Xe===R?Te(re,Q,ie.props.children,Me,ie.key):Q!==null&&(Q.elementType===Xe||typeof Xe=="object"&&Xe!==null&&Xe.$$typeof===_e&&ik(Xe)===Q.type)?(Me=w(Q,ie.props),Me.ref=Qa(re,Q,ie),Me.return=re,Me):(Me=nu(ie.type,ie.key,ie.props,null,re.mode,Me),Me.ref=Qa(re,Q,ie),Me.return=re,Me)}function ce(re,Q,ie,Me){return Q===null||Q.tag!==4||Q.stateNode.containerInfo!==ie.containerInfo||Q.stateNode.implementation!==ie.implementation?(Q=fp(ie,re.mode,Me),Q.return=re,Q):(Q=w(Q,ie.children||[]),Q.return=re,Q)}function Te(re,Q,ie,Me,Xe){return Q===null||Q.tag!==7?(Q=fi(ie,re.mode,Me,Xe),Q.return=re,Q):(Q=w(Q,ie),Q.return=re,Q)}function Ie(re,Q,ie){if(typeof Q=="string"&&Q!==""||typeof Q=="number")return Q=dp(""+Q,re.mode,ie),Q.return=re,Q;if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case J:return ie=nu(Q.type,Q.key,Q.props,null,re.mode,ie),ie.ref=Qa(re,null,Q),ie.return=re,ie;case W:return Q=fp(Q,re.mode,ie),Q.return=re,Q;case _e:var Me=Q._init;return Ie(re,Me(Q._payload),ie)}if(st(Q)||F(Q))return Q=fi(Q,re.mode,ie,null),Q.return=re,Q;Rc(re,Q)}return null}function Ee(re,Q,ie,Me){var Xe=Q!==null?Q.key:null;if(typeof ie=="string"&&ie!==""||typeof ie=="number")return Xe!==null?null:z(re,Q,""+ie,Me);if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case J:return ie.key===Xe?G(re,Q,ie,Me):null;case W:return ie.key===Xe?ce(re,Q,ie,Me):null;case _e:return Xe=ie._init,Ee(re,Q,Xe(ie._payload),Me)}if(st(ie)||F(ie))return Xe!==null?null:Te(re,Q,ie,Me,null);Rc(re,ie)}return null}function Ze(re,Q,ie,Me,Xe){if(typeof Me=="string"&&Me!==""||typeof Me=="number")return re=re.get(ie)||null,z(Q,re,""+Me,Xe);if(typeof Me=="object"&&Me!==null){switch(Me.$$typeof){case J:return re=re.get(Me.key===null?ie:Me.key)||null,G(Q,re,Me,Xe);case W:return re=re.get(Me.key===null?ie:Me.key)||null,ce(Q,re,Me,Xe);case _e:var ct=Me._init;return Ze(re,Q,ie,ct(Me._payload),Xe)}if(st(Me)||F(Me))return re=re.get(ie)||null,Te(Q,re,Me,Xe,null);Rc(Q,Me)}return null}function Ge(re,Q,ie,Me){for(var Xe=null,ct=null,ut=Q,wt=Q=0,pr=null;ut!==null&&wt<ie.length;wt++){ut.index>wt?(pr=ut,ut=null):pr=ut.sibling;var Yt=Ee(re,ut,ie[wt],Me);if(Yt===null){ut===null&&(ut=pr);break}o&&ut&&Yt.alternate===null&&i(re,ut),Q=b(Yt,Q,wt),ct===null?Xe=Yt:ct.sibling=Yt,ct=Yt,ut=pr}if(wt===ie.length)return d(re,ut),Tn&&oi(re,wt),Xe;if(ut===null){for(;wt<ie.length;wt++)ut=Ie(re,ie[wt],Me),ut!==null&&(Q=b(ut,Q,wt),ct===null?Xe=ut:ct.sibling=ut,ct=ut);return Tn&&oi(re,wt),Xe}for(ut=m(re,ut);wt<ie.length;wt++)pr=Ze(ut,re,wt,ie[wt],Me),pr!==null&&(o&&pr.alternate!==null&&ut.delete(pr.key===null?wt:pr.key),Q=b(pr,Q,wt),ct===null?Xe=pr:ct.sibling=pr,ct=pr);return o&&ut.forEach(function($s){return i(re,$s)}),Tn&&oi(re,wt),Xe}function Ye(re,Q,ie,Me){var Xe=F(ie);if(typeof Xe!="function")throw Error(n(150));if(ie=Xe.call(ie),ie==null)throw Error(n(151));for(var ct=Xe=null,ut=Q,wt=Q=0,pr=null,Yt=ie.next();ut!==null&&!Yt.done;wt++,Yt=ie.next()){ut.index>wt?(pr=ut,ut=null):pr=ut.sibling;var $s=Ee(re,ut,Yt.value,Me);if($s===null){ut===null&&(ut=pr);break}o&&ut&&$s.alternate===null&&i(re,ut),Q=b($s,Q,wt),ct===null?Xe=$s:ct.sibling=$s,ct=$s,ut=pr}if(Yt.done)return d(re,ut),Tn&&oi(re,wt),Xe;if(ut===null){for(;!Yt.done;wt++,Yt=ie.next())Yt=Ie(re,Yt.value,Me),Yt!==null&&(Q=b(Yt,Q,wt),ct===null?Xe=Yt:ct.sibling=Yt,ct=Yt);return Tn&&oi(re,wt),Xe}for(ut=m(re,ut);!Yt.done;wt++,Yt=ie.next())Yt=Ze(ut,re,wt,Yt.value,Me),Yt!==null&&(o&&Yt.alternate!==null&&ut.delete(Yt.key===null?wt:Yt.key),Q=b(Yt,Q,wt),ct===null?Xe=Yt:ct.sibling=Yt,ct=Yt);return o&&ut.forEach(function(wN){return i(re,wN)}),Tn&&oi(re,wt),Xe}function Kn(re,Q,ie,Me){if(typeof ie=="object"&&ie!==null&&ie.type===R&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case J:e:{for(var Xe=ie.key,ct=Q;ct!==null;){if(ct.key===Xe){if(Xe=ie.type,Xe===R){if(ct.tag===7){d(re,ct.sibling),Q=w(ct,ie.props.children),Q.return=re,re=Q;break e}}else if(ct.elementType===Xe||typeof Xe=="object"&&Xe!==null&&Xe.$$typeof===_e&&ik(Xe)===ct.type){d(re,ct.sibling),Q=w(ct,ie.props),Q.ref=Qa(re,ct,ie),Q.return=re,re=Q;break e}d(re,ct);break}else i(re,ct);ct=ct.sibling}ie.type===R?(Q=fi(ie.props.children,re.mode,Me,ie.key),Q.return=re,re=Q):(Me=nu(ie.type,ie.key,ie.props,null,re.mode,Me),Me.ref=Qa(re,Q,ie),Me.return=re,re=Me)}return T(re);case W:e:{for(ct=ie.key;Q!==null;){if(Q.key===ct)if(Q.tag===4&&Q.stateNode.containerInfo===ie.containerInfo&&Q.stateNode.implementation===ie.implementation){d(re,Q.sibling),Q=w(Q,ie.children||[]),Q.return=re,re=Q;break e}else{d(re,Q);break}else i(re,Q);Q=Q.sibling}Q=fp(ie,re.mode,Me),Q.return=re,re=Q}return T(re);case _e:return ct=ie._init,Kn(re,Q,ct(ie._payload),Me)}if(st(ie))return Ge(re,Q,ie,Me);if(F(ie))return Ye(re,Q,ie,Me);Rc(re,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"?(ie=""+ie,Q!==null&&Q.tag===6?(d(re,Q.sibling),Q=w(Q,ie),Q.return=re,re=Q):(d(re,Q),Q=dp(ie,re.mode,Me),Q.return=re,re=Q),T(re)):d(re,Q)}return Kn}var Vi=ak(!0),lk=ak(!1),Oc=_s(null),$c=null,Yi=null,bf=null;function xf(){bf=Yi=$c=null}function _f(o){var i=Oc.current;Sn(Oc),o._currentValue=i}function Ef(o,i,d){for(;o!==null;){var m=o.alternate;if((o.childLanes&i)!==i?(o.childLanes|=i,m!==null&&(m.childLanes|=i)):m!==null&&(m.childLanes&i)!==i&&(m.childLanes|=i),o===d)break;o=o.return}}function Qi(o,i){$c=o,bf=Yi=null,o=o.dependencies,o!==null&&o.firstContext!==null&&((o.lanes&i)!==0&&(Pr=!0),o.firstContext=null)}function lo(o){var i=o._currentValue;if(bf!==o)if(o={context:o,memoizedValue:i,next:null},Yi===null){if($c===null)throw Error(n(308));Yi=o,$c.dependencies={lanes:0,firstContext:o}}else Yi=Yi.next=o;return i}var si=null;function Sf(o){si===null?si=[o]:si.push(o)}function ck(o,i,d,m){var w=i.interleaved;return w===null?(d.next=d,Sf(i)):(d.next=w.next,w.next=d),i.interleaved=d,es(o,m)}function es(o,i){o.lanes|=i;var d=o.alternate;for(d!==null&&(d.lanes|=i),d=o,o=o.return;o!==null;)o.childLanes|=i,d=o.alternate,d!==null&&(d.childLanes|=i),d=o,o=o.return;return d.tag===3?d.stateNode:null}var Ns=!1;function Nf(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function uk(o,i){o=o.updateQueue,i.updateQueue===o&&(i.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,effects:o.effects})}function ts(o,i){return{eventTime:o,lane:i,tag:0,payload:null,callback:null,next:null}}function Ts(o,i,d){var m=o.updateQueue;if(m===null)return null;if(m=m.shared,(Zt&2)!==0){var w=m.pending;return w===null?i.next=i:(i.next=w.next,w.next=i),m.pending=i,es(o,d)}return w=m.interleaved,w===null?(i.next=i,Sf(m)):(i.next=w.next,w.next=i),m.interleaved=i,es(o,d)}function Mc(o,i,d){if(i=i.updateQueue,i!==null&&(i=i.shared,(d&4194240)!==0)){var m=i.lanes;m&=o.pendingLanes,d|=m,i.lanes=d,$r(o,d)}}function dk(o,i){var d=o.updateQueue,m=o.alternate;if(m!==null&&(m=m.updateQueue,d===m)){var w=null,b=null;if(d=d.firstBaseUpdate,d!==null){do{var T={eventTime:d.eventTime,lane:d.lane,tag:d.tag,payload:d.payload,callback:d.callback,next:null};b===null?w=b=T:b=b.next=T,d=d.next}while(d!==null);b===null?w=b=i:b=b.next=i}else w=b=i;d={baseState:m.baseState,firstBaseUpdate:w,lastBaseUpdate:b,shared:m.shared,effects:m.effects},o.updateQueue=d;return}o=d.lastBaseUpdate,o===null?d.firstBaseUpdate=i:o.next=i,d.lastBaseUpdate=i}function Lc(o,i,d,m){var w=o.updateQueue;Ns=!1;var b=w.firstBaseUpdate,T=w.lastBaseUpdate,z=w.shared.pending;if(z!==null){w.shared.pending=null;var G=z,ce=G.next;G.next=null,T===null?b=ce:T.next=ce,T=G;var Te=o.alternate;Te!==null&&(Te=Te.updateQueue,z=Te.lastBaseUpdate,z!==T&&(z===null?Te.firstBaseUpdate=ce:z.next=ce,Te.lastBaseUpdate=G))}if(b!==null){var Ie=w.baseState;T=0,Te=ce=G=null,z=b;do{var Ee=z.lane,Ze=z.eventTime;if((m&Ee)===Ee){Te!==null&&(Te=Te.next={eventTime:Ze,lane:0,tag:z.tag,payload:z.payload,callback:z.callback,next:null});e:{var Ge=o,Ye=z;switch(Ee=i,Ze=d,Ye.tag){case 1:if(Ge=Ye.payload,typeof Ge=="function"){Ie=Ge.call(Ze,Ie,Ee);break e}Ie=Ge;break e;case 3:Ge.flags=Ge.flags&-65537|128;case 0:if(Ge=Ye.payload,Ee=typeof Ge=="function"?Ge.call(Ze,Ie,Ee):Ge,Ee==null)break e;Ie=ne({},Ie,Ee);break e;case 2:Ns=!0}}z.callback!==null&&z.lane!==0&&(o.flags|=64,Ee=w.effects,Ee===null?w.effects=[z]:Ee.push(z))}else Ze={eventTime:Ze,lane:Ee,tag:z.tag,payload:z.payload,callback:z.callback,next:null},Te===null?(ce=Te=Ze,G=Ie):Te=Te.next=Ze,T|=Ee;if(z=z.next,z===null){if(z=w.shared.pending,z===null)break;Ee=z,z=Ee.next,Ee.next=null,w.lastBaseUpdate=Ee,w.shared.pending=null}}while(!0);if(Te===null&&(G=Ie),w.baseState=G,w.firstBaseUpdate=ce,w.lastBaseUpdate=Te,i=w.shared.interleaved,i!==null){w=i;do T|=w.lane,w=w.next;while(w!==i)}else b===null&&(w.shared.lanes=0);li|=T,o.lanes=T,o.memoizedState=Ie}}function fk(o,i,d){if(o=i.effects,i.effects=null,o!==null)for(i=0;i<o.length;i++){var m=o[i],w=m.callback;if(w!==null){if(m.callback=null,m=d,typeof w!="function")throw Error(n(191,w));w.call(m)}}}var Xa={},Po=_s(Xa),Ja=_s(Xa),el=_s(Xa);function ii(o){if(o===Xa)throw Error(n(174));return o}function Tf(o,i){switch(bn(el,i),bn(Ja,o),bn(Po,Xa),o=i.nodeType,o){case 9:case 11:i=(i=i.documentElement)?i.namespaceURI:an(null,"");break;default:o=o===8?i.parentNode:i,i=o.namespaceURI||null,o=o.tagName,i=an(i,o)}Sn(Po),bn(Po,i)}function Xi(){Sn(Po),Sn(Ja),Sn(el)}function pk(o){ii(el.current);var i=ii(Po.current),d=an(i,o.type);i!==d&&(bn(Ja,o),bn(Po,d))}function jf(o){Ja.current===o&&(Sn(Po),Sn(Ja))}var On=_s(0);function Pc(o){for(var i=o;i!==null;){if(i.tag===13){var d=i.memoizedState;if(d!==null&&(d=d.dehydrated,d===null||d.data==="$?"||d.data==="$!"))return i}else if(i.tag===19&&i.memoizedProps.revealOrder!==void 0){if((i.flags&128)!==0)return i}else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===o)break;for(;i.sibling===null;){if(i.return===null||i.return===o)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var Cf=[];function Af(){for(var o=0;o<Cf.length;o++)Cf[o]._workInProgressVersionPrimary=null;Cf.length=0}var Dc=M.ReactCurrentDispatcher,If=M.ReactCurrentBatchConfig,ai=0,$n=null,tr=null,dr=null,zc=!1,tl=!1,nl=0,BS=0;function vr(){throw Error(n(321))}function Rf(o,i){if(i===null)return!1;for(var d=0;d<i.length&&d<o.length;d++)if(!vo(o[d],i[d]))return!1;return!0}function Of(o,i,d,m,w,b){if(ai=b,$n=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,Dc.current=o===null||o.memoizedState===null?KS:ZS,o=d(m,w),tl){b=0;do{if(tl=!1,nl=0,25<=b)throw Error(n(301));b+=1,dr=tr=null,i.updateQueue=null,Dc.current=qS,o=d(m,w)}while(tl)}if(Dc.current=Uc,i=tr!==null&&tr.next!==null,ai=0,dr=tr=$n=null,zc=!1,i)throw Error(n(300));return o}function $f(){var o=nl!==0;return nl=0,o}function Do(){var o={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return dr===null?$n.memoizedState=dr=o:dr=dr.next=o,dr}function co(){if(tr===null){var o=$n.alternate;o=o!==null?o.memoizedState:null}else o=tr.next;var i=dr===null?$n.memoizedState:dr.next;if(i!==null)dr=i,tr=o;else{if(o===null)throw Error(n(310));tr=o,o={memoizedState:tr.memoizedState,baseState:tr.baseState,baseQueue:tr.baseQueue,queue:tr.queue,next:null},dr===null?$n.memoizedState=dr=o:dr=dr.next=o}return dr}function rl(o,i){return typeof i=="function"?i(o):i}function Mf(o){var i=co(),d=i.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=o;var m=tr,w=m.baseQueue,b=d.pending;if(b!==null){if(w!==null){var T=w.next;w.next=b.next,b.next=T}m.baseQueue=w=b,d.pending=null}if(w!==null){b=w.next,m=m.baseState;var z=T=null,G=null,ce=b;do{var Te=ce.lane;if((ai&Te)===Te)G!==null&&(G=G.next={lane:0,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null}),m=ce.hasEagerState?ce.eagerState:o(m,ce.action);else{var Ie={lane:Te,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null};G===null?(z=G=Ie,T=m):G=G.next=Ie,$n.lanes|=Te,li|=Te}ce=ce.next}while(ce!==null&&ce!==b);G===null?T=m:G.next=z,vo(m,i.memoizedState)||(Pr=!0),i.memoizedState=m,i.baseState=T,i.baseQueue=G,d.lastRenderedState=m}if(o=d.interleaved,o!==null){w=o;do b=w.lane,$n.lanes|=b,li|=b,w=w.next;while(w!==o)}else w===null&&(d.lanes=0);return[i.memoizedState,d.dispatch]}function Lf(o){var i=co(),d=i.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=o;var m=d.dispatch,w=d.pending,b=i.memoizedState;if(w!==null){d.pending=null;var T=w=w.next;do b=o(b,T.action),T=T.next;while(T!==w);vo(b,i.memoizedState)||(Pr=!0),i.memoizedState=b,i.baseQueue===null&&(i.baseState=b),d.lastRenderedState=b}return[b,m]}function hk(){}function mk(o,i){var d=$n,m=co(),w=i(),b=!vo(m.memoizedState,w);if(b&&(m.memoizedState=w,Pr=!0),m=m.queue,Pf(yk.bind(null,d,m,o),[o]),m.getSnapshot!==i||b||dr!==null&&dr.memoizedState.tag&1){if(d.flags|=2048,ol(9,kk.bind(null,d,m,w,i),void 0,null),fr===null)throw Error(n(349));(ai&30)!==0||gk(d,i,w)}return w}function gk(o,i,d){o.flags|=16384,o={getSnapshot:i,value:d},i=$n.updateQueue,i===null?(i={lastEffect:null,stores:null},$n.updateQueue=i,i.stores=[o]):(d=i.stores,d===null?i.stores=[o]:d.push(o))}function kk(o,i,d,m){i.value=d,i.getSnapshot=m,wk(i)&&vk(o)}function yk(o,i,d){return d(function(){wk(i)&&vk(o)})}function wk(o){var i=o.getSnapshot;o=o.value;try{var d=i();return!vo(o,d)}catch{return!0}}function vk(o){var i=es(o,1);i!==null&&So(i,o,1,-1)}function bk(o){var i=Do();return typeof o=="function"&&(o=o()),i.memoizedState=i.baseState=o,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:rl,lastRenderedState:o},i.queue=o,o=o.dispatch=WS.bind(null,$n,o),[i.memoizedState,o]}function ol(o,i,d,m){return o={tag:o,create:i,destroy:d,deps:m,next:null},i=$n.updateQueue,i===null?(i={lastEffect:null,stores:null},$n.updateQueue=i,i.lastEffect=o.next=o):(d=i.lastEffect,d===null?i.lastEffect=o.next=o:(m=d.next,d.next=o,o.next=m,i.lastEffect=o)),o}function xk(){return co().memoizedState}function Fc(o,i,d,m){var w=Do();$n.flags|=o,w.memoizedState=ol(1|i,d,void 0,m===void 0?null:m)}function Bc(o,i,d,m){var w=co();m=m===void 0?null:m;var b=void 0;if(tr!==null){var T=tr.memoizedState;if(b=T.destroy,m!==null&&Rf(m,T.deps)){w.memoizedState=ol(i,d,b,m);return}}$n.flags|=o,w.memoizedState=ol(1|i,d,b,m)}function _k(o,i){return Fc(8390656,8,o,i)}function Pf(o,i){return Bc(2048,8,o,i)}function Ek(o,i){return Bc(4,2,o,i)}function Sk(o,i){return Bc(4,4,o,i)}function Nk(o,i){if(typeof i=="function")return o=o(),i(o),function(){i(null)};if(i!=null)return o=o(),i.current=o,function(){i.current=null}}function Tk(o,i,d){return d=d!=null?d.concat([o]):null,Bc(4,4,Nk.bind(null,i,o),d)}function Df(){}function jk(o,i){var d=co();i=i===void 0?null:i;var m=d.memoizedState;return m!==null&&i!==null&&Rf(i,m[1])?m[0]:(d.memoizedState=[o,i],o)}function Ck(o,i){var d=co();i=i===void 0?null:i;var m=d.memoizedState;return m!==null&&i!==null&&Rf(i,m[1])?m[0]:(o=o(),d.memoizedState=[o,i],o)}function Ak(o,i,d){return(ai&21)===0?(o.baseState&&(o.baseState=!1,Pr=!0),o.memoizedState=d):(vo(d,i)||(d=ps(),$n.lanes|=d,li|=d,o.baseState=!0),i)}function US(o,i){var d=Ot;Ot=d!==0&&4>d?d:4,o(!0);var m=If.transition;If.transition={};try{o(!1),i()}finally{Ot=d,If.transition=m}}function Ik(){return co().memoizedState}function HS(o,i,d){var m=Is(o);if(d={lane:m,action:d,hasEagerState:!1,eagerState:null,next:null},Rk(o))Ok(i,d);else if(d=ck(o,i,d,m),d!==null){var w=Ir();So(d,o,m,w),$k(d,i,m)}}function WS(o,i,d){var m=Is(o),w={lane:m,action:d,hasEagerState:!1,eagerState:null,next:null};if(Rk(o))Ok(i,w);else{var b=o.alternate;if(o.lanes===0&&(b===null||b.lanes===0)&&(b=i.lastRenderedReducer,b!==null))try{var T=i.lastRenderedState,z=b(T,d);if(w.hasEagerState=!0,w.eagerState=z,vo(z,T)){var G=i.interleaved;G===null?(w.next=w,Sf(i)):(w.next=G.next,G.next=w),i.interleaved=w;return}}catch{}finally{}d=ck(o,i,w,m),d!==null&&(w=Ir(),So(d,o,m,w),$k(d,i,m))}}function Rk(o){var i=o.alternate;return o===$n||i!==null&&i===$n}function Ok(o,i){tl=zc=!0;var d=o.pending;d===null?i.next=i:(i.next=d.next,d.next=i),o.pending=i}function $k(o,i,d){if((d&4194240)!==0){var m=i.lanes;m&=o.pendingLanes,d|=m,i.lanes=d,$r(o,d)}}var Uc={readContext:lo,useCallback:vr,useContext:vr,useEffect:vr,useImperativeHandle:vr,useInsertionEffect:vr,useLayoutEffect:vr,useMemo:vr,useReducer:vr,useRef:vr,useState:vr,useDebugValue:vr,useDeferredValue:vr,useTransition:vr,useMutableSource:vr,useSyncExternalStore:vr,useId:vr,unstable_isNewReconciler:!1},KS={readContext:lo,useCallback:function(o,i){return Do().memoizedState=[o,i===void 0?null:i],o},useContext:lo,useEffect:_k,useImperativeHandle:function(o,i,d){return d=d!=null?d.concat([o]):null,Fc(4194308,4,Nk.bind(null,i,o),d)},useLayoutEffect:function(o,i){return Fc(4194308,4,o,i)},useInsertionEffect:function(o,i){return Fc(4,2,o,i)},useMemo:function(o,i){var d=Do();return i=i===void 0?null:i,o=o(),d.memoizedState=[o,i],o},useReducer:function(o,i,d){var m=Do();return i=d!==void 0?d(i):i,m.memoizedState=m.baseState=i,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:i},m.queue=o,o=o.dispatch=HS.bind(null,$n,o),[m.memoizedState,o]},useRef:function(o){var i=Do();return o={current:o},i.memoizedState=o},useState:bk,useDebugValue:Df,useDeferredValue:function(o){return Do().memoizedState=o},useTransition:function(){var o=bk(!1),i=o[0];return o=US.bind(null,o[1]),Do().memoizedState=o,[i,o]},useMutableSource:function(){},useSyncExternalStore:function(o,i,d){var m=$n,w=Do();if(Tn){if(d===void 0)throw Error(n(407));d=d()}else{if(d=i(),fr===null)throw Error(n(349));(ai&30)!==0||gk(m,i,d)}w.memoizedState=d;var b={value:d,getSnapshot:i};return w.queue=b,_k(yk.bind(null,m,b,o),[o]),m.flags|=2048,ol(9,kk.bind(null,m,b,d,i),void 0,null),d},useId:function(){var o=Do(),i=fr.identifierPrefix;if(Tn){var d=Jo,m=Xo;d=(m&~(1<<32-Qt(m)-1)).toString(32)+d,i=":"+i+"R"+d,d=nl++,0<d&&(i+="H"+d.toString(32)),i+=":"}else d=BS++,i=":"+i+"r"+d.toString(32)+":";return o.memoizedState=i},unstable_isNewReconciler:!1},ZS={readContext:lo,useCallback:jk,useContext:lo,useEffect:Pf,useImperativeHandle:Tk,useInsertionEffect:Ek,useLayoutEffect:Sk,useMemo:Ck,useReducer:Mf,useRef:xk,useState:function(){return Mf(rl)},useDebugValue:Df,useDeferredValue:function(o){var i=co();return Ak(i,tr.memoizedState,o)},useTransition:function(){var o=Mf(rl)[0],i=co().memoizedState;return[o,i]},useMutableSource:hk,useSyncExternalStore:mk,useId:Ik,unstable_isNewReconciler:!1},qS={readContext:lo,useCallback:jk,useContext:lo,useEffect:Pf,useImperativeHandle:Tk,useInsertionEffect:Ek,useLayoutEffect:Sk,useMemo:Ck,useReducer:Lf,useRef:xk,useState:function(){return Lf(rl)},useDebugValue:Df,useDeferredValue:function(o){var i=co();return tr===null?i.memoizedState=o:Ak(i,tr.memoizedState,o)},useTransition:function(){var o=Lf(rl)[0],i=co().memoizedState;return[o,i]},useMutableSource:hk,useSyncExternalStore:mk,useId:Ik,unstable_isNewReconciler:!1};function xo(o,i){if(o&&o.defaultProps){i=ne({},i),o=o.defaultProps;for(var d in o)i[d]===void 0&&(i[d]=o[d]);return i}return i}function zf(o,i,d,m){i=o.memoizedState,d=d(m,i),d=d==null?i:ne({},i,d),o.memoizedState=d,o.lanes===0&&(o.updateQueue.baseState=d)}var Hc={isMounted:function(o){return(o=o._reactInternals)?An(o)===o:!1},enqueueSetState:function(o,i,d){o=o._reactInternals;var m=Ir(),w=Is(o),b=ts(m,w);b.payload=i,d!=null&&(b.callback=d),i=Ts(o,b,w),i!==null&&(So(i,o,w,m),Mc(i,o,w))},enqueueReplaceState:function(o,i,d){o=o._reactInternals;var m=Ir(),w=Is(o),b=ts(m,w);b.tag=1,b.payload=i,d!=null&&(b.callback=d),i=Ts(o,b,w),i!==null&&(So(i,o,w,m),Mc(i,o,w))},enqueueForceUpdate:function(o,i){o=o._reactInternals;var d=Ir(),m=Is(o),w=ts(d,m);w.tag=2,i!=null&&(w.callback=i),i=Ts(o,w,m),i!==null&&(So(i,o,m,d),Mc(i,o,m))}};function Mk(o,i,d,m,w,b,T){return o=o.stateNode,typeof o.shouldComponentUpdate=="function"?o.shouldComponentUpdate(m,b,T):i.prototype&&i.prototype.isPureReactComponent?!Wa(d,m)||!Wa(w,b):!0}function Lk(o,i,d){var m=!1,w=Es,b=i.contextType;return typeof b=="object"&&b!==null?b=lo(b):(w=Lr(i)?ni:wr.current,m=i.contextTypes,b=(m=m!=null)?Ki(o,w):Es),i=new i(d,b),o.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,i.updater=Hc,o.stateNode=i,i._reactInternals=o,m&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=w,o.__reactInternalMemoizedMaskedChildContext=b),i}function Pk(o,i,d,m){o=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(d,m),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(d,m),i.state!==o&&Hc.enqueueReplaceState(i,i.state,null)}function Ff(o,i,d,m){var w=o.stateNode;w.props=d,w.state=o.memoizedState,w.refs={},Nf(o);var b=i.contextType;typeof b=="object"&&b!==null?w.context=lo(b):(b=Lr(i)?ni:wr.current,w.context=Ki(o,b)),w.state=o.memoizedState,b=i.getDerivedStateFromProps,typeof b=="function"&&(zf(o,i,b,d),w.state=o.memoizedState),typeof i.getDerivedStateFromProps=="function"||typeof w.getSnapshotBeforeUpdate=="function"||typeof w.UNSAFE_componentWillMount!="function"&&typeof w.componentWillMount!="function"||(i=w.state,typeof w.componentWillMount=="function"&&w.componentWillMount(),typeof w.UNSAFE_componentWillMount=="function"&&w.UNSAFE_componentWillMount(),i!==w.state&&Hc.enqueueReplaceState(w,w.state,null),Lc(o,d,w,m),w.state=o.memoizedState),typeof w.componentDidMount=="function"&&(o.flags|=4194308)}function Ji(o,i){try{var d="",m=i;do d+=ve(m),m=m.return;while(m);var w=d}catch(b){w=`
|
|
94
|
+
Error generating stack: `+b.message+`
|
|
95
|
+
`+b.stack}return{value:o,source:i,stack:w,digest:null}}function Bf(o,i,d){return{value:o,source:null,stack:d??null,digest:i??null}}function Uf(o,i){try{console.error(i.value)}catch(d){setTimeout(function(){throw d})}}var GS=typeof WeakMap=="function"?WeakMap:Map;function Dk(o,i,d){d=ts(-1,d),d.tag=3,d.payload={element:null};var m=i.value;return d.callback=function(){Yc||(Yc=!0,rp=m),Uf(o,i)},d}function zk(o,i,d){d=ts(-1,d),d.tag=3;var m=o.type.getDerivedStateFromError;if(typeof m=="function"){var w=i.value;d.payload=function(){return m(w)},d.callback=function(){Uf(o,i)}}var b=o.stateNode;return b!==null&&typeof b.componentDidCatch=="function"&&(d.callback=function(){Uf(o,i),typeof m!="function"&&(Cs===null?Cs=new Set([this]):Cs.add(this));var T=i.stack;this.componentDidCatch(i.value,{componentStack:T!==null?T:""})}),d}function Fk(o,i,d){var m=o.pingCache;if(m===null){m=o.pingCache=new GS;var w=new Set;m.set(i,w)}else w=m.get(i),w===void 0&&(w=new Set,m.set(i,w));w.has(d)||(w.add(d),o=lN.bind(null,o,i,d),i.then(o,o))}function Bk(o){do{var i;if((i=o.tag===13)&&(i=o.memoizedState,i=i!==null?i.dehydrated!==null:!0),i)return o;o=o.return}while(o!==null);return null}function Uk(o,i,d,m,w){return(o.mode&1)===0?(o===i?o.flags|=65536:(o.flags|=128,d.flags|=131072,d.flags&=-52805,d.tag===1&&(d.alternate===null?d.tag=17:(i=ts(-1,1),i.tag=2,Ts(d,i,1))),d.lanes|=1),o):(o.flags|=65536,o.lanes=w,o)}var VS=M.ReactCurrentOwner,Pr=!1;function Ar(o,i,d,m){i.child=o===null?lk(i,null,d,m):Vi(i,o.child,d,m)}function Hk(o,i,d,m,w){d=d.render;var b=i.ref;return Qi(i,w),m=Of(o,i,d,m,b,w),d=$f(),o!==null&&!Pr?(i.updateQueue=o.updateQueue,i.flags&=-2053,o.lanes&=~w,ns(o,i,w)):(Tn&&d&&gf(i),i.flags|=1,Ar(o,i,m,w),i.child)}function Wk(o,i,d,m,w){if(o===null){var b=d.type;return typeof b=="function"&&!up(b)&&b.defaultProps===void 0&&d.compare===null&&d.defaultProps===void 0?(i.tag=15,i.type=b,Kk(o,i,b,m,w)):(o=nu(d.type,null,m,i,i.mode,w),o.ref=i.ref,o.return=i,i.child=o)}if(b=o.child,(o.lanes&w)===0){var T=b.memoizedProps;if(d=d.compare,d=d!==null?d:Wa,d(T,m)&&o.ref===i.ref)return ns(o,i,w)}return i.flags|=1,o=Os(b,m),o.ref=i.ref,o.return=i,i.child=o}function Kk(o,i,d,m,w){if(o!==null){var b=o.memoizedProps;if(Wa(b,m)&&o.ref===i.ref)if(Pr=!1,i.pendingProps=m=b,(o.lanes&w)!==0)(o.flags&131072)!==0&&(Pr=!0);else return i.lanes=o.lanes,ns(o,i,w)}return Hf(o,i,d,m,w)}function Zk(o,i,d){var m=i.pendingProps,w=m.children,b=o!==null?o.memoizedState:null;if(m.mode==="hidden")if((i.mode&1)===0)i.memoizedState={baseLanes:0,cachePool:null,transitions:null},bn(ta,Xr),Xr|=d;else{if((d&1073741824)===0)return o=b!==null?b.baseLanes|d:d,i.lanes=i.childLanes=1073741824,i.memoizedState={baseLanes:o,cachePool:null,transitions:null},i.updateQueue=null,bn(ta,Xr),Xr|=o,null;i.memoizedState={baseLanes:0,cachePool:null,transitions:null},m=b!==null?b.baseLanes:d,bn(ta,Xr),Xr|=m}else b!==null?(m=b.baseLanes|d,i.memoizedState=null):m=d,bn(ta,Xr),Xr|=m;return Ar(o,i,w,d),i.child}function qk(o,i){var d=i.ref;(o===null&&d!==null||o!==null&&o.ref!==d)&&(i.flags|=512,i.flags|=2097152)}function Hf(o,i,d,m,w){var b=Lr(d)?ni:wr.current;return b=Ki(i,b),Qi(i,w),d=Of(o,i,d,m,b,w),m=$f(),o!==null&&!Pr?(i.updateQueue=o.updateQueue,i.flags&=-2053,o.lanes&=~w,ns(o,i,w)):(Tn&&m&&gf(i),i.flags|=1,Ar(o,i,d,w),i.child)}function Gk(o,i,d,m,w){if(Lr(d)){var b=!0;Tc(i)}else b=!1;if(Qi(i,w),i.stateNode===null)Kc(o,i),Lk(i,d,m),Ff(i,d,m,w),m=!0;else if(o===null){var T=i.stateNode,z=i.memoizedProps;T.props=z;var G=T.context,ce=d.contextType;typeof ce=="object"&&ce!==null?ce=lo(ce):(ce=Lr(d)?ni:wr.current,ce=Ki(i,ce));var Te=d.getDerivedStateFromProps,Ie=typeof Te=="function"||typeof T.getSnapshotBeforeUpdate=="function";Ie||typeof T.UNSAFE_componentWillReceiveProps!="function"&&typeof T.componentWillReceiveProps!="function"||(z!==m||G!==ce)&&Pk(i,T,m,ce),Ns=!1;var Ee=i.memoizedState;T.state=Ee,Lc(i,m,T,w),G=i.memoizedState,z!==m||Ee!==G||Mr.current||Ns?(typeof Te=="function"&&(zf(i,d,Te,m),G=i.memoizedState),(z=Ns||Mk(i,d,z,m,Ee,G,ce))?(Ie||typeof T.UNSAFE_componentWillMount!="function"&&typeof T.componentWillMount!="function"||(typeof T.componentWillMount=="function"&&T.componentWillMount(),typeof T.UNSAFE_componentWillMount=="function"&&T.UNSAFE_componentWillMount()),typeof T.componentDidMount=="function"&&(i.flags|=4194308)):(typeof T.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=m,i.memoizedState=G),T.props=m,T.state=G,T.context=ce,m=z):(typeof T.componentDidMount=="function"&&(i.flags|=4194308),m=!1)}else{T=i.stateNode,uk(o,i),z=i.memoizedProps,ce=i.type===i.elementType?z:xo(i.type,z),T.props=ce,Ie=i.pendingProps,Ee=T.context,G=d.contextType,typeof G=="object"&&G!==null?G=lo(G):(G=Lr(d)?ni:wr.current,G=Ki(i,G));var Ze=d.getDerivedStateFromProps;(Te=typeof Ze=="function"||typeof T.getSnapshotBeforeUpdate=="function")||typeof T.UNSAFE_componentWillReceiveProps!="function"&&typeof T.componentWillReceiveProps!="function"||(z!==Ie||Ee!==G)&&Pk(i,T,m,G),Ns=!1,Ee=i.memoizedState,T.state=Ee,Lc(i,m,T,w);var Ge=i.memoizedState;z!==Ie||Ee!==Ge||Mr.current||Ns?(typeof Ze=="function"&&(zf(i,d,Ze,m),Ge=i.memoizedState),(ce=Ns||Mk(i,d,ce,m,Ee,Ge,G)||!1)?(Te||typeof T.UNSAFE_componentWillUpdate!="function"&&typeof T.componentWillUpdate!="function"||(typeof T.componentWillUpdate=="function"&&T.componentWillUpdate(m,Ge,G),typeof T.UNSAFE_componentWillUpdate=="function"&&T.UNSAFE_componentWillUpdate(m,Ge,G)),typeof T.componentDidUpdate=="function"&&(i.flags|=4),typeof T.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof T.componentDidUpdate!="function"||z===o.memoizedProps&&Ee===o.memoizedState||(i.flags|=4),typeof T.getSnapshotBeforeUpdate!="function"||z===o.memoizedProps&&Ee===o.memoizedState||(i.flags|=1024),i.memoizedProps=m,i.memoizedState=Ge),T.props=m,T.state=Ge,T.context=G,m=ce):(typeof T.componentDidUpdate!="function"||z===o.memoizedProps&&Ee===o.memoizedState||(i.flags|=4),typeof T.getSnapshotBeforeUpdate!="function"||z===o.memoizedProps&&Ee===o.memoizedState||(i.flags|=1024),m=!1)}return Wf(o,i,d,m,b,w)}function Wf(o,i,d,m,w,b){qk(o,i);var T=(i.flags&128)!==0;if(!m&&!T)return w&&Jg(i,d,!1),ns(o,i,b);m=i.stateNode,VS.current=i;var z=T&&typeof d.getDerivedStateFromError!="function"?null:m.render();return i.flags|=1,o!==null&&T?(i.child=Vi(i,o.child,null,b),i.child=Vi(i,null,z,b)):Ar(o,i,z,b),i.memoizedState=m.state,w&&Jg(i,d,!0),i.child}function Vk(o){var i=o.stateNode;i.pendingContext?Qg(o,i.pendingContext,i.pendingContext!==i.context):i.context&&Qg(o,i.context,!1),Tf(o,i.containerInfo)}function Yk(o,i,d,m,w){return Gi(),vf(w),i.flags|=256,Ar(o,i,d,m),i.child}var Kf={dehydrated:null,treeContext:null,retryLane:0};function Zf(o){return{baseLanes:o,cachePool:null,transitions:null}}function Qk(o,i,d){var m=i.pendingProps,w=On.current,b=!1,T=(i.flags&128)!==0,z;if((z=T)||(z=o!==null&&o.memoizedState===null?!1:(w&2)!==0),z?(b=!0,i.flags&=-129):(o===null||o.memoizedState!==null)&&(w|=1),bn(On,w&1),o===null)return wf(i),o=i.memoizedState,o!==null&&(o=o.dehydrated,o!==null)?((i.mode&1)===0?i.lanes=1:o.data==="$!"?i.lanes=8:i.lanes=1073741824,null):(T=m.children,o=m.fallback,b?(m=i.mode,b=i.child,T={mode:"hidden",children:T},(m&1)===0&&b!==null?(b.childLanes=0,b.pendingProps=T):b=ru(T,m,0,null),o=fi(o,m,d,null),b.return=i,o.return=i,b.sibling=o,i.child=b,i.child.memoizedState=Zf(d),i.memoizedState=Kf,o):qf(i,T));if(w=o.memoizedState,w!==null&&(z=w.dehydrated,z!==null))return YS(o,i,T,m,z,w,d);if(b){b=m.fallback,T=i.mode,w=o.child,z=w.sibling;var G={mode:"hidden",children:m.children};return(T&1)===0&&i.child!==w?(m=i.child,m.childLanes=0,m.pendingProps=G,i.deletions=null):(m=Os(w,G),m.subtreeFlags=w.subtreeFlags&14680064),z!==null?b=Os(z,b):(b=fi(b,T,d,null),b.flags|=2),b.return=i,m.return=i,m.sibling=b,i.child=m,m=b,b=i.child,T=o.child.memoizedState,T=T===null?Zf(d):{baseLanes:T.baseLanes|d,cachePool:null,transitions:T.transitions},b.memoizedState=T,b.childLanes=o.childLanes&~d,i.memoizedState=Kf,m}return b=o.child,o=b.sibling,m=Os(b,{mode:"visible",children:m.children}),(i.mode&1)===0&&(m.lanes=d),m.return=i,m.sibling=null,o!==null&&(d=i.deletions,d===null?(i.deletions=[o],i.flags|=16):d.push(o)),i.child=m,i.memoizedState=null,m}function qf(o,i){return i=ru({mode:"visible",children:i},o.mode,0,null),i.return=o,o.child=i}function Wc(o,i,d,m){return m!==null&&vf(m),Vi(i,o.child,null,d),o=qf(i,i.pendingProps.children),o.flags|=2,i.memoizedState=null,o}function YS(o,i,d,m,w,b,T){if(d)return i.flags&256?(i.flags&=-257,m=Bf(Error(n(422))),Wc(o,i,T,m)):i.memoizedState!==null?(i.child=o.child,i.flags|=128,null):(b=m.fallback,w=i.mode,m=ru({mode:"visible",children:m.children},w,0,null),b=fi(b,w,T,null),b.flags|=2,m.return=i,b.return=i,m.sibling=b,i.child=m,(i.mode&1)!==0&&Vi(i,o.child,null,T),i.child.memoizedState=Zf(T),i.memoizedState=Kf,b);if((i.mode&1)===0)return Wc(o,i,T,null);if(w.data==="$!"){if(m=w.nextSibling&&w.nextSibling.dataset,m)var z=m.dgst;return m=z,b=Error(n(419)),m=Bf(b,m,void 0),Wc(o,i,T,m)}if(z=(T&o.childLanes)!==0,Pr||z){if(m=fr,m!==null){switch(T&-T){case 4:w=2;break;case 16:w=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:w=32;break;case 536870912:w=268435456;break;default:w=0}w=(w&(m.suspendedLanes|T))!==0?0:w,w!==0&&w!==b.retryLane&&(b.retryLane=w,es(o,w),So(m,o,w,-1))}return cp(),m=Bf(Error(n(421))),Wc(o,i,T,m)}return w.data==="$?"?(i.flags|=128,i.child=o.child,i=cN.bind(null,o),w._reactRetry=i,null):(o=b.treeContext,Qr=xs(w.nextSibling),Yr=i,Tn=!0,bo=null,o!==null&&(io[ao++]=Xo,io[ao++]=Jo,io[ao++]=ri,Xo=o.id,Jo=o.overflow,ri=i),i=qf(i,m.children),i.flags|=4096,i)}function Xk(o,i,d){o.lanes|=i;var m=o.alternate;m!==null&&(m.lanes|=i),Ef(o.return,i,d)}function Gf(o,i,d,m,w){var b=o.memoizedState;b===null?o.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:m,tail:d,tailMode:w}:(b.isBackwards=i,b.rendering=null,b.renderingStartTime=0,b.last=m,b.tail=d,b.tailMode=w)}function Jk(o,i,d){var m=i.pendingProps,w=m.revealOrder,b=m.tail;if(Ar(o,i,m.children,d),m=On.current,(m&2)!==0)m=m&1|2,i.flags|=128;else{if(o!==null&&(o.flags&128)!==0)e:for(o=i.child;o!==null;){if(o.tag===13)o.memoizedState!==null&&Xk(o,d,i);else if(o.tag===19)Xk(o,d,i);else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===i)break e;for(;o.sibling===null;){if(o.return===null||o.return===i)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}m&=1}if(bn(On,m),(i.mode&1)===0)i.memoizedState=null;else switch(w){case"forwards":for(d=i.child,w=null;d!==null;)o=d.alternate,o!==null&&Pc(o)===null&&(w=d),d=d.sibling;d=w,d===null?(w=i.child,i.child=null):(w=d.sibling,d.sibling=null),Gf(i,!1,w,d,b);break;case"backwards":for(d=null,w=i.child,i.child=null;w!==null;){if(o=w.alternate,o!==null&&Pc(o)===null){i.child=w;break}o=w.sibling,w.sibling=d,d=w,w=o}Gf(i,!0,d,null,b);break;case"together":Gf(i,!1,null,null,void 0);break;default:i.memoizedState=null}return i.child}function Kc(o,i){(i.mode&1)===0&&o!==null&&(o.alternate=null,i.alternate=null,i.flags|=2)}function ns(o,i,d){if(o!==null&&(i.dependencies=o.dependencies),li|=i.lanes,(d&i.childLanes)===0)return null;if(o!==null&&i.child!==o.child)throw Error(n(153));if(i.child!==null){for(o=i.child,d=Os(o,o.pendingProps),i.child=d,d.return=i;o.sibling!==null;)o=o.sibling,d=d.sibling=Os(o,o.pendingProps),d.return=i;d.sibling=null}return i.child}function QS(o,i,d){switch(i.tag){case 3:Vk(i),Gi();break;case 5:pk(i);break;case 1:Lr(i.type)&&Tc(i);break;case 4:Tf(i,i.stateNode.containerInfo);break;case 10:var m=i.type._context,w=i.memoizedProps.value;bn(Oc,m._currentValue),m._currentValue=w;break;case 13:if(m=i.memoizedState,m!==null)return m.dehydrated!==null?(bn(On,On.current&1),i.flags|=128,null):(d&i.child.childLanes)!==0?Qk(o,i,d):(bn(On,On.current&1),o=ns(o,i,d),o!==null?o.sibling:null);bn(On,On.current&1);break;case 19:if(m=(d&i.childLanes)!==0,(o.flags&128)!==0){if(m)return Jk(o,i,d);i.flags|=128}if(w=i.memoizedState,w!==null&&(w.rendering=null,w.tail=null,w.lastEffect=null),bn(On,On.current),m)break;return null;case 22:case 23:return i.lanes=0,Zk(o,i,d)}return ns(o,i,d)}var ey,Vf,ty,ny;ey=function(o,i){for(var d=i.child;d!==null;){if(d.tag===5||d.tag===6)o.appendChild(d.stateNode);else if(d.tag!==4&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===i)break;for(;d.sibling===null;){if(d.return===null||d.return===i)return;d=d.return}d.sibling.return=d.return,d=d.sibling}},Vf=function(){},ty=function(o,i,d,m){var w=o.memoizedProps;if(w!==m){o=i.stateNode,ii(Po.current);var b=null;switch(d){case"input":w=ze(o,w),m=ze(o,m),b=[];break;case"select":w=ne({},w,{value:void 0}),m=ne({},m,{value:void 0}),b=[];break;case"textarea":w=we(o,w),m=we(o,m),b=[];break;default:typeof w.onClick!="function"&&typeof m.onClick=="function"&&(o.onclick=Ec)}Gt(d,m);var T;d=null;for(ce in w)if(!m.hasOwnProperty(ce)&&w.hasOwnProperty(ce)&&w[ce]!=null)if(ce==="style"){var z=w[ce];for(T in z)z.hasOwnProperty(T)&&(d||(d={}),d[T]="")}else ce!=="dangerouslySetInnerHTML"&&ce!=="children"&&ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&ce!=="autoFocus"&&(s.hasOwnProperty(ce)?b||(b=[]):(b=b||[]).push(ce,null));for(ce in m){var G=m[ce];if(z=w!=null?w[ce]:void 0,m.hasOwnProperty(ce)&&G!==z&&(G!=null||z!=null))if(ce==="style")if(z){for(T in z)!z.hasOwnProperty(T)||G&&G.hasOwnProperty(T)||(d||(d={}),d[T]="");for(T in G)G.hasOwnProperty(T)&&z[T]!==G[T]&&(d||(d={}),d[T]=G[T])}else d||(b||(b=[]),b.push(ce,d)),d=G;else ce==="dangerouslySetInnerHTML"?(G=G?G.__html:void 0,z=z?z.__html:void 0,G!=null&&z!==G&&(b=b||[]).push(ce,G)):ce==="children"?typeof G!="string"&&typeof G!="number"||(b=b||[]).push(ce,""+G):ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&(s.hasOwnProperty(ce)?(G!=null&&ce==="onScroll"&&En("scroll",o),b||z===G||(b=[])):(b=b||[]).push(ce,G))}d&&(b=b||[]).push("style",d);var ce=b;(i.updateQueue=ce)&&(i.flags|=4)}},ny=function(o,i,d,m){d!==m&&(i.flags|=4)};function sl(o,i){if(!Tn)switch(o.tailMode){case"hidden":i=o.tail;for(var d=null;i!==null;)i.alternate!==null&&(d=i),i=i.sibling;d===null?o.tail=null:d.sibling=null;break;case"collapsed":d=o.tail;for(var m=null;d!==null;)d.alternate!==null&&(m=d),d=d.sibling;m===null?i||o.tail===null?o.tail=null:o.tail.sibling=null:m.sibling=null}}function br(o){var i=o.alternate!==null&&o.alternate.child===o.child,d=0,m=0;if(i)for(var w=o.child;w!==null;)d|=w.lanes|w.childLanes,m|=w.subtreeFlags&14680064,m|=w.flags&14680064,w.return=o,w=w.sibling;else for(w=o.child;w!==null;)d|=w.lanes|w.childLanes,m|=w.subtreeFlags,m|=w.flags,w.return=o,w=w.sibling;return o.subtreeFlags|=m,o.childLanes=d,i}function XS(o,i,d){var m=i.pendingProps;switch(kf(i),i.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return br(i),null;case 1:return Lr(i.type)&&Nc(),br(i),null;case 3:return m=i.stateNode,Xi(),Sn(Mr),Sn(wr),Af(),m.pendingContext&&(m.context=m.pendingContext,m.pendingContext=null),(o===null||o.child===null)&&(Ic(i)?i.flags|=4:o===null||o.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,bo!==null&&(ip(bo),bo=null))),Vf(o,i),br(i),null;case 5:jf(i);var w=ii(el.current);if(d=i.type,o!==null&&i.stateNode!=null)ty(o,i,d,m,w),o.ref!==i.ref&&(i.flags|=512,i.flags|=2097152);else{if(!m){if(i.stateNode===null)throw Error(n(166));return br(i),null}if(o=ii(Po.current),Ic(i)){m=i.stateNode,d=i.type;var b=i.memoizedProps;switch(m[Lo]=i,m[Va]=b,o=(i.mode&1)!==0,d){case"dialog":En("cancel",m),En("close",m);break;case"iframe":case"object":case"embed":En("load",m);break;case"video":case"audio":for(w=0;w<Za.length;w++)En(Za[w],m);break;case"source":En("error",m);break;case"img":case"image":case"link":En("error",m),En("load",m);break;case"details":En("toggle",m);break;case"input":it(m,b),En("invalid",m);break;case"select":m._wrapperState={wasMultiple:!!b.multiple},En("invalid",m);break;case"textarea":Qe(m,b),En("invalid",m)}Gt(d,b),w=null;for(var T in b)if(b.hasOwnProperty(T)){var z=b[T];T==="children"?typeof z=="string"?m.textContent!==z&&(b.suppressHydrationWarning!==!0&&_c(m.textContent,z,o),w=["children",z]):typeof z=="number"&&m.textContent!==""+z&&(b.suppressHydrationWarning!==!0&&_c(m.textContent,z,o),w=["children",""+z]):s.hasOwnProperty(T)&&z!=null&&T==="onScroll"&&En("scroll",m)}switch(d){case"input":Z(m),kt(m,b,!0);break;case"textarea":Z(m),Oe(m);break;case"select":case"option":break;default:typeof b.onClick=="function"&&(m.onclick=Ec)}m=w,i.updateQueue=m,m!==null&&(i.flags|=4)}else{T=w.nodeType===9?w:w.ownerDocument,o==="http://www.w3.org/1999/xhtml"&&(o=Mt(d)),o==="http://www.w3.org/1999/xhtml"?d==="script"?(o=T.createElement("div"),o.innerHTML="<script><\/script>",o=o.removeChild(o.firstChild)):typeof m.is=="string"?o=T.createElement(d,{is:m.is}):(o=T.createElement(d),d==="select"&&(T=o,m.multiple?T.multiple=!0:m.size&&(T.size=m.size))):o=T.createElementNS(o,d),o[Lo]=i,o[Va]=m,ey(o,i,!1,!1),i.stateNode=o;e:{switch(T=pn(d,m),d){case"dialog":En("cancel",o),En("close",o),w=m;break;case"iframe":case"object":case"embed":En("load",o),w=m;break;case"video":case"audio":for(w=0;w<Za.length;w++)En(Za[w],o);w=m;break;case"source":En("error",o),w=m;break;case"img":case"image":case"link":En("error",o),En("load",o),w=m;break;case"details":En("toggle",o),w=m;break;case"input":it(o,m),w=ze(o,m),En("invalid",o);break;case"option":w=m;break;case"select":o._wrapperState={wasMultiple:!!m.multiple},w=ne({},m,{value:void 0}),En("invalid",o);break;case"textarea":Qe(o,m),w=we(o,m),En("invalid",o);break;default:w=m}Gt(d,w),z=w;for(b in z)if(z.hasOwnProperty(b)){var G=z[b];b==="style"?Ut(o,G):b==="dangerouslySetInnerHTML"?(G=G?G.__html:void 0,G!=null&&Dn(o,G)):b==="children"?typeof G=="string"?(d!=="textarea"||G!=="")&&Lt(o,G):typeof G=="number"&&Lt(o,""+G):b!=="suppressContentEditableWarning"&&b!=="suppressHydrationWarning"&&b!=="autoFocus"&&(s.hasOwnProperty(b)?G!=null&&b==="onScroll"&&En("scroll",o):G!=null&&N(o,b,G,T))}switch(d){case"input":Z(o),kt(o,m,!1);break;case"textarea":Z(o),Oe(o);break;case"option":m.value!=null&&o.setAttribute("value",""+xe(m.value));break;case"select":o.multiple=!!m.multiple,b=m.value,b!=null?X(o,!!m.multiple,b,!1):m.defaultValue!=null&&X(o,!!m.multiple,m.defaultValue,!0);break;default:typeof w.onClick=="function"&&(o.onclick=Ec)}switch(d){case"button":case"input":case"select":case"textarea":m=!!m.autoFocus;break e;case"img":m=!0;break e;default:m=!1}}m&&(i.flags|=4)}i.ref!==null&&(i.flags|=512,i.flags|=2097152)}return br(i),null;case 6:if(o&&i.stateNode!=null)ny(o,i,o.memoizedProps,m);else{if(typeof m!="string"&&i.stateNode===null)throw Error(n(166));if(d=ii(el.current),ii(Po.current),Ic(i)){if(m=i.stateNode,d=i.memoizedProps,m[Lo]=i,(b=m.nodeValue!==d)&&(o=Yr,o!==null))switch(o.tag){case 3:_c(m.nodeValue,d,(o.mode&1)!==0);break;case 5:o.memoizedProps.suppressHydrationWarning!==!0&&_c(m.nodeValue,d,(o.mode&1)!==0)}b&&(i.flags|=4)}else m=(d.nodeType===9?d:d.ownerDocument).createTextNode(m),m[Lo]=i,i.stateNode=m}return br(i),null;case 13:if(Sn(On),m=i.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(Tn&&Qr!==null&&(i.mode&1)!==0&&(i.flags&128)===0)sk(),Gi(),i.flags|=98560,b=!1;else if(b=Ic(i),m!==null&&m.dehydrated!==null){if(o===null){if(!b)throw Error(n(318));if(b=i.memoizedState,b=b!==null?b.dehydrated:null,!b)throw Error(n(317));b[Lo]=i}else Gi(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;br(i),b=!1}else bo!==null&&(ip(bo),bo=null),b=!0;if(!b)return i.flags&65536?i:null}return(i.flags&128)!==0?(i.lanes=d,i):(m=m!==null,m!==(o!==null&&o.memoizedState!==null)&&m&&(i.child.flags|=8192,(i.mode&1)!==0&&(o===null||(On.current&1)!==0?nr===0&&(nr=3):cp())),i.updateQueue!==null&&(i.flags|=4),br(i),null);case 4:return Xi(),Vf(o,i),o===null&&qa(i.stateNode.containerInfo),br(i),null;case 10:return _f(i.type._context),br(i),null;case 17:return Lr(i.type)&&Nc(),br(i),null;case 19:if(Sn(On),b=i.memoizedState,b===null)return br(i),null;if(m=(i.flags&128)!==0,T=b.rendering,T===null)if(m)sl(b,!1);else{if(nr!==0||o!==null&&(o.flags&128)!==0)for(o=i.child;o!==null;){if(T=Pc(o),T!==null){for(i.flags|=128,sl(b,!1),m=T.updateQueue,m!==null&&(i.updateQueue=m,i.flags|=4),i.subtreeFlags=0,m=d,d=i.child;d!==null;)b=d,o=m,b.flags&=14680066,T=b.alternate,T===null?(b.childLanes=0,b.lanes=o,b.child=null,b.subtreeFlags=0,b.memoizedProps=null,b.memoizedState=null,b.updateQueue=null,b.dependencies=null,b.stateNode=null):(b.childLanes=T.childLanes,b.lanes=T.lanes,b.child=T.child,b.subtreeFlags=0,b.deletions=null,b.memoizedProps=T.memoizedProps,b.memoizedState=T.memoizedState,b.updateQueue=T.updateQueue,b.type=T.type,o=T.dependencies,b.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),d=d.sibling;return bn(On,On.current&1|2),i.child}o=o.sibling}b.tail!==null&&Vt()>na&&(i.flags|=128,m=!0,sl(b,!1),i.lanes=4194304)}else{if(!m)if(o=Pc(T),o!==null){if(i.flags|=128,m=!0,d=o.updateQueue,d!==null&&(i.updateQueue=d,i.flags|=4),sl(b,!0),b.tail===null&&b.tailMode==="hidden"&&!T.alternate&&!Tn)return br(i),null}else 2*Vt()-b.renderingStartTime>na&&d!==1073741824&&(i.flags|=128,m=!0,sl(b,!1),i.lanes=4194304);b.isBackwards?(T.sibling=i.child,i.child=T):(d=b.last,d!==null?d.sibling=T:i.child=T,b.last=T)}return b.tail!==null?(i=b.tail,b.rendering=i,b.tail=i.sibling,b.renderingStartTime=Vt(),i.sibling=null,d=On.current,bn(On,m?d&1|2:d&1),i):(br(i),null);case 22:case 23:return lp(),m=i.memoizedState!==null,o!==null&&o.memoizedState!==null!==m&&(i.flags|=8192),m&&(i.mode&1)!==0?(Xr&1073741824)!==0&&(br(i),i.subtreeFlags&6&&(i.flags|=8192)):br(i),null;case 24:return null;case 25:return null}throw Error(n(156,i.tag))}function JS(o,i){switch(kf(i),i.tag){case 1:return Lr(i.type)&&Nc(),o=i.flags,o&65536?(i.flags=o&-65537|128,i):null;case 3:return Xi(),Sn(Mr),Sn(wr),Af(),o=i.flags,(o&65536)!==0&&(o&128)===0?(i.flags=o&-65537|128,i):null;case 5:return jf(i),null;case 13:if(Sn(On),o=i.memoizedState,o!==null&&o.dehydrated!==null){if(i.alternate===null)throw Error(n(340));Gi()}return o=i.flags,o&65536?(i.flags=o&-65537|128,i):null;case 19:return Sn(On),null;case 4:return Xi(),null;case 10:return _f(i.type._context),null;case 22:case 23:return lp(),null;case 24:return null;default:return null}}var Zc=!1,xr=!1,eN=typeof WeakSet=="function"?WeakSet:Set,qe=null;function ea(o,i){var d=o.ref;if(d!==null)if(typeof d=="function")try{d(null)}catch(m){Bn(o,i,m)}else d.current=null}function Yf(o,i,d){try{d()}catch(m){Bn(o,i,m)}}var ry=!1;function tN(o,i){if(lf=Ys,o=Mg(),Jd(o)){if("selectionStart"in o)var d={start:o.selectionStart,end:o.selectionEnd};else e:{d=(d=o.ownerDocument)&&d.defaultView||window;var m=d.getSelection&&d.getSelection();if(m&&m.rangeCount!==0){d=m.anchorNode;var w=m.anchorOffset,b=m.focusNode;m=m.focusOffset;try{d.nodeType,b.nodeType}catch{d=null;break e}var T=0,z=-1,G=-1,ce=0,Te=0,Ie=o,Ee=null;t:for(;;){for(var Ze;Ie!==d||w!==0&&Ie.nodeType!==3||(z=T+w),Ie!==b||m!==0&&Ie.nodeType!==3||(G=T+m),Ie.nodeType===3&&(T+=Ie.nodeValue.length),(Ze=Ie.firstChild)!==null;)Ee=Ie,Ie=Ze;for(;;){if(Ie===o)break t;if(Ee===d&&++ce===w&&(z=T),Ee===b&&++Te===m&&(G=T),(Ze=Ie.nextSibling)!==null)break;Ie=Ee,Ee=Ie.parentNode}Ie=Ze}d=z===-1||G===-1?null:{start:z,end:G}}else d=null}d=d||{start:0,end:0}}else d=null;for(cf={focusedElem:o,selectionRange:d},Ys=!1,qe=i;qe!==null;)if(i=qe,o=i.child,(i.subtreeFlags&1028)!==0&&o!==null)o.return=i,qe=o;else for(;qe!==null;){i=qe;try{var Ge=i.alternate;if((i.flags&1024)!==0)switch(i.tag){case 0:case 11:case 15:break;case 1:if(Ge!==null){var Ye=Ge.memoizedProps,Kn=Ge.memoizedState,re=i.stateNode,Q=re.getSnapshotBeforeUpdate(i.elementType===i.type?Ye:xo(i.type,Ye),Kn);re.__reactInternalSnapshotBeforeUpdate=Q}break;case 3:var ie=i.stateNode.containerInfo;ie.nodeType===1?ie.textContent="":ie.nodeType===9&&ie.documentElement&&ie.removeChild(ie.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Me){Bn(i,i.return,Me)}if(o=i.sibling,o!==null){o.return=i.return,qe=o;break}qe=i.return}return Ge=ry,ry=!1,Ge}function il(o,i,d){var m=i.updateQueue;if(m=m!==null?m.lastEffect:null,m!==null){var w=m=m.next;do{if((w.tag&o)===o){var b=w.destroy;w.destroy=void 0,b!==void 0&&Yf(i,d,b)}w=w.next}while(w!==m)}}function qc(o,i){if(i=i.updateQueue,i=i!==null?i.lastEffect:null,i!==null){var d=i=i.next;do{if((d.tag&o)===o){var m=d.create;d.destroy=m()}d=d.next}while(d!==i)}}function Qf(o){var i=o.ref;if(i!==null){var d=o.stateNode;switch(o.tag){case 5:o=d;break;default:o=d}typeof i=="function"?i(o):i.current=o}}function oy(o){var i=o.alternate;i!==null&&(o.alternate=null,oy(i)),o.child=null,o.deletions=null,o.sibling=null,o.tag===5&&(i=o.stateNode,i!==null&&(delete i[Lo],delete i[Va],delete i[pf],delete i[PS],delete i[DS])),o.stateNode=null,o.return=null,o.dependencies=null,o.memoizedProps=null,o.memoizedState=null,o.pendingProps=null,o.stateNode=null,o.updateQueue=null}function sy(o){return o.tag===5||o.tag===3||o.tag===4}function iy(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||sy(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function Xf(o,i,d){var m=o.tag;if(m===5||m===6)o=o.stateNode,i?d.nodeType===8?d.parentNode.insertBefore(o,i):d.insertBefore(o,i):(d.nodeType===8?(i=d.parentNode,i.insertBefore(o,d)):(i=d,i.appendChild(o)),d=d._reactRootContainer,d!=null||i.onclick!==null||(i.onclick=Ec));else if(m!==4&&(o=o.child,o!==null))for(Xf(o,i,d),o=o.sibling;o!==null;)Xf(o,i,d),o=o.sibling}function Jf(o,i,d){var m=o.tag;if(m===5||m===6)o=o.stateNode,i?d.insertBefore(o,i):d.appendChild(o);else if(m!==4&&(o=o.child,o!==null))for(Jf(o,i,d),o=o.sibling;o!==null;)Jf(o,i,d),o=o.sibling}var gr=null,_o=!1;function js(o,i,d){for(d=d.child;d!==null;)ay(o,i,d),d=d.sibling}function ay(o,i,d){if(ft&&typeof ft.onCommitFiberUnmount=="function")try{ft.onCommitFiberUnmount(yt,d)}catch{}switch(d.tag){case 5:xr||ea(d,i);case 6:var m=gr,w=_o;gr=null,js(o,i,d),gr=m,_o=w,gr!==null&&(_o?(o=gr,d=d.stateNode,o.nodeType===8?o.parentNode.removeChild(d):o.removeChild(d)):gr.removeChild(d.stateNode));break;case 18:gr!==null&&(_o?(o=gr,d=d.stateNode,o.nodeType===8?ff(o.parentNode,d):o.nodeType===1&&ff(o,d),ms(o)):ff(gr,d.stateNode));break;case 4:m=gr,w=_o,gr=d.stateNode.containerInfo,_o=!0,js(o,i,d),gr=m,_o=w;break;case 0:case 11:case 14:case 15:if(!xr&&(m=d.updateQueue,m!==null&&(m=m.lastEffect,m!==null))){w=m=m.next;do{var b=w,T=b.destroy;b=b.tag,T!==void 0&&((b&2)!==0||(b&4)!==0)&&Yf(d,i,T),w=w.next}while(w!==m)}js(o,i,d);break;case 1:if(!xr&&(ea(d,i),m=d.stateNode,typeof m.componentWillUnmount=="function"))try{m.props=d.memoizedProps,m.state=d.memoizedState,m.componentWillUnmount()}catch(z){Bn(d,i,z)}js(o,i,d);break;case 21:js(o,i,d);break;case 22:d.mode&1?(xr=(m=xr)||d.memoizedState!==null,js(o,i,d),xr=m):js(o,i,d);break;default:js(o,i,d)}}function ly(o){var i=o.updateQueue;if(i!==null){o.updateQueue=null;var d=o.stateNode;d===null&&(d=o.stateNode=new eN),i.forEach(function(m){var w=uN.bind(null,o,m);d.has(m)||(d.add(m),m.then(w,w))})}}function Eo(o,i){var d=i.deletions;if(d!==null)for(var m=0;m<d.length;m++){var w=d[m];try{var b=o,T=i,z=T;e:for(;z!==null;){switch(z.tag){case 5:gr=z.stateNode,_o=!1;break e;case 3:gr=z.stateNode.containerInfo,_o=!0;break e;case 4:gr=z.stateNode.containerInfo,_o=!0;break e}z=z.return}if(gr===null)throw Error(n(160));ay(b,T,w),gr=null,_o=!1;var G=w.alternate;G!==null&&(G.return=null),w.return=null}catch(ce){Bn(w,i,ce)}}if(i.subtreeFlags&12854)for(i=i.child;i!==null;)cy(i,o),i=i.sibling}function cy(o,i){var d=o.alternate,m=o.flags;switch(o.tag){case 0:case 11:case 14:case 15:if(Eo(i,o),zo(o),m&4){try{il(3,o,o.return),qc(3,o)}catch(Ye){Bn(o,o.return,Ye)}try{il(5,o,o.return)}catch(Ye){Bn(o,o.return,Ye)}}break;case 1:Eo(i,o),zo(o),m&512&&d!==null&&ea(d,d.return);break;case 5:if(Eo(i,o),zo(o),m&512&&d!==null&&ea(d,d.return),o.flags&32){var w=o.stateNode;try{Lt(w,"")}catch(Ye){Bn(o,o.return,Ye)}}if(m&4&&(w=o.stateNode,w!=null)){var b=o.memoizedProps,T=d!==null?d.memoizedProps:b,z=o.type,G=o.updateQueue;if(o.updateQueue=null,G!==null)try{z==="input"&&b.type==="radio"&&b.name!=null&&Je(w,b),pn(z,T);var ce=pn(z,b);for(T=0;T<G.length;T+=2){var Te=G[T],Ie=G[T+1];Te==="style"?Ut(w,Ie):Te==="dangerouslySetInnerHTML"?Dn(w,Ie):Te==="children"?Lt(w,Ie):N(w,Te,Ie,ce)}switch(z){case"input":en(w,b);break;case"textarea":he(w,b);break;case"select":var Ee=w._wrapperState.wasMultiple;w._wrapperState.wasMultiple=!!b.multiple;var Ze=b.value;Ze!=null?X(w,!!b.multiple,Ze,!1):Ee!==!!b.multiple&&(b.defaultValue!=null?X(w,!!b.multiple,b.defaultValue,!0):X(w,!!b.multiple,b.multiple?[]:"",!1))}w[Va]=b}catch(Ye){Bn(o,o.return,Ye)}}break;case 6:if(Eo(i,o),zo(o),m&4){if(o.stateNode===null)throw Error(n(162));w=o.stateNode,b=o.memoizedProps;try{w.nodeValue=b}catch(Ye){Bn(o,o.return,Ye)}}break;case 3:if(Eo(i,o),zo(o),m&4&&d!==null&&d.memoizedState.isDehydrated)try{ms(i.containerInfo)}catch(Ye){Bn(o,o.return,Ye)}break;case 4:Eo(i,o),zo(o);break;case 13:Eo(i,o),zo(o),w=o.child,w.flags&8192&&(b=w.memoizedState!==null,w.stateNode.isHidden=b,!b||w.alternate!==null&&w.alternate.memoizedState!==null||(np=Vt())),m&4&&ly(o);break;case 22:if(Te=d!==null&&d.memoizedState!==null,o.mode&1?(xr=(ce=xr)||Te,Eo(i,o),xr=ce):Eo(i,o),zo(o),m&8192){if(ce=o.memoizedState!==null,(o.stateNode.isHidden=ce)&&!Te&&(o.mode&1)!==0)for(qe=o,Te=o.child;Te!==null;){for(Ie=qe=Te;qe!==null;){switch(Ee=qe,Ze=Ee.child,Ee.tag){case 0:case 11:case 14:case 15:il(4,Ee,Ee.return);break;case 1:ea(Ee,Ee.return);var Ge=Ee.stateNode;if(typeof Ge.componentWillUnmount=="function"){m=Ee,d=Ee.return;try{i=m,Ge.props=i.memoizedProps,Ge.state=i.memoizedState,Ge.componentWillUnmount()}catch(Ye){Bn(m,d,Ye)}}break;case 5:ea(Ee,Ee.return);break;case 22:if(Ee.memoizedState!==null){fy(Ie);continue}}Ze!==null?(Ze.return=Ee,qe=Ze):fy(Ie)}Te=Te.sibling}e:for(Te=null,Ie=o;;){if(Ie.tag===5){if(Te===null){Te=Ie;try{w=Ie.stateNode,ce?(b=w.style,typeof b.setProperty=="function"?b.setProperty("display","none","important"):b.display="none"):(z=Ie.stateNode,G=Ie.memoizedProps.style,T=G!=null&&G.hasOwnProperty("display")?G.display:null,z.style.display=nn("display",T))}catch(Ye){Bn(o,o.return,Ye)}}}else if(Ie.tag===6){if(Te===null)try{Ie.stateNode.nodeValue=ce?"":Ie.memoizedProps}catch(Ye){Bn(o,o.return,Ye)}}else if((Ie.tag!==22&&Ie.tag!==23||Ie.memoizedState===null||Ie===o)&&Ie.child!==null){Ie.child.return=Ie,Ie=Ie.child;continue}if(Ie===o)break e;for(;Ie.sibling===null;){if(Ie.return===null||Ie.return===o)break e;Te===Ie&&(Te=null),Ie=Ie.return}Te===Ie&&(Te=null),Ie.sibling.return=Ie.return,Ie=Ie.sibling}}break;case 19:Eo(i,o),zo(o),m&4&&ly(o);break;case 21:break;default:Eo(i,o),zo(o)}}function zo(o){var i=o.flags;if(i&2){try{e:{for(var d=o.return;d!==null;){if(sy(d)){var m=d;break e}d=d.return}throw Error(n(160))}switch(m.tag){case 5:var w=m.stateNode;m.flags&32&&(Lt(w,""),m.flags&=-33);var b=iy(o);Jf(o,b,w);break;case 3:case 4:var T=m.stateNode.containerInfo,z=iy(o);Xf(o,z,T);break;default:throw Error(n(161))}}catch(G){Bn(o,o.return,G)}o.flags&=-3}i&4096&&(o.flags&=-4097)}function nN(o,i,d){qe=o,uy(o)}function uy(o,i,d){for(var m=(o.mode&1)!==0;qe!==null;){var w=qe,b=w.child;if(w.tag===22&&m){var T=w.memoizedState!==null||Zc;if(!T){var z=w.alternate,G=z!==null&&z.memoizedState!==null||xr;z=Zc;var ce=xr;if(Zc=T,(xr=G)&&!ce)for(qe=w;qe!==null;)T=qe,G=T.child,T.tag===22&&T.memoizedState!==null?py(w):G!==null?(G.return=T,qe=G):py(w);for(;b!==null;)qe=b,uy(b),b=b.sibling;qe=w,Zc=z,xr=ce}dy(o)}else(w.subtreeFlags&8772)!==0&&b!==null?(b.return=w,qe=b):dy(o)}}function dy(o){for(;qe!==null;){var i=qe;if((i.flags&8772)!==0){var d=i.alternate;try{if((i.flags&8772)!==0)switch(i.tag){case 0:case 11:case 15:xr||qc(5,i);break;case 1:var m=i.stateNode;if(i.flags&4&&!xr)if(d===null)m.componentDidMount();else{var w=i.elementType===i.type?d.memoizedProps:xo(i.type,d.memoizedProps);m.componentDidUpdate(w,d.memoizedState,m.__reactInternalSnapshotBeforeUpdate)}var b=i.updateQueue;b!==null&&fk(i,b,m);break;case 3:var T=i.updateQueue;if(T!==null){if(d=null,i.child!==null)switch(i.child.tag){case 5:d=i.child.stateNode;break;case 1:d=i.child.stateNode}fk(i,T,d)}break;case 5:var z=i.stateNode;if(d===null&&i.flags&4){d=z;var G=i.memoizedProps;switch(i.type){case"button":case"input":case"select":case"textarea":G.autoFocus&&d.focus();break;case"img":G.src&&(d.src=G.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(i.memoizedState===null){var ce=i.alternate;if(ce!==null){var Te=ce.memoizedState;if(Te!==null){var Ie=Te.dehydrated;Ie!==null&&ms(Ie)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}xr||i.flags&512&&Qf(i)}catch(Ee){Bn(i,i.return,Ee)}}if(i===o){qe=null;break}if(d=i.sibling,d!==null){d.return=i.return,qe=d;break}qe=i.return}}function fy(o){for(;qe!==null;){var i=qe;if(i===o){qe=null;break}var d=i.sibling;if(d!==null){d.return=i.return,qe=d;break}qe=i.return}}function py(o){for(;qe!==null;){var i=qe;try{switch(i.tag){case 0:case 11:case 15:var d=i.return;try{qc(4,i)}catch(G){Bn(i,d,G)}break;case 1:var m=i.stateNode;if(typeof m.componentDidMount=="function"){var w=i.return;try{m.componentDidMount()}catch(G){Bn(i,w,G)}}var b=i.return;try{Qf(i)}catch(G){Bn(i,b,G)}break;case 5:var T=i.return;try{Qf(i)}catch(G){Bn(i,T,G)}}}catch(G){Bn(i,i.return,G)}if(i===o){qe=null;break}var z=i.sibling;if(z!==null){z.return=i.return,qe=z;break}qe=i.return}}var rN=Math.ceil,Gc=M.ReactCurrentDispatcher,ep=M.ReactCurrentOwner,uo=M.ReactCurrentBatchConfig,Zt=0,fr=null,Gn=null,kr=0,Xr=0,ta=_s(0),nr=0,al=null,li=0,Vc=0,tp=0,ll=null,Dr=null,np=0,na=1/0,rs=null,Yc=!1,rp=null,Cs=null,Qc=!1,As=null,Xc=0,cl=0,op=null,Jc=-1,eu=0;function Ir(){return(Zt&6)!==0?Vt():Jc!==-1?Jc:Jc=Vt()}function Is(o){return(o.mode&1)===0?1:(Zt&2)!==0&&kr!==0?kr&-kr:FS.transition!==null?(eu===0&&(eu=ps()),eu):(o=Ot,o!==0||(o=window.event,o=o===void 0?16:Da(o.type)),o)}function So(o,i,d,m){if(50<cl)throw cl=0,op=null,Error(n(185));Tr(o,d,m),((Zt&2)===0||o!==fr)&&(o===fr&&((Zt&2)===0&&(Vc|=d),nr===4&&Rs(o,kr)),zr(o,m),d===1&&Zt===0&&(i.mode&1)===0&&(na=Vt()+500,jc&&Ss()))}function zr(o,i){var d=o.callbackNode;Gr(o,i);var m=vn(o,o===fr?kr:0);if(m===0)d!==null&&In(d),o.callbackNode=null,o.callbackPriority=0;else if(i=m&-m,o.callbackPriority!==i){if(d!=null&&In(d),i===1)o.tag===0?zS(my.bind(null,o)):ek(my.bind(null,o)),MS(function(){(Zt&6)===0&&Ss()}),d=null;else{switch(lt(m)){case 1:d=so;break;case 4:d=dt;break;case 16:d=Zn;break;case 536870912:d=Ue;break;default:d=Zn}d=_y(d,hy.bind(null,o))}o.callbackPriority=i,o.callbackNode=d}}function hy(o,i){if(Jc=-1,eu=0,(Zt&6)!==0)throw Error(n(327));var d=o.callbackNode;if(ra()&&o.callbackNode!==d)return null;var m=vn(o,o===fr?kr:0);if(m===0)return null;if((m&30)!==0||(m&o.expiredLanes)!==0||i)i=tu(o,m);else{i=m;var w=Zt;Zt|=2;var b=ky();(fr!==o||kr!==i)&&(rs=null,na=Vt()+500,ui(o,i));do try{iN();break}catch(z){gy(o,z)}while(!0);xf(),Gc.current=b,Zt=w,Gn!==null?i=0:(fr=null,kr=0,i=nr)}if(i!==0){if(i===2&&(w=Hn(o),w!==0&&(m=w,i=sp(o,w))),i===1)throw d=al,ui(o,0),Rs(o,m),zr(o,Vt()),d;if(i===6)Rs(o,m);else{if(w=o.current.alternate,(m&30)===0&&!oN(w)&&(i=tu(o,m),i===2&&(b=Hn(o),b!==0&&(m=b,i=sp(o,b))),i===1))throw d=al,ui(o,0),Rs(o,m),zr(o,Vt()),d;switch(o.finishedWork=w,o.finishedLanes=m,i){case 0:case 1:throw Error(n(345));case 2:di(o,Dr,rs);break;case 3:if(Rs(o,m),(m&130023424)===m&&(i=np+500-Vt(),10<i)){if(vn(o,0)!==0)break;if(w=o.suspendedLanes,(w&m)!==m){Ir(),o.pingedLanes|=o.suspendedLanes&w;break}o.timeoutHandle=df(di.bind(null,o,Dr,rs),i);break}di(o,Dr,rs);break;case 4:if(Rs(o,m),(m&4194240)===m)break;for(i=o.eventTimes,w=-1;0<m;){var T=31-Qt(m);b=1<<T,T=i[T],T>w&&(w=T),m&=~b}if(m=w,m=Vt()-m,m=(120>m?120:480>m?480:1080>m?1080:1920>m?1920:3e3>m?3e3:4320>m?4320:1960*rN(m/1960))-m,10<m){o.timeoutHandle=df(di.bind(null,o,Dr,rs),m);break}di(o,Dr,rs);break;case 5:di(o,Dr,rs);break;default:throw Error(n(329))}}}return zr(o,Vt()),o.callbackNode===d?hy.bind(null,o):null}function sp(o,i){var d=ll;return o.current.memoizedState.isDehydrated&&(ui(o,i).flags|=256),o=tu(o,i),o!==2&&(i=Dr,Dr=d,i!==null&&ip(i)),o}function ip(o){Dr===null?Dr=o:Dr.push.apply(Dr,o)}function oN(o){for(var i=o;;){if(i.flags&16384){var d=i.updateQueue;if(d!==null&&(d=d.stores,d!==null))for(var m=0;m<d.length;m++){var w=d[m],b=w.getSnapshot;w=w.value;try{if(!vo(b(),w))return!1}catch{return!1}}}if(d=i.child,i.subtreeFlags&16384&&d!==null)d.return=i,i=d;else{if(i===o)break;for(;i.sibling===null;){if(i.return===null||i.return===o)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function Rs(o,i){for(i&=~tp,i&=~Vc,o.suspendedLanes|=i,o.pingedLanes&=~i,o=o.expirationTimes;0<i;){var d=31-Qt(i),m=1<<d;o[d]=-1,i&=~m}}function my(o){if((Zt&6)!==0)throw Error(n(327));ra();var i=vn(o,0);if((i&1)===0)return zr(o,Vt()),null;var d=tu(o,i);if(o.tag!==0&&d===2){var m=Hn(o);m!==0&&(i=m,d=sp(o,m))}if(d===1)throw d=al,ui(o,0),Rs(o,i),zr(o,Vt()),d;if(d===6)throw Error(n(345));return o.finishedWork=o.current.alternate,o.finishedLanes=i,di(o,Dr,rs),zr(o,Vt()),null}function ap(o,i){var d=Zt;Zt|=1;try{return o(i)}finally{Zt=d,Zt===0&&(na=Vt()+500,jc&&Ss())}}function ci(o){As!==null&&As.tag===0&&(Zt&6)===0&&ra();var i=Zt;Zt|=1;var d=uo.transition,m=Ot;try{if(uo.transition=null,Ot=1,o)return o()}finally{Ot=m,uo.transition=d,Zt=i,(Zt&6)===0&&Ss()}}function lp(){Xr=ta.current,Sn(ta)}function ui(o,i){o.finishedWork=null,o.finishedLanes=0;var d=o.timeoutHandle;if(d!==-1&&(o.timeoutHandle=-1,$S(d)),Gn!==null)for(d=Gn.return;d!==null;){var m=d;switch(kf(m),m.tag){case 1:m=m.type.childContextTypes,m!=null&&Nc();break;case 3:Xi(),Sn(Mr),Sn(wr),Af();break;case 5:jf(m);break;case 4:Xi();break;case 13:Sn(On);break;case 19:Sn(On);break;case 10:_f(m.type._context);break;case 22:case 23:lp()}d=d.return}if(fr=o,Gn=o=Os(o.current,null),kr=Xr=i,nr=0,al=null,tp=Vc=li=0,Dr=ll=null,si!==null){for(i=0;i<si.length;i++)if(d=si[i],m=d.interleaved,m!==null){d.interleaved=null;var w=m.next,b=d.pending;if(b!==null){var T=b.next;b.next=w,m.next=T}d.pending=m}si=null}return o}function gy(o,i){do{var d=Gn;try{if(xf(),Dc.current=Uc,zc){for(var m=$n.memoizedState;m!==null;){var w=m.queue;w!==null&&(w.pending=null),m=m.next}zc=!1}if(ai=0,dr=tr=$n=null,tl=!1,nl=0,ep.current=null,d===null||d.return===null){nr=1,al=i,Gn=null;break}e:{var b=o,T=d.return,z=d,G=i;if(i=kr,z.flags|=32768,G!==null&&typeof G=="object"&&typeof G.then=="function"){var ce=G,Te=z,Ie=Te.tag;if((Te.mode&1)===0&&(Ie===0||Ie===11||Ie===15)){var Ee=Te.alternate;Ee?(Te.updateQueue=Ee.updateQueue,Te.memoizedState=Ee.memoizedState,Te.lanes=Ee.lanes):(Te.updateQueue=null,Te.memoizedState=null)}var Ze=Bk(T);if(Ze!==null){Ze.flags&=-257,Uk(Ze,T,z,b,i),Ze.mode&1&&Fk(b,ce,i),i=Ze,G=ce;var Ge=i.updateQueue;if(Ge===null){var Ye=new Set;Ye.add(G),i.updateQueue=Ye}else Ge.add(G);break e}else{if((i&1)===0){Fk(b,ce,i),cp();break e}G=Error(n(426))}}else if(Tn&&z.mode&1){var Kn=Bk(T);if(Kn!==null){(Kn.flags&65536)===0&&(Kn.flags|=256),Uk(Kn,T,z,b,i),vf(Ji(G,z));break e}}b=G=Ji(G,z),nr!==4&&(nr=2),ll===null?ll=[b]:ll.push(b),b=T;do{switch(b.tag){case 3:b.flags|=65536,i&=-i,b.lanes|=i;var re=Dk(b,G,i);dk(b,re);break e;case 1:z=G;var Q=b.type,ie=b.stateNode;if((b.flags&128)===0&&(typeof Q.getDerivedStateFromError=="function"||ie!==null&&typeof ie.componentDidCatch=="function"&&(Cs===null||!Cs.has(ie)))){b.flags|=65536,i&=-i,b.lanes|=i;var Me=zk(b,z,i);dk(b,Me);break e}}b=b.return}while(b!==null)}wy(d)}catch(Xe){i=Xe,Gn===d&&d!==null&&(Gn=d=d.return);continue}break}while(!0)}function ky(){var o=Gc.current;return Gc.current=Uc,o===null?Uc:o}function cp(){(nr===0||nr===3||nr===2)&&(nr=4),fr===null||(li&268435455)===0&&(Vc&268435455)===0||Rs(fr,kr)}function tu(o,i){var d=Zt;Zt|=2;var m=ky();(fr!==o||kr!==i)&&(rs=null,ui(o,i));do try{sN();break}catch(w){gy(o,w)}while(!0);if(xf(),Zt=d,Gc.current=m,Gn!==null)throw Error(n(261));return fr=null,kr=0,nr}function sN(){for(;Gn!==null;)yy(Gn)}function iN(){for(;Gn!==null&&!oo();)yy(Gn)}function yy(o){var i=xy(o.alternate,o,Xr);o.memoizedProps=o.pendingProps,i===null?wy(o):Gn=i,ep.current=null}function wy(o){var i=o;do{var d=i.alternate;if(o=i.return,(i.flags&32768)===0){if(d=XS(d,i,Xr),d!==null){Gn=d;return}}else{if(d=JS(d,i),d!==null){d.flags&=32767,Gn=d;return}if(o!==null)o.flags|=32768,o.subtreeFlags=0,o.deletions=null;else{nr=6,Gn=null;return}}if(i=i.sibling,i!==null){Gn=i;return}Gn=i=o}while(i!==null);nr===0&&(nr=5)}function di(o,i,d){var m=Ot,w=uo.transition;try{uo.transition=null,Ot=1,aN(o,i,d,m)}finally{uo.transition=w,Ot=m}return null}function aN(o,i,d,m){do ra();while(As!==null);if((Zt&6)!==0)throw Error(n(327));d=o.finishedWork;var w=o.finishedLanes;if(d===null)return null;if(o.finishedWork=null,o.finishedLanes=0,d===o.current)throw Error(n(177));o.callbackNode=null,o.callbackPriority=0;var b=d.lanes|d.childLanes;if(Jn(o,b),o===fr&&(Gn=fr=null,kr=0),(d.subtreeFlags&2064)===0&&(d.flags&2064)===0||Qc||(Qc=!0,_y(Zn,function(){return ra(),null})),b=(d.flags&15990)!==0,(d.subtreeFlags&15990)!==0||b){b=uo.transition,uo.transition=null;var T=Ot;Ot=1;var z=Zt;Zt|=4,ep.current=null,tN(o,d),cy(d,o),TS(cf),Ys=!!lf,cf=lf=null,o.current=d,nN(d),qr(),Zt=z,Ot=T,uo.transition=b}else o.current=d;if(Qc&&(Qc=!1,As=o,Xc=w),b=o.pendingLanes,b===0&&(Cs=null),rn(d.stateNode),zr(o,Vt()),i!==null)for(m=o.onRecoverableError,d=0;d<i.length;d++)w=i[d],m(w.value,{componentStack:w.stack,digest:w.digest});if(Yc)throw Yc=!1,o=rp,rp=null,o;return(Xc&1)!==0&&o.tag!==0&&ra(),b=o.pendingLanes,(b&1)!==0?o===op?cl++:(cl=0,op=o):cl=0,Ss(),null}function ra(){if(As!==null){var o=lt(Xc),i=uo.transition,d=Ot;try{if(uo.transition=null,Ot=16>o?16:o,As===null)var m=!1;else{if(o=As,As=null,Xc=0,(Zt&6)!==0)throw Error(n(331));var w=Zt;for(Zt|=4,qe=o.current;qe!==null;){var b=qe,T=b.child;if((qe.flags&16)!==0){var z=b.deletions;if(z!==null){for(var G=0;G<z.length;G++){var ce=z[G];for(qe=ce;qe!==null;){var Te=qe;switch(Te.tag){case 0:case 11:case 15:il(8,Te,b)}var Ie=Te.child;if(Ie!==null)Ie.return=Te,qe=Ie;else for(;qe!==null;){Te=qe;var Ee=Te.sibling,Ze=Te.return;if(oy(Te),Te===ce){qe=null;break}if(Ee!==null){Ee.return=Ze,qe=Ee;break}qe=Ze}}}var Ge=b.alternate;if(Ge!==null){var Ye=Ge.child;if(Ye!==null){Ge.child=null;do{var Kn=Ye.sibling;Ye.sibling=null,Ye=Kn}while(Ye!==null)}}qe=b}}if((b.subtreeFlags&2064)!==0&&T!==null)T.return=b,qe=T;else e:for(;qe!==null;){if(b=qe,(b.flags&2048)!==0)switch(b.tag){case 0:case 11:case 15:il(9,b,b.return)}var re=b.sibling;if(re!==null){re.return=b.return,qe=re;break e}qe=b.return}}var Q=o.current;for(qe=Q;qe!==null;){T=qe;var ie=T.child;if((T.subtreeFlags&2064)!==0&&ie!==null)ie.return=T,qe=ie;else e:for(T=Q;qe!==null;){if(z=qe,(z.flags&2048)!==0)try{switch(z.tag){case 0:case 11:case 15:qc(9,z)}}catch(Xe){Bn(z,z.return,Xe)}if(z===T){qe=null;break e}var Me=z.sibling;if(Me!==null){Me.return=z.return,qe=Me;break e}qe=z.return}}if(Zt=w,Ss(),ft&&typeof ft.onPostCommitFiberRoot=="function")try{ft.onPostCommitFiberRoot(yt,o)}catch{}m=!0}return m}finally{Ot=d,uo.transition=i}}return!1}function vy(o,i,d){i=Ji(d,i),i=Dk(o,i,1),o=Ts(o,i,1),i=Ir(),o!==null&&(Tr(o,1,i),zr(o,i))}function Bn(o,i,d){if(o.tag===3)vy(o,o,d);else for(;i!==null;){if(i.tag===3){vy(i,o,d);break}else if(i.tag===1){var m=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof m.componentDidCatch=="function"&&(Cs===null||!Cs.has(m))){o=Ji(d,o),o=zk(i,o,1),i=Ts(i,o,1),o=Ir(),i!==null&&(Tr(i,1,o),zr(i,o));break}}i=i.return}}function lN(o,i,d){var m=o.pingCache;m!==null&&m.delete(i),i=Ir(),o.pingedLanes|=o.suspendedLanes&d,fr===o&&(kr&d)===d&&(nr===4||nr===3&&(kr&130023424)===kr&&500>Vt()-np?ui(o,0):tp|=d),zr(o,i)}function by(o,i){i===0&&((o.mode&1)===0?i=1:(i=pt,pt<<=1,(pt&130023424)===0&&(pt=4194304)));var d=Ir();o=es(o,i),o!==null&&(Tr(o,i,d),zr(o,d))}function cN(o){var i=o.memoizedState,d=0;i!==null&&(d=i.retryLane),by(o,d)}function uN(o,i){var d=0;switch(o.tag){case 13:var m=o.stateNode,w=o.memoizedState;w!==null&&(d=w.retryLane);break;case 19:m=o.stateNode;break;default:throw Error(n(314))}m!==null&&m.delete(i),by(o,d)}var xy;xy=function(o,i,d){if(o!==null)if(o.memoizedProps!==i.pendingProps||Mr.current)Pr=!0;else{if((o.lanes&d)===0&&(i.flags&128)===0)return Pr=!1,QS(o,i,d);Pr=(o.flags&131072)!==0}else Pr=!1,Tn&&(i.flags&1048576)!==0&&tk(i,Ac,i.index);switch(i.lanes=0,i.tag){case 2:var m=i.type;Kc(o,i),o=i.pendingProps;var w=Ki(i,wr.current);Qi(i,d),w=Of(null,i,m,o,w,d);var b=$f();return i.flags|=1,typeof w=="object"&&w!==null&&typeof w.render=="function"&&w.$$typeof===void 0?(i.tag=1,i.memoizedState=null,i.updateQueue=null,Lr(m)?(b=!0,Tc(i)):b=!1,i.memoizedState=w.state!==null&&w.state!==void 0?w.state:null,Nf(i),w.updater=Hc,i.stateNode=w,w._reactInternals=i,Ff(i,m,o,d),i=Wf(null,i,m,!0,b,d)):(i.tag=0,Tn&&b&&gf(i),Ar(null,i,w,d),i=i.child),i;case 16:m=i.elementType;e:{switch(Kc(o,i),o=i.pendingProps,w=m._init,m=w(m._payload),i.type=m,w=i.tag=fN(m),o=xo(m,o),w){case 0:i=Hf(null,i,m,o,d);break e;case 1:i=Gk(null,i,m,o,d);break e;case 11:i=Hk(null,i,m,o,d);break e;case 14:i=Wk(null,i,m,xo(m.type,o),d);break e}throw Error(n(306,m,""))}return i;case 0:return m=i.type,w=i.pendingProps,w=i.elementType===m?w:xo(m,w),Hf(o,i,m,w,d);case 1:return m=i.type,w=i.pendingProps,w=i.elementType===m?w:xo(m,w),Gk(o,i,m,w,d);case 3:e:{if(Vk(i),o===null)throw Error(n(387));m=i.pendingProps,b=i.memoizedState,w=b.element,uk(o,i),Lc(i,m,null,d);var T=i.memoizedState;if(m=T.element,b.isDehydrated)if(b={element:m,isDehydrated:!1,cache:T.cache,pendingSuspenseBoundaries:T.pendingSuspenseBoundaries,transitions:T.transitions},i.updateQueue.baseState=b,i.memoizedState=b,i.flags&256){w=Ji(Error(n(423)),i),i=Yk(o,i,m,d,w);break e}else if(m!==w){w=Ji(Error(n(424)),i),i=Yk(o,i,m,d,w);break e}else for(Qr=xs(i.stateNode.containerInfo.firstChild),Yr=i,Tn=!0,bo=null,d=lk(i,null,m,d),i.child=d;d;)d.flags=d.flags&-3|4096,d=d.sibling;else{if(Gi(),m===w){i=ns(o,i,d);break e}Ar(o,i,m,d)}i=i.child}return i;case 5:return pk(i),o===null&&wf(i),m=i.type,w=i.pendingProps,b=o!==null?o.memoizedProps:null,T=w.children,uf(m,w)?T=null:b!==null&&uf(m,b)&&(i.flags|=32),qk(o,i),Ar(o,i,T,d),i.child;case 6:return o===null&&wf(i),null;case 13:return Qk(o,i,d);case 4:return Tf(i,i.stateNode.containerInfo),m=i.pendingProps,o===null?i.child=Vi(i,null,m,d):Ar(o,i,m,d),i.child;case 11:return m=i.type,w=i.pendingProps,w=i.elementType===m?w:xo(m,w),Hk(o,i,m,w,d);case 7:return Ar(o,i,i.pendingProps,d),i.child;case 8:return Ar(o,i,i.pendingProps.children,d),i.child;case 12:return Ar(o,i,i.pendingProps.children,d),i.child;case 10:e:{if(m=i.type._context,w=i.pendingProps,b=i.memoizedProps,T=w.value,bn(Oc,m._currentValue),m._currentValue=T,b!==null)if(vo(b.value,T)){if(b.children===w.children&&!Mr.current){i=ns(o,i,d);break e}}else for(b=i.child,b!==null&&(b.return=i);b!==null;){var z=b.dependencies;if(z!==null){T=b.child;for(var G=z.firstContext;G!==null;){if(G.context===m){if(b.tag===1){G=ts(-1,d&-d),G.tag=2;var ce=b.updateQueue;if(ce!==null){ce=ce.shared;var Te=ce.pending;Te===null?G.next=G:(G.next=Te.next,Te.next=G),ce.pending=G}}b.lanes|=d,G=b.alternate,G!==null&&(G.lanes|=d),Ef(b.return,d,i),z.lanes|=d;break}G=G.next}}else if(b.tag===10)T=b.type===i.type?null:b.child;else if(b.tag===18){if(T=b.return,T===null)throw Error(n(341));T.lanes|=d,z=T.alternate,z!==null&&(z.lanes|=d),Ef(T,d,i),T=b.sibling}else T=b.child;if(T!==null)T.return=b;else for(T=b;T!==null;){if(T===i){T=null;break}if(b=T.sibling,b!==null){b.return=T.return,T=b;break}T=T.return}b=T}Ar(o,i,w.children,d),i=i.child}return i;case 9:return w=i.type,m=i.pendingProps.children,Qi(i,d),w=lo(w),m=m(w),i.flags|=1,Ar(o,i,m,d),i.child;case 14:return m=i.type,w=xo(m,i.pendingProps),w=xo(m.type,w),Wk(o,i,m,w,d);case 15:return Kk(o,i,i.type,i.pendingProps,d);case 17:return m=i.type,w=i.pendingProps,w=i.elementType===m?w:xo(m,w),Kc(o,i),i.tag=1,Lr(m)?(o=!0,Tc(i)):o=!1,Qi(i,d),Lk(i,m,w),Ff(i,m,w,d),Wf(null,i,m,!0,o,d);case 19:return Jk(o,i,d);case 22:return Zk(o,i,d)}throw Error(n(156,i.tag))};function _y(o,i){return Fn(o,i)}function dN(o,i,d,m){this.tag=o,this.key=d,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=i,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=m,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fo(o,i,d,m){return new dN(o,i,d,m)}function up(o){return o=o.prototype,!(!o||!o.isReactComponent)}function fN(o){if(typeof o=="function")return up(o)?1:0;if(o!=null){if(o=o.$$typeof,o===Y)return 11;if(o===ye)return 14}return 2}function Os(o,i){var d=o.alternate;return d===null?(d=fo(o.tag,i,o.key,o.mode),d.elementType=o.elementType,d.type=o.type,d.stateNode=o.stateNode,d.alternate=o,o.alternate=d):(d.pendingProps=i,d.type=o.type,d.flags=0,d.subtreeFlags=0,d.deletions=null),d.flags=o.flags&14680064,d.childLanes=o.childLanes,d.lanes=o.lanes,d.child=o.child,d.memoizedProps=o.memoizedProps,d.memoizedState=o.memoizedState,d.updateQueue=o.updateQueue,i=o.dependencies,d.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},d.sibling=o.sibling,d.index=o.index,d.ref=o.ref,d}function nu(o,i,d,m,w,b){var T=2;if(m=o,typeof o=="function")up(o)&&(T=1);else if(typeof o=="string")T=5;else e:switch(o){case R:return fi(d.children,w,b,i);case j:T=8,w|=8;break;case A:return o=fo(12,d,i,w|2),o.elementType=A,o.lanes=b,o;case ae:return o=fo(13,d,i,w),o.elementType=ae,o.lanes=b,o;case me:return o=fo(19,d,i,w),o.elementType=me,o.lanes=b,o;case V:return ru(d,w,b,i);default:if(typeof o=="object"&&o!==null)switch(o.$$typeof){case D:T=10;break e;case H:T=9;break e;case Y:T=11;break e;case ye:T=14;break e;case _e:T=16,m=null;break e}throw Error(n(130,o==null?o:typeof o,""))}return i=fo(T,d,i,w),i.elementType=o,i.type=m,i.lanes=b,i}function fi(o,i,d,m){return o=fo(7,o,m,i),o.lanes=d,o}function ru(o,i,d,m){return o=fo(22,o,m,i),o.elementType=V,o.lanes=d,o.stateNode={isHidden:!1},o}function dp(o,i,d){return o=fo(6,o,null,i),o.lanes=d,o}function fp(o,i,d){return i=fo(4,o.children!==null?o.children:[],o.key,i),i.lanes=d,i.stateNode={containerInfo:o.containerInfo,pendingChildren:null,implementation:o.implementation},i}function pN(o,i,d,m,w){this.tag=i,this.containerInfo=o,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Vr(0),this.expirationTimes=Vr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Vr(0),this.identifierPrefix=m,this.onRecoverableError=w,this.mutableSourceEagerHydrationData=null}function pp(o,i,d,m,w,b,T,z,G){return o=new pN(o,i,d,z,G),i===1?(i=1,b===!0&&(i|=8)):i=0,b=fo(3,null,null,i),o.current=b,b.stateNode=o,b.memoizedState={element:m,isDehydrated:d,cache:null,transitions:null,pendingSuspenseBoundaries:null},Nf(b),o}function hN(o,i,d){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:W,key:m==null?null:""+m,children:o,containerInfo:i,implementation:d}}function Ey(o){if(!o)return Es;o=o._reactInternals;e:{if(An(o)!==o||o.tag!==1)throw Error(n(170));var i=o;do{switch(i.tag){case 3:i=i.stateNode.context;break e;case 1:if(Lr(i.type)){i=i.stateNode.__reactInternalMemoizedMergedChildContext;break e}}i=i.return}while(i!==null);throw Error(n(171))}if(o.tag===1){var d=o.type;if(Lr(d))return Xg(o,d,i)}return i}function Sy(o,i,d,m,w,b,T,z,G){return o=pp(d,m,!0,o,w,b,T,z,G),o.context=Ey(null),d=o.current,m=Ir(),w=Is(d),b=ts(m,w),b.callback=i??null,Ts(d,b,w),o.current.lanes=w,Tr(o,w,m),zr(o,m),o}function ou(o,i,d,m){var w=i.current,b=Ir(),T=Is(w);return d=Ey(d),i.context===null?i.context=d:i.pendingContext=d,i=ts(b,T),i.payload={element:o},m=m===void 0?null:m,m!==null&&(i.callback=m),o=Ts(w,i,T),o!==null&&(So(o,w,T,b),Mc(o,w,T)),T}function su(o){if(o=o.current,!o.child)return null;switch(o.child.tag){case 5:return o.child.stateNode;default:return o.child.stateNode}}function Ny(o,i){if(o=o.memoizedState,o!==null&&o.dehydrated!==null){var d=o.retryLane;o.retryLane=d!==0&&d<i?d:i}}function hp(o,i){Ny(o,i),(o=o.alternate)&&Ny(o,i)}function mN(){return null}var Ty=typeof reportError=="function"?reportError:function(o){console.error(o)};function mp(o){this._internalRoot=o}iu.prototype.render=mp.prototype.render=function(o){var i=this._internalRoot;if(i===null)throw Error(n(409));ou(o,i,null,null)},iu.prototype.unmount=mp.prototype.unmount=function(){var o=this._internalRoot;if(o!==null){this._internalRoot=null;var i=o.containerInfo;ci(function(){ou(null,o,null,null)}),i[Yo]=null}};function iu(o){this._internalRoot=o}iu.prototype.unstable_scheduleHydration=function(o){if(o){var i=jr();o={blockedOn:null,target:o,priority:i};for(var d=0;d<mt.length&&i!==0&&i<mt[d].priority;d++);mt.splice(d,0,o),d===0&&Wn(o)}};function gp(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11)}function au(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11&&(o.nodeType!==8||o.nodeValue!==" react-mount-point-unstable "))}function jy(){}function gN(o,i,d,m,w){if(w){if(typeof m=="function"){var b=m;m=function(){var ce=su(T);b.call(ce)}}var T=Sy(i,m,o,0,null,!1,!1,"",jy);return o._reactRootContainer=T,o[Yo]=T.current,qa(o.nodeType===8?o.parentNode:o),ci(),T}for(;w=o.lastChild;)o.removeChild(w);if(typeof m=="function"){var z=m;m=function(){var ce=su(G);z.call(ce)}}var G=pp(o,0,!1,null,null,!1,!1,"",jy);return o._reactRootContainer=G,o[Yo]=G.current,qa(o.nodeType===8?o.parentNode:o),ci(function(){ou(i,G,d,m)}),G}function lu(o,i,d,m,w){var b=d._reactRootContainer;if(b){var T=b;if(typeof w=="function"){var z=w;w=function(){var G=su(T);z.call(G)}}ou(i,T,o,w)}else T=gN(d,i,o,w,m);return su(T)}Vo=function(o){switch(o.tag){case 3:var i=o.stateNode;if(i.current.memoizedState.isDehydrated){var d=jt(i.pendingLanes);d!==0&&($r(i,d|1),zr(i,Vt()),(Zt&6)===0&&(na=Vt()+500,Ss()))}break;case 13:ci(function(){var m=es(o,1);if(m!==null){var w=Ir();So(m,o,1,w)}}),hp(o,1)}},yn=function(o){if(o.tag===13){var i=es(o,134217728);if(i!==null){var d=Ir();So(i,o,134217728,d)}hp(o,134217728)}},Ht=function(o){if(o.tag===13){var i=Is(o),d=es(o,i);if(d!==null){var m=Ir();So(d,o,i,m)}hp(o,i)}},jr=function(){return Ot},yr=function(o,i){var d=Ot;try{return Ot=o,i()}finally{Ot=d}},hn=function(o,i,d){switch(i){case"input":if(en(o,d),i=d.name,d.type==="radio"&&i!=null){for(d=o;d.parentNode;)d=d.parentNode;for(d=d.querySelectorAll("input[name="+JSON.stringify(""+i)+'][type="radio"]'),i=0;i<d.length;i++){var m=d[i];if(m!==o&&m.form===o.form){var w=Sc(m);if(!w)throw Error(n(90));De(m),en(m,w)}}}break;case"textarea":he(o,d);break;case"select":i=d.value,i!=null&&X(o,!!d.multiple,i,!1)}},Ae=ap,et=ci;var kN={usingClientEntryPoint:!1,Events:[Ya,Hi,Sc,U,de,ap]},ul={findFiberByHostInstance:ti,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},yN={bundleType:ul.bundleType,version:ul.version,rendererPackageName:ul.rendererPackageName,rendererConfig:ul.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:M.ReactCurrentDispatcher,findHostInstanceByFiber:function(o){return o=wn(o),o===null?null:o.stateNode},findFiberByHostInstance:ul.findFiberByHostInstance||mN,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 cu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!cu.isDisabled&&cu.supportsFiber)try{yt=cu.inject(yN),ft=cu}catch{}}return Fr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=kN,Fr.createPortal=function(o,i){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!gp(i))throw Error(n(200));return hN(o,i,null,d)},Fr.createRoot=function(o,i){if(!gp(o))throw Error(n(299));var d=!1,m="",w=Ty;return i!=null&&(i.unstable_strictMode===!0&&(d=!0),i.identifierPrefix!==void 0&&(m=i.identifierPrefix),i.onRecoverableError!==void 0&&(w=i.onRecoverableError)),i=pp(o,1,!1,null,null,d,!1,m,w),o[Yo]=i.current,qa(o.nodeType===8?o.parentNode:o),new mp(i)},Fr.findDOMNode=function(o){if(o==null)return null;if(o.nodeType===1)return o;var i=o._reactInternals;if(i===void 0)throw typeof o.render=="function"?Error(n(188)):(o=Object.keys(o).join(","),Error(n(268,o)));return o=wn(i),o=o===null?null:o.stateNode,o},Fr.flushSync=function(o){return ci(o)},Fr.hydrate=function(o,i,d){if(!au(i))throw Error(n(200));return lu(null,o,i,!0,d)},Fr.hydrateRoot=function(o,i,d){if(!gp(o))throw Error(n(405));var m=d!=null&&d.hydratedSources||null,w=!1,b="",T=Ty;if(d!=null&&(d.unstable_strictMode===!0&&(w=!0),d.identifierPrefix!==void 0&&(b=d.identifierPrefix),d.onRecoverableError!==void 0&&(T=d.onRecoverableError)),i=Sy(i,null,o,1,d??null,w,!1,b,T),o[Yo]=i.current,qa(o),m)for(o=0;o<m.length;o++)d=m[o],w=d._getVersion,w=w(d._source),i.mutableSourceEagerHydrationData==null?i.mutableSourceEagerHydrationData=[d,w]:i.mutableSourceEagerHydrationData.push(d,w);return new iu(i)},Fr.render=function(o,i,d){if(!au(i))throw Error(n(200));return lu(null,o,i,!1,d)},Fr.unmountComponentAtNode=function(o){if(!au(o))throw Error(n(40));return o._reactRootContainer?(ci(function(){lu(null,null,o,!1,function(){o._reactRootContainer=null,o[Yo]=null})}),!0):!1},Fr.unstable_batchedUpdates=ap,Fr.unstable_renderSubtreeIntoContainer=function(o,i,d,m){if(!au(d))throw Error(n(200));if(o==null||o._reactInternals===void 0)throw Error(n(38));return lu(o,i,d,!1,m)},Fr.version="18.3.1-next-f1338f8080-20240426",Fr}var jw;function o$(){if(jw)return Tp.exports;jw=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(),Tp.exports=r$(),Tp.exports}var Cw;function s$(){if(Cw)return mu;Cw=1;var e=o$();return mu.createRoot=e.createRoot,mu.hydrateRoot=e.hydrateRoot,mu}var i$=s$();function a$(e,t){const n=e.filter(s=>s.id!==t),r=n.filter(s=>s.agent==="waiting"||s.unseen).length;return r===0?null:{n:r,tier:n.some(s=>s.agent==="waiting")?"waiting":"unseen"}}function Xb(e,t,n){const r=h=>e.map((p,g)=>h(p)&&p.id!==t?g:-1).filter(p=>p>=0),a=[()=>r(h=>h.agent==="waiting"),()=>r(h=>!!h.unseen),()=>r(h=>h.agent==="working")].reduce((h,p)=>h.length>0?h:p(),[]),l=e.findIndex(h=>h.id===t),c=n>0?a.find(h=>h>l)??a[0]:a.findLast(h=>h<l)??a[a.length-1],u=c===void 0?void 0:e[c];return u?{activate:u.id}:null}function gm(e,t,n){const r=Xb(e,t,n);if(r)return r;const s=e[0];return s&&s.id!==t?{activate:s.id}:null}function Jb(e){return(e.key==="Enter"||e.key==="NumpadEnter")&&(e.metaKey||e.ctrlKey)&&!e.altKey?!1:e.metaKey||e.ctrlKey||e.altKey}function ex(e){const t=e.findLast(n=>n.kind==="ask"&&!n.outcome);return(t==null?void 0:t.kind)==="ask"?t:null}function tx(e){return e==="cancelled"||e==="expired"}function l$(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:tx(t.outcome)?t:null}function c$(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 u$(e){return e.map(()=>({selected:[]}))}function Aw(e,t,n,r){return e.map((s,a)=>{if(a!==t)return s;const l=s.selected.includes(n);return r?{...s,selected:l?s.selected.filter(c=>c!==n):[...s.selected,n]}:{...s,selected:[n]}})}function nx(e,t,n){return e.map((r,s)=>{if(s!==t)return r;const{note:a,...l}=r;return n===void 0?l:{...l,note:n}})}function Iw(e,t,n,r){return e.map((s,a)=>a!==t?s:{selected:n&&!r?[]:s.selected,note:s.note??""})}function Rw(e,t){const n=e[t];return n&&n.note!==void 0&&!n.note.trim()?nx(e,t,void 0):e}function rx(e){return e?e.options.length+(e.note?1:0):0}function d$(e,t){return!!(e!=null&&e.note)&&t===e.options.length}function ox(e,t){return!!e&&e.note!==void 0&&(t||e.selected.length===0)}function pa(e){var t;return!!e&&(e.selected.length>0||!!((t=e.note)!=null&&t.trim()))}function gu(e,t){return e.every((n,r)=>!n.required||pa(t[r]))}function sx(e,t){var s;const n=((t==null?void 0:t.selected)??[]).map(a=>{var l;return lx(((l=e.options.find(c=>c.value===a))==null?void 0:l.label)??a)}),r=(s=t==null?void 0:t.note)==null?void 0:s.trim();return n.length===0?r||"skipped":r?`${n.join(", ")}: ${r}`:n.join(", ")}function ix(e,t){return e.map((n,r)=>{const s=sx(n,t==null?void 0:t[r]);return e.length>1&&n.header?`${n.header} · ${s}`:s})}function f$(e){return e.outcome!=="answered"||e.ask.kind!=="question"?null:{message:e.ask.message,questions:e.ask.questions,answers:e.answers}}function p$(e,t){return t>=1&&t<=rx(e)?t-1:-1}function ca(e,t){if(!e)return 0;if(ox(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 h$(e,t,n){return Math.max(0,Math.min(n-1,e+t))}function m$(e,t,n){const r=e.length;for(let s=1;s<=r;s++){const a=(n+s)%r;if(!pa(t[a]))return a}return-1}function Yu(e){return e.length>1?e.length:-1}function g$(e){return e.length+(Yu(e)===-1?0:1)}function Ow(e,t,n){const r=m$(e,t,n);if(r!==-1)return{current:r,cursor:ca(e[r],t[r]),send:!1};const s=Yu(e);return s!==-1?{current:s,cursor:0,send:!1}:{current:n,cursor:ca(e[n],t[n]),send:!0}}const ax=/\s*\(recommended\)\s*$/i;function k$(e){return ax.test(e)}function lx(e){return e.replace(ax,"")}function ph(e,t,n){const r=location.hostname;return n!==null&&r===n.host?`${sT(n.previews,e,t)}/`:r.endsWith(".localhost")?`http://w${e}.${r}:${t}/`:r==="127.0.0.1"||r==="localhost"?`http://127.0.0.1:${t}/`:`${location.protocol}//${r}:${t}/`}function $w(e){return e.ranges.map(([t,n])=>[t+e.offset,n+e.offset])}function Mw(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 ku(e,t){return!Number.isFinite(e)||e<=0?t:Math.min(Math.max(e,170),Math.floor(window.innerWidth*.5))}function ec(e){return e.agent==="working"||e.agent==="waiting"}function Ni(e){var t,n,r;return e.agent==="waiting"?"waiting":e.agent==="working"?"working":e.agent==="error"||((n=(t=e.worktree)==null?void 0:t.lastTurn)==null?void 0:n.end)==="failed"?"failed":(r=e.worktree)!=null&&r.landed?"landed":e.procs.some(s=>s.status==="crashed"||s.status==="unreachable")?"crashed":e.procs.some(s=>s.status==="running")?"running":e.procs.some(s=>s.status==="starting")?"starting":e.procs.some(s=>s.status==="asleep")?"asleep":"idle"}const y$={waiting:"Waiting for you",working:"Agent working",failed:"Agent failed",landed:"Landed",crashed:"Crashed",running:"Running",starting:"Starting",asleep:"Asleep",idle:"Idle"};function km(e,t=!1){const n=Ni(e);return n==="idle"&&t?"Not set up":y$[n]}const w$={starting:"Starting",running:"Running",unreachable:"Not answering",crashed:"Crashed",stopped:"Stopped",asleep:"Asleep"};function v$(e){return w$[e]}function b$(e,t){return t&&Ni(e)!=="waiting"?t:null}const x$={land:"Landing",commit:"Committing","sync-main":"Syncing with main","pull-main":"Pulling"};function cx(e){return x$[e]}function ux(e){const t=e.filter(s=>s.status==="crashed"||s.status==="unreachable"),n=t[0];if(!n)return null;const r=t.map(s=>s.status==="unreachable"?`${s.name} never answered on :${s.port}`:`${s.name} crashed on :${s.port}`).join(", ");return{dead:t,tip:`${r} · click to open its tab`,stream:n.name}}function _$(e){const t=e.lastIndexOf("/");return t<0?{name:e,dir:""}:{name:e.slice(t+1),dir:e.slice(0,t)}}const dx=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}).compare;function Qu(e){const t=[];for(let n=e.indexOf("/");n!==-1;n=e.indexOf("/",n+1))t.push(e.slice(0,n));return t}function fx(e){const t=new Set;for(const n of e)for(const r of Qu(n))t.add(r);return[...t].sort(dx)}function ym(e){return e.includes("A")||e==="??"?"added":e.includes("D")?"deleted":""}function wm(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 E$=/Firefox\//.test(navigator.userAgent);function Ad(){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 S$=/Chrome\//.test(navigator.userAgent)&&Ad(),xt=e=>YN(e,{firefox:E$,pwa:S$});function vm(e){return e.component?`<${e.component} />`:`<${e.tag}>`}function hh(e,t){return e.worktree&&hr(e.worktree)&&t?t.defaultBranch:e.name}function px(e){const t=Math.max(0,e/1e3),n=(l,c)=>`${l} ${c}${l===1?"":"s"}`;if(t<60)return"a moment";const r=t/60;if(r<60)return n(Math.floor(r),"minute");const s=r/60;if(s<24)return n(Math.floor(s),"hour");const a=s/24;return a<7?n(Math.floor(a),"day"):a<365?n(Math.floor(a/7),"week"):n(Math.floor(a/365),"year")}function Ur(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 s=r/24;return s<7?`${Math.floor(s)}d`:s<365?`${Math.floor(s/7)}w`:`${Math.floor(s/365)}y`}function ha(e){const t=Math.max(0,Math.floor(e));return t<100?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function N$(e,t,n,r){var l;if(!t)return null;const s=e.filter(ir).filter(c=>c.repoId===t&&(c.worktree.agent??r)===n);return((l=s.find(c=>hr(c.worktree))??s[0])==null?void 0:l.id)??null}const T$=200;function j$(e,t){const n=new Map(e.map(r=>[r.path,r]));for(const r of t){if(n.size>=T$)break;const s=Nd(r.path);s&&!n.has(s)&&n.set(s,{path:s,text:r.text})}return n.size===e.length?e:[...n.values()]}function hx(e){return e!==void 0&&!e.routes.some(t=>!t.endpoint)}const Xu=e=>"uploading"in e&&e.uploading===!0;function Ju(e){switch(e.kind){case"image":case"file":{const{key:t,local:n,uploading:r,...s}=e;return s}case"paste":{const{key:t,chars:n,lines:r,preview:s,...a}=e;return a}case"pick":{const{key:t,...n}=e;return n}}}const C$=e=>e.filter(t=>!Xu(t)).map(Ju);let A$=0;function mh(e,t){const n=new Map(t.filter(s=>!Xu(s)).map(s=>[JSON.stringify(Ju(s)),s]));return[...e.map(s=>{const a=JSON.stringify(s),l=n.get(a);if(l)return n.delete(a),l;const c=`d${++A$}`;return s.kind==="paste"?{...s,key:c,...fm(s.text)}:{...s,key:c}}),...t.filter(Xu)]}const Mu=["files","changes","history"],I$=e=>Mu.includes(e),mx=e=>!!(e!=null&&e.carry)&&!e.batch&&e.variants===1,tc=e=>(e==null?void 0:e.worktree.id)??null,Ia=Object.freeze({chat:[],log:[],queue:[],page:{errors:[]},turn:{edits:!1,hmr:!1},changedRanges:{},commitFiles:{},search:null,design:null,draft:"",attachments:[],commands:[],termStream:po}),bm=e=>({...e,phase:"editing",repoId:null,prompt:""}),Lw=()=>bm({mode:"create",name:"",parent:`~/${Hb}`}),R$=Object.freeze({changes:!1,changesTab:"files",chat:!0,term:!1,design:!1});function O$(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.changes=="boolean"&&I$(t.changesTab)&&typeof t.chat=="boolean"&&typeof t.term=="boolean"&&typeof t.design=="boolean"}function to(e,t){const n=e.layout;let r=!1;for(const s of Object.keys(t))t[s]!==n[s]&&(r=!0);return r?{...e,layout:{...n,...t}}:e}function xm(e,t){return{...e,layout:t,changesAuto:!1}}const Ti=e=>Cd(e)?"preview":"file",$$=(e,t)=>e===t||!!e&&!!t&&e.at===t.at&&(e.at!=="tree"||t.at!=="tree"||e.worktreeId===t.worktreeId&&e.dir===t.dir),pl=(e,t)=>e.worktreeId===t.worktreeId&&e.path===t.path&&e.ref===t.ref&&e.since===t.since;function gx(e,t,n,r){var a;if(!r.fiber)return r;const s=(a=go(e,t).changedRanges[n])==null?void 0:a.offset;return s===void 0?r:{n:r.n-s}}function M$(e){const t=e.cached??Jl,n={connected:!1,connectFailure:null,repos:[],rows:[],activeRepoId:null,visible:[],archiving:[],shipping:{},visibleDiscovered:[],discoveredOpen:e.storedDiscoveredOpen??{},archivedOpen:e.storedArchivedOpen??{},committedShut:e.storedCommittedShut??{},turnOpen:e.storedTurnOpen??{},treeOpen:e.storedTreeOpen??{},treeReveal:null,refs:{},chats:{},archived:{},archivedPage:null,lastActive:e.storedLastActive??{},pendingOpen:!1,activeId:null,clientId:e.clientId,storedActive:e.storedActive??null,storedRepo:e.storedRepo??null,heard:!1,local:{},editor:null,openUrl:null,reloadReq:null,dragFiles:null,picking:!1,overlay:null,paletteReturn:null,incompatible:!1,layout:R$,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?"chat":"home",frame:e.frame??"desk",touch:e.touch??!1,changesAuto:!0,zen:!1,focusTerm:0,termRun:null,termTall:0,themes:$u.some(s=>s.id===t.id)?$u:[...$u,t],themePrefs:{...MO,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,remote:null,managed:DR,paired:!1,pairings:0,gitIdentity:!0,self:null,rebuilt:!1,update:null,updateCheck:null,version:"",install:"none",registry:null,choosingFolder:!1,newProject:null,autoSend:null,chosenFolder:null,pending:[],activeImportId:null,agents:[],defaultAgent:"claude",agentChosen:!1,agentConfigs:{},draft:null,trunks:{},visits:{}},r=e.storedRepo?n.layouts[e.storedRepo]:void 0;return r?xm(n,r):n}function kx(e){var t;return{system:e.systemDark,daylight:((t=e.daylight)==null?void 0:t.dark)??e.systemDark}}function L$(e){return e.previewTheme??jd(e.themePrefs,e.themes,kx(e))}function go(e,t){return t&&e.local[t]||Ia}function cs(e,t){return t&&e.rows.find(n=>n.id===t)||null}function fn(e,t){const n=cs(e,t);return n&&ir(n)?n:null}function yx(e){var s;const t=fn(e,e.activeId);if(!t||!Ei(t.worktree)||t.agent!=="idle"||!((s=ba(e,t.repoId))!=null&&s.empty))return!1;const n=Ra(e,t.repoId),r=e.rows.some(a=>{var l;return a.repoId===t.repoId&&((l=a.worktree)==null?void 0:l.kind)==="worktree"});return!!(n!=null&&n.needsSetup)&&!r&&go(e,t.id).chat.length===0}function Id(e){return e.newProject!==null||yx(e)}function P$(e){return e.incompatible||Id(e)}function D$(e){return(!e.needsSetup||!!e.assumed)&&Object.keys(e.config.run).length===0}function ed(e){return!!(e!=null&&e.needsSetup)&&!e.assumed}function mo(e){const t=e.activeRepoId?e.repos.find(n=>n.id===e.activeRepoId):void 0;return!!t&&D$(t)}function wx(e){return e.layout.chat&&!mo(e)&&!e.archivedPage?{a:"toggle-chat"}:{a:"focus-chat"}}function Uo(e){return mo(e)?e:to(e,{chat:!0})}function Ra(e,t){return t&&e.repos.find(n=>n.id===t)||null}function vx(e,t){if(!t)return null;const n=e.rows.filter(ir).filter(r=>r.repoId===t);return n.find(r=>Ta(r.worktree))??n.find(r=>Ei(r.worktree))??null}function ba(e,t){return t&&e.trunks[t]||null}function bl(e){return mo(e)||e.archivedPage?null:e.activeId}function z$(e,t){var r;const n=cs(e,t);return!n||!ir(n)||hr(n.worktree)||mo(e)||n.agent==="waiting"||n.unseen||((r=n.worktree.lastTurn)==null?void 0:r.end)==="failed"?"chat":"preview"}function _m(e){return e.procs.some(t=>t.status==="running"||t.status==="starting")}function td(e){if(e.archivedPage)return null;const t=fn(e,e.activeId);return t&&_m(t)?{worktreeId:t.worktree.id,repoId:t.repoId}:null}function F$(e,t,n){const r=e.filter(ir),s=n.length?r.filter(a=>!n.includes(a.id)):r;return $N(t?s.filter(a=>a.repoId===t):s)}function B$(e,t){const n=e.filter(r=>!ir(r));return t?n.filter(r=>r.repoId===t):n}function Il(e,t,n=e.rows){var c;const r=n.filter(ir),s=e.archiving.length?r.filter(u=>!e.archiving.includes(u.id)):r,a=t?e.lastActive[t]:void 0;if(a&&s.some(u=>u.id===a))return a;const l=t?s.filter(u=>u.repoId===t):s;return((c=l.find(u=>Ta(u.worktree))??l.find(u=>Ei(u.worktree))??l[0])==null?void 0:c.id)??null}function Pw(e,t){const n=Object.entries(e),r=n.filter(([s])=>!t(s));return r.length===n.length?e:Object.fromEntries(r)}function Dw(e,t,n){const r={};for(const l of t)l.shipping&&(r[l.id]=l.shipping);for(const l of Object.values(n))l.shipping&&(r[l.id]=l.shipping);for(const[l,c]of Object.entries(e))!c.sent||r[l]||(t.some(u=>u.id===l)||Ex({trunks:n},l))&&(r[l]=c);const s=Object.keys(r);return s.length===Object.keys(e).length&&s.every(l=>U$(e[l],r[l]))?e:r}const U$=(e,t)=>!!e&&!!t&&e.op===t.op&&e.step===t.step&&e.sent===t.sent;function xl(e,t){var h;const n=cs(e,t),r=(n==null?void 0:n.repoId)??e.activeRepoId,s=n&&ir(n)?{...e.lastActive,[n.repoId]:n.id}:e.lastActive,a=e.activeId!==t?e.activeId:null,l=a?e.local[a]:void 0,c=l&&((h=l.mark)==null?void 0:h.by)==="reveal"?Rl(l,"reveal"):null,u=a&&c?{...e.local,[a]:c}:e.local;return{...e,activeId:t,activeRepoId:r,lastActive:s,editor:null,archivedPage:null,local:u}}function xa(e){return $o(e)?"history":e.layout.changesTab}function H$(e,t){const n=xa(e);if($o(e))return n;const r=Mu.length;return Mu[(Mu.indexOf(n)+t+r)%r]??"changes"}function $o(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 Rl(e,t){var s;if(((s=e.mark)==null?void 0:s.by)!==t)return e;const{mark:n,...r}=e;return r}const bx=e=>e.kind==="theme"||e.kind==="appearance"||e.kind==="agent"||e.kind==="agent-page"||e.kind==="choose-folder";function Ul(e){if(!e.sending)return e;const{sending:t,...n}=e;return n}function W$(e,t){const n=Object.keys(e.local).filter(s=>{var a;return((a=e.local[s])==null?void 0:a.sending)&&(!t||s===t)});if(n.length===0)return e;const r={...e.local};for(const s of n)r[s]=Ul(r[s]);return{...e,local:r}}function K$(e,t,n,r){var l;let s=e;const a=n?(l=s[n])==null?void 0:l.sending:void 0;if(a&&n&&r&&r!==n){const c=s[r]??Ia,u=c.chat.some(h=>h.kind==="user")?{}:a;s={...s,[n]:Ul(s[n]),[r]:{...c,sending:u}}}for(const c of t){const u=s[c.id];u!=null&&u.sending&&!u.sending.message&&(c.agent==="working"||c.agent==="waiting")&&(s={...s,[c.id]:Ul(u)})}return s}function Nt(e,t,n){return{...e,local:{...e.local,[t]:n(e.local[t]??Ia)}}}function zw(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 Z$(e,t){const n=t.type==="agent-question"||t.type==="agent-permission",r=t.type==="agent-ask-end"?t.id:null;if(!n&&!r)return e;const s=t.type==="agent-ask-end"&&tx(t.outcome),{ask:a,askParked:l,askRevived:c,...u}=e;return{...u,...a&&!n&&(a.id!==r||s)?{ask:a}:{},...l&&!n&&l!==r?{askParked:l}:{},...c&&!n?{askRevived:c}:{}}}function q$(e,t,n){return Nt(e,t,r=>({...r,chat:[...r.chat,n],chatAt:Date.now()}))}function xx(e,t,n){return q$(Uo(e),t,{kind:"error",text:n})}function gh(e,t){const n=tc(fn(e,e.activeId));return n?Nt(Uo(e),n,r=>({...r,notice:t})):e}function Fw(e,t,n){return fn(e,t)?xx(e,t,n):gh(e,n)}function G$(e,t){const n=e.paletteReturn;return!t||!n?{overlay:null,paletteReturn:null}:{overlay:{kind:n.mode},paletteReturn:n}}function V$(e){const t=e.activeRepoId;if(!t)return e;const n=e.layouts[t];return n?xm(e,n):e.frame==="desk"?{...e,layouts:{...e.layouts,[t]:e.layout}}:e}function Y$(e){return e.a==="server"&&e.msg.t==="git-status"}function Q$(e){return{variants:1,batch:!1,agent:e.defaultAgent}}function X$(e){const t=fn(e,e.activeId);return!!t&&hr(t.worktree)&&!e.archivedPage&&!Id(e)?e.draft?e:{...e,draft:Q$(e)}:e.draft?{...e,draft:null}:e}function _x(e){var r;const t=e.archivedPage,n=t!==null&&((r=e.editor)==null?void 0:r.worktreeId)===t&&fn(e,t)===null;return{...e,archivedPage:null,...n?{editor:null}:{}}}function ma(e,t){let n=X$(J$(e,t));return n.unreadHold!==null&&n.activeId!==n.unreadHold&&(n={...n,unreadHold:null}),n.archivedPage!==null&&($o(n)===null||fn(n,n.archivedPage)!==null)&&(n=_x(n)),n.activeRepoId!==e.activeRepoId?n=V$(n):n.frame==="desk"&&n.activeRepoId&&!Y$(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:F$(n.rows,n.activeRepoId,n.archiving),visibleDiscovered:B$(n.rows,n.activeRepoId)}}function J$(e,t){var n,r,s,a,l,c;switch(t.a){case"connected":return{...e,connected:t.v,connectFailure:t.v?null:t.failure??e.connectFailure};case"activate":{const u=xl(e,t.id);return{...u,screen:t.id?z$(u,t.id):"home"}}case"open-draft":{if(Id(e))return e;const u=((n=vx(e,e.activeRepoId))==null?void 0:n.id)??null;return u?Uo({...xl(e,u),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(u=>u.id===t.id))?e:{...e,archivedPage:t.id,editor:null,screen:"chat"};case"close-archived":return e.archivedPage?_x(e):e;case"restoring":return Nt(e,t.id,u=>({...u,restoring:t.text}));case"sending":return Nt(e,t.id,u=>({...u,sending:{message:t.message}}));case"sent-box":return Nt(e,t.id,({notice:u,...h})=>({...Rl(h,"walk"),draft:"",attachments:[],sent:(h.sent??0)+1}));case"archive-worktrees":{const u=t.ids.filter(x=>!e.archiving.includes(x)&&fn(e,x));if(u.length===0)return e;const h={...e,archiving:[...e.archiving,...u]};if(!e.activeId||!u.includes(e.activeId))return h;const p=e.visible.filter(x=>x.id===e.activeId||!h.archiving.includes(x.id)),g=p.findIndex(x=>x.id===e.activeId),k=x=>x.id!==e.activeId&&em(x.worktree)&&!!x.worktree.landed&&x.agent==="idle",y=x=>{var N;return(N=p.find((M,J)=>J>g&&x(M))??p.find(x))==null?void 0:N.id},v=y(x=>x.id!==e.activeId&&x.agent==="waiting"),_=y(k),E=(s=Xb(p,e.activeId,1))==null?void 0:s.activate,C=(a=p.map((x,N)=>({id:x.id,i:N,far:Math.abs(N-g),up:!hr(x.worktree)&&Ni(x)==="running"})).filter(x=>x.up&&x.far>0).sort((x,N)=>x.far-N.far||N.i-x.i)[0])==null?void 0:a.id;return xl(h,v??_??E??C??Il(h,e.activeRepoId))}case"shipping":return e.shipping[t.id]||!(cs(e,t.id)||Ex(e,t.id))?e:{...e,shipping:{...e.shipping,[t.id]:{op:t.op,sent:!0}}};case"activate-repo":{if(!Ra(e,t.id))return e;const u=e.newProject?{...e,newProject:null}:e;if(t.id===e.activeRepoId)return u;const h=Il(u,t.id);return{...xl(u,h),activeRepoId:t.id,pendingOpen:!1}}case"open-repo":return{...e,pendingOpen:!0};case"new-project":return{...e,newProject:t.v,overlay:null,paletteReturn:null,previewTheme:null,editor:null};case"new-project-set":{if(!e.newProject)return e;const u="name"in t.v||"parent"in t.v||"url"in t.v||"mode"in t.v,{error:h,...p}=e.newProject;return{...e,newProject:{...u?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 u=t.v,h=e.editor,p=h&&pl(h,u)?h:null,g=u.line&&gx(e,u.worktreeId,u.path,u.line);return{...e,editor:{worktreeId:u.worktreeId,path:u.path,...u.ref?{ref:u.ref}:{},...u.since?{since:u.since}:{},view:u.view??(p==null?void 0:p.view)??null,seq:u.seq,disk:(p==null?void 0:p.disk)??null,...g?{line:g}:{},focus:u.focus,conflict:(p==null?void 0:p.conflict)??null,blame:(p==null?void 0:p.blame)??null}}}case"open-loose":{const u=t.v,h={before:u.text,after:u.text,version:null,writable:u.source.kind!=="bytes"&&!u.tooLarge&&!u.binary,binary:u.binary,tooLarge:u.tooLarge};return{...e,editor:{worktreeId:u.worktreeId,path:u.name,view:Ti(u.name),seq:u.seq,disk:h,focus:!0,conflict:null,blame:null,loose:{source:u.source}}}}case"editor-read":{const u=e.editor;if(!u||u.loose||!pl(u,t.file))return e;const h=t.disk;if(!h){const k=xx(e,u.worktreeId,t.error??`could not read ${u.path}`);return u.disk?k:{...k,editor:null}}const p=Ti(u.path),g=h.before===""?u.view&&u.view!=="diff"?u.view:p:u.view??(h.before===h.after?p:"diff");return{...e,editor:{...u,view:g,disk:h}}}case"editor-conflict":{const u=e.editor;return u&&!u.loose&&pl(u,t.file)?{...e,editor:{...u,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 u=e.editor;if(!u||!pl(u,t.file))return e;const h=u.loose&&u.disk?{...u.disk,writable:!1}:u.disk;return{...e,editor:{...u,refused:t.message,disk:h}}}case"editor-blame":{const u=e.editor;return u&&!u.loose&&pl(u,t.file)?{...e,editor:{...u,blame:t.blame}}:e}case"notice":return Nt(Uo(e),t.id,u=>({...u,notice:t.text}));case"link-refused":return Nt(e,t.id,({refusedLink:u,...h})=>t.v?{...h,refusedLink:t.v}:h);case"ask-draft":return Nt(e,t.id,u=>({...u,ask:t.ask}));case"ask-park":return Nt(e,t.id,u=>({...u,askParked:t.askId}));case"ask-unpark":return Nt(e,t.id,({askParked:u,...h})=>h);case"ask-revive":return Nt(e,t.id,({askRevived:u,...h})=>t.askId?{...h,askRevived:t.askId}:h);case"opened-url":return e.openUrl?{...e,openUrl:null}:e;case"set-draft":return Nt(e,t.id,u=>{const{notice:h,...p}=Rl(u,"walk");return{...p,draft:t.text,...h!==void 0&&t.text===""?{notice:h}:{}}});case"walk":return Nt(e,t.id,u=>({...Rl(u,"walk"),draft:t.text,...t.walk?{mark:{by:"walk",at:t.walk.at,from:t.walk.from}}:{}}));case"reveal":return Nt(Uo(e),t.id,u=>{var h;return{...u,mark:{by:"reveal",seq:t.seq,n:((h=u.mark)==null?void 0:h.by)==="reveal"?u.mark.n+1:1}}});case"attach":return Nt(Uo(e),t.id,({notice:u,...h})=>({...h,attachments:[...h.attachments,...t.items]}));case"attached":return(l=e.local[t.id])!=null&&l.attachments.some(u=>u.key===t.key)?Nt(e,t.id,u=>({...u,attachments:u.attachments.map(h=>h.key===t.key?t.item:h)})):e;case"detach":return Nt(e,t.id,({notice:u,...h})=>({...h,attachments:h.attachments.filter(p=>p.key!==t.key)}));case"clear-attachments":return Nt(e,t.id,({notice:u,...h})=>h.attachments.length?{...h,attachments:[]}:h);case"hmr":return Nt(e,t.id,u=>({...u,turn:{...u.turn,hmr:!0}}));case"page":return Nt(e,t.id,u=>({...u,page:{url:t.url??u.page.url,title:t.title??u.page.title,errors:t.fresh?[]:t.error?[...u.page.errors.slice(-2),t.error]:u.page.errors}}));case"links":return Nt(e,t.id,u=>{const h=j$(u.links??[],t.links);return h===u.links?u:{...u,links:h}});case"drag-files":return $$(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:bx(t.overlay)?e.paletteReturn:null};case"choosing-folder":return{...e,choosingFolder:t.v};case"close":return{...e,previewTheme:null,...G$(e,t.back)};case"toggle":return((c=e.overlay)==null?void 0:c.kind)===t.overlay.kind?ma(e,{a:"close"}):ma(e,{a:"open",overlay:t.overlay});case"palette-return":return{...e,paletteReturn:t.v};case"toggle-changes":return{...to(e,{changes:!e.layout.changes}),changesAuto:!1};case"focus-changes":return{...to(e,{changes:!0,changesTab:t.tab&&!$o(e)?t.tab:e.layout.changesTab}),changesAuto:!1,focusChanges:e.focusChanges+1};case"changes-tab":return to(e,{changesTab:t.v});case"edit-commit":return{...to(e,{changes:!0}),changesAuto:!1,editCommit:e.editCommit+1};case"toggle-chat":return mo(e)?e:to(e,{chat:!e.layout.chat});case"focus-chat":return{...Uo(e),focusChat:e.focusChat+1};case"walked":return{...e,walked:e.walked+1};case"show-chat":return Uo(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:{...e,screen:t.to,editor:null};case"frame":{if(e.frame===t.v)return e;const u={...e,frame:t.v};if(t.v!=="desk"||!u.activeRepoId)return u;const h=u.layouts[u.activeRepoId];return h?xm(u,h):u}case"touch":return e.touch===t.v?e:{...e,touch:t.v};case"rail-peek":return e.railPeek===t.on?e:{...e,railPeek:t.on};case"toggle-discovered":{const u=e.activeRepoId;return u?{...e,discoveredOpen:{...e.discoveredOpen,[u]:!e.discoveredOpen[u]}}:e}case"toggle-archived":{const u=e.activeRepoId;return u?{...e,archivedOpen:{...e.archivedOpen,[u]:!e.archivedOpen[u]}}:e}case"toggle-committed":{const u=e.activeRepoId;return u?{...e,committedShut:{...e.committedShut,[u]:!e.committedShut[u]}}:e}case"toggle-turn":{const u=e.activeRepoId;return u?{...e,turnOpen:{...e.turnOpen,[u]:!e.turnOpen[u]}}:e}case"tree-folder":{const u=e.treeOpen[t.worktreeId]??[];if(u.includes(t.path)===t.open)return e;const h=t.open?[...u,t.path]:u.filter(g=>g!==t.path),p={...e.treeOpen};return h.length>0?p[t.worktreeId]=h:delete p[t.worktreeId],{...e,treeOpen:p}}case"tree-reveal":{const u=e.treeOpen[t.worktreeId]??[],h=[];for(let k=t.path.indexOf("/");k!==-1;k=t.path.indexOf("/",k+1))h.push(t.path.slice(0,k));h.push(t.path);const p=h.filter(k=>!u.includes(k)),g=p.length?{...e.treeOpen,[t.worktreeId]:[...u,...p]}:e.treeOpen;return{...to(e,{changes:!0,changesTab:"files"}),changesAuto:!1,focusChanges:e.focusChanges+1,treeOpen:g,treeReveal:{worktreeId:t.worktreeId,path:t.path}}}case"files-asked":return Nt(e,t.worktreeId,u=>({...u,filesFor:t.key}));case"toggle-zen":return mo(e)?e:{...e,zen:!e.zen};case"toggle-terminal":return to(e,{term:!e.layout.term});case"focus-terminal":return{...to(e,{term:!0}),focusTerm:e.focusTerm+1};case"toggle-design":return mo(e)?e:to(e,{design:!e.layout.design});case"term-stream":return Nt({...to(e,{term:!0}),termTall:t.tall?e.termTall+1:e.termTall},t.id,u=>({...u,termStream:t.stream}));case"term-run":return Nt({...to(e,{term:!0}),focusTerm:e.focusTerm+1,termRun:{id:t.id,command:t.command}},t.id,u=>({...u,termStream:po}));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{...e,incompatible:!0,connected:!1};case"server":return o2(e,t.msg)}}function Bw(e,t){const n=Object.entries(e),r=n.filter(([s])=>t.some(a=>a.id===s));return r.length===n.length?e:Object.fromEntries(r)}function Uw(e,t,n){const r=new Set(t.map(l=>l.id));n&&r.add(n);const s=([l,c])=>r.has(l)||!!c.draft||c.attachments.length>0,a=Object.entries(e);return a.every(s)?e:Object.fromEntries(a.filter(s))}function e2(e,t,n){var s;let r=e;for(const a of n){if(!((s=a.worktree)!=null&&s.landed)||t.some(c=>{var u;return c.id===a.id&&((u=c.worktree)==null?void 0:u.landed)}))continue;const l=r[a.id];!(l!=null&&l.git)||l.git.files.length===0||(r===e&&(r={...e}),r[a.id]={...l,git:{...l.git,files:[]}})}return r}function t2(e,t){let n=e;for(const[r,s]of Object.entries(t)){const a=n[r];a!=null&&a.draft||(n===e&&(n={...e}),n[r]={...a??Ia,draft:s})}return n}function n2(e,t){let n=e;for(const[r,s]of Object.entries(t)){const a=n[r];a!=null&&a.attachments.length||(n===e&&(n={...e}),n[r]={...a??Ia,attachments:mh(s,[])})}return n}function r2(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 pi(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 Hw(e){const t=e.newProject;if((t==null?void 0:t.phase)!=="creating"||!t.repoId)return e;const n=vx(e,t.repoId);return n?t.prompt.trim()?{...Nt(e,n.id,s=>({...s,draft:t.prompt})),newProject:null,autoSend:n.id}:{...e,newProject:null}:e}function Ex(e,t){return Object.values(e.trunks).some(n=>n.id===t)}function o2(e,t){var n,r,s,a,l,c,u,h,p,g,k;switch(t.t){case"hello":{const y=x=>!!x&&t.rows.some(N=>N.id===x),v=x=>!!x&&t.repos.some(N=>N.id===x),_=v(e.activeRepoId)?e.activeRepoId:v(e.storedRepo)?e.storedRepo:null,E=y(e.activeId)?e.activeId:y(e.storedActive)?e.storedActive:Il(e,_,t.rows),C=t.rows.find(x=>x.id===E);return{...e,heard:!0,repos:t.repos,rows:t.rows,activeId:E,activeRepoId:(C==null?void 0:C.repoId)??_??((n=t.repos[0])==null?void 0:n.id)??null,trunks:t.trunks,archiving:e.archiving.length?[]:e.archiving,shipping:Dw({},t.rows,t.trunks),local:Uw(n2(t2(e.local,t.drafts),t.attachments),t.rows,e.archivedPage),lastActive:r2(e.lastActive,t.rows),treeOpen:Bw(e.treeOpen,t.rows),discoveredOpen:pi(e.discoveredOpen,t.repos),archivedOpen:pi(e.archivedOpen,t.repos),committedShut:pi(e.committedShut,t.repos),turnOpen:pi(e.turnOpen,t.repos),refs:pi(e.refs,t.repos),chats:pi(e.chats,t.repos),archived:pi(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,remote:t.remote,managed:t.managed,paired:t.paired,gitIdentity:t.gitIdentity,newProject:e.newProject??(t.repos.length===0&&t.rows.length===0&&t.pending.length===0?Lw():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(x=>x.id===e.activeImportId)?e.activeImportId:null}}case"self":{const y=((r=e.self)==null?void 0:r.building)===!0&&e.self.rebuild&&!((s=t.self)!=null&&s.building);return{...e,self:t.self,rebuilt:e.rebuilt||y&&((a=t.self)==null?void 0:a.buildFailed)===void 0}}case"paired":return{...e,paired:!0,pairings:e.pairings+1};case"update":return{...e,update:t.update};case"update-checked":return{...e,updateCheck:t.check};case"visits":return{...e,visits:{...e.visits,[t.repoId]:t.pages}};case"themes":return{...e,themes:t.themes,themePrefs:t.prefs};case"daylight":return{...e,daylight:{dark:t.dark,until:t.until}};case"agents":return{...e,agents:t.agents,defaultAgent:t.defaultAgent,agentChosen:t.agentChosen};case"agent-config":{const{t:y,...v}=t;return{...e,agentConfigs:{...e.agentConfigs,[v.agent]:v}}}case"pending-repos":{const y=new Set(e.pending.map(x=>x.id)),v=t.pending.find(x=>!y.has(x.id)),_=v&&e.pendingOpen?v.id:e.activeImportId,E=t.pending.some(x=>x.id===_),C=t.pending.some(x=>x.id===_&&x.error);return{...e,pending:t.pending,activeImportId:E?_:null,pendingOpen:C?!1:e.pendingOpen,newProject:v&&e.pendingOpen&&((l=e.newProject)==null?void 0:l.phase)==="creating"?null:e.newProject}}case"path-entries":return{...e,paths:{query:t.query,entries:t.entries,target:t.target}};case"folder-chosen":return{...e,chosenFolder:{seq:(((c=e.chosenFolder)==null?void 0:c.seq)??0)+1,folder:t.folder}};case"refs":return{...e,refs:{...e.refs,[t.repoId]:{query:t.query,refs:t.refs}}};case"chat-hits":return{...e,chats:{...e.chats,[t.repoId]:{query:t.query,hits:t.hits,truncated:t.truncated}}};case"archived":return{...e,archived:{...e.archived,[t.repoId]:t.items}};case"draft":return t.clientId===e.clientId?e:Nt(e,t.boxId,y=>{var v;return y.draft===t.text||((v=y.mark)==null?void 0:v.by)==="walk"?y:{...y,draft:t.text}});case"attachments":return t.clientId===e.clientId?e:Nt(e,t.boxId,y=>({...y,attachments:mh(t.items,y.attachments)}));case"repos":{const y=new Set(e.repos.map(N=>N.id)),v=t.repos.find(N=>!y.has(N.id));let _=e.activeRepoId,E=e.pendingOpen,C=e.newProject;v&&(E||!_)?(_=v.id,E=!1,C&&C.phase!=="unmaking"&&(C={...C,phase:"creating",repoId:v.id})):t.repos.some(N=>N.id===_)||(_=((u=t.repos[0])==null?void 0:u.id)??null),(C==null?void 0:C.phase)==="unmaking"&&!t.repos.some(N=>N.id===(C==null?void 0:C.repoId))&&(C={...C,phase:"editing",repoId:null}),t.repos.length===0&&!C&&(C=Lw());const x=e.gitIdentity||t.repos.some(N=>N.made&&!y.has(N.id));return _===e.activeRepoId?{...e,repos:t.repos,pendingOpen:E,newProject:C,gitIdentity:x}:Hw({...e,repos:t.repos,pendingOpen:E,newProject:C,gitIdentity:x,activeRepoId:_,activeId:Il(e,_),editor:null})}case"worktrees":{let y=e.activeId;(!y||!t.rows.some(N=>N.id===y))&&(y=Il(e,e.activeRepoId,t.rows));const v=new Set(e.rows.map(N=>N.id)),_=N=>{var M;return((M=N.worktree)==null?void 0:M.kind)==="worktree"&&N.worktree.createdBy===e.clientId},E=t.rows.find(N=>!v.has(N.id)&&_(N)),C=!!y&&e.rows.some(N=>{var M;return N.id===y&&((M=N.worktree)==null?void 0:M.kind)==="spare"})&&t.rows.some(N=>N.id===y&&_(N));E&&e.rows.length>0&&!C&&(y=E.id);const x=e.archiving.filter(N=>t.rows.some(M=>M.id===N));return Hw({...xl({...e,rows:t.rows,trunks:t.trunks,archiving:x.length===e.archiving.length?e.archiving:x,shipping:Dw(e.shipping,t.rows,t.trunks),local:K$(e2(Uw(e.local,t.rows,e.archivedPage),e.rows,t.rows),t.rows,e.activeId,y===(E==null?void 0:E.id)?E.id:void 0),treeOpen:Bw(e.treeOpen,t.rows)},y),editor:y===e.activeId?e.editor:null,archivedPage:E?null:e.archivedPage})}case"proc":{const y=e.rows.map(v=>v.id===t.worktreeId?{...v,procs:s2(v.procs,t.proc)}:v);return{...e,rows:y}}case"log":return Nt(e,t.worktreeId,y=>({...y,log:AN(y.log.slice(-400),t.proc,t.line,t.retract)}));case"agent":{const y=t.event,v=t.worktreeId;let _=Nt(e,v,E=>{const C=Kw(E.chat,y,t.seq),N=y.type==="tool-start"||y.type==="tool-end"||y.type==="turn-end"||y.type==="tool-update"&&y.background?zw(C,E.running):E.running;let M=E.turn;y.type==="turn-start"?M={edits:!1,hmr:!1}:y.type==="tool-start"&&K0(y)&&(M={...M,edits:!0});const J=y.type==="session-info"&&y.model?y.model:E.model,W=y.type==="session-info"&&y.effort?y.effort:E.effort,R=y.type==="usage"?{...Ww(y),heard:Date.now()}:E.usage,{restoring:j,...A}=E,D=e.rows.find(ye=>ye.id===v),H=(D==null?void 0:D.agent)==="working"||(D==null?void 0:D.agent)==="waiting",Y=A.sending?H?Ul(A):{...A,sending:{}}:A,ae=y.type==="turn-end"||y.type==="agent-error",me=Z$(y.type==="user-message"?Y:ae?Ul(E):E,y);return{...y.type==="user-message"?Rl(me,"reveal"):me,chat:C,...C!==E.chat?{chatAt:Date.now()}:{},...N!==E.running?{running:N}:{},turn:M,...J!==E.model?{model:J}:{},...W!==E.effort?{effort:W}:{},...R!==E.usage?{usage:R}:{}}});if(y.type==="turn-end"){const E=_.local[v].turn;E.edits&&!E.hmr&&(_={..._,reloadReq:{id:v,n:(((h=_.reloadReq)==null?void 0:h.n)??0)+1}})}return(y.type==="agent-question"||y.type==="agent-permission")&&v===e.activeId&&(_=Uo(_)),_}case"backfill":{let y=[],v;for(const{seq:E,event:C}of t.events)y=Kw(y,C,E),C.type==="usage"&&(v=Ww(C));const _=E=>t.events.some(({event:C})=>C.type==="user-message"&&C.text===E);return Nt(e,t.worktreeId,({restoring:E,sending:C,...x})=>({...x,...C&&!(C.message&&_(C.message.text))?{sending:C}:{},chat:y,chatAt:Date.now(),running:zw(y,x.running),log:t.log??x.log,...v?{usage:v}:{},...E!==void 0&&!_(E)?{restoring:E}:{}}))}case"git-status":{let y=e.layout.changes,v=e.changesAuto;e.changesAuto&&t.worktreeId===e.activeId&&!y&&(t.files.length>0||(((p=t.committed)==null?void 0:p.length)??0)>0)&&(y=!0,v=!1);const _=t.worktreeId===e.archivedPage?$o(e):null;_&&(t.files.length>0||(((g=t.committed)==null?void 0:g.length)??0)>0||_.landed)&&(y=!0);const E=Nt(e,t.worktreeId,C=>({...C,git:{files:t.files,committed:t.committed,turn:t.turn,ahead:t.ahead,behind:t.behind,unpushed:t.unpushed,head:t.head},changedRanges:{}}));return{...to(E,{changes:y}),changesAuto:v}}case"changed-ranges":{const y=Nt(e,t.worktreeId,_=>({..._,changedRanges:{..._.changedRanges,[t.path]:{ranges:t.ranges,offset:t.lineOffset}}})),v=y.editor;return!((k=v==null?void 0:v.line)!=null&&k.fiber)||v.worktreeId!==t.worktreeId||v.path!==t.path?y:{...y,editor:{...v,line:gx(y,v.worktreeId,v.path,v.line)}}}case"shipped":{const y=t.worktreeId,v=t.suggestion?Nt(e,y,E=>({...E,draft:t.suggestion})):e,_={...v,shipping:Pw(v.shipping,E=>{var C;return E===y&&((C=v.shipping[E])==null?void 0:C.sent)===!0}),openUrl:t.ok&&t.url?t.url:v.openUrl};return t.ok?_:y?Fw(_,y,t.message):gh(_,t.message)}case"files":return Nt(e,t.worktreeId,y=>({...y,files:t.paths,submodules:t.submodules,ignored:t.ignored}));case"search-results":return Nt(e,t.worktreeId,y=>({...y,search:{query:t.query,hits:t.hits,truncated:t.truncated}}));case"element-sources":{if(e.editor&&e.editor.seq>t.seq)return e;const[y]=t.hits;if(!y)return Nt(e,t.worktreeId,_=>({..._,notice:"nothing in the source matches this element"}));if(!t.sure)return ma(e,{a:"open",overlay:{kind:"element-sources",worktreeId:t.worktreeId,hits:t.hits}});const v=ma(e,{a:"open-file",v:{worktreeId:t.worktreeId,path:y.path,view:"file",line:{n:y.line},focus:!0,seq:t.seq}});return v.layout.changes?v:ma(v,{a:"toggle-changes"})}case"design-index":return Nt(e,t.worktreeId,y=>({...y,design:t.index}));case"routes":return Nt(e,t.worktreeId,y=>({...y,pages:{routes:t.routes,unseen:t.unseen}}));case"queue":return Nt(e,t.worktreeId,y=>({...y,queue:t.items}));case"agent-commands":return Nt(e,t.worktreeId,y=>({...y,commands:t.commands}));case"git-log":return Nt(e,t.worktreeId,y=>({...y,commits:t.commits}));case"git-commit":return Nt(e,t.worktreeId,y=>({...y,commitFiles:{...y.commitFiles,[t.sha]:t.files}}));case"error":{const y=t.worktreeId,v=e.newProject,_=(v==null?void 0:v.phase)==="creating"&&!v.repoId,E={...W$(e,y),archiving:y?e.archiving.includes(y)?e.archiving.filter(C=>C!==y):e.archiving:e.archiving.length?[]:e.archiving,shipping:Pw(e.shipping,C=>!y||C===y),newProject:_?{...v,phase:"editing",error:t.message}:(v==null?void 0:v.phase)==="unmaking"?null:v,pendingOpen:_?!1:e.pendingOpen,updateCheck:!y&&e.updateCheck==="asking"?null:e.updateCheck};return _?E:y?Fw(E,y,t.message):gh(E,t.message)}case"unsent":return Nt(Uo(e),t.boxId,({restoring:y,sending:v,..._})=>({..._,draft:_.draft||t.text,attachments:[...mh(t.items,[]),..._.attachments],notice:t.message}));default:return e}}function s2(e,t){const n=e.findIndex(s=>s.name===t.name);if(n===-1)return[...e,t];const r=e.slice();return r[n]=t,r}function Ww(e){return{used:e.used,size:e.size,...e.cost!==void 0?{cost:e.cost}:{}}}function i2(e,t){const n=t.trim();return n!==""&&(e.trim()===n||e.trim().endsWith(`: ${n}`))}function Kw(e,t,n){var a,l;const r=e[e.length-1],s=n===void 0?{}:{seq:n};switch(t.type){case"user-message":return[...e,{kind:"user",text:t.text,...(a=t.attachments)!=null&&a.length?{attachments:t.attachments}:{},...s}];case"text-delta":{const c=t.messageId?{messageId:t.messageId}:{};if((r==null?void 0:r.kind)==="assistant")return[...e.slice(0,-1),{...r,text:r.text+t.text,...c}];const u=t.messageId===void 0?-1:a2(e,t.messageId);if(u!==-1){const h=e.slice(),p=h[u];return h[u]={...p,text:p.text+t.text},h}return[...e,{kind:"assistant",text:t.text,...s,...c}]}case"thinking-delta":return(r==null?void 0:r.kind)==="thinking"?[...e.slice(0,-1),{...r,text:r.text+t.text}]:[...e,{kind:"thinking",text:t.text}];case"tool-start":return[...e,{kind:"tool",id:t.toolId,name:t.name,input:t.input,done:!1,...t.kind?{toolKind:t.kind}:{},...t.title?{title:t.title}:{},...t.parentToolId?{parentToolId:t.parentToolId}:{},...t.subagent?{subagent:!0}:{}}];case"tool-update":{const c=e.findLastIndex(p=>p.kind==="tool"&&p.id===t.toolId);if(c===-1)return e;const u=e.slice(),h=u[c];return u[c]={...h,...t.name?{name:t.name}:{},...t.title?{title:t.title}:{},...t.input!==void 0?{input:t.input}:{},...t.kind?{toolKind:t.kind}:{},...t.background?{background:!0}:{}},u}case"tool-delta":{const c=e.findLastIndex(p=>p.kind==="tool"&&p.id===t.toolId);if(c===-1)return e;const u=e.slice(),h=u[c];return u[c]={...h,output:(h.output??"")+t.text},u}case"tool-end":{const c=e.findLastIndex(p=>p.kind==="tool"&&p.id===t.toolId);if(c===-1)return e;const u=e.slice(),h=u[c];return u[c]={...h,output:t.output,isError:t.isError,...(l=t.images)!=null&&l.length?{images:t.images}:{},...t.detached?{detached:!0}:{},done:!0},u}case"agent-error":return(r==null?void 0:r.kind)==="assistant"&&i2(t.message,r.text)?[...e.slice(0,-1),{kind:"error",text:t.message}]:[...e,{kind:"error",text:t.message}];case"agent-blocked":return[...e,{kind:"blocked",tool:t.tool,path:t.path,reason:t.reason}];case"grafted":return[...e,{kind:"grafted",title:t.title,branch:t.branch}];case"landed":return[...e,{kind:"landed",text:t.message,archiveIds:t.archiveIds,ts:t.ts}];case"restored":return[...e,{kind:"restored",archivedAt:t.archivedAt,branch:t.branch,uncommitted:t.uncommitted,ts:t.ts}];case"agent-auth-required":return[...e,{kind:"auth",agent:t.agent,agentName:t.agentName,methods:t.methods,...t.rejected?{rejected:!0}:{},...t.withheld?{withheld:!0}:{},done:!1}];case"agent-auth-ok":return e.some(c=>c.kind==="auth"&&!c.done)?e.map(c=>c.kind==="auth"&&!c.done?{...c,done:!0}:c):e;case"agent-question":return Zw(e,t.toolId,{kind:"ask",id:t.id,ask:{kind:"question",message:t.message,questions:t.questions}});case"agent-permission":{const c={kind:"ask",id:t.id,ask:{kind:"permission",title:t.title,...t.detail?{detail:t.detail}:{},...t.plan?{plan:t.plan}:{},choices:t.choices}},u=e.findLast(h=>h.kind==="tool"&&h.id===t.toolId);return(u==null?void 0:u.kind)!=="tool"||t.plan||u.toolKind==="switch_mode"?Zw(e,t.toolId,c):[...e,{...c,toolId:u.id}]}case"agent-ask-end":{const c=e.findLastIndex(p=>p.kind==="ask"&&p.id===t.id&&!p.outcome);if(c===-1)return e;const u=e[c];if(u.toolId&&l2(u,t.choiceId))return[...e.slice(0,c),...e.slice(c+1)];const h=e.slice();return h[c]={...h[c],outcome:t.outcome,...t.answers?{answers:t.answers}:{},...t.choiceId?{choiceId:t.choiceId}:{}},h}case"turn-end":{const c=u=>u.kind==="tool"&&!u.done&&!u.background;return e.some(c)?e.map(u=>c(u)?{...u,done:!0}:u):e}default:return e}}function a2(e,t){var s;let n=e.length-1;for(;n>=0&&((s=e[n])==null?void 0:s.kind)==="user";)n--;const r=e[n];return(r==null?void 0:r.kind)==="assistant"&&r.messageId===t?n:-1}function l2(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 Zw(e,t,n){const r=t?e.findLastIndex(s=>s.kind==="tool"&&s.id===t):-1;return r===-1?[...e,n]:[...e.slice(0,r),...e.slice(r+1),n]}function c2(e){let t=e;const n=new Set;return{getState:()=>t,dispatch(r){const s=ma(t,r);if(s!==t){t=s;for(const a of n)a()}},subscribe(r){return n.add(r),()=>n.delete(r)}}}const Sx=S.createContext(null),Nx=S.createContext(null),Tx=S.createContext(null);function u2({store:e,sock:t,files:n,children:r}){return f.jsx(Sx.Provider,{value:e,children:f.jsx(Nx.Provider,{value:t,children:f.jsx(Tx.Provider,{value:n,children:r})})})}function Un(){const e=S.useContext(Sx);if(!e)throw new Error("useStore outside <StoreProvider>");return e}function P(e){const t=Un();return S.useSyncExternalStore(t.subscribe,()=>e(t.getState()))}function Em(){const e=P(n=>n.systemDark),t=P(n=>{var r;return(r=n.daylight)==null?void 0:r.dark});return{system:e,daylight:t??e}}function ht(){return Un().dispatch}function ot(){return S.useContext(Nx)}function jx(){return S.useContext(Tx)}const _t={active:"toyon-active",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",layouts:"toyon-layouts",client:"toyon-client",profilePrefix:"toyon-profile-",modePrefix:"toyon-mode-",modelPrefix:"toyon-model-",effortPrefix:"toyon-effort-"},d2="orch-";function f2(){for(const[e,t]of[[localStorage,["active","token","theme","editorHeight","editorFull"]],[sessionStorage,["client"]]])for(const n of t){const r=_t[n],s=d2+r.slice(6);try{const a=e.getItem(s);a!==null&&(e.getItem(r)===null&&e.setItem(r,a),e.removeItem(s))}catch{}}}function p2(e=!1,t=!0){const n=S.useRef(null);return S.useEffect(()=>{if(!t)return;const r=()=>{const a=n.current;!a||document.activeElement===a||(a.focus(),e&&a instanceof HTMLInputElement&&a.select())};r();const s=requestAnimationFrame(r);return()=>cancelAnimationFrame(s)},[e,t]),n}function ho(e,t,n){const r=()=>{try{return n(localStorage.getItem(e))??t}catch{return t}},[s,a]=S.useState(()=>({key:e,value:r()}));return s.key!==e&&a({key:e,value:r()}),[s.key===e?s.value:r(),u=>{a({key:e,value:u});try{localStorage.setItem(e,typeof u=="boolean"?u?"1":"0":String(u))}catch{}}]}function ga(e,t){return n=>{n.preventDefault(),document.body.classList.add("resizing");const r=n.currentTarget;r.classList.add("active");const s=l=>{const c=e(l,r);c!==null&&t(c)},a=()=>{document.body.classList.remove("resizing"),r.classList.remove("active"),window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",a)};window.addEventListener("pointermove",s),window.addEventListener("pointerup",a)}}function Cx(e,t){const[n,r]=S.useState(!1);return S.useEffect(()=>{if(!e){r(!1);return}const s=setTimeout(()=>r(!0),t);return()=>clearTimeout(s)},[e,t]),n}function Ax(e,t){const[n,r]=S.useState(void 0);return S.useEffect(()=>{if(e===void 0){r(void 0);return}const s=setTimeout(()=>r(e),t);return()=>clearTimeout(s)},[e,t]),n}const Ix=1500;function _a(e){const[t,n]=S.useState(()=>Date.now()),r=e!==void 0;return S.useEffect(()=>{if(!r)return;n(Date.now());const s=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(s)},[r]),r?Math.max(0,Math.floor((t-e)/1e3)):0}function h2(){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 m2(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 s=r.getBoundingClientRect(),a=n.getBoundingClientRect(),l=a.bottom-s.bottom;if(l<=0)return;const c=parseFloat(getComputedStyle(r).paddingTop)||0;r.scrollTop+=Math.min(l,Math.max(0,a.top-s.top-c))}),n=>{t.current=n}}const yu=40,g2=1200;function Rx(e,t){const n=S.useRef(!0),r=S.useRef(null),[s,a]=S.useState(!1),[l,c]=S.useState(!1),[u,h]=S.useState(!1),[p,g]=S.useState(null),k=S.useRef(null),y=S.useRef(null);gt([t],()=>{n.current||h(!0)});const v=S.useCallback(()=>{const x=e.current;x&&(n.current=x.scrollHeight-x.scrollTop-x.clientHeight<yu,a(!n.current),c(x.scrollTop>=yu),n.current&&h(!1))},[e]),_=S.useCallback(x=>{x!==0&&(g(x<0?"up":"down"),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>g(null),g2))},[]),E=S.useCallback(()=>{const x=e.current;x&&(x.scrollTop=x.scrollHeight,r.current=x.scrollTop,n.current=!0,a(!1),h(!1))},[e]),C=S.useCallback(()=>{e.current&&(e.current.scrollTop=0)},[e]);return S.useEffect(()=>{const x=e.current;if(!x)return;const N=()=>{n.current&&x.scrollTop===r.current?c(x.scrollTop>=yu):v()};x.addEventListener("scroll",N,{passive:!0});const M=D=>_(D.deltaY),J=D=>{var H;k.current=((H=D.touches[0])==null?void 0:H.clientY)??null},W=D=>{var Y;const H=(Y=D.touches[0])==null?void 0:Y.clientY;H===void 0||k.current===null||(_(k.current-H),k.current=H)};x.addEventListener("wheel",M,{passive:!0}),x.addEventListener("touchstart",J,{passive:!0}),x.addEventListener("touchmove",W,{passive:!0});const R=()=>{x.scrollTop=x.scrollHeight,r.current=x.scrollTop},j=new ResizeObserver(()=>{n.current&&R()});j.observe(x);for(const D of x.children)j.observe(D);const A=new MutationObserver(D=>{for(const H of D){for(const Y of H.addedNodes)Y instanceof Element&&j.observe(Y);for(const Y of H.removedNodes)Y instanceof Element&&j.unobserve(Y)}n.current&&x.scrollHeight-x.scrollTop-x.clientHeight<yu&&R()});return A.observe(x,{childList:!0}),()=>{x.removeEventListener("scroll",N),x.removeEventListener("wheel",M),x.removeEventListener("touchstart",J),x.removeEventListener("touchmove",W),A.disconnect(),j.disconnect(),y.current&&clearTimeout(y.current)}},[e,v,_]),{offEnd:s,offStart:l,away:u,moving:p,pinned:()=>n.current,jump:E,start:C,read:v}}function qw(e,t,n){const r=document.createRange();return r.selectNodeContents(e),r.setEnd(t,n),r.toString().length}function Gw(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=0,s=null;for(let a=n.nextNode();a;a=n.nextNode()){if(r+a.data.length>=t)return[a,t-r];r+=a.data.length,s=a}return s?[s,s.data.length]:[e,0]}function Ox(e,t){S.useLayoutEffect(()=>{const n=e.current;if(!n)return;const r=window.getSelection(),s=k=>!!k&&n.contains(k),a=r&&r.rangeCount>0&&s(r.anchorNode)?qw(n,r.anchorNode,r.anchorOffset):null,l=r&&r.rangeCount>0&&s(r.focusNode)?qw(n,r.focusNode,r.focusOffset):null,c=r&&(a!==null||l!==null)?[r.anchorNode,r.anchorOffset,r.focusNode,r.focusOffset]:null;if(n.innerHTML=t,!r||!c)return;const[u,h]=a===null?[c[0],c[1]]:Gw(n,a),[p,g]=l===null?[c[2],c[3]]:Gw(n,l);u&&p&&r.setBaseAndExtent(u,h,p,g)},[e,t])}function gt(e,t){const n=S.useRef(t);n.current=t,S.useEffect(()=>n.current(),e)}function $x(e){const[t,n]=S.useState({left:0,right:0});return S.useLayoutEffect(()=>{if(!e)return;const r=()=>{const a=e.getBoundingClientRect();let{left:l,right:c}=a;const u=e.closest("[data-pinned]");if(u){const p=u.getBoundingClientRect(),g=u.offsetWidth/p.width;l=u.offsetLeft+(l-p.left)*g,c=u.offsetLeft+(c-p.left)*g}const h={left:Math.round(l),right:Math.round(c)};n(p=>p.left===h.left&&p.right===h.right?p:h)};r();const s=new ResizeObserver(r);return s.observe(e),window.addEventListener("resize",r),()=>{s.disconnect(),window.removeEventListener("resize",r)}},[e]),t}function Vw(){const[e,t]=S.useState(null);return[t,$x(e)]}function g9(e){e.ctrlKey&&e.stopPropagation()}function k2(e){S.useEffect(()=>{const t=window.visualViewport;if(!t)return;const n=()=>{const r=e.current;if(r){if(t.scale<1.01){delete r.dataset.pinned;return}r.dataset.pinned="",r.style.setProperty("--pin-x",`${t.offsetLeft}px`),r.style.setProperty("--pin-y",`${t.offsetTop}px`),r.style.setProperty("--pin-scale",String(1/t.scale))}};return n(),t.addEventListener("resize",n),t.addEventListener("scroll",n),()=>{t.removeEventListener("resize",n),t.removeEventListener("scroll",n)}},[e])}const Oa=()=>P(e=>e.activeId),Mx=()=>Cx(!P(e=>e.connected),900),us=()=>P(e=>fn(e,e.activeId)),Sm=()=>P(e=>cs(e,e.activeId)),Lx=()=>P(e=>e.rows),Nm=()=>P(e=>e.visible),y2=()=>P(e=>e.visibleDiscovered),w2=()=>P(e=>e.activeRepoId?e.discoveredOpen[e.activeRepoId]??!1:!1),Yw=[],v2=()=>P(e=>e.activeRepoId?e.archived[e.activeRepoId]??Yw:Yw),b2=()=>P(e=>e.activeRepoId?e.archivedOpen[e.activeRepoId]??!1:!1),x2=()=>P(e=>!(e.activeRepoId&&e.committedShut[e.activeRepoId])),_2=()=>P(e=>!!(e.activeRepoId&&e.turnOpen[e.activeRepoId])),Ai=()=>P($o),$a=()=>P(e=>Ra(e,e.activeRepoId)),Px=e=>P(t=>go(t,e)),At=(e,t)=>P(n=>go(n,e)[t]),E2=()=>P(e=>e.overlay),Rd=()=>P(L$),Dx=()=>P(yx),nc=()=>P(P$),rc=()=>P(mo),S2=()=>P(e=>e.newProject),Gs=()=>P(e=>e.touch),N2=()=>P(e=>e.draft),Tm=()=>P(bl),T2=()=>P(e=>{const t=cs(e,e.activeId),n=t?e.repos.find(r=>r.id===t.repoId):null;return ed(n)?n:null}),zx="application/x-toyon-source";function k9(e){const t=e.endColumn===1&&e.endLineNumber>e.startLineNumber?e.endLineNumber-1:e.endLineNumber;return{startLine:e.startLineNumber,endLine:t}}function j2(e,t){e.setData(zx,JSON.stringify(t))}const Qw=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1;function C2(e,t){const n=e.getData(zx);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:s,endLine:a,ref:l}=r;return!Qw(s)||!Qw(a)||a<s?null:{path:r.path,startLine:s,endLine:a,...typeof l=="string"?{ref:l}:{}}}const Fx=e=>({left:e.x,top:e.y,right:e.x,bottom:e.y});function A2(e,t){return t.matchWidth===void 0?void 0:Math.max(0,e.right-e.left+t.matchWidth)}const I2=new Set(["top","bottom"]),Ap={top:"bottom",bottom:"top",left:"right",right:"left"};function Ip(e,t,n,r,s){const a=n==="top"||n==="left";return s?a?e.end+r-t:e.start-r:a?e.start-r-t:e.end+r}function Xw(e,t,n,r,s){return n==="top"||n==="left"?e>=s:e+t<=r-s}function Rp(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 Jw(e,t,n,r,s){return n==="start"?e+t<=r-s:e>=s}const ev=(e,t,n,r)=>n||!r?e:t,tv=(e,t,n,r)=>Math.max(r,Math.min(e,n-r-t));function R2(e,t,n,r){const{offset:s=0,alignOffset:a=0,cover:l=!1,flip:c="none",margin:u=8}=r,h=I2.has(r.side),p=h?{a:{start:e.top,end:e.bottom},size:t.h,limit:n.h}:{a:{start:e.left,end:e.right},size:t.w,limit:n.w},g=h?{a:{start:e.left,end:e.right},size:t.w,limit:n.w}:{a:{start:e.top,end:e.bottom},size:t.h,limit:n.h};let k=r.side;if(c==="side"||c==="both"){const E=Ip(p.a,p.size,k,s,l),C=Ip(p.a,p.size,Ap[k],s,l);k=ev(k,Ap[k],Xw(E,p.size,k,p.limit,u),Xw(C,p.size,Ap[k],p.limit,u))}let y=r.align??"center";if((c==="align"||c==="both")&&y!=="center"){const E=y==="start"?"end":"start",C=Rp(g.a,g.size,y,a),x=Rp(g.a,g.size,E,a);y=ev(y,E,Jw(C,g.size,y,g.limit,u),Jw(x,g.size,E,g.limit,u))}const v=tv(Ip(p.a,p.size,k,s,l),p.size,p.limit,u),_=tv(Rp(g.a,g.size,y,a),g.size,g.limit,u);return h?{x:_,y:v,side:k,align:y}:{x:v,y:_,side:k,align:y}}function O2(e,t,n){var a,l;const r=e.length;if(r===0)return-1;let s=t<0?n===1?0:r-1:(t+n+r)%r;for(let c=0;c<r&&((a=e[s])!=null&&a.disabled);c++)s=(s+n+r)%r;return(l=e[s])!=null&&l.disabled?-1:s}const Bx={sep:!0},xi=e=>!("sep"in e);function Od(e){const t=[];for(const n of e)(xi(n)||t.length>0&&xi(t[t.length-1]))&&t.push(n);for(;t.length>0&&!xi(t[t.length-1]);)t.pop();return t}const Mn=e=>Od(e.flatMap((t,n)=>n?[Bx,...t]:t));let oa=null,$2=0;const kh=new Set,nv=()=>{for(const e of kh)e()},Hr={get:()=>oa,subscribe(e){return kh.add(e),()=>{kh.delete(e)}},open(e){const t=Od(e.items);if(t.length===0)return Hr.close();oa={...e,items:t,id:++$2},nv()},close(){oa&&(oa=null,nv())},toggle(e){oa&&oa.target===e.target?Hr.close():Hr.open(e)}};function Ux(){return S.useSyncExternalStore(Hr.subscribe,Hr.get)}function Hx(e){const t=e.nativeEvent;return t&&"pointerType"in t?t.pointerType==="":e.clientX===0&&e.clientY===0}function M2(e,t){return Hx(e)?{anchor:(t.querySelector('[data-state~="cursor"]')??t).getBoundingClientRect()}:{at:{x:e.clientX,y:e.clientY}}}function L2(e){const t=e.anchor;return t?{rect:t,placement:{side:"bottom",align:e.align==="right"?"end":"start",offset:4,margin:4}}:{rect:Fx(e.at??{x:0,y:0}),placement:{side:"bottom",align:"start",margin:4}}}function Jt(e){return S.useMemo(()=>({contextMenu(t,n){return{onContextMenu:r=>{const s=Od(t(Hx(r)?"keyboard":"pointer",r.target));if(s.length===0)return;r.preventDefault(),r.stopPropagation();const a=r.currentTarget;Hr.open({items:s,owner:e,key:n,target:a,...M2(r,a)})}}},dropdown(t,n="left"){return{"aria-haspopup":"menu",onClick:r=>{r.stopPropagation();const s=r.currentTarget;Hr.toggle({items:t(),owner:e,target:s,toggles:!0,anchor:s.getBoundingClientRect(),align:n})}}},openUnder(t,n,r){Hr.open({items:n(),owner:e,key:r,target:t,toggles:!0,anchor:t.getBoundingClientRect(),align:"left"})}}),[e])}const Wx=e=>({id:"open-out",label:Ad()?"open in the browser":"open in a new tab",onClick:()=>window.open(e,"_blank")}),Bt=e=>{var t;return void((t=navigator.clipboard)==null?void 0:t.writeText(e).catch(()=>{}))};function Kx(e,t){const n=navigator.clipboard;if(n){if(typeof ClipboardItem>"u"||!n.write){e==="text/plain"&&t.then(r=>r.text()).then(Bt,()=>{});return}n.write([new ClipboardItem({[e]:t})]).catch(()=>{})}}const P2=e=>Kx("text/plain",fetch(e).then(t=>t.blob())),D2=e=>Kx("image/png",z2(e));async function z2(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((s,a)=>r.toBlob(l=>l?s(l):a(new Error("could not encode image")),"image/png"))}finally{n.close()}}const F2=[{label:"Zed",scheme:"zed"},{label:"VS Code",scheme:"vscode"},{label:"Cursor",scheme:"cursor"}];function jm(e){return e==="127.0.0.1"||e==="localhost"||e==="[::1]"||e.endsWith(".localhost")}function ji(e,t,n=location.hostname){if(!jm(n))return[];const r=F2.map(s=>({id:`open:${s.scheme}`,label:`open in ${s.label}`,onClick:()=>{window.location.href=`${s.scheme}://file${e}`}}));return r.push(...$d(t,n)),r}function $d(e,t=location.hostname){return!e||!jm(t)?[]:[{id:"reveal",label:"reveal in Finder",onClick:e}]}function B2(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??""}
|
|
96
|
+
${n.sort().join(`
|
|
97
|
+
`)}`}function Md(e,t,{sock:n,dispatch:r}){var l,c;if(!n)return;const s=t.local[e]??Ia,a=B2((l=s.git)==null?void 0:l.head,((c=s.git)==null?void 0:c.files)??[]);s.filesFor!==a&&(r({a:"files-asked",worktreeId:e,key:a}),n.send({t:"list-files",worktreeId:e}))}const U2=["diff","file","preview"],Zx=(e,t)=>U2.filter(n=>!(n==="preview"&&!Cd(e))&&!(n==="diff"&&t));let H2=0;const Io=()=>++H2;function Vn({dispatch:e},{focus:t=!0,...n}){e({a:"open-file",v:{...n,focus:t,seq:Io()}})}const yh=new Map;function qx(e,t,n=""){const{sock:r}=e;if(!r)return Promise.resolve("not connected to the daemon");const s=Io();return new Promise(a=>{yh.set(s,l=>{l.ok?(Vn(e,{...t,view:Ti(t.path)}),a(null)):a(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:s})})}function W2(e){const t=yh.get(e.seq);return t?(yh.delete(e.seq),t(e),!0):!1}function K2({dispatch:e},t){e({a:"tree-reveal",...t})}function is(e,t,{discard:n=!1,ref:r,since:s,showing:a,added:l=!1,kept:c=!1,select:u},h){const{sock:p,dispatch:g}=h,k=Zx(t,l).filter(x=>x!==a).map(x=>({id:`view:${x}`,label:`view ${x}`,onClick:()=>a?g({a:"editor-view",v:x}):Vn(h,{worktreeId:e.id,path:t,view:x,ref:r,since:s})})),y=`${e.dir}/${t}`,v=c?[]:ji(y,()=>p==null?void 0:p.send({t:"reveal",worktreeId:e.id,path:t}));return Mn([k,[{id:"copy-path",label:"copy path",onClick:()=>Bt(y)}],v,u?[{id:"select",label:"select…",onClick:()=>u(t)}]:[],n?[{id:"discard",label:"discard changes…",danger:!0,onClick:()=>{window.confirm(Gx([t]))&&(p==null||p.send({t:"discard-files",worktreeId:e.id,paths:[t]}))}}]:[]])}function Gx(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(`
|
|
98
|
+
`);return`Discard uncommitted changes to ${e.length} files?
|
|
99
|
+
|
|
100
|
+
${r}`}function qo(){const e=location.hash.match(/token=([a-f0-9]+)/);if(e!=null&&e[1]){try{localStorage.setItem(_t.token,e[1])}catch{}return e[1]}try{return localStorage.getItem(_t.token)??sessionStorage.getItem(_t.token)??""}catch{return""}}function Vx(){return qo()!==""}function Lu(e,t){return`/attachments/${e}/${t}?token=${qo()}`}function nd(e){return`/uploads/${e}?token=${qo()}`}async function rv(e,t){try{await t.slice(0,1).arrayBuffer()}catch{return"could not be read"}try{const n=await fetch(`/uploads?kind=${e}`,{method:"POST",headers:{authorization:`Bearer ${qo()}`,"content-type":t.type||"application/octet-stream"},body:t});return n.status>=502&&n.status<=504?null:n.ok?await n.json():await n.text()||"could not be attached"}catch{return null}}function Cm(e,t,n){const r=t.split("/").map(encodeURIComponent).join("/");return`/files/${e}/${r}?token=${qo()}&v=${encodeURIComponent(n??"")}`}function Z2(e,t){return`/loose/${encodeURIComponent(e)}?token=${qo()}&v=${encodeURIComponent(t??"")}`}async function q2(e=!1){try{const t=await fetch(`/restart?token=${qo()}${e?`&${dO}`:""}`,{method:"POST"});return t.ok?null:await t.text()||"Toyon did not restart"}catch{return null}}async function Yx(){try{const e=await fetch(`/restart?token=${qo()}`,{signal:AbortSignal.timeout(2e3)});if(!e.ok)return null;const{waiting:t,asking:n}=await e.json();return Array.isArray(t)?{waiting:t,asking:Array.isArray(n)?n:[]}:null}catch{return null}}async function G2(){try{const e=await fetch("/pair",{method:"POST",headers:{authorization:`Bearer ${qo()}`}});return e.ok?await e.json():await e.text()||"Toyon did not make a code"}catch{return"Toyon is not answering; try again once it is back."}}async function wh(){try{const e=await fetch("/health",{signal:AbortSignal.timeout(2e3)});return e.ok?(await e.json()).pid??null:null}catch{return null}}const V2=1e3,Y2=3e4,Q2=1500,ov=50,X2=e=>e.t==="chat"||e.t==="create-worktree"||e.t==="restore-worktree"||e.t==="batch-worktrees";class J2{constructor(t,n){Ct(this,"ws",null);Ct(this,"queue",[]);Ct(this,"closed",!1);Ct(this,"attempt",0);Ct(this,"timer",null);Ct(this,"downAt",null);Ct(this,"sayTimer",null);Ct(this,"sentDown",new Set);Ct(this,"wake",()=>{var n;if(this.closed||document.visibilityState!=="visible")return;const t=(n=this.ws)==null?void 0:n.readyState;t===WebSocket.OPEN||t===WebSocket.CONNECTING||(this.timer&&clearTimeout(this.timer),this.timer=null,this.attempt=0,this.connect())});this.onMsg=t,this.onStatus=n,this.connect(),document.addEventListener("visibilitychange",this.wake),window.addEventListener("online",this.wake)}async diagnose(t){if(t===iT)return"unauthorized";try{return(await fetch("/health",{signal:AbortSignal.timeout(2e3)})).ok?"blocked":"down"}catch{return"down"}}say(t){this.downAt??(this.downAt=Date.now());const n=this.downAt;this.diagnose(t).then(r=>{this.closed||this.downAt===null||this.downAt!==n||(this.sayTimer&&clearTimeout(this.sayTimer),this.sayTimer=setTimeout(()=>{!this.closed&&this.downAt!==null&&this.onStatus(!1,r)},Math.max(0,n+Q2-Date.now())))})}connect(){if(this.closed)return;const n=`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws?token=${qo()}`,r=new WebSocket(n);this.ws=r;let s=!1;r.onmessage=a=>{if(!s){s=!0,this.attempt=0,this.downAt=null,this.sayTimer&&clearTimeout(this.sayTimer),this.sayTimer=null,this.onStatus(!0);for(const l of this.queue)r.send(l.raw);this.queue=[]}try{this.onMsg(JSON.parse(a.data))}catch{}},r.onclose=a=>{if(this.ws!==r||(this.onStatus(!1),this.closed))return;this.say(a.code);const l=Math.min(Y2,V2*2**this.attempt++);this.timer=setTimeout(()=>this.connect(),l/2+Math.random()*(l/2))},r.onerror=()=>r.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(s=>s.key!==r)),X2(t)&&t.boxId&&this.sentDown.add(t.boxId),this.queue.push({key:r,raw:n}),this.queue.length>ov&&this.queue.splice(0,this.queue.length-ov)}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()}}const ro=(e,t,n)=>e.dispatch({a:"notice",id:t,text:n});function Ld(e,t,n){var s;const r=FN(((s=e.getState().local[t])==null?void 0:s.attachments)??[],n);return r===0&&ro(e,t,tm(n)),r}const eM=1e3,tM=1e4;async function Qx(e,t,n,r){var h;const{local:s,...a}=n;e.dispatch({a:"attach",id:t,items:[{...n,upload:"",uploading:!0}]});const l=()=>{var p;return!!((p=e.getState().local[t])!=null&&p.attachments.some(g=>g.key===n.key))};let c=await rv(n.kind,r);const u=c===null;u&&ro(e,t,`${n.name}: Toyon is not answering; it attaches once it is back`);for(let p=eM;c===null&&l();p=Math.min(p*2,tM))await new Promise(g=>setTimeout(g,p)),l()&&(c=await rv(n.kind,r));if(c!==null)if(typeof c=="string")e.dispatch({a:"detach",id:t,key:n.key}),ro(e,t,`${n.name}: ${c}`);else{const p=a.kind==="file"?{...a,...c}:{...a,upload:c.upload,bytes:c.bytes};e.dispatch({a:"attached",id:t,key:n.key,item:p});const g=(h=e.getState().local[t])==null?void 0:h.notice;u&&(g!=null&&g.startsWith(`${n.name}: Toyon is not answering`))&&ro(e,t,"")}s&&URL.revokeObjectURL(s)}function Am(e,t,n){if(!t||n.length===0)return;const r=Ld(e,t,"file");if(r!==0){for(const s of n.slice(0,r)){const a=s.name||"file";if(s.size>ww){ro(e,t,`${a}: larger than ${nm(ww)}`);continue}const l={kind:"file",key:crypto.randomUUID(),upload:"",name:a,bytes:s.size,text:!1};Qx(e,t,l,s)}n.length>r&&ro(e,t,`kept ${r} of ${n.length}: ${tm("file")}`)}}function Xx(e,t,n,r={}){if(!t)return;const s=XR(r.source?n.replace(/\r?\n$/,""):n);if(s.length>HR)return r.source?ro(e,t,"that paste is too large; save it in the worktree and reference it with @path"):Am(e,t,[new File([s],WR,{type:"text/plain"})]);Ld(e,t,"paste")!==0&&e.dispatch({a:"attach",id:t,items:[{kind:"paste",key:crypto.randomUUID(),text:s,...r,...fm(s)}]})}function Jx(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 sv(e,t){var a;const n=e.getState(),r=fn(n,n.activeId),s=tc(r);if(t&&s&&t.worktreeId===(r==null?void 0:r.worktree.id)&&t.text.trim()){const l="source"in t?{source:t.source}:{name:t.name};(((a=n.local[s])==null?void 0:a.attachments)??[]).some(u=>{var y;if(u.kind!=="paste")return!1;if(!("source"in t))return u.name===t.name&&u.text===t.text;const{path:h,startLine:p,endLine:g,ref:k}=t.source;return((y=u.source)==null?void 0:y.path)===h&&u.source.startLine===p&&u.source.endLine===g&&u.source.ref===k})||Xx(e,s,t.text,l)}e.dispatch(t?{a:"focus-chat"}:wx(n))}function Pd(e,t){return t!==e.activeId?null:tc(fn(e,t))}const Im=(e,t)=>`@${e}${t?"/":""}`;function Rm(e,t,n){var c;const r=e.getState(),s=Pd(r,t);if(!s)return;const a=((c=r.local[s])==null?void 0:c.draft)??"",l=a===""||/\s$/.test(a)?"":" ";e.dispatch({a:"set-draft",id:s,text:`${a}${l}${n}`}),e.dispatch({a:"focus-chat"})}function e1(e,t,n,r){Rm(e,t,`${Im(n,r)} `)}function nM(e,t,n){n.length!==0&&Rm(e,t,`${n.map(r=>Im(r,!1)).join(" ")} `)}function iv(e,t,n){Rm(e,t,n)}function rM(e,t){return fn(e,t)?t:null}function oM(e,t){var r;const n=(r=fn(e,t))==null?void 0:r.worktree;return n?[n.path]:[]}function av(e,t){if(!e)return e;const n=t.find(r=>e.startsWith(`${r}/`));return n?e.slice(n.length+1):e}function sM(e,t,n){var k;e.dispatch({a:"set-picking",v:!1});const r=e.getState(),s=rM(r,t);if(!s)return;const{classes:a,route:l,element:c,...u}=n,h=oM(r,t),p={...u,file:av(u.file,h),callFile:av(u.callFile,h)};!(((k=r.local[s])==null?void 0:k.attachments)??[]).some(y=>y.kind==="pick"&&y.selector===p.selector)&&Ld(e,s,"pick")>0&&e.dispatch({a:"attach",id:s,items:[{kind:"pick",key:crypto.randomUUID(),...p}]}),e.dispatch({a:"focus-chat"})}function iM(e,t=[],n=[]){const r={path:"",name:"",kind:"folder",children:[],ignored:!1},s=new Map([["",r]]),a=u=>{const h=s.get(u);if(h)return h;const p=u.lastIndexOf("/"),g={path:u,name:u.slice(p+1),kind:"folder",children:[],ignored:!1};return a(p===-1?"":u.slice(0,p)).children.push(g),s.set(u,g),g},l=(u,h,p=!1)=>{const g=u.lastIndexOf("/");a(g===-1?"":u.slice(0,g)).children.push({path:u,name:u.slice(g+1),kind:h,children:[],ignored:p})};for(const u of e)l(u,"file");for(const u of t)l(u,"submodule");for(const u of n)u.endsWith("/")?l(u.slice(0,-1),"ignored",!0):l(u,"file",!0);const c=u=>{const h=p=>p.kind==="file"?1:0;u.children.sort((p,g)=>h(p)-h(g)||dx(p.name,g.name));for(const p of u.children)p.kind==="folder"&&c(p)};return c(r),r.children}function aM(e,t){const n=[],r=(s,a)=>{for(const l of s){const c=l.kind==="folder"&&t(l.path);n.push({path:l.path,name:l.name,depth:a,kind:l.kind,open:c,ignored:l.ignored}),c&&r(l.children,a+1)}};return r(e,0),n}const t1=e=>{const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)};function lM(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(s=>s===""||s==="."||s==="..")?{error:"a plain path, inside the worktree"}:{path:e?`${e}/${n}`:n}}function cM(e){const t=new Map,n=new Set;for(const r of e){const s=r.path.endsWith("/")?r.path.slice(0,-1):r.path;s===r.path?t.set(s,r):n.add(s);for(const a of Qu(s))n.add(a)}return{files:t,folders:n}}const n1=new Set(FR),uM=/^image\.[a-z0-9]+$/i,dM=e=>uM.test(e.name),fM=(e,t)=>e===t||e.name===t.name&&e.size===t.size&&e.type===t.type&&e.lastModified===t.lastModified;function pM(e){if(!e)return[];const t=[];for(const a of Array.from(e.items??[])){if(a.kind!=="file"||!a.type.startsWith("image/"))continue;const l=a.getAsFile();l&&t.push(l)}if(t.length===0)for(const a of Array.from(e.files??[]))a.type.startsWith("image/")&&t.push(a);const n=[];for(const a of t)n.some(l=>fM(l,a))||n.push(a);const r=n.filter(a=>!dM(a));if(r.length>0)return r;const s=n.find(a=>n1.has(a.type))??n[0];return s?[s]:[]}function hM(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 mM(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 gM(e){try{return await createImageBitmap(e)}catch{throw new Error(`${e.name||"image"}: not a readable image`)}}function lv(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((s,a)=>r.toBlob(l=>l?s(l):a(new Error("could not encode image")),n,.9))}async function kM(e){const t=await gM(e);try{const n=Math.max(t.width,t.height);let r=e,s=e.type,a=t.width,l=t.height;if(!n1.has(s)||n>yw||e.size>Np){const c=s==="image/jpeg"?"image/jpeg":"image/png";let u=Math.min(1,yw/n);for(r=await lv(t,u,c);r.size>Np&&u>.1;)u*=.7,r=await lv(t,u,c);if(r.size>Np)throw new Error(`${e.name||"image"}: too large even after downscaling`);s=c,a=Math.max(1,Math.round(t.width*u)),l=Math.max(1,Math.round(t.height*u))}return{blob:r,name:e.name||`pasted.${s==="image/jpeg"?"jpg":"png"}`,mimeType:s,width:a,height:l}}finally{t.close()}}const Ol={el:null},yM=80,wM=2e3;let Ko=null,vh;const r1=(e,t)=>{clearTimeout(vh),vh=setTimeout(()=>$m(e),t)};function Om(e,t){Ko??(Ko={refused:!1}),e.dispatch({a:"drag-files",v:Ko.refused?null:t}),r1(e,wM)}function vM(e){Ko&&r1(e,yM)}function $m(e){clearTimeout(vh),Ko=null,e.dispatch({a:"drag-files",v:null})}function bM(e){Ko&&(Ko.refused=!0,e.dispatch({a:"drag-files",v:null}))}const o1="application/x-toyon-path";let yi=null;function xM(e){yi=e}function s1(e){yi=null,Ko&&$m(e)}const cv=e=>yi!==null&&Array.from(e.dataTransfer.types).includes(o1);function _M(e){return{onDragOver:t=>{if(!cv(t)||!yi)return;t.preventDefault();const n=Pd(e.getState(),yi.worktreeId)!==null;t.dataTransfer.dropEffect=n?"copy":"none",n&&Om(e,{at:"chat"})},onDrop:t=>{if(!cv(t)||!yi)return;t.preventDefault();const{worktreeId:n,path:r,folder:s}=yi;s1(e),e1(e,n,r,s)}}}let EM=0;function SM(e){const{blob:t,...n}=e;return{kind:"image",key:`img${++EM}`,...n,upload:"",bytes:t.size,local:URL.createObjectURL(t)}}async function Mm(e,t,n){var l;if(!t||n.length===0)return;const r=Ld(e,t,"image");if(r===0)return;const s=await Promise.allSettled(n.slice(0,r).map(kM));for(const c of s)c.status==="fulfilled"&&Qx(e,t,SM(c.value),c.value.blob);const a=s.find(c=>c.status==="rejected");a?ro(e,t,String(((l=a.reason)==null?void 0:l.message)??a.reason)):n.length>r&&ro(e,t,`kept ${r} of ${n.length}: ${tm("image")}`)}function oc(e){const t=e.getState();return tc(fn(t,t.activeId))}function NM(e,t){const n=oc(e),r=t.filter(l=>!l.folder).map(l=>l.file),s=l=>l.type.startsWith("image/");Mm(e,n,r.filter(s)),Am(e,n,r.filter(l=>!s(l)));const a=t.find(l=>l.folder);n&&a&&ro(e,n,`${a.file.name}: a folder cannot be attached; drop its files`)}const bh=Promise.resolve(null);function TM(e){var n,r,s;if(!e)return[];const t=[];for(const a of Array.from(e.items)){if(a.kind!=="file")continue;const l=a.getAsFile();if(!l)continue;const c=((n=a.getAsFileSystemHandle)==null?void 0:n.call(a).then(u=>(u==null?void 0:u.kind)==="file"?u:null,()=>null))??bh;t.push({file:l,handle:c,folder:((s=(r=a.webkitGetAsEntry)==null?void 0:r.call(a))==null?void 0:s.isDirectory)===!0})}if(t.length===0)for(const a of Array.from(e.files))t.push({file:a,handle:bh});return t}const jM=e=>e.map(t=>({file:t,handle:bh}));async function i1(e){const t=Gu*4;if(e.size>t)return{text:"",tooLarge:!0};const n=await mM(e,t);return n===null?null:n.length>Gu?{text:"",tooLarge:!0}:{text:n,tooLarge:!1}}async function CM(e,t){const n=oc(e),r=e.getState().activeId,s=p=>n&&ro(e,n,p),a=t.filter(p=>p.file.type.startsWith("image/")).map(p=>p.file);a.length&&Mm(e,n,a);const l=t.filter(p=>!p.file.type.startsWith("image/")),c=l[0];if(!c||!r)return;const u=await i1(c.file);if(!u)return void s(`${c.file.name}: not a text file`);const h=await c.handle;e.dispatch({a:"open-loose",v:{worktreeId:r,name:c.file.name,...u,binary:!1,source:h?{kind:"handle",handle:h}:{kind:"bytes"},seq:Io()}}),l.length>1&&s(`opened ${c.file.name}; one file opens at a time`)}async function AM(e,t,n,r){const s=Pd(e.getState(),n.worktreeId)??oc(e),a=c=>s&&ro(e,s,c),l={sock:t,dispatch:c=>e.dispatch(c)};for(const{file:c}of r){const u=await i1(c);if(!u){a(`${c.name}: not a text file`);continue}if(u.tooLarge){a(`${c.name}: too large to add here`);continue}const h=n.dir?`${n.dir}/${c.name}`:c.name,p=await qx(l,{worktreeId:n.worktreeId,path:h},u.text);p&&a(`${c.name}: ${p}`)}}function IM(e){const t=oc(e);t&&ro(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 a1(e,t,n,r){const s=(Ko==null?void 0:Ko.refused)??!1;$m(e),!(s||r.length===0)&&(n?n.at==="chat"?NM(e,r):n.at==="centre"?CM(e,r):AM(e,t,n,r):IM(e))}const uv=e=>!!e&&Array.from(e.types).includes("Files");function dv(e,t){var a;const n=t instanceof Element?t:t instanceof Node?t.parentElement:null;if(!n)return null;if((a=Ol.el)!=null&&a.contains(n))return oc(e)?{at:"chat"}:null;const r=n.closest(".tree"),s=r==null?void 0:r.dataset.worktree;if(r&&s){const l=n.closest("[data-path]"),c=l==null?void 0:l.dataset.kind;if(c==="submodule")return null;const u=(l==null?void 0:l.dataset.path)??"";return{at:"tree",worktreeId:s,dir:c==="file"?t1(u):u}}return!n.closest(".center-root")||n.closest('[data-pane="terminal"], [data-pane="design"]')?null:e.getState().activeId?{at:"centre"}:null}function RM(){const e=Un(),t=ot();S.useEffect(()=>{const n=l=>{l.defaultPrevented||!uv(l.dataTransfer)||(l.preventDefault(),Om(e,dv(e,l.target)),l.dataTransfer&&(l.dataTransfer.dropEffect=e.getState().dragFiles?"copy":"none"))},r=l=>{l.defaultPrevented||!uv(l.dataTransfer)||(l.preventDefault(),a1(e,t,dv(e,l.target),TM(l.dataTransfer)))},s=()=>vM(e),a=l=>{l.key==="Escape"&&bM(e)};return window.addEventListener("dragover",n),window.addEventListener("drop",r),window.addEventListener("dragleave",s),window.addEventListener("keydown",a,!0),()=>{window.removeEventListener("dragover",n),window.removeEventListener("drop",r),window.removeEventListener("dragleave",s),window.removeEventListener("keydown",a,!0)}},[e,t])}function OM(e,t){const n=Un(),r=S.useRef(!1);return{onPaste:c=>{const u=pM(c.clipboardData);if(u.length>0)return c.preventDefault(),void Mm(n,e,u);const h=hM(c.clipboardData);if(h.length>0)return c.preventDefault(),Am(n,e,h);if(r.current)return;const p=c.clipboardData.getData("text/plain"),g=p.trim()?C2(c.clipboardData,t):null;!(g&&p.includes(`
|
|
101
|
+
`))&&!GR(p)||(c.preventDefault(),Xx(n,e,p,g?{source:g}:{}))},onPasteKey:c=>{r.current=(c.metaKey||c.ctrlKey)&&c.shiftKey&&c.key.toLowerCase()==="v"},onPasteKeyUp:()=>{r.current=!1}}}function Ke(...e){return e.filter(Boolean).join(" ")}const $M={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",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",dot:"M8 4.6a3.4 3.4 0 1 0 0 6.8 3.4 3.4 0 1 0 0-6.8z"};function Et({name:e,className:t}){return f.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round",children:f.jsx("path",{d:$M[e]})})}function sc({size:e="inline",variant:t="ring",className:n}){return f.jsx("span",{className:Ke("spinner",e==="dot"&&"spinner-dot",t==="squares"&&"spinner-squares",n),"aria-hidden":"true"})}const MM='button, a[href], input, textarea, select, summary, label, [role="button"], [role="menuitem"]';function fv(e){var n;const t=e;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,MM))??t??null}function LM(e,t){var r,s,a;if(e.box.contains(t)||(r=e.trigger)!=null&&r.contains(t))return!0;const n=(a=(s=t.closest)==null?void 0:s.call(t,"[aria-controls]"))==null?void 0:a.getAttribute("aria-controls");return!!n&&n===e.box.id}function PM(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 DM(e,t){const n=new Set;for(const r of e)if(LM(r,t))for(let s=r;s;s=s.parent)n.add(s);return e.filter(r=>!n.has(r)&&r.dismiss).reverse()}const zM=e=>{setTimeout(e,0)};function FM({schedule:e=zM}={}){let t=[],n=null;const r=s=>{var a;for(const l of[...t].reverse())(a=l.dismiss)==null||a.call(l,s)};return{register(s){const a=s.trigger??(s.from===void 0?n:null),l={box:s.box,trigger:a,parent:PM(t,s.from??a),dismiss:s.dismiss,onKey:s.onKey};return t=[...t,l],l},unregister(s){t=t.filter(a=>a!==s)},top:()=>t[t.length-1]??null,open:()=>t,install(s){const a=s.document,l=g=>{var y;const k=g.target;if(k)for(const v of DM(t,k))(y=v.dismiss)==null||y.call(v,"outside");n=fv(g.target)},c=()=>e(()=>n=null),u=g=>{n||(n=fv(g.target),c())},h=g=>{var y;const k=t[t.length-1];(y=k==null?void 0:k.onKey)==null||y.call(k,g)},p=()=>e(()=>{var g;((g=a.activeElement)==null?void 0:g.tagName)==="IFRAME"&&r("frame")});return a.addEventListener("pointerdown",l,!0),a.addEventListener("pointerup",c,!0),a.addEventListener("pointercancel",c,!0),a.addEventListener("click",u,!0),s.addEventListener("keydown",h,!0),s.addEventListener("blur",p),()=>{a.removeEventListener("pointerdown",l,!0),a.removeEventListener("pointerup",c,!0),a.removeEventListener("pointercancel",c,!0),a.removeEventListener("click",u,!0),s.removeEventListener("keydown",h,!0),s.removeEventListener("blur",p)}}}}const xh=FM(),Op=typeof HTMLElement<"u"&&"showPopover"in HTMLElement.prototype,pv=e=>(e==null?void 0:e.getBoundingClientRect())??null;function BM(e,t,n,r){const s=e.querySelector(t);if(!s)return null;const a=e.getBoundingClientRect(),l=s.getBoundingClientRect();return{offset:n==="top"?a.bottom-l.bottom:l.top-a.top,alignOffset:r==="end"?a.right-l.right:l.left-a.left}}function Vs({className:e,anchor:t,placement:n,coverBy:r,track:s=t==="parent",raiseKey:a,onDismiss:l,onKey:c,trigger:u,from:h,boxRef:p,handle:g,children:k,...y}){const v=S.useRef(null),_=S.useRef({anchor:t,placement:n,coverBy:r,onDismiss:l,onKey:c,trigger:u,from:h});_.current={anchor:t,placement:n,coverBy:r,onDismiss:l,onKey:c,trigger:u,from:h};const E=S.useCallback(()=>{const x=v.current,{anchor:N,placement:M,coverBy:J}=_.current;if(!x||!N||!M)return;const W=N==="parent"?pv(x.parentElement):N();if(!W)return;const R=A2(W,M);R!==void 0&&(x.style.width=`${R}px`);for(let j=0;j<2;j++){const A=J?BM(x,J,x.dataset.side??"",x.dataset.align??""):null,D=R2(W,{w:x.offsetWidth,h:x.offsetHeight},{w:window.innerWidth,h:window.innerHeight},A?{...M,...A}:M);x.style.left=`${D.x}px`,x.style.top=`${D.y}px`;const H=x.dataset.side!==D.side||x.dataset.align!==D.align;if(x.dataset.side=D.side,x.dataset.align=D.align,!H)break}},[]);S.useImperativeHandle(g,()=>({update:E}),[E]),S.useLayoutEffect(()=>{const x=v.current;if(!x)return;p&&(p.current=x),Op&&(x.popover="manual",x.matches(":popover-open")||x.showPopover());const{onDismiss:N,onKey:M,trigger:J,from:W}=_.current,R=N||M?xh.register({box:x,trigger:J,from:W,dismiss:N?j=>{var A,D;return(D=(A=_.current).onDismiss)==null?void 0:D.call(A,j)}:void 0,onKey:M?j=>{var A,D;return(D=(A=_.current).onKey)==null?void 0:D.call(A,j)}:void 0}):null;return()=>{R&&xh.unregister(R),p&&(p.current=null),Op&&x.isConnected&&x.matches(":popover-open")&&x.hidePopover()}},[p]),S.useLayoutEffect(E),S.useLayoutEffect(()=>{if(!s)return;let x=0,N="";const M=()=>{const J=v.current,{anchor:W}=_.current,R=J&&W?W==="parent"?pv(J.parentElement):W():null;if(J&&R){const j=`${R.left},${R.top},${R.right},${R.bottom},${J.offsetWidth},${J.offsetHeight},${window.innerWidth},${window.innerHeight}`;j!==N&&(N=j,E())}x=requestAnimationFrame(M)};return x=requestAnimationFrame(M),()=>cancelAnimationFrame(x)},[s,E]);const C=S.useRef(!0);return gt([a],()=>{if(C.current){C.current=!1;return}const x=v.current;!Op||!(x!=null&&x.matches(":popover-open"))||(x.hidePopover(),x.showPopover(),E())}),f.jsx("div",{ref:v,className:Ke("float",e),...y,children:k})}const UM=/^[⌘⇧⌥⌃]+/;function Or({k:e,chip:t=!1,className:n}){var l;const r=(l=e.match(UM))==null?void 0:l[0],s=r?e.slice(r.length):e,a=["kbd",t?"kbd-chip":"",n??""].filter(Boolean).join(" ");return f.jsxs("kbd",{className:a,children:[r&&f.jsx("span",{className:"kbd-mod",children:r}),s]})}function It(e,t,{placement:n,detail:r,card:s,dot:a,name:l,aside:c,also:u}={}){const h=l?`${e}: ${l}`:e,p=(Array.isArray(r)?r:[r]).filter(k=>!!k),g=[h,...p,...c??[]].join(", ");return{"data-tip":e,"data-tip-key":t,"data-tip-placement":n,"data-tip-detail":p.length?p.join(`
|
|
102
|
+
`):void 0,"data-tip-card":s||l||c!=null&&c.length?"":void 0,"data-tip-dot":a,"data-tip-name":l,"data-tip-aside":c!=null&&c.length?c.join(`
|
|
103
|
+
`):void 0,"data-tip-also":u==null?void 0:u.text,"data-tip-also-key":u==null?void 0:u.key,"aria-label":t?`${g} (${t})`:g}}const HM=120,WM=600,KM=150,hv=6,ZM=18,$p=8;function mv(e){const t=e.dataset.tipPlacement;return t==="follow"||t==="top"||t==="bottom"||t==="left"||t==="right"?t:"bottom"}function qM(e){return e==="follow"?{side:"bottom",align:"start",offset:ZM,alignOffset:-12,flip:"both",margin:$p}:e==="left"||e==="right"?{side:e,align:"start",offset:hv,flip:"both",margin:$p}:{side:e,align:"center",offset:hv,flip:"side",margin:$p}}function GM(e,t){return e.placement==="follow"?Fx(t):e.el.getBoundingClientRect()}function l1(){var u;const[e,t]=S.useState(null),n=S.useRef(null),r=S.useRef(null),s=S.useRef({x:0,y:0}),a=Gs();if(S.useEffect(()=>{if(a)return;let h=0,p=0,g=null,k=!1,y=0;const v=()=>{window.clearTimeout(h),window.clearTimeout(p)},_=()=>{v(),k&&(y=Date.now()),k=!1,g=null,t(null)},E=(j,A)=>{var H,Y;const D=j.dataset.tip;if(!D)return _();v(),k=!0,t({el:j,text:D,key:j.dataset.tipKey,detail:(H=j.dataset.tipDetail)==null?void 0:H.split(`
|
|
104
|
+
`),card:j.dataset.tipCard!==void 0,dot:j.dataset.tipDot,name:j.dataset.tipName,aside:(Y=j.dataset.tipAside)==null?void 0:Y.split(`
|
|
105
|
+
`),also:j.dataset.tipAlso&&j.dataset.tipAlsoKey?{text:j.dataset.tipAlso,key:j.dataset.tipAlsoKey}:void 0,placement:A})},C=j=>{const A=j.target;return A instanceof Element?A.closest("[data-tip]"):null},x=j=>{s.current={x:j.clientX,y:j.clientY};const A=C(j);if(A===g)return;if(v(),g=A,!A){k&&(p=window.setTimeout(_,KM));return}const D=mv(A);if(k||Date.now()-y<WM)return E(A,D);h=window.setTimeout(()=>E(A,D),HM)},N=j=>{j.relatedTarget||_()},M=j=>{const A=C(j);if(A!=null&&A.matches(":focus-visible")){v(),g=A;const D=mv(A);E(A,D==="follow"?"bottom":D)}},J=()=>_(),W=j=>{j.key!=="Shift"&&j.key!=="Control"&&j.key!=="Alt"&&j.key!=="Meta"&&_()},R=j=>{g&&j.target instanceof Node&&j.target.contains(g)&&_()};return document.addEventListener("mouseover",x),document.addEventListener("mouseout",N),document.addEventListener("mousedown",_),document.addEventListener("keydown",W),document.addEventListener("scroll",R,!0),document.addEventListener("focusin",M),document.addEventListener("focusout",J),window.addEventListener("blur",_),()=>{v(),document.removeEventListener("mouseover",x),document.removeEventListener("mouseout",N),document.removeEventListener("mousedown",_),document.removeEventListener("keydown",W),document.removeEventListener("scroll",R,!0),document.removeEventListener("focusin",M),document.removeEventListener("focusout",J),window.removeEventListener("blur",_)}},[a]),S.useLayoutEffect(()=>{e&&!e.el.isConnected&&t(null)},[e]),S.useEffect(()=>{if((e==null?void 0:e.placement)!=="follow")return;const h=p=>{var g;s.current={x:p.clientX,y:p.clientY},(g=r.current)==null||g.update()};return document.addEventListener("mousemove",h),()=>document.removeEventListener("mousemove",h)},[e]),!e)return null;const l=f.jsxs(f.Fragment,{children:[e.dot==="spinner"?f.jsx(sc,{size:"dot",className:"tooltip-dot"}):e.dot&&f.jsx("span",{className:`dot ${e.dot} tooltip-dot`}),e.text]}),c=f.jsxs(f.Fragment,{children:[l,e.key&&f.jsx(Or,{k:e.key,className:"tooltip-key"})]});return f.jsxs(Vs,{className:Ke("tooltip",e.card&&"tooltip-card"),role:"tooltip",boxRef:n,handle:r,anchor:()=>GM(e,s.current),placement:qM(e.placement),track:!1,raiseKey:e,children:[e.also?f.jsxs("div",{className:"tooltip-pair",children:[f.jsx("span",{children:l}),e.key?f.jsx(Or,{k:e.key,className:"tooltip-key"}):f.jsx("span",{}),f.jsx("span",{className:"tooltip-also",children:e.also.text}),f.jsx(Or,{k:e.also.key,className:"tooltip-key"})]}):e.name?f.jsxs("div",{className:"tooltip-head",children:[f.jsx("span",{children:c}),f.jsx("span",{className:"tooltip-name",children:e.name})]}):c,(u=e.detail)==null?void 0:u.map(h=>f.jsx("div",{className:"tooltip-detail",children:h},h)),e.aside&&f.jsx("div",{className:"tooltip-foot",children:e.aside.map(h=>f.jsx("span",{children:h},h))})]})}const VM={sm:"",md:"btn-md",lg:"btn-lg"},YM={ghost:"",outline:"btn-outline",field:"btn-outline btn-field",inline:"btn-inline"},c1={primary:"tone-primary",quiet:"tone-quiet",danger:"tone-danger",strong:"tone-strong",chrome:"tone-chrome"};function Be({variant:e="ghost",size:t="sm",tone:n,on:r,mono:s,busy:a,className:l,type:c="button",disabled:u,children:h,...p}){const g=Ke("btn",YM[e],VM[t],n&&c1[n],r&&"on",s&&"btn-mono",a&&"btn-busy",l);return f.jsxs("button",{className:g,type:c,disabled:a||u,"aria-busy":a||void 0,...p,children:[a&&f.jsx(sc,{}),h]})}function $t({icon:e,label:t,hint:n,detail:r,also:s,badge:a,tone:l,on:c,className:u,type:h="button",...p}){const g=Ke("btn-icon",l&&c1[l],c&&"on",u);return f.jsxs("button",{className:g,type:h,...It(t,n,{detail:r,also:s}),...p,children:[typeof e=="string"?f.jsx(Et,{name:e}):e,a]})}function Ma(e,t,n){return n===0?0:(e+t+n)%n}function gv(e,t,n){return e>=0?Ma(e,t,n):n===0?-1:t>0?0:n-1}function u1(e,t,n){var a;const r=e.length,s=n.toLowerCase();for(let l=1;l<=r;l++){const c=(Math.max(t,-1)+l)%r;if((a=e[c])!=null&&a.trim().toLowerCase().startsWith(s))return c}return-1}function Mp(e,t){return e&&e.length>t.length&&e.toLowerCase().startsWith(t.toLowerCase())?e.slice(t.length):null}function QM(e,t){if(e==null)return null;if(typeof e=="string"){const s=Mp(e,t);return s?{text:s,accept:s,params:[]}:null}const n=Mp(e.show,t);if(!n)return null;const r=(e.params??[]).map(([s,a])=>[Math.max(s,t.length)-t.length,a-t.length]).filter(([s,a])=>a>s);return{text:n,accept:Mp(e.accept,t),params:r}}function d1(e){const{results:t,keyOf:n,q:r,onPick:s,listRef:a,onActive:l,onSide:c,completionOf:u,narrowTo:h,setQ:p,tabPicks:g,onIdlePick:k}=e,[y,v]=S.useState(()=>{var W;return e.idle?-1:Math.max(0,((W=e.initialIndex)==null?void 0:W.call(e,t))??0)}),_=y>=0&&t[y]?n(t[y]):null,E=S.useRef(l);E.current=l,gt([_],()=>{var W,R,j;(R=(W=a.current)==null?void 0:W.querySelector('.picker-item[data-state~="cursor"]'))==null||R.scrollIntoView({block:"nearest"}),(j=E.current)==null||j.call(E,y>=0?t[y]??null:null)});const C=y<0?-1:Math.min(y,Math.max(0,t.length-1)),x=C>=0?t[C]??null:null,N=x?QM(u==null?void 0:u(x,r),r):null,M=W=>{const R=h==null?void 0:h(W,r);if(R==null)return s(W,r);p==null||p(R),v(0)};return{index:C,active:x,ghost:N,setIndex:v,pick:M,onKeyDown:W=>{if(W.key==="ArrowDown")W.preventDefault(),v(gv(C,1,t.length));else if(W.key==="ArrowUp")W.preventDefault(),v(gv(C,-1,t.length));else if((W.key==="ArrowLeft"||W.key==="ArrowRight")&&c&&x)W.preventDefault(),c(x,W.key==="ArrowLeft"?-1:1);else if(W.key==="Tab"&&(N!=null&&N.accept))W.preventDefault(),p==null||p(r+N.accept),v(0);else if(W.key==="Tab"&&g&&x)W.preventDefault(),M(x);else if(W.key==="Enter"&&x)W.preventDefault(),M(x);else if(W.key==="Enter"&&C<0&&k)W.preventDefault(),k(r);else return!1;return!0}}}function Yn(e){const t=Object.keys(e).filter(n=>e[n]);return t.length>0?t.join(" "):void 0}const XM=new Set(["Shift","Meta","Control","Alt","CapsLock","Fn"]);function f1(){const e=Ux(),t=Un();return S.useEffect(()=>{if(!e)return;const n=()=>{e.target.isConnected||Hr.close()},r=new MutationObserver(n);r.observe(document.body,{childList:!0,subtree:!0});const s=t.subscribe(n);return()=>{r.disconnect(),s()}},[e,t]),e?f.jsx(JM,{spec:e},e.id):null}function JM({spec:e}){const t=e.items,n=t.filter(xi),[r,s]=S.useState(-1),a=S.useRef({idx:r,items:n});a.current={idx:r,items:n};const l=S.useRef(null),c=g=>{var k,y;{const v=()=>Hr.close(),{idx:_,items:E}=a.current;if(XM.has(g.key))return;if(g.key==="ArrowDown"||g.key==="ArrowUp"){g.preventDefault(),g.stopPropagation();const C=g.key==="ArrowDown"?1:-1;s(O2(E,_,C));return}if((g.key==="Enter"||g.key===" ")&&_>=0&&E[_]&&!E[_].disabled){g.preventDefault(),g.stopPropagation(),E[_].onClick(),v();return}if(g.key==="Escape"){g.stopPropagation(),v();return}if(g.key.length===1&&!g.metaKey&&!g.ctrlKey&&!g.altKey){g.preventDefault(),g.stopPropagation();const C=Array.from(((k=l.current)==null?void 0:k.querySelectorAll(".menu-label"))??[],N=>N.textContent??""),x=u1(C,_,g.key);x>=0&&!((y=E[x])!=null&&y.disabled)&&s(x);return}v()}};S.useEffect(()=>{const g=()=>Hr.close();return window.addEventListener("blur",g),window.addEventListener("resize",g),document.addEventListener("scroll",g,!0),()=>{window.removeEventListener("blur",g),window.removeEventListener("resize",g),document.removeEventListener("scroll",g,!0)}},[]);const{rect:u,placement:h}=L2(e),p=n.some(g=>g.checked);return f.jsx(Vs,{className:"menu",role:"menu",boxRef:l,anchor:()=>u,placement:h,track:!1,from:e.target,trigger:e.toggles?e.target:null,onDismiss:()=>Hr.close(),onKey:c,onContextMenu:g=>g.preventDefault(),children:t.map((g,k)=>{if(!xi(g))return f.jsx("hr",{className:"menu-sep"},`sep-${k}`);const y=n.indexOf(g);return f.jsx(eL,{item:g,gutter:p,cursor:y===r,onEnter:()=>s(y)},g.id)})})}function eL({item:e,gutter:t,cursor:n,onEnter:r}){const s=e.disabled!==void 0,a=e.detail??e.disabled;return f.jsxs("button",{...e.checked===void 0?{role:"menuitem"}:{role:"menuitemcheckbox","aria-checked":e.checked},"aria-disabled":s||void 0,className:Ke("row",e.danger&&"danger",a!==void 0&&"row-tall",s&&"disabled"),"data-state":Yn({cursor:n,checked:e.checked}),onMouseEnter:s?void 0:r,onClick:()=>{s||(e.onClick(),Hr.close())},children:[t&&f.jsx("span",{className:"menu-check",children:e.checked&&f.jsx(Et,{name:"check",className:"icon-inline"})}),f.jsxs("span",{className:"menu-text",children:[f.jsx("span",{className:"menu-label",children:e.label}),a!==void 0&&f.jsx("span",{className:"menu-detail row-dim",children:a})]}),e.key&&f.jsx(Or,{k:e.key,className:"menu-key row-dim"})]})}function Dd({items:e,current:t,onPick:n,fill:r,font:s,segmented:a,end:l,label:c,owner:u}){const h=Jt(u),p=S.useRef(null),g=k=>{var _,E;if(k.key!=="ArrowLeft"&&k.key!=="ArrowRight")return;k.preventDefault();const y=e.findIndex(C=>C.id===t),v=e[Ma(y,k.key==="ArrowRight"?1:-1,e.length)];v&&(n(v.id),(E=(_=p.current)==null?void 0:_.querySelectorAll('[role="tab"]')[e.indexOf(v)])==null||E.focus())};return f.jsxs("div",{className:Ke("tabs",r&&"tabs-fill",s==="mono"&&"tabs-mono",a&&"tabs-segmented"),children:[f.jsx("div",{className:"tabs-list",role:"tablist","aria-label":c,ref:p,onKeyDown:g,children:e.map(k=>{const y=k.id===t;return f.jsxs("div",{className:Ke("tab",y&&!!k.trail&&"tab-trailed",k.fit&&"tab-fit",k.far&&"tab-far"),"data-state":Yn({current:y}),...k.menu?h.contextMenu(k.menu):{},children:[f.jsxs("button",{type:"button",className:"tab-btn",role:"tab","aria-selected":y,tabIndex:y?0:-1,onClick:()=>n(k.id),...k.tip,...k.ariaLabel?{"aria-label":k.ariaLabel}:{},children:[k.lead,k.label]}),y&&k.trail&&f.jsx("span",{className:"tab-trail",children:k.trail})]},k.id)})}),l&&f.jsx("span",{className:"tabs-end",children:l})]})}function ds({anchor:e="top",wide:t,children:n}){return f.jsx("div",{className:Ke("view",e==="line"&&"view-anchored",t&&"view-wide"),children:n})}const kv={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"},tL="no access token for this address.\non a phone, run `toyon pair` on the machine and scan the code: it works once and lasts 2 minutes.\notherwise run `toyon` in your repo, or open the full URL\n(with #token=…) printed in ~/.toyon/daemon.log";function p1(e){return!e.connected&&(!e.heard||e.connectFailure)?e.hasToken?kv[e.connectFailure??"probing"]??kv.probing:tL:e.title===null?e.heard?`nothing open yet.
|
|
106
|
+
press ${e.projectChord} to open a project, or type a name there to start a new one`:"":null}function nL(e){const t=p1(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 Wt={post:(e,t)=>{},broadcast:e=>{}};function Hl(e,t,n,r){const s=t===r;Wt.post(e,s?{type:"pick-cancel"}:{type:"pick-start",verb:r}),n({a:"set-picking",v:s?!1:r})}function h1(e){return[{id:"copy-sha",label:`copy ${e.short}`,onClick:()=>Bt(e.sha)},{id:"copy-subject",label:"copy subject",onClick:()=>Bt(e.subject)}]}function zd(e,t,n){var s,a;const r=e[t];if(!r)return null;if(n==="ArrowRight")return r.open===void 0?null:r.open?(((s=e[t+1])==null?void 0:s.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((((a=e[l])==null?void 0:a.depth)??0)<r.depth)return{do:"to",at:l};return null}function Fd(e){return e!=null&&e.config.profiles?Object.keys(e.config.profiles):[]}function m1(e,t){const n=Fd(t);if(n.length!==0)return e.profile&&n.includes(e.profile)?e.profile:t==null?void 0:t.config.defaultProfile}const rL=e=>Bu(wi((e==null?void 0:e.config)??{}),e==null?void 0:e.defaultBranch).toLowerCase();function Hs(e,t,n){t({a:"shipping",id:n.worktreeId,op:n.t}),e==null||e.send(n)}const g1=e=>e.dirty===void 0||e.ahead===void 0||e.dirty>0||e.ahead>0;function _i(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 k1(e,t,n){t({a:"hold-unread",id:n}),e==null||e.send({t:"mark-unread",worktreeId:n})}function Lm(e,t){return{rename(n){if(!q0(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 s=r.of-1;window.confirm(`Keep "${n.worktree.title}" and archive ${s} 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?
|
|
107
|
+
|
|
108
|
+
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(!em(n.worktree))return;if(!g1(n))return _i(e,t,[n.worktree.id]);window.confirm(`Archive worktree "${n.worktree.title}"?
|
|
109
|
+
|
|
110
|
+
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.`)&&_i(e,t,[n.worktree.id])}}}function y1(e,t,n,{sock:r,dispatch:s},a){var M,J;const l=e.worktree.id,c=Lm(r,s),u=[],h=[],p=[],g=[],k=[],y=[],v=[];ec(e)&&u.push({id:"stop",label:"stop agent",onClick:()=>r==null?void 0:r.send({t:"stop-agent",worktreeId:l})});const _=!n.shipping[l];((e.dirty??0)>0||(e.ahead??0)>0||!n.layout.changes)&&h.push({id:"changes",label:`view changes${(e.dirty??0)>0?` (${e.dirty})`:""}`,onClick:()=>{s({a:"activate",id:l}),n.layout.changes||s({a:"toggle-changes"})}}),h.push({id:"terminal",label:"open terminal",onClick:()=>{s({a:"activate",id:l}),s({a:"focus-terminal"})}}),h.push(...$d(()=>r==null?void 0:r.send({t:"reveal",worktreeId:l}),a.hostname)),p.push({id:"copy-path",label:"copy path",onClick:()=>Bt(e.path)}),p.push({id:"copy-branch",label:"copy branch name",onClick:()=>Bt(e.worktree.branch)});const{transcript:E,sessionId:C}=e;E&&!hr(e.worktree)&&p.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>Bt(E)}),C&&p.push({id:"copy-session",label:"copy session id",onClick:()=>Bt(C)});const x=m1(e.worktree,t);for(const W of Ta(e.worktree)?[]:Fd(t))g.push({id:`profile:${W}`,label:`run with ${W}`,checked:W===x,onClick:()=>c.setProfile(e,W)});if(!Ei(e.worktree)&&((M=e.borrowed)!=null&&M.length)&&g.push({id:"own-procs",label:`run ${e.borrowed.join(", ")} here`,detail:"on main now",onClick:()=>c.ownProcs(e)}),!Ei(e.worktree)&&((J=e.worktree.owns)!=null&&J.length)&&g.push({id:"share-procs",label:`use main's ${e.worktree.owns.join(", ")}…`,detail:"runs here now",danger:!0,onClick:()=>c.shareProcs(e)}),q0(e.worktree)&&k.push({id:"rename",label:"rename…",onClick:()=>c.rename(e)}),e.worktree.variant&&k.push({id:"keep",label:"keep this variant…",onClick:()=>c.pickVariant(e)}),a.graft&&Ru(e.worktree)){const W=a.graft;k.push({id:"graft",label:"graft with…",onClick:()=>W(l)})}k.push({id:"unread",label:"mark as unread",key:xt("mark-unread"),disabled:e.unseen?"already unread":void 0,onClick:()=>k1(r,s,l)});const N=_?void 0:"waiting on the one in progress";return kd(e)&&(e.behind??0)>0&&y.push({id:"sync",label:`sync from main (${e.behind} behind)`,disabled:N,onClick:()=>Hs(r,s,{t:"sync-main",worktreeId:l})}),ki(e.worktree)&&y.push({id:"land",label:"land",detail:rL(t),disabled:N,onClick:()=>Hs(r,s,{t:"land",worktreeId:l})}),em(e.worktree)&&v.push({id:"archive",label:g1(e)?"archive…":"archive",key:xt("wt-archive"),danger:!0,onClick:()=>c.archive(e)}),Mn([u,h,p,g,k,y,v])}function oL(e,t,{sock:n,dispatch:r},s){const a=[],l=[{id:"adopt",label:"take over",disabled:e.locked?`held by ${e.lockReason??"another tool"}`:void 0,onClick:()=>n==null?void 0:n.send({t:"adopt-worktree",worktreeId:e.id,clientId:t.clientId})}];return kd(e)&&(e.behind??0)>0&&a.push({id:"sync",label:`sync from main (${e.behind} behind)`,onClick:()=>n==null?void 0:n.send({t:"sync-main",worktreeId:e.id})}),a.push({id:"shell",label:"open a shell here",onClick:()=>{r({a:"activate",id:e.id}),r({a:"focus-terminal"})}}),a.push(...$d(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id}),s)),Mn([l,a,[{id:"copy-path",label:"copy path",onClick:()=>Bt(e.path)}]])}const sL={sm:"",md:"field-md",lg:"field-lg"};function w1({size:e="sm",font:t,bare:n,rule:r,className:s}){const a=t??(e==="lg"?"ui":"mono");return Ke("field",sL[e],a==="ui"&&"field-ui",a==="lead"&&"field-lead",n&&"field-bare",r&&"field-rule",s)}const Ro=S.forwardRef(function({size:t,font:n,bare:r,rule:s,className:a,...l},c){return f.jsx("input",{ref:c,className:w1({size:t,font:n,bare:r,rule:s,className:a}),...l})}),Ea=S.forwardRef(function({size:t,font:n,bare:r,rule:s,className:a,...l},c){return f.jsx("textarea",{ref:c,className:w1({size:t,font:n,bare:r,rule:s,className:a}),...l})});function iL(e,t){const n=t??0;return n===0?null:`${n} behind ${e}`}function v1(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function b1(e,t){if(t.fetchFailed)return`could not reach origin${t.fetchedAt?` since ${v1(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 aL(e){return e.stale!=="diverged"}const Zo=e=>/[.!?]$/.test(e)?e:`${e}.`;function os(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 x1(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 _1=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function Pm(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 E1(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 lL(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 wu(e,t=0,n=!0,r){var s,a;if(e.check==="pending")return"Checking the work…";if(e.check==="fail"){const l=(a=(s=e.checkTail)==null?void 0:s.split(`
|
|
111
|
+
`).find(c=>c.trim()))==null?void 0:a.trim();return`Check failed${l?`: ${Zo(l)}`:"."}`}return Pm(e,t,n)==="unasked"?lL(r):null}function yv(e,t){const n=cL(e,t);return n?Zo(_1(n)):""}function cL(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 S1=e=>/^[A-Z][a-z]+(\s|$)/.test(e)?`${e.charAt(0).toLowerCase()}${e.slice(1)}`:e;function uL(e,t){const n=t??0;return n>0?`${n} behind ${e}; land takes it in first.`:""}function dL(e){return e>0?Zo(_1(`${e} ${e===1?"file":"files"} changed`)):""}function fL(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: ${Zo(S1(e.why))}`:null}function vu(e){return Zo(e)}const Bo=e=>e==="now"?"just now":`${e} ago`;function pL(e,t,n){switch(e){case"asking":return`Waiting on you${n==="now"?"":` for ${n}`}${t.ask?`: ${Zo(t.ask)}`:"."}`;case"failed":return t.auth?`Stopped ${Bo(n)}: not logged in.`:t.error?`Failed ${Bo(n)}: ${Zo(t.error)}`:`Failed ${Bo(n)}.`;case"stopped":return t.planBack?`Sent the plan back ${Bo(n)}. Say what to change.`:`Stopped ${Bo(n)}.`;case"done":return t.cut?`Ended early ${Bo(n)} (${t.cut}).`:`Finished ${Bo(n)}.`}}function Dm(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?Zo(t):pL(e.end,e.facts,Ur(e.at))}function hL(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?`Last stop, ${Bo(Ur(e.at))}: ${Zo(S1(t))}`:void 0}function Wl(e,t){var n,r;return(r=(n=e==null?void 0:e.worktree)==null?void 0:n.runs)==null?void 0:r.find(s=>s.kind===t)}function zm(e){return(e==null?void 0:e.status)==="running"||(e==null?void 0:e.status)==="detached"}function N1(e,t){const n=e.stage?[e.stage]:[];switch(e.status){case"queued":return[...n,"queued"];case"running":return[...n,`${ha(t)} of ${XN(e.timeoutMs)}`];case"detached":return[...n,ha(t),"detached"];case"terminated":return[e.why??"stopped"]}}function _h(e,t,n){return[e,...N1(t,n)].join(" · ")}const T1={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 j1(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 mL({active:e,ahead:t,behind:n,unpushed:r,dirty:s}){var en,kt,tn;const a=ot(),l=ht(),c=Jt("changes"),u=ir(e)?e.worktree:null,h=e.id,p=P(st=>{var X;return(X=st.shipping[h])==null?void 0:X.op}),g=P(st=>{var X;return(X=st.shipping[h])==null?void 0:X.step}),k=Ax(g,Ix),y=Wl(e,"commit"),v=Wl(e,"check"),_=p?y:v,E=_a(zm(_)?_==null?void 0:_.since:void 0),[C,x]=S.useState("");gt([h],()=>x(""));const N=S.useRef(null),M=(en=u==null?void 0:u.landing)!=null&&en.subject?u.landing.body?`${u.landing.subject}
|
|
112
|
+
|
|
113
|
+
${u.landing.body}`:u.landing.subject:null,J=()=>{C===""&&M&&x(M);const st=N.current;st&&(st.focus(),requestAnimationFrame(()=>st.setSelectionRange(st.value.length,st.value.length)))},W=P(st=>st.editCommit);gt([W],()=>{W&&J()});const R=C.trim()||void 0,j=P(st=>{var X;return!!((X=st.agents.find(we=>we.id===((u==null?void 0:u.agent)??st.defaultAgent)))!=null&&X.quick)}),A=u==null?void 0:u.landing,D=R?null:Pm(A,s?1:0,j),H=(A==null?void 0:A.check)==="pending",Y=!!(A!=null&&A.stale),ae=()=>{p||a==null||a.send({t:"judge",worktreeId:h})},me=()=>{p||!R&&!M||(Hs(a,l,{t:"commit",worktreeId:h,message:R??M??""}),x(""))},ye=()=>{p||Hs(a,l,{t:"land",worktreeId:h,...R?{message:R}:{}})},_e=((kt=u==null?void 0:u.landing)==null?void 0:kt.check)==="fail",V=u==null?void 0:u.pr,O=(V==null?void 0:V.state)==="open",F=O&&(s||r>0),ne=H||Y||!!D,$=!!u&&ki(u)&&(s||t>0)&&!_e&&!O&&!ne,q=!!u&&F&&!_e&&!ne,ke=!!u&&ki(u)&&!H&&(Y||D==="unwritten"||D==="unanswered")&&e.agent!=="working"&&e.agent!=="waiting",se=P(st=>st.repos.find(X=>X.id===e.repoId)??null),ve=Bu(wi((se==null?void 0:se.config)??{}),se==null?void 0:se.defaultBranch),Re=se?yd(se):"main",le=kd(e)?iL(Re,n):null,xe=e.agent==="working"||e.agent==="waiting",Le=s?u?xe?"the agent is mid-turn: sync when it is done":void 0:"commit or discard the changes here first":void 0,oe=O&&!F&&x1(V),Z=$?"land":q?"update":oe?"merge":(V==null?void 0:V.state)==="merged"?"pull":"land",Ve=p==="commit"?k??"commit":p==="land"?k?`${Z}: ${k}`:Z:null,ze=_?_.status==="terminated"?null:N1(_,E).join(" · "):H&&!p?"writing the message":null,it=_&&(_.status==="running"||_.status==="detached")?_:null,Je=it&&f.jsx($t,{icon:"stop",tone:"danger",label:j1(it.kind),onClick:()=>a==null?void 0:a.send({t:"run-stop",worktreeId:h,kind:it.kind})});return f.jsxs("div",{className:"composer commit-box",children:[u&&s&&f.jsx("div",{className:"composer-field",children:f.jsx(Ea,{size:"lg",bare:!0,ref:N,value:C,onChange:st=>x(st.target.value),onKeyDown:st=>{st.key==="Enter"&&(st.metaKey||st.ctrlKey)?(st.preventDefault(),me()):st.key==="Tab"&&!st.shiftKey&&C===""&&M&&(st.preventDefault(),J())},placeholder:M??(D==="unanswered"?"no message yet: the model did not answer. Check again, or write one here":D==="unasked"?"no message yet: write one here to commit or land":"commit message…")})}),f.jsxs("div",{className:"hint composer-knobs",children:[f.jsxs("span",{className:"commit-where",children:[f.jsx(Et,{name:"branch",className:"icon-inline"}),f.jsx("span",{className:"branch-name",children:e.branch??"detached"}),t>0&&f.jsxs("span",{className:"badge-ahead","data-tip":`${t} commit(s) ahead of ${Re}`,children:[t," ahead"]}),(u==null?void 0:u.landed)&&f.jsxs("span",{className:"badge-landed","data-tip":`Merged into ${Re}`,children:[f.jsx(Et,{name:"check",className:"icon-inline"})," landed"]})]}),f.jsxs("span",{className:"commit-acts",children:[Ve?f.jsx("span",{className:"live-text",children:Ve}):f.jsxs(f.Fragment,{children:[u&&s&&f.jsx(Be,{disabled:!R&&!M||!!p,onClick:me,...It(M&&!R?"Commit with the suggested message":"git add -A && git commit","⌘⏎"),children:"commit"}),u&&$&&f.jsx(Be,{tone:"primary",disabled:!!p,"data-tip":ve,onClick:ye,children:"land"}),ke&&f.jsx(Be,{tone:"primary",disabled:!!p,"data-tip":E1(A,!!((tn=se==null?void 0:se.config.check)!=null&&tn.trim()),D),onClick:ae,children:"check"}),H&&f.jsx("span",{className:"live-text",children:"check"}),q&&V&&f.jsx(Be,{tone:"primary",disabled:!!p,"data-tip":`Commit, take ${Re} in and push the branch; PR #${V.number} takes the new commits`,onClick:ye,children:"update"}),oe&&f.jsx(Be,{tone:"primary",disabled:!!p,"data-tip":"Merge the PR now, by the method the repo allows",onClick:ye,children:"merge"})]}),V&&f.jsxs(Be,{"data-tip":`Open PR #${V.number} on GitHub`,onClick:()=>window.open(V.url,"_blank"),...c.contextMenu(()=>[{id:"open-pr",label:"open on GitHub",onClick:()=>window.open(V.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>Bt(V.url)}]),children:["view ",f.jsx(Et,{name:"external",className:"icon-inline"})]})]})]}),(le||ze)&&f.jsxs("div",{className:"composer-notes",children:[ze&&f.jsxs("div",{className:"hint composer-note","data-tip":_?T1[_.status]:void 0,children:[f.jsx("span",{children:ze}),Je]}),le&&f.jsxs("div",{className:"hint composer-note",children:[f.jsx("span",{children:le}),p==="sync-main"?f.jsx("span",{className:"live-text",children:k?`sync: ${k}`:"sync"}):f.jsx(Be,{variant:"outline",disabled:!!p||!!Le,"data-tip":Le??`Merge ${Re} into this worktree${s?", uncommitted changes kept":""}`,onClick:()=>Hs(a,l,{t:"sync-main",worktreeId:h}),children:"sync"})]})]})]})}const gL=S.memo(function({c:t,id:n,selected:r,onToggle:s}){const a=Jt("changes");return f.jsxs("button",{className:"row row-sm log-row row-edge",id:n,"data-state":Yn({current:r,cursor:r}),role:"option","aria-selected":r,tabIndex:-1,onClick:()=>s(t.sha),...a.contextMenu(()=>h1(t)),"data-tip":`${t.subject}
|
|
114
|
+
${t.short} · ${t.author}`,"data-tip-placement":"follow",children:[f.jsx("span",{className:"subject",children:t.subject}),f.jsx("span",{className:"at row-dim",children:Ur(t.at)})]})});function kL(e,t){const n=cs(e,t);if(!n||!ir(n))return"take this worktree over to change files here";if(Ei(n.worktree))return"start a worktree to change files"}function C1(e,t,n,r){return{id:"new-file",label:"new file…",disabled:kL(e.getState(),t),onClick:()=>r(n)}}function yL(e,t,n,r){const{worktreeId:s,dir:a,path:l,folder:c,newIn:u}=e,h=Pd(t.getState(),s)?void 0:"take this worktree over to talk to an agent here",p=Im(l,c),g=[...c?[]:[{id:"open",label:"open",onClick:()=>Vn(n,{worktreeId:s,path:l,view:Ti(l)})}],{id:"add-to-chat",label:"add to chat",disabled:h,onClick:()=>e1(t,s,l,c)}],k=[C1(t,s,u,r),{id:"ask-rename",label:"ask the agent to rename…",disabled:h,onClick:()=>iv(t,s,`Rename ${p} to `)},{id:"ask-delete",label:"ask the agent to delete…",disabled:h,onClick:()=>iv(t,s,`Delete ${p} and update whatever still uses it`)}],y=[...$d(()=>{var v;return(v=n.sock)==null?void 0:v.send({t:"reveal",worktreeId:s,path:l})}),{id:"copy-path",label:"copy path",onClick:()=>Bt(`${a}/${l}`)},{id:"copy-relative-path",label:"copy relative path",onClick:()=>Bt(l)}];return Mn([g,y,k])}function wL(e,t,n,r){return Mn([[C1(t,e.worktreeId,"",r)],ji(e.dir,()=>{var s;return(s=n.sock)==null?void 0:s.send({t:"reveal",worktreeId:e.worktreeId})})])}const bu=[],vL=[],wv=new Set,vv=e=>`tree-row-${e}`;function bL({worktreeId:e,dir:t,openPath:n,openRef:r,rootRef:s}){const a=Un(),l=ot(),c=ht(),u=At(e,"files"),h=At(e,"submodules"),p=At(e,"ignored"),g=At(e,"git"),k=(g==null?void 0:g.files)??vL;gt([e,g,l],()=>Md(e,a.getState(),{sock:l,dispatch:c}));const y=P(oe=>{var Z;return((Z=oe.dragFiles)==null?void 0:Z.at)==="tree"&&oe.dragFiles.worktreeId===e?oe.dragFiles.dir:null}),v=P(oe=>oe.treeOpen[e]??bu),_=S.useMemo(()=>new Set(v),[v]),[E,C]=S.useState(wv);gt([e,n,r],()=>C(n&&!r?new Set(Qu(n).filter(oe=>!_.has(oe))):wv));const x=S.useCallback(oe=>_.has(oe)||E.has(oe),[_,E]),N=S.useCallback(oe=>{const Z=_.has(oe)||E.has(oe);if(Z&&E.has(oe)){const De=new Set(E);De.delete(oe),C(De)}c({a:"tree-folder",worktreeId:e,path:oe,open:!Z})},[_,E,e,c]),M=S.useMemo(()=>iM(u??bu,h??bu,p??bu),[u,h,p]),J=S.useMemo(()=>aM(M,x),[M,x]),W=S.useMemo(()=>cM(k),[k]),R=P(oe=>oe.treeReveal),j=R&&R.worktreeId===e?R:null,[A,D]=S.useState(()=>(j==null?void 0:j.path)??null),[H,Y]=S.useState({worktreeId:e,linked:j});(H.worktreeId!==e||H.linked!==j)&&(Y({worktreeId:e,linked:j}),D((j==null?void 0:j.path)??null));const[ae,me]=S.useState(!1),ye=S.useMemo(()=>{if(A===null)return-1;const oe=J.findIndex(Z=>Z.path===A);if(oe>=0)return oe;for(const Z of Qu(A).reverse()){const De=J.findIndex(Ve=>Ve.path===Z);if(De>=0)return De}return-1},[J,A]);gt([ye,ae],()=>{var oe,Z;ae&&((Z=(oe=s.current)==null?void 0:oe.querySelector('[data-state~="cursor"]'))==null||Z.scrollIntoView({block:"nearest"}))});const _e=S.useCallback((oe,Z)=>Vn({dispatch:c},{worktreeId:e,path:oe,view:Ti(oe),focus:Z}),[e,l,c]),V=S.useCallback(oe=>{D(oe.path),oe.kind==="folder"?N(oe.path):oe.kind==="file"&&_e(oe.path,!1)},[N,_e]),O=oe=>{var Ve;if(oe.metaKey||oe.ctrlKey||oe.altKey)return;const Z=J[ye],De=ze=>{const it=J[ze];it&&(D(it.path),it.kind==="file"&&_e(it.path,!1))};switch(oe.key){case"ArrowDown":case"ArrowUp":oe.preventDefault(),De(ye<0?0:Ma(ye,oe.key==="ArrowDown"?1:-1,J.length));return;case" ":oe.preventDefault(),(Z==null?void 0:Z.kind)==="file"?_e(Z.path,!1):(Z==null?void 0:Z.kind)==="folder"&&N(Z.path);return;case"Enter":oe.preventDefault(),(Z==null?void 0:Z.kind)==="file"?_e(Z.path,!0):(Z==null?void 0:Z.kind)==="folder"&&N(Z.path);return;case"ArrowRight":case"ArrowLeft":{oe.preventDefault();const ze=J.map(Je=>Je.kind==="folder"?{depth:Je.depth,open:Je.open}:{depth:Je.depth}),it=zd(ze,ye,oe.key);(it==null?void 0:it.do)==="to"?De(it.at):it&&Z&&N(Z.path);return}case"Escape":oe.stopPropagation(),n!==null?c({a:"close-editor"}):(Ve=document.activeElement)==null||Ve.blur();return}if(oe.key.length===1){const ze=u1(J.map(it=>it.name),ye,oe.key);ze>=0&&(oe.preventDefault(),De(ze))}},[F,ne]=S.useState(null),$=S.useRef(0),q=S.useCallback(oe=>{oe&&!x(oe)&&N(oe),$.current++,ne({dir:oe,error:null,busy:!1})},[x,N]),ke=S.useCallback(()=>{$.current++,ne(null)},[]),se=S.useCallback(oe=>{if(!F||F.busy)return;const Z=lM(F.dir,oe);if("error"in Z){ne({...F,error:Z.error});return}const De=++$.current;ne({...F,error:null,busy:!0}),qx({sock:l,dispatch:c},{worktreeId:e,path:Z.path}).then(Ve=>{Ve===null&&D(Z.path),De===$.current&&ne(Ve===null?null:{...F,error:Ve,busy:!1})})},[F,e,l,c]),ve=Jt("tree"),Re=S.useCallback(oe=>yL({worktreeId:e,dir:t,path:oe.path,folder:oe.kind!=="file",newIn:oe.kind==="folder"||oe.kind==="ignored"?oe.path:t1(oe.path)},a,{sock:l,dispatch:c},q),[e,t,a,l,c,q]),le=S.useCallback((oe,Z)=>{oe.kind==="file"&&Wt.post(e,Z?{type:"highlight-file",path:oe.path,ranges:null}:{type:"highlight-clear"})},[e]),xe=S.useCallback((oe,Z)=>{Z.dataTransfer.setData(o1,oe.path),Z.dataTransfer.setData("text/plain",oe.path),Z.dataTransfer.effectAllowed="copy",xM({worktreeId:e,path:oe.path,folder:oe.kind!=="file"})},[e]),Le=S.useCallback(()=>s1(a),[a]);return f.jsx("div",{className:Ke("tree",y===""&&"drop-over"),role:"tree","aria-label":"files","data-worktree":e,"aria-activedescendant":ae&&ye>=0?vv(ye):void 0,tabIndex:0,ref:s,onKeyDown:O,onFocus:()=>{var oe;me(!0),A===null&&D(n&&J.some(Z=>Z.path===n)?n:((oe=J[0])==null?void 0:oe.path)??null)},onBlur:oe=>!oe.currentTarget.contains(oe.relatedTarget)&&me(!1),onMouseDown:oe=>{if(oe.button!==0)return;const Z=oe.target.closest("[data-path]");(Z==null?void 0:Z.dataset.path)!==void 0&&D(Z.dataset.path)},...ve.contextMenu(oe=>{const Z=J[ye];return oe==="keyboard"&&Z?Re(Z):wL({worktreeId:e,dir:t},a,{sock:l},q)}),children:u===void 0?f.jsx("div",{className:"empty",children:"listing files…"}):J.length===0&&!F?f.jsx("div",{className:"empty",children:"no files"}):xL(J.map((oe,Z)=>f.jsx(EL,{row:oe,id:vv(Z),status:W.files.get(oe.path),changedInside:oe.kind!=="file"&&W.folders.has(oe.path),current:ae?Z===ye:!r&&oe.path===n,cursor:ae&&Z===ye,dropOver:y===oe.path,onPress:V,menu:Re,onHover:le,onDragStart:xe,onDragEnd:Le},oe.path)),F&&(()=>{var Z;const oe=F.dir===""?-1:J.findIndex(De=>De.path===F.dir);return{at:oe,node:f.jsx(_L,{depth:oe>=0?(((Z=J[oe])==null?void 0:Z.depth)??0)+1:0,error:F.error,onSubmit:se,onCancel:ke},"new-file")}})())})}function xL(e,t){return t?[...e.slice(0,t.at+1),t.node,...e.slice(t.at+1)]:e}function _L({depth:e,error:t,onSubmit:n,onCancel:r}){const[s,a]=S.useState(""),l={"--tree-depth":e},c=e===0||void 0;return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"row row-sm tree-row row-rails","data-kind":"file","data-root":c,style:l,children:[f.jsx("span",{className:"tree-caret row-dim"}),f.jsx(Ro,{bare:!0,font:"mono",autoFocus:!0,className:"tree-new-name","aria-label":"new file name","aria-invalid":t!==null||void 0,placeholder:"name",value:s,onChange:u=>a(u.target.value),onKeyDown:u=>{u.stopPropagation(),u.key==="Enter"?(u.preventDefault(),n(s)):u.key==="Escape"&&(u.preventDefault(),r())},onBlur:r})]}),t&&f.jsxs("div",{className:"tree-row tree-new-error row-rails","data-root":c,style:l,children:[f.jsx("span",{className:"tree-caret"}),f.jsx("span",{className:"hint",children:t})]})]})}const EL=S.memo(function({row:t,id:n,status:r,changedInside:s,current:a,cursor:l,dropOver:c,onPress:u,menu:h,onHover:p,onDragStart:g,onDragEnd:k}){const y=Jt("tree"),v=t.kind==="submodule",_=v?"A submodule: its files belong to its own repository":t.kind==="ignored"?"Ignored by git, so what is inside is not listed":null;return f.jsxs("div",{role:"treeitem",id:n,"aria-level":t.depth+1,"aria-expanded":t.kind==="folder"?t.open:void 0,"aria-selected":l,className:Ke("row row-sm tree-row row-rails row-edge",c&&"drop-over"),"data-state":Yn({current:a,cursor:l}),"data-kind":t.kind,"data-path":t.path,style:{"--tree-depth":t.depth},draggable:!v,onDragStart:E=>g(t,E),onDragEnd:k,onClick:()=>u(t),onMouseEnter:()=>p(t,!0),onMouseLeave:()=>p(t,!1),...y.contextMenu(()=>h(t)),..._?It(_):{},children:[f.jsx("span",{className:"tree-caret row-dim",children:t.kind==="folder"&&f.jsx(Et,{name:"caret",className:Ke("icon-inline disc-caret",!t.open&&"shut")})}),f.jsx("span",{className:Ke("tree-name",(v||t.ignored)&&"row-dim"),children:t.name}),r?f.jsx("span",{className:`xy ${ym(r.xy)}`,children:wm(r.xy)}):s&&f.jsx("span",{className:"dot tree-changed"})]})});function A1({f:e}){return e.add===void 0&&e.del===void 0?null:f.jsxs("span",{className:"counts",children:[e.add?f.jsxs("span",{className:"add",children:["+",e.add]}):null,e.del?f.jsxs("span",{className:"del",children:["−",e.del]}):null]})}const xu=S.memo(function({f:t,id:n,active:r,selected:s,checking:a=!1,checked:l=!1,onOpen:c,onCheck:u,menu:h,onHover:p}){const g=Jt("changes"),{name:k,dir:y}=_$(t.path);return f.jsxs("button",{className:"row row-sm git-file row-edge",id:n,"data-state":Yn({current:r,cursor:s,checked:l}),role:"option","aria-selected":s,tabIndex:-1,onClick:v=>u&&(a||v.shiftKey)?u(t.path):c(t.path),...g.contextMenu(()=>h(t.path)),onMouseEnter:()=>p(t.path,!0),onMouseLeave:()=>p(t.path,!1),children:[a&&f.jsx("input",{type:"checkbox",className:"changes-check",checked:l,readOnly:!0,tabIndex:-1}),f.jsx("span",{className:`xy ${ym(t.xy)}`,children:wm(t.xy)}),f.jsxs("span",{className:"path","data-tip":y?t.path:void 0,children:[f.jsx("span",{className:"name",children:k}),y&&f.jsx("span",{className:"dir row-dim",children:y})]}),f.jsx(A1,{f:t})]})}),SL={added:"A",changed:"M",removed:"D"},NL={added:"added",changed:"",removed:"deleted"},TL=S.memo(function({tests:t,id:n,cursor:r,onPick:s}){return t.map((a,l)=>f.jsxs("button",{className:"row row-sm changes-test row-rails row-edge",id:`${n}-t${l}`,"data-state":Yn({current:r===l,cursor:r===l}),"data-sub":!0,role:"option","aria-selected":r===l,tabIndex:-1,onClick:()=>s(l),"data-tip":[...a.group,a.name].join(" · "),"data-tip-placement":"follow",children:[f.jsx("span",{className:`xy ${NL[a.change]}`,children:SL[a.change]}),f.jsx("span",{className:"name",children:a.name})]},l))}),bv=new Set(["test","tests","__tests__","spec","e2e","__snapshots__","__mocks__","fixtures","testdata"]),jL=/([._-]tests?\.[^.]+$)|([._]specs?\.[^.]+$)|(^tests?[._-])|(^conftest\.py$)|(\.snap$)|([a-z0-9](Tests?|Spec)\.[^.]+$)/;function rd(e){const t=(e.endsWith("/")?e.slice(0,-1):e).split("/"),n=t.pop()??"";return e.endsWith("/")&&bv.has(n.toLowerCase())?!0:t.some(r=>bv.has(r.toLowerCase()))||jL.test(n)}function _u(e){const t=e.filter(n=>!rd(n.path));return t.length===0||t.length===e.length?{files:e,source:t.length}:{files:[...t,...e.filter(n=>rd(n.path))],source:t.length}}const Eh="(?<q>[\"'`])(?<name>(?:\\\\.|(?!\\k<q>).)*)\\k<q>",xv={tests:[new RegExp(`^\\s*(?:test|it)(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Eh}`)],groups:[new RegExp(`^\\s*describe(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Eh}`)]},CL={js:xv,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*${Eh}`),/^\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*\(/,...xv.tests]}},AL={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"},IL=3,RL=/^\s*(?:[)}\]]|end\b)/,Lp=e=>e.length-e.trimStart().length;function _v(e,t){var n,r;for(const s of t??[]){const a=(r=(n=s.exec(e))==null?void 0:n.groups)==null?void 0:r.name;if(a!==void 0)return a.replace(/^(["'`])(.*)\1$/,"$2")}return null}function Ev(e,t){const n=t.split(`
|
|
115
|
+
`),r=[],s=[];let a=Number.NEGATIVE_INFINITY;return n.forEach((l,c)=>{var k,y,v;if(l.trim()==="")return;const u=Lp(l);for(;s.length>0&&(((k=s.at(-1))==null?void 0:k.indent)??0)>=u;)s.pop();(y=e.mark)!=null&&y.test(l)&&(a=c);const p=!e.mark||c-a<=IL?_v(l,e.tests):null,g=p??_v(l,e.groups);if(g!==null){if(p!==null){a=Number.NEGATIVE_INFINITY;let _=c+1;for(;_<n.length&&(((v=n[_])==null?void 0:v.trim())===""||Lp(n[_]??"")>u);)_++;_<n.length&&Lp(n[_]??"")===u&&RL.test(n[_]??"")&&_++;const E=n.slice(c,_).map(C=>C.trim()).join(`
|
|
116
|
+
`).trim();r.push({group:s.map(C=>C.name),name:g,line:c,end:_,body:E})}s.push({indent:u,name:g})}}),r}function Sv(e){const t=new Map;for(const n of e){const r=[...n.group,n.name].join(`
|
|
117
|
+
`);let s=0;for(;t.has(`${r}
|
|
118
|
+
${s}`);)s++;t.set(`${r}
|
|
119
|
+
${s}`,n)}return t}function OL(e,t,n){const r=CL[AL[e.slice(e.lastIndexOf(".")+1).toLowerCase()]??""];if(!r)return[];const s=Sv(Ev(r,t)),a=Sv(Ev(r,n)),l=[];for(const[p,g]of a){const k=s.get(p);(k==null?void 0:k.body)!==g.body&&l.push({name:g.name,group:g.group,change:k?"changed":"added",line:g.line+1})}const c=n.split(`
|
|
120
|
+
`).length;let u=1;for(const[p,g]of s){const k=a.get(p);k?u=Math.min(k.end+1,c):l.push({name:g.name,group:g.group,change:"removed",line:u})}const h=p=>p.change==="removed"?0:1;return l.sort((p,g)=>p.line-g.line||h(p)-h(g))}const Eu=[];function $L(e){const t=Ur(e);return t==="now"?"landed just now":`landed ${t} ago`}function ML(e,t,n,r){const s=t?n>0?"no changes of its own":`same as ${e}`:"no changes";if(!r)return s;const a=Ur(r.at);return`${s}, last commit ${a==="now"?"just now":`${a} ago`}`}const Nv='[role="option"]:not([data-sub])',Tv=[];function I1({width:e,placement:t="dock"}){const n=t==="screen",r=ot(),s=ht(),a=Un(),l=Oa(),c=Ai(),u=(c==null?void 0:c.id)??l,h=us(),p=P(B=>B.layout.changes),g=nc(),k=P(B=>B.focusChanges),y=At(u,"git"),v=P(B=>B.editor&&B.editor.worktreeId===u?B.editor.path:null),_=P(B=>B.editor&&B.editor.worktreeId===u?B.editor.ref??null:null),E=P(B=>B.editor&&B.editor.worktreeId===u?B.editor.since??null:null),C=(y==null?void 0:y.files)??Eu,x=(y==null?void 0:y.committed)??Eu,{files:N,source:M}=S.useMemo(()=>_u(C),[C]),J=x.length>0,W=x2(),{files:R,source:j}=S.useMemo(()=>_u(W?x:Eu),[x,W]),A=y==null?void 0:y.turn,D=A==null?void 0:A.base,H=_2(),{files:Y,source:ae}=S.useMemo(()=>_u(A&&H?A.files:Eu),[A,H]),me=N.length,ye=N.length+Y.length,_e=P(B=>B.editor&&B.editor.worktreeId===u?B.editor.disk:null),V=S.useMemo(()=>v!==null&&_e&&rd(v)?OL(v,_e.before,_e.after):Tv,[v,_e]),[O,F]=S.useState(!1);gt([v,_,E],()=>F(!1));const ne=M>0?N.length-M:0,$=j>0?R.length-j:0,q=ae>0?Y.length-ae:0,ke=N.length===0,se=S.useMemo(()=>{if(N.length===0)return;const B=N.reduce((pt,jt)=>pt+(jt.add??0),0),ue=N.reduce((pt,jt)=>pt+(jt.del??0),0),Fe=[B>0&&`+${B}`,ue>0&&`−${ue}`].filter(Boolean).join(" "),tt=`${N.length} uncommitted ${N.length===1?"file":"files"}`;return Fe?`${tt}, ${Fe}`:tt},[N]),ve=!!y&&ke&&!J,Re=P(xa),le=c!==null||Re==="changes",xe=c!==null||Re==="history",Le=S.useCallback(B=>s({a:"changes-tab",v:B}),[s]),oe=S.useRef(Re);oe.current=Re;const Z=S.useRef(null),De=Sm(),Ve=P(B=>{const ue=Ra(B,De==null?void 0:De.repoId);return ue?yd(ue):"main"}),ze=At(u,"commits"),it=At(u,"commitFiles"),[Je,en]=S.useState(null),kt=S.useRef(null);kt.current=Je;const tn=S.useRef(null),st=At(u,"changedRanges"),X=S.useCallback((B,ue)=>{if(!u||c)return;if(!ue){tn.current=null,Wt.post(u,{type:"highlight-clear"});return}tn.current=B;const Fe=st[B];Fe?Wt.post(u,{type:"highlight-file",path:B,ranges:$w(Fe)}):r==null||r.send({t:"changed-ranges",worktreeId:u,path:B})},[u,c,st,r]);S.useEffect(()=>{const B=tn.current;if(!B||!u)return;const ue=st[B];ue&&Wt.post(u,{type:"highlight-file",path:B,ranges:$w(ue)})},[st,u]);const we=c&&N.length>0?(y==null?void 0:y.head)??null:null,Qe=S.useCallback((B,ue=!1,Fe)=>u&&Vn({dispatch:s},{worktreeId:u,path:B,focus:ue,ref:we??void 0,since:Fe}),[u,we,r,s]),he=S.useMemo(()=>c?N:[...N,...Y,...R],[c,N,Y,R]),Oe=S.useMemo(()=>{const B=[];for(const ue of ze??[])if(B.push({commit:ue}),ue.sha===Je)for(const Fe of _u(it[ue.sha]??[]).files)B.push({commit:ue,file:Fe});return B},[ze,Je,it]),Mt=S.useMemo(()=>Oe.filter(B=>!B.file&&B.commit.ahead).length,[Oe]),an=S.useMemo(()=>Oe.findIndex(B=>!B.file&&!B.commit.ahead),[Oe]),vt=c?he.length:0,Dn=(le?he.length:0)+(xe?Oe.length:0),Lt=S.useMemo(()=>{const B=new Map;if(!c)return B;const ue=new Map;for(const tt of Oe){const pt=tt.commit.landedAt??0;tt.file||ue.set(pt,(ue.get(pt)??0)+1)}if(ue.size===1&&!ue.has(0))return B;let Fe;return Oe.forEach((tt,pt)=>{const jt=tt.commit.landedAt??0;jt!==Fe&&(Fe=jt,B.set(pt,`${jt?$L(jt):"not landed"} · ${ue.get(jt)??0}`))}),B},[c,Oe]),ln=S.useRef(null),[{row:Tt,at:nn},Ut]=S.useReducer((B,ue)=>typeof ue=="number"?{row:ue,at:-1}:ue,{row:0,at:-1}),[We,Gt]=S.useState(!1),pn=(B,ue)=>We?zn(B):ue,Kt=B=>`changes-row-${B}`,[xn,hn]=S.useState(!1),[mn,gn]=S.useState([]),kn=S.useCallback(()=>{hn(!1),gn([])},[]),U=S.useCallback(B=>{hn(!0),gn(ue=>ue.includes(B)?ue.filter(Fe=>Fe!==B):[...ue,B])},[]),de=S.useMemo(()=>N.filter(B=>mn.includes(B.path)).map(B=>B.path),[N,mn]);gt([N],()=>gn(B=>{const ue=B.filter(Fe=>N.some(tt=>tt.path===Fe));return ue.length===B.length?B:ue})),gt([xn],()=>{if(!xn)return;const B=ue=>ue.key==="Escape"&&kn();return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)}),gt([u,Re],()=>{Ut(0),kn()});const Ae=y==null?void 0:y.head,et=S.useRef("");S.useEffect(()=>{if(!(xe||ve)||!u)return;const B=`${u}:${Ae??""}`;et.current!==B&&(et.current=B,r==null||r.send({t:"git-log",worktreeId:u}))},[xe,ve,u,Ae,r]);const ee=S.useCallback(B=>{en(ue=>ue===B?null:B),u&&!it[B]&&(r==null||r.send({t:"git-commit",worktreeId:u,sha:B}))},[u,it,r]);gt([Tt,nn,We],()=>{var B,ue;We&&((ue=(B=ln.current)==null?void 0:B.querySelector('[data-state~="cursor"]'))==null||ue.scrollIntoView({block:"nearest"}))});const Se=S.useRef(-1),be=B=>B>=me&&B<ye?D:void 0,fe=B=>{var ue;return((ue=he[B])==null?void 0:ue.path)===v&&(E??void 0)===be(B)&&(B<me?_===we:!_)};Se.current=le?he.findIndex((B,ue)=>fe(ue)):-1,S.useEffect(()=>{if(!k)return;const B=oe.current==="files";Se.current>=0&&Ut(Se.current);const ue=requestAnimationFrame(()=>{var Fe;return(Fe=(B?Z:ln).current)==null?void 0:Fe.focus()});return()=>cancelAnimationFrame(ue)},[k]);const Pe=S.useCallback((B,ue=!1)=>{const Fe=he[B];Fe&&(Ut(B),Qe(Fe.path,ue,B>=me&&B<ye?D:void 0),X(Fe.path,!0))},[he,Qe,X,me,ye,D]),rt=S.useCallback((B,ue=!1)=>{const Fe=kt.current;u&&Fe&&Vn({dispatch:s},{worktreeId:u,path:B,ref:Fe,focus:ue})},[u,r,s]),St=S.useCallback(B=>{const ue=Oe[B-vt];ue&&(Ut(B),ue.file&&rt(ue.file.path))},[Oe,vt,rt]),bt=S.useCallback(B=>{const ue=Oe[B-vt];ue&&(Ut(B),ue.file?rt(ue.file.path,!0):ee(ue.commit.sha))},[Oe,vt,rt,ee]),cn=B=>xe&&B>=vt,at=B=>{if(v===null)return!1;if(le&&B<he.length)return fe(B);const ue=cn(B)?Oe[B-vt]:void 0;return!!(ue!=null&&ue.file)&&_===ue.commit.sha&&ue.file.path===v},Dt=B=>at(B)&&!O?V:Tv,un=nn<Dt(Tt).length?nn:-1,zn=B=>We&&Tt===B&&un<0,An=()=>{var ue,Fe;const B=[];for(let tt=0;tt<Dn;tt++){const pt=cn(tt)?Oe[tt-vt]:void 0,jt=pt?(ue=pt.file)==null?void 0:ue.path:(Fe=he[tt])==null?void 0:Fe.path,vn=pt!=null&&pt.file?1:0,qn=Dt(tt);pt&&!pt.file?B.push({row:tt,at:-1,depth:vn,open:pt.commit.sha===Je}):jt!==void 0&&rd(jt)?B.push({row:tt,at:-1,depth:vn,open:qn.length>0}):B.push({row:tt,at:-1,depth:vn});for(let Gr=0;Gr<qn.length;Gr++)B.push({row:tt,at:Gr,depth:vn+1})}return B},lr=(B,ue=!1)=>{const Fe=V[B];!Fe||!u||v===null||Vn({dispatch:s},{worktreeId:u,path:v,ref:_??void 0,since:E??void 0,line:{n:Fe.line},focus:ue})},Rt=B=>Dt(B).length>0&&f.jsx(TL,{tests:V,id:Kt(B),cursor:We&&Tt===B?un:-1,onPick:ue=>{Ut({row:B,at:ue}),lr(ue)}}),cr=B=>{var ue;if(xn&&B.key==="Escape")B.preventDefault(),B.stopPropagation(),kn();else if(xn&&B.key===" "){B.preventDefault();const Fe=le&&Tt<N.length?N[Tt]:void 0;Fe&&U(Fe.path)}else if(B.key==="ArrowDown"&&un+1<Dt(Tt).length)B.preventDefault(),Ut({row:Tt,at:un+1}),lr(un+1);else if(B.key==="ArrowUp"&&un>=0)B.preventDefault(),un===0?Ut(Tt):(Ut({row:Tt,at:un-1}),lr(un-1));else if(B.key==="Enter"&&un>=0)B.preventDefault(),lr(un,!0);else if(B.key==="ArrowDown"||B.key==="ArrowUp"){B.preventDefault();const Fe=Ma(Tt,B.key==="ArrowDown"?1:-1,Dn);cn(Fe)?St(Fe):Pe(Fe)}else if(B.key==="Enter")B.preventDefault(),cn(Tt)?bt(Tt):Pe(Tt,!0);else if(B.key==="ArrowRight"||B.key==="ArrowLeft"){B.preventDefault();const Fe=An(),tt=zd(Fe,Fe.findIndex(vn=>vn.row===Tt&&vn.at===un),B.key),pt=tt&&Fe[tt.at];if(!tt||!pt)return;const jt=cn(pt.row)?Oe[pt.row-vt]:void 0;tt.do==="to"?pt.at>=0?(Ut({row:pt.row,at:pt.at}),lr(pt.at)):jt!=null&&jt.file&&pt.row>Tt?St(pt.row):Ut(pt.row):jt&&!jt.file?ee(jt.commit.sha):tt.do==="close"?F(!0):at(pt.row)?F(!1):jt!=null&&jt.file?St(pt.row):Pe(pt.row)}else B.key==="Escape"&&(B.stopPropagation(),v!==null?s({a:"close-editor"}):(ue=document.activeElement)==null||ue.blur())},wn=c?c.id:h==null?void 0:h.worktree.id,Xn=c?c.path:h?h.worktree.path:"",Fn=c!==null,In=S.useCallback(B=>wn?is({id:wn,dir:Xn},B,{discard:!Fn,kept:Fn,ref:we??void 0,select:Fn?void 0:U},{sock:r,dispatch:s}):[],[wn,Xn,Fn,we,U,r,s]),oo=S.useCallback(B=>wn?is({id:wn,dir:Xn},B,{kept:Fn},{sock:r,dispatch:s}):[],[wn,Xn,Fn,r,s]),qr=S.useCallback(B=>wn?is({id:wn,dir:Xn},B,{kept:Fn,since:D},{sock:r,dispatch:s}):[],[wn,Xn,Fn,D,r,s]),Vt=S.useCallback(B=>wn?is({id:wn,dir:Xn},B,{ref:kt.current??void 0,kept:Fn},{sock:r,dispatch:s}):[],[wn,Xn,Fn,r,s]),Go=Jt("changes"),so=()=>{if(le&&Tt<he.length){const ue=he[Tt];return ue?(Tt<me?In:Tt<ye?qr:oo)(ue.path):[]}const B=cn(Tt)?Oe[Tt-vt]:void 0;return B?B.file?Vt(B.file.path):h1(B.commit):[]},dt=(B,ue)=>{const Fe=he.findIndex((tt,pt)=>pt>=B&&tt.path===ue);Ut(Fe),fe(Fe)&&V.length>0?F(tt=>!tt):Qe(ue,!1,be(Fe))},Zn=S.useRef(dt);Zn.current=dt;const je=S.useCallback(B=>Zn.current(0,B),[]),Ue=S.useCallback(B=>Zn.current(me,B),[me]),yt=S.useCallback(B=>Zn.current(ye,B),[ye]),ft=S.useCallback(B=>{Ut(vt+Oe.findIndex(ue=>!ue.file&&ue.commit.sha===B)),ee(B)},[Oe,vt,ee]),rn=S.useCallback(B=>{Ut(vt+Oe.findIndex(ue=>{var Fe;return((Fe=ue.file)==null?void 0:Fe.path)===B})),B===v&&_===kt.current&&V.length>0?F(ue=>!ue):rt(B)},[Oe,vt,rt,v,_,V]),Qt=S.useCallback(()=>{},[]);return f.jsxs("div",{className:Ke("changes-dock",n&&"changes-screen",!n&&(!p||g)&&"collapsed"),style:n?void 0:{width:e},children:[!c&&f.jsx(Dd,{fill:!0,owner:"changes-tabs",label:"changes panel",items:[{id:"files",label:f.jsx(Et,{name:"folder",className:"icon-inline"}),fit:!0,ariaLabel:"files",tip:It("files",xt("files"))},{id:"changes",label:"changes",tip:It("changes",xt("changes"),{detail:se})},{id:"history",label:"history"}],current:Re,onPick:Le}),Re==="files"&&u?f.jsx(bL,{worktreeId:u,dir:h?h.worktree.path:(De==null?void 0:De.path)??"",openPath:v,openRef:_,rootRef:Z}):f.jsxs("div",{className:Ke("changes-list",xe&&"history"),role:"listbox","aria-label":c?"kept work":xe?"commits":"changed files","aria-activedescendant":We&&Tt>=0&&Tt<Dn?un<0?Kt(Tt):`${Kt(Tt)}-t${un}`:void 0,tabIndex:0,ref:ln,onKeyDown:cr,onFocus:()=>Gt(!0),onMouseDown:B=>{var tt;if(B.button!==0)return;B.preventDefault();const ue=B.target.closest(Nv),Fe=ue?Array.from(B.currentTarget.querySelectorAll(Nv)).indexOf(ue):-1;Fe>=0&&Ut(Fe),(tt=ln.current)==null||tt.focus()},onBlur:B=>!B.currentTarget.contains(B.relatedTarget)&&Gt(!1),...Go.contextMenu(B=>B==="keyboard"?so():[]),children:[le&&N.length>0&&f.jsxs(f.Fragment,{children:[(J||c)&&f.jsx("div",{className:"section-title section-row",children:"uncommitted"}),N.map((B,ue)=>f.jsxs(S.Fragment,{children:[ne>0&&ue===M&&f.jsx("div",{className:"section-title changes-sub",children:"tests"}),f.jsx(xu,{f:B,id:Kt(ue),active:pn(ue,at(ue)),selected:zn(ue),checking:xn,checked:mn.includes(B.path),onOpen:je,onCheck:Fn?void 0:U,menu:In,onHover:X}),Rt(ue)]},B.path))]}),le&&!c&&A&&f.jsxs(f.Fragment,{children:[f.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":H,"data-tip":"What changed since your last message","data-tip-placement":"follow",onClick:()=>s({a:"toggle-turn"}),onKeyDown:B=>(B.key==="Enter"||B.key===" ")&&B.stopPropagation(),children:["last turn",f.jsx(Et,{name:"caret",className:Ke("icon-inline disc-caret",!H&&"shut")})]}),Y.map((B,ue)=>f.jsxs(S.Fragment,{children:[q>0&&ue===ae&&f.jsx("div",{className:"section-title changes-sub",children:"tests"}),f.jsx(xu,{f:B,id:Kt(me+ue),active:pn(me+ue,at(me+ue)),selected:zn(me+ue),onOpen:Ue,menu:qr,onHover:X}),Rt(me+ue)]},`t-${B.path}`))]}),le&&!c&&J&&f.jsxs(f.Fragment,{children:[f.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":W,"data-tip":`Committed on this branch, not yet on ${Ve}`,"data-tip-placement":"follow",onClick:()=>s({a:"toggle-committed"}),onKeyDown:B=>(B.key==="Enter"||B.key===" ")&&B.stopPropagation(),children:["committed",f.jsx(Et,{name:"caret",className:Ke("icon-inline disc-caret",!W&&"shut")})]}),R.map((B,ue)=>f.jsxs(S.Fragment,{children:[$>0&&ue===j&&f.jsx("div",{className:"section-title changes-sub",children:"tests"}),f.jsx(xu,{f:B,id:Kt(ye+ue),active:pn(ye+ue,at(ye+ue)),selected:zn(ye+ue),onOpen:yt,menu:oo,onHover:X}),Rt(ye+ue)]},`c-${B.path}`))]}),le&&!c&&ve&&f.jsx("div",{className:"empty",children:ML(Ve,!!De&&kd(De),(y==null?void 0:y.behind)??0,ze==null?void 0:ze[0])}),xe&&Oe.map((B,ue)=>f.jsxs(S.Fragment,{children:[c&&Lt.has(ue)&&f.jsx("div",{className:"section-title section-row",children:Lt.get(ue)}),!c&&Mt>0&&ue===0&&f.jsx("div",{className:"section-title section-row",children:"on this branch"}),!c&&Mt>0&&ue===an&&f.jsx("div",{className:"section-title section-row",children:Ve}),B.file?f.jsxs(f.Fragment,{children:[f.jsx(xu,{f:B.file,id:Kt(vt+ue),active:pn(vt+ue,at(vt+ue)),selected:zn(vt+ue),onOpen:rn,menu:Vt,onHover:Qt}),Rt(vt+ue)]}):f.jsx(gL,{c:B.commit,id:Kt(vt+ue),selected:zn(vt+ue),onToggle:ft})]},B.file?`${B.commit.sha}:${B.file.path}`:B.commit.sha)),xe&&ze===void 0&&f.jsx("div",{className:"empty",children:"reading history…"}),xe&&(ze==null?void 0:ze.length)===0&&N.length===0&&f.jsx("div",{className:"empty",children:"no commits yet"})]}),xn&&f.jsxs("div",{className:"changes-pick",children:[f.jsxs(Be,{size:"md",tone:"danger",disabled:de.length===0,"data-tip":"Throw away the uncommitted changes to every checked file",onClick:()=>{!wn||de.length===0||window.confirm(Gx(de))&&(r==null||r.send({t:"discard-files",worktreeId:wn,paths:de}),kn())},children:["discard ",de.length,"…"]}),f.jsx(Be,{size:"md",disabled:de.length===0,"data-tip":"Name every checked file in the chat",onClick:()=>{wn&&nM(a,wn,de),kn()},children:"add to chat"}),f.jsx($t,{icon:"close",label:"Cancel",hint:"esc",onClick:kn})]}),De&&!c&&f.jsx(mL,{active:De,ahead:(y==null?void 0:y.ahead)??0,behind:(y==null?void 0:y.behind)??0,unpushed:(y==null?void 0:y.unpushed)??De.unpushed??0,dirty:!ke})]})}function jv(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 ic(e){return e>0&&e<.005?"<$0.01":`$${e.toFixed(2)}`}function LL(e){const t=e.landed?"Merged":e.uncommitted?"Archived with uncommitted changes":"Archived";return e.restorable?t:`${t}, commits not kept`}function R1(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(ic(e.cost)),t.push(Ur(e.archivedAt)),t.filter(Boolean).join(" · ")}function O1(e,t,n){e==null||e.send({t:"restore-worktree",archiveId:t,clientId:n})}function Pu(e,t,{sock:n,dispatch:r}){const s=[{id:"restore",label:"restore",disabled:e.restorable?void 0:"its commits were not kept",onClick:()=>{O1(n,e.id,t),r({a:"close"})}}],a=[{id:"copy-branch",label:"copy branch name",onClick:()=>Bt(e.branch)},{id:"copy-transcript",label:"copy transcript path",onClick:()=>Bt(e.transcript)}],{sessionId:l}=e;return l&&a.push({id:"copy-session",label:"copy session id",onClick:()=>Bt(l)}),Mn([s,a,[{id:"delete",label:"delete for good…",danger:!0,onClick:()=>{window.confirm(`Delete "${e.title}" for good?
|
|
121
|
+
|
|
122
|
+
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 PL=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function $1(e){const[t,n]=S.useState(()=>Date.now());return S.useEffect(()=>{const r=setInterval(()=>n(Date.now()),6e4);return()=>clearInterval(r)},[]),`${px(t-e)} ago`}function Kl({icon:e,word:t,tone:n,at:r,below:s,children:a,...l}){const c=r!==void 0?{"data-tip":`${t} ${PL.format(r)}`,"data-tip-placement":"follow"}:null;return f.jsxs("div",{...c,...l,className:"daemon-row row-edge","data-tone":n,children:[f.jsxs("div",{className:"daemon-head",children:[f.jsxs("span",{className:"daemon-tag",children:[f.jsx(Et,{name:e,className:"icon-inline"}),t]}),a]}),s]})}function DL({item:e}){const t=ot(),n=P(c=>c.clientId),r=e.uncommitted?"its chat, commits and uncommitted changes":"its chat and commits",s=e.cost!==void 0?`; the session cost ${ic(e.cost)}`:"",a=e.restorable?`Toyon kept ${r}${s}. A message sent below restores it first.`:`Its commits were not kept, so there is nothing to restore${s}; its row's menu on the rail can delete it for good.`,l=$1(e.archivedAt);return f.jsxs(Kl,{icon:"archive",word:"archived",tone:"quiet",at:e.archivedAt,below:f.jsx("div",{className:"daemon-below row-dim",children:a}),children:[f.jsxs("span",{className:"daemon-text",children:[l,e.landed?", after it was merged into main":""]}),e.restorable&&f.jsx(Be,{variant:"inline",tone:"strong",onClick:()=>O1(t,e.id,n),children:"restore"})]})}function Sa(e,t,n,r,s){const{layout:a}=e.getState();Vn({dispatch:e.dispatch},{worktreeId:n,path:r,view:"file",line:{n:s,fiber:!0}}),a.changes||e.dispatch({a:"toggle-changes"})}function zL(e){let t=0;return e.map(n=>{const r={start:t,len:n};return t+=n,r})}function FL(e,t){if(!t)return[];const n=new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"giu"),r=[];for(const s of e.matchAll(n))r.push({start:s.index,end:s.index+s[0].length});return r}function Cv(e,t,n){let r=0,s=e.length-1;for(;r<s;){const l=r+s>>1,c=e[l];(n?t>c.start+c.len:t>=c.start+c.len)?r=l+1:s=l}const a=e[r];return{i:r,at:t-a.start}}function BL(e,t){return{from:Cv(e,t.start,!1),to:Cv(e,t.end,!0)}}function Av(e,t){if(e.length===0)return-1;const n=e.findIndex(r=>r.start>=t);return n===-1?0:n}function UL(e,t,n){return t===0?-1:(e+n+t)%t}function Fm(e){return e.key==="f"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function HL({label:e,query:t,onQuery:n,seed:r,seq:s,status:a,none:l,onStep:c,onClose:u}){const h=S.useRef(null);return gt([s],()=>{var p,g;r&&n(r),(p=h.current)==null||p.focus(),(g=h.current)==null||g.select()}),f.jsxs("div",{className:"find",children:[f.jsx(Ro,{ref:h,autoFocus:!0,value:t,onChange:p=>n(p.target.value),placeholder:"find…","aria-label":e,className:"find-field",spellCheck:!1,onKeyDown:p=>{if(p.key==="Escape"){p.preventDefault(),p.stopPropagation(),u();return}if(p.key==="Enter"){p.preventDefault(),c(p.shiftKey?-1:1);return}if(Fm(p)){p.preventDefault(),p.stopPropagation(),p.currentTarget.select();return}p.key.toLowerCase()==="g"&&(p.metaKey||p.ctrlKey)&&!p.altKey&&(p.preventDefault(),p.stopPropagation(),c(p.shiftKey?-1:1))}}),f.jsx("span",{className:"find-count","aria-live":"polite",children:a}),f.jsx($t,{icon:"caret",label:"Previous match",hint:"⇧↩",className:"find-prev",disabled:l,onClick:()=>c(-1)}),f.jsx($t,{icon:"caret",label:"Next match",hint:"↩",disabled:l,onClick:()=>c(1)}),f.jsx($t,{icon:"close",label:"Close",hint:"esc",onClick:u})]})}const M1="find",L1="find-current",P1=typeof CSS<"u"&&"highlights"in CSS;function WL(e){const t=e.parentElement;return t?typeof t.checkVisibility=="function"?t.checkVisibility():!0:!1}function KL(e){const t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[];for(let r=t.nextNode();r;r=t.nextNode()){const s=r;s.data.length>0&&WL(s)&&n.push(s)}return n}const Sh={matches:[],ranges:[]};function ZL(e,t){if(!t)return Sh;const n=KL(e),r=FL(n.map(l=>l.data).join(""),t),s=zL(n.map(l=>l.data.length)),a=r.map(l=>{const{from:c,to:u}=BL(s,l),h=document.createRange();return h.setStart(n[c.i],c.at),h.setEnd(n[u.i],u.at),h});return{matches:r,ranges:a}}function qL(e,t){P1&&(CSS.highlights.set(M1,new Highlight(...e.filter((n,r)=>r!==t))),CSS.highlights.set(L1,new Highlight(...e[t]?[e[t]]:[])))}function GL(){P1&&(CSS.highlights.delete(M1),CSS.highlights.delete(L1))}function VL(e,t){if(e.length===0)return-1;const n=t.getBoundingClientRect().top,r=e.findIndex(s=>s.getBoundingClientRect().bottom>=n);return r===-1?0:r}const Iv=48;function YL(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect();n.top>=r.top+Iv&&n.bottom<=r.bottom-Iv||(e.scrollTop+=n.top-r.top-r.height/3)}function D1({root:e,body:t,seed:n,seq:r,onClose:s}){const[a,l]=S.useState(n),[c,u]=S.useState(Sh),[h,p]=S.useState(-1),g=S.useRef({found:Sh,at:-1}),k=S.useRef(""),y=S.useRef(!1),[v,_]=S.useState(0);S.useLayoutEffect(()=>{const N=t.current;if(!N)return;let M=0;const J=new MutationObserver(()=>{M||(M=requestAnimationFrame(()=>{M=0,_(W=>W+1)}))});return J.observe(N,{childList:!0,characterData:!0,subtree:!0,attributes:!0}),()=>{J.disconnect(),M&&cancelAnimationFrame(M)}},[t]),S.useLayoutEffect(()=>{const N=t.current;if(!N)return;const M=ZL(N,a),J=a!==k.current;k.current=a,J&&(y.current=!0);const{found:W,at:R}=g.current;let j;J?W.matches[R]?j=Av(M.matches,W.matches[R].start):j=e.current?VL(M.ranges,e.current):Av(M.matches,0):j=Math.min(R,M.matches.length-1),g.current={found:M,at:j},u(M),p(j)},[a,v]),S.useLayoutEffect(()=>{qL(c.ranges,h);const N=c.ranges[h];N&&(y.current&&e.current&&YL(e.current,N),y.current=!1)},[c,h,e]),S.useLayoutEffect(()=>GL,[]);const E=c.matches.length,C=N=>{if(E===0)return;y.current=!0;const M=UL(g.current.at,E,N);g.current={...g.current,at:M},p(M)},x=()=>s(c.ranges[h]??null);return f.jsx(HL,{label:"find in this document",query:a,onQuery:l,seed:n,seq:r,status:a?E===0?"no matches":`${h+1}/${E}`:"",none:E===0,onStep:C,onClose:x})}function z1(e){return e.key==="a"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function F1(e,t,n,r){S.useEffect(()=>{let s=!1;const a=c=>{s=!!e.current&&c.target instanceof Node&&e.current.contains(c.target)},l=c=>{const u=e.current;if(!u||c.defaultPrevented||!t(c))return;const h=document.activeElement;!(h&&h!==document.body?u.contains(h):s)&&!(r!=null&&r(h))||(c.preventDefault(),n(u,c))};return window.addEventListener("pointerdown",a,!0),window.addEventListener("keydown",l),()=>{window.removeEventListener("pointerdown",a,!0),window.removeEventListener("keydown",l)}},[e,t,n,r])}function QL(e){F1(e,z1,B1)}function Nh(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 B1(e){const t=document.createRange();t.selectNodeContents(e);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}const U1=({open:e,remove:t})=>[e?[{id:"open",label:"open full size",onClick:e}]:[],t?[{id:"remove",label:"remove",onClick:t}]:[]];function Zl(e,t={}){return Mn([[{id:"copy-image",label:"copy image",onClick:()=>D2(e)}],...U1(t)])}function H1(e,t={}){const{text:n,href:r}=e;return Mn([n!==void 0?[{id:"copy-text",label:"copy text",onClick:()=>Bt(n)}]:r?[{id:"copy-text",label:"copy text",onClick:()=>P2(r)}]:[],...U1(t)])}function XL(e){return[Wx(e),{id:"copy-link",label:"copy link",onClick:()=>Bt(e)}]}function Th(e){return e?[{id:"copy-code",label:"copy code",onClick:()=>Bt(e)}]:[]}function hl(e,t,{dispatch:n,sock:r},s={}){const a=s.link,l=(a==null?void 0:a.kind)==="file"&&t?()=>r==null?void 0:r.send({t:"reveal",worktreeId:t,path:a.file.path}):void 0,c=a?a.kind==="file"?od(a.file.path,s.dir??null,l):a.kind==="path"||a.kind==="outside"?od(a.path,s.dir??null):[XL(a.href)]:[],u=[{id:"copy",label:"copy message",onClick:()=>Bt(e.text)}],h=[];return e.kind==="user"&&t&&h.push({id:"draft",label:"edit in composer",onClick:()=>{const p=e.seq;if(p===void 0||!r)return n({a:"set-draft",id:t,text:e.text});n({a:"set-draft",id:t,text:""}),r.send({t:"redraft",worktreeId:t,seq:p})}}),Mn([Th(s.code),...c,u,h])}function od(e,t,n){const r=e.startsWith("/")?e:t?`${t}/${e}`:null;return[r?ji(r,n):[],[{id:"copy-path",label:"copy path",onClick:()=>Bt(e)}]]}function JL(e,t){return Mn(od(e,t))}function eP(e,t={}){const n=e.callFile??e.file,r=n?od(n,t.dir??null):[],s=t.remove?[{id:"remove",label:"remove",onClick:t.remove}]:[];return Mn([...r,s])}function Bm({owner:e,onClose:t,menu:n,children:r}){const s=Jt(e);return f.jsxs(Vs,{className:"attach-full scrim",onDismiss:t,onKey:a=>{a.key==="Escape"&&(a.stopPropagation(),t())},onClick:a=>{a.target===a.currentTarget&&t()},...n&&s.contextMenu(n),children:[r,f.jsx($t,{icon:"close",label:"Close",tone:"quiet",onClick:t})]})}/*! @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 Rv(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 tP(e){if(Array.isArray(e))return e}function nP(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,s,a,l,c=[],u=!0,h=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(u=(r=a.call(n)).done)&&(c.push(r.value),c.length!==t);u=!0);}catch(p){h=!0,s=p}finally{try{if(!u&&n.return!=null&&(l=n.return(),Object(l)!==l))return}finally{if(h)throw s}}return c}}function rP(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
123
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function oP(e,t){return tP(e)||nP(e,t)||sP(e,t)||rP()}function sP(e,t){if(e){if(typeof e=="string")return Rv(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)?Rv(e,t):void 0}}const W1=Object.entries,Ov=Object.setPrototypeOf,iP=Object.isFrozen,aP=Object.getPrototypeOf,lP=Object.getOwnPropertyDescriptor;let sr=Object.freeze,mr=Object.seal,aa=Object.create,K1=typeof Reflect<"u"&&Reflect,jh=K1.apply,Ch=K1.construct;sr||(sr=function(t){return t});mr||(mr=function(t){return t});jh||(jh=function(t,n){for(var r=arguments.length,s=new Array(r>2?r-2:0),a=2;a<r;a++)s[a-2]=arguments[a];return t.apply(n,s)});Ch||(Ch=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return new t(...r)});const mi=Qn(Array.prototype.forEach),cP=Qn(Array.prototype.lastIndexOf),$v=Qn(Array.prototype.pop),ml=Qn(Array.prototype.push),uP=Qn(Array.prototype.splice),ka=Array.isArray,_l=Qn(String.prototype.toLowerCase),Pp=Qn(String.prototype.toString),Mv=Qn(String.prototype.match),gl=Qn(String.prototype.replace),Lv=Qn(String.prototype.indexOf),dP=Qn(String.prototype.trim),fP=Qn(Number.prototype.toString),pP=Qn(Boolean.prototype.toString),Pv=typeof BigInt>"u"?null:Qn(BigInt.prototype.toString),Dv=typeof Symbol>"u"?null:Qn(Symbol.prototype.toString),Br=Qn(Object.prototype.hasOwnProperty),kl=Qn(Object.prototype.toString),_r=Qn(RegExp.prototype.test),hi=hP(TypeError);function Qn(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return jh(e,t,r)}}function hP(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Ch(e,n)}}function qt(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:_l;if(Ov&&Ov(e,null),!ka(t))return e;let r=t.length;for(;r--;){let s=t[r];if(typeof s=="string"){const a=n(s);a!==s&&(iP(t)||(t[r]=a),s=a)}e[s]=!0}return e}function mP(e){for(let t=0;t<e.length;t++)Br(e,t)||(e[t]=null);return e}function no(e){const t=aa(null);for(const r of W1(e)){var n=oP(r,2);const s=n[0],a=n[1];Br(e,s)&&(ka(a)?t[s]=mP(a):a&&typeof a=="object"&&a.constructor===Object?t[s]=no(a):t[s]=a)}return t}function gP(e){switch(typeof e){case"string":return e;case"number":return fP(e);case"boolean":return pP(e);case"bigint":return Pv?Pv(e):"0";case"symbol":return Dv?Dv(e):"Symbol()";case"undefined":return kl(e);case"function":case"object":{if(e===null)return kl(e);const t=e,n=To(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:kl(r)}return kl(e)}default:return kl(e)}}function To(e,t){for(;e!==null;){const r=lP(e,t);if(r){if(r.get)return Qn(r.get);if(typeof r.value=="function")return Qn(r.value)}e=aP(e)}function n(){return null}return n}function kP(e){try{return _r(e,""),!0}catch{return!1}}const zv=sr(["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"]),Dp=sr(["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"]),zp=sr(["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"]),yP=sr(["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"]),Fp=sr(["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"]),wP=sr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Fv=sr(["#text"]),Bv=sr(["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"]),Bp=sr(["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"]),Uv=sr(["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"]),Su=sr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),vP=mr(/{{[\w\W]*|^[\w\W]*}}/g),bP=mr(/<%[\w\W]*|^[\w\W]*%>/g),xP=mr(/\${[\w\W]*/g),_P=mr(/^data-[\-\w.\u00B7-\uFFFF]+$/),EP=mr(/^aria-[\-\w]+$/),Hv=mr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),SP=mr(/^(?:\w+script|data):/i),NP=mr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),TP=mr(/^html$/i),jP=mr(/^[a-z][.\w]*(-[.\w]+)+$/i),Wv=mr(/<[/\w!]/g),Kv=mr(/<[/\w]/g),CP=mr(/<\/no(script|embed|frames)/i),AP=mr(/\/>/i),eo={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Z1=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],IP=sr(qt({},Z1)),RP=(function(){const e={};return mi(Z1,t=>{e[t]=mr(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),sr(e)})(),OP=function(){return typeof window>"u"?null:window},$P=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(r=n.getAttribute(s));const a="dompurify"+(r?"#"+r:"");try{return t.createPolicy(a,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Zv=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Ms=function(t,n,r,s){return Br(t,n)&&ka(t[n])?qt(s.base?no(s.base):{},t[n],s.transform):r},Up=function(t,n,r){const s=Br(t,n)?t[n]:void 0;return s&&typeof s=="object"?no(s):r()};function q1(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:OP();const t=Ne=>q1(Ne);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==eo.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,s=r.currentScript;e.DocumentFragment;const a=e.HTMLTemplateElement,l=e.Node,c=e.Element,u=e.NodeFilter,h=e.NamedNodeMap;h===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const p=e.DOMParser,g=e.trustedTypes,k=c.prototype,y=To(k,"cloneNode"),v=To(k,"remove"),_=To(k,"nextSibling"),E=To(k,"childNodes"),C=To(k,"parentNode"),x=To(k,"shadowRoot"),N=To(k,"attributes"),M=l&&l.prototype?To(l.prototype,"nodeType"):null,J=l&&l.prototype?To(l.prototype,"nodeName"):null,W=l&&l.prototype?To(l.prototype,"ownerDocument"):null,R=function(I){return M?M(I):I.nodeType},j=function(I){return J?J(I):I.nodeName};if(typeof a=="function"){const Ne=n.createElement("template");Ne.content&&Ne.content.ownerDocument&&(n=Ne.content.ownerDocument)}let A,D="",H,Y=!1,ae=0;const me=function(){if(ae>0)throw hi('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.')},ye=function(I){me(),ae++;try{return A.createHTML(I)}finally{ae--}},_e=function(I){me(),ae++;try{return A.createScriptURL(I)}finally{ae--}},V=function(){return Y||(H=$P(g,s),Y=!0),H},O=n,F=O.implementation,ne=O.createNodeIterator,$=O.createDocumentFragment,q=O.getElementsByTagName,ke=r.importNode;let se=Zv();t.isSupported=typeof W1=="function"&&typeof C=="function"&&F&&F.createHTMLDocument!==void 0;const ve=vP,Re=bP,le=xP,xe=_P,Le=EP,oe=SP,Z=NP,De=jP;let Ve=Hv,ze=null;const it=qt({},[...zv,...Dp,...zp,...Fp,...Fv]);let Je=null;const en=qt({},[...Bv,...Bp,...Uv,...Su]);let kt=Object.seal(aa(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,st=null;const X=Object.seal(aa(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let we=!0,Qe=!0,he=!1,Oe=!0,Mt=!1,an=!0,vt=!1,Dn=!1,Lt=null,ln=null,Tt=!1,nn=!1,Ut=!1,We=!1,Gt=!0,pn=!1;const Kt="user-content-";let xn=!0,hn=!1,mn={},gn=null;const kn=qt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let U=null;const de=qt({},["audio","video","img","source","image","track"]);let Ae=null;const et=qt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ee="http://www.w3.org/1998/Math/MathML",Se="http://www.w3.org/2000/svg",be="http://www.w3.org/1999/xhtml";let fe=be,Pe=!1,rt=null;const St=qt({},[ee,Se,be],Pp),bt=sr(["mi","mo","mn","ms","mtext"]);let cn=qt({},bt);const at=sr(["annotation-xml"]);let Dt=qt({},at);const un=qt({},["title","style","font","a","script"]);let zn=null;const An=["application/xhtml+xml","text/html"],lr="text/html";let Rt=null,cr=null;const wn=n.createElement("form"),Xn=function(I){return I instanceof RegExp||I instanceof Function},Fn=function(){let I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(cr&&cr===I)return;(!I||typeof I!="object")&&(I={}),I=no(I),zn=An.indexOf(I.PARSER_MEDIA_TYPE)===-1?lr:I.PARSER_MEDIA_TYPE,Rt=zn==="application/xhtml+xml"?Pp:_l,ze=Ms(I,"ALLOWED_TAGS",it,{transform:Rt}),Je=Ms(I,"ALLOWED_ATTR",en,{transform:Rt}),rt=Ms(I,"ALLOWED_NAMESPACES",St,{transform:Pp}),Ae=Ms(I,"ADD_URI_SAFE_ATTR",et,{transform:Rt,base:et}),U=Ms(I,"ADD_DATA_URI_TAGS",de,{transform:Rt,base:de}),gn=Ms(I,"FORBID_CONTENTS",kn,{transform:Rt}),tn=Ms(I,"FORBID_TAGS",no({}),{transform:Rt}),st=Ms(I,"FORBID_ATTR",no({}),{transform:Rt}),mn=Br(I,"USE_PROFILES")?I.USE_PROFILES&&typeof I.USE_PROFILES=="object"?no(I.USE_PROFILES):I.USE_PROFILES:!1,we=I.ALLOW_ARIA_ATTR!==!1,Qe=I.ALLOW_DATA_ATTR!==!1,he=I.ALLOW_UNKNOWN_PROTOCOLS||!1,Oe=I.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Mt=I.SAFE_FOR_TEMPLATES||!1,an=I.SAFE_FOR_XML!==!1,vt=I.WHOLE_DOCUMENT||!1,nn=I.RETURN_DOM||!1,Ut=I.RETURN_DOM_FRAGMENT||!1,We=I.RETURN_TRUSTED_TYPE||!1,Tt=I.FORCE_BODY||!1,Gt=I.SANITIZE_DOM!==!1,pn=I.SANITIZE_NAMED_PROPS||!1,xn=I.KEEP_CONTENT!==!1,hn=I.IN_PLACE||!1,Ve=kP(I.ALLOWED_URI_REGEXP)?I.ALLOWED_URI_REGEXP:Hv,fe=typeof I.NAMESPACE=="string"?I.NAMESPACE:be,cn=Up(I,"MATHML_TEXT_INTEGRATION_POINTS",()=>qt({},bt)),Dt=Up(I,"HTML_INTEGRATION_POINTS",()=>qt({},at));const L=Up(I,"CUSTOM_ELEMENT_HANDLING",()=>aa(null));if(kt=aa(null),Br(L,"tagNameCheck")&&Xn(L.tagNameCheck)&&(kt.tagNameCheck=L.tagNameCheck),Br(L,"attributeNameCheck")&&Xn(L.attributeNameCheck)&&(kt.attributeNameCheck=L.attributeNameCheck),Br(L,"allowCustomizedBuiltInElements")&&typeof L.allowCustomizedBuiltInElements=="boolean"&&(kt.allowCustomizedBuiltInElements=L.allowCustomizedBuiltInElements),mr(kt),Mt&&(Qe=!1),Ut&&(nn=!0),mn&&(ze=qt({},Fv),Je=aa(null),mn.html===!0&&(qt(ze,zv),qt(Je,Bv)),mn.svg===!0&&(qt(ze,Dp),qt(Je,Bp),qt(Je,Su)),mn.svgFilters===!0&&(qt(ze,zp),qt(Je,Bp),qt(Je,Su)),mn.mathMl===!0&&(qt(ze,Fp),qt(Je,Uv),qt(Je,Su))),X.tagCheck=null,X.attributeCheck=null,Br(I,"ADD_TAGS")&&(typeof I.ADD_TAGS=="function"?X.tagCheck=I.ADD_TAGS:ka(I.ADD_TAGS)&&(ze===it&&(ze=no(ze)),qt(ze,I.ADD_TAGS,Rt))),Br(I,"ADD_ATTR")&&(typeof I.ADD_ATTR=="function"?X.attributeCheck=I.ADD_ATTR:ka(I.ADD_ATTR)&&(Je===en&&(Je=no(Je)),qt(Je,I.ADD_ATTR,Rt))),Br(I,"ADD_FORBID_CONTENTS")&&ka(I.ADD_FORBID_CONTENTS)&&(gn===kn&&(gn=no(gn)),qt(gn,I.ADD_FORBID_CONTENTS,Rt)),xn&&(ze["#text"]=!0),vt&&qt(ze,["html","head","body"]),ze.table&&(qt(ze,["tbody"]),delete tn.tbody),I.TRUSTED_TYPES_POLICY){if(typeof I.TRUSTED_TYPES_POLICY.createHTML!="function")throw hi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof I.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw hi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const te=A;A=I.TRUSTED_TYPES_POLICY;try{D=ye("")}catch(pe){throw A=te,pe}}else I.TRUSTED_TYPES_POLICY===null?(A=void 0,D=""):(A===void 0&&(A=V()),A&&typeof D=="string"&&(D=ye("")));sr&&sr(I),cr=I},In=qt({},[...Dp,...zp,...yP]),oo=qt({},[...Fp,...wP]),qr=function(I,L,te){return L.namespaceURI===be?I==="svg":L.namespaceURI===ee?I==="svg"&&(te==="annotation-xml"||cn[te]):!!In[I]},Vt=function(I,L,te){return L.namespaceURI===be?I==="math":L.namespaceURI===Se?I==="math"&&Dt[te]:!!oo[I]},Go=function(I,L,te){return L.namespaceURI===Se&&!Dt[te]||L.namespaceURI===ee&&!cn[te]?!1:!oo[I]&&(un[I]||!In[I])},so=function(I){let L=C(I);(!L||!L.tagName)&&(L={namespaceURI:fe,tagName:"template"});const te=_l(I.tagName),pe=_l(L.tagName);return rt[I.namespaceURI]?I.namespaceURI===Se?qr(te,L,pe):I.namespaceURI===ee?Vt(te,L,pe):I.namespaceURI===be?Go(te,L,pe):!!(zn==="application/xhtml+xml"&&rt[I.namespaceURI]):!1},dt=function(I){ml(t.removed,{element:I});try{C(I).removeChild(I)}catch{if(v(I),!C(I))throw hi("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Zn=function(I,L,te){try{I.removeAttributeNode(L)}catch{try{I.removeAttribute(te)}catch{}}},je=function(I){ft(I);const L=E(I);if(L){const pe=[];mi(L,Ce=>{ml(pe,Ce)}),mi(pe,Ce=>{try{v(Ce)}catch{}})}const te=N(I);if(te)for(let pe=te.length-1;pe>=0;--pe){const Ce=te[pe],$e=Ce&&Ce.name;typeof $e=="string"&&Zn(I,Ce,$e)}},Ue=function(I,L,te){if(!te)try{te=L.getAttributeNode(I)}catch{te=null}ml(t.removed,{attribute:te||null,from:L});try{te?L.removeAttributeNode(te):L.removeAttribute(I)}catch{try{L.removeAttribute(I)}catch{}}if(I==="is")if(nn||Ut)try{dt(L)}catch{}else try{L.setAttribute(I,"")}catch{}},yt=function(I){const L=N(I);if(L)for(let te=L.length-1;te>=0;--te){const pe=L[te],Ce=pe&&pe.name;typeof Ce!="string"||Je[Rt(Ce)]||Zn(I,pe,Ce)}},ft=function(I){const L=[I];for(;L.length>0;){const te=L.pop();R(te)===eo.element&&yt(te);const Ce=E(te);if(Ce)for(let $e=Ce.length-1;$e>=0;--$e)L.push(Ce[$e])}},rn=function(I,L){return an?I==="patchsrc"?!0:I==="for"&&L!=="label"&&L!=="output":!1},Qt=function(I){if(!an)return;const L=[I];for(;L.length>0;){const te=L.pop(),pe=R(te);if(pe===eo.processingInstruction||pe===eo.comment&&_r(Kv,te.data)){try{v(te)}catch{}continue}if(pe===eo.element){const $e=te,mt=Rt(j(te));try{$e.hasAttribute&&$e.hasAttribute("patchsrc")&&$e.removeAttribute("patchsrc"),$e.hasAttribute&&$e.hasAttribute("for")&&rn("for",mt)&&$e.removeAttribute("for")}catch{}}const Ce=E(te);if(Ce)for(let $e=Ce.length-1;$e>=0;--$e)L.push(Ce[$e])}},B=function(I){let L=null,te=null;if(Tt)I="<remove></remove>"+I;else{const $e=Mv(I,/^[\r\n\t ]+/);te=$e&&$e[0]}zn==="application/xhtml+xml"&&fe===be&&(I='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+I+"</body></html>");const pe=A?ye(I):I;if(fe===be)try{L=new p().parseFromString(pe,zn)}catch{}if(!L||!L.documentElement){L=F.createDocument(fe,"template",null);try{L.documentElement.innerHTML=Pe?D:pe}catch{}}const Ce=L.body||L.documentElement;return I&&te&&Ce.insertBefore(n.createTextNode(te),Ce.childNodes[0]||null),fe===be?q.call(L,vt?"html":"body")[0]:vt?L.documentElement:Ce},ue=function(I){const L=W?W(I):I.ownerDocument;return ne.call(L||I,I,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Fe=function(I){return I=gl(I,ve," "),I=gl(I,Re," "),I=gl(I,le," "),I},tt=function(I){var L;I.normalize();const te=W?W(I):I.ownerDocument,pe=ne.call(te||I,I,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let Ce=pe.nextNode();for(;Ce;)Ce.data=Fe(Ce.data),Ce=pe.nextNode();const $e=(L=I.querySelectorAll)===null||L===void 0?void 0:L.call(I,"template");$e&&mi($e,mt=>{jt(mt.content)&&tt(mt.content)})},pt=function(I){const L=J?J(I):null;return typeof L!="string"||Rt(L)!=="form"?!1:typeof I.nodeName!="string"||typeof I.textContent!="string"||typeof I.removeChild!="function"||I.attributes!==N(I)||typeof I.removeAttribute!="function"||typeof I.setAttribute!="function"||typeof I.namespaceURI!="string"||typeof I.insertBefore!="function"||typeof I.hasChildNodes!="function"||I.nodeType!==M(I)||I.childNodes!==E(I)},jt=function(I){if(!M||typeof I!="object"||I===null)return!1;try{return M(I)===eo.documentFragment}catch{return!1}},vn=function(I){if(!M||typeof I!="object"||I===null)return!1;try{return typeof M(I)=="number"}catch{return!1}};function qn(Ne,I,L){Ne.length!==0&&mi(Ne,te=>{te.call(t,I,L,cr)})}const Gr=function(I,L){return!!(an&&I.hasChildNodes()&&!vn(I.firstElementChild)&&_r(Wv,I.textContent)&&_r(Wv,I.innerHTML)||an&&I.namespaceURI===be&&IP[L]&&(vn(I.firstElementChild)||typeof I.textContent=="string"&&_r(RP[L],I.textContent))||I.nodeType===eo.processingInstruction||an&&I.nodeType===eo.comment&&_r(Kv,I.data))},Hn=function(I,L){if(I instanceof RegExp)return _r(I,L);if(I instanceof Function){for(var te=arguments.length,pe=new Array(te>2?te-2:0),Ce=2;Ce<te;Ce++)pe[Ce-2]=arguments[Ce];return!!I(L,...pe)}return!1},ps=function(I,L,te){if(!tn[L]&<(L)&&Hn(kt.tagNameCheck,L))return!1;if(xn&&!gn[L]){const pe=C(I),Ce=E(I);if(Ce&&pe){const $e=Ce.length;for(let mt=$e-1;mt>=0;--mt){const Xt=I===te?y(Ce[mt],!0):Ce[mt];pe.insertBefore(Xt,_(I))}}}return dt(I),!0},Vr=function(I,L,te,pe){return I.length===0?L:L===te||L===pe?no(L):L},Tr=function(I,L){return I===L||C(I)!==null?!1:(hn&&ft(I),!0)},Jn=function(I,L){if(qn(se.beforeSanitizeElements,I,null),Tr(I,L))return!0;if(pt(I))return dt(I),!0;const te=Rt(j(I));if(ze=Vr(se.uponSanitizeElement,ze,it,Lt),qn(se.uponSanitizeElement,I,{tagName:te,allowedTags:ze}),Tr(I,L))return!0;if(Gr(I,te))return dt(I),!0;if(tn[te]||!(X.tagCheck instanceof Function&&X.tagCheck(te))&&!ze[te]){const Ce=ps(I,te,L);return Ce===!1&&qn(se.afterSanitizeElements,I,null),Ce}if(R(I)===eo.element&&!so(I)||(te==="noscript"||te==="noembed"||te==="noframes")&&_r(CP,I.innerHTML))return dt(I),!0;if(Mt&&I.nodeType===eo.text){const Ce=Fe(I.textContent);I.textContent!==Ce&&(ml(t.removed,{element:I.cloneNode()}),I.textContent=Ce)}return qn(se.afterSanitizeElements,I,null),!1},$r=function(I,L,te){if(st[L]||rn(L,I)||Gt&&(L==="id"||L==="name")&&(te in n||te in wn))return!1;const pe=Je[L]||X.attributeCheck instanceof Function&&X.attributeCheck(L,I);return Qe&&_r(xe,L)||we&&_r(Le,L)?!0:pe?Ae[L]||_r(Ve,gl(te,Z,""))||(L==="src"||L==="xlink:href"||L==="href")&&I!=="script"&&Lv(te,"data:")===0&&U[I]||he&&!_r(oe,gl(te,Z,""))?!0:!te:lt(I)&&Hn(kt.tagNameCheck,I)&&Hn(kt.attributeNameCheck,L,I)||L==="is"&&kt.allowCustomizedBuiltInElements&&Hn(kt.tagNameCheck,te)},Ot=qt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),lt=function(I){return!Ot[_l(I)]&&_r(De,I)},Vo=function(I,L,te,pe){if(A&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!te)switch(g.getAttributeType(I,L)){case"TrustedHTML":return ye(pe);case"TrustedScriptURL":return _e(pe)}return pe},yn=function(I,L,te,pe){try{te?I.setAttributeNS(te,L,pe):I.setAttribute(L,pe),pt(I)?dt(I):$v(t.removed)}catch{Ue(L,I)}},Ht=function(I){qn(se.beforeSanitizeAttributes,I,null);const L=I.attributes;if(!L||pt(I))return;Je=Vr(se.uponSanitizeAttribute,Je,en,ln);const te={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Je,forceKeepAttr:void 0};let pe=L.length;const Ce=Rt(I.nodeName);for(;pe--;){const $e=L[pe],mt=$e.name,Xt=$e.namespaceURI,Nn=$e.value,_n=Rt(mt),Mo=Nn;let Wn=mt==="value"?Mo:dP(Mo);if(te.attrName=_n,te.attrValue=Wn,te.keepAttr=!0,te.forceKeepAttr=void 0,qn(se.uponSanitizeAttribute,I,te),Wn=te.attrValue,pn&&(_n==="id"||_n==="name")&&Lv(Wn,Kt)!==0&&(Ue(mt,I,$e),Wn=Kt+Wn),an&&_r(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Wn)){Ue(mt,I,$e);continue}if(_n==="attributename"&&Mv(Wn,"href")){Ue(mt,I,$e);continue}if(!te.forceKeepAttr){if(!te.keepAttr){Ue(mt,I,$e);continue}if(!Oe&&_r(AP,Wn)){Ue(mt,I,$e);continue}if(Mt&&(Wn=Fe(Wn)),!$r(Ce,_n,Wn)){Ue(mt,I,$e);continue}Wn=Vo(Ce,_n,Xt,Wn),Wn!==Mo&&yn(I,mt,Xt,Wn)}}qn(se.afterSanitizeAttributes,I,null)},jr=function(I){let L=null;const te=ue(I);for(qn(se.beforeSanitizeShadowDOM,I,null);L=te.nextNode();)if(qn(se.uponSanitizeShadowNode,L,null),Jn(L,I),Ht(L),jt(L.content)&&jr(L.content),R(L)===eo.element){const pe=x(L);jt(pe)&&(yr(pe),jr(pe))}qn(se.afterSanitizeShadowDOM,I,null)},yr=function(I){const L=[{node:I,shadow:null}];for(;L.length>0;){const te=L.pop();if(te.shadow){jr(te.shadow);continue}const pe=te.node,$e=R(pe)===eo.element,mt=E(pe);if(mt)for(let Xt=mt.length-1;Xt>=0;--Xt)L.push({node:mt[Xt],shadow:null});if($e){const Xt=J?J(pe):null;if(typeof Xt=="string"&&Rt(Xt)==="template"){const Nn=pe.content;jt(Nn)&&L.push({node:Nn,shadow:null})}}if($e){const Xt=x(pe);jt(Xt)&&L.push({node:null,shadow:Xt},{node:Xt,shadow:null})}}};return t.sanitize=function(Ne){let I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},L=null,te=null,pe=null,Ce=null;if(Pe=!Ne,Pe&&(Ne="<!-->"),typeof Ne!="string"&&!vn(Ne)&&(Ne=gP(Ne),typeof Ne!="string"))throw hi("dirty is not a string, aborting");if(!t.isSupported)return Ne;Dn?(ze=Lt,Je=ln):Fn(I),(se.uponSanitizeElement.length>0||se.uponSanitizeAttribute.length>0)&&(ze=no(ze)),se.uponSanitizeAttribute.length>0&&(Je=no(Je)),t.removed=[];const $e=hn&&typeof Ne!="string"&&vn(Ne);if($e){Qt(Ne);const Nn=j(Ne);if(typeof Nn=="string"){const _n=Rt(Nn);if(!ze[_n]||tn[_n])throw je(Ne),hi("root node is forbidden and cannot be sanitized in-place")}if(pt(Ne))throw je(Ne),hi("root node is clobbered and cannot be sanitized in-place");try{yr(Ne)}catch(_n){throw je(Ne),_n}}else if(vn(Ne))L=B("<!---->"),te=L.ownerDocument.importNode(Ne,!0),te.nodeType===eo.element&&te.nodeName==="BODY"||te.nodeName==="HTML"?L=te:L.appendChild(te),yr(te);else{if(!nn&&!Mt&&!vt&&Ne.indexOf("<")===-1)return A&&We?ye(Ne):Ne;if(L=B(Ne),!L)return nn?null:We?D:""}L&&Tt&&dt(L.firstChild);const mt=$e?Ne:L;try{const Nn=ue(mt);for(;pe=Nn.nextNode();)Jn(pe,mt),Ht(pe),jt(pe.content)&&jr(pe.content)}catch(Nn){throw $e&&(je(Ne),mi(t.removed,_n=>{_n.element&&ft(_n.element)})),Nn}if($e)return mi(t.removed,Nn=>{Nn.element&&ft(Nn.element)}),Mt&&tt(Ne),Ne;if(nn){if(Mt&&tt(L),Ut)for(Ce=$.call(L.ownerDocument);L.firstChild;)Ce.appendChild(L.firstChild);else Ce=L;return(Je.shadowroot||Je.shadowrootmode)&&(Ce=ke.call(r,Ce,!0)),Ce}let Xt=vt?L.outerHTML:L.innerHTML;return vt&&ze["!doctype"]&&L.ownerDocument&&L.ownerDocument.doctype&&L.ownerDocument.doctype.name&&_r(TP,L.ownerDocument.doctype.name)&&(Xt="<!DOCTYPE "+L.ownerDocument.doctype.name+`>
|
|
124
|
+
`+Xt),Mt&&(Xt=Fe(Xt)),A&&We?ye(Xt):Xt},t.setConfig=function(){let Ne=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Fn(Ne),Dn=!0,Lt=ze,ln=Je},t.clearConfig=function(){cr=null,Dn=!1,Lt=null,ln=null,A=H,D=""},t.isValidAttribute=function(Ne,I,L){cr||Fn({});const te=Rt(Ne),pe=Rt(I);return $r(te,pe,L)},t.addHook=function(Ne,I){typeof I=="function"&&Br(se,Ne)&&ml(se[Ne],I)},t.removeHook=function(Ne,I){if(Br(se,Ne)){if(I!==void 0){const L=cP(se[Ne],I);return L===-1?void 0:uP(se[Ne],L,1)[0]}return $v(se[Ne])}},t.removeHooks=function(Ne){Br(se,Ne)&&(se[Ne]=[])},t.removeAllHooks=function(){se=Zv()},t}var MP=q1();function Um(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ii=Um();function G1(e){Ii=e}var gi={exec:()=>null};function sa(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),s=t[r];return s||(s=e(r),t[r]=s),s}}function zt(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(s,a)=>{let l=typeof a=="string"?a:a.source;return l=l.replace(Nr.caret,"$1"),n=n.replace(s,l),r},getRegex:()=>new RegExp(n,t)};return r}var LP=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Nr={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:sa(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:sa(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:sa(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:sa(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:sa(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:sa(e=>new RegExp(`^ {0,${e}}>`))},PP=/^(?:[ \t]*(?:\n|$))+/,DP=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,zP=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ac=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,FP=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Hm=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,V1=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Y1=zt(V1).replace(/bull/g,Hm).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(),BP=zt(V1).replace(/bull/g,Hm).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(),Wm=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,UP=/^[^\n]+/,Km=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,HP=zt(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Km).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),WP=zt(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Hm).getRegex(),Bd="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",Zm=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,KP=zt("^ {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",Zm).replace("tag",Bd).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Q1=e=>zt(Wm).replace("hr",ac).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",Bd).getRegex(),ZP=Q1(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),qP=Q1(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),GP=zt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",qP).getRegex(),qm={blockquote:GP,code:DP,def:HP,fences:zP,heading:FP,hr:ac,html:KP,lheading:Y1,list:WP,newline:PP,paragraph:ZP,table:gi,text:UP},qv=zt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ac).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",Bd).getRegex(),VP={...qm,lheading:BP,table:qv,paragraph:zt(Wm).replace("hr",ac).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",qv).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",Bd).getRegex()},YP={...qm,html:zt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Zm).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:gi,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:zt(Wm).replace("hr",ac).replace("heading",` *#{1,6} *[^
|
|
125
|
+
]`).replace("lheading",Y1).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},QP=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,XP=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,X1=/^( {2,}|\\)\n(?!\s*$)/,JP=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,fs=/[\p{P}\p{S}]/u,La=/[\s\p{P}\p{S}]/u,lc=/[^\s\p{P}\p{S}]/u,e4=zt(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,La).getRegex(),t4=/[\p{Pi}\p{Ps}"']/u,J1=/(?!~)[\p{P}\p{S}]/u,n4=/(?!~)[\s\p{P}\p{S}]/u,r4=/(?:[^\s\p{P}\p{S}]|~)/u,o4=zt(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",LP?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),e_=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,s4=zt(e_,"u").replace(/punct/g,fs).getRegex(),i4=zt(e_,"u").replace(/punct/g,J1).getRegex(),a4=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,l4=zt(a4,"u").replace(/openQuote/g,t4).replace(/punct/g,fs).getRegex(),t_="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",c4=zt(t_,"gu").replace(/notPunctSpace/g,lc).replace(/punctSpace/g,La).replace(/punct/g,fs).getRegex(),u4=zt(t_,"gu").replace(/notPunctSpace/g,r4).replace(/punctSpace/g,n4).replace(/punct/g,J1).getRegex(),d4="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",f4=zt(d4,"gu").replace(/notPunctSpace/g,lc).replace(/punctSpace/g,La).replace(/punct/g,fs).getRegex(),p4=zt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,lc).replace(/punctSpace/g,La).replace(/punct/g,fs).getRegex(),h4="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",m4=zt(h4,"gu").replace(/notPunctSpace/g,lc).replace(/punctSpace/g,La).replace(/punct/g,fs).getRegex(),g4=zt(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,fs).getRegex(),k4="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",y4=zt(k4,"gu").replace(/notPunctSpace/g,lc).replace(/punctSpace/g,La).replace(/punct/g,fs).getRegex(),w4=zt(/\\(punct)/,"gu").replace(/punct/g,fs).getRegex(),v4=zt(/^<(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(),b4=zt(Zm).replace("(?:-->|$)","-->").getRegex(),x4=zt("^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",b4).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),sd=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,_4=zt(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",sd).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),n_=zt(/^!?\[(label)\]\[(ref)\]/).replace("label",sd).replace("ref",Km).getRegex(),r_=zt(/^!?\[(ref)\](?:\[\])?/).replace("ref",Km).getRegex(),E4=zt("reflink|nolink(?!\\()","g").replace("reflink",n_).replace("nolink",r_).getRegex(),Gv=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Gm={_backpedal:gi,anyPunctuation:w4,autolink:v4,blockSkip:o4,br:X1,code:XP,del:gi,delLDelim:gi,delRDelim:gi,emStrongLDelim:s4,emStrongRDelimAst:c4,emStrongRDelimUnd:p4,escape:QP,link:_4,nolink:r_,punctuation:e4,reflink:n_,reflinkSearch:E4,tag:x4,text:JP,url:gi},S4={...Gm,emStrongLDelim:l4,emStrongRDelimAst:f4,emStrongRDelimUnd:m4,link:zt(/^!?\[(label)\]\((.*?)\)/).replace("label",sd).getRegex(),reflink:zt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",sd).getRegex()},Ah={...Gm,emStrongRDelimAst:u4,emStrongLDelim:i4,delLDelim:g4,delRDelim:y4,url:zt(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Gv).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:zt(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Gv).getRegex()},N4={...Ah,br:zt(X1).replace("{2,}","*").getRegex(),text:zt(Ah.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Nu={normal:qm,gfm:VP,pedantic:YP},yl={normal:Gm,gfm:Ah,breaks:N4,pedantic:S4},T4={"&":"&","<":"<",">":">",'"':""","'":"'"},Vv=e=>T4[e];function Fo(e,t){if(t){if(Nr.escapeTest.test(e))return e.replace(Nr.escapeReplace,Vv)}else if(Nr.escapeTestNoEncode.test(e))return e.replace(Nr.escapeReplaceNoEncode,Vv);return e}function Yv(e){try{e=encodeURI(e).replace(Nr.percentDecode,"%")}catch{return null}return e}function Qv(e,t){var a;let n=e.replace(Nr.findPipe,(l,c,u)=>{let h=!1,p=c;for(;--p>=0&&u[p]==="\\";)h=!h;return h?"|":" |"}),r=n.split(Nr.splitPipe),s=0;if(r[0].trim()||r.shift(),r.length>0&&!((a=r.at(-1))!=null&&a.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;s<r.length;s++)r[s]=r[s].trim().replace(Nr.slashPipe,"|");return r}function Ls(e,t,n){let r=e.length;if(r===0)return"";let s=0;for(;s<r&&e.charAt(r-s-1)===t;)s++;return e.slice(0,r-s)}function Xv(e){let t=e.split(`
|
|
126
|
+
`),n=t.length-1;for(;n>=0&&Nr.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
127
|
+
`)}function j4(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 C4(e,t=0){let n=t,r="";for(let s of e)if(s===" "){let a=4-n%4;r+=" ".repeat(a),n+=a}else r+=s,n++;return r}function Jv(e,t,n,r,s){let a=t.href,l=t.title||null,c=e[1].replace(s.other.outputLinkReplace,"$1"),u=e[0].charAt(0)==="!";r.state.inLink=!0;let h=r.state.linkEmitted,p=r.state.inRawBlock;r.state.linkEmitted=!1;let g=r.inlineTokens(c),k=r.state.linkEmitted;if(r.state.linkEmitted=h,r.state.inLink=!1,!u){if(k){r.state.inRawBlock=p;return}r.state.linkEmitted=!0}return{type:u?"image":"link",raw:n,href:a,title:l,text:c,tokens:g}}function A4(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let s=r[1];return t.split(`
|
|
128
|
+
`).map(a=>{let l=a.match(n.other.beginningSpace);if(l===null)return a;let[c]=l;return c.length>=s.length?a.slice(s.length):a}).join(`
|
|
129
|
+
`)}var id=class{constructor(e){Ct(this,"options");Ct(this,"rules");Ct(this,"lexer");this.options=e||Ii}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]:Xv(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=A4(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=Ls(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:Ls(t[0],`
|
|
130
|
+
`),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:Ls(t[0],`
|
|
131
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Ls(t[0],`
|
|
132
|
+
`).split(`
|
|
133
|
+
`),r="",s="",a=[];for(;n.length>0;){let l=!1,c=[],u;for(u=0;u<n.length;u++)if(this.rules.other.blockquoteStart.test(n[u]))c.push(n[u]),l=!0;else if(!l)c.push(n[u]);else break;n=n.slice(u);let h=c.join(`
|
|
134
|
+
`),p=h.replace(this.rules.other.blockquoteSetextReplace,`
|
|
135
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
136
|
+
${h}`:h,s=s?`${s}
|
|
137
|
+
${p}`:p;let g=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,a,!0),this.lexer.state.top=g,n.length===0)break;let k=a.at(-1);if((k==null?void 0:k.type)==="code")break;if((k==null?void 0:k.type)==="blockquote"){let y=k,v=n.join(`
|
|
138
|
+
`),_=y.raw+`
|
|
139
|
+
`+v.replace(this.rules.other.blockquoteSetextReplace2,""),E=this.blockquote(_);a[a.length-1]=E,r=`${r}
|
|
140
|
+
${v}`,s=s.substring(0,s.length-y.text.length)+E.text;break}else if((k==null?void 0:k.type)==="list"){let y=k,v=y.raw+`
|
|
141
|
+
`+n.join(`
|
|
142
|
+
`),_=this.list(v);a[a.length-1]=_,r=r.substring(0,r.length-k.raw.length)+_.raw,s=s.substring(0,s.length-y.raw.length)+_.raw,n=v.substring(a.at(-1).raw.length).split(`
|
|
143
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:a,text:s}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,s={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 a=this.rules.other.listItemRegex(n),l=!1;for(;e;){let u=!1,h="",p="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;h=t[0],e=e.substring(h.length);let g=C4(t[2].split(`
|
|
144
|
+
`,1)[0],t[1].length),k=e.split(`
|
|
145
|
+
`,1)[0],y=!g.trim(),v=0;if(this.options.pedantic?(v=2,p=g.trimStart()):y?v=t[1].length+1:(v=g.search(this.rules.other.nonSpaceChar),v=v>4?1:v,p=g.slice(v),v+=t[1].length),y&&this.rules.other.blankLine.test(k)&&(h+=k+`
|
|
146
|
+
`,e=e.substring(k.length+1),u=!0),!u){let _=this.rules.other.nextBulletRegex(v),E=this.rules.other.hrRegex(v),C=this.rules.other.fencesBeginRegex(v),x=this.rules.other.headingBeginRegex(v),N=this.rules.other.htmlBeginRegex(v),M=this.rules.other.blockquoteBeginRegex(v);for(;e;){let J=e.split(`
|
|
147
|
+
`,1)[0],W;if(k=J,this.options.pedantic?(k=k.replace(this.rules.other.listReplaceNesting," "),W=k):W=k.replace(this.rules.other.tabCharGlobal," "),C.test(k)||x.test(k)||N.test(k)||M.test(k)||_.test(k)||E.test(k))break;if(W.search(this.rules.other.nonSpaceChar)>=v||!k.trim())p+=`
|
|
148
|
+
`+W.slice(v);else{if(y||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||C.test(g)||x.test(g)||E.test(g))break;p+=`
|
|
149
|
+
`+k}y=!k.trim(),h+=J+`
|
|
150
|
+
`,e=e.substring(J.length+1),g=W.slice(v)}}s.loose||(l?s.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(l=!0)),s.items.push({type:"list_item",raw:h,task:!!this.options.gfm&&this.rules.other.listIsTask.test(p),loose:!1,text:p,tokens:[]}),s.raw+=h}let c=s.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let u of s.items)if(this.lexer.state.top=!1,u.tokens=this.lexer.blockTokens(u.text,[]),!s.loose){let h=u.tokens.filter(g=>g.type==="space"),p=h.length>0&&h.some(g=>this.rules.other.anyLine.test(g.raw));s.loose=p}for(let u of s.items){let h=u.tokens[0];if(u.task&&((h==null?void 0:h.type)==="text"||(h==null?void 0:h.type)==="paragraph")){u.text=u.text.replace(this.rules.other.listReplaceTask,""),h.raw=h.raw.replace(this.rules.other.listReplaceTask,""),h.text=h.text.replace(this.rules.other.listReplaceTask,"");for(let g=this.lexer.inlineQueue.length-1;g>=0;g--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[g].src)){this.lexer.inlineQueue[g].src=this.lexer.inlineQueue[g].src.replace(this.rules.other.listReplaceTask,"");break}let p=this.rules.other.listTaskCheckbox.exec(u.raw);if(p){let g={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};u.checked=g.checked,s.loose?u.tokens[0]&&["paragraph","text"].includes(u.tokens[0].type)&&"tokens"in u.tokens[0]&&u.tokens[0].tokens?(u.tokens[0].raw=g.raw+u.tokens[0].raw,u.tokens[0].text=g.raw+u.tokens[0].text,u.tokens[0].tokens.unshift(g)):u.tokens.unshift({type:"paragraph",raw:g.raw,text:g.raw,tokens:[g]}):u.tokens.unshift(g)}}else u.task&&(u.task=!1)}if(s.loose)for(let u of s.items){u.loose=!0;for(let h of u.tokens)h.type==="text"&&(h.type="paragraph")}return s}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=Xv(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"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:Ls(t[0],`
|
|
151
|
+
`),href:r,title:s}}}table(e){var l;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Qv(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=(l=t[3])!=null&&l.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
152
|
+
`):[],a={type:"table",raw:Ls(t[0],`
|
|
153
|
+
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let c of r)this.rules.other.tableAlignRight.test(c)?a.align.push("right"):this.rules.other.tableAlignCenter.test(c)?a.align.push("center"):this.rules.other.tableAlignLeft.test(c)?a.align.push("left"):a.align.push(null);for(let c=0;c<n.length;c++)a.header.push({text:n[c],tokens:this.lexer.inline(n[c]),header:!0,align:a.align[c]});for(let c of s)a.rows.push(Qv(c,a.header.length).map((u,h)=>({text:u,tokens:this.lexer.inline(u),header:!1,align:a.align[h]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:Ls(t[0],`
|
|
154
|
+
`),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)===`
|
|
155
|
+
`?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 a=Ls(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{let a=j4(t[2],"()");if(a===-2)return;if(a>-1){let l=(t[0].indexOf("!")===0?5:4)+t[1].length+a;t[2]=t[2].substring(0,a),t[0]=t[0].substring(0,l).trim(),t[3]=""}}let r=t[2],s="";if(this.options.pedantic){let a=this.rules.other.pedanticHrefTitle.exec(r);a&&(r=a[1],s=a[3])}else s=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)),Jv(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.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," "),s=t[r.toLowerCase()];if(!s){let a=n[0].charAt(0);return{type:"text",raw:a,text:a}}return Jv(n,s,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 s=[...r[0]].length-1,a,l,c=s,u=0,h=r[0][0],p=n===h,g=h==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(g.lastIndex=0,t=t.slice(-1*e.length+s);(r=g.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a)continue;if(l=[...a].length,r[3]||r[4]){c+=l;continue}else if(r[5]||r[6]){if(s%3&&!((s+l)%3)){u+=l;continue}if(p)break}if(c-=l,c>0)continue;l=Math.min(l,l+c+u);let k=[...r[0]][0].length,y=e.slice(0,s+r.index+k+l);if(Math.min(s,l)%2){let _=y.slice(1,-1);return{type:"em",raw:y,text:_,tokens:this.lexer.inlineTokens(_)}}let v=y.slice(2,-2);return{type:"strong",raw:y,text:v,tokens:this.lexer.inlineTokens(v)}}}}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),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&s&&(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 s=[...r[0]].length-1,a,l,c=s,u=this.rules.inline.delRDelim;for(u.lastIndex=0,t=t.slice(-1*e.length+s);(r=u.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a||(l=[...a].length,l!==s))continue;if(r[3]||r[4]){c+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c);let h=[...r[0]][0].length,p=e.slice(0,s+r.index+h+l),g=p.slice(s,-s);return{type:"del",raw:p,text:g,tokens:this.lexer.inlineTokens(g)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let r,s;if(t[2]==="@")r=t[0],s="mailto:"+r;else{let a;do a=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(a!==t[0]);r=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:r,href:s,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}}}},Co=class Ih{constructor(t){Ct(this,"tokens");Ct(this,"options");Ct(this,"state");Ct(this,"inlineQueue");Ct(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ii,this.options.tokenizer=this.options.tokenizer||new id,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:Nr,block:Nu.normal,inline:yl.normal};this.options.pedantic?(n.block=Nu.pedantic,n.inline=yl.pedantic):this.options.gfm&&(n.block=Nu.gfm,this.options.breaks?n.inline=yl.breaks:n.inline=yl.gfm),this.tokenizer.rules=n}static get rules(){return{block:Nu,inline:yl}}static lex(t,n){return new Ih(n).lex(t)}static lexInline(t,n){return new Ih(n).inlineTokens(t)}lex(t){t=t.replace(Nr.carriageReturn,`
|
|
156
|
+
`),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 a,l,c;this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(Nr.tabCharGlobal," ").replace(Nr.spaceLine,""));let s=1/0;for(;t;){if(t.length<s)s=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let u;if((l=(a=this.options.extensions)==null?void 0:a.block)!=null&&l.some(p=>(u=p.call({lexer:this},t,n))?(t=t.substring(u.raw.length),n.push(u),!0):!1))continue;if(u=this.tokenizer.space(t)){t=t.substring(u.raw.length);let p=n.at(-1);u.raw.length===1&&p!==void 0?p.raw+=`
|
|
157
|
+
`:n.push(u);continue}if(u=this.tokenizer.code(t)){t=t.substring(u.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(`
|
|
158
|
+
`)?"":`
|
|
159
|
+
`)+u.raw,p.text+=`
|
|
160
|
+
`+u.text,this.inlineQueue.at(-1).src=p.text):n.push(u);continue}if(u=this.tokenizer.fences(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.heading(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.hr(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.blockquote(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.list(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.html(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.def(t)){t=t.substring(u.raw.length);let p=n.at(-1);(p==null?void 0:p.type)==="paragraph"||(p==null?void 0:p.type)==="text"?(p.raw+=(p.raw.endsWith(`
|
|
161
|
+
`)?"":`
|
|
162
|
+
`)+u.raw,p.text+=`
|
|
163
|
+
`+u.raw,this.inlineQueue.at(-1).src=p.text):this.tokens.links[u.tag]||(this.tokens.links[u.tag]={href:u.href,title:u.title},n.push(u));continue}if(u=this.tokenizer.table(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.lheading(t)){t=t.substring(u.raw.length),n.push(u);continue}let h=t;if((c=this.options.extensions)!=null&&c.startBlock){let p=1/0,g=t.slice(1),k;this.options.extensions.startBlock.forEach(y=>{k=y.call({lexer:this},g),typeof k=="number"&&k>=0&&(p=Math.min(p,k))}),p<1/0&&p>=0&&(h=t.substring(0,p+1))}if(this.state.top&&(u=this.tokenizer.paragraph(h))){let p=n.at(-1);r&&(p==null?void 0:p.type)==="paragraph"?(p.raw+=(p.raw.endsWith(`
|
|
164
|
+
`)?"":`
|
|
165
|
+
`)+u.raw,p.text+=`
|
|
166
|
+
`+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=p.text):n.push(u),r=h.length!==t.length,t=t.substring(u.raw.length);continue}if(u=this.tokenizer.text(t)){t=t.substring(u.raw.length);let p=n.at(-1);(p==null?void 0:p.type)==="text"?(p.raw+=(p.raw.endsWith(`
|
|
167
|
+
`)?"":`
|
|
168
|
+
`)+u.raw,p.text+=`
|
|
169
|
+
`+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=p.text):n.push(u);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}linkInText(t){if(!t.includes("["))return!1;let n=this.tokenizer.rules.inline.link;for(let r of t.matchAll(this.tokenizer.rules.inline.blockSkip))if(n.test(r[0])&&t.charAt(r.index-1)!=="!")return!0;for(let r of t.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let s=r[0],a=s.lastIndexOf("[");if(!(s.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,s.slice(a+1,-1)))&&!(a>1&&this.linkInText(s.slice(1,a-1))))return!0}return!1}inlineTokens(t,n=[]){var c,u,h,p,g;this.tokenizer.lexer=this;let r=t;if(this.tokens.links&&t.includes("[")){let k=this.tokenizer.rules.inline.reflinkSearch,y=v=>{let _=v.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,v.slice(_+1,-1)))return v;if(_>1&&v.charAt(0)!=="!"){let E=v.slice(1,_-1);if(this.linkInText(E))return"["+E.replace(k,y)+"]["+"a".repeat(v.length-_-2)+"]"}return"["+"a".repeat(v.length-2)+"]"};r=r.replace(k,y)}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,k=>"+".repeat(k.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(k,y,v)=>{let _=v?v.length:0;return k.slice(0,_)+"["+"a".repeat(k.length-_-2)+"]"}),r=((u=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:u.call({lexer:this},r))??r;let s=!1,a="",l=1/0;for(;t;){if(t.length<l)l=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}s||(a=""),s=!1;let k;if((p=(h=this.options.extensions)==null?void 0:h.inline)!=null&&p.some(v=>(k=v.call({lexer:this},t,n))?(t=t.substring(k.raw.length),n.push(k),!0):!1))continue;if(k=this.tokenizer.escape(t)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.tag(t)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.link(t)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(k.raw.length);let v=n.at(-1);k.type==="text"&&(v==null?void 0:v.type)==="text"?(v.raw+=k.raw,v.text+=k.text):n.push(k);continue}if(k=this.tokenizer.emStrong(t,r,a)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.codespan(t)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.br(t)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.del(t,r,a)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.autolink(t)){t=t.substring(k.raw.length),n.push(k);continue}if(!this.state.inLink&&(k=this.tokenizer.url(t))){t=t.substring(k.raw.length),n.push(k);continue}let y=t;if((g=this.options.extensions)!=null&&g.startInline){let v=1/0,_=t.slice(1),E;this.options.extensions.startInline.forEach(C=>{E=C.call({lexer:this},_),typeof E=="number"&&E>=0&&(v=Math.min(v,E))}),v<1/0&&v>=0&&(y=t.substring(0,v+1))}if(k=this.tokenizer.inlineText(y)){t=t.substring(k.raw.length),k.raw.slice(-1)!=="_"&&(a=k.raw.slice(-1)),s=!0;let v=n.at(-1);(v==null?void 0:v.type)==="text"?(v.raw+=k.raw,v.text+=k.text):n.push(k);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)}},ad=class{constructor(e){Ct(this,"options");Ct(this,"parser");this.options=e||Ii}space(e){return""}code({text:e,lang:t,escaped:n}){var a;let r=(a=(t||"").match(Nr.notSpaceStart))==null?void 0:a[0],s=e.replace(Nr.endingNewline,"")+`
|
|
170
|
+
`;return r?'<pre><code class="language-'+Fo(r)+'">'+(n?s:Fo(s,!0))+`</code></pre>
|
|
171
|
+
`:"<pre><code>"+(n?s:Fo(s,!0))+`</code></pre>
|
|
172
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
173
|
+
${this.parser.parse(e)}</blockquote>
|
|
174
|
+
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
175
|
+
`}hr(e){return`<hr>
|
|
176
|
+
`}list(e){let t=e.ordered,n=e.start,r="";for(let l=0;l<e.items.length;l++){let c=e.items[l];r+=this.listitem(c)}let s=t?"ol":"ul",a=t&&n!==1?' start="'+n+'"':"";return"<"+s+a+`>
|
|
177
|
+
`+r+"</"+s+`>
|
|
178
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
179
|
+
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
180
|
+
`}table(e){let t="",n="";for(let s=0;s<e.header.length;s++)n+=this.tablecell(e.header[s]);t+=this.tablerow({text:n});let r="";for(let s=0;s<e.rows.length;s++){let a=e.rows[s];n="";for(let l=0;l<a.length;l++)n+=this.tablecell(a[l]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
181
|
+
<thead>
|
|
182
|
+
`+t+`</thead>
|
|
183
|
+
`+r+`</table>
|
|
184
|
+
`}tablerow({text:e}){return`<tr>
|
|
185
|
+
${e}</tr>
|
|
186
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
187
|
+
`}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>${Fo(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),s=Yv(e);if(s===null)return r;e=s;let a='<a href="'+e+'"';return t&&(a+=' title="'+Fo(t)+'"'),a+=">"+r+"</a>",a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let s=Yv(e);if(s===null)return Fo(n);e=s;let a=`<img src="${e}" alt="${Fo(n)}"`;return t&&(a+=` title="${Fo(t)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Fo(e.text)}},Vm=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}},Ao=class Rh{constructor(t){Ct(this,"options");Ct(this,"renderer");Ct(this,"textRenderer");this.options=t||Ii,this.options.renderer=this.options.renderer||new ad,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Vm}static parse(t,n){return new Rh(n).parse(t)}static parseInline(t,n){return new Rh(n).parseInline(t)}parse(t){var r,s;this.renderer.parser=this;let n="";for(let a=0;a<t.length;a++){let l=t[a];if((s=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&s[l.type]){let u=l,h=this.options.extensions.renderers[u.type].call({parser:this},u);if(h!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(u.type)){n+=h||"";continue}}let c=l;switch(c.type){case"space":{n+=this.renderer.space(c);break}case"hr":{n+=this.renderer.hr(c);break}case"heading":{n+=this.renderer.heading(c);break}case"code":{n+=this.renderer.code(c);break}case"table":{n+=this.renderer.table(c);break}case"blockquote":{n+=this.renderer.blockquote(c);break}case"list":{n+=this.renderer.list(c);break}case"checkbox":{n+=this.renderer.checkbox(c);break}case"html":{n+=this.renderer.html(c);break}case"def":{n+=this.renderer.def(c);break}case"paragraph":{n+=this.renderer.paragraph(c);break}case"text":{n+=this.renderer.text(c);break}default:{let u='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return n}parseInline(t,n=this.renderer){var s,a;this.renderer.parser=this;let r="";for(let l=0;l<t.length;l++){let c=t[l];if((a=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&a[c.type]){let h=this.options.extensions.renderers[c.type].call({parser:this},c);if(h!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(c.type)){r+=h||"";continue}}let u=c;switch(u.type){case"escape":{r+=n.text(u);break}case"html":{r+=n.html(u);break}case"link":{r+=n.link(u);break}case"image":{r+=n.image(u);break}case"checkbox":{r+=n.checkbox(u);break}case"strong":{r+=n.strong(u);break}case"em":{r+=n.em(u);break}case"codespan":{r+=n.codespan(u);break}case"br":{r+=n.br(u);break}case"del":{r+=n.del(u);break}case"text":{r+=n.text(u);break}default:{let h='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(h),"";throw new Error(h)}}}return r}},Iu,El=(Iu=class{constructor(e){Ct(this,"options");Ct(this,"block");this.options=e||Ii}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Co.lex:Co.lexInline}provideParser(e=this.block){return e?Ao.parse:Ao.parseInline}},Ct(Iu,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),Ct(Iu,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Iu),I4=class{constructor(...e){Ct(this,"defaults",Um());Ct(this,"options",this.setOptions);Ct(this,"parse",this.parseMarkdown(!0));Ct(this,"parseInline",this.parseMarkdown(!1));Ct(this,"Parser",Ao);Ct(this,"Renderer",ad);Ct(this,"TextRenderer",Vm);Ct(this,"Lexer",Co);Ct(this,"Tokenizer",id);Ct(this,"Hooks",El);this.use(...e)}walkTokens(e,t){var r,s;let n=[];for(let a of e)switch(n=n.concat(t.call(this,a)),a.type){case"table":{let l=a;for(let c of l.header)n=n.concat(this.walkTokens(c.tokens,t));for(let c of l.rows)for(let u of c)n=n.concat(this.walkTokens(u.tokens,t));break}case"list":{let l=a;n=n.concat(this.walkTokens(l.items,t));break}default:{let l=a;(s=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&s[l.type]?this.defaults.extensions.childTokens[l.type].forEach(c=>{let u=l[c].flat(1/0);n=n.concat(this.walkTokens(u,t))}):l.tokens&&(n=n.concat(this.walkTokens(l.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let a=t.renderers[s.name];a?t.renderers[s.name]=function(...l){let c=s.renderer.apply(this,l);return c===!1&&(c=a.apply(this,l)),c}:t.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=t[s.level];a?a.unshift(s.tokenizer):t[s.level]=[s.tokenizer],s.start&&(s.level==="block"?t.startBlock?t.startBlock.push(s.start):t.startBlock=[s.start]:s.level==="inline"&&(t.startInline?t.startInline.push(s.start):t.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(t.childTokens[s.name]=s.childTokens)}),r.extensions=t),n.renderer){let s=this.defaults.renderer||new ad(this.defaults);for(let a in n.renderer){if(!(a in s))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let l=a,c=n.renderer[l],u=s[l];s[l]=(...h)=>{let p=c.apply(s,h);return p===!1&&(p=u.apply(s,h)),p||""}}r.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new id(this.defaults);for(let a in n.tokenizer){if(!(a in s))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let l=a,c=n.tokenizer[l],u=s[l];s[l]=(...h)=>{let p=c.apply(s,h);return p===!1&&(p=u.apply(s,h)),p}}r.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new El;for(let a in n.hooks){if(!(a in s))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let l=a,c=n.hooks[l],u=s[l];El.passThroughHooks.has(a)?s[l]=h=>{if(this.defaults.async&&El.passThroughHooksRespectAsync.has(a))return(async()=>{let g=await c.call(s,h);return u.call(s,g)})();let p=c.call(s,h);return u.call(s,p)}:s[l]=(...h)=>{if(this.defaults.async)return(async()=>{let g=await c.apply(s,h);return g===!1&&(g=await u.apply(s,h)),g})();let p=c.apply(s,h);return p===!1&&(p=u.apply(s,h)),p}}r.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,a=n.walkTokens;r.walkTokens=function(l){let c=[];return c.push(a.call(this,l)),s&&(c=c.concat(s.call(this,l))),c}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Co.lex(e,t??this.defaults)}parser(e,t){return Ao.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},s={...this.defaults,...r},a=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&r.async===!1)return a(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 a(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let l=s.hooks?await s.hooks.preprocess(t):t,c=await(s.hooks?await s.hooks.provideLexer(e):e?Co.lex:Co.lexInline)(l,s),u=s.hooks?await s.hooks.processAllTokens(c):c;s.walkTokens&&await Promise.all(this.walkTokens(u,s.walkTokens));let h=await(s.hooks?await s.hooks.provideParser(e):e?Ao.parse:Ao.parseInline)(u,s);return s.hooks?await s.hooks.postprocess(h):h})().catch(a);try{s.hooks&&(t=s.hooks.preprocess(t));let l=(s.hooks?s.hooks.provideLexer(e):e?Co.lex:Co.lexInline)(t,s);s.hooks&&(l=s.hooks.processAllTokens(l)),s.walkTokens&&this.walkTokens(l,s.walkTokens);let c=(s.hooks?s.hooks.provideParser(e):e?Ao.parse:Ao.parseInline)(l,s);return s.hooks&&(c=s.hooks.postprocess(c)),c}catch(l){return a(l)}}}onError(e,t){return n=>{if(n.message+=`
|
|
188
|
+
Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+Fo(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},Ci=new I4;function on(e,t){return Ci.parse(e,t)}on.options=on.setOptions=function(e){return Ci.setOptions(e),on.defaults=Ci.defaults,G1(on.defaults),on};on.getDefaults=Um;on.defaults=Ii;function R4(...e){return Ci.use(...e),on.defaults=Ci.defaults,G1(on.defaults),on}on.use=R4;on.walkTokens=function(e,t){return Ci.walkTokens(e,t)};on.parseInline=Ci.parseInline;on.Parser=Ao;on.parser=Ao.parse;on.Renderer=ad;on.TextRenderer=Vm;on.Lexer=Co;on.lexer=Co.lex;on.Tokenizer=id;on.Hooks=El;on.parse=on;on.options;on.setOptions;on.walkTokens;on.parseInline;Ao.parse;Co.lex;const o_="#toyon-link-pending",O4=/!?\[([^[\]\n]*)(?:\]\(([^()\s]*))?$/;function $4(e){const t=e.lastIndexOf(`
|
|
189
|
+
`)+1,n=e.slice(t),r=O4.exec(n);return!r||M4(e.slice(0,t))||L4(n.slice(0,r.index))?e:`${e.slice(0,t)}${n.slice(0,r.index)}[${r[1]}](${o_})`}function M4(e){let t=!1;for(const n of e.split(`
|
|
190
|
+
`))/^\s*(```|~~~)/.test(n)&&(t=!t);return t}function L4(e){let t=0;for(const n of e)n==="`"&&t++;return t%2===1}const Hp="__[a-z][a-z0-9_]*[a-z0-9]__",P4=new RegExp(`^(?:${Hp}\\.)+${Hp}|^${Hp}(?=\\.\\w|\\(|["'])`),D4={name:"dunder",level:"inline",start:e=>e.indexOf("__"),tokenizer(e){const t=P4.exec(e);if(t)return{type:"dunder",raw:t[0],text:t[0]}},renderer:e=>e.text};function Ym(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 s of n.split("/"))if(!(s===""||s==="."))if(s===".."){if(!r.length)return null;r.pop()}else r.push(decodeURIComponent(s));return r.length?r.join("/"):null}const s_=e=>e.slice(0,Math.max(0,e.lastIndexOf("/")));function i_(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 s=n.match(/:(\d+)(?::\d+)?$/);s&&(n=n.slice(0,s.index));const a=e.replace(/\/+$/,"");if(!a||!n.startsWith(`${a}/`))return null;const l=n.endsWith("/"),c=n.slice(a.length+1).replace(/\/+$/,"");if(!c||c.split("/").some(p=>p===".."))return null;if(l)return{path:c,folder:!0};const u=(r==null?void 0:r[1])??(s==null?void 0:s[1]),h=u?Number.parseInt(u,10):void 0;return h&&h>0?{path:c,line:h}:{path:c}}function a_(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),s=t.slice(0,n.index);return r>0?{path:s,line:r}:{path:s}}function z4(e){return e.length<2||!e.startsWith("/")||e.startsWith("//")||/\s/.test(e)?null:e}function F4(e){if(e.header.some(n=>n.text.trim()))return!1;let t="";for(const n of e.rows){let r="";for(const s of n)r+=this.tablecell(s);t+=this.tablerow({text:r})}return`<table>
|
|
191
|
+
<tbody>${t}</tbody></table>
|
|
192
|
+
`}function B4(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 s={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},a=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),l={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},c={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,s]};s.contains.push(c);const u={match:/\\"/},h={className:"string",begin:/'/,end:/'/},p={match:/\\'/},g={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},k=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],y=e.SHEBANG({binary:`(${k.join("|")})`,relevance:10}),v={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},_=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],E=["true","false"],C={match:/(\/[a-z._-]+)+/},x=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],N=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],M=["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"],J=["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:_,literal:E,built_in:[...x,...N,"set","shopt",...M,...J]},contains:[y,e.SHEBANG(),v,g,a,l,C,c,u,h,p,n]}}const U4=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_-]*/}}),H4=["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"],W4=["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"],K4=[...H4,...W4],Z4=["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(),q4=["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(),G4=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),V4=["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 Y4(e){const t=e.regex,n=U4(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},s="and or not only",a=/@-?\w[\w]*(-\w+)*/,l="[a-zA-Z-][a-zA-Z0-9_-]*",c=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+l,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+q4.join("|")+")"},{begin:":(:)?("+G4.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+V4.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,n.UNICODE_RANGE,...c,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...c,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:a},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:Z4.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...c,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+K4.join("|")+")\\b"}]}}function Q4(e){const a={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:a,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:a,illegal:/["']/}]}]}}function X4(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 s={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},a={className:"literal",begin:/\bon|off|true|false|yes|no\b/},l={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},c={begin:/\[/,end:/\]/,contains:[r,a,s,l,n,"self"],relevance:0},u=/[A-Za-z0-9_-]+/,h=/"(\\"|[^"])*"/,p=/'[^']*'/,g=t.either(u,h,p),k=t.concat(g,"(\\s*\\.\\s*",g,")*",t.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:k,className:"attr",starts:{end:/$/,contains:[r,c,a,s,l,n]}}]}}const e0="[A-Za-z$_][0-9A-Za-z$_]*",J4=["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"],eD=["true","false","null","undefined","NaN","Infinity"],l_=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],c_=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],u_=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],tD=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],nD=[].concat(u_,l_,c_);function rD(e){const t=e.regex,n=(O,{after:F})=>{const ne="</"+O[0].slice(1);return O.input.indexOf(ne,F)!==-1},r=e0,s={begin:"<>",end:"</>"},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(O,F)=>{const ne=O[0].length+O.index,$=O.input[ne];if($==="<"||$===","){F.ignoreMatch();return}$===">"&&(n(O,{after:ne})||F.ignoreMatch());let q;const ke=O.input.substring(ne);if(q=ke.match(/^\s*=/)){F.ignoreMatch();return}if((q=ke.match(/^\s+extends\s+/))&&q.index===0){F.ignoreMatch();return}}},c={$pattern:e0,keyword:J4,literal:eD,built_in:nD,"variable.language":tD},u="[0-9](_?[0-9])*",h=`\\.(${u})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",g={className:"number",variants:[{begin:`(\\b(${p})((${h})|\\.)?|(${h}))[eE][+-]?(${u})\\b`},{begin:`\\b(${p})\\b((${h})\\b|\\.)?|(${h})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},k={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"xml"}},v={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"css"}},_={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"graphql"}},E={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,k]},x={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},N=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,v,_,E,{match:/\$\d+/},g];k.contains=N.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(N)});const M=[].concat(x,k.contains),J=M.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(M)}]),W={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:J},R={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},j={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:{_:[...l_,...c_]}},A={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},D={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[W],illegal:/%/},H={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function Y(O){return t.concat("(?!",O.join("|"),")")}const ae={match:t.concat(/\b/,Y([...u_,"super","import","await"].map(O=>`${O}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},me={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},ye={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},W]},_e="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",V={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(_e)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[W]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:J,CLASS_REFERENCE:j},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),A,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,v,_,E,x,{match:/\$\d+/},g,j,{scope:"attr",match:r+t.lookahead(":"),relevance:0},V,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[x,e.REGEXP_MODE,{className:"function",begin:_e,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:J}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:a},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},D,{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},me,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[W]},ae,H,R,ye,{match:/\$[(.]/}]}}const oD="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",sD={scope:"number",match:oD,relevance:0};function iD(e){const t={className:"attr",begin:/(("(\\.|[^\\"\r\n])*")|('(\\.|[^\\'\r\n])*'))(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],s={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,s,sD,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function aD(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={match:/^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/},s={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}]},a={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},l={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},c=/[A-Za-z][A-Za-z0-9+.-]*/,u={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,c,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},h={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},p={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},g=e.inherit(h,{contains:[]}),k=e.inherit(p,{contains:[]});h.contains.push(k),p.contains.push(g);let y=[n,u];return[h,p,g,k].forEach(C=>{C.contains=C.contains.concat(y)}),y=y.concat(h,p),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:y},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:y}]}]},n,a,r,h,p,{className:"quote",begin:"^>\\s+",contains:y,end:"$"},s,u,l,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function lD(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","lazy","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],c={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","aiter","all","anext","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozendict","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","sentinel","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},u={className:"meta",begin:/^(>>>|\.\.\.) /},h={className:"subst",begin:/\{/,end:/\}/,keywords:c,illegal:/#/},p={begin:/\{\{/,relevance:0},g={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,u,p,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u,p,h]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,p,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,p,h]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},k="[0-9](_?[0-9])*",y=`(\\b(${k}))?\\.(${k})|\\b(${k})\\.`,v=`\\b|${r.join("|")}`,_={className:"number",relevance:0,variants:[{begin:`(\\b(${k})|(${y}))[eE][+-]?(${k})[jJ]?(?=${v})`},{begin:`(${y})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${v})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${v})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${v})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${v})`},{begin:`\\b(${k})[jJ](?=${v})`}]},E={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:c,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},C={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:["self",u,_,g,e.HASH_COMMENT_MODE]}]};return h.contains=[g,_,u],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:c,illegal:/(<\/|\?)|=>/,contains:[u,_,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},g,E,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[C]},{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:[_,C,g]}]}}function cD(e){const t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),s=t.concat(n,e.IDENT_RE),a={scope:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!(?:let|for|while|if|else|match)\b)/,s,t.lookahead(/\s*\(/))},l="([ui](8|16|32|64|128|size)|f(16|32|64|128))?",c=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","raw","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],u=["true","false","Some","None","Ok","Err"],h=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],p=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f16","f32","f64","f128","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:p,keyword:c,literal:u,built_in:h},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{scope:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|"|\\|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{scope:"number",variants:[{begin:"\\b0b([01_]+)"+l},{begin:"\\b0o([0-7_]+)"+l},{begin:"\\b0x([A-Fa-f0-9_]+)"+l},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+l}],relevance:0},{begin:[/\bsafe/,/\s+/,/extern/],scope:{1:"keyword",3:"keyword"}},{begin:[/fn/,/\s+/,r],scope:{1:"keyword",3:"title.function"}},{scope:"meta",begin:"#!?\\[",end:"\\]",contains:[{scope:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],scope:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],scope:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],scope:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],scope:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:h,type:p}},{scope:"punctuation",begin:"->"},a]}}const ld="[A-Za-z$_][0-9A-Za-z$_]*",d_=["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"],f_=["true","false","null","undefined","NaN","Infinity"],p_=["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"],h_=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],m_=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],g_=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],k_=[].concat(m_,p_,h_);function uD(e){const t=e.regex,n=(O,{after:F})=>{const ne="</"+O[0].slice(1);return O.input.indexOf(ne,F)!==-1},r=ld,s={begin:"<>",end:"</>"},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(O,F)=>{const ne=O[0].length+O.index,$=O.input[ne];if($==="<"||$===","){F.ignoreMatch();return}$===">"&&(n(O,{after:ne})||F.ignoreMatch());let q;const ke=O.input.substring(ne);if(q=ke.match(/^\s*=/)){F.ignoreMatch();return}if((q=ke.match(/^\s+extends\s+/))&&q.index===0){F.ignoreMatch();return}}},c={$pattern:ld,keyword:d_,literal:f_,built_in:k_,"variable.language":g_},u="[0-9](_?[0-9])*",h=`\\.(${u})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",g={className:"number",variants:[{begin:`(\\b(${p})((${h})|\\.)?|(${h}))[eE][+-]?(${u})\\b`},{begin:`\\b(${p})\\b((${h})\\b|\\.)?|(${h})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},k={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"xml"}},v={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"css"}},_={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"graphql"}},E={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,k]},x={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},N=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,v,_,E,{match:/\$\d+/},g];k.contains=N.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(N)});const M=[].concat(x,k.contains),J=M.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(M)}]),W={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:J},R={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},j={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:{_:[...p_,...h_]}},A={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},D={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[W],illegal:/%/},H={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function Y(O){return t.concat("(?!",O.join("|"),")")}const ae={match:t.concat(/\b/,Y([...m_,"super","import","await"].map(O=>`${O}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},me={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},ye={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},W]},_e="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",V={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(_e)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[W]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:J,CLASS_REFERENCE:j},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),A,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,v,_,E,x,{match:/\$\d+/},g,j,{scope:"attr",match:r+t.lookahead(":"),relevance:0},V,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[x,e.REGEXP_MODE,{className:"function",begin:_e,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:J}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:a},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},D,{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},me,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[W]},ae,H,R,ye,{match:/\$[(.]/}]}}function dD(e){const t=e.regex,n=uD(e),r=ld,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],a={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},l={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:s},contains:[n.exports.CLASS_REFERENCE]},c={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},u=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],h={$pattern:ld,keyword:d_.concat(u),literal:f_,built_in:k_.concat(s),"variable.language":g_},p={className:"meta",begin:"@"+r},g=(_,E,C)=>{const x=_.contains.findIndex(N=>N.label===E);if(x===-1)throw new Error("can not find mode to replace");_.contains.splice(x,1,C)};Object.assign(n.keywords,h),n.exports.PARAMS_CONTAINS.push(p);const k=n.contains.find(_=>_.scope==="attr"),y=Object.assign({},k,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,k,y]),n.contains=n.contains.concat([p,a,l,y]),g(n,"shebang",e.SHEBANG()),g(n,"use_strict",c);const v=n.contains.find(_=>_.label==="func.def");return v.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function fD(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,s={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},a={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},l=e.inherit(a,{begin:/\(/,end:/\)/}),c=e.inherit(e.APOS_STRING_MODE,{className:"string"}),u=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),h={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[s]},{begin:/'/,end:/'/,contains:[s]},{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:[a,u,c,l,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[a,l,u,c]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[u]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[h],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:"css"}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[h],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:"javascript"}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:h}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function pD(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]|$)/}]},s={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},a={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,s]},c=e.inherit(l,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),k={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},y={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},v={begin:/\{/,end:/\}/,contains:[y],illegal:"\\n",relevance:0},_={begin:"\\[",end:"\\]",contains:[y],illegal:"\\n",relevance:0},E=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},k,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},v,_,a,l],C=[...E];return C.pop(),C.push(c),y.contains=C,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:E}}var Wp,t0;function hD(){if(t0)return Wp;t0=1;function e(U){return U instanceof Map?U.clear=U.delete=U.set=function(){throw new Error("map is read-only")}:U instanceof Set&&(U.add=U.clear=U.delete=function(){throw new Error("set is read-only")}),Object.freeze(U),Object.getOwnPropertyNames(U).forEach(de=>{const Ae=U[de],et=typeof Ae;(et==="object"||et==="function")&&!Object.isFrozen(Ae)&&e(Ae)}),U}class t{constructor(de){de.data===void 0&&(de.data={}),this.data=de.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(U){return U.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(U,...de){const Ae=Object.create(null);for(const et in U)Ae[et]=U[et];return de.forEach(function(et){for(const ee in et)Ae[ee]=et[ee]}),Ae}const s="</span>",a=U=>!!U.scope,l=(U,{prefix:de})=>{if(U.startsWith("language:"))return U.replace("language:","language-");if(U.includes(".")){const Ae=U.split(".");return[`${de}${Ae.shift()}`,...Ae.map((et,ee)=>`${et}${"_".repeat(ee+1)}`)].join(" ")}return`${de}${U}`};class c{constructor(de,Ae){this.buffer="",this.classPrefix=Ae.classPrefix,de.walk(this)}addText(de){this.buffer+=n(de)}openNode(de){if(!a(de))return;const Ae=l(de.scope,{prefix:this.classPrefix});this.span(Ae)}closeNode(de){a(de)&&(this.buffer+=s)}value(){return this.buffer}span(de){this.buffer+=`<span class="${de}">`}}const u=(U={})=>{const de={children:[]};return Object.assign(de,U),de};class h{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(de){this.top.children.push(de)}openNode(de){const Ae=u({scope:de});this.add(Ae),this.stack.push(Ae)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(de){return this.constructor._walk(de,this.rootNode)}static _walk(de,Ae){return typeof Ae=="string"?de.addText(Ae):Ae.children&&(de.openNode(Ae),Ae.children.forEach(et=>this._walk(de,et)),de.closeNode(Ae)),de}static _collapse(de){typeof de!="string"&&de.children&&(de.children.every(Ae=>typeof Ae=="string")?de.children=[de.children.join("")]:de.children.forEach(Ae=>{h._collapse(Ae)}))}}class p extends h{constructor(de){super(),this.options=de}addText(de){de!==""&&this.add(de)}startScope(de){this.openNode(de)}endScope(){this.closeNode()}__addSublanguage(de,Ae){const et=de.root;Ae&&(et.scope=`language:${Ae}`),this.add(et)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function g(U){return U?typeof U=="string"?U:U.source:null}function k(U){return _("(?=",U,")")}function y(U){return _("(?:",U,")*")}function v(U){return _("(?:",U,")?")}function _(...U){return U.map(Ae=>g(Ae)).join("")}function E(U){const de=U[U.length-1];return typeof de=="object"&&de.constructor===Object?(U.splice(U.length-1,1),de):{}}function C(...U){return"("+(E(U).capture?"":"?:")+U.map(et=>g(et)).join("|")+")"}function x(U){return new RegExp(U.toString()+"|").exec("").length-1}function N(U,de){const Ae=U&&U.exec(de);return Ae&&Ae.index===0}const M=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function J(U,{joinWith:de}){let Ae=0;return U.map(et=>{Ae+=1;const ee=Ae;let Se=g(et),be="";for(;Se.length>0;){const fe=M.exec(Se);if(!fe){be+=Se;break}be+=Se.substring(0,fe.index),Se=Se.substring(fe.index+fe[0].length),fe[0][0]==="\\"&&fe[1]?be+="\\"+String(Number(fe[1])+ee):(be+=fe[0],fe[0]==="("&&Ae++)}return be}).map(et=>`(${et})`).join(de)}const W=/\b\B/,R="[a-zA-Z]\\w*",j="[a-zA-Z_]\\w*",A="\\b\\d+(\\.\\d+)?",D="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",H="\\b(0b[01]+)",Y="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",ae=(U={})=>{const de=/^#![ ]*\//;return U.binary&&(U.begin=_(de,/.*\b/,U.binary,/\b.*/)),r({scope:"meta",begin:de,end:/$/,relevance:0,"on:begin":(Ae,et)=>{Ae.index!==0&&et.ignoreMatch()}},U)},me={begin:"\\\\[\\s\\S]",relevance:0},ye={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[me]},_e={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[me]},V={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/},O=function(U,de,Ae={}){const et=r({scope:"comment",begin:U,end:de,contains:[]},Ae);et.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 ee=C("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 et.contains.push({begin:_(/[ ]+/,"(",ee,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),et},F=O("//","$"),ne=O("/\\*","\\*/"),$=O("#","$"),q={scope:"number",begin:A,relevance:0},ke={scope:"number",begin:D,relevance:0},se={scope:"number",begin:H,relevance:0},ve={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[me,{begin:/\[/,end:/\]/,relevance:0,contains:[me]}]},Re={scope:"title",begin:R,relevance:0},le={scope:"title",begin:j,relevance:0},xe={begin:"\\.\\s*"+j,relevance:0};var oe=Object.freeze({__proto__:null,APOS_STRING_MODE:ye,BACKSLASH_ESCAPE:me,BINARY_NUMBER_MODE:se,BINARY_NUMBER_RE:H,COMMENT:O,C_BLOCK_COMMENT_MODE:ne,C_LINE_COMMENT_MODE:F,C_NUMBER_MODE:ke,C_NUMBER_RE:D,END_SAME_AS_BEGIN:function(U){return Object.assign(U,{"on:begin":(de,Ae)=>{Ae.data._beginMatch=de[1]},"on:end":(de,Ae)=>{Ae.data._beginMatch!==de[1]&&Ae.ignoreMatch()}})},HASH_COMMENT_MODE:$,IDENT_RE:R,MATCH_NOTHING_RE:W,METHOD_GUARD:xe,NUMBER_MODE:q,NUMBER_RE:A,PHRASAL_WORDS_MODE:V,QUOTE_STRING_MODE:_e,REGEXP_MODE:ve,RE_STARTERS_RE:Y,SHEBANG:ae,TITLE_MODE:Re,UNDERSCORE_IDENT_RE:j,UNDERSCORE_TITLE_MODE:le});function Z(U,de){U.input[U.index-1]==="."&&de.ignoreMatch()}function De(U,de){U.className!==void 0&&(U.scope=U.className,delete U.className)}function Ve(U,de){de&&U.beginKeywords&&(U.begin="\\b("+U.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",U.__beforeBegin=Z,U.keywords=U.keywords||U.beginKeywords,delete U.beginKeywords,U.relevance===void 0&&(U.relevance=0))}function ze(U,de){Array.isArray(U.illegal)&&(U.illegal=C(...U.illegal))}function it(U,de){if(U.match){if(U.begin||U.end)throw new Error("begin & end are not supported with match");U.begin=U.match,delete U.match}}function Je(U,de){U.relevance===void 0&&(U.relevance=1)}const en=(U,de)=>{if(!U.beforeMatch)return;if(U.starts)throw new Error("beforeMatch cannot be used with starts");const Ae=Object.assign({},U);Object.keys(U).forEach(et=>{delete U[et]}),U.keywords=Ae.keywords,U.begin=_(Ae.beforeMatch,k(Ae.begin)),U.starts={relevance:0,contains:[Object.assign(Ae,{endsParent:!0})]},U.relevance=0,delete Ae.beforeMatch},kt=["of","and","for","in","not","or","if","then","parent","list","value"],tn="keyword";function st(U,de,Ae=tn){const et=Object.create(null);return typeof U=="string"?ee(Ae,U.split(" ")):Array.isArray(U)?ee(Ae,U):Object.keys(U).forEach(function(Se){Object.assign(et,st(U[Se],de,Se))}),et;function ee(Se,be){de&&(be=be.map(fe=>fe.toLowerCase())),be.forEach(function(fe){const Pe=fe.split("|");et[Pe[0]]=[Se,X(Pe[0],Pe[1])]})}}function X(U,de){return de?Number(de):we(U)?0:1}function we(U){return kt.includes(U.toLowerCase())}const Qe={},he=U=>{console.error(U)},Oe=(U,...de)=>{console.log(`WARN: ${U}`,...de)},Mt=(U,de)=>{Qe[`${U}/${de}`]||(console.log(`Deprecated as of ${U}. ${de}`),Qe[`${U}/${de}`]=!0)},an=new Error;function vt(U,de,{key:Ae}){let et=0;const ee=U[Ae],Se={},be={};for(let fe=1;fe<=de.length;fe++)be[fe+et]=ee[fe],Se[fe+et]=!0,et+=x(de[fe-1]);U[Ae]=be,U[Ae]._emit=Se,U[Ae]._multi=!0}function Dn(U){if(Array.isArray(U.begin)){if(U.skip||U.excludeBegin||U.returnBegin)throw he("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),an;if(typeof U.beginScope!="object"||U.beginScope===null)throw he("beginScope must be object"),an;vt(U,U.begin,{key:"beginScope"}),U.begin=J(U.begin,{joinWith:""})}}function Lt(U){if(Array.isArray(U.end)){if(U.skip||U.excludeEnd||U.returnEnd)throw he("skip, excludeEnd, returnEnd not compatible with endScope: {}"),an;if(typeof U.endScope!="object"||U.endScope===null)throw he("endScope must be object"),an;vt(U,U.end,{key:"endScope"}),U.end=J(U.end,{joinWith:""})}}function ln(U){U.scope&&typeof U.scope=="object"&&U.scope!==null&&(U.beginScope=U.scope,delete U.scope)}function Tt(U){ln(U),typeof U.beginScope=="string"&&(U.beginScope={_wrap:U.beginScope}),typeof U.endScope=="string"&&(U.endScope={_wrap:U.endScope}),Dn(U),Lt(U)}function nn(U){function de(be,fe){return new RegExp(g(be),"m"+(U.case_insensitive?"i":"")+(U.unicodeRegex?"u":"")+(fe?"g":""))}class Ae{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(fe,Pe){Pe.position=this.position++,this.matchIndexes[this.matchAt]=Pe,this.regexes.push([Pe,fe]),this.matchAt+=x(fe)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const fe=this.regexes.map(Pe=>Pe[1]);this.matcherRe=de(J(fe,{joinWith:"|"}),!0),this.lastIndex=0}exec(fe){this.matcherRe.lastIndex=this.lastIndex;const Pe=this.matcherRe.exec(fe);if(!Pe)return null;const rt=Pe.findIndex((bt,cn)=>cn>0&&bt!==void 0),St=this.matchIndexes[rt];return Pe.splice(0,rt),Object.assign(Pe,St)}}class et{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(fe){if(this.multiRegexes[fe])return this.multiRegexes[fe];const Pe=new Ae;return this.rules.slice(fe).forEach(([rt,St])=>Pe.addRule(rt,St)),Pe.compile(),this.multiRegexes[fe]=Pe,Pe}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(fe,Pe){this.rules.push([fe,Pe]),Pe.type==="begin"&&this.count++}exec(fe){const Pe=this.getMatcher(this.regexIndex);Pe.lastIndex=this.lastIndex;let rt=Pe.exec(fe);if(this.resumingScanAtSamePosition()&&!(rt&&rt.index===this.lastIndex)){const St=this.getMatcher(0);St.lastIndex=this.lastIndex+1,rt=St.exec(fe)}return rt&&(this.regexIndex+=rt.position+1,this.regexIndex===this.count&&this.considerAll()),rt}}function ee(be){const fe=new et;return be.contains.forEach(Pe=>fe.addRule(Pe.begin,{rule:Pe,type:"begin"})),be.terminatorEnd&&fe.addRule(be.terminatorEnd,{type:"end"}),be.illegal&&fe.addRule(be.illegal,{type:"illegal"}),fe}function Se(be,fe){const Pe=be;if(be.isCompiled)return Pe;[De,it,Tt,en].forEach(St=>St(be,fe)),U.compilerExtensions.forEach(St=>St(be,fe)),be.__beforeBegin=null,[Ve,ze,Je].forEach(St=>St(be,fe)),be.isCompiled=!0;let rt=null;return typeof be.keywords=="object"&&be.keywords.$pattern&&(be.keywords=Object.assign({},be.keywords),rt=be.keywords.$pattern,delete be.keywords.$pattern),rt=rt||/\w+/,be.keywords&&(be.keywords=st(be.keywords,U.case_insensitive)),Pe.keywordPatternRe=de(rt,!0),fe&&(be.begin||(be.begin=/\B|\b/),Pe.beginRe=de(Pe.begin),!be.end&&!be.endsWithParent&&(be.end=/\B|\b/),be.end&&(Pe.endRe=de(Pe.end)),Pe.terminatorEnd=g(Pe.end)||"",be.endsWithParent&&fe.terminatorEnd&&(Pe.terminatorEnd+=(be.end?"|":"")+fe.terminatorEnd)),be.illegal&&(Pe.illegalRe=de(be.illegal)),be.contains||(be.contains=[]),be.contains=[].concat(...be.contains.map(function(St){return We(St==="self"?be:St)})),be.contains.forEach(function(St){Se(St,Pe)}),be.starts&&Se(be.starts,fe),Pe.matcher=ee(Pe),Pe}if(U.compilerExtensions||(U.compilerExtensions=[]),U.contains&&U.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return U.classNameAliases=r(U.classNameAliases||{}),Se(U)}function Ut(U){return U?U.endsWithParent||Ut(U.starts):!1}function We(U){return U.variants&&!U.cachedVariants&&(U.cachedVariants=U.variants.map(function(de){return r(U,{variants:null},de)})),U.cachedVariants?U.cachedVariants:Ut(U)?r(U,{starts:U.starts?r(U.starts):null}):Object.isFrozen(U)?r(U):U}var Gt="11.11.2";class pn extends Error{constructor(de,Ae){super(de),this.name="HTMLInjectionError",this.html=Ae}}const Kt=n,xn=r,hn=Symbol("nomatch"),mn=7,gn=function(U){const de=Object.create(null),Ae=Object.create(null),et=[];let ee=!0;const Se="Could not find the language '{}', did you forget to load/include a language module?",be={disableAutodetect:!0,name:"Plain text",contains:[]};let fe={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:p};function Pe(je){return fe.noHighlightRe.test(je)}function rt(je){let Ue=je.className+" ";Ue+=je.parentNode?je.parentNode.className:"";const yt=fe.languageDetectRe.exec(Ue);if(yt){const ft=In(yt[1]);return ft||(Oe(Se.replace("{}",yt[1])),Oe("Falling back to no-highlight mode for this block.",je)),ft?yt[1]:"no-highlight"}return Ue.split(/\s+/).find(ft=>Pe(ft)||In(ft))}function St(je,Ue,yt){let ft="",rn="";typeof Ue=="object"?(ft=je,yt=Ue.ignoreIllegals,rn=Ue.language):(Mt("10.7.0","highlight(lang, code, ...args) has been deprecated."),Mt("10.7.0",`Please use highlight(code, options) instead.
|
|
193
|
+
https://github.com/highlightjs/highlight.js/issues/2277`),rn=je,ft=Ue),yt===void 0&&(yt=!0);const Qt={code:ft,language:rn};dt("before:highlight",Qt);const B=Qt.result?Qt.result:bt(Qt.language,Qt.code,yt);return B.code=Qt.code,dt("after:highlight",B),B}function bt(je,Ue,yt,ft){const rn=Object.create(null);function Qt(L,te){return L.keywords[te]}function B(){if(!lt.keywords){yn.addText(Ht);return}let L=0;lt.keywordPatternRe.lastIndex=0;let te=lt.keywordPatternRe.exec(Ht),pe="";for(;te;){pe+=Ht.substring(L,te.index);const Ce=Jn.case_insensitive?te[0].toLowerCase():te[0],$e=Qt(lt,Ce);if($e){const[mt,Xt]=$e;if(yn.addText(pe),pe="",rn[Ce]=(rn[Ce]||0)+1,rn[Ce]<=mn&&(jr+=Xt),mt.startsWith("_"))pe+=te[0];else{const Nn=Jn.classNameAliases[mt]||mt;tt(te[0],Nn)}}else pe+=te[0];L=lt.keywordPatternRe.lastIndex,te=lt.keywordPatternRe.exec(Ht)}pe+=Ht.substring(L),yn.addText(pe)}function ue(){if(Ht==="")return;let L=null;if(typeof lt.subLanguage=="string"){if(!de[lt.subLanguage]){yn.addText(Ht);return}L=bt(lt.subLanguage,Ht,!0,Vo[lt.subLanguage]),Vo[lt.subLanguage]=L._top}else L=at(Ht,lt.subLanguage.length?lt.subLanguage:null);lt.relevance>0&&(jr+=L.relevance),yn.__addSublanguage(L._emitter,L.language)}function Fe(){lt.subLanguage!=null?ue():B(),Ht=""}function tt(L,te){L!==""&&(yn.startScope(te),yn.addText(L),yn.endScope())}function pt(L,te){let pe=1;const Ce=te.length-1;for(;pe<=Ce;){if(!L._emit[pe]){pe++;continue}const $e=Jn.classNameAliases[L[pe]]||L[pe],mt=te[pe];$e?tt(mt,$e):(Ht=mt,B(),Ht=""),pe++}}function jt(L,te){return L.scope&&typeof L.scope=="string"&&yn.openNode(Jn.classNameAliases[L.scope]||L.scope),L.beginScope&&(L.beginScope._wrap?(tt(Ht,Jn.classNameAliases[L.beginScope._wrap]||L.beginScope._wrap),Ht=""):L.beginScope._multi&&(pt(L.beginScope,te),Ht="")),lt=Object.create(L,{parent:{value:lt}}),lt}function vn(L,te,pe){let Ce=N(L.endRe,pe);if(Ce){if(L["on:end"]){const $e=new t(L);L["on:end"](te,$e),$e.isMatchIgnored&&(Ce=!1)}if(Ce){for(;L.endsParent&&L.parent;)L=L.parent;return L}}if(L.endsWithParent)return vn(L.parent,te,pe)}function qn(L){return lt.matcher.regexIndex===0?(Ht+=L[0],1):(I=!0,0)}function Gr(L){const te=L[0],pe=L.rule,Ce=new t(pe),$e=[pe.__beforeBegin,pe["on:begin"]];for(const mt of $e)if(mt&&(mt(L,Ce),Ce.isMatchIgnored))return qn(te);return pe.skip?Ht+=te:(pe.excludeBegin&&(Ht+=te),Fe(),!pe.returnBegin&&!pe.excludeBegin&&(Ht=te)),jt(pe,L),pe.returnBegin?0:te.length}function Hn(L){const te=L[0],pe=Ue.substring(L.index),Ce=vn(lt,L,pe);if(!Ce)return hn;const $e=lt;lt.endScope&<.endScope._wrap?(Fe(),tt(te,lt.endScope._wrap)):lt.endScope&<.endScope._multi?(Fe(),pt(lt.endScope,L)):$e.skip?Ht+=te:($e.returnEnd||$e.excludeEnd||(Ht+=te),Fe(),$e.excludeEnd&&(Ht=te));do lt.scope&&yn.closeNode(),!lt.skip&&!lt.subLanguage&&(jr+=lt.relevance),lt=lt.parent;while(lt!==Ce.parent);return Ce.starts&&jt(Ce.starts,L),$e.returnEnd?0:te.length}function ps(){const L=[];for(let te=lt;te!==Jn;te=te.parent)te.scope&&L.unshift(te.scope);L.forEach(te=>yn.openNode(te))}let Vr={};function Tr(L,te){const pe=te&&te[0];if(Ht+=L,pe==null)return Fe(),0;if(Vr.type==="begin"&&te.type==="end"&&Vr.index===te.index&&pe===""){if(Ht+=Ue.slice(te.index,te.index+1),!ee){const Ce=new Error(`0 width match regex (${je})`);throw Ce.languageName=je,Ce.badRule=Vr.rule,Ce}return 1}if(Vr=te,te.type==="begin")return Gr(te);if(te.type==="illegal"&&!yt){const Ce=new Error('Illegal lexeme "'+pe+'" for mode "'+(lt.scope||"<unnamed>")+'"');throw Ce.mode=lt,Ce}else if(te.type==="end"){const Ce=Hn(te);if(Ce!==hn)return Ce}if(te.type==="illegal"&&pe==="")return te.index===Ue.length||(Ht+=`
|
|
194
|
+
`),1;if(Ne>1e5&&Ne>te.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Ht+=pe,pe.length}const Jn=In(je);if(!Jn)throw he(Se.replace("{}",je)),new Error('Unknown language: "'+je+'"');const $r=nn(Jn);let Ot="",lt=ft||$r;const Vo={},yn=new fe.__emitter(fe);ps();let Ht="",jr=0,yr=0,Ne=0,I=!1;try{if(Jn.__emitTokens)Jn.__emitTokens(Ue,yn);else{for(lt.matcher.considerAll();;){Ne++,I?I=!1:lt.matcher.considerAll(),lt.matcher.lastIndex=yr;const L=lt.matcher.exec(Ue);if(!L)break;const te=Ue.substring(yr,L.index),pe=Tr(te,L);yr=L.index+pe}Tr(Ue.substring(yr))}return yn.finalize(),Ot=yn.toHTML(),{language:je,value:Ot,relevance:jr,illegal:!1,_emitter:yn,_top:lt}}catch(L){if(L.message&&L.message.includes("Illegal"))return{language:je,value:Kt(Ue),illegal:!0,relevance:0,_illegalBy:{message:L.message,index:yr,context:Ue.slice(yr-100,yr+100),mode:L.mode,resultSoFar:Ot},_emitter:yn};if(ee)return{language:je,value:Kt(Ue),illegal:!1,relevance:0,errorRaised:L,_emitter:yn,_top:lt};throw L}}function cn(je){const Ue={value:Kt(je),illegal:!1,relevance:0,_top:be,_emitter:new fe.__emitter(fe)};return Ue._emitter.addText(je),Ue}function at(je,Ue){Ue=Ue||fe.languages||Object.keys(de);const yt=cn(je),ft=Ue.filter(In).filter(qr).map(Fe=>bt(Fe,je,!1));ft.unshift(yt);const rn=ft.sort((Fe,tt)=>{if(Fe.relevance!==tt.relevance)return tt.relevance-Fe.relevance;if(Fe.language&&tt.language){if(In(Fe.language).supersetOf===tt.language)return 1;if(In(tt.language).supersetOf===Fe.language)return-1}return 0}),[Qt,B]=rn,ue=Qt;return ue.secondBest=B,ue}function Dt(je,Ue,yt){const ft=Ue&&Ae[Ue]||yt;je.classList.add("hljs"),je.classList.add(`language-${ft}`)}function un(je){let Ue=null;const yt=rt(je);if(Pe(yt))return;if(dt("before:highlightElement",{el:je,language:yt}),je.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",je);return}if(je.children.length>0&&(fe.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(je)),fe.throwUnescapedHTML))throw new pn("One of your code blocks includes unescaped HTML.",je.innerHTML);Ue=je;const ft=Ue.textContent,rn=yt?St(ft,{language:yt,ignoreIllegals:!0}):at(ft);je.innerHTML=rn.value,je.dataset.highlighted="yes",Dt(je,yt,rn.language),je.result={language:rn.language,re:rn.relevance,relevance:rn.relevance},rn.secondBest&&(je.secondBest={language:rn.secondBest.language,relevance:rn.secondBest.relevance}),dt("after:highlightElement",{el:je,result:rn,text:ft})}function zn(je){fe=xn(fe,je)}const An=()=>{cr(),Mt("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function lr(){cr(),Mt("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Rt=!1;function cr(){function je(){cr()}if(document.readyState==="loading"){Rt||window.addEventListener("DOMContentLoaded",je,!1),Rt=!0;return}document.querySelectorAll(fe.cssSelector).forEach(un)}function wn(je,Ue){let yt=null;try{yt=Ue(U)}catch(ft){if(he("Language definition for '{}' could not be registered.".replace("{}",je)),ee)he(ft);else throw ft;yt=be}yt.name||(yt.name=je),de[je]=yt,yt.rawDefinition=Ue.bind(null,U),yt.aliases&&oo(yt.aliases,{languageName:je})}function Xn(je){delete de[je];for(const Ue of Object.keys(Ae))Ae[Ue]===je&&delete Ae[Ue]}function Fn(){return Object.keys(de)}function In(je){return je=(je||"").toLowerCase(),de[je]||de[Ae[je]]}function oo(je,{languageName:Ue}){typeof je=="string"&&(je=[je]),je.forEach(yt=>{Ae[yt.toLowerCase()]=Ue})}function qr(je){const Ue=In(je);return Ue&&!Ue.disableAutodetect}function Vt(je){je["before:highlightBlock"]&&!je["before:highlightElement"]&&(je["before:highlightElement"]=Ue=>{je["before:highlightBlock"](Object.assign({block:Ue.el},Ue))}),je["after:highlightBlock"]&&!je["after:highlightElement"]&&(je["after:highlightElement"]=Ue=>{je["after:highlightBlock"](Object.assign({block:Ue.el},Ue))})}function Go(je){Vt(je),et.push(je)}function so(je){const Ue=et.indexOf(je);Ue!==-1&&et.splice(Ue,1)}function dt(je,Ue){const yt=je;et.forEach(function(ft){ft[yt]&&ft[yt](Ue)})}function Zn(je){return Mt("10.7.0","highlightBlock will be removed entirely in v12.0"),Mt("10.7.0","Please use highlightElement now."),un(je)}Object.assign(U,{highlight:St,highlightAuto:at,highlightAll:cr,highlightElement:un,highlightBlock:Zn,configure:zn,initHighlighting:An,initHighlightingOnLoad:lr,registerLanguage:wn,unregisterLanguage:Xn,listLanguages:Fn,getLanguage:In,registerAliases:oo,autoDetection:qr,inherit:xn,addPlugin:Go,removePlugin:so}),U.debugMode=function(){ee=!1},U.safeMode=function(){ee=!0},U.versionString=Gt,U.regex={concat:_,lookahead:k,either:C,optional:v,anyNumberOfTimes:y};for(const je in oe)typeof oe[je]=="object"&&e(oe[je]);return Object.assign(U,oe),U},kn=gn({});return kn.newInstance=()=>gn({}),Wp=kn,kn.HighlightJS=kn,kn.default=kn,Wp}var mD=hD();const gD=W0(mD),n0={},kD="hljs-";function yD(e){const t=gD.newInstance();return e&&a(e),{highlight:n,highlightAuto:r,listLanguages:s,register:a,registerAlias:l,registered:c};function n(u,h,p){const g=p||n0,k=typeof g.prefix=="string"?g.prefix:kD;if(!t.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");t.configure({__emitter:wD,classPrefix:k});const y=t.highlight(h,{ignoreIllegals:!0,language:u});if(y.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:y.errorRaised});const v=y._emitter.root,_=v.data;return _.language=y.language,_.relevance=y.relevance,v}function r(u,h){const g=(h||n0).subset||s();let k=-1,y=0,v;for(;++k<g.length;){const _=g[k];if(!t.getLanguage(_))continue;const E=n(_,u,h);E.data&&E.data.relevance!==void 0&&E.data.relevance>y&&(y=E.data.relevance,v=E)}return v||{type:"root",children:[],data:{language:void 0,relevance:y}}}function s(){return t.listLanguages()}function a(u,h){if(typeof u=="string")t.registerLanguage(u,h);else{let p;for(p in u)Object.hasOwn(u,p)&&t.registerLanguage(p,u[p])}}function l(u,h){if(typeof u=="string")t.registerAliases(typeof h=="string"?h:[...h],{languageName:u});else{let p;for(p in u)if(Object.hasOwn(u,p)){const g=u[p];t.registerAliases(typeof g=="string"?g:[...g],{languageName:p})}}}function c(u){return!!t.getLanguage(u)}}class wD{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],s=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:s}):r.children.push(...s)}openNode(t){const n=this,r=t.split(".").map(function(l,c){return c?l+"_".repeat(c):n.options.classPrefix+l}),s=this.stack[this.stack.length-1],a={type:"element",tagName:"span",properties:{className:r},children:[]};s.children.push(a),this.stack.push(a)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const y_=yD({bash:B4,css:Y4,go:Q4,ini:X4,javascript:rD,json:iD,markdown:aD,python:lD,rust:cD,typescript:dD,xml:fD,yaml:pD}),r0={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 Qm(e,t){const n=e&&(r0[e]??(y_.registered(e)?e:null));if(n)return n;const r=t.lastIndexOf("."),s=r<0?"":t.slice(r+1).toLowerCase();return(s?r0[s]:null)??null}const vD=/^(?:diff --git a\/\S+ b\/(\S+)|\+\+\+ (?:b\/)?(\S+))$/gm;function bD(e){const t=new Set;for(const n of e.matchAll(vD)){const r=n[1]??n[2]??"";r&&r!=="/dev/null"&&t.add(r)}return t.size===1?[...t][0]:""}const xD={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 w_(e,t){const n=[[]],r=(a,l)=>{const c=a.split(`
|
|
195
|
+
`);for(const[u,h]of c.entries()){if(u>0&&n.push([]),!h)continue;const p=n[n.length-1],g=p[p.length-1];g&&g.scope===l?g.text+=h:p.push({text:h,scope:l})}},s=(a,l)=>{for(const c of a)c.type==="text"?r(c.value,l):c.type==="element"&&s(c.children,_D(c)??l)};try{s(y_.highlight(t,e).children,"")}catch{return e.split(`
|
|
196
|
+
`).map(a=>a?[{text:a,scope:""}]:[])}return n}function _D(e){var r;const t=((r=e.properties)==null?void 0:r.className)??[];let n=null;for(const s of t){const a=xD[s.startsWith("hljs-")?s.slice(5):s];a&&(n=a)}return n}const o0=/^\d+\t/;function Xm(e,t){if(!t)return[];const n=e.split(`
|
|
197
|
+
`),r=o0.test(n[0]??""),s=r?n.map(l=>{var c;return((c=o0.exec(l))==null?void 0:c[0])??""}):[],a=r?n.map((l,c)=>l.slice(s[c].length)).join(`
|
|
198
|
+
`):e;return w_(a,t).map((l,c)=>{const u=l.map(p=>({text:p.text,changed:!1,scope:p.scope})),h=s[c];return h?[{text:h,changed:!1,scope:""},...u]:u})}function ED(e,t){var r;const n=new Array(e.length);if(t){let s=0;for(let a=0;a<=e.length;a++){const l=(r=e[a])==null?void 0:r.kind;a<e.length&&l!=="hunk"&&l!=="meta"||(SD(e,s,a,t,n),s=a+1)}}return e.map((s,a)=>ND(s.spans,n[a],s.text))}function SD(e,t,n,r,s){var a,l;for(const c of["del","add"]){const u=[];for(let g=t;g<n;g++){const k=(a=e[g])==null?void 0:a.kind;(k===""||k===c)&&u.push(g)}if(u.length===0)continue;const h=u.map(g=>{var k;return((k=e[g])==null?void 0:k.text)??""}).join(`
|
|
199
|
+
`),p=w_(h,r);for(const[g,k]of u.entries())(c==="add"||((l=e[k])==null?void 0:l.kind)==="del")&&(s[k]=p[g])}}function ND(e,t,n){if(!(e!=null&&e.length)&&!(t!=null&&t.length))return n?[{text:n,changed:!1,scope:""}]:[];const r=[],s=e!=null&&e.length?e:[{text:n,changed:!1}],a=t!=null&&t.length?t:[{text:n,scope:""}];let l=0,c=0,u=0,h=0;for(;l<s.length&&c<a.length;){const p=s[l],g=a[c],k=Math.min(p.text.length-u,g.text.length-h);if(k>0){const y={text:p.text.slice(u,u+k),changed:p.changed,scope:g.scope},v=r[r.length-1];v&&v.changed===y.changed&&v.scope===y.scope?v.text+=y.text:r.push(y)}u+=k,h+=k,u>=p.text.length&&(l++,u=0),h>=g.text.length&&(c++,h=0)}return r}on.use({extensions:[D4],renderer:{code({text:e,lang:t}){const n=Qm((t??"").trim().toLowerCase().split(/\s+/)[0]??"","");return n?`<pre><code>${Xm(e,n).map(s=>s.map(a=>a.scope?`<span class="sy-${a.scope}">${s0(a.text)}</span>`:s0(a.text)).join("")).join(`
|
|
200
|
+
`)}</code></pre>
|
|
201
|
+
`:!1},table:F4}});const s0=e=>e.replace(/[&<>]/g,t=>t==="&"?"&":t==="<"?"<":">"),v_=MP(window);let ss=null;v_.addHook("afterSanitizeAttributes",e=>{const t=e.tagName==="A"?e.getAttribute("href")??"":"";if(t===o_){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=ss!=null&&ss.fileRoot?i_(ss.fileRoot,t):null,r=n?null:a_(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 a=z4(e.textContent??"");a&&e.setAttribute("data-path",a)}const s=ss==null?void 0:ss.base;if(e.tagName==="IMG"&&s){const a=Ym(s.dir,e.getAttribute("src")??"");a&&e.setAttribute("src",Cm(s.worktreeId,a,s.version))}});function $l(e,t){ss=t??null;const n=t!=null&&t.streaming?$4(e):e;try{return v_.sanitize(on.parse(n,{async:!1}))}finally{ss=null}}function Jm(e,t){var p,g,k;const[n,r]=S.useState(()=>$l(e,t)),s=S.useRef(0),a=(p=t==null?void 0:t.base)==null?void 0:p.worktreeId,l=(g=t==null?void 0:t.base)==null?void 0:g.dir,c=(k=t==null?void 0:t.base)==null?void 0:k.version,u=t==null?void 0:t.fileRoot,h=t==null?void 0:t.streaming;return S.useEffect(()=>{const y=a!==void 0&&l!==void 0?{worktreeId:a,dir:l,version:c??null}:void 0,v=y||u||h?{base:y,fileRoot:u,streaming:h}:void 0,_=performance.now()-s.current;if(_>=100){s.current=performance.now(),r($l(e,v));return}const E=setTimeout(()=>{s.current=performance.now(),r($l(e,v))},100-_);return()=>clearTimeout(E)},[e,a,l,c,u,h]),n}const b_=e=>e.replace(/\n$/,""),TD=1500,i0=4;function x_(e){return e.closest(".md pre")}function Oh(e){const t=x_(e);return t?b_(t.textContent??""):null}function jD(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{pre:t,top:r.top-n.top+e.scrollTop+i0,right:n.left+e.clientLeft+e.clientWidth-r.right+i0}}function eg(e){const[t,n]=S.useState(null),[r,s]=S.useState(null);if(S.useEffect(()=>{const h=e.current;if(!h)return;const p=k=>{if(!(k.target instanceof Element)||k.target.closest(".code-copy"))return;const y=x_(k.target);n(y&&h.contains(y)?jD(h,y):null)},g=()=>n(null);return h.addEventListener("pointerover",p),h.addEventListener("pointerleave",g),()=>{h.removeEventListener("pointerover",p),h.removeEventListener("pointerleave",g)}},[e]),S.useEffect(()=>{if(!r)return;const h=setTimeout(()=>s(null),TD);return()=>clearTimeout(h)},[r]),!(t!=null&&t.pre.isConnected))return null;const{pre:a,top:l,right:c}=t,u=r===a;return f.jsx($t,{className:"code-copy",style:{top:l,right:c},icon:u?"check":"copy",label:u?"Copied":"Copy code",onClick:()=>{Bt(b_(a.textContent??"")),s(a)}})}function CD(e){return!e||e===document.body?!1:e.closest(".monaco-editor, .xterm")?!0:(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&!e.closest(".chat-input")}function __(e,t){gt([t],()=>{const s=requestAnimationFrame(()=>{var a;CD(document.activeElement)||(a=e.current)==null||a.focus()});return()=>cancelAnimationFrame(s)});const n=S.useRef(!1),r=S.useCallback(()=>{requestAnimationFrame(()=>{var s;document.activeElement===document.body&&((s=e.current)==null||s.focus())})},[e]);return S.useEffect(()=>{const s=()=>{n.current=!0},a=()=>{n.current=!1,r()};return window.addEventListener("pointerdown",s,!0),window.addEventListener("pointerup",a,!0),window.addEventListener("pointercancel",a,!0),()=>{window.removeEventListener("pointerdown",s,!0),window.removeEventListener("pointerup",a,!0),window.removeEventListener("pointercancel",a,!0)}},[r]),s=>{!s.relatedTarget&&!n.current&&r()}}function AD({item:e,worktreeId:t,rootRef:n,onAnswer:r}){return e.ask.kind==="question"?f.jsx(ID,{item:e,ask:e.ask,worktreeId:t,root:n,onAnswer:r}):f.jsx(RD,{item:e,ask:e.ask,worktreeId:t,root:n})}const E_=e=>e.length===1&&e>="1"&&e<="9",Sl=e=>e.key==="Enter"||e.key==="NumpadEnter";function ID({item:e,ask:t,worktreeId:n,root:r,onAnswer:s}){const a=__(r,e.id),l=ot(),c=ht(),{message:u,questions:h}=t,p=At(n,"ask"),g=S.useMemo(()=>(p==null?void 0:p.id)===e.id?p:{id:e.id,draft:u$(h),current:0},[p,e.id,h]),{draft:k,current:y}=g,v=y===Yu(h),_=h[y],E=k[y],C=!!(_!=null&&_.multi),[x,N]=S.useState(()=>ca(_,E)),M=Gs(),J=S.useRef(null),W=(O,F)=>c({a:"ask-draft",id:n,ask:{id:e.id,draft:O,current:F}}),R=O=>{if(!s)return l==null?void 0:l.send({t:"agent-answer",worktreeId:n,askId:e.id,...O?{answers:O}:{}});O&&s(O)},j=()=>c(s?{a:"ask-revive",id:n}:{a:"ask-park",id:n,askId:e.id}),A=()=>{gu(h,k)&&R(k)},D=O=>{N(ca(h[O],k[O])),W(k,O)},H=O=>{_!=null&&_.note&&(W(Iw(k,y,O,C),y),requestAnimationFrame(()=>{var F;return(F=J.current)==null?void 0:F.focus()}))},Y=()=>{if(!(_!=null&&_.note))return;const O=_.options[x];if(!O||C)return H(!O);W(Iw(Aw(k,y,O.value,!1),y,!1,!1),y),requestAnimationFrame(()=>{var F;return(F=J.current)==null?void 0:F.focus()})},ae=O=>{if(d$(_,O))return N(O),H(!0);const F=_==null?void 0:_.options[O];if(!_||!F)return;const ne=Aw(k,y,F.value,C);if(C){N(O),W(ne,y);return}const $=Ow(h,ne,y);N($.cursor),W(ne,$.current),$.send&&gu(h,ne)&&R(ne)},me=O=>{var F,ne;if(O.target instanceof HTMLTextAreaElement){if(O.key==="Escape"||O.key==="Tab"&&!O.shiftKey){O.preventDefault(),O.stopPropagation();const $=Rw(k,y);$!==k&&(W($,y),N(ca(_,$[y]))),(F=r.current)==null||F.focus()}else if(Sl(O)&&(O.metaKey||O.ctrlKey))O.preventDefault(),A();else if(Sl(O)&&!O.shiftKey){O.preventDefault();const $=Rw(k,y);if((ne=r.current)==null||ne.focus(),!pa($[y])){$!==k&&(W($,y),N(ca(_,$[y])));return}const q=Ow(h,$,y);N(q.cursor),W($,q.current),q.send&&gu(h,$)&&R($)}return}if(!Jb(O)){if(O.key==="Escape")return O.preventDefault(),O.stopPropagation(),j();if(Sl(O)&&(O.metaKey||O.ctrlKey))return O.preventDefault(),A();if(Sl(O)||O.key===" "&&C)return O.preventDefault(),v?A():ae(x);if(O.key==="ArrowUp"||O.key==="ArrowDown")return O.preventDefault(),_?N(Ma(x,O.key==="ArrowUp"?-1:1,rx(_))):void 0;if(O.key==="ArrowLeft"||O.key==="ArrowRight"||O.key==="Tab"){O.preventDefault();const $=O.key==="ArrowLeft"||O.key==="Tab"&&O.shiftKey;return D(h$(y,$?-1:1,g$(h)))}if(O.key==="n"&&(_!=null&&_.note))return O.preventDefault(),Y();if(O.key==="s"&&!s)return O.preventDefault(),R();if(E_(O.key)){const $=v?Number(O.key)<=h.length?Number(O.key)-1:-1:p$(_,Number(O.key));return $===-1?void 0:(O.preventDefault(),v?D($):ae($))}}},ye=O=>h.length===1&&!O.multi,_e=(O,F)=>f.jsxs("div",{className:"ask-foot",children:[(!O||!ye(O)||M&&(F==null?void 0:F.note)!==void 0)&&f.jsx(Be,{variant:"outline",size:"md",disabled:!gu(h,k),onClick:A,children:"send"}),(O==null?void 0:O.note)&&F&&F.selected.length>0&&F.note===void 0&&f.jsxs(Be,{tone:"quiet",size:"md",onClick:()=>H(!1),children:[f.jsx(Or,{k:"n",chip:!0}),"add a note"]}),!s&&f.jsxs(Be,{tone:"quiet",size:"md",onClick:()=>R(),children:[f.jsx(Or,{k:"s",chip:!0}),"skip"]})]}),V=(O,F)=>{const ne=F===y,$=k[F],q=ox($,!!O.multi),ke=ne?O.options[x]:void 0,se=Yn({cursor:ne&&!M&&x===O.options.length,checked:q}),ve=()=>x!==O.options.length&&N(O.options.length),Re=xe=>f.jsx(Ea,{ref:ne?J:void 0,bare:!0,font:"ui",rows:1,className:"ask-own-field",placeholder:xe,value:($==null?void 0:$.note)??"",onChange:Le=>W(nx(k,F,Le.target.value),F)}),le=xe=>{var Le;xe.target instanceof HTMLTextAreaElement||(xe.preventDefault(),(Le=xe.currentTarget.querySelector("textarea"))==null||Le.focus())};return f.jsxs("div",{className:Ke("ask-page",!ne&&"ask-page-off"),children:[f.jsx("div",{className:"ask-head",children:f.jsx("div",{className:"ask-text",children:O.text||u})}),f.jsxs("div",{className:"ask-options",children:[O.options.map((xe,Le)=>{const oe=$==null?void 0:$.selected.includes(xe.value),Z=Yn({cursor:ne&&!M&&Le===x,checked:oe}),De=()=>Le!==x&&N(Le),Ve=f.jsxs(f.Fragment,{children:[f.jsx(Or,{k:String(Le+1),className:"ask-num row-dim"}),f.jsxs("span",{className:"ask-label",children:[lx(xe.label),k$(xe.label)&&f.jsx("span",{className:"badge-recommended",children:"recommended"})]}),!M&&O.note&&!O.multi&&f.jsxs("span",{className:Ke("ask-hint row-dim",ne&&Le===x&&($==null?void 0:$.note)===void 0&&"on"),children:[f.jsx(Or,{k:"n"})," add a note"]}),xe.description&&f.jsx("span",{className:"ask-desc row-dim",children:xe.description})]});return oe&&!q&&($==null?void 0:$.note)!==void 0?f.jsxs("div",{className:"picker-item ask-opt row-edge","data-state":Z,onMouseMove:De,onMouseDown:le,children:[Ve,Re("a note for the agent, sent with your pick")]},xe.value):f.jsx("button",{type:"button",className:"picker-item ask-opt row-edge","data-state":Z,onMouseMove:De,onClick:()=>{var ze;ae(Le),(ze=r.current)==null||ze.focus()},children:Ve},xe.value)}),O.note&&!q&&f.jsxs("button",{type:"button",className:"picker-item ask-opt row-edge","data-state":se,onMouseMove:ve,onClick:()=>ae(O.options.length),children:[f.jsx(Or,{k:String(O.options.length+1),className:"ask-num row-dim"}),f.jsx("span",{className:"ask-label",children:O.note.label}),f.jsx("span",{className:"ask-desc row-dim",children:"your own answer"})]}),O.note&&q&&($==null?void 0:$.note)!==void 0&&f.jsxs("div",{className:"picker-item ask-opt row-edge","data-state":se,onMouseMove:ve,onMouseDown:le,children:[f.jsx(Or,{k:String(O.options.length+1),className:"ask-num row-dim"}),f.jsx("span",{className:"ask-label",children:O.note.label}),Re("your own answer")]})]}),(ke==null?void 0:ke.preview)&&f.jsx("pre",{className:"ask-preview",children:ke.preview}),_e(O,$)]},O.id)};return f.jsxs("div",{ref:r,className:"ask-box",tabIndex:-1,onKeyDown:me,onBlur:a,children:[h.length>1&&f.jsx("div",{className:"ask-tabs",children:f.jsx(Dd,{label:"questions",owner:"ask",items:[...h.map((O,F)=>({id:String(F),label:O.header||`question ${F+1}`,lead:f.jsx("span",{className:Ke("dot ask-step",pa(k[F])&&"answered")})})),{id:String(h.length),label:"send",far:!0}],current:String(y),onPick:O=>{var F;D(Number(O)),(F=r.current)==null||F.focus()}})}),f.jsxs("div",{className:"ask-pages",children:[h.map(V),Yu(h)!==-1&&f.jsxs("div",{className:Ke("ask-page",!v&&"ask-page-off"),children:[f.jsx("div",{className:"ask-head",children:f.jsx("div",{className:"ask-text",children:"Send these answers?"})}),f.jsx("div",{className:"ask-options",children:h.map((O,F)=>{const ne=pa(k[F]);return f.jsxs("button",{type:"button",className:"picker-item ask-opt ask-sum",onClick:()=>{var $;D(F),($=r.current)==null||$.focus()},children:[f.jsx(Or,{k:String(F+1),className:"ask-num row-dim"}),f.jsxs("span",{className:"ask-label",children:[f.jsx("span",{className:"row-dim",children:O.header||`question ${F+1}`})," ",f.jsx("span",{className:Ke(!ne&&"row-dim"),children:ne?sx(O,k[F]):"no answer yet"})]})]},O.id)})}),_e()]})]})]})}function RD({item:e,ask:t,worktreeId:n,root:r}){const s=__(r,e.id),a=ot(),l=ht(),c=P(x=>x.activeId),[u,h]=S.useState(0),p=Gs(),g=t.plan,k=S.useMemo(()=>t.detail&&!g?$l(t.detail):"",[t.detail,g]),y=S.useRef(null),v=eg(y),_=()=>{g&&c===n&&Vn({dispatch:l},{worktreeId:n,path:g,view:"preview",focus:!1})};gt([e.id,g],_);const E=x=>{const N=t.choices[x];N&&(a==null||a.send({t:"agent-decide",worktreeId:n,askId:e.id,choiceId:N.id}))},C=x=>{if(!Jb(x)){if(x.key==="Escape")return x.preventDefault(),x.stopPropagation(),l({a:"ask-park",id:n,askId:e.id});if(Sl(x))return x.preventDefault(),E(u);if(x.key==="ArrowUp"||x.key==="ArrowDown")return x.preventDefault(),h(Ma(u,x.key==="ArrowUp"?-1:1,t.choices.length));E_(x.key)&&t.choices[Number(x.key)-1]&&(x.preventDefault(),E(Number(x.key)-1))}};return f.jsxs("div",{ref:r,className:"ask-box",tabIndex:-1,onKeyDown:C,onBlur:s,children:[f.jsx("div",{className:"ask-head",children:f.jsx("div",{className:"ask-text",children:t.title})}),k&&f.jsxs("div",{ref:y,className:"ask-detail md",children:[f.jsx("div",{dangerouslySetInnerHTML:{__html:k}}),v]}),f.jsx("div",{className:"ask-options",children:t.choices.map((x,N)=>f.jsxs("button",{type:"button",className:Ke("picker-item ask-opt row-edge",x.kind.startsWith("reject")&&"deny"),"data-state":Yn({cursor:!p&&N===u}),onMouseMove:()=>N!==u&&h(N),onClick:()=>E(N),children:[f.jsx(Or,{k:String(N+1),className:"ask-num row-dim"}),f.jsx("span",{className:"ask-label",children:x.name})]},x.id))})]})}const OD={skipped:"you skipped this",cancelled:"the turn was stopped before you answered",expired:"Toyon restarted before you answered"};function $D({item:e}){if(!e.outcome)return null;const t=OD[e.outcome];if(e.ask.kind==="permission"){const{title:n,choices:r}=e.ask,s=r.find(a=>a.id===e.choiceId);return f.jsxs("div",{className:"ask-closed",children:[!e.toolId&&f.jsx("div",{className:"ask-lead",children:n}),f.jsx("div",{className:"ask-answered",children:s?s.name:t??"closed"})]})}return f.jsxs("div",{className:"ask-closed",children:[f.jsx("div",{className:"ask-lead",children:e.ask.message}),f.jsx("div",{className:"ask-answered",children:t??"closed"})]})}const MD=e=>e.t==="open-path"||e.t==="open-loose",ua=new Map,LD=16;function PD({sock:e,dispatch:t},n,r){const s=Io();ua.set(s,{worktreeId:n,href:r.href});for(const a of ua.keys()){if(ua.size<=LD)break;ua.delete(a)}t({a:"link-refused",id:n,v:null}),e==null||e.send({t:"open-by-path",path:r.path,seq:s})}function DD(e,t){const n=ua.get(t.seq);n&&(ua.delete(t.seq),e.dispatch({a:"link-refused",id:n.worktreeId,v:{href:n.href,message:t.message}}))}function zD(e,t,n){var a;const r=e.getState();if(n.t==="open-path"){const l={dispatch:u=>e.dispatch(u)};if(cs(r,n.worktreeId)){r.activeId!==n.worktreeId&&e.dispatch({a:"activate",id:n.worktreeId}),Vn(l,{worktreeId:n.worktreeId,path:n.path});return}const c=Object.keys(r.trunks).find(u=>{var h;return((h=r.trunks[u])==null?void 0:h.id)===n.worktreeId});if(!c)return;if(((a=cs(r,r.activeId))==null?void 0:a.repoId)!==c){const u=r.rows.find(h=>h.repoId===c);if(!u)return;e.dispatch({a:"activate",id:u.id})}Vn(l,{worktreeId:n.worktreeId,path:n.path});return}const s=r.activeId;if(!s){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:s,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:Io()}})}function tg(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 s=n.getAttribute("href");if(!s)return null;const a=t?i_(t,s):null;if(a)return{kind:"file",file:a};const l=a_(s);return l?{kind:"outside",href:s,...l}:{kind:"out",href:s}}function ng(e,t,n,r){const s=tg(e.target,t);if((s==null?void 0:s.kind)==="outside"&&n){e.preventDefault(),PD(r,n,s);return}if((s==null?void 0:s.kind)!=="file"||!n)return;const a=s.file;if(e.preventDefault(),a.folder){K2(r,{worktreeId:n,path:a.path});return}Vn(r,{worktreeId:n,path:a.path,...a.line?{line:{n:a.line}}:{}})}const FD=150,BD=e=>({side:e,align:"center",offset:12,flip:"side",margin:8});function S_({chip:e,className:t,children:n}){const[r,s]=S.useState(!1),a=P(c=>c.chatSide);S.useEffect(()=>{const c=e.current;if(!c)return;let u=0;const h=()=>{window.clearTimeout(u),s(!1)},p=()=>{window.clearTimeout(u),u=window.setTimeout(()=>s(!0),FD)};return c.addEventListener("mouseenter",p),c.addEventListener("mouseleave",h),c.addEventListener("mousedown",h),()=>{window.clearTimeout(u),c.removeEventListener("mouseenter",p),c.removeEventListener("mouseleave",h),c.removeEventListener("mousedown",h)}},[e]);const l=()=>{var p;const c=e.current;if(!c)return null;const u=c.getBoundingClientRect(),h=((p=c.closest(".chat-log"))==null?void 0:p.getBoundingClientRect())??u;return{left:h.left,right:h.right,top:u.top,bottom:u.bottom}};return r?f.jsx(Vs,{className:Ke("chip-peek",t),anchor:l,placement:BD(a==="left"?"right":"left"),track:!0,children:n}):null}function rg({className:e,label:t,tip:n,peek:r,full:s,menu:a,removeLabel:l,onRemove:c}){const u=S.useRef(null),[h,p]=S.useState(!1),g=Jt("chat"),k=s!==void 0;return f.jsxs("div",{ref:u,className:Ke("pick-chip row row-sm",e),"data-tip":k?"Open full size":n,"data-tip-placement":"follow",...g.contextMenu(()=>a({open:k?()=>p(!0):void 0,remove:c})),children:[k?f.jsx("button",{type:"button",className:"chip-link",onClick:()=>p(!0),children:t}):t,c&&f.jsx($t,{icon:"close",label:l,tone:"quiet",onClick:c}),k&&r!==void 0&&f.jsx(S_,{chip:u,children:r}),h&&k&&f.jsx(Bm,{owner:"chat",onClose:()=>p(!1),menu:()=>a(),children:s})]})}const UD=/^ {0,3}(`{3,}|~{3,})/,HD=/^#{1,6} \S/,WD=/^\s*(?:[-*+]|\d+[.)]) \S/,KD=/^> ?\S/,ZD=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/,qD=/\[[^\]\n]+\]\((?:https?:|\.{0,2}\/|#)[^)\s]*\)/,GD=/\*\*[^\s*][^*\n]*\*\*/;function VD(e){var a,l;const t=e.split(`
|
|
202
|
+
`),n=new Set;let r=null,s=0;for(let c=0;c<t.length;c++){const u=t[c],h=(a=UD.exec(u))==null?void 0:a[1];if(r){h!=null&&h.startsWith(r)&&(r=null,n.add("fence"));continue}if(h){r=h;continue}HD.test(u)&&!((l=t[c+1])!=null&&l.trim())&&n.add("heading"),WD.test(u)&&++s===2&&n.add("list"),KD.test(u)&&n.add("quote"),ZD.test(u)&&n.add("table"),qD.test(u)&&n.add("link"),GD.test(u)&&n.add("bold")}return n.size}function YD(e,t){if(t)return Cd(t)==="markdown"?"rendered":"plain";const n=VD(e);return n>=2?"rendered":n===1?"source":"plain"}function og({n:e,name:t,source:n,lines:r,chars:s,preview:a,text:l,href:c,onRemove:u,className:h=""}){const p=(n==null?void 0:n.path)??t??"",g=p.includes("/")?p.slice(0,p.lastIndexOf("/")):"",k=n?[g,n.ref?`at ${n.ref.slice(0,7)}`:""].filter(Boolean).join(" "):[g,`${r} ${r===1?"line":"lines"}`,`${s.toLocaleString()} chars`,a].filter(Boolean).join(" · "),y=f.jsxs(f.Fragment,{children:[f.jsx(Et,{name:"text",className:"icon-inline"}),f.jsxs("span",{className:"pick-target",children:[f.jsx("b",{children:t?t.slice(t.lastIndexOf("/")+1):n?YR(n):V0("paste",e)}),k&&f.jsxs("span",{className:"pick-file row-dim",children:[" · ",k]})]})]}),v=l!==void 0||c!==void 0;return f.jsx(rg,{className:Ke("paste-chip",h),label:y,tip:a||void 0,peek:v?f.jsx(j_,{text:l,href:c}):void 0,full:v?f.jsx(T_,{text:l,href:c,path:p||void 0}):void 0,menu:_=>H1({text:l,href:c},_),removeLabel:"Remove attachment",onRemove:u})}function N_(e,t){const[n,r]=S.useState(e??null),[s,a]=S.useState(!1);return S.useEffect(()=>{if(e!==void 0||!t)return;let l=!0;return fetch(t).then(c=>c.ok?c.text():Promise.reject(new Error(String(c.status)))).then(c=>{l&&r(c)}).catch(()=>{l&&a(!0)}),()=>{l=!1}},[e,t]),{text:e??n,failed:s}}function T_({text:e,href:t,path:n}){const{text:r,failed:s}=N_(e,t),a=S.useMemo(()=>r?YD(r,n):"plain",[r,n]),[l,c]=S.useState(null);if(s)return f.jsx("p",{className:"paste-full hint",children:"Toyon could not read that back."});if(!r||a==="plain")return f.jsx("pre",{className:"paste-full paste-text",children:r});const u=l??a==="rendered";return f.jsxs("div",{className:"paste-full paste-doc",children:[f.jsx("div",{className:"paste-doc-head",children:f.jsxs(Be,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>c(!u),"data-tip":u?"Text: read it as it was sent":"Preview: read it rendered",children:[f.jsx(Et,{name:u?"text":"book",className:"icon-inline"})," ",u?"text":"preview"]})}),u?f.jsx(QD,{text:r}):f.jsx("pre",{className:"paste-doc-body paste-text",children:r})]})}function QD({text:e}){const t=S.useMemo(()=>$l(e),[e]);return f.jsx("div",{className:"paste-doc-body md md-preview",onClick:n=>{const r=n.target.closest("a");r&&r.target!=="_blank"&&n.preventDefault()},dangerouslySetInnerHTML:{__html:t}})}const XD=2e4;function j_({text:e,href:t}){const{text:n}=N_(e,t);return n?f.jsx("pre",{className:"paste-peek paste-text",children:n.slice(0,XD)}):null}function sg({name:e,bytes:t,href:n,uploading:r,onRemove:s,className:a=""}){return f.jsx(rg,{className:Ke("file-chip",a),label:f.jsxs(f.Fragment,{children:[f.jsx(Et,{name:"file",className:"icon-inline"}),f.jsxs("span",{className:"pick-target",children:[f.jsx("b",{children:e}),f.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",nm(t),r&&" · uploading"]})]})]}),tip:e,peek:n?f.jsx(j_,{href:n}):void 0,full:n?f.jsx(T_,{href:n,path:e}):void 0,menu:l=>H1({href:n},l),removeLabel:"Remove attachment",onRemove:s})}function C_(e){return e.replace(/^([\t ]*)\*\*(\S(?:[^\n]*\S)?)\*\*([\t ]*)$/gm,"$1$2$3")}const A_=120,JD=/^\*\*(\S(?:[^\n]*\S)?)\*\*$/;function I_(e){var n,r;const t=[];for(const s of e.split(/\n[\t ]*\n/)){const a=s.trim();if(!a)continue;const l=((r=(n=JD.exec(a))==null?void 0:n[1])==null?void 0:r.replace(/`/g,""))??"";if(!l||l.length>A_)return[];t.push(l)}return t}function R_(e){const t=I_(e);if(t.length)return t.at(-1);const n=C_(e).trim().replace(/`/g,"");return n&&!n.includes(`
|
|
203
|
+
`)&&n.length<=A_?n:""}const ez={read:"read",edit:"edit",delete:"delete",move:"move",search:"search",execute:"run",think:"think",fetch:"fetch",switch_mode:"mode",other:"tool"},a0={read:"book",edit:"edit",delete:"trash",move:"move",search:"search",execute:"run",think:"bulb",fetch:"globe",switch_mode:"swap",other:"dot"},l0=new Map([[pm,"chat"],["Monitor","clock"],["TaskOutput","terminal"],["Skill","layers"]]),c0={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"},tz=/(^|\s)(-[A-Za-z]*[iI]|--in-place)/,nz=String.raw`(?:"[^"]*"|'[^']*'|[^\s;&|]+)`,u0=new RegExp(String.raw`^\s*(?:(?:cd|echo)\s+${nz}\s*(?:&&|;)|(?:export\s+)?[A-Za-z_]\w*=(?:"[^"]*"|'[^']*'|[^\s;&|()\`]*)\s*(?:&&|;|(?=\s)))\s*`),rz=/^python[\d.]*$/,oz=new RegExp(`open\\([^)]*,\\s*["'][wax]|(?<!std(?:out|err))\\.write\\(|\\.write_text\\(`);function sz(e){let t=e;for(let n=t.replace(u0,"");n!==t;n=t.replace(u0,""))t=n;return t}const iz=new RegExp("(?<![0-9&])>{1,2}\\s*(?!\\/dev\\/null|&)[^\\s&>]");function az(e){const t=sz(e).trim(),n=t.split(/\s+/)[0]??"",r=n.slice(n.lastIndexOf("/")+1),s=r==="sed"?tz.test(e)?void 0:"book":c0[r];if(s==="book"||s==="search"){const a=t.split(/&&|;|\n|\|/)[0]??"";if(iz.test(a))return r==="cat"&&a.includes("<<")?"edit":void 0}return s||(rz.test(r)?t.includes("<<")&&oz.test(t)?"edit":void 0:c0[r])}function Ho(e,t){const n=e.input,r=n?n[t]:void 0;return typeof r=="string"?r:""}const lz=/^(?:\/(?:usr\/)?bin\/)?(?:ba|z|da)?sh\s+(?:-[a-zA-Z]+\s+)*(?:'([^']*)'|"((?:[^"\\]|\\.)*)")\s*$/;function cz(e){const t=lz.exec(e.trim());return t?t[1]!==void 0?t[1]:(t[2]??"").replace(/\\(["\\$`])/g,"$1"):e}const uz="Guardian Review";function O_(e){return e.toolKind==="think"&&e.title===uz}function dz(e){const t=s=>{var l,c;return((c=(l=[...e.matchAll(new RegExp(`^${s}:[ \\t]*(.+)$`,"gm"))].at(-1))==null?void 0:l[1])==null?void 0:c.trim().toLowerCase())??""},n=t("Status"),r=t("Risk");return!n||n==="in progress"?"reviewing":r?`${n}, ${r} risk`:n}function ql(e,t=[]){const n=cz(Ho(e,"command")),s=$_(e)||n||Ho(e,"path")||Ho(e,"pattern")||(e.title&&e.title!==e.name?e.title:""),a=ig(Ho(e,"description")||s,t),l=e.toolKind&&e.toolKind in a0?e.toolKind:"other",c=ez[l],u=e.name===pm,h=(l!=="other"||u)&&e.name!==cO,p=a&&(h||e.name===e.title||e.name===Aa||e.name===Kb)?"":e.name,g=p&&p.toLowerCase()!==c?p:a?"":c,k=(l==="execute"||l==="other")&&n?az(n):void 0;return{label:u?"ask":c,name:g,icon:l0.get(e.name)??l0.get(e.title??"")??k??a0[l],hint:a===g?"":a,command:n&&n!==a?n:""}}const fz=/^Async agent launched/m;function pz(e){if(!e.subagent)return!1;const t=e.input;return!!e.detached||(t==null?void 0:t.run_in_background)===!0||!!e.output&&fz.test(e.output)}const hz={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 mz(e){const t=e.toolKind;return gd(e.input)?e.subagent?"writing the brief":e.name===pm?"writing the question":Jh(t)?hz[t]:"":""}function $h(e,t){const n=M_(t),r=n[0],s=Ho(e,"description");return s&&r&&!r.code&&r.text===s?n.slice(1):n}function Ud(e){return $_(e)||Ho(e,"path")}function gz(e){return Ho(e,"description")}function $_(e){return Ho(e,"file_path")||Ho(e,"filepath")||Ho(e,"filePath")||kz(e)}function kz(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 ig(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 yz=/^(`{3,})([\w+#.-]*)\s*$/;function M_(e){var c;const t=[];let n=[],r="",s=!1,a=0;const l=()=>{const u=n.join(`
|
|
204
|
+
`).replace(/^\n+|\n+$/g,"");u.trim()&&t.push({code:s,diff:wz(u,r),lang:s?r:"",text:u}),n=[]};for(const u of e.split(`
|
|
205
|
+
`)){const h=yz.exec(u),p=((c=h==null?void 0:h[1])==null?void 0:c.length)??0;if(!h||s&&(p<a||h[2])){n.push(u);continue}l(),s=!s,a=s?p:0,r=s?(h[2]??"").toLowerCase():""}return l(),t}function wz(e,t){return t==="diff"||t==="patch"||/^diff --git /m.test(e)||/^@@ .*@@/m.test(e)?!0:/^--- /m.test(e)&&/^[+-]/m.test(e)}const vz=/^(diff --git |index [0-9a-f]+\.\.|new file mode |deleted file mode |similarity index |rename (from|to) |Binary files )/;function bz(e){const t=[];for(const n of e.split(`
|
|
206
|
+
`)){const r=_z(n);if(r==="meta"&&!n.startsWith("diff --git "))continue;const s=r==="add"||r==="del"||n.startsWith(" ");t.push({kind:r,text:s?n.slice(1):n})}return xz(t),t}function xz(e){var t,n,r,s;for(let a=0;a<e.length;){if(((t=e[a])==null?void 0:t.kind)!=="del"&&((n=e[a])==null?void 0:n.kind)!=="add"){a++;continue}let l=a;for(;((r=e[l])==null?void 0:r.kind)==="del";)l++;let c=l;for(;((s=e[c])==null?void 0:s.kind)==="add";)c++;const u=e.slice(a,l),h=e.slice(l,c),p=u.length>0&&h.length>0?fT(u.map(g=>g.text).join(`
|
|
207
|
+
`),h.map(g=>g.text).join(`
|
|
208
|
+
`)):null;p&&(d0(u,Ly(p.before)),d0(h,Ly(p.after)));for(const g of[...u,...h])g.spans??(g.spans=[]);a=c}}function d0(e,t){if(t.length===e.length)for(const[n,r]of e.entries())r.spans=t[n]}function _z(e){return e.startsWith("@@")?"hunk":e.startsWith("+++")||e.startsWith("---")||vz.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":""}function Ez(e){const t=e.tools.at(-1);return!!t.background&&!t.done&&!t.parentToolId&&t.name!==Aa}const L_=new Set(["read","edit","fetch"]);function P_(e,t){if(e.isError||!e.toolKind||!L_.has(e.toolKind)||Jh(e.toolKind)&&gd(e.input))return"";const{hint:n}=ql(e,t);return n?`${e.parentToolId??""}
|
|
209
|
+
${e.toolKind}
|
|
210
|
+
${e.name}
|
|
211
|
+
${n}`:""}function f0(e,t,n){if(!t||!("tools"in t)||e.done||e.isError||!e.toolKind||!L_.has(e.toolKind))return!1;const r=t.tools[0];return r.toolKind===e.toolKind&&r.name===e.name&&r.parentToolId===e.parentToolId&&P_(r,n)!==""}function D_(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 Sz(e){return e.done&&!e.output&&!e.isError&&Jh(e.toolKind)&&gd(e.input)}function Nz(e,t){const n=D_(e),r=[],s=new Map;let a="";for(const[l,c]of e.entries()){if(c.kind!=="tool"){a="",r.push({at:l,item:c});continue}if(Sz(c))continue;if(n.has(c.id)){a="";const g={at:l,spawn:c,run:[],end:l};s.set(c.id,{entry:g,key:""}),r.push(g);continue}const u=P_(c,t),h=c.parentToolId?s.get(c.parentToolId):void 0;if(h){const g=h.entry.run,k=g.at(-1);u&&u===h.key&&k?k.tools.push(c):!u&&f0(c,k,t)?k.next=c:g.push({at:l,tools:[c]}),h.key=u,h.entry.end=l;continue}const p=r.at(-1);if(u&&u===a&&p&&"tools"in p){p.tools.push(c);continue}if(!u&&f0(c,p,t)){p.next=c;continue}a=u,r.push({at:l,tools:[c]})}return r}function Tz(e){return e.reduce((t,n)=>t+n.tools.length,0)}function jz(e){const t=new Set,n=new Set;let r=!0;for(let a=e.length-1;a>=0;a--){const l=e[a];if(l.kind!=="tool"||!l.parentToolId){r=!1;continue}n.add(l.parentToolId),(r||!l.done)&&t.add(l.parentToolId)}let s=!0;for(let a=e.length-1;a>=0;a--){const l=e[a];l.kind==="user"&&(s=!1),!(l.kind!=="tool"||!l.subagent)&&(l.isError?t.delete(l.id):l.done?pz(l)?s&&!n.has(l.id)&&t.add(l.id):t.delete(l.id):t.add(l.id))}return t}function Cz(e,t){const n=[],r=[];let s=-1;for(const a of e)"spawn"in a?t.has(a.spawn.id)?n.push(a):(s=Math.max(s,a.end),r.push({key:s,entry:a})):"tools"in a&&Ez(a)?n.push(a):r.push({key:a.at,entry:a});return r.sort((a,l)=>a.key-l.key),{flow:r.map(a=>a.entry),floating:n}}function Az(e){const t=D_(e);return e.some(n=>n.kind==="tool"&&!n.done&&!n.parentToolId&&!n.background&&(!t.has(n.id)||gd(n.input)))}function Iz(e){return e.findIndex(t=>"tools"in t&&!t.tools[0].parentToolId&&!t.tools.at(-1).done&&!t.tools.at(-1).background)}function z_(e,t=!1){const n=new Set;let r=!1,s=!1;return e.forEach((a,l)=>{if(!("tools"in a)||!t&&a.tools[0].parentToolId)return;const c=a.tools.at(-1);if(c.done||c.background||c.name===Aa)return;const u=K0({name:c.name,kind:c.toolKind});(s||r&&u)&&n.add(l),r=!0,s||(s=u)}),n}function Rz(e){return e.findIndex(t=>!t.tools.at(-1).done)}function F_(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function Oz(e,t){return!e||!t?e===t:e.length===t.length&&e.every((n,r)=>{var s,a;return n.at===((s=t[r])==null?void 0:s.at)&&n.next===((a=t[r])==null?void 0:a.next)&&F_(n.tools,t[r].tools)})}function $z(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"&&!O_(r))return t;continue}if(n.item.kind==="thinking"){if(!n.item.text.trim())continue;return R_(n.item.text)?-1:t}if(Mz(n.item))return-1}}return-1}function Mz(e){return e.kind==="assistant"?!!e.text.trim():e.kind==="ask"?e.ask.kind==="question"||!!e.outcome:!0}function Lz(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 ag({src:e,n:t,name:n,width:r,height:s,bytes:a,uploading:l,onRemove:c,className:u=""}){return f.jsx(rg,{className:Ke("image-chip",u),label:f.jsxs(f.Fragment,{children:[f.jsx("img",{className:"image-thumb",src:e,alt:n,width:40,height:40}),f.jsxs("span",{className:"pick-target",children:[f.jsx("b",{children:V0("image",t)}),f.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",n," · ",r,"×",s," · ",nm(a),l&&" · uploading"]})]})]}),peek:f.jsx("img",{src:e,alt:n,style:{aspectRatio:`${r} / ${s}`}}),full:f.jsx("img",{src:e,alt:n}),menu:h=>Zl(e,h),removeLabel:"Remove image",onRemove:c})}function Pz({img:e,src:t}){return f.jsx(ag,{className:"in-chat",src:t,...e})}function B_(e,{sock:t,dispatch:n}){var g,k;const r=y=>y?"hide":"show",s=e.repos.some(y=>y.id===e.activeRepoId),a=(g=fn(e,e.activeId))==null?void 0:g.worktree.id,l=[];s&&(l.push({id:"new",label:"new worktree…",key:xt("new"),onClick:()=>n({a:"open-draft"})}),l.push({id:"refs",label:"open a branch or PR…",key:xt("refs"),onClick:()=>n({a:"open",overlay:{kind:"refs"}})})),a&&(l.push({id:"jump",label:"jump to file…",key:xt("quick-open"),onClick:()=>n({a:"open",overlay:{kind:"quick-open"}})}),l.push({id:"search",label:"search in files…",key:xt("search"),onClick:()=>n({a:"open",overlay:{kind:"search"}})})),td(e)&&l.push({id:"routes",label:"go to page…",key:xt("routes"),onClick:()=>n({a:"open",overlay:{kind:"routes"}})}),s&&l.push({id:"chats",label:"search chats…",key:xt("chats"),onClick:()=>n({a:"open",overlay:{kind:"chats"}})});const c=gm(e.visible,e.activeId,1);c&&l.push({id:"wt-unseen-next",label:"next that needs you",key:xt("wt-unseen-next"),onClick:()=>n({a:"activate",id:c.activate})}),l.push({id:"project",label:e.repos.length>1?"switch project…":"open project…",key:xt("project"),onClick:()=>n({a:"open",overlay:{kind:"projects",form:"center"}})});const u=[{id:"changes",label:`${r(e.layout.changes)} changes panel`,key:xt("changes"),onClick:()=>n({a:"toggle-changes"})},{id:"files",label:`${r(e.layout.changes&&xa(e)==="files")} files`,key:xt("files"),onClick:()=>n(e.layout.changes&&xa(e)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"})},{id:"chat",label:`${r(e.layout.chat)} chat panel`,key:xt("composer"),onClick:()=>n({a:"toggle-chat"})},{id:"terminal",label:`${r(e.layout.term)} terminal`,key:xt("terminal"),onClick:()=>n({a:"toggle-terminal"})},{id:"rail",label:`${r(e.railOpen)} worktree panel`,key:xt("rail"),onClick:()=>n({a:"toggle-rail"})},{id:"design",label:`${r(e.layout.design)} design system`,key:xt("design"),onClick:()=>n({a:"toggle-design"})},{id:"zen",label:"full-bleed preview",key:xt("zen"),onClick:()=>n({a:"toggle-zen"})}],h=[{id:"commands",label:"command palette",key:xt("commands"),onClick:()=>n({a:"open",overlay:{kind:"commands"}})},{id:"keys",label:"settings & shortcuts",key:xt("keys"),onClick:()=>n({a:"open",overlay:{kind:"keys"}})}];if((k=e.self)!=null&&k.restart&&h.push({id:"restart-daemon",label:"restart Toyon",onClick:()=>t==null?void 0:t.send({t:"restart-daemon"})}),e.remote){e.frame==="desk"&&h.push({id:"pair",label:"open on your phone",onClick:()=>n({a:"open",overlay:{kind:"pair"}})});const y=yT(`https://${e.remote.host}`);h.push({id:"toyon-cloud",label:"add to toyon.cloud",...e.managed.deploy?{}:{disabled:"managed by your organization"},onClick:()=>window.open(y,"_blank")})}const p=mo(e)?new Set(["chat","design","zen"]):null;return Mn([l,p?u.filter(y=>!p.has(y.id)):u,h])}function lg(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 U_(e,{sock:t}){return[{id:"restart:shell",label:"restart shell",onClick:()=>t==null?void 0:t.send({t:"term-restart",worktreeId:e,stream:po})}]}function Dz(e,t,n,r){return Mn([[...e.flatMap(s=>lg(s,t,r)),...U_(t,r)],[{id:"terminal",label:`${n?"hide":"show"} terminal`,onClick:()=>r.dispatch({a:"toggle-terminal"})}]])}function zz(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 Hd(e,t,{sock:n,dispatch:r}){const s=[];e.id!==t&&s.push({id:`repo:${e.id}`,label:`switch to ${e.name}`,onClick:()=>r({a:"activate-repo",id:e.id})});const a=[{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}?
|
|
212
|
+
|
|
213
|
+
Its procs stop, it leaves the project list, and the chat on main is deleted. The checkout is not touched, and archived worktrees come back when you open it again.`)&&(n==null||n.send({t:"forget-repo",repoId:e.id}))}}];return Mn([s,a])}const cd={dark:"dark",light:"light",system:"follow system",daylight:"follow daylight"};function Fz(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(s=>e(n.name,s))},t.click()}function H_(e,{sock:t,dispatch:n}){var a;const r=e.themePrefs,s=l=>{var c;return((c=e.themes.find(u=>u.id===l))==null?void 0:c.name)??l};return Mn([[{id:"theme",label:"theme…",detail:jd(r,e.themes,kx(e)).name,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"theme"}})},{id:"appearance",topic:"theme",label:"light or dark…",detail:cd[r.mode],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"appearance"}})}],[{id:"agent",label:"default agent…",detail:((a=e.agents.find(l=>l.id===e.defaultAgent))==null?void 0:a.name)??e.defaultAgent,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"agent"}})}],[{id:"chat-side",label:"chat side",detail:e.chatSide,onClick:()=>n({a:"toggle-chat-side"})}],[{id:"theme-import",topic:"theme",label:"import a VS Code theme…",onClick:()=>Fz((l,c)=>t==null?void 0:t.send({t:"import-theme",name:l,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:s(r.dark),sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"dark"}})},{id:"theme-light",topic:"theme",label:"light slot override…",detail:s(r.light),sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"light"}})}]])}function Bz(e,t,n,r,s){const a=[],l=(g,k,y,v,_)=>a.push({id:g,label:k,hint:v,run:y,sub:_}),c=(g,k)=>{for(const y of g){if(!xi(y)||y.disabled!==void 0||y.checked)continue;const v=y.key??(typeof y.detail=="string"?y.detail:void 0),_=k?`${k.scope}:${y.id}`:y.id,E=y.topic?`${y.topic}: ${y.label}`:y.label;l(_,k?`${E} · ${k.name}`:E,y.onClick,v,y.sub)}},u={sock:n,dispatch:t},h=r,p=h==null?void 0:h.worktree.id;if(c(B_(e,u).filter(g=>!xi(g)||g.id!=="commands")),s&&c(Hd(s,s.id,u),{scope:"project",name:s.name}),p&&!mo(e)&&(l("pick",e.picking==="chat"?"cancel element picker":"pick an element for the chat",()=>Hl(p,e.picking,t,"chat"),xt("pick")),l("inspect",e.picking==="code"?"cancel element picker":"pick an element to open its code",()=>Hl(p,e.picking,t,"code"),xt("inspect")),l("reload","reload preview",()=>Wt.post(p,{type:"reload"}))),c(H_(e,u)),h&&p){const g=e.repos.find(k=>k.id===h.worktree.repoId)??null;c(y1(h,g,e,u,{hostname:e.hostname}),{scope:"wt",name:hh(h,g)});for(const k of h.procs)c(lg(k,p,u))}e.visible.forEach((g,k)=>{if(g.worktree.id===p)return;const y=g.worktree.variant;l(`go:${g.worktree.id}`,`switch to ${hh(g,s)}${y?` (v${y.index}/${y.of})`:""}`,()=>t({a:"activate",id:g.worktree.id}),HN(k,e.visible.length))});for(const g of e.repos)g.id!==(s==null?void 0:s.id)&&l(`repo:${g.id}`,`switch to project ${g.name}`,()=>t({a:"activate-repo",id:g.id}));return a}function W_(){const e=ht(),t=ot(),n=P(j=>j.picking),r=P(j=>j.layout),s=P(j=>j.chatSide),a=P(j=>j.railOpen),l=P(j=>j.themePrefs),c=P(j=>j.themes),u=P(j=>j.systemDark),h=P(j=>j.daylight),p=P(j=>j.rows),g=P(j=>j.visible),k=P(j=>j.activeId),y=P(j=>j.activeRepoId),v=P(j=>j.repos),_=P(j=>j.agents),E=P(j=>j.defaultAgent),C=P(j=>j.shipping),x=P(j=>j.remote),N=P(j=>j.managed),M=P(j=>j.frame),J=P(j=>j.self),W=P(j=>j.archivedPage),R=P(j=>j.archived);return S.useMemo(()=>{const j={picking:n,layout:r,chatSide:s,railOpen:a,themePrefs:l,themes:c,systemDark:u,daylight:h,rows:p,visible:g,activeId:k,activeRepoId:y,repos:v,agents:_,defaultAgent:E,shipping:C,remote:x,managed:N,frame:M,self:J,archivedPage:W,archived:R,hostname:location.hostname};return Bz(j,e,t,fn(j,k),Ra(j,y))},[n,r,s,a,l,c,u,h,p,g,k,y,v,_,E,C,x,N,M,J,W,R,e,t])}function K_(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=[];for(const s of e){const a=Mh(s.label.toLowerCase(),n);a>0&&r.push({c:s,score:a})}return r.sort((s,a)=>a.score-s.score),r.map(s=>s.c)}function Mh(e,t){const n=cg(e,t);if(!n)return 0;let r=0,s=0,a=-1;for(const l of n)s=l===a+1?s+1:1,r+=s+(Z_(e,l)?3:0),a=l;return r+Math.max(0,40-e.length/4)}const Z_=(e,t)=>t===0||/[\s:\-–—·/.(]/.test(e[t-1]);function cg(e,t){const n=e.toLowerCase(),r=[];let s=0;for(const a of t.toLowerCase()){let l=-1;if(n[s]===a)l=s;else if(a===" ")l=n.indexOf(" ",s);else for(let c=n.indexOf(a,s);c!==-1;c=n.indexOf(a,c+1))if(Z_(n,c)){l=c;break}if(l===-1)return null;r.push(l),s=l+1}return r}const Na=(e,...t)=>{const n=e.trim().toLowerCase();return!n||t.some(r=>r==null?void 0:r.toLowerCase().includes(n))},Uz=/^[^\s]*$/;function p0(e,t){if(e.startsWith("!"))return null;if(e.startsWith("/")){const a=e.indexOf(" "),l=a===-1?e.length:a;if(!(e.indexOf("/",1)!==-1&&e.indexOf("/",1)<l)&&t<=l)return{kind:"command",query:e.slice(1,t),from:0,to:l}}const 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(!Uz.test(r))return null;let s=t;for(;s<e.length&&!/\s/.test(e[s]??"");)s++;return{kind:"file",query:r,from:n,to:s}}const Hz={files:new Set,folders:new Set},h0=new WeakMap;function Wz(e){if(!e)return Hz;let t=h0.get(e);return t||(t={files:new Set(e),folders:new Set(fx(e))},h0.set(e,t)),t}const Kz=/(^|\s)(@\S+)/g,Zz=/[.,;:!?)\]}'"]$/;function m0(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 qz(e,t){const n=[];let r=0;const s=a=>{if(!a)return;const l=n.at(-1);(l==null?void 0:l.kind)==="text"?l.text+=a:n.push({kind:"text",text:a})};for(const a of e.matchAll(Kz)){const l=a.index+(a[1]??"").length;let c=(a[2]??"").slice(1),u=m0(c,t);for(;!u&&Zz.test(c);)c=c.slice(0,-1),u=c?m0(c,t):null;u&&(s(e.slice(r,l)),n.push(u),r=l+u.text.length)}return s(e.slice(r)),n}function Gz(e,t,n){return{text:e.slice(0,t.from)+n+e.slice(t.to),caret:t.from+n.length}}function Vz(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=a=>e.map(l=>({c:l,score:a(l)})).filter(l=>l.score>0).sort((l,c)=>c.score-l.score||l.c.name.localeCompare(c.c.name)).map(l=>l.c),s=r(a=>Mh(a.name,n));return s.length>0?s:r(a=>Mh(a.description,n))}const Yz=/(^|\s)@\S/;function q_({text:e,worktreeId:t,root:n,inField:r}){const s=Un(),a=ot(),l=P(p=>{var g;return t?(g=p.local[t])==null?void 0:g.files:void 0}),c=Wz(l),u=S.useMemo(()=>qz(e,c),[e,c]),h=l===void 0&&t&&Yz.test(e)?t:null;return S.useEffect(()=>{h&&Md(h,s.getState(),{sock:a,dispatch:s.dispatch})},[h,s,a]),f.jsx(f.Fragment,{children:u.map((p,g)=>{if(p.kind==="text")return p.text;if(p.kind==="changes"){const _=It("this worktree's uncommitted files",void 0,{placement:"follow"});return f.jsx("span",{className:"chat-mention","data-changes":"",..._,children:p.text},g)}if(!n||!t)return p.text;const k=p.kind==="folder",y=`${n}/${p.path}${k?"/":""}`,v=It(k?`${p.path}/`:p.path,void 0,{placement:"follow"});return f.jsx("a",{className:"chat-mention",href:y,tabIndex:r?-1:void 0,...v,children:p.text},g)})})}function G_(e,t,n,r){if(e.target.closest("[data-changes]")){n&&r.dispatch({a:"focus-changes",tab:"changes"});return}ng(e,t,n,r)}function Qz(e){return e.length<2||!e.every(t=>{var n;return t.length===1&&((n=t[0])==null?void 0:n.diff)})?null:Jz(e.map(t=>t[0].text))}const Xz=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function Jz(e,t=3){let n=[];for(const r of e){const s=e3(r);if(!s)return null;const a=t3(n,s);if(!a)return null;n=a}return n.some(r=>r.kind!=="same")?n3(n,t):null}function e3(e){const t=[];let n=null;for(const r of e.split(`
|
|
214
|
+
`)){const s=Xz.exec(r);if(s){n={oldStart:Number(s[1]),newStart:Number(s[2]),ops:[]},t.push(n);continue}if(!n)return null;const a=r[0];if(a===" "||a==="-"||a==="+")n.ops.push({mark:a,text:r.slice(1)});else if(r==="")n.ops.push({mark:" ",text:""});else return null}return t.length>0?t:null}function t3(e,t){const n=[];let r=0,s=0,a=0,l=0;const c=p=>{p.kind==="same"?s=p.a-p.c:p.kind==="add"?s-=1:s+=1},u=()=>{for(;r<e.length&&e[r].kind==="del";)n.push(e[r]),c(e[r]),r++},h=p=>{for(let g=p;g<e.length;g++){const k=e[g];if(k.kind!=="del")return k.c}return Number.POSITIVE_INFINITY};for(const p of t){if(p.oldStart<=l)return null;for(;r<e.length;){const y=e[r];if((y.kind==="del"?h(r):y.c)>=p.oldStart)break;n.push(y.kind==="del"?y:{...y,c:y.c+a}),c(y),r++}let g=p.oldStart,k=p.newStart;for(const y of p.ops){if(u(),y.mark==="+"){n.push({kind:"add",c:k,text:y.text}),k++;continue}const v=e[r],_=v&&v.kind!=="del"&&v.c===g?v:void 0;if(_){if(_.text!==y.text)return null;r++,c(_),y.mark===" "?n.push({..._,c:k}):_.kind==="same"&&n.push({kind:"del",a:_.a,text:_.text})}else y.mark===" "?n.push({kind:"same",a:g+s,c:k,text:y.text}):n.push({kind:"del",a:g+s,text:y.text});y.mark===" "&&k++,g++}a=k-g,l=g-1}for(;r<e.length;r++){const p=e[r];n.push(p.kind==="del"?p:{...p,c:p.c+a})}return n}function n3(e,t){const n=[];for(const r of o3(e))for(const[s,a]of s3(r.rows,t)){const l=r3(r.rows.slice(s,a)),c=l.filter(g=>g.kind!=="add").length,u=l.filter(g=>g.kind!=="del").length,h=l.find(g=>g.kind!=="add"),p=l.find(g=>g.kind!=="del");n.push(`@@ -${h?h.a:r.oldAt[s]},${c} +${p?p.c:r.newAt[s]},${u} @@`,...l.map(g=>`${g.kind==="add"?"+":g.kind==="del"?"-":" "}${g.text}`))}return n.join(`
|
|
215
|
+
`)}function r3(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 s=e.slice(n,r);t.push(...s.filter(a=>a.kind==="del"),...s.filter(a=>a.kind==="add")),n=r}return t}function o3(e){const t=[];let n=null,r=1,s=1;for(const a of e){const l=a.kind==="add"?r:a.a,c=a.kind==="del"?s:a.c;(!n||l!==r||c!==s)&&(n={rows:[],oldAt:[],newAt:[]},t.push(n)),n.rows.push(a),n.oldAt.push(l),n.newAt.push(c),r=l+(a.kind==="add"?0:1),s=c+(a.kind==="del"?0:1)}return t}function s3(e,t){const n=[];let r=0;for(;r<e.length;){if(e[r].kind==="same"){r++;continue}let s=r,a=r;for(;a<e.length;){if(e[a].kind!=="same"){s=a,a++;continue}let l=0;for(;a+l<e.length&&e[a+l].kind==="same";)l++;if(l>t*2||a+l>=e.length)break;a+=l}n.push([Math.max(0,r-t),Math.min(e.length,s+t+1)]),r=s+t+1}return n}function Lh({pieces:e}){return f.jsx(f.Fragment,{children:e.map((t,n)=>{const r=`${t.changed?"ch ":""}${t.scope?`sy-${t.scope}`:""}`.trim();return r?f.jsx("span",{className:r,children:t.text},n):f.jsx(S.Fragment,{children:t.text},n)})})}function ug({pick:e,dir:t,worktreeId:n,tipText:r,onHover:s,onOpen:a,onRemove:l,className:c=""}){const u=e.callFile,h=e.file,p=u?{path:u,line:e.callLine}:h?{path:h,line:e.line}:null,g=u&&h?{path:h,line:e.line}:null,k=(C,x)=>`${C}${x?`:${x}`:""}`,y=C=>C.split("/").pop()??C,v=(C,x,N,M)=>a?f.jsx("button",{className:"pick-open","data-tip":M,onClick:()=>a(C,x??1),children:N}):N,_=Jt("chat"),E=S.useRef(null);return f.jsxs("div",{ref:E,className:Ke("pick-chip row row-sm",c),"data-tip":r,onMouseEnter:()=>s==null?void 0:s(!0),onMouseLeave:()=>s==null?void 0:s(!1),..._.contextMenu(()=>eP(e,{dir:t,remove:l})),children:[f.jsxs("span",{className:"pick-target",children:[f.jsx(Et,{name:"pick",className:"icon-inline"})," ",vm(e),p&&f.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",v(p.path,p.line,k(y(p.path),p.line),`Open ${k(p.path,p.line)}`)]}),g&&f.jsxs("span",{className:"pick-file row-dim",children:[" ","·"," ",v(g.path,g.line,k(g.path.split("/").pop()??g.path,g.line),`Open the component: ${k(g.path,g.line)}`)]})]}),l&&f.jsx($t,{icon:"close",label:"Remove attachment",tone:"quiet",onClick:l}),n&&(p==null?void 0:p.line)&&f.jsx(S_,{chip:E,children:f.jsx(l3,{worktreeId:n,path:p.path,line:p.line})})]})}const i3=6,a3=16;function l3({worktreeId:e,path:t,line:n}){const r=jx(),s=ot(),a=P(g=>{var k;return((k=$o(g))==null?void 0:k.id)===e}),l=P(g=>{var k;return a?0:(k=go(g,e).changedRanges[t])==null?void 0:k.offset}),[c,u]=S.useState(null);S.useEffect(()=>{let g=!0;return a||s==null||s.send({t:"changed-ranges",worktreeId:e,path:t}),r==null||r.look(e,t).then(k=>{g&&u(k)}),()=>{g=!1}},[r,s,e,t,a]);const h=S.useMemo(()=>{if(c===null||l===void 0)return null;const g=c.split(`
|
|
216
|
+
`),k=n-l,y=Math.max(1,k-i3),v=Math.min(g.length,k+a3);if(y>v)return null;const _=g.slice(y-1,v);return{from:y,at:k,slice:_,painted:Xm(_.join(`
|
|
217
|
+
`),Qm("",t))}},[c,l,n,t]);if(!h)return null;const p=String(h.from+h.slice.length-1).length;return f.jsx("pre",{className:"pick-peek",children:h.slice.map((g,k)=>{const y=h.from+k,v=h.painted[k];return f.jsxs("span",{className:"pick-peek-line","data-state":y===h.at?"current":void 0,children:[f.jsx("span",{className:"pick-peek-n",children:String(y).padStart(p)}),v!=null&&v.length?f.jsx(Lh,{pieces:v}):g||" "]},y)})})}function c3(e,t,n,r,s){const{sock:a}=r,l=e[0];if(!l)return[];const c=[],u=ig(Ud(l),t);if(u&&!u.startsWith("/")&&n){const v=l.toolKind==="edit"?"diff":"file";c.push({id:"open-diff",label:`open ${v}`,onClick:()=>Vn(r,{worktreeId:n.id,path:u,view:v})}),c.push(...ji(`${n.dir}/${u}`,()=>a==null?void 0:a.send({t:"reveal",worktreeId:n.id,path:u})))}else u.startsWith("/")&&c.push(...ji(u),{id:"copy-path",label:"copy path",onClick:()=>Bt(u)});const h=[],p=ql(l,t).command,g=gz(l);g&&g!==p&&h.push({id:"copy-description",label:"copy description",onClick:()=>Bt(g)}),p&&h.push({id:"copy-command",label:"copy command",onClick:()=>Bt(p)});const k=e.map(v=>v.output??"").filter(Boolean).join(`
|
|
218
|
+
`);k&&h.push({id:"copy-output",label:"copy output",onClick:()=>Bt(k)});const y=s.leaf?[]:[{id:"fold",label:s.open?"collapse":"expand",onClick:s.toggle}];return Mn([c,h,y])}function g0({text:e,menu:t,marked:n,worktreeId:r,fileRoot:s,streaming:a}){const l=Jm(e,{fileRoot:s,streaming:a}),c=ot(),u=ht(),h=Jt("chat"),p=S.useRef(null);Ox(p,l);const g=P(v=>{var _;return r?(_=v.local[r])==null?void 0:_.refusedLink:void 0});gt([l,g],()=>{var _;const v=p.current;if(v)for(const E of v.querySelectorAll("a.file-link")){const C=g!==void 0&&E.getAttribute("href")===g.href;E.classList.toggle("file-link-refused",C),C?((_=E.dataset).tipWas??(_.tipWas=E.dataset.tip??""),E.dataset.tip=g.message,E.dataset.tipPlacement="bottom",E.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0}))):E.dataset.tipWas!==void 0&&(E.dataset.tip=E.dataset.tipWas,E.dataset.tipPlacement="follow",delete E.dataset.tipWas)}});const k=S.useRef(null),y=eg(k);return f.jsxs("div",{ref:k,className:"msg-assistant md row-edge","data-state":Yn({cursor:n}),...h.contextMenu((v,_)=>t(tg(_,s),Oh(_))),onClick:v=>ng(v,s,r,{sock:c,dispatch:u}),children:[f.jsx("div",{ref:p}),y]})}const Kp=40;function V_(e,t){return e.map(n=>{const r=Qm(n.lang,t||(n.diff?bD(n.text):""));if(n.diff){const s=bz(n.text);return{...n,lines:s,painted:ED(s,r)}}return{...n,lines:[],painted:n.code?Xm(n.text,r):[]}})}function Y_({blocks:e,path:t,worktreeId:n}){ot();const r=ht();return f.jsx("div",{className:"tool-out",children:e.map((s,a)=>s.diff?f.jsxs("pre",{className:"tool-block diff",children:[s.lines.slice(0,Kp).map((l,c)=>{var u;return l.kind==="hunk"?f.jsx("span",{className:"dl hunk",title:l.text},c):f.jsx("span",{className:`dl ${l.kind}`,children:(u=s.painted[c])!=null&&u.length?f.jsx(Lh,{pieces:s.painted[c]}):l.text||" "},c)}),s.lines.length>Kp&&f.jsxs("button",{type:"button",className:"dl more",disabled:!t||!n,"data-tip":t&&n?"Open this file's diff":void 0,onClick:()=>n&&Vn({dispatch:r},{worktreeId:n,path:t,view:"diff"}),children:[s.lines.length-Kp," more lines"]})]},a):s.code?f.jsx("pre",{className:"tool-block",children:s.painted.length?s.painted.map((l,c)=>f.jsxs(S.Fragment,{children:[c>0?`
|
|
219
|
+
`:null,f.jsx(Lh,{pieces:l})]},c)):s.text},a):f.jsx("p",{className:"tool-note",children:s.text},a))})}function u3({image:e,worktreeId:t}){const n=Lu(t,e.file),[r,s]=S.useState(!1),a=Jt("chat");return f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",className:"tool-image","data-tip":"Open full size","data-tip-placement":"follow",onClick:()=>s(!0),...a.contextMenu(()=>Zl(n,{open:()=>s(!0)})),children:f.jsx("img",{src:n,alt:e.file})}),r&&f.jsx(Bm,{owner:"chat",onClose:()=>s(!1),menu:()=>Zl(n),children:f.jsx("img",{src:n,alt:e.file})})]})}const d3=S.memo(function({item:t,roots:n,worktreeId:r}){const s=S.useMemo(()=>V_($h(t,t.output??""),Ud(t)),[t]),a=ql(t,n).command,l=r?t.images??[]:[];return!a&&s.length===0&&l.length===0?null:f.jsxs("div",{className:"tool-part",children:[a&&f.jsx("pre",{className:"tool-block cmd",children:a}),s.length>0&&f.jsx(Y_,{blocks:s,path:Q_(t,n),worktreeId:r}),l.length>0&&r&&f.jsx("div",{className:"tool-out",children:l.map(c=>f.jsx(u3,{image:c,worktreeId:r},c.file))})]})});function Q_(e,t){const n=ig(Ud(e),t??[]);return n.startsWith("/")?"":n}const f3=S.memo(function({text:t,item:n,roots:r,worktreeId:s}){const a=Ud(n),l=S.useMemo(()=>V_([{code:!0,diff:!0,lang:"diff",text:t}],a),[t,a]);return f.jsx("div",{className:"tool-part",children:f.jsx(Y_,{blocks:l,path:Q_(n,r),worktreeId:s})})});function Ph({className:e,state:t,auto:n,leaf:r,growing:s,label:a,summary:l,menu:c,children:u}){const[h,p]=S.useState(null),g=S.useRef(null),k=S.useRef(null),y=Rx(k),v=m2(".chat-log"),_=!r&&(h??n),E=()=>{r||(_||v(g.current),p(!_))},C=Jt("chat");return f.jsxs("details",{ref:g,className:Ke(e,r&&"leaf"),"data-state":t,open:_,onToggle:x=>{if(!x.currentTarget.open||s)return;const N=k.current;N&&(N.scrollTop=0,y.read())},...C.contextMenu((x,N)=>c({open:_,leaf:!!r,toggle:E},N)),tabIndex:-1,onPointerDown:()=>{var x;return(x=g.current)==null?void 0:x.focus({preventScroll:!0})},onKeyDown:x=>{if((x.key==="ArrowLeft"||x.key==="ArrowRight")&&!r){if(x.shiftKey||x.altKey||x.metaKey||x.ctrlKey)return;zd([{depth:0,open:_}],0,x.key)&&E();return}x.key!=="Escape"||!_||(x.stopPropagation(),p(!1))},children:[f.jsx("summary",{"aria-label":a,tabIndex:r?-1:void 0,onClick:x=>{x.preventDefault(),E()},children:l}),f.jsx("div",{className:"tool-body",ref:k,children:u})]})}const p3=S.memo(function({item:t,open:n,streaming:r,worktreeId:s,fileRoot:a}){const l=I_(t.text),c=l.slice(0,-1),u=Jm(l.length?c.join(`
|
|
220
|
+
|
|
221
|
+
`):C_(t.text),a?{fileRoot:a}:void 0),h=ot(),p=ht(),g=r?"Thinking":"Thought",k=S.useRef(null);Ox(k,u);const y=S.useRef(null),v=eg(y),_=f.jsx("div",{className:"tool-part",children:f.jsxs("div",{ref:y,className:"tool-out thought-out md",onClick:C=>ng(C,a,s,{sock:h,dispatch:p}),children:[f.jsx("div",{ref:k}),v]})}),E=l.at(-1)??(r?"":R_(t.text));if(E){const C=c.length===0;return f.jsx(Ph,{className:"tool-row",auto:!1,leaf:C,growing:r,label:E,menu:(x,N)=>Mn([Th(Oh(N)),[{id:"copy",label:"copy thought",onClick:()=>Bt(t.text)}],...C?[]:[[{id:"fold",label:x.open?"collapse":"expand",onClick:x.toggle}]]]),summary:f.jsxs(f.Fragment,{children:[f.jsx(Et,{name:"bulb",className:"tool-icon"}),f.jsx("span",{className:Ke("tool-hint thought-line",r&&"live-text"),children:E})]}),children:C?null:_})}return f.jsx(Ph,{className:"tool-row",auto:!!n,growing:r,label:g,menu:(C,x)=>Mn([Th(Oh(x)),[{id:"copy",label:"copy thought",onClick:()=>Bt(t.text)}],[{id:"fold",label:C.open?"collapse":"expand",onClick:C.toggle}]]),summary:f.jsxs(f.Fragment,{children:[f.jsx(Et,{name:"bulb",className:"tool-icon"}),f.jsx("span",{className:Ke("tool-name",r&&"live-text"),children:g})]}),children:_})}),Nl=6,h3={land:"the land",commit:"the commit","sync-main":"the sync","pull-main":"the pull"},Tu=S.memo(function e({tools:t,run:n,next:r,live:s,working:a,since:l,queued:c,roots:u,worktreeId:h,marked:p}){const g=t[0],k=S.useMemo(()=>Qz(t.map(q=>$h(q,q.output??""))),[t]),y=t.at(-1)??g,v=!y.done,_=v&&!!y.background,E=v||!!r,C=E&&!c||!!a,x=v&&!!c,N=_a(v||a?l:void 0),M=n?Rz(n):-1,J=S.useMemo(()=>n?z_(n,!0):void 0,[n]),W=!!s||!!n&&E,R=ql(g,u),j=v?mz(g):"",{label:A,icon:D}=R,H=O_(g),Y=j?"":H?"Guardian":R.name,ae=j||(H?dz(g.output??""):R.hint),me=!(n&&n.length>0)&&!k&&t.every(q=>{var ke;return!ql(q,u).command&&$h(q,q.output??"").length===0&&!((ke=q.images)!=null&&ke.length)}),ye=n?Tz(n):0,_e=[A,ae].filter(Boolean).join(" ")+(_?", in the background":"")+(x?", queued":""),V=j?"":n?`${ye} ${ye===1?"call":"calls"}`:t.length>1?`×${t.length}`:"",O=Un(),F=ot(),ne=P(q=>{var ke;return h?(ke=q.shipping[h])==null?void 0:ke.op:void 0}),$=v&&g.name===Aa&&h?{worktreeId:h,toolId:y.id}:null;return f.jsxs(Ph,{className:Ke("tool-row",t.some(q=>q.isError)&&"error",g.parentToolId&&"nested",n&&"spawn",x&&"queued"),state:Yn({cursor:p}),auto:W,leaf:me,growing:C,label:n&&V?`${_e}, ${V}`:t.length>1?`${_e}, ${t.length} calls`:_e,menu:q=>{const ke=fn(O.getState(),h),se=ke?{id:ke.worktree.id,dir:ke.worktree.path}:null;return c3(t,u??[],se,{sock:F,dispatch:O.dispatch},q)},summary:f.jsxs(f.Fragment,{children:[f.jsx(Et,{name:n?"spawn":D,className:"tool-icon"}),Y&&f.jsx("span",{className:Ke("tool-name",C&&!ae&&"live-text"),children:Y}),j?f.jsx("span",{className:"tool-writing","data-tip":ae,children:f.jsx(sc,{variant:"squares"})}):ae&&f.jsx("span",{className:Ke("tool-hint",C&&"live-text"),children:ae}),_&&f.jsx("span",{className:"tool-status",children:"in the background"}),x&&f.jsx("span",{className:"tool-status",children:"queued"}),N>=Nl&&f.jsx("span",{className:Ke("tool-age",M>=0&&"tool-age-folded"),children:ha(N)}),V&&f.jsx("span",{className:"tool-count",children:V}),$&&f.jsx($t,{icon:"stop",tone:"danger",className:"tool-stop",label:ne?`Stop ${h3[ne]}: this step is killed, and what it printed so far stays`:_?"Kill what the command left running; what it printed so far stays":"Kill the command and everything it started; what it printed so far stays",onClick:q=>{q.preventDefault(),q.stopPropagation(),F==null||F.send({t:"exec-stop",...$})}})]}),children:[n&&n.length>0&&f.jsx("div",{className:"spawn-run",children:n.map((q,ke)=>f.jsx(e,{tools:q.tools,next:q.next,since:ke===M?l:void 0,queued:J==null?void 0:J.has(ke),roots:u,worktreeId:h},q.at))}),k?f.jsx(f3,{text:k,item:g,roots:u,worktreeId:h}):t.map(q=>f.jsx(d3,{item:q,roots:u,worktreeId:h},q.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&&F_(e.tools,t.tools)&&Oz(e.run,t.run));function m3({item:e}){const t=ot(),n=ht(),r=P(v=>v.activeId),s=P(v=>v.layout.term),a=P(v=>{var _;return((_=v.rows.find(E=>E.id===v.activeId))==null?void 0:_.login)??!1}),l=P(v=>v.managed.problem),[c,u]=S.useState(""),[h,p]=S.useState(null),g=S.useRef(!1);if(gt([a],()=>{a&&g.current&&r&&n({a:"term-stream",id:r,stream:ls,tall:!0})}),gt([e.done],()=>{e.done&&g.current&&s&&n({a:"toggle-terminal"}),g.current=!1}),!r)return null;const k=(v,_)=>{t==null||t.send({t:"agent-auth",worktreeId:r,methodId:v,..._?{apiKey:_}:{}})},y=e.methods.find(v=>v.id===h);return f.jsxs("div",{className:`auth-card ${e.done?"done":""}`,children:[f.jsx("div",{className:"auth-title",children:e.done?`${e.agentName} is logged in`:e.rejected?`${e.agentName}'s credentials were refused`:`${e.agentName} is not logged in`}),!e.done&&f.jsxs("div",{className:"auth-methods",children:[e.methods.map(v=>v.needsKey?f.jsx(Be,{variant:"outline",on:h===v.id,"data-tip":v.description,onClick:()=>p(h===v.id?null:v.id),children:v.name},v.id):f.jsx(Be,{variant:"outline","data-tip":v.kind==="terminal"?"opens in the terminal pane":v.description,onClick:()=>{k(v.id),v.kind==="terminal"&&(g.current=!0)},children:v.name},v.id)),f.jsx(Be,{variant:"outline","data-tip":"after logging in elsewhere (the terminal, another window)",onClick:()=>t==null?void 0:t.send({t:"agent-retry",worktreeId:r}),children:"send again"})]}),!e.done&&a&&f.jsx("div",{className:"hint auth-hint",children:"paste the code into the login tab below and press Enter; it stays hidden as you paste. Your message sends once you are in."}),!e.done&&e.withheld&&f.jsx("div",{className:"hint auth-hint",children:l?"the policy file on this machine is invalid, so signing in with a Claude plan is off until it is fixed; toyon doctor says why":"signing in with a Claude plan is managed by your organization"}),!e.done&&y&&f.jsxs("form",{className:"auth-key",onSubmit:v=>{v.preventDefault(),c.trim()&&(k(y.id,c.trim()),u(""),p(null))},children:[f.jsx(Ro,{type:"password",autoFocus:!0,placeholder:`${y.name} for ${e.agentName}`,value:c,onChange:v=>u(v.target.value)}),f.jsx(Be,{type:"submit",children:"use key"})]})]})}const g3=S.memo(function({item:t,worktreeId:n,onPickHover:r,marked:s,streaming:a}){const l=Un(),c=ot(),u=Jt("chat"),h={sock:c,dispatch:l.dispatch},p=()=>{const k=fn(l.getState(),n);return k?k.worktree.path:null},g=()=>{var k;return(k=fn(l.getState(),n))==null?void 0:k.worktree.path};switch(t.kind){case"user":{const k=g();return f.jsxs("div",{className:"msg-user row-edge","data-state":Yn({cursor:s}),...u.contextMenu((y,v)=>hl(t,n??null,h,{link:tg(v,k),dir:p()})),onClick:y=>G_(y,k,n,h),children:[t.attachments&&n&&f.jsx("div",{className:"msg-attachments",children:t.attachments.map(y=>y.kind==="image"?f.jsx(Pz,{img:y,src:Lu(n,y.file)},`${y.kind}-${y.n}`):y.kind==="file"?f.jsx(sg,{className:"in-chat",name:y.name,bytes:y.bytes,href:y.text?Lu(n,y.file):void 0},`${y.kind}-${y.n}`):y.kind==="paste"?f.jsx(og,{className:"in-chat",n:y.n,name:y.name,source:y.source,lines:y.lines,chars:y.chars,preview:y.preview,href:Lu(n,y.file)},`${y.kind}-${y.n}`):f.jsx(ug,{pick:y,dir:p(),className:"in-chat",tipText:"Hover to highlight on the page",onHover:v=>r==null?void 0:r(y,v),worktreeId:n,onOpen:(v,_)=>Sa(l,c,n,v,_)},`${y.kind}-${y.n}`))}),f.jsx(q_,{text:t.text,worktreeId:n,root:k})]})}case"assistant":return f.jsx(g0,{text:t.text,menu:(k,y)=>hl(t,n??null,h,{link:k,code:y,dir:p()}),marked:s,worktreeId:n,fileRoot:g(),streaming:a});case"error":return f.jsx("div",{className:"msg-assistant msg-error",...u.contextMenu(()=>hl(t,n??null,h)),children:t.text});case"auth":return f.jsx(m3,{item:t});case"ask":{const k=f$(t);if(!k)return f.jsx($D,{item:t});const y=ix(k.questions,k.answers).join(`
|
|
222
|
+
`),v={kind:"assistant",text:y};return f.jsxs(f.Fragment,{children:[f.jsx(g0,{text:k.message,menu:(_,E)=>hl({kind:"assistant",text:k.message},n??null,h,{link:_,code:E,dir:p()}),worktreeId:n,fileRoot:g()}),f.jsx("div",{className:"msg-user",...u.contextMenu(()=>hl(v,n??null,h)),children:y})]})}case"blocked":return f.jsxs(Kl,{icon:"lock",word:"blocked",tone:"red",below:f.jsx("div",{className:"daemon-below row-dim",children:t.reason}),...u.contextMenu(()=>JL(t.path,p())),children:[f.jsx("span",{className:"tool-name",children:t.tool}),t.path&&f.jsx("span",{className:"tool-hint",children:t.path})]});case"grafted":return f.jsxs(Kl,{icon:"layers",word:"grafted",tone:"accent","data-tip":`what follows was said in ${t.title} before it was merged in here`,"data-tip-placement":"follow",children:[f.jsx("span",{className:"tool-name",children:t.title}),f.jsx("span",{className:"tool-hint",children:t.branch})]});case"landed":return f.jsx(y3,{item:t});case"restored":return f.jsx(k3,{item:t})}});function k3({item:e}){return f.jsx(Kl,{icon:"reload",word:"restored",tone:"quiet",at:e.ts,children:f.jsxs("span",{className:"daemon-text",children:["after ",px(e.ts-e.archivedAt)," in the archive, back on ",e.branch,e.uncommitted?" with its uncommitted changes":""]})})}function y3({item:e}){const t=ot(),n=ht(),r=P(a=>e.archiveIds.filter(l=>fn(a,l)!==null).length),s=$1(e.ts);return f.jsxs(Kl,{icon:"check",word:"landed",tone:"aqua",at:e.ts,children:[f.jsxs("span",{className:"daemon-text",children:[e.text,", ",s]}),r>0&&f.jsx(Be,{variant:"inline",tone:"strong",onClick:()=>_i(t,n,e.archiveIds),children:r>1?`archive ${r} worktrees`:"archive the other worktree"})]})}function w3(e){return e.startsWith("!")?e.slice(1).trim():null}function X_(e){if(e.kind!=="tool"||e.name!==Aa&&e.name!==Kb)return null;const t=e.input;return typeof(t==null?void 0:t.command)=="string"?t.command:null}const Zp=6e3,k0=1500;function v3(e){if(e.length<=Zp)return e;const t=e.length-Zp;return`${e.slice(0,k0)}
|
|
223
|
+
[${t} characters cut here]
|
|
224
|
+
${e.slice(e.length-(Zp-k0))}`}function b3(e){const t=[];for(let n=e.length-1;n>=0;n--){const r=e[n];if(r.kind==="user")break;if(r.kind!=="tool"||!r.done)continue;const s=X_(r);if(s===null)continue;const a=M_(r.output??"").map(c=>c.text).join(`
|
|
225
|
+
`),l=v3(a);t.unshift(`$ ${s}${l?`
|
|
226
|
+
${l}`:""}`)}if(t.length!==0)return`Shell commands the user ran since their last message, and what each printed:
|
|
227
|
+
${t.join(`
|
|
228
|
+
`)}`}const J_=e=>e===""||e==="!";function y0(e,t){const n=new Set,r=[];for(let s=e.length-1;s>=0;s--){const a=e[s],l=X_(a),c=l!==null?`!${l}`:a.kind==="user"&&!t?a.text:null;c===null||!c.trim()||n.has(c)||(n.add(c),r.push({text:c,at:s}))}return r}function x3(e,t,n,r){if(!t){if(r!=="up"&&r!=="first"||!J_(n))return null;const c=y0(e,n==="!"),u=r==="up"?c[0]:c.at(-1);return u?{walk:{at:u.at,from:n},text:u.text}:null}if(r==="box")return{walk:null,text:t.from};const s=y0(e,t.from==="!"),a=r==="first"?s.length-1:s.findIndex(c=>c.at===t.at)+(r==="up"?1:-1);if(a<0)return{walk:null,text:t.from};const l=s[a];return l?{walk:{at:l.at,from:t.from},text:l.text}:{walk:t,text:n}}const _3={get current(){return Ol.el}};function w0({items:e,next:t,worktreeId:n,dir:r,onOpen:s}){return f.jsx("div",{className:"msg-attachments",children:Q0(e,t).map(([a,l])=>a.kind==="image"?f.jsx(ag,{className:"in-chat",src:nd(a.upload),n:l,name:a.name,width:a.width,height:a.height,bytes:a.bytes},`image-${l}`):a.kind==="file"?f.jsx(sg,{className:"in-chat",name:a.name,bytes:a.bytes,href:a.text?nd(a.upload):void 0},`file-${l}`):a.kind==="paste"?f.jsx(og,{className:"in-chat",n:l,name:a.name,source:a.source,...fm(a.text),text:a.text},`paste-${l}`):f.jsx(ug,{className:"in-chat",pick:a,dir:r,worktreeId:n,onOpen:s},`pick-${l}`))})}const E3=new Set;function v0({active:e,archived:t,lead:n,tail:r}){const s=ot(),a=Un(),l=(e==null?void 0:e.worktree.id)??(t==null?void 0:t.id)??null,c=At(l,"chat"),u=At(l,"queue"),h=At(l,"restoring"),p=At(l,"sending"),g=S.useMemo(()=>Y0(c.map(he=>he.kind==="user"?he.attachments:void 0)),[c]),k=S.useMemo(()=>{let he=g;return u.map(Oe=>{const Mt=he;return he=X0(he,Oe.attachments??[]),Mt})},[u,g]),y=p!=null&&p.message?u.findIndex(he=>{var Oe;return he.text===((Oe=p.message)==null?void 0:Oe.text)}):-1,v=S.useRef(null);QL(v);const[_,E]=S.useState(null),C=S.useCallback(()=>{const he=(v.current&&Nh(v.current))??"";E(Oe=>({seed:he||(Oe==null?void 0:Oe.seed)||"",seq:((Oe==null?void 0:Oe.seq)??0)+1}))},[]),x=S.useCallback(he=>!(he!=null&&he.closest("[data-pane]"))&&!a.getState().overlay,[a]);F1(_3,Fm,C,x);const N=he=>{if(E(null),he){const Oe=window.getSelection();Oe==null||Oe.removeAllRanges(),Oe==null||Oe.addRange(he)}},M=Rx(v,c);gt([l],()=>M.jump());const J=M.offStart&&M.moving==="up",W=M.offEnd&&(M.moving==="down"||M.away),R=(J||W)&&f.jsxs("div",{className:Ke("jump",M.away&&"jump-news"),children:[J&&f.jsx("button",{className:"jump-up",onClick:M.start,"data-tip":"Jump to start",children:f.jsx(Et,{name:"caret-up",className:"icon-inline"})}),W&&f.jsxs("button",{className:"jump-down",onClick:M.jump,"data-tip":"Jump to latest",children:[f.jsx(Et,{name:"caret",className:"icon-inline"}),M.away&&" new messages"]})]}),j=At(l,"mark"),A=(j==null?void 0:j.by)==="walk"?j.at:void 0,D=S.useRef(null),H=()=>{const he=v.current,Oe=he==null?void 0:he.querySelector(':scope > [data-state~="cursor"]');if(!he||!Oe)return;const Mt=parseFloat(getComputedStyle(he).paddingTop)||0;he.scrollTop+=Oe.getBoundingClientRect().top-he.getBoundingClientRect().top-Mt,M.read()};gt([A],()=>{const he=v.current;if(he){if(A===void 0){const Oe=D.current;if(D.current=null,!Oe||!J_(go(a.getState(),l).draft))return;Oe.bottom?M.jump():(he.scrollTop=Oe.top,M.read());return}D.current??(D.current={bottom:M.pinned(),top:he.scrollTop}),H()}});const Y=At(l,"sent");gt([Y],()=>{Y&&M.jump()});const ae=(j==null?void 0:j.by)==="reveal"?j:void 0,me=S.useMemo(()=>ae?Lz(c,ae.seq):-1,[c,ae]),ye=A??(me>=0?me:void 0);gt([ae==null?void 0:ae.n,me],()=>{me>=0&&H()});const _e=S.useCallback((he,Oe)=>{l&&(Oe?Wt.post(l,{type:"highlight-selector",selector:he.selector,label:vm(he)}):Wt.post(l,{type:"highlight-clear"}))},[l]),V=!!e&&ec(e),O=At(l,"askParked"),F=S.useMemo(()=>{const he=ex(c);return!!he&&O!==he.id},[c,O]),ne=e==null?void 0:e.worktree,$=(ne==null?void 0:ne.path)??(t==null?void 0:t.path),q=S.useMemo(()=>$?[$]:[],[$]),ke=S.useMemo(()=>Nz(c,q),[c,q]),se=S.useMemo(()=>V?jz(c):E3,[V,c]),{flow:ve,floating:Re}=S.useMemo(()=>Cz(ke,se),[ke,se]),le=(e==null?void 0:e.agent)==="working",xe=le||(e==null?void 0:e.agent)==="waiting",Le=S.useMemo(()=>xe?$z(ve):-1,[xe,ve]),oe=ve.at(-1),Z=le&&oe&&"item"in oe&&(oe.item.kind==="thinking"||oe.item.kind==="assistant")?ve.length-1:-1,De=ve.findLastIndex(he=>{var Oe;return"tools"in he&&((Oe=he.tools[0])==null?void 0:Oe.name)===Aa}),Ve=At(l,"chatAt"),ze=_a(V?Ve:void 0),it=At(l,"usage"),Je=(it==null?void 0:it.heard)!==void 0&&Ve!==void 0&&it.heard>Ve?it.heard:void 0,en=_a(V?Je:void 0),kt=Az(c),tn=Re.length>0,st=Z>=0||kt||tn,X=S.useMemo(()=>Iz(ve),[ve]),we=S.useMemo(()=>z_(ve),[ve]),Qe=At(l,"running");return f.jsxs("div",{className:"chat-wrap",children:[f.jsxs("div",{className:"chat-log",ref:v,children:[n,ve.map((he,Oe)=>"spawn"in he?f.jsx(Tu,{tools:[he.spawn],run:he.run,roots:q,worktreeId:l},he.at):"tools"in he?f.jsx(Tu,{tools:he.tools,next:he.next,live:Oe===Le||Oe===De,since:Oe===X?Qe==null?void 0:Qe.at:void 0,queued:we.has(Oe),roots:q,worktreeId:l,marked:he.at===ye},he.at):he.item.kind==="thinking"?f.jsx(p3,{item:he.item,open:Oe===Le,streaming:Oe===Z,worktreeId:l,fileRoot:e==null?void 0:e.worktree.path},he.at):f.jsx(g3,{item:he.item,worktreeId:l,onPickHover:_e,marked:he.at===ye,streaming:le&&Oe===ve.length-1},he.at)),Re.map(he=>"spawn"in he?f.jsx(Tu,{tools:[he.spawn],run:he.run,working:!0,since:Ve,roots:q,worktreeId:l},he.at):f.jsx(Tu,{tools:he.tools,since:Ve,roots:q,worktreeId:l},he.at)),l&&(p==null?void 0:p.message)&&f.jsxs("div",{className:"msg-user",children:[p.message.attachments&&f.jsx(w0,{items:p.message.attachments,next:g,worktreeId:l,dir:(e==null?void 0:e.worktree.path)??null,onOpen:(he,Oe)=>Sa(a,s,l,he,Oe)}),p.message.text]}),e&&(p||V&&!(e.agent==="waiting"&&F)&&!kt&&!tn&&!(st&&ze<Nl))&&f.jsx("div",{className:"working-row",children:e.agent==="waiting"?"waiting for your answer…":st?ze>=Nl&&f.jsxs("span",{children:["quiet for",f.jsx("span",{className:"working-num",children:ha(ze)})]}):f.jsxs("span",{className:"working-mark",children:[f.jsx(sc,{variant:"squares"}),Je!==void 0?en>=Nl&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"working-word",children:"thinking"}),f.jsx("span",{className:"working-num",children:ha(en)})]}):ze>=Nl&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"working-word",children:"waiting for the model"}),f.jsx("span",{className:"working-num",children:ha(ze)})]})]})}),l&&u.map((he,Oe)=>Oe===y?null:f.jsxs("div",{className:"msg-user queued-msg",children:[f.jsxs("span",{className:"queued-tag",children:[f.jsx(Et,{name:"clock",className:"icon-inline"}),"queued"]}),f.jsxs("div",{className:"queued-text",children:[he.attachments&&f.jsx(w0,{items:he.attachments,next:k[Oe]??g,worktreeId:l,dir:(e==null?void 0:e.worktree.path)??null,onOpen:(Mt,an)=>Sa(a,s,l,Mt,an)}),he.text]}),f.jsxs("span",{className:"queued-actions",children:[f.jsx($t,{icon:"edit",label:"Edit: removes from queue, puts it back in the input",onClick:()=>Jx(a,s,l,Oe)}),f.jsx($t,{icon:"close",label:"Remove from queue",onClick:()=>s==null?void 0:s.send({t:"unqueue",worktreeId:l,index:Oe})})]})]},`q-${Oe}`)),r,h!==void 0&&f.jsxs("div",{className:"msg-user queued-msg",children:[f.jsxs("span",{className:"queued-tag",children:[f.jsx(Et,{name:"clock",className:"icon-inline"}),"restoring"]}),f.jsx("span",{className:"queued-text",children:h})]})]}),_&&f.jsx(D1,{root:v,body:v,seed:_.seed,seq:_.seq,onClose:N}),R]})}function eE({hints:e,className:t=""}){return f.jsx("div",{className:`key-hints ${t}`.trim(),children:e.map(([n,r])=>f.jsxs("span",{className:"key-hint",children:[f.jsx(Or,{k:n}),r]},n))})}const S3={side:"top",align:"start",offset:4,alignOffset:-10,matchWidth:-20,flip:"side",margin:8};function N3({results:e,keyOf:t,row:n,rowClass:r,nav:s,listRef:a,empty:l}){return f.jsxs(Vs,{className:"inline-picker",anchor:"parent",placement:S3,children:[f.jsxs("div",{className:"picker-list",ref:a,children:[e.map((c,u)=>f.jsx("button",{className:Ke("picker-item",r==null?void 0:r(c)),"data-state":Yn({cursor:u===s.index}),onMouseMove:()=>u!==s.index&&s.setIndex(u),onMouseDown:h=>h.preventDefault(),onClick:()=>s.pick(c),children:n(c,u===s.index)},t(c))),e.length===0&&f.jsx("div",{className:"empty",children:l})]}),f.jsx(eE,{hints:[["↑↓","moves"],["tab","inserts"],["esc","dismisses"]]})]})}function T3({fraction:e,className:t}){const r=2*Math.PI*5.5,s=Math.max(0,Math.min(1,Number.isFinite(e)?e:0));return f.jsxs("svg",{className:Ke("ring",t),viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[f.jsx("circle",{className:"ring-track",cx:"7",cy:"7",r:5.5}),f.jsx("circle",{className:"ring-fill",cx:"7",cy:"7",r:5.5,strokeDasharray:`${r*s} ${r}`})]})}function j3(e,t=Pl.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 Wo="";function C3(e){var h;const t=I3(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="",...s]=(e.description??"").split(" · "),a=e.name.replace(/\s*\([^)]*\)$/,""),l=r.match(/^(.+?) (\d+(?:\.\d+)*)(?: with (.+))?$/);if(!(l!=null&&l[2])||l[1]!==a)return{label:e.name,...e.description?{description:e.description}:{}};const u=[l[3]??((h=e.name.match(/\(([^)]*)\)$/))==null?void 0:h[1]),...s].filter(Boolean).join(" · ");return{label:a,version:l[2],...u?{description:u}:{}}}const A3=/(?:^|[./])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 I3(e){const t=e.match(A3),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 tE(e,t,n,r){const s=Z0(e),a=IN(e),l=v=>a&&v===(s==null?void 0:s.id)?a.id:v,c=l(t||n||(s==null?void 0:s.id)||Wo),u=l(t||(s==null?void 0:s.id)||Wo),h=a?e.filter(v=>v!==s):e,p=h.some(v=>v.id===c),g=h.map(v=>({c:v,words:C3(v)})),k=v=>[v.label,v.version].filter(Boolean).join(" "),y=[...s?[]:[{id:Wo,label:r.label,description:r.description}],...g.map(({c:v,words:_})=>{const E=g.filter(x=>k(x.words)===k(_)).length===1?_:void 0,C=E?E.description:v.description;return{id:v.id,label:E?E.label:v.name,...E!=null&&E.version?{suffix:E.version}:{},...E!=null&&E.version&&g.some(x=>x.c!==v&&x.words.label===E.label)?{chip:k(E)}:{},description:v===a?["recommended",C].filter(Boolean).join(" · "):C}}),...c&&!p?[{id:c,label:c}]:[]];if(c!==u){const v=y.find(C=>C.id===c),_=y.findIndex(C=>C.id===u),E=y[_];if(E){const C=(v==null?void 0:v.chip)??(v==null?void 0:v.label)??c;y[_]={...E,description:[`${C} now`,E.description].filter(Boolean).join(" · ")}}}return{rows:y,shown:c,picked:u}}const wl=(e,t)=>`${e} ${t}`;function R3(e){const t=e.indexOf(" ");return t<0?{agent:e,model:Wo}:{agent:e.slice(0,t),model:e.slice(t+1)}}function O3(e,t,n){const r=e.length>1;let s=wl(t,n);return{rows:e.flatMap(l=>{var p;const c=l.short??l.name,u=l.id===t;if(!l.available||!((p=l.models)!=null&&p.length))return u&&(s=wl(l.id,Wo)),[{id:wl(l.id,Wo),label:c,description:l.available?"its own default model; the rest are listed once it has run":l.reason??"not installed",disabled:!l.available}];const h=tE(l.models,u?n:Wo,void 0,{label:`${c} default`,description:`whatever ${l.name} runs when nothing is asked for`});return u&&(s=wl(l.id,h.shown)),h.rows.map(g=>({...g,id:wl(l.id,g.id),...r&&g.id!==Wo?{prefix:c}:{}}))}),shown:s}}function Wd({anchored:e=!1,...t}){return e?f.jsx($3,{...t,anchored:e===!0?{}:e}):f.jsx(M3,{...t})}function $3({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,anchored:s,coverBy:a,id:l,children:c}){return f.jsx(Vs,{className:Ke(r?"":"overlay-box","anchored",n),id:l,anchor:"parent",placement:{side:"bottom",align:"start",cover:!0,margin:0,...s},coverBy:a,onDismiss:e?()=>e():void 0,onKey:t?nE(t):void 0,children:c})}function M3({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,id:s,children:a}){return f.jsx(Vs,{className:"overlay scrim",id:s,onDismiss:e?()=>e():void 0,onKey:t?nE(t):void 0,onClick:l=>{e&&l.target===l.currentTarget&&e()},children:f.jsx("div",{className:Ke(r?"":"overlay-box",n),children:a})})}const nE=e=>t=>{t.key==="Escape"&&(t.stopPropagation(),e())};function L3({text:e,params:t}){if(t.length===0)return e;const n=[];let r=0;for(const[s,a]of t)s>r&&n.push(e.slice(r,s)),n.push(f.jsx("span",{className:"picker-ghost-param",children:e.slice(s,a)},s)),r=a;return r<e.length&&n.push(e.slice(r)),n}function Kr({items:e,filter:t,keyOf:n,row:r,rowClass:s,rowTitle:a,onPick:l,onBack:c,onActive:u,onSide:h,onTab:p,onQuery:g,completionOf:k,narrowTo:y,placeholder:v,initialQuery:_="",initialIndex:E,selectOnMount:C=!1,idleWhen:x,onIdlePick:N,anchored:M=!1,onEscape:J,lead:W,trailing:R,empty:j="no matches",footer:A,keys:D,rowMenu:H,groupOf:Y,groupHead:ae,headAlone:me=!1}){const ye=Jt("picker"),[_e,V]=S.useState(_),O=S.useMemo(()=>t(e,_e),[e,_e,t]),F=S.useRef(null),ne=Gs(),$=p2(C,!ne);S.useEffect(()=>{if(!g)return;const Z=setTimeout(()=>g(_e),150);return()=>clearTimeout(Z)},[_e,g]);const q=d1({results:O,keyOf:n,q:_e,onPick:l,listRef:F,onActive:u,onSide:h,completionOf:k,narrowTo:y,setQ:V,initialIndex:E,idle:(x==null?void 0:x(_))??!1,onIdlePick:N}),{index:ke,ghost:se}=q,ve=typeof D=="function"?D(q.active,_e):D,Re=[];ve!=null&&ve.nav&&Re.push(["↑↓",ve.nav]),ve!=null&&ve.side&&h&&Re.push(["←→",ve.side]),ve!=null&&ve.complete&&(se!=null&&se.accept)&&Re.push(["tab",ve.complete]),ve!=null&&ve.tab&&p&&Re.push(["tab",ve.tab]),ve!=null&&ve.pick&&Re.push(["enter",ve.pick]),ve!=null&&ve.back&&Re.push(["esc",ve.back]);const le=f.jsxs("div",{className:"picker-input",onMouseDown:Z=>{var De;Z.target.closest("input")||(Z.preventDefault(),(De=$.current)==null||De.focus())},children:[W,f.jsxs("div",{className:"picker-caret",children:[f.jsx(Ro,{font:"mono",bare:!0,ref:$,value:_e,onChange:Z=>{V(Z.target.value),q.setIndex(x!=null&&x(Z.target.value)?-1:0)},onKeyDown:Z=>{var De;if(H&&q.active&&(Z.key==="ContextMenu"||Z.key==="F10"&&Z.shiftKey)){const Ve=(De=F.current)==null?void 0:De.querySelector('[data-state~="cursor"]');if(Ve){Z.preventDefault(),Z.stopPropagation(),Hr.open({items:H(q.active),owner:"picker",target:Ve,anchor:Ve.getBoundingClientRect()});return}}q.onKeyDown(Z)||!p||Z.key!=="Tab"||Z.shiftKey||(Z.preventDefault(),p())},placeholder:v}),se&&f.jsxs("div",{className:"picker-ghost","aria-hidden":"true",children:[f.jsx("span",{className:"picker-typed",children:_e}),L3(se)]})]}),R]}),xe=new Map;if(Y)for(const Z of O)xe.set(Y(Z),(xe.get(Y(Z))??0)+1);const Le=f.jsxs("div",{className:"picker-list",ref:F,children:[O.map((Z,De)=>{const Ve=Y==null?void 0:Y(Z),ze=Ve!==void 0&&(me||xe.size>1)&&(De===0||(Y==null?void 0:Y(O[De-1]))!==Ve)?f.jsx("div",{className:"picker-group",children:(ae==null?void 0:ae(Ve,xe.get(Ve)??0))??Ve}):null;return f.jsxs(S.Fragment,{children:[ze,f.jsx("button",{className:Ke("picker-item",s==null?void 0:s(Z)),"data-state":Yn({cursor:De===ke}),title:a==null?void 0:a(Z),onMouseMove:()=>De!==ke&&q.setIndex(De),onClick:()=>{var it;q.pick(Z),(it=$.current)==null||it.focus()},...ye.contextMenu(()=>(H==null?void 0:H(Z))??[]),children:r(Z,De===ke,_e)})]},n(Z))}),O.length===0&&f.jsx("div",{className:"empty",children:typeof j=="function"?j(_e):j}),A==null?void 0:A(_e,O)]}),oe=Re.length>0&&f.jsx(eE,{hints:Re});return f.jsxs(Wd,{onClose:c,onEscape:J,boxClass:"picker",anchored:M,coverBy:W?".picker-input > *:first-child":R?".picker-input > *:last-child":void 0,children:[le,Le,oe]})}function Bs({value:e,reads:t,options:n,onChange:r,placeholder:s,hint:a,className:l,onClose:c}){const[u,h]=S.useState(!1),p=()=>{h(!1),c==null||c()},g=t??e,k=n.find(v=>v.id===g),y=(k==null?void 0:k.chip)??(k==null?void 0:k.label)??g;return f.jsxs("span",{className:"chip-picker",children:[f.jsx(Be,{variant:"ghost",tone:"chrome",mono:!0,on:u,className:Ke("chip-picker-btn",l),...It(a),onClick:()=>u?p():h(!0),children:y}),u&&f.jsx(Kr,{anchored:{flip:"both",margin:8},onEscape:p,items:n,filter:(v,_)=>{const E=_.trim().toLowerCase().split(/\s+/).filter(Boolean);return v.filter(C=>{const x=`${C.prefix??""} ${C.label??C.id} ${C.suffix??""} ${C.id}`.toLowerCase();return E.every(N=>x.includes(N))})},keyOf:v=>v.id,initialIndex:v=>Math.max(0,v.findIndex(_=>_.id===e)),lead:f.jsx(Be,{tone:"chrome",mono:!0,on:!0,className:"chip-picker-lead",onClick:p,children:y}),placeholder:s,rowClass:()=>"picker-row",row:v=>f.jsxs(f.Fragment,{children:[v.id===e&&f.jsx("span",{className:"row-current","aria-hidden":"true"}),f.jsxs("span",{className:Ke("chip-option",v.disabled&&"chip-option-off"),"aria-disabled":v.disabled,children:[f.jsxs("span",{className:"chip-option-name",children:[v.prefix?`${v.prefix} `:null,v.label??v.id,v.suffix?f.jsx("span",{className:"chip-option-suffix",children:` ${v.suffix}`}):null]}),v.description&&f.jsx("span",{className:"chip-option-desc row-dim",children:v.description})]})]}),onPick:v=>{v.disabled||(r(v.id),p())},onBack:p})]})}function rE({choices:e,value:t,current:n,what:r,defaultLabel:s,defaultDescription:a,placeholder:l,className:c,onChange:u,onClose:h}){if(e.length===0)return null;const{rows:p,shown:g,picked:k}=tE(e,t,n,{label:s,description:a}),y=p.find(_=>_.id===g),v=(y==null?void 0:y.chip)??(y==null?void 0:y.label)??g;return f.jsx(Bs,{value:k,reads:g,options:p,onChange:u,onClose:h,className:c,hint:t?`asked for ${v}; click to change`:`${v}, the agent's choice; click to pick ${r}`,placeholder:l})}function oE(e){const[t,n]=ho(_t.effortPrefix+(e??""),Wo,r=>r??"");return[t,n]}function Dh({efforts:e,value:t,current:n,onChange:r,onClose:s}){return f.jsx(rE,{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:s})}function P3(e){const[t,n]=ho(_t.modePrefix+((e==null?void 0:e.id)??""),th,r=>Xl.some(s=>s.id===r)?r:th);return[t,n]}const D3=e=>{var t;return((t=Xl.find(n=>n.id===e))==null?void 0:t.description)??""};function b0({value:e,onChange:t,onClose:n}){return f.jsx(Bs,{value:e,options:Xl.map(r=>({id:r.id,label:r.name,description:r.description})),onChange:t,onClose:n,className:Ke("mode-chip",e!=="auto"&&"mode-held"),hint:`${e}: ${D3(e)}. Click to change`,placeholder:"what the agent may do without asking"})}function sE(e){const[t,n]=ho(_t.modelPrefix+(e??""),Wo,r=>r??"");return[t,n]}function iE(e,t){try{localStorage.setItem(_t.modelPrefix+e,t)}catch{}}function zh({models:e,value:t,current:n,onChange:r,onClose:s}){return f.jsx(rE,{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:s})}function aE({agents:e,agent:t,model:n,onChange:r,onClose:s}){const{rows:a,shown:l}=O3(e,t,n);if(a.length===0)return null;const c=a.find(h=>h.id===l),u=c?[c.prefix,c.label,c.suffix].filter(Boolean).join(" "):n;return f.jsx(Bs,{value:l,options:a,onChange:h=>{const p=R3(h);r(p.agent,p.model)},onClose:s,className:"model-chip",hint:`${u} works on the new worktree; click to change`,placeholder:"which agent and model work on it"})}function lE(e){const t=Fd(e),[n,r]=ho(_t.profilePrefix+((e==null?void 0:e.id)??""),(e==null?void 0:e.config.defaultProfile)??"",a=>a??void 0);return[t.length===0?void 0:t.includes(n)?n:e==null?void 0:e.config.defaultProfile,r]}function z3({repo:e,value:t,onChange:n,onClose:r}){const s=Fd(e);if(s.length===0||!t)return null;const a=(e==null?void 0:e.config.profiles)??{},l=(e==null?void 0:e.configFile)??"the settings",c=u=>{var g;const h=((g=a[u])==null?void 0:g.run)??[],p=h.length>0?`runs ${h.join(", ")}`:"runs nothing";return u===(e==null?void 0:e.config.defaultProfile)?`${p}; the default in ${l}`:p};return f.jsx(Bs,{value:t,options:s.map(u=>({id:u,description:c(u)})),onChange:n,onClose:r,hint:s.length>1?`${t}: ${c(t)}. Click to change`:`the only profile in ${l}`,placeholder:"the profile the worktree runs"})}function Gl(e,t,n){if(!t)return e;const r=new Set(t.map(l=>l-n)),s=[];let a="";for(let l=0;l<e.length;l++)r.has(l)?(a&&s.push(a),a="",s.push(f.jsx("b",{className:"hit",children:e[l]},l))):a+=e[l];return a&&s.push(a),s}function F3({c:e,query:t}){const n=t.trim();return f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"picker-name",children:["/",Gl(e.name,n?cg(e.name,n):null,0)]}),f.jsx("span",{className:"picker-desc row-dim",children:e.description})]})}function rr({label:e,hint:t,current:n=!1}){return f.jsxs(f.Fragment,{children:[n&&f.jsx("span",{className:"row-current","aria-hidden":"true"}),f.jsx("span",{className:"picker-label",children:e}),t?f.jsx("span",{className:"picker-hint row-dim",children:t}):null]})}function B3(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 U3=/ \| | - | \u2013 | \u2014 | \u00b7 |: /,H3=/^(\d+|[0-9a-f]{8}-[0-9a-f-]{27}|[0-9a-f]{12,})$/i,W3=/^[[:$*{]|\[/;function K3(e){const t=new Map,n=e.filter(a=>!!a.title);if(new Set(n.map(a=>a.path)).size<2)return t;const r=n.map(a=>({path:a.path,parts:a.title.split(U3).map(l=>l.trim()).filter(Boolean)})),s=new Map;for(const{path:a,parts:l}of r)for(const c of l)s.set(c,(s.get(c)??new Set).add(a));for(const{path:a,parts:l}of r){const c=l.filter(u=>{var h;return(((h=s.get(u))==null?void 0:h.size)??0)<2});c.length>0&&t.set(a,c.join(" "))}return t}function dg(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(H3.test(r)||W3.test(r))continue;const s=r.replace(/[-_.]+/g," ").trim();if(s)return s[0].toUpperCase()+s.slice(1)}return"Home"}const qp=8,Z3=3,q3=50,G3=3;function V3(e,t,n=[]){const r=new Map,s=[],a=new Map;for(const l of(t==null?void 0:t.routes)??[]){if(l.endpoint)continue;const c=l.dynamic?mO(l.path):null;c?(s.push(c),a.set(l.path,l)):r.set(l.path,l)}return{history:e,statics:r,templates:s,templateRoutes:a,unseen:(t==null?void 0:t.unseen)??{},titles:K3(e),links:new Map(n.map(l=>[l.path,l.text]))}}function cE(e){if(!e)return"/";try{const t=new URL(e);return t.pathname+t.search+t.hash}catch{return"/"}}function Y3(e){const t=e.trim();return/^[/?#]/.test(t)?t:`/${t}`}function Q3(e,t){const n=/^[/?#]/.test(t)?e:e.replace(/^\//,"");return t&&n.toLowerCase().startsWith(t.toLowerCase())?n:null}const uE=e=>/^\[\[?\.\.\.|^\*$|^\$$/.test(e),Tl=e=>uE(e)||/[[:$*{]/.test(e)&&!/^[^[{:$*]+\?$/.test(e),X3=e=>Td(`/${e}`).text.slice(1),fg=e=>e.split("/").filter(Boolean);function pg(e,t){const n=t.startsWith("/"),r=t.replace(/^\//,"").split("/"),s=fg(e);let a="";const l=[],c=g=>{const k=X3(g);l.push([a.length,a.length+k.length]),a+=k};for(let g=0;g<r.length;g++){const k=r[g],y=s[g];if(y===void 0)return null;if(g<r.length-1){if(uE(y))return{show:t,accept:t};if(Tl(y)){if(!k)return null}else if(k.toLowerCase()!==y.toLowerCase())return null;a+=`${Tl(y)?k:y}/`;continue}if(Tl(y))k?a+=k:c(y);else{if(!y.toLowerCase().startsWith(k.toLowerCase()))return null;a+=y}}for(const g of s.slice(r.length))a+="/",Tl(g)?c(g):a+=g;const u=n?1:0,h=(n?"/":"")+a,p=l[0];return{show:h,accept:p?h.slice(0,p[0]+u):h,params:l.map(([g,k])=>[g+u,k+u])}}function J3(e,t){const n=pg(e,t);return n?n.accept.length>t.length?n.accept:t:Td(e).literal}function dE(e,t){if(e.kind==="go")return null;if(e.template){const n=pg(e.path,t);return n&&n.show.length>t.length?n:null}return Q3(e.path,t)}const e5=e=>e.trim().replace(/^\//,"").toLowerCase();function fE(e,t){for(let n=0;n<e.length;n++)if("/-_.#".includes(e[n])&&e.startsWith(t,n+1))return!0;return!1}function t5(e,t,n){const r=e.replace(/^\//,"").toLowerCase(),s=t.toLowerCase();return r===n?100:r.startsWith(n)?80:fE(r,n)?60:s.startsWith(n)?50:s.split(/\s+/).some(a=>a.startsWith(n))?45:r.includes(n)||s.includes(n)?20:0}function n5(e,t){const{text:n,literal:r}=Td(e);return r.replace(/^\//,"").toLowerCase().startsWith(t)?80:pg(e,t)?70:fE(n.replace(/^\//,"").toLowerCase(),t)?60:0}function r5(e,t){const n=fg(e).findIndex(Tl);return n>=0&&t.split("/").length>n}function Ml(e,t,n){var c;const r=e.statics.get(t),s=r?null:gO(e.templates,t),a=(r==null?void 0:r.file)??(s?(c=e.templateRoutes.get(s.path))==null?void 0:c.file:void 0),l=a?e.unseen[a]:void 0;return{kind:"page",path:t,title:e.titles.get(t)||e.links.get(t)||dg(t),template:!1,visited:n<Number.POSITIVE_INFINITY,...a?{file:a}:{},...l?{badge:l}:{},rank:n,group:(s==null?void 0:s.path)??t,score:0}}function pE(e,t){const n=e.unseen[t.file];return{kind:"page",path:t.path,title:dg(t.path),template:!0,visited:!1,file:t.file,...n?{badge:n}:{},rank:Number.POSITIVE_INFINITY,group:t.path,score:0}}function Du({rank:e,group:t,score:n,...r}){return r}const ud=e=>fg(e).length,dd=e=>e.badge==="new"?0:e.badge==="changed"?1:2;function o5(e,t){const n=new Set,r=[];e.history.forEach((p,g)=>{if(p.path===t)return;const k=Ml(e,p.path,g);n.has(k.group)||(n.add(k.group),r.push(k))});const s=new Set(r.map(p=>p.path)),a=r.filter(p=>p.badge);for(const[p,g]of e.statics)e.unseen[g.file]&&p!==t&&!s.has(p)&&a.push(Ml(e,p,Number.POSITIVE_INFINITY));for(const p of e.templateRoutes.values())e.unseen[p.file]&&!n.has(p.path)&&a.push(pE(e,p));a.sort((p,g)=>dd(p)-dd(g)||p.rank-g.rank);const l=r.filter(p=>!p.badge),c=a.slice(0,qp-Math.min(Z3,l.length));for(const p of l)c.length<qp&&c.push(p);const u=new Set(c.map(p=>p.path)),h=[...e.statics.keys(),...[...e.links.keys()].filter(p=>!e.statics.has(p))].filter(p=>p!==t&&!u.has(p)&&!s.has(p)).sort((p,g)=>ud(p)-ud(g)||(p<g?-1:p>g?1:0));for(const p of h){if(c.length>=qp)break;c.push(Ml(e,p,Number.POSITIVE_INFINITY))}return c.map(Du)}function s5(e,t,n){var g;const r=e5(t),s=Y3(t),a=new Map;e.history.forEach((k,y)=>{k.path!==n&&a.set(k.path,Ml(e,k.path,y))});for(const k of[...e.statics.keys(),...e.links.keys()])k!==n&&!a.has(k)&&a.set(k,Ml(e,k,Number.POSITIVE_INFINITY));const l=[];for(const k of a.values()){const y=t5(k.path,k.title,r);y>0&&l.push({...k,score:y})}let c=null;for(const k of e.templates){const y=e.templateRoutes.get(k.path);if(!c&&!e.statics.has(s)&&k.re.test(s)){c=y;continue}const v=n5(k.path,r);v>=60&&l.push({...pE(e,y),score:v})}l.sort((k,y)=>y.score-k.score||k.rank-y.rank||dd(k)-dd(y)||ud(k.path)-ud(y.path)||(k.path<y.path?-1:k.path>y.path?1:0));const u=new Map,h=[];for(const k of l){if(!k.template&&k.group!==k.path){const y=u.get(k.group)??0;if(y>=G3&&!r5(k.group,r))continue;u.set(k.group,y+1)}if(h.push(k),h.length>=q3)break}if(h.some(k=>k.score===100))return h.map(Du);const p={kind:"go",path:s,title:dg((c==null?void 0:c.path)??s)};return c||(((g=h[0])==null?void 0:g.score)??0)<80?[p,...h.map(Du)]:[...h.map(Du),p]}function hE(e,{query:t,current:n,here:r}){return t===n||t.trim()===""?o5(e,r):s5(e,t,r)}const i5=[],a5=[];function mE(e,t){const n=P(a=>(t?a.visits[t]:void 0)??i5),r=At(e,"pages"),s=At(e,"links");return gt([e],()=>{hx(r)&&Wt.post(e,{type:"links"})}),S.useMemo(()=>V3(n,r,s),[n,r,s])}function l5({row:e}){if(e.kind!=="page"||!e.template)return f.jsx("span",{className:"bar-route-path row-dim",children:e.path});const{text:t,params:n}=Td(e.path),r=[];let s=0;for(const[a,l]of n)a>s&&r.push(t.slice(s,a)),r.push(f.jsx("span",{className:"bar-route-param",children:t.slice(a,l)},a)),s=l;return s<t.length&&r.push(t.slice(s)),f.jsx("span",{className:"bar-route-path row-dim",children:r})}function gE({row:e}){return f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"picker-label",children:e.title}),f.jsx(l5,{row:e}),e.kind==="go"?f.jsx("span",{className:"picker-hint row-dim",children:"go"}):e.badge?f.jsx("span",{className:e.badge==="new"?"badge-new":"badge-changed",children:e.badge}):null]})}const kE=e=>e.kind==="page"&&e.file?e.file:e.path,yE=(e,t)=>e.kind==="page"&&e.template?J3(e.path,t):null,wE=e=>e.kind==="page"&&e.template?"fills in the parameter":"goes there";function vE(e,t,n){return e.kind!=="page"?[]:Od([...e.file&&t.dir?is({id:t.worktreeId,dir:t.dir},e.file,{},n):[],Bx,...e.visited?B3(t.repoId,e.path,n):[]])}function c5({worktreeId:e,repoId:t,url:n}){const r=ht(),s=ot(),a=P(k=>{const y=fn(k,e);return y?y.worktree.path:null}),l=mE(e,t),c=cE(n),u=n?Nd(n):null,h=S.useCallback((k,y)=>hE(l,{query:y,current:c,here:u}),[l,c,u]),p=S.useCallback(k=>k===c||k.trim()==="",[c]),g=()=>r({a:"close"});return f.jsx(Kr,{anchored:{matchWidth:0},items:a5,filter:h,initialQuery:c,selectOnMount:!0,idleWhen:p,onIdlePick:()=>{Wt.post(e,{type:"reload"}),g()},keyOf:k=>`${k.kind}:${k.path}`,rowClass:()=>"picker-row",rowTitle:kE,completionOf:(k,y)=>p(y)?null:dE(k,y),narrowTo:yE,onPick:k=>{Wt.post(e,{type:"navigate",path:k.path}),g()},onBack:g,rowMenu:k=>vE(k,{worktreeId:e,repoId:t,dir:a},{sock:s,dispatch:r}),placeholder:"type a path",keys:k=>({complete:"completes the path",pick:k?wE(k):"reloads",back:"closes"}),empty:"no pages yet; type a path",row:k=>f.jsx(gE,{row:k})})}function bE(e,t){const n=t.trim();return f.jsx(rr,{label:Gl(e.label,n?cg(e.label,n):null,0),hint:e.hint&&f.jsx(Or,{k:e.hint})})}function xE({anchored:e,trailing:t}){const n=ht(),r=W_(),s=P(a=>{var l;return((l=a.paletteReturn)==null?void 0:l.mode)==="commands"?a.paletteReturn.q:""});return f.jsx(Kr,{anchored:e,trailing:t,items:r,filter:K_,rowClass:()=>"picker-row",keyOf:a=>a.id,onPick:(a,l)=>{a.sub?n({a:"palette-return",v:{mode:"commands",q:l}}):n({a:"close"}),a.run()},onBack:()=>n({a:"close"}),placeholder:"run a command…",keys:{pick:"runs",back:"closes"},initialQuery:s,empty:"no matching command",row:(a,l,c)=>bE(a,c)})}function _E(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),s=e.map(l=>{const c=n.get(l)??(r.some(u=>l.startsWith(u))?{path:l,xy:"??"}:void 0);return c?{path:l,status:c}:{path:l}}),a=new Set(e);for(const l of t)!a.has(l.path)&&!l.path.endsWith("/")&&s.push({path:l.path,status:l});return s}function x0(e,t){const n=e.split("/"),r=t.split("/");for(let s=0;;s++){const a=n[s],l=r[s];if(a===void 0||l===void 0)return n.length-r.length;const c=s===n.length-1,u=s===r.length-1;if(c!==u)return c?-1:1;if(a!==l)return a<l?-1:1}}function EE(e,t,n,r=50){const s=_E(e,t),a=n.trim().toLowerCase();if(!a){const c=new Map(t.map((g,k)=>[g.path,k])),u=g=>{var k;return c.get(((k=g.status)==null?void 0:k.path)??"")??c.get(g.path)??Number.MAX_SAFE_INTEGER},h=s.filter(g=>g.status).sort((g,k)=>u(g)-u(k)||x0(g.path,k.path)),p=s.filter(g=>!g.status).sort((g,k)=>x0(g.path,k.path));return{rows:[...h,...p].slice(0,r),changed:Math.min(h.length,r)}}const l=NE(s,a);return l.sort((c,u)=>u.score-c.score||c.row.path.localeCompare(u.row.path)),{rows:l.slice(0,r).map(c=>c.row),changed:0}}function SE(e,t){const n=e.toLowerCase(),r=_0(n,t);return r<=0?0:_0(n.slice(n.lastIndexOf("/")+1),t)>0?r+10:r}function NE(e,t){const n=[];for(const r of e){const s=SE(r.path,t);s>0&&n.push({row:r,score:r.status?s+4:s})}return n}function u5(e,t,n,r,s){const a=r.trim().toLowerCase();if(!a)return EE(e,n,r,s).rows.map(u=>({kind:"file",path:u.path,status:u.status}));const l=NE(_E(e,n),a).map(({row:u,score:h})=>({row:{kind:"file",path:u.path,status:u.status},score:h}));for(const u of t){const h=SE(u,a);h>0&&l.push({row:{kind:"folder",path:u},score:h})}const c=u=>u.kind==="folder"?1:0;return l.sort((u,h)=>h.score-u.score||c(u.row)-c(h.row)||u.row.path.localeCompare(h.row.path)),l.slice(0,s).map(u=>u.row)}function d5(e,t){const n=e.toLowerCase(),r=[];let s=0;for(const a of t.toLowerCase()){const l=n.indexOf(a,s);if(l===-1)return null;r.push(l),s=l+1}return r}function _0(e,t){let n=0,r=0,s=0;for(const a of t){const l=e.indexOf(a,r);if(l===-1)return 0;s=l===r?s+1:1,n+=s+(l===0||e[l-1]==="/"||e[l-1]==="."?3:0),r=l+1}return n+Math.max(0,40-e.length/4)}function f5(e){const t=e.lastIndexOf("/");return t===-1?[e,""]:[e.slice(t+1),e.slice(0,t+1)]}const E0=[],p5=[],h5=[];function m5({worktreeId:e}){var _;const t=ht(),n=ot(),r=Un();gt([e,n],()=>Md(e,r.getState(),{sock:n,dispatch:t}));const s=Px(e),a=s.files??p5,l=((_=s.git)==null?void 0:_.files)??h5,c=W_(),u=P(E=>{var C;return((C=E.paletteReturn)==null?void 0:C.mode)==="quick-open"?E.paletteReturn.q:""}),h=P(E=>{var x;const C=(x=fn(E,e))==null?void 0:x.worktree;return C?C.path:null}),p=P(E=>{var C;return((C=fn(E,e))==null?void 0:C.repoId)??null}),g=P(E=>{var C;return((C=td(E))==null?void 0:C.worktreeId)===e}),k=mE(e,p),y=s.page.url?Nd(s.page.url):null,v=S.useCallback((E,C)=>C.startsWith(">")?K_(c,C.slice(1)).map(x=>({kind:"cmd",c:x})):C.startsWith("/")?g?hE(k,{query:C,current:"/",here:y}).map(x=>({kind:"page",page:x})):E0:EE(a,l,C).rows.map(x=>({kind:"file",path:x.path,status:x.status})),[c,a,l,g,k,y]);return f.jsx(Kr,{items:E0,filter:v,keyOf:E=>E.kind==="cmd"?`c:${E.c.id}`:E.kind==="page"?`p:${E.page.kind}:${E.page.path}`:`f:${E.path}`,rowClass:E=>E.kind==="file"?"qo-file":"picker-row",rowTitle:E=>E.kind==="page"?kE(E.page):void 0,completionOf:(E,C)=>E.kind==="page"?dE(E.page,C):null,narrowTo:(E,C)=>E.kind==="page"?yE(E.page,C):null,onPick:(E,C)=>{E.kind==="cmd"?(E.c.sub?t({a:"palette-return",v:{mode:"quick-open",q:C}}):t({a:"close"}),E.c.run()):E.kind==="page"?(Wt.post(e,{type:"navigate",path:E.page.path}),t({a:"close"})):(Vn({dispatch:t},{worktreeId:e,path:E.path,view:Ti(E.path)}),t({a:"close"}))},onBack:()=>t({a:"close"}),rowMenu:E=>E.kind==="file"&&h?is({id:e,dir:h},E.path,{},{sock:n,dispatch:t}):E.kind==="page"&&p?vE(E.page,{worktreeId:e,repoId:p,dir:h},{sock:n,dispatch:t}):[],placeholder:"jump to file · type > for commands, / for pages",keys:(E,C)=>C.startsWith("/")?{complete:"completes the path",pick:(E==null?void 0:E.kind)==="page"?wE(E.page):void 0,back:"closes"}:{pick:"opens",back:"closes"},initialQuery:u,empty:E=>E.startsWith(">")?"no matching command":E.startsWith("/")?g?"no pages yet; type a path":"no preview running":"no matches",row:(E,C,x)=>E.kind==="cmd"?bE(E.c,x.slice(1)):E.kind==="page"?f.jsx(gE,{row:E.page}):Fh(E.path,E.status,x,{gutter:l.length>0})})}function Fh(e,t,n,{folder:r=!1,gutter:s=!0}={}){const[a,l]=f5(e),c=n.trim()?d5(e,n.trim()):null;return f.jsxs(f.Fragment,{children:[s&&f.jsx("span",{className:`xy ${t?ym(t.xy):""}`,children:t?wm(t.xy):""}),f.jsxs("span",{className:"name",children:[Gl(a,c,l.length),r&&"/"]}),f.jsx("span",{className:"dir row-dim",children:l&&f.jsxs(f.Fragment,{children:["",Gl(l,c,0),""]})}),t&&f.jsx(A1,{f:t})]})}const g5=e=>Xl.some(t=>t.id===e);function k5(e){return[...Xl.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"}]}function y5(e,t){const n=new Set(e.map(r=>r.name));return[...e,...t.filter(r=>!n.has(r.name))]}function w5(e,t){const n=/^\/(\S*)([\s\S]*)$/.exec(e);if(!n)return null;const r=n[1]??"";return t.some(s=>s.name===r)?{name:r,args:(n[2]??"").trim()}:null}const S0=[],v5=[],b5=new Set(["ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),x5=e=>({kind:"cmd",c:e});function _5(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 E5(e){return e.kind==="cmd"?`/${e.c.name} `:e.kind==="folder"?`@${e.path}/ `:e.kind==="changes"?"@changes ":`@${e.path} `}const N0="still uploading what is attached; send again in a moment";function Bh({active:e,draft:t,archived:n,greenfield:r,placement:s="dock"}){var hc,Li,Pi,ws,ei,Fa,mc,gc;const a=s==="screen",l=ht(),c=ot(),u=Un(),h=!!t,p=(e==null?void 0:e.worktree.id)??null,g=e==null?void 0:e.worktree.repoId,k=n?n.id:tc(e),y=At(k,"draft"),v=At(k,"attachments"),_=At(k,"notice"),E=((hc=e==null?void 0:e.worktree.owns)==null?void 0:hc.join(", "))??"",C=S.useRef({id:p,owns:E});gt([p,E],()=>{const K=C.current;C.current={id:p,owns:E},!(K.id!==p||K.owns===E||!E||!k||n)&&l({a:"notice",id:k,text:`Running its own ${E} here now: this branch changed it.`})});const x=At(k,"mark"),N=(x==null?void 0:x.by)==="walk"?x:void 0,M=At(p,"chat"),J=At(p,"queue"),W=S.useMemo(()=>p&&!h?ex(M):null,[p,h,M]),R=At(p,"askParked"),j=At(p,"sending"),A=S.useMemo(()=>p&&!h&&!j?l$(M):null,[p,h,j,M]),D=At(p,"askRevived"),H=!W&&A&&D===A.id?A:null,Y=W&&R!==W.id?W:H,ae=W?R===W.id?W:null:A&&!H?A:null,me=S.useRef(null),ye=Gs(),_e=Tm(),V=At(_e,"page"),O=rc(),{onPaste:F,onPasteKey:ne,onPasteKeyUp:$}=OM(k,p),q=K=>k&&l({a:"set-draft",id:k,text:K}),ke=P(K=>K.clientId),se=P(K=>K.repos.find(He=>He.id===(e==null?void 0:e.worktree.repoId))??null),ve=P(K=>K.defaultAgent),Re=P(K=>K.agentChosen),le=h||!!r,xe=!le&&!!e&&!e.worktree.agent,Le=le||xe,oe=(t==null?void 0:t.agent)??ve,Z=P(K=>K.agents.find(He=>He.id===(Le?oe:e==null?void 0:e.worktree.agent))),De=!!(Z!=null&&Z.quick),Ve=(Z==null?void 0:Z.models)??S0,ze=(Z==null?void 0:Z.efforts)??S0,[it,Je]=sE(oe),[en,kt]=oE(oe),tn=P(K=>K.agents),st=(K,He)=>{if(K===oe){Je(He);return}iE(K,He),h?l({a:"draft-agent",id:K}):c==null||c.send({t:"set-default-agent",agent:K})},X=At(p,"model"),we=At(p,"effort"),Qe=At(p,"usage")??(e==null?void 0:e.usage),[he]=lE(se),Oe=(t==null?void 0:t.profile)??he,[Mt,an]=P3(se),vt=(e==null?void 0:e.worktree.mode)??th,Dn=P(K=>K.picking),Lt=P(K=>K.layout.term),ln=ux((e==null?void 0:e.procs)??[]),Tt=Jt("composer"),nn=At(p,"files"),Ut=S.useMemo(()=>fx(nn??v5),[nn]),We=At(p,"git"),Gt=(We==null?void 0:We.files.length)??(e==null?void 0:e.dirty)??0,pn=(We==null?void 0:We.unpushed)??(e==null?void 0:e.unpushed)??0,Kt=P(K=>{var He;return p?(He=K.shipping[p])==null?void 0:He.op:void 0}),xn=P(K=>{var He;return p?(He=K.shipping[p])==null?void 0:He.step:void 0}),hn=P(K=>ba(K,g)),mn=P(K=>{var He;return hn?(He=K.shipping[hn.id])==null?void 0:He.op:void 0}),gn=hn&&se&&le?b1(se.defaultBranch,hn):null,kn=P(K=>h?N$(K.rows,g,oe,ve):p),U=At(kn,"commands"),de=U.some(K=>K.name==="compact"),Ae=(e==null?void 0:e.agent)==="working"||(e==null?void 0:e.agent)==="waiting",et=Ae&&!!p&&!h,ee=e==null?void 0:e.worktree.lastTurn,Se=!y.trim()&&v.length===0,be=!h&&!r&&Se&&!Ae?ee:void 0,fe=!h&&!r&&e&&ki(e.worktree)?e.worktree.landing:void 0,Pe=!!(fe!=null&&fe.ready)&&!fe.stale&&!wu(fe,Gt,De,Z==null?void 0:Z.name),rt=Se&&(!Ae||Pe)?fe:void 0,St=Gt||(((Li=We==null?void 0:We.committed)==null?void 0:Li.length)??0),bt=!h&&!r&&Se&&!Ae&&!!e,cn=!!(e!=null&&e.worktree.landed)&&Gt===0,at=bt&&cn,Dt=bt&&!at?e.worktree.pr:void 0,un=!cn&&((Pi=e==null?void 0:e.worktree.pr)==null?void 0:Pi.state)==="open"?e.worktree.pr:void 0,zn=!!un&&(Gt>0||pn>0),An=((ws=e==null?void 0:e.worktree.pr)==null?void 0:ws.state)==="closed",lr=wi((se==null?void 0:se.config)??{}),Rt=S.useMemo(()=>k5(Bu(wi((se==null?void 0:se.config)??{}),se==null?void 0:se.defaultBranch)),[se]),cr=de&&!Ae,wn=()=>p&&(c==null?void 0:c.send({t:"chat",worktreeId:p,text:"/compact"})),Xn=()=>[{id:"compact",label:"compact the context",detail:"shrink the chat to a summary",disabled:de?Ae?"wait for the turn to end":void 0:"this agent offers no compact command",onClick:wn}],[Fn,In]=S.useState(0),[oo,qr]=S.useState(null),[Vt,Go]=S.useState(null),so=S.useRef(null),dt=k&&!n?p0(y,Fn):null,Zn=dt!==null&&dt.from!==oo&&!N,je=dt==null?void 0:dt.kind,Ue=dt==null?void 0:dt.query,yt=S.useMemo(()=>{if(Ue===void 0)return[];if(je==="command")return Vz(y5(Rt,U),Ue).slice(0,8).map(x5);const K=[],He=(We==null?void 0:We.files.length)??0;return He>0&&"changes".startsWith(Ue.toLowerCase())&&K.push({kind:"changes",n:He}),K.push(...u5(nn??[],Ut,(We==null?void 0:We.files)??[],Ue,8)),K},[je,Ue,nn,Ut,We,U,Rt]),ft=S.useRef(null),rn=S.useRef(null),Qt=()=>{var K;return(K=me.current??ft.current)==null?void 0:K.focus()},B=Qt;gt([r?e==null?void 0:e.worktree.id:null],()=>{if(!r)return;const K=requestAnimationFrame(()=>{var Ft;const He=document.activeElement;(!He||He===document.body)&&((Ft=ft.current)==null||Ft.focus())});return()=>cancelAnimationFrame(K)});const ue=P(K=>K.focusChat),Fe=S.useRef(ue),tt=!!Dx();gt([ue],()=>{if(ue===Fe.current||(Fe.current=ue,tt!==!!r))return;const K=requestAnimationFrame(Qt);return()=>cancelAnimationFrame(K)});const pt=Y==null?void 0:Y.id,jt=S.useRef({id:p,askUpId:pt});gt([p,pt],()=>{const K=jt.current;if(jt.current={id:p,askUpId:pt},pt||!K.askUpId||K.id!==p||tt!==!!r||ye&&!ae)return;const He=requestAnimationFrame(()=>{var Rn;const Ft=document.activeElement;(!Ft||Ft===document.body)&&((Rn=ft.current)==null||Rn.focus())});return()=>cancelAnimationFrame(He)});const vn=P(K=>K.walked),qn=S.useRef(vn);gt([vn],()=>{if(vn===qn.current||(qn.current=vn,tt!==!!r))return;const K=requestAnimationFrame(()=>{const He=document.activeElement;(!He||He===document.body||He.closest(".rail"))&&Qt()});return()=>cancelAnimationFrame(K)});const Gr=d1({results:yt,keyOf:K=>K.kind==="cmd"?`c:${K.c.name}`:K.kind==="changes"?"changes":`f:${K.path}`,q:(dt==null?void 0:dt.query)??"",listRef:so,tabPicks:!0,onPick:K=>{if(!dt)return;const{text:He,caret:Ft}=Gz(y,dt,E5(K));q(He),qr(dt.from),Go(K.kind==="cmd"&&K.c.hint?{name:K.c.name,hint:K.c.hint}:null),requestAnimationFrame(()=>{const Rn=ft.current;Rn&&(Rn.focus(),Rn.setSelectionRange(Ft,Ft),In(Ft))})}}),Hn=p||n?w3(y):null,ps=Vt&&y===`/${Vt.name} `?Vt.hint:null,Vr=Hn===""&&e?h?" 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,Tr=ps??Vr,Jn=(e==null?void 0:e.worktree.title)??"untitled",$r=(ei=ee==null?void 0:ee.recap)==null?void 0:ei.text,Ot=()=>{p&&Hs(c,l,{t:"land",worktreeId:p})},lt=K=>{p&&(c==null||c.send({t:"judge",worktreeId:p,...K?{note:K}:{}}))},Vo=!!((Fa=se==null?void 0:se.config.check)!=null&&Fa.trim()),yn=Pm(fe,Gt,De),Ht=bt&&!Kt&&!le&&ki(e.worktree)&&!cn&&!An&&St>0&&(!fe||!!fe.stale||yn==="unanswered"),jr="Archive this worktree when you are done here; the rail's archived section brings it back with its chat.",yr=zn?"update":"land",Ne=se?yd(se):"main",I=zn&&un?`Commit, take ${Ne} in and push the branch; PR #${un.number} takes the new commits.`:`${Bu(lr,se==null?void 0:se.defaultBranch)}.`,L=p?at?{word:"archive",line:((mc=e==null?void 0:e.worktree.pr)==null?void 0:mc.state)==="merged"?os(e.worktree.pr):`landed on ${(se==null?void 0:se.defaultBranch)??"main"}.`,tip:jr,run:()=>_i(c,l,[p])}:(Dt==null?void 0:Dt.state)==="open"&&!zn?x1(Dt)?{word:"merge",line:vu($r??os(Dt)),tip:`${os(Dt)} Merge the PR now, by the method the repo allows.`,run:Ot,ships:!0}:{word:"view",line:vu($r??os(Dt)),tip:`${os(Dt)} Open the PR on GitHub.`,run:()=>window.open(Dt.url,"_blank")}:(Dt==null?void 0:Dt.state)==="closed"?{word:"archive",line:os(Dt),tip:`${os(Dt)} ${jr}`,run:()=>_i(c,l,[p])}:Ht?{word:"check",line:(fe==null?void 0:fe.subject)??vu($r??dL(St)),tip:E1(fe,Vo,yn),run:lt}:rt!=null&&rt.ready&&!wu(rt,Gt,De,Z==null?void 0:Z.name)?{word:yr,line:rt.subject??vu($r??(yv(rt,St)||"ready")),tip:[yv(rt,St),uL(Ne,e==null?void 0:e.behind),I,rt.subject?"Tab edits the message first.":""].filter(Boolean).join(" "),run:Ot,ships:!0}:null:null,te=((L==null?void 0:L.word)==="land"||(L==null?void 0:L.word)==="update"||(L==null?void 0:L.word)==="check")&&rt?fL(rt,yn):null,pe=S.useRef(null);Kt!=="land"&&(pe.current=p&&(L!=null&&L.ships)?{id:p,verb:L,under:te}:null);const Ce=Kt==="land"&&Se&&((gc=pe.current)==null?void 0:gc.id)===p?pe.current:null,$e=Ce?Ce.verb:L,mt=!!($e!=null&&$e.ships)&&Kt==="land",Xt=Ax(xn,Ix),Nn=Wl(e,"commit"),_n=Wl(e,"check"),Mo=mt?Nn:_n,Wn=_a(zm(Mo)?Mo==null?void 0:Mo.since:void 0),hs=rt?rt.check==="pending"&&_n&&_n.status!=="terminated"?_h("Checking the work",_n,Wn):wu(rt,Gt,De,Z==null?void 0:Z.name):null,Ri=$e&&mt?Xt?`${$e.word}: ${Xt}`:`${$e.word} ${$e.line}`:null,cc=Ri&&Nn&&Nn.status!=="terminated"?_h(Ri,Nn,Wn):Ri,ms=n?n.restorable?`message agent on ${n.title}; sending restores it first`:"its commits were not kept, so it cannot come back":e?$e?"":hs||(Dt?os(Dt):be?Dm(be):r?`describe ${Jn}…`:le?"describe a change":a?`message agent on ${Jn}`:`message agent on ${Jn}; / for a command, ! for a shell command`):"no worktree selected",yo=y!==""||Tr||!e?null:mt?Xt?null:Ce?Ce.under:te:$e?te:Dt||hs?$r??(rt==null?void 0:rt.subject)??null:null,Ys=S.useRef(!1);S.useEffect(()=>{const K=Zn&&!Ys.current;Ys.current=Zn,K&&((dt==null?void 0:dt.kind)==="file"&&p?Md(p,u.getState(),{sock:c,dispatch:l}):(dt==null?void 0:dt.kind)==="command"&&kn&&U.length===0&&(c==null||c.send({t:"list-commands",worktreeId:kn})))},[Zn,dt==null?void 0:dt.kind,U.length,p,kn,c,u,l]);const uc=()=>{if(!e)return;const K=[],He=V;if(He.url)try{const er=new URL(He.url);K.push(`current route: ${er.pathname}${er.search}`)}catch{}He.title&&K.push(`page title: ${He.title}`),He.errors.length&&K.push(`recent console errors:
|
|
229
|
+
${He.errors.map(er=>`- ${er}`).join(`
|
|
230
|
+
`)}`);const Ft=[];r&&Ft.push(j3(e.worktree.title,se==null?void 0:se.configFile)),K.length>0&&Ft.push(`What the user is looking at right now:
|
|
231
|
+
${K.join(`
|
|
232
|
+
`)}`);const Rn=b3(M);return Rn&&Ft.push(Rn),Ft.length>0?Ft:void 0},dc=K=>{le?an(K):p&&K!==vt&&(c==null||c.send({t:"set-worktree-mode",worktreeId:p,mode:K}))},ur=K=>k&&l({a:"notice",id:k,text:K}),$i=(K,He="")=>{if(!e||!p)return;if(K==="archive"){cn||An?_i(c,l,[p]):ur("archive is for a landed worktree; this one has not landed");return}if(K==="check"){le||!ki(e.worktree)?ur("nothing to check from here"):Ae?ur("wait for the turn to end"):St===0?ur("nothing to check: no changes here"):lt(He||void 0);return}const Ft=fe?wu(fe,Gt,De,Z==null?void 0:Z.name):null;le||!ki(e.worktree)?ur("nothing to land from here"):cn?ur(`already landed on ${(se==null?void 0:se.defaultBranch)??"main"}`):Ft?ur(Ft):Ae&&(!fe||fe.stale)?ur("wait for the turn to end"):fe!=null&&fe.stale?ur("the work changed since this was checked; check again first"):Ot()},Mi=v.some(Xu),Da=()=>{k&&(c==null||c.send({t:"set-draft",boxId:k,text:y,clientId:ke}))},wo=()=>{if(!k||Se)return;if(n){if(!n.restorable)return;if(Hn!==null){ur("nothing runs here until it is restored");return}if(Mi){ur(N0);return}const vs=v.length?v.map(Ju):void 0;Da(),c==null||c.send({t:"restore-worktree",archiveId:n.id,clientId:ke,message:{text:y.trim(),attachments:vs},boxId:k}),l({a:"restoring",id:k,text:y.trim()}),l({a:"sent-box",id:k});return}if(!e||!p)return;if(Hn!==null){Hn&&h?l({a:"term-run",id:p,command:Hn}):Hn&&(c==null||c.send({t:"exec",worktreeId:p,command:Hn})),q("");return}const K=w5(y,Rt),He=K&&g5(K.name)?K.name:void 0;if(K&&!He){$i(K.name,K.args),q("");return}if(He&&!(K!=null&&K.args)){dc(He),q("");return}if(t!=null&&t.batch&&v.length){ur("a batch takes no attachments; remove them or turn batch off");return}if(r&&!Re){ur("choose an agent above first");return}if(Mi){ur(N0);return}const Ft=K?K.args:y.trim(),Rn=uc(),er=v.length?v.map(Ju):void 0;if(Da(),He&&dc(He),le){const vs=Ta(e.worktree)?{worktreeId:p}:{},Gd={clientId:ke,repoId:e.worktree.repoId,context:Rn,attachments:er,agent:oe,profile:Oe,mode:He??Mt,...it?{model:it}:{},...en?{effort:en}:{},...mx(t)?{carry:!0}:{}};if(oe!==ve&&(c==null||c.send({t:"set-default-agent",agent:oe})),t!=null&&t.batch)c==null||c.send({t:"batch-worktrees",repoId:e.worktree.repoId,prompt:Ft,agent:oe,...it?{model:it}:{},...en?{effort:en}:{},boxId:k});else{const kc=t&&t.variants>1?{variants:t.variants}:{};c==null||c.send({t:"create-worktree",...Gd,...vs,...kc,prompt:Ft,boxId:k}),k&&l({a:"sending",id:k,message:{text:Ft,attachments:er}})}}else xe&&(c==null||c.send({t:"set-worktree-model",worktreeId:p,model:it}),c==null||c.send({t:"set-worktree-effort",worktreeId:p,effort:en})),c==null||c.send({t:"chat",worktreeId:p,clientId:ke,text:Ft,context:Rn,attachments:er,boxId:k}),Ae||l({a:"sending",id:p,message:{text:Ft,attachments:er}});l({a:"sent-box",id:k}),r&&l({a:"show-chat"})},za=K=>{if(!p||(H==null?void 0:H.ask.kind)!=="question")return;if(!K.some(pa))return l({a:"ask-revive",id:p});const He=ix(H.ask.questions,K).join(`
|
|
233
|
+
`);c==null||c.send({t:"chat",worktreeId:p,clientId:ke,text:He,context:uc()}),l({a:"sending",id:p,message:{text:He}}),l({a:"ask-revive",id:p})},gs=P(K=>K.autoSend);gt([gs,p],()=>{!gs||gs!==p||!y.trim()||tt!==!!r||(l({a:"auto-sent"}),wo())});const fc=()=>{const K=v[v.length-1];return!k||!K?!1:(l({a:"detach",id:k,key:K.key}),!0)},Qs=K=>{k&&(l({a:"walk",id:k,walk:K.walk,text:K.text}),requestAnimationFrame(()=>{var He;(He=ft.current)==null||He.setSelectionRange(K.text.length,K.text.length),In(K.text.length)}))},Xs=()=>{k&&N&&l({a:"walk",id:k,walk:null,text:y})},pc=le?[]:M.map(K=>K.kind==="user"?K.attachments:void 0),Cr=le?[]:J.flatMap(K=>K.attachments??[]),ks=e?e.worktree.path:null,Js=e==null?void 0:e.worktree.plan,ys=et&&!Y;return f.jsxs("div",{className:Ke("composer chat-input",ys&&"stopping"),children:[Js&&e&&f.jsxs("div",{className:"composer-plan",children:[f.jsx(Et,{name:"text",className:"icon-inline"}),f.jsx(Be,{variant:"inline",className:"composer-plan-path","data-tip":"Read the plan in the editor pane",onClick:()=>Vn({dispatch:l},{worktreeId:e.worktree.id,path:Js,view:"preview"}),children:Js})]}),ae&&p&&f.jsxs("div",{className:"composer-ask",children:[f.jsx(Et,{name:"chat",className:"icon-inline"}),f.jsxs("span",{className:"composer-ask-line",children:[f.jsx(Be,{variant:"inline",tone:"strong","data-tip":"Bring the question back into the box",onClick:()=>{l(ae.outcome?{a:"ask-revive",id:p,askId:ae.id}:{a:"ask-unpark",id:p}),l({a:"focus-chat"})},children:"answer"})," ",c$(ae)]})]}),k&&Q0(v,X0(Y0(pc),Cr)).map(([K,He])=>{const Ft=()=>l({a:"detach",id:k,key:K.key});return K.kind==="image"?f.jsx(ag,{src:K.local??nd(K.upload),n:He,name:K.name,width:K.width,height:K.height,bytes:K.bytes,uploading:K.uploading,onRemove:Ft},K.key):K.kind==="file"?f.jsx(sg,{name:K.name,bytes:K.bytes,href:K.text&&K.upload?nd(K.upload):void 0,uploading:K.uploading,onRemove:Ft},K.key):K.kind==="paste"?f.jsx(og,{n:He,name:K.name,source:K.source,lines:K.lines,chars:K.chars,preview:K.preview,text:K.text,onRemove:Ft},K.key):f.jsx(ug,{pick:K,dir:ks,tipText:K.html,onHover:Rn=>_e&&Wt.post(_e,Rn?{type:"highlight-selector",selector:K.selector,label:vm(K)}:{type:"highlight-clear"}),worktreeId:p,onOpen:(Rn,er)=>p&&Sa(u,c,p,Rn,er),onRemove:Ft},K.key)}),Zn&&dt&&f.jsx(N3,{results:yt,keyOf:K=>K.kind==="cmd"?`c:${K.c.name}`:K.kind==="changes"?"changes":K.kind==="folder"?`d:${K.path}`:`f:${K.path}`,rowClass:K=>K.kind==="file"||K.kind==="folder"?"qo-file":K.kind==="changes"?"picker-row":"picker-row picker-cmd",nav:Gr,listRef:so,empty:_5(dt.kind,nn,U.length,kn!==null),row:K=>{const He=((We==null?void 0:We.files.length)??0)>0;return K.kind==="file"?Fh(K.path,K.status,dt.query,{gutter:He}):K.kind==="folder"?Fh(K.path,void 0,dt.query,{folder:!0,gutter:He}):K.kind==="changes"?f.jsx(rr,{label:"@changes",hint:`${K.n} uncommitted ${K.n===1?"file":"files"}`}):f.jsx(F3,{c:K.c,query:dt.query})}}),Y&&p?f.jsx(AD,{item:Y,worktreeId:p,rootRef:me,onAnswer:H?za:void 0},Y.id):f.jsxs("div",{className:Ke("composer-field",Hn!==null&&"shell",N&&"recalled"),children:[f.jsx(Ea,{size:"lg",bare:!0,font:Hn!==null?"mono":"ui",ref:ft,value:y,onChange:K=>{var vs;const He=K.target.value,Ft=K.target.selectionStart??He.length;q(He),In(Ft),Gr.setIndex(0);const{inputType:Rn}=K.nativeEvent;qr(Rn==="insertFromPaste"||Rn==="insertFromDrop"?((vs=p0(He,Ft))==null?void 0:vs.from)??null:null)},onKeyUp:K=>{$(),In(K.currentTarget.selectionStart??0)},onClick:K=>{In(K.currentTarget.selectionStart??0),Xs()},onPaste:F,onScroll:K=>{rn.current&&(rn.current.scrollTop=K.currentTarget.scrollTop)},onKeyDown:K=>{if(ne(K),!K.nativeEvent.isComposing){if(K.key==="Escape"){const He=u.getState();if(He.overlay||He.choosingFolder)return}if(Zn){if(K.key==="Escape"){K.preventDefault(),K.stopPropagation(),qr((dt==null?void 0:dt.from)??null);return}if(Gr.onKeyDown(K))return}if((K.key==="ArrowUp"||K.key==="ArrowDown")&&!K.altKey&&!K.ctrlKey){const He=K.key==="ArrowUp",Ft=J.at(-1);if(He&&!K.metaKey&&!N&&y===""&&p&&!h&&Ft!==void 0){K.preventDefault(),Jx(u,c,p,J.length-1);return}const Rn=K.metaKey?He?"first":"box":He?"up":"down",er=p?x3(M,N??null,y,Rn):null;if(er){K.preventDefault(),(er.walk!==N||er.text!==y)&&Qs(er);return}}if(N&&K.key==="Escape"){K.preventDefault(),K.stopPropagation(),Qs({walk:null,text:N.from});return}if(K.key==="Escape"&&Ae&&p&&!h){K.preventDefault(),K.stopPropagation(),c==null||c.send({t:"stop-agent",worktreeId:p});return}if(N&&b5.has(K.key)&&Xs(),K.key==="Tab"&&!K.shiftKey&&y===""&&(rt!=null&&rt.subject)){K.preventDefault(),l({a:"edit-commit"});return}K.key==="Enter"&&!K.shiftKey?(K.preventDefault(),wo()):K.key==="Backspace"&&y===""&&fc()&&K.preventDefault()}},placeholder:yo||$e?"":ms,disabled:!e&&!(n!=null&&n.restorable)}),Tr&&f.jsxs("div",{className:"composer-ghost","aria-hidden":"true",children:[f.jsx("span",{className:"picker-typed",children:y}),Tr]}),p&&Hn===null&&y.includes("@")&&f.jsx("div",{ref:rn,className:"composer-ghost composer-marks","aria-hidden":"true",onClick:K=>G_(K,e==null?void 0:e.worktree.path,p,{sock:c,dispatch:l}),children:f.jsx(q_,{text:y,worktreeId:p,root:e==null?void 0:e.worktree.path,inField:!0})}),(yo||$e)&&f.jsxs("div",{className:"composer-ghost","aria-hidden":$e?void 0:"true",children:[f.jsx("span",{className:Ke("composer-placeholder",mt&&"live-text"),children:cc||($e?f.jsxs(f.Fragment,{children:[f.jsx(Be,{variant:"inline",tone:"strong",className:"composer-verb",disabled:!!$e.ships&&!!Kt,...It($e.tip,void 0,{placement:"top"}),onClick:$e.run,children:$e.word})," ",f.jsx("span",{className:"composer-verb-line",children:$e.line})]}):ms)}),yo&&f.jsxs(f.Fragment,{children:[`
|
|
234
|
+
`,f.jsx("span",{className:"composer-subline",children:yo})]})]}),ys&&f.jsx($t,{icon:"stop",tone:"danger",className:"composer-stop",label:`Stop the agent (context up to here is kept${J.length?"; queued messages go next":""})`,hint:"esc",onClick:()=>p&&(c==null?void 0:c.send({t:"stop-agent",worktreeId:p}))})]}),_&&f.jsx("div",{className:"hint composer-notice",role:"status",children:_}),!Y&&f.jsxs("div",{className:"hint composer-knobs",children:[f.jsxs("span",{className:"spawn-left",children:[Le?tn.length>1?f.jsx(aE,{agents:tn,agent:oe,model:it,onChange:st,onClose:B}):f.jsx(zh,{models:Ve,value:it,onChange:Je,onClose:B}):e&&f.jsx(zh,{models:Ve,value:e.worktree.model??"",current:X,onChange:K=>c==null?void 0:c.send({t:"set-worktree-model",worktreeId:e.worktree.id,model:K}),onClose:B}),Le?f.jsx(Dh,{efforts:ze,value:en,onChange:kt,onClose:B}):e&&f.jsx(Dh,{efforts:ze,value:e.worktree.effort??"",current:we,onChange:K=>c==null?void 0:c.send({t:"set-worktree-effort",worktreeId:e.worktree.id,effort:K}),onClose:B}),le?f.jsx(b0,{value:Mt,onChange:an,onClose:B}):e&&f.jsx(b0,{value:vt,onChange:K=>c==null?void 0:c.send({t:"set-worktree-mode",worktreeId:e.worktree.id,mode:K}),onClose:B}),Qe&&!le&&p&&f.jsx($t,{icon:f.jsx(T3,{fraction:Qe.used/Qe.size}),tone:"chrome",label:`${Math.round(100*Qe.used/Qe.size)}% of context`,detail:`${jv(Qe.used)} of ${jv(Qe.size)}${Qe.cost!==void 0?` · ${ic(Qe.cost)} this session`:""}${cr?" · click to compact":""}`,onClick:K=>{cr?wn():Tt.openUnder(K.currentTarget,Xn)},...Tt.contextMenu(Xn)})]}),f.jsxs("span",{className:"spawn-tools",children:[!r&&!n&&!a&&f.jsx($t,{icon:"terminal",tone:"chrome",on:Lt,className:"composer-term",disabled:!e,label:ln?ln.tip:"Terminal",hint:xt("terminal"),badge:ln&&f.jsx("span",{className:"composer-term-dot"}),onClick:()=>{l(ln&&!Lt&&p?{a:"term-stream",id:p,stream:ln.stream}:{a:"toggle-terminal"})},...Tt.contextMenu(()=>e&&p?Dz(e.procs,p,Lt,{sock:c,dispatch:u.dispatch}):[])}),!r&&!O&&!n&&!a&&f.jsx($t,{icon:"pick",label:"Pick an element on the page to attach",hint:xt("pick"),on:Dn==="chat",disabled:!_e,onClick:()=>_e&&Hl(_e,Dn,l,"chat")})]})]}),gn&&hn&&f.jsx("div",{className:"composer-notes",children:f.jsxs("div",{className:"hint composer-note",children:[f.jsx("span",{children:gn}),aL(hn)&&f.jsx(Be,{variant:"outline",busy:mn==="pull-main",disabled:!!mn,"data-tip":"Fast-forward main to origin",onClick:()=>Hs(c,l,{t:"pull-main",worktreeId:hn.id}),children:"pull"})]})})]})}function TE({children:e,className:t,tip:n,...r}){return f.jsxs("label",{className:Ke("check",t),"data-tip":n,children:[f.jsx("input",{type:"checkbox",className:"check-box",...r}),f.jsx("span",{children:e})]})}const S5=[1,2,3];function N5({draft:e,lead:t}){const n=ht(),r=P(c=>Ra(c,t==null?void 0:t.repoId)),[s]=lE(r),a=P(c=>{var u;return((u=ba(c,t==null?void 0:t.repoId))==null?void 0:u.dirty)??0}),l=!e.batch&&e.variants===1;return f.jsxs("div",{className:"draft-intro",children:[f.jsxs("div",{className:"draft-row hint",children:[f.jsx(Be,{variant:"ghost",tone:"chrome",on:e.batch,"data-tip":"An agent splits the prompt into a worktree per task",onClick:()=>n({a:"draft-batch",v:!e.batch}),children:"batch"}),f.jsxs("span",{className:"draft-variants",children:[S5.map(c=>f.jsx(Be,{variant:"ghost",on:e.variants===c,disabled:e.batch,onClick:()=>n({a:"draft-variants",n:c}),children:c},c)),f.jsx("span",{"data-tip":"Run the same prompt in N parallel worktrees, keep the best",children:"variants"})]}),f.jsx("span",{className:"draft-runs",children:f.jsx(z3,{repo:r,value:e.profile??s,onChange:c=>n({a:"draft-profile",profile:c})})})]}),t&&r&&a>0&&f.jsx("div",{className:"draft-notes",children:f.jsxs(TE,{className:"hint draft-note",checked:mx(e),disabled:!l,tip:l?`Move the ${a} uncommitted ${a===1?"file":"files"} into the new worktree, leaving ${r.defaultBranch} clean`:"One set of changes can only go into one worktree",onChange:c=>n({a:"draft-carry",v:c.currentTarget.checked}),children:[f.jsxs("span",{className:"badge-dirty",children:["~",a]})," on ",r.defaultBranch," come along"]})})]})}function fd({placement:e,className:t,width:n,archived:r}){const s=ht(),a=us(),l=N2(),c=At(a==null?void 0:a.worktree.id,"sending"),u=$a(),h=e==="centre"&&!r&&(u!=null&&u.assumed)?u:null,p=P(y=>{var v;return((v=y.dragFiles)==null?void 0:v.at)==="chat"}),g=Un(),k=S.useMemo(()=>_M(g),[g]);return f.jsxs("div",{className:Ke(e==="dock"?"chat-dock":e==="centre"?"chat-centre":"chat-screen",t,p&&"drop-over"),style:n===void 0?void 0:{width:n},...k,ref:y=>{var v;y?Ol.el=y:(v=Ol.el)!=null&&v.isConnected||(Ol.el=null)},children:[r?f.jsx(v0,{active:null,archived:r,tail:f.jsx(DL,{item:r})}):f.jsx(v0,{active:a,lead:h&&f.jsxs("p",{className:"hint chat-centre-note",children:[h.name," has ",f.jsx("code",{children:h.assumed})," and no dev server, so it is chat only for now."," ",f.jsx(Be,{variant:"inline",onClick:()=>s({a:"open",overlay:{kind:"setup",repoId:h.id}}),children:"add a dev server"})]})}),!r&&l&&!c&&f.jsx(N5,{draft:l,lead:a}),r?f.jsx(Bh,{active:null,archived:r,placement:e}):f.jsx(Bh,{active:a,draft:l,placement:e})]})}const T5="modulepreload",j5=function(e){return"/"+e},T0={},Uh=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(p=>Promise.resolve(p).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),u=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));s=l(n.map(h=>{if(h=j5(h),h in T0)return;T0[h]=!0;const p=h.endsWith(".css"),g=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${g}`))return;const k=document.createElement("link");if(k.rel=p?"stylesheet":T5,p||(k.as="script"),k.crossOrigin="",k.href=h,u&&k.setAttribute("nonce",u),document.head.appendChild(k),p)return new Promise((y,v)=>{k.addEventListener("load",y),k.addEventListener("error",()=>v(Error(`Unable to preload CSS for ${h}`)))})}))}function a(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return s.then(l=>{for(const c of l||[])c.status==="rejected"&&a(c.reason);return t().catch(a)})},hg=800;function C5(e,t,n,r){if(r.version===e.version)return"same";const s=t===e.text&&n===null;return r.version===null?s?"gone":"conflict":r.after===t||r.after===n?"adopt":s?"apply":"conflict"}const No=e=>`${e.worktreeId}
|
|
235
|
+
${e.ref??""}
|
|
236
|
+
${e.since??""}
|
|
237
|
+
${e.path}`;class A5{constructor(t){Ct(this,"files",new Map);Ct(this,"looks",new Map);this.d=t}start(){var a,l;let t=this.d.store.getState();const n=this.d.store.subscribe(()=>{const c=this.d.store.getState(),u=t;t=c,this.follow(u,c)}),r=()=>{const c=this.d.store.getState().editor;c&&!c.loose&&this.refresh(No(c))};(a=this.d.win)==null||a.addEventListener("focus",r);const s=()=>{for(const[c,u]of this.files)u.timer!==void 0&&this.saveNow(c)};return(l=this.d.win)==null||l.addEventListener("pagehide",s),()=>{var c,u;n(),(c=this.d.win)==null||c.removeEventListener("focus",r),(u=this.d.win)==null||u.removeEventListener("pagehide",s)}}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(No(t));if(!r)return;if(t.t==="file-blame"){this.blamed(r,t);return}const s=r.out;!s||s.seq!==t.seq||(r.out=null,t.t==="file-read"?this.read(r,t):s.write!==void 0&&this.written(r,s.write,t),this.next(r))}look(t,n){if(!this.d.store.getState().connected)return Promise.resolve(null);const r=Io();return new Promise(s=>{this.looks.set(r,s),this.d.send({t:"read-file",worktreeId:t,path:n,seq:r})})}bind(t){const n=No(t);return{attach:r=>this.attach(n,r),edited:()=>this.edited(n),saveNow:()=>this.saveNow(n)}}reload(t){var s;const n=this.files.get(No(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"}):(s=n.buffer)==null||s.replace(r.after),this.next(n))}keepMine(t){const n=this.files.get(No(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 a,l;t.connected&&!n.connected&&this.dropped();const r=(a=n.editor)!=null&&a.loose?null:n.editor,s=(l=t.editor)!=null&&l.loose?null:t.editor;if(s&&(!r||No(s)!==No(r))&&this.closed(No(s)),r&&(!s||s.seq!==r.seq)&&this.opened(r),!t.connected&&n.connected)for(const c of this.files.values())c.reread=!0,this.next(c);else r&&s&&s.seq===r.seq&&go(t,r.worktreeId).git!==go(n,r.worktreeId).git&&this.refresh(No(r))}opened(t){const n=No(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:s,since:a}=t.file;if(t.reread){t.reread=!1;const c=Io();t.out={seq:c},this.d.send({t:"read-file",worktreeId:n,path:r,ref:s,since:a,seq:c});return}if(t.pending!==null&&t.base&&t.pending===t.base.text&&(t.pending=null),t.pending!==null&&t.writable&&!t.conflict&&!s){const c=t.pending,u=Io();t.pending=null,t.out={seq:u,write:c},this.d.send({t:"write-file",worktreeId:n,path:r,content:c,base:((l=t.base)==null?void 0:l.version)??null,seq:u});return}!t.open&&!t.buffer&&t.pending===null&&!t.conflict&&this.files.delete(No(t.file))}read(t,n){var k,y;const{file:r}=t;if(n.error){t.open&&this.d.store.dispatch({a:"editor-read",file:r,disk:null,error:n.error});return}const{before:s,after:a,version:l,writable:c,binary:u,tooLarge:h}=n;t.writable=c,t.open&&(this.d.store.dispatch({a:"editor-read",file:r,disk:{before:s,after:a,version:l,writable:c,binary:u,tooLarge:h}}),!u&&!h&&(l!==null||r.ref)&&this.askBlame(t,l));const p={after:t.buffer?t.buffer.normalize(a):a,version:l};if(!t.base){t.base={text:p.after,version:l};return}const g=((k=t.buffer)==null?void 0:k.text())??t.pending??t.base.text;switch(C5(t.base,g,t.pending,p)){case"same":break;case"adopt":t.base={text:p.after,version:l};break;case"apply":(y=t.buffer)==null||y.replace(p.after),t.base={text:p.after,version:l};break;case"gone":t.base={text:"",version:null},t.open&&this.d.store.dispatch({a:"close-editor"});break;case"conflict":this.setConflict(t,p);return}this.setConflict(t,null)}askBlame(t,n){const r=Io();t.blame={seq:r,version:n};const{worktreeId:s,path:a,ref:l}=t.file;this.d.send({t:"blame-file",worktreeId:s,path:a,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:s,lines:a}=n;this.d.store.dispatch({a:"editor-blame",file:t.file,blame:{commits:s,lines:a,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)},hg))}saveNow(t){const n=this.files.get(t);if(!(n!=null&&n.buffer))return;this.cancelTimer(n);const r=n.buffer.text();r.length>Gu||(n.pending=r,this.next(n))}cancelTimer(t){t.timer!==void 0&&(this.d.timers.clear(t.timer),t.timer=void 0)}}const jE={attach:()=>{},edited:()=>{},saveNow:()=>{}},I5=e=>({timers:{set:(t,n)=>setTimeout(t,n),clear:t=>clearTimeout(t)},win:typeof window>"u"?null:window,send:e}),Hh=new Map;function R5(e){const t=Hh.get(e.seq);return t?(Hh.delete(e.seq),t(e),!0):!1}function O5(e,t,n,r){if(e.kind==="bytes")return jE;if(e.kind==="grant")return $5(e,t,n,r);const s=e.handle;let a=null,l,c=null,u=Promise.resolve(),h=!1;const p=()=>(c??(c=(async()=>await s.queryPermission({mode:"readwrite"})==="granted"?!0:await s.requestPermission({mode:"readwrite"})==="granted")().catch(()=>!1)),c),g=()=>{l!==void 0&&r.timers.clear(l),l=void 0},k=()=>{h||(h=!0,g(),n(`read-only: the browser would not save ${t}`))},y=async E=>{if(!await p())return k();const C=await s.createWritable();await C.write(E),await C.close()},v=()=>{if(!a||h)return;g();const E=a.text();u=u.then(()=>y(E)).catch(k)},_=()=>{l!==void 0&&v()};return{attach(E){var C,x;if(E){a=E,(C=r.win)==null||C.addEventListener("pagehide",_);return}l!==void 0&&v(),a=null,(x=r.win)==null||x.removeEventListener("pagehide",_)},edited(){!a||h||(p().then(E=>{E||k()}),g(),l=r.timers.set(v,hg))},saveNow:v}}function $5(e,t,n,r){let s=null,a,l=e.version,c=!1,u=null,h=!1;const p=()=>{a!==void 0&&r.timers.clear(a),a=void 0},g=_=>{h||(h=!0,p(),u=null,n(_))},k=_=>{if(!r.send)return;const E=Io();c=!0,Hh.set(E,C=>{if(c=!1,C.ok?l=C.version:C.reason==="changed"?g(`read-only: ${t} changed on disk; open it again to edit`):g(C.message??`not saved: ${t}`),u!==null&&!h){const x=u;u=null,k(x)}}),r.send({t:"write-loose",id:e.id,content:_,base:l,seq:E})},y=()=>{if(!s||h)return;p();const _=s.text();_.length>Gu||(c?u=_:k(_))},v=()=>{a!==void 0&&y()};return{attach(_){var E,C;if(_){s=_,(E=r.win)==null||E.addEventListener("pagehide",v);return}a!==void 0&&y(),s=null,(C=r.win)==null||C.removeEventListener("pagehide",v)},edited(){!s||h||(p(),a=r.timers.set(y,hg))},saveNow:y}}let Wh=!1;function M5(){Wh=!0}function pd({title:e,body:t,action:n,pane:r,children:s}){return f.jsxs("div",{className:Ke("crash",r&&"in-pane"),children:[f.jsx("div",{className:"crash-title",children:e}),t&&f.jsx("div",{className:"crash-body",children:t}),s,n]})}const j0={title:"Toyon was updated",body:"This page is still running the old build. Reload to pick up the new one."};class mg extends S.Component{constructor(){super(...arguments);Ct(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,r){console.error("[toyon] render error",n,r.componentStack)}render(){const{error:n}=this.state;return n?f.jsx(pd,{pane:this.props.pane,title:Wh?j0.title:"Toyon hit an error",body:Wh?j0.body:n.message||String(n),action:f.jsx(Be,{variant:"outline",onClick:()=>window.location.reload(),children:"reload"})}):this.props.children}}function gg({kind:e,className:t,height:n,resizable:r=!0,onDragStart:s,title:a,tabs:l,actions:c,menu:u,full:h,onToggleFull:p,onClose:g,closeHint:k="esc",children:y}){const v=Jt("pane"),_=p&&f.jsxs(Be,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:p,"data-tip":h?"Split view: show the preview above":"Full height: hide the preview",children:[f.jsx(Et,{name:h?"split":"full",className:"icon-inline"})," ",h?"split":"full"]}),E=f.jsx($t,{icon:"close",label:"Close",hint:k,onClick:g});return f.jsxs("div",{className:`pane ${t}`,"data-pane":e,tabIndex:-1,style:n===void 0?void 0:{height:n},children:[r&&f.jsx("div",{className:"pane-resize",onPointerDown:s}),f.jsx("div",{className:Ke("pane-head",l&&"pane-head-tabs"),...v.contextMenu(()=>(u==null?void 0:u())??[]),children:l?f.jsx(Dd,{...l,end:f.jsxs(f.Fragment,{children:[c,_,E]})}):f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"pane-title",children:a}),c,_,E]})}),y]})}function L5({src:e,path:t,full:n,onFull:r}){const s=Jt("editor");return f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",className:"editor-image",onClick:()=>r(!0),...s.contextMenu(()=>Zl(e,{open:()=>r(!0)})),children:f.jsx("img",{src:e,alt:t})}),n&&f.jsx(Bm,{owner:"editor",onClose:()=>r(!1),menu:()=>Zl(e),children:f.jsx("img",{src:e,alt:t})})]})}const P5={image:L5};function D5({kind:e,src:t,path:n,openSeq:r,focus:s,full:a,onFull:l}){const c=S.useRef(null);gt([r],()=>{var h;s&&((h=c.current)==null||h.focus())});const u=P5[e];return f.jsx("div",{ref:c,className:"editor-viewer",tabIndex:-1,children:f.jsx(u,{src:t,path:n,full:a,onFull:l})})}const z5="img[src], source[src], video[src], audio[src], video[poster], link[href], object[data]";function F5(e,t){if(!t)return e;const n=new DOMParser().parseFromString(e,"text/html");let r=!1;for(const s of n.querySelectorAll(z5))for(const a of["src","href","poster","data"]){const l=s.getAttribute(a),c=l===null?null:Ym(t.dir,l);c&&(s.setAttribute(a,Cm(t.worktreeId,c,t.version)),r=!0)}return r?`${n.doctype?`<!doctype html>
|
|
238
|
+
`:""}${n.documentElement.outerHTML}`:e}function B5({text:e,path:t,worktreeId:n,version:r,openSeq:s,focus:a}){const l=S.useRef(null);gt([s],()=>{var h;a&&((h=l.current)==null||h.focus())});const c=s_(t),u=S.useMemo(()=>F5(e,r===void 0?null:{worktreeId:n,dir:c,version:r}),[e,n,c,r]);return f.jsx("div",{ref:l,className:"editor-viewer",tabIndex:-1,children:f.jsx("iframe",{className:"editor-frame",title:t,sandbox:"",srcDoc:u})})}function U5(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 H5(e){const t=new Map,n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=U5(n.map(s=>Number(s.tagName[1])));return n.map((s,a)=>{var u;const l=((u=s.textContent)==null?void 0:u.trim())??"",c=t.get(l)??0;return t.set(l,c+1),{id:`${c}
|
|
239
|
+
${l}`,level:Number(s.tagName[1]),depth:r[a],text:l,el:s}})}const W5=48,K5=16;function Z5({text:e,path:t,worktreeId:n,version:r,openSeq:s,focus:a,onChat:l}){ot();const c=ht(),u=s_(t),h=Jm(e,r===void 0?void 0:{base:{worktreeId:n,dir:u,version:r}}),p=S.useRef(null),g=S.useRef(null),[k,y]=S.useState([]),[v,_]=S.useState(-1),[E,C]=S.useState(null),x=W=>{var R;if(C(null),W){const j=window.getSelection();j==null||j.removeAllRanges(),j==null||j.addRange(W)}(R=p.current)==null||R.focus()};gt([s],()=>{var W;a&&((W=p.current)==null||W.focus())}),gt([h],()=>{p.current&&y(H5(p.current))}),S.useLayoutEffect(()=>{const W=p.current;if(!W)return;let R=0;const j=()=>{if(R=0,W.scrollTop+W.clientHeight>=W.scrollHeight-1){_(k.length-1);return}const D=W.scrollTop+W5;let H=-1;for(let Y=0;Y<k.length;Y++)k[Y].el.offsetTop<=D&&(H=Y);_(H)},A=()=>{R||(R=requestAnimationFrame(j))};return j(),W.addEventListener("scroll",A),()=>{W.removeEventListener("scroll",A),R&&cancelAnimationFrame(R)}},[k]);const N=W=>{var j,A;const R=(j=k[W])==null?void 0:j.el;(A=p.current)==null||A.scrollTo({top:Math.max(0,R?R.offsetTop-K5:0),behavior:"smooth"})},M=W=>{const R=W.target.closest("a"),j=R==null?void 0:R.getAttribute("href");if(!j||(R==null?void 0:R.target)==="_blank")return;W.preventDefault();const A=Ym(u,j);A&&Vn({dispatch:c},{worktreeId:n,path:A,view:Ti(A)})},J=W=>{var R;if(Fm(W)){W.preventDefault(),W.stopPropagation();const j=(g.current&&Nh(g.current))??"";C(A=>({seed:j||(A==null?void 0:A.seed)||"",seq:((A==null?void 0:A.seq)??0)+1}));return}if(W.key==="Escape"&&E){W.stopPropagation(),x(null);return}if(z1(W)&&g.current){W.preventDefault(),B1(g.current);return}if(((R=J0(W))==null?void 0:R.id)==="composer"&&g.current){const j=Nh(g.current);if(!j)return;W.preventDefault(),W.stopPropagation(),l(j)}};return f.jsxs(f.Fragment,{children:[f.jsx("div",{ref:p,className:"editor-viewer editor-preview",tabIndex:-1,onClick:M,onKeyDown:J,children:f.jsx("div",{ref:g,className:"md md-preview",dangerouslySetInnerHTML:{__html:h}})}),E&&f.jsx(D1,{root:p,body:g,seed:E.seed,seq:E.seq,onClose:x}),f.jsx(q5,{heads:k,at:v,onJump:N})]})}function q5({heads:e,at:t,onJump:n}){const[r,s]=S.useState(!1),a=S.useRef(null);return e.length<2?null:f.jsxs(f.Fragment,{children:[f.jsx("div",{ref:a,className:"editor-outline","aria-hidden":!0,onPointerEnter:l=>{l.pointerType==="mouse"&&s(!0)},onClick:()=>s(l=>!l),children:e.map((l,c)=>f.jsx("span",{className:"editor-outline-tick","data-level":l.level,"data-state":Yn({current:c===t})},l.id))}),r&&f.jsx(Vs,{className:"editor-outline-list",anchor:()=>{var l;return((l=a.current)==null?void 0:l.getBoundingClientRect())??null},placement:{side:"right",align:"center",cover:!0},trigger:a.current,onDismiss:()=>s(!1),onPointerLeave:l=>{l.pointerType==="mouse"&&s(!1)},children:e.map((l,c)=>f.jsx("button",{type:"button",className:"row editor-outline-row","data-level":l.level,"data-state":Yn({current:c===t}),onClick:()=>n(c),children:f.jsx("span",{className:"editor-outline-label",style:{"--outline-depth":l.depth},children:l.text})},l.id))})]})}function G5({absPath:e,onReveal:t}){const n=Jt("editor");return jm(location.hostname)?f.jsxs(Be,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",...n.dropdown(()=>ji(e,t),"right"),children:["open in ",f.jsx(Et,{name:"caret",className:"icon-inline"})]}):null}const V5=S.lazy(async()=>{const[e]=await Promise.all([Uh(()=>import("./Editor-DAJni9OF.js").then(t=>t.E),__vite__mapDeps([0,1,2])),Uh(()=>import("./grammar-Cfxx1yRn.js"),[]).then(t=>t.grammarsReady)]);return e});function C0({what:e}){return Cx(!0,3e3)?f.jsx("div",{className:"empty",children:f.jsxs("span",{className:"live-text",children:["loading ",e]})}):null}const Y5=()=>{},Q5={diff:"diff",file:"text",preview:"book"};function X5(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 CE({editor:e,height:t,full:n=!1,onToggleFull:r,onDragStart:s,placement:a="stack"}){const l=a==="screen",c=ht(),u=Un(),h=ot(),p=jx(),g=Rd(),{worktreeId:k,path:y,ref:v,since:_}=e,E=e.loose,C=P(V=>{var O;return((O=$o(V))==null?void 0:O.id)===k}),x=P(V=>{var F,ne;const O=(F=fn(V,k))==null?void 0:F.worktree;return O?O.path:(ne=$o(V))==null?void 0:ne.path}),N=E?E.source.kind==="grant"?E.source.path:null:x?`${x}/${y}`:y,M=v!==void 0,J=S.useMemo(()=>E?O5(E.source,y,V=>c({a:"editor-refused",file:{worktreeId:k,path:y},message:V}),I5(h?V=>h.send(V):null)):(p==null?void 0:p.bind({worktreeId:k,path:y,...v?{ref:v}:{},..._?{since:_}:{}}))??jE,[p,k,y,v,_,E,c,h]),W=P(V=>go(V,k).changedRanges[y]);S.useEffect(()=>{!W&&!M&&!C&&!E&&(h==null||h.send({t:"changed-ranges",worktreeId:k,path:y}))},[k,y,W,M,C,E,h]);const R=(W==null?void 0:W.offset)??0,j=e.disk,A=e.view??"diff",D=(j==null?void 0:j.before)==="",H=Zx(y,D).filter(V=>V!==A&&!(E&&V==="diff")),Y=(E==null?void 0:E.source.kind)==="grant"?E.source:null,ae=M||C||E&&!Y?null:XO(y),[me,ye]=S.useState(!1),_e=e.line&&!e.line.fiber?e.line.n:void 0;return f.jsxs(gg,{kind:"editor",className:Ke("editor-pane",n&&"full"),height:n||l?void 0:t,resizable:!n&&!l,onDragStart:s??Y5,title:M?`${y} at ${v==null?void 0:v.slice(0,7)}`:_?`${y}, last turn`:y,menu:()=>x&&!E?is({id:k,dir:x},y,{discard:!M&&!C,kept:C,ref:v,showing:e.view??void 0,added:D},{sock:h,dispatch:c}):[],onClose:()=>c({a:"close-editor"}),full:n,onToggleFull:l?void 0:r,actions:f.jsxs(f.Fragment,{children:[!ae&&H.map(V=>f.jsxs(Be,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>c({a:"editor-view",v:V}),"data-tip":X5(V,A),children:[f.jsx(Et,{name:Q5[V],className:"icon-inline"})," ",V]},V)),ae==="image"&&f.jsxs(Be,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>ye(!0),"data-tip":"Full size: see the picture over the window",children:[f.jsx(Et,{name:"zen",className:"icon-inline"})," full size"]}),!C&&N!==null&&f.jsx(G5,{absPath:N,onReveal:E?void 0:()=>h==null?void 0:h.send({t:"reveal",worktreeId:k,path:y})})]}),children:[j&&f.jsx(J5,{editor:e,disk:j,files:p}),f.jsx("div",{className:"editor-body",children:j?ae?f.jsx(D5,{kind:ae,src:Y?Z2(Y.id,Y.version):Cm(k,y,j.version),path:y,openSeq:e.seq,focus:e.focus,full:me,onFull:ye}):j.binary?f.jsx("div",{className:"empty",children:"not a text file: open it in another editor"}):j.tooLarge?f.jsx("div",{className:"empty",children:"too large to open here: open it in another editor"}):A==="preview"&&Cd(y)==="html"?f.jsx(B5,{text:j.after,path:y,worktreeId:k,version:M||C||E?void 0:j.version,openSeq:e.seq,focus:e.focus}):A==="preview"?f.jsx(Z5,{text:j.after,path:y,worktreeId:k,version:M||C||E?void 0:j.version,openSeq:e.seq,focus:e.focus,onChat:V=>sv(u,{worktreeId:k,text:V,name:y})}):f.jsx(mg,{pane:!0,children:f.jsx(S.Suspense,{fallback:f.jsx(C0,{what:A}),children:f.jsx(V5,{file:{worktreeId:k,path:y,...v?{ref:v}:{},..._?{since:_}:{}},disk:j,blame:e.blame,view:A,openSeq:e.seq,line:_e,focus:e.focus,readOnly:M||!j.writable||l,theme:g,sync:J,onCopy:E?void 0:(V,O,F)=>j2(F,{worktreeId:k,path:V,...O,...v?{ref:v}:{}}),onChat:(V,O)=>sv(u,O&&(E?{worktreeId:k,text:O.text,name:V}:{worktreeId:k,text:O.text,source:{path:V,startLine:O.startLine,endLine:O.endLine,...v?{ref:v}:{}}})),onNew:()=>u.dispatch({a:"open-draft"}),onLineHover:M||E?void 0:V=>{V==null?Wt.post(k,{type:"highlight-clear"}):Wt.post(k,{type:"highlight-file",path:y,ranges:[[V+R,V+R]]})}},`${k}
|
|
240
|
+
${E?"loose":v??_??""}
|
|
241
|
+
${y}`)})}):f.jsx(C0,{what:y},y)})]})}function J5({editor:e,disk:t,files:n}){const{worktreeId:r,path:s,ref:a,since:l,conflict:c}=e,u={worktreeId:r,path:s,...a?{ref:a}:{},...l?{since:l}:{}};if(c){const h=c.version===null;return f.jsxs("div",{className:"editor-note",children:[f.jsx("span",{className:"editor-note-text",children:h?"deleted on disk; your edits are not saved":"changed on disk; your edits are not saved"}),f.jsx(Be,{variant:"outline",onClick:()=>n==null?void 0:n.reload(u),"data-tip":h?"Close the file; your edits go with it":"Take the file as it is on disk; undo brings your edits back",children:h?"close":"reload"}),f.jsx(Be,{variant:"outline",tone:"danger",onClick:()=>n==null?void 0:n.keepMine(u),"data-tip":h?"Save your edits as the file again":"Save your edits over the file on disk",children:"keep mine"})]})}return e.refused?f.jsx("div",{className:"editor-note",children:f.jsx("span",{className:"hint",children:e.refused})}):e.loose&&!t.writable&&!t.tooLarge&&!t.binary?f.jsx("div",{className:"editor-note",children:f.jsxs("span",{className:"hint",children:["read-only: ",s," is not in a project; drop it on a folder in files to add it"]})}):a===void 0&&!t.writable&&!t.binary&&!t.tooLarge?f.jsx("div",{className:"editor-note",children:f.jsx("span",{className:"hint",children:"read-only: Toyon does not run this worktree"})}):null}function kg(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 AE(e,t,n=!1){var s;const r=((s=t.find(a=>a.id===(e==null?void 0:e.repoId)))==null?void 0:s.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}:n?{text:"Toyon's shell was rebuilt while this page was open",reload:!0,busy:!1}:e!=null&&e.restart?{text:`Toyon itself is behind ${r}`,restart:!0,busy:!1}:null}const IE=e=>`Toyon restarts once ${e.join(", ")} ${e.length===1?"finishes":"finish"}`,e6=(e,t)=>[...e,...t.filter(n=>!e.includes(n))];function t6(e,t,n){const r=[...t];return[...e.map(a=>{const l=r.indexOf(a);return l===-1?{name:a,dot:"idle",note:"finished"}:(r.splice(l,1),{name:a,dot:"working",note:null})}),...n.map(a=>({name:a,dot:"waiting",note:"asking you"}))]}function n6(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 r6(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:IE(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}const o6=(e,t)=>{const n=fh(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"}},hd="https://github.com/toyon-dev/toyon",s6=e=>`${hd}/releases/tag/v${e}`,i6=`${hd}/releases/latest`,a6=4e3;function l6(e,t,n,r){if(r==="asking")return{value:`${e} checking`,text:`Asking ${fh(n)} for the newest version`,act:"check",busy:!0};const s=fh(r.registry),a={act:"check",busy:!1};if(r.latest===null)return{...a,value:`${e} no answer`,text:`Could not reach ${s}. Press to ask again`,settles:!0};if(YO(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{...a,value:`${r.latest} out`,text:`Toyon ${r.latest} is out. ${l}`}}return{...a,value:`${e} up to date`,text:`Toyon ${e} is the newest version ${s} lists. Press to ask again`,settles:!0}}function c6(e,t,n,r,s,a=!1,l=null,c=null){if(n){if(n.restarting){const h=n.installed??n.running,p=n.restarting.length>0?IE(n.restarting):"Toyon is restarting; this page reloads when it is back";return{value:`${h} restarting`,text:p,act:"restart",busy:!0}}if(n.installing){const h=n.latest??n.installed??n.running;return{value:`${h} installing`,text:`Installing Toyon ${h}`,act:"update",busy:!0}}if(n.failed){const h=n.failed.line.replace(/\.$/,"");return{value:`${n.running} update failed`,text:`Installing Toyon ${n.failed.version} stopped: ${h}. Press to try again, or run ${n.failed.command}`,act:"update",busy:!1}}if(n.installed)return{value:`${n.installed} ready`,text:`Toyon ${n.installed} is installed and ${n.running} is still running. It restarts onto the new one when nothing is busy; press to restart now`,act:"restart",busy:!1};if(n.latest)return{value:`${n.latest} out`,text:n.method==="npx"?`Toyon ${n.latest} is out. This copy runs with npx, so run npx toyon@${n.latest} to use it`:`Toyon ${n.latest} is out and installs when nothing is busy; press to install now`,act:"update",busy:!1}}const u=AE(r,s,a);return u?u.busy?{value:`${e} rebuilding`,text:u.text,act:"rebuild",busy:!0}:u.reload?{value:`${e} rebuilt`,text:u.text,act:"reload",busy:!1}:u.build==="try again"?{value:`${e} rebuild stopped`,text:u.text,detail:u.detail,act:"rebuild",busy:!1}:{value:`${e} behind`,text:u.text,act:u.build?"rebuild":"restart",busy:!1}:c?l6(e,t,l,c):{value:e,text:`Toyon ${e}, ${o6(t,l)}`,act:"check",busy:!1}}function u6(e,t){const n=r=>()=>window.open(r,"_blank");return Mn([t?[{id:"check-update",label:"check for updates",...t.off?{disabled:t.off}:{},onClick:t.run}]:[],[{id:"release-notes",label:`release notes for ${e}`,onClick:n(s6(e))},{id:"latest-release",label:"latest release",onClick:n(i6)},{id:"repo",label:"Toyon on GitHub",onClick:n(hd)},{id:"report",label:"report a problem",onClick:n(`${hd}/issues/new`)}],[{id:"copy-version",label:"copy version",onClick:()=>Bt(e)}]])}const d6=GN.map(e=>({title:e,rows:QN(e).map(t=>[xt(t),Cl[t].label])}));function f6(){const e=ht(),t=ot(),n=Jt("keys"),r=P(p=>p.themePrefs),s=P(p=>p.themes),a=P(p=>p.chatSide),l=Em(),c=P(p=>p.agents),u=$a(),h=p=>{e({a:"palette-return",v:{mode:"keys",q:""}}),e(p)};return f.jsxs(Wd,{bare:!0,boxClass:"keys-stack",id:"keys-help",onClose:()=>e({a:"close"}),children:[f.jsxs("div",{className:"keys-card",children:[f.jsxs("div",{children:[u&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"section-title keys-h",children:u.name}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"processes"}),f.jsx(Be,{variant:"field",mono:!0,className:"keys-chip","data-tip":`edit the install + start commands in ${u.configFile}`,onClick:()=>e({a:"open",overlay:{kind:"setup",repoId:u.id}}),...n.contextMenu(()=>Hd(u,u.id,{sock:t,dispatch:e})),children:f.jsx("span",{className:"keys-v",children:Object.keys(u.config.run).join(" + ")||"not set up"})})]})]}),f.jsx("div",{className:"section-title keys-h",children:"Agents"}),c.map(p=>f.jsx(m6,{agent:p},p.id))]}),f.jsxs("div",{children:[f.jsx("div",{className:"section-title keys-h",children:"Appearance"}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"mode"}),f.jsx(Be,{variant:"field",mono:!0,onClick:()=>h({a:"open",overlay:{kind:"appearance"}}),children:cd[r.mode]})]}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"theme"}),f.jsx(Be,{variant:"field",mono:!0,onClick:()=>h({a:"open",overlay:{kind:"theme",slot:"theme"}}),children:jd(r,s,l).name})]}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"chat side"}),f.jsx(Be,{variant:"field",mono:!0,onClick:()=>e({a:"toggle-chat-side"}),children:a})]}),f.jsx("div",{className:"section-title keys-h",children:"Toyon"}),f.jsx(p6,{}),f.jsx(h6,{})]})]}),f.jsx("div",{className:"keys-card",children:d6.map(p=>f.jsxs("div",{children:[f.jsx("div",{className:"section-title keys-h",children:p.title}),p.rows.map(([g,k])=>f.jsxs("div",{className:"keys-row",children:[f.jsx(Or,{k:g}),f.jsx("span",{className:"keys-d",children:k})]},g))]},p.title))})]})}function p6(){const e=ot(),t=ht(),n=Jt("keys"),r=P(C=>C.version),s=P(C=>C.install),a=P(C=>C.registry),l=P(C=>C.update),c=P(C=>C.self),u=P(C=>C.rebuilt),h=P(C=>C.repos),p=P(C=>C.managed.updates),g=P(C=>C.updateCheck),k=c6(r,s,l,c,h,u,a,g),y=!p&&(k.act==="update"||k.act==="check"),v=k.settles&&g&&g!=="asking"?g:null;S.useEffect(()=>{if(!v)return;const C=()=>t({a:"update-check-settle",check:v}),x=setTimeout(C,a6);return()=>{clearTimeout(x),C()}},[v,t]);const _=()=>{k.act==="restart"?e==null||e.send({t:"restart-daemon"}):k.act==="reload"?window.location.reload():k.act==="rebuild"&&c?e==null||e.send({t:"run-after-land",repoId:c.repoId}):k.act==="update"?e==null||e.send({t:"update-now"}):k.act==="check"&&e&&(t({a:"update-check"}),e.send({t:"check-update"}))},E=()=>u6(r,k.act==="check"&&!k.busy?{run:_,...y?{off:"managed by your organization"}:{}}:null);return f.jsxs("div",{className:"keys-setting",...n.contextMenu(E),children:[f.jsx("span",{className:"keys-d",children:"version"}),f.jsx(Be,{variant:"field",mono:!0,busy:k.busy,disabled:y,onClick:_,...It(y?"updates are managed by your organization":k.text,void 0,{detail:k.detail}),children:k.value})]})}function h6(){const e=P(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: ${zR(e).join(", ")||"nothing turned off"}`;return f.jsx("div",{className:"hint",children:t})}function RE(e){return e.available?e.auth?e.auth.kind==="none"?"not logged in":e.auth.label:"ready":e.installing?"installing":"not installed"}function OE(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 m6({agent:e}){const t=ht(),n=ot(),r=Jt("keys");return f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:e.name}),f.jsx(Be,{variant:"field",mono:!0,"data-tip":OE(e),...r.contextMenu(()=>kg(e,{sock:n})),onClick:()=>{t({a:"palette-return",v:{mode:"keys",q:""}}),t({a:"open",overlay:{kind:"agent-page",agent:e.id}})},children:RE(e)})]})}function g6({agentId:e}){const t=ht(),n=ot(),r=$a(),s=P(k=>k.home),a=P(k=>k.agents.find(y=>y.id===e)??null),l=P(k=>k.agentConfigs[e]??null),c=Jt("keys");if(S.useEffect(()=>{n==null||n.send({t:"agent-config",agent:e,...r?{repoId:r.id}:{}})},[n,e,r]),!a)return null;const u=kg(a,{sock:n}),h=()=>t({a:"close",back:!0}),p=k=>s&&k.startsWith(`${s}/`)?`~${k.slice(s.length)}`:k,g=k=>n==null?void 0:n.send({t:"reveal-agent-file",agent:e,file:k.id,...r?{repoId:r.id}:{}});return f.jsx(Wd,{bare:!0,boxClass:"keys-stack",onClose:h,children:f.jsxs("div",{className:"keys-card keys-settings",children:[f.jsx("div",{className:"agent-page-back",children:f.jsx($t,{icon:"back",label:"back to settings",hint:"esc",onClick:h})}),f.jsx("div",{className:"section-title keys-h",children:a.name}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"signed in"}),f.jsx(Be,{variant:"field",mono:!0,"data-tip":OE(a),disabled:u.length===0,...c.dropdown(()=>u,"right"),children:RE(a)})]}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"commit messages"}),f.jsx("span",{className:"keys-d",children:a.quick?"its quick model writes one after each turn":"none: it has no quick model, so you write them in the changes panel; quickModel in agents.json names one"})]}),f.jsx("div",{className:"section-title keys-h",children:"MCP servers it will load"}),l===null?f.jsx("div",{className:"keys-setting",children:f.jsx("span",{className:"keys-d",children:"reading…"})}):l.servers.length===0?f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"none configured"}),f.jsx("span",{className:"keys-d",children:"add one with the agent's own CLI, or a .mcp.json in the repo"})]}):l.servers.map(k=>f.jsx(k6,{s:k},`${k.scope}:${k.name}`)),l&&l.files.length>0&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"section-title keys-h",children:"the files it reads"}),l.files.map(k=>f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:k.label}),k.exists?f.jsx(Be,{variant:"field",mono:!0,"data-tip":`reveal ${p(k.path)} in Finder`,onClick:()=>g(k),children:p(k.path)}):f.jsxs("span",{className:"keys-d",children:["not present: ",p(k.path)]})]},k.id))]})]})})}function k6({s:e}){return f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{children:e.name}),f.jsx("span",{className:"keys-d",children:e.detail?`${e.scope} · ${e.detail}`:e.scope})]})}function y6(){const e=ht(),t=ot(),n=P(s=>s.agents),r=P(s=>s.defaultAgent);return f.jsx(Kr,{items:n,filter:(s,a)=>s.filter(l=>Na(a,l.name,l.id)),rowClass:s=>s.available?"picker-row":"picker-row dim",keyOf:s=>s.id,initialIndex:s=>Math.max(0,s.findIndex(a=>a.id===r)),onPick:s=>{s.available&&(t==null||t.send({t:"set-default-agent",agent:s.id}),e({a:"close"}))},onBack:()=>e({a:"close",back:!0}),rowMenu:s=>kg(s,{sock:t}),placeholder:"default agent for new worktrees",keys:{pick:"sets",back:"closes"},row:s=>f.jsx(rr,{label:s.name,current:s.id===r,hint:s.available?s.sandboxed?void 0:"unsandboxed":s.reason??"not installed"})})}const w6=["dark","light","system","daylight"],v6=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"});function b6(){const e=ht(),t=ot(),n=P(u=>u.themePrefs),r=P(u=>u.themes),s=Em(),a=P(u=>u.daylight),l=u=>{var h;return((h=r.find(p=>p.id===n[mm({...n,mode:u},s)]))==null?void 0:h.name)??""},c=u=>{if(u==="system")return`${s.system?"dark":"light"} now · ${l(u)}`;if(u!=="daylight")return l(u);const h=a&&a.until>Date.now()?` · ${s.daylight?"light":"dark"} at ${v6.format(a.until)}`:"";return`${s.daylight?"dark":"light"} now${h} · ${l(u)}`};return f.jsx(Kr,{items:w6,filter:(u,h)=>u.filter(p=>Na(h,cd[p])),rowClass:()=>"picker-row",keyOf:u=>u,initialIndex:u=>u.indexOf(n.mode),onActive:u=>e({a:"preview-theme",theme:u?jd({...n,mode:u},r,s):null}),onPick:u=>{t==null||t.send({t:"set-theme",prefs:{...n,mode:u}}),e({a:"close"})},onBack:()=>e({a:"close",back:!0}),placeholder:"light/dark mode",keys:{nav:"preview",pick:"keeps",back:"reverts"},row:u=>f.jsx(rr,{label:cd[u],current:u===n.mode,hint:c(u)})})}const x6=2,Kh=e=>Zb(e).join(" ").length<x6,_6=e=>({kind:"chat",id:e.id,name:e.name,hint:e.branch??"",fields:[e.name,e.branch??""]}),E6=e=>({kind:"chat",id:e.id,name:e.title,hint:R1(e),fields:[e.title,e.branch],prompt:e.prompt,archived:e});function S6(e,t,n){const r=Zb(t),s=n==="all"&&!Kh(t);return e.filter(a=>{if(a.kind==="hit")return s;const l=n==="names"&&a.prompt?[...a.fields,a.prompt]:a.fields;return r.every(c=>l.some(u=>u.toLowerCase().includes(c)))})}const N6=e=>e.flatMap(([t,n])=>Array.from({length:n},(r,s)=>t+s));function T6({repoId:e,scope:t}){const n=ht(),r=ot(),s=P(x=>x.clientId),a=P(x=>x.chats[e]),l=Nm(),c=P(x=>x.archived[e]),[u,h]=S.useState(t),p=S.useCallback(()=>h(x=>x==="all"?"names":"all"),[]);S.useEffect(()=>{r==null||r.send({t:"list-archived",repoId:e})},[r,e]);const g=S.useMemo(()=>[...l.filter(x=>!hr(x.worktree)).map(_6),...(c??[]).map(E6)],[l,c]),k=S.useMemo(()=>new Map(g.map(x=>[x.id,x])),[g]),y=S.useMemo(()=>[...g,...((a==null?void 0:a.hits)??[]).map(x=>({kind:"hit",hit:x}))],[g,a]),v=S.useCallback((x,N)=>S6(x,N,u),[u]),_=S.useCallback(x=>{u==="all"&&!Kh(x)&&(r==null||r.send({t:"search-chats",repoId:e,query:x.trim()}))},[r,e,u]),E=x=>!a||a.query!==x.trim(),C=x=>u==="all"&&!Kh(x);return f.jsx(Kr,{items:y,filter:v,onQuery:_,onTab:p,trailing:f.jsx(Be,{tone:"chrome",on:u==="names","aria-pressed":u==="names",onClick:p,children:"names only"}),keyOf:x=>x.kind==="hit"?`h:${x.hit.worktreeId}:${x.hit.seq}`:`w:${x.id}`,rowClass:x=>x.kind==="hit"?"chats-hit":Ke("picker-row",x.archived&&!x.archived.restorable&&"dim"),rowTitle:x=>{var N;return x.kind==="hit"?x.hit.text:((N=x.archived)==null?void 0:N.prompt)??x.name},groupOf:x=>x.kind==="hit"?`h:${x.hit.worktreeId}`:x.archived?"archived":"open",groupHead:(x,N)=>{if(!x.startsWith("h:"))return`${x} · ${N}`;const M=k.get(x.slice(2));return f.jsxs("span",{children:[(M==null?void 0:M.name)??"a worktree",(M==null?void 0:M.archived)&&f.jsxs(f.Fragment,{children:[" ",f.jsx("span",{className:"row-dim",children:"archived"})]}),` · ${N}`]})},headAlone:!0,onPick:x=>{const N=x.kind==="hit"?x.hit.worktreeId:x.id,M=x.kind==="hit"?x.hit.archived:!!x.archived;n(M?{a:"open-archived",id:N}:{a:"activate",id:N}),x.kind==="hit"&&n({a:"reveal",id:N,seq:x.hit.seq}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:x=>x.kind==="chat"&&x.archived?Pu(x.archived,s,{sock:r,dispatch:n}):[],placeholder:u==="names"?"find a chat by name…":"search in chats…",keys:x=>({nav:"moves",tab:u==="names"?"searches messages too":"searches names only",pick:x?x.kind==="hit"?"opens the chat there":"opens its chat":void 0,back:"closes"}),empty:x=>x.trim()?C(x)?E(x)?"searching…":"no chat says that":"no chat is named that":c?"no chats yet":"looking…",footer:(x,N)=>{const M=N.filter(J=>J.kind==="hit").length;return a!=null&&a.truncated&&!E(x)&&M>0?f.jsxs("div",{className:"empty",children:["showing the first ",M,"; narrow the search"]}):null},row:x=>x.kind==="chat"?f.jsx(rr,{label:x.name,hint:x.hint}):f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"chats-text",children:Gl(x.hit.text,N6(x.hit.match),0)}),f.jsxs("span",{className:"chats-said row-dim",children:[x.hit.role==="user"?"you":"the agent",x.hit.ts>0?` · ${Ur(x.hit.ts)}`:""]})]})})}function j6({worktreeId:e,hits:t}){const n=ht(),r=ot(),s=P(c=>c.layout.changes),a=P(c=>{var h;const u=(h=fn(c,e))==null?void 0:h.worktree;return u?u.path:null}),l=S.useCallback((c,u)=>{const h=u.trim().toLowerCase();return h?c.filter(p=>`${p.path}:${p.line} ${p.text}`.toLowerCase().includes(h)):c},[]);return f.jsx(Kr,{items:t,filter:l,keyOf:c=>`${c.path}:${c.line}`,rowClass:()=>"search-hit",rowTitle:c=>`${c.path}:${c.line}`,onPick:c=>{Vn({dispatch:n},{worktreeId:e,path:c.path,view:"file",line:{n:c.line}}),s||n({a:"toggle-changes"}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:c=>a?is({id:e,dir:a},c.path,{},{sock:r,dispatch:n}):[],placeholder:"lines that could write this element",keys:{pick:"opens the file",back:"closes"},row:c=>f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"search-loc",children:[c.path,":",c.line]}),f.jsx("span",{className:"search-text",children:c.text})]})})}const Kd=e=>/^(~|\/|\.\.?\/)/.test(e.trim());function $E(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 C6(e,t,n){const r=e.map(h=>h.path.slice(0,h.path.lastIndexOf("/"))).filter(Boolean),s=e.find(h=>h.id===t),a=s==null?void 0:s.path.slice(0,s.path.lastIndexOf("/")),l=new Map;for(const h of r)l.set(h,(l.get(h)??0)+1);let c="",u=0;for(const[h,p]of[...l].sort(([g],[k])=>g.localeCompare(k)))(p>u||p===u&&h===a)&&(c=h,u=p);return c?ME(c,n):`~/${Hb}`}function ME(e,t){return t&&(e===t||e.startsWith(`${t}/`))?`~${e.slice(t.length)}`:e}function LE(e,t){return`${e.replace(/\/+$/,"")}/${t.trim()}`}function A6(e){const t=e.query.trim(),n=()=>e.entries.map(l=>({kind:"dir",entry:l}));if(!Kd(t)){const l=e.repos.filter(g=>Na(t,g.name,g.path)).map(g=>({kind:"repo",repo:g})),c=e.pending.filter(g=>Na(t,g.name,g.url)).map(g=>({kind:"pending",pending:g})),u=[...l,...c];if(!t)return[...u,{kind:"new"},{kind:"disk"}];const h=tO(t);if(h)return u.length>0?u:[{kind:"clone",url:h.url,name:h.name}];const p=g=>g.toLowerCase()===t.toLowerCase();return e.repos.some(g=>p(g.name))||e.pending.some(g=>p(g.name))||Bl(t)?u:[...u,{kind:"create",name:t,parent:null}]}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:s,name:a}=$E(t);return Bl(a)?n():[...n(),{kind:"create",name:a,parent:s}]}function Vl(e,t){return t&&(e==="~"||e.startsWith("~/"))?`${t}${e.slice(1)}`:e}function PE(e,t){const n=Vl(e,t).replace(/\/+$/,"");return n.startsWith("/")?ME(n.slice(0,n.lastIndexOf("/"))||"/",t):null}function Zh(e,t){const n=Vl(e,t).replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||"/"}function I6(e){const t=e.query.trim(),n=t.lastIndexOf("/"),r=n<0?"":t.slice(0,n)||"/",s=Vl(r,e.home);if(!Kd(t)||!s.startsWith("/"))return[];const a=t.slice(n+1).toLowerCase(),l=e.answered.trim()===t?e.target:null,c=!l||(a?l.parentExists:l.exists&&l.isDir&&!l.isRepo),u=e.entries.filter(p=>{if(p.isRepo)return!1;const g=Vl(p.path,e.home);return(g.slice(0,g.lastIndexOf("/"))||"/")===s&&p.name.toLowerCase().startsWith(a)}),h=PE(r,e.home);return[...c?[{kind:"here",path:r}]:[],...h?[{kind:"up",path:h}]:[],...u.map(p=>({kind:"dir",entry:p}))]}function R6({project:e}){const t=ht(),n=ot(),r=P(h=>h.paths),s=P(h=>h.home),a=S.useCallback(h=>{Kd(h)&&(n==null||n.send({t:"browse-path",path:h}))},[n]),l=S.useCallback((h,p)=>I6({query:p,entries:r.entries,target:r.target,answered:r.query,home:s}),[r,s]),c=Bl(e.name)?null:e.name.trim(),u=h=>`${h.replace(/\/+$/,"")}/`;return f.jsx(Kr,{initialQuery:u(e.parent),lead:f.jsx("span",{className:"picker-chip",children:c??"new project"}),items:[],filter:l,keyOf:h=>h.kind==="dir"?`d:${h.entry.path}`:`${h.kind}:${h.path}`,rowClass:()=>"picker-row folder-row",onQuery:a,completionOf:h=>h.kind==="dir"?u(h.entry.path):null,narrowTo:h=>h.kind==="dir"?u(h.entry.path):h.kind==="up"?u(h.path):null,onPick:h=>{h.kind==="here"&&(t({a:"new-project-set",v:{mode:e.mode==="init"?"create":e.mode,parent:h.path}}),t({a:"close"}))},onBack:()=>t({a:"close"}),placeholder:"type a folder path",keys:h=>({complete:"completes the path",pick:(h==null?void 0:h.kind)==="here"?"chooses it":(h==null?void 0:h.kind)==="up"?"goes up":"opens it",back:"goes back"}),empty:"no such folder",row:h=>h.kind==="here"?f.jsx(rr,{label:`put ${c??"it"} in ${Zh(h.path,s)}`,hint:f.jsx("bdi",{children:c?LE(h.path,c):h.path})}):h.kind==="up"?f.jsx(rr,{label:`up to ${Zh(h.path,s)}`,hint:f.jsx("bdi",{children:h.path})}):f.jsx(rr,{label:h.entry.name})})}const Pa=function(e,t){let s=e;const a=jl[t];let l=null,c=0,u=null;const h=[],p={},g=function(R,j){c=s*4+17,l=(function(A){const D=new Array(A);for(let H=0;H<A;H+=1){D[H]=new Array(A);for(let Y=0;Y<A;Y+=1)D[H][Y]=null}return D})(c),k(0,0),k(c-7,0),k(0,c-7),_(),v(),C(R,j),s>=7&&E(R),u==null&&(u=M(s,a,h)),x(u,j)},k=function(R,j){for(let A=-1;A<=7;A+=1)if(!(R+A<=-1||c<=R+A))for(let D=-1;D<=7;D+=1)j+D<=-1||c<=j+D||(0<=A&&A<=6&&(D==0||D==6)||0<=D&&D<=6&&(A==0||A==6)||2<=A&&A<=4&&2<=D&&D<=4?l[R+A][j+D]=!0:l[R+A][j+D]=!1)},y=function(){let R=0,j=0;for(let A=0;A<8;A+=1){g(!0,A);const D=Ds.getLostPoint(p);(A==0||R>D)&&(R=D,j=A)}return j},v=function(){for(let R=8;R<c-8;R+=1)l[R][6]==null&&(l[R][6]=R%2==0);for(let R=8;R<c-8;R+=1)l[6][R]==null&&(l[6][R]=R%2==0)},_=function(){const R=Ds.getPatternPosition(s);for(let j=0;j<R.length;j+=1)for(let A=0;A<R.length;A+=1){const D=R[j],H=R[A];if(l[D][H]==null)for(let Y=-2;Y<=2;Y+=1)for(let ae=-2;ae<=2;ae+=1)Y==-2||Y==2||ae==-2||ae==2||Y==0&&ae==0?l[D+Y][H+ae]=!0:l[D+Y][H+ae]=!1}},E=function(R){const j=Ds.getBCHTypeNumber(s);for(let A=0;A<18;A+=1){const D=!R&&(j>>A&1)==1;l[Math.floor(A/3)][A%3+c-8-3]=D}for(let A=0;A<18;A+=1){const D=!R&&(j>>A&1)==1;l[A%3+c-8-3][Math.floor(A/3)]=D}},C=function(R,j){const A=a<<3|j,D=Ds.getBCHTypeInfo(A);for(let H=0;H<15;H+=1){const Y=!R&&(D>>H&1)==1;H<6?l[H][8]=Y:H<8?l[H+1][8]=Y:l[c-15+H][8]=Y}for(let H=0;H<15;H+=1){const Y=!R&&(D>>H&1)==1;H<8?l[8][c-H-1]=Y:H<9?l[8][15-H-1+1]=Y:l[8][15-H-1]=Y}l[c-8][8]=!R},x=function(R,j){let A=-1,D=c-1,H=7,Y=0;const ae=Ds.getMaskFunction(j);for(let me=c-1;me>0;me-=2)for(me==6&&(me-=1);;){for(let ye=0;ye<2;ye+=1)if(l[D][me-ye]==null){let _e=!1;Y<R.length&&(_e=(R[Y]>>>H&1)==1),ae(D,me-ye)&&(_e=!_e),l[D][me-ye]=_e,H-=1,H==-1&&(Y+=1,H=7)}if(D+=A,D<0||c<=D){D-=A,A=-A;break}}},N=function(R,j){let A=0,D=0,H=0;const Y=new Array(j.length),ae=new Array(j.length);for(let V=0;V<j.length;V+=1){const O=j[V].dataCount,F=j[V].totalCount-O;D=Math.max(D,O),H=Math.max(H,F),Y[V]=new Array(O);for(let ke=0;ke<Y[V].length;ke+=1)Y[V][ke]=255&R.getBuffer()[ke+A];A+=O;const ne=Ds.getErrorCorrectPolynomial(F),q=Yl(Y[V],ne.getLength()-1).mod(ne);ae[V]=new Array(ne.getLength()-1);for(let ke=0;ke<ae[V].length;ke+=1){const se=ke+q.getLength()-ae[V].length;ae[V][ke]=se>=0?q.getAt(se):0}}let me=0;for(let V=0;V<j.length;V+=1)me+=j[V].totalCount;const ye=new Array(me);let _e=0;for(let V=0;V<D;V+=1)for(let O=0;O<j.length;O+=1)V<Y[O].length&&(ye[_e]=Y[O][V],_e+=1);for(let V=0;V<H;V+=1)for(let O=0;O<j.length;O+=1)V<ae[O].length&&(ye[_e]=ae[O][V],_e+=1);return ye},M=function(R,j,A){const D=A0.getRSBlocks(R,j),H=I0();for(let ae=0;ae<A.length;ae+=1){const me=A[ae];H.put(me.getMode(),4),H.put(me.getLength(),Ds.getLengthInBits(me.getMode(),R)),me.write(H)}let Y=0;for(let ae=0;ae<D.length;ae+=1)Y+=D[ae].dataCount;if(H.getLengthInBits()>Y*8)throw"code length overflow. ("+H.getLengthInBits()+">"+Y*8+")";for(H.getLengthInBits()+4<=Y*8&&H.put(0,4);H.getLengthInBits()%8!=0;)H.putBit(!1);for(;!(H.getLengthInBits()>=Y*8||(H.put(236,8),H.getLengthInBits()>=Y*8));)H.put(17,8);return N(H,D)};p.addData=function(R,j){j=j||"Byte";let A=null;switch(j){case"Numeric":A=O6(R);break;case"Alphanumeric":A=$6(R);break;case"Byte":A=M6(R);break;case"Kanji":A=L6(R);break;default:throw"mode:"+j}h.push(A),u=null},p.isDark=function(R,j){if(R<0||c<=R||j<0||c<=j)throw R+","+j;return l[R][j]},p.getModuleCount=function(){return c},p.make=function(){if(s<1){let R=1;for(;R<40;R++){const j=A0.getRSBlocks(R,a),A=I0();for(let H=0;H<h.length;H++){const Y=h[H];A.put(Y.getMode(),4),A.put(Y.getLength(),Ds.getLengthInBits(Y.getMode(),R)),Y.write(A)}let D=0;for(let H=0;H<j.length;H++)D+=j[H].dataCount;if(A.getLengthInBits()<=D*8)break}s=R}g(!1,y())},p.createTableTag=function(R,j){R=R||2,j=typeof j>"u"?R*4:j;let A="";A+='<table style="',A+=" border-width: 0px; border-style: none;",A+=" border-collapse: collapse;",A+=" padding: 0px; margin: "+j+"px;",A+='">',A+="<tbody>";for(let D=0;D<p.getModuleCount();D+=1){A+="<tr>";for(let H=0;H<p.getModuleCount();H+=1)A+='<td style="',A+=" border-width: 0px; border-style: none;",A+=" border-collapse: collapse;",A+=" padding: 0px; margin: 0px;",A+=" width: "+R+"px;",A+=" height: "+R+"px;",A+=" background-color: ",A+=p.isDark(D,H)?"#000000":"#ffffff",A+=";",A+='"/>';A+="</tr>"}return A+="</tbody>",A+="</table>",A},p.createSvgTag=function(R,j,A,D){let H={};typeof arguments[0]=="object"&&(H=arguments[0],R=H.cellSize,j=H.margin,A=H.alt,D=H.title),R=R||2,j=typeof j>"u"?R*4:j,A=typeof A=="string"?{text:A}:A||{},A.text=A.text||null,A.id=A.text?A.id||"qrcode-description":null,D=typeof D=="string"?{text:D}:D||{},D.text=D.text||null,D.id=D.text?D.id||"qrcode-title":null;const Y=p.getModuleCount()*R+j*2;let ae,me,ye,_e,V="",O;for(O="l"+R+",0 0,"+R+" -"+R+",0 0,-"+R+"z ",V+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',V+=H.scalable?"":' width="'+Y+'px" height="'+Y+'px"',V+=' viewBox="0 0 '+Y+" "+Y+'" ',V+=' preserveAspectRatio="xMinYMin meet"',V+=D.text||A.text?' role="img" aria-labelledby="'+J([D.id,A.id].join(" ").trim())+'"':"",V+=">",V+=D.text?'<title id="'+J(D.id)+'">'+J(D.text)+"</title>":"",V+=A.text?'<description id="'+J(A.id)+'">'+J(A.text)+"</description>":"",V+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',V+='<path d="',ye=0;ye<p.getModuleCount();ye+=1)for(_e=ye*R+j,ae=0;ae<p.getModuleCount();ae+=1)p.isDark(ye,ae)&&(me=ae*R+j,V+="M"+me+","+_e+O);return V+='" stroke="transparent" fill="black"/>',V+="</svg>",V},p.createDataURL=function(R,j){R=R||2,j=typeof j>"u"?R*4:j;const A=p.getModuleCount()*R+j*2,D=j,H=A-j;return F6(A,A,function(Y,ae){if(D<=Y&&Y<H&&D<=ae&&ae<H){const me=Math.floor((Y-D)/R),ye=Math.floor((ae-D)/R);return p.isDark(ye,me)?0:1}else return 1})},p.createImgTag=function(R,j,A){R=R||2,j=typeof j>"u"?R*4:j;const D=p.getModuleCount()*R+j*2;let H="";return H+="<img",H+=' src="',H+=p.createDataURL(R,j),H+='"',H+=' width="',H+=D,H+='"',H+=' height="',H+=D,H+='"',A&&(H+=' alt="',H+=J(A),H+='"'),H+="/>",H};const J=function(R){let j="";for(let A=0;A<R.length;A+=1){const D=R.charAt(A);switch(D){case"<":j+="<";break;case">":j+=">";break;case"&":j+="&";break;case'"':j+=""";break;default:j+=D;break}}return j},W=function(R){R=typeof R>"u"?2:R;const A=p.getModuleCount()*1+R*2,D=R,H=A-R;let Y,ae,me,ye,_e;const V={"██":"█","█ ":"▀"," █":"▄"," ":" "},O={"██":"▀","█ ":"▀"," █":" "," ":" "};let F="";for(Y=0;Y<A;Y+=2){for(me=Math.floor((Y-D)/1),ye=Math.floor((Y+1-D)/1),ae=0;ae<A;ae+=1)_e="█",D<=ae&&ae<H&&D<=Y&&Y<H&&p.isDark(me,Math.floor((ae-D)/1))&&(_e=" "),D<=ae&&ae<H&&D<=Y+1&&Y+1<H&&p.isDark(ye,Math.floor((ae-D)/1))?_e+=" ":_e+="█",F+=R<1&&Y+1>=H?O[_e]:V[_e];F+=`
|
|
242
|
+
`}return A%2&&R>0?F.substring(0,F.length-A-1)+Array(A+1).join("▀"):F.substring(0,F.length-1)};return p.createASCII=function(R,j){if(R=R||1,R<2)return W(j);R-=1,j=typeof j>"u"?R*2:j;const A=p.getModuleCount()*R+j*2,D=j,H=A-j;let Y,ae,me,ye;const _e=Array(R+1).join("██"),V=Array(R+1).join(" ");let O="",F="";for(Y=0;Y<A;Y+=1){for(me=Math.floor((Y-D)/R),F="",ae=0;ae<A;ae+=1)ye=1,D<=ae&&ae<H&&D<=Y&&Y<H&&p.isDark(me,Math.floor((ae-D)/R))&&(ye=0),F+=ye?_e:V;for(me=0;me<R;me+=1)O+=F+`
|
|
243
|
+
`}return O.substring(0,O.length-1)},p.renderTo2dContext=function(R,j){j=j||2;const A=p.getModuleCount();for(let D=0;D<A;D++)for(let H=0;H<A;H++)R.fillStyle=p.isDark(D,H)?"black":"white",R.fillRect(H*j,D*j,j,j)},p};Pa.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};Pa.createStringToBytes=function(e,t){const n=(function(){const s=D6(e),a=function(){const u=s.read();if(u==-1)throw"eof";return u};let l=0;const c={};for(;;){const u=s.read();if(u==-1)break;const h=a(),p=a(),g=a(),k=String.fromCharCode(u<<8|h),y=p<<8|g;c[k]=y,l+=1}if(l!=t)throw l+" != "+t;return c})(),r=63;return function(s){const a=[];for(let l=0;l<s.length;l+=1){const c=s.charCodeAt(l);if(c<128)a.push(c);else{const u=n[s.charAt(l)];typeof u=="number"?(u&255)==u?a.push(u):(a.push(u>>>8),a.push(u&255)):a.push(r)}}return a}};const Sr={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},jl={L:1,M:0,Q:3,H:2},Ps={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},Ds=(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,s={},a=function(l){let c=0;for(;l!=0;)c+=1,l>>>=1;return c};return s.getBCHTypeInfo=function(l){let c=l<<10;for(;a(c)-a(t)>=0;)c^=t<<a(c)-a(t);return(l<<10|c)^r},s.getBCHTypeNumber=function(l){let c=l<<12;for(;a(c)-a(n)>=0;)c^=n<<a(c)-a(n);return l<<12|c},s.getPatternPosition=function(l){return e[l-1]},s.getMaskFunction=function(l){switch(l){case Ps.PATTERN000:return function(c,u){return(c+u)%2==0};case Ps.PATTERN001:return function(c,u){return c%2==0};case Ps.PATTERN010:return function(c,u){return u%3==0};case Ps.PATTERN011:return function(c,u){return(c+u)%3==0};case Ps.PATTERN100:return function(c,u){return(Math.floor(c/2)+Math.floor(u/3))%2==0};case Ps.PATTERN101:return function(c,u){return c*u%2+c*u%3==0};case Ps.PATTERN110:return function(c,u){return(c*u%2+c*u%3)%2==0};case Ps.PATTERN111:return function(c,u){return(c*u%3+(c+u)%2)%2==0};default:throw"bad maskPattern:"+l}},s.getErrorCorrectPolynomial=function(l){let c=Yl([1],0);for(let u=0;u<l;u+=1)c=c.multiply(Yl([1,Fs.gexp(u)],0));return c},s.getLengthInBits=function(l,c){if(1<=c&&c<10)switch(l){case Sr.MODE_NUMBER:return 10;case Sr.MODE_ALPHA_NUM:return 9;case Sr.MODE_8BIT_BYTE:return 8;case Sr.MODE_KANJI:return 8;default:throw"mode:"+l}else if(c<27)switch(l){case Sr.MODE_NUMBER:return 12;case Sr.MODE_ALPHA_NUM:return 11;case Sr.MODE_8BIT_BYTE:return 16;case Sr.MODE_KANJI:return 10;default:throw"mode:"+l}else if(c<41)switch(l){case Sr.MODE_NUMBER:return 14;case Sr.MODE_ALPHA_NUM:return 13;case Sr.MODE_8BIT_BYTE:return 16;case Sr.MODE_KANJI:return 12;default:throw"mode:"+l}else throw"type:"+c},s.getLostPoint=function(l){const c=l.getModuleCount();let u=0;for(let g=0;g<c;g+=1)for(let k=0;k<c;k+=1){let y=0;const v=l.isDark(g,k);for(let _=-1;_<=1;_+=1)if(!(g+_<0||c<=g+_))for(let E=-1;E<=1;E+=1)k+E<0||c<=k+E||_==0&&E==0||v==l.isDark(g+_,k+E)&&(y+=1);y>5&&(u+=3+y-5)}for(let g=0;g<c-1;g+=1)for(let k=0;k<c-1;k+=1){let y=0;l.isDark(g,k)&&(y+=1),l.isDark(g+1,k)&&(y+=1),l.isDark(g,k+1)&&(y+=1),l.isDark(g+1,k+1)&&(y+=1),(y==0||y==4)&&(u+=3)}for(let g=0;g<c;g+=1)for(let k=0;k<c-6;k+=1)l.isDark(g,k)&&!l.isDark(g,k+1)&&l.isDark(g,k+2)&&l.isDark(g,k+3)&&l.isDark(g,k+4)&&!l.isDark(g,k+5)&&l.isDark(g,k+6)&&(u+=40);for(let g=0;g<c;g+=1)for(let k=0;k<c-6;k+=1)l.isDark(k,g)&&!l.isDark(k+1,g)&&l.isDark(k+2,g)&&l.isDark(k+3,g)&&l.isDark(k+4,g)&&!l.isDark(k+5,g)&&l.isDark(k+6,g)&&(u+=40);let h=0;for(let g=0;g<c;g+=1)for(let k=0;k<c;k+=1)l.isDark(k,g)&&(h+=1);const p=Math.abs(100*h/c/c-50)/5;return u+=p*10,u},s})(),Fs=(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})(),Yl=function(e,t){if(typeof e.length>"u")throw e.length+"/"+t;const n=(function(){let s=0;for(;s<e.length&&e[s]==0;)s+=1;const a=new Array(e.length-s+t);for(let l=0;l<e.length-s;l+=1)a[l]=e[l+s];return a})(),r={};return r.getAt=function(s){return n[s]},r.getLength=function(){return n.length},r.multiply=function(s){const a=new Array(r.getLength()+s.getLength()-1);for(let l=0;l<r.getLength();l+=1)for(let c=0;c<s.getLength();c+=1)a[l+c]^=Fs.gexp(Fs.glog(r.getAt(l))+Fs.glog(s.getAt(c)));return Yl(a,0)},r.mod=function(s){if(r.getLength()-s.getLength()<0)return r;const a=Fs.glog(r.getAt(0))-Fs.glog(s.getAt(0)),l=new Array(r.getLength());for(let c=0;c<r.getLength();c+=1)l[c]=r.getAt(c);for(let c=0;c<s.getLength();c+=1)l[c]^=Fs.gexp(Fs.glog(s.getAt(c))+a);return Yl(l,0).mod(s)},r},A0=(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(s,a){const l={};return l.totalCount=s,l.dataCount=a,l},n={},r=function(s,a){switch(a){case jl.L:return e[(s-1)*4+0];case jl.M:return e[(s-1)*4+1];case jl.Q:return e[(s-1)*4+2];case jl.H:return e[(s-1)*4+3];default:return}};return n.getRSBlocks=function(s,a){const l=r(s,a);if(typeof l>"u")throw"bad rs block @ typeNumber:"+s+"/errorCorrectionLevel:"+a;const c=l.length/3,u=[];for(let h=0;h<c;h+=1){const p=l[h*3+0],g=l[h*3+1],k=l[h*3+2];for(let y=0;y<p;y+=1)u.push(t(g,k))}return u},n})(),I0=function(){const e=[];let t=0;const n={};return n.getBuffer=function(){return e},n.getAt=function(r){const s=Math.floor(r/8);return(e[s]>>>7-r%8&1)==1},n.put=function(r,s){for(let a=0;a<s;a+=1)n.putBit((r>>>s-a-1&1)==1)},n.getLengthInBits=function(){return t},n.putBit=function(r){const s=Math.floor(t/8);e.length<=s&&e.push(0),r&&(e[s]|=128>>>t%8),t+=1},n},O6=function(e){const t=Sr.MODE_NUMBER,n=e,r={};r.getMode=function(){return t},r.getLength=function(l){return n.length},r.write=function(l){const c=n;let u=0;for(;u+2<c.length;)l.put(s(c.substring(u,u+3)),10),u+=3;u<c.length&&(c.length-u==1?l.put(s(c.substring(u,u+1)),4):c.length-u==2&&l.put(s(c.substring(u,u+2)),7))};const s=function(l){let c=0;for(let u=0;u<l.length;u+=1)c=c*10+a(l.charAt(u));return c},a=function(l){if("0"<=l&&l<="9")return l.charCodeAt(0)-48;throw"illegal char :"+l};return r},$6=function(e){const t=Sr.MODE_ALPHA_NUM,n=e,r={};r.getMode=function(){return t},r.getLength=function(a){return n.length},r.write=function(a){const l=n;let c=0;for(;c+1<l.length;)a.put(s(l.charAt(c))*45+s(l.charAt(c+1)),11),c+=2;c<l.length&&a.put(s(l.charAt(c)),6)};const s=function(a){if("0"<=a&&a<="9")return a.charCodeAt(0)-48;if("A"<=a&&a<="Z")return a.charCodeAt(0)-65+10;switch(a){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 :"+a}};return r},M6=function(e){const t=Sr.MODE_8BIT_BYTE,n=Pa.stringToBytes(e),r={};return r.getMode=function(){return t},r.getLength=function(s){return n.length},r.write=function(s){for(let a=0;a<n.length;a+=1)s.put(n[a],8)},r},L6=function(e){const t=Sr.MODE_KANJI,n=Pa.stringToBytes;(function(a,l){const c=n(a);if(c.length!=2||(c[0]<<8|c[1])!=l)throw"sjis not supported."})("友",38726);const r=n(e),s={};return s.getMode=function(){return t},s.getLength=function(a){return~~(r.length/2)},s.write=function(a){const l=r;let c=0;for(;c+1<l.length;){let u=(255&l[c])<<8|255&l[c+1];if(33088<=u&&u<=40956)u-=33088;else if(57408<=u&&u<=60351)u-=49472;else throw"illegal char at "+(c+1)+"/"+u;u=(u>>>8&255)*192+(u&255),a.put(u,13),c+=2}if(c<l.length)throw"illegal char at "+(c+1)},s},DE=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,s){r=r||0,s=s||n.length;for(let a=0;a<s;a+=1)t.writeByte(n[a+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},P6=function(){let e=0,t=0,n=0,r="";const s={},a=function(c){r+=String.fromCharCode(l(c&63))},l=function(c){if(c<0)throw"n:"+c;if(c<26)return 65+c;if(c<52)return 97+(c-26);if(c<62)return 48+(c-52);if(c==62)return 43;if(c==63)return 47;throw"n:"+c};return s.writeByte=function(c){for(e=e<<8|c&255,t+=8,n+=1;t>=6;)a(e>>>t-6),t-=6},s.flush=function(){if(t>0&&(a(e<<6-t),e=0,t=0),n%3!=0){const c=3-n%3;for(let u=0;u<c;u+=1)r+="="}},s.toString=function(){return r},s},D6=function(e){const t=e;let n=0,r=0,s=0;const a={};a.read=function(){for(;s<8;){if(n>=t.length){if(s==0)return-1;throw"unexpected end of file./"+s}const u=t.charAt(n);if(n+=1,u=="=")return s=0,-1;if(u.match(/^\s$/))continue;r=r<<6|l(u.charCodeAt(0)),s+=6}const c=r>>>s-8&255;return s-=8,c};const l=function(c){if(65<=c&&c<=90)return c-65;if(97<=c&&c<=122)return c-97+26;if(48<=c&&c<=57)return c-48+52;if(c==43)return 62;if(c==47)return 63;throw"c:"+c};return a},z6=function(e,t){const n=e,r=t,s=new Array(e*t),a={};a.setPixel=function(h,p,g){s[p*n+h]=g},a.write=function(h){h.writeString("GIF87a"),h.writeShort(n),h.writeShort(r),h.writeByte(128),h.writeByte(0),h.writeByte(0),h.writeByte(0),h.writeByte(0),h.writeByte(0),h.writeByte(255),h.writeByte(255),h.writeByte(255),h.writeString(","),h.writeShort(0),h.writeShort(0),h.writeShort(n),h.writeShort(r),h.writeByte(0);const p=2,g=c(p);h.writeByte(p);let k=0;for(;g.length-k>255;)h.writeByte(255),h.writeBytes(g,k,255),k+=255;h.writeByte(g.length-k),h.writeBytes(g,k,g.length-k),h.writeByte(0),h.writeString(";")};const l=function(h){const p=h;let g=0,k=0;const y={};return y.write=function(v,_){if(v>>>_)throw"length over";for(;g+_>=8;)p.writeByte(255&(v<<g|k)),_-=8-g,v>>>=8-g,k=0,g=0;k=v<<g|k,g=g+_},y.flush=function(){g>0&&p.writeByte(k)},y},c=function(h){const p=1<<h,g=(1<<h)+1;let k=h+1;const y=u();for(let x=0;x<p;x+=1)y.add(String.fromCharCode(x));y.add(String.fromCharCode(p)),y.add(String.fromCharCode(g));const v=DE(),_=l(v);_.write(p,k);let E=0,C=String.fromCharCode(s[E]);for(E+=1;E<s.length;){const x=String.fromCharCode(s[E]);E+=1,y.contains(C+x)?C=C+x:(_.write(y.indexOf(C),k),y.size()<4095&&(y.size()==1<<k&&(k+=1),y.add(C+x)),C=x)}return _.write(y.indexOf(C),k),_.write(g,k),_.flush(),v.toByteArray()},u=function(){const h={};let p=0;const g={};return g.add=function(k){if(g.contains(k))throw"dup key:"+k;h[k]=p,p+=1},g.size=function(){return p},g.indexOf=function(k){return h[k]},g.contains=function(k){return typeof h[k]<"u"},g};return a},F6=function(e,t,n){const r=z6(e,t);for(let c=0;c<t;c+=1)for(let u=0;u<e;u+=1)r.setPixel(u,c,n(u,c));const s=DE();r.write(s);const a=P6(),l=s.toByteArray();for(let c=0;c<l.length;c+=1)a.writeByte(l[c]);return a.flush(),"data:image/gif;base64,"+a};Pa.stringToBytes;function B6(e){const t=Pa(0,"M");t.addData(e,"Byte"),t.make();const n=t.getModuleCount();return Array.from({length:n},(r,s)=>Array.from({length:n},(a,l)=>t.isDark(s,l)))}const Gp=4;function U6({text:e,spent:t}){const{size:n,d:r}=S.useMemo(()=>{const s=B6(e);let a="";return s.forEach((l,c)=>{l.forEach((u,h)=>{u&&(a+=`M${h+Gp} ${c+Gp}h1v1h-1z`)})}),{size:s.length+Gp*2,d:a}},[e]);return f.jsx("svg",{className:Ke("pair-qr",t&&"pair-qr-spent"),viewBox:`0 0 ${n} ${n}`,shapeRendering:"crispEdges",role:"img","aria-label":"Pairing code",children:f.jsx("path",{d:r})})}function H6(e){const[t,n]=S.useState(0);return S.useEffect(()=>{if(!e)return;const r=performance.now()+e.ms,s=()=>n(Math.max(0,Math.ceil((r-performance.now())/1e3)));s();const a=setInterval(s,250);return()=>clearInterval(a)},[e]),t}function W6(){const e=ht(),t=P(v=>{var _;return((_=v.remote)==null?void 0:_.host)??null}),n=P(v=>v.pairings),[r,s]=S.useState(null),[a,l]=S.useState(null),[c,u]=S.useState(0),h=S.useRef(n),p=H6(r);gt([c],()=>{let v=!0;return s(null),l(null),G2().then(_=>{v&&(h.current=n,typeof _=="string"?l(_):s(_))}),()=>{v=!1}});const g=r!==null&&n>h.current,k=r!==null&&p===0,y=()=>e({a:"close"});return f.jsx(Wd,{bare:!0,boxClass:"pair-stack",onClose:y,children:f.jsxs("div",{className:"pair-card",children:[f.jsx("div",{className:"pair-title",children:"Open on your phone"}),g?f.jsx("p",{className:"pair-line",children:"Paired. Your phone lists this machine on toyon.cloud now."}):a?f.jsx("p",{className:"pair-line",children:a}):f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"pair-frame",children:r&&f.jsx(U6,{text:r.url,spent:k})}),t&&f.jsx("div",{className:"hint pair-host",children:t}),f.jsx("p",{className:"pair-line",children:r?k?"This code has expired.":f.jsxs(f.Fragment,{children:["Scan with your phone's camera. The code works once; ",f.jsx("span",{className:"pair-left",children:p})," seconds left."]}):"Making a code."})]}),f.jsxs("div",{className:"pair-actions",children:[(k||a)&&!g&&f.jsx(Be,{variant:"outline",onClick:()=>u(v=>v+1),children:"new code"}),f.jsx(Be,{tone:"quiet",onClick:y,children:"done"})]})]})})}function yg({form:e}){var x;const t=ht(),n=ot(),r=P(N=>N.repos),s=P(N=>N.newProject?null:N.activeRepoId),a=P(N=>N.rows),l=P(N=>N.paths),c=P(N=>N.home),u=P(N=>N.pending),h=S.useCallback(N=>{Kd(N)&&(n==null||n.send({t:"browse-path",path:N}))},[n]),p=S.useCallback((N,M)=>A6({query:M,repos:r,pending:u,entries:[...l.entries].sort((J,W)=>Number(W.isRepo)-Number(J.isRepo)),target:l.target,answered:l.query}),[r,l,u]),g=N=>{const M=a.filter(D=>D.repoId===N.id),J=M.filter(ir).filter(D=>D.worktree.kind!=="spare"),W=J.filter(ec).length,R=J.length-1,j=M.length-M.filter(ir).length;return[R>0?`${R} worktree${R===1?"":"s"}`:null,W>0?`${W} working`:null,j>0?`${j} discovered`:null].filter(Boolean).join(" · ")||void 0},k=()=>t({a:"close"}),y=()=>t({a:"close",back:!0}),v=N=>{t({a:"open-repo"}),n==null||n.send({t:"register-repo",path:N})},_=(N,M)=>{t({a:"open-repo"}),n==null||n.send({t:"create-repo",mode:"create",parent:N,name:M})},E=(N,M,J)=>t({a:"new-project",v:bm({mode:N,name:M,parent:C6(r,s,c),...J?{url:J}:{}})}),C=()=>t({a:"open",overlay:{kind:"projects",form:"disk"}});return f.jsx(Kr,{anchored:e==="pill",initialQuery:e==="disk"?"~/":"",lead:e==="disk"?void 0:f.jsx("span",{className:"picker-chip",children:((x=r.find(N=>N.id===s))==null?void 0:x.name)??"no project"}),trailing:e==="disk"?void 0:f.jsx($t,{icon:"folder",label:"Find a project on disk",onClick:C}),items:[],filter:p,initialIndex:N=>N.findIndex(M=>M.kind==="repo"&&M.repo.id===s),keyOf:N=>N.kind==="repo"?N.repo.id:N.kind==="dir"?`d:${N.entry.path}`:N.kind==="open"?`open:${N.path}`:N.kind==="pending"?`p:${N.pending.id}`:N.kind==="clone"?`clone:${N.url}`:N.kind==="new"?"new-project":N.kind==="disk"?"open-folder":`new:${N.parent??""}/${N.name}`,rowClass:N=>Ke("picker-row",(N.kind==="new"||N.kind==="disk")&&"new-project-row"),onQuery:h,completionOf:N=>N.kind==="dir"?N.entry.isRepo?N.entry.path:`${N.entry.path}/`:null,narrowTo:N=>N.kind==="dir"&&!N.entry.isRepo?`${N.entry.path}/`:null,onPick:N=>{if(N.kind==="clone")return E("clone",N.name,N.url);if(N.kind==="create"&&!N.parent)return E("create",N.name);if(N.kind==="new")return E("create","");if(N.kind==="disk")return C();N.kind==="pending"?t({a:"watch-import",id:N.pending.id}):N.kind==="repo"?t({a:"activate-repo",id:N.repo.id}):N.kind==="open"?v(N.path):N.kind==="dir"?v(N.entry.path):N.parent&&_(N.parent,N.name),k()},onBack:y,rowMenu:N=>N.kind==="repo"?Hd(N.repo,s,{sock:n,dispatch:t}):N.kind==="pending"?zz(N.pending,{sock:n,dispatch:t}):[],placeholder:r.length>1?"switch project, or type a name or path":"type a name or a path to start",keys:N=>({complete:"completes the path",pick:(N==null?void 0:N.kind)==="dir"&&!N.entry.isRepo?"descends":(N==null?void 0:N.kind)==="pending"?"watches it":(N==null?void 0:N.kind)==="create"?N.parent?"creates it":"names it":(N==null?void 0:N.kind)==="clone"?"clones it":(N==null?void 0:N.kind)==="new"?"starts one":(N==null?void 0:N.kind)==="disk"?"browses":"opens",back:"closes"}),empty:"nothing here; keep typing a path (~/… or /…)",row:N=>N.kind==="repo"?f.jsx(rr,{label:N.repo.name,current:N.repo.id===s,hint:g(N.repo)}):N.kind==="pending"?f.jsx(rr,{label:N.pending.name,hint:N.pending.error?"import failed":"importing…"}):N.kind==="dir"?f.jsx(rr,{label:N.entry.name,hint:N.entry.isRepo?"git repo":void 0}):N.kind==="open"?f.jsx(rr,{label:`open ${N.path}`,hint:"register with this daemon"}):N.kind==="clone"?f.jsx(rr,{label:`clone ${N.name}`,hint:K6(N.url)}):N.kind==="new"?f.jsx(rr,{label:f.jsxs(f.Fragment,{children:[f.jsx(Et,{name:"plus",className:"icon-inline"}),"new project"]})}):N.kind==="disk"?f.jsx(rr,{label:f.jsxs(f.Fragment,{children:[f.jsx(Et,{name:"folder",className:"icon-inline"}),"open folder"]})}):f.jsx(rr,{label:`create ${N.name}`,hint:N.parent?`in ${N.parent}`:"new project"})})}function K6(e){const t=e.match(/^[a-z+]+:\/\/(?:[^@/]*@)?([^/:]+)/i)??e.match(/^[^@]+@([^:]+):/);return(t==null?void 0:t[1])??"git remote"}function Z6(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:()=>Bt(r)})}const n=[{id:"copy-ref",label:e.kind==="pr"?"copy PR number":"copy branch name",onClick:()=>Bt(e.ref)}];return Mn([t,n])}const q6=[],G6={branch:"branch",remote:"globe",pr:"pr"},R0={pr:0,branch:1,remote:2},V6={pr:"pull requests",branch:"branches",remote:"remote branches"};function Y6({repoId:e}){const t=ht(),n=ot(),r=P(g=>g.clientId),s=P(g=>g.refs[e]),a=P(g=>g.rows),l=g=>{var k;return((k=a.find(y=>y.id===g))==null?void 0:k.name)??"a worktree"},c=S.useCallback(g=>[...g].sort((k,y)=>R0[k.kind]-R0[y.kind]),[]),u=S.useCallback(g=>n==null?void 0:n.send({t:"search-refs",repoId:e,query:g.trim()}),[n,e]),h=g=>!s||s.query!==g.trim(),p=g=>g.openIn?`open in ${l(g.openIn)}`:g.merged?"merged":g.pr?`${g.pr.author}${g.pr.draft?" · draft":""}${g.pr.fork?" · fork":""}`:g.subject??"";return f.jsx(Kr,{items:(s==null?void 0:s.refs)??q6,filter:c,onQuery:u,keyOf:g=>`${g.kind}:${g.ref}`,rowClass:()=>"picker-row ref-row",onPick:g=>{g.openIn?t({a:"activate",id:g.openIn}):n==null||n.send({t:"open-ref",repoId:e,kind:g.kind,ref:g.ref,clientId:r,...g.pr?{pr:{title:g.pr.title,url:g.pr.url}}:{}}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:Z6,groupOf:g=>g.kind,groupHead:(g,k)=>`${V6[g]} · ${k}`,placeholder:"open a branch or PR…",keys:g=>({nav:"moves",pick:g!=null&&g.openIn?"switches to it":"opens it as a worktree",back:"closes"}),empty:g=>h(g)?"looking…":g.trim()?"no branch or PR matches":"no unmerged branches or open PRs",row:g=>f.jsx(rr,{label:f.jsxs(f.Fragment,{children:[f.jsx(Et,{name:G6[g.kind],className:"icon-inline"}),f.jsx("span",{className:"ref-name",children:g.name})]}),hint:p(g)})})}const O0=[],Vp=2;function Q6({worktreeId:e}){const t=ht(),n=ot(),r=Px(e).search,s=P(h=>h.layout.changes),a=P(h=>{var g;const p=(g=fn(h,e))==null?void 0:g.worktree;return p?p.path:null}),l=S.useCallback((h,p)=>p.trim().length>=Vp?h:O0,[]),c=S.useCallback(h=>{const p=h.trim();p.length>=Vp&&(n==null||n.send({t:"search",worktreeId:e,query:p}))},[n,e]),u=h=>!r||r.query.trim()!==h.trim();return f.jsx(Kr,{items:(r==null?void 0:r.hits)??O0,filter:l,onQuery:c,keyOf:h=>`${h.path}:${h.line}`,rowClass:()=>"search-hit",rowTitle:h=>`${h.path}:${h.line}`,onPick:h=>{Vn({dispatch:t},{worktreeId:e,path:h.path,view:"file",line:{n:h.line}}),s||t({a:"toggle-changes"}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:h=>a?is({id:e,dir:a},h.path,{},{sock:n,dispatch:t}):[],placeholder:"search in files…",keys:{pick:"opens the file",back:"closes"},empty:h=>h.trim().length<Vp?"type at least two characters":u(h)?"searching…":"no matches",footer:(h,p)=>r!=null&&r.truncated&&!u(h)&&p.length>0?f.jsxs("div",{className:"empty",children:["showing the first ",p.length,"; narrow the search"]}):null,row:h=>f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"search-loc",children:[h.path,":",h.line]}),f.jsx("span",{className:"search-text",children:h.text})]})})}const $0=e=>e.source==="file"?"~/.toyon/themes":e.source==="vscode"?"VS Code":"";function X6({slot:e}){const t=ht(),n=ot(),r=P(x=>x.themePrefs),s=P(x=>x.themes),a=Em(),l=mm(r,a),c=r[e==="theme"?l:e],u=()=>t({a:"close"}),h=()=>t({a:"close",back:!0}),p=x=>t({a:"preview-theme",theme:x}),[g,k]=S.useState(null),[y,v]=S.useState(null),_=(x,N)=>x[N??l]??x.dark??x.light??null,E=S.useMemo(()=>KO(s),[s]),C=S.useMemo(()=>s.filter(x=>x.kind===e),[s,e]);return gt([g,y],()=>{e==="theme"&&p(g?_(g,y):null)}),e!=="theme"?f.jsx(Kr,{items:C,filter:(x,N)=>x.filter(M=>Na(N,M.name,M.id)),rowClass:()=>"picker-row",keyOf:x=>x.id,initialIndex:x=>x.findIndex(N=>N.id===c),onActive:p,onPick:x=>{n==null||n.send({t:"set-theme",prefs:{...r,[e]:x.id}}),u()},onBack:h,placeholder:`${e} slot override`,keys:{nav:"preview",pick:"keeps",back:"reverts"},empty:"no matching theme",row:x=>f.jsx(rr,{label:x.name,current:x.id===c,hint:$0(x)})}):f.jsx(Kr,{items:E,filter:(x,N)=>x.filter(M=>{var J,W;return Na(N,M.name,(J=M.dark)==null?void 0:J.name,(W=M.light)==null?void 0:W.name)}),rowClass:()=>"picker-row",keyOf:x=>{var N,M;return x.name+(((N=x.dark)==null?void 0:N.id)??((M=x.light)==null?void 0:M.id))},initialIndex:x=>x.findIndex(N=>{var M,J;return((M=N.dark)==null?void 0:M.id)===c||((J=N.light)==null?void 0:J.id)===c}),onActive:k,onSide:x=>{var N;x.dark&&x.light&&v((((N=_(x,y))==null?void 0:N.kind)??l)==="dark"?"light":"dark")},onPick:x=>{n==null||n.send({t:"set-theme",prefs:ZO(r,x)}),u()},onBack:h,placeholder:"theme",keys:{nav:"preview",side:"dark/light",pick:"keeps",back:"reverts"},empty:"no matching theme",row:(x,N)=>{var R,j;const M=_(x,N?y:null),J=$0(x.dark??x.light),W=((R=x.dark)==null?void 0:R.id)===c||((j=x.light)==null?void 0:j.id)===c;return f.jsx(rr,{label:x.name,current:W,hint:f.jsxs("span",{className:"theme-kinds",children:[J&&f.jsx("span",{children:J}),f.jsx("span",{className:"kind","data-state":Yn({current:N&&(M==null?void 0:M.kind)==="dark"}),children:x.dark?"dark":""}),f.jsx("span",{className:"kind","data-state":Yn({current:N&&(M==null?void 0:M.kind)==="light"}),children:x.light?"light":""})]})})}})}function zE(){const e=E2(),t=P(a=>a.frame==="phone"),n=Oa(),r=P(a=>a.activeRepoId),s=P(a=>a.newProject);return f.jsxs(f.Fragment,{children:[(e==null?void 0:e.kind)==="quick-open"&&n&&f.jsx(m5,{worktreeId:n}),(e==null?void 0:e.kind)==="search"&&n&&f.jsx(Q6,{worktreeId:n}),(e==null?void 0:e.kind)==="element-sources"&&f.jsx(j6,{worktreeId:e.worktreeId,hits:e.hits}),(e==null?void 0:e.kind)==="refs"&&r&&f.jsx(Y6,{repoId:r}),(e==null?void 0:e.kind)==="chats"&&r&&f.jsx(T6,{repoId:r,scope:e.names?"names":"all"}),(e==null?void 0:e.kind)==="keys"&&f.jsx(f6,{}),(e==null?void 0:e.kind)==="pair"&&f.jsx(W6,{}),(e==null?void 0:e.kind)==="theme"&&f.jsx(X6,{slot:e.slot}),(e==null?void 0:e.kind)==="appearance"&&f.jsx(b6,{}),(e==null?void 0:e.kind)==="agent"&&f.jsx(y6,{}),(e==null?void 0:e.kind)==="agent-page"&&f.jsx(g6,{agentId:e.agent}),(e==null?void 0:e.kind)==="commands"&&!t&&f.jsx(xE,{}),(e==null?void 0:e.kind)==="projects"&&e.form!=="pill"&&f.jsx(yg,{form:e.form},e.form),(e==null?void 0:e.kind)==="choose-folder"&&s&&f.jsx(R6,{project:s})]})}const zu="Lost the daemon; retrying",J6="Not run by Toyon",eF="new worktree",tF=new Set(["waiting","working","starting","failed","crashed"]);function FE(e,t){if(t.offline)return zu;if(!ir(e))return e.locked?`Held by ${e.lockReason??"another tool"}`:t.path;if(t.op)return cx(t.op);if(hr(e.worktree))return eF;const n=km(e,t.needsSetup),r=e.worktree.lastTurn;return!tF.has(Ni(e))&&r?Dm(r):t.at?`${n} · ${t.at}`:n}function nF(e){const t=e.worktree.lastTurn,n=t?(ec(e)?hL:Dm)(t):void 0,r=e.worktree.pr&&!e.worktree.landed?os(e.worktree.pr):void 0;return[n,r].filter(s=>!!s)}function rF(e,t,n,r){var h,p;let s;const a=(g,k)=>{k&&(!s||k>s.at)&&(s={title:g,at:k})};for(const g of e){const k=(h=g.worktree)==null?void 0:h.lands;g.worktree&&(k!=null&&k.length)&&a(g.worktree.title,(p=k[k.length-1])==null?void 0:p.at)}for(const g of t)a(g.title,g.landedAt);const l=s?`Landed ${s.title} ${Bo(Ur(s.at))}.`:void 0,c=n?b1(r,n):null,u=c?Zo(`${c.charAt(0).toUpperCase()}${c.slice(1)}`):n!=null&&n.fetchedAt?`Level with origin, fetched ${Bo(Ur(n.fetchedAt))}.`:void 0;return[l,u].filter(g=>!!g)}const M0=160;function oF(e){var r;const t=(r=e.prompt)==null?void 0:r.replace(/\s+/g," ").trim();if(!t)return[];if(t.length<=M0)return[t];const n=t.slice(0,M0);return[`${n.slice(0,Math.max(n.lastIndexOf(" "),1)).trimEnd()}…`]}function sF(e){const n=[e.auto&&`auto archived: ${e.landed?LN(e.auto):e.auto}`,e.cost!==void 0?ic(e.cost):void 0].filter(r=>!!r);return n.length?n:void 0}const L0=25;function iF(e,t){if(e.length<=L0+1)return{shown:e,rest:0};const n=e.slice(0,L0),r=t?e.find(s=>s.id===t):void 0;return r&&!n.includes(r)&&n.push(r),{shown:n,rest:e.length-n.length}}const aF=.5;function lF(e){const t=e.usage,n=t&&t.size>0?t.used/t.size:0,r=[n>=aF?`${Math.round(100*n)}% of context`:void 0,e.queued?`${e.queued} queued`:void 0,(t==null?void 0:t.cost)!==void 0?ic(t.cost):void 0].filter(s=>!!s);return r.length?r:void 0}const ju=e=>e>999?"1k+":String(e);function BE({width:e,placement:t="strip"}){const n=t==="screen",r=Gs(),s=P(X=>X.chatSide)==="left"?"right":"left",a=ht(),l=ot(),c=Nm(),u=c[0]&&hr(c[0].worktree)?c[0]:null,h=u?c.slice(1):c,p=P(X=>ba(X,X.activeRepoId)),g=X=>u&&X.id===u.id&&p?{behind:p.behind,dirty:p.dirty}:X,[,k]=S.useState(0);S.useEffect(()=>{const X=setInterval(()=>k(we=>we+1),6e4);return()=>clearInterval(X)},[]);const y=y2(),v=w2(),_=v2(),E=b2(),C=(X,we,Qe)=>{X.key!=="ArrowLeft"&&X.key!=="ArrowRight"||X.shiftKey||X.altKey||X.metaKey||X.ctrlKey||(X.preventDefault(),zd([{depth:0,open:we}],0,X.key)&&a({a:Qe}))},x=Ai(),N=P(X=>X.clientId),M=P(X=>X.activeRepoId),J=P(X=>X.connected);S.useEffect(()=>{l&&J&&M&&l.send({t:"list-archived",repoId:M})},[l,J,M]);const W=Oa(),R=Mx(),j=P(X=>X.layout),A=P(X=>X.railOpen),D=P(X=>X.railPeek),H=S.useRef(null),[Y,ae]=S.useState(!1);gt([D],()=>{var X;D&&!n&&!r&&!((X=H.current)!=null&&X.matches(":hover"))&&ae(!0)}),S.useEffect(()=>{if(!Y)return;let X=null;const we=Qe=>{if(!X){X={x:Qe.clientX,y:Qe.clientY};return}Math.abs(Qe.clientX-X.x)+Math.abs(Qe.clientY-X.y)<3||ae(!1)};return window.addEventListener("pointermove",we),()=>window.removeEventListener("pointermove",we)},[Y]);const me=P(X=>X.focusRail),ye=S.useRef(me),_e=S.useRef(null);gt([me],()=>{if(me===ye.current)return;ye.current=me;const X=requestAnimationFrame(()=>{var we,Qe;return(Qe=(we=_e.current)==null?void 0:we.querySelector('[data-state~="current"]'))==null?void 0:Qe.focus()});return()=>cancelAnimationFrame(X)});const V=P(X=>X.repos),O=P(X=>X.shipping),F=X=>V.find(we=>we.id===X.repoId)??null,ne=Jt("rail"),$=Ux(),q=P(X=>X.home),ke=X=>{const we=X.worktree?X.worktree.path:X.path;return q&&we.startsWith(`${q}/`)?`~${we.slice(q.length)}`:we},[se,ve]=S.useState(!1),[Re,le]=S.useState([]),xe=X=>{Ru(X.worktree)&&(ve(!0),le(we=>we.includes(X.worktree.id)?we.filter(Qe=>Qe!==X.worktree.id):[...we,X.worktree.id]))},Le=()=>{ve(!1),le([])};gt([se],()=>{const X=we=>we.key==="Escape"&&Le();return se&&window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)});const oe=Lm(l,a),Z={sock:l,dispatch:a},De=X=>{ve(!0),le(we=>X===W||we.includes(X)?we:[...we,X])},Ve=X=>ir(X)?y1(X,F(X),{layout:j,shipping:O},Z,{graft:De,hostname:location.hostname}):oL(X,{clientId:N},Z,location.hostname),ze=iF(_,(x==null?void 0:x.id)??null),it=ze.shown.some(X=>(X.dirty??0)>0),Je=X=>f.jsxs("button",{type:"button",className:Ke("row row-edge row-quiet rail-disc-item rail-arch-item",($==null?void 0:$.owner)==="rail"&&$.key===X.id&&"menu-open"),"data-state":Yn({current:(x==null?void 0:x.id)===X.id}),...It(LL(X),void 0,{placement:s,card:!0,detail:oF(X),aside:sF(X)}),onClick:()=>a({a:"open-archived",id:X.id}),...ne.contextMenu(()=>Pu(X,N,Z),X.id),children:[f.jsxs("span",{className:"rail-gut",onClick:r?we=>{we.stopPropagation(),ne.openUnder(we.currentTarget,()=>Pu(X,N,Z),X.id)}:void 0,children:[f.jsx("span",{className:"rail-at row-dim",children:Ur(X.archivedAt)}),f.jsx("span",{className:"rail-more",...It("Actions"),onClick:we=>{we.stopPropagation(),ne.openUnder(we.currentTarget,()=>Pu(X,N,Z),X.id)},children:f.jsx(Et,{name:"more"})})]}),f.jsx("span",{className:"branch",children:X.title}),it&&f.jsx("span",{className:"rail-counts",children:f.jsx("span",{className:"rail-count row-dim","data-tip":X.dirty?`${X.dirty} uncommitted, kept`:void 0,children:X.dirty?`~${ju(X.dirty)}`:""})}),X.auto?f.jsx("span",{className:"rail-glyph rail-auto row-dim",children:f.jsx(Et,{name:"clock",className:"icon-inline"})}):f.jsx("span",{className:"dot"}),n&&f.jsx("span",{className:"rail-at rail-at-end row-dim",children:Ur(X.archivedAt)})]},X.id),en=[...c,...y].map(g),kt=["ahead","dirty","behind"].filter(X=>en.some(we=>(we[X]??0)>0)),tn=X=>{const we=kt.findIndex(Qe=>(X[Qe]??0)>0);return new Set(we<0?[]:kt.slice(we))},st=X=>{var Ut;const we=ir(X)?X:null,Qe=!!we&&hr(we.worktree),he=g(X),Oe=V.find(We=>We.id===X.repoId)??null,Mt=Oe?yd(Oe):"main",an=Oe&&gT(Oe)&&(p!=null&&p.fetchedAt)?` as of ${v1(p.fetchedAt)}`:"",vt=tn(he),Dn=!!he.ahead&&!he.dirty,Lt=X.id,ln=($==null?void 0:$.owner)==="rail"&&$.key===Lt,Tt=we&&se&&Ru(we.worktree)&&Lt!==W,nn=b$(X,(Ut=O[Lt])==null?void 0:Ut.op);return f.jsxs("button",{type:"button",className:Ke("row row-edge",we?"rail-item":"row-quiet rail-disc-item",ln&&"menu-open"),"data-state":Yn({current:Lt===W&&!x,checked:Re.includes(Lt)}),...we?It(R?zu:nn?cx(nn):km(X,ed(F(we))),void 0,{placement:s,card:!0,aside:lF(X),detail:hr(we.worktree)?rF(c,_,p,Mt):nF(we),dot:R?void 0:nn?"spinner":Ni(X)}):It(R?zu:X.locked?`Held by ${X.lockReason??"another tool"}`:J6,void 0,{placement:s,card:!0,detail:ke(X),dot:R||X.locked?void 0:"discovered"}),"data-wt":Lt,onKeyDown:We=>{var xn,hn;if(!we||se||We.key!=="ArrowUp"&&We.key!=="ArrowDown"||We.altKey||We.ctrlKey||We.metaKey)return;We.preventDefault();const Gt=We.key==="ArrowDown",pn=c.findIndex(mn=>mn.id===Lt),Kt=c[pn+(Gt?1:-1)];Kt&&(a({a:"activate",id:Kt.id}),(hn=(xn=We.currentTarget.parentElement)==null?void 0:xn.querySelector(`[data-wt="${Kt.id}"]`))==null||hn.focus())},onClick:We=>{we&&(se||We.shiftKey)?Lt===W?ve(!0):xe(we):Qe&&!n?a({a:"open-draft"}):(a({a:"activate",id:Lt}),we&&!r&&a({a:"walked"}))},...ne.contextMenu(()=>Ve(X),Lt),children:[f.jsx("span",{className:"rail-gut",onClick:r&&!se?We=>{We.stopPropagation(),ne.openUnder(We.currentTarget,()=>Ve(X),Lt)}:void 0,children:Tt?f.jsx("input",{type:"checkbox",className:"rail-graft-check",checked:Re.includes(Lt),readOnly:!0,tabIndex:-1}):!se&&f.jsxs(f.Fragment,{children:[we&&!Qe&&f.jsx("span",{className:"rail-at row-dim",children:Ur(Ll(we.worktree))}),f.jsx("span",{className:"rail-more",...It("Actions"),onClick:We=>{We.stopPropagation(),ne.openUnder(We.currentTarget,()=>Ve(X),Lt)},children:f.jsx(Et,{name:"more"})})]})}),Qe?f.jsxs("span",{className:"branch rail-main-label",children:[f.jsx(Et,{name:"plus",className:"icon-inline"}),"new worktree"]}):f.jsx("span",{className:Ke("branch",(we==null?void 0:we.worktree.unnamed)&&"row-dim"),children:hh(X,we?F(we):null)}),(we==null?void 0:we.worktree.mode)&&we.worktree.mode!=="auto"&&f.jsx("span",{className:"rail-badge badge-mode","data-tip":`${we.worktree.mode} mode: the agent waits for you`,children:we.worktree.mode}),we&&(()=>{const We=F(we),Gt=m1(we.worktree,We);return Gt&&Gt!==(We==null?void 0:We.config.defaultProfile)?f.jsx("span",{className:"rail-badge badge-profile","data-tip":`runs the ${Gt} profile`,children:Gt}):null})(),(we==null?void 0:we.worktree.variant)&&f.jsxs("span",{className:"rail-badge badge-variant clickable","data-tip":"Keep this variant, archive the others",onClick:We=>{We.stopPropagation(),oe.pickVariant(we)},children:[f.jsxs("span",{className:"num",children:["v",we.worktree.variant.index,"/",we.worktree.variant.of]}),f.jsx("span",{className:"act",children:"pick"})]}),f.jsxs("span",{className:"rail-counts",children:[vt.has("ahead")&&f.jsx("span",{className:"rail-count badge-ahead","data-tip":he.ahead?`${he.ahead} ahead of ${Mt}`:void 0,children:he.ahead?`+${ju(he.ahead)}`:""}),vt.has("dirty")&&!Dn&&f.jsx("span",{className:"rail-count badge-dirty","data-tip":he.dirty?`${he.dirty} uncommitted${Qe?" on main":""}`:void 0,children:he.dirty?`~${ju(he.dirty)}`:""}),vt.has("behind")&&f.jsx("span",{className:"rail-count rail-behind row-dim","data-tip":he.behind?`${he.behind} behind ${Qe?"origin":Mt}${Qe?"":an}`:void 0,children:he.behind?ju(he.behind):""})]}),(()=>{if(nn)return f.jsx(sc,{size:"dot"});if(X.locked)return f.jsx("span",{className:"rail-glyph rail-lock row-dim",children:f.jsx(Et,{name:"lock",className:"icon-inline"})});if(!we)return f.jsx("span",{className:"dot discovered"});const We=se||R?null:ux(X.procs),Gt=X.unseen?" unseen":"",pn=Ni(X);return Qe&&!We&&pn!=="crashed"&&!R?f.jsxs(f.Fragment,{children:[f.jsx("span",{className:`dot ${pn} rail-main-dot`}),f.jsx("span",{className:"rail-glyph rail-main-strip",children:f.jsx(Et,{name:"plus"})})]}):!We||pn!=="crashed"?f.jsx("span",{className:`dot ${pn}${Gt}`}):f.jsx("span",{className:`dot crashed clickable${Gt}`,...It(We.tip),onClick:Kt=>{Kt.stopPropagation(),a({a:"activate",id:Lt}),a({a:"term-stream",id:Lt,stream:We.stream})}})})(),n&&f.jsx("span",{className:"rail-say row-dim",children:FE(X,{offline:R,needsSetup:ed(we?F(we):null),path:ke(X),at:we&&!Qe?Ur(Ll(we.worktree)):void 0,op:nn})})]},Lt)};return f.jsx("div",{ref:H,className:Ke("rail",n&&"rail-screen",!n&&(se||($==null?void 0:$.owner)==="rail"||D)&&"hold",Y&&"quiet",(n||A)&&"pinned",R&&"offline"),style:e!==void 0&&!n?{"--rail-width":`${e}px`}:void 0,onClick:r&&!n&&!A?X=>{X.target instanceof Element&&X.target.closest("button, .rail-gut")||a({a:"toggle-rail"})}:void 0,children:f.jsxs("div",{className:"rail-panel","data-tip":R?zu:void 0,"data-tip-placement":"follow",children:[f.jsxs("div",{className:"rail-list",ref:_e,children:[u&&!n&&st(u),h.map(st),se&&f.jsxs("div",{className:"rail-graft",children:[(()=>{const X=c.find(he=>he.worktree.id===W&&Ru(he.worktree)),we=Re.filter(he=>he!==(X==null?void 0:X.worktree.id)),Qe=we.map(he=>{var Oe;return((Oe=c.find(Mt=>Mt.worktree.id===he))==null?void 0:Oe.worktree.title)??he}).join(", ");return f.jsxs(Be,{size:"md",tone:"primary",disabled:!X||we.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 ${Qe} onto ${X.worktree.title}?
|
|
244
|
+
|
|
245
|
+
Their branches are merged in, then their directories and branches are removed.`)&&(l==null||l.send({t:"graft",targetId:X.worktree.id,sourceIds:we}),Le())},children:["graft ",we.length]})})(),f.jsxs(Be,{size:"md",disabled:!Re.some(X=>{var we;return(((we=c.find(Qe=>Qe.worktree.id===X))==null?void 0:we.behind)??0)>0}),"data-tip":"Pull main into every selected worktree that's behind",onClick:()=>{for(const X of Re){const we=c.find(Qe=>Qe.worktree.id===X);((we==null?void 0:we.behind)??0)>0&&Hs(l,a,{t:"sync-main",worktreeId:X})}Le()},children:[f.jsx(Et,{name:"pull",className:"icon-inline"})," sync"]}),f.jsx(Be,{size:"md",tone:"danger",disabled:Re.length===0,"data-tip":"Archive all selected worktrees; their chats and work are kept",onClick:()=>{window.confirm(`Archive ${Re.length} worktree(s)?
|
|
246
|
+
|
|
247
|
+
Their directories and branches go. The chats, commits and any uncommitted changes are kept, and each can be restored.`)&&(_i(l,a,Re),Le())},children:"archive…"}),f.jsx($t,{icon:"close",label:"Cancel",hint:"esc",onClick:Le})]}),!se&&y.length>0&&f.jsxs(f.Fragment,{children:[f.jsxs("button",{className:"section-title section-row section-fold rail-disc-head","aria-expanded":v,...It(`${y.length} worktree${y.length===1?"":"s"} here that Toyon did not make`,void 0,{placement:s}),onClick:()=>a({a:"toggle-discovered"}),onKeyDown:X=>C(X,v,"toggle-discovered"),children:[f.jsx("span",{className:"rail-gut",children:f.jsx(Et,{name:"caret",className:Ke("icon-inline disc-caret",!v&&"shut")})}),f.jsx("span",{className:"rail-label",children:"discovered"})]}),v&&y.map(st)]}),!se&&_.length>0&&f.jsxs(f.Fragment,{children:[f.jsxs("button",{type:"button",className:"section-title section-row section-fold rail-disc-head","aria-expanded":E,...It(`${_.length} archived worktree${_.length===1?"":"s"}, kept with ${_.length===1?"its chat":"their chats"}`,void 0,{placement:s}),onClick:()=>a({a:"toggle-archived"}),onKeyDown:X=>C(X,E,"toggle-archived"),children:[f.jsx("span",{className:"rail-gut",children:f.jsx(Et,{name:"caret",className:Ke("icon-inline disc-caret",!E&&"shut")})}),f.jsx("span",{className:"rail-label",children:"archived"})]}),E&&ze.shown.map(Je),E&&ze.rest>0&&M&&f.jsxs("button",{type:"button",className:"row row-quiet rail-disc-item rail-arch-item",...It("Find an older one by its name, branch or first message",void 0,{placement:s}),onClick:()=>a({a:"open",overlay:{kind:"chats",names:!0}}),children:[f.jsx("span",{className:"rail-gut"}),f.jsxs("span",{className:"branch row-dim",children:[ze.rest," more"]}),f.jsx("span",{className:"dot"})]})]})]}),!n&&f.jsx("div",{className:"rail-foot",children:f.jsx($t,{icon:"worktrees",label:"Worktree panel",hint:xt("rail"),tone:"chrome",on:A,onClick:()=>a({a:"toggle-rail"})})})]})})}function cF({screen:e,tabs:t}){const n=ht(),r=$a(),s=P(N=>N.repos),a=us(),l=Oa(),c=Ai(),u=Nm(),h=Mx(),p=a$(u,l),g=u.find(N=>hr(N.worktree)),k=e==="home",y=k?(r==null?void 0:r.name)??null:(c==null?void 0:c.title)??(a==null?void 0:a.worktree.title)??null,v=u.filter(N=>!hr(N.worktree)).length,_=k?v===0?"no worktrees yet":`${v} ${v===1?"worktree":"worktrees"}`:c?R1(c):a?FE(a,{offline:h,needsSetup:ed(r),path:a.worktree.path,at:hr(a.worktree)?void 0:Ur(Ll(a.worktree))}):null,E=!k&&!c&&!!a&&Ni(a)==="waiting",C=P(N=>{var M;return((M=N.overlay)==null?void 0:M.kind)==="projects"&&N.overlay.form==="pill"}),x=P(N=>{var M;return((M=N.overlay)==null?void 0:M.kind)==="commands"});return f.jsxs("div",{className:"phone-bar",children:[f.jsxs("div",{className:"phone-bar-row",children:[!k&&f.jsx($t,{icon:"back",label:"Worktrees",tone:"chrome",onClick:()=>n({a:"screen",to:"home"})}),f.jsxs("div",{className:"phone-title",children:[k&&s.length>1?f.jsxs("span",{className:"phone-drop phone-switch",children:[f.jsxs(Be,{size:"md",tone:"chrome",on:C,onClick:()=>n({a:"toggle",overlay:{kind:"projects",form:"pill"}}),children:[y,f.jsx(Et,{name:"caret",className:"icon-inline"})]}),C&&f.jsx(yg,{form:"pill"})]}):f.jsx("span",{className:"phone-name",children:y}),_&&f.jsx("span",{className:Ke("phone-sub",E&&"phone-sub-asks"),children:_})]}),p&&f.jsxs(Be,{size:"md",tone:"primary",onClick:()=>{const N=gm(u,l,1);N&&n({a:"activate",id:N.activate})},children:[p.n," ",p.tier]}),k&&g&&f.jsx($t,{icon:"plus",label:"New worktree",tone:"chrome",onClick:()=>n({a:"activate",id:g.id})}),f.jsxs("span",{className:"phone-drop",children:[f.jsx($t,{icon:"more",label:"Menu",tone:"chrome",on:x,onClick:()=>n({a:"toggle",overlay:{kind:"commands"}})}),x&&f.jsx(xE,{anchored:{flip:"align",margin:6},trailing:f.jsx($t,{icon:"close",label:"Close",tone:"chrome",onClick:()=>n({a:"close"})})})]})]}),t&&f.jsx("div",{className:"phone-tabs",children:t})]})}function uF({active:e,url:t,hidden:n}){return f.jsx("div",{className:"phone-preview",hidden:n,children:_m(e)?f.jsx("iframe",{className:"phone-preview-frame",src:t,title:e.worktree.title}):f.jsx(ds,{wide:!0,children:f.jsx("p",{className:"status-line",children:km(e)})})})}const dF=Vx();function fF(){const e=ht(),t=P(x=>x.screen),n=us(),r=Ai(),s=P(x=>x.editor),a=P(x=>x.remote),l=rc(),c=P(x=>x.connected),u=P(x=>x.heard),h=P(x=>x.connectFailure),p=P(x=>x.chatSide),g=Gs(),k=p1({connected:c,heard:u,connectFailure:h,hasToken:dF,projectChord:xt("project"),title:(n==null?void 0:n.worktree.title)??null}),y=t!=="home"&&(n!==null||r!==null),v=y&&!l&&!r?n:null,_=v?ph(v.worktree.id,v.worktree.proxyPort,a):null,E=t==="preview"&&!v?"chat":t,C=[{id:"chat",label:"chat"},...v&&_?[{id:"preview",label:"preview",trail:f.jsx($t,{icon:"external",label:"Open in browser",tone:"chrome",onClick:()=>window.open(_,"_blank")})}]:[],{id:"changes",label:"code"}];return f.jsxs("div",{className:"app phone","data-chat-side":p,"data-touch":g||void 0,"data-hover":!g||void 0,children:[f.jsx(l1,{}),f.jsx(f1,{}),f.jsx(cF,{screen:y?"chat":"home",tabs:y&&k===null&&f.jsx(Dd,{fill:!0,segmented:!0,owner:"phone-tabs",label:"worktree",items:C,current:E,onPick:x=>e({a:"screen",to:x})})}),f.jsx("div",{className:"phone-screen",children:f.jsxs("div",{className:"center-root",children:[k!==null?f.jsx(ds,{wide:!0,children:f.jsx("p",{className:"status-line",children:k})}):y?s?f.jsx(CE,{editor:s,placement:"screen"}):E==="chat"?f.jsx(fd,{placement:"screen",archived:r}):E==="changes"?f.jsx(I1,{placement:"screen"}):null:f.jsx(BE,{placement:"screen"}),v&&_&&f.jsx(uF,{active:v,url:_,hidden:E!=="preview"||s!==null},v.worktree.id),f.jsx(zE,{})]})})]})}function pF(){try{const e=localStorage.getItem(_t.theme);if(e){const t=JSON.parse(e);if(t!=null&&t.colors&&typeof t.colors.surface0=="string")return t}}catch{}return Jl}function UE(e,t={}){var r;const n=document.documentElement;for(const[s,a]of Object.entries(BO(e)))n.style.setProperty(s,a);if(n.style.colorScheme=e.kind,n.dataset.theme=e.kind,(r=document.querySelector('meta[name="theme-color"]'))==null||r.setAttribute("content",e.colors.surface1),t.remember!==!1)try{localStorage.setItem(_t.theme,JSON.stringify(e))}catch{}}function HE(e){const t=hm(e);return{type:"theme",accent:t,accentFg:VO(t)}}function hF(){var e;return((e=window.matchMedia)==null?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)??!0}const mF=12*36e5;function gF(){try{const e=localStorage.getItem(_t.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<mF?{dark:!t.dark,until:0}:null}catch{return null}}function kF(e){try{localStorage.setItem(_t.daylight,JSON.stringify(e))}catch{}}function yF(e){var r;const t=(r=window.matchMedia)==null?void 0:r.call(window,"(prefers-color-scheme: dark)");if(!t)return()=>{};const n=s=>e(s.matches);return t.addEventListener("change",n),()=>t.removeEventListener("change",n)}function qh(e,t){return[{id:"copy-name",label:"copy name",detail:e,onClick:()=>Bt(e)},{id:"copy-value",label:"copy value",detail:t,onClick:()=>Bt(t)}]}function Gh(e){return[{id:"copy-value",label:"copy value",detail:e,onClick:()=>Bt(e)}]}function wF(e,t,{sock:n},r){return t?Mn([[{id:"source",label:"open source",onClick:r}],ji(`${e.dir}/${t}`,()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id,path:t})),[{id:"copy-path",label:"copy path",onClick:()=>Bt(t)}]]):[]}function Ql(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(a=>a+a).join(""):n;if(r.length!==6&&r.length!==8)return null;const s=Number.parseInt(r.slice(0,6),16);return[s>>16&255,s>>8&255,s&255]}function vF(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());return t?t[1].length===4||t[1].length===8:!1}function P0([e,t,n]){const r=s=>{const a=s/255;return a<=.03928?a/12.92:((a+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function WE(e,t){if(vF(e))return null;const n=Ql(e);if(!n)return null;const r=Ql(t);if(!r)return null;const[s,a]=[P0(n),P0(r)];return`${((Math.max(s,a)+.05)/(Math.min(s,a)+.05)).toFixed(2)}:1`}function bF({worktreeId:e,height:t,full:n,onToggleFull:r,onDragStart:s}){const a=ht(),l=ot(),c=P(h=>go(h,e).design);S.useEffect(()=>{c||l==null||l.send({t:"design-scan",worktreeId:e})},[c,e,l]),S.useEffect(()=>()=>Wt.post(e,{type:"highlight-clear"}),[e]);const u={outline:h=>Wt.post(e,h),clear:()=>Wt.post(e,{type:"highlight-clear"}),open:h=>Vn({dispatch:a},{worktreeId:e,path:h})};return f.jsx(gg,{kind:"design",className:Ke("design-pane",n&&"full"),height:n?void 0:t,resizable:!n,onDragStart:s,title:c?f.jsx("span",{children:SF(c)}):void 0,onClose:()=>a({a:"toggle-design"}),closeHint:xt("design"),full:n,onToggleFull:r,actions:f.jsxs(Be,{variant:"outline",onClick:()=>l==null?void 0:l.send({t:"design-scan",worktreeId:e}),"data-tip":"Scan this worktree again",children:[f.jsx(Et,{name:"reload",className:"icon-inline"})," rescan"]}),children:c?f.jsxs("div",{className:"design-body",style:EF,onMouseLeave:u.clear,children:[c.tokens.length===0&&c.literals.length>0?f.jsx(IF,{literals:c.literals,outline:u.outline,clear:u.clear}):f.jsx(CF,{tokens:c.tokens,coverage:c.coverage,outline:u.outline,clear:u.clear}),f.jsx(FF,{index:c,outline:u.outline,clear:u.clear,onOpen:u.open}),f.jsx(BF,{index:c,outline:u.outline,clear:u.clear,onOpen:u.open})]}):f.jsx("div",{className:"empty",children:"reading the design system…"})})}const xF=720,_F=132,EF={"--design-column":`${xF}px`,"--design-cell":`${_F}px`};function SF(e){const t=Object.values(e.coverage.files).reduce((r,s)=>r+s,0),n=e.coverage.stylesheets;return`${t} file${t===1?"":"s"} read, ${n} stylesheet${n===1?"":"s"}`}const da=e=>`${e} use${e===1?"":"s"}`;function Zd({title:e,note:t,children:n}){return f.jsxs("section",{className:"design-section",children:[f.jsxs("h2",{className:"design-h",children:[e,t&&f.jsx("span",{className:"design-note",children:t})]}),n]})}function md({children:e}){return f.jsx("p",{className:"design-gap",children:e})}const NF=[{kind:"font",label:"type"},{kind:"color",label:"color"},{kind:"length",label:"size & radius"},{kind:"shadow",label:"shadow"},{kind:"other",label:"computed"}];function TF(e){return e.find(t=>t.kind==="color"&&Ql(t.resolved??t.value)!==null)}function jF(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 CF({tokens:e,coverage:t,outline:n,clear:r}){const s=TF(e),a=s&&(s.resolved??s.value),l=new Map;for(const u of e){const h=(u.resolved??u.value).trim().toLowerCase();l.set(h,[...l.get(h)??[],u.name])}const c=u=>(l.get((u.resolved??u.value).trim().toLowerCase())??[]).filter(h=>h!==u.name);return f.jsx(Zd,{title:"Tokens",children:e.length===0?f.jsx(md,{children:jF(t)}):NF.map(({kind:u,label:h})=>{const p=e.filter(k=>k.kind===u);if(p.length===0)return null;const g=ZE(p.map(k=>k.value));return f.jsxs("div",{className:"design-group",children:[u!=="font"&&f.jsx("span",{className:"design-group-name",children:h}),u==="font"?f.jsx(qE,{groups:LF(p),outline:n,clear:r}):f.jsx("div",{className:"design-breakout",style:KE(p.length),children:f.jsx("div",{className:"design-grid",children:p.map(k=>{const y=k.resolved??k.value,v=k.kind==="color"&&a?WE(y,a):null;return f.jsx(GE,{kind:k.kind,name:k.name,lines:k.resolved?[k.value,k.resolved]:[k.value],actual:y,ratio:v,largest:g,tipText:DF(k,v,s,c(k)),menu:()=>qh(k.name,y),outline:n,clear:r},k.name)})})})]},u)})})}const AF=[{role:"color",kind:"color",label:"color"},{role:"radius",kind:"length",label:"radius"},{role:"shadow",kind:"shadow",label:"shadow"}];function IF({literals:e,outline:t,clear:n}){const r=e.find(a=>a.ground&&Ql(a.value)!==null),s=PF(e);return f.jsxs(Zd,{title:"Values",note:"written out in the rules; no custom properties",children:[s.length>0&&f.jsx("div",{className:"design-group",children:f.jsx(qE,{groups:s,outline:t,clear:n})}),AF.map(({role:a,kind:l,label:c})=>{const u=e.filter(p=>p.role===a);if(u.length===0)return null;const h=ZE(u.map(p=>p.value));return f.jsxs("div",{className:"design-group",children:[f.jsx("span",{className:"design-group-name",children:c}),f.jsx("div",{className:"design-breakout",style:KE(u.length),children:f.jsx("div",{className:"design-grid",children:u.map(p=>{const g=l==="color"&&r?WE(p.value,r.value):null;return f.jsx(GE,{kind:l,name:p.value,lines:[da(p.uses)],actual:p.value,ratio:g,largest:h,tipText:zF(p,g,r),menu:()=>Gh(p.value),outline:t,clear:n},p.value)})})})]},a)})]})}function KE(e){const t="var(--design-cell)",n=`min(round(down, 100%, ${t}), calc(${e} * ${t}))`,r=`round(down, var(--design-column), ${t})`,s=`round(down, max(0px, calc((${n} - ${r}) / 2)), ${t})`;return{width:n,marginLeft:`max(0px, calc((100% - var(--design-column)) / 2 - ${s}))`}}function ZE(e){return e.reduce((t,n)=>Math.max(t,Math.abs(Number.parseFloat(n))||0),0)}const RF=["color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color","outline-color"];function OF(e,t){if(!e)return[];const n=getComputedStyle(e);return t.map(r=>[r,n.getPropertyValue(r)])}const Vh=e=>(e.split(",")[0]??e).replace(/["']/g,"").trim();function $F(e){const t=/^[1-9]00\s+([\d.]+)px(?:\s*\/\s*([\d.]+)(px)?)?\s+(.+)$/.exec(e.trim());if(!t)return{family:Vh(e),size:null,lead:null};const n=Number(t[1]),r=t[2]?Number(t[2]):null,s=r===null?null:Math.round((t[3]?r:n*r)*100)/100;return{family:Vh(t[4]??""),size:n,lead:s}}function Yp(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 MF(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 LF(e){const t=e.map(n=>({token:n,actual:n.resolved??n.value,...$F(n.resolved??n.value)}));return[...new Set(t.map(n=>n.family))].map(n=>{const r=t.filter(a=>a.family===n),s=r.find(a=>a.size===null);return{family:n,stack:s?s.actual:n,name:s==null?void 0:s.token.name,label:s?s.token.name:n,tipText:s?`${s.token.name}
|
|
248
|
+
${s.actual}`:void 0,menu:()=>s?qh(s.token.name,s.actual):[],rows:r.filter(a=>a.size!==null).sort((a,l)=>(l.size??0)-(a.size??0)).map(a=>({key:a.token.name,sample:`${a.family} ${a.size}${a.lead===null?"":`/${a.lead}`}`,style:{font:a.actual},name:a.token.name,label:a.token.name,tipText:`${a.token.name}
|
|
249
|
+
${a.actual}`,menu:()=>qh(a.token.name,a.actual)}))}})}function PF(e){const t=e.filter(s=>s.role==="family"),n=e.filter(s=>s.role==="size");return[...new Set([...t.map(s=>s.value),...n.map(s=>s.family??"initial")])].map(s=>{const a=t.find(c=>c.value===s),l=s==="initial"?"default face":Vh(s);return{family:l,stack:s,name:a?da(a.uses):void 0,label:l,tipText:a?`${a.value}
|
|
250
|
+
${da(a.uses)}: ${a.selectors.join(", ")}`:void 0,menu:()=>a?Gh(a.value):[],rows:n.filter(c=>(c.family??"initial")===s).sort((c,u)=>Yp(u.value)-Yp(c.value)).map(c=>{const u=Yp(c.value),h=MF(c.lead,u),p=c.value.endsWith("px")?`${u}`:c.value;return{key:`${c.value}/${c.lead??""}`,sample:`${l} ${p}${h===null?"":`/${h}`}`,style:{fontFamily:s,fontSize:c.value,lineHeight:c.lead},name:da(c.uses),label:c.value,tipText:`${c.value}${c.lead?` / ${c.lead}`:""}
|
|
251
|
+
${da(c.uses)}: ${c.selectors.join(", ")}`,menu:()=>Gh(c.value)}})}})}function qE({groups:e,outline:t,clear:n}){const r=(a,l,c)=>t({type:"highlight-computed",props:OF(a.currentTarget.querySelector(".design-face-sample"),l?["font-family","font-size","line-height"]:["font-family"]),match:"all",label:c}),s=Jt("design");return f.jsx("div",{className:"design-faces",children:e.map(a=>f.jsxs("div",{className:"design-face-group",children:[f.jsxs("div",{className:"design-face-head row-edge",onMouseEnter:l=>r(l,!1,a.label),onMouseLeave:n,...s.contextMenu(a.menu),...a.tipText?It(a.tipText,void 0,{placement:"follow"}):{},children:[f.jsx("span",{className:"design-face-sample design-face-family",style:{fontFamily:a.stack},children:a.family}),a.name&&f.jsx("span",{className:"design-face-name row-dim",children:a.name})]}),a.rows.map(l=>f.jsxs("div",{className:"design-face row-edge",onMouseEnter:c=>r(c,!0,l.label),onMouseLeave:n,...s.contextMenu(l.menu),...It(l.tipText,void 0,{placement:"follow"}),children:[f.jsx("span",{className:"design-face-sample",style:l.style,children:l.sample}),f.jsx("span",{className:"design-face-name row-dim",children:l.name})]},l.key))]},a.stack))})}function GE({kind:e,name:t,lines:n,actual:r,ratio:s,largest:a,tipText:l,menu:c,outline:u,clear:h}){const p=e==="color"&&Ql(r)!==null,g=e==="length"?Number.parseFloat(r):Number.NaN,k=Jt("design");return f.jsxs("div",{className:"design-cell","data-kind":e,...k.contextMenu(c),onMouseEnter:p?y=>{const v=y.currentTarget.querySelector(".design-fill"),_=v?getComputedStyle(v).backgroundColor:"";u({type:"highlight-computed",props:RF.map(E=>[E,_]),match:"any",label:t})}:void 0,onMouseLeave:p?h:void 0,...It(l),children:[e==="color"&&f.jsx("div",{className:"design-sample",children:p&&f.jsx("span",{className:"design-fill",style:{background:r}})}),f.jsxs("div",{className:"design-plate",children:[f.jsx("span",{className:"design-cell-name",children:t}),n.map((y,v)=>f.jsxs("span",{className:"design-cell-line",children:[f.jsx("span",{className:"design-cell-value",children:y}),v===0&&s&&f.jsx("span",{className:"design-cell-note",children:s})]},y)),Number.isFinite(g)&&a>0&&f.jsx("span",{className:"design-scale",style:{width:`${Math.max(2,Math.abs(g)/a*100)}%`}})]})]})}function DF(e,t,n,r=[]){const s=[e.name,e.resolved?`${e.value} resolves to ${e.resolved}`:e.value];if(r.length>0&&s.push(`same value as ${r.join(", ")}`),t&&n){const a=e.name===n.name;s.push(a?"the ground these ratios are measured against":`${t} against ${n.name}`)}return s.join(`
|
|
252
|
+
`)}function zF(e,t,n){const r=[e.value,`${da(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(`
|
|
253
|
+
`)}function VE({shared:e,rest:t}){return e.length===0?f.jsx("ul",{className:"design-rows",children:t}):f.jsxs(f.Fragment,{children:[f.jsx("ul",{className:"design-rows",children:e}),t.length>0&&f.jsxs("details",{className:"design-tail",children:[f.jsxs("summary",{className:"row-edge",children:[f.jsx("span",{className:"design-count row-dim",children:t.length}),"used once or never"]}),f.jsx("ul",{className:"design-rows",children:t})]})]})}function FF({index:e,outline:t,clear:n,onOpen:r}){const{components:s,typed:a}=e;if(s.length===0)return null;const l=s.filter(h=>h.imports>=2),c=s.filter(h=>h.imports<2),u=h=>f.jsx(YE,{count:h.imports,name:h.name,path:h.path,onEnter:()=>t({type:"highlight-file",path:h.path,ranges:null}),onLeave:n,onOpen:()=>r(h.path),children:h.variants.length>0&&f.jsx("span",{className:"design-variants",children:h.variants.map(p=>f.jsxs("span",{className:"design-variant",children:[p.prop,": ",p.values.join(" · ")]},p.prop))})},`${h.path}:${h.name}`);return f.jsxs(Zd,{title:"Components",note:`${l.length} reused of ${s.length}`,children:[!a&&f.jsx(md,{children:"No TypeScript in this project, so the values each prop allows are not listed."}),f.jsx(VE,{shared:l.map(u),rest:c.map(u)})]})}function BF({index:e,outline:t,clear:n,onOpen:r}){const{classes:s,coverage:a}=e,l=s.filter(k=>k.uses>0),c=s.filter(k=>k.uses>=2),u=s.filter(k=>k.uses<2),h=c.filter(k=>k.unwrapped).length,p=s.length?`${c.length} reused of ${s.length}`+(h?`, ${h} with no component of their name`:""):void 0,g=k=>f.jsx(UF,{cls:k,outline:t,clear:n,onOpen:r},k.name);return f.jsx(Zd,{title:"Classes",note:p,children:s.length===0?f.jsx(md,{children:"No stylesheet in this project defines a class. Utility-first CSS generates its own."}):l.length===0?f.jsx(md,{children:a.classAttrs>0?`${a.classAttrs} class attributes were read, and none names a class this scan can follow. That is what a CSS Modules project looks like from here.`:"No class attribute anywhere in the source that was read. The markup may live in a file type this scan does not open."}):f.jsx(VE,{shared:c.map(g),rest:u.map(g)})})}function UF({cls:e,outline:t,clear:n,onOpen:r}){return f.jsx(YE,{count:e.uses,name:`.${e.name}`,path:e.path,onEnter:()=>t({type:"highlight-selector",selector:`.${e.name}`,label:`.${e.name}`}),onLeave:n,onOpen:()=>e.path&&r(e.path),children:e.unwrapped&&f.jsx("span",{className:"design-tag",children:"no component"})})}function YE({count:e,name:t,path:n,onEnter:r,onLeave:s,onOpen:a,children:l}){const c=us(),u=ot();ht();const h=Jt("design");return f.jsx("li",{children:f.jsxs("button",{type:"button",className:"design-row row-edge",onMouseEnter:r,onFocus:r,onMouseLeave:s,onBlur:s,onClick:a,disabled:!n,...h.contextMenu(()=>c?wF({id:c.worktree.id,dir:c.worktree.path},n,{sock:u},a):[]),children:[f.jsx("span",{className:"design-count row-dim",children:e}),f.jsx("span",{className:"design-name",children:t}),f.jsx("span",{className:"design-path row-dim",children:n}),l]})})}function HF({worktreeId:e,procs:t,borrowed:n,login:r,current:s,onRestart:a}){const l=ot();ht();const c={sock:l},u=(p,g)=>f.jsx($t,{icon:"reload",label:g,onClick:()=>a(p)}),h={id:ls,label:"login",tip:It("The agent's login; it closes once you are in",void 0,{placement:"top"}),trail:u(ls,"Run the login again")};return r&&s===ls?[h]:[{id:po,label:"shell",tip:It("A shell in this worktree",void 0,{placement:"top"}),menu:()=>U_(e,c),trail:u(po,"Restart the shell")},...r?[h]:[],...t.map(p=>({id:p.name,label:p.name,lead:f.jsx("span",{className:`dot ${p.status}`}),tip:It(v$(p.status),void 0,{placement:"top",dot:p.status,name:p.name,detail:p.command,aside:[`:${p.port}`]}),menu:()=>lg(p,e,c),trail:u(p.name,`Restart ${p.name}`)})),...n.map(p=>({id:p,label:p,lead:f.jsx("span",{className:"dot borrowed"}),tip:It(`${p} runs on main for every worktree; this one reaches it at its usual address`,void 0,{placement:"top"})}))]}const WF=S.lazy(()=>Uh(()=>import("./XTerm-dug6M6yd.js"),__vite__mapDeps([3,4]))),KF=[];function ZF({worktreeId:e,opened:t,height:n,onDragStart:r}){const s=ht(),a=ot(),l=Rd(),c=P(H=>H.connected),u=P(H=>H.focusTerm),h=us(),p=(h==null?void 0:h.procs)??[],g=(h==null?void 0:h.borrowed)??KF,k=(h==null?void 0:h.login)??!1,y=At(e,"termStream"),v=P(H=>{var Y;return((Y=H.termRun)==null?void 0:Y.id)===e&&y===po?H.termRun.command:null}),[_,E]=S.useState(null),C=g.includes(y);S.useEffect(()=>{y===po||(y===ls?k:p.some(Y=>Y.name===y)||g.includes(y))||s({a:"term-stream",id:e,stream:po})},[p,g,k,y,e,s]);const x=H=>{H!==y&&(E(null),s({a:"term-stream",id:e,stream:H}))},N=S.useRef(!1),[M,J]=S.useState(0),W=H=>{H===po&&H===y&&(N.current=!0),a==null||a.send({t:"term-restart",worktreeId:e,stream:H}),H===ls&&H===y&&(E(null),J(Y=>Y+1))},R=(H,Y)=>{if(H)return E(null);if(N.current){N.current=!1,J(ae=>ae+1);return}E({code:Y})},j=HF({worktreeId:e,procs:p,borrowed:g,login:k,current:y,onRestart:W}),A=S.useRef(!t),D=!A.current;return S.useEffect(()=>{A.current=!1},[]),f.jsxs(gg,{kind:"terminal",className:"term-pane",height:n,onDragStart:r,tabs:{items:j,current:y,onPick:x,font:"mono",owner:"terminal",label:"terminal streams"},onClose:()=>s({a:"toggle-terminal"}),closeHint:xt("terminal"),children:[f.jsxs("div",{className:"term-body",children:[C&&f.jsx(pd,{pane:!0,title:`${y} runs on main`,body:"Every worktree reaches main's copy until its own changes touch it, or until asked.",action:f.jsx(Be,{variant:"outline",onClick:()=>a==null?void 0:a.send({t:"own-procs",worktreeId:e,names:[y]}),children:"run it here"})}),f.jsx(mg,{pane:!0,children:f.jsx(S.Suspense,{fallback:f.jsx("div",{className:"empty",children:"loading terminal…"}),children:f.jsx(WF,{worktreeId:e,stream:y,theme:l,sock:a,connected:c,focusOnMount:D,focusReq:u,onAlive:R,run:v,onRan:()=>s({a:"term-ran"}),onEscape:()=>s({a:"toggle-terminal"})},`${y}:${M}`)})})]}),_!==null&&!C&&f.jsx(pd,{pane:!0,title:y===po?"the shell exited":y===ls?"the login did not finish":`${y} exited`,body:_.code===void 0?void 0:`exit code ${_.code}`,action:f.jsx(Be,{variant:"outline",onClick:()=>W(y),children:"restart"})})]})}function qF(e,t){const r=e.procs.filter(a=>a.status==="crashed"||a.status==="unreachable").map(a=>`- \`${a.name}\`: \`${a.command}\`, started with PORT=${a.port}. ${GF(a)}`),s=t.slice(-40).map(a=>`[${a.proc}] ${a.line}`).join(`
|
|
254
|
+
`);return["The dev server in this worktree is not reachable, so the preview is empty.","",...r,"",s?`Last output:
|
|
255
|
+
\`\`\`
|
|
256
|
+
${s}
|
|
257
|
+
\`\`\``:"It produced no output.","","Find the cause and fix it. The command must run in the foreground and listen on the port in the PORT environment variable, which Toyon sets differently for each worktree. If the tool takes its port from a flag instead (Vite does), make the app read PORT, for Vite `server.port: Number(process.env.PORT)` with `strictPort: true`, or add the flag to the start command in toyon's settings file. When your turn ends toyon restarts the process and checks again."].join(`
|
|
258
|
+
`)}function GF(e){return e.detail?e.detail:e.status==="crashed"?e.exitCode!=null?`It exited with code ${e.exitCode}.`:"It crashed.":"It never answered on that port."}function VF(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(`
|
|
259
|
+
`)}function YF(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(`
|
|
260
|
+
`)}function QF(e){return e==="reserved"?"checking out a fresh worktree…":e==="warming"?"copying dependencies and running setup…":"starting dev servers…"}const XF="preview off since the restore; it starts when the agent writes a file";function JF({worktree:e,log:t}){const n=ot(),r=ht(),s=e.procs,a=_=>n==null?void 0:n.send({t:"term-restart",worktreeId:e.id,stream:_.name}),l=s.some(_=>_.status==="crashed"||_.status==="unreachable"),c=P(_=>_.clientId),u=Wl(e,"setup"),h=u&&u.status!=="terminated"?u:null,p=_a(zm(h??void 0)?h==null?void 0:h.since:void 0),g=!!e.worktree.parked&&s.length===0,k=()=>n==null?void 0:n.send({t:"preview-start",worktreeId:e.id}),y=h&&(h.status==="running"||h.status==="detached"),v=()=>{const _=qF(e,t);if(hr(e.worktree)){const E=Ta(e.worktree)?{worktreeId:e.id}:{};n==null||n.send({t:"create-worktree",clientId:c,repoId:e.repoId,prompt:_,...E})}else n==null||n.send({t:"chat",worktreeId:e.id,text:_})};return f.jsxs(ds,{wide:!0,children:[s.length===0?f.jsx("div",{className:"status-line",children:h?f.jsx("span",{className:"live-text","data-tip":T1[h.status],children:_h("setup",h,p)}):g?XF:QF(e.worktree.phase)}):f.jsx("ul",{className:"boot-procs",children:s.map(_=>f.jsxs("li",{className:Ke("boot-proc",(_.status==="crashed"||_.status==="unreachable")&&"boot-bad"),children:[f.jsx("span",{className:"boot-name",children:_.name}),f.jsx("span",{className:"boot-status",children:e8(_)}),(_.status==="crashed"||_.status==="unreachable")&&f.jsx(Be,{variant:"outline",onClick:()=>a(_),children:"restart"}),_.detail&&_.status!=="asleep"&&f.jsx("div",{className:"boot-detail",children:_.detail})]},_.name))}),g&&f.jsx("div",{className:"status-actions",children:f.jsx(Be,{variant:"outline",size:"lg",onClick:k,children:"start preview"})}),y&&f.jsx("div",{className:"status-actions",children:f.jsx(Be,{variant:"outline","data-tip":j1("setup"),onClick:()=>n==null?void 0:n.send({t:"run-stop",worktreeId:e.id,kind:"setup"}),children:"stop setup"})}),l&&f.jsxs("div",{className:"status-actions",children:[e.agent==="idle"&&f.jsx(Be,{variant:"outline",size:"lg",onClick:v,children:"ask the agent to fix it"}),f.jsx(Be,{onClick:()=>r({a:"open",overlay:{kind:"setup",repoId:e.repoId}}),children:"edit setup"})]}),t.length>0&&f.jsx("pre",{className:"status-tail",children:t.slice(-30).map(_=>`[${_.proc}] ${_.line}`).join(`
|
|
261
|
+
`)})]})}function e8(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 t8({row:e}){const t=ot(),n=P(a=>a.clientId),r=P(a=>a.home),s=r&&e.path.startsWith(`${r}/`)?`~${e.path.slice(r.length)}`:e.path;return f.jsxs(ds,{wide:!0,children:[f.jsx("p",{className:"status-line",children:e.name}),f.jsxs("p",{children:["This worktree exists in git, but Toyon did not make it and is not running it: no dev servers, no preview, no agent. A shell at ",f.jsx("code",{children:s})," opens below."]}),e.locked?f.jsxs("p",{children:["Another tool is holding it",e.lockReason?`: ${e.lockReason}`:"",". Taking it over would put Toyon's dev servers in a directory something else is working in, so that stays off until the lock goes."]}):f.jsxs(f.Fragment,{children:[f.jsx("p",{children:"Taking it over gives it a port, starts the processes from the project's settings and lists it with your other worktrees. Your files are left alone: the install and setup commands do not re-run."}),f.jsx("div",{className:"status-actions",children:f.jsx(Be,{variant:"outline",size:"lg",onClick:()=>t==null?void 0:t.send({t:"adopt-worktree",worktreeId:e.id,clientId:n}),children:"take over"})})]})]})}function n8(e,t,n){return!e||!t||e===t?null:n(e)===n(t)?e:null}function r8(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 o8(e){return e.available?e.sandboxed?`${e.name} works on it`:`${e.name} works on it, with no sandbox around its commands`:e.installing?`${e.name} is installing; it works on it once that lands`:e.onDemand&&e.reason==="not installed"?`${e.name} is a large download; press to fetch it`:`${e.reason??"not installed"}; press to install again`}function QE(){const e=ot(),t=P(u=>u.agents),n=P(u=>u.agentChosen),[r,s]=S.useState(null),a=r?t.find(u=>u.id===r):void 0,l=u=>e==null?void 0:e.send({t:"set-default-agent",agent:u});if(gt([a==null?void 0:a.available,r],()=>{!r||!(a!=null&&a.available)||(l(r),s(null))}),n)return null;const c=u=>{if(u.available){l(u.id);return}s(u.id),u.installing||e==null||e.send({t:"install-agent",agent:u.id})};return f.jsxs("div",{className:"hint agent-ask",children:[f.jsx("span",{children:"which agent works on it?"}),t.map(u=>f.jsx(Be,{variant:"outline",size:"md",busy:u.installing||r===u.id,onClick:()=>c(u),...It(o8(u)),children:u.name},u.id))]})}function s8({active:e}){const t=ht(),n=ot(),r=Un(),s=$a(),a=P(u=>u.home),l=e.worktree.title,c=()=>{s!=null&&s.made&&(t({a:"new-project",v:{...bm({mode:s.made==="git"?"init":"create",name:s.name,parent:PE(s.path,a)??s.path}),phase:"unmaking",repoId:s.id,prompt:go(r.getState(),e.worktree.id).draft}}),n==null||n.send({t:"unmake-repo",repoId:s.id}))};return f.jsxs(ds,{anchor:"line",children:[f.jsx("p",{className:"form-title",children:s!=null&&s.made?f.jsx(Be,{variant:"inline",onClick:c,...It("Rename or move this project"),children:l}):l}),f.jsx(QE,{}),f.jsx("div",{className:"form-body form-body-lg",children:f.jsx(Bh,{active:e,greenfield:!0})})]})}function i8({pending:e}){const t=ht(),n=ot(),r=!!e.error,s=()=>{n==null||n.send({t:"cancel-import",id:e.id}),t({a:"watch-import",id:null})},a=S.useRef(null);return S.useEffect(()=>{var l;return(l=a.current)==null?void 0:l.scrollTo({top:a.current.scrollHeight})},[e.lines.length]),f.jsxs(ds,{wide:!0,children:[f.jsxs("p",{className:"status-line",children:[r?"could not import":"importing"," ",e.name]}),f.jsxs("p",{children:["from ",f.jsx("code",{children:e.url})," into ",f.jsx("code",{children:e.parent})]}),r?f.jsx("p",{className:"import-error",children:e.error}):f.jsx("p",{className:"hint",children:"the whole history is cloned, so worktrees, land and graft all work on it straight away."}),f.jsx("div",{className:"status-tail",ref:a,children:e.lines.length===0&&!r?f.jsx("span",{className:"import-idle",children:"starting git…"}):e.lines.map((l,c)=>f.jsx("div",{children:l},c))}),f.jsx("div",{className:"status-actions",children:f.jsx(Be,{variant:"outline",size:"lg",onClick:s,children:r?"dismiss":"stop"})})]})}const a8=150,l8=/^[^\s@]+@[^\s@]+$/,c8=14,D0=[];function u8({project:e}){var oe;const t=ht(),n=ot(),r=P(Z=>Z.repos),s=P(Z=>Z.home),a=P(Z=>Z.folderDialog),l=P(Z=>Z.gitIdentity),c=P(Z=>Z.choosingFolder),u=P(Z=>Z.chosenFolder),h=P(Z=>Z.paths),p=P(Z=>Z.agents),g=P(Z=>Z.defaultAgent),k=P(Z=>Z.agentChosen),[y,v]=S.useState({name:"",email:""}),[_,E]=S.useState(null),[C,x]=S.useState(null),N=S.useRef(null),M=S.useRef(null),{mode:J,name:W,parent:R,prompt:j}=e,A=J==="clone",D=J==="init",H=e.phase==="editing",Y=W.trim(),ae=D||!Y?null:Bl(W),me=!D&&Y&&!ae?LE(R,Y):null,ye=Zh(R,s),_e=me!==null&&h.query===me&&((oe=h.target)==null?void 0:oe.exists)===!0,V=!l&&!A,O=!V||y.name.trim()!==""&&l8.test(y.email.trim()),F=H&&!_&&(D||Y!==""&&!ae&&!_e)&&O&&k,ne=p.find(Z=>Z.id===g),[$,q]=sE(g),[ke,se]=oE(g),ve=(Z,De)=>{if(Z===g){q(De);return}iE(Z,De),n==null||n.send({t:"set-default-agent",agent:Z})};S.useEffect(()=>{if(!me)return;const Z=setTimeout(()=>n==null?void 0:n.send({t:"browse-path",path:me}),a8);return()=>clearTimeout(Z)},[me,n]),gt([e.phase],()=>{var Z;e.phase==="editing"&&((Z=N.current)==null||Z.focus())}),gt([J,W,R],()=>x(null));const Re=()=>{F&&(t({a:"open-repo"}),t({a:"new-project-set",v:{phase:"creating"}}),n==null||n.send({t:"create-repo",mode:J,parent:R.trim(),name:Y,...A&&e.url?{url:e.url}:{},...V?{identity:{name:y.name.trim(),email:y.email.trim()}}:{}}))},le=Z=>{const De=r.find(Ve=>Ve.path===Vl(Z,s));if(De){t({a:"activate-repo",id:De.id});return}t({a:"open-repo"}),n==null||n.send({t:"register-repo",path:Z})},xe=Z=>{x(null),a?(t({a:"choosing-folder",v:Z}),n==null||n.send({t:"choose-folder",start:R,purpose:Z})):t(Z==="location"?{a:"open",overlay:{kind:"choose-folder"}}:{a:"open",overlay:{kind:"projects",form:"disk"}})};gt([u==null?void 0:u.seq],()=>{var De,Ve;if(!c||!u)return;t({a:"choosing-folder",v:!1});const Z=u.folder;if(!Z){(De=N.current)==null||De.focus();return}if(c==="open"&&Z.kind==="project"){le(Z.path);return}if(c==="open"&&Z.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(E(Z.kind==="project"?Z.path:null),Z.kind!=="project"){if(Z.kind==="empty"&&!A){const ze=$E(Z.path);t({a:"new-project-set",v:{mode:"init",parent:ze.parent,name:ze.name}});return}t({a:"new-project-set",v:{mode:A?"clone":"create",parent:Z.path}}),(Ve=N.current)==null||Ve.focus()}});const Le=C??(D?"the empty folder you chose becomes the project":_?"the folder you chose is already a project: open it, or choose another":_e?`${ye} already has a folder called ${Y}`:ae);return f.jsxs(ds,{anchor:"line",children:[A&&f.jsx("p",{className:"new-project-url",children:e.url}),f.jsxs("div",{className:"form-head",children:[D?f.jsx("p",{className:"form-title",children:W}):f.jsx(Ro,{ref:N,bare:!0,font:"lead",className:"new-project-field",autoFocus:!0,spellCheck:!1,autoComplete:"off",value:W,placeholder:"Project name",disabled:!H,style:{width:`${Math.max(W.length+1,c8)}ch`},onChange:Z=>t({a:"new-project-set",v:{name:Z.target.value}}),onKeyDown:Z=>{var De;Z.key==="Enter"&&(Z.preventDefault(),(De=M.current)==null||De.focus())}}),f.jsxs("span",{className:"new-project-where",children:[f.jsx("span",{className:"hint",children:"in"}),f.jsx("span",{className:"new-project-parent",...It(R),children:ye}),f.jsx($t,{icon:"folder",label:a?"Choose in Finder":"Choose a folder",className:"new-project-folder",on:c==="location",disabled:!H,onClick:()=>xe("location")})]})]}),Le&&f.jsx("p",{className:"hint",children:Le}),f.jsx(QE,{}),f.jsx("div",{className:"form-body",children:f.jsx(Ea,{ref:M,bare:!0,font:"ui",value:j,placeholder:`describe ${Y||"the app"}…`,disabled:!H,onChange:Z=>t({a:"new-project-set",v:{prompt:Z.target.value}}),onKeyDown:Z=>{Z.key!=="Enter"||Z.shiftKey||(Z.preventDefault(),Re())}})}),f.jsxs("div",{className:"hint form-knobs",children:[p.length>1?f.jsx(aE,{agents:p,agent:g,model:$,onChange:ve}):f.jsx(zh,{models:(ne==null?void 0:ne.models)??D0,value:$,onChange:q}),f.jsx(Dh,{efforts:(ne==null?void 0:ne.efforts)??D0,value:ke,onChange:se}),_?f.jsx(Be,{variant:"outline",size:"lg",className:"form-go",autoFocus:!0,onClick:()=>le(_),children:"open it"}):f.jsx(Be,{variant:"outline",size:"lg",className:"form-go",busy:e.phase==="creating",disabled:!F,onClick:Re,...It(k?A?"Clone the project":j.trim()?"Make it and start on this":"Make the project":"Choose an agent first","⏎"),children:A?"clone":"create"})]}),e.error&&f.jsx("p",{className:"hint",role:"status",children:e.error}),V&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"new-project-identity",children:[f.jsx(Ro,{size:"md",font:"ui",rule:!0,value:y.name,placeholder:"Your name",autoComplete:"name",disabled:!H,onChange:Z=>v({...y,name:Z.target.value})}),f.jsx(Ro,{size:"md",font:"ui",rule:!0,type:"email",value:y.email,placeholder:"Email",autoComplete:"email",disabled:!H,onChange:Z=>v({...y,email:Z.target.value})})]}),f.jsx("p",{className:"hint",children:"git labels the work you save with these, and asks only once"})]}),!A&&H&&f.jsx(Be,{tone:"quiet",className:"new-project-open",onClick:()=>xe("open"),children:"or open a folder you already have"})]})}function ia({label:e,hint:t,children:n}){return f.jsxs("label",{className:"form-row",children:[f.jsx("span",{className:"form-label",children:e}),f.jsxs("div",{className:"form-control",children:[n,t&&f.jsx("span",{className:"hint",children:t})]})]})}let d8=1;const Qp=(e,t,n=!1)=>({id:d8++,name:e,cmd:t,shared:n}),f8=[{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 p8({repo:e,onClose:t}){const n=ot(),r=Un(),s=P(le=>le.clientId),a=P(le=>le.rows.find(xe=>{var Le;return ir(xe)&&xe.id===((Le=ba(le,e.id))==null?void 0:Le.id)})??null),l=P(le=>{var xe;return((xe=ba(le,e.id))==null?void 0:xe.id)??null});S.useEffect(()=>{if(!t)return;const le=xe=>xe.key==="Escape"&&t();return window.addEventListener("keydown",le),()=>window.removeEventListener("keydown",le)},[t]);const[c]=S.useState(()=>Object.keys(e.config.run).length>0),[u,h]=S.useState(()=>{const le=Object.entries(e.config.run).map(([xe,Le])=>Qp(xe,tb(Le),eT(Le)));return le.length>0?le:[Qp("web","")]}),[p,g]=S.useState(()=>(e.config.setup??[]).join(`
|
|
262
|
+
`)),[k,y]=S.useState(()=>(e.config.teardown??[]).join(`
|
|
263
|
+
`)),[v,_]=S.useState(()=>e.config.check??""),[E,C]=S.useState(()=>wi(e.config).land),[x,N]=S.useState(()=>wi(e.config).automerge),[M,J]=S.useState(()=>wi(e.config).merge??"default"),[W,R]=S.useState(()=>rT(e.configFile)),j=oT(e.configFile,W),A=!!e.remote&&E==="pr",D=u.length>1,H=u.some(le=>le.name.trim()&&le.cmd.trim()),ae=!!a&&!t&&!c&&!H,me=(le,xe)=>h(u.map((Le,oe)=>oe===le?{...Le,...xe}:Le)),ye=le=>le.split(`
|
|
264
|
+
`).map(xe=>xe.trim()).filter(Boolean),_e=()=>ye(p),V=()=>ye(k),O=()=>{const{check:le,land:xe,teardown:Le,...oe}=e.config,Z=e.remote?E:nh,De=M==="default"||Z!=="pr"&&M===rh?void 0:M,Ve={...Z!==nh?{route:Z}:{},...Z==="pr"&&x?{automerge:!0}:{},...De?{method:De}:{}};return{...oe,setup:_e(),...V().length>0?{teardown:V()}:{},...v.trim()?{check:v.trim()}:{},...Object.keys(Ve).length>0?{land:Ve}:{}}},F=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...O(),run:Object.fromEntries(u.filter(le=>le.name.trim()&&le.cmd.trim()).map((le,xe)=>[le.name.trim(),le.shared&&xe>0?{cmd:le.cmd.trim(),from:"trunk"}:le.cmd.trim()]))},kind:W}),t==null||t()},ne=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...O(),run:{}},kind:W}),t==null||t()},$=()=>n==null?void 0:n.send({t:"create-worktree",clientId:s,repoId:e.id,prompt:YF(e,j)}),q=e.services,ke=[p,k,...u.map(le=>le.cmd)].some(le=>le.includes("TOYON_WORKTREE"))||tT(e.config),se=q?[q.envUrl?`the database at ${q.envUrl.name} in ${q.envUrl.file}`:null,q.compose?`the stack in ${q.compose}`:null].filter(Boolean).join(" and "):"",ve=()=>q&&(n==null?void 0:n.send({t:"create-worktree",clientId:s,repoId:e.id,prompt:VF(e,j,q)})),Re=(le,xe)=>f.jsxs("div",{className:"setup-proc",children:[D&&f.jsx(Ro,{size:"md",rule:!0,className:"setup-name",value:le.name,placeholder:"name",...It("Process name, shown in the status bar"),onChange:Le=>me(xe,{name:Le.target.value})}),f.jsx(Ro,{size:"md",rule:!0,className:"setup-cmd",value:le.cmd,placeholder:"npm run dev",onChange:Le=>me(xe,{cmd:Le.target.value})}),D&&f.jsx($t,{icon:"close",label:"Remove",onClick:()=>h(u.filter((Le,oe)=>oe!==xe))}),D&&xe>0&&f.jsx(TE,{className:"setup-shared",checked:le.shared,onChange:Le=>me(xe,{shared:Le.target.checked}),tip:"Main runs it once for every worktree; a worktree whose changes touch it runs its own",children:"shared from main"})]},le.id);return f.jsxs(ds,{children:[f.jsxs("p",{className:"form-title",children:["how does ",e.name," start?"]}),q&&!ke&&f.jsxs("p",{className:"hint setup-shared-note",children:["Worktrees will share ",se,", migrations included."," ",f.jsx(Be,{tone:"quiet",disabled:!a,onClick:ve,children:"ask the agent to keep them apart"})]}),f.jsx(ia,{label:"install",hint:"once per new worktree; one command per line",children:f.jsx(Ea,{size:"md",rule:!0,rows:Math.max(1,p.split(`
|
|
265
|
+
`).length),value:p,placeholder:"bun install",onChange:le=>g(le.target.value)})}),f.jsx(ia,{label:"remove",hint:"once when a worktree goes, before its directory does; one command per line",children:f.jsx(Ea,{size:"md",rule:!0,rows:Math.max(1,k.split(`
|
|
266
|
+
`).length),value:k,placeholder:'dropdb --if-exists "app_$TOYON_WORKTREE"',onChange:le=>y(le.target.value)})}),f.jsx(ia,{label:"check",hint:"runs after each of the agent's turns; the work lands only when it passes",children:f.jsx(Ro,{size:"md",rule:!0,value:v,placeholder:"bun run check",onChange:le=>_(le.target.value)})}),e.remote&&f.jsx(ia,{label:"land",hint:"where a worktree's finished work goes; one way per repo",children:f.jsxs("div",{className:"setup-land",children:[f.jsx(Bs,{value:E,options:pT.map(le=>({id:le.id,label:le.name,description:le.description})),onChange:C,hint:"where the work goes",placeholder:"where work lands"}),A&&f.jsx(Bs,{value:x?"github":"you",options:mT.map(le=>({id:le.id,label:le.name,description:le.description})),onChange:le=>N(le==="github"),hint:"who merges the pull request",placeholder:"who merges it"})]})}),f.jsx(ia,{label:"merge",hint:A?"how GitHub merges the pull request; only what the repo allows":"how the commits arrive on main",children:f.jsx(Bs,{value:M==="default"&&!A?rh:M,options:[...A?[{id:"default",label:"what the repo allows",description:"the repo's allowed methods on GitHub: squash, else a merge commit, else rebase"}]:[],...hT.map(le=>({id:le.id,label:le.name,description:le.description}))],onChange:J,hint:"how the commits arrive on main",placeholder:"how the commits arrive"})}),f.jsx(ia,{label:"start",hint:f.jsxs(f.Fragment,{children:["must listen on ",f.jsx("code",{...It("Toyon sets a different port for each worktree"),children:"$PORT"}),e.guess&&l&&f.jsxs(f.Fragment,{children:[" · from ",f.jsx(Be,{mono:!0,tone:"quiet",...It(`open ${e.guess} in the editor pane`),onClick:()=>Sa(r,n,l,e.guess??"",1),children:e.guess})]})]}),children:u[0]&&Re(u[0],0)}),u.slice(1).map((le,xe)=>f.jsxs("div",{className:"form-row",children:[f.jsx("span",{className:"form-label"}),f.jsx("div",{className:"form-control",children:Re(le,xe+1)})]},le.id)),f.jsxs("div",{className:"form-row",children:[f.jsx("span",{className:"form-label"}),f.jsxs(Be,{tone:"quiet",onClick:()=>h([...u,Qp("","")]),children:[f.jsx(Et,{name:"plus",className:"icon-inline"})," another process"]})]}),f.jsxs("div",{className:"form-knobs",children:[f.jsx(Bs,{value:W,options:f8,onChange:R,hint:"whether the settings file is committed with the repo or kept out of git",placeholder:"committed or kept local"}),f.jsx("span",{className:"form-sign",children:j}),t&&f.jsx(Be,{onClick:t,children:"cancel"}),(!c||t)&&f.jsx(Be,{...It("This project has no dev server: chat, changes and the terminal work, the preview stays empty"),onClick:ne,children:"no dev server"}),ae&&a?f.jsx(Be,{variant:"outline",size:"lg",disabled:a.agent!=="idle",...It("The agent reads the repo and writes the settings file; the daemon picks it up as soon as it lands"),onClick:$,children:"let the agent work it out"}):f.jsxs(Be,{variant:"outline",size:"lg",disabled:!H,...t?It("Restarts every worktree of this repo. Profiles and other keys in the file are kept."):{},onClick:F,children:[t?"save + restart":"start"," ",f.jsx(Et,{name:"forward",className:"icon-inline"})]})]})]})}const Xp={title:"Toyon was updated",body:"The Toyon running is older than the one installed. Restart it to finish the update.",waiting:"Restarting Toyon. This page reloads when it is back."},h8=1e3,z0={held:[],asking:[],seen:[]};async function F0(e,t){for(;;){await new Promise(s=>setTimeout(s,h8));const[n,r]=await Promise.all([wh(),Yx()]);if(n!==null&&n!==e)break;t(r??{waiting:[],asking:[]})}window.location.reload()}function m8(){const[e,t]=S.useState(!1),[n,r]=S.useState(null),[s,a]=S.useState(z0),l=S.useRef(null),c=S.useCallback(g=>a(k=>({held:g.waiting,asking:g.asking,seen:e6(k.seen,g.waiting)})),[]);S.useEffect(()=>{let g=!0;return(async()=>{const[k,y]=await Promise.all([wh(),Yx()]);!g||y===null||l.current||(l.current={pid:k},t(!0),c(y),F0(k,c))})(),()=>{g=!1}},[c]);const u=async g=>{t(!0),r(null);const k=l.current??{pid:await wh()},y=await q2(g);if(y){t(l.current!==null),r(y);return}g&&a(z0),!l.current&&(l.current=k,F0(k.pid,c))},h=e&&s.held.length>0,p=h?t6(s.seen,s.held,s.asking):[];return f.jsx(pd,{title:Xp.title,body:n??(h?n6(s.held.length,s.seen.length):e?Xp.waiting:Xp.body),action:h?f.jsx(Be,{variant:"outline",onClick:()=>void u(!0),children:"restart now"}):f.jsx(Be,{variant:"outline",busy:e,onClick:()=>void u(!1),children:"restart"}),children:p.length>0&&f.jsx("ul",{className:"crash-list",children:p.map((g,k)=>f.jsxs("li",{className:Ke("crash-row",g.dot!=="working"&&"row-dim"),children:[f.jsx("span",{className:Ke("dot",g.dot)}),f.jsx("span",{className:"crash-row-name",children:g.name}),g.note&&f.jsx("span",{className:"crash-row-note",children:g.note})]},k))})})}const g8=1500,k8={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};class y8{constructor(t,n,r=k8){Ct(this,"frames",new Map);this.send=t,this.sendTitle=n,this.timers=r}note(t,n,r){const s=this.frame(t);s.timer!==null&&(this.timers.clear(s.timer),s.timer=null),s.pending=null,r!==void 0&&(s.title=vw(r));const a=Nd(n);if(!a){s.sent=null;return}if(a===s.sent){this.renamed(t,s);return}s.pending=a,s.timer=this.timers.set(()=>{s.timer=null,s.pending=null,s.sent=a,s.sentTitle=s.title,this.send(t,a,s.title)},g8)}title(t,n){const r=this.frame(t);r.title=vw(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 w8=Vx(),v8=2*6e4;function B0(e){e==null||e.setAttribute("src",e.src)}const b8=8e3;function x8({onRoot:e}){const t=S.useRef(null),n=S.useCallback(ee=>{t.current=ee,e(ee)},[e]),r=ht(),s=Un(),a=ot(),l=S.useRef(a);l.current=a;const[c]=S.useState(()=>new y8((ee,Se,be)=>{var fe,Pe;(fe=l.current)==null||fe.send({t:"visit",worktreeId:ee,path:Se,title:be}),hx((Pe=s.getState().local[ee])==null?void 0:Pe.pages)&&Wt.post(ee,{type:"links"})},(ee,Se,be)=>{var fe;return(fe=l.current)==null?void 0:fe.send({t:"page-title",worktreeId:ee,path:Se,title:be})}));S.useEffect(()=>()=>c.dispose(),[c]);const u=Lx(),h=Oa(),p=us(),g=P(ee=>ee.connected),k=P(ee=>ee.heard),y=P(ee=>ee.connectFailure),v=P(ee=>ee.remote),_=P(ee=>ee.editor),E=Dx(),C=S2(),x=nc(),N=P(ee=>ee.layout.term)&&!x,M=P(ee=>ee.focusTerm),J=S.useRef(!1),W=S.useRef(M),R=!J.current||M!==W.current;S.useEffect(()=>{J.current=N&&!!h,W.current=M});const j=rc(),A=P(ee=>ee.layout.design)&&!x&&!j,D=P(ee=>ee.reloadReq),H=Rd(),Y=S.useRef(H);Y.current=H;const ae=P(ee=>ee.zen),me=P(ee=>{var Se;return((Se=ee.dragFiles)==null?void 0:Se.at)==="centre"}),ye=S.useRef(ae);ye.current=ae;const _e=At(h,"log"),V=P(ee=>ee.incompatible),O=T2(),F=P(ee=>{var Se;return((Se=ee.overlay)==null?void 0:Se.kind)==="setup"?ee.repos.find(be=>be.id===ee.overlay.repoId)??null:null}),ne=(p==null?void 0:p.worktree.empty)===!0,$=!!p&&ec(p),q=O&&!ne&&!$?O:null,ke=q??F,se=P(ee=>ee.pending.find(Se=>Se.id===ee.activeImportId)??null),[ve,Re]=S.useState([]),le=S.useRef(new Map),xe=S.useRef(new Map),[Le,oe]=S.useState([]),Z=S.useRef(new Set),De=S.useRef(new Set);S.useEffect(()=>{Wt.post=(ee,Se)=>{var be,fe;if(Se.type==="reload"&&Z.current.has(ee))return B0(le.current.get(ee));(fe=(be=le.current.get(ee))==null?void 0:be.contentWindow)==null||fe.postMessage({__toyon:!0,...Se},xe.current.get(ee)??"*")},Wt.broadcast=ee=>{var Se;for(const[be,fe]of le.current)(Se=fe.contentWindow)==null||Se.postMessage({__toyon:!0,...ee},xe.current.get(be)??"*")}},[]),S.useEffect(()=>{let ee=null;const Se=Pe=>{Pe.target instanceof HTMLElement&&Pe.target.tagName!=="IFRAME"&&(ee=Pe.target)},be=Pe=>{Pe.relatedTarget===null&&setTimeout(()=>{document.activeElement===document.body&&(ee=null)},0)},fe=Pe=>{var rt,St;if((rt=Pe.data)!=null&&rt.__toyon)for(const[bt,cn]of le.current){if(cn.contentWindow!==Pe.source)continue;if(Pe.origin!==xe.current.get(bt))return;const at=lO(Pe.data);if(!at)return;switch(at.type){case"key":window.dispatchEvent(new KeyboardEvent(at.up?"keyup":"keydown",{key:at.key,code:at.code,metaKey:at.meta,ctrlKey:!!at.ctrl,shiftKey:!!at.shift,altKey:!!at.alt}));break;case"hmr":r({a:"hmr",id:bt});break;case"loaded":Z.current.delete(bt),De.current.add(bt),oe(Dt=>Dt.includes(bt)?Dt:[...Dt,bt]),Wt.post(bt,HE(Y.current)),Wt.post(bt,{type:"zen",on:ye.current}),r({a:"hmr",id:bt}),r({a:"page",id:bt,url:at.url,title:at.title,fresh:!0}),c.note(bt,at.url,at.title);break;case"navigated":r({a:"page",id:bt,url:at.url,...at.title!==void 0?{title:at.title}:{}}),c.note(bt,at.url,at.title);break;case"title":r({a:"page",id:bt,title:at.title}),c.title(bt,at.title);break;case"links":r({a:"links",id:bt,links:at.links});break;case"page-error":{const Dt=at.source?` (${Mw(at.source)}:${at.line??"?"})`:"";r({a:"page",id:bt,error:`${at.message}${Dt}`});break}case"picked":{const{type:Dt,verb:un,site:zn,...An}=at,lr=zn==="call"?{file:An.callFile,line:An.callLine}:{file:An.file,line:An.line};if(un==="code"){r({a:"set-picking",v:!1});const Rt=(St=fn(s.getState(),bt))==null?void 0:St.worktree;lr.file?Sa(s,a,bt,Mw(lr.file,Rt==null?void 0:Rt.path),lr.line??1):a==null||a.send({t:"find-element",worktreeId:bt,seq:Io(),element:An.element})}else sM(s,bt,An);break}case"pick-cancel":r({a:"set-picking",v:!1});break;case"drag-files":Om(s,s.getState().activeId?{at:"centre"}:null);break;case"drop-files":a1(s,a,s.getState().activeId?{at:"centre"}:null,jM(at.files));break;case"focus":at.gesture?ee=null:document.activeElement===cn&&(ee!=null&&ee.isConnected)&&ee!==document.body&&ee.focus();break;case"highlight-miss":console.warn(`[toyon] highlight miss on ${at.path}: ${at.fileMatched} elements from this file, ${at.withSource} elements with source info on page, ranges=${JSON.stringify(at.ranges)}`);break}return}};return window.addEventListener("message",fe),document.addEventListener("focusin",Se),document.addEventListener("focusout",be),()=>{window.removeEventListener("message",fe),document.removeEventListener("focusin",Se),document.removeEventListener("focusout",be)}},[r,s,a,c]),S.useEffect(()=>{Wt.broadcast({type:"zen",on:ae})},[ae]);const Ve=S.useRef(new Map);gt([D==null?void 0:D.id,D==null?void 0:D.n],()=>{if(!D)return;const{id:ee}=D;clearTimeout(Ve.current.get(ee)),Ve.current.set(ee,setTimeout(()=>{Ve.current.delete(ee),Wt.post(ee,{type:"reload"})},1200))});const ze=Sm(),it=ze&&!ir(ze)?ze:null,Je=Ai(),en=!!p&&p.procs.some(ee=>ee.status==="running"),kt=Tm(),tn=kt!==null&&kt===h&&en;S.useEffect(()=>{kt&&tn&&!ve.includes(kt)&&Re(ee=>[...ee,kt])},[kt,tn,ve]);const st=u.filter(ee=>ir(ee)&&ee.procs.some(Se=>Se.status==="asleep")).map(ee=>ee.id).join(" ");S.useEffect(()=>{const ee=new Set(st.split(" ").filter(Boolean));ve.some(Se=>ee.has(Se))&&Re(Se=>Se.filter(be=>!ee.has(be)))},[st,ve]),S.useEffect(()=>{const ee=ve.filter(Se=>Se!==kt).map(Se=>setTimeout(()=>Re(be=>be.filter(fe=>fe!==Se)),v8));return()=>{for(const Se of ee)clearTimeout(Se)}},[ve,kt]),S.useEffect(()=>{oe(ee=>ee.every(Se=>ve.includes(Se))?ee:ee.filter(Se=>ve.includes(Se)))},[ve]);const X=u.filter(ir).filter(ee=>ve.includes(ee.id)).map(ee=>({id:ee.worktree.id,port:ee.worktree.proxyPort,title:ee.worktree.title})),we=X.filter(ee=>{var Se;return(Se=u.find(be=>be.id===ee.id))==null?void 0:Se.procs.some(be=>be.status==="running")}).map(ee=>ee.id).join(" ");gt([we],()=>{for(const ee of we.split(" "))Z.current.has(ee)&&B0(le.current.get(ee))});const[Qe,he]=S.useState(null),[Oe,Mt]=S.useState(kt),an=S.useRef(null);Oe!==kt&&(Mt(kt),he(n8(an.current,kt,ee=>{var Se;return((Se=u.find(be=>be.id===ee))==null?void 0:Se.repoId)??null}))),S.useEffect(()=>{if(!Qe)return;const ee=setTimeout(()=>he(null),b8);return()=>clearTimeout(ee)},[Qe]);const vt=kt!==null&&Le.includes(kt),Dn=r8({previewId:kt,painted:vt,ready:tn,carry:Qe,mounted:ve}),Lt=Dn!==null&&Dn!==kt;S.useEffect(()=>{an.current=Dn});const[ln,Tt]=ho(_t.editorHeight,0,ee=>{const Se=Number(ee);return Number.isFinite(Se)&&Se>=120?Se:0}),[nn,Ut]=ho(_t.designHeight,0,ee=>{const Se=Number(ee);return Number.isFinite(Se)&&Se>0?Se:0}),[We,Gt]=ho(_t.designFull,!1,ee=>ee===null?void 0:ee==="1"),[pn,Kt]=ho(_t.editorFull,!1,ee=>ee===null?void 0:ee==="1"),[xn,hn]=ho(_t.termHeight,240,ee=>{const Se=Number(ee);return Number.isFinite(Se)&&Se>=140?Se:void 0}),mn=P(ee=>ee.termTall);gt([mn],()=>{const ee=t.current;mn&&ee&&hn(Math.max(xn,Math.round(ee.clientHeight/2)))});const gn=ee=>(Se,be)=>{const fe=be.parentElement,Pe=t.current;if(!fe||!Pe)return null;let rt=0;for(const bt of Array.from(Pe.querySelectorAll(":scope > .pane")))bt!==fe&&!bt.classList.contains("full")&&(rt+=bt.offsetHeight);const St=Math.max(Pe.clientHeight-rt-80,ee);return Math.min(Math.max(fe.getBoundingClientRect().bottom-Se.clientY,ee),St)},kn=ga(gn(120),ee=>Tt(Math.round(ee))),U=ga(gn(160),ee=>Ut(Math.round(ee))),de=ga(gn(140),ee=>hn(Math.round(ee))),Ae=P(ee=>{var Se,be;return p&&hr(p.worktree)?((be=(Se=ee.rows.find(fe=>{var Pe;return fe.repoId===p.worktree.repoId&&((Pe=fe.worktree)==null?void 0:Pe.kind)==="worktree"}))==null?void 0:Se.worktree)==null?void 0:be.title)??null:null}),et=nL({connected:g,heard:k,connectFailure:y,hasToken:w8,projectChord:xt("project"),title:(p==null?void 0:p.worktree.title)??null,needsSetup:!!O,busy:$,treeEmpty:ne,landsFrom:Ae});return f.jsxs("div",{className:"center-root",ref:n,children:[f.jsx("div",{className:Ke("center-area",me&&"drop-over"),style:{display:!(ae&&!j)&&(_&&pn||A&&We)?"none":void 0},children:f.jsxs("div",{className:"frames-wrap",children:[X.map(ee=>f.jsx("iframe",{ref:Se=>{Se?(le.current.set(ee.id,Se),xe.current.set(ee.id,new URL(ph(ee.id,ee.port,v)).origin)):(le.current.delete(ee.id),xe.current.delete(ee.id),Z.current.delete(ee.id),De.current.delete(ee.id))},onLoad:()=>{De.current.delete(ee.id)?Z.current.delete(ee.id):Z.current.add(ee.id)},src:ph(ee.id,ee.port,v),title:ee.title,style:{display:ee.id===Dn&&!ke&&!se&&!x&&!j?"block":"none"}},ee.id)),C?f.jsx(u8,{project:C}):f.jsxs(f.Fragment,{children:[se&&f.jsx(i8,{pending:se},se.id),E&&p&&!se&&f.jsx(s8,{active:p},p.worktree.id),ke&&!se&&!E&&f.jsx(p8,{repo:ke,onClose:q?void 0:()=>r({a:"close"})},`${ke.id}:${JSON.stringify(ke.config)}`),it&&!ke&&!se&&!Je&&f.jsx(t8,{row:it}),Je&&!ke&&!se&&f.jsx(fd,{placement:"centre",archived:Je},Je.id),!en&&!it&&!Je&&!ke&&!se&&!E&&V&&f.jsx(m8,{}),!en&&!it&&!Je&&!ke&&!se&&!E&&!V&&(et!==null?f.jsx(ds,{wide:!0,children:f.jsx("p",{className:"status-line",children:et})}):j?f.jsx(fd,{placement:"centre"}):Lt?null:p&&f.jsx(JF,{worktree:p,log:_e}))]})]})}),_&&f.jsx(CE,{editor:_,height:pn?"100%":ln>0?ln:"45%",full:pn,onToggleFull:()=>Kt(!pn),onDragStart:kn}),A&&h&&!Je&&f.jsx(bF,{worktreeId:h,height:We?"100%":nn>0?nn:"55%",full:We,onToggleFull:()=>Gt(!We),onDragStart:U},`design:${h}`),N&&h&&!Je&&f.jsx(ZF,{worktreeId:h,opened:R,height:xn,onDragStart:de},`term:${h}`),f.jsx(zE,{})]})}function _8({width:e}){const t=P(r=>r.layout.chat),n=nc();return f.jsx(fd,{placement:"dock",className:!t||n?"collapsed":void 0,width:e})}function E8(e,t){const n=[];return e&&(n.push(Wx(e)),n.push({id:"copy-url",label:"copy URL",onClick:()=>Bt(e)})),Mn([n,[{id:"reload",label:"reload preview",key:xt("reload"),onClick:t.reload}]])}const S8=520,Jp=8;function N8({winW:e,centre:t,leadRight:n,toolsLeft:r}){const s=t.right-t.left,a=Math.max(0,Math.min(S8,Math.floor(e*.4),s-2*Jp)),l=t.left+(s-a)/2,c=n+Jp,u=r-Jp-a,h=Math.max(Math.min(l,u),c);return{left:Math.round(h),width:a}}function T8({center:e}){const t=h2(),n=$x(e),r=S.useRef(null);k2(r);const[s,a]=Vw(),[l,c]=Vw(),u=N8({winW:t,centre:n,leadRight:a.right,toolsLeft:c.left}),h=ht(),p=ot(),g=Un(),k=Jt("bar"),y=us(),v=rc(),_=P(Y=>Y.zen)&&!v,E=P(Y=>Y.layout.changes),C=P(Y=>Y.layout.chat),x=nc(),N=P(Y=>Y.layout.design),M=P(Y=>{var ae;return((ae=Y.overlay)==null?void 0:ae.kind)==="keys"}),J=O8(),W=(y==null?void 0:y.worktree.id)??null,R=P(Y=>Y.archivedPage!==null),j=!!y&&_m(y)&&!R,A=P(Y=>Y.chatSide)==="left",D=!x&&f.jsx($t,{icon:"branch",label:"Changes panel",hint:xt("changes"),tone:"chrome",on:E,onClick:()=>h({a:"toggle-changes"})}),H=!x&&!v&&f.jsx($t,{icon:"chat",label:"Chat panel",hint:xt("composer"),tone:"chrome",on:C,onClick:()=>h({a:"toggle-chat"})});return f.jsxs("div",{className:"top-bar",ref:r,children:[_&&f.jsx("span",{className:"bar-zen-title",children:(y==null?void 0:y.worktree.title)??"Toyon"}),f.jsxs("span",{className:"bar-lead",ref:s,children:[A?H:D,f.jsx(j8,{}),J&&f.jsx(qd,{icon:"download","data-tip":"Install Toyon as an app (own window, dock icon)",onClick:()=>void J.prompt(),children:"install app"}),f.jsx(A8,{}),f.jsx(I8,{})]}),!v&&f.jsx(C8,{worktreeId:W,repoId:(y==null?void 0:y.repoId)??null,ready:j,left:u.left,width:u.width}),f.jsx("span",{className:"bar-grow"}),f.jsxs("span",{className:"bar-tools",ref:l,children:[f.jsx(R8,{}),f.jsx($t,{icon:"settings",label:"Settings & shortcuts",hint:xt("keys"),tone:"chrome",on:M,"aria-controls":"keys-help","aria-expanded":M,onClick:()=>h({a:"toggle",overlay:{kind:"keys"}}),...k.contextMenu(()=>H_(g.getState(),{sock:p,dispatch:h}))}),!x&&!v&&f.jsx($t,{icon:"palette",label:"Design system",hint:xt("design"),tone:"chrome",on:N,onClick:()=>h({a:"toggle-design"})}),A?D:H,!v&&f.jsx($t,{icon:"zen",className:"bar-zen",label:"Full-bleed preview",hint:xt("zen"),tone:"chrome",on:_,onClick:()=>h({a:"toggle-zen"})})]})]})}function j8(){const e=ht(),t=ot(),n=$a(),r=P(h=>h.repos),s=Jt("bar"),a=()=>Mn([[{id:"project",label:r.length>1?"switch project…":"open project…",key:xt("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?Hd(n,n.id,{sock:t,dispatch:e}):[]]),l=P(h=>{var p;return((p=h.overlay)==null?void 0:p.kind)==="projects"&&h.overlay.form==="pill"}),c=P(h=>h.heard),u=P(h=>h.newProject!==null);return f.jsxs("span",{className:"bar-project",children:[f.jsx(Be,{tone:"chrome",className:"bar-pill",on:l,...It(r.length>1?"Switch project":"Open a project",xt("project")),onClick:()=>e({a:"toggle",overlay:{kind:"projects",form:"pill"}}),...s.contextMenu(a),children:f.jsx("span",{className:"bar-project-name",children:u?"new project":(n==null?void 0:n.name)??(c?"open project":"")})}),l&&f.jsx(yg,{form:"pill"})]})}function C8({worktreeId:e,repoId:t,ready:n,left:r,width:s}){const a=At(e,"page").url,l=cE(a),c=ht(),u=P(v=>{var _;return((_=v.overlay)==null?void 0:_.kind)==="routes"}),h=()=>{n&&e&&t&&!u&&c({a:"open",overlay:{kind:"routes"}})};gt([e,n],()=>{u&&c({a:"close"})});const g=Jt("bar").contextMenu(()=>n?E8(a,{reload:()=>e&&Wt.post(e,{type:"reload"})}):[]),k=P(v=>v.picking),y=Tm();return f.jsxs("div",{className:"bar-center",style:{left:r,width:s},children:[f.jsx($t,{icon:"back",label:"Back",hint:xt("back"),disabled:!n,onClick:()=>e&&Wt.post(e,{type:"back"}),...g}),f.jsx($t,{icon:"forward",label:"Forward",hint:xt("forward"),disabled:!n,onClick:()=>e&&Wt.post(e,{type:"forward"}),...g}),f.jsx($t,{icon:"reload",label:"Reload preview",hint:xt("reload"),disabled:!n,onClick:()=>e&&Wt.post(e,{type:"reload"}),...g}),f.jsxs("span",{className:"bar-route",children:[f.jsx(Ro,{className:"bar-path",value:n?l:"",readOnly:!0,disabled:!n,placeholder:n?"/":"",onMouseDown:v=>{v.button===0&&v.preventDefault()},onClick:h,onFocus:h,spellCheck:!1,...It("Go to a page",xt("routes"))}),u&&n&&e&&t&&f.jsx(c5,{worktreeId:e,repoId:t,url:a},e)]}),f.jsx($t,{icon:"inspect",label:"Pick an element to open its code",hint:xt("inspect"),also:{text:"Add an element to chat",key:xt("pick")},on:k==="code",disabled:!n||!y,onClick:()=>y&&Hl(y,k,c,"code")})]})}function qd({icon:e,busy:t,children:n,...r}){return f.jsxs(Be,{disabled:t,...r,children:[!t&&f.jsx(Et,{name:e,className:"icon-inline"}),f.jsx("span",{className:Ke(t&&"live-text"),children:n})]})}function A8(){const e=P(u=>u.self),t=P(u=>u.rebuilt),n=P(u=>u.repos),r=ot(),s=P(u=>{var h;return((h=u.update)==null?void 0:h.restarting)!=null}),a=AE(e,n,t);if(!a||s)return null;const l=a.busy?"rebuilding":a.reload?"reload Toyon":a.build==="rebuild"?"rebuild Toyon":a.build??"restart Toyon",c=()=>{a.reload?window.location.reload():e&&(r==null||r.send(a.build?{t:"run-after-land",repoId:e.repoId}:{t:"restart-daemon"}))};return f.jsx(qd,{icon:"reload",busy:a.busy,onClick:c,...It(a.text,void 0,{detail:a.detail}),children:l})}function I8(){const e=P(s=>s.update),t=P(s=>s.managed.updates),n=ot(),r=r6(e);return!r||!t?null:f.jsx(qd,{icon:"reload",busy:r.busy,onClick:()=>{r.retry&&(n==null||n.send({t:"update-now"}))},...It(r.text),children:r.word})}function R8(){const e=ht(),t=P(a=>a.remote!==null&&a.frame==="desk"),n=P(a=>a.paired),r=P(a=>{var l;return((l=a.overlay)==null?void 0:l.kind)==="pair"});if(!t)return null;const s=()=>e({a:"toggle",overlay:{kind:"pair"}});return n?f.jsx($t,{icon:"phone",label:"Open on your phone",tone:"chrome",on:r,"aria-expanded":r,onClick:s}):f.jsx(qd,{icon:"phone","aria-expanded":r,onClick:s,...It("Scan a code with your phone to open this machine there, signed in"),children:"open on phone"})}function O8(){const[e,t]=S.useState(null);return S.useEffect(()=>{if(Ad())return;const n=s=>{s.preventDefault(),t(s)},r=()=>t(null);return window.addEventListener("beforeinstallprompt",n),window.addEventListener("appinstalled",r),()=>{window.removeEventListener("beforeinstallprompt",n),window.removeEventListener("appinstalled",r)}},[]),e}function $8(e,t,n){return t==="left"?n-e.left:e.right-n}const M8="input, textarea, [contenteditable], .monaco-editor, .xterm, iframe";function L8(){const e=Un(),t=ht(),n=ot(),r=nc(),s=Gs(),a=rc(),l=P(V=>V.zen)&&!a,c=Ai(),u=P(V=>V.layout.changes)&&!r,h=P(V=>V.layout.chat)&&!r&&!a&&!c,p=P(V=>V.chatSide),g=P(V=>V.railOpen),[k,y]=ho(_t.changesWidth,220,V=>V?ku(Number(V),220):void 0),[v,_]=ho(_t.chatWidth,380,V=>V?ku(Number(V),380):void 0),[E,C]=ho(_t.railWidth,280,V=>V?ku(Number(V),280):void 0),x=(V,O,F)=>{const ne=O.classList.contains("left")?"left":"right",$=ne==="left"?O.previousElementSibling:O.nextElementSibling;return $?ku($8($.getBoundingClientRect(),ne,V.clientX),F):null},N=ga((V,O)=>x(V,O,220),y),M=ga((V,O)=>x(V,O,380),_),J=ga((V,O)=>x(V,O,280),C),[W,R]=S.useState(null),A=Jt("app").contextMenu(()=>B_(e.getState(),{sock:n,dispatch:t})),D=f.jsx(I1,{width:k}),H=!a&&!c&&f.jsx(_8,{width:v}),Y=!r&&f.jsx(BE,{width:E}),ae=V=>!r&&g&&f.jsx("div",{className:`dock-resize ${V}`,onPointerDown:J}),me=p==="left",ye=me?{dock:H,open:h,drag:M}:{dock:D,open:u,drag:N},_e=me?{dock:D,open:u,drag:N}:{dock:H,open:h,drag:M};return f.jsxs("div",{className:Ke("app",l&&"zen"),"data-chat-side":p,"data-touch":s||void 0,"data-hover":!s||void 0,onContextMenu:V=>{V.defaultPrevented||V.target instanceof Element&&V.target.closest(M8)||A.onContextMenu(V)},children:[f.jsx(l1,{}),f.jsx(f1,{}),f.jsx(T8,{center:W}),f.jsxs("div",{className:"docks",children:[me&&Y,me&&ae("left"),ye.dock,ye.open&&f.jsx("div",{className:"dock-resize left",onPointerDown:ye.drag}),f.jsx(x8,{onRoot:R}),_e.open&&f.jsx("div",{className:"dock-resize right",onPointerDown:_e.drag}),_e.dock,!me&&ae("right"),!me&&Y]})]})}function P8(e){return e.altKey?"Alt":e.ctrlKey?"Control":e.metaKey?"Meta":null}function D8(e,t){return t==="Alt"?e.altKey:t==="Control"?e.ctrlKey:e.metaKey}const z8=200,F8={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};function B8(e,t=F8){let n=null,r=!1,s=null;const a=()=>{r||(r=!0,e(!0))},l=()=>{s!==null&&(t.clear(s),s=null)},c=()=>{l(),n=null,r&&(r=!1,e(!1))};return{press(u){const h=n!==null;n=P8(u),l(),n&&(h?a():s=t.set(()=>{s=null,a()},z8))},keyup(u){n&&u===n&&c()},mods(u){n&&!D8(u,n)&&c()},end:c}}function U8(e,t,n,r){if(!n)return null;const s=e.findIndex(u=>u.id===n);if(s>=0){const u=e[(s+r+e.length)%e.length];return u&&u.id!==n?{activate:u.id}:null}const a=t.findIndex(u=>u.id===n);if(a<0)return null;const l=t[a+r];if(l)return{activate:l.id};const c=e[e.length-1];return r<0&&c?{activate:c.id}:null}const H8=new Set(["design","chats"]),W8=new Set(["reload","back","forward"]),K8=new Set(["project","commands","keys","zen"]);function Z8(){const e=Un(),t=ot();S.useEffect(()=>{const n=B8(h=>e.dispatch({a:"rail-peek",on:h})),r=n.end,s=h=>{e.getState().railOpen||n.press(h)},a=h=>n.keyup(h.key),l=h=>n.mods(h),c=()=>{var k,y;const h=e.getState(),g=((y=(k=document.activeElement)==null?void 0:k.closest("[data-pane]"))==null?void 0:y.dataset.pane)??(h.layout.term?"terminal":h.editor?"editor":h.layout.design?"design":null);g==="terminal"?e.dispatch({a:"toggle-terminal"}):g==="editor"?e.dispatch({a:"close-editor"}):g==="design"&&e.dispatch({a:"toggle-design"})},u=h=>{var _,E,C,x;l(h),UN(h)&&!h.defaultPrevented&&h.preventDefault();const p=e.getState(),{dispatch:g}=e,k=N=>{const M=document.activeElement,J=!M||M===document.body||!!M.closest(".rail, .chat-input");g({a:"activate",id:N}),J&&g({a:"walked"})},y=J0(h,{guest:!!((_=document.activeElement)!=null&&_.closest(".xterm"))});if(!(p.zen&&!mo(p)&&!p.overlay&&!p.picking&&!(y&&BN.has(y.id))||(y==null?void 0:y.id)==="close"&&!Ad()||(E=document.activeElement)!=null&&E.closest(".monaco-editor")&&y&&H8.has(y.id))&&!(y&&qN(y.id,document.activeElement))&&!(y&&W8.has(y.id)&&!(bl(p)&&td(p)))){if(y){const N=h.defaultPrevented;if(h.preventDefault(),p.newProject&&!K8.has(y.id))return;switch(y.id){case"worktree":{const M=WN(y.digit,p.visible.length),J=M===null?void 0:p.visible[M];J&&k(J.id);break}case"wt-prev":case"wt-next":{const M=U8(p.visible,p.visibleDiscovered,p.activeId,y.id==="wt-next"?1:-1);M&&k(M.activate),s(h);break}case"wt-unseen-prev":case"wt-unseen-next":{const M=gm(p.visible,p.activeId,y.id==="wt-unseen-next"?1:-1);M&&k(M.activate),s(h);break}case"mark-unread":p.activeId&&!p.draft&&p.visible.some(M=>M.id===p.activeId)&&k1(t,g,p.activeId);break;case"wt-archive":{if(h.repeat||N)break;const M=p.draft||p.archivedPage?void 0:p.visible.find(J=>J.id===p.activeId);M&&Lm(t,g).archive(M);break}case"new":g({a:"open-draft"});break;case"project":g({a:"toggle",overlay:{kind:"projects",form:"center"}});break;case"quick-open":((C=p.overlay)==null?void 0:C.kind)==="quick-open"?g({a:"close"}):p.activeId&&g({a:"open",overlay:{kind:"quick-open"}});break;case"routes":((x=p.overlay)==null?void 0:x.kind)==="routes"?g({a:"close"}):td(p)&&g({a:"open",overlay:{kind:"routes"}});break;case"reload":case"back":case"forward":{const M=bl(p);M&&Wt.post(M,{type:y.id});break}case"pick":case"inspect":{const M=bl(p);M&&Hl(M,p.picking,g,y.id==="pick"?"chat":"code");break}case"search":p.activeId&&g({a:"toggle",overlay:{kind:"search"}});break;case"refs":p.activeRepoId&&g({a:"toggle",overlay:{kind:"refs"}});break;case"chats":p.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":!(p.zen&&!mo(p))&&!p.overlay&&c();break;case"changes":g(p.layout.changes&&(xa(p)==="changes"||$o(p)!==null)?{a:"toggle-changes"}:{a:"focus-changes",tab:"changes"});break;case"files":g(p.layout.changes&&xa(p)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"});break;case"panel-tab-prev":case"panel-tab-next":if(Id(p))break;g(p.layout.changes?{a:"focus-changes",tab:H$(p,y.id==="panel-tab-next"?1:-1)}:{a:"focus-changes"});break;case"composer":g(wx(p));break;case"rail":g(p.railOpen?{a:"toggle-rail"}:{a:"focus-rail"});break;case"keys":g({a:"toggle",overlay:{kind:"keys"}});break;case"terminal":g(p.layout.term?{a:"toggle-terminal"}:{a:"focus-terminal"});break;case"design":g({a:"toggle-design"});break;case"term-tab":{const M=p.rows.find(j=>j.id===p.activeId);if(!M)break;const J=go(p,p.activeId).termStream;if(M.login&&J===ls)break;const W=[po,...M.login?[ls]:[],...M.procs.map(j=>j.name)],R=W.indexOf(J);g({a:"term-stream",id:M.id,stream:W[(R+1)%W.length]??po});break}}}else if(h.key==="Escape")if(p.choosingFolder)t==null||t.send({t:"cancel-folder"}),g({a:"choosing-folder",v:!1});else if(p.overlay)g({a:"close",back:bx(p.overlay)});else if(p.newProject)p.newProject.phase==="editing"&&g({a:"close-new-project"});else if(p.picking){const N=bl(p);N&&Wt.post(N,{type:"pick-cancel"}),g({a:"set-picking",v:!1})}else p.archivedPage?g({a:"close-archived"}):p.activeImportId?g({a:"watch-import",id:null}):c()}};return window.addEventListener("keydown",u),window.addEventListener("keyup",a),window.addEventListener("pointermove",l),window.addEventListener("pointerdown",l),window.addEventListener("blur",r),()=>{window.removeEventListener("keydown",u),window.removeEventListener("keyup",a),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 s=e.getState();s.picking&&s.activeId&&Wt.post(s.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 q8=3,G8=2e3,V8=200,Y8=5e3;function Q8(){const e=Un(),t=ht(),n=ot(),r=Oa(),s=P(F=>F.activeRepoId),a=us(),l=Sm(),c=P(F=>F.connected),u=P(F=>F.daylight),h=P(F=>{var ne;return((ne=F.daylight)==null?void 0:ne.until)??0}),p=Ai(),g=P(F=>F.railOpen),k=P(F=>F.chatSide),y=P(F=>F.layouts),v=P(F=>F.lastActive),_=P(F=>F.discoveredOpen),E=P(F=>F.archivedOpen),C=P(F=>F.committedShut),x=P(F=>F.turnOpen),N=P(F=>F.treeOpen),M=Rd(),J=P(F=>F.previewTheme!==null),W=P(F=>F.openUrl),R=Lx();S.useEffect(()=>xh.install(window),[]);const j=S.useRef([]);S.useEffect(()=>{if(!n||!c||!r)return;const F=[r,...j.current.filter(ne=>ne!==r)];for(const ne of F.splice(q8))n.send({t:"unsubscribe",worktreeId:ne});j.current.includes(r)||n.send({t:"subscribe",worktreeId:r}),j.current=F},[r,c,n]),S.useEffect(()=>{if(!(!n||!c))for(const F of j.current)n.send({t:"subscribe",worktreeId:F})},[c,n]);const A=S.useRef(void 0);S.useEffect(()=>{if(!n||!c)return;let F;const ne=()=>{const ke=document.visibilityState==="visible"?r:null;n.send({t:"view",worktreeId:ke}),A.current=ke},$=()=>{clearTimeout(F),F=setTimeout(ne,V8)};A.current===void 0||A.current===r||document.visibilityState!=="visible"?ne():$();const q=()=>document.visibilityState==="visible"?$():ne();return document.addEventListener("visibilitychange",q),()=>{clearTimeout(F),document.removeEventListener("visibilitychange",q)}},[r,c,n]);const D=(p==null?void 0:p.id)??null;S.useEffect(()=>{if(!(!n||!c||!D))return n.send({t:"subscribe",worktreeId:D}),()=>n.send({t:"unsubscribe",worktreeId:D})},[D,c,n]),S.useEffect(()=>{const F=new Set(R.map($=>$.id)),ne=j.current.filter($=>!F.has($));if(ne.length!==0&&(j.current=j.current.filter($=>F.has($)),!(!n||!c)))for(const $ of ne)n.send({t:"unsubscribe",worktreeId:$})},[R,c,n]);const H=(p==null?void 0:p.title)??(l==null?void 0:l.name)??null;S.useEffect(()=>{document.title=H?`${H} · Toyon`:"Toyon"},[H]);const Y=!!(a!=null&&a.unseen),ae=P(F=>F.unreadHold!==null&&F.unreadHold===F.activeId);S.useEffect(()=>{if(!n||!r||!Y||ae)return;let F;const ne=()=>document.visibilityState==="visible"&&document.hasFocus(),$=()=>{clearTimeout(F),ne()&&(F=setTimeout(()=>{ne()&&n.send({t:"seen",worktreeId:r})},G8))},q=()=>clearTimeout(F);return $(),window.addEventListener("focus",$),window.addEventListener("blur",q),()=>{q(),window.removeEventListener("focus",$),window.removeEventListener("blur",q)}},[n,r,Y,ae]);const me=S.useRef(0);S.useEffect(()=>{if(!n||!c||!s)return;const F=()=>{Date.now()-me.current<Y8||(me.current=Date.now(),n.send({t:"refresh-git",repoId:s}))};return window.addEventListener("focus",F),()=>window.removeEventListener("focus",F)},[n,c,s]),S.useEffect(()=>{UE(M,{remember:!J}),Wt.broadcast(HE(M))},[M,J]),S.useEffect(()=>yF(F=>t({a:"system-dark",v:F})),[t]);const ye=S.useCallback(()=>{n==null||n.send({t:"zone",tz:Intl.DateTimeFormat().resolvedOptions().timeZone})},[n]);S.useEffect(()=>{if(!c)return;ye();const F=()=>{document.visibilityState==="visible"&&ye()};return document.addEventListener("visibilitychange",F),()=>document.removeEventListener("visibilitychange",F)},[c,ye]),S.useEffect(()=>{if(!c||h<=Date.now())return;const F=setTimeout(ye,h-Date.now()+1e3);return()=>clearTimeout(F)},[c,h,ye]),S.useEffect(()=>{u&&u.until>0&&kF(u)},[u]),S.useEffect(()=>{if(r)try{localStorage.setItem(_t.active,r)}catch{}},[r]),S.useEffect(()=>{if(s)try{localStorage.setItem(_t.repo,s)}catch{}},[s]),S.useEffect(()=>{try{localStorage.setItem(_t.rail,g?"1":"0")}catch{}},[g]),S.useEffect(()=>{try{localStorage.setItem(_t.chatSide,k)}catch{}},[k]),S.useEffect(()=>{try{localStorage.setItem(_t.layouts,JSON.stringify(y))}catch{}},[y]),S.useEffect(()=>{try{localStorage.setItem(_t.lastActive,JSON.stringify(v))}catch{}},[v]),S.useEffect(()=>{try{localStorage.setItem(_t.discoveredOpen,JSON.stringify(_))}catch{}},[_]),S.useEffect(()=>{try{localStorage.setItem(_t.archivedOpen,JSON.stringify(E))}catch{}},[E]),S.useEffect(()=>{try{localStorage.setItem(_t.committedShut,JSON.stringify(C))}catch{}},[C]),S.useEffect(()=>{try{localStorage.setItem(_t.turnOpen,JSON.stringify(x))}catch{}},[x]),S.useEffect(()=>{try{localStorage.setItem(_t.treeOpen,JSON.stringify(N))}catch{}},[N]),Z8(),RM();const _e=S.useRef(null);S.useEffect(()=>{!W||_e.current===W||(_e.current=W,window.open(W,"_blank"),t({a:"opened-url"}))},[W,t]);const V=S.useRef(null);return gt([r],()=>{var Re,le,xe,Le;const F=V.current;if(V.current=r,!F||!r||F===r)return;const ne=e.getState(),$=R.find(oe=>oe.id===F),q=R.find(oe=>oe.id===r),ke=(le=(Re=$==null?void 0:$.worktree)==null?void 0:Re.variant)==null?void 0:le.group;if(!ke||((Le=(xe=q==null?void 0:q.worktree)==null?void 0:xe.variant)==null?void 0:Le.group)!==ke)return;const se=oe=>{var Z;try{const De=(Z=ne.local[oe])==null?void 0:Z.page.url;return De?new URL(De).pathname+new URL(De).search:"/"}catch{return"/"}},ve=se(F);ve!==se(r)&&Wt.post(r,{type:"navigate",path:ve})}),P(F=>F.frame)==="phone"?f.jsx(fF,{}):f.jsx(L8,{})}const X8=640,J8=1e3,XE=`(max-width: ${X8}px), ((hover: none) and (max-width: ${J8}px))`,JE="(hover: none)",e9=()=>{var e;return(e=window.matchMedia)!=null&&e.call(window,XE).matches?"phone":"desk"},t9=()=>{var e;return((e=window.matchMedia)==null?void 0:e.call(window,JE).matches)??!1};function n9(e){const t=(s,a)=>{var u;const l=(u=window.matchMedia)==null?void 0:u.call(window,s);if(!l)return()=>{};const c=h=>a(h.matches);return l.addEventListener("change",c),()=>l.removeEventListener("change",c)},n=t(XE,s=>e.dispatch({a:"frame",v:s?"phone":"desk"})),r=t(JE,s=>e.dispatch({a:"touch",v:s}));return()=>{n(),r()}}const Yh="toyonDepth";function U0(e){return e.frame!=="phone"||!e.heard?null:e.screen!=="home"&&(fn(e,e.activeId)!==null||$o(e)!==null)?e.editor?2:1:0}const eh=e=>{const t=e&&typeof e=="object"?e[Yh]:void 0;return typeof t=="number"?t:null};function r9(e,t=window){const n=t.history;let r=eh(n.state)??0;eh(n.state)===null&&n.replaceState({[Yh]:0},"");const s=()=>{const c=U0(e.getState());if(!(c===null||c===r)){if(c>r)for(let u=r+1;u<=c;u++)n.pushState({[Yh]:u},"");else n.go(c-r);r=c}},a=c=>{r=eh(c.state)??0;const u=e.getState(),h=U0(u);h===null||h===r||(h>r?e.dispatch(r===0?{a:"screen",to:"home"}:{a:"screen",to:u.screen}):h===0&&u.activeId&&e.dispatch({a:"screen",to:"chat"}),s())};t.addEventListener("popstate",a);const l=e.subscribe(s);return s(),()=>{t.removeEventListener("popstate",a),l()}}const Cu=new Map,o9={on(e,t){let n=Cu.get(e);return n||(n=new Set,Cu.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Cu.delete(e)}},deliver(e){for(const t of Cu.get(CN(e.worktreeId,e.stream))??[])t(e)}};window.__toyonShell=!0;window.top!==window&&(document.documentElement.dataset.framed="");f2();const eS=pF();UE(eS);function as(e,t){try{return e.getItem(t)}catch{return null}}function s9(){const e={};try{const t=JSON.parse(as(localStorage,_t.layouts)??"{}");if(!t||typeof t!="object")return e;for(const[n,r]of Object.entries(t))O$(r)&&(e[n]=r)}catch{}return e}function i9(){const e={};try{const t=JSON.parse(as(localStorage,_t.lastActive)??"{}");if(!t||typeof t!="object")return e;for(const[n,r]of Object.entries(t))typeof r=="string"&&r&&(e[n]=r)}catch{}return e}function Au(e){const t={};try{const n=JSON.parse(as(localStorage,e)??"{}");if(!n||typeof n!="object")return t;for(const[r,s]of Object.entries(n))typeof s=="boolean"&&(t[r]=s)}catch{}return t}function a9(){const e={};try{const t=JSON.parse(as(localStorage,_t.treeOpen)??"{}");if(!t||typeof t!="object")return e;for(const[n,r]of Object.entries(t))Array.isArray(r)&&r.every(s=>typeof s=="string")&&r.length>0&&(e[n]=r)}catch{}return e}const l9=400,c9=2e3;function u9(){const e=new Map,t=new Map,n=tS(),r=a=>{var c,u;clearTimeout((c=t.get(a))==null?void 0:c.timer),t.delete(a);const l=or.getState().local[a];!l||((u=l.mark)==null?void 0:u.by)==="walk"||(e.get(a)??"")!==l.draft&&(e.set(a,l.draft),Us.send({t:"set-draft",boxId:a,text:l.draft,clientId:or.getState().clientId}))},s=()=>{for(const a of[...t.keys()])r(a)};return or.subscribe(()=>{var a,l;for(const[c,u]of Object.entries(or.getState().local)){if(n.another(c,u.sent)&&(clearTimeout((a=t.get(c))==null?void 0:a.timer),t.delete(c),e.set(c,"")),((l=u.mark)==null?void 0:l.by)==="walk"||(e.get(c)??"")===u.draft)continue;if(!u.draft){r(c);continue}const h=t.get(c);if((h==null?void 0:h.text)===u.draft)continue;clearTimeout(h==null?void 0:h.timer);const p=(h==null?void 0:h.since)??Date.now(),g=Math.max(0,Math.min(l9,p+c9-Date.now()));t.set(c,{text:u.draft,timer:setTimeout(r,g,c),since:p})}}),window.addEventListener("focusout",s),window.addEventListener("pagehide",s),{hello(a){e.clear();for(const[l,c]of Object.entries(a))e.set(l,c)},heard(a,l){return t.has(a)?!1:(e.set(a,l),!0)}}}function tS(){const e=new Map;return{another(t,n=0){return(e.get(t)??0)===n?!1:(e.set(t,n),!0)}}}function d9(){const e=new Map,t=new Map,n=tS();return or.subscribe(()=>{for(const[r,s]of Object.entries(or.getState().local)){if(n.another(r,s.sent)&&t.set(r,"[]"),e.get(r)===s.attachments)continue;e.set(r,s.attachments);const a=C$(s.attachments),l=JSON.stringify(a);(t.get(r)??"[]")!==l&&(t.set(r,l),Us.send({t:"set-attachments",boxId:r,items:a,clientId:or.getState().clientId}))}}),{hello(r){t.clear(),e.clear();for(const[s,a]of Object.entries(r))t.set(s,JSON.stringify(a))},heard(r,s){t.set(r,JSON.stringify(s))}}}function f9(){const e=as(sessionStorage,_t.client);if(e)return e;const t=Math.random().toString(36).slice(2,10);try{sessionStorage.setItem(_t.client,t)}catch{}return t}const or=c2(M$({cached:eS,systemDark:hF(),daylight:gF(),storedActive:as(localStorage,_t.active),storedRepo:as(localStorage,_t.repo),storedRailOpen:as(localStorage,_t.rail)==="1",storedChatSide:as(localStorage,_t.chatSide)==="right"?"right":"left",storedLayouts:s9(),storedLastActive:i9(),storedDiscoveredOpen:Au(_t.discoveredOpen),storedArchivedOpen:Au(_t.archivedOpen),storedCommittedShut:Au(_t.committedShut),storedTurnOpen:Au(_t.turnOpen),storedTreeOpen:a9(),clientId:f9(),frame:e9(),touch:t9()}));n9(or);r9(or);let Fu=null;const Us=new J2(e=>{if(e.t==="hello"){if(Fu!==null&&(e.version!==Fu||e.protocol!==dh)){Us.dispose(),window.location.reload();return}if(e.protocol!==dh){or.dispatch({a:"incompatible"}),Us.dispose();return}Fu=e.version;const t=new Set(Us.sentWhileDown());if(t.size){const n=r=>Object.fromEntries(Object.entries(r).filter(([s])=>!t.has(s)));e.drafts=n(e.drafts),e.attachments=n(e.attachments)}H0.hello(e.drafts),Qh.hello(e.attachments)}if(e.t==="attachments"&&e.clientId!==or.getState().clientId&&Qh.heard(e.boxId,e.items),!(e.t==="draft"&&e.clientId!==or.getState().clientId&&!H0.heard(e.boxId,e.text))){if(KR(e)){o9.deliver(e);return}if(ZR(e)){if(e.t==="file-written"&&W2(e))return;wg.receive(e);return}if(e.t==="loose-written"){R5(e);return}if(MD(e)){zD(or,Us,e);return}if(e.t==="open-refused"){DD(or,e);return}or.dispatch({a:"server",msg:e})}},(e,t)=>or.dispatch({a:"connected",v:e,failure:t})),wg=new A5({store:or,send:e=>Us.send(e),timers:{set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)},win:window});wg.start();window.addEventListener("vite:preloadError",M5);const H0=u9(),Qh=d9(),p9=(window.toyonBoot??Promise.resolve(null)).then(e=>{const t=e;t&&typeof t=="object"&&t.t==="hello"&&t.protocol===dh&&(Fu??(Fu=t.version),Qh.hello(t.attachments),or.dispatch({a:"server",msg:t}))});p9.then(()=>i$.createRoot(document.getElementById("root")).render(f.jsx(e$.StrictMode,{children:f.jsx(mg,{children:f.jsx(u2,{store:or,sock:Us,files:wg,children:f.jsx(Q8,{})})})})));"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{});export{Vs as F,Uh as _,Ur as a,hm as b,k9 as c,eb as d,o9 as e,CN as f,HL as g,qO as h,Fm as i,f as j,m9 as k,J0 as m,g9 as p,S as r,FO as s,Jl as t,gt as u,_w as w};
|