toyon 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/README.md +9 -12
  2. package/dist/bridge.js +1 -1
  3. package/dist/cli.js +1 -1
  4. package/dist/daemon.js +1745 -787
  5. package/dist/shell/assets/{Editor-CgKsVXHS.js → Editor-DR-GTFmf.js} +4 -4
  6. package/dist/shell/assets/{XTerm-CMRoVDAh.js → XTerm-B3kT_naP.js} +12 -12
  7. package/dist/shell/assets/{cssMode-Dg15kh0f.js → cssMode-CB4CczRa.js} +1 -1
  8. package/dist/shell/assets/{freemarker2-CU21n-BA.js → freemarker2-Wjq3dVyB.js} +1 -1
  9. package/dist/shell/assets/{grammar-DGBFIuP2.js → grammar-yCr7BdNP.js} +1 -1
  10. package/dist/shell/assets/{handlebars-DVAbWe34.js → handlebars-Bjvi6pTu.js} +1 -1
  11. package/dist/shell/assets/{html-BkxU7kNX.js → html-iB2mKeN2.js} +1 -1
  12. package/dist/shell/assets/{htmlMode-Brl4kLPo.js → htmlMode-DtZVhckD.js} +1 -1
  13. package/dist/shell/assets/index-DVg10dTN.js +237 -0
  14. package/dist/shell/assets/index-wt4cLIYn.css +1 -0
  15. package/dist/shell/assets/{javascript-DoIo3Pg8.js → javascript-BpuIkItm.js} +1 -1
  16. package/dist/shell/assets/{jsonMode-B9qq6lCy.js → jsonMode-QCLe5ypz.js} +1 -1
  17. package/dist/shell/assets/{liquid-Cn1aqWby.js → liquid-CQI6mzhA.js} +1 -1
  18. package/dist/shell/assets/{lspLanguageFeatures-C5ez8E_9.js → lspLanguageFeatures-DqXzGsHQ.js} +1 -1
  19. package/dist/shell/assets/{mdx-1MuVz0xd.js → mdx-D2Unh-By.js} +1 -1
  20. package/dist/shell/assets/{python-DFhVdcGk.js → python-LLSqiJ4D.js} +1 -1
  21. package/dist/shell/assets/{razor-BitqUXpg.js → razor-CJ2qsTB8.js} +1 -1
  22. package/dist/shell/assets/{tsMode-loK_YDOL.js → tsMode-CwjjHUH5.js} +1 -1
  23. package/dist/shell/assets/{xml-Cc4ljERX.js → xml-BzqCyEOW.js} +1 -1
  24. package/dist/shell/assets/{yaml-0hpVC8PU.js → yaml-N1Bfi3ds.js} +1 -1
  25. package/dist/shell/index.html +3 -3
  26. package/package.json +1 -1
  27. package/dist/shell/assets/index-DUmxVabc.css +0 -1
  28. package/dist/shell/assets/index-WHwsRrlj.js +0 -232
@@ -0,0 +1,237 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Editor-DR-GTFmf.js","assets/grammar-yCr7BdNP.js","assets/Editor-CB2SckMT.css","assets/XTerm-B3kT_naP.js","assets/XTerm-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
2
+ var Y_=Object.defineProperty;var Q_=(e,t,n)=>t in e?Y_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var mt=(e,t,n)=>Q_(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)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(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();function Yv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Sf={exports:{}},Ca={},Nf={exports:{}},wt={};/**
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 uk;function X_(){if(uk)return wt;uk=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),p=Symbol.iterator;function h(O){return O===null||typeof O!="object"?null:(O=p&&O[p]||O["@@iterator"],typeof O=="function"?O:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,_={};function E(O,ee,D){this.props=O,this.context=ee,this.refs=_,this.updater=D||v}E.prototype.isReactComponent={},E.prototype.setState=function(O,ee){if(typeof O!="object"&&typeof O!="function"&&O!=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,O,ee,"setState")},E.prototype.forceUpdate=function(O){this.updater.enqueueForceUpdate(this,O,"forceUpdate")};function j(){}j.prototype=E.prototype;function x(O,ee,D){this.props=O,this.context=ee,this.refs=_,this.updater=D||v}var H=x.prototype=new j;H.constructor=x,b(H,E.prototype),H.isPureReactComponent=!0;var B=Array.isArray,re=Object.prototype.hasOwnProperty,F={current:null},C={key:!0,ref:!0,__self:!0,__source:!0};function L(O,ee,D){var q,Te={},Ne=null,je=null;if(ee!=null)for(q in ee.ref!==void 0&&(je=ee.ref),ee.key!==void 0&&(Ne=""+ee.key),ee)re.call(ee,q)&&!C.hasOwnProperty(q)&&(Te[q]=ee[q]);var Re=arguments.length-2;if(Re===1)Te.children=D;else if(1<Re){for(var Ze=Array(Re),st=0;st<Re;st++)Ze[st]=arguments[st+2];Te.children=Ze}if(O&&O.defaultProps)for(q in Re=O.defaultProps,Re)Te[q]===void 0&&(Te[q]=Re[q]);return{$$typeof:e,type:O,key:Ne,ref:je,props:Te,_owner:F.current}}function I(O,ee){return{$$typeof:e,type:O.type,key:ee,ref:O.ref,props:O.props,_owner:O._owner}}function Z(O){return typeof O=="object"&&O!==null&&O.$$typeof===e}function V(O){var ee={"=":"=0",":":"=2"};return"$"+O.replace(/[=:]/g,function(D){return ee[D]})}var K=/\/+/g;function le(O,ee){return typeof O=="object"&&O!==null&&O.key!=null?V(""+O.key):ee.toString(36)}function de(O,ee,D,q,Te){var Ne=typeof O;(Ne==="undefined"||Ne==="boolean")&&(O=null);var je=!1;if(O===null)je=!0;else switch(Ne){case"string":case"number":je=!0;break;case"object":switch(O.$$typeof){case e:case t:je=!0}}if(je)return je=O,Te=Te(je),O=q===""?"."+le(je,0):q,B(Te)?(D="",O!=null&&(D=O.replace(K,"$&/")+"/"),de(Te,ee,D,"",function(st){return st})):Te!=null&&(Z(Te)&&(Te=I(Te,D+(!Te.key||je&&je.key===Te.key?"":(""+Te.key).replace(K,"$&/")+"/")+O)),ee.push(Te)),1;if(je=0,q=q===""?".":q+":",B(O))for(var Re=0;Re<O.length;Re++){Ne=O[Re];var Ze=q+le(Ne,Re);je+=de(Ne,ee,D,Ze,Te)}else if(Ze=h(O),typeof Ze=="function")for(O=Ze.call(O),Re=0;!(Ne=O.next()).done;)Ne=Ne.value,Ze=q+le(Ne,Re++),je+=de(Ne,ee,D,Ze,Te);else if(Ne==="object")throw ee=String(O),Error("Objects are not valid as a React child (found: "+(ee==="[object Object]"?"object with keys {"+Object.keys(O).join(", ")+"}":ee)+"). If you meant to render a collection of children, use an array instead.");return je}function Q(O,ee,D){if(O==null)return O;var q=[],Te=0;return de(O,q,"","",function(Ne){return ee.call(D,Ne,Te++)}),q}function ce(O){if(O._status===-1){var ee=O._result;ee=ee(),ee.then(function(D){(O._status===0||O._status===-1)&&(O._status=1,O._result=D)},function(D){(O._status===0||O._status===-1)&&(O._status=2,O._result=D)}),O._status===-1&&(O._status=0,O._result=ee)}if(O._status===1)return O._result.default;throw O._result}var R={current:null},M={transition:null},G={ReactCurrentDispatcher:R,ReactCurrentBatchConfig:M,ReactCurrentOwner:F};function ne(){throw Error("act(...) is not supported in production builds of React.")}return wt.Children={map:Q,forEach:function(O,ee,D){Q(O,function(){ee.apply(this,arguments)},D)},count:function(O){var ee=0;return Q(O,function(){ee++}),ee},toArray:function(O){return Q(O,function(ee){return ee})||[]},only:function(O){if(!Z(O))throw Error("React.Children.only expected to receive a single React element child.");return O}},wt.Component=E,wt.Fragment=n,wt.Profiler=i,wt.PureComponent=x,wt.StrictMode=r,wt.Suspense=d,wt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=G,wt.act=ne,wt.cloneElement=function(O,ee,D){if(O==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+O+".");var q=b({},O.props),Te=O.key,Ne=O.ref,je=O._owner;if(ee!=null){if(ee.ref!==void 0&&(Ne=ee.ref,je=F.current),ee.key!==void 0&&(Te=""+ee.key),O.type&&O.type.defaultProps)var Re=O.type.defaultProps;for(Ze in ee)re.call(ee,Ze)&&!C.hasOwnProperty(Ze)&&(q[Ze]=ee[Ze]===void 0&&Re!==void 0?Re[Ze]:ee[Ze])}var Ze=arguments.length-2;if(Ze===1)q.children=D;else if(1<Ze){Re=Array(Ze);for(var st=0;st<Ze;st++)Re[st]=arguments[st+2];q.children=Re}return{$$typeof:e,type:O.type,key:Te,ref:Ne,props:q,_owner:je}},wt.createContext=function(O){return O={$$typeof:l,_currentValue:O,_currentValue2:O,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},O.Provider={$$typeof:a,_context:O},O.Consumer=O},wt.createElement=L,wt.createFactory=function(O){var ee=L.bind(null,O);return ee.type=O,ee},wt.createRef=function(){return{current:null}},wt.forwardRef=function(O){return{$$typeof:c,render:O}},wt.isValidElement=Z,wt.lazy=function(O){return{$$typeof:k,_payload:{_status:-1,_result:O},_init:ce}},wt.memo=function(O,ee){return{$$typeof:g,type:O,compare:ee===void 0?null:ee}},wt.startTransition=function(O){var ee=M.transition;M.transition={};try{O()}finally{M.transition=ee}},wt.unstable_act=ne,wt.useCallback=function(O,ee){return R.current.useCallback(O,ee)},wt.useContext=function(O){return R.current.useContext(O)},wt.useDebugValue=function(){},wt.useDeferredValue=function(O){return R.current.useDeferredValue(O)},wt.useEffect=function(O,ee){return R.current.useEffect(O,ee)},wt.useId=function(){return R.current.useId()},wt.useImperativeHandle=function(O,ee,D){return R.current.useImperativeHandle(O,ee,D)},wt.useInsertionEffect=function(O,ee){return R.current.useInsertionEffect(O,ee)},wt.useLayoutEffect=function(O,ee){return R.current.useLayoutEffect(O,ee)},wt.useMemo=function(O,ee){return R.current.useMemo(O,ee)},wt.useReducer=function(O,ee,D){return R.current.useReducer(O,ee,D)},wt.useRef=function(O){return R.current.useRef(O)},wt.useState=function(O){return R.current.useState(O)},wt.useSyncExternalStore=function(O,ee,D){return R.current.useSyncExternalStore(O,ee,D)},wt.useTransition=function(){return R.current.useTransition()},wt.version="18.3.1",wt}var dk;function Vp(){return dk||(dk=1,Nf.exports=X_()),Nf.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 fk;function J_(){if(fk)return Ca;fk=1;var e=Vp(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function l(c,d,g){var k,p={},h=null,v=null;g!==void 0&&(h=""+g),d.key!==void 0&&(h=""+d.key),d.ref!==void 0&&(v=d.ref);for(k in d)r.call(d,k)&&!a.hasOwnProperty(k)&&(p[k]=d[k]);if(c&&c.defaultProps)for(k in d=c.defaultProps,d)p[k]===void 0&&(p[k]=d[k]);return{$$typeof:t,type:c,key:h,ref:v,props:p,_owner:i.current}}return Ca.Fragment=n,Ca.jsx=l,Ca.jsxs=l,Ca}var pk;function eE(){return pk||(pk=1,Sf.exports=J_()),Sf.exports}var f=eE();const tE=new Set(["edit","delete","move","execute"]),nE=new Set(["Edit","Write","MultiEdit","NotebookEdit","Bash"]);function rE(e){return e.kind?tE.has(e.kind):nE.has(e.name)}const oE=["read","edit","delete","move","search","execute","fetch"];function Qv(e){return oE.includes(e??"")}function Xv(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 hl=[{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"}],dp="auto";function iE(e){return e.branch.startsWith("toyon/")}const to="shell",Ko="login";function sE(e,t){return`${e}/${t}`}function Jv(e){return e.find(t=>t.id==="default")}function aE(e){const t=Jv(e);if(t!=null&&t.description)return e.find(n=>n!==t&&n.name===t.description)}function Mn(e){return e.worktree!==void 0}function yu(e){return e.kind==="main"}function Hs(e){return e.kind==="spare"}function Yn(e){return Hs(e)||yu(e)}function ew(e){return e.kind==="worktree"}function tw(e){return e.kind==="worktree"&&iE(e)}function Cs(e){var t;return e.kind==="worktree"&&((t=e.from)==null?void 0:t.kind)!=="pr"}function Pc(e){return e.kind==="worktree"}function qp(e){return!!e.branch&&!e.locked&&!(e.worktree&&Yn(e.worktree))}const Qa=e=>{var t;return e.promptedAt??((t=e.lastTurn)==null?void 0:t.at)??e.createdAt},lE=e=>Yn(e)?0:1,cE=e=>e.variant?`group:${e.variant.group}`:`row:${e.id}`;function uE(e){const t=[],n=new Map;for(const r of e){const i=r.worktree,a=cE(i),l=n.get(a);if(l){l.rows.push(r),l.at=Math.max(l.at,Qa(i));continue}const c={tier:lE(i),at:Qa(i),rows:[r]};t.push(c),n.set(a,c)}return t.sort((r,i)=>r.tier-i.tier||i.at-r.at),t.flatMap(r=>r.rows.length>1?r.rows.sort((i,a)=>{var l,c;return(((l=i.worktree.variant)==null?void 0:l.index)??0)-(((c=a.worktree.variant)==null?void 0:c.index)??0)}):r.rows)}const nw={image:6,paste:4,pick:8},dE={image:"image",paste:"paste",pick:"element"},fE={image:"Image",paste:"Pasted text"},rw=(e,t)=>`${fE[e]} ${t}`,Yp=e=>`at most ${nw[e]} ${dE[e]}s per message`,pE=(e,t)=>e.filter(n=>n.kind===t).length,hE=(e,t)=>Math.max(0,nw[t]-pE(e,t));function mE(e){const t={image:1,paste: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 gE(e,t){const n={...t};return e.map(r=>[r,n[r.kind]++])}const Lc=[{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:"mark-unread",key:"u",shift:!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"}],kE=new Set(["zen","close","back","forward"]);function ow(e,{guest:t=!1}={}){var r,i;if(e.altKey){if(e.metaKey||e.ctrlKey)return null;const a=Lc.find(l=>l.alt&&l.key===e.key&&!!l.shift===e.shiftKey);return a&&a.id!=="worktree"?{id:a.id}:null}if(!e.metaKey&&!e.ctrlKey){if(e.shiftKey||t)return null;const a=Lc.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 Lc){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||(i=a.aliases)!=null&&i.includes(n)))return{id:a.id}}return null}function iw(e){const t=Lc.find(n=>n.id===e);if(!t)throw new Error(`unknown chord ${e}`);return t}function yE(e,t){return e===t-1?"⌘9":e<8?`⌘${e+1}`:void 0}function vE(e,t){return t===0?null:e===9?t-1:e-1<t?e-1:null}function wE(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}const bE=["Find","Preview","Panels","Worktrees"],Wa={"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"},"mark-unread":{label:"mark worktree unread",section:"Worktrees"},project:{label:"open project",section:"Worktrees"},refs:{label:"open a branch or PR",section:"Worktrees"}},xE={ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Tab:"Tab"};function _E(e,t={}){var c;const n=iw(e),r=Wa[e],i=r.advertise&&t[r.advertise.when]?r.advertise.key:n.key;if(i===n.bareAlias)return i;const a=i==="1-9"?"1-9":xE[i]??i.toUpperCase(),l=i!==n.key&&i===((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 EE(e){return Object.keys(Wa).filter(t=>Wa[t].section===e&&!Wa[t].hidden)}const Xa={folder:{shared:".toyon/settings.json",local:".toyon/settings.local.json"},root:{shared:"toyon.json",local:"toyon.local.json"}};function SE(e){return e===Xa.folder.local||e===Xa.root.local}function NE(e){return SE(e)?"local":"shared"}function TE(e,t){return(Object.values(Xa).find(r=>r.shared===e||r.local===e)??Xa.folder)[t]}function CE(e,t,n){return e.replace("{id}",t).replace("{port}",String(n))}const jE=4401,AE=25e4;function IE(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 i=e.slice(0,n).map(a=>({mark:" ",value:a}));return i.push(...RE(e.slice(n,e.length-r),t.slice(n,t.length-r))),i.push(...e.slice(e.length-r).map(a=>({mark:" ",value:a}))),i}function RE(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)>AE)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 d=t.length-1;d>=0;d--)r[c*n+d]=e[c]===t[d]?(r[(c+1)*n+d+1]??0)+1:Math.max(r[(c+1)*n+d]??0,r[c*n+d+1]??0);const i=[];let a=0,l=0;for(;a<e.length&&l<t.length;)e[a]===t[l]?(i.push({mark:" ",value:e[a]}),a++,l++):(r[(a+1)*n+l]??0)>=(r[a*n+l+1]??0)?(i.push({mark:"-",value:e[a]}),a++):(i.push({mark:"+",value:t[l]}),l++);for(;a<e.length;)i.push({mark:"-",value:e[a++]});for(;l<t.length;)i.push({mark:"+",value:t[l++]});return i}const OE=/[\p{L}\p{N}_$]+|\s+|[^\s\p{L}\p{N}_$]/gu;function hk(e){return e.match(OE)??[]}const $E=.4;function ME(e,t){if(e===t)return null;const n=IE(hk(e),hk(t));let r=0;for(const i of n)i.mark===" "&&(r+=i.value.length);return r<$E*Math.max(e.length,t.length)?null:{before:mk(n,"-"),after:mk(n,"+")}}function mk(e,t){const n=[];for(const r of e){if(r.mark!==" "&&r.mark!==t)continue;const i=r.mark===t,a=n[n.length-1];a&&a.changed===i?a.text+=r.value:n.push({text:r.value,changed:i})}for(let r=1;r<n.length-1;r++){const i=n[r];i&&(i.changed?i.changed=i.text.trim()!=="":i.changed=i.text.length<=2)}return sw(n)}function gk(e){const t=[[]];for(const n of e){const r=n.text.split(`
19
+ `);for(const[i,a]of r.entries())i>0&&t.push([]),a&&t[t.length-1].push({text:a,changed:n.changed})}return t.map(sw)}function sw(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 PE=[{id:"merge",name:"here",description:"onto main in this checkout; nothing is pushed"},{id:"push",name:"here and push",description:"onto main here, then main is pushed to origin"},{id:"pr",name:"pull request",description:"the branch is pushed and a pull request opened on GitHub"}],LE=[{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"}],DE=[{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)"}],fp="merge",pp="merge";function Wi(e){var n,r,i;const t=((n=e.land)==null?void 0:n.route)??fp;return{land:t,automerge:t==="pr"&&((r=e.land)==null?void 0:r.automerge)===!0,...(i=e.land)!=null&&i.method?{merge:e.land.method}:{}}}function Kc(e,t="main"){const n={merge:"merge into",squash:"squash onto",rebase:"rebase onto"}[e.merge??pp];switch(e.land){case"merge":return`Commit and ${n} ${t} here`;case"push":return`Commit, ${n} ${t} 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 zE="https://toyon.cloud",FE=e=>`${zE}/#add=${encodeURIComponent(e)}`,hp=65,BE=5e6,UE=["image/png","image/jpeg","image/gif","image/webp"],kk=2576,Tf=5*1024*1024,HE=1200,ZE=10,WE=1e5;function KE(e){return e.t==="term-data"||e.t==="term-snapshot"||e.t==="term-exit"}function GE(e){return e.t==="file-read"||e.t==="file-written"}const VE=80;function qE(e){var r;const t=e.split(`
20
+ `),n=((r=t.find(i=>i.trim().length>0))==null?void 0:r.trim())??"";return{chars:e.length,lines:t.length,preview:n.slice(0,VE)}}function YE(e){return e.length>=HE||e.split(`
21
+ `).length>=ZE}function QE({startLine:e,endLine:t}){return e===t?`${e}`:`${e}-${t}`}function XE(e){return`${e.path.slice(e.path.lastIndexOf("/")+1)} (${QE(e)})`}const JE=/\u001B(?:\[[0-?]*[ -/]*[@-~]|\][^\u0007]*(?:\u0007|\u001B\\))/g;function eS(e){return e.replace(JE,"")}const aw="Projects";function tS(e){for(const t of e){const n=t.codePointAt(0)??0;if(n<32||n===127)return!0}return!1}function Ja(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":tS(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 nS=/^(?:https?|ssh|git|file):\/\/\S+$/i,lw=/^[\w.-]+@[\w.-]+:\S+$/;function rS(e){const t=e.trim();if(!nS.test(t)&&!lw.test(t))return null;const n=oS(t);return n&&!Ja(n)?{url:t,name:n}:null}function oS(e){var i;const t=((i=e.split(/[?#]/)[0])==null?void 0:i.replace(/\/+$/,""))??"";return((lw.test(t)?t.split(":")[1]??"":t).split("/").pop()??"").replace(/\.git$/i,"")}function cw(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function yk(e,t="|"){return e.map(n=>fw(n)).join(t)}function mp(e,t){return typeof t=="bigint"?t.toString():t}function vu(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function iS(e){return e==null}function Qp(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function sS(e,t){const n=e/t,r=Math.round(n),i=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function Or(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ei(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function aS(e){return JSON.stringify(e)}function lS(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const uw="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function el(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const cS=vu(()=>{var e;if(vo.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 tl(e){if(el(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(el(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function dw(e){return tl(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const uS=new Set(["string","number","symbol"]);function Ls(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Si(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function He(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 fw(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function dS(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const fS={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 pS(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=Ei(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]&&Or(l,c,n.shape[c])}return Or(this,"shape",l),l},checks:[]});return Si(e,a)}function hS(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=Ei(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 Or(this,"shape",l),l},checks:[]});return Si(e,a)}function mS(e,t){if(!tl(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 i=Ei(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return Or(this,"shape",a),a}});return Si(e,i)}function gS(e,t){if(!tl(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Ei(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Or(this,"shape",r),r}});return Si(e,n)}function kS(e,t){var r,i;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((i=e._zod.def.checks)!=null&&i.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=Ei(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Or(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Si(e,n)}function vk(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=Ei(t._zod.def,{get shape(){const d=t._zod.def.shape,g={...d};if(n)for(const k of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(d,k))throw new Error(`Unrecognized key: "${String(k)}"`);n[k]&&(g[k]=e?new e({type:"optional",innerType:d[k]}):d[k])}else for(const k of Reflect.ownKeys(d))g[k]=e?new e({type:"optional",innerType:d[k]}):d[k];return Or(this,"shape",g),g},checks:[]});return Si(t,c)}function yS(e,t,n){const r=Ei(t._zod.def,{get shape(){const i=t._zod.def.shape,a={...i};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:i[l]}))}else for(const l of Reflect.ownKeys(i))a[l]=new e({type:"nonoptional",innerType:i[l]});return Or(this,"shape",a),a}});return Si(t,r)}function js(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 vS(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 wu(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function ja(e){return typeof e=="string"?e:e==null?void 0:e.message}function wk(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Zs(e,t,n){var h,v,b,_,E,j,x,H,B,re;var r;const i=(v=(h=e.inst)==null?void 0:h._zod)==null?void 0:v.traits;i!=null&&i.has("$ZodType")&&(i.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const a=e.schema!==e.inst?(_=(b=e.schema)==null?void 0:b._zod.def)==null?void 0:_.error:void 0,l=e.message?e.message:ja((x=(j=(E=e.inst)==null?void 0:E._zod.def)==null?void 0:j.error)==null?void 0:x.call(j,e))??ja(a==null?void 0:a(e))??ja((H=t==null?void 0:t.error)==null?void 0:H.call(t,e))??ja((B=n.customError)==null?void 0:B.call(n,e))??ja((re=n.localeError)==null?void 0:re.call(n,e))??"Invalid input",{inst:c,schema:d,continue:g,input:k,...p}=e;return p.path??(p.path=[]),p.message=l,t!=null&&t.reportInput&&(p.input=k),p}const wS=/[\uD800-\uDBFF]/;function Xp(e){const t=e.length;if(!wS.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 Jp(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function bS(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 nl(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function xS(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):_S(e,n,r.value)}}function Ds(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function pw(e,t,n){return Ds(e,t,n,!1)}function _S(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Ds(this,t,n.bind(this))},set(r){Ds(this,t,r)}})}function ES(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let Cf,gi=!1;const SS={configurable:!0,get(){gi=!0}};function Ht(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&Cf!==e._zod){Cf=void 0;return}Cf=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,SS);const i=gi;gi=!1;try{const a=n(this);return gi?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:a}),gi=gi||i,a}catch(a){throw delete this[t],gi=gi||i,a}},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i})}})}function NS(e,t,n,r){const i=ES(e,t);i&&Object.defineProperty(i,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 TS="~constantCatch";function CS(e){const t=()=>e;return t[TS]=!0,t}var bk;const jf={value:void 0,enumerable:!1};let xk="captureStackTrace"in Error?Error:null;function jS(e){const t=xk;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return xk=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function fe(e,t,n,r){const i={};function a(h){this.def=h,this.constr=p,this.traits=new Set}a.prototype=i;const l=n,c=l&&new WeakSet;function d(h,v){if(!h._zod){jf.value=new a(v);try{Object.defineProperty(h,"_zod",jf)}finally{jf.value=void 0}}if(h._zod.traits.has(e))return;if(h._zod.traits.add(e),t(h,v),c){const _=Object.getPrototypeOf(h),E=h._zod.constr.prototype;let j=_;for(;j&&j!==E;)j=Object.getPrototypeOf(j);const x=j??_;c.has(x)||(c.add(x),xS(x,l))}const b=p.prototype;for(const _ in b)Object.prototype.hasOwnProperty.call(b,_)&&(_ in h||(h[_]=b[_].bind(h)))}const g=(r==null?void 0:r.Parent)??Object;class k extends g{}Object.defineProperty(k,"name",{value:e});function p(h){var E;const v=r!=null&&r.Parent?jS(k):this;d(v,h);const b=v._zod.deferred;if(b){for(const j of b)j();v._zod.deferred=void 0}const _=(E=globalThis.__zod_globalConfig)==null?void 0:E.postProcessor;return _&&_(v),v}return Object.defineProperty(p,"init",{value:d}),Object.defineProperty(p,Symbol.hasInstance,{value:h=>{var v,b;return r!=null&&r.Parent&&h instanceof r.Parent?!0:(b=(v=h==null?void 0:h._zod)==null?void 0:v.traits)==null?void 0:b.has(e)}}),Object.defineProperty(p,"name",{value:e}),p}class Os extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class hw extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(bk=globalThis).__zod_globalConfig??(bk.__zod_globalConfig={});const vo=globalThis.__zod_globalConfig;function Ni(e){return e&&Object.assign(vo,e),vo}function AS(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,mp,2)),e.message}function IS(e){this._zod.message=e}const RS={get:AS,set:IS,enumerable:!0,configurable:!0},Af={value:void 0,enumerable:!1},If={value:void 0,enumerable:!1},_k=new WeakSet([Object.prototype,Error.prototype]),mw=(e,t)=>{e.name="$ZodError",Af.value=e._zod,Object.defineProperty(e,"_zod",Af),If.value=t,Object.defineProperty(e,"issues",If),Af.value=void 0,If.value=void 0,Object.defineProperty(e,"message",RS);const n=Object.getPrototypeOf(e);_k.has(n)||(_k.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})}}))},gw=fe("$ZodError",mw),kw=fe("$ZodError",mw,void 0,{Parent:Error});function OS(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 $S(e,t=n=>n.message){const n={},r=[];for(const i of e.issues)i.path.length>0?OS(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function MS(e,t=n=>n.message){const n={_errors:[]},r=(i,a=[])=>{for(const l of i.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 d=n,g=0;for(;g<c.length;){const k=c[g],p=g===c.length-1;if(k==="_errors"){p&&d._errors.push(t(l)),g++;continue}Object.prototype.hasOwnProperty.call(d,k)||Object.defineProperty(d,k,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const h=d[k];p&&h._errors.push(t(l)),d=h,g++}}}};return r(e),n}function bu(e,t){return{callee:(t==null?void 0:t.callee)??e,Err:t==null?void 0:t.Err}}const eh=e=>{const t=(n,r,i,a)=>{const l=i?{...i,async:!1}:{async:!1},c=n._zod.run({value:r,issues:[]},l);if(c instanceof Promise)throw new Os;if(c.issues.length){const d=new((a==null?void 0:a.Err)??e)(c.issues.map(g=>Zs(g,l,Ni())));throw uw(d,(a==null?void 0:a.callee)??t),d}return c.value};return t},th=e=>{const t=async(n,r,i,a)=>{const l=i?{...i,async:!0}:{async:!0};let c=n._zod.run({value:r,issues:[]},l);if(c instanceof Promise&&(c=await c),c.issues.length){const d=new((a==null?void 0:a.Err)??e)(c.issues.map(g=>Zs(g,l,Ni())));throw uw(d,(a==null?void 0:a.callee)??t),d}return c.value};return t},xu=e=>(t,n,r)=>{const i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Os;return a.issues.length?{success:!1,error:new(e??gw)(a.issues.map(l=>Zs(l,i,Ni())))}:{success:!0,data:a.value}},PS=xu(kw),_u=e=>async(t,n,r)=>{const i=r?{...r,async:!0}:{async:!0};let a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(l=>Zs(l,i,Ni())))}:{success:!0,data:a.value}},LS=_u(kw),DS=e=>{const t=eh(e),n=(r,i,a,l)=>{const c=a?{...a,direction:"backward"}:{direction:"backward"};return t(r,i,c,bu(n,l))};return n},zS=e=>{const t=eh(e),n=(r,i,a,l)=>t(r,i,a,bu(n,l));return n},FS=e=>{const t=th(e),n=async(r,i,a,l)=>{const c=a?{...a,direction:"backward"}:{direction:"backward"};return await t(r,i,c,bu(n,l))};return n},BS=e=>{const t=th(e),n=async(r,i,a,l)=>await t(r,i,a,bu(n,l));return n},US=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return xu(e)(t,n,i)},HS=e=>(t,n,r)=>xu(e)(t,n,r),ZS=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return _u(e)(t,n,i)},WS=e=>async(t,n,r)=>_u(e)(t,n,r),KS=/^[cC][0-9a-z]{6,}$/,GS=/^[0-9a-z]+$/,VS=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,qS=/^[0-9a-vA-V]{20}$/,YS=/^[A-Za-z0-9]{27}$/,QS=/^[a-zA-Z0-9_-]{21}$/;function XS(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const JS=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,eN=/^([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})$/,Ek=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)$/,tN=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,nN="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function rN(){return new RegExp(nN,"u")}const oN=/^(?:(?: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])$/,iN=/^(([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}|:))$/,sN=/^((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])$/,aN=/^(([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])$/,lN=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,yw=/^[A-Za-z0-9_-]*$/,cN=/^https?$/,uN=/^\+[1-9]\d{6,14}$/,vw="(?:(?:\\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 dN(e){return new RegExp(`^${e}$`)}const fN=dN(vw);function gp(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 pN(e){return new RegExp(`^${gp(e)}$`)}function hN(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${gp({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${gp({precision:e.precision})}`:n;return new RegExp(`^${vw}T(?:${r})$`)}const mN=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}$`)},gN=/^-?\d+$/,kN=/^-?\d+(?:\.\d+)?$/,yN=/^(?:true|false)$/i,vN=/^[^A-Z]*$/,wN=/^[^a-z]*$/,$r=fe("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),nh=e=>{const t=e.value;return!iS(t)&&t.length!==void 0},Gc={number:"number",bigint:"bigint",object:"date"},ww=fe("$ZodCheckLessThan",(e,t)=>{$r.init(e,t);const n=Gc[typeof t.value];e._zod.onattach.push(r=>{const i=r._zod.bag,a=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<a&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Gc[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})}}),bw=fe("$ZodCheckGreaterThan",(e,t)=>{$r.init(e,t);const n=Gc[typeof t.value];e._zod.onattach.push(r=>{const i=r._zod.bag,a=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>a&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Gc[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})}}),bN=fe("$ZodCheckMultipleOf",(e,t)=>{$r.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):sS(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})}}),xN=fe("$ZodCheckNumberFormat",(e,t)=>{var l;$r.init(e,t),t.format=t.format||"float64";const n=(l=t.format)==null?void 0:l.includes("int"),r=n?"int":"number",[i,a]=fS[t.format];e._zod.onattach.push(c=>{const d=c._zod.bag;d.format=t.format,d.minimum=i,d.maximum=a,n&&(d.pattern=gN)}),e._zod.check=c=>{const d=c.value;if(n){if(!Number.isInteger(d)){c.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:d,inst:e});return}if(!Number.isSafeInteger(d)){d>0?c.issues.push({input:d,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:d,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}}d<i&&c.issues.push({origin:"number",input:d,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),d>a&&c.issues.push({origin:"number",input:d,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),_N=fe("$ZodCheckMaxLength",(e,t)=>{var n;$r.init(e,t),(n=e._zod.def).when??(n.when=nh),e._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const i=r.value,a=i.length;if((typeof i=="string"&&a>t.maximum?Xp(i):a)<=t.maximum)return;const c=Jp(i);r.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),EN=fe("$ZodCheckMinLength",(e,t)=>{var n;$r.init(e,t),(n=e._zod.def).when??(n.when=nh),e._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const i=r.value,a=i.length;if((typeof i=="string"&&a>=t.minimum&&a<t.minimum*2?Xp(i):a)>=t.minimum)return;const c=Jp(i);r.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),SN=fe("$ZodCheckLengthEquals",(e,t)=>{var n;$r.init(e,t),(n=e._zod.def).when??(n.when=nh),e._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=r=>{const i=r.value,a=i.length,l=typeof i=="string"&&a>=t.length&&a<=t.length*2?Xp(i):a;if(l===t.length)return;const c=Jp(i),d=l>t.length;r.issues.push({origin:c,...d?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Eu=fe("$ZodCheckStringFormat",(e,t)=>{var n,r;$r.init(e,t),e._zod.onattach.push(i=>{const a=i._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=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),NN=fe("$ZodCheckRegex",(e,t)=>{Eu.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})}}),TN=fe("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=vN),Eu.init(e,t)}),CN=fe("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=wN),Eu.init(e,t)}),jN=fe("$ZodCheckIncludes",(e,t)=>{$r.init(e,t);const n=Ls(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.onattach.push(i=>{const a=i._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),AN=fe("$ZodCheckStartsWith",(e,t)=>{$r.init(e,t);const n=new RegExp(`^${Ls(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.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})}}),IN=fe("$ZodCheckEndsWith",(e,t)=>{$r.init(e,t);const n=new RegExp(`.*${Ls(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.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})}}),RN=fe("$ZodCheckOverwrite",(e,t)=>{$r.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class ON{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(`
22
+ `).filter(l=>l),i=Math.min(...r.map(l=>l.length-l.trimStart().length)),a=r.map(l=>l.slice(i)).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(", ")}) {
23
+ ${n.join(`
24
+ `)}
25
+ };`)(...Object.values(this.closed))}}const $N={major:4,minor:5,patch:4},an=fe("$ZodType",(e,t)=>{var a;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=$N;const r=e._zod.def.checks,i=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r!=null&&r.length?[...r]:[];for(const l of i)for(const c of l._zod.onattach)c(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),(a=e._zod.deferred)==null||a.push(()=>{e._zod.run=e._zod.parse});else{const l=(d,g,k)=>{if(d.memo)return d;let p=js(d),h;for(const v of g){if(v._zod.def.when){if(vS(d)||!v._zod.def.when(d))continue}else if(p)continue;const b=d.issues.length,_=v._zod.check(d);if(_ instanceof Promise&&(k==null?void 0:k.async)===!1)throw new Os;if(h||_ instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await _,d.issues.length!==b&&(wk(d.issues,b,e),p||(p=js(d,b)))});else{if(d.issues.length===b)continue;wk(d.issues,b,e),p||(p=js(d,b))}}return h?h.then(()=>d):d},c=(d,g,k)=>{if(js(d))return d.aborted=!0,d;const p=l(g,i,k);if(p instanceof Promise){if(k.async===!1)throw new Os;return p.then(h=>e._zod.parse(h,k))}return e._zod.parse(p,k)};e._zod.run=(d,g)=>{if(g.skipChecks)return e._zod.parse(d,g);if(g.direction==="backward"){const p=e._zod.parse({value:d.value,issues:[]},{...g,skipChecks:!0});return p instanceof Promise?p.then(h=>c(h,d,g)):c(p,d,g)}const k=e._zod.parse(d,g);if(k instanceof Promise){if(g.async===!1)throw new Os;return k.then(p=>l(p,i,g))}return l(k,i,g)}}},{get"~standard"(){return pw(this,"~standard",xw(this))},set"~standard"(e){Ds(this,"~standard",e)}}),Sk=e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}};function xw(e){return{validate:t=>{try{return Sk(PS(e,t))}catch{return LS(e,t).then(Sk)}},vendor:"zod",version:1}}const rh=fe("$ZodString",(e,t)=>{var n;an.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??mN(e._zod.bag),e._zod.parse=(r,i)=>{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}}),ln=fe("$ZodStringFormat",(e,t)=>{Eu.init(e,t),rh.init(e,t)}),MN=fe("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=eN),ln.init(e,t)}),PN=fe("$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=Ek(r))}else t.pattern??(t.pattern=Ek());ln.init(e,t)}),LN=fe("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=tN),ln.init(e,t)}),_w=1,Ew=2;function DN(e,t){var n;if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===cN.source&&!/^https?:\/\//i.test(e))return _w;try{return new URL(e)}catch{return Ew}}const zN=/[\t\n\r]/g;function FN(e){return e.replace(zN,"")}function BN(e,t){return t.lastIndex=0,t.test(e.hostname)}function UN(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const HN=fe("$ZodURL",(e,t)=>{ln.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),i=DN(r,t);if(i===_w){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(i===Ew){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!BN(i,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&&!UN(i,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?i.href:FN(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),ZN=fe("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=rN()),ln.init(e,t)}),WN=fe("$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?QS:XS(t.length)),ln.init(e,t)}),KN=fe("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=KS),ln.init(e,t)}),GN=fe("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=GS),ln.init(e,t)}),VN=fe("$ZodULID",(e,t)=>{t.pattern??(t.pattern=VS),ln.init(e,t)}),qN=fe("$ZodXID",(e,t)=>{t.pattern??(t.pattern=qS),ln.init(e,t)}),YN=fe("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=YS),ln.init(e,t)}),QN=fe("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=hN(t)),ln.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(n=>{n._zod.bag.laxFormat=!0}))}),XN=fe("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=fN),ln.init(e,t)}),JN=fe("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=pN(t)),ln.init(e,t)}),eT=fe("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=JS),ln.init(e,t)}),tT=fe("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=oN),ln.init(e,t),e._zod.bag.format="ipv4"}),nT=/^[0-9a-fA-F:.]+$/;function Sw(e){if(!nT.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}const rT=fe("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=iN),ln.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{Sw(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),oT=fe("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=sN),ln.init(e,t)});function iT(e){const t=e.split("/");if(t.length!==2)return!1;const[n,r]=t;if(!r)return!1;const i=Number(r);return`${i}`!==r||i<0||i>128?!1:Sw(n)}const sT=fe("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=aN),ln.init(e,t),e._zod.check=n=>{iT(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Nw(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const aT=fe("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=lN),ln.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Nw(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function lT(e){if(!yw.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Nw(n)}const cT=fe("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=yw),ln.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{lT(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),uT=fe("$ZodE164",(e,t)=>{t.pattern??(t.pattern=uN),ln.init(e,t)});function dT(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const fT=fe("$ZodJWT",(e,t)=>{ln.init(e,t),e._zod.check=n=>{dT(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Tw=fe("$ZodNumber",(e,t)=>{an.init(e,t),e._zod.pattern=e._zod.bag.pattern??kN,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const a=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...a?{received:a}:{}}),n}}),pT=fe("$ZodNumberFormat",(e,t)=>{xN.init(e,t),Tw.init(e,t)}),hT=fe("$ZodBoolean",(e,t)=>{an.init(e,t),e._zod.pattern=yN,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),mT=fe("$ZodUnknown",(e,t)=>{an.init(e,t),e._zod.parse=n=>n}),gT=fe("$ZodNever",(e,t)=>{an.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Nk(e,t,n){e.issues.length&&t.issues.push(...wu(n,e.issues)),t.value[n]=e.value}const kT=fe("$ZodArray",(e,t)=>{an.init(e,t);const n=vo.memoizer;n==null||n.attach(e),e._zod.parse=(r,i)=>{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),i):Array(a.length);const l=[];for(let c=0;c<a.length;c++){const d=a[c],g=t.element._zod.run({value:d,issues:[]},i);g instanceof Promise?l.push(g.then(k=>Nk(k,r,c))):Nk(g,r,c)}return l.length?Promise.all(l).then(()=>r):r}});function Vc(e,t,n,r,i,a){const l=n in r,c=a==="optional";if(!(!l&&c&&i==="optional")){if(e.issues.length){if(i!==void 0&&c&&!l)return;t.issues.push(...wu(n,e.issues))}if(!l&&i===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 yT=[];function Cw(e){var l,c,d,g;const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:yT,i=r.length?[...t,...r]:t;for(const k of i)if(!((g=(d=(c=(l=e.shape)==null?void 0:l[k])==null?void 0:c._zod)==null?void 0:d.traits)!=null&&g.has("$ZodType")))throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);const a=dS(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function jw(e,t,n,r,i,a){const l=[],c=i.keySet,d=i.catchall._zod,g=d.def.type,k=d.optin,p=d.optout;for(const h in t){if(c.has(h))continue;if(h==="__proto__"){g==="never"&&l.push(h);continue}if(g==="never"){l.push(h);continue}const v=d.run({value:t[h],issues:[]},r);v instanceof Promise?e.push(v.then(b=>Vc(b,n,h,t,k,p))):Vc(v,n,h,t,k,p)}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 kp=new WeakMap,vT=fe("$ZodObject",(e,t)=>{an.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const d=t.shape;kp.set(t,d),Object.defineProperty(t,"shape",{get:()=>{const g={...d};return Object.defineProperty(t,"shape",{value:g}),kp.set(t,g),g}})}const r=vu(()=>Cw(t));Ht(e,"propValues",d=>{const g=d.def.shape,k={};for(const p in g){const h=g[p]._zod;if(h.values){Object.prototype.hasOwnProperty.call(k,p)||Or(k,p,new Set);for(const v of h.values)k[p].add(v);h.optin!==void 0&&k[p].add(void 0)}}return k});const i=el,a=t.catchall;let l;const c=vo.memoizer;c==null||c.attach(e),e._zod.parse=(d,g)=>{l??(l=r.value);const k=d.value;if(!i(k))return d.issues.push({expected:"object",code:"invalid_type",input:k,inst:e}),d;d.value=c?c.alloc(e,d,{},g):{};const p=[],h=l.shape;for(const v of l.allKeys){if(v==="__proto__")continue;const b=h[v],_=b._zod.optin,E=b._zod.optout,j=b._zod.run({value:k[v],issues:[]},g);j instanceof Promise?p.push(j.then(x=>Vc(x,d,v,k,_,E))):Vc(j,d,v,k,_,E)}return a?jw(p,k,d,g,r.value,e):p.length?Promise.all(p).then(()=>d):d}}),wT=fe("$ZodObjectJIT",(e,t)=>{vT.init(e,t);const n=e._zod.parse,r=vu(()=>Cw(t)),i=vo.memoizer,a=v=>{var re,F;const b=r.value,_=b.symbolKeys,E=new ON(["payload","ctx"],{shape:v,inst:e,memo:i,syms:_}),j=C=>`shape[${C}]._zod.run({ value: input[${C}], issues: [] }, ctx)`,x=(C,L)=>`
26
+ for (let i = 0; i < ${C}.issues.length; i++) {
27
+ const iss = ${C}.issues[i];
28
+ iss.path = iss.path ? [${L}, ...iss.path] : [${L}];
29
+ payload.issues.push(iss);
30
+ }`;E.write("const input = payload.value;");const H=Object.create(null);let B=0;for(const C of b.allKeys)H[C]=`key_${B++}`;E.write(i?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const C of b.allKeys){if(C==="__proto__")continue;const L=H[C],I=typeof C=="symbol"?`syms[${_.indexOf(C)}]`:aS(C),Z=`${I} in input`,V=v[C],K=(re=V==null?void 0:V._zod)==null?void 0:re.optin,le=K!==void 0,de=((F=V==null?void 0:V._zod)==null?void 0:F.optout)==="optional";if(E.write(`const ${L} = ${j(I)};`),le&&de){const Q=K==="optional"?`${L}_present`:`${L}.value !== undefined || ${L}_present`;E.write(`
31
+ const ${L}_present = ${Z};
32
+ if (!${L}.issues.length || ${L}_present) {
33
+ if (${L}.issues.length) {${x(L,I)}
34
+ }
35
+
36
+ if (${Q}) {
37
+ newResult[${I}] = ${L}.value;
38
+ }
39
+ }
40
+
41
+ `)}else le?E.write(`
42
+ if (${L}.issues.length) {${x(L,I)}
43
+ }
44
+
45
+ if (${L}.value === undefined) {
46
+ if (${Z}) {
47
+ newResult[${I}] = undefined;
48
+ }
49
+ } else {
50
+ newResult[${I}] = ${L}.value;
51
+ }
52
+
53
+ `):E.write(`
54
+ const ${L}_present = ${Z};
55
+ if (${L}.issues.length) {${x(L,I)}
56
+ }
57
+ if (!${L}_present && !${L}.issues.length) {
58
+ payload.issues.push({
59
+ code: "invalid_type",
60
+ expected: "nonoptional",
61
+ input: undefined,
62
+ path: [${I}]
63
+ });
64
+ }
65
+
66
+ if (${L}_present) {
67
+ newResult[${I}] = ${L}.value;
68
+ }
69
+
70
+ `)}return E.write("payload.value = newResult;"),E.write("return payload;"),E.compile()};let l;const c=el,d=!vo.jitless,k=d&&cS.value,p=t.catchall;let h;e._zod.parse=(v,b)=>{h??(h=r.value);const _=v.value;return c(_)?d&&k&&(b==null?void 0:b.async)===!1&&b.jitless!==!0?(l||(l=a(t.shape)),v=l(v,b),p?jw([],_,v,b,h,e):v):n(v,b):(v.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),v)}});function Tk(e,t,n,r){for(const a of e)if(a.issues.length===0)return t.value=a.value,t;const i=e.filter(a=>!js(a));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(a=>a.issues.map(l=>Zs(l,r,Ni())))}),t)}const Aw=fe("$ZodUnion",(e,t)=>{an.init(e,t),Ht(e,"optin",r=>r.def.options.some(i=>i._zod.optin==="defaulted")?"defaulted":r.def.options.some(i=>i._zod.optin!==void 0)?"optional":void 0),Ht(e,"optout",r=>r.def.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Ht(e,"values",r=>{if(r.def.options.every(i=>i._zod.values))return new Set(r.def.options.flatMap(i=>Array.from(i._zod.values)))}),Ht(e,"pattern",r=>{if(r.def.options.every(i=>i._zod.pattern)){const i=r.def.options.map(a=>a._zod.pattern);return new RegExp(`^(${i.map(a=>Qp(a.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1;const l=[];for(const c of t.options){const d=c._zod.run({value:r.value,issues:[]},i);if(d instanceof Promise)l.push(d),a=!0;else{if(d.issues.length===0)return d;l.push(d)}}return a?Promise.all(l).then(c=>Tk(c,r,e,i)):Tk(l,r,e,i)}}),bT=fe("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Aw.init(e,t);const n=e._zod.parse;Ht(e,"propValues",i=>{const a={};for(const l of i.def.options){const c=l._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${i.def.options.indexOf(l)}"`);for(const[d,g]of Object.entries(c)){Object.prototype.hasOwnProperty.call(a,d)||Or(a,d,new Set);for(const k of g)a[d].add(k)}}return a}),t.options.forEach((i,a)=>{const l=kp.get(i._zod.def);if(l&&!Object.prototype.hasOwnProperty.call(l,t.discriminator))throw new Error(`Invalid discriminated union option at index "${a}"`)});const r=vu(()=>{var l;const i=t.options,a=new Map;for(const c of i){const d=(l=c._zod.propValues)==null?void 0:l[t.discriminator];if(!d||d.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(c)}"`);for(const g of d){if(a.has(g))throw new Error(`Duplicate discriminator value "${String(g)}"`);a.set(g,c)}}return a});e._zod.parse=(i,a)=>{const l=i.value;if(!el(l))return i.issues.push({code:"invalid_type",expected:"object",input:l,inst:e}),i;const c=r.value.get(l==null?void 0:l[t.discriminator]);return c?c._zod.run(i,a):t.unionFallback||a.direction==="backward"?n(i,a):(i.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}),i)}}),xT=fe("$ZodIntersection",(e,t)=>{an.init(e,t),e._zod.parse=(n,r)=>{const i=n.value,a=t.left._zod.run({value:i,issues:[]},r),l=t.right._zod.run({value:i,issues:[]},r);return a instanceof Promise||l instanceof Promise?Promise.all([a,l]).then(([d,g])=>Ck(n,d,g)):Ck(n,a,l)}});function yp(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(tl(e)&&tl(t)){const n=Object.keys(t),r=Object.keys(e).filter(a=>n.indexOf(a)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,"__proto__")&&delete i.__proto__;for(const a of r){if(a==="__proto__")continue;const l=yp(e[a],t[a]);if(!l.valid)return{valid:!1,mergeErrorPath:[a,...l.mergeErrorPath]};i[a]=l.data}return{valid:!0,data:i}}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 i=e[r],a=t[r],l=yp(i,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 Ck(e,t,n){const r=new Map;let i;const a=new Map,l=(g,k)=>{var h,v;let p;if(g.code==="unrecognized_keys"&&!((h=g.path)!=null&&h.length))i??(i=g),p=g.keys;else if(g.code==="invalid_key"&&g.origin==="record"&&((v=g.path)==null?void 0:v.length)===1){const b=String(g.path[0]);a.has(b)||a.set(b,g),p=[b]}else return!1;for(const b of p)r.has(b)||r.set(b,{}),r.get(b)[k]=!0;return!0};for(const g of t.issues)l(g,"l")||e.issues.push(g);for(const g of n.issues)l(g,"r")||e.issues.push(g);const c=[...r].filter(([,g])=>g.l&&g.r).map(([g])=>g);if(c.length){const g=i?c.filter(k=>i.keys.includes(k)):[];g.length&&e.issues.push({...i,keys:g});for(const k of c)!g.includes(k)&&a.has(k)&&e.issues.push(a.get(k))}const d=yp(t.value,n.value);if(!d.valid){if(js(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(d.mergeErrorPath)}`)}return e.value=d.data,e}const _T=fe("$ZodTuple",(e,t)=>{an.init(e,t);const n=t.items,r=vo.memoizer;r==null||r.attach(e),e._zod.parse=(i,a)=>{const l=i.value;if(!Array.isArray(l))return i.issues.push({input:l,inst:e,expected:"tuple",code:"invalid_type"}),i;i.value=r?r.alloc(e,i,[],a):[];const c=[],d=jk(n,"optin"),g=jk(n,"optout");if(!t.rest){if(l.length<d)return i.issues.push({code:"too_small",minimum:d,inclusive:!0,input:l,inst:e,origin:"array"}),i;l.length>n.length&&i.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:l,inst:e,origin:"array"})}const k=new Array(n.length);for(let p=0;p<n.length;p++){const h=n[p]._zod.run({value:l[p],issues:[]},a);h instanceof Promise?c.push(h.then(v=>{k[p]=v})):k[p]=h}if(t.rest){let p=n.length-1;const h=l.slice(n.length);for(const v of h){p++;const b=t.rest._zod.run({value:v,issues:[]},a);b instanceof Promise?c.push(b.then(_=>Ak(_,i,p))):Ak(b,i,p)}}return c.length?Promise.all(c).then(()=>Ik(k,i,n,l,g)):Ik(k,i,n,l,g)}});function jk(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 Ak(e,t,n){e.issues.length&&t.issues.push(...wu(n,e.issues)),t.value[n]=e.value}function Ik(e,t,n,r,i){for(let a=0;a<n.length;a++){const l=e[a],c=a<r.length;if(!c&&a>=i&&n[a]._zod.optin==="optional"){t.value.length=a;break}if(l.issues.length){if(!c&&a>=i){t.value.length=a;break}t.issues.push(...wu(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 ET=fe("$ZodEnum",(e,t)=>{an.init(e,t);const n=cw(t.entries),r=new Set(n);e._zod.values=r;const i=n.filter(a=>uS.has(typeof a));e._zod.pattern=new RegExp(i.length?`^(${i.map(a=>Ls(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}}),ST=fe("$ZodLiteral",(e,t)=>{an.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"?Ls(r):r?Ls(r.toString()):String(r)).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(r,i)=>{const a=r.value;return n.has(a)||r.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),r}}),NT=fe("$ZodTransform",(e,t)=>{var n;an.init(e,t),e._zod.optin="optional",(n=vo.memoizer)==null||n.guard(e),e._zod.parse=(r,i)=>{if(i.direction==="backward")throw new hw(e.constructor.name);const a=t.transform(r.value,r);if(i.async)return(a instanceof Promise?a:Promise.resolve(a)).then(c=>(r.value=c,r));if(a instanceof Promise)throw new Os;return r.value=a,r}});function Rk(e,t){return e.value=t.issues.length?void 0:t.value,e}const Iw=fe("$ZodOptional",(e,t)=>{an.init(e,t),Ht(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",Ht(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),Ht(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Qp(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;const i=t.innerType._zod.run({value:n.value,issues:[]},r);return i instanceof Promise?i.then(a=>Rk(n,a)):Rk(n,i)}return t.innerType._zod.run(n,r)}}),TT=fe("$ZodExactOptional",(e,t)=>{Iw.init(e,t),Ht(e,"values",n=>n.def.innerType._zod.values),Ht(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),CT=fe("$ZodNullable",(e,t)=>{an.init(e,t),Ht(e,"optin",n=>n.def.innerType._zod.optin),Ht(e,"optout",n=>n.def.innerType._zod.optout),Ht(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Qp(r.source)}|null)$`):void 0}),Ht(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)}),jT=fe("$ZodDefault",(e,t)=>{an.init(e,t),e._zod.optin="defaulted",Ht(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 i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(a=>Ok(a,t)):Ok(i,t)}});function Ok(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const AT=fe("$ZodPrefault",(e,t)=>{an.init(e,t),e._zod.optin="defaulted",Ht(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))}),IT=fe("$ZodNonOptional",(e,t)=>{an.init(e,t),Ht(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r].filter(i=>i!==void 0)):void 0}),e._zod.parse=(n,r)=>{const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(a=>$k(a,e)):$k(i,e)}});function $k(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 Mk(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(i=>Zs(i,r,Ni()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const RT=fe("$ZodCatch",(e,t)=>{an.init(e,t),Ht(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),Ht(e,"optout",n=>n.def.innerType._zod.optout),Ht(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 i=t.innerType._zod.run({value:n.value,issues:[]},r);return i instanceof Promise?i.then(a=>Mk(n,a,t,r)):Mk(n,i,t,r)}}),OT=fe("$ZodPipe",(e,t)=>{an.init(e,t),Ht(e,"values",n=>n.def.in._zod.values),Ht(e,"optin",n=>n.def.in._zod.optin),Ht(e,"optout",n=>n.def.out._zod.optout),Ht(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=>bc(l,t.in,r)):bc(a,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(a=>bc(a,t.out,r)):bc(i,t.out,r)}});function bc(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 $T=fe("$ZodReadonly",(e,t)=>{an.init(e,t),Ht(e,"propValues",n=>n.def.innerType._zod.propValues),Ht(e,"values",n=>n.def.innerType._zod.values),Ht(e,"optin",n=>{var r,i;return(i=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:i.optin}),Ht(e,"optout",n=>{var r,i;return(i=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:i.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(Pk):Pk(i)}});function Pk(e){return e.memo||(e.value=Object.freeze(e.value)),e}const MT=fe("$ZodCustom",(e,t)=>{$r.init(e,t),an.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(a=>Lk(a,n,r,e));Lk(i,n,r,e)}});function Lk(e,t,n,r){if(!e){const i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),t.issues.push(nl(i))}}class PT extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const vp="~memo",Dk=[];function Rf(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const zk=new WeakMap;function Rw(e,t){const n=zk.get(e);if(n!==void 0)return n;if(t.has(e))return!0;t.add(e);let r=!1;const i=c=>{!r&&(c!=null&&c._zod)&&Rw(c,t)&&(r=!0)},a=e._zod.def;switch(a.type){case"object":{for(const c of Reflect.ownKeys(a.shape))i(a.shape[c]);i(a.catchall);break}case"array":i(a.element);break;case"tuple":for(const c of a.items)i(c);i(a.rest);break;case"record":case"map":i(a.keyType),i(a.valueType);break;case"set":i(a.valueType);break;case"union":for(const c of a.options)i(c);break;case"intersection":i(a.left),i(a.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(a.innerType);break;case"pipe":i(a.in),i(a.out);break;case"function":i(a.input),i(a.output);break;case"lazy":i(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 d=Object.getOwnPropertyDescriptor(a,c);if(!d||d.get)continue;const g=d.value;if(!(!g||typeof g!="object")){if(g._zod)i(g);else if(Array.isArray(g))for(const k of g)i(k)}}}return t.delete(e),zk.set(e,r),r}function LT(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}let xc;const _c=[],DT={alloc(e,t,n){const r=xc;if(!r)return n;xc=void 0;const i={value:n,issues:null};return r.set(t.value,i),_c.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const n=e._zod.parse,r=(i,a)=>{if(a.direction!=="backward"&&FT(a,i.value))throw new PT;return n(i,a)};e._zod.parse=r,e._zod.run===n&&(e._zod.run=r)})},attach(e){var t;let n,r,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const a=e._zod.parse,l=(c,d)=>{if(n===void 0&&(n=Rw(e,new Set),!n))return e._zod.parse=a,e._zod.run===l&&(e._zod.run=a),a(c,d);const g=c.value;if(g===null||typeof g!="object")return a(c,d);let k=d[vp];k||(k={buckets:new Map,backEdges:void 0},d[vp]=k);let p;r===d?p=i:(p=LT(k,e),r=d,i=p);const h=p.get(g);if(h)return c.value=h.value,h.issues?h.issues.length&&c.issues.push(...Rf(h.issues)):(c.memo=!0,k.backEdges??(k.backEdges=new Set),k.backEdges.add(h.value)),c;xc=p;const v=_c.length,b=a(c,d);xc=void 0;const _=_c.length>v?_c.pop():void 0;return b instanceof Promise?b.then(E=>(_&&(_.issues=E.issues.length?Rf(E.issues):Dk),E)):(_&&(_.issues=b.issues.length?Rf(b.issues):Dk),b)};e._zod.parse=l,e._zod.run===a&&(e._zod.run=l)})}};function zT(){return DT}function FT(e,t){var r;const n=(r=e[vp])==null?void 0:r.backEdges;return n!==void 0&&t!==null&&typeof t=="object"&&n.has(t)}const BT=()=>{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 i(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=i(a.expected),c=bS(a.input),d=i(c,a.input);return`Invalid input: expected ${l}, received ${d}`}case"invalid_value":return a.values.length===1?`Invalid input: expected ${fw(a.values[0])}`:`Invalid option: expected one of ${yk(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":""}: ${yk(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 UT(){return{localeError:BT()}}var Fk;class HT{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 i={...r,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function ZT(){return new HT}(Fk=globalThis).__zod_globalRegistry??(Fk.__zod_globalRegistry=ZT());const Da=globalThis.__zod_globalRegistry;function WT(e,t){return new e({type:"string",...He(t)})}function KT(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...He(t)})}function GT(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...He(t)})}function VT(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...He(t)})}function qT(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...He(t)})}function YT(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...He(t)})}function QT(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...He(t)})}function XT(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...He(t)})}function JT(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...He(t)})}function eC(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...He(t)})}function tC(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...He(t)})}function nC(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...He(t)})}function rC(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...He(t)})}function oC(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...He(t)})}function iC(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...He(t)})}function sC(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...He(t)})}function aC(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...He(t)})}function lC(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...He(t)})}function cC(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...He(t)})}function uC(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...He(t)})}function dC(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...He(t)})}function fC(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...He(t)})}function pC(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...He(t)})}function hC(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...He(t)})}function mC(e,t){return new e({type:"string",format:"date",check:"string_format",...He(t)})}function gC(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...He(t)})}function kC(e,t){return new e({type:"string",format:"duration",check:"string_format",...He(t)})}function yC(e,t){return new e({type:"number",checks:[],...He(t)})}function vC(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...He(t)})}function wC(e,t){return new e({type:"boolean",...He(t)})}function bC(e){return new e({type:"unknown"})}function xC(e,t){return new e({type:"never",...He(t)})}function Bk(e,t){return new ww({check:"less_than",...He(t),value:e,inclusive:!1})}function Of(e,t){return new ww({check:"less_than",...He(t),value:e,inclusive:!0})}function Uk(e,t){return new bw({check:"greater_than",...He(t),value:e,inclusive:!1})}function $f(e,t){return new bw({check:"greater_than",...He(t),value:e,inclusive:!0})}function Hk(e,t){return new bN({check:"multiple_of",...He(t),value:e})}function Ow(e,t){return new _N({check:"max_length",...He(t),maximum:e})}function qc(e,t){return new EN({check:"min_length",...He(t),minimum:e})}function $w(e,t){return new SN({check:"length_equals",...He(t),length:e})}function _C(e,t){return new NN({check:"string_format",format:"regex",...He(t),pattern:e})}function EC(e){return new TN({check:"string_format",format:"lowercase",...He(e)})}function SC(e){return new CN({check:"string_format",format:"uppercase",...He(e)})}function NC(e,t){return new jN({check:"string_format",format:"includes",...He(t),includes:e})}function TC(e,t){return new AN({check:"string_format",format:"starts_with",...He(t),prefix:e})}function CC(e,t){return new IN({check:"string_format",format:"ends_with",...He(t),suffix:e})}function Ws(e){return new RN({check:"overwrite",tx:e})}function jC(e){return Ws(t=>t.normalize(e))}function AC(){return Ws(e=>e.trim())}function IC(){return Ws(e=>e.toLowerCase())}function RC(){return Ws(e=>e.toUpperCase())}function OC(){return Ws(e=>lS(e))}function $C(e,t,n){return new e({type:"array",element:t,...He(n)})}function MC(e,t,n){return new e({type:"custom",check:"custom",fn:t,...He(n)})}function PC(e,t){const n=LC(r=>(r.addIssue=i=>{if(typeof i=="string")r.issues.push(nl(i,r.value,n._zod.def));else{const a=i;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(nl(a))}},e(r.value,r)),t);return n}function LC(e,t){const n=new $r({check:"custom",...He(t)});return n._zod.check=e,n}function Ka(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&Or(e,r,n[r]);return e}function Mw(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)??Da,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 bi(e,t,n,r,i){const a=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a==="any")return!1;if(a===void 0||a==="throw")throw new Error(i);return Object.assign(n,a),!0}function Pn(e,t,n={path:[],schemaPath:[]}){var k,p;var r;const i=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=(p=(k=e._zod).toJSONSchema)==null?void 0:p.call(k);if(c)l.schema=c;else{const h={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,l.schema,h);else{const b=l.schema,_=t.processors[i.type];if(!_)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);_(e,t,b,h)}const v=e._zod.parent;v&&(l.ref||(l.ref=v),Pn(v,t,h),t.seen.get(v).isParent=!0)}const d=t.metadataRegistry.get(e);return d&&Ka(l.schema,d),t.io==="input"&&gr(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 Zk(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Pw(e,t){var l,c,d,g;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 k of e.seen.entries()){const p=(l=e.metadataRegistry.get(k[0]))==null?void 0:l.id;if(p){const h=r.get(p);if(h&&h!==k[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(p,k[0])}}const i=k=>{var _;const p=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const E=(_=e.external.registry.get(k[0]))==null?void 0:_.id,j=e.external.uri??(H=>H);if(E)return{ref:j(E)};const x=k[1].defId??k[1].schema.id??`schema${e.counter++}`;return k[1].defId=x,{defId:x,ref:`${j("__shared")}#/${p}/${Zk(x)}`}}const h="#",v=`${h}/${p}/`;if(k[1]===n&&!k[1].schema.id)return{ref:h};const b=k[1].schema.id??`__schema${e.counter++}`;return{defId:b,ref:v+Zk(b)}},a=k=>{if(k[1].schema.$ref)return;const p=k[1],{ref:h,defId:v}=i(k);p.def={...p.schema},v&&(p.defId=v);const b=p.schema;for(const _ in b)delete b[_];b.$ref=h};if(e.cycles==="throw")for(const k of e.seen.entries()){const p=k[1];if(p.cycle)throw new Error(`Cycle detected: #/${(c=p.cycle)==null?void 0:c.join("/")}/<root>
71
+
72
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const k of e.seen.entries()){const p=k[1];if(t===k[0]){a(k);continue}if(e.external){const v=(d=e.external.registry.get(k[0]))==null?void 0:d.id;if(t!==k[0]&&v){a(k);continue}}if((g=e.metadataRegistry.get(k[0]))==null?void 0:g.id){a(k);continue}if(p.cycle){a(k);continue}if(p.count>1&&e.reused==="ref"){a(k);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Lw(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;Lw(r);const i=Object.keys(r);if(i.length!==1||i[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 Dw=new Set(["type","properties","required","additionalProperties"]),Wk=["oneOf","anyOf"];function Kk(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function wp(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(!Dw.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 d=[];for(const k of t){const p=((a=k.properties)==null?void 0:a[c])??Kk(k);p!=null&&(d.some(h=>JSON.stringify(h)===JSON.stringify(p))||d.push(p))}const g=d.length===1?d[0]:wp(d)??{allOf:d};Or(n,c,g)}for(const c of l.required??[])r.add(c)}const i={type:"object",properties:n};if(r.size&&(i.required=[...r]),t.every(l=>l.additionalProperties===!1))i.additionalProperties=!1;else{const l=[];for(const c of t){const d=Kk(c);d&&!l.some(g=>JSON.stringify(g)===JSON.stringify(d))&&l.push(d)}l.length===1?i.additionalProperties=l[0]:l.length>1&&(i.additionalProperties={allOf:l})}return i}function DC(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const i of Dw)if(i in e)return;const n=t.filter(i=>Wk.some(a=>Array.isArray(i[a])));let r=null;if(!n.length)r=wp(t);else{const i=n[0],a=Wk.find(d=>Array.isArray(i[d]));if(Object.keys(i).length!==1)return;const l=t.filter(d=>d!==i),c=i[a].map(d=>wp([...l,d]));if(c.some(d=>!d))return;r={[a]:c}}r&&(delete e.allOf,Ka(e,r))}function zw(e,t){var c,d,g,k;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=p=>{const h=e.seen.get(p);if(h.ref===null)return;const v=h.def??h.schema,b={...v},_=h.ref;if(h.ref=null,_){r(_);const j=e.seen.get(_),x=j.schema;if(x.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(v.allOf=v.allOf??[],v.allOf.push(x)):Ka(v,x),Ka(v,b),p._zod.parent===_)for(const B in v)B==="$ref"||B==="allOf"||B in b||delete v[B];if(x.$ref&&j.def)for(const B in v)B==="$ref"||B==="allOf"||B in j.def&&JSON.stringify(v[B])===JSON.stringify(j.def[B])&&delete v[B]}const E=p._zod.parent;if(E&&E!==_){r(E);const j=e.seen.get(E);if(j!=null&&j.schema.$ref&&(v.$ref=j.schema.$ref,j.def))for(const x in v)x==="$ref"||x==="allOf"||x in j.def&&JSON.stringify(v[x])===JSON.stringify(j.def[x])&&delete v[x]}e.override({zodSchema:p,jsonSchema:v,path:h.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const p of[...e.seen.entries()].reverse())r(p[0]);if(e.target!=="openapi-3.0")for(const p of e.seen.entries())Lw(p[1].def??p[1].schema);for(const p of e.deferred)p();if(e.intersections.length){const p=new Map;for(const h of e.seen.values())for(const v of[h.schema,h.def]){const b=v==null?void 0:v.allOf;if(!Array.isArray(b))continue;const _=p.get(b);_?_.push(v):p.set(b,[v])}for(const h of e.intersections)for(const v of p.get(h)??[])DC(v)}}const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,(c=e.external)!=null&&c.uri){const p=(d=e.external.registry.get(t))==null?void 0:d.id;if(!p)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(p)}Ka(i,n.defId?n.schema:n.def??n.schema);const a=(g=e.metadataRegistry.get(t))==null?void 0:g.id;a!==void 0&&i.id===a&&delete i.id;const l=((k=e.external)==null?void 0:k.defs)??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const p of e.seen.entries()){const h=p[1];h.def&&h.defId&&(h.def.id===h.defId&&delete h.def.id,Or(l,h.defId,h.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(l).length>0&&(e.target==="draft-2020-12"?i.$defs=l:i.definitions=l);try{const p=JSON.parse(JSON.stringify(i));return Object.defineProperty(p,"~standard",{value:{...t["~standard"],jsonSchema:{input:Yc(t,"input",e.processors),output:Yc(t,"output",e.processors)}},enumerable:!1,writable:!1}),p}catch{throw new Error("Error converting schema to JSON.")}}function gr(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 gr(r.element,n);if(r.type==="set")return gr(r.valueType,n);if(r.type==="lazy")return gr(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 gr(r.innerType,n);if(r.type==="intersection")return gr(r.left,n)||gr(r.right,n);if(r.type==="record"||r.type==="map")return gr(r.keyType,n)||gr(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:gr(r.in,n)||gr(r.out,n);if(r.type==="object"){for(const i in r.shape)if(gr(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(gr(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(gr(i,n))return!0;return!!(r.rest&&gr(r.rest,n))}return!1}const zC=(e,t={})=>n=>{const r=Mw({...n,processors:t});return Pn(e,r),Pw(r,e),zw(r,e)},Yc=(e,t,n={})=>r=>{const{libraryOptions:i,target:a}=r??{},l=Mw({...i??{},target:a,io:t,processors:n});return Pn(e,l),Pw(l,e),zw(l,e)},FC={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},BC=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:a,maximum:l,format:c,patterns:d,contentEncoding:g,laxFormat:k}=e._zod.bag;if(typeof a=="number"&&(i.minLength=a),typeof l=="number"&&(i.maxLength=l),c&&(i.format=FC[c]??c,i.format===""&&delete i.format,(c==="time"||k)&&delete i.format),g&&(i.contentEncoding=g),d&&d.size>0){const p=[...d];p.length===1?i.pattern=p[0].source:p.length>1&&(i.allOf=[...p.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},UC=(e,t,n,r)=>{const i=n,{minimum:a,maximum:l,format:c,multipleOf:d,exclusiveMaximum:g,exclusiveMinimum:k}=e._zod.bag;typeof c=="string"&&c.includes("int")?i.type="integer":i.type="number";const p=typeof k=="number"&&k>=(a??Number.NEGATIVE_INFINITY),h=typeof g=="number"&&g<=(l??Number.POSITIVE_INFINITY),v=t.target==="draft-04"||t.target==="openapi-3.0";p?v?(i.minimum=k,i.exclusiveMinimum=!0):i.exclusiveMinimum=k:typeof a=="number"&&(i.minimum=a),h?v?(i.maximum=g,i.exclusiveMaximum=!0):i.exclusiveMaximum=g:typeof l=="number"&&(i.maximum=l),typeof d=="number"&&(Number.isFinite(d)&&d!==0?i.multipleOf=Math.abs(d):bi(e,t,i,r,`A multipleOf divisor of ${d} cannot be represented in JSON Schema`))},HC=(e,t,n,r)=>{n.type="boolean"},ZC=(e,t,n,r)=>{n.not={}},WC=(e,t,n,r)=>{},KC=(e,t,n,r)=>{const i=e._zod.def,a=cw(i.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},GC=(e,t,n,r)=>{const i=e._zod.def;if(i.values.length===0){n.not={};return}const a=[];for(const l of i.values)if(l===void 0){if(bi(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof l=="bigint"){if(bi(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},VC=(e,t,n,r)=>{bi(e,t,n,r,"Custom types cannot be represented in JSON Schema")},qC=(e,t,n,r)=>{bi(e,t,n,r,"Transforms cannot be represented in JSON Schema")},YC=(e,t,n,r)=>{const i=n,a=e._zod.def,{minimum:l,maximum:c}=e._zod.bag;typeof l=="number"&&(i.minItems=l),typeof c=="number"&&(i.maxItems=c),i.type="array",i.items=Pn(a.element,t,{...r,path:[...r.path,"items"]})};function Qc(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Qc(t.out):t.type==="catch"?Qc(t.innerType):e._zod.optin}const QC=(e,t,n,r)=>{var k;const i=n,a=e._zod.def,l=a.shape;if(Object.getOwnPropertySymbols(l).length&&bi(e,t,i,r,"Symbol keys cannot be represented in JSON Schema"))return;i.type="object",i.properties={};for(const p in l)Or(i.properties,p,Pn(l[p],t,{...r,path:[...r.path,"properties",p]}));const d=new Set(Object.keys(l)),g=new Set([...d].filter(p=>{const h=a.shape[p];return t.io==="input"?Qc(h)===void 0:h._zod.optout===void 0}));g.size>0&&(i.required=Array.from(g)),((k=a.catchall)==null?void 0:k._zod.def.type)==="never"?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Pn(a.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},XC=(e,t,n,r)=>{const i=e._zod.def,a=i.inclusive===!1,l=i.options.map((c,d)=>Pn(c,t,{...r,path:[...r.path,a?"oneOf":"anyOf",d]}));a?n.oneOf=l:n.anyOf=l},JC=(e,t,n,r)=>{const i=e._zod.def,a=Pn(i.left,t,{...r,path:[...r.path,"allOf",0]}),l=Pn(i.right,t,{...r,path:[...r.path,"allOf",1]}),c=g=>"allOf"in g&&Object.keys(g).length===1,d=[...c(a)?a.allOf:[a],...c(l)?l.allOf:[l]];n.allOf=d,t.intersections.push(d)},ej=(e,t,n,r)=>{const i=n,a=e._zod.def;i.type="array";const l=t.target==="draft-2020-12"?"prefixItems":"items",c=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",d=a.items.map((_,E)=>Pn(_,t,{...r,path:[...r.path,l,E]})),g=a.rest?Pn(a.rest,t,{...r,path:[...r.path,c,...t.target==="openapi-3.0"?[a.items.length]:[]]}):null;let k=a.items.length;for(;k>0;){const _=a.items[k-1];if(!(t.io==="input"?Qc(_)!==void 0:_._zod.optout==="optional"))break;k--}const p=a.items.length,h=!a.rest;t.target==="draft-2020-12"?(i.prefixItems=d,h?i.items=!1:g&&(i.items=g),k>0&&(i.minItems=k),h&&(i.maxItems=p)):t.target==="openapi-3.0"?(i.items={anyOf:d},g&&i.items.anyOf.push(g),k>0&&(i.minItems=k),h&&(i.maxItems=p)):(i.items=d,h?i.additionalItems=!1:g&&(i.additionalItems=g),k>0&&(i.minItems=k),h&&(i.maxItems=p));const{minimum:v,maximum:b}=e._zod.bag;typeof v=="number"&&(i.minItems=v),typeof b=="number"&&(i.maxItems=b)},tj=(e,t,n,r)=>{const i=e._zod.def,a=Pn(i.innerType,t,r),l=t.seen.get(e);t.target==="openapi-3.0"?(l.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:"null"}]},nj=(e,t,n,r)=>{const i=e._zod.def;Pn(i.innerType,t,r);const a=t.seen.get(e);a.ref=i.innerType},oh=Symbol();function Fw(e,t,n,r,i){let a=!1;const l=JSON.stringify(e,(c,d)=>typeof d!="bigint"?d:(a=!0,null));return a?(bi(t,n,r,i,"BigInt defaults cannot be represented in JSON Schema"),oh):JSON.parse(l)}const rj=(e,t,n,r)=>{const i=e._zod.def;Pn(i.innerType,t,r);const a=t.seen.get(e);a.ref=i.innerType;const l=Fw(i.defaultValue,e,t,n,r);l!==oh&&(n.default=l)},oj=(e,t,n,r)=>{const i=e._zod.def;Pn(i.innerType,t,r);const a=t.seen.get(e);if(a.ref=i.innerType,t.io!=="input")return;const l=Fw(i.defaultValue,e,t,n,r);l!==oh&&(n._prefault=l)},ij=(e,t,n,r)=>{const i=e._zod.def;Pn(i.innerType,t,r);const a=t.seen.get(e);a.ref=i.innerType;let l;try{l=i.catchValue(void 0)}catch{bi(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=l},sj=(e,t,n,r)=>{const i=e._zod.def,a=i.in._zod.traits.has("$ZodTransform"),l=t.io==="input"?a?i.out:i.in:i.out;Pn(l,t,r);const c=t.seen.get(e);c.ref=l},aj=(e,t,n,r)=>{const i=e._zod.def;Pn(i.innerType,t,r);const a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Bw=(e,t,n,r)=>{const i=e._zod.def;Pn(i.innerType,t,r);const a=t.seen.get(e);a.ref=i.innerType},Gk=new WeakSet([Object.prototype,Error.prototype]);function Ec(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 lj=(e,t)=>{gw.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);Gk.has(n)||(Gk.add(n),Ec(n,"format",r=>i=>MS(r,i)),Ec(n,"flatten",r=>i=>$S(r,i)),Ec(n,"addIssue",r=>i=>{r.issues.push(i),r.message=JSON.stringify(r.issues,mp,2)}),Ec(n,"addIssues",r=>i=>{r.issues.push(...i),r.message=JSON.stringify(r.issues,mp,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},oo=fe("ZodError",lj,void 0,{Parent:Error}),cj=eh(oo),uj=th(oo),dj=xu(oo),fj=_u(oo),pj=DS(oo),hj=zS(oo),mj=FS(oo),gj=BS(oo),kj=US(oo),yj=HS(oo),vj=ZS(oo),wj=WS(oo);function bj(){vo.localeError||Ni(UT())}function Su(){vo.memoizer||Ni({memoizer:zT()})}const fn=fe("ZodType",(e,t)=>(bj(),an.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(Ei(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Si(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(wA(e,t))},superRefine(e,t){return this.check(bA(e,t))},overwrite(e){return this.check(Ws(e))},optional(){return Yk(this)},exactOptional(){return aA(this)},nullable(){return Qk(this)},nullish(){return Yk(Qk(this))},nonoptional(e){return pA(this,e)},array(){return rl(this)},or(e){return Xj([this,e])},and(e){return nA(this,e)},transform(e){return Xk(this,sA(e))},default(e){return uA(this,e)},prefault(e){return fA(this,e)},catch(e){return mA(this,e)},pipe(e){return Xk(this,e)},readonly(){return yA(this)},describe(e){const t=this.clone();return Da.add(t,{description:e}),t},meta(...e){if(e.length===0)return Da.get(this);const t=this.clone();return Da.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 pw(this,"~standard",{...xw(this),jsonSchema:{input:Yc(this,"input"),output:Yc(this,"output")}})},set"~standard"(e){Ds(this,"~standard",e)},parse:function e(t,n){return cj(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await uj(this,t,n,{callee:e})},safeParse(e,t){return dj(this,e,t)},async safeParseAsync(e,t){return fj(this,e,t)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(e){Ds(this,"spa",e)},encode:function e(t,n){return pj(this,t,n,{callee:e})},decode:function e(t,n){return hj(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await mj(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await gj(this,t,n,{callee:e})},safeEncode(e,t){return kj(this,e,t)},safeDecode(e,t){return yj(this,e,t)},async safeEncodeAsync(e,t){return vj(this,e,t)},async safeDecodeAsync(e,t){return wj(this,e,t)},toJSONSchema(e){return zC(this,{})(e)},get description(){var e;return(e=Da.get(this))==null?void 0:e.description},get _def(){return this._zod.def}}),Uw=fe("_ZodString",(e,t)=>{rh.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(r,i,a)=>BC(e,r,i);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(_C(...e))},includes(...e){return this.check(NC(...e))},startsWith(...e){return this.check(TC(...e))},endsWith(...e){return this.check(CC(...e))},min(...e){return this.check(qc(...e))},max(...e){return this.check(Ow(...e))},length(...e){return this.check($w(...e))},nonempty(...e){return this.check(qc(1,...e))},lowercase(e){return this.check(EC(e))},uppercase(e){return this.check(SC(e))},trim(){return this.check(AC())},normalize(...e){return this.check(jC(...e))},toLowerCase(){return this.check(IC())},toUpperCase(){return this.check(RC())},slugify(){return this.check(OC())}}),xj=fe("ZodString",(e,t)=>{rh.init(e,t),Uw.init(e,t)},{email(e){return this.check(KT(Tj,e))},url(e){return this.check(XT(jj,e))},jwt(e){return this.check(pC(Zj,e))},emoji(e){return this.check(JT(Aj,e))},guid(e){return this.check(GT(Cj,e))},uuid(e){return this.check(VT(Sc,e))},uuidv4(e){return this.check(qT(Sc,e))},uuidv6(e){return this.check(YT(Sc,e))},uuidv7(e){return this.check(QT(Sc,e))},nanoid(e){return this.check(eC(Ij,e))},cuid(e){return this.check(tC(Rj,e))},cuid2(e){return this.check(nC(Oj,e))},ulid(e){return this.check(rC($j,e))},base64(e){return this.check(uC(Bj,e))},base64url(e){return this.check(dC(Uj,e))},xid(e){return this.check(oC(Mj,e))},ksuid(e){return this.check(iC(Pj,e))},ipv4(e){return this.check(sC(Lj,e))},ipv6(e){return this.check(aC(Dj,e))},cidrv4(e){return this.check(lC(zj,e))},cidrv6(e){return this.check(cC(Fj,e))},e164(e){return this.check(fC(Hj,e))},datetime(e){return this.check(hC(_j,e))},date(e){return this.check(mC(Ej,e))},time(e){return this.check(gC(Sj,e))},duration(e){return this.check(kC(Nj,e))}});function en(e){return WT(xj,e)}const pn=fe("ZodStringFormat",(e,t)=>{ln.init(e,t),Uw.init(e,t)}),_j=fe("ZodISODateTime",(e,t)=>{QN.init(e,t),pn.init(e,t)}),Ej=fe("ZodISODate",(e,t)=>{XN.init(e,t),pn.init(e,t)}),Sj=fe("ZodISOTime",(e,t)=>{JN.init(e,t),pn.init(e,t)}),Nj=fe("ZodISODuration",(e,t)=>{eT.init(e,t),pn.init(e,t)}),Tj=fe("ZodEmail",(e,t)=>{LN.init(e,t),pn.init(e,t)}),Cj=fe("ZodGUID",(e,t)=>{MN.init(e,t),pn.init(e,t)}),Sc=fe("ZodUUID",(e,t)=>{PN.init(e,t),pn.init(e,t)}),jj=fe("ZodURL",(e,t)=>{HN.init(e,t),pn.init(e,t)}),Aj=fe("ZodEmoji",(e,t)=>{ZN.init(e,t),pn.init(e,t)}),Ij=fe("ZodNanoID",(e,t)=>{WN.init(e,t),pn.init(e,t)}),Rj=fe("ZodCUID",(e,t)=>{KN.init(e,t),pn.init(e,t)}),Oj=fe("ZodCUID2",(e,t)=>{GN.init(e,t),pn.init(e,t)}),$j=fe("ZodULID",(e,t)=>{VN.init(e,t),pn.init(e,t)}),Mj=fe("ZodXID",(e,t)=>{qN.init(e,t),pn.init(e,t)}),Pj=fe("ZodKSUID",(e,t)=>{YN.init(e,t),pn.init(e,t)}),Lj=fe("ZodIPv4",(e,t)=>{tT.init(e,t),pn.init(e,t)}),Dj=fe("ZodIPv6",(e,t)=>{rT.init(e,t),pn.init(e,t)}),zj=fe("ZodCIDRv4",(e,t)=>{oT.init(e,t),pn.init(e,t)}),Fj=fe("ZodCIDRv6",(e,t)=>{sT.init(e,t),pn.init(e,t)}),Bj=fe("ZodBase64",(e,t)=>{aT.init(e,t),pn.init(e,t)}),Uj=fe("ZodBase64URL",(e,t)=>{cT.init(e,t),pn.init(e,t)}),Hj=fe("ZodE164",(e,t)=>{uT.init(e,t),pn.init(e,t)}),Zj=fe("ZodJWT",(e,t)=>{fT.init(e,t),pn.init(e,t)}),Hw=fe("ZodNumber",(e,t)=>{Tw.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(r,i,a)=>UC(e,r,i,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(Uk(e,t))},gte(e,t){return this.check($f(e,t))},min(e,t){return this.check($f(e,t))},lt(e,t){return this.check(Bk(e,t))},lte(e,t){return this.check(Of(e,t))},max(e,t){return this.check(Of(e,t))},int(e){return this.check(Vk(e))},safe(e){return this.check(Vk(e))},positive(e){return this.check(Uk(0,e))},nonnegative(e){return this.check($f(0,e))},negative(e){return this.check(Bk(0,e))},nonpositive(e){return this.check(Of(0,e))},multipleOf(e,t){return this.check(Hk(e,t))},step(e,t){return this.check(Hk(e,t))},finite(){return this}});function Ki(e){return yC(Hw,e)}const Wj=fe("ZodNumberFormat",(e,t)=>{pT.init(e,t),Hw.init(e,t)});function Vk(e){return vC(Wj,e)}const Kj=fe("ZodBoolean",(e,t)=>{hT.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>HC(e,n,r)});function Es(e){return wC(Kj,e)}const Gj=fe("ZodUnknown",(e,t)=>{mT.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>WC()});function qk(){return bC(Gj)}const Vj=fe("ZodNever",(e,t)=>{gT.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ZC(e,n,r)});function qj(e){return xC(Vj,e)}const Yj=fe("ZodArray",(e,t)=>{Su(),kT.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>YC(e,n,r,i),e.element=t.element},{min(e,t){return this.check(qc(e,t))},nonempty(e){return this.check(qc(1,e))},max(e,t){return this.check(Ow(e,t))},length(e,t){return this.check($w(e,t))},unwrap(){return this.element}});function rl(e,t){return $C(Yj,e,t)}const Qj=fe("ZodObject",(e,t)=>{Su(),wT.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>QC(e,n,r,i),NS(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return xp(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:qk()})},loose(){return this.clone({...this._zod.def,catchall:qk()})},strict(){return this.clone({...this._zod.def,catchall:qj()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return mS(this,e)},safeExtend(e){return gS(this,e)},merge(e){return kS(this,e)},pick(e){return pS(this,e)},omit(e){return hS(this,e)},partial(...e){return vk(ih,this,e[0])},exactPartial(...e){return vk(Kw,this,e[0],"exactPartial")},required(...e){return yS(Gw,this,e[0])}});function kr(e,t){const n={type:"object",shape:e??{},...He(t)};return new Qj(n)}const Zw=fe("ZodUnion",(e,t)=>{Aw.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>XC(e,n,r,i),e.options=t.options});function Xj(e,t){return new Zw({type:"union",options:e,...He(t)})}const Jj=fe("ZodDiscriminatedUnion",(e,t)=>{Zw.init(e,t),bT.init(e,t)});function eA(e,t,n){return new Jj({type:"union",options:t,discriminator:e,...He(n)})}const tA=fe("ZodIntersection",(e,t)=>{xT.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>JC(e,n,r,i)});function nA(e,t){return new tA({type:"intersection",left:e,right:t})}const rA=fe("ZodTuple",(e,t)=>{Su(),_T.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ej(e,n,r,i)},{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 ih({type:"optional",innerType:n}))})}});function Ww(e,t,n){const r=t instanceof an,i=r?n:t,a=r?t:null;return new rA({type:"tuple",items:e,rest:a,...He(i)})}const bp=fe("ZodEnum",(e,t)=>{ET.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(r,i,a)=>KC(e,r,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,i)=>{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 bp({...t,checks:[],...He(i),entries:a})},e.exclude=(r,i)=>{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 bp({...t,checks:[],...He(i),entries:a})}});function xp(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new bp({type:"enum",entries:n,...He(t)})}const oA=fe("ZodLiteral",(e,t)=>{ST.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>GC(e,n,r,i),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 Fr(e,t){return new oA({type:"literal",values:Array.isArray(e)?e:[e],...He(t)})}const iA=fe("ZodTransform",(e,t)=>{Su(),NT.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>qC(e,n,r,i),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new hw(e.constructor.name);n.addIssue=a=>{if(typeof a=="string")n.issues.push(nl(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(nl(l))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(a=>(n.value=a,n)):(n.value=i,n)}});function sA(e){return new iA({type:"transform",transform:e})}const ih=fe("ZodOptional",(e,t)=>{Iw.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Bw(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Yk(e){return new ih({type:"optional",innerType:e})}const Kw=fe("ZodExactOptional",(e,t)=>{TT.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Bw(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function aA(e){return new Kw({type:"optional",innerType:e})}const lA=fe("ZodNullable",(e,t)=>{CT.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>tj(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Qk(e){return new lA({type:"nullable",innerType:e})}const cA=fe("ZodDefault",(e,t)=>{jT.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rj(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function uA(e,t){return new cA({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():dw(t)}})}const dA=fe("ZodPrefault",(e,t)=>{AT.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>oj(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function fA(e,t){return new dA({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():dw(t)}})}const Gw=fe("ZodNonOptional",(e,t)=>{IT.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>nj(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function pA(e,t){return new Gw({type:"nonoptional",innerType:e,...He(t)})}const hA=fe("ZodCatch",(e,t)=>{RT.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ij(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function mA(e,t){return new hA({type:"catch",innerType:e,catchValue:typeof t=="function"?t:CS(t)})}const gA=fe("ZodPipe",(e,t)=>{OT.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sj(e,n,r,i),e.in=t.in,e.out=t.out});function Xk(e,t){return new gA({type:"pipe",in:e,out:t})}const kA=fe("ZodReadonly",(e,t)=>{$T.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>aj(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function yA(e){return new kA({type:"readonly",innerType:e})}const vA=fe("ZodCustom",(e,t)=>{MT.init(e,t),fn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>VC(e,n,r,i)});function wA(e,t={}){return MC(vA,e,t)}function bA(e,t){return PC(e,t)}const xA=kr({component:en().nullable(),file:en().nullable(),line:Ki().nullable(),callFile:en().nullable().default(null),callLine:Ki().nullable().default(null),tag:en(),selector:en()}),_A=kr({tag:en().max(40),id:en().max(200),classes:rl(en().max(120)).max(16),text:en().max(200),attrs:rl(Ww([en().max(40),en().max(200)])).max(12)}),EA=Ww([Ki(),Ki()]),SA=xA.extend({classes:en(),text:en(),html:en(),route:en(),element:_A}),NA=eA("type",[kr({type:Fr("loaded"),url:en(),title:en()}),kr({type:Fr("navigated"),url:en(),title:en().optional()}),kr({type:Fr("title"),title:en()}),kr({type:Fr("links"),links:rl(kr({path:en().max(2048),text:en().max(120)})).max(200)}),kr({type:Fr("hmr")}),kr({type:Fr("page-error"),message:en(),source:en().optional(),line:Ki().optional()}),SA.extend({type:Fr("picked"),verb:xp(["chat","code"]).default("chat"),site:xp(["call","source"]).default("source")}),kr({type:Fr("pick-cancel")}),kr({type:Fr("highlight-miss"),path:en(),fileMatched:Ki(),withSource:Ki(),ranges:rl(EA).nullable()}),kr({type:Fr("drag-files")}),kr({type:Fr("drop-files")}),kr({type:Fr("focus"),gesture:Es()}),kr({type:Fr("key"),key:en(),meta:Es(),ctrl:Es().optional(),shift:Es().optional(),alt:Es().optional(),up:Es().optional()})]);function TA(e){const t=NA.safeParse(e);return t.success?t.data:null}const Xc="shell",Vw="check",CA="now",jA="http://preview.invalid",AA=200;function Jk(e){const t=e==null?void 0:e.replace(/\s+/g," ").trim().slice(0,AA).trim();return t||void 0}function Nu(e){let t;try{t=new URL(e,jA)}catch{return null}if(t.pathname.startsWith("/__toyon"))return null;const n=ey(t.pathname)||"/",r=t.hash.startsWith("#/")?ey(t.hash.split("?")[0]??""):"";return r.length>1?`${n}${r}`:n}const ey=e=>e.replace(/\/+$/,""),IA={static:4,mixed:3.5,param:3,optional:2,"optional-static":2,splat:1},Jc=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function qw(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 i=/^\[([^\]=]+)(?:=[^\]]*)?\]$/.exec(e)??/^:([\w-]+)$/.exec(e)??/^\$([\w-]+)$/.exec(e);if(i)return{kind:"param",name:i[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 g of e.matchAll(/\[([^\]=]+)(?:=[^\]]*)?\]|\{\$([\w-]+)\}/g)){const k=e.slice(c,g.index);k&&(a.push({text:k}),l+=Jc(k)),a.push({name:g[1]??g[2]??"param"}),l+="[^/]+?",c=(g.index??0)+g[0].length}const d=e.slice(c);if(d&&(a.push({text:d}),l+=Jc(d)),a.some(g=>"name"in g))return{kind:"mixed",pattern:l,parts:a}}return{kind:"static",text:e}}function RA(e){const t=e.split("/").filter(Boolean).map(qw);if(t.every(r=>r.kind==="static"))return null;let n="";for(const r of t)r.kind==="static"?n+=`/${Jc(r.text)}`:r.kind==="optional-static"?n+=`(?:/${Jc(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,i)=>r+IA[i.kind],0),statics:t.filter(r=>r.kind==="static").length}}function OA(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 Tu(e){let t="";const n=[],r=i=>{n.push([t.length,t.length+i.length]),t+=i};for(const i of e.split("/").filter(Boolean).map(qw))if(t+="/",i.kind==="static"||i.kind==="optional-static")t+=i.text;else if(i.kind==="mixed")for(const a of i.parts)"name"in a?r(a.name):t+=a.text;else r(i.name);return t||(t="/"),{text:t,params:n,literal:n.length>0?t.slice(0,n[0][0]):t}}const ml={id:"toyon-dark",family:"Toyon",name:"Toyon Dark",kind:"dark",source:"builtin",pair:"toyon-light",accent:"red",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"}},Yw={id:"toyon-light",family:"Toyon",name:"Toyon Light",kind:"light",source:"builtin",pair:"toyon-dark",accent:"red",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"}},$A={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"}},MA={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"}},PA={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"}},LA={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"}},DA={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"}},zA={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"}},FA={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"}},BA={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"}},UA={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"}},HA={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"}},ZA={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"}},WA={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"}},KA={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"}},GA={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"}},VA={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"}},qA={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"}},YA={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"}},QA=[FA,BA,UA,HA,ZA,WA,KA,GA,VA,qA,YA],Dc=[ml,Yw,$A,MA,PA,LA,DA,zA,...QA],XA={mode:"dark",light:Yw.id,dark:ml.id},JA=["surface0","surface1","surface2","element0","element1","border0","border1","text0","text1","text2","red","orange","yellow","green","aqua","blue","purple","diffAdd","diffDel"];function eI(e){return`--${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function ty(e){const t=Xw(e);return t>.008856?116*t**(1/3)-16:903.3*t}function Qw(e,t){const n=ty(e)+t,r=ju(e);if(!r)return e;let i=0,a=2;for(let l=0;l<24;l++){const c=(i+a)/2,d=eu(Math.min(255,r[0]*c),Math.min(255,r[1]*c),Math.min(255,r[2]*c));ty(d)<n?i=c:a=c}return eu(Math.min(255,r[0]*i),Math.min(255,r[1]*i),Math.min(255,r[2]*i))}function tI(e){return Qw(e.colors.surface1,-4)}function nI(e){return Qw(e.colors.surface0,-4)}function ny(e){return dI(e,.55)}function rI(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 oI(e){const t={};for(const n of JA)t[eI(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(rI(e)))t[`--syntax-${n}`]=r;return t["--accent"]=e.colors[sh(e)],t["--fault"]=e.colors[iI(e)],t["--sunken"]=tI(e),t["--sunken-floor"]=nI(e),t["--scrim"]=uI(e.colors.surface0,.7),t["--shadow"]=e.kind==="dark"?"#00000066":"#0000002e",t["--diff-add-word"]=ny(e.colors.diffAdd),t["--diff-del-word"]=ny(e.colors.diffDel),t}function sh(e){return e.accent??"orange"}function iI(e){return sh(e)==="orange"?"red":"orange"}function sI(e){return e==="system"||e==="daylight"}function ah(e,t){return e.mode==="system"?t.system?"dark":"light":e.mode==="daylight"?t.daylight?"dark":"light":e.mode}function Cu(e,t,n){const r=ah(e,n);return t.find(i=>i.id===e[r])??Dc.find(i=>i.kind===r)??ml}function aI(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(),i=r(e.name);if(!i.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)===i)??null}function lI(e){const t=[],n=new Set,r=i=>i.family??(i.name.replace(/\b(dark|light)\b/gi,"").replace(/\s+/g," ").trim()||i.name);for(const i of e){if(n.has(i.id))continue;const a=aI(i,e),l={name:r(i)};l[i.kind]=i,n.add(i.id),a&&(l[a.kind]=a,n.add(a.id)),t.push(l)}return t}function cI(e,t){const n={...e};return t.dark&&(n.dark=t.dark.id),t.light&&(n.light=t.light.id),!sI(n.mode)&&!t[n.mode]&&(n.mode=t.dark?"dark":"light"),n}function ju(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(i=>i+i).join("")),n.length!==6&&n.length!==8)return null;const r=i=>parseInt(n.slice(i,i+2),16);return[r(0),r(2),r(4),n.length===8?r(6)/255:1]}function eu(e,t,n,r=1){const i=a=>Math.round(Math.max(0,Math.min(255,a))).toString(16).padStart(2,"0");return`#${i(e)}${i(t)}${i(n)}${r>=1?"":i(r*255)}`}function uI(e,t){const n=ju(e);return n?eu(n[0],n[1],n[2],t):e}function dI(e,t){const n=ju(e);return n?eu(n[0],n[1],n[2],Math.min(1,n[3]*t)):e}function Xw(e){const t=ju(e);if(!t)return 0;const n=r=>{const i=r/255;return i<=.03928?i/12.92:((i+.055)/1.055)**2.4};return .2126*n(t[0])+.7152*n(t[1])+.0722*n(t[2])}function fI(e){return Xw(e)>.179?"#1d2021":"#fbf1c7"}const pI=[[/\.(png|jpe?g|gif|webp|avif|bmp|ico)$/i,"image"]];function hI(e){var t;return((t=pI.find(([n])=>n.test(e)))==null?void 0:t[1])??null}function Jw(e){return/\.(md|markdown)$/i.test(e)}var T=Vp();const mI=Yv(T);var Nc={},Mf={exports:{}},Ar={},Pf={exports:{}},Lf={};/**
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 ry;function gI(){return ry||(ry=1,(function(e){function t(M,G){var ne=M.length;M.push(G);e:for(;0<ne;){var O=ne-1>>>1,ee=M[O];if(0<i(ee,G))M[O]=G,M[ne]=ee,ne=O;else break e}}function n(M){return M.length===0?null:M[0]}function r(M){if(M.length===0)return null;var G=M[0],ne=M.pop();if(ne!==G){M[0]=ne;e:for(var O=0,ee=M.length,D=ee>>>1;O<D;){var q=2*(O+1)-1,Te=M[q],Ne=q+1,je=M[Ne];if(0>i(Te,ne))Ne<ee&&0>i(je,Te)?(M[O]=je,M[Ne]=ne,O=Ne):(M[O]=Te,M[q]=ne,O=q);else if(Ne<ee&&0>i(je,ne))M[O]=je,M[Ne]=ne,O=Ne;else break e}}return G}function i(M,G){var ne=M.sortIndex-G.sortIndex;return ne!==0?ne:M.id-G.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 d=[],g=[],k=1,p=null,h=3,v=!1,b=!1,_=!1,E=typeof setTimeout=="function"?setTimeout:null,j=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 H(M){for(var G=n(g);G!==null;){if(G.callback===null)r(g);else if(G.startTime<=M)r(g),G.sortIndex=G.expirationTime,t(d,G);else break;G=n(g)}}function B(M){if(_=!1,H(M),!b)if(n(d)!==null)b=!0,ce(re);else{var G=n(g);G!==null&&R(B,G.startTime-M)}}function re(M,G){b=!1,_&&(_=!1,j(L),L=-1),v=!0;var ne=h;try{for(H(G),p=n(d);p!==null&&(!(p.expirationTime>G)||M&&!V());){var O=p.callback;if(typeof O=="function"){p.callback=null,h=p.priorityLevel;var ee=O(p.expirationTime<=G);G=e.unstable_now(),typeof ee=="function"?p.callback=ee:p===n(d)&&r(d),H(G)}else r(d);p=n(d)}if(p!==null)var D=!0;else{var q=n(g);q!==null&&R(B,q.startTime-G),D=!1}return D}finally{p=null,h=ne,v=!1}}var F=!1,C=null,L=-1,I=5,Z=-1;function V(){return!(e.unstable_now()-Z<I)}function K(){if(C!==null){var M=e.unstable_now();Z=M;var G=!0;try{G=C(!0,M)}finally{G?le():(F=!1,C=null)}}else F=!1}var le;if(typeof x=="function")le=function(){x(K)};else if(typeof MessageChannel<"u"){var de=new MessageChannel,Q=de.port2;de.port1.onmessage=K,le=function(){Q.postMessage(null)}}else le=function(){E(K,0)};function ce(M){C=M,F||(F=!0,le())}function R(M,G){L=E(function(){M(e.unstable_now())},G)}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(M){M.callback=null},e.unstable_continueExecution=function(){b||v||(b=!0,ce(re))},e.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<M?Math.floor(1e3/M):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(M){switch(h){case 1:case 2:case 3:var G=3;break;default:G=h}var ne=h;h=G;try{return M()}finally{h=ne}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(M,G){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var ne=h;h=M;try{return G()}finally{h=ne}},e.unstable_scheduleCallback=function(M,G,ne){var O=e.unstable_now();switch(typeof ne=="object"&&ne!==null?(ne=ne.delay,ne=typeof ne=="number"&&0<ne?O+ne:O):ne=O,M){case 1:var ee=-1;break;case 2:ee=250;break;case 5:ee=1073741823;break;case 4:ee=1e4;break;default:ee=5e3}return ee=ne+ee,M={id:k++,callback:G,priorityLevel:M,startTime:ne,expirationTime:ee,sortIndex:-1},ne>O?(M.sortIndex=ne,t(g,M),n(d)===null&&M===n(g)&&(_?(j(L),L=-1):_=!0,R(B,ne-O))):(M.sortIndex=ee,t(d,M),b||v||(b=!0,ce(re))),M},e.unstable_shouldYield=V,e.unstable_wrapCallback=function(M){var G=h;return function(){var ne=h;h=G;try{return M.apply(this,arguments)}finally{h=ne}}}})(Lf)),Lf}var oy;function kI(){return oy||(oy=1,Pf.exports=gI()),Pf.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 iy;function yI(){if(iy)return Ar;iy=1;var e=Vp(),t=kI();function n(o){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+o,u=1;u<arguments.length;u++)s+="&args[]="+encodeURIComponent(arguments[u]);return"Minified React error #"+o+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,i={};function a(o,s){l(o,s),l(o+"Capture",s)}function l(o,s){for(i[o]=s,o=0;o<s.length;o++)r.add(s[o])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=Object.prototype.hasOwnProperty,g=/^[: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]*$/,k={},p={};function h(o){return d.call(p,o)?!0:d.call(k,o)?!1:g.test(o)?p[o]=!0:(k[o]=!0,!1)}function v(o,s,u,m){if(u!==null&&u.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return m?!1:u!==null?!u.acceptsBooleans:(o=o.toLowerCase().slice(0,5),o!=="data-"&&o!=="aria-");default:return!1}}function b(o,s,u,m){if(s===null||typeof s>"u"||v(o,s,u,m))return!0;if(m)return!1;if(u!==null)switch(u.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function _(o,s,u,m,y,w,S){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=m,this.attributeNamespace=y,this.mustUseProperty=u,this.propertyName=o,this.type=s,this.sanitizeURL=w,this.removeEmptyString=S}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 s=o[0];E[s]=new _(s,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 j=/[\-:]([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 s=o.replace(j,x);E[s]=new _(s,1,!1,o,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(o){var s=o.replace(j,x);E[s]=new _(s,1,!1,o,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(o){var s=o.replace(j,x);E[s]=new _(s,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 H(o,s,u,m){var y=E.hasOwnProperty(s)?E[s]:null;(y!==null?y.type!==0:m||!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(b(s,u,y,m)&&(u=null),m||y===null?h(s)&&(u===null?o.removeAttribute(s):o.setAttribute(s,""+u)):y.mustUseProperty?o[y.propertyName]=u===null?y.type===3?!1:"":u:(s=y.attributeName,m=y.attributeNamespace,u===null?o.removeAttribute(s):(y=y.type,u=y===3||y===4&&u===!0?"":""+u,m?o.setAttributeNS(m,s,u):o.setAttribute(s,u))))}var B=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,re=Symbol.for("react.element"),F=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),I=Symbol.for("react.profiler"),Z=Symbol.for("react.provider"),V=Symbol.for("react.context"),K=Symbol.for("react.forward_ref"),le=Symbol.for("react.suspense"),de=Symbol.for("react.suspense_list"),Q=Symbol.for("react.memo"),ce=Symbol.for("react.lazy"),R=Symbol.for("react.offscreen"),M=Symbol.iterator;function G(o){return o===null||typeof o!="object"?null:(o=M&&o[M]||o["@@iterator"],typeof o=="function"?o:null)}var ne=Object.assign,O;function ee(o){if(O===void 0)try{throw Error()}catch(u){var s=u.stack.trim().match(/\n( *(at )?)/);O=s&&s[1]||""}return`
89
+ `+O+o}var D=!1;function q(o,s){if(!o||D)return"";D=!0;var u=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(s)if(s=function(){throw Error()},Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(ae){var m=ae}Reflect.construct(o,[],s)}else{try{s.call()}catch(ae){m=ae}o.call(s.prototype)}else{try{throw Error()}catch(ae){m=ae}o()}}catch(ae){if(ae&&m&&typeof ae.stack=="string"){for(var y=ae.stack.split(`
90
+ `),w=m.stack.split(`
91
+ `),S=y.length-1,P=w.length-1;1<=S&&0<=P&&y[S]!==w[P];)P--;for(;1<=S&&0<=P;S--,P--)if(y[S]!==w[P]){if(S!==1||P!==1)do if(S--,P--,0>P||y[S]!==w[P]){var W=`
92
+ `+y[S].replace(" at new "," at ");return o.displayName&&W.includes("<anonymous>")&&(W=W.replace("<anonymous>",o.displayName)),W}while(1<=S&&0<=P);break}}}finally{D=!1,Error.prepareStackTrace=u}return(o=o?o.displayName||o.name:"")?ee(o):""}function Te(o){switch(o.tag){case 5:return ee(o.type);case 16:return ee("Lazy");case 13:return ee("Suspense");case 19:return ee("SuspenseList");case 0:case 2:case 15:return o=q(o.type,!1),o;case 11:return o=q(o.type.render,!1),o;case 1:return o=q(o.type,!0),o;default:return""}}function Ne(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 C:return"Fragment";case F:return"Portal";case I:return"Profiler";case L:return"StrictMode";case le:return"Suspense";case de:return"SuspenseList"}if(typeof o=="object")switch(o.$$typeof){case V:return(o.displayName||"Context")+".Consumer";case Z:return(o._context.displayName||"Context")+".Provider";case K:var s=o.render;return o=o.displayName,o||(o=s.displayName||s.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case Q:return s=o.displayName||null,s!==null?s:Ne(o.type)||"Memo";case ce:s=o._payload,o=o._init;try{return Ne(o(s))}catch{}}return null}function je(o){var s=o.type;switch(o.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return o=s.render,o=o.displayName||o.name||"",s.displayName||(o!==""?"ForwardRef("+o+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ne(s);case 8:return s===L?"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 s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function Re(o){switch(typeof o){case"boolean":case"number":case"string":case"undefined":return o;case"object":return o;default:return""}}function Ze(o){var s=o.type;return(o=o.nodeName)&&o.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function st(o){var s=Ze(o)?"checked":"value",u=Object.getOwnPropertyDescriptor(o.constructor.prototype,s),m=""+o[s];if(!o.hasOwnProperty(s)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var y=u.get,w=u.set;return Object.defineProperty(o,s,{configurable:!0,get:function(){return y.call(this)},set:function(S){m=""+S,w.call(this,S)}}),Object.defineProperty(o,s,{enumerable:u.enumerable}),{getValue:function(){return m},setValue:function(S){m=""+S},stopTracking:function(){o._valueTracker=null,delete o[s]}}}}function Ee(o){o._valueTracker||(o._valueTracker=st(o))}function Tt(o){if(!o)return!1;var s=o._valueTracker;if(!s)return!0;var u=s.getValue(),m="";return o&&(m=Ze(o)?o.checked?"true":"false":o.value),o=m,o!==u?(s.setValue(o),!0):!1}function zt(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 Xe(o,s){var u=s.checked;return ne({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:u??o._wrapperState.initialChecked})}function pt(o,s){var u=s.defaultValue==null?"":s.defaultValue,m=s.checked!=null?s.checked:s.defaultChecked;u=Re(s.value!=null?s.value:u),o._wrapperState={initialChecked:m,initialValue:u,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function ht(o,s){s=s.checked,s!=null&&H(o,"checked",s,!1)}function wn(o,s){ht(o,s);var u=Re(s.value),m=s.type;if(u!=null)m==="number"?(u===0&&o.value===""||o.value!=u)&&(o.value=""+u):o.value!==""+u&&(o.value=""+u);else if(m==="submit"||m==="reset"){o.removeAttribute("value");return}s.hasOwnProperty("value")?Ft(o,s.type,u):s.hasOwnProperty("defaultValue")&&Ft(o,s.type,Re(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(o.defaultChecked=!!s.defaultChecked)}function jt(o,s,u){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var m=s.type;if(!(m!=="submit"&&m!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+o._wrapperState.initialValue,u||s===o.value||(o.value=s),o.defaultValue=s}u=o.name,u!==""&&(o.name=""),o.defaultChecked=!!o._wrapperState.initialChecked,u!==""&&(o.name=u)}function Ft(o,s,u){(s!=="number"||zt(o.ownerDocument)!==o)&&(u==null?o.defaultValue=""+o._wrapperState.initialValue:o.defaultValue!==""+u&&(o.defaultValue=""+u))}var te=Array.isArray;function pe(o,s,u,m){if(o=o.options,s){s={};for(var y=0;y<u.length;y++)s["$"+u[y]]=!0;for(u=0;u<o.length;u++)y=s.hasOwnProperty("$"+o[u].value),o[u].selected!==y&&(o[u].selected=y),y&&m&&(o[u].defaultSelected=!0)}else{for(u=""+Re(u),s=null,y=0;y<o.length;y++){if(o[y].value===u){o[y].selected=!0,m&&(o[y].defaultSelected=!0);return}s!==null||o[y].disabled||(s=o[y])}s!==null&&(s.selected=!0)}}function rt(o,s){if(s.dangerouslySetInnerHTML!=null)throw Error(n(91));return ne({},s,{value:void 0,defaultValue:void 0,children:""+o._wrapperState.initialValue})}function at(o,s){var u=s.value;if(u==null){if(u=s.children,s=s.defaultValue,u!=null){if(s!=null)throw Error(n(92));if(te(u)){if(1<u.length)throw Error(n(93));u=u[0]}s=u}s==null&&(s=""),u=s}o._wrapperState={initialValue:Re(u)}}function ut(o,s){var u=Re(s.value),m=Re(s.defaultValue);u!=null&&(u=""+u,u!==o.value&&(o.value=u),s.defaultValue==null&&o.defaultValue!==u&&(o.defaultValue=u)),m!=null&&(o.defaultValue=""+m)}function tn(o){var s=o.textContent;s===o._wrapperState.initialValue&&s!==""&&s!==null&&(o.value=s)}function Kt(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 tt(o,s){return o==null||o==="http://www.w3.org/1999/xhtml"?Kt(s):o==="http://www.w3.org/2000/svg"&&s==="foreignObject"?"http://www.w3.org/1999/xhtml":o}var qe,nn=(function(o){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(s,u,m,y){MSApp.execUnsafeLocalFunction(function(){return o(s,u,m,y)})}:o})(function(o,s){if(o.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in o)o.innerHTML=s;else{for(qe=qe||document.createElement("div"),qe.innerHTML="<svg>"+s.valueOf().toString()+"</svg>",s=qe.firstChild;o.firstChild;)o.removeChild(o.firstChild);for(;s.firstChild;)o.appendChild(s.firstChild)}});function ie(o,s){if(s){var u=o.firstChild;if(u&&u===o.lastChild&&u.nodeType===3){u.nodeValue=s;return}}o.textContent=s}var he={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},lt=["Webkit","ms","Moz","O"];Object.keys(he).forEach(function(o){lt.forEach(function(s){s=s+o.charAt(0).toUpperCase()+o.substring(1),he[s]=he[o]})});function At(o,s,u){return s==null||typeof s=="boolean"||s===""?"":u||typeof s!="number"||s===0||he.hasOwnProperty(o)&&he[o]?(""+s).trim():s+"px"}function bt(o,s){o=o.style;for(var u in s)if(s.hasOwnProperty(u)){var m=u.indexOf("--")===0,y=At(u,s[u],m);u==="float"&&(u="cssFloat"),m?o.setProperty(u,y):o[u]=y}}var Qt=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 vr(o,s){if(s){if(Qt[o]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(n(137,o));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(n(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(n(61))}if(s.style!=null&&typeof s.style!="object")throw Error(n(62))}}function bn(o,s){if(o.indexOf("-")===-1)return typeof s.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 Tn=null;function Kn(o){return o=o.target||o.srcElement||window,o.correspondingUseElement&&(o=o.correspondingUseElement),o.nodeType===3?o.parentNode:o}var lr=null,Pt=null,xt=null;function hn(o){if(o=pa(o)){if(typeof lr!="function")throw Error(n(280));var s=o.stateNode;s&&(s=Pl(s),lr(o.stateNode,o.type,s))}}function N(o){Pt?xt?xt.push(o):xt=[o]:Pt=o}function X(){if(Pt){var o=Pt,s=xt;if(xt=Pt=null,hn(o),s)for(o=0;o<s.length;o++)hn(s[o])}}function me(o,s){return o(s)}function xe(){}var We=!1;function gt(o,s,u){if(We)return o(s,u);We=!0;try{return me(o,s,u)}finally{We=!1,(Pt!==null||xt!==null)&&(xe(),X())}}function Ce(o,s){var u=o.stateNode;if(u===null)return null;var m=Pl(u);if(m===null)return null;u=m[s];e:switch(s){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(u&&typeof u!="function")throw Error(n(231,s,typeof u));return u}var ge=!1;if(c)try{var De={};Object.defineProperty(De,"passive",{get:function(){ge=!0}}),window.addEventListener("test",De,De),window.removeEventListener("test",De,De)}catch{ge=!1}function Ue(o,s,u,m,y,w,S,P,W){var ae=Array.prototype.slice.call(arguments,3);try{s.apply(u,ae)}catch(ve){this.onError(ve)}}var kt=!1,Gn=null,xn=!1,Cn=null,cr={onError:function(o){kt=!0,Gn=o}};function ur(o,s,u,m,y,w,S,P,W){kt=!1,Gn=null,Ue.apply(cr,arguments)}function io(o,s,u,m,y,w,S,P,W){if(ur.apply(this,arguments),kt){if(kt){var ae=Gn;kt=!1,Gn=null}else throw Error(n(198));xn||(xn=!0,Cn=ae)}}function wr(o){var s=o,u=o;if(o.alternate)for(;s.return;)s=s.return;else{o=s;do s=o,(s.flags&4098)!==0&&(u=s.return),o=s.return;while(o)}return s.tag===3?u:null}function yt(o){if(o.tag===13){var s=o.memoizedState;if(s===null&&(o=o.alternate,o!==null&&(s=o.memoizedState)),s!==null)return s.dehydrated}return null}function Ot(o){if(wr(o)!==o)throw Error(n(188))}function Qn(o){var s=o.alternate;if(!s){if(s=wr(o),s===null)throw Error(n(188));return s!==o?null:o}for(var u=o,m=s;;){var y=u.return;if(y===null)break;var w=y.alternate;if(w===null){if(m=y.return,m!==null){u=m;continue}break}if(y.child===w.child){for(w=y.child;w;){if(w===u)return Ot(y),o;if(w===m)return Ot(y),s;w=w.sibling}throw Error(n(188))}if(u.return!==m.return)u=y,m=w;else{for(var S=!1,P=y.child;P;){if(P===u){S=!0,u=y,m=w;break}if(P===m){S=!0,m=y,u=w;break}P=P.sibling}if(!S){for(P=w.child;P;){if(P===u){S=!0,u=w,m=y;break}if(P===m){S=!0,m=w,u=y;break}P=P.sibling}if(!S)throw Error(n(189))}}if(u.alternate!==m)throw Error(n(190))}if(u.tag!==3)throw Error(n(188));return u.stateNode.current===u?o:s}function Gr(o){return o=Qn(o),o!==null?bo(o):null}function bo(o){if(o.tag===5||o.tag===6)return o;for(o=o.child;o!==null;){var s=bo(o);if(s!==null)return s;o=o.sibling}return null}var dr=t.unstable_scheduleCallback,Dn=t.unstable_cancelCallback,fr=t.unstable_shouldYield,so=t.unstable_requestPaint,Gt=t.unstable_now,xo=t.unstable_getCurrentPriorityLevel,_o=t.unstable_ImmediatePriority,kn=t.unstable_UserBlockingPriority,Vr=t.unstable_NormalPriority,we=t.unstable_LowPriority,Ae=t.unstable_IdlePriority,ot=null,it=null;function Vt(o){if(it&&typeof it.onCommitFiberRoot=="function")try{it.onCommitFiberRoot(ot,o,void 0,(o.current.flags&128)===128)}catch{}}var Bt=Math.clz32?Math.clz32:cn,jn=Math.log,Mr=Math.LN2;function cn(o){return o>>>=0,o===0?32:31-(jn(o)/Mr|0)|0}var mn=64,br=4194304;function zn(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 pr(o,s){var u=o.pendingLanes;if(u===0)return 0;var m=0,y=o.suspendedLanes,w=o.pingedLanes,S=u&268435455;if(S!==0){var P=S&~y;P!==0?m=zn(P):(w&=S,w!==0&&(m=zn(w)))}else S=u&~y,S!==0?m=zn(S):w!==0&&(m=zn(w));if(m===0)return 0;if(s!==0&&s!==m&&(s&y)===0&&(y=m&-m,w=s&-s,y>=w||y===16&&(w&4194240)!==0))return s;if((m&4)!==0&&(m|=u&16),s=o.entangledLanes,s!==0)for(o=o.entanglements,s&=m;0<s;)u=31-Bt(s),y=1<<u,m|=o[u],s&=~y;return m}function Xn(o,s){switch(o){case 1:case 2:case 4:return s+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 s+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 yn(o,s){for(var u=o.suspendedLanes,m=o.pingedLanes,y=o.expirationTimes,w=o.pendingLanes;0<w;){var S=31-Bt(w),P=1<<S,W=y[S];W===-1?((P&u)===0||(P&m)!==0)&&(y[S]=Xn(P,s)):W<=s&&(o.expiredLanes|=P),w&=~P}}function xr(o){return o=o.pendingLanes&-1073741825,o!==0?o:o&1073741824?1073741824:0}function Ti(){var o=mn;return mn<<=1,(mn&4194240)===0&&(mn=64),o}function _r(o){for(var s=[],u=0;31>u;u++)s.push(o);return s}function Jn(o,s,u){o.pendingLanes|=s,s!==536870912&&(o.suspendedLanes=0,o.pingedLanes=0),o=o.eventTimes,s=31-Bt(s),o[s]=u}function Fn(o,s){var u=o.pendingLanes&~s;o.pendingLanes=s,o.suspendedLanes=0,o.pingedLanes=0,o.expiredLanes&=s,o.mutableReadLanes&=s,o.entangledLanes&=s,s=o.entanglements;var m=o.eventTimes;for(o=o.expirationTimes;0<u;){var y=31-Bt(u),w=1<<y;s[y]=0,m[y]=-1,o[y]=-1,u&=~w}}function Eo(o,s){var u=o.entangledLanes|=s;for(o=o.entanglements;u;){var m=31-Bt(u),y=1<<m;y&s|o[m]&s&&(o[m]|=s),u&=~y}}var vt=0;function ze(o){return o&=-o,1<o?4<o?(o&268435455)!==0?16:536870912:4:1}var Ro,Xt,Nt,Er,Bn,ye=!1,A=[],$=null,J=null,ue=null,be=new Map,Ie=new Map,et=[],U="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 Me(o,s){switch(o){case"focusin":case"focusout":$=null;break;case"dragenter":case"dragleave":J=null;break;case"mouseover":case"mouseout":ue=null;break;case"pointerover":case"pointerout":be.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ie.delete(s.pointerId)}}function Je(o,s,u,m,y,w){return o===null||o.nativeEvent!==w?(o={blockedOn:s,domEventName:u,eventSystemFlags:m,nativeEvent:w,targetContainers:[y]},s!==null&&(s=pa(s),s!==null&&Xt(s)),o):(o.eventSystemFlags|=m,s=o.targetContainers,y!==null&&s.indexOf(y)===-1&&s.push(y),o)}function An(o,s,u,m,y){switch(s){case"focusin":return $=Je($,o,s,u,m,y),!0;case"dragenter":return J=Je(J,o,s,u,m,y),!0;case"mouseover":return ue=Je(ue,o,s,u,m,y),!0;case"pointerover":var w=y.pointerId;return be.set(w,Je(be.get(w)||null,o,s,u,m,y)),!0;case"gotpointercapture":return w=y.pointerId,Ie.set(w,Je(Ie.get(w)||null,o,s,u,m,y)),!0}return!1}function qt(o){var s=Ci(o.target);if(s!==null){var u=wr(s);if(u!==null){if(s=u.tag,s===13){if(s=yt(u),s!==null){o.blockedOn=s,Bn(o.priority,function(){Nt(u)});return}}else if(s===3&&u.stateNode.current.memoizedState.isDehydrated){o.blockedOn=u.tag===3?u.stateNode.containerInfo:null;return}}}o.blockedOn=null}function Oo(o){if(o.blockedOn!==null)return!1;for(var s=o.targetContainers;0<s.length;){var u=Qu(o.domEventName,o.eventSystemFlags,s[0],o.nativeEvent);if(u===null){u=o.nativeEvent;var m=new u.constructor(u.type,u);Tn=m,u.target.dispatchEvent(m),Tn=null}else return s=pa(u),s!==null&&Xt(s),o.blockedOn=u,!1;s.shift()}return!0}function ea(o,s,u){Oo(o)&&u.delete(s)}function qu(){ye=!1,$!==null&&Oo($)&&($=null),J!==null&&Oo(J)&&(J=null),ue!==null&&Oo(ue)&&(ue=null),be.forEach(ea),Ie.forEach(ea)}function So(o,s){o.blockedOn===s&&(o.blockedOn=null,ye||(ye=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,qu)))}function ta(o){function s(y){return So(y,o)}if(0<A.length){So(A[0],o);for(var u=1;u<A.length;u++){var m=A[u];m.blockedOn===o&&(m.blockedOn=null)}}for($!==null&&So($,o),J!==null&&So(J,o),ue!==null&&So(ue,o),be.forEach(s),Ie.forEach(s),u=0;u<et.length;u++)m=et[u],m.blockedOn===o&&(m.blockedOn=null);for(;0<et.length&&(u=et[0],u.blockedOn===null);)qt(u),u.blockedOn===null&&et.shift()}var ns=B.ReactCurrentBatchConfig,_l=!0;function bx(o,s,u,m){var y=vt,w=ns.transition;ns.transition=null;try{vt=1,Yu(o,s,u,m)}finally{vt=y,ns.transition=w}}function xx(o,s,u,m){var y=vt,w=ns.transition;ns.transition=null;try{vt=4,Yu(o,s,u,m)}finally{vt=y,ns.transition=w}}function Yu(o,s,u,m){if(_l){var y=Qu(o,s,u,m);if(y===null)hd(o,s,m,El,u),Me(o,m);else if(An(y,o,s,u,m))m.stopPropagation();else if(Me(o,m),s&4&&-1<U.indexOf(o)){for(;y!==null;){var w=pa(y);if(w!==null&&Ro(w),w=Qu(o,s,u,m),w===null&&hd(o,s,m,El,u),w===y)break;y=w}y!==null&&m.stopPropagation()}else hd(o,s,m,null,u)}}var El=null;function Qu(o,s,u,m){if(El=null,o=Kn(m),o=Ci(o),o!==null)if(s=wr(o),s===null)o=null;else if(u=s.tag,u===13){if(o=yt(s),o!==null)return o;o=null}else if(u===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;o=null}else s!==o&&(o=null);return El=o,null}function Yh(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(xo()){case _o:return 1;case kn:return 4;case Vr:case we:return 16;case Ae:return 536870912;default:return 16}default:return 16}}var Qo=null,Xu=null,Sl=null;function Qh(){if(Sl)return Sl;var o,s=Xu,u=s.length,m,y="value"in Qo?Qo.value:Qo.textContent,w=y.length;for(o=0;o<u&&s[o]===y[o];o++);var S=u-o;for(m=1;m<=S&&s[u-m]===y[w-m];m++);return Sl=y.slice(o,1<m?1-m:void 0)}function Nl(o){var s=o.keyCode;return"charCode"in o?(o=o.charCode,o===0&&s===13&&(o=13)):o=s,o===10&&(o=13),32<=o||o===13?o:0}function Tl(){return!0}function Xh(){return!1}function Pr(o){function s(u,m,y,w,S){this._reactName=u,this._targetInst=y,this.type=m,this.nativeEvent=w,this.target=S,this.currentTarget=null;for(var P in o)o.hasOwnProperty(P)&&(u=o[P],this[P]=u?u(w):w[P]);return this.isDefaultPrevented=(w.defaultPrevented!=null?w.defaultPrevented:w.returnValue===!1)?Tl:Xh,this.isPropagationStopped=Xh,this}return ne(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var u=this.nativeEvent;u&&(u.preventDefault?u.preventDefault():typeof u.returnValue!="unknown"&&(u.returnValue=!1),this.isDefaultPrevented=Tl)},stopPropagation:function(){var u=this.nativeEvent;u&&(u.stopPropagation?u.stopPropagation():typeof u.cancelBubble!="unknown"&&(u.cancelBubble=!0),this.isPropagationStopped=Tl)},persist:function(){},isPersistent:Tl}),s}var rs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(o){return o.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ju=Pr(rs),na=ne({},rs,{view:0,detail:0}),_x=Pr(na),ed,td,ra,Cl=ne({},na,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:rd,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!==ra&&(ra&&o.type==="mousemove"?(ed=o.screenX-ra.screenX,td=o.screenY-ra.screenY):td=ed=0,ra=o),ed)},movementY:function(o){return"movementY"in o?o.movementY:td}}),Jh=Pr(Cl),Ex=ne({},Cl,{dataTransfer:0}),Sx=Pr(Ex),Nx=ne({},na,{relatedTarget:0}),nd=Pr(Nx),Tx=ne({},rs,{animationName:0,elapsedTime:0,pseudoElement:0}),Cx=Pr(Tx),jx=ne({},rs,{clipboardData:function(o){return"clipboardData"in o?o.clipboardData:window.clipboardData}}),Ax=Pr(jx),Ix=ne({},rs,{data:0}),em=Pr(Ix),Rx={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ox={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"},$x={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Mx(o){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(o):(o=$x[o])?!!s[o]:!1}function rd(){return Mx}var Px=ne({},na,{key:function(o){if(o.key){var s=Rx[o.key]||o.key;if(s!=="Unidentified")return s}return o.type==="keypress"?(o=Nl(o),o===13?"Enter":String.fromCharCode(o)):o.type==="keydown"||o.type==="keyup"?Ox[o.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:rd,charCode:function(o){return o.type==="keypress"?Nl(o):0},keyCode:function(o){return o.type==="keydown"||o.type==="keyup"?o.keyCode:0},which:function(o){return o.type==="keypress"?Nl(o):o.type==="keydown"||o.type==="keyup"?o.keyCode:0}}),Lx=Pr(Px),Dx=ne({},Cl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),tm=Pr(Dx),zx=ne({},na,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:rd}),Fx=Pr(zx),Bx=ne({},rs,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ux=Pr(Bx),Hx=ne({},Cl,{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}),Zx=Pr(Hx),Wx=[9,13,27,32],od=c&&"CompositionEvent"in window,oa=null;c&&"documentMode"in document&&(oa=document.documentMode);var Kx=c&&"TextEvent"in window&&!oa,nm=c&&(!od||oa&&8<oa&&11>=oa),rm=" ",om=!1;function im(o,s){switch(o){case"keyup":return Wx.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function sm(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var os=!1;function Gx(o,s){switch(o){case"compositionend":return sm(s);case"keypress":return s.which!==32?null:(om=!0,rm);case"textInput":return o=s.data,o===rm&&om?null:o;default:return null}}function Vx(o,s){if(os)return o==="compositionend"||!od&&im(o,s)?(o=Qh(),Sl=Xu=Qo=null,os=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return nm&&s.locale!=="ko"?null:s.data;default:return null}}var qx={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 am(o){var s=o&&o.nodeName&&o.nodeName.toLowerCase();return s==="input"?!!qx[o.type]:s==="textarea"}function lm(o,s,u,m){N(m),s=Ol(s,"onChange"),0<s.length&&(u=new Ju("onChange","change",null,u,m),o.push({event:u,listeners:s}))}var ia=null,sa=null;function Yx(o){Nm(o,0)}function jl(o){var s=cs(o);if(Tt(s))return o}function Qx(o,s){if(o==="change")return s}var cm=!1;if(c){var id;if(c){var sd="oninput"in document;if(!sd){var um=document.createElement("div");um.setAttribute("oninput","return;"),sd=typeof um.oninput=="function"}id=sd}else id=!1;cm=id&&(!document.documentMode||9<document.documentMode)}function dm(){ia&&(ia.detachEvent("onpropertychange",fm),sa=ia=null)}function fm(o){if(o.propertyName==="value"&&jl(sa)){var s=[];lm(s,sa,o,Kn(o)),gt(Yx,s)}}function Xx(o,s,u){o==="focusin"?(dm(),ia=s,sa=u,ia.attachEvent("onpropertychange",fm)):o==="focusout"&&dm()}function Jx(o){if(o==="selectionchange"||o==="keyup"||o==="keydown")return jl(sa)}function e_(o,s){if(o==="click")return jl(s)}function t_(o,s){if(o==="input"||o==="change")return jl(s)}function n_(o,s){return o===s&&(o!==0||1/o===1/s)||o!==o&&s!==s}var ao=typeof Object.is=="function"?Object.is:n_;function aa(o,s){if(ao(o,s))return!0;if(typeof o!="object"||o===null||typeof s!="object"||s===null)return!1;var u=Object.keys(o),m=Object.keys(s);if(u.length!==m.length)return!1;for(m=0;m<u.length;m++){var y=u[m];if(!d.call(s,y)||!ao(o[y],s[y]))return!1}return!0}function pm(o){for(;o&&o.firstChild;)o=o.firstChild;return o}function hm(o,s){var u=pm(o);o=0;for(var m;u;){if(u.nodeType===3){if(m=o+u.textContent.length,o<=s&&m>=s)return{node:u,offset:s-o};o=m}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=pm(u)}}function mm(o,s){return o&&s?o===s?!0:o&&o.nodeType===3?!1:s&&s.nodeType===3?mm(o,s.parentNode):"contains"in o?o.contains(s):o.compareDocumentPosition?!!(o.compareDocumentPosition(s)&16):!1:!1}function gm(){for(var o=window,s=zt();s instanceof o.HTMLIFrameElement;){try{var u=typeof s.contentWindow.location.href=="string"}catch{u=!1}if(u)o=s.contentWindow;else break;s=zt(o.document)}return s}function ad(o){var s=o&&o.nodeName&&o.nodeName.toLowerCase();return s&&(s==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||s==="textarea"||o.contentEditable==="true")}function r_(o){var s=gm(),u=o.focusedElem,m=o.selectionRange;if(s!==u&&u&&u.ownerDocument&&mm(u.ownerDocument.documentElement,u)){if(m!==null&&ad(u)){if(s=m.start,o=m.end,o===void 0&&(o=s),"selectionStart"in u)u.selectionStart=s,u.selectionEnd=Math.min(o,u.value.length);else if(o=(s=u.ownerDocument||document)&&s.defaultView||window,o.getSelection){o=o.getSelection();var y=u.textContent.length,w=Math.min(m.start,y);m=m.end===void 0?w:Math.min(m.end,y),!o.extend&&w>m&&(y=m,m=w,w=y),y=hm(u,w);var S=hm(u,m);y&&S&&(o.rangeCount!==1||o.anchorNode!==y.node||o.anchorOffset!==y.offset||o.focusNode!==S.node||o.focusOffset!==S.offset)&&(s=s.createRange(),s.setStart(y.node,y.offset),o.removeAllRanges(),w>m?(o.addRange(s),o.extend(S.node,S.offset)):(s.setEnd(S.node,S.offset),o.addRange(s)))}}for(s=[],o=u;o=o.parentNode;)o.nodeType===1&&s.push({element:o,left:o.scrollLeft,top:o.scrollTop});for(typeof u.focus=="function"&&u.focus(),u=0;u<s.length;u++)o=s[u],o.element.scrollLeft=o.left,o.element.scrollTop=o.top}}var o_=c&&"documentMode"in document&&11>=document.documentMode,is=null,ld=null,la=null,cd=!1;function km(o,s,u){var m=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;cd||is==null||is!==zt(m)||(m=is,"selectionStart"in m&&ad(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}),la&&aa(la,m)||(la=m,m=Ol(ld,"onSelect"),0<m.length&&(s=new Ju("onSelect","select",null,s,u),o.push({event:s,listeners:m}),s.target=is)))}function Al(o,s){var u={};return u[o.toLowerCase()]=s.toLowerCase(),u["Webkit"+o]="webkit"+s,u["Moz"+o]="moz"+s,u}var ss={animationend:Al("Animation","AnimationEnd"),animationiteration:Al("Animation","AnimationIteration"),animationstart:Al("Animation","AnimationStart"),transitionend:Al("Transition","TransitionEnd")},ud={},ym={};c&&(ym=document.createElement("div").style,"AnimationEvent"in window||(delete ss.animationend.animation,delete ss.animationiteration.animation,delete ss.animationstart.animation),"TransitionEvent"in window||delete ss.transitionend.transition);function Il(o){if(ud[o])return ud[o];if(!ss[o])return o;var s=ss[o],u;for(u in s)if(s.hasOwnProperty(u)&&u in ym)return ud[o]=s[u];return o}var vm=Il("animationend"),wm=Il("animationiteration"),bm=Il("animationstart"),xm=Il("transitionend"),_m=new Map,Em="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 Xo(o,s){_m.set(o,s),a(s,[o])}for(var dd=0;dd<Em.length;dd++){var fd=Em[dd],i_=fd.toLowerCase(),s_=fd[0].toUpperCase()+fd.slice(1);Xo(i_,"on"+s_)}Xo(vm,"onAnimationEnd"),Xo(wm,"onAnimationIteration"),Xo(bm,"onAnimationStart"),Xo("dblclick","onDoubleClick"),Xo("focusin","onFocus"),Xo("focusout","onBlur"),Xo(xm,"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 ca="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(" "),a_=new Set("cancel close invalid load scroll toggle".split(" ").concat(ca));function Sm(o,s,u){var m=o.type||"unknown-event";o.currentTarget=u,io(m,s,void 0,o),o.currentTarget=null}function Nm(o,s){s=(s&4)!==0;for(var u=0;u<o.length;u++){var m=o[u],y=m.event;m=m.listeners;e:{var w=void 0;if(s)for(var S=m.length-1;0<=S;S--){var P=m[S],W=P.instance,ae=P.currentTarget;if(P=P.listener,W!==w&&y.isPropagationStopped())break e;Sm(y,P,ae),w=W}else for(S=0;S<m.length;S++){if(P=m[S],W=P.instance,ae=P.currentTarget,P=P.listener,W!==w&&y.isPropagationStopped())break e;Sm(y,P,ae),w=W}}}if(xn)throw o=Cn,xn=!1,Cn=null,o}function rn(o,s){var u=s[wd];u===void 0&&(u=s[wd]=new Set);var m=o+"__bubble";u.has(m)||(Tm(s,o,2,!1),u.add(m))}function pd(o,s,u){var m=0;s&&(m|=4),Tm(u,o,m,s)}var Rl="_reactListening"+Math.random().toString(36).slice(2);function ua(o){if(!o[Rl]){o[Rl]=!0,r.forEach(function(u){u!=="selectionchange"&&(a_.has(u)||pd(u,!1,o),pd(u,!0,o))});var s=o.nodeType===9?o:o.ownerDocument;s===null||s[Rl]||(s[Rl]=!0,pd("selectionchange",!1,s))}}function Tm(o,s,u,m){switch(Yh(s)){case 1:var y=bx;break;case 4:y=xx;break;default:y=Yu}u=y.bind(null,s,u,o),y=void 0,!ge||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(y=!0),m?y!==void 0?o.addEventListener(s,u,{capture:!0,passive:y}):o.addEventListener(s,u,!0):y!==void 0?o.addEventListener(s,u,{passive:y}):o.addEventListener(s,u,!1)}function hd(o,s,u,m,y){var w=m;if((s&1)===0&&(s&2)===0&&m!==null)e:for(;;){if(m===null)return;var S=m.tag;if(S===3||S===4){var P=m.stateNode.containerInfo;if(P===y||P.nodeType===8&&P.parentNode===y)break;if(S===4)for(S=m.return;S!==null;){var W=S.tag;if((W===3||W===4)&&(W=S.stateNode.containerInfo,W===y||W.nodeType===8&&W.parentNode===y))return;S=S.return}for(;P!==null;){if(S=Ci(P),S===null)return;if(W=S.tag,W===5||W===6){m=w=S;continue e}P=P.parentNode}}m=m.return}gt(function(){var ae=w,ve=Kn(u),_e=[];e:{var ke=_m.get(o);if(ke!==void 0){var Oe=Ju,Le=o;switch(o){case"keypress":if(Nl(u)===0)break e;case"keydown":case"keyup":Oe=Lx;break;case"focusin":Le="focus",Oe=nd;break;case"focusout":Le="blur",Oe=nd;break;case"beforeblur":case"afterblur":Oe=nd;break;case"click":if(u.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Oe=Jh;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Oe=Sx;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Oe=Fx;break;case vm:case wm:case bm:Oe=Cx;break;case xm:Oe=Ux;break;case"scroll":Oe=_x;break;case"wheel":Oe=Zx;break;case"copy":case"cut":case"paste":Oe=Ax;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Oe=tm}var Fe=(s&4)!==0,vn=!Fe&&o==="scroll",oe=Fe?ke!==null?ke+"Capture":null:ke;Fe=[];for(var Y=ae,se;Y!==null;){se=Y;var Se=se.stateNode;if(se.tag===5&&Se!==null&&(se=Se,oe!==null&&(Se=Ce(Y,oe),Se!=null&&Fe.push(da(Y,Se,se)))),vn)break;Y=Y.return}0<Fe.length&&(ke=new Oe(ke,Le,null,u,ve),_e.push({event:ke,listeners:Fe}))}}if((s&7)===0){e:{if(ke=o==="mouseover"||o==="pointerover",Oe=o==="mouseout"||o==="pointerout",ke&&u!==Tn&&(Le=u.relatedTarget||u.fromElement)&&(Ci(Le)||Le[$o]))break e;if((Oe||ke)&&(ke=ve.window===ve?ve:(ke=ve.ownerDocument)?ke.defaultView||ke.parentWindow:window,Oe?(Le=u.relatedTarget||u.toElement,Oe=ae,Le=Le?Ci(Le):null,Le!==null&&(vn=wr(Le),Le!==vn||Le.tag!==5&&Le.tag!==6)&&(Le=null)):(Oe=null,Le=ae),Oe!==Le)){if(Fe=Jh,Se="onMouseLeave",oe="onMouseEnter",Y="mouse",(o==="pointerout"||o==="pointerover")&&(Fe=tm,Se="onPointerLeave",oe="onPointerEnter",Y="pointer"),vn=Oe==null?ke:cs(Oe),se=Le==null?ke:cs(Le),ke=new Fe(Se,Y+"leave",Oe,u,ve),ke.target=vn,ke.relatedTarget=se,Se=null,Ci(ve)===ae&&(Fe=new Fe(oe,Y+"enter",Le,u,ve),Fe.target=se,Fe.relatedTarget=vn,Se=Fe),vn=Se,Oe&&Le)t:{for(Fe=Oe,oe=Le,Y=0,se=Fe;se;se=as(se))Y++;for(se=0,Se=oe;Se;Se=as(Se))se++;for(;0<Y-se;)Fe=as(Fe),Y--;for(;0<se-Y;)oe=as(oe),se--;for(;Y--;){if(Fe===oe||oe!==null&&Fe===oe.alternate)break t;Fe=as(Fe),oe=as(oe)}Fe=null}else Fe=null;Oe!==null&&Cm(_e,ke,Oe,Fe,!1),Le!==null&&vn!==null&&Cm(_e,vn,Le,Fe,!0)}}e:{if(ke=ae?cs(ae):window,Oe=ke.nodeName&&ke.nodeName.toLowerCase(),Oe==="select"||Oe==="input"&&ke.type==="file")var Be=Qx;else if(am(ke))if(cm)Be=t_;else{Be=Jx;var Ye=Xx}else(Oe=ke.nodeName)&&Oe.toLowerCase()==="input"&&(ke.type==="checkbox"||ke.type==="radio")&&(Be=e_);if(Be&&(Be=Be(o,ae))){lm(_e,Be,u,ve);break e}Ye&&Ye(o,ke,ae),o==="focusout"&&(Ye=ke._wrapperState)&&Ye.controlled&&ke.type==="number"&&Ft(ke,"number",ke.value)}switch(Ye=ae?cs(ae):window,o){case"focusin":(am(Ye)||Ye.contentEditable==="true")&&(is=Ye,ld=ae,la=null);break;case"focusout":la=ld=is=null;break;case"mousedown":cd=!0;break;case"contextmenu":case"mouseup":case"dragend":cd=!1,km(_e,u,ve);break;case"selectionchange":if(o_)break;case"keydown":case"keyup":km(_e,u,ve)}var Qe;if(od)e:{switch(o){case"compositionstart":var nt="onCompositionStart";break e;case"compositionend":nt="onCompositionEnd";break e;case"compositionupdate":nt="onCompositionUpdate";break e}nt=void 0}else os?im(o,u)&&(nt="onCompositionEnd"):o==="keydown"&&u.keyCode===229&&(nt="onCompositionStart");nt&&(nm&&u.locale!=="ko"&&(os||nt!=="onCompositionStart"?nt==="onCompositionEnd"&&os&&(Qe=Qh()):(Qo=ve,Xu="value"in Qo?Qo.value:Qo.textContent,os=!0)),Ye=Ol(ae,nt),0<Ye.length&&(nt=new em(nt,o,null,u,ve),_e.push({event:nt,listeners:Ye}),Qe?nt.data=Qe:(Qe=sm(u),Qe!==null&&(nt.data=Qe)))),(Qe=Kx?Gx(o,u):Vx(o,u))&&(ae=Ol(ae,"onBeforeInput"),0<ae.length&&(ve=new em("onBeforeInput","beforeinput",null,u,ve),_e.push({event:ve,listeners:ae}),ve.data=Qe))}Nm(_e,s)})}function da(o,s,u){return{instance:o,listener:s,currentTarget:u}}function Ol(o,s){for(var u=s+"Capture",m=[];o!==null;){var y=o,w=y.stateNode;y.tag===5&&w!==null&&(y=w,w=Ce(o,u),w!=null&&m.unshift(da(o,w,y)),w=Ce(o,s),w!=null&&m.push(da(o,w,y))),o=o.return}return m}function as(o){if(o===null)return null;do o=o.return;while(o&&o.tag!==5);return o||null}function Cm(o,s,u,m,y){for(var w=s._reactName,S=[];u!==null&&u!==m;){var P=u,W=P.alternate,ae=P.stateNode;if(W!==null&&W===m)break;P.tag===5&&ae!==null&&(P=ae,y?(W=Ce(u,w),W!=null&&S.unshift(da(u,W,P))):y||(W=Ce(u,w),W!=null&&S.push(da(u,W,P)))),u=u.return}S.length!==0&&o.push({event:s,listeners:S})}var l_=/\r\n?/g,c_=/\u0000|\uFFFD/g;function jm(o){return(typeof o=="string"?o:""+o).replace(l_,`
93
+ `).replace(c_,"")}function $l(o,s,u){if(s=jm(s),jm(o)!==s&&u)throw Error(n(425))}function Ml(){}var md=null,gd=null;function kd(o,s){return o==="textarea"||o==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var yd=typeof setTimeout=="function"?setTimeout:void 0,u_=typeof clearTimeout=="function"?clearTimeout:void 0,Am=typeof Promise=="function"?Promise:void 0,d_=typeof queueMicrotask=="function"?queueMicrotask:typeof Am<"u"?function(o){return Am.resolve(null).then(o).catch(f_)}:yd;function f_(o){setTimeout(function(){throw o})}function vd(o,s){var u=s,m=0;do{var y=u.nextSibling;if(o.removeChild(u),y&&y.nodeType===8)if(u=y.data,u==="/$"){if(m===0){o.removeChild(y),ta(s);return}m--}else u!=="$"&&u!=="$?"&&u!=="$!"||m++;u=y}while(u);ta(s)}function Jo(o){for(;o!=null;o=o.nextSibling){var s=o.nodeType;if(s===1||s===3)break;if(s===8){if(s=o.data,s==="$"||s==="$!"||s==="$?")break;if(s==="/$")return null}}return o}function Im(o){o=o.previousSibling;for(var s=0;o;){if(o.nodeType===8){var u=o.data;if(u==="$"||u==="$!"||u==="$?"){if(s===0)return o;s--}else u==="/$"&&s++}o=o.previousSibling}return null}var ls=Math.random().toString(36).slice(2),No="__reactFiber$"+ls,fa="__reactProps$"+ls,$o="__reactContainer$"+ls,wd="__reactEvents$"+ls,p_="__reactListeners$"+ls,h_="__reactHandles$"+ls;function Ci(o){var s=o[No];if(s)return s;for(var u=o.parentNode;u;){if(s=u[$o]||u[No]){if(u=s.alternate,s.child!==null||u!==null&&u.child!==null)for(o=Im(o);o!==null;){if(u=o[No])return u;o=Im(o)}return s}o=u,u=o.parentNode}return null}function pa(o){return o=o[No]||o[$o],!o||o.tag!==5&&o.tag!==6&&o.tag!==13&&o.tag!==3?null:o}function cs(o){if(o.tag===5||o.tag===6)return o.stateNode;throw Error(n(33))}function Pl(o){return o[fa]||null}var bd=[],us=-1;function ei(o){return{current:o}}function on(o){0>us||(o.current=bd[us],bd[us]=null,us--)}function Jt(o,s){us++,bd[us]=o.current,o.current=s}var ti={},er=ei(ti),Sr=ei(!1),ji=ti;function ds(o,s){var u=o.type.contextTypes;if(!u)return ti;var m=o.stateNode;if(m&&m.__reactInternalMemoizedUnmaskedChildContext===s)return m.__reactInternalMemoizedMaskedChildContext;var y={},w;for(w in u)y[w]=s[w];return m&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=s,o.__reactInternalMemoizedMaskedChildContext=y),y}function Nr(o){return o=o.childContextTypes,o!=null}function Ll(){on(Sr),on(er)}function Rm(o,s,u){if(er.current!==ti)throw Error(n(168));Jt(er,s),Jt(Sr,u)}function Om(o,s,u){var m=o.stateNode;if(s=s.childContextTypes,typeof m.getChildContext!="function")return u;m=m.getChildContext();for(var y in m)if(!(y in s))throw Error(n(108,je(o)||"Unknown",y));return ne({},u,m)}function Dl(o){return o=(o=o.stateNode)&&o.__reactInternalMemoizedMergedChildContext||ti,ji=er.current,Jt(er,o),Jt(Sr,Sr.current),!0}function $m(o,s,u){var m=o.stateNode;if(!m)throw Error(n(169));u?(o=Om(o,s,ji),m.__reactInternalMemoizedMergedChildContext=o,on(Sr),on(er),Jt(er,o)):on(Sr),Jt(Sr,u)}var Mo=null,zl=!1,xd=!1;function Mm(o){Mo===null?Mo=[o]:Mo.push(o)}function m_(o){zl=!0,Mm(o)}function ni(){if(!xd&&Mo!==null){xd=!0;var o=0,s=vt;try{var u=Mo;for(vt=1;o<u.length;o++){var m=u[o];do m=m(!0);while(m!==null)}Mo=null,zl=!1}catch(y){throw Mo!==null&&(Mo=Mo.slice(o+1)),dr(_o,ni),y}finally{vt=s,xd=!1}}return null}var fs=[],ps=0,Fl=null,Bl=0,qr=[],Yr=0,Ai=null,Po=1,Lo="";function Ii(o,s){fs[ps++]=Bl,fs[ps++]=Fl,Fl=o,Bl=s}function Pm(o,s,u){qr[Yr++]=Po,qr[Yr++]=Lo,qr[Yr++]=Ai,Ai=o;var m=Po;o=Lo;var y=32-Bt(m)-1;m&=~(1<<y),u+=1;var w=32-Bt(s)+y;if(30<w){var S=y-y%5;w=(m&(1<<S)-1).toString(32),m>>=S,y-=S,Po=1<<32-Bt(s)+y|u<<y|m,Lo=w+o}else Po=1<<w|u<<y|m,Lo=o}function _d(o){o.return!==null&&(Ii(o,1),Pm(o,1,0))}function Ed(o){for(;o===Fl;)Fl=fs[--ps],fs[ps]=null,Bl=fs[--ps],fs[ps]=null;for(;o===Ai;)Ai=qr[--Yr],qr[Yr]=null,Lo=qr[--Yr],qr[Yr]=null,Po=qr[--Yr],qr[Yr]=null}var Lr=null,Dr=null,sn=!1,lo=null;function Lm(o,s){var u=eo(5,null,null,0);u.elementType="DELETED",u.stateNode=s,u.return=o,s=o.deletions,s===null?(o.deletions=[u],o.flags|=16):s.push(u)}function Dm(o,s){switch(o.tag){case 5:var u=o.type;return s=s.nodeType!==1||u.toLowerCase()!==s.nodeName.toLowerCase()?null:s,s!==null?(o.stateNode=s,Lr=o,Dr=Jo(s.firstChild),!0):!1;case 6:return s=o.pendingProps===""||s.nodeType!==3?null:s,s!==null?(o.stateNode=s,Lr=o,Dr=null,!0):!1;case 13:return s=s.nodeType!==8?null:s,s!==null?(u=Ai!==null?{id:Po,overflow:Lo}:null,o.memoizedState={dehydrated:s,treeContext:u,retryLane:1073741824},u=eo(18,null,null,0),u.stateNode=s,u.return=o,o.child=u,Lr=o,Dr=null,!0):!1;default:return!1}}function Sd(o){return(o.mode&1)!==0&&(o.flags&128)===0}function Nd(o){if(sn){var s=Dr;if(s){var u=s;if(!Dm(o,s)){if(Sd(o))throw Error(n(418));s=Jo(u.nextSibling);var m=Lr;s&&Dm(o,s)?Lm(m,u):(o.flags=o.flags&-4097|2,sn=!1,Lr=o)}}else{if(Sd(o))throw Error(n(418));o.flags=o.flags&-4097|2,sn=!1,Lr=o}}}function zm(o){for(o=o.return;o!==null&&o.tag!==5&&o.tag!==3&&o.tag!==13;)o=o.return;Lr=o}function Ul(o){if(o!==Lr)return!1;if(!sn)return zm(o),sn=!0,!1;var s;if((s=o.tag!==3)&&!(s=o.tag!==5)&&(s=o.type,s=s!=="head"&&s!=="body"&&!kd(o.type,o.memoizedProps)),s&&(s=Dr)){if(Sd(o))throw Fm(),Error(n(418));for(;s;)Lm(o,s),s=Jo(s.nextSibling)}if(zm(o),o.tag===13){if(o=o.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(n(317));e:{for(o=o.nextSibling,s=0;o;){if(o.nodeType===8){var u=o.data;if(u==="/$"){if(s===0){Dr=Jo(o.nextSibling);break e}s--}else u!=="$"&&u!=="$!"&&u!=="$?"||s++}o=o.nextSibling}Dr=null}}else Dr=Lr?Jo(o.stateNode.nextSibling):null;return!0}function Fm(){for(var o=Dr;o;)o=Jo(o.nextSibling)}function hs(){Dr=Lr=null,sn=!1}function Td(o){lo===null?lo=[o]:lo.push(o)}var g_=B.ReactCurrentBatchConfig;function ha(o,s,u){if(o=u.ref,o!==null&&typeof o!="function"&&typeof o!="object"){if(u._owner){if(u=u._owner,u){if(u.tag!==1)throw Error(n(309));var m=u.stateNode}if(!m)throw Error(n(147,o));var y=m,w=""+o;return s!==null&&s.ref!==null&&typeof s.ref=="function"&&s.ref._stringRef===w?s.ref:(s=function(S){var P=y.refs;S===null?delete P[w]:P[w]=S},s._stringRef=w,s)}if(typeof o!="string")throw Error(n(284));if(!u._owner)throw Error(n(290,o))}return o}function Hl(o,s){throw o=Object.prototype.toString.call(s),Error(n(31,o==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":o))}function Bm(o){var s=o._init;return s(o._payload)}function Um(o){function s(oe,Y){if(o){var se=oe.deletions;se===null?(oe.deletions=[Y],oe.flags|=16):se.push(Y)}}function u(oe,Y){if(!o)return null;for(;Y!==null;)s(oe,Y),Y=Y.sibling;return null}function m(oe,Y){for(oe=new Map;Y!==null;)Y.key!==null?oe.set(Y.key,Y):oe.set(Y.index,Y),Y=Y.sibling;return oe}function y(oe,Y){return oe=ui(oe,Y),oe.index=0,oe.sibling=null,oe}function w(oe,Y,se){return oe.index=se,o?(se=oe.alternate,se!==null?(se=se.index,se<Y?(oe.flags|=2,Y):se):(oe.flags|=2,Y)):(oe.flags|=1048576,Y)}function S(oe){return o&&oe.alternate===null&&(oe.flags|=2),oe}function P(oe,Y,se,Se){return Y===null||Y.tag!==6?(Y=vf(se,oe.mode,Se),Y.return=oe,Y):(Y=y(Y,se),Y.return=oe,Y)}function W(oe,Y,se,Se){var Be=se.type;return Be===C?ve(oe,Y,se.props.children,Se,se.key):Y!==null&&(Y.elementType===Be||typeof Be=="object"&&Be!==null&&Be.$$typeof===ce&&Bm(Be)===Y.type)?(Se=y(Y,se.props),Se.ref=ha(oe,Y,se),Se.return=oe,Se):(Se=pc(se.type,se.key,se.props,null,oe.mode,Se),Se.ref=ha(oe,Y,se),Se.return=oe,Se)}function ae(oe,Y,se,Se){return Y===null||Y.tag!==4||Y.stateNode.containerInfo!==se.containerInfo||Y.stateNode.implementation!==se.implementation?(Y=wf(se,oe.mode,Se),Y.return=oe,Y):(Y=y(Y,se.children||[]),Y.return=oe,Y)}function ve(oe,Y,se,Se,Be){return Y===null||Y.tag!==7?(Y=zi(se,oe.mode,Se,Be),Y.return=oe,Y):(Y=y(Y,se),Y.return=oe,Y)}function _e(oe,Y,se){if(typeof Y=="string"&&Y!==""||typeof Y=="number")return Y=vf(""+Y,oe.mode,se),Y.return=oe,Y;if(typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case re:return se=pc(Y.type,Y.key,Y.props,null,oe.mode,se),se.ref=ha(oe,null,Y),se.return=oe,se;case F:return Y=wf(Y,oe.mode,se),Y.return=oe,Y;case ce:var Se=Y._init;return _e(oe,Se(Y._payload),se)}if(te(Y)||G(Y))return Y=zi(Y,oe.mode,se,null),Y.return=oe,Y;Hl(oe,Y)}return null}function ke(oe,Y,se,Se){var Be=Y!==null?Y.key:null;if(typeof se=="string"&&se!==""||typeof se=="number")return Be!==null?null:P(oe,Y,""+se,Se);if(typeof se=="object"&&se!==null){switch(se.$$typeof){case re:return se.key===Be?W(oe,Y,se,Se):null;case F:return se.key===Be?ae(oe,Y,se,Se):null;case ce:return Be=se._init,ke(oe,Y,Be(se._payload),Se)}if(te(se)||G(se))return Be!==null?null:ve(oe,Y,se,Se,null);Hl(oe,se)}return null}function Oe(oe,Y,se,Se,Be){if(typeof Se=="string"&&Se!==""||typeof Se=="number")return oe=oe.get(se)||null,P(Y,oe,""+Se,Be);if(typeof Se=="object"&&Se!==null){switch(Se.$$typeof){case re:return oe=oe.get(Se.key===null?se:Se.key)||null,W(Y,oe,Se,Be);case F:return oe=oe.get(Se.key===null?se:Se.key)||null,ae(Y,oe,Se,Be);case ce:var Ye=Se._init;return Oe(oe,Y,se,Ye(Se._payload),Be)}if(te(Se)||G(Se))return oe=oe.get(se)||null,ve(Y,oe,Se,Be,null);Hl(Y,Se)}return null}function Le(oe,Y,se,Se){for(var Be=null,Ye=null,Qe=Y,nt=Y=0,Zn=null;Qe!==null&&nt<se.length;nt++){Qe.index>nt?(Zn=Qe,Qe=null):Zn=Qe.sibling;var Lt=ke(oe,Qe,se[nt],Se);if(Lt===null){Qe===null&&(Qe=Zn);break}o&&Qe&&Lt.alternate===null&&s(oe,Qe),Y=w(Lt,Y,nt),Ye===null?Be=Lt:Ye.sibling=Lt,Ye=Lt,Qe=Zn}if(nt===se.length)return u(oe,Qe),sn&&Ii(oe,nt),Be;if(Qe===null){for(;nt<se.length;nt++)Qe=_e(oe,se[nt],Se),Qe!==null&&(Y=w(Qe,Y,nt),Ye===null?Be=Qe:Ye.sibling=Qe,Ye=Qe);return sn&&Ii(oe,nt),Be}for(Qe=m(oe,Qe);nt<se.length;nt++)Zn=Oe(Qe,oe,nt,se[nt],Se),Zn!==null&&(o&&Zn.alternate!==null&&Qe.delete(Zn.key===null?nt:Zn.key),Y=w(Zn,Y,nt),Ye===null?Be=Zn:Ye.sibling=Zn,Ye=Zn);return o&&Qe.forEach(function(di){return s(oe,di)}),sn&&Ii(oe,nt),Be}function Fe(oe,Y,se,Se){var Be=G(se);if(typeof Be!="function")throw Error(n(150));if(se=Be.call(se),se==null)throw Error(n(151));for(var Ye=Be=null,Qe=Y,nt=Y=0,Zn=null,Lt=se.next();Qe!==null&&!Lt.done;nt++,Lt=se.next()){Qe.index>nt?(Zn=Qe,Qe=null):Zn=Qe.sibling;var di=ke(oe,Qe,Lt.value,Se);if(di===null){Qe===null&&(Qe=Zn);break}o&&Qe&&di.alternate===null&&s(oe,Qe),Y=w(di,Y,nt),Ye===null?Be=di:Ye.sibling=di,Ye=di,Qe=Zn}if(Lt.done)return u(oe,Qe),sn&&Ii(oe,nt),Be;if(Qe===null){for(;!Lt.done;nt++,Lt=se.next())Lt=_e(oe,Lt.value,Se),Lt!==null&&(Y=w(Lt,Y,nt),Ye===null?Be=Lt:Ye.sibling=Lt,Ye=Lt);return sn&&Ii(oe,nt),Be}for(Qe=m(oe,Qe);!Lt.done;nt++,Lt=se.next())Lt=Oe(Qe,oe,nt,Lt.value,Se),Lt!==null&&(o&&Lt.alternate!==null&&Qe.delete(Lt.key===null?nt:Lt.key),Y=w(Lt,Y,nt),Ye===null?Be=Lt:Ye.sibling=Lt,Ye=Lt);return o&&Qe.forEach(function(q_){return s(oe,q_)}),sn&&Ii(oe,nt),Be}function vn(oe,Y,se,Se){if(typeof se=="object"&&se!==null&&se.type===C&&se.key===null&&(se=se.props.children),typeof se=="object"&&se!==null){switch(se.$$typeof){case re:e:{for(var Be=se.key,Ye=Y;Ye!==null;){if(Ye.key===Be){if(Be=se.type,Be===C){if(Ye.tag===7){u(oe,Ye.sibling),Y=y(Ye,se.props.children),Y.return=oe,oe=Y;break e}}else if(Ye.elementType===Be||typeof Be=="object"&&Be!==null&&Be.$$typeof===ce&&Bm(Be)===Ye.type){u(oe,Ye.sibling),Y=y(Ye,se.props),Y.ref=ha(oe,Ye,se),Y.return=oe,oe=Y;break e}u(oe,Ye);break}else s(oe,Ye);Ye=Ye.sibling}se.type===C?(Y=zi(se.props.children,oe.mode,Se,se.key),Y.return=oe,oe=Y):(Se=pc(se.type,se.key,se.props,null,oe.mode,Se),Se.ref=ha(oe,Y,se),Se.return=oe,oe=Se)}return S(oe);case F:e:{for(Ye=se.key;Y!==null;){if(Y.key===Ye)if(Y.tag===4&&Y.stateNode.containerInfo===se.containerInfo&&Y.stateNode.implementation===se.implementation){u(oe,Y.sibling),Y=y(Y,se.children||[]),Y.return=oe,oe=Y;break e}else{u(oe,Y);break}else s(oe,Y);Y=Y.sibling}Y=wf(se,oe.mode,Se),Y.return=oe,oe=Y}return S(oe);case ce:return Ye=se._init,vn(oe,Y,Ye(se._payload),Se)}if(te(se))return Le(oe,Y,se,Se);if(G(se))return Fe(oe,Y,se,Se);Hl(oe,se)}return typeof se=="string"&&se!==""||typeof se=="number"?(se=""+se,Y!==null&&Y.tag===6?(u(oe,Y.sibling),Y=y(Y,se),Y.return=oe,oe=Y):(u(oe,Y),Y=vf(se,oe.mode,Se),Y.return=oe,oe=Y),S(oe)):u(oe,Y)}return vn}var ms=Um(!0),Hm=Um(!1),Zl=ei(null),Wl=null,gs=null,Cd=null;function jd(){Cd=gs=Wl=null}function Ad(o){var s=Zl.current;on(Zl),o._currentValue=s}function Id(o,s,u){for(;o!==null;){var m=o.alternate;if((o.childLanes&s)!==s?(o.childLanes|=s,m!==null&&(m.childLanes|=s)):m!==null&&(m.childLanes&s)!==s&&(m.childLanes|=s),o===u)break;o=o.return}}function ks(o,s){Wl=o,Cd=gs=null,o=o.dependencies,o!==null&&o.firstContext!==null&&((o.lanes&s)!==0&&(Tr=!0),o.firstContext=null)}function Qr(o){var s=o._currentValue;if(Cd!==o)if(o={context:o,memoizedValue:s,next:null},gs===null){if(Wl===null)throw Error(n(308));gs=o,Wl.dependencies={lanes:0,firstContext:o}}else gs=gs.next=o;return s}var Ri=null;function Rd(o){Ri===null?Ri=[o]:Ri.push(o)}function Zm(o,s,u,m){var y=s.interleaved;return y===null?(u.next=u,Rd(s)):(u.next=y.next,y.next=u),s.interleaved=u,Do(o,m)}function Do(o,s){o.lanes|=s;var u=o.alternate;for(u!==null&&(u.lanes|=s),u=o,o=o.return;o!==null;)o.childLanes|=s,u=o.alternate,u!==null&&(u.childLanes|=s),u=o,o=o.return;return u.tag===3?u.stateNode:null}var ri=!1;function Od(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Wm(o,s){o=o.updateQueue,s.updateQueue===o&&(s.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,effects:o.effects})}function zo(o,s){return{eventTime:o,lane:s,tag:0,payload:null,callback:null,next:null}}function oi(o,s,u){var m=o.updateQueue;if(m===null)return null;if(m=m.shared,($t&2)!==0){var y=m.pending;return y===null?s.next=s:(s.next=y.next,y.next=s),m.pending=s,Do(o,u)}return y=m.interleaved,y===null?(s.next=s,Rd(m)):(s.next=y.next,y.next=s),m.interleaved=s,Do(o,u)}function Kl(o,s,u){if(s=s.updateQueue,s!==null&&(s=s.shared,(u&4194240)!==0)){var m=s.lanes;m&=o.pendingLanes,u|=m,s.lanes=u,Eo(o,u)}}function Km(o,s){var u=o.updateQueue,m=o.alternate;if(m!==null&&(m=m.updateQueue,u===m)){var y=null,w=null;if(u=u.firstBaseUpdate,u!==null){do{var S={eventTime:u.eventTime,lane:u.lane,tag:u.tag,payload:u.payload,callback:u.callback,next:null};w===null?y=w=S:w=w.next=S,u=u.next}while(u!==null);w===null?y=w=s:w=w.next=s}else y=w=s;u={baseState:m.baseState,firstBaseUpdate:y,lastBaseUpdate:w,shared:m.shared,effects:m.effects},o.updateQueue=u;return}o=u.lastBaseUpdate,o===null?u.firstBaseUpdate=s:o.next=s,u.lastBaseUpdate=s}function Gl(o,s,u,m){var y=o.updateQueue;ri=!1;var w=y.firstBaseUpdate,S=y.lastBaseUpdate,P=y.shared.pending;if(P!==null){y.shared.pending=null;var W=P,ae=W.next;W.next=null,S===null?w=ae:S.next=ae,S=W;var ve=o.alternate;ve!==null&&(ve=ve.updateQueue,P=ve.lastBaseUpdate,P!==S&&(P===null?ve.firstBaseUpdate=ae:P.next=ae,ve.lastBaseUpdate=W))}if(w!==null){var _e=y.baseState;S=0,ve=ae=W=null,P=w;do{var ke=P.lane,Oe=P.eventTime;if((m&ke)===ke){ve!==null&&(ve=ve.next={eventTime:Oe,lane:0,tag:P.tag,payload:P.payload,callback:P.callback,next:null});e:{var Le=o,Fe=P;switch(ke=s,Oe=u,Fe.tag){case 1:if(Le=Fe.payload,typeof Le=="function"){_e=Le.call(Oe,_e,ke);break e}_e=Le;break e;case 3:Le.flags=Le.flags&-65537|128;case 0:if(Le=Fe.payload,ke=typeof Le=="function"?Le.call(Oe,_e,ke):Le,ke==null)break e;_e=ne({},_e,ke);break e;case 2:ri=!0}}P.callback!==null&&P.lane!==0&&(o.flags|=64,ke=y.effects,ke===null?y.effects=[P]:ke.push(P))}else Oe={eventTime:Oe,lane:ke,tag:P.tag,payload:P.payload,callback:P.callback,next:null},ve===null?(ae=ve=Oe,W=_e):ve=ve.next=Oe,S|=ke;if(P=P.next,P===null){if(P=y.shared.pending,P===null)break;ke=P,P=ke.next,ke.next=null,y.lastBaseUpdate=ke,y.shared.pending=null}}while(!0);if(ve===null&&(W=_e),y.baseState=W,y.firstBaseUpdate=ae,y.lastBaseUpdate=ve,s=y.shared.interleaved,s!==null){y=s;do S|=y.lane,y=y.next;while(y!==s)}else w===null&&(y.shared.lanes=0);Mi|=S,o.lanes=S,o.memoizedState=_e}}function Gm(o,s,u){if(o=s.effects,s.effects=null,o!==null)for(s=0;s<o.length;s++){var m=o[s],y=m.callback;if(y!==null){if(m.callback=null,m=u,typeof y!="function")throw Error(n(191,y));y.call(m)}}}var ma={},To=ei(ma),ga=ei(ma),ka=ei(ma);function Oi(o){if(o===ma)throw Error(n(174));return o}function $d(o,s){switch(Jt(ka,s),Jt(ga,o),Jt(To,ma),o=s.nodeType,o){case 9:case 11:s=(s=s.documentElement)?s.namespaceURI:tt(null,"");break;default:o=o===8?s.parentNode:s,s=o.namespaceURI||null,o=o.tagName,s=tt(s,o)}on(To),Jt(To,s)}function ys(){on(To),on(ga),on(ka)}function Vm(o){Oi(ka.current);var s=Oi(To.current),u=tt(s,o.type);s!==u&&(Jt(ga,o),Jt(To,u))}function Md(o){ga.current===o&&(on(To),on(ga))}var un=ei(0);function Vl(o){for(var s=o;s!==null;){if(s.tag===13){var u=s.memoizedState;if(u!==null&&(u=u.dehydrated,u===null||u.data==="$?"||u.data==="$!"))return s}else if(s.tag===19&&s.memoizedProps.revealOrder!==void 0){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===o)break;for(;s.sibling===null;){if(s.return===null||s.return===o)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var Pd=[];function Ld(){for(var o=0;o<Pd.length;o++)Pd[o]._workInProgressVersionPrimary=null;Pd.length=0}var ql=B.ReactCurrentDispatcher,Dd=B.ReactCurrentBatchConfig,$i=0,dn=null,In=null,Un=null,Yl=!1,ya=!1,va=0,k_=0;function tr(){throw Error(n(321))}function zd(o,s){if(s===null)return!1;for(var u=0;u<s.length&&u<o.length;u++)if(!ao(o[u],s[u]))return!1;return!0}function Fd(o,s,u,m,y,w){if($i=w,dn=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,ql.current=o===null||o.memoizedState===null?b_:x_,o=u(m,y),ya){w=0;do{if(ya=!1,va=0,25<=w)throw Error(n(301));w+=1,Un=In=null,s.updateQueue=null,ql.current=__,o=u(m,y)}while(ya)}if(ql.current=Jl,s=In!==null&&In.next!==null,$i=0,Un=In=dn=null,Yl=!1,s)throw Error(n(300));return o}function Bd(){var o=va!==0;return va=0,o}function Co(){var o={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Un===null?dn.memoizedState=Un=o:Un=Un.next=o,Un}function Xr(){if(In===null){var o=dn.alternate;o=o!==null?o.memoizedState:null}else o=In.next;var s=Un===null?dn.memoizedState:Un.next;if(s!==null)Un=s,In=o;else{if(o===null)throw Error(n(310));In=o,o={memoizedState:In.memoizedState,baseState:In.baseState,baseQueue:In.baseQueue,queue:In.queue,next:null},Un===null?dn.memoizedState=Un=o:Un=Un.next=o}return Un}function wa(o,s){return typeof s=="function"?s(o):s}function Ud(o){var s=Xr(),u=s.queue;if(u===null)throw Error(n(311));u.lastRenderedReducer=o;var m=In,y=m.baseQueue,w=u.pending;if(w!==null){if(y!==null){var S=y.next;y.next=w.next,w.next=S}m.baseQueue=y=w,u.pending=null}if(y!==null){w=y.next,m=m.baseState;var P=S=null,W=null,ae=w;do{var ve=ae.lane;if(($i&ve)===ve)W!==null&&(W=W.next={lane:0,action:ae.action,hasEagerState:ae.hasEagerState,eagerState:ae.eagerState,next:null}),m=ae.hasEagerState?ae.eagerState:o(m,ae.action);else{var _e={lane:ve,action:ae.action,hasEagerState:ae.hasEagerState,eagerState:ae.eagerState,next:null};W===null?(P=W=_e,S=m):W=W.next=_e,dn.lanes|=ve,Mi|=ve}ae=ae.next}while(ae!==null&&ae!==w);W===null?S=m:W.next=P,ao(m,s.memoizedState)||(Tr=!0),s.memoizedState=m,s.baseState=S,s.baseQueue=W,u.lastRenderedState=m}if(o=u.interleaved,o!==null){y=o;do w=y.lane,dn.lanes|=w,Mi|=w,y=y.next;while(y!==o)}else y===null&&(u.lanes=0);return[s.memoizedState,u.dispatch]}function Hd(o){var s=Xr(),u=s.queue;if(u===null)throw Error(n(311));u.lastRenderedReducer=o;var m=u.dispatch,y=u.pending,w=s.memoizedState;if(y!==null){u.pending=null;var S=y=y.next;do w=o(w,S.action),S=S.next;while(S!==y);ao(w,s.memoizedState)||(Tr=!0),s.memoizedState=w,s.baseQueue===null&&(s.baseState=w),u.lastRenderedState=w}return[w,m]}function qm(){}function Ym(o,s){var u=dn,m=Xr(),y=s(),w=!ao(m.memoizedState,y);if(w&&(m.memoizedState=y,Tr=!0),m=m.queue,Zd(Jm.bind(null,u,m,o),[o]),m.getSnapshot!==s||w||Un!==null&&Un.memoizedState.tag&1){if(u.flags|=2048,ba(9,Xm.bind(null,u,m,y,s),void 0,null),Hn===null)throw Error(n(349));($i&30)!==0||Qm(u,s,y)}return y}function Qm(o,s,u){o.flags|=16384,o={getSnapshot:s,value:u},s=dn.updateQueue,s===null?(s={lastEffect:null,stores:null},dn.updateQueue=s,s.stores=[o]):(u=s.stores,u===null?s.stores=[o]:u.push(o))}function Xm(o,s,u,m){s.value=u,s.getSnapshot=m,eg(s)&&tg(o)}function Jm(o,s,u){return u(function(){eg(s)&&tg(o)})}function eg(o){var s=o.getSnapshot;o=o.value;try{var u=s();return!ao(o,u)}catch{return!0}}function tg(o){var s=Do(o,1);s!==null&&po(s,o,1,-1)}function ng(o){var s=Co();return typeof o=="function"&&(o=o()),s.memoizedState=s.baseState=o,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:wa,lastRenderedState:o},s.queue=o,o=o.dispatch=w_.bind(null,dn,o),[s.memoizedState,o]}function ba(o,s,u,m){return o={tag:o,create:s,destroy:u,deps:m,next:null},s=dn.updateQueue,s===null?(s={lastEffect:null,stores:null},dn.updateQueue=s,s.lastEffect=o.next=o):(u=s.lastEffect,u===null?s.lastEffect=o.next=o:(m=u.next,u.next=o,o.next=m,s.lastEffect=o)),o}function rg(){return Xr().memoizedState}function Ql(o,s,u,m){var y=Co();dn.flags|=o,y.memoizedState=ba(1|s,u,void 0,m===void 0?null:m)}function Xl(o,s,u,m){var y=Xr();m=m===void 0?null:m;var w=void 0;if(In!==null){var S=In.memoizedState;if(w=S.destroy,m!==null&&zd(m,S.deps)){y.memoizedState=ba(s,u,w,m);return}}dn.flags|=o,y.memoizedState=ba(1|s,u,w,m)}function og(o,s){return Ql(8390656,8,o,s)}function Zd(o,s){return Xl(2048,8,o,s)}function ig(o,s){return Xl(4,2,o,s)}function sg(o,s){return Xl(4,4,o,s)}function ag(o,s){if(typeof s=="function")return o=o(),s(o),function(){s(null)};if(s!=null)return o=o(),s.current=o,function(){s.current=null}}function lg(o,s,u){return u=u!=null?u.concat([o]):null,Xl(4,4,ag.bind(null,s,o),u)}function Wd(){}function cg(o,s){var u=Xr();s=s===void 0?null:s;var m=u.memoizedState;return m!==null&&s!==null&&zd(s,m[1])?m[0]:(u.memoizedState=[o,s],o)}function ug(o,s){var u=Xr();s=s===void 0?null:s;var m=u.memoizedState;return m!==null&&s!==null&&zd(s,m[1])?m[0]:(o=o(),u.memoizedState=[o,s],o)}function dg(o,s,u){return($i&21)===0?(o.baseState&&(o.baseState=!1,Tr=!0),o.memoizedState=u):(ao(u,s)||(u=Ti(),dn.lanes|=u,Mi|=u,o.baseState=!0),s)}function y_(o,s){var u=vt;vt=u!==0&&4>u?u:4,o(!0);var m=Dd.transition;Dd.transition={};try{o(!1),s()}finally{vt=u,Dd.transition=m}}function fg(){return Xr().memoizedState}function v_(o,s,u){var m=li(o);if(u={lane:m,action:u,hasEagerState:!1,eagerState:null,next:null},pg(o))hg(s,u);else if(u=Zm(o,s,u,m),u!==null){var y=mr();po(u,o,m,y),mg(u,s,m)}}function w_(o,s,u){var m=li(o),y={lane:m,action:u,hasEagerState:!1,eagerState:null,next:null};if(pg(o))hg(s,y);else{var w=o.alternate;if(o.lanes===0&&(w===null||w.lanes===0)&&(w=s.lastRenderedReducer,w!==null))try{var S=s.lastRenderedState,P=w(S,u);if(y.hasEagerState=!0,y.eagerState=P,ao(P,S)){var W=s.interleaved;W===null?(y.next=y,Rd(s)):(y.next=W.next,W.next=y),s.interleaved=y;return}}catch{}finally{}u=Zm(o,s,y,m),u!==null&&(y=mr(),po(u,o,m,y),mg(u,s,m))}}function pg(o){var s=o.alternate;return o===dn||s!==null&&s===dn}function hg(o,s){ya=Yl=!0;var u=o.pending;u===null?s.next=s:(s.next=u.next,u.next=s),o.pending=s}function mg(o,s,u){if((u&4194240)!==0){var m=s.lanes;m&=o.pendingLanes,u|=m,s.lanes=u,Eo(o,u)}}var Jl={readContext:Qr,useCallback:tr,useContext:tr,useEffect:tr,useImperativeHandle:tr,useInsertionEffect:tr,useLayoutEffect:tr,useMemo:tr,useReducer:tr,useRef:tr,useState:tr,useDebugValue:tr,useDeferredValue:tr,useTransition:tr,useMutableSource:tr,useSyncExternalStore:tr,useId:tr,unstable_isNewReconciler:!1},b_={readContext:Qr,useCallback:function(o,s){return Co().memoizedState=[o,s===void 0?null:s],o},useContext:Qr,useEffect:og,useImperativeHandle:function(o,s,u){return u=u!=null?u.concat([o]):null,Ql(4194308,4,ag.bind(null,s,o),u)},useLayoutEffect:function(o,s){return Ql(4194308,4,o,s)},useInsertionEffect:function(o,s){return Ql(4,2,o,s)},useMemo:function(o,s){var u=Co();return s=s===void 0?null:s,o=o(),u.memoizedState=[o,s],o},useReducer:function(o,s,u){var m=Co();return s=u!==void 0?u(s):s,m.memoizedState=m.baseState=s,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:s},m.queue=o,o=o.dispatch=v_.bind(null,dn,o),[m.memoizedState,o]},useRef:function(o){var s=Co();return o={current:o},s.memoizedState=o},useState:ng,useDebugValue:Wd,useDeferredValue:function(o){return Co().memoizedState=o},useTransition:function(){var o=ng(!1),s=o[0];return o=y_.bind(null,o[1]),Co().memoizedState=o,[s,o]},useMutableSource:function(){},useSyncExternalStore:function(o,s,u){var m=dn,y=Co();if(sn){if(u===void 0)throw Error(n(407));u=u()}else{if(u=s(),Hn===null)throw Error(n(349));($i&30)!==0||Qm(m,s,u)}y.memoizedState=u;var w={value:u,getSnapshot:s};return y.queue=w,og(Jm.bind(null,m,w,o),[o]),m.flags|=2048,ba(9,Xm.bind(null,m,w,u,s),void 0,null),u},useId:function(){var o=Co(),s=Hn.identifierPrefix;if(sn){var u=Lo,m=Po;u=(m&~(1<<32-Bt(m)-1)).toString(32)+u,s=":"+s+"R"+u,u=va++,0<u&&(s+="H"+u.toString(32)),s+=":"}else u=k_++,s=":"+s+"r"+u.toString(32)+":";return o.memoizedState=s},unstable_isNewReconciler:!1},x_={readContext:Qr,useCallback:cg,useContext:Qr,useEffect:Zd,useImperativeHandle:lg,useInsertionEffect:ig,useLayoutEffect:sg,useMemo:ug,useReducer:Ud,useRef:rg,useState:function(){return Ud(wa)},useDebugValue:Wd,useDeferredValue:function(o){var s=Xr();return dg(s,In.memoizedState,o)},useTransition:function(){var o=Ud(wa)[0],s=Xr().memoizedState;return[o,s]},useMutableSource:qm,useSyncExternalStore:Ym,useId:fg,unstable_isNewReconciler:!1},__={readContext:Qr,useCallback:cg,useContext:Qr,useEffect:Zd,useImperativeHandle:lg,useInsertionEffect:ig,useLayoutEffect:sg,useMemo:ug,useReducer:Hd,useRef:rg,useState:function(){return Hd(wa)},useDebugValue:Wd,useDeferredValue:function(o){var s=Xr();return In===null?s.memoizedState=o:dg(s,In.memoizedState,o)},useTransition:function(){var o=Hd(wa)[0],s=Xr().memoizedState;return[o,s]},useMutableSource:qm,useSyncExternalStore:Ym,useId:fg,unstable_isNewReconciler:!1};function co(o,s){if(o&&o.defaultProps){s=ne({},s),o=o.defaultProps;for(var u in o)s[u]===void 0&&(s[u]=o[u]);return s}return s}function Kd(o,s,u,m){s=o.memoizedState,u=u(m,s),u=u==null?s:ne({},s,u),o.memoizedState=u,o.lanes===0&&(o.updateQueue.baseState=u)}var ec={isMounted:function(o){return(o=o._reactInternals)?wr(o)===o:!1},enqueueSetState:function(o,s,u){o=o._reactInternals;var m=mr(),y=li(o),w=zo(m,y);w.payload=s,u!=null&&(w.callback=u),s=oi(o,w,y),s!==null&&(po(s,o,y,m),Kl(s,o,y))},enqueueReplaceState:function(o,s,u){o=o._reactInternals;var m=mr(),y=li(o),w=zo(m,y);w.tag=1,w.payload=s,u!=null&&(w.callback=u),s=oi(o,w,y),s!==null&&(po(s,o,y,m),Kl(s,o,y))},enqueueForceUpdate:function(o,s){o=o._reactInternals;var u=mr(),m=li(o),y=zo(u,m);y.tag=2,s!=null&&(y.callback=s),s=oi(o,y,m),s!==null&&(po(s,o,m,u),Kl(s,o,m))}};function gg(o,s,u,m,y,w,S){return o=o.stateNode,typeof o.shouldComponentUpdate=="function"?o.shouldComponentUpdate(m,w,S):s.prototype&&s.prototype.isPureReactComponent?!aa(u,m)||!aa(y,w):!0}function kg(o,s,u){var m=!1,y=ti,w=s.contextType;return typeof w=="object"&&w!==null?w=Qr(w):(y=Nr(s)?ji:er.current,m=s.contextTypes,w=(m=m!=null)?ds(o,y):ti),s=new s(u,w),o.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,s.updater=ec,o.stateNode=s,s._reactInternals=o,m&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=y,o.__reactInternalMemoizedMaskedChildContext=w),s}function yg(o,s,u,m){o=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(u,m),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(u,m),s.state!==o&&ec.enqueueReplaceState(s,s.state,null)}function Gd(o,s,u,m){var y=o.stateNode;y.props=u,y.state=o.memoizedState,y.refs={},Od(o);var w=s.contextType;typeof w=="object"&&w!==null?y.context=Qr(w):(w=Nr(s)?ji:er.current,y.context=ds(o,w)),y.state=o.memoizedState,w=s.getDerivedStateFromProps,typeof w=="function"&&(Kd(o,s,w,u),y.state=o.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof y.getSnapshotBeforeUpdate=="function"||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(s=y.state,typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount(),s!==y.state&&ec.enqueueReplaceState(y,y.state,null),Gl(o,u,y,m),y.state=o.memoizedState),typeof y.componentDidMount=="function"&&(o.flags|=4194308)}function vs(o,s){try{var u="",m=s;do u+=Te(m),m=m.return;while(m);var y=u}catch(w){y=`
94
+ Error generating stack: `+w.message+`
95
+ `+w.stack}return{value:o,source:s,stack:y,digest:null}}function Vd(o,s,u){return{value:o,source:null,stack:u??null,digest:s??null}}function qd(o,s){try{console.error(s.value)}catch(u){setTimeout(function(){throw u})}}var E_=typeof WeakMap=="function"?WeakMap:Map;function vg(o,s,u){u=zo(-1,u),u.tag=3,u.payload={element:null};var m=s.value;return u.callback=function(){ac||(ac=!0,df=m),qd(o,s)},u}function wg(o,s,u){u=zo(-1,u),u.tag=3;var m=o.type.getDerivedStateFromError;if(typeof m=="function"){var y=s.value;u.payload=function(){return m(y)},u.callback=function(){qd(o,s)}}var w=o.stateNode;return w!==null&&typeof w.componentDidCatch=="function"&&(u.callback=function(){qd(o,s),typeof m!="function"&&(si===null?si=new Set([this]):si.add(this));var S=s.stack;this.componentDidCatch(s.value,{componentStack:S!==null?S:""})}),u}function bg(o,s,u){var m=o.pingCache;if(m===null){m=o.pingCache=new E_;var y=new Set;m.set(s,y)}else y=m.get(s),y===void 0&&(y=new Set,m.set(s,y));y.has(u)||(y.add(u),o=D_.bind(null,o,s,u),s.then(o,o))}function xg(o){do{var s;if((s=o.tag===13)&&(s=o.memoizedState,s=s!==null?s.dehydrated!==null:!0),s)return o;o=o.return}while(o!==null);return null}function _g(o,s,u,m,y){return(o.mode&1)===0?(o===s?o.flags|=65536:(o.flags|=128,u.flags|=131072,u.flags&=-52805,u.tag===1&&(u.alternate===null?u.tag=17:(s=zo(-1,1),s.tag=2,oi(u,s,1))),u.lanes|=1),o):(o.flags|=65536,o.lanes=y,o)}var S_=B.ReactCurrentOwner,Tr=!1;function hr(o,s,u,m){s.child=o===null?Hm(s,null,u,m):ms(s,o.child,u,m)}function Eg(o,s,u,m,y){u=u.render;var w=s.ref;return ks(s,y),m=Fd(o,s,u,m,w,y),u=Bd(),o!==null&&!Tr?(s.updateQueue=o.updateQueue,s.flags&=-2053,o.lanes&=~y,Fo(o,s,y)):(sn&&u&&_d(s),s.flags|=1,hr(o,s,m,y),s.child)}function Sg(o,s,u,m,y){if(o===null){var w=u.type;return typeof w=="function"&&!yf(w)&&w.defaultProps===void 0&&u.compare===null&&u.defaultProps===void 0?(s.tag=15,s.type=w,Ng(o,s,w,m,y)):(o=pc(u.type,null,m,s,s.mode,y),o.ref=s.ref,o.return=s,s.child=o)}if(w=o.child,(o.lanes&y)===0){var S=w.memoizedProps;if(u=u.compare,u=u!==null?u:aa,u(S,m)&&o.ref===s.ref)return Fo(o,s,y)}return s.flags|=1,o=ui(w,m),o.ref=s.ref,o.return=s,s.child=o}function Ng(o,s,u,m,y){if(o!==null){var w=o.memoizedProps;if(aa(w,m)&&o.ref===s.ref)if(Tr=!1,s.pendingProps=m=w,(o.lanes&y)!==0)(o.flags&131072)!==0&&(Tr=!0);else return s.lanes=o.lanes,Fo(o,s,y)}return Yd(o,s,u,m,y)}function Tg(o,s,u){var m=s.pendingProps,y=m.children,w=o!==null?o.memoizedState:null;if(m.mode==="hidden")if((s.mode&1)===0)s.memoizedState={baseLanes:0,cachePool:null,transitions:null},Jt(bs,zr),zr|=u;else{if((u&1073741824)===0)return o=w!==null?w.baseLanes|u:u,s.lanes=s.childLanes=1073741824,s.memoizedState={baseLanes:o,cachePool:null,transitions:null},s.updateQueue=null,Jt(bs,zr),zr|=o,null;s.memoizedState={baseLanes:0,cachePool:null,transitions:null},m=w!==null?w.baseLanes:u,Jt(bs,zr),zr|=m}else w!==null?(m=w.baseLanes|u,s.memoizedState=null):m=u,Jt(bs,zr),zr|=m;return hr(o,s,y,u),s.child}function Cg(o,s){var u=s.ref;(o===null&&u!==null||o!==null&&o.ref!==u)&&(s.flags|=512,s.flags|=2097152)}function Yd(o,s,u,m,y){var w=Nr(u)?ji:er.current;return w=ds(s,w),ks(s,y),u=Fd(o,s,u,m,w,y),m=Bd(),o!==null&&!Tr?(s.updateQueue=o.updateQueue,s.flags&=-2053,o.lanes&=~y,Fo(o,s,y)):(sn&&m&&_d(s),s.flags|=1,hr(o,s,u,y),s.child)}function jg(o,s,u,m,y){if(Nr(u)){var w=!0;Dl(s)}else w=!1;if(ks(s,y),s.stateNode===null)nc(o,s),kg(s,u,m),Gd(s,u,m,y),m=!0;else if(o===null){var S=s.stateNode,P=s.memoizedProps;S.props=P;var W=S.context,ae=u.contextType;typeof ae=="object"&&ae!==null?ae=Qr(ae):(ae=Nr(u)?ji:er.current,ae=ds(s,ae));var ve=u.getDerivedStateFromProps,_e=typeof ve=="function"||typeof S.getSnapshotBeforeUpdate=="function";_e||typeof S.UNSAFE_componentWillReceiveProps!="function"&&typeof S.componentWillReceiveProps!="function"||(P!==m||W!==ae)&&yg(s,S,m,ae),ri=!1;var ke=s.memoizedState;S.state=ke,Gl(s,m,S,y),W=s.memoizedState,P!==m||ke!==W||Sr.current||ri?(typeof ve=="function"&&(Kd(s,u,ve,m),W=s.memoizedState),(P=ri||gg(s,u,P,m,ke,W,ae))?(_e||typeof S.UNSAFE_componentWillMount!="function"&&typeof S.componentWillMount!="function"||(typeof S.componentWillMount=="function"&&S.componentWillMount(),typeof S.UNSAFE_componentWillMount=="function"&&S.UNSAFE_componentWillMount()),typeof S.componentDidMount=="function"&&(s.flags|=4194308)):(typeof S.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=m,s.memoizedState=W),S.props=m,S.state=W,S.context=ae,m=P):(typeof S.componentDidMount=="function"&&(s.flags|=4194308),m=!1)}else{S=s.stateNode,Wm(o,s),P=s.memoizedProps,ae=s.type===s.elementType?P:co(s.type,P),S.props=ae,_e=s.pendingProps,ke=S.context,W=u.contextType,typeof W=="object"&&W!==null?W=Qr(W):(W=Nr(u)?ji:er.current,W=ds(s,W));var Oe=u.getDerivedStateFromProps;(ve=typeof Oe=="function"||typeof S.getSnapshotBeforeUpdate=="function")||typeof S.UNSAFE_componentWillReceiveProps!="function"&&typeof S.componentWillReceiveProps!="function"||(P!==_e||ke!==W)&&yg(s,S,m,W),ri=!1,ke=s.memoizedState,S.state=ke,Gl(s,m,S,y);var Le=s.memoizedState;P!==_e||ke!==Le||Sr.current||ri?(typeof Oe=="function"&&(Kd(s,u,Oe,m),Le=s.memoizedState),(ae=ri||gg(s,u,ae,m,ke,Le,W)||!1)?(ve||typeof S.UNSAFE_componentWillUpdate!="function"&&typeof S.componentWillUpdate!="function"||(typeof S.componentWillUpdate=="function"&&S.componentWillUpdate(m,Le,W),typeof S.UNSAFE_componentWillUpdate=="function"&&S.UNSAFE_componentWillUpdate(m,Le,W)),typeof S.componentDidUpdate=="function"&&(s.flags|=4),typeof S.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof S.componentDidUpdate!="function"||P===o.memoizedProps&&ke===o.memoizedState||(s.flags|=4),typeof S.getSnapshotBeforeUpdate!="function"||P===o.memoizedProps&&ke===o.memoizedState||(s.flags|=1024),s.memoizedProps=m,s.memoizedState=Le),S.props=m,S.state=Le,S.context=W,m=ae):(typeof S.componentDidUpdate!="function"||P===o.memoizedProps&&ke===o.memoizedState||(s.flags|=4),typeof S.getSnapshotBeforeUpdate!="function"||P===o.memoizedProps&&ke===o.memoizedState||(s.flags|=1024),m=!1)}return Qd(o,s,u,m,w,y)}function Qd(o,s,u,m,y,w){Cg(o,s);var S=(s.flags&128)!==0;if(!m&&!S)return y&&$m(s,u,!1),Fo(o,s,w);m=s.stateNode,S_.current=s;var P=S&&typeof u.getDerivedStateFromError!="function"?null:m.render();return s.flags|=1,o!==null&&S?(s.child=ms(s,o.child,null,w),s.child=ms(s,null,P,w)):hr(o,s,P,w),s.memoizedState=m.state,y&&$m(s,u,!0),s.child}function Ag(o){var s=o.stateNode;s.pendingContext?Rm(o,s.pendingContext,s.pendingContext!==s.context):s.context&&Rm(o,s.context,!1),$d(o,s.containerInfo)}function Ig(o,s,u,m,y){return hs(),Td(y),s.flags|=256,hr(o,s,u,m),s.child}var Xd={dehydrated:null,treeContext:null,retryLane:0};function Jd(o){return{baseLanes:o,cachePool:null,transitions:null}}function Rg(o,s,u){var m=s.pendingProps,y=un.current,w=!1,S=(s.flags&128)!==0,P;if((P=S)||(P=o!==null&&o.memoizedState===null?!1:(y&2)!==0),P?(w=!0,s.flags&=-129):(o===null||o.memoizedState!==null)&&(y|=1),Jt(un,y&1),o===null)return Nd(s),o=s.memoizedState,o!==null&&(o=o.dehydrated,o!==null)?((s.mode&1)===0?s.lanes=1:o.data==="$!"?s.lanes=8:s.lanes=1073741824,null):(S=m.children,o=m.fallback,w?(m=s.mode,w=s.child,S={mode:"hidden",children:S},(m&1)===0&&w!==null?(w.childLanes=0,w.pendingProps=S):w=hc(S,m,0,null),o=zi(o,m,u,null),w.return=s,o.return=s,w.sibling=o,s.child=w,s.child.memoizedState=Jd(u),s.memoizedState=Xd,o):ef(s,S));if(y=o.memoizedState,y!==null&&(P=y.dehydrated,P!==null))return N_(o,s,S,m,P,y,u);if(w){w=m.fallback,S=s.mode,y=o.child,P=y.sibling;var W={mode:"hidden",children:m.children};return(S&1)===0&&s.child!==y?(m=s.child,m.childLanes=0,m.pendingProps=W,s.deletions=null):(m=ui(y,W),m.subtreeFlags=y.subtreeFlags&14680064),P!==null?w=ui(P,w):(w=zi(w,S,u,null),w.flags|=2),w.return=s,m.return=s,m.sibling=w,s.child=m,m=w,w=s.child,S=o.child.memoizedState,S=S===null?Jd(u):{baseLanes:S.baseLanes|u,cachePool:null,transitions:S.transitions},w.memoizedState=S,w.childLanes=o.childLanes&~u,s.memoizedState=Xd,m}return w=o.child,o=w.sibling,m=ui(w,{mode:"visible",children:m.children}),(s.mode&1)===0&&(m.lanes=u),m.return=s,m.sibling=null,o!==null&&(u=s.deletions,u===null?(s.deletions=[o],s.flags|=16):u.push(o)),s.child=m,s.memoizedState=null,m}function ef(o,s){return s=hc({mode:"visible",children:s},o.mode,0,null),s.return=o,o.child=s}function tc(o,s,u,m){return m!==null&&Td(m),ms(s,o.child,null,u),o=ef(s,s.pendingProps.children),o.flags|=2,s.memoizedState=null,o}function N_(o,s,u,m,y,w,S){if(u)return s.flags&256?(s.flags&=-257,m=Vd(Error(n(422))),tc(o,s,S,m)):s.memoizedState!==null?(s.child=o.child,s.flags|=128,null):(w=m.fallback,y=s.mode,m=hc({mode:"visible",children:m.children},y,0,null),w=zi(w,y,S,null),w.flags|=2,m.return=s,w.return=s,m.sibling=w,s.child=m,(s.mode&1)!==0&&ms(s,o.child,null,S),s.child.memoizedState=Jd(S),s.memoizedState=Xd,w);if((s.mode&1)===0)return tc(o,s,S,null);if(y.data==="$!"){if(m=y.nextSibling&&y.nextSibling.dataset,m)var P=m.dgst;return m=P,w=Error(n(419)),m=Vd(w,m,void 0),tc(o,s,S,m)}if(P=(S&o.childLanes)!==0,Tr||P){if(m=Hn,m!==null){switch(S&-S){case 4:y=2;break;case 16:y=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:y=32;break;case 536870912:y=268435456;break;default:y=0}y=(y&(m.suspendedLanes|S))!==0?0:y,y!==0&&y!==w.retryLane&&(w.retryLane=y,Do(o,y),po(m,o,y,-1))}return kf(),m=Vd(Error(n(421))),tc(o,s,S,m)}return y.data==="$?"?(s.flags|=128,s.child=o.child,s=z_.bind(null,o),y._reactRetry=s,null):(o=w.treeContext,Dr=Jo(y.nextSibling),Lr=s,sn=!0,lo=null,o!==null&&(qr[Yr++]=Po,qr[Yr++]=Lo,qr[Yr++]=Ai,Po=o.id,Lo=o.overflow,Ai=s),s=ef(s,m.children),s.flags|=4096,s)}function Og(o,s,u){o.lanes|=s;var m=o.alternate;m!==null&&(m.lanes|=s),Id(o.return,s,u)}function tf(o,s,u,m,y){var w=o.memoizedState;w===null?o.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:m,tail:u,tailMode:y}:(w.isBackwards=s,w.rendering=null,w.renderingStartTime=0,w.last=m,w.tail=u,w.tailMode=y)}function $g(o,s,u){var m=s.pendingProps,y=m.revealOrder,w=m.tail;if(hr(o,s,m.children,u),m=un.current,(m&2)!==0)m=m&1|2,s.flags|=128;else{if(o!==null&&(o.flags&128)!==0)e:for(o=s.child;o!==null;){if(o.tag===13)o.memoizedState!==null&&Og(o,u,s);else if(o.tag===19)Og(o,u,s);else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===s)break e;for(;o.sibling===null;){if(o.return===null||o.return===s)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}m&=1}if(Jt(un,m),(s.mode&1)===0)s.memoizedState=null;else switch(y){case"forwards":for(u=s.child,y=null;u!==null;)o=u.alternate,o!==null&&Vl(o)===null&&(y=u),u=u.sibling;u=y,u===null?(y=s.child,s.child=null):(y=u.sibling,u.sibling=null),tf(s,!1,y,u,w);break;case"backwards":for(u=null,y=s.child,s.child=null;y!==null;){if(o=y.alternate,o!==null&&Vl(o)===null){s.child=y;break}o=y.sibling,y.sibling=u,u=y,y=o}tf(s,!0,u,null,w);break;case"together":tf(s,!1,null,null,void 0);break;default:s.memoizedState=null}return s.child}function nc(o,s){(s.mode&1)===0&&o!==null&&(o.alternate=null,s.alternate=null,s.flags|=2)}function Fo(o,s,u){if(o!==null&&(s.dependencies=o.dependencies),Mi|=s.lanes,(u&s.childLanes)===0)return null;if(o!==null&&s.child!==o.child)throw Error(n(153));if(s.child!==null){for(o=s.child,u=ui(o,o.pendingProps),s.child=u,u.return=s;o.sibling!==null;)o=o.sibling,u=u.sibling=ui(o,o.pendingProps),u.return=s;u.sibling=null}return s.child}function T_(o,s,u){switch(s.tag){case 3:Ag(s),hs();break;case 5:Vm(s);break;case 1:Nr(s.type)&&Dl(s);break;case 4:$d(s,s.stateNode.containerInfo);break;case 10:var m=s.type._context,y=s.memoizedProps.value;Jt(Zl,m._currentValue),m._currentValue=y;break;case 13:if(m=s.memoizedState,m!==null)return m.dehydrated!==null?(Jt(un,un.current&1),s.flags|=128,null):(u&s.child.childLanes)!==0?Rg(o,s,u):(Jt(un,un.current&1),o=Fo(o,s,u),o!==null?o.sibling:null);Jt(un,un.current&1);break;case 19:if(m=(u&s.childLanes)!==0,(o.flags&128)!==0){if(m)return $g(o,s,u);s.flags|=128}if(y=s.memoizedState,y!==null&&(y.rendering=null,y.tail=null,y.lastEffect=null),Jt(un,un.current),m)break;return null;case 22:case 23:return s.lanes=0,Tg(o,s,u)}return Fo(o,s,u)}var Mg,nf,Pg,Lg;Mg=function(o,s){for(var u=s.child;u!==null;){if(u.tag===5||u.tag===6)o.appendChild(u.stateNode);else if(u.tag!==4&&u.child!==null){u.child.return=u,u=u.child;continue}if(u===s)break;for(;u.sibling===null;){if(u.return===null||u.return===s)return;u=u.return}u.sibling.return=u.return,u=u.sibling}},nf=function(){},Pg=function(o,s,u,m){var y=o.memoizedProps;if(y!==m){o=s.stateNode,Oi(To.current);var w=null;switch(u){case"input":y=Xe(o,y),m=Xe(o,m),w=[];break;case"select":y=ne({},y,{value:void 0}),m=ne({},m,{value:void 0}),w=[];break;case"textarea":y=rt(o,y),m=rt(o,m),w=[];break;default:typeof y.onClick!="function"&&typeof m.onClick=="function"&&(o.onclick=Ml)}vr(u,m);var S;u=null;for(ae in y)if(!m.hasOwnProperty(ae)&&y.hasOwnProperty(ae)&&y[ae]!=null)if(ae==="style"){var P=y[ae];for(S in P)P.hasOwnProperty(S)&&(u||(u={}),u[S]="")}else ae!=="dangerouslySetInnerHTML"&&ae!=="children"&&ae!=="suppressContentEditableWarning"&&ae!=="suppressHydrationWarning"&&ae!=="autoFocus"&&(i.hasOwnProperty(ae)?w||(w=[]):(w=w||[]).push(ae,null));for(ae in m){var W=m[ae];if(P=y!=null?y[ae]:void 0,m.hasOwnProperty(ae)&&W!==P&&(W!=null||P!=null))if(ae==="style")if(P){for(S in P)!P.hasOwnProperty(S)||W&&W.hasOwnProperty(S)||(u||(u={}),u[S]="");for(S in W)W.hasOwnProperty(S)&&P[S]!==W[S]&&(u||(u={}),u[S]=W[S])}else u||(w||(w=[]),w.push(ae,u)),u=W;else ae==="dangerouslySetInnerHTML"?(W=W?W.__html:void 0,P=P?P.__html:void 0,W!=null&&P!==W&&(w=w||[]).push(ae,W)):ae==="children"?typeof W!="string"&&typeof W!="number"||(w=w||[]).push(ae,""+W):ae!=="suppressContentEditableWarning"&&ae!=="suppressHydrationWarning"&&(i.hasOwnProperty(ae)?(W!=null&&ae==="onScroll"&&rn("scroll",o),w||P===W||(w=[])):(w=w||[]).push(ae,W))}u&&(w=w||[]).push("style",u);var ae=w;(s.updateQueue=ae)&&(s.flags|=4)}},Lg=function(o,s,u,m){u!==m&&(s.flags|=4)};function xa(o,s){if(!sn)switch(o.tailMode){case"hidden":s=o.tail;for(var u=null;s!==null;)s.alternate!==null&&(u=s),s=s.sibling;u===null?o.tail=null:u.sibling=null;break;case"collapsed":u=o.tail;for(var m=null;u!==null;)u.alternate!==null&&(m=u),u=u.sibling;m===null?s||o.tail===null?o.tail=null:o.tail.sibling=null:m.sibling=null}}function nr(o){var s=o.alternate!==null&&o.alternate.child===o.child,u=0,m=0;if(s)for(var y=o.child;y!==null;)u|=y.lanes|y.childLanes,m|=y.subtreeFlags&14680064,m|=y.flags&14680064,y.return=o,y=y.sibling;else for(y=o.child;y!==null;)u|=y.lanes|y.childLanes,m|=y.subtreeFlags,m|=y.flags,y.return=o,y=y.sibling;return o.subtreeFlags|=m,o.childLanes=u,s}function C_(o,s,u){var m=s.pendingProps;switch(Ed(s),s.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return nr(s),null;case 1:return Nr(s.type)&&Ll(),nr(s),null;case 3:return m=s.stateNode,ys(),on(Sr),on(er),Ld(),m.pendingContext&&(m.context=m.pendingContext,m.pendingContext=null),(o===null||o.child===null)&&(Ul(s)?s.flags|=4:o===null||o.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,lo!==null&&(hf(lo),lo=null))),nf(o,s),nr(s),null;case 5:Md(s);var y=Oi(ka.current);if(u=s.type,o!==null&&s.stateNode!=null)Pg(o,s,u,m,y),o.ref!==s.ref&&(s.flags|=512,s.flags|=2097152);else{if(!m){if(s.stateNode===null)throw Error(n(166));return nr(s),null}if(o=Oi(To.current),Ul(s)){m=s.stateNode,u=s.type;var w=s.memoizedProps;switch(m[No]=s,m[fa]=w,o=(s.mode&1)!==0,u){case"dialog":rn("cancel",m),rn("close",m);break;case"iframe":case"object":case"embed":rn("load",m);break;case"video":case"audio":for(y=0;y<ca.length;y++)rn(ca[y],m);break;case"source":rn("error",m);break;case"img":case"image":case"link":rn("error",m),rn("load",m);break;case"details":rn("toggle",m);break;case"input":pt(m,w),rn("invalid",m);break;case"select":m._wrapperState={wasMultiple:!!w.multiple},rn("invalid",m);break;case"textarea":at(m,w),rn("invalid",m)}vr(u,w),y=null;for(var S in w)if(w.hasOwnProperty(S)){var P=w[S];S==="children"?typeof P=="string"?m.textContent!==P&&(w.suppressHydrationWarning!==!0&&$l(m.textContent,P,o),y=["children",P]):typeof P=="number"&&m.textContent!==""+P&&(w.suppressHydrationWarning!==!0&&$l(m.textContent,P,o),y=["children",""+P]):i.hasOwnProperty(S)&&P!=null&&S==="onScroll"&&rn("scroll",m)}switch(u){case"input":Ee(m),jt(m,w,!0);break;case"textarea":Ee(m),tn(m);break;case"select":case"option":break;default:typeof w.onClick=="function"&&(m.onclick=Ml)}m=y,s.updateQueue=m,m!==null&&(s.flags|=4)}else{S=y.nodeType===9?y:y.ownerDocument,o==="http://www.w3.org/1999/xhtml"&&(o=Kt(u)),o==="http://www.w3.org/1999/xhtml"?u==="script"?(o=S.createElement("div"),o.innerHTML="<script><\/script>",o=o.removeChild(o.firstChild)):typeof m.is=="string"?o=S.createElement(u,{is:m.is}):(o=S.createElement(u),u==="select"&&(S=o,m.multiple?S.multiple=!0:m.size&&(S.size=m.size))):o=S.createElementNS(o,u),o[No]=s,o[fa]=m,Mg(o,s,!1,!1),s.stateNode=o;e:{switch(S=bn(u,m),u){case"dialog":rn("cancel",o),rn("close",o),y=m;break;case"iframe":case"object":case"embed":rn("load",o),y=m;break;case"video":case"audio":for(y=0;y<ca.length;y++)rn(ca[y],o);y=m;break;case"source":rn("error",o),y=m;break;case"img":case"image":case"link":rn("error",o),rn("load",o),y=m;break;case"details":rn("toggle",o),y=m;break;case"input":pt(o,m),y=Xe(o,m),rn("invalid",o);break;case"option":y=m;break;case"select":o._wrapperState={wasMultiple:!!m.multiple},y=ne({},m,{value:void 0}),rn("invalid",o);break;case"textarea":at(o,m),y=rt(o,m),rn("invalid",o);break;default:y=m}vr(u,y),P=y;for(w in P)if(P.hasOwnProperty(w)){var W=P[w];w==="style"?bt(o,W):w==="dangerouslySetInnerHTML"?(W=W?W.__html:void 0,W!=null&&nn(o,W)):w==="children"?typeof W=="string"?(u!=="textarea"||W!=="")&&ie(o,W):typeof W=="number"&&ie(o,""+W):w!=="suppressContentEditableWarning"&&w!=="suppressHydrationWarning"&&w!=="autoFocus"&&(i.hasOwnProperty(w)?W!=null&&w==="onScroll"&&rn("scroll",o):W!=null&&H(o,w,W,S))}switch(u){case"input":Ee(o),jt(o,m,!1);break;case"textarea":Ee(o),tn(o);break;case"option":m.value!=null&&o.setAttribute("value",""+Re(m.value));break;case"select":o.multiple=!!m.multiple,w=m.value,w!=null?pe(o,!!m.multiple,w,!1):m.defaultValue!=null&&pe(o,!!m.multiple,m.defaultValue,!0);break;default:typeof y.onClick=="function"&&(o.onclick=Ml)}switch(u){case"button":case"input":case"select":case"textarea":m=!!m.autoFocus;break e;case"img":m=!0;break e;default:m=!1}}m&&(s.flags|=4)}s.ref!==null&&(s.flags|=512,s.flags|=2097152)}return nr(s),null;case 6:if(o&&s.stateNode!=null)Lg(o,s,o.memoizedProps,m);else{if(typeof m!="string"&&s.stateNode===null)throw Error(n(166));if(u=Oi(ka.current),Oi(To.current),Ul(s)){if(m=s.stateNode,u=s.memoizedProps,m[No]=s,(w=m.nodeValue!==u)&&(o=Lr,o!==null))switch(o.tag){case 3:$l(m.nodeValue,u,(o.mode&1)!==0);break;case 5:o.memoizedProps.suppressHydrationWarning!==!0&&$l(m.nodeValue,u,(o.mode&1)!==0)}w&&(s.flags|=4)}else m=(u.nodeType===9?u:u.ownerDocument).createTextNode(m),m[No]=s,s.stateNode=m}return nr(s),null;case 13:if(on(un),m=s.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(sn&&Dr!==null&&(s.mode&1)!==0&&(s.flags&128)===0)Fm(),hs(),s.flags|=98560,w=!1;else if(w=Ul(s),m!==null&&m.dehydrated!==null){if(o===null){if(!w)throw Error(n(318));if(w=s.memoizedState,w=w!==null?w.dehydrated:null,!w)throw Error(n(317));w[No]=s}else hs(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;nr(s),w=!1}else lo!==null&&(hf(lo),lo=null),w=!0;if(!w)return s.flags&65536?s:null}return(s.flags&128)!==0?(s.lanes=u,s):(m=m!==null,m!==(o!==null&&o.memoizedState!==null)&&m&&(s.child.flags|=8192,(s.mode&1)!==0&&(o===null||(un.current&1)!==0?Rn===0&&(Rn=3):kf())),s.updateQueue!==null&&(s.flags|=4),nr(s),null);case 4:return ys(),nf(o,s),o===null&&ua(s.stateNode.containerInfo),nr(s),null;case 10:return Ad(s.type._context),nr(s),null;case 17:return Nr(s.type)&&Ll(),nr(s),null;case 19:if(on(un),w=s.memoizedState,w===null)return nr(s),null;if(m=(s.flags&128)!==0,S=w.rendering,S===null)if(m)xa(w,!1);else{if(Rn!==0||o!==null&&(o.flags&128)!==0)for(o=s.child;o!==null;){if(S=Vl(o),S!==null){for(s.flags|=128,xa(w,!1),m=S.updateQueue,m!==null&&(s.updateQueue=m,s.flags|=4),s.subtreeFlags=0,m=u,u=s.child;u!==null;)w=u,o=m,w.flags&=14680066,S=w.alternate,S===null?(w.childLanes=0,w.lanes=o,w.child=null,w.subtreeFlags=0,w.memoizedProps=null,w.memoizedState=null,w.updateQueue=null,w.dependencies=null,w.stateNode=null):(w.childLanes=S.childLanes,w.lanes=S.lanes,w.child=S.child,w.subtreeFlags=0,w.deletions=null,w.memoizedProps=S.memoizedProps,w.memoizedState=S.memoizedState,w.updateQueue=S.updateQueue,w.type=S.type,o=S.dependencies,w.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),u=u.sibling;return Jt(un,un.current&1|2),s.child}o=o.sibling}w.tail!==null&&Gt()>xs&&(s.flags|=128,m=!0,xa(w,!1),s.lanes=4194304)}else{if(!m)if(o=Vl(S),o!==null){if(s.flags|=128,m=!0,u=o.updateQueue,u!==null&&(s.updateQueue=u,s.flags|=4),xa(w,!0),w.tail===null&&w.tailMode==="hidden"&&!S.alternate&&!sn)return nr(s),null}else 2*Gt()-w.renderingStartTime>xs&&u!==1073741824&&(s.flags|=128,m=!0,xa(w,!1),s.lanes=4194304);w.isBackwards?(S.sibling=s.child,s.child=S):(u=w.last,u!==null?u.sibling=S:s.child=S,w.last=S)}return w.tail!==null?(s=w.tail,w.rendering=s,w.tail=s.sibling,w.renderingStartTime=Gt(),s.sibling=null,u=un.current,Jt(un,m?u&1|2:u&1),s):(nr(s),null);case 22:case 23:return gf(),m=s.memoizedState!==null,o!==null&&o.memoizedState!==null!==m&&(s.flags|=8192),m&&(s.mode&1)!==0?(zr&1073741824)!==0&&(nr(s),s.subtreeFlags&6&&(s.flags|=8192)):nr(s),null;case 24:return null;case 25:return null}throw Error(n(156,s.tag))}function j_(o,s){switch(Ed(s),s.tag){case 1:return Nr(s.type)&&Ll(),o=s.flags,o&65536?(s.flags=o&-65537|128,s):null;case 3:return ys(),on(Sr),on(er),Ld(),o=s.flags,(o&65536)!==0&&(o&128)===0?(s.flags=o&-65537|128,s):null;case 5:return Md(s),null;case 13:if(on(un),o=s.memoizedState,o!==null&&o.dehydrated!==null){if(s.alternate===null)throw Error(n(340));hs()}return o=s.flags,o&65536?(s.flags=o&-65537|128,s):null;case 19:return on(un),null;case 4:return ys(),null;case 10:return Ad(s.type._context),null;case 22:case 23:return gf(),null;case 24:return null;default:return null}}var rc=!1,rr=!1,A_=typeof WeakSet=="function"?WeakSet:Set,Pe=null;function ws(o,s){var u=o.ref;if(u!==null)if(typeof u=="function")try{u(null)}catch(m){gn(o,s,m)}else u.current=null}function rf(o,s,u){try{u()}catch(m){gn(o,s,m)}}var Dg=!1;function I_(o,s){if(md=_l,o=gm(),ad(o)){if("selectionStart"in o)var u={start:o.selectionStart,end:o.selectionEnd};else e:{u=(u=o.ownerDocument)&&u.defaultView||window;var m=u.getSelection&&u.getSelection();if(m&&m.rangeCount!==0){u=m.anchorNode;var y=m.anchorOffset,w=m.focusNode;m=m.focusOffset;try{u.nodeType,w.nodeType}catch{u=null;break e}var S=0,P=-1,W=-1,ae=0,ve=0,_e=o,ke=null;t:for(;;){for(var Oe;_e!==u||y!==0&&_e.nodeType!==3||(P=S+y),_e!==w||m!==0&&_e.nodeType!==3||(W=S+m),_e.nodeType===3&&(S+=_e.nodeValue.length),(Oe=_e.firstChild)!==null;)ke=_e,_e=Oe;for(;;){if(_e===o)break t;if(ke===u&&++ae===y&&(P=S),ke===w&&++ve===m&&(W=S),(Oe=_e.nextSibling)!==null)break;_e=ke,ke=_e.parentNode}_e=Oe}u=P===-1||W===-1?null:{start:P,end:W}}else u=null}u=u||{start:0,end:0}}else u=null;for(gd={focusedElem:o,selectionRange:u},_l=!1,Pe=s;Pe!==null;)if(s=Pe,o=s.child,(s.subtreeFlags&1028)!==0&&o!==null)o.return=s,Pe=o;else for(;Pe!==null;){s=Pe;try{var Le=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(Le!==null){var Fe=Le.memoizedProps,vn=Le.memoizedState,oe=s.stateNode,Y=oe.getSnapshotBeforeUpdate(s.elementType===s.type?Fe:co(s.type,Fe),vn);oe.__reactInternalSnapshotBeforeUpdate=Y}break;case 3:var se=s.stateNode.containerInfo;se.nodeType===1?se.textContent="":se.nodeType===9&&se.documentElement&&se.removeChild(se.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Se){gn(s,s.return,Se)}if(o=s.sibling,o!==null){o.return=s.return,Pe=o;break}Pe=s.return}return Le=Dg,Dg=!1,Le}function _a(o,s,u){var m=s.updateQueue;if(m=m!==null?m.lastEffect:null,m!==null){var y=m=m.next;do{if((y.tag&o)===o){var w=y.destroy;y.destroy=void 0,w!==void 0&&rf(s,u,w)}y=y.next}while(y!==m)}}function oc(o,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var u=s=s.next;do{if((u.tag&o)===o){var m=u.create;u.destroy=m()}u=u.next}while(u!==s)}}function of(o){var s=o.ref;if(s!==null){var u=o.stateNode;switch(o.tag){case 5:o=u;break;default:o=u}typeof s=="function"?s(o):s.current=o}}function zg(o){var s=o.alternate;s!==null&&(o.alternate=null,zg(s)),o.child=null,o.deletions=null,o.sibling=null,o.tag===5&&(s=o.stateNode,s!==null&&(delete s[No],delete s[fa],delete s[wd],delete s[p_],delete s[h_])),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 Fg(o){return o.tag===5||o.tag===3||o.tag===4}function Bg(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||Fg(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 sf(o,s,u){var m=o.tag;if(m===5||m===6)o=o.stateNode,s?u.nodeType===8?u.parentNode.insertBefore(o,s):u.insertBefore(o,s):(u.nodeType===8?(s=u.parentNode,s.insertBefore(o,u)):(s=u,s.appendChild(o)),u=u._reactRootContainer,u!=null||s.onclick!==null||(s.onclick=Ml));else if(m!==4&&(o=o.child,o!==null))for(sf(o,s,u),o=o.sibling;o!==null;)sf(o,s,u),o=o.sibling}function af(o,s,u){var m=o.tag;if(m===5||m===6)o=o.stateNode,s?u.insertBefore(o,s):u.appendChild(o);else if(m!==4&&(o=o.child,o!==null))for(af(o,s,u),o=o.sibling;o!==null;)af(o,s,u),o=o.sibling}var Vn=null,uo=!1;function ii(o,s,u){for(u=u.child;u!==null;)Ug(o,s,u),u=u.sibling}function Ug(o,s,u){if(it&&typeof it.onCommitFiberUnmount=="function")try{it.onCommitFiberUnmount(ot,u)}catch{}switch(u.tag){case 5:rr||ws(u,s);case 6:var m=Vn,y=uo;Vn=null,ii(o,s,u),Vn=m,uo=y,Vn!==null&&(uo?(o=Vn,u=u.stateNode,o.nodeType===8?o.parentNode.removeChild(u):o.removeChild(u)):Vn.removeChild(u.stateNode));break;case 18:Vn!==null&&(uo?(o=Vn,u=u.stateNode,o.nodeType===8?vd(o.parentNode,u):o.nodeType===1&&vd(o,u),ta(o)):vd(Vn,u.stateNode));break;case 4:m=Vn,y=uo,Vn=u.stateNode.containerInfo,uo=!0,ii(o,s,u),Vn=m,uo=y;break;case 0:case 11:case 14:case 15:if(!rr&&(m=u.updateQueue,m!==null&&(m=m.lastEffect,m!==null))){y=m=m.next;do{var w=y,S=w.destroy;w=w.tag,S!==void 0&&((w&2)!==0||(w&4)!==0)&&rf(u,s,S),y=y.next}while(y!==m)}ii(o,s,u);break;case 1:if(!rr&&(ws(u,s),m=u.stateNode,typeof m.componentWillUnmount=="function"))try{m.props=u.memoizedProps,m.state=u.memoizedState,m.componentWillUnmount()}catch(P){gn(u,s,P)}ii(o,s,u);break;case 21:ii(o,s,u);break;case 22:u.mode&1?(rr=(m=rr)||u.memoizedState!==null,ii(o,s,u),rr=m):ii(o,s,u);break;default:ii(o,s,u)}}function Hg(o){var s=o.updateQueue;if(s!==null){o.updateQueue=null;var u=o.stateNode;u===null&&(u=o.stateNode=new A_),s.forEach(function(m){var y=F_.bind(null,o,m);u.has(m)||(u.add(m),m.then(y,y))})}}function fo(o,s){var u=s.deletions;if(u!==null)for(var m=0;m<u.length;m++){var y=u[m];try{var w=o,S=s,P=S;e:for(;P!==null;){switch(P.tag){case 5:Vn=P.stateNode,uo=!1;break e;case 3:Vn=P.stateNode.containerInfo,uo=!0;break e;case 4:Vn=P.stateNode.containerInfo,uo=!0;break e}P=P.return}if(Vn===null)throw Error(n(160));Ug(w,S,y),Vn=null,uo=!1;var W=y.alternate;W!==null&&(W.return=null),y.return=null}catch(ae){gn(y,s,ae)}}if(s.subtreeFlags&12854)for(s=s.child;s!==null;)Zg(s,o),s=s.sibling}function Zg(o,s){var u=o.alternate,m=o.flags;switch(o.tag){case 0:case 11:case 14:case 15:if(fo(s,o),jo(o),m&4){try{_a(3,o,o.return),oc(3,o)}catch(Fe){gn(o,o.return,Fe)}try{_a(5,o,o.return)}catch(Fe){gn(o,o.return,Fe)}}break;case 1:fo(s,o),jo(o),m&512&&u!==null&&ws(u,u.return);break;case 5:if(fo(s,o),jo(o),m&512&&u!==null&&ws(u,u.return),o.flags&32){var y=o.stateNode;try{ie(y,"")}catch(Fe){gn(o,o.return,Fe)}}if(m&4&&(y=o.stateNode,y!=null)){var w=o.memoizedProps,S=u!==null?u.memoizedProps:w,P=o.type,W=o.updateQueue;if(o.updateQueue=null,W!==null)try{P==="input"&&w.type==="radio"&&w.name!=null&&ht(y,w),bn(P,S);var ae=bn(P,w);for(S=0;S<W.length;S+=2){var ve=W[S],_e=W[S+1];ve==="style"?bt(y,_e):ve==="dangerouslySetInnerHTML"?nn(y,_e):ve==="children"?ie(y,_e):H(y,ve,_e,ae)}switch(P){case"input":wn(y,w);break;case"textarea":ut(y,w);break;case"select":var ke=y._wrapperState.wasMultiple;y._wrapperState.wasMultiple=!!w.multiple;var Oe=w.value;Oe!=null?pe(y,!!w.multiple,Oe,!1):ke!==!!w.multiple&&(w.defaultValue!=null?pe(y,!!w.multiple,w.defaultValue,!0):pe(y,!!w.multiple,w.multiple?[]:"",!1))}y[fa]=w}catch(Fe){gn(o,o.return,Fe)}}break;case 6:if(fo(s,o),jo(o),m&4){if(o.stateNode===null)throw Error(n(162));y=o.stateNode,w=o.memoizedProps;try{y.nodeValue=w}catch(Fe){gn(o,o.return,Fe)}}break;case 3:if(fo(s,o),jo(o),m&4&&u!==null&&u.memoizedState.isDehydrated)try{ta(s.containerInfo)}catch(Fe){gn(o,o.return,Fe)}break;case 4:fo(s,o),jo(o);break;case 13:fo(s,o),jo(o),y=o.child,y.flags&8192&&(w=y.memoizedState!==null,y.stateNode.isHidden=w,!w||y.alternate!==null&&y.alternate.memoizedState!==null||(uf=Gt())),m&4&&Hg(o);break;case 22:if(ve=u!==null&&u.memoizedState!==null,o.mode&1?(rr=(ae=rr)||ve,fo(s,o),rr=ae):fo(s,o),jo(o),m&8192){if(ae=o.memoizedState!==null,(o.stateNode.isHidden=ae)&&!ve&&(o.mode&1)!==0)for(Pe=o,ve=o.child;ve!==null;){for(_e=Pe=ve;Pe!==null;){switch(ke=Pe,Oe=ke.child,ke.tag){case 0:case 11:case 14:case 15:_a(4,ke,ke.return);break;case 1:ws(ke,ke.return);var Le=ke.stateNode;if(typeof Le.componentWillUnmount=="function"){m=ke,u=ke.return;try{s=m,Le.props=s.memoizedProps,Le.state=s.memoizedState,Le.componentWillUnmount()}catch(Fe){gn(m,u,Fe)}}break;case 5:ws(ke,ke.return);break;case 22:if(ke.memoizedState!==null){Gg(_e);continue}}Oe!==null?(Oe.return=ke,Pe=Oe):Gg(_e)}ve=ve.sibling}e:for(ve=null,_e=o;;){if(_e.tag===5){if(ve===null){ve=_e;try{y=_e.stateNode,ae?(w=y.style,typeof w.setProperty=="function"?w.setProperty("display","none","important"):w.display="none"):(P=_e.stateNode,W=_e.memoizedProps.style,S=W!=null&&W.hasOwnProperty("display")?W.display:null,P.style.display=At("display",S))}catch(Fe){gn(o,o.return,Fe)}}}else if(_e.tag===6){if(ve===null)try{_e.stateNode.nodeValue=ae?"":_e.memoizedProps}catch(Fe){gn(o,o.return,Fe)}}else if((_e.tag!==22&&_e.tag!==23||_e.memoizedState===null||_e===o)&&_e.child!==null){_e.child.return=_e,_e=_e.child;continue}if(_e===o)break e;for(;_e.sibling===null;){if(_e.return===null||_e.return===o)break e;ve===_e&&(ve=null),_e=_e.return}ve===_e&&(ve=null),_e.sibling.return=_e.return,_e=_e.sibling}}break;case 19:fo(s,o),jo(o),m&4&&Hg(o);break;case 21:break;default:fo(s,o),jo(o)}}function jo(o){var s=o.flags;if(s&2){try{e:{for(var u=o.return;u!==null;){if(Fg(u)){var m=u;break e}u=u.return}throw Error(n(160))}switch(m.tag){case 5:var y=m.stateNode;m.flags&32&&(ie(y,""),m.flags&=-33);var w=Bg(o);af(o,w,y);break;case 3:case 4:var S=m.stateNode.containerInfo,P=Bg(o);sf(o,P,S);break;default:throw Error(n(161))}}catch(W){gn(o,o.return,W)}o.flags&=-3}s&4096&&(o.flags&=-4097)}function R_(o,s,u){Pe=o,Wg(o)}function Wg(o,s,u){for(var m=(o.mode&1)!==0;Pe!==null;){var y=Pe,w=y.child;if(y.tag===22&&m){var S=y.memoizedState!==null||rc;if(!S){var P=y.alternate,W=P!==null&&P.memoizedState!==null||rr;P=rc;var ae=rr;if(rc=S,(rr=W)&&!ae)for(Pe=y;Pe!==null;)S=Pe,W=S.child,S.tag===22&&S.memoizedState!==null?Vg(y):W!==null?(W.return=S,Pe=W):Vg(y);for(;w!==null;)Pe=w,Wg(w),w=w.sibling;Pe=y,rc=P,rr=ae}Kg(o)}else(y.subtreeFlags&8772)!==0&&w!==null?(w.return=y,Pe=w):Kg(o)}}function Kg(o){for(;Pe!==null;){var s=Pe;if((s.flags&8772)!==0){var u=s.alternate;try{if((s.flags&8772)!==0)switch(s.tag){case 0:case 11:case 15:rr||oc(5,s);break;case 1:var m=s.stateNode;if(s.flags&4&&!rr)if(u===null)m.componentDidMount();else{var y=s.elementType===s.type?u.memoizedProps:co(s.type,u.memoizedProps);m.componentDidUpdate(y,u.memoizedState,m.__reactInternalSnapshotBeforeUpdate)}var w=s.updateQueue;w!==null&&Gm(s,w,m);break;case 3:var S=s.updateQueue;if(S!==null){if(u=null,s.child!==null)switch(s.child.tag){case 5:u=s.child.stateNode;break;case 1:u=s.child.stateNode}Gm(s,S,u)}break;case 5:var P=s.stateNode;if(u===null&&s.flags&4){u=P;var W=s.memoizedProps;switch(s.type){case"button":case"input":case"select":case"textarea":W.autoFocus&&u.focus();break;case"img":W.src&&(u.src=W.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(s.memoizedState===null){var ae=s.alternate;if(ae!==null){var ve=ae.memoizedState;if(ve!==null){var _e=ve.dehydrated;_e!==null&&ta(_e)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}rr||s.flags&512&&of(s)}catch(ke){gn(s,s.return,ke)}}if(s===o){Pe=null;break}if(u=s.sibling,u!==null){u.return=s.return,Pe=u;break}Pe=s.return}}function Gg(o){for(;Pe!==null;){var s=Pe;if(s===o){Pe=null;break}var u=s.sibling;if(u!==null){u.return=s.return,Pe=u;break}Pe=s.return}}function Vg(o){for(;Pe!==null;){var s=Pe;try{switch(s.tag){case 0:case 11:case 15:var u=s.return;try{oc(4,s)}catch(W){gn(s,u,W)}break;case 1:var m=s.stateNode;if(typeof m.componentDidMount=="function"){var y=s.return;try{m.componentDidMount()}catch(W){gn(s,y,W)}}var w=s.return;try{of(s)}catch(W){gn(s,w,W)}break;case 5:var S=s.return;try{of(s)}catch(W){gn(s,S,W)}}}catch(W){gn(s,s.return,W)}if(s===o){Pe=null;break}var P=s.sibling;if(P!==null){P.return=s.return,Pe=P;break}Pe=s.return}}var O_=Math.ceil,ic=B.ReactCurrentDispatcher,lf=B.ReactCurrentOwner,Jr=B.ReactCurrentBatchConfig,$t=0,Hn=null,_n=null,qn=0,zr=0,bs=ei(0),Rn=0,Ea=null,Mi=0,sc=0,cf=0,Sa=null,Cr=null,uf=0,xs=1/0,Bo=null,ac=!1,df=null,si=null,lc=!1,ai=null,cc=0,Na=0,ff=null,uc=-1,dc=0;function mr(){return($t&6)!==0?Gt():uc!==-1?uc:uc=Gt()}function li(o){return(o.mode&1)===0?1:($t&2)!==0&&qn!==0?qn&-qn:g_.transition!==null?(dc===0&&(dc=Ti()),dc):(o=vt,o!==0||(o=window.event,o=o===void 0?16:Yh(o.type)),o)}function po(o,s,u,m){if(50<Na)throw Na=0,ff=null,Error(n(185));Jn(o,u,m),(($t&2)===0||o!==Hn)&&(o===Hn&&(($t&2)===0&&(sc|=u),Rn===4&&ci(o,qn)),jr(o,m),u===1&&$t===0&&(s.mode&1)===0&&(xs=Gt()+500,zl&&ni()))}function jr(o,s){var u=o.callbackNode;yn(o,s);var m=pr(o,o===Hn?qn:0);if(m===0)u!==null&&Dn(u),o.callbackNode=null,o.callbackPriority=0;else if(s=m&-m,o.callbackPriority!==s){if(u!=null&&Dn(u),s===1)o.tag===0?m_(Yg.bind(null,o)):Mm(Yg.bind(null,o)),d_(function(){($t&6)===0&&ni()}),u=null;else{switch(ze(m)){case 1:u=_o;break;case 4:u=kn;break;case 16:u=Vr;break;case 536870912:u=Ae;break;default:u=Vr}u=ok(u,qg.bind(null,o))}o.callbackPriority=s,o.callbackNode=u}}function qg(o,s){if(uc=-1,dc=0,($t&6)!==0)throw Error(n(327));var u=o.callbackNode;if(_s()&&o.callbackNode!==u)return null;var m=pr(o,o===Hn?qn:0);if(m===0)return null;if((m&30)!==0||(m&o.expiredLanes)!==0||s)s=fc(o,m);else{s=m;var y=$t;$t|=2;var w=Xg();(Hn!==o||qn!==s)&&(Bo=null,xs=Gt()+500,Li(o,s));do try{P_();break}catch(P){Qg(o,P)}while(!0);jd(),ic.current=w,$t=y,_n!==null?s=0:(Hn=null,qn=0,s=Rn)}if(s!==0){if(s===2&&(y=xr(o),y!==0&&(m=y,s=pf(o,y))),s===1)throw u=Ea,Li(o,0),ci(o,m),jr(o,Gt()),u;if(s===6)ci(o,m);else{if(y=o.current.alternate,(m&30)===0&&!$_(y)&&(s=fc(o,m),s===2&&(w=xr(o),w!==0&&(m=w,s=pf(o,w))),s===1))throw u=Ea,Li(o,0),ci(o,m),jr(o,Gt()),u;switch(o.finishedWork=y,o.finishedLanes=m,s){case 0:case 1:throw Error(n(345));case 2:Di(o,Cr,Bo);break;case 3:if(ci(o,m),(m&130023424)===m&&(s=uf+500-Gt(),10<s)){if(pr(o,0)!==0)break;if(y=o.suspendedLanes,(y&m)!==m){mr(),o.pingedLanes|=o.suspendedLanes&y;break}o.timeoutHandle=yd(Di.bind(null,o,Cr,Bo),s);break}Di(o,Cr,Bo);break;case 4:if(ci(o,m),(m&4194240)===m)break;for(s=o.eventTimes,y=-1;0<m;){var S=31-Bt(m);w=1<<S,S=s[S],S>y&&(y=S),m&=~w}if(m=y,m=Gt()-m,m=(120>m?120:480>m?480:1080>m?1080:1920>m?1920:3e3>m?3e3:4320>m?4320:1960*O_(m/1960))-m,10<m){o.timeoutHandle=yd(Di.bind(null,o,Cr,Bo),m);break}Di(o,Cr,Bo);break;case 5:Di(o,Cr,Bo);break;default:throw Error(n(329))}}}return jr(o,Gt()),o.callbackNode===u?qg.bind(null,o):null}function pf(o,s){var u=Sa;return o.current.memoizedState.isDehydrated&&(Li(o,s).flags|=256),o=fc(o,s),o!==2&&(s=Cr,Cr=u,s!==null&&hf(s)),o}function hf(o){Cr===null?Cr=o:Cr.push.apply(Cr,o)}function $_(o){for(var s=o;;){if(s.flags&16384){var u=s.updateQueue;if(u!==null&&(u=u.stores,u!==null))for(var m=0;m<u.length;m++){var y=u[m],w=y.getSnapshot;y=y.value;try{if(!ao(w(),y))return!1}catch{return!1}}}if(u=s.child,s.subtreeFlags&16384&&u!==null)u.return=s,s=u;else{if(s===o)break;for(;s.sibling===null;){if(s.return===null||s.return===o)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function ci(o,s){for(s&=~cf,s&=~sc,o.suspendedLanes|=s,o.pingedLanes&=~s,o=o.expirationTimes;0<s;){var u=31-Bt(s),m=1<<u;o[u]=-1,s&=~m}}function Yg(o){if(($t&6)!==0)throw Error(n(327));_s();var s=pr(o,0);if((s&1)===0)return jr(o,Gt()),null;var u=fc(o,s);if(o.tag!==0&&u===2){var m=xr(o);m!==0&&(s=m,u=pf(o,m))}if(u===1)throw u=Ea,Li(o,0),ci(o,s),jr(o,Gt()),u;if(u===6)throw Error(n(345));return o.finishedWork=o.current.alternate,o.finishedLanes=s,Di(o,Cr,Bo),jr(o,Gt()),null}function mf(o,s){var u=$t;$t|=1;try{return o(s)}finally{$t=u,$t===0&&(xs=Gt()+500,zl&&ni())}}function Pi(o){ai!==null&&ai.tag===0&&($t&6)===0&&_s();var s=$t;$t|=1;var u=Jr.transition,m=vt;try{if(Jr.transition=null,vt=1,o)return o()}finally{vt=m,Jr.transition=u,$t=s,($t&6)===0&&ni()}}function gf(){zr=bs.current,on(bs)}function Li(o,s){o.finishedWork=null,o.finishedLanes=0;var u=o.timeoutHandle;if(u!==-1&&(o.timeoutHandle=-1,u_(u)),_n!==null)for(u=_n.return;u!==null;){var m=u;switch(Ed(m),m.tag){case 1:m=m.type.childContextTypes,m!=null&&Ll();break;case 3:ys(),on(Sr),on(er),Ld();break;case 5:Md(m);break;case 4:ys();break;case 13:on(un);break;case 19:on(un);break;case 10:Ad(m.type._context);break;case 22:case 23:gf()}u=u.return}if(Hn=o,_n=o=ui(o.current,null),qn=zr=s,Rn=0,Ea=null,cf=sc=Mi=0,Cr=Sa=null,Ri!==null){for(s=0;s<Ri.length;s++)if(u=Ri[s],m=u.interleaved,m!==null){u.interleaved=null;var y=m.next,w=u.pending;if(w!==null){var S=w.next;w.next=y,m.next=S}u.pending=m}Ri=null}return o}function Qg(o,s){do{var u=_n;try{if(jd(),ql.current=Jl,Yl){for(var m=dn.memoizedState;m!==null;){var y=m.queue;y!==null&&(y.pending=null),m=m.next}Yl=!1}if($i=0,Un=In=dn=null,ya=!1,va=0,lf.current=null,u===null||u.return===null){Rn=1,Ea=s,_n=null;break}e:{var w=o,S=u.return,P=u,W=s;if(s=qn,P.flags|=32768,W!==null&&typeof W=="object"&&typeof W.then=="function"){var ae=W,ve=P,_e=ve.tag;if((ve.mode&1)===0&&(_e===0||_e===11||_e===15)){var ke=ve.alternate;ke?(ve.updateQueue=ke.updateQueue,ve.memoizedState=ke.memoizedState,ve.lanes=ke.lanes):(ve.updateQueue=null,ve.memoizedState=null)}var Oe=xg(S);if(Oe!==null){Oe.flags&=-257,_g(Oe,S,P,w,s),Oe.mode&1&&bg(w,ae,s),s=Oe,W=ae;var Le=s.updateQueue;if(Le===null){var Fe=new Set;Fe.add(W),s.updateQueue=Fe}else Le.add(W);break e}else{if((s&1)===0){bg(w,ae,s),kf();break e}W=Error(n(426))}}else if(sn&&P.mode&1){var vn=xg(S);if(vn!==null){(vn.flags&65536)===0&&(vn.flags|=256),_g(vn,S,P,w,s),Td(vs(W,P));break e}}w=W=vs(W,P),Rn!==4&&(Rn=2),Sa===null?Sa=[w]:Sa.push(w),w=S;do{switch(w.tag){case 3:w.flags|=65536,s&=-s,w.lanes|=s;var oe=vg(w,W,s);Km(w,oe);break e;case 1:P=W;var Y=w.type,se=w.stateNode;if((w.flags&128)===0&&(typeof Y.getDerivedStateFromError=="function"||se!==null&&typeof se.componentDidCatch=="function"&&(si===null||!si.has(se)))){w.flags|=65536,s&=-s,w.lanes|=s;var Se=wg(w,P,s);Km(w,Se);break e}}w=w.return}while(w!==null)}ek(u)}catch(Be){s=Be,_n===u&&u!==null&&(_n=u=u.return);continue}break}while(!0)}function Xg(){var o=ic.current;return ic.current=Jl,o===null?Jl:o}function kf(){(Rn===0||Rn===3||Rn===2)&&(Rn=4),Hn===null||(Mi&268435455)===0&&(sc&268435455)===0||ci(Hn,qn)}function fc(o,s){var u=$t;$t|=2;var m=Xg();(Hn!==o||qn!==s)&&(Bo=null,Li(o,s));do try{M_();break}catch(y){Qg(o,y)}while(!0);if(jd(),$t=u,ic.current=m,_n!==null)throw Error(n(261));return Hn=null,qn=0,Rn}function M_(){for(;_n!==null;)Jg(_n)}function P_(){for(;_n!==null&&!fr();)Jg(_n)}function Jg(o){var s=rk(o.alternate,o,zr);o.memoizedProps=o.pendingProps,s===null?ek(o):_n=s,lf.current=null}function ek(o){var s=o;do{var u=s.alternate;if(o=s.return,(s.flags&32768)===0){if(u=C_(u,s,zr),u!==null){_n=u;return}}else{if(u=j_(u,s),u!==null){u.flags&=32767,_n=u;return}if(o!==null)o.flags|=32768,o.subtreeFlags=0,o.deletions=null;else{Rn=6,_n=null;return}}if(s=s.sibling,s!==null){_n=s;return}_n=s=o}while(s!==null);Rn===0&&(Rn=5)}function Di(o,s,u){var m=vt,y=Jr.transition;try{Jr.transition=null,vt=1,L_(o,s,u,m)}finally{Jr.transition=y,vt=m}return null}function L_(o,s,u,m){do _s();while(ai!==null);if(($t&6)!==0)throw Error(n(327));u=o.finishedWork;var y=o.finishedLanes;if(u===null)return null;if(o.finishedWork=null,o.finishedLanes=0,u===o.current)throw Error(n(177));o.callbackNode=null,o.callbackPriority=0;var w=u.lanes|u.childLanes;if(Fn(o,w),o===Hn&&(_n=Hn=null,qn=0),(u.subtreeFlags&2064)===0&&(u.flags&2064)===0||lc||(lc=!0,ok(Vr,function(){return _s(),null})),w=(u.flags&15990)!==0,(u.subtreeFlags&15990)!==0||w){w=Jr.transition,Jr.transition=null;var S=vt;vt=1;var P=$t;$t|=4,lf.current=null,I_(o,u),Zg(u,o),r_(gd),_l=!!md,gd=md=null,o.current=u,R_(u),so(),$t=P,vt=S,Jr.transition=w}else o.current=u;if(lc&&(lc=!1,ai=o,cc=y),w=o.pendingLanes,w===0&&(si=null),Vt(u.stateNode),jr(o,Gt()),s!==null)for(m=o.onRecoverableError,u=0;u<s.length;u++)y=s[u],m(y.value,{componentStack:y.stack,digest:y.digest});if(ac)throw ac=!1,o=df,df=null,o;return(cc&1)!==0&&o.tag!==0&&_s(),w=o.pendingLanes,(w&1)!==0?o===ff?Na++:(Na=0,ff=o):Na=0,ni(),null}function _s(){if(ai!==null){var o=ze(cc),s=Jr.transition,u=vt;try{if(Jr.transition=null,vt=16>o?16:o,ai===null)var m=!1;else{if(o=ai,ai=null,cc=0,($t&6)!==0)throw Error(n(331));var y=$t;for($t|=4,Pe=o.current;Pe!==null;){var w=Pe,S=w.child;if((Pe.flags&16)!==0){var P=w.deletions;if(P!==null){for(var W=0;W<P.length;W++){var ae=P[W];for(Pe=ae;Pe!==null;){var ve=Pe;switch(ve.tag){case 0:case 11:case 15:_a(8,ve,w)}var _e=ve.child;if(_e!==null)_e.return=ve,Pe=_e;else for(;Pe!==null;){ve=Pe;var ke=ve.sibling,Oe=ve.return;if(zg(ve),ve===ae){Pe=null;break}if(ke!==null){ke.return=Oe,Pe=ke;break}Pe=Oe}}}var Le=w.alternate;if(Le!==null){var Fe=Le.child;if(Fe!==null){Le.child=null;do{var vn=Fe.sibling;Fe.sibling=null,Fe=vn}while(Fe!==null)}}Pe=w}}if((w.subtreeFlags&2064)!==0&&S!==null)S.return=w,Pe=S;else e:for(;Pe!==null;){if(w=Pe,(w.flags&2048)!==0)switch(w.tag){case 0:case 11:case 15:_a(9,w,w.return)}var oe=w.sibling;if(oe!==null){oe.return=w.return,Pe=oe;break e}Pe=w.return}}var Y=o.current;for(Pe=Y;Pe!==null;){S=Pe;var se=S.child;if((S.subtreeFlags&2064)!==0&&se!==null)se.return=S,Pe=se;else e:for(S=Y;Pe!==null;){if(P=Pe,(P.flags&2048)!==0)try{switch(P.tag){case 0:case 11:case 15:oc(9,P)}}catch(Be){gn(P,P.return,Be)}if(P===S){Pe=null;break e}var Se=P.sibling;if(Se!==null){Se.return=P.return,Pe=Se;break e}Pe=P.return}}if($t=y,ni(),it&&typeof it.onPostCommitFiberRoot=="function")try{it.onPostCommitFiberRoot(ot,o)}catch{}m=!0}return m}finally{vt=u,Jr.transition=s}}return!1}function tk(o,s,u){s=vs(u,s),s=vg(o,s,1),o=oi(o,s,1),s=mr(),o!==null&&(Jn(o,1,s),jr(o,s))}function gn(o,s,u){if(o.tag===3)tk(o,o,u);else for(;s!==null;){if(s.tag===3){tk(s,o,u);break}else if(s.tag===1){var m=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof m.componentDidCatch=="function"&&(si===null||!si.has(m))){o=vs(u,o),o=wg(s,o,1),s=oi(s,o,1),o=mr(),s!==null&&(Jn(s,1,o),jr(s,o));break}}s=s.return}}function D_(o,s,u){var m=o.pingCache;m!==null&&m.delete(s),s=mr(),o.pingedLanes|=o.suspendedLanes&u,Hn===o&&(qn&u)===u&&(Rn===4||Rn===3&&(qn&130023424)===qn&&500>Gt()-uf?Li(o,0):cf|=u),jr(o,s)}function nk(o,s){s===0&&((o.mode&1)===0?s=1:(s=br,br<<=1,(br&130023424)===0&&(br=4194304)));var u=mr();o=Do(o,s),o!==null&&(Jn(o,s,u),jr(o,u))}function z_(o){var s=o.memoizedState,u=0;s!==null&&(u=s.retryLane),nk(o,u)}function F_(o,s){var u=0;switch(o.tag){case 13:var m=o.stateNode,y=o.memoizedState;y!==null&&(u=y.retryLane);break;case 19:m=o.stateNode;break;default:throw Error(n(314))}m!==null&&m.delete(s),nk(o,u)}var rk;rk=function(o,s,u){if(o!==null)if(o.memoizedProps!==s.pendingProps||Sr.current)Tr=!0;else{if((o.lanes&u)===0&&(s.flags&128)===0)return Tr=!1,T_(o,s,u);Tr=(o.flags&131072)!==0}else Tr=!1,sn&&(s.flags&1048576)!==0&&Pm(s,Bl,s.index);switch(s.lanes=0,s.tag){case 2:var m=s.type;nc(o,s),o=s.pendingProps;var y=ds(s,er.current);ks(s,u),y=Fd(null,s,m,o,y,u);var w=Bd();return s.flags|=1,typeof y=="object"&&y!==null&&typeof y.render=="function"&&y.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,Nr(m)?(w=!0,Dl(s)):w=!1,s.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,Od(s),y.updater=ec,s.stateNode=y,y._reactInternals=s,Gd(s,m,o,u),s=Qd(null,s,m,!0,w,u)):(s.tag=0,sn&&w&&_d(s),hr(null,s,y,u),s=s.child),s;case 16:m=s.elementType;e:{switch(nc(o,s),o=s.pendingProps,y=m._init,m=y(m._payload),s.type=m,y=s.tag=U_(m),o=co(m,o),y){case 0:s=Yd(null,s,m,o,u);break e;case 1:s=jg(null,s,m,o,u);break e;case 11:s=Eg(null,s,m,o,u);break e;case 14:s=Sg(null,s,m,co(m.type,o),u);break e}throw Error(n(306,m,""))}return s;case 0:return m=s.type,y=s.pendingProps,y=s.elementType===m?y:co(m,y),Yd(o,s,m,y,u);case 1:return m=s.type,y=s.pendingProps,y=s.elementType===m?y:co(m,y),jg(o,s,m,y,u);case 3:e:{if(Ag(s),o===null)throw Error(n(387));m=s.pendingProps,w=s.memoizedState,y=w.element,Wm(o,s),Gl(s,m,null,u);var S=s.memoizedState;if(m=S.element,w.isDehydrated)if(w={element:m,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},s.updateQueue.baseState=w,s.memoizedState=w,s.flags&256){y=vs(Error(n(423)),s),s=Ig(o,s,m,u,y);break e}else if(m!==y){y=vs(Error(n(424)),s),s=Ig(o,s,m,u,y);break e}else for(Dr=Jo(s.stateNode.containerInfo.firstChild),Lr=s,sn=!0,lo=null,u=Hm(s,null,m,u),s.child=u;u;)u.flags=u.flags&-3|4096,u=u.sibling;else{if(hs(),m===y){s=Fo(o,s,u);break e}hr(o,s,m,u)}s=s.child}return s;case 5:return Vm(s),o===null&&Nd(s),m=s.type,y=s.pendingProps,w=o!==null?o.memoizedProps:null,S=y.children,kd(m,y)?S=null:w!==null&&kd(m,w)&&(s.flags|=32),Cg(o,s),hr(o,s,S,u),s.child;case 6:return o===null&&Nd(s),null;case 13:return Rg(o,s,u);case 4:return $d(s,s.stateNode.containerInfo),m=s.pendingProps,o===null?s.child=ms(s,null,m,u):hr(o,s,m,u),s.child;case 11:return m=s.type,y=s.pendingProps,y=s.elementType===m?y:co(m,y),Eg(o,s,m,y,u);case 7:return hr(o,s,s.pendingProps,u),s.child;case 8:return hr(o,s,s.pendingProps.children,u),s.child;case 12:return hr(o,s,s.pendingProps.children,u),s.child;case 10:e:{if(m=s.type._context,y=s.pendingProps,w=s.memoizedProps,S=y.value,Jt(Zl,m._currentValue),m._currentValue=S,w!==null)if(ao(w.value,S)){if(w.children===y.children&&!Sr.current){s=Fo(o,s,u);break e}}else for(w=s.child,w!==null&&(w.return=s);w!==null;){var P=w.dependencies;if(P!==null){S=w.child;for(var W=P.firstContext;W!==null;){if(W.context===m){if(w.tag===1){W=zo(-1,u&-u),W.tag=2;var ae=w.updateQueue;if(ae!==null){ae=ae.shared;var ve=ae.pending;ve===null?W.next=W:(W.next=ve.next,ve.next=W),ae.pending=W}}w.lanes|=u,W=w.alternate,W!==null&&(W.lanes|=u),Id(w.return,u,s),P.lanes|=u;break}W=W.next}}else if(w.tag===10)S=w.type===s.type?null:w.child;else if(w.tag===18){if(S=w.return,S===null)throw Error(n(341));S.lanes|=u,P=S.alternate,P!==null&&(P.lanes|=u),Id(S,u,s),S=w.sibling}else S=w.child;if(S!==null)S.return=w;else for(S=w;S!==null;){if(S===s){S=null;break}if(w=S.sibling,w!==null){w.return=S.return,S=w;break}S=S.return}w=S}hr(o,s,y.children,u),s=s.child}return s;case 9:return y=s.type,m=s.pendingProps.children,ks(s,u),y=Qr(y),m=m(y),s.flags|=1,hr(o,s,m,u),s.child;case 14:return m=s.type,y=co(m,s.pendingProps),y=co(m.type,y),Sg(o,s,m,y,u);case 15:return Ng(o,s,s.type,s.pendingProps,u);case 17:return m=s.type,y=s.pendingProps,y=s.elementType===m?y:co(m,y),nc(o,s),s.tag=1,Nr(m)?(o=!0,Dl(s)):o=!1,ks(s,u),kg(s,m,y),Gd(s,m,y,u),Qd(null,s,m,!0,o,u);case 19:return $g(o,s,u);case 22:return Tg(o,s,u)}throw Error(n(156,s.tag))};function ok(o,s){return dr(o,s)}function B_(o,s,u,m){this.tag=o,this.key=u,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,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 eo(o,s,u,m){return new B_(o,s,u,m)}function yf(o){return o=o.prototype,!(!o||!o.isReactComponent)}function U_(o){if(typeof o=="function")return yf(o)?1:0;if(o!=null){if(o=o.$$typeof,o===K)return 11;if(o===Q)return 14}return 2}function ui(o,s){var u=o.alternate;return u===null?(u=eo(o.tag,s,o.key,o.mode),u.elementType=o.elementType,u.type=o.type,u.stateNode=o.stateNode,u.alternate=o,o.alternate=u):(u.pendingProps=s,u.type=o.type,u.flags=0,u.subtreeFlags=0,u.deletions=null),u.flags=o.flags&14680064,u.childLanes=o.childLanes,u.lanes=o.lanes,u.child=o.child,u.memoizedProps=o.memoizedProps,u.memoizedState=o.memoizedState,u.updateQueue=o.updateQueue,s=o.dependencies,u.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},u.sibling=o.sibling,u.index=o.index,u.ref=o.ref,u}function pc(o,s,u,m,y,w){var S=2;if(m=o,typeof o=="function")yf(o)&&(S=1);else if(typeof o=="string")S=5;else e:switch(o){case C:return zi(u.children,y,w,s);case L:S=8,y|=8;break;case I:return o=eo(12,u,s,y|2),o.elementType=I,o.lanes=w,o;case le:return o=eo(13,u,s,y),o.elementType=le,o.lanes=w,o;case de:return o=eo(19,u,s,y),o.elementType=de,o.lanes=w,o;case R:return hc(u,y,w,s);default:if(typeof o=="object"&&o!==null)switch(o.$$typeof){case Z:S=10;break e;case V:S=9;break e;case K:S=11;break e;case Q:S=14;break e;case ce:S=16,m=null;break e}throw Error(n(130,o==null?o:typeof o,""))}return s=eo(S,u,s,y),s.elementType=o,s.type=m,s.lanes=w,s}function zi(o,s,u,m){return o=eo(7,o,m,s),o.lanes=u,o}function hc(o,s,u,m){return o=eo(22,o,m,s),o.elementType=R,o.lanes=u,o.stateNode={isHidden:!1},o}function vf(o,s,u){return o=eo(6,o,null,s),o.lanes=u,o}function wf(o,s,u){return s=eo(4,o.children!==null?o.children:[],o.key,s),s.lanes=u,s.stateNode={containerInfo:o.containerInfo,pendingChildren:null,implementation:o.implementation},s}function H_(o,s,u,m,y){this.tag=s,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=_r(0),this.expirationTimes=_r(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=_r(0),this.identifierPrefix=m,this.onRecoverableError=y,this.mutableSourceEagerHydrationData=null}function bf(o,s,u,m,y,w,S,P,W){return o=new H_(o,s,u,P,W),s===1?(s=1,w===!0&&(s|=8)):s=0,w=eo(3,null,null,s),o.current=w,w.stateNode=o,w.memoizedState={element:m,isDehydrated:u,cache:null,transitions:null,pendingSuspenseBoundaries:null},Od(w),o}function Z_(o,s,u){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:F,key:m==null?null:""+m,children:o,containerInfo:s,implementation:u}}function ik(o){if(!o)return ti;o=o._reactInternals;e:{if(wr(o)!==o||o.tag!==1)throw Error(n(170));var s=o;do{switch(s.tag){case 3:s=s.stateNode.context;break e;case 1:if(Nr(s.type)){s=s.stateNode.__reactInternalMemoizedMergedChildContext;break e}}s=s.return}while(s!==null);throw Error(n(171))}if(o.tag===1){var u=o.type;if(Nr(u))return Om(o,u,s)}return s}function sk(o,s,u,m,y,w,S,P,W){return o=bf(u,m,!0,o,y,w,S,P,W),o.context=ik(null),u=o.current,m=mr(),y=li(u),w=zo(m,y),w.callback=s??null,oi(u,w,y),o.current.lanes=y,Jn(o,y,m),jr(o,m),o}function mc(o,s,u,m){var y=s.current,w=mr(),S=li(y);return u=ik(u),s.context===null?s.context=u:s.pendingContext=u,s=zo(w,S),s.payload={element:o},m=m===void 0?null:m,m!==null&&(s.callback=m),o=oi(y,s,S),o!==null&&(po(o,y,S,w),Kl(o,y,S)),S}function gc(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 ak(o,s){if(o=o.memoizedState,o!==null&&o.dehydrated!==null){var u=o.retryLane;o.retryLane=u!==0&&u<s?u:s}}function xf(o,s){ak(o,s),(o=o.alternate)&&ak(o,s)}function W_(){return null}var lk=typeof reportError=="function"?reportError:function(o){console.error(o)};function _f(o){this._internalRoot=o}kc.prototype.render=_f.prototype.render=function(o){var s=this._internalRoot;if(s===null)throw Error(n(409));mc(o,s,null,null)},kc.prototype.unmount=_f.prototype.unmount=function(){var o=this._internalRoot;if(o!==null){this._internalRoot=null;var s=o.containerInfo;Pi(function(){mc(null,o,null,null)}),s[$o]=null}};function kc(o){this._internalRoot=o}kc.prototype.unstable_scheduleHydration=function(o){if(o){var s=Er();o={blockedOn:null,target:o,priority:s};for(var u=0;u<et.length&&s!==0&&s<et[u].priority;u++);et.splice(u,0,o),u===0&&qt(o)}};function Ef(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11)}function yc(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11&&(o.nodeType!==8||o.nodeValue!==" react-mount-point-unstable "))}function ck(){}function K_(o,s,u,m,y){if(y){if(typeof m=="function"){var w=m;m=function(){var ae=gc(S);w.call(ae)}}var S=sk(s,m,o,0,null,!1,!1,"",ck);return o._reactRootContainer=S,o[$o]=S.current,ua(o.nodeType===8?o.parentNode:o),Pi(),S}for(;y=o.lastChild;)o.removeChild(y);if(typeof m=="function"){var P=m;m=function(){var ae=gc(W);P.call(ae)}}var W=bf(o,0,!1,null,null,!1,!1,"",ck);return o._reactRootContainer=W,o[$o]=W.current,ua(o.nodeType===8?o.parentNode:o),Pi(function(){mc(s,W,u,m)}),W}function vc(o,s,u,m,y){var w=u._reactRootContainer;if(w){var S=w;if(typeof y=="function"){var P=y;y=function(){var W=gc(S);P.call(W)}}mc(s,S,o,y)}else S=K_(u,s,o,y,m);return gc(S)}Ro=function(o){switch(o.tag){case 3:var s=o.stateNode;if(s.current.memoizedState.isDehydrated){var u=zn(s.pendingLanes);u!==0&&(Eo(s,u|1),jr(s,Gt()),($t&6)===0&&(xs=Gt()+500,ni()))}break;case 13:Pi(function(){var m=Do(o,1);if(m!==null){var y=mr();po(m,o,1,y)}}),xf(o,1)}},Xt=function(o){if(o.tag===13){var s=Do(o,134217728);if(s!==null){var u=mr();po(s,o,134217728,u)}xf(o,134217728)}},Nt=function(o){if(o.tag===13){var s=li(o),u=Do(o,s);if(u!==null){var m=mr();po(u,o,s,m)}xf(o,s)}},Er=function(){return vt},Bn=function(o,s){var u=vt;try{return vt=o,s()}finally{vt=u}},lr=function(o,s,u){switch(s){case"input":if(wn(o,u),s=u.name,u.type==="radio"&&s!=null){for(u=o;u.parentNode;)u=u.parentNode;for(u=u.querySelectorAll("input[name="+JSON.stringify(""+s)+'][type="radio"]'),s=0;s<u.length;s++){var m=u[s];if(m!==o&&m.form===o.form){var y=Pl(m);if(!y)throw Error(n(90));Tt(m),wn(m,y)}}}break;case"textarea":ut(o,u);break;case"select":s=u.value,s!=null&&pe(o,!!u.multiple,s,!1)}},me=mf,xe=Pi;var G_={usingClientEntryPoint:!1,Events:[pa,cs,Pl,N,X,mf]},Ta={findFiberByHostInstance:Ci,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},V_={bundleType:Ta.bundleType,version:Ta.version,rendererPackageName:Ta.rendererPackageName,rendererConfig:Ta.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:B.ReactCurrentDispatcher,findHostInstanceByFiber:function(o){return o=Gr(o),o===null?null:o.stateNode},findFiberByHostInstance:Ta.findFiberByHostInstance||W_,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 wc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!wc.isDisabled&&wc.supportsFiber)try{ot=wc.inject(V_),it=wc}catch{}}return Ar.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=G_,Ar.createPortal=function(o,s){var u=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ef(s))throw Error(n(200));return Z_(o,s,null,u)},Ar.createRoot=function(o,s){if(!Ef(o))throw Error(n(299));var u=!1,m="",y=lk;return s!=null&&(s.unstable_strictMode===!0&&(u=!0),s.identifierPrefix!==void 0&&(m=s.identifierPrefix),s.onRecoverableError!==void 0&&(y=s.onRecoverableError)),s=bf(o,1,!1,null,null,u,!1,m,y),o[$o]=s.current,ua(o.nodeType===8?o.parentNode:o),new _f(s)},Ar.findDOMNode=function(o){if(o==null)return null;if(o.nodeType===1)return o;var s=o._reactInternals;if(s===void 0)throw typeof o.render=="function"?Error(n(188)):(o=Object.keys(o).join(","),Error(n(268,o)));return o=Gr(s),o=o===null?null:o.stateNode,o},Ar.flushSync=function(o){return Pi(o)},Ar.hydrate=function(o,s,u){if(!yc(s))throw Error(n(200));return vc(null,o,s,!0,u)},Ar.hydrateRoot=function(o,s,u){if(!Ef(o))throw Error(n(405));var m=u!=null&&u.hydratedSources||null,y=!1,w="",S=lk;if(u!=null&&(u.unstable_strictMode===!0&&(y=!0),u.identifierPrefix!==void 0&&(w=u.identifierPrefix),u.onRecoverableError!==void 0&&(S=u.onRecoverableError)),s=sk(s,null,o,1,u??null,y,!1,w,S),o[$o]=s.current,ua(o),m)for(o=0;o<m.length;o++)u=m[o],y=u._getVersion,y=y(u._source),s.mutableSourceEagerHydrationData==null?s.mutableSourceEagerHydrationData=[u,y]:s.mutableSourceEagerHydrationData.push(u,y);return new kc(s)},Ar.render=function(o,s,u){if(!yc(s))throw Error(n(200));return vc(null,o,s,!1,u)},Ar.unmountComponentAtNode=function(o){if(!yc(o))throw Error(n(40));return o._reactRootContainer?(Pi(function(){vc(null,null,o,!1,function(){o._reactRootContainer=null,o[$o]=null})}),!0):!1},Ar.unstable_batchedUpdates=mf,Ar.unstable_renderSubtreeIntoContainer=function(o,s,u,m){if(!yc(u))throw Error(n(200));if(o==null||o._reactInternals===void 0)throw Error(n(38));return vc(o,s,u,!1,m)},Ar.version="18.3.1-next-f1338f8080-20240426",Ar}var sy;function vI(){if(sy)return Mf.exports;sy=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(),Mf.exports=yI(),Mf.exports}var ay;function wI(){if(ay)return Nc;ay=1;var e=vI();return Nc.createRoot=e.createRoot,Nc.hydrateRoot=e.hydrateRoot,Nc}var bI=wI();const xI=200;function _I(e,t){const n=new Map(e.map(r=>[r.path,r]));for(const r of t){if(n.size>=xI)break;const i=Nu(r.path);i&&!n.has(i)&&n.set(i,{path:i,text:r.text})}return n.size===e.length?e:[...n.values()]}function e0(e){return e!==void 0&&!e.routes.some(t=>!t.endpoint)}const _p=["files","changes","history"],EI=e=>_p.includes(e),t0=e=>!!(e!=null&&e.carry)&&!e.batch&&e.variants===1,gl=e=>(e==null?void 0:e.worktree.id)??null,Au=Object.freeze({chat:[],log:[],queue:[],page:{errors:[]},turn:{edits:!1,hmr:!1},changedRanges:{},commitFiles:{},search:null,design:null,draft:"",attachments:[],commands:[],termStream:to}),lh=e=>({...e,phase:"editing",repoId:null,prompt:""}),ly=()=>lh({mode:"create",name:"",parent:`~/${aw}`}),SI=Object.freeze({changes:!1,changesTab:"files",chat:!0,term:!1,design:!1});function NI(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.changes=="boolean"&&EI(t.changesTab)&&typeof t.chat=="boolean"&&typeof t.term=="boolean"&&typeof t.design=="boolean"}function Ur(e,t){const n=e.layout;let r=!1;for(const i of Object.keys(t))t[i]!==n[i]&&(r=!0);return r?{...e,layout:{...n,...t}}:e}function ch(e,t){return{...e,layout:t,changesAuto:!1}}const kl=e=>Jw(e)?"preview":"file",Df=(e,t)=>e.worktreeId===t.worktreeId&&e.path===t.path&&e.ref===t.ref;function n0(e,t,n,r){var a;if(!r.fiber)return r;const i=(a=wo(e,t).changedRanges[n])==null?void 0:a.offset;return i===void 0?r:{n:r.n-i}}function TI(e){const t=e.cached??ml,n={connected:!1,connectFailure:null,repos:[],rows:[],activeRepoId:null,visible:[],archiving:[],shipping:{},visibleDiscovered:[],discoveredOpen:e.storedDiscoveredOpen??{},archivedOpen:e.storedArchivedOpen??{},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:!1,picking:!1,overlay:null,paletteReturn:null,incompatible:!1,layout:SI,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:Dc.some(i=>i.id===t.id)?Dc:[...Dc,t],themePrefs:{...XA,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,paired:!1,pairings:0,gitIdentity:!0,self:null,update:null,version:"",install:"none",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?ch(n,r):n}function r0(e){var t;return{system:e.systemDark,daylight:((t=e.daylight)==null?void 0:t.dark)??e.systemDark}}function CI(e){return e.previewTheme??Cu(e.themePrefs,e.themes,r0(e))}function wo(e,t){return t&&e.local[t]||Au}function Ks(e,t){return t&&e.rows.find(n=>n.id===t)||null}function Yt(e,t){const n=Ks(e,t);return n&&Mn(n)?n:null}function o0(e){var i;const t=Yt(e,e.activeId);if(!t||!yu(t.worktree)||t.agent!=="idle"||!((i=zs(e,t.repoId))!=null&&i.empty))return!1;const n=Gs(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&&wo(e,t.id).chat.length===0}function Iu(e){return e.newProject!==null||o0(e)}function jI(e){return e.incompatible||Iu(e)}function AI(e){return(!e.needsSetup||!!e.assumed)&&Object.keys(e.config.run).length===0}function tu(e){return!!(e!=null&&e.needsSetup)&&!e.assumed}function ro(e){const t=e.activeRepoId?e.repos.find(n=>n.id===e.activeRepoId):void 0;return!!t&&AI(t)}function Ho(e){return ro(e)?e:Ur(e,{chat:!0})}function Gs(e,t){return t&&e.repos.find(n=>n.id===t)||null}function i0(e,t){if(!t)return null;const n=e.rows.filter(Mn).filter(r=>r.repoId===t);return n.find(r=>Hs(r.worktree))??n.find(r=>yu(r.worktree))??null}function zs(e,t){return t&&e.trunks[t]||null}function za(e){return ro(e)||e.archivedPage?null:e.activeId}function II(e,t){var r;const n=Ks(e,t);return!n||!Mn(n)||Yn(n.worktree)||ro(e)||n.agent==="waiting"||n.unseen||((r=n.worktree.lastTurn)==null?void 0:r.end)==="failed"?"chat":"preview"}function uh(e){return e.procs.some(t=>t.status==="running"||t.status==="starting")}function nu(e){if(e.archivedPage)return null;const t=Yt(e,e.activeId);return t&&uh(t)?{worktreeId:t.worktree.id,repoId:t.repoId}:null}function RI(e,t,n){const r=e.filter(Mn),i=n.length?r.filter(a=>!n.includes(a.id)):r;return uE(t?i.filter(a=>a.repoId===t):i)}function OI(e,t){const n=e.filter(r=>!Mn(r));return t?n.filter(r=>r.repoId===t):n}function Ga(e,t,n=e.rows){var c;const r=n.filter(Mn),i=e.archiving.length?r.filter(d=>!e.archiving.includes(d.id)):r,a=t?e.lastActive[t]:void 0;if(a&&i.some(d=>d.id===a))return a;const l=t?i.filter(d=>d.repoId===t):i;return((c=l.find(d=>Hs(d.worktree))??l.find(d=>yu(d.worktree))??l[0])==null?void 0:c.id)??null}function zc(e,t){const n=Object.entries(e),r=n.filter(([i])=>!t(i));return r.length===n.length?e:Object.fromEntries(r)}function As(e,t){var g;const n=Ks(e,t),r=(n==null?void 0:n.repoId)??e.activeRepoId,i=n&&Mn(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&&((g=l.mark)==null?void 0:g.by)==="reveal"?ru(l,"reveal"):null,d=a&&c?{...e.local,[a]:c}:e.local;return{...e,activeId:t,activeRepoId:r,lastActive:i,editor:null,archivedPage:null,local:d}}function Fs(e){return xi(e)&&e.layout.changesTab==="files"?"changes":e.layout.changesTab}function $I(e,t){const n=xi(e)?_p.filter(r=>r!=="files"):_p;return n[(n.indexOf(Fs(e))+t+n.length)%n.length]??"changes"}function xi(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 ru(e,t){var i;if(((i=e.mark)==null?void 0:i.by)!==t)return e;const{mark:n,...r}=e;return r}const s0=e=>e.kind==="theme"||e.kind==="appearance"||e.kind==="agent"||e.kind==="agent-page"||e.kind==="choose-folder";function _t(e,t,n){return{...e,local:{...e.local,[t]:n(e.local[t]??Au)}}}function MI(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{ask:i,askParked:a,...l}=e;return{...l,...i&&!n&&i.id!==r?{ask:i}:{},...a&&!n&&a!==r?{askParked:a}:{}}}function a0(e,t,n){return _t(e,t,r=>({...r,chat:[...r.chat,n]}))}function l0(e,t,n){return a0(Ho(e),t,{kind:"error",text:n})}function Ep(e,t){const n=gl(Yt(e,e.activeId));return n?_t(Ho(e),n,r=>({...r,notice:t})):e}function cy(e,t,n){return Yt(e,t)?l0(e,t,n):Ep(e,n)}function PI(e,t){const n=e.paletteReturn;return!t||!n?{overlay:null,paletteReturn:null}:{overlay:{kind:n.mode},paletteReturn:n}}function LI(e){const t=e.activeRepoId;if(!t)return e;const n=e.layouts[t];return n?ch(e,n):e.frame==="desk"?{...e,layouts:{...e.layouts,[t]:e.layout}}:e}function DI(e){return e.a==="server"&&e.msg.t==="git-status"}function zI(e){return{variants:1,batch:!1,agent:e.defaultAgent}}function FI(e){const t=Yt(e,e.activeId);return!!t&&Yn(t.worktree)&&!e.archivedPage&&!Iu(e)?e.draft?e:{...e,draft:zI(e)}:e.draft?{...e,draft:null}:e}function c0(e){var r;const t=e.archivedPage,n=t!==null&&((r=e.editor)==null?void 0:r.worktreeId)===t&&Yt(e,t)===null;return{...e,archivedPage:null,...n?{editor:null}:{}}}function $s(e,t){let n=FI(BI(e,t));return n.unreadHold!==null&&n.activeId!==n.unreadHold&&(n={...n,unreadHold:null}),n.archivedPage!==null&&(xi(n)===null||Yt(n,n.archivedPage)!==null)&&(n=c0(n)),n.activeRepoId!==e.activeRepoId?n=LI(n):n.frame==="desk"&&n.activeRepoId&&!DI(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:RI(n.rows,n.activeRepoId,n.archiving),visibleDiscovered:OI(n.rows,n.activeRepoId)}}function BI(e,t){var n,r,i;switch(t.a){case"connected":return{...e,connected:t.v,connectFailure:t.v?null:t.failure??e.connectFailure};case"activate":{const a=As(e,t.id);return{...a,screen:t.id?II(a,t.id):"home"}}case"open-draft":{if(Iu(e))return e;const a=((n=i0(e,e.activeRepoId))==null?void 0:n.id)??null;return a?Ho({...As(e,a),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(a=>a.id===t.id))?e:{...e,archivedPage:t.id,editor:null,screen:"chat"};case"close-archived":return e.archivedPage?c0(e):e;case"restoring":return _t(e,t.id,a=>({...a,restoring:t.text}));case"archive-worktrees":{const a=t.ids.filter(c=>!e.archiving.includes(c)&&Yt(e,c));if(a.length===0)return e;const l={...e,archiving:[...e.archiving,...a]};return e.activeId&&a.includes(e.activeId)?As(l,Ga(l,e.activeRepoId)):l}case"shipping":return e.shipping[t.id]||!(Ks(e,t.id)||u0(e,t.id))?e:{...e,shipping:{...e.shipping,[t.id]:t.op}};case"activate-repo":{if(!Gs(e,t.id))return e;const a=e.newProject?{...e,newProject:null}:e;if(t.id===e.activeRepoId)return a;const l=Ga(a,t.id);return{...As(a,l),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 a="name"in t.v||"parent"in t.v||"url"in t.v||"mode"in t.v,{error:l,...c}=e.newProject;return{...e,newProject:{...a?c: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 a=t.v,l=e.editor,c=l&&l.worktreeId===a.worktreeId&&l.path===a.path&&l.ref===a.ref?l:null,d=a.line&&n0(e,a.worktreeId,a.path,a.line);return{...e,editor:{worktreeId:a.worktreeId,path:a.path,...a.ref?{ref:a.ref}:{},view:a.view??(c==null?void 0:c.view)??null,seq:a.seq,disk:(c==null?void 0:c.disk)??null,...d?{line:d}:{},focus:a.focus,conflict:(c==null?void 0:c.conflict)??null}}}case"editor-read":{const a=e.editor;if(!a||!Df(a,t.file))return e;const l=t.disk;if(!l){const g=l0(e,a.worktreeId,t.error??`could not read ${a.path}`);return a.disk?g:{...g,editor:null}}const c=kl(a.path),d=l.before===""?a.view&&a.view!=="diff"?a.view:c:a.view??(l.before===l.after?c:"diff");return{...e,editor:{...a,view:d,disk:l}}}case"editor-conflict":{const a=e.editor;return a&&Df(a,t.file)?{...e,editor:{...a,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 a=e.editor;return a&&Df(a,t.file)?{...e,editor:{...a,refused:t.message}}:e}case"notice":return _t(Ho(e),t.id,a=>({...a,notice:t.text}));case"ask-draft":return _t(e,t.id,a=>({...a,ask:t.ask}));case"ask-park":return _t(e,t.id,a=>({...a,askParked:t.askId}));case"ask-unpark":return _t(e,t.id,({askParked:a,...l})=>l);case"opened-url":return e.openUrl?{...e,openUrl:null}:e;case"set-draft":return _t(e,t.id,a=>{const{notice:l,...c}=ru(a,"walk");return{...c,draft:t.text,...l!==void 0&&t.text===""?{notice:l}:{}}});case"walk":return _t(e,t.id,a=>({...ru(a,"walk"),draft:t.text,...t.walk?{mark:{by:"walk",at:t.walk.at,from:t.walk.from}}:{}}));case"reveal":return _t(Ho(e),t.id,a=>{var l;return{...a,mark:{by:"reveal",seq:t.seq,n:((l=a.mark)==null?void 0:l.by)==="reveal"?a.mark.n+1:1}}});case"attach":return _t(Ho(e),t.id,({notice:a,...l})=>({...l,attachments:[...l.attachments,...t.items]}));case"detach":return _t(e,t.id,({notice:a,...l})=>({...l,attachments:l.attachments.filter(c=>c.key!==t.key)}));case"clear-attachments":return _t(e,t.id,({notice:a,...l})=>l.attachments.length?{...l,attachments:[]}:l);case"hmr":return _t(e,t.id,a=>({...a,turn:{...a.turn,hmr:!0}}));case"page":return _t(e,t.id,a=>({...a,page:{url:t.url??a.page.url,title:t.title??a.page.title,errors:t.fresh?[]:t.error?[...a.page.errors.slice(-2),t.error]:a.page.errors}}));case"links":return _t(e,t.id,a=>{const l=_I(a.links??[],t.links);return l===a.links?a:{...a,links:l}});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:s0(t.overlay)?e.paletteReturn:null};case"choosing-folder":return{...e,choosingFolder:t.v};case"close":return{...e,previewTheme:null,...PI(e,t.back)};case"toggle":return((i=e.overlay)==null?void 0:i.kind)===t.overlay.kind?$s(e,{a:"close"}):$s(e,{a:"open",overlay:t.overlay});case"palette-return":return{...e,paletteReturn:t.v};case"toggle-changes":return{...Ur(e,{changes:!e.layout.changes}),changesAuto:!1};case"focus-changes":return{...Ur(e,{changes:!0,changesTab:t.tab??e.layout.changesTab}),changesAuto:!1,focusChanges:e.focusChanges+1};case"changes-tab":return Ur(e,{changesTab:t.v});case"edit-commit":return{...Ur(e,{changes:!0}),changesAuto:!1,editCommit:e.editCommit+1};case"toggle-chat":return ro(e)?e:Ur(e,{chat:!e.layout.chat});case"focus-chat":return{...Ho(e),focusChat:e.focusChat+1};case"walked":return{...e,walked:e.walked+1};case"show-chat":return Ho(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"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 a={...e,frame:t.v};if(t.v!=="desk"||!a.activeRepoId)return a;const l=a.layouts[a.activeRepoId];return l?ch(a,l):a}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 a=e.activeRepoId;return a?{...e,discoveredOpen:{...e.discoveredOpen,[a]:!e.discoveredOpen[a]}}:e}case"toggle-archived":{const a=e.activeRepoId;return a?{...e,archivedOpen:{...e.archivedOpen,[a]:!e.archivedOpen[a]}}:e}case"tree-folder":{const a=e.treeOpen[t.worktreeId]??[];if(a.includes(t.path)===t.open)return e;const l=t.open?[...a,t.path]:a.filter(d=>d!==t.path),c={...e.treeOpen};return l.length>0?c[t.worktreeId]=l:delete c[t.worktreeId],{...e,treeOpen:c}}case"tree-reveal":{const a=e.treeOpen[t.worktreeId]??[],l=[];for(let g=t.path.indexOf("/");g!==-1;g=t.path.indexOf("/",g+1))l.push(t.path.slice(0,g));l.push(t.path);const c=l.filter(g=>!a.includes(g)),d=c.length?{...e.treeOpen,[t.worktreeId]:[...a,...c]}:e.treeOpen;return{...Ur(e,{changes:!0,changesTab:"files"}),changesAuto:!1,focusChanges:e.focusChanges+1,treeOpen:d,treeReveal:{worktreeId:t.worktreeId,path:t.path}}}case"files-asked":return _t(e,t.worktreeId,a=>({...a,filesFor:t.key}));case"toggle-zen":return ro(e)?e:{...e,zen:!e.zen};case"toggle-terminal":return Ur(e,{term:!e.layout.term});case"focus-terminal":return{...Ur(e,{term:!0}),focusTerm:e.focusTerm+1};case"toggle-design":return ro(e)?e:Ur(e,{design:!e.layout.design});case"term-stream":return _t({...Ur(e,{term:!0}),termTall:t.tall?e.termTall+1:e.termTall},t.id,a=>({...a,termStream:t.stream}));case"term-run":return _t({...Ur(e,{term:!0}),focusTerm:e.focusTerm+1,termRun:{id:t.id,command:t.command}},t.id,a=>({...a,termStream:to}));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 WI(e,t.msg)}}function uy(e,t){const n=Object.entries(e),r=n.filter(([i])=>t.some(a=>a.id===i));return r.length===n.length?e:Object.fromEntries(r)}function dy(e,t,n){const r=new Set(t.map(l=>l.id));n&&r.add(n);const i=([l,c])=>r.has(l)||!!c.draft,a=Object.entries(e);return a.every(i)?e:Object.fromEntries(a.filter(i))}function UI(e,t){let n=e;for(const[r,i]of Object.entries(t)){const a=n[r];a!=null&&a.draft||(n===e&&(n={...e}),n[r]={...a??Au,draft:i})}return n}function HI(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 Aa(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 fy(e){const t=e.newProject;if((t==null?void 0:t.phase)!=="creating"||!t.repoId)return e;const n=i0(e,t.repoId);return n?t.prompt.trim()?{..._t(e,n.id,i=>({...i,draft:t.prompt})),newProject:null,autoSend:n.id}:{...e,newProject:null}:e}function u0(e,t){return Object.values(e.trunks).some(n=>n.id===t)}function ZI(e,t,n){return zc(e.shipping,r=>!t.some(i=>i.id===r)&&!u0({trunks:n},r))}function WI(e,t){var n,r,i,a,l,c,d,g,k;switch(t.t){case"hello":{const p=E=>!!E&&t.rows.some(j=>j.id===E),h=E=>!!E&&t.repos.some(j=>j.id===E),v=h(e.activeRepoId)?e.activeRepoId:h(e.storedRepo)?e.storedRepo:null,b=p(e.activeId)?e.activeId:p(e.storedActive)?e.storedActive:Ga(e,v,t.rows),_=t.rows.find(E=>E.id===b);return{...e,heard:!0,repos:t.repos,rows:t.rows,activeId:b,activeRepoId:(_==null?void 0:_.repoId)??v??((n=t.repos[0])==null?void 0:n.id)??null,trunks:t.trunks,archiving:e.archiving.length?[]:e.archiving,shipping:zc(e.shipping,()=>!0),local:dy(UI(e.local,t.drafts),t.rows,e.archivedPage),lastActive:HI(e.lastActive,t.rows),treeOpen:uy(e.treeOpen,t.rows),discoveredOpen:Aa(e.discoveredOpen,t.repos),archivedOpen:Aa(e.archivedOpen,t.repos),refs:Aa(e.refs,t.repos),chats:Aa(e.chats,t.repos),archived:Aa(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,paired:t.paired,gitIdentity:t.gitIdentity,newProject:e.newProject??(t.repos.length===0&&t.rows.length===0&&t.pending.length===0?ly():null),pending:t.pending,visits:t.visits,self:t.self,update:t.update,version:t.version,install:t.install,activeImportId:t.pending.some(E=>E.id===e.activeImportId)?e.activeImportId:null}}case"self":return{...e,self:t.self};case"paired":return{...e,paired:!0,pairings:e.pairings+1};case"update":return{...e,update:t.update};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:p,...h}=t;return{...e,agentConfigs:{...e.agentConfigs,[h.agent]:h}}}case"pending-repos":{const p=new Set(e.pending.map(E=>E.id)),h=t.pending.find(E=>!p.has(E.id)),v=h&&e.pendingOpen?h.id:e.activeImportId,b=t.pending.some(E=>E.id===v),_=t.pending.some(E=>E.id===v&&E.error);return{...e,pending:t.pending,activeImportId:b?v:null,pendingOpen:_?!1:e.pendingOpen,newProject:h&&e.pendingOpen&&((r=e.newProject)==null?void 0:r.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:(((i=e.chosenFolder)==null?void 0:i.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:_t(e,t.boxId,p=>{var h;return p.draft===t.text||((h=p.mark)==null?void 0:h.by)==="walk"?p:{...p,draft:t.text}});case"repos":{const p=new Set(e.repos.map(j=>j.id)),h=t.repos.find(j=>!p.has(j.id));let v=e.activeRepoId,b=e.pendingOpen,_=e.newProject;h&&(b||!v)?(v=h.id,b=!1,_&&_.phase!=="unmaking"&&(_={..._,phase:"creating",repoId:h.id})):t.repos.some(j=>j.id===v)||(v=((a=t.repos[0])==null?void 0:a.id)??null),(_==null?void 0:_.phase)==="unmaking"&&!t.repos.some(j=>j.id===(_==null?void 0:_.repoId))&&(_={..._,phase:"editing",repoId:null}),t.repos.length===0&&!_&&(_=ly());const E=e.gitIdentity||t.repos.some(j=>j.made&&!p.has(j.id));return v===e.activeRepoId?{...e,repos:t.repos,pendingOpen:b,newProject:_,gitIdentity:E}:fy({...e,repos:t.repos,pendingOpen:b,newProject:_,gitIdentity:E,activeRepoId:v,activeId:Ga(e,v),editor:null})}case"worktrees":{let p=e.activeId;(!p||!t.rows.some(j=>j.id===p))&&(p=Ga(e,e.activeRepoId,t.rows));const h=new Set(e.rows.map(j=>j.id)),v=j=>{var x;return((x=j.worktree)==null?void 0:x.kind)==="worktree"&&j.worktree.createdBy===e.clientId},b=t.rows.find(j=>!h.has(j.id)&&v(j)),_=!!p&&e.rows.some(j=>{var x;return j.id===p&&((x=j.worktree)==null?void 0:x.kind)==="spare"})&&t.rows.some(j=>j.id===p&&v(j));b&&e.rows.length>0&&!_&&(p=b.id);const E=e.archiving.filter(j=>t.rows.some(x=>x.id===j));return fy({...As({...e,rows:t.rows,trunks:t.trunks,archiving:E.length===e.archiving.length?e.archiving:E,shipping:ZI(e,t.rows,t.trunks),local:dy(e.local,t.rows,e.archivedPage),treeOpen:uy(e.treeOpen,t.rows)},p),editor:p===e.activeId?e.editor:null,archivedPage:b?null:e.archivedPage})}case"proc":{const p=e.rows.map(h=>h.id===t.worktreeId?{...h,procs:KI(h.procs,t.proc)}:h);return{...e,rows:p}}case"log":return _t(e,t.worktreeId,p=>({...p,log:[...p.log.slice(-400),{proc:t.proc,line:t.line}]}));case"agent":{const p=t.event,h=t.worktreeId;let v=_t(e,h,b=>{const _=hy(b.chat,p,t.seq);let E=b.turn;p.type==="turn-start"?E={edits:!1,hmr:!1}:p.type==="tool-start"&&rE(p)&&(E={...E,edits:!0});const j=p.type==="session-info"&&p.model?p.model:b.model,x=p.type==="session-info"&&p.effort?p.effort:b.effort,H=p.type==="usage"?py(p):b.usage,{restoring:B,...re}=b,F=MI(p.type==="user-message"?re:b,p);return{...p.type==="user-message"?ru(F,"reveal"):F,chat:_,turn:E,...j!==b.model?{model:j}:{},...x!==b.effort?{effort:x}:{},...H!==b.usage?{usage:H}:{}}});if(p.type==="turn-end"){const b=v.local[h].turn;b.edits&&!b.hmr&&(v={...v,reloadReq:{id:h,n:(((l=v.reloadReq)==null?void 0:l.n)??0)+1}})}return(p.type==="agent-question"||p.type==="agent-permission")&&h===e.activeId&&(v=Ho(v)),v}case"backfill":{let p=[],h;for(const{seq:b,event:_}of t.events)p=hy(p,_,b),_.type==="usage"&&(h=py(_));const v=b=>t.events.some(({event:_})=>_.type==="user-message"&&_.text===b);return _t(e,t.worktreeId,({restoring:b,..._})=>({..._,chat:p,log:t.log??_.log,...h?{usage:h}:{},...b!==void 0&&!v(b)?{restoring:b}:{}}))}case"git-status":{let p=e.layout.changes,h=e.changesAuto;e.changesAuto&&t.worktreeId===e.activeId&&!p&&(t.files.length>0||(((c=t.committed)==null?void 0:c.length)??0)>0)&&(p=!0,h=!1);const v=t.worktreeId===e.archivedPage?xi(e):null;v&&(t.files.length>0||(((d=t.committed)==null?void 0:d.length)??0)>0||v.landed)&&(p=!0);const b=_t(e,t.worktreeId,_=>({..._,git:{files:t.files,committed:t.committed,ahead:t.ahead,behind:t.behind,unpushed:t.unpushed,head:t.head},changedRanges:{}}));return{...Ur(b,{changes:p}),changesAuto:h}}case"changed-ranges":{const p=_t(e,t.worktreeId,v=>({...v,changedRanges:{...v.changedRanges,[t.path]:{ranges:t.ranges,offset:t.lineOffset}}})),h=p.editor;return!((g=h==null?void 0:h.line)!=null&&g.fiber)||h.worktreeId!==t.worktreeId||h.path!==t.path?p:{...p,editor:{...h,line:n0(p,h.worktreeId,h.path,h.line)}}}case"shipped":{const p=t.worktreeId,h=t.suggestion?_t(As(e,p),p,b=>({...b,draft:t.suggestion})):e,v={...h,shipping:zc(h.shipping,b=>b===p),openUrl:t.ok&&t.url?t.url:h.openUrl};return t.ok?t.merged?a0(v,p,{kind:"landed",text:t.message,archiveIds:t.archiveIds??[]}):v:p?cy(v,p,t.message):Ep(v,t.message)}case"files":return _t(e,t.worktreeId,p=>({...p,files:t.paths,submodules:t.submodules,ignored:t.ignored}));case"search-results":return _t(e,t.worktreeId,p=>({...p,search:{query:t.query,hits:t.hits,truncated:t.truncated}}));case"element-sources":{if(e.editor&&e.editor.seq>t.seq)return e;const[p]=t.hits;if(!p)return _t(e,t.worktreeId,v=>({...v,notice:"nothing in the source matches this element"}));if(!t.sure)return $s(e,{a:"open",overlay:{kind:"element-sources",worktreeId:t.worktreeId,hits:t.hits}});const h=$s(e,{a:"open-file",v:{worktreeId:t.worktreeId,path:p.path,view:"file",line:{n:p.line},focus:!0,seq:t.seq}});return h.layout.changes?h:$s(h,{a:"toggle-changes"})}case"design-index":return _t(e,t.worktreeId,p=>({...p,design:t.index}));case"routes":return _t(e,t.worktreeId,p=>({...p,pages:{routes:t.routes,unseen:t.unseen}}));case"queue":return _t(e,t.worktreeId,p=>({...p,queue:t.items}));case"agent-commands":return _t(e,t.worktreeId,p=>({...p,commands:t.commands}));case"git-log":return _t(e,t.worktreeId,p=>({...p,commits:t.commits}));case"git-commit":return _t(e,t.worktreeId,p=>({...p,commitFiles:{...p.commitFiles,[t.sha]:t.files}}));case"error":{const p=t.worktreeId,h=e.newProject,v=(h==null?void 0:h.phase)==="creating"&&!h.repoId,b={...e,archiving:p?e.archiving.includes(p)?e.archiving.filter(E=>E!==p):e.archiving:e.archiving.length?[]:e.archiving,shipping:zc(e.shipping,E=>!p||E===p),newProject:v?{...h,phase:"editing",error:t.message}:(h==null?void 0:h.phase)==="unmaking"?null:h,pendingOpen:v?!1:e.pendingOpen};if(v)return b;const _=p?(k=b.local[p])==null?void 0:k.restoring:void 0;return p&&_!==void 0?_t(b,p,({restoring:E,...j})=>({...j,draft:j.draft||_,notice:t.message})):p?cy(b,p,t.message):Ep(b,t.message)}default:return e}}function KI(e,t){const n=e.findIndex(i=>i.name===t.name);if(n===-1)return[...e,t];const r=e.slice();return r[n]=t,r}function py(e){return{used:e.used,size:e.size,...e.cost!==void 0?{cost:e.cost}:{}}}function GI(e,t){const n=t.trim();return n!==""&&(e.trim()===n||e.trim().endsWith(`: ${n}`))}function hy(e,t,n){var a;const r=e[e.length-1],i=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}:{},...i}];case"text-delta":return(r==null?void 0:r.kind)==="assistant"?[...e.slice(0,-1),{...r,text:r.text+t.text}]:[...e,{kind:"assistant",text:t.text,...i}];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 l=e.findLastIndex(g=>g.kind==="tool"&&g.id===t.toolId);if(l===-1)return e;const c=e.slice(),d=c[l];return c[l]={...d,...t.name?{name:t.name}:{},...t.title?{title:t.title}:{},...t.input!==void 0?{input:t.input}:{},...t.kind?{toolKind:t.kind}:{}},c}case"tool-delta":{const l=e.findLastIndex(g=>g.kind==="tool"&&g.id===t.toolId);if(l===-1)return e;const c=e.slice(),d=c[l];return c[l]={...d,output:(d.output??"")+t.text},c}case"tool-end":{const l=e.findLastIndex(g=>g.kind==="tool"&&g.id===t.toolId);if(l===-1)return e;const c=e.slice(),d=c[l];return c[l]={...d,output:t.output,isError:t.isError,done:!0},c}case"agent-error":return(r==null?void 0:r.kind)==="assistant"&&GI(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"agent-auth-required":return[...e,{kind:"auth",agent:t.agent,agentName:t.agentName,methods:t.methods,...t.rejected?{rejected:!0}:{},done:!1}];case"agent-auth-ok":return e.some(l=>l.kind==="auth"&&!l.done)?e.map(l=>l.kind==="auth"&&!l.done?{...l,done:!0}:l):e;case"agent-question":return my(e,t.toolId,{kind:"ask",id:t.id,ask:{kind:"question",message:t.message,questions:t.questions}});case"agent-permission":return my(e,t.toolId,{kind:"ask",id:t.id,ask:{kind:"permission",title:t.title,...t.detail?{detail:t.detail}:{},...t.plan?{plan:t.plan}:{},choices:t.choices}});case"agent-ask-end":{const l=e.findLastIndex(d=>d.kind==="ask"&&d.id===t.id&&!d.outcome);if(l===-1)return e;const c=e.slice();return c[l]={...c[l],outcome:t.outcome,...t.answers?{answers:t.answers}:{},...t.choiceId?{choiceId:t.choiceId}:{}},c}case"turn-end":return e.some(l=>l.kind==="tool"&&!l.done)?e.map(l=>l.kind==="tool"&&!l.done?{...l,done:!0}:l):e;default:return e}}function my(e,t,n){const r=t?e.findLastIndex(i=>i.kind==="tool"&&i.id===t):-1;return r===-1?[...e,n]:[...e.slice(0,r),...e.slice(r+1),n]}function VI(e){let t=e;const n=new Set;return{getState:()=>t,dispatch(r){const i=$s(t,r);if(i!==t){t=i;for(const a of n)a()}},subscribe(r){return n.add(r),()=>n.delete(r)}}}const d0=T.createContext(null),f0=T.createContext(null),p0=T.createContext(null);function qI({store:e,sock:t,files:n,children:r}){return f.jsx(d0.Provider,{value:e,children:f.jsx(f0.Provider,{value:t,children:f.jsx(p0.Provider,{value:n,children:r})})})}function Sn(){const e=T.useContext(d0);if(!e)throw new Error("useStore outside <StoreProvider>");return e}function z(e){const t=Sn();return T.useSyncExternalStore(t.subscribe,()=>e(t.getState()))}function dh(){const e=z(n=>n.systemDark),t=z(n=>{var r;return(r=n.daylight)==null?void 0:r.dark});return{system:e,daylight:t??e}}function Ve(){return Sn().dispatch}function Ge(){return T.useContext(f0)}function YI(){return T.useContext(p0)}const dt={active:"toyon-active",repo:"toyon-repo",lastActive:"toyon-last",discoveredOpen:"toyon-disc",archivedOpen:"toyon-arch",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-"},QI="orch-";function XI(){for(const[e,t]of[[localStorage,["active","token","theme","editorHeight","editorFull"]],[sessionStorage,["client"]]])for(const n of t){const r=dt[n],i=QI+r.slice(6);try{const a=e.getItem(i);a!==null&&(e.getItem(r)===null&&e.setItem(r,a),e.removeItem(i))}catch{}}}function JI(e=!1,t=!0){const n=T.useRef(null);return T.useEffect(()=>{if(!t)return;const r=()=>{const a=n.current;!a||document.activeElement===a||(a.focus(),e&&a instanceof HTMLInputElement&&a.select())};r();const i=requestAnimationFrame(r);return()=>cancelAnimationFrame(i)},[e,t]),n}function no(e,t,n){const r=()=>{try{return n(localStorage.getItem(e))??t}catch{return t}},[i,a]=T.useState(()=>({key:e,value:r()}));return i.key!==e&&a({key:e,value:r()}),[i.key===e?i.value:r(),d=>{a({key:e,value:d});try{localStorage.setItem(e,typeof d=="boolean"?d?"1":"0":String(d))}catch{}}]}function Ms(e,t){return n=>{n.preventDefault(),document.body.classList.add("resizing");const r=n.currentTarget;r.classList.add("active");const i=l=>{const c=e(l,r);c!==null&&t(c)},a=()=>{document.body.classList.remove("resizing"),r.classList.remove("active"),window.removeEventListener("pointermove",i),window.removeEventListener("pointerup",a)};window.addEventListener("pointermove",i),window.addEventListener("pointerup",a)}}function h0(e,t){const[n,r]=T.useState(!1);return T.useEffect(()=>{if(!e){r(!1);return}const i=setTimeout(()=>r(!0),t);return()=>clearTimeout(i)},[e,t]),n}function e2(){const[e,t]=T.useState(window.innerWidth);return T.useEffect(()=>{const n=()=>t(window.innerWidth);return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),e}function t2(e){const t=T.useRef(null);return T.useLayoutEffect(()=>{const n=t.current;if(!n)return;t.current=null;const r=n.closest(e);if(!r)return;const i=r.getBoundingClientRect(),a=n.getBoundingClientRect(),l=a.bottom-i.bottom;if(l<=0)return;const c=parseFloat(getComputedStyle(r).paddingTop)||0;r.scrollTop+=Math.min(l,Math.max(0,a.top-i.top-c))}),n=>{t.current=n}}const n2=40;function m0(e,t){const n=T.useRef(!0),[r,i]=T.useState(!1);ft([t],()=>{n.current||i(!0)});const a=T.useCallback(()=>{const c=e.current;c&&(n.current=c.scrollHeight-c.scrollTop-c.clientHeight<n2,n.current&&i(!1))},[e]),l=T.useCallback((c=!1)=>{const d=e.current;d&&(c?d.scrollTo({top:d.scrollHeight,behavior:"smooth"}):d.scrollTop=d.scrollHeight,n.current=!0,i(!1))},[e]);return T.useEffect(()=>{const c=e.current;if(!c)return;c.addEventListener("scroll",a,{passive:!0});const d=new ResizeObserver(()=>{n.current&&(c.scrollTop=c.scrollHeight)});d.observe(c);for(const k of c.children)d.observe(k);const g=new MutationObserver(k=>{for(const p of k){for(const h of p.addedNodes)h instanceof Element&&d.observe(h);for(const h of p.removedNodes)h instanceof Element&&d.unobserve(h)}});return g.observe(c,{childList:!0}),()=>{c.removeEventListener("scroll",a),g.disconnect(),d.disconnect()}},[e,a]),{away:r,pinned:()=>n.current,jump:l,read:a}}function ft(e,t){const n=T.useRef(t);n.current=t,T.useEffect(()=>n.current(),e)}function g0(e){const[t,n]=T.useState({left:0,right:0});return T.useLayoutEffect(()=>{if(!e)return;const r=()=>{const a=e.getBoundingClientRect(),l={left:Math.round(a.left),right:Math.round(a.right)};n(c=>c.left===l.left&&c.right===l.right?c:l)};r();const i=new ResizeObserver(r);return i.observe(e),window.addEventListener("resize",r),()=>{i.disconnect(),window.removeEventListener("resize",r)}},[e]),t}function gy(){const[e,t]=T.useState(null);return[t,g0(e)]}const Vs=()=>z(e=>e.activeId),k0=()=>h0(!z(e=>e.connected),900),Vo=()=>z(e=>Yt(e,e.activeId)),fh=()=>z(e=>Ks(e,e.activeId)),y0=()=>z(e=>e.rows),ph=()=>z(e=>e.visible),r2=()=>z(e=>e.visibleDiscovered),o2=()=>z(e=>e.activeRepoId?e.discoveredOpen[e.activeRepoId]??!1:!1),ky=[],v0=()=>z(e=>e.activeRepoId?e.archived[e.activeRepoId]??ky:ky),i2=()=>z(e=>e.activeRepoId?e.archivedOpen[e.activeRepoId]??!1:!1),Qi=()=>z(xi),qs=()=>z(e=>Gs(e,e.activeRepoId)),w0=e=>z(t=>wo(t,e)),It=(e,t)=>z(n=>wo(n,e)[t]),s2=()=>z(e=>e.overlay),Ru=()=>z(CI),b0=()=>z(o0),yl=()=>z(jI),vl=()=>z(ro),a2=()=>z(e=>e.newProject),Xi=()=>z(e=>e.touch),l2=()=>z(e=>e.draft),hh=()=>z(za),c2=()=>z(e=>{const t=Ks(e,e.activeId),n=t?e.repos.find(r=>r.id===t.repoId):null;return tu(n)?n:null}),x0="application/x-toyon-source";function _3(e){const t=e.endColumn===1&&e.endLineNumber>e.startLineNumber?e.endLineNumber-1:e.endLineNumber;return{startLine:e.startLineNumber,endLine:t}}function u2(e,t){e.setData(x0,JSON.stringify(t))}const yy=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1;function d2(e,t){const n=e.getData(x0);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:i,endLine:a,ref:l}=r;return!yy(i)||!yy(a)||a<i?null:{path:r.path,startLine:i,endLine:a,...typeof l=="string"?{ref:l}:{}}}const qi=(e,t,n)=>e.dispatch({a:"notice",id:t,text:n});function Ou(e,t,n){var i;const r=hE(((i=e.getState().local[t])==null?void 0:i.attachments)??[],n);return r===0&&qi(e,t,Yp(n)),r}function vy(e){switch(e.kind){case"image":{const{key:t,bytes:n,...r}=e;return r}case"paste":{const{key:t,chars:n,lines:r,preview:i,...a}=e;return a}case"pick":{const{key:t,...n}=e;return n}}}function mh(e,t,n,r={}){if(!t)return;const i=eS(r.source?n.replace(/\r?\n$/,""):n);if(Ou(e,t,"paste")!==0){if(i.length>WE)return qi(e,t,"that paste is too large; save it in the worktree and reference it with @path");e.dispatch({a:"attach",id:t,items:[{kind:"paste",key:crypto.randomUUID(),text:i,...r,...qE(i)}]})}}function wy(e,t){var a;const n=e.getState(),r=Yt(n,n.activeId),i=gl(r);if(t&&i&&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[i])==null?void 0:a.attachments)??[]).some(d=>{var v;if(d.kind!=="paste")return!1;if(!("source"in t))return d.name===t.name&&d.text===t.text;const{path:g,startLine:k,endLine:p,ref:h}=t.source;return((v=d.source)==null?void 0:v.path)===g&&d.source.startLine===k&&d.source.endLine===p&&d.source.ref===h})||mh(e,i,t.text,l)}e.dispatch({a:"focus-chat"})}function gh(e,t){return t!==e.activeId?null:gl(Yt(e,t))}const _0=(e,t)=>`@${e}${t?"/":""}`;function E0(e,t,n){var c;const r=e.getState(),i=gh(r,t);if(!i)return;const a=((c=r.local[i])==null?void 0:c.draft)??"",l=a===""||/\s$/.test(a)?"":" ";e.dispatch({a:"set-draft",id:i,text:`${a}${l}${n}`}),e.dispatch({a:"focus-chat"})}function S0(e,t,n,r){E0(e,t,`${_0(n,r)} `)}function by(e,t,n){E0(e,t,n)}function f2(e,t){return Yt(e,t)?t:null}function p2(e,t){var r;const n=(r=Yt(e,t))==null?void 0:r.worktree;return n?[n.path]:[]}function xy(e,t){if(!e)return e;const n=t.find(r=>e.startsWith(`${r}/`));return n?e.slice(n.length+1):e}function h2(e,t,n){var h;e.dispatch({a:"set-picking",v:!1});const r=e.getState(),i=f2(r,t);if(!i)return;const{classes:a,route:l,element:c,...d}=n,g=p2(r,t),k={...d,file:xy(d.file,g),callFile:xy(d.callFile,g)};!(((h=r.local[i])==null?void 0:h.attachments)??[]).some(v=>v.kind==="pick"&&v.selector===k.selector)&&Ou(e,i,"pick")>0&&e.dispatch({a:"attach",id:i,items:[{kind:"pick",key:crypto.randomUUID(),...k}]}),e.dispatch({a:"focus-chat"})}const N0=new Set(UE),m2=2*1024*1024,g2=/^image\.[a-z0-9]+$/i,k2=e=>g2.test(e.name),y2=(e,t)=>e===t||e.name===t.name&&e.size===t.size&&e.type===t.type&&e.lastModified===t.lastModified;function v2(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=>y2(l,a))||n.push(a);const r=n.filter(a=>!k2(a));if(r.length>0)return r;const i=n.find(a=>N0.has(a.type))??n[0];return i?[i]:[]}function w2(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 b2(e){if(e.size>m2)return null;try{return new TextDecoder("utf-8",{fatal:!0}).decode(await e.arrayBuffer())}catch{return null}}async function x2(e){try{return await createImageBitmap(e)}catch{throw new Error(`${e.name||"image"}: not a readable image`)}}function _2(e){let t="";const n=new Uint8Array(e);for(let r=0;r<n.length;r+=32768)t+=String.fromCharCode(...n.subarray(r,r+32768));return btoa(t)}function _y(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((i,a)=>r.toBlob(l=>l?i(l):a(new Error("could not encode image")),n,.9))}let E2=0;async function S2(e){const t=await x2(e);try{const n=Math.max(t.width,t.height);let r=e,i=e.type,a=t.width,l=t.height;if(!N0.has(i)||n>kk||e.size>Tf){const c=i==="image/jpeg"?"image/jpeg":"image/png";let d=Math.min(1,kk/n);for(r=await _y(t,d,c);r.size>Tf&&d>.1;)d*=.7,r=await _y(t,d,c);if(r.size>Tf)throw new Error(`${e.name||"image"}: too large even after downscaling`);i=c,a=Math.max(1,Math.round(t.width*d)),l=Math.max(1,Math.round(t.height*d))}return{kind:"image",key:`img${++E2}`,name:e.name||`pasted.${i==="image/jpeg"?"jpg":"png"}`,mimeType:i,data:_2(await r.arrayBuffer()),width:a,height:l,bytes:r.size}}finally{t.close()}}function N2(e){return`data:${e.mimeType};base64,${e.data}`}function T2(e){return e>=1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}const Fc={el:null},C2=80,j2=2e3;let Kr=null,Sp;const T0=(e,t)=>{clearTimeout(Sp),Sp=setTimeout(()=>$u(e),t)};function kh(e,t){Kr??(Kr={refused:!1}),e.dispatch({a:"drag-files",v:t&&!Kr.refused}),T0(e,j2)}function A2(e){Kr&&T0(e,C2)}function $u(e){clearTimeout(Sp),Kr=null,e.dispatch({a:"drag-files",v:!1})}function I2(e){Kr&&(Kr.refused=!0,e.dispatch({a:"drag-files",v:!1}))}const C0="application/x-toyon-path";let Zi=null;function R2(e){Zi=e}function j0(e){Zi=null,Kr&&$u(e)}const Ey=e=>Zi!==null&&Array.from(e.dataTransfer.types).includes(C0);function O2(e){return{onDragOver:t=>{if(!Ey(t)||!Zi)return;t.preventDefault();const n=gh(e.getState(),Zi.worktreeId)!==null;t.dataTransfer.dropEffect=n?"copy":"none",n&&kh(e,!0)},onDrop:t=>{if(!Ey(t)||!Zi)return;t.preventDefault();const{worktreeId:n,path:r,folder:i}=Zi;j0(e),S0(e,n,r,i)}}}async function A0(e,t,n){var c;if(!t||n.length===0)return;const r=Ou(e,t,"image");if(r===0)return;const i=await Promise.allSettled(n.slice(0,r).map(S2)),a=i.flatMap(d=>d.status==="fulfilled"?[d.value]:[]),l=i.find(d=>d.status==="rejected");a.length&&e.dispatch({a:"attach",id:t,items:a}),l?qi(e,t,String(((c=l.reason)==null?void 0:c.message)??l.reason)):n.length>r&&qi(e,t,`kept ${r} of ${n.length}: ${Yp("image")}`)}async function I0(e,t,n){if(!t||n.length===0)return;const r=Ou(e,t,"paste");if(r!==0){for(const i of n.slice(0,r)){const a=await b2(i);a===null?qi(e,t,`${i.name}: not a text file`):mh(e,t,a,{name:i.name})}n.length>r&&qi(e,t,`kept ${r} of ${n.length}: ${Yp("paste")}`)}}function yh(e){const t=e.getState();return gl(Yt(t,t.activeId))}function $2(e,t){const n=(Kr==null?void 0:Kr.refused)??!1;if($u(e),n||t.length===0)return;const r=yh(e),i=t.filter(a=>a.type.startsWith("image/"));if(i.length)return void A0(e,r,i);I0(e,r,t)}function R0(e){const t=(Kr==null?void 0:Kr.refused)??!1;$u(e);const n=yh(e);!t&&n&&qi(e,n,"drop images on the chat to attach them")}const Sy=e=>!!e&&Array.from(e.types).includes("Files"),Ny=e=>{var t;return e.target instanceof Node&&!!((t=Fc.el)!=null&&t.contains(e.target))};function M2(){const e=Sn();T.useEffect(()=>{const t=a=>{a.defaultPrevented||!Sy(a.dataTransfer)||(a.preventDefault(),kh(e,Ny(a)&&!!yh(e)),a.dataTransfer&&(a.dataTransfer.dropEffect=e.getState().dragFiles?"copy":"none"))},n=a=>{var l;a.defaultPrevented||!Sy(a.dataTransfer)||(a.preventDefault(),Ny(a)?$2(e,Array.from(((l=a.dataTransfer)==null?void 0:l.files)??[])):R0(e))},r=()=>A2(e),i=a=>{a.key==="Escape"&&I2(e)};return window.addEventListener("dragover",t),window.addEventListener("drop",n),window.addEventListener("dragleave",r),window.addEventListener("keydown",i,!0),()=>{window.removeEventListener("dragover",t),window.removeEventListener("drop",n),window.removeEventListener("dragleave",r),window.removeEventListener("keydown",i,!0)}},[e])}function P2(e,t){const n=Sn(),r=T.useRef(!1);return{onPaste:c=>{const d=v2(c.clipboardData);if(d.length>0)return c.preventDefault(),void A0(n,e,d);const g=w2(c.clipboardData);if(g.length>0)return c.preventDefault(),void I0(n,e,g);if(r.current)return;const k=c.clipboardData.getData("text/plain"),p=k.trim()?d2(c.clipboardData,t):null;!(p&&k.includes(`
96
+ `))&&!YE(k)||(c.preventDefault(),mh(n,e,k,p?{source:p}:{}))},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 L2={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",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",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",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",dot:"M8 4.6a3.4 3.4 0 1 0 0 6.8 3.4 3.4 0 1 0 0-6.8z"};function Ct({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:L2[e]})})}function vh({size:e="inline",className:t}){return f.jsx("span",{className:Ke("spinner",e==="dot"&&"spinner-dot",t),"aria-hidden":"true"})}const D2='button, a[href], input, textarea, select, summary, label, [role="button"], [role="menuitem"]';function Ty(e){var n;const t=e;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,D2))??t??null}function z2(e,t){var r,i,a;if(e.box.contains(t)||(r=e.trigger)!=null&&r.contains(t))return!0;const n=(a=(i=t.closest)==null?void 0:i.call(t,"[aria-controls]"))==null?void 0:a.getAttribute("aria-controls");return!!n&&n===e.box.id}function F2(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 B2(e,t){const n=new Set;for(const r of e)if(z2(r,t))for(let i=r;i;i=i.parent)n.add(i);return e.filter(r=>!n.has(r)&&r.dismiss).reverse()}const U2=e=>{setTimeout(e,0)};function H2({schedule:e=U2}={}){let t=[],n=null;const r=i=>{var a;for(const l of[...t].reverse())(a=l.dismiss)==null||a.call(l,i)};return{register(i){const a=i.trigger??(i.from===void 0?n:null),l={box:i.box,trigger:a,parent:F2(t,i.from??a),dismiss:i.dismiss,onKey:i.onKey};return t=[...t,l],l},unregister(i){t=t.filter(a=>a!==i)},top:()=>t[t.length-1]??null,open:()=>t,install(i){const a=i.document,l=p=>{var v;const h=p.target;if(h)for(const b of B2(t,h))(v=b.dismiss)==null||v.call(b,"outside");n=Ty(p.target)},c=()=>e(()=>n=null),d=p=>{n||(n=Ty(p.target),c())},g=p=>{var v;const h=t[t.length-1];(v=h==null?void 0:h.onKey)==null||v.call(h,p)},k=()=>e(()=>{var p;((p=a.activeElement)==null?void 0:p.tagName)==="IFRAME"&&r("frame")});return a.addEventListener("pointerdown",l,!0),a.addEventListener("pointerup",c,!0),a.addEventListener("pointercancel",c,!0),a.addEventListener("click",d,!0),i.addEventListener("keydown",g,!0),i.addEventListener("blur",k),()=>{a.removeEventListener("pointerdown",l,!0),a.removeEventListener("pointerup",c,!0),a.removeEventListener("pointercancel",c,!0),a.removeEventListener("click",d,!0),i.removeEventListener("keydown",g,!0),i.removeEventListener("blur",k)}}}}const ol=H2(),O0=e=>({left:e.x,top:e.y,right:e.x,bottom:e.y});function Z2(e,t){return t.matchWidth===void 0?void 0:Math.max(0,e.right-e.left+t.matchWidth)}const W2=new Set(["top","bottom"]),zf={top:"bottom",bottom:"top",left:"right",right:"left"};function Ff(e,t,n,r,i){const a=n==="top"||n==="left";return i?a?e.end+r-t:e.start-r:a?e.start-r-t:e.end+r}function Cy(e,t,n,r,i){return n==="top"||n==="left"?e>=i:e+t<=r-i}function Bf(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 jy(e,t,n,r,i){return n==="start"?e+t<=r-i:e>=i}const Ay=(e,t,n,r)=>n||!r?e:t,Iy=(e,t,n,r)=>Math.max(r,Math.min(e,n-r-t));function K2(e,t,n,r){const{offset:i=0,alignOffset:a=0,cover:l=!1,flip:c="none",margin:d=8}=r,g=W2.has(r.side),k=g?{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},p=g?{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 h=r.side;if(c==="side"||c==="both"){const E=Ff(k.a,k.size,h,i,l),j=Ff(k.a,k.size,zf[h],i,l);h=Ay(h,zf[h],Cy(E,k.size,h,k.limit,d),Cy(j,k.size,zf[h],k.limit,d))}let v=r.align??"center";if((c==="align"||c==="both")&&v!=="center"){const E=v==="start"?"end":"start",j=Bf(p.a,p.size,v,a),x=Bf(p.a,p.size,E,a);v=Ay(v,E,jy(j,p.size,v,p.limit,d),jy(x,p.size,E,p.limit,d))}const b=Iy(Ff(k.a,k.size,h,i,l),k.size,k.limit,d),_=Iy(Bf(p.a,p.size,v,a),p.size,p.limit,d);return g?{x:_,y:b,side:h,align:v}:{x:b,y:_,side:h,align:v}}const Uf=typeof HTMLElement<"u"&&"showPopover"in HTMLElement.prototype,Ry=e=>(e==null?void 0:e.getBoundingClientRect())??null;function G2(e,t,n,r){const i=e.querySelector(t);if(!i)return null;const a=e.getBoundingClientRect(),l=i.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 Ji({className:e,anchor:t,placement:n,coverBy:r,track:i=t==="parent",raiseKey:a,onDismiss:l,onKey:c,trigger:d,from:g,boxRef:k,handle:p,children:h,...v}){const b=T.useRef(null),_=T.useRef({anchor:t,placement:n,coverBy:r,onDismiss:l,onKey:c,trigger:d,from:g});_.current={anchor:t,placement:n,coverBy:r,onDismiss:l,onKey:c,trigger:d,from:g};const E=T.useCallback(()=>{const x=b.current,{anchor:H,placement:B,coverBy:re}=_.current;if(!x||!H||!B)return;const F=H==="parent"?Ry(x.parentElement):H();if(!F)return;const C=Z2(F,B);C!==void 0&&(x.style.width=`${C}px`);for(let L=0;L<2;L++){const I=re?G2(x,re,x.dataset.side??"",x.dataset.align??""):null,Z=K2(F,{w:x.offsetWidth,h:x.offsetHeight},{w:window.innerWidth,h:window.innerHeight},I?{...B,...I}:B);x.style.left=`${Z.x}px`,x.style.top=`${Z.y}px`;const V=x.dataset.side!==Z.side||x.dataset.align!==Z.align;if(x.dataset.side=Z.side,x.dataset.align=Z.align,!V)break}},[]);T.useImperativeHandle(p,()=>({update:E}),[E]),T.useLayoutEffect(()=>{const x=b.current;if(!x)return;k&&(k.current=x),Uf&&(x.popover="manual",x.matches(":popover-open")||x.showPopover());const{onDismiss:H,onKey:B,trigger:re,from:F}=_.current,C=H||B?ol.register({box:x,trigger:re,from:F,dismiss:H?L=>{var I,Z;return(Z=(I=_.current).onDismiss)==null?void 0:Z.call(I,L)}:void 0,onKey:B?L=>{var I,Z;return(Z=(I=_.current).onKey)==null?void 0:Z.call(I,L)}:void 0}):null;return()=>{C&&ol.unregister(C),k&&(k.current=null),Uf&&x.isConnected&&x.matches(":popover-open")&&x.hidePopover()}},[k]),T.useLayoutEffect(E),T.useLayoutEffect(()=>{if(!i)return;let x=0,H="";const B=()=>{const re=b.current,{anchor:F}=_.current,C=re&&F?F==="parent"?Ry(re.parentElement):F():null;if(re&&C){const L=`${C.left},${C.top},${C.right},${C.bottom},${re.offsetWidth},${re.offsetHeight},${window.innerWidth},${window.innerHeight}`;L!==H&&(H=L,E())}x=requestAnimationFrame(B)};return x=requestAnimationFrame(B),()=>cancelAnimationFrame(x)},[i,E]);const j=T.useRef(!0);return ft([a],()=>{if(j.current){j.current=!1;return}const x=b.current;!Uf||!(x!=null&&x.matches(":popover-open"))||(x.hidePopover(),x.showPopover(),E())}),f.jsx("div",{ref:b,className:Ke("float",e),...v,children:h})}function V2(e,{onDismiss:t,onKey:n,trigger:r}={}){const i=T.useRef({onDismiss:t,onKey:n,trigger:r});i.current={onDismiss:t,onKey:n,trigger:r},T.useLayoutEffect(()=>{const a=e.current;if(!a)return;const{onDismiss:l,onKey:c,trigger:d}=i.current,g=ol.register({box:a,trigger:d,dismiss:l?k=>{var p,h;return(h=(p=i.current).onDismiss)==null?void 0:h.call(p,k)}:void 0,onKey:c?k=>{var p,h;return(h=(p=i.current).onKey)==null?void 0:h.call(p,k)}:void 0});return()=>ol.unregister(g)},[e])}const q2=/^[⌘⇧⌥⌃]+/;function Zr({k:e,chip:t=!1,className:n}){var l;const r=(l=e.match(q2))==null?void 0:l[0],i=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}),i]})}function Et(e,t,{placement:n,detail:r,dot:i,name:a,aside:l,also:c}={}){const g=[a?`${e}: ${a}`:e,a?l:void 0,r].filter(Boolean).join(", ");return{"data-tip":e,"data-tip-key":t,"data-tip-placement":n,"data-tip-detail":r,"data-tip-dot":i,"data-tip-name":a,"data-tip-aside":l,"data-tip-also":c==null?void 0:c.text,"data-tip-also-key":c==null?void 0:c.key,"aria-label":t?`${g} (${t})`:g}}const Y2=120,Q2=600,X2=150,J2=6,eR=18,Oy=8;function $y(e){const t=e.dataset.tipPlacement;return t==="follow"||t==="top"||t==="bottom"||t==="left"||t==="right"?t:"bottom"}function tR(e){return e==="follow"?{side:"bottom",align:"start",offset:eR,alignOffset:-12,flip:"both",margin:Oy}:{side:e,align:"center",offset:J2,flip:"side",margin:Oy}}function nR(e,t){return e.placement==="follow"?O0(t):e.el.getBoundingClientRect()}function $0(){const[e,t]=T.useState(null),n=T.useRef(null),r=T.useRef(null),i=T.useRef({x:0,y:0}),a=Xi();if(T.useEffect(()=>{if(a)return;let d=0,g=0,k=null,p=!1,h=0;const v=()=>{window.clearTimeout(d),window.clearTimeout(g)},b=()=>{v(),p&&(h=Date.now()),p=!1,k=null,t(null)},_=(F,C)=>{const L=F.dataset.tip;if(!L)return b();v(),p=!0,t({el:F,text:L,key:F.dataset.tipKey,detail:F.dataset.tipDetail,dot:F.dataset.tipDot,name:F.dataset.tipName,aside:F.dataset.tipAside,also:F.dataset.tipAlso&&F.dataset.tipAlsoKey?{text:F.dataset.tipAlso,key:F.dataset.tipAlsoKey}:void 0,placement:C})},E=F=>{const C=F.target;return C instanceof Element?C.closest("[data-tip]"):null},j=F=>{i.current={x:F.clientX,y:F.clientY};const C=E(F);if(C===k)return;if(v(),k=C,!C){p&&(g=window.setTimeout(b,X2));return}const L=$y(C);if(p||Date.now()-h<Q2)return _(C,L);d=window.setTimeout(()=>_(C,L),Y2)},x=F=>{F.relatedTarget||b()},H=F=>{const C=E(F);if(C!=null&&C.matches(":focus-visible")){v(),k=C;const L=$y(C);_(C,L==="follow"?"bottom":L)}},B=()=>b(),re=F=>{F.key!=="Shift"&&F.key!=="Control"&&F.key!=="Alt"&&F.key!=="Meta"&&b()};return document.addEventListener("mouseover",j),document.addEventListener("mouseout",x),document.addEventListener("mousedown",b),document.addEventListener("keydown",re),document.addEventListener("scroll",b,!0),document.addEventListener("focusin",H),document.addEventListener("focusout",B),window.addEventListener("blur",b),()=>{v(),document.removeEventListener("mouseover",j),document.removeEventListener("mouseout",x),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",re),document.removeEventListener("scroll",b,!0),document.removeEventListener("focusin",H),document.removeEventListener("focusout",B),window.removeEventListener("blur",b)}},[a]),T.useLayoutEffect(()=>{e&&!e.el.isConnected&&t(null)},[e]),T.useEffect(()=>{if((e==null?void 0:e.placement)!=="follow")return;const d=g=>{var k;i.current={x:g.clientX,y:g.clientY},(k=r.current)==null||k.update()};return document.addEventListener("mousemove",d),()=>document.removeEventListener("mousemove",d)},[e]),!e)return null;const l=f.jsxs(f.Fragment,{children:[e.dot==="spinner"?f.jsx(vh,{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(Zr,{k:e.key,className:"tooltip-key"})]});return f.jsxs(Ji,{className:"tooltip",role:"tooltip",boxRef:n,handle:r,anchor:()=>nR(e,i.current),placement:tR(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(Zr,{k:e.key,className:"tooltip-key"}):f.jsx("span",{}),f.jsx("span",{className:"tooltip-also",children:e.also.text}),f.jsx(Zr,{k:e.also.key,className:"tooltip-key"})]}):c,e.name&&f.jsxs("div",{className:"tooltip-name",children:[e.placement==="left"&&e.aside&&f.jsx("span",{className:"tooltip-aside",children:e.aside}),f.jsx("span",{children:e.name}),e.placement!=="left"&&e.aside&&f.jsx("span",{className:"tooltip-aside",children:e.aside})]}),e.detail&&f.jsx("div",{className:"tooltip-detail",children:e.detail})]})}const rR={sm:"",md:"btn-md",lg:"btn-lg"},oR={ghost:"",outline:"btn-outline",field:"btn-outline btn-field",inline:"btn-inline"},M0={primary:"tone-primary",quiet:"tone-quiet",danger:"tone-danger",strong:"tone-strong",chrome:"tone-chrome"};function $e({variant:e="ghost",size:t="sm",tone:n,on:r,mono:i,busy:a,className:l,type:c="button",disabled:d,children:g,...k}){const p=a&&e==="inline",h=Ke("btn",oR[e],rR[t],n&&M0[n],r&&"on",i&&"btn-mono",a&&"btn-busy",l);return f.jsxs("button",{className:h,type:c,disabled:a||d,"aria-busy":a||void 0,...k,children:[a&&!p&&f.jsx(vh,{}),p?f.jsx("span",{className:"live-text",children:g}):g]})}function Dt({icon:e,label:t,hint:n,detail:r,also:i,badge:a,tone:l,on:c,className:d,type:g="button",...k}){const p=Ke("btn-icon",l&&M0[l],c&&"on",d);return f.jsxs("button",{className:p,type:g,...Et(t,n,{detail:r,also:i}),...k,children:[typeof e=="string"?f.jsx(Ct,{name:e}):e,a]})}function Ys(e,t,n){return n===0?0:(e+t+n)%n}function My(e,t,n){return e>=0?Ys(e,t,n):n===0?-1:t>0?0:n-1}function P0(e,t,n){var a;const r=e.length,i=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(i))return c}return-1}function Hf(e,t){return e&&e.length>t.length&&e.toLowerCase().startsWith(t.toLowerCase())?e.slice(t.length):null}function iR(e,t){if(e==null)return null;if(typeof e=="string"){const i=Hf(e,t);return i?{text:i,accept:i,params:[]}:null}const n=Hf(e.show,t);if(!n)return null;const r=(e.params??[]).map(([i,a])=>[Math.max(i,t.length)-t.length,a-t.length]).filter(([i,a])=>a>i);return{text:n,accept:Hf(e.accept,t),params:r}}function L0(e){const{results:t,keyOf:n,q:r,onPick:i,listRef:a,onActive:l,onSide:c,completionOf:d,narrowTo:g,setQ:k,tabPicks:p,onIdlePick:h}=e,[v,b]=T.useState(()=>{var F;return e.idle?-1:Math.max(0,((F=e.initialIndex)==null?void 0:F.call(e,t))??0)}),_=v>=0&&t[v]?n(t[v]):null,E=T.useRef(l);E.current=l,ft([_],()=>{var F,C,L;(C=(F=a.current)==null?void 0:F.querySelector('.picker-item[data-state~="cursor"]'))==null||C.scrollIntoView({block:"nearest"}),(L=E.current)==null||L.call(E,v>=0?t[v]??null:null)});const j=v<0?-1:Math.min(v,Math.max(0,t.length-1)),x=j>=0?t[j]??null:null,H=x?iR(d==null?void 0:d(x,r),r):null,B=F=>{const C=g==null?void 0:g(F,r);if(C==null)return i(F,r);k==null||k(C),b(0)};return{index:j,active:x,ghost:H,setIndex:b,pick:B,onKeyDown:F=>{if(F.key==="ArrowDown")F.preventDefault(),b(My(j,1,t.length));else if(F.key==="ArrowUp")F.preventDefault(),b(My(j,-1,t.length));else if((F.key==="ArrowLeft"||F.key==="ArrowRight")&&c&&x)F.preventDefault(),c(x,F.key==="ArrowLeft"?-1:1);else if(F.key==="Tab"&&(H!=null&&H.accept))F.preventDefault(),k==null||k(r+H.accept),b(0);else if(F.key==="Tab"&&p&&x)F.preventDefault(),B(x);else if(F.key==="Enter"&&x)F.preventDefault(),B(x);else if(F.key==="Enter"&&j<0&&h)F.preventDefault(),h(r);else return!1;return!0}}}function sR(e,t,n){var a,l;const r=e.length;if(r===0)return-1;let i=t<0?n===1?0:r-1:(t+n+r)%r;for(let c=0;c<r&&((a=e[i])!=null&&a.disabled);c++)i=(i+n+r)%r;return(l=e[i])!=null&&l.disabled?-1:i}const D0={sep:!0},Gi=e=>!("sep"in e);function Mu(e){const t=[];for(const n of e)(Gi(n)||t.length>0&&Gi(t[t.length-1]))&&t.push(n);for(;t.length>0&&!Gi(t[t.length-1]);)t.pop();return t}const Nn=e=>Mu(e.flatMap((t,n)=>n?[D0,...t]:t));let Ss=null,aR=0;const Np=new Set,Py=()=>{for(const e of Np)e()},Rr={get:()=>Ss,subscribe(e){return Np.add(e),()=>{Np.delete(e)}},open(e){const t=Mu(e.items);if(t.length===0)return Rr.close();Ss={...e,items:t,id:++aR},Py()},close(){Ss&&(Ss=null,Py())},toggle(e){Ss&&Ss.target===e.target?Rr.close():Rr.open(e)}};function z0(){return T.useSyncExternalStore(Rr.subscribe,Rr.get)}function F0(e){const t=e.nativeEvent;return t&&"pointerType"in t?t.pointerType==="":e.clientX===0&&e.clientY===0}function lR(e,t){return F0(e)?{anchor:(t.querySelector('[data-state~="cursor"]')??t).getBoundingClientRect()}:{at:{x:e.clientX,y:e.clientY}}}function cR(e){const t=e.anchor;return t?{rect:t,placement:{side:"bottom",align:e.align==="right"?"end":"start",offset:4,margin:4}}:{rect:O0(e.at??{x:0,y:0}),placement:{side:"bottom",align:"start",margin:4}}}function Wt(e){return T.useMemo(()=>({contextMenu(t,n){return{onContextMenu:r=>{const i=Mu(t(F0(r)?"keyboard":"pointer",r.target));if(i.length===0)return;r.preventDefault(),r.stopPropagation();const a=r.currentTarget;Rr.open({items:i,owner:e,key:n,target:a,...lR(r,a)})}}},dropdown(t,n="left"){return{"aria-haspopup":"menu",onClick:r=>{r.stopPropagation();const i=r.currentTarget;Rr.toggle({items:t(),owner:e,target:i,toggles:!0,anchor:i.getBoundingClientRect(),align:n})}}},openUnder(t,n,r){Rr.open({items:n(),owner:e,key:r,target:t,toggles:!0,anchor:t.getBoundingClientRect(),align:"left"})}}),[e])}function Ln(e){const t=Object.keys(e).filter(n=>e[n]);return t.length>0?t.join(" "):void 0}const uR=new Set(["Shift","Meta","Control","Alt","CapsLock","Fn"]);function B0(){const e=z0(),t=Sn();return T.useEffect(()=>{if(!e)return;const n=()=>{e.target.isConnected||Rr.close()},r=new MutationObserver(n);r.observe(document.body,{childList:!0,subtree:!0});const i=t.subscribe(n);return()=>{r.disconnect(),i()}},[e,t]),e?f.jsx(dR,{spec:e},e.id):null}function dR({spec:e}){const t=e.items,n=t.filter(Gi),[r,i]=T.useState(-1),a=T.useRef({idx:r,items:n});a.current={idx:r,items:n};const l=T.useRef(null),c=p=>{var h,v;{const b=()=>Rr.close(),{idx:_,items:E}=a.current;if(uR.has(p.key))return;if(p.key==="ArrowDown"||p.key==="ArrowUp"){p.preventDefault(),p.stopPropagation();const j=p.key==="ArrowDown"?1:-1;i(sR(E,_,j));return}if((p.key==="Enter"||p.key===" ")&&_>=0&&E[_]&&!E[_].disabled){p.preventDefault(),p.stopPropagation(),E[_].onClick(),b();return}if(p.key==="Escape"){p.stopPropagation(),b();return}if(p.key.length===1&&!p.metaKey&&!p.ctrlKey&&!p.altKey){p.preventDefault(),p.stopPropagation();const j=Array.from(((h=l.current)==null?void 0:h.querySelectorAll(".menu-label"))??[],H=>H.textContent??""),x=P0(j,_,p.key);x>=0&&!((v=E[x])!=null&&v.disabled)&&i(x);return}b()}};T.useEffect(()=>{const p=()=>Rr.close();return window.addEventListener("blur",p),window.addEventListener("resize",p),document.addEventListener("scroll",p,!0),()=>{window.removeEventListener("blur",p),window.removeEventListener("resize",p),document.removeEventListener("scroll",p,!0)}},[]);const{rect:d,placement:g}=cR(e),k=n.some(p=>p.checked);return f.jsx(Ji,{className:"menu",role:"menu",boxRef:l,anchor:()=>d,placement:g,track:!1,from:e.target,trigger:e.toggles?e.target:null,onDismiss:()=>Rr.close(),onKey:c,onContextMenu:p=>p.preventDefault(),children:t.map((p,h)=>{if(!Gi(p))return f.jsx("hr",{className:"menu-sep"},`sep-${h}`);const v=n.indexOf(p);return f.jsx(fR,{item:p,gutter:k,cursor:v===r,onEnter:()=>i(v)},p.id)})})}function fR({item:e,gutter:t,cursor:n,onEnter:r}){const i=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":i||void 0,className:Ke("row",e.danger&&"danger",a!==void 0&&"row-tall",i&&"disabled"),"data-state":Ln({cursor:n,checked:e.checked}),onMouseEnter:i?void 0:r,onClick:()=>{i||(e.onClick(),Rr.close())},children:[t&&f.jsx("span",{className:"menu-check",children:e.checked&&f.jsx(Ct,{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(Zr,{k:e.key,className:"menu-key row-dim"})]})}function Pu({items:e,current:t,onPick:n,fill:r,font:i,segmented:a,end:l,label:c,owner:d}){const g=Wt(d),k=T.useRef(null),p=h=>{var _,E;if(h.key!=="ArrowLeft"&&h.key!=="ArrowRight")return;h.preventDefault();const v=e.findIndex(j=>j.id===t),b=e[Ys(v,h.key==="ArrowRight"?1:-1,e.length)];b&&(n(b.id),(E=(_=k.current)==null?void 0:_.querySelectorAll('[role="tab"]')[e.indexOf(b)])==null||E.focus())};return f.jsxs("div",{className:Ke("tabs",r&&"tabs-fill",i==="mono"&&"tabs-mono",a&&"tabs-segmented"),children:[f.jsx("div",{className:"tabs-list",role:"tablist","aria-label":c,ref:k,onKeyDown:p,children:e.map(h=>{const v=h.id===t;return f.jsxs("div",{className:Ke("tab",v&&!!h.trail&&"tab-trailed",h.fit&&"tab-fit",h.far&&"tab-far"),"data-state":Ln({current:v}),...h.menu?g.contextMenu(h.menu):{},children:[f.jsxs("button",{type:"button",className:"tab-btn",role:"tab","aria-selected":v,tabIndex:v?0:-1,onClick:()=>n(h.id),...h.tip,...h.ariaLabel?{"aria-label":h.ariaLabel}:{},children:[h.lead,h.label]}),v&&h.trail&&f.jsx("span",{className:"tab-trail",children:h.trail})]},h.id)})}),l&&f.jsx("span",{className:"tabs-end",children:l})]})}function qo({anchor:e="top",wide:t,children:n}){return f.jsx("div",{className:Ke("view",e==="line"&&"view-anchored",t&&"view-wide"),children:n})}function es(){const e=location.hash.match(/token=([a-f0-9]+)/);if(e!=null&&e[1]){try{localStorage.setItem(dt.token,e[1])}catch{}return e[1]}try{return localStorage.getItem(dt.token)??sessionStorage.getItem(dt.token)??""}catch{return""}}function U0(){return es()!==""}function Ly(e,t){return`/attachments/${e}/${t}?token=${es()}`}function H0(e,t,n){const r=t.split("/").map(encodeURIComponent).join("/");return`/files/${e}/${r}?token=${es()}&v=${encodeURIComponent(n??"")}`}async function pR(e=!1){try{const t=await fetch(`/restart?token=${es()}${e?`&${CA}`:""}`,{method:"POST"});return t.ok?null:await t.text()||"Toyon did not restart"}catch{return null}}async function Z0(){try{const e=await fetch(`/restart?token=${es()}`,{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 hR(){try{const e=await fetch("/pair",{method:"POST",headers:{authorization:`Bearer ${es()}`}});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 Tp(){try{const e=await fetch("/health",{signal:AbortSignal.timeout(2e3)});return e.ok?(await e.json()).pid??null:null}catch{return null}}const mR=1e3,gR=3e4,kR=1500,Dy=50;class yR{constructor(t,n){mt(this,"ws",null);mt(this,"queue",[]);mt(this,"closed",!1);mt(this,"attempt",0);mt(this,"timer",null);mt(this,"downAt",null);mt(this,"sayTimer",null);mt(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===jE)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+kR-Date.now())))})}connect(){if(this.closed)return;const n=`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws?token=${es()}`,r=new WebSocket(n);this.ws=r;let i=!1;r.onmessage=a=>{if(!i){i=!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(gR,mR*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(i=>i.key!==r)),this.queue.push({key:r,raw:n}),this.queue.length>Dy&&this.queue.splice(0,this.queue.length-Dy)}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 zy={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"},vR="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 W0(e){return!e.connected&&(!e.heard||e.connectFailure)?e.hasToken?zy[e.connectFailure??"probing"]??zy.probing:vR:e.title===null?e.heard?`nothing open yet.
97
+ press ${e.projectChord} to open a project, or type a name there to start a new one`:"":null}function wR(e){const t=W0(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 Rt={post:(e,t)=>{},broadcast:e=>{}};function il(e,t,n,r){const i=t===r;Rt.post(e,i?{type:"pick-cancel"}:{type:"pick-start",verb:r}),n({a:"set-picking",v:i?!1:r})}function Cp(e,t,n){const r=location.hostname;return n!==null&&r===n.host?`${CE(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 Fy(e){return e.ranges.map(([t,n])=>[t+e.offset,n+e.offset])}function By(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 Tc(e,t){return!Number.isFinite(e)||e<=0?t:Math.min(Math.max(e,170),Math.floor(window.innerWidth*.5))}function Lu(e){return e.agent==="working"||e.agent==="waiting"}function Bs(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(i=>i.status==="crashed"||i.status==="unreachable")?"crashed":e.procs.some(i=>i.status==="running")?"running":e.procs.some(i=>i.status==="starting")?"starting":e.procs.some(i=>i.status==="asleep")?"asleep":"idle"}const bR={waiting:"Waiting for you",working:"Agent working",failed:"Agent failed",landed:"Landed",crashed:"Crashed",running:"Running",starting:"Starting",asleep:"Asleep",idle:"Idle"};function wh(e,t=!1){const n=Bs(e);return n==="idle"&&t?"Not set up":bR[n]}function xR(e,t){return t&&Bs(e)!=="waiting"?t:null}const _R={land:"Landing",commit:"Committing","sync-main":"Syncing with main","pull-main":"Pulling"};function K0(e){return _R[e]}function G0(e){const t=e.filter(i=>i.status==="crashed"||i.status==="unreachable"),n=t[0];if(!n)return null;const r=t.map(i=>i.status==="unreachable"?`${i.name} never answered on :${i.port}`:`${i.name} crashed on :${i.port}`).join(", ");return{dead:t,tip:`${r} · click to open its tab`,stream:n.name}}function ER(e){const t=e.lastIndexOf("/");return t<0?{name:e,dir:""}:{name:e.slice(t+1),dir:e.slice(0,t)}}const V0=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}).compare;function Va(e){const t=[];for(let n=e.indexOf("/");n!==-1;n=e.indexOf("/",n+1))t.push(e.slice(0,n));return t}function SR(e){const t=new Set;for(const n of e)for(const r of Va(n))t.add(r);return[...t].sort(V0)}function bh(e){return e.includes("A")||e==="??"?"added":e.includes("D")?"deleted":""}function xh(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 NR=/Firefox\//.test(navigator.userAgent);function Du(){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 TR=/Chrome\//.test(navigator.userAgent)&&Du(),ct=e=>_E(e,{firefox:NR,pwa:TR});function _h(e){return e.component?`<${e.component} />`:`<${e.tag}>`}function ou(e,t){return e.worktree&&Yn(e.worktree)&&t?t.defaultBranch:e.name}function yo(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 i=r/24;return i<7?`${Math.floor(i)}d`:i<365?`${Math.floor(i/7)}w`:`${Math.floor(i/365)}y`}function CR(e,t,n,r){var l;if(!t)return null;const i=e.filter(Mn).filter(c=>c.repoId===t&&(c.worktree.agent??r)===n);return((l=i.find(c=>Yn(c.worktree))??i[0])==null?void 0:l.id)??null}const q0=e=>({id:"open-out",label:Du()?"open in the browser":"open in a new tab",onClick:()=>window.open(e,"_blank")}),Zt=e=>{var t;return void((t=navigator.clipboard)==null?void 0:t.writeText(e).catch(()=>{}))};function Y0(e,t){const n=navigator.clipboard;if(n){if(typeof ClipboardItem>"u"||!n.write){e==="text/plain"&&t.then(r=>r.text()).then(Zt,()=>{});return}n.write([new ClipboardItem({[e]:t})]).catch(()=>{})}}const jR=e=>Y0("text/plain",fetch(e).then(t=>t.blob())),AR=e=>Y0("image/png",IR(e));async function IR(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((i,a)=>r.toBlob(l=>l?i(l):a(new Error("could not encode image")),"image/png"))}finally{n.close()}}function Q0(e){return[{id:"copy-sha",label:`copy ${e.short}`,onClick:()=>Zt(e.sha)},{id:"copy-subject",label:"copy subject",onClick:()=>Zt(e.subject)}]}const RR=[{label:"Zed",scheme:"zed"},{label:"VS Code",scheme:"vscode"},{label:"Cursor",scheme:"cursor"}];function Eh(e){return e==="127.0.0.1"||e==="localhost"||e==="[::1]"||e.endsWith(".localhost")}function Qs(e,t,n=location.hostname){if(!Eh(n))return[];const r=RR.map(i=>({id:`open:${i.scheme}`,label:`open in ${i.label}`,onClick:()=>{window.location.href=`${i.scheme}://file${e}`}}));return r.push(...zu(t,n)),r}function zu(e,t=location.hostname){return!e||!Eh(t)?[]:[{id:"reveal",label:"reveal in Finder",onClick:e}]}function OR(e,t){const n=[];for(const r of t)r.xy.includes("D")?n.push(`-${r.path}`):/[?ARC]/.test(r.xy)&&n.push(`+${r.path}`);return`${e??""}
98
+ ${n.sort().join(`
99
+ `)}`}function Sh(e,t,{sock:n,dispatch:r}){var l,c;if(!n)return;const i=t.local[e]??Au,a=OR((l=i.git)==null?void 0:l.head,((c=i.git)==null?void 0:c.files)??[]);i.filesFor!==a&&(r({a:"files-asked",worktreeId:e,key:a}),n.send({t:"list-files",worktreeId:e}))}const $R=["diff","file","preview"],X0=(e,t)=>$R.filter(n=>!(n==="preview"&&!Jw(e))&&!(n==="diff"&&t));let MR=0;const iu=()=>++MR;function ar({dispatch:e},{focus:t=!0,...n}){e({a:"open-file",v:{...n,focus:t,seq:iu()}})}function PR({dispatch:e},t){e({a:"tree-reveal",...t})}function vi(e,t,{discard:n=!1,ref:r,showing:i,added:a=!1,kept:l=!1},c){const{sock:d,dispatch:g}=c,k=X0(t,a).filter(_=>_!==i).map(_=>({id:`view:${_}`,label:`view ${_}`,onClick:()=>i?g({a:"editor-view",v:_}):ar(c,{worktreeId:e.id,path:t,view:_,ref:r})})),p=`${e.dir}/${t}`,h=l?[]:Qs(p,()=>d==null?void 0:d.send({t:"reveal",worktreeId:e.id,path:t}));return Nn([k,[{id:"copy-path",label:"copy path",onClick:()=>Zt(p)}],h,n?[{id:"discard",label:"discard changes…",danger:!0,onClick:()=>{window.confirm(`Discard uncommitted changes to ${t}?`)&&(d==null||d.send({t:"discard-file",worktreeId:e.id,path:t}))}}]:[]])}function Fu(e){return e!=null&&e.config.profiles?Object.keys(e.config.profiles):[]}function J0(e,t){const n=Fu(t);if(n.length!==0)return e.profile&&n.includes(e.profile)?e.profile:t==null?void 0:t.config.defaultProfile}const LR=e=>Kc(Wi((e==null?void 0:e.config)??{}),e==null?void 0:e.defaultBranch).toLowerCase();function wi(e,t,n){t({a:"shipping",id:n.worktreeId,op:n.t}),e==null||e.send(n)}const eb=e=>e.dirty===void 0||e.ahead===void 0||e.dirty>0||e.ahead>0;function Vi(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 tb(e,t,n){t({a:"hold-unread",id:n}),e==null||e.send({t:"mark-unread",worktreeId:n})}function nb(e,t){return{rename(n){if(!tw(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 i=r.of-1;window.confirm(`Keep "${n.worktree.title}" and archive ${i} 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})},archive(n){if(!ew(n.worktree))return;if(!eb(n))return Vi(e,t,[n.worktree.id]);window.confirm(`Archive worktree "${n.worktree.title}"?
100
+
101
+ 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.`)&&Vi(e,t,[n.worktree.id])}}}function rb(e,t,n,{sock:r,dispatch:i},a){const l=e.worktree.id,c=nb(r,i),d=[],g=[],k=[],p=[],h=[],v=[],b=[];Lu(e)&&d.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)&&g.push({id:"changes",label:`view changes${(e.dirty??0)>0?` (${e.dirty})`:""}`,onClick:()=>{i({a:"activate",id:l}),n.layout.changes||i({a:"toggle-changes"})}}),g.push({id:"terminal",label:"open terminal",onClick:()=>{i({a:"activate",id:l}),i({a:"focus-terminal"})}}),g.push(...zu(()=>r==null?void 0:r.send({t:"reveal",worktreeId:l}),a.hostname)),k.push({id:"copy-path",label:"copy path",onClick:()=>Zt(e.path)}),k.push({id:"copy-branch",label:"copy branch name",onClick:()=>Zt(e.worktree.branch)});const{transcript:E,sessionId:j}=e;E&&!Yn(e.worktree)&&k.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>Zt(E)}),j&&k.push({id:"copy-session",label:"copy session id",onClick:()=>Zt(j)});const x=J0(e.worktree,t);for(const B of Hs(e.worktree)?[]:Fu(t))p.push({id:`profile:${B}`,label:`run with ${B}`,checked:B===x,onClick:()=>c.setProfile(e,B)});if(tw(e.worktree)&&h.push({id:"rename",label:"rename…",onClick:()=>c.rename(e)}),e.worktree.variant&&h.push({id:"keep",label:"keep this variant…",onClick:()=>c.pickVariant(e)}),a.graft&&Pc(e.worktree)){const B=a.graft;h.push({id:"graft",label:"graft with…",onClick:()=>B(l)})}h.push({id:"unread",label:"mark as unread",disabled:e.unseen?"already unread":void 0,onClick:()=>tb(r,i,l)});const H=_?void 0:"waiting on the one in progress";return qp(e)&&(e.behind??0)>0&&v.push({id:"sync",label:`sync from main (${e.behind} behind)`,disabled:H,onClick:()=>wi(r,i,{t:"sync-main",worktreeId:l})}),Cs(e.worktree)&&v.push({id:"land",label:"land",detail:LR(t),disabled:H,onClick:()=>wi(r,i,{t:"land",worktreeId:l})}),ew(e.worktree)&&b.push({id:"archive",label:eb(e)?"archive…":"archive",danger:!0,onClick:()=>c.archive(e)}),Nn([d,g,k,p,h,v,b])}function DR(e,t,{sock:n,dispatch:r},i){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 qp(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(...zu(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id}),i)),Nn([l,a,[{id:"copy-path",label:"copy path",onClick:()=>Zt(e.path)}]])}const zR={sm:"",md:"field-md",lg:"field-lg"};function ob({size:e="sm",font:t,bare:n,rule:r,className:i}){const a=t??(e==="lg"?"ui":"mono");return Ke("field",zR[e],a==="ui"&&"field-ui",a==="lead"&&"field-lead",n&&"field-bare",r&&"field-rule",i)}const Go=T.forwardRef(function({size:t,font:n,bare:r,rule:i,className:a,...l},c){return f.jsx("input",{ref:c,className:ob({size:t,font:n,bare:r,rule:i,className:a}),...l})}),wl=T.forwardRef(function({size:t,font:n,bare:r,rule:i,className:a,...l},c){return f.jsx("textarea",{ref:c,className:ob({size:t,font:n,bare:r,rule:i,className:a}),...l})});function FR(e,t){const n=t??0;return n===0?null:`${n} behind ${e}`}function BR(e,t){const n=t.behind??0;if(n===0)return null;if(t.stale==="diverged")return`${e} has diverged from origin`;if(t.stale==="dirty"&&t.dirty>0){const r=`~${t.dirty} uncommitted`;return`${n} behind origin; ${r} on ${e} ${t.dirty===1?"keeps":"keep"} it where it is`}return`${n} behind origin`}function UR(e){return e.stale!=="diverged"}const _i=e=>/[.!?]$/.test(e)?e:`${e}.`;function Fi(e){const t=`PR #${e.number}`;if(e.state==="merged")return`${t} merged; main here is behind origin.`;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 ib(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 sb=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function Zf(e){var t,n;if(e.check==="pending")return"Checking the work…";if(e.check==="fail"){const r=(n=(t=e.checkTail)==null?void 0:t.split(`
102
+ `).find(i=>i.trim()))==null?void 0:n.trim();return`Check failed${r?`: ${_i(r)}`:"."}`}return null}function Uy(e,t){const n=ab(e,t);return n?_i(sb(n)):""}function ab(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 HR=e=>/^[A-Z][a-z]+(\s|$)/.test(e)?`${e.charAt(0).toLowerCase()}${e.slice(1)}`:e;function ZR(e,t){const n=t??0;return n>0?`${n} behind ${e}; land takes it in first.`:""}function WR(e){return e>0?_i(sb(`${e} ${e===1?"file":"files"} changed`)):""}function KR(e,t){if(e.stale)return"Changed since this was written.";if(e.why)return`Not ready: ${_i(HR(e.why))}`;const n=ab(e,t);return n?`Ready: ${n}.`:"Ready."}function Cc(e){return _i(e)}function GR(e,t,n){const r=n==="now"?"just now":`${n} ago`;switch(e){case"asking":return`Waiting on you${n==="now"?"":` for ${n}`}${t.ask?`: ${_i(t.ask)}`:"."}`;case"failed":return t.auth?`Stopped ${r}: not logged in.`:t.error?`Failed ${r}: ${_i(t.error)}`:`Failed ${r}.`;case"stopped":return t.planBack?`Sent the plan back ${r}. Say what to change.`:`Stopped ${r}.`;case"done":return t.cut?`Ended early ${r} (${t.cut}).`:`Finished ${r}.`}}function Nh(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?_i(t):GR(e.end,e.facts,yo(e.at))}function VR({active:e,ahead:t,behind:n,unpushed:r,dirty:i}){var de,Q;const a=Ge(),l=Ve(),c=Wt("changes"),d=Mn(e)?e.worktree:null,g=e.id,k=z(ce=>ce.shipping[g]),[p,h]=T.useState("");ft([g],()=>h(""));const v=T.useRef(null),b=(de=d==null?void 0:d.landing)!=null&&de.subject?d.landing.body?`${d.landing.subject}
103
+
104
+ ${d.landing.body}`:d.landing.subject:null,_=()=>{p===""&&b&&h(b);const ce=v.current;ce&&(ce.focus(),requestAnimationFrame(()=>ce.setSelectionRange(ce.value.length,ce.value.length)))},E=z(ce=>ce.editCommit);ft([E],()=>{E&&_()});const j=p.trim()||void 0,x=()=>{k||!j&&!b||(wi(a,l,{t:"commit",worktreeId:g,message:j??b??""}),h(""))},H=()=>{k||wi(a,l,{t:"land",worktreeId:g,...j?{message:j}:{}})},B=((Q=d==null?void 0:d.landing)==null?void 0:Q.check)==="fail",re=d==null?void 0:d.pr,F=(re==null?void 0:re.state)==="open",C=F&&(i||r>0),L=!!d&&Cs(d)&&(i||t>0)&&!B&&!F,I=!!d&&C&&!B,Z=z(ce=>ce.repos.find(R=>R.id===e.repoId)??null),V=Kc(Wi((Z==null?void 0:Z.config)??{}),Z==null?void 0:Z.defaultBranch),K=(Z==null?void 0:Z.defaultBranch)??"main",le=qp(e)?FR(K,n):null;return f.jsxs("div",{className:"composer commit-box",children:[d&&i&&f.jsx("div",{className:"composer-field",children:f.jsx(wl,{size:"lg",bare:!0,ref:v,value:p,onChange:ce=>h(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&(ce.metaKey||ce.ctrlKey)?(ce.preventDefault(),x()):ce.key==="Tab"&&!ce.shiftKey&&p===""&&b&&(ce.preventDefault(),_())},placeholder:b??"commit message…"})}),f.jsxs("div",{className:"hint composer-knobs",children:[f.jsxs("span",{className:"commit-where",children:[f.jsx(Ct,{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 main`,children:[t," ahead"]}),(d==null?void 0:d.landed)&&f.jsxs("span",{className:"badge-landed","data-tip":"Merged into main",children:[f.jsx(Ct,{name:"check",className:"icon-inline"})," landed"]})]}),f.jsxs("span",{className:"commit-acts",children:[d&&i&&f.jsx($e,{busy:k==="commit",disabled:!j&&!b||!!k,onClick:x,...Et(b&&!j?"Commit with the suggested message":"git add -A && git commit","⌘⏎"),children:"commit"}),d&&L&&f.jsx($e,{tone:"primary",busy:k==="land",disabled:!!k,"data-tip":V,onClick:H,children:"land"}),I&&re&&f.jsx($e,{tone:"primary",busy:k==="land",disabled:!!k,"data-tip":`Commit, take ${K} in and push the branch; PR #${re.number} takes the new commits`,onClick:H,children:"update"}),F&&!C&&ib(re)&&f.jsx($e,{tone:"primary",busy:k==="land",disabled:!!k,"data-tip":"Merge the PR now, by the method the repo allows",onClick:H,children:"merge"}),re&&f.jsxs($e,{"data-tip":`Open PR #${re.number} on GitHub`,onClick:()=>window.open(re.url,"_blank"),...c.contextMenu(()=>[{id:"open-pr",label:"open on GitHub",onClick:()=>window.open(re.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>Zt(re.url)}]),children:["view ",f.jsx(Ct,{name:"external",className:"icon-inline"})]})]})]}),le&&f.jsx("div",{className:"composer-notes",children:f.jsxs("div",{className:"hint composer-note",children:[f.jsx("span",{children:le}),f.jsx($e,{variant:"outline",busy:k==="sync-main",disabled:!!k||i,"data-tip":i?"commit or discard the changes here first":`Merge ${K} into this worktree`,onClick:()=>wi(a,l,{t:"sync-main",worktreeId:g}),children:"sync"})]})})]})}const qR=T.memo(function({c:t,id:n,selected:r,onToggle:i}){const a=Wt("changes");return f.jsxs("button",{className:"row row-sm log-row row-edge",id:n,"data-state":Ln({current:r,cursor:r}),role:"option","aria-selected":r,tabIndex:-1,onClick:()=>i(t.sha),...a.contextMenu(()=>Q0(t)),"data-tip":`${t.subject}
105
+ ${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:yo(t.at)})]})});function YR(e,t,n){const{worktreeId:r,dir:i,path:a,folder:l}=e,c=gh(t.getState(),r)?void 0:"take this worktree over to talk to an agent here",d=_0(a,l),g=[...l?[]:[{id:"open",label:"open",onClick:()=>ar(n,{worktreeId:r,path:a,view:kl(a)})}],{id:"add-to-chat",label:"add to chat",disabled:c,onClick:()=>S0(t,r,a,l)}],k=[{id:"ask-rename",label:"ask the agent to rename…",disabled:c,onClick:()=>by(t,r,`Rename ${d} to `)},{id:"ask-delete",label:"ask the agent to delete…",disabled:c,onClick:()=>by(t,r,`Delete ${d} and update whatever still uses it`)}],p=[...zu(()=>{var h;return(h=n.sock)==null?void 0:h.send({t:"reveal",worktreeId:r,path:a})}),{id:"copy-path",label:"copy path",onClick:()=>Zt(`${i}/${a}`)},{id:"copy-relative-path",label:"copy relative path",onClick:()=>Zt(a)}];return Nn([g,p,k])}function QR(e,t){return Qs(e.dir,()=>{var n;return(n=t.sock)==null?void 0:n.send({t:"reveal",worktreeId:e.worktreeId})})}function XR(e,t=[],n=[]){const r={path:"",name:"",kind:"folder",children:[],ignored:!1},i=new Map([["",r]]),a=d=>{const g=i.get(d);if(g)return g;const k=d.lastIndexOf("/"),p={path:d,name:d.slice(k+1),kind:"folder",children:[],ignored:!1};return a(k===-1?"":d.slice(0,k)).children.push(p),i.set(d,p),p},l=(d,g,k=!1)=>{const p=d.lastIndexOf("/");a(p===-1?"":d.slice(0,p)).children.push({path:d,name:d.slice(p+1),kind:g,children:[],ignored:k})};for(const d of e)l(d,"file");for(const d of t)l(d,"submodule");for(const d of n)d.endsWith("/")?l(d.slice(0,-1),"ignored",!0):l(d,"file",!0);const c=d=>{const g=k=>k.kind==="file"?1:0;d.children.sort((k,p)=>g(k)-g(p)||V0(k.name,p.name));for(const k of d.children)k.kind==="folder"&&c(k)};return c(r),r.children}function JR(e,t){const n=[],r=(i,a)=>{for(const l of i){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}function eO(e){const t=new Map,n=new Set;for(const r of e){const i=r.path.endsWith("/")?r.path.slice(0,-1):r.path;i===r.path?t.set(i,r):n.add(i);for(const a of Va(i))n.add(a)}return{files:t,folders:n}}const jc=[],tO=[],Hy=new Set,Zy=e=>`tree-row-${e}`;function nO({worktreeId:e,dir:t,openPath:n,openRef:r,rootRef:i}){const a=Sn(),l=Ge(),c=Ve(),d=It(e,"files"),g=It(e,"submodules"),k=It(e,"ignored"),p=It(e,"git"),h=(p==null?void 0:p.files)??tO;ft([e,p,l],()=>Sh(e,a.getState(),{sock:l,dispatch:c}));const v=z(D=>D.treeOpen[e]??jc),b=T.useMemo(()=>new Set(v),[v]),[_,E]=T.useState(Hy);ft([e,n,r],()=>E(n&&!r?new Set(Va(n).filter(D=>!b.has(D))):Hy));const j=T.useCallback(D=>b.has(D)||_.has(D),[b,_]),x=T.useCallback(D=>{const q=b.has(D)||_.has(D);if(q&&_.has(D)){const Te=new Set(_);Te.delete(D),E(Te)}c({a:"tree-folder",worktreeId:e,path:D,open:!q})},[b,_,e,c]),H=T.useMemo(()=>XR(d??jc,g??jc,k??jc),[d,g,k]),B=T.useMemo(()=>JR(H,j),[H,j]),re=T.useMemo(()=>eO(h),[h]),F=z(D=>D.treeReveal),C=F&&F.worktreeId===e?F:null,[L,I]=T.useState(()=>(C==null?void 0:C.path)??null),[Z,V]=T.useState({worktreeId:e,linked:C});(Z.worktreeId!==e||Z.linked!==C)&&(V({worktreeId:e,linked:C}),I((C==null?void 0:C.path)??null));const[K,le]=T.useState(!1),de=T.useMemo(()=>{if(L===null)return-1;const D=B.findIndex(q=>q.path===L);if(D>=0)return D;for(const q of Va(L).reverse()){const Te=B.findIndex(Ne=>Ne.path===q);if(Te>=0)return Te}return-1},[B,L]);ft([de,K],()=>{var D,q;K&&((q=(D=i.current)==null?void 0:D.querySelector('[data-state~="cursor"]'))==null||q.scrollIntoView({block:"nearest"}))});const Q=T.useCallback((D,q)=>ar({dispatch:c},{worktreeId:e,path:D,view:kl(D),focus:q}),[e,l,c]),ce=T.useCallback(D=>{I(D.path),D.kind==="folder"?x(D.path):D.kind==="file"&&Q(D.path,!1)},[x,Q]),R=D=>{var Ne,je;if(D.metaKey||D.ctrlKey||D.altKey)return;const q=B[de],Te=Re=>{const Ze=B[Re];Ze&&(I(Ze.path),Ze.kind==="file"&&Q(Ze.path,!1))};switch(D.key){case"ArrowDown":case"ArrowUp":D.preventDefault(),Te(de<0?0:Ys(de,D.key==="ArrowDown"?1:-1,B.length));return;case" ":D.preventDefault(),(q==null?void 0:q.kind)==="file"?Q(q.path,!1):(q==null?void 0:q.kind)==="folder"&&x(q.path);return;case"Enter":D.preventDefault(),(q==null?void 0:q.kind)==="file"?Q(q.path,!0):(q==null?void 0:q.kind)==="folder"&&x(q.path);return;case"ArrowRight":if(D.preventDefault(),(q==null?void 0:q.kind)!=="folder")return;q.open?(((Ne=B[de+1])==null?void 0:Ne.depth)??-1)>q.depth&&Te(de+1):x(q.path);return;case"ArrowLeft":{if(D.preventDefault(),!q)return;if(q.kind==="folder"&&q.open){x(q.path);return}const Re=Va(q.path).at(-1);Re!==void 0&&I(Re);return}case"Escape":D.stopPropagation(),n!==null?c({a:"close-editor"}):(je=document.activeElement)==null||je.blur();return}if(D.key.length===1){const Re=P0(B.map(Ze=>Ze.name),de,D.key);Re>=0&&(D.preventDefault(),Te(Re))}},M=Wt("tree"),G=T.useCallback(D=>YR({worktreeId:e,dir:t,path:D.path,folder:D.kind!=="file"},a,{sock:l,dispatch:c}),[e,t,a,l,c]),ne=T.useCallback((D,q)=>{D.kind==="file"&&Rt.post(e,q?{type:"highlight-file",path:D.path,ranges:null}:{type:"highlight-clear"})},[e]),O=T.useCallback((D,q)=>{q.dataTransfer.setData(C0,D.path),q.dataTransfer.setData("text/plain",D.path),q.dataTransfer.effectAllowed="copy",R2({worktreeId:e,path:D.path,folder:D.kind!=="file"})},[e]),ee=T.useCallback(()=>j0(a),[a]);return f.jsx("div",{className:"tree",role:"tree","aria-label":"files","aria-activedescendant":K&&de>=0?Zy(de):void 0,tabIndex:0,ref:i,onKeyDown:R,onFocus:()=>{var D;le(!0),L===null&&I(n&&B.some(q=>q.path===n)?n:((D=B[0])==null?void 0:D.path)??null)},onBlur:D=>!D.currentTarget.contains(D.relatedTarget)&&le(!1),onMouseDown:D=>{if(D.button!==0)return;const q=D.target.closest("[data-path]");(q==null?void 0:q.dataset.path)!==void 0&&I(q.dataset.path)},...M.contextMenu(D=>{const q=B[de];return D==="keyboard"&&q?G(q):QR({worktreeId:e,dir:t},{sock:l})}),children:d===void 0?f.jsx("div",{className:"empty",children:"listing files…"}):B.length===0?f.jsx("div",{className:"empty",children:"no files"}):B.map((D,q)=>f.jsx(rO,{row:D,id:Zy(q),status:re.files.get(D.path),changedInside:D.kind!=="file"&&re.folders.has(D.path),current:K?q===de:!r&&D.path===n,cursor:K&&q===de,onPress:ce,menu:G,onHover:ne,onDragStart:O,onDragEnd:ee},D.path))})}const rO=T.memo(function({row:t,id:n,status:r,changedInside:i,current:a,cursor:l,onPress:c,menu:d,onHover:g,onDragStart:k,onDragEnd:p}){const h=Wt("tree"),v=t.kind==="submodule",b=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:"row row-sm tree-row row-edge","data-state":Ln({current:a,cursor:l}),"data-kind":t.kind,"data-path":t.path,style:{"--tree-depth":t.depth},draggable:!v,onDragStart:_=>k(t,_),onDragEnd:p,onClick:()=>c(t),onMouseEnter:()=>g(t,!0),onMouseLeave:()=>g(t,!1),...h.contextMenu(()=>d(t)),...b?Et(b):{},children:[f.jsx("span",{className:"tree-caret row-dim",children:t.kind==="folder"&&f.jsx(Ct,{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 ${bh(r.xy)}`,children:xh(r.xy)}):i&&f.jsx("span",{className:"dot tree-changed"})]})});function lb({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 Wf=T.memo(function({f:t,id:n,active:r,selected:i,onOpen:a,menu:l,onHover:c}){const d=Wt("changes"),{name:g,dir:k}=ER(t.path);return f.jsxs("button",{className:"row row-sm git-file row-edge",id:n,"data-state":Ln({current:r,cursor:i}),role:"option","aria-selected":i,tabIndex:-1,onClick:()=>a(t.path),...d.contextMenu(()=>l(t.path)),onMouseEnter:()=>c(t.path,!0),onMouseLeave:()=>c(t.path,!1),children:[f.jsx("span",{className:`xy ${bh(t.xy)}`,children:xh(t.xy)}),f.jsxs("span",{className:"path","data-tip":k?t.path:void 0,children:[f.jsx("span",{className:"name",children:g}),k&&f.jsx("span",{className:"dir row-dim",children:k})]}),f.jsx(lb,{f:t})]})}),Wy=[];function oO(e){const t=yo(e);return t==="now"?"landed just now":`landed ${t} ago`}function cb({width:e,placement:t="dock"}){const n=t==="screen",r=Ge(),i=Ve(),a=Vs(),l=Qi(),c=(l==null?void 0:l.id)??a,d=Vo(),g=z(ie=>ie.layout.changes),k=yl(),p=z(ie=>ie.focusChanges),h=It(c,"git"),v=z(ie=>ie.editor&&ie.editor.worktreeId===c?ie.editor.path:null),b=z(ie=>ie.editor&&ie.editor.worktreeId===c?ie.editor.ref??null:null),_=(h==null?void 0:h.files)??Wy,E=(h==null?void 0:h.committed)??Wy,j=_.length===0,x=z(Fs),H=T.useCallback(ie=>i({a:"changes-tab",v:ie}),[i]),B=T.useRef(x);B.current=x;const re=T.useRef(null),F=fh(),C=z(ie=>{var he;return((he=Gs(ie,F==null?void 0:F.repoId))==null?void 0:he.defaultBranch)??"main"}),L=It(c,"commits"),I=It(c,"commitFiles"),[Z,V]=T.useState(null),K=T.useRef(null);K.current=Z;const le=T.useRef(null),de=It(c,"changedRanges"),Q=T.useCallback((ie,he)=>{if(!c||l)return;if(!he){le.current=null,Rt.post(c,{type:"highlight-clear"});return}le.current=ie;const lt=de[ie];lt?Rt.post(c,{type:"highlight-file",path:ie,ranges:Fy(lt)}):r==null||r.send({t:"changed-ranges",worktreeId:c,path:ie})},[c,l,de,r]);T.useEffect(()=>{const ie=le.current;if(!ie||!c)return;const he=de[ie];he&&Rt.post(c,{type:"highlight-file",path:ie,ranges:Fy(he)})},[de,c]);const ce=T.useCallback((ie,he=!1)=>c&&ar({dispatch:i},{worktreeId:c,path:ie,focus:he}),[c,r,i]),R=T.useMemo(()=>[..._,...E],[_,E]),M=T.useMemo(()=>{const ie=[];for(const he of L??[])if(ie.push({commit:he}),he.sha===Z)for(const lt of I[he.sha]??[])ie.push({commit:he,file:lt});return ie},[L,Z,I]),G=T.useMemo(()=>M.filter(ie=>!ie.file&&ie.commit.ahead).length,[M]),ne=T.useMemo(()=>M.findIndex(ie=>!ie.file&&!ie.commit.ahead),[M]),O=T.useMemo(()=>{const ie=new Map;if(!l)return ie;const he=new Map;for(const At of M){const bt=At.commit.landedAt??0;At.file||he.set(bt,(he.get(bt)??0)+1)}let lt;return M.forEach((At,bt)=>{const Qt=At.commit.landedAt??0;Qt!==lt&&(lt=Qt,ie.set(bt,`${Qt?oO(Qt):"not landed"} · ${he.get(Qt)??0}`))}),ie},[l,M]),ee=T.useRef(null),[D,q]=T.useState(0),[Te,Ne]=T.useState(!1),je=(ie,he)=>Te?D===ie:he,Re=ie=>`changes-row-${ie}`;ft([c,x],()=>q(0));const Ze=h==null?void 0:h.head,st=T.useRef("");T.useEffect(()=>{if(x!=="history"||!c)return;const ie=`${c}:${Ze??""}`;st.current!==ie&&(st.current=ie,r==null||r.send({t:"git-log",worktreeId:c}))},[x,c,Ze,r]);const Ee=T.useCallback(ie=>{V(he=>he===ie?null:ie),c&&!I[ie]&&(r==null||r.send({t:"git-commit",worktreeId:c,sha:ie}))},[c,I,r]);ft([D,Te],()=>{var ie,he;Te&&((he=(ie=ee.current)==null?void 0:ie.querySelector('[data-state~="cursor"]'))==null||he.scrollIntoView({block:"nearest"}))});const Tt=T.useRef(-1);Tt.current=R.findIndex(ie=>ie.path===v),T.useEffect(()=>{if(!p)return;const ie=B.current==="files";B.current==="changes"&&Tt.current>=0&&q(Tt.current);const he=requestAnimationFrame(()=>{var lt;return(lt=(ie?re:ee).current)==null?void 0:lt.focus()});return()=>cancelAnimationFrame(he)},[p]);const zt=T.useCallback((ie,he=!1)=>{const lt=R[ie];lt&&(q(ie),ce(lt.path,he),Q(lt.path,!0))},[R,ce,Q]),Xe=T.useCallback((ie,he=!1)=>{const lt=K.current;c&&lt&&ar({dispatch:i},{worktreeId:c,path:ie,ref:lt,focus:he})},[c,r,i]),pt=T.useCallback(ie=>{const he=M[ie];he&&(q(ie),he.file&&Xe(he.file.path))},[M,Xe]),ht=T.useCallback(ie=>{const he=M[ie];he&&(q(ie),he.file?Xe(he.file.path,!0):Ee(he.commit.sha))},[M,Xe,Ee]),wn=ie=>{var lt,At;const he=x==="history";if(ie.key==="ArrowDown"||ie.key==="ArrowUp"){ie.preventDefault();const bt=Ys(D,ie.key==="ArrowDown"?1:-1,he?M.length:R.length);he?pt(bt):zt(bt)}else if(ie.key==="Enter")ie.preventDefault(),he?ht(D):zt(D,!0);else if(ie.key==="ArrowRight"||ie.key==="ArrowLeft"){ie.preventDefault();const bt=M[D];if(!he||!bt)return;if(ie.key==="ArrowRight"){if(bt.file)return;bt.commit.sha!==Z?Ee(bt.commit.sha):(lt=M[D+1])!=null&&lt.file&&pt(D+1)}else bt.commit.sha===Z&&(bt.file&&q(M.findIndex(Qt=>!Qt.file&&Qt.commit.sha===bt.commit.sha)),Ee(bt.commit.sha))}else ie.key==="Escape"&&(ie.stopPropagation(),v!==null?i({a:"close-editor"}):(At=document.activeElement)==null||At.blur())},jt=l?l.id:d==null?void 0:d.worktree.id,Ft=l?l.path:d?d.worktree.path:"",te=l!==null,pe=T.useCallback(ie=>jt?vi({id:jt,dir:Ft},ie,{discard:!te,kept:te},{sock:r,dispatch:i}):[],[jt,Ft,te,r,i]),rt=T.useCallback(ie=>jt?vi({id:jt,dir:Ft},ie,{kept:te},{sock:r,dispatch:i}):[],[jt,Ft,te,r,i]),at=T.useCallback(ie=>jt?vi({id:jt,dir:Ft},ie,{ref:K.current??void 0,kept:te},{sock:r,dispatch:i}):[],[jt,Ft,te,r,i]),ut=Wt("changes"),tn=()=>{if(x==="changes"){const he=R[D];return he?(D<_.length?pe:rt)(he.path):[]}const ie=M[D];return ie?ie.file?at(ie.file.path):Q0(ie.commit):[]},Kt=T.useCallback(ie=>{q(R.findIndex(he=>he.path===ie)),ce(ie)},[R,ce]),tt=T.useCallback(ie=>{q(M.findIndex(he=>!he.file&&he.commit.sha===ie)),Ee(ie)},[M,Ee]),qe=T.useCallback(ie=>{q(M.findIndex(he=>{var lt;return((lt=he.file)==null?void 0:lt.path)===ie})),Xe(ie)},[M,Xe]),nn=T.useCallback(()=>{},[]);return f.jsxs("div",{className:Ke("changes-dock",n&&"changes-screen",!n&&(!g||k)&&"collapsed"),style:n?void 0:{width:e},children:[f.jsx(Pu,{fill:!0,owner:"changes-tabs",label:"changes panel",items:[...l?[]:[{id:"files",label:f.jsx(Ct,{name:"folder",className:"icon-inline"}),fit:!0,ariaLabel:"files",tip:Et("files",ct("files"))}],{id:"changes",label:_.length>0?f.jsxs(f.Fragment,{children:["changes ",f.jsx("span",{className:"tab-count",children:_.length})]}):"changes"},{id:"history",label:"history"}],current:x,onPick:H}),x==="files"&&c?f.jsx(nO,{worktreeId:c,dir:d?d.worktree.path:(F==null?void 0:F.path)??"",openPath:v,openRef:b,rootRef:re}):f.jsxs("div",{className:Ke("changes-list",x==="history"&&"history"),role:"listbox","aria-label":x==="history"?"commits":"changed files","aria-activedescendant":Te&&D>=0&&D<(x==="history"?M.length:R.length)?Re(D):void 0,tabIndex:0,ref:ee,onKeyDown:wn,onFocus:()=>Ne(!0),onMouseDown:ie=>{var At;if(ie.button!==0)return;ie.preventDefault();const he=ie.target.closest('[role="option"]'),lt=he?Array.from(ie.currentTarget.querySelectorAll('[role="option"]')).indexOf(he):-1;lt>=0&&q(lt),(At=ee.current)==null||At.focus()},onBlur:ie=>!ie.currentTarget.contains(ie.relatedTarget)&&Ne(!1),...ut.contextMenu(ie=>ie==="keyboard"?tn():[]),children:[x==="changes"&&_.length>0&&f.jsxs(f.Fragment,{children:[E.length>0&&f.jsxs("div",{className:"section-title",children:["uncommitted · ",_.length]}),_.map((ie,he)=>f.jsx(Wf,{f:ie,id:Re(he),active:je(he,!b&&ie.path===v),selected:Te&&D===he,onOpen:Kt,menu:pe,onHover:Q},ie.path))]}),x==="changes"&&E.length>0&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"section-title","data-tip":"Committed on this branch, not yet on main","data-tip-placement":"follow",children:["committed · ",E.length]}),E.map((ie,he)=>f.jsx(Wf,{f:ie,id:Re(_.length+he),active:je(_.length+he,!b&&ie.path===v),selected:Te&&D===_.length+he,onOpen:Kt,menu:rt,onHover:Q},`c-${ie.path}`))]}),x==="changes"&&j&&E.length===0&&f.jsx("div",{className:"empty",children:l?l.landed?"all of it landed":"nothing that is not on main":"clean"}),x==="history"&&M.map((ie,he)=>f.jsxs(T.Fragment,{children:[l&&O.has(he)&&f.jsx("div",{className:"section-title",children:O.get(he)}),!l&&G>0&&he===0&&f.jsxs("div",{className:"section-title",children:["on this branch · ",G]}),!l&&G>0&&he===ne&&f.jsx("div",{className:"section-title",children:C}),ie.file?f.jsx(Wf,{f:ie.file,id:Re(he),active:je(he,b===ie.commit.sha&&ie.file.path===v),selected:Te&&D===he,onOpen:qe,menu:at,onHover:nn}):f.jsx(qR,{c:ie.commit,id:Re(he),selected:Te&&D===he,onToggle:tt})]},ie.file?`${ie.commit.sha}:${ie.file.path}`:ie.commit.sha)),x==="history"&&L===void 0&&f.jsx("div",{className:"empty",children:"reading history…"}),x==="history"&&(L==null?void 0:L.length)===0&&f.jsx("div",{className:"empty",children:"no commits yet"})]}),F&&!l&&f.jsx(VR,{active:F,ahead:(h==null?void 0:h.ahead)??0,behind:(h==null?void 0:h.behind)??0,unpushed:(h==null?void 0:h.unpushed)??F.unpushed??0,dirty:!j})]})}function su(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 sl(e){return e>0&&e<.005?"<$0.01":`$${e.toFixed(2)}`}function iO(e){const t=e.landed?"Merged":e.uncommitted?"Archived with uncommitted changes":"Archived";return e.restorable?t:`${t}, commits not kept`}function Th(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(sl(e.cost)),t.push(yo(e.archivedAt)),t.filter(Boolean).join(" · ")}function ub(e,t,n){e==null||e.send({t:"restore-worktree",archiveId:t,clientId:n})}function Bc(e,t,{sock:n,dispatch:r}){const i=[{id:"restore",label:"restore",disabled:e.restorable?void 0:"its commits were not kept",onClick:()=>{ub(n,e.id,t),r({a:"close"})}}],a=[{id:"copy-branch",label:"copy branch name",onClick:()=>Zt(e.branch)},{id:"copy-transcript",label:"copy transcript path",onClick:()=>Zt(e.transcript)}],{sessionId:l}=e;return l&&a.push({id:"copy-session",label:"copy session id",onClick:()=>Zt(l)}),Nn([i,a,[{id:"delete",label:"delete for good…",danger:!0,onClick:()=>{window.confirm(`Delete "${e.title}" for good?
106
+
107
+ 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}))}}]])}function sO(e){const t=yo(e);if(t==="now")return"just now";const n=Number.parseInt(t,10),r={m:"minute",h:"hour",d:"day",w:"week",y:"year"}[t.slice(-1)]??"day";return`${n} ${r}${n===1?"":"s"} ago`}function aO({item:e}){const t=Ge(),n=z(i=>i.clientId),r=e.restorable?e.uncommitted?"its chat, its commits and its uncommitted changes":"its chat and its commits":"its chat";return f.jsxs("div",{className:"hint chat-archived",children:[f.jsxs("p",{children:["This worktree was archived ",sO(e.archivedAt),e.landed?", after it was merged into main":"",": its directory and branch are gone, and nothing runs. Toyon kept ",r,".",e.cost!==void 0?` The agent's session cost ${sl(e.cost)}.`:""]}),e.restorable?f.jsxs(f.Fragment,{children:[f.jsx("p",{children:"Restoring checks its commits out again on the same branch, puts the uncommitted changes back over them, unstaged, and picks the chat up from here. The directory is new, so the install and setup commands run, and then the processes from the project's settings start. A message sent below restores it first."}),f.jsx($e,{variant:"outline",onClick:()=>ub(t,e.id,n),children:"restore"})]}):f.jsx("p",{children:"Its commits were not kept, so there is nothing to restore. Its row's menu on the rail can delete it for good."})]})}function db(e){return e.key==="a"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function lO(e){T.useEffect(()=>{let t=!1;const n=i=>{t=!!e.current&&i.target instanceof Node&&e.current.contains(i.target)},r=i=>{const a=e.current;if(!t||!a||!db(i))return;const l=document.activeElement;l&&l!==document.body&&!a.contains(l)||(i.preventDefault(),fb(a))};return window.addEventListener("pointerdown",n,!0),window.addEventListener("keydown",r),()=>{window.removeEventListener("pointerdown",n,!0),window.removeEventListener("keydown",r)}},[e])}function cO(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 fb(e){const t=document.createRange();t.selectNodeContents(e);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}function pb(e){const t=e.findLast(n=>n.kind==="ask"&&!n.outcome);return(t==null?void 0:t.kind)==="ask"?t:null}function uO(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 dO(e){return e.map(()=>({selected:[]}))}function fO(e,t,n,r){return e.map((i,a)=>{if(a!==t)return i;const l=i.selected.includes(n);return r?{...i,selected:l?i.selected.filter(c=>c!==n):[...i.selected,n]}:{...i,selected:[n]}})}function hb(e,t,n){return e.map((r,i)=>{if(i!==t)return r;const{note:a,...l}=r;return n===void 0?l:{...l,note:n}})}function pO(e,t,n,r){return e.map((i,a)=>a!==t?i:{selected:n&&!r?[]:i.selected,note:i.note??""})}function Ky(e,t){const n=e[t];return n&&n.note!==void 0&&!n.note.trim()?hb(e,t,void 0):e}function mb(e){return e?e.options.length+(e.note?1:0):0}function hO(e,t){return!!(e!=null&&e.note)&&t===e.options.length}function gb(e,t){return!!e&&e.note!==void 0&&(t||e.selected.length===0)}function qa(e){var t;return!!e&&(e.selected.length>0||!!((t=e.note)!=null&&t.trim()))}function Ac(e,t){return e.every((n,r)=>!n.required||qa(t[r]))}function kb(e,t){var i;const n=((t==null?void 0:t.selected)??[]).map(a=>{var l;return vb(((l=e.options.find(c=>c.value===a))==null?void 0:l.label)??a)}),r=(i=t==null?void 0:t.note)==null?void 0:i.trim();return n.length===0?r||"skipped":r?`${n.join(", ")}: ${r}`:n.join(", ")}function mO(e,t){return t>=1&&t<=mb(e)?t-1:-1}function Is(e,t){if(!e)return 0;if(gb(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 gO(e,t,n){return Math.max(0,Math.min(n-1,e+t))}function kO(e,t,n){const r=e.length;for(let i=1;i<=r;i++){const a=(n+i)%r;if(!qa(t[a]))return a}return-1}function au(e){return e.length>1?e.length:-1}function yO(e){return e.length+(au(e)===-1?0:1)}function Gy(e,t,n){const r=kO(e,t,n);if(r!==-1)return{current:r,cursor:Is(e[r],t[r]),send:!1};const i=au(e);return i!==-1?{current:i,cursor:0,send:!1}:{current:n,cursor:Is(e[n],t[n]),send:!0}}const yb=/\s*\(recommended\)\s*$/i;function vO(e){return yb.test(e)}function vb(e){return e.replace(yb,"")}const wb=({open:e,remove:t})=>[e?[{id:"open",label:"open full size",onClick:e}]:[],t?[{id:"remove",label:"remove",onClick:t}]:[]];function Vy(e,t={}){return Nn([[{id:"copy-image",label:"copy image",onClick:()=>AR(e)}],...wb(t)])}function qy(e,t={}){const{text:n,href:r}=e;return Nn([n!==void 0?[{id:"copy-text",label:"copy text",onClick:()=>Zt(n)}]:r?[{id:"copy-text",label:"copy text",onClick:()=>jR(r)}]:[],...wb(t)])}function wO(e){return[q0(e),{id:"copy-link",label:"copy link",onClick:()=>Zt(e)}]}function Kf(e,t,{dispatch:n,sock:r},i={}){const a=i.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"?lu(a.file.path,i.dir??null,l):a.kind==="path"?lu(a.path,i.dir??null):[wO(a.href)]:[],d=[{id:"copy",label:"copy message",onClick:()=>Zt(e.text)}],g=[];return e.kind==="user"&&t&&g.push({id:"draft",label:"edit in composer",onClick:()=>n({a:"set-draft",id:t,text:e.text})}),Nn([...c,d,g])}function lu(e,t,n){const r=e.startsWith("/")?e:t?`${t}/${e}`:null;return[r?Qs(r,n):[],[{id:"copy-path",label:"copy path",onClick:()=>Zt(e)}]]}function bO(e,t){return Nn(lu(e,t))}function xO(e,t={}){const n=e.callFile??e.file,r=n?lu(n,t.dir??null):[],i=t.remove?[{id:"remove",label:"remove",onClick:t.remove}]:[];return Nn([...r,i])}function Bu(e,t,n,r,i){const{layout:a}=e.getState();ar({dispatch:e.dispatch},{worktreeId:n,path:r,view:"file",line:{n:i,fiber:!0}}),a.changes||e.dispatch({a:"toggle-changes"})}function al({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(Zr,{k:n}),r]},n))})}/*! @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 Yy(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 _O(e){if(Array.isArray(e))return e}function EO(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,a,l,c=[],d=!0,g=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(d=(r=a.call(n)).done)&&(c.push(r.value),c.length!==t);d=!0);}catch(k){g=!0,i=k}finally{try{if(!d&&n.return!=null&&(l=n.return(),Object(l)!==l))return}finally{if(g)throw i}}return c}}function SO(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
108
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function NO(e,t){return _O(e)||EO(e,t)||TO(e,t)||SO()}function TO(e,t){if(e){if(typeof e=="string")return Yy(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)?Yy(e,t):void 0}}const bb=Object.entries,Qy=Object.setPrototypeOf,CO=Object.isFrozen,jO=Object.getPrototypeOf,AO=Object.getOwnPropertyDescriptor;let $n=Object.freeze,Wn=Object.seal,Ts=Object.create,xb=typeof Reflect<"u"&&Reflect,jp=xb.apply,Ap=xb.construct;$n||($n=function(t){return t});Wn||(Wn=function(t){return t});jp||(jp=function(t,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),a=2;a<r;a++)i[a-2]=arguments[a];return t.apply(n,i)});Ap||(Ap=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return new t(...r)});const Ui=En(Array.prototype.forEach),IO=En(Array.prototype.lastIndexOf),Xy=En(Array.prototype.pop),Ia=En(Array.prototype.push),RO=En(Array.prototype.splice),Ps=Array.isArray,Fa=En(String.prototype.toLowerCase),Gf=En(String.prototype.toString),Jy=En(String.prototype.match),Ra=En(String.prototype.replace),ev=En(String.prototype.indexOf),OO=En(String.prototype.trim),$O=En(Number.prototype.toString),MO=En(Boolean.prototype.toString),tv=typeof BigInt>"u"?null:En(BigInt.prototype.toString),nv=typeof Symbol>"u"?null:En(Symbol.prototype.toString),Ir=En(Object.prototype.hasOwnProperty),Oa=En(Object.prototype.toString),or=En(RegExp.prototype.test),Bi=PO(TypeError);function En(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return jp(e,t,r)}}function PO(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Ap(e,n)}}function Mt(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Fa;if(Qy&&Qy(e,null),!Ps(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i=="string"){const a=n(i);a!==i&&(CO(t)||(t[r]=a),i=a)}e[i]=!0}return e}function LO(e){for(let t=0;t<e.length;t++)Ir(e,t)||(e[t]=null);return e}function Hr(e){const t=Ts(null);for(const r of bb(e)){var n=NO(r,2);const i=n[0],a=n[1];Ir(e,i)&&(Ps(a)?t[i]=LO(a):a&&typeof a=="object"&&a.constructor===Object?t[i]=Hr(a):t[i]=a)}return t}function DO(e){switch(typeof e){case"string":return e;case"number":return $O(e);case"boolean":return MO(e);case"bigint":return tv?tv(e):"0";case"symbol":return nv?nv(e):"Symbol()";case"undefined":return Oa(e);case"function":case"object":{if(e===null)return Oa(e);const t=e,n=mo(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:Oa(r)}return Oa(e)}default:return Oa(e)}}function mo(e,t){for(;e!==null;){const r=AO(e,t);if(r){if(r.get)return En(r.get);if(typeof r.value=="function")return En(r.value)}e=jO(e)}function n(){return null}return n}function zO(e){try{return or(e,""),!0}catch{return!1}}const rv=$n(["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"]),Vf=$n(["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"]),qf=$n(["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"]),FO=$n(["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"]),Yf=$n(["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"]),BO=$n(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ov=$n(["#text"]),iv=$n(["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"]),Qf=$n(["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"]),sv=$n(["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"]),Ic=$n(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),UO=Wn(/{{[\w\W]*|^[\w\W]*}}/g),HO=Wn(/<%[\w\W]*|^[\w\W]*%>/g),ZO=Wn(/\${[\w\W]*/g),WO=Wn(/^data-[\-\w.\u00B7-\uFFFF]+$/),KO=Wn(/^aria-[\-\w]+$/),av=Wn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),GO=Wn(/^(?:\w+script|data):/i),VO=Wn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),qO=Wn(/^html$/i),YO=Wn(/^[a-z][.\w]*(-[.\w]+)+$/i),lv=Wn(/<[/\w!]/g),cv=Wn(/<[/\w]/g),QO=Wn(/<\/no(script|embed|frames)/i),XO=Wn(/\/>/i),Br={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},_b=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],JO=$n(Mt({},_b)),e$=(function(){const e={};return Ui(_b,t=>{e[t]=Wn(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),$n(e)})(),t$=function(){return typeof window>"u"?null:window},n$=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(r=n.getAttribute(i));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}},uv=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},fi=function(t,n,r,i){return Ir(t,n)&&Ps(t[n])?Mt(i.base?Hr(i.base):{},t[n],i.transform):r},Xf=function(t,n,r){const i=Ir(t,n)?t[n]:void 0;return i&&typeof i=="object"?Hr(i):r()};function Eb(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:t$();const t=ye=>Eb(ye);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==Br.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,i=r.currentScript;e.DocumentFragment;const a=e.HTMLTemplateElement,l=e.Node,c=e.Element,d=e.NodeFilter,g=e.NamedNodeMap;g===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const k=e.DOMParser,p=e.trustedTypes,h=c.prototype,v=mo(h,"cloneNode"),b=mo(h,"remove"),_=mo(h,"nextSibling"),E=mo(h,"childNodes"),j=mo(h,"parentNode"),x=mo(h,"shadowRoot"),H=mo(h,"attributes"),B=l&&l.prototype?mo(l.prototype,"nodeType"):null,re=l&&l.prototype?mo(l.prototype,"nodeName"):null,F=l&&l.prototype?mo(l.prototype,"ownerDocument"):null,C=function(A){return B?B(A):A.nodeType},L=function(A){return re?re(A):A.nodeName};if(typeof a=="function"){const ye=n.createElement("template");ye.content&&ye.content.ownerDocument&&(n=ye.content.ownerDocument)}let I,Z="",V,K=!1,le=0;const de=function(){if(le>0)throw Bi('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Q=function(A){de(),le++;try{return I.createHTML(A)}finally{le--}},ce=function(A){de(),le++;try{return I.createScriptURL(A)}finally{le--}},R=function(){return K||(V=n$(p,i),K=!0),V},M=n,G=M.implementation,ne=M.createNodeIterator,O=M.createDocumentFragment,ee=M.getElementsByTagName,D=r.importNode;let q=uv();t.isSupported=typeof bb=="function"&&typeof j=="function"&&G&&G.createHTMLDocument!==void 0;const Te=UO,Ne=HO,je=ZO,Re=WO,Ze=KO,st=GO,Ee=VO,Tt=YO;let zt=av,Xe=null;const pt=Mt({},[...rv,...Vf,...qf,...Yf,...ov]);let ht=null;const wn=Mt({},[...iv,...Qf,...sv,...Ic]);let jt=Object.seal(Ts(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}})),Ft=null,te=null;const pe=Object.seal(Ts(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let rt=!0,at=!0,ut=!1,tn=!0,Kt=!1,tt=!0,qe=!1,nn=!1,ie=null,he=null,lt=!1,At=!1,bt=!1,Qt=!1,vr=!0,bn=!1;const Tn="user-content-";let Kn=!0,lr=!1,Pt={},xt=null;const hn=Mt({},["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 N=null;const X=Mt({},["audio","video","img","source","image","track"]);let me=null;const xe=Mt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),We="http://www.w3.org/1998/Math/MathML",gt="http://www.w3.org/2000/svg",Ce="http://www.w3.org/1999/xhtml";let ge=Ce,De=!1,Ue=null;const kt=Mt({},[We,gt,Ce],Gf),Gn=$n(["mi","mo","mn","ms","mtext"]);let xn=Mt({},Gn);const Cn=$n(["annotation-xml"]);let cr=Mt({},Cn);const ur=Mt({},["title","style","font","a","script"]);let io=null;const wr=["application/xhtml+xml","text/html"],yt="text/html";let Ot=null,Qn=null;const Gr=n.createElement("form"),bo=function(A){return A instanceof RegExp||A instanceof Function},dr=function(){let A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Qn&&Qn===A)return;(!A||typeof A!="object")&&(A={}),A=Hr(A),io=wr.indexOf(A.PARSER_MEDIA_TYPE)===-1?yt:A.PARSER_MEDIA_TYPE,Ot=io==="application/xhtml+xml"?Gf:Fa,Xe=fi(A,"ALLOWED_TAGS",pt,{transform:Ot}),ht=fi(A,"ALLOWED_ATTR",wn,{transform:Ot}),Ue=fi(A,"ALLOWED_NAMESPACES",kt,{transform:Gf}),me=fi(A,"ADD_URI_SAFE_ATTR",xe,{transform:Ot,base:xe}),N=fi(A,"ADD_DATA_URI_TAGS",X,{transform:Ot,base:X}),xt=fi(A,"FORBID_CONTENTS",hn,{transform:Ot}),Ft=fi(A,"FORBID_TAGS",Hr({}),{transform:Ot}),te=fi(A,"FORBID_ATTR",Hr({}),{transform:Ot}),Pt=Ir(A,"USE_PROFILES")?A.USE_PROFILES&&typeof A.USE_PROFILES=="object"?Hr(A.USE_PROFILES):A.USE_PROFILES:!1,rt=A.ALLOW_ARIA_ATTR!==!1,at=A.ALLOW_DATA_ATTR!==!1,ut=A.ALLOW_UNKNOWN_PROTOCOLS||!1,tn=A.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Kt=A.SAFE_FOR_TEMPLATES||!1,tt=A.SAFE_FOR_XML!==!1,qe=A.WHOLE_DOCUMENT||!1,At=A.RETURN_DOM||!1,bt=A.RETURN_DOM_FRAGMENT||!1,Qt=A.RETURN_TRUSTED_TYPE||!1,lt=A.FORCE_BODY||!1,vr=A.SANITIZE_DOM!==!1,bn=A.SANITIZE_NAMED_PROPS||!1,Kn=A.KEEP_CONTENT!==!1,lr=A.IN_PLACE||!1,zt=zO(A.ALLOWED_URI_REGEXP)?A.ALLOWED_URI_REGEXP:av,ge=typeof A.NAMESPACE=="string"?A.NAMESPACE:Ce,xn=Xf(A,"MATHML_TEXT_INTEGRATION_POINTS",()=>Mt({},Gn)),cr=Xf(A,"HTML_INTEGRATION_POINTS",()=>Mt({},Cn));const $=Xf(A,"CUSTOM_ELEMENT_HANDLING",()=>Ts(null));if(jt=Ts(null),Ir($,"tagNameCheck")&&bo($.tagNameCheck)&&(jt.tagNameCheck=$.tagNameCheck),Ir($,"attributeNameCheck")&&bo($.attributeNameCheck)&&(jt.attributeNameCheck=$.attributeNameCheck),Ir($,"allowCustomizedBuiltInElements")&&typeof $.allowCustomizedBuiltInElements=="boolean"&&(jt.allowCustomizedBuiltInElements=$.allowCustomizedBuiltInElements),Wn(jt),Kt&&(at=!1),bt&&(At=!0),Pt&&(Xe=Mt({},ov),ht=Ts(null),Pt.html===!0&&(Mt(Xe,rv),Mt(ht,iv)),Pt.svg===!0&&(Mt(Xe,Vf),Mt(ht,Qf),Mt(ht,Ic)),Pt.svgFilters===!0&&(Mt(Xe,qf),Mt(ht,Qf),Mt(ht,Ic)),Pt.mathMl===!0&&(Mt(Xe,Yf),Mt(ht,sv),Mt(ht,Ic))),pe.tagCheck=null,pe.attributeCheck=null,Ir(A,"ADD_TAGS")&&(typeof A.ADD_TAGS=="function"?pe.tagCheck=A.ADD_TAGS:Ps(A.ADD_TAGS)&&(Xe===pt&&(Xe=Hr(Xe)),Mt(Xe,A.ADD_TAGS,Ot))),Ir(A,"ADD_ATTR")&&(typeof A.ADD_ATTR=="function"?pe.attributeCheck=A.ADD_ATTR:Ps(A.ADD_ATTR)&&(ht===wn&&(ht=Hr(ht)),Mt(ht,A.ADD_ATTR,Ot))),Ir(A,"ADD_FORBID_CONTENTS")&&Ps(A.ADD_FORBID_CONTENTS)&&(xt===hn&&(xt=Hr(xt)),Mt(xt,A.ADD_FORBID_CONTENTS,Ot)),Kn&&(Xe["#text"]=!0),qe&&Mt(Xe,["html","head","body"]),Xe.table&&(Mt(Xe,["tbody"]),delete Ft.tbody),A.TRUSTED_TYPES_POLICY){if(typeof A.TRUSTED_TYPES_POLICY.createHTML!="function")throw Bi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof A.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Bi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const J=I;I=A.TRUSTED_TYPES_POLICY;try{Z=Q("")}catch(ue){throw I=J,ue}}else A.TRUSTED_TYPES_POLICY===null?(I=void 0,Z=""):(I===void 0&&(I=R()),I&&typeof Z=="string"&&(Z=Q("")));$n&&$n(A),Qn=A},Dn=Mt({},[...Vf,...qf,...FO]),fr=Mt({},[...Yf,...BO]),so=function(A,$,J){return $.namespaceURI===Ce?A==="svg":$.namespaceURI===We?A==="svg"&&(J==="annotation-xml"||xn[J]):!!Dn[A]},Gt=function(A,$,J){return $.namespaceURI===Ce?A==="math":$.namespaceURI===gt?A==="math"&&cr[J]:!!fr[A]},xo=function(A,$,J){return $.namespaceURI===gt&&!cr[J]||$.namespaceURI===We&&!xn[J]?!1:!fr[A]&&(ur[A]||!Dn[A])},_o=function(A){let $=j(A);(!$||!$.tagName)&&($={namespaceURI:ge,tagName:"template"});const J=Fa(A.tagName),ue=Fa($.tagName);return Ue[A.namespaceURI]?A.namespaceURI===gt?so(J,$,ue):A.namespaceURI===We?Gt(J,$,ue):A.namespaceURI===Ce?xo(J,$,ue):!!(io==="application/xhtml+xml"&&Ue[A.namespaceURI]):!1},kn=function(A){Ia(t.removed,{element:A});try{j(A).removeChild(A)}catch{if(b(A),!j(A))throw Bi("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Vr=function(A,$,J){try{A.removeAttributeNode($)}catch{try{A.removeAttribute(J)}catch{}}},we=function(A){it(A);const $=E(A);if($){const ue=[];Ui($,be=>{Ia(ue,be)}),Ui(ue,be=>{try{b(be)}catch{}})}const J=H(A);if(J)for(let ue=J.length-1;ue>=0;--ue){const be=J[ue],Ie=be&&be.name;typeof Ie=="string"&&Vr(A,be,Ie)}},Ae=function(A,$,J){if(!J)try{J=$.getAttributeNode(A)}catch{J=null}Ia(t.removed,{attribute:J||null,from:$});try{J?$.removeAttributeNode(J):$.removeAttribute(A)}catch{try{$.removeAttribute(A)}catch{}}if(A==="is")if(At||bt)try{kn($)}catch{}else try{$.setAttribute(A,"")}catch{}},ot=function(A){const $=H(A);if($)for(let J=$.length-1;J>=0;--J){const ue=$[J],be=ue&&ue.name;typeof be!="string"||ht[Ot(be)]||Vr(A,ue,be)}},it=function(A){const $=[A];for(;$.length>0;){const J=$.pop();C(J)===Br.element&&ot(J);const be=E(J);if(be)for(let Ie=be.length-1;Ie>=0;--Ie)$.push(be[Ie])}},Vt=function(A,$){return tt?A==="patchsrc"?!0:A==="for"&&$!=="label"&&$!=="output":!1},Bt=function(A){if(!tt)return;const $=[A];for(;$.length>0;){const J=$.pop(),ue=C(J);if(ue===Br.processingInstruction||ue===Br.comment&&or(cv,J.data)){try{b(J)}catch{}continue}if(ue===Br.element){const Ie=J,et=Ot(L(J));try{Ie.hasAttribute&&Ie.hasAttribute("patchsrc")&&Ie.removeAttribute("patchsrc"),Ie.hasAttribute&&Ie.hasAttribute("for")&&Vt("for",et)&&Ie.removeAttribute("for")}catch{}}const be=E(J);if(be)for(let Ie=be.length-1;Ie>=0;--Ie)$.push(be[Ie])}},jn=function(A){let $=null,J=null;if(lt)A="<remove></remove>"+A;else{const Ie=Jy(A,/^[\r\n\t ]+/);J=Ie&&Ie[0]}io==="application/xhtml+xml"&&ge===Ce&&(A='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+A+"</body></html>");const ue=I?Q(A):A;if(ge===Ce)try{$=new k().parseFromString(ue,io)}catch{}if(!$||!$.documentElement){$=G.createDocument(ge,"template",null);try{$.documentElement.innerHTML=De?Z:ue}catch{}}const be=$.body||$.documentElement;return A&&J&&be.insertBefore(n.createTextNode(J),be.childNodes[0]||null),ge===Ce?ee.call($,qe?"html":"body")[0]:qe?$.documentElement:be},Mr=function(A){const $=F?F(A):A.ownerDocument;return ne.call($||A,A,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},cn=function(A){return A=Ra(A,Te," "),A=Ra(A,Ne," "),A=Ra(A,je," "),A},mn=function(A){var $;A.normalize();const J=F?F(A):A.ownerDocument,ue=ne.call(J||A,A,d.SHOW_TEXT|d.SHOW_COMMENT|d.SHOW_CDATA_SECTION|d.SHOW_PROCESSING_INSTRUCTION,null);let be=ue.nextNode();for(;be;)be.data=cn(be.data),be=ue.nextNode();const Ie=($=A.querySelectorAll)===null||$===void 0?void 0:$.call(A,"template");Ie&&Ui(Ie,et=>{zn(et.content)&&mn(et.content)})},br=function(A){const $=re?re(A):null;return typeof $!="string"||Ot($)!=="form"?!1:typeof A.nodeName!="string"||typeof A.textContent!="string"||typeof A.removeChild!="function"||A.attributes!==H(A)||typeof A.removeAttribute!="function"||typeof A.setAttribute!="function"||typeof A.namespaceURI!="string"||typeof A.insertBefore!="function"||typeof A.hasChildNodes!="function"||A.nodeType!==B(A)||A.childNodes!==E(A)},zn=function(A){if(!B||typeof A!="object"||A===null)return!1;try{return B(A)===Br.documentFragment}catch{return!1}},pr=function(A){if(!B||typeof A!="object"||A===null)return!1;try{return typeof B(A)=="number"}catch{return!1}};function Xn(ye,A,$){ye.length!==0&&Ui(ye,J=>{J.call(t,A,$,Qn)})}const yn=function(A,$){return!!(tt&&A.hasChildNodes()&&!pr(A.firstElementChild)&&or(lv,A.textContent)&&or(lv,A.innerHTML)||tt&&A.namespaceURI===Ce&&JO[$]&&(pr(A.firstElementChild)||typeof A.textContent=="string"&&or(e$[$],A.textContent))||A.nodeType===Br.processingInstruction||tt&&A.nodeType===Br.comment&&or(cv,A.data))},xr=function(A,$){if(A instanceof RegExp)return or(A,$);if(A instanceof Function){for(var J=arguments.length,ue=new Array(J>2?J-2:0),be=2;be<J;be++)ue[be-2]=arguments[be];return!!A($,...ue)}return!1},Ti=function(A,$,J){if(!Ft[$]&&ze($)&&xr(jt.tagNameCheck,$))return!1;if(Kn&&!xt[$]){const ue=j(A),be=E(A);if(be&&ue){const Ie=be.length;for(let et=Ie-1;et>=0;--et){const U=A===J?v(be[et],!0):be[et];ue.insertBefore(U,_(A))}}}return kn(A),!0},_r=function(A,$,J,ue){return A.length===0?$:$===J||$===ue?Hr($):$},Jn=function(A,$){return A===$||j(A)!==null?!1:(lr&&it(A),!0)},Fn=function(A,$){if(Xn(q.beforeSanitizeElements,A,null),Jn(A,$))return!0;if(br(A))return kn(A),!0;const J=Ot(L(A));if(Xe=_r(q.uponSanitizeElement,Xe,pt,ie),Xn(q.uponSanitizeElement,A,{tagName:J,allowedTags:Xe}),Jn(A,$))return!0;if(yn(A,J))return kn(A),!0;if(Ft[J]||!(pe.tagCheck instanceof Function&&pe.tagCheck(J))&&!Xe[J]){const be=Ti(A,J,$);return be===!1&&Xn(q.afterSanitizeElements,A,null),be}if(C(A)===Br.element&&!_o(A)||(J==="noscript"||J==="noembed"||J==="noframes")&&or(QO,A.innerHTML))return kn(A),!0;if(Kt&&A.nodeType===Br.text){const be=cn(A.textContent);A.textContent!==be&&(Ia(t.removed,{element:A.cloneNode()}),A.textContent=be)}return Xn(q.afterSanitizeElements,A,null),!1},Eo=function(A,$,J){if(te[$]||Vt($,A)||vr&&($==="id"||$==="name")&&(J in n||J in Gr))return!1;const ue=ht[$]||pe.attributeCheck instanceof Function&&pe.attributeCheck($,A);return at&&or(Re,$)||rt&&or(Ze,$)?!0:ue?me[$]||or(zt,Ra(J,Ee,""))||($==="src"||$==="xlink:href"||$==="href")&&A!=="script"&&ev(J,"data:")===0&&N[A]||ut&&!or(st,Ra(J,Ee,""))?!0:!J:ze(A)&&xr(jt.tagNameCheck,A)&&xr(jt.attributeNameCheck,$,A)||$==="is"&&jt.allowCustomizedBuiltInElements&&xr(jt.tagNameCheck,J)},vt=Mt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ze=function(A){return!vt[Fa(A)]&&or(Tt,A)},Ro=function(A,$,J,ue){if(I&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!J)switch(p.getAttributeType(A,$)){case"TrustedHTML":return Q(ue);case"TrustedScriptURL":return ce(ue)}return ue},Xt=function(A,$,J,ue){try{J?A.setAttributeNS(J,$,ue):A.setAttribute($,ue),br(A)?kn(A):Xy(t.removed)}catch{Ae($,A)}},Nt=function(A){Xn(q.beforeSanitizeAttributes,A,null);const $=A.attributes;if(!$||br(A))return;ht=_r(q.uponSanitizeAttribute,ht,wn,he);const J={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ht,forceKeepAttr:void 0};let ue=$.length;const be=Ot(A.nodeName);for(;ue--;){const Ie=$[ue],et=Ie.name,U=Ie.namespaceURI,Me=Ie.value,Je=Ot(et),An=Me;let qt=et==="value"?An:OO(An);if(J.attrName=Je,J.attrValue=qt,J.keepAttr=!0,J.forceKeepAttr=void 0,Xn(q.uponSanitizeAttribute,A,J),qt=J.attrValue,bn&&(Je==="id"||Je==="name")&&ev(qt,Tn)!==0&&(Ae(et,A,Ie),qt=Tn+qt),tt&&or(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,qt)){Ae(et,A,Ie);continue}if(Je==="attributename"&&Jy(qt,"href")){Ae(et,A,Ie);continue}if(!J.forceKeepAttr){if(!J.keepAttr){Ae(et,A,Ie);continue}if(!tn&&or(XO,qt)){Ae(et,A,Ie);continue}if(Kt&&(qt=cn(qt)),!Eo(be,Je,qt)){Ae(et,A,Ie);continue}qt=Ro(be,Je,U,qt),qt!==An&&Xt(A,et,U,qt)}}Xn(q.afterSanitizeAttributes,A,null)},Er=function(A){let $=null;const J=Mr(A);for(Xn(q.beforeSanitizeShadowDOM,A,null);$=J.nextNode();)if(Xn(q.uponSanitizeShadowNode,$,null),Fn($,A),Nt($),zn($.content)&&Er($.content),C($)===Br.element){const ue=x($);zn(ue)&&(Bn(ue),Er(ue))}Xn(q.afterSanitizeShadowDOM,A,null)},Bn=function(A){const $=[{node:A,shadow:null}];for(;$.length>0;){const J=$.pop();if(J.shadow){Er(J.shadow);continue}const ue=J.node,Ie=C(ue)===Br.element,et=E(ue);if(et)for(let U=et.length-1;U>=0;--U)$.push({node:et[U],shadow:null});if(Ie){const U=re?re(ue):null;if(typeof U=="string"&&Ot(U)==="template"){const Me=ue.content;zn(Me)&&$.push({node:Me,shadow:null})}}if(Ie){const U=x(ue);zn(U)&&$.push({node:null,shadow:U},{node:U,shadow:null})}}};return t.sanitize=function(ye){let A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},$=null,J=null,ue=null,be=null;if(De=!ye,De&&(ye="<!-->"),typeof ye!="string"&&!pr(ye)&&(ye=DO(ye),typeof ye!="string"))throw Bi("dirty is not a string, aborting");if(!t.isSupported)return ye;nn?(Xe=ie,ht=he):dr(A),(q.uponSanitizeElement.length>0||q.uponSanitizeAttribute.length>0)&&(Xe=Hr(Xe)),q.uponSanitizeAttribute.length>0&&(ht=Hr(ht)),t.removed=[];const Ie=lr&&typeof ye!="string"&&pr(ye);if(Ie){Bt(ye);const Me=L(ye);if(typeof Me=="string"){const Je=Ot(Me);if(!Xe[Je]||Ft[Je])throw we(ye),Bi("root node is forbidden and cannot be sanitized in-place")}if(br(ye))throw we(ye),Bi("root node is clobbered and cannot be sanitized in-place");try{Bn(ye)}catch(Je){throw we(ye),Je}}else if(pr(ye))$=jn("<!---->"),J=$.ownerDocument.importNode(ye,!0),J.nodeType===Br.element&&J.nodeName==="BODY"||J.nodeName==="HTML"?$=J:$.appendChild(J),Bn(J);else{if(!At&&!Kt&&!qe&&ye.indexOf("<")===-1)return I&&Qt?Q(ye):ye;if($=jn(ye),!$)return At?null:Qt?Z:""}$&&lt&&kn($.firstChild);const et=Ie?ye:$;try{const Me=Mr(et);for(;ue=Me.nextNode();)Fn(ue,et),Nt(ue),zn(ue.content)&&Er(ue.content)}catch(Me){throw Ie&&(we(ye),Ui(t.removed,Je=>{Je.element&&it(Je.element)})),Me}if(Ie)return Ui(t.removed,Me=>{Me.element&&it(Me.element)}),Kt&&mn(ye),ye;if(At){if(Kt&&mn($),bt)for(be=O.call($.ownerDocument);$.firstChild;)be.appendChild($.firstChild);else be=$;return(ht.shadowroot||ht.shadowrootmode)&&(be=D.call(r,be,!0)),be}let U=qe?$.outerHTML:$.innerHTML;return qe&&Xe["!doctype"]&&$.ownerDocument&&$.ownerDocument.doctype&&$.ownerDocument.doctype.name&&or(qO,$.ownerDocument.doctype.name)&&(U="<!DOCTYPE "+$.ownerDocument.doctype.name+`>
109
+ `+U),Kt&&(U=cn(U)),I&&Qt?Q(U):U},t.setConfig=function(){let ye=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};dr(ye),nn=!0,ie=Xe,he=ht},t.clearConfig=function(){Qn=null,nn=!1,ie=null,he=null,I=V,Z=""},t.isValidAttribute=function(ye,A,$){Qn||dr({});const J=Ot(ye),ue=Ot(A);return Eo(J,ue,$)},t.addHook=function(ye,A){typeof A=="function"&&Ir(q,ye)&&Ia(q[ye],A)},t.removeHook=function(ye,A){if(Ir(q,ye)){if(A!==void 0){const $=IO(q[ye],A);return $===-1?void 0:RO(q[ye],$,1)[0]}return Xy(q[ye])}},t.removeHooks=function(ye){Ir(q,ye)&&(q[ye]=[])},t.removeAllHooks=function(){q=uv()},t}var r$=Eb();function Ch(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ts=Ch();function Sb(e){ts=e}var Hi={exec:()=>null};function Ns(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function St(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(i,a)=>{let l=typeof a=="string"?a:a.source;return l=l.replace(sr.caret,"$1"),n=n.replace(i,l),r},getRegex:()=>new RegExp(n,t)};return r}var o$=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),sr={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:Ns(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Ns(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Ns(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Ns(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Ns(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:Ns(e=>new RegExp(`^ {0,${e}}>`))},i$=/^(?:[ \t]*(?:\n|$))+/,s$=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,a$=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,bl=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,l$=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,jh=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Nb=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Tb=St(Nb).replace(/bull/g,jh).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(),c$=St(Nb).replace(/bull/g,jh).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(),Ah=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,u$=/^[^\n]+/,Ih=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,d$=St(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ih).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),f$=St(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,jh).getRegex(),Uu="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",Rh=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,p$=St("^ {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",Rh).replace("tag",Uu).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Cb=e=>St(Ah).replace("hr",bl).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",Uu).getRegex(),h$=Cb(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),m$=Cb(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),g$=St(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",m$).getRegex(),Oh={blockquote:g$,code:s$,def:d$,fences:a$,heading:l$,hr:bl,html:p$,lheading:Tb,list:f$,newline:i$,paragraph:h$,table:Hi,text:u$},dv=St("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",bl).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",Uu).getRegex(),k$={...Oh,lheading:c$,table:dv,paragraph:St(Ah).replace("hr",bl).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",dv).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",Uu).getRegex()},y$={...Oh,html:St(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Rh).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:Hi,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:St(Ah).replace("hr",bl).replace("heading",` *#{1,6} *[^
110
+ ]`).replace("lheading",Tb).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},v$=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,w$=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,jb=/^( {2,}|\\)\n(?!\s*$)/,b$=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Yo=/[\p{P}\p{S}]/u,Xs=/[\s\p{P}\p{S}]/u,xl=/[^\s\p{P}\p{S}]/u,x$=St(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Xs).getRegex(),_$=/[\p{Pi}\p{Ps}"']/u,Ab=/(?!~)[\p{P}\p{S}]/u,E$=/(?!~)[\s\p{P}\p{S}]/u,S$=/(?:[^\s\p{P}\p{S}]|~)/u,N$=St(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",o$?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Ib=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,T$=St(Ib,"u").replace(/punct/g,Yo).getRegex(),C$=St(Ib,"u").replace(/punct/g,Ab).getRegex(),j$=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,A$=St(j$,"u").replace(/openQuote/g,_$).replace(/punct/g,Yo).getRegex(),Rb="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",I$=St(Rb,"gu").replace(/notPunctSpace/g,xl).replace(/punctSpace/g,Xs).replace(/punct/g,Yo).getRegex(),R$=St(Rb,"gu").replace(/notPunctSpace/g,S$).replace(/punctSpace/g,E$).replace(/punct/g,Ab).getRegex(),O$="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",$$=St(O$,"gu").replace(/notPunctSpace/g,xl).replace(/punctSpace/g,Xs).replace(/punct/g,Yo).getRegex(),M$=St("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,xl).replace(/punctSpace/g,Xs).replace(/punct/g,Yo).getRegex(),P$="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",L$=St(P$,"gu").replace(/notPunctSpace/g,xl).replace(/punctSpace/g,Xs).replace(/punct/g,Yo).getRegex(),D$=St(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Yo).getRegex(),z$="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",F$=St(z$,"gu").replace(/notPunctSpace/g,xl).replace(/punctSpace/g,Xs).replace(/punct/g,Yo).getRegex(),B$=St(/\\(punct)/,"gu").replace(/punct/g,Yo).getRegex(),U$=St(/^<(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(),H$=St(Rh).replace("(?:-->|$)","-->").getRegex(),Z$=St("^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",H$).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),cu=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,W$=St(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",cu).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ob=St(/^!?\[(label)\]\[(ref)\]/).replace("label",cu).replace("ref",Ih).getRegex(),$b=St(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ih).getRegex(),K$=St("reflink|nolink(?!\\()","g").replace("reflink",Ob).replace("nolink",$b).getRegex(),fv=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,$h={_backpedal:Hi,anyPunctuation:B$,autolink:U$,blockSkip:N$,br:jb,code:w$,del:Hi,delLDelim:Hi,delRDelim:Hi,emStrongLDelim:T$,emStrongRDelimAst:I$,emStrongRDelimUnd:M$,escape:v$,link:W$,nolink:$b,punctuation:x$,reflink:Ob,reflinkSearch:K$,tag:Z$,text:b$,url:Hi},G$={...$h,emStrongLDelim:A$,emStrongRDelimAst:$$,emStrongRDelimUnd:L$,link:St(/^!?\[(label)\]\((.*?)\)/).replace("label",cu).getRegex(),reflink:St(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",cu).getRegex()},Ip={...$h,emStrongRDelimAst:R$,emStrongLDelim:C$,delLDelim:D$,delRDelim:F$,url:St(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",fv).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:St(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",fv).getRegex()},V$={...Ip,br:St(jb).replace("{2,}","*").getRegex(),text:St(Ip.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Rc={normal:Oh,gfm:k$,pedantic:y$},$a={normal:$h,gfm:Ip,breaks:V$,pedantic:G$},q$={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},pv=e=>q$[e];function Ao(e,t){if(t){if(sr.escapeTest.test(e))return e.replace(sr.escapeReplace,pv)}else if(sr.escapeTestNoEncode.test(e))return e.replace(sr.escapeReplaceNoEncode,pv);return e}function hv(e){try{e=encodeURI(e).replace(sr.percentDecode,"%")}catch{return null}return e}function mv(e,t){var a;let n=e.replace(sr.findPipe,(l,c,d)=>{let g=!1,k=c;for(;--k>=0&&d[k]==="\\";)g=!g;return g?"|":" |"}),r=n.split(sr.splitPipe),i=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(;i<r.length;i++)r[i]=r[i].trim().replace(sr.slashPipe,"|");return r}function pi(e,t,n){let r=e.length;if(r===0)return"";let i=0;for(;i<r&&e.charAt(r-i-1)===t;)i++;return e.slice(0,r-i)}function gv(e){let t=e.split(`
111
+ `),n=t.length-1;for(;n>=0&&sr.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
112
+ `)}function Y$(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 Q$(e,t=0){let n=t,r="";for(let i of e)if(i===" "){let a=4-n%4;r+=" ".repeat(a),n+=a}else r+=i,n++;return r}function kv(e,t,n,r,i){let a=t.href,l=t.title||null,c=e[1].replace(i.other.outputLinkReplace,"$1"),d=e[0].charAt(0)==="!";r.state.inLink=!0;let g=r.state.linkEmitted,k=r.state.inRawBlock;r.state.linkEmitted=!1;let p=r.inlineTokens(c),h=r.state.linkEmitted;if(r.state.linkEmitted=g,r.state.inLink=!1,!d){if(h){r.state.inRawBlock=k;return}r.state.linkEmitted=!0}return{type:d?"image":"link",raw:n,href:a,title:l,text:c,tokens:p}}function X$(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
113
+ `).map(a=>{let l=a.match(n.other.beginningSpace);if(l===null)return a;let[c]=l;return c.length>=i.length?a.slice(i.length):a}).join(`
114
+ `)}var uu=class{constructor(e){mt(this,"options");mt(this,"rules");mt(this,"lexer");this.options=e||ts}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]:gv(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=X$(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=pi(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:pi(t[0],`
115
+ `),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:pi(t[0],`
116
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=pi(t[0],`
117
+ `).split(`
118
+ `),r="",i="",a=[];for(;n.length>0;){let l=!1,c=[],d;for(d=0;d<n.length;d++)if(this.rules.other.blockquoteStart.test(n[d]))c.push(n[d]),l=!0;else if(!l)c.push(n[d]);else break;n=n.slice(d);let g=c.join(`
119
+ `),k=g.replace(this.rules.other.blockquoteSetextReplace,`
120
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
121
+ ${g}`:g,i=i?`${i}
122
+ ${k}`:k;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(k,a,!0),this.lexer.state.top=p,n.length===0)break;let h=a.at(-1);if((h==null?void 0:h.type)==="code")break;if((h==null?void 0:h.type)==="blockquote"){let v=h,b=n.join(`
123
+ `),_=v.raw+`
124
+ `+b.replace(this.rules.other.blockquoteSetextReplace2,""),E=this.blockquote(_);a[a.length-1]=E,r=`${r}
125
+ ${b}`,i=i.substring(0,i.length-v.text.length)+E.text;break}else if((h==null?void 0:h.type)==="list"){let v=h,b=v.raw+`
126
+ `+n.join(`
127
+ `),_=this.list(b);a[a.length-1]=_,r=r.substring(0,r.length-h.raw.length)+_.raw,i=i.substring(0,i.length-v.raw.length)+_.raw,n=b.substring(a.at(-1).raw.length).split(`
128
+ `);continue}}return{type:"blockquote",raw:r,tokens:a,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={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 d=!1,g="",k="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;g=t[0],e=e.substring(g.length);let p=Q$(t[2].split(`
129
+ `,1)[0],t[1].length),h=e.split(`
130
+ `,1)[0],v=!p.trim(),b=0;if(this.options.pedantic?(b=2,k=p.trimStart()):v?b=t[1].length+1:(b=p.search(this.rules.other.nonSpaceChar),b=b>4?1:b,k=p.slice(b),b+=t[1].length),v&&this.rules.other.blankLine.test(h)&&(g+=h+`
131
+ `,e=e.substring(h.length+1),d=!0),!d){let _=this.rules.other.nextBulletRegex(b),E=this.rules.other.hrRegex(b),j=this.rules.other.fencesBeginRegex(b),x=this.rules.other.headingBeginRegex(b),H=this.rules.other.htmlBeginRegex(b),B=this.rules.other.blockquoteBeginRegex(b);for(;e;){let re=e.split(`
132
+ `,1)[0],F;if(h=re,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),F=h):F=h.replace(this.rules.other.tabCharGlobal," "),j.test(h)||x.test(h)||H.test(h)||B.test(h)||_.test(h)||E.test(h))break;if(F.search(this.rules.other.nonSpaceChar)>=b||!h.trim())k+=`
133
+ `+F.slice(b);else{if(v||p.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||j.test(p)||x.test(p)||E.test(p))break;k+=`
134
+ `+h}v=!h.trim(),g+=re+`
135
+ `,e=e.substring(re.length+1),p=F.slice(b)}}i.loose||(l?i.loose=!0:this.rules.other.doubleBlankLine.test(g)&&(l=!0)),i.items.push({type:"list_item",raw:g,task:!!this.options.gfm&&this.rules.other.listIsTask.test(k),loose:!1,text:k,tokens:[]}),i.raw+=g}let c=i.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let d of i.items)if(this.lexer.state.top=!1,d.tokens=this.lexer.blockTokens(d.text,[]),!i.loose){let g=d.tokens.filter(p=>p.type==="space"),k=g.length>0&&g.some(p=>this.rules.other.anyLine.test(p.raw));i.loose=k}for(let d of i.items){let g=d.tokens[0];if(d.task&&((g==null?void 0:g.type)==="text"||(g==null?void 0:g.type)==="paragraph")){d.text=d.text.replace(this.rules.other.listReplaceTask,""),g.raw=g.raw.replace(this.rules.other.listReplaceTask,""),g.text=g.text.replace(this.rules.other.listReplaceTask,"");for(let p=this.lexer.inlineQueue.length-1;p>=0;p--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[p].src)){this.lexer.inlineQueue[p].src=this.lexer.inlineQueue[p].src.replace(this.rules.other.listReplaceTask,"");break}let k=this.rules.other.listTaskCheckbox.exec(d.raw);if(k){let p={type:"checkbox",raw:k[0]+" ",checked:k[0]!=="[ ]"};d.checked=p.checked,i.loose?d.tokens[0]&&["paragraph","text"].includes(d.tokens[0].type)&&"tokens"in d.tokens[0]&&d.tokens[0].tokens?(d.tokens[0].raw=p.raw+d.tokens[0].raw,d.tokens[0].text=p.raw+d.tokens[0].text,d.tokens[0].tokens.unshift(p)):d.tokens.unshift({type:"paragraph",raw:p.raw,text:p.raw,tokens:[p]}):d.tokens.unshift(p)}}else d.task&&(d.task=!1)}if(i.loose)for(let d of i.items){d.loose=!0;for(let g of d.tokens)g.type==="text"&&(g.type="paragraph")}return i}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=gv(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"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:pi(t[0],`
136
+ `),href:r,title:i}}}table(e){var l;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=mv(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(l=t[3])!=null&&l.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
137
+ `):[],a={type:"table",raw:pi(t[0],`
138
+ `),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 i)a.rows.push(mv(c,a.header.length).map((d,g)=>({text:d,tokens:this.lexer.inline(d),header:!1,align:a.align[g]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:pi(t[0],`
139
+ `),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)===`
140
+ `?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=pi(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{let a=Y$(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],i="";if(this.options.pedantic){let a=this.rules.other.pedanticHrefTitle.exec(r);a&&(r=a[1],i=a[3])}else i=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)),kv(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.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," "),i=t[r.toLowerCase()];if(!i){let a=n[0].charAt(0);return{type:"text",raw:a,text:a}}return kv(n,i,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 i=[...r[0]].length-1,a,l,c=i,d=0,g=r[0][0],k=n===g,p=g==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,t=t.slice(-1*e.length+i);(r=p.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(i%3&&!((i+l)%3)){d+=l;continue}if(k)break}if(c-=l,c>0)continue;l=Math.min(l,l+c+d);let h=[...r[0]][0].length,v=e.slice(0,i+r.index+h+l);if(Math.min(i,l)%2){let _=v.slice(1,-1);return{type:"em",raw:v,text:_,tokens:this.lexer.inlineTokens(_)}}let b=v.slice(2,-2);return{type:"strong",raw:v,text:b,tokens:this.lexer.inlineTokens(b)}}}}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),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(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 i=[...r[0]].length-1,a,l,c=i,d=this.rules.inline.delRDelim;for(d.lastIndex=0,t=t.slice(-1*e.length+i);(r=d.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a||(l=[...a].length,l!==i))continue;if(r[3]||r[4]){c+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c);let g=[...r[0]][0].length,k=e.slice(0,i+r.index+g+l),p=k.slice(i,-i);return{type:"del",raw:k,text:p,tokens:this.lexer.inlineTokens(p)}}}}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,i;if(t[2]==="@")r=t[0],i="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."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:r,href:i,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}}}},go=class Rp{constructor(t){mt(this,"tokens");mt(this,"options");mt(this,"state");mt(this,"inlineQueue");mt(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||ts,this.options.tokenizer=this.options.tokenizer||new uu,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:sr,block:Rc.normal,inline:$a.normal};this.options.pedantic?(n.block=Rc.pedantic,n.inline=$a.pedantic):this.options.gfm&&(n.block=Rc.gfm,this.options.breaks?n.inline=$a.breaks:n.inline=$a.gfm),this.tokenizer.rules=n}static get rules(){return{block:Rc,inline:$a}}static lex(t,n){return new Rp(n).lex(t)}static lexInline(t,n){return new Rp(n).inlineTokens(t)}lex(t){t=t.replace(sr.carriageReturn,`
141
+ `),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(sr.tabCharGlobal," ").replace(sr.spaceLine,""));let i=1/0;for(;t;){if(t.length<i)i=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let d;if((l=(a=this.options.extensions)==null?void 0:a.block)!=null&&l.some(k=>(d=k.call({lexer:this},t,n))?(t=t.substring(d.raw.length),n.push(d),!0):!1))continue;if(d=this.tokenizer.space(t)){t=t.substring(d.raw.length);let k=n.at(-1);d.raw.length===1&&k!==void 0?k.raw+=`
142
+ `:n.push(d);continue}if(d=this.tokenizer.code(t)){t=t.substring(d.raw.length);let k=n.at(-1);(k==null?void 0:k.type)==="paragraph"||(k==null?void 0:k.type)==="text"?(k.raw+=(k.raw.endsWith(`
143
+ `)?"":`
144
+ `)+d.raw,k.text+=`
145
+ `+d.text,this.inlineQueue.at(-1).src=k.text):n.push(d);continue}if(d=this.tokenizer.fences(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.heading(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.hr(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.blockquote(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.list(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.html(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.def(t)){t=t.substring(d.raw.length);let k=n.at(-1);(k==null?void 0:k.type)==="paragraph"||(k==null?void 0:k.type)==="text"?(k.raw+=(k.raw.endsWith(`
146
+ `)?"":`
147
+ `)+d.raw,k.text+=`
148
+ `+d.raw,this.inlineQueue.at(-1).src=k.text):this.tokens.links[d.tag]||(this.tokens.links[d.tag]={href:d.href,title:d.title},n.push(d));continue}if(d=this.tokenizer.table(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.lheading(t)){t=t.substring(d.raw.length),n.push(d);continue}let g=t;if((c=this.options.extensions)!=null&&c.startBlock){let k=1/0,p=t.slice(1),h;this.options.extensions.startBlock.forEach(v=>{h=v.call({lexer:this},p),typeof h=="number"&&h>=0&&(k=Math.min(k,h))}),k<1/0&&k>=0&&(g=t.substring(0,k+1))}if(this.state.top&&(d=this.tokenizer.paragraph(g))){let k=n.at(-1);r&&(k==null?void 0:k.type)==="paragraph"?(k.raw+=(k.raw.endsWith(`
149
+ `)?"":`
150
+ `)+d.raw,k.text+=`
151
+ `+d.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=k.text):n.push(d),r=g.length!==t.length,t=t.substring(d.raw.length);continue}if(d=this.tokenizer.text(t)){t=t.substring(d.raw.length);let k=n.at(-1);(k==null?void 0:k.type)==="text"?(k.raw+=(k.raw.endsWith(`
152
+ `)?"":`
153
+ `)+d.raw,k.text+=`
154
+ `+d.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=k.text):n.push(d);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 i=r[0],a=i.lastIndexOf("[");if(!(i.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,i.slice(a+1,-1)))&&!(a>1&&this.linkInText(i.slice(1,a-1))))return!0}return!1}inlineTokens(t,n=[]){var c,d,g,k,p;this.tokenizer.lexer=this;let r=t;if(this.tokens.links&&t.includes("[")){let h=this.tokenizer.rules.inline.reflinkSearch,v=b=>{let _=b.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,b.slice(_+1,-1)))return b;if(_>1&&b.charAt(0)!=="!"){let E=b.slice(1,_-1);if(this.linkInText(E))return"["+E.replace(h,v)+"]["+"a".repeat(b.length-_-2)+"]"}return"["+"a".repeat(b.length-2)+"]"};r=r.replace(h,v)}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,h=>"+".repeat(h.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(h,v,b)=>{let _=b?b.length:0;return h.slice(0,_)+"["+"a".repeat(h.length-_-2)+"]"}),r=((d=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:d.call({lexer:this},r))??r;let i=!1,a="",l=1/0;for(;t;){if(t.length<l)l=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}i||(a=""),i=!1;let h;if((k=(g=this.options.extensions)==null?void 0:g.inline)!=null&&k.some(b=>(h=b.call({lexer:this},t,n))?(t=t.substring(h.raw.length),n.push(h),!0):!1))continue;if(h=this.tokenizer.escape(t)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.tag(t)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.link(t)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(h.raw.length);let b=n.at(-1);h.type==="text"&&(b==null?void 0:b.type)==="text"?(b.raw+=h.raw,b.text+=h.text):n.push(h);continue}if(h=this.tokenizer.emStrong(t,r,a)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.codespan(t)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.br(t)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.del(t,r,a)){t=t.substring(h.raw.length),n.push(h);continue}if(h=this.tokenizer.autolink(t)){t=t.substring(h.raw.length),n.push(h);continue}if(!this.state.inLink&&(h=this.tokenizer.url(t))){t=t.substring(h.raw.length),n.push(h);continue}let v=t;if((p=this.options.extensions)!=null&&p.startInline){let b=1/0,_=t.slice(1),E;this.options.extensions.startInline.forEach(j=>{E=j.call({lexer:this},_),typeof E=="number"&&E>=0&&(b=Math.min(b,E))}),b<1/0&&b>=0&&(v=t.substring(0,b+1))}if(h=this.tokenizer.inlineText(v)){t=t.substring(h.raw.length),h.raw.slice(-1)!=="_"&&(a=h.raw.slice(-1)),i=!0;let b=n.at(-1);(b==null?void 0:b.type)==="text"?(b.raw+=h.raw,b.text+=h.text):n.push(h);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)}},du=class{constructor(e){mt(this,"options");mt(this,"parser");this.options=e||ts}space(e){return""}code({text:e,lang:t,escaped:n}){var a;let r=(a=(t||"").match(sr.notSpaceStart))==null?void 0:a[0],i=e.replace(sr.endingNewline,"")+`
155
+ `;return r?'<pre><code class="language-'+Ao(r)+'">'+(n?i:Ao(i,!0))+`</code></pre>
156
+ `:"<pre><code>"+(n?i:Ao(i,!0))+`</code></pre>
157
+ `}blockquote({tokens:e}){return`<blockquote>
158
+ ${this.parser.parse(e)}</blockquote>
159
+ `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
160
+ `}hr(e){return`<hr>
161
+ `}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 i=t?"ol":"ul",a=t&&n!==1?' start="'+n+'"':"";return"<"+i+a+`>
162
+ `+r+"</"+i+`>
163
+ `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
164
+ `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
165
+ `}table(e){let t="",n="";for(let i=0;i<e.header.length;i++)n+=this.tablecell(e.header[i]);t+=this.tablerow({text:n});let r="";for(let i=0;i<e.rows.length;i++){let a=e.rows[i];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>
166
+ <thead>
167
+ `+t+`</thead>
168
+ `+r+`</table>
169
+ `}tablerow({text:e}){return`<tr>
170
+ ${e}</tr>
171
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
172
+ `}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>${Ao(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),i=hv(e);if(i===null)return r;e=i;let a='<a href="'+e+'"';return t&&(a+=' title="'+Ao(t)+'"'),a+=">"+r+"</a>",a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=hv(e);if(i===null)return Ao(n);e=i;let a=`<img src="${e}" alt="${Ao(n)}"`;return t&&(a+=` title="${Ao(t)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Ao(e.text)}},Mh=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}},ko=class Op{constructor(t){mt(this,"options");mt(this,"renderer");mt(this,"textRenderer");this.options=t||ts,this.options.renderer=this.options.renderer||new du,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Mh}static parse(t,n){return new Op(n).parse(t)}static parseInline(t,n){return new Op(n).parseInline(t)}parse(t){var r,i;this.renderer.parser=this;let n="";for(let a=0;a<t.length;a++){let l=t[a];if((i=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&i[l.type]){let d=l,g=this.options.extensions.renderers[d.type].call({parser:this},d);if(g!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(d.type)){n+=g||"";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 d='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return n}parseInline(t,n=this.renderer){var i,a;this.renderer.parser=this;let r="";for(let l=0;l<t.length;l++){let c=t[l];if((a=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&a[c.type]){let g=this.options.extensions.renderers[c.type].call({parser:this},c);if(g!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(c.type)){r+=g||"";continue}}let d=c;switch(d.type){case"escape":{r+=n.text(d);break}case"html":{r+=n.html(d);break}case"link":{r+=n.link(d);break}case"image":{r+=n.image(d);break}case"checkbox":{r+=n.checkbox(d);break}case"strong":{r+=n.strong(d);break}case"em":{r+=n.em(d);break}case"codespan":{r+=n.codespan(d);break}case"br":{r+=n.br(d);break}case"del":{r+=n.del(d);break}case"text":{r+=n.text(d);break}default:{let g='Token with "'+d.type+'" type was not found.';if(this.options.silent)return console.error(g),"";throw new Error(g)}}}return r}},Mc,Ba=(Mc=class{constructor(e){mt(this,"options");mt(this,"block");this.options=e||ts}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?go.lex:go.lexInline}provideParser(e=this.block){return e?ko.parse:ko.parseInline}},mt(Mc,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),mt(Mc,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Mc),J$=class{constructor(...e){mt(this,"defaults",Ch());mt(this,"options",this.setOptions);mt(this,"parse",this.parseMarkdown(!0));mt(this,"parseInline",this.parseMarkdown(!1));mt(this,"Parser",ko);mt(this,"Renderer",du);mt(this,"TextRenderer",Mh);mt(this,"Lexer",go);mt(this,"Tokenizer",uu);mt(this,"Hooks",Ba);this.use(...e)}walkTokens(e,t){var r,i;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 d of c)n=n.concat(this.walkTokens(d.tokens,t));break}case"list":{let l=a;n=n.concat(this.walkTokens(l.items,t));break}default:{let l=a;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[l.type]?this.defaults.extensions.childTokens[l.type].forEach(c=>{let d=l[c].flat(1/0);n=n.concat(this.walkTokens(d,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(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let a=t.renderers[i.name];a?t.renderers[i.name]=function(...l){let c=i.renderer.apply(this,l);return c===!1&&(c=a.apply(this,l)),c}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=t[i.level];a?a.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),r.extensions=t),n.renderer){let i=this.defaults.renderer||new du(this.defaults);for(let a in n.renderer){if(!(a in i))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let l=a,c=n.renderer[l],d=i[l];i[l]=(...g)=>{let k=c.apply(i,g);return k===!1&&(k=d.apply(i,g)),k||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new uu(this.defaults);for(let a in n.tokenizer){if(!(a in i))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let l=a,c=n.tokenizer[l],d=i[l];i[l]=(...g)=>{let k=c.apply(i,g);return k===!1&&(k=d.apply(i,g)),k}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new Ba;for(let a in n.hooks){if(!(a in i))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let l=a,c=n.hooks[l],d=i[l];Ba.passThroughHooks.has(a)?i[l]=g=>{if(this.defaults.async&&Ba.passThroughHooksRespectAsync.has(a))return(async()=>{let p=await c.call(i,g);return d.call(i,p)})();let k=c.call(i,g);return d.call(i,k)}:i[l]=(...g)=>{if(this.defaults.async)return(async()=>{let p=await c.apply(i,g);return p===!1&&(p=await d.apply(i,g)),p})();let k=c.apply(i,g);return k===!1&&(k=d.apply(i,g)),k}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,a=n.walkTokens;r.walkTokens=function(l){let c=[];return c.push(a.call(this,l)),i&&(c=c.concat(i.call(this,l))),c}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return go.lex(e,t??this.defaults)}parser(e,t){return ko.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.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(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let l=i.hooks?await i.hooks.preprocess(t):t,c=await(i.hooks?await i.hooks.provideLexer(e):e?go.lex:go.lexInline)(l,i),d=i.hooks?await i.hooks.processAllTokens(c):c;i.walkTokens&&await Promise.all(this.walkTokens(d,i.walkTokens));let g=await(i.hooks?await i.hooks.provideParser(e):e?ko.parse:ko.parseInline)(d,i);return i.hooks?await i.hooks.postprocess(g):g})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let l=(i.hooks?i.hooks.provideLexer(e):e?go.lex:go.lexInline)(t,i);i.hooks&&(l=i.hooks.processAllTokens(l)),i.walkTokens&&this.walkTokens(l,i.walkTokens);let c=(i.hooks?i.hooks.provideParser(e):e?ko.parse:ko.parseInline)(l,i);return i.hooks&&(c=i.hooks.postprocess(c)),c}catch(l){return a(l)}}}onError(e,t){return n=>{if(n.message+=`
173
+ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+Ao(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},Yi=new J$;function Ut(e,t){return Yi.parse(e,t)}Ut.options=Ut.setOptions=function(e){return Yi.setOptions(e),Ut.defaults=Yi.defaults,Sb(Ut.defaults),Ut};Ut.getDefaults=Ch;Ut.defaults=ts;function eM(...e){return Yi.use(...e),Ut.defaults=Yi.defaults,Sb(Ut.defaults),Ut}Ut.use=eM;Ut.walkTokens=function(e,t){return Yi.walkTokens(e,t)};Ut.parseInline=Yi.parseInline;Ut.Parser=ko;Ut.parser=ko.parse;Ut.Renderer=du;Ut.TextRenderer=Mh;Ut.Lexer=go;Ut.lexer=go.lex;Ut.Tokenizer=uu;Ut.Hooks=Ba;Ut.parse=Ut;Ut.options;Ut.setOptions;Ut.walkTokens;Ut.parseInline;ko.parse;go.lex;function Mb(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 i of n.split("/"))if(!(i===""||i==="."))if(i===".."){if(!r.length)return null;r.pop()}else r.push(decodeURIComponent(i));return r.length?r.join("/"):null}const tM=e=>e.slice(0,Math.max(0,e.lastIndexOf("/")));function Pb(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 i=n.match(/:(\d+)(?::\d+)?$/);i&&(n=n.slice(0,i.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(k=>k===".."))return null;if(l)return{path:c,folder:!0};const d=(r==null?void 0:r[1])??(i==null?void 0:i[1]),g=d?Number.parseInt(d,10):void 0;return g&&g>0?{path:c,line:g}:{path:c}}function nM(e){if(!e.startsWith("/")||e.startsWith("//"))return null;try{return decodeURIComponent(e)}catch{return null}}function rM(e){if(e.header.some(n=>n.text.trim()))return!1;let t="";for(const n of e.rows){let r="";for(const i of n)r+=this.tablecell(i);t+=this.tablerow({text:r})}return`<table>
174
+ <tbody>${t}</tbody></table>
175
+ `}function oM(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 i={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,i]};i.contains.push(c);const d={match:/\\"/},g={className:"string",begin:/'/,end:/'/},k={match:/\\'/},p={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},h=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],v=e.SHEBANG({binary:`(${h.join("|")})`,relevance:10}),b={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"],j={match:/(\/[a-z._-]+)+/},x=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],H=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],B=["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"],re=["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,...H,"set","shopt",...B,...re]},contains:[v,e.SHEBANG(),b,p,a,l,j,c,d,g,k,n]}}const iM=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_-]*/}}),sM=["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"],aM=["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"],lM=[...sM,...aM],cM=["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(),uM=["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(),dM=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),fM=["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 pM(e){const t=e.regex,n=iM(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},i="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:":("+uM.join("|")+")"},{begin:":(:)?("+dM.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+fM.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:i,attribute:cM.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...c,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+lM.join("|")+")\\b"}]}}function hM(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 mM(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 i={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,i,l,n,"self"],relevance:0},d=/[A-Za-z0-9_-]+/,g=/"(\\"|[^"])*"/,k=/'[^']*'/,p=t.either(d,g,k),h=t.concat(p,"(\\s*\\.\\s*",p,")*",t.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:h,className:"attr",starts:{end:/$/,contains:[r,c,a,i,l,n]}}]}}const yv="[A-Za-z$_][0-9A-Za-z$_]*",gM=["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"],kM=["true","false","null","undefined","NaN","Infinity"],Lb=["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"],Db=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],zb=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],yM=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],vM=[].concat(zb,Lb,Db);function wM(e){const t=e.regex,n=(M,{after:G})=>{const ne="</"+M[0].slice(1);return M.input.indexOf(ne,G)!==-1},r=yv,i={begin:"<>",end:"</>"},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(M,G)=>{const ne=M[0].length+M.index,O=M.input[ne];if(O==="<"||O===","){G.ignoreMatch();return}O===">"&&(n(M,{after:ne})||G.ignoreMatch());let ee;const D=M.input.substring(ne);if(ee=D.match(/^\s*=/)){G.ignoreMatch();return}if((ee=D.match(/^\s+extends\s+/))&&ee.index===0){G.ignoreMatch();return}}},c={$pattern:yv,keyword:gM,literal:kM,built_in:vM,"variable.language":yM},d="[0-9](_?[0-9])*",g=`\\.(${d})`,k="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",p={className:"number",variants:[{begin:`(\\b(${k})((${g})|\\.)?|(${g}))[eE][+-]?(${d})\\b`},{begin:`\\b(${k})\\b((${g})\\b|\\.)?|(${g})\\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},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},v={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},b={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"css"}},_={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},E={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,h]},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]},H=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,v,b,_,E,{match:/\$\d+/},p];h.contains=H.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(H)});const B=[].concat(x,h.contains),re=B.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(B)}]),F={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:re},C={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"}}]},L={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:{_:[...Lb,...Db]}},I={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},Z={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[F],illegal:/%/},V={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function K(M){return t.concat("(?!",M.join("|"),")")}const le={match:t.concat(/\b/,K([...zb,"super","import","await"].map(M=>`${M}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},de={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},Q={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},F]},ce="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",R={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ce)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[F]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:re,CLASS_REFERENCE:L},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),I,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,v,b,_,E,x,{match:/\$\d+/},p,L,{scope:"attr",match:r+t.lookahead(":"),relevance:0},R,{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:ce,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:re}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.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"]}]}]},Z,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[F,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},de,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[F]},le,V,C,Q,{match:/\$[(.]/}]}}const bM="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",xM={scope:"number",match:bM,relevance:0};function _M(e){const t={className:"attr",begin:/(("(\\.|[^\\"\r\n])*")|('(\\.|[^\\'\r\n])*'))(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],i={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,i,xM,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function EM(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={match:/^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/},i={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+.-]*/,d={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}]},g={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},k={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},p=e.inherit(g,{contains:[]}),h=e.inherit(k,{contains:[]});g.contains.push(h),k.contains.push(p);let v=[n,d];return[g,k,p,h].forEach(j=>{j.contains=j.contains.concat(v)}),v=v.concat(g,k),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:v},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:v}]}]},n,a,r,g,k,{className:"quote",begin:"^>\\s+",contains:v,end:"$"},i,d,l,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function SM(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"]},d={className:"meta",begin:/^(>>>|\.\.\.) /},g={className:"subst",begin:/\{/,end:/\}/,keywords:c,illegal:/#/},k={begin:/\{\{/,relevance:0},p={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,d],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,d],relevance:10},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,d,k,g]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,d,k,g]},{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,k,g]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,k,g]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},h="[0-9](_?[0-9])*",v=`(\\b(${h}))?\\.(${h})|\\b(${h})\\.`,b=`\\b|${r.join("|")}`,_={className:"number",relevance:0,variants:[{begin:`(\\b(${h})|(${v}))[eE][+-]?(${h})[jJ]?(?=${b})`},{begin:`(${v})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${b})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${b})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${b})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${b})`},{begin:`\\b(${h})[jJ](?=${b})`}]},E={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:c,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},j={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:["self",d,_,p,e.HASH_COMMENT_MODE]}]};return g.contains=[p,_,d],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:c,illegal:/(<\/|\?)|=>/,contains:[d,_,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},p,E,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[j]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[_,j,p]}]}}function NM(e){const t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),i=t.concat(n,e.IDENT_RE),a={scope:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!(?:let|for|while|if|else|match)\b)/,i,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"],d=["true","false","Some","None","Ok","Err"],g=["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!"],k=["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:k,keyword:c,literal:d,built_in:g},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:g,type:k}},{scope:"punctuation",begin:"->"},a]}}const fu="[A-Za-z$_][0-9A-Za-z$_]*",Fb=["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"],Bb=["true","false","null","undefined","NaN","Infinity"],Ub=["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"],Hb=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Zb=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Wb=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],Kb=[].concat(Zb,Ub,Hb);function TM(e){const t=e.regex,n=(M,{after:G})=>{const ne="</"+M[0].slice(1);return M.input.indexOf(ne,G)!==-1},r=fu,i={begin:"<>",end:"</>"},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(M,G)=>{const ne=M[0].length+M.index,O=M.input[ne];if(O==="<"||O===","){G.ignoreMatch();return}O===">"&&(n(M,{after:ne})||G.ignoreMatch());let ee;const D=M.input.substring(ne);if(ee=D.match(/^\s*=/)){G.ignoreMatch();return}if((ee=D.match(/^\s+extends\s+/))&&ee.index===0){G.ignoreMatch();return}}},c={$pattern:fu,keyword:Fb,literal:Bb,built_in:Kb,"variable.language":Wb},d="[0-9](_?[0-9])*",g=`\\.(${d})`,k="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",p={className:"number",variants:[{begin:`(\\b(${k})((${g})|\\.)?|(${g}))[eE][+-]?(${d})\\b`},{begin:`\\b(${k})\\b((${g})\\b|\\.)?|(${g})\\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},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},v={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},b={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"css"}},_={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},E={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,h]},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]},H=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,v,b,_,E,{match:/\$\d+/},p];h.contains=H.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(H)});const B=[].concat(x,h.contains),re=B.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(B)}]),F={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:re},C={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"}}]},L={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:{_:[...Ub,...Hb]}},I={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},Z={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[F],illegal:/%/},V={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function K(M){return t.concat("(?!",M.join("|"),")")}const le={match:t.concat(/\b/,K([...Zb,"super","import","await"].map(M=>`${M}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},de={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},Q={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},F]},ce="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",R={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ce)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[F]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:re,CLASS_REFERENCE:L},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),I,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,v,b,_,E,x,{match:/\$\d+/},p,L,{scope:"attr",match:r+t.lookahead(":"),relevance:0},R,{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:ce,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:re}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.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"]}]}]},Z,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[F,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},de,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[F]},le,V,C,Q,{match:/\$[(.]/}]}}function CM(e){const t=e.regex,n=TM(e),r=fu,i=["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:i},contains:[n.exports.CLASS_REFERENCE]},c={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},d=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],g={$pattern:fu,keyword:Fb.concat(d),literal:Bb,built_in:Kb.concat(i),"variable.language":Wb},k={className:"meta",begin:"@"+r},p=(_,E,j)=>{const x=_.contains.findIndex(H=>H.label===E);if(x===-1)throw new Error("can not find mode to replace");_.contains.splice(x,1,j)};Object.assign(n.keywords,g),n.exports.PARAMS_CONTAINS.push(k);const h=n.contains.find(_=>_.scope==="attr"),v=Object.assign({},h,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,h,v]),n.contains=n.contains.concat([k,a,l,v]),p(n,"shebang",e.SHEBANG()),p(n,"use_strict",c);const b=n.contains.find(_=>_.label==="func.def");return b.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function jM(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,i={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"}),d=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),g={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:[i]},{begin:/'/,end:/'/,contains:[i]},{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,d,c,l,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[a,l,d,c]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},i,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[d]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[g],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:"css"}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[g],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:g}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function AM(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]|$)/}]},i={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,i]},c=e.inherit(l,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),h={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"},v={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},b={begin:/\{/,end:/\}/,contains:[v],illegal:"\\n",relevance:0},_={begin:"\\[",end:"\\]",contains:[v],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}},h,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},b,_,a,l],j=[...E];return j.pop(),j.push(c),v.contains=j,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:E}}var Jf,vv;function IM(){if(vv)return Jf;vv=1;function e(N){return N instanceof Map?N.clear=N.delete=N.set=function(){throw new Error("map is read-only")}:N instanceof Set&&(N.add=N.clear=N.delete=function(){throw new Error("set is read-only")}),Object.freeze(N),Object.getOwnPropertyNames(N).forEach(X=>{const me=N[X],xe=typeof me;(xe==="object"||xe==="function")&&!Object.isFrozen(me)&&e(me)}),N}class t{constructor(X){X.data===void 0&&(X.data={}),this.data=X.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(N){return N.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(N,...X){const me=Object.create(null);for(const xe in N)me[xe]=N[xe];return X.forEach(function(xe){for(const We in xe)me[We]=xe[We]}),me}const i="</span>",a=N=>!!N.scope,l=(N,{prefix:X})=>{if(N.startsWith("language:"))return N.replace("language:","language-");if(N.includes(".")){const me=N.split(".");return[`${X}${me.shift()}`,...me.map((xe,We)=>`${xe}${"_".repeat(We+1)}`)].join(" ")}return`${X}${N}`};class c{constructor(X,me){this.buffer="",this.classPrefix=me.classPrefix,X.walk(this)}addText(X){this.buffer+=n(X)}openNode(X){if(!a(X))return;const me=l(X.scope,{prefix:this.classPrefix});this.span(me)}closeNode(X){a(X)&&(this.buffer+=i)}value(){return this.buffer}span(X){this.buffer+=`<span class="${X}">`}}const d=(N={})=>{const X={children:[]};return Object.assign(X,N),X};class g{constructor(){this.rootNode=d(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(X){this.top.children.push(X)}openNode(X){const me=d({scope:X});this.add(me),this.stack.push(me)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(X){return this.constructor._walk(X,this.rootNode)}static _walk(X,me){return typeof me=="string"?X.addText(me):me.children&&(X.openNode(me),me.children.forEach(xe=>this._walk(X,xe)),X.closeNode(me)),X}static _collapse(X){typeof X!="string"&&X.children&&(X.children.every(me=>typeof me=="string")?X.children=[X.children.join("")]:X.children.forEach(me=>{g._collapse(me)}))}}class k extends g{constructor(X){super(),this.options=X}addText(X){X!==""&&this.add(X)}startScope(X){this.openNode(X)}endScope(){this.closeNode()}__addSublanguage(X,me){const xe=X.root;me&&(xe.scope=`language:${me}`),this.add(xe)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function p(N){return N?typeof N=="string"?N:N.source:null}function h(N){return _("(?=",N,")")}function v(N){return _("(?:",N,")*")}function b(N){return _("(?:",N,")?")}function _(...N){return N.map(me=>p(me)).join("")}function E(N){const X=N[N.length-1];return typeof X=="object"&&X.constructor===Object?(N.splice(N.length-1,1),X):{}}function j(...N){return"("+(E(N).capture?"":"?:")+N.map(xe=>p(xe)).join("|")+")"}function x(N){return new RegExp(N.toString()+"|").exec("").length-1}function H(N,X){const me=N&&N.exec(X);return me&&me.index===0}const B=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function re(N,{joinWith:X}){let me=0;return N.map(xe=>{me+=1;const We=me;let gt=p(xe),Ce="";for(;gt.length>0;){const ge=B.exec(gt);if(!ge){Ce+=gt;break}Ce+=gt.substring(0,ge.index),gt=gt.substring(ge.index+ge[0].length),ge[0][0]==="\\"&&ge[1]?Ce+="\\"+String(Number(ge[1])+We):(Ce+=ge[0],ge[0]==="("&&me++)}return Ce}).map(xe=>`(${xe})`).join(X)}const F=/\b\B/,C="[a-zA-Z]\\w*",L="[a-zA-Z_]\\w*",I="\\b\\d+(\\.\\d+)?",Z="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",V="\\b(0b[01]+)",K="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",le=(N={})=>{const X=/^#![ ]*\//;return N.binary&&(N.begin=_(X,/.*\b/,N.binary,/\b.*/)),r({scope:"meta",begin:X,end:/$/,relevance:0,"on:begin":(me,xe)=>{me.index!==0&&xe.ignoreMatch()}},N)},de={begin:"\\\\[\\s\\S]",relevance:0},Q={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[de]},ce={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[de]},R={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/},M=function(N,X,me={}){const xe=r({scope:"comment",begin:N,end:X,contains:[]},me);xe.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const We=j("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return xe.contains.push({begin:_(/[ ]+/,"(",We,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),xe},G=M("//","$"),ne=M("/\\*","\\*/"),O=M("#","$"),ee={scope:"number",begin:I,relevance:0},D={scope:"number",begin:Z,relevance:0},q={scope:"number",begin:V,relevance:0},Te={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[de,{begin:/\[/,end:/\]/,relevance:0,contains:[de]}]},Ne={scope:"title",begin:C,relevance:0},je={scope:"title",begin:L,relevance:0},Re={begin:"\\.\\s*"+L,relevance:0};var st=Object.freeze({__proto__:null,APOS_STRING_MODE:Q,BACKSLASH_ESCAPE:de,BINARY_NUMBER_MODE:q,BINARY_NUMBER_RE:V,COMMENT:M,C_BLOCK_COMMENT_MODE:ne,C_LINE_COMMENT_MODE:G,C_NUMBER_MODE:D,C_NUMBER_RE:Z,END_SAME_AS_BEGIN:function(N){return Object.assign(N,{"on:begin":(X,me)=>{me.data._beginMatch=X[1]},"on:end":(X,me)=>{me.data._beginMatch!==X[1]&&me.ignoreMatch()}})},HASH_COMMENT_MODE:O,IDENT_RE:C,MATCH_NOTHING_RE:F,METHOD_GUARD:Re,NUMBER_MODE:ee,NUMBER_RE:I,PHRASAL_WORDS_MODE:R,QUOTE_STRING_MODE:ce,REGEXP_MODE:Te,RE_STARTERS_RE:K,SHEBANG:le,TITLE_MODE:Ne,UNDERSCORE_IDENT_RE:L,UNDERSCORE_TITLE_MODE:je});function Ee(N,X){N.input[N.index-1]==="."&&X.ignoreMatch()}function Tt(N,X){N.className!==void 0&&(N.scope=N.className,delete N.className)}function zt(N,X){X&&N.beginKeywords&&(N.begin="\\b("+N.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",N.__beforeBegin=Ee,N.keywords=N.keywords||N.beginKeywords,delete N.beginKeywords,N.relevance===void 0&&(N.relevance=0))}function Xe(N,X){Array.isArray(N.illegal)&&(N.illegal=j(...N.illegal))}function pt(N,X){if(N.match){if(N.begin||N.end)throw new Error("begin & end are not supported with match");N.begin=N.match,delete N.match}}function ht(N,X){N.relevance===void 0&&(N.relevance=1)}const wn=(N,X)=>{if(!N.beforeMatch)return;if(N.starts)throw new Error("beforeMatch cannot be used with starts");const me=Object.assign({},N);Object.keys(N).forEach(xe=>{delete N[xe]}),N.keywords=me.keywords,N.begin=_(me.beforeMatch,h(me.begin)),N.starts={relevance:0,contains:[Object.assign(me,{endsParent:!0})]},N.relevance=0,delete me.beforeMatch},jt=["of","and","for","in","not","or","if","then","parent","list","value"],Ft="keyword";function te(N,X,me=Ft){const xe=Object.create(null);return typeof N=="string"?We(me,N.split(" ")):Array.isArray(N)?We(me,N):Object.keys(N).forEach(function(gt){Object.assign(xe,te(N[gt],X,gt))}),xe;function We(gt,Ce){X&&(Ce=Ce.map(ge=>ge.toLowerCase())),Ce.forEach(function(ge){const De=ge.split("|");xe[De[0]]=[gt,pe(De[0],De[1])]})}}function pe(N,X){return X?Number(X):rt(N)?0:1}function rt(N){return jt.includes(N.toLowerCase())}const at={},ut=N=>{console.error(N)},tn=(N,...X)=>{console.log(`WARN: ${N}`,...X)},Kt=(N,X)=>{at[`${N}/${X}`]||(console.log(`Deprecated as of ${N}. ${X}`),at[`${N}/${X}`]=!0)},tt=new Error;function qe(N,X,{key:me}){let xe=0;const We=N[me],gt={},Ce={};for(let ge=1;ge<=X.length;ge++)Ce[ge+xe]=We[ge],gt[ge+xe]=!0,xe+=x(X[ge-1]);N[me]=Ce,N[me]._emit=gt,N[me]._multi=!0}function nn(N){if(Array.isArray(N.begin)){if(N.skip||N.excludeBegin||N.returnBegin)throw ut("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),tt;if(typeof N.beginScope!="object"||N.beginScope===null)throw ut("beginScope must be object"),tt;qe(N,N.begin,{key:"beginScope"}),N.begin=re(N.begin,{joinWith:""})}}function ie(N){if(Array.isArray(N.end)){if(N.skip||N.excludeEnd||N.returnEnd)throw ut("skip, excludeEnd, returnEnd not compatible with endScope: {}"),tt;if(typeof N.endScope!="object"||N.endScope===null)throw ut("endScope must be object"),tt;qe(N,N.end,{key:"endScope"}),N.end=re(N.end,{joinWith:""})}}function he(N){N.scope&&typeof N.scope=="object"&&N.scope!==null&&(N.beginScope=N.scope,delete N.scope)}function lt(N){he(N),typeof N.beginScope=="string"&&(N.beginScope={_wrap:N.beginScope}),typeof N.endScope=="string"&&(N.endScope={_wrap:N.endScope}),nn(N),ie(N)}function At(N){function X(Ce,ge){return new RegExp(p(Ce),"m"+(N.case_insensitive?"i":"")+(N.unicodeRegex?"u":"")+(ge?"g":""))}class me{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(ge,De){De.position=this.position++,this.matchIndexes[this.matchAt]=De,this.regexes.push([De,ge]),this.matchAt+=x(ge)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const ge=this.regexes.map(De=>De[1]);this.matcherRe=X(re(ge,{joinWith:"|"}),!0),this.lastIndex=0}exec(ge){this.matcherRe.lastIndex=this.lastIndex;const De=this.matcherRe.exec(ge);if(!De)return null;const Ue=De.findIndex((Gn,xn)=>xn>0&&Gn!==void 0),kt=this.matchIndexes[Ue];return De.splice(0,Ue),Object.assign(De,kt)}}class xe{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(ge){if(this.multiRegexes[ge])return this.multiRegexes[ge];const De=new me;return this.rules.slice(ge).forEach(([Ue,kt])=>De.addRule(Ue,kt)),De.compile(),this.multiRegexes[ge]=De,De}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(ge,De){this.rules.push([ge,De]),De.type==="begin"&&this.count++}exec(ge){const De=this.getMatcher(this.regexIndex);De.lastIndex=this.lastIndex;let Ue=De.exec(ge);if(this.resumingScanAtSamePosition()&&!(Ue&&Ue.index===this.lastIndex)){const kt=this.getMatcher(0);kt.lastIndex=this.lastIndex+1,Ue=kt.exec(ge)}return Ue&&(this.regexIndex+=Ue.position+1,this.regexIndex===this.count&&this.considerAll()),Ue}}function We(Ce){const ge=new xe;return Ce.contains.forEach(De=>ge.addRule(De.begin,{rule:De,type:"begin"})),Ce.terminatorEnd&&ge.addRule(Ce.terminatorEnd,{type:"end"}),Ce.illegal&&ge.addRule(Ce.illegal,{type:"illegal"}),ge}function gt(Ce,ge){const De=Ce;if(Ce.isCompiled)return De;[Tt,pt,lt,wn].forEach(kt=>kt(Ce,ge)),N.compilerExtensions.forEach(kt=>kt(Ce,ge)),Ce.__beforeBegin=null,[zt,Xe,ht].forEach(kt=>kt(Ce,ge)),Ce.isCompiled=!0;let Ue=null;return typeof Ce.keywords=="object"&&Ce.keywords.$pattern&&(Ce.keywords=Object.assign({},Ce.keywords),Ue=Ce.keywords.$pattern,delete Ce.keywords.$pattern),Ue=Ue||/\w+/,Ce.keywords&&(Ce.keywords=te(Ce.keywords,N.case_insensitive)),De.keywordPatternRe=X(Ue,!0),ge&&(Ce.begin||(Ce.begin=/\B|\b/),De.beginRe=X(De.begin),!Ce.end&&!Ce.endsWithParent&&(Ce.end=/\B|\b/),Ce.end&&(De.endRe=X(De.end)),De.terminatorEnd=p(De.end)||"",Ce.endsWithParent&&ge.terminatorEnd&&(De.terminatorEnd+=(Ce.end?"|":"")+ge.terminatorEnd)),Ce.illegal&&(De.illegalRe=X(Ce.illegal)),Ce.contains||(Ce.contains=[]),Ce.contains=[].concat(...Ce.contains.map(function(kt){return Qt(kt==="self"?Ce:kt)})),Ce.contains.forEach(function(kt){gt(kt,De)}),Ce.starts&&gt(Ce.starts,ge),De.matcher=We(De),De}if(N.compilerExtensions||(N.compilerExtensions=[]),N.contains&&N.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return N.classNameAliases=r(N.classNameAliases||{}),gt(N)}function bt(N){return N?N.endsWithParent||bt(N.starts):!1}function Qt(N){return N.variants&&!N.cachedVariants&&(N.cachedVariants=N.variants.map(function(X){return r(N,{variants:null},X)})),N.cachedVariants?N.cachedVariants:bt(N)?r(N,{starts:N.starts?r(N.starts):null}):Object.isFrozen(N)?r(N):N}var vr="11.11.2";class bn extends Error{constructor(X,me){super(X),this.name="HTMLInjectionError",this.html=me}}const Tn=n,Kn=r,lr=Symbol("nomatch"),Pt=7,xt=function(N){const X=Object.create(null),me=Object.create(null),xe=[];let We=!0;const gt="Could not find the language '{}', did you forget to load/include a language module?",Ce={disableAutodetect:!0,name:"Plain text",contains:[]};let ge={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:k};function De(we){return ge.noHighlightRe.test(we)}function Ue(we){let Ae=we.className+" ";Ae+=we.parentNode?we.parentNode.className:"";const ot=ge.languageDetectRe.exec(Ae);if(ot){const it=Dn(ot[1]);return it||(tn(gt.replace("{}",ot[1])),tn("Falling back to no-highlight mode for this block.",we)),it?ot[1]:"no-highlight"}return Ae.split(/\s+/).find(it=>De(it)||Dn(it))}function kt(we,Ae,ot){let it="",Vt="";typeof Ae=="object"?(it=we,ot=Ae.ignoreIllegals,Vt=Ae.language):(Kt("10.7.0","highlight(lang, code, ...args) has been deprecated."),Kt("10.7.0",`Please use highlight(code, options) instead.
176
+ https://github.com/highlightjs/highlight.js/issues/2277`),Vt=we,it=Ae),ot===void 0&&(ot=!0);const Bt={code:it,language:Vt};kn("before:highlight",Bt);const jn=Bt.result?Bt.result:Gn(Bt.language,Bt.code,ot);return jn.code=Bt.code,kn("after:highlight",jn),jn}function Gn(we,Ae,ot,it){const Vt=Object.create(null);function Bt($,J){return $.keywords[J]}function jn(){if(!ze.keywords){Xt.addText(Nt);return}let $=0;ze.keywordPatternRe.lastIndex=0;let J=ze.keywordPatternRe.exec(Nt),ue="";for(;J;){ue+=Nt.substring($,J.index);const be=Fn.case_insensitive?J[0].toLowerCase():J[0],Ie=Bt(ze,be);if(Ie){const[et,U]=Ie;if(Xt.addText(ue),ue="",Vt[be]=(Vt[be]||0)+1,Vt[be]<=Pt&&(Er+=U),et.startsWith("_"))ue+=J[0];else{const Me=Fn.classNameAliases[et]||et;mn(J[0],Me)}}else ue+=J[0];$=ze.keywordPatternRe.lastIndex,J=ze.keywordPatternRe.exec(Nt)}ue+=Nt.substring($),Xt.addText(ue)}function Mr(){if(Nt==="")return;let $=null;if(typeof ze.subLanguage=="string"){if(!X[ze.subLanguage]){Xt.addText(Nt);return}$=Gn(ze.subLanguage,Nt,!0,Ro[ze.subLanguage]),Ro[ze.subLanguage]=$._top}else $=Cn(Nt,ze.subLanguage.length?ze.subLanguage:null);ze.relevance>0&&(Er+=$.relevance),Xt.__addSublanguage($._emitter,$.language)}function cn(){ze.subLanguage!=null?Mr():jn(),Nt=""}function mn($,J){$!==""&&(Xt.startScope(J),Xt.addText($),Xt.endScope())}function br($,J){let ue=1;const be=J.length-1;for(;ue<=be;){if(!$._emit[ue]){ue++;continue}const Ie=Fn.classNameAliases[$[ue]]||$[ue],et=J[ue];Ie?mn(et,Ie):(Nt=et,jn(),Nt=""),ue++}}function zn($,J){return $.scope&&typeof $.scope=="string"&&Xt.openNode(Fn.classNameAliases[$.scope]||$.scope),$.beginScope&&($.beginScope._wrap?(mn(Nt,Fn.classNameAliases[$.beginScope._wrap]||$.beginScope._wrap),Nt=""):$.beginScope._multi&&(br($.beginScope,J),Nt="")),ze=Object.create($,{parent:{value:ze}}),ze}function pr($,J,ue){let be=H($.endRe,ue);if(be){if($["on:end"]){const Ie=new t($);$["on:end"](J,Ie),Ie.isMatchIgnored&&(be=!1)}if(be){for(;$.endsParent&&$.parent;)$=$.parent;return $}}if($.endsWithParent)return pr($.parent,J,ue)}function Xn($){return ze.matcher.regexIndex===0?(Nt+=$[0],1):(A=!0,0)}function yn($){const J=$[0],ue=$.rule,be=new t(ue),Ie=[ue.__beforeBegin,ue["on:begin"]];for(const et of Ie)if(et&&(et($,be),be.isMatchIgnored))return Xn(J);return ue.skip?Nt+=J:(ue.excludeBegin&&(Nt+=J),cn(),!ue.returnBegin&&!ue.excludeBegin&&(Nt=J)),zn(ue,$),ue.returnBegin?0:J.length}function xr($){const J=$[0],ue=Ae.substring($.index),be=pr(ze,$,ue);if(!be)return lr;const Ie=ze;ze.endScope&&ze.endScope._wrap?(cn(),mn(J,ze.endScope._wrap)):ze.endScope&&ze.endScope._multi?(cn(),br(ze.endScope,$)):Ie.skip?Nt+=J:(Ie.returnEnd||Ie.excludeEnd||(Nt+=J),cn(),Ie.excludeEnd&&(Nt=J));do ze.scope&&Xt.closeNode(),!ze.skip&&!ze.subLanguage&&(Er+=ze.relevance),ze=ze.parent;while(ze!==be.parent);return be.starts&&zn(be.starts,$),Ie.returnEnd?0:J.length}function Ti(){const $=[];for(let J=ze;J!==Fn;J=J.parent)J.scope&&$.unshift(J.scope);$.forEach(J=>Xt.openNode(J))}let _r={};function Jn($,J){const ue=J&&J[0];if(Nt+=$,ue==null)return cn(),0;if(_r.type==="begin"&&J.type==="end"&&_r.index===J.index&&ue===""){if(Nt+=Ae.slice(J.index,J.index+1),!We){const be=new Error(`0 width match regex (${we})`);throw be.languageName=we,be.badRule=_r.rule,be}return 1}if(_r=J,J.type==="begin")return yn(J);if(J.type==="illegal"&&!ot){const be=new Error('Illegal lexeme "'+ue+'" for mode "'+(ze.scope||"<unnamed>")+'"');throw be.mode=ze,be}else if(J.type==="end"){const be=xr(J);if(be!==lr)return be}if(J.type==="illegal"&&ue==="")return J.index===Ae.length||(Nt+=`
177
+ `),1;if(ye>1e5&&ye>J.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Nt+=ue,ue.length}const Fn=Dn(we);if(!Fn)throw ut(gt.replace("{}",we)),new Error('Unknown language: "'+we+'"');const Eo=At(Fn);let vt="",ze=it||Eo;const Ro={},Xt=new ge.__emitter(ge);Ti();let Nt="",Er=0,Bn=0,ye=0,A=!1;try{if(Fn.__emitTokens)Fn.__emitTokens(Ae,Xt);else{for(ze.matcher.considerAll();;){ye++,A?A=!1:ze.matcher.considerAll(),ze.matcher.lastIndex=Bn;const $=ze.matcher.exec(Ae);if(!$)break;const J=Ae.substring(Bn,$.index),ue=Jn(J,$);Bn=$.index+ue}Jn(Ae.substring(Bn))}return Xt.finalize(),vt=Xt.toHTML(),{language:we,value:vt,relevance:Er,illegal:!1,_emitter:Xt,_top:ze}}catch($){if($.message&&$.message.includes("Illegal"))return{language:we,value:Tn(Ae),illegal:!0,relevance:0,_illegalBy:{message:$.message,index:Bn,context:Ae.slice(Bn-100,Bn+100),mode:$.mode,resultSoFar:vt},_emitter:Xt};if(We)return{language:we,value:Tn(Ae),illegal:!1,relevance:0,errorRaised:$,_emitter:Xt,_top:ze};throw $}}function xn(we){const Ae={value:Tn(we),illegal:!1,relevance:0,_top:Ce,_emitter:new ge.__emitter(ge)};return Ae._emitter.addText(we),Ae}function Cn(we,Ae){Ae=Ae||ge.languages||Object.keys(X);const ot=xn(we),it=Ae.filter(Dn).filter(so).map(cn=>Gn(cn,we,!1));it.unshift(ot);const Vt=it.sort((cn,mn)=>{if(cn.relevance!==mn.relevance)return mn.relevance-cn.relevance;if(cn.language&&mn.language){if(Dn(cn.language).supersetOf===mn.language)return 1;if(Dn(mn.language).supersetOf===cn.language)return-1}return 0}),[Bt,jn]=Vt,Mr=Bt;return Mr.secondBest=jn,Mr}function cr(we,Ae,ot){const it=Ae&&me[Ae]||ot;we.classList.add("hljs"),we.classList.add(`language-${it}`)}function ur(we){let Ae=null;const ot=Ue(we);if(De(ot))return;if(kn("before:highlightElement",{el:we,language:ot}),we.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",we);return}if(we.children.length>0&&(ge.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(we)),ge.throwUnescapedHTML))throw new bn("One of your code blocks includes unescaped HTML.",we.innerHTML);Ae=we;const it=Ae.textContent,Vt=ot?kt(it,{language:ot,ignoreIllegals:!0}):Cn(it);we.innerHTML=Vt.value,we.dataset.highlighted="yes",cr(we,ot,Vt.language),we.result={language:Vt.language,re:Vt.relevance,relevance:Vt.relevance},Vt.secondBest&&(we.secondBest={language:Vt.secondBest.language,relevance:Vt.secondBest.relevance}),kn("after:highlightElement",{el:we,result:Vt,text:it})}function io(we){ge=Kn(ge,we)}const wr=()=>{Qn(),Kt("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function yt(){Qn(),Kt("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Ot=!1;function Qn(){function we(){Qn()}if(document.readyState==="loading"){Ot||window.addEventListener("DOMContentLoaded",we,!1),Ot=!0;return}document.querySelectorAll(ge.cssSelector).forEach(ur)}function Gr(we,Ae){let ot=null;try{ot=Ae(N)}catch(it){if(ut("Language definition for '{}' could not be registered.".replace("{}",we)),We)ut(it);else throw it;ot=Ce}ot.name||(ot.name=we),X[we]=ot,ot.rawDefinition=Ae.bind(null,N),ot.aliases&&fr(ot.aliases,{languageName:we})}function bo(we){delete X[we];for(const Ae of Object.keys(me))me[Ae]===we&&delete me[Ae]}function dr(){return Object.keys(X)}function Dn(we){return we=(we||"").toLowerCase(),X[we]||X[me[we]]}function fr(we,{languageName:Ae}){typeof we=="string"&&(we=[we]),we.forEach(ot=>{me[ot.toLowerCase()]=Ae})}function so(we){const Ae=Dn(we);return Ae&&!Ae.disableAutodetect}function Gt(we){we["before:highlightBlock"]&&!we["before:highlightElement"]&&(we["before:highlightElement"]=Ae=>{we["before:highlightBlock"](Object.assign({block:Ae.el},Ae))}),we["after:highlightBlock"]&&!we["after:highlightElement"]&&(we["after:highlightElement"]=Ae=>{we["after:highlightBlock"](Object.assign({block:Ae.el},Ae))})}function xo(we){Gt(we),xe.push(we)}function _o(we){const Ae=xe.indexOf(we);Ae!==-1&&xe.splice(Ae,1)}function kn(we,Ae){const ot=we;xe.forEach(function(it){it[ot]&&it[ot](Ae)})}function Vr(we){return Kt("10.7.0","highlightBlock will be removed entirely in v12.0"),Kt("10.7.0","Please use highlightElement now."),ur(we)}Object.assign(N,{highlight:kt,highlightAuto:Cn,highlightAll:Qn,highlightElement:ur,highlightBlock:Vr,configure:io,initHighlighting:wr,initHighlightingOnLoad:yt,registerLanguage:Gr,unregisterLanguage:bo,listLanguages:dr,getLanguage:Dn,registerAliases:fr,autoDetection:so,inherit:Kn,addPlugin:xo,removePlugin:_o}),N.debugMode=function(){We=!1},N.safeMode=function(){We=!0},N.versionString=vr,N.regex={concat:_,lookahead:h,either:j,optional:b,anyNumberOfTimes:v};for(const we in st)typeof st[we]=="object"&&e(st[we]);return Object.assign(N,st),N},hn=xt({});return hn.newInstance=()=>xt({}),Jf=hn,hn.HighlightJS=hn,hn.default=hn,Jf}var RM=IM();const OM=Yv(RM),wv={},$M="hljs-";function MM(e){const t=OM.newInstance();return e&&a(e),{highlight:n,highlightAuto:r,listLanguages:i,register:a,registerAlias:l,registered:c};function n(d,g,k){const p=k||wv,h=typeof p.prefix=="string"?p.prefix:$M;if(!t.getLanguage(d))throw new Error("Unknown language: `"+d+"` is not registered");t.configure({__emitter:PM,classPrefix:h});const v=t.highlight(g,{ignoreIllegals:!0,language:d});if(v.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:v.errorRaised});const b=v._emitter.root,_=b.data;return _.language=v.language,_.relevance=v.relevance,b}function r(d,g){const p=(g||wv).subset||i();let h=-1,v=0,b;for(;++h<p.length;){const _=p[h];if(!t.getLanguage(_))continue;const E=n(_,d,g);E.data&&E.data.relevance!==void 0&&E.data.relevance>v&&(v=E.data.relevance,b=E)}return b||{type:"root",children:[],data:{language:void 0,relevance:v}}}function i(){return t.listLanguages()}function a(d,g){if(typeof d=="string")t.registerLanguage(d,g);else{let k;for(k in d)Object.hasOwn(d,k)&&t.registerLanguage(k,d[k])}}function l(d,g){if(typeof d=="string")t.registerAliases(typeof g=="string"?g:[...g],{languageName:d});else{let k;for(k in d)if(Object.hasOwn(d,k)){const p=d[k];t.registerAliases(typeof p=="string"?p:[...p],{languageName:k})}}}function c(d){return!!t.getLanguage(d)}}class PM{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],i=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:i}):r.children.push(...i)}openNode(t){const n=this,r=t.split(".").map(function(l,c){return c?l+"_".repeat(c):n.options.classPrefix+l}),i=this.stack[this.stack.length-1],a={type:"element",tagName:"span",properties:{className:r},children:[]};i.children.push(a),this.stack.push(a)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const Gb=MM({bash:oM,css:pM,go:hM,ini:mM,javascript:wM,json:_M,markdown:EM,python:SM,rust:NM,typescript:CM,xml:jM,yaml:AM}),bv={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 Vb(e,t){const n=e&&(bv[e]??(Gb.registered(e)?e:null));if(n)return n;const r=t.lastIndexOf("."),i=r<0?"":t.slice(r+1).toLowerCase();return(i?bv[i]:null)??null}const LM=/^(?:diff --git a\/\S+ b\/(\S+)|\+\+\+ (?:b\/)?(\S+))$/gm;function DM(e){const t=new Set;for(const n of e.matchAll(LM)){const r=n[1]??n[2]??"";r&&r!=="/dev/null"&&t.add(r)}return t.size===1?[...t][0]:""}const zM={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 qb(e,t){const n=[[]],r=(a,l)=>{const c=a.split(`
178
+ `);for(const[d,g]of c.entries()){if(d>0&&n.push([]),!g)continue;const k=n[n.length-1],p=k[k.length-1];p&&p.scope===l?p.text+=g:k.push({text:g,scope:l})}},i=(a,l)=>{for(const c of a)c.type==="text"?r(c.value,l):c.type==="element"&&i(c.children,FM(c)??l)};try{i(Gb.highlight(t,e).children,"")}catch{return e.split(`
179
+ `).map(a=>a?[{text:a,scope:""}]:[])}return n}function FM(e){var r;const t=((r=e.properties)==null?void 0:r.className)??[];let n=null;for(const i of t){const a=zM[i.startsWith("hljs-")?i.slice(5):i];a&&(n=a)}return n}const xv=/^\d+\t/;function Yb(e,t){if(!t)return[];const n=e.split(`
180
+ `),r=xv.test(n[0]??""),i=r?n.map(l=>{var c;return((c=xv.exec(l))==null?void 0:c[0])??""}):[],a=r?n.map((l,c)=>l.slice(i[c].length)).join(`
181
+ `):e;return qb(a,t).map((l,c)=>{const d=l.map(k=>({text:k.text,changed:!1,scope:k.scope})),g=i[c];return g?[{text:g,changed:!1,scope:""},...d]:d})}function BM(e,t){var r;const n=new Array(e.length);if(t){let i=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"||(UM(e,i,a,t,n),i=a+1)}}return e.map((i,a)=>HM(i.spans,n[a],i.text))}function UM(e,t,n,r,i){var a,l;for(const c of["del","add"]){const d=[];for(let p=t;p<n;p++){const h=(a=e[p])==null?void 0:a.kind;(h===""||h===c)&&d.push(p)}if(d.length===0)continue;const g=d.map(p=>{var h;return((h=e[p])==null?void 0:h.text)??""}).join(`
182
+ `),k=qb(g,r);for(const[p,h]of d.entries())(c==="add"||((l=e[h])==null?void 0:l.kind)==="del")&&(i[h]=k[p])}}function HM(e,t,n){if(!(e!=null&&e.length)&&!(t!=null&&t.length))return n?[{text:n,changed:!1,scope:""}]:[];const r=[],i=e!=null&&e.length?e:[{text:n,changed:!1}],a=t!=null&&t.length?t:[{text:n,scope:""}];let l=0,c=0,d=0,g=0;for(;l<i.length&&c<a.length;){const k=i[l],p=a[c],h=Math.min(k.text.length-d,p.text.length-g);if(h>0){const v={text:k.text.slice(d,d+h),changed:k.changed,scope:p.scope},b=r[r.length-1];b&&b.changed===v.changed&&b.scope===v.scope?b.text+=v.text:r.push(v)}d+=h,g+=h,d>=k.text.length&&(l++,d=0),g>=p.text.length&&(c++,g=0)}return r}Ut.use({renderer:{code({text:e,lang:t}){const n=Vb((t??"").trim().toLowerCase().split(/\s+/)[0]??"","");return n?`<pre><code>${Yb(e,n).map(i=>i.map(a=>a.scope?`<span class="sy-${a.scope}">${_v(a.text)}</span>`:_v(a.text)).join("")).join(`
183
+ `)}</code></pre>
184
+ `:!1},table:rM}});const _v=e=>e.replace(/[&<>]/g,t=>t==="&"?"&amp;":t==="<"?"&lt;":"&gt;"),Qb=r$(window);let Uo=null;Qb.addHook("afterSanitizeAttributes",e=>{var i;const t=e.tagName==="A"?e.getAttribute("href")??"":"";/^https?:/i.test(t)&&(e.setAttribute("target","_blank"),e.setAttribute("rel","noreferrer"));const n=Uo!=null&&Uo.fileRoot?Pb(Uo.fileRoot,t):null;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");else if(t){const a=nM(t);if(a&&(e.removeAttribute("href"),e.classList.add("path-text"),e.setAttribute("data-path",a),!(e.childNodes.length===1&&((i=e.firstElementChild)==null?void 0:i.tagName)==="CODE"))){const l=e.ownerDocument.createElement("code");l.append(...Array.from(e.childNodes)),e.append(l)}}const r=Uo==null?void 0:Uo.base;if(e.tagName==="IMG"&&r){const a=Mb(r.dir,e.getAttribute("src")??"");a&&e.setAttribute("src",H0(r.worktreeId,a,r.version))}});function Uc(e,t){Uo=t??null;try{return Qb.sanitize(Ut.parse(e,{async:!1}))}finally{Uo=null}}function Ph(e,t){var g,k,p;const[n,r]=T.useState(()=>Uc(e,t)),i=T.useRef(0),a=(g=t==null?void 0:t.base)==null?void 0:g.worktreeId,l=(k=t==null?void 0:t.base)==null?void 0:k.dir,c=(p=t==null?void 0:t.base)==null?void 0:p.version,d=t==null?void 0:t.fileRoot;return T.useEffect(()=>{const h=a!==void 0&&l!==void 0?{worktreeId:a,dir:l,version:c??null}:void 0,v=h||d?{base:h,fileRoot:d}:void 0,b=performance.now()-i.current;if(b>=100){i.current=performance.now(),r(Uc(e,v));return}const _=setTimeout(()=>{i.current=performance.now(),r(Uc(e,v))},100-b);return()=>clearTimeout(_)},[e,a,l,c,d]),n}function ZM(e){return!e||e===document.body?!1:e.closest(".monaco-editor, .xterm")?!0:(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&!e.closest(".chat-input")}function Xb(e,t){return ft([t],()=>{const n=requestAnimationFrame(()=>{var r;ZM(document.activeElement)||(r=e.current)==null||r.focus()});return()=>cancelAnimationFrame(n)}),n=>{n.relatedTarget||requestAnimationFrame(()=>{var r;document.activeElement===document.body&&((r=e.current)==null||r.focus())})}}function WM({item:e,worktreeId:t,rootRef:n}){return e.ask.kind==="question"?f.jsx(KM,{item:e,ask:e.ask,worktreeId:t,root:n}):f.jsx(VM,{item:e,ask:e.ask,worktreeId:t,root:n})}const Jb=e=>e.length===1&&e>="1"&&e<="9",Ua=e=>e.key==="Enter"||e.key==="NumpadEnter";function KM({item:e,ask:t,worktreeId:n,root:r}){const i=Xb(r,e.id),a=Ge(),l=Ve(),{message:c,questions:d}=t,g=It(n,"ask"),k=T.useMemo(()=>(g==null?void 0:g.id)===e.id?g:{id:e.id,draft:dO(d),current:0},[g,e.id,d]),{draft:p,current:h}=k,v=h===au(d),b=d[h],_=p[h],E=!!(b!=null&&b.multi),[j,x]=T.useState(()=>Is(b,_)),H=Xi(),B=T.useRef(null),re=(Q,ce)=>l({a:"ask-draft",id:n,ask:{id:e.id,draft:Q,current:ce}}),F=Q=>a==null?void 0:a.send({t:"agent-answer",worktreeId:n,askId:e.id,...Q?{answers:Q}:{}}),C=()=>{Ac(d,p)&&F(p)},L=Q=>{x(Is(d[Q],p[Q])),re(p,Q)},I=Q=>{b!=null&&b.note&&(re(pO(p,h,Q,E),h),requestAnimationFrame(()=>{var ce;return(ce=B.current)==null?void 0:ce.focus()}))},Z=Q=>{if(hO(b,Q))return x(Q),I(!0);const ce=b==null?void 0:b.options[Q];if(!b||!ce)return;const R=fO(p,h,ce.value,E);if(E){x(Q),re(R,h);return}const M=Gy(d,R,h);x(M.cursor),re(R,M.current),M.send&&Ac(d,R)&&F(R)},V=Q=>{var ce,R;if(Q.target instanceof HTMLTextAreaElement){if(Q.key==="Escape"||Q.key==="Tab"&&!Q.shiftKey){Q.preventDefault(),Q.stopPropagation();const M=Ky(p,h);M!==p&&(re(M,h),x(Is(b,M[h]))),(ce=r.current)==null||ce.focus()}else if(Ua(Q)&&(Q.metaKey||Q.ctrlKey))Q.preventDefault(),C();else if(Ua(Q)&&!Q.shiftKey){Q.preventDefault();const M=Ky(p,h);if((R=r.current)==null||R.focus(),!qa(M[h])){M!==p&&(re(M,h),x(Is(b,M[h])));return}const G=Gy(d,M,h);x(G.cursor),re(M,G.current),G.send&&Ac(d,M)&&F(M)}return}if(Q.key==="Escape")return Q.preventDefault(),Q.stopPropagation(),l({a:"ask-park",id:n,askId:e.id});if(Ua(Q)&&(Q.metaKey||Q.ctrlKey))return Q.preventDefault(),C();if(Ua(Q)||Q.key===" "&&E)return Q.preventDefault(),v?C():Z(j);if(Q.key==="ArrowUp"||Q.key==="ArrowDown")return Q.preventDefault(),b?x(Ys(j,Q.key==="ArrowUp"?-1:1,mb(b))):void 0;if(Q.key==="ArrowLeft"||Q.key==="ArrowRight"||Q.key==="Tab"){Q.preventDefault();const M=Q.key==="ArrowLeft"||Q.key==="Tab"&&Q.shiftKey;return L(gO(h,M?-1:1,yO(d)))}if(Q.key==="n"&&(b!=null&&b.note))return Q.preventDefault(),I(!1);if(Q.key==="s")return Q.preventDefault(),F();if(Jb(Q.key)){const M=v?Number(Q.key)<=d.length?Number(Q.key)-1:-1:mO(b,Number(Q.key));return M===-1?void 0:(Q.preventDefault(),v?L(M):Z(M))}},K=Q=>Q?[...d.length>1?[["←→","question"]]:[],["↑↓","move"],["⏎","choose"],...Q.note?[["n","add a note"]]:[],["⌘⏎","send"],["esc","reply instead"]]:[["←→","question"],["⏎","send"],["esc","reply instead"]],le=(Q,ce)=>f.jsxs("div",{className:"ask-foot",children:[f.jsx($e,{variant:"outline",size:"md",disabled:!Ac(d,p),onClick:C,children:"send"}),(Q==null?void 0:Q.note)&&ce&&ce.selected.length>0&&ce.note===void 0&&f.jsxs($e,{tone:"quiet",size:"md",onClick:()=>I(!1),children:[f.jsx(Zr,{k:"n",chip:!0}),"add a note"]}),f.jsxs($e,{tone:"quiet",size:"md",onClick:()=>F(),children:[f.jsx(Zr,{k:"s",chip:!0}),"skip"]}),f.jsxs($e,{variant:"outline",tone:"danger",size:"md",className:"ask-stop","data-tip":"Stop the agent (context up to here is kept)",onClick:()=>a==null?void 0:a.send({t:"stop-agent",worktreeId:n}),children:[f.jsx(Ct,{name:"stop",className:"icon-inline"})," stop"]})]}),de=(Q,ce)=>{const R=ce===h,M=p[ce],G=gb(M,!!Q.multi),ne=R?Q.options[j]:void 0;return f.jsxs("div",{className:Ke("ask-page",!R&&"ask-page-off"),children:[f.jsx("div",{className:"ask-head",children:f.jsx("div",{className:"ask-text",children:Q.text||c})}),f.jsxs("div",{className:"ask-options",children:[Q.options.map((O,ee)=>{const D=M==null?void 0:M.selected.includes(O.value);return f.jsxs("button",{type:"button",className:"picker-item ask-opt row-edge","data-state":Ln({cursor:R&&!H&&ee===j,checked:D}),onMouseMove:()=>ee!==j&&x(ee),onClick:()=>{var q;Z(ee),(q=r.current)==null||q.focus()},children:[f.jsx(Zr,{k:String(ee+1),className:"ask-num row-dim"}),f.jsxs("span",{className:"ask-label",children:[vb(O.label),vO(O.label)&&f.jsx("span",{className:"badge-recommended",children:"recommended"})]}),O.description&&f.jsx("span",{className:"ask-desc row-dim",children:O.description})]},O.value)}),Q.note&&f.jsxs("button",{type:"button",className:"picker-item ask-opt row-edge","data-state":Ln({cursor:R&&!H&&j===Q.options.length,checked:G}),onMouseMove:()=>j!==Q.options.length&&x(Q.options.length),onClick:()=>Z(Q.options.length),children:[f.jsx(Zr,{k:String(Q.options.length+1),className:"ask-num row-dim"}),f.jsx("span",{className:"ask-label",children:Q.note.label}),f.jsx("span",{className:"ask-desc row-dim",children:"your own answer"})]})]}),(ne==null?void 0:ne.preview)&&f.jsx("pre",{className:"ask-preview",children:ne.preview}),Q.note&&(M==null?void 0:M.note)!==void 0&&f.jsx(wl,{ref:R?B:void 0,bare:!0,font:"ui",rows:2,className:"ask-own",placeholder:G?`${Q.note.label}: your own answer`:"a note for the agent, sent with your pick",value:M.note,onChange:O=>re(hb(p,ce,O.target.value),ce)}),le(Q,M),f.jsx(al,{hints:K(Q),className:"ask-keys"})]},Q.id)};return f.jsxs("div",{ref:r,className:"ask-box",tabIndex:-1,onKeyDown:V,onBlur:i,children:[d.length>1&&f.jsx("div",{className:"ask-tabs",children:f.jsx(Pu,{label:"questions",owner:"ask",items:[...d.map((Q,ce)=>({id:String(ce),label:Q.header||`question ${ce+1}`,lead:f.jsx("span",{className:Ke("dot ask-step",qa(p[ce])&&"answered")})})),{id:String(d.length),label:"send",far:!0}],current:String(h),onPick:Q=>{var ce;L(Number(Q)),(ce=r.current)==null||ce.focus()}})}),f.jsxs("div",{className:"ask-pages",children:[d.map(de),au(d)!==-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:d.map((Q,ce)=>{const R=qa(p[ce]);return f.jsxs("button",{type:"button",className:"picker-item ask-opt ask-sum",onClick:()=>{var M;L(ce),(M=r.current)==null||M.focus()},children:[f.jsx(Zr,{k:String(ce+1),className:"ask-num row-dim"}),f.jsxs("span",{className:"ask-label",children:[f.jsx("span",{className:"row-dim",children:Q.header||`question ${ce+1}`})," ",f.jsx("span",{className:Ke(!R&&"row-dim"),children:R?kb(Q,p[ce]):"no answer yet"})]})]},Q.id)})}),le(),f.jsx(al,{hints:K(),className:"ask-keys"})]})]})]})}const GM=[["↑↓","move"],["⏎","choose"],["esc","reply instead"]];function VM({item:e,ask:t,worktreeId:n,root:r}){const i=Xb(r,e.id),a=Ge(),l=Ve(),c=z(E=>E.activeId),[d,g]=T.useState(0),k=Xi(),p=t.plan,h=T.useMemo(()=>t.detail&&!p?Uc(t.detail):"",[t.detail,p]),v=()=>{p&&c===n&&ar({dispatch:l},{worktreeId:n,path:p,view:"preview",focus:!1})};ft([e.id,p],v);const b=E=>{const j=t.choices[E];j&&(a==null||a.send({t:"agent-decide",worktreeId:n,askId:e.id,choiceId:j.id}))},_=E=>{if(E.key==="Escape")return E.preventDefault(),E.stopPropagation(),l({a:"ask-park",id:n,askId:e.id});if(Ua(E))return E.preventDefault(),b(d);if(E.key==="ArrowUp"||E.key==="ArrowDown")return E.preventDefault(),g(Ys(d,E.key==="ArrowUp"?-1:1,t.choices.length));Jb(E.key)&&t.choices[Number(E.key)-1]&&(E.preventDefault(),b(Number(E.key)-1))};return f.jsxs("div",{ref:r,className:"ask-box",tabIndex:-1,onKeyDown:_,onBlur:i,children:[f.jsx("div",{className:"ask-head",children:f.jsx("div",{className:"ask-text",children:t.title})}),h&&f.jsx("div",{className:"ask-detail md",dangerouslySetInnerHTML:{__html:h}}),f.jsx("div",{className:"ask-options",children:t.choices.map((E,j)=>f.jsxs("button",{type:"button",className:Ke("picker-item ask-opt row-edge",E.kind.startsWith("reject")&&"deny"),"data-state":Ln({cursor:!k&&j===d}),onMouseMove:()=>j!==d&&g(j),onClick:()=>b(j),children:[f.jsx(Zr,{k:String(j+1),className:"ask-num row-dim"}),f.jsx("span",{className:"ask-label",children:E.name})]},E.id))}),f.jsx(al,{hints:GM,className:"ask-keys"})]})}const qM={skipped:"you skipped this",cancelled:"the turn was stopped before you answered",expired:"Toyon restarted before you answered"};function YM({item:e,worktreeId:t}){const n=Ve(),r=It(t,"askParked");if(!e.outcome)return r!==e.id?null:f.jsxs("button",{type:"button",className:"row ask-row",onClick:()=>{t&&n({a:"ask-unpark",id:t}),n({a:"focus-chat"})},children:[f.jsx("span",{className:"ask-tag",children:"asking"}),f.jsx("span",{className:"ask-row-text",children:uO(e)})]});const i=qM[e.outcome];if(e.ask.kind==="permission"){const{title:c,choices:d}=e.ask,g=d.find(k=>k.id===e.choiceId);return f.jsxs("div",{className:"ask-closed",children:[f.jsx("div",{className:"ask-lead",children:c}),f.jsx("div",{className:"ask-answered",children:g?g.name:i??"closed"})]})}const{message:a,questions:l}=e.ask;return f.jsxs("div",{className:"ask-closed",children:[f.jsx("div",{className:"ask-lead",children:a}),i?f.jsx("div",{className:"ask-answered",children:i}):l.map((c,d)=>{var g;return f.jsxs("div",{className:"ask-answered",children:[c.header&&f.jsx("span",{className:"ask-header",children:c.header}),c.header&&" ",kb(c,(g=e.answers)==null?void 0:g[d])]},c.id)})]})}const QM={read:"read",edit:"edit",delete:"delete",move:"move",search:"search",execute:"run",think:"think",fetch:"fetch",switch_mode:"mode",other:"tool"},Ev={read:"book",edit:"edit",delete:"trash",move:"move",search:"search",execute:"run",think:"bulb",fetch:"globe",switch_mode:"swap",other:"dot"},XM={grep:"search",rg:"search",ag:"search",ack:"search",find:"search",fd:"search",cat:"book",head:"book",tail:"book",less:"book",bat:"book",ls:"folder",tree:"folder",mkdir:"folder",rm:"trash",rmdir:"trash",mv:"move",curl:"globe",wget:"globe",git:"branch"};function JM(e){const t=e.trim().split(/\s+/)[0]??"";return XM[t.slice(t.lastIndexOf("/")+1)]}function Zo(e,t){const n=e.input,r=n?n[t]:void 0;return typeof r=="string"?r:""}function ll(e,t=[]){const n=Zo(e,"command"),i=e1(e)||n||Zo(e,"path")||Zo(e,"pattern")||(e.title&&e.title!==e.name?e.title:""),a=Lh(Zo(e,"description")||i,t),l=e.toolKind&&e.toolKind in Ev?e.toolKind:"other",c=QM[l],d=a&&(e.name===e.title||e.name===Xc||e.name===Vw)?"":e.name,g=d&&d.toLowerCase()!==c?d:a?"":c,k=(l==="execute"||l==="other")&&n?JM(n):void 0;return{label:c,name:g,icon:k??Ev[l],hint:a===g?"":a,command:n&&n!==a?n:""}}const eP={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 tP(e){const t=e.toolKind;return Qv(t)&&Xv(e.input)?eP[t]:""}function $p(e,t){const n=t1(t),r=n[0],i=Zo(e,"description");return i&&r&&!r.code&&r.text===i?n.slice(1):n}function Hu(e){return e1(e)||Zo(e,"path")}function e1(e){return Zo(e,"file_path")||Zo(e,"filepath")||Zo(e,"filePath")}function Lh(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 nP=/^(`{3,})([\w+#.-]*)\s*$/;function t1(e){var c;const t=[];let n=[],r="",i=!1,a=0;const l=()=>{const d=n.join(`
185
+ `).replace(/^\n+|\n+$/g,"");d.trim()&&t.push({code:i,diff:rP(d,r),lang:i?r:"",text:d}),n=[]};for(const d of e.split(`
186
+ `)){const g=nP.exec(d),k=((c=g==null?void 0:g[1])==null?void 0:c.length)??0;if(!g||i&&(k<a||g[2])){n.push(d);continue}l(),i=!i,a=i?k:0,r=i?(g[2]??"").toLowerCase():""}return l(),t}function rP(e,t){return t==="diff"||t==="patch"||/^diff --git /m.test(e)||/^@@ .*@@/m.test(e)?!0:/^--- /m.test(e)&&/^[+-]/m.test(e)}const oP=/^(diff --git |index [0-9a-f]+\.\.|new file mode |deleted file mode |similarity index |rename (from|to) |Binary files )/;function iP(e){const t=[];for(const n of e.split(`
187
+ `)){const r=aP(n);if(r==="meta"&&!n.startsWith("diff --git "))continue;const i=r==="add"||r==="del"||n.startsWith(" ");t.push({kind:r,text:i?n.slice(1):n})}return sP(t),t}function sP(e){var t,n,r,i;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(;((i=e[c])==null?void 0:i.kind)==="add";)c++;const d=e.slice(a,l),g=e.slice(l,c),k=d.length>0&&g.length>0?ME(d.map(p=>p.text).join(`
188
+ `),g.map(p=>p.text).join(`
189
+ `)):null;k&&(Sv(d,gk(k.before)),Sv(g,gk(k.after)));for(const p of[...d,...g])p.spans??(p.spans=[]);a=c}}function Sv(e,t){if(t.length===e.length)for(const[n,r]of e.entries())r.spans=t[n]}function aP(e){return e.startsWith("@@")?"hunk":e.startsWith("+++")||e.startsWith("---")||oP.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":""}const n1=new Set(["read","edit","fetch"]);function r1(e,t){if(e.isError||!e.toolKind||!n1.has(e.toolKind))return"";const{hint:n}=ll(e,t);return n?`${e.parentToolId??""}
190
+ ${e.toolKind}
191
+ ${e.name}
192
+ ${n}`:""}function Nv(e,t,n){if(!t||!("tools"in t)||e.done||e.isError||!e.toolKind||!n1.has(e.toolKind))return!1;const r=t.tools[0];return r.toolKind===e.toolKind&&r.name===e.name&&r.parentToolId===e.parentToolId&&r1(r,n)!==""}function lP(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 cP(e){return e.done&&!e.output&&!e.isError&&Qv(e.toolKind)&&Xv(e.input)}function uP(e,t){const n=lP(e),r=[],i=new Map;let a="";for(const[l,c]of e.entries()){if(c.kind!=="tool"){a="",r.push({at:l,item:c});continue}if(cP(c))continue;if(n.has(c.id)){a="";const p=[];i.set(c.id,{run:p,key:""}),r.push({at:l,spawn:c,run:p});continue}const d=r1(c,t),g=c.parentToolId?i.get(c.parentToolId):void 0;if(g){const p=g.run.at(-1);d&&d===g.key&&p?p.tools.push(c):!d&&Nv(c,p,t)?p.next=c:g.run.push({at:l,tools:[c]}),g.key=d;continue}const k=r.at(-1);if(d&&d===a&&k&&"tools"in k){k.tools.push(c);continue}if(!d&&Nv(c,k,t)){k.next=c;continue}a=d,r.push({at:l,tools:[c]})}return r}function dP(e){return e.reduce((t,n)=>t+n.tools.length,0)}function fP(e){const t=new Set;let n=!0;for(let i=e.length-1;i>=0;i--){const a=e[i];if(a.kind!=="tool"||!a.parentToolId){n=!1;continue}(n||!a.done)&&t.add(a.parentToolId)}if(t.size===0)return{ids:t,calls:0};let r=0;for(const i of e)i.kind==="tool"&&i.parentToolId&&t.has(i.parentToolId)&&r++;return{ids:t,calls:r}}function o1(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function pP(e,t){return!e||!t?e===t:e.length===t.length&&e.every((n,r)=>{var i,a;return n.at===((i=t[r])==null?void 0:i.at)&&n.next===((a=t[r])==null?void 0:a.next)&&o1(n.tools,t[r].tools)})}function hP(e){var t;for(let n=e.length-1;n>=0;n--){const r=e[n];if(!("spawn"in r)){if("tools"in r){if(((t=r.tools[0])==null?void 0:t.toolKind)==="think")return n;continue}if(r.item.kind==="thinking"){if(r.item.text.trim())return n;continue}if(mP(r.item))return-1}}return-1}function mP(e){return e.kind==="assistant"?!!e.text.trim():e.kind==="ask"?!!e.outcome:!0}function gP(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 i1({onClose:e,menu:t,children:n}){const r=Wt("chat");return f.jsxs(Ji,{className:"attach-full",onDismiss:e,onKey:i=>{i.key==="Escape"&&(i.stopPropagation(),e())},onClick:i=>{i.target===i.currentTarget&&e()},...t&&r.contextMenu(t),children:[n,f.jsx(Dt,{icon:"close",label:"Close",tone:"quiet",onClick:e})]})}function s1({src:e,n:t,name:n,width:r,height:i,bytes:a,onRemove:l,className:c=""}){const d=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:rw("image",t)}),f.jsxs("span",{className:"pick-file",children:[" ","· ",n," · ",r,"×",i," · ",T2(a)]})]})]}),g=T.useRef(null),[k,p]=T.useState(!1),h=Wt("chat");return f.jsxs("div",{ref:g,className:Ke("pick-chip image-chip",c),"data-tip":"Open full size","data-tip-placement":"follow",...h.contextMenu(()=>Vy(e,{open:()=>p(!0),remove:l})),children:[f.jsx("button",{type:"button",className:"image-link",onClick:()=>p(!0),children:d}),l&&f.jsx(Dt,{icon:"close",label:"Remove image",tone:"quiet",onClick:l}),f.jsx(wP,{chip:g,src:e,alt:n,width:r,height:i}),k&&f.jsx(i1,{onClose:()=>p(!1),menu:()=>Vy(e),children:f.jsx("img",{src:e,alt:n})})]})}function kP({img:e,src:t}){return f.jsx(s1,{className:"in-chat",src:t,...e})}const yP=150,vP={side:"left",align:"center",offset:12,flip:"side",margin:8};function wP({chip:e,src:t,alt:n,width:r,height:i}){const[a,l]=T.useState(!1);T.useEffect(()=>{const d=e.current;if(!d)return;let g=0;const k=()=>{window.clearTimeout(g),l(!1)},p=()=>{window.clearTimeout(g),g=window.setTimeout(()=>l(!0),yP)};return d.addEventListener("mouseenter",p),d.addEventListener("mouseleave",k),d.addEventListener("mousedown",k),()=>{window.clearTimeout(g),d.removeEventListener("mouseenter",p),d.removeEventListener("mouseleave",k),d.removeEventListener("mousedown",k)}},[e]);const c=()=>{var p;const d=e.current;if(!d)return null;const g=d.getBoundingClientRect(),k=((p=d.closest(".chat-log"))==null?void 0:p.getBoundingClientRect())??g;return{left:k.left,right:k.right,top:g.top,bottom:g.bottom}};return a?f.jsx(Ji,{className:"image-peek",anchor:c,placement:vP,track:!0,children:f.jsx("img",{src:t,alt:n,style:{aspectRatio:`${r} / ${i}`}})}):null}function bP(e){return e.length<2||!e.every(t=>{var n;return t.length===1&&((n=t[0])==null?void 0:n.diff)})?null:_P(e.map(t=>t[0].text))}const xP=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function _P(e,t=3){let n=[];for(const r of e){const i=EP(r);if(!i)return null;const a=SP(n,i);if(!a)return null;n=a}return n.some(r=>r.kind!=="same")?NP(n,t):null}function EP(e){const t=[];let n=null;for(const r of e.split(`
193
+ `)){const i=xP.exec(r);if(i){n={oldStart:Number(i[1]),newStart:Number(i[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 SP(e,t){const n=[];let r=0,i=0,a=0,l=0;const c=k=>{k.kind==="same"?i=k.a-k.c:k.kind==="add"?i-=1:i+=1},d=()=>{for(;r<e.length&&e[r].kind==="del";)n.push(e[r]),c(e[r]),r++},g=k=>{for(let p=k;p<e.length;p++){const h=e[p];if(h.kind!=="del")return h.c}return Number.POSITIVE_INFINITY};for(const k of t){if(k.oldStart<=l)return null;for(;r<e.length;){const v=e[r];if((v.kind==="del"?g(r):v.c)>=k.oldStart)break;n.push(v.kind==="del"?v:{...v,c:v.c+a}),c(v),r++}let p=k.oldStart,h=k.newStart;for(const v of k.ops){if(d(),v.mark==="+"){n.push({kind:"add",c:h,text:v.text}),h++;continue}const b=e[r],_=b&&b.kind!=="del"&&b.c===p?b:void 0;if(_){if(_.text!==v.text)return null;r++,c(_),v.mark===" "?n.push({..._,c:h}):_.kind==="same"&&n.push({kind:"del",a:_.a,text:_.text})}else v.mark===" "?n.push({kind:"same",a:p+i,c:h,text:v.text}):n.push({kind:"del",a:p+i,text:v.text});v.mark===" "&&h++,p++}a=h-p,l=p-1}for(;r<e.length;r++){const k=e[r];n.push(k.kind==="del"?k:{...k,c:k.c+a})}return n}function NP(e,t){const n=[];for(const r of CP(e))for(const[i,a]of jP(r.rows,t)){const l=TP(r.rows.slice(i,a)),c=l.filter(p=>p.kind!=="add").length,d=l.filter(p=>p.kind!=="del").length,g=l.find(p=>p.kind!=="add"),k=l.find(p=>p.kind!=="del");n.push(`@@ -${g?g.a:r.oldAt[i]},${c} +${k?k.c:r.newAt[i]},${d} @@`,...l.map(p=>`${p.kind==="add"?"+":p.kind==="del"?"-":" "}${p.text}`))}return n.join(`
194
+ `)}function TP(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 i=e.slice(n,r);t.push(...i.filter(a=>a.kind==="del"),...i.filter(a=>a.kind==="add")),n=r}return t}function CP(e){const t=[];let n=null,r=1,i=1;for(const a of e){const l=a.kind==="add"?r:a.a,c=a.kind==="del"?i:a.c;(!n||l!==r||c!==i)&&(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),i=c+(a.kind==="del"?0:1)}return t}function jP(e,t){const n=[];let r=0;for(;r<e.length;){if(e[r].kind==="same"){r++;continue}let i=r,a=r;for(;a<e.length;){if(e[a].kind!=="same"){i=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,i+t+1)]),r=i+t+1}return n}function a1({n:e,name:t,source:n,lines:r,chars:i,preview:a,text:l,href:c,onRemove:d,className:g=""}){const k=(n==null?void 0:n.path)??t??"",p=k.includes("/")?k.slice(0,k.lastIndexOf("/")):"",h=n?[p,n.ref?`at ${n.ref.slice(0,7)}`:""].filter(Boolean).join(" "):[p,`${r} ${r===1?"line":"lines"}`,`${i.toLocaleString()} chars`,a].filter(Boolean).join(" · "),v=f.jsxs(f.Fragment,{children:[f.jsx(Ct,{name:"text",className:"icon-inline"}),f.jsxs("span",{className:"pick-target",children:[f.jsx("b",{children:t?t.slice(t.lastIndexOf("/")+1):n?XE(n):rw("paste",e)}),h&&f.jsxs("span",{className:"pick-file",children:[" · ",h]})]})]}),[b,_]=T.useState(!1),E=Wt("chat"),j={text:l,href:c};return f.jsxs("div",{className:Ke("pick-chip paste-chip",g),"data-tip":a||void 0,...E.contextMenu(()=>qy(j,{open:c?()=>_(!0):void 0,remove:d})),children:[c?f.jsx("button",{type:"button",className:"image-link",onClick:()=>_(!0),children:v}):v,d&&f.jsx(Dt,{icon:"close",label:"Remove attachment",tone:"quiet",onClick:d}),b&&c&&f.jsx(i1,{onClose:()=>_(!1),menu:()=>qy(j),children:f.jsx(AP,{href:c})})]})}function AP({href:e}){const[t,n]=T.useState(null),[r,i]=T.useState(!1);return T.useEffect(()=>{let a=!0;return fetch(e).then(l=>l.ok?l.text():Promise.reject(new Error(String(l.status)))).then(l=>{a&&n(l)}).catch(()=>{a&&i(!0)}),()=>{a=!1}},[e]),r?f.jsx("p",{className:"paste-full hint",children:"Toyon could not read that paste back."}):f.jsx("pre",{className:"paste-full paste-text",children:t})}function l1({pick:e,dir:t,tipText:n,onHover:r,onOpen:i,onRemove:a,className:l=""}){const c=e.callFile,d=e.file,g=c?{path:c,line:e.callLine}:d?{path:d,line:e.line}:null,k=c&&d?{path:d,line:e.line}:null,p=(_,E)=>`${_}${E?`:${E}`:""}`,h=_=>_.split("/").pop()??_,v=(_,E,j,x)=>i?f.jsx("button",{className:"pick-open","data-tip":x,onClick:()=>i(_,E??1),children:j}):j,b=Wt("chat");return f.jsxs("div",{className:Ke("pick-chip",l),"data-tip":n,onMouseEnter:()=>r==null?void 0:r(!0),onMouseLeave:()=>r==null?void 0:r(!1),...b.contextMenu(()=>xO(e,{dir:t,remove:a})),children:[f.jsxs("span",{className:"pick-target",children:[f.jsx(Ct,{name:"pick",className:"icon-inline"})," ",_h(e),g&&f.jsxs("span",{className:"pick-file",children:[" ","· ",v(g.path,g.line,p(h(g.path),g.line),`Open ${p(g.path,g.line)}`)]}),k&&f.jsxs("span",{className:"pick-file",children:[" ","·"," ",v(k.path,k.line,p(k.path.split("/").pop()??k.path,k.line),`Open the component: ${p(k.path,k.line)}`)]})]}),a&&f.jsx(Dt,{icon:"close",label:"Remove attachment",tone:"quiet",onClick:a})]})}function IP(e){return e.replace(/^([\t ]*)\*\*(\S(?:[^\n]*\S)?)\*\*([\t ]*)$/gm,"$1$2$3")}function RP(e,t,n,r,i){const{sock:a}=r,l=e[0];if(!l)return[];const c=[],d=Lh(Hu(l),t);if(d&&!d.startsWith("/")&&n){const v=l.toolKind==="edit"?"diff":"file";c.push({id:"open-diff",label:`open ${v}`,onClick:()=>ar(r,{worktreeId:n.id,path:d,view:v})}),c.push(...Qs(`${n.dir}/${d}`,()=>a==null?void 0:a.send({t:"reveal",worktreeId:n.id,path:d})))}const g=[],k=ll(l,t).command;k&&g.push({id:"copy-command",label:"copy command",onClick:()=>Zt(k)});const p=e.map(v=>v.output??"").filter(Boolean).join(`
195
+ `);p&&g.push({id:"copy-output",label:"copy output",onClick:()=>Zt(p)});const h=i.leaf?[]:[{id:"fold",label:i.open?"collapse":"expand",onClick:i.toggle}];return Nn([c,g,h])}function c1(e,t){const n=e.closest("a");if(!n)return null;const r=n.getAttribute("data-path");if(r)return{kind:"path",path:r};const i=n.getAttribute("href");if(!i)return null;const a=t?Pb(t,i):null;return a?{kind:"file",file:a}:{kind:"out",href:i}}function u1(e,t,n,r){const i=c1(e.target,t);if((i==null?void 0:i.kind)!=="file"||!n)return;const a=i.file;if(e.preventDefault(),a.folder){PR(r,{worktreeId:n,path:a.path});return}ar(r,{worktreeId:n,path:a.path,...a.line?{view:"file",line:{n:a.line}}:{}})}function OP({text:e,menu:t,marked:n,worktreeId:r,fileRoot:i}){const a=Ph(e,i?{fileRoot:i}:void 0);Ge();const l=Ve(),c=Wt("chat");return f.jsx("div",{className:"msg-assistant md row-edge","data-state":Ln({cursor:n}),...c.contextMenu((d,g)=>t(c1(g,i))),onClick:d=>u1(d,i,r,{dispatch:l}),dangerouslySetInnerHTML:{__html:a}})}const ep=40;function d1(e,t){return e.map(n=>{const r=Vb(n.lang,t||(n.diff?DM(n.text):""));if(n.diff){const i=iP(n.text);return{...n,lines:i,painted:BM(i,r)}}return{...n,lines:[],painted:n.code?Yb(n.text,r):[]}})}function f1({blocks:e,path:t,worktreeId:n}){Ge();const r=Ve();return f.jsx("div",{className:"tool-out",children:e.map((i,a)=>i.diff?f.jsxs("pre",{className:"tool-block diff",children:[i.lines.slice(0,ep).map((l,c)=>{var d;return l.kind==="hunk"?f.jsx("span",{className:"dl hunk",title:l.text},c):f.jsx("span",{className:`dl ${l.kind}`,children:(d=i.painted[c])!=null&&d.length?f.jsx(Tv,{pieces:i.painted[c]}):l.text||" "},c)}),i.lines.length>ep&&f.jsxs("button",{type:"button",className:"dl more",disabled:!t||!n,"data-tip":t&&n?"Open this file's diff":void 0,onClick:()=>n&&ar({dispatch:r},{worktreeId:n,path:t,view:"diff"}),children:[i.lines.length-ep," more lines"]})]},a):i.code?f.jsx("pre",{className:"tool-block",children:i.painted.length?i.painted.map((l,c)=>f.jsxs(T.Fragment,{children:[c>0?`
196
+ `:null,f.jsx(Tv,{pieces:l})]},c)):i.text},a):f.jsx("p",{className:"tool-note",children:i.text},a))})}const $P=T.memo(function({item:t,roots:n,worktreeId:r}){const i=T.useMemo(()=>d1($p(t,t.output??""),Hu(t)),[t]),a=ll(t,n).command;return!a&&i.length===0?null:f.jsxs("div",{className:"tool-part",children:[a&&f.jsx("pre",{className:"tool-block cmd",children:a}),i.length>0&&f.jsx(f1,{blocks:i,path:p1(t,n),worktreeId:r})]})});function p1(e,t){const n=Lh(Hu(e),t??[]);return n.startsWith("/")?"":n}const MP=T.memo(function({text:t,item:n,roots:r,worktreeId:i}){const a=Hu(n),l=T.useMemo(()=>d1([{code:!0,diff:!0,lang:"diff",text:t}],a),[t,a]);return f.jsx("div",{className:"tool-part",children:f.jsx(f1,{blocks:l,path:p1(n,r),worktreeId:i})})});function Tv({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(T.Fragment,{children:t.text},n)})})}function h1({className:e,state:t,auto:n,leaf:r,label:i,summary:a,menu:l,onToggle:c,children:d}){const[g,k]=T.useState(null),p=T.useRef(null),h=t2(".chat-log"),v=!r&&(g??n),b=()=>{r||(v||h(p.current),k(!v))},_=Wt("chat");return f.jsxs("details",{ref:p,className:Ke(e,r&&"leaf"),"data-state":t,open:v,onToggle:E=>c==null?void 0:c(E.currentTarget.open),..._.contextMenu(()=>l({open:v,leaf:!!r,toggle:b})),tabIndex:-1,onPointerDown:()=>{var E;return(E=p.current)==null?void 0:E.focus({preventScroll:!0})},onKeyDown:E=>{E.key!=="Escape"||!v||(E.stopPropagation(),k(!1))},children:[f.jsx("summary",{"aria-label":i,tabIndex:r?-1:void 0,onClick:E=>{E.preventDefault(),b()},children:a}),d]})}const PP=T.memo(function({item:t,open:n,streaming:r,worktreeId:i,fileRoot:a}){const l=Ph(IP(t.text),a?{fileRoot:a}:void 0);Ge();const c=Ve(),d=r?"Thinking":"Thought",g=T.useRef(null);m0(g);const k=p=>{const h=g.current;!h||!p||r||(h.scrollTop=0)};return f.jsx(h1,{className:"tool-row",auto:!!n,label:d,onToggle:k,menu:p=>Nn([[{id:"copy",label:"copy thought",onClick:()=>Zt(t.text)}],[{id:"fold",label:p.open?"collapse":"expand",onClick:p.toggle}]]),summary:f.jsxs(f.Fragment,{children:[f.jsx(Ct,{name:"bulb",className:"tool-icon"}),f.jsx("span",{className:Ke("tool-name",r&&"live-text"),children:d})]}),children:f.jsx("div",{className:"tool-part",children:f.jsx("div",{ref:g,className:"tool-out thought-out md",onClick:p=>u1(p,a,i,{dispatch:c}),dangerouslySetInnerHTML:{__html:l}})})})}),Cv=T.memo(function e({tools:t,run:n,next:r,live:i,working:a,roots:l,worktreeId:c,marked:d}){var V;const g=t[0],k=T.useMemo(()=>bP(t.map(K=>$p(K,K.output??""))),[t]),p=!((V=t.at(-1))!=null&&V.done),h=p||!!r,v=h||!!a,b=!!i||!!n&&h,_=ll(g,l),E=p?tP(g):"",{label:j,icon:x}=_,H=E?"":_.name,B=E||_.hint,re=!(n&&n.length>0)&&!k&&t.every(K=>!ll(K,l).command&&$p(K,K.output??"").length===0),F=n?dP(n):0,C=[j,B].filter(Boolean).join(" "),L=n?`${F} ${F===1?"call":"calls"}`:t.length>1?`×${t.length}`:"",I=Sn(),Z=Ge();return f.jsxs(h1,{className:Ke("tool-row",t.some(K=>K.isError)&&"error",g.parentToolId&&"nested",n&&"spawn"),state:Ln({cursor:d}),auto:b,leaf:re,label:n?`${C}, ${L}`:t.length>1?`${C}, ${t.length} calls`:C,menu:K=>{const le=Yt(I.getState(),c),de=le?{id:le.worktree.id,dir:le.worktree.path}:null;return RP(t,l??[],de,{sock:Z,dispatch:I.dispatch},K)},summary:f.jsxs(f.Fragment,{children:[f.jsx(Ct,{name:n?"spawn":x,className:"tool-icon"}),H&&f.jsx("span",{className:Ke("tool-name",v&&"live-text"),children:H}),B&&f.jsx("span",{className:Ke("tool-hint",v&&"live-text"),children:B}),L&&f.jsx("span",{className:"tool-count",children:L})]}),children:[n&&n.length>0&&f.jsx("div",{className:"spawn-run",children:n.map(K=>f.jsx(e,{tools:K.tools,next:K.next,roots:l,worktreeId:c},K.at))}),k?f.jsx(MP,{text:k,item:g,roots:l,worktreeId:c}):t.map(K=>f.jsx($P,{item:K,roots:l,worktreeId:c},K.id))]})},(e,t)=>e.live===t.live&&e.working===t.working&&e.next===t.next&&e.roots===t.roots&&e.worktreeId===t.worktreeId&&e.marked===t.marked&&o1(e.tools,t.tools)&&pP(e.run,t.run));function LP({item:e}){const t=Ge(),n=Ve(),r=z(v=>v.activeId),i=z(v=>v.layout.term),a=z(v=>{var b;return((b=v.rows.find(_=>_.id===v.activeId))==null?void 0:b.login)??!1}),[l,c]=T.useState(""),[d,g]=T.useState(null),k=T.useRef(!1);if(ft([a],()=>{a&&k.current&&r&&n({a:"term-stream",id:r,stream:Ko,tall:!0})}),ft([e.done],()=>{e.done&&k.current&&i&&n({a:"toggle-terminal"}),k.current=!1}),!r)return null;const p=(v,b)=>{t==null||t.send({t:"agent-auth",worktreeId:r,methodId:v,...b?{apiKey:b}:{}})},h=e.methods.find(v=>v.id===d);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($e,{variant:"outline",on:d===v.id,"data-tip":v.description,onClick:()=>g(d===v.id?null:v.id),children:v.name},v.id):f.jsx($e,{variant:"outline","data-tip":v.kind==="terminal"?"opens in the terminal pane":v.description,onClick:()=>{p(v.id),v.kind==="terminal"&&(k.current=!0)},children:v.name},v.id)),f.jsx($e,{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&&h&&f.jsxs("form",{className:"auth-key",onSubmit:v=>{v.preventDefault(),l.trim()&&(p(h.id,l.trim()),c(""),g(null))},children:[f.jsx(Go,{type:"password",autoFocus:!0,placeholder:`${h.name} for ${e.agentName}`,value:l,onChange:v=>c(v.target.value)}),f.jsx($e,{type:"submit",children:"use key"})]})]})}const DP=T.memo(function({item:t,worktreeId:n,onPickHover:r,marked:i}){const a=Sn(),l=Ge(),c=Wt("chat"),d={sock:l,dispatch:a.dispatch},g=()=>{const p=Yt(a.getState(),n);return p?p.worktree.path:null},k=()=>{var p;return(p=Yt(a.getState(),n))==null?void 0:p.worktree.path};switch(t.kind){case"user":return f.jsxs("div",{className:"msg-user row-edge","data-state":Ln({cursor:i}),...c.contextMenu(()=>Kf(t,n??null,d)),children:[t.attachments&&n&&f.jsx("div",{className:"msg-attachments",children:t.attachments.map(p=>p.kind==="image"?f.jsx(kP,{img:p,src:Ly(n,p.file)},`${p.kind}-${p.n}`):p.kind==="paste"?f.jsx(a1,{className:"in-chat",n:p.n,name:p.name,source:p.source,lines:p.lines,chars:p.chars,preview:p.preview,href:Ly(n,p.file)},`${p.kind}-${p.n}`):f.jsx(l1,{pick:p,dir:g(),className:"in-chat",tipText:"Hover to highlight on the page",onHover:h=>r==null?void 0:r(p,h),onOpen:(h,v)=>Bu(a,l,n,h,v)},`${p.kind}-${p.n}`))}),t.text]});case"assistant":return f.jsx(OP,{text:t.text,menu:p=>Kf(t,n??null,d,{link:p,dir:g()}),marked:i,worktreeId:n,fileRoot:k()});case"error":return f.jsx("div",{className:"msg-assistant msg-error",...c.contextMenu(()=>Kf(t,n??null,d)),children:t.text});case"auth":return f.jsx(LP,{item:t});case"ask":return f.jsx(YM,{item:t,worktreeId:n});case"blocked":return f.jsxs("div",{className:"blocked-row",...c.contextMenu(()=>bO(t.path,g())),children:[f.jsxs("div",{className:"blocked-head",children:[f.jsx("span",{className:"blocked-tag",children:"blocked"}),f.jsx("span",{className:"tool-name",children:t.tool}),t.path&&f.jsx("span",{className:"tool-hint",children:t.path})]}),f.jsx("div",{className:"blocked-why row-dim",children:t.reason})]});case"grafted":return f.jsxs("div",{className:"graft-row","data-tip":`what follows was said in ${t.title} before it was merged in here`,"data-tip-placement":"follow",children:[f.jsx("span",{className:"graft-tag",children:"grafted"}),f.jsx("span",{className:"tool-name",children:t.title}),f.jsx("span",{className:"tool-hint",children:t.branch})]});case"landed":return f.jsx(zP,{item:t})}});function zP({item:e}){const t=Ge(),n=Ve(),r=z(i=>e.archiveIds.filter(a=>Yt(i,a)!==null).length);return f.jsxs("div",{className:"landed-row",children:[f.jsx("span",{className:"landed-tag",children:"landed"}),f.jsx("span",{className:"landed-text",children:e.text}),r>0&&f.jsx($e,{variant:"inline",tone:"strong",onClick:()=>Vi(t,n,e.archiveIds),children:r>1?`archive ${r} worktrees`:"archive the other worktree"})]})}function FP(e){return e.startsWith("!")?e.slice(1).trim():null}function m1(e){if(e.kind!=="tool"||e.name!==Xc&&e.name!==Vw)return null;const t=e.input;return typeof(t==null?void 0:t.command)=="string"?t.command:null}const tp=6e3,jv=1500;function BP(e){if(e.length<=tp)return e;const t=e.length-tp;return`${e.slice(0,jv)}
197
+ [${t} characters cut here]
198
+ ${e.slice(e.length-(tp-jv))}`}function UP(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 i=m1(r);if(i===null)continue;const a=t1(r.output??"").map(c=>c.text).join(`
199
+ `),l=BP(a);t.unshift(`$ ${i}${l?`
200
+ ${l}`:""}`)}if(t.length!==0)return`Shell commands the user ran since their last message, and what each printed:
201
+ ${t.join(`
202
+ `)}`}const g1=e=>e===""||e==="!";function Av(e,t){const n=new Set,r=[];for(let i=e.length-1;i>=0;i--){const a=e[i],l=m1(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:i}))}return r}function HP(e,t,n,r){if(!t){if(r!=="up"||!g1(n))return null;const c=Av(e,n==="!")[0];return c?{walk:{at:c.at,from:n},text:c.text}:null}const i=Av(e,t.from==="!"),a=i.findIndex(c=>c.at===t.at)+(r==="up"?1:-1);if(a<0)return{walk:null,text:t.from};const l=i[a];return l?{walk:{at:l.at,from:t.from},text:l.text}:{walk:t,text:n}}const Mp=3;function ZP(e,t){const n=T.useRef(Date.now()),[r,i]=T.useState(()=>Date.now());return ft([e],()=>{const a=(r-n.current)/1e3>=Mp;n.current=Date.now(),a&&i(n.current)}),T.useEffect(()=>{if(!t)return;const a=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(a)},[t]),t?Math.floor((r-n.current)/1e3):0}function Iv({active:e,archived:t,lead:n,tail:r}){const i=Ve(),a=Ge(),l=Sn(),c=(e==null?void 0:e.worktree.id)??(t==null?void 0:t.id)??null,d=It(c,"chat"),g=It(c,"queue"),k=It(c,"restoring"),p=T.useRef(null);lO(p);const h=m0(p,d);ft([c],()=>h.jump());const v=It(c,"mark"),b=(v==null?void 0:v.by)==="walk"?v.at:void 0,_=T.useRef(null),E=()=>{const D=p.current,q=D==null?void 0:D.querySelector(':scope > [data-state~="cursor"]');if(!D||!q)return;const Te=parseFloat(getComputedStyle(D).paddingTop)||0;D.scrollTop+=q.getBoundingClientRect().top-D.getBoundingClientRect().top-Te,h.read()};ft([b],()=>{const D=p.current;if(D){if(b===void 0){const q=_.current;if(_.current=null,!q||!g1(wo(l.getState(),c).draft))return;q.bottom?h.jump():(D.scrollTop=q.top,h.read());return}_.current??(_.current={bottom:h.pinned(),top:D.scrollTop}),E()}});const j=(v==null?void 0:v.by)==="reveal"?v:void 0,x=T.useMemo(()=>j?gP(d,j.seq):-1,[d,j]),H=b??(x>=0?x:void 0);ft([j==null?void 0:j.n,x],()=>{x>=0&&E()});const B=T.useCallback((D,q)=>{c&&(q?Rt.post(c,{type:"highlight-selector",selector:D.selector,label:_h(D)}):Rt.post(c,{type:"highlight-clear"}))},[c]),re=!!e&&Lu(e),F=It(c,"askParked"),C=T.useMemo(()=>{const D=pb(d);return!!D&&F!==D.id},[d,F]),L=e==null?void 0:e.worktree,I=(L==null?void 0:L.path)??(t==null?void 0:t.path),Z=T.useMemo(()=>I?[I]:[],[I]),V=T.useMemo(()=>uP(d,Z),[d,Z]),K=(e==null?void 0:e.agent)==="working",le=K||(e==null?void 0:e.agent)==="waiting",de=T.useMemo(()=>le?hP(V):-1,[le,V]),Q=V.at(-1),ce=K&&Q&&"item"in Q&&Q.item.kind==="thinking"?V.length-1:-1,R=V.findLastIndex(D=>{var q;return"tools"in D&&((q=D.tools[0])==null?void 0:q.name)===Xc}),M=d.some(D=>D.kind==="tool"&&D.name===Xc&&!D.done),G=ZP(d,re),ne=ce>=0||d.some(D=>D.kind==="tool"&&!D.done&&!D.parentToolId),O=T.useMemo(()=>fP(d),[d]),ee=O.ids.size;return f.jsxs("div",{className:"chat-wrap",children:[f.jsxs("div",{className:"chat-log",ref:p,children:[n,V.map((D,q)=>"spawn"in D?f.jsx(Cv,{tools:[D.spawn],run:D.run,working:re&&O.ids.has(D.spawn.id),roots:Z,worktreeId:c},D.at):"tools"in D?f.jsx(Cv,{tools:D.tools,next:D.next,live:q===de||q===R,roots:Z,worktreeId:c,marked:D.at===H},D.at):D.item.kind==="thinking"?f.jsx(PP,{item:D.item,open:q===de,streaming:q===ce,worktreeId:c,fileRoot:e==null?void 0:e.worktree.path},D.at):f.jsx(DP,{item:D.item,worktreeId:c,onPickHover:B,marked:D.at===H},D.at)),re&&e&&!(e.agent==="waiting"&&C)&&f.jsxs("div",{className:"working-row",children:[e.agent==="waiting"?"waiting for your answer…":ne?G>=Mp&&f.jsxs("span",{children:["quiet for",f.jsxs("span",{className:"working-num",children:[G,"s"]})]}):f.jsxs("span",{children:[ee?`${ee} ${ee===1?"agent":"agents"} working…`:"working…",ee>0&&f.jsxs("span",{className:"working-num",children:[O.calls," ",O.calls===1?"call":"calls"]}),G>=Mp&&f.jsxs("span",{className:"working-num",children:[G,"s"]})]}),f.jsxs($e,{variant:"outline",tone:"danger","data-tip":`Stop the agent (context up to here is kept${g.length?"; queued messages go next":""})`,"data-tip-key":"esc",onClick:()=>a==null?void 0:a.send({t:"stop-agent",worktreeId:e.worktree.id}),children:[f.jsx(Ct,{name:"stop",className:"icon-inline"})," stop"]})]}),M&&e&&f.jsxs("div",{className:"working-row",children:["running…",f.jsxs($e,{variant:"outline",tone:"danger","data-tip":"Kill the command; what it printed so far stays",onClick:()=>a==null?void 0:a.send({t:"exec-stop",worktreeId:e.worktree.id}),children:[f.jsx(Ct,{name:"stop",className:"icon-inline"})," stop"]})]}),c&&g.map((D,q)=>f.jsxs("div",{className:"msg-user queued-msg",children:[f.jsx("span",{className:"queued-tag",children:"queued"}),f.jsx("span",{className:"queued-text",children:D}),f.jsxs("span",{className:"queued-actions",children:[f.jsx(Dt,{icon:"edit",label:"Edit: removes from queue, puts it back in the input",onClick:()=>{a==null||a.send({t:"unqueue",worktreeId:c,index:q}),i({a:"set-draft",id:c,text:D})}}),f.jsx(Dt,{icon:"close",label:"Remove from queue",onClick:()=>a==null?void 0:a.send({t:"unqueue",worktreeId:c,index:q})})]})]},`q-${q}`)),r,k!==void 0&&f.jsxs("div",{className:"msg-user queued-msg",children:[f.jsx("span",{className:"queued-tag",children:"restoring"}),f.jsx("span",{className:"queued-text",children:k})]})]}),h.away&&f.jsxs("button",{className:"jump-down",onClick:()=>h.jump(!0),"data-tip":"Jump to latest",children:[f.jsx(Ct,{name:"caret",className:"icon-inline"})," new messages"]})]})}function Dh(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 k1(e,{sock:t}){return[{id:"restart:shell",label:"restart shell",onClick:()=>t==null?void 0:t.send({t:"term-restart",worktreeId:e,stream:to})}]}function WP(e,t,n,r){return Nn([[...e.flatMap(i=>Dh(i,t,r)),...k1(t,r)],[{id:"terminal",label:`${n?"hide":"show"} terminal`,onClick:()=>r.dispatch({a:"toggle-terminal"})}]])}const KP={side:"top",align:"start",offset:4,alignOffset:-10,matchWidth:-20,flip:"side",margin:8};function GP({results:e,keyOf:t,row:n,rowClass:r,nav:i,listRef:a,empty:l}){return f.jsxs(Ji,{className:"inline-picker",anchor:"parent",placement:KP,children:[f.jsxs("div",{className:"picker-list",ref:a,children:[e.map((c,d)=>f.jsx("button",{className:Ke("picker-item",r==null?void 0:r(c)),"data-state":Ln({cursor:d===i.index}),onMouseMove:()=>d!==i.index&&i.setIndex(d),onMouseDown:g=>g.preventDefault(),onClick:()=>i.pick(c),children:n(c,d===i.index)},t(c))),e.length===0&&f.jsx("div",{className:"empty",children:l})]}),f.jsx(al,{hints:[["↑↓","moves"],["tab","inserts"],["esc","dismisses"]]})]})}function VP({fraction:e,className:t}){const r=2*Math.PI*5.5,i=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*i} ${r}`})]})}function qP(e,t=Xa.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 Io="";function YP(e){var g;const t=XP(e.name);if(t){const k=[t.qualifier,e.description||e.name].filter(Boolean).join(" · ");return{label:t.label,version:t.version,description:k}}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="",...i]=(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 d=[l[3]??((g=e.name.match(/\(([^)]*)\)$/))==null?void 0:g[1]),...i].filter(Boolean).join(" · ");return{label:a,version:l[2],...d?{description:d}:{}}}const QP=/(?:^|[./])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 XP(e){const t=e.match(QP),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 y1(e,t,n,r){const i=Jv(e),a=aE(e),l=b=>a&&b===(i==null?void 0:i.id)?a.id:b,c=l(t||n||(i==null?void 0:i.id)||Io),d=l(t||(i==null?void 0:i.id)||Io),g=a?e.filter(b=>b!==i):e,k=g.some(b=>b.id===c),p=g.map(b=>({c:b,words:YP(b)})),h=b=>[b.label,b.version].filter(Boolean).join(" "),v=[...i?[]:[{id:Io,label:r.label,description:r.description}],...p.map(({c:b,words:_})=>{const E=p.filter(x=>h(x.words)===h(_)).length===1?_:void 0,j=E?E.description:b.description;return{id:b.id,label:E?E.label:b.name,...E!=null&&E.version?{suffix:E.version}:{},...E!=null&&E.version&&p.some(x=>x.c!==b&&x.words.label===E.label)?{chip:h(E)}:{},description:b===a?["recommended",j].filter(Boolean).join(" · "):j}}),...c&&!k?[{id:c,label:c}]:[]];if(c!==d){const b=v.find(j=>j.id===c),_=v.findIndex(j=>j.id===d),E=v[_];if(E){const j=(b==null?void 0:b.chip)??(b==null?void 0:b.label)??c;v[_]={...E,description:[`${j} now`,E.description].filter(Boolean).join(" · ")}}}return{rows:v,shown:c,picked:d}}const Ma=(e,t)=>`${e} ${t}`;function JP(e){const t=e.indexOf(" ");return t<0?{agent:e,model:Io}:{agent:e.slice(0,t),model:e.slice(t+1)}}function e4(e,t,n){const r=e.length>1;let i=Ma(t,n);return{rows:e.flatMap(l=>{var k;const c=l.short??l.name,d=l.id===t;if(!l.available||!((k=l.models)!=null&&k.length))return d&&(i=Ma(l.id,Io)),[{id:Ma(l.id,Io),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 g=y1(l.models,d?n:Io,void 0,{label:`${c} default`,description:`whatever ${l.name} runs when nothing is asked for`});return d&&(i=Ma(l.id,g.shown)),g.rows.map(p=>({...p,id:Ma(l.id,p.id),...r&&p.id!==Io?{prefix:c}:{}}))}),shown:i}}function Zu({anchored:e=!1,...t}){return e?f.jsx(t4,{...t,anchored:e===!0?{}:e}):f.jsx(n4,{...t})}function t4({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,anchored:i,coverBy:a,id:l,children:c}){return f.jsx(Ji,{className:Ke(r?"":"overlay-box","anchored",n),id:l,anchor:"parent",placement:{side:"bottom",align:"start",cover:!0,margin:0,...i},coverBy:a,onDismiss:e?()=>e():void 0,onKey:t?v1(t):void 0,children:c})}function n4({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,id:i,children:a}){const l=T.useRef(null);return V2(l,{onDismiss:e?()=>e():void 0,onKey:t?v1(t):void 0}),f.jsx("div",{className:"overlay",children:f.jsx("div",{className:Ke(r?"":"overlay-box",n),id:i,ref:l,children:a})})}const v1=e=>t=>{t.key==="Escape"&&(t.stopPropagation(),e())};function r4({text:e,params:t}){if(t.length===0)return e;const n=[];let r=0;for(const[i,a]of t)i>r&&n.push(e.slice(r,i)),n.push(f.jsx("span",{className:"picker-ghost-param",children:e.slice(i,a)},i)),r=a;return r<e.length&&n.push(e.slice(r)),n}function yr({items:e,filter:t,keyOf:n,row:r,rowClass:i,rowTitle:a,onPick:l,onBack:c,onActive:d,onSide:g,onQuery:k,completionOf:p,narrowTo:h,placeholder:v,initialQuery:b="",initialIndex:_,selectOnMount:E=!1,idleWhen:j,onIdlePick:x,anchored:H=!1,onEscape:B,lead:re,trailing:F,empty:C="no matches",footer:L,keys:I,rowMenu:Z}){const V=Wt("picker"),[K,le]=T.useState(b),de=T.useMemo(()=>t(e,K),[e,K,t]),Q=T.useRef(null),ce=Xi(),R=JI(E,!ce);T.useEffect(()=>{if(!k)return;const Ne=setTimeout(()=>k(K),150);return()=>clearTimeout(Ne)},[K,k]);const M=L0({results:de,keyOf:n,q:K,onPick:l,listRef:Q,onActive:d,onSide:g,completionOf:p,narrowTo:h,setQ:le,initialIndex:_,idle:(j==null?void 0:j(b))??!1,onIdlePick:x}),{index:G,ghost:ne}=M,O=typeof I=="function"?I(M.active,K):I,ee=[];O!=null&&O.nav&&ee.push(["↑↓",O.nav]),O!=null&&O.side&&g&&ee.push(["←→",O.side]),O!=null&&O.complete&&(ne!=null&&ne.accept)&&ee.push(["tab",O.complete]),O!=null&&O.pick&&ee.push(["enter",O.pick]),O!=null&&O.back&&ee.push(["esc",O.back]);const D=f.jsxs("div",{className:"picker-input",onMouseDown:Ne=>{var je;Ne.target.closest("input, button")||(Ne.preventDefault(),(je=R.current)==null||je.focus())},children:[re,f.jsxs("div",{className:"picker-caret",children:[f.jsx(Go,{font:"mono",bare:!0,ref:R,value:K,onChange:Ne=>{le(Ne.target.value),M.setIndex(j!=null&&j(Ne.target.value)?-1:0)},onKeyDown:Ne=>{var je;if(Z&&M.active&&(Ne.key==="ContextMenu"||Ne.key==="F10"&&Ne.shiftKey)){const Re=(je=Q.current)==null?void 0:je.querySelector('[data-state~="cursor"]');if(Re){Ne.preventDefault(),Ne.stopPropagation(),Rr.open({items:Z(M.active),owner:"picker",target:Re,anchor:Re.getBoundingClientRect()});return}}M.onKeyDown(Ne)},placeholder:v}),ne&&f.jsxs("div",{className:"picker-ghost","aria-hidden":"true",children:[f.jsx("span",{className:"picker-typed",children:K}),r4(ne)]})]}),F]}),q=f.jsxs("div",{className:"picker-list",ref:Q,children:[de.map((Ne,je)=>f.jsx("button",{className:Ke("picker-item",i==null?void 0:i(Ne)),"data-state":Ln({cursor:je===G}),title:a==null?void 0:a(Ne),onMouseMove:()=>je!==G&&M.setIndex(je),onClick:()=>{var Re;M.pick(Ne),(Re=R.current)==null||Re.focus()},...V.contextMenu(()=>(Z==null?void 0:Z(Ne))??[]),children:r(Ne,je===G,K)},n(Ne))),de.length===0&&f.jsx("div",{className:"empty",children:typeof C=="function"?C(K):C}),L==null?void 0:L(K,de)]}),Te=ee.length>0&&f.jsx(al,{hints:ee});return f.jsxs(Zu,{onClose:c,onEscape:B,boxClass:"picker",anchored:H,coverBy:re?".picker-input > *:first-child":F?".picker-input > *:last-child":void 0,children:[D,q,Te]})}function yi({value:e,reads:t,options:n,onChange:r,placeholder:i,hint:a,className:l,onClose:c}){const[d,g]=T.useState(!1),k=()=>{g(!1),c==null||c()},p=t??e,h=n.find(b=>b.id===p),v=(h==null?void 0:h.chip)??(h==null?void 0:h.label)??p;return f.jsxs("span",{className:"chip-picker",children:[f.jsx($e,{variant:"ghost",tone:"chrome",mono:!0,on:d,className:Ke("chip-picker-btn",l),...Et(a),onClick:()=>d?k():g(!0),children:v}),d&&f.jsx(yr,{anchored:{flip:"both",margin:8},onEscape:k,items:n,filter:(b,_)=>{const E=_.trim().toLowerCase().split(/\s+/).filter(Boolean);return b.filter(j=>{const x=`${j.prefix??""} ${j.label??j.id} ${j.suffix??""} ${j.id}`.toLowerCase();return E.every(H=>x.includes(H))})},keyOf:b=>b.id,initialIndex:b=>Math.max(0,b.findIndex(_=>_.id===e)),lead:f.jsx($e,{tone:"chrome",mono:!0,on:!0,className:"chip-picker-lead",onClick:k,children:v}),placeholder:i,rowClass:()=>"picker-row",row:b=>f.jsxs(f.Fragment,{children:[b.id===e&&f.jsx("span",{className:"row-current","aria-hidden":"true"}),f.jsxs("span",{className:Ke("chip-option",b.disabled&&"chip-option-off"),"aria-disabled":b.disabled,children:[f.jsxs("span",{className:"chip-option-name",children:[b.prefix?`${b.prefix} `:null,b.label??b.id,b.suffix?f.jsx("span",{className:"chip-option-suffix",children:` ${b.suffix}`}):null]}),b.description&&f.jsx("span",{className:"chip-option-desc row-dim",children:b.description})]})]}),onPick:b=>{b.disabled||(r(b.id),k())},onBack:k})]})}function w1({choices:e,value:t,current:n,what:r,defaultLabel:i,defaultDescription:a,placeholder:l,className:c,onChange:d,onClose:g}){if(e.length===0)return null;const{rows:k,shown:p,picked:h}=y1(e,t,n,{label:i,description:a}),v=k.find(_=>_.id===p),b=(v==null?void 0:v.chip)??(v==null?void 0:v.label)??p;return f.jsx(yi,{value:h,reads:p,options:k,onChange:d,onClose:g,className:c,hint:t?`asked for ${b}; click to change`:`${b}, the agent's choice; click to pick ${r}`,placeholder:l})}function b1(e){const[t,n]=no(dt.effortPrefix+(e??""),Io,r=>r??"");return[t,n]}function Pp({efforts:e,value:t,current:n,onChange:r,onClose:i}){return f.jsx(w1,{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:i})}function o4(e){const[t,n]=no(dt.modePrefix+((e==null?void 0:e.id)??""),dp,r=>hl.some(i=>i.id===r)?r:dp);return[t,n]}const i4=e=>{var t;return((t=hl.find(n=>n.id===e))==null?void 0:t.description)??""};function Rv({value:e,onChange:t,onClose:n}){return f.jsx(yi,{value:e,options:hl.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}: ${i4(e)}. Click to change`,placeholder:"what the agent may do without asking"})}function x1(e){const[t,n]=no(dt.modelPrefix+(e??""),Io,r=>r??"");return[t,n]}function _1(e,t){try{localStorage.setItem(dt.modelPrefix+e,t)}catch{}}function Lp({models:e,value:t,current:n,onChange:r,onClose:i}){return f.jsx(w1,{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:i})}function E1({agents:e,agent:t,model:n,onChange:r,onClose:i}){const{rows:a,shown:l}=e4(e,t,n);if(a.length===0)return null;const c=a.find(g=>g.id===l),d=c?[c.prefix,c.label,c.suffix].filter(Boolean).join(" "):n;return f.jsx(yi,{value:l,options:a,onChange:g=>{const k=JP(g);r(k.agent,k.model)},onClose:i,className:"model-chip",hint:`${d} works on the new worktree; click to change`,placeholder:"which agent and model work on it"})}function S1(e){const t=Fu(e),[n,r]=no(dt.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 s4({repo:e,value:t,onChange:n,onClose:r}){const i=Fu(e);if(i.length===0||!t)return null;const a=(e==null?void 0:e.config.profiles)??{},l=(e==null?void 0:e.configFile)??"the settings",c=d=>{var p;const g=((p=a[d])==null?void 0:p.run)??[],k=g.length>0?`runs ${g.join(", ")}`:"runs nothing";return d===(e==null?void 0:e.config.defaultProfile)?`${k}; the default in ${l}`:k};return f.jsx(yi,{value:t,options:i.map(d=>({id:d,description:c(d)})),onChange:n,onClose:r,hint:i.length>1?`${t}: ${c(t)}. Click to change`:`the only profile in ${l}`,placeholder:"the profile the worktree runs"})}function cl(e,t,n){if(!t)return e;const r=new Set(t.map(l=>l-n)),i=[];let a="";for(let l=0;l<e.length;l++)r.has(l)?(a&&i.push(a),a="",i.push(f.jsx("b",{className:"hit",children:e[l]},l))):a+=e[l];return a&&i.push(a),i}function a4(e,t){const n=e.filter(i=>i.id!==t),r=n.filter(i=>i.agent==="waiting"||i.unseen).length;return r===0?null:{n:r,tier:n.some(i=>i.agent==="waiting")?"waiting":"unseen"}}function zh(e,t,n){const r=g=>e.map((k,p)=>g(k)&&k.id!==t?p:-1).filter(k=>k>=0),a=[()=>r(g=>g.agent==="waiting"),()=>r(g=>!!g.unseen),()=>r(g=>g.agent==="working")].reduce((g,k)=>g.length>0?g:k(),[]);if(a.length===0){const g=e[0];return g&&g.id!==t?{activate:g.id}:null}const l=e.findIndex(g=>g.id===t),c=n>0?a.find(g=>g>l)??a[0]:a.findLast(g=>g<l)??a[a.length-1],d=c===void 0?void 0:e[c];return d?{activate:d.id}:null}function N1(e,{sock:t,dispatch:n}){var p,h;const r=v=>v?"hide":"show",i=e.repos.some(v=>v.id===e.activeRepoId),a=(p=Yt(e,e.activeId))==null?void 0:p.worktree.id,l=[];i&&(l.push({id:"new",label:"new worktree…",key:ct("new"),onClick:()=>n({a:"open-draft"})}),l.push({id:"refs",label:"open a branch or PR…",key:ct("refs"),onClick:()=>n({a:"open",overlay:{kind:"refs"}})})),a&&(l.push({id:"jump",label:"jump to file…",key:ct("quick-open"),onClick:()=>n({a:"open",overlay:{kind:"quick-open"}})}),l.push({id:"search",label:"search in files…",key:ct("search"),onClick:()=>n({a:"open",overlay:{kind:"search"}})})),nu(e)&&l.push({id:"routes",label:"go to page…",key:ct("routes"),onClick:()=>n({a:"open",overlay:{kind:"routes"}})}),i&&l.push({id:"chats",label:"search chats…",key:ct("chats"),onClick:()=>n({a:"open",overlay:{kind:"chats"}})});const c=zh(e.visible,e.activeId,1);c&&l.push({id:"wt-unseen-next",label:"next that needs you",key:ct("wt-unseen-next"),onClick:()=>n({a:"activate",id:c.activate})}),l.push({id:"project",label:e.repos.length>1?"switch project…":"open project…",key:ct("project"),onClick:()=>n({a:"open",overlay:{kind:"projects",form:"center"}})});const d=[{id:"changes",label:`${r(e.layout.changes)} changes panel`,key:ct("changes"),onClick:()=>n({a:"toggle-changes"})},{id:"files",label:`${r(e.layout.changes&&Fs(e)==="files")} files`,key:ct("files"),onClick:()=>n(e.layout.changes&&Fs(e)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"})},{id:"chat",label:`${r(e.layout.chat)} chat panel`,key:ct("composer"),onClick:()=>n({a:"toggle-chat"})},{id:"terminal",label:`${r(e.layout.term)} terminal`,key:ct("terminal"),onClick:()=>n({a:"toggle-terminal"})},{id:"rail",label:`${r(e.railOpen)} worktree panel`,key:ct("rail"),onClick:()=>n({a:"toggle-rail"})},{id:"design",label:`${r(e.layout.design)} design system`,key:ct("design"),onClick:()=>n({a:"toggle-design"})},{id:"zen",label:"full-bleed preview",key:ct("zen"),onClick:()=>n({a:"toggle-zen"})}],g=[{id:"commands",label:"command palette",key:ct("commands"),onClick:()=>n({a:"open",overlay:{kind:"commands"}})},{id:"keys",label:"settings & shortcuts",key:ct("keys"),onClick:()=>n({a:"open",overlay:{kind:"keys"}})}];if((h=e.self)!=null&&h.restart&&g.push({id:"restart-daemon",label:"restart Toyon",onClick:()=>t==null?void 0:t.send({t:"restart-daemon"})}),e.remote){e.frame==="desk"&&g.push({id:"pair",label:"open on your phone",onClick:()=>n({a:"open",overlay:{kind:"pair"}})});const v=FE(`https://${e.remote.host}`);g.push({id:"toyon-cloud",label:"add to toyon.cloud",onClick:()=>window.open(v,"_blank")})}const k=ro(e)?new Set(["chat","design","zen"]):null;return Nn([l,k?d.filter(v=>!k.has(v.id)):d,g])}function l4(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 Wu(e,t,{sock:n,dispatch:r}){const i=[];e.id!==t&&i.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:"open",overlay:{kind:"archived",repoId:e.id}})},{id:`forget:${e.id}`,label:"forget project…",danger:!0,onClick:()=>{window.confirm(`Forget ${e.name}?
203
+
204
+ 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 Nn([i,a])}const pu={dark:"dark",light:"light",system:"follow system",daylight:"follow daylight"};function c4(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(i=>e(n.name,i))},t.click()}function T1(e,{sock:t,dispatch:n}){var a;const r=e.themePrefs,i=l=>{var c;return((c=e.themes.find(d=>d.id===l))==null?void 0:c.name)??l};return Nn([[{id:"theme",label:"theme…",detail:Cu(r,e.themes,r0(e)).name,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"theme"}})},{id:"appearance",topic:"theme",label:"light or dark…",detail:pu[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:()=>c4((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:i(r.dark),sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"dark"}})},{id:"theme-light",topic:"theme",label:"light slot override…",detail:i(r.light),sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"light"}})}]])}function u4(e,t,n,r,i){const a=[],l=(p,h,v,b,_)=>a.push({id:p,label:h,hint:b,run:v,sub:_}),c=(p,h)=>{for(const v of p){if(!Gi(v)||v.disabled!==void 0||v.checked)continue;const b=v.key??(typeof v.detail=="string"?v.detail:void 0),_=h?`${h.scope}:${v.id}`:v.id,E=v.topic?`${v.topic}: ${v.label}`:v.label;l(_,h?`${E} · ${h.name}`:E,v.onClick,b,v.sub)}},d={sock:n,dispatch:t},g=r,k=g==null?void 0:g.worktree.id;if(c(N1(e,d).filter(p=>!Gi(p)||p.id!=="commands")),i&&c(Wu(i,i.id,d),{scope:"project",name:i.name}),k&&!ro(e)&&(l("pick",e.picking==="chat"?"cancel element picker":"pick an element for the chat",()=>il(k,e.picking,t,"chat"),ct("pick")),l("inspect",e.picking==="code"?"cancel element picker":"pick an element to open its code",()=>il(k,e.picking,t,"code"),ct("inspect")),l("reload","reload preview",()=>Rt.post(k,{type:"reload"}))),c(T1(e,d)),g&&k){const p=e.repos.find(h=>h.id===g.worktree.repoId)??null;c(rb(g,p,e,d,{hostname:e.hostname}),{scope:"wt",name:ou(g,p)});for(const h of g.procs)c(Dh(h,k,d))}e.visible.forEach((p,h)=>{if(p.worktree.id===k)return;const v=p.worktree.variant;l(`go:${p.worktree.id}`,`switch to ${ou(p,i)}${v?` (v${v.index}/${v.of})`:""}`,()=>t({a:"activate",id:p.worktree.id}),yE(h,e.visible.length))});for(const p of e.repos)p.id!==(i==null?void 0:i.id)&&l(`repo:${p.id}`,`switch to project ${p.name}`,()=>t({a:"activate-repo",id:p.id}));return a}function C1(){const e=Ve(),t=Ge(),n=z(C=>C.picking),r=z(C=>C.layout),i=z(C=>C.chatSide),a=z(C=>C.railOpen),l=z(C=>C.themePrefs),c=z(C=>C.themes),d=z(C=>C.systemDark),g=z(C=>C.daylight),k=z(C=>C.rows),p=z(C=>C.visible),h=z(C=>C.activeId),v=z(C=>C.activeRepoId),b=z(C=>C.repos),_=z(C=>C.agents),E=z(C=>C.defaultAgent),j=z(C=>C.shipping),x=z(C=>C.remote),H=z(C=>C.frame),B=z(C=>C.self),re=z(C=>C.archivedPage),F=z(C=>C.archived);return T.useMemo(()=>{const C={picking:n,layout:r,chatSide:i,railOpen:a,themePrefs:l,themes:c,systemDark:d,daylight:g,rows:k,visible:p,activeId:h,activeRepoId:v,repos:b,agents:_,defaultAgent:E,shipping:j,remote:x,frame:H,self:B,archivedPage:re,archived:F,hostname:location.hostname};return u4(C,e,t,Yt(C,h),Gs(C,v))},[n,r,i,a,l,c,d,g,k,p,h,v,b,_,E,j,x,H,B,re,F,e,t])}function j1(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=[];for(const i of e){const a=Dp(i.label.toLowerCase(),n);a>0&&r.push({c:i,score:a})}return r.sort((i,a)=>a.score-i.score),r.map(i=>i.c)}function Dp(e,t){const n=Fh(e,t);if(!n)return 0;let r=0,i=0,a=-1;for(const l of n)i=l===a+1?i+1:1,r+=i+(A1(e,l)?3:0),a=l;return r+Math.max(0,40-e.length/4)}const A1=(e,t)=>t===0||/[\s:\-–—·/.(]/.test(e[t-1]);function Fh(e,t){const n=e.toLowerCase(),r=[];let i=0;for(const a of t.toLowerCase()){let l=-1;if(n[i]===a)l=i;else if(a===" ")l=n.indexOf(" ",i);else for(let c=n.indexOf(a,i);c!==-1;c=n.indexOf(a,c+1))if(A1(n,c)){l=c;break}if(l===-1)return null;r.push(l),i=l+1}return r}const Us=(e,...t)=>{const n=e.trim().toLowerCase();return!n||t.some(r=>r==null?void 0:r.toLowerCase().includes(n))};function d4({c:e,query:t}){const n=t.trim();return f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"picker-name",children:["/",cl(e.name,n?Fh(e.name,n):null,0)]}),f.jsx("span",{className:"picker-desc row-dim",children:e.description})]})}function On({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 f4(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 p4=/ \| | - | \u2013 | \u2014 | \u00b7 |: /,h4=/^(\d+|[0-9a-f]{8}-[0-9a-f-]{27}|[0-9a-f]{12,})$/i,m4=/^[[:$*{]|\[/;function g4(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(p4).map(l=>l.trim()).filter(Boolean)})),i=new Map;for(const{path:a,parts:l}of r)for(const c of l)i.set(c,(i.get(c)??new Set).add(a));for(const{path:a,parts:l}of r){const c=l.filter(d=>{var g;return(((g=i.get(d))==null?void 0:g.size)??0)<2});c.length>0&&t.set(a,c.join(" "))}return t}function Bh(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(h4.test(r)||m4.test(r))continue;const i=r.replace(/[-_.]+/g," ").trim();if(i)return i[0].toUpperCase()+i.slice(1)}return"Home"}const np=8,k4=3,y4=50,v4=3;function w4(e,t,n=[]){const r=new Map,i=[],a=new Map;for(const l of(t==null?void 0:t.routes)??[]){if(l.endpoint)continue;const c=l.dynamic?RA(l.path):null;c?(i.push(c),a.set(l.path,l)):r.set(l.path,l)}return{history:e,statics:r,templates:i,templateRoutes:a,unseen:(t==null?void 0:t.unseen)??{},titles:g4(e),links:new Map(n.map(l=>[l.path,l.text]))}}function I1(e){if(!e)return"/";try{const t=new URL(e);return t.pathname+t.search+t.hash}catch{return"/"}}function b4(e){const t=e.trim();return/^[/?#]/.test(t)?t:`/${t}`}function x4(e,t){const n=/^[/?#]/.test(t)?e:e.replace(/^\//,"");return t&&n.toLowerCase().startsWith(t.toLowerCase())?n:null}const R1=e=>/^\[\[?\.\.\.|^\*$|^\$$/.test(e),Ha=e=>R1(e)||/[[:$*{]/.test(e)&&!/^[^[{:$*]+\?$/.test(e),_4=e=>Tu(`/${e}`).text.slice(1),Uh=e=>e.split("/").filter(Boolean);function Hh(e,t){const n=t.startsWith("/"),r=t.replace(/^\//,"").split("/"),i=Uh(e);let a="";const l=[],c=p=>{const h=_4(p);l.push([a.length,a.length+h.length]),a+=h};for(let p=0;p<r.length;p++){const h=r[p],v=i[p];if(v===void 0)return null;if(p<r.length-1){if(R1(v))return{show:t,accept:t};if(Ha(v)){if(!h)return null}else if(h.toLowerCase()!==v.toLowerCase())return null;a+=`${Ha(v)?h:v}/`;continue}if(Ha(v))h?a+=h:c(v);else{if(!v.toLowerCase().startsWith(h.toLowerCase()))return null;a+=v}}for(const p of i.slice(r.length))a+="/",Ha(p)?c(p):a+=p;const d=n?1:0,g=(n?"/":"")+a,k=l[0];return{show:g,accept:k?g.slice(0,k[0]+d):g,params:l.map(([p,h])=>[p+d,h+d])}}function E4(e,t){const n=Hh(e,t);return n?n.accept.length>t.length?n.accept:t:Tu(e).literal}function O1(e,t){if(e.kind==="go")return null;if(e.template){const n=Hh(e.path,t);return n&&n.show.length>t.length?n:null}return x4(e.path,t)}const S4=e=>e.trim().replace(/^\//,"").toLowerCase();function $1(e,t){for(let n=0;n<e.length;n++)if("/-_.#".includes(e[n])&&e.startsWith(t,n+1))return!0;return!1}function N4(e,t,n){const r=e.replace(/^\//,"").toLowerCase(),i=t.toLowerCase();return r===n?100:r.startsWith(n)?80:$1(r,n)?60:i.startsWith(n)?50:i.split(/\s+/).some(a=>a.startsWith(n))?45:r.includes(n)||i.includes(n)?20:0}function T4(e,t){const{text:n,literal:r}=Tu(e);return r.replace(/^\//,"").toLowerCase().startsWith(t)?80:Hh(e,t)?70:$1(n.replace(/^\//,"").toLowerCase(),t)?60:0}function C4(e,t){const n=Uh(e).findIndex(Ha);return n>=0&&t.split("/").length>n}function Ya(e,t,n){var c;const r=e.statics.get(t),i=r?null:OA(e.templates,t),a=(r==null?void 0:r.file)??(i?(c=e.templateRoutes.get(i.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)||Bh(t),template:!1,visited:n<Number.POSITIVE_INFINITY,...a?{file:a}:{},...l?{badge:l}:{},rank:n,group:(i==null?void 0:i.path)??t,score:0}}function M1(e,t){const n=e.unseen[t.file];return{kind:"page",path:t.path,title:Bh(t.path),template:!0,visited:!1,file:t.file,...n?{badge:n}:{},rank:Number.POSITIVE_INFINITY,group:t.path,score:0}}function Hc({rank:e,group:t,score:n,...r}){return r}const hu=e=>Uh(e).length,mu=e=>e.badge==="new"?0:e.badge==="changed"?1:2;function j4(e,t){const n=new Set,r=[];e.history.forEach((k,p)=>{if(k.path===t)return;const h=Ya(e,k.path,p);n.has(h.group)||(n.add(h.group),r.push(h))});const i=new Set(r.map(k=>k.path)),a=r.filter(k=>k.badge);for(const[k,p]of e.statics)e.unseen[p.file]&&k!==t&&!i.has(k)&&a.push(Ya(e,k,Number.POSITIVE_INFINITY));for(const k of e.templateRoutes.values())e.unseen[k.file]&&!n.has(k.path)&&a.push(M1(e,k));a.sort((k,p)=>mu(k)-mu(p)||k.rank-p.rank);const l=r.filter(k=>!k.badge),c=a.slice(0,np-Math.min(k4,l.length));for(const k of l)c.length<np&&c.push(k);const d=new Set(c.map(k=>k.path)),g=[...e.statics.keys(),...[...e.links.keys()].filter(k=>!e.statics.has(k))].filter(k=>k!==t&&!d.has(k)&&!i.has(k)).sort((k,p)=>hu(k)-hu(p)||(k<p?-1:k>p?1:0));for(const k of g){if(c.length>=np)break;c.push(Ya(e,k,Number.POSITIVE_INFINITY))}return c.map(Hc)}function A4(e,t,n){var p;const r=S4(t),i=b4(t),a=new Map;e.history.forEach((h,v)=>{h.path!==n&&a.set(h.path,Ya(e,h.path,v))});for(const h of[...e.statics.keys(),...e.links.keys()])h!==n&&!a.has(h)&&a.set(h,Ya(e,h,Number.POSITIVE_INFINITY));const l=[];for(const h of a.values()){const v=N4(h.path,h.title,r);v>0&&l.push({...h,score:v})}let c=null;for(const h of e.templates){const v=e.templateRoutes.get(h.path);if(!c&&!e.statics.has(i)&&h.re.test(i)){c=v;continue}const b=T4(h.path,r);b>=60&&l.push({...M1(e,v),score:b})}l.sort((h,v)=>v.score-h.score||h.rank-v.rank||mu(h)-mu(v)||hu(h.path)-hu(v.path)||(h.path<v.path?-1:h.path>v.path?1:0));const d=new Map,g=[];for(const h of l){if(!h.template&&h.group!==h.path){const v=d.get(h.group)??0;if(v>=v4&&!C4(h.group,r))continue;d.set(h.group,v+1)}if(g.push(h),g.length>=y4)break}if(g.some(h=>h.score===100))return g.map(Hc);const k={kind:"go",path:i,title:Bh((c==null?void 0:c.path)??i)};return c||(((p=g[0])==null?void 0:p.score)??0)<80?[k,...g.map(Hc)]:[...g.map(Hc),k]}function P1(e,{query:t,current:n,here:r}){return t===n||t.trim()===""?j4(e,r):A4(e,t,r)}const I4=[],R4=[];function L1(e,t){const n=z(a=>(t?a.visits[t]:void 0)??I4),r=It(e,"pages"),i=It(e,"links");return ft([e],()=>{e0(r)&&Rt.post(e,{type:"links"})}),T.useMemo(()=>w4(n,r,i),[n,r,i])}function O4({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}=Tu(e.path),r=[];let i=0;for(const[a,l]of n)a>i&&r.push(t.slice(i,a)),r.push(f.jsx("span",{className:"bar-route-param",children:t.slice(a,l)},a)),i=l;return i<t.length&&r.push(t.slice(i)),f.jsx("span",{className:"bar-route-path row-dim",children:r})}function D1({row:e}){return f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"picker-label",children:e.title}),f.jsx(O4,{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 z1=e=>e.kind==="page"&&e.file?e.file:e.path,F1=(e,t)=>e.kind==="page"&&e.template?E4(e.path,t):null,B1=e=>e.kind==="page"&&e.template?"fills in the parameter":"goes there";function U1(e,t,n){return e.kind!=="page"?[]:Mu([...e.file&&t.dir?vi({id:t.worktreeId,dir:t.dir},e.file,{},n):[],D0,...e.visited?f4(t.repoId,e.path,n):[]])}function $4({worktreeId:e,repoId:t,url:n}){const r=Ve(),i=Ge(),a=z(h=>{const v=Yt(h,e);return v?v.worktree.path:null}),l=L1(e,t),c=I1(n),d=n?Nu(n):null,g=T.useCallback((h,v)=>P1(l,{query:v,current:c,here:d}),[l,c,d]),k=T.useCallback(h=>h===c||h.trim()==="",[c]),p=()=>r({a:"close"});return f.jsx(yr,{anchored:{matchWidth:0},items:R4,filter:g,initialQuery:c,selectOnMount:!0,idleWhen:k,onIdlePick:()=>{Rt.post(e,{type:"reload"}),p()},keyOf:h=>`${h.kind}:${h.path}`,rowClass:()=>"picker-row",rowTitle:z1,completionOf:(h,v)=>k(v)?null:O1(h,v),narrowTo:F1,onPick:h=>{Rt.post(e,{type:"navigate",path:h.path}),p()},onBack:p,rowMenu:h=>U1(h,{worktreeId:e,repoId:t,dir:a},{sock:i,dispatch:r}),placeholder:"type a path",keys:h=>({complete:"completes the path",pick:h?B1(h):"reloads",back:"closes"}),empty:"no pages yet; type a path",row:h=>f.jsx(D1,{row:h})})}function H1(e,t){const n=t.trim();return f.jsx(On,{label:cl(e.label,n?Fh(e.label,n):null,0),hint:e.hint&&f.jsx(Zr,{k:e.hint})})}function Z1({anchored:e,trailing:t}){const n=Ve(),r=C1(),i=z(a=>{var l;return((l=a.paletteReturn)==null?void 0:l.mode)==="commands"?a.paletteReturn.q:""});return f.jsx(yr,{anchored:e,trailing:t,items:r,filter:j1,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:i,empty:"no matching command",row:(a,l,c)=>H1(a,c)})}function W1(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),i=e.map(l=>{const c=n.get(l)??(r.some(d=>l.startsWith(d))?{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("/")&&i.push({path:l.path,status:l});return i}function K1(e,t,n,r=50){const i=W1(e,t),a=n.trim().toLowerCase();if(!a){const c=new Map(t.map((p,h)=>[p.path,h])),d=p=>{var h;return c.get(((h=p.status)==null?void 0:h.path)??"")??c.get(p.path)??Number.MAX_SAFE_INTEGER},g=i.filter(p=>p.status).sort((p,h)=>d(p)-d(h)||p.path.localeCompare(h.path)),k=i.filter(p=>!p.status).sort((p,h)=>p.path.localeCompare(h.path));return{rows:[...g,...k].slice(0,r),changed:Math.min(g.length,r)}}const l=V1(i,a);return l.sort((c,d)=>d.score-c.score||c.row.path.localeCompare(d.row.path)),{rows:l.slice(0,r).map(c=>c.row),changed:0}}function G1(e,t){const n=e.toLowerCase(),r=Ov(n,t);return r<=0?0:Ov(n.slice(n.lastIndexOf("/")+1),t)>0?r+10:r}function V1(e,t){const n=[];for(const r of e){const i=G1(r.path,t);i>0&&n.push({row:r,score:r.status?i+4:i})}return n}function M4(e,t,n,r,i){const a=r.trim().toLowerCase();if(!a)return K1(e,n,r,i).rows.map(d=>({kind:"file",path:d.path,status:d.status}));const l=V1(W1(e,n),a).map(({row:d,score:g})=>({row:{kind:"file",path:d.path,status:d.status},score:g}));for(const d of t){const g=G1(d,a);g>0&&l.push({row:{kind:"folder",path:d},score:g})}const c=d=>d.kind==="folder"?1:0;return l.sort((d,g)=>g.score-d.score||c(d.row)-c(g.row)||d.row.path.localeCompare(g.row.path)),l.slice(0,i).map(d=>d.row)}function P4(e,t){const n=e.toLowerCase(),r=[];let i=0;for(const a of t.toLowerCase()){const l=n.indexOf(a,i);if(l===-1)return null;r.push(l),i=l+1}return r}function Ov(e,t){let n=0,r=0,i=0;for(const a of t){const l=e.indexOf(a,r);if(l===-1)return 0;i=l===r?i+1:1,n+=i+(l===0||e[l-1]==="/"||e[l-1]==="."?3:0),r=l+1}return n+Math.max(0,40-e.length/4)}function L4(e){const t=e.lastIndexOf("/");return t===-1?[e,""]:[e.slice(t+1),e.slice(0,t+1)]}const $v=[],D4=[],z4=[];function F4({worktreeId:e}){var _;const t=Ve(),n=Ge(),r=Sn();ft([e,n],()=>Sh(e,r.getState(),{sock:n,dispatch:t}));const i=w0(e),a=i.files??D4,l=((_=i.git)==null?void 0:_.files)??z4,c=C1(),d=z(E=>{var j;return((j=E.paletteReturn)==null?void 0:j.mode)==="quick-open"?E.paletteReturn.q:""}),g=z(E=>{var x;const j=(x=Yt(E,e))==null?void 0:x.worktree;return j?j.path:null}),k=z(E=>{var j;return((j=Yt(E,e))==null?void 0:j.repoId)??null}),p=z(E=>{var j;return((j=nu(E))==null?void 0:j.worktreeId)===e}),h=L1(e,k),v=i.page.url?Nu(i.page.url):null,b=T.useCallback((E,j)=>j.startsWith(">")?j1(c,j.slice(1)).map(x=>({kind:"cmd",c:x})):j.startsWith("/")?p?P1(h,{query:j,current:"/",here:v}).map(x=>({kind:"page",page:x})):$v:K1(a,l,j).rows.map(x=>({kind:"file",path:x.path,status:x.status})),[c,a,l,p,h,v]);return f.jsx(yr,{items:$v,filter:b,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"?z1(E.page):void 0,completionOf:(E,j)=>E.kind==="page"?O1(E.page,j):null,narrowTo:(E,j)=>E.kind==="page"?F1(E.page,j):null,onPick:(E,j)=>{E.kind==="cmd"?(E.c.sub?t({a:"palette-return",v:{mode:"quick-open",q:j}}):t({a:"close"}),E.c.run()):E.kind==="page"?(Rt.post(e,{type:"navigate",path:E.page.path}),t({a:"close"})):(ar({dispatch:t},{worktreeId:e,path:E.path,view:kl(E.path)}),t({a:"close"}))},onBack:()=>t({a:"close"}),rowMenu:E=>E.kind==="file"&&g?vi({id:e,dir:g},E.path,{},{sock:n,dispatch:t}):E.kind==="page"&&k?U1(E.page,{worktreeId:e,repoId:k,dir:g},{sock:n,dispatch:t}):[],placeholder:"jump to file · type > for commands, / for pages",keys:(E,j)=>j.startsWith("/")?{complete:"completes the path",pick:(E==null?void 0:E.kind)==="page"?B1(E.page):void 0,back:"closes"}:{pick:"opens",back:"closes"},initialQuery:d,empty:E=>E.startsWith(">")?"no matching command":E.startsWith("/")?p?"no pages yet; type a path":"no preview running":"no matches",row:(E,j,x)=>E.kind==="cmd"?H1(E.c,x.slice(1)):E.kind==="page"?f.jsx(D1,{row:E.page}):zp(E.path,E.status,x)})}function zp(e,t,n,r=!1){const[i,a]=L4(e),l=n.trim()?P4(e,n.trim()):null;return f.jsxs(f.Fragment,{children:[f.jsx("span",{className:`xy ${t?bh(t.xy):""}`,children:t?xh(t.xy):""}),f.jsxs("span",{className:"name",children:[cl(i,l,a.length),r&&"/"]}),f.jsx("span",{className:"dir row-dim",children:a&&f.jsxs(f.Fragment,{children:["‎",cl(a,l,0),"‎"]})}),t&&f.jsx(lb,{f:t})]})}const B4=/^[^\s]*$/;function U4(e,t){if(e.startsWith("!"))return null;if(e.startsWith("/")){const a=e.indexOf(" "),l=a===-1?e.length:a;if(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(!B4.test(r))return null;let i=t;for(;i<e.length&&!/\s/.test(e[i]??"");)i++;return{kind:"file",query:r,from:n,to:i}}function H4(e,t,n){return{text:e.slice(0,t.from)+n+e.slice(t.to),caret:t.from+n.length}}function Z4(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),i=r(a=>Dp(a.name,n));return i.length>0?i:r(a=>Dp(a.description,n))}const W4=e=>hl.some(t=>t.id===e);function K4(e){return[...hl.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"},{name:"land",description:e},{name:"archive",description:"archive this worktree once its work has landed"}]}function G4(e,t){const n=new Set(e.map(r=>r.name));return[...e,...t.filter(r=>!n.has(r.name))]}function V4(e,t){const n=/^\/(\S*)([\s\S]*)$/.exec(e);if(!n)return null;const r=n[1]??"";return t.some(i=>i.name===r)?{name:r,args:(n[2]??"").trim()}:null}const Mv=[],q4=[],Y4=new Set(["ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),Q4=e=>({kind:"cmd",c:e});function X4(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 J4(e){return e.kind==="cmd"?`/${e.c.name} `:e.kind==="folder"?`@${e.path}/ `:e.kind==="changes"?"@changes ":`@${e.path} `}function Fp({active:e,draft:t,archived:n,greenfield:r,placement:i="dock"}){var ue,be,Ie,et;const a=i==="screen",l=Ve(),c=Ge(),d=Sn(),g=!!t,k=(e==null?void 0:e.worktree.id)??null,p=e==null?void 0:e.worktree.repoId,h=n?n.id:gl(e),v=It(h,"draft"),b=It(h,"attachments"),_=It(h,"notice"),E=It(h,"mark"),j=(E==null?void 0:E.by)==="walk"?E:void 0,x=It(k,"chat"),H=It(k,"queue"),B=T.useMemo(()=>k&&!g?pb(x):null,[k,g,x]),re=It(k,"askParked"),F=B&&re!==B.id?B:null,C=B&&re===B.id?B:null,L=T.useRef(null),I=hh(),Z=It(I,"page"),V=vl(),{onPaste:K,onPasteKey:le,onPasteKeyUp:de}=P2(h,k),Q=U=>h&&l({a:"set-draft",id:h,text:U}),ce=z(U=>U.clientId),R=z(U=>U.repos.find(Me=>Me.id===(e==null?void 0:e.worktree.repoId))??null),M=z(U=>U.defaultAgent),G=z(U=>U.agentChosen),ne=g||!!r,O=!ne&&!!e&&!e.worktree.agent,ee=ne||O,D=(t==null?void 0:t.agent)??M,q=z(U=>U.agents.find(Me=>Me.id===(ee?D:e==null?void 0:e.worktree.agent))),Te=(q==null?void 0:q.models)??Mv,Ne=(q==null?void 0:q.efforts)??Mv,[je,Re]=x1(D),[Ze,st]=b1(D),Ee=z(U=>U.agents),Tt=(U,Me)=>{if(U===D){Re(Me);return}_1(U,Me),g?l({a:"draft-agent",id:U}):c==null||c.send({t:"set-default-agent",agent:U})},zt=It(k,"model"),Xe=It(k,"effort"),pt=It(k,"usage")??(e==null?void 0:e.usage),[ht]=S1(R),wn=(t==null?void 0:t.profile)??ht,[jt,Ft]=o4(R),te=(e==null?void 0:e.worktree.mode)??dp,pe=z(U=>U.picking),rt=z(U=>U.layout.term),at=G0((e==null?void 0:e.procs)??[]),ut=Wt("composer"),tn=It(k,"files"),Kt=T.useMemo(()=>SR(tn??q4),[tn]),tt=It(k,"git"),qe=(tt==null?void 0:tt.files.length)??(e==null?void 0:e.dirty)??0,nn=(tt==null?void 0:tt.unpushed)??(e==null?void 0:e.unpushed)??0,ie=z(U=>k?U.shipping[k]:void 0),he=z(U=>zs(U,p)),lt=z(U=>he?U.shipping[he.id]:void 0),At=he&&R&&ne?BR(R.defaultBranch,he):null,bt=z(U=>g?CR(U.rows,p,D,M):k),Qt=It(bt,"commands"),vr=Qt.some(U=>U.name==="compact"),bn=(e==null?void 0:e.agent)==="working"||(e==null?void 0:e.agent)==="waiting",Tn=e==null?void 0:e.worktree.lastTurn,Kn=!v.trim()&&b.length===0,lr=!g&&!r&&Kn&&!bn?Tn:void 0,Pt=!g&&!r&&e&&Cs(e.worktree)?e.worktree.landing:void 0,xt=Kn&&!bn?Pt:void 0,hn=qe||(((ue=tt==null?void 0:tt.committed)==null?void 0:ue.length)??0),N=!g&&!r&&Kn&&!bn&&!!e,X=!!(e!=null&&e.worktree.landed)&&qe===0&&((tt==null?void 0:tt.ahead)??0)===0,me=N&&X,xe=N&&!me?e.worktree.pr:void 0,We=(xe==null?void 0:xe.state)==="open"&&(qe>0||nn>0),gt=((be=e==null?void 0:e.worktree.pr)==null?void 0:be.state)==="closed",Ce=Wi((R==null?void 0:R.config)??{}),ge=T.useMemo(()=>K4(Kc(Wi((R==null?void 0:R.config)??{}),R==null?void 0:R.defaultBranch)),[R]),De=vr&&!bn,Ue=()=>k&&(c==null?void 0:c.send({t:"chat",worktreeId:k,text:"/compact"})),kt=()=>[{id:"compact",label:"compact the context",detail:"shrink the chat to a summary",disabled:vr?bn?"wait for the turn to end":void 0:"this agent offers no compact command",onClick:Ue}],[Gn,xn]=T.useState(0),[Cn,cr]=T.useState(null),[ur,io]=T.useState(null),wr=T.useRef(null),yt=h&&!n?U4(v,Gn):null,Ot=yt!==null&&yt.from!==Cn&&!j,Qn=yt==null?void 0:yt.kind,Gr=yt==null?void 0:yt.query,bo=T.useMemo(()=>{if(Gr===void 0)return[];if(Qn==="command")return Z4(G4(ge,Qt),Gr).slice(0,8).map(Q4);const U=[],Me=(tt==null?void 0:tt.files.length)??0;return Me>0&&"changes".startsWith(Gr.toLowerCase())&&U.push({kind:"changes",n:Me}),U.push(...M4(tn??[],Kt,(tt==null?void 0:tt.files)??[],Gr,8)),U},[Qn,Gr,tn,Kt,tt,Qt,ge]),dr=T.useRef(null),Dn=()=>{var U;return(U=L.current??dr.current)==null?void 0:U.focus()},fr=Dn;ft([r?e==null?void 0:e.worktree.id:null],()=>{if(!r)return;const U=requestAnimationFrame(()=>{var Je;const Me=document.activeElement;(!Me||Me===document.body)&&((Je=dr.current)==null||Je.focus())});return()=>cancelAnimationFrame(U)});const so=z(U=>U.focusChat),Gt=T.useRef(so),xo=!!b0();ft([so],()=>{if(so===Gt.current||(Gt.current=so,xo!==!!r))return;const U=requestAnimationFrame(Dn);return()=>cancelAnimationFrame(U)});const _o=C==null?void 0:C.id;ft([_o],()=>{if(!_o||xo!==!!r)return;const U=requestAnimationFrame(()=>{var Je;const Me=document.activeElement;(!Me||Me===document.body)&&((Je=dr.current)==null||Je.focus())});return()=>cancelAnimationFrame(U)});const kn=z(U=>U.walked),Vr=T.useRef(kn);ft([kn],()=>{if(kn===Vr.current||(Vr.current=kn,xo!==!!r))return;const U=requestAnimationFrame(()=>{const Me=document.activeElement;(!Me||Me===document.body||Me.closest(".rail"))&&Dn()});return()=>cancelAnimationFrame(U)});const we=L0({results:bo,keyOf:U=>U.kind==="cmd"?`c:${U.c.name}`:U.kind==="changes"?"changes":`f:${U.path}`,q:(yt==null?void 0:yt.query)??"",listRef:wr,tabPicks:!0,onPick:U=>{if(!yt)return;const{text:Me,caret:Je}=H4(v,yt,J4(U));Q(Me),cr(yt.from),io(U.kind==="cmd"&&U.c.hint?{name:U.c.name,hint:U.c.hint}:null),requestAnimationFrame(()=>{const An=dr.current;An&&(An.focus(),An.setSelectionRange(Je,Je),xn(Je))})}}),Ae=k||n?FP(v):null,ot=ur&&v===`/${ur.name} `?ur.hint:null,it=Ae===""&&e?g?" a command to run in the new worktree's terminal":` a command to run in ${e.worktree.title}; its output goes on the transcript`:null,Vt=ot??it,Bt=(e==null?void 0:e.worktree.title)??"untitled",jn=(Ie=Tn==null?void 0:Tn.recap)==null?void 0:Ie.text,Mr=()=>{k&&wi(c,l,{t:"land",worktreeId:k})},cn=()=>{k&&(c==null||c.send({t:"judge",worktreeId:k}))},mn=!!((et=R==null?void 0:R.config.check)!=null&&et.trim()),br=N&&!ne&&Cs(e.worktree)&&!X&&!gt&&hn>0&&(!Pt||!!Pt.stale),zn="Archive this worktree when you are done here; the rail's archived section brings it back with its chat.",pr=We?"update":"land",Xn=We&&xe?`Commit, take ${(R==null?void 0:R.defaultBranch)??"main"} in and push the branch; PR #${xe.number} takes the new commits.`:`${Kc(Ce,R==null?void 0:R.defaultBranch)}.`,yn=k?me?{word:"archive",line:`landed on ${(R==null?void 0:R.defaultBranch)??"main"}.`,tip:zn,run:()=>Vi(c,l,[k])}:(xe==null?void 0:xe.state)==="open"&&!We?ib(xe)?{word:"merge",line:Cc(jn??Fi(xe)),tip:`${Fi(xe)} Merge the PR now, by the method the repo allows.`,run:Mr,ships:!0}:{word:"view",line:Cc(jn??Fi(xe)),tip:`${Fi(xe)} Open the PR on GitHub.`,run:()=>window.open(xe.url,"_blank")}:(xe==null?void 0:xe.state)==="closed"?{word:"archive",line:Fi(xe),tip:`${Fi(xe)} ${zn}`,run:()=>Vi(c,l,[k])}:br?{word:"check",line:(Pt==null?void 0:Pt.subject)??Cc(jn??WR(hn)),tip:Pt!=null&&Pt.stale?`The work changed since this was written. ${mn?"Run the check again and refresh":"Refresh"} the message.`:`${mn?"Run the repo's check here, then write":"Write"} the recap and the commit message.`,run:cn}:xt!=null&&xt.ready&&!Zf(xt)?{word:pr,line:xt.subject??Cc(jn??(Uy(xt,hn)||"ready")),tip:[Uy(xt,hn),ZR((R==null?void 0:R.defaultBranch)??"main",e==null?void 0:e.behind),Xn,xt.subject?"Tab edits the message first.":""].filter(Boolean).join(" "),run:Mr,ships:!0}:null:null,xr=xt?Zf(xt):null,_r=n?n.restorable?`message agent on ${n.title}; sending restores it first`:"its commits were not kept, so it cannot come back":e?yn?"":xr||(xe?Fi(xe):lr?Nh(lr):r?`describe ${Bt}…`:ne?"describe a change":a?`message agent on ${Bt}`:`message agent on ${Bt}; / for a command, ! for a shell command`):"no worktree selected",Jn=v!==""||Vt||!e?null:yn?(yn.word==="land"||yn.word==="update"||yn.word==="check")&&xt?KR(xt,hn):null:xe||xr?jn??(xt==null?void 0:xt.subject)??null:null,Fn=T.useRef(!1);T.useEffect(()=>{const U=Ot&&!Fn.current;Fn.current=Ot,U&&((yt==null?void 0:yt.kind)==="file"&&k?Sh(k,d.getState(),{sock:c,dispatch:l}):(yt==null?void 0:yt.kind)==="command"&&bt&&Qt.length===0&&(c==null||c.send({t:"list-commands",worktreeId:bt})))},[Ot,yt==null?void 0:yt.kind,Qt.length,k,bt,c,d,l]);const Eo=()=>{if(!e)return;const U=[],Me=Z;if(Me.url)try{const qt=new URL(Me.url);U.push(`current route: ${qt.pathname}${qt.search}`)}catch{}Me.title&&U.push(`page title: ${Me.title}`),Me.errors.length&&U.push(`recent console errors:
205
+ ${Me.errors.map(qt=>`- ${qt}`).join(`
206
+ `)}`);const Je=[];r&&Je.push(qP(e.worktree.title,R==null?void 0:R.configFile)),U.length>0&&Je.push(`What the user is looking at right now:
207
+ ${U.join(`
208
+ `)}`);const An=UP(x);return An&&Je.push(An),Je.length>0?Je:void 0},vt=U=>{ne?Ft(U):k&&U!==te&&(c==null||c.send({t:"set-worktree-mode",worktreeId:k,mode:U}))},ze=U=>h&&l({a:"notice",id:h,text:U}),Ro=U=>{if(!e||!k)return;if(U==="archive"){X||gt?Vi(c,l,[k]):ze("archive is for a landed worktree; this one has not landed");return}if(U==="check"){ne||!Cs(e.worktree)?ze("nothing to check from here"):bn?ze("wait for the turn to end"):hn===0?ze("nothing to check: no changes here"):cn();return}const Me=Pt?Zf(Pt):null;ne||!Cs(e.worktree)?ze("nothing to land from here"):X?ze(`already landed on ${(R==null?void 0:R.defaultBranch)??"main"}`):bn?ze("wait for the turn to end"):Me?ze(Me):Pt!=null&&Pt.stale?ze("the work changed since this was checked; check again first"):Mr()},Xt=()=>{if(!h||Kn)return;if(n){if(!n.restorable)return;if(Ae!==null){ze("nothing runs here until it is restored");return}const Oo=b.length?b.map(vy):void 0;c==null||c.send({t:"restore-worktree",archiveId:n.id,clientId:ce,message:{text:v.trim(),attachments:Oo}}),b.length&&l({a:"clear-attachments",id:h}),l({a:"restoring",id:h,text:v.trim()}),Q("");return}if(!e||!k)return;if(Ae!==null){Ae&&g?l({a:"term-run",id:k,command:Ae}):Ae&&(c==null||c.send({t:"exec",worktreeId:k,command:Ae})),Q("");return}const U=V4(v,ge),Me=U&&W4(U.name)?U.name:void 0;if(U&&!Me){Ro(U.name),Q("");return}if(Me&&!(U!=null&&U.args)){vt(Me),Q("");return}if(t!=null&&t.batch&&b.length){ze("a batch takes no attachments; remove them or turn batch off");return}if(r&&!G){ze("choose an agent above first");return}const Je=U?U.args:v.trim(),An=Eo(),qt=b.length?b.map(vy):void 0;if(Me&&vt(Me),ne){const Oo=Hs(e.worktree)?{worktreeId:k}:{},ea={clientId:ce,repoId:e.worktree.repoId,context:An,attachments:qt,agent:D,profile:wn,mode:Me??jt,...je?{model:je}:{},...Ze?{effort:Ze}:{},...t0(t)?{carry:!0}:{}};if(D!==M&&(c==null||c.send({t:"set-default-agent",agent:D})),t!=null&&t.batch)c==null||c.send({t:"batch-worktrees",repoId:e.worktree.repoId,prompt:Je,agent:D,...je?{model:je}:{},...Ze?{effort:Ze}:{}});else if(t&&t.variants>1){const qu=Math.random().toString(36).slice(2,10);for(let So=0;So<t.variants;So++)c==null||c.send({t:"create-worktree",...ea,...So===0?Oo:{},prompt:Je,variant:{group:qu,index:So+1,of:t.variants}})}else c==null||c.send({t:"create-worktree",...ea,...Oo,prompt:Je})}else O&&(c==null||c.send({t:"set-worktree-model",worktreeId:k,model:je}),c==null||c.send({t:"set-worktree-effort",worktreeId:k,effort:Ze})),c==null||c.send({t:"chat",worktreeId:k,clientId:ce,text:Je,context:An,attachments:qt});b.length&&l({a:"clear-attachments",id:h}),Q(""),r&&l({a:"show-chat"})},Nt=z(U=>U.autoSend);ft([Nt,k],()=>{!Nt||Nt!==k||!v.trim()||xo!==!!r||(l({a:"auto-sent"}),Xt())});const Er=()=>{const U=b[b.length-1];return!h||!U?!1:(l({a:"detach",id:h,key:U.key}),!0)},Bn=U=>{h&&(l({a:"walk",id:h,walk:U.walk,text:U.text}),requestAnimationFrame(()=>{var Me;(Me=dr.current)==null||Me.setSelectionRange(U.text.length,U.text.length),xn(U.text.length)}))},ye=()=>{h&&j&&l({a:"walk",id:h,walk:null,text:v})},A=ne?[]:x.map(U=>U.kind==="user"?U.attachments:void 0),$=e?e.worktree.path:null,J=e==null?void 0:e.worktree.plan;return f.jsxs("div",{className:"composer chat-input",children:[J&&e&&f.jsxs("div",{className:"hint composer-plan",children:[f.jsx(Ct,{name:"text",className:"icon-inline"}),f.jsx("span",{className:"composer-plan-path",children:J}),f.jsx($e,{className:"composer-plan-open","data-tip":"Read the plan in the editor pane",onClick:()=>ar({dispatch:l},{worktreeId:e.worktree.id,path:J,view:"preview"}),children:"open"})]}),h&&gE(b,mE(A)).map(([U,Me])=>{const Je=()=>l({a:"detach",id:h,key:U.key});return U.kind==="image"?f.jsx(s1,{src:N2(U),n:Me,name:U.name,width:U.width,height:U.height,bytes:U.bytes,onRemove:Je},U.key):U.kind==="paste"?f.jsx(a1,{n:Me,name:U.name,source:U.source,lines:U.lines,chars:U.chars,preview:U.preview,text:U.text,onRemove:Je},U.key):f.jsx(l1,{pick:U,dir:$,tipText:U.html,onHover:An=>I&&Rt.post(I,An?{type:"highlight-selector",selector:U.selector,label:_h(U)}:{type:"highlight-clear"}),onOpen:(An,qt)=>k&&Bu(d,c,k,An,qt),onRemove:Je},U.key)}),Ot&&yt&&f.jsx(GP,{results:bo,keyOf:U=>U.kind==="cmd"?`c:${U.c.name}`:U.kind==="changes"?"changes":U.kind==="folder"?`d:${U.path}`:`f:${U.path}`,rowClass:U=>U.kind==="file"||U.kind==="folder"?"qo-file":U.kind==="changes"?"picker-row":"picker-row picker-cmd",nav:we,listRef:wr,empty:X4(yt.kind,tn,Qt.length,bt!==null),row:U=>U.kind==="file"?zp(U.path,U.status,yt.query):U.kind==="folder"?zp(U.path,void 0,yt.query,!0):U.kind==="changes"?f.jsx(On,{label:"@changes",hint:`${U.n} uncommitted ${U.n===1?"file":"files"}`}):f.jsx(d4,{c:U.c,query:yt.query})}),F&&k?f.jsx(WM,{item:F,worktreeId:k,rootRef:L},F.id):f.jsxs("div",{className:Ke("composer-field",Ae!==null&&"shell",j&&"recalled"),children:[f.jsx(wl,{size:"lg",bare:!0,font:Ae!==null?"mono":"ui",ref:dr,value:v,onChange:U=>{Q(U.target.value),xn(U.target.selectionStart??U.target.value.length),we.setIndex(0),cr(null)},onKeyUp:U=>{de(),xn(U.currentTarget.selectionStart??0)},onClick:U=>{xn(U.currentTarget.selectionStart??0),ye()},onPaste:K,onKeyDown:U=>{if(le(U),!U.nativeEvent.isComposing){if(Ot){if(U.key==="Escape"){U.preventDefault(),U.stopPropagation(),cr((yt==null?void 0:yt.from)??null);return}if(we.onKeyDown(U))return}if((U.key==="ArrowUp"||U.key==="ArrowDown")&&!U.altKey&&!U.ctrlKey&&!U.metaKey){const Me=H.at(-1);if(U.key==="ArrowUp"&&!j&&v===""&&k&&!g&&Me!==void 0){U.preventDefault(),c==null||c.send({t:"unqueue",worktreeId:k,index:H.length-1}),Bn({walk:null,text:Me});return}const Je=k?HP(x,j??null,v,U.key==="ArrowUp"?"up":"down"):null;if(Je){U.preventDefault(),(Je.walk!==j||Je.text!==v)&&Bn(Je);return}}if(j&&U.key==="Escape"){U.preventDefault(),U.stopPropagation(),Bn({walk:null,text:j.from});return}if(U.key==="Escape"&&bn&&k&&!g){U.preventDefault(),U.stopPropagation(),c==null||c.send({t:"stop-agent",worktreeId:k});return}if(j&&Y4.has(U.key)&&ye(),U.key==="Tab"&&!U.shiftKey&&v===""&&(xt!=null&&xt.subject)){U.preventDefault(),l({a:"edit-commit"});return}U.key==="Enter"&&!U.shiftKey?(U.preventDefault(),Xt()):U.key==="Backspace"&&v===""&&Er()&&U.preventDefault()}},placeholder:Jn||yn?"":_r,disabled:!e&&!(n!=null&&n.restorable)}),Vt&&f.jsxs("div",{className:"composer-ghost","aria-hidden":"true",children:[f.jsx("span",{className:"picker-typed",children:v}),Vt]}),(Jn||yn)&&f.jsxs("div",{className:"composer-ghost","aria-hidden":yn?void 0:"true",children:[f.jsx("span",{className:"composer-placeholder",children:yn?f.jsxs(f.Fragment,{children:[f.jsx($e,{variant:"inline",tone:"strong",className:"composer-verb",busy:!!yn.ships&&ie==="land",disabled:!!yn.ships&&!!ie&&ie!=="land",...Et(yn.tip,void 0,{placement:"top"}),onClick:yn.run,children:yn.word}),`: ${yn.line}`]}):_r}),Jn&&f.jsxs(f.Fragment,{children:[`
209
+ `,f.jsx("span",{className:"composer-subline",children:Jn})]})]})]}),_&&f.jsx("div",{className:"hint composer-notice",role:"status",children:_}),!F&&f.jsxs("div",{className:"hint composer-knobs",children:[f.jsxs("span",{className:"spawn-left",children:[ee?Ee.length>1?f.jsx(E1,{agents:Ee,agent:D,model:je,onChange:Tt,onClose:fr}):f.jsx(Lp,{models:Te,value:je,onChange:Re,onClose:fr}):e&&f.jsx(Lp,{models:Te,value:e.worktree.model??"",current:zt,onChange:U=>c==null?void 0:c.send({t:"set-worktree-model",worktreeId:e.worktree.id,model:U}),onClose:fr}),ee?f.jsx(Pp,{efforts:Ne,value:Ze,onChange:st,onClose:fr}):e&&f.jsx(Pp,{efforts:Ne,value:e.worktree.effort??"",current:Xe,onChange:U=>c==null?void 0:c.send({t:"set-worktree-effort",worktreeId:e.worktree.id,effort:U}),onClose:fr}),ne?f.jsx(Rv,{value:jt,onChange:Ft,onClose:fr}):e&&f.jsx(Rv,{value:te,onChange:U=>c==null?void 0:c.send({t:"set-worktree-mode",worktreeId:e.worktree.id,mode:U}),onClose:fr}),pt&&!ne&&k&&f.jsx(Dt,{icon:f.jsx(VP,{fraction:pt.used/pt.size}),tone:"chrome",label:`${Math.round(100*pt.used/pt.size)}% of context`,detail:`${su(pt.used)} of ${su(pt.size)}${pt.cost!==void 0?` · ${sl(pt.cost)} this session`:""}${De?" · click to compact":""}`,onClick:U=>{De?Ue():ut.openUnder(U.currentTarget,kt)},...ut.contextMenu(kt)})]}),f.jsxs("span",{className:"spawn-tools",children:[!r&&!n&&!a&&f.jsx(Dt,{icon:"terminal",tone:"chrome",on:rt,className:"composer-term",disabled:!e,label:at?at.tip:"Terminal",hint:ct("terminal"),badge:at&&f.jsx("span",{className:"composer-term-dot"}),onClick:()=>{l(at&&!rt&&k?{a:"term-stream",id:k,stream:at.stream}:{a:"toggle-terminal"})},...ut.contextMenu(()=>e&&k?WP(e.procs,k,rt,{sock:c,dispatch:d.dispatch}):[])}),!r&&!V&&!n&&!a&&f.jsx(Dt,{icon:"pick",label:"Pick an element on the page to attach",hint:ct("pick"),on:pe==="chat",disabled:!I,onClick:()=>I&&il(I,pe,l,"chat")})]})]}),(At&&he||C&&k)&&f.jsxs("div",{className:"composer-notes",children:[C&&k&&f.jsxs("div",{className:"hint composer-note",children:[f.jsx("span",{children:"the agent is waiting on a question"}),f.jsx($e,{variant:"outline",onClick:()=>{l({a:"ask-unpark",id:k}),l({a:"focus-chat"})},children:"answer"})]}),At&&he&&f.jsxs("div",{className:"hint composer-note",children:[f.jsx("span",{children:At}),UR(he)&&f.jsx($e,{variant:"outline",busy:lt==="pull-main",disabled:!!lt||he.dirty>0,"data-tip":he.dirty>0?`commit or discard the changes on ${R==null?void 0:R.defaultBranch} first`:"Fast-forward main to origin",onClick:()=>wi(c,l,{t:"pull-main",worktreeId:he.id}),children:"pull"})]})]})]})}function eL({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 tL=[1,2,3];function nL({draft:e,lead:t}){const n=Ve(),r=z(c=>Gs(c,t==null?void 0:t.repoId)),[i]=S1(r),a=z(c=>{var d;return((d=zs(c,t==null?void 0:t.repoId))==null?void 0:d.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($e,{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:[tL.map(c=>f.jsx($e,{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(s4,{repo:r,value:e.profile??i,onChange:c=>n({a:"draft-profile",profile:c})})})]}),t&&r&&a>0&&f.jsx("div",{className:"draft-notes",children:f.jsxs(eL,{className:"hint draft-note",checked:t0(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 gu({placement:e,className:t,width:n,archived:r}){const i=Ve(),a=Vo(),l=l2(),c=qs(),d=e==="centre"&&!r&&(c!=null&&c.assumed)?c:null,g=z(h=>h.dragFiles),k=Sn(),p=T.useMemo(()=>O2(k),[k]);return f.jsxs("div",{className:Ke(e==="dock"?"chat-dock":e==="centre"?"chat-centre":"chat-screen",t,g&&"drop-over"),style:n===void 0?void 0:{width:n},...p,ref:h=>{var v;h?Fc.el=h:(v=Fc.el)!=null&&v.isConnected||(Fc.el=null)},children:[r?f.jsx(Iv,{active:null,archived:r,tail:f.jsx(aO,{item:r})}):f.jsx(Iv,{active:a,lead:d&&f.jsxs("p",{className:"hint chat-centre-note",children:[d.name," has ",f.jsx("code",{children:d.assumed})," and no dev server, so it is chat only for now."," ",f.jsx($e,{variant:"inline",onClick:()=>i({a:"open",overlay:{kind:"setup",repoId:d.id}}),children:"add a dev server"})]})}),!r&&l&&f.jsx(nL,{draft:l,lead:a}),r?f.jsx(Fp,{active:null,archived:r,placement:e}):f.jsx(Fp,{active:a,draft:l,placement:e})]})}const rL="modulepreload",oL=function(e){return"/"+e},Pv={},Bp=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let l=function(g){return Promise.all(g.map(k=>Promise.resolve(k).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));i=l(n.map(g=>{if(g=oL(g),g in Pv)return;Pv[g]=!0;const k=g.endsWith(".css"),p=k?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${g}"]${p}`))return;const h=document.createElement("link");if(h.rel=k?"stylesheet":rL,k||(h.as="script"),h.crossOrigin="",h.href=g,d&&h.setAttribute("nonce",d),document.head.appendChild(h),k)return new Promise((v,b)=>{h.addEventListener("load",v),h.addEventListener("error",()=>b(Error(`Unable to preload CSS for ${g}`)))})}))}function a(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return i.then(l=>{for(const c of l||[])c.status==="rejected"&&a(c.reason);return t().catch(a)})};let Up=!1;function iL(){Up=!0}function Zh({title:e,body:t,action:n,pane:r,children:i}){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}),i,n]})}const Lv={title:"Toyon was updated",body:"This page is still running the old build. Reload to pick up the new one."};class Wh extends T.Component{constructor(){super(...arguments);mt(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(Zh,{pane:this.props.pane,title:Up?Lv.title:"Toyon hit an error",body:Up?Lv.body:n.message||String(n),action:f.jsx($e,{variant:"outline",onClick:()=>window.location.reload(),children:"reload"})}):this.props.children}}function Kh({kind:e,className:t,height:n,resizable:r=!0,onDragStart:i,title:a,tabs:l,actions:c,menu:d,full:g,onToggleFull:k,onClose:p,closeHint:h="esc",children:v}){const b=Wt("pane"),_=k&&f.jsxs($e,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:k,"data-tip":g?"Split view: show the preview above":"Full height: hide the preview",children:[f.jsx(Ct,{name:g?"split":"full",className:"icon-inline"})," ",g?"split":"full"]}),E=f.jsx(Dt,{icon:"close",label:"Close",hint:h,onClick:p});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:i}),f.jsx("div",{className:Ke("pane-head",l&&"pane-head-tabs"),...b.contextMenu(()=>(d==null?void 0:d())??[]),children:l?f.jsx(Pu,{...l,end:f.jsxs(f.Fragment,{children:[c,_,E]})}):f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"pane-title",children:a}),c,_,E]})}),v]})}const sL={image:({src:e,path:t})=>f.jsx("div",{className:"editor-image",children:f.jsx("img",{src:e,alt:t})})};function aL({kind:e,src:t,path:n,openSeq:r,focus:i}){const a=T.useRef(null);ft([r],()=>{var c;i&&((c=a.current)==null||c.focus())});const l=sL[e];return f.jsx("div",{ref:a,className:"editor-viewer",tabIndex:-1,children:f.jsx(l,{src:t,path:n})})}function lL(e){const t=[];return e.map(n=>{for(;t.length&&t[t.length-1]>=n;)t.pop();const r=t.length;return t.push(n),r})}function cL(e){const t=new Map,n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=lL(n.map(i=>Number(i.tagName[1])));return n.map((i,a)=>{var d;const l=((d=i.textContent)==null?void 0:d.trim())??"",c=t.get(l)??0;return t.set(l,c+1),{id:`${c}
210
+ ${l}`,level:Number(i.tagName[1]),depth:r[a],text:l,el:i}})}const uL=48,dL=16;function fL({text:e,path:t,worktreeId:n,version:r,openSeq:i,focus:a,onChat:l}){Ge();const c=Ve(),d=tM(t),g=Ph(e,r===void 0?void 0:{base:{worktreeId:n,dir:d,version:r}}),k=T.useRef(null),p=T.useRef(null),[h,v]=T.useState([]),[b,_]=T.useState(-1);ft([i],()=>{var H;a&&((H=k.current)==null||H.focus())}),ft([g],()=>{k.current&&v(cL(k.current))}),T.useLayoutEffect(()=>{const H=k.current;if(!H)return;let B=0;const re=()=>{if(B=0,H.scrollTop+H.clientHeight>=H.scrollHeight-1){_(h.length-1);return}const C=H.scrollTop+uL;let L=-1;for(let I=0;I<h.length;I++)h[I].el.offsetTop<=C&&(L=I);_(L)},F=()=>{B||(B=requestAnimationFrame(re))};return re(),H.addEventListener("scroll",F),()=>{H.removeEventListener("scroll",F),B&&cancelAnimationFrame(B)}},[h]);const E=H=>{var re,F;const B=(re=h[H])==null?void 0:re.el;(F=k.current)==null||F.scrollTo({top:Math.max(0,B?B.offsetTop-dL:0),behavior:"smooth"})},j=H=>{const B=H.target.closest("a"),re=B==null?void 0:B.getAttribute("href");if(!re||(B==null?void 0:B.target)==="_blank")return;H.preventDefault();const F=Mb(d,re);F&&ar({dispatch:c},{worktreeId:n,path:F,view:kl(F)})},x=H=>{var B;if(db(H)&&p.current){H.preventDefault(),fb(p.current);return}if(((B=ow(H))==null?void 0:B.id)==="composer"&&p.current){const re=cO(p.current);if(!re)return;H.preventDefault(),H.stopPropagation(),l(re)}};return f.jsxs(f.Fragment,{children:[f.jsx("div",{ref:k,className:"editor-viewer editor-preview",tabIndex:-1,onClick:j,onKeyDown:x,children:f.jsx("div",{ref:p,className:"md md-preview",dangerouslySetInnerHTML:{__html:g}})}),f.jsx(pL,{heads:h,at:b,onJump:E})]})}function pL({heads:e,at:t,onJump:n}){const[r,i]=T.useState(!1),a=T.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"&&i(!0)},onClick:()=>i(l=>!l),children:e.map((l,c)=>f.jsx("span",{className:"editor-outline-tick","data-level":l.level,"data-state":Ln({current:c===t})},l.id))}),r&&f.jsx(Ji,{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:()=>i(!1),onPointerLeave:l=>{l.pointerType==="mouse"&&i(!1)},children:e.map((l,c)=>f.jsx("button",{type:"button",className:"row editor-outline-row","data-level":l.level,"data-state":Ln({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 hL({absPath:e,onReveal:t}){const n=Wt("editor");return Eh(location.hostname)?f.jsxs($e,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",...n.dropdown(()=>Qs(e,t),"right"),children:["open in ",f.jsx(Ct,{name:"caret",className:"icon-inline"})]}):null}const mL=T.lazy(async()=>{const[e]=await Promise.all([Bp(()=>import("./Editor-DR-GTFmf.js").then(t=>t.E),__vite__mapDeps([0,1,2])),Bp(()=>import("./grammar-yCr7BdNP.js"),[]).then(t=>t.grammarsReady)]);return e});function Dv({what:e}){return h0(!0,3e3)?f.jsx("div",{className:"empty",children:f.jsxs("span",{className:"live-text",children:["loading ",e]})}):null}const gL={attach:()=>{},edited:()=>{},saveNow:()=>{}},kL=()=>{},yL={diff:"diff",file:"text",preview:"book"};function vL(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 q1({editor:e,height:t,full:n=!1,onToggleFull:r,onDragStart:i,placement:a="stack"}){const l=a==="screen",c=Ve(),d=Sn(),g=Ge(),k=YI(),p=Ru(),{worktreeId:h,path:v,ref:b}=e,_=z(K=>{var le;return((le=xi(K))==null?void 0:le.id)===h}),E=z(K=>{var de,Q;const le=(de=Yt(K,h))==null?void 0:de.worktree;return le?le.path:(Q=xi(K))==null?void 0:Q.path}),j=E?`${E}/${v}`:v,x=b!==void 0,H=T.useMemo(()=>(k==null?void 0:k.bind({worktreeId:h,path:v,...b?{ref:b}:{}}))??gL,[k,h,v,b]),B=z(K=>wo(K,h).changedRanges[v]);T.useEffect(()=>{!B&&!x&&!_&&(g==null||g.send({t:"changed-ranges",worktreeId:h,path:v}))},[h,v,B,x,_,g]);const re=(B==null?void 0:B.offset)??0,F=e.disk,C=e.view??"diff",L=(F==null?void 0:F.before)==="",I=X0(v,L).filter(K=>K!==C),Z=x||_?null:hI(v),V=e.line&&!e.line.fiber?e.line.n:void 0;return f.jsxs(Kh,{kind:"editor",className:Ke("editor-pane",n&&"full"),height:n||l?void 0:t,resizable:!n&&!l,onDragStart:i??kL,title:x?`${v} at ${b==null?void 0:b.slice(0,7)}`:v,menu:()=>E?vi({id:h,dir:E},v,{discard:!x&&!_,kept:_,ref:b,showing:e.view??void 0,added:L},{sock:g,dispatch:c}):[],onClose:()=>c({a:"close-editor"}),full:n,onToggleFull:l?void 0:r,actions:f.jsxs(f.Fragment,{children:[!Z&&I.map(K=>f.jsxs($e,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>c({a:"editor-view",v:K}),"data-tip":vL(K,C),children:[f.jsx(Ct,{name:yL[K],className:"icon-inline"})," ",K]},K)),!_&&f.jsx(hL,{absPath:j,onReveal:()=>g==null?void 0:g.send({t:"reveal",worktreeId:h,path:v})})]}),children:[F&&f.jsx(wL,{editor:e,disk:F,files:k}),f.jsx("div",{className:"editor-body",children:F?Z?f.jsx(aL,{kind:Z,src:H0(h,v,F.version),path:v,openSeq:e.seq,focus:e.focus}):F.binary?f.jsx("div",{className:"empty",children:"not a text file: open it in another editor"}):F.tooLarge?f.jsx("div",{className:"empty",children:"too large to open here: open it in another editor"}):C==="preview"?f.jsx(fL,{text:F.after,path:v,worktreeId:h,version:x||_?void 0:F.version,openSeq:e.seq,focus:e.focus,onChat:K=>wy(d,{worktreeId:h,text:K,name:v})}):f.jsx(Wh,{pane:!0,children:f.jsx(T.Suspense,{fallback:f.jsx(Dv,{what:C}),children:f.jsx(mL,{file:{worktreeId:h,path:v,...b?{ref:b}:{}},disk:F,view:C,openSeq:e.seq,line:V,focus:e.focus,readOnly:x||!F.writable||l,theme:p,sync:H,onCopy:(K,le,de)=>u2(de,{worktreeId:h,path:K,...le,...b?{ref:b}:{}}),onChat:(K,le)=>wy(d,le&&{worktreeId:h,text:le.text,source:{path:K,startLine:le.startLine,endLine:le.endLine,...b?{ref:b}:{}}}),onLineHover:x?void 0:K=>{K==null?Rt.post(h,{type:"highlight-clear"}):Rt.post(h,{type:"highlight-file",path:v,ranges:[[K+re,K+re]]})}},`${h}
211
+ ${b??""}
212
+ ${v}`)})}):f.jsx(Dv,{what:v},v)})]})}function wL({editor:e,disk:t,files:n}){const{worktreeId:r,path:i,ref:a,conflict:l}=e,c={worktreeId:r,path:i,...a?{ref:a}:{}};if(l){const d=l.version===null;return f.jsxs("div",{className:"editor-note",children:[f.jsx("span",{className:"editor-note-text",children:d?"deleted on disk; your edits are not saved":"changed on disk; your edits are not saved"}),f.jsx($e,{variant:"outline",onClick:()=>n==null?void 0:n.reload(c),"data-tip":d?"Close the file; your edits go with it":"Take the file as it is on disk; undo brings your edits back",children:d?"close":"reload"}),f.jsx($e,{variant:"outline",tone:"danger",onClick:()=>n==null?void 0:n.keepMine(c),"data-tip":d?"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})}):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 Gh(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 Y1(e,t){var r;if(!e)return null;const n=((r=t.find(i=>i.id===e.repoId))==null?void 0:r.defaultBranch)??"the default branch";return e.building?{text:`Rebuilding Toyon from ${n}`,busy:!0}:e.buildFailed?{text:"Rebuilding Toyon stopped",detail:e.buildFailed,build:"try again",busy:!1}:e.rebuild?{text:`Toyon's shell is behind ${n}`,build:"rebuild",busy:!1}:e.restart?{text:`Toyon itself is behind ${n}`,restart:!0,busy:!1}:null}const Q1=e=>`Toyon restarts once ${e.join(", ")} ${e.length===1?"finishes":"finish"}`,bL=(e,t)=>[...e,...t.filter(n=>!e.includes(n))];function xL(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 _L(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 EL(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:Q1(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 SL={npm:"installed with npm. A newer version installs itself when nothing is busy; press to check for one now",bun:"installed with bun. A newer version installs itself when nothing is busy; press to check for one now",npx:"run with npx, which fetches the newest version itself. Press to check for one now",none:"run from a checkout, which does not update itself"};function NL(e,t,n,r,i){if(n){if(n.restarting){const l=n.installed??n.running,c=n.restarting.length>0?Q1(n.restarting):"Toyon is restarting; this page reloads when it is back";return{value:`${l}, restarting`,text:c,act:"restart",busy:!0}}if(n.installing){const l=n.latest??n.installed??n.running;return{value:`${l}, installing`,text:`Installing Toyon ${l}`,act:"update",busy:!0}}if(n.failed){const l=n.failed.line.replace(/\.$/,"");return{value:`${n.running}, update failed`,text:`Installing Toyon ${n.failed.version} stopped: ${l}. 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.running}, ${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 a=Y1(r,i);return a?a.busy?{value:`${e}, rebuilding`,text:a.text,act:"rebuild",busy:!0}:a.build==="try again"?{value:`${e}, rebuild stopped`,text:a.text,detail:a.detail,act:"rebuild",busy:!1}:{value:`${e}, behind`,text:a.text,act:a.build?"rebuild":"restart",busy:!1}:{value:e,text:`Toyon ${e}, ${SL[t]}`,act:t==="none"?null:"check",busy:!1}}const TL=bE.map(e=>({title:e,rows:EE(e).map(t=>[ct(t),Wa[t].label])}));function CL(){const e=Ve(),t=Ge(),n=Wt("keys"),r=z(k=>k.themePrefs),i=z(k=>k.themes),a=z(k=>k.chatSide),l=dh(),c=z(k=>k.agents),d=qs(),g=k=>{e({a:"palette-return",v:{mode:"keys",q:""}}),e(k)};return f.jsxs(Zu,{bare:!0,boxClass:"keys-stack",id:"keys-help",onClose:()=>e({a:"close"}),children:[f.jsxs("div",{className:"keys-card",children:[f.jsxs("div",{children:[d&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"section-title keys-h",children:d.name}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"processes"}),f.jsx($e,{variant:"field",mono:!0,className:"keys-chip","data-tip":`edit the install + start commands in ${d.configFile}`,onClick:()=>e({a:"open",overlay:{kind:"setup",repoId:d.id}}),...n.contextMenu(()=>Wu(d,d.id,{sock:t,dispatch:e})),children:f.jsx("span",{className:"keys-v",children:Object.keys(d.config.run).join(" + ")||"not set up"})})]})]}),f.jsx("div",{className:"section-title keys-h",children:"Agents"}),c.map(k=>f.jsx(AL,{agent:k},k.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($e,{variant:"field",mono:!0,onClick:()=>g({a:"open",overlay:{kind:"appearance"}}),children:pu[r.mode]})]}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"theme"}),f.jsx($e,{variant:"field",mono:!0,onClick:()=>g({a:"open",overlay:{kind:"theme",slot:"theme"}}),children:Cu(r,i,l).name})]}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"chat side"}),f.jsx($e,{variant:"field",mono:!0,onClick:()=>e({a:"toggle-chat-side"}),children:a})]}),f.jsx("div",{className:"section-title keys-h",children:"Toyon"}),f.jsx(jL,{})]})]}),f.jsx("div",{className:"keys-card",children:TL.map(k=>f.jsxs("div",{children:[f.jsx("div",{className:"section-title keys-h",children:k.title}),k.rows.map(([p,h])=>f.jsxs("div",{className:"keys-row",children:[f.jsx(Zr,{k:p}),f.jsx("span",{className:"keys-d",children:h})]},p))]},k.title))})]})}function jL(){const e=Ge(),t=z(d=>d.version),n=z(d=>d.install),r=z(d=>d.update),i=z(d=>d.self),a=z(d=>d.repos),l=NL(t,n,r,i,a),c=()=>{l.act==="restart"?e==null||e.send({t:"restart-daemon"}):l.act==="rebuild"&&i?e==null||e.send({t:"run-after-land",repoId:i.repoId}):l.act==="update"?e==null||e.send({t:"update-now"}):l.act==="check"&&(e==null||e.send({t:"check-update"}))};return f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"version"}),f.jsx($e,{variant:"field",mono:!0,busy:l.busy,disabled:l.act===null,onClick:c,...Et(l.text,void 0,{detail:l.detail}),children:l.value})]})}function X1(e){return e.available?e.auth?e.auth.kind==="none"?"not logged in":e.auth.label:"ready":e.installing?"installing":"not installed"}function J1(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 AL({agent:e}){const t=Ve(),n=Ge(),r=Wt("keys");return f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:e.name}),f.jsx($e,{variant:"field",mono:!0,"data-tip":J1(e),...r.contextMenu(()=>Gh(e,{sock:n})),onClick:()=>{t({a:"palette-return",v:{mode:"keys",q:""}}),t({a:"open",overlay:{kind:"agent-page",agent:e.id}})},children:X1(e)})]})}function IL({agentId:e}){const t=Ve(),n=Ge(),r=qs(),i=z(h=>h.home),a=z(h=>h.agents.find(v=>v.id===e)??null),l=z(h=>h.agentConfigs[e]??null),c=Wt("keys");if(T.useEffect(()=>{n==null||n.send({t:"agent-config",agent:e,...r?{repoId:r.id}:{}})},[n,e,r]),!a)return null;const d=Gh(a,{sock:n}),g=()=>t({a:"close",back:!0}),k=h=>i&&h.startsWith(`${i}/`)?`~${h.slice(i.length)}`:h,p=h=>n==null?void 0:n.send({t:"reveal-agent-file",agent:e,file:h.id,...r?{repoId:r.id}:{}});return f.jsx(Zu,{bare:!0,boxClass:"keys-stack",onClose:g,children:f.jsxs("div",{className:"keys-card keys-settings",children:[f.jsx("div",{className:"agent-page-back",children:f.jsx(Dt,{icon:"back",label:"back to settings",hint:"esc",onClick:g})}),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($e,{variant:"field",mono:!0,"data-tip":J1(a),disabled:d.length===0,...c.dropdown(()=>d,"right"),children:X1(a)})]}),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(h=>f.jsx(RL,{s:h},`${h.scope}:${h.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(h=>f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:h.label}),h.exists?f.jsx($e,{variant:"field",mono:!0,"data-tip":`reveal ${k(h.path)} in Finder`,onClick:()=>p(h),children:k(h.path)}):f.jsxs("span",{className:"keys-d",children:["not present: ",k(h.path)]})]},h.id))]})]})})}function RL({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 OL(){const e=Ve(),t=Ge(),n=z(i=>i.agents),r=z(i=>i.defaultAgent);return f.jsx(yr,{items:n,filter:(i,a)=>i.filter(l=>Us(a,l.name,l.id)),rowClass:i=>i.available?"picker-row":"picker-row dim",keyOf:i=>i.id,initialIndex:i=>Math.max(0,i.findIndex(a=>a.id===r)),onPick:i=>{i.available&&(t==null||t.send({t:"set-default-agent",agent:i.id}),e({a:"close"}))},onBack:()=>e({a:"close",back:!0}),rowMenu:i=>Gh(i,{sock:t}),placeholder:"default agent for new worktrees",keys:{pick:"sets",back:"closes"},row:i=>f.jsx(On,{label:i.name,current:i.id===r,hint:i.available?i.sandboxed?void 0:"unsandboxed":i.reason??"not installed"})})}const $L=["dark","light","system","daylight"],ML=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"});function PL(){const e=Ve(),t=Ge(),n=z(d=>d.themePrefs),r=z(d=>d.themes),i=dh(),a=z(d=>d.daylight),l=d=>{var g;return((g=r.find(k=>k.id===n[ah({...n,mode:d},i)]))==null?void 0:g.name)??""},c=d=>{if(d==="system")return`${i.system?"dark":"light"} now · ${l(d)}`;if(d!=="daylight")return l(d);const g=a&&a.until>Date.now()?` · ${i.daylight?"light":"dark"} at ${ML.format(a.until)}`:"";return`${i.daylight?"dark":"light"} now${g} · ${l(d)}`};return f.jsx(yr,{items:$L,filter:(d,g)=>d.filter(k=>Us(g,pu[k])),rowClass:()=>"picker-row",keyOf:d=>d,initialIndex:d=>d.indexOf(n.mode),onActive:d=>e({a:"preview-theme",theme:d?Cu({...n,mode:d},r,i):null}),onPick:d=>{t==null||t.send({t:"set-theme",prefs:{...n,mode:d}}),e({a:"close"})},onBack:()=>e({a:"close",back:!0}),placeholder:"light/dark mode",keys:{nav:"preview",pick:"keeps",back:"reverts"},row:d=>f.jsx(On,{label:pu[d],current:d===n.mode,hint:c(d)})})}const LL=[],DL=(e,t)=>[e.title,e.branch,e.prompt??""].some(n=>n.toLowerCase().includes(t));function zL({repoId:e}){const t=Ve(),n=Ge(),r=z(l=>l.clientId),i=z(l=>l.archived[e]);T.useEffect(()=>{n==null||n.send({t:"list-archived",repoId:e})},[n,e]);const a=T.useCallback((l,c)=>{const d=c.trim().toLowerCase();return d?l.filter(g=>DL(g,d)):l},[]);return f.jsx(yr,{items:i??LL,filter:a,keyOf:l=>l.id,rowClass:l=>l.restorable?"picker-row":"picker-row dim",rowTitle:l=>l.prompt??l.title,onPick:l=>{t({a:"open-archived",id:l.id}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:l=>Bc(l,r,{sock:n,dispatch:t}),placeholder:"find an archived worktree…",keys:l=>({nav:"moves",pick:l?"opens it":void 0,back:"closes"}),empty:l=>i?l.trim()?"no archived worktree matches":"nothing archived yet":"looking…",row:l=>f.jsx(On,{label:l.title,hint:Th(l)})})}const rp=2,FL=[],BL=e=>({kind:"worktree",id:e.id,name:e.name,archived:!1,hint:e.branch??"",fields:[e.name,e.branch??""]}),UL=e=>({kind:"worktree",id:e.id,name:e.title,archived:!0,hint:Th(e),fields:[e.title,e.branch]}),HL=([e,t])=>Array.from({length:t},(n,r)=>e+r);function ZL({repoId:e}){const t=Ve(),n=Ge(),r=z(h=>h.chats[e]),i=ph(),a=v0();T.useEffect(()=>{n==null||n.send({t:"list-archived",repoId:e})},[n,e]);const l=T.useMemo(()=>[...i.filter(h=>!Yn(h.worktree)).map(BL),...a.map(UL)],[i,a]),c=T.useMemo(()=>new Map(l.map(h=>[h.id,h.name])),[l]),d=T.useMemo(()=>[...l,...((r==null?void 0:r.hits)??[]).map(h=>({kind:"hit",hit:h}))],[l,r]),g=T.useCallback((h,v)=>{const b=v.trim().toLowerCase();return b.length<rp?FL:h.filter(_=>_.kind==="hit"||_.fields.some(E=>E.toLowerCase().includes(b)))},[]),k=T.useCallback(h=>{const v=h.trim();v.length>=rp&&(n==null||n.send({t:"search-chats",repoId:e,query:v}))},[n,e]),p=h=>!r||r.query!==h.trim();return f.jsx(yr,{items:d,filter:g,onQuery:k,keyOf:h=>h.kind==="hit"?`h:${h.hit.worktreeId}:${h.hit.seq}`:`w:${h.id}`,rowClass:h=>h.kind==="hit"?"chats-hit":"picker-row",rowTitle:h=>h.kind==="hit"?h.hit.text:void 0,onPick:h=>{const v=h.kind==="hit"?h.hit.worktreeId:h.id,b=h.kind==="hit"?h.hit.archived:h.archived;t(b?{a:"open-archived",id:v}:{a:"activate",id:v}),h.kind==="hit"&&t({a:"reveal",id:v,seq:h.hit.seq}),t({a:"close"})},onBack:()=>t({a:"close"}),placeholder:"search in chats…",keys:h=>({nav:"moves",pick:h?h.kind==="hit"?"opens the chat there":"opens its chat":void 0,back:"closes"}),empty:h=>h.trim().length<rp?"type at least two characters":p(h)?"searching…":"no chat says that",footer:(h,v)=>{const b=v.filter(_=>_.kind==="hit").length;return r!=null&&r.truncated&&!p(h)&&b>0?f.jsxs("div",{className:"empty",children:["showing the first ",b,"; narrow the search"]}):null},row:h=>h.kind==="worktree"?f.jsx(On,{label:h.archived?f.jsxs(f.Fragment,{children:[h.name," ",f.jsx("span",{className:"row-dim",children:"archived"})]}):h.name,hint:h.hint}):f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"chats-where",children:[f.jsx("span",{className:"chats-name",children:c.get(h.hit.worktreeId)??"a worktree"}),h.hit.archived&&f.jsx("span",{className:"row-dim",children:"archived"}),f.jsxs("span",{className:"chats-said row-dim",children:[h.hit.role==="user"?"you":"the agent",h.hit.ts>0?` · ${yo(h.hit.ts)}`:""]})]}),f.jsx("span",{className:"chats-text",children:cl(h.hit.text,HL(h.hit.match),0)})]})})}function WL({worktreeId:e,hits:t}){const n=Ve(),r=Ge(),i=z(c=>c.layout.changes),a=z(c=>{var g;const d=(g=Yt(c,e))==null?void 0:g.worktree;return d?d.path:null}),l=T.useCallback((c,d)=>{const g=d.trim().toLowerCase();return g?c.filter(k=>`${k.path}:${k.line} ${k.text}`.toLowerCase().includes(g)):c},[]);return f.jsx(yr,{items:t,filter:l,keyOf:c=>`${c.path}:${c.line}`,rowClass:()=>"search-hit",rowTitle:c=>`${c.path}:${c.line}`,onPick:c=>{ar({dispatch:n},{worktreeId:e,path:c.path,view:"file",line:{n:c.line}}),i||n({a:"toggle-changes"}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:c=>a?vi({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 Ku=e=>/^(~|\/|\.\.?\/)/.test(e.trim());function ex(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 KL(e,t,n){const r=e.map(g=>g.path.slice(0,g.path.lastIndexOf("/"))).filter(Boolean),i=e.find(g=>g.id===t),a=i==null?void 0:i.path.slice(0,i.path.lastIndexOf("/")),l=new Map;for(const g of r)l.set(g,(l.get(g)??0)+1);let c="",d=0;for(const[g,k]of[...l].sort(([p],[h])=>p.localeCompare(h)))(k>d||k===d&&g===a)&&(c=g,d=k);return c?tx(c,n):`~/${aw}`}function tx(e,t){return t&&(e===t||e.startsWith(`${t}/`))?`~${e.slice(t.length)}`:e}function nx(e,t){return`${e.replace(/\/+$/,"")}/${t.trim()}`}function GL(e){const t=e.query.trim(),n=()=>e.entries.map(l=>({kind:"dir",entry:l}));if(!Ku(t)){const l=e.repos.filter(p=>Us(t,p.name,p.path)).map(p=>({kind:"repo",repo:p})),c=e.pending.filter(p=>Us(t,p.name,p.url)).map(p=>({kind:"pending",pending:p})),d=[...l,...c];if(!t)return[...d,{kind:"new"}];const g=rS(t);if(g)return d.length>0?d:[{kind:"clone",url:g.url,name:g.name}];const k=p=>p.toLowerCase()===t.toLowerCase();return e.repos.some(p=>k(p.name))||e.pending.some(p=>k(p.name))||Ja(t)?d:[...d,{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:i,name:a}=ex(t);return Ja(a)?n():[...n(),{kind:"create",name:a,parent:i}]}function ul(e,t){return t&&(e==="~"||e.startsWith("~/"))?`${t}${e.slice(1)}`:e}function rx(e,t){const n=ul(e,t).replace(/\/+$/,"");return n.startsWith("/")?tx(n.slice(0,n.lastIndexOf("/"))||"/",t):null}function Hp(e,t){const n=ul(e,t).replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||"/"}function VL(e){const t=e.query.trim(),n=t.lastIndexOf("/"),r=n<0?"":t.slice(0,n)||"/",i=ul(r,e.home);if(!Ku(t)||!i.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),d=e.entries.filter(k=>{if(k.isRepo)return!1;const p=ul(k.path,e.home);return(p.slice(0,p.lastIndexOf("/"))||"/")===i&&k.name.toLowerCase().startsWith(a)}),g=rx(r,e.home);return[...c?[{kind:"here",path:r}]:[],...g?[{kind:"up",path:g}]:[],...d.map(k=>({kind:"dir",entry:k}))]}function qL({project:e}){const t=Ve(),n=Ge(),r=z(g=>g.paths),i=z(g=>g.home),a=T.useCallback(g=>{Ku(g)&&(n==null||n.send({t:"browse-path",path:g}))},[n]),l=T.useCallback((g,k)=>VL({query:k,entries:r.entries,target:r.target,answered:r.query,home:i}),[r,i]),c=Ja(e.name)?null:e.name.trim(),d=g=>`${g.replace(/\/+$/,"")}/`;return f.jsx(yr,{initialQuery:d(e.parent),lead:f.jsx("span",{className:"picker-chip",children:c??"new project"}),items:[],filter:l,keyOf:g=>g.kind==="dir"?`d:${g.entry.path}`:`${g.kind}:${g.path}`,rowClass:()=>"picker-row folder-row",onQuery:a,completionOf:g=>g.kind==="dir"?d(g.entry.path):null,narrowTo:g=>g.kind==="dir"?d(g.entry.path):g.kind==="up"?d(g.path):null,onPick:g=>{g.kind==="here"&&(t({a:"new-project-set",v:{mode:e.mode==="init"?"create":e.mode,parent:g.path}}),t({a:"close"}))},onBack:()=>t({a:"close"}),placeholder:"type a folder path",keys:g=>({complete:"completes the path",pick:(g==null?void 0:g.kind)==="here"?"chooses it":(g==null?void 0:g.kind)==="up"?"goes up":"opens it",back:"goes back"}),empty:"no such folder",row:g=>g.kind==="here"?f.jsx(On,{label:`put ${c??"it"} in ${Hp(g.path,i)}`,hint:f.jsx("bdi",{children:c?nx(g.path,c):g.path})}):g.kind==="up"?f.jsx(On,{label:`up to ${Hp(g.path,i)}`,hint:f.jsx("bdi",{children:g.path})}):f.jsx(On,{label:g.entry.name})})}const Js=function(e,t){let i=e;const a=Za[t];let l=null,c=0,d=null;const g=[],k={},p=function(C,L){c=i*4+17,l=(function(I){const Z=new Array(I);for(let V=0;V<I;V+=1){Z[V]=new Array(I);for(let K=0;K<I;K+=1)Z[V][K]=null}return Z})(c),h(0,0),h(c-7,0),h(0,c-7),_(),b(),j(C,L),i>=7&&E(C),d==null&&(d=B(i,a,g)),x(d,L)},h=function(C,L){for(let I=-1;I<=7;I+=1)if(!(C+I<=-1||c<=C+I))for(let Z=-1;Z<=7;Z+=1)L+Z<=-1||c<=L+Z||(0<=I&&I<=6&&(Z==0||Z==6)||0<=Z&&Z<=6&&(I==0||I==6)||2<=I&&I<=4&&2<=Z&&Z<=4?l[C+I][L+Z]=!0:l[C+I][L+Z]=!1)},v=function(){let C=0,L=0;for(let I=0;I<8;I+=1){p(!0,I);const Z=mi.getLostPoint(k);(I==0||C>Z)&&(C=Z,L=I)}return L},b=function(){for(let C=8;C<c-8;C+=1)l[C][6]==null&&(l[C][6]=C%2==0);for(let C=8;C<c-8;C+=1)l[6][C]==null&&(l[6][C]=C%2==0)},_=function(){const C=mi.getPatternPosition(i);for(let L=0;L<C.length;L+=1)for(let I=0;I<C.length;I+=1){const Z=C[L],V=C[I];if(l[Z][V]==null)for(let K=-2;K<=2;K+=1)for(let le=-2;le<=2;le+=1)K==-2||K==2||le==-2||le==2||K==0&&le==0?l[Z+K][V+le]=!0:l[Z+K][V+le]=!1}},E=function(C){const L=mi.getBCHTypeNumber(i);for(let I=0;I<18;I+=1){const Z=!C&&(L>>I&1)==1;l[Math.floor(I/3)][I%3+c-8-3]=Z}for(let I=0;I<18;I+=1){const Z=!C&&(L>>I&1)==1;l[I%3+c-8-3][Math.floor(I/3)]=Z}},j=function(C,L){const I=a<<3|L,Z=mi.getBCHTypeInfo(I);for(let V=0;V<15;V+=1){const K=!C&&(Z>>V&1)==1;V<6?l[V][8]=K:V<8?l[V+1][8]=K:l[c-15+V][8]=K}for(let V=0;V<15;V+=1){const K=!C&&(Z>>V&1)==1;V<8?l[8][c-V-1]=K:V<9?l[8][15-V-1+1]=K:l[8][15-V-1]=K}l[c-8][8]=!C},x=function(C,L){let I=-1,Z=c-1,V=7,K=0;const le=mi.getMaskFunction(L);for(let de=c-1;de>0;de-=2)for(de==6&&(de-=1);;){for(let Q=0;Q<2;Q+=1)if(l[Z][de-Q]==null){let ce=!1;K<C.length&&(ce=(C[K]>>>V&1)==1),le(Z,de-Q)&&(ce=!ce),l[Z][de-Q]=ce,V-=1,V==-1&&(K+=1,V=7)}if(Z+=I,Z<0||c<=Z){Z-=I,I=-I;break}}},H=function(C,L){let I=0,Z=0,V=0;const K=new Array(L.length),le=new Array(L.length);for(let R=0;R<L.length;R+=1){const M=L[R].dataCount,G=L[R].totalCount-M;Z=Math.max(Z,M),V=Math.max(V,G),K[R]=new Array(M);for(let D=0;D<K[R].length;D+=1)K[R][D]=255&C.getBuffer()[D+I];I+=M;const ne=mi.getErrorCorrectPolynomial(G),ee=dl(K[R],ne.getLength()-1).mod(ne);le[R]=new Array(ne.getLength()-1);for(let D=0;D<le[R].length;D+=1){const q=D+ee.getLength()-le[R].length;le[R][D]=q>=0?ee.getAt(q):0}}let de=0;for(let R=0;R<L.length;R+=1)de+=L[R].totalCount;const Q=new Array(de);let ce=0;for(let R=0;R<Z;R+=1)for(let M=0;M<L.length;M+=1)R<K[M].length&&(Q[ce]=K[M][R],ce+=1);for(let R=0;R<V;R+=1)for(let M=0;M<L.length;M+=1)R<le[M].length&&(Q[ce]=le[M][R],ce+=1);return Q},B=function(C,L,I){const Z=zv.getRSBlocks(C,L),V=Fv();for(let le=0;le<I.length;le+=1){const de=I[le];V.put(de.getMode(),4),V.put(de.getLength(),mi.getLengthInBits(de.getMode(),C)),de.write(V)}let K=0;for(let le=0;le<Z.length;le+=1)K+=Z[le].dataCount;if(V.getLengthInBits()>K*8)throw"code length overflow. ("+V.getLengthInBits()+">"+K*8+")";for(V.getLengthInBits()+4<=K*8&&V.put(0,4);V.getLengthInBits()%8!=0;)V.putBit(!1);for(;!(V.getLengthInBits()>=K*8||(V.put(236,8),V.getLengthInBits()>=K*8));)V.put(17,8);return H(V,Z)};k.addData=function(C,L){L=L||"Byte";let I=null;switch(L){case"Numeric":I=YL(C);break;case"Alphanumeric":I=QL(C);break;case"Byte":I=XL(C);break;case"Kanji":I=JL(C);break;default:throw"mode:"+L}g.push(I),d=null},k.isDark=function(C,L){if(C<0||c<=C||L<0||c<=L)throw C+","+L;return l[C][L]},k.getModuleCount=function(){return c},k.make=function(){if(i<1){let C=1;for(;C<40;C++){const L=zv.getRSBlocks(C,a),I=Fv();for(let V=0;V<g.length;V++){const K=g[V];I.put(K.getMode(),4),I.put(K.getLength(),mi.getLengthInBits(K.getMode(),C)),K.write(I)}let Z=0;for(let V=0;V<L.length;V++)Z+=L[V].dataCount;if(I.getLengthInBits()<=Z*8)break}i=C}p(!1,v())},k.createTableTag=function(C,L){C=C||2,L=typeof L>"u"?C*4:L;let I="";I+='<table style="',I+=" border-width: 0px; border-style: none;",I+=" border-collapse: collapse;",I+=" padding: 0px; margin: "+L+"px;",I+='">',I+="<tbody>";for(let Z=0;Z<k.getModuleCount();Z+=1){I+="<tr>";for(let V=0;V<k.getModuleCount();V+=1)I+='<td style="',I+=" border-width: 0px; border-style: none;",I+=" border-collapse: collapse;",I+=" padding: 0px; margin: 0px;",I+=" width: "+C+"px;",I+=" height: "+C+"px;",I+=" background-color: ",I+=k.isDark(Z,V)?"#000000":"#ffffff",I+=";",I+='"/>';I+="</tr>"}return I+="</tbody>",I+="</table>",I},k.createSvgTag=function(C,L,I,Z){let V={};typeof arguments[0]=="object"&&(V=arguments[0],C=V.cellSize,L=V.margin,I=V.alt,Z=V.title),C=C||2,L=typeof L>"u"?C*4:L,I=typeof I=="string"?{text:I}:I||{},I.text=I.text||null,I.id=I.text?I.id||"qrcode-description":null,Z=typeof Z=="string"?{text:Z}:Z||{},Z.text=Z.text||null,Z.id=Z.text?Z.id||"qrcode-title":null;const K=k.getModuleCount()*C+L*2;let le,de,Q,ce,R="",M;for(M="l"+C+",0 0,"+C+" -"+C+",0 0,-"+C+"z ",R+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',R+=V.scalable?"":' width="'+K+'px" height="'+K+'px"',R+=' viewBox="0 0 '+K+" "+K+'" ',R+=' preserveAspectRatio="xMinYMin meet"',R+=Z.text||I.text?' role="img" aria-labelledby="'+re([Z.id,I.id].join(" ").trim())+'"':"",R+=">",R+=Z.text?'<title id="'+re(Z.id)+'">'+re(Z.text)+"</title>":"",R+=I.text?'<description id="'+re(I.id)+'">'+re(I.text)+"</description>":"",R+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',R+='<path d="',Q=0;Q<k.getModuleCount();Q+=1)for(ce=Q*C+L,le=0;le<k.getModuleCount();le+=1)k.isDark(Q,le)&&(de=le*C+L,R+="M"+de+","+ce+M);return R+='" stroke="transparent" fill="black"/>',R+="</svg>",R},k.createDataURL=function(C,L){C=C||2,L=typeof L>"u"?C*4:L;const I=k.getModuleCount()*C+L*2,Z=L,V=I-L;return rD(I,I,function(K,le){if(Z<=K&&K<V&&Z<=le&&le<V){const de=Math.floor((K-Z)/C),Q=Math.floor((le-Z)/C);return k.isDark(Q,de)?0:1}else return 1})},k.createImgTag=function(C,L,I){C=C||2,L=typeof L>"u"?C*4:L;const Z=k.getModuleCount()*C+L*2;let V="";return V+="<img",V+=' src="',V+=k.createDataURL(C,L),V+='"',V+=' width="',V+=Z,V+='"',V+=' height="',V+=Z,V+='"',I&&(V+=' alt="',V+=re(I),V+='"'),V+="/>",V};const re=function(C){let L="";for(let I=0;I<C.length;I+=1){const Z=C.charAt(I);switch(Z){case"<":L+="&lt;";break;case">":L+="&gt;";break;case"&":L+="&amp;";break;case'"':L+="&quot;";break;default:L+=Z;break}}return L},F=function(C){C=typeof C>"u"?2:C;const I=k.getModuleCount()*1+C*2,Z=C,V=I-C;let K,le,de,Q,ce;const R={"██":"█","█ ":"▀"," █":"▄"," ":" "},M={"██":"▀","█ ":"▀"," █":" "," ":" "};let G="";for(K=0;K<I;K+=2){for(de=Math.floor((K-Z)/1),Q=Math.floor((K+1-Z)/1),le=0;le<I;le+=1)ce="█",Z<=le&&le<V&&Z<=K&&K<V&&k.isDark(de,Math.floor((le-Z)/1))&&(ce=" "),Z<=le&&le<V&&Z<=K+1&&K+1<V&&k.isDark(Q,Math.floor((le-Z)/1))?ce+=" ":ce+="█",G+=C<1&&K+1>=V?M[ce]:R[ce];G+=`
213
+ `}return I%2&&C>0?G.substring(0,G.length-I-1)+Array(I+1).join("▀"):G.substring(0,G.length-1)};return k.createASCII=function(C,L){if(C=C||1,C<2)return F(L);C-=1,L=typeof L>"u"?C*2:L;const I=k.getModuleCount()*C+L*2,Z=L,V=I-L;let K,le,de,Q;const ce=Array(C+1).join("██"),R=Array(C+1).join(" ");let M="",G="";for(K=0;K<I;K+=1){for(de=Math.floor((K-Z)/C),G="",le=0;le<I;le+=1)Q=1,Z<=le&&le<V&&Z<=K&&K<V&&k.isDark(de,Math.floor((le-Z)/C))&&(Q=0),G+=Q?ce:R;for(de=0;de<C;de+=1)M+=G+`
214
+ `}return M.substring(0,M.length-1)},k.renderTo2dContext=function(C,L){L=L||2;const I=k.getModuleCount();for(let Z=0;Z<I;Z++)for(let V=0;V<I;V++)C.fillStyle=k.isDark(Z,V)?"black":"white",C.fillRect(V*L,Z*L,L,L)},k};Js.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};Js.createStringToBytes=function(e,t){const n=(function(){const i=tD(e),a=function(){const d=i.read();if(d==-1)throw"eof";return d};let l=0;const c={};for(;;){const d=i.read();if(d==-1)break;const g=a(),k=a(),p=a(),h=String.fromCharCode(d<<8|g),v=k<<8|p;c[h]=v,l+=1}if(l!=t)throw l+" != "+t;return c})(),r=63;return function(i){const a=[];for(let l=0;l<i.length;l+=1){const c=i.charCodeAt(l);if(c<128)a.push(c);else{const d=n[i.charAt(l)];typeof d=="number"?(d&255)==d?a.push(d):(a.push(d>>>8),a.push(d&255)):a.push(r)}}return a}};const ir={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},Za={L:1,M:0,Q:3,H:2},hi={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},mi=(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,i={},a=function(l){let c=0;for(;l!=0;)c+=1,l>>>=1;return c};return i.getBCHTypeInfo=function(l){let c=l<<10;for(;a(c)-a(t)>=0;)c^=t<<a(c)-a(t);return(l<<10|c)^r},i.getBCHTypeNumber=function(l){let c=l<<12;for(;a(c)-a(n)>=0;)c^=n<<a(c)-a(n);return l<<12|c},i.getPatternPosition=function(l){return e[l-1]},i.getMaskFunction=function(l){switch(l){case hi.PATTERN000:return function(c,d){return(c+d)%2==0};case hi.PATTERN001:return function(c,d){return c%2==0};case hi.PATTERN010:return function(c,d){return d%3==0};case hi.PATTERN011:return function(c,d){return(c+d)%3==0};case hi.PATTERN100:return function(c,d){return(Math.floor(c/2)+Math.floor(d/3))%2==0};case hi.PATTERN101:return function(c,d){return c*d%2+c*d%3==0};case hi.PATTERN110:return function(c,d){return(c*d%2+c*d%3)%2==0};case hi.PATTERN111:return function(c,d){return(c*d%3+(c+d)%2)%2==0};default:throw"bad maskPattern:"+l}},i.getErrorCorrectPolynomial=function(l){let c=dl([1],0);for(let d=0;d<l;d+=1)c=c.multiply(dl([1,ki.gexp(d)],0));return c},i.getLengthInBits=function(l,c){if(1<=c&&c<10)switch(l){case ir.MODE_NUMBER:return 10;case ir.MODE_ALPHA_NUM:return 9;case ir.MODE_8BIT_BYTE:return 8;case ir.MODE_KANJI:return 8;default:throw"mode:"+l}else if(c<27)switch(l){case ir.MODE_NUMBER:return 12;case ir.MODE_ALPHA_NUM:return 11;case ir.MODE_8BIT_BYTE:return 16;case ir.MODE_KANJI:return 10;default:throw"mode:"+l}else if(c<41)switch(l){case ir.MODE_NUMBER:return 14;case ir.MODE_ALPHA_NUM:return 13;case ir.MODE_8BIT_BYTE:return 16;case ir.MODE_KANJI:return 12;default:throw"mode:"+l}else throw"type:"+c},i.getLostPoint=function(l){const c=l.getModuleCount();let d=0;for(let p=0;p<c;p+=1)for(let h=0;h<c;h+=1){let v=0;const b=l.isDark(p,h);for(let _=-1;_<=1;_+=1)if(!(p+_<0||c<=p+_))for(let E=-1;E<=1;E+=1)h+E<0||c<=h+E||_==0&&E==0||b==l.isDark(p+_,h+E)&&(v+=1);v>5&&(d+=3+v-5)}for(let p=0;p<c-1;p+=1)for(let h=0;h<c-1;h+=1){let v=0;l.isDark(p,h)&&(v+=1),l.isDark(p+1,h)&&(v+=1),l.isDark(p,h+1)&&(v+=1),l.isDark(p+1,h+1)&&(v+=1),(v==0||v==4)&&(d+=3)}for(let p=0;p<c;p+=1)for(let h=0;h<c-6;h+=1)l.isDark(p,h)&&!l.isDark(p,h+1)&&l.isDark(p,h+2)&&l.isDark(p,h+3)&&l.isDark(p,h+4)&&!l.isDark(p,h+5)&&l.isDark(p,h+6)&&(d+=40);for(let p=0;p<c;p+=1)for(let h=0;h<c-6;h+=1)l.isDark(h,p)&&!l.isDark(h+1,p)&&l.isDark(h+2,p)&&l.isDark(h+3,p)&&l.isDark(h+4,p)&&!l.isDark(h+5,p)&&l.isDark(h+6,p)&&(d+=40);let g=0;for(let p=0;p<c;p+=1)for(let h=0;h<c;h+=1)l.isDark(h,p)&&(g+=1);const k=Math.abs(100*g/c/c-50)/5;return d+=k*10,d},i})(),ki=(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})(),dl=function(e,t){if(typeof e.length>"u")throw e.length+"/"+t;const n=(function(){let i=0;for(;i<e.length&&e[i]==0;)i+=1;const a=new Array(e.length-i+t);for(let l=0;l<e.length-i;l+=1)a[l]=e[l+i];return a})(),r={};return r.getAt=function(i){return n[i]},r.getLength=function(){return n.length},r.multiply=function(i){const a=new Array(r.getLength()+i.getLength()-1);for(let l=0;l<r.getLength();l+=1)for(let c=0;c<i.getLength();c+=1)a[l+c]^=ki.gexp(ki.glog(r.getAt(l))+ki.glog(i.getAt(c)));return dl(a,0)},r.mod=function(i){if(r.getLength()-i.getLength()<0)return r;const a=ki.glog(r.getAt(0))-ki.glog(i.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<i.getLength();c+=1)l[c]^=ki.gexp(ki.glog(i.getAt(c))+a);return dl(l,0).mod(i)},r},zv=(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(i,a){const l={};return l.totalCount=i,l.dataCount=a,l},n={},r=function(i,a){switch(a){case Za.L:return e[(i-1)*4+0];case Za.M:return e[(i-1)*4+1];case Za.Q:return e[(i-1)*4+2];case Za.H:return e[(i-1)*4+3];default:return}};return n.getRSBlocks=function(i,a){const l=r(i,a);if(typeof l>"u")throw"bad rs block @ typeNumber:"+i+"/errorCorrectionLevel:"+a;const c=l.length/3,d=[];for(let g=0;g<c;g+=1){const k=l[g*3+0],p=l[g*3+1],h=l[g*3+2];for(let v=0;v<k;v+=1)d.push(t(p,h))}return d},n})(),Fv=function(){const e=[];let t=0;const n={};return n.getBuffer=function(){return e},n.getAt=function(r){const i=Math.floor(r/8);return(e[i]>>>7-r%8&1)==1},n.put=function(r,i){for(let a=0;a<i;a+=1)n.putBit((r>>>i-a-1&1)==1)},n.getLengthInBits=function(){return t},n.putBit=function(r){const i=Math.floor(t/8);e.length<=i&&e.push(0),r&&(e[i]|=128>>>t%8),t+=1},n},YL=function(e){const t=ir.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 d=0;for(;d+2<c.length;)l.put(i(c.substring(d,d+3)),10),d+=3;d<c.length&&(c.length-d==1?l.put(i(c.substring(d,d+1)),4):c.length-d==2&&l.put(i(c.substring(d,d+2)),7))};const i=function(l){let c=0;for(let d=0;d<l.length;d+=1)c=c*10+a(l.charAt(d));return c},a=function(l){if("0"<=l&&l<="9")return l.charCodeAt(0)-48;throw"illegal char :"+l};return r},QL=function(e){const t=ir.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(i(l.charAt(c))*45+i(l.charAt(c+1)),11),c+=2;c<l.length&&a.put(i(l.charAt(c)),6)};const i=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},XL=function(e){const t=ir.MODE_8BIT_BYTE,n=Js.stringToBytes(e),r={};return r.getMode=function(){return t},r.getLength=function(i){return n.length},r.write=function(i){for(let a=0;a<n.length;a+=1)i.put(n[a],8)},r},JL=function(e){const t=ir.MODE_KANJI,n=Js.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),i={};return i.getMode=function(){return t},i.getLength=function(a){return~~(r.length/2)},i.write=function(a){const l=r;let c=0;for(;c+1<l.length;){let d=(255&l[c])<<8|255&l[c+1];if(33088<=d&&d<=40956)d-=33088;else if(57408<=d&&d<=60351)d-=49472;else throw"illegal char at "+(c+1)+"/"+d;d=(d>>>8&255)*192+(d&255),a.put(d,13),c+=2}if(c<l.length)throw"illegal char at "+(c+1)},i},ox=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,i){r=r||0,i=i||n.length;for(let a=0;a<i;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},eD=function(){let e=0,t=0,n=0,r="";const i={},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 i.writeByte=function(c){for(e=e<<8|c&255,t+=8,n+=1;t>=6;)a(e>>>t-6),t-=6},i.flush=function(){if(t>0&&(a(e<<6-t),e=0,t=0),n%3!=0){const c=3-n%3;for(let d=0;d<c;d+=1)r+="="}},i.toString=function(){return r},i},tD=function(e){const t=e;let n=0,r=0,i=0;const a={};a.read=function(){for(;i<8;){if(n>=t.length){if(i==0)return-1;throw"unexpected end of file./"+i}const d=t.charAt(n);if(n+=1,d=="=")return i=0,-1;if(d.match(/^\s$/))continue;r=r<<6|l(d.charCodeAt(0)),i+=6}const c=r>>>i-8&255;return i-=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},nD=function(e,t){const n=e,r=t,i=new Array(e*t),a={};a.setPixel=function(g,k,p){i[k*n+g]=p},a.write=function(g){g.writeString("GIF87a"),g.writeShort(n),g.writeShort(r),g.writeByte(128),g.writeByte(0),g.writeByte(0),g.writeByte(0),g.writeByte(0),g.writeByte(0),g.writeByte(255),g.writeByte(255),g.writeByte(255),g.writeString(","),g.writeShort(0),g.writeShort(0),g.writeShort(n),g.writeShort(r),g.writeByte(0);const k=2,p=c(k);g.writeByte(k);let h=0;for(;p.length-h>255;)g.writeByte(255),g.writeBytes(p,h,255),h+=255;g.writeByte(p.length-h),g.writeBytes(p,h,p.length-h),g.writeByte(0),g.writeString(";")};const l=function(g){const k=g;let p=0,h=0;const v={};return v.write=function(b,_){if(b>>>_)throw"length over";for(;p+_>=8;)k.writeByte(255&(b<<p|h)),_-=8-p,b>>>=8-p,h=0,p=0;h=b<<p|h,p=p+_},v.flush=function(){p>0&&k.writeByte(h)},v},c=function(g){const k=1<<g,p=(1<<g)+1;let h=g+1;const v=d();for(let x=0;x<k;x+=1)v.add(String.fromCharCode(x));v.add(String.fromCharCode(k)),v.add(String.fromCharCode(p));const b=ox(),_=l(b);_.write(k,h);let E=0,j=String.fromCharCode(i[E]);for(E+=1;E<i.length;){const x=String.fromCharCode(i[E]);E+=1,v.contains(j+x)?j=j+x:(_.write(v.indexOf(j),h),v.size()<4095&&(v.size()==1<<h&&(h+=1),v.add(j+x)),j=x)}return _.write(v.indexOf(j),h),_.write(p,h),_.flush(),b.toByteArray()},d=function(){const g={};let k=0;const p={};return p.add=function(h){if(p.contains(h))throw"dup key:"+h;g[h]=k,k+=1},p.size=function(){return k},p.indexOf=function(h){return g[h]},p.contains=function(h){return typeof g[h]<"u"},p};return a},rD=function(e,t,n){const r=nD(e,t);for(let c=0;c<t;c+=1)for(let d=0;d<e;d+=1)r.setPixel(d,c,n(d,c));const i=ox();r.write(i);const a=eD(),l=i.toByteArray();for(let c=0;c<l.length;c+=1)a.writeByte(l[c]);return a.flush(),"data:image/gif;base64,"+a};Js.stringToBytes;function oD(e){const t=Js(0,"M");t.addData(e,"Byte"),t.make();const n=t.getModuleCount();return Array.from({length:n},(r,i)=>Array.from({length:n},(a,l)=>t.isDark(i,l)))}const op=4;function iD({text:e,spent:t}){const{size:n,d:r}=T.useMemo(()=>{const i=oD(e);let a="";return i.forEach((l,c)=>{l.forEach((d,g)=>{d&&(a+=`M${g+op} ${c+op}h1v1h-1z`)})}),{size:i.length+op*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 sD(e){const[t,n]=T.useState(0);return T.useEffect(()=>{if(!e)return;const r=performance.now()+e.ms,i=()=>n(Math.max(0,Math.ceil((r-performance.now())/1e3)));i();const a=setInterval(i,250);return()=>clearInterval(a)},[e]),t}function aD(){const e=Ve(),t=z(b=>{var _;return((_=b.remote)==null?void 0:_.host)??null}),n=z(b=>b.pairings),[r,i]=T.useState(null),[a,l]=T.useState(null),[c,d]=T.useState(0),g=T.useRef(n),k=sD(r);ft([c],()=>{let b=!0;return i(null),l(null),hR().then(_=>{b&&(g.current=n,typeof _=="string"?l(_):i(_))}),()=>{b=!1}});const p=r!==null&&n>g.current,h=r!==null&&k===0,v=()=>e({a:"close"});return f.jsx(Zu,{bare:!0,boxClass:"pair-stack",onClose:v,children:f.jsxs("div",{className:"pair-card",children:[f.jsx("div",{className:"pair-title",children:"Open on your phone"}),p?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(iD,{text:r.url,spent:h})}),t&&f.jsx("div",{className:"hint pair-host",children:t}),f.jsx("p",{className:"pair-line",children:r?h?"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:k})," seconds left."]}):"Making a code."})]}),f.jsxs("div",{className:"pair-actions",children:[(h||a)&&!p&&f.jsx($e,{variant:"outline",onClick:()=>d(b=>b+1),children:"new code"}),f.jsx($e,{tone:"quiet",onClick:v,children:"done"})]})]})})}function Vh({form:e}){var j;const t=Ve(),n=Ge(),r=z(x=>x.repos),i=z(x=>x.newProject?null:x.activeRepoId),a=z(x=>x.rows),l=z(x=>x.paths),c=z(x=>x.home),d=z(x=>x.pending),g=T.useCallback(x=>{Ku(x)&&(n==null||n.send({t:"browse-path",path:x}))},[n]),k=T.useCallback((x,H)=>GL({query:H,repos:r,pending:d,entries:[...l.entries].sort((B,re)=>Number(re.isRepo)-Number(B.isRepo)),target:l.target,answered:l.query}),[r,l,d]),p=x=>{const H=a.filter(I=>I.repoId===x.id),B=H.filter(Mn).filter(I=>I.worktree.kind!=="spare"),re=B.filter(Lu).length,F=B.length-1,C=H.length-H.filter(Mn).length;return[F>0?`${F} worktree${F===1?"":"s"}`:null,re>0?`${re} working`:null,C>0?`${C} discovered`:null].filter(Boolean).join(" · ")||void 0},h=()=>t({a:"close"}),v=()=>t({a:"close",back:!0}),b=x=>{t({a:"open-repo"}),n==null||n.send({t:"register-repo",path:x})},_=(x,H)=>{t({a:"open-repo"}),n==null||n.send({t:"create-repo",mode:"create",parent:x,name:H})},E=(x,H,B)=>t({a:"new-project",v:lh({mode:x,name:H,parent:KL(r,i,c),...B?{url:B}:{}})});return f.jsx(yr,{anchored:e==="pill",initialQuery:e==="disk"?"~/":"",lead:e==="disk"?void 0:f.jsx("span",{className:"picker-chip",children:((j=r.find(x=>x.id===i))==null?void 0:j.name)??"no project"}),trailing:e==="disk"?void 0:f.jsx(Dt,{icon:"folder",label:"Find a project on disk",onClick:()=>t({a:"open",overlay:{kind:"projects",form:"disk"}})}),items:[],filter:k,initialIndex:x=>x.findIndex(H=>H.kind==="repo"&&H.repo.id===i),keyOf:x=>x.kind==="repo"?x.repo.id:x.kind==="dir"?`d:${x.entry.path}`:x.kind==="open"?`open:${x.path}`:x.kind==="pending"?`p:${x.pending.id}`:x.kind==="clone"?`clone:${x.url}`:x.kind==="new"?"new-project":`new:${x.parent??""}/${x.name}`,rowClass:x=>Ke("picker-row",x.kind==="new"&&"new-project-row"),onQuery:g,completionOf:x=>x.kind==="dir"?x.entry.isRepo?x.entry.path:`${x.entry.path}/`:null,narrowTo:x=>x.kind==="dir"&&!x.entry.isRepo?`${x.entry.path}/`:null,onPick:x=>{if(x.kind==="clone")return E("clone",x.name,x.url);if(x.kind==="create"&&!x.parent)return E("create",x.name);if(x.kind==="new")return E("create","");x.kind==="pending"?t({a:"watch-import",id:x.pending.id}):x.kind==="repo"?t({a:"activate-repo",id:x.repo.id}):x.kind==="open"?b(x.path):x.kind==="dir"?b(x.entry.path):x.parent&&_(x.parent,x.name),h()},onBack:v,rowMenu:x=>x.kind==="repo"?Wu(x.repo,i,{sock:n,dispatch:t}):x.kind==="pending"?l4(x.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:x=>({complete:"completes the path",pick:(x==null?void 0:x.kind)==="dir"&&!x.entry.isRepo?"descends":(x==null?void 0:x.kind)==="pending"?"watches it":(x==null?void 0:x.kind)==="create"?x.parent?"creates it":"names it":(x==null?void 0:x.kind)==="clone"?"clones it":(x==null?void 0:x.kind)==="new"?"starts one":"opens",back:"closes"}),empty:"nothing here; keep typing a path (~/… or /…)",row:x=>x.kind==="repo"?f.jsx(On,{label:x.repo.name,current:x.repo.id===i,hint:p(x.repo)}):x.kind==="pending"?f.jsx(On,{label:x.pending.name,hint:x.pending.error?"import failed":"importing…"}):x.kind==="dir"?f.jsx(On,{label:x.entry.name,hint:x.entry.isRepo?"git repo":void 0}):x.kind==="open"?f.jsx(On,{label:`open ${x.path}`,hint:"register with this daemon"}):x.kind==="clone"?f.jsx(On,{label:`clone ${x.name}`,hint:lD(x.url)}):x.kind==="new"?f.jsx(On,{label:f.jsxs(f.Fragment,{children:[f.jsx(Ct,{name:"plus",className:"icon-inline"}),"new project"]})}):f.jsx(On,{label:`create ${x.name}`,hint:x.parent?`in ${x.parent}`:"new project"})})}function lD(e){const t=e.match(/^[a-z+]+:\/\/(?:[^@/]*@)?([^/:]+)/i)??e.match(/^[^@]+@([^:]+):/);return(t==null?void 0:t[1])??"git remote"}function cD(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:()=>Zt(r)})}const n=[{id:"copy-ref",label:e.kind==="pr"?"copy PR number":"copy branch name",onClick:()=>Zt(e.ref)}];return Nn([t,n])}const uD=[],dD={branch:"branch",remote:"globe",pr:"pr"};function fD({repoId:e}){const t=Ve(),n=Ge(),r=z(p=>p.clientId),i=z(p=>p.refs[e]),a=z(p=>p.rows),l=p=>{var h;return((h=a.find(v=>v.id===p))==null?void 0:h.name)??"a worktree"},c=T.useCallback(p=>p,[]),d=T.useCallback(p=>n==null?void 0:n.send({t:"search-refs",repoId:e,query:p.trim()}),[n,e]),g=p=>!i||i.query!==p.trim(),k=p=>p.openIn?`open in ${l(p.openIn)}`:p.merged?"merged":p.pr?`${p.pr.author}${p.pr.draft?" · draft":""}${p.pr.fork?" · fork":""}`:p.subject??"";return f.jsx(yr,{items:(i==null?void 0:i.refs)??uD,filter:c,onQuery:d,keyOf:p=>`${p.kind}:${p.ref}`,rowClass:()=>"picker-row ref-row",onPick:p=>{p.openIn?t({a:"activate",id:p.openIn}):n==null||n.send({t:"open-ref",repoId:e,kind:p.kind,ref:p.ref,clientId:r,...p.pr?{pr:{title:p.pr.title,url:p.pr.url}}:{}}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:cD,placeholder:"open a branch or PR…",keys:p=>({nav:"moves",pick:p!=null&&p.openIn?"switches to it":"opens it as a worktree",back:"closes"}),empty:p=>g(p)?"looking…":p.trim()?"no branch or PR matches":"no unmerged branches or open PRs",row:p=>f.jsx(On,{label:f.jsxs(f.Fragment,{children:[f.jsx(Ct,{name:dD[p.kind],className:"icon-inline"}),p.name]}),hint:k(p)})})}const Bv=[],ip=2;function pD({worktreeId:e}){const t=Ve(),n=Ge(),r=w0(e).search,i=z(g=>g.layout.changes),a=z(g=>{var p;const k=(p=Yt(g,e))==null?void 0:p.worktree;return k?k.path:null}),l=T.useCallback((g,k)=>k.trim().length>=ip?g:Bv,[]),c=T.useCallback(g=>{const k=g.trim();k.length>=ip&&(n==null||n.send({t:"search",worktreeId:e,query:k}))},[n,e]),d=g=>!r||r.query.trim()!==g.trim();return f.jsx(yr,{items:(r==null?void 0:r.hits)??Bv,filter:l,onQuery:c,keyOf:g=>`${g.path}:${g.line}`,rowClass:()=>"search-hit",rowTitle:g=>`${g.path}:${g.line}`,onPick:g=>{ar({dispatch:t},{worktreeId:e,path:g.path,view:"file",line:{n:g.line}}),i||t({a:"toggle-changes"}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:g=>a?vi({id:e,dir:a},g.path,{},{sock:n,dispatch:t}):[],placeholder:"search in files…",keys:{pick:"opens the file",back:"closes"},empty:g=>g.trim().length<ip?"type at least two characters":d(g)?"searching…":"no matches",footer:(g,k)=>r!=null&&r.truncated&&!d(g)&&k.length>0?f.jsxs("div",{className:"empty",children:["showing the first ",k.length,"; narrow the search"]}):null,row:g=>f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"search-loc",children:[g.path,":",g.line]}),f.jsx("span",{className:"search-text",children:g.text})]})})}const Uv=e=>e.source==="file"?"~/.toyon/themes":e.source==="vscode"?"VS Code":"";function hD({slot:e}){const t=Ve(),n=Ge(),r=z(x=>x.themePrefs),i=z(x=>x.themes),a=dh(),l=ah(r,a),c=r[e==="theme"?l:e],d=()=>t({a:"close"}),g=()=>t({a:"close",back:!0}),k=x=>t({a:"preview-theme",theme:x}),[p,h]=T.useState(null),[v,b]=T.useState(null),_=(x,H)=>x[H??l]??x.dark??x.light??null,E=T.useMemo(()=>lI(i),[i]),j=T.useMemo(()=>i.filter(x=>x.kind===e),[i,e]);return ft([p,v],()=>{e==="theme"&&k(p?_(p,v):null)}),e!=="theme"?f.jsx(yr,{items:j,filter:(x,H)=>x.filter(B=>Us(H,B.name,B.id)),rowClass:()=>"picker-row",keyOf:x=>x.id,initialIndex:x=>x.findIndex(H=>H.id===c),onActive:k,onPick:x=>{n==null||n.send({t:"set-theme",prefs:{...r,[e]:x.id}}),d()},onBack:g,placeholder:`${e} slot override`,keys:{nav:"preview",pick:"keeps",back:"reverts"},empty:"no matching theme",row:x=>f.jsx(On,{label:x.name,current:x.id===c,hint:Uv(x)})}):f.jsx(yr,{items:E,filter:(x,H)=>x.filter(B=>{var re,F;return Us(H,B.name,(re=B.dark)==null?void 0:re.name,(F=B.light)==null?void 0:F.name)}),rowClass:()=>"picker-row",keyOf:x=>{var H,B;return x.name+(((H=x.dark)==null?void 0:H.id)??((B=x.light)==null?void 0:B.id))},initialIndex:x=>x.findIndex(H=>{var B,re;return((B=H.dark)==null?void 0:B.id)===c||((re=H.light)==null?void 0:re.id)===c}),onActive:h,onSide:x=>{var H;x.dark&&x.light&&b((((H=_(x,v))==null?void 0:H.kind)??l)==="dark"?"light":"dark")},onPick:x=>{n==null||n.send({t:"set-theme",prefs:cI(r,x)}),d()},onBack:g,placeholder:"theme",keys:{nav:"preview",side:"dark/light",pick:"keeps",back:"reverts"},empty:"no matching theme",row:(x,H)=>{var C,L;const B=_(x,H?v:null),re=Uv(x.dark??x.light),F=((C=x.dark)==null?void 0:C.id)===c||((L=x.light)==null?void 0:L.id)===c;return f.jsx(On,{label:x.name,current:F,hint:f.jsxs("span",{className:"theme-kinds",children:[re&&f.jsx("span",{children:re}),f.jsx("span",{className:"kind","data-state":Ln({current:H&&(B==null?void 0:B.kind)==="dark"}),children:x.dark?"dark":""}),f.jsx("span",{className:"kind","data-state":Ln({current:H&&(B==null?void 0:B.kind)==="light"}),children:x.light?"light":""})]})})}})}function ix(){const e=s2(),t=z(a=>a.frame==="phone"),n=Vs(),r=z(a=>a.activeRepoId),i=z(a=>a.newProject);return f.jsxs(f.Fragment,{children:[(e==null?void 0:e.kind)==="quick-open"&&n&&f.jsx(F4,{worktreeId:n}),(e==null?void 0:e.kind)==="search"&&n&&f.jsx(pD,{worktreeId:n}),(e==null?void 0:e.kind)==="element-sources"&&f.jsx(WL,{worktreeId:e.worktreeId,hits:e.hits}),(e==null?void 0:e.kind)==="refs"&&r&&f.jsx(fD,{repoId:r}),(e==null?void 0:e.kind)==="chats"&&r&&f.jsx(ZL,{repoId:r}),(e==null?void 0:e.kind)==="archived"&&f.jsx(zL,{repoId:e.repoId}),(e==null?void 0:e.kind)==="keys"&&f.jsx(CL,{}),(e==null?void 0:e.kind)==="pair"&&f.jsx(aD,{}),(e==null?void 0:e.kind)==="theme"&&f.jsx(hD,{slot:e.slot}),(e==null?void 0:e.kind)==="appearance"&&f.jsx(PL,{}),(e==null?void 0:e.kind)==="agent"&&f.jsx(OL,{}),(e==null?void 0:e.kind)==="agent-page"&&f.jsx(IL,{agentId:e.agent}),(e==null?void 0:e.kind)==="commands"&&!t&&f.jsx(Z1,{}),(e==null?void 0:e.kind)==="projects"&&e.form!=="pill"&&f.jsx(Vh,{form:e.form},e.form),(e==null?void 0:e.kind)==="choose-folder"&&i&&f.jsx(qL,{project:i})]})}const Zc="Lost the daemon; retrying",mD="Not run by Toyon",gD="new worktree",kD=new Set(["waiting","working","starting","failed","crashed"]);function sx(e,t){if(t.offline)return Zc;if(!Mn(e))return e.locked?`Held by ${e.lockReason??"another tool"}`:t.path;if(t.op)return K0(t.op);if(Yn(e.worktree))return gD;const n=wh(e,t.needsSetup),r=e.worktree.lastTurn;return!kD.has(Bs(e))&&r?Nh(r):t.at?`${n} · ${t.at}`:n}const Oc=e=>e>999?"1k+":String(e);function ax({width:e,placement:t="strip"}){const n=t==="screen",r=Xi(),i=z(te=>te.chatSide)==="left"?"right":"left",a=Ve(),l=Ge(),c=ph(),d=c[0]&&Yn(c[0].worktree)?c[0]:null,g=d?c.slice(1):c,k=z(te=>zs(te,te.activeRepoId)),p=te=>d&&te.id===d.id&&k?{behind:k.behind,dirty:k.dirty}:te,[,h]=T.useState(0);T.useEffect(()=>{const te=setInterval(()=>h(pe=>pe+1),6e4);return()=>clearInterval(te)},[]);const v=r2(),b=o2(),_=v0(),E=i2(),j=Qi(),x=z(te=>te.clientId),H=z(te=>te.activeRepoId),B=z(te=>te.connected);T.useEffect(()=>{l&&B&&H&&l.send({t:"list-archived",repoId:H})},[l,B,H]);const re=Vs(),F=k0(),C=z(te=>te.layout),L=z(te=>te.railOpen),I=z(te=>te.railPeek),Z=T.useRef(null),[V,K]=T.useState(!1);ft([I],()=>{var te;I&&!n&&!r&&!((te=Z.current)!=null&&te.matches(":hover"))&&K(!0)}),T.useEffect(()=>{if(!V)return;let te=null;const pe=rt=>{if(!te){te={x:rt.clientX,y:rt.clientY};return}Math.abs(rt.clientX-te.x)+Math.abs(rt.clientY-te.y)<3||K(!1)};return window.addEventListener("pointermove",pe),()=>window.removeEventListener("pointermove",pe)},[V]);const le=z(te=>te.focusRail),de=T.useRef(le),Q=T.useRef(null);ft([le],()=>{if(le===de.current)return;de.current=le;const te=requestAnimationFrame(()=>{var pe,rt;return(rt=(pe=Q.current)==null?void 0:pe.querySelector('[data-state~="current"]'))==null?void 0:rt.focus()});return()=>cancelAnimationFrame(te)});const ce=z(te=>te.repos),R=z(te=>te.shipping),M=te=>ce.find(pe=>pe.id===te.repoId)??null,G=Wt("rail"),ne=z0(),O=z(te=>te.home),ee=te=>{const pe=te.worktree?te.worktree.path:te.path;return O&&pe.startsWith(`${O}/`)?`~${pe.slice(O.length)}`:pe},D=te=>{var pe;return Mn(te)&&Yn(te.worktree)?[(pe=M(te))==null?void 0:pe.name,ou(te,M(te))].filter(Boolean).join(" · "):te.branch??te.name},q=te=>{const pe=te.usage,rt=[(pe==null?void 0:pe.cost)!==void 0?sl(pe.cost):null,pe?`${su(pe.used)} of ${su(pe.size)}`:null];return rt.some(Boolean)?rt.filter(Boolean).join(" · "):void 0},[Te,Ne]=T.useState(!1),[je,Re]=T.useState([]),Ze=te=>{Pc(te.worktree)&&(Ne(!0),Re(pe=>pe.includes(te.worktree.id)?pe.filter(rt=>rt!==te.worktree.id):[...pe,te.worktree.id]))},st=()=>{Ne(!1),Re([])};ft([Te],()=>{const te=pe=>pe.key==="Escape"&&st();return Te&&window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)});const Ee=nb(l,a),Tt={sock:l,dispatch:a},zt=te=>{Ne(!0),Re(pe=>te===re||pe.includes(te)?pe:[...pe,te])},Xe=te=>Mn(te)?rb(te,M(te),{layout:C,shipping:R},Tt,{graft:zt,hostname:location.hostname}):DR(te,{clientId:x},Tt,location.hostname),pt=_.some(te=>(te.dirty??0)>0),ht=te=>f.jsxs("button",{type:"button",className:Ke("row row-edge row-quiet rail-disc-item rail-arch-item",(ne==null?void 0:ne.owner)==="rail"&&ne.key===te.id&&"menu-open"),"data-state":Ln({current:(j==null?void 0:j.id)===te.id}),...Et(iO(te),void 0,{placement:i,name:te.branch,aside:te.cost!==void 0?sl(te.cost):void 0}),onClick:()=>a({a:"open-archived",id:te.id}),...G.contextMenu(()=>Bc(te,x,Tt),te.id),children:[f.jsxs("span",{className:"rail-gut",onClick:r?pe=>{pe.stopPropagation(),G.openUnder(pe.currentTarget,()=>Bc(te,x,Tt),te.id)}:void 0,children:[f.jsx("span",{className:"rail-at row-dim",children:yo(te.archivedAt)}),f.jsx("span",{className:"rail-more",...Et("Actions"),onClick:pe=>{pe.stopPropagation(),G.openUnder(pe.currentTarget,()=>Bc(te,x,Tt),te.id)},children:f.jsx(Ct,{name:"more"})})]}),f.jsx("span",{className:"branch",children:te.title}),pt&&f.jsx("span",{className:"rail-counts",children:f.jsx("span",{className:"rail-count row-dim","data-tip":te.dirty?`${te.dirty} uncommitted, kept`:void 0,children:te.dirty?`~${Oc(te.dirty)}`:""})}),te.auto?f.jsx("span",{className:"rail-glyph rail-auto row-dim",...Et(`Archived automatically: ${te.auto}`,void 0,{placement:i}),children:f.jsx(Ct,{name:"clock",className:"icon-inline"})}):f.jsx("span",{className:"dot"}),n&&f.jsx("span",{className:"rail-at rail-at-end row-dim",children:yo(te.archivedAt)})]},te.id),wn=[...c,...v].map(p),jt={dirty:wn.some(te=>(te.dirty??0)>0),behind:wn.some(te=>(te.behind??0)>0),ahead:wn.some(te=>(te.ahead??0)>0)},Ft=te=>{const pe=Mn(te)?te:null,rt=!!pe&&Yn(pe.worktree),at=p(te),ut=te.id,tn=(ne==null?void 0:ne.owner)==="rail"&&ne.key===ut,Kt=pe&&Te&&Pc(pe.worktree)&&ut!==re,tt=xR(te,R[ut]);return f.jsxs("button",{type:"button",className:Ke("row row-edge",pe?"rail-item":"row-quiet rail-disc-item",tn&&"menu-open"),"data-state":Ln({current:ut===re&&!j,checked:je.includes(ut)}),...pe?Et(F?Zc:tt?K0(tt):wh(te,tu(M(pe))),void 0,{placement:i,name:D(te),aside:q(te),detail:te.unseen&&pe.worktree.lastTurn?Nh(pe.worktree.lastTurn):void 0,dot:F?void 0:tt?"spinner":Bs(te)}):Et(F?Zc:te.locked?`Held by ${te.lockReason??"another tool"}`:mD,void 0,{placement:i,name:D(te),detail:ee(te),dot:F||te.locked?void 0:"discovered"}),"data-wt":ut,onKeyDown:qe=>{var lt,At;if(!pe||Te||qe.key!=="ArrowUp"&&qe.key!=="ArrowDown"||qe.altKey||qe.ctrlKey||qe.metaKey)return;qe.preventDefault();const nn=qe.key==="ArrowDown",ie=c.findIndex(bt=>bt.id===ut),he=c[ie+(nn?1:-1)];he&&(a({a:"activate",id:he.id}),(At=(lt=qe.currentTarget.parentElement)==null?void 0:lt.querySelector(`[data-wt="${he.id}"]`))==null||At.focus())},onClick:qe=>{pe&&(Te||qe.shiftKey)?ut===re?Ne(!0):Ze(pe):a(rt&&!n?{a:"open-draft"}:{a:"activate",id:ut})},...G.contextMenu(()=>Xe(te),ut),children:[f.jsx("span",{className:"rail-gut",onClick:r&&!Te?qe=>{qe.stopPropagation(),G.openUnder(qe.currentTarget,()=>Xe(te),ut)}:void 0,children:Kt?f.jsx("input",{type:"checkbox",className:"rail-graft-check",checked:je.includes(ut),readOnly:!0,tabIndex:-1}):!Te&&f.jsxs(f.Fragment,{children:[pe&&!rt&&f.jsx("span",{className:"rail-at row-dim",children:yo(Qa(pe.worktree))}),f.jsx("span",{className:"rail-more",...Et("Actions"),onClick:qe=>{qe.stopPropagation(),G.openUnder(qe.currentTarget,()=>Xe(te),ut)},children:f.jsx(Ct,{name:"more"})})]})}),rt?f.jsxs("span",{className:"branch rail-main-label",children:[f.jsx(Ct,{name:"plus",className:"icon-inline"}),"new worktree"]}):f.jsx("span",{className:Ke("branch",(pe==null?void 0:pe.worktree.unnamed)&&"row-dim"),children:ou(te,pe?M(pe):null)}),(pe==null?void 0:pe.worktree.mode)&&pe.worktree.mode!=="auto"&&f.jsx("span",{className:"rail-badge badge-mode","data-tip":`${pe.worktree.mode} mode: the agent waits for you`,children:pe.worktree.mode}),pe&&(()=>{const qe=M(pe),nn=J0(pe.worktree,qe);return nn&&nn!==(qe==null?void 0:qe.config.defaultProfile)?f.jsx("span",{className:"rail-badge badge-profile","data-tip":`runs the ${nn} profile`,children:nn}):null})(),(pe==null?void 0:pe.worktree.variant)&&f.jsxs("span",{className:"rail-badge badge-variant clickable","data-tip":"Keep this variant, archive the others",onClick:qe=>{qe.stopPropagation(),Ee.pickVariant(pe)},children:[f.jsxs("span",{className:"num",children:["v",pe.worktree.variant.index,"/",pe.worktree.variant.of]}),f.jsx("span",{className:"act",children:"pick"})]}),f.jsxs("span",{className:"rail-counts",children:[jt.dirty&&f.jsx("span",{className:"rail-count badge-dirty","data-tip":at.dirty?`${at.dirty} uncommitted${rt?" on main":""}`:void 0,children:at.dirty?`~${Oc(at.dirty)}`:""}),jt.behind&&f.jsx("span",{className:"rail-count rail-behind row-dim","data-tip":at.behind?`${at.behind} behind ${rt?"origin":"main"}`:void 0,children:at.behind?Oc(at.behind):""}),jt.ahead&&f.jsx("span",{className:"rail-count badge-ahead","data-tip":at.ahead?`${at.ahead} ahead of main`:void 0,children:at.ahead?`+${Oc(at.ahead)}`:""})]}),(()=>{if(tt)return f.jsx(vh,{size:"dot"});if(te.locked)return f.jsx("span",{className:"rail-glyph rail-lock row-dim",children:f.jsx(Ct,{name:"lock",className:"icon-inline"})});if(!pe)return f.jsx("span",{className:"dot discovered"});const qe=Te||F?null:G0(te.procs),nn=te.unseen?" unseen":"",ie=Bs(te);return rt&&!qe&&ie!=="crashed"&&!F?f.jsxs(f.Fragment,{children:[f.jsx("span",{className:`dot ${ie} rail-main-dot`}),f.jsx("span",{className:"rail-glyph rail-main-strip",children:f.jsx(Ct,{name:"plus"})})]}):!qe||ie!=="crashed"?f.jsx("span",{className:`dot ${ie}${nn}`}):f.jsx("span",{className:`dot crashed clickable${nn}`,...Et(qe.tip),onClick:he=>{he.stopPropagation(),a({a:"activate",id:ut}),a({a:"term-stream",id:ut,stream:qe.stream})}})})(),n&&f.jsx("span",{className:"rail-say row-dim",children:sx(te,{offline:F,needsSetup:tu(pe?M(pe):null),path:ee(te),at:pe&&!rt?yo(Qa(pe.worktree)):void 0,op:tt})})]},ut)};return f.jsx("div",{ref:Z,className:Ke("rail",n&&"rail-screen",!n&&(Te||(ne==null?void 0:ne.owner)==="rail"||I)&&"hold",V&&"quiet",(n||L)&&"pinned",F&&"offline"),style:e!==void 0&&!n?{"--rail-width":`${e}px`}:void 0,onClick:r&&!n&&!L?te=>{te.target instanceof Element&&te.target.closest("button, .rail-gut")||a({a:"toggle-rail"})}:void 0,children:f.jsxs("div",{className:"rail-panel","data-tip":F?Zc:void 0,"data-tip-placement":"follow",children:[f.jsxs("div",{className:"rail-list",ref:Q,children:[d&&!n&&Ft(d),g.map(Ft),Te&&f.jsxs("div",{className:"rail-graft",children:[(()=>{const te=c.find(at=>at.worktree.id===re&&Pc(at.worktree)),pe=je.filter(at=>at!==(te==null?void 0:te.worktree.id)),rt=pe.map(at=>{var ut;return((ut=c.find(tn=>tn.worktree.id===at))==null?void 0:ut.worktree.title)??at}).join(", ");return f.jsxs($e,{size:"md",tone:"primary",disabled:!te||pe.length===0,"data-tip":te?`Merge the checked worktrees into ${te.worktree.title} and remove them`:"Select a worktree to graft onto",onClick:()=>{te&&window.confirm(`Graft ${rt} onto ${te.worktree.title}?
215
+
216
+ Their branches are merged in, then their directories and branches are removed.`)&&(l==null||l.send({t:"graft",targetId:te.worktree.id,sourceIds:pe}),st())},children:["graft ",pe.length]})})(),f.jsxs($e,{size:"md",disabled:!je.some(te=>{var pe;return(((pe=c.find(rt=>rt.worktree.id===te))==null?void 0:pe.behind)??0)>0}),"data-tip":"Pull main into every selected worktree that's behind",onClick:()=>{for(const te of je){const pe=c.find(rt=>rt.worktree.id===te);((pe==null?void 0:pe.behind)??0)>0&&wi(l,a,{t:"sync-main",worktreeId:te})}st()},children:[f.jsx(Ct,{name:"pull",className:"icon-inline"})," sync"]}),f.jsx($e,{size:"md",tone:"danger",disabled:je.length===0,"data-tip":"Archive all selected worktrees; their chats and work are kept",onClick:()=>{window.confirm(`Archive ${je.length} worktree(s)?
217
+
218
+ Their directories and branches go. The chats, commits and any uncommitted changes are kept, and each can be restored.`)&&(Vi(l,a,je),st())},children:"archive…"}),f.jsx(Dt,{icon:"close",label:"Cancel",hint:"esc",onClick:st})]}),!Te&&v.length>0&&f.jsxs(f.Fragment,{children:[f.jsxs("button",{className:"rail-disc-head","aria-expanded":b,...Et(`${v.length} worktree${v.length===1?"":"s"} here that Toyon did not make`,void 0,{placement:i}),onClick:()=>a({a:"toggle-discovered"}),children:[f.jsx("span",{className:"rail-gut",children:f.jsx(Ct,{name:"caret",className:Ke("icon-inline disc-caret",!b&&"shut")})}),f.jsxs("span",{className:"rail-label",children:["discovered · ",v.length]})]}),b&&v.map(Ft)]}),!Te&&_.length>0&&f.jsxs(f.Fragment,{children:[f.jsxs("button",{type:"button",className:"rail-disc-head","aria-expanded":E,...Et(`${_.length} archived worktree${_.length===1?"":"s"}, kept with ${_.length===1?"its chat":"their chats"}`,void 0,{placement:i}),onClick:()=>a({a:"toggle-archived"}),children:[f.jsx("span",{className:"rail-gut",children:f.jsx(Ct,{name:"caret",className:Ke("icon-inline disc-caret",!E&&"shut")})}),f.jsxs("span",{className:"rail-label",children:["archived · ",_.length]})]}),E&&_.map(ht)]})]}),!n&&f.jsx("div",{className:"rail-foot",children:f.jsx(Dt,{icon:"worktrees",label:"Worktree panel",hint:ct("rail"),tone:"chrome",on:L,onClick:()=>a({a:"toggle-rail"})})})]})})}function yD({screen:e,tabs:t}){const n=Ve(),r=qs(),i=z(H=>H.repos),a=Vo(),l=Vs(),c=Qi(),d=ph(),g=k0(),k=a4(d,l),p=d.find(H=>Yn(H.worktree)),h=e==="home",v=h?(r==null?void 0:r.name)??null:(c==null?void 0:c.title)??(a==null?void 0:a.worktree.title)??null,b=d.filter(H=>!Yn(H.worktree)).length,_=h?b===0?"no worktrees yet":`${b} ${b===1?"worktree":"worktrees"}`:c?Th(c):a?sx(a,{offline:g,needsSetup:tu(r),path:a.worktree.path,at:Yn(a.worktree)?void 0:yo(Qa(a.worktree))}):null,E=!h&&!c&&!!a&&Bs(a)==="waiting",j=z(H=>{var B;return((B=H.overlay)==null?void 0:B.kind)==="projects"&&H.overlay.form==="pill"}),x=z(H=>{var B;return((B=H.overlay)==null?void 0:B.kind)==="commands"});return f.jsxs("div",{className:"phone-bar",children:[f.jsxs("div",{className:"phone-bar-row",children:[!h&&f.jsx(Dt,{icon:"back",label:"Worktrees",tone:"chrome",onClick:()=>n({a:"screen",to:"home"})}),f.jsxs("div",{className:"phone-title",children:[h&&i.length>1?f.jsxs("span",{className:"phone-drop phone-switch",children:[f.jsxs($e,{size:"md",tone:"chrome",on:j,onClick:()=>n({a:"toggle",overlay:{kind:"projects",form:"pill"}}),children:[v,f.jsx(Ct,{name:"caret",className:"icon-inline"})]}),j&&f.jsx(Vh,{form:"pill"})]}):f.jsx("span",{className:"phone-name",children:v}),_&&f.jsx("span",{className:Ke("phone-sub",E&&"phone-sub-asks"),children:_})]}),k&&f.jsxs($e,{size:"md",tone:"primary",onClick:()=>{const H=zh(d,l,1);H&&n({a:"activate",id:H.activate})},children:[k.n," ",k.tier]}),h&&p&&f.jsx(Dt,{icon:"plus",label:"New worktree",tone:"chrome",onClick:()=>n({a:"activate",id:p.id})}),f.jsxs("span",{className:"phone-drop",children:[f.jsx(Dt,{icon:"more",label:"Menu",tone:"chrome",on:x,onClick:()=>n({a:"toggle",overlay:{kind:"commands"}})}),x&&f.jsx(Z1,{anchored:{flip:"align",margin:6},trailing:f.jsx(Dt,{icon:"close",label:"Close",tone:"chrome",onClick:()=>n({a:"close"})})})]})]}),t&&f.jsx("div",{className:"phone-tabs",children:t})]})}function vD({active:e,url:t,hidden:n}){return f.jsx("div",{className:"phone-preview",hidden:n,children:uh(e)?f.jsx("iframe",{className:"phone-preview-frame",src:t,title:e.worktree.title}):f.jsx(qo,{wide:!0,children:f.jsx("p",{className:"status-line",children:wh(e)})})})}const wD=U0();function bD(){const e=Ve(),t=z(x=>x.screen),n=Vo(),r=Qi(),i=z(x=>x.editor),a=z(x=>x.remote),l=vl(),c=z(x=>x.connected),d=z(x=>x.heard),g=z(x=>x.connectFailure),k=z(x=>x.chatSide),p=Xi(),h=W0({connected:c,heard:d,connectFailure:g,hasToken:wD,projectChord:ct("project"),title:(n==null?void 0:n.worktree.title)??null}),v=t!=="home"&&(n!==null||r!==null),b=v&&!l&&!r?n:null,_=b?Cp(b.worktree.id,b.worktree.proxyPort,a):null,E=t==="preview"&&!b?"chat":t,j=[{id:"chat",label:"chat"},...b&&_?[{id:"preview",label:"preview",trail:f.jsx(Dt,{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":k,"data-touch":p||void 0,"data-hover":!p||void 0,children:[f.jsx($0,{}),f.jsx(B0,{}),f.jsx(yD,{screen:v?"chat":"home",tabs:v&&h===null&&f.jsx(Pu,{fill:!0,segmented:!0,owner:"phone-tabs",label:"worktree",items:j,current:E,onPick:x=>e({a:"screen",to:x})})}),f.jsx("div",{className:"phone-screen",children:f.jsxs("div",{className:"center",children:[h!==null?f.jsx(qo,{wide:!0,children:f.jsx("p",{className:"status-line",children:h})}):v?i?f.jsx(q1,{editor:i,placement:"screen"}):E==="chat"?f.jsx(gu,{placement:"screen",archived:r}):E==="changes"?f.jsx(cb,{placement:"screen"}):null:f.jsx(ax,{placement:"screen"}),b&&_&&f.jsx(vD,{active:b,url:_,hidden:E!=="preview"||i!==null},b.worktree.id),f.jsx(ix,{})]})})]})}function xD(){try{const e=localStorage.getItem(dt.theme);if(e){const t=JSON.parse(e);if(t!=null&&t.colors&&typeof t.colors.surface0=="string")return t}}catch{}return ml}function lx(e,t={}){var r;const n=document.documentElement;for(const[i,a]of Object.entries(oI(e)))n.style.setProperty(i,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(dt.theme,JSON.stringify(e))}catch{}}function cx(e){const t=e.colors[sh(e)];return{type:"theme",accent:t,accentFg:fI(t)}}function _D(){var e;return((e=window.matchMedia)==null?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)??!0}const ED=12*36e5;function SD(){try{const e=localStorage.getItem(dt.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<ED?{dark:!t.dark,until:0}:null}catch{return null}}function ND(e){try{localStorage.setItem(dt.daylight,JSON.stringify(e))}catch{}}function TD(e){var r;const t=(r=window.matchMedia)==null?void 0:r.call(window,"(prefers-color-scheme: dark)");if(!t)return()=>{};const n=i=>e(i.matches);return t.addEventListener("change",n),()=>t.removeEventListener("change",n)}function Zp(e,t){return[{id:"copy-name",label:"copy name",detail:e,onClick:()=>Zt(e)},{id:"copy-value",label:"copy value",detail:t,onClick:()=>Zt(t)}]}function Wp(e){return[{id:"copy-value",label:"copy value",detail:e,onClick:()=>Zt(e)}]}function CD(e,t,{sock:n},r){return t?Nn([[{id:"source",label:"open source",onClick:r}],Qs(`${e.dir}/${t}`,()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id,path:t})),[{id:"copy-path",label:"copy path",onClick:()=>Zt(t)}]]):[]}function fl(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 i=Number.parseInt(r.slice(0,6),16);return[i>>16&255,i>>8&255,i&255]}function jD(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());return t?t[1].length===4||t[1].length===8:!1}function Hv([e,t,n]){const r=i=>{const a=i/255;return a<=.03928?a/12.92:((a+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function ux(e,t){if(jD(e))return null;const n=fl(e);if(!n)return null;const r=fl(t);if(!r)return null;const[i,a]=[Hv(n),Hv(r)];return`${((Math.max(i,a)+.05)/(Math.min(i,a)+.05)).toFixed(2)}:1`}function AD({worktreeId:e,height:t,full:n,onToggleFull:r,onDragStart:i}){const a=Ve(),l=Ge(),c=z(g=>wo(g,e).design);T.useEffect(()=>{c||l==null||l.send({t:"design-scan",worktreeId:e})},[c,e,l]),T.useEffect(()=>()=>Rt.post(e,{type:"highlight-clear"}),[e]);const d={outline:g=>Rt.post(e,g),clear:()=>Rt.post(e,{type:"highlight-clear"}),open:g=>ar({dispatch:a},{worktreeId:e,path:g})};return f.jsx(Kh,{kind:"design",className:Ke("design-pane",n&&"full"),height:n?void 0:t,resizable:!n,onDragStart:i,title:c?f.jsx("span",{children:$D(c)}):void 0,onClose:()=>a({a:"toggle-design"}),closeHint:ct("design"),full:n,onToggleFull:r,actions:f.jsxs($e,{variant:"outline",onClick:()=>l==null?void 0:l.send({t:"design-scan",worktreeId:e}),"data-tip":"Scan this worktree again",children:[f.jsx(Ct,{name:"reload",className:"icon-inline"})," rescan"]}),children:c?f.jsxs("div",{className:"design-body",style:OD,onMouseLeave:d.clear,children:[c.tokens.length===0&&c.literals.length>0?f.jsx(FD,{literals:c.literals,outline:d.outline,clear:d.clear}):f.jsx(DD,{tokens:c.tokens,coverage:c.coverage,outline:d.outline,clear:d.clear}),f.jsx(qD,{index:c,outline:d.outline,clear:d.clear,onOpen:d.open}),f.jsx(YD,{index:c,outline:d.outline,clear:d.clear,onOpen:d.open})]}):f.jsx("div",{className:"empty",children:"reading the design system…"})})}const ID=720,RD=132,OD={"--design-column":`${ID}px`,"--design-cell":`${RD}px`};function $D(e){const t=Object.values(e.coverage.files).reduce((r,i)=>r+i,0),n=e.coverage.stylesheets;return`${t} file${t===1?"":"s"} read, ${n} stylesheet${n===1?"":"s"}`}const Rs=e=>`${e} use${e===1?"":"s"}`;function Gu({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 ku({children:e}){return f.jsx("p",{className:"design-gap",children:e})}const MD=[{kind:"font",label:"type"},{kind:"color",label:"color"},{kind:"length",label:"size & radius"},{kind:"shadow",label:"shadow"},{kind:"other",label:"computed"}];function PD(e){return e.find(t=>t.kind==="color"&&fl(t.resolved??t.value)!==null)}function LD(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 DD({tokens:e,coverage:t,outline:n,clear:r}){const i=PD(e),a=i&&(i.resolved??i.value),l=new Map;for(const d of e){const g=(d.resolved??d.value).trim().toLowerCase();l.set(g,[...l.get(g)??[],d.name])}const c=d=>(l.get((d.resolved??d.value).trim().toLowerCase())??[]).filter(g=>g!==d.name);return f.jsx(Gu,{title:"Tokens",children:e.length===0?f.jsx(ku,{children:LD(t)}):MD.map(({kind:d,label:g})=>{const k=e.filter(h=>h.kind===d);if(k.length===0)return null;const p=fx(k.map(h=>h.value));return f.jsxs("div",{className:"design-group",children:[d!=="font"&&f.jsx("span",{className:"design-group-name",children:g}),d==="font"?f.jsx(px,{groups:WD(k),outline:n,clear:r}):f.jsx("div",{className:"design-breakout",style:dx(k.length),children:f.jsx("div",{className:"design-grid",children:k.map(h=>{const v=h.resolved??h.value,b=h.kind==="color"&&a?ux(v,a):null;return f.jsx(hx,{kind:h.kind,name:h.name,lines:h.resolved?[h.value,h.resolved]:[h.value],actual:v,ratio:b,largest:p,tipText:GD(h,b,i,c(h)),menu:()=>Zp(h.name,v),outline:n,clear:r},h.name)})})})]},d)})})}const zD=[{role:"color",kind:"color",label:"color"},{role:"radius",kind:"length",label:"radius"},{role:"shadow",kind:"shadow",label:"shadow"}];function FD({literals:e,outline:t,clear:n}){const r=e.find(a=>a.ground&&fl(a.value)!==null),i=KD(e);return f.jsxs(Gu,{title:"Values",note:"written out in the rules; no custom properties",children:[i.length>0&&f.jsx("div",{className:"design-group",children:f.jsx(px,{groups:i,outline:t,clear:n})}),zD.map(({role:a,kind:l,label:c})=>{const d=e.filter(k=>k.role===a);if(d.length===0)return null;const g=fx(d.map(k=>k.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:dx(d.length),children:f.jsx("div",{className:"design-grid",children:d.map(k=>{const p=l==="color"&&r?ux(k.value,r.value):null;return f.jsx(hx,{kind:l,name:k.value,lines:[Rs(k.uses)],actual:k.value,ratio:p,largest:g,tipText:VD(k,p,r),menu:()=>Wp(k.value),outline:t,clear:n},k.value)})})})]},a)})]})}function dx(e){const t="var(--design-cell)",n=`min(round(down, 100%, ${t}), calc(${e} * ${t}))`,r=`round(down, var(--design-column), ${t})`,i=`round(down, max(0px, calc((${n} - ${r}) / 2)), ${t})`;return{width:n,marginLeft:`max(0px, calc((100% - var(--design-column)) / 2 - ${i}))`}}function fx(e){return e.reduce((t,n)=>Math.max(t,Math.abs(Number.parseFloat(n))||0),0)}const BD=["color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color","outline-color"];function UD(e,t){if(!e)return[];const n=getComputedStyle(e);return t.map(r=>[r,n.getPropertyValue(r)])}const Kp=e=>(e.split(",")[0]??e).replace(/["']/g,"").trim();function HD(e){const t=/^[1-9]00\s+([\d.]+)px(?:\s*\/\s*([\d.]+)(px)?)?\s+(.+)$/.exec(e.trim());if(!t)return{family:Kp(e),size:null,lead:null};const n=Number(t[1]),r=t[2]?Number(t[2]):null,i=r===null?null:Math.round((t[3]?r:n*r)*100)/100;return{family:Kp(t[4]??""),size:n,lead:i}}function sp(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 ZD(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 WD(e){const t=e.map(n=>({token:n,actual:n.resolved??n.value,...HD(n.resolved??n.value)}));return[...new Set(t.map(n=>n.family))].map(n=>{const r=t.filter(a=>a.family===n),i=r.find(a=>a.size===null);return{family:n,stack:i?i.actual:n,name:i==null?void 0:i.token.name,label:i?i.token.name:n,tipText:i?`${i.token.name}
219
+ ${i.actual}`:void 0,menu:()=>i?Zp(i.token.name,i.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}
220
+ ${a.actual}`,menu:()=>Zp(a.token.name,a.actual)}))}})}function KD(e){const t=e.filter(i=>i.role==="family"),n=e.filter(i=>i.role==="size");return[...new Set([...t.map(i=>i.value),...n.map(i=>i.family??"initial")])].map(i=>{const a=t.find(c=>c.value===i),l=i==="initial"?"default face":Kp(i);return{family:l,stack:i,name:a?Rs(a.uses):void 0,label:l,tipText:a?`${a.value}
221
+ ${Rs(a.uses)}: ${a.selectors.join(", ")}`:void 0,menu:()=>a?Wp(a.value):[],rows:n.filter(c=>(c.family??"initial")===i).sort((c,d)=>sp(d.value)-sp(c.value)).map(c=>{const d=sp(c.value),g=ZD(c.lead,d),k=c.value.endsWith("px")?`${d}`:c.value;return{key:`${c.value}/${c.lead??""}`,sample:`${l} ${k}${g===null?"":`/${g}`}`,style:{fontFamily:i,fontSize:c.value,lineHeight:c.lead},name:Rs(c.uses),label:c.value,tipText:`${c.value}${c.lead?` / ${c.lead}`:""}
222
+ ${Rs(c.uses)}: ${c.selectors.join(", ")}`,menu:()=>Wp(c.value)}})}})}function px({groups:e,outline:t,clear:n}){const r=(a,l,c)=>t({type:"highlight-computed",props:UD(a.currentTarget.querySelector(".design-face-sample"),l?["font-family","font-size","line-height"]:["font-family"]),match:"all",label:c}),i=Wt("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,...i.contextMenu(a.menu),...a.tipText?Et(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,...i.contextMenu(l.menu),...Et(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 hx({kind:e,name:t,lines:n,actual:r,ratio:i,largest:a,tipText:l,menu:c,outline:d,clear:g}){const k=e==="color"&&fl(r)!==null,p=e==="length"?Number.parseFloat(r):Number.NaN,h=Wt("design");return f.jsxs("div",{className:"design-cell","data-kind":e,...h.contextMenu(c),onMouseEnter:k?v=>{const b=v.currentTarget.querySelector(".design-fill"),_=b?getComputedStyle(b).backgroundColor:"";d({type:"highlight-computed",props:BD.map(E=>[E,_]),match:"any",label:t})}:void 0,onMouseLeave:k?g:void 0,...Et(l),children:[e==="color"&&f.jsx("div",{className:"design-sample",children:k&&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((v,b)=>f.jsxs("span",{className:"design-cell-line",children:[f.jsx("span",{className:"design-cell-value",children:v}),b===0&&i&&f.jsx("span",{className:"design-cell-note",children:i})]},v)),Number.isFinite(p)&&a>0&&f.jsx("span",{className:"design-scale",style:{width:`${Math.max(2,Math.abs(p)/a*100)}%`}})]})]})}function GD(e,t,n,r=[]){const i=[e.name,e.resolved?`${e.value} resolves to ${e.resolved}`:e.value];if(r.length>0&&i.push(`same value as ${r.join(", ")}`),t&&n){const a=e.name===n.name;i.push(a?"the ground these ratios are measured against":`${t} against ${n.name}`)}return i.join(`
223
+ `)}function VD(e,t,n){const r=[e.value,`${Rs(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(`
224
+ `)}function mx({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 qD({index:e,outline:t,clear:n,onOpen:r}){const{components:i,typed:a}=e;if(i.length===0)return null;const l=i.filter(g=>g.imports>=2),c=i.filter(g=>g.imports<2),d=g=>f.jsx(gx,{count:g.imports,name:g.name,path:g.path,onEnter:()=>t({type:"highlight-file",path:g.path,ranges:null}),onLeave:n,onOpen:()=>r(g.path),children:g.variants.length>0&&f.jsx("span",{className:"design-variants",children:g.variants.map(k=>f.jsxs("span",{className:"design-variant",children:[k.prop,": ",k.values.join(" · ")]},k.prop))})},`${g.path}:${g.name}`);return f.jsxs(Gu,{title:"Components",note:`${l.length} reused of ${i.length}`,children:[!a&&f.jsx(ku,{children:"No TypeScript in this project, so the values each prop allows are not listed."}),f.jsx(mx,{shared:l.map(d),rest:c.map(d)})]})}function YD({index:e,outline:t,clear:n,onOpen:r}){const{classes:i,coverage:a}=e,l=i.filter(h=>h.uses>0),c=i.filter(h=>h.uses>=2),d=i.filter(h=>h.uses<2),g=c.filter(h=>h.unwrapped).length,k=i.length?`${c.length} reused of ${i.length}`+(g?`, ${g} with no component of their name`:""):void 0,p=h=>f.jsx(QD,{cls:h,outline:t,clear:n,onOpen:r},h.name);return f.jsx(Gu,{title:"Classes",note:k,children:i.length===0?f.jsx(ku,{children:"No stylesheet in this project defines a class. Utility-first CSS generates its own."}):l.length===0?f.jsx(ku,{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(mx,{shared:c.map(p),rest:d.map(p)})})}function QD({cls:e,outline:t,clear:n,onOpen:r}){return f.jsx(gx,{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 gx({count:e,name:t,path:n,onEnter:r,onLeave:i,onOpen:a,children:l}){const c=Vo(),d=Ge();Ve();const g=Wt("design");return f.jsx("li",{children:f.jsxs("button",{type:"button",className:"design-row row-edge",onMouseEnter:r,onFocus:r,onMouseLeave:i,onBlur:i,onClick:a,disabled:!n,...g.contextMenu(()=>c?CD({id:c.worktree.id,dir:c.worktree.path},n,{sock:d},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 XD({worktreeId:e,procs:t,login:n,current:r,onRestart:i}){const a=Ge();Ve();const l={sock:a},c=(g,k)=>f.jsx(Dt,{icon:"reload",label:k,onClick:()=>i(g)}),d={id:Ko,label:"login",tip:Et("The agent's login; it closes once you are in",void 0,{placement:"top"}),trail:c(Ko,"Run the login again")};return n&&r===Ko?[d]:[{id:to,label:"shell",tip:Et("A shell in this worktree",void 0,{placement:"top"}),menu:()=>k1(e,l),trail:c(to,"Restart the shell")},...n?[d]:[],...t.map(g=>({id:g.name,label:g.name,lead:f.jsx("span",{className:`dot ${g.status}`}),tip:Et(`${g.command}
225
+ ${g.status} on :${g.port}`,void 0,{placement:"top"}),menu:()=>Dh(g,e,l),trail:c(g.name,`Restart ${g.name}`)}))]}const JD=T.lazy(()=>Bp(()=>import("./XTerm-B3kT_naP.js"),__vite__mapDeps([3,4])));function ez({worktreeId:e,opened:t,height:n,onDragStart:r}){const i=Ve(),a=Ge(),l=Ru(),c=z(I=>I.connected),d=z(I=>I.focusTerm),g=Vo(),k=(g==null?void 0:g.procs)??[],p=(g==null?void 0:g.login)??!1,h=It(e,"termStream"),v=z(I=>{var Z;return((Z=I.termRun)==null?void 0:Z.id)===e&&h===to?I.termRun.command:null}),[b,_]=T.useState(null);T.useEffect(()=>{h===to||(h===Ko?p:k.some(Z=>Z.name===h))||i({a:"term-stream",id:e,stream:to})},[k,p,h,e,i]);const E=I=>{I!==h&&(_(null),i({a:"term-stream",id:e,stream:I}))},j=T.useRef(!1),[x,H]=T.useState(0),B=I=>{I===to&&I===h&&(j.current=!0),a==null||a.send({t:"term-restart",worktreeId:e,stream:I}),I===Ko&&I===h&&(_(null),H(Z=>Z+1))},re=(I,Z)=>{if(I)return _(null);if(j.current){j.current=!1,H(V=>V+1);return}_({code:Z})},F=XD({worktreeId:e,procs:k,login:p,current:h,onRestart:B}),C=T.useRef(!t),L=!C.current;return T.useEffect(()=>{C.current=!1},[]),f.jsxs(Kh,{kind:"terminal",className:"term-pane",height:n,onDragStart:r,tabs:{items:F,current:h,onPick:E,font:"mono",owner:"terminal",label:"terminal streams"},onClose:()=>i({a:"toggle-terminal"}),closeHint:ct("terminal"),children:[f.jsx("div",{className:"term-body",children:f.jsx(Wh,{pane:!0,children:f.jsx(T.Suspense,{fallback:f.jsx("div",{className:"empty",children:"loading terminal…"}),children:f.jsx(JD,{worktreeId:e,stream:h,theme:l,sock:a,connected:c,focusOnMount:L,focusReq:d,onAlive:re,run:v,onRan:()=>i({a:"term-ran"}),onEscape:()=>i({a:"toggle-terminal"})},`${h}:${x}`)})})}),b!==null&&f.jsx(Zh,{pane:!0,title:h===to?"the shell exited":h===Ko?"the login did not finish":`${h} exited`,body:b.code===void 0?void 0:`exit code ${b.code}`,action:f.jsx($e,{variant:"outline",onClick:()=>B(h),children:"restart"})})]})}function tz(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}. ${nz(a)}`),i=t.slice(-40).map(a=>`[${a.proc}] ${a.line}`).join(`
226
+ `);return["The dev server in this worktree is not reachable, so the preview is empty.","",...r,"",i?`Last output:
227
+ \`\`\`
228
+ ${i}
229
+ \`\`\``:"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(`
230
+ `)}function nz(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 rz(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. 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(`
231
+ `)}function oz(e){return e==="reserved"?"checking out a fresh worktree…":e==="warming"?"copying dependencies and running setup…":"starting dev servers…"}function iz({worktree:e,log:t}){const n=Ge(),r=Ve(),i=e.procs,a=g=>n==null?void 0:n.send({t:"term-restart",worktreeId:e.id,stream:g.name}),l=i.some(g=>g.status==="crashed"||g.status==="unreachable"),c=z(g=>g.clientId),d=()=>{const g=tz(e,t);if(Yn(e.worktree)){const k=Hs(e.worktree)?{worktreeId:e.id}:{};n==null||n.send({t:"create-worktree",clientId:c,repoId:e.repoId,prompt:g,...k})}else n==null||n.send({t:"chat",worktreeId:e.id,text:g})};return f.jsxs(qo,{wide:!0,children:[i.length===0?f.jsx("div",{className:"status-line",children:oz(e.worktree.phase)}):f.jsx("ul",{className:"boot-procs",children:i.map(g=>f.jsxs("li",{className:Ke("boot-proc",(g.status==="crashed"||g.status==="unreachable")&&"boot-bad"),children:[f.jsx("span",{className:"boot-name",children:g.name}),f.jsx("span",{className:"boot-status",children:sz(g)}),(g.status==="crashed"||g.status==="unreachable")&&f.jsx($e,{variant:"outline",onClick:()=>a(g),children:"restart"}),g.detail&&g.status!=="asleep"&&f.jsx("div",{className:"boot-detail",children:g.detail})]},g.name))}),l&&f.jsxs("div",{className:"status-actions",children:[e.agent==="idle"&&f.jsx($e,{variant:"outline",size:"lg",onClick:d,children:"ask the agent to fix it"}),f.jsx($e,{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(g=>`[${g.proc}] ${g.line}`).join(`
232
+ `)})]})}function sz(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 az({row:e}){const t=Ge(),n=z(a=>a.clientId),r=z(a=>a.home),i=r&&e.path.startsWith(`${r}/`)?`~${e.path.slice(r.length)}`:e.path;return f.jsxs(qo,{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:i})," 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($e,{variant:"outline",size:"lg",onClick:()=>t==null?void 0:t.send({t:"adopt-worktree",worktreeId:e.id,clientId:n}),children:"take over"})})]})]})}function lz(e,t,n){return!e||!t||e===t?null:n(e)===n(t)?e:null}function cz(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 uz(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 kx(){const e=Ge(),t=z(d=>d.agents),n=z(d=>d.agentChosen),[r,i]=T.useState(null),a=r?t.find(d=>d.id===r):void 0,l=d=>e==null?void 0:e.send({t:"set-default-agent",agent:d});if(ft([a==null?void 0:a.available,r],()=>{!r||!(a!=null&&a.available)||(l(r),i(null))}),n)return null;const c=d=>{if(d.available){l(d.id);return}i(d.id),d.installing||e==null||e.send({t:"install-agent",agent:d.id})};return f.jsxs("div",{className:"hint agent-ask",children:[f.jsx("span",{children:"which agent works on it?"}),t.map(d=>f.jsx($e,{variant:"outline",size:"md",busy:d.installing||r===d.id,onClick:()=>c(d),...Et(uz(d)),children:d.name},d.id))]})}function dz({active:e}){const t=Ve(),n=Ge(),r=Sn(),i=qs(),a=z(d=>d.home),l=e.worktree.title,c=()=>{i!=null&&i.made&&(t({a:"new-project",v:{...lh({mode:i.made==="git"?"init":"create",name:i.name,parent:rx(i.path,a)??i.path}),phase:"unmaking",repoId:i.id,prompt:wo(r.getState(),e.worktree.id).draft}}),n==null||n.send({t:"unmake-repo",repoId:i.id}))};return f.jsxs(qo,{anchor:"line",children:[f.jsx("p",{className:"form-title",children:i!=null&&i.made?f.jsx($e,{variant:"inline",onClick:c,...Et("Rename or move this project"),children:l}):l}),f.jsx(kx,{}),f.jsx("div",{className:"form-body form-body-lg",children:f.jsx(Fp,{active:e,greenfield:!0})})]})}function fz({pending:e}){const t=Ve(),n=Ge(),r=!!e.error,i=()=>{n==null||n.send({t:"cancel-import",id:e.id}),t({a:"watch-import",id:null})},a=T.useRef(null);return T.useEffect(()=>{var l;return(l=a.current)==null?void 0:l.scrollTo({top:a.current.scrollHeight})},[e.lines.length]),f.jsxs(qo,{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($e,{variant:"outline",size:"lg",onClick:i,children:r?"dismiss":"stop"})})]})}const pz=150,hz=/^[^\s@]+@[^\s@]+$/,mz=14,Zv=[];function gz({project:e}){var st;const t=Ve(),n=Ge(),r=z(Ee=>Ee.repos),i=z(Ee=>Ee.home),a=z(Ee=>Ee.folderDialog),l=z(Ee=>Ee.gitIdentity),c=z(Ee=>Ee.choosingFolder),d=z(Ee=>Ee.chosenFolder),g=z(Ee=>Ee.paths),k=z(Ee=>Ee.agents),p=z(Ee=>Ee.defaultAgent),h=z(Ee=>Ee.agentChosen),[v,b]=T.useState({name:"",email:""}),[_,E]=T.useState(null),[j,x]=T.useState(null),H=T.useRef(null),B=T.useRef(null),{mode:re,name:F,parent:C,prompt:L}=e,I=re==="clone",Z=re==="init",V=e.phase==="editing",K=F.trim(),le=Z||!K?null:Ja(F),de=!Z&&K&&!le?nx(C,K):null,Q=Hp(C,i),ce=de!==null&&g.query===de&&((st=g.target)==null?void 0:st.exists)===!0,R=!l&&!I,M=!R||v.name.trim()!==""&&hz.test(v.email.trim()),G=V&&!_&&(Z||K!==""&&!le&&!ce)&&M&&h,ne=k.find(Ee=>Ee.id===p),[O,ee]=x1(p),[D,q]=b1(p),Te=(Ee,Tt)=>{if(Ee===p){ee(Tt);return}_1(Ee,Tt),n==null||n.send({t:"set-default-agent",agent:Ee})};T.useEffect(()=>{if(!de)return;const Ee=setTimeout(()=>n==null?void 0:n.send({t:"browse-path",path:de}),pz);return()=>clearTimeout(Ee)},[de,n]),ft([e.phase],()=>{var Ee;e.phase==="editing"&&((Ee=H.current)==null||Ee.focus())}),ft([re,F,C],()=>x(null));const Ne=()=>{G&&(t({a:"open-repo"}),t({a:"new-project-set",v:{phase:"creating"}}),n==null||n.send({t:"create-repo",mode:re,parent:C.trim(),name:K,...I&&e.url?{url:e.url}:{},...R?{identity:{name:v.name.trim(),email:v.email.trim()}}:{}}))},je=Ee=>{const Tt=r.find(zt=>zt.path===ul(Ee,i));if(Tt){t({a:"activate-repo",id:Tt.id});return}t({a:"open-repo"}),n==null||n.send({t:"register-repo",path:Ee})},Re=Ee=>{x(null),a?(t({a:"choosing-folder",v:Ee}),n==null||n.send({t:"choose-folder",start:C,purpose:Ee})):t(Ee==="location"?{a:"open",overlay:{kind:"choose-folder"}}:{a:"open",overlay:{kind:"projects",form:"disk"}})};ft([d==null?void 0:d.seq],()=>{var Tt,zt;if(!c||!d)return;t({a:"choosing-folder",v:!1});const Ee=d.folder;if(!Ee){(Tt=H.current)==null||Tt.focus();return}if(c==="open"&&Ee.kind==="project"){je(Ee.path);return}if(c==="open"&&Ee.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(Ee.kind==="project"?Ee.path:null),Ee.kind!=="project"){if(Ee.kind==="empty"&&!I){const Xe=ex(Ee.path);t({a:"new-project-set",v:{mode:"init",parent:Xe.parent,name:Xe.name}});return}t({a:"new-project-set",v:{mode:I?"clone":"create",parent:Ee.path}}),(zt=H.current)==null||zt.focus()}});const Ze=j??(Z?"the empty folder you chose becomes the project":_?"the folder you chose is already a project: open it, or choose another":ce?`${Q} already has a folder called ${K}`:le);return f.jsxs(qo,{anchor:"line",children:[I&&f.jsx("p",{className:"new-project-url",children:e.url}),f.jsxs("div",{className:"form-head",children:[Z?f.jsx("p",{className:"form-title",children:F}):f.jsx(Go,{ref:H,bare:!0,font:"lead",className:"new-project-field",autoFocus:!0,spellCheck:!1,autoComplete:"off",value:F,placeholder:"Project name",disabled:!V,style:{width:`${Math.max(F.length+1,mz)}ch`},onChange:Ee=>t({a:"new-project-set",v:{name:Ee.target.value}}),onKeyDown:Ee=>{var Tt;Ee.key==="Enter"&&(Ee.preventDefault(),(Tt=B.current)==null||Tt.focus())}}),f.jsxs("span",{className:"new-project-where",children:[f.jsx("span",{className:"hint",children:"in"}),f.jsx("span",{className:"new-project-parent",...Et(C),children:Q}),f.jsx(Dt,{icon:"folder",label:a?"Choose in Finder":"Choose a folder",className:"new-project-folder",on:c==="location",disabled:!V,onClick:()=>Re("location")})]})]}),Ze&&f.jsx("p",{className:"hint",children:Ze}),f.jsx(kx,{}),f.jsx("div",{className:"form-body",children:f.jsx(wl,{ref:B,bare:!0,font:"ui",value:L,placeholder:`describe ${K||"the app"}…`,disabled:!V,onChange:Ee=>t({a:"new-project-set",v:{prompt:Ee.target.value}}),onKeyDown:Ee=>{Ee.key!=="Enter"||Ee.shiftKey||(Ee.preventDefault(),Ne())}})}),f.jsxs("div",{className:"hint form-knobs",children:[k.length>1?f.jsx(E1,{agents:k,agent:p,model:O,onChange:Te}):f.jsx(Lp,{models:(ne==null?void 0:ne.models)??Zv,value:O,onChange:ee}),f.jsx(Pp,{efforts:(ne==null?void 0:ne.efforts)??Zv,value:D,onChange:q}),_?f.jsx($e,{variant:"outline",size:"lg",className:"form-go",autoFocus:!0,onClick:()=>je(_),children:"open it"}):f.jsx($e,{variant:"outline",size:"lg",className:"form-go",busy:e.phase==="creating",disabled:!G,onClick:Ne,...Et(h?I?"Clone the project":L.trim()?"Make it and start on this":"Make the project":"Choose an agent first","⏎"),children:I?"clone":"create"})]}),e.error&&f.jsx("p",{className:"hint",role:"status",children:e.error}),R&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"new-project-identity",children:[f.jsx(Go,{size:"md",font:"ui",rule:!0,value:v.name,placeholder:"Your name",autoComplete:"name",disabled:!V,onChange:Ee=>b({...v,name:Ee.target.value})}),f.jsx(Go,{size:"md",font:"ui",rule:!0,type:"email",value:v.email,placeholder:"Email",autoComplete:"email",disabled:!V,onChange:Ee=>b({...v,email:Ee.target.value})})]}),f.jsx("p",{className:"hint",children:"git labels the work you save with these, and asks only once"})]}),!I&&V&&f.jsx($e,{tone:"quiet",className:"new-project-open",onClick:()=>Re("open"),children:"or open a folder you already have"})]})}function Pa({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 kz=1;const ap=(e,t)=>({id:kz++,name:e,cmd:t}),yz=[{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 vz({repo:e,onClose:t}){const n=Ge(),r=Sn(),i=z(G=>G.clientId),a=z(G=>G.rows.find(ne=>{var O;return Mn(ne)&&ne.id===((O=zs(G,e.id))==null?void 0:O.id)})??null),l=z(G=>{var ne;return((ne=zs(G,e.id))==null?void 0:ne.id)??null});T.useEffect(()=>{if(!t)return;const G=ne=>ne.key==="Escape"&&t();return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[t]);const[c]=T.useState(()=>Object.keys(e.config.run).length>0),[d,g]=T.useState(()=>{const G=Object.entries(e.config.run).map(([ne,O])=>ap(ne,O));return G.length>0?G:[ap("web","")]}),[k,p]=T.useState(()=>(e.config.setup??[]).join(`
233
+ `)),[h,v]=T.useState(()=>e.config.check??""),[b,_]=T.useState(()=>Wi(e.config).land),[E,j]=T.useState(()=>Wi(e.config).automerge),[x,H]=T.useState(()=>Wi(e.config).merge??"default"),[B,re]=T.useState(()=>NE(e.configFile)),F=TE(e.configFile,B),C=!!e.remote&&b==="pr",L=d.length>1,I=d.some(G=>G.name.trim()&&G.cmd.trim()),V=!!a&&!t&&!c&&!I,K=(G,ne)=>g(d.map((O,ee)=>ee===G?{...O,...ne}:O)),le=()=>k.split(`
234
+ `).map(G=>G.trim()).filter(Boolean),de=()=>{const{check:G,land:ne,...O}=e.config,ee=e.remote?b:fp,D=x==="default"||ee!=="pr"&&x===pp?void 0:x,q={...ee!==fp?{route:ee}:{},...ee==="pr"&&E?{automerge:!0}:{},...D?{method:D}:{}};return{...O,setup:le(),...h.trim()?{check:h.trim()}:{},...Object.keys(q).length>0?{land:q}:{}}},Q=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...de(),run:Object.fromEntries(d.filter(G=>G.name.trim()&&G.cmd.trim()).map(G=>[G.name.trim(),G.cmd.trim()]))},kind:B}),t==null||t()},ce=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...de(),run:{}},kind:B}),t==null||t()},R=()=>n==null?void 0:n.send({t:"create-worktree",clientId:i,repoId:e.id,prompt:rz(e,F)}),M=(G,ne)=>f.jsxs("div",{className:"setup-proc",children:[L&&f.jsx(Go,{size:"md",rule:!0,className:"setup-name",value:G.name,placeholder:"name",...Et("Process name, shown in the status bar"),onChange:O=>K(ne,{name:O.target.value})}),f.jsx(Go,{size:"md",rule:!0,className:"setup-cmd",value:G.cmd,placeholder:"npm run dev",onChange:O=>K(ne,{cmd:O.target.value})}),L&&f.jsx(Dt,{icon:"close",label:"Remove",onClick:()=>g(d.filter((O,ee)=>ee!==ne))})]},G.id);return f.jsxs(qo,{children:[f.jsxs("p",{className:"form-title",children:["how does ",e.name," start?"]}),f.jsx(Pa,{label:"install",hint:"once per new worktree; one command per line",children:f.jsx(wl,{size:"md",rule:!0,rows:Math.max(1,k.split(`
235
+ `).length),value:k,placeholder:"bun install",onChange:G=>p(G.target.value)})}),f.jsx(Pa,{label:"check",hint:"runs after each of the agent's turns; the work lands only when it passes",children:f.jsx(Go,{size:"md",rule:!0,value:h,placeholder:"bun run check",onChange:G=>v(G.target.value)})}),e.remote&&f.jsx(Pa,{label:"land",hint:"where a worktree's finished work goes; one way per repo",children:f.jsxs("div",{className:"setup-land",children:[f.jsx(yi,{value:b,options:PE.map(G=>({id:G.id,label:G.name,description:G.description})),onChange:_,hint:"where the work goes",placeholder:"where work lands"}),C&&f.jsx(yi,{value:E?"github":"you",options:DE.map(G=>({id:G.id,label:G.name,description:G.description})),onChange:G=>j(G==="github"),hint:"who merges the pull request",placeholder:"who merges it"})]})}),f.jsx(Pa,{label:"merge",hint:C?"how GitHub merges the pull request; only what the repo allows":"how the commits arrive on main",children:f.jsx(yi,{value:x==="default"&&!C?pp:x,options:[...C?[{id:"default",label:"what the repo allows",description:"the repo's allowed methods on GitHub: squash, else a merge commit, else rebase"}]:[],...LE.map(G=>({id:G.id,label:G.name,description:G.description}))],onChange:H,hint:"how the commits arrive on main",placeholder:"how the commits arrive"})}),f.jsx(Pa,{label:"start",hint:f.jsxs(f.Fragment,{children:["must listen on ",f.jsx("code",{...Et("Toyon sets a different port for each worktree"),children:"$PORT"}),e.guess&&l&&f.jsxs(f.Fragment,{children:[" · from ",f.jsx($e,{mono:!0,tone:"quiet",...Et(`open ${e.guess} in the editor pane`),onClick:()=>Bu(r,n,l,e.guess??"",1),children:e.guess})]})]}),children:d[0]&&M(d[0],0)}),d.slice(1).map((G,ne)=>f.jsxs("div",{className:"form-row",children:[f.jsx("span",{className:"form-label"}),f.jsx("div",{className:"form-control",children:M(G,ne+1)})]},G.id)),f.jsxs("div",{className:"form-row",children:[f.jsx("span",{className:"form-label"}),f.jsxs($e,{tone:"quiet",onClick:()=>g([...d,ap("","")]),children:[f.jsx(Ct,{name:"plus",className:"icon-inline"})," another process"]})]}),f.jsxs("div",{className:"form-knobs",children:[f.jsx(yi,{value:B,options:yz,onChange:re,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:F}),t&&f.jsx($e,{onClick:t,children:"cancel"}),(!c||t)&&f.jsx($e,{...Et("This project has no dev server: chat, changes and the terminal work, the preview stays empty"),onClick:ce,children:"no dev server"}),V&&a?f.jsx($e,{variant:"outline",size:"lg",disabled:a.agent!=="idle",...Et("The agent reads the repo and writes the settings file; the daemon picks it up as soon as it lands"),onClick:R,children:"let the agent work it out"}):f.jsxs($e,{variant:"outline",size:"lg",disabled:!I,...t?Et("Restarts every worktree of this repo. Profiles and other keys in the file are kept."):{},onClick:Q,children:[t?"save + restart":"start"," ",f.jsx(Ct,{name:"forward",className:"icon-inline"})]})]})]})}const lp={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."},wz=1e3,Wv={held:[],asking:[],seen:[]};async function Kv(e,t){for(;;){await new Promise(i=>setTimeout(i,wz));const[n,r]=await Promise.all([Tp(),Z0()]);if(n!==null&&n!==e)break;t(r??{waiting:[],asking:[]})}window.location.reload()}function bz(){const[e,t]=T.useState(!1),[n,r]=T.useState(null),[i,a]=T.useState(Wv),l=T.useRef(null),c=T.useCallback(p=>a(h=>({held:p.waiting,asking:p.asking,seen:bL(h.seen,p.waiting)})),[]);T.useEffect(()=>{let p=!0;return(async()=>{const[h,v]=await Promise.all([Tp(),Z0()]);!p||v===null||l.current||(l.current={pid:h},t(!0),c(v),Kv(h,c))})(),()=>{p=!1}},[c]);const d=async p=>{t(!0),r(null);const h=l.current??{pid:await Tp()},v=await pR(p);if(v){t(l.current!==null),r(v);return}p&&a(Wv),!l.current&&(l.current=h,Kv(h.pid,c))},g=e&&i.held.length>0,k=g?xL(i.seen,i.held,i.asking):[];return f.jsx(Zh,{title:lp.title,body:n??(g?_L(i.held.length,i.seen.length):e?lp.waiting:lp.body),action:g?f.jsx($e,{variant:"outline",onClick:()=>void d(!0),children:"restart now"}):f.jsx($e,{variant:"outline",busy:e,onClick:()=>void d(!1),children:"restart"}),children:k.length>0&&f.jsx("ul",{className:"crash-list",children:k.map((p,h)=>f.jsxs("li",{className:Ke("crash-row",p.dot!=="working"&&"row-dim"),children:[f.jsx("span",{className:Ke("dot",p.dot)}),f.jsx("span",{className:"crash-row-name",children:p.name}),p.note&&f.jsx("span",{className:"crash-row-note",children:p.note})]},h))})})}const xz=1500,_z={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};class Ez{constructor(t,n,r=_z){mt(this,"frames",new Map);this.send=t,this.sendTitle=n,this.timers=r}note(t,n,r){const i=this.frame(t);i.timer!==null&&(this.timers.clear(i.timer),i.timer=null),i.pending=null,r!==void 0&&(i.title=Jk(r));const a=Nu(n);if(!a){i.sent=null;return}if(a===i.sent){this.renamed(t,i);return}i.pending=a,i.timer=this.timers.set(()=>{i.timer=null,i.pending=null,i.sent=a,i.sentTitle=i.title,this.send(t,a,i.title)},xz)}title(t,n){const r=this.frame(t);r.title=Jk(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 Sz=U0(),Nz=2*6e4,Tz=8e3;function Cz({onRoot:e}){const t=T.useRef(null),n=T.useCallback(N=>{t.current=N,e(N)},[e]),r=Ve(),i=Sn(),a=Ge(),l=T.useRef(a);l.current=a;const[c]=T.useState(()=>new Ez((N,X,me)=>{var xe,We;(xe=l.current)==null||xe.send({t:"visit",worktreeId:N,path:X,title:me}),e0((We=i.getState().local[N])==null?void 0:We.pages)&&Rt.post(N,{type:"links"})},(N,X,me)=>{var xe;return(xe=l.current)==null?void 0:xe.send({t:"page-title",worktreeId:N,path:X,title:me})}));T.useEffect(()=>()=>c.dispose(),[c]);const d=y0(),g=Vs(),k=Vo(),p=z(N=>N.connected),h=z(N=>N.heard),v=z(N=>N.connectFailure),b=z(N=>N.remote),_=z(N=>N.editor),E=b0(),j=a2(),x=yl(),H=z(N=>N.layout.term)&&!x,B=z(N=>N.focusTerm),re=T.useRef(!1),F=T.useRef(B),C=!re.current||B!==F.current;T.useEffect(()=>{re.current=H&&!!g,F.current=B});const L=vl(),I=z(N=>N.layout.design)&&!x&&!L,Z=z(N=>N.reloadReq),V=Ru(),K=T.useRef(V);K.current=V;const le=z(N=>N.zen),de=T.useRef(le);de.current=le;const Q=It(g,"log"),ce=z(N=>N.incompatible),R=c2(),M=z(N=>{var X;return((X=N.overlay)==null?void 0:X.kind)==="setup"?N.repos.find(me=>me.id===N.overlay.repoId)??null:null}),G=(k==null?void 0:k.worktree.empty)===!0,ne=!!k&&Lu(k),O=R&&!G&&!ne?R:null,ee=O??M,D=z(N=>N.pending.find(X=>X.id===N.activeImportId)??null),[q,Te]=T.useState([]),Ne=T.useRef(new Map),je=T.useRef(new Map),[Re,Ze]=T.useState([]);T.useEffect(()=>{Rt.post=(N,X)=>{var me,xe;return(xe=(me=Ne.current.get(N))==null?void 0:me.contentWindow)==null?void 0:xe.postMessage({__toyon:!0,...X},je.current.get(N)??"*")},Rt.broadcast=N=>{var X;for(const[me,xe]of Ne.current)(X=xe.contentWindow)==null||X.postMessage({__toyon:!0,...N},je.current.get(me)??"*")}},[]),T.useEffect(()=>{let N=null;const X=We=>{We.target instanceof HTMLElement&&We.target.tagName!=="IFRAME"&&(N=We.target)},me=We=>{We.relatedTarget===null&&setTimeout(()=>{document.activeElement===document.body&&(N=null)},0)},xe=We=>{var gt,Ce;if((gt=We.data)!=null&&gt.__toyon)for(const[ge,De]of Ne.current){if(De.contentWindow!==We.source)continue;if(We.origin!==je.current.get(ge))return;const Ue=TA(We.data);if(!Ue)return;switch(Ue.type){case"key":window.dispatchEvent(new KeyboardEvent(Ue.up?"keyup":"keydown",{key:Ue.key,metaKey:Ue.meta,ctrlKey:!!Ue.ctrl,shiftKey:!!Ue.shift,altKey:!!Ue.alt}));break;case"hmr":r({a:"hmr",id:ge});break;case"loaded":Ze(kt=>kt.includes(ge)?kt:[...kt,ge]),Rt.post(ge,cx(K.current)),Rt.post(ge,{type:"zen",on:de.current}),r({a:"hmr",id:ge}),r({a:"page",id:ge,url:Ue.url,title:Ue.title,fresh:!0}),c.note(ge,Ue.url,Ue.title);break;case"navigated":r({a:"page",id:ge,url:Ue.url,...Ue.title!==void 0?{title:Ue.title}:{}}),c.note(ge,Ue.url,Ue.title);break;case"title":r({a:"page",id:ge,title:Ue.title}),c.title(ge,Ue.title);break;case"links":r({a:"links",id:ge,links:Ue.links});break;case"page-error":{const kt=Ue.source?` (${By(Ue.source)}:${Ue.line??"?"})`:"";r({a:"page",id:ge,error:`${Ue.message}${kt}`});break}case"picked":{const{type:kt,verb:Gn,site:xn,...Cn}=Ue,cr=xn==="call"?{file:Cn.callFile,line:Cn.callLine}:{file:Cn.file,line:Cn.line};if(Gn==="code"){r({a:"set-picking",v:!1});const ur=(Ce=Yt(i.getState(),ge))==null?void 0:Ce.worktree;cr.file?Bu(i,a,ge,By(cr.file,ur==null?void 0:ur.path),cr.line??1):a==null||a.send({t:"find-element",worktreeId:ge,seq:iu(),element:Cn.element})}else h2(i,ge,Cn);break}case"pick-cancel":r({a:"set-picking",v:!1});break;case"drag-files":kh(i,!1);break;case"drop-files":R0(i);break;case"focus":Ue.gesture?N=null:document.activeElement===De&&(N!=null&&N.isConnected)&&N!==document.body&&N.focus();break;case"highlight-miss":console.warn(`[toyon] highlight miss on ${Ue.path}: ${Ue.fileMatched} elements from this file, ${Ue.withSource} elements with source info on page, ranges=${JSON.stringify(Ue.ranges)}`);break}return}};return window.addEventListener("message",xe),document.addEventListener("focusin",X),document.addEventListener("focusout",me),()=>{window.removeEventListener("message",xe),document.removeEventListener("focusin",X),document.removeEventListener("focusout",me)}},[r,i,a,c]),T.useEffect(()=>{Rt.broadcast({type:"zen",on:le})},[le]);const st=T.useRef(new Map);ft([Z==null?void 0:Z.id,Z==null?void 0:Z.n],()=>{if(!Z)return;const{id:N}=Z;clearTimeout(st.current.get(N)),st.current.set(N,setTimeout(()=>{st.current.delete(N),Rt.post(N,{type:"reload"})},1200))});const Ee=fh(),Tt=Ee&&!Mn(Ee)?Ee:null,zt=Qi(),Xe=!!k&&k.procs.some(N=>N.status==="running"),pt=hh(),ht=pt!==null&&pt===g&&Xe;T.useEffect(()=>{pt&&ht&&!q.includes(pt)&&Te(N=>[...N,pt])},[pt,ht,q]);const wn=d.filter(N=>Mn(N)&&N.procs.some(X=>X.status==="asleep")).map(N=>N.id).join(" ");T.useEffect(()=>{const N=new Set(wn.split(" ").filter(Boolean));q.some(X=>N.has(X))&&Te(X=>X.filter(me=>!N.has(me)))},[wn,q]),T.useEffect(()=>{const N=q.filter(X=>X!==pt).map(X=>setTimeout(()=>Te(me=>me.filter(xe=>xe!==X)),Nz));return()=>{for(const X of N)clearTimeout(X)}},[q,pt]),T.useEffect(()=>{Ze(N=>N.every(X=>q.includes(X))?N:N.filter(X=>q.includes(X)))},[q]);const jt=d.filter(Mn).filter(N=>q.includes(N.id)).map(N=>({id:N.worktree.id,port:N.worktree.proxyPort,title:N.worktree.title})),[Ft,te]=T.useState(null),[pe,rt]=T.useState(pt),at=T.useRef(null);pe!==pt&&(rt(pt),te(lz(at.current,pt,N=>{var X;return((X=d.find(me=>me.id===N))==null?void 0:X.repoId)??null}))),T.useEffect(()=>{if(!Ft)return;const N=setTimeout(()=>te(null),Tz);return()=>clearTimeout(N)},[Ft]);const ut=pt!==null&&Re.includes(pt),tn=cz({previewId:pt,painted:ut,ready:ht,carry:Ft,mounted:q}),Kt=tn!==null&&tn!==pt;T.useEffect(()=>{at.current=tn});const[tt,qe]=no(dt.editorHeight,0,N=>{const X=Number(N);return Number.isFinite(X)&&X>=120?X:0}),[nn,ie]=no(dt.designHeight,0,N=>{const X=Number(N);return Number.isFinite(X)&&X>0?X:0}),[he,lt]=no(dt.designFull,!1,N=>N===null?void 0:N==="1"),[At,bt]=no(dt.editorFull,!1,N=>N===null?void 0:N==="1"),[Qt,vr]=no(dt.termHeight,240,N=>{const X=Number(N);return Number.isFinite(X)&&X>=140?X:void 0}),bn=z(N=>N.termTall);ft([bn],()=>{const N=t.current;bn&&N&&vr(Math.max(Qt,Math.round(N.clientHeight/2)))});const Tn=N=>(X,me)=>{const xe=me.parentElement,We=t.current;if(!xe||!We)return null;let gt=0;for(const ge of Array.from(We.querySelectorAll(":scope > .pane")))ge!==xe&&!ge.classList.contains("full")&&(gt+=ge.offsetHeight);const Ce=Math.max(We.clientHeight-gt-80,N);return Math.min(Math.max(xe.getBoundingClientRect().bottom-X.clientY,N),Ce)},Kn=Ms(Tn(120),N=>qe(Math.round(N))),lr=Ms(Tn(160),N=>ie(Math.round(N))),Pt=Ms(Tn(140),N=>vr(Math.round(N))),xt=z(N=>{var X,me;return k&&Yn(k.worktree)?((me=(X=N.rows.find(xe=>{var We;return xe.repoId===k.worktree.repoId&&((We=xe.worktree)==null?void 0:We.kind)==="worktree"}))==null?void 0:X.worktree)==null?void 0:me.title)??null:null}),hn=wR({connected:p,heard:h,connectFailure:v,hasToken:Sz,projectChord:ct("project"),title:(k==null?void 0:k.worktree.title)??null,needsSetup:!!R,busy:ne,treeEmpty:G,landsFrom:xt});return f.jsxs("div",{className:"center",ref:n,children:[f.jsx("div",{className:"center-area",style:{display:!(le&&!L)&&(_&&At||I&&he)?"none":void 0},children:f.jsxs("div",{className:"frames-wrap",children:[jt.map(N=>f.jsx("iframe",{ref:X=>{X?(Ne.current.set(N.id,X),je.current.set(N.id,new URL(Cp(N.id,N.port,b)).origin)):(Ne.current.delete(N.id),je.current.delete(N.id))},src:Cp(N.id,N.port,b),title:N.title,style:{display:N.id===tn&&!ee&&!D&&!x&&!L?"block":"none"}},N.id)),j?f.jsx(gz,{project:j}):f.jsxs(f.Fragment,{children:[D&&f.jsx(fz,{pending:D},D.id),E&&k&&!D&&f.jsx(dz,{active:k},k.worktree.id),ee&&!D&&!E&&f.jsx(vz,{repo:ee,onClose:O?void 0:()=>r({a:"close"})},`${ee.id}:${JSON.stringify(ee.config)}`),Tt&&!ee&&!D&&!zt&&f.jsx(az,{row:Tt}),zt&&!ee&&!D&&f.jsx(gu,{placement:"centre",archived:zt},zt.id),!Xe&&!Tt&&!zt&&!ee&&!D&&!E&&ce&&f.jsx(bz,{}),!Xe&&!Tt&&!zt&&!ee&&!D&&!E&&!ce&&(hn!==null?f.jsx(qo,{wide:!0,children:f.jsx("p",{className:"status-line",children:hn})}):L?f.jsx(gu,{placement:"centre"}):Kt?null:k&&f.jsx(iz,{worktree:k,log:Q}))]})]})}),_&&f.jsx(q1,{editor:_,height:At?"100%":tt>0?tt:"45%",full:At,onToggleFull:()=>bt(!At),onDragStart:Kn}),I&&g&&!zt&&f.jsx(AD,{worktreeId:g,height:he?"100%":nn>0?nn:"55%",full:he,onToggleFull:()=>lt(!he),onDragStart:lr},`design:${g}`),H&&g&&!zt&&f.jsx(ez,{worktreeId:g,opened:C,height:Qt,onDragStart:Pt},`term:${g}`),f.jsx(ix,{})]})}function jz({width:e}){const t=z(r=>r.layout.chat),n=yl();return f.jsx(gu,{placement:"dock",className:!t||n?"collapsed":void 0,width:e})}function Az(e,t){const n=[];return e&&(n.push(q0(e)),n.push({id:"copy-url",label:"copy URL",onClick:()=>Zt(e)})),Nn([n,[{id:"reload",label:"reload preview",key:ct("reload"),onClick:t.reload}]])}const Iz=520,cp=8;function Rz({winW:e,centre:t,leadRight:n,toolsLeft:r}){const i=t.right-t.left,a=Math.max(0,Math.min(Iz,Math.floor(e*.4),i-2*cp)),l=t.left+(i-a)/2,c=n+cp,d=r-cp-a,g=Math.max(Math.min(l,d),c);return{left:Math.round(g),width:a}}function Oz({center:e}){const t=e2(),n=g0(e),[r,i]=gy(),[a,l]=gy(),c=Rz({winW:t,centre:n,leadRight:i.right,toolsLeft:l.left}),d=Ve(),g=Ge(),k=Sn(),p=Wt("bar"),h=Vo(),v=vl(),b=z(V=>V.zen)&&!v,_=z(V=>V.layout.changes),E=z(V=>V.layout.chat),j=yl(),x=z(V=>V.layout.design),H=z(V=>{var K;return((K=V.overlay)==null?void 0:K.kind)==="keys"}),B=zz(),re=(h==null?void 0:h.worktree.id)??null,F=z(V=>V.archivedPage!==null),C=!!h&&uh(h)&&!F,L=z(V=>V.chatSide)==="left",I=!j&&f.jsx(Dt,{icon:"branch",label:"Changes panel",hint:ct("changes"),tone:"chrome",on:_,onClick:()=>d({a:"toggle-changes"})}),Z=!j&&!v&&f.jsx(Dt,{icon:"chat",label:"Chat panel",hint:ct("composer"),tone:"chrome",on:E,onClick:()=>d({a:"toggle-chat"})});return f.jsxs("div",{className:"top-bar",children:[b&&f.jsx("span",{className:"bar-zen-title",children:(h==null?void 0:h.worktree.title)??"Toyon"}),f.jsxs("span",{className:"bar-lead",ref:r,children:[L?Z:I,f.jsx($z,{}),B&&f.jsx(Vu,{icon:"download","data-tip":"Install Toyon as an app (own window, dock icon)",onClick:()=>void B.prompt(),children:"install app"}),f.jsx(Pz,{}),f.jsx(Lz,{})]}),!v&&f.jsx(Mz,{worktreeId:re,repoId:(h==null?void 0:h.repoId)??null,ready:C,left:c.left,width:c.width}),f.jsx("span",{className:"bar-grow"}),f.jsxs("span",{className:"bar-tools",ref:a,children:[f.jsx(Dz,{}),f.jsx(Dt,{icon:"settings",label:"Settings & shortcuts",hint:ct("keys"),tone:"chrome",on:H,"aria-controls":"keys-help","aria-expanded":H,onClick:()=>d({a:"toggle",overlay:{kind:"keys"}}),...p.contextMenu(()=>T1(k.getState(),{sock:g,dispatch:d}))}),!j&&!v&&f.jsx(Dt,{icon:"palette",label:"Design system",hint:ct("design"),tone:"chrome",on:x,onClick:()=>d({a:"toggle-design"})}),L?I:Z,!v&&f.jsx(Dt,{icon:"zen",className:"bar-zen",label:"Full-bleed preview",hint:ct("zen"),tone:"chrome",on:b,onClick:()=>d({a:"toggle-zen"})})]})]})}function $z(){const e=Ve(),t=Ge(),n=qs(),r=z(g=>g.repos),i=Wt("bar"),a=()=>Nn([[{id:"project",label:r.length>1?"switch project…":"open project…",key:ct("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?Wu(n,n.id,{sock:t,dispatch:e}):[]]),l=z(g=>{var k;return((k=g.overlay)==null?void 0:k.kind)==="projects"&&g.overlay.form==="pill"}),c=z(g=>g.heard),d=z(g=>g.newProject!==null);return f.jsxs("span",{className:"bar-project",children:[f.jsx($e,{tone:"chrome",className:"bar-pill",on:l,...Et(r.length>1?"Switch project":"Open a project",ct("project")),onClick:()=>e({a:"toggle",overlay:{kind:"projects",form:"pill"}}),...i.contextMenu(a),children:f.jsx("span",{className:"bar-project-name",children:d?"new project":(n==null?void 0:n.name)??(c?"open project":"")})}),l&&f.jsx(Vh,{form:"pill"})]})}function Mz({worktreeId:e,repoId:t,ready:n,left:r,width:i}){const a=It(e,"page").url,l=I1(a),c=Ve(),d=z(b=>{var _;return((_=b.overlay)==null?void 0:_.kind)==="routes"}),g=()=>{n&&e&&t&&!d&&c({a:"open",overlay:{kind:"routes"}})};ft([e,n],()=>{d&&c({a:"close"})});const p=Wt("bar").contextMenu(()=>n?Az(a,{reload:()=>e&&Rt.post(e,{type:"reload"})}):[]),h=z(b=>b.picking),v=hh();return f.jsxs("div",{className:"bar-center",style:{left:r,width:i},children:[f.jsx(Dt,{icon:"back",label:"Back",hint:ct("back"),disabled:!n,onClick:()=>e&&Rt.post(e,{type:"back"}),...p}),f.jsx(Dt,{icon:"forward",label:"Forward",hint:ct("forward"),disabled:!n,onClick:()=>e&&Rt.post(e,{type:"forward"}),...p}),f.jsx(Dt,{icon:"reload",label:"Reload preview",hint:ct("reload"),disabled:!n,onClick:()=>e&&Rt.post(e,{type:"reload"}),...p}),f.jsxs("span",{className:"bar-route",children:[f.jsx(Go,{className:"bar-path",value:n?l:"",readOnly:!0,disabled:!n,placeholder:n?"/":"",onMouseDown:b=>{b.button===0&&b.preventDefault()},onClick:g,onFocus:g,spellCheck:!1,...Et("Go to a page",ct("routes"))}),d&&n&&e&&t&&f.jsx($4,{worktreeId:e,repoId:t,url:a},e)]}),f.jsx(Dt,{icon:"inspect",label:"Pick an element to open its code",hint:ct("inspect"),also:{text:"Add an element to chat",key:ct("pick")},on:h==="code",disabled:!n||!v,onClick:()=>v&&il(v,h,c,"code")})]})}function Vu({icon:e,busy:t,children:n,...r}){return f.jsxs($e,{disabled:t,...r,children:[!t&&f.jsx(Ct,{name:e,className:"icon-inline"}),f.jsx("span",{className:Ke(t&&"live-text"),children:n})]})}function Pz(){const e=z(c=>c.self),t=z(c=>c.repos),n=Ge(),r=z(c=>{var d;return((d=c.update)==null?void 0:d.restarting)!=null}),i=Y1(e,t);if(!i||!e||r)return null;const a=i.busy?"rebuilding":i.build==="rebuild"?"rebuild Toyon":i.build??"restart Toyon",l=()=>n==null?void 0:n.send(i.build?{t:"run-after-land",repoId:e.repoId}:{t:"restart-daemon"});return f.jsx(Vu,{icon:"reload",busy:i.busy,onClick:l,...Et(i.text,void 0,{detail:i.detail}),children:a})}function Lz(){const e=z(r=>r.update),t=Ge(),n=EL(e);return n?f.jsx(Vu,{icon:"reload",busy:n.busy,onClick:()=>{n.retry&&(t==null||t.send({t:"update-now"}))},...Et(n.text),children:n.word}):null}function Dz(){const e=Ve(),t=z(a=>a.remote!==null&&a.frame==="desk"),n=z(a=>a.paired),r=z(a=>{var l;return((l=a.overlay)==null?void 0:l.kind)==="pair"});if(!t)return null;const i=()=>e({a:"toggle",overlay:{kind:"pair"}});return n?f.jsx(Dt,{icon:"phone",label:"Open on your phone",tone:"chrome",on:r,"aria-expanded":r,onClick:i}):f.jsx(Vu,{icon:"phone","aria-expanded":r,onClick:i,...Et("Scan a code with your phone to open this machine there, signed in"),children:"open on phone"})}function zz(){const[e,t]=T.useState(null);return T.useEffect(()=>{if(Du())return;const n=i=>{i.preventDefault(),t(i)},r=()=>t(null);return window.addEventListener("beforeinstallprompt",n),window.addEventListener("appinstalled",r),()=>{window.removeEventListener("beforeinstallprompt",n),window.removeEventListener("appinstalled",r)}},[]),e}function Fz(e,t,n){return t==="left"?n-e.left:e.right-n}const Bz="input, textarea, [contenteditable], .monaco-editor, .xterm, iframe";function Uz(){const e=Sn(),t=Ve(),n=Ge(),r=yl(),i=Xi(),a=vl(),l=z(R=>R.zen)&&!a,c=Qi(),d=z(R=>R.layout.changes)&&!r,g=z(R=>R.layout.chat)&&!r&&!a&&!c,k=z(R=>R.chatSide),p=z(R=>R.railOpen),[h,v]=no(dt.changesWidth,220,R=>R?Tc(Number(R),220):void 0),[b,_]=no(dt.chatWidth,380,R=>R?Tc(Number(R),380):void 0),[E,j]=no(dt.railWidth,280,R=>R?Tc(Number(R),280):void 0),x=(R,M,G)=>{const ne=M.classList.contains("left")?"left":"right",O=ne==="left"?M.previousElementSibling:M.nextElementSibling;return O?Tc(Fz(O.getBoundingClientRect(),ne,R.clientX),G):null},H=Ms((R,M)=>x(R,M,220),v),B=Ms((R,M)=>x(R,M,380),_),re=Ms((R,M)=>x(R,M,280),j),[F,C]=T.useState(null),I=Wt("app").contextMenu(()=>N1(e.getState(),{sock:n,dispatch:t})),Z=f.jsx(cb,{width:h}),V=!a&&!c&&f.jsx(jz,{width:b}),K=!r&&f.jsx(ax,{width:E}),le=R=>!r&&p&&f.jsx("div",{className:`dock-resize ${R}`,onPointerDown:re}),de=k==="left",Q=de?{dock:V,open:g,drag:B}:{dock:Z,open:d,drag:H},ce=de?{dock:Z,open:d,drag:H}:{dock:V,open:g,drag:B};return f.jsxs("div",{className:Ke("app",l&&"zen"),"data-chat-side":k,"data-touch":i||void 0,"data-hover":!i||void 0,onContextMenu:R=>{R.defaultPrevented||R.target instanceof Element&&R.target.closest(Bz)||I.onContextMenu(R)},children:[f.jsx($0,{}),f.jsx(B0,{}),f.jsx(Oz,{center:F}),f.jsxs("div",{className:"docks",children:[de&&K,de&&le("left"),Q.dock,Q.open&&f.jsx("div",{className:"dock-resize left",onPointerDown:Q.drag}),f.jsx(Cz,{onRoot:C}),ce.open&&f.jsx("div",{className:"dock-resize right",onPointerDown:ce.drag}),ce.dock,!de&&le("right"),!de&&K]})]})}function Hz(e){return e.altKey?"Alt":e.ctrlKey?"Control":e.metaKey?"Meta":null}function Zz(e,t){return t==="Alt"?e.altKey:t==="Control"?e.ctrlKey:e.metaKey}const Wz=200,Kz={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};function Gz(e,t=Kz){let n=null,r=!1,i=null;const a=()=>{r||(r=!0,e(!0))},l=()=>{i!==null&&(t.clear(i),i=null)},c=()=>{l(),n=null,r&&(r=!1,e(!1))};return{press(d){const g=n!==null;n=Hz(d),l(),n&&(g?a():i=t.set(()=>{i=null,a()},Wz))},keyup(d){n&&d===n&&c()},mods(d){n&&!Zz(d,n)&&c()},end:c}}function Vz(e,t,n,r){if(!n)return null;const i=e.findIndex(d=>d.id===n);if(i>=0){const d=e[(i+r+e.length)%e.length];return d&&d.id!==n?{activate:d.id}:null}const a=t.findIndex(d=>d.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 La=e=>{var t;return!!((t=document.activeElement)!=null&&t.closest(e))},qz=new Set(["design","new","routes","chats"]),Yz=new Set(["reload","back","forward"]),Qz=new Set(["project","commands","keys","zen"]);function Xz(){const e=Sn(),t=Ge();T.useEffect(()=>{const n=Gz(g=>e.dispatch({a:"rail-peek",on:g})),r=n.end,i=g=>{e.getState().railOpen||n.press(g)},a=g=>n.keyup(g.key),l=g=>n.mods(g),c=()=>{var h,v;const g=e.getState(),p=((v=(h=document.activeElement)==null?void 0:h.closest("[data-pane]"))==null?void 0:v.dataset.pane)??(g.layout.term?"terminal":g.editor?"editor":g.layout.design?"design":null);p==="terminal"?e.dispatch({a:"toggle-terminal"}):p==="editor"?e.dispatch({a:"close-editor"}):p==="design"&&e.dispatch({a:"toggle-design"})},d=g=>{var _,E,j,x;l(g);const k=e.getState(),{dispatch:p}=e,h=H=>{const B=document.activeElement,re=!B||B===document.body||!!B.closest(".rail, .chat-input");p({a:"activate",id:H}),re&&p({a:"walked"})},v=ow(g,{guest:!!((_=document.activeElement)!=null&&_.closest(".xterm"))});if(!(k.zen&&!ro(k)&&!k.overlay&&!k.picking&&!(v&&kE.has(v.id))||(v==null?void 0:v.id)==="close"&&!Du()||(E=document.activeElement)!=null&&E.closest(".monaco-editor")&&v&&(g.altKey||qz.has(v.id)))&&!(v&&iw(v.id).textKeeps&&wE(document.activeElement))&&!(v&&Yz.has(v.id)&&!(za(k)&&nu(k)))){if(v){if(g.preventDefault(),k.newProject&&!Qz.has(v.id))return;switch(v.id){case"worktree":{const H=vE(v.digit,k.visible.length),B=H===null?void 0:k.visible[H];B&&h(B.id);break}case"wt-prev":case"wt-next":{const H=Vz(k.visible,k.visibleDiscovered,k.activeId,v.id==="wt-next"?1:-1);H&&h(H.activate),i(g);break}case"wt-unseen-prev":case"wt-unseen-next":{const H=zh(k.visible,k.activeId,v.id==="wt-unseen-next"?1:-1);H&&h(H.activate),i(g);break}case"mark-unread":k.activeId&&!k.draft&&k.visible.some(H=>H.id===k.activeId)&&tb(t,p,k.activeId);break;case"new":p({a:"open-draft"});break;case"project":p({a:"toggle",overlay:{kind:"projects",form:"center"}});break;case"quick-open":((j=k.overlay)==null?void 0:j.kind)==="quick-open"?p({a:"close"}):k.activeId&&p({a:"open",overlay:{kind:"quick-open"}});break;case"routes":((x=k.overlay)==null?void 0:x.kind)==="routes"?p({a:"close"}):nu(k)&&p({a:"open",overlay:{kind:"routes"}});break;case"reload":case"back":case"forward":{const H=za(k);H&&Rt.post(H,{type:v.id});break}case"pick":case"inspect":{const H=za(k);H&&il(H,k.picking,p,v.id==="pick"?"chat":"code");break}case"search":k.activeId&&p({a:"toggle",overlay:{kind:"search"}});break;case"refs":k.activeRepoId&&p({a:"toggle",overlay:{kind:"refs"}});break;case"chats":k.activeRepoId&&p({a:"toggle",overlay:{kind:"chats"}});break;case"commands":p({a:"toggle",overlay:{kind:"commands"}});break;case"zen":p({a:"toggle-zen"});break;case"close":!(k.zen&&!ro(k))&&!k.overlay&&c();break;case"changes":p(k.layout.changes&&Fs(k)==="changes"&&La(".changes-list")?{a:"toggle-changes"}:{a:"focus-changes",tab:"changes"});break;case"files":p(k.layout.changes&&Fs(k)==="files"&&La(".tree")?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"});break;case"panel-tab-prev":case"panel-tab-next":if(Iu(k))break;p(k.layout.changes?{a:"focus-changes",tab:$I(k,v.id==="panel-tab-next"?1:-1)}:{a:"focus-changes"});break;case"composer":p(k.layout.chat&&!ro(k)&&!k.archivedPage&&La(".chat-input")?{a:"toggle-chat"}:{a:"focus-chat"});break;case"rail":p(k.railOpen&&La(".rail-list")?{a:"toggle-rail"}:{a:"focus-rail"});break;case"keys":p({a:"toggle",overlay:{kind:"keys"}});break;case"terminal":p(k.layout.term&&La(".xterm")?{a:"toggle-terminal"}:{a:"focus-terminal"});break;case"design":p({a:"toggle-design"});break;case"term-tab":{const H=k.rows.find(C=>C.id===k.activeId);if(!H)break;const B=wo(k,k.activeId).termStream;if(H.login&&B===Ko)break;const re=[to,...H.login?[Ko]:[],...H.procs.map(C=>C.name)],F=re.indexOf(B);p({a:"term-stream",id:H.id,stream:re[(F+1)%re.length]??to});break}}}else if(g.key==="Escape")if(k.choosingFolder)t==null||t.send({t:"cancel-folder"}),p({a:"choosing-folder",v:!1});else if(k.overlay)p({a:"close",back:s0(k.overlay)});else if(k.newProject)k.newProject.phase==="editing"&&p({a:"close-new-project"});else if(k.picking){const H=za(k);H&&Rt.post(H,{type:"pick-cancel"}),p({a:"set-picking",v:!1})}else k.archivedPage?p({a:"close-archived"}):k.activeImportId?p({a:"watch-import",id:null}):c()}};return window.addEventListener("keydown",d),window.addEventListener("keyup",a),window.addEventListener("pointermove",l),window.addEventListener("pointerdown",l),window.addEventListener("blur",r),()=>{window.removeEventListener("keydown",d),window.removeEventListener("keyup",a),window.removeEventListener("pointermove",l),window.removeEventListener("pointerdown",l),window.removeEventListener("blur",r),r()}},[e,t]),T.useEffect(()=>{const n=r=>{if(r.key!=="Alt"&&r.key!=="Shift")return;const i=e.getState();i.picking&&i.activeId&&Rt.post(i.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 Jz=3,e3=2e3,t3=200,n3=5e3;function r3(){const e=Sn(),t=Ve(),n=Ge(),r=Vs(),i=z(R=>R.activeRepoId),a=Vo(),l=fh(),c=z(R=>R.connected),d=z(R=>R.daylight),g=z(R=>{var M;return((M=R.daylight)==null?void 0:M.until)??0}),k=Qi(),p=z(R=>R.railOpen),h=z(R=>R.chatSide),v=z(R=>R.layouts),b=z(R=>R.lastActive),_=z(R=>R.discoveredOpen),E=z(R=>R.archivedOpen),j=z(R=>R.treeOpen),x=Ru(),H=z(R=>R.previewTheme!==null),B=z(R=>R.openUrl),re=y0();T.useEffect(()=>ol.install(window),[]);const F=T.useRef([]);T.useEffect(()=>{if(!n||!c||!r)return;const R=[r,...F.current.filter(M=>M!==r)];for(const M of R.splice(Jz))n.send({t:"unsubscribe",worktreeId:M});F.current.includes(r)||n.send({t:"subscribe",worktreeId:r}),F.current=R},[r,c,n]),T.useEffect(()=>{if(!(!n||!c))for(const R of F.current)n.send({t:"subscribe",worktreeId:R})},[c,n]);const C=T.useRef(void 0);T.useEffect(()=>{if(!n||!c)return;let R;const M=()=>{const O=document.visibilityState==="visible"?r:null;n.send({t:"view",worktreeId:O}),C.current=O},G=()=>{clearTimeout(R),R=setTimeout(M,t3)};C.current===void 0||C.current===r||document.visibilityState!=="visible"?M():G();const ne=()=>document.visibilityState==="visible"?G():M();return document.addEventListener("visibilitychange",ne),()=>{clearTimeout(R),document.removeEventListener("visibilitychange",ne)}},[r,c,n]);const L=(k==null?void 0:k.id)??null;T.useEffect(()=>{if(!(!n||!c||!L))return n.send({t:"subscribe",worktreeId:L}),()=>n.send({t:"unsubscribe",worktreeId:L})},[L,c,n]),T.useEffect(()=>{const R=new Set(re.map(G=>G.id)),M=F.current.filter(G=>!R.has(G));if(M.length!==0&&(F.current=F.current.filter(G=>R.has(G)),!(!n||!c)))for(const G of M)n.send({t:"unsubscribe",worktreeId:G})},[re,c,n]);const I=(k==null?void 0:k.title)??(l==null?void 0:l.name)??null;T.useEffect(()=>{document.title=I?`${I} · Toyon`:"Toyon"},[I]);const Z=!!(a!=null&&a.unseen),V=z(R=>R.unreadHold!==null&&R.unreadHold===R.activeId);T.useEffect(()=>{if(!n||!r||!Z||V)return;let R;const M=()=>document.visibilityState==="visible"&&document.hasFocus(),G=()=>{clearTimeout(R),M()&&(R=setTimeout(()=>{M()&&n.send({t:"seen",worktreeId:r})},e3))},ne=()=>clearTimeout(R);return G(),window.addEventListener("focus",G),window.addEventListener("blur",ne),()=>{ne(),window.removeEventListener("focus",G),window.removeEventListener("blur",ne)}},[n,r,Z,V]);const K=T.useRef(0);T.useEffect(()=>{if(!n||!c||!i)return;const R=()=>{Date.now()-K.current<n3||(K.current=Date.now(),n.send({t:"refresh-git",repoId:i}))};return window.addEventListener("focus",R),()=>window.removeEventListener("focus",R)},[n,c,i]),T.useEffect(()=>{lx(x,{remember:!H}),Rt.broadcast(cx(x))},[x,H]),T.useEffect(()=>TD(R=>t({a:"system-dark",v:R})),[t]);const le=T.useCallback(()=>{n==null||n.send({t:"zone",tz:Intl.DateTimeFormat().resolvedOptions().timeZone})},[n]);T.useEffect(()=>{if(!c)return;le();const R=()=>{document.visibilityState==="visible"&&le()};return document.addEventListener("visibilitychange",R),()=>document.removeEventListener("visibilitychange",R)},[c,le]),T.useEffect(()=>{if(!c||g<=Date.now())return;const R=setTimeout(le,g-Date.now()+1e3);return()=>clearTimeout(R)},[c,g,le]),T.useEffect(()=>{d&&d.until>0&&ND(d)},[d]),T.useEffect(()=>{if(r)try{localStorage.setItem(dt.active,r)}catch{}},[r]),T.useEffect(()=>{if(i)try{localStorage.setItem(dt.repo,i)}catch{}},[i]),T.useEffect(()=>{try{localStorage.setItem(dt.rail,p?"1":"0")}catch{}},[p]),T.useEffect(()=>{try{localStorage.setItem(dt.chatSide,h)}catch{}},[h]),T.useEffect(()=>{try{localStorage.setItem(dt.layouts,JSON.stringify(v))}catch{}},[v]),T.useEffect(()=>{try{localStorage.setItem(dt.lastActive,JSON.stringify(b))}catch{}},[b]),T.useEffect(()=>{try{localStorage.setItem(dt.discoveredOpen,JSON.stringify(_))}catch{}},[_]),T.useEffect(()=>{try{localStorage.setItem(dt.archivedOpen,JSON.stringify(E))}catch{}},[E]),T.useEffect(()=>{try{localStorage.setItem(dt.treeOpen,JSON.stringify(j))}catch{}},[j]),Xz(),M2();const de=T.useRef(null);T.useEffect(()=>{!B||de.current===B||(de.current=B,window.open(B,"_blank"),t({a:"opened-url"}))},[B,t]);const Q=T.useRef(null);return ft([r],()=>{var q,Te,Ne,je;const R=Q.current;if(Q.current=r,!R||!r||R===r)return;const M=e.getState(),G=re.find(Re=>Re.id===R),ne=re.find(Re=>Re.id===r),O=(Te=(q=G==null?void 0:G.worktree)==null?void 0:q.variant)==null?void 0:Te.group;if(!O||((je=(Ne=ne==null?void 0:ne.worktree)==null?void 0:Ne.variant)==null?void 0:je.group)!==O)return;const ee=Re=>{var Ze;try{const st=(Ze=M.local[Re])==null?void 0:Ze.page.url;return st?new URL(st).pathname+new URL(st).search:"/"}catch{return"/"}},D=ee(R);D!==ee(r)&&Rt.post(r,{type:"navigate",path:D})}),z(R=>R.frame)==="phone"?f.jsx(bD,{}):f.jsx(Uz,{})}const o3=640,i3=1e3,yx=`(max-width: ${o3}px), ((hover: none) and (max-width: ${i3}px))`,vx="(hover: none)",s3=()=>{var e;return(e=window.matchMedia)!=null&&e.call(window,yx).matches?"phone":"desk"},a3=()=>{var e;return((e=window.matchMedia)==null?void 0:e.call(window,vx).matches)??!1};function l3(e){const t=(i,a)=>{var d;const l=(d=window.matchMedia)==null?void 0:d.call(window,i);if(!l)return()=>{};const c=g=>a(g.matches);return l.addEventListener("change",c),()=>l.removeEventListener("change",c)},n=t(yx,i=>e.dispatch({a:"frame",v:i?"phone":"desk"})),r=t(vx,i=>e.dispatch({a:"touch",v:i}));return()=>{n(),r()}}const Gp="toyonDepth";function Gv(e){return e.frame!=="phone"||!e.heard?null:e.screen!=="home"&&(Yt(e,e.activeId)!==null||xi(e)!==null)?e.editor?2:1:0}const up=e=>{const t=e&&typeof e=="object"?e[Gp]:void 0;return typeof t=="number"?t:null};function c3(e,t=window){const n=t.history;let r=up(n.state)??0;up(n.state)===null&&n.replaceState({[Gp]:0},"");const i=()=>{const c=Gv(e.getState());if(!(c===null||c===r)){if(c>r)for(let d=r+1;d<=c;d++)n.pushState({[Gp]:d},"");else n.go(c-r);r=c}},a=c=>{r=up(c.state)??0;const d=e.getState(),g=Gv(d);g===null||g===r||(g>r?e.dispatch(r===0?{a:"screen",to:"home"}:{a:"screen",to:d.screen}):g===0&&d.activeId&&e.dispatch({a:"screen",to:"chat"}),i())};t.addEventListener("popstate",a);const l=e.subscribe(i);return i(),()=>{t.removeEventListener("popstate",a),l()}}const $c=new Map,u3={on(e,t){let n=$c.get(e);return n||(n=new Set,$c.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&$c.delete(e)}},deliver(e){for(const t of $c.get(sE(e.worktreeId,e.stream))??[])t(e)}},d3=800;function f3(e,t,n,r){if(r.version===e.version)return"same";const i=t===e.text&&n===null;return r.version===null?i?"gone":"conflict":r.after===t||r.after===n?"adopt":i?"apply":"conflict"}const ho=e=>`${e.worktreeId}
236
+ ${e.ref??""}
237
+ ${e.path}`;class p3{constructor(t){mt(this,"files",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(),d=t;t=c,this.follow(d,c)}),r=()=>{const c=this.d.store.getState().editor;c&&this.refresh(ho(c))};(a=this.d.win)==null||a.addEventListener("focus",r);const i=()=>{for(const[c,d]of this.files)d.timer!==void 0&&this.saveNow(c)};return(l=this.d.win)==null||l.addEventListener("pagehide",i),()=>{var c,d;n(),(c=this.d.win)==null||c.removeEventListener("focus",r),(d=this.d.win)==null||d.removeEventListener("pagehide",i)}}receive(t){const n=this.files.get(ho(t)),r=n==null?void 0:n.out;!n||!r||r.seq!==t.seq||(n.out=null,t.t==="file-read"?this.read(n,t):r.write!==void 0&&this.written(n,r.write,t),this.next(n))}bind(t){const n=ho(t);return{attach:r=>this.attach(n,r),edited:()=>this.edited(n),saveNow:()=>this.saveNow(n)}}reload(t){var i;const n=this.files.get(ho(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"}):(i=n.buffer)==null||i.replace(r.after),this.next(n))}keepMine(t){const n=this.files.get(ho(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){t.connected&&!n.connected&&this.dropped();const r=n.editor,i=t.editor;if(i&&(!r||ho(i)!==ho(r))&&this.closed(ho(i)),r&&(!i||i.seq!==r.seq)&&this.opened(r),!t.connected&&n.connected)for(const a of this.files.values())a.reread=!0,this.next(a);else r&&i&&i.seq===r.seq&&wo(t,r.worktreeId).git!==wo(n,r.worktreeId).git&&this.refresh(ho(r))}opened(t){const n=ho(t);let r=this.files.get(n);r||(r={file:{worktreeId:t.worktreeId,path:t.path,...t.ref?{ref:t.ref}:{}},open:!0,base:null,out:null,pending:null,reread:!1,writable:!1,conflict:null,buffer:null,timer:void 0},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.files.values())t.out&&(t.out.write!==void 0&&(t.pending??(t.pending=t.out.write)),t.out=null,t.reread=!0)}next(t){var a;if(t.out||!this.d.store.getState().connected)return;const{worktreeId:n,path:r,ref:i}=t.file;if(t.reread){t.reread=!1;const l=iu();t.out={seq:l},this.d.send({t:"read-file",worktreeId:n,path:r,ref:i,seq:l});return}if(t.pending!==null&&t.base&&t.pending===t.base.text&&(t.pending=null),t.pending!==null&&t.writable&&!t.conflict&&!i){const l=t.pending,c=iu();t.pending=null,t.out={seq:c,write:l},this.d.send({t:"write-file",worktreeId:n,path:r,content:l,base:((a=t.base)==null?void 0:a.version)??null,seq:c});return}!t.open&&!t.buffer&&t.pending===null&&!t.conflict&&this.files.delete(ho(t.file))}read(t,n){var h,v;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:i,after:a,version:l,writable:c,binary:d,tooLarge:g}=n;t.writable=c,t.open&&this.d.store.dispatch({a:"editor-read",file:r,disk:{before:i,after:a,version:l,writable:c,binary:d,tooLarge:g}});const k={after:t.buffer?t.buffer.normalize(a):a,version:l};if(!t.base){t.base={text:k.after,version:l};return}const p=((h=t.buffer)==null?void 0:h.text())??t.pending??t.base.text;switch(f3(t.base,p,t.pending,k)){case"same":break;case"adopt":t.base={text:k.after,version:l};break;case"apply":(v=t.buffer)==null||v.replace(k.after),t.base={text:k.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,k);return}this.setConflict(t,null)}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)},d3))}saveNow(t){const n=this.files.get(t);if(!(n!=null&&n.buffer))return;this.cancelTimer(n);const r=n.buffer.text();r.length>BE||(n.pending=r,this.next(n))}cancelTimer(t){t.timer!==void 0&&(this.d.timers.clear(t.timer),t.timer=void 0)}}window.__toyonShell=!0;XI();const wx=xD();lx(wx);function Wo(e,t){try{return e.getItem(t)}catch{return null}}function h3(){const e={};try{const t=JSON.parse(Wo(localStorage,dt.layouts)??"{}");if(!t||typeof t!="object")return e;for(const[n,r]of Object.entries(t))NI(r)&&(e[n]=r)}catch{}return e}function m3(){const e={};try{const t=JSON.parse(Wo(localStorage,dt.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 Vv(e){const t={};try{const n=JSON.parse(Wo(localStorage,e)??"{}");if(!n||typeof n!="object")return t;for(const[r,i]of Object.entries(n))typeof i=="boolean"&&(t[r]=i)}catch{}return t}function g3(){const e={};try{const t=JSON.parse(Wo(localStorage,dt.treeOpen)??"{}");if(!t||typeof t!="object")return e;for(const[n,r]of Object.entries(t))Array.isArray(r)&&r.every(i=>typeof i=="string")&&r.length>0&&(e[n]=r)}catch{}return e}const k3=400,y3=2e3;function v3(){const e=new Map,t=new Map,n=i=>{var l,c;clearTimeout((l=t.get(i))==null?void 0:l.timer),t.delete(i);const a=Wr.getState().local[i];!a||((c=a.mark)==null?void 0:c.by)==="walk"||(e.get(i)??"")!==a.draft&&(e.set(i,a.draft),pl.send({t:"set-draft",boxId:i,text:a.draft,clientId:Wr.getState().clientId}))},r=()=>{for(const i of[...t.keys()])n(i)};return Wr.subscribe(()=>{var i;for(const[a,l]of Object.entries(Wr.getState().local)){if(((i=l.mark)==null?void 0:i.by)==="walk"||(e.get(a)??"")===l.draft)continue;if(!l.draft){n(a);continue}const c=t.get(a);if((c==null?void 0:c.text)===l.draft)continue;clearTimeout(c==null?void 0:c.timer);const d=(c==null?void 0:c.since)??Date.now(),g=Math.max(0,Math.min(k3,d+y3-Date.now()));t.set(a,{text:l.draft,timer:setTimeout(n,g,a),since:d})}}),window.addEventListener("focusout",r),window.addEventListener("pagehide",r),{hello(i){e.clear();for(const[a,l]of Object.entries(i))e.set(a,l)},heard(i,a){return t.has(i)?!1:(e.set(i,a),!0)}}}function w3(){const e=Wo(sessionStorage,dt.client);if(e)return e;const t=Math.random().toString(36).slice(2,10);try{sessionStorage.setItem(dt.client,t)}catch{}return t}const Wr=VI(TI({cached:wx,systemDark:_D(),daylight:SD(),storedActive:Wo(localStorage,dt.active),storedRepo:Wo(localStorage,dt.repo),storedRailOpen:Wo(localStorage,dt.rail)==="1",storedChatSide:Wo(localStorage,dt.chatSide)==="right"?"right":"left",storedLayouts:h3(),storedLastActive:m3(),storedDiscoveredOpen:Vv(dt.discoveredOpen),storedArchivedOpen:Vv(dt.archivedOpen),storedTreeOpen:g3(),clientId:w3(),frame:s3(),touch:a3()}));l3(Wr);c3(Wr);let Wc=null;const pl=new yR(e=>{if(e.t==="hello"){if(Wc!==null&&(e.version!==Wc||e.protocol!==hp)){pl.dispose(),window.location.reload();return}if(e.protocol!==hp){Wr.dispatch({a:"incompatible"}),pl.dispose();return}Wc=e.version,qv.hello(e.drafts)}if(!(e.t==="draft"&&e.clientId!==Wr.getState().clientId&&!qv.heard(e.boxId,e.text))){if(KE(e)){u3.deliver(e);return}if(GE(e)){qh.receive(e);return}Wr.dispatch({a:"server",msg:e})}},(e,t)=>Wr.dispatch({a:"connected",v:e,failure:t})),qh=new p3({store:Wr,send:e=>pl.send(e),timers:{set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)},win:window});qh.start();window.addEventListener("vite:preloadError",iL);const qv=v3(),b3=(window.toyonBoot??Promise.resolve(null)).then(e=>{const t=e;t&&typeof t=="object"&&t.t==="hello"&&t.protocol===hp&&(Wc??(Wc=t.version),Wr.dispatch({a:"server",msg:t}))});b3.then(()=>bI.createRoot(document.getElementById("root")).render(f.jsx(mI.StrictMode,{children:f.jsx(Wh,{children:f.jsx(qI,{store:Wr,sock:pl,files:qh,children:f.jsx(r3,{})})})})));"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{});export{Bp as _,sh as a,_3 as b,u3 as c,sE as d,uI as h,f as j,ow as m,T as r,rI as s,ml as t,ft as u,ny as w};